Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2148352rdb; Tue, 3 Oct 2023 11:40:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoZy2BBEynbm0bYL/7SKXZZPaGn9iqfXyPypdqKY2qRVN4Xu//SyMp1FRYGqSJr881xi4y X-Received: by 2002:a05:6a20:3d8b:b0:130:d5a:e40e with SMTP id s11-20020a056a203d8b00b001300d5ae40emr317176pzi.7.1696358458216; Tue, 03 Oct 2023 11:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696358458; cv=none; d=google.com; s=arc-20160816; b=RcFdP+Q/TmpWqNagmdCzj+v+Fh5iWEUOhdPy9skpum/Jqppwcm/EW5zaxX4vcNqSHc M9F+PXEibRPC7aeFjvXQvNRxwpf4iPcSKuOnHONHWjZcTiOKCsoDUodE53+azZSo0NCq NuGRUgEVFTAGhek8Ldbm+h2dtVjVIcY/3SDa6aubbvM6jgIyTO9H66shjSDS639i+9kh wJEY1+i1ZqDl/fJqCfiyeXsV4yPtHCqL5TUscEsCFmu8szZkllU2u5YwdHUn8koqEycg smz+AImaTxHdfgpMqzvy9Ar7s94/Ch1px9F4j3ZpHESexmx8KYZdJU5SsO4J5UituW8f 9uRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=E4EHhQcGy2VS2JlcOPiKLjlIFfrg/psFf5RMRLEP3YE=; fh=SSeTfZfPFRW+vITS2cqvrO3g+asDcE+DNOYwEo3wigs=; b=HoePZBZq9TpXaDa4+xzUKo1ixQZByH0FLPL4HpkwkZXwqQ6hMINF9i+dzAf9JTACp9 BOvVCuLqfja79nHRTjiTBRsMG8o0jxCZR26kQaUIClAd1zwW298RB9n08IVmFyV4T/z4 2eXI/u/OWQ2p7AUCUn3mzGEnOUjZfZUqbaQopTSOZC9b99TxenEr5/jFbnWLPXS9axdq dWzhgc4V/cQPl/6PcqDRVzcez+R/eBYki7MqvR5cRGLNWJ36BCCpUW8YqFgvMOo/JHnl N04sPNEMQ/aFC8YekJ4Ub5Vq5p6c+1KC+cmFCzvBzT8ZsX/zVr4kHriRqq0xcdFGNzYE PM+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=NVtywLp8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id b19-20020a6567d3000000b0056a1a149034si2062241pgs.650.2023.10.03.11.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 11:40:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=NVtywLp8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id E1D408039865; Tue, 3 Oct 2023 11:40:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232021AbjJCSku (ORCPT + 99 others); Tue, 3 Oct 2023 14:40:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232127AbjJCSks (ORCPT ); Tue, 3 Oct 2023 14:40:48 -0400 Received: from mail-vs1-xe36.google.com (mail-vs1-xe36.google.com [IPv6:2607:f8b0:4864:20::e36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C3B695 for ; Tue, 3 Oct 2023 11:40:40 -0700 (PDT) Received: by mail-vs1-xe36.google.com with SMTP id ada2fe7eead31-4527d7f7305so645751137.1 for ; Tue, 03 Oct 2023 11:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696358439; x=1696963239; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=E4EHhQcGy2VS2JlcOPiKLjlIFfrg/psFf5RMRLEP3YE=; b=NVtywLp8/m1kTVnO0jYxdh9jx11prD5iwZL/YqB/oMwyO4tFVZxoQP2h2ZE0JbpHT0 Wy1M/eGPM9IViLC/2ECIxhMjJYoQ2JjZIcsGqqLAM255BX/DYocKVflc2Z8YkIPT/Eac w/DIfDT4+EmgDlReX/GfMNolUro/9r3LB+3SwUCKegITK8iMoOP9iBtGBmJrxLYv0H4K EY/G7dLU4xEqEF+SbxDVlihDtikfidTk4kJTpZNGzpWCiyKD7XohoGEfGZokkv8oMbN8 Hv2Do20wBlQUS60xofEdFGWUxurLRfeAu4AO/F4K7YTZE8LuZYMjj6zgbQiqS0FI/7Wb 2x6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696358439; x=1696963239; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E4EHhQcGy2VS2JlcOPiKLjlIFfrg/psFf5RMRLEP3YE=; b=ehXURBVeFCXHpVWBBwF9zcAn6zA8HHEWn4B5SG4YxQhkDBEujiU3rbSsGhkDMvEuTg MPz+BKGQOEypuZonxmAAFyHPKdSjITRH16x+bNwPhPKDecdJbjZW1id1dAQncX3EkqKm /ac/3j59UWnFH1nRcG1d7vaMWHcfdDpkwYY8uQ2PyUzwzE1s7tjhj3p/2esvmeANaoDR E3xgiwfxp8taezloJzFxa5fR+0VXCgB2aNmwT5dDECOsM8f1OF3jy03gSVGsKxdvPI42 H34Vx7rDKuPG7up09Dy6WajT+D0BCzURgpUMvnBu8WE5oAW2blpE+A3uch9nrKpHbjN0 y92g== X-Gm-Message-State: AOJu0YyDxTJRnSNqvnRR24gDuAyknjk/dEtt82CQNxqigb8tKs09KVpb vwb6zoQLBZwjMLZ2QwS8dbjVoSvy76IFRDGiW4d6Pg== X-Received: by 2002:a67:b40b:0:b0:452:74b1:63d7 with SMTP id x11-20020a67b40b000000b0045274b163d7mr210462vsl.6.1696358439487; Tue, 03 Oct 2023 11:40:39 -0700 (PDT) MIME-Version: 1.0 References: <20231003182407.32198-1-alexghiti@rivosinc.com> In-Reply-To: <20231003182407.32198-1-alexghiti@rivosinc.com> From: Sami Tolvanen Date: Tue, 3 Oct 2023 11:40:03 -0700 Message-ID: Subject: Re: [PATCH -fixes] riscv: Fix ftrace syscall handling which are now prefixed with __riscv_ To: Alexandre Ghiti Cc: Steven Rostedt , Masami Hiramatsu , Mark Rutland , Paul Walmsley , Palmer Dabbelt , Albert Ou , Kees Cook , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 11:40:53 -0700 (PDT) On Tue, Oct 3, 2023 at 11:24=E2=80=AFAM Alexandre Ghiti 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 > --- > 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/ftr= ace.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(unsigne= d 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 Sami