From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BEDA0C433EF for ; Tue, 24 May 2022 00:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PuqOH1phtEccheWpsJAEvXnLbmjpwOEtsdk872M6cYk=; b=wXX39Ml/9FySeZ zV63FZFT0OX+C3vmauJbktha3zTiy4Bwy5MFsqhoGe09tXIVeECBlld2F3ST49jRi2XZMV0iJNjxV Ns5fH0c0pGcX2YMptfCb4wmN3u79LXYK49VxxjACAZxPyHSlKPS9UMoFjIpgn8dGQ40qXt9H+e0bP z90aIJKcnkvGGBfC+2idIXi53donkTNGTdWMXVgB81vhnL0JeOHOmH3Loc3aLaMp0Lyj4xEhP6Qvf yQ17DhGZ0Fwc4kmWJCLOtcUwqRjcIb6ebqgp34QWYjytQPTo3E5M3Ng50rMIqk6s1ImDcqB1PW1mw vXG2YtKpKl6AjtEgqwng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ntIIz-006LXe-2C; Tue, 24 May 2022 00:21:45 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ntIEQ-006JUg-Iq for linux-arm-kernel@lists.infradead.org; Tue, 24 May 2022 00:17:09 +0000 Received: from x64host.home (unknown [47.189.24.195]) by linux.microsoft.com (Postfix) with ESMTPSA id 8504120B6C7C; Mon, 23 May 2022 17:17:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8504120B6C7C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1653351422; bh=i38XBmt03Yj6P5EVI/Y5EXfzyY4okm3GZVL0Cbb4zHY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sfxAzXRMl11Qrr1SKOR9ea5oIJHGiWhdgsHqPPqFKf4ahKkqKBeISs0qQ+OmR29h8 AZvThfbgfBLg44ZxabgwLCB02mOch/EQ906C5w3Hx97du/aAmRSz0kLoAXT96QHk/Z EanZbUxltHcUVXXSzqnCJ7aQSRevWF4q56vT0qJ4= From: madvenka@linux.microsoft.com To: jpoimboe@redhat.com, peterz@infradead.org, chenzhongjin@huawei.com, mark.rutland@arm.com, broonie@kernel.org, nobuta.keiya@fujitsu.com, sjitindarsingh@gmail.com, catalin.marinas@arm.com, will@kernel.org, jamorris@linux.microsoft.com, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, madvenka@linux.microsoft.com Subject: [RFC PATCH v2 15/20] arm64: Add unwind hints to specific points in code Date: Mon, 23 May 2022 19:16:32 -0500 Message-Id: <20220524001637.1707472-16-madvenka@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220524001637.1707472-1-madvenka@linux.microsoft.com> References: <20220524001637.1707472-1-madvenka@linux.microsoft.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220523_171702_781045_4AE9F675 X-CRM114-Status: GOOD ( 12.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: "Madhavan T. Venkataraman" Add unwind hints to the following: - Ftrace entry code - Interrupt and Exception handlers - Kretprobe trampoline Signed-off-by: Madhavan T. Venkataraman --- arch/arm64/kernel/entry-ftrace.S | 23 +++++++++++++++++++ arch/arm64/kernel/entry.S | 3 +++ arch/arm64/kernel/probes/kprobes_trampoline.S | 3 +++ 3 files changed, 29 insertions(+) diff --git a/arch/arm64/kernel/entry-ftrace.S b/arch/arm64/kernel/entry-ftrace.S index e535480a4069..6d68833e8cec 100644 --- a/arch/arm64/kernel/entry-ftrace.S +++ b/arch/arm64/kernel/entry-ftrace.S @@ -11,6 +11,7 @@ #include #include #include +#include #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS /* @@ -95,7 +96,14 @@ SYM_CODE_START(ftrace_common) mov x3, sp // regs SYM_INNER_LABEL(ftrace_call, SYM_L_GLOBAL) + /* + * Tracer functions are patched at ftrace_stub. Stack traces + * taken from tracer functions will end up here. Place an + * unwind hint based on the stackframe setup in ftrace_regs_entry. + */ bl ftrace_stub +SYM_INNER_LABEL(ftrace_call_entry, SYM_L_GLOBAL) + UNWIND_HINT_REGS PT_REGS_SIZE #ifdef CONFIG_FUNCTION_GRAPH_TRACER SYM_INNER_LABEL(ftrace_graph_call, SYM_L_GLOBAL) // ftrace_graph_caller(); @@ -134,10 +142,25 @@ SYM_CODE_START(ftrace_graph_caller) add x1, sp, #S_LR // parent_ip (callsite's LR) ldr x2, [sp, #PT_REGS_SIZE] // parent fp (callsite's FP) bl prepare_ftrace_return +SYM_INNER_LABEL(ftrace_graph_caller_entry, SYM_L_GLOBAL) + UNWIND_HINT_REGS PT_REGS_SIZE b ftrace_common_return SYM_CODE_END(ftrace_graph_caller) #endif +/* + * ftrace_regs_entry() sets up two stackframes - one for the callsite and + * one for the ftrace entry code. Unwind hints have been placed for the + * ftrace entry code above. We need an unwind hint for the callsite. Callsites + * are numerous. But the unwind hint required for all the callsites is the + * same. Define a dummy function here with the callsite unwind hint for the + * benefit of the unwinder. + */ +SYM_CODE_START(ftrace_callsite) + UNWIND_HINT_FTRACE 16 // for the callsite + ret +SYM_CODE_END(ftrace_callsite) + #else /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */ /* diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index ede028dee81b..95d5f3c08aa1 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -28,6 +28,7 @@ #include #include #include +#include .macro clear_gp_regs .irp n,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 @@ -560,6 +561,7 @@ SYM_CODE_START_LOCAL(el\el\ht\()_\regsize\()_\label) .if \el == 0 b ret_to_user .else + UNWIND_HINT_REGS PT_REGS_SIZE b ret_to_kernel .endif SYM_CODE_END(el\el\ht\()_\regsize\()_\label) @@ -894,6 +896,7 @@ SYM_FUNC_START(call_on_irq_stack) /* Move to the new stack and call the function there */ mov sp, x16 blr x1 + UNWIND_HINT_IRQ 16 /* * Restore the SP from the FP, and restore the FP and LR from the frame diff --git a/arch/arm64/kernel/probes/kprobes_trampoline.S b/arch/arm64/kernel/probes/kprobes_trampoline.S index 9a6499bed58b..847cbb81ca33 100644 --- a/arch/arm64/kernel/probes/kprobes_trampoline.S +++ b/arch/arm64/kernel/probes/kprobes_trampoline.S @@ -6,6 +6,7 @@ #include #include #include +#include .text @@ -71,6 +72,8 @@ SYM_CODE_START(__kretprobe_trampoline) mov x0, sp bl trampoline_probe_handler + UNWIND_HINT_REGS PT_REGS_SIZE + /* * Replace trampoline address in lr with actual orig_ret_addr return * address. -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel