diff --git a/backends-tpm-Avoid-using-g_alloca.patch b/backends-tpm-Avoid-using-g_alloca.patch new file mode 100644 index 0000000000000000000000000000000000000000..dba5000f0690a02c743cf7bfb788f7850e23bae2 --- /dev/null +++ b/backends-tpm-Avoid-using-g_alloca.patch @@ -0,0 +1,44 @@ +From ab6aa0196a12fa15db9c94212ccea39164417cc8 Mon Sep 17 00:00:00 2001 +From: dinglimin +Date: Sat, 14 Jun 2025 15:43:39 +0800 +Subject: [PATCH] backends/tpm: Avoid using g_alloca() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + + cherry picked from commit 0ff9cd9a6af54ccaa293e252aa356fb150788099 + tpm_emulator_ctrlcmd() is not in hot path. + Use the heap instead of the stack, removing + the g_alloca() call. + Signed-off-by: Philippe Mathieu-Daudé + Reviewed-by: Pierrick Bouvier + Reviewed-by: Thomas Huth + Reviewed-by: Stefan Berger + Reviewed-by: Stefan Hajnoczi + Message-Id: <20250605193540.59874-3-philmd@linaro.org> + + Signed-off-by: dinglimin +--- + backends/tpm/tpm_emulator.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c +index f7f1b4ad7a..0d07df216e 100644 +--- a/backends/tpm/tpm_emulator.c ++++ b/backends/tpm/tpm_emulator.c +@@ -128,10 +128,10 @@ static int tpm_emulator_ctrlcmd(TPMEmulator *tpm, unsigned long cmd, void *msg, + CharBackend *dev = &tpm->ctrl_chr; + uint32_t cmd_no = cpu_to_be32(cmd); + ssize_t n = sizeof(uint32_t) + msg_len_in; +- uint8_t *buf = NULL; + + WITH_QEMU_LOCK_GUARD(&tpm->mutex) { +- buf = g_alloca(n); ++ g_autofree uint8_t *buf = g_malloc(n); ++ + memcpy(buf, &cmd_no, sizeof(cmd_no)); + memcpy(buf + sizeof(cmd_no), msg, msg_len_in); + +-- +2.33.0 + diff --git a/hw-virtio-virtio-pci-Support-shadow-device-for-virti.patch b/hw-virtio-virtio-pci-Support-shadow-device-for-virti.patch new file mode 100644 index 0000000000000000000000000000000000000000..b6942768824db06771806f2bc35e4533456b5680 --- /dev/null +++ b/hw-virtio-virtio-pci-Support-shadow-device-for-virti.patch @@ -0,0 +1,65 @@ +From e4c28afade86b8533b46bc87a56a8a0f32ab191a Mon Sep 17 00:00:00 2001 +From: Jia Qingtong +Date: Mon, 16 Jun 2025 17:24:13 +0800 +Subject: [PATCH] hw/virtio/virtio-pci:Support shadow device for + virtio-net/blk/scsi devices + +Currently we only support shadow device for "virtio-net", now let's +extend this feature to support "virtio-blk" and "virtio-scsi" devices. + +Signed-off-by: Yanan Wang +Signed-off-by: Jia Qingtong +--- + hw/virtio/virtio-pci.c | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c +index 558471307a..13220c258d 100644 +--- a/hw/virtio/virtio-pci.c ++++ b/hw/virtio/virtio-pci.c +@@ -1020,6 +1020,15 @@ int __attribute__((weak)) kvm_delete_shadow_device(PCIDevice *dev) + } + #endif + ++#ifdef __aarch64__ ++static bool shadow_device_supported(VirtIODevice *vdev) ++{ ++ return !strcmp(vdev->name, "virtio-net") || ++ !strcmp(vdev->name, "virtio-blk") || ++ !strcmp(vdev->name, "virtio-scsi"); ++} ++#endif ++ + static int kvm_virtio_pci_vector_vq_use(VirtIOPCIProxy *proxy, int nvqs) + { + int queue_no; +@@ -1027,7 +1036,7 @@ static int kvm_virtio_pci_vector_vq_use(VirtIOPCIProxy *proxy, int nvqs) + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + + #ifdef __aarch64__ +- if (!strcmp(vdev->name, "virtio-net")) { ++ if (shadow_device_supported(vdev)) { + kvm_create_shadow_device(&proxy->pci_dev); + } + #endif +@@ -1044,7 +1053,7 @@ static int kvm_virtio_pci_vector_vq_use(VirtIOPCIProxy *proxy, int nvqs) + virtio_pci_commit_route_changes(vdev); + + #ifdef __aarch64__ +- if (!strcmp(vdev->name, "virtio-net") && ret != 0) { ++ if (shadow_device_supported(vdev) && ret != 0) { + kvm_delete_shadow_device(&proxy->pci_dev); + } + #endif +@@ -1093,7 +1102,7 @@ static void kvm_virtio_pci_vector_vq_release(VirtIOPCIProxy *proxy, int nvqs) + } + + #ifdef __aarch64__ +- if (!strcmp(vdev->name, "virtio-net")) { ++ if (shadow_device_supported(vdev)) { + kvm_delete_shadow_device(&proxy->pci_dev); + } + #endif +-- +2.33.0 + diff --git a/qemu-options-enable-smbios-option-on-RISC-V.patch b/qemu-options-enable-smbios-option-on-RISC-V.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9912cd806699d8130cbef858161a45a656001bf --- /dev/null +++ b/qemu-options-enable-smbios-option-on-RISC-V.patch @@ -0,0 +1,36 @@ +From 987e286cc7614c5ff3cc9096798675d7da70a5ea Mon Sep 17 00:00:00 2001 +From: yechao-w +Date: Fri, 30 May 2025 09:13:08 +0800 +Subject: [PATCH] qemu-options: enable -smbios option on RISC-V + +commit e2ff0dec156eff4e109c678654df1225d384fd14 upstream + +With SMBIOS support added for RISC-V we also should enable the command line +option. + +Signed-off-by: Heinrich Schuchardt +Reviewed-by: Daniel Henrique Barboza +Acked-by: Alistair Francis +Reviewed-by: Andrew Jones +Message-ID: <20240123184229.10415-5-heinrich.schuchardt@canonical.com> +Signed-off-by: Alistair Francis +--- + qemu-options.hx | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/qemu-options.hx b/qemu-options.hx +index cbaa2e5367..55765fb34c 100644 +--- a/qemu-options.hx ++++ b/qemu-options.hx +@@ -2690,7 +2690,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, + " specify SMBIOS type 17 fields\n" + "-smbios type=41[,designation=str][,kind=str][,instance=%d][,pcidev=str]\n" + " specify SMBIOS type 41 fields\n", +- QEMU_ARCH_I386 | QEMU_ARCH_ARM | QEMU_ARCH_LOONGARCH) ++ QEMU_ARCH_I386 | QEMU_ARCH_ARM | QEMU_ARCH_LOONGARCH | QEMU_ARCH_RISCV) + SRST + ``-smbios file=binary`` + Load SMBIOS entry from binary file. +-- +2.33.0 + diff --git a/qemu-options.hx-correct-formatting-smbios-type-4.patch b/qemu-options.hx-correct-formatting-smbios-type-4.patch new file mode 100644 index 0000000000000000000000000000000000000000..031748df04206d1c2fc8603651f6db0bf8699f79 --- /dev/null +++ b/qemu-options.hx-correct-formatting-smbios-type-4.patch @@ -0,0 +1,40 @@ +From 851559a1442a824559f273380c7ad1fa06f559e8 Mon Sep 17 00:00:00 2001 +From: yechao-w +Date: Thu, 19 Jun 2025 10:27:13 +0800 +Subject: [PATCH] qemu-options.hx: correct formatting -smbios type=4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +commit 68baeaafa562e360188fb3be8a9451db1c5bd862 upstream + +processor-family and processor-id can be assigned independently. + +Add missing brackets. + +Fixes: b5831d79671c ("smbios: add processor-family option") +Signed-off-by: Heinrich Schuchardt +Reviewed-by: Thomas Huth +Reviewed-by: Philippe Mathieu-Daudé +Message-ID: <20240729204816.11905-1-heinrich.schuchardt@canonical.com> +Signed-off-by: Philippe Mathieu-Daudé +--- + qemu-options.hx | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/qemu-options.hx b/qemu-options.hx +index 55765fb34c..b09d692d5b 100644 +--- a/qemu-options.hx ++++ b/qemu-options.hx +@@ -2679,7 +2679,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, + " specify SMBIOS type 3 fields\n" + "-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str]\n" + " [,asset=str][,part=str][,max-speed=%d][,current-speed=%d]\n" +- " [,processor-family=%d,processor-id=%d]\n" ++ " [,processor-family=%d][,processor-id=%d]\n" + " specify SMBIOS type 4 fields\n" + "-smbios type=8[,external_reference=str][,internal_reference=str][,connector_type=%d][,port_type=%d]\n" + " specify SMBIOS type 8 fields\n" +-- +2.33.0 + diff --git a/qemu.spec b/qemu.spec index 03182ad1f676035a3dacce780f35b020917a0324..2976027d73b5a155a67c40a89744348414b14631 100644 --- a/qemu.spec +++ b/qemu.spec @@ -3,7 +3,7 @@ Name: qemu Version: 8.2.0 -Release: 37 +Release: 38 Epoch: 11 Summary: QEMU is a generic and open source machine emulator and virtualizer License: GPLv2 and BSD and MIT and CC-BY-SA-4.0 @@ -937,6 +937,18 @@ Patch0920: Revert-backends-iommufd-Make-iommufd_backend_-return.patch Patch0921: qapi-misc-target-Add-Virtcca-capability-struct-and-q.patch Patch0922: qapi-misc-target-Add-KVM-option-to-isolate-virtcca-d.patch Patch0923: Add-stub-function-for-tmm_get_kae_num-if-CONFIG_KVM-.patch +Patch0924: sync-header-file-from-upstream.patch +Patch0925: backends-tpm-Avoid-using-g_alloca.patch +Patch0926: hw-virtio-virtio-pci-Support-shadow-device-for-virti.patch +Patch0927: smbios-add-processor-family-option.patch +Patch0928: smbios-function-to-set-default-processor-family.patch +Patch0929: target-riscv-SMBIOS-support-for-RISC-V-virt-machine.patch +Patch0930: qemu-options-enable-smbios-option-on-RISC-V.patch +Patch0931: qemu-options.hx-correct-formatting-smbios-type-4.patch +Patch0932: tests-unit-test-char-Avoid-using-g_alloca.patch +Patch0933: virtio-processes-indirect-descriptors-even-if-the-re.patch + + BuildRequires: flex BuildRequires: gcc @@ -1539,6 +1551,18 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Fri Jul 18 2025 Pengrui Zhang - 11:8.2.0-38 +- sync header file from upstream +- backends/tpm: Avoid using g_alloca() +- hw/virtio/virtio-pci:Support shadow device for virtio-net/blk/scsi devices +- smbios: add processor-family option +- smbios: function to set default processor family +- target/riscv: SMBIOS support for RISC-V virt machine +- qemu-options: enable -smbios option on RISC-V +- qemu-options.hx: correct formatting -smbios type=4 +- tests/unit/test-char: Avoid using g_alloca() +- virtio processes indirect descriptors even if the respected + * Wed Jun 18 2025 Panhengchang - 11:8.2.0-37 - Add stub function for 'tmm_get_kae_num' if 'CONFIG_KVM' is not set. - qapi/misc-target: Add KVM option to isolate virtcca detection interface. diff --git a/smbios-add-processor-family-option.patch b/smbios-add-processor-family-option.patch new file mode 100644 index 0000000000000000000000000000000000000000..c367176ff8ee7f67bfcae273b55b8223a043c78d --- /dev/null +++ b/smbios-add-processor-family-option.patch @@ -0,0 +1,110 @@ +From 8bbff5547eb88886ee13fa8eb95658318c457298 Mon Sep 17 00:00:00 2001 +From: yechao-w +Date: Fri, 30 May 2025 09:07:29 +0800 +Subject: [PATCH] smbios: add processor-family option + +commit b5831d79671cea3f7bd42cffab93fe6eab8c3db0 upstream + +For RISC-V the SMBIOS standard requires specific values of the processor +family value depending on the bitness of the CPU. + +Add a processor-family option for SMBIOS table 4. + +The value of processor-family may exceed 255 and therefore must be provided +in the Processor Family 2 field. Set the Processor Family field to 0xFE +which signals that the Processor Family 2 is used. + +Signed-off-by: Heinrich Schuchardt +Reviewed-by: Alistair Francis +Reviewed-by: Andrew Jones +Message-ID: <20240123184229.10415-2-heinrich.schuchardt@canonical.com> +Signed-off-by: Alistair Francis +--- + hw/smbios/smbios.c | 13 +++++++++++-- + qemu-options.hx | 4 ++-- + 2 files changed, 13 insertions(+), 4 deletions(-) + +diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c +index 2a90601ac5..647bc6d603 100644 +--- a/hw/smbios/smbios.c ++++ b/hw/smbios/smbios.c +@@ -102,6 +102,7 @@ static struct { + #define DEFAULT_CPU_SPEED 2000 + + static struct { ++ uint16_t processor_family; + const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part; + uint64_t max_speed; + uint64_t current_speed; +@@ -110,6 +111,7 @@ static struct { + .max_speed = DEFAULT_CPU_SPEED, + .current_speed = DEFAULT_CPU_SPEED, + .processor_id = 0, ++ .processor_family = 0x01, /* Other */ + }; + + struct type8_instance { +@@ -337,6 +339,10 @@ static const QemuOptDesc qemu_smbios_type4_opts[] = { + .name = "part", + .type = QEMU_OPT_STRING, + .help = "part number", ++ }, { ++ .name = "processor-family", ++ .type = QEMU_OPT_NUMBER, ++ .help = "processor family", + }, { + .name = "processor-id", + .type = QEMU_OPT_NUMBER, +@@ -726,7 +732,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance) + snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance); + SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str); + t->processor_type = 0x03; /* CPU */ +- t->processor_family = 0x01; /* Other */ ++ t->processor_family = 0xfe; /* use Processor Family 2 field */ + SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer); + if (type4.processor_id == 0) { + t->processor_id[0] = cpu_to_le32(smbios_cpuid_version); +@@ -758,7 +764,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance) + t->thread_count = (threads_per_socket > 255) ? 0xFF : threads_per_socket; + + t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */ +- t->processor_family2 = cpu_to_le16(0x01); /* Other */ ++ t->processor_family2 = cpu_to_le16(type4.processor_family); + + if (tbl_len == SMBIOS_TYPE_4_LEN_V30) { + t->core_count2 = t->core_enabled2 = cpu_to_le16(cores_per_socket); +@@ -1402,6 +1408,9 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) + return; + } + save_opt(&type4.sock_pfx, opts, "sock_pfx"); ++ type4.processor_family = qemu_opt_get_number(opts, ++ "processor-family", ++ 0x01 /* Other */); + save_opt(&type4.manufacturer, opts, "manufacturer"); + save_opt(&type4.version, opts, "version"); + save_opt(&type4.serial, opts, "serial"); +diff --git a/qemu-options.hx b/qemu-options.hx +index 7fe76c4b1d..cbaa2e5367 100644 +--- a/qemu-options.hx ++++ b/qemu-options.hx +@@ -2679,7 +2679,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, + " specify SMBIOS type 3 fields\n" + "-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str]\n" + " [,asset=str][,part=str][,max-speed=%d][,current-speed=%d]\n" +- " [,processor-id=%d]\n" ++ " [,processor-family=%d,processor-id=%d]\n" + " specify SMBIOS type 4 fields\n" + "-smbios type=8[,external_reference=str][,internal_reference=str][,connector_type=%d][,port_type=%d]\n" + " specify SMBIOS type 8 fields\n" +@@ -2707,7 +2707,7 @@ SRST + ``-smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str][,sku=str]`` + Specify SMBIOS type 3 fields + +-``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-id=%d]`` ++``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-family=%d][,processor-id=%d]`` + Specify SMBIOS type 4 fields + + ``-smbios type=11[,value=str][,path=filename]`` +-- +2.33.0 + diff --git a/smbios-function-to-set-default-processor-family.patch b/smbios-function-to-set-default-processor-family.patch new file mode 100644 index 0000000000000000000000000000000000000000..9b312dc230c5be8474ba333383c12e899af5eecc --- /dev/null +++ b/smbios-function-to-set-default-processor-family.patch @@ -0,0 +1,51 @@ +From 4e1255411ea509a014d860f3cab1b5425b6556c8 Mon Sep 17 00:00:00 2001 +From: yechao-w +Date: Fri, 30 May 2025 09:08:40 +0800 +Subject: [PATCH] smbios: function to set default processor family + +commit 6f3b727bcc867688034ef1489a58e958142973b1 upstream + +Provide a function to set the default processor family. + +Signed-off-by: Heinrich Schuchardt +Reviewed-by: Andrew Jones +Message-ID: <20240123184229.10415-3-heinrich.schuchardt@canonical.com> +Signed-off-by: Alistair Francis +--- + hw/smbios/smbios.c | 7 +++++++ + include/hw/firmware/smbios.h | 1 + + 2 files changed, 8 insertions(+) + +diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c +index 647bc6d603..c0c5a81e66 100644 +--- a/hw/smbios/smbios.c ++++ b/hw/smbios/smbios.c +@@ -989,6 +989,13 @@ void smbios_set_cpuid(uint32_t version, uint32_t features) + field = value; \ + } + ++void smbios_set_default_processor_family(uint16_t processor_family) ++{ ++ if (type4.processor_family <= 0x01) { ++ type4.processor_family = processor_family; ++ } ++} ++ + void smbios_set_defaults(const char *manufacturer, const char *product, + const char *version, bool legacy_mode, + bool uuid_encoded, SmbiosEntryPointType ep_type) +diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h +index 7f3259a630..6e514982d4 100644 +--- a/include/hw/firmware/smbios.h ++++ b/include/hw/firmware/smbios.h +@@ -295,6 +295,7 @@ void smbios_set_cpuid(uint32_t version, uint32_t features); + void smbios_set_defaults(const char *manufacturer, const char *product, + const char *version, bool legacy_mode, + bool uuid_encoded, SmbiosEntryPointType ep_type); ++void smbios_set_default_processor_family(uint16_t processor_family); + uint8_t *smbios_get_table_legacy(MachineState *ms, size_t *length); + void smbios_get_tables(MachineState *ms, + const struct smbios_phys_mem_area *mem_array, +-- +2.33.0 + diff --git a/sync-header-file-from-upstream.patch b/sync-header-file-from-upstream.patch new file mode 100644 index 0000000000000000000000000000000000000000..54c4e81b3a59c0e66d23de8fe3f190612c8f13dc --- /dev/null +++ b/sync-header-file-from-upstream.patch @@ -0,0 +1,137 @@ +From 5b9ece5e96c40f56e7c84bf15d4a5a7d1205bc25 Mon Sep 17 00:00:00 2001 +From: Xianglai Li +Date: Mon, 26 May 2025 16:58:25 +0800 +Subject: [PATCH] sync header file from upstream + +The local interrupt controller simulation header file is inconsistent +with the upstream header file. To ensure uapi compatibility, +the upstream interrupt controller simulation header file is now +synchronized. + +Signed-off-by: Xianglai Li +--- + hw/intc/loongarch_extioi_kvm.c | 2 +- + hw/intc/loongarch_ipi_kvm.c | 2 +- + hw/intc/loongarch_pch_pic_kvm.c | 2 +- + linux-headers/asm-loongarch/kvm.h | 15 ++++++--------- + linux-headers/linux/kvm.h | 13 +++++++------ + target/loongarch/kvm/kvm.c | 4 ---- + 6 files changed, 16 insertions(+), 22 deletions(-) + +diff --git a/hw/intc/loongarch_extioi_kvm.c b/hw/intc/loongarch_extioi_kvm.c +index 2e7c764b7c..94af4378e4 100644 +--- a/hw/intc/loongarch_extioi_kvm.c ++++ b/hw/intc/loongarch_extioi_kvm.c +@@ -115,7 +115,7 @@ static void kvm_loongarch_extioi_realize(DeviceState *dev, Error **errp) + } + + if (!extioi_class->is_created) { +- cd.type = KVM_DEV_TYPE_LA_EXTIOI; ++ cd.type = KVM_DEV_TYPE_LOONGARCH_EIOINTC; + ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd); + if (ret < 0) { + error_setg_errno(errp, errno, +diff --git a/hw/intc/loongarch_ipi_kvm.c b/hw/intc/loongarch_ipi_kvm.c +index fd308eb0c0..57fc05db77 100644 +--- a/hw/intc/loongarch_ipi_kvm.c ++++ b/hw/intc/loongarch_ipi_kvm.c +@@ -128,7 +128,7 @@ static void kvm_loongarch_ipi_realize(DeviceState *dev, Error **errp) + } + + if (!ipi_class->is_created) { +- cd.type = KVM_DEV_TYPE_LA_IPI; ++ cd.type = KVM_DEV_TYPE_LOONGARCH_IPI; + ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd); + if (ret < 0) { + error_setg_errno(errp, errno, "Creating the KVM device failed"); +diff --git a/hw/intc/loongarch_pch_pic_kvm.c b/hw/intc/loongarch_pch_pic_kvm.c +index 8f66d9a01f..e9cef02f9a 100644 +--- a/hw/intc/loongarch_pch_pic_kvm.c ++++ b/hw/intc/loongarch_pch_pic_kvm.c +@@ -113,7 +113,7 @@ static void kvm_loongarch_pch_pic_realize(DeviceState *dev, Error **errp) + } + + if (!pch_pic_class->is_created) { +- cd.type = KVM_DEV_TYPE_LA_PCH_PIC; ++ cd.type = KVM_DEV_TYPE_LOONGARCH_PCHPIC; + ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd); + if (ret < 0) { + error_setg_errno(errp, errno, +diff --git a/linux-headers/asm-loongarch/kvm.h b/linux-headers/asm-loongarch/kvm.h +index 34abd65939..d22b19e134 100644 +--- a/linux-headers/asm-loongarch/kvm.h ++++ b/linux-headers/asm-loongarch/kvm.h +@@ -135,25 +135,22 @@ struct kvm_iocsr_entry { + #define KVM_IRQCHIP_NUM_PINS 64 + #define KVM_MAX_CORES 256 + +-#define KVM_LOONGARCH_VM_HAVE_IRQCHIP 0x40000001 ++#define KVM_DEV_LOONGARCH_IPI_GRP_REGS 0x40000001 + +-#define KVM_DEV_LOONGARCH_IPI_GRP_REGS 0x40000002 ++#define KVM_DEV_LOONGARCH_EXTIOI_GRP_REGS 0x40000002 + +-#define KVM_DEV_LOONGARCH_EXTIOI_GRP_REGS 0x40000003 +- +-#define KVM_DEV_LOONGARCH_EXTIOI_GRP_SW_STATUS 0x40000006 ++#define KVM_DEV_LOONGARCH_EXTIOI_GRP_SW_STATUS 0x40000003 + #define KVM_DEV_LOONGARCH_EXTIOI_SW_STATUS_NUM_CPU 0x0 + #define KVM_DEV_LOONGARCH_EXTIOI_SW_STATUS_FEATURE 0x1 + #define KVM_DEV_LOONGARCH_EXTIOI_SW_STATUS_STATE 0x2 + +-#define KVM_DEV_LOONGARCH_EXTIOI_GRP_CTRL 0x40000007 ++#define KVM_DEV_LOONGARCH_EXTIOI_GRP_CTRL 0x40000004 + #define KVM_DEV_LOONGARCH_EXTIOI_CTRL_INIT_NUM_CPU 0x0 + #define KVM_DEV_LOONGARCH_EXTIOI_CTRL_INIT_FEATURE 0x1 + #define KVM_DEV_LOONGARCH_EXTIOI_CTRL_LOAD_FINISHED 0x3 + +-#define KVM_DEV_LOONGARCH_PCH_PIC_GRP_CTRL 0x40000004 +-#define KVM_DEV_LOONGARCH_PCH_PIC_CTRL_INIT 0 +- + #define KVM_DEV_LOONGARCH_PCH_PIC_GRP_REGS 0x40000005 ++#define KVM_DEV_LOONGARCH_PCH_PIC_GRP_CTRL 0x40000006 ++#define KVM_DEV_LOONGARCH_PCH_PIC_CTRL_INIT 0 + + #endif /* __UAPI_ASM_LOONGARCH_KVM_H */ +diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h +index 0714651440..413663e332 100644 +--- a/linux-headers/linux/kvm.h ++++ b/linux-headers/linux/kvm.h +@@ -1487,12 +1487,13 @@ 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_LA_PCH_PIC = 0x100, +-#define KVM_DEV_TYPE_LA_PCH_PIC KVM_DEV_TYPE_LA_PCH_PIC +- KVM_DEV_TYPE_LA_IPI, +-#define KVM_DEV_TYPE_LA_IPI KVM_DEV_TYPE_LA_IPI +- KVM_DEV_TYPE_LA_EXTIOI, +-#define KVM_DEV_TYPE_LA_EXTIOI KVM_DEV_TYPE_LA_EXTIOI ++ 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, + }; + +diff --git a/target/loongarch/kvm/kvm.c b/target/loongarch/kvm/kvm.c +index f6e008a517..f724e77a1b 100644 +--- a/target/loongarch/kvm/kvm.c ++++ b/target/loongarch/kvm/kvm.c +@@ -973,10 +973,6 @@ int kvm_arch_get_default_type(MachineState *ms) + int kvm_arch_init(MachineState *ms, KVMState *s) + { + cap_has_mp_state = kvm_check_extension(s, KVM_CAP_MP_STATE); +- if(!kvm_vm_check_attr(kvm_state, KVM_LOONGARCH_VM_HAVE_IRQCHIP, KVM_LOONGARCH_VM_HAVE_IRQCHIP)) { +- s->kernel_irqchip_allowed = false; +- } +- + return 0; + } + +-- +2.33.0 + diff --git a/target-riscv-SMBIOS-support-for-RISC-V-virt-machine.patch b/target-riscv-SMBIOS-support-for-RISC-V-virt-machine.patch new file mode 100644 index 0000000000000000000000000000000000000000..8c96662c5bb968580c65fb0266e7b58b544f6be3 --- /dev/null +++ b/target-riscv-SMBIOS-support-for-RISC-V-virt-machine.patch @@ -0,0 +1,109 @@ +From 5f27d198462966c13dc60e32be48978ecc987698 Mon Sep 17 00:00:00 2001 +From: yechao-w +Date: Fri, 30 May 2025 09:12:20 +0800 +Subject: [PATCH] target/riscv: SMBIOS support for RISC-V virt machine + +commit ecf286478475d11ae4cdef7e52d9c8e1672f2868 upstream + +Generate SMBIOS tables for the RISC-V mach-virt. +Add CONFIG_SMBIOS=y to the RISC-V default config. +Set the default processor family in the type 4 table. + +The implementation is based on the corresponding ARM and Loongson code. + +With the patch the following firmware tables are provided: + + etc/smbios/smbios-anchor + etc/smbios/smbios-tables + +Signed-off-by: Heinrich Schuchardt +Reviewed-by: Andrew Jones +Message-ID: <20240123184229.10415-4-heinrich.schuchardt@canonical.com> +Signed-off-by: Alistair Francis +--- + hw/riscv/Kconfig | 1 + + hw/riscv/virt.c | 42 ++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 43 insertions(+) + +diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig +index b6a5eb4452..1e11ac9432 100644 +--- a/hw/riscv/Kconfig ++++ b/hw/riscv/Kconfig +@@ -41,6 +41,7 @@ config RISCV_VIRT + select RISCV_IMSIC + select SIFIVE_PLIC + select SIFIVE_TEST ++ select SMBIOS + select VIRTIO_MMIO + select FW_CFG_DMA + select PLATFORM_BUS +diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c +index d2eac24156..9b29ed1108 100644 +--- a/hw/riscv/virt.c ++++ b/hw/riscv/virt.c +@@ -36,6 +36,7 @@ + #include "hw/riscv/boot.h" + #include "hw/riscv/numa.h" + #include "kvm/kvm_riscv.h" ++#include "hw/firmware/smbios.h" + #include "hw/intc/riscv_aclint.h" + #include "hw/intc/riscv_aplic.h" + #include "hw/intc/riscv_imsic.h" +@@ -1249,6 +1250,45 @@ static void create_platform_bus(RISCVVirtState *s, DeviceState *irqchip) + sysbus_mmio_get_region(sysbus, 0)); + } + ++static void virt_build_smbios(RISCVVirtState *s) ++{ ++ MachineClass *mc = MACHINE_GET_CLASS(s); ++ MachineState *ms = MACHINE(s); ++ uint8_t *smbios_tables, *smbios_anchor; ++ size_t smbios_tables_len, smbios_anchor_len; ++ struct smbios_phys_mem_area mem_array; ++ const char *product = "QEMU Virtual Machine"; ++ ++ if (kvm_enabled()) { ++ product = "KVM Virtual Machine"; ++ } ++ ++ smbios_set_defaults("QEMU", product, mc->name, false, ++ true, SMBIOS_ENTRY_POINT_TYPE_64); ++ ++ if (riscv_is_32bit(&s->soc[0])) { ++ smbios_set_default_processor_family(0x200); ++ } else { ++ smbios_set_default_processor_family(0x201); ++ } ++ ++ /* build the array of physical mem area from base_memmap */ ++ mem_array.address = s->memmap[VIRT_DRAM].base; ++ mem_array.length = ms->ram_size; ++ ++ smbios_get_tables(ms, &mem_array, 1, ++ &smbios_tables, &smbios_tables_len, ++ &smbios_anchor, &smbios_anchor_len, ++ &error_fatal); ++ ++ if (smbios_anchor) { ++ fw_cfg_add_file(s->fw_cfg, "etc/smbios/smbios-tables", ++ smbios_tables, smbios_tables_len); ++ fw_cfg_add_file(s->fw_cfg, "etc/smbios/smbios-anchor", ++ smbios_anchor, smbios_anchor_len); ++ } ++} ++ + static void virt_machine_done(Notifier *notifier, void *data) + { + RISCVVirtState *s = container_of(notifier, RISCVVirtState, +@@ -1337,6 +1377,8 @@ static void virt_machine_done(Notifier *notifier, void *data) + riscv_setup_direct_kernel(kernel_entry, fdt_load_addr); + } + ++ virt_build_smbios(s); ++ + if (virt_is_acpi_enabled(s)) { + virt_acpi_setup(s); + } +-- +2.33.0 + diff --git a/tests-unit-test-char-Avoid-using-g_alloca.patch b/tests-unit-test-char-Avoid-using-g_alloca.patch new file mode 100644 index 0000000000000000000000000000000000000000..e28323ec53a6963bec8784437526bd9eceeb358a --- /dev/null +++ b/tests-unit-test-char-Avoid-using-g_alloca.patch @@ -0,0 +1,46 @@ +From 693b6555bb16c82ec8fefa50263b0e8fcdc54cdc Mon Sep 17 00:00:00 2001 +From: dinglimin +Date: Sat, 14 Jun 2025 15:59:16 +0800 +Subject: [PATCH] tests/unit/test-char: Avoid using g_alloca() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + + tests/unit/test-char: Avoid using g_alloca() + + Do not use g_alloca(), simply allocate the CharBackend + structure on the stack. + + Signed-off-by: Philippe Mathieu-Daudé + Reviewed-by: Pierrick Bouvier + Reviewed-by: Stefan Hajnoczi + + Signed-off-by: dinglimin +--- + tests/unit/test-char.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/tests/unit/test-char.c b/tests/unit/test-char.c +index 649fdf64e1..0cb2633190 100644 +--- a/tests/unit/test-char.c ++++ b/tests/unit/test-char.c +@@ -574,7 +574,7 @@ static void char_udp_test_internal(Chardev *reuse_chr, int sock) + struct sockaddr_in other; + SocketIdleData d = { 0, }; + Chardev *chr; +- CharBackend *be; ++ CharBackend stack_be, *be = &stack_be; + socklen_t alen = sizeof(other); + int ret; + char buf[10]; +@@ -590,7 +590,6 @@ static void char_udp_test_internal(Chardev *reuse_chr, int sock) + chr = qemu_chr_new("client", tmp, NULL); + g_assert_nonnull(chr); + +- be = g_alloca(sizeof(CharBackend)); + qemu_chr_fe_init(be, chr, &error_abort); + } + +-- +2.33.0 + diff --git a/virtio-processes-indirect-descriptors-even-if-the-re.patch b/virtio-processes-indirect-descriptors-even-if-the-re.patch new file mode 100644 index 0000000000000000000000000000000000000000..f0023b9dca59ad8641595f8903e23e4efabae88b --- /dev/null +++ b/virtio-processes-indirect-descriptors-even-if-the-re.patch @@ -0,0 +1,60 @@ +From 62cedbd18455e0b800c9ab0a47eef599c5309eaa Mon Sep 17 00:00:00 2001 +From: dinglimin +Date: Sat, 14 Jun 2025 16:40:39 +0800 +Subject: [PATCH] virtio processes indirect descriptors even if the respected + feature VIRTIO_RING_F_INDIRECT_DESC was not negotiated. If qemu is used with + reduced set of features to emulate the hardware device that does not support + indirect descriptors, the will probably trigger problematic flows on the + hardware setup but do not reveal the mistake on qemu. Add LOG_GUEST_ERROR + for such case. This will issue logs with '-d guest_errors' in the command + line + +Signed-off-by: Yuri Benditovich +Message-Id: <20250515063237.808293-1-yuri.benditovich@daynix.com> +Signed-off-by: Yuri Benditovich +Signed-off-by: dinglimin +--- + hw/virtio/virtio.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c +index 4f5b241fd3..f57b6c955e 100644 +--- a/hw/virtio/virtio.c ++++ b/hw/virtio/virtio.c +@@ -204,6 +204,15 @@ static const char *virtio_id_to_name(uint16_t device_id) + return name; + } + ++static void virtio_check_indirect_feature(VirtIODevice *vdev) ++{ ++ if (!virtio_vdev_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC)) { ++ qemu_log_mask(LOG_GUEST_ERROR, ++ "Device %s: indirect_desc was not negotiated!\n", ++ vdev->name); ++ } ++} ++ + /* Called within call_rcu(). */ + static void virtio_free_region_cache(VRingMemoryRegionCaches *caches) + { +@@ -1614,6 +1623,8 @@ static void *virtqueue_split_pop(VirtQueue *vq, size_t sz) + goto done; + } + ++ virtio_check_indirect_feature(vdev); ++ + /* loop over the indirect descriptor table */ + len = address_space_cache_init(&indirect_desc_cache, vdev->dma_as, + desc.addr, desc.len, false); +@@ -1744,6 +1755,8 @@ static void *virtqueue_packed_pop(VirtQueue *vq, size_t sz) + goto done; + } + ++ virtio_check_indirect_feature(vdev); ++ + /* loop over the indirect descriptor table */ + len = address_space_cache_init(&indirect_desc_cache, vdev->dma_as, + desc.addr, desc.len, false); +-- +2.33.0 +