arm tcg/kvm refactor and split with kvm only support
Subsystems (4)
v16 cover arm tcg/kvm refactor and split with kvm only support
Hi,
I have picked up the baton from Claudio to try and get the ARM re-factoring across the line. Most of the patches from Claudio remain unchanged and have just had minor fixups from re-basing against the moving target. I've done my best to make sure any fixes that have been made in the meantime weren't lost.
I've included Phillipe's qtest_has_accel v7 patches (I had problems with v8) to aid in my aarch64 testing. I'm expecting them to be up-streamed by Phillipe in due course. I've also nabbed one of Phillipe's Kconfig tweaks to allow for target specific expression of some config variables.
The main thing that enables the --disable-tcg build is the addition of --with-devices-FOO configure option which is a mechanism to override the existing default device configurations. The two that I've been testing are a 64 bit only build on x86:
'../../configure' '--without-default-features' \
'--target-list=arm-softmmu,aarch64-softmmu' \
'--with-devices-aarch64=../../configs/aarch64-softmmu/64bit-only.mak'which results in the aarch64-softmmu build only supporting sbsa-ref, virt and xlnx-versal-virt.
The second is a KVM only cross build:
'../../configure' '--disable-docs' \
'--target-list=aarch64-softmmu' \
'--enable-kvm' '--disable-tcg' \
'--cross-prefix=aarch64-linux-gnu-' \
'--with-devices-aarch64=../../configs/aarch64-softmmu/virt-only.mak'Finally I've made a few minor Kconfig and testing tweaks before adding some gitlab coverage. As a result I was able to drop the Revert: idau patch because I can properly build an image without stray devices in the qtree.
The following need review:
- gitlab: defend the new stripped down arm64 configs
- tests/qtest: make xlnx-can-test conditional on being configured
- tests/qtest: split the cdrom-test into arm/aarch64
- hw/arm: add dependency on OR_IRQ for XLNX_VERSAL
- target/arm: move CONFIG_V7M out of default-devices
Alex Bennée (6):
target/arm: move CONFIG_V7M out of default-devices hw/arm: add dependency on OR_IRQ for XLNX_VERSAL tests/qtest: split the cdrom-test into arm/aarch64 tests/qtest: make xlnx-can-test conditional on being configured
configure: allow the overriding of default-config in the build
gitlab: defend the new stripped down arm64 configs
Claudio Fontana (80):
meson: add target_user_arch
accel: add cpu_reset
target/arm: move translate modules to tcg/
target/arm: move helpers to tcg/
arm: tcg: only build under CONFIG_TCG
target/arm: tcg: add sysemu and user subdirs
target/arm: tcg: split mte_helper user-only and sysemu code target/arm: tcg: move sysemu-only parts of debug_helper target/arm: tcg: split tlb_helper user-only and sysemu-only parts target/arm: tcg: split m_helper user-only and sysemu-only parts target/arm: only build psci for TCG
target/arm: split off cpu-sysemu.c
target/arm: tcg: fix comment style before move to cpu-mmu target/arm: move physical address translation to cpu-mmu target/arm: fix style in preparation of new cpregs module target/arm: split cpregs from tcg/helper.c
target/arm: move cpu definitions to common cpu module target/arm: only perform TCG cpu and machine inits if TCG enabled target/arm: tcg: add stubs for some helpers for non-tcg builds target/arm: move cpsr_read, cpsr_write to cpu_common target/arm: add temporary stub for arm_rebuild_hflags target/arm: move arm_hcr_el2_eff from tcg/ to common_cpu target/arm: split vfp state setting from tcg helpers target/arm: move arm_mmu_idx* to cpu-mmu
target/arm: move sve_zcr_len_for_el to common_cpu target/arm: move arm_sctlr away from tcg helpers target/arm: move arm_cpu_list to common_cpu
target/arm: move aarch64_sync_32_to_64 (and vv) to cpu code target/arm: new cpu32 ARM 32 bit CPU Class
target/arm: split 32bit and 64bit arm dump state target/arm: move a15 cpu model away from the TCG-only models target/arm: fixup sve_exception_el code style before move target/arm: move sve_exception_el out of TCG helpers target/arm: fix comments style of fp_exception_el before moving it target/arm: move fp_exception_el out of TCG helpers target/arm: remove now useless ifndef from fp_exception_el target/arm: make further preparation for the exception code to move target/arm: fix style of arm_cpu_do_interrupt functions before move target/arm: move exception code out of tcg/helper.c target/arm: rename handle_semihosting to tcg_handle_semihosting target/arm: replace CONFIG_TCG with tcg_enabled target/arm: move TCGCPUOps to tcg/tcg-cpu.c
target/arm: move cpu_tcg to tcg/tcg-cpu-models.c target/arm: wrap call to aarch64_sve_change_el in tcg_enabled() target/arm: remove kvm include file for PSCI and arm-powerctl target/arm: move kvm-const.h, kvm.c, kvm64.c, kvm_arm.h to kvm/
MAINTAINERS: update arm kvm maintained files to all in target/arm/kvm/ target/arm: cleanup cpu includes
target/arm: remove broad "else" statements when checking accels target/arm: remove kvm-stub.c
tests/qtest: skip bios-tables-test test_acpi_oem_fields_virt for KVM
tests: do not run test-hmp on all machines for ARM KVM-only
tests: device-introspect-test: cope with ARM TCG-only devices
tests: do not run qom-test on all machines for ARM KVM-only target/arm: create kvm cpu accel class
target/arm: move kvm post init initialization to kvm cpu accel target/arm: add tcg cpu accel class
target/arm: move TCG gt timer creation code in tcg/ target/arm: cpu-sve: new module
target/arm: cpu-sve: rename functions according to module prefix target/arm: cpu-sve: split TCG and KVM functionality target/arm: cpu-sve: make cpu_sve_finalize_features return bool target/arm: make is_aa64 and arm_el_is_aa64 a macro for
!TARGET_AARCH64
target/arm: restrict rebuild_hflags_a64 to TARGET_AARCH64 target/arm: arch_dump: restrict ELFCLASS64 to AArch64 target/arm: cpu-exceptions, cpu-exceptions-aa64: new modules target/arm: tcg: restrict ZCR cpregs to TARGET_AARCH64 target/arm: tcg-sve: import narrow_vq and change_el functions target/arm: tcg-sve: rename the narrow_vq and change_el functions target/arm: move sve_zcr_len_for_el to TARGET_AARCH64-only cpu-sve
cpu-sve: rename sve_zcr_len_for_el to cpu_sve_get_zcr_len_for_el target/arm: cpu-common: wrap a64-only check with is_a64 target/arm: cpu-pauth: new module for ARMv8.3 Pointer Authentication target/arm: cpu-pauth: change arm_cpu_pauth_finalize name and sig target/arm: move arm_cpu_finalize_features into cpu64 target/arm: cpu64: rename arm_cpu_finalize_features target/arm: cpu64: some final cleanup on aarch64_cpu_finalize_features XXX target/arm: experiment refactoring cpu "max" target/arm: tcg: remove superfluous CONFIG_TCG check target/arm: remove v7m stub function for !CONFIG_TCG
Philippe Mathieu-Daudé (13):
MAINTAINERS: Add qtest/arm-cpu-features.c to ARM TCG CPUs section
accel: Introduce 'query-accels' QMP command
qtest: Add qtest_has_accel() method qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM qtest/arm-cpu-features: Restrict sve_tests_sve_off_kvm test to KVM qtest/arm-cpu-features: Remove TCG fallback to KVM specific tests qtest/arm-cpu-features: Use generic qtest_has_accel() to check for TCG qtest/migration-test: Skip tests if KVM not builtin on s390x/ppc64 qtest/bios-tables-test: Rename tests not TCG specific qtest/bios-tables-test: Rename TCG specific tests qtest/bios-tables-test: Make test build-independent from accelerator
qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore
meson: Introduce target-specific Kconfig
configure | 20 +
configs/aarch64-softmmu/64bit-only.mak | 10 +
configs/aarch64-softmmu/virt-only.mak | 8 +
default-configs/devices/arm-softmmu.mak | 3 -
meson.build | 9 +-
qapi/machine.json | 47 +
include/hw/core/accel-cpu.h | 2 +
include/qemu/accel.h | 6 +
target/arm/arm-powerctl.h | 2 -
target/arm/cpregs.h | 515 ++
target/arm/cpu-exceptions-aa64.h | 28 +
target/arm/cpu-mmu.h | 119 +
target/arm/cpu-qom.h | 3 -
target/arm/cpu-sve.h | 40 +
target/arm/cpu-vfp.h | 29 +
target/arm/cpu.h | 534 +-
target/arm/cpu32.h | 32 +
target/arm/helper-a64.h | 2 +
target/arm/helper.h | 1 -
target/arm/internals.h | 46 +-
target/arm/{ => kvm}/kvm-consts.h | 0
target/arm/kvm/kvm-sve.h | 28 +
target/arm/{ => kvm}/kvm_arm.h | 0
target/arm/kvm/trace.h | 1 +
target/arm/tcg/cpu-pauth.h | 34 +
target/arm/tcg/m_helper.h | 21 +
target/arm/tcg/mte_helper.h | 53 +
target/arm/{ => tcg}/op_addsub.h | 0
target/arm/tcg/tcg-cpu.h | 40 +
target/arm/tcg/tcg-sve.h | 29 +
target/arm/tcg/tlb_helper.h | 17 +
target/arm/tcg/trace.h | 1 +
target/arm/{ => tcg}/translate-a64.h | 0
target/arm/{ => tcg}/translate.h | 0
target/arm/{ => tcg}/vec_internal.h | 0
target/arm/trace.h | 1 -
tests/qtest/libqos/libqtest.h | 8 +
target/arm/{ => tcg}/a32-uncond.decode | 0
target/arm/{ => tcg}/a32.decode | 0
target/arm/{ => tcg}/m-nocp.decode | 0
target/arm/{ => tcg}/neon-dp.decode | 0
target/arm/{ => tcg}/neon-ls.decode | 0
target/arm/{ => tcg}/neon-shared.decode | 0
target/arm/{ => tcg}/sve.decode | 0
target/arm/{ => tcg}/t16.decode | 0
target/arm/{ => tcg}/t32.decode | 0
target/arm/{ => tcg}/vfp-uncond.decode | 0
target/arm/{ => tcg}/vfp.decode | 0
accel/accel-common.c | 9 +
accel/accel-qmp.c | 49 +
hw/arm/boot.c | 5 +-
hw/arm/pxa2xx.c | 1 +
hw/arm/pxa2xx_pic.c | 1 +
hw/arm/sbsa-ref.c | 2 +-
hw/arm/virt-acpi-build.c | 2 +-
hw/arm/virt.c | 2 +-
hw/arm/xlnx-versal.c | 2 +-
hw/arm/xlnx-zynqmp.c | 2 +-
hw/core/cpu-common.c | 3 +-
hw/cpu/a15mpcore.c | 2 +-
hw/intc/arm_gic_kvm.c | 2 +-
hw/intc/arm_gicv3_cpuif.c | 1 +
hw/intc/arm_gicv3_its_kvm.c | 2 +-
hw/intc/arm_gicv3_kvm.c | 3 +-
linux-user/syscall.c | 6 +-
target/arm/arch_dump.c | 15 +-
target/arm/arm-powerctl.c | 8 +-
target/arm/cpregs.c | 380 +
target/arm/cpu-common.c | 358 +
target/arm/cpu-exceptions-aa64.c | 277 +
target/arm/cpu-exceptions.c | 445 ++
target/arm/cpu-mmu-sysemu.c | 2307 ++++++
target/arm/cpu-mmu.c | 215 +
target/arm/cpu-sve.c | 323 +
target/arm/cpu-sysemu.c | 482 ++
target/arm/cpu-user.c | 46 +
target/arm/cpu-vfp.c | 97 +
target/arm/cpu.c | 759 +-
target/arm/cpu32.c | 260 +
target/arm/cpu64.c | 723 +-
target/arm/cpustate-list.c | 146 +
target/arm/gdbstub.c | 1 +
target/arm/kvm-stub.c | 24 -
target/arm/kvm/kvm-cpu.c | 128 +
target/arm/kvm/kvm-sve.c | 118 +
target/arm/{ => kvm}/kvm.c | 18 +-
target/arm/{ => kvm}/kvm64.c | 0
target/arm/machine.c | 39 +-
target/arm/monitor.c | 10 +-
target/arm/psci.c | 1 -
target/arm/{helper.c => tcg/cpregs.c} | 6557 +----------------
target/arm/tcg/cpu-pauth.c | 66 +
target/arm/tcg/cpu-vfp.c | 146 +
target/arm/{ => tcg}/crypto_helper.c | 0
target/arm/{ => tcg}/debug_helper.c | 27 -
target/arm/{ => tcg}/helper-a64.c | 3 +-
target/arm/tcg/helper.c | 1300 ++++
target/arm/{ => tcg}/iwmmxt_helper.c | 0
target/arm/tcg/m_helper.c | 93 +
target/arm/{ => tcg}/mte_helper.c | 191 +-
target/arm/{ => tcg}/neon_helper.c | 0
target/arm/{ => tcg}/op_helper.c | 1 +
target/arm/{ => tcg}/pauth_helper.c | 2 +-
target/arm/{ => tcg}/sve_helper.c | 0
target/arm/tcg/sysemu/debug_helper.c | 33 +
target/arm/{ => tcg/sysemu}/m_helper.c | 203 +-
target/arm/tcg/sysemu/mte_helper.c | 159 +
target/arm/tcg/sysemu/tcg-cpu.c | 119 +
target/arm/tcg/sysemu/tlb_helper.c | 84 +
.../arm/{cpu_tcg.c => tcg/tcg-cpu-models.c} | 153 +-
target/arm/tcg/tcg-cpu.c | 502 ++
target/arm/tcg/tcg-stubs.c | 21 +
target/arm/tcg/tcg-sve.c | 167 +
target/arm/{ => tcg}/tlb_helper.c | 97 +-
target/arm/{ => tcg}/translate-a64.c | 1 +
target/arm/{ => tcg}/translate-m-nocp.c | 0
target/arm/{ => tcg}/translate-neon.c | 0
target/arm/{ => tcg}/translate-sve.c | 0
target/arm/{ => tcg}/translate-vfp.c | 0
target/arm/{ => tcg}/translate.c | 1 +
target/arm/tcg/user/m_helper.c | 97 +
target/arm/tcg/user/mte_helper.c | 57 +
target/arm/tcg/user/tlb_helper.c | 32 +
target/arm/{ => tcg}/vec_helper.c | 0
target/arm/{ => tcg}/vfp_helper.c | 216 +-
target/i386/cpu.c | 4 -
target/i386/kvm/kvm-cpu.c | 6 +
tests/qtest/arm-cpu-features.c | 47 +-
tests/qtest/bios-tables-test.c | 163 +-
tests/qtest/cdrom-test.c | 5 +-
tests/qtest/device-introspect-test.c | 32 +-
tests/qtest/libqtest.c | 29 +
tests/qtest/migration-test.c | 4 +-
tests/qtest/qom-test.c | 20 +
tests/qtest/test-hmp.c | 20 +
.gitlab-ci.d/buildtest.yml | 10 +
.gitlab-ci.d/crossbuilds.yml | 9 +
Kconfig | 1 +
MAINTAINERS | 3 +-
accel/meson.build | 2 +-
hw/arm/Kconfig | 4 +
roms/u-boot | 2 +-
target/Kconfig | 23 +
target/alpha/Kconfig | 2 +
target/alpha/meson.build | 3 +
target/arm/Kconfig | 6 +
target/arm/kvm/meson.build | 6 +
target/arm/kvm/trace-events | 4 +
target/arm/meson.build | 64 +-
target/arm/tcg/meson.build | 53 +
target/arm/tcg/sysemu/meson.build | 10 +
target/arm/{ => tcg}/trace-events | 5 +-
target/arm/tcg/user/meson.build | 5 +
target/avr/Kconfig | 2 +
target/cris/Kconfig | 2 +
target/cris/meson.build | 3 +
target/hexagon/meson.build | 3 +
target/hppa/Kconfig | 2 +
target/hppa/meson.build | 3 +
target/i386/Kconfig | 5 +
target/lm32/Kconfig | 2 +
target/m68k/Kconfig | 2 +
target/m68k/meson.build | 3 +
target/microblaze/Kconfig | 2 +
target/microblaze/meson.build | 3 +
target/mips/Kconfig | 6 +
target/moxie/Kconfig | 2 +
target/nios2/Kconfig | 2 +
target/nios2/meson.build | 3 +
target/openrisc/Kconfig | 2 +
target/openrisc/meson.build | 3 +
target/ppc/Kconfig | 5 +
target/ppc/meson.build | 3 +
target/riscv/Kconfig | 5 +
target/riscv/meson.build | 3 +
target/rx/Kconfig | 2 +
target/s390x/Kconfig | 2 +
target/s390x/meson.build | 3 +
target/sh4/Kconfig | 2 +
target/sh4/meson.build | 3 +
target/sparc/Kconfig | 5 +
target/sparc/meson.build | 3 +
target/tilegx/Kconfig | 2 +
target/tricore/Kconfig | 2 +
target/tricore/meson.build | 3 +
target/unicore32/Kconfig | 2 +
target/xtensa/Kconfig | 2 +
target/xtensa/meson.build | 3 +
tests/qtest/meson.build | 5 +-
189 files changed, 10701 insertions(+), 9237 deletions(-)
create mode 100644 configs/aarch64-softmmu/64bit-only.mak
create mode 100644 configs/aarch64-softmmu/virt-only.mak
create mode 100644 target/arm/cpregs.h
create mode 100644 target/arm/cpu-exceptions-aa64.h
create mode 100644 target/arm/cpu-mmu.h
create mode 100644 target/arm/cpu-sve.h
create mode 100644 target/arm/cpu-vfp.h
create mode 100644 target/arm/cpu32.h
rename target/arm/{ => kvm}/kvm-consts.h (100%)
create mode 100644 target/arm/kvm/kvm-sve.h
rename target/arm/{ => kvm}/kvm_arm.h (100%)
create mode 100644 target/arm/kvm/trace.h
create mode 100644 target/arm/tcg/cpu-pauth.h
create mode 100644 target/arm/tcg/m_helper.h
create mode 100644 target/arm/tcg/mte_helper.h
rename target/arm/{ => tcg}/op_addsub.h (100%)
create mode 100644 target/arm/tcg/tcg-cpu.h
create mode 100644 target/arm/tcg/tcg-sve.h
create mode 100644 target/arm/tcg/tlb_helper.h
create mode 100644 target/arm/tcg/trace.h
rename target/arm/{ => tcg}/translate-a64.h (100%)
rename target/arm/{ => tcg}/translate.h (100%)
rename target/arm/{ => tcg}/vec_internal.h (100%)
delete mode 100644 target/arm/trace.h
rename target/arm/{ => tcg}/a32-uncond.decode (100%)
rename target/arm/{ => tcg}/a32.decode (100%)
rename target/arm/{ => tcg}/m-nocp.decode (100%)
rename target/arm/{ => tcg}/neon-dp.decode (100%)
rename target/arm/{ => tcg}/neon-ls.decode (100%)
rename target/arm/{ => tcg}/neon-shared.decode (100%)
rename target/arm/{ => tcg}/sve.decode (100%)
rename target/arm/{ => tcg}/t16.decode (100%)
rename target/arm/{ => tcg}/t32.decode (100%)
rename target/arm/{ => tcg}/vfp-uncond.decode (100%)
rename target/arm/{ => tcg}/vfp.decode (100%)
create mode 100644 accel/accel-qmp.c
create mode 100644 target/arm/cpregs.c
create mode 100644 target/arm/cpu-common.c
create mode 100644 target/arm/cpu-exceptions-aa64.c
create mode 100644 target/arm/cpu-exceptions.c
create mode 100644 target/arm/cpu-mmu-sysemu.c
create mode 100644 target/arm/cpu-mmu.c
create mode 100644 target/arm/cpu-sve.c
create mode 100644 target/arm/cpu-sysemu.c
create mode 100644 target/arm/cpu-user.c
create mode 100644 target/arm/cpu-vfp.c
create mode 100644 target/arm/cpu32.c
create mode 100644 target/arm/cpustate-list.c
delete mode 100644 target/arm/kvm-stub.c
create mode 100644 target/arm/kvm/kvm-cpu.c
create mode 100644 target/arm/kvm/kvm-sve.c
rename target/arm/{ => kvm}/kvm.c (98%)
rename target/arm/{ => kvm}/kvm64.c (100%)
rename target/arm/{helper.c => tcg/cpregs.c} (57%)
create mode 100644 target/arm/tcg/cpu-pauth.c
create mode 100644 target/arm/tcg/cpu-vfp.c
rename target/arm/{ => tcg}/crypto_helper.c (100%)
rename target/arm/{ => tcg}/debug_helper.c (92%)
rename target/arm/{ => tcg}/helper-a64.c (99%)
create mode 100644 target/arm/tcg/helper.c
rename target/arm/{ => tcg}/iwmmxt_helper.c (100%)
create mode 100644 target/arm/tcg/m_helper.c
rename target/arm/{ => tcg}/mte_helper.c (76%)
rename target/arm/{ => tcg}/neon_helper.c (100%)
rename target/arm/{ => tcg}/op_helper.c (99%)
rename target/arm/{ => tcg}/pauth_helper.c (99%)
rename target/arm/{ => tcg}/sve_helper.c (100%)
create mode 100644 target/arm/tcg/sysemu/debug_helper.c
rename target/arm/{ => tcg/sysemu}/m_helper.c (94%)
create mode 100644 target/arm/tcg/sysemu/mte_helper.c
create mode 100644 target/arm/tcg/sysemu/tcg-cpu.c
create mode 100644 target/arm/tcg/sysemu/tlb_helper.c
rename target/arm/{cpu_tcg.c => tcg/tcg-cpu-models.c} (86%)
create mode 100644 target/arm/tcg/tcg-cpu.c
create mode 100644 target/arm/tcg/tcg-stubs.c
create mode 100644 target/arm/tcg/tcg-sve.c
rename target/arm/{ => tcg}/tlb_helper.c (56%)
rename target/arm/{ => tcg}/translate-a64.c (99%)
rename target/arm/{ => tcg}/translate-m-nocp.c (100%)
rename target/arm/{ => tcg}/translate-neon.c (100%)
rename target/arm/{ => tcg}/translate-sve.c (100%)
rename target/arm/{ => tcg}/translate-vfp.c (100%)
rename target/arm/{ => tcg}/translate.c (99%)
create mode 100644 target/arm/tcg/user/m_helper.c
create mode 100644 target/arm/tcg/user/mte_helper.c
create mode 100644 target/arm/tcg/user/tlb_helper.c
rename target/arm/{ => tcg}/vec_helper.c (100%)
rename target/arm/{ => tcg}/vfp_helper.c (84%)
create mode 100644 target/Kconfig
create mode 100644 target/alpha/Kconfig
create mode 100644 target/arm/Kconfig
create mode 100644 target/arm/kvm/meson.build
create mode 100644 target/arm/kvm/trace-events
create mode 100644 target/arm/tcg/meson.build
create mode 100644 target/arm/tcg/sysemu/meson.build
rename target/arm/{ => tcg}/trace-events (78%)
create mode 100644 target/arm/tcg/user/meson.build
create mode 100644 target/avr/Kconfig
create mode 100644 target/cris/Kconfig
create mode 100644 target/hppa/Kconfig
create mode 100644 target/i386/Kconfig
create mode 100644 target/lm32/Kconfig
create mode 100644 target/m68k/Kconfig
create mode 100644 target/microblaze/Kconfig
create mode 100644 target/mips/Kconfig
create mode 100644 target/moxie/Kconfig
create mode 100644 target/nios2/Kconfig
create mode 100644 target/openrisc/Kconfig
create mode 100644 target/ppc/Kconfig
create mode 100644 target/riscv/Kconfig
create mode 100644 target/rx/Kconfig
create mode 100644 target/s390x/Kconfig
create mode 100644 target/sh4/Kconfig
create mode 100644 target/sparc/Kconfig
create mode 100644 target/tilegx/Kconfig
create mode 100644 target/tricore/Kconfig
create mode 100644 target/unicore32/Kconfig
create mode 100644 target/xtensa/KconfigSignature · 1 line
2.20.1
PATCH v16 1/99 MAINTAINERS: Add qtest/arm-cpu-features.c to ARM TCG CPUs section
From: Philippe Mathieu-Daudé <[email protected]>
We want the ARM maintainers and the qemu-arm@ list to be notified when this file is modified. Add an entry to the 'ARM TCG CPUs' section in the MAINTAINERS file.
Message-Id: <[email protected]>
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -155,6 +155,7 @@ S: Maintained F: target/arm/ F: tests/tcg/arm/ F: tests/tcg/aarch64/ +F: tests/qtest/arm-cpu-features.c F: hw/arm/ F: hw/cpu/a*mpcore.c F: include/hw/cpu/a*mpcore.h
Signature · 1 line
2.20.1
Re: [PATCH v16 01/99] MAINTAINERS: Add qtest/arm-cpu-features.c to ARM TCG CPUs section
Quoted 11 lines · Alex Bennée
From: Philippe Mathieu-Daudé<[email protected]>
We want the ARM maintainers and the qemu-arm@ list to be notified when this file is modified. Add an entry to the 'ARM TCG CPUs' section in the
MAINTAINERSfile.Acked-by Andrew Jones<[email protected]>Reviewed-by Thomas Huth<[email protected]>Reviewed-by Alex Bennée<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Alex Bennée<[email protected]>
Quoted 4 lines
Message-Id:<[email protected]>
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
r~
PATCH v16 2/99 accel: Introduce 'query-accels' QMP command
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Introduce the 'query-accels' QMP command which returns a list of built-in accelerator names.
- Accelerator is a QAPI enum of all existing accelerators,
- AcceleratorInfo is a QAPI structure providing accelerator specific information. Currently the common structure base provides the name of the accelerator, while the specific part is empty, but each accelerator can expand it.
- 'query-accels' QMP command returns a list of @AcceleratorInfo
For example on a KVM-only build we get:
{ "execute": "query-accels" }
{
"return": [
{
"name": "qtest"
},
{
"name": "kvm"
}
]
}Note that we can't make the enum values or union branches conditional because of target-specific poisoning of accelerator definitions.
Message-Id: <[email protected]>
--- qapi/machine.json | 47 +++++++++++++++++++++++++++++++++++++++++++++ accel/accel-qmp.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ accel/meson.build | 2 +- 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 accel/accel-qmp.c
qapi/machine.json +47 -0
@@ -1274,3 +1274,50 @@ ## { 'event': 'MEM_UNPLUG_ERROR', 'data': { 'device': 'str', 'msg': 'str' } } + +## +# @Accelerator: +# +# An enumeration of accelerator names. +# +# Since: 6.1 +## +{ 'enum': 'Accelerator', + 'data': [ 'hax', 'hvf', 'kvm', 'qtest', 'tcg', 'whpx', 'xen' ] } + +## +# @AcceleratorInfo: +# +# Accelerator information. +# +# @name: The accelerator name. +# +# Since: 6.1 +## +{ 'struct': 'AcceleratorInfo', + 'data': { 'name': 'Accelerator' } } + +## +# @query-accels: +# +# Get a list of AcceleratorInfo for all built-in accelerators. +# +# Returns: a list of @AcceleratorInfo describing each accelerator. +# +# Since: 6.1 +# +# Example: +# +# -> { "execute": "query-accels" } +# <- { "return": [ +# { +# "name": "qtest" +# }, +# { +# "name": "kvm" +# } +# ] } +# +## +{ 'command': 'query-accels', + 'returns': ['AcceleratorInfo'] }
accel/accel-qmp.c new file +49 -0
49 lines not on this page · raw message
accel/meson.build +1 -1
@@ -1,4 +1,4 @@ -specific_ss.add(files('accel-common.c')) +specific_ss.add(files('accel-common.c', 'accel-qmp.c')) softmmu_ss.add(files('accel-softmmu.c')) user_ss.add(files('accel-user.c'))
Signature · 1 line
2.20.1
Re: [PATCH v16 02/99] accel: Introduce 'query-accels' QMP command
Quoted 38 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Introduce the 'query-accels' QMP command which returns a list of built-in accelerator names.
- Accelerator is a QAPI enum of all existing accelerators,
- AcceleratorInfo is a QAPI structure providing accelerator specific information. Currently the common structure base provides the name of the accelerator, while the specific part is empty, but each accelerator can expand it.
- 'query-accels' QMP command returns a list of @AcceleratorInfo
For example on a KVM-only build we get:
{ "execute": "query-accels" } { "return": [ { "name": "qtest" }, { "name": "kvm" } ] }Note that we can't make the enum values or union branches conditional because of target-specific poisoning of accelerator definitions.
Reviewed-by Eric Blake <[email protected]>Reviewed-by Alex Bennée <[email protected]>Tested-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
---
[...]
Quoted 10 lines
accel/accel-qmp.c new file +10
-0+static const bool accel_builtin_list[ACCELERATOR__MAX ] = { + [ACCELERATOR_QTEST ] = true, +#ifdef CONFIG_TCG + [ACCELERATOR_TCG ] = true, +#endif +#ifdef CONFIG_KVM + [ACCELERATOR_KVM ] = true, +#endif +#ifdef CONFIG_HAX + [ACCELERATOR_HAX] = true,
accel/accel-qmp.c line 31
Quoted 10 lines
accel/accel-qmp.c new file +10
-0+#endif +#ifdef CONFIG_HVF + [ACCELERATOR_HVF ] = true, +#endif +#ifdef CONFIG_WHPX + [ACCELERATOR_WHPX ] = true, +#endif +#ifdef CONFIG_XEN_BACKEND + [ACCELERATOR_XEN] = true, +#endif
Nit: Use alphabetical order here, too, just like you did in the enum?
Apart from that:
Re: [PATCH v16 02/99] accel: Introduce 'query-accels' QMP command
Quoted 54 lines · Thomas Huth
Quoted 38 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Introduce the 'query-accels' QMP command which returns a list of built-in accelerator names.
- Accelerator is a QAPI enum of all existing accelerators,
- AcceleratorInfo is a QAPI structure providing accelerator specific information. Currently the common structure base provides the name of the accelerator, while the specific part is empty, but each accelerator can expand it.
- 'query-accels' QMP command returns a list of @AcceleratorInfo
For example on a KVM-only build we get:
{ "execute": "query-accels" }
{
"return": [
{
"name": "qtest"
},
{
"name": "kvm"
}
]
}Note that we can't make the enum values or union branches conditional because of target-specific poisoning of accelerator definitions.
Reviewed-by Eric Blake <[email protected]>Reviewed-by Alex Bennée <[email protected]>Tested-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
---[...]
Quoted 14 lines
accel/accel-qmp.c new file +14
-0+static const bool accel_builtin_list[ACCELERATOR__MAX ] = { + [ACCELERATOR_QTEST] = true, +#ifdef CONFIG_TCG + [ACCELERATOR_TCG] = true, +#endif +#ifdef CONFIG_KVM + [ACCELERATOR_KVM] = true, +#endif +#ifdef CONFIG_HAX + [ACCELERATOR_HAX] = true, +#endif +#ifdef CONFIG_HVF + [ACCELERATOR_HVF] = true, +#endif
Quoted 8 lines
accel/accel-qmp.c line 31
Quoted 6 lines
accel/accel-qmp.c new file +6
-0+#ifdef CONFIG_WHPX + [ACCELERATOR_WHPX] = true, +#endif +#ifdef CONFIG_XEN_BACKEND + [ACCELERATOR_XEN] = true, +#endif Nit: Use alphabetical order here, too, just like you did in the enum?
This has been drastically simplified by Markus using target-specific machine code in v8.
Re: [PATCH v16 02/99] accel: Introduce 'query-accels' QMP command
In reply to Alex BennéeQuoted 31 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Introduce the 'query-accels' QMP command which returns a list of built-in accelerator names.
- Accelerator is a QAPI enum of all existing accelerators,
- AcceleratorInfo is a QAPI structure providing accelerator specific information. Currently the common structure base provides the name of the accelerator, while the specific part is empty, but each accelerator can expand it.
- 'query-accels' QMP command returns a list of @AcceleratorInfo
For example on a KVM-only build we get:
{ "execute": "query-accels" } { "return": [ { "name": "qtest" }, { "name": "kvm" } ] }Note that we can't make the enum values or union branches conditional because of target-specific poisoning of accelerator definitions.
Quoted 6 lines
Reviewed-by Eric Blake <[email protected]>Reviewed-by Alex Bennée <[email protected]>Tested-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
I assume this one's superseded by Phil's "[PATCH v8 02/12] accel:
Introduce 'query-accels' QMP command", i.e. I should review that one, not this one.
Re: [PATCH v16 02/99] accel: Introduce 'query-accels' QMP command
Quoted 9 lines · Markus Armbruster
Quoted 6 lines · Alex Bennée
Reviewed-by Eric Blake <[email protected]>Reviewed-by Alex Bennée <[email protected]>Tested-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
Quoted 3 lines
I assume this one's superseded by Phil's "[PATCH v8 02/12] accel:
Introduce 'query-accels' QMP command", i.e. I should review that one, not this one.
Correct.
PATCH v16 3/99 qtest: Add qtest_has_accel() method
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Introduce the qtest_has_accel() method which allows a runtime query on whether a QEMU instance has an accelerator built-in.
Message-Id: <[email protected]>
--- tests/qtest/libqos/libqtest.h | 8 ++++++++ tests/qtest/libqtest.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)
tests/qtest/libqos/libqtest.h +8 -0
@@ -763,6 +763,14 @@ void qmp_expect_error_and_unref(QDict *rsp, const char *class);*/ bool qtest_probe_child (QTestState *s); +/** +* qtest_has_accel: +* @accel_name: Accelerator name to check for. +* +* Returns: true if the accelerator is built in. +*/ +bool qtest_has_accel (const char *accel_name); +/** * qtest_set_expected_status: * @s: QTestState instance to operate on.
tests/qtest/libqtest.c +29 -0
@@ -393,6 +393,35 @@ QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd)return qts; } +bool qtest_has_accel (const char *accel_name) +{ +bool has_accel = false; +QDict *response; +QList *accels; +QListEntry *accel; +QTestState *qts; + + qts =qtest_initf ("-accel qtest -machine none" ); + response =qtest_qmp (qts,"{'execute': 'query-accels'}" ); + accels =qdict_get_qlist (response,"return" ); + + QLIST_FOREACH_ENTRY(accels, accel) { +QDict *accel_dict =qobject_to (QDict,qlist_entry_obj (accel)); +const char *name =qdict_get_str (accel_dict,"name" ); + +if (g_str_equal (name, accel_name)) { + has_accel = true; +break ; + } + } +qobject_unref (response); + +qtest_quit (qts); + +return has_accel; +} + +void qtest_quit (QTestState *s) {qtest_remove_abrt_handler (s);
Signature · 1 line
2.20.1
Re: [PATCH v16 03/99] qtest: Add qtest_has_accel() method
Quoted 59 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Introduce the
qtest_has_accel()method which allows a runtime query on whether a QEMU instance has an accelerator built-in.Reviewed-by Eric Blake <[email protected]>Reviewed-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
--- tests/qtest/libqos/libqtest.h | 8 ++++++++ tests/qtest/libqtest.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)tests/qtest/libqos/libqtest.h +8
-0@@ -763,6 +763,14 @@ void qmp_expect_error_and_unref(QDict *rsp, const char *class);*/ bool qtest_probe_child (QTestState *s); +/** +* qtest_has_accel: +* @accel_name: Accelerator name to check for. +* +* Returns: true if the accelerator is built in. +*/ +bool qtest_has_accel (const char *accel_name); +/** * qtest_set_expected_status: * @s: QTestState instance to operate on. tests/qtest/libqtest.c +17
-0@@ -393,6 +393,35 @@ QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd)return qts; } +bool qtest_has_accel (const char *accel_name) +{ +bool has_accel = false; +QDict *response; +QList *accels; +QListEntry *accel; +QTestState *qts; + + qts =qtest_initf ("-accel qtest -machine none" ); + response =qtest_qmp (qts,"{'execute': 'query-accels'}" ); + accels =qdict_get_qlist (response,"return" ); + + QLIST_FOREACH_ENTRY(accels, accel) { +QDict *accel_dict =qobject_to (QDict,qlist_entry_obj (accel)); +const char *name =qdict_get_str (accel_dict,"name" ); + +if (g_str_equal (name, accel_name)) {
tests/qtest/libqtest.c QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd) · line 422
Quoted 10 lines
tests/qtest/libqtest.c +10
-0+ has_accel = true; +break ; + } + } +qobject_unref (response); + +qtest_quit (qts); + +return has_accel; +}
This spawns a new instance of QEMU each time the function is called - which could slow down testing quite a bit if a test calls this function quite often. Would it be feasible to cache this information, so that you only have to run a new instance of QEMU once?
Thomas
Re: [PATCH v16 03/99] qtest: Add qtest_has_accel() method
Quoted 40 lines · Thomas Huth
Quoted 39 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Introduce the
qtest_has_accel()method which allows a runtime query on whether a QEMU instance has an accelerator built-in.Reviewed-by Eric Blake <[email protected]>Reviewed-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
---
tests/qtest/libqos/libqtest.h| 8 ++++++++ tests/qtest/libqtest.c | 29 +++++++++++++++++++++++++++++2 files changed, 37 insertions(+)+bool
qtest_has_accel(const char *accel_name)tests/qtest/libqtest.c +23
-0+{ + bool has_accel = false; + QDict *response; + QList *accels; + QListEntry *accel; + QTestState *qts; + + qts = qtest_initf("-accel qtest -machine none"); + response = qtest_qmp(qts, "{'execute': 'query-accels'}"); + accels = qdict_get_qlist(response, "return"); + + QLIST_FOREACH_ENTRY(accels, accel) { + QDict *accel_dict = qobject_to(QDict, qlist_entry_obj(accel)); + const char *name = qdict_get_str(accel_dict, "name"); + + if (g_str_equal(name, accel_name)) { + has_accel = true; + break; + } + } + qobject_unref(response); + + qtest_quit(qts);
Quoted 8 lines
tests/qtest/libqtest.c QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd) · line 422
Quoted 3 lines
tests/qtest/libqtest.c +3
-0+ + return has_accel; +}This spawns a new instance of QEMU each time the function is called - which could slow down testing quite a bit if a test calls this function quite often. Would it be feasible to cache this information, so that you only have to run a new instance of QEMU once?
Good idea!
PATCH v16 4/99 qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Use the recently added generic qtest_has_accel() method to check if KVM is available.
Message-Id: <[email protected]>
--- tests/qtest/arm-cpu-features.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-)
tests/qtest/arm-cpu-features.c +1 -24
@@ -26,21 +26,6 @@ " 'arguments': { 'type': 'full', "#define QUERY_TAIL "}}" -static bool kvm_enabled (QTestState *qts) -{ -QDict *resp, *qdict; -bool enabled; - - resp =qtest_qmp (qts,"{ 'execute': 'query-kvm' }" ); -g_assert (qdict_haskey (resp,"return" )); - qdict =qdict_get_qdict (resp,"return" ); -g_assert (qdict_haskey (qdict,"enabled" )); - enabled =qdict_get_bool (qdict,"enabled" ); -qobject_unref (resp); - -return enabled; -} -static QDict *do_query_no_props (QTestState *qts,const char *cpu_type) { return qtest_qmp(qts, QUERY_HEAD "'model': { 'name': %s }"
@@ -493,14 +478,6 @@ static void test_query_cpu_model_expansion_kvm(const void *data) qts =qtest_init (MACHINE_KVM "-cpu max" ); -/* -* These tests target the 'host' CPU type, so KVM must be enabled. -*/ -if (!kvm_enabled (qts)) { -qtest_quit (qts); -return ; - } -/* Enabling and disabling kvm-no-adjvtime should always work. */ assert_has_feature_disabled (qts,"host" ,"kvm-no-adjvtime" );assert_set_feature (qts,"host" ,"kvm-no-adjvtime" , true);
@@ -624,7 +601,7 @@ int main(int argc, char **argv)* order avoid attempting to run an AArch32 QEMU with KVM on * AArch64 hosts. That won't work and isn't easy to detect. */ -if (g_str_equal (qtest_get_arch (),"aarch64" )) { +if (g_str_equal (qtest_get_arch (),"aarch64" ) &&qtest_has_accel ("kvm" )) {qtest_add_data_func ("/arm/kvm/query-cpu-model-expansion" ,NULL , test_query_cpu_model_expansion_kvm); }
Signature · 1 line
2.20.1
Re: [PATCH v16 04/99] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
Quoted 10 lines · Alex Bennée
From: Philippe Mathieu-Daudé<[email protected]>
Use the recently added generic
qtest_has_accel()method to check if KVM is available.Suggested-by Claudio Fontana<[email protected]>Reviewed-by Andrew Jones<[email protected]>Reviewed-by Alex Bennée<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Alex Bennée<[email protected]>
Quoted 4 lines
Message-Id:<[email protected]>
--- tests/qtest/arm-cpu-features.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-)
r~
Re: [PATCH v16 04/99] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
In reply to Alex BennéeQuoted 57 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Use the recently added generic
qtest_has_accel()method to check if KVM is available.Suggested-by Claudio Fontana <[email protected]>Reviewed-by Andrew Jones <[email protected]>Reviewed-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
--- tests/qtest/arm-cpu-features.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-)tests/qtest/arm-cpu-features.c +0
-23@@ -26,21 +26,6 @@ " 'arguments': { 'type': 'full', "#define QUERY_TAIL "}}" -static bool kvm_enabled (QTestState *qts) -{ -QDict *resp, *qdict; -bool enabled; - - resp =qtest_qmp (qts,"{ 'execute': 'query-kvm' }" ); -g_assert (qdict_haskey (resp,"return" )); - qdict =qdict_get_qdict (resp,"return" ); -g_assert (qdict_haskey (qdict,"enabled" )); - enabled =qdict_get_bool (qdict,"enabled" ); -qobject_unref (resp); - -return enabled; -} -static QDict *do_query_no_props (QTestState *qts,const char *cpu_type) { return qtest_qmp(qts, QUERY_HEAD "'model': { 'name': %s }"@@ -493,14 +478,6 @@ static void test_query_cpu_model_expansion_kvm(const void *data) qts =qtest_init (MACHINE_KVM "-cpu max" ); -/* -* These tests target the 'host' CPU type, so KVM must be enabled. -*/ -if (!kvm_enabled (qts)) { -qtest_quit (qts); -return ; - } -/* Enabling and disabling kvm-no-adjvtime should always work. */ assert_has_feature_disabled (qts,"host" ,"kvm-no-adjvtime" );assert_set_feature (qts,"host" ,"kvm-no-adjvtime" , true);
tests/qtest/arm-cpu-features.c int main(int argc, char **argv) · line 606
Quoted 7 lines
tests/qtest/arm-cpu-features.c +1
-1@@ -624,7 +601,7 @@ int main(int argc, char **argv)* order avoid attempting to run an AArch32 QEMU with KVM on * AArch64 hosts. That won't work and isn't easy to detect. */ -if (g_str_equal (qtest_get_arch (),"aarch64" )) { +if (g_str_equal (qtest_get_arch (),"aarch64" ) &&qtest_has_accel ("kvm" )) {qtest_add_data_func ("/arm/kvm/query-cpu-model-expansion" ,NULL , test_query_cpu_model_expansion_kvm);
I think this is wrong: query-kvm checks whether kvm is *enabled*, while your new function only checks whether kvm has been built into the binary. There is still the possibility that kvm has been built into the binary, but is not available on the host, so in that case the test will fail now.
Thus please drop / rework this patch.
Thomas
Re: [PATCH v16 04/99] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
Quoted 72 lines · Thomas Huth
Quoted 56 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Use the recently added generic
qtest_has_accel()method to check if KVM is available.Suggested-by Claudio Fontana <[email protected]>Reviewed-by Andrew Jones <[email protected]>Reviewed-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
---
tests/qtest/arm-cpu-features.c| 25 +------------------------1 file changed, 1 insertion(+), 24 deletions(-)tests/qtest/arm-cpu-features.c +0
-0@@ -26,21 +26,6 @@" 'arguments': { 'type': 'full', " #define QUERY_TAIL "}}"
-static boolkvm_enabled(QTestState *qts)tests/qtest/arm-cpu-features.c +0
-14-{ - QDict *resp, *qdict; - bool enabled; - - resp = qtest_qmp(qts, "{ 'execute': 'query-kvm' }"); - g_assert(qdict_haskey(resp, "return")); - qdict = qdict_get_qdict(resp, "return"); - g_assert(qdict_haskey(qdict, "enabled")); - enabled = qdict_get_bool(qdict, "enabled"); - qobject_unref(resp); - - return enabled; -} -static QDict *do_query_no_props(QTestState *qts, const char
*cpu_type) {
return qtest_qmp(qts,QUERY_HEAD"'model': { 'name': %s }"tests/qtest/arm-cpu-features.c +0
-0@@ -493,14 +478,6 @@ static void test_query_cpu_model_expansion_kvm(const void *data) qts = qtest_init(MACHINE_KVM "-cpu max");- /*
- * These tests target the 'host' CPU type, so KVM must be enabled. - */
- if (!kvm_enabled(qts)) {
-qtest_quit(qts);
- return;
- }
-
/* Enabling and disabling kvm-no-adjvtime should always work. */assert_has_feature_disabled(qts, "host", "kvm-no-adjvtime");assert_set_feature(qts, "host", "kvm-no-adjvtime", true);tests/qtest/arm-cpu-features.c int main(int argc, char **argv) · line 607
Quoted 8 lines
tests/qtest/arm-cpu-features.c +1
-1@@ -624,7 +601,7 @@ int main(int argc, char **argv)* order avoid attempting to run an AArch32 QEMU with KVM on * AArch64 hosts. That won't work and isn't easy to detect. */ - if (g_str_equal(qtest_get_arch(), "aarch64")) { + if (g_str_equal(qtest_get_arch(), "aarch64") &&qtest_has_accel ("kvm" )) { qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", NULL, test_query_cpu_model_expansion_kvm);I think this is wrong: query-kvm checks whether kvm is *enabled*, while your new function only checks whether kvm has been built into the binary. There is still the possibility that kvm has been built into the binary, but is not available on the host, so in that case the test will fail now.
Quoted 1 line
Thus please drop / rework this patch.
Indeed, this is unfortunate :(
Re: [PATCH v16 04/99] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
Quoted 64 lines · Philippe Mathieu-Daudé
Quoted 63 lines · Thomas Huth
Quoted 62 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Use the recently added generic
qtest_has_accel()method to check if KVM is available.Suggested-by Claudio Fontana <[email protected]>Reviewed-by Andrew Jones <[email protected]>Reviewed-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
---
tests/qtest/arm-cpu-features.c| 25 +------------------------1 file changed, 1 insertion(+), 24 deletions(-)tests/qtest/arm-cpu-features.c +0
-0@@ -26,21 +26,6 @@" 'arguments': { 'type': 'full', " #define QUERY_TAIL "}}"
-static boolkvm_enabled(QTestState *qts)tests/qtest/arm-cpu-features.c +0
-14-{ - QDict *resp, *qdict; - bool enabled; - - resp = qtest_qmp(qts, "{ 'execute': 'query-kvm' }"); - g_assert(qdict_haskey(resp, "return")); - qdict = qdict_get_qdict(resp, "return"); - g_assert(qdict_haskey(qdict, "enabled")); - enabled = qdict_get_bool(qdict, "enabled"); - qobject_unref(resp); - - return enabled; -} -static QDict *do_query_no_props(QTestState *qts, const char
*cpu_type) {
return qtest_qmp(qts,QUERY_HEAD"'model': { 'name': %s }"tests/qtest/arm-cpu-features.c +0
-0@@ -493,14 +478,6 @@ static void test_query_cpu_model_expansion_kvm(const void *data) qts = qtest_init(MACHINE_KVM "-cpu max");- /*
- * These tests target the 'host' CPU type, so KVM must be enabled. - */
- if (!kvm_enabled(qts)) {
-qtest_quit(qts);
- return;
- }
-
/* Enabling and disabling kvm-no-adjvtime should always work. */assert_has_feature_disabled(qts, "host", "kvm-no-adjvtime");assert_set_feature(qts, "host", "kvm-no-adjvtime", true);tests/qtest/arm-cpu-features.c +1
-1@@ -624,7 +601,7 @@ int main(int argc, char **argv)* order avoid attempting to run an AArch32 QEMU with KVM on * AArch64 hosts. That won't work and isn't easy to detect. */ - if (g_str_equal(qtest_get_arch(), "aarch64")) { + if (g_str_equal(qtest_get_arch(), "aarch64") &&qtest_has_accel ("kvm" )) {
Quoted 8 lines
Quoted 8 lines
tests/qtest/arm-cpu-features.c int main(int argc, char **argv) · line 606
Quoted 2 lines
tests/qtest/arm-cpu-features.c +0
-0qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", NULL, test_query_cpu_model_expansion_kvm);I think this is wrong: query-kvm checks whether kvm is *enabled*, while your new function only checks whether kvm has been built into the binary. There is still the possibility that kvm has been built into the binary, but is not available on the host, so in that case the test will fail now.
Not enough coffee earlier. I think this is a documentation problem, query-kvm returns a list of *runtime* accelerators:
https://www.mail-archive.com/[email protected]/msg811144.html
IIUC what Paolo said, if something asks for an accelerator that is not present at build-time, then this is a configuration problem, not relevant for the management interface.
Quoted 5 lines
Quoted 2 lines
Thus please drop / rework this patch.
Indeed, this is unfortunate :(
Re: [PATCH v16 04/99] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
Quoted 74 lines · Philippe Mathieu-Daudé
Quoted 64 lines · Philippe Mathieu-Daudé
Quoted 63 lines · Thomas Huth
Quoted 62 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Use the recently added generic
qtest_has_accel()method to check if KVM is available.Suggested-by Claudio Fontana <[email protected]>Reviewed-by Andrew Jones <[email protected]>Reviewed-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
---
tests/qtest/arm-cpu-features.c| 25 +------------------------1 file changed, 1 insertion(+), 24 deletions(-)tests/qtest/arm-cpu-features.c +0
-0@@ -26,21 +26,6 @@" 'arguments': { 'type': 'full', " #define QUERY_TAIL "}}"
-static boolkvm_enabled(QTestState *qts)tests/qtest/arm-cpu-features.c +0
-14-{ - QDict *resp, *qdict; - bool enabled; - - resp = qtest_qmp(qts, "{ 'execute': 'query-kvm' }"); - g_assert(qdict_haskey(resp, "return")); - qdict = qdict_get_qdict(resp, "return"); - g_assert(qdict_haskey(qdict, "enabled")); - enabled = qdict_get_bool(qdict, "enabled"); - qobject_unref(resp); - - return enabled; -} -static QDict *do_query_no_props(QTestState *qts, const char
*cpu_type) {
return qtest_qmp(qts,QUERY_HEAD"'model': { 'name': %s }"tests/qtest/arm-cpu-features.c +0
-0@@ -493,14 +478,6 @@ static void test_query_cpu_model_expansion_kvm(const void *data) qts = qtest_init(MACHINE_KVM "-cpu max");- /*
- * These tests target the 'host' CPU type, so KVM must be enabled. - */
- if (!kvm_enabled(qts)) {
-qtest_quit(qts);
- return;
- }
-
/* Enabling and disabling kvm-no-adjvtime should always work. */assert_has_feature_disabled(qts, "host", "kvm-no-adjvtime");assert_set_feature(qts, "host", "kvm-no-adjvtime", true);tests/qtest/arm-cpu-features.c +1
-1@@ -624,7 +601,7 @@ int main(int argc, char **argv)* order avoid attempting to run an AArch32 QEMU with KVM on * AArch64 hosts. That won't work and isn't easy to detect. */ - if (g_str_equal(qtest_get_arch(), "aarch64")) { + if (g_str_equal(qtest_get_arch(), "aarch64") &&qtest_has_accel ("kvm" )) {Quoted 8 lines
Quoted 8 lines
tests/qtest/arm-cpu-features.c int main(int argc, char **argv) · line 606
Quoted 2 lines
tests/qtest/arm-cpu-features.c +0
-0qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", NULL, test_query_cpu_model_expansion_kvm);I think this is wrong: query-kvm checks whether kvm is *enabled*, while your new function only checks whether kvm has been built into the binary. There is still the possibility that kvm has been built into the binary, but is not available on the host, so in that case the test will fail now.
Quoted 7 lines
Not enough coffee earlier. I think this is a documentation problem, query-kvm returns a list of *runtime* accelerators:
https://www.mail-archive.com/[email protected]/msg811144.htmlIIUC what Paolo said, if something asks for an accelerator that is not present at build-time, then this is a configuration problem, not relevant for the management interface.
Argh no... sigh. So we have 4 cases:
1- accelerator not built
2- accelerator built in as module but not loaded
3- accelerator built in & loaded but not usable
4- accelerator built in & loaded and usable
QMP query-accels returns "accelerator built in & loaded" without precising it is usable.
qtest kvm_enabled() checks if the accelerator is enabled without checking it is built-in.
QMP query-kvm returns 'present' as in built-in (so case 1), and 'enabled' (a.k.a. 'allowed') updated once init_machine() succeeded (so case 4).
So, again, IIUC Paolo, what he said is for the management layer 1 and 2 are the same, the accelerator is not present.
For qtests, we want the 'usable' case (4) right? Whether the accelerator is builtin / loaded is irrelevant.
Could we improve the terminology here? Maybe is_present() and is_usable()? Suggestions?
Do we need to add both query-present-accels query-usable-accels commands? Is it actually possible to return an array of 'usable' accelerators?
Maybe simply add query-present-accels() -> [] and
query-usable-accel(accel) -> bool.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Thus please drop / rework this patch.
Indeed, this is unfortunate :(
Re: [PATCH v16 04/99] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
Quoted 22 lines · Philippe Mathieu-Daudé
Quoted 8 lines
Not enough coffee earlier. I think this is a documentation problem, query-kvm returns a list of *runtime* accelerators:
https://www.mail-archive.com/[email protected]/msg811144.htmlIIUC what Paolo said, if something asks for an accelerator that is not present at build-time, then this is a configuration problem, not relevant for the management interface.
Argh no... sigh. So we have 4 cases:
1- accelerator not built
2- accelerator built in as module but not loaded
3- accelerator built in & loaded but not usable
4- accelerator built in & loaded and usableQMP query-accels returns "accelerator built in & loaded" without precising it is usable.
qtest
kvm_enabled()checks if the accelerator is enabled without checking it is built-in.
Quoted 6 lines
QMP query-kvm returns 'present' as in built-in (so case 1), and 'enabled' (a.k.a. 'allowed') updated once
init_machine()succeeded (so case 4).So, again, IIUC Paolo, what he said is for the management layer 1 and 2 are the same, the accelerator is not present.
Isn't 3 in the same boat? Really, the management app cares if it can use the accelerator, not whether it is present.
Quoted 7 lines
For qtests, we want the 'usable' case (4) right? Whether the accelerator is builtin / loaded is irrelevant.
Could we improve the terminology here? Maybe
is_present()andis_usable()? Suggestions?
Quoted 6 lines
Do we need to add both query-present-accels query-usable-accels commands? Is it actually possible to return an array of 'usable' accelerators?
Maybe simply add query-present-accels() -> [] and
query-usable-accel(accel) -> bool.
Can you just make query-accels return both pieces of information?
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [PATCH v16 04/99] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for KVM
In reply to Philippe Mathieu-DaudéQuoted 100 lines · Philippe Mathieu-Daudé
Quoted 74 lines · Philippe Mathieu-Daudé
Quoted 64 lines · Philippe Mathieu-Daudé
Quoted 63 lines · Thomas Huth
Quoted 62 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Use the recently added generic
qtest_has_accel()method to check if KVM is available.Suggested-by Claudio Fontana <[email protected]>Reviewed-by Andrew Jones <[email protected]>Reviewed-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
---
tests/qtest/arm-cpu-features.c| 25 +------------------------1 file changed, 1 insertion(+), 24 deletions(-)tests/qtest/arm-cpu-features.c +0
-0@@ -26,21 +26,6 @@" 'arguments': { 'type': 'full', " #define QUERY_TAIL "}}"
-static boolkvm_enabled(QTestState *qts)tests/qtest/arm-cpu-features.c +0
-14-{ - QDict *resp, *qdict; - bool enabled; - - resp = qtest_qmp(qts, "{ 'execute': 'query-kvm' }"); - g_assert(qdict_haskey(resp, "return")); - qdict = qdict_get_qdict(resp, "return"); - g_assert(qdict_haskey(qdict, "enabled")); - enabled = qdict_get_bool(qdict, "enabled"); - qobject_unref(resp); - - return enabled; -} -static QDict *do_query_no_props(QTestState *qts, const char
*cpu_type) {
return qtest_qmp(qts,QUERY_HEAD"'model': { 'name': %s }"tests/qtest/arm-cpu-features.c +0
-0@@ -493,14 +478,6 @@ static void test_query_cpu_model_expansion_kvm(const void *data) qts = qtest_init(MACHINE_KVM "-cpu max");- /*
- * These tests target the 'host' CPU type, so KVM must be enabled. - */
- if (!kvm_enabled(qts)) {
-qtest_quit(qts);
- return;
- }
-
/* Enabling and disabling kvm-no-adjvtime should always work. */assert_has_feature_disabled(qts, "host", "kvm-no-adjvtime");assert_set_feature(qts, "host", "kvm-no-adjvtime", true);tests/qtest/arm-cpu-features.c +1
-1@@ -624,7 +601,7 @@ int main(int argc, char **argv)* order avoid attempting to run an AArch32 QEMU with KVM on * AArch64 hosts. That won't work and isn't easy to detect. */ - if (g_str_equal(qtest_get_arch(), "aarch64")) { + if (g_str_equal(qtest_get_arch(), "aarch64") &&qtest_has_accel ("kvm" )) {Quoted 8 lines
Quoted 8 lines
tests/qtest/arm-cpu-features.c int main(int argc, char **argv) · line 606
Quoted 2 lines
tests/qtest/arm-cpu-features.c +0
-0qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", NULL, test_query_cpu_model_expansion_kvm);I think this is wrong: query-kvm checks whether kvm is *enabled*, while your new function only checks whether kvm has been built into the binary. There is still the possibility that kvm has been built into the binary, but is not available on the host, so in that case the test will fail now.
Quoted 7 lines
Not enough coffee earlier. I think this is a documentation problem, query-kvm returns a list of *runtime* accelerators:
https://www.mail-archive.com/[email protected]/msg811144.htmlIIUC what Paolo said, if something asks for an accelerator that is not present at build-time, then this is a configuration problem, not relevant for the management interface.
Argh no... sigh. So we have 4 cases:
1- accelerator not built
2- accelerator built in as module but not loaded
3- accelerator built in & loaded but not usable
4- accelerator built in & loaded and usableQMP query-accels returns "accelerator built in & loaded" without precising it is usable.
qtest
kvm_enabled()checks if the accelerator is enabled without checking it is built-in.QMP query-kvm returns 'present' as in built-in (so case 1), and 'enabled' (a.k.a. 'allowed') updated once
init_machine()succeeded (so case 4).
Quoted 8 lines
So, again, IIUC Paolo, what he said is for the management layer 1 and 2 are the same, the accelerator is not present.
For qtests, we want the 'usable' case (4) right? Whether the accelerator is builtin / loaded is irrelevant.
Could we improve the terminology here? Maybe
is_present()andis_usable()? Suggestions?
Let me try some terms:
1 - bool accelerator_built() -> accelerator has been part of this QEMU build. 2 - bool accelerator_loaded() -> accelerator has been loaded, either because it is built-in, or because its code has been dynamically loaded
and probably the management layers do not care about the distinction between 1, 2.
Maybe instead of "usable", "available" is better?
3 - bool accelerator_available()
Then we have the accelerator that is actually active, selected or chosen.
4 - bool accelerator_enabled()? bool accelerator_active()? bool accelerator_chosen()? bool accelerator_used()?
We already use the term "allowed", with different meaning and implementations depending on --enable-xxx, which is quite confusing I think..
Ciao,
Claudoi
Quoted 15 lines
Do we need to add both query-present-accels query-usable-accels commands? Is it actually possible to return an array of 'usable' accelerators?
Maybe simply add query-present-accels() -> [] and
query-usable-accel(accel) -> bool.Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Thus please drop / rework this patch.
Indeed, this is unfortunate :(
PATCH v16 5/99 qtest/arm-cpu-features: Restrict sve_tests_sve_off_kvm test to KVM
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
The sve_tests_sve_off_kvm() test is KVM specific. Only run it if KVM is available.
Message-Id: <[email protected]>
--- tests/qtest/arm-cpu-features.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/qtest/arm-cpu-features.c +2 -2
@@ -604,6 +604,8 @@ int main(int argc, char **argv)if (g_str_equal (qtest_get_arch (),"aarch64" ) &&qtest_has_accel ("kvm" )) {qtest_add_data_func ("/arm/kvm/query-cpu-model-expansion" ,NULL , test_query_cpu_model_expansion_kvm); +qtest_add_data_func ("/arm/kvm/query-cpu-model-expansion/sve-off" , +NULL , sve_tests_sve_off_kvm); }if (g_str_equal (qtest_get_arch (),"aarch64" )) {
@@ -611,8 +613,6 @@ int main(int argc, char **argv) NULL, sve_tests_sve_max_vq_8);qtest_add_data_func ("/arm/max/query-cpu-model-expansion/sve-off" ,NULL , sve_tests_sve_off); -qtest_add_data_func ("/arm/kvm/query-cpu-model-expansion/sve-off" , -NULL , sve_tests_sve_off_kvm); }return g_test_run ();
Signature · 1 line
2.20.1
Re: [PATCH v16 05/99] qtest/arm-cpu-features: Restrict sve_tests_sve_off_kvm test to KVM
Quoted 10 lines · Alex Bennée
From: Philippe Mathieu-Daudé<[email protected]>
The
sve_tests_sve_off_kvm()test is KVM specific.
Only run it if KVM is available.Suggested-by Andrew Jones<[email protected]>Reviewed-by Andrew Jones<[email protected]>Reviewed-by Alex Bennée<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Alex Bennée<[email protected]>
Quoted 4 lines
Message-Id:<[email protected]>
--- tests/qtest/arm-cpu-features.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
r~
PATCH v16 6/99 qtest/arm-cpu-features: Remove TCG fallback to KVM specific tests
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
sve_tests_sve_off_kvm() and test_query_cpu_model_expansion_kvm() tests are now only being run if KVM is available. Drop the TCG fallback.
Message-Id: <[email protected]>
--- tests/qtest/arm-cpu-features.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qtest/arm-cpu-features.c +1 -1
@@ -21,7 +21,7 @@#define SVE_MAX_VQ 16#define MACHINE "-machine virt,gic-version=max -accel tcg " -#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accel tcg " +#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm "#define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \ " 'arguments': { 'type': 'full', "#define QUERY_TAIL "}}"
Signature · 1 line
2.20.1
Re: [PATCH v16 06/99] qtest/arm-cpu-features: Remove TCG fallback to KVM specific tests
Quoted 11 lines · Alex Bennée
From: Philippe Mathieu-Daudé<[email protected]>
sve_tests_sve_off_kvm()andtest_query_cpu_model_expansion_kvm()tests are now only being run if KVM is available. Drop the TCG fallback.Suggested-by Andrew Jones<[email protected]>Reviewed-by Andrew Jones<[email protected]>Reviewed-by Alex Bennée<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Alex Bennée<[email protected]>
Quoted 4 lines
Message-Id:<[email protected]>
--- tests/qtest/arm-cpu-features.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
Re: [PATCH v16 06/99] qtest/arm-cpu-features: Remove TCG fallback to KVM specific tests
In reply to Alex BennéeQuoted 21 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
sve_tests_sve_off_kvm()andtest_query_cpu_model_expansion_kvm()tests are now only being run if KVM is available. Drop the TCG fallback.Suggested-by Andrew Jones <[email protected]>Reviewed-by Andrew Jones <[email protected]>Reviewed-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
--- tests/qtest/arm-cpu-features.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/qtest/arm-cpu-features.c +0
-0
tests/qtest/arm-cpu-features.c line 24
Quoted 5 lines
tests/qtest/arm-cpu-features.c +1
-1@@ -21,7 +21,7 @@#define SVE_MAX_VQ 16#define MACHINE "-machine virt,gic-version=max -accel tcg " -#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accel tcg " +#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm "
Same comment as with patch 04/99: I think this is wrong. You're mixing up whether an accelerator has been built into the binary with the fact whether an accelerator is available and usable. There are plenty of cases where e.g. kvm is built into the binary but not usable during runtime, e.g. because:
1) The kernel does not support it
2) The current host CPU does not support it
3) There are problems with the permission to /dev/kvm
etc.
I think we either need the fallback mechanism to tcg or you need to properly check whether KVM is usable, too.
Thomas
Re: [PATCH v16 06/99] qtest/arm-cpu-features: Remove TCG fallback to KVM specific tests
Quoted 30 lines · Thomas Huth
Quoted 25 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
sve_tests_sve_off_kvm()andtest_query_cpu_model_expansion_kvm()tests are now only being run if KVM is available. Drop the TCG fallback.Suggested-by Andrew Jones <[email protected]>Reviewed-by Andrew Jones <[email protected]>Reviewed-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
---
tests/qtest/arm-cpu-features.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tests/qtest/arm-cpu-features.c +0
-1@@ -21,7 +21,7 @@ #define SVE_MAX_VQ 16 #define MACHINE "-machine virt,gic-version=max -accel tcg " -#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accelQuoted 2 lines
tcg "
+#defineMACHINE_KVM"-machine virt,gic-version=max -accel kvm "Same comment as with patch 04/99: I think this is wrong. You're mixing
Quoted 8 lines
up whether an accelerator has been built into the binary with the fact whether an accelerator is available and usable. There are plenty of cases where e.g. kvm is built into the binary but not usable during runtime, e.g. because:
1) The kernel does not support it
2) The current host CPU does not support it
3) There are problems with the permission to/dev/kvm
etc.
Yes.
Quoted 1 line
I think we either need the fallback mechanism to tcg
No, this is precisely what we want to test.
Quoted 2 lines
or you need to
properly check whether KVM is usable, too.
Yes.
PATCH v16 7/99 qtest/arm-cpu-features: Use generic qtest_has_accel() to check for TCG
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Now than we can probe if the TCG accelerator is available at runtime with a QMP command, only run these tests if TCG is built into the QEMU binary.
Message-Id: <[email protected]>
--- tests/qtest/arm-cpu-features.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
tests/qtest/arm-cpu-features.c +9 -7
@@ -20,7 +20,7 @@*/ #define SVE_MAX_VQ 16 -#define MACHINE "-machine virt,gic-version=max -accel tcg " +#define MACHINE_TCG "-machine virt,gic-version=max -accel tcg "#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm "#define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \ " 'arguments': { 'type': 'full', "
@@ -337,7 +337,7 @@ static void sve_tests_sve_max_vq_8(const void *data) {QTestState *qts; - qts =qtest_init (MACHINE "-cpu max,sve-max-vq=8" ); + qts =qtest_init (MACHINE_TCG "-cpu max,sve-max-vq=8" );assert_sve_vls (qts,"max" ,BIT_ULL (8 ) -1 ,NULL );
@@ -372,7 +372,7 @@ static void sve_tests_sve_off(const void *data) {QTestState *qts; - qts =qtest_init (MACHINE "-cpu max,sve=off" ); + qts =qtest_init (MACHINE_TCG "-cpu max,sve=off" );/* SVE is off, so the map should be empty. */ assert_sve_vls (qts,"max" ,0 ,NULL );
@@ -428,7 +428,7 @@ static void test_query_cpu_model_expansion(const void *data) {QTestState *qts; - qts =qtest_init (MACHINE "-cpu max" ); + qts =qtest_init (MACHINE_TCG "-cpu max" );/* Test common query-cpu-model-expansion input validation */ assert_type_full (qts);
@@ -593,8 +593,10 @@ int main(int argc, char **argv) {g_test_init (&argc, &argv,NULL ); -qtest_add_data_func ("/arm/query-cpu-model-expansion" , -NULL , test_query_cpu_model_expansion); +if (qtest_has_accel ("tcg" )) { +qtest_add_data_func ("/arm/query-cpu-model-expansion" , +NULL , test_query_cpu_model_expansion); + }/* * For now we only run KVM specific tests with AArch64 QEMU in
@@ -608,7 +610,7 @@ int main(int argc, char **argv) NULL, sve_tests_sve_off_kvm); } -if (g_str_equal (qtest_get_arch (),"aarch64" )) { +if (g_str_equal (qtest_get_arch (),"aarch64" ) &&qtest_has_accel ("tcg" )) {qtest_add_data_func ("/arm/max/query-cpu-model-expansion/sve-max-vq-8" ,NULL , sve_tests_sve_max_vq_8); qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off",
Signature · 1 line
2.20.1
Re: [PATCH v16 07/99] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for TCG
Quoted 11 lines · Alex Bennée
From: Philippe Mathieu-Daudé<[email protected]>
Now than we can probe if the TCG accelerator is available at runtime with a QMP command, only run these tests if TCG is built into the QEMU binary.
Suggested-by Andrew Jones<[email protected]>Reviewed-by Andrew Jones<[email protected]>Reviewed-by Alex Bennée<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Alex Bennée<[email protected]>
Quoted 4 lines
Message-Id:<[email protected]>
--- tests/qtest/arm-cpu-features.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
r~
Re: [PATCH v16 07/99] qtest/arm-cpu-features: Use generic qtest_has_accel() to check for TCG
In reply to Alex BennéeQuoted 11 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Now than we can probe if the TCG accelerator is available at runtime with a QMP command, only run these tests if TCG is built into the QEMU binary.
Suggested-by Andrew Jones <[email protected]>Reviewed-by Andrew Jones <[email protected]>Reviewed-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>
Quoted 4 lines
Message-Id: <[email protected]>
--- tests/qtest/arm-cpu-features.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
PATCH v16 8/99 qtest/migration-test: Skip tests if KVM not builtin on s390x/ppc64
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
We might have a s390x/ppc64 QEMU binary built without the KVM accelerator (configured with --disable-kvm).
Checking for /dev/kvm accessibility isn't enough, also check for the accelerator in the binary.
Message-Id: <[email protected]>
--- tests/qtest/migration-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/qtest/migration-test.c +2 -2
@@ -1387,7 +1387,7 @@ int main(int argc, char **argv)*/ if (g_str_equal (qtest_get_arch (),"ppc64" ) && (access ("/sys/module/kvm_hv" ,F_OK ) || -access ("/dev/kvm" ,R_OK |W_OK ))) { +access ("/dev/kvm" ,R_OK |W_OK ) || !qtest_has_accel ("kvm" ))) {g_test_message ("Skipping test: kvm_hv not available" );return g_test_run (); }
@@ -1398,7 +1398,7 @@ int main(int argc, char **argv)*/ if (g_str_equal (qtest_get_arch (),"s390x" )) {#if defined(HOST_S390X ) -if (access ("/dev/kvm" ,R_OK |W_OK )) { +if (access ("/dev/kvm" ,R_OK |W_OK ) || !qtest_has_accel ("kvm" )) {g_test_message ("Skipping test: kvm not available" );return g_test_run (); }
Signature · 1 line
2.20.1
Re: [PATCH v16 08/99] qtest/migration-test: Skip tests if KVM not builtin on s390x/ppc64
Quoted 8 lines · Alex Bennée
if (g_str_equal(qtest_get_arch(), "ppc64") && (access("/sys/module/kvm_hv", F_OK) ||tests/qtest/migration-test.c +1
-1- access("/dev/kvm", R_OK | W_OK))) { + access("/dev/kvm", R_OK | W_OK) || !qtest_has_accel("kvm"))) {g_test_message ("Skipping test: kvm_hv not available" );return g_test_run (); }
tests/qtest/migration-test.c int main(int argc, char **argv) · line 1402
Quoted 6 lines
tests/qtest/migration-test.c +1
-1@@ -1398,7 +1398,7 @@ int main(int argc, char **argv)*/ if (g_str_equal (qtest_get_arch (),"s390x" )) {#if defined(HOST_S390X ) -if (access ("/dev/kvm" ,R_OK |W_OK )) { +if (access ("/dev/kvm" ,R_OK |W_OK ) || !qtest_has_accel ("kvm" )) {g_test_message ("Skipping test: kvm not available" );
I would have sorted the kvm test first.
For s390x, we has the HOST test, but ppc doesn't. So we're doing the access() on any host, e.g. x86_64, where kvm cannot true for this test.
r~
Re: [PATCH v16 08/99] qtest/migration-test: Skip tests if KVM not builtin on s390x/ppc64
Quoted 10 lines · Richard Henderson
Quoted 9 lines · Alex Bennée
if (
g_str_equal(qtest_get_arch(), "ppc64")&& (access("/sys/module/kvm_hv", F_OK)||
-access("/dev/kvm", R_OK | W_OK))) {
+access("/dev/kvm", R_OK | W_OK)|| !qtest_has_accel("kvm"))) {g_test_message("Skipping test: kvm_hv not available"); returng_test_run();
}(quoted diff) +0
-0@@ -1398,7 +1398,7 @@ int main(int argc, char **argv) */
Quoted 8 lines
tests/qtest/migration-test.c int main(int argc, char **argv) · line 1402
Quoted 6 lines
tests/qtest/migration-test.c +1
-1if (g_str_equal(qtest_get_arch(), "s390x")) { #if defined(HOST_S390X) - if (access("/dev/kvm", R_OK | W_OK)) { + if (access("/dev/kvm", R_OK | W_OK) || !qtest_has_accel ("kvm" )) { g_test_message("Skipping test: kvm not available");I would have sorted the kvm test first.
access() is a simple syscall from the qtest, while qtest_has_accel() spawn a whole QEMU process to exec the QMP request.
Quoted 2 lines
For s390x, we has the HOST test, but ppc doesn't. So we're doing the
access()on any host, e.g.x86_64, where kvm cannot true for this test.
Hmm I suppose the issue you described predate this patch?
Re: [PATCH v16 08/99] qtest/migration-test: Skip tests if KVM not builtin on s390x/ppc64
In reply to Alex BennéeQuoted 13 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
We might have a s390x/ppc64 QEMU binary built without the KVM accelerator (configured with --disable-kvm).
Checking for/dev/kvmaccessibility isn't enough, also check for the accelerator in the binary.Reviewed-by David Gibson <[email protected]>Reviewed-by Greg Kurz <[email protected]>Reviewed-by Cornelia Huck <[email protected]>Reviewed-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>
Quoted 4 lines
Message-Id: <[email protected]>
--- tests/qtest/migration-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH v16 9/99 qtest/bios-tables-test: Rename tests not TCG specific
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Various tests don't require TCG, but have '_tcg' in their name. As this is misleading, remove 'tcg' from their name.
Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test.c | 142 ++++++++++++++++----------------- 1 file changed, 71 insertions(+), 71 deletions(-)
tests/qtest/bios-tables-test.c +71 -71
@@ -753,7 +753,7 @@ static uint8_t base_required_struct_types[] = {0 ,1 ,3 ,4 ,16 ,17 ,19 ,32 ,127 }; -static void test_acpi_piix4_tcg (void ) +static void test_acpi_piix4 (void ) {test_data data;
@@ -768,7 +768,7 @@ static void test_acpi_piix4_tcg(void)free_test_data (&data); } -static void test_acpi_piix4_tcg_bridge (void ) +static void test_acpi_piix4_bridge (void ) {test_data data;
@@ -824,7 +824,7 @@ static void test_acpi_piix4_no_acpi_pci_hotplug(void)free_test_data (&data); } -static void test_acpi_q35_tcg (void ) +static void test_acpi_q35 (void ) {test_data data;
@@ -841,7 +841,7 @@ static void test_acpi_q35_tcg(void)free_test_data (&data); } -static void test_acpi_q35_tcg_bridge (void ) +static void test_acpi_q35_bridge (void ) {test_data data;
@@ -855,7 +855,7 @@ static void test_acpi_q35_tcg_bridge(void)free_test_data (&data); } -static void test_acpi_q35_tcg_mmio64 (void ) +static void test_acpi_q35_mmio64 (void ) {test_data data = { .machine =MACHINE_Q35 ,
@@ -872,7 +872,7 @@ static void test_acpi_q35_tcg_mmio64(void)free_test_data (&data); } -static void test_acpi_piix4_tcg_cphp (void ) +static void test_acpi_piix4_cphp (void ) {test_data data;
@@ -888,7 +888,7 @@ static void test_acpi_piix4_tcg_cphp(void)free_test_data (&data); } -static void test_acpi_q35_tcg_cphp (void ) +static void test_acpi_q35_cphp (void ) {test_data data;
@@ -908,7 +908,7 @@ static uint8_t ipmi_required_struct_types[] = {0 ,1 ,3 ,4 ,16 ,17 ,19 ,32 ,38 ,127 }; -static void test_acpi_q35_tcg_ipmi (void ) +static void test_acpi_q35_ipmi (void ) {test_data data;
@@ -923,7 +923,7 @@ static void test_acpi_q35_tcg_ipmi(void)free_test_data (&data); } -static void test_acpi_piix4_tcg_ipmi (void ) +static void test_acpi_piix4_ipmi (void ) {test_data data;
@@ -941,7 +941,7 @@ static void test_acpi_piix4_tcg_ipmi(void)free_test_data (&data); } -static void test_acpi_q35_tcg_memhp (void ) +static void test_acpi_q35_memhp (void ) {test_data data;
@@ -957,7 +957,7 @@ static void test_acpi_q35_tcg_memhp(void)free_test_data (&data); } -static void test_acpi_piix4_tcg_memhp (void ) +static void test_acpi_piix4_memhp (void ) {test_data data;
@@ -973,7 +973,7 @@ static void test_acpi_piix4_tcg_memhp(void)free_test_data (&data); } -static void test_acpi_piix4_tcg_nosmm (void ) +static void test_acpi_piix4_nosmm (void ) {test_data data;
@@ -984,7 +984,7 @@ static void test_acpi_piix4_tcg_nosmm(void)free_test_data (&data); } -static void test_acpi_piix4_tcg_smm_compat (void ) +static void test_acpi_piix4_smm_compat (void ) {test_data data;
@@ -995,7 +995,7 @@ static void test_acpi_piix4_tcg_smm_compat(void)free_test_data (&data); } -static void test_acpi_piix4_tcg_smm_compat_nosmm (void ) +static void test_acpi_piix4_smm_compat_nosmm (void ) {test_data data;
@@ -1006,7 +1006,7 @@ static void test_acpi_piix4_tcg_smm_compat_nosmm(void)free_test_data (&data); } -static void test_acpi_piix4_tcg_nohpet (void ) +static void test_acpi_piix4_nohpet (void ) {test_data data;
@@ -1017,7 +1017,7 @@ static void test_acpi_piix4_tcg_nohpet(void)free_test_data (&data); } -static void test_acpi_q35_tcg_numamem (void ) +static void test_acpi_q35_numamem (void ) {test_data data;
@@ -1029,7 +1029,7 @@ static void test_acpi_q35_tcg_numamem(void)free_test_data (&data); } -static void test_acpi_q35_tcg_nosmm (void ) +static void test_acpi_q35_nosmm (void ) {test_data data;
@@ -1040,7 +1040,7 @@ static void test_acpi_q35_tcg_nosmm(void)free_test_data (&data); } -static void test_acpi_q35_tcg_smm_compat (void ) +static void test_acpi_q35_smm_compat (void ) {test_data data;
@@ -1051,7 +1051,7 @@ static void test_acpi_q35_tcg_smm_compat(void)free_test_data (&data); } -static void test_acpi_q35_tcg_smm_compat_nosmm (void ) +static void test_acpi_q35_smm_compat_nosmm (void ) {test_data data;
@@ -1062,7 +1062,7 @@ static void test_acpi_q35_tcg_smm_compat_nosmm(void)free_test_data (&data); } -static void test_acpi_q35_tcg_nohpet (void ) +static void test_acpi_q35_nohpet (void ) {test_data data;
@@ -1073,7 +1073,7 @@ static void test_acpi_q35_tcg_nohpet(void)free_test_data (&data); } -static void test_acpi_piix4_tcg_numamem (void ) +static void test_acpi_piix4_numamem (void ) {test_data data;
@@ -1087,11 +1087,11 @@ static void test_acpi_piix4_tcg_numamem(void)uint64_t tpm_tis_base_addr; -static void test_acpi_tcg_tpm (const char *machine,const char *tpm_if, +static void test_acpi_tpm (const char *machine,const char *tpm_if,uint64_t base) {#ifdef CONFIG_TPM -gchar *tmp_dir_name =g_strdup_printf ("qemu-test_acpi_%s_tcg_%s.XXXXXX" , +gchar *tmp_dir_name =g_strdup_printf ("qemu-test_acpi_%s_%s.XXXXXX" , machine, tpm_if);char *tmp_path =g_dir_make_tmp (tmp_dir_name,NULL );TestState test;
@@ -1139,12 +1139,12 @@ static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if,#endif } -static void test_acpi_q35_tcg_tpm_tis (void ) +static void test_acpi_q35_tpm_tis (void ) { -test_acpi_tcg_tpm ("q35" ,"tis" ,0xFED40000 ); +test_acpi_tpm ("q35" ,"tis" ,0xFED40000 ); } -static void test_acpi_tcg_dimm_pxm (const char *machine) +static void test_acpi_dimm_pxm (const char *machine) {test_data data;
@@ -1174,14 +1174,14 @@ static void test_acpi_tcg_dimm_pxm(const char *machine)free_test_data (&data); } -static void test_acpi_q35_tcg_dimm_pxm (void ) +static void test_acpi_q35_dimm_pxm (void ) { -test_acpi_tcg_dimm_pxm (MACHINE_Q35 ); +test_acpi_dimm_pxm (MACHINE_Q35 ); } -static void test_acpi_piix4_tcg_dimm_pxm (void ) +static void test_acpi_piix4_dimm_pxm (void ) { -test_acpi_tcg_dimm_pxm (MACHINE_PC ); +test_acpi_dimm_pxm (MACHINE_PC ); }static void test_acpi_virt_tcg_memhp (void )
@@ -1223,7 +1223,7 @@ static void test_acpi_microvm_prepare(test_data *data) data->blkdev ="virtio-blk-device" ; } -static void test_acpi_microvm_tcg (void ) +static void test_acpi_microvm (void ) {test_data data;
@@ -1233,7 +1233,7 @@ static void test_acpi_microvm_tcg(void)free_test_data (&data); } -static void test_acpi_microvm_usb_tcg (void ) +static void test_acpi_microvm_usb (void ) {test_data data;
@@ -1244,7 +1244,7 @@ static void test_acpi_microvm_usb_tcg(void)free_test_data (&data); } -static void test_acpi_microvm_rtc_tcg (void ) +static void test_acpi_microvm_rtc (void ) {test_data data;
@@ -1255,7 +1255,7 @@ static void test_acpi_microvm_rtc_tcg(void)free_test_data (&data); } -static void test_acpi_microvm_pcie_tcg (void ) +static void test_acpi_microvm_pcie (void ) {test_data data;
@@ -1267,7 +1267,7 @@ static void test_acpi_microvm_pcie_tcg(void)free_test_data (&data); } -static void test_acpi_microvm_ioapic2_tcg (void ) +static void test_acpi_microvm_ioapic2 (void ) {test_data data;
@@ -1332,7 +1332,7 @@ static void test_acpi_virt_tcg_pxb(void)free_test_data (&data); } -static void test_acpi_tcg_acpi_hmat (const char *machine) +static void test_acpi_acpi_hmat (const char *machine) {test_data data;
@@ -1364,14 +1364,14 @@ static void test_acpi_tcg_acpi_hmat(const char *machine)free_test_data (&data); } -static void test_acpi_q35_tcg_acpi_hmat (void ) +static void test_acpi_q35_acpi_hmat (void ) { -test_acpi_tcg_acpi_hmat (MACHINE_Q35 ); +test_acpi_acpi_hmat (MACHINE_Q35 ); } -static void test_acpi_piix4_tcg_acpi_hmat (void ) +static void test_acpi_piix4_acpi_hmat (void ) { -test_acpi_tcg_acpi_hmat (MACHINE_PC ); +test_acpi_acpi_hmat (MACHINE_PC ); }static void test_acpi_virt_tcg (void )
@@ -1512,50 +1512,50 @@ int main(int argc, char *argv[])return ret; }qtest_add_func ("acpi/q35/oem-fields" , test_acpi_oem_fields_q35); -qtest_add_func ("acpi/q35/tpm-tis" , test_acpi_q35_tcg_tpm_tis); -qtest_add_func ("acpi/piix4" , test_acpi_piix4_tcg); +qtest_add_func ("acpi/q35/tpm-tis" , test_acpi_q35_tpm_tis); +qtest_add_func ("acpi/piix4" , test_acpi_piix4);qtest_add_func ("acpi/oem-fields" , test_acpi_oem_fields_pc); -qtest_add_func ("acpi/piix4/bridge" , test_acpi_piix4_tcg_bridge); +qtest_add_func ("acpi/piix4/bridge" , test_acpi_piix4_bridge);qtest_add_func ("acpi/piix4/pci-hotplug/no_root_hotplug" , test_acpi_piix4_no_root_hotplug);qtest_add_func ("acpi/piix4/pci-hotplug/no_bridge_hotplug" , test_acpi_piix4_no_bridge_hotplug);qtest_add_func ("acpi/piix4/pci-hotplug/off" , test_acpi_piix4_no_acpi_pci_hotplug); -qtest_add_func ("acpi/q35" , test_acpi_q35_tcg); -qtest_add_func ("acpi/q35/bridge" , test_acpi_q35_tcg_bridge); -qtest_add_func ("acpi/q35/mmio64" , test_acpi_q35_tcg_mmio64); -qtest_add_func ("acpi/piix4/ipmi" , test_acpi_piix4_tcg_ipmi); -qtest_add_func ("acpi/q35/ipmi" , test_acpi_q35_tcg_ipmi); -qtest_add_func ("acpi/piix4/cpuhp" , test_acpi_piix4_tcg_cphp); -qtest_add_func ("acpi/q35/cpuhp" , test_acpi_q35_tcg_cphp); -qtest_add_func ("acpi/piix4/memhp" , test_acpi_piix4_tcg_memhp); -qtest_add_func ("acpi/q35/memhp" , test_acpi_q35_tcg_memhp); -qtest_add_func ("acpi/piix4/numamem" , test_acpi_piix4_tcg_numamem); -qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_tcg_numamem); -qtest_add_func ("acpi/piix4/nosmm" , test_acpi_piix4_tcg_nosmm); +qtest_add_func ("acpi/q35" , test_acpi_q35); +qtest_add_func ("acpi/q35/bridge" , test_acpi_q35_bridge); +qtest_add_func ("acpi/q35/mmio64" , test_acpi_q35_mmio64); +qtest_add_func ("acpi/piix4/ipmi" , test_acpi_piix4_ipmi); +qtest_add_func ("acpi/q35/ipmi" , test_acpi_q35_ipmi); +qtest_add_func ("acpi/piix4/cpuhp" , test_acpi_piix4_cphp); +qtest_add_func ("acpi/q35/cpuhp" , test_acpi_q35_cphp); +qtest_add_func ("acpi/piix4/memhp" , test_acpi_piix4_memhp); +qtest_add_func ("acpi/q35/memhp" , test_acpi_q35_memhp); +qtest_add_func ("acpi/piix4/numamem" , test_acpi_piix4_numamem); +qtest_add_func ("acpi/q35/numamem" , test_acpi_q35_numamem); +qtest_add_func ("acpi/piix4/nosmm" , test_acpi_piix4_nosmm);qtest_add_func ("acpi/piix4/smm-compat" , - test_acpi_piix4_tcg_smm_compat); + test_acpi_piix4_smm_compat);qtest_add_func ("acpi/piix4/smm-compat-nosmm" , - test_acpi_piix4_tcg_smm_compat_nosmm); -qtest_add_func ("acpi/piix4/nohpet" , test_acpi_piix4_tcg_nohpet); -qtest_add_func ("acpi/q35/nosmm" , test_acpi_q35_tcg_nosmm); + test_acpi_piix4_smm_compat_nosmm); +qtest_add_func ("acpi/piix4/nohpet" , test_acpi_piix4_nohpet); +qtest_add_func ("acpi/q35/nosmm" , test_acpi_q35_nosmm);qtest_add_func ("acpi/q35/smm-compat" , - test_acpi_q35_tcg_smm_compat); + test_acpi_q35_smm_compat);qtest_add_func ("acpi/q35/smm-compat-nosmm" , - test_acpi_q35_tcg_smm_compat_nosmm); -qtest_add_func ("acpi/q35/nohpet" , test_acpi_q35_tcg_nohpet); -qtest_add_func ("acpi/piix4/dimmpxm" , test_acpi_piix4_tcg_dimm_pxm); -qtest_add_func ("acpi/q35/dimmpxm" , test_acpi_q35_tcg_dimm_pxm); -qtest_add_func ("acpi/piix4/acpihmat" , test_acpi_piix4_tcg_acpi_hmat); -qtest_add_func ("acpi/q35/acpihmat" , test_acpi_q35_tcg_acpi_hmat); -qtest_add_func ("acpi/microvm" , test_acpi_microvm_tcg); -qtest_add_func ("acpi/microvm/usb" , test_acpi_microvm_usb_tcg); -qtest_add_func ("acpi/microvm/rtc" , test_acpi_microvm_rtc_tcg); -qtest_add_func ("acpi/microvm/ioapic2" , test_acpi_microvm_ioapic2_tcg); + test_acpi_q35_smm_compat_nosmm); +qtest_add_func ("acpi/q35/nohpet" , test_acpi_q35_nohpet); +qtest_add_func ("acpi/piix4/dimmpxm" , test_acpi_piix4_dimm_pxm); +qtest_add_func ("acpi/q35/dimmpxm" , test_acpi_q35_dimm_pxm); +qtest_add_func ("acpi/piix4/acpihmat" , test_acpi_piix4_acpi_hmat); +qtest_add_func ("acpi/q35/acpihmat" , test_acpi_q35_acpi_hmat); +qtest_add_func ("acpi/microvm" , test_acpi_microvm); +qtest_add_func ("acpi/microvm/usb" , test_acpi_microvm_usb); +qtest_add_func ("acpi/microvm/rtc" , test_acpi_microvm_rtc); +qtest_add_func ("acpi/microvm/ioapic2" , test_acpi_microvm_ioapic2);qtest_add_func ("acpi/microvm/oem-fields" , test_acpi_oem_fields_microvm);if (strcmp (arch,"x86_64" ) ==0 ) { -qtest_add_func ("acpi/microvm/pcie" , test_acpi_microvm_pcie_tcg); +qtest_add_func ("acpi/microvm/pcie" , test_acpi_microvm_pcie); } }else if (strcmp (arch,"aarch64" ) ==0 ) {qtest_add_func ("acpi/virt" , test_acpi_virt_tcg);
Signature · 1 line
2.20.1
Re: [PATCH v16 09/99] qtest/bios-tables-test: Rename tests not TCG specific
Quoted 13 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Various tests don't require TCG, but have '
_tcg' in their name. As this is misleading, remove 'tcg' from their name.Reported-by Igor Mammedov <[email protected]>Reviewed-by Igor Mammedov <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test.c | 142 ++++++++++++++++----------------- 1 file changed, 71 insertions(+), 71 deletions(-)
[...]
tests/qtest/bios-tables-test.c static void test_acpi_microvm_rtc_tcg(void) · line 1260
Quoted 8 lines
tests/qtest/bios-tables-test.c +1
-1@@ -1255,7 +1255,7 @@ static void test_acpi_microvm_rtc_tcg(void)free_test_data (&data); } -static void test_acpi_microvm_pcie_tcg (void ) +static void test_acpi_microvm_pcie (void ) {test_data data;
This change is wrong: test_acpi_microvm_pcie_tcg() uses data.tcg_only = true, so the _tcg suffix indeed makes sense here.
Thomas
Re: [PATCH v16 09/99] qtest/bios-tables-test: Rename tests not TCG specific
Quoted 15 lines · Thomas Huth
Quoted 13 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Various tests don't require TCG, but have '
_tcg' in their name. As this is misleading, remove 'tcg' from their name.Reported-by Igor Mammedov <[email protected]>Reviewed-by Igor Mammedov <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
---
tests/qtest/bios-tables-test.c| 142 ++++++++++++++++-----------------1 file changed, 71 insertions(+), 71 deletions(-)[...]
Quoted 10 lines
tests/qtest/bios-tables-test.c static void test_acpi_microvm_rtc_tcg(void) · line 1260
Quoted 7 lines
tests/qtest/bios-tables-test.c +1
-0@@ -1255,7 +1255,7 @@ static void test_acpi_microvm_rtc_tcg(void) free_test_data(&data); } -static void test_acpi_microvm_pcie_tcg(void) +static voidtest_acpi_microvm_pcie (void) { test_data data;This change is wrong:
test_acpi_microvm_pcie_tcg()uses data.tcg_only = true, so the_tcgsuffix indeed makes sense here.
I supposed I messed while rebasing...
PATCH v16 10/99 qtest/bios-tables-test: Rename TCG specific tests
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Some tests require TCG, but don't have '_tcg' in their name, while others do. Unify the test names by adding 'tcg' to the TCG specific tests.
Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tests/qtest/bios-tables-test.c +4 -4
@@ -1255,7 +1255,7 @@ static void test_acpi_microvm_rtc(void)free_test_data (&data); } -static void test_acpi_microvm_pcie (void ) +static void test_acpi_microvm_pcie_tcg (void ) {test_data data;
@@ -1475,7 +1475,7 @@ static void test_acpi_oem_fields_microvm(void)g_free (args); } -static void test_acpi_oem_fields_virt (void ) +static void test_acpi_oem_fields_virt_tcg (void ) {test_data data = { .machine ="virt" ,
@@ -1555,14 +1555,14 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/microvm/ioapic2" , test_acpi_microvm_ioapic2);qtest_add_func ("acpi/microvm/oem-fields" , test_acpi_oem_fields_microvm);if (strcmp (arch,"x86_64" ) ==0 ) { -qtest_add_func ("acpi/microvm/pcie" , test_acpi_microvm_pcie); +qtest_add_func ("acpi/microvm/pcie" , test_acpi_microvm_pcie_tcg); } }else if (strcmp (arch,"aarch64" ) ==0 ) {qtest_add_func ("acpi/virt" , test_acpi_virt_tcg);qtest_add_func ("acpi/virt/numamem" , test_acpi_virt_tcg_numamem);qtest_add_func ("acpi/virt/memhp" , test_acpi_virt_tcg_memhp);qtest_add_func ("acpi/virt/pxb" , test_acpi_virt_tcg_pxb); -qtest_add_func ("acpi/virt/oem-fields" , test_acpi_oem_fields_virt); +qtest_add_func ("acpi/virt/oem-fields" , test_acpi_oem_fields_virt_tcg); } ret =g_test_run ();boot_sector_cleanup (disk);
Signature · 1 line
2.20.1
Re: [PATCH v16 10/99] qtest/bios-tables-test: Rename TCG specific tests
Quoted 20 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Some tests require TCG, but don't have '
_tcg' in their name, while others do. Unify the test names by adding 'tcg' to the TCG specific tests.Reported-by Igor Mammedov <[email protected]>Reviewed-by Igor Mammedov <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)tests/qtest/bios-tables-test.c +0
-0
tests/qtest/bios-tables-test.c static void test_acpi_microvm_rtc(void) · line 1258
Quoted 5 lines
tests/qtest/bios-tables-test.c +1
-1@@ -1255,7 +1255,7 @@ static void test_acpi_microvm_rtc(void)free_test_data (&data); } -static void test_acpi_microvm_pcie (void ) +static void test_acpi_microvm_pcie_tcg (void )
Lol, that's the one you removed in the previous patch :-)
tests/qtest/bios-tables-test.c static void test_acpi_oem_fields_microvm(void) · line 1478
Quoted 9 lines
tests/qtest/bios-tables-test.c +1
-1{test_data data;@@ -1475,7 +1475,7 @@ static void test_acpi_oem_fields_microvm(void)g_free (args); } -static void test_acpi_oem_fields_virt (void ) +static void test_acpi_oem_fields_virt_tcg (void )
This one is ok.
Thomas
PATCH v16 11/99 qtest/bios-tables-test: Make test build-independent from accelerator
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Now that we can probe if the TCG accelerator is available at runtime with a QMP command, do it once at the beginning and only register the tests we can run.
We can then replace the #ifdef'ry by an assertion.
Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
tests/qtest/bios-tables-test.c +6 -8
@@ -97,6 +97,7 @@ typedef struct {QTestState *qts; } test_data; +static bool tcg_accel_available;static char disk[] ="tests/acpi-test-disk-XXXXXX" ;static const char *data_dir ="tests/data/acpi" ;#ifdef CONFIG_IASL
@@ -718,12 +719,7 @@ static void test_acpi_one(const char *params, test_data *data)char *args;bool use_uefi = data->uefi_fl1 && data->uefi_fl2; -#ifndef CONFIG_TCG -if (data->tcg_only) { -g_test_skip ("TCG disabled, skipping ACPI tcg_only test" ); -return ; - } -#endif /* CONFIG_TCG */ +assert (!data->tcg_only || tcg_accel_available); args =test_acpi_create_args (data, params, use_uefi); data->qts =qtest_init (args);
@@ -1506,6 +1502,8 @@ int main(int argc, char *argv[])g_test_init (&argc, &argv,NULL ); + tcg_accel_available =qtest_has_accel ("tcg" ); +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { ret =boot_sector_init (disk);if (ret) {
@@ -1554,10 +1552,10 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/microvm/rtc" , test_acpi_microvm_rtc);qtest_add_func ("acpi/microvm/ioapic2" , test_acpi_microvm_ioapic2);qtest_add_func ("acpi/microvm/oem-fields" , test_acpi_oem_fields_microvm); -if (strcmp (arch,"x86_64" ) ==0 ) { +if (strcmp (arch,"x86_64" ) ==0 && tcg_accel_available) {qtest_add_func ("acpi/microvm/pcie" , test_acpi_microvm_pcie_tcg); } - }else if (strcmp (arch,"aarch64" ) ==0 ) { + }else if (strcmp (arch,"aarch64" ) ==0 && tcg_accel_available) {qtest_add_func ("acpi/virt" , test_acpi_virt_tcg);qtest_add_func ("acpi/virt/numamem" , test_acpi_virt_tcg_numamem);qtest_add_func ("acpi/virt/memhp" , test_acpi_virt_tcg_memhp);
Signature · 1 line
2.20.1
Re: [PATCH v16 11/99] qtest/bios-tables-test: Make test build-independent from accelerator
Quoted 7 lines · Alex Bennée
From: Philippe Mathieu-Daudé<[email protected]>
Now that we can probe if the TCG accelerator is available at runtime with a QMP command, do it once at the beginning and only register the tests we can run.
We can then replace the #ifdef'ry by an assertion.
Quoted 8 lines
Reviewed-by Eric Blake<[email protected]>Reviewed-by Igor Mammedov<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Alex Bennée<[email protected]>Message-Id:<[email protected]>
--- tests/qtest/bios-tables-test.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
r~
Re: [PATCH v16 11/99] qtest/bios-tables-test: Make test build-independent from accelerator
In reply to Alex BennéeQuoted 55 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Now that we can probe if the TCG accelerator is available at runtime with a QMP command, do it once at the beginning and only register the tests we can run.
We can then replace the #ifdef'ry by an assertion.Reviewed-by Eric Blake <[email protected]>Reviewed-by Igor Mammedov <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
--- tests/qtest/bios-tables-test.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)tests/qtest/bios-tables-test.c +4
-6@@ -97,6 +97,7 @@ typedef struct {QTestState *qts; } test_data; +static bool tcg_accel_available;static char disk[] ="tests/acpi-test-disk-XXXXXX" ;static const char *data_dir ="tests/data/acpi" ;#ifdef CONFIG_IASL @@ -718,12 +719,7 @@ static void test_acpi_one(const char *params, test_data *data)char *args;bool use_uefi = data->uefi_fl1 && data->uefi_fl2; -#ifndef CONFIG_TCG -if (data->tcg_only) { -g_test_skip ("TCG disabled, skipping ACPI tcg_only test" ); -return ; - } -#endif /* CONFIG_TCG */ +assert (!data->tcg_only || tcg_accel_available); args =test_acpi_create_args (data, params, use_uefi); data->qts =qtest_init (args);@@ -1506,6 +1502,8 @@ int main(int argc, char *argv[])g_test_init (&argc, &argv,NULL ); + tcg_accel_available =qtest_has_accel ("tcg" ); +if (strcmp (arch,"i386" ) ==0 ||strcmp (arch,"x86_64" ) ==0 ) { ret =boot_sector_init (disk);if (ret) {@@ -1554,10 +1552,10 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/microvm/rtc" , test_acpi_microvm_rtc);qtest_add_func ("acpi/microvm/ioapic2" , test_acpi_microvm_ioapic2);
tests/qtest/bios-tables-test.c int main(int argc, char *argv[]) · line 1561
Quoted 10 lines
tests/qtest/bios-tables-test.c +2
-2qtest_add_func ("acpi/microvm/oem-fields" , test_acpi_oem_fields_microvm); -if (strcmp (arch,"x86_64" ) ==0 ) { +if (strcmp (arch,"x86_64" ) ==0 && tcg_accel_available) {qtest_add_func ("acpi/microvm/pcie" , test_acpi_microvm_pcie_tcg); } - }else if (strcmp (arch,"aarch64" ) ==0 ) { + }else if (strcmp (arch,"aarch64" ) ==0 && tcg_accel_available) {qtest_add_func ("acpi/virt" , test_acpi_virt_tcg);qtest_add_func ("acpi/virt/numamem" , test_acpi_virt_tcg_numamem);qtest_add_func ("acpi/virt/memhp" , test_acpi_virt_tcg_memhp);
PATCH v16 12/99 qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore
In reply to Alex BennéeFrom: Philippe Mathieu-Daudé <[email protected]>
Since commit 82bf7ae84ce ("target/arm: Remove KVM support for 32-bit Arm hosts") we can remove the comment / check added in commit ab6b6a77774 and directly run the bios-tables-test.
Message-Id: <[email protected]>
--- tests/qtest/meson.build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tests/qtest/meson.build +1 -2
@@ -176,14 +176,13 @@ qtests_arm = \ 'boot-serial-test', 'hexloader-test'] -# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional qtests_aarch64 = \ - (cpu != 'arm' ? ['bios-tables-test'] : []) + \ (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \ (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \ ['arm-cpu-features', 'numa-test', 'boot-serial-test', + 'bios-tables-test', 'xlnx-can-test', 'migration-test']
Signature · 1 line
2.20.1
Re: [PATCH v16 12/99] qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore
Quoted 11 lines · Alex Bennée
From: Philippe Mathieu-Daudé<[email protected]>
Since commit
82bf7ae84ce("target/arm: Remove KVM support for 32-bit Arm hosts") we can remove the comment / check added in commitab6b6a77774and directly run the bios-tables-test.Reviewed-by Eric Blake<[email protected]>Reviewed-by Alex Bennée<[email protected]>Tested-by Alex Bennée<[email protected]>Signed-off-by Philippe Mathieu-Daudé<[email protected]>Signed-off-by Alex Bennée<[email protected]>
Quoted 4 lines
Message-Id:<[email protected]>
--- tests/qtest/meson.build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
r~
Re: [PATCH v16 12/99] qtest: Do not restrict bios-tables-test to Aarch64 hosts anymore
In reply to Alex BennéeQuoted 27 lines · Alex Bennée
From: Philippe Mathieu-Daudé <[email protected]>
Since commit
82bf7ae84ce("target/arm: Remove KVM support for 32-bit Arm hosts") we can remove the comment / check added in commitab6b6a77774and directly run the bios-tables-test.Reviewed-by Eric Blake <[email protected]>Reviewed-by Alex Bennée <[email protected]>Tested-by Alex Bennée <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Alex Bennée <[email protected]>Message-Id: <[email protected]>
--- tests/qtest/meson.build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)tests/qtest/meson.build +0
-1@@ -176,14 +176,13 @@ qtests_arm = \ 'boot-serial-test', 'hexloader-test'] -# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional qtests_aarch64 = \
tests/qtest/meson.build qtests_arm = \ · line 188
Quoted 10 lines
tests/qtest/meson.build +1
-1- (cpu != 'arm' ? ['bios-tables-test'] : []) + \ (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \ (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \ ['arm-cpu-features', 'numa-test', 'boot-serial-test', + 'bios-tables-test', 'xlnx-can-test', 'migration-test']
PATCH v16 13/99 meson: add target_user_arch
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
the lack of target_user_arch makes it hard to fully leverage the build system in order to separate user code from sysemu code.
Provide it, so that we can avoid the proliferation of #ifdef in target code.
---
v15
- remove duplicate ss.source_set for mips
--- target/alpha/meson.build | 3 +++ target/arm/meson.build | 2 ++ target/cris/meson.build | 3 +++ target/hexagon/meson.build | 3 +++ target/hppa/meson.build | 3 +++ target/m68k/meson.build | 3 +++ target/microblaze/meson.build | 3 +++ target/nios2/meson.build | 3 +++ target/openrisc/meson.build | 3 +++ target/ppc/meson.build | 3 +++ target/riscv/meson.build | 3 +++ target/s390x/meson.build | 3 +++ target/sh4/meson.build | 3 +++ target/sparc/meson.build | 3 +++ target/tricore/meson.build | 3 +++ target/xtensa/meson.build | 3 +++ 16 files changed, 47 insertions(+)
target/alpha/meson.build +3 -0
@@ -14,5 +14,8 @@ alpha_ss.add(files( alpha_softmmu_ss = ss.source_set() alpha_softmmu_ss.add(files('machine.c')) +alpha_user_ss = ss.source_set() + target_arch += {'alpha': alpha_ss} target_softmmu_arch += {'alpha': alpha_softmmu_ss} +target_user_arch += {'alpha': alpha_user_ss}
target/arm/meson.build +2 -0
@@ -56,6 +56,8 @@ arm_softmmu_ss.add(files( 'monitor.c', 'psci.c', )) +arm_user_ss = ss.source_set() target_arch += {'arm': arm_ss} target_softmmu_arch += {'arm': arm_softmmu_ss} +target_user_arch += {'arm': arm_user_ss}
target/cris/meson.build +3 -0
@@ -10,5 +10,8 @@ cris_ss.add(files( cris_softmmu_ss = ss.source_set() cris_softmmu_ss.add(files('mmu.c', 'machine.c')) +cris_user_ss = ss.source_set() + target_arch += {'cris': cris_ss} target_softmmu_arch += {'cris': cris_softmmu_ss} +target_user_arch += {'cris': cris_user_ss}
target/hexagon/meson.build +3 -0
@@ -175,4 +175,7 @@ hexagon_ss.add(files( 'fma_emu.c', )) +hexagon_user_ss = ss.source_set() + target_arch += {'hexagon': hexagon_ss} +target_user_arch += {'hexagon': hexagon_user_ss}
target/hppa/meson.build +3 -0
@@ -15,5 +15,8 @@ hppa_ss.add(files( hppa_softmmu_ss = ss.source_set() hppa_softmmu_ss.add(files('machine.c')) +hppa_user_ss = ss.source_set() + target_arch += {'hppa': hppa_ss} target_softmmu_arch += {'hppa': hppa_softmmu_ss} +target_user_arch += {'hppa': hppa_user_ss}
target/m68k/meson.build +3 -0
@@ -13,5 +13,8 @@ m68k_ss.add(files( m68k_softmmu_ss = ss.source_set() m68k_softmmu_ss.add(files('monitor.c')) +m68k_user_ss = ss.source_set() + target_arch += {'m68k': m68k_ss} target_softmmu_arch += {'m68k': m68k_softmmu_ss} +target_user_arch += {'m68k': m68k_user_ss}
target/microblaze/meson.build +3 -0
@@ -16,5 +16,8 @@ microblaze_softmmu_ss.add(files( 'machine.c', )) +microblaze_user_ss = ss.source_set() + target_arch += {'microblaze': microblaze_ss} target_softmmu_arch += {'microblaze': microblaze_softmmu_ss} +target_user_arch += {'microblaze': microblaze_user_ss}
target/nios2/meson.build +3 -0
@@ -11,5 +11,8 @@ nios2_ss.add(files( nios2_softmmu_ss = ss.source_set() nios2_softmmu_ss.add(files('monitor.c')) +nios2_user_ss = ss.source_set() + target_arch += {'nios2': nios2_ss} target_softmmu_arch += {'nios2': nios2_softmmu_ss} +target_user_arch += {'nios2': nios2_user_ss}
target/openrisc/meson.build +3 -0
@@ -19,5 +19,8 @@ openrisc_ss.add(files( openrisc_softmmu_ss = ss.source_set() openrisc_softmmu_ss.add(files('machine.c')) +openrisc_user_ss = ss.source_set() + target_arch += {'openrisc': openrisc_ss} target_softmmu_arch += {'openrisc': openrisc_softmmu_ss} +target_user_arch += {'openrisc': openrisc_user_ss}
target/ppc/meson.build +3 -0
@@ -51,5 +51,8 @@ ppc_softmmu_ss.add(when: 'TARGET_PPC64', if_true: files( 'mmu-radix64.c', )) +ppc_user_ss = ss.source_set() + target_arch += {'ppc': ppc_ss} target_softmmu_arch += {'ppc': ppc_softmmu_ss} +target_user_arch += {'ppc': ppc_user_ss}
target/riscv/meson.build +3 -0
@@ -27,5 +27,8 @@ riscv_softmmu_ss.add(files( 'machine.c' )) +riscv_user_ss = ss.source_set() + target_arch += {'riscv': riscv_ss} target_softmmu_arch += {'riscv': riscv_softmmu_ss} +target_user_arch += {'riscv': riscv_user_ss}
target/s390x/meson.build +3 -0
@@ -58,5 +58,8 @@ if host_machine.cpu_family() == 's390x' and cc.has_link_argument('-Wl,--s390-pgs if_true: declare_dependency(link_args: ['-Wl,--s390-pgste'])) endif +s390x_user_ss = ss.source_set() + target_arch += {'s390x': s390x_ss} target_softmmu_arch += {'s390x': s390x_softmmu_ss} +target_user_arch += {'s390x': s390x_user_ss}
target/sh4/meson.build +3 -0
@@ -10,5 +10,8 @@ sh4_ss.add(files( sh4_softmmu_ss = ss.source_set() sh4_softmmu_ss.add(files('monitor.c')) +sh4_user_ss = ss.source_set() + target_arch += {'sh4': sh4_ss} target_softmmu_arch += {'sh4': sh4_softmmu_ss} +target_user_arch += {'sh4': sh4_user_ss}
target/sparc/meson.build +3 -0
@@ -19,5 +19,8 @@ sparc_softmmu_ss.add(files( 'monitor.c', )) +sparc_user_ss = ss.source_set() + target_arch += {'sparc': sparc_ss} target_softmmu_arch += {'sparc': sparc_softmmu_ss} +target_user_arch += {'sparc': sparc_user_ss}
target/tricore/meson.build +3 -0
@@ -11,5 +11,8 @@ tricore_ss.add(zlib) tricore_softmmu_ss = ss.source_set() +tricore_user_ss = ss.source_set() + target_arch += {'tricore': tricore_ss} target_softmmu_arch += {'tricore': tricore_softmmu_ss} +target_user_arch += {'tricore': tricore_user_ss}
target/xtensa/meson.build +3 -0
@@ -23,5 +23,8 @@ xtensa_softmmu_ss.add(files( 'xtensa-semi.c', )) +xtensa_user_ss = ss.source_set() + target_arch += {'xtensa': xtensa_ss} target_softmmu_arch += {'xtensa': xtensa_softmmu_ss} +target_user_arch += {'xtensa': xtensa_user_ss}
Signature · 1 line
2.20.1
Re: [PATCH v16 13/99] meson: add target_user_arch
Quoted 14 lines · Alex Bennée
From: Claudio Fontana <[email protected]>
the lack of
target_user_archmakes it hard to fully leverage the build system in order to separate user code from sysemu code.Provide it, so that we can avoid the proliferation of #ifdef in target code.
Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Alex Bennée <[email protected]>[claudio: added changes for new target hexagon]Signed-off-by Claudio Fontana <[email protected]>Signed-off-by Alex Bennée <[email protected]>
Quoted 3 lines
---
v15
- remove duplicate ss.source_set for mips
Either add it only on target/arm/, or on every targets but then revert 46369b50ee3 ("meson: Introduce meson_user_arch source set for arch-specific user-mode")?
PATCH v16 14/99 accel: add cpu_reset
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
in cpu_reset(), implemented in the common cpu.c,
add a call to a new accel_cpu_reset(), which ensures that the CPU accel interface is also reset when the CPU is reset.
Use this first for x86/kvm, simply moving the kvm_arch_reset_vcpu() call.
--- include/hw/core/accel-cpu.h | 2 ++ include/qemu/accel.h | 6 ++++++ accel/accel-common.c | 9 +++++++++ hw/core/cpu-common.c | 3 ++- target/i386/cpu.c | 4 ---- target/i386/kvm/kvm-cpu.c | 6 ++++++ 6 files changed, 25 insertions(+), 5 deletions(-)
include/hw/core/accel-cpu.h +2 -0
@@ -33,6 +33,8 @@ typedef struct AccelCPUClass {void (*cpu_class_init)(CPUClass *cc);void (*cpu_instance_init)(CPUState *cpu);bool (*cpu_realizefn)(CPUState *cpu,Error **errp); + void (*cpu_reset)(CPUState *cpu); + } AccelCPUClass;#endif /* ACCEL_CPU_H */
include/qemu/accel.h +6 -0
@@ -91,4 +91,10 @@ void accel_cpu_instance_init(CPUState *cpu);*/ bool accel_cpu_realizefn (CPUState *cpu,Error **errp); +/** +* accel_cpu_reset: +* @cpu: The CPU that needs to call accel-specific reset. +*/ +void accel_cpu_reset (CPUState *cpu); +#endif /* QEMU_ACCEL_H */
accel/accel-common.c +9 -0
@@ -121,6 +121,15 @@ bool accel_cpu_realizefn(CPUState *cpu, Error **errp)return true; } +void accel_cpu_reset (CPUState *cpu) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); + +if (cc->accel_cpu && cc->accel_cpu->cpu_reset) { + cc->accel_cpu->cpu_reset (cpu); + } +} +static const TypeInfo accel_cpu_type = { .name =TYPE_ACCEL_CPU , .parent =TYPE_OBJECT ,
hw/core/cpu-common.c +2 -1
@@ -34,6 +34,7 @@#include "hw/qdev-properties.h" #include "trace/trace-root.h" #include "qemu/plugin.h" +#include "qemu/accel.h" CPUState *cpu_by_arch_id (int64_t id) {
@@ -112,7 +113,7 @@ void cpu_dump_state(CPUState *cpu, FILE *f, int flags)void cpu_reset (CPUState *cpu) {device_cold_reset (DEVICE (cpu)); - +accel_cpu_reset (cpu);trace_guest_cpu_reset (cpu); }
target/i386/cpu.c +0 -4
@@ -5749,10 +5749,6 @@ static void x86_cpu_reset(DeviceState *dev)apic_designate_bsp (cpu->apic_state, s->cpu_index ==0 ); s->halted = !cpu_is_bsp (cpu); - -if (kvm_enabled ()) { -kvm_arch_reset_vcpu (cpu); - }#endif }
target/i386/kvm/kvm-cpu.c +6 -0
@@ -135,12 +135,18 @@ static void kvm_cpu_instance_init(CPUState *cs) } } +static void kvm_cpu_reset (CPUState *cpu) +{ +kvm_arch_reset_vcpu (X86_CPU (cpu)); +} +static void kvm_cpu_accel_class_init (ObjectClass *oc,void *data) {AccelCPUClass *acc =ACCEL_CPU_CLASS (oc); acc->cpu_realizefn = kvm_cpu_realizefn; acc->cpu_instance_init = kvm_cpu_instance_init; + acc->cpu_reset = kvm_cpu_reset; }static const TypeInfo kvm_cpu_accel_type_info = { .name =ACCEL_CPU_NAME ("kvm" ),
Signature · 1 line
2.20.1
Re: [PATCH v16 14/99] accel: add cpu_reset
Quoted 10 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
in
cpu_reset(), implemented in the commoncpu.c,
add a call to a newaccel_cpu_reset(), which ensures that the CPU accel interface is also reset when the CPU is reset.Use this first for x86/kvm, simply moving the
kvm_arch_reset_vcpu()call.Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>
Quoted 8 lines
--- include/hw/core/accel-cpu.h | 2 ++ include/qemu/accel.h | 6 ++++++ accel/accel-common.c | 9 +++++++++ hw/core/cpu-common.c | 3 ++- target/i386/cpu.c | 4 ---- target/i386/kvm/kvm-cpu.c | 6 ++++++ 6 files changed, 25 insertions(+), 5 deletions(-)
r~
PATCH v16 15/99 target/arm: move translate modules to tcg/
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
---
target/arm/{ => tcg}/translate-a64.h | 0
target/arm/{ => tcg}/translate.h | 0
target/arm/{ => tcg}/a32-uncond.decode | 0
target/arm/{ => tcg}/a32.decode | 0
target/arm/{ => tcg}/m-nocp.decode | 0
target/arm/{ => tcg}/neon-dp.decode | 0
target/arm/{ => tcg}/neon-ls.decode | 0
target/arm/{ => tcg}/neon-shared.decode | 0
target/arm/{ => tcg}/sve.decode | 0
target/arm/{ => tcg}/t16.decode | 0
target/arm/{ => tcg}/t32.decode | 0
target/arm/{ => tcg}/vfp-uncond.decode | 0
target/arm/{ => tcg}/vfp.decode | 0
target/arm/{ => tcg}/translate-a64.c | 0
target/arm/{ => tcg}/translate-m-nocp.c | 0
target/arm/{ => tcg}/translate-neon.c | 0
target/arm/{ => tcg}/translate-sve.c | 0
target/arm/{ => tcg}/translate-vfp.c | 0
target/arm/{ => tcg}/translate.c | 0
target/arm/meson.build | 23 ++-------------------
target/arm/tcg/meson.build | 27 +++++++++++++++++++++++++
21 files changed, 29 insertions(+), 21 deletions(-)
rename target/arm/{ => tcg}/translate-a64.h (100%)
rename target/arm/{ => tcg}/translate.h (100%)
rename target/arm/{ => tcg}/a32-uncond.decode (100%)
rename target/arm/{ => tcg}/a32.decode (100%)
rename target/arm/{ => tcg}/m-nocp.decode (100%)
rename target/arm/{ => tcg}/neon-dp.decode (100%)
rename target/arm/{ => tcg}/neon-ls.decode (100%)
rename target/arm/{ => tcg}/neon-shared.decode (100%)
rename target/arm/{ => tcg}/sve.decode (100%)
rename target/arm/{ => tcg}/t16.decode (100%)
rename target/arm/{ => tcg}/t32.decode (100%)
rename target/arm/{ => tcg}/vfp-uncond.decode (100%)
rename target/arm/{ => tcg}/vfp.decode (100%)
rename target/arm/{ => tcg}/translate-a64.c (100%)
rename target/arm/{ => tcg}/translate-m-nocp.c (100%)
rename target/arm/{ => tcg}/translate-neon.c (100%)
rename target/arm/{ => tcg}/translate-sve.c (100%)
rename target/arm/{ => tcg}/translate-vfp.c (100%)
rename target/arm/{ => tcg}/translate.c (100%)
create mode 100644 target/arm/tcg/meson.buildtarget/arm/tcg/translate-a64.h renamed from target/arm/translate-a64.h +0 -0
target/arm/tcg/translate.h renamed from target/arm/translate.h +0 -0
target/arm/tcg/a32-uncond.decode renamed from target/arm/a32-uncond.decode +0 -0
target/arm/tcg/a32.decode renamed from target/arm/a32.decode +0 -0
target/arm/tcg/m-nocp.decode renamed from target/arm/m-nocp.decode +0 -0
target/arm/tcg/neon-dp.decode renamed from target/arm/neon-dp.decode +0 -0
target/arm/tcg/neon-ls.decode renamed from target/arm/neon-ls.decode +0 -0
target/arm/tcg/neon-shared.decode renamed from target/arm/neon-shared.decode +0 -0
target/arm/tcg/sve.decode renamed from target/arm/sve.decode +0 -0
target/arm/tcg/t16.decode renamed from target/arm/t16.decode +0 -0
target/arm/tcg/t32.decode renamed from target/arm/t32.decode +0 -0
target/arm/tcg/vfp-uncond.decode renamed from target/arm/vfp-uncond.decode +0 -0
target/arm/tcg/vfp.decode renamed from target/arm/vfp.decode +0 -0
target/arm/tcg/translate-a64.c renamed from target/arm/translate-a64.c +0 -0
target/arm/tcg/translate-m-nocp.c renamed from target/arm/translate-m-nocp.c +0 -0
target/arm/tcg/translate-neon.c renamed from target/arm/translate-neon.c +0 -0
target/arm/tcg/translate-sve.c renamed from target/arm/translate-sve.c +0 -0
target/arm/tcg/translate-vfp.c renamed from target/arm/translate-vfp.c +0 -0
target/arm/tcg/translate.c renamed from target/arm/translate.c +0 -0
target/arm/meson.build +2 -21
@@ -1,19 +1,4 @@ -gen = [ - decodetree.process('sve.decode', extra_args: '--decode=disas_sve'), - decodetree.process('neon-shared.decode', extra_args: '--decode=disas_neon_shared'), - decodetree.process('neon-dp.decode', extra_args: '--decode=disas_neon_dp'), - decodetree.process('neon-ls.decode', extra_args: '--decode=disas_neon_ls'), - decodetree.process('vfp.decode', extra_args: '--decode=disas_vfp'), - decodetree.process('vfp-uncond.decode', extra_args: '--decode=disas_vfp_uncond'), - decodetree.process('m-nocp.decode', extra_args: '--decode=disas_m_nocp'), - decodetree.process('a32.decode', extra_args: '--static-decode=disas_a32'), - decodetree.process('a32-uncond.decode', extra_args: '--static-decode=disas_a32_uncond'), - decodetree.process('t32.decode', extra_args: '--static-decode=disas_t32'), - decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-decode=disas_t16']), -] - arm_ss = ss.source_set() -arm_ss.add(gen) arm_ss.add(files( 'cpu.c', 'crypto_helper.c',
@@ -25,10 +10,6 @@ arm_ss.add(files( 'neon_helper.c', 'op_helper.c', 'tlb_helper.c', - 'translate.c', - 'translate-m-nocp.c', - 'translate-neon.c', - 'translate-vfp.c', 'vec_helper.c', 'vfp_helper.c', 'cpu_tcg.c',
@@ -44,8 +25,6 @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'mte_helper.c', 'pauth_helper.c', 'sve_helper.c', - 'translate-a64.c', - 'translate-sve.c', )) arm_softmmu_ss = ss.source_set()
@@ -58,6 +37,8 @@ arm_softmmu_ss.add(files( )) arm_user_ss = ss.source_set() +subdir('tcg') + target_arch += {'arm': arm_ss} target_softmmu_arch += {'arm': arm_softmmu_ss} target_user_arch += {'arm': arm_user_ss}
target/arm/tcg/meson.build new file +27 -0
@@ -0,0 +1,27 @@ +gen = [ + decodetree.process('sve.decode', extra_args: '--decode=disas_sve'), + decodetree.process('neon-shared.decode', extra_args: '--decode=disas_neon_shared'), + decodetree.process('neon-dp.decode', extra_args: '--decode=disas_neon_dp'), + decodetree.process('neon-ls.decode', extra_args: '--decode=disas_neon_ls'), + decodetree.process('vfp.decode', extra_args: '--decode=disas_vfp'), + decodetree.process('vfp-uncond.decode', extra_args: '--decode=disas_vfp_uncond'), + decodetree.process('m-nocp.decode', extra_args: '--decode=disas_m_nocp'), + decodetree.process('a32.decode', extra_args: '--static-decode=disas_a32'), + decodetree.process('a32-uncond.decode', extra_args: '--static-decode=disas_a32_uncond'), + decodetree.process('t32.decode', extra_args: '--static-decode=disas_t32'), + decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-decode=disas_t16']), +] + +arm_ss.add(gen) + +arm_ss.add(files( + 'translate.c', + 'translate-m-nocp.c', + 'translate-neon.c', + 'translate-vfp.c', +)) + +arm_ss.add(when: 'TARGET_AARCH64', if_true: files( + 'translate-a64.c', + 'translate-sve.c', +))
Signature · 1 line
2.20.1
PATCH v16 16/99 target/arm: move helpers to tcg/
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
---
meson.build | 1 +
target/arm/{ => tcg}/op_addsub.h | 0
target/arm/tcg/trace.h | 1 +
target/arm/{ => tcg}/vec_internal.h | 0
target/arm/{ => tcg}/crypto_helper.c | 0
target/arm/{ => tcg}/debug_helper.c | 0
target/arm/{ => tcg}/helper-a64.c | 0
target/arm/{ => tcg}/helper.c | 0
target/arm/{ => tcg}/iwmmxt_helper.c | 0
target/arm/{ => tcg}/m_helper.c | 0
target/arm/{ => tcg}/mte_helper.c | 0
target/arm/{ => tcg}/neon_helper.c | 0
target/arm/{ => tcg}/op_helper.c | 0
target/arm/{ => tcg}/pauth_helper.c | 0
target/arm/{ => tcg}/sve_helper.c | 0
target/arm/{ => tcg}/tlb_helper.c | 0
target/arm/{ => tcg}/vec_helper.c | 0
target/arm/{ => tcg}/vfp_helper.c | 0
target/arm/meson.build | 14 --------------
target/arm/tcg/meson.build | 14 ++++++++++++++
target/arm/tcg/trace-events | 10 ++++++++++
target/arm/trace-events | 9 ---------
22 files changed, 26 insertions(+), 23 deletions(-)
rename target/arm/{ => tcg}/op_addsub.h (100%)
create mode 100644 target/arm/tcg/trace.h
rename target/arm/{ => tcg}/vec_internal.h (100%)
rename target/arm/{ => tcg}/crypto_helper.c (100%)
rename target/arm/{ => tcg}/debug_helper.c (100%)
rename target/arm/{ => tcg}/helper-a64.c (100%)
rename target/arm/{ => tcg}/helper.c (100%)
rename target/arm/{ => tcg}/iwmmxt_helper.c (100%)
rename target/arm/{ => tcg}/m_helper.c (100%)
rename target/arm/{ => tcg}/mte_helper.c (100%)
rename target/arm/{ => tcg}/neon_helper.c (100%)
rename target/arm/{ => tcg}/op_helper.c (100%)
rename target/arm/{ => tcg}/pauth_helper.c (100%)
rename target/arm/{ => tcg}/sve_helper.c (100%)
rename target/arm/{ => tcg}/tlb_helper.c (100%)
rename target/arm/{ => tcg}/vec_helper.c (100%)
rename target/arm/{ => tcg}/vfp_helper.c (100%)
create mode 100644 target/arm/tcg/trace-eventsmeson.build +1 -0
@@ -1860,6 +1860,7 @@ if have_system or have_user 'accel/tcg', 'hw/core', 'target/arm', + 'target/arm/tcg', 'target/hppa', 'target/i386', 'target/i386/kvm',
target/arm/tcg/op_addsub.h renamed from target/arm/op_addsub.h +0 -0
target/arm/tcg/trace.h new file +1 -0
@@ -0,0 +1 @@ +#include "trace/trace-target_arm_tcg.h"
target/arm/tcg/vec_internal.h renamed from target/arm/vec_internal.h +0 -0
target/arm/tcg/crypto_helper.c renamed from target/arm/crypto_helper.c +0 -0
target/arm/tcg/debug_helper.c renamed from target/arm/debug_helper.c +0 -0
target/arm/tcg/helper-a64.c renamed from target/arm/helper-a64.c +0 -0
target/arm/tcg/helper.c renamed from target/arm/helper.c +0 -0
target/arm/tcg/iwmmxt_helper.c renamed from target/arm/iwmmxt_helper.c +0 -0
target/arm/tcg/m_helper.c renamed from target/arm/m_helper.c +0 -0
target/arm/tcg/mte_helper.c renamed from target/arm/mte_helper.c +0 -0
target/arm/tcg/neon_helper.c renamed from target/arm/neon_helper.c +0 -0
target/arm/tcg/op_helper.c renamed from target/arm/op_helper.c +0 -0
target/arm/tcg/pauth_helper.c renamed from target/arm/pauth_helper.c +0 -0
target/arm/tcg/sve_helper.c renamed from target/arm/sve_helper.c +0 -0
target/arm/tcg/tlb_helper.c renamed from target/arm/tlb_helper.c +0 -0
target/arm/tcg/vec_helper.c renamed from target/arm/vec_helper.c +0 -0
target/arm/tcg/vfp_helper.c renamed from target/arm/vfp_helper.c +0 -0
target/arm/meson.build +0 -14
@@ -1,17 +1,7 @@ arm_ss = ss.source_set() arm_ss.add(files( 'cpu.c', - 'crypto_helper.c', - 'debug_helper.c', 'gdbstub.c', - 'helper.c', - 'iwmmxt_helper.c', - 'm_helper.c', - 'neon_helper.c', - 'op_helper.c', - 'tlb_helper.c', - 'vec_helper.c', - 'vfp_helper.c', 'cpu_tcg.c', )) arm_ss.add(zlib)
@@ -21,10 +11,6 @@ arm_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c', 'kvm64.c'), if_false: fil arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'cpu64.c', 'gdbstub64.c', - 'helper-a64.c', - 'mte_helper.c', - 'pauth_helper.c', - 'sve_helper.c', )) arm_softmmu_ss = ss.source_set()
target/arm/tcg/meson.build +14 -0
@@ -19,9 +19,23 @@ arm_ss.add(files( 'translate-m-nocp.c', 'translate-neon.c', 'translate-vfp.c', + 'helper.c', + 'iwmmxt_helper.c', + 'm_helper.c', + 'neon_helper.c', + 'op_helper.c', + 'tlb_helper.c', + 'vec_helper.c', + 'vfp_helper.c', + 'crypto_helper.c', + 'debug_helper.c', )) arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'translate-a64.c', 'translate-sve.c', + 'helper-a64.c', + 'mte_helper.c', + 'pauth_helper.c', + 'sve_helper.c', ))
target/arm/tcg/trace-events new file +10 -0
@@ -0,0 +1,10 @@ +# See docs/devel/tracing.txt for syntax documentation. + +# helper.c +arm_gt_recalc(int timer, int irqstate, uint64_t nexttick) "gt recalc: timer %d irqstate %d next tick 0x%" PRIx64 +arm_gt_recalc_disabled(int timer) "gt recalc: timer %d irqstate 0 timer disabled" +arm_gt_cval_write(int timer, uint64_t value) "gt_cval_write: timer %d value 0x%" PRIx64 +arm_gt_tval_write(int timer, uint64_t value) "gt_tval_write: timer %d value 0x%" PRIx64 +arm_gt_ctl_write(int timer, uint64_t value) "gt_ctl_write: timer %d value 0x%" PRIx64 +arm_gt_imask_toggle(int timer, int irqstate) "gt_ctl_write: timer %d IMASK toggle, new irqstate %d" +arm_gt_cntvoff_write(uint64_t value) "gt_cntvoff_write: value 0x%" PRIx64
target/arm/trace-events +0 -9
@@ -1,13 +1,4 @@ # See docs/devel/tracing.rst for syntax documentation. -# helper.c -arm_gt_recalc(int timer, int irqstate, uint64_t nexttick) "gt recalc: timer %d irqstate %d next tick 0x%" PRIx64 -arm_gt_recalc_disabled(int timer) "gt recalc: timer %d irqstate 0 timer disabled" -arm_gt_cval_write(int timer, uint64_t value) "gt_cval_write: timer %d value 0x%" PRIx64 -arm_gt_tval_write(int timer, uint64_t value) "gt_tval_write: timer %d value 0x%" PRIx64 -arm_gt_ctl_write(int timer, uint64_t value) "gt_ctl_write: timer %d value 0x%" PRIx64 -arm_gt_imask_toggle(int timer, int irqstate) "gt_ctl_write: timer %d IMASK toggle, new irqstate %d" -arm_gt_cntvoff_write(uint64_t value) "gt_cntvoff_write: value 0x%" PRIx64 - # kvm.c kvm_arm_fixup_msi_route(uint64_t iova, uint64_t gpa) "MSI iova = 0x%"PRIx64" is translated into 0x%"PRIx64
Signature · 1 line
2.20.1
PATCH v16 17/99 arm: tcg: only build under CONFIG_TCG
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
--- target/arm/tcg/meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/arm/tcg/meson.build +3 -3
@@ -12,9 +12,9 @@ gen = [ decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-decode=disas_t16']), ] -arm_ss.add(gen) +arm_ss.add(when: 'CONFIG_TCG', if_true: gen) -arm_ss.add(files( +arm_ss.add(when: 'CONFIG_TCG', if_true: files( 'translate.c', 'translate-m-nocp.c', 'translate-neon.c',
@@ -31,7 +31,7 @@ arm_ss.add(files( 'debug_helper.c', )) -arm_ss.add(when: 'TARGET_AARCH64', if_true: files( +arm_ss.add(when: ['TARGET_AARCH64','CONFIG_TCG'], if_true: files( 'translate-a64.c', 'translate-sve.c', 'helper-a64.c',
Signature · 1 line
2.20.1
PATCH v16 18/99 target/arm: tcg: add sysemu and user subdirs
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
--- target/arm/tcg/meson.build | 3 +++ target/arm/tcg/sysemu/meson.build | 2 ++ target/arm/tcg/user/meson.build | 2 ++ 3 files changed, 7 insertions(+) create mode 100644 target/arm/tcg/sysemu/meson.build create mode 100644 target/arm/tcg/user/meson.build
target/arm/tcg/meson.build +3 -0
@@ -39,3 +39,6 @@ arm_ss.add(when: ['TARGET_AARCH64','CONFIG_TCG'], if_true: files( 'pauth_helper.c', 'sve_helper.c', )) + +subdir('user') +subdir('sysemu')
target/arm/tcg/sysemu/meson.build new file +2 -0
@@ -0,0 +1,2 @@ +arm_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( +))
target/arm/tcg/user/meson.build new file +2 -0
@@ -0,0 +1,2 @@ +arm_user_ss.add(when: 'CONFIG_TCG', if_true: files( +))
Signature · 1 line
2.20.1
PATCH v16 19/99 target/arm: tcg: split mte_helper user-only and sysemu code
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
allocation_tag_mem has a different implementation for user-only and sysemu, so move the two implementations into the dedicated subdirs.
--- target/arm/tcg/mte_helper.h | 53 ++++++++ target/arm/tcg/mte_helper.c | 191 +---------------------------- target/arm/tcg/sysemu/mte_helper.c | 159 ++++++++++++++++++++++++ target/arm/tcg/user/mte_helper.c | 57 +++++++++ target/arm/tcg/sysemu/meson.build | 1 + target/arm/tcg/user/meson.build | 1 + 6 files changed, 272 insertions(+), 190 deletions(-) create mode 100644 target/arm/tcg/mte_helper.h create mode 100644 target/arm/tcg/sysemu/mte_helper.c create mode 100644 target/arm/tcg/user/mte_helper.c
target/arm/tcg/mte_helper.h new file +53 -0
@@ -0,0 +1,53 @@ +/* +* ARM v8.5-MemTag Operations +* +* Copyright (c) 2020 Linaro, Ltd. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef MTE_HELPER_H +#define MTE_HELPER_H + +/** +* allocation_tag_mem: +* @env: the cpu environment +* @ptr_mmu_idx: the addressing regime to use for the virtual address +* @ptr: the virtual address for which to look up tag memory +* @ptr_access: the access to use for the virtual address +* @ptr_size: the number of bytes in the normal memory access +* @tag_access: the access to use for the tag memory +* @tag_size: the number of bytes in the tag memory access +* @ra: the return address for exception handling +* +* Our tag memory is formatted as a sequence of little-endian nibbles. +* That is, the byte at (addr >> (LOG2_TAG_GRANULE + 1)) contains two +* tags, with the tag at [3:0] for the lower addr and the tag at [7:4] +* for the higher addr. +* +* Here, resolve the physical address from the virtual address, and return +* a pointer to the corresponding tag byte. Exit with exception if the +* virtual address is not accessible for @ptr_access. +* +* The @ptr_size and @tag_size values may not have an obvious relation +* due to the alignment of @ptr, and the number of tag checks required. +* +* If there is no tag storage corresponding to @ptr, return NULL. +*/ +uint8_t *allocation_tag_mem (CPUARMState *env,int ptr_mmu_idx, +uint64_t ptr,MMUAccessType ptr_access, +int ptr_size,MMUAccessType tag_access, +int tag_size,uintptr_t ra); + +#endif /* MTE_HELPER_H */
target/arm/tcg/mte_helper.c +1 -190
203 lines not on this page · raw message
target/arm/tcg/sysemu/mte_helper.c new file +159 -0
159 lines not on this page · raw message
target/arm/tcg/user/mte_helper.c new file +57 -0
57 lines not on this page · raw message
target/arm/tcg/sysemu/meson.build +1 -0
@@ -1,2 +1,3 @@ arm_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( + 'mte_helper.c', ))
target/arm/tcg/user/meson.build +1 -0
@@ -1,2 +1,3 @@ arm_user_ss.add(when: 'CONFIG_TCG', if_true: files( + 'mte_helper.c', ))
Signature · 1 line
2.20.1
PATCH v16 20/99 target/arm: tcg: move sysemu-only parts of debug_helper
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
move sysemu-only parts of debug_helper to sysemu/
--- target/arm/tcg/debug_helper.c | 27 ----------------------- target/arm/tcg/sysemu/debug_helper.c | 33 ++++++++++++++++++++++++++++ target/arm/tcg/sysemu/meson.build | 1 + 3 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 target/arm/tcg/sysemu/debug_helper.c
target/arm/tcg/debug_helper.c +0 -27
@@ -308,30 +308,3 @@ void arm_debug_excp_handler(CPUState *cs) arm_debug_target_el(env)); } } - -#if !defined(CONFIG_USER_ONLY ) - -vaddr arm_adjust_watchpoint_address (CPUState *cs,vaddr addr,int len) -{ -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; - -/* -* In BE32 system mode, target memory is stored byteswapped (on a -* little-endian host system), and by the time we reach here (via an -* opcode helper) the addresses of subword accesses have been adjusted -* to account for that, which means that watchpoints will not match. -* Undo the adjustment here. -*/ -if (arm_sctlr_b (env)) { -if (len ==1 ) { - addr ^=3 ; - }else if (len ==2 ) { - addr ^=2 ; - } - } - -return addr; -} - -#endif
target/arm/tcg/sysemu/debug_helper.c new file +33 -0
@@ -0,0 +1,33 @@ +/* +* ARM debug helpers. +* +* This code is licensed under the GNU GPL v2 or later. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#include "qemu/osdep.h" +#include "cpu.h" +#include "internals.h" + +vaddr arm_adjust_watchpoint_address (CPUState *cs,vaddr addr,int len) +{ +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; + +/* +* In BE32 system mode, target memory is stored byteswapped (on a +* little-endian host system), and by the time we reach here (via an +* opcode helper) the addresses of subword accesses have been adjusted +* to account for that, which means that watchpoints will not match. +* Undo the adjustment here. +*/ +if (arm_sctlr_b (env)) { +if (len ==1 ) { + addr ^=3 ; + }else if (len ==2 ) { + addr ^=2 ; + } + } + +return addr; +}
target/arm/tcg/sysemu/meson.build +1 -0
@@ -1,3 +1,4 @@ arm_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( + 'debug_helper.c', 'mte_helper.c', ))
Signature · 1 line
2.20.1
PATCH v16 21/99 target/arm: tcg: split tlb_helper user-only and sysemu-only parts
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
--- target/arm/tcg/tlb_helper.h | 17 ++++++ target/arm/tcg/sysemu/tlb_helper.c | 83 +++++++++++++++++++++++++ target/arm/tcg/tlb_helper.c | 97 ++---------------------------- target/arm/tcg/user/tlb_helper.c | 32 ++++++++++ target/arm/tcg/sysemu/meson.build | 1 + target/arm/tcg/user/meson.build | 1 + 6 files changed, 138 insertions(+), 93 deletions(-) create mode 100644 target/arm/tcg/tlb_helper.h create mode 100644 target/arm/tcg/sysemu/tlb_helper.c create mode 100644 target/arm/tcg/user/tlb_helper.c
target/arm/tcg/tlb_helper.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* ARM TLB (Translation lookaside buffer) helpers. +* +* This code is licensed under the GNU GPL v2 or later. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#ifndef TLB_HELPER_H +#define TLB_HELPER_H + +#include "cpu.h" + +void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, +MMUAccessType access_type, +int mmu_idx,ARMMMUFaultInfo *fi); + +#endif /* TLB_HELPER_H */
target/arm/tcg/sysemu/tlb_helper.c new file +83 -0
83 lines not on this page · raw message
target/arm/tcg/tlb_helper.c +4 -93
112 lines not on this page · raw message
target/arm/tcg/user/tlb_helper.c new file +32 -0
@@ -0,0 +1,32 @@ +/* +* ARM TLB (Translation lookaside buffer) helpers. +* +* This code is licensed under the GNU GPL v2 or later. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ +#include "qemu/osdep.h" +#include "cpu.h" +#include "internals.h" +#include "exec/exec-all.h" +#include "tcg/tlb_helper.h" + +bool arm_cpu_tlb_fill (CPUState *cs,vaddr address,int size, +MMUAccessType access_type,int mmu_idx, +bool probe,uintptr_t retaddr) +{ +ARMCPU *cpu =ARM_CPU (cs); +ARMMMUFaultInfo fi = {}; + +int flags =page_get_flags (useronly_clean_ptr (address)); +if (flags &PAGE_VALID ) { + fi.type = ARMFault_Permission; + }else { + fi.type = ARMFault_Translation; + } + fi.level =3 ; + +/* now we have a real cpu fault */ +cpu_restore_state (cs, retaddr, true); +arm_deliver_fault (cpu, address, access_type, mmu_idx, &fi); +}
target/arm/tcg/sysemu/meson.build +1 -0
@@ -1,4 +1,5 @@ arm_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( 'debug_helper.c', 'mte_helper.c', + 'tlb_helper.c', ))
target/arm/tcg/user/meson.build +1 -0
@@ -1,3 +1,4 @@ arm_user_ss.add(when: 'CONFIG_TCG', if_true: files( 'mte_helper.c', + 'tlb_helper.c', ))
Signature · 1 line
2.20.1
PATCH v16 22/99 target/arm: tcg: split m_helper user-only and sysemu-only parts
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
in the process remove a few CONFIG_TCG that are superfluous now.
--- target/arm/tcg/m_helper.h | 21 + target/arm/tcg/m_helper.c | 2767 +---------------------------- target/arm/tcg/sysemu/m_helper.c | 2655 +++++++++++++++++++++++++++ target/arm/tcg/user/m_helper.c | 97 + target/arm/tcg/sysemu/meson.build | 1 + target/arm/tcg/user/meson.build | 1 + 6 files changed, 2780 insertions(+), 2762 deletions(-) create mode 100644 target/arm/tcg/m_helper.h create mode 100644 target/arm/tcg/sysemu/m_helper.c create mode 100644 target/arm/tcg/user/m_helper.c
target/arm/tcg/m_helper.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* ARM v7m generic helpers. +* +* This code is licensed under the GNU GPL v2 or later. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef M_HELPER_H +#define M_HELPER_H + +#include "cpu.h" + +void v7m_msr_xpsr (CPUARMState *env,uint32_t mask, +uint32_t reg,uint32_t val); + +uint32_t v7m_mrs_xpsr (CPUARMState *env,uint32_t reg,unsigned el); + +uint32_t v7m_mrs_control (CPUARMState *env,uint32_t secure); + +#endif /* M_HELPER_H */
target/arm/tcg/m_helper.c +5 -2762
2,798 lines not on this page · raw message
target/arm/tcg/sysemu/m_helper.c new file +2655 -0
181 lines not on this page · raw message
target/arm/tcg/user/m_helper.c new file +97 -0
97 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.20.1
Part of the diff is not shown here. View the raw message.
PATCH v16 23/99 target/arm: only build psci for TCG
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
We do not move psci.c to tcg/ because we expect other hypervisors to use it (waiting for HVF enablement).
--- target/arm/meson.build | 4 ++++ 1 file changed, 4 insertions(+)
target/arm/meson.build +4 -0
@@ -19,8 +19,12 @@ arm_softmmu_ss.add(files( 'arm-powerctl.c', 'machine.c', 'monitor.c', +)) + +arm_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( 'psci.c', )) + arm_user_ss = ss.source_set() subdir('tcg')
Signature · 1 line
2.20.1
PATCH v16 24/99 target/arm: split off cpu-sysemu.c
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
move work is needed later on to split things into tcg-specific portions and kvm-specific portions of this
--- target/arm/internals.h | 8 ++- target/arm/cpu-sysemu.c | 105 ++++++++++++++++++++++++++++++++++++++++ target/arm/cpu.c | 83 ------------------------------- target/arm/meson.build | 1 + 4 files changed, 113 insertions(+), 84 deletions(-) create mode 100644 target/arm/cpu-sysemu.c
target/arm/internals.h +7 -1
@@ -1202,4 +1202,10 @@ static inline uint64_t useronly_maybe_clean_ptr(uint32_t desc, uint64_t ptr) return ptr; } -#endif +#ifndef CONFIG_USER_ONLY +void arm_cpu_set_irq (void *opaque,int irq,int level); +void arm_cpu_kvm_set_irq (void *opaque,int irq,int level); +bool arm_cpu_virtio_is_big_endian (CPUState *cs); +#endif /* !CONFIG_USER_ONLY */ + +#endif /* TARGET_ARM_INTERNALS_H */
target/arm/cpu-sysemu.c new file +105 -0
105 lines not on this page · raw message
target/arm/cpu.c +0 -83
89 lines not on this page · raw message
target/arm/meson.build +1 -0
@@ -17,6 +17,7 @@ arm_softmmu_ss = ss.source_set() arm_softmmu_ss.add(files( 'arch_dump.c', 'arm-powerctl.c', + 'cpu-sysemu.c', 'machine.c', 'monitor.c', ))
Signature · 1 line
2.20.1
PATCH v16 25/99 target/arm: tcg: fix comment style before move to cpu-mmu
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
before exporting some functionality from helper.c into a new module, fix the comment style of those functions.
--- target/arm/tcg/helper.c | 152 ++++++++++++++++++++++++++-------------- 1 file changed, 101 insertions(+), 51 deletions(-)
target/arm/tcg/helper.c +101 -51
@@ -10477,7 +10477,8 @@ static inline bool regime_translation_disabled(CPUARMState *env,return false;case 0 :default : -/* HFNMIENA set and ENABLE clear is UNPREDICTABLE, but +/* +* HFNMIENA set and ENABLE clear is UNPREDICTABLE, but * we warned about that in armv7m_nvic.c when the guest set it. */ return true;
@@ -10531,7 +10532,8 @@ static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx,#endif /* !CONFIG_USER_ONLY */ -/* Convert a possible stage1+2 MMU index into the appropriate +/* +* Convert a possible stage1+2 MMU index into the appropriate * stage 1 MMU index */ static inline ARMMMUIdx stage_1_mmu_idx (ARMMMUIdx mmu_idx)
@@ -10602,7 +10604,8 @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx) } } -/* Translate section/page access permissions to page +/* +* Translate section/page access permissions to page * R/W protection flags * * @env: CPUARMState
@@ -10658,7 +10661,8 @@ static inline int ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, } } -/* Translate section/page access permissions to page +/* +* Translate section/page access permissions to page * R/W protection flags. * * @ap: The 2-bit simple AP (AP[2:1])
@@ -10686,7 +10690,8 @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)return simple_ap_to_rw_prot_is_user (ap,regime_is_user (env, mmu_idx)); } -/* Translate S2 section/page access permissions to protection flags +/* +* Translate S2 section/page access permissions to protection flags * * @env: CPUARMState * @s2ap: The 2-bit stage2 access permissions (S2AP)
@@ -10734,7 +10739,8 @@ static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0)return prot; } -/* Translate section/page access permissions to protection flags +/* +* Translate section/page access permissions to protection flags * * @env: CPUARMState * @mmu_idx: MMU index indicating required translation regime
@@ -10771,7 +10777,8 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64,return prot_rw; } -/* TODO have_wxn should be replaced with +/* +* TODO have_wxn should be replaced with * ARM_FEATURE_V8 || (ARM_FEATURE_V7 && ARM_FEATURE_EL2) * when ARM_FEATURE_EL2 starts getting set. For now we assume all LPAE * compatible processors have EL2, which is required for [U]WXN.
@@ -11043,7 +11050,8 @@ static bool get_phys_addr_v5(CPUARMState *env, uint32_t address, phys_addr = (desc &0xfffff000 ) | (address &0xfff ); *page_size =0x1000 ; }else { -/* UNPREDICTABLE in ARMv5; we choose to take a +/* +* UNPREDICTABLE in ARMv5; we choose to take a * page translation fault. */ fi->type = ARMFault_Translation;
@@ -11109,7 +11117,8 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, } type = (desc &3 );if (type ==0 || (type ==3 && !cpu_isar_feature (aa32_pxn, cpu))) { -/* Section translation fault, or attempt to use the encoding +/* +* Section translation fault, or attempt to use the encoding * which is Reserved on implementations without PXN. */ fi->type = ARMFault_Translation;
@@ -11214,7 +11223,8 @@ static bool get_phys_addr_v6(CPUARMState *env, uint32_t address, } }if (ns) { -/* The NS bit will (as required by the architecture) have no effect if +/* +* The NS bit will (as required by the architecture) have no effect if * the CPU doesn't support TZ or this is a non-secure translation * regime, because the attribute will already be non-secure. */
@@ -11296,7 +11306,8 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level,return true; } -/* Translate from the 4-bit stage 2 representation of +/* +* Translate from the 4-bit stage 2 representation of * memory attributes (without cache-allocation hints) to * the 8-bit representation of the stage 1 MAIR registers * (which includes allocation hints).
@@ -11585,7 +11596,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, stride =9 ; } -/* Note that QEMU ignores shareability and cacheability attributes, +/* +* Note that QEMU ignores shareability and cacheability attributes, * so we don't need to do anything with the SH, ORGN, IRGN fields * in the TTBCR. Similarly, TTBCR:A1 selects whether we get the * ASID from TTBR0 or TTBR1, but QEMU's TLB doesn't currently
@@ -11594,19 +11606,22 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,*/ ttbr =regime_ttbr (env, mmu_idx, param.select); -/* Here we should have set up all the parameters for the translation: +/* +* Here we should have set up all the parameters for the translation: * inputsize, ttbr, epd, stride, tbi */ if (param.epd) { -/* Translation table walk disabled => Translation fault on TLB miss +/* +* Translation table walk disabled => Translation fault on TLB miss * Note: This is always 0 on 64-bit EL2 and EL3. */ goto do_fault; }if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) { -/* The starting level depends on the virtual address size (which can +/* +* The starting level depends on the virtual address size (which can * be up to 48 bits) and the translation granule size. It indicates * the number of strides (stride bits at a time) needed to * consume the bits of the input address. In the pseudocode this is:
@@ -11619,7 +11634,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,*/ level =4 - (inputsize -4 ) / stride; }else { -/* For stage 2 translations the starting level is specified by the +/* +* For stage 2 translations the starting level is specified by the * VTCR_EL2.SL0 field (whose interpretation depends on the page size) */ uint32_t sl0 =extract32 (tcr->raw_tcr,6 ,2 );
@@ -11659,7 +11675,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,*/ descaddr &= ~indexmask; -/* The address field in the descriptor goes up to bit 39 for ARMv7 +/* +* The address field in the descriptor goes up to bit 39 for ARMv7 * but up to bit 47 for ARMv8, but we use the descaddrmask * up to bit 39 for AArch32, because we don't need other bits in that case * to construct next descriptor address (anyway they should be all zeroes).
@@ -11667,7 +11684,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, descaddrmask = ((1ull << (aarch64 ?48 :40 )) -1 ) & ~indexmask_grainsize; -/* Secure accesses start with the page table in secure memory and +/* +* Secure accesses start with the page table in secure memory and * can be downgraded to non-secure at any step. Non-secure accesses * remain non-secure. We implement this by just ORing in the NSTable/NS * bits at each step.
@@ -11693,7 +11711,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, descaddr = descriptor & descaddrmask;if ((descriptor &2 ) && (level <3 )) { -/* Table entry. The top five bits are attributes which may +/* +* Table entry. The top five bits are attributes which may * propagate down through lower levels of the table (and * which are all arranged so that 0 means "no effect", so * we can gather them up by ORing in the bits at each level).
@@ -11703,7 +11722,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, indexmask = indexmask_grainsize;continue ; } -/* Block entry at level 1 or 2, or page entry at level 3. +/* +* Block entry at level 1 or 2, or page entry at level 3. * These are basically the same thing, although the number * of bits we pull in from the vaddr varies. */
@@ -11725,15 +11745,17 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,break ; } attrs |=extract32 (tableattrs,0 ,2 ) <<11 ;/* XN, PXN */ -/* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 +/* +* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1 * means "force PL1 access only", which means forcing AP[1] to 0. */ attrs &= ~(extract32 (tableattrs,2 ,1 ) <<4 );/* !APT[0] => AP[1] */ attrs |=extract32 (tableattrs,3 ,1 ) <<5 ;/* APT[1] => AP[2] */ break ; } -/* Here descaddr is the final physical address, and attributes -* are all in attrs. +/* +* Here descaddr is the final physical address, +* and attributes are all in attrs. */ fault_type = ARMFault_AccessFlag;if ((attrs & (1 <<8 )) ==0 ) {
@@ -11760,7 +11782,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address, }if (ns) { -/* The NS bit will (as required by the architecture) have no effect if +/* +* The NS bit will (as required by the architecture) have no effect if * the CPU doesn't support TZ or this is a non-secure translation * regime, because the attribute will already be non-secure. */
@@ -11814,7 +11837,8 @@ static inline void get_phys_addr_pmsav7_default(CPUARMState *env,break ; } }else { -/* Default system address map for M profile cores. +/* +* Default system address map for M profile cores. * The architecture specifies which regions are execute-never; * at the MPU level no other checks are defined. */
@@ -11840,7 +11864,8 @@ static inline void get_phys_addr_pmsav7_default(CPUARMState *env,static bool pmsav7_use_background_region (ARMCPU *cpu,ARMMMUIdx mmu_idx,bool is_user) { -/* Return true if we should use the default memory map as a +/* +* Return true if we should use the default memory map as a * "background" region if there are no hits against any MPU regions. */ CPUARMState *env = &cpu->env;
@@ -11866,7 +11891,8 @@ static inline bool m_is_ppb_region(CPUARMState *env, uint32_t address)static inline bool m_is_system_region (CPUARMState *env,uint32_t address) { -/* True if address is in the M profile system region +/* +* True if address is in the M profile system region * 0xe0000000 - 0xffffffff */ return arm_feature (env,ARM_FEATURE_M ) &&extract32 (address,29 ,3 ) ==0x7 ;
@@ -11888,7 +11914,8 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,if (regime_translation_disabled (env, mmu_idx) ||m_is_ppb_region (env, address)) { -/* MPU disabled or M profile PPB access: use default memory map. +/* +* MPU disabled or M profile PPB access: use default memory map. * The other case which uses the default memory map in the * v7M ARM ARM pseudocode is exception vector reads from the vector * table. In QEMU those accesses are done in arm_v7m_load_vector(),
@@ -11954,7 +11981,8 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, srdis_mask = srdis ?0x3 :0x0 ;for (i =2 ; i <=8 && rsize <TARGET_PAGE_BITS ; i *=2 ) { -/* This will check in groups of 2, 4 and then 8, whether +/* +* This will check in groups of 2, 4 and then 8, whether * the subregion bits are consistent. rsize is incremented * back up to give the region size, considering consistent * adjacent subregions as one region. Stop testing if rsize
@@ -12062,7 +12090,8 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,static bool v8m_is_sau_exempt (CPUARMState *env,uint32_t address,MMUAccessType access_type) { -/* The architecture specifies that certain address ranges are +/* +* The architecture specifies that certain address ranges are * exempt from v8M SAU/IDAU checks. */ return
@@ -12078,7 +12107,8 @@ void v8m_security_lookup(CPUARMState *env, uint32_t address, MMUAccessType access_type, ARMMMUIdx mmu_idx, V8M_SAttributes *sattrs) { -/* Look up the security attributes for this address. Compare the +/* +* Look up the security attributes for this address. Compare the * pseudocode SecurityCheck() function. * We assume the caller has zero-initialized *sattrs. */
@@ -12129,7 +12159,8 @@ void v8m_security_lookup(CPUARMState *env, uint32_t address, sattrs->subpage = true; }if (sattrs->srvalid) { -/* If we hit in more than one region then we must report +/* +* If we hit in more than one region then we must report * as Secure, not NS-Callable, with no valid region * number info. */
@@ -12187,7 +12218,8 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, int *prot, bool *is_subpage, ARMMMUFaultInfo *fi, uint32_t *mregion) { -/* Perform a PMSAv8 MPU lookup (without also doing the SAU check +/* +* Perform a PMSAv8 MPU lookup (without also doing the SAU check * that a full phys-to-virt translation does). * mregion is (if not NULL) set to the region number which matched, * or -1 if no region number is returned (MPU off, address did not
@@ -12211,7 +12243,8 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, *mregion =-1 ; } -/* Unlike the ARM ARM pseudocode, we don't need to check whether this +/* +* Unlike the ARM ARM pseudocode, we don't need to check whether this * was an exception vector read from the vector table (which is always * done using the default system address map), because those accesses * are done in arm_v7m_load_vector(), which always does a direct
@@ -12228,7 +12261,8 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,for (n = (int )cpu->pmsav7_dregion -1 ; n >=0 ; n--) {/* region search */ -/* Note that the base address is bits [31:5] from the register +/* +* Note that the base address is bits [31:5] from the register * with bits [4:0] all zeroes, but the limit address is bits * [31:5] from the register with bits [4:0] all ones. */
@@ -12264,7 +12298,8 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address, }if (matchregion !=-1 ) { -/* Multiple regions match -- always a failure (unlike +/* +* Multiple regions match -- always a failure (unlike * PMSAv7 where highest-numbered-region wins) */ fi->type = ARMFault_Permission;
@@ -12304,7 +12339,8 @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,if (*prot && !xn && !(pxn && !is_user)) { *prot |=PAGE_EXEC ; } -/* We don't need to look the attribute up in the MAIR0/MAIR1 +/* +* We don't need to look the attribute up in the MAIR0/MAIR1 * registers because that only tells us about cacheability. */ if (mregion) {
@@ -12332,7 +12368,8 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,if (arm_feature (env,ARM_FEATURE_M_SECURITY )) {v8m_security_lookup (env, address, access_type, mmu_idx, &sattrs);if (access_type ==MMU_INST_FETCH ) { -/* Instruction fetches always use the MMU bank and the +/* +* Instruction fetches always use the MMU bank and the * transaction attribute determined by the fetch address, * regardless of CPU state. This is painful for QEMU * to handle, because it would mean we need to encode
@@ -12361,14 +12398,16 @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,return true; } }else { -/* For data accesses we always use the MMU bank indicated +/* +* For data accesses we always use the MMU bank indicated * by the current CPU state, but the security attributes * might downgrade a secure access to nonsecure. */ if (sattrs.ns) { txattrs->secure = false; }else if (!secure) { -/* NS access to S memory must fault. +/* +* NS access to S memory must fault. * Architecturally we should first check whether the * MPU information for this address indicates that we * are doing an unaligned access to Device memory, which
@@ -12416,8 +12455,10 @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,continue ; } mask =1 << ((base >>1 ) &0x1f ); -/* Keep this shift separate from the above to avoid an -(undefined) << 32. */ +/* +* Keep this shift separate from the above to avoid an +* (undefined) << 32 +*/ mask = (mask <<1 ) -1 ;if (((base ^ address) & ~mask) ==0 ) {break ;
@@ -12477,7 +12518,8 @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,return false; } -/* Combine either inner or outer cacheability attributes for normal +/* +* Combine either inner or outer cacheability attributes for normal * memory, according to table D4-42 and pseudocode procedure * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM). *
@@ -12493,7 +12535,8 @@ static uint8_t combine_cacheattr_nibble(uint8_t s1, uint8_t s2)/* stage 1 write-through takes precedence */ return s1; }else if (extract32 (s2,2 ,2 ) ==2 ) { -/* stage 2 write-through takes precedence, but the allocation hint +/* +* stage 2 write-through takes precedence, but the allocation hint * is still taken from stage 1 */ return (2 <<2 ) |extract32 (s1,0 ,2 );
@@ -12502,7 +12545,8 @@ static uint8_t combine_cacheattr_nibble(uint8_t s1, uint8_t s2) } } -/* Combine S1 and S2 cacheability/shareability attributes, per D4.5.4 +/* +* Combine S1 and S2 cacheability/shareability attributes, per D4.5.4 * and CombineS1S2Desc() * * @s1: Attributes from stage 1 walk
@@ -12552,7 +12596,8 @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2) ret.attrs =0xc ;/* GRE */ } -/* Any location for which the resultant memory type is any +/* +* Any location for which the resultant memory type is any * type of Device memory is always treated as Outer Shareable. */ ret.shareability =2 ;
@@ -12562,7 +12607,8 @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2) | combine_cacheattr_nibble(s1lo, s2lo);if (ret.attrs ==0x44 ) { -/* Any location for which the resultant memory type is Normal +/* +* Any location for which the resultant memory type is Normal * Inner Non-cacheable, Outer Non-cacheable is always treated * as Outer Shareable. */
@@ -12579,7 +12625,8 @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2) } -/* get_phys_addr - get the physical address for this virtual address +/* +* get_phys_addr - get the physical address for this virtual address * * Find the physical address corresponding to the given virtual address, * by doing a translation table walk on MMU based systems or using the
@@ -12614,7 +12661,8 @@ bool get_phys_addr(CPUARMState *env, target_ulong address,ARMMMUIdx s1_mmu_idx =stage_1_mmu_idx (mmu_idx);if (mmu_idx != s1_mmu_idx) { -/* Call ourselves recursively to do the stage 1 and then stage 2 +/* +* Call ourselves recursively to do the stage 1 and then stage 2 * translations if mmu_idx is a two-stage regime. */ if (arm_feature (env,ARM_FEATURE_EL2 )) {
@@ -12686,14 +12734,16 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, } } -/* The page table entries may downgrade secure to non-secure, but +/* +* The page table entries may downgrade secure to non-secure, but * cannot upgrade an non-secure translation regime's attributes * to secure. */ attrs->secure =regime_is_secure (env, mmu_idx); attrs->user =regime_is_user (env, mmu_idx); -/* Fast Context Switch Extension. This doesn't exist at all in v8. +/* +* Fast Context Switch Extension. This doesn't exist at all in v8. * In v7 and earlier it affects all stage 1 translations. */ if (address < 0x02000000 && mmu_idx != ARMMMUIdx_Stage2
Signature · 1 line
2.20.1
PATCH v16 26/99 target/arm: move physical address translation to cpu-mmu
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
get_phys_addr is needed for KVM too, and in turn it requires the aa64_va_parameter* family of functions.
Create cpu-mmu and cpu-mmu-sysemu to store these and other mmu-related functions.
--- target/arm/cpu-mmu.h | 119 ++ target/arm/cpu.h | 3 - target/arm/internals.h | 34 - target/arm/cpu-mmu-sysemu.c | 2307 ++++++++++++++++++++++++++ target/arm/cpu-mmu.c | 124 ++ target/arm/cpu.c | 1 + target/arm/tcg/helper.c | 2442 +--------------------------- target/arm/tcg/pauth_helper.c | 2 +- target/arm/tcg/sysemu/m_helper.c | 2 +- target/arm/tcg/sysemu/tlb_helper.c | 1 + target/arm/meson.build | 2 + 11 files changed, 2557 insertions(+), 2480 deletions(-) create mode 100644 target/arm/cpu-mmu.h create mode 100644 target/arm/cpu-mmu-sysemu.c create mode 100644 target/arm/cpu-mmu.c
target/arm/cpu-mmu.h new file +119 -0
@@ -0,0 +1,119 @@ +/* +* QEMU ARM CPU address translation related code +* +* Copyright (c) 2012 SUSE LINUX Products GmbH +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see +* <http://www.gnu.org/licenses/gpl-2.0.html> +*/ +#ifndef ARM_CPU_MMU_H +#define ARM_CPU_MMU_H + +#include "cpu.h" +#include "internals.h" + +/* +* Parameters of a given virtual address, as extracted from the +* translation control register (TCR) for a given regime. +*/ +typedef struct ARMVAParameters { +unsigned tsz :8 ; +unsigned select :1 ; +bool tbi :1 ; +bool epd :1 ; +bool hpd :1 ; +bool using16k :1 ; +bool using64k :1 ; +}ARMVAParameters ; + +/* cpu-mmu.c */ + +int aa64_va_parameter_tbi (uint64_t tcr,ARMMMUIdx mmu_idx); +int aa64_va_parameter_tbid (uint64_t tcr,ARMMMUIdx mmu_idx); +int aa64_va_parameter_tcma (uint64_t tcr,ARMMMUIdx mmu_idx); +ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va, +ARMMMUIdx mmu_idx,bool data); + +/* Return the SCTLR value which controls this address translation regime */ +static inline uint64_t regime_sctlr (CPUARMState *env,ARMMMUIdx mmu_idx) +{ +return env->cp15.sctlr_el[regime_el (env, mmu_idx)]; +} + +/* +* Convert a possible stage1+2 MMU index into the appropriate +* stage 1 MMU index +*/ +static inline ARMMMUIdx stage_1_mmu_idx (ARMMMUIdx mmu_idx) +{ +switch (mmu_idx) { +case ARMMMUIdx_SE10_0: +return ARMMMUIdx_Stage1_SE0; +case ARMMMUIdx_SE10_1: +return ARMMMUIdx_Stage1_SE1; +case ARMMMUIdx_SE10_1_PAN: +return ARMMMUIdx_Stage1_SE1_PAN; +case ARMMMUIdx_E10_0: +return ARMMMUIdx_Stage1_E0; +case ARMMMUIdx_E10_1: +return ARMMMUIdx_Stage1_E1; +case ARMMMUIdx_E10_1_PAN: +return ARMMMUIdx_Stage1_E1_PAN; +default : +return mmu_idx; + } +} + +/* Return true if the translation regime is using LPAE format page tables */ +static inline bool regime_using_lpae_format (CPUARMState *env, +ARMMMUIdx mmu_idx) +{ +int el =regime_el (env, mmu_idx); +if (el ==2 ||arm_el_is_aa64 (env, el)) { +return true; + } +if (arm_feature (env,ARM_FEATURE_LPAE ) + && (regime_tcr (env, mmu_idx)->raw_tcr &TTBCR_EAE )) { +return true; + } +return false; +} + +#ifndef CONFIG_USER_ONLY + +/* cpu-mmu-sysemu.c */ + +void v8m_security_lookup (CPUARMState *env,uint32_t address, +MMUAccessType access_type,ARMMMUIdx mmu_idx, +V8M_SAttributes *sattrs); + +bool pmsav8_mpu_lookup (CPUARMState *env,uint32_t address, +MMUAccessType access_type,ARMMMUIdx mmu_idx, +hwaddr *phys_ptr,MemTxAttrs *txattrs, +int *prot,bool *is_subpage, +ARMMMUFaultInfo *fi,uint32_t *mregion); + +bool get_phys_addr (CPUARMState *env,target_ulong address, +MMUAccessType access_type,ARMMMUIdx mmu_idx, +hwaddr *phys_ptr,MemTxAttrs *attrs,int *prot, +target_ulong *page_size, +ARMMMUFaultInfo *fi,ARMCacheAttrs *cacheattrs) + __attribute__((nonnull)); + +hwaddr arm_cpu_get_phys_page_attrs_debug (CPUState *cs,vaddr addr, +MemTxAttrs *attrs); + +#endif /* !CONFIG_USER_ONLY */ + +#endif /* ARM_CPU_MMU_H */
target/arm/cpu.h +0 -3
@@ -1033,9 +1033,6 @@ void arm_cpu_do_interrupt(CPUState *cpu);void arm_v7m_cpu_do_interrupt (CPUState *cpu);bool arm_cpu_exec_interrupt (CPUState *cpu,int int_req); -hwaddr arm_cpu_get_phys_page_attrs_debug (CPUState *cpu,vaddr addr, -MemTxAttrs *attrs); -int arm_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int arm_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/arm/internals.h +0 -34
@@ -1022,23 +1022,6 @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id)return valid; } -/* -* Parameters of a given virtual address, as extracted from the -* translation control register (TCR) for a given regime. -*/ -typedef struct ARMVAParameters { -unsigned tsz :8 ; -unsigned select :1 ; -bool tbi :1 ; -bool epd :1 ; -bool hpd :1 ; -bool using16k :1 ; -bool using64k :1 ; -}ARMVAParameters ; - -ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va, -ARMMMUIdx mmu_idx,bool data); -static inline int exception_target_el (CPUARMState *env) {int target_el =MAX (1 ,arm_current_el (env));
@@ -1086,29 +1069,12 @@ typedef struct V8M_SAttributes { bool irvalid; } V8M_SAttributes; -void v8m_security_lookup (CPUARMState *env,uint32_t address, -MMUAccessType access_type,ARMMMUIdx mmu_idx, -V8M_SAttributes *sattrs); - -bool pmsav8_mpu_lookup (CPUARMState *env,uint32_t address, -MMUAccessType access_type,ARMMMUIdx mmu_idx, -hwaddr *phys_ptr,MemTxAttrs *txattrs, -int *prot,bool *is_subpage, -ARMMMUFaultInfo *fi,uint32_t *mregion); -/* Cacheability and shareability attributes for a memory access */ typedef struct ARMCacheAttrs {unsigned int attrs:8 ;/* as in the MAIR register encoding */ unsigned int shareability:2 ;/* as in the SH field of the VMSAv8-64 PTEs */ }ARMCacheAttrs ; -bool get_phys_addr (CPUARMState *env,target_ulong address, -MMUAccessType access_type,ARMMMUIdx mmu_idx, -hwaddr *phys_ptr,MemTxAttrs *attrs,int *prot, -target_ulong *page_size, -ARMMMUFaultInfo *fi,ARMCacheAttrs *cacheattrs) - __attribute__((nonnull)); -void arm_log_exception (int idx);#endif /* !CONFIG_USER_ONLY */
target/arm/cpu-mmu-sysemu.c new file +2307 -0
2,307 lines not on this page · raw message
target/arm/cpu-mmu.c new file +124 -0
124 lines not on this page · raw message
target/arm/cpu.c +1 -0
@@ -41,6 +41,7 @@#include "kvm_arm.h" #include "disas/capstone.h" #include "fpu/softfloat.h" +#include "cpu-mmu.h" static void arm_cpu_set_pc (CPUState *cs,vaddr value) {
target/arm/tcg/helper.c +1 -2441
382 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.20.1
Part of the diff is not shown here. View the raw message.
PATCH v16 27/99 target/arm: fix style in preparation of new cpregs module
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
in preparation of the creation of a new cpregs module, fix the style for the to-be-exported code.
--- target/arm/cpu.h | 54 ++++--- target/arm/tcg/helper.c | 310 ++++++++++++++++++++++++++-------------- 2 files changed, 239 insertions(+), 125 deletions(-)
target/arm/cpu.h +36 -18
@@ -2709,14 +2709,16 @@ typedef struct ARMCPRegInfo ARMCPRegInfo; typedef enum CPAccessResult { /* Access is permitted */ CP_ACCESS_OK = 0, - /* Access fails due to a configurable trap or enable which would + /* + * Access fails due to a configurable trap or enable which would * result in a categorized exception syndrome giving information about * the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, * 0xc or 0x18). The exception is taken to the usual target EL (EL1 or * PL1 if in EL0, otherwise to the current EL). */ CP_ACCESS_TRAP = 1, - /* Access fails and results in an exception syndrome 0x0 ("uncategorized"). + /* + * Access fails and results in an exception syndrome 0x0 ("uncategorized"). * Note that this is not a catch-all case -- the set of cases which may * result in this failure is specifically defined by the architecture. */
@@ -2727,14 +2729,16 @@ typedef enum CPAccessResult {/* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ CP_ACCESS_TRAP_UNCATEGORIZED_EL2 =5 ,CP_ACCESS_TRAP_UNCATEGORIZED_EL3 =6 , -/* Access fails and results in an exception syndrome for an FP access, +/* +* Access fails and results in an exception syndrome for an FP access, * trapped directly to EL2 or EL3 */ CP_ACCESS_TRAP_FP_EL2 =7 ,CP_ACCESS_TRAP_FP_EL3 =8 , } CPAccessResult; -/* Access functions for coprocessor registers. These cannot fail and +/* +* Access functions for coprocessor registers. These cannot fail and * may not raise exceptions. */ typedef uint64_t CPReadFn (CPUARMState *env,const ARMCPRegInfo *opaque);
@@ -2753,7 +2757,8 @@ typedef void CPResetFn(CPUARMState *env, const ARMCPRegInfo *opaque);struct ARMCPRegInfo {/* Name of register (useful mainly for debugging, need not be unique) */ const char *name; -/* Location of register: coprocessor number and (crn,crm,opc1,opc2) +/* +* Location of register: coprocessor number and (crn,crm,opc1,opc2) * tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a * 'wildcard' field -- any value of that field in the MRC/MCR insn * will be decoded to this register. The register read and write
@@ -2784,16 +2789,19 @@ struct ARMCPRegInfo {int access;/* Security state: ARM_CP_SECSTATE_* bits/values */ int secure; -/* The opaque pointer passed to define_arm_cp_regs_with_opaque() when +/* +* The opaque pointer passed to define_arm_cp_regs_with_opaque() when * this register was defined: can be used to hand data through to the * register read/write functions, since they are passed the ARMCPRegInfo*. */ void *opaque; -/* Value of this register, if it is ARM_CP_CONST. Otherwise, if +/* +* Value of this register, if it is ARM_CP_CONST. Otherwise, if * fieldoffset is non-zero, the reset value of the register. */ uint64_t resetvalue; -/* Offset of the field in CPUARMState for this register. +/* +* Offset of the field in CPUARMState for this register. * * This is not needed if either: * 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs
@@ -2801,7 +2809,8 @@ struct ARMCPRegInfo {*/ ptrdiff_t fieldoffset;/* offsetof(CPUARMState, field) */ -/* Offsets of the secure and non-secure fields in CPUARMState for the +/* +* Offsets of the secure and non-secure fields in CPUARMState for the * register if it is banked. These fields are only used during the static * registration of a register. During hashing the bank associated * with a given security state is copied to fieldoffset which is used from
@@ -2814,36 +2823,42 @@ struct ARMCPRegInfo {*/ ptrdiff_t bank_fieldoffsets[2 ]; -/* Function for making any access checks for this register in addition to +/* +* Function for making any access checks for this register in addition to * those specified by the 'access' permissions bits. If NULL, no extra * checks required. The access check is performed at runtime, not at * translate time. */ CPAccessFn *accessfn; -/* Function for handling reads of this register. If NULL, then reads +/* +* Function for handling reads of this register. If NULL, then reads * will be done by loading from the offset into CPUARMState specified * by fieldoffset. */ CPReadFn *readfn; -/* Function for handling writes of this register. If NULL, then writes +/* +* Function for handling writes of this register. If NULL, then writes * will be done by writing to the offset into CPUARMState specified * by fieldoffset. */ CPWriteFn *writefn; -/* Function for doing a "raw" read; used when we need to copy +/* +* Function for doing a "raw" read; used when we need to copy * coprocessor state to the kernel for KVM or out for * migration. This only needs to be provided if there is also a * readfn and it has side effects (for instance clear-on-read bits). */ CPReadFn *raw_readfn; -/* Function for doing a "raw" write; used when we need to copy KVM +/* +* Function for doing a "raw" write; used when we need to copy KVM * kernel coprocessor state into userspace, or for inbound * migration. This only needs to be provided if there is also a * writefn and it masks out "unwritable" bits or has write-one-to-clear * or similar behaviour. */ CPWriteFn *raw_writefn; -/* Function for resetting the register. If NULL, then reset will be done +/* +* Function for resetting the register. If NULL, then reset will be done * by writing resetvalue to the field specified in fieldoffset. If * fieldoffset is 0 then no reset will be done. */
@@ -2863,7 +2878,8 @@ struct ARMCPRegInfo {CPWriteFn *orig_writefn; }; -/* Macros which are lvalues for the field in CPUARMState for the +/* +* Macros which are lvalues for the field in CPUARMState for the * ARMCPRegInfo *ri. */ #define CPREG_FIELD32 (env, ri) \
@@ -2917,12 +2933,14 @@ void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri,/* CPReadFn that can be used for read-as-zero behaviour */ uint64_t arm_cp_read_zero (CPUARMState *env,const ARMCPRegInfo *ri); -/* CPResetFn that does nothing, for use if no reset is required even +/* +* CPResetFn that does nothing, for use if no reset is required even * if fieldoffset is non zero. */ void arm_cp_reset_ignore (CPUARMState *env,const ARMCPRegInfo *opaque); -/* Return true if this reginfo struct's field in the cpu state struct +/* +* Return true if this reginfo struct's field in the cpu state struct * is 64 bits wide. */ static inline bool cpreg_field_is_64bit (const ARMCPRegInfo *ri)
target/arm/tcg/helper.c +203 -107
903 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v16 28/99 target/arm: split cpregs from tcg/helper.c
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
give them their own common module cpregs.c, and an interface cpregs.h. Extract the raw cpustate list to its own module.
This is more or less needed for KVM too.
For the tcg-specific registers, stuff them into tcg/cpregs.c
As a result, the monster that is tcg/helper.c is a bit less scary, and a lot of stuff is removed from cpu.h too, relegated to cpregs.h.
--- target/arm/cpregs.h | 515 ++ target/arm/cpu.h | 480 -- hw/arm/pxa2xx.c | 1 + hw/arm/pxa2xx_pic.c | 1 + hw/intc/arm_gicv3_cpuif.c | 1 + hw/intc/arm_gicv3_kvm.c | 1 + target/arm/cpregs.c | 380 ++ target/arm/cpu.c | 1 + target/arm/cpu64.c | 2 +- target/arm/cpu_tcg.c | 1 + target/arm/cpustate-list.c | 146 + target/arm/gdbstub.c | 1 + target/arm/machine.c | 1 + target/arm/tcg/cpregs.c | 7674 +++++++++++++++++++++++++++ target/arm/tcg/helper.c | 9051 +------------------------------- target/arm/tcg/op_helper.c | 1 + target/arm/tcg/translate-a64.c | 1 + target/arm/tcg/translate.c | 1 + target/arm/meson.build | 2 + target/arm/tcg/meson.build | 1 + 20 files changed, 9005 insertions(+), 9257 deletions(-) create mode 100644 target/arm/cpregs.h create mode 100644 target/arm/cpregs.c create mode 100644 target/arm/cpustate-list.c create mode 100644 target/arm/tcg/cpregs.c
target/arm/cpregs.h new file +515 -0
@@ -0,0 +1,515 @@ +/* +* ARM CP registers +* +* This code is licensed under the GNU GPL v2 or later. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef CPREGS_H +#define CPREGS_H + +/* +* Interface for defining coprocessor registers. +* Registers are defined in tables of arm_cp_reginfo structs +* which are passed to define_arm_cp_regs(). +*/ + +/* +* When looking up a coprocessor register we look for it +* via an integer which encodes all of: +* coprocessor number +* Crn, Crm, opc1, opc2 fields +* 32 or 64 bit register (ie is it accessed via MRC/MCR +* or via MRRC/MCRR?) +* non-secure/secure bank (AArch32 only) +* We allow 4 bits for opc1 because MRRC/MCRR have a 4 bit field. +* (In this case crn and opc2 should be zero.) +* For AArch64, there is no 32/64 bit size distinction; +* instead all registers have a 2 bit op0, 3 bit op1 and op2, +* and 4 bit CRn and CRm. The encoding patterns are chosen +* to be easy to convert to and from the KVM encodings, and also +* so that the hashtable can contain both AArch32 and AArch64 +* registers (to allow for interprocessing where we might run +* 32 bit code on a 64 bit core). +*/ +/* +* This bit is private to our hashtable cpreg; in KVM register +* IDs the AArch64/32 distinction is the KVM_REG_ARM/ARM64 +* in the upper bits of the 64 bit ID. +*/ +#define CP_REG_AA64_SHIFT 28 +#define CP_REG_AA64_MASK (1 << CP_REG_AA64_SHIFT) + +/* +* To enable banking of coprocessor registers depending on ns-bit we +* add a bit to distinguish between secure and non-secure cpregs in the +* hashtable. +*/ +#define CP_REG_NS_SHIFT 29 +#define CP_REG_NS_MASK (1 << CP_REG_NS_SHIFT) + +#define ENCODE_CP_REG (cp, is64, ns, crn, crm, opc1, opc2) \ + ((ns) << CP_REG_NS_SHIFT | ((cp) << 16) | ((is64) << 15) | \ + ((crn) << 11) | ((crm) << 7) | ((opc1) << 3) | (opc2)) + +#define ENCODE_AA64_CP_REG (cp, crn, crm, op0, op1, op2) \ + (CP_REG_AA64_MASK | \ + ((cp) << CP_REG_ARM_COPROC_SHIFT) | \ + ((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \ + ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \ + ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \ + ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \ + ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT)) + +/* +* Convert a full 64 bit KVM register ID to the truncated 32 bit +* version used as a key for the coprocessor register hashtable +*/ +static inline uint32_t kvm_to_cpreg_id (uint64_t kvmid) +{ +uint32_t cpregid = kvmid; +if ((kvmid &CP_REG_ARCH_MASK ) ==CP_REG_ARM64 ) { + cpregid |=CP_REG_AA64_MASK ; + }else { +if ((kvmid &CP_REG_SIZE_MASK ) ==CP_REG_SIZE_U64 ) { + cpregid |= (1 <<15 ); + } + +/* +* KVM is always non-secure so add the NS flag on AArch32 register +* entries. +*/ + cpregid |=1 <<CP_REG_NS_SHIFT ; + } +return cpregid; +} + +/* +* Convert a truncated 32 bit hashtable key into the full +* 64 bit KVM register ID. +*/ +static inline uint64_t cpreg_to_kvm_id (uint32_t cpregid) +{ +uint64_t kvmid; + +if (cpregid &CP_REG_AA64_MASK ) { + kvmid = cpregid & ~CP_REG_AA64_MASK ; + kvmid |=CP_REG_SIZE_U64 |CP_REG_ARM64 ; + }else { + kvmid = cpregid & ~(1 <<15 ); +if (cpregid & (1 <<15 )) { + kvmid |=CP_REG_SIZE_U64 |CP_REG_ARM ; + }else { + kvmid |=CP_REG_SIZE_U32 |CP_REG_ARM ; + } + } +return kvmid; +} + +/* +* ARMCPRegInfo type field bits. If the SPECIAL bit is set this is a +* special-behaviour cp reg and bits [11..8] indicate what behaviour +* it has. Otherwise it is a simple cp reg, where CONST indicates that +* TCG can assume the value to be constant (ie load at translate time) +* and 64BIT indicates a 64 bit wide coprocessor register. SUPPRESS_TB_END +* indicates that the TB should not be ended after a write to this register +* (the default is that the TB ends after cp writes). OVERRIDE permits +* a register definition to override a previous definition for the +* same (cp, is64, crn, crm, opc1, opc2) tuple: either the new or the +* old must have the OVERRIDE bit set. +* ALIAS indicates that this register is an alias view of some underlying +* state which is also visible via another register, and that the other +* register is handling migration and reset; registers marked ALIAS will not be +* migrated but may have their state set by syncing of register state from KVM. +* NO_RAW indicates that this register has no underlying state and does not +* support raw access for state saving/loading; it will not be used for either +* migration or KVM state synchronization. (Typically this is for "registers" +* which are actually used as instructions for cache maintenance and so on.) +* IO indicates that this register does I/O and therefore its accesses +* need to be marked with gen_io_start() and also end the TB. In particular, +* registers which implement clocks or timers require this. +* RAISES_EXC is for when the read or write hook might raise an exception; +* the generated code will synchronize the CPU state before calling the hook +* so that it is safe for the hook to call raise_exception(). +* NEWEL is for writes to registers that might change the exception +* level - typically on older ARM chips. For those cases we need to +* re-read the new el when recomputing the translation flags. +*/ +#define ARM_CP_SPECIAL 0x0001 +#define ARM_CP_CONST 0x0002 +#define ARM_CP_64BIT 0x0004 +#define ARM_CP_SUPPRESS_TB_END 0x0008 +#define ARM_CP_OVERRIDE 0x0010 +#define ARM_CP_ALIAS 0x0020 +#define ARM_CP_IO 0x0040 +#define ARM_CP_NO_RAW 0x0080 +#define ARM_CP_NOP (ARM_CP_SPECIAL | 0x0100) +#define ARM_CP_WFI (ARM_CP_SPECIAL | 0x0200) +#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300) +#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400) +#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) +#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) +#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) +#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA +#define ARM_CP_FPU 0x1000 +#define ARM_CP_SVE 0x2000 +#define ARM_CP_NO_GDB 0x4000 +#define ARM_CP_RAISES_EXC 0x8000 +#define ARM_CP_NEWEL 0x10000 +/* Used only as a terminator for ARMCPRegInfo lists */ +#define ARM_CP_SENTINEL 0xfffff +/* Mask of only the flag bits in a type field */ +#define ARM_CP_FLAG_MASK 0x1f0ff + +/* +* Valid values for ARMCPRegInfo state field, indicating which of +* the AArch32 and AArch64 execution states this register is visible in. +* If the reginfo doesn't explicitly specify then it is AArch32 only. +* If the reginfo is declared to be visible in both states then a second +* reginfo is synthesised for the AArch32 view of the AArch64 register, +* such that the AArch32 view is the lower 32 bits of the AArch64 one. +* Note that we rely on the values of these enums as we iterate through +* the various states in some places. +*/ +enum { +ARM_CP_STATE_AA32 =0 , +ARM_CP_STATE_AA64 =1 , +ARM_CP_STATE_BOTH =2 , +}; + +/* +* ARM CP register secure state flags. These flags identify security state +* attributes for a given CP register entry. +* The existence of both or neither secure and non-secure flags indicates that +* the register has both a secure and non-secure hash entry. A single one of +* these flags causes the register to only be hashed for the specified +* security state. +* Although definitions may have any combination of the S/NS bits, each +* registered entry will only have one to identify whether the entry is secure +* or non-secure. +*/ +enum { +ARM_CP_SECSTATE_S = (1 <<0 ),/* bit[0]: Secure state register */ +ARM_CP_SECSTATE_NS = (1 <<1 ),/* bit[1]: Non-secure state register */ +}; + +/* +* Return true if cptype is a valid type field. This is used to try to +* catch errors where the sentinel has been accidentally left off the end +* of a list of registers. +*/ +static inline bool cptype_valid (int cptype) +{ +return ((cptype & ~ARM_CP_FLAG_MASK ) ==0 ) + || ((cptype &ARM_CP_SPECIAL ) && + ((cptype & ~ARM_CP_FLAG_MASK ) <=ARM_LAST_SPECIAL )); +} + +/* +* Access rights: +* We define bits for Read and Write access for what rev C of the v7-AR ARM ARM +* defines as PL0 (user), PL1 (fiq/irq/svc/abt/und/sys, ie privileged), and +* PL2 (hyp). The other level which has Read and Write bits is Secure PL1 +* (ie any of the privileged modes in Secure state, or Monitor mode). +* If a register is accessible in one privilege level it's always accessible +* in higher privilege levels too. Since "Secure PL1" also follows this rule +* (ie anything visible in PL2 is visible in S-PL1, some things are only +* visible in S-PL1) but "Secure PL1" is a bit of a mouthful, we bend the +* terminology a little and call this PL3. +* In AArch64 things are somewhat simpler as the PLx bits line up exactly +* with the ELx exception levels. +* +* If access permissions for a register are more complex than can be +* described with these bits, then use a laxer set of restrictions, and +* do the more restrictive/complex check inside a helper function. +*/ +#define PL3_R 0x80 +#define PL3_W 0x40 +#define PL2_R (0x20 | PL3_R) +#define PL2_W (0x10 | PL3_W) +#define PL1_R (0x08 | PL2_R) +#define PL1_W (0x04 | PL2_W) +#define PL0_R (0x02 | PL1_R) +#define PL0_W (0x01 | PL1_W) + +/* +* For user-mode some registers are accessible to EL0 via a kernel +* trap-and-emulate ABI. In this case we define the read permissions +* as actually being PL0_R. However some bits of any given register +* may still be masked. +*/ +#ifdef CONFIG_USER_ONLY +#define PL0U_R PL0_R +#else +#define PL0U_R PL1_R +#endif + +#define PL3_RW (PL3_R | PL3_W) +#define PL2_RW (PL2_R | PL2_W) +#define PL1_RW (PL1_R | PL1_W) +#define PL0_RW (PL0_R | PL0_W) + +typedef enum CPAccessResult { +/* Access is permitted */ +CP_ACCESS_OK =0 , +/* +* Access fails due to a configurable trap or enable which would +* result in a categorized exception syndrome giving information about +* the failing instruction (ie syndrome category 0x3, 0x4, 0x5, 0x6, +* 0xc or 0x18). The exception is taken to the usual target EL (EL1 or +* PL1 if in EL0, otherwise to the current EL). +*/ +CP_ACCESS_TRAP =1 , +/* +* Access fails and results in an exception syndrome 0x0 ("uncategorized"). +* Note that this is not a catch-all case -- the set of cases which may +* result in this failure is specifically defined by the architecture. +*/ +CP_ACCESS_TRAP_UNCATEGORIZED =2 , +/* As CP_ACCESS_TRAP, but for traps directly to EL2 or EL3 */ +CP_ACCESS_TRAP_EL2 =3 , +CP_ACCESS_TRAP_EL3 =4 , +/* As CP_ACCESS_UNCATEGORIZED, but for traps directly to EL2 or EL3 */ +CP_ACCESS_TRAP_UNCATEGORIZED_EL2 =5 , +CP_ACCESS_TRAP_UNCATEGORIZED_EL3 =6 , +/* +* Access fails and results in an exception syndrome for an FP access, +* trapped directly to EL2 or EL3 +*/ +CP_ACCESS_TRAP_FP_EL2 =7 , +CP_ACCESS_TRAP_FP_EL3 =8 , +}CPAccessResult ; + +/* +* Access functions for coprocessor registers. These cannot fail and +* may not raise exceptions. +*/ +typedef uint64_t CPReadFn (CPUARMState *env,const ARMCPRegInfo *opaque); +typedef void CPWriteFn (CPUARMState *env,const ARMCPRegInfo *opaque, +uint64_t value); +/* Access permission check functions for coprocessor registers. */ +typedef CPAccessResult CPAccessFn (CPUARMState *env, +const ARMCPRegInfo *opaque, +bool isread); +/* Hook function for register reset */ +typedef void CPResetFn (CPUARMState *env,const ARMCPRegInfo *opaque); + +#define CP_ANY 0xff + +/* Definition of an ARM coprocessor register */ +struct ARMCPRegInfo { +/* Name of register (useful mainly for debugging, need not be unique) */ +const char *name; +/* +* Location of register: coprocessor number and (crn,crm,opc1,opc2) +* tuple. Any of crm, opc1 and opc2 may be CP_ANY to indicate a +* 'wildcard' field -- any value of that field in the MRC/MCR insn +* will be decoded to this register. The register read and write +* callbacks will be passed an ARMCPRegInfo with the crn/crm/opc1/opc2 +* used by the program, so it is possible to register a wildcard and +* then behave differently on read/write if necessary. +* For 64 bit registers, only crm and opc1 are relevant; crn and opc2 +* must both be zero. +* For AArch64-visible registers, opc0 is also used. +* Since there are no "coprocessors" in AArch64, cp is purely used as a +* way to distinguish (for KVM's benefit) guest-visible system registers +* from demuxed ones provided to preserve the "no side effects on +* KVM register read/write from QEMU" semantics. cp==0x13 is guest +* visible (to match KVM's encoding); cp==0 will be converted to +* cp==0x13 when the ARMCPRegInfo is registered, for convenience. +*/ +uint8_t cp; +uint8_t crn; +uint8_t crm; +uint8_t opc0; +uint8_t opc1; +uint8_t opc2; +/* Execution state in which this register is visible: ARM_CP_STATE_* */ +int state; +/* Register type: ARM_CP_* bits/values */ +int type; +/* Access rights: PL*_[RW] */ +int access; +/* Security state: ARM_CP_SECSTATE_* bits/values */ +int secure; +/* +* The opaque pointer passed to define_arm_cp_regs_with_opaque() when +* this register was defined: can be used to hand data through to the +* register read/write functions, since they are passed the ARMCPRegInfo*. +*/ +void *opaque; +/* +* Value of this register, if it is ARM_CP_CONST. Otherwise, if +* fieldoffset is non-zero, the reset value of the register. +*/ +uint64_t resetvalue; +/* +* Offset of the field in CPUARMState for this register. +* +* This is not needed if either: +* 1. type is ARM_CP_CONST or one of the ARM_CP_SPECIALs +* 2. both readfn and writefn are specified +*/ +ptrdiff_t fieldoffset;/* offsetof(CPUARMState, field) */ + +/* +* Offsets of the secure and non-secure fields in CPUARMState for the +* register if it is banked. These fields are only used during the static +* registration of a register. During hashing the bank associated +* with a given security state is copied to fieldoffset which is used from +* there on out. +* +* It is expected that register definitions use either fieldoffset or +* bank_fieldoffsets in the definition but not both. It is also expected +* that both bank offsets are set when defining a banked register. This +* use indicates that a register is banked. +*/ +ptrdiff_t bank_fieldoffsets[2 ]; + +/* +* Function for making any access checks for this register in addition to +* those specified by the 'access' permissions bits. If NULL, no extra +* checks required. The access check is performed at runtime, not at +* translate time. +*/ +CPAccessFn *accessfn; +/* +* Function for handling reads of this register. If NULL, then reads +* will be done by loading from the offset into CPUARMState specified +* by fieldoffset. +*/ +CPReadFn *readfn; +/* +* Function for handling writes of this register. If NULL, then writes +* will be done by writing to the offset into CPUARMState specified +* by fieldoffset. +*/ +CPWriteFn *writefn; +/* +* Function for doing a "raw" read; used when we need to copy +* coprocessor state to the kernel for KVM or out for +* migration. This only needs to be provided if there is also a +* readfn and it has side effects (for instance clear-on-read bits). +*/ +CPReadFn *raw_readfn; +/* +* Function for doing a "raw" write; used when we need to copy KVM +* kernel coprocessor state into userspace, or for inbound +* migration. This only needs to be provided if there is also a +* writefn and it masks out "unwritable" bits or has write-one-to-clear +* or similar behaviour. +*/ +CPWriteFn *raw_writefn; +/* +* Function for resetting the register. If NULL, then reset will be done +* by writing resetvalue to the field specified in fieldoffset. If +* fieldoffset is 0 then no reset will be done. +*/ +CPResetFn *resetfn; + +/* +* "Original" writefn and readfn. +* For ARMv8.1-VHE register aliases, we overwrite the read/write +* accessor functions of various EL1/EL0 to perform the runtime +* check for which sysreg should actually be modified, and then +* forwards the operation. Before overwriting the accessors, +* the original function is copied here, so that accesses that +* really do go to the EL1/EL0 version proceed normally. +* (The corresponding EL2 register is linked via opaque.) +*/ +CPReadFn *orig_readfn; +CPWriteFn *orig_writefn; +}; + +/* +* Macros which are lvalues for the field in CPUARMState for the +* ARMCPRegInfo *ri. +*/ +#define CPREG_FIELD32 (env, ri) \ + (*(uint32_t *)((char *)(env) + (ri)->fieldoffset)) +#define CPREG_FIELD64 (env, ri) \ + (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) + +#define REGINFO_SENTINEL { .type = ARM_CP_SENTINEL } + +void define_arm_cp_regs_with_opaque (ARMCPU *cpu, +const ARMCPRegInfo *regs,void *opaque); +void define_one_arm_cp_reg_with_opaque (ARMCPU *cpu, +const ARMCPRegInfo *regs,void *opaque); +static inline void define_arm_cp_regs (ARMCPU *cpu,const ARMCPRegInfo *regs) +{ +define_arm_cp_regs_with_opaque (cpu, regs,0 ); +} +static inline void define_one_arm_cp_reg (ARMCPU *cpu,const ARMCPRegInfo *regs) +{ +define_one_arm_cp_reg_with_opaque (cpu, regs,0 ); +} +const ARMCPRegInfo *get_arm_cp_reginfo (GHashTable *cpregs,uint32_t encoded_cp); + +/* +* Definition of an ARM co-processor register as viewed from +* userspace. This is used for presenting sanitised versions of +* registers to userspace when emulating the Linux AArch64 CPU +* ID/feature ABI (advertised as HWCAP_CPUID). +*/ +typedef struct ARMCPRegUserSpaceInfo { +/* Name of register */ +const char *name; + +/* Is the name actually a glob pattern */ +bool is_glob; + +/* Only some bits are exported to user space */ +uint64_t exported_bits; + +/* Fixed bits are applied after the mask */ +uint64_t fixed_bits; +}ARMCPRegUserSpaceInfo ; + +#define REGUSERINFO_SENTINEL { .name = NULL } + +/* CPWriteFn that can be used to implement writes-ignored behaviour */ +void arm_cp_write_ignore (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value); +/* CPReadFn that can be used for read-as-zero behaviour */ +uint64_t arm_cp_read_zero (CPUARMState *env,const ARMCPRegInfo *ri); + +/* +* CPResetFn that does nothing, for use if no reset is required even +* if fieldoffset is non zero. +*/ +void arm_cp_reset_ignore (CPUARMState *env,const ARMCPRegInfo *opaque); + +/* +* Return true if this reginfo struct's field in the cpu state struct +* is 64 bits wide. +*/ +static inline bool cpreg_field_is_64bit (const ARMCPRegInfo *ri) +{ +return (ri->state ==ARM_CP_STATE_AA64 ) || (ri->type &ARM_CP_64BIT ); +} + +static inline bool cp_access_ok (int current_el, +const ARMCPRegInfo *ri,int isread) +{ +return (ri->access >> ((current_el *2 ) + isread)) &1 ; +} + +/* Raw read of a coprocessor register (as needed for migration, etc) */ +uint64_t read_raw_cp_reg (CPUARMState *env,const ARMCPRegInfo *ri); + +#ifdef CONFIG_TCG +/* Modify ARMCPRegInfo for access from userspace. */ +void modify_arm_cp_regs (ARMCPRegInfo *regs,const ARMCPRegUserSpaceInfo *mods); +#endif + +/* +* default raw read/write of coprocessor register field, +* behavior if no other function defined, and not const. +*/ +uint64_t raw_read (CPUARMState *env,const ARMCPRegInfo *ri); +void raw_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value); + +#endif /* CPREGS_H */
target/arm/cpu.h +0 -480
492 lines not on this page · raw message
hw/arm/pxa2xx.c +1 -0
@@ -30,6 +30,7 @@#include "qemu/cutils.h" #include "qemu/log.h" #include "qom/object.h" +#include "cpregs.h" static struct { hwaddr io_base;
hw/arm/pxa2xx_pic.c +1 -0
@@ -17,6 +17,7 @@#include "hw/sysbus.h" #include "migration/vmstate.h" #include "qom/object.h" +#include "cpregs.h" #define ICIP 0x00/* Interrupt Controller IRQ Pending register */ #define ICMR 0x04/* Interrupt Controller Mask register */
hw/intc/arm_gicv3_cpuif.c +1 -0
@@ -19,6 +19,7 @@#include "gicv3_internal.h" #include "hw/irq.h" #include "cpu.h" +#include "cpregs.h" void gicv3_set_gicv3state (CPUState *cpu,GICv3CPUState *s) {
hw/intc/arm_gicv3_kvm.c +1 -0
@@ -31,6 +31,7 @@#include "vgic_common.h" #include "migration/blocker.h" #include "qom/object.h" +#include "cpregs.h" #ifdef DEBUG_GICV3_KVM #define DPRINTF (fmt, ...) \
target/arm/cpregs.c new file +380 -0
380 lines not on this page · raw message
target/arm/cpu.c +1 -0
@@ -26,6 +26,7 @@#include "qapi/error.h" #include "qapi/visitor.h" #include "cpu.h" +#include "cpregs.h" #ifdef CONFIG_TCG #include "hw/core/tcg-cpu-ops.h" #endif /* CONFIG_TCG */
target/arm/cpu64.c +1 -1
@@ -32,7 +32,7 @@#include "kvm_arm.h" #include "qapi/visitor.h" #include "hw/qdev-properties.h" - +#include "cpregs.h" #ifndef CONFIG_USER_ONLY static uint64_t a57_a53_l2ctlr_read (CPUARMState *env,const ARMCPRegInfo *ri)
target/arm/cpu_tcg.c +1 -0
@@ -18,6 +18,7 @@#if !defined(CONFIG_USER_ONLY )#include "hw/boards.h" #endif +#include "cpregs.h" /* CPU models. These are not needed for the AArch64 linux-user build. */ #if !defined(CONFIG_USER_ONLY ) || !defined(TARGET_AARCH64 )
target/arm/cpustate-list.c new file +146 -0
146 lines not on this page · raw message
target/arm/gdbstub.c +1 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" #include "exec/gdbstub.h" +#include "cpregs.h" typedef struct RegisterSysregXmlParam { CPUState *cs;
target/arm/machine.c +1 -0
@@ -5,6 +5,7 @@#include "kvm_arm.h" #include "internals.h" #include "migration/cpu.h" +#include "cpregs.h" static bool vfp_needed (void *opaque) {
target/arm/tcg/cpregs.c new file +7674 -0
1,403 lines not on this page · raw message
target/arm/tcg/helper.c +275 -8776
9,051 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.20.1
Part of the diff is not shown here. View the raw message.
PATCH v16 29/99 target/arm: move cpu definitions to common cpu module
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
--- target/arm/cpu-common.c | 41 +++++++++++++++++++++++++++++++++++++++++ target/arm/tcg/helper.c | 29 ----------------------------- target/arm/meson.build | 1 + 3 files changed, 42 insertions(+), 29 deletions(-) create mode 100644 target/arm/cpu-common.c
target/arm/cpu-common.c new file +41 -0
@@ -0,0 +1,41 @@ +/* +* ARM CPU common definitions +* +* This code is licensed under the GNU GPL v2 or later. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "qom/object.h" +#include "qapi/qapi-commands-machine-target.h" +#include "qapi/error.h" +#include "cpu.h" + +static void arm_cpu_add_definition (gpointer data,gpointer user_data) +{ +ObjectClass *oc = data; +CpuDefinitionInfoList **cpu_list = user_data; +CpuDefinitionInfo *info; +const char *typename; + + typename =object_class_get_name (oc); + info =g_malloc0 (sizeof (*info)); + info->name =g_strndup (typename, +strlen (typename) -strlen ("-" TYPE_ARM_CPU )); + info->q_typename =g_strdup (typename); + +QAPI_LIST_PREPEND (*cpu_list, info); +} + +CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) +{ +CpuDefinitionInfoList *cpu_list =NULL ; +GSList *list; + + list =object_class_get_list (TYPE_ARM_CPU , false); +g_slist_foreach (list, arm_cpu_add_definition, &cpu_list); +g_slist_free (list); + +return cpu_list; +}
target/arm/tcg/helper.c +0 -29
@@ -28,7 +28,6 @@#include "sysemu/kvm.h" #include "sysemu/tcg.h" #include "qemu/range.h" -#include "qapi/qapi-commands-machine-target.h" #include "qapi/error.h" #include "qemu/guest-random.h" #ifdef CONFIG_TCG
@@ -697,34 +696,6 @@ void arm_cpu_list(void)g_slist_free (list); } -static void arm_cpu_add_definition (gpointer data,gpointer user_data) -{ -ObjectClass *oc = data; -CpuDefinitionInfoList **cpu_list = user_data; -CpuDefinitionInfo *info; -const char *typename; - - typename =object_class_get_name (oc); - info =g_malloc0 (sizeof (*info)); - info->name =g_strndup (typename, -strlen (typename) -strlen ("-" TYPE_ARM_CPU )); - info->q_typename =g_strdup (typename); - -QAPI_LIST_PREPEND (*cpu_list, info); -} - -CpuDefinitionInfoList *qmp_query_cpu_definitions (Error **errp) -{ -CpuDefinitionInfoList *cpu_list =NULL ; -GSList *list; - - list =object_class_get_list (TYPE_ARM_CPU , false); -g_slist_foreach (list, arm_cpu_add_definition, &cpu_list); -g_slist_free (list); - -return cpu_list; -} -static int bad_mode_switch (CPUARMState *env,int mode,CPSRWriteType write_type) {/* Return true if it is not valid for us to switch to
target/arm/meson.build +1 -0
@@ -2,6 +2,7 @@ arm_ss = ss.source_set() arm_ss.add(files( 'cpregs.c', 'cpu.c', + 'cpu-common.c', 'cpu-mmu.c', 'cpustate-list.c', 'gdbstub.c',
Signature · 1 line
2.20.1
PATCH v16 30/99 target/arm: only perform TCG cpu and machine inits if TCG enabled
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
of note, cpreg lists were previously initialized by TCG first, and then thrown away and replaced with the data coming from KVM.
Now we just initialize once, either for TCG or for KVM.
--- target/arm/cpu.c | 32 ++++++++++++++++++-------------- target/arm/kvm.c | 18 +++++++++--------- target/arm/machine.c | 20 +++++++++++++------- 3 files changed, 40 insertions(+), 30 deletions(-)
target/arm/cpu.c +18 -14
@@ -435,9 +435,11 @@ static void arm_cpu_reset(DeviceState *dev) }#endif -hw_breakpoint_update_all (cpu); -hw_watchpoint_update_all (cpu); -arm_rebuild_hflags (env); +if (tcg_enabled ()) { +hw_breakpoint_update_all (cpu); +hw_watchpoint_update_all (cpu); +arm_rebuild_hflags (env); + } } static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
@@ -1318,6 +1320,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) } } +#ifdef CONFIG_TCG {uint64_t scale;
@@ -1343,7 +1346,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->gt_timer[GTIMER_HYPVIRT ] =timer_new (QEMU_CLOCK_VIRTUAL , scale, arm_gt_hvtimer_cb, cpu); } -#endif +#endif /* CONFIG_TCG */ +#endif /* !CONFIG_USER_ONLY */ cpu_exec_realizefn (cs, &local_err);if (local_err !=NULL ) {
@@ -1646,17 +1650,16 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)unset_feature (env,ARM_FEATURE_PMU ); }if (arm_feature (env,ARM_FEATURE_PMU )) { -pmu_init (cpu); - -if (!kvm_enabled ()) { +if (tcg_enabled ()) { +pmu_init (cpu);arm_register_pre_el_change_hook (cpu, &pmu_pre_el_change,0 );arm_register_el_change_hook (cpu, &pmu_post_el_change,0 ); - }#ifndef CONFIG_USER_ONLY - cpu->pmu_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , arm_pmu_timer_cb, - cpu); + cpu->pmu_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , arm_pmu_timer_cb, + cpu);#endif + } }else { cpu->isar.id_aa64dfr0 =FIELD_DP64 (cpu->isar.id_aa64dfr0,ID_AA64DFR0 ,PMUVER ,0 );
@@ -1739,10 +1742,11 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)set_feature (env,ARM_FEATURE_VBAR ); } -register_cp_regs_for_features (cpu); -arm_cpu_register_gdb_regs_for_features (cpu); - -init_cpreg_list (cpu); +if (tcg_enabled ()) { +register_cp_regs_for_features (cpu); +arm_cpu_register_gdb_regs_for_features (cpu); +init_cpreg_list (cpu); + }#ifndef CONFIG_USER_ONLY MachineState *ms =MACHINE (qdev_get_machine ());
target/arm/kvm.c +9 -9
@@ -431,9 +431,11 @@ static uint64_t *kvm_arm_get_cpreg_ptr(ARMCPU *cpu, uint64_t regidx)return &cpu->cpreg_values[res - cpu->cpreg_indexes]; } -/* Initialize the ARMCPU cpreg list according to the kernel's -* definition of what CPU registers it knows about (and throw away -* the previous TCG-created cpreg list). +/* +* Initialize the ARMCPU cpreg list according to the kernel's +* definition of what CPU registers it knows about. +* +* The parallel for TCG is init_cpreg_list() in tcg/ */ int kvm_arm_init_cpreg_list (ARMCPU *cpu) {
@@ -475,12 +477,10 @@ int kvm_arm_init_cpreg_list(ARMCPU *cpu) arraylen++; } - cpu->cpreg_indexes =g_renew (uint64_t, cpu->cpreg_indexes, arraylen); - cpu->cpreg_values =g_renew (uint64_t, cpu->cpreg_values, arraylen); - cpu->cpreg_vmstate_indexes =g_renew (uint64_t, cpu->cpreg_vmstate_indexes, - arraylen); - cpu->cpreg_vmstate_values =g_renew (uint64_t, cpu->cpreg_vmstate_values, - arraylen); + cpu->cpreg_indexes =g_new (uint64_t, arraylen); + cpu->cpreg_values =g_new (uint64_t, arraylen); + cpu->cpreg_vmstate_indexes =g_new (uint64_t, arraylen); + cpu->cpreg_vmstate_values =g_new (uint64_t, arraylen); cpu->cpreg_array_len = arraylen; cpu->cpreg_vmstate_array_len = arraylen;
target/arm/machine.c +13 -7
@@ -2,6 +2,7 @@#include "cpu.h" #include "qemu/error-report.h" #include "sysemu/kvm.h" +#include "sysemu/tcg.h" #include "kvm_arm.h" #include "internals.h" #include "migration/cpu.h"
@@ -635,7 +636,7 @@ static int cpu_pre_save(void *opaque) {ARMCPU *cpu = opaque; -if (!kvm_enabled ()) { +if (tcg_enabled ()) {pmu_op_start (&cpu->env); }
@@ -670,7 +671,7 @@ static int cpu_post_save(void *opaque) {ARMCPU *cpu = opaque; -if (!kvm_enabled ()) { +if (tcg_enabled ()) {pmu_op_finish (&cpu->env); }
@@ -689,7 +690,7 @@ static int cpu_pre_load(void *opaque)*/ env->irq_line_state =UINT32_MAX ; -if (!kvm_enabled ()) { +if (tcg_enabled ()) {pmu_op_start (&cpu->env); }
@@ -759,13 +760,13 @@ static int cpu_post_load(void *opaque, int version_id) } } -hw_breakpoint_update_all (cpu); -hw_watchpoint_update_all (cpu); +if (tcg_enabled ()) { +hw_breakpoint_update_all (cpu); +hw_watchpoint_update_all (cpu); -if (!kvm_enabled ()) {pmu_op_finish (&cpu->env); +arm_rebuild_hflags (&cpu->env); } -arm_rebuild_hflags (&cpu->env);return 0 ; }
@@ -815,8 +816,13 @@ const VMStateDescription vmstate_arm_cpu = {VMSTATE_UINT32 (env.exception.syndrome,ARMCPU ),VMSTATE_UINT32 (env.exception.fsr,ARMCPU ),VMSTATE_UINT64 (env.exception.vaddress,ARMCPU ), +#ifdef CONFIG_TCGVMSTATE_TIMER_PTR (gt_timer[GTIMER_PHYS ],ARMCPU ),VMSTATE_TIMER_PTR (gt_timer[GTIMER_VIRT ],ARMCPU ), +#else +VMSTATE_UNUSED (sizeof (QEMUTimer *)), + VMSTATE_UNUSED(sizeof(QEMUTimer *)), +#endif /* CONFIG_TCG */ { .name ="power_state" , .version_id = 0,
Signature · 1 line
2.20.1
PATCH v16 31/99 target/arm: tcg: add stubs for some helpers for non-tcg builds
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
this first armv7m one should go away with proper configuration changes (only enabling possible boards for KVM).
--- target/arm/tcg/tcg-stubs.c | 16 ++++++++++++++++ target/arm/tcg/meson.build | 3 +++ 2 files changed, 19 insertions(+) create mode 100644 target/arm/tcg/tcg-stubs.c
target/arm/tcg/tcg-stubs.c new file +16 -0
@@ -0,0 +1,16 @@ +/* +* QEMU ARM stubs for some TCG helper functions +* +* Copyright 2021 SUSE LLC +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#include "qemu/osdep.h" +#include "cpu.h" + +void write_v7m_exception (CPUARMState *env,uint32_t new_exc) +{ +g_assert_not_reached (); +}
target/arm/tcg/meson.build +3 -0
@@ -30,6 +30,9 @@ arm_ss.add(when: 'CONFIG_TCG', if_true: files( 'vfp_helper.c', 'crypto_helper.c', 'debug_helper.c', + +), if_false: files( + 'tcg-stubs.c', )) arm_ss.add(when: ['TARGET_AARCH64','CONFIG_TCG'], if_true: files(
Signature · 1 line
2.20.1
PATCH v16 32/99 target/arm: move cpsr_read, cpsr_write to cpu_common
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
we need as a result to move switch_mode too,
so we put an implementation into cpu_user and cpu_sysemu.
--- target/arm/cpu.h | 2 + target/arm/cpu-common.c | 192 +++++++++++++++++++++++++++++++++++ target/arm/cpu-sysemu.c | 30 ++++++ target/arm/cpu-user.c | 24 +++++ target/arm/tcg/helper.c | 220 ---------------------------------------- target/arm/meson.build | 3 + 6 files changed, 251 insertions(+), 220 deletions(-) create mode 100644 target/arm/cpu-user.c
target/arm/cpu.h +2 -0
@@ -1390,6 +1390,8 @@ typedef enum CPSRWriteType {void cpsr_write (CPUARMState *env,uint32_t val,uint32_t mask,CPSRWriteType write_type); +void switch_mode (CPUARMState *env,int mode); +/* Return the current xPSR value. */ static inline uint32_t xpsr_read (CPUARMState *env) {
target/arm/cpu-common.c +192 -0
205 lines not on this page · raw message
target/arm/cpu-sysemu.c +30 -0
@@ -103,3 +103,33 @@ bool arm_cpu_virtio_is_big_endian(CPUState *cs)cpu_synchronize_state (cs);return arm_cpu_data_is_big_endian (env); } + +void switch_mode (CPUARMState *env,int mode) +{ +int old_mode; +int i; + + old_mode = env->uncached_cpsr &CPSR_M ; +if (mode == old_mode) { +return ; + } + +if (old_mode ==ARM_CPU_MODE_FIQ ) { +memcpy (env->fiq_regs, env->regs +8 ,5 *sizeof (uint32_t )); +memcpy (env->regs +8 , env->usr_regs,5 *sizeof (uint32_t )); + }else if (mode ==ARM_CPU_MODE_FIQ ) { +memcpy (env->usr_regs, env->regs +8 ,5 *sizeof (uint32_t )); +memcpy (env->regs +8 , env->fiq_regs,5 *sizeof (uint32_t )); + } + + i =bank_number (old_mode); + env->banked_r13[i] = env->regs[13 ]; + env->banked_spsr[i] = env->spsr; + + i =bank_number (mode); + env->regs[13 ] = env->banked_r13[i]; + env->spsr = env->banked_spsr[i]; + + env->banked_r14[r14_bank_number (old_mode)] = env->regs[14 ]; + env->regs[14 ] = env->banked_r14[r14_bank_number (mode)]; +}
target/arm/cpu-user.c new file +24 -0
@@ -0,0 +1,24 @@ +/* +* ARM CPU user-mode only code +* +* This code is licensed under the GNU GPL v2 or later. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qom/object.h" +#include "qapi/qapi-commands-machine-target.h" +#include "qapi/error.h" +#include "cpu.h" +#include "internals.h" + +void switch_mode (CPUARMState *env,int mode) +{ +ARMCPU *cpu =env_archcpu (env); + +if (mode !=ARM_CPU_MODE_USR ) { +cpu_abort (CPU (cpu),"Tried to switch out of user mode\n" ); + } +}
target/arm/tcg/helper.c +0 -220
244 lines not on this page · raw message
target/arm/meson.build +3 -0
@@ -32,6 +32,9 @@ arm_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( )) arm_user_ss = ss.source_set() +arm_user_ss.add(files( + 'cpu-user.c', +)) subdir('tcg')
Signature · 1 line
2.20.1
PATCH v16 33/99 target/arm: add temporary stub for arm_rebuild_hflags
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
this should go away once the configuration and hw/arm is clean
--- hw/arm/boot.c | 5 ++++- target/arm/arm-powerctl.c | 8 +++++--- target/arm/tcg/tcg-stubs.c | 5 +++++ 3 files changed, 14 insertions(+), 4 deletions(-)
hw/arm/boot.c +4 -1
@@ -26,6 +26,7 @@#include "qemu/config-file.h" #include "qemu/option.h" #include "qemu/units.h" +#include "sysemu/tcg.h" /* Kernel boot protocol is specified in the kernel docs * Documentation/arm/Booting and Documentation/arm64/booting.txt
@@ -796,7 +797,9 @@ static void do_cpu_reset(void *opaque) info->secondary_cpu_reset_hook (cpu, info); } } -arm_rebuild_hflags (env); +if (tcg_enabled ()) { +arm_rebuild_hflags (env); + } } }
target/arm/arm-powerctl.c +5 -3
@@ -15,6 +15,7 @@#include "arm-powerctl.h" #include "qemu/log.h" #include "qemu/main-loop.h" +#include "sysemu/tcg.h" #ifndef DEBUG_ARM_POWERCTL #define DEBUG_ARM_POWERCTL 0
@@ -127,9 +128,10 @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state, target_cpu->env.regs[0 ] = info->context_id; } -/* CP15 update requires rebuilding hflags */ -arm_rebuild_hflags (&target_cpu->env); - +if (tcg_enabled ()) { +/* CP15 update requires rebuilding hflags */ +arm_rebuild_hflags (&target_cpu->env); + }/* Start the new CPU at the requested address */ cpu_set_pc (target_cpu_state, info->entry);
target/arm/tcg/tcg-stubs.c +5 -0
@@ -14,3 +14,8 @@ void write_v7m_exception(CPUARMState *env, uint32_t new_exc) {g_assert_not_reached (); } + +void arm_rebuild_hflags (CPUARMState *env) +{ +g_assert_not_reached (); +}
Signature · 1 line
2.20.1
PATCH v16 34/99 target/arm: move arm_hcr_el2_eff from tcg/ to common_cpu
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
we will need this for KVM too, especially for Nested support.
--- target/arm/cpu-common.c | 68 +++++++++++++++++++++++++++++++++++++++++ target/arm/tcg/helper.c | 68 ----------------------------------------- 2 files changed, 68 insertions(+), 68 deletions(-)
target/arm/cpu-common.c +68 -0
@@ -231,3 +231,71 @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, mask &= ~CACHED_CPSR_BITS ; env->uncached_cpsr = (env->uncached_cpsr & ~mask) | (val & mask); } + +/* +* Return the effective value of HCR_EL2. +* Bits that are not included here: +* RW (read from SCR_EL3.RW as needed) +*/ +uint64_t arm_hcr_el2_eff (CPUARMState *env) +{ +uint64_t ret = env->cp15.hcr_el2; + +if (!arm_is_el2_enabled (env)) { +/* +* "This register has no effect if EL2 is not enabled in the +* current Security state". This is ARMv8.4-SecEL2 speak for +* !(SCR_EL3.NS==1 || SCR_EL3.EEL2==1). +* +* Prior to that, the language was "In an implementation that +* includes EL3, when the value of SCR_EL3.NS is 0 the PE behaves +* as if this field is 0 for all purposes other than a direct +* read or write access of HCR_EL2". With lots of enumeration +* on a per-field basis. In current QEMU, this is condition +* is arm_is_secure_below_el3. +* +* Since the v8.4 language applies to the entire register, and +* appears to be backward compatible, use that. +*/ +return 0 ; + } + +/* +* For a cpu that supports both aarch64 and aarch32, we can set bits +* in HCR_EL2 (e.g. via EL3) that are RES0 when we enter EL2 as aa32. +* Ignore all of the bits in HCR+HCR2 that are not valid for aarch32. +*/ +if (!arm_el_is_aa64 (env,2 )) { +uint64_t aa32_valid; + +/* +* These bits are up-to-date as of ARMv8.6. +* For HCR, it's easiest to list just the 2 bits that are invalid. +* For HCR2, list those that are valid. +*/ + aa32_valid =MAKE_64BIT_MASK (0 ,32 ) & ~(HCR_RW |HCR_TDZ ); + aa32_valid |= (HCR_CD |HCR_ID |HCR_TERR |HCR_TEA |HCR_MIOCNCE | +HCR_TID4 |HCR_TICAB |HCR_TOCU |HCR_TTLBIS ); + ret &= aa32_valid; + } + +if (ret &HCR_TGE ) { +/* These bits are up-to-date as of ARMv8.6. */ +if (ret &HCR_E2H ) { + ret &= ~(HCR_VM |HCR_FMO |HCR_IMO |HCR_AMO | +HCR_BSU_MASK |HCR_DC |HCR_TWI |HCR_TWE | +HCR_TID0 |HCR_TID2 |HCR_TPCP |HCR_TPU | +HCR_TDZ |HCR_CD |HCR_ID |HCR_MIOCNCE | +HCR_TID4 |HCR_TICAB |HCR_TOCU |HCR_ENSCXT | +HCR_TTLBIS |HCR_TTLBOS |HCR_TID5 ); + }else { + ret |=HCR_FMO |HCR_IMO |HCR_AMO ; + } + ret &= ~(HCR_SWIO |HCR_PTW |HCR_VF |HCR_VI |HCR_VSE | +HCR_FB |HCR_TID1 |HCR_TID3 |HCR_TSC |HCR_TACR | +HCR_TSW |HCR_TTLB |HCR_TVM |HCR_HCD |HCR_TRVM | +HCR_TLOR ); + } + +return ret; +}
target/arm/tcg/helper.c +0 -68
74 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v16 35/99 target/arm: split vfp state setting from tcg helpers
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
cpu-vfp.c: vfp_get_fpsr and vfp_set_fpsr are needed also for KVM,
so create a new cpu-vfp.c
tcg/cpu-vfp.c: vfp_get_fpscr_from_host and vv are TCG-only, so we
move the implementation to tcg/cpu-vfp.c
--- target/arm/cpu-vfp.h | 29 +++++ target/arm/cpu-vfp.c | 97 +++++++++++++++++ target/arm/tcg/cpu-vfp.c | 146 +++++++++++++++++++++++++ target/arm/tcg/vfp_helper.c | 210 +----------------------------------- target/arm/meson.build | 1 + target/arm/tcg/meson.build | 1 + 6 files changed, 276 insertions(+), 208 deletions(-) create mode 100644 target/arm/cpu-vfp.h create mode 100644 target/arm/cpu-vfp.c create mode 100644 target/arm/tcg/cpu-vfp.c
target/arm/cpu-vfp.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* ARM VFP floating-point operations internals +* +* Copyright (c) 2003 Fabrice Bellard +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef CPU_VFP_H +#define CPU_VFP_H + +#include "qemu/osdep.h" +#include "cpu.h" + +uint32_t vfp_get_fpscr_from_host (CPUARMState *env); +void vfp_set_fpscr_to_host (CPUARMState *env,uint32_t val); + +#endif /* CPU_VFP_H */
target/arm/cpu-vfp.c new file +97 -0
97 lines not on this page · raw message
target/arm/tcg/cpu-vfp.c new file +146 -0
146 lines not on this page · raw message
target/arm/tcg/vfp_helper.c +2 -208
222 lines not on this page · raw message
target/arm/meson.build +1 -0
@@ -4,6 +4,7 @@ arm_ss.add(files( 'cpu.c', 'cpu-common.c', 'cpu-mmu.c', + 'cpu-vfp.c', 'cpustate-list.c', 'gdbstub.c', 'cpu_tcg.c',
target/arm/tcg/meson.build +1 -0
@@ -21,6 +21,7 @@ arm_ss.add(when: 'CONFIG_TCG', if_true: files( 'translate-vfp.c', 'helper.c', 'cpregs.c', + 'cpu-vfp.c', 'iwmmxt_helper.c', 'm_helper.c', 'neon_helper.c',
Signature · 1 line
2.20.1
PATCH v16 36/99 target/arm: move arm_mmu_idx* to cpu-mmu
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
--- target/arm/cpu-mmu.c | 95 +++++++++++++++++++++++++++++++++++++++++ target/arm/tcg/helper.c | 95 ----------------------------------------- 2 files changed, 95 insertions(+), 95 deletions(-)
target/arm/cpu-mmu.c +95 -0
@@ -122,3 +122,98 @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, .using64k = using64k, }; } + +/* Return the exception level we're running at if this is our mmu_idx */ +int arm_mmu_idx_to_el (ARMMMUIdx mmu_idx) +{ +if (mmu_idx &ARM_MMU_IDX_M ) { +return mmu_idx &ARM_MMU_IDX_M_PRIV ; + } + +switch (mmu_idx) { +case ARMMMUIdx_E10_0: +case ARMMMUIdx_E20_0: +case ARMMMUIdx_SE10_0: +case ARMMMUIdx_SE20_0: +return 0 ; +case ARMMMUIdx_E10_1: +case ARMMMUIdx_E10_1_PAN: +case ARMMMUIdx_SE10_1: +case ARMMMUIdx_SE10_1_PAN: +return 1 ; +case ARMMMUIdx_E2: +case ARMMMUIdx_E20_2: +case ARMMMUIdx_E20_2_PAN: +case ARMMMUIdx_SE2: +case ARMMMUIdx_SE20_2: +case ARMMMUIdx_SE20_2_PAN: +return 2 ; +case ARMMMUIdx_SE3: +return 3 ; +default : +g_assert_not_reached (); + } +} + +#ifndef CONFIG_TCG +ARMMMUIdx arm_v7m_mmu_idx_for_secstate (CPUARMState *env,bool secstate) +{ +g_assert_not_reached (); +} +#endif + +ARMMMUIdx arm_mmu_idx_el (CPUARMState *env,int el) +{ +ARMMMUIdx idx; +uint64_t hcr; + +if (arm_feature (env,ARM_FEATURE_M )) { +return arm_v7m_mmu_idx_for_secstate (env, env->v7m.secure); + } + +/* See ARM pseudo-function ELIsInHost. */ +switch (el) { +case 0 : + hcr =arm_hcr_el2_eff (env); +if ((hcr & (HCR_E2H |HCR_TGE )) == (HCR_E2H |HCR_TGE )) { + idx = ARMMMUIdx_E20_0; + }else { + idx = ARMMMUIdx_E10_0; + } +break ; +case 1 : +if (env->pstate &PSTATE_PAN ) { + idx = ARMMMUIdx_E10_1_PAN; + }else { + idx = ARMMMUIdx_E10_1; + } +break ; +case 2 : +/* Note that TGE does not apply at EL2. */ +if (arm_hcr_el2_eff (env) &HCR_E2H ) { +if (env->pstate &PSTATE_PAN ) { + idx = ARMMMUIdx_E20_2_PAN; + }else { + idx = ARMMMUIdx_E20_2; + } + }else { + idx = ARMMMUIdx_E2; + } +break ; +case 3 : +return ARMMMUIdx_SE3; +default : +g_assert_not_reached (); + } + +if (arm_is_secure_below_el3 (env)) { + idx &= ~ARM_MMU_IDX_A_NS ; + } + +return idx; +} + +ARMMMUIdx arm_mmu_idx (CPUARMState *env) +{ +return arm_mmu_idx_el (env,arm_current_el (env)); +}
target/arm/tcg/helper.c +0 -95
101 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v16 37/99 target/arm: move sve_zcr_len_for_el to common_cpu
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
it is required by arch-dump.c and cpu.c, so apparently we need this for KVM too
--- target/arm/cpu-common.c | 43 +++++++++++++++++++++++++++++++++++++++++ target/arm/tcg/helper.c | 33 ------------------------------- 2 files changed, 43 insertions(+), 33 deletions(-)
target/arm/cpu-common.c +43 -0
@@ -299,3 +299,46 @@ uint64_t arm_hcr_el2_eff(CPUARMState *env)return ret; } + +/* +* these are AARCH64-only, but due to the chain of dependencies, +* between HELPER prototypes, hflags, cpreg definitions and functions in +* tcg/ etc, it becomes incredibly messy to add what should be here: +* +* #ifdef TARGET_AARCH64 +*/ + +static uint32_t sve_zcr_get_valid_len (ARMCPU *cpu,uint32_t start_len) +{ +uint32_t end_len; + + end_len = start_len &=0xf ; +if (!test_bit (start_len, cpu->sve_vq_map)) { + end_len =find_last_bit (cpu->sve_vq_map, start_len); +assert (end_len < start_len); + } +return end_len; +} + +/* +* Given that SVE is enabled, return the vector length for EL. +*/ +uint32_t sve_zcr_len_for_el (CPUARMState *env,int el) +{ +ARMCPU *cpu =env_archcpu (env); +uint32_t zcr_len = cpu->sve_max_vq -1 ; + +if (el <=1 ) { + zcr_len =MIN (zcr_len,0xf & (uint32_t )env->vfp.zcr_el[1 ]); + } +if (el <=2 &&arm_feature (env,ARM_FEATURE_EL2 )) { + zcr_len =MIN (zcr_len,0xf & (uint32_t )env->vfp.zcr_el[2 ]); + } +if (arm_feature (env,ARM_FEATURE_EL3 )) { + zcr_len =MIN (zcr_len,0xf & (uint32_t )env->vfp.zcr_el[3 ]); + } + +return sve_zcr_get_valid_len (cpu, zcr_len); +} + +/* #endif TARGET_AARCH64 , see matching comment above */
target/arm/tcg/helper.c +0 -33
@@ -322,39 +322,6 @@ int sve_exception_el(CPUARMState *env, int el)return 0 ; } -static uint32_t sve_zcr_get_valid_len (ARMCPU *cpu,uint32_t start_len) -{ -uint32_t end_len; - - end_len = start_len &=0xf ; -if (!test_bit (start_len, cpu->sve_vq_map)) { - end_len =find_last_bit (cpu->sve_vq_map, start_len); -assert (end_len < start_len); - } -return end_len; -} - -/* -* Given that SVE is enabled, return the vector length for EL. -*/ -uint32_t sve_zcr_len_for_el (CPUARMState *env,int el) -{ -ARMCPU *cpu =env_archcpu (env); -uint32_t zcr_len = cpu->sve_max_vq -1 ; - -if (el <=1 ) { - zcr_len =MIN (zcr_len,0xf & (uint32_t )env->vfp.zcr_el[1 ]); - } -if (el <=2 &&arm_feature (env,ARM_FEATURE_EL2 )) { - zcr_len =MIN (zcr_len,0xf & (uint32_t )env->vfp.zcr_el[2 ]); - } -if (arm_feature (env,ARM_FEATURE_EL3 )) { - zcr_len =MIN (zcr_len,0xf & (uint32_t )env->vfp.zcr_el[3 ]); - } - -return sve_zcr_get_valid_len (cpu, zcr_len); -} -void hw_watchpoint_update (ARMCPU *cpu,int n) {CPUARMState *env = &cpu->env;
Signature · 1 line
2.20.1
Re: [PATCH v16 37/99] target/arm: move sve_zcr_len_for_el to common_cpu
Quoted 11 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
it is required by
arch-dump.candcpu.c, so apparently we need this for KVM tooSigned-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/cpu-common.c | 43 +++++++++++++++++++++++++++++++++++++++++ target/arm/tcg/helper.c | 33 ------------------------------- 2 files changed, 43 insertions(+), 33 deletions(-)
r~
PATCH v16 38/99 target/arm: move arm_sctlr away from tcg helpers
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
this function is used for kvm too, add it to the
cpu-common module.
--- target/arm/cpu-common.c | 11 +++++++++++ target/arm/tcg/helper.c | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-)
target/arm/cpu-common.c +11 -0
@@ -342,3 +342,14 @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) }/* #endif TARGET_AARCH64 , see matching comment above */ + +uint64_t arm_sctlr (CPUARMState *env,int el) +{ +/* Only EL0 needs to be adjusted for EL1&0 or EL2&0. */ +if (el ==0 ) { +ARMMMUIdx mmu_idx =arm_mmu_idx_el (env,0 ); + el = (mmu_idx == ARMMMUIdx_E20_0 || mmu_idx == ARMMMUIdx_SE20_0) + ?2 :1 ; + } +return env->cp15.sctlr_el[el]; +}
target/arm/tcg/helper.c +0 -11
@@ -1675,17 +1675,6 @@ void arm_cpu_do_interrupt(CPUState *cs) }#endif /* !CONFIG_USER_ONLY */ -uint64_t arm_sctlr (CPUARMState *env,int el) -{ -/* Only EL0 needs to be adjusted for EL1&0 or EL2&0. */ -if (el ==0 ) { -ARMMMUIdx mmu_idx =arm_mmu_idx_el (env,0 ); - el = (mmu_idx == ARMMMUIdx_E20_0 || mmu_idx == ARMMMUIdx_SE20_0) - ?2 :1 ; - } -return env->cp15.sctlr_el[el]; -} -/* Returns true if the stage 1 translation regime is using LPAE format page * tables. Used when raising alignment exceptions, whose FSR changes depending * on whether the long or short descriptor format is in use. */
Signature · 1 line
2.20.1
Re: [PATCH v16 38/99] target/arm: move arm_sctlr away from tcg helpers
Quoted 11 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
this function is used for kvm too, add it to the
cpu-common module.Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/cpu-common.c | 11 +++++++++++ target/arm/tcg/helper.c | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-)
r~
PATCH v16 39/99 target/arm: move arm_cpu_list to common_cpu
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
--- target/arm/cpu-common.c | 42 +++++++++++++++++++++++++++++++++++++++++ target/arm/tcg/helper.c | 41 ---------------------------------------- 2 files changed, 42 insertions(+), 41 deletions(-)
target/arm/cpu-common.c +42 -0
@@ -8,6 +8,7 @@#include "qemu/osdep.h" #include "qemu/log.h" +#include "qemu/qemu-print.h" #include "qom/object.h" #include "qapi/qapi-commands-machine-target.h" #include "qapi/error.h"
@@ -353,3 +354,44 @@ uint64_t arm_sctlr(CPUARMState *env, int el) }return env->cp15.sctlr_el[el]; } + +/* Sort alphabetically by type name, except for "any". */ +static gint arm_cpu_list_compare (gconstpointer a,gconstpointer b) +{ +ObjectClass *class_a = (ObjectClass *)a; +ObjectClass *class_b = (ObjectClass *)b; +const char *name_a, *name_b; + + name_a =object_class_get_name (class_a); + name_b =object_class_get_name (class_b); +if (strcmp (name_a,"any-" TYPE_ARM_CPU ) ==0 ) { +return 1 ; + }else if (strcmp (name_b,"any-" TYPE_ARM_CPU ) ==0 ) { +return -1 ; + }else { +return strcmp (name_a, name_b); + } +} + +static void arm_cpu_list_entry (gpointer data,gpointer user_data) +{ +ObjectClass *oc = data; +const char *typename; +char *name; + + typename =object_class_get_name (oc); + name =g_strndup (typename,strlen (typename) -strlen ("-" TYPE_ARM_CPU )); +qemu_printf (" %s\n" , name); +g_free (name); +} + +void arm_cpu_list (void ) +{ +GSList *list; + + list =object_class_get_list (TYPE_ARM_CPU , false); + list =g_slist_sort (list, arm_cpu_list_compare); +qemu_printf ("Available CPUs:\n" ); +g_slist_foreach (list, arm_cpu_list_entry,NULL ); +g_slist_free (list); +}
target/arm/tcg/helper.c +0 -41
47 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v16 40/99 target/arm: move aarch64_sync_32_to_64 (and vv) to cpu code
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
and arm_phys_excp_target_el since it is tied up inside the same #ifdef block.
aarch64_sync_32_to_64 and aarch64_sync_64_to_32 are mixed in with the TCG helpers, but they shouldn't, as they are needed for KVM too.
kvm_arch_get_registers()
{
if (!is_a64(env)) {
aarch64_sync_64_to_32(env);
}
write_kvmstate_to_list(cpu);
write_list_to_cpustate(cpu);
...
}kvm_arch_put_registers()
{
if (!is_a64(env)) {
aarch64_sync_32_to_64(env);
}
write_cpustate_to_list(cpu, true);
write_list_to_kvmstate(cpu, level)
...
}Move to the cpu module.
--- target/arm/cpu-sysemu.c | 215 +++++++++++++++++++++++++++++++++++++ target/arm/cpu-user.c | 11 ++ target/arm/tcg/helper.c | 232 +--------------------------------------- 3 files changed, 229 insertions(+), 229 deletions(-)
target/arm/cpu-sysemu.c +215 -0
@@ -133,3 +133,218 @@ void switch_mode(CPUARMState *env, int mode) env->banked_r14[r14_bank_number (old_mode)] = env->regs[14 ]; env->regs[14 ] = env->banked_r14[r14_bank_number (mode)]; } + +/* +* Function used to synchronize QEMU's AArch64 register set with AArch32 +* register set. This is necessary when switching between AArch32 and AArch64 +* execution state. +*/ +void aarch64_sync_32_to_64 (CPUARMState *env) +{ +int i; +uint32_t mode = env->uncached_cpsr &CPSR_M ; + +/* We can blanket copy R[0:7] to X[0:7] */ +for (i =0 ; i <8 ; i++) { + env->xregs[i] = env->regs[i]; + } + +/* +* Unless we are in FIQ mode, x8-x12 come from the user registers r8-r12. +* Otherwise, they come from the banked user regs. +*/ +if (mode ==ARM_CPU_MODE_FIQ ) { +for (i =8 ; i <13 ; i++) { + env->xregs[i] = env->usr_regs[i -8 ]; + } + }else { +for (i =8 ; i <13 ; i++) { + env->xregs[i] = env->regs[i]; + } + } + +/* +* Registers x13-x23 are the various mode SP and FP registers. Registers +* r13 and r14 are only copied if we are in that mode, otherwise we copy +* from the mode banked register. +*/ +if (mode ==ARM_CPU_MODE_USR || mode ==ARM_CPU_MODE_SYS ) { + env->xregs[13 ] = env->regs[13 ]; + env->xregs[14 ] = env->regs[14 ]; + }else { + env->xregs[13 ] = env->banked_r13[bank_number (ARM_CPU_MODE_USR )]; +/* HYP is an exception in that it is copied from r14 */ +if (mode ==ARM_CPU_MODE_HYP ) { + env->xregs[14 ] = env->regs[14 ]; + }else { + env->xregs[14 ] = env->banked_r14[r14_bank_number (ARM_CPU_MODE_USR )]; + } + } + +if (mode ==ARM_CPU_MODE_HYP ) { + env->xregs[15 ] = env->regs[13 ]; + }else { + env->xregs[15 ] = env->banked_r13[bank_number (ARM_CPU_MODE_HYP )]; + } + +if (mode ==ARM_CPU_MODE_IRQ ) { + env->xregs[16 ] = env->regs[14 ]; + env->xregs[17 ] = env->regs[13 ]; + }else { + env->xregs[16 ] = env->banked_r14[r14_bank_number (ARM_CPU_MODE_IRQ )]; + env->xregs[17 ] = env->banked_r13[bank_number (ARM_CPU_MODE_IRQ )]; + } + +if (mode ==ARM_CPU_MODE_SVC ) { + env->xregs[18 ] = env->regs[14 ]; + env->xregs[19 ] = env->regs[13 ]; + }else { + env->xregs[18 ] = env->banked_r14[r14_bank_number (ARM_CPU_MODE_SVC )]; + env->xregs[19 ] = env->banked_r13[bank_number (ARM_CPU_MODE_SVC )]; + } + +if (mode ==ARM_CPU_MODE_ABT ) { + env->xregs[20 ] = env->regs[14 ]; + env->xregs[21 ] = env->regs[13 ]; + }else { + env->xregs[20 ] = env->banked_r14[r14_bank_number (ARM_CPU_MODE_ABT )]; + env->xregs[21 ] = env->banked_r13[bank_number (ARM_CPU_MODE_ABT )]; + } + +if (mode ==ARM_CPU_MODE_UND ) { + env->xregs[22 ] = env->regs[14 ]; + env->xregs[23 ] = env->regs[13 ]; + }else { + env->xregs[22 ] = env->banked_r14[r14_bank_number (ARM_CPU_MODE_UND )]; + env->xregs[23 ] = env->banked_r13[bank_number (ARM_CPU_MODE_UND )]; + } + +/* +* Registers x24-x30 are mapped to r8-r14 in FIQ mode. If we are in FIQ +* mode, then we can copy from r8-r14. Otherwise, we copy from the +* FIQ bank for r8-r14. +*/ +if (mode ==ARM_CPU_MODE_FIQ ) { +for (i =24 ; i <31 ; i++) { + env->xregs[i] = env->regs[i -16 ];/* X[24:30] <- R[8:14] */ + } + }else { +for (i =24 ; i <29 ; i++) { + env->xregs[i] = env->fiq_regs[i -24 ]; + } + env->xregs[29 ] = env->banked_r13[bank_number (ARM_CPU_MODE_FIQ )]; + env->xregs[30 ] = env->banked_r14[r14_bank_number (ARM_CPU_MODE_FIQ )]; + } + + env->pc = env->regs[15 ]; +} + +/* +* Function used to synchronize QEMU's AArch32 register set with AArch64 +* register set. This is necessary when switching between AArch32 and AArch64 +* execution state. +*/ +void aarch64_sync_64_to_32 (CPUARMState *env) +{ +int i; +uint32_t mode = env->uncached_cpsr &CPSR_M ; + +/* We can blanket copy X[0:7] to R[0:7] */ +for (i =0 ; i <8 ; i++) { + env->regs[i] = env->xregs[i]; + } + +/* +* Unless we are in FIQ mode, r8-r12 come from the user registers x8-x12. +* Otherwise, we copy x8-x12 into the banked user regs. +*/ +if (mode ==ARM_CPU_MODE_FIQ ) { +for (i =8 ; i <13 ; i++) { + env->usr_regs[i -8 ] = env->xregs[i]; + } + }else { +for (i =8 ; i <13 ; i++) { + env->regs[i] = env->xregs[i]; + } + } + +/* +* Registers r13 & r14 depend on the current mode. +* If we are in a given mode, we copy the corresponding x registers to r13 +* and r14. Otherwise, we copy the x register to the banked r13 and r14 +* for the mode. +*/ +if (mode ==ARM_CPU_MODE_USR || mode ==ARM_CPU_MODE_SYS ) { + env->regs[13 ] = env->xregs[13 ]; + env->regs[14 ] = env->xregs[14 ]; + }else { + env->banked_r13[bank_number (ARM_CPU_MODE_USR )] = env->xregs[13 ]; + +/* +* HYP is an exception in that it does not have its own banked r14 but +* shares the USR r14 +*/ +if (mode ==ARM_CPU_MODE_HYP ) { + env->regs[14 ] = env->xregs[14 ]; + }else { + env->banked_r14[r14_bank_number (ARM_CPU_MODE_USR )] = env->xregs[14 ]; + } + } + +if (mode ==ARM_CPU_MODE_HYP ) { + env->regs[13 ] = env->xregs[15 ]; + }else { + env->banked_r13[bank_number (ARM_CPU_MODE_HYP )] = env->xregs[15 ]; + } + +if (mode ==ARM_CPU_MODE_IRQ ) { + env->regs[14 ] = env->xregs[16 ]; + env->regs[13 ] = env->xregs[17 ]; + }else { + env->banked_r14[r14_bank_number (ARM_CPU_MODE_IRQ )] = env->xregs[16 ]; + env->banked_r13[bank_number (ARM_CPU_MODE_IRQ )] = env->xregs[17 ]; + } + +if (mode ==ARM_CPU_MODE_SVC ) { + env->regs[14 ] = env->xregs[18 ]; + env->regs[13 ] = env->xregs[19 ]; + }else { + env->banked_r14[r14_bank_number (ARM_CPU_MODE_SVC )] = env->xregs[18 ]; + env->banked_r13[bank_number (ARM_CPU_MODE_SVC )] = env->xregs[19 ]; + } + +if (mode ==ARM_CPU_MODE_ABT ) { + env->regs[14 ] = env->xregs[20 ]; + env->regs[13 ] = env->xregs[21 ]; + }else { + env->banked_r14[r14_bank_number (ARM_CPU_MODE_ABT )] = env->xregs[20 ]; + env->banked_r13[bank_number (ARM_CPU_MODE_ABT )] = env->xregs[21 ]; + } + +if (mode ==ARM_CPU_MODE_UND ) { + env->regs[14 ] = env->xregs[22 ]; + env->regs[13 ] = env->xregs[23 ]; + }else { + env->banked_r14[r14_bank_number (ARM_CPU_MODE_UND )] = env->xregs[22 ]; + env->banked_r13[bank_number (ARM_CPU_MODE_UND )] = env->xregs[23 ]; + } + +/* +* Registers x24-x30 are mapped to r8-r14 in FIQ mode. If we are in FIQ +* mode, then we can copy to r8-r14. Otherwise, we copy to the +* FIQ bank for r8-r14. +*/ +if (mode ==ARM_CPU_MODE_FIQ ) { +for (i =24 ; i <31 ; i++) { + env->regs[i -16 ] = env->xregs[i];/* X[24:30] -> R[8:14] */ + } + }else { +for (i =24 ; i <29 ; i++) { + env->fiq_regs[i -24 ] = env->xregs[i]; + } + env->banked_r13[bank_number (ARM_CPU_MODE_FIQ )] = env->xregs[29 ]; + env->banked_r14[r14_bank_number (ARM_CPU_MODE_FIQ )] = env->xregs[30 ]; + } + + env->regs[15 ] = env->pc; +}
target/arm/cpu-user.c +11 -0
@@ -22,3 +22,14 @@ void switch_mode(CPUARMState *env, int mode)cpu_abort (CPU (cpu),"Tried to switch out of user mode\n" ); } } + +void aarch64_sync_64_to_32 (CPUARMState *env) +{ +g_assert_not_reached (); +} + +uint32_t arm_phys_excp_target_el (CPUState *cs,uint32_t excp_idx, +uint32_t cur_el,bool secure) +{ +return 1 ; +}
target/arm/tcg/helper.c +3 -229
245 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v16 41/99 target/arm: new cpu32 ARM 32 bit CPU Class
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
In the ARM CPU class hierarchy, the ancestor TYPE_ARM_CPU is fundamentally a 32 bit CPU Class. The child TYPE_AARCH64_CPU overrides the class to make it a 64 bit CPU Class.
Explicitly put the 32bit CPU Class implementation in a cpu32.c, along with the 32bit CPU Class model registration function.
In later changes, we will further split 32bit and 64bit code.
--- target/arm/cpu-qom.h | 3 -- target/arm/cpu32.h | 28 ++++++++++ target/arm/cpu.c | 55 ++----------------- target/arm/cpu32.c | 118 +++++++++++++++++++++++++++++++++++++++++ target/arm/cpu64.c | 2 +- target/arm/cpu_tcg.c | 3 +- target/arm/meson.build | 6 ++- 7 files changed, 159 insertions(+), 56 deletions(-) create mode 100644 target/arm/cpu32.h create mode 100644 target/arm/cpu32.c
target/arm/cpu-qom.h +0 -3
@@ -38,9 +38,6 @@ typedef struct ARMCPUInfo {void (*class_init)(ObjectClass *oc,void *data); } ARMCPUInfo; -void arm_cpu_register (const ARMCPUInfo *info); -void aarch64_cpu_register (const ARMCPUInfo *info); -/** * ARMCPUClass: * @parent_realize: The parent class' realize handler.
target/arm/cpu32.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* QEMU ARM CPU models (32bit) +* +* Copyright (c) 2012 SUSE LINUX Products GmbH +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see +* <http://www.gnu.org/licenses/gpl-2.0.html> +*/ + +#ifndef ARM_CPU32_H +#define ARM_CPU32_H + +void arm_cpu_dump_state (CPUState *cs,FILE *f,int flags); +void arm32_cpu_class_init (ObjectClass *oc,void *data); +void arm32_cpu_register (const ARMCPUInfo *info); + +#endif /* ARM_CPU32_H */
target/arm/cpu.c +5 -50
95 lines not on this page · raw message
target/arm/cpu32.c new file +118 -0
118 lines not on this page · raw message
target/arm/cpu64.c +1 -1
@@ -860,7 +860,7 @@ static void cpu_register_class_init(ObjectClass *oc, void *data) acc->info = data; } -void aarch64_cpu_register (const ARMCPUInfo *info) +static void aarch64_cpu_register (const ARMCPUInfo *info) {TypeInfo type_info = { .parent =TYPE_AARCH64_CPU ,
target/arm/cpu_tcg.c +2 -1
@@ -19,6 +19,7 @@#include "hw/boards.h" #endif #include "cpregs.h" +#include "cpu32.h" /* CPU models. These are not needed for the AArch64 linux-user build. */ #if !defined(CONFIG_USER_ONLY ) || !defined(TARGET_AARCH64 )
@@ -1072,7 +1073,7 @@ static void arm_tcg_cpu_register_types(void)type_register_static (&idau_interface_type_info);for (i =0 ; i <ARRAY_SIZE (arm_tcg_cpus); ++i) { -arm_cpu_register (&arm_tcg_cpus[i]); +arm32_cpu_register (&arm_tcg_cpus[i]); } }
target/arm/meson.build +5 -1
@@ -2,12 +2,12 @@ arm_ss = ss.source_set() arm_ss.add(files( 'cpregs.c', 'cpu.c', + 'cpu32.c', 'cpu-common.c', 'cpu-mmu.c', 'cpu-vfp.c', 'cpustate-list.c', 'gdbstub.c', - 'cpu_tcg.c', )) arm_ss.add(zlib)
@@ -18,6 +18,10 @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'gdbstub64.c', )) +arm_ss.add(when: 'CONFIG_TCG', if_true: files( + 'cpu_tcg.c', +)) + arm_softmmu_ss = ss.source_set() arm_softmmu_ss.add(files( 'arch_dump.c',
Signature · 1 line
2.20.1
Re: [PATCH v16 41/99] target/arm: new cpu32 ARM 32 bit CPU Class
Quoted 22 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
In the ARM CPU class hierarchy, the ancestor
TYPE_ARM_CPUis fundamentally a 32 bit CPU Class. The childTYPE_AARCH64_CPUoverrides the class to make it a 64 bit CPU Class.Explicitly put the 32bit CPU Class implementation in a
cpu32.c, along with the 32bit CPU Class model registration function.In later changes, we will further split 32bit and 64bit code.
Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/cpu-qom.h | 3 -- target/arm/cpu32.h | 28 ++++++++++ target/arm/cpu.c | 55 ++----------------- target/arm/cpu32.c | 118 +++++++++++++++++++++++++++++++++++++++++ target/arm/cpu64.c | 2 +- target/arm/cpu_tcg.c | 3 +- target/arm/meson.build | 6 ++- 7 files changed, 159 insertions(+), 56 deletions(-)
Quoted 2 lines
create mode 100644
target/arm/cpu32.h
create mode 100644target/arm/cpu32.c
r~
PATCH v16 42/99 target/arm: split 32bit and 64bit arm dump state
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
--- target/arm/cpu32.h | 2 +- target/arm/cpu.c | 225 --------------------------------------------- target/arm/cpu32.c | 85 ++++++++++++++++- target/arm/cpu64.c | 142 ++++++++++++++++++++++++++++ 4 files changed, 227 insertions(+), 227 deletions(-)
target/arm/cpu32.h +1 -1
@@ -21,7 +21,7 @@#ifndef ARM_CPU32_H #define ARM_CPU32_H -void arm_cpu_dump_state (CPUState *cs,FILE *f,int flags); +void arm32_cpu_dump_state (CPUState *cs,FILE *f,int flags);void arm32_cpu_class_init (ObjectClass *oc,void *data);void arm32_cpu_register (const ARMCPUInfo *info);
target/arm/cpu.c +0 -225
237 lines not on this page · raw message
target/arm/cpu32.c +84 -1
97 lines not on this page · raw message
target/arm/cpu64.c +142 -0
161 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH v16 42/99] target/arm: split 32bit and 64bit arm dump state
Quoted 10 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/cpu32.h | 2 +- target/arm/cpu.c | 225 --------------------------------------------- target/arm/cpu32.c | 85 ++++++++++++++++- target/arm/cpu64.c | 142 ++++++++++++++++++++++++++++ 4 files changed, 227 insertions(+), 227 deletions(-)
r~
PATCH v16 43/99 target/arm: move a15 cpu model away from the TCG-only models
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
Cortex-A15 is the only ARM cpu class we need in KVM too.
We will be able to move it to tcg/ once the board code and configurations are fixed.
--- target/arm/cpu32.h | 4 +++ target/arm/cpu32.c | 73 ++++++++++++++++++++++++++++++++++++++++++++ target/arm/cpu_tcg.c | 67 ---------------------------------------- 3 files changed, 77 insertions(+), 67 deletions(-)
target/arm/cpu32.h +4 -0
@@ -21,8 +21,12 @@#ifndef ARM_CPU32_H #define ARM_CPU32_H +#include "cpregs.h" +void arm32_cpu_dump_state (CPUState *cs,FILE *f,int flags);void arm32_cpu_class_init (ObjectClass *oc,void *data);void arm32_cpu_register (const ARMCPUInfo *info); +void cortex_a15_initfn (Object *obj); +extern const ARMCPRegInfo cortexa15_cp_reginfo[];#endif /* ARM_CPU32_H */
target/arm/cpu32.c +73 -0
81 lines not on this page · raw message
target/arm/cpu_tcg.c +0 -67
85 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH v16 43/99] target/arm: move a15 cpu model away from the TCG-only models
Quoted 7 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
Cortex-A15 is the only ARM cpu class we need in KVM too.
We will be able to move it to tcg/ once the board code and configurations are fixed.
Quoted 7 lines
Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/cpu32.h | 4 +++ target/arm/cpu32.c | 73 ++++++++++++++++++++++++++++++++++++++++++++ target/arm/cpu_tcg.c | 67 ---------------------------------------- 3 files changed, 77 insertions(+), 67 deletions(-)
I don't follow this one. Why would kvm, which is 64-bit only, require a 32-bit only cpu?
I guess I can accept that our board configurations are old and fragile, and I realize there are already 99 bottles of beer on^W^W^W^W patches here, but what needs to happen to fix this properly?
I guess I can give it an
if it helps us move forward.
r~
Re: [PATCH v16 43/99] target/arm: move a15 cpu model away from the TCG-only models
Quoted 14 lines · Richard Henderson
Quoted 5 lines · Alex Bennée
From: Claudio Fontana<[email protected]> Cortex-A15 is the only ARM cpu class we need in KVM too. We will be able to move it to tcg/ once the board code and configurations
are fixed.Quoted 7 lines
Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/cpu32.h | 4 +++ target/arm/cpu32.c | 73 ++++++++++++++++++++++++++++++++++++++++++++ target/arm/cpu_tcg.c | 67 ---------------------------------------- 3 files changed, 77 insertions(+), 67 deletions(-)
Quoted 6 lines
I don't follow this one. Why would kvm, which is 64-bit only, require a 32-bit only cpu?
I guess I can accept that our board configurations are old and fragile, and I realize there are already 99 bottles of beer on^W^W^W^W patches here, but what needs to happen to fix this properly?
I'll drop this and fix whatever we need to. 32 bit ARM KVM is listed in removed-features so I think we are good.
Quoted 8 lines
I guess I can give it an
if it helps us move forward.
r~
Signature · 1 line
Alex Bennée
Re: [PATCH v16 43/99] target/arm: move a15 cpu model away from the TCG-only models
Quoted 20 lines · Alex Bennée
Quoted 17 lines · Richard Henderson
Quoted 5 lines · Alex Bennée
From: Claudio Fontana<[email protected]> Cortex-A15 is the only ARM cpu class we need in KVM too. We will be able to move it to tcg/ once the board code and configurations
are fixed.Quoted 7 lines
Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/cpu32.h | 4 +++ target/arm/cpu32.c | 73 ++++++++++++++++++++++++++++++++++++++++++++ target/arm/cpu_tcg.c | 67 ---------------------------------------- 3 files changed, 77 insertions(+), 67 deletions(-)I don't follow this one. Why would kvm, which is 64-bit only, require a 32-bit only cpu?
Quoted 6 lines
Quoted 3 lines
I guess I can accept that our board configurations are old and fragile, and I realize there are already 99 bottles of beer on^W^W^W^W patches here, but what needs to happen to fix this properly?
I'll drop this and fix whatever we need to. 32 bit ARM KVM is listed in removed-features so I think we are good.
Problem is, if I recall correctly, that the virt board currently requires an a15 to exist.
Quoted 11 lines
Quoted 9 lines
I guess I can give it an
if it helps us move forward.
r~
PATCH v16 44/99 target/arm: fixup sve_exception_el code style before move
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
before moving over sve_exception_el from the helper code, cleanup the style.
--- target/arm/tcg/helper.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
target/arm/tcg/helper.c +6 -3
@@ -261,7 +261,8 @@ static int arm_gdb_set_svereg(CPUARMState *env, uint8_t *buf, int reg) }#endif /* TARGET_AARCH64 */ -/* Return the exception level to which exceptions should be taken +/* +* Return the exception level to which exceptions should be taken * via SVEAccessTrap. If an exception should be routed through * AArch64.AdvSIMDFPAccessTrap, return 0; fp_exception_el should * take care of raising that exception.
@@ -275,7 +276,8 @@ int sve_exception_el(CPUARMState *env, int el)if (el <=1 && (hcr_el2 & (HCR_E2H |HCR_TGE )) != (HCR_E2H |HCR_TGE )) {bool disabled = false; -/* The CPACR.ZEN controls traps to EL1: +/* +* The CPACR.ZEN controls traps to EL1: * 0, 2 : trap EL0 and EL1 accesses * 1 : trap only EL0 accesses * 3 : trap no accesses
@@ -301,7 +303,8 @@ int sve_exception_el(CPUARMState *env, int el) } } -/* CPTR_EL2. Since TZ and TFP are positive, +/* +* CPTR_EL2. Since TZ and TFP are positive, * they will be zero when EL2 is not present. */ if (el <=2 &&arm_is_el2_enabled (env)) {
Signature · 1 line
2.20.1
PATCH v16 45/99 target/arm: move sve_exception_el out of TCG helpers
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
we need this for KVM too.
--- target/arm/cpu-sysemu.c | 62 +++++++++++++++++++++++++++++++++++++++ target/arm/cpu-user.c | 5 ++++ target/arm/tcg/helper.c | 64 ----------------------------------------- 3 files changed, 67 insertions(+), 64 deletions(-)
target/arm/cpu-sysemu.c +62 -0
@@ -348,3 +348,65 @@ void aarch64_sync_64_to_32(CPUARMState *env) env->regs[15 ] = env->pc; } + +/* +* Return the exception level to which exceptions should be taken +* via SVEAccessTrap. If an exception should be routed through +* AArch64.AdvSIMDFPAccessTrap, return 0; fp_exception_el should +* take care of raising that exception. +* C.f. the ARM pseudocode function CheckSVEEnabled. +*/ +int sve_exception_el (CPUARMState *env,int el) +{ +uint64_t hcr_el2 =arm_hcr_el2_eff (env); + +if (el <=1 && (hcr_el2 & (HCR_E2H |HCR_TGE )) != (HCR_E2H |HCR_TGE )) { +bool disabled = false; + +/* +* The CPACR.ZEN controls traps to EL1: +* 0, 2 : trap EL0 and EL1 accesses +* 1 : trap only EL0 accesses +* 3 : trap no accesses +*/ +if (!extract32 (env->cp15.cpacr_el1,16 ,1 )) { + disabled = true; + }else if (!extract32 (env->cp15.cpacr_el1,17 ,1 )) { + disabled = el ==0 ; + } +if (disabled) { +/* route_to_el2 */ +return hcr_el2 &HCR_TGE ?2 :1 ; + } + +/* Check CPACR.FPEN. */ +if (!extract32 (env->cp15.cpacr_el1,20 ,1 )) { + disabled = true; + }else if (!extract32 (env->cp15.cpacr_el1,21 ,1 )) { + disabled = el ==0 ; + } +if (disabled) { +return 0 ; + } + } + +/* +* CPTR_EL2. Since TZ and TFP are positive, +* they will be zero when EL2 is not present. +*/ +if (el <=2 &&arm_is_el2_enabled (env)) { +if (env->cp15.cptr_el[2 ] &CPTR_TZ ) { +return 2 ; + } +if (env->cp15.cptr_el[2 ] &CPTR_TFP ) { +return 0 ; + } + } + +/* CPTR_EL3. Since EZ is negative we must check for EL3. */ +if (arm_feature (env,ARM_FEATURE_EL3 ) + && !(env->cp15.cptr_el[3 ] &CPTR_EZ )) { +return 3 ; + } +return 0 ; +}
target/arm/cpu-user.c +5 -0
@@ -33,3 +33,8 @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, {return 1 ; } + +int sve_exception_el (CPUARMState *env,int el) +{ +return 0 ; +}
target/arm/tcg/helper.c +0 -64
70 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v16 46/99 target/arm: fix comments style of fp_exception_el before moving it
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
--- target/arm/tcg/helper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
target/arm/tcg/helper.c +8 -4
@@ -1625,13 +1625,15 @@ uint32_t HELPER(crc32c)(uint32_t acc, uint32_t val, uint32_t bytes)return crc32c (acc, buf, bytes) ^0xffffffff ; } -/* Return the exception level to which FP-disabled exceptions should +/* +* Return the exception level to which FP-disabled exceptions should * be taken, or 0 if FP is enabled. */ int fp_exception_el (CPUARMState *env,int cur_el) {#ifndef CONFIG_USER_ONLY -/* CPACR and the CPTR registers don't exist before v6, so FP is +/* +* CPACR and the CPTR registers don't exist before v6, so FP is * always accessible */ if (!arm_feature (env,ARM_FEATURE_V6 )) {
@@ -1654,7 +1656,8 @@ int fp_exception_el(CPUARMState *env, int cur_el)return 0 ; } -/* The CPACR controls traps to EL1, or PL1 if we're 32 bit: +/* +* The CPACR controls traps to EL1, or PL1 if we're 32 bit: * 0, 2 : trap EL0 and EL1/PL1 accesses * 1 : trap only EL0 accesses * 3 : trap no accesses
@@ -1701,7 +1704,8 @@ int fp_exception_el(CPUARMState *env, int cur_el) } } -/* For the CPTR registers we don't need to guard with an ARM_FEATURE +/* +* For the CPTR registers we don't need to guard with an ARM_FEATURE * check because zero bits in the registers mean "don't trap". */
Signature · 1 line
2.20.1
Re: [PATCH v16 46/99] target/arm: fix comments style of fp_exception_el before moving it
Quoted 7 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/tcg/helper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
r~
PATCH v16 47/99 target/arm: move fp_exception_el out of TCG helpers
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
--- target/arm/cpu-sysemu.c | 100 ++++++++++++++++++++++++++++++++++++++++ target/arm/cpu-user.c | 5 ++ target/arm/tcg/helper.c | 100 ---------------------------------------- 3 files changed, 105 insertions(+), 100 deletions(-)
target/arm/cpu-sysemu.c +100 -0
@@ -410,3 +410,103 @@ int sve_exception_el(CPUARMState *env, int el) }return 0 ; } + +/* +* Return the exception level to which FP-disabled exceptions should +* be taken, or 0 if FP is enabled. +*/ +int fp_exception_el (CPUARMState *env,int cur_el) +{ +#ifndef CONFIG_USER_ONLY +/* +* CPACR and the CPTR registers don't exist before v6, so FP is +* always accessible +*/ +if (!arm_feature (env,ARM_FEATURE_V6 )) { +return 0 ; + } + +if (arm_feature (env,ARM_FEATURE_M )) { +/* CPACR can cause a NOCP UsageFault taken to current security state */ +if (!v7m_cpacr_pass (env, env->v7m.secure, cur_el !=0 )) { +return 1 ; + } + +if (arm_feature (env,ARM_FEATURE_M_SECURITY ) && !env->v7m.secure) { +if (!extract32 (env->v7m.nsacr,10 ,1 )) { +/* FP insns cause a NOCP UsageFault taken to Secure */ +return 3 ; + } + } + +return 0 ; + } + +/* +* The CPACR controls traps to EL1, or PL1 if we're 32 bit: +* 0, 2 : trap EL0 and EL1/PL1 accesses +* 1 : trap only EL0 accesses +* 3 : trap no accesses +* This register is ignored if E2H+TGE are both set. +*/ +if ((arm_hcr_el2_eff (env) & (HCR_E2H |HCR_TGE )) != (HCR_E2H |HCR_TGE )) { +int fpen =extract32 (env->cp15.cpacr_el1,20 ,2 ); + +switch (fpen) { +case 0 : +case 2 : +if (cur_el ==0 || cur_el ==1 ) { +/* Trap to PL1, which might be EL1 or EL3 */ +if (arm_is_secure (env) && !arm_el_is_aa64 (env,3 )) { +return 3 ; + } +return 1 ; + } +if (cur_el ==3 && !is_a64 (env)) { +/* Secure PL1 running at EL3 */ +return 3 ; + } +break ; +case 1 : +if (cur_el ==0 ) { +return 1 ; + } +break ; +case 3 : +break ; + } + } + +/* +* The NSACR allows A-profile AArch32 EL3 and M-profile secure mode +* to control non-secure access to the FPU. It doesn't have any +* effect if EL3 is AArch64 or if EL3 doesn't exist at all. +*/ +if ((arm_feature (env,ARM_FEATURE_EL3 ) && !arm_el_is_aa64 (env,3 ) && + cur_el <=2 && !arm_is_secure_below_el3 (env))) { +if (!extract32 (env->cp15.nsacr,10 ,1 )) { +/* FP insns act as UNDEF */ +return cur_el ==2 ?2 :1 ; + } + } + +/* +* For the CPTR registers we don't need to guard with an ARM_FEATURE +* check because zero bits in the registers mean "don't trap". +*/ + +/* CPTR_EL2 : present in v7VE or v8 */ +if (cur_el <=2 &&extract32 (env->cp15.cptr_el[2 ],10 ,1 ) + &&arm_is_el2_enabled (env)) { +/* Trap FP ops at EL2, NS-EL1 or NS-EL0 to EL2 */ +return 2 ; + } + +/* CPTR_EL3 : present in v8 */ +if (extract32 (env->cp15.cptr_el[3 ],10 ,1 )) { +/* Trap all FP ops to EL3 */ +return 3 ; + } +#endif +return 0 ; +}
target/arm/cpu-user.c +5 -0
@@ -38,3 +38,8 @@ int sve_exception_el(CPUARMState *env, int el) {return 0 ; } + +int fp_exception_el (CPUARMState *env,int el) +{ +return 0 ; +}
target/arm/tcg/helper.c +0 -100
106 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH v16 47/99] target/arm: move fp_exception_el out of TCG helpers
Quoted 16 lines · Alex Bennée
From: Claudio Fontana <[email protected]>
Signed-off-by Claudio Fontana <[email protected]>Signed-off-by Alex Bennée <[email protected]>--- target/arm/cpu-sysemu.c | 100 ++++++++++++++++++++++++++++++++++++++++ target/arm/cpu-user.c | 5 ++ target/arm/tcg/helper.c | 100 ---------------------------------------- 3 files changed, 105 insertions(+), 100 deletions(-)target/arm/cpu-sysemu.c +0
-0@@ -410,3 +410,103 @@ int sve_exception_el(CPUARMState *env, int el) }
target/arm/cpu-sysemu.c int sve_exception_el(CPUARMState *env, int el) · line 420
Quoted 10 lines
target/arm/cpu-sysemu.c +8
-0return 0 ; } + +/* +* Return the exception level to which FP-disabled exceptions should +* be taken, or 0 if FP is enabled. +*/ +int fp_exception_el (CPUARMState *env,int cur_el) +{ +#ifndef CONFIG_USER_ONLY
This is cpu-sysemu.c, you can remove the ifdefs. Otherwise,
r~
PATCH v16 48/99 target/arm: remove now useless ifndef from fp_exception_el
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
after moving the code of fp_exception_el to a sysemu-only module, we can remove the #ifndef CONFIG_USER_ONLY.
--- target/arm/cpu-sysemu.c | 2 -- 1 file changed, 2 deletions(-)
target/arm/cpu-sysemu.c +0 -2
@@ -417,7 +417,6 @@ int sve_exception_el(CPUARMState *env, int el)*/ int fp_exception_el (CPUARMState *env,int cur_el) { -#ifndef CONFIG_USER_ONLY /* * CPACR and the CPTR registers don't exist before v6, so FP is * always accessible
@@ -507,6 +506,5 @@ int fp_exception_el(CPUARMState *env, int cur_el)/* Trap all FP ops to EL3 */ return 3 ; } -#endif return 0 ; }
Signature · 1 line
2.20.1
Re: [PATCH v16 48/99] target/arm: remove now useless ifndef from fp_exception_el
Quoted 24 lines · Alex Bennée
From: Claudio Fontana <[email protected]>
after moving the code of
fp_exception_elto a sysemu-only module, we can remove the #ifndefCONFIG_USER_ONLY.Signed-off-by Claudio Fontana <[email protected]>Signed-off-by Alex Bennée <[email protected]>--- target/arm/cpu-sysemu.c | 2 -- 1 file changed, 2 deletions(-)target/arm/cpu-sysemu.c +0
-1@@ -417,7 +417,6 @@ int sve_exception_el(CPUARMState *env, int el)*/ int fp_exception_el (CPUARMState *env,int cur_el) { -#ifndef CONFIG_USER_ONLY /* * CPACR and the CPTR registers don't exist before v6, so FP is * always accessible
target/arm/cpu-sysemu.c int fp_exception_el(CPUARMState *env, int cur_el) · line 510
Quoted 6 lines
target/arm/cpu-sysemu.c +0
-1@@ -507,6 +506,5 @@ int fp_exception_el(CPUARMState *env, int cur_el)/* Trap all FP ops to EL3 */ return 3 ; } -#endif return 0 ; }
Ah, squash with previous. Just like was done in patch 45 with sve_exception_el while moving.
r~
PATCH v16 49/99 target/arm: make further preparation for the exception code to move
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
the exception code in tcg/ needs some adjustment before being exposed to KVM-only builds. We need to call arm_rebuild_hflags only when TCG is enabled, or we will error out.
The direct call to helper_rebuild_hflags_a64(env, new_el) will not be possible when extracting out to common code,
it seems safe to replace it with a call to arm_rebuild_hflags, since the write to pstate is already done.
Also, some CONFIG_TCG needs to be extended further, so that all the tcg-only code is marked as such.
--- target/arm/tcg/helper.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
target/arm/tcg/helper.c +9 -3
@@ -755,7 +755,9 @@ static void take_aarch32_exception(CPUARMState *env, int new_mode, env->regs[14 ] = env->regs[15 ] + offset; } env->regs[15 ] = newpc; -arm_rebuild_hflags (env); +if (tcg_enabled ()) { +arm_rebuild_hflags (env); + } }static void arm_cpu_do_interrupt_aarch32_hyp (CPUState *cs)
@@ -1242,7 +1244,11 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)pstate_write (env,PSTATE_DAIF | new_mode); env->aarch64 =1 ;aarch64_restore_sp (env, new_el); -helper_rebuild_hflags_a64 (env, new_el); + +if (tcg_enabled ()) { +/* pstate already written, so we can use arm_rebuild_hflags here */ +arm_rebuild_hflags (env); + } env->pc = addr;
@@ -1306,6 +1312,7 @@ void arm_cpu_do_interrupt(CPUState *cs) env->exception.syndrome); } +#ifdef CONFIG_TCG if (arm_is_psci_call (cpu, cs->exception_index)) {arm_handle_psci_call (cpu);qemu_log_mask (CPU_LOG_INT ,"...handled as PSCI call\n" );
@@ -1317,7 +1324,6 @@ void arm_cpu_do_interrupt(CPUState *cs)* that caused the exception, not the target exception level, so * must be handled here. */ -#ifdef CONFIG_TCG if (cs->exception_index ==EXCP_SEMIHOST ) {handle_semihosting (cs);return ;
Signature · 1 line
2.20.1
Re: [PATCH v16 49/99] target/arm: make further preparation for the exception code to move
Quoted 11 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
the exception code in tcg/ needs some adjustment before being exposed to KVM-only builds. We need to call
arm_rebuild_hflagsonly when TCG is enabled, or we will error out.The direct call to
helper_rebuild_hflags_a64(env, new_el)will not be possible when extracting out to common code,
it seems safe to replace it with a call toarm_rebuild_hflags, since the write to pstate is already done.
Quoted 8 lines
Also, some
CONFIG_TCGneeds to be extended further, so that all the tcg-only code is marked as such.Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/tcg/helper.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
r~
PATCH v16 50/99 target/arm: fix style of arm_cpu_do_interrupt functions before move
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
before refactoring the exception code, fix the style of the functions being moved.
--- target/arm/tcg/helper.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
target/arm/tcg/helper.c +11 -6
@@ -896,10 +896,11 @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs) new_mode =ARM_CPU_MODE_UND ; addr =0x04 ; mask =CPSR_I ; -if (env->thumb) +if (env->thumb) { offset =2 ; -else + }else { offset =4 ; + }break ;case EXCP_SWI : new_mode =ARM_CPU_MODE_SVC ;
@@ -985,7 +986,8 @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs)/* High vectors. When enabled, base address cannot be remapped. */ addr +=0xffff0000 ; }else { -/* ARM v7 architectures provide a vector base address register to remap +/* +* ARM v7 architectures provide a vector base address register to remap * the interrupt vector table. * This register is only followed in non-monitor mode, and is banked. * Note: only bits 31:5 are valid.
@@ -1094,7 +1096,8 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)aarch64_sve_change_el (env, cur_el, new_el,is_a64 (env));if (cur_el < new_el) { -/* Entry vector offset depends on whether the implemented EL +/* +* Entry vector offset depends on whether the implemented EL * immediately lower than the target level is using AArch32 or AArch64 */ bool is_aa64;
@@ -1285,7 +1288,8 @@ static void handle_semihosting(CPUState *cs) }#endif -/* Handle a CPU exception for A and R profile CPUs. +/* +* Handle a CPU exception for A and R profile CPUs. * Do any appropriate logging, handle PSCI calls, and then hand off * to the AArch64-entry or AArch32-entry function depending on the * target exception level's register width.
@@ -1330,7 +1334,8 @@ void arm_cpu_do_interrupt(CPUState *cs) }#endif -/* Hooks may change global state so BQL should be held, also the +/* +* Hooks may change global state so BQL should be held, also the * BQL needs to be held for any modification of * cs->interrupt_request. */
Signature · 1 line
2.20.1
PATCH v16 51/99 target/arm: move exception code out of tcg/helper.c
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
cpu-sysemu.c:
we need this sysemu code for KVM too, so we move the code to cpu-sysemu.c so we can reach a builable state.
There will be further split later on in dedicated exception modules for 32 and 64bit, after we make more necessary changes to be able to split TARGET_AARCH64-only code.
tcg/sysemu/tcg-cpu.c:
the TCG-specific code we put in tcg/sysemu/, in preparation for the addition of the tcg-cpu accel-cpu ARM subclass.
--- target/arm/tcg/tcg-cpu.h | 31 ++ target/arm/cpu-sysemu.c | 670 +++++++++++++++++++++++++++ target/arm/tcg/helper.c | 734 ------------------------------ target/arm/tcg/sysemu/tcg-cpu.c | 73 +++ target/arm/tcg/sysemu/meson.build | 1 + 5 files changed, 775 insertions(+), 734 deletions(-) create mode 100644 target/arm/tcg/tcg-cpu.h create mode 100644 target/arm/tcg/sysemu/tcg-cpu.c
target/arm/tcg/tcg-cpu.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* QEMU ARM CPU +* +* Copyright (c) 2012 SUSE LINUX Products GmbH +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see +* <http://www.gnu.org/licenses/gpl-2.0.html> +*/ +#ifndef ARM_TCG_CPU_H +#define ARM_TCG_CPU_H + +#include "cpu.h" + +#ifndef CONFIG_USER_ONLY +/* Do semihosting call and set the appropriate return value. */ +void handle_semihosting (CPUState *cs); + +#endif /* !CONFIG_USER_ONLY */ + +#endif /* ARM_TCG_CPU_H */
target/arm/cpu-sysemu.c +670 -0
683 lines not on this page · raw message
target/arm/tcg/helper.c +0 -734
753 lines not on this page · raw message
target/arm/tcg/sysemu/tcg-cpu.c new file +73 -0
73 lines not on this page · raw message
target/arm/tcg/sysemu/meson.build +1 -0
@@ -2,5 +2,6 @@ arm_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( 'debug_helper.c', 'm_helper.c', 'mte_helper.c', + 'tcg-cpu.c', 'tlb_helper.c', ))
Signature · 1 line
2.20.1
Re: [PATCH v16 51/99] target/arm: move exception code out of tcg/helper.c
Quoted 25 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
cpu-sysemu.c:we need this sysemu code for KVM too, so we move the code to
cpu-sysemu.cso we can reach a builable state.There will be further split later on in dedicated exception modules for 32 and 64bit, after we make more necessary changes to be able to split TARGET_AARCH64-only code.
tcg/sysemu/tcg-cpu.c:the TCG-specific code we put in tcg/sysemu/, in preparation for the addition of the tcg-cpu accel-cpu ARM subclass.
Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/tcg/tcg-cpu.h | 31 ++ target/arm/cpu-sysemu.c | 670 +++++++++++++++++++++++++++ target/arm/tcg/helper.c | 734 ------------------------------ target/arm/tcg/sysemu/tcg-cpu.c | 73 +++ target/arm/tcg/sysemu/meson.build | 1 + 5 files changed, 775 insertions(+), 734 deletions(-)
Quoted 2 lines
create mode 100644
target/arm/tcg/tcg-cpu.hcreate mode 100644target/arm/tcg/sysemu/tcg-cpu.c
r~
Re: [PATCH v16 51/99] target/arm: move exception code out of tcg/helper.c
In reply to Alex BennéeQuoted 47 lines · Alex Bennée
From: Claudio Fontana <[email protected]>
cpu-sysemu.c:we need this sysemu code for KVM too, so we move the code to
cpu-sysemu.cso we can reach a builable state.There will be further split later on in dedicated exception modules for 32 and 64bit, after we make more necessary changes to be able to split TARGET_AARCH64-only code.
tcg/sysemu/tcg-cpu.c:the TCG-specific code we put in tcg/sysemu/, in preparation for the addition of the tcg-cpu accel-cpu ARM subclass.
Signed-off-by Claudio Fontana <[email protected]>Signed-off-by Alex Bennée <[email protected]>--- target/arm/tcg/tcg-cpu.h | 31 ++ target/arm/cpu-sysemu.c | 670 +++++++++++++++++++++++++++ target/arm/tcg/helper.c | 734 ------------------------------ target/arm/tcg/sysemu/tcg-cpu.c | 73 +++ target/arm/tcg/sysemu/meson.build | 1 + 5 files changed, 775 insertions(+), 734 deletions(-)create mode 100644
target/arm/tcg/tcg-cpu.hcreate mode 100644target/arm/tcg/sysemu/tcg-cpu.ctarget/arm/tcg/tcg-cpu.h new file +13
-0@@ -0,0 +1,31 @@ +/* +* QEMU ARM CPU +* +* Copyright (c) 2012 SUSE LINUX Products GmbH +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
target/arm/tcg/tcg-cpu.h line 23
Quoted 10 lines
target/arm/tcg/tcg-cpu.h new file +10
-0+* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see +* <http://www.gnu.org/licenses/gpl-2.0.html> +*/ +#ifndef ARM_TCG_CPU_H +#define ARM_TCG_CPU_H + +#include "cpu.h"
I presume there's something later that requires this include?
target/arm/tcg/tcg-cpu.h line 27
Quoted 4 lines
target/arm/tcg/tcg-cpu.h new file +4
-0+ +#ifndef CONFIG_USER_ONLY +/* Do semihosting call and set the appropriate return value. */ +void handle_semihosting (CPUState *cs);
... because at present this typedef is already present, via "qemu/typedefs.h" via "qemu/osdep.h", which is always included first.
r`
Quoted 1,543 lines
target/arm/tcg/tcg-cpu.h new file +4
-0+ +#endif /* !CONFIG_USER_ONLY */ + +#endif /* ARM_TCG_CPU_H */ target/arm/cpu-sysemu.c +670
-0@@ -19,10 +19,14 @@*/ #include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/main-loop.h" #include "cpu.h" #include "internals.h" #include "sysemu/hw_accel.h" #include "kvm_arm.h" +#include "sysemu/tcg.h" +#include "tcg/tcg-cpu.h" void arm_cpu_set_irq (void *opaque,int irq,int level) {@@ -508,3 +512,669 @@ int fp_exception_el(CPUARMState *env, int cur_el) }return 0 ; } + +static void take_aarch32_exception (CPUARMState *env,int new_mode, +uint32_t mask,uint32_t offset, +uint32_t newpc) +{ +int new_el; + +/* Change the CPU state so as to actually take the exception. */ +switch_mode (env, new_mode); + +/* +* For exceptions taken to AArch32 we must clear the SS bit in both +* PSTATE and in the old-state value we save to SPSR_<mode>, so zero it now. +*/ + env->pstate &= ~PSTATE_SS ; + env->spsr =cpsr_read (env); +/* Clear IT bits. */ + env->condexec_bits =0 ; +/* Switch to the new mode, and to the correct instruction set. */ + env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M ) | new_mode; + +/* This must be after mode switching. */ + new_el =arm_current_el (env); + +/* Set new mode endianness */ + env->uncached_cpsr &= ~CPSR_E ; +if (env->cp15.sctlr_el[new_el] &SCTLR_EE ) { + env->uncached_cpsr |=CPSR_E ; + } +/* J and IL must always be cleared for exception entry */ + env->uncached_cpsr &= ~(CPSR_IL |CPSR_J ); + env->daif |= mask; + +if (new_mode ==ARM_CPU_MODE_HYP ) { + env->thumb = (env->cp15.sctlr_el[2 ] &SCTLR_TE ) !=0 ; + env->elr_el[2 ] = env->regs[15 ]; + }else { +/* CPSR.PAN is normally preserved preserved unless... */ +if (cpu_isar_feature (aa32_pan,env_archcpu (env))) { +switch (new_el) { +case 3 : +if (!arm_is_secure_below_el3 (env)) { +/* ... the target is EL3, from non-secure state. */ + env->uncached_cpsr &= ~CPSR_PAN ; +break ; + } +/* ... the target is EL3, from secure state ... */ +/* fall through */ +case 1 : +/* ... the target is EL1 and SCTLR.SPAN is 0. */ +if (!(env->cp15.sctlr_el[new_el] &SCTLR_SPAN )) { + env->uncached_cpsr |=CPSR_PAN ; + } +break ; + } + } +/* +* this is a lie, as there was no c1_sys on V4T/V5, but who cares +* and we should just guard the thumb mode on V4 +*/ +if (arm_feature (env,ARM_FEATURE_V4T )) { + env->thumb = + (A32_BANKED_CURRENT_REG_GET (env, sctlr) &SCTLR_TE ) !=0 ; + } + env->regs[14 ] = env->regs[15 ] + offset; + } + env->regs[15 ] = newpc; +if (tcg_enabled ()) { +arm_rebuild_hflags (env); + } +} + +static void arm_cpu_do_interrupt_aarch32_hyp (CPUState *cs) +{ +/* +* Handle exception entry to Hyp mode; this is sufficiently +* different to entry to other AArch32 modes that we handle it +* separately here. +* +* The vector table entry used is always the 0x14 Hyp mode entry point, +* unless this is an UNDEF/HVC/abort taken from Hyp to Hyp. +* The offset applied to the preferred return address is always zero +* (see DDI0487C.a section G1.12.3). +* PSTATE A/I/F masks are set based only on the SCR.EA/IRQ/FIQ values. +*/ +uint32_t addr, mask; +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; + +switch (cs->exception_index) { +case EXCP_UDEF : + addr =0x04 ; +break ; +case EXCP_SWI : + addr =0x14 ; +break ; +case EXCP_BKPT : +/* Fall through to prefetch abort. */ +case EXCP_PREFETCH_ABORT : + env->cp15.ifar_s = env->exception.vaddress; +qemu_log_mask (CPU_LOG_INT ,"...with HIFAR 0x%x\n" , + (uint32_t )env->exception.vaddress); + addr =0x0c ; +break ; +case EXCP_DATA_ABORT : + env->cp15.dfar_s = env->exception.vaddress; +qemu_log_mask (CPU_LOG_INT ,"...with HDFAR 0x%x\n" , + (uint32_t )env->exception.vaddress); + addr =0x10 ; +break ; +case EXCP_IRQ : + addr =0x18 ; +break ; +case EXCP_FIQ : + addr =0x1c ; +break ; +case EXCP_HVC : + addr =0x08 ; +break ; +case EXCP_HYP_TRAP : + addr =0x14 ; +break ; +default : +cpu_abort (cs,"Unhandled exception 0x%x\n" , cs->exception_index); + } + +if (cs->exception_index !=EXCP_IRQ && cs->exception_index !=EXCP_FIQ ) { +if (!arm_feature (env,ARM_FEATURE_V8 )) { +/* +* QEMU syndrome values are v8-style. v7 has the IL bit +* UNK/SBZP for "field not valid" cases, where v8 uses RES1. +* If this is a v7 CPU, squash the IL bit in those cases. +*/ +if (cs->exception_index ==EXCP_PREFETCH_ABORT || + (cs->exception_index ==EXCP_DATA_ABORT && + !(env->exception.syndrome &ARM_EL_ISV )) || +syn_get_ec (env->exception.syndrome) ==EC_UNCATEGORIZED ) { + env->exception.syndrome &= ~ARM_EL_IL ; + } + } + env->cp15.esr_el[2 ] = env->exception.syndrome; + } + +if (arm_current_el (env) !=2 && addr <0x14 ) { + addr =0x14 ; + } + + mask =0 ; +if (!(env->cp15.scr_el3 &SCR_EA )) { + mask |=CPSR_A ; + } +if (!(env->cp15.scr_el3 &SCR_IRQ )) { + mask |=CPSR_I ; + } +if (!(env->cp15.scr_el3 &SCR_FIQ )) { + mask |=CPSR_F ; + } + + addr += env->cp15.hvbar; + +take_aarch32_exception (env,ARM_CPU_MODE_HYP , mask,0 , addr); +} + +static void arm_cpu_do_interrupt_aarch32 (CPUState *cs) +{ +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; +uint32_t addr; +uint32_t mask; +int new_mode; +uint32_t offset; +uint32_t moe; + +/* If this is a debug exception we must update the DBGDSCR.MOE bits */ +switch (syn_get_ec (env->exception.syndrome)) { +case EC_BREAKPOINT : +case EC_BREAKPOINT_SAME_EL : + moe =1 ; +break ; +case EC_WATCHPOINT : +case EC_WATCHPOINT_SAME_EL : + moe =10 ; +break ; +case EC_AA32_BKPT : + moe =3 ; +break ; +case EC_VECTORCATCH : + moe =5 ; +break ; +default : + moe =0 ; +break ; + } + +if (moe) { + env->cp15.mdscr_el1 =deposit64 (env->cp15.mdscr_el1,2 ,4 , moe); + } + +if (env->exception.target_el ==2 ) { +arm_cpu_do_interrupt_aarch32_hyp (cs); +return ; + } + +switch (cs->exception_index) { +case EXCP_UDEF : + new_mode =ARM_CPU_MODE_UND ; + addr =0x04 ; + mask =CPSR_I ; +if (env->thumb) { + offset =2 ; + }else { + offset =4 ; + } +break ; +case EXCP_SWI : + new_mode =ARM_CPU_MODE_SVC ; + addr =0x08 ; + mask =CPSR_I ; +/* The PC already points to the next instruction. */ + offset =0 ; +break ; +case EXCP_BKPT : +/* Fall through to prefetch abort. */ +case EXCP_PREFETCH_ABORT : +A32_BANKED_CURRENT_REG_SET (env, ifsr, env->exception.fsr); +A32_BANKED_CURRENT_REG_SET (env, ifar, env->exception.vaddress); +qemu_log_mask (CPU_LOG_INT ,"...with IFSR 0x%x IFAR 0x%x\n" , + env->exception.fsr, (uint32_t )env->exception.vaddress); + new_mode =ARM_CPU_MODE_ABT ; + addr =0x0c ; + mask =CPSR_A |CPSR_I ; + offset =4 ; +break ; +case EXCP_DATA_ABORT : +A32_BANKED_CURRENT_REG_SET (env, dfsr, env->exception.fsr); +A32_BANKED_CURRENT_REG_SET (env, dfar, env->exception.vaddress); +qemu_log_mask (CPU_LOG_INT ,"...with DFSR 0x%x DFAR 0x%x\n" , + env->exception.fsr, + (uint32_t )env->exception.vaddress); + new_mode =ARM_CPU_MODE_ABT ; + addr =0x10 ; + mask =CPSR_A |CPSR_I ; + offset =8 ; +break ; +case EXCP_IRQ : + new_mode =ARM_CPU_MODE_IRQ ; + addr =0x18 ; +/* Disable IRQ and imprecise data aborts. */ + mask =CPSR_A |CPSR_I ; + offset =4 ; +if (env->cp15.scr_el3 &SCR_IRQ ) { +/* IRQ routed to monitor mode */ + new_mode =ARM_CPU_MODE_MON ; + mask |=CPSR_F ; + } +break ; +case EXCP_FIQ : + new_mode =ARM_CPU_MODE_FIQ ; + addr =0x1c ; +/* Disable FIQ, IRQ and imprecise data aborts. */ + mask =CPSR_A |CPSR_I |CPSR_F ; +if (env->cp15.scr_el3 &SCR_FIQ ) { +/* FIQ routed to monitor mode */ + new_mode =ARM_CPU_MODE_MON ; + } + offset =4 ; +break ; +case EXCP_VIRQ : + new_mode =ARM_CPU_MODE_IRQ ; + addr =0x18 ; +/* Disable IRQ and imprecise data aborts. */ + mask =CPSR_A |CPSR_I ; + offset =4 ; +break ; +case EXCP_VFIQ : + new_mode =ARM_CPU_MODE_FIQ ; + addr =0x1c ; +/* Disable FIQ, IRQ and imprecise data aborts. */ + mask =CPSR_A |CPSR_I |CPSR_F ; + offset =4 ; +break ; +case EXCP_SMC : + new_mode =ARM_CPU_MODE_MON ; + addr =0x08 ; + mask =CPSR_A |CPSR_I |CPSR_F ; + offset =0 ; +break ; +default : +cpu_abort (cs,"Unhandled exception 0x%x\n" , cs->exception_index); +return ;/* Never happens. Keep compiler happy. */ + } + +if (new_mode ==ARM_CPU_MODE_MON ) { + addr += env->cp15.mvbar; + }else if (A32_BANKED_CURRENT_REG_GET (env, sctlr) &SCTLR_V ) { +/* High vectors. When enabled, base address cannot be remapped. */ + addr +=0xffff0000 ; + }else { +/* +* ARM v7 architectures provide a vector base address register to remap +* the interrupt vector table. +* This register is only followed in non-monitor mode, and is banked. +* Note: only bits 31:5 are valid. +*/ + addr +=A32_BANKED_CURRENT_REG_GET (env, vbar); + } + +if ((env->uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_MON ) { + env->cp15.scr_el3 &= ~SCR_NS ; + } + +take_aarch32_exception (env, new_mode, mask, offset, addr); +} + +static int aarch64_regnum (CPUARMState *env,int aarch32_reg) +{ +/* +* Return the register number of the AArch64 view of the AArch32 +* register @aarch32_reg. The CPUARMState CPSR is assumed to still +* be that of the AArch32 mode the exception came from. +*/ +int mode = env->uncached_cpsr &CPSR_M ; + +switch (aarch32_reg) { + case 0 ... 7: +return aarch32_reg; + case 8 ... 12: +return mode ==ARM_CPU_MODE_FIQ ? aarch32_reg +16 : aarch32_reg; +case 13 : +switch (mode) { +case ARM_CPU_MODE_USR : +case ARM_CPU_MODE_SYS : +return 13 ; +case ARM_CPU_MODE_HYP : +return 15 ; +case ARM_CPU_MODE_IRQ : +return 17 ; +case ARM_CPU_MODE_SVC : +return 19 ; +case ARM_CPU_MODE_ABT : +return 21 ; +case ARM_CPU_MODE_UND : +return 23 ; +case ARM_CPU_MODE_FIQ : +return 29 ; +default : +g_assert_not_reached (); + } +case 14 : +switch (mode) { +case ARM_CPU_MODE_USR : +case ARM_CPU_MODE_SYS : +case ARM_CPU_MODE_HYP : +return 14 ; +case ARM_CPU_MODE_IRQ : +return 16 ; +case ARM_CPU_MODE_SVC : +return 18 ; +case ARM_CPU_MODE_ABT : +return 20 ; +case ARM_CPU_MODE_UND : +return 22 ; +case ARM_CPU_MODE_FIQ : +return 30 ; +default : +g_assert_not_reached (); + } +case 15 : +return 31 ; +default : +g_assert_not_reached (); + } +} + +static uint32_t cpsr_read_for_spsr_elx (CPUARMState *env) +{ +uint32_t ret =cpsr_read (env); + +/* Move DIT to the correct location for SPSR_ELx */ +if (ret &CPSR_DIT ) { + ret &= ~CPSR_DIT ; + ret |=PSTATE_DIT ; + } +/* Merge PSTATE.SS into SPSR_ELx */ + ret |= env->pstate &PSTATE_SS ; + +return ret; +} + +/* Handle exception entry to a target EL which is using AArch64 */ +static void arm_cpu_do_interrupt_aarch64 (CPUState *cs) +{ +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; +unsigned int new_el = env->exception.target_el; +target_ulong addr = env->cp15.vbar_el[new_el]; +unsigned int new_mode =aarch64_pstate_mode (new_el, true); +unsigned int old_mode; +unsigned int cur_el =arm_current_el (env); +int rt; + +/* +* Note that new_el can never be 0. If cur_el is 0, then +* el0_a64 is is_a64(), else el0_a64 is ignored. +*/ +aarch64_sve_change_el (env, cur_el, new_el,is_a64 (env)); + +if (cur_el < new_el) { +/* +* Entry vector offset depends on whether the implemented EL +* immediately lower than the target level is using AArch32 or AArch64 +*/ +bool is_aa64; +uint64_t hcr; + +switch (new_el) { +case 3 : + is_aa64 = (env->cp15.scr_el3 &SCR_RW ) !=0 ; +break ; +case 2 : + hcr =arm_hcr_el2_eff (env); +if ((hcr & (HCR_E2H |HCR_TGE )) != (HCR_E2H |HCR_TGE )) { + is_aa64 = (hcr &HCR_RW ) !=0 ; +break ; + } +/* fall through */ +case 1 : + is_aa64 =is_a64 (env); +break ; +default : +g_assert_not_reached (); + } + +if (is_aa64) { + addr +=0x400 ; + }else { + addr +=0x600 ; + } + }else if (pstate_read (env) &PSTATE_SP ) { + addr +=0x200 ; + } + +switch (cs->exception_index) { +case EXCP_PREFETCH_ABORT : +case EXCP_DATA_ABORT : + env->cp15.far_el[new_el] = env->exception.vaddress; +qemu_log_mask (CPU_LOG_INT ,"...with FAR 0x%" PRIx64"\n" , + env->cp15.far_el[new_el]); +/* fall through */ +case EXCP_BKPT : +case EXCP_UDEF : +case EXCP_SWI : +case EXCP_HVC : +case EXCP_HYP_TRAP : +case EXCP_SMC : +switch (syn_get_ec (env->exception.syndrome)) { +case EC_ADVSIMDFPACCESSTRAP : +/* +* QEMU internal FP/SIMD syndromes from AArch32 include the +* TA and coproc fields which are only exposed if the exception +* is taken to AArch32 Hyp mode. Mask them out to get a valid +* AArch64 format syndrome. +*/ + env->exception.syndrome &= ~MAKE_64BIT_MASK (0 ,20 ); +break ; +case EC_CP14RTTRAP : +case EC_CP15RTTRAP : +case EC_CP14DTTRAP : +/* +* For a trap on AArch32 MRC/MCR/LDC/STC the Rt field is currently +* the raw register field from the insn; when taking this to +* AArch64 we must convert it to the AArch64 view of the register +* number. Notice that we read a 4-bit AArch32 register number and +* write back a 5-bit AArch64 one. +*/ + rt =extract32 (env->exception.syndrome,5 ,4 ); + rt =aarch64_regnum (env, rt); + env->exception.syndrome =deposit32 (env->exception.syndrome, +5 ,5 , rt); +break ; +case EC_CP15RRTTRAP : +case EC_CP14RRTTRAP : +/* Similarly for MRRC/MCRR traps for Rt and Rt2 fields */ + rt =extract32 (env->exception.syndrome,5 ,4 ); + rt =aarch64_regnum (env, rt); + env->exception.syndrome =deposit32 (env->exception.syndrome, +5 ,5 , rt); + rt =extract32 (env->exception.syndrome,10 ,4 ); + rt =aarch64_regnum (env, rt); + env->exception.syndrome =deposit32 (env->exception.syndrome, +10 ,5 , rt); +break ; + } + env->cp15.esr_el[new_el] = env->exception.syndrome; +break ; +case EXCP_IRQ : +case EXCP_VIRQ : + addr +=0x80 ; +break ; +case EXCP_FIQ : +case EXCP_VFIQ : + addr +=0x100 ; +break ; +default : +cpu_abort (cs,"Unhandled exception 0x%x\n" , cs->exception_index); + } + +if (is_a64 (env)) { + old_mode =pstate_read (env); +aarch64_save_sp (env,arm_current_el (env)); + env->elr_el[new_el] = env->pc; + }else { + old_mode =cpsr_read_for_spsr_elx (env); + env->elr_el[new_el] = env->regs[15 ]; + +aarch64_sync_32_to_64 (env); + + env->condexec_bits =0 ; + } + env->banked_spsr[aarch64_banked_spsr_index (new_el)] = old_mode; + +qemu_log_mask (CPU_LOG_INT ,"...with ELR 0x%" PRIx64"\n" , + env->elr_el[new_el]); + +if (cpu_isar_feature (aa64_pan, cpu)) { +/* The value of PSTATE.PAN is normally preserved, except when ... */ + new_mode |= old_mode &PSTATE_PAN ; +switch (new_el) { +case 2 : +/* ... the target is EL2 with HCR_EL2.{E2H,TGE} == '11' ... */ +if ((arm_hcr_el2_eff (env) & (HCR_E2H |HCR_TGE )) + != (HCR_E2H |HCR_TGE )) { +break ; + } +/* fall through */ +case 1 : +/* ... the target is EL1 ... */ +/* ... and SCTLR_ELx.SPAN == 0, then set to 1. */ +if ((env->cp15.sctlr_el[new_el] &SCTLR_SPAN ) ==0 ) { + new_mode |=PSTATE_PAN ; + } +break ; + } + } +if (cpu_isar_feature (aa64_mte, cpu)) { + new_mode |=PSTATE_TCO ; + } + +pstate_write (env,PSTATE_DAIF | new_mode); + env->aarch64 =1 ; +aarch64_restore_sp (env, new_el); + +if (tcg_enabled ()) { +/* pstate already written, so we can use arm_rebuild_hflags here */ +arm_rebuild_hflags (env); + } + + env->pc = addr; + +qemu_log_mask (CPU_LOG_INT ,"...to EL%d PC 0x%" PRIx64" PSTATE 0x%x\n" , + new_el, env->pc,pstate_read (env)); +} + +void arm_log_exception (int idx) +{ +if (qemu_loglevel_mask (CPU_LOG_INT )) { +const char *exc =NULL ; +static const char *const excnames[] = { + [EXCP_UDEF ] ="Undefined Instruction" , + [EXCP_SWI ] ="SVC" , + [EXCP_PREFETCH_ABORT ] ="Prefetch Abort" , + [EXCP_DATA_ABORT ] ="Data Abort" , + [EXCP_IRQ ] ="IRQ" , + [EXCP_FIQ ] ="FIQ" , + [EXCP_BKPT ] ="Breakpoint" , + [EXCP_EXCEPTION_EXIT ] ="QEMU v7M exception exit" , + [EXCP_KERNEL_TRAP ] ="QEMU intercept of kernel commpage" , + [EXCP_HVC ] ="Hypervisor Call" , + [EXCP_HYP_TRAP ] ="Hypervisor Trap" , + [EXCP_SMC ] ="Secure Monitor Call" , + [EXCP_VIRQ ] ="Virtual IRQ" , + [EXCP_VFIQ ] ="Virtual FIQ" , + [EXCP_SEMIHOST ] ="Semihosting call" , + [EXCP_NOCP ] ="v7M NOCP UsageFault" , + [EXCP_INVSTATE ] ="v7M INVSTATE UsageFault" , + [EXCP_STKOF ] ="v8M STKOF UsageFault" , + [EXCP_LAZYFP ] ="v7M exception during lazy FP stacking" , + [EXCP_LSERR ] ="v8M LSERR UsageFault" , + [EXCP_UNALIGNED ] ="v7M UNALIGNED UsageFault" , + }; + +if (idx >=0 && idx <ARRAY_SIZE (excnames)) { + exc = excnames[idx]; + } +if (!exc) { + exc ="unknown" ; + } +qemu_log_mask (CPU_LOG_INT ,"Taking exception %d [%s]\n" , idx, exc); + } +} + +/* +* Handle a CPU exception for A and R profile CPUs. +* Do any appropriate logging, handle PSCI calls, and then hand off +* to the AArch64-entry or AArch32-entry function depending on the +* target exception level's register width. +* +* Note: this is used for both TCG (as the do_interrupt tcg op), +* and KVM to re-inject guest debug exceptions, and to +* inject a Synchronous-External-Abort. +*/ +void arm_cpu_do_interrupt (CPUState *cs) +{ +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; +unsigned int new_el = env->exception.target_el; + +assert (!arm_feature (env,ARM_FEATURE_M )); + +arm_log_exception (cs->exception_index); +qemu_log_mask (CPU_LOG_INT ,"...from EL%d to EL%d\n" ,arm_current_el (env), + new_el); +if (qemu_loglevel_mask (CPU_LOG_INT ) + && !excp_is_internal (cs->exception_index)) { +qemu_log_mask (CPU_LOG_INT ,"...with ESR 0x%x/0x%" PRIx32"\n" , +syn_get_ec (env->exception.syndrome), + env->exception.syndrome); + } + +#ifdef CONFIG_TCG +if (arm_is_psci_call (cpu, cs->exception_index)) { +arm_handle_psci_call (cpu); +qemu_log_mask (CPU_LOG_INT ,"...handled as PSCI call\n" ); +return ; + } +/* +* Semihosting semantics depend on the register width of the code +* that caused the exception, not the target exception level, so +* must be handled here. +*/ +if (cs->exception_index ==EXCP_SEMIHOST ) { +handle_semihosting (cs); +return ; + } +#endif /* CONFIG_TCG */ +/* +* Hooks may change global state so BQL should be held, also the +* BQL needs to be held for any modification of +* cs->interrupt_request. +*/ +g_assert (qemu_mutex_iothread_locked ()); +arm_call_pre_el_change_hook (cpu); + +assert (!excp_is_internal (cs->exception_index)); +if (arm_el_is_aa64 (env, new_el)) { +arm_cpu_do_interrupt_aarch64 (cs); + }else { +arm_cpu_do_interrupt_aarch32 (cs); + } + +arm_call_el_change_hook (cpu); + +if (tcg_enabled ()) { + cs->interrupt_request |=CPU_INTERRUPT_EXITTB ; + } +}target/arm/tcg/helper.c +0
-734@@ -7,34 +7,13 @@*/ #include "qemu/osdep.h" -#include "qemu/units.h" -#include "target/arm/idau.h" -#include "trace.h" #include "cpu.h" #include "internals.h" #include "exec/gdbstub.h" #include "exec/helper-proto.h" -#include "qemu/host-utils.h" -#include "qemu/main-loop.h" -#include "qemu/bitops.h" #include "qemu/crc32c.h" -#include "qemu/qemu-print.h" -#include "exec/exec-all.h" #include <zlib.h> /* For crc32 */ -#include "hw/irq.h" -#include "semihosting/semihost.h" -#include "sysemu/cpus.h" -#include "sysemu/cpu-timers.h" -#include "sysemu/kvm.h" -#include "sysemu/tcg.h" -#include "qemu/range.h" -#include "qapi/error.h" -#include "qemu/guest-random.h" -#ifdef CONFIG_TCG #include "arm_ldst.h" -#include "exec/cpu_ldst.h" -#include "semihosting/common-semi.h" -#endif #include "cpu-mmu.h" #include "cpregs.h" @@ -643,719 +622,6 @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, return target_el; } -void arm_log_exception (int idx) -{ -if (qemu_loglevel_mask (CPU_LOG_INT )) { -const char *exc =NULL ; -static const char *const excnames[] = { - [EXCP_UDEF ] ="Undefined Instruction" , - [EXCP_SWI ] ="SVC" , - [EXCP_PREFETCH_ABORT ] ="Prefetch Abort" , - [EXCP_DATA_ABORT ] ="Data Abort" , - [EXCP_IRQ ] ="IRQ" , - [EXCP_FIQ ] ="FIQ" , - [EXCP_BKPT ] ="Breakpoint" , - [EXCP_EXCEPTION_EXIT ] ="QEMU v7M exception exit" , - [EXCP_KERNEL_TRAP ] ="QEMU intercept of kernel commpage" , - [EXCP_HVC ] ="Hypervisor Call" , - [EXCP_HYP_TRAP ] ="Hypervisor Trap" , - [EXCP_SMC ] ="Secure Monitor Call" , - [EXCP_VIRQ ] ="Virtual IRQ" , - [EXCP_VFIQ ] ="Virtual FIQ" , - [EXCP_SEMIHOST ] ="Semihosting call" , - [EXCP_NOCP ] ="v7M NOCP UsageFault" , - [EXCP_INVSTATE ] ="v7M INVSTATE UsageFault" , - [EXCP_STKOF ] ="v8M STKOF UsageFault" , - [EXCP_LAZYFP ] ="v7M exception during lazy FP stacking" , - [EXCP_LSERR ] ="v8M LSERR UsageFault" , - [EXCP_UNALIGNED ] ="v7M UNALIGNED UsageFault" , - }; - -if (idx >=0 && idx <ARRAY_SIZE (excnames)) { - exc = excnames[idx]; - } -if (!exc) { - exc ="unknown" ; - } -qemu_log_mask (CPU_LOG_INT ,"Taking exception %d [%s]\n" , idx, exc); - } -} - -static void take_aarch32_exception (CPUARMState *env,int new_mode, -uint32_t mask,uint32_t offset, -uint32_t newpc) -{ -int new_el; - -/* Change the CPU state so as to actually take the exception. */ -switch_mode (env, new_mode); - -/* -* For exceptions taken to AArch32 we must clear the SS bit in both -* PSTATE and in the old-state value we save to SPSR_<mode>, so zero it now. -*/ - env->pstate &= ~PSTATE_SS ; - env->spsr =cpsr_read (env); -/* Clear IT bits. */ - env->condexec_bits =0 ; -/* Switch to the new mode, and to the correct instruction set. */ - env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M ) | new_mode; - -/* This must be after mode switching. */ - new_el =arm_current_el (env); - -/* Set new mode endianness */ - env->uncached_cpsr &= ~CPSR_E ; -if (env->cp15.sctlr_el[new_el] &SCTLR_EE ) { - env->uncached_cpsr |=CPSR_E ; - } -/* J and IL must always be cleared for exception entry */ - env->uncached_cpsr &= ~(CPSR_IL |CPSR_J ); - env->daif |= mask; - -if (cpu_isar_feature (aa32_ssbs,env_archcpu (env))) { -if (env->cp15.sctlr_el[new_el] &SCTLR_DSSBS_32 ) { - env->uncached_cpsr |=CPSR_SSBS ; - }else { - env->uncached_cpsr &= ~CPSR_SSBS ; - } - } - -if (new_mode ==ARM_CPU_MODE_HYP ) { - env->thumb = (env->cp15.sctlr_el[2 ] &SCTLR_TE ) !=0 ; - env->elr_el[2 ] = env->regs[15 ]; - }else { -/* CPSR.PAN is normally preserved preserved unless... */ -if (cpu_isar_feature (aa32_pan,env_archcpu (env))) { -switch (new_el) { -case 3 : -if (!arm_is_secure_below_el3 (env)) { -/* ... the target is EL3, from non-secure state. */ - env->uncached_cpsr &= ~CPSR_PAN ; -break ; - } -/* ... the target is EL3, from secure state ... */ -/* fall through */ -case 1 : -/* ... the target is EL1 and SCTLR.SPAN is 0. */ -if (!(env->cp15.sctlr_el[new_el] &SCTLR_SPAN )) { - env->uncached_cpsr |=CPSR_PAN ; - } -break ; - } - } -/* -* this is a lie, as there was no c1_sys on V4T/V5, but who cares -* and we should just guard the thumb mode on V4 -*/ -if (arm_feature (env,ARM_FEATURE_V4T )) { - env->thumb = - (A32_BANKED_CURRENT_REG_GET (env, sctlr) &SCTLR_TE ) !=0 ; - } - env->regs[14 ] = env->regs[15 ] + offset; - } - env->regs[15 ] = newpc; -if (tcg_enabled ()) { -arm_rebuild_hflags (env); - } -} - -static void arm_cpu_do_interrupt_aarch32_hyp (CPUState *cs) -{ -/* -* Handle exception entry to Hyp mode; this is sufficiently -* different to entry to other AArch32 modes that we handle it -* separately here. -* -* The vector table entry used is always the 0x14 Hyp mode entry point, -* unless this is an UNDEF/HVC/abort taken from Hyp to Hyp. -* The offset applied to the preferred return address is always zero -* (see DDI0487C.a section G1.12.3). -* PSTATE A/I/F masks are set based only on the SCR.EA/IRQ/FIQ values. -*/ -uint32_t addr, mask; -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; - -switch (cs->exception_index) { -case EXCP_UDEF : - addr =0x04 ; -break ; -case EXCP_SWI : - addr =0x14 ; -break ; -case EXCP_BKPT : -/* Fall through to prefetch abort. */ -case EXCP_PREFETCH_ABORT : - env->cp15.ifar_s = env->exception.vaddress; -qemu_log_mask (CPU_LOG_INT ,"...with HIFAR 0x%x\n" , - (uint32_t )env->exception.vaddress); - addr =0x0c ; -break ; -case EXCP_DATA_ABORT : - env->cp15.dfar_s = env->exception.vaddress; -qemu_log_mask (CPU_LOG_INT ,"...with HDFAR 0x%x\n" , - (uint32_t )env->exception.vaddress); - addr =0x10 ; -break ; -case EXCP_IRQ : - addr =0x18 ; -break ; -case EXCP_FIQ : - addr =0x1c ; -break ; -case EXCP_HVC : - addr =0x08 ; -break ; -case EXCP_HYP_TRAP : - addr =0x14 ; -break ; -default : -cpu_abort (cs,"Unhandled exception 0x%x\n" , cs->exception_index); - } - -if (cs->exception_index !=EXCP_IRQ && cs->exception_index !=EXCP_FIQ ) { -if (!arm_feature (env,ARM_FEATURE_V8 )) { -/* -* QEMU syndrome values are v8-style. v7 has the IL bit -* UNK/SBZP for "field not valid" cases, where v8 uses RES1. -* If this is a v7 CPU, squash the IL bit in those cases. -*/ -if (cs->exception_index ==EXCP_PREFETCH_ABORT || - (cs->exception_index ==EXCP_DATA_ABORT && - !(env->exception.syndrome &ARM_EL_ISV )) || -syn_get_ec (env->exception.syndrome) ==EC_UNCATEGORIZED ) { - env->exception.syndrome &= ~ARM_EL_IL ; - } - } - env->cp15.esr_el[2 ] = env->exception.syndrome; - } - -if (arm_current_el (env) !=2 && addr <0x14 ) { - addr =0x14 ; - } - - mask =0 ; -if (!(env->cp15.scr_el3 &SCR_EA )) { - mask |=CPSR_A ; - } -if (!(env->cp15.scr_el3 &SCR_IRQ )) { - mask |=CPSR_I ; - } -if (!(env->cp15.scr_el3 &SCR_FIQ )) { - mask |=CPSR_F ; - } - - addr += env->cp15.hvbar; - -take_aarch32_exception (env,ARM_CPU_MODE_HYP , mask,0 , addr); -} - -static void arm_cpu_do_interrupt_aarch32 (CPUState *cs) -{ -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; -uint32_t addr; -uint32_t mask; -int new_mode; -uint32_t offset; -uint32_t moe; - -/* If this is a debug exception we must update the DBGDSCR.MOE bits */ -switch (syn_get_ec (env->exception.syndrome)) { -case EC_BREAKPOINT : -case EC_BREAKPOINT_SAME_EL : - moe =1 ; -break ; -case EC_WATCHPOINT : -case EC_WATCHPOINT_SAME_EL : - moe =10 ; -break ; -case EC_AA32_BKPT : - moe =3 ; -break ; -case EC_VECTORCATCH : - moe =5 ; -break ; -default : - moe =0 ; -break ; - } - -if (moe) { - env->cp15.mdscr_el1 =deposit64 (env->cp15.mdscr_el1,2 ,4 , moe); - } - -if (env->exception.target_el ==2 ) { -arm_cpu_do_interrupt_aarch32_hyp (cs); -return ; - } - -switch (cs->exception_index) { -case EXCP_UDEF : - new_mode =ARM_CPU_MODE_UND ; - addr =0x04 ; - mask =CPSR_I ; -if (env->thumb) { - offset =2 ; - }else { - offset =4 ; - } -break ; -case EXCP_SWI : - new_mode =ARM_CPU_MODE_SVC ; - addr =0x08 ; - mask =CPSR_I ; -/* The PC already points to the next instruction. */ - offset =0 ; -break ; -case EXCP_BKPT : -/* Fall through to prefetch abort. */ -case EXCP_PREFETCH_ABORT : -A32_BANKED_CURRENT_REG_SET (env, ifsr, env->exception.fsr); -A32_BANKED_CURRENT_REG_SET (env, ifar, env->exception.vaddress); -qemu_log_mask (CPU_LOG_INT ,"...with IFSR 0x%x IFAR 0x%x\n" , - env->exception.fsr, (uint32_t )env->exception.vaddress); - new_mode =ARM_CPU_MODE_ABT ; - addr =0x0c ; - mask =CPSR_A |CPSR_I ; - offset =4 ; -break ; -case EXCP_DATA_ABORT : -A32_BANKED_CURRENT_REG_SET (env, dfsr, env->exception.fsr); -A32_BANKED_CURRENT_REG_SET (env, dfar, env->exception.vaddress); -qemu_log_mask (CPU_LOG_INT ,"...with DFSR 0x%x DFAR 0x%x\n" , - env->exception.fsr, - (uint32_t )env->exception.vaddress); - new_mode =ARM_CPU_MODE_ABT ; - addr =0x10 ; - mask =CPSR_A |CPSR_I ; - offset =8 ; -break ; -case EXCP_IRQ : - new_mode =ARM_CPU_MODE_IRQ ; - addr =0x18 ; -/* Disable IRQ and imprecise data aborts. */ - mask =CPSR_A |CPSR_I ; - offset =4 ; -if (env->cp15.scr_el3 &SCR_IRQ ) { -/* IRQ routed to monitor mode */ - new_mode =ARM_CPU_MODE_MON ; - mask |=CPSR_F ; - } -break ; -case EXCP_FIQ : - new_mode =ARM_CPU_MODE_FIQ ; - addr =0x1c ; -/* Disable FIQ, IRQ and imprecise data aborts. */ - mask =CPSR_A |CPSR_I |CPSR_F ; -if (env->cp15.scr_el3 &SCR_FIQ ) { -/* FIQ routed to monitor mode */ - new_mode =ARM_CPU_MODE_MON ; - } - offset =4 ; -break ; -case EXCP_VIRQ : - new_mode =ARM_CPU_MODE_IRQ ; - addr =0x18 ; -/* Disable IRQ and imprecise data aborts. */ - mask =CPSR_A |CPSR_I ; - offset =4 ; -break ; -case EXCP_VFIQ : - new_mode =ARM_CPU_MODE_FIQ ; - addr =0x1c ; -/* Disable FIQ, IRQ and imprecise data aborts. */ - mask =CPSR_A |CPSR_I |CPSR_F ; - offset =4 ; -break ; -case EXCP_SMC : - new_mode =ARM_CPU_MODE_MON ; - addr =0x08 ; - mask =CPSR_A |CPSR_I |CPSR_F ; - offset =0 ; -break ; -default : -cpu_abort (cs,"Unhandled exception 0x%x\n" , cs->exception_index); -return ;/* Never happens. Keep compiler happy. */ - } - -if (new_mode ==ARM_CPU_MODE_MON ) { - addr += env->cp15.mvbar; - }else if (A32_BANKED_CURRENT_REG_GET (env, sctlr) &SCTLR_V ) { -/* High vectors. When enabled, base address cannot be remapped. */ - addr +=0xffff0000 ; - }else { -/* -* ARM v7 architectures provide a vector base address register to remap -* the interrupt vector table. -* This register is only followed in non-monitor mode, and is banked. -* Note: only bits 31:5 are valid. -*/ - addr +=A32_BANKED_CURRENT_REG_GET (env, vbar); - } - -if ((env->uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_MON ) { - env->cp15.scr_el3 &= ~SCR_NS ; - } - -take_aarch32_exception (env, new_mode, mask, offset, addr); -} - -static int aarch64_regnum (CPUARMState *env,int aarch32_reg) -{ -/* -* Return the register number of the AArch64 view of the AArch32 -* register @aarch32_reg. The CPUARMState CPSR is assumed to still -* be that of the AArch32 mode the exception came from. -*/ -int mode = env->uncached_cpsr &CPSR_M ; - -switch (aarch32_reg) { - case 0 ... 7: -return aarch32_reg; - case 8 ... 12: -return mode ==ARM_CPU_MODE_FIQ ? aarch32_reg +16 : aarch32_reg; -case 13 : -switch (mode) { -case ARM_CPU_MODE_USR : -case ARM_CPU_MODE_SYS : -return 13 ; -case ARM_CPU_MODE_HYP : -return 15 ; -case ARM_CPU_MODE_IRQ : -return 17 ; -case ARM_CPU_MODE_SVC : -return 19 ; -case ARM_CPU_MODE_ABT : -return 21 ; -case ARM_CPU_MODE_UND : -return 23 ; -case ARM_CPU_MODE_FIQ : -return 29 ; -default : -g_assert_not_reached (); - } -case 14 : -switch (mode) { -case ARM_CPU_MODE_USR : -case ARM_CPU_MODE_SYS : -case ARM_CPU_MODE_HYP : -return 14 ; -case ARM_CPU_MODE_IRQ : -return 16 ; -case ARM_CPU_MODE_SVC : -return 18 ; -case ARM_CPU_MODE_ABT : -return 20 ; -case ARM_CPU_MODE_UND : -return 22 ; -case ARM_CPU_MODE_FIQ : -return 30 ; -default : -g_assert_not_reached (); - } -case 15 : -return 31 ; -default : -g_assert_not_reached (); - } -} - -static uint32_t cpsr_read_for_spsr_elx (CPUARMState *env) -{ -uint32_t ret =cpsr_read (env); - -/* Move DIT to the correct location for SPSR_ELx */ -if (ret &CPSR_DIT ) { - ret &= ~CPSR_DIT ; - ret |=PSTATE_DIT ; - } -/* Merge PSTATE.SS into SPSR_ELx */ - ret |= env->pstate &PSTATE_SS ; - -return ret; -} - -/* Handle exception entry to a target EL which is using AArch64 */ -static void arm_cpu_do_interrupt_aarch64 (CPUState *cs) -{ -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; -unsigned int new_el = env->exception.target_el; -target_ulong addr = env->cp15.vbar_el[new_el]; -unsigned int new_mode =aarch64_pstate_mode (new_el, true); -unsigned int old_mode; -unsigned int cur_el =arm_current_el (env); -int rt; - -/* -* Note that new_el can never be 0. If cur_el is 0, then -* el0_a64 is is_a64(), else el0_a64 is ignored. -*/ -aarch64_sve_change_el (env, cur_el, new_el,is_a64 (env)); - -if (cur_el < new_el) { -/* -* Entry vector offset depends on whether the implemented EL -* immediately lower than the target level is using AArch32 or AArch64 -*/ -bool is_aa64; -uint64_t hcr; - -switch (new_el) { -case 3 : - is_aa64 = (env->cp15.scr_el3 &SCR_RW ) !=0 ; -break ; -case 2 : - hcr =arm_hcr_el2_eff (env); -if ((hcr & (HCR_E2H |HCR_TGE )) != (HCR_E2H |HCR_TGE )) { - is_aa64 = (hcr &HCR_RW ) !=0 ; -break ; - } -/* fall through */ -case 1 : - is_aa64 =is_a64 (env); -break ; -default : -g_assert_not_reached (); - } - -if (is_aa64) { - addr +=0x400 ; - }else { - addr +=0x600 ; - } - }else if (pstate_read (env) &PSTATE_SP ) { - addr +=0x200 ; - } - -switch (cs->exception_index) { -case EXCP_PREFETCH_ABORT : -case EXCP_DATA_ABORT : - env->cp15.far_el[new_el] = env->exception.vaddress; -qemu_log_mask (CPU_LOG_INT ,"...with FAR 0x%" PRIx64"\n" , - env->cp15.far_el[new_el]); -/* fall through */ -case EXCP_BKPT : -case EXCP_UDEF : -case EXCP_SWI : -case EXCP_HVC : -case EXCP_HYP_TRAP : -case EXCP_SMC : -switch (syn_get_ec (env->exception.syndrome)) { -case EC_ADVSIMDFPACCESSTRAP : -/* -* QEMU internal FP/SIMD syndromes from AArch32 include the -* TA and coproc fields which are only exposed if the exception -* is taken to AArch32 Hyp mode. Mask them out to get a valid -* AArch64 format syndrome. -*/ - env->exception.syndrome &= ~MAKE_64BIT_MASK (0 ,20 ); -break ; -case EC_CP14RTTRAP : -case EC_CP15RTTRAP : -case EC_CP14DTTRAP : -/* -* For a trap on AArch32 MRC/MCR/LDC/STC the Rt field is currently -* the raw register field from the insn; when taking this to -* AArch64 we must convert it to the AArch64 view of the register -* number. Notice that we read a 4-bit AArch32 register number and -* write back a 5-bit AArch64 one. -*/ - rt =extract32 (env->exception.syndrome,5 ,4 ); - rt =aarch64_regnum (env, rt); - env->exception.syndrome =deposit32 (env->exception.syndrome, -5 ,5 , rt); -break ; -case EC_CP15RRTTRAP : -case EC_CP14RRTTRAP : -/* Similarly for MRRC/MCRR traps for Rt and Rt2 fields */ - rt =extract32 (env->exception.syndrome,5 ,4 ); - rt =aarch64_regnum (env, rt); - env->exception.syndrome =deposit32 (env->exception.syndrome, -5 ,5 , rt); - rt =extract32 (env->exception.syndrome,10 ,4 ); - rt =aarch64_regnum (env, rt); - env->exception.syndrome =deposit32 (env->exception.syndrome, -10 ,5 , rt); -break ; - } - env->cp15.esr_el[new_el] = env->exception.syndrome; -break ; -case EXCP_IRQ : -case EXCP_VIRQ : - addr +=0x80 ; -break ; -case EXCP_FIQ : -case EXCP_VFIQ : - addr +=0x100 ; -break ; -default : -cpu_abort (cs,"Unhandled exception 0x%x\n" , cs->exception_index); - } - -if (is_a64 (env)) { - old_mode =pstate_read (env); -aarch64_save_sp (env,arm_current_el (env)); - env->elr_el[new_el] = env->pc; - }else { - old_mode =cpsr_read_for_spsr_elx (env); - env->elr_el[new_el] = env->regs[15 ]; - -aarch64_sync_32_to_64 (env); - - env->condexec_bits =0 ; - } - env->banked_spsr[aarch64_banked_spsr_index (new_el)] = old_mode; - -qemu_log_mask (CPU_LOG_INT ,"...with ELR 0x%" PRIx64"\n" , - env->elr_el[new_el]); - -if (cpu_isar_feature (aa64_pan, cpu)) { -/* The value of PSTATE.PAN is normally preserved, except when ... */ - new_mode |= old_mode &PSTATE_PAN ; -switch (new_el) { -case 2 : -/* ... the target is EL2 with HCR_EL2.{E2H,TGE} == '11' ... */ -if ((arm_hcr_el2_eff (env) & (HCR_E2H |HCR_TGE )) - != (HCR_E2H |HCR_TGE )) { -break ; - } -/* fall through */ -case 1 : -/* ... the target is EL1 ... */ -/* ... and SCTLR_ELx.SPAN == 0, then set to 1. */ -if ((env->cp15.sctlr_el[new_el] &SCTLR_SPAN ) ==0 ) { - new_mode |=PSTATE_PAN ; - } -break ; - } - } -if (cpu_isar_feature (aa64_mte, cpu)) { - new_mode |=PSTATE_TCO ; - } - -if (cpu_isar_feature (aa64_ssbs, cpu)) { -if (env->cp15.sctlr_el[new_el] &SCTLR_DSSBS_64 ) { - new_mode |=PSTATE_SSBS ; - }else { - new_mode &= ~PSTATE_SSBS ; - } - } - -pstate_write (env,PSTATE_DAIF | new_mode); - env->aarch64 =1 ; -aarch64_restore_sp (env, new_el); - -if (tcg_enabled ()) { -/* pstate already written, so we can use arm_rebuild_hflags here */ -arm_rebuild_hflags (env); - } - - env->pc = addr; - -qemu_log_mask (CPU_LOG_INT ,"...to EL%d PC 0x%" PRIx64" PSTATE 0x%x\n" , - new_el, env->pc,pstate_read (env)); -} - -/* -* Do semihosting call and set the appropriate return value. All the -* permission and validity checks have been done at translate time. -* -* We only see semihosting exceptions in TCG only as they are not -* trapped to the hypervisor in KVM. -*/ -#ifdef CONFIG_TCG -static void handle_semihosting (CPUState *cs) -{ -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; - -if (is_a64 (env)) { -qemu_log_mask (CPU_LOG_INT , -"...handling as semihosting call 0x%" PRIx64"\n" , - env->xregs[0 ]); - env->xregs[0 ] =do_common_semihosting (cs); - env->pc +=4 ; - }else { -qemu_log_mask (CPU_LOG_INT , -"...handling as semihosting call 0x%x\n" , - env->regs[0 ]); - env->regs[0 ] =do_common_semihosting (cs); - env->regs[15 ] += env->thumb ?2 :4 ; - } -} -#endif - -/* -* Handle a CPU exception for A and R profile CPUs. -* Do any appropriate logging, handle PSCI calls, and then hand off -* to the AArch64-entry or AArch32-entry function depending on the -* target exception level's register width. -* -* Note: this is used for both TCG (as the do_interrupt tcg op), -* and KVM to re-inject guest debug exceptions, and to -* inject a Synchronous-External-Abort. -*/ -void arm_cpu_do_interrupt (CPUState *cs) -{ -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; -unsigned int new_el = env->exception.target_el; - -assert (!arm_feature (env,ARM_FEATURE_M )); - -arm_log_exception (cs->exception_index); -qemu_log_mask (CPU_LOG_INT ,"...from EL%d to EL%d\n" ,arm_current_el (env), - new_el); -if (qemu_loglevel_mask (CPU_LOG_INT ) - && !excp_is_internal (cs->exception_index)) { -qemu_log_mask (CPU_LOG_INT ,"...with ESR 0x%x/0x%" PRIx32"\n" , -syn_get_ec (env->exception.syndrome), - env->exception.syndrome); - } - -#ifdef CONFIG_TCG -if (arm_is_psci_call (cpu, cs->exception_index)) { -arm_handle_psci_call (cpu); -qemu_log_mask (CPU_LOG_INT ,"...handled as PSCI call\n" ); -return ; - } - -/* -* Semihosting semantics depend on the register width of the code -* that caused the exception, not the target exception level, so -* must be handled here. -*/ -if (cs->exception_index ==EXCP_SEMIHOST ) { -handle_semihosting (cs); -return ; - } -#endif - -/* -* Hooks may change global state so BQL should be held, also the -* BQL needs to be held for any modification of -* cs->interrupt_request. -*/ -g_assert (qemu_mutex_iothread_locked ()); - -arm_call_pre_el_change_hook (cpu); - -assert (!excp_is_internal (cs->exception_index)); -if (arm_el_is_aa64 (env, new_el)) { -arm_cpu_do_interrupt_aarch64 (cs); - }else { -arm_cpu_do_interrupt_aarch32 (cs); - } - -arm_call_el_change_hook (cpu); - -if (!kvm_enabled ()) { - cs->interrupt_request |=CPU_INTERRUPT_EXITTB ; - } -}#endif /* !CONFIG_USER_ONLY */ /* Returns true if the stage 1 translation regime is using LPAE format page target/arm/tcg/sysemu/tcg-cpu.c new file +73
-0@@ -0,0 +1,73 @@ +/* +* QEMU ARM TCG CPU (sysemu code) +* +* Copyright (c) 2012 SUSE LINUX Products GmbH +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, see +* <http://www.gnu.org/licenses/gpl-2.0.html> +*/ + +#include "qemu/osdep.h" +#include "qemu/qemu-print.h" +#include "qemu-common.h" +#include "target/arm/idau.h" +#include "qemu/module.h" +#include "qapi/error.h" +#include "qapi/visitor.h" +#include "cpu.h" +#include "hw/core/tcg-cpu-ops.h" +#include "semihosting/common-semi.h" +#include "cpregs.h" +#include "internals.h" +#include "exec/exec-all.h" +#include "hw/qdev-properties.h" +#if !defined(CONFIG_USER_ONLY ) +#include "hw/loader.h" +#include "hw/boards.h" +#endif +#include "sysemu/sysemu.h" +#include "sysemu/tcg.h" +#include "sysemu/hw_accel.h" +#include "kvm_arm.h" +#include "disas/capstone.h" +#include "fpu/softfloat.h" +#include "cpu-mmu.h" +#include "tcg/tcg-cpu.h" + +/* +* Do semihosting call and set the appropriate return value. All the +* permission and validity checks have been done at translate time. +* +* We only see semihosting exceptions in TCG only as they are not +* trapped to the hypervisor in KVM. +*/ +void handle_semihosting (CPUState *cs) +{ +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; + +if (is_a64 (env)) { +qemu_log_mask (CPU_LOG_INT , +"...handling as semihosting call 0x%" PRIx64"\n" , + env->xregs[0 ]); + env->xregs[0 ] =do_common_semihosting (cs); + env->pc +=4 ; + }else { +qemu_log_mask (CPU_LOG_INT , +"...handling as semihosting call 0x%x\n" , + env->regs[0 ]); + env->regs[0 ] =do_common_semihosting (cs); + env->regs[15 ] += env->thumb ?2 :4 ; + } +}target/arm/tcg/sysemu/meson.build +1
-0@@ -2,5 +2,6 @@ arm_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( 'debug_helper.c', 'm_helper.c', 'mte_helper.c', + 'tcg-cpu.c', 'tlb_helper.c', ))
PATCH v16 52/99 target/arm: rename handle_semihosting to tcg_handle_semihosting
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
make it clearer from the name that this is a tcg-only function.
--- target/arm/tcg/tcg-cpu.h | 2 +- target/arm/cpu-sysemu.c | 2 +- target/arm/tcg/sysemu/tcg-cpu.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
target/arm/tcg/tcg-cpu.h +1 -1
@@ -24,7 +24,7 @@#ifndef CONFIG_USER_ONLY /* Do semihosting call and set the appropriate return value. */ -void handle_semihosting (CPUState *cs); +void tcg_handle_semihosting (CPUState *cs);#endif /* !CONFIG_USER_ONLY */
target/arm/cpu-sysemu.c +1 -1
@@ -1153,7 +1153,7 @@ void arm_cpu_do_interrupt(CPUState *cs)* must be handled here. */ if (cs->exception_index ==EXCP_SEMIHOST ) { -handle_semihosting (cs); +tcg_handle_semihosting (cs);return ; }#endif /* CONFIG_TCG */
target/arm/tcg/sysemu/tcg-cpu.c +1 -1
@@ -52,7 +52,7 @@* We only see semihosting exceptions in TCG only as they are not * trapped to the hypervisor in KVM. */ -void handle_semihosting (CPUState *cs) +void tcg_handle_semihosting (CPUState *cs) {ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;
Signature · 1 line
2.20.1
Re: [PATCH v16 52/99] target/arm: rename handle_semihosting to tcg_handle_semihosting
Quoted 11 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
make it clearer from the name that this is a tcg-only function.
Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/tcg/tcg-cpu.h | 2 +- target/arm/cpu-sysemu.c | 2 +- target/arm/tcg/sysemu/tcg-cpu.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
r~
PATCH v16 53/99 target/arm: replace CONFIG_TCG with tcg_enabled
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
for "all" builds (tcg + kvm), we want to avoid doing
the psci and semihosting checks if tcg is built-in, but not enabled.
--- target/arm/cpu-sysemu.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
target/arm/cpu-sysemu.c +15 -15
@@ -1141,22 +1141,22 @@ void arm_cpu_do_interrupt(CPUState *cs) env->exception.syndrome); } -#ifdef CONFIG_TCG -if (arm_is_psci_call (cpu, cs->exception_index)) { -arm_handle_psci_call (cpu); -qemu_log_mask (CPU_LOG_INT ,"...handled as PSCI call\n" ); -return ; - } -/* -* Semihosting semantics depend on the register width of the code -* that caused the exception, not the target exception level, so -* must be handled here. -*/ -if (cs->exception_index ==EXCP_SEMIHOST ) { -tcg_handle_semihosting (cs); -return ; +if (tcg_enabled ()) { +if (arm_is_psci_call (cpu, cs->exception_index)) { +arm_handle_psci_call (cpu); +qemu_log_mask (CPU_LOG_INT ,"...handled as PSCI call\n" ); +return ; + } +/* +* Semihosting semantics depend on the register width of the code +* that caused the exception, not the target exception level, so +* must be handled here. +*/ +if (cs->exception_index ==EXCP_SEMIHOST ) { +tcg_handle_semihosting (cs); +return ; + } } -#endif /* CONFIG_TCG */ /* * Hooks may change global state so BQL should be held, also the * BQL needs to be held for any modification of
Signature · 1 line
2.20.1
Re: [PATCH v16 53/99] target/arm: replace CONFIG_TCG with tcg_enabled
Quoted 10 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
for "all" builds (tcg + kvm), we want to avoid doing
the psci and semihosting checks if tcg is built-in, but not enabled.Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/cpu-sysemu.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
r~
PATCH v16 54/99 target/arm: move TCGCPUOps to tcg/tcg-cpu.c
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
move the TCGCPUOps interface to tcg/tcg-cpu.c
in preparation for the addition of the TCG accel-cpu class.
--- target/arm/cpu.h | 1 - target/arm/internals.h | 5 - target/arm/tcg/tcg-cpu.h | 6 + target/arm/cpu-sysemu.c | 4 + target/arm/cpu.c | 210 +--------------------------------- target/arm/cpu_tcg.c | 2 +- target/arm/tcg/helper.c | 1 + target/arm/tcg/tcg-cpu.c | 229 +++++++++++++++++++++++++++++++++++++ target/arm/tcg/meson.build | 1 + 9 files changed, 244 insertions(+), 215 deletions(-) create mode 100644 target/arm/tcg/tcg-cpu.c
target/arm/cpu.h +0 -1
@@ -1031,7 +1031,6 @@ extern const VMStateDescription vmstate_arm_cpu;void arm_cpu_do_interrupt (CPUState *cpu);void arm_v7m_cpu_do_interrupt (CPUState *cpu); -bool arm_cpu_exec_interrupt (CPUState *cpu,int int_req);int arm_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int arm_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/arm/internals.h +0 -5
@@ -173,11 +173,6 @@ static inline int r14_bank_number(int mode)void arm_cpu_register_gdb_regs_for_features (ARMCPU *cpu);void arm_translate_init (void ); -#ifdef CONFIG_TCG -void arm_cpu_synchronize_from_tb (CPUState *cs,const TranslationBlock *tb); -#endif /* CONFIG_TCG */ - -enum arm_fprounding {FPROUNDING_TIEEVEN ,FPROUNDING_POSINF ,
target/arm/tcg/tcg-cpu.h +6 -0
@@ -21,6 +21,12 @@#define ARM_TCG_CPU_H #include "cpu.h" +#include "hw/core/tcg-cpu-ops.h" + +void arm_cpu_synchronize_from_tb (CPUState *cs, +const TranslationBlock *tb); + +extern struct TCGCPUOps arm_tcg_ops;#ifndef CONFIG_USER_ONLY /* Do semihosting call and set the appropriate return value. */
target/arm/cpu-sysemu.c +4 -0
@@ -28,6 +28,10 @@#include "sysemu/tcg.h" #include "tcg/tcg-cpu.h" +#ifdef CONFIG_TCG +#include "tcg/tcg-cpu.h" +#endif /* CONFIG_TCG */ +void arm_cpu_set_irq (void *opaque,int irq,int level) {ARMCPU *cpu = opaque;
target/arm/cpu.c +2 -208
240 lines not on this page · raw message
target/arm/cpu_tcg.c +1 -1
@@ -11,7 +11,7 @@#include "qemu/osdep.h" #include "cpu.h" #ifdef CONFIG_TCG -#include "hw/core/tcg-cpu-ops.h" +#include "tcg/tcg-cpu.h" #endif /* CONFIG_TCG */ #include "internals.h" #include "target/arm/idau.h"
target/arm/tcg/helper.c +1 -0
@@ -16,6 +16,7 @@#include "arm_ldst.h" #include "cpu-mmu.h" #include "cpregs.h" +#include "tcg-cpu.h" static int vfp_gdb_get_reg (CPUARMState *env,GByteArray *buf,int reg) {
target/arm/tcg/tcg-cpu.c new file +229 -0
229 lines not on this page · raw message
target/arm/tcg/meson.build +1 -0
@@ -31,6 +31,7 @@ arm_ss.add(when: 'CONFIG_TCG', if_true: files( 'vfp_helper.c', 'crypto_helper.c', 'debug_helper.c', + 'tcg-cpu.c', ), if_false: files( 'tcg-stubs.c',
Signature · 1 line
2.20.1
Re: [PATCH v16 54/99] target/arm: move TCGCPUOps to tcg/tcg-cpu.c
Quoted 18 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
move the TCGCPUOps interface to
tcg/tcg-cpu.c
in preparation for the addition of the TCG accel-cpu class.Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- target/arm/cpu.h | 1 - target/arm/internals.h | 5 - target/arm/tcg/tcg-cpu.h | 6 + target/arm/cpu-sysemu.c | 4 + target/arm/cpu.c | 210 +--------------------------------- target/arm/cpu_tcg.c | 2 +- target/arm/tcg/helper.c | 1 + target/arm/tcg/tcg-cpu.c | 229 +++++++++++++++++++++++++++++++++++++ target/arm/tcg/meson.build | 1 + 9 files changed, 244 insertions(+), 215 deletions(-)
Quoted 1 line
create mode 100644
target/arm/tcg/tcg-cpu.c
r~
PATCH v16 55/99 target/arm: move cpu_tcg to tcg/tcg-cpu-models.c
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
move the module containing cpu models definitions for 32bit TCG-only CPUs to tcg/ and rename it for clarity.
---
target/arm/{cpu_tcg.c => tcg/tcg-cpu-models.c} | 7 +------
target/arm/meson.build | 4 ----
target/arm/tcg/meson.build | 1 +
3 files changed, 2 insertions(+), 10 deletions(-)
rename target/arm/{cpu_tcg.c => tcg/tcg-cpu-models.c} (99%)target/arm/tcg/tcg-cpu-models.c renamed from target/arm/cpu_tcg.c +1 -6
@@ -1,5 +1,5 @@/* -* QEMU ARM TCG CPUs. +* QEMU ARM TCG-only CPUs. * * Copyright (c) 2012 SUSE LINUX Products GmbH *
@@ -9,10 +9,7 @@*/ #include "qemu/osdep.h" -#include "cpu.h" -#ifdef CONFIG_TCG #include "tcg/tcg-cpu.h" -#endif /* CONFIG_TCG */ #include "internals.h" #include "target/arm/idau.h" #if !defined(CONFIG_USER_ONLY )
@@ -24,7 +21,6 @@/* CPU models. These are not needed for the AArch64 linux-user build. */ #if !defined(CONFIG_USER_ONLY ) || !defined(TARGET_AARCH64 ) -#ifdef CONFIG_TCGstatic bool arm_v7m_cpu_exec_interrupt (CPUState *cs,int interrupt_request) {CPUClass *cc =CPU_GET_CLASS (cs);
@@ -48,7 +44,6 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) }return ret; } -#endif /* CONFIG_TCG */ static void arm926_initfn (Object *obj) {
target/arm/meson.build +0 -4
@@ -18,10 +18,6 @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'gdbstub64.c', )) -arm_ss.add(when: 'CONFIG_TCG', if_true: files( - 'cpu_tcg.c', -)) - arm_softmmu_ss = ss.source_set() arm_softmmu_ss.add(files( 'arch_dump.c',
target/arm/tcg/meson.build +1 -0
@@ -32,6 +32,7 @@ arm_ss.add(when: 'CONFIG_TCG', if_true: files( 'crypto_helper.c', 'debug_helper.c', 'tcg-cpu.c', + 'tcg-cpu-models.c', ), if_false: files( 'tcg-stubs.c',
Signature · 1 line
2.20.1
PATCH v16 56/99 target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
After this patch it is possible to build only kvm:
./configure --disable-tcg --enable-kvm
--- target/arm/cpu-sysemu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
target/arm/cpu-sysemu.c +7 -5
@@ -917,11 +917,13 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)unsigned int cur_el =arm_current_el (env);int rt; -/* -* Note that new_el can never be 0. If cur_el is 0, then -* el0_a64 is is_a64(), else el0_a64 is ignored. -*/ -aarch64_sve_change_el (env, cur_el, new_el,is_a64 (env)); +if (tcg_enabled ()) { +/* +* Note that new_el can never be 0. If cur_el is 0, then +* el0_a64 is is_a64(), else el0_a64 is ignored. +*/ +aarch64_sve_change_el (env, cur_el, new_el,is_a64 (env)); + }if (cur_el < new_el) {/*
Signature · 1 line
2.20.1
PATCH v16 57/99 target/arm: remove kvm include file for PSCI and arm-powerctl
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
The QEMU PSCI implementation is not used for KVM, we do not need the kvm constants header.
--- target/arm/arm-powerctl.h | 2 -- target/arm/psci.c | 1 - 2 files changed, 3 deletions(-)
target/arm/arm-powerctl.h +0 -2
@@ -11,8 +11,6 @@#ifndef QEMU_ARM_POWERCTL_H #define QEMU_ARM_POWERCTL_H -#include "kvm-consts.h" -#define QEMU_ARM_POWERCTL_RET_SUCCESS QEMU_PSCI_RET_SUCCESS#define QEMU_ARM_POWERCTL_INVALID_PARAM QEMU_PSCI_RET_INVALID_PARAMS#define QEMU_ARM_POWERCTL_ALREADY_ON QEMU_PSCI_RET_ALREADY_ON
target/arm/psci.c +0 -1
@@ -19,7 +19,6 @@#include "qemu/osdep.h" #include "cpu.h" #include "exec/helper-proto.h" -#include "kvm-consts.h" #include "qemu/main-loop.h" #include "sysemu/runstate.h" #include "internals.h"
Signature · 1 line
2.20.1
PATCH v16 58/99 target/arm: move kvm-const.h, kvm.c, kvm64.c, kvm_arm.h to kvm/
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
and adapt the code including the header references, and trace-events / trace.h
---
meson.build | 2 +-
target/arm/cpu.h | 2 +-
target/arm/{ => kvm}/kvm-consts.h | 0
target/arm/{ => kvm}/kvm_arm.h | 0
target/arm/kvm/trace.h | 1 +
target/arm/trace.h | 1 -
hw/arm/sbsa-ref.c | 2 +-
hw/arm/virt-acpi-build.c | 2 +-
hw/arm/virt.c | 2 +-
hw/arm/xlnx-versal.c | 2 +-
hw/arm/xlnx-zynqmp.c | 2 +-
hw/cpu/a15mpcore.c | 2 +-
hw/intc/arm_gic_kvm.c | 2 +-
hw/intc/arm_gicv3_its_kvm.c | 2 +-
hw/intc/arm_gicv3_kvm.c | 2 +-
target/arm/cpu-sysemu.c | 2 +-
target/arm/cpu.c | 2 +-
target/arm/cpu32.c | 2 +-
target/arm/cpu64.c | 2 +-
target/arm/{ => kvm}/kvm.c | 0
target/arm/{ => kvm}/kvm64.c | 0
target/arm/machine.c | 2 +-
target/arm/monitor.c | 2 +-
target/arm/tcg/sysemu/tcg-cpu.c | 1 -
MAINTAINERS | 2 +-
target/arm/kvm/meson.build | 4 ++++
target/arm/{ => kvm}/trace-events | 0
target/arm/meson.build | 3 +--
28 files changed, 24 insertions(+), 22 deletions(-)
rename target/arm/{ => kvm}/kvm-consts.h (100%)
rename target/arm/{ => kvm}/kvm_arm.h (100%)
create mode 100644 target/arm/kvm/trace.h
delete mode 100644 target/arm/trace.h
rename target/arm/{ => kvm}/kvm.c (100%)
rename target/arm/{ => kvm}/kvm64.c (100%)
create mode 100644 target/arm/kvm/meson.build
rename target/arm/{ => kvm}/trace-events (100%)meson.build +1 -1
@@ -1859,8 +1859,8 @@ if have_system or have_user trace_events_subdirs += [ 'accel/tcg', 'hw/core', - 'target/arm', 'target/arm/tcg', + 'target/arm/kvm', 'target/hppa', 'target/i386', 'target/i386/kvm',
target/arm/cpu.h +1 -1
@@ -20,7 +20,7 @@#ifndef ARM_CPU_H #define ARM_CPU_H -#include "kvm-consts.h" +#include "kvm/kvm-consts.h" #include "hw/registerfields.h" #include "cpu-qom.h" #include "exec/cpu-defs.h"
target/arm/kvm/kvm-consts.h renamed from target/arm/kvm-consts.h +0 -0
target/arm/kvm/kvm_arm.h renamed from target/arm/kvm_arm.h +0 -0
target/arm/kvm/trace.h new file +1 -0
@@ -0,0 +1 @@ +#include "trace/trace-target_arm_kvm.h"
target/arm/trace.h deleted +0 -1
@@ -1 +0,0 @@ -#include "trace/trace-target_arm.h"
hw/arm/sbsa-ref.c +1 -1
@@ -28,7 +28,7 @@#include "sysemu/runstate.h" #include "sysemu/sysemu.h" #include "exec/hwaddr.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "hw/arm/boot.h" #include "hw/block/flash.h" #include "hw/boards.h"
hw/arm/virt-acpi-build.c +1 -1
@@ -51,7 +51,7 @@#include "sysemu/numa.h" #include "sysemu/reset.h" #include "sysemu/tpm.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "migration/vmstate.h" #include "hw/acpi/ghes.h"
hw/arm/virt.c +1 -1
@@ -63,7 +63,7 @@#include "hw/intc/arm_gic.h" #include "hw/intc/arm_gicv3_common.h" #include "hw/irq.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "hw/firmware/smbios.h" #include "qapi/visitor.h" #include "qapi/qapi-visit-common.h"
hw/arm/xlnx-versal.c +1 -1
@@ -18,7 +18,7 @@#include "sysemu/sysemu.h" #include "sysemu/kvm.h" #include "hw/arm/boot.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "hw/misc/unimp.h" #include "hw/arm/xlnx-versal.h"
hw/arm/xlnx-zynqmp.c +1 -1
@@ -23,7 +23,7 @@#include "hw/boards.h" #include "sysemu/kvm.h" #include "sysemu/sysemu.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #define GIC_NUM_SPI_INTR 160
hw/cpu/a15mpcore.c +1 -1
@@ -25,7 +25,7 @@#include "hw/irq.h" #include "hw/qdev-properties.h" #include "sysemu/kvm.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" static void a15mp_priv_set_irq (void *opaque,int irq,int level) {
hw/intc/arm_gic_kvm.c +1 -1
@@ -24,7 +24,7 @@#include "qemu/module.h" #include "migration/blocker.h" #include "sysemu/kvm.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "gic_internal.h" #include "vgic_common.h" #include "qom/object.h"
hw/intc/arm_gicv3_its_kvm.c +1 -1
@@ -25,7 +25,7 @@#include "hw/qdev-properties.h" #include "sysemu/runstate.h" #include "sysemu/kvm.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "migration/blocker.h" #include "qom/object.h"
hw/intc/arm_gicv3_kvm.c +1 -1
@@ -26,7 +26,7 @@#include "qemu/module.h" #include "sysemu/kvm.h" #include "sysemu/runstate.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "gicv3_internal.h" #include "vgic_common.h" #include "migration/blocker.h"
target/arm/cpu-sysemu.c +1 -1
@@ -24,7 +24,7 @@#include "cpu.h" #include "internals.h" #include "sysemu/hw_accel.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "sysemu/tcg.h" #include "tcg/tcg-cpu.h"
target/arm/cpu.c +1 -1
@@ -39,7 +39,7 @@#endif #include "sysemu/tcg.h" #include "sysemu/hw_accel.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "disas/capstone.h" #include "fpu/softfloat.h" #include "cpu-mmu.h"
target/arm/cpu32.c +1 -1
@@ -37,7 +37,7 @@#include "sysemu/sysemu.h" #include "sysemu/tcg.h" #include "sysemu/hw_accel.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "disas/capstone.h" #include "fpu/softfloat.h" #include "cpu-mmu.h"
target/arm/cpu64.c +1 -1
@@ -31,7 +31,7 @@#include "hw/loader.h" #endif #include "sysemu/kvm.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "qapi/visitor.h" #include "hw/qdev-properties.h" #include "cpregs.h"
target/arm/kvm/kvm.c renamed from target/arm/kvm.c +0 -0
target/arm/kvm/kvm64.c renamed from target/arm/kvm64.c +0 -0
target/arm/machine.c +1 -1
@@ -3,7 +3,7 @@#include "qemu/error-report.h" #include "sysemu/kvm.h" #include "sysemu/tcg.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "internals.h" #include "migration/cpu.h" #include "cpregs.h"
target/arm/monitor.c +1 -1
@@ -22,7 +22,7 @@#include "qemu/osdep.h" #include "hw/boards.h" -#include "kvm_arm.h" +#include "kvm/kvm_arm.h" #include "qapi/error.h" #include "qapi/visitor.h" #include "qapi/qobject-input-visitor.h"
target/arm/tcg/sysemu/tcg-cpu.c +0 -1
@@ -39,7 +39,6 @@#include "sysemu/sysemu.h" #include "sysemu/tcg.h" #include "sysemu/hw_accel.h" -#include "kvm_arm.h" #include "disas/capstone.h" #include "fpu/softfloat.h" #include "cpu-mmu.h"
MAINTAINERS +1 -1
@@ -373,7 +373,7 @@ ARM KVM CPUs M: Peter Maydell <[email protected]> L: [email protected] S: Maintained -F: target/arm/kvm.c +F: target/arm/kvm/kvm.c MIPS KVM CPUs M: Huacai Chen <[email protected]>
target/arm/kvm/meson.build new file +4 -0
@@ -0,0 +1,4 @@ +arm_ss.add(when: 'CONFIG_KVM', if_true: files( + 'kvm.c', + 'kvm64.c', +))
target/arm/kvm/trace-events renamed from target/arm/trace-events +0 -0
target/arm/meson.build +1 -2
@@ -11,8 +11,6 @@ arm_ss.add(files( )) arm_ss.add(zlib) -arm_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c', 'kvm64.c'), if_false: files('kvm-stub.c')) - arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'cpu64.c', 'gdbstub64.c',
@@ -38,6 +36,7 @@ arm_user_ss.add(files( )) subdir('tcg') +subdir('kvm') target_arch += {'arm': arm_ss} target_softmmu_arch += {'arm': arm_softmmu_ss}
Signature · 1 line
2.20.1
PATCH v16 59/99 MAINTAINERS: update arm kvm maintained files to all in target/arm/kvm/
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
@@ -373,7 +373,7 @@ ARM KVM CPUs M: Peter Maydell <[email protected]> L: [email protected] S: Maintained -F: target/arm/kvm/kvm.c +F: target/arm/kvm/ MIPS KVM CPUs M: Huacai Chen <[email protected]>
Signature · 1 line
2.20.1
Re: [PATCH v16 59/99] MAINTAINERS: update arm kvm maintained files to all in target/arm/kvm/
Quoted 7 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
Signed-off-by Claudio Fontana<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
PATCH v16 60/99 target/arm: cleanup cpu includes
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
cpu.c,cpu32.c,cpu64.c,tcg/sysemu/tcg-cpu.c,
all need a good cleanup when it comes to included header files.
--- target/arm/cpu.c | 6 ++---- target/arm/cpu32.c | 14 -------------- target/arm/cpu64.c | 6 ------ target/arm/tcg/sysemu/tcg-cpu.c | 22 +--------------------- 4 files changed, 3 insertions(+), 45 deletions(-)
target/arm/cpu.c +2 -4
@@ -21,24 +21,22 @@#include "qemu/osdep.h" #include "qemu-common.h" #include "target/arm/idau.h" -#include "qemu/module.h" #include "qapi/error.h" -#include "qapi/visitor.h" #include "cpu.h" #include "cpregs.h" +#ifdef CONFIG_TCG #include "tcg/tcg-cpu.h" #endif /* CONFIG_TCG */ #include "cpu32.h" -#include "internals.h" #include "exec/exec-all.h" #include "hw/qdev-properties.h" #if !defined(CONFIG_USER_ONLY )#include "hw/loader.h" #include "hw/boards.h" #endif +#include "sysemu/tcg.h" -#include "sysemu/hw_accel.h" #include "kvm/kvm_arm.h" #include "disas/capstone.h" #include "fpu/softfloat.h"
target/arm/cpu32.c +0 -14
@@ -20,26 +20,12 @@#include "qemu/osdep.h" #include "qemu/qemu-print.h" -#include "qemu-common.h" -#include "target/arm/idau.h" #include "qemu/module.h" -#include "qapi/error.h" -#include "qapi/visitor.h" #include "cpu.h" #include "cpregs.h" -#include "internals.h" -#include "exec/exec-all.h" -#include "hw/qdev-properties.h" #if !defined(CONFIG_USER_ONLY ) -#include "hw/loader.h" #include "hw/boards.h" #endif -#include "sysemu/sysemu.h" -#include "sysemu/tcg.h" -#include "sysemu/hw_accel.h" -#include "kvm/kvm_arm.h" -#include "disas/capstone.h" -#include "fpu/softfloat.h" #include "cpu-mmu.h" #include "cpu32.h"
target/arm/cpu64.c +0 -6
@@ -23,13 +23,7 @@#include "qemu/qemu-print.h" #include "cpu.h" #include "cpu32.h" -#ifdef CONFIG_TCG -#include "hw/core/tcg-cpu-ops.h" -#endif /* CONFIG_TCG */ #include "qemu/module.h" -#if !defined(CONFIG_USER_ONLY ) -#include "hw/loader.h" -#endif #include "sysemu/kvm.h" #include "kvm/kvm_arm.h" #include "qapi/visitor.h"
target/arm/tcg/sysemu/tcg-cpu.c +1 -21
@@ -19,29 +19,9 @@*/ #include "qemu/osdep.h" -#include "qemu/qemu-print.h" -#include "qemu-common.h" -#include "target/arm/idau.h" -#include "qemu/module.h" -#include "qapi/error.h" -#include "qapi/visitor.h" #include "cpu.h" -#include "hw/core/tcg-cpu-ops.h" #include "semihosting/common-semi.h" -#include "cpregs.h" -#include "internals.h" -#include "exec/exec-all.h" -#include "hw/qdev-properties.h" -#if !defined(CONFIG_USER_ONLY ) -#include "hw/loader.h" -#include "hw/boards.h" -#endif -#include "sysemu/sysemu.h" -#include "sysemu/tcg.h" -#include "sysemu/hw_accel.h" -#include "disas/capstone.h" -#include "fpu/softfloat.h" -#include "cpu-mmu.h" +#include "qemu/log.h" #include "tcg/tcg-cpu.h" /*
Signature · 1 line
2.20.1
PATCH v16 61/99 target/arm: remove broad "else" statements when checking accels
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
There might be more than just KVM and TCG in the future, so where appropriate, replace broad "else" statements with the appropriate if (accel_enabled()) check.
Also invert some checks for !kvm_enabled() or !tcg_enabled() where it seems appropriate to do so.
Note that to make qtest happy we need to perform gpio initialization in the qtest_enabled() case as well.
Hopefully we do not break any Xen stuff.
--- target/arm/cpu.c | 9 +++++---- target/arm/cpu64.c | 9 +++++---- target/arm/machine.c | 18 ++++++------------ 3 files changed, 16 insertions(+), 20 deletions(-)
target/arm/cpu.c +5 -4
@@ -37,6 +37,7 @@#endif #include "sysemu/tcg.h" +#include "sysemu/qtest.h" #include "kvm/kvm_arm.h" #include "disas/capstone.h" #include "fpu/softfloat.h"
@@ -564,7 +565,7 @@ static void arm_cpu_initfn(Object *obj)* the same interface as non-KVM CPUs. */ qdev_init_gpio_in (DEVICE (cpu), arm_cpu_kvm_set_irq,4 ); - }else { + }else if (tcg_enabled () ||qtest_enabled ()) {qdev_init_gpio_in (DEVICE (cpu), arm_cpu_set_irq,4 ); }
@@ -741,14 +742,14 @@ void arm_cpu_post_init(Object *obj) ?cpu_isar_feature (aa64_fp_simd, cpu) : cpu_isar_feature(aa32_vfp, cpu)) { cpu->has_vfp = true; -if (!kvm_enabled ()) { +if (tcg_enabled ()) {qdev_property_add_static (DEVICE (obj), &arm_cpu_has_vfp_property); } }if (arm_feature (&cpu->env,ARM_FEATURE_NEON )) { cpu->has_neon = true; -if (!kvm_enabled ()) { +if (tcg_enabled ()) {qdev_property_add_static (DEVICE (obj), &arm_cpu_has_neon_property); } }
@@ -849,7 +850,7 @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)* We have not registered the cpu properties when KVM * is in use, so the user will not be able to set them. */ -if (!kvm_enabled ()) { +if (tcg_enabled ()) {arm_cpu_pauth_finalize (cpu, &local_err);if (local_err !=NULL ) {error_propagate (errp, local_err);
target/arm/cpu64.c +5 -4
@@ -24,6 +24,7 @@#include "cpu.h" #include "cpu32.h" #include "qemu/module.h" +#include "sysemu/tcg.h" #include "sysemu/kvm.h" #include "kvm/kvm_arm.h" #include "qapi/visitor.h"
@@ -297,7 +298,7 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)*/ bitmap_andnot (tmp, kvm_supported, cpu->sve_vq_init, max_vq);bitmap_or (cpu->sve_vq_map, cpu->sve_vq_map, tmp, max_vq); - }else { + }else if (tcg_enabled ()) {/* Propagate enabled bits down through required powers-of-two. */ for (vq =pow2floor (max_vq); vq >=1 ; vq >>=1 ) {if (!test_bit (vq -1 , cpu->sve_vq_init)) {
@@ -334,7 +335,7 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) "vector length must be enabled.\n");return ; } - }else { + }else if (tcg_enabled ()) {/* Disabling a power-of-two disables all larger lengths. */ if (test_bit (0 , cpu->sve_vq_init)) {error_setg (errp,"cannot disable sve128" );
@@ -416,7 +417,7 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) }return ; } - }else { + }else if (tcg_enabled ()) {/* Ensure all required powers-of-two are enabled. */ for (vq =pow2floor (max_vq); vq >=1 ; vq >>=1 ) {if (!test_bit (vq -1 , cpu->sve_vq_map)) {
@@ -610,7 +611,7 @@ static void aarch64_max_initfn(Object *obj)if (kvm_enabled ()) {kvm_arm_set_cpu_features_from_host (cpu); - }else { + }else if (tcg_enabled ()) {uint64_t t;uint32_t u;aarch64_a57_initfn (obj);
target/arm/machine.c +6 -12
@@ -638,9 +638,11 @@ static int cpu_pre_save(void *opaque)if (tcg_enabled ()) {pmu_op_start (&cpu->env); - } - -if (kvm_enabled ()) { +if (!write_cpustate_to_list (cpu, false)) { +/* This should never fail. */ +abort (); + } + }else if (kvm_enabled ()) {if (!write_kvmstate_to_list (cpu)) {/* This should never fail */ abort ();
@@ -651,11 +653,6 @@ static int cpu_pre_save(void *opaque)* write_kvmstate_to_list() */ kvm_arm_cpu_pre_save (cpu); - }else { -if (!write_cpustate_to_list (cpu, false)) { -/* This should never fail. */ -abort (); - } } cpu->cpreg_vmstate_array_len = cpu->cpreg_array_len;
@@ -754,13 +751,10 @@ static int cpu_post_load(void *opaque, int version_id)*/ write_list_to_cpustate (cpu);kvm_arm_cpu_post_load (cpu); - }else { + }else if (tcg_enabled ()) {if (!write_list_to_cpustate (cpu)) {return -1 ; } - } - -if (tcg_enabled ()) {hw_breakpoint_update_all (cpu);hw_watchpoint_update_all (cpu);
Signature · 1 line
2.20.1
Re: [PATCH v16 61/99] target/arm: remove broad "else" statements when checking accels
Quoted 20 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
There might be more than just KVM and TCG in the future, so where appropriate, replace broad "else" statements with the appropriate if (
accel_enabled()) check.Also invert some checks for !kvm_enabled() or !tcg_enabled() where it seems appropriate to do so.
Note that to make qtest happy we need to perform gpio initialization in the
qtest_enabled()case as well.Hopefully we do not break any Xen stuff.
Signed-off-by Claudio Fontana<[email protected]>Cc Julien Grall<[email protected]>Cc Stefano Stabellini<[email protected]>Cc Olaf Hering<[email protected]>Cc Alex Bennée<[email protected]>Signed-off-by Alex Bennée<[email protected]>
Quoted 5 lines
--- target/arm/cpu.c | 9 +++++---- target/arm/cpu64.c | 9 +++++---- target/arm/machine.c | 18 ++++++------------ 3 files changed, 16 insertions(+), 20 deletions(-)
r~
PATCH v16 62/99 target/arm: remove kvm-stub.c
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
the functions used in machine.c are now protected via if (kvm_enabled()), so the stub is not needed.
--- target/arm/kvm-stub.c | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 target/arm/kvm-stub.c
target/arm/kvm-stub.c deleted +0 -24
@@ -1,24 +0,0 @@ -/* -* QEMU KVM ARM specific function stubs -* -* Copyright Linaro Limited 2013 -* -* Author: Peter Maydell <[email protected]> -* -* This work is licensed under the terms of the GNU GPL, version 2 or later. -* See the COPYING file in the top-level directory. -* -*/ -#include "qemu/osdep.h" -#include "cpu.h" -#include "kvm_arm.h" - -bool write_kvmstate_to_list (ARMCPU *cpu) -{ -abort (); -} - -bool write_list_to_kvmstate (ARMCPU *cpu,int level) -{ -abort (); -}
Signature · 1 line
2.20.1
PATCH v16 63/99 tests/qtest: skip bios-tables-test test_acpi_oem_fields_virt for KVM
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
test is TCG-only.
--- tests/qtest/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)
tests/qtest/bios-tables-test.c +7 -0
@@ -1484,6 +1484,13 @@ static void test_acpi_oem_fields_virt_tcg(void) };char *args; +#ifndef CONFIG_TCG +if (data.tcg_only) { +g_test_skip ("TCG disabled, skipping ACPI tcg_only test" ); +return ; + } +#endif /* CONFIG_TCG */ + args =test_acpi_create_args (&data,"-cpu cortex-a57 " OEM_TEST_ARGS , true); data.qts =qtest_init (args);
Signature · 1 line
2.20.1
Re: [PATCH v16 63/99] tests/qtest: skip bios-tables-test test_acpi_oem_fields_virt for KVM
Quoted 10 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
test is TCG-only.
Signed-off-by Claudio Fontana<[email protected]>Cc Philippe Mathieu-Daudé<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- tests/qtest/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)
The new qtest_has_accel should be used instead of an ifdef.
r~
Re: [PATCH v16 63/99] tests/qtest: skip bios-tables-test test_acpi_oem_fields_virt for KVM
Quoted 11 lines · Richard Henderson
Quoted 8 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
test is TCG-only.Signed-off-by Claudio Fontana<[email protected]>Cc Philippe Mathieu-Daudé<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- tests/qtest/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)The new
qtest_has_accelshould be used instead of an ifdef.
I think I can drop the whole patch as nothing is added unless:
} else if (strcmp(arch, "aarch64") == 0 && tcg_accel_available) {further down.
Quoted 3 lines
r~
Signature · 1 line
Alex Bennée
PATCH v16 64/99 tests: do not run test-hmp on all machines for ARM KVM-only
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
on ARM we currently list and build all machines, even when building KVM-only, without TCG.
Until we fix this (and we only list and build machines that are compatible with KVM), only test specifically using the "virt" machine in this case.
--- tests/qtest/test-hmp.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tests/qtest/test-hmp.c +20 -0
@@ -157,8 +157,28 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL ); +/* +* XXX currently we build also boards for ARM that are incompatible with KVM. +* We therefore need to check this explicitly, and only test virt for kvm-only +* arm builds. +* After we do the work of Kconfig etc to ensure that only KVM-compatible boards +* are built for the kvm-only build, we could remove this. +*/ +#ifndef CONFIG_TCG + { +const char *arch =qtest_get_arch (); + +if (strcmp (arch,"arm" ) ==0 ||strcmp (arch,"aarch64" ) ==0 ) { +add_machine_test_case ("virt" ); + goto add_machine_test_done; + } + } +#endif /* !CONFIG_TCG */ +qtest_cb_for_every_machine (add_machine_test_case,g_test_quick ()); + goto add_machine_test_done; + add_machine_test_done:/* as none machine has no memory by default, add a test case with memory */ qtest_add_data_func ("hmp/none+2MB" ,g_strdup ("none -m 2" ), test_machine);
Signature · 1 line
2.20.1
Re: [PATCH v16 64/99] tests: do not run test-hmp on all machines for ARM KVM-only
Quoted 9 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
on ARM we currently list and build all machines, even when building KVM-only, without TCG.
Until we fix this (and we only list and build machines that are compatible with KVM), only test specifically using the "virt" machine in this case.
Quoted 6 lines
Signed-off-by Claudio Fontana<[email protected]>Cc Philippe Mathieu-Daudé<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- tests/qtest/test-hmp.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
qtest_has_accel, I assume.
PATCH v16 65/99 tests: device-introspect-test: cope with ARM TCG-only devices
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
Skip the test_device_intro_concrete for now for ARM KVM-only build, as on ARM we currently build devices for ARM that are not compatible with a KVM-only build.
We can remove this workaround when we fix this in KConfig etc, and we only list and build machines that are compatible with KVM for KVM-only builds.
Alternative implementation provided by Alex.
--- tests/qtest/device-introspect-test.c | 32 +++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)
tests/qtest/device-introspect-test.c +27 -5
@@ -305,6 +305,24 @@ static void test_abstract_interfaces(void)qtest_quit (qts); } +/* +* XXX currently we build also boards for ARM that are incompatible with KVM. +* We therefore need to check this explicitly, and only test virt for kvm-only +* arm builds. +* After we do the work of Kconfig etc to ensure that only KVM-compatible boards +* are built for the kvm-only build, we could remove this. +*/ +static bool skip_machine_tests (void ) +{ +#ifndef CONFIG_TCG +const char *arch =qtest_get_arch (); +if (strcmp (arch,"arm" ) ==0 ||strcmp (arch,"aarch64" ) ==0 ) { +return true; + } +#endif /* !CONFIG_TCG */ +return false; +} +static void add_machine_test_case (const char *mname) {char *path, *args;
@@ -329,11 +347,15 @@ int main(int argc, char **argv)qtest_add_func ("device/introspect/none" , test_device_intro_none);qtest_add_func ("device/introspect/abstract" , test_device_intro_abstract);qtest_add_func ("device/introspect/abstract-interfaces" , test_abstract_interfaces); -if (g_test_quick ()) { -qtest_add_data_func ("device/introspect/concrete/defaults/none" , -g_strdup (common_args), test_device_intro_concrete); - }else { -qtest_cb_for_every_machine (add_machine_test_case, true); + +if (!skip_machine_tests ()) { +if (g_test_quick ()) { +qtest_add_data_func ("device/introspect/concrete/defaults/none" , +g_strdup (common_args), + test_device_intro_concrete); + }else { +qtest_cb_for_every_machine (add_machine_test_case, true); + } }return g_test_run ();
Signature · 1 line
2.20.1
Re: [PATCH v16 65/99] tests: device-introspect-test: cope with ARM TCG-only devices
Quoted 12 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
Skip the
test_device_intro_concretefor now for ARM KVM-only build, as on ARM we currently build devices for ARM that are not compatible with a KVM-only build.We can remove this workaround when we fix this in KConfig etc, and we only list and build machines that are compatible with KVM for KVM-only builds.
Alternative implementation provided by Alex.
Quoted 7 lines
Suggested-by Alex Bennée<[email protected]>Signed-off-by Claudio Fontana<[email protected]>Cc Philippe Mathieu-Daudé<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- tests/qtest/device-introspect-test.c | 32 +++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)
Similarly, qtest_has_accel.
r~
PATCH v16 66/99 tests: do not run qom-test on all machines for ARM KVM-only
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
on ARM we currently list and build all machines, even when building KVM-only, without TCG.
Until we fix this (and we only list and build machines that are compatible with KVM), only test specifically using the "virt" machine in this case.
--- tests/qtest/qom-test.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
tests/qtest/qom-test.c +20 -0
@@ -90,7 +90,27 @@ int main(int argc, char **argv) {g_test_init (&argc, &argv,NULL ); +/* +* XXX currently we build also boards for ARM that are incompatible with KVM. +* We therefore need to check this explicitly, and only test virt for kvm-only +* arm builds. +* After we do the work of Kconfig etc to ensure that only KVM-compatible boards +* are built for the kvm-only build, we could remove this. +*/ +#ifndef CONFIG_TCG + { +const char *arch =qtest_get_arch (); + +if (strcmp (arch,"arm" ) ==0 ||strcmp (arch,"aarch64" ) ==0 ) { +add_machine_test_case ("virt" ); + goto add_machine_test_done; + } + } +#endif /* !CONFIG_TCG */ +qtest_cb_for_every_machine (add_machine_test_case,g_test_quick ()); + goto add_machine_test_done; + add_machine_test_done:return g_test_run (); }
Signature · 1 line
2.20.1
Re: [PATCH v16 66/99] tests: do not run qom-test on all machines for ARM KVM-only
Quoted 9 lines · Alex Bennée
From: Claudio Fontana<[email protected]>
on ARM we currently list and build all machines, even when building KVM-only, without TCG.
Until we fix this (and we only list and build machines that are compatible with KVM), only test specifically using the "virt" machine in this case.
Quoted 6 lines
Signed-off-by Claudio Fontana<[email protected]>Cc Philippe Mathieu-Daudé<[email protected]>Signed-off-by Alex Bennée<[email protected]>--- tests/qtest/qom-test.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
Similarly, qtest_has_accel.
r~
PATCH v16 67/99 target/arm: create kvm cpu accel class
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
move init, realizefn and reset code into it.
--- target/arm/internals.h | 1 - target/arm/cpu-sysemu.c | 32 ---------- target/arm/cpu.c | 49 +++----------- target/arm/kvm/kvm-cpu.c | 128 +++++++++++++++++++++++++++++++++++++ target/arm/kvm/meson.build | 1 + 5 files changed, 137 insertions(+), 74 deletions(-) create mode 100644 target/arm/kvm/kvm-cpu.c
target/arm/internals.h +0 -1
@@ -1165,7 +1165,6 @@ static inline uint64_t useronly_maybe_clean_ptr(uint32_t desc, uint64_t ptr)#ifndef CONFIG_USER_ONLY void arm_cpu_set_irq (void *opaque,int irq,int level); -void arm_cpu_kvm_set_irq (void *opaque,int irq,int level);bool arm_cpu_virtio_is_big_endian (CPUState *cs);#endif /* !CONFIG_USER_ONLY */
target/arm/cpu-sysemu.c +0 -32
@@ -24,7 +24,6 @@#include "cpu.h" #include "internals.h" #include "sysemu/hw_accel.h" -#include "kvm/kvm_arm.h" #include "sysemu/tcg.h" #include "tcg/tcg-cpu.h"
@@ -72,37 +71,6 @@ void arm_cpu_set_irq(void *opaque, int irq, int level) } } -void arm_cpu_kvm_set_irq (void *opaque,int irq,int level) -{ -#ifdef CONFIG_KVM -ARMCPU *cpu = opaque; -CPUARMState *env = &cpu->env; -CPUState *cs =CPU (cpu); -uint32_t linestate_bit; -int irq_id; - -switch (irq) { -case ARM_CPU_IRQ : - irq_id =KVM_ARM_IRQ_CPU_IRQ ; - linestate_bit =CPU_INTERRUPT_HARD ; -break ; -case ARM_CPU_FIQ : - irq_id =KVM_ARM_IRQ_CPU_FIQ ; - linestate_bit =CPU_INTERRUPT_FIQ ; -break ; -default : -g_assert_not_reached (); - } - -if (level) { - env->irq_line_state |= linestate_bit; - }else { - env->irq_line_state &= ~linestate_bit; - } -kvm_arm_set_irq (cs->cpu_index,KVM_ARM_IRQ_TYPE_CPU , irq_id, !!level); -#endif -} -bool arm_cpu_virtio_is_big_endian (CPUState *cs) {ARMCPU *cpu =ARM_CPU (cs);
target/arm/cpu.c +8 -41
95 lines not on this page · raw message
target/arm/kvm/kvm-cpu.c new file +128 -0
128 lines not on this page · raw message
target/arm/kvm/meson.build +1 -0
@@ -1,4 +1,5 @@ arm_ss.add(when: 'CONFIG_KVM', if_true: files( 'kvm.c', 'kvm64.c', + 'kvm-cpu.c', ))
Signature · 1 line
2.20.1
PATCH v16 68/99 target/arm: move kvm post init initialization to kvm cpu accel
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
--- target/arm/cpu.c | 4 ---- target/arm/kvm/kvm-cpu.c | 1 + 2 files changed, 1 insertion(+), 4 deletions(-)
target/arm/cpu.c +0 -4
@@ -778,10 +778,6 @@ void arm_cpu_post_init(Object *obj)qdev_property_add_static (DEVICE (cpu), &arm_cpu_gt_cntfrq_property); } -if (kvm_enabled ()) { -kvm_arm_add_vcpu_properties (obj); - } -#ifndef CONFIG_USER_ONLY if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 ) &&cpu_isar_feature (aa64_mte, cpu)) {
target/arm/kvm/kvm-cpu.c +1 -0
@@ -63,6 +63,7 @@ static void kvm_cpu_instance_init(CPUState *cs)* the same interface as non-KVM CPUs. */ qdev_init_gpio_in (DEVICE (cs), arm_cpu_kvm_set_irq,4 ); +kvm_arm_add_vcpu_properties (OBJECT (cs)); }static bool kvm_cpu_realizefn (CPUState *cs,Error **errp)
Signature · 1 line
2.20.1
PATCH v16 69/99 target/arm: add tcg cpu accel class
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
move init, realizefn and reset code into it.
--- target/arm/tcg/tcg-cpu.h | 4 ++- target/arm/cpu.c | 44 ++------------------------ target/arm/tcg/sysemu/tcg-cpu.c | 27 ++++++++++++++++ target/arm/tcg/tcg-cpu-models.c | 10 +++--- target/arm/tcg/tcg-cpu.c | 55 +++++++++++++++++++++++++++++++-- 5 files changed, 92 insertions(+), 48 deletions(-)
target/arm/tcg/tcg-cpu.h +3 -1
@@ -22,15 +22,17 @@#include "cpu.h" #include "hw/core/tcg-cpu-ops.h" +#include "hw/core/accel-cpu.h" void arm_cpu_synchronize_from_tb (CPUState *cs,const TranslationBlock *tb); -extern struct TCGCPUOps arm_tcg_ops; +void tcg_arm_init_accel_cpu (AccelCPUClass *accel_cpu,CPUClass *cc);#ifndef CONFIG_USER_ONLY /* Do semihosting call and set the appropriate return value. */ void tcg_handle_semihosting (CPUState *cs); +bool tcg_cpu_realizefn (CPUState *cs,Error **errp);#endif /* !CONFIG_USER_ONLY */
target/arm/cpu.c +3 -41
74 lines not on this page · raw message
target/arm/tcg/sysemu/tcg-cpu.c +27 -0
@@ -19,10 +19,13 @@*/ #include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/timer.h" #include "cpu.h" #include "semihosting/common-semi.h" #include "qemu/log.h" #include "tcg/tcg-cpu.h" +#include "internals.h" /* * Do semihosting call and set the appropriate return value. All the
@@ -50,3 +53,27 @@ void tcg_handle_semihosting(CPUState *cs) env->regs[15 ] += env->thumb ?2 :4 ; } } + +bool tcg_cpu_realizefn (CPUState *cs,Error **errp) +{ +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; + +/* +* The NVIC and M-profile CPU are two halves of a single piece of +* hardware; trying to use one without the other is a command line +* error and will result in segfaults if not caught here. +*/ +if (arm_feature (env,ARM_FEATURE_M )) { +if (!env->nvic) { +error_setg (errp,"This board cannot be used with Cortex-M CPUs" ); +return false; + } + }else { +if (env->nvic) { +error_setg (errp,"This board can only be used with Cortex-M CPUs" ); +return false; + } + } +return true; +}
target/arm/tcg/tcg-cpu-models.c +6 -4
@@ -846,16 +846,18 @@ static const struct TCGCPUOps arm_v7m_tcg_ops = { };#endif /* CONFIG_TCG */ +static void arm_v7m_init_accel_cpu (AccelCPUClass *accel_cpu,CPUClass *cc) +{ + cc->tcg_ops = &arm_v7m_tcg_ops; +} +static void arm_v7m_class_init (ObjectClass *oc,void *data) {ARMCPUClass *acc =ARM_CPU_CLASS (oc);CPUClass *cc =CPU_CLASS (oc); acc->info = data; -#ifdef CONFIG_TCG - cc->tcg_ops = &arm_v7m_tcg_ops; -#endif /* CONFIG_TCG */ - + cc->init_accel_cpu = arm_v7m_init_accel_cpu; cc->gdb_core_xml_file ="arm-m-profile.xml" ; }
target/arm/tcg/tcg-cpu.c +53 -2
71 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH v16 69/99] target/arm: add tcg cpu accel class
Quoted 20 lines · Alex Bennée
From: Claudio Fontana <[email protected]>
move init, realizefn and reset code into it.
Signed-off-by Claudio Fontana <[email protected]>Cc Paolo Bonzini <[email protected]>Signed-off-by Alex Bennée <[email protected]>--- target/arm/tcg/tcg-cpu.h | 4 ++- target/arm/cpu.c | 44 ++------------------------ target/arm/tcg/sysemu/tcg-cpu.c | 27 ++++++++++++++++ target/arm/tcg/tcg-cpu-models.c | 10 +++--- target/arm/tcg/tcg-cpu.c | 55 +++++++++++++++++++++++++++++++-- 5 files changed, 92 insertions(+), 48 deletions(-)target/arm/tcg/tcg-cpu.h +0
-0
target/arm/tcg/tcg-cpu.h line 25
Quoted 4 lines
target/arm/tcg/tcg-cpu.h +1
-0@@ -22,15 +22,17 @@#include "cpu.h" #include "hw/core/tcg-cpu-ops.h" +#include "hw/core/accel-cpu.h"
Ideally we'd have a qemu/typedef.h entry so this include isn't needed...
target/arm/tcg/tcg-cpu.h line 30
Quoted 6 lines
target/arm/tcg/tcg-cpu.h +1
-1void arm_cpu_synchronize_from_tb (CPUState *cs,const TranslationBlock *tb); -extern struct TCGCPUOps arm_tcg_ops; +void tcg_arm_init_accel_cpu (AccelCPUClass *accel_cpu,CPUClass *cc);
... simply for this declaration.
Also, can we now remove the tcg-cpu-ops.h include?
target/arm/tcg/tcg-cpu.h static void arm_cpu_class_init(ObjectClass *oc, void *data) · line 1433
Quoted 7 lines
target/arm/tcg/tcg-cpu.h +1
-1@@ -1467,7 +1429,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->disas_set_info = arm_disas_set_info;#ifdef CONFIG_TCG - cc->tcg_ops = &arm_tcg_ops; + cc->init_accel_cpu = tcg_arm_init_accel_cpu;#endif /* CONFIG_TCG */
Is this already inside tcg_enabled()? Because otherwise it looks as if this is overwriting a field also used by kvm. Whereas the code that's being replaced set a field only used by tcg.
KVM sets its hooks differently, via kvm_cpu_accel_register_types, so I don't understand this hook at all. But it seems like there should not be two different ways to set acc->cpu_instance_init.
r~
Re: [PATCH v16 69/99] target/arm: add tcg cpu accel class
Quoted 16 lines · Richard Henderson
Quoted 15 lines · Alex Bennée
From: Claudio Fontana <[email protected]> move init, realizefn and reset code into it.
Signed-off-by Claudio Fontana <[email protected]>Cc Paolo Bonzini <[email protected]>Signed-off-by Alex Bennée <[email protected]>--- target/arm/tcg/tcg-cpu.h | 4 ++- target/arm/cpu.c | 44 ++------------------------ target/arm/tcg/sysemu/tcg-cpu.c | 27 ++++++++++++++++ target/arm/tcg/tcg-cpu-models.c | 10 +++--- target/arm/tcg/tcg-cpu.c | 55 +++++++++++++++++++++++++++++++-- 5 files changed, 92 insertions(+), 48 deletions(-)target/arm/tcg/tcg-cpu.h +0
-1--- a/target/arm/tcg/tcg-cpu.h
Quoted 8 lines
target/arm/tcg/tcg-cpu.h line 24
Quoted 5 lines
+++
b/target/arm/tcg/tcg-cpu.htarget/arm/tcg/tcg-cpu.h +1
-0@@ -22,15 +22,17 @@#include "cpu.h" #include "hw/core/tcg-cpu-ops.h" +#include "hw/core/accel-cpu.h" Ideally we'd have a
qemu/typedef.hentry so this include isn't needed...
Ok, moved the needed includes into the .c
Quoted 9 lines
target/arm/tcg/tcg-cpu.h line 30
Quoted 5 lines
target/arm/tcg/tcg-cpu.h +1
-0void arm_cpu_synchronize_from_tb (CPUState *cs,const TranslationBlock *tb); -extern struct TCGCPUOps arm_tcg_ops; +void tcg_arm_init_accel_cpu (AccelCPUClass *accel_cpu,CPUClass *cc);... simply for this declaration.
Also, can we now remove thetcg-cpu-ops.hinclude?
Quoted 9 lines
target/arm/tcg/tcg-cpu.h static void arm_cpu_class_init(ObjectClass *oc, void *data) · line 1432
Quoted 6 lines
target/arm/tcg/tcg-cpu.h +1
-1@@ -1467,7 +1429,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->disas_set_info = arm_disas_set_info;#ifdef CONFIG_TCG - cc->tcg_ops = &arm_tcg_ops; + cc->init_accel_cpu = tcg_arm_init_accel_cpu;#endif /* CONFIG_TCG */ Is this already inside
tcg_enabled()? Because otherwise it looks as if this is overwriting a field also used by kvm.
Is it? I can only see the existing x86 TCG CPU and now in this case allowing an override of arm_v7m_init_accel_cpu and it's resulting TCG ops variant. This is because all the 32 bit CPUs now have parent = TYPE_ARM_CPU as their parent class.
Quoted 5 lines
Whereas the code that's being replaced set a field only used by tcg.
KVM sets its hooks differently, via
kvm_cpu_accel_register_types, so I don't understand this hook at all. But it seems like there should not be two different ways to setacc->cpu_instance_init.
That isn't being reset - it's set once in the which ever accel_class_init ends up being instantiated. Of course this is all QOM so I could be wrong.
Quoted 3 lines
r~
Signature · 1 line
Alex Bennée
PATCH v16 70/99 target/arm: move TCG gt timer creation code in tcg/
In reply to Alex BennéeFrom: Claudio Fontana <[email protected]>
we need to be careful not to use
if (tcg_enabled())
here, because of the VMSTATE definitions in machine.c, which are only protected by CONFIG_TCG, and thus it would break the --enable-tcg --enable-kvm build.
--- target/arm/tcg/tcg-cpu.h | 1 + target/arm/cpu.c | 30 ++++--------------------- target/arm/tcg/sysemu/tcg-cpu.c | 40 +++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 26 deletions(-)
target/arm/tcg/tcg-cpu.h +1 -0
@@ -33,6 +33,7 @@ void tcg_arm_init_accel_cpu(AccelCPUClass *accel_cpu, CPUClass *cc);/* Do semihosting call and set the appropriate return value. */ void tcg_handle_semihosting (CPUState *cs);bool tcg_cpu_realizefn (CPUState *cs,Error **errp); +bool tcg_cpu_realize_gt_timers (CPUState *cs,Error **errp);#endif /* !CONFIG_USER_ONLY */
target/arm/cpu.c +4 -26
@@ -859,32 +859,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)bool no_aa32 = false;#if defined(CONFIG_TCG ) && !defined(CONFIG_USER_ONLY ) - { -uint64_t scale; - -if (arm_feature (env,ARM_FEATURE_GENERIC_TIMER )) { -if (!cpu->gt_cntfrq_hz) { -error_setg (errp,"Invalid CNTFRQ: %" PRId64"Hz" , - cpu->gt_cntfrq_hz); -return ; - } - scale =gt_cntfrq_period_ns (cpu); - }else { - scale =GTIMER_SCALE ; - } - - cpu->gt_timer[GTIMER_PHYS ] =timer_new (QEMU_CLOCK_VIRTUAL , scale, - arm_gt_ptimer_cb, cpu); - cpu->gt_timer[GTIMER_VIRT ] =timer_new (QEMU_CLOCK_VIRTUAL , scale, - arm_gt_vtimer_cb, cpu); - cpu->gt_timer[GTIMER_HYP ] =timer_new (QEMU_CLOCK_VIRTUAL , scale, - arm_gt_htimer_cb, cpu); - cpu->gt_timer[GTIMER_SEC ] =timer_new (QEMU_CLOCK_VIRTUAL , scale, - arm_gt_stimer_cb, cpu); - cpu->gt_timer[GTIMER_HYPVIRT ] =timer_new (QEMU_CLOCK_VIRTUAL , scale, - arm_gt_hvtimer_cb, cpu); - } -#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ +if (!tcg_cpu_realize_gt_timers (cs, errp)) { +return ; + } +#endif cpu_exec_realizefn (cs, &local_err);if (local_err !=NULL ) {
target/arm/tcg/sysemu/tcg-cpu.c +40 -0
@@ -54,6 +54,46 @@ void tcg_handle_semihosting(CPUState *cs) } } +/* +* we cannot use tcg_enabled() to condition the call to this function, +* due to the fields VMSTATE definitions in machine.c : it would break +* the --enable-tcg --enable-kvm build. We need to run this code whenever +* CONFIG_TCG is true, regardless of the chosen accelerator. +* +* So we cannot call this from tcg_cpu_realizefn, as this needs to +* be called whenever TCG is built-in, regardless of whether it is +* enabled or not. +*/ +bool tcg_cpu_realize_gt_timers (CPUState *cs,Error **errp) +{ +ARMCPU *cpu =ARM_CPU (cs); +CPUARMState *env = &cpu->env; +uint64_t scale; + +if (arm_feature (env,ARM_FEATURE_GENERIC_TIMER )) { +if (!cpu->gt_cntfrq_hz) { +error_setg (errp,"Invalid CNTFRQ: %" PRId64"Hz" , + cpu->gt_cntfrq_hz); +return false; + } + scale =gt_cntfrq_period_ns (cpu); + }else { + scale =GTIMER_SCALE ; + } + + cpu->gt_timer[GTIMER_PHYS ] =timer_new (QEMU_CLOCK_VIRTUAL , scale, + arm_gt_ptimer_cb, cpu); + cpu->gt_timer[GTIMER_VIRT ] =timer_new (QEMU_CLOCK_VIRTUAL , scale, + arm_gt_vtimer_cb, cpu); + cpu->gt_timer[GTIMER_HYP ] =timer_new (QEMU_CLOCK_VIRTUAL , scale, + arm_gt_htimer_cb, cpu); + cpu->gt_timer[GTIMER_SEC ] =timer_new (QEMU_CLOCK_VIRTUAL , scale, + arm_gt_stimer_cb, cpu); + cpu->gt_timer[GTIMER_HYPVIRT ] =timer_new (QEMU_CLOCK_VIRTUAL , scale, + arm_gt_hvtimer_cb, cpu); +return true; +} +bool tcg_cpu_realizefn (CPUState *cs,Error **errp) {ARMCPU *cpu =ARM_CPU (cs);
Signature · 1 line
2.20.1