Skip to content

Commit 75a5fba

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: Compute MDCR_EL2 at vcpu_load()
KVM has picked up several hacks to cope with vcpu->arch.mdcr_el2 needing to be prepared before vcpu_load(), which is when it gets programmed into hardware on VHE. Now that the flows for reprogramming MDCR_EL2 have been simplified, move that computation to vcpu_load(). Tested-by: James Clark <[email protected]> Signed-off-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 06d22a9 commit 75a5fba

File tree

3 files changed

+3
-19
lines changed

3 files changed

+3
-19
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,6 @@ static inline bool kvm_system_needs_idmapped_vectors(void)
13411341
static inline void kvm_arch_sync_events(struct kvm *kvm) {}
13421342

13431343
void kvm_init_host_debug_data(void);
1344-
void kvm_arm_vcpu_init_debug(struct kvm_vcpu *vcpu);
13451344
void kvm_arm_setup_debug(struct kvm_vcpu *vcpu);
13461345
void kvm_arm_clear_debug(struct kvm_vcpu *vcpu);
13471346
void kvm_vcpu_load_debug(struct kvm_vcpu *vcpu);

arch/arm64/kvm/arm.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,8 +804,6 @@ int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu)
804804

805805
kvm_init_mpidr_data(kvm);
806806

807-
kvm_arm_vcpu_init_debug(vcpu);
808-
809807
if (likely(irqchip_in_kernel(kvm))) {
810808
/*
811809
* Map the VGIC hardware resources before running a vcpu the

arch/arm64/kvm/debug.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,6 @@ static void kvm_arm_setup_mdcr_el2(struct kvm_vcpu *vcpu)
9898
preempt_enable();
9999
}
100100

101-
/**
102-
* kvm_arm_vcpu_init_debug - setup vcpu debug traps
103-
*
104-
* @vcpu: the vcpu pointer
105-
*
106-
* Set vcpu initial mdcr_el2 value.
107-
*/
108-
void kvm_arm_vcpu_init_debug(struct kvm_vcpu *vcpu)
109-
{
110-
preempt_disable();
111-
kvm_arm_setup_mdcr_el2(vcpu);
112-
preempt_enable();
113-
}
114-
115101
/**
116102
* kvm_arm_setup_debug - set up debug related stuff
117103
*
@@ -131,8 +117,6 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
131117
{
132118
unsigned long mdscr;
133119

134-
kvm_arm_setup_mdcr_el2(vcpu);
135-
136120
/* Check if we need to use the debug registers. */
137121
if (vcpu->guest_debug || kvm_vcpu_os_lock_enabled(vcpu)) {
138122
/* Save guest debug state */
@@ -273,6 +257,8 @@ void kvm_vcpu_load_debug(struct kvm_vcpu *vcpu)
273257
else
274258
vcpu->arch.debug_owner = VCPU_DEBUG_FREE;
275259
}
260+
261+
kvm_arm_setup_mdcr_el2(vcpu);
276262
}
277263

278264
/*
@@ -287,6 +273,7 @@ void kvm_debug_set_guest_ownership(struct kvm_vcpu *vcpu)
287273
return;
288274

289275
vcpu->arch.debug_owner = VCPU_DEBUG_GUEST_OWNED;
276+
kvm_arm_setup_mdcr_el2(vcpu);
290277
}
291278

292279
void kvm_debug_handle_oslar(struct kvm_vcpu *vcpu, u64 val)

0 commit comments

Comments
 (0)