Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1553997rdb; Mon, 8 Jan 2024 03:05:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFyR5Y+ckDLWRefVlDFqY8WIz334TtDVRezH7S3CALkm0VFHlsGzYsDaiuqN4wrUtRZhOMo X-Received: by 2002:a05:6e02:1e02:b0:35d:5995:1d74 with SMTP id g2-20020a056e021e0200b0035d59951d74mr7325557ila.57.1704711928209; Mon, 08 Jan 2024 03:05:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704711928; cv=none; d=google.com; s=arc-20160816; b=ptE5XZ4JuWtLRFWbHXCdRERteqiPjyyza8KRtS3/tgma3WLOKroXXq8k10Le4OR3E7 TtE1uWU1GbBpULWE6kqjinWu9p+0iCL/VYjJYb44buFv55CnSeefNkkP4Jcdmq6i+z5e loJZ6cPHvGGnJ1EKr1utxnGw/Yoq6CzQENgjCg4d9+zlZFOtGzZFPyg8qs9twMhg808W ew6BqhQ4D1d3cSvMq/X5GFFbhovqEFcIYiTaCyOBEGPT2DEHLcqlhYd/991d4QWGxlyr jdmkG1tEVSXI7h3Psx8WoXW3qd7u865kMaU4x45cwPGOCFIbQPnKSnBViMNXvOvJgYRp QqIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=ntNDtBQCHqA01Pn70YcZIVpF2U85mmzEeS6W4avtfYk=; fh=rOGoK0j+/Owi2o0e7X1WiZN++1J9+T1NQ/TpNWukzZ8=; b=fnFXoCvM/CvIkgLJMBbtoPdOBSYny7/BtWEq9EovFzr7/QDWlUhNMyKEOZW/Y2a8nS Wbb97ZhrdZgCMyYdurNtQ0y1VmLvxh4WpeQarS1KXQO6LrZ1SL3hUM+5Y56zgw7Gbf5q HrV71I7wdMw1AFv+4JrhSI7iu4JXs/S0SsVkq0sE2v7pAikSBfWoE0CZxUejvZIvNaav BlhWnil+qPr8RW5MafeyrS19f5wiFKXGeiNC2T680hYytYqAtuQZdlYTJF9mNPNeEbrp 3fHNVHrAQrGgzp6jWAgWNvh3QFuFpsOob2d1qydBpfpZniuhJpNCxhGwxBAfDyvhduIQ CdzA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19373-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19373-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i4-20020a639d04000000b005ceeeea4e58si3703724pgd.119.2024.01.08.03.05.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 03:05:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19373-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19373-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19373-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AA1A3B21C73 for ; Mon, 8 Jan 2024 11:05:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61AEC1427A; Mon, 8 Jan 2024 11:04:56 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org 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 DEA691401A; Mon, 8 Jan 2024 11:04:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA6B7C433C7; Mon, 8 Jan 2024 11:04:49 +0000 (UTC) Date: Mon, 8 Jan 2024 11:04:47 +0000 From: Catalin Marinas To: Oliver Upton Cc: Lorenzo Pieralisi , Jason Gunthorpe , 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Jan 05, 2024 at 08:42:31PM +0000, Oliver Upton wrote: > On Thu, Dec 21, 2023 at 01:19:18PM +0000, Catalin Marinas wrote: > > > 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 you stare at it long enough, the mismatch starts to look fine ;). > > Even if you have the VFIO stage 1 Normal NC, KVM stage 2 Normal NC, you > > can still have the guest setting stage 1 to Device and introduce an > > architectural mismatch. These aliases have some bad reputation but the > > behaviour is constrained architecturally. > > > > IMHO we should move on from this attribute mismatch since we can't fully > > solve it anyway and focus instead on what the device, system can > > tolerate, who's responsible for deciding which MMIO ranges can be mapped > > as Normal NC. > > Fair enough :) The other slightly unsavory part is that we're baking > the mapping policy into KVM. I'd prefer it if this policy were kept in > userspace somehow, but there's no actual usecase for userspace selecting > memory attributes at this point. If by policy you mean who's deciding the write-combining relaxation, this series moved it to the vfio-pci host driver. KVM only picks the appropriate memory type for stage 2 based on the vma flags. That's Normal NC in the absence of anything better on arm64 and it does more than just write-combining but we can describe what this new VM_* flag allows. If we want to keep this decision strictly in user space, we can do it with some ioctl(). The downside is that the host kernel now puts more trust in the user VMM, so my preference would be to keep this in the vfio driver. Or we can do both, vfio-pci allows the relaxation, the VMM tells KVM to go for a more relaxed stage 2 via an ioctl(). -- Catalin