public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13
@ 2025-01-27 13:24 Anup Patel
  2025-01-27 13:24 ` [kvmtool PATCH 1/6] Sync-up headers with Linux-6.13 kernel Anup Patel
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Anup Patel @ 2025-01-27 13:24 UTC (permalink / raw)
  To: Will Deacon, julien.thierry.kdev, maz
  Cc: Paolo Bonzini, Atish Patra, Andrew Jones, Anup Patel, kvm,
	kvm-riscv, Anup Patel

This series adds support for new ISA extensions based on Linux-6.13
namely: Svade, Svadu, Smnpm, and Ssnpm.

These patches can also be found in the riscv_more_exts_round5_v1 branch
at: https://github.com/avpatel/kvmtool.git

Anup Patel (6):
  Sync-up headers with Linux-6.13 kernel
  Add __KERNEL_DIV_ROUND_UP() macro
  riscv: Add Svade extension support
  riscv: Add Svadu extension support
  riscv: Add Smnpm extension support
  riscv: Add Ssnpm extension support

 arm/aarch64/include/asm/kvm.h       |   6 ++
 include/linux/kernel.h              |   3 +
 include/linux/kvm.h                 |   8 ++
 include/linux/virtio_balloon.h      |  16 +++-
 include/linux/virtio_pci.h          | 131 ++++++++++++++++++++++++++++
 riscv/fdt.c                         |   4 +
 riscv/include/asm/kvm.h             |   4 +
 riscv/include/kvm/kvm-config-arch.h |  12 +++
 x86/include/asm/kvm.h               |   2 +
 9 files changed, 184 insertions(+), 2 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [kvmtool PATCH 1/6] Sync-up headers with Linux-6.13 kernel
  2025-01-27 13:24 [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13 Anup Patel
@ 2025-01-27 13:24 ` Anup Patel
  2025-01-27 13:24 ` [kvmtool PATCH 2/6] Add __KERNEL_DIV_ROUND_UP() macro Anup Patel
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Anup Patel @ 2025-01-27 13:24 UTC (permalink / raw)
  To: Will Deacon, julien.thierry.kdev, maz
  Cc: Paolo Bonzini, Atish Patra, Andrew Jones, Anup Patel, kvm,
	kvm-riscv, Anup Patel

We sync-up Linux headers to get latest KVM RISC-V headers having
newly added ISA extensions in ONE_REG interface.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 arm/aarch64/include/asm/kvm.h  |   6 ++
 include/linux/kvm.h            |   8 ++
 include/linux/virtio_balloon.h |  16 +++-
 include/linux/virtio_pci.h     | 131 +++++++++++++++++++++++++++++++++
 riscv/include/asm/kvm.h        |   4 +
 x86/include/asm/kvm.h          |   2 +
 6 files changed, 165 insertions(+), 2 deletions(-)

diff --git a/arm/aarch64/include/asm/kvm.h b/arm/aarch64/include/asm/kvm.h
index 964df31..66736ff 100644
--- a/arm/aarch64/include/asm/kvm.h
+++ b/arm/aarch64/include/asm/kvm.h
@@ -484,6 +484,12 @@ enum {
  */
 #define KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2	(1ULL << 0)
 
+/*
+ * Shutdown caused by a PSCI v1.3 SYSTEM_OFF2 call.
+ * Valid only when the system event has a type of KVM_SYSTEM_EVENT_SHUTDOWN.
+ */
+#define KVM_SYSTEM_EVENT_SHUTDOWN_FLAG_PSCI_OFF2	(1ULL << 0)
+
 /* run->fail_entry.hardware_entry_failure_reason codes. */
 #define KVM_EXIT_FAIL_ENTRY_CPU_UNSUPPORTED	(1ULL << 0)
 
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 637efc0..502ea63 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -1158,7 +1158,15 @@ enum kvm_device_type {
 #define KVM_DEV_TYPE_ARM_PV_TIME	KVM_DEV_TYPE_ARM_PV_TIME
 	KVM_DEV_TYPE_RISCV_AIA,
 #define KVM_DEV_TYPE_RISCV_AIA		KVM_DEV_TYPE_RISCV_AIA
+	KVM_DEV_TYPE_LOONGARCH_IPI,
+#define KVM_DEV_TYPE_LOONGARCH_IPI	KVM_DEV_TYPE_LOONGARCH_IPI
+	KVM_DEV_TYPE_LOONGARCH_EIOINTC,
+#define KVM_DEV_TYPE_LOONGARCH_EIOINTC	KVM_DEV_TYPE_LOONGARCH_EIOINTC
+	KVM_DEV_TYPE_LOONGARCH_PCHPIC,
+#define KVM_DEV_TYPE_LOONGARCH_PCHPIC	KVM_DEV_TYPE_LOONGARCH_PCHPIC
+
 	KVM_DEV_TYPE_MAX,
+
 };
 
 struct kvm_vfio_spapr_tce {
diff --git a/include/linux/virtio_balloon.h b/include/linux/virtio_balloon.h
index ddaa45e..ee35a37 100644
--- a/include/linux/virtio_balloon.h
+++ b/include/linux/virtio_balloon.h
@@ -71,7 +71,13 @@ struct virtio_balloon_config {
 #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
 #define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page allocations */
 #define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
-#define VIRTIO_BALLOON_S_NR       10
+#define VIRTIO_BALLOON_S_OOM_KILL      10 /* OOM killer invocations */
+#define VIRTIO_BALLOON_S_ALLOC_STALL   11 /* Stall count of memory allocatoin */
+#define VIRTIO_BALLOON_S_ASYNC_SCAN    12 /* Amount of memory scanned asynchronously */
+#define VIRTIO_BALLOON_S_DIRECT_SCAN   13 /* Amount of memory scanned directly */
+#define VIRTIO_BALLOON_S_ASYNC_RECLAIM 14 /* Amount of memory reclaimed asynchronously */
+#define VIRTIO_BALLOON_S_DIRECT_RECLAIM 15 /* Amount of memory reclaimed directly */
+#define VIRTIO_BALLOON_S_NR       16
 
 #define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \
 	VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \
@@ -83,7 +89,13 @@ struct virtio_balloon_config {
 	VIRTIO_BALLOON_S_NAMES_prefix "available-memory", \
 	VIRTIO_BALLOON_S_NAMES_prefix "disk-caches", \
 	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \
-	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures" \
+	VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures", \
+	VIRTIO_BALLOON_S_NAMES_prefix "oom-kills", \
+	VIRTIO_BALLOON_S_NAMES_prefix "alloc-stalls", \
+	VIRTIO_BALLOON_S_NAMES_prefix "async-scans", \
+	VIRTIO_BALLOON_S_NAMES_prefix "direct-scans", \
+	VIRTIO_BALLOON_S_NAMES_prefix "async-reclaims", \
+	VIRTIO_BALLOON_S_NAMES_prefix "direct-reclaims" \
 }
 
 #define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("")
diff --git a/include/linux/virtio_pci.h b/include/linux/virtio_pci.h
index a820849..1beb317 100644
--- a/include/linux/virtio_pci.h
+++ b/include/linux/virtio_pci.h
@@ -40,6 +40,7 @@
 #define _LINUX_VIRTIO_PCI_H
 
 #include <linux/types.h>
+#include <linux/kernel.h>
 
 #ifndef VIRTIO_PCI_NO_LEGACY
 
@@ -240,6 +241,17 @@ struct virtio_pci_cfg_cap {
 #define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_READ		0x5
 #define VIRTIO_ADMIN_CMD_LEGACY_NOTIFY_INFO		0x6
 
+/* Device parts access commands. */
+#define VIRTIO_ADMIN_CMD_CAP_ID_LIST_QUERY		0x7
+#define VIRTIO_ADMIN_CMD_DEVICE_CAP_GET			0x8
+#define VIRTIO_ADMIN_CMD_DRIVER_CAP_SET			0x9
+#define VIRTIO_ADMIN_CMD_RESOURCE_OBJ_CREATE		0xa
+#define VIRTIO_ADMIN_CMD_RESOURCE_OBJ_DESTROY		0xd
+#define VIRTIO_ADMIN_CMD_DEV_PARTS_METADATA_GET		0xe
+#define VIRTIO_ADMIN_CMD_DEV_PARTS_GET			0xf
+#define VIRTIO_ADMIN_CMD_DEV_PARTS_SET			0x10
+#define VIRTIO_ADMIN_CMD_DEV_MODE_SET			0x11
+
 struct virtio_admin_cmd_hdr {
 	__le16 opcode;
 	/*
@@ -286,4 +298,123 @@ struct virtio_admin_cmd_notify_info_result {
 	struct virtio_admin_cmd_notify_info_data entries[VIRTIO_ADMIN_CMD_MAX_NOTIFY_INFO];
 };
 
+#define VIRTIO_DEV_PARTS_CAP 0x0000
+
+struct virtio_dev_parts_cap {
+	__u8 get_parts_resource_objects_limit;
+	__u8 set_parts_resource_objects_limit;
+};
+
+#define MAX_CAP_ID __KERNEL_DIV_ROUND_UP(VIRTIO_DEV_PARTS_CAP + 1, 64)
+
+struct virtio_admin_cmd_query_cap_id_result {
+	__le64 supported_caps[MAX_CAP_ID];
+};
+
+struct virtio_admin_cmd_cap_get_data {
+	__le16 id;
+	__u8 reserved[6];
+};
+
+struct virtio_admin_cmd_cap_set_data {
+	__le16 id;
+	__u8 reserved[6];
+	__u8 cap_specific_data[];
+};
+
+struct virtio_admin_cmd_resource_obj_cmd_hdr {
+	__le16 type;
+	__u8 reserved[2];
+	__le32 id; /* Indicates unique resource object id per resource object type */
+};
+
+struct virtio_admin_cmd_resource_obj_create_data {
+	struct virtio_admin_cmd_resource_obj_cmd_hdr hdr;
+	__le64 flags;
+	__u8 resource_obj_specific_data[];
+};
+
+#define VIRTIO_RESOURCE_OBJ_DEV_PARTS 0
+
+#define VIRTIO_RESOURCE_OBJ_DEV_PARTS_TYPE_GET 0
+#define VIRTIO_RESOURCE_OBJ_DEV_PARTS_TYPE_SET 1
+
+struct virtio_resource_obj_dev_parts {
+	__u8 type;
+	__u8 reserved[7];
+};
+
+#define VIRTIO_ADMIN_CMD_DEV_PARTS_METADATA_TYPE_SIZE 0
+#define VIRTIO_ADMIN_CMD_DEV_PARTS_METADATA_TYPE_COUNT 1
+#define VIRTIO_ADMIN_CMD_DEV_PARTS_METADATA_TYPE_LIST 2
+
+struct virtio_admin_cmd_dev_parts_metadata_data {
+	struct virtio_admin_cmd_resource_obj_cmd_hdr hdr;
+	__u8 type;
+	__u8 reserved[7];
+};
+
+#define VIRTIO_DEV_PART_F_OPTIONAL 0
+
+struct virtio_dev_part_hdr {
+	__le16 part_type;
+	__u8 flags;
+	__u8 reserved;
+	union {
+		struct {
+			__le32 offset;
+			__le32 reserved;
+		} pci_common_cfg;
+		struct {
+			__le16 index;
+			__u8 reserved[6];
+		} vq_index;
+	} selector;
+	__le32 length;
+};
+
+struct virtio_dev_part {
+	struct virtio_dev_part_hdr hdr;
+	__u8 value[];
+};
+
+struct virtio_admin_cmd_dev_parts_metadata_result {
+	union {
+		struct {
+			__le32 size;
+			__le32 reserved;
+		} parts_size;
+		struct {
+			__le32 count;
+			__le32 reserved;
+		} hdr_list_count;
+		struct {
+			__le32 count;
+			__le32 reserved;
+			struct virtio_dev_part_hdr hdrs[];
+		} hdr_list;
+	};
+};
+
+#define VIRTIO_ADMIN_CMD_DEV_PARTS_GET_TYPE_SELECTED 0
+#define VIRTIO_ADMIN_CMD_DEV_PARTS_GET_TYPE_ALL 1
+
+struct virtio_admin_cmd_dev_parts_get_data {
+	struct virtio_admin_cmd_resource_obj_cmd_hdr hdr;
+	__u8 type;
+	__u8 reserved[7];
+	struct virtio_dev_part_hdr hdr_list[];
+};
+
+struct virtio_admin_cmd_dev_parts_set_data {
+	struct virtio_admin_cmd_resource_obj_cmd_hdr hdr;
+	struct virtio_dev_part parts[];
+};
+
+#define VIRTIO_ADMIN_CMD_DEV_MODE_F_STOPPED 0
+
+struct virtio_admin_cmd_dev_mode_set_data {
+	__u8 flags;
+};
+
 #endif
diff --git a/riscv/include/asm/kvm.h b/riscv/include/asm/kvm.h
index e97db32..3482c9a 100644
--- a/riscv/include/asm/kvm.h
+++ b/riscv/include/asm/kvm.h
@@ -175,6 +175,10 @@ enum KVM_RISCV_ISA_EXT_ID {
 	KVM_RISCV_ISA_EXT_ZCF,
 	KVM_RISCV_ISA_EXT_ZCMOP,
 	KVM_RISCV_ISA_EXT_ZAWRS,
+	KVM_RISCV_ISA_EXT_SMNPM,
+	KVM_RISCV_ISA_EXT_SSNPM,
+	KVM_RISCV_ISA_EXT_SVADE,
+	KVM_RISCV_ISA_EXT_SVADU,
 	KVM_RISCV_ISA_EXT_MAX,
 };
 
diff --git a/x86/include/asm/kvm.h b/x86/include/asm/kvm.h
index bf57a82..88585c1 100644
--- a/x86/include/asm/kvm.h
+++ b/x86/include/asm/kvm.h
@@ -439,6 +439,8 @@ struct kvm_sync_regs {
 #define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT	(1 << 4)
 #define KVM_X86_QUIRK_FIX_HYPERCALL_INSN	(1 << 5)
 #define KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS	(1 << 6)
+#define KVM_X86_QUIRK_SLOT_ZAP_ALL		(1 << 7)
+#define KVM_X86_QUIRK_STUFF_FEATURE_MSRS	(1 << 8)
 
 #define KVM_STATE_NESTED_FORMAT_VMX	0
 #define KVM_STATE_NESTED_FORMAT_SVM	1
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [kvmtool PATCH 2/6] Add __KERNEL_DIV_ROUND_UP() macro
  2025-01-27 13:24 [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13 Anup Patel
  2025-01-27 13:24 ` [kvmtool PATCH 1/6] Sync-up headers with Linux-6.13 kernel Anup Patel
