x86/bugs, KVM: Support the combination of guest and host IBRS
A guest may modify the SPEC_CTRL MSR from the value used by the kernel. Since the kernel doesn't use IBRS, this means a value of zero is what is needed in the host. But the 336996-Speculative-Execution-Side-Channel-Mitigations.pdf refers to the other bits as reserved so the kernel should respect the boot time SPEC_CTRL value and use that. This allows to deal with future extensions to the SPEC_CTRL interface if any at all. Note: This uses wrmsrl() instead of native_wrmsl(). I does not make any difference as paravirt will over-write the callq *0xfff.. with the wrmsrl assembler code. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Borislav Petkov <bp@suse.de> Reviewed-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:

gecommit door
Thomas Gleixner

bovenliggende
1b86883ccb
commit
5cf6875487
@@ -123,6 +123,24 @@ u64 x86_spec_ctrl_get_default(void)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(x86_spec_ctrl_get_default);
|
||||
|
||||
void x86_spec_ctrl_set_guest(u64 guest_spec_ctrl)
|
||||
{
|
||||
if (!boot_cpu_has(X86_FEATURE_IBRS))
|
||||
return;
|
||||
if (x86_spec_ctrl_base != guest_spec_ctrl)
|
||||
wrmsrl(MSR_IA32_SPEC_CTRL, guest_spec_ctrl);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(x86_spec_ctrl_set_guest);
|
||||
|
||||
void x86_spec_ctrl_restore_host(u64 guest_spec_ctrl)
|
||||
{
|
||||
if (!boot_cpu_has(X86_FEATURE_IBRS))
|
||||
return;
|
||||
if (x86_spec_ctrl_base != guest_spec_ctrl)
|
||||
wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(x86_spec_ctrl_restore_host);
|
||||
|
||||
#ifdef RETPOLINE
|
||||
static bool spectre_v2_bad_module;
|
||||
|
||||
|
Verwijs in nieuw issue
Block a user