From f8bfbf06df93e361609a8186051d148736ffa038 Mon Sep 17 00:00:00 2001 From: "taifu.gc" Date: Sat, 14 Jun 2025 13:24:19 +0800 Subject: [PATCH] Add patch to fix riscv build failure --- ...definition-to-conditionalize-debug-s.patch | 185 ++++++++++++++++++ qemu.spec | 6 +- 2 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 0354-kvm-use-configs-definition-to-conditionalize-debug-s.patch diff --git a/0354-kvm-use-configs-definition-to-conditionalize-debug-s.patch b/0354-kvm-use-configs-definition-to-conditionalize-debug-s.patch new file mode 100644 index 0000000..df0d03e --- /dev/null +++ b/0354-kvm-use-configs-definition-to-conditionalize-debug-s.patch @@ -0,0 +1,185 @@ +From cab0a521311a9ca334fc2b97d560c68cb6759c78 Mon Sep 17 00:00:00 2001 +From: Paolo Bonzini +Date: Fri, 22 Mar 2024 19:29:07 +0100 +Subject: [PATCH] kvm: use configs/ definition to conditionalize debug support + +If an architecture adds support for KVM_CAP_SET_GUEST_DEBUG but QEMU does not +have the necessary code, QEMU will fail to build after updating kernel headers. +Avoid this by using a #define in config-target.h instead of KVM_CAP_SET_GUEST_DEBUG. + +Signed-off-by: Paolo Bonzini +--- + accel/kvm/kvm-accel-ops.c | 4 ++-- + accel/kvm/kvm-all.c | 10 +++++----- + configs/targets/aarch64-softmmu.mak | 1 + + configs/targets/i386-softmmu.mak | 1 + + configs/targets/ppc-softmmu.mak | 1 + + configs/targets/ppc64-softmmu.mak | 1 + + configs/targets/s390x-softmmu.mak | 1 + + configs/targets/x86_64-softmmu.mak | 1 + + include/sysemu/kvm.h | 2 +- + include/sysemu/kvm_int.h | 2 +- + 10 files changed, 15 insertions(+), 9 deletions(-) + +diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c +index 54f19028b8..4c155f028a 100644 +--- a/accel/kvm/kvm-accel-ops.c ++++ b/accel/kvm/kvm-accel-ops.c +@@ -86,7 +86,7 @@ static bool kvm_cpus_are_resettable(void) + return !kvm_enabled() || kvm_cpu_check_are_resettable(); + } + +-#ifdef KVM_CAP_SET_GUEST_DEBUG ++#ifdef TARGET_KVM_HAVE_GUEST_DEBUG + static int kvm_update_guest_debug_ops(CPUState *cpu) + { + return kvm_update_guest_debug(cpu, 0); +@@ -105,7 +105,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void *data) + ops->synchronize_state = kvm_cpu_synchronize_state; + ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm; + +-#ifdef KVM_CAP_SET_GUEST_DEBUG ++#ifdef TARGET_KVM_HAVE_GUEST_DEBUG + ops->update_guest_debug = kvm_update_guest_debug_ops; + ops->supports_guest_debug = kvm_supports_guest_debug; + ops->insert_breakpoint = kvm_insert_breakpoint; +diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c +index aaee470b8a..73fb041347 100644 +--- a/accel/kvm/kvm-all.c ++++ b/accel/kvm/kvm-all.c +@@ -2409,7 +2409,7 @@ static int kvm_init(MachineState *ms) + s->sigmask_len = 8; + accel_blocker_init(); + +-#ifdef KVM_CAP_SET_GUEST_DEBUG ++#ifdef TARGET_KVM_HAVE_GUEST_DEBUG + QTAILQ_INIT(&s->kvm_sw_breakpoints); + #endif + QLIST_INIT(&s->kvm_parked_vcpus); +@@ -2597,7 +2597,7 @@ static int kvm_init(MachineState *ms) + kvm_vm_attributes_allowed = + (kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0); + +-#ifdef KVM_CAP_SET_GUEST_DEBUG ++#ifdef TARGET_KVM_HAVE_GUEST_DEBUG + kvm_has_guest_debug = + (kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG) > 0); + #endif +@@ -2606,7 +2606,7 @@ static int kvm_init(MachineState *ms) + if (kvm_has_guest_debug) { + kvm_sstep_flags = SSTEP_ENABLE; + +-#if defined KVM_CAP_SET_GUEST_DEBUG2 ++#if defined TARGET_KVM_HAVE_GUEST_DEBUG + int guest_debug_flags = + kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG2); + +@@ -3225,7 +3225,7 @@ bool kvm_arm_supports_user_irq(void) + return kvm_check_extension(kvm_state, KVM_CAP_ARM_USER_IRQ); + } + +-#ifdef KVM_CAP_SET_GUEST_DEBUG ++#ifdef TARGET_KVM_HAVE_GUEST_DEBUG + struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *cpu, vaddr pc) + { + struct kvm_sw_breakpoint *bp; +@@ -3385,7 +3385,7 @@ void kvm_remove_all_breakpoints(CPUState *cpu) + } + } + +-#endif /* !KVM_CAP_SET_GUEST_DEBUG */ ++#endif /* !TARGET_KVM_HAVE_GUEST_DEBUG */ + + static int kvm_set_signal_mask(CPUState *cpu, const sigset_t *sigset) + { +diff --git a/configs/targets/aarch64-softmmu.mak b/configs/targets/aarch64-softmmu.mak +index b4338e9568..83c22391a6 100644 +--- a/configs/targets/aarch64-softmmu.mak ++++ b/configs/targets/aarch64-softmmu.mak +@@ -1,5 +1,6 @@ + TARGET_ARCH=aarch64 + TARGET_BASE_ARCH=arm + TARGET_SUPPORTS_MTTCG=y ++TARGET_KVM_HAVE_GUEST_DEBUG=y + TARGET_XML_FILES= gdb-xml/aarch64-core.xml gdb-xml/aarch64-fpu.xml gdb-xml/arm-core.xml gdb-xml/arm-vfp.xml gdb-xml/arm-vfp3.xml gdb-xml/arm-vfp-sysregs.xml gdb-xml/arm-neon.xml gdb-xml/arm-m-profile.xml gdb-xml/arm-m-profile-mve.xml gdb-xml/aarch64-pauth.xml + TARGET_NEED_FDT=y +diff --git a/configs/targets/i386-softmmu.mak b/configs/targets/i386-softmmu.mak +index 6b3c99fc86..d61b507613 100644 +--- a/configs/targets/i386-softmmu.mak ++++ b/configs/targets/i386-softmmu.mak +@@ -1,4 +1,5 @@ + TARGET_ARCH=i386 + TARGET_SUPPORTS_MTTCG=y + TARGET_NEED_FDT=y ++TARGET_KVM_HAVE_GUEST_DEBUG=y + TARGET_XML_FILES= gdb-xml/i386-32bit.xml +diff --git a/configs/targets/ppc-softmmu.mak b/configs/targets/ppc-softmmu.mak +index 774440108f..f3ea9c98f7 100644 +--- a/configs/targets/ppc-softmmu.mak ++++ b/configs/targets/ppc-softmmu.mak +@@ -1,4 +1,5 @@ + TARGET_ARCH=ppc + TARGET_BIG_ENDIAN=y ++TARGET_KVM_HAVE_GUEST_DEBUG=y + TARGET_XML_FILES= gdb-xml/power-core.xml gdb-xml/power-fpu.xml gdb-xml/power-altivec.xml gdb-xml/power-spe.xml + TARGET_NEED_FDT=y +diff --git a/configs/targets/ppc64-softmmu.mak b/configs/targets/ppc64-softmmu.mak +index ddf0c39617..1db8d8381d 100644 +--- a/configs/targets/ppc64-softmmu.mak ++++ b/configs/targets/ppc64-softmmu.mak +@@ -2,5 +2,6 @@ TARGET_ARCH=ppc64 + TARGET_BASE_ARCH=ppc + TARGET_BIG_ENDIAN=y + TARGET_SUPPORTS_MTTCG=y ++TARGET_KVM_HAVE_GUEST_DEBUG=y + TARGET_XML_FILES= gdb-xml/power64-core.xml gdb-xml/power-fpu.xml gdb-xml/power-altivec.xml gdb-xml/power-spe.xml gdb-xml/power-vsx.xml + TARGET_NEED_FDT=y +diff --git a/configs/targets/s390x-softmmu.mak b/configs/targets/s390x-softmmu.mak +index 70d2f9f0ba..b22218aacc 100644 +--- a/configs/targets/s390x-softmmu.mak ++++ b/configs/targets/s390x-softmmu.mak +@@ -1,4 +1,5 @@ + TARGET_ARCH=s390x + TARGET_BIG_ENDIAN=y + TARGET_SUPPORTS_MTTCG=y ++TARGET_KVM_HAVE_GUEST_DEBUG=y + TARGET_XML_FILES= gdb-xml/s390x-core64.xml gdb-xml/s390-acr.xml gdb-xml/s390-fpr.xml gdb-xml/s390-vx.xml gdb-xml/s390-cr.xml gdb-xml/s390-virt.xml gdb-xml/s390-virt-kvm.xml gdb-xml/s390-gs.xml +diff --git a/configs/targets/x86_64-softmmu.mak b/configs/targets/x86_64-softmmu.mak +index 197817c943..c5f882e5ba 100644 +--- a/configs/targets/x86_64-softmmu.mak ++++ b/configs/targets/x86_64-softmmu.mak +@@ -2,4 +2,5 @@ TARGET_ARCH=x86_64 + TARGET_BASE_ARCH=i386 + TARGET_SUPPORTS_MTTCG=y + TARGET_NEED_FDT=y ++TARGET_KVM_HAVE_GUEST_DEBUG=y + TARGET_XML_FILES= gdb-xml/i386-64bit.xml +diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h +index fa1e42f085..facebf1e9f 100644 +--- a/include/sysemu/kvm.h ++++ b/include/sysemu/kvm.h +@@ -247,7 +247,7 @@ void kvm_flush_coalesced_mmio_buffer(void); + * calling down to kvm_arch_update_guest_debug after the generic + * fields have been set. + */ +-#ifdef KVM_CAP_SET_GUEST_DEBUG ++#ifdef TARGET_KVM_HAVE_GUEST_DEBUG + int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap); + #else + static inline int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap) +diff --git a/include/sysemu/kvm_int.h b/include/sysemu/kvm_int.h +index fd846394be..35aefb8d9a 100644 +--- a/include/sysemu/kvm_int.h ++++ b/include/sysemu/kvm_int.h +@@ -78,7 +78,7 @@ struct KVMState + struct kvm_coalesced_mmio_ring *coalesced_mmio_ring; + bool coalesced_flush_in_progress; + int vcpu_events; +-#ifdef KVM_CAP_SET_GUEST_DEBUG ++#ifdef TARGET_KVM_HAVE_GUEST_DEBUG + QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints; + #endif + int max_nested_state_len; +-- +2.39.3 + diff --git a/qemu.spec b/qemu.spec index dcf1afb..034d6c7 100644 --- a/qemu.spec +++ b/qemu.spec @@ -1,4 +1,4 @@ -%define anolis_release 29 +%define anolis_release 30 %bcond_with check %global all_system_emu_support 0 @@ -639,6 +639,7 @@ Patch0350: 0350-smbios-add-processor-family-option.patch Patch0351: 0351-smbios-function-to-set-default-processor-family.patch Patch0352: 0352-target-riscv-smbios-support-for-risc-v-virt-machine.patch Patch0353: 0353-qemu-options-enable-smbios-option-on-risc-v.patch +Patch0354: 0354-kvm-use-configs-definition-to-conditionalize-debug-s.patch ExclusiveArch: x86_64 aarch64 loongarch64 riscv64 @@ -2203,6 +2204,9 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ %endif %changelog +* Sat Jun 14 2025 Chang Gao - 2:8.2.0-30 +- add patch to fix riscv build failure + * Wed Jun 11 2025 Yihao Yan - 2:8.2.0-29 - add support for riscv build -- Gitee