Re: FSGSBASE causing panic on 5.9-rc1

From: Tom Lendacky
Date: Thu Aug 20 2020 - 15:04:50 EST


On 8/20/20 1:41 PM, Tom Lendacky wrote:
On 8/20/20 1:39 PM, Jim Mattson wrote:
On Thu, Aug 20, 2020 at 11:38 AM Jim Mattson <jmattson@xxxxxxxxxx> wrote:

On Thu, Aug 20, 2020 at 11:34 AM Tom Lendacky <thomas.lendacky@xxxxxxx> wrote:


Bisecting with unsafe_fsgsbase identified:

c82965f9e530 ("x86/entry/64: Handle FSGSBASE enabled paranoid entry/exit")

But I'm thinking that could be because it starts using GET_PERCPU_BASE,
which on Rome would use RDPID. So is SVM restoring TSC_AUX_MSR too late?
That would explain why I don't see the issue on Naples, which doesn't
support RDPID.

It looks to me like SVM loads the guest TSC_AUX from vcpu_load to
vcpu_put, with this comment:

/* This assumes that the kernel never uses MSR_TSC_AUX */
if (static_cpu_has(X86_FEATURE_RDTSCP))
         wrmsrl(MSR_TSC_AUX, svm->tsc_aux);

Correction: It never restores TSC_AUX, AFAICT.

It does, it's in the host_save_user_msrs array.

I added a quick hack to save TSC_AUX to a new variable in the SVM struct and then restore it right after VMEXIT (just after where GS is restored in svm_vcpu_enter_exit()) and my guest is no longer crashing.

Thanks,
Tom


Thanks,
Tom