Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2283102pxb; Mon, 23 Aug 2021 16:57:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqUwDOWBEAS5LM+1ixhOvbj7wNTSDTPVzUl0BUNCnB6bJDu1Y33cA5J4EXh+eL2CWsnGOY X-Received: by 2002:a05:6402:31ae:: with SMTP id dj14mr39520108edb.94.1629763079069; Mon, 23 Aug 2021 16:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629763079; cv=none; d=google.com; s=arc-20160816; b=TmyjIhRrn98DALj8x3obpnLtxP4Tj0RSfkWO/UDHo4lsTO0z4CI3s1BFIsv6L1ZBfL 5MLdoGroocf14V6Dqiykm7iyMbBKHAIE0F25Cb3fJFeHLpd761xbEjbp9iRG3nyK2Rvo qw54SjkjpHSaaroO0mUkIYhItuAzJXF8zp/d0hyY5ZbcBO7iKzecVKkT0o5ou4651r+d Gcs86qR8v74V91NViwMRnIfbJ8ggFD02MBhqDEV7ak8Vuo3Z9sTe870D4ZtbIguPLx8R 0BmAsmP/hYGuwiITZd3dz1UKgT+4xEwPru+J/gdKG35SjuNc/S7DNWaP4RenwwTOmkR7 qg+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=RF+d9qpVprIgoIZ0mXGZUwRPD3HGuqO+bXOLg0En698=; b=Q8bB3GCGgKwR4LGJGsRTrUeVrCyc8kuJ8XgNJWvlAP4bFeGlKkoFuG8zds7ufAichb dvNsnL40vaN2hb9dnFHJeRLHeftuM3TY/ohDL8Zk4eDrb/hmyUGuNE0m8Plrt306TedM ByjWZ2sa6QFrZGuR7Dlb5uthOEcRx0r42AqnhBe3wEF3Q++EymBqMH3T+avPJb+fbDzF Qf7rL8L54UkGNyguqAKzFnDIOYgUaMUpEfHgLBekSVmmnixx6TX/BB41+TzbOPPbNeNc COfcDmjZso9lmtCGEgH2ttXOX0ab8p045gT/0i898aFZiA5xfR99/5X+q1Vcd/HR8i13 21XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TjrQUVXi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nb19si13527898ejc.681.2021.08.23.16.57.36; Mon, 23 Aug 2021 16:57:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TjrQUVXi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233371AbhHWX45 (ORCPT + 99 others); Mon, 23 Aug 2021 19:56:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50531 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233260AbhHWX45 (ORCPT ); Mon, 23 Aug 2021 19:56:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629762973; 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=RF+d9qpVprIgoIZ0mXGZUwRPD3HGuqO+bXOLg0En698=; b=TjrQUVXiJRnZm5zdmiMSgNJM8Mz4QUaHHG/Z62UymjbI9HNCRXB352A6+ylM01kehZPLga fgigsL7HPBFhN0gZspn969usecXH5HSrik36Km+PHQI4BB3usiez5X4n5XiC6jSG50ncdU IiWUJTngOLA0p4IKybgaISdO8LX6qxw= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-566-vFM40aZLN_2eZT2lWOxusA-1; Mon, 23 Aug 2021 19:56:11 -0400 X-MC-Unique: vFM40aZLN_2eZT2lWOxusA-1 Received: by mail-ej1-f70.google.com with SMTP id ak17-20020a170906889100b005c5d1e5e707so1574647ejc.16 for ; Mon, 23 Aug 2021 16:56:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RF+d9qpVprIgoIZ0mXGZUwRPD3HGuqO+bXOLg0En698=; b=N0DWQe2ysbLoLA2IdnwTwaILKR7qdyDf6sob0TIGBRM/BWuGtg5A8hXE6qM9kG8oBI QafzJnKL60rbGK/SKlAzkh4y+gbBktjjy46LS3U3TDJ2zSfW/fW1uMKFrqwTfjvW9JLz N01RrH7tKtdE3F8tigJA9NAu/hvRsM2Kt67EzTh3w52F6MuA4npu4LTJ8YoRP75IjUey zwTook+/14C9/WcrI0+QZX9YgJb2yRrY6GWHmZlFTvNr3dB2I3/z5P5fi5L98gitX4vS rf4rujZWB2dUYtzljT0I0KkFfExP2NLmp3go1tL4F2wgkTxrrqUIfiXBvE/lJ8aQEdQO XGZQ== X-Gm-Message-State: AOAM533XbWpsZBNK28esuCRmJlikjHMJ+KCVUK9mWRcHfnaPzuwg7nds snXb+2qbr2gnOfgK9+6IAGOTX/50Id2zWAIQeUWnkm64vMM107mgYlI7CDNw3F74xqj53S++0/i NVAzBlwZ1GJP0R7FUQXXet0+5 X-Received: by 2002:a17:907:2cf1:: with SMTP id hz17mr32841067ejc.438.1629762970800; Mon, 23 Aug 2021 16:56:10 -0700 (PDT) X-Received: by 2002:a17:907:2cf1:: with SMTP id hz17mr32841039ejc.438.1629762970610; Mon, 23 Aug 2021 16:56:10 -0700 (PDT) Received: from redhat.com ([2.55.137.225]) by smtp.gmail.com with ESMTPSA id m17sm4928372ejr.27.2021.08.23.16.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 16:56:09 -0700 (PDT) Date: Mon, 23 Aug 2021 19:56:03 -0400 From: "Michael S. Tsirkin" To: Kuppuswamy Sathyanarayanan Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Andy Lutomirski , Bjorn Helgaas , Richard Henderson , Thomas Bogendoerfer , James E J Bottomley , Helge Deller , "David S . Miller" , Arnd Bergmann , Jonathan Corbet , Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Sean Christopherson , Kuppuswamy Sathyanarayanan , x86@kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v4 11/15] pci: Add pci_iomap_shared{,_range} Message-ID: <20210823195409-mutt-send-email-mst@kernel.org> References: <20210805005218.2912076-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210805005218.2912076-12-sathyanarayanan.kuppuswamy@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210805005218.2912076-12-sathyanarayanan.kuppuswamy@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 04, 2021 at 05:52:14PM -0700, Kuppuswamy Sathyanarayanan wrote: > From: Andi Kleen > > Add a new variant of pci_iomap for mapping all PCI resources > of a devices as shared memory with a hypervisor in a confidential > guest. > > Signed-off-by: Andi Kleen > Signed-off-by: Kuppuswamy Sathyanarayanan I'm a bit puzzled by this part. So why should the guest *not* map pci memory as shared? And if the answer is never (as it seems to be) then why not just make regular pci_iomap DTRT? Thanks! > --- > include/asm-generic/pci_iomap.h | 6 +++++ > lib/pci_iomap.c | 46 +++++++++++++++++++++++++++++++++ > 2 files changed, 52 insertions(+) > > diff --git a/include/asm-generic/pci_iomap.h b/include/asm-generic/pci_iomap.h > index d4f16dcc2ed7..0178ddd7ad88 100644 > --- a/include/asm-generic/pci_iomap.h > +++ b/include/asm-generic/pci_iomap.h > @@ -18,6 +18,12 @@ extern void __iomem *pci_iomap_range(struct pci_dev *dev, int bar, > extern void __iomem *pci_iomap_wc_range(struct pci_dev *dev, int bar, > unsigned long offset, > unsigned long maxlen); > +extern void __iomem *pci_iomap_shared(struct pci_dev *dev, int bar, > + unsigned long max); > +extern void __iomem *pci_iomap_shared_range(struct pci_dev *dev, int bar, > + unsigned long offset, > + unsigned long maxlen); > + > /* Create a virtual mapping cookie for a port on a given PCI device. > * Do not call this directly, it exists to make it easier for architectures > * to override */ > diff --git a/lib/pci_iomap.c b/lib/pci_iomap.c > index 6251c3f651c6..b04e8689eab3 100644 > --- a/lib/pci_iomap.c > +++ b/lib/pci_iomap.c > @@ -25,6 +25,11 @@ static void __iomem *map_ioremap_wc(phys_addr_t addr, size_t size) > return ioremap_wc(addr, size); > } > > +static void __iomem *map_ioremap_shared(phys_addr_t addr, size_t size) > +{ > + return ioremap_shared(addr, size); > +} > + > static void __iomem *pci_iomap_range_map(struct pci_dev *dev, > int bar, > unsigned long offset, > @@ -101,6 +106,47 @@ void __iomem *pci_iomap_wc_range(struct pci_dev *dev, > } > EXPORT_SYMBOL_GPL(pci_iomap_wc_range); > > +/** > + * pci_iomap_shared_range - create a virtual shared mapping cookie for a > + * PCI BAR > + * @dev: PCI device that owns the BAR > + * @bar: BAR number > + * @offset: map memory at the given offset in BAR > + * @maxlen: max length of the memory to map > + * > + * Remap a pci device's resources shared in a confidential guest. > + * For more details see pci_iomap_range's documentation. > + * > + * @maxlen specifies the maximum length to map. To get access to > + * the complete BAR from offset to the end, pass %0 here. > + */ > +void __iomem *pci_iomap_shared_range(struct pci_dev *dev, int bar, > + unsigned long offset, unsigned long maxlen) > +{ > + return pci_iomap_range_map(dev, bar, offset, maxlen, > + map_ioremap_shared); > +} > +EXPORT_SYMBOL_GPL(pci_iomap_shared_range); > + > +/** > + * pci_iomap_shared - create a virtual shared mapping cookie for a PCI BAR > + * @dev: PCI device that owns the BAR > + * @bar: BAR number > + * @maxlen: length of the memory to map > + * > + * See pci_iomap for details. This function creates a shared mapping > + * with the host for confidential hosts. > + * > + * @maxlen specifies the maximum length to map. To get access to the > + * complete BAR without checking for its length first, pass %0 here. > + */ > +void __iomem *pci_iomap_shared(struct pci_dev *dev, int bar, > + unsigned long maxlen) > +{ > + return pci_iomap_shared_range(dev, bar, 0, maxlen); > +} > +EXPORT_SYMBOL_GPL(pci_iomap_shared); > + > /** > * pci_iomap - create a virtual mapping cookie for a PCI BAR > * @dev: PCI device that owns the BAR > -- > 2.25.1