On Thu, Dec 08, 2022 at 12:24:54PM +0100, Jan Beulich wrote:
> core_set_legacy_ssbd() counts the number of times SSBD is being enabled
> via LS_CFG on a core. This assumes that calls there only occur if the
> state actually changes. While svm_ctxt_switch_{to,from}() conform to
> this, guest_wrmsr() doesn't: It also calls the function when the bit
> doesn't actually change. Extend the conditional there accordingly.
> 
> Fixes: b2030e6730a2 ("amd/virt_ssbd: set SSBD at vCPU context switch")
> Reported-by: Andrew Cooper <[email protected]>
> Signed-off-by: Jan Beulich <[email protected]>
> ---
> This is the less intrusive but more fragile variant of a fix. The
> alternative would be to have core_set_legacy_ssbd() record per-thread
> state, such that the necessary checking can be done there.

Hm, yes, it's going to take a bit more of memory to keep track of
this.

> This wants properly testing on affected hardware. From Andrew's
> description it's also not clear whether this really is addressing that
> problem, or yet another one in this same area.
> 
> --- a/xen/arch/x86/msr.c
> +++ b/xen/arch/x86/msr.c
> @@ -699,12 +699,16 @@ int guest_wrmsr(struct vcpu *v, uint32_t
>          }
>          else

I think you could turn this into an `else if` and check if the new
value and the current one differ on the SSBD bit?

Provided it fixes the issue:

Acked-by: Roger Pau Monné <[email protected]>

Thanks, Roger.

Reply via email to