From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23DD13A6B7C for ; Tue, 21 Apr 2026 22:52:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776811939; cv=none; b=TZXWkSD4qxAO3/OF+83b8821wcs9ukoUVl71vXBTO+n6zdgBTAZ8w1G82QlH3caJhPeS34MH7xqhTNekRnufjuUq/jfg/SZqg18BecPX4jNUMu3TOidpwZZrz702iOid8sL9rmae+tduFFyDJz/QbB4ENCupIM7W3CcEjb20ZHE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776811939; c=relaxed/simple; bh=udffv3jNsveJNyWjHMP0HSXsJ23lIpfFHViHlEMIDZw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dy0TGnRBSuyXFPHfqcpoNljb7NgD5dz4geWPCq6+mTW+Nwn3tqXupkJM3KrvzSf13q15xl3b6ag4eLHX1FH8UbSR3ElkKcRgi1LIT7gUbLHi2Bwh8xgS8k6OwtKK0moSUPm5RrvmdYIU8/ZU53ku7/fClFXHgdnswAPZM2sOUoQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dylanbhatch.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=cxYHOJ4G; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dylanbhatch.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cxYHOJ4G" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-358e425c261so5623230a91.3 for ; Tue, 21 Apr 2026 15:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776811936; x=1777416736; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=zNlZDyegmOFELN70B6bCpVLxtkFdBX1CWXSw170KDZw=; b=cxYHOJ4GQCzreXIoW6ThkcALOWw/RI0kOF1PrS/i5Uw8PUytIb1G2tBKEgNtZY31jx txGw1RywitrFtM7laUfnIUdeUzTswHBSPKjvUE+7da0uP+7qN7f8yMhqcM/oyZqmXy0K panydf9zqInBnlHgvWWSdQx2Ki9YdfhAmc9KeINastyt7SMKz29Hz1MU37kco5RnLloN 8Zn+gpzL00cGjisWqA4LZ6YIKLN38FHaWPSae5Qav5SZHkrfoRQAAluZV3Z+3dCityEs qSwyrch1bjFWUyh91BIKzuRREhlwOiFrNhKjglAUgk2X98MGx1jbe97XjsYaC9dyTLM1 rGeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776811936; x=1777416736; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zNlZDyegmOFELN70B6bCpVLxtkFdBX1CWXSw170KDZw=; b=PCsGMf3YfaVT64VSrs2TWqR+MWI9wuze7sr8nJF3H03NQ9JnEX92reBK1vGU0opJLH ieusW28ra7iiQXOflrrYMV+TNq8IV1u4/29awq/lUs29lr6Hwmel6RD3bTYp938icShl lrMLIMCeH8wq2SbIKDngTVB6byumQgIlSHmpNp0ShU1D4dmoWoyS8hHJ7d0tO/bRxWcY FWuvpsB0aEqh9tYbdXdg2IpZllIeGwnbFRUBwLsQN6EwTPJ99DrVcGYw6/2pdN7bnd1q 5f+22QBqQ45824MxU6WVIrlnd4kCzVhKkm5m+BnKptH6XCGNfDVwfa5Ve7kXvVzefaIv liVQ== X-Forwarded-Encrypted: i=1; AFNElJ8cTBo1AMO8z5C5Dd1cDvuY6xtFcw1DPOauEIltRIuK7wpm23qllVpmGPy0G+GusosW7P9wm5v7pZo14p5efVt9@vger.kernel.org X-Gm-Message-State: AOJu0YwzC4ZJK44zENCtjdD897jfoyqpn4ArEgSFBYGjhvKzoOjHcZHw tZIwvmLKqiE4WDHW0yLwj6AcrV1/mMnbj/vl7hxeksuRTtZ6m7s8agBQfoKUBncqfmxYi8iP9td lfx5Uv/BOxPeE1QX8p94+YLJFHg== X-Received: from pjrx9.prod.google.com ([2002:a17:90a:bc89:b0:35d:9dbb:bda8]) (user=dylanbhatch job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3811:b0:35f:c729:de9f with SMTP id 98e67ed59e1d1-361404c2053mr20137572a91.27.1776811936241; Tue, 21 Apr 2026 15:52:16 -0700 (PDT) Date: Tue, 21 Apr 2026 22:51:55 +0000 In-Reply-To: <20260421225200.1198447-1-dylanbhatch@google.com> Precedence: bulk X-Mailing-List: linux-toolchains@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260421225200.1198447-1-dylanbhatch@google.com> X-Mailer: git-send-email 2.54.0.rc1.555.g9c883467ad-goog Message-ID: <20260421225200.1198447-4-dylanbhatch@google.com> Subject: [PATCH v4 3/8] arm64: entry: add unwind info for various kernel entries From: Dylan Hatch To: Roman Gushchin , Weinan Liu , Will Deacon , Josh Poimboeuf , Indu Bhagat , Peter Zijlstra , Steven Rostedt , Catalin Marinas , Jiri Kosina , Jens Remus Cc: Dylan Hatch , Mark Rutland , Prasanna Kumar T S M , Puranjay Mohan , Song Liu , joe.lawrence@redhat.com, linux-toolchains@vger.kernel.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Randy Dunlap Content-Type: text/plain; charset="UTF-8" From: Weinan Liu DWARF CFI (Call Frame Information) specifies how to recover the return address and callee-saved registers at each PC in a given function. Compilers are able to generate the CFI annotations when they compile the code to assembly language. For handcrafted assembly, we need to annotate them by hand. Annotate minimal CFI to enable stacktracing using SFrame for kernel exception entries through el1*_64_*() paths and irq entries through call_on_irq_stack() Signed-off-by: Weinan Liu Signed-off-by: Dylan Hatch Suggested-by: Jens Remus --- arch/arm64/kernel/entry.S | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index f8018b5c1f9a..dc55b0b19cfa 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -30,6 +30,12 @@ #include #include +/* + * Do not generate .eh_frame. Only generate .debug_frame and optionally + * .sframe (via assembler option --gsframe[-N]). + */ + .cfi_sections .debug_frame + .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 mov x\n, xzr @@ -575,7 +581,16 @@ SYM_CODE_START_LOCAL(el\el\ht\()_\regsize\()_\label) .if \el == 0 b ret_to_user .else + /* + * Minimal DWARF CFI for unwinding across the call above. + * Enable unwinding for el1*_64_*() path only. + */ + .cfi_startproc + .cfi_def_cfa_offset PT_REGS_SIZE + .cfi_offset 29, S_FP - PT_REGS_SIZE + .cfi_offset 30, S_LR - PT_REGS_SIZE b ret_to_kernel + .cfi_endproc .endif SYM_CODE_END(el\el\ht\()_\regsize\()_\label) .endm @@ -872,6 +887,7 @@ NOKPROBE(ret_from_fork) * Calls func(regs) using this CPU's irq stack and shadow irq stack. */ SYM_FUNC_START(call_on_irq_stack) + .cfi_startproc save_and_disable_daif x9 #ifdef CONFIG_SHADOW_CALL_STACK get_current_task x16 @@ -882,6 +898,9 @@ SYM_FUNC_START(call_on_irq_stack) /* Create a frame record to save our LR and SP (implicit in FP) */ stp x29, x30, [sp, #-16]! mov x29, sp + .cfi_def_cfa 29, 16 + .cfi_offset 29, -16 + .cfi_offset 30, -8 ldr_this_cpu x16, irq_stack_ptr, x17 @@ -897,9 +916,13 @@ SYM_FUNC_START(call_on_irq_stack) */ mov sp, x29 ldp x29, x30, [sp], #16 + .cfi_restore 29 + .cfi_restore 30 + .cfi_def_cfa 31, 0 scs_load_current restore_irq x9 ret + .cfi_endproc SYM_FUNC_END(call_on_irq_stack) NOKPROBE(call_on_irq_stack) -- 2.54.0.rc1.555.g9c883467ad-goog