On 09/12/2022 09:59, Roger Pau Monné wrote: > 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 <andrew.coop...@citrix.com> >> Signed-off-by: Jan Beulich <jbeul...@suse.com> >> --- >> 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.
It shouldn't. Turn the count field into a bitmap of thread_ids. The interface to this functionality should be WRMSR-like, and should support repeated writes of the same value. Anything else is a timebomb which has already gone off once... I'll have a play with this while looking into the repro I've got. ~Andrew