Skip to content

Commit 9a3bfb2

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Fix TRFCR_EL1/PMSCR_EL1 access in hVHE mode
When running in hVHE mode, EL1 accesses are performed with the EL12 accessor, as we run with HCR_EL2.E2H=1. Unfortunately, both PMSCR_EL1 and TRFCR_EL1 are used with the EL1 accessor, meaning that we actually affect the EL2 state. Duh. Switch to using the {read,write}_sysreg_el1() helpers that will do the right thing in all circumstances. Note that the 'Fixes:' tag doesn't represent the point where the bug was introduced (there is no such point), but the first practical point where the hVHE feature is usable. Cc: James Clark <[email protected]> Cc: Anshuman Khandual <[email protected]> Fixes: 38cba55 ("KVM: arm64: Force HCR_E2H in guest context when ARM64_KVM_HVHE is set") Signed-off-by: Marc Zyngier <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 43b3bed commit 9a3bfb2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/arm64/kvm/hyp/nvhe/debug-sr.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ static void __debug_save_spe(u64 *pmscr_el1)
3131
return;
3232

3333
/* Yes; save the control register and disable data generation */
34-
*pmscr_el1 = read_sysreg_s(SYS_PMSCR_EL1);
35-
write_sysreg_s(0, SYS_PMSCR_EL1);
34+
*pmscr_el1 = read_sysreg_el1(SYS_PMSCR);
35+
write_sysreg_el1(0, SYS_PMSCR);
3636
isb();
3737

3838
/* Now drain all buffered data to memory */
@@ -48,7 +48,7 @@ static void __debug_restore_spe(u64 pmscr_el1)
4848
isb();
4949

5050
/* Re-enable data generation */
51-
write_sysreg_s(pmscr_el1, SYS_PMSCR_EL1);
51+
write_sysreg_el1(pmscr_el1, SYS_PMSCR);
5252
}
5353

5454
static void __debug_save_trace(u64 *trfcr_el1)
@@ -63,8 +63,8 @@ static void __debug_save_trace(u64 *trfcr_el1)
6363
* Since access to TRFCR_EL1 is trapped, the guest can't
6464
* modify the filtering set by the host.
6565
*/
66-
*trfcr_el1 = read_sysreg_s(SYS_TRFCR_EL1);
67-
write_sysreg_s(0, SYS_TRFCR_EL1);
66+
*trfcr_el1 = read_sysreg_el1(SYS_TRFCR);
67+
write_sysreg_el1(0, SYS_TRFCR);
6868
isb();
6969
/* Drain the trace buffer to memory */
7070
tsb_csync();
@@ -76,7 +76,7 @@ static void __debug_restore_trace(u64 trfcr_el1)
7676
return;
7777

7878
/* Restore trace filter controls */
79-
write_sysreg_s(trfcr_el1, SYS_TRFCR_EL1);
79+
write_sysreg_el1(trfcr_el1, SYS_TRFCR);
8080
}
8181

8282
void __debug_save_host_buffers_nvhe(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)