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

Robert Hoo
2023-02-11T03:12:45Z

On Fri, 2023-02-10 at 11:38 +0800, Yang, Weijiang wrote:
> On 2/9/2023 10:40 AM, Robert Hoo wrote:
>
> [...]
>
>
> > -
> > +#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
>
> I prefer using:
>
> root_pgd = mmu->get_guest_pgd(vcpu);
>
> if (IS_ENABLED(CONFIG_X86_64))
>
> root_pgd &= ~(X86_CR3_LAM_U48 | X86_CR3_LAM_U57);
>
> I looks more structured.
>
OK, thanks, both look all right to me.
Just don't quite understand the "structured" meaning, would you
elaborate more? Same as 8d5265b1016 ("KVM: x86/mmu: Use IS_ENABLED() to
avoid RETPOLINE for TDP page faults")?