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 X-Spam-Level: X-Spam-Status: No, score=-6.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2354FC4320E for ; Wed, 1 Sep 2021 17:09:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A6C47610C9 for ; Wed, 1 Sep 2021 17:09:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A6C47610C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 31DD8900002; Wed, 1 Sep 2021 13:09:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A5108D0001; Wed, 1 Sep 2021 13:09:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11EE1900002; Wed, 1 Sep 2021 13:09:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id F41C98D0001 for ; Wed, 1 Sep 2021 13:09:02 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B449C180279A3 for ; Wed, 1 Sep 2021 17:09:02 +0000 (UTC) X-FDA: 78539639724.22.F2B0F7C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 29271B0000A1 for ; Wed, 1 Sep 2021 17:09:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630516141; 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=ppU0WSH8L8u52xOzHa0kdyUHC+mfjhjRB8vBl5001vI=; b=ATQOyzCCR/UmRXn5npMZRFaMpXiDdVI90e1bVeJzxvxj279t5CXfMpktHJYbFehdC7RgD6 ZGnCAfwrXINByaHb5+pBo7aNcez8iBH/0xnwrETJZT9hyDQkFkzg/JG/dK8AKadO90v2dt UlH+V1pr3K9vSXmYthhyYDUtHV8C7Vk= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-yCG15ZFjMQSI5dsKVfcOAQ-1; Wed, 01 Sep 2021 13:08:59 -0400 X-MC-Unique: yCG15ZFjMQSI5dsKVfcOAQ-1 Received: by mail-wr1-f69.google.com with SMTP id u2-20020adfdd42000000b001579f5d6779so130208wrm.8 for ; Wed, 01 Sep 2021 10:08:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=ppU0WSH8L8u52xOzHa0kdyUHC+mfjhjRB8vBl5001vI=; b=UbVOwPDiljhyliOmvhy9RenGhsj+gj1qt/aRolAL1NEunDKgNxMyKnSdMlVPQ35uc6 k+V6zjOhXgzzVCZfsPS4Eb/Xb/iQfnPZFlH94gbbJH5L9jKRtuXKiCccnTB4JXqyvR62 7urswZ2NMsuWEFPAff6/uKwju8V1H469khyv9PIztV2EK7qojZhjLRbOyzus5d8fKRAc UM4XTi/x2vuDzHUEM3gUmtB1kmOewS1VZDMnr7VGsnbGPWH7e3EzVzFOw8AVBdfj2t2F kszR+dbVIeMiu1ECDuJjlM+ZuL03znfy+v6oXNC63OvWkXZFob+WikOCa11rTKDKuScB 0L/w== X-Gm-Message-State: AOAM531DX4Ntrt+/4JOeBQwrDEUTx7lFHJHlNc7ll7F4Hd7JCH2JTjKc 9/L22MRMEb5NSAeP518QJpgofA4FOPBrSO3mRkNXhf494sDp6LVVKk4H3mognI8E7jidDwwNjMU ORLPuKGlmFNc= X-Received: by 2002:a1c:7e8a:: with SMTP id z132mr436990wmc.75.1630516138294; Wed, 01 Sep 2021 10:08:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtTx+lCLKYPuP/eNNEgNo/a72ut1zmit05cmxtndTEGk43A0rPKYZ+5URztN5SHWb3pXiUrA== X-Received: by 2002:a1c:7e8a:: with SMTP id z132mr436955wmc.75.1630516138034; Wed, 01 Sep 2021 10:08:58 -0700 (PDT) Received: from [192.168.3.132] (p4ff23f71.dip0.t-ipconnect.de. [79.242.63.113]) by smtp.gmail.com with ESMTPSA id t14sm133532wmi.12.2021.09.01.10.08.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Sep 2021 10:08:57 -0700 (PDT) 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> <1a4a1548-7e14-c2b4-e210-cc60a2895acd@redhat.com> <4b863492fd33dce28a3a61662d649987b7d5066d.camel@linux.ibm.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [RFC] KVM: mm: fd-based approach for supporting KVM guest private memory Message-ID: <214ca837-3102-d6d1-764e-6b4cd1bab368@redhat.com> Date: Wed, 1 Sep 2021 19:08:55 +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: <4b863492fd33dce28a3a61662d649987b7d5066d.camel@linux.ibm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ATQOyzCC; spf=none (imf24.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: h1eg5xbg3j4thiu99b1qejb994s1hfnf X-Rspamd-Queue-Id: 29271B0000A1 X-Rspamd-Server: rspam04 X-HE-Tag: 1630516142-812274 Content-Transfer-Encoding: quoted-printable 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: >>> 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. >=20 > Heh, well what other suggestion do you have? The problem is there > needs to be code somewhere to perform some operations that's trusted by > both the guest and the host. The only element for a confidential VM > that has this shared trust is the OVMF firmware, so it seems logical to > use it. Let me put it this way: I worked with another architecture that doesn't=20 fault on access of a secure page, but instead automatically=20 exports/encrypts it so it can be swapped. It doesn't send a MCE and=20 kills the host. It doesn't require fancy code in the guest firmware to=20 export a page. The code runs in the ultravisor -- yes, I'm talking about s390x. Now, I=20 am not an expert on all of the glory details of TDX, SEV, ... to say=20 which attack surface they introduced with that design, and if it can't=20 be mitigated. I can only assume that there are real reasons (e.g.,=20 supporting an ultravisor is problematic, patents? ;) ) why x86-64 is=20 different. So whenever I see something really complicated to work around such=20 issues, it feels to me like a hardware/platform limitation is making our=20 life hard and forces us to come up with such "interesting" designs. Sure, it's logical in this context, but it feels like "The house doesn't=20 have a door, so I'll have to climb through the window.". It gets the job=20 done but isn't ideally what you'd want to have. If you understand what I=20 am trying to say :) >=20 >> >>> 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. >=20 > What I was thinking is that OVMF can emulate devices in this trusted > code ... another potential use for it is a trusted vTPM for SEV-SNP so > we can do measured boot. To use it we'd give the guest kernel some > type of virtual swap driver that attaches to this OVMF device. I > suppose by the time we've done this, it really does look like a > balloon, but I'd like to think of it more as a paravirt memory > controller since it might be used to make a guest more co-operative in > a host overcommit situation. >=20 > That's not to say we *should* do this, merely that it doesn't have to > look like a pig with lipstick. It's an interesting approach: it would essentially mean that the OVMF=20 would swap pages out to some virtual device and then essentially=20 "inflate" the pages like a balloon. Still, it doesn't sound like=20 something you want to trigger from actual kernel context when actually=20 swapping in the kernel. It would much rather be something like other=20 balloon implementations: completely controlled by user space. So yes, "doesn't look like a pig with lipstick", but still compared to=20 proper in-kernel swapping, looks like a workaround. --=20 Thanks, David / dhildenb