Sean Christopherson <sean.j.christopherson@xxxxxxxxx> writes: > Initialize vcpu->arch.tdp_level during vCPU creation to avoid consuming > garbage if userspace calls KVM_RUN without first calling KVM_SET_CPUID. > > Fixes: e93fd3b3e89e9 ("KVM: x86/mmu: Capture TDP level when updating CPUID") > Reported-by: syzbot+904752567107eefb728c@xxxxxxxxxxxxxxxxxxxxxxxxx > Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> > --- > arch/x86/kvm/x86.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index b226fb8abe41b..01a6304056197 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -9414,6 +9414,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) > fx_init(vcpu); > > vcpu->arch.maxphyaddr = cpuid_query_maxphyaddr(vcpu); > + vcpu->arch.tdp_level = kvm_x86_ops.get_tdp_level(vcpu); > > vcpu->arch.pat = MSR_IA32_CR_PAT_DEFAULT; Reviewed-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> Looking at kvm_update_cpuid() I was thinking if it would make sense to duplicate the "/* Note, maxphyaddr must be updated before tdp_level. */" comment here (it seems to be a vmx-only thing btw), drop it from kvm_update_cpuid() or move cpuid_query_maxphyaddr() to get_tdp_level() but didn't come to a conclusive answer. -- Vitaly