Skip to content

Commit d3a80c5

Browse files
Anshuman Khandualctmarinas
authored andcommitted
arm64/debug: Drop redundant DBG_MDSCR_* macros
MDSCR_EL1 has already been defined in tools sysreg format and hence can be used in all debug monitor related call paths. But using generated sysreg definitions causes build warnings because there is a mismatch between mdscr variable (u32) and GENMASK() based masks (long unsigned int). Convert all variables handling MDSCR_EL1 register as u64 which also reflects its true width as well. -------------------------------------------------------------------------- arch/arm64/kernel/debug-monitors.c: In function ‘disable_debug_monitors’: arch/arm64/kernel/debug-monitors.c:108:13: warning: conversion from ‘long unsigned int’ to ‘u32’ {aka ‘unsigned int’} changes value from ‘18446744073709518847’ to ‘4294934527’ [-Woverflow] 108 | disable = ~MDSCR_EL1_MDE; | ^ -------------------------------------------------------------------------- While here, replace an open encoding with MDSCR_EL1_TDCC in __cpu_setup(). Cc: Will Deacon <[email protected]> Cc: Mark Rutland <[email protected]> Cc: [email protected] Cc: [email protected] Reviewed-by: Ada Couprie Diaz <[email protected]> Signed-off-by: Anshuman Khandual <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 19272b3 commit d3a80c5

File tree

5 files changed

+16
-22
lines changed

5 files changed

+16
-22
lines changed

arch/arm64/include/asm/assembler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
.macro disable_step_tsk, flgs, tmp
5454
tbz \flgs, #TIF_SINGLESTEP, 9990f
5555
mrs \tmp, mdscr_el1
56-
bic \tmp, \tmp, #DBG_MDSCR_SS
56+
bic \tmp, \tmp, #MDSCR_EL1_SS
5757
msr mdscr_el1, \tmp
5858
isb // Take effect before a subsequent clear of DAIF.D
5959
9990:
@@ -63,7 +63,7 @@
6363
.macro enable_step_tsk, flgs, tmp
6464
tbz \flgs, #TIF_SINGLESTEP, 9990f
6565
mrs \tmp, mdscr_el1
66-
orr \tmp, \tmp, #DBG_MDSCR_SS
66+
orr \tmp, \tmp, #MDSCR_EL1_SS
6767
msr mdscr_el1, \tmp
6868
9990:
6969
.endm

arch/arm64/include/asm/debug-monitors.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@
1313
#include <asm/ptrace.h>
1414

1515
/* Low-level stepping controls. */
16-
#define DBG_MDSCR_SS (1 << 0)
1716
#define DBG_SPSR_SS (1 << 21)
1817

19-
/* MDSCR_EL1 enabling bits */
20-
#define DBG_MDSCR_KDE (1 << 13)
21-
#define DBG_MDSCR_MDE (1 << 15)
22-
#define DBG_MDSCR_MASK ~(DBG_MDSCR_KDE | DBG_MDSCR_MDE)
23-
2418
#define DBG_ESR_EVT(x) (((x) >> 27) & 0x7)
2519

2620
/* AArch64 */

arch/arm64/kernel/debug-monitors.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ u8 debug_monitors_arch(void)
3434
/*
3535
* MDSCR access routines.
3636
*/
37-
static void mdscr_write(u32 mdscr)
37+
static void mdscr_write(u64 mdscr)
3838
{
3939
unsigned long flags;
4040
flags = local_daif_save();
@@ -43,7 +43,7 @@ static void mdscr_write(u32 mdscr)
4343
}
4444
NOKPROBE_SYMBOL(mdscr_write);
4545

46-
static u32 mdscr_read(void)
46+
static u64 mdscr_read(void)
4747
{
4848
return read_sysreg(mdscr_el1);
4949
}
@@ -79,16 +79,16 @@ static DEFINE_PER_CPU(int, kde_ref_count);
7979

