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=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL 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 6836BC07E95 for ; Mon, 19 Jul 2021 19:14:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1621C60720 for ; Mon, 19 Jul 2021 19:14:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1621C60720 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9DC9A8D00EC; Mon, 19 Jul 2021 15:14:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9655E6B018E; Mon, 19 Jul 2021 15:14:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 790938D00EC; Mon, 19 Jul 2021 15:14:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id 4BE036B018D for ; Mon, 19 Jul 2021 15:14:22 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DA589184600CA for ; Mon, 19 Jul 2021 19:14:20 +0000 (UTC) X-FDA: 78380288280.31.809CF9D Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by imf04.hostedemail.com (Postfix) with ESMTP id 920EF50000A0 for ; Mon, 19 Jul 2021 19:14:20 +0000 (UTC) Received: by mail-pg1-f170.google.com with SMTP id u14so19980920pga.11 for ; Mon, 19 Jul 2021 12:14:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2XllpOUOhhdBvpd5Av+f2na/9hRxJV/QURDHxqubmW8=; b=TAK2LJLZI6u4VHRX2CtOxDwgftlqvQHU1lzhdQy0LcCcpbcr9ralpKcma3Fe1DAXVB YEbBG2X95V7PcYiO0NGfbsi3Mq0cpEE3BWadst6/qrqSI45eUiSf3Qjvvs6crWGL9pAk f2S4uAxDH1tnD8dXBw6emsJHGIQpk2eykj7mExtMmKVHuA7Vr+eL6Oey1hzAPDg0oa7c OqiF98AMx5gJrcAFkQlYE7iIsV7JKMNqh9RKqeBFp/4OqS+g0z1Kqo7z2BDexEgHIRFG OcCF2FjqNIBEhh9hv1V9N0corxEGyzsVRPh6ngPwFo0wqMpY3VZZiMwxPSWpMijKQ4qA 4xYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2XllpOUOhhdBvpd5Av+f2na/9hRxJV/QURDHxqubmW8=; b=W7tFY4yxo6MaCy7MdH/TgKa5TiVPNVJ85xzdcl15Pmc7wZm3x68ihBdAtBQw7UcNtr DdMcj1oli29ulCZh2+b3fYhMu4diQrVc8bgAAVxwbZRxThH3pgLONT9JWpOZxetD6CaA QMRXisk1qbU4nC/D0MYNbGwYM071jaibmITvWbuR7Bz40PmaTk+2vpnEChfkxx0WU2Bh IMvtEN5xWGI8oyt/JvtX6IQ6MNFEWNuEqH8qcO+/9wTvS9FwrldGg81zXxDLJLCxgC3j MVexhwbcicqRRafiOEhbwo7GKtGBtEl2FD74Te3S8R9tCPPSzcyP2o9xL2p3coiPWmQX +tUQ== X-Gm-Message-State: AOAM530/4SZQ8dx1eiMef0/rVjFKxGH4CSn/H2f6D1UPR3QwMfmR/98G Nlh9qGQxdctwKrnYAMfDgQcPWQ== X-Google-Smtp-Source: ABdhPJx+EzDcqa/llq3nQF6Vq0NHWvv5j8Tkv3O31Pzz7AmNV8hJdli78mh1Sa+ATMQeYmFd5XN3Uw== X-Received: by 2002:a63:5059:: with SMTP id q25mr26911779pgl.9.1626722059360; Mon, 19 Jul 2021 12:14:19 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id u24sm22109816pfm.141.2021.07.19.12.14.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 12:14:18 -0700 (PDT) Date: Mon, 19 Jul 2021 19:14:15 +0000 From: Sean Christopherson To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , Vlastimil Babka , tony.luck@intel.com, npmccallum@redhat.com, brijesh.ksingh@gmail.com Subject: Re: [PATCH Part2 RFC v4 25/40] KVM: SVM: Reclaim the guest pages when SEV-SNP VM terminates Message-ID: References: <20210707183616.5620-1-brijesh.singh@amd.com> <20210707183616.5620-26-brijesh.singh@amd.com> <2711d9f9-21a0-7baa-d0ff-2c0f69ca6949@amd.com> <912c929c-06ba-a391-36bb-050384907d81@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=TAK2LJLZ; spf=pass (imf04.hostedemail.com: domain of seanjc@google.com designates 209.85.215.170 as permitted sender) smtp.mailfrom=seanjc@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam02 X-Stat-Signature: jqup36u7p3hjru7f1kbdbqt31kzf1xoo X-Rspamd-Queue-Id: 920EF50000A0 X-HE-Tag: 1626722060-309669 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 Mon, Jul 19, 2021, Sean Christopherson wrote: > On Mon, Jul 19, 2021, Brijesh Singh wrote: > > > > On 7/19/21 12:18 PM, Sean Christopherson wrote: > > > > > > > > Okay, I will add helper to make things easier. One case where we will > > > > need to directly call the rmpupdate() is during the LAUNCH_UPDATE > > > > command. In that case the page is private and its immutable bit is also > > > > set. This is because the firmware makes change to the page, and we are > > > > required to set the immutable bit before the call. > > > > > > Or do "int rmp_make_firmware(u64 pfn, bool immutable)"? > > > > That's not what we need. > > > > We need 'rmp_make_private() + immutable' all in one RMPUPDATE. Here is the > > snippet from SNP_LAUNCH_UPDATE. > > Ah, not firmwrare, gotcha. But we can still use a helper, e.g. an inner > double-underscore helper, __rmp_make_private(). Hmm, looking at it again, I think I also got confused by the comment for the VMSA page: /* Transition the VMSA page to a firmware state. */ e.assigned = 1; e.immutable = 1; e.asid = sev->asid; e.gpa = -1; e.pagesize = RMP_PG_SIZE_4K; Unlike __snp_alloc_firmware_pages() in the CCP code, the VMSA is associated with the guest's ASID, just not a GPA. I.e. the VMSA is more of a specialized guest private page, as opposed to a dedicated firmware page. I.e. a __rmp_make_private() and/or rmp_make_private_immutable() definitely seems like a good idea.