Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3433918pxb; Mon, 4 Apr 2022 16:53:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOWRJkhz+sTqZzodx8z9K8a6+S0rm5cMTYN2dKzeu51HXCfcavjZttqBRCc97k3etZL6R4 X-Received: by 2002:a17:902:aa81:b0:156:a183:b2e0 with SMTP id d1-20020a170902aa8100b00156a183b2e0mr694207plr.73.1649116404548; Mon, 04 Apr 2022 16:53:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649116404; cv=none; d=google.com; s=arc-20160816; b=GksT9K/romxFmedVzZ9La3SZdLxj/lCIscdCkMcQzHs0Q3gjLUSgsGe5M7VGV2vgx8 r0AjMz+BSQjtruLklDx6J985GQ9sDS6B8Qf3PSFDN7It7ziB6Jp9p0+GYJsC3B5erg/0 RBhpTaDw+Emfkb/u38gGM505bVKYOHD6LRvJgDdsHhnj4+zUF6hmMIq0JnZyyODzOdP8 vvaNDI5NDKRvNjLihQaPPnSx+8I9rX2j/I9q/rVr7U5Us1Uo0tZ6RRJ8lbhQ2BM1PSAu 78He/+iq/g8fcpjPmeyxv9enjcqfgSWy5RVuNN6eZWP/505yknKZS6/buTgxFXXgQ4kM NAYg== 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=gIH+kCrSXmFI+fUc29mzPw+H1akkAs2ZuFoVFSP0vxU=; b=WGQm8QRv2G7irh89DqTliMvxZcpdKpPMfE+bo4YTzLsmaKn7eDWXFGwJdbfhjG90/F R/6nNljP+bPmOoeCgwOtrWKOJG0NFzn52dtWPjDQVU/FXGmCcBzft84BWiXNUdLwZsPA ED+ORzBJEULmKRPytdJqAQa6kdb/qGNqbgSKVhHvb8spBMee7OzEGxX7l55DM/s1Vp5b IdpNK1E7KhbnOcWt/k7XpRN4ulOnOeCJl5LehnyEAeMmZusbKqh6icT5vtufdM1ALjgY Wc8ivMXWxvoC4S+NvRqxWTGpdURppgoCHltDvZPDIjNgS0sjTHR9XzEIr5PTHOmJUx3y b8QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Rr+FaoMf; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id z9-20020a655a49000000b003993a5ee24bsi2694362pgs.693.2022.04.04.16.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 16:53:24 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Rr+FaoMf; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 454B75E173; Mon, 4 Apr 2022 16:36:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378944AbiDDWGa (ORCPT + 99 others); Mon, 4 Apr 2022 18:06:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379412AbiDDRIp (ORCPT ); Mon, 4 Apr 2022 13:08:45 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF75F40A23 for ; Mon, 4 Apr 2022 10:06:48 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id m12-20020a17090b068c00b001cabe30a98dso1057530pjz.4 for ; Mon, 04 Apr 2022 10:06:48 -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=JNEdSVc7vul+D6OCtvDj8qcP3Oz/Bxu2EwSV+cEB9WB5Z2UztFuUIrqb4r+DboS8Wm KO53dfkXgEd9WpYCjdtQ7EWRV7qq6eFKggMwTzU/p0qwzc64jooY28eRkW5GK7wyYdzV 2jEcbZew6pvXLZ1rzAwKUwm6w9i8WTyiIzrYOsb0rAd5yqGVJIyEqYwqTHYeLwLkBTE+ 8vM2BrNM4QmORY9rOMnduUkovoz6N+kGtHhP+dPKsVDfzjxDqonFMHtbC16wue/GPyte Tp8k05LARD6nhSTL8NwtZ7cemKsEbBB5s3+u6JSvUwgrcW6CM4/3pRdpgm85z5VQ20d0 6Diw== X-Gm-Message-State: AOAM530Ffk5JBDPGIPPm4XSH5O6yjvmu7zth3iA7Ma9aDtuWAsVi+1Wu zH6M4Nl0HtlOM8B+mO3tcTRZVw== 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-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.