[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 4 Apr 2022 17:06:43 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Quentin Perret <qperret@...gle.com>
Cc: Andy Lutomirski <luto@...nel.org>,
Steven Price <steven.price@....com>,
Chao Peng <chao.p.peng@...ux.intel.com>,
kvm list <kvm@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-mm@...ck.org, linux-fsdevel@...r.kernel.org,
Linux API <linux-api@...r.kernel.org>, qemu-devel@...gnu.org,
Paolo Bonzini <pbonzini@...hat.com>,
Jonathan Corbet <corbet@....net>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
the arch/x86 maintainers <x86@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>, Hugh Dickins <hughd@...gle.com>,
Jeff Layton <jlayton@...nel.org>,
"J . Bruce Fields" <bfields@...ldses.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Mike Rapoport <rppt@...nel.org>,
"Maciej S . Szmigiero" <mail@...iej.szmigiero.name>,
Vlastimil Babka <vbabka@...e.cz>,
Vishal Annapurve <vannapurve@...gle.com>,
Yu Zhang <yu.c.zhang@...ux.intel.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
"Nakajima, Jun" <jun.nakajima@...el.com>,
Dave Hansen <dave.hansen@...el.com>,
Andi Kleen <ak@...ux.intel.com>,
David Hildenbrand <david@...hat.com>,
Marc Zyngier <maz@...nel.org>, Will Deacon <will@...nel.org>
Subject: Re: [PATCH v5 00/13] KVM: mm: fd-based approach for supporting KVM
guest private memory
On Mon, Apr 04, 2022, Quentin Perret wrote:
> On Friday 01 Apr 2022 at 12:56:50 (-0700), Andy Lutomirski wrote:
> FWIW, there are a couple of reasons why I'd like to have in-place
> conversions:
>
> - one goal of pKVM is to migrate some things away from the Arm
> Trustzone environment (e.g. DRM and the likes) and into protected VMs
> instead. This will give Linux a fighting chance to defend itself
> against these things -- they currently have access to _all_ memory.
> And transitioning pages between Linux and Trustzone (donations and
> shares) is fast and non-destructive, so we really do not want pKVM to
> regress by requiring the hypervisor to memcpy things;
Is there actually a _need_ for the conversion to be non-destructive? E.g. I assume
the "trusted" side of things will need to be reworked to run as a pKVM guest, at
which point reworking its logic to understand that conversions are destructive and
slow-ish doesn't seem too onerous.
> - it can be very useful for protected VMs to do shared=>private
> conversions. Think of a VM receiving some data from the host in a
> shared buffer, and then it wants to operate on that buffer without
> risking to leak confidential informations in a transient state. In
> that case the most logical thing to do is to convert the buffer back
> to private, do whatever needs to be done on that buffer (decrypting a
> frame, ...), and then share it back with the host to consume it;
If performance is a motivation, why would the guest want to do two conversions
instead of just doing internal memcpy() to/from a private page? I would be quite
surprised if multiple exits and TLB shootdowns is actually faster, especially at
any kind of scale where zapping stage-2 PTEs will cause lock contention and IPIs.
> - similar to the previous point, a protected VM might want to
> temporarily turn a buffer private to avoid ToCToU issues;
Again, bounce buffer the page in the guest.
> - once we're able to do device assignment to protected VMs, this might
> allow DMA-ing to a private buffer, and make it shared later w/o
> bouncing.
Exposing a private buffer to a device doesn't requring in-place conversion. The
proper way to handle this would be to teach e.g. VFIO to retrieve the PFN from
the backing store. I don't understand the use case for sharing a DMA'd page at a
later time; with whom would the guest share the page? E.g. if a NIC has access to
guest private data then there should never be a need to convert/bounce the page.
Powered by blists - more mailing lists