Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3349372pxb; Mon, 4 Apr 2022 14:17:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAgwgRH1lY1XgakzjkAmj2MUoPgElrzsqx3x1BWBXJPywUKDEkYT4EGnjM+yfoqre69jr1 X-Received: by 2002:a17:90a:a4c:b0:1ca:a723:aa76 with SMTP id o70-20020a17090a0a4c00b001caa723aa76mr148718pjo.101.1649107078156; Mon, 04 Apr 2022 14:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649107078; cv=none; d=google.com; s=arc-20160816; b=wT9uLZsiX7+FrZd0wZAAF1Tt9PUUDlLJw84aJm2MPdBC+b8CufK/rfw1wTZ3gg6JD3 Kg50B7I4f1gGZ8PqAJbiD0LvIK+bRydJIKk55J0wqJmdzNSpad6L9VLap5EXdRqFFQCK Z7/cwbueU+AGYF2/WNmM1+P+zVA01UPagLifSG6tFBJBVrDM5Fn7zHoBDImu9mmjdmCu CYc/JGReWINPKAEZsEs3pmcPZIzaGamyO3c3Q1Znxmz4q0iM1DAeSiRiL2XWdw0+6/Up ubKFRrzWAhvldUUf1sOCTo/5nMbnWm05nm0nFo4BH3sYUtbx3s2+pdCqxhdtU0xyvHCo qsaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=eHLXFPB43a0gnppLqjUxW0rgYvQoLtqoNm9fHewh/ZM=; b=zxedTauBYwD+2LwAgaxMoFFgU7wYX3W+VugVHzXeoruxjvSocrYYIvmkdriiai+4rf 9w6GqP2Zx8OmJAQDzBr5UKr2w40uvkhrX5GdHoGueTpVNh16p9PxB95qYzKc0kci3E3R rusKnmZWg+7jC1fLU7FKZfE/STr6zvuXiy9nxznBOuu71V29dH7Ck4JrZZHXb3oYoR5E MfDdV0rzbvvxZPi2EJb1XkiA9IqtCGIxD4n9KHaH1j03gMc9iMPLTVV7CxsetcCLovC2 3iTQoP99zAUmjOVy91/V8uBSQJfuqOQ2Uwo1ajk1LCXWQgGTPI/HXrSitBbWz2mzZhbm j89g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=JiGgFIpd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a17090a2ac300b001c6586c5f45si85494pjg.60.2022.04.04.14.17.44; Mon, 04 Apr 2022 14:17:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=JiGgFIpd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349000AbiDASVt (ORCPT + 99 others); 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-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" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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.