Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3792168pxf; Mon, 29 Mar 2021 11:30:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRJy+2lPWy2fT5hXGmdPMaBaquYZCDzGmT0ov2WxapkRQ7wME6YlJuCGt9OZ6Zrot3H+EJ X-Received: by 2002:a05:6402:1115:: with SMTP id u21mr29681981edv.383.1617042659686; Mon, 29 Mar 2021 11:30:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617042659; cv=none; d=google.com; s=arc-20160816; b=ji2vDF33DaL5U16EoiZ7OnEnLVHZeceTu7mQC0vSy0rXiV84cmY+IaOeiKWPKqnkuV NjjDdVFWKz7kGPvsiYeB/4+GDJvMRscpBCZb34iXJm9XVzOUNlsQPR1kxhdS7bIe8isU pZBabL2Uo6afbGMnJh4jDoOJrAKB9EPIHxkB3zP+GW2jnOFvHPz+rZHDCWMLjrciEmPc qiV5zxa8rKt2j644fMD5Typ9e9PL9V2xGlOKZg5y/glyNP0fixBVimpWkce+Od+UHHAS EL/xd2hbMsIYOj+jaadVUjoibcJMRJePV+kER4aj59YfWMGAWwu4mo1s638yPWy33qZE Yw8g== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=X3JnzAWB/wP2byqIVYcRzkGaaPhYaCeo9nv6lfgBPe0=; b=02VjvD81MvVQ/+1/Dt05A3OjYnpgvc03rSnDKcCBdN6ZCpNVy6OqbJetLGxMRZtpxO ZikaTiV5+hX12b5NRa3fCcDaXhqctag8uSzL3CPHY81JQGlg/vi4idq7ZumZqAUWX8NH G0scb5hgsKmV9Gz0HhAvI7FLlTa3IwDcbdtdqryk2ltoO88QlQI5Xwf/j3MznFpMEThW Jp61BfZlY7L4LEFLsso2RV9LryMXJbCi3bCJKKgSWHP2W77YPbkPb6HrY3M1mz559yoV vetCQZaldd8xLPPzXiWFnfmWjcMtCZRn1g333onBnb05Js1OUpmRLucXp6gEXAkdIOH9 3SRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=ciYwCT3N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v24si12921948eju.663.2021.03.29.11.30.36; Mon, 29 Mar 2021 11:30:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=ciYwCT3N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231672AbhC2S3N (ORCPT + 99 others); Mon, 29 Mar 2021 14:29:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231219AbhC2S3H (ORCPT ); Mon, 29 Mar 2021 14:29:07 -0400 Received: from ustc.edu.cn (email6.ustc.edu.cn [IPv6:2001:da8:d800::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A0E46C061574; Mon, 29 Mar 2021 11:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ustc.edu.cn; s=dkim; h=Received:Date:From:To:Cc:Subject: Message-ID:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=X3JnzAWB/wP2byqIVYcRzkGaaPhYaCeo9n v6lfgBPe0=; b=ciYwCT3No/H9XxjptM0VF/OY2o4gT28I5Kw7VbmnXEjTsDu4mf YsC1hh4Hvuul3+7dfes7tXCpnxr5rNaeT3+rm05riOI1g4KMOnote/sxQ5EcgzWR OEgbeXuq5a1pXFFi581bdlA3cwdSHNOFbsIHEz4ICpx4YZi1p/j/ZTpXU= Received: from xhacker (unknown [101.86.19.180]) by newmailweb.ustc.edu.cn (Coremail) with SMTP id LkAmygCXnkpiHGJg2vRpAA--.2864S2; Tue, 30 Mar 2021 02:28:50 +0800 (CST) Date: Tue, 30 Mar 2021 02:23:54 +0800 From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , " =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?=" , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Luke Nelson , Xi Wang Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 4/9] riscv: Constify sbi_ipi_ops Message-ID: <20210330022354.385a9a52@xhacker> In-Reply-To: <20210330022144.150edc6e@xhacker> References: <20210330022144.150edc6e@xhacker> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CM-TRANSID: LkAmygCXnkpiHGJg2vRpAA--.2864S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KFyxuF4kuF1rWw17ZFyrJFb_yoW8tw1kpw 4UCr45CFWrGFn7Ga43tFWku3y3K3ZrWwnIy34Yka45JFnIqrWUAan0qw12vwn8GFyDuFyS 9r4rCrZ0vF1UAFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkKb7Iv0xC_Zr1lb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjc xK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40E FcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Gr 0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4IIrI8v6xkF7I0E8cxan2IY 04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI 0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y 0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UMIIF0xvE42xK8VAvwI8IcIk0rVW8JVW3JwCI42IY6I8E87Iv67AKxVW8JVWx JwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7IU8tKsU UUUUU== X-CM-SenderInfo: xmv2xttqjtqzxdloh3xvwfhvlgxou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jisheng Zhang Constify the sbi_ipi_ops so that it will be placed in the .rodata section. This will cause attempts to modify it to fail when strict page permissions are in place. Signed-off-by: Jisheng Zhang --- arch/riscv/include/asm/smp.h | 4 ++-- arch/riscv/kernel/sbi.c | 2 +- arch/riscv/kernel/smp.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/riscv/include/asm/smp.h b/arch/riscv/include/asm/smp.h index df1f7c4cd433..a7d2811f3536 100644 --- a/arch/riscv/include/asm/smp.h +++ b/arch/riscv/include/asm/smp.h @@ -46,7 +46,7 @@ int riscv_hartid_to_cpuid(int hartid); void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out); /* Set custom IPI operations */ -void riscv_set_ipi_ops(struct riscv_ipi_ops *ops); +void riscv_set_ipi_ops(const struct riscv_ipi_ops *ops); /* Clear IPI for current CPU */ void riscv_clear_ipi(void); @@ -92,7 +92,7 @@ static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in, cpumask_set_cpu(boot_cpu_hartid, out); } -static inline void riscv_set_ipi_ops(struct riscv_ipi_ops *ops) +static inline void riscv_set_ipi_ops(const struct riscv_ipi_ops *ops) { } diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c index cbd94a72eaa7..cb848e80865e 100644 --- a/arch/riscv/kernel/sbi.c +++ b/arch/riscv/kernel/sbi.c @@ -556,7 +556,7 @@ static void sbi_send_cpumask_ipi(const struct cpumask *target) sbi_send_ipi(cpumask_bits(&hartid_mask)); } -static struct riscv_ipi_ops sbi_ipi_ops = { +static const struct riscv_ipi_ops sbi_ipi_ops = { .ipi_inject = sbi_send_cpumask_ipi }; diff --git a/arch/riscv/kernel/smp.c b/arch/riscv/kernel/smp.c index 504284d49135..e035124f06dc 100644 --- a/arch/riscv/kernel/smp.c +++ b/arch/riscv/kernel/smp.c @@ -85,9 +85,9 @@ static void ipi_stop(void) wait_for_interrupt(); } -static struct riscv_ipi_ops *ipi_ops __ro_after_init; +static const struct riscv_ipi_ops *ipi_ops __ro_after_init; -void riscv_set_ipi_ops(struct riscv_ipi_ops *ops) +void riscv_set_ipi_ops(const struct riscv_ipi_ops *ops) { ipi_ops = ops; } -- 2.31.0