Re: [RFC PATCH v2] x86/sev-es: Include XSS value in GHCB CPUID request

From: Borislav Petkov
Date: Thu Jun 15 2023 - 07:59:13 EST


On Wed, May 24, 2023 at 03:56:19PM +0000, John Allen wrote:
> + if (has_cpuflag(X86_FEATURE_SHSTK) && regs->ax == 0xd && regs->cx <= 1) {
> + unsigned long lo, hi;
> + u64 xss;
> +
> + /*
> + * Since vc_handle_cpuid may be used during early boot, the
> + * rdmsr wrappers are incompatible and should not be used.
> + * Invoke the instruction directly.
> + */
> + asm volatile("rdmsr" : "=a" (lo), "=d" (hi)
> + : "c" (MSR_IA32_XSS));
> + xss = (hi << 32) | lo;
> + ghcb_set_xss(ghcb, xss);

$ git grep ghcb_set_xss
$

So this patch needs some tree which I'm not aware of.

Also, this passing through of host XSS to the guest looks like it is
bypassing the vcpu->arch.ia32_xss copy which KVM seems to maintain. It
looks to me like the handling needs to be synchronized with it or so.

Thx.

--
Regards/Gruss,
Boris.

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