Re: [PATCH v18 057/121] KVM: TDX: Add load_mmu_pgd method for TDX

From: Isaku Yamahata
Date: Mon Feb 26 2024 - 14:16:41 EST


On Mon, Feb 05, 2024 at 10:23:34AM +0800,
Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx> wrote:

> > diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> > index 59d170709f82..25510b6740a3 100644
> > --- a/arch/x86/kvm/vmx/tdx.c
> > +++ b/arch/x86/kvm/vmx/tdx.c
> > @@ -501,6 +501,11 @@ void tdx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
> > */
> > }
> > +void tdx_load_mmu_pgd(struct kvm_vcpu *vcpu, hpa_t root_hpa, int pgd_level)
> > +{
> > + td_vmcs_write64(to_tdx(vcpu), SHARED_EPT_POINTER, root_hpa & PAGE_MASK);
>
> If we have concern about the alignment of root_hpa, shouldn't we do some
> check instead of masking the address quietly?

Makes sense. I'll add WARN_ON_ONCE(root_hpa & ~PAGE_MASK)
--
Isaku Yamahata <isaku.yamahata@xxxxxxxxxxxxxxx>