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 03C4AC433EF for ; Fri, 1 Apr 2022 18:20:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349216AbiDASVt (ORCPT ); Fri, 1 Apr 2022 14:21:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237960AbiDASVr (ORCPT ); Fri, 1 Apr 2022 14:21:47 -0400 Received: from mail-oi1-x230.google.com (mail-oi1-x230.google.com [IPv6:2607:f8b0:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3927038198 for ; Fri, 1 Apr 2022 11:19:58 -0700 (PDT) Received: by mail-oi1-x230.google.com with SMTP id r8so3622923oib.5 for ; Fri, 01 Apr 2022 11:19:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eHLXFPB43a0gnppLqjUxW0rgYvQoLtqoNm9fHewh/ZM=; b=JiGgFIpd74uTRA6V+9qW7DaMC71MtGGaxOvC6WdOCd/bXamUfcNrHIEpUkeLU0scEN XB48Iw+VG++iNY8mBwVBtxeGMTHwZ4OUvnlFoPFrHGPANQ954d3T4nY7AutwdgmUbAi+ miYUwUzNFg7q9RxqPFL1qg/xEYlAjSIklEZbEaiDO3aQL5Wjw3fB/5jqZSfSJL9hUuMV GUxB/tqFZr9JT1xu2UdkWHDAQQL1CjDhPYthTfPMwTJyEErQyq5p5aBaZlpjmEkPL5cD Ok9XdzuLFDkopRQIO610cL0s0AO2OM+p4ndPP0GAUKq+vzbEKDQPcISmmRwHX+z8vpgd dFpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eHLXFPB43a0gnppLqjUxW0rgYvQoLtqoNm9fHewh/ZM=; b=YOLhQMOoERrj1XD4CfWc2HJY4zSmF8ELLqy/IFq7gmQkF0r07CJq5rKLKzpKYrDD7H H9vM3AgUWY6gMi5+/XXmWgFyQGN4nWI5tgsbtuFu0SknT6wEHzQTmwvba2oAC7OpI2JU yW306RKiy+FSU/MzkTQvjblWBCHAcmJEtU3fDUBbN4J3CfdOfnPFXSxseAxiO1uNuCPJ HaeLC0EeDnqYcVXqExwyNWchk/UvAU++X8M+DE2E8sNo4ZT2mrKSwxRqu+auye+HHWro 7KG3R4dBoQAiuUL+Zxh2JEtwz99bcifPlhNX1/pNxioXaBiwmmw/s2DMWsNaX2l5WyIF 4JYg== X-Gm-Message-State: AOAM533oh9fdgAUk573aA9ErwcCNVTXBqRwhWIghKEATEgzleVJdJpYK n8MDXz7YKZ15ORK3V5ktwaMaqIWRqshqOu10K2G7EA== X-Google-Smtp-Source: ABdhPJzAra3XYpsanxy7lbMV6Dj0vB4VTMrYWik4wdND29JmH+6sY2++wMQxn5qSA0fDTBGh8r6x4Okf4wizD5UDOKQ= X-Received: by 2002:a05:6808:11cc:b0:2d9:a01a:488f with SMTP id p12-20020a05680811cc00b002d9a01a488fmr5381769oiv.218.1648837197341; Fri, 01 Apr 2022 11:19:57 -0700 (PDT) MIME-Version: 1.0 References: <20220308043857.13652-1-nikunj@amd.com> <5567f4ec-bbcf-4caf-16c1-3621b77a1779@amd.com> In-Reply-To: From: Marc Orr Date: Fri, 1 Apr 2022 11:19:46 -0700 Message-ID: Subject: Re: [PATCH RFC v1 0/9] KVM: SVM: Defer page pinning for SEV guests To: Sean Christopherson Cc: Peter Gonda , "Nikunj A. Dadhania" , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Brijesh Singh , Tom Lendacky , Bharata B Rao , "Maciej S . Szmigiero" , Mingwei Zhang , David Hildenbrand , kvm list , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 1, 2022 at 11:02 AM Sean Christopherson wrote: > > On Fri, Apr 01, 2022, Marc Orr wrote: > > On Thu, Mar 31, 2022 at 12:01 PM Sean Christopherson wrote: > > > Yep, that's a big reason why I view purging the existing SEV memory management as > > > a long term goal. The other being that userspace obviously needs to be updated to > > > support UPM[*]. I suspect the only feasible way to enable this for SEV/SEV-ES > > > would be to restrict it to new VM types that have a disclaimer regarding additional > > > requirements. > > > > > > [*] I believe Peter coined the UPM acronym for "Unmapping guest Private Memory". We've > > > been using it iternally for discussion and it rolls off the tongue a lot easier than > > > the full phrase, and is much more precise/descriptive than just "private fd". > > > > Can we really "purge the existing SEV memory management"? This seems > > like a non-starter because it violates userspace API (i.e., the > > ability for the userspace VMM to run a guest without > > KVM_FEATURE_HC_MAP_GPA_RANGE). Or maybe I'm not quite following what > > you mean by purge. > > I really do mean purge, but I also really do mean "long term", as in 5+ years > (probably 10+ if I'm being realistic). > > Removing support is completely ok, as is changing the uABI, the rule is that we > can't break userspace. If all users are migrated to private-fd, e.g. by carrots > and/or sticks such as putting the code into maintenance-only mode, then at some > point in the future there will be no users left to break and we can drop the > current code and make use of private-fd mandatory for SEV/SEV-ES guests. Ah, it makes sense now. Thanks! > > Assuming that UPM-based lazy pinning comes together via a new VM type > > that only supports new images based on a minimum kernel version with > > KVM_FEATURE_HC_MAP_GPA_RANGE, then I think this would like as follows: > > > > 1. Userspace VMM: Check SEV VM type. If type is legacy SEV type then > > do upfront pinning. Else, skip up front pinning. > > Yep, if by legacy "SEV type" you mean "SEV/SEV-ES guest that isn't required to > use MAP_GPA_RANGE", which I'm pretty sure you do based on #3. Yeah, that's exactly what I meant. > > 2. KVM: I'm not sure anything special needs to happen here. For the > > legacy VM types, it can be configured to use legacy memslots, > > presumably the same as non-CVMs will be configured. For the new VM > > type, it should be configured to use UPM. > > Correct, for now, KVM does nothing different for SEV/SEV-ES guests. > > > 3. Control plane (thing creating VMs): Responsible for not allowing > > legacy SEV images (i.e., images without KVM_FEATURE_HC_MAP_GPA_RANGE) > > with the new SEV VM types that use UPM and have support for demand > > pinning. > > > > Sean: Did I get this right? > > Yep. Thank you for verifying.