Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <will.deacon@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

+13 -5
+13 -5
arch/arm64/include/asm/hw_breakpoint.h
··· 18 18 19 19 #include <asm/cputype.h> 20 20 #include <asm/cpufeature.h> 21 + #include <asm/virt.h> 21 22 22 23 #ifdef __KERNEL__ 23 24 ··· 36 35 struct arch_hw_breakpoint_ctrl ctrl; 37 36 }; 38 37 38 + /* Privilege Levels */ 39 + #define AARCH64_BREAKPOINT_EL1 1 40 + #define AARCH64_BREAKPOINT_EL0 2 41 + 42 + #define DBG_HMC_HYP (1 << 13) 43 + 39 44 static inline u32 encode_ctrl_reg(struct arch_hw_breakpoint_ctrl ctrl) 40 45 { 41 - return (ctrl.len << 5) | (ctrl.type << 3) | (ctrl.privilege << 1) | 46 + u32 val = (ctrl.len << 5) | (ctrl.type << 3) | (ctrl.privilege << 1) | 42 47 ctrl.enabled; 48 + 49 + if (is_kernel_in_hyp_mode() && ctrl.privilege == AARCH64_BREAKPOINT_EL1) 50 + val |= DBG_HMC_HYP; 51 + 52 + return val; 43 53 } 44 54 45 55 static inline void decode_ctrl_reg(u32 reg, ··· 72 60 #define ARM_BREAKPOINT_LOAD 1 73 61 #define ARM_BREAKPOINT_STORE 2 74 62 #define AARCH64_ESR_ACCESS_MASK (1 << 6) 75 - 76 - /* Privilege Levels */ 77 - #define AARCH64_BREAKPOINT_EL1 1 78 - #define AARCH64_BREAKPOINT_EL0 2 79 63 80 64 /* Lengths */ 81 65 #define ARM_BREAKPOINT_LEN_1 0x1