Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7124503rdb; Wed, 3 Jan 2024 05:34:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxJ31sV0n3VWmPaF3LpVuxtx0vCKFZr7F8+CxkUKrurN9sGZOZ9gH0i6vzl+RC7vxW50xD X-Received: by 2002:a05:6512:246:b0:50e:18dd:60a6 with SMTP id b6-20020a056512024600b0050e18dd60a6mr7379397lfo.37.1704288866762; Wed, 03 Jan 2024 05:34:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704288866; cv=none; d=google.com; s=arc-20160816; b=OensDcA+8lm53KUJ+3ou3bGS5TiwMgJSk8ZLLqWmFVRykVMuJ3UN1mH81N+Y+AWac5 M7cHEwYhDAwIedbLERRD/AttG1QHz1r9+6P/aOQkdL/85Dk5kCc5f8EGLMjcqb8bDhtV cTrhcqm2RWvk75rG0qGSHUnTtEkRk7hBCjado7bIWVpEKLK5K+uqZiVsSiyZeYjSXSrE eQU3bJqNRTVNUjhppDNUl+DQYx/NlosHRKN+4WJiIKqUBDb8a6Uf2dtSJ0w0bva+y714 5uk5V3MjqDAa9nXNShICK7y5ESaMBzdtCedkzsuD15q/65cmPeBFfLQ8d97E4mvV/fGK VdkA== 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=i2ebhdPpdNJKWVMPY3szJ5Hb8QerDm9zMllrbNVSUnk=; fh=x4Q6aCL2f1AwnIVN1IbixH9Z7Ny57WqG4fnyRhbP1bI=; b=n8slEisIzm29cf0leWh/9C3G2I+L7WuP+lW/8o3MHzhKjrJbPzruarvKHUienyUXWd Of+qNNfNGTLusb0U9jkj+R7rfeaBdUhagrZQtWHg9xlgR8R6NwE5fivC6SwePCYanoUX L9bnntQiiMZ7gfio4mr7bUKjCejoSG2iuU9VscQJO9abMpBc2yZ8kjPpIrCR2Wzl0Xgl /2EJv21mp+H2XuSHaxzkCF0OXwdokkYDSnoE3LjS7RrM222yXzk3UX+5jiNC2j5pTctj wzSmffre80vY4nSyZ1WV+D9xvAnCP1Nm/1Cb0zhJmMicwSaYiJNvKG05hrk2Gto6zIVE YJLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-15587-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15587-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f22-20020a50a6d6000000b00554eaf000c7si8043472edc.469.2024.01.03.05.34.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 05:34:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-15587-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-15587-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-15587-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7AC5E1F2456D for ; Wed, 3 Jan 2024 13:34:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 695A01A70E; Wed, 3 Jan 2024 13:33:24 +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 E49011A5B5; Wed, 3 Jan 2024 13:33:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E489CC433C8; Wed, 3 Jan 2024 13:33:17 +0000 (UTC) Date: Wed, 3 Jan 2024 13:33:15 +0000 From: Catalin Marinas To: Jason Gunthorpe Cc: Oliver Upton , Lorenzo Pieralisi , 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> <20240102170908.GG50406@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: <20240102170908.GG50406@nvidia.com> On Tue, Jan 02, 2024 at 01:09:08PM -0400, Jason Gunthorpe wrote: > On Thu, Dec 21, 2023 at 01:19:18PM +0000, Catalin Marinas wrote: > > If we really want to avoid any aliases (though I think we are spending > > too many cycles on something that's not a real issue), the only way is > > to have fd-based mappings in KVM so that there's no VMM alias. After > > that we need to choose between (2) and (3) since the VMM may no longer > > be able to probe the device and figure out which ranges need what > > attributes. > > If we use a FD then KVM will be invoking some API on the FD to get the > physical memory addreses and we can have that API also return > information on the allowed memory types. I think the part with a VFIO WC flag wouldn't be any different. The fd-based mapping only solves the mismatched alias, otherwise the decision for Normal NC vs Device still lies with the guest driver. > > > 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. > > > > As I mentioned above, the limitation may be more complex if the > > intra-BAR attributes are not something readily available in the device > > documentation. Maybe Jason or Ankit can shed some light here: are those > > intra-BAR ranges configurable by the (guest) driver or they are already > > pre-configured by firmware and the driver only needs to probe them? > > Configured by the guest on the fly, on a page by page basis. > > There is no way for the VMM to pre-predict what memory type the VM > will need. The VM must be in control of this. That's a key argument why the VMM cannot do this, unless we come up with some para-virtualised interface and split the device configuration logic between the VMM and the VM. I don't think that's feasible, too much complexity. -- Catalin