On Tue, Apr 04, 2023 at 09:09:20PM +0800, Binbin Wu wrote: > /* Page table builder macros common to shadow (host) PTEs and guest PTEs. */ >+#define __PT_BASE_ADDR_MASK (((1ULL << 52) - 1) & ~(u64)(PAGE_SIZE-1)) This is an open-coded GENMASK_ULL(). So, you'd better use GENMASK_ULL() here. >--- a/arch/x86/kvm/x86.c >+++ b/arch/x86/kvm/x86.c >@@ -1260,7 +1260,7 @@ int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) > * stuff CR3, e.g. for RSM emulation, and there is no guarantee that > * the current vCPU mode is accurate. > */ >- if (kvm_vcpu_is_illegal_gpa(vcpu, cr3)) >+ if (!kvm_vcpu_is_legal_cr3(vcpu, cr3)) I prefer to modify the call sites in SVM nested code to use the new function. Although this change does not affect functionality, it provides a clear distinction between CR3 checks and GPA checks.