Re: [PATCH v2 4/6] KVM: Add arch hooks for enabling/disabling virtualization
From: Sean Christopherson
Date: Tue May 28 2024 - 18:50:47 EST
On Thu, May 23, 2024, Kai Huang wrote:
> On 22/05/2024 2:28 pm, Sean Christopherson wrote:
> > static int __kvm_enable_virtualization(void)
> > {
> > if (__this_cpu_read(hardware_enabled))
> > @@ -5604,6 +5614,8 @@ static int kvm_enable_virtualization(void)
> > if (kvm_usage_count++)
> > return 0;
> > + kvm_arch_enable_virtualization();
> > +
> > r = cpuhp_setup_state(CPUHP_AP_KVM_ONLINE, "kvm/cpu:online",
> > kvm_online_cpu, kvm_offline_cpu);
>
>
> Nit: is kvm_arch_pre_enable_virtualization() a better name?
Hmm, yes? I don't have a strong preference either way. I did consider a more
verbose name, but omitted the "pre" because the hook is called only on the 0=>1
transition of kvm_usage_count, and for some reason that made me think "pre" would
be confusing.
On the other hand, "pre" very clearly communicates that the hook is invoked,
and _needs_ to be invoked (for x86), before KVM enables virtualization.
So I'm leaning towards kvm_arch_pre_enable_virtualization().
Anyone else have an opinion?