Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2370678rdh; Sun, 26 Nov 2023 04:18:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IETvE1GwH8Mb0zlJd+2vSUcVJJB4H4Jyn65ATDPBIOAXMD8yxtL2wZc8J9xKD19xZq3K1/g X-Received: by 2002:a05:6a00:1d06:b0:6cb:8c70:4792 with SMTP id a6-20020a056a001d0600b006cb8c704792mr10259277pfx.4.1701001117857; Sun, 26 Nov 2023 04:18:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701001117; cv=none; d=google.com; s=arc-20160816; b=igifQBHMLx+IZY+KwmKTMCHSQLQrTGalZIIFUsl0FkuYi5dTqZtw3O3DaCL7Lia6iO lskbyArVEmKoC5g6JF55/WOzZjuNWZU6NgUzxtzBRFzh8KrqxjslPkSIVdjvSqY7BpdE L3y401zVaaC+srFXISYjfeKEaITjQeacLdqvrq8OBIaQc/q2x3WCf4Uslqf37GDku8NF EwVogmI+410r125A0HN7oRz+C4WhwqPuqk7HgqOxcYB1oim0lrvlbz1BT8eFfo6g/Tb6 9SCdHDHtOg8RleHTwjtYHivjdbhTj2To3VmON5KbU6162x9lBd3O9wJsfASPeeuUvCOZ CyMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=OX3UhP+7GfiLGXjVLKbY1PiQ+uviFaaJlTg6zswZjvo=; fh=mJ53REgB3BUBoI6t27bwzI7zQjeqCOshFdFKneJvz60=; b=bV5xl/nIa7pYHrGhCElLPAn4tcelURppx0Qd8hfL+yTuHr5zgzFRqr1U+jeQ++ajqE a50HPINJSp0M0JxUBzqGt4u7nmMISccCDCRYFlK1iUi1V/Iz6FveC2/iv+fA3d6R/KJM 8nGb8PY0dyEWZemIIFAWXq1UZyaO5AD3o9UEuH4oAXuAZxsq7NRVd9aP5qjcm28RB3W4 E60uYMoU7fC7orM09CwMKCLPmn6X7OOm2rra8JxPRYxJ4d6cRTLZBK7w1vPYNWUEXTZL W9XvmjcHbzMgVAoxViSUKfNtMiFuUe1CbL4z1g8YEDRrEMZqBIPflFZHXaQoT3NtI7YH dUPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h12-20020a056a00170c00b006cbd3f3a2fcsi7532125pfc.77.2023.11.26.04.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 04:18:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F200C8062916; Sun, 26 Nov 2023 04:18:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229456AbjKZMKK (ORCPT + 99 others); Sun, 26 Nov 2023 07:10:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjKZMKJ (ORCPT ); Sun, 26 Nov 2023 07:10:09 -0500 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ADE45B6 for ; Sun, 26 Nov 2023 04:10:13 -0800 (PST) Received: from loongson.cn (unknown [111.9.175.10]) by gateway (Coremail) with SMTP id _____8AxXOqjNWNlnNs8AA--.28074S3; Sun, 26 Nov 2023 20:10:11 +0800 (CST) Received: from localhost.localdomain (unknown [111.9.175.10]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dxvi+hNWNlqdlMAA--.38908S2; Sun, 26 Nov 2023 20:10:10 +0800 (CST) From: Jinyang He To: Huacai Chen , WANG Xuerui , Hengqi Chen Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] LoongArch: Set unwind stack type to unknown rather than set error flag Date: Sun, 26 Nov 2023 20:10:02 +0800 Message-Id: <20231126121002.22568-1-hejinyang@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Dxvi+hNWNlqdlMAA--.38908S2 X-CM-SenderInfo: pkhmx0p1dqwqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW7WF4xWw1UGrWrKrW8AFW7KFX_yoW5JF1kpr ZxA3Z3Wr4YgF92q3srtry8uryDXwnrCw13Wa4qyFyrCFnrXry2vw4Fva4DZF4qq3s5G34F vFn5G3s0ga1UJacCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07jUsqXUUUUU= X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 26 Nov 2023 04:18:36 -0800 (PST) During the unwinding, unwind_done() is used as an end condition. Normally it unwind to the user stack and then set the stack type to unknown, which is a normal exit. When something unexpected happens in unwind process and we cannot unwind anymore, we should set the error flag, and also set the stack type to unknown to indicate that the unwind process cannot continue. The error flag emphasizes that the unwind process produce an unexpected error. There is no unexpected things when we unwind the PT_REGS in the top of IRQ stack and find out that is an user mode PT_REGS. Thus, we should not set error flag and just set stack type to unknown. Reported-by: Hengqi Chen Signed-off-by: Jinyang He --- arch/loongarch/kernel/stacktrace.c | 2 +- arch/loongarch/kernel/unwind.c | 1 - arch/loongarch/kernel/unwind_prologue.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/loongarch/kernel/stacktrace.c b/arch/loongarch/kernel/stacktrace.c index 92270f14db94..f623feb2129f 100644 --- a/arch/loongarch/kernel/stacktrace.c +++ b/arch/loongarch/kernel/stacktrace.c @@ -32,7 +32,7 @@ void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, } for (unwind_start(&state, task, regs); - !unwind_done(&state) && !unwind_error(&state); unwind_next_frame(&state)) { + !unwind_done(&state); unwind_next_frame(&state)) { addr = unwind_get_return_address(&state); if (!addr || !consume_entry(cookie, addr)) break; diff --git a/arch/loongarch/kernel/unwind.c b/arch/loongarch/kernel/unwind.c index ba324ba76fa1..a463d6961344 100644 --- a/arch/loongarch/kernel/unwind.c +++ b/arch/loongarch/kernel/unwind.c @@ -28,6 +28,5 @@ bool default_next_frame(struct unwind_state *state) } while (!get_stack_info(state->sp, state->task, info)); - state->error = true; return false; } diff --git a/arch/loongarch/kernel/unwind_prologue.c b/arch/loongarch/kernel/unwind_prologue.c index 55afc27320e1..929ae240280a 100644 --- a/arch/loongarch/kernel/unwind_prologue.c +++ b/arch/loongarch/kernel/unwind_prologue.c @@ -227,7 +227,7 @@ static bool next_frame(struct unwind_state *state) } while (!get_stack_info(state->sp, state->task, info)); out: - state->error = true; + state->stack_info.type = STACK_TYPE_UNKNOWN; return false; } -- 2.42.0