From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC41DC4332F for ; Wed, 13 Dec 2023 20:05:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51CBA6B0590; Wed, 13 Dec 2023 15:05:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A5BF6B0591; Wed, 13 Dec 2023 15:05:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3465D6B0592; Wed, 13 Dec 2023 15:05:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 205766B0590 for ; Wed, 13 Dec 2023 15:05:42 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F044FA015F for ; Wed, 13 Dec 2023 20:05:41 +0000 (UTC) X-FDA: 81562875282.15.60B3796 Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) by imf27.hostedemail.com (Postfix) with ESMTP id 22AA140021 for ; Wed, 13 Dec 2023 20:05:38 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=jJcnDy5b; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf27.hostedemail.com: domain of oliver.upton@linux.dev designates 95.215.58.186 as permitted sender) smtp.mailfrom=oliver.upton@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702497939; a=rsa-sha256; cv=none; b=SSM3HMPr64bM0DLUxHxAPpIER+vSO3GS1sSJMXNEzB33E4vcyisBQxYNYce6oNq6tr4mtI 09x1gHf7VpoVwStM671Dt5pjsz3NIwGVCPgmh5fN+s45qIlHuuQoY1qI8mUcA6e+/w2CRP bht2FsKCL5KKADtg6oc1FX9NdxpWa/k= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=jJcnDy5b; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf27.hostedemail.com: domain of oliver.upton@linux.dev designates 95.215.58.186 as permitted sender) smtp.mailfrom=oliver.upton@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702497939; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bs3RmWkkBEnHpfKuSLQmU1XdcllYwTl+oGw2E3qh8dc=; b=CJGTWBxuj9QIhnt51UiGwbZz4Mt3C27MJYmsHu8LnzP/rxK3D2ztwlAvV6RvfREECrVE5B 6AMqjkf8wlxJrvjYwJSVB4z7VBGqyrDym1sQKGUr9y3UvFKHSV+nfXTkGZhL/09ikawat8 9wmiLUFqohc3xjrd3ih6lTgDlTZ/Fmg= Date: Wed, 13 Dec 2023 20:05:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702497936; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bs3RmWkkBEnHpfKuSLQmU1XdcllYwTl+oGw2E3qh8dc=; b=jJcnDy5bHbUQZ++rOn61pjWjrjxub6x7tQGxN6Q/n2e8x8QqbvQBN0WMjqMDzS9KbV0iYs wCgSpmwEUbVv6YEq3zCdtU1qGuTE6IwHyJzcoTRQw4SP/Qsfm9Sz/cIkb2d4mN4aAQUtts tgUEit1z6/gIrWV69f2FgtcachFAZYI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Jason Gunthorpe Cc: Catalin Marinas , ankita@nvidia.com, maz@kernel.org, suzuki.poulose@arm.com, yuzenghui@huawei.com, will@kernel.org, alex.williamson@redhat.com, kevin.tian@intel.com, yi.l.liu@intel.com, ardb@kernel.org, akpm@linux-foundation.org, gshan@redhat.com, linux-mm@kvack.org, lpieralisi@kernel.org, aniketa@nvidia.com, cjia@nvidia.com, kwankhede@nvidia.com, targupta@nvidia.com, vsethi@nvidia.com, acurrid@nvidia.com, apopple@nvidia.com, jhubbard@nvidia.com, danw@nvidia.com, mochs@nvidia.com, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 2/2] kvm: arm64: set io memory s2 pte as normalnc for vfio pci devices Message-ID: References: <20231208164709.23101-1-ankita@nvidia.com> <20231208164709.23101-3-ankita@nvidia.com> <20231212181156.GO3014157@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231212181156.GO3014157@nvidia.com> X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 22AA140021 X-Stat-Signature: u37xpauoft9pf6ruyamb7u8ja83zyhdc X-HE-Tag: 1702497938-492663 X-HE-Meta: U2FsdGVkX1+4SFeWwCQLo5CjJZ727+ZV+zVw8QaurWOZbRAz0vG5GCM4Vg5lXhX1K0BOzIRB6oFLadZ1anfTcRBEyEKUOnsq56w03R6yqaFnEGTgZBABdBcynhHrSrGxyYnrf5pelaVcGOZQAxTibiP/21pV7W530OsVoJwYzn1lLDoEeefyl6NLpnfsE/Zo8ui1+EnhZcFbWw+RCQPae/4ruk5E7GNyaek4jbO+RhNkwszfcuKcHspVj+9hpdFyKFXYYBB4UJTI/BIzaS2/W66Q7SqRZrQNaqoSvWFgje4Gq+IUjOns4ifVrLbvUBDRAjM0nwvMtDX8IDal1OL3I57jkJWowjScSgaJpG9BC+SmRTCpINcjZ1YEHaEiuw2PEGdWW+zdRigb/hAgcJb7Opd5s7RGZQG3STAc0kbDQYN8sGbQ5or27J2m+tNt+bug/EBYGaLHbV1fQGBtz1yC9uhSBxTAnQ811Cl3lEB8FHgncGxhP61axKoYPJnZKV7k7+vn9L5K0bi3WXF6mQHT+8JJeWdCZgBITaaveG+gp4dwr10awZ8rqsgl3nYnNI3cc6W7Ow3fkn89A1syH+SE0+jI+4yX3WU7mBwr3JMZhBtxBpFyLO5/O5AvXd3ZyVPVhPNGFBe8cKch+pfZLCpT7Ns4/k5WykDtR8UJQ3oW7RAFAUx94t/zej5YctioTOC4Hdl3PvPpGmYgTIY5h6fPYmylyIJO5BsaVpbajgCxH3pnJhT9BcHhYpPsrt3xsijtWdLpspRuIJZO+aWt+wxF0dvvyhckpqgMN0I7sSbqs2MPgUS8rd7+k6cQRfnYxu6lbqr7FUabyy7a6EEjmxtkZX1zDbBDDVVcAmaGLOnu+L42kqcLyiNvvDvagzAl5X4J2uRDne8YwlQ6FUGo21jd2MjJXNVsO1oYDbXn1O08rjuKVWw32KyZurvJVexgExEsFRGvLEXC71xHBx9r99A uxC9NcX5 1VP3R35oFCByEnsYePLYj3jW669d0GKeq5Wom7aY/w95iuRe43U7lqmKI68IARoD1iA4+HeMZFRXkOPvxJIfdFcAQLQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi, Sorry, a bit late to the discussion :) On Tue, Dec 12, 2023 at 02:11:56PM -0400, Jason Gunthorpe wrote: > On Tue, Dec 12, 2023 at 05:46:34PM +0000, Catalin Marinas wrote: > > should know the implications. There's also an expectation that the > > actual driver (KVM guests) or maybe later DPDK can choose the safe > > non-cacheable or write-combine (Linux terminology) attributes for the > > BAR. > > DPDK won't rely on this interface Wait, so what's the expected interface for determining the memory attributes at stage-1? I'm somewhat concerned that we're conflating two things here: 1) KVM needs to know the memory attributes to use at stage-2, which isn't fundamentally different from what's needed for userspace stage-1 mappings. 2) KVM additionally needs a hint that the device / VFIO can handle mismatched aliases w/o the machine exploding. This goes beyond supporting Normal-NC mappings at stage-2 and is really a bug with our current scheme (nGnRnE at stage-1, nGnRE at stage-2). I was hoping that (1) could be some 'common' plumbing for both userspace and KVM mappings. And for (2), any case where a device is intolerant of mismatches && KVM cannot force the memory attributes should be rejected. AFAICT, the only reason PCI devices can get the blanket treatment of Normal-NC at stage-2 is because userspace has a Device-* mapping and can't speculatively load from the alias. This feels a bit hacky, and maybe we should prioritize an interface for mapping a device into a VM w/o a valid userspace mapping. I very much understand that this has been going on for a while, and we need to do *something* to get passthrough working well for devices that like 'WC'. I just want to make sure we don't paint ourselves into a corner that's hard to get out of in the future. -- Thanks, Oliver