From 81f5cad3858f27623b1b14467926032d229b76cc Mon Sep 17 00:00:00 2001 From: Xiaoyao Li Date: Mon, 15 Jan 2024 04:13:24 -0500 Subject: [PATCH 01/17] i386/cpu: Clear FEAT_XSAVE_XSS_LO/HI leafs when CPUID_EXT_XSAVE is not available Leaf FEAT_XSAVE_XSS_LO and FEAT_XSAVE_XSS_HI also need to be cleared when CPUID_EXT_XSAVE is not set. Fixes: 301e90675c3f ("target/i386: Enable support for XSAVES based features") Signed-off-by: Xiaoyao Li Reviewed-by: Yang Weijiang Message-ID: <20240115091325.1904229-2-xiaoyao.li@intel.com> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 0cd32a6fce..800caeb593 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6927,6 +6927,8 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu) if (!(env->features[FEAT_1_ECX] & CPUID_EXT_XSAVE)) { env->features[FEAT_XSAVE_XCR0_LO] = 0; env->features[FEAT_XSAVE_XCR0_HI] = 0; + env->features[FEAT_XSAVE_XSS_LO] = 0; + env->features[FEAT_XSAVE_XSS_HI] = 0; return; } From a11a365159b944e05be76f3ec3b98c8b38cb70fd Mon Sep 17 00:00:00 2001 From: Xiaoyao Li Date: Mon, 15 Jan 2024 04:13:25 -0500 Subject: [PATCH 02/17] i386/cpu: Mask with XCR0/XSS mask for FEAT_XSAVE_XCR0_HI and FEAT_XSAVE_XSS_HI leafs The value of FEAT_XSAVE_XCR0_HI leaf and FEAT_XSAVE_XSS_HI leaf also need to be masked by XCR0 and XSS mask respectively, to make it logically correct. Fixes: 301e90675c3f ("target/i386: Enable support for XSAVES based features") Signed-off-by: Xiaoyao Li Reviewed-by: Yang Weijiang Message-ID: <20240115091325.1904229-3-xiaoyao.li@intel.com> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 800caeb593..3ce138fecb 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6947,9 +6947,9 @@ static void x86_cpu_enable_xsave_components(X86CPU *cpu) } env->features[FEAT_XSAVE_XCR0_LO] = mask & CPUID_XSTATE_XCR0_MASK; - env->features[FEAT_XSAVE_XCR0_HI] = mask >> 32; + env->features[FEAT_XSAVE_XCR0_HI] = (mask & CPUID_XSTATE_XCR0_MASK) >> 32; env->features[FEAT_XSAVE_XSS_LO] = mask & CPUID_XSTATE_XSS_MASK; - env->features[FEAT_XSAVE_XSS_HI] = mask >> 32; + env->features[FEAT_XSAVE_XSS_HI] = (mask & CPUID_XSTATE_XSS_MASK) >> 32; } /***** Steps involved on loading and filtering CPUID data From eba978061ee5b19059db9603b97b007144617dc3 Mon Sep 17 00:00:00 2001 From: Xiaoyao Li Date: Tue, 24 Oct 2023 04:33:54 -0400 Subject: [PATCH 03/17] target/i386: Add support of KVM_FEATURE_ASYNC_PF_VMEXIT for guest KVM_FEATURE_ASYNC_PF_VMEXIT has been introduced for years, however QEMU doesn't support expose it to guest. Add support for it. Signed-off-by: Xiaoyao Li Message-ID: <20231024083354.1171308-1-xiaoyao.li@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 3ce138fecb..bca776e1fe 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -857,7 +857,7 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = { .feat_names = { "kvmclock", "kvm-nopiodelay", "kvm-mmu", "kvmclock", "kvm-asyncpf", "kvm-steal-time", "kvm-pv-eoi", "kvm-pv-unhalt", - NULL, "kvm-pv-tlb-flush", NULL, "kvm-pv-ipi", + NULL, "kvm-pv-tlb-flush", "kvm-asyncpf-vmexit", "kvm-pv-ipi", "kvm-poll-control", "kvm-pv-sched-yield", "kvm-asyncpf-int", "kvm-msi-ext-dest-id", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, From 2a1019f2092dd73e157e01add94db5c7c82563b4 Mon Sep 17 00:00:00 2001 From: Xiaoyao Li Date: Sat, 7 Oct 2023 02:58:19 -0400 Subject: [PATCH 04/17] i386/pc: Drop pc_machine_kvm_type() pc_machine_kvm_type() was introduced by commit e21be724eaf5 ("i386/xen: add pc_machine_kvm_type to initialize XEN_EMULATE mode") to do Xen specific initialization by utilizing kvm_type method. commit eeedfe6c6316 ("hw/xen: Simplify emulated Xen platform init") moves the Xen specific initialization to pc_basic_device_init(). There is no need to keep the PC specific kvm_type() implementation anymore. So we'll fallback to kvm_arch_get_default_type(), which simply returns 0. Signed-off-by: Xiaoyao Li Reviewed-by: Isaku Yamahata Reviewed-by: David Hildenbrand Acked-by: David Woodhouse Acked-by: Michael S. Tsirkin Message-ID: <20231007065819.27498-1-xiaoyao.li@intel.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc.c | 5 ----- include/hw/i386/pc.h | 3 --- 2 files changed, 8 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 196827531a..28194014f8 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1756,11 +1756,6 @@ static void pc_machine_initfn(Object *obj) cxl_machine_init(obj, &pcms->cxl_devices_state); } -int pc_machine_kvm_type(MachineState *machine, const char *kvm_type) -{ - return 0; -} - static void pc_machine_reset(MachineState *machine, ShutdownCause reason) { CPUState *cs; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index ec0e5efcb2..02a0deedd3 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -310,15 +310,12 @@ extern const size_t pc_compat_1_5_len; extern GlobalProperty pc_compat_1_4[]; extern const size_t pc_compat_1_4_len; -int pc_machine_kvm_type(MachineState *machine, const char *vm_type); - #define DEFINE_PC_MACHINE(suffix, namestr, initfn, optsfn) \ static void pc_machine_##suffix##_class_init(ObjectClass *oc, void *data) \ { \ MachineClass *mc = MACHINE_CLASS(oc); \ optsfn(mc); \ mc->init = initfn; \ - mc->kvm_type = pc_machine_kvm_type; \ } \ static const TypeInfo pc_machine_type_##suffix = { \ .name = namestr TYPE_MACHINE_SUFFIX, \ From ea18be78a6a2126a269d4f624999dacebc99e8b9 Mon Sep 17 00:00:00 2001 From: Xiaoyao Li Date: Wed, 24 Jan 2024 21:33:28 -0500 Subject: [PATCH 05/17] physmem: replace function name with __func__ in ram_block_discard_range() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use __func__ to avoid hard-coded function name. Signed-off-by: Xiaoyao Li Reviewed-by: David Hildenbrand Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20240125023328.2520888-1-xiaoyao.li@intel.com> Signed-off-by: Paolo Bonzini --- system/physmem.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index 5e66d9ae36..5e054650b8 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3495,16 +3495,15 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) uint8_t *host_startaddr = rb->host + start; if (!QEMU_PTR_IS_ALIGNED(host_startaddr, rb->page_size)) { - error_report("ram_block_discard_range: Unaligned start address: %p", - host_startaddr); + error_report("%s: Unaligned start address: %p", + __func__, host_startaddr); goto err; } if ((start + length) <= rb->max_length) { bool need_madvise, need_fallocate; if (!QEMU_IS_ALIGNED(length, rb->page_size)) { - error_report("ram_block_discard_range: Unaligned length: %zx", - length); + error_report("%s: Unaligned length: %zx", __func__, length); goto err; } @@ -3528,8 +3527,8 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) * proper error message. */ if (rb->flags & RAM_READONLY_FD) { - error_report("ram_block_discard_range: Discarding RAM" - " with readonly files is not supported"); + error_report("%s: Discarding RAM with readonly files is not" + " supported", __func__); goto err; } @@ -3544,27 +3543,26 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) * file. */ if (!qemu_ram_is_shared(rb)) { - warn_report_once("ram_block_discard_range: Discarding RAM" + warn_report_once("%s: Discarding RAM" " in private file mappings is possibly" " dangerous, because it will modify the" " underlying file and will affect other" - " users of the file"); + " users of the file", __func__); } ret = fallocate(rb->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, start, length); if (ret) { ret = -errno; - error_report("ram_block_discard_range: Failed to fallocate " - "%s:%" PRIx64 " +%zx (%d)", - rb->idstr, start, length, ret); + error_report("%s: Failed to fallocate %s:%" PRIx64 " +%zx (%d)", + __func__, rb->idstr, start, length, ret); goto err; } #else ret = -ENOSYS; - error_report("ram_block_discard_range: fallocate not available/file" + error_report("%s: fallocate not available/file" "%s:%" PRIx64 " +%zx (%d)", - rb->idstr, start, length, ret); + __func__, rb->idstr, start, length, ret); goto err; #endif } @@ -3582,25 +3580,23 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start, size_t length) } if (ret) { ret = -errno; - error_report("ram_block_discard_range: Failed to discard range " + error_report("%s: Failed to discard range " "%s:%" PRIx64 " +%zx (%d)", - rb->idstr, start, length, ret); + __func__, rb->idstr, start, length, ret); goto err; } #else ret = -ENOSYS; - error_report("ram_block_discard_range: MADVISE not available" - "%s:%" PRIx64 " +%zx (%d)", - rb->idstr, start, length, ret); + error_report("%s: MADVISE not available %s:%" PRIx64 " +%zx (%d)", + __func__, rb->idstr, start, length, ret); goto err; #endif } trace_ram_block_discard_range(rb->idstr, host_startaddr, length, need_madvise, need_fallocate, ret); } else { - error_report("ram_block_discard_range: Overrun block '%s' (%" PRIu64 - "/%zx/" RAM_ADDR_FMT")", - rb->idstr, start, length, rb->max_length); + error_report("%s: Overrun block '%s' (%" PRIu64 "/%zx/" RAM_ADDR_FMT")", + __func__, rb->idstr, start, length, rb->max_length); } err: From 10f92799af8ba3c3cef2352adcd4780f13fbab31 Mon Sep 17 00:00:00 2001 From: Xiaoyao Li Date: Wed, 24 Jan 2024 21:40:14 -0500 Subject: [PATCH 06/17] i386/cpuid: Decrease cpuid_i when skipping CPUID leaf 1F Existing code misses a decrement of cpuid_i when skip leaf 0x1F. There's a blank CPUID entry(with leaf, subleaf as 0, and all fields stuffed 0s) left in the CPUID array. It conflicts with correct CPUID leaf 0. Signed-off-by: Xiaoyao Li Reviewed-by:Yang Weijiang Message-ID: <20240125024016.2521244-2-xiaoyao.li@intel.com> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 76a66246eb..dff9dedbd7 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1914,6 +1914,7 @@ int kvm_arch_init_vcpu(CPUState *cs) } case 0x1f: if (env->nr_dies < 2) { + cpuid_i--; break; } /* fallthrough */ From a3b5376521a0de898440e8d0942b54e628f0949f Mon Sep 17 00:00:00 2001 From: Xiaoyao Li Date: Wed, 24 Jan 2024 21:40:15 -0500 Subject: [PATCH 07/17] i386/cpuid: Remove subleaf constraint on CPUID leaf 1F No such constraint that subleaf index needs to be less than 64. Signed-off-by: Xiaoyao Li Reviewed-by:Yang Weijiang Message-ID: <20240125024016.2521244-3-xiaoyao.li@intel.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index dff9dedbd7..9758c83693 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1926,10 +1926,6 @@ int kvm_arch_init_vcpu(CPUState *cs) break; } - if (i == 0x1f && j == 64) { - break; - } - c->function = i; c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX; c->index = j; From 0729857c707535847d7fe31d3d91eb8b2a118e3c Mon Sep 17 00:00:00 2001 From: Xiaoyao Li Date: Wed, 24 Jan 2024 21:40:16 -0500 Subject: [PATCH 08/17] i386/cpuid: Move leaf 7 to correct group CPUID leaf 7 was grouped together with SGX leaf 0x12 by commit b9edbadefb9e ("i386: Propagate SGX CPUID sub-leafs to KVM") by mistake. SGX leaf 0x12 has its specific logic to check if subleaf (starting from 2) is valid or not by checking the bit 0:3 of corresponding EAX is 1 or not. Leaf 7 follows the logic that EAX of subleaf 0 enumerates the maximum valid subleaf. Fixes: b9edbadefb9e ("i386: Propagate SGX CPUID sub-leafs to KVM") Signed-off-by: Xiaoyao Li Message-ID: <20240125024016.2521244-4-xiaoyao.li@intel.com> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 9758c83693..42970ab046 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1951,7 +1951,6 @@ int kvm_arch_init_vcpu(CPUState *cs) c = &cpuid_data.entries[cpuid_i++]; } break; - case 0x7: case 0x12: for (j = 0; ; j++) { c->function = i; @@ -1971,6 +1970,7 @@ int kvm_arch_init_vcpu(CPUState *cs) c = &cpuid_data.entries[cpuid_i++]; } break; + case 0x7: case 0x14: case 0x1d: case 0x1e: { From deac624f221bf8000c19e138547832ac0144c610 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 29 Jan 2024 12:34:27 +0100 Subject: [PATCH 09/17] mips: remove unnecessary "select PTIMER" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no use of ptimer functions in mips_cps.c or any other related code. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Paolo Bonzini --- hw/mips/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/mips/Kconfig b/hw/mips/Kconfig index 505381a0bb..ab61af209a 100644 --- a/hw/mips/Kconfig +++ b/hw/mips/Kconfig @@ -50,7 +50,6 @@ config LOONGSON3V config MIPS_CPS bool - select PTIMER select MIPS_ITU config MIPS_BOSTON From 41514c0a77346da43994bc98f43c34f95cf2e0d3 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 29 Jan 2024 14:32:38 +0100 Subject: [PATCH 10/17] isa-superio: validate floppy.count value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure that the value is valid; it can only be zero or one. And never create a floppy disk controller if it is zero. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Paolo Bonzini --- hw/isa/isa-superio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c index 7dbfc374da..e06a548c68 100644 --- a/hw/isa/isa-superio.c +++ b/hw/isa/isa-superio.c @@ -116,7 +116,9 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) } /* Floppy disc */ - if (!k->floppy.is_enabled || k->floppy.is_enabled(sio, 0)) { + assert(k->floppy.count <= 1); + if (k->floppy.count && + (!k->floppy.is_enabled || k->floppy.is_enabled(sio, 0))) { isa = isa_new(TYPE_ISA_FDC); d = DEVICE(isa); if (k->floppy.get_iobase) { From 2fdc20f9d47f8bcfb9ba54a70a49a9da72901b00 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 29 Jan 2024 14:33:54 +0100 Subject: [PATCH 11/17] smc37c669: remove useless is_enabled functions Calls to is_enabled are bounded to indices that actually exist in the SuperIO device. Therefore, the is_enabled functions in smc37c669 are not doing anything and they can be removed. Reviewed-by: Bernhard Beschow Signed-off-by: Paolo Bonzini --- hw/isa/smc37c669-superio.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/hw/isa/smc37c669-superio.c b/hw/isa/smc37c669-superio.c index 18287741cb..388e2ed937 100644 --- a/hw/isa/smc37c669-superio.c +++ b/hw/isa/smc37c669-superio.c @@ -14,11 +14,6 @@ /* UARTs (compatible with NS16450 or PC16550) */ -static bool is_serial_enabled(ISASuperIODevice *sio, uint8_t index) -{ - return index < 2; -} - static uint16_t get_serial_iobase(ISASuperIODevice *sio, uint8_t index) { return index ? 0x2f8 : 0x3f8; @@ -31,11 +26,6 @@ static unsigned int get_serial_irq(ISASuperIODevice *sio, uint8_t index) /* Parallel port */ -static bool is_parallel_enabled(ISASuperIODevice *sio, uint8_t index) -{ - return index < 1; -} - static uint16_t get_parallel_iobase(ISASuperIODevice *sio, uint8_t index) { return 0x378; @@ -53,11 +43,6 @@ static unsigned int get_parallel_dma(ISASuperIODevice *sio, uint8_t index) /* Diskette controller (Software compatible with the Intel PC8477) */ -static bool is_fdc_enabled(ISASuperIODevice *sio, uint8_t index) -{ - return index < 1; -} - static uint16_t get_fdc_iobase(ISASuperIODevice *sio, uint8_t index) { return 0x3f0; @@ -79,20 +64,17 @@ static void smc37c669_class_init(ObjectClass *klass, void *data) sc->parallel = (ISASuperIOFuncs){ .count = 1, - .is_enabled = is_parallel_enabled, .get_iobase = get_parallel_iobase, .get_irq = get_parallel_irq, .get_dma = get_parallel_dma, }; sc->serial = (ISASuperIOFuncs){ .count = 2, - .is_enabled = is_serial_enabled, .get_iobase = get_serial_iobase, .get_irq = get_serial_irq, }; sc->floppy = (ISASuperIOFuncs){ .count = 1, - .is_enabled = is_fdc_enabled, .get_iobase = get_fdc_iobase, .get_irq = get_fdc_irq, .get_dma = get_fdc_dma, From 6f738143b3ff5b009819848d3871382208d55908 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 25 Jan 2024 14:13:06 +0100 Subject: [PATCH 12/17] configure: do not create legacy symlinks With more than three years since Meson was introduced in the build system, people have had quite some time to move away from the foo-softmmu/qemu-system-* and foo-linux-user/qemu-* symbolic links. Remove them, and with them another instance of the "softmmu" name for system emulators. Reviewed-by: Thomas Huth Signed-off-by: Paolo Bonzini --- configure | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/configure b/configure index ff058d6c48..9cdb5a6818 100755 --- a/configure +++ b/configure @@ -1605,21 +1605,11 @@ echo "GENISOIMAGE=$genisoimage" >> $config_host_mak echo "MESON=$meson" >> $config_host_mak echo "NINJA=$ninja" >> $config_host_mak echo "EXESUF=$EXESUF" >> $config_host_mak - # use included Linux headers for KVM architectures if test "$host_os" = "linux" && test -n "$linux_arch"; then symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm fi -for target in $target_list; do - target_dir="$target" - target_name=$(echo $target | cut -d '-' -f 1)$EXESUF - case $target in - *-user) symlink "../qemu-$target_name" "$target_dir/qemu-$target_name" ;; - *) symlink "../qemu-system-$target_name" "$target_dir/qemu-system-$target_name" ;; - esac -done - if test "$default_targets" = "yes"; then echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak fi From 32f8f83287349eedb677d9ea32b71fc6ab06964a Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 25 Jan 2024 14:13:20 +0100 Subject: [PATCH 13/17] configure: put all symlink creation together Cc: Thomas Huth Signed-off-by: Paolo Bonzini --- configure | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 9cdb5a6818..3cd736b139 100755 --- a/configure +++ b/configure @@ -1538,6 +1538,11 @@ for f in $LINKS ; do fi done +# use included Linux headers for KVM architectures +if test "$host_os" = "linux" && test -n "$linux_arch"; then + symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm +fi + echo "# Automatically generated by configure - do not modify" > Makefile.prereqs # Mac OS X ships with a broken assembler @@ -1605,11 +1610,6 @@ echo "GENISOIMAGE=$genisoimage" >> $config_host_mak echo "MESON=$meson" >> $config_host_mak echo "NINJA=$ninja" >> $config_host_mak echo "EXESUF=$EXESUF" >> $config_host_mak -# use included Linux headers for KVM architectures -if test "$host_os" = "linux" && test -n "$linux_arch"; then - symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm -fi - if test "$default_targets" = "yes"; then echo "CONFIG_DEFAULT_TARGETS=y" >> $config_host_mak fi From d8c7f1334fa4cb3a99de7cb664095902c5fc6605 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 9 Feb 2024 22:55:54 +0100 Subject: [PATCH 14/17] i386: xen: fix compilation --without-default-devices The xenpv machine type requires XEN_BUS, so select it. Signed-off-by: Paolo Bonzini --- accel/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/accel/Kconfig b/accel/Kconfig index a30cf2eb48..794e0d18d2 100644 --- a/accel/Kconfig +++ b/accel/Kconfig @@ -16,3 +16,4 @@ config KVM config XEN bool select FSDEV_9P if VIRTFS + select XEN_BUS From 99d0dcd7f102c07a510200d768cae65e5db25d23 Mon Sep 17 00:00:00 2001 From: Ziqiao Kong Date: Thu, 15 Feb 2024 17:50:17 +0800 Subject: [PATCH 15/17] target/i386: Generate an illegal opcode exception on cmp instructions with lock prefix target/i386: As specified by Intel Manual Vol2 3-180, cmp instructions are not allowed to have lock prefix and a `UD` should be raised. Without this patch, s1->T0 will be uninitialized and used in the case OP_CMPL. Signed-off-by: Ziqiao Kong Message-ID: <20240215095015.570748-2-ziqiaokong@gmail.com> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- target/i386/tcg/translate.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 10cba16256..07f642dc9e 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -1507,12 +1507,13 @@ static bool check_iopl(DisasContext *s) /* if d == OR_TMP0, it means memory operand (address in A0) */ static void gen_op(DisasContext *s1, int op, MemOp ot, int d) { + /* Invalid lock prefix when destination is not memory or OP_CMPL. */ + if ((d != OR_TMP0 || op == OP_CMPL) && s1->prefix & PREFIX_LOCK) { + gen_illegal_opcode(s1); + return; + } + if (d != OR_TMP0) { - if (s1->prefix & PREFIX_LOCK) { - /* Lock prefix when destination is not memory. */ - gen_illegal_opcode(s1); - return; - } gen_op_mov_v_reg(s1, ot, s1->T0, d); } else if (!(s1->prefix & PREFIX_LOCK)) { gen_op_ld_v(s1, ot, s1->T0, s1->A0); From 726c60993689790b515b20603f3710b2b0418ee9 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 29 Jan 2024 14:05:29 +0100 Subject: [PATCH 16/17] usb: inline device creation functions Allow boards to use the device creation functions even if USB itself is not available; of course the functions will fail inexorably, but this can be okay if the calls are conditional on the existence of some USB host controller device. This is for example the case for hw/mips/loongson3_virt.c. Acked-by: Richard Henderson Signed-off-by: Paolo Bonzini --- hw/usb/bus.c | 23 ----------------------- include/hw/usb.h | 27 ++++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 59c39945dd..76fda41b7e 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -329,29 +329,6 @@ void usb_legacy_register(const char *typename, const char *usbdevice_name, } } -USBDevice *usb_new(const char *name) -{ - return USB_DEVICE(qdev_new(name)); -} - -static USBDevice *usb_try_new(const char *name) -{ - return USB_DEVICE(qdev_try_new(name)); -} - -bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp) -{ - return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp); -} - -USBDevice *usb_create_simple(USBBus *bus, const char *name) -{ - USBDevice *dev = usb_new(name); - - usb_realize_and_unref(dev, bus, &error_abort); - return dev; -} - static void usb_fill_port(USBPort *port, void *opaque, int index, USBPortOps *ops, int speedmask) { diff --git a/include/hw/usb.h b/include/hw/usb.h index 32c23a5ca2..cfeead2840 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -30,6 +30,7 @@ #include "qemu/iov.h" #include "qemu/queue.h" #include "qom/object.h" +#include "qapi/error.h" /* Constants related to the USB / PCI interaction */ #define USB_SBRN 0x60 /* Serial Bus Release Number Register */ @@ -500,9 +501,6 @@ void usb_bus_release(USBBus *bus); USBBus *usb_bus_find(int busnr); void usb_legacy_register(const char *typename, const char *usbdevice_name, USBDevice *(*usbdevice_init)(void)); -USBDevice *usb_new(const char *name); -bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp); -USBDevice *usb_create_simple(USBBus *bus, const char *name); USBDevice *usbdevice_create(const char *cmdline); void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index, USBPortOps *ops, int speedmask); @@ -582,4 +580,27 @@ void usb_pcap_init(FILE *fp); void usb_pcap_ctrl(USBPacket *p, bool setup); void usb_pcap_data(USBPacket *p, bool setup); +static inline USBDevice *usb_new(const char *name) +{ + return USB_DEVICE(qdev_new(name)); +} + +static inline USBDevice *usb_try_new(const char *name) +{ + return USB_DEVICE(qdev_try_new(name)); +} + +static inline bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp) +{ + return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp); +} + +static inline USBDevice *usb_create_simple(USBBus *bus, const char *name) +{ + USBDevice *dev = usb_new(name); + + usb_realize_and_unref(dev, bus, &error_abort); + return dev; +} + #endif From 5f9beb5001738d9d32bb8a617ed0528d99d7f09a Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 13 Feb 2024 16:48:39 +0100 Subject: [PATCH 17/17] ci: Fix again build-previous-qemu The build-previous-qemu job is now trying to fetch from the upstream repository, but the tag is only fetched into FETCH_HEAD: $ git remote add upstream https://gitlab.com/qemu-project/qemu 00:00 $ git fetch upstream $QEMU_PREV_VERSION 00:02 warning: redirecting to https://gitlab.com/qemu-project/qemu.git/ From https://gitlab.com/qemu-project/qemu * tag v8.2.0 -> FETCH_HEAD $ git checkout $QEMU_PREV_VERSION 00:02 error: pathspec v8.2.0 did not match any file(s) known to git Fix by fetching the tag into the checkout itself. Reviewed-by: Fabiano Rosas Signed-off-by: Paolo Bonzini --- .gitlab-ci.d/buildtest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index f56df59c94..a1c030337b 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -190,7 +190,7 @@ build-previous-qemu: before_script: - export QEMU_PREV_VERSION="$(sed 's/\([0-9.]*\)\.[0-9]*/v\1.0/' VERSION)" - git remote add upstream https://gitlab.com/qemu-project/qemu - - git fetch upstream $QEMU_PREV_VERSION + - git fetch upstream refs/tags/$QEMU_PREV_VERSION:refs/tags/$QEMU_PREV_VERSION - git checkout $QEMU_PREV_VERSION after_script: - mv build build-previous