Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp10746imn; Tue, 26 Jul 2022 20:19:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uVOMgVUCNy0YGPbM8CnFEHg24fAfm/veo97ErlvKNRlTPuCwXQ50d4EL6Dqopjab38NId5 X-Received: by 2002:a17:902:728c:b0:16d:9fcc:aaed with SMTP id d12-20020a170902728c00b0016d9fccaaedmr4916056pll.117.1658891962650; Tue, 26 Jul 2022 20:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658891962; cv=none; d=google.com; s=arc-20160816; b=zZywhcDnAR2/87LKXmpy1RcFOmkN2TbssublTAfOEd7Htmai7fSKOC8k1ensjpvm9V BZM2SjHwv0kh3cjhdFDvZVnLKtxOK0u99sZSF01YbGwfFZ1Wu7tZY2jQ6l+5tA+ppfdt PgXSM5fX6HNwSI2wOu+EFUtV4B+DHwxz11VErz2u3I8EeZJjYp/zxgCoWoAn04fEQAZy 5XipZjFFK3Y2uOkvoPJceAfRHNH8hZqx0P8059YPj1JC+16LopjZRTlxZCBiw+8I2X8q tf1odu44K0tZcOnFg83U0D/6P/RlJFJb4CQU7dQe9NugeeoQuiMQ+IkA1YQPayZwZdta Mj3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=615fQfX5O7ME5cH0kkKpFAZ9/FeHkfQ4L78tnnLDZvU=; b=ZfCNIAaW8KjWJ5imAmgBI0KiMYCGsFno0PWf6hrpmV/0B7KjXL+MPoEFenIkmVGONe T8W0exEYJriFbrwAtDw9zIOxM2BLzELsBhTNajqaYkkr9M2ATHqo0DjkAM+A+Yx2JToQ RxShCRdUQaYahNY8Bir2MF8BhwJEl7DzNifxGVVvPII1/4bnCx83OS0JMGYgNP/8No/G 6nEz8+9DDSrZY1KonURJ5M+Xb5ksG/0aVQLvlb7fV+CkCt5qz5jTJClLvosQP+wLHZUn VGQNop0e5GZZ2W9ONH14KTSrULF9Ec4NtYT99Spuqwa/4wpydmX60koajX7TDcBlzfsF u27g== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a63b744000000b00411cbe3fbe6si21636091pgt.815.2022.07.26.20.19.06; Tue, 26 Jul 2022 20:19:22 -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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240272AbiG0DR7 (ORCPT + 99 others); Tue, 26 Jul 2022 23:17:59 -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 Content-Type: text/plain 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 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 == ret_addr_p) reliable = 1; ... if (!reliable) continue; ... } This requires: *stack* <= 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=y, unwind_start() will stop at show_stack(), where: state->sp == first_frame == *stack* And this will causes: ret_addr_p = unwind_get_return_address_ptr = state->sp - 1 => *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 tasks")' This patch removed the equal condition when state->sp == 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 %sp on GCC 10 compiled kernels")' state->sp = 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 inactive 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 <= (unsigned long)first_frame)) unwind_next_frame(state); return; -- 2.17.1