Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1017833pxb; Wed, 1 Sep 2021 15:25:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBNGNx96aBHTESn6EbPmrklU2jyvpBclSrYErgdOsTJv0BF6I17knnVgJxg6HGxuL0kp3B X-Received: by 2002:a05:6402:c90:: with SMTP id cm16mr183509edb.170.1630535117852; Wed, 01 Sep 2021 15:25:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630535117; cv=none; d=google.com; s=arc-20160816; b=cAUP5BY/OxYCuY1uR0NGK1Pidy8E8QgFI18pHB7IVbQ48wa3l7XVQdprm88fCc4gWS /zWOyH2icKetOlrd/ith67rrF/LTOViG0ksBl9s9htUOsu0s9rWyjgM6hVkZ3y+7Uukh cxfE9EZBn2fUs6GDLhDpv7VUfGiB2LsmbaNjBHRsFFtffO+8gn2W/kKVmozgzxIixTWR YdzWOjMdqGuUtcPFFX2aAGCX/Q71vV6WePa4tUyrC9L6JUitg6tyfQ9O6OhGuKO9AGiq gpFh9WNqxIOkQ0jDEi9vJ6cbfqm5R7Mz4ujUbz/VUvCF9G27WXgeUd06/fQK+LBfsPdR IRKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=kuwA3a8VRWyiF+2itRlcJL8JZbLVL9d2O5cOM0SFnRU=; b=HfWFBWAxlinGv+vuSy5sWZrA+u4YUe7ZZ3xfncuPWDJ0dpLfma2mucBhzOiPU7+fFo BnIoc+nAr+1IWgJUgRHjhvs0A8aTTngk8/Hj6CHr641veI7NKI/PlDrJe3HqAZeSAY1O 5bkW8g9Fb96OG4/U29Lrsa4qXUqv8laeUfUpGdtxqbE4jbLdTGcwcubThuDDEKOEZ+j1 19CWy+YRWuLCojAAONrZUoiCpJG5rWa4aVqm/9VcFFCHoqXQ8b4AbmipfKPGr5Ubcnxm M1ndFSumfi6DDzoALcubibDjPTV1zXpzUqB9eG2p9BXmKULEQ/HSvMbKouzHj1BOwI9f DNVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iDVVpleI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hd17si967020ejc.727.2021.09.01.15.24.45; Wed, 01 Sep 2021 15:25:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iDVVpleI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245280AbhIAQXJ (ORCPT + 99 others); Wed, 1 Sep 2021 12:23:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49104 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245092AbhIAQXI (ORCPT ); Wed, 1 Sep 2021 12:23:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630513330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kuwA3a8VRWyiF+2itRlcJL8JZbLVL9d2O5cOM0SFnRU=; b=iDVVpleIvDt3sj7hH04SYQZKSEAGfQbBZL1pYYl11pfwIvAquOGyd5oBr1s3A5d9186Lt9 VAJHdzGU74fsvYvooEH6C0+ev9wW0TjGAL6mran1mlZnO6WZ//Dt7kZHBR6YgSEZGGZ/Ee mDiDxmFVdLLfYpM/gIrnyNo+duIuUMg= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-i5kwvw0APoSUVxfnQmCGtw-1; Wed, 01 Sep 2021 12:22:09 -0400 X-MC-Unique: i5kwvw0APoSUVxfnQmCGtw-1 Received: by mail-wm1-f72.google.com with SMTP id g3-20020a1c2003000000b002e751c4f439so25935wmg.7 for ; Wed, 01 Sep 2021 09:22:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=kuwA3a8VRWyiF+2itRlcJL8JZbLVL9d2O5cOM0SFnRU=; b=s5xuR9ND9F2F75Dks7yH/B0huoENHy5lsFP9zi7M3rDHucRpjXHinhClwY96H19y3l TNqDXnuLGFuuVX0S0rInJr+d4LBUn95w00aYNhZHw1137xCN3+S0hAGrmnf2w4STu0rY cizcJXePuj82TIWYeFHdE8cc3WP00z2jeEiWhHFj884ZsrGgSU37UIW+IEhic+cDzqKs E7wjVHIoQgTQAtbA7Pxm/stdfk2Odw1IR/Aje0o5DnOZHC151rl6YdtrgonG3fft3xxB EVPI3i1aQsM2WxlJ15pWbfyD7AwtWo4Ihu0/h2lnr9C6CVe+oMt026hjbzfqSCrx+/E4 yovQ== X-Gm-Message-State: AOAM533RYcqjUOUTrOuUEs3Onln7qVuJQoGOhs6226TFwN2y9ikLe6NT 0Iz4D5MBpwKhvBZCLNku4qMuoKq65SXWwu5M8GJpJort1MJ2feKt1OKANxoKYv+W59Qd8810Knb Bat9jZNf1Eg3XXc8hbIgFEFQk X-Received: by 2002:a5d:5441:: with SMTP id w1mr219203wrv.280.1630513328548; Wed, 01 Sep 2021 09:22:08 -0700 (PDT) X-Received: by 2002:a5d:5441:: with SMTP id w1mr219161wrv.280.1630513328354; Wed, 01 Sep 2021 09:22:08 -0700 (PDT) Received: from [192.168.3.132] (p4ff23f71.dip0.t-ipconnect.de. [79.242.63.113]) by smtp.gmail.com with ESMTPSA id q85sm31443wme.23.2021.09.01.09.22.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Sep 2021 09:22:07 -0700 (PDT) Subject: Re: [RFC] KVM: mm: fd-based approach for supporting KVM guest private memory To: jejb@linux.ibm.com, Andy Lutomirski , Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm list , Linux Kernel Mailing List , Borislav Petkov , Andrew Morton , Joerg Roedel , Andi Kleen , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , "Peter Zijlstra (Intel)" , Ingo Molnar , Varad Gautam , Dario Faggioli , the arch/x86 maintainers , linux-mm@kvack.org, linux-coco@lists.linux.dev, "Kirill A. Shutemov" , "Kirill A . Shutemov" , Sathyanarayanan Kuppuswamy , Dave Hansen , Yu Zhang References: <20210824005248.200037-1-seanjc@google.com> <307d385a-a263-276f-28eb-4bc8dd287e32@redhat.com> <61ea53ce-2ba7-70cc-950d-ca128bcb29c5@redhat.com> <9ec3636a-6434-4c98-9d8d-addc82858c41@www.fastmail.com> From: David Hildenbrand Organization: Red Hat Message-ID: Date: Wed, 1 Sep 2021 18:22:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01.09.21 18:18, James Bottomley wrote: > On Wed, 2021-09-01 at 08:54 -0700, Andy Lutomirski wrote: > [...] >> If you want to swap a page on TDX, you can't. Sorry, go directly to >> jail, do not collect $200. > > Actually, even on SEV-ES you can't either. You can read the encrypted > page and write it out if you want, but unless you swap it back to the > exact same physical memory location, the encryption key won't work. > Since we don't guarantee this for swap, I think swap won't actually > work for any confidential computing environment. > >> So I think there are literally zero code paths that currently call >> try_to_unmap() that will actually work like that on TDX. If we run >> out of memory on a TDX host, we can kill the guest completely and >> reclaim all of its memory (which probably also involves killing QEMU >> or whatever other user program is in charge), but that's really our >> only option. > > I think our only option for swap is guest co-operation. We're going to > have to inflate a balloon or something in the guest and have the guest > driver do some type of bounce of the page, where it becomes an > unencrypted page in the guest (so the host can read it without the > physical address keying of the encryption getting in the way) but > actually encrypted with a swap transfer key known only to the guest. I > assume we can use the page acceptance infrastructure currently being > discussed elsewhere to do swap back in as well ... the host provides > the guest with the encrypted swap page and the guest has to decrypt it > and place it in encrypted guest memory. Ballooning is indeed *the* mechanism to avoid swapping in the hypervisor and much rather let the guest swap. Shame it requires trusting a guest, which we, in general, can't. Not to mention other issues we already do have with ballooning (latency, broken auto-ballooning, over-inflating, ...). -- Thanks, David / dhildenb