Skip to contentSkip to conversation

target/arm: Compile accelerator-related objects as common code

PATCH Superseded Philippe Mathieu-Daudé 3 participants 20 messages Apr 1 – Apr 3

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover target/arm: Compile accelerator-related objects as common code

First drop TARGET_KVM_HAVE_GUEST_DEBUG (all targets but MIPS support it), then -- after minor changes -- move the ARM specific accelerator units to target_common_system_arch[] source set, allowing to remove arm_system_ss[] for good.

Philippe Mathieu-Daudé (8):
accel/kvm: Include missing 'exec/vaddr.h' header accel/kvm: Remove TARGET_KVM_HAVE_GUEST_DEBUG accel/kvm: Expose all non-target specific declarations target/arm: Compile WHPX as common object
target/arm: Remove target_ulong use in hvf_handle_psci_call() target/arm: Compile HVF as common object
target/arm: Remove target_ulong cast in kvm_arm_handle_dabt_nisv() target/arm: Compile KVM as common object

 configs/targets/aarch64-softmmu.mak     |  1 -
 configs/targets/i386-softmmu.mak        |  1 -
 configs/targets/loongarch64-softmmu.mak |  1 -
 configs/targets/ppc-softmmu.mak         |  1 -
 configs/targets/ppc64-softmmu.mak       |  1 -
 configs/targets/riscv64-softmmu.mak     |  1 -
 configs/targets/s390x-softmmu.mak       |  1 -
 configs/targets/x86_64-softmmu.mak      |  1 -
 include/system/kvm.h                    | 13 +------------
 include/system/kvm_int.h                |  2 --
 accel/kvm/kvm-accel-ops.c               |  4 ----
 accel/kvm/kvm-all.c                     | 13 ++-----------
 target/arm/hvf/hvf.c                    |  2 +-
 target/arm/kvm.c                        |  3 +--
 target/mips/kvm.c                       |  5 +++++
 target/arm/hvf/meson.build              |  2 +-
 target/arm/meson.build                  | 12 +++++++-----
 target/arm/whpx/meson.build             |  6 +++---
 18 files changed, 21 insertions(+), 49 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/8 accel/kvm: Include missing 'exec/vaddr.h' header

Commit b67be03e3ac ("accel/kvm: Widen pc/saved_insn for kvm_sw_breakpoint") used the vaddr type in the kvm_sw_breakpoint structure but forgot to include the header defining it. Do it now in order to avoid when refactoring unrelated headers:

include/system/kvm.h:404:5: error: unknown type name 'vaddr'

    404 |     vaddr pc;
        |     ^~~~~
  include/system/kvm.h:405:5: error: unknown type name 'vaddr'
    405 |     vaddr saved_insn;
        |     ^~~~~
---
 include/system/kvm.h | 1 +
 1 file changed, 1 insertion(+)
include/system/kvm.h +1 -0
index 5fa33eddda3..12f7fc8fb58 100644
@@ -17,6 +17,7 @@
 #define QEMU_KVM_H
 
 #include "exec/memattrs.h"
+#include "exec/vaddr.h"
 #include "qemu/accel.h"
 #include "qom/object.h"
 
Signature · 1 line
2.53.0
Reviewed-by on v1 1/8
#2 lore raw

Re: [PATCH-for-11.1 1/8] accel/kvm: Include missing 'exec/vaddr.h' header

Quoted 6 lines · Philippe Mathieu-Daudé

Commit b67be03e3ac ("accel/kvm: Widen pc/saved_insn for kvm_sw_breakpoint") used the vaddr type in the kvm_sw_breakpoint structure but forgot to include the header defining it. Do it now in order to avoid when refactoring unrelated headers:

Quoted 8 lines

include/system/kvm.h:404:5: error: unknown type name 'vaddr'

    404 |     vaddr pc;
        |     ^~~~~
  include/system/kvm.h:405:5: error: unknown type name 'vaddr'
    405 |     vaddr saved_insn;
        |     ^~~~~

Alistair

Quoted 20 lines
---
 include/system/kvm.h | 1 +
 1 file changed, 1 insertion(+)
include/system/kvm.h +1 -1
index 5fa33eddda3..12f7fc8fb58 100644
@@ -17,6 +17,7 @@
 #define QEMU_KVM_H
 
 #include "exec/memattrs.h"
+#include "exec/vaddr.h"
 #include "qemu/accel.h"
 #include "qom/object.h"
 
--

2.53.0

Reviewed-by on v1 1/8
#3 lore raw

Re: [PATCH-for-11.1 1/8] accel/kvm: Include missing 'exec/vaddr.h' header

In reply to Philippe Mathieu-Daudé
Quoted 12 lines · Philippe Mathieu-Daudé

Commit b67be03e3ac ("accel/kvm: Widen pc/saved_insn for kvm_sw_breakpoint") used the vaddr type in the kvm_sw_breakpoint structure but forgot to include the header defining it. Do it now in order to avoid when refactoring unrelated headers:

   include/system/kvm.h:404:5: error: unknown type name 'vaddr'
     404 |     vaddr pc;
         |     ^~~~~
   include/system/kvm.h:405:5: error: unknown type name 'vaddr'
     405 |     vaddr saved_insn;
         |     ^~~~~
Quoted 5 lines
---
  include/system/kvm.h | 1 +
  1 file changed, 1 insertion(+)

r~

Quoted 12 lines
include/system/kvm.h +1 -0
index 5fa33eddda3..12f7fc8fb58 100644
@@ -17,6 +17,7 @@
  #define QEMU_KVM_H
 
  #include "exec/memattrs.h"
+#include "exec/vaddr.h"
  #include "qemu/accel.h"
  #include "qom/object.h"
 
#4 lore raw

PATCH 2/8 accel/kvm: Remove TARGET_KVM_HAVE_GUEST_DEBUG

In reply to Philippe Mathieu-Daudé

All targets except MIPS have TARGET_KVM_HAVE_GUEST_DEBUG=y. Declare the kvm_update_guest_debug() stub to MIPS and have TARGET_KVM_HAVE_GUEST_DEBUG be the default.

---
 configs/targets/aarch64-softmmu.mak     |  1 -
 configs/targets/i386-softmmu.mak        |  1 -
 configs/targets/loongarch64-softmmu.mak |  1 -
 configs/targets/ppc-softmmu.mak         |  1 -
 configs/targets/ppc64-softmmu.mak       |  1 -
 configs/targets/riscv64-softmmu.mak     |  1 -
 configs/targets/s390x-softmmu.mak       |  1 -
 configs/targets/x86_64-softmmu.mak      |  1 -
 include/system/kvm.h                    |  7 -------
 include/system/kvm_int.h                |  2 --
 accel/kvm/kvm-accel-ops.c               |  4 ----
 accel/kvm/kvm-all.c                     | 13 ++-----------
 target/mips/kvm.c                       |  5 +++++
 13 files changed, 7 insertions(+), 32 deletions(-)
configs/targets/aarch64-softmmu.mak +0 -1
index d34aead41c4..6f60ca6505c 100644
@@ -1,6 +1,5 @@
 TARGET_ARCH=aarch64
 TARGET_BASE_ARCH=arm
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-vfp-sysregs.xml arm-neon.xml arm-m-profile.xml arm-m-profile-mve.xml aarch64-pauth.xml aarch64-sme2.xml
 # needed by boot.c
 TARGET_NEED_FDT=y
configs/targets/i386-softmmu.mak +0 -1
index 38a8f85201f..2eef68dc55e 100644
@@ -1,5 +1,4 @@
 TARGET_ARCH=i386
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_KVM_HAVE_RESET_PARKED_VCPU=y
 TARGET_XML_FILES= i386-32bit.xml
 TARGET_LONG_BITS=32
configs/targets/loongarch64-softmmu.mak +0 -1
index 476407f9413..7e0b1ab5d05 100644
@@ -1,6 +1,5 @@
 TARGET_ARCH=loongarch64
 TARGET_BASE_ARCH=loongarch
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= loongarch-base32.xml loongarch-base64.xml loongarch-fpu.xml loongarch-lsx.xml loongarch-lasx.xml
 # all boards require libfdt
 TARGET_NEED_FDT=y
configs/targets/ppc-softmmu.mak +0 -1
index 867898bd47c..c47887f8992 100644
@@ -1,5 +1,4 @@
 TARGET_ARCH=ppc
 TARGET_BIG_ENDIAN=y
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= power-core.xml power-fpu.xml power-altivec.xml power-spe.xml
 TARGET_LONG_BITS=32
configs/targets/ppc64-softmmu.mak +0 -1
index 10d7a2681e7..8c6dc84b821 100644
@@ -1,7 +1,6 @@
 TARGET_ARCH=ppc64
 TARGET_BASE_ARCH=ppc
 TARGET_BIG_ENDIAN=y
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml
 # all boards require libfdt
 TARGET_NEED_FDT=y
configs/targets/riscv64-softmmu.mak +0 -1
index 5059c550480..e0d2c7032d6 100644
@@ -1,6 +1,5 @@
 TARGET_ARCH=riscv64
 TARGET_BASE_ARCH=riscv
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= riscv-64bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-64bit-virtual.xml riscv-32bit-cpu.xml riscv-32bit-virtual.xml
 # needed by boot.c
 TARGET_NEED_FDT=y
configs/targets/s390x-softmmu.mak +0 -1
index e273075f1a9..699e5ced96f 100644
@@ -1,6 +1,5 @@
 TARGET_ARCH=s390x
 TARGET_BIG_ENDIAN=y
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-virt-kvm.xml s390-gs.xml
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/x86_64-softmmu.mak +0 -1
index c7f8746b4f5..491173df466 100644
@@ -1,6 +1,5 @@
 TARGET_ARCH=x86_64
 TARGET_BASE_ARCH=i386
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_KVM_HAVE_RESET_PARKED_VCPU=y
 TARGET_XML_FILES= i386-64bit.xml i386-64bit-apx.xml
 TARGET_LONG_BITS=64
include/system/kvm.h +0 -7
index 12f7fc8fb58..a2463a3ac3f 100644
@@ -236,14 +236,7 @@ void kvm_irqchip_change_notify(void);
  * calling down to kvm_arch_update_guest_debug after the generic
  * fields have been set.
  */
-#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)
-{
-    return -EINVAL;
-}
-#endif
 
 /* internal API */
 
include/system/kvm_int.h +0 -2
index 0876aac938d..9d1d3fd3deb 100644
@@ -113,9 +113,7 @@ struct KVMState
     struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
     bool coalesced_flush_in_progress;
     int vcpu_events;
-#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
     QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints;
-#endif
     int max_nested_state_len;
     int kvm_shadow_mem;
     bool kernel_irqchip_allowed;
accel/kvm/kvm-accel-ops.c +0 -4
index 6d9140e549f..d4af6b416c3 100644
@@ -85,12 +85,10 @@ static bool kvm_cpus_are_resettable(void)
     return !kvm_enabled() || !kvm_state->guest_state_protected;
 }
 
-#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
 static int kvm_update_guest_debug_ops(CPUState *cpu)
 {
     return kvm_update_guest_debug(cpu, 0);
 }
-#endif
 
 static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)
 {
@@ -105,13 +103,11 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)
     ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm;
     ops->handle_interrupt = generic_handle_interrupt;
 
-#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;
     ops->remove_breakpoint = kvm_remove_breakpoint;
     ops->remove_all_breakpoints = kvm_remove_all_breakpoints;
-#endif
 }
 
 static const TypeInfo kvm_accel_ops_type = {
accel/kvm/kvm-all.c +2 -11
index 774499d34f8..9a46a61b7f5 100644
@@ -2919,9 +2919,7 @@ static int kvm_init(AccelState *as, MachineState *ms)
     s->sigmask_len = 8;
     accel_blocker_init();
 
-#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
     QTAILQ_INIT(&s->kvm_sw_breakpoints);
-#endif
     QLIST_INIT(&s->kvm_parked_vcpus);
     s->fd = qemu_open_old(s->device ?: "/dev/kvm", O_RDWR);
     if (s->fd == -1) {
@@ -3032,23 +3030,19 @@ static int kvm_init(AccelState *as, MachineState *ms)
     kvm_vm_attributes_allowed =
         (kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0);
 
-#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
     kvm_has_guest_debug =
         (kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG) > 0);
-#endif
 
     kvm_sstep_flags = 0;
     if (kvm_has_guest_debug) {
-        kvm_sstep_flags = SSTEP_ENABLE;
-
-#if defined TARGET_KVM_HAVE_GUEST_DEBUG
         int guest_debug_flags =
             kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG2);
 
+        kvm_sstep_flags = SSTEP_ENABLE;
+
         if (guest_debug_flags & KVM_GUESTDBG_BLOCKIRQ) {
             kvm_sstep_flags |= SSTEP_NOIRQ;
         }
-#endif
     }
 
     kvm_state = s;
@@ -3781,7 +3775,6 @@ bool kvm_arm_supports_user_irq(void)
     return kvm_check_extension(kvm_state, KVM_CAP_ARM_USER_IRQ);
 }
 
-#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
 struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *cpu, vaddr pc)
 {
     struct kvm_sw_breakpoint *bp;
@@ -3941,8 +3934,6 @@ void kvm_remove_all_breakpoints(CPUState *cpu)
     }
 }
 
-#endif /* !TARGET_KVM_HAVE_GUEST_DEBUG */
-
 static int kvm_set_signal_mask(CPUState *cpu, const sigset_t *sigset)
 {
     KVMState *s = kvm_state;
target/mips/kvm.c +5 -0
index a85e162409c..49bff68b137 100644
@@ -1262,6 +1262,11 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
     abort();
 }
 
+int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
+{
+    return -EINVAL;
+}
+
 int kvm_arch_get_default_type(MachineState *machine)
 {
 #if defined(KVM_CAP_MIPS_VZ)
Signature · 1 line
2.53.0
Reviewed-by on v1 2/8
#5 lore raw

Re: [PATCH-for-11.1 2/8] accel/kvm: Remove TARGET_KVM_HAVE_GUEST_DEBUG

Quoted 6 lines · Philippe Mathieu-Daudé

All targets except MIPS have TARGET_KVM_HAVE_GUEST_DEBUG=y. Declare the kvm_update_guest_debug() stub to MIPS and have TARGET_KVM_HAVE_GUEST_DEBUG be the default.

Alistair

Quoted 244 lines
---
 configs/targets/aarch64-softmmu.mak     |  1 -
 configs/targets/i386-softmmu.mak        |  1 -
 configs/targets/loongarch64-softmmu.mak |  1 -
 configs/targets/ppc-softmmu.mak         |  1 -
 configs/targets/ppc64-softmmu.mak       |  1 -
 configs/targets/riscv64-softmmu.mak     |  1 -
 configs/targets/s390x-softmmu.mak       |  1 -
 configs/targets/x86_64-softmmu.mak      |  1 -
 include/system/kvm.h                    |  7 -------
 include/system/kvm_int.h                |  2 --
 accel/kvm/kvm-accel-ops.c               |  4 ----
 accel/kvm/kvm-all.c                     | 13 ++-----------
 target/mips/kvm.c                       |  5 +++++
 13 files changed, 7 insertions(+), 32 deletions(-)
configs/targets/aarch64-softmmu.mak +0 -1
index d34aead41c4..6f60ca6505c 100644
@@ -1,6 +1,5 @@
 TARGET_ARCH=aarch64
 TARGET_BASE_ARCH=arm
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= aarch64-core.xml aarch64-fpu.xml arm-core.xml arm-vfp.xml arm-vfp3.xml arm-vfp-sysregs.xml arm-neon.xml arm-m-profile.xml arm-m-profile-mve.xml aarch64-pauth.xml aarch64-sme2.xml
 # needed by boot.c
 TARGET_NEED_FDT=y
configs/targets/i386-softmmu.mak +0 -1
index 38a8f85201f..2eef68dc55e 100644
@@ -1,5 +1,4 @@
 TARGET_ARCH=i386
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_KVM_HAVE_RESET_PARKED_VCPU=y
 TARGET_XML_FILES= i386-32bit.xml
 TARGET_LONG_BITS=32
configs/targets/loongarch64-softmmu.mak +0 -1
index 476407f9413..7e0b1ab5d05 100644
@@ -1,6 +1,5 @@
 TARGET_ARCH=loongarch64
 TARGET_BASE_ARCH=loongarch
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= loongarch-base32.xml loongarch-base64.xml loongarch-fpu.xml loongarch-lsx.xml loongarch-lasx.xml
 # all boards require libfdt
 TARGET_NEED_FDT=y
configs/targets/ppc-softmmu.mak +0 -1
index 867898bd47c..c47887f8992 100644
@@ -1,5 +1,4 @@
 TARGET_ARCH=ppc
 TARGET_BIG_ENDIAN=y
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= power-core.xml power-fpu.xml power-altivec.xml power-spe.xml
 TARGET_LONG_BITS=32
configs/targets/ppc64-softmmu.mak +0 -1
index 10d7a2681e7..8c6dc84b821 100644
@@ -1,7 +1,6 @@
 TARGET_ARCH=ppc64
 TARGET_BASE_ARCH=ppc
 TARGET_BIG_ENDIAN=y
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml power-vsx.xml
 # all boards require libfdt
 TARGET_NEED_FDT=y
configs/targets/riscv64-softmmu.mak +0 -1
index 5059c550480..e0d2c7032d6 100644
@@ -1,6 +1,5 @@
 TARGET_ARCH=riscv64
 TARGET_BASE_ARCH=riscv
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= riscv-64bit-cpu.xml riscv-32bit-fpu.xml riscv-64bit-fpu.xml riscv-64bit-virtual.xml riscv-32bit-cpu.xml riscv-32bit-virtual.xml
 # needed by boot.c
 TARGET_NEED_FDT=y
configs/targets/s390x-softmmu.mak +0 -1
index e273075f1a9..699e5ced96f 100644
@@ -1,6 +1,5 @@
 TARGET_ARCH=s390x
 TARGET_BIG_ENDIAN=y
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_XML_FILES= s390x-core64.xml s390-acr.xml s390-fpr.xml s390-vx.xml s390-cr.xml s390-virt.xml s390-virt-kvm.xml s390-gs.xml
 TARGET_LONG_BITS=64
 TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/x86_64-softmmu.mak +0 -1
index c7f8746b4f5..491173df466 100644
@@ -1,6 +1,5 @@
 TARGET_ARCH=x86_64
 TARGET_BASE_ARCH=i386
-TARGET_KVM_HAVE_GUEST_DEBUG=y
 TARGET_KVM_HAVE_RESET_PARKED_VCPU=y
 TARGET_XML_FILES= i386-64bit.xml i386-64bit-apx.xml
 TARGET_LONG_BITS=64
include/system/kvm.h +0 -7
index 12f7fc8fb58..a2463a3ac3f 100644
@@ -236,14 +236,7 @@ void kvm_irqchip_change_notify(void);
  * calling down to kvm_arch_update_guest_debug after the generic
  * fields have been set.
  */
-#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)
-{
-    return -EINVAL;
-}
-#endif
 
 /* internal API */
 
include/system/kvm_int.h +0 -2
index 0876aac938d..9d1d3fd3deb 100644
@@ -113,9 +113,7 @@ struct KVMState
     struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
     bool coalesced_flush_in_progress;
     int vcpu_events;
-#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
     QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints;
-#endif
     int max_nested_state_len;
     int kvm_shadow_mem;
     bool kernel_irqchip_allowed;
accel/kvm/kvm-accel-ops.c +0 -4
index 6d9140e549f..d4af6b416c3 100644
@@ -85,12 +85,10 @@ static bool kvm_cpus_are_resettable(void)
     return !kvm_enabled() || !kvm_state->guest_state_protected;
 }
 
-#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
 static int kvm_update_guest_debug_ops(CPUState *cpu)
 {
     return kvm_update_guest_debug(cpu, 0);
 }
-#endif
 
 static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)
 {
@@ -105,13 +103,11 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)
     ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm;
     ops->handle_interrupt = generic_handle_interrupt;
 
-#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;
     ops->remove_breakpoint = kvm_remove_breakpoint;
     ops->remove_all_breakpoints = kvm_remove_all_breakpoints;
-#endif
 }
 
 static const TypeInfo kvm_accel_ops_type = {
accel/kvm/kvm-all.c +2 -11
index 774499d34f8..9a46a61b7f5 100644
@@ -2919,9 +2919,7 @@ static int kvm_init(AccelState *as, MachineState *ms)
     s->sigmask_len = 8;
     accel_blocker_init();
 
-#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
     QTAILQ_INIT(&s->kvm_sw_breakpoints);
-#endif
     QLIST_INIT(&s->kvm_parked_vcpus);
     s->fd = qemu_open_old(s->device ?: "/dev/kvm", O_RDWR);
     if (s->fd == -1) {
@@ -3032,23 +3030,19 @@ static int kvm_init(AccelState *as, MachineState *ms)
     kvm_vm_attributes_allowed =
         (kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0);
 
-#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
     kvm_has_guest_debug =
         (kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG) > 0);
-#endif
 
     kvm_sstep_flags = 0;
     if (kvm_has_guest_debug) {
-        kvm_sstep_flags = SSTEP_ENABLE;
-
-#if defined TARGET_KVM_HAVE_GUEST_DEBUG
         int guest_debug_flags =
             kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG2);
 
+        kvm_sstep_flags = SSTEP_ENABLE;
+
         if (guest_debug_flags & KVM_GUESTDBG_BLOCKIRQ) {
             kvm_sstep_flags |= SSTEP_NOIRQ;
         }
-#endif
     }
 
     kvm_state = s;
@@ -3781,7 +3775,6 @@ bool kvm_arm_supports_user_irq(void)
     return kvm_check_extension(kvm_state, KVM_CAP_ARM_USER_IRQ);
 }
 
-#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
 struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *cpu, vaddr pc)
 {
     struct kvm_sw_breakpoint *bp;
@@ -3941,8 +3934,6 @@ void kvm_remove_all_breakpoints(CPUState *cpu)
     }
 }
 
-#endif /* !TARGET_KVM_HAVE_GUEST_DEBUG */
-
 static int kvm_set_signal_mask(CPUState *cpu, const sigset_t *sigset)
 {
     KVMState *s = kvm_state;
target/mips/kvm.c +5 -1
index a85e162409c..49bff68b137 100644
@@ -1262,6 +1262,11 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
     abort();
 }
 
+int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
+{
+    return -EINVAL;
+}
+
 int kvm_arch_get_default_type(MachineState *machine)
 {
 #if defined(KVM_CAP_MIPS_VZ)
--

2.53.0

Reviewed-by on v1 2/8
#6 lore raw

Re: [PATCH-for-11.1 2/8] accel/kvm: Remove TARGET_KVM_HAVE_GUEST_DEBUG

In reply to Philippe Mathieu-Daudé
Quoted 5 lines · Philippe Mathieu-Daudé

All targets except MIPS have TARGET_KVM_HAVE_GUEST_DEBUG=y. Declare the kvm_update_guest_debug() stub to MIPS and have TARGET_KVM_HAVE_GUEST_DEBUG be the default.

Quoted 15 lines
---
  configs/targets/aarch64-softmmu.mak     |  1 -
  configs/targets/i386-softmmu.mak        |  1 -
  configs/targets/loongarch64-softmmu.mak |  1 -
  configs/targets/ppc-softmmu.mak         |  1 -
  configs/targets/ppc64-softmmu.mak       |  1 -
  configs/targets/riscv64-softmmu.mak     |  1 -
  configs/targets/s390x-softmmu.mak       |  1 -
  configs/targets/x86_64-softmmu.mak      |  1 -
  include/system/kvm.h                    |  7 -------
  include/system/kvm_int.h                |  2 --
  accel/kvm/kvm-accel-ops.c               |  4 ----
  accel/kvm/kvm-all.c                     | 13 ++-----------
  target/mips/kvm.c                       |  5 +++++
  13 files changed, 7 insertions(+), 32 deletions(-)

r~

#7 lore raw

PATCH 3/8 accel/kvm: Expose all non-target specific declarations

In reply to Philippe Mathieu-Daudé

None of the declarations guarded within the COMPILING_PER_TARGET checks use target-specific declaration. "cpu.h" is not required since some time (maybe commit 4fb54de823e "meson: build target libraries with common dependencies"). Remove the restrictions.

---
 include/system/kvm.h | 5 -----
 1 file changed, 5 deletions(-)
include/system/kvm.h +0 -5
index a2463a3ac3f..8bf7a10deac 100644
@@ -224,9 +224,6 @@ void kvm_irqchip_add_change_notifier(Notifier *n);
 void kvm_irqchip_remove_change_notifier(Notifier *n);
 void kvm_irqchip_change_notify(void);
 
-#ifdef COMPILING_PER_TARGET
-#include "cpu.h"
-
 /**
  * kvm_update_guest_debug(): ensure KVM debug structures updated
  * @cs: the CPUState for this cpu
@@ -449,8 +446,6 @@ void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len);
 int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr,
                                        hwaddr *phys_addr);
 
-#endif /* COMPILING_PER_TARGET */
-
 bool kvm_arch_supports_vmfd_change(void);
 int kvm_arch_on_vmfd_change(MachineState *ms, KVMState *s);
 
Signature · 1 line
2.53.0
#8 lore raw

Re: [PATCH-for-11.1 3/8] accel/kvm: Expose all non-target specific declarations

Quoted 15 lines · Philippe Mathieu-Daudé

None of the declarations guarded within the COMPILING_PER_TARGET checks use target-specific declaration. "cpu.h" is not required since some time (maybe commit 4fb54de823e "meson: build target libraries with common dependencies"). Remove the restrictions.

---
  include/system/kvm.h | 5 -----
  1 file changed, 5 deletions(-)
include/system/kvm.h +0 -0
index a2463a3ac3f..8bf7a10deac 100644

include/system/kvm.h void kvm_irqchip_add_change_notifier(Notifier *n); · line 228

Quoted 5 lines
include/system/kvm.h +0 -2
@@ -224,9 +224,6 @@ void kvm_irqchip_add_change_notifier(Notifier *n);
  void kvm_irqchip_remove_change_notifier(Notifier *n);
  void kvm_irqchip_change_notify(void);
 
-#ifdef COMPILING_PER_TARGET
-#include "cpu.h"

Missing:

  #include "qemu/queue.h"
Quoted 12 lines
include/system/kvm.h +0 -2
  /**
   * kvm_update_guest_debug(): ensure KVM debug structures updated
   * @cs: the CPUState for this cpu
@@ -449,8 +446,6 @@ void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len);
  int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr,
                                         hwaddr *phys_addr);
 
-#endif /* COMPILING_PER_TARGET */
-
  bool kvm_arch_supports_vmfd_change(void);
  int kvm_arch_on_vmfd_change(MachineState *ms, KVMState *s);
 
Reviewed-by on v1 3/8
#9 lore raw

Re: [PATCH-for-11.1 3/8] accel/kvm: Expose all non-target specific declarations

In reply to Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé

None of the declarations guarded within the COMPILING_PER_TARGET checks use target-specific declaration. "cpu.h" is not required since some time (maybe commit 4fb54de823e "meson: build target libraries with common dependencies"). Remove the restrictions.

---
  include/system/kvm.h | 5 -----
  1 file changed, 5 deletions(-)

r~

#10 lore raw

PATCH 4/8 target/arm: Compile WHPX as common object

In reply to Philippe Mathieu-Daudé

whpx-all.c doesn't use target-specific code, move it from arm_system_ss[] to arm_common_system_ss[] to compile it once.

---
 target/arm/whpx/meson.build | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
target/arm/whpx/meson.build +3 -3
index 3df632c9d30..db31e928012 100644
@@ -1,5 +1,5 @@
-arm_system_ss.add(when: 'CONFIG_WHPX', if_true: files(
+arm_common_system_ss.add(when: 'CONFIG_WHPX', if_true: files(
   'whpx-all.c',
+), if_false: files(
+  'whpx-stub.c'
 ))
-
-arm_common_system_ss.add(when: 'CONFIG_WHPX', if_false: files('whpx-stub.c'))
Signature · 1 line
2.53.0
Reviewed-by on v1 4/8
#11 lore raw

Re: [PATCH-for-11.1 4/8] target/arm: Compile WHPX as common object

Quoted 13 lines · Philippe Mathieu-Daudé

whpx-all.c doesn't use target-specific code, move it from arm_system_ss[] to arm_common_system_ss[] to compile it once.

---
  target/arm/whpx/meson.build | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
target/arm/whpx/meson.build +0 -0
index 3df632c9d30..db31e928012 100644

target/arm/whpx/meson.build line 5

Quoted 8 lines
target/arm/whpx/meson.build +3 -3
@@ -1,5 +1,5 @@
-arm_system_ss.add(when: 'CONFIG_WHPX', if_true: files(
+arm_common_system_ss.add(when: 'CONFIG_WHPX', if_true: files(
    'whpx-all.c',
+), if_false: files(
+  'whpx-stub.c'
  ))
-
-arm_common_system_ss.add(when: 'CONFIG_WHPX', if_false: files('whpx-stub.c'))

r~

#12 lore raw

PATCH 5/8 target/arm: Remove target_ulong use in hvf_handle_psci_call()

In reply to Philippe Mathieu-Daudé

Similarly to commit 3580aa03547 ("target/arm/tcg/psci.c: make compilation unit common") which replaced the target_ulong use in arm_handle_psci_call(), replace the one in hvf_handle_psci_call.

---
 target/arm/hvf/hvf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/hvf/hvf.c +1 -1
index 5fc8f6bbbd9..678afe5c8e1 100644
@@ -1418,7 +1418,7 @@ static bool hvf_handle_psci_call(CPUState *cpu, int *excp_ret)
     bool target_aarch64 = true;
     CPUState *target_cpu_state;
     ARMCPU *target_cpu;
-    target_ulong entry;
+    uint64_t entry;
     int target_el = 1;
     int32_t ret = 0;
 
Signature · 1 line
2.53.0
Reviewed-by on v1 5/8
#13 lore raw

Re: [PATCH-for-11.1 5/8] target/arm: Remove target_ulong use in hvf_handle_psci_call()

Quoted 15 lines · Philippe Mathieu-Daudé

Similarly to commit 3580aa03547 ("target/arm/tcg/psci.c: make compilation unit common") which replaced the target_ulong use in arm_handle_psci_call(), replace the one in hvf_handle_psci_call.

---
  target/arm/hvf/hvf.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/hvf/hvf.c +0 -0
index 5fc8f6bbbd9..678afe5c8e1 100644

target/arm/hvf/hvf.c static bool hvf_handle_psci_call(CPUState *cpu, int *excp_ret) · line 1424

Quoted 8 lines
target/arm/hvf/hvf.c +1 -1
@@ -1418,7 +1418,7 @@ static bool hvf_handle_psci_call(CPUState *cpu, int *excp_ret)
      bool target_aarch64 = true;
      CPUState *target_cpu_state;
      ARMCPU *target_cpu;
-    target_ulong entry;
+    uint64_t entry;
      int target_el = 1;
      int32_t ret = 0;
 

This could be vaddr, because entry is the start pc for the on-lining cpu. But uint64_t does match arm_set_cpu_on declaration.

Anyway,

r~

#14 lore raw

PATCH 6/8 target/arm: Compile HVF as common object

In reply to Philippe Mathieu-Daudé

Neither of hvf.c nor hyp_gdbstub.c use target-specific code. Move them from arm_system_ss[] to arm_common_system_ss[] to compile them once.

---
 target/arm/hvf/meson.build | 2 +-
 target/arm/meson.build     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
target/arm/hvf/meson.build +1 -1
index afc509a470e..ccb0d338af6 100644
@@ -1,3 +1,3 @@
-arm_system_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: files(
+arm_common_system_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: files(
   'hvf.c',
 ))
target/arm/meson.build +1 -1
index 6e0e504a403..f14debc6a2f 100644
@@ -20,7 +20,6 @@ arm_common_system_ss.add(files(
   'arm-qmp-cmds.c',
 ))
 arm_system_ss.add(when: 'CONFIG_KVM', if_true: files('hyp_gdbstub.c', 'kvm.c'))
-arm_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c'))
 
 arm_user_ss.add(files('cpu.c'))
 arm_user_ss.add(when: 'TARGET_AARCH64', if_false: files(
@@ -41,6 +40,7 @@ arm_common_system_ss.add(files('cpu.c'))
 arm_common_system_ss.add(when: 'TARGET_AARCH64', if_false: files(
   'cpu32-stubs.c'))
 arm_common_system_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
+arm_common_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c'))
 arm_common_system_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING',
 		                 if_true: files('common-semi-target.c'))
 arm_common_system_ss.add(files(
Signature · 1 line
2.53.0
Reviewed-by on v1 6/8
#15 lore raw

Re: [PATCH-for-11.1 6/8] target/arm: Compile HVF as common object

Quoted 9 lines · Philippe Mathieu-Daudé

Neither of hvf.c nor hyp_gdbstub.c use target-specific code. Move them from arm_system_ss[] to arm_common_system_ss[] to compile them once.

---
  target/arm/hvf/meson.build | 2 +-
  target/arm/meson.build     | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

r~

Quoted 30 lines
target/arm/hvf/meson.build +1 -1
index afc509a470e..ccb0d338af6 100644
@@ -1,3 +1,3 @@
-arm_system_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: files(
+arm_common_system_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: files(
    'hvf.c',
  ))
target/arm/meson.build +1 -1
index 6e0e504a403..f14debc6a2f 100644
@@ -20,7 +20,6 @@ arm_common_system_ss.add(files(
    'arm-qmp-cmds.c',
  ))
  arm_system_ss.add(when: 'CONFIG_KVM', if_true: files('hyp_gdbstub.c', 'kvm.c'))
-arm_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c'))
 
  arm_user_ss.add(files('cpu.c'))
  arm_user_ss.add(when: 'TARGET_AARCH64', if_false: files(
@@ -41,6 +40,7 @@ arm_common_system_ss.add(files('cpu.c'))
  arm_common_system_ss.add(when: 'TARGET_AARCH64', if_false: files(
    'cpu32-stubs.c'))
  arm_common_system_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
+arm_common_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c'))
  arm_common_system_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING',
  		                 if_true: files('common-semi-target.c'))
  arm_common_system_ss.add(files(
#16 lore raw

PATCH 7/8 target/arm: Remove target_ulong cast in kvm_arm_handle_dabt_nisv()

In reply to Philippe Mathieu-Daudé

kvm_arm_handle_dabt_nisv() uses a uint64_t type for its @fault_ipa argument since its introduction in commit 694bcaa81f4 ("target/arm:
kvm: Handle DABT with no valid ISS"). Use the proper format and remove the pointless cast.

---
 target/arm/kvm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
target/arm/kvm.c +1 -2
index d4a68874b88..c09dc4cb3dc 100644
@@ -1453,8 +1453,7 @@ static int kvm_arm_handle_dabt_nisv(ARMCPU *cpu, uint64_t esr_iss,
         }
     } else {
         error_report("Data abort exception triggered by guest memory access "
-                     "at physical address: 0x"  TARGET_FMT_lx,
-                     (target_ulong)fault_ipa);
+                     "at physical address: 0x%08"  PRIx64, fault_ipa);
         error_printf("KVM unable to emulate faulting instruction.\n");
     }
     return -1;
Signature · 1 line
2.53.0
Reviewed-by on v1 7/8
#17 lore raw

Re: [PATCH-for-11.1 7/8] target/arm: Remove target_ulong cast in kvm_arm_handle_dabt_nisv()

Quoted 9 lines · Philippe Mathieu-Daudé

kvm_arm_handle_dabt_nisv() uses a uint64_t type for its @fault_ipa argument since its introduction in commit 694bcaa81f4 ("target/arm:
kvm: Handle DABT with no valid ISS"). Use the proper format and remove the pointless cast.

---
  target/arm/kvm.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

r~

Quoted 15 lines
target/arm/kvm.c +1 -2
index d4a68874b88..c09dc4cb3dc 100644
@@ -1453,8 +1453,7 @@ static int kvm_arm_handle_dabt_nisv(ARMCPU *cpu, uint64_t esr_iss,
          }
      } else {
          error_report("Data abort exception triggered by guest memory access "
-                     "at physical address: 0x"  TARGET_FMT_lx,
-                     (target_ulong)fault_ipa);
+                     "at physical address: 0x%08"  PRIx64, fault_ipa);
          error_printf("KVM unable to emulate faulting instruction.\n");
      }
      return -1;
#18 lore raw

PATCH 8/8 target/arm: Compile KVM as common object

In reply to Philippe Mathieu-Daudé

Neither of kvm.c nor hyp_gdbstub.c use target-specific code. Move them from arm_system_ss[] to arm_common_system_ss[] to compile them once. The arm_system_ss[] source set ends up unused, remove it.

---
 target/arm/meson.build | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
target/arm/meson.build +6 -4
index f14debc6a2f..1b5d346d474 100644
@@ -1,7 +1,6 @@
 arm_ss = ss.source_set()
 arm_common_ss = ss.source_set()
 arm_common_system_ss = ss.source_set()
-arm_system_ss = ss.source_set()
 arm_user_ss = ss.source_set()
 
 arm_common_system_ss.add(files('gdbstub.c'))
@@ -19,7 +18,6 @@ arm_common_ss.add(files(
 arm_common_system_ss.add(files(
   'arm-qmp-cmds.c',
 ))
-arm_system_ss.add(when: 'CONFIG_KVM', if_true: files('hyp_gdbstub.c', 'kvm.c'))
 
 arm_user_ss.add(files('cpu.c'))
 arm_user_ss.add(when: 'TARGET_AARCH64', if_false: files(
@@ -39,7 +37,12 @@ arm_user_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING',
 arm_common_system_ss.add(files('cpu.c'))
 arm_common_system_ss.add(when: 'TARGET_AARCH64', if_false: files(
   'cpu32-stubs.c'))
-arm_common_system_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
+arm_common_system_ss.add(when: 'CONFIG_KVM', if_true: files(
+  'kvm.c',
+  'hyp_gdbstub.c',
+), if_false: files(
+  'kvm-stub.c',
+))
 arm_common_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c'))
 arm_common_system_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING',
 		                 if_true: files('common-semi-target.c'))
@@ -67,7 +70,6 @@ else
 endif
 
 target_arch += {'arm': arm_ss}
-target_system_arch += {'arm': arm_system_ss}
 target_user_arch += {'arm': arm_user_ss}
 target_common_arch += {'arm': arm_common_ss}
 target_common_system_arch += {'arm': arm_common_system_ss}
Signature · 1 line
2.53.0
Reviewed-by on v1 8/8
#19 lore raw

Re: [PATCH-for-11.1 8/8] target/arm: Compile KVM as common object

Quoted 9 lines · Philippe Mathieu-Daudé

Neither of kvm.c nor hyp_gdbstub.c use target-specific code. Move them from arm_system_ss[] to arm_common_system_ss[] to compile them once. The arm_system_ss[] source set ends up unused, remove it.

---
  target/arm/meson.build | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)

r~

Quoted 43 lines
target/arm/meson.build +6 -4
index f14debc6a2f..1b5d346d474 100644
@@ -1,7 +1,6 @@
  arm_ss = ss.source_set()
  arm_common_ss = ss.source_set()
  arm_common_system_ss = ss.source_set()
-arm_system_ss = ss.source_set()
  arm_user_ss = ss.source_set()
 
  arm_common_system_ss.add(files('gdbstub.c'))
@@ -19,7 +18,6 @@ arm_common_ss.add(files(
  arm_common_system_ss.add(files(
    'arm-qmp-cmds.c',
  ))
-arm_system_ss.add(when: 'CONFIG_KVM', if_true: files('hyp_gdbstub.c', 'kvm.c'))
 
  arm_user_ss.add(files('cpu.c'))
  arm_user_ss.add(when: 'TARGET_AARCH64', if_false: files(
@@ -39,7 +37,12 @@ arm_user_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING',
  arm_common_system_ss.add(files('cpu.c'))
  arm_common_system_ss.add(when: 'TARGET_AARCH64', if_false: files(
    'cpu32-stubs.c'))
-arm_common_system_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c'))
+arm_common_system_ss.add(when: 'CONFIG_KVM', if_true: files(
+  'kvm.c',
+  'hyp_gdbstub.c',
+), if_false: files(
+  'kvm-stub.c',
+))
  arm_common_system_ss.add(when: 'CONFIG_HVF', if_true: files('hyp_gdbstub.c'))
  arm_common_system_ss.add(when: 'CONFIG_ARM_COMPATIBLE_SEMIHOSTING',
  		                 if_true: files('common-semi-target.c'))
@@ -67,7 +70,6 @@ else
  endif
 
  target_arch += {'arm': arm_ss}
-target_system_arch += {'arm': arm_system_ss}
  target_user_arch += {'arm': arm_user_ss}
  target_common_arch += {'arm': arm_common_ss}
  target_common_system_arch += {'arm': arm_common_system_ss}