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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72FEEC4167D for ; Mon, 4 Apr 2022 21:28:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382446AbiDDV3u (ORCPT ); Mon, 4 Apr 2022 17:29:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379413AbiDDRIp (ORCPT ); Mon, 4 Apr 2022 13:08:45 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9F2440A24 for ; Mon, 4 Apr 2022 10:06:48 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id bx5so9308961pjb.3 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=Ov5TjFMsLIO5mH+GvpCZd3lC9VGSDcRGXb0Ig5ibzr5oUg/cqQ8bGaNPkRKYjITMoz dQ5TblSvm48yPvkjiXFbUYTS8oEVLAOAObCtFqddM6x56Sj9qfIm11gCoJzAwgEb9ueb YD5/6WyC47noJfWUKncVfDVbAEUnchy/kPO03kgfHtUnekiI/+KsZok8dUIyYEXq4Ic3 bqs4A3+F5/0EeqOnZsxrdiUCEGkYtAnF5bTWcjZuoPbwzIrsWECaVrA6GY3hgQVpqW6n PCqZT0w3QVEUA/0lMZWTv8ysdJ8okL1OlMzm69X6KB6Kr3sr7mTnLO1wu5VRbUAWdiHl hPoQ== X-Gm-Message-State: AOAM533MYuW6whHzYQdqI9+7vlLmSjIL360Pe+bXQsjfcoSiIizcyaLY HetPp1W6ZZxZU27g6te2qVbgYg== 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: Precedence: bulk List-ID: X-Mailing-List: linux-api@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.