Re: [PATCH v4 2/9] KVM: x86: MMU: Clear CR3 LAM bits when allocate shadow root

Chao Gao
2023-02-09T09:55:36Z

On Thu, Feb 09, 2023 at 10:40:15AM +0800, Robert Hoo wrote:
>--- a/arch/x86/kvm/mmu/mmu.c
>+++ b/arch/x86/kvm/mmu/mmu.c
>@@ -3698,8 +3698,11 @@ static int mmu_alloc_shadow_roots(struct kvm_vcpu *vcpu)
> gfn_t root_gfn, root_pgd;
> int quadrant, i, r;
> hpa_t root;
>-

The blank line should be kept.

>+#ifdef CONFIG_X86_64
>+ root_pgd = mmu->get_guest_pgd(vcpu) & ~(X86_CR3_LAM_U48 | X86_CR3_LAM_U57);
>+#else
> root_pgd = mmu->get_guest_pgd(vcpu);
>+#endif

Why are other call sites of mmu->get_guest_pgd() not changed? And what's
the value of the #ifdef?

> root_gfn = root_pgd >> PAGE_SHIFT;
>
> if (mmu_check_root(vcpu, root_gfn))
>--
>2.31.1
>