Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp1560930rdb; Sat, 26 Aug 2023 07:34:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGf6zufpsyM/DkCURsI3jEp8CQ5HBrMPXl1MtevMsv4E0ZNMcLhEiDlHuwnIIa4QozZlhey X-Received: by 2002:a05:6e02:dca:b0:34c:abcb:97e8 with SMTP id l10-20020a056e020dca00b0034cabcb97e8mr11857326ilj.24.1693060440963; Sat, 26 Aug 2023 07:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693060440; cv=none; d=google.com; s=arc-20160816; b=NztpWSespZKTdTlTc5Gr0BrHUDRbP4UPb/20mc/HeKuyNG0P7dGdNJ/N1JrWuipF9K smra5VsRH7D2XYJ+KfCJDCcjlsL1KrppBvtsljEyrujfTGsVVFnNBv+RHfa8LB6NIOQM HqCvtCPX6WJoKsSVewWpyp0SmmH38fBJadyFiyS3Fd8aKmzFIZZMuYhl9XYxOVRn2x6I hf+bjBmQkKpjDo5C8PU7xaI6Ox9KjjUdTsC+7sA/FMzzPMgvsW+/CDESvNK3jHGM0HMf 78BtWXYztMjHm3N8SJo8SUiXbC8fYnYxtRooZqlywXApC9Ys0UHmAc4T9gKmgtVv9MFo B9Dw== 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:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=0W9ovR8ECqKrh9mHahiWw8NWhkeyDK/dN2UHAb74lU4=; fh=rITqo0SP+PPteTr63GUdrxGKxmclX4QicWAjUs3tgrQ=; b=WnGVJN6cvsCJSCyohr7CHWUSUKdbKFtRPAWPwU/su1prFaVJFGIIAxi6Yf0Go/q9SD ZRYLFn+ZGTXLilAH4yW0c8xfZKpswUYgy5OT/Kt9tsSsPug6ffv6JY1id2RQvLstkkLW ZEyn50RntakvUt3SApWvvnna7e6dyyrJ3/hCMP9uulbfzosQYjAAVEuX/fjK58atKVOq 8Oqjfo4iIE6ZX0aeX6tKZPQk+vDu2rjyl9bCvM9WFjaCWhthGkJhrAVhxAiWNFgIQqmR 3xr6yvVAbaqSiCIg1fRYC5WlqyaGijRnRMxg4yaRzvRnLAsBFwBnOx5DllfY6k8XkCpa XIqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="CYK6t/9m"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020a633c4c000000b00564bcae8b53si3221120pgn.803.2023.08.26.07.33.30; Sat, 26 Aug 2023 07:34:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="CYK6t/9m"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231536AbjHZODS (ORCPT + 99 others); Sat, 26 Aug 2023 10:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231304AbjHZOC4 (ORCPT ); Sat, 26 Aug 2023 10:02:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 792E61711 for ; Sat, 26 Aug 2023 07:02:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 17B8861F4A for ; Sat, 26 Aug 2023 14:02:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD3A7C433C7; Sat, 26 Aug 2023 14:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693058570; bh=RZHkYur0kpYvgVYND39F8EDHpz0KGEHIwqM0/355IUs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=CYK6t/9miqMJe5VMd7UiNWV2OFKCownnT6Ig+7Q+o6MTvHzQbkt3fZ9WB6gvA9xA7 OuC0j56OJRCUCgDjaMocRfXzo1gKz5OEychsYWDvjjLDfOuckjMs3GuGrfau7vRIOV 1N1+4pj+EOEY0cHOsRxfaSVJsCF+eZgr89hy28O/WmTseKLJlQY8hH2FPBbvhrB4aD gfexUXDZfDnS+eAwuDv+bY5ZeBJCG9OCjdpexk63QxMwlsBqlfP2x94UsIaepmG/29 ek3eVKbCVYNEl/zihNgr2P+RQKkFlAfE1tuN9nnVuV4x1Czf2WRtlZ+BAyrWUO+DJW 6iIPDxHnHScXQ== From: =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= To: Puranjay Mohan , paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, pulehui@huawei.com, conor.dooley@microchip.com, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, kpsingh@kernel.org, bpf@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: puranjay12@gmail.com Subject: Re: [PATCH bpf-next v2 2/3] riscv: implement a memset like function for text In-Reply-To: <20230824133135.1176709-3-puranjay12@gmail.com> References: <20230824133135.1176709-1-puranjay12@gmail.com> <20230824133135.1176709-3-puranjay12@gmail.com> Date: Sat, 26 Aug 2023 16:02:47 +0200 Message-ID: <871qfprjeg.fsf@all.your.base.are.belong.to.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, 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: X-Mailing-List: linux-kernel@vger.kernel.org Puranjay Mohan writes: > The BPF JIT needs to write invalid instructions to RX regions of memory > to invalidate removed BPF programs. This needs a function like memset() > that can work with RX memory. > > Implement patch_text_set_nosync() which is similar to text_poke_set() of > x86. Some additional nits, in addition to the other comments (Song, kernel test bot, Lehui). > Signed-off-by: Puranjay Mohan > --- > arch/riscv/include/asm/patch.h | 1 + > arch/riscv/kernel/patch.c | 74 ++++++++++++++++++++++++++++++++++ > 2 files changed, 75 insertions(+) > > diff --git a/arch/riscv/include/asm/patch.h b/arch/riscv/include/asm/patc= h.h > index 63c98833d510..aa5c1830ea43 100644 > --- a/arch/riscv/include/asm/patch.h > +++ b/arch/riscv/include/asm/patch.h > @@ -7,6 +7,7 @@ > #define _ASM_RISCV_PATCH_H >=20=20 > int patch_text_nosync(void *addr, const void *insns, size_t len); > +int patch_text_set_nosync(void *addr, const int c, size_t len); > int patch_text(void *addr, u32 *insns, int ninsns); >=20=20 > extern int riscv_patch_in_stop_machine; > diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c > index 465b2eebbc37..24d49999ac1a 100644 > --- a/arch/riscv/kernel/patch.c > +++ b/arch/riscv/kernel/patch.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include >=20=20 > struct patch_insn { > void *addr; > @@ -53,6 +54,34 @@ static void patch_unmap(int fixmap) > } > NOKPROBE_SYMBOL(patch_unmap); >=20=20 > +static int __patch_insn_set(void *addr, const int c, size_t len) Drop the "const" from "const int c" everywhere in this patch, and let's just use u8 instead of int. We don't need to carry the old memset() legacy argumentts! We're more modern than that! ;-) Bj=C3=B6rn