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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E060C433F5 for ; Fri, 19 Nov 2021 16:00:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BA3E961A58 for ; Fri, 19 Nov 2021 16:00:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BA3E961A58 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0778C6B006C; Fri, 19 Nov 2021 11:00:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 028D16B0071; Fri, 19 Nov 2021 11:00:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E319C6B0074; Fri, 19 Nov 2021 11:00:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D5BE76B006C for ; Fri, 19 Nov 2021 11:00:37 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 942451850E6B9 for ; Fri, 19 Nov 2021 16:00:27 +0000 (UTC) X-FDA: 78826141842.19.AAD41F0 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by imf09.hostedemail.com (Postfix) with ESMTP id 040A23000127 for ; Fri, 19 Nov 2021 16:00:24 +0000 (UTC) Received: by mail-qt1-f171.google.com with SMTP id f20so9882152qtb.4 for ; Fri, 19 Nov 2021 08:00:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VtV9HHXd4X5WRhcYz4pKiiL6eAEsTLpENVV+xmm0B1E=; b=gsJUvh5WctLgXnshRJv4wGg2JAgnGdSqNb3S1bmxpaDvTOBEX8LcgLW/+JvwTzVB37 v5K7AG9csFvUa4d1e8VMH07tEJ/4GXeXR0y5xTNeGGDEbPPYGPgXDzn7G4nizRSxv1eO ORYsNAAPbkIfEb6NsGnWQ8GCPrvVKrf/49w0ZT27g2F3XOg052ttHxyU5wmveX2QAeR0 /CkUMXANh4cDh+HorkLPLoxEa1f7SRa67fSFzDU/E1oWa7A8N6PtOVfUv80pyqxAxqRj YJDGrR6Uf5+iNfe0u7fumnhfivIpDOd+RCAzSsT04BV51dAxqsTNgRzPecBJz4DuF5VH RdEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VtV9HHXd4X5WRhcYz4pKiiL6eAEsTLpENVV+xmm0B1E=; b=LR1Z8zbWggVZOPWdWdrFW96ZDHlXXZKVp0b6vyYckRldtKlS5KLa2TUPjNeEnUrmhr Gb+Gngn4WvMGH8Wq4n5Ra3lDccSMI/wZ34eZSatD1go9ODWEhVKbTFqrEtusWTh2FUMP KN90FGyQgMxMDHVrTv2jYUR8vL/YgwZuxNSqScUUlh1aLi2Byytmth0p20pf80pO42w8 qDLLUlzCRxhcIdMzlwhIrHmSDwIu7oaH4AssrPYLtOvkOWmELovtP1dfEMNGcOW5gCbJ hPPwNtb3rLJIp0c2WH7dmZrjvQBNjamXwQrrIioPffNxFjgjIGagau1R7MHJBUeYWwQT lhDQ== X-Gm-Message-State: AOAM532lvq0ESkMBXBoRtCXVFkfjqRk4E4oryCFmXBYWlUR5wZPpkyni 0ZW7GwBiaOxOPsGVr6SWBtgkRQ== X-Google-Smtp-Source: ABdhPJxKednFIP8LV5fXPBeBBtPHTY7W03I8IO74iFi+Vm9ZxLiGU52DJu0TAbPkEtajZX/lLl8ZnA== X-Received: by 2002:a05:622a:349:: with SMTP id r9mr7258679qtw.213.1637337626383; Fri, 19 Nov 2021 08:00:26 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id j20sm54140qko.117.2021.11.19.08.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 08:00:25 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1mo6JL-00CHtq-W3; Fri, 19 Nov 2021 12:00:24 -0400 Date: Fri, 19 Nov 2021 12:00:23 -0400 From: Jason Gunthorpe To: David Hildenbrand Cc: Chao Peng , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Yu Zhang , "Kirill A . Shutemov" , luto@kernel.org, john.ji@intel.com, susie.li@intel.com, jun.nakajima@intel.com, dave.hansen@intel.com, ak@linux.intel.com Subject: Re: [RFC v2 PATCH 01/13] mm/shmem: Introduce F_SEAL_GUEST Message-ID: <20211119160023.GI876299@ziepe.ca> References: <20211119134739.20218-1-chao.p.peng@linux.intel.com> <20211119134739.20218-2-chao.p.peng@linux.intel.com> <20211119151943.GH876299@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 040A23000127 X-Stat-Signature: 8py6goy8gn9hygmrp1shbmr4m11k3qd7 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b=gsJUvh5W; dmarc=none; spf=pass (imf09.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.160.171 as permitted sender) smtp.mailfrom=jgg@ziepe.ca X-HE-Tag: 1637337624-445806 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Nov 19, 2021 at 04:39:15PM +0100, David Hildenbrand wrote: > > If qmeu can put all the guest memory in a memfd and not map it, then > > I'd also like to see that the IOMMU can use this interface too so we > > can have VFIO working in this configuration. > > In QEMU we usually want to (and must) be able to access guest memory > from user space, with the current design we wouldn't even be able to > temporarily mmap it -- which makes sense for encrypted memory only. The > corner case really is encrypted memory. So I don't think we'll see a > broad use of this feature outside of encrypted VMs in QEMU. I might be > wrong, most probably I am :) Interesting.. The non-encrypted case I had in mind is the horrible flow in VFIO to support qemu re-execing itself (VFIO_DMA_UNMAP_FLAG_VADDR). Here VFIO is connected to a VA in a mm_struct that will become invalid during the kexec period, but VFIO needs to continue to access it. For IOMMU cases this is OK because the memory is already pinned, but for the 'emulated iommu' used by mdevs pages are pinned dynamically. qemu needs to ensure that VFIO can continue to access the pages across the kexec, even though there is nothing to pin_user_pages() on. This flow would work a lot better if VFIO was connected to the memfd that is storing the guest memory. Then it naturally doesn't get disrupted by exec() and we don't need the mess in the kernel.. I was wondering if we could get here using the direct_io APIs but this would do the job too. > Apart from the special "encrypted memory" semantics, I assume nothing > speaks against allowing for mmaping these memfds, for example, for any > other VFIO use cases. We will eventually have VFIO with "encrypted memory". There was a talk in LPC about the enabling work for this. So, if the plan is to put fully encrpyted memory inside a memfd, then we still will eventually need a way to pull the pfns it into the IOMMU, presumably along with the access control parameters needed to pass to the secure monitor to join a PCI device to the secure memory. Jason