Skip to content

Commit cc5705f

Browse files
author
Marc Zyngier
committed
KVM: arm64: Drop vcpu->arch.has_run_once for vcpu->pid
With the transition to kvm_arch_vcpu_run_pid_change() to handle the "run once" activities, it becomes obvious that has_run_once is now an exact shadow of vcpu->pid. Replace vcpu->arch.has_run_once with a new vcpu_has_run_once() helper that directly checks for vcpu->pid, and get rid of the now unused field. Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent b5aa368 commit cc5705f

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,6 @@ struct kvm_vcpu_arch {
367367
int target;
368368
DECLARE_BITMAP(features, KVM_VCPU_MAX_FEATURES);
369369

370-
/* Detect first run of a vcpu */
371-
bool has_run_once;
372-
373370
/* Virtual SError ESR to restore when HCR_EL2.VSE is set */
374371
u64 vsesr_el2;
375372

@@ -606,6 +603,8 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
606603
void kvm_arm_halt_guest(struct kvm *kvm);
607604
void kvm_arm_resume_guest(struct kvm *kvm);
608605

606+
#define vcpu_has_run_once(vcpu) !!rcu_access_pointer((vcpu)->pid)
607+
609608
#ifndef __KVM_NVHE_HYPERVISOR__
610609
#define kvm_call_hyp_nvhe(f, ...) \
611610
({ \

arch/arm64/kvm/arm.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
351351

352352
void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
353353
{
354-
if (vcpu->arch.has_run_once && unlikely(!irqchip_in_kernel(vcpu->kvm)))
354+
if (vcpu_has_run_once(vcpu) && unlikely(!irqchip_in_kernel(vcpu->kvm)))
355355
static_branch_dec(&userspace_irqchip_in_use);
356356

357357
kvm_mmu_free_memory_cache(&vcpu->arch.mmu_page_cache);
@@ -609,7 +609,7 @@ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu)
609609
if (ret)
610610
return ret;
611611

612-
if (likely(vcpu->arch.has_run_once))
612+
if (likely(vcpu_has_run_once(vcpu)))
613613
return 0;
614614

615615
kvm_arm_vcpu_init_debug(vcpu);
@@ -640,8 +640,6 @@ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu)
640640
static_branch_inc(&userspace_irqchip_in_use);
641641
}
642642

643-
vcpu->arch.has_run_once = true;
644-
645643
/*
646644
* Initialize traps for protected VMs.
647645
* NOTE: Move to run in EL2 directly, rather than via a hypercall, once
@@ -1132,7 +1130,7 @@ static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu,
11321130
* need to invalidate the I-cache though, as FWB does *not*
11331131
* imply CTR_EL0.DIC.
11341132
*/
1135-
if (vcpu->arch.has_run_once) {
1133+
if (vcpu_has_run_once(vcpu)) {
11361134
if (!cpus_have_final_cap(ARM64_HAS_STAGE2_FWB))
11371135
stage2_unmap_vm(vcpu->kvm);
11381136
else

arch/arm64/kvm/vgic/vgic-init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ int kvm_vgic_create(struct kvm *kvm, u32 type)
9191
return ret;
9292

9393
kvm_for_each_vcpu(i, vcpu, kvm) {
94-
if (vcpu->arch.has_run_once)
94+
if (vcpu_has_run_once(vcpu))
9595
goto out_unlock;
9696
}
9797
ret = 0;

0 commit comments

Comments
 (0)