Skip to content

Commit 811154e

Browse files
akihikodakiMarc Zyngier
authored andcommitted
KVM: arm64: Populate fault info for watchpoint
When handling ESR_ELx_EC_WATCHPT_LOW, far_el2 member of struct kvm_vcpu_fault_info will be copied to far member of struct kvm_debug_exit_arch and exposed to the userspace. The userspace will see stale values from older faults if the fault info does not get populated. Fixes: 8fb2046 ("KVM: arm64: Move early handlers to per-EC handlers") Suggested-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230530024651.10014-1-akihiko.odaki@daynix.com Cc: stable@vger.kernel.org
1 parent a9f0e3d commit 811154e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

arch/arm64/kvm/hyp/include/hyp/switch.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,17 +412,21 @@ static bool kvm_hyp_handle_cp15_32(struct kvm_vcpu *vcpu, u64 *exit_code)
412412
return false;
413413
}
414414

415-
static bool kvm_hyp_handle_iabt_low(struct kvm_vcpu *vcpu, u64 *exit_code)
415+
static bool kvm_hyp_handle_memory_fault(struct kvm_vcpu *vcpu, u64 *exit_code)
416416
{
417417
if (!__populate_fault_info(vcpu))
418418
return true;
419419

420420
return false;
421421
}
422+
static bool kvm_hyp_handle_iabt_low(struct kvm_vcpu *vcpu, u64 *exit_code)
423+
__alias(kvm_hyp_handle_memory_fault);
424+
static bool kvm_hyp_handle_watchpt_low(struct kvm_vcpu *vcpu, u64 *exit_code)
425+
__alias(kvm_hyp_handle_memory_fault);
422426

423427
static bool kvm_hyp_handle_dabt_low(struct kvm_vcpu *vcpu, u64 *exit_code)
424428
{
425-
if (!__populate_fault_info(vcpu))
429+
if (kvm_hyp_handle_memory_fault(vcpu, exit_code))
426430
return true;
427431

428432
if (static_branch_unlikely(&vgic_v2_cpuif_trap)) {

arch/arm64/kvm/hyp/nvhe/switch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ static const exit_handler_fn hyp_exit_handlers[] = {
186186
[ESR_ELx_EC_FP_ASIMD] = kvm_hyp_handle_fpsimd,
187187
[ESR_ELx_EC_IABT_LOW] = kvm_hyp_handle_iabt_low,
188188
[ESR_ELx_EC_DABT_LOW] = kvm_hyp_handle_dabt_low,
189+
[ESR_ELx_EC_WATCHPT_LOW] = kvm_hyp_handle_watchpt_low,
189190
[ESR_ELx_EC_PAC] = kvm_hyp_handle_ptrauth,
190191
};
191192

@@ -196,6 +197,7 @@ static const exit_handler_fn pvm_exit_handlers[] = {
196197
[ESR_ELx_EC_FP_ASIMD] = kvm_hyp_handle_fpsimd,
197198
[ESR_ELx_EC_IABT_LOW] = kvm_hyp_handle_iabt_low,
198199
[ESR_ELx_EC_DABT_LOW] = kvm_hyp_handle_dabt_low,
200+
[ESR_ELx_EC_WATCHPT_LOW] = kvm_hyp_handle_watchpt_low,
199201
[ESR_ELx_EC_PAC] = kvm_hyp_handle_ptrauth,
200202
};
201203

arch/arm64/kvm/hyp/vhe/switch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static const exit_handler_fn hyp_exit_handlers[] = {
110110
[ESR_ELx_EC_FP_ASIMD] = kvm_hyp_handle_fpsimd,
111111
[ESR_ELx_EC_IABT_LOW] = kvm_hyp_handle_iabt_low,
112112
[ESR_ELx_EC_DABT_LOW] = kvm_hyp_handle_dabt_low,
113+
[ESR_ELx_EC_WATCHPT_LOW] = kvm_hyp_handle_watchpt_low,
113114
[ESR_ELx_EC_PAC] = kvm_hyp_handle_ptrauth,
114115
};
115116

0 commit comments

Comments
 (0)