Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp1186179lqt; Sat, 20 Apr 2024 04:37:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqcuRIe8CuNrDS6sMgTdKex+2Zg+9iX2CNWpZCFECubbbGrX2dIzrAHTNUBL81h9dBPwtlNEEO8OsxoAPE2AMwD3LaXs4NJQLJPq67ZQ== X-Google-Smtp-Source: AGHT+IELi7OudlSBCSp86+SmZCAhkkcXbiNHvqGgi/vWn0O7Fa535RJsLGakNsrn+eC69ru4W5t0 X-Received: by 2002:a17:90b:384c:b0:2a5:1fcf:efb7 with SMTP id nl12-20020a17090b384c00b002a51fcfefb7mr4498611pjb.21.1713613059257; Sat, 20 Apr 2024 04:37:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713613059; cv=pass; d=google.com; s=arc-20160816; b=NQCpenRHIgotwd3gCB592Ej0jrrAzyEkdpSEZ0YtusNhO9Hhl3c8Dw0uHTp0OPHG6i 1xV+GSQDG3MAFR6EWcGcQs8LIT21qrgrnN+dlhNSpOxT4h7uwIGP3pw64FOtIz5SPbrq Gi3MxA/8I5WPpbcYrOd9rjUSTJl2nNWeekZwD8g1ZlgYx0vplOwVBwPDqlgnO4nOn4K5 3okolCj69r1g8wR4+pX7g1qpqZCHBzlPdRF2iZIzpEHNf2i5RNtiHY9z5Rn/t8bGJNaa v7lDI7VgbX4JHqokQaL44SCZsaqtz+vvkSUqjdI9flO0J8LAn5CVOO9NzPJ3hsdFjsNc SFOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=kZ3BA7Ry6N4HO6TCLIUCUpzdBq47ZipFI737SQ3eAt4=; fh=h+8MDwOwzs+3DAl2pf9vwrBuPgCm6QWWZ6OL8hUd36c=; b=s11R7gNiFszDVvTlQCoFQvwvjUFMNHE+EHja9ylkdEksnqhyDeWAfxUsjjulvS+VTT rqnzrE9pGlh3Kgc24LLGXQ/swAHc1HKl/xktAM9Pa6Y81UuOxn3pEL6higr/QYaTRHgz VlGgEV5LH7s2zyk4S7N8r+QdNO6ah0JbjZ8DvyKVcStzSJ8TAuhxbO5n4KRS4vnsUVKo WFH27UXB3CURTahmUUkLI2eu4jYDrb8w+cSzELe8+4NfSr1FPqwLJY/kEbVrpakhwJrD HRW0eGHRrE7ZpEYmRDrW5zjZkkwV9YQjD6RdCY1crBWEyeBMej++2ZL2ibzCBtYLhbU3 DkwA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZSjH8xfY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-152254-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152254-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s5-20020a17090a2f0500b002a283b05fb3si4834104pjd.79.2024.04.20.04.37.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 04:37:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152254-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZSjH8xfY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-152254-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152254-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DBCB928175F for ; Sat, 20 Apr 2024 11:37:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9EDC229CF3; Sat, 20 Apr 2024 11:37:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZSjH8xfY" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB9CE205E3A; Sat, 20 Apr 2024 11:37:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713613051; cv=none; b=n6ZOBDaCtVBhTCqX7pPGggTJxIlzOnF5heXXO+o0OygBtl5dnfSNgfk7rnr0iaOS6m6ii0ixgOmIw0d8VyG0XdoCP9tpCm+6WAYVO+DyO96IGWp+xKN08GV3TpxfPeMuh3HlgGQLWIM6RFwACvdn3IONM4XQGxu39+Ozx8QgHco= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713613051; c=relaxed/simple; bh=mcbXPArX3W5bs/P2RSabEjC9+JVFSfDDDGwpIZwpHfE=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=EgdwT6e3ncfY9gSGTVmLwM5yAqdB5NkBU7bI2ITaozHIOwnigiQT9Y3LCl0K/ibq5omXFUAjmqQ+fEpVbfOswbzf55UfdBZ6dVyO6dm+SHksWe66v/5WH9cr6P0P1gfgIdoOXqo4eZKYkFXf3LagtlcFTGQphK2aYKe6WI8oUl4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZSjH8xfY; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 132DDC072AA; Sat, 20 Apr 2024 11:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713613051; bh=mcbXPArX3W5bs/P2RSabEjC9+JVFSfDDDGwpIZwpHfE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ZSjH8xfYL22lL0GdIKPSujIBpaCXmJdaf0KXyz8w4arA+m2zXxzM4Dlhjj8wwjt4y 7oFP3FCxgC33lyaasVfnskXH13U4srvxM44Nng94e76byoJgy0I2r0JxZEE1CcIL3h Lf7s1UtlktES/aJ00wtJZssO3x2hJzpzR6HBJxNqUl29naxWdAvndtnKnuuPaMMUPk FvrZbOpidXJ/or8dzgpzVC4xAxDHLpKkkpDT/DwRx83hHlW9VM/ZIZhbY7vvCnohw4 uOvZskWAv+qGxnK8kfPtSED6TQ/ht5W8Pq29ZmLW1bLnYn3aAttOuiU2kc1ZdVYgks 8DQfrWIKfMzYA== Received: from 82-132-232-8.dab.02.net ([82.132.232.8] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ry928-006LLL-2X; Sat, 20 Apr 2024 12:37:28 +0100 Date: Sat, 20 Apr 2024 12:37:25 +0100 Message-ID: <87zftoqn7u.wl-maz@kernel.org> From: Marc Zyngier To: Will Deacon Cc: Hector Martin , Catalin Marinas , Mark Rutland , Zayd Qumsieh , Justin Lu , Ryan Houdek , Mark Brown , Ard Biesheuvel , Mateusz Guzik , Anshuman Khandual , Oliver Upton , Miguel Luis , Joey Gouly , Christoph Paasch , Kees Cook , Sami Tolvanen , Baoquan He , Joel Granados , Dawei Li , Andrew Morton , Florent Revest , David Hildenbrand , Stefan Roesch , Andy Chiu , Josh Triplett , Oleg Nesterov , Helge Deller , Zev Weiss , Ondrej Mosnacek , Miguel Ojeda , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Asahi Linux Subject: Re: [PATCH 0/4] arm64: Support the TSO memory model In-Reply-To: <20240419165809.GA4020@willie-the-truck> References: <20240411-tso-v1-0-754f11abfbff@marcan.st> <20240411132853.GA26481@willie-the-truck> <28ab55b3-e699-4487-b332-f1f20a6b22a1@marcan.st> <20240419165809.GA4020@willie-the-truck> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 82.132.232.8 X-SA-Exim-Rcpt-To: will@kernel.org, marcan@marcan.st, catalin.marinas@arm.com, mark.rutland@arm.com, zayd_qumsieh@apple.com, ih_justin@apple.com, Houdek.Ryan@fex-emu.org, broonie@kernel.org, ardb@kernel.org, mjguzik@gmail.com, anshuman.khandual@arm.com, oliver.upton@linux.dev, miguel.luis@oracle.com, joey.gouly@arm.com, cpaasch@apple.com, keescook@chromium.org, samitolvanen@google.com, bhe@redhat.com, j.granados@samsung.com, dawei.li@shingroup.cn, akpm@linux-foundation.org, revest@chromium.org, david@redhat.com, shr@devkernel.io, andy.chiu@sifive.com, josh@joshtriplett.org, oleg@redhat.com, deller@gmx.de, zev@bewilderbeest.net, omosnace@redhat.com, ojeda@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Fri, 19 Apr 2024 17:58:09 +0100, Will Deacon wrote: > > On Thu, Apr 11, 2024 at 11:19:13PM +0900, Hector Martin wrote: > > On 2024/04/11 22:28, Will Deacon wrote: > > > * Some binaries in a distribution exhibit instability which goes away > > > in TSO mode, so a taskset-like program is used to run them with TSO > > > enabled. > > > > Since the flag is cleared on execve, this third one isn't generally > > possible as far as I know. > > Ah ok, I'd missed that. Thanks. > > > > In all these cases, we end up with native arm64 applications that will > > > either fail to load or will crash in subtle ways on CPUs without the TSO > > > feature. Assuming that the application cannot be fixed, a better > > > approach would be to recompile using stronger instructions (e.g. > > > LDAR/STLR) so that at least the resulting binary is portable. Now, it's > > > true that some existing CPUs are TSO by design (this is a perfectly > > > valid implementation of the arm64 memory model), but I think there's a > > > big difference between quietly providing more ordering guarantees than > > > software may be relying on and providing a mechanism to discover, > > > request and ultimately rely upon the stronger behaviour. > > > > The problem is "just" using stronger instructions is much more > > expensive, as emulators have demonstrated. If TSO didn't serve a > > practical purpose I wouldn't be submitting this, but it does. This is > > basically non-negotiable for x86 emulation; if this is rejected > > upstream, it will forever live as a downstream patch used by the entire > > gaming-on-Mac-Linux ecosystem (and this is an ecosystem we are very > > explicitly targeting, given our efforts with microVMs for 4K page size > > support and the upcoming Vulkan drivers). > > These microVMs sound quite interesting. What exactly are they? Are you > running them under KVM? > > Ignoring the mechanism for the time being, would it solve your problem > if you were able to run specific microVMs in TSO mode, or do you *really* > need the VM to have finer-grained control than that? If the whole VM is > running in TSO mode, then my concerns largely disappear, as that's > indistinguishable from running on a hardware implementation that happens > to be TSO. Since KVM has been mentioned a few times, I'll give my take on this. Since day 1, it was a conscious decision for KVM/arm64 to emulate the architecture, and only that -- this is complicated enough. Meaning that no implementation-defined features should be explicitly exposed to the guest. So I have no plan to expose any such feature for userspace to configure TSO or anything else of the sort. However, that doesn't preclude VMs from running in TSO mode if the HW is configured as such at boot time. From what I have understood, this is a per translation regime setting (EL1 and EL2 have separate knobs). So it should be possible to set ACTLR_EL1.TSO=1 from firmware (using the non-architected ACTLR_EL12 accessor), and let things work without touching anything else (KVM doesn't context switch this register and traps accesses to it). This would keep KVM out of the loop, the host side would be unaffected, and only VMs would pay the overhead of TSO. I appreciate that this is not the ideal situation, and very much an all-or-nothing approach. But that's what we can reasonably manage from an upstream perspective given the variability of the arm64 ecosystem. M. -- Without deviation from the norm, progress is not possible.