diff mbox series

[v4,3/4] MIPS: Return earlier in die() if notify_die() returns NOTIFY_STOP

Message ID 1692434183-2054-4-git-send-email-yangtiezhu@loongson.cn (mailing list archive)
State Accepted
Commit b5583beac56d5eb1492ed0a60a59d632f7736d6d
Headers show
Series Modify die() for MIPS | expand

Commit Message

Tiezhu Yang Aug. 19, 2023, 8:36 a.m. UTC
After the call to oops_exit(), it should not panic or execute
the crash kernel if the oops is to be suppressed.

Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/mips/kernel/traps.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Huacai Chen Aug. 20, 2023, 8:53 a.m. UTC | #1
Hi, Tiezhu,

On Sun, Aug 20, 2023 at 7:21 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
> After the call to oops_exit(), it should not panic or execute
> the crash kernel if the oops is to be suppressed.
>
> Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  arch/mips/kernel/traps.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
> index 8e528a8..fd770dc 100644
> --- a/arch/mips/kernel/traps.c
> +++ b/arch/mips/kernel/traps.c
> @@ -412,6 +412,9 @@ void die(const char *str, struct pt_regs *regs)
>
>         oops_exit();
>
> +       if (ret == NOTIFY_STOP)
> +               return;
> +
>         if (in_interrupt())
>                 panic("Fatal exception in interrupt");
>
> @@ -421,8 +424,7 @@ void die(const char *str, struct pt_regs *regs)
>         if (regs && kexec_should_crash(current))
>                 crash_kexec(regs);
>
> -       if (ret != NOTIFY_STOP)
> -               make_task_dead(SIGSEGV);
> +       make_task_dead(SIGSEGV);
Then you call make_task_dead() at the end unconditionally, and die()
becomes a noreturn function again.

Huacai
>  }
>
>  extern struct exception_table_entry __start___dbe_table[];
> --
> 2.1.0
>
Tiezhu Yang Aug. 21, 2023, 2:28 a.m. UTC | #2
On 08/20/2023 04:53 PM, Huacai Chen wrote:
> Hi, Tiezhu,
>
> On Sun, Aug 20, 2023 at 7:21 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>>
>> After the call to oops_exit(), it should not panic or execute
>> the crash kernel if the oops is to be suppressed.
>>
>> Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk>
>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>> ---
>>  arch/mips/kernel/traps.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
>> index 8e528a8..fd770dc 100644
>> --- a/arch/mips/kernel/traps.c
>> +++ b/arch/mips/kernel/traps.c
>> @@ -412,6 +412,9 @@ void die(const char *str, struct pt_regs *regs)
>>
>>         oops_exit();
>>
>> +       if (ret == NOTIFY_STOP)
>> +               return;
>> +
>>         if (in_interrupt())
>>                 panic("Fatal exception in interrupt");
>>
>> @@ -421,8 +424,7 @@ void die(const char *str, struct pt_regs *regs)
>>         if (regs && kexec_should_crash(current))
>>                 crash_kexec(regs);
>>
>> -       if (ret != NOTIFY_STOP)
>> -               make_task_dead(SIGSEGV);
>> +       make_task_dead(SIGSEGV);
> Then you call make_task_dead() at the end unconditionally, and die()
> becomes a noreturn function again.

No, it can return if (ret == NOTIFY_STOP), so die() is a return
function now, please see objdump -d arch/mips/kernel/traps.o.

