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=-8.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 86011C4320E for ; Tue, 31 Aug 2021 19:12:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0817F61056 for ; Tue, 31 Aug 2021 19:12:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0817F61056 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 8E5626B006C; Tue, 31 Aug 2021 15:12:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 892F16B0071; Tue, 31 Aug 2021 15:12:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75B0B6B0072; Tue, 31 Aug 2021 15:12:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0247.hostedemail.com [216.40.44.247]) by kanga.kvack.org (Postfix) with ESMTP id 63DE86B006C for ; Tue, 31 Aug 2021 15:12:52 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 26CDD181AEF21 for ; Tue, 31 Aug 2021 19:12:52 +0000 (UTC) X-FDA: 78536322984.07.2AE1830 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id BF580F000090 for ; Tue, 31 Aug 2021 19:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630437171; 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=B3R8+9xCMOWLuSi664S67yIHwiGeNUaH36y7wRqkQk8=; b=FUZ/rXlQvZM75rOFydFPmME0oFtv5gGfsohVbJt6+t0S3qkB/FgcDZwuwAXC+2h3TsIPAH z+b3KXbrK2gx4K4mxjJaTqTzavOuyFAMmFGMqBQfuVJbZNHvhGPcrMc3Ew9z+9RmOmUrbu EnXrqXD6ymZoJO2ygWNZgnbINka5P5Y= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-382-Bl682Tb5Mg2hRynNwpqQYw-1; Tue, 31 Aug 2021 15:12:47 -0400 X-MC-Unique: Bl682Tb5Mg2hRynNwpqQYw-1 Received: by mail-wr1-f71.google.com with SMTP id n18-20020adfe792000000b00156ae576abdso150395wrm.9 for ; Tue, 31 Aug 2021 12:12:47 -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=B3R8+9xCMOWLuSi664S67yIHwiGeNUaH36y7wRqkQk8=; b=haws2Ur94GGVhdzG4yfnUlKtRLXbMRkni7/xUlpYzEdEITsdhTnpna4vFtWE8rwijx oaQm+hsVcG+yVRDfXVFujifJVTGB2X619LK7QxrZkX9NFvsyiFhCANy2FscUHY7a1Uu5 2TThHE7q75sh8Hmlyx0HOkGZIPqCpHGog8KB6N3Jfl9OJAWF+XUWJr4Y6YLFx+7AeKVw 4lHs85qUNPcQCygr6WIwMAnsnz3G5muRjkNalBSUKuQcCFIJaRwQE2exbtqkR+eb6+e8 eKrgaJUID3iVUyVlUPa9wbi5GYex+JA89n+DlJlVjuzG072J0eg9q5MvJun+PDsxtgZy BjaA== X-Gm-Message-State: AOAM530eY40Gw2qXy+txjJdowYWxxjoGKoiyi7JcU6Ux5XNo8jhRirSF UiY+kgpliXztRLukHZHUJtzL3px4abWAVmdcDJU9jPCzjXEHfevn4lbLvI/g4L0lHRLfpKwvX3Y YQPuvq6Jo5Jo= X-Received: by 2002:a1c:f315:: with SMTP id q21mr5819439wmq.76.1630437166294; Tue, 31 Aug 2021 12:12:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiLNTwKQMvs3colTkzHCAECIzU7cGUrdshsPwDbRyk3ubr6ahQwvcGeQbVyq70Sw5+SV5+fA== X-Received: by 2002:a1c:f315:: with SMTP id q21mr5819425wmq.76.1630437166118; Tue, 31 Aug 2021 12:12:46 -0700 (PDT) Received: from [192.168.3.132] (p4ff23bf5.dip0.t-ipconnect.de. [79.242.59.245]) by smtp.gmail.com with ESMTPSA id f5sm3231993wmb.47.2021.08.31.12.12.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Aug 2021 12:12:45 -0700 (PDT) Subject: Re: [RFC] KVM: mm: fd-based approach for supporting KVM guest private memory To: Sean Christopherson , Andy Lutomirski 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> <40af9d25-c854-8846-fdab-13fe70b3b279@kernel.org> <73319f3c-6f5e-4f39-a678-7be5fddd55f2@www.fastmail.com> From: David Hildenbrand Organization: Red Hat Message-ID: <949e6d95-266d-0234-3b86-6bd3c5267333@redhat.com> Date: Tue, 31 Aug 2021 21:12:44 +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: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="FUZ/rXlQ"; spf=none (imf17.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: qcpzpjfahn4am69m8iwusodsxsdqr9or X-Rspamd-Queue-Id: BF580F000090 X-Rspamd-Server: rspam04 X-HE-Tag: 1630437171-906883 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: On 28.08.21 00:28, Sean Christopherson wrote: > On Fri, Aug 27, 2021, Andy Lutomirski wrote: >> >> On Thu, Aug 26, 2021, at 2:26 PM, David Hildenbrand wrote: >>> On 26.08.21 19:05, Andy Lutomirski wrote: >> >>>> Oof. That's quite a requirement. What's the point of the VMA once all >>>> this is done? >>> >>> You can keep using things like mbind(), madvise(), ... and the GUP code >>> with a special flag might mostly just do what you want. You won't have >>> to reinvent too many wheels on the page fault logic side at least. > > Ya, Kirill's RFC more or less proved a special GUP flag would indeed Just Work. > However, the KVM page fault side of things would require only a handful of small > changes to send private memslots down a different path. Compared to the rest of > the enabling, it's quite minor. > > The counter to that is other KVM architectures would need to learn how to use the > new APIs, though I suspect that there will be a fair bit of arch enabling regardless > of what route we take. > >> You can keep calling the functions. The implementations working is a >> different story: you can't just unmap (pte_numa-style or otherwise) a private >> guest page to quiesce it, move it with memcpy(), and then fault it back in. > > Ya, I brought this up in my earlier reply. Even the initial implementation (without > real NUMA support) would likely be painful, e.g. the KVM TDX RFC/PoC adds dedicated > logic in KVM to handle the case where NUMA balancing zaps a _pinned_ page and then > KVM fault in the same pfn. It's not thaaat ugly, but it's arguably more invasive > to KVM's page fault flows than a new fd-based private memslot scheme. I might have a different mindset, but less code churn doesn't necessarily translate to "better approach". I'm certainly not pushing for what I proposed (it's a rough, broken sketch). I'm much rather trying to come up with alternatives that try solving the same issue, handling the identified requirements. I have a gut feeling that the list of requirements might not be complete yet. For example, I wonder if we have to protect against user space replacing private pages by shared pages or punishing random holes into the encrypted memory fd. -- Thanks, David / dhildenb