Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp220074lqq; Thu, 13 Jun 2024 00:33:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXEqptl2wkT+ZyN9vvd5+r/787DB7ECGRxpWzWy/pR/KiW1pu5aYaDFzfZ177wARoj2CtJy6wg06dY0QBPu0ldGcmtt0LP32Kgk0c8ozw== X-Google-Smtp-Source: AGHT+IHPl/HuHDTv41PNBnALn7cYcdC5sI8N+MlmqzfFfE/vzv6YCpGH60bPdsC/dHTidXXRaZkH X-Received: by 2002:a05:620a:4451:b0:795:4e2c:eac4 with SMTP id af79cd13be357-798100f1f9dmr303279485a.9.1718263997109; Thu, 13 Jun 2024 00:33:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718263997; cv=pass; d=google.com; s=arc-20160816; b=Qodc/q7Qdjm6xdFIOrT5Rl84uLWFcQ0lN87CyjELdu2dr1gGdkSZqdHvSMhCh33+aw I+KczU3e1sTcwRCsPtjs2Kvzy923h1qY9Mm6cIIIMxvWZJ5LMttGIf0/89zEg4aez/oK +H+LgMV8Z+Y7vd4iuHFFhKopG51mV4Fq2aDnmxH6zEBTV6QoQ7EYRCrVlG/4kxlsQhN0 JZHA9tHkrbAm4XC4cKKw7l9Qii06R3zs8Lz9PjBh92hUuu/s80qRMgvLfjOUWuh1U99o ht+Myg2vBTWz36SyrhKxRIgvHKE6vfbfB7wUXL1PYHm0qrgm0R5Uh56mlAy369PijoG4 7Nxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=90j1lP2iehIU9E2euRd9xJoPIJsKCYmj2Va6/Ket5KI=; fh=HK3kAK9socxydxISJyIYcfq/8uO2iPvdod/+rUWGEjY=; b=R+n7OD3SRdSXTkFuBY0U79kjCduS+hTauSVrr7AcN9f7QGdUORoik7e/NtvCAXf/1J PcBmb9d120+2Ih9rdq0rerrzgLmGaHuhYa0bivHgJN8O/bnCSZXWpM+hIqHRPT8PwWFk yquSpbXqZkLubiO8DfAevG2+KLONb22RmLyv6J/56FTzTK4AYLo9NwjhuUn2h8qEGPsw zalpi5Tl7hA3isnEEJE9O1gxTRXm3Voi4ZZ5kqooiyhld8er3odrL/hMarmSmq+oqqBq m0akDFuvaXRK87AqtfnDX/mreJxDEx2O2NjtxbWQDJT4KEl0SoOynUCL/wubO9g3UxoD przw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=CDmnzgHr; 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-212710-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212710-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-798abd17126si77239785a.407.2024.06.13.00.33.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 00:33:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212710-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=CDmnzgHr; 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-212710-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212710-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CBE3B1C2314B for ; Thu, 13 Jun 2024 07:33:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2D7E13C3E2; Thu, 13 Jun 2024 07:32:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="CDmnzgHr" Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 7CC1E13C66A for ; Thu, 13 Jun 2024 07:32:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718263965; cv=none; b=gP/baM0R+0rsHaPb3q1yHiKxStGhw6bDGFej3DHnfcrXPhlmDP7tre9JbIPtVDlPfNbMIaudfuSs7ehvShKX9bY/iK6Vk4zgxp3ID/yZsJ1yz1Pxaoi0i7HVo/ZaklYYxUmWsLmAXihH6tra3W70DmniQ8svPo/KRm4EOjNwOYM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718263965; c=relaxed/simple; bh=JiXCsJYbgQAz9+R6zTWp/RApNEHB55TEiq7HnF4rVDs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dpDC8aPA/Kh75GSZ8ZPVzuA8yUxq3dAEpYIrGNzDS7D6mtWKaT7RCf11928Onsvo/vbHj6cvrcnIl3CRTQQQKGBZQqvZeo30On0kAkmPNXMMwK2Kc8rH6rp5Lp6IuBAPBvXzMi3MD7kjVNunlyT864Ax9JVuMliVDWMW6Wr46IM= 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=CDmnzgHr; arc=none smtp.client-ip=209.85.210.182 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-pf1-f182.google.com with SMTP id d2e1a72fcca58-6f4603237e0so519916b3a.0 for ; Thu, 13 Jun 2024 00:32:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1718263964; x=1718868764; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=90j1lP2iehIU9E2euRd9xJoPIJsKCYmj2Va6/Ket5KI=; b=CDmnzgHrN8I69+1iXs0n+uGJ4tABm3ifoX9XjxQPv/VsPfMX3e9qkxQ9tsrAoSfxvH 1gNjMvnoHWg7g2fpmNDSjf3PnS7G0jxLEVnDOpTe8/RIzFepnyNlyaLaTdHL9mOpyWRk 4x3wAJcrmpR/sI+mXb4HIp8xbD5Wdr9awdaGZJlkf24mSAvOPonAMggz5ceGrBNR0BYS xksIhxbkSZCUlU+4kl9dN+sXxBoRbEJkbR4tkP/NPvrQxXTNAHv1gCjZAB/IYG5c/EfH XHvKh1KtAUBzf4m8gIcC8rN2HMryp1hpNfSJeTOWiN9sL4KexLpwhAd4z/F/tTzuT0xq TrJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718263964; x=1718868764; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=90j1lP2iehIU9E2euRd9xJoPIJsKCYmj2Va6/Ket5KI=; b=rOwUlt+t0HftPHGJdXCtX4rxq2fsiOm1tvi5J8/bOFdKAOPlw1NQLKGbAz6ytQHbzv gB2WFLlrR+dCsYGGIAYE4w0sod7VHj6Muke1jOq/jJRl+YMkQbjX4JtA0wkf86XjdqkW Rh4vTwSaC5jGWjIiu3oh89vWQzuYM6Z5c22gF6GSTWt/80s3ulETyo6BtYuzYqHyF5pl n2uri6GE4OHJoeG5ND3met6aeIoc/WZ6pynCD43kA75OaDDrXiOE5PUlTEAqXIR65ZPp ldYgsL+C1tT0N5xA27Xw9JlnKpjl0H6816PpzAt1ZVpUaD4uKjZyHeTie7mE4r/kX8l8 hDUg== X-Forwarded-Encrypted: i=1; AJvYcCVz+kZaFsuy7XD6FbNmKxcy5t3MZAtbor2Vlco1Zre8mOu4s/hv+QVSaBLVNwXmS0LmO+9+p0q8G4hRIcYU1svLI6MmQ6zcXuCDoxf9 X-Gm-Message-State: AOJu0YyIWeHTX55/Y3F8e1/lfT/zenP6xg51v5GGDYAS8rEdQ2BGeYev 2b4AXYbzckKvHUF01iiUXr773gRZbnSQ81moR/NA0uwT24FBEEfefKLGfAj1bUY= X-Received: by 2002:a05:6a00:2d84:b0:705:a18a:686a with SMTP id d2e1a72fcca58-705c9389332mr2770164b3a.7.1718263963654; Thu, 13 Jun 2024 00:32:43 -0700 (PDT) Received: from [127.0.1.1] (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705cc78a1a0sm730028b3a.0.2024.06.13.00.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 00:32:43 -0700 (PDT) From: Andy Chiu Date: Thu, 13 Jun 2024 15:11:06 +0800 Subject: [PATCH 1/8] riscv: stacktrace: convert arch_stack_walk() to noinstr Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240613-dev-andyc-dyn-ftrace-v4-v1-1-1a538e12c01e@sifive.com> References: <20240613-dev-andyc-dyn-ftrace-v4-v1-0-1a538e12c01e@sifive.com> In-Reply-To: <20240613-dev-andyc-dyn-ftrace-v4-v1-0-1a538e12c01e@sifive.com> To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Zong Li , Steven Rostedt , Masami Hiramatsu , Mark Rutland , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Puranjay Mohan Cc: Palmer Dabbelt , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, llvm@lists.linux.dev, Andy Chiu X-Mailer: b4 0.12.4 arch_stack_walk() is called intensively in function_graph when the kernel is compiled with CONFIG_TRACE_IRQFLAGS. As a result, the kernel logs a lot of arch_stack_walk and its sub-functions into the ftrace buffer. However, these functions should not appear on the trace log because they are part of the ftrace itself. This patch references what arm64 does for the smae function. So it further prevent the re-enter kprobe issue, which is also possible on riscv. Related-to: commit 0fbcd8abf337 ("arm64: Prohibit instrumentation on arch_stack_walk()") Fixes: 680341382da5 ("riscv: add CALLER_ADDRx support") Signed-off-by: Andy Chiu --- arch/riscv/kernel/stacktrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c index 528ec7cc9a62..0d3f00eb0bae 100644 --- a/arch/riscv/kernel/stacktrace.c +++ b/arch/riscv/kernel/stacktrace.c @@ -156,7 +156,7 @@ unsigned long __get_wchan(struct task_struct *task) return pc; } -noinline void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, +noinline noinstr void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, struct task_struct *task, struct pt_regs *regs) { walk_stackframe(task, regs, consume_entry, cookie); -- 2.43.0