From: Heiko Stuebner <heiko@sntech.de>
To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu
Cc: atishp@atishpatra.org, anup@brainfault.org, jszhang@kernel.org,
christoph.muellner@vrull.eu, philipp.tomsich@vrull.eu,
mick@ics.forth.gr, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, Heiko Stuebner <heiko@sntech.de>
Subject: [PATCH 2/2] riscv: provide default implementations for __sbi_set_timer and __sbi_send_ipi
Date: Mon, 13 Dec 2021 12:20:34 +0100 [thread overview]
Message-ID: <20211213112034.2896536-2-heiko@sntech.de> (raw)
In-Reply-To: <20211213112034.2896536-1-heiko@sntech.de>
The mentioned function pointers get called from different sbi functions
which may get called from other areas of the kernel without fully
checking if the sbi initialization was done.
So similarly to sbi_remote_fence_i, provide empty functions for them
to prevent any null-pointer dereferences in the future.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
arch/riscv/kernel/sbi.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
index 69d0a96b97d0..6a21345c6712 100644
--- a/arch/riscv/kernel/sbi.c
+++ b/arch/riscv/kernel/sbi.c
@@ -14,6 +14,13 @@
unsigned long sbi_spec_version __ro_after_init = SBI_SPEC_VERSION_DEFAULT;
EXPORT_SYMBOL(sbi_spec_version);
+static void __sbi_set_timer_none(uint64_t stime_value) {}
+
+static int __sbi_send_ipi_none(const unsigned long *hart_mask)
+{
+ return -EOPNOTSUPP;
+}
+
static int __sbi_rfence_none(int fid, const unsigned long *hart_mask,
unsigned long start, unsigned long size,
unsigned long arg4, unsigned long arg5)
@@ -21,8 +28,9 @@ static int __sbi_rfence_none(int fid, const unsigned long *hart_mask,
return -EOPNOTSUPP;
}
-static void (*__sbi_set_timer)(uint64_t stime) __ro_after_init;
-static int (*__sbi_send_ipi)(const unsigned long *hart_mask) __ro_after_init;
+static void (*__sbi_set_timer)(uint64_t stime) __ro_after_init = __sbi_set_timer_none;
+static int (*__sbi_send_ipi)(const unsigned long *hart_mask)
+ __ro_after_init = __sbi_send_ipi_none;
static int (*__sbi_rfence)(int fid, const unsigned long *hart_mask,
unsigned long start, unsigned long size,
unsigned long arg4, unsigned long arg5)
--
2.30.2
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2021-12-13 11:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-13 11:20 [PATCH 1/2] riscv: prevent null-pointer dereference with sbi_remote_fence_i Heiko Stuebner
2021-12-13 11:20 ` Heiko Stuebner [this message]
2021-12-14 2:10 ` [PATCH 2/2] riscv: provide default implementations for __sbi_set_timer and __sbi_send_ipi Atish Patra
2021-12-14 11:08 ` Heiko Stuebner
2021-12-14 1:51 ` [PATCH 1/2] riscv: prevent null-pointer dereference with sbi_remote_fence_i Atish Patra
2021-12-14 10:41 ` Heiko Stuebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211213112034.2896536-2-heiko@sntech.de \
--to=heiko@sntech.de \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=atishp@atishpatra.org \
--cc=christoph.muellner@vrull.eu \
--cc=jszhang@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mick@ics.forth.gr \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=philipp.tomsich@vrull.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox