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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C967C433F5 for ; Mon, 4 Apr 2022 17:07:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A7616B0071; Mon, 4 Apr 2022 13:07:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5570F6B0073; Mon, 4 Apr 2022 13:07:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D2CF6B0074; Mon, 4 Apr 2022 13:07:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 2F59D6B0071 for ; Mon, 4 Apr 2022 13:07:00 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0325523983 for ; Mon, 4 Apr 2022 17:06:49 +0000 (UTC) X-FDA: 79319826180.07.63038B0 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf09.hostedemail.com (Postfix) with ESMTP id 8D65014003F for ; Mon, 4 Apr 2022 17:06:49 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id bx5so9308960pjb.3 for ; Mon, 04 Apr 2022 10:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=gIH+kCrSXmFI+fUc29mzPw+H1akkAs2ZuFoVFSP0vxU=; b=Rr+FaoMffwErSOq6pRJ5Va7RKsFxClc5D23MZTexTKDgRmNLw+QXPH7HgVaF+gPlsH VVR7VJA+skjtzQ0GECeuU2WVaa0asrNgHkDBl6tstbwCf7C6oMyBne0DAlcAXCdcVL7g YrXAno9IHlxoD/YmxzSY5HC12atdMPGZ+Q8N6kZHZabK4TNxokJ7fJfCa2Z4Dji8u6pl 3dHXlOPQbLuOhlHnPj7HtE/XDcufKULa7gV7RWaa0It/x7X/ULWQS6QyjSSWicyoNFMA ahGu94J7u389AK59eb7k4Mps25d3P18aXb3oZxp/f/pFl16fpYmLG3tkL22HLs/vsOZL l1Tg== 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=gIH+kCrSXmFI+fUc29mzPw+H1akkAs2ZuFoVFSP0vxU=; b=EC5RaBk2goRPnP7B7YIwIZNk8/MpjNJKeZ3bbJtQA5OgYRmfrpHrJEjj94VuEfXyKX /p114IWJ5QkYzRwRBelRi7xS8nMG0TVQ+38r/c5ycHrld1x1ElqUHSqatUJNwtlhCAr7 BHKC8VjjUZnuvDGqtYhPQv6IhkIr9YPgjlG/R8NRH1Tkx9qbbXsVca8tLlCimYvhOwn7 XU4HfFktR5o9P6MWORto67/Zh49tuNeCgvbX+Rtdrk5q8id/6jkUKZfMEGmS7HBvukBG tbHPf+kIDfefbYLAtMDSds+uwNMALKVOUaiPsVfGk2J6spaXOwqib1575y5kw970TchP tFcA== X-Gm-Message-State: AOAM5311QE8bz4EMXYvBLvtBt15zMqWl0grK3M42FRfudO0WDpx/dhJj 43awpBuWnvW5n4ygVrfJ+u+Ynw== X-Google-Smtp-Source: ABdhPJxR0cMYn6++nMtTapD/RTNavycubKSgeugDdrZDDJ6GPqebAjtiOfHHZgX3JbxNGnvGjPUvmw== X-Received: by 2002:a17:902:7247:b0:156:9d3d:756d with SMTP id c7-20020a170902724700b001569d3d756dmr687366pll.6.1649092007999; Mon, 04 Apr 2022 10:06:47 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id x9-20020a17090a970900b001ca6c59b350sm428753pjo.2.2022.04.04.10.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 10:06:47 -0700 (PDT) Date: Mon, 4 Apr 2022 17:06:43 +0000 From: Sean Christopherson To: Quentin Perret Cc: Andy Lutomirski , Steven Price , Chao Peng , kvm list , Linux Kernel Mailing List , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Linux API , qemu-devel@nongnu.org, Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , the arch/x86 maintainers , "H. Peter Anvin" , Hugh Dickins , Jeff Layton , "J . Bruce Fields" , Andrew Morton , Mike Rapoport , "Maciej S . Szmigiero" , Vlastimil Babka , Vishal Annapurve , Yu Zhang , "Kirill A. Shutemov" , "Nakajima, Jun" , Dave Hansen , Andi Kleen , David Hildenbrand , Marc Zyngier , Will Deacon Subject: Re: [PATCH v5 00/13] KVM: mm: fd-based approach for supporting KVM guest private memory Message-ID: References: <88620519-029e-342b-0a85-ce2a20eaf41b@arm.com> <80aad2f9-9612-4e87-a27a-755d3fa97c92@www.fastmail.com> <83fd55f8-cd42-4588-9bf6-199cbce70f33@www.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: ktye8wzk8onyq4dznyjnbjtjpxopzmfz Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=Rr+FaoMf; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of seanjc@google.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=seanjc@google.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 8D65014003F X-HE-Tag: 1649092009-275457 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 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.