On 9/29/22 19:47, Jim Mattson wrote:
It sounds like that behavior may need clarification from AMD. If that's
possible then it might indeed make sense to move the AMD spec_ctrl wrmsr
to asm like we did for Intel.
On the other side of the transition, restoration of the host
IA32_SPEC_CTRL value is definitely way too late. With respect to the
user/kernel boundary, AMD says, "If software chooses to toggle STIBP
(e.g., set STIBP on kernel entry, and clear it on kernel exit),
software should set STIBP to 1 before executing the return thunk
training sequence." I assume the same requirements apply to the
guest/host boundary. The return thunk training sequence is in
vmenter.S, quite close to the VM-exit. On hosts without V_SPEC_CTRL,
the host's IA32_SPEC_CTRL value is not restored until much later.
I think it's easier to just do both sides than to wait for
clarifications. I'll take a look.
Paolo