File 5aaa5c98-x86-ignore-guest-microcode-loads.patch of Package xen.7317
# Commit 59c0983e10d70ea2368085271b75fb007811fe52
# Date 2018-03-15 12:44:24 +0100
# Author Jan Beulich <jbeulich@suse.com>
# Committer Jan Beulich <jbeulich@suse.com>
x86: ignore guest microcode loading attempts
The respective MSRs are write-only, and hence attempts by guests to
write to these are - as of 1f1d183d49 ("x86/HVM: don't give the wrong
impression of WRMSR succeeding") no longer ignored. Restore original
behavior for the two affected MSRs.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3353,6 +3353,8 @@ int hvm_msr_read_intercept(unsigned int
*msr_content = var_range_base[index];
break;
+ case MSR_AMD_PATCHLOADER:
+ case MSR_IA32_UCODE_WRITE:
case MSR_PRED_CMD:
/* Write-only */
goto gp_fault;
@@ -3422,6 +3424,26 @@ int hvm_msr_write_intercept(unsigned int
return X86EMUL_EXCEPTION;
break;
+ case MSR_AMD_PATCHLOADER:
+ /*
+ * See note on MSR_IA32_UCODE_WRITE below, which may or may not apply
+ * to AMD CPUs as well (at least the architectural/CPUID part does).
+ */
+ if ( boot_cpu_data.x86_vendor != X86_VENDOR_AMD )
+ goto gp_fault;
+ break;
+
+ case MSR_IA32_UCODE_WRITE:
+ /*
+ * Some versions of Windows at least on certain hardware try to load
+ * microcode before setting up an IDT. Therefore we must not inject #GP
+ * for such attempts. Also the MSR is architectural and not qualified
+ * by any CPUID bit.
+ */
+ if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
+ goto gp_fault;
+ break;
+
case MSR_IA32_TSC:
hvm_set_guest_tsc_msr(v, msr_content);
break;