@ 2025-01-27 13:24 ` Anup Patel
  2025-02-11 11:40   ` Will Deacon
  2025-01-27 13:24 ` [kvmtool PATCH 3/6] riscv: Add Svade extension support Anup Patel
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 10+ messages in thread
From: Anup Patel @ 2025-01-27 13:24 UTC (permalink / raw)
  To: Will Deacon, julien.thierry.kdev, maz
  Cc: Paolo Bonzini, Atish Patra, Andrew Jones, Anup Patel, kvm,
	kvm-riscv, Anup Patel

The latest virtio_pci.h header from Linux-6.13 kernel requires
__KERNEL_DIV_ROUND_UP() macro so define it conditionally in
linux/kernel.h.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 include/linux/kernel.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 6c22f1c..df42d63 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -8,6 +8,9 @@
 #define round_down(x, y)	((x) & ~__round_mask(x, y))
 
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
+#ifndef __KERNEL_DIV_ROUND_UP
+#define __KERNEL_DIV_ROUND_UP(n,d)	DIV_ROUND_UP(n,d)
+#endif
 
 #define ALIGN(x,a)		__ALIGN_MASK(x,(typeof(x))(a)-1)
 #define __ALIGN_MASK(x,mask)	(((x)+(mask))&~(mask))
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [kvmtool PATCH 3/6] riscv: Add Svade extension support
  2025-01-27 13:24 [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13 Anup Patel
  2025-01-27 13:24 ` [kvmtool PATCH 1/6] Sync-up headers with Linux-6.13 kernel Anup Patel
  2025-01-27 13:24 ` [kvmtool PATCH 2/6] Add __KERNEL_DIV_ROUND_UP() macro Anup Patel
@ 2025-01-27 13:24 ` Anup Patel
  2025-01-27 13:24 ` [kvmtool PATCH 4/6] riscv: Add Svadu " Anup Patel
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Anup Patel @ 2025-01-27 13:24 UTC (permalink / raw)
  To: Will Deacon, julien.thierry.kdev, maz
  Cc: Paolo Bonzini, Atish Patra, Andrew Jones, Anup Patel, kvm,
	kvm-riscv, Anup Patel

When the Svade extension is available expose it to the guest
via device tree so that guest can use it.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 riscv/fdt.c                         | 1 +
 riscv/include/kvm/kvm-config-arch.h | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/riscv/fdt.c b/riscv/fdt.c
index 85c8f95..cf0c036 100644
--- a/riscv/fdt.c
+++ b/riscv/fdt.c
@@ -20,6 +20,7 @@ struct isa_ext_info isa_info_arr[] = {
 	{"ssaia", KVM_RISCV_ISA_EXT_SSAIA},
 	{"sscofpmf", KVM_RISCV_ISA_EXT_SSCOFPMF},
 	{"sstc", KVM_RISCV_ISA_EXT_SSTC},
+	{"svade", KVM_RISCV_ISA_EXT_SVADE},
 	{"svinval", KVM_RISCV_ISA_EXT_SVINVAL},
 	{"svnapot", KVM_RISCV_ISA_EXT_SVNAPOT},
 	{"svpbmt", KVM_RISCV_ISA_EXT_SVPBMT},
diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h
index 7a9ca60..5389dff 100644
--- a/riscv/include/kvm/kvm-config-arch.h
+++ b/riscv/include/kvm/kvm-config-arch.h
@@ -37,6 +37,9 @@ struct kvm_config_arch {
 	OPT_BOOLEAN('\0', "disable-sstc",				\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SSTC],	\
 		    "Disable Sstc Extension"),				\
+	OPT_BOOLEAN('\0', "disable-svade",				\
+		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SVADE],	\
+		    "Disable Svade Extension"),				\
 	OPT_BOOLEAN('\0', "disable-svinval",				\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SVINVAL],	\
 		    "Disable Svinval Extension"),			\
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [kvmtool PATCH 4/6] riscv: Add Svadu extension support
  2025-01-27 13:24 [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13 Anup Patel
                   ` (2 preceding siblings ...)
  2025-01-27 13:24 ` [kvmtool PATCH 3/6] riscv: Add Svade extension support Anup Patel
@ 2025-01-27 13:24 ` Anup Patel
  2025-01-27 13:24 ` [kvmtool PATCH 5/6] riscv: Add Smnpm " Anup Patel
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Anup Patel @ 2025-01-27 13:24 UTC (permalink / raw)
  To: Will Deacon, julien.thierry.kdev, maz
  Cc: Paolo Bonzini, Atish Patra, Andrew Jones, Anup Patel, kvm,
	kvm-riscv, Anup Patel

When the Svadu extension is available expose it to the guest
via device tree so that guest can use it.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 riscv/fdt.c                         | 1 +
 riscv/include/kvm/kvm-config-arch.h | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/riscv/fdt.c b/riscv/fdt.c
index cf0c036..7f774f8 100644
--- a/riscv/fdt.c
+++ b/riscv/fdt.c
@@ -21,6 +21,7 @@ struct isa_ext_info isa_info_arr[] = {
 	{"sscofpmf", KVM_RISCV_ISA_EXT_SSCOFPMF},
 	{"sstc", KVM_RISCV_ISA_EXT_SSTC},
 	{"svade", KVM_RISCV_ISA_EXT_SVADE},
+	{"svadu", KVM_RISCV_ISA_EXT_SVADU},
 	{"svinval", KVM_RISCV_ISA_EXT_SVINVAL},
 	{"svnapot", KVM_RISCV_ISA_EXT_SVNAPOT},
 	{"svpbmt", KVM_RISCV_ISA_EXT_SVPBMT},
diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h
index 5389dff..e3eeb84 100644
--- a/riscv/include/kvm/kvm-config-arch.h
+++ b/riscv/include/kvm/kvm-config-arch.h
@@ -40,6 +40,9 @@ struct kvm_config_arch {
 	OPT_BOOLEAN('\0', "disable-svade",				\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SVADE],	\
 		    "Disable Svade Extension"),				\
+	OPT_BOOLEAN('\0', "disable-svadu",				\
+		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SVADU],	\
+		    "Disable Svadu Extension"),				\
 	OPT_BOOLEAN('\0', "disable-svinval",				\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SVINVAL],	\
 		    "Disable Svinval Extension"),			\
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [kvmtool PATCH 5/6] riscv: Add Smnpm extension support
  2025-01-27 13:24 [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13 Anup Patel
                   ` (3 preceding siblings ...)
  2025-01-27 13:24 ` [kvmtool PATCH 4/6] riscv: Add Svadu " Anup Patel
@ 2025-01-27 13:24 ` Anup Patel
  2025-01-27 13:24 ` [kvmtool PATCH 6/6] riscv: Add Ssnpm " Anup Patel
  2025-02-11 11:56 ` [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13 Will Deacon
  6 siblings, 0 replies; 10+ messages in thread
From: Anup Patel @ 2025-01-27 13:24 UTC (permalink / raw)
  To: Will Deacon, julien.thierry.kdev, maz
  Cc: Paolo Bonzini, Atish Patra, Andrew Jones, Anup Patel, kvm,
	kvm-riscv, Anup Patel

When the Smnpm extension is available expose it to the guest
via device tree so that guest can use it.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 riscv/fdt.c                         | 1 +
 riscv/include/kvm/kvm-config-arch.h | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/riscv/fdt.c b/riscv/fdt.c
index 7f774f8..4c9dbc1 100644
--- a/riscv/fdt.c
+++ b/riscv/fdt.c
@@ -16,6 +16,7 @@ struct isa_ext_info {
 
 struct isa_ext_info isa_info_arr[] = {
 	/* sorted alphabetically */
+	{"smnpm", KVM_RISCV_ISA_EXT_SMNPM},
 	{"smstateen", KVM_RISCV_ISA_EXT_SMSTATEEN},
 	{"ssaia", KVM_RISCV_ISA_EXT_SSAIA},
 	{"sscofpmf", KVM_RISCV_ISA_EXT_SSCOFPMF},
diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h
index e3eeb84..5eccdd0 100644
--- a/riscv/include/kvm/kvm-config-arch.h
+++ b/riscv/include/kvm/kvm-config-arch.h
@@ -25,6 +25,9 @@ struct kvm_config_arch {
 	OPT_U64('\0', "custom-mimpid",					\
 		&(cfg)->custom_mimpid,					\
 		"Show custom mimpid to Guest VCPU"),			\
+	OPT_BOOLEAN('\0', "disable-smnpm",				\
+		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SMNPM],	\
+		    "Disable Smnpm Extension"),				\
 	OPT_BOOLEAN('\0', "disable-smstateen",				\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SMSTATEEN],	\
 		    "Disable Smstateen Extension"),			\
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [kvmtool PATCH 6/6] riscv: Add Ssnpm extension support
  2025-01-27 13:24 [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13 Anup Patel
                   ` (4 preceding siblings ...)
  2025-01-27 13:24 ` [kvmtool PATCH 5/6] riscv: Add Smnpm " Anup Patel
@ 2025-01-27 13:24 ` Anup Patel
  2025-02-11 11:56 ` [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13 Will Deacon
  6 siblings, 0 replies; 10+ messages in thread
From: Anup Patel @ 2025-01-27 13:24 UTC (permalink / raw)
  To: Will Deacon, julien.thierry.kdev, maz
  Cc: Paolo Bonzini, Atish Patra, Andrew Jones, Anup Patel, kvm,
	kvm-riscv, Anup Patel

When the Ssnpm extension is available expose it to the guest
via device tree so that guest can use it.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 riscv/fdt.c                         | 1 +
 riscv/include/kvm/kvm-config-arch.h | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/riscv/fdt.c b/riscv/fdt.c
index 4c9dbc1..03113cc 100644
--- a/riscv/fdt.c
+++ b/riscv/fdt.c
@@ -20,6 +20,7 @@ struct isa_ext_info isa_info_arr[] = {
 	{"smstateen", KVM_RISCV_ISA_EXT_SMSTATEEN},
 	{"ssaia", KVM_RISCV_ISA_EXT_SSAIA},
 	{"sscofpmf", KVM_RISCV_ISA_EXT_SSCOFPMF},
+	{"ssnpm", KVM_RISCV_ISA_EXT_SSNPM},
 	{"sstc", KVM_RISCV_ISA_EXT_SSTC},
 	{"svade", KVM_RISCV_ISA_EXT_SVADE},
 	{"svadu", KVM_RISCV_ISA_EXT_SVADU},
diff --git a/riscv/include/kvm/kvm-config-arch.h b/riscv/include/kvm/kvm-config-arch.h
index 5eccdd0..e56610b 100644
--- a/riscv/include/kvm/kvm-config-arch.h
+++ b/riscv/include/kvm/kvm-config-arch.h
@@ -37,6 +37,9 @@ struct kvm_config_arch {
 	OPT_BOOLEAN('\0', "disable-sscofpmf",				\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SSCOFPMF],	\
 		    "Disable Sscofpmf Extension"),			\
+	OPT_BOOLEAN('\0', "disable-ssnpm",				\
+		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SSNPM],	\
+		    "Disable Ssnpm Extension"),				\
 	OPT_BOOLEAN('\0', "disable-sstc",				\
 		    &(cfg)->ext_disabled[KVM_RISCV_ISA_EXT_SSTC],	\
 		    "Disable Sstc Extension"),				\
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [kvmtool PATCH 2/6] Add __KERNEL_DIV_ROUND_UP() macro
  2025-01-27 13:24 ` [kvmtool PATCH 2/6] Add __KERNEL_DIV_ROUND_UP() macro Anup Patel
@ 2025-02-11 11:40   ` Will Deacon
  2025-02-11 11:58     ` Anup Patel
  0 siblings, 1 reply; 10+ messages in thread
From: Will Deacon @ 2025-02-11 11:40 UTC (permalink / raw)
  To: Anup Patel
  Cc: julien.thierry.kdev, maz, Paolo Bonzini, Atish Patra,
	Andrew Jones, Anup Patel, kvm, kvm-riscv

On Mon, Jan 27, 2025 at 06:54:20PM +0530, Anup Patel wrote:
> The latest virtio_pci.h header from Linux-6.13 kernel requires
> __KERNEL_DIV_ROUND_UP() macro so define it conditionally in
> linux/kernel.h.
> 
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> ---
>  include/linux/kernel.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 6c22f1c..df42d63 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -8,6 +8,9 @@
>  #define round_down(x, y)	((x) & ~__round_mask(x, y))
>  
>  #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
> +#ifndef __KERNEL_DIV_ROUND_UP
> +#define __KERNEL_DIV_ROUND_UP(n,d)	DIV_ROUND_UP(n,d)
> +#endif

I'm happy to take this for now, but perhaps we should be pulling
in the uapi const.h header instead of rolling this ourselves? Ideally,
kernel.h would disappear altogether.

Will

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13
  2025-01-27 13:24 [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13 Anup Patel
                   ` (5 preceding siblings ...)
  2025-01-27 13:24 ` [kvmtool PATCH 6/6] riscv: Add Ssnpm " Anup Patel
@ 2025-02-11 11:56 ` Will Deacon
  6 siblings, 0 replies; 10+ messages in thread
From: Will Deacon @ 2025-02-11 11:56 UTC (permalink / raw)
  To: julien.thierry.kdev, maz, Anup Patel
  Cc: catalin.marinas, kernel-team, Will Deacon, Paolo Bonzini,
	Atish Patra, Andrew Jones, Anup Patel, kvm, kvm-riscv

On Mon, 27 Jan 2025 18:54:18 +0530, Anup Patel wrote:
> This series adds support for new ISA extensions based on Linux-6.13
> namely: Svade, Svadu, Smnpm, and Ssnpm.
> 
> These patches can also be found in the riscv_more_exts_round5_v1 branch
> at: https://github.com/avpatel/kvmtool.git
> 
> Anup Patel (6):
>   Sync-up headers with Linux-6.13 kernel
>   Add __KERNEL_DIV_ROUND_UP() macro
>   riscv: Add Svade extension support
>   riscv: Add Svadu extension support
>   riscv: Add Smnpm extension support
>   riscv: Add Ssnpm extension support
> 
> [...]

Applied to kvmtool (master), thanks!

[1/6] Sync-up headers with Linux-6.13 kernel
      https://git.kernel.org/will/kvmtool/c/4b2cc0660ef3
[2/6] Add __KERNEL_DIV_ROUND_UP() macro
      https://git.kernel.org/will/kvmtool/c/66567918472f
[3/6] riscv: Add Svade extension support
      https://git.kernel.org/will/kvmtool/c/f8ed03217263
[4/6] riscv: Add Svadu extension support
      https://git.kernel.org/will/kvmtool/c/521b1b676e5c
[5/6] riscv: Add Smnpm extension support
      https://git.kernel.org/will/kvmtool/c/4489348c961b
[6/6] riscv: Add Ssnpm extension support
      https://git.kernel.org/will/kvmtool/c/e48563f5c4a4

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [kvmtool PATCH 2/6] Add __KERNEL_DIV_ROUND_UP() macro
  2025-02-11 11:40   ` Will Deacon
@ 2025-02-11 11:58     ` Anup Patel
  0 siblings, 0 replies; 10+ messages in thread
From: Anup Patel @ 2025-02-11 11:58 UTC (permalink / raw)
  To: Will Deacon
  Cc: julien.thierry.kdev, maz, Paolo Bonzini, Atish Patra,
	Andrew Jones, Anup Patel, kvm, kvm-riscv

On Tue, Feb 11, 2025 at 5:10 PM Will Deacon <will@kernel.org> wrote:
>
> On Mon, Jan 27, 2025 at 06:54:20PM +0530, Anup Patel wrote:
> > The latest virtio_pci.h header from Linux-6.13 kernel requires
> > __KERNEL_DIV_ROUND_UP() macro so define it conditionally in
> > linux/kernel.h.
> >
> > Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> > ---
> >  include/linux/kernel.h | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> > index 6c22f1c..df42d63 100644
> > --- a/include/linux/kernel.h
> > +++ b/include/linux/kernel.h
> > @@ -8,6 +8,9 @@
> >  #define round_down(x, y)     ((x) & ~__round_mask(x, y))
> >
> >  #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
> > +#ifndef __KERNEL_DIV_ROUND_UP
> > +#define __KERNEL_DIV_ROUND_UP(n,d)   DIV_ROUND_UP(n,d)
> > +#endif
>
> I'm happy to take this for now, but perhaps we should be pulling
> in the uapi const.h header instead of rolling this ourselves? Ideally,
> kernel.h would disappear altogether.
>

Sure, next time I will try to pull the uapi const.h header into kvmtool.

Thanks,
Anup

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-02-11 11:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-27 13:24 [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13 Anup Patel
2025-01-27 13:24 ` [kvmtool PATCH 1/6] Sync-up headers with Linux-6.13 kernel Anup Patel
2025-01-27 13:24 ` [kvmtool PATCH 2/6] Add __KERNEL_DIV_ROUND_UP() macro Anup Patel
2025-02-11 11:40   ` Will Deacon
2025-02-11 11:58     ` Anup Patel
2025-01-27 13:24 ` [kvmtool PATCH 3/6] riscv: Add Svade extension support Anup Patel
2025-01-27 13:24 ` [kvmtool PATCH 4/6] riscv: Add Svadu " Anup Patel
2025-01-27 13:24 ` [kvmtool PATCH 5/6] riscv: Add Smnpm " Anup Patel
2025-01-27 13:24 ` [kvmtool PATCH 6/6] riscv: Add Ssnpm " Anup Patel
2025-02-11 11:56 ` [kvmtool PATCH 0/6] Add RISC-V ISA extensions based on Linux-6.13 Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox