Re: [PATCH v6 14/42] x86/sev: Register GHCB memory when SEV-SNP is active

From: Borislav Petkov
Date: Tue Nov 02 2021 - 12:53:44 EST


On Fri, Oct 08, 2021 at 01:04:25PM -0500, Brijesh Singh wrote:
> + /* SEV-SNP guest requires that GHCB must be registered. */
> + if (cc_platform_has(CC_ATTR_SEV_SNP))
> + snp_register_ghcb(data, __pa(ghcb));

This looks like more of that "let's register a GHCB at the time the
first #VC fires".

And there already is setup_ghcb() which is called in the #VC handler.
And that thing registers a GHCB GPA.

But then you have to do it here again.

I think this should be changed together with the CPUID page detection
stuff we talked about earlier, where, after you've established that this
is an SNP guest, you call setup_ghcb() *once* and after that you have
everything set up, including the GHCB GPA. And then the #VC exceptions
can come.

Right?

Or is there a chicken-and-an-egg issue here which I'm not thinking
about?

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette