mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
riscv: add icache flush for nommu sigreturn trampoline
commit8d73648274upstream. In a NOMMU kernel, sigreturn trampolines are generated on the user stack by setup_rt_frame. Currently, these trampolines are not instruction fenced, thus their visibility to ifetch is not guaranteed. This patch adds a flush_icache_range in setup_rt_frame to fix this problem. Signed-off-by: Mathis Salmen <mathis.salmen@matsal.de> Fixes:6bd33e1ece("riscv: add nommu support") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20230406101130.82304-1-mathis.salmen@matsal.de Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c76e79e526
commit
2a4835b8ed
@@ -16,6 +16,7 @@
|
|||||||
#include <asm/vdso.h>
|
#include <asm/vdso.h>
|
||||||
#include <asm/switch_to.h>
|
#include <asm/switch_to.h>
|
||||||
#include <asm/csr.h>
|
#include <asm/csr.h>
|
||||||
|
#include <asm/cacheflush.h>
|
||||||
|
|
||||||
extern u32 __user_rt_sigreturn[2];
|
extern u32 __user_rt_sigreturn[2];
|
||||||
|
|
||||||
@@ -178,6 +179,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
|
|||||||
{
|
{
|
||||||
struct rt_sigframe __user *frame;
|
struct rt_sigframe __user *frame;
|
||||||
long err = 0;
|
long err = 0;
|
||||||
|
unsigned long __maybe_unused addr;
|
||||||
|
|
||||||
frame = get_sigframe(ksig, regs, sizeof(*frame));
|
frame = get_sigframe(ksig, regs, sizeof(*frame));
|
||||||
if (!access_ok(frame, sizeof(*frame)))
|
if (!access_ok(frame, sizeof(*frame)))
|
||||||
@@ -206,7 +208,12 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
|
|||||||
if (copy_to_user(&frame->sigreturn_code, __user_rt_sigreturn,
|
if (copy_to_user(&frame->sigreturn_code, __user_rt_sigreturn,
|
||||||
sizeof(frame->sigreturn_code)))
|
sizeof(frame->sigreturn_code)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
regs->ra = (unsigned long)&frame->sigreturn_code;
|
|
||||||
|
addr = (unsigned long)&frame->sigreturn_code;
|
||||||
|
/* Make sure the two instructions are pushed to icache. */
|
||||||
|
flush_icache_range(addr, addr + sizeof(frame->sigreturn_code));
|
||||||
|
|
||||||
|
regs->ra = addr;
|
||||||
#endif /* CONFIG_MMU */
|
#endif /* CONFIG_MMU */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user