From nobody Wed Apr 15 04:18:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C540AC19F21 for ; Wed, 27 Jul 2022 03:18:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240289AbiG0DSC (ORCPT ); Tue, 26 Jul 2022 23:18:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240237AbiG0DR4 (ORCPT ); Tue, 26 Jul 2022 23:17:56 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3457DF95; Tue, 26 Jul 2022 20:17:54 -0700 (PDT) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LszSg5p93zmVB0; Wed, 27 Jul 2022 11:16:03 +0800 (CST) Received: from dggpemm500013.china.huawei.com (7.185.36.172) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 11:17:53 +0800 Received: from ubuntu1804.huawei.com (10.67.175.36) by dggpemm500013.china.huawei.com (7.185.36.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 27 Jul 2022 11:17:52 +0800 From: Chen Zhongjin To: , , CC: , , , , , , , , Subject: [PATCH] Revert "x86/unwind/orc: Don't skip the first frame for inactive tasks" Date: Wed, 27 Jul 2022 11:15:06 +0800 Message-ID: <20220727031506.59322-1-chenzhongjin@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.175.36] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500013.china.huawei.com (7.185.36.172) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This reverts commit f1d9a2abff66aa8156fbc1493abed468db63ea48. When CONFIG_GCOV_PROFILE_ALL is enabled, show_stack() and related functions (e.g. dump_stack) will break for x86 ORC unwinder. Call Trace: ? dump_stack_lvl+0x83/0xb7 ? schedule+0x1/0x190 ? dump_stack+0x13/0x1f ? handler_pre0+0x3f/0x53 [kp_unwind] ... show_trace_log_lvl() searches text address on stack to validate whether unwind results are reliable. The code: for (; stack < stack_info.end; stack++) { ... if (stack =3D=3D ret_addr_p) reliable =3D 1; ... if (!reliable) continue; ... } This requires: *stack* <=3D ret_addr_p So that the first ret_addr_p can be found when stack++. In normal cases the frame of show_stack() should be optimized out. However if it is not optimized such as CONFIG_GCOV_PROFILE_ALL=3Dy, unwind_start() will stop at show_stack(), where: state->sp =3D=3D first_frame =3D=3D *stack* And this will causes: ret_addr_p =3D unwind_get_return_address_ptr =3D state->sp - 1 =3D> *stack* > ret_addr_p Then reliable check will ignore all unwind because first ret_addr_p can't be found. 'f1d9a2abff66 ("x86/unwind/orc: Don't skip the first frame for inactive tas= ks")' This patch removed the equal condition when state->sp =3D=3D first_frame which makes frame of show_stack() not be skipped. But the reason to do that is not established now: 'f2ac57a4c49d ("x86/unwind/orc: Fix inactive tasks with stack pointer in %s= p on GCC 10 compiled kernels")' state->sp =3D first_frame + sizeof(*frame), state->sp and first_frame can't be equal for inactive stack any more. Regard this equal condition doesn't involve other cases now, revert it to fix above problem. After revert, stack can be printed right: Call Trace: dump_stack_lvl+0x83/0xb7 ? schedule+0x1/0x190 dump_stack+0x13/0x1f handler_pre0+0x3f/0x53 [kp_unwind] ... Fixes: f1d9a2abff66 ("x86/unwind/orc: Don't skip the first frame for inacti= ve tasks") Signed-off-by: Chen Zhongjin --- arch/x86/kernel/unwind_orc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c index 38185aedf7d1..514dc9ef99fe 100644 --- a/arch/x86/kernel/unwind_orc.c +++ b/arch/x86/kernel/unwind_orc.c @@ -708,7 +708,7 @@ void __unwind_start(struct unwind_state *state, struct = task_struct *task, /* Otherwise, skip ahead to the user-specified starting frame: */ while (!unwind_done(state) && (!on_stack(&state->stack_info, first_frame, sizeof(long)) || - state->sp < (unsigned long)first_frame)) + state->sp <=3D (unsigned long)first_frame)) unwind_next_frame(state); =20 return; --=20 2.17.1