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

ARM: hw_breakpoint: Check function for OS Save and Restore mechanism

v7 debug introduced OS Save and Restore mechanism. On a v7 debug SinglePower
system, i.e a system without a separate core and debug power domain, which does
not support external debug over powerdown, it is implementation defined whether
OS Save and Restore is implemented.
v7.1 debug requires OS Save and Restore mechanism. v6 debug and v6.1 debug do
not implement it.

A new global variable bool has_ossr is introduced and is determined in
arch_hw_breakpoint_init() like debug_arch or the number of BRPs/WRPs.

The logic how to check if OS Save and Restore is supported has changed with
this patch. In reset_ctrl_regs() a mask consisting of OSLM[1] (OSLSR.3) and
OSLM[0] (OSLSR.0) was used to check if the system supports OS Save and
Restore. In the new function core_has_os_save_restore() only OSLM[0] is used.
It is not necessary to check OSLM[1] too since it is v7.1 debug specific and
v7.1 debug requires OS Save and Restore and thus OS Lock.

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>

authored by

Dietmar Eggemann and committed by
Will Deacon
57ba8997 02051ead

+26 -5
+3
arch/arm/include/asm/hw_breakpoint.h
··· 85 85 #define ARM_DSCR_HDBGEN (1 << 14) 86 86 #define ARM_DSCR_MDBGEN (1 << 15) 87 87 88 + /* OSLSR os lock model bits */ 89 + #define ARM_OSLSR_OSLM0 (1 << 0) 90 + 88 91 /* opcode2 numbers for the co-processor instructions. */ 89 92 #define ARM_OP2_BVR 4 90 93 #define ARM_OP2_BCR 5
+23 -5
arch/arm/kernel/hw_breakpoint.c
··· 50 50 /* Debug architecture version. */ 51 51 static u8 debug_arch; 52 52 53 + /* Does debug architecture support OS Save and Restore? */ 54 + static bool has_ossr; 55 + 53 56 /* Maximum supported watchpoint length. */ 54 57 static u8 max_watchpoint_len; 55 58 ··· 907 904 .fn = debug_reg_trap, 908 905 }; 909 906 907 + /* Does this core support OS Save and Restore? */ 908 + static bool core_has_os_save_restore(void) 909 + { 910 + u32 oslsr; 911 + 912 + switch (get_debug_arch()) { 913 + case ARM_DEBUG_ARCH_V7_1: 914 + return true; 915 + case ARM_DEBUG_ARCH_V7_ECP14: 916 + ARM_DBG_READ(c1, c1, 4, oslsr); 917 + if (oslsr & ARM_OSLSR_OSLM0) 918 + return true; 919 + default: 920 + return false; 921 + } 922 + } 923 + 910 924 static void reset_ctrl_regs(void *unused) 911 925 { 912 926 int i, raw_num_brps, err = 0, cpu = smp_processor_id(); ··· 951 931 if ((val & 0x1) == 0) 952 932 err = -EPERM; 953 933 954 - /* 955 - * Check whether we implement OS save and restore. 956 - */ 957 - ARM_DBG_READ(c1, c1, 4, val); 958 - if ((val & 0x9) == 0) 934 + if (!has_ossr) 959 935 goto clear_vcr; 960 936 break; 961 937 case ARM_DEBUG_ARCH_V7_1: ··· 1040 1024 pr_info("debug architecture 0x%x unsupported.\n", debug_arch); 1041 1025 return 0; 1042 1026 } 1027 + 1028 + has_ossr = core_has_os_save_restore(); 1043 1029 1044 1030 /* Determine how many BRPs/WRPs are available. */ 1045 1031 core_num_brps = get_num_brps();