From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23F6AC4338F for ; Mon, 23 Aug 2021 23:56:23 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A13966138B for ; Mon, 23 Aug 2021 23:56:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A13966138B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 65D0E80E67; Mon, 23 Aug 2021 23:56:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PJZ-VjWiFD0d; Mon, 23 Aug 2021 23:56:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 0926280E1B; Mon, 23 Aug 2021 23:56:18 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D16F1C001A; Mon, 23 Aug 2021 23:56:17 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 304EEC000E for ; Mon, 23 Aug 2021 23:56:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 12C5A606C4 for ; Mon, 23 Aug 2021 23:56:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nCvuBLfg-9K7 for ; Mon, 23 Aug 2021 23:56:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 351366064F for ; Mon, 23 Aug 2021 23:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629762975; 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=HTX85xoxa5uBj3g95+eRppIBDeHskEPVfU+DokdKcRDmynbAmycmDzId+SEj7inD2Wsnsy loffqtLLF4vUidCYcDQxTNhfEnw7wXevJypga7VrVGRXRxQca4lQnqSXvcqSgGXTP3qVvr O3bMCv7emonR2ygab27GEwf0Ku/t4Ko= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-560-5eyUotHYMbGGAOENTDsWTg-1; Mon, 23 Aug 2021 19:56:11 -0400 X-MC-Unique: 5eyUotHYMbGGAOENTDsWTg-1 Received: by mail-ed1-f69.google.com with SMTP id x24-20020aa7dad8000000b003bed477317eso9652539eds.18 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=A5nzRKNgwEypcabVa0Zcal6G5lhWFMRehRwB/zilMoCHqJY+uXUcPqRekToQV67mdy KgX4ceSCesXZIHxXDwnVuHOIAsX3G1ZEnGFB0UVicv3S1dI2NTyxlRVnjoiGVjWLXJEG a5eIHMh+VC74uB90bwpfxeiaGoNl5COwFRRZ+Y4zq4vv813NnIvXF5rJ80r4G795LtBC AE+UbaYLv65M7auGVpUMJdsrZyFjAcRRHMZx3wrEK9LAo/2eGEBXfEZaKW65Uk4t0q3M JAAIOosW6QgCVGu9g7QGnmtjdcfb4eavDErsW/Yqa7/o4wnbRsBzb10jbVCgxtdofB/D ausw== X-Gm-Message-State: AOAM532iMnlavvKUBhojDJumGdyRfUJzeTnU2PF/oTUoKnVXz2PpXjvz 8nfeisI35Yo3db1TbxHZ0kOpySnAZmSi/cH6i8P4+EcuexjAY+hCUjb7umSaH4CopupduKW+3Lx cYBLN+QD0Fi6k6hPGZUYxKwc1SrTOIc343IVVhoE2xQ== X-Received: by 2002:a17:907:2cf1:: with SMTP id hz17mr32841073ejc.438.1629762970804; Mon, 23 Aug 2021 16:56:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlg8FJcUqFiderk/GNwJI39sbQlYErPR6APlNK/zjSzsj+DjKP0nKP8p+wjD6AR325FzPuGA== 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 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 In-Reply-To: <20210805005218.2912076-12-sathyanarayanan.kuppuswamy@linux.intel.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Cc: Kuppuswamy Sathyanarayanan , linux-doc@vger.kernel.org, Peter Zijlstra , linux-pci@vger.kernel.org, linux-mips@vger.kernel.org, James E J Bottomley , Dave Hansen , Peter H Anvin , sparclinux@vger.kernel.org, Thomas Gleixner , linux-arch@vger.kernel.org, Andi Kleen , Jonathan Corbet , Helge Deller , x86@kernel.org, Ingo Molnar , Arnd Bergmann , Tony Luck , Borislav Petkov , Andy Lutomirski , Bjorn Helgaas , Dan Williams , virtualization@lists.linux-foundation.org, Richard Henderson , Thomas Bogendoerfer , linux-parisc@vger.kernel.org, Sean Christopherson , linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, "David S . Miller" , Kirill Shutemov X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" 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 _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization