[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <453e1ccd-50c6-d6c9-e4e8-49fff6382101@amd.com>
Date: Mon, 6 Dec 2021 09:15:59 -0600
From: Brijesh Singh <brijesh.singh@....com>
To: Borislav Petkov <bp@...en8.de>
Cc: brijesh.singh@....com, x86@...nel.org,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
linux-efi@...r.kernel.org, platform-driver-x86@...r.kernel.org,
linux-coco@...ts.linux.dev, linux-mm@...ck.org,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Joerg Roedel <jroedel@...e.de>,
Tom Lendacky <thomas.lendacky@....com>,
"H. Peter Anvin" <hpa@...or.com>, Ard Biesheuvel <ardb@...nel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Jim Mattson <jmattson@...gle.com>,
Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Sergio Lopez <slp@...hat.com>, Peter Gonda <pgonda@...gle.com>,
Peter Zijlstra <peterz@...radead.org>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
David Rientjes <rientjes@...gle.com>,
Dov Murik <dovmurik@...ux.ibm.com>,
Tobin Feldman-Fitzthum <tobin@....com>,
Michael Roth <michael.roth@....com>,
Vlastimil Babka <vbabka@...e.cz>,
"Kirill A . Shutemov" <kirill@...temov.name>,
Andi Kleen <ak@...ux.intel.com>,
"Dr . David Alan Gilbert" <dgilbert@...hat.com>,
tony.luck@...el.com, marcorr@...gle.com,
sathyanarayanan.kuppuswamy@...ux.intel.com
Subject: Re: [PATCH v7 10/45] x86/sev: Add support for hypervisor feature
VMGEXIT
On 12/2/21 11:52 AM, Borislav Petkov wrote:
> On Wed, Nov 10, 2021 at 04:06:56PM -0600, Brijesh Singh wrote:
>> +/*
>> + * The hypervisor features are available from GHCB version 2 onward.
>> + */
>> +static bool get_hv_features(void)
>> +{
>> + u64 val;
>> +
>> + sev_hv_features = 0;
>> +
>> + if (ghcb_version < 2)
>> + return false;
>> +
>> + sev_es_wr_ghcb_msr(GHCB_MSR_HV_FT_REQ);
>> + VMGEXIT();
>> +
>> + val = sev_es_rd_ghcb_msr();
>> + if (GHCB_RESP_CODE(val) != GHCB_MSR_HV_FT_RESP)
>> + return false;
>> +
>> + sev_hv_features = GHCB_MSR_HV_FT_RESP_VAL(val);
>> +
>> + return true;
>> +}
>
> I still don't like this.
>
> This is more of that run-me-in-the-exception-handler thing while this is
> purely feature detection stuff which needs to be done exactly once on
> init.
>
> IOW, that stanza
>
> if (!sev_es_negotiate_protocol())
> sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SEV_ES_PROT_UNSUPPORTED);
>
> should be called once in sev_enable() for the decompressor kernel and
> once in sev_es_init_vc_handling() for kernel proper.
>
I will look into it, I will improve the sev_enable() to call GHCB MSR
protocol query the version and feature.
> Then you don't need to do any of that sev_hv_features = 0 thing but
> detect them exactly once and query them as much as you can.
>
> Thx.
>
Powered by blists - more mailing lists