Skip to content

Commit f7e7602

Browse files
clementlegersmb49
authored andcommitted
riscv: misaligned: declare misaligned_access_speed under CONFIG_RISCV_MISALIGNED
BugLink: https://bugs.launchpad.net/bugs/2121266 [ Upstream commit 1317045a7d6f397904d105f6d40dc9787876a34b ] While misaligned_access_speed was defined in a file compile with CONFIG_RISCV_MISALIGNED, its definition was under CONFIG_RISCV_SCALAR_MISALIGNED. This resulted in compilation problems when using it in a file compiled with CONFIG_RISCV_MISALIGNED. Move the declaration under CONFIG_RISCV_MISALIGNED so that it can be used unconditionnally when compiled with that config and remove the check for that variable in traps_misaligned.c. Signed-off-by: Clément Léger <cleger@rivosinc.com> Reviewed-by: Charlie Jenkins <charlie@rivosinc.com> Tested-by: Charlie Jenkins <charlie@rivosinc.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Link: https://lore.kernel.org/r/20250523101932.1594077-9-cleger@rivosinc.com Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Noah Wager <noah.wager@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 2645f01 commit f7e7602

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

arch/riscv/include/asm/cpufeature.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@ bool __init check_unaligned_access_emulated_all_cpus(void);
7171
void check_unaligned_access_emulated(struct work_struct *work __always_unused);
7272
void unaligned_emulation_finish(void);
7373
bool unaligned_ctl_available(void);
74-
DECLARE_PER_CPU(long, misaligned_access_speed);
7574
#else
7675
static inline bool unaligned_ctl_available(void)
7776
{
7877
return false;
7978
}
8079
#endif
8180

81+
#if defined(CONFIG_RISCV_MISALIGNED)
82+
DECLARE_PER_CPU(long, misaligned_access_speed);
83+
#endif
84+
8285
bool __init check_vector_unaligned_access_emulated_all_cpus(void);
8386
#if defined(CONFIG_RISCV_VECTOR_MISALIGNED)
8487
void check_vector_unaligned_access_emulated(struct work_struct *work __always_unused);

arch/riscv/kernel/traps_misaligned.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,7 @@ static int handle_scalar_misaligned_load(struct pt_regs *regs)
368368

369369
perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr);
370370

371-
#ifdef CONFIG_RISCV_PROBE_UNALIGNED_ACCESS
372371
*this_cpu_ptr(&misaligned_access_speed) = RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED;
373-
#endif
374372

375373
if (!unaligned_enabled)
376374
return -1;

0 commit comments

Comments
 (0)