[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJF2gTSR5A1vxz_5SSK207SaC-3QHLcKFvcy35VtrKEk4-D9iQ@mail.gmail.com>
Date: Wed, 21 Sep 2022 10:16:03 +0800
From: Guo Ren <guoren@...nel.org>
To: Chen Zhongjin <chenzhongjin@...wei.com>
Cc: linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org,
linux-perf-users@...r.kernel.org, paul.walmsley@...ive.com,
palmer@...belt.com, aou@...s.berkeley.edu, peterz@...radead.org,
mingo@...hat.com, acme@...nel.org, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, namhyung@...nel.org,
jolsa@...nel.org, nsaenzju@...hat.com, frederic@...nel.org,
changbin.du@...el.com, vincent.chen@...ive.com, ardb@...nel.org,
mhiramat@...nel.org, rostedt@...dmis.org, keescook@...omium.org,
catalin.marinas@....com
Subject: Re: [PATCH -next 4/7] riscv: syscall: Don't clobber s0 when syscall
On Wed, Sep 21, 2022 at 9:30 AM Guo Ren <guoren@...nel.org> wrote:
>
> On Tue, Sep 20, 2022 at 11:15 PM Chen Zhongjin <chenzhongjin@...wei.com> wrote:
> >
> > syscall uses s0 to load address of sys_call_table.
> >
> > Since now we uses s0 to save pt_regs for unwinding, clobber
> > s0 can make unwinder treat s0 as pt_regs address. Use s1 for
> > this job.
> This patch does not make sense. Why couldn't we use s1 for pt_regs?
Seems s0->fp can't be replaced. I take back the question.
>
> No need to modify the entry.S here.
>
> >
> > Signed-off-by: Chen Zhongjin <chenzhongjin@...wei.com>
> > ---
> > arch/riscv/kernel/entry.S | 20 ++++++++++----------
> > 1 file changed, 10 insertions(+), 10 deletions(-)
> >
> > diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S
> > index ecb15c7430b4..a3b14a649782 100644
> > --- a/arch/riscv/kernel/entry.S
> > +++ b/arch/riscv/kernel/entry.S
> > @@ -205,33 +205,33 @@ handle_syscall:
> > check_syscall_nr:
> > /* Check to make sure we don't jump to a bogus syscall number. */
> > li t0, __NR_syscalls
> > - la s0, sys_ni_syscall
> > + la s1, sys_ni_syscall
> > /*
> > * Syscall number held in a7.
> > * If syscall number is above allowed value, redirect to ni_syscall.
> > */
> > bgeu a7, t0, 3f
> > #ifdef CONFIG_COMPAT
> > - REG_L s0, PT_STATUS(sp)
> > - srli s0, s0, SR_UXL_SHIFT
> > - andi s0, s0, (SR_UXL >> SR_UXL_SHIFT)
> > + REG_L s1, PT_STATUS(sp)
> > + srli s1, s1, SR_UXL_SHIFT
> > + andi s1, s1, (SR_UXL >> SR_UXL_SHIFT)
> > li t0, (SR_UXL_32 >> SR_UXL_SHIFT)
> > - sub t0, s0, t0
> > + sub t0, s1, t0
> > bnez t0, 1f
> >
> > /* Call compat_syscall */
> > - la s0, compat_sys_call_table
> > + la s1, compat_sys_call_table
> > j 2f
> > 1:
> > #endif
> > /* Call syscall */
> > - la s0, sys_call_table
> > + la s1, sys_call_table
> > 2:
> > slli t0, a7, RISCV_LGPTR
> > - add s0, s0, t0
> > - REG_L s0, 0(s0)
> > + add s1, s1, t0
> > + REG_L s1, 0(s1)
> > 3:
> > - jalr s0
> > + jalr s1
> >
> > ret_from_syscall:
> > /* Set user a0 to kernel a0 */
> > --
> > 2.17.1
> >
>
>
> --
> Best Regards
> Guo Ren
--
Best Regards
Guo Ren
Powered by blists - more mailing lists