Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp939134pxb; Wed, 1 Sep 2021 13:12:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzp32rozH8uGM2mGVePuQoP44o+BaPLRIAzu84mZrpPkFXMne0sEq5xFwLUiZgs5B9JcPq4 X-Received: by 2002:a17:906:dc43:: with SMTP id yz3mr1284649ejb.467.1630527161872; Wed, 01 Sep 2021 13:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630527161; cv=none; d=google.com; s=arc-20160816; b=YwtfEQYRZTpbHMhFqrAWp2yHO6kYkGzDaJ7OTUZSiWCNSTbJ1h/sqaD38picNpipm9 kqsfAyhrXR8slGhvx9ifWU1a2ZS2nC/cvq0/XnbO36kKWRof6Pz0H1CHRVrmNzZFPC5A z/80gsP5f9/4NuuFynCZok7bGQP4vRC4Zi/i8FVG7MZDAleH46H0GpIr4e4Ilixgmh4U vTSdWUgnTbbQzKEKa+dtMXiZh19v8cd0ds/ZW+IxG9slvh6xfhEWfM6oGMeN70XW32RJ JbRKZem35ZuSSHcrLTPvwIko4FOBCkWi/ncD2hDweGEwrballdbPu/gbk0n2isQIUZMT 4CIg== 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=eaXvq8CHBS7mwji7NsTxccjCmayM+ohRvagESdHP8T4=; b=H5FoQ8kw8jneC71ibCQbUsI5UW5vXKhYraIMUXOJdFOlrOzRSKsEmxXeZgWXUxLRhn ovn5lm2FTVWCgUpuowlLHfFJIxUseD2rrgBCIxkS6qEM98mB7nVTUaG8l7QOI5hlcxce COcb2axy4auzmPnTXHEit+06xbQ6VkZvr//r1EctPYs3hn5kBAyCg49HJYSikDJUD2Di yA7Xl/CyhE8UWWQPJLVE3q9LzfVrPR7I9h0cPxKMjG6+eZVKJdXk8l7+kiTJfBglEH45 kvpkWZnU2AeEiJFr7YGtzBdE0MdnR7BsVvbAYdpHXdAesHUrvCqlc0wZHw2Z4n7q7mnW Cd/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SYEgL0K1; 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 j23si894534eje.21.2021.09.01.13.11.56; Wed, 01 Sep 2021 13:12:41 -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=SYEgL0K1; 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 S245436AbhIAQiY (ORCPT + 99 others); Wed, 1 Sep 2021 12:38:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36842 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245434AbhIAQiX (ORCPT ); Wed, 1 Sep 2021 12:38:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630514246; 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=eaXvq8CHBS7mwji7NsTxccjCmayM+ohRvagESdHP8T4=; b=SYEgL0K16LDaJORfP5hEWNCMorGvnGZ5lxS4iedYWZa5kgwA16jlEDjU1IDY6AfwdTsIPs tT2IVUq6o++2+8963qmnrunvhoKbaeHNJLLq57Xx9pqPmdQUkMQ1RRyQWrYHl9smeO8kMT 8dJW21ePwmMzgliYrPObUiNQmevDFtQ= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-490-99urWw8hNDmytgUVmD3zDg-1; Wed, 01 Sep 2021 12:37:25 -0400 X-MC-Unique: 99urWw8hNDmytgUVmD3zDg-1 Received: by mail-wm1-f71.google.com with SMTP id p11-20020a05600c204b00b002f05aff1663so46431wmg.2 for ; Wed, 01 Sep 2021 09:37:23 -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=eaXvq8CHBS7mwji7NsTxccjCmayM+ohRvagESdHP8T4=; b=bnmM+Wl17RaEZcK2Q7enS6IjawBksHimrANH/hgePr6QdGI07VsT5VBqdVgegB7N40 VA+lUUKi9TD3tFGtRpVQ/wa006/Qw3jVyX+Y0mpPnSJePYTA7PuBd6N4fBzFHgl2Uf9r 9O5qhgX7akdF3ww2UGL6qDAc5g4ExVP3SgQ4mdhUoGJmAZdyscK0NVGmnw0k+PsOwy8C ef/eSSMhQNoQRuQ9nBVIBkYyF/hMU4w44FpFF9AYQi/13bKR2iZegy/ggufzaZhZYmqK C0i1hoKpQAlqSlxxz+zEnR/XAX33lw/JTHKovbg+094u/ZAZIYBy3xe7ksjK8xi06Gmo q8sg== X-Gm-Message-State: AOAM531QaxArKt7Z+MTZ4d/xKBbXCKOqw9IDEgqzqUOzSyeF+AktLO3s +WJaqDbSY9KfIU7ljG43MUHxkWQafelDZjalSM1v1Jpplbu7evh3gBzk401jJnIeVVAsegmNbm7 l9fYNNU+u4Q+IzbgJVQL0wPff X-Received: by 2002:adf:eac5:: with SMTP id o5mr367669wrn.22.1630514242966; Wed, 01 Sep 2021 09:37:22 -0700 (PDT) X-Received: by 2002:adf:eac5:: with SMTP id o5mr367624wrn.22.1630514242736; Wed, 01 Sep 2021 09:37:22 -0700 (PDT) Received: from [192.168.3.132] (p4ff23f71.dip0.t-ipconnect.de. [79.242.63.113]) by smtp.gmail.com with ESMTPSA id n1sm21391441wrp.49.2021.09.01.09.37.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Sep 2021 09:37:22 -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> <0d6b2a7e22f5e27e03abc21795124ccd66655966.camel@linux.ibm.com> From: David Hildenbrand Organization: Red Hat Message-ID: <1a4a1548-7e14-c2b4-e210-cc60a2895acd@redhat.com> Date: Wed, 1 Sep 2021 18:37:20 +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: <0d6b2a7e22f5e27e03abc21795124ccd66655966.camel@linux.ibm.com> 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:31, James Bottomley wrote: > On Wed, 2021-09-01 at 18:22 +0200, David Hildenbrand wrote: >> 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, ...). > > > Well not necessarily, but it depends how clever we want to get. If you > look over on the OVMF/edk2 list, there's a proposal to do guest > migration via a mirror VM that invokes a co-routine embedded in the > OVMF binary: Yes, I heard of that. "Interesting" design. > > https://patchew.org/EDK2/20210818212048.162626-1-tobin@linux.ibm.com/ > > This gives us a page encryption mechanism that's provided by the host > but accepted via the guest using attestation, meaning we have a > mutually trusted piece of code that can use to extract encrypted pages. > It does seem it could be enhanced to do swapping for us as well if > that's a road we want to go down? Right, but that's than no longer ballooning, unless I am missing something important. You'd ask the guest to export/import, and you can trust it. But do we want to call something like that out of random kernel context when swapping/writeback, ...? Hard to tell. Feels like it won't win in a beauty contest. -- Thanks, David / dhildenb