* [PATCH] riscv: Move user-visible sbi ext ids to uapi
@ 2025-09-17 9:21 BillXiang
2025-10-08 18:17 ` Paul Walmsley
0 siblings, 1 reply; 6+ messages in thread
From: BillXiang @ 2025-09-17 9:21 UTC (permalink / raw)
To: linux-riscv; +Cc: BillXiang
Move those sbi ext ids to uapi because they will be forwarded
to user space by kvm.
Signed-off-by: BillXiang <xiangwencheng@lanxincomputing.com>
---
arch/riscv/include/asm/sbi.h | 16 +-----------
arch/riscv/include/uapi/asm/sbi.h | 43 +++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 15 deletions(-)
create mode 100644 arch/riscv/include/uapi/asm/sbi.h
diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
index 341e74238aa0..e196feaabb2e 100644
--- a/arch/riscv/include/asm/sbi.h
+++ b/arch/riscv/include/asm/sbi.h
@@ -10,13 +10,12 @@
#include <linux/types.h>
#include <linux/cpumask.h>
#include <linux/jump_label.h>
+#include <uapi/asm/sbi.h>
#ifdef CONFIG_RISCV_SBI
enum sbi_ext_id {
#ifdef CONFIG_RISCV_SBI_V01
SBI_EXT_0_1_SET_TIMER = 0x0,
- SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1,
- SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2,
SBI_EXT_0_1_CLEAR_IPI = 0x3,
SBI_EXT_0_1_SEND_IPI = 0x4,
SBI_EXT_0_1_REMOTE_FENCE_I = 0x5,
@@ -37,13 +36,6 @@ enum sbi_ext_id {
SBI_EXT_NACL = 0x4E41434C,
SBI_EXT_FWFT = 0x46574654,
- /* Experimentals extensions must lie within this range */
- SBI_EXT_EXPERIMENTAL_START = 0x08000000,
- SBI_EXT_EXPERIMENTAL_END = 0x08FFFFFF,
-
- /* Vendor extensions must lie within this range */
- SBI_EXT_VENDOR_START = 0x09000000,
- SBI_EXT_VENDOR_END = 0x09FFFFFF,
};
enum sbi_ext_base_fid {
@@ -263,12 +255,6 @@ enum sbi_pmu_ctr_type {
#define SBI_PMU_STOP_FLAG_RESET BIT(0)
#define SBI_PMU_STOP_FLAG_TAKE_SNAPSHOT BIT(1)
-enum sbi_ext_dbcn_fid {
- SBI_EXT_DBCN_CONSOLE_WRITE = 0,
- SBI_EXT_DBCN_CONSOLE_READ = 1,
- SBI_EXT_DBCN_CONSOLE_WRITE_BYTE = 2,
-};
-
/* SBI STA (steal-time accounting) extension */
enum sbi_ext_sta_fid {
SBI_EXT_STA_STEAL_TIME_SET_SHMEM = 0,
diff --git a/arch/riscv/include/uapi/asm/sbi.h b/arch/riscv/include/uapi/asm/sbi.h
new file mode 100644
index 000000000000..d29ac0abeefe
--- /dev/null
+++ b/arch/riscv/include/uapi/asm/sbi.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright (C) 2025 Lanxincomputing Corporation or its affiliates.
+ *
+ * Authors:
+ * BillXiang <xiangwencheng@lanxincomputing.com>
+ */
+
+#ifndef _UAPI_ASM_RISCV_SBI_H
+#define _UAPI_ASM_RISCV_SBI_H
+
+
+enum SBI_EXT_ID {
+ /*
+ * The CONSOLE_GETCHAR/CONSOLE_PUTCHAR SBI calls cannot be
+ * handled in kernel so they will be forwarded to userspace by kvm.
+ */
+ SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1,
+ SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2,
+ /*
+ * Both SBI experimental and vendor extensions are
+ * unconditionally forwarded to userspace by kvm.
+ */
+ /* Experimentals extensions must lie within this range */
+ SBI_EXT_EXPERIMENTAL_START = 0x08000000,
+ SBI_EXT_EXPERIMENTAL_END = 0x08FFFFFF,
+
+ /* Vendor extensions must lie within this range */
+ SBI_EXT_VENDOR_START = 0x09000000,
+ SBI_EXT_VENDOR_END = 0x09FFFFFF,
+};
+
+/*
+* The SBI debug console functions are unconditionally
+* forwarded to the userspace by kvm.
+*/
+enum sbi_ext_dbcn_fid {
+ SBI_EXT_DBCN_CONSOLE_WRITE = 0,
+ SBI_EXT_DBCN_CONSOLE_READ = 1,
+ SBI_EXT_DBCN_CONSOLE_WRITE_BYTE = 2,
+};
+
+#endif /* _UAPI_ASM_RISCV_SBI_H */
\ No newline at end of file
--
2.43.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] riscv: Move user-visible sbi ext ids to uapi
2025-09-17 9:21 [PATCH] riscv: Move user-visible sbi ext ids to uapi BillXiang
@ 2025-10-08 18:17 ` Paul Walmsley
2025-10-08 20:06 ` Andrew Jones
0 siblings, 1 reply; 6+ messages in thread
From: Paul Walmsley @ 2025-10-08 18:17 UTC (permalink / raw)
To: BillXiang; +Cc: linux-riscv
Hi,
a few comments:
On Wed, 17 Sep 2025, BillXiang wrote:
> Move those sbi ext ids to uapi because they will be forwarded
> to user space by kvm.
>
> Signed-off-by: BillXiang <xiangwencheng@lanxincomputing.com>
checkpatch.pl reports several issues with this patch. Please follow these
steps before sending patches to the public lists:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst
> ---
> arch/riscv/include/asm/sbi.h | 16 +-----------
> arch/riscv/include/uapi/asm/sbi.h | 43 +++++++++++++++++++++++++++++++
> 2 files changed, 44 insertions(+), 15 deletions(-)
> create mode 100644 arch/riscv/include/uapi/asm/sbi.h
>
> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
> index 341e74238aa0..e196feaabb2e 100644
> --- a/arch/riscv/include/asm/sbi.h
> +++ b/arch/riscv/include/asm/sbi.h
> @@ -10,13 +10,12 @@
> #include <linux/types.h>
> #include <linux/cpumask.h>
> #include <linux/jump_label.h>
> +#include <uapi/asm/sbi.h>
>
> #ifdef CONFIG_RISCV_SBI
> enum sbi_ext_id {
> #ifdef CONFIG_RISCV_SBI_V01
> SBI_EXT_0_1_SET_TIMER = 0x0,
> - SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1,
> - SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2,
> SBI_EXT_0_1_CLEAR_IPI = 0x3,
> SBI_EXT_0_1_SEND_IPI = 0x4,
> SBI_EXT_0_1_REMOTE_FENCE_I = 0x5,
> @@ -37,13 +36,6 @@ enum sbi_ext_id {
> SBI_EXT_NACL = 0x4E41434C,
> SBI_EXT_FWFT = 0x46574654,
>
> - /* Experimentals extensions must lie within this range */
> - SBI_EXT_EXPERIMENTAL_START = 0x08000000,
> - SBI_EXT_EXPERIMENTAL_END = 0x08FFFFFF,
> -
> - /* Vendor extensions must lie within this range */
> - SBI_EXT_VENDOR_START = 0x09000000,
> - SBI_EXT_VENDOR_END = 0x09FFFFFF,
> };
>
> enum sbi_ext_base_fid {
> @@ -263,12 +255,6 @@ enum sbi_pmu_ctr_type {
> #define SBI_PMU_STOP_FLAG_RESET BIT(0)
> #define SBI_PMU_STOP_FLAG_TAKE_SNAPSHOT BIT(1)
>
> -enum sbi_ext_dbcn_fid {
> - SBI_EXT_DBCN_CONSOLE_WRITE = 0,
> - SBI_EXT_DBCN_CONSOLE_READ = 1,
> - SBI_EXT_DBCN_CONSOLE_WRITE_BYTE = 2,
> -};
> -
> /* SBI STA (steal-time accounting) extension */
> enum sbi_ext_sta_fid {
> SBI_EXT_STA_STEAL_TIME_SET_SHMEM = 0,
> diff --git a/arch/riscv/include/uapi/asm/sbi.h b/arch/riscv/include/uapi/asm/sbi.h
> new file mode 100644
> index 000000000000..d29ac0abeefe
> --- /dev/null
> +++ b/arch/riscv/include/uapi/asm/sbi.h
> @@ -0,0 +1,43 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> +/*
> + * Copyright (C) 2025 Lanxincomputing Corporation or its affiliates.
Most of this file is cut-and-pasted from another kernel file, with
different copyrights. When that happens, it's best to add the copyright
notices from the original file, as the new file appears to be a derivative
of the initial work.
> + *
> + * Authors:
> + * BillXiang <xiangwencheng@lanxincomputing.com>
Same for authorship information.
> + */
> +
> +#ifndef _UAPI_ASM_RISCV_SBI_H
> +#define _UAPI_ASM_RISCV_SBI_H
> +
> +
> +enum SBI_EXT_ID {
> + /*
> + * The CONSOLE_GETCHAR/CONSOLE_PUTCHAR SBI calls cannot be
> + * handled in kernel so they will be forwarded to userspace by kvm.
> + */
> + SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1,
> + SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2,
> + /*
> + * Both SBI experimental and vendor extensions are
> + * unconditionally forwarded to userspace by kvm.
> + */
> + /* Experimentals extensions must lie within this range */
> + SBI_EXT_EXPERIMENTAL_START = 0x08000000,
> + SBI_EXT_EXPERIMENTAL_END = 0x08FFFFFF,
> +
> + /* Vendor extensions must lie within this range */
> + SBI_EXT_VENDOR_START = 0x09000000,
> + SBI_EXT_VENDOR_END = 0x09FFFFFF,
> +};
> +
> +/*
> +* The SBI debug console functions are unconditionally
> +* forwarded to the userspace by kvm.
> +*/
> +enum sbi_ext_dbcn_fid {
> + SBI_EXT_DBCN_CONSOLE_WRITE = 0,
> + SBI_EXT_DBCN_CONSOLE_READ = 1,
> + SBI_EXT_DBCN_CONSOLE_WRITE_BYTE = 2,
> +};
> +
> +#endif /* _UAPI_ASM_RISCV_SBI_H */
> \ No newline at end of file
I do have some broader questions: is this patch really needed? Is it
fixing anything that's broken? These SBI constants aren't defined by the
kernel; they come from RISC-V standards.
- Paul
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] riscv: Move user-visible sbi ext ids to uapi
2025-10-08 18:17 ` Paul Walmsley
@ 2025-10-08 20:06 ` Andrew Jones
2025-10-08 20:37 ` Paul Walmsley
0 siblings, 1 reply; 6+ messages in thread
From: Andrew Jones @ 2025-10-08 20:06 UTC (permalink / raw)
To: Paul Walmsley; +Cc: BillXiang, linux-riscv
On Wed, Oct 08, 2025 at 12:17:01PM -0600, Paul Walmsley wrote:
...
> I do have some broader questions: is this patch really needed? Is it
> fixing anything that's broken? These SBI constants aren't defined by the
> kernel; they come from RISC-V standards.
Hi Paul,
You're right that we don't want this patch. I hadn't noticed that the same
patch was posted more than once or I would have nacked it here too. I
replied to the other posting[1] a couple weeks ago.
[1] https://lore.kernel.org/all/20250924-7e9764acec6722b5ef29ce7d@orel/
Thanks,
drew
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] riscv: Move user-visible sbi ext ids to uapi
2025-10-08 20:06 ` Andrew Jones
@ 2025-10-08 20:37 ` Paul Walmsley
2025-10-09 7:27 ` BillXiang
0 siblings, 1 reply; 6+ messages in thread
From: Paul Walmsley @ 2025-10-08 20:37 UTC (permalink / raw)
To: Andrew Jones; +Cc: Paul Walmsley, BillXiang, linux-riscv
Hi Drew,
On Wed, 8 Oct 2025, Andrew Jones wrote:
> On Wed, Oct 08, 2025 at 12:17:01PM -0600, Paul Walmsley wrote:
> ...
> > I do have some broader questions: is this patch really needed? Is it
> > fixing anything that's broken? These SBI constants aren't defined by the
> > kernel; they come from RISC-V standards.
>
> Hi Paul,
>
> You're right that we don't want this patch. I hadn't noticed that the same
> patch was posted more than once or I would have nacked it here too. I
> replied to the other posting[1] a couple weeks ago.
>
> [1] https://lore.kernel.org/all/20250924-7e9764acec6722b5ef29ce7d@orel/
Thanks for the heads up and for the early review. Patchwork didn't pick
up the thread for whatever reason beyond the initial patch, and I didn't
bother to check the mail archive...
- Paul
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] riscv: Move user-visible sbi ext ids to uapi
2025-10-08 20:37 ` Paul Walmsley
@ 2025-10-09 7:27 ` BillXiang
2025-10-09 15:07 ` Andrew Jones
0 siblings, 1 reply; 6+ messages in thread
From: BillXiang @ 2025-10-09 7:27 UTC (permalink / raw)
To: Paul Walmsley, Andrew Jones; +Cc: linux-riscv
On 10/9/2025 4:37 AM, Paul Walmsley wrote:
> Hi Drew,
>
> On Wed, 8 Oct 2025, Andrew Jones wrote:
>
>> On Wed, Oct 08, 2025 at 12:17:01PM -0600, Paul Walmsley wrote:
>> ...
>>> I do have some broader questions: is this patch really needed? Is it
>>> fixing anything that's broken? These SBI constants aren't defined by the
>>> kernel; they come from RISC-V standards.
Hi All,
Thanks for the review, and sorry for the noise my earlier mistake caused.
Just to clarify the intent of this patch: these SBI constants are
defined by the RISC-V spec, but they are implemented by kernel.
IMO, for a userspace developer working on linux it's better to include
this constants from kernel instead of define them again.
If you don't like the patch, feel free to ignore it, nothing breaks
either way.
Additionally, the goodness of UAPI was described in[1].
[1] https://lwn.net/Articles/507794/
>>
>> Hi Paul,
>>
>> You're right that we don't want this patch. I hadn't noticed that the same
>> patch was posted more than once or I would have nacked it here too. I
>> replied to the other posting[1] a couple weeks ago.
>>
>> [1] https://lore.kernel.org/all/20250924-7e9764acec6722b5ef29ce7d@orel/
>
> Thanks for the heads up and for the early review. Patchwork didn't pick
> up the thread for whatever reason beyond the initial patch, and I didn't
> bother to check the mail archive...
>
>
> - Paul
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] riscv: Move user-visible sbi ext ids to uapi
2025-10-09 7:27 ` BillXiang
@ 2025-10-09 15:07 ` Andrew Jones
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Jones @ 2025-10-09 15:07 UTC (permalink / raw)
To: BillXiang; +Cc: Paul Walmsley, linux-riscv
On Thu, Oct 09, 2025 at 03:27:18PM +0800, BillXiang wrote:
> On 10/9/2025 4:37 AM, Paul Walmsley wrote:
> > Hi Drew,
> >
> > On Wed, 8 Oct 2025, Andrew Jones wrote:
> >
> >> On Wed, Oct 08, 2025 at 12:17:01PM -0600, Paul Walmsley wrote:
> >> ...
> >>> I do have some broader questions: is this patch really needed? Is it
> >>> fixing anything that's broken? These SBI constants aren't defined by the
> >>> kernel; they come from RISC-V standards.
>
> Hi All,
>
> Thanks for the review, and sorry for the noise my earlier mistake caused.
> Just to clarify the intent of this patch: these SBI constants are
> defined by the RISC-V spec, but they are implemented by kernel.
> IMO, for a userspace developer working on linux it's better to include
> this constants from kernel instead of define them again.
> If you don't like the patch, feel free to ignore it, nothing breaks
> either way.
> Additionally, the goodness of UAPI was described in[1].
>
> [1] https://lwn.net/Articles/507794/
No one is arguing with the benefits of separate UAPI headers, but these
constants are not Linux UAPI. These constants are SBI. If anything,
there should be a header generator developed that takes the SBI spec as
input and creates headers which can be included into any project that
needs them, such as SBI firmwares, Linux, Xen, KVM VMMs, etc.. That
generator could also create Rust constants directly and prepare the
information for any other languages as well.
Thanks,
drew
>
> >>
> >> Hi Paul,
> >>
> >> You're right that we don't want this patch. I hadn't noticed that the same
> >> patch was posted more than once or I would have nacked it here too. I
> >> replied to the other posting[1] a couple weeks ago.
> >>
> >> [1] https://lore.kernel.org/all/20250924-7e9764acec6722b5ef29ce7d@orel/
> >
> > Thanks for the heads up and for the early review. Patchwork didn't pick
> > up the thread for whatever reason beyond the initial patch, and I didn't
> > bother to check the mail archive...
> >
> >
> > - Paul
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-10-09 15:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-17 9:21 [PATCH] riscv: Move user-visible sbi ext ids to uapi BillXiang
2025-10-08 18:17 ` Paul Walmsley
2025-10-08 20:06 ` Andrew Jones
2025-10-08 20:37 ` Paul Walmsley
2025-10-09 7:27 ` BillXiang
2025-10-09 15:07 ` Andrew Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox