Skip to content

Commit 152880d

Browse files
reijiw-kvmMarc Zyngier
authored andcommitted
KVM: arm64: selftests: Add helpers to enable debug exceptions
Add helpers to enable breakpoint and watchpoint exceptions. No functional change intended. Signed-off-by: Reiji Watanabe <[email protected]> Reviewed-by: Ricardo Koller <[email protected]> Reviewed-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 700b886 commit 152880d

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

tools/testing/selftests/kvm/aarch64/debug-exceptions.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,39 +130,40 @@ static void enable_os_lock(void)
130130
GUEST_ASSERT(read_sysreg(oslsr_el1) & 2);
131131
}
132132

133+
static void enable_monitor_debug_exceptions(void)
134+
{
135+
uint32_t mdscr;
136+
137+
asm volatile("msr daifclr, #8");
138+
139+
mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE;
140+
write_sysreg(mdscr, mdscr_el1);
141+
isb();
142+
}
143+
133144
static void install_wp(uint8_t wpn, uint64_t addr)
134145
{
135146
uint32_t wcr;
136-
uint32_t mdscr;
137147

138148
wcr = DBGWCR_LEN8 | DBGWCR_RD | DBGWCR_WR | DBGWCR_EL1 | DBGWCR_E;
139149
write_dbgwcr(wpn, wcr);
140150
write_dbgwvr(wpn, addr);
141151

142152
isb();
143153

144-
asm volatile("msr daifclr, #8");
145-
146-
mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE;
147-
write_sysreg(mdscr, mdscr_el1);
148-
isb();
154+
enable_monitor_debug_exceptions();
149155
}
150156

151157
static void install_hw_bp(uint8_t bpn, uint64_t addr)
152158
{
153159
uint32_t bcr;
154-
uint32_t mdscr;
155160

156161
bcr = DBGBCR_LEN8 | DBGBCR_EXEC | DBGBCR_EL1 | DBGBCR_E;
157162
write_dbgbcr(bpn, bcr);
158163
write_dbgbvr(bpn, addr);
159164
isb();
160165

161-
asm volatile("msr daifclr, #8");
162-
163-
mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE;
164-
write_sysreg(mdscr, mdscr_el1);
165-
isb();
166+
enable_monitor_debug_exceptions();
166167
}
167168

168169
static void install_ss(void)

0 commit comments

Comments
 (0)