Message ID | 20231003182407.32198-1-alexghiti@rivosinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2270981vqb; Tue, 3 Oct 2023 11:24:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKy8jVR5Z7/lg405r/lsXffZYzOHJddBKNz1angmzejh1F4X7bcJYxJtvmzW68M79nAJar X-Received: by 2002:a05:6808:6190:b0:3a7:82e8:8fd1 with SMTP id dn16-20020a056808619000b003a782e88fd1mr393963oib.20.1696357457570; Tue, 03 Oct 2023 11:24:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696357457; cv=none; d=google.com; s=arc-20160816; b=akSnnZCXjC+3dAQrECb9pMgN+rlSF3EKeE5dLzgGVM0JOaPapl8pzf92A1C/wEsCz8 o42pdDIJVO9m5Stng/5cemJaDwK/tKJD3BAexKZO4bEaumz9LIguaz+WJnTgmvzQVHnC 9Gk8ca45QsD1YReXynQvdjq+SWpGU48qCTdSFFMtY1+yGZZ9FRAsmM25CjSFxCzHhcAe 6GdVQ75QQ9BOQFBVWtZMFpv55noxNGTk5N3lTY51cwsZSWC9KjOvVdQwZqvUsg3ysBcO GEjXxTEGYD793QMKQ6kD+3zUGcWQg0cay9gWG4yfVTPPLe5oa6woHVikZX+V7QqioC0t 0h+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9fq2RfR39uaAULbR2hK0DPNGxa1+1fryXBa+jVce0es=; fh=xZrR3CT6LJP3358Szach6YZrgDxBcWmc4kbhcDXB6Jw=; b=NcdxG4XSqGpjD8qBQAw8yx9khmT8QVLN5VRheroWXUOLIi47TYOE0+jqzKDwC7EN9j 9CKOAW9GizIQvWIyc5d879qZ377upikaQbgh8N3tK4f7BYT+/dBAzFDsvBkwAql6pDcA v1b9oz+lQYJ11QDF6Y/yhpkk/QHru9ordJZimdXTzmnYEhiPjpdZfze/L1Rzb1jOa4IW sFtKDY/iiVdYRmTBR3vy6nmevUnPB/e8cjCm+VaMK4Ie2irfdMOT1t59GBHsUl9ipg50 0JaZRH7WVlAP0lgBQ2WXMVfPzcauegL/u3JNIOtrRiA2ETSh9NmQOHSsG84jyS1fI13U tsmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=nEzdDOpo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id nv2-20020a17090b1b4200b00276945c92c1si2249001pjb.36.2023.10.03.11.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 11:24:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=nEzdDOpo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B5AE7812DBFB; Tue, 3 Oct 2023 11:24:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231667AbjJCSYP (ORCPT <rfc822;chrisfriedt@gmail.com> + 17 others); Tue, 3 Oct 2023 14:24:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230293AbjJCSYO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 3 Oct 2023 14:24:14 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B70690 for <linux-kernel@vger.kernel.org>; Tue, 3 Oct 2023 11:24:11 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40572aeb73cso11749645e9.3 for <linux-kernel@vger.kernel.org>; Tue, 03 Oct 2023 11:24:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1696357450; x=1696962250; 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=9fq2RfR39uaAULbR2hK0DPNGxa1+1fryXBa+jVce0es=; b=nEzdDOpoqBI+wQtVlCWJW8amnF8ZXPhPovZR+h40G2m8tHkKCExGUYemCvKZqTtYKL npqglkZ835xAqhI8HHNAwhJeo/uH+r7FKOzG2e70C6lLfpCvn9ztd9EsfoZxmnIm+wGE vV4ALlFYs+3yvbEp6eXRSj8jefM8m/u26a4FBUtk/ifqwbzW2RKZVfO7d0OgJznRf9gI 6XfpO0oBDr9Sr2F9o80cf4b7AJZcJPY+TqVqBF4k5qP/i4aWsG+Cvk4QNax6q3rKO7Bp PUCm37oW547HK7qno/OaTw+JOJl4AO8TiLLGZBYuCWFUTcsTKjwg5UVZTkYNJlKW0skB FZ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696357450; x=1696962250; 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=9fq2RfR39uaAULbR2hK0DPNGxa1+1fryXBa+jVce0es=; b=RfybMEmpV3AucucSNrgjTL+end3gkfhzcwVcOIWkl3q33q1Z77oYNTtX9cFBtH0k3j f3CfwQgSiHFyRmrquQphICD/oVBxKMHZJvW4SxpMxuyK94Pqf0YY1ngWluRshel6I/lR /88lqxIHSSeaLOzEMuEJwAEPDeeeDxlXKI6X+x1WuSpplB6oWWIXxqd0NI+LHdUqRSrj JlzW/PlP5daUd/jIAHbd4cZmUOajQVaQ3w0N9+2rwWqA/qjAMf2j0Kjjngw3RkYbAXGU UQOqw06j+9Oj8TmF5fHHy8kWBdUNCmpiA/RM8PiYvZQiZWDQduG8tc/rN0nWgda53SDG 2LhA== X-Gm-Message-State: AOJu0Yxoq8xO9H2VtJJGXLw3whkIxYPNQpA6+lSa5nnhVi/i1gGdi+bk wnWDIkApzRVJKtS9v8i3M+tnZw== X-Received: by 2002:a05:600c:22cf:b0:401:4542:5edd with SMTP id 15-20020a05600c22cf00b0040145425eddmr187257wmg.34.1696357449779; Tue, 03 Oct 2023 11:24:09 -0700 (PDT) Received: from alex-rivos.ba.rivosinc.com (amontpellier-656-1-456-62.w92-145.abo.wanadoo.fr. [92.145.124.62]) by smtp.gmail.com with ESMTPSA id m24-20020a7bca58000000b004063977eccesm10001349wml.42.2023.10.03.11.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 11:24:09 -0700 (PDT) From: Alexandre Ghiti <alexghiti@rivosinc.com> To: Steven Rostedt <rostedt@goodmis.org>, Masami Hiramatsu <mhiramat@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, Sami Tolvanen <samitolvanen@google.com>, Kees Cook <keescook@chromium.org>, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Alexandre Ghiti <alexghiti@rivosinc.com> Subject: [PATCH -fixes] riscv: Fix ftrace syscall handling which are now prefixed with __riscv_ Date: Tue, 3 Oct 2023 20:24:07 +0200 Message-Id: <20231003182407.32198-1-alexghiti@rivosinc.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 03 Oct 2023 11:24:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778759717376592264 X-GMAIL-MSGID: 1778759717376592264 |
Series |
[-fixes] riscv: Fix ftrace syscall handling which are now prefixed with __riscv_
|
|
Commit Message
Alexandre Ghiti
Oct. 3, 2023, 6:24 p.m. UTC
ftrace creates entries for each syscall in the tracefs but has failed
since commit 08d0ce30e0e4 ("riscv: Implement syscall wrappers") which
prefixes all riscv syscalls with __riscv_.
So fix this by implementing arch_syscall_match_sym_name() which allows us
to ignore this prefix.
And also ignore compat syscalls like x86/arm64 by implementing
arch_trace_is_compat_syscall().
Fixes: 08d0ce30e0e4 ("riscv: Implement syscall wrappers")
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
---
arch/riscv/include/asm/ftrace.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
Comments
@Conor Dooley This fails checkpatch but the documentation here states that this is how to do: https://elixir.bootlin.com/linux/latest/source/Documentation/trace/ftrace-design.rst#L246 On Tue, Oct 3, 2023 at 8:24 PM Alexandre Ghiti <alexghiti@rivosinc.com> wrote: > > ftrace creates entries for each syscall in the tracefs but has failed > since commit 08d0ce30e0e4 ("riscv: Implement syscall wrappers") which > prefixes all riscv syscalls with __riscv_. > > So fix this by implementing arch_syscall_match_sym_name() which allows us > to ignore this prefix. > > And also ignore compat syscalls like x86/arm64 by implementing > arch_trace_is_compat_syscall(). > > Fixes: 08d0ce30e0e4 ("riscv: Implement syscall wrappers") > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> > --- > arch/riscv/include/asm/ftrace.h | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h > index 740a979171e5..2b2f5df7ef2c 100644 > --- a/arch/riscv/include/asm/ftrace.h > +++ b/arch/riscv/include/asm/ftrace.h > @@ -31,6 +31,27 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr) > return addr; > } > > +/* > + * Let's do like x86/arm64 and ignore the compat syscalls. > + */ > +#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS > +static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs) > +{ > + return is_compat_task(); > +} > + > +#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME > +static inline bool arch_syscall_match_sym_name(const char *sym, > + const char *name) > +{ > + /* > + * Since all syscall functions have __riscv_ prefix, we must skip it. > + * However, as we described above, we decided to ignore compat > + * syscalls, so we don't care about __riscv_compat_ prefix here. > + */ > + return !strcmp(sym + 8, name); > +} > + > struct dyn_arch_ftrace { > }; > #endif > -- > 2.39.2 >
On Tue, Oct 3, 2023 at 11:24 AM Alexandre Ghiti <alexghiti@rivosinc.com> wrote: > > ftrace creates entries for each syscall in the tracefs but has failed > since commit 08d0ce30e0e4 ("riscv: Implement syscall wrappers") which > prefixes all riscv syscalls with __riscv_. > > So fix this by implementing arch_syscall_match_sym_name() which allows us > to ignore this prefix. > > And also ignore compat syscalls like x86/arm64 by implementing > arch_trace_is_compat_syscall(). > > Fixes: 08d0ce30e0e4 ("riscv: Implement syscall wrappers") > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> > --- > arch/riscv/include/asm/ftrace.h | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h > index 740a979171e5..2b2f5df7ef2c 100644 > --- a/arch/riscv/include/asm/ftrace.h > +++ b/arch/riscv/include/asm/ftrace.h > @@ -31,6 +31,27 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr) > return addr; > } > > +/* > + * Let's do like x86/arm64 and ignore the compat syscalls. > + */ > +#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS > +static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs) > +{ > + return is_compat_task(); > +} > + > +#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME > +static inline bool arch_syscall_match_sym_name(const char *sym, > + const char *name) > +{ > + /* > + * Since all syscall functions have __riscv_ prefix, we must skip it. > + * However, as we described above, we decided to ignore compat > + * syscalls, so we don't care about __riscv_compat_ prefix here. > + */ > + return !strcmp(sym + 8, name); > +} Good catch, thanks for fixing this! Reviewed-by: Sami Tolvanen <samitolvanen@google.com> Sami
On Tue, 3 Oct 2023 20:24:07 +0200 Alexandre Ghiti <alexghiti@rivosinc.com> wrote: > ftrace creates entries for each syscall in the tracefs but has failed > since commit 08d0ce30e0e4 ("riscv: Implement syscall wrappers") which > prefixes all riscv syscalls with __riscv_. > > So fix this by implementing arch_syscall_match_sym_name() which allows us > to ignore this prefix. > > And also ignore compat syscalls like x86/arm64 by implementing > arch_trace_is_compat_syscall(). > Looks good to me, Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Thank you, > Fixes: 08d0ce30e0e4 ("riscv: Implement syscall wrappers") > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> > --- > arch/riscv/include/asm/ftrace.h | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h > index 740a979171e5..2b2f5df7ef2c 100644 > --- a/arch/riscv/include/asm/ftrace.h > +++ b/arch/riscv/include/asm/ftrace.h > @@ -31,6 +31,27 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr) > return addr; > } > > +/* > + * Let's do like x86/arm64 and ignore the compat syscalls. > + */ > +#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS > +static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs) > +{ > + return is_compat_task(); > +} > + > +#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME > +static inline bool arch_syscall_match_sym_name(const char *sym, > + const char *name) > +{ > + /* > + * Since all syscall functions have __riscv_ prefix, we must skip it. > + * However, as we described above, we decided to ignore compat > + * syscalls, so we don't care about __riscv_compat_ prefix here. > + */ > + return !strcmp(sym + 8, name); > +} > + > struct dyn_arch_ftrace { > }; > #endif > -- > 2.39.2 >
Alexandre Ghiti <alexghiti@rivosinc.com> writes: > @Conor Dooley This fails checkpatch but the documentation here states > that this is how to do: > https://elixir.bootlin.com/linux/latest/source/Documentation/trace/ftrace-design.rst#L246 FWIW, I'll relax the PW CI checkpatch test going forward. It's way too strict...
Alexandre Ghiti <alexghiti@rivosinc.com> writes: > ftrace creates entries for each syscall in the tracefs but has failed > since commit 08d0ce30e0e4 ("riscv: Implement syscall wrappers") which > prefixes all riscv syscalls with __riscv_. > > So fix this by implementing arch_syscall_match_sym_name() which allows us > to ignore this prefix. > > And also ignore compat syscalls like x86/arm64 by implementing > arch_trace_is_compat_syscall(). > > Fixes: 08d0ce30e0e4 ("riscv: Implement syscall wrappers") > Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> This fix does the BPF test suite happier! Tested-by: Björn Töpel <bjorn@rivosinc.com>
Hello: This patch was applied to riscv/linux.git (fixes) by Palmer Dabbelt <palmer@rivosinc.com>: On Tue, 3 Oct 2023 20:24:07 +0200 you wrote: > ftrace creates entries for each syscall in the tracefs but has failed > since commit 08d0ce30e0e4 ("riscv: Implement syscall wrappers") which > prefixes all riscv syscalls with __riscv_. > > So fix this by implementing arch_syscall_match_sym_name() which allows us > to ignore this prefix. > > [...] Here is the summary with links: - [-fixes] riscv: Fix ftrace syscall handling which are now prefixed with __riscv_ https://git.kernel.org/riscv/c/a87e7d3e8832 You are awesome, thank you!
diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h index 740a979171e5..2b2f5df7ef2c 100644 --- a/arch/riscv/include/asm/ftrace.h +++ b/arch/riscv/include/asm/ftrace.h @@ -31,6 +31,27 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr) return addr; } +/* + * Let's do like x86/arm64 and ignore the compat syscalls. + */ +#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS +static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs) +{ + return is_compat_task(); +} + +#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME +static inline bool arch_syscall_match_sym_name(const char *sym, + const char *name) +{ + /* + * Since all syscall functions have __riscv_ prefix, we must skip it. + * However, as we described above, we decided to ignore compat + * syscalls, so we don't care about __riscv_compat_ prefix here. + */ + return !strcmp(sym + 8, name); +} + struct dyn_arch_ftrace { }; #endif