target/riscv: Apply KVM policy to ISA extensions
cover target/riscv: Apply KVM policy to ISA extensions
Currently the single and multi letter ISA extensions exposed to the guest vcpu don't confirm to the KVM policies. This patchset updates the kvm headers and applies policies set in KVM to the extensions exposed to the guest.
Mayuresh Chitale (3):
update-linux-headers: Version 6.1-rc2
target/riscv: Extend isa_ext_data for single letter extensions target/riscv: kvm: Support selecting VCPU extensions
include/standard-headers/drm/drm_fourcc.h | 34 ++++- include/standard-headers/linux/ethtool.h | 63 +++++++- include/standard-headers/linux/fuse.h | 6 +- .../linux/input-event-codes.h | 1 + include/standard-headers/linux/virtio_blk.h | 19 +++ linux-headers/asm-generic/hugetlb_encode.h | 26 ++-- linux-headers/asm-generic/mman-common.h | 2 + linux-headers/asm-mips/mman.h | 2 + linux-headers/asm-riscv/kvm.h | 4 + linux-headers/linux/kvm.h | 1 + linux-headers/linux/psci.h | 14 ++ linux-headers/linux/userfaultfd.h | 4 + linux-headers/linux/vfio.h | 142 ++++++++++++++++++ target/riscv/cpu.c | 52 ++++--- target/riscv/kvm.c | 88 +++++++++-- target/riscv/kvm_riscv.h | 2 +- 16 files changed, 408 insertions(+), 52 deletions(-)
Signature · 1 line
2.34.1
PATCH 3/3 target/riscv: kvm: Support selecting VCPU extensions
Set the state of each ISA extension on the vcpu depending on what is set in the CPU property and what is allowed by KVM for that extension.
--- target/riscv/cpu.c | 11 ++++- target/riscv/kvm.c | 88 ++++++++++++++++++++++++++++++++++------ target/riscv/kvm_riscv.h | 2 +- 3 files changed, 87 insertions(+), 14 deletions(-)
target/riscv/cpu.c +10 -1
@@ -1191,10 +1191,19 @@ static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str) {char *old = *isa_str;char *new = *isa_str; -int i; +int i, offset;for (i =0 ; i <ARRAY_SIZE (isa_edata_arr); i++) {if (isa_ext_is_enabled (cpu, &isa_edata_arr[i])) { + offset = isa_edata_arr[i].ext_enable_offset; +if (kvm_enabled () && !kvm_riscv_ext_supported (offset)) { +#ifndef CONFIG_USER_ONLY +info_report ("disabling %s extension for hart 0x%lx because " +"kvm does not support it" , isa_edata_arr[i].name, + (unsigned long )cpu->env.mhartid); +#endif +continue ; + }if (isa_edata_arr[i].multi_letter) {if (cpu->cfg.short_isa_string) {continue ;
target/riscv/kvm.c +76 -12
107 lines not on this page · raw message
target/riscv/kvm_riscv.h +1 -1
@@ -21,5 +21,5 @@void kvm_riscv_reset_vcpu (RISCVCPU *cpu);void kvm_riscv_set_irq (RISCVCPU *cpu,int irq,int level); - +bool kvm_riscv_ext_supported (int offset);#endif
Signature · 1 line
2.34.1
PATCH 1/3 update-linux-headers: Version 6.1-rc2
In reply to Mayuresh ChitaleSync headers with kernel commit 247f34f7b803
--- include/standard-headers/drm/drm_fourcc.h | 34 ++++- include/standard-headers/linux/ethtool.h | 63 +++++++- include/standard-headers/linux/fuse.h | 6 +- .../linux/input-event-codes.h | 1 + include/standard-headers/linux/virtio_blk.h | 19 +++ linux-headers/asm-generic/hugetlb_encode.h | 26 ++-- linux-headers/asm-generic/mman-common.h | 2 + linux-headers/asm-mips/mman.h | 2 + linux-headers/asm-riscv/kvm.h | 4 + linux-headers/linux/kvm.h | 1 + linux-headers/linux/psci.h | 14 ++ linux-headers/linux/userfaultfd.h | 4 + linux-headers/linux/vfio.h | 142 ++++++++++++++++++ 13 files changed, 298 insertions(+), 20 deletions(-)
include/standard-headers/drm/drm_fourcc.h +30 -4
@@ -98,18 +98,42 @@ extern "C" {#define DRM_FORMAT_INVALID 0/* color index */ +#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ')/* [7:0] C0:C1:C2:C3:C4:C5:C6:C7 1:1:1:1:1:1:1:1 eight pixels/byte */ +#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ')/* [7:0] C0:C1:C2:C3 2:2:2:2 four pixels/byte */ +#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ')/* [7:0] C0:C1 4:4 two pixels/byte */ #define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ')/* [7:0] C */ -/* 8 bpp Red */ +/* 1 bpp Darkness (inverse relationship between channel value and brightness) */ +#define DRM_FORMAT_D1 fourcc_code('D', '1', ' ', ' ')/* [7:0] D0:D1:D2:D3:D4:D5:D6:D7 1:1:1:1:1:1:1:1 eight pixels/byte */ + +/* 2 bpp Darkness (inverse relationship between channel value and brightness) */ +#define DRM_FORMAT_D2 fourcc_code('D', '2', ' ', ' ')/* [7:0] D0:D1:D2:D3 2:2:2:2 four pixels/byte */ + +/* 4 bpp Darkness (inverse relationship between channel value and brightness) */ +#define DRM_FORMAT_D4 fourcc_code('D', '4', ' ', ' ')/* [7:0] D0:D1 4:4 two pixels/byte */ + +/* 8 bpp Darkness (inverse relationship between channel value and brightness) */ +#define DRM_FORMAT_D8 fourcc_code('D', '8', ' ', ' ')/* [7:0] D */ + +/* 1 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ')/* [7:0] R0:R1:R2:R3:R4:R5:R6:R7 1:1:1:1:1:1:1:1 eight pixels/byte */ + +/* 2 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R2 fourcc_code('R', '2', ' ', ' ')/* [7:0] R0:R1:R2:R3 2:2:2:2 four pixels/byte */ + +/* 4 bpp Red (direct relationship between channel value and brightness) */ +#define DRM_FORMAT_R4 fourcc_code('R', '4', ' ', ' ')/* [7:0] R0:R1 4:4 two pixels/byte */ + +/* 8 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ')/* [7:0] R */ -/* 10 bpp Red */ +/* 10 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R10 fourcc_code('R', '1', '0', ' ')/* [15:0] x:R 6:10 little endian */ -/* 12 bpp Red */ +/* 12 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R12 fourcc_code('R', '1', '2', ' ')/* [15:0] x:R 4:12 little endian */ -/* 16 bpp Red */ +/* 16 bpp Red (direct relationship between channel value and brightness) */ #define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ')/* [15:0] R little endian */ /* 16 bpp RG */
@@ -204,7 +228,9 @@ extern "C" {#define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y')/* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */ #define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V')/* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */ +#define DRM_FORMAT_AVUY8888 fourcc_code('A', 'V', 'U', 'Y')/* [31:0] A:Cr:Cb:Y 8:8:8:8 little endian */ #define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V')/* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */ +#define DRM_FORMAT_XVUY8888 fourcc_code('X', 'V', 'U', 'Y')/* [31:0] X:Cr:Cb:Y 8:8:8:8 little endian */ #define DRM_FORMAT_VUY888 fourcc_code('V', 'U', '2', '4')/* [23:0] Cr:Cb:Y 8:8:8 little endian */ #define DRM_FORMAT_VUY101010 fourcc_code('V', 'U', '3', '0')/* Y followed by U then V, 10:10:10. Non-linear modifier only */
include/standard-headers/linux/ethtool.h +61 -2
88 lines not on this page · raw message
include/standard-headers/linux/fuse.h +5 -1
@@ -194,6 +194,9 @@* - add FUSE_SECURITY_CTX init flag * - add security context to create, mkdir, symlink, and mknod requests * - add FUSE_HAS_INODE_DAX, FUSE_ATTR_DAX +* +* 7.37 +* - add FUSE_TMPFILE */ #ifndef _LINUX_FUSE_H
@@ -225,7 +228,7 @@#define FUSE_KERNEL_VERSION 7/** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 36 +#define FUSE_KERNEL_MINOR_VERSION 37/** The node ID of the root inode */ #define FUSE_ROOT_ID 1
@@ -533,6 +536,7 @@ enum fuse_opcode {FUSE_SETUPMAPPING =48 ,FUSE_REMOVEMAPPING =49 ,FUSE_SYNCFS =50 , +FUSE_TMPFILE =51 ,/* CUSE specific operations */ CUSE_INIT = 4096,
include/standard-headers/linux/input-event-codes.h +1 -0
@@ -862,6 +862,7 @@#define ABS_TOOL_WIDTH 0x1c#define ABS_VOLUME 0x20 +#define ABS_PROFILE 0x21#define ABS_MISC 0x28
include/standard-headers/linux/virtio_blk.h +19 -0
@@ -40,6 +40,7 @@#define VIRTIO_BLK_F_MQ 12/* support more than one vq */ #define VIRTIO_BLK_F_DISCARD 13/* DISCARD is supported */ #define VIRTIO_BLK_F_WRITE_ZEROES 14/* WRITE ZEROES is supported */ +#define VIRTIO_BLK_F_SECURE_ERASE 16/* Secure Erase is supported */ /* Legacy feature bits */ #ifndef VIRTIO_BLK_NO_LEGACY
@@ -119,6 +120,21 @@ struct virtio_blk_config {uint8_t write_zeroes_may_unmap;uint8_t unused1[3 ]; + +/* the next 3 entries are guarded by VIRTIO_BLK_F_SECURE_ERASE */ +/* +* The maximum secure erase sectors (in 512-byte sectors) for +* one segment. +*/ +__virtio32 max_secure_erase_sectors; +/* +* The maximum number of secure erase segments in a +* secure erase command. +*/ +__virtio32 max_secure_erase_seg; +/* Secure erase commands must be aligned to this number of sectors. */ +__virtio32 secure_erase_sector_alignment; + }QEMU_PACKED ;/*
@@ -153,6 +169,9 @@ struct virtio_blk_config {/* Write zeroes command */ #define VIRTIO_BLK_T_WRITE_ZEROES 13 +/* Secure erase command */ +#define VIRTIO_BLK_T_SECURE_ERASE 14 +#ifndef VIRTIO_BLK_NO_LEGACY /* Barrier before this op. */ #define VIRTIO_BLK_T_BARRIER 0x80000000
linux-headers/asm-generic/hugetlb_encode.h +13 -13
@@ -20,18 +20,18 @@#define HUGETLB_FLAG_ENCODE_SHIFT 26#define HUGETLB_FLAG_ENCODE_MASK 0x3f -#define HUGETLB_FLAG_ENCODE_16KB (14 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_64KB (16 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_512KB (19 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_1MB (20 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_2MB (21 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_8MB (23 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_16MB (24 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_32MB (25 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_256MB (28 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_512MB (29 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_1GB (30 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_2GB (31 << HUGETLB_FLAG_ENCODE_SHIFT) -#define HUGETLB_FLAG_ENCODE_16GB (34 << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_16KB (14U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_64KB (16U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_512KB (19U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_1MB (20U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_2MB (21U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_8MB (23U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_16MB (24U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_32MB (25U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_256MB (28U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_512MB (29U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_1GB (30U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_2GB (31U << HUGETLB_FLAG_ENCODE_SHIFT) +#define HUGETLB_FLAG_ENCODE_16GB (34U << HUGETLB_FLAG_ENCODE_SHIFT)#endif /* _ASM_GENERIC_HUGETLB_ENCODE_H_ */
linux-headers/asm-generic/mman-common.h +2 -0
@@ -77,6 +77,8 @@#define MADV_DONTNEED_LOCKED 24/* like DONTNEED, but drop locked pages too */ +#define MADV_COLLAPSE 25/* Synchronous hugepage collapse */ +/* compatibility flags */ #define MAP_FILE 0
linux-headers/asm-mips/mman.h +2 -0
@@ -103,6 +103,8 @@#define MADV_DONTNEED_LOCKED 24/* like DONTNEED, but drop locked pages too */ +#define MADV_COLLAPSE 25/* Synchronous hugepage collapse */ +/* compatibility flags */ #define MAP_FILE 0
linux-headers/asm-riscv/kvm.h +4 -0
@@ -48,6 +48,7 @@ struct kvm_sregs {/* CONFIG registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ struct kvm_riscv_config {unsigned long isa; +unsigned long zicbom_block_size; };/* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
@@ -98,6 +99,9 @@ enum KVM_RISCV_ISA_EXT_ID {KVM_RISCV_ISA_EXT_M ,KVM_RISCV_ISA_EXT_SVPBMT ,KVM_RISCV_ISA_EXT_SSTC , +KVM_RISCV_ISA_EXT_SVINVAL , +KVM_RISCV_ISA_EXT_ZIHINTPAUSE , +KVM_RISCV_ISA_EXT_ZICBOM , KVM_RISCV_ISA_EXT_MAX, };
linux-headers/linux/kvm.h +1 -0
@@ -1175,6 +1175,7 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220#define KVM_CAP_S390_ZPCI_OP 221#define KVM_CAP_S390_CPU_TOPOLOGY 222 +#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223#ifdef KVM_CAP_IRQ_ROUTING
linux-headers/linux/psci.h +14 -0
@@ -48,12 +48,26 @@#define PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU PSCI_0_2_FN64(7)#define PSCI_1_0_FN_PSCI_FEATURES PSCI_0_2_FN(10) +#define PSCI_1_0_FN_CPU_FREEZE PSCI_0_2_FN(11) +#define PSCI_1_0_FN_CPU_DEFAULT_SUSPEND PSCI_0_2_FN(12) +#define PSCI_1_0_FN_NODE_HW_STATE PSCI_0_2_FN(13)#define PSCI_1_0_FN_SYSTEM_SUSPEND PSCI_0_2_FN(14)#define PSCI_1_0_FN_SET_SUSPEND_MODE PSCI_0_2_FN(15) +#define PSCI_1_0_FN_STAT_RESIDENCY PSCI_0_2_FN(16) +#define PSCI_1_0_FN_STAT_COUNT PSCI_0_2_FN(17) +#define PSCI_1_1_FN_SYSTEM_RESET2 PSCI_0_2_FN(18) +#define PSCI_1_1_FN_MEM_PROTECT PSCI_0_2_FN(19) +#define PSCI_1_1_FN_MEM_PROTECT_CHECK_RANGE PSCI_0_2_FN(19) +#define PSCI_1_0_FN64_CPU_DEFAULT_SUSPEND PSCI_0_2_FN64(12) +#define PSCI_1_0_FN64_NODE_HW_STATE PSCI_0_2_FN64(13)#define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14) +#define PSCI_1_0_FN64_STAT_RESIDENCY PSCI_0_2_FN64(16) +#define PSCI_1_0_FN64_STAT_COUNT PSCI_0_2_FN64(17) +#define PSCI_1_1_FN64_SYSTEM_RESET2 PSCI_0_2_FN64(18) +#define PSCI_1_1_FN64_MEM_PROTECT_CHECK_RANGE PSCI_0_2_FN64(19)/* PSCI v0.2 power state encoding for CPU_SUSPEND function */ #define PSCI_0_2_POWER_STATE_ID_MASK 0xffff
linux-headers/linux/userfaultfd.h +4 -0
@@ -12,6 +12,10 @@#include <linux/types.h> +/* ioctls for /dev/userfaultfd */ +#define USERFAULTFD_IOC 0xAA +#define USERFAULTFD_IOC_NEW _IO(USERFAULTFD_IOC, 0x00) +/* * If the UFFDIO_API is upgraded someday, the UFFDIO_UNREGISTER and * UFFDIO_WAKE ioctls should be defined as _IOW and not as _IOR. In
linux-headers/linux/vfio.h +142 -0
148 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH 2/3 target/riscv: Extend isa_ext_data for single letter extensions
In reply to Mayuresh ChitaleCurrently the ISA string for a CPU is generated from two different arrays, one for single letter extensions and another for multi letter extensions. Add all the single letter extensions to the isa_ext_data array and use it for generating the ISA string. Also drop 'P' and 'Q' extensions from the list of single letter extensions as those are not supported yet.
--- target/riscv/cpu.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-)
target/riscv/cpu.c +23 -18
@@ -41,8 +41,6 @@ (QEMU_VERSION_MICRO))#define RISCV_CPU_MIMPID RISCV_CPU_MARCHID -static const char riscv_single_letter_exts[] ="IEMAFDQCPVH" ; -struct isa_ext_data {const char *name;bool multi_letter;
@@ -71,6 +69,13 @@ struct isa_ext_data {* extensions by an underscore. */ static const struct isa_ext_data isa_edata_arr[] = { +ISA_EXT_DATA_ENTRY (i, false,PRIV_VERSION_1_10_0 , ext_i), +ISA_EXT_DATA_ENTRY (e, false,PRIV_VERSION_1_10_0 , ext_e), +ISA_EXT_DATA_ENTRY (m, false,PRIV_VERSION_1_10_0 , ext_m), +ISA_EXT_DATA_ENTRY (a, false,PRIV_VERSION_1_10_0 , ext_a), +ISA_EXT_DATA_ENTRY (f, false,PRIV_VERSION_1_10_0 , ext_f), +ISA_EXT_DATA_ENTRY (d, false,PRIV_VERSION_1_10_0 , ext_d), +ISA_EXT_DATA_ENTRY (c, false,PRIV_VERSION_1_10_0 , ext_c),ISA_EXT_DATA_ENTRY (h, false,PRIV_VERSION_1_12_0 , ext_h),ISA_EXT_DATA_ENTRY (v, false,PRIV_VERSION_1_12_0 , ext_v),ISA_EXT_DATA_ENTRY (zicsr, true,PRIV_VERSION_1_10_0 , ext_icsr),
@@ -1182,16 +1187,23 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)device_class_set_props (dc, riscv_cpu_properties); } -static void riscv_isa_string_ext (RISCVCPU *cpu,char **isa_str,int max_str_len) +static void riscv_isa_string_ext (RISCVCPU *cpu,char **isa_str) {char *old = *isa_str;char *new = *isa_str;int i;for (i =0 ; i <ARRAY_SIZE (isa_edata_arr); i++) { -if (isa_edata_arr[i].multi_letter && -isa_ext_is_enabled (cpu, &isa_edata_arr[i])) { - new =g_strconcat (old,"_" , isa_edata_arr[i].name,NULL ); +if (isa_ext_is_enabled (cpu, &isa_edata_arr[i])) { +if (isa_edata_arr[i].multi_letter) { +if (cpu->cfg.short_isa_string) { +continue ; + } + new =g_strconcat (old,"_" , isa_edata_arr[i].name,NULL ); + }else { + new =g_strconcat (old, isa_edata_arr[i].name,NULL ); + } +g_free (old); old = new; }
@@ -1202,19 +1214,12 @@ static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str, int max_str_len)char *riscv_isa_string (RISCVCPU *cpu) { -int i; -const size_t maxlen =sizeof ("rv128" ) +sizeof (riscv_single_letter_exts); +const size_t maxlen =sizeof ("rv128" );char *isa_str =g_new (char, maxlen); -char *p = isa_str +snprintf (isa_str, maxlen,"rv%d" ,TARGET_LONG_BITS ); -for (i =0 ; i <sizeof (riscv_single_letter_exts) -1 ; i++) { -if (cpu->env.misa_ext &RV (riscv_single_letter_exts[i])) { - *p++ =qemu_tolower (riscv_single_letter_exts[i]); - } - } - *p ='\0' ; -if (!cpu->cfg.short_isa_string) { -riscv_isa_string_ext (cpu, &isa_str, maxlen); - } + +snprintf (isa_str, maxlen,"rv%d" ,TARGET_LONG_BITS ); +riscv_isa_string_ext (cpu, &isa_str); +return isa_str; }
Signature · 1 line
2.34.1
Quoted 10 lines · Mayuresh Chitale
Currently the single and multi letter ISA extensions exposed to the guest vcpu don't confirm to the KVM policies. This patchset updates the kvm headers and applies policies set in KVM to the extensions exposed to the guest.
Mayuresh Chitale (3):
update-linux-headers: Version 6.1-rc2
target/riscv: Extendisa_ext_datafor single letter extensions target/riscv: kvm: Support selecting VCPU extensions
I already reviewed this internally and it hasn't changed, so
for the series
Thanks,
drew
Re: [PATCH v1 2/3] target/riscv: Extend isa_ext_data for single letter extensions
In reply to Mayuresh ChitaleQuoted 9 lines · Mayuresh Chitale
Currently the ISA string for a CPU is generated from two different arrays, one for single letter extensions and another for multi letter extensions. Add all the single letter extensions to the
isa_ext_dataarray and use it for generating the ISA string. Also drop 'P' and 'Q' extensions from the list of single letter extensions as those are not supported yet.Signed-off-by Mayuresh Chitale <[email protected]>
Alistair
Quoted 88 lines
--- target/riscv/cpu.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-)target/riscv/cpu.c +23
-19@@ -41,8 +41,6 @@ (QEMU_VERSION_MICRO))#define RISCV_CPU_MIMPID RISCV_CPU_MARCHID -static const char riscv_single_letter_exts[] ="IEMAFDQCPVH" ; -struct isa_ext_data {const char *name;bool multi_letter;@@ -71,6 +69,13 @@ struct isa_ext_data {* extensions by an underscore. */ static const struct isa_ext_data isa_edata_arr[] = { +ISA_EXT_DATA_ENTRY (i, false,PRIV_VERSION_1_10_0 , ext_i), +ISA_EXT_DATA_ENTRY (e, false,PRIV_VERSION_1_10_0 , ext_e), +ISA_EXT_DATA_ENTRY (m, false,PRIV_VERSION_1_10_0 , ext_m), +ISA_EXT_DATA_ENTRY (a, false,PRIV_VERSION_1_10_0 , ext_a), +ISA_EXT_DATA_ENTRY (f, false,PRIV_VERSION_1_10_0 , ext_f), +ISA_EXT_DATA_ENTRY (d, false,PRIV_VERSION_1_10_0 , ext_d), +ISA_EXT_DATA_ENTRY (c, false,PRIV_VERSION_1_10_0 , ext_c),ISA_EXT_DATA_ENTRY (h, false,PRIV_VERSION_1_12_0 , ext_h),ISA_EXT_DATA_ENTRY (v, false,PRIV_VERSION_1_12_0 , ext_v),ISA_EXT_DATA_ENTRY (zicsr, true,PRIV_VERSION_1_10_0 , ext_icsr),@@ -1182,16 +1187,23 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)device_class_set_props (dc, riscv_cpu_properties); } -static void riscv_isa_string_ext (RISCVCPU *cpu,char **isa_str,int max_str_len) +static void riscv_isa_string_ext (RISCVCPU *cpu,char **isa_str) {char *old = *isa_str;char *new = *isa_str;int i;for (i =0 ; i <ARRAY_SIZE (isa_edata_arr); i++) { -if (isa_edata_arr[i].multi_letter && -isa_ext_is_enabled (cpu, &isa_edata_arr[i])) { - new =g_strconcat (old,"_" , isa_edata_arr[i].name,NULL ); +if (isa_ext_is_enabled (cpu, &isa_edata_arr[i])) { +if (isa_edata_arr[i].multi_letter) { +if (cpu->cfg.short_isa_string) { +continue ; + } + new =g_strconcat (old,"_" , isa_edata_arr[i].name,NULL ); + }else { + new =g_strconcat (old, isa_edata_arr[i].name,NULL ); + } +g_free (old); old = new; }@@ -1202,19 +1214,12 @@ static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str, int max_str_len)char *riscv_isa_string (RISCVCPU *cpu) { -int i; -const size_t maxlen =sizeof ("rv128" ) +sizeof (riscv_single_letter_exts); +const size_t maxlen =sizeof ("rv128" );char *isa_str =g_new (char, maxlen); -char *p = isa_str +snprintf (isa_str, maxlen,"rv%d" ,TARGET_LONG_BITS ); -for (i =0 ; i <sizeof (riscv_single_letter_exts) -1 ; i++) { -if (cpu->env.misa_ext &RV (riscv_single_letter_exts[i])) { - *p++ =qemu_tolower (riscv_single_letter_exts[i]); - } - } - *p ='\0' ; -if (!cpu->cfg.short_isa_string) { -riscv_isa_string_ext (cpu, &isa_str, maxlen); - } + +snprintf (isa_str, maxlen,"rv%d" ,TARGET_LONG_BITS ); +riscv_isa_string_ext (cpu, &isa_str); +return isa_str; } --2.34.1
Re: [PATCH v1 3/3] target/riscv: kvm: Support selecting VCPU extensions
In reply to Mayuresh ChitaleQuoted 5 lines · Mayuresh Chitale
Set the state of each ISA extension on the vcpu depending on what is set in the CPU property and what is allowed by KVM for that extension.
Signed-off-by Mayuresh Chitale <[email protected]>
Alistair
Quoted 159 lines
--- target/riscv/cpu.c | 11 ++++- target/riscv/kvm.c | 88 ++++++++++++++++++++++++++++++++++------ target/riscv/kvm_riscv.h | 2 +- 3 files changed, 87 insertions(+), 14 deletions(-)target/riscv/cpu.c +10
-1@@ -1191,10 +1191,19 @@ static void riscv_isa_string_ext(RISCVCPU *cpu, char **isa_str) {char *old = *isa_str;char *new = *isa_str; -int i; +int i, offset;for (i =0 ; i <ARRAY_SIZE (isa_edata_arr); i++) {if (isa_ext_is_enabled (cpu, &isa_edata_arr[i])) { + offset = isa_edata_arr[i].ext_enable_offset; +if (kvm_enabled () && !kvm_riscv_ext_supported (offset)) { +#ifndef CONFIG_USER_ONLY +info_report ("disabling %s extension for hart 0x%lx because " +"kvm does not support it" , isa_edata_arr[i].name, + (unsigned long )cpu->env.mhartid); +#endif +continue ; + }if (isa_edata_arr[i].multi_letter) {if (cpu->cfg.short_isa_string) {continue ;target/riscv/kvm.c +76
-12@@ -42,6 +42,29 @@#include "migration/migration.h" #include "sysemu/runstate.h" +struct isa_ext_info { +const char *name; +target_ulong misa_bit; +int ext_enable_offset; +}; + +#define ISA_EXT_DATA_ENTRY (_name, _bit, _prop) \ + {#_name, _bit, offsetof(struct RISCVCPUConfig, _prop)} + +static const struct isa_ext_info isa_info_arr[] = { +ISA_EXT_DATA_ENTRY (a,RVA , ext_a), +ISA_EXT_DATA_ENTRY (c,RVC , ext_c), +ISA_EXT_DATA_ENTRY (d,RVD , ext_d), +ISA_EXT_DATA_ENTRY (f,RVF , ext_f), +ISA_EXT_DATA_ENTRY (h,RVH , ext_h), +ISA_EXT_DATA_ENTRY (i,RVI , ext_i), +ISA_EXT_DATA_ENTRY (m,RVM , ext_m), +ISA_EXT_DATA_ENTRY (svpbmt,0 , ext_svpbmt), +ISA_EXT_DATA_ENTRY (sstc,0 , ext_sstc), +ISA_EXT_DATA_ENTRY (svinval,0 , ext_svinval), +ISA_EXT_DATA_ENTRY (zihintpause,0 , ext_zihintpause), +}; +static uint64_t kvm_riscv_reg_id (CPURISCVState *env,uint64_t type,uint64_t idx) {@@ -394,25 +417,66 @@ void kvm_arch_init_irq_routing(KVMState *s) { } +bool kvm_riscv_ext_supported (int offset) +{ +int i; + +for (i =0 ; i <KVM_RISCV_ISA_EXT_MAX ; ++i) { +if (isa_info_arr[i].ext_enable_offset == offset) { +return true; + } + } +return false; +} + +static void kvm_riscv_set_isa_ext (CPUState *cs,CPURISCVState *env) +{ +RISCVCPU *cpu =RISCV_CPU (cs); +unsigned long isa_ext_out; +bool *ext_state; +uint64_t id; +int i, ret; + + env->misa_ext =0 ; +for (i =0 ; i <ARRAY_SIZE (isa_info_arr); i++) { + ext_state = (void *)&cpu->cfg + isa_info_arr[i].ext_enable_offset; + id =kvm_riscv_reg_id (env,KVM_REG_RISCV_ISA_EXT , i); + ret =kvm_get_one_reg (cs, id, &isa_ext_out); +if (ret) { +warn_report ("Disabling ext %s due to failure." , + isa_info_arr[i].name); + *ext_state = false; +continue ; + } +if (isa_ext_out != (*ext_state)) { + isa_ext_out = *ext_state; + ret =kvm_set_one_reg (cs, id, &isa_ext_out); +if (ret) { +warn_report ("Could not %s ext %s." , + (isa_ext_out ?"enable" :"disable" ), + isa_info_arr[i].name); + *ext_state = !isa_ext_out; + } + } +/* +* If the sigle letter extension is supported by KVM then set +* the corresponding misa bit for the guest vcpu. +*/ +if (isa_info_arr[i].misa_bit && (*ext_state)) { + env->misa_ext |= isa_info_arr[i].misa_bit; + } + } +} +int kvm_arch_init_vcpu (CPUState *cs) { -int ret =0 ; -target_ulong isa;RISCVCPU *cpu =RISCV_CPU (cs);CPURISCVState *env = &cpu->env; -uint64_t id;qemu_add_vm_change_state_handler (kvm_riscv_vm_state_change, cs); - id =kvm_riscv_reg_id (env,KVM_REG_RISCV_CONFIG , -KVM_REG_RISCV_CONFIG_REG (isa)); - ret =kvm_get_one_reg (cs, id, &isa); -if (ret) { -return ret; - } - env->misa_ext = isa; - -return ret; +kvm_riscv_set_isa_ext (cs, env); +return 0 ; }int kvm_arch_msi_data_to_gsi (uint32_t data)target/riscv/kvm_riscv.h +1
-2@@ -21,5 +21,5 @@void kvm_riscv_reset_vcpu (RISCVCPU *cpu);void kvm_riscv_set_irq (RISCVCPU *cpu,int irq,int level); - +bool kvm_riscv_ext_supported (int offset);#endif --2.34.1