mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "BillXiang" <xiangwencheng@lanxincomputing.com>
To: <anup@brainfault.org>
Cc: <kvm-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	 <paul.walmsley@sifive.com>, <palmer@dabbelt.com>,
	 <aou@eecs.berkeley.edu>, <alex@ghiti.fr>, <atishp@rivosinc.com>,
	 <ajones@ventanamicro.com>,
	 "BillXiang" <xiangwencheng@lanxincomputing.com>
Subject: [PATCH] riscv: Move user-visible sbi ext ids to uapi
Date: Wed, 17 Sep 2025 16:52:46 +0800	[thread overview]
Message-ID: <20250917085246.1430354-1-xiangwencheng@lanxincomputing.com> (raw)

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

             reply	other threads:[~2025-09-17  8:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-17  8:52 BillXiang [this message]
2025-09-23 20:14 ` Andrew Jones
2025-09-24  2:35   ` BillXiang
2025-09-24 12:54     ` Andrew Jones
2025-09-25  2:09       ` BillXiang

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=20250917085246.1430354-1-xiangwencheng@lanxincomputing.com \
    --to=xiangwencheng@lanxincomputing.com \
    --cc=ajones@ventanamicro.com \
    --cc=alex@ghiti.fr \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atishp@rivosinc.com \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    /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

all inboxes | Powered by JetHome®