arm cleanup experiment for kvm-only build
Subsystems (2)
v11 cover arm cleanup experiment for kvm-only build
Here a new version of the series that enables kvm-only builds.
The goal here is to enable the KVM-only build, but there is some additional cleanup too.
In this iteration we split helpers in tcg/ into user and sysemu parts, to put into the respective directories.
I also had to actually remove the asserts in tcg_arm_init_accel_cpu, as they were breaking for "enable-all" builds, including both KVM and TCG.
Comments welcome, thanks,
Ciao, C
v10 ->v11:
* "target/arm: tcg: split mte_helper user-only and sysemu code" (new)
* "target/arm: tcg: move sysemu-only parts of debug_helper" (new)
* "target/arm: tcg: split tlb_helper user-only and sysemu-only parts" (new)
* "target/arm: tcg: split m_helper user-only and sysemu-only parts: (new)
* "target/arm: tcg: remove superfluous CONFIG_TCG check" (new)
* "target/arm: remove v7m stub function for !CONFIG_TCG" (new)
* "target/arm: add tcg cpu accel class"
- removed the asserts for tcg_arm_init_accel_cpu, as they break for "enable-all" builds which include both TCG and KVM.
v9 -> v10:
* "target/arm: create kvm cpu accel class"
- add accel_cpu::cpu_reset to kvm-cpu
* "target/arm: add tcg cpu accel class"
- add accel_cpu::cpu_reset to tcg-cpu
* 'XXX target/arm: experiment refactoring cpu "max"'
- new tentative RFC for discussion
v8 -> v9:
* added: "make is_aa64 and arm_el_is_aa64 a macro for !TARGET_AARCH64"
* added: "arch_dump: restrict ELFCLASS64 to AArch64"
* added: "cpu-exceptions: new module"
* added: "tcg: restrict ZCR cpregs to TARGET_AARCH64"
* added: "cpu-pauth: new module for ARMv8.3 Pointer Authentication"
* added: "refactor arm_cpu_finalize_features into cpu64"
v7 -> v8:
* added split of SVE CPU properties code from cpu into cpu-sve.
* added split of cpu-sve into tcg/cpu-sve and kvm/cpu-sve.
v6 -> v7:
* added tcg accel-cpu, experiment with improving the setting of the TCGOps, as discussed at:
https://lists.gnu.org/archive/html/qemu-devel/2021-03/msg04315.html
v5 -> v6:
* rebased on latest master, adapted to arm changes
* needed to restore the cortex-a15 cpu,
moving it away from the TCG-only cpu file. This is a partial revert of commit "target/arm: Restrict TCG cpus to TCG accel"
* added first patches that create the kvm cpu accel class
v4 -> v5:
* fixed other remaining tests for kvm-only build
* rebased on latest target/arm changes (painful)
* reverted Philippe's IDAU v8m change
v3 -> v4:
* added style cleanup patches
* added header cleanup
* added basic move of simple KVM-only code to kvm/
* fixed some qtest failures due to existing:
if (kvm_enabled) {
} else {
} which needed explicit if qtest_enabled() in addition to tcg_enabled() check
* include 32bit cpus for AArch64 too.
v2 -> v3:
* "target/arm: tcg: add sysemu and user subsirs"
- new standalone patch to create the empty tcg/sysemu and tcg/user subdirs.
* "target/arm: only build psci for TCG"
- do not move psci inside tcg/ directory, because HVF might use it soon.
(Peter)
* "target/arm: move physical address translation"
- change the module name from "get-phys-addr" to "cpu-mmu", which includes aa64_va_parameter in this patch, and that will also contain the get_mmu_idx* functions later in the series. (Richard)
* "target/arm: split cpregs from tcg/helper.c"
- moved raw_read and raw_write to cpregs.h (Richard)
* "target/arm: only perform TCG cpu and machine inits if TCG enabled"
- add an explanatory comment before the kvm function for cpreg list init
- change the use of g_renew to g_new, since we do not do the double initialization of cpreg list anymore.
* "target/arm: add temporary stub for arm_rebuild_hflags"
- use a if (tcg_enabled()) instead of #ifdef (Richard)
* "target/arm: split vfp state setting from tcg helpers"
- explain better what goes where in the commit (Richard)
* "target/arm: move arm_mmu_idx*"
- move the functions to cpu-mmu instead of get-phys-addr (Richard)
* "target/arm: move sve_zcr_len_for_el to common_cpu"
- add a comment about those functions being in theory TARGET_AARCH64 specific, but making the change would spawn a large number of additional #ifdefs. This state predates this change (Richard).
* "target/arm: move aarch64_sync_32_to_64 (and vv) to cpu code"
- explain better why these functions are needed for KVM too (Richard)
* "target/arm: move sve_exception_el out of TCG helpers"
- bring over the sve_exception_el code, making it available for KVM too. (Richard)
* "target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()"
- mention in the commit that this enables finally a build with configure --enable-kvm --disable-tcg
v1 -> v2: reworked of the whole series
In this v2, only the first two patches remain, the rest is reworked.
Main reasons for the rework were:
1) moving out cpregs to its own module, leave the tcg-only part in tcg/
2) split of arm cpu32, cpu64 and cpu models. This is still not perfect, but I think it's an improvement.
3) import less stuff, that is actually unused or can be stubbed on KVM (thanks to the precious feedback on the previous RFCv1).
...
Main issues:
1) basically needs the "configure only machines compatible with KVM" from Philippe, so we can avoid some of the stubs.
2) tests/ work fine building with tcg or with tcg + kvm,
but for making a kvm-only build pass the tests, more work is needed in tests/ figuring out which tests are TCG-only and which need to be tweaked.
Thanks a lot for your comments!
. / . / . / . / . / . /
Hi all,
this is an experiment, a cleanup based on and requiring the series "i386 cleanup PART 2":
https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg05935.html
The goal is to split the code between TCG-only and non-TCG code, fixing the KVM-only build (configure --disable-tcg),
and laying the ground for further cleanups and the use of the new accel objects in the hierarchy to specialize the cpu according to the accelerator.
This is known to be an early state, with probably a lot of work still needed.
I thought it could be useful to share early, especially in light of the combination of this with Philippe's work on building only the machines and devices compatible with KVM for arm.
Comments welcome, thanks,
Claudio
Claudio Fontana (55):
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: move physical address translation to cpu-mmu target/arm: cpu-mmu: fix comment style
target/arm: split cpregs from tcg/helper.c
target/arm: cpregs: fix style (mostly just comments) target/arm: move cpu definitions to common cpu module target/arm: only perform TCG cpu and machine inits if TCG enabled target/arm: kvm: add stubs for some helpers
target/arm: move cpsr_read, cpsr_write to cpu_common target/arm: add temporary stub for arm_rebuild_hflags 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: split a15 cpu model and 32bit class functions to cpu32.c target/arm: move sve_exception_el out of TCG helpers target/arm: refactor exception and cpu code
target/arm: cpu: fix style
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/ target/arm: cleanup cpu includes
target/arm: remove broad "else" statements when checking accels tests/qtest: skip bios-tables-test test_acpi_oem_fields_virt for KVM
tests: restrict TCG-only arm-cpu-features tests to TCG builds
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 Revert "target/arm: Restrict v8M IDAU to TCG"
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: split TCG and KVM functionality target/arm: make is_aa64 and arm_el_is_aa64 a macro for
!TARGET_AARCH64
target/arm: arch_dump: restrict ELFCLASS64 to AArch64 target/arm: cpu-exceptions: new module
target/arm: tcg: restrict ZCR cpregs to TARGET_AARCH64 target/arm: cpu-pauth: new module for ARMv8.3 Pointer Authentication target/arm: refactor arm_cpu_finalize_features into cpu64 XXX target/arm: experiment refactoring cpu "max" target/arm: tcg: remove superfluous CONFIG_TCG check target/arm: remove v7m stub function for !CONFIG_TCG
meson.build | 3 +-
target/arm/arm-powerctl.h | 2 -
target/arm/cpregs.h | 274 +
target/arm/cpu-exceptions-aa64.h | 32 +
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 | 323 +-
target/arm/cpu32.h | 29 +
target/arm/helper-a64.h | 2 +
target/arm/helper.h | 1 -
target/arm/internals.h | 46 +-
target/arm/kvm/cpu-sve.h | 30 +
target/arm/{ => kvm}/kvm-consts.h | 0
target/arm/{ => kvm}/kvm_arm.h | 5 +-
target/arm/kvm/trace.h | 1 +
target/arm/tcg/cpu-pauth.h | 38 +
target/arm/tcg/cpu-sve.h | 31 +
target/arm/tcg/m_helper.h | 21 +
target/arm/tcg/mte_helper.h | 52 +
target/arm/{ => tcg}/op_addsub.h | 0
target/arm/tcg/tcg-cpu.h | 40 +
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 -
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
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/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 | 4 +
target/arm/arch_dump.c | 13 +-
target/arm/arm-powerctl.c | 8 +-
target/arm/cpregs.c | 377 +
target/arm/cpu-common.c | 329 +
target/arm/cpu-exceptions-aa64.c | 553 ++
target/arm/cpu-exceptions.c | 481 ++
target/arm/cpu-mmu-sysemu.c | 2305 +++++++
target/arm/cpu-mmu.c | 214 +
target/arm/cpu-sve.c | 292 +
target/arm/cpu-sysemu.c | 80 +
target/arm/cpu-user.c | 41 +
target/arm/cpu-vfp.c | 92 +
target/arm/cpu.c | 785 +--
target/arm/cpu32.c | 260 +
target/arm/cpu64.c | 698 +-
target/arm/cpustate-list.c | 146 +
target/arm/gdbstub.c | 5 +-
target/arm/kvm-stub.c | 24 -
target/arm/kvm/cpu-sve.c | 118 +
target/arm/kvm/helper-stubs.c | 43 +
target/arm/kvm/kvm-cpu.c | 127 +
target/arm/{ => kvm}/kvm.c | 18 +-
target/arm/{ => kvm}/kvm64.c | 8 +-
target/arm/machine.c | 40 +-
target/arm/monitor.c | 10 +-
target/arm/psci.c | 1 -
target/arm/{helper.c => tcg/cpregs.c} | 6102 +----------------
target/arm/tcg/cpu-pauth.c | 66 +
target/arm/tcg/cpu-sve.c | 80 +
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 | 2 +
target/arm/tcg/helper.c | 1532 +++++
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 | 200 +-
target/arm/tcg/sysemu/mte_helper.c | 159 +
target/arm/tcg/sysemu/tcg-cpu.c | 120 +
target/arm/tcg/sysemu/tlb_helper.c | 84 +
.../arm/{cpu_tcg.c => tcg/tcg-cpu-models.c} | 163 +-
target/arm/tcg/tcg-cpu.c | 498 ++
target/arm/{ => tcg}/tlb_helper.c | 96 +-
target/arm/{ => tcg}/translate-a64.c | 1 +
target/arm/{ => tcg}/translate-sve.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 | 31 +
target/arm/{ => tcg}/vec_helper.c | 0
target/arm/{ => tcg}/vfp_helper.c | 216 +-
tests/qtest/arm-cpu-features.c | 15 +
tests/qtest/bios-tables-test.c | 7 +
tests/qtest/device-introspect-test.c | 18 +
tests/qtest/qom-test.c | 20 +
tests/qtest/test-hmp.c | 20 +
target/arm/{ => tcg}/translate-neon.c.inc | 0
target/arm/{ => tcg}/translate-vfp.c.inc | 0
MAINTAINERS | 2 +-
target/arm/kvm/meson.build | 10 +
target/arm/kvm/trace-events | 4 +
target/arm/meson.build | 59 +-
target/arm/tcg/meson.build | 47 +
target/arm/tcg/sysemu/meson.build | 8 +
target/arm/{ => tcg}/trace-events | 3 -
target/arm/tcg/user/meson.build | 6 +
126 files changed, 9952 insertions(+), 8504 deletions(-)
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
create mode 100644 target/arm/kvm/cpu-sve.h
rename target/arm/{ => kvm}/kvm-consts.h (100%)
rename target/arm/{ => kvm}/kvm_arm.h (98%)
create mode 100644 target/arm/kvm/trace.h
create mode 100644 target/arm/tcg/cpu-pauth.h
create mode 100644 target/arm/tcg/cpu-sve.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/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 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/cpu-sve.c
create mode 100644 target/arm/kvm/helper-stubs.c
create mode 100644 target/arm/kvm/kvm-cpu.c
rename target/arm/{ => kvm}/kvm.c (98%)
rename target/arm/{ => kvm}/kvm64.c (99%)
rename target/arm/{helper.c => tcg/cpregs.c} (59%)
create mode 100644 target/arm/tcg/cpu-pauth.c
create mode 100644 target/arm/tcg/cpu-sve.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 (77%)
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
rename target/arm/{ => tcg}/tlb_helper.c (56%)
rename target/arm/{ => tcg}/translate-a64.c (99%)
rename target/arm/{ => tcg}/translate-sve.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%)
rename target/arm/{ => tcg}/translate-neon.c.inc (100%)
rename target/arm/{ => tcg}/translate-vfp.c.inc (100%)
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 (85%)
create mode 100644 target/arm/tcg/user/meson.buildSignature · 1 line
2.26.2
RFC v11 1/55 target/arm: move translate modules to tcg/
---
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-sve.c | 0
target/arm/{ => tcg}/translate.c | 0
target/arm/{ => tcg}/translate-neon.c.inc | 0
target/arm/{ => tcg}/translate-vfp.c.inc | 0
target/arm/meson.build | 20 ++-----------------
target/arm/tcg/meson.build | 24 +++++++++++++++++++++++
20 files changed, 26 insertions(+), 18 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-sve.c (100%)
rename target/arm/{ => tcg}/translate.c (100%)
rename target/arm/{ => tcg}/translate-neon.c.inc (100%)
rename target/arm/{ => tcg}/translate-vfp.c.inc (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-sve.c renamed from target/arm/translate-sve.c +0 -0
target/arm/tcg/translate.c renamed from target/arm/translate.c +0 -0
target/arm/tcg/translate-neon.c.inc renamed from target/arm/translate-neon.c.inc +0 -0
target/arm/tcg/translate-vfp.c.inc renamed from target/arm/translate-vfp.c.inc +0 -0
target/arm/meson.build +2 -18
@@ -1,19 +1,4 @@ -gen = [ - decodetree.process('sve.decode', extra_args: '--decode=disas_sve'), - decodetree.process('neon-shared.decode', extra_args: '--static-decode=disas_neon_shared'), - decodetree.process('neon-dp.decode', extra_args: '--static-decode=disas_neon_dp'), - decodetree.process('neon-ls.decode', extra_args: '--static-decode=disas_neon_ls'), - decodetree.process('vfp.decode', extra_args: '--static-decode=disas_vfp'), - decodetree.process('vfp-uncond.decode', extra_args: '--static-decode=disas_vfp_uncond'), - decodetree.process('m-nocp.decode', extra_args: '--static-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,7 +10,6 @@ arm_ss.add(files( 'neon_helper.c', 'op_helper.c', 'tlb_helper.c', - 'translate.c', 'vec_helper.c', 'vfp_helper.c', 'cpu_tcg.c',
@@ -41,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()
@@ -55,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 +24 -0
@@ -0,0 +1,24 @@ +gen = [ + decodetree.process('sve.decode', extra_args: '--decode=disas_sve'), + decodetree.process('neon-shared.decode', extra_args: '--static-decode=disas_neon_shared'), + decodetree.process('neon-dp.decode', extra_args: '--static-decode=disas_neon_dp'), + decodetree.process('neon-ls.decode', extra_args: '--static-decode=disas_neon_ls'), + decodetree.process('vfp.decode', extra_args: '--static-decode=disas_vfp'), + decodetree.process('vfp-uncond.decode', extra_args: '--static-decode=disas_vfp_uncond'), + decodetree.process('m-nocp.decode', extra_args: '--static-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', +)) + +arm_ss.add(when: 'TARGET_AARCH64', if_true: files( + 'translate-a64.c', + 'translate-sve.c', +))
Signature · 1 line
2.26.2
RFC v11 2/55 target/arm: move helpers to tcg/
In reply to Claudio Fontana---
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
@@ -1845,6 +1845,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
@@ -16,9 +16,23 @@ arm_ss.add(gen) arm_ss.add(files( 'translate.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.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 - # 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.26.2
RFC v11 3/55 arm: tcg: only build under CONFIG_TCG
In reply to Claudio Fontana--- 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', 'helper.c', 'iwmmxt_helper.c',
@@ -28,7 +28,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.26.2
RFC v11 4/55 target/arm: tcg: add sysemu and user subdirs
In reply to Claudio Fontana--- target/arm/tcg/meson.build | 3 +++ target/arm/tcg/sysemu/meson.build | 3 +++ target/arm/tcg/user/meson.build | 3 +++ 3 files changed, 9 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
@@ -36,3 +36,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 +3 -0
@@ -0,0 +1,3 @@ + +arm_softmmu_ss.add(when: ['CONFIG_TCG','CONFIG_SOFTMMU'], if_true: files( +))
target/arm/tcg/user/meson.build new file +3 -0
@@ -0,0 +1,3 @@ + +arm_user_ss.add(when: ['CONFIG_TCG','CONFIG_USER_ONLY'], if_true: files( +))
Signature · 1 line
2.26.2
Re: [RFC v11 04/55] target/arm: tcg: add sysemu and user subdirs
target/arm/tcg/sysemu/meson.build line 3
Quoted 5 lines · Claudio Fontana
+++ b/target/arm/tcg/sysemu/meson.build
target/arm/tcg/sysemu/meson.build new file +3
-0@@ -0,0 +1,3 @@ + +arm_softmmu_ss.add(when: ['CONFIG_TCG','CONFIG_SOFTMMU'], if_true: files( +))
Blank lines at the start of each new file?
Otherwise,
r~
Re: [RFC v11 04/55] target/arm: tcg: add sysemu and user subdirs
In reply to Claudio Fontanatarget/arm/tcg/user/meson.build line 2
Quoted 10 lines · Claudio Fontana
target/arm/tcg/sysemu/meson.build new file +2
-0+arm_softmmu_ss.add(when: ['CONFIG_TCG','CONFIG_SOFTMMU'], if_true: files( +))target/arm/tcg/user/meson.build new file +2
-0@@ -0,0 +1,3 @@ + +arm_user_ss.add(when: ['CONFIG_TCG','CONFIG_USER_ONLY'], if_true: files(
Actually, surely the CONFIG_USER_ONLY and CONFIG_SOFTMMU tests are redundant with the variables, as they are eventually added to target_softmmu_arch and target_user_arch.
r~
Re: [RFC v11 04/55] target/arm: tcg: add sysemu and user subdirs
Quoted 17 lines · Richard Henderson
target/arm/tcg/user/meson.build line 2
Quoted 10 lines · Claudio Fontana
target/arm/tcg/sysemu/meson.build new file +2
-0+arm_softmmu_ss.add(when: ['CONFIG_TCG','CONFIG_SOFTMMU'], if_true: files( +))target/arm/tcg/user/meson.build new file +2
-0@@ -0,0 +1,3 @@ + +arm_user_ss.add(when: ['CONFIG_TCG','CONFIG_USER_ONLY'], if_true: files(Actually, surely the
CONFIG_USER_ONLYandCONFIG_SOFTMMUtests are redundant with the variables, as they are eventually added totarget_softmmu_archandtarget_user_arch.
Quoted 2 lines
r~
Yes, good point, needs fixing.
RFC v11 5/55 target/arm: tcg: split mte_helper user-only and sysemu code
In reply to Claudio Fontanaallocation_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 | 52 ++++++++ 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, 271 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 +52 -0
@@ -0,0 +1,52 @@ +/* +* 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,3 +1,4 @@ arm_softmmu_ss.add(when: ['CONFIG_TCG','CONFIG_SOFTMMU'], if_true: files( + 'mte_helper.c', ))
target/arm/tcg/user/meson.build +1 -0
@@ -1,3 +1,4 @@ arm_user_ss.add(when: ['CONFIG_TCG','CONFIG_USER_ONLY'], if_true: files( + 'mte_helper.c', ))
Signature · 1 line
2.26.2
Re: [RFC v11 05/55] target/arm: tcg: split mte_helper user-only and sysemu code
target/arm/tcg/mte_helper.h line 22
Quoted 3 lines · Claudio Fontana
target/arm/tcg/mte_helper.h new file +3
-0+#ifndef MTE_HELPER_H +#define MTE_HELPER_H +/**
Whitespace after the define.
Otherwise,
r~
RFC v11 6/55 target/arm: tcg: move sysemu-only parts of debug_helper
In reply to Claudio Fontanamove 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,4 +1,5 @@ arm_softmmu_ss.add(when: ['CONFIG_TCG','CONFIG_SOFTMMU'], if_true: files( 'mte_helper.c', + 'debug_helper.c', ))
Signature · 1 line
2.26.2
Re: [RFC v11 06/55] target/arm: tcg: move sysemu-only parts of debug_helper
target/arm/tcg/sysemu/meson.build line 5
Quoted 8 lines · Claudio Fontana
target/arm/tcg/sysemu/meson.build +1
-0@@ -1,4 +1,5 @@ arm_softmmu_ss.add(when: ['CONFIG_TCG','CONFIG_SOFTMMU'], if_true: files( 'mte_helper.c', + 'debug_helper.c', ))
Sort the files as you add them. Otherwise,
r~
RFC v11 7/55 target/arm: tcg: split tlb_helper user-only and sysemu-only parts
In reply to Claudio Fontana--- target/arm/tcg/tlb_helper.h | 17 ++++++ target/arm/tcg/sysemu/tlb_helper.c | 83 ++++++++++++++++++++++++++ target/arm/tcg/tlb_helper.c | 96 ++---------------------------- target/arm/tcg/user/tlb_helper.c | 31 ++++++++++ target/arm/tcg/sysemu/meson.build | 1 + target/arm/tcg/user/meson.build | 1 + 6 files changed, 137 insertions(+), 92 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 -92
111 lines not on this page · raw message
target/arm/tcg/user/tlb_helper.c new file +31 -0
@@ -0,0 +1,31 @@ +/* +* 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; + } + +/* 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
@@ -2,4 +2,5 @@ arm_softmmu_ss.add(when: ['CONFIG_TCG','CONFIG_SOFTMMU'], if_true: files( 'mte_helper.c', 'debug_helper.c', + 'tlb_helper.c', ))
target/arm/tcg/user/meson.build +1 -0
@@ -1,4 +1,5 @@ arm_user_ss.add(when: ['CONFIG_TCG','CONFIG_USER_ONLY'], if_true: files( 'mte_helper.c', + 'tlb_helper.c', ))
Signature · 1 line
2.26.2
Re: [RFC v11 07/55] target/arm: tcg: split tlb_helper user-only and sysemu-only parts
Quoted 9 lines · Claudio Fontana
Signed-off-by 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 | 96 ++---------------------------- target/arm/tcg/user/tlb_helper.c | 31 ++++++++++ target/arm/tcg/sysemu/meson.build | 1 + target/arm/tcg/user/meson.build | 1 + 6 files changed, 137 insertions(+), 92 deletions(-)
Quoted 3 lines
create mode 100644
target/arm/tcg/tlb_helper.hcreate mode 100644target/arm/tcg/sysemu/tlb_helper.ccreate mode 100644target/arm/tcg/user/tlb_helper.c
r~
RFC v11 8/55 target/arm: tcg: split m_helper user-only and sysemu-only parts
In reply to Claudio Fontanain the process remove a few CONFIG_TCG that are superfluous now.
--- target/arm/tcg/m_helper.h | 21 + target/arm/tcg/m_helper.c | 2766 +---------------------------- 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(+), 2761 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 -2761
2,797 lines not on this page · raw message
target/arm/tcg/sysemu/m_helper.c new file +2655 -0
182 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.26.2
Part of the diff is not shown here. View the raw message.
Re: [RFC v11 08/55] target/arm: tcg: split m_helper user-only and sysemu-only parts
Quoted 11 lines · Claudio Fontana
in the process remove a few
CONFIG_TCGthat are superfluous now.Signed-off-by Claudio Fontana<[email protected]>--- target/arm/tcg/m_helper.h | 21 + target/arm/tcg/m_helper.c | 2766 +---------------------------- 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(+), 2761 deletions(-)
Quoted 3 lines
create mode 100644
target/arm/tcg/m_helper.hcreate mode 100644target/arm/tcg/sysemu/m_helper.ccreate mode 100644target/arm/tcg/user/m_helper.c
r~
RFC v11 9/55 target/arm: only build psci for TCG
In reply to Claudio FontanaWe 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.26.2
RFC v11 10/55 target/arm: split off cpu-sysemu.c
In reply to Claudio Fontanamove 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
@@ -1205,4 +1205,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
@@ -19,6 +19,7 @@ arm_softmmu_ss.add(files( 'arm-powerctl.c', 'machine.c', 'monitor.c', + 'cpu-sysemu.c', )) arm_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files(
Signature · 1 line
2.26.2
Re: [RFC v11 10/55] target/arm: split off cpu-sysemu.c
Quoted 5 lines · Claudio Fontana
move work is needed later on to split things into tcg-specific portions and kvm-specific portions of this
Signed-off-by Claudio Fontana<[email protected]>Reviewed-by Alex Bennée<[email protected]>
Quoted 7 lines
--- 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
r~
RFC v11 11/55 target/arm: move physical address translation to cpu-mmu
In reply to Claudio Fontanaget_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 | 118 ++ target/arm/cpu.h | 3 - target/arm/internals.h | 34 - target/arm/cpu-mmu-sysemu.c | 2258 ++++++++++++++++++++++++++ target/arm/cpu-mmu.c | 124 ++ target/arm/cpu.c | 1 + target/arm/tcg/helper.c | 2392 +--------------------------- 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, 2507 insertions(+), 2430 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 +118 -0
@@ -0,0 +1,118 @@ +/* +* 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
@@ -1027,9 +1027,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
@@ -1021,23 +1021,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));
@@ -1085,29 +1068,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 +2258 -0
2,258 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
@@ -42,6 +42,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 -2391
432 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.26.2
Part of the diff is not shown here. View the raw message.
Re: [RFC v11 11/55] target/arm: move physical address translation to cpu-mmu
Quoted 8 lines · Claudio Fontana
get_phys_addris 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.
Signed-off-by Claudio Fontana<[email protected]>---
r~
RFC v11 12/55 target/arm: cpu-mmu: fix comment style
In reply to Claudio Fontana--- target/arm/cpu-mmu.h | 3 +- target/arm/cpu-mmu-sysemu.c | 149 ++++++++++++++++++++++++------------ 2 files changed, 101 insertions(+), 51 deletions(-)
target/arm/cpu-mmu.h +2 -1
@@ -51,7 +51,8 @@ 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 +/* +* Convert a possible stage1+2 MMU index into the appropriate * stage 1 MMU index */ static inline ARMMMUIdx stage_1_mmu_idx (ARMMMUIdx mmu_idx)
target/arm/cpu-mmu-sysemu.c +99 -50
435 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [RFC v11 12/55] target/arm: cpu-mmu: fix comment style
Quoted 5 lines · Claudio Fontana
Signed-off-by Claudio Fontana<[email protected]>--- target/arm/cpu-mmu.h | 3 +- target/arm/cpu-mmu-sysemu.c | 149 ++++++++++++++++++++++++------------ 2 files changed, 101 insertions(+), 51 deletions(-)
Surely this should go before the code movement. I would think that checkpatch will complain about patch 11.
r~
RFC v11 13/55 target/arm: split cpregs from tcg/helper.c
In reply to Claudio Fontanagive 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 | 256 + target/arm/cpu.h | 234 - 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 | 363 ++ 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 | 7592 ++++++++++++++++++++++++++++++ target/arm/tcg/helper.c | 8084 +------------------------------- 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, 8373 insertions(+), 8318 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 +256 -0
@@ -0,0 +1,256 @@ +/* +* 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 + +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 -234
246 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
@@ -32,6 +32,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 +363 -0
363 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 +7592 -0
1,925 lines not on this page · raw message
target/arm/tcg/helper.c +1 -8083
8,084 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.26.2
Part of the diff is not shown here. View the raw message.
Re: [RFC v11 13/55] target/arm: split cpregs from tcg/helper.c
Quoted 11 lines · Claudio Fontana
give them their own common module
cpregs.c, and an interfacecpregs.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.cAs a result, the monster that is
tcg/helper.cis a bit less scary, and a lot of stuff is removed fromcpu.htoo, relegated tocpregs.h.Signed-off-by Claudio Fontana<[email protected]>---
I would expect ARM_CP_* to move out of cpu.h.
I don't see any use of the ARMCPRegInfo typedef remaining in cpu.h. Surely that should move to the new header.
Otherwise, it's really nice to get so many lines out of helper.c.
r~
RFC v11 14/55 target/arm: cpregs: fix style (mostly just comments)
In reply to Claudio Fontana--- target/arm/cpregs.h | 54 ++++++--- target/arm/cpregs.c | 60 ++++++---- target/arm/tcg/cpregs.c | 253 ++++++++++++++++++++++++++-------------- 3 files changed, 241 insertions(+), 126 deletions(-)
target/arm/cpregs.h +36 -18
@@ -12,14 +12,16 @@ 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. */
@@ -30,14 +32,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);
@@ -56,7 +60,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
@@ -87,16 +92,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
@@ -104,7 +112,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
@@ -117,36 +126,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. */
@@ -166,7 +181,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) \
@@ -218,12 +234,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/cpregs.c +37 -23
165 lines not on this page · raw message
target/arm/tcg/cpregs.c +168 -85
747 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [RFC v11 14/55] target/arm: cpregs: fix style (mostly just comments)
Quoted 6 lines · Claudio Fontana
Signed-off-by Claudio Fontana<[email protected]>--- target/arm/cpregs.h | 54 ++++++--- target/arm/cpregs.c | 60 ++++++---- target/arm/tcg/cpregs.c | 253 ++++++++++++++++++++++++++-------------- 3 files changed, 241 insertions(+), 126 deletions(-)
Again, this should have happened before code movement.
r~
RFC v11 15/55 target/arm: move cpu definitions to common cpu module
In reply to Claudio Fontana--- 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
@@ -6,6 +6,7 @@ arm_ss.add(files( 'cpu-mmu.c', 'cpregs.c', 'cpustate-list.c', + 'cpu-common.c', )) arm_ss.add(zlib)
Signature · 1 line
2.26.2
Re: [RFC v11 15/55] target/arm: move cpu definitions to common cpu module
Quoted 7 lines · Claudio Fontana
Signed-off-by 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
r~
RFC v11 16/55 target/arm: only perform TCG cpu and machine inits if TCG enabled
In reply to Claudio Fontanaof 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
@@ -436,9 +436,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,
@@ -1319,6 +1321,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) } } +#ifdef CONFIG_TCG {uint64_t scale;
@@ -1344,7 +1347,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 ) {
@@ -1645,17 +1649,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 );
@@ -1738,10 +1741,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.26.2
Re: [RFC v11 16/55] target/arm: only perform TCG cpu and machine inits if TCG enabled
Quoted 11 lines · Claudio Fontana
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.
Signed-off-by Claudio Fontana<[email protected]>--- target/arm/cpu.c | 32 ++++++++++++++++++-------------- target/arm/kvm.c | 18 +++++++++--------- target/arm/machine.c | 20 +++++++++++++------- 3 files changed, 40 insertions(+), 30 deletions(-)
r~
RFC v11 17/55 target/arm: kvm: add stubs for some helpers
In reply to Claudio Fontanaat least the armv7m one should go away with proper configuration changes (only enabling possible boards for KVM).
--- target/arm/kvm/helper-stubs.c | 27 +++++++++++++++++++++++++++ target/arm/kvm/meson.build | 3 +++ target/arm/meson.build | 1 + 3 files changed, 31 insertions(+) create mode 100644 target/arm/kvm/helper-stubs.c create mode 100644 target/arm/kvm/meson.build
target/arm/kvm/helper-stubs.c new file +27 -0
@@ -0,0 +1,27 @@ +/* +* QEMU ARM KVM stubs for some 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" + +/* return the effective value of HCR_EL2. For KVM, always 0. */ +uint64_t arm_hcr_el2_eff (CPUARMState *env) +{ +return 0 ; +} + +int fp_exception_el (CPUARMState *env,int cur_el) +{ +return 0 ; +} + +void write_v7m_exception (CPUARMState *env,uint32_t new_exc) +{ +g_assert_not_reached (); +}
target/arm/kvm/meson.build new file +3 -0
@@ -0,0 +1,3 @@ +arm_ss.add(when: 'CONFIG_TCG', if_false: files( + 'helper-stubs.c', +))
target/arm/meson.build +1 -0
@@ -34,6 +34,7 @@ arm_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files( arm_user_ss = ss.source_set() subdir('tcg') +subdir('kvm') target_arch += {'arm': arm_ss} target_softmmu_arch += {'arm': arm_softmmu_ss}
Signature · 1 line
2.26.2
Re: [RFC v11 17/55] target/arm: kvm: add stubs for some helpers
target/arm/kvm/helper-stubs.c
Quoted 18 lines · Claudio Fontana
at least the armv7m one should go away with proper configuration changes (only enabling possible boards for KVM).
Signed-off-by Claudio Fontana<[email protected]>--- target/arm/kvm/helper-stubs.c | 27 +++++++++++++++++++++++++++ target/arm/kvm/meson.build | 3 +++ target/arm/meson.build | 1 + 3 files changed, 31 insertions(+)create mode 100644
target/arm/kvm/helper-stubs.ccreate mode 100644 target/arm/kvm/meson.buildtarget/arm/kvm/helper-stubs.c new file +0
-0@@ -0,0 +1,27 @@
Hmm. Is this really kvm-specific, or should it just be tcg/tcg-stubs.c, added with: 'CONFIG_TCG', if_false: ?
r~
Re: [RFC v11 17/55] target/arm: kvm: add stubs for some helpers
In reply to Claudio Fontanatarget/arm/kvm/helper-stubs.c line 17
Quoted 5 lines · Claudio Fontana
target/arm/kvm/helper-stubs.c new file +5
-0+/* return the effective value of HCR_EL2. For KVM, always 0. */ +uint64_t arm_hcr_el2_eff (CPUARMState *env) +{ +return 0 ; +}
Oh, amusingly, patches for kvm nested virtualization,
https://patchew.org/QEMU/[email protected]/
mean that the guest *can* run in EL2, and this always 0 comment isn't true.
So we'll need to keep the original copy of this function in an accelerator agnostic place.
r~
RFC v11 18/55 target/arm: move cpsr_read, cpsr_write to cpu_common
In reply to Claudio Fontanawe 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
@@ -1383,6 +1383,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') subdir('kvm')
Signature · 1 line
2.26.2
Re: [RFC v11 18/55] target/arm: move cpsr_read, cpsr_write to cpu_common
Quoted 12 lines · Claudio Fontana
we need as a result to move
switch_modetoo,
so we put an implementation intocpu_userandcpu_sysemu.Signed-off-by Claudio Fontana<[email protected]>--- 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(-)
Quoted 1 line
create mode 100644
target/arm/cpu-user.c
r~
RFC v11 19/55 target/arm: add temporary stub for arm_rebuild_hflags
In reply to Claudio Fontanathis should go away once the configuration and hw/arm is clean
--- hw/arm/boot.c | 5 ++++- target/arm/arm-powerctl.c | 8 +++++--- target/arm/kvm/helper-stubs.c | 6 ++++++ 3 files changed, 15 insertions(+), 4 deletions(-)
hw/arm/boot.c +4 -1
@@ -27,6 +27,7 @@#include "qemu/option.h" #include "exec/address-spaces.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
@@ -797,7 +798,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/kvm/helper-stubs.c +6 -0
@@ -25,3 +25,9 @@ void write_v7m_exception(CPUARMState *env, uint32_t new_exc) {g_assert_not_reached (); } + +/* XXX this is used all over in hw/arm, needs Philippe's work to remove */ +void arm_rebuild_hflags (CPUARMState *env) +{ +g_assert_not_reached (); +}
Signature · 1 line
2.26.2
Re: [RFC v11 19/55] target/arm: add temporary stub for arm_rebuild_hflags
Quoted 8 lines · Claudio Fontana
this should go away once the configuration and hw/arm is clean
Signed-off-by Claudio Fontana<[email protected]>--- hw/arm/boot.c | 5 ++++- target/arm/arm-powerctl.c | 8 +++++--- target/arm/kvm/helper-stubs.c | 6 ++++++ 3 files changed, 15 insertions(+), 4 deletions(-)
r~
RFC v11 20/55 target/arm: split vfp state setting from tcg helpers
In reply to Claudio Fontanacpu-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
kvm/helper-stubs.c: vfp_get_fpscr_from_host and vv stubs for KVM.
--- target/arm/cpu-vfp.h | 29 +++++ target/arm/cpu-vfp.c | 92 +++++++++++++++ target/arm/kvm/helper-stubs.c | 10 ++ 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 + 7 files changed, 281 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 +92 -0
92 lines not on this page · raw message
target/arm/kvm/helper-stubs.c +10 -0
@@ -9,6 +9,7 @@#include "qemu/osdep.h" #include "cpu.h" +#include "cpu-vfp.h" /* return the effective value of HCR_EL2. For KVM, always 0. */ uint64_t arm_hcr_el2_eff (CPUARMState *env)
@@ -31,3 +32,12 @@ void arm_rebuild_hflags(CPUARMState *env) {g_assert_not_reached (); } + +uint32_t vfp_get_fpscr_from_host (CPUARMState *env) +{ +return 0 ; +} + +void vfp_set_fpscr_to_host (CPUARMState *env,uint32_t val) +{ +}
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
@@ -7,6 +7,7 @@ arm_ss.add(files( 'cpregs.c', 'cpustate-list.c', 'cpu-common.c', + 'cpu-vfp.c', )) arm_ss.add(zlib)
target/arm/tcg/meson.build +1 -0
@@ -18,6 +18,7 @@ arm_ss.add(when: 'CONFIG_TCG', if_true: files( 'translate.c', 'helper.c', 'cpregs.c', + 'cpu-vfp.c', 'iwmmxt_helper.c', 'm_helper.c', 'neon_helper.c',
Signature · 1 line
2.26.2
Re: [RFC v11 20/55] target/arm: split vfp state setting from tcg helpers
Quoted 18 lines · Claudio Fontana
cpu-vfp.c:vfp_get_fpsrandvfp_set_fpsrare needed also for KVM,
so create a newcpu-vfp.c
tcg/cpu-vfp.c:vfp_get_fpscr_from_hostand vv are TCG-only, so we
move the implementation totcg/cpu-vfp.c
kvm/helper-stubs.c:vfp_get_fpscr_from_hostand vv stubs for KVM.Signed-off-by Claudio Fontana<[email protected]>--- target/arm/cpu-vfp.h | 29 +++++ target/arm/cpu-vfp.c | 92 +++++++++++++++ target/arm/kvm/helper-stubs.c | 10 ++ 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 + 7 files changed, 281 insertions(+), 208 deletions(-)
Quoted 3 lines
create mode 100644
target/arm/cpu-vfp.h
create mode 100644target/arm/cpu-vfp.c
create mode 100644target/arm/tcg/cpu-vfp.c
r~
RFC v11 21/55 target/arm: move arm_mmu_idx* to cpu-mmu
In reply to Claudio Fontana--- 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.26.2
Re: [RFC v11 21/55] target/arm: move arm_mmu_idx* to cpu-mmu
Quoted 5 lines · Claudio Fontana
Signed-off-by Claudio Fontana<[email protected]>--- target/arm/cpu-mmu.c | 95 +++++++++++++++++++++++++++++++++++++++++ target/arm/tcg/helper.c | 95 ----------------------------------------- 2 files changed, 95 insertions(+), 95 deletions(-)
r~
RFC v11 22/55 target/arm: move sve_zcr_len_for_el to common_cpu
In reply to Claudio Fontanait 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
@@ -231,3 +231,46 @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, mask &= ~CACHED_CPSR_BITS ; env->uncached_cpsr = (env->uncached_cpsr & ~mask) | (val & mask); } + +/* +* 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
@@ -390,39 +390,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.26.2
Re: [RFC v11 22/55] target/arm: move sve_zcr_len_for_el to common_cpu
Quoted 4 lines · Claudio Fontana
it is required by
arch-dump.candcpu.c, so apparently we need this for KVM tooSigned-off-by Claudio Fontana <[email protected]>
Quoted 9 lines
target/arm/cpu-common.c +9
-0+/* +* 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)
target/arm/cpu-common.c void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, · line 253
Quoted 10 lines
target/arm/cpu-common.c +10
-0+{ +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; +}
I guess you could
#ifdef TARGET_AARCH64
...
#else
g_assert_not_reached();#endif
Dunno if it's worth it or not, since they're small.
r~
Re: [RFC v11 22/55] target/arm: move sve_zcr_len_for_el to common_cpu
Quoted 36 lines · Richard Henderson
Quoted 4 lines · Claudio Fontana
it is required by
arch-dump.candcpu.c, so apparently we need this for KVM tooSigned-off-by Claudio Fontana <[email protected]>Reviewed-by Richard Henderson <[email protected]>Quoted 9 lines
target/arm/cpu-common.c +9
-0+/* +* 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)target/arm/cpu-common.c void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, · line 253
Quoted 10 lines
target/arm/cpu-common.c +10
-0+{ +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; +}I guess you could
#ifdef TARGET_AARCH64 ... #else g_assert_not_reached();
Quoted 7 lines
#endif
Dunno if it's worth it or not, since they're small.
r~
I'll check this again. IIRC I _did_ handle the HELPER() / hflags / cpreg problem in the end, so it should be possible to make this actually right (ie #ifdef TARGET_AARCH64)
RFC v11 23/55 target/arm: move arm_sctlr away from tcg helpers
In reply to Claudio Fontanathis 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
@@ -274,3 +274,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
@@ -1743,17 +1743,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.26.2
Re: [RFC v11 23/55] target/arm: move arm_sctlr away from tcg helpers
Quoted 4 lines · Claudio Fontana
this function is used for kvm too, add it to the
cpu-common module.Signed-off-by Claudio Fontana <[email protected]>
target/arm/cpu-common.c uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) · line 284
Quoted 9 lines
/* #endif
TARGET_AARCH64, see matching comment above */target/arm/cpu-common.c +8
-0+ +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 ;
I only thought of it because of the comment, but *E20_0 is aarch64 only; aarch32 always uses el = 1 here. ;-)
r~
Re: [RFC v11 23/55] target/arm: move arm_sctlr away from tcg helpers
Quoted 22 lines · Richard Henderson
Quoted 4 lines · Claudio Fontana
this function is used for kvm too, add it to the
cpu-common module.Signed-off-by Claudio Fontana <[email protected]>Reviewed-by Richard Henderson <[email protected]>target/arm/cpu-common.c uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) · line 284
Quoted 9 lines
/* #endif
TARGET_AARCH64, see matching comment above */target/arm/cpu-common.c +8
-0+ +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 ;I only thought of it because of the comment, but
*E20_0is aarch64 only; aarch32 always uses el = 1 here. ;-)
Quoted 1 line
r~
In this case, maybe we should do:
uint64_t arm_sctlr(CPUARMState *env, int el)
{
/* Only EL0 needs to be adjusted for EL1&0 or EL2&0. */
if (el == 0) {
#ifdef TARGET_AARCH64
ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, 0);
el = (mmu_idx == ARMMMUIdx_E20_0 || mmu_idx == ARMMMUIdx_SE20_0)
? 2 : 1;
#else
el = 1;
#endif
}
return env->cp15.sctlr_el[el];
}?
Thanks,
Claudio
RFC v11 24/55 target/arm: move arm_cpu_list to common_cpu
In reply to Claudio Fontana--- 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"
@@ -285,3 +286,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.26.2
RFC v11 25/55 target/arm: move aarch64_sync_32_to_64 (and vv) to cpu code
In reply to Claudio Fontanaand 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 | 217 +++++++++++++++++++++++++++++++++++++ target/arm/cpu-user.c | 11 ++ target/arm/tcg/helper.c | 232 +--------------------------------------- 3 files changed, 231 insertions(+), 229 deletions(-)
target/arm/cpu-sysemu.c +217 -0
@@ -133,3 +133,220 @@ 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.26.2
Re: [RFC v11 25/55] target/arm: move aarch64_sync_32_to_64 (and vv) to cpu code
target/arm/cpu-sysemu.c void switch_mode(CPUARMState *env, int mode) · line 138
Quoted 3 lines · Claudio Fontana
target/arm/cpu-sysemu.c +3
-0+ + +
Watch the excessive whitespace. Otherwise,
r~
RFC v11 26/55 target/arm: split a15 cpu model and 32bit class functions to cpu32.c
In reply to Claudio Fontanaprovide helper functions there to initialize 32bit models, and export the a15 cpu model.
We still need to keep around a15 until we sort out the board configurations.
cpu.c will continue to contain the common parts between 32 and 64.
Note that we need to build cpu32 also for TARGET_AARCH64, because qemu-system-aarch64 is supposed to be able to run non-aarch64 cpus too.
--- target/arm/cpu-qom.h | 3 - target/arm/cpu.h | 4 +- target/arm/cpu32.h | 29 +++++ target/arm/cpu.c | 277 +---------------------------------------- target/arm/cpu32.c | 274 ++++++++++++++++++++++++++++++++++++++++ target/arm/cpu64.c | 131 ++++++++++++++++++- target/arm/cpu_tcg.c | 70 +---------- target/arm/gdbstub.c | 4 +- target/arm/meson.build | 5 + 9 files changed, 448 insertions(+), 349 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/cpu.h +2 -2
@@ -1026,8 +1026,8 @@ 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); +int arm32_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg); +int arm32_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);/* * Helpers to dynamically generates XML descriptions of the sysregs
target/arm/cpu32.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* 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 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/cpu.c +4 -273
320 lines not on this page · raw message
target/arm/cpu32.c new file +274 -0
274 lines not on this page · raw message
target/arm/cpu64.c +130 -1
155 lines not on this page · raw message
target/arm/cpu_tcg.c +2 -68
100 lines not on this page · raw message
target/arm/gdbstub.c +2 -2
@@ -34,7 +34,7 @@ typedef struct RegisterSysregXmlParam {We hack round this by giving the FPA regs zero size when talking to a newer gdb. */ -int arm_cpu_gdb_read_register (CPUState *cs,GByteArray *mem_buf,int n) +int arm32_cpu_gdb_read_register (CPUState *cs,GByteArray *mem_buf,int n) {ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;
@@ -69,7 +69,7 @@ int arm_cpu_gdb_read_register(CPUState *cs, GByteArray *mem_buf, int n)return 0 ; } -int arm_cpu_gdb_write_register (CPUState *cs,uint8_t *mem_buf,int n) +int arm32_cpu_gdb_write_register (CPUState *cs,uint8_t *mem_buf,int n) {ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;
target/arm/meson.build +5 -0
@@ -1,6 +1,7 @@ arm_ss = ss.source_set() arm_ss.add(files( 'cpu.c', + 'cpu32.c', 'gdbstub.c', 'cpu_tcg.c', 'cpu-mmu.c',
@@ -18,6 +19,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.26.2
Re: [RFC v11 26/55] target/arm: split a15 cpu model and 32bit class functions to cpu32.c
target/arm/cpu.c static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) · line 866
Quoted 10 lines · Claudio Fontana
target/arm/cpu.c +0
-10-static void arm_cpu_dump_state (CPUState *cs,FILE *f,int flags) -{ -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; -int i; - -if (is_a64 (env)) { -aarch64_cpu_dump_state (cs, f, flags); -return ; - }
You've lost this bit.
Somewhere there needs to be a check of the current cpu state, and one of the two functions must be called.
target/arm/cpu64.c static void aarch64_cpu_class_init(ObjectClass *oc, void *data) · line 954
Quoted 5 lines
target/arm/cpu64.c +1
-0@@ -823,6 +951,7 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs =34 ; cc->gdb_core_xml_file ="aarch64-core.xml" ; cc->gdb_arch_name = aarch64_gdb_arch_name; + cc->dump_state = aarch64_cpu_dump_state;
I suggest this continue to set arm_cpu_dump_state, like so,
static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags)
{
if (is_a64(env)) {
aarch64_cpu_dump_state(cs, f, flags);
} else {
aarch32_cpu_dump_state(cs, f, flags);
}
}r~
Re: [RFC v11 26/55] target/arm: split a15 cpu model and 32bit class functions to cpu32.c
Quoted 14 lines · Richard Henderson
target/arm/cpu.c static void arm_disas_set_info(CPUState *cpu, disassemble_info *info) · line 866
Quoted 10 lines · Claudio Fontana
target/arm/cpu.c +0
-10-static void arm_cpu_dump_state (CPUState *cs,FILE *f,int flags) -{ -ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env; -int i; - -if (is_a64 (env)) { -aarch64_cpu_dump_state (cs, f, flags); -return ; - }You've lost this bit.
Quoted 2 lines
Somewhere there needs to be a check of the current cpu state, and one of the two functions must be called.
Thanks for the nice catch, I got confused there.
Quoted 22 lines
target/arm/cpu64.c static void aarch64_cpu_class_init(ObjectClass *oc, void *data) · line 954
Quoted 7 lines
target/arm/cpu64.c +1
-0@@ -823,6 +951,7 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_num_core_regs =34 ; cc->gdb_core_xml_file ="aarch64-core.xml" ; cc->gdb_arch_name = aarch64_gdb_arch_name; + cc->dump_state = aarch64_cpu_dump_state;I suggest this continue to set
arm_cpu_dump_state, like so,static void
arm_cpu_dump_state(CPUState *cs, FILE *f, int flags){ if (is_a64(env)) { aarch64_cpu_dump_state(cs, f, flags); } else { aarch32_cpu_dump_state(cs, f, flags); } }r~
RFC v11 27/55 target/arm: move sve_exception_el out of TCG helpers
In reply to Claudio Fontanawe need this for KVM too.
--- target/arm/cpu-sysemu.c | 60 ++++++++++++++++++++++++++++++++++++++++ target/arm/cpu-user.c | 5 ++++ target/arm/tcg/helper.c | 61 ----------------------------------------- 3 files changed, 65 insertions(+), 61 deletions(-)
target/arm/cpu-sysemu.c +60 -0
@@ -350,3 +350,63 @@ 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 -61
67 lines not on this page · raw message
Signature · 1 line
2.26.2
Re: [RFC v11 27/55] target/arm: move sve_exception_el out of TCG helpers
Quoted 8 lines · Claudio Fontana
we need this for KVM too.
Signed-off-by Claudio Fontana<[email protected]>--- target/arm/cpu-sysemu.c | 60 ++++++++++++++++++++++++++++++++++++++++ target/arm/cpu-user.c | 5 ++++ target/arm/tcg/helper.c | 61 ----------------------------------------- 3 files changed, 65 insertions(+), 61 deletions(-)
r~
RFC v11 28/55 target/arm: refactor exception and cpu code
In reply to Claudio Fontanamove exception code out of tcg/
as we need part of it for KVM too.
put the exception code into separate cpu modules as appropriate, including:
cpu-sysemu.ctcg/tcg-cpu.ctcg/sysemu/tcg-cpu.c
to avoid naming confusion with the existing cpu_tcg.c, containg cpu models definitions for 32bit TCG-only cpus, rename this file as tcg/tcg-cpu-models.c
The 64bit cpu models (a53/a57/a72/max) for both TCG and KVM remain in cpu64.c .
---
target/arm/cpu.h | 1 -
target/arm/internals.h | 5 -
target/arm/tcg/tcg-cpu.h | 37 +
target/arm/cpu-sysemu.c | 669 ++++++++++++++++
target/arm/cpu.c | 209 +----
target/arm/tcg/helper.c | 724 +-----------------
target/arm/tcg/sysemu/tcg-cpu.c | 73 ++
.../arm/{cpu_tcg.c => tcg/tcg-cpu-models.c} | 12 +-
target/arm/tcg/tcg-cpu.c | 229 ++++++
target/arm/meson.build | 5 -
target/arm/tcg/meson.build | 4 +-
target/arm/tcg/sysemu/meson.build | 1 +
12 files changed, 1018 insertions(+), 951 deletions(-)
create mode 100644 target/arm/tcg/tcg-cpu.h
create mode 100644 target/arm/tcg/sysemu/tcg-cpu.c
rename target/arm/{cpu_tcg.c => tcg/tcg-cpu-models.c} (99%)
create mode 100644 target/arm/tcg/tcg-cpu.ctarget/arm/cpu.h +0 -1
@@ -1024,7 +1024,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 arm32_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int arm32_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg);
target/arm/internals.h +0 -5
@@ -172,11 +172,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 new file +37 -0
@@ -0,0 +1,37 @@ +/* +* 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" +#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. */ +void tcg_handle_semihosting (CPUState *cs); + +#endif /* !CONFIG_USER_ONLY */ + +#endif /* ARM_TCG_CPU_H */
target/arm/cpu-sysemu.c +669 -0
682 lines not on this page · raw message
target/arm/cpu.c +2 -207
239 lines not on this page · raw message
target/arm/tcg/helper.c +1 -723
745 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/tcg-cpu-models.c renamed from target/arm/cpu_tcg.c +3 -9
@@ -1,5 +1,5 @@/* -* QEMU ARM TCG CPUs. +* QEMU ARM TCG-only CPUs. * * Copyright (c) 2012 SUSE LINUX Products GmbH *
@@ -9,10 +9,8 @@*/ #include "qemu/osdep.h" -#include "cpu.h" -#ifdef CONFIG_TCG -#include "hw/core/tcg-cpu-ops.h" -#endif /* CONFIG_TCG */ +#include "tcg-cpu.h" +#include "internals.h" #include "target/arm/idau.h" #if !defined(CONFIG_USER_ONLY )
@@ -24,7 +22,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 +45,6 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) }return ret; } -#endif /* CONFIG_TCG */ static void arm926_initfn (Object *obj) {
@@ -833,7 +829,6 @@ static void pxa270c5_initfn(Object *obj) cpu->reset_sctlr =0x00000078 ; } -#ifdef CONFIG_TCG static struct TCGCPUOps arm_v7m_tcg_ops = { .initialize = arm_translate_init, .synchronize_from_tb = arm_cpu_synchronize_from_tb,
@@ -849,7 +844,6 @@ static struct TCGCPUOps arm_v7m_tcg_ops = { .debug_check_watchpoint = arm_debug_check_watchpoint,#endif /* !CONFIG_USER_ONLY */ }; -#endif /* CONFIG_TCG */ static void arm_v7m_class_init (ObjectClass *oc,void *data) {
target/arm/tcg/tcg-cpu.c new file +229 -0
229 lines not on this page · raw message
target/arm/meson.build +0 -5
@@ -3,7 +3,6 @@ arm_ss.add(files( 'cpu.c', 'cpu32.c', 'gdbstub.c', - 'cpu_tcg.c', 'cpu-mmu.c', 'cpregs.c', 'cpustate-list.c',
@@ -19,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 +3 -1
@@ -28,9 +28,11 @@ arm_ss.add(when: 'CONFIG_TCG', if_true: files( 'vfp_helper.c', 'crypto_helper.c', 'debug_helper.c', + 'tcg-cpu.c', + 'tcg-cpu-models.c', )) -arm_ss.add(when: ['TARGET_AARCH64','CONFIG_TCG'], if_true: files( +arm_ss.add(when: ['TARGET_AARCH64', 'CONFIG_TCG'], if_true: files( 'translate-a64.c', 'translate-sve.c', 'helper-a64.c',
target/arm/tcg/sysemu/meson.build +1 -0
@@ -4,4 +4,5 @@ arm_softmmu_ss.add(when: ['CONFIG_TCG','CONFIG_SOFTMMU'], if_true: files( 'debug_helper.c', 'tlb_helper.c', 'm_helper.c', + 'tcg-cpu.c', ))
Signature · 1 line
2.26.2
Re: [RFC v11 28/55] target/arm: refactor exception and cpu code
Quoted 6 lines · Claudio Fontana
move exception code out of tcg/
as we need part of it for KVM too.put the exception code into separate cpu modules as appropriate, including:
Quoted 7 lines
cpu-sysemu.ctcg/tcg-cpu.ctcg/sysemu/tcg-cpu.cto avoid naming confusion with the existing
cpu_tcg.c, containg cpu models definitions for 32bit TCG-only cpus, rename this file astcg/tcg-cpu-models.c
Obviously all of this should not be done in one step.
Isn't tcg/tcg-* redundant?
r~
Re: [RFC v11 28/55] target/arm: refactor exception and cpu code
Quoted 11 lines · Richard Henderson
Quoted 10 lines · Claudio Fontana
move exception code out of tcg/
as we need part of it for KVM too.put the exception code into separate cpu modules as appropriate, including:
cpu-sysemu.ctcg/tcg-cpu.ctcg/sysemu/tcg-cpu.c
Quoted 5 lines
Quoted 3 lines
to avoid naming confusion with the existing
cpu_tcg.c, containg cpu models definitions for 32bit TCG-only cpus, rename this file astcg/tcg-cpu-models.cObviously all of this should not be done in one step.
Ok will work on it.
Quoted 2 lines
Isn't tcg/tcg-* redundant?
I considered that, and at some point I had "cpu.c" for x86 too. After working on it for a while, I noticed how
it got really confusing in practice to have files called just "cpu.c" when working on them, just too many files are called "cpu.c". It was confusing.
I also like the extra emphasis on the accel for this:
kvm/kvm.ckvm/kvm-cpu.ckvm/kvm-stub.c
tcg/tcg-cpu.ctcg/tcg-stub.c
Thanks,
Claudio
Re: [RFC v11 28/55] target/arm: refactor exception and cpu code
Quoted 5 lines · Claudio Fontana
Quoted 1 line
Isn't tcg/tcg-* redundant?
I considered that, and at some point I had "
cpu.c" for x86 too. After working on it for a while, I noticed how
it got really confusing in practice to have files called just "cpu.c" when working on them, just too many files are called "cpu.c". It was confusing.
Quoted 8 lines
I also like the extra emphasis on the accel for this:
kvm/kvm.ckvm/kvm-cpu.ckvm/kvm-stub.c
tcg/tcg-cpu.ctcg/tcg-stub.c
But then you go and invent
cpu-sve.ckvm/cpu-sve.ctcg/cpu-sve.c
etc. So, please make up your mind.
r~
Re: [RFC v11 28/55] target/arm: refactor exception and cpu code
Quoted 15 lines · Richard Henderson
Quoted 5 lines · Claudio Fontana
Quoted 1 line
Isn't tcg/tcg-* redundant?
I considered that, and at some point I had "
cpu.c" for x86 too. After working on it for a while, I noticed how
it got really confusing in practice to have files called just "cpu.c" when working on them, just too many files are called "cpu.c". It was confusing.Quoted 8 lines
I also like the extra emphasis on the accel for this:
kvm/kvm.ckvm/kvm-cpu.ckvm/kvm-stub.c
tcg/tcg-cpu.ctcg/tcg-stub.c
Quoted 8 lines
But then you go and invent
cpu-sve.ckvm/cpu-sve.ctcg/cpu-sve.cetc. So, please make up your mind.
Inconsistencies are all over already, and the two are very unrelated things.
tcg-cpu comes from accel-cpu, where accel- is replaced by tcg- in this case.
cpu-sve is a specialization of "cpu" where we currently put all the properties and the like.
cpu-sve-props is probably a better name.
RFC v11 29/55 target/arm: cpu: fix style
In reply to Claudio Fontana--- target/arm/cpu-sysemu.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
target/arm/cpu-sysemu.c +11 -6
@@ -372,7 +372,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
@@ -398,7 +399,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)) {
@@ -625,10 +627,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 ;
@@ -714,7 +717,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.
@@ -1013,7 +1017,8 @@ void arm_log_exception(int idx) } } -/* 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.
Signature · 1 line
2.26.2
Re: [RFC v11 29/55] target/arm: cpu: fix style
Quoted 5 lines · Claudio Fontana
Signed-off-by Claudio Fontana<[email protected]>Reviewed-by Philippe Mathieu-Daudé<[email protected]>--- target/arm/cpu-sysemu.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
Obviously, this should be done before the code moves.
r~
RFC v11 30/55 target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()
In reply to Claudio FontanaAfter 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
@@ -820,11 +820,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) {/* Entry vector offset depends on whether the implemented EL
Signature · 1 line
2.26.2
Re: [RFC v11 30/55] target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()
Quoted 3 lines · Claudio Fontana
After this patch it is possible to build only kvm:
./configure --disable-tcg --enable-kvm
FWIW at this point we get a different failure than later on:
21:10:25 [alex@aarch64-new:~/l/q/b/disable.tcg] (94e2abe0…)|… + make check-qtest
GIT ui/keycodemapdb tests/fp/berkeley-testfloat-3 tests/fp/berkeley-softfloat-3 meson dtc capstone slirp
[1/19] Generating qemu-version.h with a meson_exe.py custom command
Running test qtest-aarch64/qom-test
qemu-system-aarch64: missing interface 'idau-interface' for object 'machine'
socket_accept failed: Resource temporarily unavailable
**
ERROR:../../tests/qtest/libqtest.c:319:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
ERROR qtest-aarch64/qom-test - Bail out! ERROR:../../tests/qtest/libqtest.c:319:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0)
make: *** [Makefile.mtest:24: run-test-1] Error 1
Quoted 29 lines
Signed-off-by Claudio Fontana <[email protected]>--- target/arm/cpu-sysemu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)target/arm/cpu-sysemu.c +7
-5@@ -820,11 +820,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) {/* Entry vector offset depends on whether the implemented EL
Signature · 1 line
Alex Bennée
Re: [RFC v11 30/55] target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()
Quoted 6 lines · Alex Bennée
Quoted 3 lines · Claudio Fontana
After this patch it is possible to build only kvm:
./configure --disable-tcg --enable-kvm
It's possible to build, but tests will fail until all the test-related patches are applied.
Quoted 8 lines
FWIW at this point we get a different failure than later on:
21:10:25 [alex@aarch64-new:~/l/q/b/disable.tcg] (94e2abe0…)|… + make check-qtest
GIT ui/keycodemapdb tests/fp/berkeley-testfloat-3 tests/fp/berkeley-softfloat-3 meson dtc capstone slirp
[1/19] Generatingqemu-version.hwith ameson_exe.pycustom command Running test qtest-aarch64/qom-test
qemu-system-aarch64: missing interface 'idau-interface' for object 'machine'
This one is broken by a recent commit in QEMU mainline, by removing the idau interface from KVM cpus.
This is fixed by: Revert "target/arm: Restrict v8M IDAU to TCG" in the series.
Quoted 38 lines
socket_accept failed: Resource temporarily unavailable ** ERROR:../../tests/qtest/libqtest.c:319:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0) ERROR qtest-aarch64/qom-test - Bail out! ERROR:../../tests/qtest/libqtest.c:319:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0) make: *** [Makefile.mtest:24: run-test-1] Error 1Quoted 29 lines
Signed-off-by Claudio Fontana <[email protected]>--- target/arm/cpu-sysemu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)target/arm/cpu-sysemu.c +7
-5@@ -820,11 +820,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) {/* Entry vector offset depends on whether the implemented EL
Re: [RFC v11 30/55] target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()
Quoted 11 lines · Claudio Fontana
Quoted 6 lines · Alex Bennée
Quoted 3 lines · Claudio Fontana
After this patch it is possible to build only kvm:
./configure --disable-tcg --enable-kvm
It's possible to build, but tests will fail until all the test-related patches are applied.
So I think there has to be a change in ordering in the series so we don't have differing failure modes as we enable. I'm not sure if that means all tests need to be fixed before the first "--disable-tcg builds" patch but I would expect at least a basic:
qemu-system-aarch64 -M virt,gic=host -cpu host -accel kvm -m 2048 -net none -nographic -kernel ~/lsrc/linux.git/builds/arm64.virt/arch/arm64/boot/Image -append "panic=-1"
--no-reboot
works - so at least we can track if any of the additional changes cause regressions.
Quoted 9 lines
Quoted 8 lines
FWIW at this point we get a different failure than later on:
21:10:25 [alex@aarch64-new:~/l/q/b/disable.tcg] (94e2abe0…)|… + make check-qtest
GIT ui/keycodemapdb tests/fp/berkeley-testfloat-3 tests/fp/berkeley-softfloat-3 meson dtc capstone slirp
[1/19] Generatingqemu-version.hwith ameson_exe.pycustom command Running test qtest-aarch64/qom-test
qemu-system-aarch64: missing interface 'idau-interface' for object 'machine'
Quoted 4 lines
This one is broken by a recent commit in QEMU mainline, by removing the idau interface from KVM cpus.
This is fixed by: Revert "target/arm: Restrict v8M IDAU to TCG" in the series.
The proper fix is probably to move the mps2tz machine type that brings this in to TCG only.
Moving up the build chain to the revert I now get:
./qemu-system-aarch64 -M virt,gic=host -cpu host -accel kvm -m 2048 -net none -nographic -kernel ~/lsrc/linux.git/builds/arm64.virt/arch/arm64/boot/Image -append "panic=-1" --no-reboot
qemu-system-aarch64: Property 'virt-6.0-machine.gic' not found
Quoted 39 lines
Quoted 39 lines
socket_accept failed: Resource temporarily unavailable ** ERROR:../../tests/qtest/libqtest.c:319:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0) ERROR qtest-aarch64/qom-test - Bail out! ERROR:../../tests/qtest/libqtest.c:319:qtest_init_without_qmp_handshake: assertion failed: (s->fd >= 0 && s->qmp_fd >= 0) make: *** [Makefile.mtest:24: run-test-1] Error 1Quoted 29 lines
Signed-off-by Claudio Fontana <[email protected]>--- target/arm/cpu-sysemu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)target/arm/cpu-sysemu.c +7
-5@@ -820,11 +820,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) {/* Entry vector offset depends on whether the implemented EL
Signature · 1 line
Alex Bennée
Re: [RFC v11 30/55] target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()
Quoted 3 lines · Alex Bennée
Quoted 1 line · Claudio Fontana
On 3/23/21 11:50 PM, Alex Bennée wrote:
<snip>
Quoted 8 lines
Moving up the build chain to the revert I now get:
./qemu-system-aarch64 -M virt,gic=host -cpu host -accel kvm -m 2048
-net none -nographic -kernel ~/lsrc/linux.git/builds/arm64.virt/arch/arm64/boot/Image -append "panic=-1"
--no-reboot
qemu-system-aarch64: Property 'virt-6.0-machine.gic' not found
PEBKAC:
The proper command line is "-M virt,gic-version=host"
Signature · 1 line
Alex Bennée
Re: [RFC v11 30/55] target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()
Quoted 7 lines · Alex Bennée
Quoted 3 lines · Alex Bennée
Quoted 1 line · Claudio Fontana
On 3/23/21 11:50 PM, Alex Bennée wrote:
<snip>
Quoted 8 lines
Quoted 8 lines
Moving up the build chain to the revert I now get:
./qemu-system-aarch64 -M virt,gic=host -cpu host -accel kvm -m 2048
-net none -nographic -kernel ~/lsrc/linux.git/builds/arm64.virt/arch/arm64/boot/Image -append "panic=-1"
--no-reboot
qemu-system-aarch64: Property 'virt-6.0-machine.gic' not found
I think I am seeing this on master too, can you check?
./qemu-system-aarch64 -M virt,gic=host -cpu host -accel kvm -m 2048 -net none -nographic -drive if=pflash,format=raw,file=/home/cfontana/QEMU_EFI.img -drive if=pflash,file=/home/cfontana/varstore.img -drive if=virtio,file=/home/cfontana/debian.img -drive if=virtio,format=raw,file=/home/cfontana/debian-10.8.0-arm64-netinst.iso
qemu-system-aarch64: Property 'virt-6.0-machine.gic' not found
Quoted 5 lines
PEBKAC:
The proper command line is "-M virt,gic-version=host"
Re: [RFC v11 30/55] target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()
Quoted 20 lines · Claudio Fontana
Quoted 7 lines · Alex Bennée
Quoted 3 lines · Alex Bennée
Quoted 1 line · Claudio Fontana
On 3/23/21 11:50 PM, Alex Bennée wrote:
<snip>
Quoted 8 lines
Quoted 8 lines
Moving up the build chain to the revert I now get:
./qemu-system-aarch64 -M virt,gic=host -cpu host -accel kvm -m 2048
-net none -nographic -kernel ~/lsrc/linux.git/builds/arm64.virt/arch/arm64/boot/Image -append "panic=-1"
--no-reboot
qemu-system-aarch64: Property 'virt-6.0-machine.gic' not foundI think I am seeing this on master too, can you check?
Quoted 15 lines
./qemu-system-aarch64 -M virt,gic=host -cpu host -accel kvm -m 2048
-net none -nographic -drive if=pflash,format=raw,file=/home/cfontana/QEMU_EFI.img -drive if=pflash,file=/home/cfontana/varstore.img -drive if=virtio,file=/home/cfontana/debian.img -drive if=virtio,format=raw,file=/home/cfontana/debian-10.8.0-arm64-netinst.isoqemu-system-aarch64: Property 'virt-6.0-machine.gic' not found
Quoted 5 lines
PEBKAC:
The proper command line is "-M virt,gic-version=host"
Sorry apologies for the acronym: Problem Exists Between Keyboard and Chair - i.e. I messed up the command line ;-)
Signature · 1 line
Alex Bennée
Re: [RFC v11 30/55] target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()
In reply to Claudio FontanaQuoted 8 lines · Claudio Fontana
After this patch it is possible to build only kvm:
./configure --disable-tcg --enable-kvm
Signed-off-by Claudio Fontana<[email protected]>--- target/arm/cpu-sysemu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
r~
RFC v11 31/55 target/arm: remove kvm include file for PSCI and arm-powerctl
In reply to Claudio FontanaThe 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.26.2
Re: [RFC v11 31/55] target/arm: remove kvm include file for PSCI and arm-powerctl
Quoted 8 lines · Claudio Fontana
The QEMU PSCI implementation is not used for KVM,
we do not need the kvm constants header.Signed-off-by Claudio Fontana<[email protected]>--- target/arm/arm-powerctl.h | 2 -- target/arm/psci.c | 1 - 2 files changed, 3 deletions(-)
r~
RFC v11 32/55 target/arm: move kvm-const.h, kvm.c, kvm64.c, kvm_arm.h to kvm/
In reply to Claudio Fontanaand 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-stub.c | 24 ------------------------
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 | 5 +++++
target/arm/{ => kvm}/trace-events | 0
target/arm/meson.build | 2 --
29 files changed, 24 insertions(+), 46 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
delete mode 100644 target/arm/kvm-stub.c
rename target/arm/{ => kvm}/kvm.c (100%)
rename target/arm/{ => kvm}/kvm64.c (100%)
rename target/arm/{ => kvm}/trace-events (100%)meson.build +1 -1
@@ -1844,8 +1844,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
@@ -29,7 +29,7 @@#include "sysemu/sysemu.h" #include "exec/address-spaces.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
@@ -65,7 +65,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
@@ -19,7 +19,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
@@ -25,7 +25,7 @@#include "exec/address-spaces.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
@@ -26,7 +26,7 @@#include "hw/sysbus.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
@@ -27,7 +27,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" #ifdef CONFIG_TCG
target/arm/cpu.c +1 -1
@@ -41,7 +41,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/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
@@ -30,7 +30,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-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 (); -}
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
@@ -398,7 +398,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 +5 -0
@@ -1,3 +1,8 @@ arm_ss.add(when: 'CONFIG_TCG', if_false: files( 'helper-stubs.c', )) + +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 +0 -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',
Signature · 1 line
2.26.2
Re: [RFC v11 32/55] target/arm: move kvm-const.h, kvm.c, kvm64.c, kvm_arm.h to kvm/
Quoted 1 line · Claudio Fontana
target/arm/kvm-stub.c | 24 ------------------------
Can you really get rid of this?
If so, I think this should be a separate step.
target/arm/kvm/meson.build line 8
Quoted 12 lines
target/arm/kvm/meson.build +5
-0@@ -1,3 +1,8 @@ arm_ss.add(when: 'CONFIG_TCG', if_false: files( 'helper-stubs.c', )) + +arm_ss.add(when: 'CONFIG_KVM', if_true: files( + 'kvm.c', + 'kvm64.c', +))
Watch the whitespace warnings.
r~
Re: [RFC v11 32/55] target/arm: move kvm-const.h, kvm.c, kvm64.c, kvm_arm.h to kvm/
Quoted 4 lines · Richard Henderson
Quoted 1 line · Claudio Fontana
target/arm/kvm-stub.c | 24 ------------------------Can you really get rid of this?
calls in machine.c are protected by if (kvm_enabled()), so as long as the proto is in sight we can remove those. Futher refactoring of kvm/tcg for machines could improve this further (we still have it mixed on x86 too).
Quoted 1 line
If so, I think this should be a separate step.
Ok, can split up,
Claudio
Quoted 20 lines
Quoted 5 lines
target/arm/kvm/meson.build line 8
Quoted 9 lines
target/arm/kvm/meson.build +5
-0@@ -1,3 +1,8 @@ arm_ss.add(when: 'CONFIG_TCG', if_false: files( 'helper-stubs.c', )) + +arm_ss.add(when: 'CONFIG_KVM', if_true: files( + 'kvm.c', + 'kvm64.c', +))Watch the whitespace warnings.
r~
RFC v11 33/55 target/arm: cleanup cpu includes
In reply to Claudio Fontanacpu.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 | 8 ++------ target/arm/cpu32.c | 14 -------------- target/arm/cpu64.c | 6 ------ target/arm/tcg/sysemu/tcg-cpu.c | 22 +--------------------- 4 files changed, 3 insertions(+), 47 deletions(-)
target/arm/cpu.c +2 -6
@@ -19,28 +19,24 @@*/ #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" +#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/sysemu.h" +#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
@@ -22,13 +22,7 @@#include "qapi/error.h" #include "qemu/qemu-print.h" #include "cpu.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.26.2
RFC v11 34/55 target/arm: remove broad "else" statements when checking accels
In reply to Claudio FontanaThere 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 | 10 ++++++---- target/arm/cpu64.c | 13 +++++++++---- target/arm/machine.c | 19 ++++++------------- 3 files changed, 21 insertions(+), 21 deletions(-)
target/arm/cpu.c +6 -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,8 @@ 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 { + } +if (tcg_enabled () ||qtest_enabled ()) {qdev_init_gpio_in (DEVICE (cpu), arm_cpu_set_irq,4 ); }
@@ -741,14 +743,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 +851,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 +9 -4
@@ -23,6 +23,7 @@#include "qemu/qemu-print.h" #include "cpu.h" #include "qemu/module.h" +#include "sysemu/tcg.h" #include "sysemu/kvm.h" #include "kvm/kvm_arm.h" #include "qapi/visitor.h"
@@ -296,7 +297,8 @@ 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 { + } +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)) {
@@ -333,7 +335,8 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) "vector length must be enabled.\n");return ; } - }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" );
@@ -415,7 +418,8 @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) }return ; } - }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)) {
@@ -609,7 +613,8 @@ static void aarch64_max_initfn(Object *obj)if (kvm_enabled ()) {kvm_arm_set_cpu_features_from_host (cpu); - }else { + } +if (tcg_enabled ()) {uint64_t t;uint32_t u;aarch64_a57_initfn (obj);
target/arm/machine.c +6 -13
@@ -638,24 +638,21 @@ static int cpu_pre_save(void *opaque)if (tcg_enabled ()) {pmu_op_start (&cpu->env); +if (!write_cpustate_to_list (cpu, false)) { +/* This should never fail. */ +abort (); + } } -if (kvm_enabled ()) {if (!write_kvmstate_to_list (cpu)) {/* This should never fail */ abort (); } -/* * kvm_arm_cpu_pre_save() must be called after * 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,20 +751,16 @@ static int cpu_post_load(void *opaque, int version_id)*/ write_list_to_cpustate (cpu);kvm_arm_cpu_post_load (cpu); - }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); -pmu_op_finish (&cpu->env);arm_rebuild_hflags (&cpu->env); } -return 0 ; }
Signature · 1 line
2.26.2
Re: [RFC v11 34/55] target/arm: remove broad "else" statements when checking accels
target/arm/cpu64.c void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) · line 301
Quoted 7 lines · Claudio Fontana
target/arm/cpu64.c +2
-1@@ -296,7 +297,8 @@ 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 { + } +if (tcg_enabled ()) {
Better as else if, I think.
r~
RFC v11 35/55 tests/qtest: skip bios-tables-test test_acpi_oem_fields_virt for KVM
In reply to Claudio Fontanatest is TCG-only.
--- tests/qtest/bios-tables-test.c | 7 +++++++ 1 file changed, 7 insertions(+)
tests/qtest/bios-tables-test.c +7 -0
@@ -1488,6 +1488,13 @@ static void test_acpi_oem_fields_virt(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.26.2
RFC v11 36/55 tests: restrict TCG-only arm-cpu-features tests to TCG builds
In reply to Claudio Fontanasve_tests_sve_max_vq_8,sve_tests_sve_off,test_query_cpu_model_expansion
all require TCG to run. Skip them for KVM-only builds.
--- tests/qtest/arm-cpu-features.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
tests/qtest/arm-cpu-features.c +15 -0
@@ -352,6 +352,11 @@ static void sve_tests_sve_max_vq_8(const void *data) {QTestState *qts; +#ifndef CONFIG_TCG +g_test_skip ("TCG disabled, skipping tcg_only sve_tests_sve_max_vq_8" ); +return ; +#endif /* CONFIG_TCG */ + qts =qtest_init (MACHINE "-cpu max,sve-max-vq=8" );assert_sve_vls (qts,"max" ,BIT_ULL (8 ) -1 ,NULL );
@@ -387,6 +392,11 @@ static void sve_tests_sve_off(const void *data) {QTestState *qts; +#ifndef CONFIG_TCG +g_test_skip ("TCG disabled, skipping tcg_only sve_tests_sve_off" ); +return ; +#endif /* CONFIG_TCG */ + qts =qtest_init (MACHINE "-cpu max,sve=off" );/* SVE is off, so the map should be empty. */
@@ -443,6 +453,11 @@ static void test_query_cpu_model_expansion(const void *data) {QTestState *qts; +#ifndef CONFIG_TCG +g_test_skip ("TCG disabled, skipping tcg_only test_query_cpu_model_expansion" ); +return ; +#endif /* CONFIG_TCG */ + qts =qtest_init (MACHINE "-cpu max" );/* Test common query-cpu-model-expansion input validation */
Signature · 1 line
2.26.2
RFC v11 37/55 tests: do not run test-hmp on all machines for ARM KVM-only
In reply to Claudio Fontanaon 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.26.2
RFC v11 38/55 tests: device-introspect-test: cope with ARM TCG-only devices
In reply to Claudio FontanaSkip 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.
--- tests/qtest/device-introspect-test.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
tests/qtest/device-introspect-test.c +18 -0
@@ -329,12 +329,30 @@ 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); + +/* +* 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 ) { + goto add_machine_test_done; + } + } +#endif /* !CONFIG_TCG */ 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); } + goto add_machine_test_done; + add_machine_test_done:return g_test_run (); }
Signature · 1 line
2.26.2
RFC v11 39/55 tests: do not run qom-test on all machines for ARM KVM-only
In reply to Claudio Fontanaon 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.26.2
RFC v11 40/55 Revert "target/arm: Restrict v8M IDAU to TCG"
In reply to Claudio FontanaThis reverts commit 6e937ba7f8fb90d66cb3781f7fed32fb4239556a
This change breaks quickly at startup, as all interfaces in boards are checked in vl.c in select_machine():
{
GSList *machines = object_class_get_list(TYPE_MACHINE, false);
}
In order to restrict v8M IDAU to TCG,
we need to first disable all incompatible boards when building only KVM.
--- target/arm/cpu.c | 7 +++++++ target/arm/tcg/tcg-cpu-models.c | 8 -------- 2 files changed, 7 insertions(+), 8 deletions(-)
target/arm/cpu.c +7 -0
@@ -1510,9 +1510,16 @@ static const TypeInfo arm_cpu_type_info = { .class_init = arm_cpu_class_init, }; +static const TypeInfo idau_interface_type_info = { + .name =TYPE_IDAU_INTERFACE , + .parent =TYPE_INTERFACE , + .class_size =sizeof (IDAUInterfaceClass), +}; +static void arm_cpu_register_types (void ) {type_register_static (&arm_cpu_type_info); +type_register_static (&idau_interface_type_info);#ifdef CONFIG_KVM type_register_static (&host_arm_cpu_type_info);
target/arm/tcg/tcg-cpu-models.c +0 -8
@@ -12,7 +12,6 @@#include "tcg-cpu.h" #include "internals.h" -#include "target/arm/idau.h" #if !defined(CONFIG_USER_ONLY )#include "hw/boards.h" #endif
@@ -987,17 +986,10 @@ static const ARMCPUInfo arm_tcg_cpus[] = {#endif }; -static const TypeInfo idau_interface_type_info = { - .name =TYPE_IDAU_INTERFACE , - .parent =TYPE_INTERFACE , - .class_size =sizeof (IDAUInterfaceClass), -}; -static void arm_tcg_cpu_register_types (void ) {size_t i; -type_register_static (&idau_interface_type_info);for (i =0 ; i <ARRAY_SIZE (arm_tcg_cpus); ++i) {arm32_cpu_register (&arm_tcg_cpus[i]); }
Signature · 1 line
2.26.2
RFC v11 41/55 target/arm: create kvm cpu accel class
In reply to Claudio Fontanamove init, realizefn and reset code into it.
--- target/arm/internals.h | 1 - target/arm/cpu-sysemu.c | 32 ---------- target/arm/cpu.c | 48 ++------------ target/arm/kvm/kvm-cpu.c | 128 +++++++++++++++++++++++++++++++++++++ target/arm/kvm/meson.build | 3 +- 5 files changed, 137 insertions(+), 75 deletions(-) create mode 100644 target/arm/kvm/kvm-cpu.c
target/arm/internals.h +0 -1
@@ -1168,7 +1168,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" #ifdef CONFIG_TCG
@@ -71,37 +70,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 +7 -41
94 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 +2 -1
@@ -5,4 +5,5 @@ arm_ss.add(when: 'CONFIG_TCG', if_false: files( arm_ss.add(when: 'CONFIG_KVM', if_true: files( 'kvm.c', 'kvm64.c', -)) + 'kvm-cpu.c', +))
Signature · 1 line
2.26.2
RFC v11 42/55 target/arm: move kvm post init initialization to kvm cpu accel
In reply to Claudio Fontana--- 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.26.2
RFC v11 43/55 target/arm: add tcg cpu accel class
In reply to Claudio Fontanamove 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
@@ -844,16 +844,18 @@ static struct TCGCPUOps arm_v7m_tcg_ops = {#endif /* !CONFIG_USER_ONLY */ }; +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.26.2
RFC v11 44/55 target/arm: move TCG gt timer creation code in tcg/
In reply to Claudio Fontanawe 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 | 28 +++------------------- target/arm/tcg/sysemu/tcg-cpu.c | 41 +++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 25 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 +3 -25
@@ -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); +if (!tcg_cpu_realize_gt_timers (cs, errp)) { +return ; } -#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ +#endif cpu_exec_realizefn (cs, &local_err);if (local_err !=NULL ) {
target/arm/tcg/sysemu/tcg-cpu.c +41 -0
52 lines not on this page · raw message
Signature · 1 line
2.26.2
RFC v11 45/55 target/arm: cpu-sve: new module
In reply to Claudio Fontanaextract the SVE-related cpu object properties and functions, and move them to a separate module.
Disentangle SVE from pauth that is a separate, TCG-only feature.
--- target/arm/cpu-sve.h | 40 +++++ target/arm/cpu.h | 22 +-- target/arm/cpu-sve.c | 360 +++++++++++++++++++++++++++++++++++++++ target/arm/cpu.c | 5 +- target/arm/cpu64.c | 333 +----------------------------------- target/arm/kvm/kvm-cpu.c | 2 +- target/arm/meson.build | 1 + 7 files changed, 417 insertions(+), 346 deletions(-) create mode 100644 target/arm/cpu-sve.h create mode 100644 target/arm/cpu-sve.c
target/arm/cpu-sve.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* QEMU AArch64 CPU SVE Extensions for TARGET_AARCH64 +* +* Copyright (c) 2013 Linaro Ltd +* +* 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 CPU_SVE_H +#define CPU_SVE_H + +/* note: SVE is an AARCH64-only option, only include this for TARGET_AARCH64 */ + +/* called by arm_cpu_finalize_features in realizefn */ +void cpu_sve_finalize_features (ARMCPU *cpu,Error **errp); + +/* add the CPU SVE properties */ +void cpu_sve_add_props (Object *obj); + +/* add the CPU SVE properties specific to the "MAX" CPU */ +void cpu_sve_add_props_max (Object *obj); + +/* In AArch32 mode, predicate registers do not exist at all. */ +typedef struct ARMPredicateReg { + uint64_t p[DIV_ROUND_UP(2 * ARM_MAX_VQ, 8)] QEMU_ALIGNED(16); +}ARMPredicateReg ; + +#endif /* CPU_SVE_H */
target/arm/cpu.h +9 -13
@@ -173,7 +173,8 @@ typedef struct {#define VSTCR_SW VTCR_NSW#define VSTCR_SA VTCR_NSA -/* Define a maximum sized vector register. +/* +* Define a maximum sized vector register. * For 32-bit, this is a 128-bit NEON/AdvSIMD register. * For 64-bit, this is a 2048-bit SVE register. *
@@ -201,28 +202,25 @@ typedef struct {#ifdef TARGET_AARCH64 # define ARM_MAX_VQ 16 -void arm_cpu_sve_finalize (ARMCPU *cpu,Error **errp); -void arm_cpu_pauth_finalize (ARMCPU *cpu,Error **errp); +# include "cpu-sve.h" #else # define ARM_MAX_VQ 1 -static inline void arm_cpu_sve_finalize (ARMCPU *cpu,Error **errp) { } -static inline void arm_cpu_pauth_finalize (ARMCPU *cpu,Error **errp) { } -#endif +#endif /* TARGET_AARCH64 */ typedef struct ARMVectorReg { uint64_t d[2 * ARM_MAX_VQ] QEMU_ALIGNED(16); }ARMVectorReg ; -#ifdef TARGET_AARCH64 -/* In AArch32 mode, predicate registers do not exist at all. */ -typedef struct ARMPredicateReg { - uint64_t p[DIV_ROUND_UP(2 * ARM_MAX_VQ, 8)] QEMU_ALIGNED(16); -}ARMPredicateReg ; +/* ARMv8.3 Pointer Authentication Extension (AARCH64-only) */ +#ifdef TARGET_AARCH64 +void arm_cpu_pauth_finalize (ARMCPU *cpu,Error **errp);/* In AArch32 mode, PAC keys do not exist at all. */ typedef struct ARMPACKey {uint64_t lo, hi; }ARMPACKey ; +#else +static inline void arm_cpu_pauth_finalize (ARMCPU *cpu,Error **errp) { }#endif typedef struct CPUARMState {
@@ -1052,7 +1050,6 @@ int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);void aarch64_sve_narrow_vq (CPUARMState *env,unsigned vq);void aarch64_sve_change_el (CPUARMState *env,int old_el,int new_el,bool el0_a64); -void aarch64_add_sve_properties (Object *obj);/* * SVE registers are encoded in KVM's memory in an endianness-invariant format.
@@ -1083,7 +1080,6 @@ static inline void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq) { }static inline void aarch64_sve_change_el (CPUARMState *env,int o,int n,bool a) { } -static inline void aarch64_add_sve_properties (Object *obj) { }#endif void aarch64_sync_32_to_64 (CPUARMState *env);
target/arm/cpu-sve.c new file +360 -0
360 lines not on this page · raw message
target/arm/cpu.c +4 -1
@@ -23,6 +23,7 @@#include "target/arm/idau.h" #include "qapi/error.h" #include "cpu.h" +#include "cpu-sve.h" #include "cpregs.h" #ifdef CONFIG_TCG
@@ -818,8 +819,9 @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) {Error *local_err =NULL ; +#ifdef TARGET_AARCH64 if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { -arm_cpu_sve_finalize (cpu, &local_err); +cpu_sve_finalize_features (cpu, &local_err);if (local_err !=NULL ) {error_propagate (errp, local_err);return ;
@@ -838,6 +840,7 @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) } } } +#endif /* TARGET_AARCH64 */ if (kvm_enabled ()) {kvm_arm_steal_time_finalize (cpu, &local_err);
target/arm/cpu64.c +2 -331
345 lines not on this page · raw message
target/arm/kvm/kvm-cpu.c +1 -1
@@ -88,7 +88,7 @@ static void host_cpu_instance_init(Object *obj)kvm_arm_set_cpu_features_from_host (cpu);if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { -aarch64_add_sve_properties (obj); +cpu_sve_add_props (obj); }arm_cpu_post_init (obj); }
target/arm/meson.build +1 -0
@@ -14,6 +14,7 @@ arm_ss.add(zlib) arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'cpu64.c', 'gdbstub64.c', + 'cpu-sve.c', )) arm_softmmu_ss = ss.source_set()
Signature · 1 line
2.26.2
Re: [RFC v11 45/55] target/arm: cpu-sve: new module
Quoted 52 lines · Claudio Fontana
extract the SVE-related cpu object properties and functions, and move them to a separate module.
Disentangle SVE from pauth that is a separate, TCG-only feature.
Signed-off-by Claudio Fontana <[email protected]>--- target/arm/cpu-sve.h | 40 +++++ target/arm/cpu.h | 22 +-- target/arm/cpu-sve.c | 360 +++++++++++++++++++++++++++++++++++++++ target/arm/cpu.c | 5 +- target/arm/cpu64.c | 333 +----------------------------------- target/arm/kvm/kvm-cpu.c | 2 +- target/arm/meson.build | 1 + 7 files changed, 417 insertions(+), 346 deletions(-)create mode 100644
target/arm/cpu-sve.h
create mode 100644target/arm/cpu-sve.ctarget/arm/cpu-sve.h new file +28
-0@@ -0,0 +1,40 @@ +/* +* QEMU AArch64 CPU SVE Extensions for TARGET_AARCH64 +* +* Copyright (c) 2013 Linaro Ltd +* +* 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 CPU_SVE_H +#define CPU_SVE_H + +/* note: SVE is an AARCH64-only option, only include this for TARGET_AARCH64 */ + +/* called by arm_cpu_finalize_features in realizefn */ +void cpu_sve_finalize_features (ARMCPU *cpu,Error **errp); +
target/arm/cpu-sve.h line 38
Quoted 10 lines
target/arm/cpu-sve.h new file +10
-0+/* add the CPU SVE properties */ +void cpu_sve_add_props (Object *obj); + +/* add the CPU SVE properties specific to the "MAX" CPU */ +void cpu_sve_add_props_max (Object *obj); + +/* In AArch32 mode, predicate registers do not exist at all. */ +typedef struct ARMPredicateReg { + uint64_t p[DIV_ROUND_UP(2 * ARM_MAX_VQ, 8)] QEMU_ALIGNED(16); +}ARMPredicateReg ;
I don't agree with moving this out of cpu.h, next to the rest of the vector definitions.
I agree that we should be using more files, but if we're going to have an cpu-sve.c, why did some of the sve functions go into cpu-common.c?
I don't agree with moving functions and renaming them simultaneously. I'm not even sure why you're renaming them, or why you've suddenly chosen "cpu_sve_*" as the prefix to use.
r~
Re: [RFC v11 45/55] target/arm: cpu-sve: new module
Quoted 67 lines · Richard Henderson
Quoted 52 lines · Claudio Fontana
extract the SVE-related cpu object properties and functions, and move them to a separate module.
Disentangle SVE from pauth that is a separate, TCG-only feature.
Signed-off-by Claudio Fontana <[email protected]>--- target/arm/cpu-sve.h | 40 +++++ target/arm/cpu.h | 22 +-- target/arm/cpu-sve.c | 360 +++++++++++++++++++++++++++++++++++++++ target/arm/cpu.c | 5 +- target/arm/cpu64.c | 333 +----------------------------------- target/arm/kvm/kvm-cpu.c | 2 +- target/arm/meson.build | 1 + 7 files changed, 417 insertions(+), 346 deletions(-)create mode 100644
target/arm/cpu-sve.h
create mode 100644target/arm/cpu-sve.ctarget/arm/cpu-sve.h new file +28
-0@@ -0,0 +1,40 @@ +/* +* QEMU AArch64 CPU SVE Extensions for TARGET_AARCH64 +* +* Copyright (c) 2013 Linaro Ltd +* +* 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 CPU_SVE_H +#define CPU_SVE_H + +/* note: SVE is an AARCH64-only option, only include this for TARGET_AARCH64 */ + +/* called by arm_cpu_finalize_features in realizefn */ +void cpu_sve_finalize_features (ARMCPU *cpu,Error **errp); +target/arm/cpu-sve.h line 38
Quoted 10 lines
target/arm/cpu-sve.h new file +10
-0+/* add the CPU SVE properties */ +void cpu_sve_add_props (Object *obj); + +/* add the CPU SVE properties specific to the "MAX" CPU */ +void cpu_sve_add_props_max (Object *obj); + +/* In AArch32 mode, predicate registers do not exist at all. */ +typedef struct ARMPredicateReg { + uint64_t p[DIV_ROUND_UP(2 * ARM_MAX_VQ, 8)] QEMU_ALIGNED(16); +}ARMPredicateReg ;I don't agree with moving this out of
cpu.h, next to the rest of the vector definitions.
Quoted 2 lines
I agree that we should be using more files, but if we're going to have an
cpu-sve.c, why did some of the sve functions go intocpu-common.c?
maybe cpu-sve-props.c would be a better name, it really contains only cpu sve properties code.
Quoted 8 lines
I don't agree with moving functions and renaming them simultaneously. I'm not even sure why you're renaming them, or why you've suddenly chosen "cpu_sve_*" as the prefix to use.
r~
I think the idea was trying to create a cpu_sve module handling everything related to sve, and consistently using the name of the module as the prefix.
It might be too early to attempt that anyway; as you noted, there is other SVE-related functionality all over the place, so better to revisit this.
I'd suggest renaming this to cpu_sve_props, and moving everything not props related out of it.
Thanks,
Claudio
Re: [RFC v11 45/55] target/arm: cpu-sve: new module
Quoted 68 lines · Claudio Fontana
Quoted 67 lines · Richard Henderson
Quoted 52 lines · Claudio Fontana
extract the SVE-related cpu object properties and functions, and move them to a separate module.
Disentangle SVE from pauth that is a separate, TCG-only feature.
Signed-off-by Claudio Fontana <[email protected]>--- target/arm/cpu-sve.h | 40 +++++ target/arm/cpu.h | 22 +-- target/arm/cpu-sve.c | 360 +++++++++++++++++++++++++++++++++++++++ target/arm/cpu.c | 5 +- target/arm/cpu64.c | 333 +----------------------------------- target/arm/kvm/kvm-cpu.c | 2 +- target/arm/meson.build | 1 + 7 files changed, 417 insertions(+), 346 deletions(-)create mode 100644
target/arm/cpu-sve.h
create mode 100644target/arm/cpu-sve.ctarget/arm/cpu-sve.h new file +28
-0@@ -0,0 +1,40 @@ +/* +* QEMU AArch64 CPU SVE Extensions for TARGET_AARCH64 +* +* Copyright (c) 2013 Linaro Ltd +* +* 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 CPU_SVE_H +#define CPU_SVE_H + +/* note: SVE is an AARCH64-only option, only include this for TARGET_AARCH64 */ + +/* called by arm_cpu_finalize_features in realizefn */ +void cpu_sve_finalize_features (ARMCPU *cpu,Error **errp); +target/arm/cpu-sve.h line 38
Quoted 10 lines
target/arm/cpu-sve.h new file +10
-0+/* add the CPU SVE properties */ +void cpu_sve_add_props (Object *obj); + +/* add the CPU SVE properties specific to the "MAX" CPU */ +void cpu_sve_add_props_max (Object *obj); + +/* In AArch32 mode, predicate registers do not exist at all. */ +typedef struct ARMPredicateReg { + uint64_t p[DIV_ROUND_UP(2 * ARM_MAX_VQ, 8)] QEMU_ALIGNED(16); +}ARMPredicateReg ;I don't agree with moving this out of
cpu.h, next to the rest of the vector definitions.
Quoted 2 lines
Quoted 2 lines
I agree that we should be using more files, but if we're going to have an
cpu-sve.c, why did some of the sve functions go intocpu-common.c?
actually, now that the option of making those SVE functions in cpu-common.c TARGET_AARCH64-specific is open, we could attempt to import them in cpu-sve.
I'll give it a try, lets see the result.
Quoted 27 lines
maybe
cpu-sve-props.cwould be a better name, it really contains only cpu sve properties code.Quoted 8 lines
I don't agree with moving functions and renaming them simultaneously. I'm not even sure why you're renaming them, or why you've suddenly chosen "cpu_sve_*" as the prefix to use.
r~
I think the idea was trying to create a
cpu_svemodule handling everything related to sve, and consistently using the name of the module as the prefix.It might be too early to attempt that anyway; as you noted, there is other SVE-related functionality all over the place, so better to revisit this.
I'd suggest renaming this to
cpu_sve_props, and moving everything not props related out of it.Thanks,
Claudio
RFC v11 46/55 target/arm: cpu-sve: split TCG and KVM functionality
In reply to Claudio Fontanaput the KVM-specific and TCG-specific functionality in the respective subdirectories kvm/ and tcg/
--- target/arm/cpu-sve.h | 2 +- target/arm/kvm/cpu-sve.h | 30 +++++++ target/arm/tcg/cpu-sve.h | 24 ++++++ target/arm/cpu-sve.c | 166 +++++++++++-------------------------- target/arm/cpu.c | 3 +- target/arm/kvm/cpu-sve.c | 118 ++++++++++++++++++++++++++ target/arm/tcg/cpu-sve.c | 80 ++++++++++++++++++ target/arm/kvm/meson.build | 1 + target/arm/tcg/meson.build | 1 + 9 files changed, 305 insertions(+), 120 deletions(-) create mode 100644 target/arm/kvm/cpu-sve.h create mode 100644 target/arm/tcg/cpu-sve.h create mode 100644 target/arm/kvm/cpu-sve.c create mode 100644 target/arm/tcg/cpu-sve.c
target/arm/cpu-sve.h +1 -1
@@ -24,7 +24,7 @@/* note: SVE is an AARCH64-only option, only include this for TARGET_AARCH64 */ /* called by arm_cpu_finalize_features in realizefn */ -void cpu_sve_finalize_features (ARMCPU *cpu,Error **errp); +bool cpu_sve_finalize_features (ARMCPU *cpu,Error **errp);/* add the CPU SVE properties */ void cpu_sve_add_props (Object *obj);
target/arm/kvm/cpu-sve.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* QEMU AArch64 CPU SVE KVM interface +* +* 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. +*/ + +#ifndef KVM_CPU_SVE_H +#define KVM_CPU_SVE_H + +/* note: SVE is an AARCH64-only option, only include this for TARGET_AARCH64 */ + +void kvm_cpu_sve_get_supported_lens (ARMCPU *cpu, +unsigned long *kvm_supported); + +void kvm_cpu_sve_enable_lens (unsigned long *sve_vq_map, +unsigned long *sve_vq_init,uint32_t max_vq, +unsigned long *kvm_supported); + +uint32_t kvm_cpu_sve_disable_lens (unsigned long *sve_vq_map, +unsigned long *sve_vq_init, +unsigned long *kvm_supported,Error **errp); + +bool kvm_cpu_sve_validate_lens (unsigned long *sve_vq_map,uint32_t max_vq, +unsigned long *kvm_supported,Error **errp, +uint32_t sve_max_vq); + +#endif /* KVM_CPU_SVE_H */
target/arm/tcg/cpu-sve.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* QEMU AArch64 CPU SVE TCG interface +* +* 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. +*/ + +#ifndef TCG_CPU_SVE_H +#define TCG_CPU_SVE_H + +/* note: SVE is an AARCH64-only option, only include this for TARGET_AARCH64 */ + +void tcg_cpu_sve_enable_lens (unsigned long *sve_vq_map, +unsigned long *sve_vq_init,uint32_t max_vq); + +uint32_t tcg_cpu_sve_disable_lens (unsigned long *sve_vq_map, +unsigned long *sve_vq_init,Error **errp); + +bool tcg_cpu_sve_validate_lens (unsigned long *sve_vq_map,uint32_t max_vq, +Error **errp); + +#endif /* TCG_CPU_SVE_H */
target/arm/cpu-sve.c +49 -117
226 lines not on this page · raw message
target/arm/cpu.c +1 -2
@@ -821,8 +821,7 @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)#ifdef TARGET_AARCH64 if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { -cpu_sve_finalize_features (cpu, &local_err); -if (local_err !=NULL ) { +if (!cpu_sve_finalize_features (cpu, &local_err)) {error_propagate (errp, local_err);return ; }
target/arm/kvm/cpu-sve.c new file +118 -0
118 lines not on this page · raw message
target/arm/tcg/cpu-sve.c new file +80 -0
80 lines not on this page · raw message
target/arm/kvm/meson.build +1 -0
@@ -6,4 +6,5 @@ arm_ss.add(when: 'CONFIG_KVM', if_true: files( 'kvm.c', 'kvm64.c', 'kvm-cpu.c', + 'cpu-sve.c', ))
target/arm/tcg/meson.build +1 -0
@@ -39,6 +39,7 @@ arm_ss.add(when: ['TARGET_AARCH64', 'CONFIG_TCG'], if_true: files( 'mte_helper.c', 'pauth_helper.c', 'sve_helper.c', + 'cpu-sve.c', )) subdir('user')
Signature · 1 line
2.26.2
Re: [RFC v11 46/55] target/arm: cpu-sve: split TCG and KVM functionality
target/arm/cpu-sve.h line 27
Quoted 3 lines · Claudio Fontana
/* called by
arm_cpu_finalize_featuresin realizefn */target/arm/cpu-sve.h +1
-1-void cpu_sve_finalize_features (ARMCPU *cpu,Error **errp); +bool cpu_sve_finalize_features (ARMCPU *cpu,Error **errp);
No interface changes simultaneous with code movement.
r~
RFC v11 47/55 target/arm: make is_aa64 and arm_el_is_aa64 a macro for !TARGET_AARCH64
In reply to Claudio Fontanawhen TARGET_AARCH64 is not defined, it is helpful to make is_aa64() and arm_el_is_aa64 macros defined to "false".
This way we can make more code TARGET_AARCH64-only.
--- target/arm/cpu.h | 37 ++++++++++++++++++++++++------------- target/arm/cpu-mmu-sysemu.c | 6 ++---- 2 files changed, 26 insertions(+), 17 deletions(-)
target/arm/cpu.h +24 -13
@@ -1051,6 +1051,11 @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);void aarch64_sve_change_el (CPUARMState *env,int old_el,int new_el,bool el0_a64); +static inline bool is_a64 (CPUARMState *env) +{ +return env->aarch64; +} +/* * SVE registers are encoded in KVM's memory in an endianness-invariant format. * The byte at offset i from the start of the in-memory representation contains
@@ -1080,7 +1085,10 @@ static inline void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq) { }static inline void aarch64_sve_change_el (CPUARMState *env,int o,int n,bool a) { } -#endif + +#define is_a64 (env) (false) + +#endif /* TARGET_AARCH64 */ void aarch64_sync_32_to_64 (CPUARMState *env);void aarch64_sync_64_to_32 (CPUARMState *env);
@@ -1089,11 +1097,6 @@ int fp_exception_el(CPUARMState *env, int cur_el);int sve_exception_el (CPUARMState *env,int cur_el);uint32_t sve_zcr_len_for_el (CPUARMState *env,int el); -static inline bool is_a64 (CPUARMState *env) -{ -return env->aarch64; -} -/* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */
@@ -2193,13 +2196,7 @@ static inline bool arm_is_el2_enabled(CPUARMState *env) }#endif -/** -* arm_hcr_el2_eff(): Return the effective value of HCR_EL2. -* E.g. when in secure state, fields in HCR_EL2 are suppressed, -* "for all purposes other than a direct read or write access of HCR_EL2." -* Not included here is HCR_RW. -*/ -uint64_t arm_hcr_el2_eff (CPUARMState *env); +#ifdef TARGET_AARCH64 /* Return true if the specified exception level is running in AArch64 state. */ static inline bool arm_el_is_aa64 (CPUARMState *env,int el)
@@ -2234,6 +2231,20 @@ static inline bool arm_el_is_aa64(CPUARMState *env, int el) return aa64; } +#else + +#define arm_el_is_aa64 (env, el) (false) + +#endif /* TARGET_AARCH64 */ + +/** +* arm_hcr_el2_eff(): Return the effective value of HCR_EL2. +* E.g. when in secure state, fields in HCR_EL2 are suppressed, +* "for all purposes other than a direct read or write access of HCR_EL2." +* Not included here is HCR_RW. +*/ +uint64_t arm_hcr_el2_eff (CPUARMState *env); +/* Function for determing whether guest cp register reads and writes should * access the secure or non-secure bank of a cp register. When EL3 is * operating in AArch32 state, the NS-bit determines whether the secure
target/arm/cpu-mmu-sysemu.c +2 -4
@@ -787,7 +787,6 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, }if (is_aa64) { -CPUARMState *env = &cpu->env;unsigned int pamax =arm_pamax (cpu);switch (stride) {
@@ -812,7 +811,7 @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level,/* Inputsize checks. */ if (inputsize > pamax && - (arm_el_is_aa64 (env,1 ) || inputsize >40 )) { + (arm_el_is_aa64 (&cpu->env,1 ) || inputsize >40 )) {/* This is CONSTRAINED UNPREDICTABLE and we choose to fault. */ return false; }
@@ -967,9 +966,8 @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,int addrsize, inputsize;TCR *tcr =regime_tcr (env, mmu_idx);int ap, ns, xn, pxn; -uint32_t el =regime_el (env, mmu_idx);uint64_t descaddrmask; -bool aarch64 =arm_el_is_aa64 (env, el); +bool aarch64 =arm_el_is_aa64 (env,regime_el (env, mmu_idx));bool guarded = false;/* TODO: This code does not support shareability levels. */
Signature · 1 line
2.26.2
Re: [RFC v11 47/55] target/arm: make is_aa64 and arm_el_is_aa64 a macro for !TARGET_AARCH64
Quoted 1 line · Claudio Fontana
+#define
is_a64(env)(false)
...
Quoted 1 line
+#define
arm_el_is_aa64(env, el)(false)
Why a define and not have the ifdef inside the static inline?
This define is causing you to make other random changes to avoid unused variables, and I'm not keen.
If you're running into problems with --enable-debug not eliminating code blocks, leading to link errors, then I think that __attribute__((always_inline)) and a comment will be the best option.
target/arm/cpu.h static inline bool arm_el_is_aa64(CPUARMState *env, int el) · line 2246
Quoted 10 lines
target/arm/cpu.h +10
-0+ +#endif /* TARGET_AARCH64 */ + +/** +* arm_hcr_el2_eff(): Return the effective value of HCR_EL2. +* E.g. when in secure state, fields in HCR_EL2 are suppressed, +* "for all purposes other than a direct read or write access of HCR_EL2." +* Not included here is HCR_RW. +*/ +uint64_t arm_hcr_el2_eff (CPUARMState *env);
Is this diff being weird or did you really move this declaration, and if so, why?
r~
Re: [RFC v11 47/55] target/arm: make is_aa64 and arm_el_is_aa64 a macro for !TARGET_AARCH64
Quoted 5 lines · Richard Henderson
Quoted 1 line · Claudio Fontana
+#define
is_a64(env)(false)...
Quoted 1 line
+#define
arm_el_is_aa64(env, el)(false)
Quoted 8 lines
Why a define and not have the ifdef inside the static inline?
This define is causing you to make other random changes to avoid unused variables, and I'm not keen.
If you're running into problems with --enable-debug not eliminating code blocks, leading to link errors, then I think that __attribute__((always_inline)) and a comment will be the best option.
right, I need to make this guaranteed to cause code elision, so that I can avoid including unneeded function definitions for aarch64 in arm builds.
Quoted 18 lines
target/arm/cpu.h static inline bool arm_el_is_aa64(CPUARMState *env, int el) · line 2246
Quoted 12 lines
target/arm/cpu.h +10
-0+ +#endif /* TARGET_AARCH64 */ + +/** +* arm_hcr_el2_eff(): Return the effective value of HCR_EL2. +* E.g. when in secure state, fields in HCR_EL2 are suppressed, +* "for all purposes other than a direct read or write access of HCR_EL2." +* Not included here is HCR_RW. +*/ +uint64_t arm_hcr_el2_eff (CPUARMState *env);Is this diff being weird or did you really move this declaration, and if so, why?
r~
Re: [RFC v11 47/55] target/arm: make is_aa64 and arm_el_is_aa64 a macro for !TARGET_AARCH64
In reply to Richard HendersonQuoted 5 lines · Richard Henderson
Quoted 1 line · Claudio Fontana
+#define
is_a64(env)(false)...
Quoted 1 line
+#define
arm_el_is_aa64(env, el)(false)
Quoted 8 lines
Why a define and not have the ifdef inside the static inline?
This define is causing you to make other random changes to avoid unused variables, and I'm not keen.
If you're running into problems with --enable-debug not eliminating code blocks, leading to link errors, then I think that __attribute__((always_inline)) and a comment will be the best option.
I am not getting linking troubles even with --enable-debug atm, so I'd avoid the attribute for now?
Quoted 14 lines
target/arm/cpu.h static inline bool arm_el_is_aa64(CPUARMState *env, int el) · line 2246
Quoted 12 lines
target/arm/cpu.h +10
-0+ +#endif /* TARGET_AARCH64 */ + +/** +* arm_hcr_el2_eff(): Return the effective value of HCR_EL2. +* E.g. when in secure state, fields in HCR_EL2 are suppressed, +* "for all purposes other than a direct read or write access of HCR_EL2." +* Not included here is HCR_RW. +*/ +uint64_t arm_hcr_el2_eff (CPUARMState *env);Is this diff being weird or did you really move this declaration, and if so, why?
Yes, weird diff.
Quoted 4 lines
r~
Tx
Re: [RFC v11 47/55] target/arm: make is_aa64 and arm_el_is_aa64 a macro for !TARGET_AARCH64
Quoted 11 lines · Claudio Fontana
Quoted 10 lines · Richard Henderson
Quoted 1 line · Claudio Fontana
+#define
is_a64(env)(false)...
Quoted 1 line
+#define
arm_el_is_aa64(env, el)(false)Why a define and not have the ifdef inside the static inline?
This define is causing you to make other random changes to avoid unused variables, and I'm not keen.
Quoted 6 lines
Quoted 3 lines
If you're running into problems with --enable-debug not eliminating code blocks, leading to link errors, then I think that __attribute__((always_inline)) and a comment will be the best option.
I am not getting linking troubles even with --enable-debug atm, so I'd avoid the attribute for now?
Nevermind, I got the error again. And it does not go away with ((always_inline))...
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: libqemu-arm-softmmu.fa.p/target_arm_cpu-exceptions.c.o: in function `arm_cpu_do_interrupt':/home/claudio/git/qemu-pristine/qemu/build-tcg/../target/arm/cpu-exceptions.c:471: undefined reference to `arm_cpu_do_interrupt_aarch64'
I will have to keep this until I find a better solution..
Quoted 25 lines
Quoted 15 lines
target/arm/cpu.h static inline bool arm_el_is_aa64(CPUARMState *env, int el) · line 2246
Quoted 13 lines
target/arm/cpu.h +10
-0+ +#endif /* TARGET_AARCH64 */ + +/** +* arm_hcr_el2_eff(): Return the effective value of HCR_EL2. +* E.g. when in secure state, fields in HCR_EL2 are suppressed, +* "for all purposes other than a direct read or write access of HCR_EL2." +* Not included here is HCR_RW. +*/ +uint64_t arm_hcr_el2_eff (CPUARMState *env);Is this diff being weird or did you really move this declaration, and if so, why?
Yes, weird diff.
Quoted 4 lines
r~
Tx
Re: [RFC v11 47/55] target/arm: make is_aa64 and arm_el_is_aa64 a macro for !TARGET_AARCH64
In reply to Claudio FontanaQuoted 11 lines · Claudio Fontana
Quoted 10 lines · Richard Henderson
Quoted 1 line · Claudio Fontana
+#define
is_a64(env)(false)...
Quoted 1 line
+#define
arm_el_is_aa64(env, el)(false)Why a define and not have the ifdef inside the static inline?
This define is causing you to make other random changes to avoid unused variables, and I'm not keen.
Quoted 6 lines
Quoted 3 lines
If you're running into problems with --enable-debug not eliminating code blocks, leading to link errors, then I think that __attribute__((always_inline)) and a comment will be the best option.
I am not getting linking troubles even with --enable-debug atm, so I'd avoid the attribute for now?
Then you must use the macro arguments in the define.
#define foo(x, y) ((void)(x), (void)(y), false)
r~
RFC v11 48/55 target/arm: arch_dump: restrict ELFCLASS64 to AArch64
In reply to Claudio Fontanathis will allow us to restrict more code to TARGET_AARCH64
--- target/arm/helper-a64.h | 2 ++ target/arm/helper.h | 1 - target/arm/arch_dump.c | 12 +++++++----- target/arm/cpu.c | 1 - target/arm/cpu64.c | 4 ++++ target/arm/tcg/helper.c | 13 +++++++++++-- 6 files changed, 24 insertions(+), 9 deletions(-)
target/arm/helper-a64.h +2 -0
@@ -119,3 +119,5 @@ DEF_HELPER_FLAGS_2(st2g_stub, TCG_CALL_NO_WG, void, env, i64) DEF_HELPER_FLAGS_2(ldgm, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_3(stgm, TCG_CALL_NO_WG, void, env, i64, i64) DEF_HELPER_FLAGS_3(stzgm_tags, TCG_CALL_NO_WG, void, env, i64, i64) + +DEF_HELPER_FLAGS_2 (rebuild_hflags_a64,TCG_CALL_NO_RWG , void, env, int)
target/arm/helper.h +0 -1
@@ -94,7 +94,6 @@ DEF_HELPER_FLAGS_1(rebuild_hflags_m32_newel, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_2(rebuild_hflags_m32, TCG_CALL_NO_RWG, void, env, int) DEF_HELPER_FLAGS_1(rebuild_hflags_a32_newel, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_2(rebuild_hflags_a32, TCG_CALL_NO_RWG, void, env, int) -DEF_HELPER_FLAGS_2(rebuild_hflags_a64, TCG_CALL_NO_RWG, void, env, int)DEF_HELPER_FLAGS_5 (probe_access,TCG_CALL_NO_WG , void, env, tl, i32, i32, i32)
target/arm/arch_dump.c +7 -5
@@ -23,6 +23,8 @@#include "elf.h" #include "sysemu/dump.h" +#ifdef TARGET_AARCH64 + /* struct user_pt_regs from arch/arm64/include/uapi/asm/ptrace.h */ struct aarch64_user_regs { uint64_t regs[31];
@@ -141,7 +143,6 @@ static int aarch64_write_elf64_prfpreg(WriteCoreDumpFunction f,return 0 ; } -#ifdef TARGET_AARCH64 static off_t sve_zreg_offset (uint32_t vq,int n) {off_t off =sizeof (struct aarch64_user_sve_header );
@@ -229,7 +230,6 @@ static int aarch64_write_elf64_sve(WriteCoreDumpFunction f,return 0 ; } -#endif int arm_cpu_write_elf64_note (WriteCoreDumpFunction f,CPUState *cs,int cpuid,void *opaque)
@@ -272,15 +272,15 @@ int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, return ret; } -#ifdef TARGET_AARCH64 if (cpu_isar_feature (aa64_sve, cpu)) { ret =aarch64_write_elf64_sve (f, env, cpuid, s); } -#endif return ret; } +#endif /* TARGET_AARCH64 */ +/* struct pt_regs from arch/arm/include/asm/ptrace.h */ struct arm_user_regs {uint32_t regs[17 ];
@@ -449,12 +449,14 @@ ssize_t cpu_get_note_size(int class, int machine, int nr_cpus)size_t note_size;if (class ==ELFCLASS64 ) { +#ifdef TARGET_AARCH64 note_size =AARCH64_PRSTATUS_NOTE_SIZE ; note_size +=AARCH64_PRFPREG_NOTE_SIZE ; -#ifdef TARGET_AARCH64 if (cpu_isar_feature (aa64_sve, cpu)) { note_size +=AARCH64_SVE_NOTE_SIZE (&cpu->env); } +#else +return -1 ;/* unsupported */ #endif }else { note_size =ARM_PRSTATUS_NOTE_SIZE ;
target/arm/cpu.c +0 -1
@@ -1391,7 +1391,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->asidx_from_attrs = arm_asidx_from_attrs; cc->vmsd = &vmstate_arm_cpu; cc->virtio_is_big_endian = arm_cpu_virtio_is_big_endian; - cc->write_elf64_note = arm_cpu_write_elf64_note; cc->write_elf32_note = arm_cpu_write_elf32_note;#endif
target/arm/cpu64.c +4 -0
@@ -623,6 +623,10 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_arch_name = aarch64_gdb_arch_name; cc->dump_state = aarch64_cpu_dump_state; +#ifndef CONFIG_USER_ONLY + cc->write_elf64_note = arm_cpu_write_elf64_note; +#endif /* !CONFIG_USER_ONLY */ +object_class_property_add_bool (oc,"aarch64" , aarch64_cpu_get_aarch64, aarch64_cpu_set_aarch64); object_class_property_set_description(oc, "aarch64",
target/arm/tcg/helper.c +11 -2
@@ -18,6 +18,9 @@#include "cpregs.h" #include "tcg-cpu.h" +uint32_t rebuild_hflags_a64 (CPUARMState *env,int el,int fp_el, +ARMMMUIdx mmu_idx); +static int vfp_gdb_get_reg (CPUARMState *env,GByteArray *buf,int reg) {ARMCPU *cpu =env_archcpu (env);
@@ -1152,8 +1155,10 @@ static uint32_t rebuild_hflags_a32(CPUARMState *env, int fp_el,return rebuild_hflags_common_32 (env, fp_el, mmu_idx, flags); } -static uint32_t rebuild_hflags_a64 (CPUARMState *env,int el,int fp_el, -ARMMMUIdx mmu_idx) +#ifdef TARGET_AARCH64 + +uint32_t rebuild_hflags_a64 (CPUARMState *env,int el,int fp_el, +ARMMMUIdx mmu_idx) {uint32_t flags =rebuild_hflags_aprofile (env);ARMMMUIdx stage1 =stage_1_mmu_idx (mmu_idx);
@@ -1272,6 +1277,8 @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, return rebuild_hflags_common(env, fp_el, mmu_idx, flags); } +#endif /* TARGET_AARCH64 */ +static uint32_t rebuild_hflags_internal (CPUARMState *env) {int el =arm_current_el (env);
@@ -1332,6 +1339,7 @@ void HELPER(rebuild_hflags_a32)(CPUARMState *env, int el) env->hflags =rebuild_hflags_a32 (env, fp_el, mmu_idx); } +#ifdef TARGET_AARCH64 void HELPER (rebuild_hflags_a64 )(CPUARMState *env,int el) {int fp_el =fp_exception_el (env, el);
@@ -1339,6 +1347,7 @@ void HELPER(rebuild_hflags_a64)(CPUARMState *env, int el) env->hflags = rebuild_hflags_a64(env, el, fp_el, mmu_idx); } +#endif /* TARGET_AARCH64 */ static inline void assert_hflags_rebuild_correctly (CPUARMState *env) {
Signature · 1 line
2.26.2
Re: [RFC v11 48/55] target/arm: arch_dump: restrict ELFCLASS64 to AArch64
Quoted 17 lines · Claudio Fontana
this will allow us to restrict more code to
TARGET_AARCH64Signed-off-by Claudio Fontana <[email protected]>--- target/arm/helper-a64.h | 2 ++ target/arm/helper.h | 1 - target/arm/arch_dump.c | 12 +++++++----- target/arm/cpu.c | 1 - target/arm/cpu64.c | 4 ++++ target/arm/tcg/helper.c | 13 +++++++++++-- 6 files changed, 24 insertions(+), 9 deletions(-)target/arm/helper-a64.h +0
-0
target/arm/helper-a64.h DEF_HELPER_FLAGS_2(st2g_stub, TCG_CALL_NO_WG, void, env, i64) · line 123
Quoted 5 lines
target/arm/helper-a64.h +2
-0@@ -119,3 +119,5 @@ DEF_HELPER_FLAGS_2(st2g_stub, TCG_CALL_NO_WG, void, env, i64) DEF_HELPER_FLAGS_2(ldgm, TCG_CALL_NO_WG, i64, env, i64) DEF_HELPER_FLAGS_3(stgm, TCG_CALL_NO_WG, void, env, i64, i64) DEF_HELPER_FLAGS_3(stzgm_tags, TCG_CALL_NO_WG, void, env, i64, i64) + +DEF_HELPER_FLAGS_2 (rebuild_hflags_a64,TCG_CALL_NO_RWG , void, env, int)
I'm certain this has nothing to do with arch_dump. Split your patches.
r~
RFC v11 49/55 target/arm: cpu-exceptions: new module
In reply to Claudio Fontanaextract the exception handling code from cpu-sysemu, and split it into general arm code and an AArch64-specific part.
--- target/arm/cpu-exceptions-aa64.h | 32 + target/arm/cpu.h | 4 - target/arm/arch_dump.c | 1 + target/arm/cpu-exceptions-aa64.c | 552 +++++++++++++++++ target/arm/cpu-exceptions.c | 481 +++++++++++++++ target/arm/cpu-sysemu.c | 976 ------------------------------- target/arm/cpu-user.c | 1 + target/arm/cpu64.c | 1 + target/arm/kvm/kvm64.c | 1 + target/arm/tcg/helper-a64.c | 1 + target/arm/tcg/helper.c | 1 + target/arm/meson.build | 5 + 12 files changed, 1076 insertions(+), 980 deletions(-) create mode 100644 target/arm/cpu-exceptions-aa64.h create mode 100644 target/arm/cpu-exceptions-aa64.c create mode 100644 target/arm/cpu-exceptions.c
target/arm/cpu-exceptions-aa64.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* QEMU AArch64 CPU Exceptions 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> +*/ + +#ifndef CPU_EXCEPTIONS_AA64_H +#define CPU_EXCEPTIONS_AA64_H + +#include "cpu.h" + +int sve_exception_el (CPUARMState *env,int el); +void aarch64_sync_64_to_32 (CPUARMState *env); +void aarch64_sync_32_to_64 (CPUARMState *env); +void arm_cpu_do_interrupt_aarch64 (CPUState *cs); + +#endif /* CPU_EXCEPTIONS_AA64_H */ +
target/arm/cpu.h +0 -4
@@ -1090,11 +1090,7 @@ static inline void aarch64_sve_change_el(CPUARMState *env, int o,#endif /* TARGET_AARCH64 */ -void aarch64_sync_32_to_64 (CPUARMState *env); -void aarch64_sync_64_to_32 (CPUARMState *env); -int fp_exception_el (CPUARMState *env,int cur_el); -int sve_exception_el (CPUARMState *env,int cur_el);uint32_t sve_zcr_len_for_el (CPUARMState *env,int el);/* you can call this signal handler from your SIGBUS and SIGSEGV
target/arm/arch_dump.c +1 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "cpu.h" +#include "cpu-exceptions-aa64.h" #include "elf.h" #include "sysemu/dump.h"
target/arm/cpu-exceptions-aa64.c new file +552 -0
552 lines not on this page · raw message
target/arm/cpu-exceptions.c new file +481 -0
481 lines not on this page · raw message
target/arm/cpu-sysemu.c +0 -976
979 lines not on this page · raw message
target/arm/cpu-user.c +1 -0
@@ -12,6 +12,7 @@#include "qapi/qapi-commands-machine-target.h" #include "qapi/error.h" #include "cpu.h" +#include "cpu-exceptions-aa64.h" #include "internals.h" void switch_mode (CPUARMState *env,int mode)
target/arm/cpu64.c +1 -0
@@ -22,6 +22,7 @@#include "qapi/error.h" #include "qemu/qemu-print.h" #include "cpu.h" +#include "cpu-exceptions-aa64.h" #include "qemu/module.h" #include "sysemu/tcg.h" #include "sysemu/kvm.h"
target/arm/kvm/kvm64.c +1 -0
@@ -19,6 +19,7 @@#include "qemu-common.h" #include "qapi/error.h" #include "cpu.h" +#include "cpu-exceptions-aa64.h" #include "qemu/timer.h" #include "qemu/error-report.h" #include "qemu/host-utils.h"
target/arm/tcg/helper-a64.c +1 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu/units.h" #include "cpu.h" +#include "cpu-exceptions-aa64.h" #include "exec/gdbstub.h" #include "exec/helper-proto.h" #include "qemu/host-utils.h"
target/arm/tcg/helper.c +1 -0
@@ -8,6 +8,7 @@#include "qemu/osdep.h" #include "cpu.h" +#include "cpu-exceptions-aa64.h" #include "internals.h" #include "exec/gdbstub.h" #include "exec/helper-proto.h"
target/arm/meson.build +5 -0
@@ -25,6 +25,11 @@ arm_softmmu_ss.add(files( 'monitor.c', 'cpu-sysemu.c', 'cpu-mmu-sysemu.c', + 'cpu-exceptions.c', +)) + +arm_softmmu_ss.add(when: 'TARGET_AARCH64', if_true: files( + 'cpu-exceptions-aa64.c' )) arm_softmmu_ss.add(when: 'CONFIG_TCG', if_true: files(
Signature · 1 line
2.26.2
RFC v11 50/55 target/arm: tcg: restrict ZCR cpregs to TARGET_AARCH64
In reply to Claudio Fontanarestrict zcr_el1, zcr_el2, zcr_no_el2, zcr_el3 reginfo, as well as related SVE functions.
--- target/arm/cpu.h | 7 ------- target/arm/tcg/cpu-sve.h | 7 +++++++ linux-user/syscall.c | 4 ++++ target/arm/cpu-exceptions-aa64.c | 1 + target/arm/tcg/cpregs.c | 10 ++++++++-- target/arm/tcg/helper-a64.c | 1 + target/arm/tcg/helper.c | 1 + 7 files changed, 22 insertions(+), 9 deletions(-)
target/arm/cpu.h +0 -7
@@ -1047,9 +1047,6 @@ int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,#ifdef TARGET_AARCH64 int aarch64_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int aarch64_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); -void aarch64_sve_narrow_vq (CPUARMState *env,unsigned vq); -void aarch64_sve_change_el (CPUARMState *env,int old_el, -int new_el,bool el0_a64);static inline bool is_a64 (CPUARMState *env) {
@@ -1081,10 +1078,6 @@ static inline uint64_t *sve_bswap64(uint64_t *dst, uint64_t *src, int nr) }#else -static inline void aarch64_sve_narrow_vq (CPUARMState *env,unsigned vq) { } -static inline void aarch64_sve_change_el (CPUARMState *env,int o, -int n,bool a) -{ }#define is_a64 (env) (false)
target/arm/tcg/cpu-sve.h +7 -0
@@ -21,4 +21,11 @@ uint32_t tcg_cpu_sve_disable_lens(unsigned long *sve_vq_map,bool tcg_cpu_sve_validate_lens (unsigned long *sve_vq_map,uint32_t max_vq,Error **errp); +/* tcg/helper.c */ + +void aarch64_sve_narrow_vq (CPUARMState *env,unsigned vq); + +void aarch64_sve_change_el (CPUARMState *env,int old_el, +int new_el,bool el0_a64); +#endif /* TCG_CPU_SVE_H */
linux-user/syscall.c +4 -0
@@ -134,6 +134,10 @@#include "fd-trans.h" #include "tcg/tcg.h" +#ifdef TARGET_AARCH64 +#include "tcg/cpu-sve.h" +#endif /* TARGET_AARCH64 */ +#ifndef CLONE_IO #define CLONE_IO 0x80000000/* Clone io context */ #endif
target/arm/cpu-exceptions-aa64.c +1 -0
@@ -21,6 +21,7 @@#include "qemu/osdep.h" #include "qemu/log.h" #include "cpu.h" +#include "tcg/cpu-sve.h" #include "internals.h" #include "sysemu/tcg.h"
target/arm/tcg/cpregs.c +8 -2
@@ -5792,6 +5792,10 @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = {REGINFO_SENTINEL }; +#ifdef TARGET_AARCH64 + +#include "tcg/cpu-sve.h" +static void zcr_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {
@@ -5844,6 +5848,8 @@ static const ARMCPRegInfo zcr_el3_reginfo = { .writefn = zcr_write, .raw_writefn = raw_write }; +#endif /* TARGET_AARCH64 */ +static void dbgwvr_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {
@@ -7573,6 +7579,7 @@ void register_cp_regs_for_features(ARMCPU *cpu)define_arm_cp_regs (cpu, vhe_reginfo); } +#ifdef TARGET_AARCH64 if (cpu_isar_feature (aa64_sve, cpu)) {define_one_arm_cp_reg (cpu, &zcr_el1_reginfo);if (arm_feature (env,ARM_FEATURE_EL2 )) {
@@ -7585,7 +7592,6 @@ void register_cp_regs_for_features(ARMCPU *cpu) } } -#ifdef TARGET_AARCH64 if (cpu_isar_feature (aa64_pauth, cpu)) {define_arm_cp_regs (cpu, pauth_reginfo); }
@@ -7615,7 +7621,7 @@ void register_cp_regs_for_features(ARMCPU *cpu)define_arm_cp_regs (cpu, mte_tco_ro_reginfo); define_arm_cp_regs(cpu, mte_el0_cacheop_reginfo); } -#endif +#endif /* TARGET_AARCH64 */ if (cpu_isar_feature (any_predinv, cpu)) {define_arm_cp_regs (cpu, predinv_reginfo);
target/arm/tcg/helper-a64.c +1 -0
@@ -20,6 +20,7 @@#include "qemu/osdep.h" #include "qemu/units.h" #include "cpu.h" +#include "tcg/cpu-sve.h" #include "cpu-exceptions-aa64.h" #include "exec/gdbstub.h" #include "exec/helper-proto.h"
target/arm/tcg/helper.c +1 -0
@@ -16,6 +16,7 @@#include <zlib.h> /* For crc32 */ #include "arm_ldst.h" #include "cpu-mmu.h" +#include "tcg/cpu-sve.h" #include "cpregs.h" #include "tcg-cpu.h"
Signature · 1 line
2.26.2
RFC v11 51/55 target/arm: cpu-pauth: new module for ARMv8.3 Pointer Authentication
In reply to Claudio FontanaPointer Authentication is an AARCH64-only ARMv8.3 optional extension, whose cpu properties can be separated out in its own module.
--- target/arm/cpu.h | 13 +------- target/arm/tcg/cpu-pauth.h | 38 ++++++++++++++++++++++ target/arm/cpu.c | 3 +- target/arm/cpu64.c | 34 +------------------- target/arm/tcg/cpu-pauth.c | 66 ++++++++++++++++++++++++++++++++++++++ target/arm/tcg/meson.build | 1 + 6 files changed, 108 insertions(+), 47 deletions(-) create mode 100644 target/arm/tcg/cpu-pauth.h create mode 100644 target/arm/tcg/cpu-pauth.c
target/arm/cpu.h +1 -12
@@ -203,6 +203,7 @@ typedef struct {#ifdef TARGET_AARCH64 # define ARM_MAX_VQ 16# include "cpu-sve.h" +# include "tcg/cpu-pauth.h" #else # define ARM_MAX_VQ 1#endif /* TARGET_AARCH64 */
@@ -211,18 +212,6 @@ typedef struct ARMVectorReg { uint64_t d[2 * ARM_MAX_VQ] QEMU_ALIGNED(16); } ARMVectorReg; -/* ARMv8.3 Pointer Authentication Extension (AARCH64-only) */ - -#ifdef TARGET_AARCH64 -void arm_cpu_pauth_finalize (ARMCPU *cpu,Error **errp); -/* In AArch32 mode, PAC keys do not exist at all. */ -typedef struct ARMPACKey { -uint64_t lo, hi; -}ARMPACKey ; -#else -static inline void arm_cpu_pauth_finalize (ARMCPU *cpu,Error **errp) { } -#endif - typedef struct CPUARMState { /* Regs for current mode. */ uint32_t regs[16];
target/arm/tcg/cpu-pauth.h new file +38 -0
@@ -0,0 +1,38 @@ +/* +* QEMU AArch64 Pointer Authentication Extensions +* +* Copyright (c) 2013 Linaro Ltd +* +* 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 CPU_PAUTH_H +#define CPU_PAUTH_H + +/* ARMv8.3 pauth is an AARCH64 option, only include this for TARGET_AARCH64 */ + +/* called by arm_cpu_finalize_features in realizefn */ +bool cpu_pauth_finalize (ARMCPU *cpu,Error **errp); + +/* add the CPU Pointer Authentication properties */ +void cpu_pauth_add_props (Object *obj); + +/* Pointer Authentication Code Key */ + +typedef struct ARMPACKey { +uint64_t lo, hi; +}ARMPACKey ; + +#endif /* CPU_PAUTH_H */
target/arm/cpu.c +1 -2
@@ -832,8 +832,7 @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)* is in use, so the user will not be able to set them. */ if (tcg_enabled ()) { -arm_cpu_pauth_finalize (cpu, &local_err); -if (local_err !=NULL ) { +if (!cpu_pauth_finalize (cpu, &local_err)) {error_propagate (errp, local_err);return ; }
target/arm/cpu64.c +1 -33
@@ -245,36 +245,6 @@ static void aarch64_a72_initfn(Object *obj)define_arm_cp_regs (cpu, cortex_a72_a57_a53_cp_reginfo); } -void arm_cpu_pauth_finalize (ARMCPU *cpu,Error **errp) -{ -int arch_val =0 , impdef_val =0 ; -uint64_t t; - -/* TODO: Handle HaveEnhancedPAC, HaveEnhancedPAC2, HaveFPAC. */ -if (cpu->prop_pauth) { -if (cpu->prop_pauth_impdef) { - impdef_val =1 ; - }else { - arch_val =1 ; - } - }else if (cpu->prop_pauth_impdef) { -error_setg (errp,"cannot enable pauth-impdef without pauth" ); -error_append_hint (errp,"Add pauth=on to the CPU property list.\n" ); - } - - t = cpu->isar.id_aa64isar1; - t =FIELD_DP64 (t,ID_AA64ISAR1 ,APA , arch_val); - t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPA , arch_val); - t =FIELD_DP64 (t,ID_AA64ISAR1 ,API , impdef_val); - t =FIELD_DP64 (t,ID_AA64ISAR1 ,GPI , impdef_val); - cpu->isar.id_aa64isar1 = t; -} - -static Property arm_cpu_pauth_property = -DEFINE_PROP_BOOL ("pauth" ,ARMCPU , prop_pauth, true); -static Property arm_cpu_pauth_impdef_property = -DEFINE_PROP_BOOL ("pauth-impdef" ,ARMCPU , prop_pauth_impdef, false); -/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host); * otherwise, a CPU with as many features enabled as our emulation supports. * The version of '-cpu max' for qemu-system-arm is defined in cpu.c;
@@ -433,9 +403,7 @@ static void aarch64_max_initfn(Object *obj) cpu->dcz_blocksize =7 ;/* 512 bytes */ #endif -/* Default to PAUTH on, with the architected algorithm. */ -qdev_property_add_static (DEVICE (obj), &arm_cpu_pauth_property); -qdev_property_add_static (DEVICE (obj), &arm_cpu_pauth_impdef_property); +cpu_pauth_add_props (obj); }cpu_sve_add_props (obj);
target/arm/tcg/cpu-pauth.c new file +66 -0
66 lines not on this page · raw message
target/arm/tcg/meson.build +1 -0
@@ -40,6 +40,7 @@ arm_ss.add(when: ['TARGET_AARCH64', 'CONFIG_TCG'], if_true: files( 'pauth_helper.c', 'sve_helper.c', 'cpu-sve.c', + 'cpu-pauth.c', )) subdir('user')
Signature · 1 line
2.26.2
RFC v11 52/55 target/arm: refactor arm_cpu_finalize_features into cpu64
In reply to Claudio Fontanaall the features in arm_cpu_finalize_features are actually TARGET_AARCH64-only, since KVM is now only supported on 64bit.
Therefore move the function to cpu64, and rename it to aarch64_cpu_finalize_features.
--- target/arm/cpu.h | 3 +- target/arm/kvm/kvm_arm.h | 5 ++-- target/arm/cpu.c | 65 ++++++++++------------------------------ target/arm/cpu64.c | 25 ++++++++++++++++ target/arm/kvm/kvm64.c | 7 +++-- target/arm/monitor.c | 8 +++-- 6 files changed, 54 insertions(+), 59 deletions(-)
target/arm/cpu.h +1 -2
@@ -1036,6 +1036,7 @@ int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,#ifdef TARGET_AARCH64 int aarch64_cpu_gdb_read_register (CPUState *cpu,GByteArray *buf,int reg);int aarch64_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); +bool aarch64_cpu_finalize_features (ARMCPU *cpu,Error **errp);static inline bool is_a64 (CPUARMState *env) {
@@ -2096,8 +2097,6 @@ static inline int arm_feature(CPUARMState *env, int feature)return (env->features & (1ULL << feature)) !=0 ; } -void arm_cpu_finalize_features (ARMCPU *cpu,Error **errp); -#if !defined(CONFIG_USER_ONLY )/* Return true if exception levels below EL3 are in secure state, * or would be following an exception return to that level.
target/arm/kvm/kvm_arm.h +3 -2
@@ -275,7 +275,7 @@ void kvm_arm_add_vcpu_properties(Object *obj);* Validate the kvm-steal-time property selection and set its default * based on KVM support and guest configuration. */ -void kvm_arm_steal_time_finalize (ARMCPU *cpu,Error **errp); +bool kvm_arm_steal_time_finalize (ARMCPU *cpu,Error **errp);/** * kvm_arm_steal_time_supported:
@@ -436,9 +436,10 @@ static inline void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa)g_assert_not_reached (); } -static inline void kvm_arm_steal_time_finalize (ARMCPU *cpu,Error **errp) +static inline bool kvm_arm_steal_time_finalize (ARMCPU *cpu,Error **errp) {g_assert_not_reached (); +return false; }static inline void kvm_arm_sve_get_vls (CPUState *cs,unsigned long *map)
target/arm/cpu.c +15 -50
84 lines not on this page · raw message
target/arm/cpu64.c +25 -0
@@ -22,6 +22,8 @@#include "qapi/error.h" #include "qemu/qemu-print.h" #include "cpu.h" +#include "cpu-sve.h" +#include "tcg/cpu-pauth.h" #include "cpu-exceptions-aa64.h" #include "qemu/module.h" #include "sysemu/tcg.h"
@@ -454,6 +456,29 @@ static gchar *aarch64_gdb_arch_name(CPUState *cs)return g_strdup ("aarch64" ); } +bool aarch64_cpu_finalize_features (ARMCPU *cpu,Error **errp) +{ +if (!cpu_sve_finalize_features (cpu, errp)) { +return false; + } +if (tcg_enabled ()) { +/* +* KVM does not support modifications to this feature. +* We have not registered the cpu properties when KVM +* is in use, so the user will not be able to set them. +*/ +if (!cpu_pauth_finalize (cpu, errp)) { +return false; + } + } +if (kvm_enabled ()) { +if (!kvm_arm_steal_time_finalize (cpu, errp)) { +return false; + } + } +return true; +} +static void aarch64_cpu_dump_state (CPUState *cs,FILE *f,int flags) {ARMCPU *cpu =ARM_CPU (cs);
target/arm/kvm/kvm64.c +4 -3
@@ -677,7 +677,7 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)return true; } -void kvm_arm_steal_time_finalize (ARMCPU *cpu,Error **errp) +bool kvm_arm_steal_time_finalize (ARMCPU *cpu,Error **errp) {bool has_steal_time =kvm_arm_steal_time_supported ();
@@ -691,7 +691,7 @@ void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp)if (!has_steal_time) {error_setg (errp,"'kvm-steal-time' cannot be enabled " "on this host" ); -return ; +return false; }else if (!arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {/* * DEN0057A chapter 2 says "This specification only covers
@@ -702,9 +702,10 @@ void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp)*/ error_setg (errp,"'kvm-steal-time' cannot be enabled " "for AArch32 guests" ); -return ; +return false; } } +return true; }bool kvm_arm_aarch32_supported (void )
target/arm/monitor.c +6 -2
@@ -184,9 +184,11 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,if (!err) {visit_check_struct (visitor, &err); } +#ifdef TARGET_AARCH64 if (!err) { -arm_cpu_finalize_features (ARM_CPU (obj), &err); +aarch64_cpu_finalize_features (ARM_CPU (obj), &err); } +#endif /* TARGET_AARCH64 */ visit_end_struct (visitor,NULL );visit_free (visitor);if (err) {
@@ -195,7 +197,9 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,return NULL ; } }else { -arm_cpu_finalize_features (ARM_CPU (obj), &error_abort); +#ifdef TARGET_AARCH64 +aarch64_cpu_finalize_features (ARM_CPU (obj), &error_abort); +#endif /* TARGET_AARCH64 */ } expansion_info =g_new0 (CpuModelExpansionInfo,1 );
Signature · 1 line
2.26.2
RFC v11 53/55 XXX target/arm: experiment refactoring cpu "max"
In reply to Claudio FontanaXXX Someone who really understands which properties should be added where should review this attentively.
What goes into cpu leaf class initialization?
What goes into arm_post_init / accel_cpu?
What goes into arm_cpu_finalize_features / aarch64_cpu_finalize_features?
Should there be shift of more code into finalize_features?
--- target/arm/cpu.h | 3 + target/arm/cpu64.c | 167 ++--------------------- target/arm/kvm/kvm-cpu.c | 4 +- target/arm/tcg/tcg-cpu-models.c | 62 +-------- target/arm/tcg/tcg-cpu.c | 228 +++++++++++++++++++++++++++++++- 5 files changed, 242 insertions(+), 222 deletions(-)
target/arm/cpu.h +3 -0
@@ -997,6 +997,9 @@ struct ARMCPU {/* Generic timer counter frequency, in Hz */ uint64_t gt_cntfrq_hz; + +/* MAX features requested via cpu="max" */ +bool max_features; };unsigned int gt_cntfrq_period_ns (ARMCPU *cpu);
target/arm/cpu64.c +14 -153
183 lines not on this page · raw message
target/arm/kvm/kvm-cpu.c +1 -3
@@ -87,9 +87,7 @@ static void host_cpu_instance_init(Object *obj)ARMCPU *cpu =ARM_CPU (obj);kvm_arm_set_cpu_features_from_host (cpu); -if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { -cpu_sve_add_props (obj); - } +cpu_sve_add_props (obj);arm_cpu_post_init (obj); }
target/arm/tcg/tcg-cpu-models.c +1 -61
68 lines not on this page · raw message
target/arm/tcg/tcg-cpu.c +223 -5
239 lines not on this page · raw message
Signature · 1 line
2.26.2
RFC v11 54/55 target/arm: tcg: remove superfluous CONFIG_TCG check
In reply to Claudio Fontanamodules under tcg/ are only built for CONFIG_TCG anyway.
--- target/arm/tcg/vfp_helper.c | 6 ------ 1 file changed, 6 deletions(-)
target/arm/tcg/vfp_helper.c +0 -6
@@ -21,10 +21,8 @@#include "cpu.h" #include "exec/helper-proto.h" #include "internals.h" -#ifdef CONFIG_TCG #include "qemu/log.h" #include "fpu/softfloat.h" -#endif /* VFP support. We follow the convention used for VFP instructions: Single precision routines have a "s" suffix, double precision a
@@ -40,8 +38,6 @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)vfp_set_fpscr (env, val); } -#ifdef CONFIG_TCG -#define VFP_HELPER (name, p) HELPER(glue(glue(vfp_,name),p))#define VFP_BINOP (name) \
@@ -1110,5 +1106,3 @@ void HELPER(check_hcr_el2_trap)(CPUARMState *env, uint32_t rt, uint32_t reg)raise_exception (env,EXCP_HYP_TRAP , syndrome,2 ); } - -#endif
Signature · 1 line
2.26.2
RFC v11 55/55 target/arm: remove v7m stub function for !CONFIG_TCG
In reply to Claudio Fontanait is needed just once, so just move the CONFIG_TCG check in place.
--- target/arm/cpu-mmu.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
target/arm/cpu-mmu.c +2 -7
@@ -155,21 +155,16 @@ int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx) } } -#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; +#ifdef CONFIG_TCG if (arm_feature (env,ARM_FEATURE_M )) {return arm_v7m_mmu_idx_for_secstate (env, env->v7m.secure); } +#endif /* CONFIG_TCG */ /* See ARM pseudo-function ELIsInHost. */ switch (el) {
Signature · 1 line
2.26.2