8080
void enable_debug_monitors(enum dbg_active_el el)
8181
{
82-
u32 mdscr, enable = 0;
82+
u64 mdscr, enable = 0;
8383

8484
WARN_ON(preemptible());
8585

8686
if (this_cpu_inc_return(mde_ref_count) == 1)
87-
enable = DBG_MDSCR_MDE;
87+
enable = MDSCR_EL1_MDE;
8888

8989
if (el == DBG_ACTIVE_EL1 &&
9090
this_cpu_inc_return(kde_ref_count) == 1)
91-
enable |= DBG_MDSCR_KDE;
91+
enable |= MDSCR_EL1_KDE;
9292

9393
if (enable && debug_enabled) {
9494
mdscr = mdscr_read();
@@ -100,16 +100,16 @@ NOKPROBE_SYMBOL(enable_debug_monitors);
100100

101101
void disable_debug_monitors(enum dbg_active_el el)
102102
{
103-
u32 mdscr, disable = 0;
103+
u64 mdscr, disable = 0;
104104

105105
WARN_ON(preemptible());
106106

107107
if (this_cpu_dec_return(mde_ref_count) == 0)
108-
disable = ~DBG_MDSCR_MDE;
108+
disable = ~MDSCR_EL1_MDE;
109109

110110
if (el == DBG_ACTIVE_EL1 &&
111111
this_cpu_dec_return(kde_ref_count) == 0)
112-
disable &= ~DBG_MDSCR_KDE;
112+
disable &= ~MDSCR_EL1_KDE;
113113

114114
if (disable) {
115115
mdscr = mdscr_read();
@@ -415,23 +415,23 @@ void kernel_enable_single_step(struct pt_regs *regs)
415415
{
416416
WARN_ON(!irqs_disabled());
417417
set_regs_spsr_ss(regs);
418-
mdscr_write(mdscr_read() | DBG_MDSCR_SS);
418+
mdscr_write(mdscr_read() | MDSCR_EL1_SS);
419419
enable_debug_monitors(DBG_ACTIVE_EL1);
420420
}
421421
NOKPROBE_SYMBOL(kernel_enable_single_step);
422422

423423
void kernel_disable_single_step(void)
424424
{
425425
WARN_ON(!irqs_disabled());
426-
mdscr_write(mdscr_read() & ~DBG_MDSCR_SS);
426+
mdscr_write(mdscr_read() & ~MDSCR_EL1_SS);
427427
disable_debug_monitors(DBG_ACTIVE_EL1);
428428
}
429429
NOKPROBE_SYMBOL(kernel_disable_single_step);
430430

431431
int kernel_active_single_step(void)
432432
{
433433
WARN_ON(!irqs_disabled());
434-
return mdscr_read() & DBG_MDSCR_SS;
434+
return mdscr_read() & MDSCR_EL1_SS;
435435
}
436436
NOKPROBE_SYMBOL(kernel_active_single_step);
437437

arch/arm64/kernel/entry-common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static DEFINE_PER_CPU(int, __in_cortex_a76_erratum_1463225_wa);
344344

345345
static void cortex_a76_erratum_1463225_svc_handler(void)
346346
{
347-
u32 reg, val;
347+
u64 reg, val;
348348

349349
if (!unlikely(test_thread_flag(TIF_SINGLESTEP)))
350350
return;
@@ -354,7 +354,7 @@ static void cortex_a76_erratum_1463225_svc_handler(void)
354354

355355
__this_cpu_write(__in_cortex_a76_erratum_1463225_wa, 1);
356356
reg = read_sysreg(mdscr_el1);
357-
val = reg | DBG_MDSCR_SS | DBG_MDSCR_KDE;
357+
val = reg | MDSCR_EL1_SS | MDSCR_EL1_KDE;
358358
write_sysreg(val, mdscr_el1);
359359
asm volatile("msr daifclr, #8");
360360
isb();

arch/arm64/mm/proc.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ SYM_FUNC_START(__cpu_setup)
454454
dsb nsh
455455

456456
msr cpacr_el1, xzr // Reset cpacr_el1
457-
mov x1, #1 << 12 // Reset mdscr_el1 and disable
457+
mov x1, MDSCR_EL1_TDCC // Reset mdscr_el1 and disable
458458
msr mdscr_el1, x1 // access to the DCC from EL0
459459
reset_pmuserenr_el0 x1 // Disable PMU access from EL0
460460
reset_amuserenr_el0 x1 // Disable AMU access from EL0

0 commit comments

Comments
 (0)