Thanks,
Tiezhu
Huacai Chen Aug. 22, 2023, 7:38 a.m. UTC | #3
On Mon, Aug 21, 2023 at 10:29 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
>
>
> On 08/20/2023 04:53 PM, Huacai Chen wrote:
> > Hi, Tiezhu,
> >
> > On Sun, Aug 20, 2023 at 7:21 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> >>
> >> After the call to oops_exit(), it should not panic or execute
> >> the crash kernel if the oops is to be suppressed.
> >>
> >> Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk>
> >> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> >> ---
> >>  arch/mips/kernel/traps.c | 6 ++++--
> >>  1 file changed, 4 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
> >> index 8e528a8..fd770dc 100644
> >> --- a/arch/mips/kernel/traps.c
> >> +++ b/arch/mips/kernel/traps.c
> >> @@ -412,6 +412,9 @@ void die(const char *str, struct pt_regs *regs)
> >>
> >>         oops_exit();
> >>
> >> +       if (ret == NOTIFY_STOP)
> >> +               return;
> >> +
> >>         if (in_interrupt())
> >>                 panic("Fatal exception in interrupt");
> >>
> >> @@ -421,8 +424,7 @@ void die(const char *str, struct pt_regs *regs)
> >>         if (regs && kexec_should_crash(current))
> >>                 crash_kexec(regs);
> >>
> >> -       if (ret != NOTIFY_STOP)
> >> -               make_task_dead(SIGSEGV);
> >> +       make_task_dead(SIGSEGV);
> > Then you call make_task_dead() at the end unconditionally, and die()
> > becomes a noreturn function again.
>
> No, it can return if (ret == NOTIFY_STOP), so die() is a return
> function now, please see objdump -d arch/mips/kernel/traps.o.
Then should loongarch patches need to be updated, too?

Huacai
>
> Thanks,
> Tiezhu
>
Tiezhu Yang Aug. 22, 2023, 8:55 a.m. UTC | #4
On 08/22/2023 03:38 PM, Huacai Chen wrote:
> On Mon, Aug 21, 2023 at 10:29 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>>
>>
>>
>> On 08/20/2023 04:53 PM, Huacai Chen wrote:
>>> Hi, Tiezhu,
>>>
>>> On Sun, Aug 20, 2023 at 7:21 AM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>>>>
>>>> After the call to oops_exit(), it should not panic or execute
>>>> the crash kernel if the oops is to be suppressed.
>>>>
>>>> Suggested-by: Maciej W. Rozycki <macro@orcam.me.uk>
>>>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>>>> ---
>>>>  arch/mips/kernel/traps.c | 6 ++++--
>>>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
>>>> index 8e528a8..fd770dc 100644
>>>> --- a/arch/mips/kernel/traps.c
>>>> +++ b/arch/mips/kernel/traps.c
>>>> @@ -412,6 +412,9 @@ void die(const char *str, struct pt_regs *regs)
>>>>
>>>>         oops_exit();
>>>>
>>>> +       if (ret == NOTIFY_STOP)
>>>> +               return;
>>>> +
>>>>         if (in_interrupt())
>>>>                 panic("Fatal exception in interrupt");
>>>>
>>>> @@ -421,8 +424,7 @@ void die(const char *str, struct pt_regs *regs)
>>>>         if (regs && kexec_should_crash(current))
>>>>                 crash_kexec(regs);
>>>>
>>>> -       if (ret != NOTIFY_STOP)
>>>> -               make_task_dead(SIGSEGV);
>>>> +       make_task_dead(SIGSEGV);
>>> Then you call make_task_dead() at the end unconditionally, and die()
>>> becomes a noreturn function again.
>>
>> No, it can return if (ret == NOTIFY_STOP), so die() is a return
>> function now, please see objdump -d arch/mips/kernel/traps.o.
> Then should loongarch patches need to be updated, too?

Yes, I think so, will do it.

Thanks,
Tiezhu
diff mbox series

Patch

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 8e528a8..fd770dc 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -412,6 +412,9 @@  void die(const char *str, struct pt_regs *regs)
 
 	oops_exit();
 
+	if (ret == NOTIFY_STOP)
+		return;
+
 	if (in_interrupt())
 		panic("Fatal exception in interrupt");
 
@@ -421,8 +424,7 @@  void die(const char *str, struct pt_regs *regs)
 	if (regs && kexec_should_crash(current))
 		crash_kexec(regs);
 
-	if (ret != NOTIFY_STOP)
-		make_task_dead(SIGSEGV);
+	make_task_dead(SIGSEGV);
 }
 
 extern struct exception_table_entry __start___dbe_table[];