[PATCH 0/2] Fix MSR_IA32_PLATFORM_ID access for TDX guests

Binbin Wu posted 2 patches 1 month, 2 weeks ago
arch/x86/kernel/cpu/microcode/core.c     | 2 +-
arch/x86/kernel/cpu/microcode/intel.c    | 4 ++++
arch/x86/kernel/cpu/microcode/internal.h | 5 +++++
arch/x86/kvm/vmx/tdx.c                   | 1 +
4 files changed, 11 insertions(+), 1 deletion(-)
[PATCH 0/2] Fix MSR_IA32_PLATFORM_ID access for TDX guests
Posted by Binbin Wu 1 month, 2 weeks ago
Since commit d8630b67ca1e ("x86/cpu: Add platform ID to CPU info
structure"), the Linux kernel reads MSR_IA32_PLATFORM_ID during CPU
init. This causes unchecked MSR access errors when running as a TDX
guest, because KVM doesn't include MSR_IA32_PLATFORM_ID in
tdx_has_emulated_msr().

On KVM side, this patch set adds MSR_IA32_PLATFORM_ID to
tdx_has_emulated_msr() so that KVM returns 0 for TDs reading this MSR,
consistent with how KVM already handles it for normal VMs.

Optionally, in order to provide back-compatibility for newer Linux guests
running on older KVM hosts without the fix, the second patch skips the
MSR_IA32_PLATFORM_ID read entirely when Linux is running in a
virtualized environment. This could be dropped if we think the fix on
KVM side is sufficient.

Binbin Wu (2):
  KVM: TDX: Allow TDs to read MSR_IA32_PLATFORM_ID
  x86/cpu: Skip reading MSR_IA32_PLATFORM_ID in virtualized environment

 arch/x86/kernel/cpu/microcode/core.c     | 2 +-
 arch/x86/kernel/cpu/microcode/intel.c    | 4 ++++
 arch/x86/kernel/cpu/microcode/internal.h | 5 +++++
 arch/x86/kvm/vmx/tdx.c                   | 1 +
 4 files changed, 11 insertions(+), 1 deletion(-)


base-commit: 39704f00f747aba3144289870b5fd8ac230a9aaf
-- 
2.46.0