mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 10:57:46 +00:00
xtensa: fix MAKE_PC_FROM_RA second argument
commit 0e60f0b758
upstream.
Xtensa has two-argument MAKE_PC_FROM_RA macro to convert a0 to an actual
return address because when windowed ABI is used call{,x}{4,8,12}
opcodes stuff encoded window size into the top 2 bits of the register
that becomes a return address in the called function. Second argument of
that macro is supposed to be an address having these 2 topmost bits set
correctly, but the comment suggested that that could be the stack
address. However the stack doesn't have to be in the same 1GByte region
as the code, especially in noMMU XIP configurations.
Fix the comment and use either _text or regs->pc as the second argument
for the MAKE_PC_FROM_RA macro.
Cc: stable@vger.kernel.org
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ffd4917c1e
commit
ef31b4647e
4 changed files with 10 additions and 8 deletions
|
@ -115,9 +115,9 @@
|
|||
#define MAKE_RA_FOR_CALL(ra,ws) (((ra) & 0x3fffffff) | (ws) << 30)
|
||||
|
||||
/* Convert return address to a valid pc
|
||||
* Note: We assume that the stack pointer is in the same 1GB ranges as the ra
|
||||
* Note: 'text' is the address within the same 1GB range as the ra
|
||||
*/
|
||||
#define MAKE_PC_FROM_RA(ra,sp) (((ra) & 0x3fffffff) | ((sp) & 0xc0000000))
|
||||
#define MAKE_PC_FROM_RA(ra, text) (((ra) & 0x3fffffff) | ((unsigned long)(text) & 0xc0000000))
|
||||
|
||||
#elif defined(__XTENSA_CALL0_ABI__)
|
||||
|
||||
|
@ -127,9 +127,9 @@
|
|||
#define MAKE_RA_FOR_CALL(ra, ws) (ra)
|
||||
|
||||
/* Convert return address to a valid pc
|
||||
* Note: We assume that the stack pointer is in the same 1GB ranges as the ra
|
||||
* Note: 'text' is not used as 'ra' is always the full address
|
||||
*/
|
||||
#define MAKE_PC_FROM_RA(ra, sp) (ra)
|
||||
#define MAKE_PC_FROM_RA(ra, text) (ra)
|
||||
|
||||
#else
|
||||
#error Unsupported Xtensa ABI
|
||||
|
|
|
@ -87,7 +87,7 @@ struct pt_regs {
|
|||
# define user_mode(regs) (((regs)->ps & 0x00000020)!=0)
|
||||
# define instruction_pointer(regs) ((regs)->pc)
|
||||
# define return_pointer(regs) (MAKE_PC_FROM_RA((regs)->areg[0], \
|
||||
(regs)->areg[1]))
|
||||
(regs)->pc))
|
||||
|
||||
# ifndef CONFIG_SMP
|
||||
# define profile_pc(regs) instruction_pointer(regs)
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include <asm/asm-offsets.h>
|
||||
#include <asm/regs.h>
|
||||
#include <asm/hw_breakpoint.h>
|
||||
#include <asm/sections.h>
|
||||
#include <asm/traps.h>
|
||||
|
||||
extern void ret_from_fork(void);
|
||||
|
@ -380,7 +381,7 @@ unsigned long __get_wchan(struct task_struct *p)
|
|||
int count = 0;
|
||||
|
||||
sp = p->thread.sp;
|
||||
pc = MAKE_PC_FROM_RA(p->thread.ra, p->thread.sp);
|
||||
pc = MAKE_PC_FROM_RA(p->thread.ra, _text);
|
||||
|
||||
do {
|
||||
if (sp < stack_page + sizeof(struct task_struct) ||
|
||||
|
@ -392,7 +393,7 @@ unsigned long __get_wchan(struct task_struct *p)
|
|||
|
||||
/* Stack layout: sp-4: ra, sp-3: sp' */
|
||||
|
||||
pc = MAKE_PC_FROM_RA(SPILL_SLOT(sp, 0), sp);
|
||||
pc = MAKE_PC_FROM_RA(SPILL_SLOT(sp, 0), _text);
|
||||
sp = SPILL_SLOT(sp, 1);
|
||||
} while (count++ < 16);
|
||||
return 0;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <linux/stacktrace.h>
|
||||
|
||||
#include <asm/ftrace.h>
|
||||
#include <asm/sections.h>
|
||||
#include <asm/stacktrace.h>
|
||||
#include <asm/traps.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
@ -189,7 +190,7 @@ void walk_stackframe(unsigned long *sp,
|
|||
if (a1 <= (unsigned long)sp)
|
||||
break;
|
||||
|
||||
frame.pc = MAKE_PC_FROM_RA(a0, a1);
|
||||
frame.pc = MAKE_PC_FROM_RA(a0, _text);
|
||||
frame.sp = a1;
|
||||
|
||||
if (fn(&frame, data))
|
||||
|
|
Loading…
Reference in a new issue