Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1464883pxb; Sun, 12 Sep 2021 20:32:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynxUSmaATCKfAy03xN8n2u2rK+D4f/MZGxwiKPBRBrCF+ma0nKZpGJQs+xz1gfciYgEXxT X-Received: by 2002:a05:6638:2493:: with SMTP id x19mr7933409jat.57.1631503954260; Sun, 12 Sep 2021 20:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631503954; cv=none; d=google.com; s=arc-20160816; b=yY5wx7v7EgLGfVTzKm82J9dKx4jwxwgszYHf7bL6FdaGipyMP0fYgBvAQ4dyb1M0w5 WmntRp1GanaPKNRAA6mkkURE33LGQIKw3ygxLdnehbiZjMHX6Xaq6DPpd7FN1Q5kL9Eg 7oDt8YBZOAAq0HAzfPmio9B9RBllQmhyKrtE4BbJRcnB09qFCmSnmqKt0QIzxHG6Tx2q EF91gZ+LE5KZbtDedLrVxbu6dfnOo23d6xpmHoVGCugjm8sHnpOyURqYJMmzrAYtt6cN vGfrN8d44+sIIz9cq+PPWENwlHsZauieNXuwPQ5Nb0MucvT+l+V5KYlgh1xIzr3yeK9X z9nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:to :from:subject; bh=Ctc3h6KesxqktoWPWdKwh3ZUCIb8sLxRl14jHprinec=; b=AwSfeimKjv3O6nqZjF5Ti2oPazq8VYXdjtBq/Z3M5jLt2xtGmTUO0FBniTt/to8fa4 ztrHZrUt1jyeiA1BG6+JCKQKp+wcNoluYyOM0Q6WIR/FmKFBMIN33FFSXPPkjdIYvigu NdpKeE0zxBmMa1QQrqCJscK6WwkargAVMfQ22+JZjfToRYVUe/664A3w798PbcbZVDJe l0e6fpPjgzmSshCPt5AK33PM9A5ro+YY+WyMWT5JuEiZZSVdMSbS4b/F07AspEuab7gx zQT652bWGlRl+NhnvPiS/ZZrdsXC+FQFv/JX/DkHvnPXWRT/Ukme45dNMPTD6K5ch5iT MUyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b125si5948747jab.33.2021.09.12.20.32.23; Sun, 12 Sep 2021 20:32:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238551AbhIMDcN (ORCPT + 99 others); Sun, 12 Sep 2021 23:32:13 -0400 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:46771 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238149AbhIMDcM (ORCPT ); Sun, 12 Sep 2021 23:32:12 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=yun.wang@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0Uo74YxF_1631503852; Received: from testdeMacBook-Pro.local(mailfrom:yun.wang@linux.alibaba.com fp:SMTPD_---0Uo74YxF_1631503852) by smtp.aliyun-inc.com(127.0.0.1); Mon, 13 Sep 2021 11:30:53 +0800 Subject: [PATCH] perf: fix panic by disable ftrace on fault.c From: =?UTF-8?B?546L6LSH?= To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "open list:X86 MM" , "open list:BPF (Safe dynamic programs and tools)" , "open list:BPF (Safe dynamic programs and tools)" References: Message-ID: Date: Mon, 13 Sep 2021 11:30:52 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When running with ftrace function enabled, we observed panic as below: traps: PANIC: double fault, error_code: 0x0 [snip] RIP: 0010:perf_swevent_get_recursion_context+0x0/0x70 [snip] Call Trace: perf_trace_buf_alloc+0x26/0xd0 perf_ftrace_function_call+0x18f/0x2e0 kernelmode_fixup_or_oops+0x5/0x120 __bad_area_nosemaphore+0x1b8/0x280 do_user_addr_fault+0x410/0x920 exc_page_fault+0x92/0x300 asm_exc_page_fault+0x1e/0x30 RIP: 0010:__get_user_nocheck_8+0x6/0x13 perf_callchain_user+0x266/0x2f0 get_perf_callchain+0x194/0x210 perf_callchain+0xa3/0xc0 perf_prepare_sample+0xa5/0xa60 perf_event_output_forward+0x7b/0x1b0 __perf_event_overflow+0x67/0x120 perf_swevent_overflow+0xcb/0x110 perf_swevent_event+0xb0/0xf0 perf_tp_event+0x292/0x410 perf_trace_run_bpf_submit+0x87/0xc0 perf_trace_lock_acquire+0x12b/0x170 lock_acquire+0x1bf/0x2e0 perf_output_begin+0x70/0x4b0 perf_log_throttle+0xe2/0x1a0 perf_event_nmi_handler+0x30/0x50 nmi_handle+0xba/0x2a0 default_do_nmi+0x45/0xf0 exc_nmi+0x155/0x170 end_repeat_nmi+0x16/0x55 According to the trace we know the story is like this, the NMI triggered perf IRQ throttling and call perf_log_throttle(), which triggered the swevent overflow, and the overflow process do perf_callchain_user() which triggered a user PF, and the PF process triggered perf ftrace which finally lead into a suspected stack overflow. This patch disable ftrace on fault.c, which help to avoid the panic. Reported-by: Abaci Signed-off-by: Michael Wang --- arch/x86/mm/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile index 5864219..1dbdca5 100644 --- a/arch/x86/mm/Makefile +++ b/arch/x86/mm/Makefile @@ -1,5 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 # Kernel does not boot with instrumentation of tlb.c and mem_encrypt*.c + +# Disable ftrace to avoid stack overflow. +CFLAGS_REMOVE_fault.o = $(CC_FLAGS_FTRACE) + KCOV_INSTRUMENT_tlb.o := n KCOV_INSTRUMENT_mem_encrypt.o := n KCOV_INSTRUMENT_mem_encrypt_identity.o := n -- 1.8.3.1