Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6124402rdb; Thu, 14 Dec 2023 08:56:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/Bzm+70iZn6g+M2FH+8Snd2Pj8aA0EJ8GRrUELqKJYReQg164yGDDWdMrTAdRMl2/V9b5 X-Received: by 2002:a17:903:2381:b0:1d3:629c:c02c with SMTP id v1-20020a170903238100b001d3629cc02cmr2123427plh.12.1702573017982; Thu, 14 Dec 2023 08:56:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702573017; cv=none; d=google.com; s=arc-20160816; b=JFOR11QMokx1Gg3K0+cth8oDUWGCkpSWbPPaF+owAc6jsNxFfuVoaSK/PqXyNpdPLt HfMSDr6Y31N7DFP2uVZoFS8TKcm5vn/8SLN1fXIddk13vNcQintga37wCq0x9Uy/O9w+ f2qBCPLV/+Va1vQM5KwVhyu4B3c/wthb/dQE8PWxcljcVYuVAHBY58ZQ87jAB3XBuNdv /qjXF9vN3f9QzOtbn8/+RjJHgHYuqyhhBULn6p6PydFhnYlaZ0Lj1SEwXo3cGe5YFAf/ LKKanMly1K0rTfyEaEUFHq8NjJnQhPEcN5rSdQgmKVXE5Z+DUkS96fX7IqYp9AFyAIyd 1gZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=4YNudICFnccOJwSRae1JA15vTriKkExaSPdeDL+9ouQ=; fh=d0LtzBXC7CO3fPZ8Vy52fZVwGxTVbU0YV5c4xmKxxoM=; b=JkEp0dpq/eTBwPZDpkXjfuMrwffnaigmgiLmM/jvk3FZ+v4QTP3EjjZM3jrmFlBC6W pP+BMOxqHAFQIQrSjxa2i6AJgWoii/NrKoS2hOr3ifjsyDe3jdire+XGqLl3U8EB8LjZ G2MCS6vNpKKGyBULGs4ktFgF1MsWxzRNMHjLTP37YbPAx6+DJ4EYPzFrLQpsjjG+uuXT Tl4djxZCxaadpg7hfAV7zz8z9tfe3IgXfnhWPTGLnml9Mg4jEjNZV6o+QDidIKU8+ypR G0fETvGxFiHL0SO2pXXKFUolX+w7KUjaFOKn/FwXKhGlR8THxdin6g+BdlXtJf7ZCj0I opeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=E60cAGDA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id v15-20020a63150f000000b005b91536981csi11506364pgl.11.2023.12.14.08.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 08:56:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=E60cAGDA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 5BE8E80A9998; Thu, 14 Dec 2023 08:56:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229532AbjLNQ4J (ORCPT + 99 others); Thu, 14 Dec 2023 11:56:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbjLNQ4I (ORCPT ); Thu, 14 Dec 2023 11:56:08 -0500 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [IPv6:2001:41d0:203:375::ac]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8620AB7 for ; Thu, 14 Dec 2023 08:56:12 -0800 (PST) Date: Thu, 14 Dec 2023 16:56:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702572970; 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=4YNudICFnccOJwSRae1JA15vTriKkExaSPdeDL+9ouQ=; b=E60cAGDAv7DLogGVzQ767p+8gD8T7Uf/QSXhFzabZSx5Z+LA7N2090ZifH+dopmn0oBAsB +KpmKolLuvIonLpihx3t0oJrVTF3GH9zJjB/5JxvxCNTx7I2g62Wu9IjAETEpeCRAeBwJF xmt2EieAYHyu3P78CbW8deoTVu4A78E= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Lorenzo Pieralisi Cc: Jason Gunthorpe , 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, 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, james.morse@arm.com 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: X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 14 Dec 2023 08:56:32 -0800 (PST) On Thu, Dec 14, 2023 at 04:48:15PM +0100, Lorenzo Pieralisi wrote: [...] > > 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. > > FWIW - I have tried to summarize the reasoning behind PCIe devices > Normal-NC default stage-2 safety in a document that I have just realized > now it has become this series cover letter, I don't think the PCI blanket > treatment is related *only* to the current user space mappings (ie > BTW, AFAICS it is also *possible* at present to map a prefetchable BAR through > sysfs with Normal-NC memory attributes in the host at the same time a PCI > device is passed-through to a guest with VFIO - and therefore we have a > dev-nGnRnE stage-1 mapping for it. Don't think anyone does that - what for - > but it is possible and KVM would not know about it). > > Again, FWIW, we were told (source Arm ARM) mismatched aliases concerning > device-XXX vs Normal-NC are not problematic as long as the transactions > issued for the related mappings are independent (and none of the > mappings is cacheable). > > I appreciate this is not enough to give everyone full confidence on > this solution robustness - that's why I wrote that up so that we know > what we are up against and write KVM interfaces accordingly. Apologies, I didn't mean to question what's going on here from the hardware POV. My concern was more from the kernel + user interfaces POV, this all seems to work (specifically for PCI) by maintaining an intentional mismatch between the VFIO stage-1 and KVM stage-2 mappings. If we add more behind-the-scenes tricks to get other MMIO mappings working in the future then this whole interaction will get even hairier. At least if we follow the stage-1 attributes (where possible) then we can document some sort of expected behavior in KVM. The VMM would need know if the device has read side-effects, as the only way to get a Normal-NC mapping in the guest would be to have one at stage-1. Kinda stinks to make the VMM aware of the device, but IMO it is a fundamental limitation of the way we back memslots right now. -- Thanks, Oliver