Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1548982rdb; Thu, 7 Dec 2023 02:14:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXtZK3hrA643yQHnQ+KvLUj7gRdU2jWYMo+bLE/DclFnzS0U03MJHeLiqhct0IMZHyej35 X-Received: by 2002:a17:902:d4c5:b0:1d0:b315:91ef with SMTP id o5-20020a170902d4c500b001d0b31591efmr2703741plg.24.1701944056451; Thu, 07 Dec 2023 02:14:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701944056; cv=none; d=google.com; s=arc-20160816; b=ilAcF7jxWXWjjNkAHo3pfJT41JyS6NkMu87g7U29vluVtqJyd1khmibBfY9W1kPcLi Ac+Dn9+fyICXbBpr9ba8soAmAY3Y/6Vx4mbfj3SdSBnBMV2ajVDVIwYK2LawenwtsW7i tocL4oiz+4qSxzyRqKv1Lf62B/a1Sr3w7vsV+edvcYmvvsWjU/gDISxkvw+jXMh6VuvA 6Uh5Kn7DPi8g2s3/PRPSmXCcxc9skM16r1sjqrFjWVBx6dMveAdskM9FX7vDIzUgbVPH /srZjIQqH8YGEtjrc55NEyf+znanULY8xq7xjzOuBX5V24KXDNhJbq6HrlPUz1x1ez5f fD/g== 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:date:dkim-signature; bh=kJZlu3yrxRl98y6W9ZenI84l7rPUBLXsOM/N5WmwSbg=; fh=j0jmCrz+VjVMJNkG22Wz7eR9l+eK0/ddq4C/OAD9jYQ=; b=NeYyvgyQJ831i1QgV7pRn0ujULRk4bOmHu2ubjjccv55r3/vWaO1LymOzvG9hz/AEq vb+Vj8gpmsvhdRIeuQ/Zuq0weV/rpDv/X1bLZTjG/XQe+Cme5fHOBI/DcrrCTW2PejwZ 5G5bkvpvok6eyGN6IY+ocVP1yZMoIlde7s4qak/alePRUd3lXJb+JLVykqxj4pFNhklX zqx+TSFeFLVqgtD333uKFCWSfxFehBEV5fKQG2N/WLzJYaaKgRpsl/adfWn1qITlQkWb 57SPjpH8m231eTRo5gt1wZsZyPTvify5kkRR1gEh7OQOIQBIORs9WIYKU1rzkDLGz8YW kN/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hhHuuJeq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q1-20020a170902dac100b001d0916275d6si916975plx.418.2023.12.07.02.14.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 02:14:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hhHuuJeq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id DCD02807DE2F; Thu, 7 Dec 2023 02:14:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231443AbjLGKN5 (ORCPT + 99 others); Thu, 7 Dec 2023 05:13:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbjLGKNz (ORCPT ); Thu, 7 Dec 2023 05:13:55 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D40BAA4 for ; Thu, 7 Dec 2023 02:14:00 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE0C4C433C8; Thu, 7 Dec 2023 10:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701944040; bh=imy4ugx4p592rTLtYsew6LM8Qw7swHAvvWpZOmSRbzM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hhHuuJeqjenrJzluJ4waW5koAwpWLKrwzA15G7CY8Utv6hjNfvFBFFodpJSyTaKaF 7EN4QZkZ0wMz69gziLzI+1qWic/TNJhzwqb92SOYzocWHNq5gIwurKXze1emnQSkUu 5EaDIvOuY5Q9MPaZqjdoMnnNo9cbueXBY7gfxZidJC/YhLIrrDuLczNiynyULhIAXI +Ntbu8iq1JUNgGpTswSapQAtiLCQP87puO1UsFeWiY02poI233eYyilYZXLK6DrKQE vQEMmx2GQCZtFgFbx6pK6MBsP4SP7Y5Bg73JfNkZU6HgGJdvjt7ZSA9LYt+cuYd/lJ E6mNvF9PiP9pg== Date: Thu, 7 Dec 2023 11:13:52 +0100 From: Lorenzo Pieralisi To: Jason Gunthorpe Cc: Catalin Marinas , Marc Zyngier , ankita@nvidia.com, Shameerali Kolothum Thodi , oliver.upton@linux.dev, suzuki.poulose@arm.com, yuzenghui@huawei.com, will@kernel.org, ardb@kernel.org, akpm@linux-foundation.org, gshan@redhat.com, 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 v2 1/1] KVM: arm64: allow the VM to select DEVICE_* and NORMAL_NC for IO memory Message-ID: References: <20231205164318.GG2692119@nvidia.com> <20231205194822.GL2692119@nvidia.com> <20231206150556.GQ2692119@nvidia.com> <20231206153809.GS2692119@nvidia.com> <20231206164802.GT2692119@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231206164802.GT2692119@nvidia.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 07 Dec 2023 02:14:14 -0800 (PST) On Wed, Dec 06, 2023 at 12:48:02PM -0400, Jason Gunthorpe wrote: > On Wed, Dec 06, 2023 at 04:23:25PM +0000, Catalin Marinas wrote: > > On Wed, Dec 06, 2023 at 11:38:09AM -0400, Jason Gunthorpe wrote: > > > On Wed, Dec 06, 2023 at 04:18:05PM +0100, Lorenzo Pieralisi wrote: > > > > On Wed, Dec 06, 2023 at 11:05:56AM -0400, Jason Gunthorpe wrote: > > > > > On Wed, Dec 06, 2023 at 02:49:02PM +0000, Catalin Marinas wrote: > > > > > > BTW, on those Mellanox devices that require different attributes within > > > > > > a BAR, do they have a problem with speculative reads causing > > > > > > side-effects? > > > > > > > > > > Yes. We definitely have had that problem in the past on older > > > > > devices. VFIO must map the BAR using pgprot_device/noncached() into > > > > > the VMM, no other choice is functionally OK. > > > > > > > > Were those BARs tagged as prefetchable or non-prefetchable ? I assume the > > > > latter but please let me know if I am guessing wrong. > > > > > > I don't know it was quite old HW. Probably. > > > > > > Just because a BAR is not marked as prefetchable doesn't mean that the > > > device can't use NORMAL_NC on subsets of it. > > > > What about the other way around - would we have a prefetchable BAR that > > has portions which are unprefetchable? > > I would say possibly. > > Prefetch is a dead concept in PCIe, it was obsoleted in PCI-X about 20 > years ago. No PCIe system has ever done prefetch. > > There is a strong incentive to mark BAR's as prefetchable because it > allows 64 bit addressing in configurations with bridges. If by strong incentive you mean the "Additional guidance on the Prefetchable Bit in Memory Space BARs" in the PCI express specifications, I think it has been removed from the spec and the criteria that had to be met to implement it were basically impossible to fulfill on ARM systems, it did not make any sense in the first place. I agree on your statement related to the prefetchable concept but I believe that a prefetchable BAR containing regions that have read side-effects is essentially a borked design unless at system level speculative reads are prevented (as far as I understand the implementation note this could only be an endpoint integrated in a system where read speculation can't just happen (?)). Long story short: a PCIe card/device that can be plugged on any PCIe compliant system (x86, ARM or whatever) should not mark a BAR region with memory read side-effects as prefetchable, either that or I don't understand what the implementation note above was all about. AFAIK the prefetchable concept in PCIe is likely to be scrapped altogether in the not too distant future. Anyway, that was just for completeness (and to shed light on the BAR prefetchable bit usage). Lorenzo