Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2460318rdg; Mon, 14 Aug 2023 03:23:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWgKU5SpbnvCVG5phCh+mYRYLzbxBzCv7JrMoS/R08P6W2Zfidzg1MJaBWbvWpORz+gjyz X-Received: by 2002:a17:902:ce8b:b0:1bc:7837:366a with SMTP id f11-20020a170902ce8b00b001bc7837366amr12447916plg.19.1692008607178; Mon, 14 Aug 2023 03:23:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692008607; cv=none; d=google.com; s=arc-20160816; b=I3X4PPQgNIi1D/agOkBi3GnwPnN80jARqRmewjsD+SZQ8CyqOPb+gEtCyRK3LX8Ulz WOn29LBJC5w3tDFmHP8KQ4tK/FYozGLcSXT/4zTqT/5KgulAnlTkMxJKNmcrtcQyN9Oc TR5F7LiChGMRHzfD4GfFC27ngbSm+dJcSIS9Hk9tvRk+NJgytnc4mfxEo6GYYotZ1Pka 13Aj21U4WXekPdAUZs3fAHhvNK1meDNVq84jImvJoEkGXYUNosL0KJwQPD+dThdBgVm/ wY6du9tp1vFaI5O76wW3pTH1HxzL1I5K2mZuZ/rojhxtCZ4AGPhf8o+a0cC7szWFNT8M PZqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=bf3xSJCZcCuv6UBVKoLiqn99DMJlFyS7SYRw+IwRdzo=; fh=SZ39SBhiFik3r2Qby0lfj8dSyaj5PbEfEri4a6Oa5Uc=; b=L5y8Qxo0eN82hpTSBI728BLXFU+zkCB1MIgkjMg0L77aJUJ6wXIB4Z5GlByqf8Bubk YI1G6JGJ2EX4f/Sz7EXs3kymK1L5rn25Qj1Dt14XS9MBzioKYHGIzNp8nhznUdnkRCBb s19aReKQEAwwfY/8MXdM+1YVwdGcdgAhdQ225I52UJitO+zeSi/rKwWLVa4KxR6qvjnZ UqsCvX0Ehhj6VOsBTuVvA9doNMv6R39Ok6l8y+GIwnJJsDP1h9oHWi/Cc86QQZxdiE+F cdb0rjo+O8l7A1oqj739icVnYE4e4Nr1JM8k76P+DqmDIa1EqvES5yFG6YlrNWh9yN/n 5RIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lg4-20020a170902fb8400b001b89b1b9a01si7666324plb.194.2023.08.14.03.23.15; Mon, 14 Aug 2023 03:23:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233530AbjHNJfd (ORCPT + 99 others); Mon, 14 Aug 2023 05:35:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233683AbjHNJfN (ORCPT ); Mon, 14 Aug 2023 05:35:13 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1E630E61 for ; Mon, 14 Aug 2023 02:35:11 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8AxlPBO9dlkIRUYAA--.49791S3; Mon, 14 Aug 2023 17:35:10 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxLCNN9dlkgLtZAA--.5447S3; Mon, 14 Aug 2023 17:35:10 +0800 (CST) From: Tiezhu Yang To: Huacai Chen Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH v3 1/2] LoongArch: Remove noreturn attribute for die() Date: Mon, 14 Aug 2023 17:35:03 +0800 Message-Id: <1692005704-19126-2-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1692005704-19126-1-git-send-email-yangtiezhu@loongson.cn> References: <1692005704-19126-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8CxLCNN9dlkgLtZAA--.5447S3 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoWxXry8KF4kZry5XrW3try7Jwc_yoW5Gr1DpF ZrCa4DGFWUCFs5XFyDJF4DuFy5JrZ5G3429wnF93yF9FnIqw1rXr1kGrWqvF4rt3yrWrW0 qFWFgw1SqFZxAabCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Ib4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r126r13M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU tVWrXwAv7VC2z280aVAFwI0_Cr0_Gr1UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x 0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C267AK xVWUXVWUAwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMI IF0xvEx4A2jsIE14v26F4j6r4UJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnI WIevJa73UjIFyTuYvjxU7fOzDUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If notify_die() returns NOTIFY_STOP, honor the return value from the handler chain invocation in die() as, through a debugger, the fault may have been fixed. It makes sense even if ignoring the event will make the system unstable, by allowing access through a debugger it has been compromised already anyway. So we can remove the noreturn attribute for die() to make our port consistent with x86, arm64, riscv and csky. Commit 20c0d2d44029 ("[PATCH] i386: pass proper trap numbers to die chain handlers") may be the earliest of similar changes. Link: https://lore.kernel.org/all/alpine.DEB.2.21.2308132148500.8596@angie.orcam.me.uk/ Signed-off-by: Tiezhu Yang --- arch/loongarch/include/asm/ptrace.h | 2 +- arch/loongarch/kernel/traps.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/loongarch/include/asm/ptrace.h b/arch/loongarch/include/asm/ptrace.h index 35f0958..164bc90 100644 --- a/arch/loongarch/include/asm/ptrace.h +++ b/arch/loongarch/include/asm/ptrace.h @@ -162,7 +162,7 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long val #define instruction_pointer(regs) ((regs)->csr_era) #define profile_pc(regs) instruction_pointer(regs) -extern void die(const char *, struct pt_regs *) __noreturn; +extern void die(const char *, struct pt_regs *); static inline void die_if_kernel(const char *str, struct pt_regs *regs) { diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c index 8fb5e7a..bbdfc5b 100644 --- a/arch/loongarch/kernel/traps.c +++ b/arch/loongarch/kernel/traps.c @@ -383,16 +383,15 @@ void show_registers(struct pt_regs *regs) static DEFINE_RAW_SPINLOCK(die_lock); -void __noreturn die(const char *str, struct pt_regs *regs) +void die(const char *str, struct pt_regs *regs) { static int die_counter; - int sig = SIGSEGV; + int ret; oops_enter(); - if (notify_die(DIE_OOPS, str, regs, 0, current->thread.trap_nr, - SIGSEGV) == NOTIFY_STOP) - sig = 0; + ret = notify_die(DIE_OOPS, str, regs, 0, + current->thread.trap_nr, SIGSEGV); console_verbose(); raw_spin_lock_irq(&die_lock); @@ -414,7 +413,8 @@ void __noreturn die(const char *str, struct pt_regs *regs) if (panic_on_oops) panic("Fatal exception"); - make_task_dead(sig); + if (ret != NOTIFY_STOP) + make_task_dead(SIGSEGV); } static inline void setup_vint_size(unsigned int size) -- 2.1.0