public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] Relax canonical checks on some arch msrs
@ 2024-08-15 12:33 Maxim Levitsky
  2024-08-15 12:33 ` [PATCH v3 1/4] KVM: x86: relax canonical check for some x86 architectural msrs Maxim Levitsky
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Maxim Levitsky @ 2024-08-15 12:33 UTC (permalink / raw)
  To: kvm
  Cc: Ingo Molnar, x86, Paolo Bonzini, Sean Christopherson,
	Thomas Gleixner, Dave Hansen, Borislav Petkov, linux-kernel,
	H. Peter Anvin, Maxim Levitsky

Recently we came up upon a failure where likely the guest writes
0xff4547ceb1600000 to MSR_KERNEL_GS_BASE and later on, qemu
sets this value via KVM_PUT_MSRS, and is rejected by the
kernel, likely due to not being canonical in 4 level paging.

One of the way to trigger this is to make the guest enter SMM,
which causes paging to be disabled, which SMM bios re-enables
but not the whole 5 level. MSR_KERNEL_GS_BASE on the other
hand continues to contain old value.

I did some reverse engineering and to my surprise I found out
that both Intel and AMD indeed ignore CR4.LA57 when doing
canonical checks on this and other msrs and/or other arch
registers (like GDT base) which contain linear addresses.

V2: addressed a very good feedback from Chao Gao. Thanks!

V3: also fix the nested VMX, and also fix the
MSR_IA32_SYSENTER_EIP / MSR_IA32_SYSENTER_ESP

Best regards,
	Maxim Levitsky

Maxim Levitsky (4):
  KVM: x86: relax canonical check for some x86 architectural msrs
  KVM: x86: add X86_FEATURE_LA57 to governed_features
  KVM: nVMX: relax canonical checks on some x86 registers in vmx host
    state
  KVM: SVM: fix emulation of msr reads/writes of MSR_FS_BASE and
    MSR_GS_BASE

 arch/x86/kvm/cpuid.c             |  2 ++
 arch/x86/kvm/governed_features.h |  1 +
 arch/x86/kvm/svm/svm.c           | 12 ++++++++++++
 arch/x86/kvm/vmx/nested.c        | 30 +++++++++++++++++++++++-------
 arch/x86/kvm/x86.c               | 29 +++++++++++++++++++++++++++--
 5 files changed, 65 insertions(+), 9 deletions(-)

-- 
2.40.1



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2025-09-16 20:47 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-15 12:33 [PATCH v3 0/4] Relax canonical checks on some arch msrs Maxim Levitsky
2024-08-15 12:33 ` [PATCH v3 1/4] KVM: x86: relax canonical check for some x86 architectural msrs Maxim Levitsky
2024-08-16 21:49   ` Sean Christopherson
2024-08-16 22:02     ` Sean Christopherson
2024-08-20 12:13     ` mlevitsk
2024-08-21 12:04       ` mlevitsk
2024-08-21 16:04         ` Sean Christopherson
2024-08-23 11:14           ` mlevitsk
2024-08-23 13:59             ` Sean Christopherson
2025-09-12 20:28               ` Jim Mattson
2025-09-16 20:47                 ` Sean Christopherson
2024-08-15 12:33 ` [PATCH v3 2/4] KVM: x86: add X86_FEATURE_LA57 to governed_features Maxim Levitsky
2024-08-15 12:33 ` [PATCH v3 3/4] KVM: nVMX: relax canonical checks on some x86 registers in vmx host state Maxim Levitsky
2024-08-16 10:40   ` mlevitsk
2024-08-16 22:03     ` Sean Christopherson
2024-08-20 12:19       ` mlevitsk
2024-08-15 12:33 ` [PATCH v3 4/4] KVM: SVM: fix emulation of msr reads/writes of MSR_FS_BASE and MSR_GS_BASE Maxim Levitsky
2024-08-16 22:04   ` Sean Christopherson
2024-08-24  0:07     ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox