Commit a2305e3d authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Michael Ellerman

powerpc: mark local variables around longjmp as volatile

gcc-11 points out that modifying local variables next to a
longjmp/setjmp may cause undefined behavior:

arch/powerpc/kexec/crash.c: In function 'crash_kexec_prepare_cpus.constprop':
arch/powerpc/kexec/crash.c:108:22: error: variable 'ncpus' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbere
d]
arch/powerpc/kexec/crash.c:109:13: error: variable 'tries' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbere
d]
arch/powerpc/xmon/xmon.c: In function 'xmon_print_symbol':
arch/powerpc/xmon/xmon.c:3625:21: error: variable 'name' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
arch/powerpc/xmon/xmon.c: In function 'stop_spus':
arch/powerpc/xmon/xmon.c:4057:13: error: variable 'i' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
arch/powerpc/xmon/xmon.c: In function 'restart_spus':
arch/powerpc/xmon/xmon.c:4098:13: error: variable 'i' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
arch/powerpc/xmon/xmon.c: In function 'dump_opal_msglog':
arch/powerpc/xmon/xmon.c:3008:16: error: variable 'pos' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
arch/powerpc/xmon/xmon.c: In function 'show_pte':
arch/powerpc/xmon/xmon.c:3207:29: error: variable 'tsk' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
arch/powerpc/xmon/xmon.c: In function 'show_tasks':
arch/powerpc/xmon/xmon.c:3302:29: error: variable 'tsk' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
arch/powerpc/xmon/xmon.c: In function 'xmon_core':
arch/powerpc/xmon/xmon.c:494:13: error: variable 'cmd' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
arch/powerpc/xmon/xmon.c:860:21: error: variable 'bp' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
arch/powerpc/xmon/xmon.c:860:21: error: variable 'bp' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]
arch/powerpc/xmon/xmon.c:492:48: error: argument 'fromipi' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered]

According to the documentation, marking these as 'volatile' is
sufficient to avoid the problem, and it shuts up the warning.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210429080708.1520360-1-arnd@kernel.org
parent d40a82be
...@@ -105,8 +105,8 @@ void crash_ipi_callback(struct pt_regs *regs) ...@@ -105,8 +105,8 @@ void crash_ipi_callback(struct pt_regs *regs)
static void crash_kexec_prepare_cpus(int cpu) static void crash_kexec_prepare_cpus(int cpu)
{ {
unsigned int msecs; unsigned int msecs;
unsigned int ncpus = num_online_cpus() - 1;/* Excluding the panic cpu */ volatile unsigned int ncpus = num_online_cpus() - 1;/* Excluding the panic cpu */
int tries = 0; volatile int tries = 0;
int (*old_handler)(struct pt_regs *regs); int (*old_handler)(struct pt_regs *regs);
printk(KERN_EMERG "Sending IPI to other CPUs\n"); printk(KERN_EMERG "Sending IPI to other CPUs\n");
......
...@@ -499,10 +499,10 @@ static void xmon_touch_watchdogs(void) ...@@ -499,10 +499,10 @@ static void xmon_touch_watchdogs(void)
touch_nmi_watchdog(); touch_nmi_watchdog();
} }
static int xmon_core(struct pt_regs *regs, int fromipi) static int xmon_core(struct pt_regs *regs, volatile int fromipi)
{ {
int cmd = 0; volatile int cmd = 0;
struct bpt *bp; struct bpt *volatile bp;
long recurse_jmp[JMP_BUF_LEN]; long recurse_jmp[JMP_BUF_LEN];
bool locked_down; bool locked_down;
unsigned long offset; unsigned long offset;
...@@ -872,7 +872,7 @@ static inline void force_enable_xmon(void) ...@@ -872,7 +872,7 @@ static inline void force_enable_xmon(void)
static struct bpt *at_breakpoint(unsigned long pc) static struct bpt *at_breakpoint(unsigned long pc)
{ {
int i; int i;
struct bpt *bp; struct bpt *volatile bp;
bp = bpts; bp = bpts;
for (i = 0; i < NBPTS; ++i, ++bp) for (i = 0; i < NBPTS; ++i, ++bp)
...@@ -3109,7 +3109,7 @@ static void dump_opal_msglog(void) ...@@ -3109,7 +3109,7 @@ static void dump_opal_msglog(void)
{ {
unsigned char buf[128]; unsigned char buf[128];
ssize_t res; ssize_t res;
loff_t pos = 0; volatile loff_t pos = 0;
if (!firmware_has_feature(FW_FEATURE_OPAL)) { if (!firmware_has_feature(FW_FEATURE_OPAL)) {
printf("Machine is not running OPAL firmware.\n"); printf("Machine is not running OPAL firmware.\n");
...@@ -3264,7 +3264,7 @@ memzcan(void) ...@@ -3264,7 +3264,7 @@ memzcan(void)
printf("%.8lx\n", a - mskip); printf("%.8lx\n", a - mskip);
} }
static void show_task(struct task_struct *tsk) static void show_task(struct task_struct *volatile tsk)
{ {
char state; char state;
...@@ -3308,7 +3308,7 @@ static void format_pte(void *ptep, unsigned long pte) ...@@ -3308,7 +3308,7 @@ static void format_pte(void *ptep, unsigned long pte)
static void show_pte(unsigned long addr) static void show_pte(unsigned long addr)
{ {
unsigned long tskv = 0; unsigned long tskv = 0;
struct task_struct *tsk = NULL; struct task_struct *volatile tsk = NULL;
struct mm_struct *mm; struct mm_struct *mm;
pgd_t *pgdp; pgd_t *pgdp;
p4d_t *p4dp; p4d_t *p4dp;
...@@ -3403,7 +3403,7 @@ static void show_pte(unsigned long addr) ...@@ -3403,7 +3403,7 @@ static void show_pte(unsigned long addr)
static void show_tasks(void) static void show_tasks(void)
{ {
unsigned long tskv; unsigned long tskv;
struct task_struct *tsk = NULL; struct task_struct *volatile tsk = NULL;
printf(" task_struct ->thread.ksp ->thread.regs PID PPID S P CMD\n"); printf(" task_struct ->thread.ksp ->thread.regs PID PPID S P CMD\n");
...@@ -3726,7 +3726,7 @@ static void xmon_print_symbol(unsigned long address, const char *mid, ...@@ -3726,7 +3726,7 @@ static void xmon_print_symbol(unsigned long address, const char *mid,
const char *after) const char *after)
{ {
char *modname; char *modname;
const char *name = NULL; const char *volatile name = NULL;
unsigned long offset, size; unsigned long offset, size;
printf(REG, address); printf(REG, address);
...@@ -4158,7 +4158,7 @@ void xmon_register_spus(struct list_head *list) ...@@ -4158,7 +4158,7 @@ void xmon_register_spus(struct list_head *list)
static void stop_spus(void) static void stop_spus(void)
{ {
struct spu *spu; struct spu *spu;
int i; volatile int i;
u64 tmp; u64 tmp;
for (i = 0; i < XMON_NUM_SPUS; i++) { for (i = 0; i < XMON_NUM_SPUS; i++) {
...@@ -4199,7 +4199,7 @@ static void stop_spus(void) ...@@ -4199,7 +4199,7 @@ static void stop_spus(void)
static void restart_spus(void) static void restart_spus(void)
{ {
struct spu *spu; struct spu *spu;
int i; volatile int i;
for (i = 0; i < XMON_NUM_SPUS; i++) { for (i = 0; i < XMON_NUM_SPUS; i++) {
if (!spu_info[i].spu) if (!spu_info[i].spu)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment