Skip to content

Commit

Permalink
KVM: Rename arch hooks related to per-CPU virtualization enabling
Browse files Browse the repository at this point in the history
Rename the per-CPU hooks used to enable virtualization in hardware to
align with the KVM-wide helpers in kvm_main.c, and to better capture that
the callbacks are invoked on every online CPU.

No functional change intended.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Sean Christopherson <[email protected]>
Reviewed-by: Kai Huang <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
sean-jc authored and bonzini committed Sep 4, 2024
1 parent 70c0194 commit 071f24a
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions arch/arm64/kvm/arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,7 @@ static void cpu_hyp_uninit(void *discard)
}
}

int kvm_arch_hardware_enable(void)
int kvm_arch_enable_virtualization_cpu(void)
{
/*
* Most calls to this function are made with migration
Expand All @@ -2183,7 +2183,7 @@ int kvm_arch_hardware_enable(void)
return 0;
}

void kvm_arch_hardware_disable(void)
void kvm_arch_disable_virtualization_cpu(void)
{
kvm_timer_cpu_down();
kvm_vgic_cpu_down();
Expand Down Expand Up @@ -2379,7 +2379,7 @@ static int __init do_pkvm_init(u32 hyp_va_bits)

/*
* The stub hypercalls are now disabled, so set our local flag to
* prevent a later re-init attempt in kvm_arch_hardware_enable().
* prevent a later re-init attempt in kvm_arch_enable_virtualization_cpu().
*/
__this_cpu_write(kvm_hyp_initialized, 1);
preempt_enable();
Expand Down
4 changes: 2 additions & 2 deletions arch/loongarch/kvm/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ long kvm_arch_dev_ioctl(struct file *filp,
return -ENOIOCTLCMD;
}

int kvm_arch_hardware_enable(void)
int kvm_arch_enable_virtualization_cpu(void)
{
unsigned long env, gcfg = 0;

Expand Down Expand Up @@ -300,7 +300,7 @@ int kvm_arch_hardware_enable(void)
return 0;
}

void kvm_arch_hardware_disable(void)
void kvm_arch_disable_virtualization_cpu(void)
{
write_csr_gcfg(0);
write_csr_gstat(0);
Expand Down
4 changes: 2 additions & 2 deletions arch/mips/kvm/mips.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
return 1;
}

int kvm_arch_hardware_enable(void)
int kvm_arch_enable_virtualization_cpu(void)
{
return kvm_mips_callbacks->hardware_enable();
}

void kvm_arch_hardware_disable(void)
void kvm_arch_disable_virtualization_cpu(void)
{
kvm_mips_callbacks->hardware_disable();
}
Expand Down
4 changes: 2 additions & 2 deletions arch/riscv/kvm/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ long kvm_arch_dev_ioctl(struct file *filp,
return -EINVAL;
}

int kvm_arch_hardware_enable(void)
int kvm_arch_enable_virtualization_cpu(void)
{
csr_write(CSR_HEDELEG, KVM_HEDELEG_DEFAULT);
csr_write(CSR_HIDELEG, KVM_HIDELEG_DEFAULT);
Expand All @@ -35,7 +35,7 @@ int kvm_arch_hardware_enable(void)
return 0;
}

void kvm_arch_hardware_disable(void)
void kvm_arch_disable_virtualization_cpu(void)
{
kvm_riscv_aia_disable();

Expand Down
6 changes: 3 additions & 3 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static void kvm_on_user_return(struct user_return_notifier *urn)

/*
* Disabling irqs at this point since the following code could be
* interrupted and executed through kvm_arch_hardware_disable()
* interrupted and executed through kvm_arch_disable_virtualization_cpu()
*/
local_irq_save(flags);
if (msrs->registered) {
Expand Down Expand Up @@ -12512,7 +12512,7 @@ void kvm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector)
}
EXPORT_SYMBOL_GPL(kvm_vcpu_deliver_sipi_vector);

int kvm_arch_hardware_enable(void)
int kvm_arch_enable_virtualization_cpu(void)
{
struct kvm *kvm;
struct kvm_vcpu *vcpu;
Expand Down Expand Up @@ -12608,7 +12608,7 @@ int kvm_arch_hardware_enable(void)
return 0;
}

void kvm_arch_hardware_disable(void)
void kvm_arch_disable_virtualization_cpu(void)
{
kvm_x86_call(hardware_disable)();
drop_user_return_notifiers();
Expand Down
4 changes: 2 additions & 2 deletions include/linux/kvm_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -1521,8 +1521,8 @@ static inline void kvm_create_vcpu_debugfs(struct kvm_vcpu *vcpu) {}
#endif

#ifdef CONFIG_KVM_GENERIC_HARDWARE_ENABLING
int kvm_arch_hardware_enable(void);
void kvm_arch_hardware_disable(void);
int kvm_arch_enable_virtualization_cpu(void);
void kvm_arch_disable_virtualization_cpu(void);
#endif
int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu);
bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu);
Expand Down
4 changes: 2 additions & 2 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5583,7 +5583,7 @@ static int kvm_enable_virtualization_cpu(void)
if (__this_cpu_read(virtualization_enabled))
return 0;

if (kvm_arch_hardware_enable()) {
if (kvm_arch_enable_virtualization_cpu()) {
pr_info("kvm: enabling virtualization on CPU%d failed\n",
raw_smp_processor_id());
return -EIO;
Expand All @@ -5608,7 +5608,7 @@ static void kvm_disable_virtualization_cpu(void *ign)
if (!__this_cpu_read(virtualization_enabled))
return;

kvm_arch_hardware_disable();
kvm_arch_disable_virtualization_cpu();

__this_cpu_write(virtualization_enabled, false);
}
Expand Down

0 comments on commit 071f24a

Please sign in to comment.