Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp502105imn; Tue, 26 Jul 2022 01:28:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vTmylzEY08MI8VjdCuf2ZEhv3K6Ec4rLXE5fq7NwnRvSjTJV5I1hIJg8eQ5WcVCd6L4hNi X-Received: by 2002:a17:902:a710:b0:16c:5305:2244 with SMTP id w16-20020a170902a71000b0016c53052244mr16294514plq.125.1658824132115; Tue, 26 Jul 2022 01:28:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658824132; cv=none; d=google.com; s=arc-20160816; b=UnTYM2ms2DZXxi5yen/D7mQ3WXuQtYMzObx6jRsIU/tQwAEAXcItSFmH6iHa7ASzIO CSSaYeCszdSqyOQYj+Lp7ezzNq5PFXA30AZ3zXD18ohPKGlHPzPbSPP3Frwcmdrp/tr4 i6Dnx4LMIMXSK1Su8PIm5Xll5gE+aScQkH1jHj82zMiFhksZKs0mVG9KVTN14MteGcZT o8bNb48vFFl3jCxjmPQVkfwfSD2aEmL8rNKNCM0Q4yZPXne65Pu6zD7p+Z34RF9dTJQq KSuIKtcvh7lsRFO0FYg9T5FKYoW0Gm2OZ/d/CVRQHs/q9tAmg4qLrAFpmtaBKHH0Zxgr 01Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=8aHVqpauS6CR+8HsL3CrsSQ3ANvZKwTfg7EIqyEjeJQ=; b=PPDLStMvJ9gDjIf6YXWfI2oSs6imm89Aw3IZ/s8d4ysD4mYr8DOsXun73fNtGRSRVF 9gjHkU95WTln/rtDvkFvgublgf8nhSIA/Co6doJ0XIaEb6y0C+jyjgVCRjJkQ0Hg+wXD QIS/ysLtcRCI1mtuzPbmHWZpDt1BeIvqy626GAoIJybsVcWmSwYv4EnVhdMpGRNbwcW1 KDJR9JbQ5tNxpwoBdJhewcWbhy+amYB1XNq0bQr1Tboy/1vLo/OOSeC09KqYc85Wjw7U QHxej7EYIdZqWH5Vu11mgEC1NfZoMH130I6K6fOWie7BcT9QL2rnRbwlryskD5IjSARt wm8Q== 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 b6-20020a170902e94600b0016a50167a61si16581504pll.282.2022.07.26.01.28.35; Tue, 26 Jul 2022 01:28:52 -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 S231974AbiGZIKj (ORCPT + 99 others); Tue, 26 Jul 2022 04:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237981AbiGZIKf (ORCPT ); Tue, 26 Jul 2022 04:10:35 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A52BB1DF; Tue, 26 Jul 2022 01:10:33 -0700 (PDT) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LsTzZ6Nv9zjWxv; Tue, 26 Jul 2022 16:07:38 +0800 (CST) Received: from kwepemm600010.china.huawei.com (7.193.23.86) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 26 Jul 2022 16:10:27 +0800 Received: from [10.67.110.237] (10.67.110.237) by kwepemm600010.china.huawei.com (7.193.23.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 26 Jul 2022 16:10:25 +0800 Subject: Re: [PATCH 1/5] ARM: stacktrace: Skip frame pointer boundary check for call_with_stack() To: Linus Walleij CC: , , , , , , , , , , , , , , , , , , , , , , , Li Huafei References: <20220712021527.109921-1-lihuafei1@huawei.com> <20220712021527.109921-2-lihuafei1@huawei.com> From: Li Huafei Message-ID: Date: Tue, 26 Jul 2022 16:10:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.67.110.237] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600010.china.huawei.com (7.193.23.86) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 Hi Linus, sorry for the late reply. On 2022/7/18 16:57, Linus Walleij wrote: > On Tue, Jul 12, 2022 at 4:18 AM Li Huafei wrote: > >> When using the frame pointer unwinder, it was found that the stack trace >> output of stack_trace_save() is incomplete if the stack contains >> call_with_stack(): >> >> [0x7f00002c] dump_stack_task+0x2c/0x90 [hrtimer] >> [0x7f0000a0] hrtimer_hander+0x10/0x18 [hrtimer] >> [0x801a67f0] __hrtimer_run_queues+0x1b0/0x3b4 >> [0x801a7350] hrtimer_run_queues+0xc4/0xd8 >> [0x801a597c] update_process_times+0x3c/0x88 >> [0x801b5a98] tick_periodic+0x50/0xd8 >> [0x801b5bf4] tick_handle_periodic+0x24/0x84 >> [0x8010ffc4] twd_handler+0x38/0x48 >> [0x8017d220] handle_percpu_devid_irq+0xa8/0x244 >> [0x80176e9c] generic_handle_domain_irq+0x2c/0x3c >> [0x8052e3a8] gic_handle_irq+0x7c/0x90 >> [0x808ab15c] generic_handle_arch_irq+0x60/0x80 >> [0x8051191c] call_with_stack+0x1c/0x20 >> >> For the frame pointer unwinder, unwind_frame() checks stackframe::fp by >> stackframe::sp. Since call_with_stack() switches the SP from one stack >> to another, stackframe::fp and stackframe: :sp will point to different >> stacks, so we can no longer check stackframe::fp by stackframe::sp. Skip >> checking stackframe::fp at this point to avoid this problem. >> >> Signed-off-by: Li Huafei > Very nice catch! Took me some time to realize what was > going on here. Yeah, it took me some time to discover the cause of the problem too. > > Reviewed-by: Linus Walleij Thanks! > > Nitpick below: > >> + /* >> + * call_with_stack() is the only place we allow SP to jump from one >> + * stack to another, with FP and SP pointing to different stacks, >> + * skipping the FP boundary check at this point. >> + */ >> + if (pc >= (unsigned long)&call_with_stack && >> + pc < (unsigned long)&call_with_stack_end) >> + return 0; > Can we create a local helper macro to do this, if it needs to happen > some other time? Hopefully this won't come up again.:( Maybe it would be better to define a macro when this happens? Thanks, Huafei > > #define ARM_PC_IN_FUNCTION(pc, func) (pc >=. ...) > > Yours, > Linus Walleij > .