Skip to content

Commit ae7e27f

Browse files
author
Marc Zyngier
committed
arm64: hw_breakpoint: Allow EL2 breakpoints if running in HYP
With VHE, we place kernel {watch,break}-points at EL2 to get things like kgdb and "perf -e mem:..." working. This requires a bit of repainting in the low-level encore/decode, but is otherwise pretty simple. Acked-by: Will Deacon <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent d98ecda commit ae7e27f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

arch/arm64/include/asm/hw_breakpoint.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <asm/cputype.h>
2020
#include <asm/cpufeature.h>
21+
#include <asm/virt.h>
2122

2223
#ifdef __KERNEL__
2324

@@ -35,10 +36,21 @@ struct arch_hw_breakpoint {
3536
struct arch_hw_breakpoint_ctrl ctrl;
3637
};
3738

39+
/* Privilege Levels */
40+
#define AARCH64_BREAKPOINT_EL1 1
41+
#define AARCH64_BREAKPOINT_EL0 2
42+
43+
#define DBG_HMC_HYP (1 << 13)
44+
3845
static inline u32 encode_ctrl_reg(struct arch_hw_breakpoint_ctrl ctrl)
3946
{
40-
return (ctrl.len << 5) | (ctrl.type << 3) | (ctrl.privilege << 1) |
47+
u32 val = (ctrl.len << 5) | (ctrl.type << 3) | (ctrl.privilege << 1) |
4148
ctrl.enabled;
49+
50+
if (is_kernel_in_hyp_mode() && ctrl.privilege == AARCH64_BREAKPOINT_EL1)
51+
val |= DBG_HMC_HYP;
52+
53+
return val;
4254
}
4355

4456
static inline void decode_ctrl_reg(u32 reg,
@@ -61,10 +73,6 @@ static inline void decode_ctrl_reg(u32 reg,
6173
#define ARM_BREAKPOINT_STORE 2
6274
#define AARCH64_ESR_ACCESS_MASK (1 << 6)
6375

64-
/* Privilege Levels */
65-
#define AARCH64_BREAKPOINT_EL1 1
66-
#define AARCH64_BREAKPOINT_EL0 2
67-
6876
/* Lengths */
6977
#define ARM_BREAKPOINT_LEN_1 0x1
7078
#define ARM_BREAKPOINT_LEN_2 0x3

0 commit comments

Comments
 (0)