Re: [PATCH 03/23] KVM: MMU: remove valid from extended role

Paolo Bonzini
2022-02-10T09:53:28Z

On 2/9/22 23:54, Sean Christopherson wrote:
> Nope, it's not guaranteed to be non-zero:
>
> static int role_regs_to_root_level(struct kvm_mmu_role_regs *regs)
> {
> if (!____is_cr0_pg(regs))
> return 0; <=============================================
> else if (____is_efer_lma(regs))
> return ____is_cr4_la57(regs) ? PT64_ROOT_5LEVEL :
> PT64_ROOT_4LEVEL;
> else if (____is_cr4_pae(regs))
> return PT32E_ROOT_LEVEL;
> else
> return PT32_ROOT_LEVEL;
> }
>

Yes, see my reply to David. At the end of the series the assumption is
correct:

- level is always nonzero in mmu_role

- one of level or direct (which is !CR0.PG) is always nonzero in cpu_role

So the patch can be kept but it has to be moved much later.

Paolo