From: Guo Ren <guoren@kernel.org>
To: Chen Zhongjin <chenzhongjin@huawei.com>
Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-perf-users@vger.kernel.org, paul.walmsley@sifive.com,
palmer@dabbelt.com, aou@eecs.berkeley.edu, peterz@infradead.org,
mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, namhyung@kernel.org,
jolsa@kernel.org, nsaenzju@redhat.com, frederic@kernel.org,
changbin.du@intel.com, vincent.chen@sifive.com, ardb@kernel.org,
mhiramat@kernel.org, rostedt@goodmis.org, keescook@chromium.org,
catalin.marinas@arm.com
Subject: Re: [PATCH -next 4/7] riscv: syscall: Don't clobber s0 when syscall
Date: Wed, 21 Sep 2022 10:16:03 +0800 [thread overview]
Message-ID: <CAJF2gTSR5A1vxz_5SSK207SaC-3QHLcKFvcy35VtrKEk4-D9iQ@mail.gmail.com> (raw)
In-Reply-To: <CAJF2gTQ8QjUiRhQiM67SET=bCpppG2opcN3_ch7GEqdAkBnBUA@mail.gmail.com>
On Wed, Sep 21, 2022 at 9:30 AM Guo Ren <guoren@kernel.org> wrote:
>
> On Tue, Sep 20, 2022 at 11:15 PM Chen Zhongjin <chenzhongjin@huawei.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@huawei.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
next prev parent reply other threads:[~2022-09-21 2:16 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-20 15:11 [PATCH -next 0/7] riscv: Improvments for stacktrace Chen Zhongjin
2022-09-20 15:11 ` [PATCH -next 1/7] riscv: stacktrace: Replace walk_stackframe with arch_stack_walk Chen Zhongjin
2022-09-20 15:11 ` [PATCH -next 2/7] riscv: stacktrace: Introduce unwind functions Chen Zhongjin
2022-09-20 15:11 ` [PATCH -next 3/7] riscv: stacktrace: Save pt_regs in encoded fp on irq entry Chen Zhongjin
2022-09-21 2:13 ` Guo Ren
2022-09-20 15:11 ` [PATCH -next 4/7] riscv: syscall: Don't clobber s0 when syscall Chen Zhongjin
2022-09-21 1:30 ` Guo Ren
2022-09-21 2:16 ` Guo Ren [this message]
2022-09-20 15:12 ` [PATCH -next 5/7] riscv: stacktrace: Implement stacktrace for irq Chen Zhongjin
2022-09-20 15:12 ` [PATCH -next 6/7] riscv: stacktrace: Fix unwinding on ftrace_regs_call Chen Zhongjin
2022-09-21 1:43 ` Guo Ren
2022-09-21 3:00 ` Chen Zhongjin
2022-09-20 15:12 ` [PATCH -next 7/7] riscv: stacktrace: Fix unwinding on __kretporbe_trampoline Chen Zhongjin
2022-09-21 2:30 ` [PATCH -next 0/7] riscv: Improvments for stacktrace Guo Ren
2022-09-21 12:33 ` Chen Zhongjin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJF2gTSR5A1vxz_5SSK207SaC-3QHLcKFvcy35VtrKEk4-D9iQ@mail.gmail.com \
--to=guoren@kernel.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=changbin.du@intel.com \
--cc=chenzhongjin@huawei.com \
--cc=frederic@kernel.org \
--cc=jolsa@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=nsaenzju@redhat.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.chen@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).