Re: [PATCH v2 25/25] KVM: x86/mmu: extract initialization of the page walking data

Sean Christopherson
2022-03-08T20:02:36Z

On Mon, Feb 21, 2022, Paolo Bonzini wrote:
> +static void kvm_vcpu_init_walker(struct kvm_vcpu *vcpu,
> + struct kvm_mmu *mmu,
> + union kvm_mmu_paging_mode new_mode)

kvm_vcpu_init_walker() is a rather odd and almost maliciously obtuse. We're not
short on space for this one, so how about?

static void kvm_mmu_init_guest_walker(struct kvm_vcpu *vcpu,
struct kvm_mmu *mmu,
union kvm_mmu_paging_mode new_mode)
> void kvm_init_mmu(struct kvm_vcpu *vcpu)
> {
> struct kvm_mmu_role_regs regs = vcpu_to_role_regs(vcpu);
> union kvm_mmu_paging_mode cpu_mode = kvm_calc_cpu_mode(vcpu, &regs);
>
> + kvm_vcpu_init_walker(vcpu, vcpu->arch.walk_mmu, cpu_mode);
> if (mmu_is_nested(vcpu))
> - init_kvm_nested_mmu(vcpu, cpu_mode);
> - else if (tdp_enabled)
> + return;

Nice! I really like that this highlights that the nested_mmu crud is just for
the walker. Can you also add a comment here explaining that part?

> +
> + if (tdp_enabled)
> init_kvm_tdp_mmu(vcpu, cpu_mode);
> else
> init_kvm_softmmu(vcpu, cpu_mode);
> --
> 2.31.1
>