2022-09-26 14:48:18

by Jun Yi

[permalink] [raw]
Subject: [PATCH v3] LoongArch: Fixup do_ri csr_era

csr_era of pt_regs in do_ri should not add 4 to point to the
next instruction.

Signed-off-by: Jun Yi <[email protected]>
---
arch/loongarch/kernel/traps.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c
index aa1c95aaf595..ec888eda3d45 100644
--- a/arch/loongarch/kernel/traps.c
+++ b/arch/loongarch/kernel/traps.c
@@ -477,8 +477,6 @@ asmlinkage void noinstr do_ri(struct pt_regs *regs)

die_if_kernel("Reserved instruction in kernel code", regs);

- compute_return_era(regs);
-
if (unlikely(get_user(opcode, era) < 0)) {
status = SIGSEGV;
current->thread.error_code = 1;
--
2.31.1


2022-09-27 00:38:00

by Guo Ren

[permalink] [raw]
Subject: Re: [PATCH v3] LoongArch: Fixup do_ri csr_era

On Mon, Sep 26, 2022 at 8:27 PM Jun Yi <[email protected]> wrote:
>
> csr_era of pt_regs in do_ri should not add 4 to point to the
> next instruction.
The comment does not make sense. I think it wants to skip some
instructions, but your patch broke that.

>
> Signed-off-by: Jun Yi <[email protected]>
> ---
> arch/loongarch/kernel/traps.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c
> index aa1c95aaf595..ec888eda3d45 100644
> --- a/arch/loongarch/kernel/traps.c
> +++ b/arch/loongarch/kernel/traps.c
> @@ -477,8 +477,6 @@ asmlinkage void noinstr do_ri(struct pt_regs *regs)
>
> die_if_kernel("Reserved instruction in kernel code", regs);
>
> - compute_return_era(regs);
> -
> if (unlikely(get_user(opcode, era) < 0)) {
> status = SIGSEGV;
> current->thread.error_code = 1;
> --
> 2.31.1
>


--
Best Regards
Guo Ren

2022-09-27 03:34:07

by Jun Yi

[permalink] [raw]
Subject: Re: [PATCH v3] LoongArch: Fixup do_ri csr_era

do_ri is porting from mips, mipsr6 use do_ri to emulate some fp
instructions, but Loongarch do not need to emulate these instructions.

And the regs->csr_era be always recovered to ths old_era =
regs->csr_era, so the compute_return_era is useless.

On 9/27/22 07:41, Guo Ren wrote:
> On Mon, Sep 26, 2022 at 8:27 PM Jun Yi <[email protected]> wrote:
>>
>> csr_era of pt_regs in do_ri should not add 4 to point to the
>> next instruction.
> The comment does not make sense. I think it wants to skip some
> instructions, but your patch broke that.
>
>>
>> Signed-off-by: Jun Yi <[email protected]>
>> ---
>> arch/loongarch/kernel/traps.c | 2 --
>> 1 file changed, 2 deletions(-)
>>
>> diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c
>> index aa1c95aaf595..ec888eda3d45 100644
>> --- a/arch/loongarch/kernel/traps.c
>> +++ b/arch/loongarch/kernel/traps.c
>> @@ -477,8 +477,6 @@ asmlinkage void noinstr do_ri(struct pt_regs *regs)
>>
>> die_if_kernel("Reserved instruction in kernel code", regs);
>>
>> - compute_return_era(regs);
>> -
>> if (unlikely(get_user(opcode, era) < 0)) {
>> status = SIGSEGV;
>> current->thread.error_code = 1;
>> --
>> 2.31.1
>>
>
>

2022-09-27 05:19:11

by Huacai Chen

[permalink] [raw]
Subject: Re: [PATCH v3] LoongArch: Fixup do_ri csr_era

Hi, all,

I clean up do_ri() further based on this patch [1], thanks.

[1] https://lore.kernel.org/loongarch/[email protected]/T/#u


On Tue, Sep 27, 2022 at 11:10 AM Jun Yi <[email protected]> wrote:
>
> do_ri is porting from mips, mipsr6 use do_ri to emulate some fp
> instructions, but Loongarch do not need to emulate these instructions.
>
> And the regs->csr_era be always recovered to ths old_era =
> regs->csr_era, so the compute_return_era is useless.
>
> On 9/27/22 07:41, Guo Ren wrote:
> > On Mon, Sep 26, 2022 at 8:27 PM Jun Yi <[email protected]> wrote:
> >>
> >> csr_era of pt_regs in do_ri should not add 4 to point to the
> >> next instruction.
> > The comment does not make sense. I think it wants to skip some
> > instructions, but your patch broke that.
> >
> >>
> >> Signed-off-by: Jun Yi <[email protected]>
> >> ---
> >> arch/loongarch/kernel/traps.c | 2 --
> >> 1 file changed, 2 deletions(-)
> >>
> >> diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c
> >> index aa1c95aaf595..ec888eda3d45 100644
> >> --- a/arch/loongarch/kernel/traps.c
> >> +++ b/arch/loongarch/kernel/traps.c
> >> @@ -477,8 +477,6 @@ asmlinkage void noinstr do_ri(struct pt_regs *regs)
> >>
> >> die_if_kernel("Reserved instruction in kernel code", regs);
> >>
> >> - compute_return_era(regs);
> >> -
> >> if (unlikely(get_user(opcode, era) < 0)) {
> >> status = SIGSEGV;
> >> current->thread.error_code = 1;
> >> --
> >> 2.31.1
> >>
> >
> >
>