Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp976149lqb; Wed, 29 May 2024 17:17:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCULJz9h8cnwW74XjZQ7osdUBK1hDMYQRxyO4HvL0xuX3plcg4u5xB8N7RME47g+5Rr0iZ201unZHHm9WPEJobgnQ90ACwaHfwJ3ReANQw== X-Google-Smtp-Source: AGHT+IG5/mWx0caSAYeepaPlmV7D5Cbgj9YC5THNY4QWMWolkwUBEvNu1HoCXUqfVeaJuEb1Elh5 X-Received: by 2002:a17:902:dac3:b0:1f5:e635:21fc with SMTP id d9443c01a7336-1f6193fb19cmr6673985ad.21.1717028263776; Wed, 29 May 2024 17:17:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717028263; cv=pass; d=google.com; s=arc-20160816; b=Z2efqyg/QXZdQiDEKYt7zxL/vbsiSjbTjaOoLuBTKxMtqXJ3JcA6Am+JeqIP0jQthk SDLm41WTc1co/wPM3zu7H3LdIvieO3QMI7OvMDA2i4KARyeX0jpIRPRNFFU1LVpGmcCp AlcBPdJ1tot0IMWYS6trc5CZiTg6Tu9WuWugd6xp+2EShuYo+zREvXzhb98xUxOZQiBc ZGBFF1ka85K/q9KNGRun0gOBjSkMx9JzmPoo+fbG8Ovjh9PS1U9yBsXFSjDVbSBnQGPh w7G3TXZzTomNEojRK++wf5fAhzkKbEbMiZCLw5n8M0PIRxf2fvu/EUliwMODe8LVJw+q 9RkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=CfeW8EqYXxaySwYF/8C+JSagNvnC45TM4Hz+nm+CSRI=; fh=gNUYiv73h6u5ZmRlF2RuFX9gm9dJ5pn6p0K0pPeVQbM=; b=0ndThZFCIl8MNlvipQX0b+HY3TEKZdHFIyme+DVE8lA/2yO0mC1I4jS6asjhSzEVVP ExU2hEehsPUa8EV8kg7pCt4oGeWPVBSTGQjOMyweGt9xmvNXcOo9VEC4R81dnFpKXxT7 dhG2zKvsCnNrV+KD6uZNvykxuj0zkbDekvQMyAj+jA8e/u6nCgacXXDyhAqZkFhESIc6 pxxzA59xojuZ0PW3SqljkEpfRjvVwpb8qRztm9tXGaxmHB2e/y8eFziJNp1nbxDrV5OX 7sMOH1A49A15EY87smL+GKYot20FpTx3PQt86Bytg12V+ZZHSUwmCFfGWnRdmrUtTKLA fyHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=kPCTzTiW; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-194796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c785d02si106466025ad.117.2024.05.29.17.17.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 17:17:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=kPCTzTiW; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-194796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 59BD3284995 for ; Thu, 30 May 2024 00:17:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 461A2441F; Thu, 30 May 2024 00:17:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="kPCTzTiW" Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (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 CECAB36B for ; Thu, 30 May 2024 00:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717028257; cv=none; b=lnFuiloTlRqNoaKU/e2pga8Y9Qbs/vS4wvABshFEeLdQuzjl6/VDAjVm477hJQEt1iJ/E07RTUyfPkHMWD5N+TTfpBth/iZjGMeAwIvivTOAQW9yXAjJ11yYOFMxG/JysMBY9PdELtJ2QLKVEmcknjvQWwlZ+rVO9dEmzFAOpTw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717028257; c=relaxed/simple; bh=N0smt2++7ScOhXPh6M+r1d4lJInmP2zBUg5+ve1Db4g=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CTpz2Hht+zgMWzhmIWT0prv8kzKKbvuLDRawnnC20FHthlcojsvL8cAhiEyEbhFDK1nU9A8xvDJmWcT/QXO5c9wXeYNr0/LRFd0kkIsKaT8SD3vXU1Ntcb1jDf0CZX5FSLjS0BTlt5muutMYiyjqm2S3cWUwsWu3YB24d4nbcW0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=kPCTzTiW; arc=none smtp.client-ip=209.85.215.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-6570bd6c3d7so220526a12.0 for ; Wed, 29 May 2024 17:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1717028255; x=1717633055; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=CfeW8EqYXxaySwYF/8C+JSagNvnC45TM4Hz+nm+CSRI=; b=kPCTzTiWknIFzJS4uThEwxGxwQeyRR16VqvjS9RaggepPk/v5aAg7ePEFH0jYnDHzS lUbWg0nX30ULRmh4lwQvbLWDU3LIJtidi3v1JM5kCXqOa2CrmzuAX6Pnu0rsybHBiZ7P uxgtaLfo95dA8MCwFudmpLcQ/pKb+cMEdEseuq7/rOAk9tImwJaC7x95gtEcaYQiDXLV ks/EwVRSMzpfnwjhaGMbfipG7SwLQ8eodF8Q7DobvSfdRJddUbzgGxG004dRODTI0u+Z TBfTYsq7BbtaOR6zwgoxGxa2fJb/yWPcvEuQC0XN0JoBO9xBvnTGa3/xhUSDgydluV5i tYDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717028255; x=1717633055; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CfeW8EqYXxaySwYF/8C+JSagNvnC45TM4Hz+nm+CSRI=; b=AwHT5SQ7G7e8A6uRL6uOsUWEBCMZFPWdqmeztj6/4e75cWiiav1pXBFM2ePTNFBbbo PupTf4s4IosW70qO+S3AoQ2ycUJZLMd9VcZp9zWf/h84r+qy1SDPw5QNjuiowstg0kFv LR7faqrFuhVPiiiqzyk5AGv0VxkLXo/Xu7nyn9cZablIKDDrX71+wu1nJtE2KhT7b4+n bxj3UibdZPb9D2wPVk6CZ3wQzxwQIlWoqY05Ep72c/mxu+PAZ/SlV31nhOJGgwibNZ4X uA2G6KPZrTC8R+JyeWwsEnKFq3DlQIhJDmSiYUVrQXkuKYyaXJrsoZdr898vBM4oB0Us Nayg== X-Gm-Message-State: AOJu0YxUqMEFmnkU37obtEiYN+d0ZZB897yR2wtv2gKnIQGAHQN1N4oQ juuFu27CYIxbpdP7DXNtRpJt2I6UVTV4781EyGr8uaXfI6EXGnldsiMqW2j4Qog= X-Received: by 2002:a17:90b:3709:b0:2c0:29d5:3515 with SMTP id 98e67ed59e1d1-2c1abc12514mr663413a91.3.1717028254983; Wed, 29 May 2024 17:17:34 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c1a776e206sm432171a91.20.2024.05.29.17.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 17:17:34 -0700 (PDT) From: Samuel Holland To: Palmer Dabbelt Cc: linux-kernel@vger.kernel.org, Andy Chiu , linux-riscv@lists.infradead.org, Matthew Bystrin , Sami Tolvanen , Samuel Holland Subject: [PATCH 0/4] riscv: Frame pointer fixes and enhancements Date: Wed, 29 May 2024 17:15:55 -0700 Message-ID: <20240530001733.1407654-1-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This series improves frame pointer support in the RISC-V kernel. Patch 1 fixes a bug in 32-bit kernels. Patch 2 prepares for patch 3, which fixes several places where the kernel clobbers the frame pointer. Patch 4 saves a frame record in the exception entry assembly so the kernel can unwind past exceptions. Here's an example of what the result looks like: [ 150.315343] sysrq: Show backtrace of all active CPUs [ 150.319827] sysrq: CPU0: [ 150.322063] Call Trace: [ 150.324684] [] show_stack+0x2c/0x38 [ 150.329757] [] sysrq_handle_showallcpus+0x78/0xbc [ 150.336014] [] __handle_sysrq+0x152/0x15e [ 150.341601] [] write_sysrq_trigger+0xa4/0xba [ 150.347221] [] proc_reg_write+0x3e/0x80 [ 150.352787] [] vfs_write+0xd8/0x302 [ 150.357625] [] ksys_write+0x58/0xaa [ 150.362856] [] __riscv_sys_write+0x16/0x1e [ 150.368317] [] syscall_handler+0x1c/0x28 [ 150.373986] [] do_trap_ecall_u+0x64/0xb0 [ 150.379431] [] ret_from_exception+0x0/0x70 [ 150.385207] sysrq: CPU1: backtrace skipped as idling [ 150.385210] sysrq: CPU2: backtrace skipped as idling [ 150.385213] sysrq: CPU3: [ 150.397294] Call Trace: [ 150.399717] [] show_stack+0x2c/0x38 [ 150.404756] [] showacpu+0x56/0x84 [ 150.409620] [] __flush_smp_call_function_queue+0x13a/0x1d2 [ 150.416657] [] generic_smp_call_function_single_interrupt+0xe/0x16 [ 150.424390] [] handle_IPI+0x38/0x74 [ 150.429424] [] handle_percpu_devid_irq+0x82/0x106 [ 150.435678] [] generic_handle_domain_irq+0x1c/0x2a [ 150.442019] [] ipi_mux_process+0x6e/0xd6 [ 150.447490] [] sbi_ipi_handle+0x30/0x46 [ 150.452876] [] generic_handle_domain_irq+0x1c/0x2a [ 150.459217] [] riscv_intc_irq+0x22/0x60 [ 150.464602] [] handle_riscv_irq+0x30/0x4e [ 150.470161] [] do_irq+0x1a/0x30 [ 150.474851] [] ret_from_exception+0x0/0x70 [ 150.480497] [] __percpu_counter_sum+0xbe/0xd0 [ 150.486403] [] __percpu_counter_sum+0xbe/0xd0 [ 150.492310] [] __mmdrop+0xc8/0x208 [ 150.497260] [] finish_task_switch+0x120/0x198 [ 150.503167] [] __schedule+0x444/0x6c8 [ 150.508378] [] preempt_schedule_common+0x18/0x32 [ 150.514546] [] preempt_schedule+0x22/0x24 [ 150.520105] [] sysrq_handle_showallcpus+0xba/0xbc [ 150.526359] [] __handle_sysrq+0x152/0x15e [ 150.531917] [] write_sysrq_trigger+0xa4/0xba [ 150.537737] [] proc_reg_write+0x3e/0x80 [ 150.543122] [] vfs_write+0xd8/0x302 [ 150.548160] [] ksys_write+0x58/0xaa [ 150.553197] [] __riscv_sys_write+0x16/0x1e [ 150.558847] [] syscall_handler+0x1c/0x28 [ 150.564316] [] do_trap_ecall_u+0x64/0xb0 [ 150.569788] [] ret_from_exception+0x0/0x70 Samuel Holland (4): riscv: Fix 32-bit call_on_irq_stack() frame pointer ABI riscv: entry: Balance vector context nesting riscv: entry: Do not clobber the frame pointer riscv: entry: Save a frame record for exceptions arch/riscv/include/asm/processor.h | 9 ++++- arch/riscv/include/asm/ptrace.h | 5 +++ arch/riscv/include/asm/stacktrace.h | 5 --- arch/riscv/kernel/asm-offsets.c | 10 ++--- arch/riscv/kernel/entry.S | 60 +++++++++++++++-------------- arch/riscv/kernel/head.S | 6 +-- arch/riscv/kernel/process.c | 5 +-- arch/riscv/kernel/stacktrace.c | 9 ----- 8 files changed, 53 insertions(+), 56 deletions(-) -- 2.44.1