Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp585188pxb; Thu, 31 Mar 2022 12:13:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/UmssKhxp7LICN/RSm2AepGk02oLSwc794XdfhkgJia+0KF3/qUutdVi9xMc8mn8yopiZ X-Received: by 2002:a17:907:1ca3:b0:6e0:eb09:8 with SMTP id nb35-20020a1709071ca300b006e0eb090008mr6256332ejc.49.1648753980297; Thu, 31 Mar 2022 12:13:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648753980; cv=none; d=google.com; s=arc-20160816; b=xy5ui7+lQc7OKJjwZ00SWlgetsoTamtYg05CGrICdBfDFvoKEYdQwb4CUzyZkvAoEx 0s/HNDgM0oXChO4TOn0NwfDP4+ieTFC2xv6o41W8/c2bYJTB8i7I10j0cRk5neWwtYok pX8I2Ka0uZ2sxPd7amICauhGfO3+s0yxkVY+mw/NNzVY1xDAXPzuwKdow/uWZmGOxfvx HZCYCsnmFvzDlFCsKRdxKigcUQ09MpPJpFaLvDgh2hkC0mUoDvXK6IuY3Bh8J2CWx5dC wcN733agElb91tT5wrVFaMZhYThLn6XB4FXbvg4VHsl3LgU6VNj7xp5wfy13P4BCdEvs zYCg== 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=Tvw6taPpgUktbBufV96johk8JlHiJhYBWcWPuBo5rDc=; b=K07lHivygTdTwogziqi0x6trEE60egywmmJjN6o2XS3bmnS096JFgtmeJJE7gkMHim L6UoWi6gB31w9KMXtM9/DXUD9wYYJxAXwM/IKUlX5xJ5USJ6I5xQzvdF/Y2MGfMri553 fvk7gxfwrQrzOq5t2QCVBb2uFm/M9H7GnIYioOBQ0nH7atYr8FctuzXYzwwxtw/bDwAD 1SJkqiA3B9QQApduOgBC4cUDDAkf+UNTyc8JNFbZBCUjbTqUZlXUrU20qLJPdwBRZh8h Ihxfq8/WXFWhfy32i4Bz0rkoqh5gZWzmfDKN4TVYgHU+657+OAVQW7SE0LWrFiZgQjCx k2gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=gyTvwZKk; 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 e15-20020a056402190f00b00418c2b5be16si401095edz.248.2022.03.31.12.12.33; Thu, 31 Mar 2022 12:13:00 -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=gyTvwZKk; 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 S234580AbiCaSeW (ORCPT + 99 others); Thu, 31 Mar 2022 14:34:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232464AbiCaSeW (ORCPT ); Thu, 31 Mar 2022 14:34:22 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 975131C1ED5 for ; Thu, 31 Mar 2022 11:32:33 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id c15so902070ljr.9 for ; Thu, 31 Mar 2022 11:32:33 -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=Tvw6taPpgUktbBufV96johk8JlHiJhYBWcWPuBo5rDc=; b=gyTvwZKkWvITZ/zBPRstzK2sv3jlV0a0Qv4j6f3+SSTv0Q+DPIDg1CHCfkMvOizNNe fcFu/+LVmwvdfBMnWx9eJpH9bXskgTOomTeSXivuJphqNC1UIdx3Wm8AnWje6VCw/0Ws bVnVtbYRbbzSqSas2eUdPUXv3oGMaX7cZ0gpccp1XPIrzCtNiYGbLF0QfSJ/iVlMe1cs SAV0A2z33vKySiLF0gPFvGh2Brkp9URnuHx7Y0MYyCQW32BDoS1hBgwHysfxKhG+3A8T isNoHSIjD0P2uik7tChfWEI02cHLuFxNmBbHCnNA0kJXVhKpd+ty7goKqaGsInhk0JcZ aXUg== 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=Tvw6taPpgUktbBufV96johk8JlHiJhYBWcWPuBo5rDc=; b=TPI6MOSMECefSNwNMSOERPdiK46wHJv6jGsDkIyhVWumJykSeAxA+j7Mi0O2RhVXAN QgLe/YyC39Wuvvmd3AnGiCc0A+EqEbBxURLV+K0TvMAagjsWgu+NiOiyBitBvUuhEMON +/npchV2wZ3+SIo/470ccttOnOYeqyUEQg15m54PbI2bre4xBUm8Xz69e6jOlA6EBzZt l5c3bkigrSc2jw0AUuLMbLancvsqoh5s++cJLi5M4HPEAAdh8vaGyvTMXyS8lVT+E97f Bgei2evo6QL4PjuQVVOOw5cnRjctFS3X5dBW2XWyQo6Rm6G20ItLQ/fkbqiz+gRdtu8H LPkQ== X-Gm-Message-State: AOAM532gf8HNWnzTotDe4DRg8rTmk+UvRt6jApzLBhYYydpmEoQDupYe AvdFwRgocKbpiINwifT9F8RqHMNwAQW5otVbbV7ctQ== X-Received: by 2002:a2e:3c1a:0:b0:249:88f6:f606 with SMTP id j26-20020a2e3c1a000000b0024988f6f606mr11027684lja.132.1648751549725; Thu, 31 Mar 2022 11:32:29 -0700 (PDT) MIME-Version: 1.0 References: <20220308043857.13652-1-nikunj@amd.com> <5567f4ec-bbcf-4caf-16c1-3621b77a1779@amd.com> In-Reply-To: <5567f4ec-bbcf-4caf-16c1-3621b77a1779@amd.com> From: Peter Gonda Date: Thu, 31 Mar 2022 12:32:18 -0600 Message-ID: Subject: Re: [PATCH RFC v1 0/9] KVM: SVM: Defer page pinning for SEV guests To: "Nikunj A. Dadhania" Cc: Sean Christopherson , 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=unavailable 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 Wed, Mar 30, 2022 at 10:48 PM Nikunj A. Dadhania wrote: > > > > On 3/31/2022 1:17 AM, Sean Christopherson wrote: > > On Wed, Mar 30, 2022, Nikunj A. Dadhania wrote: > >> On 3/29/2022 2:30 AM, Sean Christopherson wrote: > >>> Let me preface this by saying I generally like the idea and especially the > >>> performance, but... > >>> > >>> I think we should abandon this approach in favor of committing all our resources > >>> to fd-based private memory[*], which (if done right) will provide on-demand pinning > >>> for "free". > >> > >> I will give this a try for SEV, was on my todo list. > >> > >>> I would much rather get that support merged sooner than later, and use > >>> it as a carrot for legacy SEV to get users to move over to its new APIs, with a long > >>> term goal of deprecating and disallowing SEV/SEV-ES guests without fd-based private > >>> memory. > >> > >>> That would require guest kernel support to communicate private vs. shared, > >> > >> Could you explain this in more detail? This is required for punching hole for shared pages? > > > > Unlike SEV-SNP, which enumerates private vs. shared in the error code, SEV and SEV-ES > > don't provide private vs. shared information to the host (KVM) on page fault. And > > it's even more fundamental then that, as SEV/SEV-ES won't even fault if the guest > > accesses the "wrong" GPA variant, they'll silent consume/corrupt data. > > > > That means KVM can't support implicit conversions for SEV/SEV-ES, and so an explicit > > hypercall is mandatory. SEV doesn't even have a vendor-agnostic guest/host paravirt > > ABI, and IIRC SEV-ES doesn't provide a conversion/map hypercall in the GHCB spec, so > > running a SEV/SEV-ES guest under UPM would require the guest firmware+kernel to be > > properly enlightened beyond what is required architecturally. > > > > So with guest supporting KVM_FEATURE_HC_MAP_GPA_RANGE and host (KVM) supporting > KVM_HC_MAP_GPA_RANGE hypercall, SEV/SEV-ES guest should communicate private/shared > pages to the hypervisor, this information can be used to mark page shared/private. One concern here may be that the VMM doesn't know which guests have KVM_FEATURE_HC_MAP_GPA_RANGE support and which don't. Only once the guest boots does the guest tell KVM that it supports KVM_FEATURE_HC_MAP_GPA_RANGE. If the guest doesn't we need to pin all the memory before we run the guest to be safe to be safe.