1 | First arm pullreq of the 8.0 series... | 1 | The following changes since commit 003ba52a8b327180e284630b289c6ece5a3e08b9: |
---|---|---|---|
2 | 2 | ||
3 | The following changes since commit ae2b87341b5ddb0dcb1b3f2d4f586ef18de75873: | 3 | Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-02-16 11:16:39 +0000) |
4 | |||
5 | Merge tag 'pull-qapi-2022-12-14-v2' of https://repo.or.cz/qemu/armbru into staging (2022-12-14 22:42:14 +0000) | ||
6 | 4 | ||
7 | are available in the Git repository at: | 5 | are available in the Git repository at: |
8 | 6 | ||
9 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20221215 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230216 |
10 | 8 | ||
11 | for you to fetch changes up to 4f3ebdc33618e7c163f769047859d6f34373e3af: | 9 | for you to fetch changes up to caf01d6a435d9f4a95aeae2f9fc6cb8b889b1fb8: |
12 | 10 | ||
13 | target/arm: Restrict arm_cpu_exec_interrupt() to TCG accelerator (2022-12-15 11:18:20 +0000) | 11 | tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG (2023-02-16 16:28:53 +0000) |
14 | 12 | ||
15 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
16 | target-arm queue: | 14 | target-arm queue: |
17 | * hw/arm/virt: Add properties to allow more granular | 15 | * Some mostly M-profile-related code cleanups |
18 | configuration of use of highmem space | 16 | * avocado: Retire the boot_linux.py AArch64 TCG tests |
19 | * target/arm: Add Cortex-A55 CPU | 17 | * hw/arm/smmuv3: Add GBPA register |
20 | * hw/intc/arm_gicv3: Fix GICD_TYPER ITLinesNumber advertisement | 18 | * arm/virt: don't try to spell out the accelerator |
21 | * Implement FEAT_EVT | 19 | * hw/arm: Attach PSPI module to NPCM7XX SoC |
22 | * Some 3-phase-reset conversions for Arm GIC, SMMU | 20 | * Some cleanup/refactoring patches aiming towards |
23 | * hw/arm/boot: set initrd with #address-cells type in fdt | 21 | allowing building Arm targets without CONFIG_TCG |
24 | * align user-mode exposed ID registers with Linux | ||
25 | * hw/misc: Move some arm-related files from specific_ss into softmmu_ss | ||
26 | * Restrict arm_cpu_exec_interrupt() to TCG accelerator | ||
27 | 22 | ||
28 | ---------------------------------------------------------------- | 23 | ---------------------------------------------------------------- |
29 | Gavin Shan (7): | 24 | Alex Bennée (1): |
30 | hw/arm/virt: Introduce virt_set_high_memmap() helper | 25 | tests/avocado: retire the Aarch64 TCG tests from boot_linux.py |
31 | hw/arm/virt: Rename variable size to region_size in virt_set_high_memmap() | ||
32 | hw/arm/virt: Introduce variable region_base in virt_set_high_memmap() | ||
33 | hw/arm/virt: Introduce virt_get_high_memmap_enabled() helper | ||
34 | hw/arm/virt: Improve high memory region address assignment | ||
35 | hw/arm/virt: Add 'compact-highmem' property | ||
36 | hw/arm/virt: Add properties to disable high memory regions | ||
37 | 26 | ||
38 | Luke Starrett (1): | 27 | Claudio Fontana (3): |
39 | hw/intc/arm_gicv3: Fix GICD_TYPER ITLinesNumber advertisement | 28 | target/arm: rename handle_semihosting to tcg_handle_semihosting |
29 | target/arm: wrap psci call with tcg_enabled | ||
30 | target/arm: wrap call to aarch64_sve_change_el in tcg_enabled() | ||
40 | 31 | ||
41 | Mihai Carabas (1): | 32 | Cornelia Huck (1): |
42 | hw/arm/virt: build SMBIOS 19 table | 33 | arm/virt: don't try to spell out the accelerator |
43 | 34 | ||
44 | Peter Maydell (15): | 35 | Fabiano Rosas (7): |
45 | target/arm: Allow relevant HCR bits to be written for FEAT_EVT | 36 | target/arm: Move PC alignment check |
46 | target/arm: Implement HCR_EL2.TTLBIS traps | 37 | target/arm: Move cpregs code out of cpu.h |
47 | target/arm: Implement HCR_EL2.TTLBOS traps | 38 | tests/avocado: Skip tests that require a missing accelerator |
48 | target/arm: Implement HCR_EL2.TICAB,TOCU traps | 39 | tests/avocado: Tag TCG tests with accel:tcg |
49 | target/arm: Implement HCR_EL2.TID4 traps | 40 | target/arm: Use "max" as default cpu for the virt machine with KVM |
50 | target/arm: Report FEAT_EVT for TCG '-cpu max' | 41 | tests/qtest: arm-cpu-features: Match tests to required accelerators |
51 | hw/arm: Convert TYPE_ARM_SMMU to 3-phase reset | 42 | tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG |
52 | hw/arm: Convert TYPE_ARM_SMMUV3 to 3-phase reset | ||
53 | hw/intc: Convert TYPE_ARM_GIC_COMMON to 3-phase reset | ||
54 | hw/intc: Convert TYPE_ARM_GIC_KVM to 3-phase reset | ||
55 | hw/intc: Convert TYPE_ARM_GICV3_COMMON to 3-phase reset | ||
56 | hw/intc: Convert TYPE_KVM_ARM_GICV3 to 3-phase reset | ||
57 | hw/intc: Convert TYPE_ARM_GICV3_ITS_COMMON to 3-phase reset | ||
58 | hw/intc: Convert TYPE_ARM_GICV3_ITS to 3-phase reset | ||
59 | hw/intc: Convert TYPE_KVM_ARM_ITS to 3-phase reset | ||
60 | 43 | ||
61 | Philippe Mathieu-Daudé (1): | 44 | Hao Wu (3): |
62 | target/arm: Restrict arm_cpu_exec_interrupt() to TCG accelerator | 45 | MAINTAINERS: Add myself to maintainers and remove Havard |
46 | hw/ssi: Add Nuvoton PSPI Module | ||
47 | hw/arm: Attach PSPI module to NPCM7XX SoC | ||
63 | 48 | ||
64 | Schspa Shi (1): | 49 | Jean-Philippe Brucker (2): |
65 | hw/arm/boot: set initrd with #address-cells type in fdt | 50 | hw/arm/smmu-common: Support 64-bit addresses |
51 | hw/arm/smmu-common: Fix TTB1 handling | ||
66 | 52 | ||
67 | Thomas Huth (1): | 53 | Mostafa Saleh (1): |
68 | hw/misc: Move some arm-related files from specific_ss into softmmu_ss | 54 | hw/arm/smmuv3: Add GBPA register |
69 | 55 | ||
70 | Timofey Kutergin (1): | 56 | Philippe Mathieu-Daudé (12): |
71 | target/arm: Add Cortex-A55 CPU | 57 | hw/intc/armv7m_nvic: Use OBJECT_DECLARE_SIMPLE_TYPE() macro |
58 | target/arm: Simplify arm_v7m_mmu_idx_for_secstate() for user emulation | ||
59 | target/arm: Reduce arm_v7m_mmu_idx_[all/for_secstate_and_priv]() scope | ||
60 | target/arm: Constify ID_PFR1 on user emulation | ||
61 | target/arm: Convert CPUARMState::eabi to boolean | ||
62 | target/arm: Avoid resetting CPUARMState::eabi field | ||
63 | target/arm: Restrict CPUARMState::gicv3state to sysemu | ||
64 | target/arm: Restrict CPUARMState::arm_boot_info to sysemu | ||
65 | target/arm: Restrict CPUARMState::nvic to sysemu | ||
66 | target/arm: Store CPUARMState::nvic as NVICState* | ||
67 | target/arm: Declare CPU <-> NVIC helpers in 'hw/intc/armv7m_nvic.h' | ||
68 | hw/arm: Add missing XLNX_ZYNQMP_ARM -> USB_DWC3 Kconfig dependency | ||
72 | 69 | ||
73 | Zhuojia Shen (1): | 70 | MAINTAINERS | 8 +- |
74 | target/arm: align exposed ID registers with Linux | 71 | docs/system/arm/nuvoton.rst | 2 +- |
72 | hw/arm/smmuv3-internal.h | 7 + | ||
73 | include/hw/arm/npcm7xx.h | 2 + | ||
74 | include/hw/arm/smmu-common.h | 2 - | ||
75 | include/hw/arm/smmuv3.h | 1 + | ||
76 | include/hw/intc/armv7m_nvic.h | 128 +++++++++++++++++- | ||
77 | include/hw/ssi/npcm_pspi.h | 53 ++++++++ | ||
78 | linux-user/user-internals.h | 2 +- | ||
79 | target/arm/cpregs.h | 98 ++++++++++++++ | ||
80 | target/arm/cpu.h | 228 ++------------------------------- | ||
81 | target/arm/internals.h | 14 -- | ||
82 | hw/arm/npcm7xx.c | 25 +++- | ||
83 | hw/arm/smmu-common.c | 4 +- | ||
84 | hw/arm/smmuv3.c | 43 ++++++- | ||
85 | hw/arm/virt.c | 10 +- | ||
86 | hw/intc/armv7m_nvic.c | 38 ++---- | ||
87 | hw/ssi/npcm_pspi.c | 221 ++++++++++++++++++++++++++++++++ | ||
88 | linux-user/arm/cpu_loop.c | 4 +- | ||
89 | target/arm/cpu.c | 5 +- | ||
90 | target/arm/cpu_tcg.c | 3 + | ||
91 | target/arm/helper.c | 31 +++-- | ||
92 | target/arm/m_helper.c | 86 +++++++------ | ||
93 | target/arm/machine.c | 18 +-- | ||
94 | tests/qtest/arm-cpu-features.c | 28 ++-- | ||
95 | hw/arm/Kconfig | 1 + | ||
96 | hw/ssi/meson.build | 2 +- | ||
97 | hw/ssi/trace-events | 5 + | ||
98 | tests/avocado/avocado_qemu/__init__.py | 4 + | ||
99 | tests/avocado/boot_linux.py | 48 ++----- | ||
100 | tests/avocado/boot_linux_console.py | 1 + | ||
101 | tests/avocado/machine_aarch64_virt.py | 63 ++++++++- | ||
102 | tests/avocado/reverse_debugging.py | 8 ++ | ||
103 | tests/qtest/meson.build | 4 +- | ||
104 | 34 files changed, 798 insertions(+), 399 deletions(-) | ||
105 | create mode 100644 include/hw/ssi/npcm_pspi.h | ||
106 | create mode 100644 hw/ssi/npcm_pspi.c | ||
75 | 107 | ||
76 | docs/system/arm/emulation.rst | 1 + | ||
77 | docs/system/arm/virt.rst | 18 +++ | ||
78 | include/hw/arm/smmuv3.h | 2 +- | ||
79 | include/hw/arm/virt.h | 2 + | ||
80 | include/hw/misc/xlnx-zynqmp-apu-ctrl.h | 2 +- | ||
81 | target/arm/cpu.h | 30 +++++ | ||
82 | target/arm/kvm-consts.h | 8 +- | ||
83 | hw/arm/boot.c | 10 +- | ||
84 | hw/arm/smmu-common.c | 7 +- | ||
85 | hw/arm/smmuv3.c | 12 +- | ||
86 | hw/arm/virt.c | 202 +++++++++++++++++++++++----- | ||
87 | hw/intc/arm_gic_common.c | 7 +- | ||
88 | hw/intc/arm_gic_kvm.c | 14 +- | ||
89 | hw/intc/arm_gicv3_common.c | 7 +- | ||
90 | hw/intc/arm_gicv3_dist.c | 4 +- | ||
91 | hw/intc/arm_gicv3_its.c | 14 +- | ||
92 | hw/intc/arm_gicv3_its_common.c | 7 +- | ||
93 | hw/intc/arm_gicv3_its_kvm.c | 14 +- | ||
94 | hw/intc/arm_gicv3_kvm.c | 14 +- | ||
95 | hw/misc/imx6_src.c | 2 +- | ||
96 | hw/misc/iotkit-sysctl.c | 1 - | ||
97 | target/arm/cpu.c | 5 +- | ||
98 | target/arm/cpu64.c | 70 ++++++++++ | ||
99 | target/arm/cpu_tcg.c | 1 + | ||
100 | target/arm/helper.c | 231 ++++++++++++++++++++++++--------- | ||
101 | hw/misc/meson.build | 11 +- | ||
102 | 26 files changed, 538 insertions(+), 158 deletions(-) | ||
103 | diff view generated by jsdifflib |
1 | From: Mihai Carabas <mihai.carabas@oracle.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Use the base_memmap to build the SMBIOS 19 table which provides the address | 3 | Manually convert to OBJECT_DECLARE_SIMPLE_TYPE() macro, |
4 | mapping for a Physical Memory Array (from spec [1] chapter 7.20). | 4 | similarly to automatic conversion from commit 8063396bf3 |
5 | ("Use OBJECT_DECLARE_SIMPLE_TYPE when possible"). | ||
5 | 6 | ||
6 | This was present on i386 from commit c97294ec1b9e36887e119589d456557d72ab37b5 | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | ("SMBIOS: Build aggregate smbios tables and entry point"). | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | 9 | Message-id: 20230206223502.25122-2-philmd@linaro.org | |
9 | [1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.5.0.pdf | ||
10 | |||
11 | The absence of this table is a breach of the specs and is | ||
12 | detected by the FirmwareTestSuite (FWTS), but it doesn't | ||
13 | cause any known problems for guest OSes. | ||
14 | |||
15 | Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com> | ||
16 | Message-id: 1668789029-5432-1-git-send-email-mihai.carabas@oracle.com | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 11 | --- |
20 | hw/arm/virt.c | 8 +++++++- | 12 | include/hw/intc/armv7m_nvic.h | 5 +---- |
21 | 1 file changed, 7 insertions(+), 1 deletion(-) | 13 | 1 file changed, 1 insertion(+), 4 deletions(-) |
22 | 14 | ||
23 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 15 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h |
24 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/arm/virt.c | 17 | --- a/include/hw/intc/armv7m_nvic.h |
26 | +++ b/hw/arm/virt.c | 18 | +++ b/include/hw/intc/armv7m_nvic.h |
27 | @@ -XXX,XX +XXX,XX @@ static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size) | 19 | @@ -XXX,XX +XXX,XX @@ |
28 | static void virt_build_smbios(VirtMachineState *vms) | 20 | #include "qom/object.h" |
29 | { | 21 | |
30 | MachineClass *mc = MACHINE_GET_CLASS(vms); | 22 | #define TYPE_NVIC "armv7m_nvic" |
31 | + MachineState *ms = MACHINE(vms); | 23 | - |
32 | VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); | 24 | -typedef struct NVICState NVICState; |
33 | uint8_t *smbios_tables, *smbios_anchor; | 25 | -DECLARE_INSTANCE_CHECKER(NVICState, NVIC, |
34 | size_t smbios_tables_len, smbios_anchor_len; | 26 | - TYPE_NVIC) |
35 | + struct smbios_phys_mem_area mem_array; | 27 | +OBJECT_DECLARE_SIMPLE_TYPE(NVICState, NVIC) |
36 | const char *product = "QEMU Virtual Machine"; | 28 | |
37 | 29 | /* Highest permitted number of exceptions (architectural limit) */ | |
38 | if (kvm_enabled()) { | 30 | #define NVIC_MAX_VECTORS 512 |
39 | @@ -XXX,XX +XXX,XX @@ static void virt_build_smbios(VirtMachineState *vms) | ||
40 | vmc->smbios_old_sys_ver ? "1.0" : mc->name, false, | ||
41 | true, SMBIOS_ENTRY_POINT_TYPE_64); | ||
42 | |||
43 | - smbios_get_tables(MACHINE(vms), NULL, 0, | ||
44 | + /* build the array of physical mem area from base_memmap */ | ||
45 | + mem_array.address = vms->memmap[VIRT_MEM].base; | ||
46 | + mem_array.length = ms->ram_size; | ||
47 | + | ||
48 | + smbios_get_tables(ms, &mem_array, 1, | ||
49 | &smbios_tables, &smbios_tables_len, | ||
50 | &smbios_anchor, &smbios_anchor_len, | ||
51 | &error_fatal); | ||
52 | -- | 31 | -- |
53 | 2.25.1 | 32 | 2.34.1 |
33 | |||
34 | diff view generated by jsdifflib |
1 | Convert the TYPE_ARM_GICV3_ITS device to 3-phase reset. | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20230206223502.25122-3-philmd@linaro.org | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Message-id: 20221109161444.3397405-9-peter.maydell@linaro.org | ||
7 | --- | 8 | --- |
8 | hw/intc/arm_gicv3_its.c | 14 +++++++++----- | 9 | target/arm/m_helper.c | 11 ++++++++--- |
9 | 1 file changed, 9 insertions(+), 5 deletions(-) | 10 | 1 file changed, 8 insertions(+), 3 deletions(-) |
10 | 11 | ||
11 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | 12 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/intc/arm_gicv3_its.c | 14 | --- a/target/arm/m_helper.c |
14 | +++ b/hw/intc/arm_gicv3_its.c | 15 | +++ b/target/arm/m_helper.c |
15 | @@ -XXX,XX +XXX,XX @@ DECLARE_OBJ_CHECKERS(GICv3ITSState, GICv3ITSClass, | 16 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) |
16 | 17 | return 0; | |
17 | struct GICv3ITSClass { | 18 | } |
18 | GICv3ITSCommonClass parent_class; | 19 | |
19 | - void (*parent_reset)(DeviceState *dev); | 20 | -#else |
20 | + ResettablePhases parent_phases; | 21 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) |
21 | }; | 22 | +{ |
23 | + return ARMMMUIdx_MUser; | ||
24 | +} | ||
25 | + | ||
26 | +#else /* !CONFIG_USER_ONLY */ | ||
22 | 27 | ||
23 | /* | 28 | /* |
24 | @@ -XXX,XX +XXX,XX @@ static void gicv3_arm_its_realize(DeviceState *dev, Error **errp) | 29 | * What kind of stack write are we doing? This affects how exceptions |
25 | } | 30 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) |
31 | return tt_resp; | ||
26 | } | 32 | } |
27 | 33 | ||
28 | -static void gicv3_its_reset(DeviceState *dev) | 34 | -#endif /* !CONFIG_USER_ONLY */ |
29 | +static void gicv3_its_reset_hold(Object *obj) | 35 | - |
36 | ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | ||
37 | bool secstate, bool priv, bool negpri) | ||
30 | { | 38 | { |
31 | - GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev); | 39 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) |
32 | + GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj); | 40 | |
33 | GICv3ITSClass *c = ARM_GICV3_ITS_GET_CLASS(s); | 41 | return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); |
34 | |||
35 | - c->parent_reset(dev); | ||
36 | + if (c->parent_phases.hold) { | ||
37 | + c->parent_phases.hold(obj); | ||
38 | + } | ||
39 | |||
40 | /* Quiescent bit reset to 1 */ | ||
41 | s->ctlr = FIELD_DP32(s->ctlr, GITS_CTLR, QUIESCENT, 1); | ||
42 | @@ -XXX,XX +XXX,XX @@ static Property gicv3_its_props[] = { | ||
43 | static void gicv3_its_class_init(ObjectClass *klass, void *data) | ||
44 | { | ||
45 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
46 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
47 | GICv3ITSClass *ic = ARM_GICV3_ITS_CLASS(klass); | ||
48 | GICv3ITSCommonClass *icc = ARM_GICV3_ITS_COMMON_CLASS(klass); | ||
49 | |||
50 | dc->realize = gicv3_arm_its_realize; | ||
51 | device_class_set_props(dc, gicv3_its_props); | ||
52 | - device_class_set_parent_reset(dc, gicv3_its_reset, &ic->parent_reset); | ||
53 | + resettable_class_set_parent_phases(rc, NULL, gicv3_its_reset_hold, NULL, | ||
54 | + &ic->parent_phases); | ||
55 | icc->post_load = gicv3_its_post_load; | ||
56 | } | 42 | } |
57 | 43 | + | |
44 | +#endif /* !CONFIG_USER_ONLY */ | ||
58 | -- | 45 | -- |
59 | 2.25.1 | 46 | 2.34.1 |
60 | 47 | ||
61 | 48 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | After the improvement to high memory region address assignment is | 3 | arm_v7m_mmu_idx_all() and arm_v7m_mmu_idx_for_secstate_and_priv() |
4 | applied, the memory layout can be changed, introducing possible | 4 | are only used for system emulation in m_helper.c. |
5 | migration breakage. For example, VIRT_HIGH_PCIE_MMIO memory region | 5 | Move the definitions to avoid prototype forward declarations. |
6 | is disabled or enabled when the optimization is applied or not, with | ||
7 | the following configuration. The configuration is only achievable by | ||
8 | modifying the source code until more properties are added to allow | ||
9 | users selectively disable those high memory regions. | ||
10 | 6 | ||
11 | pa_bits = 40; | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
12 | vms->highmem_redists = false; | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | vms->highmem_ecam = false; | 9 | Message-id: 20230206223502.25122-4-philmd@linaro.org |
14 | vms->highmem_mmio = true; | ||
15 | |||
16 | # qemu-system-aarch64 -accel kvm -cpu host \ | ||
17 | -machine virt-7.2,compact-highmem={on, off} \ | ||
18 | -m 4G,maxmem=511G -monitor stdio | ||
19 | |||
20 | Region compact-highmem=off compact-highmem=on | ||
21 | ---------------------------------------------------------------- | ||
22 | MEM [1GB 512GB] [1GB 512GB] | ||
23 | HIGH_GIC_REDISTS2 [512GB 512GB+64MB] [disabled] | ||
24 | HIGH_PCIE_ECAM [512GB+256MB 512GB+512MB] [disabled] | ||
25 | HIGH_PCIE_MMIO [disabled] [512GB 1TB] | ||
26 | |||
27 | In order to keep backwords compatibility, we need to disable the | ||
28 | optimization on machine, which is virt-7.1 or ealier than it. It | ||
29 | means the optimization is enabled by default from virt-7.2. Besides, | ||
30 | 'compact-highmem' property is added so that the optimization can be | ||
31 | explicitly enabled or disabled on all machine types by users. | ||
32 | |||
33 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
34 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
35 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
36 | Reviewed-by: Marc Zyngier <maz@kernel.org> | ||
37 | Tested-by: Zhenyu Zhang <zhenyzha@redhat.com> | ||
38 | Message-id: 20221029224307.138822-7-gshan@redhat.com | ||
39 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
40 | --- | 11 | --- |
41 | docs/system/arm/virt.rst | 4 ++++ | 12 | target/arm/internals.h | 14 -------- |
42 | include/hw/arm/virt.h | 1 + | 13 | target/arm/m_helper.c | 74 +++++++++++++++++++++--------------------- |
43 | hw/arm/virt.c | 32 ++++++++++++++++++++++++++++++++ | 14 | 2 files changed, 37 insertions(+), 51 deletions(-) |
44 | 3 files changed, 37 insertions(+) | ||
45 | 15 | ||
46 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst | 16 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
47 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/docs/system/arm/virt.rst | 18 | --- a/target/arm/internals.h |
49 | +++ b/docs/system/arm/virt.rst | 19 | +++ b/target/arm/internals.h |
50 | @@ -XXX,XX +XXX,XX @@ highmem | 20 | @@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx core_to_aa64_mmu_idx(int mmu_idx) |
51 | address space above 32 bits. The default is ``on`` for machine types | 21 | |
52 | later than ``virt-2.12``. | 22 | int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx); |
53 | 23 | ||
54 | +compact-highmem | 24 | -/* |
55 | + Set ``on``/``off`` to enable/disable the compact layout for high memory regions. | 25 | - * Return the MMU index for a v7M CPU with all relevant information |
56 | + The default is ``on`` for machine types later than ``virt-7.2``. | 26 | - * manually specified. |
27 | - */ | ||
28 | -ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | ||
29 | - bool secstate, bool priv, bool negpri); | ||
30 | - | ||
31 | -/* | ||
32 | - * Return the MMU index for a v7M CPU in the specified security and | ||
33 | - * privilege state. | ||
34 | - */ | ||
35 | -ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
36 | - bool secstate, bool priv); | ||
37 | - | ||
38 | /* Return the MMU index for a v7M CPU in the specified security state */ | ||
39 | ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate); | ||
40 | |||
41 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/m_helper.c | ||
44 | +++ b/target/arm/m_helper.c | ||
45 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | ||
46 | |||
47 | #else /* !CONFIG_USER_ONLY */ | ||
48 | |||
49 | +static ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | ||
50 | + bool secstate, bool priv, bool negpri) | ||
51 | +{ | ||
52 | + ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; | ||
57 | + | 53 | + |
58 | gic-version | 54 | + if (priv) { |
59 | Specify the version of the Generic Interrupt Controller (GIC) to provide. | 55 | + mmu_idx |= ARM_MMU_IDX_M_PRIV; |
60 | Valid values are: | 56 | + } |
61 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/include/hw/arm/virt.h | ||
64 | +++ b/include/hw/arm/virt.h | ||
65 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineClass { | ||
66 | bool no_pmu; | ||
67 | bool claim_edge_triggered_timers; | ||
68 | bool smbios_old_sys_ver; | ||
69 | + bool no_highmem_compact; | ||
70 | bool no_highmem_ecam; | ||
71 | bool no_ged; /* Machines < 4.2 have no support for ACPI GED device */ | ||
72 | bool kvm_no_adjvtime; | ||
73 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/hw/arm/virt.c | ||
76 | +++ b/hw/arm/virt.c | ||
77 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry base_memmap[] = { | ||
78 | * Note the extended_memmap is sized so that it eventually also includes the | ||
79 | * base_memmap entries (VIRT_HIGH_GIC_REDIST2 index is greater than the last | ||
80 | * index of base_memmap). | ||
81 | + * | ||
82 | + * The memory map for these Highmem IO Regions can be in legacy or compact | ||
83 | + * layout, depending on 'compact-highmem' property. With legacy layout, the | ||
84 | + * PA space for one specific region is always reserved, even if the region | ||
85 | + * has been disabled or doesn't fit into the PA space. However, the PA space | ||
86 | + * for the region won't be reserved in these circumstances with compact layout. | ||
87 | */ | ||
88 | static MemMapEntry extended_memmap[] = { | ||
89 | /* Additional 64 MB redist region (can contain up to 512 redistributors) */ | ||
90 | @@ -XXX,XX +XXX,XX @@ static void virt_set_highmem(Object *obj, bool value, Error **errp) | ||
91 | vms->highmem = value; | ||
92 | } | ||
93 | |||
94 | +static bool virt_get_compact_highmem(Object *obj, Error **errp) | ||
95 | +{ | ||
96 | + VirtMachineState *vms = VIRT_MACHINE(obj); | ||
97 | + | 57 | + |
98 | + return vms->highmem_compact; | 58 | + if (negpri) { |
59 | + mmu_idx |= ARM_MMU_IDX_M_NEGPRI; | ||
60 | + } | ||
61 | + | ||
62 | + if (secstate) { | ||
63 | + mmu_idx |= ARM_MMU_IDX_M_S; | ||
64 | + } | ||
65 | + | ||
66 | + return mmu_idx; | ||
99 | +} | 67 | +} |
100 | + | 68 | + |
101 | +static void virt_set_compact_highmem(Object *obj, bool value, Error **errp) | 69 | +static ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, |
70 | + bool secstate, bool priv) | ||
102 | +{ | 71 | +{ |
103 | + VirtMachineState *vms = VIRT_MACHINE(obj); | 72 | + bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate); |
104 | + | 73 | + |
105 | + vms->highmem_compact = value; | 74 | + return arm_v7m_mmu_idx_all(env, secstate, priv, negpri); |
106 | +} | 75 | +} |
107 | + | 76 | + |
108 | static bool virt_get_its(Object *obj, Error **errp) | 77 | +/* Return the MMU index for a v7M CPU in the specified security state */ |
109 | { | 78 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) |
110 | VirtMachineState *vms = VIRT_MACHINE(obj); | 79 | +{ |
111 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data) | 80 | + bool priv = arm_v7m_is_handler_mode(env) || |
112 | "Set on/off to enable/disable using " | 81 | + !(env->v7m.control[secstate] & 1); |
113 | "physical address space above 32 bits"); | ||
114 | |||
115 | + object_class_property_add_bool(oc, "compact-highmem", | ||
116 | + virt_get_compact_highmem, | ||
117 | + virt_set_compact_highmem); | ||
118 | + object_class_property_set_description(oc, "compact-highmem", | ||
119 | + "Set on/off to enable/disable compact " | ||
120 | + "layout for high memory regions"); | ||
121 | + | 82 | + |
122 | object_class_property_add_str(oc, "gic-version", virt_get_gic_version, | 83 | + return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); |
123 | virt_set_gic_version); | 84 | +} |
124 | object_class_property_set_description(oc, "gic-version", | ||
125 | @@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj) | ||
126 | |||
127 | /* High memory is enabled by default */ | ||
128 | vms->highmem = true; | ||
129 | + vms->highmem_compact = !vmc->no_highmem_compact; | ||
130 | vms->gic_version = VIRT_GIC_VERSION_NOSEL; | ||
131 | |||
132 | vms->highmem_ecam = !vmc->no_highmem_ecam; | ||
133 | @@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(7, 2) | ||
134 | |||
135 | static void virt_machine_7_1_options(MachineClass *mc) | ||
136 | { | ||
137 | + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); | ||
138 | + | 85 | + |
139 | virt_machine_7_2_options(mc); | 86 | /* |
140 | compat_props_add(mc->compat_props, hw_compat_7_1, hw_compat_7_1_len); | 87 | * What kind of stack write are we doing? This affects how exceptions |
141 | + /* Compact layout for high memory regions was introduced with 7.2 */ | 88 | * generated during the stacking are treated. |
142 | + vmc->no_highmem_compact = true; | 89 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) |
90 | return tt_resp; | ||
143 | } | 91 | } |
144 | DEFINE_VIRT_MACHINE(7, 1) | 92 | |
145 | 93 | -ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | |
94 | - bool secstate, bool priv, bool negpri) | ||
95 | -{ | ||
96 | - ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; | ||
97 | - | ||
98 | - if (priv) { | ||
99 | - mmu_idx |= ARM_MMU_IDX_M_PRIV; | ||
100 | - } | ||
101 | - | ||
102 | - if (negpri) { | ||
103 | - mmu_idx |= ARM_MMU_IDX_M_NEGPRI; | ||
104 | - } | ||
105 | - | ||
106 | - if (secstate) { | ||
107 | - mmu_idx |= ARM_MMU_IDX_M_S; | ||
108 | - } | ||
109 | - | ||
110 | - return mmu_idx; | ||
111 | -} | ||
112 | - | ||
113 | -ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | ||
114 | - bool secstate, bool priv) | ||
115 | -{ | ||
116 | - bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate); | ||
117 | - | ||
118 | - return arm_v7m_mmu_idx_all(env, secstate, priv, negpri); | ||
119 | -} | ||
120 | - | ||
121 | -/* Return the MMU index for a v7M CPU in the specified security state */ | ||
122 | -ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | ||
123 | -{ | ||
124 | - bool priv = arm_v7m_is_handler_mode(env) || | ||
125 | - !(env->v7m.control[secstate] & 1); | ||
126 | - | ||
127 | - return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); | ||
128 | -} | ||
129 | - | ||
130 | #endif /* !CONFIG_USER_ONLY */ | ||
146 | -- | 131 | -- |
147 | 2.25.1 | 132 | 2.34.1 |
133 | |||
134 | diff view generated by jsdifflib |
1 | For FEAT_EVT, the HCR_EL2.TTLBOS bit allows trapping on EL1 | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | use of TLB maintenance instructions that operate on the | ||
3 | outer shareable domain: | ||
4 | 2 | ||
5 | TLBI VMALLE1OS, TLBI VAE1OS, TLBI ASIDE1OS,TLBI VAAE1OS, | 3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | TLBI VALE1OS, TLBI VAALE1OS, TLBI RVAE1OS, TLBI RVAAE1OS, | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | TLBI RVALE1OS, and TLBI RVAALE1OS. | 5 | Message-id: 20230206223502.25122-5-philmd@linaro.org |
8 | |||
9 | (There are no AArch32 outer-shareable TLB maintenance ops.) | ||
10 | |||
11 | Implement the trapping. | ||
12 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | --- | 7 | --- |
16 | target/arm/helper.c | 33 +++++++++++++++++++++++---------- | 8 | target/arm/helper.c | 12 ++++++++++-- |
17 | 1 file changed, 23 insertions(+), 10 deletions(-) | 9 | 1 file changed, 10 insertions(+), 2 deletions(-) |
18 | 10 | ||
19 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 11 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
20 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.c | 13 | --- a/target/arm/helper.c |
22 | +++ b/target/arm/helper.c | 14 | +++ b/target/arm/helper.c |
23 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_ttlbis(CPUARMState *env, const ARMCPRegInfo *ri, | 15 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) |
24 | return CP_ACCESS_OK; | 16 | } |
25 | } | 17 | } |
26 | 18 | ||
27 | +#ifdef TARGET_AARCH64 | 19 | +#ifndef CONFIG_USER_ONLY |
28 | +/* Check for traps from EL1 due to HCR_EL2.TTLB or TTLBOS. */ | 20 | /* |
29 | +static CPAccessResult access_ttlbos(CPUARMState *env, const ARMCPRegInfo *ri, | 21 | * We don't know until after realize whether there's a GICv3 |
30 | + bool isread) | 22 | * attached, and that is what registers the gicv3 sysregs. |
31 | +{ | 23 | @@ -XXX,XX +XXX,XX @@ static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri) |
32 | + if (arm_current_el(env) == 1 && | 24 | return pfr1; |
33 | + (arm_hcr_el2_eff(env) & (HCR_TTLB | HCR_TTLBOS))) { | 25 | } |
34 | + return CP_ACCESS_TRAP_EL2; | 26 | |
35 | + } | 27 | -#ifndef CONFIG_USER_ONLY |
36 | + return CP_ACCESS_OK; | 28 | static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) |
37 | +} | ||
38 | +#endif | ||
39 | + | ||
40 | static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
41 | { | 29 | { |
42 | ARMCPU *cpu = env_archcpu(env); | 30 | ARMCPU *cpu = env_archcpu(env); |
43 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { | 31 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
44 | .writefn = tlbi_aa64_rvae1is_write }, | 32 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 1, |
45 | { .name = "TLBI_RVAE1OS", .state = ARM_CP_STATE_AA64, | 33 | .access = PL1_R, .type = ARM_CP_NO_RAW, |
46 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 1, | 34 | .accessfn = access_aa32_tid3, |
47 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | 35 | +#ifdef CONFIG_USER_ONLY |
48 | + .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | 36 | + .type = ARM_CP_CONST, |
49 | .writefn = tlbi_aa64_rvae1is_write }, | 37 | + .resetvalue = cpu->isar.id_pfr1, |
50 | { .name = "TLBI_RVAAE1OS", .state = ARM_CP_STATE_AA64, | 38 | +#else |
51 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 3, | 39 | + .type = ARM_CP_NO_RAW, |
52 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | 40 | + .accessfn = access_aa32_tid3, |
53 | + .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | 41 | .readfn = id_pfr1_read, |
54 | .writefn = tlbi_aa64_rvae1is_write }, | 42 | - .writefn = arm_cp_write_ignore }, |
55 | { .name = "TLBI_RVALE1OS", .state = ARM_CP_STATE_AA64, | 43 | + .writefn = arm_cp_write_ignore |
56 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 5, | 44 | +#endif |
57 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | 45 | + }, |
58 | + .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | 46 | { .name = "ID_DFR0", .state = ARM_CP_STATE_BOTH, |
59 | .writefn = tlbi_aa64_rvae1is_write }, | 47 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 2, |
60 | { .name = "TLBI_RVAALE1OS", .state = ARM_CP_STATE_AA64, | 48 | .access = PL1_R, .type = ARM_CP_CONST, |
61 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 7, | ||
62 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
63 | + .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
64 | .writefn = tlbi_aa64_rvae1is_write }, | ||
65 | { .name = "TLBI_RVAE1", .state = ARM_CP_STATE_AA64, | ||
66 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 1, | ||
67 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
68 | static const ARMCPRegInfo tlbios_reginfo[] = { | ||
69 | { .name = "TLBI_VMALLE1OS", .state = ARM_CP_STATE_AA64, | ||
70 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 0, | ||
71 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
72 | + .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
73 | .writefn = tlbi_aa64_vmalle1is_write }, | ||
74 | { .name = "TLBI_VAE1OS", .state = ARM_CP_STATE_AA64, | ||
75 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 1, | ||
76 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
77 | + .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
78 | .writefn = tlbi_aa64_vae1is_write }, | ||
79 | { .name = "TLBI_ASIDE1OS", .state = ARM_CP_STATE_AA64, | ||
80 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 2, | ||
81 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
82 | + .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
83 | .writefn = tlbi_aa64_vmalle1is_write }, | ||
84 | { .name = "TLBI_VAAE1OS", .state = ARM_CP_STATE_AA64, | ||
85 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 3, | ||
86 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
87 | + .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
88 | .writefn = tlbi_aa64_vae1is_write }, | ||
89 | { .name = "TLBI_VALE1OS", .state = ARM_CP_STATE_AA64, | ||
90 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 5, | ||
91 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
92 | + .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
93 | .writefn = tlbi_aa64_vae1is_write }, | ||
94 | { .name = "TLBI_VAALE1OS", .state = ARM_CP_STATE_AA64, | ||
95 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 7, | ||
96 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
97 | + .access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW, | ||
98 | .writefn = tlbi_aa64_vae1is_write }, | ||
99 | { .name = "TLBI_ALLE2OS", .state = ARM_CP_STATE_AA64, | ||
100 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 0, | ||
101 | -- | 49 | -- |
102 | 2.25.1 | 50 | 2.34.1 |
51 | |||
52 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This introduces variable 'region_base' for the base address of the | 3 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> |
4 | specific high memory region. It's the preparatory work to optimize | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | high memory region address assignment. | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | 6 | Message-id: 20230206223502.25122-6-philmd@linaro.org | |
7 | No functional change intended. | ||
8 | |||
9 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
12 | Reviewed-by: Marc Zyngier <maz@kernel.org> | ||
13 | Tested-by: Zhenyu Zhang <zhenyzha@redhat.com> | ||
14 | Message-id: 20221029224307.138822-4-gshan@redhat.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 8 | --- |
17 | hw/arm/virt.c | 12 ++++++------ | 9 | linux-user/user-internals.h | 2 +- |
18 | 1 file changed, 6 insertions(+), 6 deletions(-) | 10 | target/arm/cpu.h | 2 +- |
11 | linux-user/arm/cpu_loop.c | 4 ++-- | ||
12 | 3 files changed, 4 insertions(+), 4 deletions(-) | ||
19 | 13 | ||
20 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 14 | diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h |
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/virt.c | 16 | --- a/linux-user/user-internals.h |
23 | +++ b/hw/arm/virt.c | 17 | +++ b/linux-user/user-internals.h |
24 | @@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) | 18 | @@ -XXX,XX +XXX,XX @@ void print_termios(void *arg); |
25 | static void virt_set_high_memmap(VirtMachineState *vms, | 19 | #ifdef TARGET_ARM |
26 | hwaddr base, int pa_bits) | 20 | static inline int regpairs_aligned(CPUArchState *cpu_env, int num) |
27 | { | 21 | { |
28 | - hwaddr region_size; | 22 | - return cpu_env->eabi == 1; |
29 | + hwaddr region_base, region_size; | 23 | + return cpu_env->eabi; |
30 | bool fits; | 24 | } |
31 | int i; | 25 | #elif defined(TARGET_MIPS) && defined(TARGET_ABI_MIPSO32) |
32 | 26 | static inline int regpairs_aligned(CPUArchState *cpu_env, int num) { return 1; } | |
33 | for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) { | 27 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
34 | + region_base = ROUND_UP(base, extended_memmap[i].size); | 28 | index XXXXXXX..XXXXXXX 100644 |
35 | region_size = extended_memmap[i].size; | 29 | --- a/target/arm/cpu.h |
36 | 30 | +++ b/target/arm/cpu.h | |
37 | - base = ROUND_UP(base, region_size); | 31 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
38 | - vms->memmap[i].base = base; | 32 | |
39 | + vms->memmap[i].base = region_base; | 33 | #if defined(CONFIG_USER_ONLY) |
40 | vms->memmap[i].size = region_size; | 34 | /* For usermode syscall translation. */ |
41 | 35 | - int eabi; | |
42 | /* | 36 | + bool eabi; |
43 | @@ -XXX,XX +XXX,XX @@ static void virt_set_high_memmap(VirtMachineState *vms, | 37 | #endif |
44 | * | 38 | |
45 | * For each device that doesn't fit, disable it. | 39 | struct CPUBreakpoint *cpu_breakpoint[16]; |
46 | */ | 40 | diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c |
47 | - fits = (base + region_size) <= BIT_ULL(pa_bits); | 41 | index XXXXXXX..XXXXXXX 100644 |
48 | + fits = (region_base + region_size) <= BIT_ULL(pa_bits); | 42 | --- a/linux-user/arm/cpu_loop.c |
49 | if (fits) { | 43 | +++ b/linux-user/arm/cpu_loop.c |
50 | - vms->highest_gpa = base + region_size - 1; | 44 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) |
51 | + vms->highest_gpa = region_base + region_size - 1; | ||
52 | } | ||
53 | |||
54 | switch (i) { | ||
55 | @@ -XXX,XX +XXX,XX @@ static void virt_set_high_memmap(VirtMachineState *vms, | ||
56 | break; | 45 | break; |
57 | } | 46 | case EXCP_SWI: |
58 | 47 | { | |
59 | - base += region_size; | 48 | - env->eabi = 1; |
60 | + base = region_base + region_size; | 49 | + env->eabi = true; |
61 | } | 50 | /* system call */ |
62 | } | 51 | if (env->thumb) { |
52 | /* Thumb is always EABI style with syscall number in r7 */ | ||
53 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) | ||
54 | * > 0xfffff and are handled below as out-of-range. | ||
55 | */ | ||
56 | n ^= ARM_SYSCALL_BASE; | ||
57 | - env->eabi = 0; | ||
58 | + env->eabi = false; | ||
59 | } | ||
60 | } | ||
63 | 61 | ||
64 | -- | 62 | -- |
65 | 2.25.1 | 63 | 2.34.1 |
64 | |||
65 | diff view generated by jsdifflib |
1 | From: Thomas Huth <thuth@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The header target/arm/kvm-consts.h checks CONFIG_KVM which is marked as | 3 | Although the 'eabi' field is only used in user emulation where |
4 | poisoned in common code, so the files that include this header have to | 4 | CPU reset doesn't occur, it doesn't belong to the area to reset. |
5 | be added to specific_ss and recompiled for each, qemu-system-arm and | 5 | Move it after the 'end_reset_fields' for consistency. |
6 | qemu-system-aarch64. However, since the kvm headers are only optionally | ||
7 | used in kvm-constants.h for some sanity checks, we can additionally | ||
8 | check the NEED_CPU_H macro first to avoid the poisoned CONFIG_KVM macro, | ||
9 | so kvm-constants.h can also be used from "common" files (without the | ||
10 | sanity checks - which should be OK since they are still done from other | ||
11 | target-specific files instead). This way, and by adjusting some other | ||
12 | include statements in the related files here and there, we can move some | ||
13 | files from specific_ss into softmmu_ss, so that they only need to be | ||
14 | compiled once during the build process. | ||
15 | 6 | ||
16 | Signed-off-by: Thomas Huth <thuth@redhat.com> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
18 | Message-id: 20221202154023.293614-1-thuth@redhat.com | 9 | Message-id: 20230206223502.25122-7-philmd@linaro.org |
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | --- | 11 | --- |
21 | include/hw/misc/xlnx-zynqmp-apu-ctrl.h | 2 +- | 12 | target/arm/cpu.h | 9 ++++----- |
22 | target/arm/kvm-consts.h | 8 ++++---- | 13 | 1 file changed, 4 insertions(+), 5 deletions(-) |
23 | hw/misc/imx6_src.c | 2 +- | ||
24 | hw/misc/iotkit-sysctl.c | 1 - | ||
25 | hw/misc/meson.build | 11 +++++------ | ||
26 | 5 files changed, 11 insertions(+), 13 deletions(-) | ||
27 | 14 | ||
28 | diff --git a/include/hw/misc/xlnx-zynqmp-apu-ctrl.h b/include/hw/misc/xlnx-zynqmp-apu-ctrl.h | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
29 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/include/hw/misc/xlnx-zynqmp-apu-ctrl.h | 17 | --- a/target/arm/cpu.h |
31 | +++ b/include/hw/misc/xlnx-zynqmp-apu-ctrl.h | 18 | +++ b/target/arm/cpu.h |
32 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
33 | 20 | ARMVectorReg zarray[ARM_MAX_VQ * 16]; | |
34 | #include "hw/sysbus.h" | 21 | #endif |
35 | #include "hw/register.h" | 22 | |
36 | -#include "target/arm/cpu.h" | 23 | -#if defined(CONFIG_USER_ONLY) |
37 | +#include "target/arm/cpu-qom.h" | 24 | - /* For usermode syscall translation. */ |
38 | 25 | - bool eabi; | |
39 | #define TYPE_XLNX_ZYNQMP_APU_CTRL "xlnx.apu-ctrl" | 26 | -#endif |
40 | OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPAPUCtrl, XLNX_ZYNQMP_APU_CTRL) | ||
41 | diff --git a/target/arm/kvm-consts.h b/target/arm/kvm-consts.h | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/kvm-consts.h | ||
44 | +++ b/target/arm/kvm-consts.h | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | #ifndef ARM_KVM_CONSTS_H | ||
47 | #define ARM_KVM_CONSTS_H | ||
48 | |||
49 | +#ifdef NEED_CPU_H | ||
50 | #ifdef CONFIG_KVM | ||
51 | #include <linux/kvm.h> | ||
52 | #include <linux/psci.h> | ||
53 | - | 27 | - |
54 | #define MISMATCH_CHECK(X, Y) QEMU_BUILD_BUG_ON(X != Y) | 28 | struct CPUBreakpoint *cpu_breakpoint[16]; |
55 | +#endif | 29 | struct CPUWatchpoint *cpu_watchpoint[16]; |
56 | +#endif | 30 | |
57 | 31 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | |
58 | -#else | 32 | const struct arm_boot_info *boot_info; |
59 | - | 33 | /* Store GICv3CPUState to access from this struct */ |
60 | +#ifndef MISMATCH_CHECK | 34 | void *gicv3state; |
61 | #define MISMATCH_CHECK(X, Y) QEMU_BUILD_BUG_ON(0) | 35 | +#if defined(CONFIG_USER_ONLY) |
62 | - | 36 | + /* For usermode syscall translation. */ |
63 | #endif | 37 | + bool eabi; |
64 | 38 | +#endif /* CONFIG_USER_ONLY */ | |
65 | #define CP_REG_SIZE_SHIFT 52 | 39 | |
66 | diff --git a/hw/misc/imx6_src.c b/hw/misc/imx6_src.c | 40 | #ifdef TARGET_TAGGED_ADDRESSES |
67 | index XXXXXXX..XXXXXXX 100644 | 41 | /* Linux syscall tagged address support */ |
68 | --- a/hw/misc/imx6_src.c | ||
69 | +++ b/hw/misc/imx6_src.c | ||
70 | @@ -XXX,XX +XXX,XX @@ | ||
71 | #include "qemu/log.h" | ||
72 | #include "qemu/main-loop.h" | ||
73 | #include "qemu/module.h" | ||
74 | -#include "arm-powerctl.h" | ||
75 | +#include "target/arm/arm-powerctl.h" | ||
76 | #include "hw/core/cpu.h" | ||
77 | |||
78 | #ifndef DEBUG_IMX6_SRC | ||
79 | diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c | ||
80 | index XXXXXXX..XXXXXXX 100644 | ||
81 | --- a/hw/misc/iotkit-sysctl.c | ||
82 | +++ b/hw/misc/iotkit-sysctl.c | ||
83 | @@ -XXX,XX +XXX,XX @@ | ||
84 | #include "hw/qdev-properties.h" | ||
85 | #include "hw/arm/armsse-version.h" | ||
86 | #include "target/arm/arm-powerctl.h" | ||
87 | -#include "target/arm/cpu.h" | ||
88 | |||
89 | REG32(SECDBGSTAT, 0x0) | ||
90 | REG32(SECDBGSET, 0x4) | ||
91 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
92 | index XXXXXXX..XXXXXXX 100644 | ||
93 | --- a/hw/misc/meson.build | ||
94 | +++ b/hw/misc/meson.build | ||
95 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_IMX', if_true: files( | ||
96 | 'imx25_ccm.c', | ||
97 | 'imx31_ccm.c', | ||
98 | 'imx6_ccm.c', | ||
99 | + 'imx6_src.c', | ||
100 | 'imx6ul_ccm.c', | ||
101 | 'imx7_ccm.c', | ||
102 | 'imx7_gpr.c', | ||
103 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files( | ||
104 | )) | ||
105 | softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) | ||
106 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c')) | ||
107 | -specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-crf.c')) | ||
108 | -specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-apu-ctrl.c')) | ||
109 | +softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-crf.c')) | ||
110 | +softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-apu-ctrl.c')) | ||
111 | specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-crl.c')) | ||
112 | softmmu_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files( | ||
113 | 'xlnx-versal-xramc.c', | ||
114 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_TZ_MPC', if_true: files('tz-mpc.c')) | ||
115 | softmmu_ss.add(when: 'CONFIG_TZ_MSC', if_true: files('tz-msc.c')) | ||
116 | softmmu_ss.add(when: 'CONFIG_TZ_PPC', if_true: files('tz-ppc.c')) | ||
117 | softmmu_ss.add(when: 'CONFIG_IOTKIT_SECCTL', if_true: files('iotkit-secctl.c')) | ||
118 | +softmmu_ss.add(when: 'CONFIG_IOTKIT_SYSCTL', if_true: files('iotkit-sysctl.c')) | ||
119 | softmmu_ss.add(when: 'CONFIG_IOTKIT_SYSINFO', if_true: files('iotkit-sysinfo.c')) | ||
120 | softmmu_ss.add(when: 'CONFIG_ARMSSE_CPU_PWRCTRL', if_true: files('armsse-cpu-pwrctrl.c')) | ||
121 | softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c')) | ||
122 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_ahb_apb_pnp.c')) | ||
123 | |||
124 | specific_ss.add(when: 'CONFIG_AVR_POWER', if_true: files('avr_power.c')) | ||
125 | |||
126 | -specific_ss.add(when: 'CONFIG_IMX', if_true: files('imx6_src.c')) | ||
127 | -specific_ss.add(when: 'CONFIG_IOTKIT_SYSCTL', if_true: files('iotkit-sysctl.c')) | ||
128 | - | ||
129 | specific_ss.add(when: 'CONFIG_MAC_VIA', if_true: files('mac_via.c')) | ||
130 | |||
131 | specific_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_cmgcr.c', 'mips_cpc.c')) | ||
132 | specific_ss.add(when: 'CONFIG_MIPS_ITU', if_true: files('mips_itu.c')) | ||
133 | |||
134 | -specific_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c')) | ||
135 | +softmmu_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c')) | ||
136 | |||
137 | # HPPA devices | ||
138 | softmmu_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c')) | ||
139 | -- | 42 | -- |
140 | 2.25.1 | 43 | 2.34.1 |
141 | 44 | ||
142 | 45 | diff view generated by jsdifflib |
1 | Convert the TYPE_KVM_ARM_ITS device to 3-phase reset. | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Message-id: 20230206223502.25122-8-philmd@linaro.org | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Message-id: 20221109161444.3397405-10-peter.maydell@linaro.org | ||
7 | --- | 7 | --- |
8 | hw/intc/arm_gicv3_its_kvm.c | 14 +++++++++----- | 8 | target/arm/cpu.h | 3 ++- |
9 | 1 file changed, 9 insertions(+), 5 deletions(-) | 9 | 1 file changed, 2 insertions(+), 1 deletion(-) |
10 | 10 | ||
11 | diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c | 11 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
12 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/intc/arm_gicv3_its_kvm.c | 13 | --- a/target/arm/cpu.h |
14 | +++ b/hw/intc/arm_gicv3_its_kvm.c | 14 | +++ b/target/arm/cpu.h |
15 | @@ -XXX,XX +XXX,XX @@ DECLARE_OBJ_CHECKERS(GICv3ITSState, KVMARMITSClass, | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
16 | 16 | ||
17 | struct KVMARMITSClass { | 17 | void *nvic; |
18 | GICv3ITSCommonClass parent_class; | 18 | const struct arm_boot_info *boot_info; |
19 | - void (*parent_reset)(DeviceState *dev); | 19 | +#if !defined(CONFIG_USER_ONLY) |
20 | + ResettablePhases parent_phases; | 20 | /* Store GICv3CPUState to access from this struct */ |
21 | }; | 21 | void *gicv3state; |
22 | 22 | -#if defined(CONFIG_USER_ONLY) | |
23 | 23 | +#else /* CONFIG_USER_ONLY */ | |
24 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_post_load(GICv3ITSState *s) | 24 | /* For usermode syscall translation. */ |
25 | GITS_CTLR, &s->ctlr, true, &error_abort); | 25 | bool eabi; |
26 | } | 26 | #endif /* CONFIG_USER_ONLY */ |
27 | |||
28 | -static void kvm_arm_its_reset(DeviceState *dev) | ||
29 | +static void kvm_arm_its_reset_hold(Object *obj) | ||
30 | { | ||
31 | - GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev); | ||
32 | + GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj); | ||
33 | KVMARMITSClass *c = KVM_ARM_ITS_GET_CLASS(s); | ||
34 | int i; | ||
35 | |||
36 | - c->parent_reset(dev); | ||
37 | + if (c->parent_phases.hold) { | ||
38 | + c->parent_phases.hold(obj); | ||
39 | + } | ||
40 | |||
41 | if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, | ||
42 | KVM_DEV_ARM_ITS_CTRL_RESET)) { | ||
43 | @@ -XXX,XX +XXX,XX @@ static Property kvm_arm_its_props[] = { | ||
44 | static void kvm_arm_its_class_init(ObjectClass *klass, void *data) | ||
45 | { | ||
46 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
47 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
48 | GICv3ITSCommonClass *icc = ARM_GICV3_ITS_COMMON_CLASS(klass); | ||
49 | KVMARMITSClass *ic = KVM_ARM_ITS_CLASS(klass); | ||
50 | |||
51 | dc->realize = kvm_arm_its_realize; | ||
52 | device_class_set_props(dc, kvm_arm_its_props); | ||
53 | - device_class_set_parent_reset(dc, kvm_arm_its_reset, &ic->parent_reset); | ||
54 | + resettable_class_set_parent_phases(rc, NULL, kvm_arm_its_reset_hold, NULL, | ||
55 | + &ic->parent_phases); | ||
56 | icc->send_msi = kvm_its_send_msi; | ||
57 | icc->pre_save = kvm_arm_its_pre_save; | ||
58 | icc->post_load = kvm_arm_its_post_load; | ||
59 | -- | 27 | -- |
60 | 2.25.1 | 28 | 2.34.1 |
61 | 29 | ||
62 | 30 | diff view generated by jsdifflib |
1 | Convert the TYPE_KVM_ARM_GICV3 device to 3-phase reset. | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Message-id: 20230206223502.25122-9-philmd@linaro.org | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Message-id: 20221109161444.3397405-7-peter.maydell@linaro.org | ||
7 | --- | 7 | --- |
8 | hw/intc/arm_gicv3_kvm.c | 14 +++++++++----- | 8 | target/arm/cpu.h | 2 +- |
9 | 1 file changed, 9 insertions(+), 5 deletions(-) | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 10 | ||
11 | diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c | 11 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
12 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/intc/arm_gicv3_kvm.c | 13 | --- a/target/arm/cpu.h |
14 | +++ b/hw/intc/arm_gicv3_kvm.c | 14 | +++ b/target/arm/cpu.h |
15 | @@ -XXX,XX +XXX,XX @@ DECLARE_OBJ_CHECKERS(GICv3State, KVMARMGICv3Class, | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
16 | struct KVMARMGICv3Class { | 16 | } sau; |
17 | ARMGICv3CommonClass parent_class; | 17 | |
18 | DeviceRealize parent_realize; | 18 | void *nvic; |
19 | - void (*parent_reset)(DeviceState *dev); | 19 | - const struct arm_boot_info *boot_info; |
20 | + ResettablePhases parent_phases; | 20 | #if !defined(CONFIG_USER_ONLY) |
21 | }; | 21 | + const struct arm_boot_info *boot_info; |
22 | 22 | /* Store GICv3CPUState to access from this struct */ | |
23 | static void kvm_arm_gicv3_set_irq(void *opaque, int irq, int level) | 23 | void *gicv3state; |
24 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) | 24 | #else /* CONFIG_USER_ONLY */ |
25 | c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS]; | ||
26 | } | ||
27 | |||
28 | -static void kvm_arm_gicv3_reset(DeviceState *dev) | ||
29 | +static void kvm_arm_gicv3_reset_hold(Object *obj) | ||
30 | { | ||
31 | - GICv3State *s = ARM_GICV3_COMMON(dev); | ||
32 | + GICv3State *s = ARM_GICV3_COMMON(obj); | ||
33 | KVMARMGICv3Class *kgc = KVM_ARM_GICV3_GET_CLASS(s); | ||
34 | |||
35 | DPRINTF("Reset\n"); | ||
36 | |||
37 | - kgc->parent_reset(dev); | ||
38 | + if (kgc->parent_phases.hold) { | ||
39 | + kgc->parent_phases.hold(obj); | ||
40 | + } | ||
41 | |||
42 | if (s->migration_blocker) { | ||
43 | DPRINTF("Cannot put kernel gic state, no kernel interface\n"); | ||
44 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp) | ||
45 | static void kvm_arm_gicv3_class_init(ObjectClass *klass, void *data) | ||
46 | { | ||
47 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
48 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
49 | ARMGICv3CommonClass *agcc = ARM_GICV3_COMMON_CLASS(klass); | ||
50 | KVMARMGICv3Class *kgc = KVM_ARM_GICV3_CLASS(klass); | ||
51 | |||
52 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_class_init(ObjectClass *klass, void *data) | ||
53 | agcc->post_load = kvm_arm_gicv3_put; | ||
54 | device_class_set_parent_realize(dc, kvm_arm_gicv3_realize, | ||
55 | &kgc->parent_realize); | ||
56 | - device_class_set_parent_reset(dc, kvm_arm_gicv3_reset, &kgc->parent_reset); | ||
57 | + resettable_class_set_parent_phases(rc, NULL, kvm_arm_gicv3_reset_hold, NULL, | ||
58 | + &kgc->parent_phases); | ||
59 | } | ||
60 | |||
61 | static const TypeInfo kvm_arm_gicv3_info = { | ||
62 | -- | 25 | -- |
63 | 2.25.1 | 26 | 2.34.1 |
64 | 27 | ||
65 | 28 | diff view generated by jsdifflib |
1 | FEAT_EVT adds five new bits to the HCR_EL2 register: TTLBIS, TTLBOS, | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | TICAB, TOCU and TID4. These allow the guest to enable trapping of | ||
3 | various EL1 instructions to EL2. In this commit, add the necessary | ||
4 | code to allow the guest to set these bits if the feature is present; | ||
5 | because the bit is always zero when the feature isn't present we | ||
6 | won't need to use explicit feature checks in the "trap on condition" | ||
7 | tests in the following commits. | ||
8 | 2 | ||
9 | Note that although full implementation of the feature (mandatory from | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Armv8.5 onward) requires all five trap bits, the ID registers permit | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | a value indicating that only TICAB, TOCU and TID4 are implemented, | 5 | Message-id: 20230206223502.25122-10-philmd@linaro.org |
12 | which might be the case for CPUs between Armv8.2 and Armv8.5. | ||
13 | |||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | --- | 7 | --- |
17 | target/arm/cpu.h | 30 ++++++++++++++++++++++++++++++ | 8 | target/arm/cpu.h | 2 +- |
18 | target/arm/helper.c | 6 ++++++ | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
19 | 2 files changed, 36 insertions(+) | ||
20 | 10 | ||
21 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 11 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
22 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/cpu.h | 13 | --- a/target/arm/cpu.h |
24 | +++ b/target/arm/cpu.h | 14 | +++ b/target/arm/cpu.h |
25 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_tts2uxn(const ARMISARegisters *id) | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
26 | return FIELD_EX32(id->id_mmfr4, ID_MMFR4, XNX) != 0; | 16 | uint32_t ctrl; |
27 | } | 17 | } sau; |
28 | 18 | ||
29 | +static inline bool isar_feature_aa32_half_evt(const ARMISARegisters *id) | 19 | - void *nvic; |
30 | +{ | 20 | #if !defined(CONFIG_USER_ONLY) |
31 | + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, EVT) >= 1; | 21 | + void *nvic; |
32 | +} | 22 | const struct arm_boot_info *boot_info; |
33 | + | 23 | /* Store GICv3CPUState to access from this struct */ |
34 | +static inline bool isar_feature_aa32_evt(const ARMISARegisters *id) | 24 | void *gicv3state; |
35 | +{ | ||
36 | + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, EVT) >= 2; | ||
37 | +} | ||
38 | + | ||
39 | static inline bool isar_feature_aa32_dit(const ARMISARegisters *id) | ||
40 | { | ||
41 | return FIELD_EX32(id->id_pfr0, ID_PFR0, DIT) != 0; | ||
42 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ids(const ARMISARegisters *id) | ||
43 | return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, IDS) != 0; | ||
44 | } | ||
45 | |||
46 | +static inline bool isar_feature_aa64_half_evt(const ARMISARegisters *id) | ||
47 | +{ | ||
48 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, EVT) >= 1; | ||
49 | +} | ||
50 | + | ||
51 | +static inline bool isar_feature_aa64_evt(const ARMISARegisters *id) | ||
52 | +{ | ||
53 | + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, EVT) >= 2; | ||
54 | +} | ||
55 | + | ||
56 | static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) | ||
57 | { | ||
58 | return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; | ||
59 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_ras(const ARMISARegisters *id) | ||
60 | return isar_feature_aa64_ras(id) || isar_feature_aa32_ras(id); | ||
61 | } | ||
62 | |||
63 | +static inline bool isar_feature_any_half_evt(const ARMISARegisters *id) | ||
64 | +{ | ||
65 | + return isar_feature_aa64_half_evt(id) || isar_feature_aa32_half_evt(id); | ||
66 | +} | ||
67 | + | ||
68 | +static inline bool isar_feature_any_evt(const ARMISARegisters *id) | ||
69 | +{ | ||
70 | + return isar_feature_aa64_evt(id) || isar_feature_aa32_evt(id); | ||
71 | +} | ||
72 | + | ||
73 | /* | ||
74 | * Forward to the above feature tests given an ARMCPU pointer. | ||
75 | */ | ||
76 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/helper.c | ||
79 | +++ b/target/arm/helper.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | ||
81 | } | ||
82 | } | ||
83 | |||
84 | + if (cpu_isar_feature(any_evt, cpu)) { | ||
85 | + valid_mask |= HCR_TTLBIS | HCR_TTLBOS | HCR_TICAB | HCR_TOCU | HCR_TID4; | ||
86 | + } else if (cpu_isar_feature(any_half_evt, cpu)) { | ||
87 | + valid_mask |= HCR_TICAB | HCR_TOCU | HCR_TID4; | ||
88 | + } | ||
89 | + | ||
90 | /* Clear RES0 bits. */ | ||
91 | value &= valid_mask; | ||
92 | |||
93 | -- | 25 | -- |
94 | 2.25.1 | 26 | 2.34.1 |
27 | |||
28 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When building with --disable-tcg on Darwin we get: | 3 | There is no point in using a void pointer to access the NVIC. |
4 | 4 | Use the real type to avoid casting it while debugging. | |
5 | target/arm/cpu.c:725:16: error: incomplete definition of type 'struct TCGCPUOps' | ||
6 | cc->tcg_ops->do_interrupt(cs); | ||
7 | ~~~~~~~~~~~^ | ||
8 | |||
9 | Commit 083afd18a9 ("target/arm: Restrict cpu_exec_interrupt() | ||
10 | handler to sysemu") limited this block to system emulation, | ||
11 | but neglected to also limit it to TCG. | ||
12 | 5 | ||
13 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
14 | Reviewed-by: Fabiano Rosas <farosas@suse.de> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20221209110823.59495-1-philmd@linaro.org | 8 | Message-id: 20230206223502.25122-11-philmd@linaro.org |
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 10 | --- |
18 | target/arm/cpu.c | 5 +++-- | 11 | target/arm/cpu.h | 46 ++++++++++++++++++++++--------------------- |
19 | 1 file changed, 3 insertions(+), 2 deletions(-) | 12 | hw/intc/armv7m_nvic.c | 38 ++++++++++++----------------------- |
20 | 13 | target/arm/cpu.c | 1 + | |
14 | target/arm/m_helper.c | 2 +- | ||
15 | 4 files changed, 39 insertions(+), 48 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMTBFlags { | ||
22 | |||
23 | typedef struct ARMMMUFaultInfo ARMMMUFaultInfo; | ||
24 | |||
25 | +typedef struct NVICState NVICState; | ||
26 | + | ||
27 | typedef struct CPUArchState { | ||
28 | /* Regs for current mode. */ | ||
29 | uint32_t regs[16]; | ||
30 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
31 | } sau; | ||
32 | |||
33 | #if !defined(CONFIG_USER_ONLY) | ||
34 | - void *nvic; | ||
35 | + NVICState *nvic; | ||
36 | const struct arm_boot_info *boot_info; | ||
37 | /* Store GICv3CPUState to access from this struct */ | ||
38 | void *gicv3state; | ||
39 | @@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | ||
40 | |||
41 | /* Interface between CPU and Interrupt controller. */ | ||
42 | #ifndef CONFIG_USER_ONLY | ||
43 | -bool armv7m_nvic_can_take_pending_exception(void *opaque); | ||
44 | +bool armv7m_nvic_can_take_pending_exception(NVICState *s); | ||
45 | #else | ||
46 | -static inline bool armv7m_nvic_can_take_pending_exception(void *opaque) | ||
47 | +static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s) | ||
48 | { | ||
49 | return true; | ||
50 | } | ||
51 | #endif | ||
52 | /** | ||
53 | * armv7m_nvic_set_pending: mark the specified exception as pending | ||
54 | - * @opaque: the NVIC | ||
55 | + * @s: the NVIC | ||
56 | * @irq: the exception number to mark pending | ||
57 | * @secure: false for non-banked exceptions or for the nonsecure | ||
58 | * version of a banked exception, true for the secure version of a banked | ||
59 | @@ -XXX,XX +XXX,XX @@ static inline bool armv7m_nvic_can_take_pending_exception(void *opaque) | ||
60 | * if @secure is true and @irq does not specify one of the fixed set | ||
61 | * of architecturally banked exceptions. | ||
62 | */ | ||
63 | -void armv7m_nvic_set_pending(void *opaque, int irq, bool secure); | ||
64 | +void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure); | ||
65 | /** | ||
66 | * armv7m_nvic_set_pending_derived: mark this derived exception as pending | ||
67 | - * @opaque: the NVIC | ||
68 | + * @s: the NVIC | ||
69 | * @irq: the exception number to mark pending | ||
70 | * @secure: false for non-banked exceptions or for the nonsecure | ||
71 | * version of a banked exception, true for the secure version of a banked | ||
72 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure); | ||
73 | * exceptions (exceptions generated in the course of trying to take | ||
74 | * a different exception). | ||
75 | */ | ||
76 | -void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure); | ||
77 | +void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure); | ||
78 | /** | ||
79 | * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending | ||
80 | - * @opaque: the NVIC | ||
81 | + * @s: the NVIC | ||
82 | * @irq: the exception number to mark pending | ||
83 | * @secure: false for non-banked exceptions or for the nonsecure | ||
84 | * version of a banked exception, true for the secure version of a banked | ||
85 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure); | ||
86 | * Similar to armv7m_nvic_set_pending(), but specifically for exceptions | ||
87 | * generated in the course of lazy stacking of FP registers. | ||
88 | */ | ||
89 | -void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure); | ||
90 | +void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure); | ||
91 | /** | ||
92 | * armv7m_nvic_get_pending_irq_info: return highest priority pending | ||
93 | * exception, and whether it targets Secure state | ||
94 | - * @opaque: the NVIC | ||
95 | + * @s: the NVIC | ||
96 | * @pirq: set to pending exception number | ||
97 | * @ptargets_secure: set to whether pending exception targets Secure | ||
98 | * | ||
99 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure); | ||
100 | * to true if the current highest priority pending exception should | ||
101 | * be taken to Secure state, false for NS. | ||
102 | */ | ||
103 | -void armv7m_nvic_get_pending_irq_info(void *opaque, int *pirq, | ||
104 | +void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq, | ||
105 | bool *ptargets_secure); | ||
106 | /** | ||
107 | * armv7m_nvic_acknowledge_irq: make highest priority pending exception active | ||
108 | - * @opaque: the NVIC | ||
109 | + * @s: the NVIC | ||
110 | * | ||
111 | * Move the current highest priority pending exception from the pending | ||
112 | * state to the active state, and update v7m.exception to indicate that | ||
113 | * it is the exception currently being handled. | ||
114 | */ | ||
115 | -void armv7m_nvic_acknowledge_irq(void *opaque); | ||
116 | +void armv7m_nvic_acknowledge_irq(NVICState *s); | ||
117 | /** | ||
118 | * armv7m_nvic_complete_irq: complete specified interrupt or exception | ||
119 | - * @opaque: the NVIC | ||
120 | + * @s: the NVIC | ||
121 | * @irq: the exception number to complete | ||
122 | * @secure: true if this exception was secure | ||
123 | * | ||
124 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque); | ||
125 | * 0 if there is still an irq active after this one was completed | ||
126 | * (Ignoring -1, this is the same as the RETTOBASE value before completion.) | ||
127 | */ | ||
128 | -int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure); | ||
129 | +int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure); | ||
130 | /** | ||
131 | * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | ||
132 | - * @opaque: the NVIC | ||
133 | + * @s: the NVIC | ||
134 | * @irq: the exception number to mark pending | ||
135 | * @secure: false for non-banked exceptions or for the nonsecure | ||
136 | * version of a banked exception, true for the secure version of a banked | ||
137 | @@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure); | ||
138 | * interrupt the current execution priority. This controls whether the | ||
139 | * RDY bit for it in the FPCCR is set. | ||
140 | */ | ||
141 | -bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure); | ||
142 | +bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure); | ||
143 | /** | ||
144 | * armv7m_nvic_raw_execution_priority: return the raw execution priority | ||
145 | - * @opaque: the NVIC | ||
146 | + * @s: the NVIC | ||
147 | * | ||
148 | * Returns: the raw execution priority as defined by the v8M architecture. | ||
149 | * This is the execution priority minus the effects of AIRCR.PRIS, | ||
150 | * and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting. | ||
151 | * (v8M ARM ARM I_PKLD.) | ||
152 | */ | ||
153 | -int armv7m_nvic_raw_execution_priority(void *opaque); | ||
154 | +int armv7m_nvic_raw_execution_priority(NVICState *s); | ||
155 | /** | ||
156 | * armv7m_nvic_neg_prio_requested: return true if the requested execution | ||
157 | * priority is negative for the specified security state. | ||
158 | - * @opaque: the NVIC | ||
159 | + * @s: the NVIC | ||
160 | * @secure: the security state to test | ||
161 | * This corresponds to the pseudocode IsReqExecPriNeg(). | ||
162 | */ | ||
163 | #ifndef CONFIG_USER_ONLY | ||
164 | -bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure); | ||
165 | +bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure); | ||
166 | #else | ||
167 | -static inline bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure) | ||
168 | +static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure) | ||
169 | { | ||
170 | return false; | ||
171 | } | ||
172 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | ||
173 | index XXXXXXX..XXXXXXX 100644 | ||
174 | --- a/hw/intc/armv7m_nvic.c | ||
175 | +++ b/hw/intc/armv7m_nvic.c | ||
176 | @@ -XXX,XX +XXX,XX @@ static inline int nvic_exec_prio(NVICState *s) | ||
177 | return MIN(running, s->exception_prio); | ||
178 | } | ||
179 | |||
180 | -bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure) | ||
181 | +bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure) | ||
182 | { | ||
183 | /* Return true if the requested execution priority is negative | ||
184 | * for the specified security state, ie that security state | ||
185 | @@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure) | ||
186 | * mean we don't allow FAULTMASK_NS to actually make the execution | ||
187 | * priority negative). Compare pseudocode IsReqExcPriNeg(). | ||
188 | */ | ||
189 | - NVICState *s = opaque; | ||
190 | - | ||
191 | if (s->cpu->env.v7m.faultmask[secure]) { | ||
192 | return true; | ||
193 | } | ||
194 | @@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure) | ||
195 | return false; | ||
196 | } | ||
197 | |||
198 | -bool armv7m_nvic_can_take_pending_exception(void *opaque) | ||
199 | +bool armv7m_nvic_can_take_pending_exception(NVICState *s) | ||
200 | { | ||
201 | - NVICState *s = opaque; | ||
202 | - | ||
203 | return nvic_exec_prio(s) > nvic_pending_prio(s); | ||
204 | } | ||
205 | |||
206 | -int armv7m_nvic_raw_execution_priority(void *opaque) | ||
207 | +int armv7m_nvic_raw_execution_priority(NVICState *s) | ||
208 | { | ||
209 | - NVICState *s = opaque; | ||
210 | - | ||
211 | return s->exception_prio; | ||
212 | } | ||
213 | |||
214 | @@ -XXX,XX +XXX,XX @@ static void nvic_irq_update(NVICState *s) | ||
215 | * if @secure is true and @irq does not specify one of the fixed set | ||
216 | * of architecturally banked exceptions. | ||
217 | */ | ||
218 | -static void armv7m_nvic_clear_pending(void *opaque, int irq, bool secure) | ||
219 | +static void armv7m_nvic_clear_pending(NVICState *s, int irq, bool secure) | ||
220 | { | ||
221 | - NVICState *s = (NVICState *)opaque; | ||
222 | VecInfo *vec; | ||
223 | |||
224 | assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq); | ||
225 | @@ -XXX,XX +XXX,XX @@ static void do_armv7m_nvic_set_pending(void *opaque, int irq, bool secure, | ||
226 | } | ||
227 | } | ||
228 | |||
229 | -void armv7m_nvic_set_pending(void *opaque, int irq, bool secure) | ||
230 | +void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure) | ||
231 | { | ||
232 | - do_armv7m_nvic_set_pending(opaque, irq, secure, false); | ||
233 | + do_armv7m_nvic_set_pending(s, irq, secure, false); | ||
234 | } | ||
235 | |||
236 | -void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure) | ||
237 | +void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure) | ||
238 | { | ||
239 | - do_armv7m_nvic_set_pending(opaque, irq, secure, true); | ||
240 | + do_armv7m_nvic_set_pending(s, irq, secure, true); | ||
241 | } | ||
242 | |||
243 | -void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure) | ||
244 | +void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure) | ||
245 | { | ||
246 | /* | ||
247 | * Pend an exception during lazy FP stacking. This differs | ||
248 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure) | ||
249 | * whether we should escalate depends on the saved context | ||
250 | * in the FPCCR register, not on the current state of the CPU/NVIC. | ||
251 | */ | ||
252 | - NVICState *s = (NVICState *)opaque; | ||
253 | bool banked = exc_is_banked(irq); | ||
254 | VecInfo *vec; | ||
255 | bool targets_secure; | ||
256 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure) | ||
257 | } | ||
258 | |||
259 | /* Make pending IRQ active. */ | ||
260 | -void armv7m_nvic_acknowledge_irq(void *opaque) | ||
261 | +void armv7m_nvic_acknowledge_irq(NVICState *s) | ||
262 | { | ||
263 | - NVICState *s = (NVICState *)opaque; | ||
264 | CPUARMState *env = &s->cpu->env; | ||
265 | const int pending = s->vectpending; | ||
266 | const int running = nvic_exec_prio(s); | ||
267 | @@ -XXX,XX +XXX,XX @@ static bool vectpending_targets_secure(NVICState *s) | ||
268 | exc_targets_secure(s, s->vectpending); | ||
269 | } | ||
270 | |||
271 | -void armv7m_nvic_get_pending_irq_info(void *opaque, | ||
272 | +void armv7m_nvic_get_pending_irq_info(NVICState *s, | ||
273 | int *pirq, bool *ptargets_secure) | ||
274 | { | ||
275 | - NVICState *s = (NVICState *)opaque; | ||
276 | const int pending = s->vectpending; | ||
277 | bool targets_secure; | ||
278 | |||
279 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_get_pending_irq_info(void *opaque, | ||
280 | *pirq = pending; | ||
281 | } | ||
282 | |||
283 | -int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure) | ||
284 | +int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure) | ||
285 | { | ||
286 | - NVICState *s = (NVICState *)opaque; | ||
287 | VecInfo *vec = NULL; | ||
288 | int ret = 0; | ||
289 | |||
290 | @@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure) | ||
291 | return ret; | ||
292 | } | ||
293 | |||
294 | -bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | ||
295 | +bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure) | ||
296 | { | ||
297 | /* | ||
298 | * Return whether an exception is "ready", i.e. it is enabled and is | ||
299 | @@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | ||
300 | * for non-banked exceptions secure is always false; for banked exceptions | ||
301 | * it indicates which of the exceptions is required. | ||
302 | */ | ||
303 | - NVICState *s = (NVICState *)opaque; | ||
304 | bool banked = exc_is_banked(irq); | ||
305 | VecInfo *vec; | ||
306 | int running = nvic_exec_prio(s); | ||
21 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 307 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
22 | index XXXXXXX..XXXXXXX 100644 | 308 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/cpu.c | 309 | --- a/target/arm/cpu.c |
24 | +++ b/target/arm/cpu.c | 310 | +++ b/target/arm/cpu.c |
25 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) | 311 | @@ -XXX,XX +XXX,XX @@ |
26 | arm_rebuild_hflags(env); | 312 | #if !defined(CONFIG_USER_ONLY) |
27 | } | 313 | #include "hw/loader.h" |
28 | 314 | #include "hw/boards.h" | |
29 | -#ifndef CONFIG_USER_ONLY | 315 | +#include "hw/intc/armv7m_nvic.h" |
30 | +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) | 316 | #endif |
31 | 317 | #include "sysemu/tcg.h" | |
32 | static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | 318 | #include "sysemu/qtest.h" |
33 | unsigned int target_el, | 319 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
34 | @@ -XXX,XX +XXX,XX @@ static bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | 320 | index XXXXXXX..XXXXXXX 100644 |
35 | cc->tcg_ops->do_interrupt(cs); | 321 | --- a/target/arm/m_helper.c |
36 | return true; | 322 | +++ b/target/arm/m_helper.c |
37 | } | 323 | @@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr, |
38 | -#endif /* !CONFIG_USER_ONLY */ | 324 | * that we will need later in order to do lazy FP reg stacking. |
39 | + | 325 | */ |
40 | +#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */ | 326 | bool is_secure = env->v7m.secure; |
41 | 327 | - void *nvic = env->nvic; | |
42 | void arm_cpu_update_virq(ARMCPU *cpu) | 328 | + NVICState *nvic = env->nvic; |
43 | { | 329 | /* |
330 | * Some bits are unbanked and live always in fpccr[M_REG_S]; some bits | ||
331 | * are banked and we want to update the bit in the bank for the | ||
44 | -- | 332 | -- |
45 | 2.25.1 | 333 | 2.34.1 |
46 | 334 | ||
47 | 335 | diff view generated by jsdifflib |
1 | Update the ID registers for TCG's '-cpu max' to report the | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | FEAT_EVT Enhanced Virtualization Traps support. | 2 | |
3 | 3 | While dozens of files include "cpu.h", only 3 files require | |
4 | these NVIC helper declarations. | ||
5 | |||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Message-id: 20230206223502.25122-12-philmd@linaro.org | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | 10 | --- |
7 | docs/system/arm/emulation.rst | 1 + | 11 | include/hw/intc/armv7m_nvic.h | 123 ++++++++++++++++++++++++++++++++++ |
8 | target/arm/cpu64.c | 1 + | 12 | target/arm/cpu.h | 123 ---------------------------------- |
9 | target/arm/cpu_tcg.c | 1 + | 13 | target/arm/cpu.c | 4 +- |
10 | 3 files changed, 3 insertions(+) | 14 | target/arm/cpu_tcg.c | 3 + |
11 | 15 | target/arm/m_helper.c | 3 + | |
12 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | 16 | 5 files changed, 132 insertions(+), 124 deletions(-) |
13 | index XXXXXXX..XXXXXXX 100644 | 17 | |
14 | --- a/docs/system/arm/emulation.rst | 18 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h |
15 | +++ b/docs/system/arm/emulation.rst | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | 20 | --- a/include/hw/intc/armv7m_nvic.h |
17 | - FEAT_DoubleFault (Double Fault Extension) | 21 | +++ b/include/hw/intc/armv7m_nvic.h |
18 | - FEAT_E0PD (Preventing EL0 access to halves of address maps) | 22 | @@ -XXX,XX +XXX,XX @@ struct NVICState { |
19 | - FEAT_ETS (Enhanced Translation Synchronization) | 23 | qemu_irq sysresetreq; |
20 | +- FEAT_EVT (Enhanced Virtualization Traps) | 24 | }; |
21 | - FEAT_FCMA (Floating-point complex number instructions) | 25 | |
22 | - FEAT_FHM (Floating-point half-precision multiplication instructions) | 26 | +/* Interface between CPU and Interrupt controller. */ |
23 | - FEAT_FP16 (Half-precision floating-point data processing) | 27 | +/** |
24 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 28 | + * armv7m_nvic_set_pending: mark the specified exception as pending |
25 | index XXXXXXX..XXXXXXX 100644 | 29 | + * @s: the NVIC |
26 | --- a/target/arm/cpu64.c | 30 | + * @irq: the exception number to mark pending |
27 | +++ b/target/arm/cpu64.c | 31 | + * @secure: false for non-banked exceptions or for the nonsecure |
28 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 32 | + * version of a banked exception, true for the secure version of a banked |
29 | t = FIELD_DP64(t, ID_AA64MMFR2, FWB, 1); /* FEAT_S2FWB */ | 33 | + * exception. |
30 | t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */ | 34 | + * |
31 | t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */ | 35 | + * Marks the specified exception as pending. Note that we will assert() |
32 | + t = FIELD_DP64(t, ID_AA64MMFR2, EVT, 2); /* FEAT_EVT */ | 36 | + * if @secure is true and @irq does not specify one of the fixed set |
33 | t = FIELD_DP64(t, ID_AA64MMFR2, E0PD, 1); /* FEAT_E0PD */ | 37 | + * of architecturally banked exceptions. |
34 | cpu->isar.id_aa64mmfr2 = t; | 38 | + */ |
35 | 39 | +void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure); | |
40 | +/** | ||
41 | + * armv7m_nvic_set_pending_derived: mark this derived exception as pending | ||
42 | + * @s: the NVIC | ||
43 | + * @irq: the exception number to mark pending | ||
44 | + * @secure: false for non-banked exceptions or for the nonsecure | ||
45 | + * version of a banked exception, true for the secure version of a banked | ||
46 | + * exception. | ||
47 | + * | ||
48 | + * Similar to armv7m_nvic_set_pending(), but specifically for derived | ||
49 | + * exceptions (exceptions generated in the course of trying to take | ||
50 | + * a different exception). | ||
51 | + */ | ||
52 | +void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure); | ||
53 | +/** | ||
54 | + * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending | ||
55 | + * @s: the NVIC | ||
56 | + * @irq: the exception number to mark pending | ||
57 | + * @secure: false for non-banked exceptions or for the nonsecure | ||
58 | + * version of a banked exception, true for the secure version of a banked | ||
59 | + * exception. | ||
60 | + * | ||
61 | + * Similar to armv7m_nvic_set_pending(), but specifically for exceptions | ||
62 | + * generated in the course of lazy stacking of FP registers. | ||
63 | + */ | ||
64 | +void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure); | ||
65 | +/** | ||
66 | + * armv7m_nvic_get_pending_irq_info: return highest priority pending | ||
67 | + * exception, and whether it targets Secure state | ||
68 | + * @s: the NVIC | ||
69 | + * @pirq: set to pending exception number | ||
70 | + * @ptargets_secure: set to whether pending exception targets Secure | ||
71 | + * | ||
72 | + * This function writes the number of the highest priority pending | ||
73 | + * exception (the one which would be made active by | ||
74 | + * armv7m_nvic_acknowledge_irq()) to @pirq, and sets @ptargets_secure | ||
75 | + * to true if the current highest priority pending exception should | ||
76 | + * be taken to Secure state, false for NS. | ||
77 | + */ | ||
78 | +void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq, | ||
79 | + bool *ptargets_secure); | ||
80 | +/** | ||
81 | + * armv7m_nvic_acknowledge_irq: make highest priority pending exception active | ||
82 | + * @s: the NVIC | ||
83 | + * | ||
84 | + * Move the current highest priority pending exception from the pending | ||
85 | + * state to the active state, and update v7m.exception to indicate that | ||
86 | + * it is the exception currently being handled. | ||
87 | + */ | ||
88 | +void armv7m_nvic_acknowledge_irq(NVICState *s); | ||
89 | +/** | ||
90 | + * armv7m_nvic_complete_irq: complete specified interrupt or exception | ||
91 | + * @s: the NVIC | ||
92 | + * @irq: the exception number to complete | ||
93 | + * @secure: true if this exception was secure | ||
94 | + * | ||
95 | + * Returns: -1 if the irq was not active | ||
96 | + * 1 if completing this irq brought us back to base (no active irqs) | ||
97 | + * 0 if there is still an irq active after this one was completed | ||
98 | + * (Ignoring -1, this is the same as the RETTOBASE value before completion.) | ||
99 | + */ | ||
100 | +int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure); | ||
101 | +/** | ||
102 | + * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | ||
103 | + * @s: the NVIC | ||
104 | + * @irq: the exception number to mark pending | ||
105 | + * @secure: false for non-banked exceptions or for the nonsecure | ||
106 | + * version of a banked exception, true for the secure version of a banked | ||
107 | + * exception. | ||
108 | + * | ||
109 | + * Return whether an exception is "ready", i.e. whether the exception is | ||
110 | + * enabled and is configured at a priority which would allow it to | ||
111 | + * interrupt the current execution priority. This controls whether the | ||
112 | + * RDY bit for it in the FPCCR is set. | ||
113 | + */ | ||
114 | +bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure); | ||
115 | +/** | ||
116 | + * armv7m_nvic_raw_execution_priority: return the raw execution priority | ||
117 | + * @s: the NVIC | ||
118 | + * | ||
119 | + * Returns: the raw execution priority as defined by the v8M architecture. | ||
120 | + * This is the execution priority minus the effects of AIRCR.PRIS, | ||
121 | + * and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting. | ||
122 | + * (v8M ARM ARM I_PKLD.) | ||
123 | + */ | ||
124 | +int armv7m_nvic_raw_execution_priority(NVICState *s); | ||
125 | +/** | ||
126 | + * armv7m_nvic_neg_prio_requested: return true if the requested execution | ||
127 | + * priority is negative for the specified security state. | ||
128 | + * @s: the NVIC | ||
129 | + * @secure: the security state to test | ||
130 | + * This corresponds to the pseudocode IsReqExecPriNeg(). | ||
131 | + */ | ||
132 | +#ifndef CONFIG_USER_ONLY | ||
133 | +bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure); | ||
134 | +#else | ||
135 | +static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure) | ||
136 | +{ | ||
137 | + return false; | ||
138 | +} | ||
139 | +#endif | ||
140 | +#ifndef CONFIG_USER_ONLY | ||
141 | +bool armv7m_nvic_can_take_pending_exception(NVICState *s); | ||
142 | +#else | ||
143 | +static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s) | ||
144 | +{ | ||
145 | + return true; | ||
146 | +} | ||
147 | +#endif | ||
148 | + | ||
149 | #endif | ||
150 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
151 | index XXXXXXX..XXXXXXX 100644 | ||
152 | --- a/target/arm/cpu.h | ||
153 | +++ b/target/arm/cpu.h | ||
154 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_list(void); | ||
155 | uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | ||
156 | uint32_t cur_el, bool secure); | ||
157 | |||
158 | -/* Interface between CPU and Interrupt controller. */ | ||
159 | -#ifndef CONFIG_USER_ONLY | ||
160 | -bool armv7m_nvic_can_take_pending_exception(NVICState *s); | ||
161 | -#else | ||
162 | -static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s) | ||
163 | -{ | ||
164 | - return true; | ||
165 | -} | ||
166 | -#endif | ||
167 | -/** | ||
168 | - * armv7m_nvic_set_pending: mark the specified exception as pending | ||
169 | - * @s: the NVIC | ||
170 | - * @irq: the exception number to mark pending | ||
171 | - * @secure: false for non-banked exceptions or for the nonsecure | ||
172 | - * version of a banked exception, true for the secure version of a banked | ||
173 | - * exception. | ||
174 | - * | ||
175 | - * Marks the specified exception as pending. Note that we will assert() | ||
176 | - * if @secure is true and @irq does not specify one of the fixed set | ||
177 | - * of architecturally banked exceptions. | ||
178 | - */ | ||
179 | -void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure); | ||
180 | -/** | ||
181 | - * armv7m_nvic_set_pending_derived: mark this derived exception as pending | ||
182 | - * @s: the NVIC | ||
183 | - * @irq: the exception number to mark pending | ||
184 | - * @secure: false for non-banked exceptions or for the nonsecure | ||
185 | - * version of a banked exception, true for the secure version of a banked | ||
186 | - * exception. | ||
187 | - * | ||
188 | - * Similar to armv7m_nvic_set_pending(), but specifically for derived | ||
189 | - * exceptions (exceptions generated in the course of trying to take | ||
190 | - * a different exception). | ||
191 | - */ | ||
192 | -void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure); | ||
193 | -/** | ||
194 | - * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending | ||
195 | - * @s: the NVIC | ||
196 | - * @irq: the exception number to mark pending | ||
197 | - * @secure: false for non-banked exceptions or for the nonsecure | ||
198 | - * version of a banked exception, true for the secure version of a banked | ||
199 | - * exception. | ||
200 | - * | ||
201 | - * Similar to armv7m_nvic_set_pending(), but specifically for exceptions | ||
202 | - * generated in the course of lazy stacking of FP registers. | ||
203 | - */ | ||
204 | -void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure); | ||
205 | -/** | ||
206 | - * armv7m_nvic_get_pending_irq_info: return highest priority pending | ||
207 | - * exception, and whether it targets Secure state | ||
208 | - * @s: the NVIC | ||
209 | - * @pirq: set to pending exception number | ||
210 | - * @ptargets_secure: set to whether pending exception targets Secure | ||
211 | - * | ||
212 | - * This function writes the number of the highest priority pending | ||
213 | - * exception (the one which would be made active by | ||
214 | - * armv7m_nvic_acknowledge_irq()) to @pirq, and sets @ptargets_secure | ||
215 | - * to true if the current highest priority pending exception should | ||
216 | - * be taken to Secure state, false for NS. | ||
217 | - */ | ||
218 | -void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq, | ||
219 | - bool *ptargets_secure); | ||
220 | -/** | ||
221 | - * armv7m_nvic_acknowledge_irq: make highest priority pending exception active | ||
222 | - * @s: the NVIC | ||
223 | - * | ||
224 | - * Move the current highest priority pending exception from the pending | ||
225 | - * state to the active state, and update v7m.exception to indicate that | ||
226 | - * it is the exception currently being handled. | ||
227 | - */ | ||
228 | -void armv7m_nvic_acknowledge_irq(NVICState *s); | ||
229 | -/** | ||
230 | - * armv7m_nvic_complete_irq: complete specified interrupt or exception | ||
231 | - * @s: the NVIC | ||
232 | - * @irq: the exception number to complete | ||
233 | - * @secure: true if this exception was secure | ||
234 | - * | ||
235 | - * Returns: -1 if the irq was not active | ||
236 | - * 1 if completing this irq brought us back to base (no active irqs) | ||
237 | - * 0 if there is still an irq active after this one was completed | ||
238 | - * (Ignoring -1, this is the same as the RETTOBASE value before completion.) | ||
239 | - */ | ||
240 | -int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure); | ||
241 | -/** | ||
242 | - * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure) | ||
243 | - * @s: the NVIC | ||
244 | - * @irq: the exception number to mark pending | ||
245 | - * @secure: false for non-banked exceptions or for the nonsecure | ||
246 | - * version of a banked exception, true for the secure version of a banked | ||
247 | - * exception. | ||
248 | - * | ||
249 | - * Return whether an exception is "ready", i.e. whether the exception is | ||
250 | - * enabled and is configured at a priority which would allow it to | ||
251 | - * interrupt the current execution priority. This controls whether the | ||
252 | - * RDY bit for it in the FPCCR is set. | ||
253 | - */ | ||
254 | -bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure); | ||
255 | -/** | ||
256 | - * armv7m_nvic_raw_execution_priority: return the raw execution priority | ||
257 | - * @s: the NVIC | ||
258 | - * | ||
259 | - * Returns: the raw execution priority as defined by the v8M architecture. | ||
260 | - * This is the execution priority minus the effects of AIRCR.PRIS, | ||
261 | - * and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting. | ||
262 | - * (v8M ARM ARM I_PKLD.) | ||
263 | - */ | ||
264 | -int armv7m_nvic_raw_execution_priority(NVICState *s); | ||
265 | -/** | ||
266 | - * armv7m_nvic_neg_prio_requested: return true if the requested execution | ||
267 | - * priority is negative for the specified security state. | ||
268 | - * @s: the NVIC | ||
269 | - * @secure: the security state to test | ||
270 | - * This corresponds to the pseudocode IsReqExecPriNeg(). | ||
271 | - */ | ||
272 | -#ifndef CONFIG_USER_ONLY | ||
273 | -bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure); | ||
274 | -#else | ||
275 | -static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure) | ||
276 | -{ | ||
277 | - return false; | ||
278 | -} | ||
279 | -#endif | ||
280 | - | ||
281 | /* Interface for defining coprocessor registers. | ||
282 | * Registers are defined in tables of arm_cp_reginfo structs | ||
283 | * which are passed to define_arm_cp_regs(). | ||
284 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
285 | index XXXXXXX..XXXXXXX 100644 | ||
286 | --- a/target/arm/cpu.c | ||
287 | +++ b/target/arm/cpu.c | ||
288 | @@ -XXX,XX +XXX,XX @@ | ||
289 | #if !defined(CONFIG_USER_ONLY) | ||
290 | #include "hw/loader.h" | ||
291 | #include "hw/boards.h" | ||
292 | +#ifdef CONFIG_TCG | ||
293 | #include "hw/intc/armv7m_nvic.h" | ||
294 | -#endif | ||
295 | +#endif /* CONFIG_TCG */ | ||
296 | +#endif /* !CONFIG_USER_ONLY */ | ||
297 | #include "sysemu/tcg.h" | ||
298 | #include "sysemu/qtest.h" | ||
299 | #include "sysemu/hw_accel.h" | ||
36 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | 300 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
37 | index XXXXXXX..XXXXXXX 100644 | 301 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/target/arm/cpu_tcg.c | 302 | --- a/target/arm/cpu_tcg.c |
39 | +++ b/target/arm/cpu_tcg.c | 303 | +++ b/target/arm/cpu_tcg.c |
40 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | 304 | @@ -XXX,XX +XXX,XX @@ |
41 | t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | 305 | #include "hw/boards.h" |
42 | t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */ | 306 | #endif |
43 | t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX */ | 307 | #include "cpregs.h" |
44 | + t = FIELD_DP32(t, ID_MMFR4, EVT, 2); /* FEAT_EVT */ | 308 | +#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) |
45 | cpu->isar.id_mmfr4 = t; | 309 | +#include "hw/intc/armv7m_nvic.h" |
46 | 310 | +#endif | |
47 | t = cpu->isar.id_mmfr5; | 311 | |
312 | |||
313 | /* Share AArch32 -cpu max features with AArch64. */ | ||
314 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
315 | index XXXXXXX..XXXXXXX 100644 | ||
316 | --- a/target/arm/m_helper.c | ||
317 | +++ b/target/arm/m_helper.c | ||
318 | @@ -XXX,XX +XXX,XX @@ | ||
319 | #include "exec/cpu_ldst.h" | ||
320 | #include "semihosting/common-semi.h" | ||
321 | #endif | ||
322 | +#if !defined(CONFIG_USER_ONLY) | ||
323 | +#include "hw/intc/armv7m_nvic.h" | ||
324 | +#endif | ||
325 | |||
326 | static void v7m_msr_xpsr(CPUARMState *env, uint32_t mask, | ||
327 | uint32_t reg, uint32_t val) | ||
48 | -- | 328 | -- |
49 | 2.25.1 | 329 | 2.34.1 |
330 | |||
331 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Alex Bennée <alex.bennee@linaro.org> | |
2 | |||
3 | The two TCG tests for GICv2 and GICv3 are very heavy weight distros | ||
4 | that take a long time to boot up, especially for an --enable-debug | ||
5 | build. The total code coverage they give is: | ||
6 | |||
7 | Overall coverage rate: | ||
8 | lines......: 11.2% (59584 of 530123 lines) | ||
9 | functions..: 15.0% (7436 of 49443 functions) | ||
10 | branches...: 6.3% (19273 of 303933 branches) | ||
11 | |||
12 | We already get pretty close to that with the machine_aarch64_virt | ||
13 | tests which only does one full boot (~120s vs ~600s) of alpine. We | ||
14 | expand the kernel+initrd boot (~8s) to test both GICs and also add an | ||
15 | RNG device and a block device to generate a few IRQs and exercise the | ||
16 | storage layer. With that we get to a coverage of: | ||
17 | |||
18 | Overall coverage rate: | ||
19 | lines......: 11.0% (58121 of 530123 lines) | ||
20 | functions..: 14.9% (7343 of 49443 functions) | ||
21 | branches...: 6.0% (18269 of 303933 branches) | ||
22 | |||
23 | which I feel is close enough given the massive time saving. If we want | ||
24 | to target any more sub-systems we can use lighter weight more directed | ||
25 | tests. | ||
26 | |||
27 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
28 | Reviewed-by: Fabiano Rosas <farosas@suse.de> | ||
29 | Acked-by: Richard Henderson <richard.henderson@linaro.org> | ||
30 | Message-id: 20230203181632.2919715-1-alex.bennee@linaro.org | ||
31 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
33 | --- | ||
34 | tests/avocado/boot_linux.py | 48 ++++---------------- | ||
35 | tests/avocado/machine_aarch64_virt.py | 63 ++++++++++++++++++++++++--- | ||
36 | 2 files changed, 65 insertions(+), 46 deletions(-) | ||
37 | |||
38 | diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/tests/avocado/boot_linux.py | ||
41 | +++ b/tests/avocado/boot_linux.py | ||
42 | @@ -XXX,XX +XXX,XX @@ def test_pc_q35_kvm(self): | ||
43 | self.launch_and_wait(set_up_ssh_connection=False) | ||
44 | |||
45 | |||
46 | -# For Aarch64 we only boot KVM tests in CI as the TCG tests are very | ||
47 | -# heavyweight. There are lighter weight distros which we use in the | ||
48 | -# machine_aarch64_virt.py tests. | ||
49 | +# For Aarch64 we only boot KVM tests in CI as booting the current | ||
50 | +# Fedora OS in TCG tests is very heavyweight. There are lighter weight | ||
51 | +# distros which we use in the machine_aarch64_virt.py tests. | ||
52 | class BootLinuxAarch64(LinuxTest): | ||
53 | """ | ||
54 | :avocado: tags=arch:aarch64 | ||
55 | :avocado: tags=machine:virt | ||
56 | - :avocado: tags=machine:gic-version=2 | ||
57 | """ | ||
58 | timeout = 720 | ||
59 | |||
60 | - def add_common_args(self): | ||
61 | - self.vm.add_args('-bios', | ||
62 | - os.path.join(BUILD_DIR, 'pc-bios', | ||
63 | - 'edk2-aarch64-code.fd')) | ||
64 | - self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0') | ||
65 | - self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom') | ||
66 | - | ||
67 | - @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') | ||
68 | - def test_fedora_cloud_tcg_gicv2(self): | ||
69 | - """ | ||
70 | - :avocado: tags=accel:tcg | ||
71 | - :avocado: tags=cpu:max | ||
72 | - :avocado: tags=device:gicv2 | ||
73 | - """ | ||
74 | - self.require_accelerator("tcg") | ||
75 | - self.vm.add_args("-accel", "tcg") | ||
76 | - self.vm.add_args("-cpu", "max,lpa2=off") | ||
77 | - self.vm.add_args("-machine", "virt,gic-version=2") | ||
78 | - self.add_common_args() | ||
79 | - self.launch_and_wait(set_up_ssh_connection=False) | ||
80 | - | ||
81 | - @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') | ||
82 | - def test_fedora_cloud_tcg_gicv3(self): | ||
83 | - """ | ||
84 | - :avocado: tags=accel:tcg | ||
85 | - :avocado: tags=cpu:max | ||
86 | - :avocado: tags=device:gicv3 | ||
87 | - """ | ||
88 | - self.require_accelerator("tcg") | ||
89 | - self.vm.add_args("-accel", "tcg") | ||
90 | - self.vm.add_args("-cpu", "max,lpa2=off") | ||
91 | - self.vm.add_args("-machine", "virt,gic-version=3") | ||
92 | - self.add_common_args() | ||
93 | - self.launch_and_wait(set_up_ssh_connection=False) | ||
94 | - | ||
95 | def test_virt_kvm(self): | ||
96 | """ | ||
97 | :avocado: tags=accel:kvm | ||
98 | @@ -XXX,XX +XXX,XX @@ def test_virt_kvm(self): | ||
99 | self.require_accelerator("kvm") | ||
100 | self.vm.add_args("-accel", "kvm") | ||
101 | self.vm.add_args("-machine", "virt,gic-version=host") | ||
102 | - self.add_common_args() | ||
103 | + self.vm.add_args('-bios', | ||
104 | + os.path.join(BUILD_DIR, 'pc-bios', | ||
105 | + 'edk2-aarch64-code.fd')) | ||
106 | + self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0') | ||
107 | + self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom') | ||
108 | self.launch_and_wait(set_up_ssh_connection=False) | ||
109 | |||
110 | |||
111 | diff --git a/tests/avocado/machine_aarch64_virt.py b/tests/avocado/machine_aarch64_virt.py | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/tests/avocado/machine_aarch64_virt.py | ||
114 | +++ b/tests/avocado/machine_aarch64_virt.py | ||
115 | @@ -XXX,XX +XXX,XX @@ | ||
116 | |||
117 | import time | ||
118 | import os | ||
119 | +import logging | ||
120 | |||
121 | from avocado_qemu import QemuSystemTest | ||
122 | from avocado_qemu import wait_for_console_pattern | ||
123 | from avocado_qemu import exec_command | ||
124 | from avocado_qemu import BUILD_DIR | ||
125 | +from avocado.utils import process | ||
126 | +from avocado.utils.path import find_command | ||
127 | |||
128 | class Aarch64VirtMachine(QemuSystemTest): | ||
129 | KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' | ||
130 | @@ -XXX,XX +XXX,XX @@ def test_alpine_virt_tcg_gic_max(self): | ||
131 | self.wait_for_console_pattern('Welcome to Alpine Linux 3.16') | ||
132 | |||
133 | |||
134 | - def test_aarch64_virt(self): | ||
135 | + def common_aarch64_virt(self, machine): | ||
136 | """ | ||
137 | - :avocado: tags=arch:aarch64 | ||
138 | - :avocado: tags=machine:virt | ||
139 | - :avocado: tags=accel:tcg | ||
140 | - :avocado: tags=cpu:max | ||
141 | + Common code to launch basic virt machine with kernel+initrd | ||
142 | + and a scratch disk. | ||
143 | """ | ||
144 | + logger = logging.getLogger('aarch64_virt') | ||
145 | + | ||
146 | kernel_url = ('https://fileserver.linaro.org/s/' | ||
147 | 'z6B2ARM7DQT3HWN/download') | ||
148 | - | ||
149 | kernel_hash = 'ed11daab50c151dde0e1e9c9cb8b2d9bd3215347' | ||
150 | kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) | ||
151 | |||
152 | @@ -XXX,XX +XXX,XX @@ def test_aarch64_virt(self): | ||
153 | 'console=ttyAMA0') | ||
154 | self.require_accelerator("tcg") | ||
155 | self.vm.add_args('-cpu', 'max,pauth-impdef=on', | ||
156 | + '-machine', machine, | ||
157 | '-accel', 'tcg', | ||
158 | '-kernel', kernel_path, | ||
159 | '-append', kernel_command_line) | ||
160 | + | ||
161 | + # A RNG offers an easy way to generate a few IRQs | ||
162 | + self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0') | ||
163 | + self.vm.add_args('-object', | ||
164 | + 'rng-random,id=rng0,filename=/dev/urandom') | ||
165 | + | ||
166 | + # Also add a scratch block device | ||
167 | + logger.info('creating scratch qcow2 image') | ||
168 | + image_path = os.path.join(self.workdir, 'scratch.qcow2') | ||
169 | + qemu_img = os.path.join(BUILD_DIR, 'qemu-img') | ||
170 | + if not os.path.exists(qemu_img): | ||
171 | + qemu_img = find_command('qemu-img', False) | ||
172 | + if qemu_img is False: | ||
173 | + self.cancel('Could not find "qemu-img", which is required to ' | ||
174 | + 'create the temporary qcow2 image') | ||
175 | + cmd = '%s create -f qcow2 %s 8M' % (qemu_img, image_path) | ||
176 | + process.run(cmd) | ||
177 | + | ||
178 | + # Add the device | ||
179 | + self.vm.add_args('-blockdev', | ||
180 | + f"driver=qcow2,file.driver=file,file.filename={image_path},node-name=scratch") | ||
181 | + self.vm.add_args('-device', | ||
182 | + 'virtio-blk-device,drive=scratch') | ||
183 | + | ||
184 | self.vm.launch() | ||
185 | self.wait_for_console_pattern('Welcome to Buildroot') | ||
186 | time.sleep(0.1) | ||
187 | exec_command(self, 'root') | ||
188 | time.sleep(0.1) | ||
189 | + exec_command(self, 'dd if=/dev/hwrng of=/dev/vda bs=512 count=4') | ||
190 | + time.sleep(0.1) | ||
191 | + exec_command(self, 'md5sum /dev/vda') | ||
192 | + time.sleep(0.1) | ||
193 | + exec_command(self, 'cat /proc/interrupts') | ||
194 | + time.sleep(0.1) | ||
195 | exec_command(self, 'cat /proc/self/maps') | ||
196 | time.sleep(0.1) | ||
197 | + | ||
198 | + def test_aarch64_virt_gicv3(self): | ||
199 | + """ | ||
200 | + :avocado: tags=arch:aarch64 | ||
201 | + :avocado: tags=machine:virt | ||
202 | + :avocado: tags=accel:tcg | ||
203 | + :avocado: tags=cpu:max | ||
204 | + """ | ||
205 | + self.common_aarch64_virt("virt,gic_version=3") | ||
206 | + | ||
207 | + def test_aarch64_virt_gicv2(self): | ||
208 | + """ | ||
209 | + :avocado: tags=arch:aarch64 | ||
210 | + :avocado: tags=machine:virt | ||
211 | + :avocado: tags=accel:tcg | ||
212 | + :avocado: tags=cpu:max | ||
213 | + """ | ||
214 | + self.common_aarch64_virt("virt,gic-version=2") | ||
215 | -- | ||
216 | 2.34.1 | ||
217 | |||
218 | diff view generated by jsdifflib |
1 | Convert the TYPE_ARM_SMMUV3 device to 3-phase reset. The legacy | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | reset method doesn't do anything that's invalid in the hold phase, so | ||
3 | the conversion only requires changing it to a hold phase method, and | ||
4 | using the 3-phase versions of the "save the parent reset method and | ||
5 | chain to it" code. | ||
6 | 2 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | GBPA register can be used to globally abort all |
4 | transactions. | ||
5 | |||
6 | It is described in the SMMU manual in "6.3.14 SMMU_GBPA". | ||
7 | ABORT reset value is IMPLEMENTATION DEFINED, it is chosen to | ||
8 | be zero(Do not abort incoming transactions). | ||
9 | |||
10 | Other fields have default values of Use Incoming. | ||
11 | |||
12 | If UPDATE is not set, the write is ignored. This is the only permitted | ||
13 | behavior in SMMUv3.2 and later.(6.3.14.1 Update procedure) | ||
14 | |||
15 | As this patch adds a new state to the SMMU (GBPA), it is added | ||
16 | in a new subsection for forward migration compatibility. | ||
17 | GBPA is only migrated if its value is different from the reset value. | ||
18 | It does this to be backward migration compatible if SW didn't write | ||
19 | the register. | ||
20 | |||
21 | Signed-off-by: Mostafa Saleh <smostafa@google.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 23 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 24 | Message-id: 20230214094009.2445653-1-smostafa@google.com |
11 | Message-id: 20221109161444.3397405-3-peter.maydell@linaro.org | 25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | 27 | --- |
13 | include/hw/arm/smmuv3.h | 2 +- | 28 | hw/arm/smmuv3-internal.h | 7 +++++++ |
14 | hw/arm/smmuv3.c | 12 ++++++++---- | 29 | include/hw/arm/smmuv3.h | 1 + |
15 | 2 files changed, 9 insertions(+), 5 deletions(-) | 30 | hw/arm/smmuv3.c | 43 +++++++++++++++++++++++++++++++++++++++- |
31 | 3 files changed, 50 insertions(+), 1 deletion(-) | ||
16 | 32 | ||
33 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/hw/arm/smmuv3-internal.h | ||
36 | +++ b/hw/arm/smmuv3-internal.h | ||
37 | @@ -XXX,XX +XXX,XX @@ REG32(CR0ACK, 0x24) | ||
38 | REG32(CR1, 0x28) | ||
39 | REG32(CR2, 0x2c) | ||
40 | REG32(STATUSR, 0x40) | ||
41 | +REG32(GBPA, 0x44) | ||
42 | + FIELD(GBPA, ABORT, 20, 1) | ||
43 | + FIELD(GBPA, UPDATE, 31, 1) | ||
44 | + | ||
45 | +/* Use incoming. */ | ||
46 | +#define SMMU_GBPA_RESET_VAL 0x1000 | ||
47 | + | ||
48 | REG32(IRQ_CTRL, 0x50) | ||
49 | FIELD(IRQ_CTRL, GERROR_IRQEN, 0, 1) | ||
50 | FIELD(IRQ_CTRL, PRI_IRQEN, 1, 1) | ||
17 | diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h | 51 | diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h |
18 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/smmuv3.h | 53 | --- a/include/hw/arm/smmuv3.h |
20 | +++ b/include/hw/arm/smmuv3.h | 54 | +++ b/include/hw/arm/smmuv3.h |
21 | @@ -XXX,XX +XXX,XX @@ struct SMMUv3Class { | 55 | @@ -XXX,XX +XXX,XX @@ struct SMMUv3State { |
22 | /*< public >*/ | 56 | uint32_t cr[3]; |
23 | 57 | uint32_t cr0ack; | |
24 | DeviceRealize parent_realize; | 58 | uint32_t statusr; |
25 | - DeviceReset parent_reset; | 59 | + uint32_t gbpa; |
26 | + ResettablePhases parent_phases; | 60 | uint32_t irq_ctrl; |
27 | }; | 61 | uint32_t gerror; |
28 | 62 | uint32_t gerrorn; | |
29 | #define TYPE_ARM_SMMUV3 "arm-smmuv3" | ||
30 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | 63 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
31 | index XXXXXXX..XXXXXXX 100644 | 64 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/hw/arm/smmuv3.c | 65 | --- a/hw/arm/smmuv3.c |
33 | +++ b/hw/arm/smmuv3.c | 66 | +++ b/hw/arm/smmuv3.c |
34 | @@ -XXX,XX +XXX,XX @@ static void smmu_init_irq(SMMUv3State *s, SysBusDevice *dev) | 67 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s) |
68 | s->gerror = 0; | ||
69 | s->gerrorn = 0; | ||
70 | s->statusr = 0; | ||
71 | + s->gbpa = SMMU_GBPA_RESET_VAL; | ||
72 | } | ||
73 | |||
74 | static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr, STE *buf, | ||
75 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
76 | qemu_mutex_lock(&s->mutex); | ||
77 | |||
78 | if (!smmu_enabled(s)) { | ||
79 | - status = SMMU_TRANS_DISABLE; | ||
80 | + if (FIELD_EX32(s->gbpa, GBPA, ABORT)) { | ||
81 | + status = SMMU_TRANS_ABORT; | ||
82 | + } else { | ||
83 | + status = SMMU_TRANS_DISABLE; | ||
84 | + } | ||
85 | goto epilogue; | ||
35 | } | 86 | } |
36 | } | 87 | |
37 | 88 | @@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_writel(SMMUv3State *s, hwaddr offset, | |
38 | -static void smmu_reset(DeviceState *dev) | 89 | case A_GERROR_IRQ_CFG2: |
39 | +static void smmu_reset_hold(Object *obj) | 90 | s->gerror_irq_cfg2 = data; |
40 | { | 91 | return MEMTX_OK; |
41 | - SMMUv3State *s = ARM_SMMUV3(dev); | 92 | + case A_GBPA: |
42 | + SMMUv3State *s = ARM_SMMUV3(obj); | 93 | + /* |
43 | SMMUv3Class *c = ARM_SMMUV3_GET_CLASS(s); | 94 | + * If UPDATE is not set, the write is ignored. This is the only |
44 | 95 | + * permitted behavior in SMMUv3.2 and later. | |
45 | - c->parent_reset(dev); | 96 | + */ |
46 | + if (c->parent_phases.hold) { | 97 | + if (data & R_GBPA_UPDATE_MASK) { |
47 | + c->parent_phases.hold(obj); | 98 | + /* Ignore update bit as write is synchronous. */ |
99 | + s->gbpa = data & ~R_GBPA_UPDATE_MASK; | ||
100 | + } | ||
101 | + return MEMTX_OK; | ||
102 | case A_STRTAB_BASE: /* 64b */ | ||
103 | s->strtab_base = deposit64(s->strtab_base, 0, 32, data); | ||
104 | return MEMTX_OK; | ||
105 | @@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_readl(SMMUv3State *s, hwaddr offset, | ||
106 | case A_STATUSR: | ||
107 | *data = s->statusr; | ||
108 | return MEMTX_OK; | ||
109 | + case A_GBPA: | ||
110 | + *data = s->gbpa; | ||
111 | + return MEMTX_OK; | ||
112 | case A_IRQ_CTRL: | ||
113 | case A_IRQ_CTRL_ACK: | ||
114 | *data = s->irq_ctrl; | ||
115 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3_queue = { | ||
116 | }, | ||
117 | }; | ||
118 | |||
119 | +static bool smmuv3_gbpa_needed(void *opaque) | ||
120 | +{ | ||
121 | + SMMUv3State *s = opaque; | ||
122 | + | ||
123 | + /* Only migrate GBPA if it has different reset value. */ | ||
124 | + return s->gbpa != SMMU_GBPA_RESET_VAL; | ||
125 | +} | ||
126 | + | ||
127 | +static const VMStateDescription vmstate_gbpa = { | ||
128 | + .name = "smmuv3/gbpa", | ||
129 | + .version_id = 1, | ||
130 | + .minimum_version_id = 1, | ||
131 | + .needed = smmuv3_gbpa_needed, | ||
132 | + .fields = (VMStateField[]) { | ||
133 | + VMSTATE_UINT32(gbpa, SMMUv3State), | ||
134 | + VMSTATE_END_OF_LIST() | ||
48 | + } | 135 | + } |
49 | 136 | +}; | |
50 | smmuv3_init_regs(s); | 137 | + |
51 | } | 138 | static const VMStateDescription vmstate_smmuv3 = { |
52 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_instance_init(Object *obj) | 139 | .name = "smmuv3", |
53 | static void smmuv3_class_init(ObjectClass *klass, void *data) | 140 | .version_id = 1, |
54 | { | 141 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3 = { |
55 | DeviceClass *dc = DEVICE_CLASS(klass); | 142 | |
56 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | 143 | VMSTATE_END_OF_LIST(), |
57 | SMMUv3Class *c = ARM_SMMUV3_CLASS(klass); | 144 | }, |
58 | 145 | + .subsections = (const VMStateDescription * []) { | |
59 | dc->vmsd = &vmstate_smmuv3; | 146 | + &vmstate_gbpa, |
60 | - device_class_set_parent_reset(dc, smmu_reset, &c->parent_reset); | 147 | + NULL |
61 | + resettable_class_set_parent_phases(rc, NULL, smmu_reset_hold, NULL, | 148 | + } |
62 | + &c->parent_phases); | 149 | }; |
63 | c->parent_realize = dc->realize; | 150 | |
64 | dc->realize = smmu_realize; | 151 | static void smmuv3_instance_init(Object *obj) |
65 | } | ||
66 | -- | 152 | -- |
67 | 2.25.1 | 153 | 2.34.1 |
68 | |||
69 | diff view generated by jsdifflib |
1 | Convert the TYPE_ARM_GICV3_COMMON parent class to 3-phase reset. | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Since commit acc0b8b05a when running the ZynqMP ZCU102 board with | ||
4 | a QEMU configured using --without-default-devices, we get: | ||
5 | |||
6 | $ qemu-system-aarch64 -M xlnx-zcu102 | ||
7 | qemu-system-aarch64: missing object type 'usb_dwc3' | ||
8 | Abort trap: 6 | ||
9 | |||
10 | Fix by adding the missing Kconfig dependency. | ||
11 | |||
12 | Fixes: acc0b8b05a ("hw/arm/xlnx-zynqmp: Connect ZynqMP's USB controllers") | ||
13 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
14 | Message-id: 20230216092327.2203-1-philmd@linaro.org | ||
15 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Message-id: 20221109161444.3397405-6-peter.maydell@linaro.org | ||
7 | --- | 17 | --- |
8 | hw/intc/arm_gicv3_common.c | 7 ++++--- | 18 | hw/arm/Kconfig | 1 + |
9 | 1 file changed, 4 insertions(+), 3 deletions(-) | 19 | 1 file changed, 1 insertion(+) |
10 | 20 | ||
11 | diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c | 21 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
12 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/intc/arm_gicv3_common.c | 23 | --- a/hw/arm/Kconfig |
14 | +++ b/hw/intc/arm_gicv3_common.c | 24 | +++ b/hw/arm/Kconfig |
15 | @@ -XXX,XX +XXX,XX @@ static void arm_gicv3_finalize(Object *obj) | 25 | @@ -XXX,XX +XXX,XX @@ config XLNX_ZYNQMP_ARM |
16 | g_free(s->redist_region_count); | 26 | select XLNX_CSU_DMA |
17 | } | 27 | select XLNX_ZYNQMP |
18 | 28 | select XLNX_ZDMA | |
19 | -static void arm_gicv3_common_reset(DeviceState *dev) | 29 | + select USB_DWC3 |
20 | +static void arm_gicv3_common_reset_hold(Object *obj) | 30 | |
21 | { | 31 | config XLNX_VERSAL |
22 | - GICv3State *s = ARM_GICV3_COMMON(dev); | 32 | bool |
23 | + GICv3State *s = ARM_GICV3_COMMON(obj); | ||
24 | int i; | ||
25 | |||
26 | for (i = 0; i < s->num_cpu; i++) { | ||
27 | @@ -XXX,XX +XXX,XX @@ static Property arm_gicv3_common_properties[] = { | ||
28 | static void arm_gicv3_common_class_init(ObjectClass *klass, void *data) | ||
29 | { | ||
30 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
31 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
32 | ARMLinuxBootIfClass *albifc = ARM_LINUX_BOOT_IF_CLASS(klass); | ||
33 | |||
34 | - dc->reset = arm_gicv3_common_reset; | ||
35 | + rc->phases.hold = arm_gicv3_common_reset_hold; | ||
36 | dc->realize = arm_gicv3_common_realize; | ||
37 | device_class_set_props(dc, arm_gicv3_common_properties); | ||
38 | dc->vmsd = &vmstate_gicv3; | ||
39 | -- | 33 | -- |
40 | 2.25.1 | 34 | 2.34.1 |
41 | 35 | ||
42 | 36 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Cornelia Huck <cohuck@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | The 3 high memory regions are usually enabled by default, but they may | 3 | Just use current_accel_name() directly. |
4 | be not used. For example, VIRT_HIGH_GIC_REDIST2 isn't needed by GICv2. | ||
5 | This leads to waste in the PA space. | ||
6 | 4 | ||
7 | Add properties ("highmem-redists", "highmem-ecam", "highmem-mmio") to | 5 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> |
8 | allow users selectively disable them if needed. After that, the high | ||
9 | memory region for GICv3 or GICv4 redistributor can be disabled by user, | ||
10 | the number of maximal supported CPUs needs to be calculated based on | ||
11 | 'vms->highmem_redists'. The follow-up error message is also improved | ||
12 | to indicate if the high memory region for GICv3 and GICv4 has been | ||
13 | enabled or not. | ||
14 | |||
15 | Suggested-by: Marc Zyngier <maz@kernel.org> | ||
16 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
17 | Reviewed-by: Marc Zyngier <maz@kernel.org> | ||
18 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
19 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 6 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
20 | Message-id: 20221029224307.138822-8-gshan@redhat.com | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 9 | --- |
23 | docs/system/arm/virt.rst | 13 +++++++ | 10 | hw/arm/virt.c | 6 +++--- |
24 | hw/arm/virt.c | 75 ++++++++++++++++++++++++++++++++++++++-- | 11 | 1 file changed, 3 insertions(+), 3 deletions(-) |
25 | 2 files changed, 86 insertions(+), 2 deletions(-) | ||
26 | 12 | ||
27 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/docs/system/arm/virt.rst | ||
30 | +++ b/docs/system/arm/virt.rst | ||
31 | @@ -XXX,XX +XXX,XX @@ compact-highmem | ||
32 | Set ``on``/``off`` to enable/disable the compact layout for high memory regions. | ||
33 | The default is ``on`` for machine types later than ``virt-7.2``. | ||
34 | |||
35 | +highmem-redists | ||
36 | + Set ``on``/``off`` to enable/disable the high memory region for GICv3 or | ||
37 | + GICv4 redistributor. The default is ``on``. Setting this to ``off`` will | ||
38 | + limit the maximum number of CPUs when GICv3 or GICv4 is used. | ||
39 | + | ||
40 | +highmem-ecam | ||
41 | + Set ``on``/``off`` to enable/disable the high memory region for PCI ECAM. | ||
42 | + The default is ``on`` for machine types later than ``virt-3.0``. | ||
43 | + | ||
44 | +highmem-mmio | ||
45 | + Set ``on``/``off`` to enable/disable the high memory region for PCI MMIO. | ||
46 | + The default is ``on``. | ||
47 | + | ||
48 | gic-version | ||
49 | Specify the version of the Generic Interrupt Controller (GIC) to provide. | ||
50 | Valid values are: | ||
51 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 13 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
52 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/hw/arm/virt.c | 15 | --- a/hw/arm/virt.c |
54 | +++ b/hw/arm/virt.c | 16 | +++ b/hw/arm/virt.c |
55 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 17 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
56 | if (vms->gic_version == VIRT_GIC_VERSION_2) { | 18 | if (vms->secure && (kvm_enabled() || hvf_enabled())) { |
57 | virt_max_cpus = GIC_NCPU; | 19 | error_report("mach-virt: %s does not support providing " |
58 | } else { | 20 | "Security extensions (TrustZone) to the guest CPU", |
59 | - virt_max_cpus = virt_redist_capacity(vms, VIRT_GIC_REDIST) + | 21 | - kvm_enabled() ? "KVM" : "HVF"); |
60 | - virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2); | 22 | + current_accel_name()); |
61 | + virt_max_cpus = virt_redist_capacity(vms, VIRT_GIC_REDIST); | ||
62 | + if (vms->highmem_redists) { | ||
63 | + virt_max_cpus += virt_redist_capacity(vms, VIRT_HIGH_GIC_REDIST2); | ||
64 | + } | ||
65 | } | ||
66 | |||
67 | if (max_cpus > virt_max_cpus) { | ||
68 | error_report("Number of SMP CPUs requested (%d) exceeds max CPUs " | ||
69 | "supported by machine 'mach-virt' (%d)", | ||
70 | max_cpus, virt_max_cpus); | ||
71 | + if (vms->gic_version != VIRT_GIC_VERSION_2 && !vms->highmem_redists) { | ||
72 | + error_printf("Try 'highmem-redists=on' for more CPUs\n"); | ||
73 | + } | ||
74 | + | ||
75 | exit(1); | 23 | exit(1); |
76 | } | 24 | } |
77 | 25 | ||
78 | @@ -XXX,XX +XXX,XX @@ static void virt_set_compact_highmem(Object *obj, bool value, Error **errp) | 26 | if (vms->virt && (kvm_enabled() || hvf_enabled())) { |
79 | vms->highmem_compact = value; | 27 | error_report("mach-virt: %s does not support providing " |
80 | } | 28 | "Virtualization extensions to the guest CPU", |
81 | 29 | - kvm_enabled() ? "KVM" : "HVF"); | |
82 | +static bool virt_get_highmem_redists(Object *obj, Error **errp) | 30 | + current_accel_name()); |
83 | +{ | 31 | exit(1); |
84 | + VirtMachineState *vms = VIRT_MACHINE(obj); | 32 | } |
85 | + | 33 | |
86 | + return vms->highmem_redists; | 34 | if (vms->mte && (kvm_enabled() || hvf_enabled())) { |
87 | +} | 35 | error_report("mach-virt: %s does not support providing " |
88 | + | 36 | "MTE to the guest CPU", |
89 | +static void virt_set_highmem_redists(Object *obj, bool value, Error **errp) | 37 | - kvm_enabled() ? "KVM" : "HVF"); |
90 | +{ | 38 | + current_accel_name()); |
91 | + VirtMachineState *vms = VIRT_MACHINE(obj); | 39 | exit(1); |
92 | + | 40 | } |
93 | + vms->highmem_redists = value; | 41 | |
94 | +} | ||
95 | + | ||
96 | +static bool virt_get_highmem_ecam(Object *obj, Error **errp) | ||
97 | +{ | ||
98 | + VirtMachineState *vms = VIRT_MACHINE(obj); | ||
99 | + | ||
100 | + return vms->highmem_ecam; | ||
101 | +} | ||
102 | + | ||
103 | +static void virt_set_highmem_ecam(Object *obj, bool value, Error **errp) | ||
104 | +{ | ||
105 | + VirtMachineState *vms = VIRT_MACHINE(obj); | ||
106 | + | ||
107 | + vms->highmem_ecam = value; | ||
108 | +} | ||
109 | + | ||
110 | +static bool virt_get_highmem_mmio(Object *obj, Error **errp) | ||
111 | +{ | ||
112 | + VirtMachineState *vms = VIRT_MACHINE(obj); | ||
113 | + | ||
114 | + return vms->highmem_mmio; | ||
115 | +} | ||
116 | + | ||
117 | +static void virt_set_highmem_mmio(Object *obj, bool value, Error **errp) | ||
118 | +{ | ||
119 | + VirtMachineState *vms = VIRT_MACHINE(obj); | ||
120 | + | ||
121 | + vms->highmem_mmio = value; | ||
122 | +} | ||
123 | + | ||
124 | + | ||
125 | static bool virt_get_its(Object *obj, Error **errp) | ||
126 | { | ||
127 | VirtMachineState *vms = VIRT_MACHINE(obj); | ||
128 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data) | ||
129 | "Set on/off to enable/disable compact " | ||
130 | "layout for high memory regions"); | ||
131 | |||
132 | + object_class_property_add_bool(oc, "highmem-redists", | ||
133 | + virt_get_highmem_redists, | ||
134 | + virt_set_highmem_redists); | ||
135 | + object_class_property_set_description(oc, "highmem-redists", | ||
136 | + "Set on/off to enable/disable high " | ||
137 | + "memory region for GICv3 or GICv4 " | ||
138 | + "redistributor"); | ||
139 | + | ||
140 | + object_class_property_add_bool(oc, "highmem-ecam", | ||
141 | + virt_get_highmem_ecam, | ||
142 | + virt_set_highmem_ecam); | ||
143 | + object_class_property_set_description(oc, "highmem-ecam", | ||
144 | + "Set on/off to enable/disable high " | ||
145 | + "memory region for PCI ECAM"); | ||
146 | + | ||
147 | + object_class_property_add_bool(oc, "highmem-mmio", | ||
148 | + virt_get_highmem_mmio, | ||
149 | + virt_set_highmem_mmio); | ||
150 | + object_class_property_set_description(oc, "highmem-mmio", | ||
151 | + "Set on/off to enable/disable high " | ||
152 | + "memory region for PCI MMIO"); | ||
153 | + | ||
154 | object_class_property_add_str(oc, "gic-version", virt_get_gic_version, | ||
155 | virt_set_gic_version); | ||
156 | object_class_property_set_description(oc, "gic-version", | ||
157 | -- | 42 | -- |
158 | 2.25.1 | 43 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | There are three high memory regions, which are VIRT_HIGH_REDIST2, | 3 | Havard is no longer working on the Nuvoton systems for a while |
4 | VIRT_HIGH_PCIE_ECAM and VIRT_HIGH_PCIE_MMIO. Their base addresses | 4 | and won't be able to do any work on it in the future. So I'll |
5 | are floating on highest RAM address. However, they can be disabled | 5 | take over maintaining the Nuvoton system from him. |
6 | in several cases. | ||
7 | 6 | ||
8 | (1) One specific high memory region is likely to be disabled by | 7 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
9 | code by toggling vms->highmem_{redists, ecam, mmio}. | 8 | Acked-by: Havard Skinnemoen <hskinnemoen@google.com> |
10 | 9 | Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org> | |
11 | (2) VIRT_HIGH_PCIE_ECAM region is disabled on machine, which is | 10 | Message-id: 20230208235433.3989937-2-wuhaotsh@google.com |
12 | 'virt-2.12' or ealier than it. | ||
13 | |||
14 | (3) VIRT_HIGH_PCIE_ECAM region is disabled when firmware is loaded | ||
15 | on 32-bits system. | ||
16 | |||
17 | (4) One specific high memory region is disabled when it breaks the | ||
18 | PA space limit. | ||
19 | |||
20 | The current implementation of virt_set_{memmap, high_memmap}() isn't | ||
21 | optimized because the high memory region's PA space is always reserved, | ||
22 | regardless of whatever the actual state in the corresponding | ||
23 | vms->highmem_{redists, ecam, mmio} flag. In the code, 'base' and | ||
24 | 'vms->highest_gpa' are always increased for case (1), (2) and (3). | ||
25 | It's unnecessary since the assigned PA space for the disabled high | ||
26 | memory region won't be used afterwards. | ||
27 | |||
28 | Improve the address assignment for those three high memory region by | ||
29 | skipping the address assignment for one specific high memory region if | ||
30 | it has been disabled in case (1), (2) and (3). The memory layout may | ||
31 | be changed after the improvement is applied, which leads to potential | ||
32 | migration breakage. So 'vms->highmem_compact' is added to control if | ||
33 | the improvement should be applied. For now, 'vms->highmem_compact' is | ||
34 | set to false, meaning that we don't have memory layout change until it | ||
35 | becomes configurable through property 'compact-highmem' in next patch. | ||
36 | |||
37 | Signed-off-by: Gavin Shan <gshan@redhat.com> | ||
38 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
39 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
40 | Reviewed-by: Marc Zyngier <maz@kernel.org> | ||
41 | Tested-by: Zhenyu Zhang <zhenyzha@redhat.com> | ||
42 | Message-id: 20221029224307.138822-6-gshan@redhat.com | ||
43 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
44 | --- | 12 | --- |
45 | include/hw/arm/virt.h | 1 + | 13 | MAINTAINERS | 2 +- |
46 | hw/arm/virt.c | 15 ++++++++++----- | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
47 | 2 files changed, 11 insertions(+), 5 deletions(-) | ||
48 | 15 | ||
49 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | 16 | diff --git a/MAINTAINERS b/MAINTAINERS |
50 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/include/hw/arm/virt.h | 18 | --- a/MAINTAINERS |
52 | +++ b/include/hw/arm/virt.h | 19 | +++ b/MAINTAINERS |
53 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineState { | 20 | @@ -XXX,XX +XXX,XX @@ F: include/hw/net/mv88w8618_eth.h |
54 | PFlashCFI01 *flash[2]; | 21 | F: docs/system/arm/musicpal.rst |
55 | bool secure; | 22 | |
56 | bool highmem; | 23 | Nuvoton NPCM7xx |
57 | + bool highmem_compact; | 24 | -M: Havard Skinnemoen <hskinnemoen@google.com> |
58 | bool highmem_ecam; | 25 | M: Tyrone Ting <kfting@nuvoton.com> |
59 | bool highmem_mmio; | 26 | +M: Hao Wu <wuhaotsh@google.com> |
60 | bool highmem_redists; | 27 | L: qemu-arm@nongnu.org |
61 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 28 | S: Supported |
62 | index XXXXXXX..XXXXXXX 100644 | 29 | F: hw/*/npcm7xx* |
63 | --- a/hw/arm/virt.c | ||
64 | +++ b/hw/arm/virt.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static void virt_set_high_memmap(VirtMachineState *vms, | ||
66 | vms->memmap[i].size = region_size; | ||
67 | |||
68 | /* | ||
69 | - * Check each device to see if they fit in the PA space, | ||
70 | - * moving highest_gpa as we go. | ||
71 | + * Check each device to see if it fits in the PA space, | ||
72 | + * moving highest_gpa as we go. For compatibility, move | ||
73 | + * highest_gpa for disabled fitting devices as well, if | ||
74 | + * the compact layout has been disabled. | ||
75 | * | ||
76 | * For each device that doesn't fit, disable it. | ||
77 | */ | ||
78 | fits = (region_base + region_size) <= BIT_ULL(pa_bits); | ||
79 | - if (fits) { | ||
80 | - vms->highest_gpa = region_base + region_size - 1; | ||
81 | + *region_enabled &= fits; | ||
82 | + if (vms->highmem_compact && !*region_enabled) { | ||
83 | + continue; | ||
84 | } | ||
85 | |||
86 | - *region_enabled &= fits; | ||
87 | base = region_base + region_size; | ||
88 | + if (fits) { | ||
89 | + vms->highest_gpa = base - 1; | ||
90 | + } | ||
91 | } | ||
92 | } | ||
93 | |||
94 | -- | 30 | -- |
95 | 2.25.1 | 31 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | This introduces virt_get_high_memmap_enabled() helper, which returns | 3 | Nuvoton's PSPI is a general purpose SPI module which enables |
4 | the pointer to vms->highmem_{redists, ecam, mmio}. The pointer will | 4 | connections to SPI-based peripheral devices. |
5 | be used in the subsequent patches. | ||
6 | 5 | ||
7 | No functional change intended. | 6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
8 | 7 | Reviewed-by: Chris Rauer <crauer@google.com> | |
9 | Signed-off-by: Gavin Shan <gshan@redhat.com> | 8 | Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org> |
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 9 | Message-id: 20230208235433.3989937-3-wuhaotsh@google.com |
11 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
12 | Reviewed-by: Marc Zyngier <maz@kernel.org> | ||
13 | Tested-by: Zhenyu Zhang <zhenyzha@redhat.com> | ||
14 | Message-id: 20221029224307.138822-5-gshan@redhat.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 11 | --- |
17 | hw/arm/virt.c | 32 +++++++++++++++++++------------- | 12 | MAINTAINERS | 6 +- |
18 | 1 file changed, 19 insertions(+), 13 deletions(-) | 13 | include/hw/ssi/npcm_pspi.h | 53 +++++++++ |
14 | hw/ssi/npcm_pspi.c | 221 +++++++++++++++++++++++++++++++++++++ | ||
15 | hw/ssi/meson.build | 2 +- | ||
16 | hw/ssi/trace-events | 5 + | ||
17 | 5 files changed, 283 insertions(+), 4 deletions(-) | ||
18 | create mode 100644 include/hw/ssi/npcm_pspi.h | ||
19 | create mode 100644 hw/ssi/npcm_pspi.c | ||
19 | 20 | ||
20 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 21 | diff --git a/MAINTAINERS b/MAINTAINERS |
21 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/virt.c | 23 | --- a/MAINTAINERS |
23 | +++ b/hw/arm/virt.c | 24 | +++ b/MAINTAINERS |
24 | @@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) | 25 | @@ -XXX,XX +XXX,XX @@ M: Tyrone Ting <kfting@nuvoton.com> |
25 | return arm_cpu_mp_affinity(idx, clustersz); | 26 | M: Hao Wu <wuhaotsh@google.com> |
26 | } | 27 | L: qemu-arm@nongnu.org |
27 | 28 | S: Supported | |
28 | +static inline bool *virt_get_high_memmap_enabled(VirtMachineState *vms, | 29 | -F: hw/*/npcm7xx* |
29 | + int index) | 30 | -F: include/hw/*/npcm7xx* |
30 | +{ | 31 | -F: tests/qtest/npcm7xx* |
31 | + bool *enabled_array[] = { | 32 | +F: hw/*/npcm* |
32 | + &vms->highmem_redists, | 33 | +F: include/hw/*/npcm* |
33 | + &vms->highmem_ecam, | 34 | +F: tests/qtest/npcm* |
34 | + &vms->highmem_mmio, | 35 | F: pc-bios/npcm7xx_bootrom.bin |
35 | + }; | 36 | F: roms/vbootrom |
36 | + | 37 | F: docs/system/arm/nuvoton.rst |
37 | + assert(ARRAY_SIZE(extended_memmap) - VIRT_LOWMEMMAP_LAST == | 38 | diff --git a/include/hw/ssi/npcm_pspi.h b/include/hw/ssi/npcm_pspi.h |
38 | + ARRAY_SIZE(enabled_array)); | 39 | new file mode 100644 |
39 | + assert(index - VIRT_LOWMEMMAP_LAST < ARRAY_SIZE(enabled_array)); | 40 | index XXXXXXX..XXXXXXX |
40 | + | 41 | --- /dev/null |
41 | + return enabled_array[index - VIRT_LOWMEMMAP_LAST]; | 42 | +++ b/include/hw/ssi/npcm_pspi.h |
42 | +} | 43 | @@ -XXX,XX +XXX,XX @@ |
43 | + | 44 | +/* |
44 | static void virt_set_high_memmap(VirtMachineState *vms, | 45 | + * Nuvoton Peripheral SPI Module |
45 | hwaddr base, int pa_bits) | 46 | + * |
46 | { | 47 | + * Copyright 2023 Google LLC |
47 | hwaddr region_base, region_size; | 48 | + * |
48 | - bool fits; | 49 | + * This program is free software; you can redistribute it and/or modify it |
49 | + bool *region_enabled, fits; | 50 | + * under the terms of the GNU General Public License as published by the |
50 | int i; | 51 | + * Free Software Foundation; either version 2 of the License, or |
51 | 52 | + * (at your option) any later version. | |
52 | for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) { | 53 | + * |
53 | + region_enabled = virt_get_high_memmap_enabled(vms, i); | 54 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
54 | region_base = ROUND_UP(base, extended_memmap[i].size); | 55 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
55 | region_size = extended_memmap[i].size; | 56 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
56 | 57 | + * for more details. | |
57 | @@ -XXX,XX +XXX,XX @@ static void virt_set_high_memmap(VirtMachineState *vms, | 58 | + */ |
58 | vms->highest_gpa = region_base + region_size - 1; | 59 | +#ifndef NPCM_PSPI_H |
59 | } | 60 | +#define NPCM_PSPI_H |
60 | 61 | + | |
61 | - switch (i) { | 62 | +#include "hw/ssi/ssi.h" |
62 | - case VIRT_HIGH_GIC_REDIST2: | 63 | +#include "hw/sysbus.h" |
63 | - vms->highmem_redists &= fits; | 64 | + |
64 | - break; | 65 | +/* |
65 | - case VIRT_HIGH_PCIE_ECAM: | 66 | + * Number of registers in our device state structure. Don't change this without |
66 | - vms->highmem_ecam &= fits; | 67 | + * incrementing the version_id in the vmstate. |
67 | - break; | 68 | + */ |
68 | - case VIRT_HIGH_PCIE_MMIO: | 69 | +#define NPCM_PSPI_NR_REGS 3 |
69 | - vms->highmem_mmio &= fits; | 70 | + |
70 | - break; | 71 | +/** |
71 | - } | 72 | + * NPCMPSPIState - Device state for one Flash Interface Unit. |
72 | - | 73 | + * @parent: System bus device. |
73 | + *region_enabled &= fits; | 74 | + * @mmio: Memory region for register access. |
74 | base = region_base + region_size; | 75 | + * @spi: The SPI bus mastered by this controller. |
75 | } | 76 | + * @regs: Register contents. |
76 | } | 77 | + * @irq: The interrupt request queue for this module. |
78 | + * | ||
79 | + * Each PSPI has a shared bank of registers, and controls up to four chip | ||
80 | + * selects. Each chip select has a dedicated memory region which may be used to | ||
81 | + * read and write the flash connected to that chip select as if it were memory. | ||
82 | + */ | ||
83 | +typedef struct NPCMPSPIState { | ||
84 | + SysBusDevice parent; | ||
85 | + | ||
86 | + MemoryRegion mmio; | ||
87 | + | ||
88 | + SSIBus *spi; | ||
89 | + uint16_t regs[NPCM_PSPI_NR_REGS]; | ||
90 | + qemu_irq irq; | ||
91 | +} NPCMPSPIState; | ||
92 | + | ||
93 | +#define TYPE_NPCM_PSPI "npcm-pspi" | ||
94 | +OBJECT_DECLARE_SIMPLE_TYPE(NPCMPSPIState, NPCM_PSPI) | ||
95 | + | ||
96 | +#endif /* NPCM_PSPI_H */ | ||
97 | diff --git a/hw/ssi/npcm_pspi.c b/hw/ssi/npcm_pspi.c | ||
98 | new file mode 100644 | ||
99 | index XXXXXXX..XXXXXXX | ||
100 | --- /dev/null | ||
101 | +++ b/hw/ssi/npcm_pspi.c | ||
102 | @@ -XXX,XX +XXX,XX @@ | ||
103 | +/* | ||
104 | + * Nuvoton NPCM Peripheral SPI Module (PSPI) | ||
105 | + * | ||
106 | + * Copyright 2023 Google LLC | ||
107 | + * | ||
108 | + * This program is free software; you can redistribute it and/or modify it | ||
109 | + * under the terms of the GNU General Public License as published by the | ||
110 | + * Free Software Foundation; either version 2 of the License, or | ||
111 | + * (at your option) any later version. | ||
112 | + * | ||
113 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
114 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
115 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
116 | + * for more details. | ||
117 | + */ | ||
118 | + | ||
119 | +#include "qemu/osdep.h" | ||
120 | + | ||
121 | +#include "hw/irq.h" | ||
122 | +#include "hw/registerfields.h" | ||
123 | +#include "hw/ssi/npcm_pspi.h" | ||
124 | +#include "migration/vmstate.h" | ||
125 | +#include "qapi/error.h" | ||
126 | +#include "qemu/error-report.h" | ||
127 | +#include "qemu/log.h" | ||
128 | +#include "qemu/module.h" | ||
129 | +#include "qemu/units.h" | ||
130 | + | ||
131 | +#include "trace.h" | ||
132 | + | ||
133 | +REG16(PSPI_DATA, 0x0) | ||
134 | +REG16(PSPI_CTL1, 0x2) | ||
135 | + FIELD(PSPI_CTL1, SPIEN, 0, 1) | ||
136 | + FIELD(PSPI_CTL1, MOD, 2, 1) | ||
137 | + FIELD(PSPI_CTL1, EIR, 5, 1) | ||
138 | + FIELD(PSPI_CTL1, EIW, 6, 1) | ||
139 | + FIELD(PSPI_CTL1, SCM, 7, 1) | ||
140 | + FIELD(PSPI_CTL1, SCIDL, 8, 1) | ||
141 | + FIELD(PSPI_CTL1, SCDV, 9, 7) | ||
142 | +REG16(PSPI_STAT, 0x4) | ||
143 | + FIELD(PSPI_STAT, BSY, 0, 1) | ||
144 | + FIELD(PSPI_STAT, RBF, 1, 1) | ||
145 | + | ||
146 | +static void npcm_pspi_update_irq(NPCMPSPIState *s) | ||
147 | +{ | ||
148 | + int level = 0; | ||
149 | + | ||
150 | + /* Only fire IRQ when the module is enabled. */ | ||
151 | + if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, SPIEN)) { | ||
152 | + /* Update interrupt as BSY is cleared. */ | ||
153 | + if ((!FIELD_EX16(s->regs[R_PSPI_STAT], PSPI_STAT, BSY)) && | ||
154 | + FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, EIW)) { | ||
155 | + level = 1; | ||
156 | + } | ||
157 | + | ||
158 | + /* Update interrupt as RBF is set. */ | ||
159 | + if (FIELD_EX16(s->regs[R_PSPI_STAT], PSPI_STAT, RBF) && | ||
160 | + FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, EIR)) { | ||
161 | + level = 1; | ||
162 | + } | ||
163 | + } | ||
164 | + qemu_set_irq(s->irq, level); | ||
165 | +} | ||
166 | + | ||
167 | +static uint16_t npcm_pspi_read_data(NPCMPSPIState *s) | ||
168 | +{ | ||
169 | + uint16_t value = s->regs[R_PSPI_DATA]; | ||
170 | + | ||
171 | + /* Clear stat bits as the value are read out. */ | ||
172 | + s->regs[R_PSPI_STAT] = 0; | ||
173 | + | ||
174 | + return value; | ||
175 | +} | ||
176 | + | ||
177 | +static void npcm_pspi_write_data(NPCMPSPIState *s, uint16_t data) | ||
178 | +{ | ||
179 | + uint16_t value = 0; | ||
180 | + | ||
181 | + if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, MOD)) { | ||
182 | + value = ssi_transfer(s->spi, extract16(data, 8, 8)) << 8; | ||
183 | + } | ||
184 | + value |= ssi_transfer(s->spi, extract16(data, 0, 8)); | ||
185 | + s->regs[R_PSPI_DATA] = value; | ||
186 | + | ||
187 | + /* Mark data as available */ | ||
188 | + s->regs[R_PSPI_STAT] = R_PSPI_STAT_BSY_MASK | R_PSPI_STAT_RBF_MASK; | ||
189 | +} | ||
190 | + | ||
191 | +/* Control register read handler. */ | ||
192 | +static uint64_t npcm_pspi_ctrl_read(void *opaque, hwaddr addr, | ||
193 | + unsigned int size) | ||
194 | +{ | ||
195 | + NPCMPSPIState *s = opaque; | ||
196 | + uint16_t value; | ||
197 | + | ||
198 | + switch (addr) { | ||
199 | + case A_PSPI_DATA: | ||
200 | + value = npcm_pspi_read_data(s); | ||
201 | + break; | ||
202 | + | ||
203 | + case A_PSPI_CTL1: | ||
204 | + value = s->regs[R_PSPI_CTL1]; | ||
205 | + break; | ||
206 | + | ||
207 | + case A_PSPI_STAT: | ||
208 | + value = s->regs[R_PSPI_STAT]; | ||
209 | + break; | ||
210 | + | ||
211 | + default: | ||
212 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
213 | + "%s: write to invalid offset 0x%" PRIx64 "\n", | ||
214 | + DEVICE(s)->canonical_path, addr); | ||
215 | + return 0; | ||
216 | + } | ||
217 | + trace_npcm_pspi_ctrl_read(DEVICE(s)->canonical_path, addr, value); | ||
218 | + npcm_pspi_update_irq(s); | ||
219 | + | ||
220 | + return value; | ||
221 | +} | ||
222 | + | ||
223 | +/* Control register write handler. */ | ||
224 | +static void npcm_pspi_ctrl_write(void *opaque, hwaddr addr, uint64_t v, | ||
225 | + unsigned int size) | ||
226 | +{ | ||
227 | + NPCMPSPIState *s = opaque; | ||
228 | + uint16_t value = v; | ||
229 | + | ||
230 | + trace_npcm_pspi_ctrl_write(DEVICE(s)->canonical_path, addr, value); | ||
231 | + | ||
232 | + switch (addr) { | ||
233 | + case A_PSPI_DATA: | ||
234 | + npcm_pspi_write_data(s, value); | ||
235 | + break; | ||
236 | + | ||
237 | + case A_PSPI_CTL1: | ||
238 | + s->regs[R_PSPI_CTL1] = value; | ||
239 | + break; | ||
240 | + | ||
241 | + case A_PSPI_STAT: | ||
242 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
243 | + "%s: write to read-only register PSPI_STAT: 0x%08" | ||
244 | + PRIx64 "\n", DEVICE(s)->canonical_path, v); | ||
245 | + break; | ||
246 | + | ||
247 | + default: | ||
248 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
249 | + "%s: write to invalid offset 0x%" PRIx64 "\n", | ||
250 | + DEVICE(s)->canonical_path, addr); | ||
251 | + return; | ||
252 | + } | ||
253 | + npcm_pspi_update_irq(s); | ||
254 | +} | ||
255 | + | ||
256 | +static const MemoryRegionOps npcm_pspi_ctrl_ops = { | ||
257 | + .read = npcm_pspi_ctrl_read, | ||
258 | + .write = npcm_pspi_ctrl_write, | ||
259 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
260 | + .valid = { | ||
261 | + .min_access_size = 1, | ||
262 | + .max_access_size = 2, | ||
263 | + .unaligned = false, | ||
264 | + }, | ||
265 | + .impl = { | ||
266 | + .min_access_size = 2, | ||
267 | + .max_access_size = 2, | ||
268 | + .unaligned = false, | ||
269 | + }, | ||
270 | +}; | ||
271 | + | ||
272 | +static void npcm_pspi_enter_reset(Object *obj, ResetType type) | ||
273 | +{ | ||
274 | + NPCMPSPIState *s = NPCM_PSPI(obj); | ||
275 | + | ||
276 | + trace_npcm_pspi_enter_reset(DEVICE(obj)->canonical_path, type); | ||
277 | + memset(s->regs, 0, sizeof(s->regs)); | ||
278 | +} | ||
279 | + | ||
280 | +static void npcm_pspi_realize(DeviceState *dev, Error **errp) | ||
281 | +{ | ||
282 | + NPCMPSPIState *s = NPCM_PSPI(dev); | ||
283 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
284 | + Object *obj = OBJECT(dev); | ||
285 | + | ||
286 | + s->spi = ssi_create_bus(dev, "pspi"); | ||
287 | + memory_region_init_io(&s->mmio, obj, &npcm_pspi_ctrl_ops, s, | ||
288 | + "mmio", 4 * KiB); | ||
289 | + sysbus_init_mmio(sbd, &s->mmio); | ||
290 | + sysbus_init_irq(sbd, &s->irq); | ||
291 | +} | ||
292 | + | ||
293 | +static const VMStateDescription vmstate_npcm_pspi = { | ||
294 | + .name = "npcm-pspi", | ||
295 | + .version_id = 0, | ||
296 | + .minimum_version_id = 0, | ||
297 | + .fields = (VMStateField[]) { | ||
298 | + VMSTATE_UINT16_ARRAY(regs, NPCMPSPIState, NPCM_PSPI_NR_REGS), | ||
299 | + VMSTATE_END_OF_LIST(), | ||
300 | + }, | ||
301 | +}; | ||
302 | + | ||
303 | + | ||
304 | +static void npcm_pspi_class_init(ObjectClass *klass, void *data) | ||
305 | +{ | ||
306 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
307 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
308 | + | ||
309 | + dc->desc = "NPCM Peripheral SPI Module"; | ||
310 | + dc->realize = npcm_pspi_realize; | ||
311 | + dc->vmsd = &vmstate_npcm_pspi; | ||
312 | + rc->phases.enter = npcm_pspi_enter_reset; | ||
313 | +} | ||
314 | + | ||
315 | +static const TypeInfo npcm_pspi_types[] = { | ||
316 | + { | ||
317 | + .name = TYPE_NPCM_PSPI, | ||
318 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
319 | + .instance_size = sizeof(NPCMPSPIState), | ||
320 | + .class_init = npcm_pspi_class_init, | ||
321 | + }, | ||
322 | +}; | ||
323 | +DEFINE_TYPES(npcm_pspi_types); | ||
324 | diff --git a/hw/ssi/meson.build b/hw/ssi/meson.build | ||
325 | index XXXXXXX..XXXXXXX 100644 | ||
326 | --- a/hw/ssi/meson.build | ||
327 | +++ b/hw/ssi/meson.build | ||
328 | @@ -XXX,XX +XXX,XX @@ | ||
329 | softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_smc.c')) | ||
330 | softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-spi.c')) | ||
331 | -softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c')) | ||
332 | +softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c', 'npcm_pspi.c')) | ||
333 | softmmu_ss.add(when: 'CONFIG_PL022', if_true: files('pl022.c')) | ||
334 | softmmu_ss.add(when: 'CONFIG_SIFIVE_SPI', if_true: files('sifive_spi.c')) | ||
335 | softmmu_ss.add(when: 'CONFIG_SSI', if_true: files('ssi.c')) | ||
336 | diff --git a/hw/ssi/trace-events b/hw/ssi/trace-events | ||
337 | index XXXXXXX..XXXXXXX 100644 | ||
338 | --- a/hw/ssi/trace-events | ||
339 | +++ b/hw/ssi/trace-events | ||
340 | @@ -XXX,XX +XXX,XX @@ npcm7xx_fiu_ctrl_write(const char *id, uint64_t addr, uint32_t data) "%s offset: | ||
341 | npcm7xx_fiu_flash_read(const char *id, int cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64 | ||
342 | npcm7xx_fiu_flash_write(const char *id, unsigned cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64 | ||
343 | |||
344 | +# npcm_pspi.c | ||
345 | +npcm_pspi_enter_reset(const char *id, int reset_type) "%s reset type: %d" | ||
346 | +npcm_pspi_ctrl_read(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16 | ||
347 | +npcm_pspi_ctrl_write(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16 | ||
348 | + | ||
349 | # ibex_spi_host.c | ||
350 | |||
351 | ibex_spi_host_reset(const char *msg) "%s" | ||
77 | -- | 352 | -- |
78 | 2.25.1 | 353 | 2.34.1 | diff view generated by jsdifflib |
1 | For FEAT_EVT, the HCR_EL2.TICAB bit allows trapping of the ICIALLUIS | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | and IC IALLUIS cache maintenance instructions. | ||
3 | 2 | ||
4 | The HCR_EL2.TOCU bit traps all the other cache maintenance | 3 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
5 | instructions that operate to the point of unification: | 4 | Reviewed-by: Titus Rwantare <titusr@google.com> |
6 | AArch64 IC IVAU, IC IALLU, DC CVAU | 5 | Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org> |
7 | AArch32 ICIMVAU, ICIALLU, DCCMVAU | 6 | Message-id: 20230208235433.3989937-4-wuhaotsh@google.com |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | docs/system/arm/nuvoton.rst | 2 +- | ||
10 | include/hw/arm/npcm7xx.h | 2 ++ | ||
11 | hw/arm/npcm7xx.c | 25 +++++++++++++++++++++++-- | ||
12 | 3 files changed, 26 insertions(+), 3 deletions(-) | ||
8 | 13 | ||
9 | The two trap bits between them cover all of the cache maintenance | 14 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst |
10 | instructions which must also check the HCR_TPU flag. Turn the old | ||
11 | aa64_cacheop_pou_access() function into a helper function which takes | ||
12 | the set of HCR_EL2 flags to check as an argument, and call it from | ||
13 | new access_ticab() and access_tocu() functions as appropriate for | ||
14 | each cache op. | ||
15 | |||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | --- | ||
19 | target/arm/helper.c | 36 +++++++++++++++++++++++------------- | ||
20 | 1 file changed, 23 insertions(+), 13 deletions(-) | ||
21 | |||
22 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
23 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/helper.c | 16 | --- a/docs/system/arm/nuvoton.rst |
25 | +++ b/target/arm/helper.c | 17 | +++ b/docs/system/arm/nuvoton.rst |
26 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult aa64_cacheop_poc_access(CPUARMState *env, | 18 | @@ -XXX,XX +XXX,XX @@ Supported devices |
27 | return CP_ACCESS_OK; | 19 | * SMBus controller (SMBF) |
20 | * Ethernet controller (EMC) | ||
21 | * Tachometer | ||
22 | + * Peripheral SPI controller (PSPI) | ||
23 | |||
24 | Missing devices | ||
25 | --------------- | ||
26 | @@ -XXX,XX +XXX,XX @@ Missing devices | ||
27 | |||
28 | * Ethernet controller (GMAC) | ||
29 | * USB device (USBD) | ||
30 | - * Peripheral SPI controller (PSPI) | ||
31 | * SD/MMC host | ||
32 | * PECI interface | ||
33 | * PCI and PCIe root complex and bridges | ||
34 | diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/include/hw/arm/npcm7xx.h | ||
37 | +++ b/include/hw/arm/npcm7xx.h | ||
38 | @@ -XXX,XX +XXX,XX @@ | ||
39 | #include "hw/nvram/npcm7xx_otp.h" | ||
40 | #include "hw/timer/npcm7xx_timer.h" | ||
41 | #include "hw/ssi/npcm7xx_fiu.h" | ||
42 | +#include "hw/ssi/npcm_pspi.h" | ||
43 | #include "hw/usb/hcd-ehci.h" | ||
44 | #include "hw/usb/hcd-ohci.h" | ||
45 | #include "target/arm/cpu.h" | ||
46 | @@ -XXX,XX +XXX,XX @@ struct NPCM7xxState { | ||
47 | NPCM7xxFIUState fiu[2]; | ||
48 | NPCM7xxEMCState emc[2]; | ||
49 | NPCM7xxSDHCIState mmc; | ||
50 | + NPCMPSPIState pspi[2]; | ||
51 | }; | ||
52 | |||
53 | #define TYPE_NPCM7XX "npcm7xx" | ||
54 | diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/arm/npcm7xx.c | ||
57 | +++ b/hw/arm/npcm7xx.c | ||
58 | @@ -XXX,XX +XXX,XX @@ enum NPCM7xxInterrupt { | ||
59 | NPCM7XX_EMC1RX_IRQ = 15, | ||
60 | NPCM7XX_EMC1TX_IRQ, | ||
61 | NPCM7XX_MMC_IRQ = 26, | ||
62 | + NPCM7XX_PSPI2_IRQ = 28, | ||
63 | + NPCM7XX_PSPI1_IRQ = 31, | ||
64 | NPCM7XX_TIMER0_IRQ = 32, /* Timer Module 0 */ | ||
65 | NPCM7XX_TIMER1_IRQ, | ||
66 | NPCM7XX_TIMER2_IRQ, | ||
67 | @@ -XXX,XX +XXX,XX @@ static const hwaddr npcm7xx_emc_addr[] = { | ||
68 | 0xf0826000, | ||
69 | }; | ||
70 | |||
71 | +/* Register base address for each PSPI Module */ | ||
72 | +static const hwaddr npcm7xx_pspi_addr[] = { | ||
73 | + 0xf0200000, | ||
74 | + 0xf0201000, | ||
75 | +}; | ||
76 | + | ||
77 | static const struct { | ||
78 | hwaddr regs_addr; | ||
79 | uint32_t unconnected_pins; | ||
80 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_init(Object *obj) | ||
81 | object_initialize_child(obj, "emc[*]", &s->emc[i], TYPE_NPCM7XX_EMC); | ||
82 | } | ||
83 | |||
84 | + for (i = 0; i < ARRAY_SIZE(s->pspi); i++) { | ||
85 | + object_initialize_child(obj, "pspi[*]", &s->pspi[i], TYPE_NPCM_PSPI); | ||
86 | + } | ||
87 | + | ||
88 | object_initialize_child(obj, "mmc", &s->mmc, TYPE_NPCM7XX_SDHCI); | ||
28 | } | 89 | } |
29 | 90 | ||
30 | -static CPAccessResult aa64_cacheop_pou_access(CPUARMState *env, | 91 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) |
31 | - const ARMCPRegInfo *ri, | 92 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc), 0, |
32 | - bool isread) | 93 | npcm7xx_irq(s, NPCM7XX_MMC_IRQ)); |
33 | +static CPAccessResult do_cacheop_pou_access(CPUARMState *env, uint64_t hcrflags) | 94 | |
34 | { | 95 | + /* PSPI */ |
35 | /* Cache invalidate/clean to Point of Unification... */ | 96 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_pspi_addr) != ARRAY_SIZE(s->pspi)); |
36 | switch (arm_current_el(env)) { | 97 | + for (i = 0; i < ARRAY_SIZE(s->pspi); i++) { |
37 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult aa64_cacheop_pou_access(CPUARMState *env, | 98 | + SysBusDevice *sbd = SYS_BUS_DEVICE(&s->pspi[i]); |
38 | } | 99 | + int irq = (i == 0) ? NPCM7XX_PSPI1_IRQ : NPCM7XX_PSPI2_IRQ; |
39 | /* fall through */ | ||
40 | case 1: | ||
41 | - /* ... EL1 must trap to EL2 if HCR_EL2.TPU is set. */ | ||
42 | - if (arm_hcr_el2_eff(env) & HCR_TPU) { | ||
43 | + /* ... EL1 must trap to EL2 if relevant HCR_EL2 flags are set. */ | ||
44 | + if (arm_hcr_el2_eff(env) & hcrflags) { | ||
45 | return CP_ACCESS_TRAP_EL2; | ||
46 | } | ||
47 | break; | ||
48 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult aa64_cacheop_pou_access(CPUARMState *env, | ||
49 | return CP_ACCESS_OK; | ||
50 | } | ||
51 | |||
52 | +static CPAccessResult access_ticab(CPUARMState *env, const ARMCPRegInfo *ri, | ||
53 | + bool isread) | ||
54 | +{ | ||
55 | + return do_cacheop_pou_access(env, HCR_TICAB | HCR_TPU); | ||
56 | +} | ||
57 | + | 100 | + |
58 | +static CPAccessResult access_tocu(CPUARMState *env, const ARMCPRegInfo *ri, | 101 | + sysbus_realize(sbd, &error_abort); |
59 | + bool isread) | 102 | + sysbus_mmio_map(sbd, 0, npcm7xx_pspi_addr[i]); |
60 | +{ | 103 | + sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, irq)); |
61 | + return do_cacheop_pou_access(env, HCR_TOCU | HCR_TPU); | 104 | + } |
62 | +} | ||
63 | + | 105 | + |
64 | /* See: D4.7.2 TLB maintenance requirements and the TLB maintenance instructions | 106 | create_unimplemented_device("npcm7xx.shm", 0xc0001000, 4 * KiB); |
65 | * Page D4-1736 (DDI0487A.b) | 107 | create_unimplemented_device("npcm7xx.vdmx", 0xe0800000, 4 * KiB); |
66 | */ | 108 | create_unimplemented_device("npcm7xx.pcierc", 0xe1000000, 64 * KiB); |
67 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | 109 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) |
68 | { .name = "IC_IALLUIS", .state = ARM_CP_STATE_AA64, | 110 | create_unimplemented_device("npcm7xx.peci", 0xf0100000, 4 * KiB); |
69 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0, | 111 | create_unimplemented_device("npcm7xx.siox[1]", 0xf0101000, 4 * KiB); |
70 | .access = PL1_W, .type = ARM_CP_NOP, | 112 | create_unimplemented_device("npcm7xx.siox[2]", 0xf0102000, 4 * KiB); |
71 | - .accessfn = aa64_cacheop_pou_access }, | 113 | - create_unimplemented_device("npcm7xx.pspi1", 0xf0200000, 4 * KiB); |
72 | + .accessfn = access_ticab }, | 114 | - create_unimplemented_device("npcm7xx.pspi2", 0xf0201000, 4 * KiB); |
73 | { .name = "IC_IALLU", .state = ARM_CP_STATE_AA64, | 115 | create_unimplemented_device("npcm7xx.ahbpci", 0xf0400000, 1 * MiB); |
74 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 0, | 116 | create_unimplemented_device("npcm7xx.mcphy", 0xf05f0000, 64 * KiB); |
75 | .access = PL1_W, .type = ARM_CP_NOP, | 117 | create_unimplemented_device("npcm7xx.gmac1", 0xf0802000, 8 * KiB); |
76 | - .accessfn = aa64_cacheop_pou_access }, | ||
77 | + .accessfn = access_tocu }, | ||
78 | { .name = "IC_IVAU", .state = ARM_CP_STATE_AA64, | ||
79 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 5, .opc2 = 1, | ||
80 | .access = PL0_W, .type = ARM_CP_NOP, | ||
81 | - .accessfn = aa64_cacheop_pou_access }, | ||
82 | + .accessfn = access_tocu }, | ||
83 | { .name = "DC_IVAC", .state = ARM_CP_STATE_AA64, | ||
84 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, | ||
85 | .access = PL1_W, .accessfn = aa64_cacheop_poc_access, | ||
86 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
87 | { .name = "DC_CVAU", .state = ARM_CP_STATE_AA64, | ||
88 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 11, .opc2 = 1, | ||
89 | .access = PL0_W, .type = ARM_CP_NOP, | ||
90 | - .accessfn = aa64_cacheop_pou_access }, | ||
91 | + .accessfn = access_tocu }, | ||
92 | { .name = "DC_CIVAC", .state = ARM_CP_STATE_AA64, | ||
93 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 1, | ||
94 | .access = PL0_W, .type = ARM_CP_NOP, | ||
95 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
96 | .writefn = tlbiipas2is_hyp_write }, | ||
97 | /* 32 bit cache operations */ | ||
98 | { .name = "ICIALLUIS", .cp = 15, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0, | ||
99 | - .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, | ||
100 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_ticab }, | ||
101 | { .name = "BPIALLUIS", .cp = 15, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 6, | ||
102 | .type = ARM_CP_NOP, .access = PL1_W }, | ||
103 | { .name = "ICIALLU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 0, | ||
104 | - .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, | ||
105 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tocu }, | ||
106 | { .name = "ICIMVAU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 1, | ||
107 | - .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, | ||
108 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tocu }, | ||
109 | { .name = "BPIALL", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 6, | ||
110 | .type = ARM_CP_NOP, .access = PL1_W }, | ||
111 | { .name = "BPIMVA", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 7, | ||
112 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
113 | { .name = "DCCSW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, | ||
114 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
115 | { .name = "DCCMVAU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 11, .opc2 = 1, | ||
116 | - .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, | ||
117 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tocu }, | ||
118 | { .name = "DCCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 1, | ||
119 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_poc_access }, | ||
120 | { .name = "DCCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, | ||
121 | -- | 118 | -- |
122 | 2.25.1 | 119 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Timofey Kutergin <tkutergin@gmail.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The Cortex-A55 is one of the newer armv8.2+ CPUs; in particular | 3 | Addresses targeting the second translation table (TTB1) in the SMMU have |
4 | it supports the Privileged Access Never (PAN) feature. Add | 4 | all upper bits set. Ensure the IOMMU region covers all 64 bits. |
5 | a model of this CPU, so you can use a CPU type on the virt | ||
6 | board that models a specific real hardware CPU, rather than | ||
7 | having to use the QEMU-specific "max" CPU type. | ||
8 | 5 | ||
9 | Signed-off-by: Timofey Kutergin <tkutergin@gmail.com> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20221121150819.2782817-1-tkutergin@gmail.com | 7 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
11 | [PMM: tweaked commit message] | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Message-id: 20230214171921.1917916-2-jean-philippe@linaro.org |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 11 | --- |
15 | docs/system/arm/virt.rst | 1 + | 12 | include/hw/arm/smmu-common.h | 2 -- |
16 | hw/arm/virt.c | 1 + | 13 | hw/arm/smmu-common.c | 2 +- |
17 | target/arm/cpu64.c | 69 ++++++++++++++++++++++++++++++++++++++++ | 14 | 2 files changed, 1 insertion(+), 3 deletions(-) |
18 | 3 files changed, 71 insertions(+) | ||
19 | 15 | ||
20 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst | 16 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h |
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/docs/system/arm/virt.rst | 18 | --- a/include/hw/arm/smmu-common.h |
23 | +++ b/docs/system/arm/virt.rst | 19 | +++ b/include/hw/arm/smmu-common.h |
24 | @@ -XXX,XX +XXX,XX @@ Supported guest CPU types: | 20 | @@ -XXX,XX +XXX,XX @@ |
25 | - ``cortex-a15`` (32-bit; the default) | 21 | #define SMMU_PCI_DEVFN_MAX 256 |
26 | - ``cortex-a35`` (64-bit) | 22 | #define SMMU_PCI_DEVFN(sid) (sid & 0xFF) |
27 | - ``cortex-a53`` (64-bit) | 23 | |
28 | +- ``cortex-a55`` (64-bit) | 24 | -#define SMMU_MAX_VA_BITS 48 |
29 | - ``cortex-a57`` (64-bit) | 25 | - |
30 | - ``cortex-a72`` (64-bit) | 26 | /* |
31 | - ``cortex-a76`` (64-bit) | 27 | * Page table walk error types |
32 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 28 | */ |
29 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/arm/virt.c | 31 | --- a/hw/arm/smmu-common.c |
35 | +++ b/hw/arm/virt.c | 32 | +++ b/hw/arm/smmu-common.c |
36 | @@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = { | 33 | @@ -XXX,XX +XXX,XX @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) |
37 | ARM_CPU_TYPE_NAME("cortex-a15"), | 34 | |
38 | ARM_CPU_TYPE_NAME("cortex-a35"), | 35 | memory_region_init_iommu(&sdev->iommu, sizeof(sdev->iommu), |
39 | ARM_CPU_TYPE_NAME("cortex-a53"), | 36 | s->mrtypename, |
40 | + ARM_CPU_TYPE_NAME("cortex-a55"), | 37 | - OBJECT(s), name, 1ULL << SMMU_MAX_VA_BITS); |
41 | ARM_CPU_TYPE_NAME("cortex-a57"), | 38 | + OBJECT(s), name, UINT64_MAX); |
42 | ARM_CPU_TYPE_NAME("cortex-a72"), | 39 | address_space_init(&sdev->as, |
43 | ARM_CPU_TYPE_NAME("cortex-a76"), | 40 | MEMORY_REGION(&sdev->iommu), name); |
44 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 41 | trace_smmu_add_mr(name); |
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/cpu64.c | ||
47 | +++ b/target/arm/cpu64.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj) | ||
49 | define_cortex_a72_a57_a53_cp_reginfo(cpu); | ||
50 | } | ||
51 | |||
52 | +static void aarch64_a55_initfn(Object *obj) | ||
53 | +{ | ||
54 | + ARMCPU *cpu = ARM_CPU(obj); | ||
55 | + | ||
56 | + cpu->dtb_compatible = "arm,cortex-a55"; | ||
57 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
58 | + set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
59 | + set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
60 | + set_feature(&cpu->env, ARM_FEATURE_AARCH64); | ||
61 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
62 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | ||
63 | + set_feature(&cpu->env, ARM_FEATURE_EL3); | ||
64 | + set_feature(&cpu->env, ARM_FEATURE_PMU); | ||
65 | + | ||
66 | + /* Ordered by B2.4 AArch64 registers by functional group */ | ||
67 | + cpu->clidr = 0x82000023; | ||
68 | + cpu->ctr = 0x84448004; /* L1Ip = VIPT */ | ||
69 | + cpu->dcz_blocksize = 4; /* 64 bytes */ | ||
70 | + cpu->isar.id_aa64dfr0 = 0x0000000010305408ull; | ||
71 | + cpu->isar.id_aa64isar0 = 0x0000100010211120ull; | ||
72 | + cpu->isar.id_aa64isar1 = 0x0000000000100001ull; | ||
73 | + cpu->isar.id_aa64mmfr0 = 0x0000000000101122ull; | ||
74 | + cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; | ||
75 | + cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull; | ||
76 | + cpu->isar.id_aa64pfr0 = 0x0000000010112222ull; | ||
77 | + cpu->isar.id_aa64pfr1 = 0x0000000000000010ull; | ||
78 | + cpu->id_afr0 = 0x00000000; | ||
79 | + cpu->isar.id_dfr0 = 0x04010088; | ||
80 | + cpu->isar.id_isar0 = 0x02101110; | ||
81 | + cpu->isar.id_isar1 = 0x13112111; | ||
82 | + cpu->isar.id_isar2 = 0x21232042; | ||
83 | + cpu->isar.id_isar3 = 0x01112131; | ||
84 | + cpu->isar.id_isar4 = 0x00011142; | ||
85 | + cpu->isar.id_isar5 = 0x01011121; | ||
86 | + cpu->isar.id_isar6 = 0x00000010; | ||
87 | + cpu->isar.id_mmfr0 = 0x10201105; | ||
88 | + cpu->isar.id_mmfr1 = 0x40000000; | ||
89 | + cpu->isar.id_mmfr2 = 0x01260000; | ||
90 | + cpu->isar.id_mmfr3 = 0x02122211; | ||
91 | + cpu->isar.id_mmfr4 = 0x00021110; | ||
92 | + cpu->isar.id_pfr0 = 0x10010131; | ||
93 | + cpu->isar.id_pfr1 = 0x00011011; | ||
94 | + cpu->isar.id_pfr2 = 0x00000011; | ||
95 | + cpu->midr = 0x412FD050; /* r2p0 */ | ||
96 | + cpu->revidr = 0; | ||
97 | + | ||
98 | + /* From B2.23 CCSIDR_EL1 */ | ||
99 | + cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */ | ||
100 | + cpu->ccsidr[1] = 0x200fe01a; /* 32KB L1 icache */ | ||
101 | + cpu->ccsidr[2] = 0x703fe07a; /* 512KB L2 cache */ | ||
102 | + | ||
103 | + /* From B2.96 SCTLR_EL3 */ | ||
104 | + cpu->reset_sctlr = 0x30c50838; | ||
105 | + | ||
106 | + /* From B4.45 ICH_VTR_EL2 */ | ||
107 | + cpu->gic_num_lrs = 4; | ||
108 | + cpu->gic_vpribits = 5; | ||
109 | + cpu->gic_vprebits = 5; | ||
110 | + cpu->gic_pribits = 5; | ||
111 | + | ||
112 | + cpu->isar.mvfr0 = 0x10110222; | ||
113 | + cpu->isar.mvfr1 = 0x13211111; | ||
114 | + cpu->isar.mvfr2 = 0x00000043; | ||
115 | + | ||
116 | + /* From D5.4 AArch64 PMU register summary */ | ||
117 | + cpu->isar.reset_pmcr_el0 = 0x410b3000; | ||
118 | +} | ||
119 | + | ||
120 | static void aarch64_a72_initfn(Object *obj) | ||
121 | { | ||
122 | ARMCPU *cpu = ARM_CPU(obj); | ||
123 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = { | ||
124 | { .name = "cortex-a35", .initfn = aarch64_a35_initfn }, | ||
125 | { .name = "cortex-a57", .initfn = aarch64_a57_initfn }, | ||
126 | { .name = "cortex-a53", .initfn = aarch64_a53_initfn }, | ||
127 | + { .name = "cortex-a55", .initfn = aarch64_a55_initfn }, | ||
128 | { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, | ||
129 | { .name = "cortex-a76", .initfn = aarch64_a76_initfn }, | ||
130 | { .name = "a64fx", .initfn = aarch64_a64fx_initfn }, | ||
131 | -- | 42 | -- |
132 | 2.25.1 | 43 | 2.34.1 | diff view generated by jsdifflib |
1 | Convert the TYPE_ARM_SMMU device to 3-phase reset. The legacy method | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | doesn't do anything that's invalid in the hold phase, so the | ||
3 | conversion is simple and not a behaviour change. | ||
4 | 2 | ||
5 | Note that we must convert this base class before we can convert the | 3 | Addresses targeting the second translation table (TTB1) in the SMMU have |
6 | TYPE_ARM_SMMUV3 subclass -- transitional support in Resettable | 4 | all upper bits set (except for the top byte when TBI is enabled). Fix |
7 | handles "chain to parent class reset" when the base class is 3-phase | 5 | the TTB1 check. |
8 | and the subclass is still using legacy reset, but not the other way | ||
9 | around. | ||
10 | 6 | ||
7 | Reported-by: Ola Hugosson <ola.hugosson@arm.com> | ||
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
11 | Message-id: 20230214171921.1917916-3-jean-philippe@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
15 | Message-id: 20221109161444.3397405-2-peter.maydell@linaro.org | ||
16 | --- | 13 | --- |
17 | hw/arm/smmu-common.c | 7 ++++--- | 14 | hw/arm/smmu-common.c | 2 +- |
18 | 1 file changed, 4 insertions(+), 3 deletions(-) | 15 | 1 file changed, 1 insertion(+), 1 deletion(-) |
19 | 16 | ||
20 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | 17 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c |
21 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/smmu-common.c | 19 | --- a/hw/arm/smmu-common.c |
23 | +++ b/hw/arm/smmu-common.c | 20 | +++ b/hw/arm/smmu-common.c |
24 | @@ -XXX,XX +XXX,XX @@ static void smmu_base_realize(DeviceState *dev, Error **errp) | 21 | @@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova) |
25 | } | 22 | /* there is a ttbr0 region and we are in it (high bits all zero) */ |
26 | } | 23 | return &cfg->tt[0]; |
27 | 24 | } else if (cfg->tt[1].tsz && | |
28 | -static void smmu_base_reset(DeviceState *dev) | 25 | - !extract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte)) { |
29 | +static void smmu_base_reset_hold(Object *obj) | 26 | + sextract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte) == -1) { |
30 | { | 27 | /* there is a ttbr1 region and we are in it (high bits all one) */ |
31 | - SMMUState *s = ARM_SMMU(dev); | 28 | return &cfg->tt[1]; |
32 | + SMMUState *s = ARM_SMMU(obj); | 29 | } else if (!cfg->tt[0].tsz) { |
33 | |||
34 | g_hash_table_remove_all(s->configs); | ||
35 | g_hash_table_remove_all(s->iotlb); | ||
36 | @@ -XXX,XX +XXX,XX @@ static Property smmu_dev_properties[] = { | ||
37 | static void smmu_base_class_init(ObjectClass *klass, void *data) | ||
38 | { | ||
39 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
40 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
41 | SMMUBaseClass *sbc = ARM_SMMU_CLASS(klass); | ||
42 | |||
43 | device_class_set_props(dc, smmu_dev_properties); | ||
44 | device_class_set_parent_realize(dc, smmu_base_realize, | ||
45 | &sbc->parent_realize); | ||
46 | - dc->reset = smmu_base_reset; | ||
47 | + rc->phases.hold = smmu_base_reset_hold; | ||
48 | } | ||
49 | |||
50 | static const TypeInfo smmu_base_info = { | ||
51 | -- | 30 | -- |
52 | 2.25.1 | 31 | 2.34.1 |
53 | |||
54 | diff view generated by jsdifflib |
1 | From: Zhuojia Shen <chaosdefinition@hotmail.com> | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | In CPUID registers exposed to userspace, some registers were missing | 3 | make it clearer from the name that this is a tcg-only function. |
4 | and some fields were not exposed. This patch aligns exposed ID | ||
5 | registers and their fields with what the upstream kernel currently | ||
6 | exposes. | ||
7 | 4 | ||
8 | Specifically, the following new ID registers/fields are exposed to | 5 | Signed-off-by: Claudio Fontana <cfontana@suse.de> |
9 | userspace: | 6 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
10 | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
11 | ID_AA64PFR1_EL1.BT: bits 3-0 | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
12 | ID_AA64PFR1_EL1.MTE: bits 11-8 | 9 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
13 | ID_AA64PFR1_EL1.SME: bits 27-24 | ||
14 | |||
15 | ID_AA64ZFR0_EL1.SVEver: bits 3-0 | ||
16 | ID_AA64ZFR0_EL1.AES: bits 7-4 | ||
17 | ID_AA64ZFR0_EL1.BitPerm: bits 19-16 | ||
18 | ID_AA64ZFR0_EL1.BF16: bits 23-20 | ||
19 | ID_AA64ZFR0_EL1.SHA3: bits 35-32 | ||
20 | ID_AA64ZFR0_EL1.SM4: bits 43-40 | ||
21 | ID_AA64ZFR0_EL1.I8MM: bits 47-44 | ||
22 | ID_AA64ZFR0_EL1.F32MM: bits 55-52 | ||
23 | ID_AA64ZFR0_EL1.F64MM: bits 59-56 | ||
24 | |||
25 | ID_AA64SMFR0_EL1.F32F32: bit 32 | ||
26 | ID_AA64SMFR0_EL1.B16F32: bit 34 | ||
27 | ID_AA64SMFR0_EL1.F16F32: bit 35 | ||
28 | ID_AA64SMFR0_EL1.I8I32: bits 39-36 | ||
29 | ID_AA64SMFR0_EL1.F64F64: bit 48 | ||
30 | ID_AA64SMFR0_EL1.I16I64: bits 55-52 | ||
31 | ID_AA64SMFR0_EL1.FA64: bit 63 | ||
32 | |||
33 | ID_AA64MMFR0_EL1.ECV: bits 63-60 | ||
34 | |||
35 | ID_AA64MMFR1_EL1.AFP: bits 47-44 | ||
36 | |||
37 | ID_AA64MMFR2_EL1.AT: bits 35-32 | ||
38 | |||
39 | ID_AA64ISAR0_EL1.RNDR: bits 63-60 | ||
40 | |||
41 | ID_AA64ISAR1_EL1.FRINTTS: bits 35-32 | ||
42 | ID_AA64ISAR1_EL1.BF16: bits 47-44 | ||
43 | ID_AA64ISAR1_EL1.DGH: bits 51-48 | ||
44 | ID_AA64ISAR1_EL1.I8MM: bits 55-52 | ||
45 | |||
46 | ID_AA64ISAR2_EL1.WFxT: bits 3-0 | ||
47 | ID_AA64ISAR2_EL1.RPRES: bits 7-4 | ||
48 | ID_AA64ISAR2_EL1.GPA3: bits 11-8 | ||
49 | ID_AA64ISAR2_EL1.APA3: bits 15-12 | ||
50 | |||
51 | The code is also refactored to use symbolic names for ID register fields | ||
52 | for better readability and maintainability. | ||
53 | |||
54 | Signed-off-by: Zhuojia Shen <chaosdefinition@hotmail.com> | ||
55 | Message-id: DS7PR12MB6309BC9133877BCC6FC419FEAC0D9@DS7PR12MB6309.namprd12.prod.outlook.com | ||
56 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
57 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
58 | --- | 11 | --- |
59 | target/arm/helper.c | 96 +++++++++++++++++++++++++++++++++++++-------- | 12 | target/arm/helper.c | 4 ++-- |
60 | 1 file changed, 79 insertions(+), 17 deletions(-) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
61 | 14 | ||
62 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
63 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
64 | --- a/target/arm/helper.c | 17 | --- a/target/arm/helper.c |
65 | +++ b/target/arm/helper.c | 18 | +++ b/target/arm/helper.c |
66 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 19 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) |
67 | #ifdef CONFIG_USER_ONLY | 20 | * trapped to the hypervisor in KVM. |
68 | static const ARMCPRegUserSpaceInfo v8_user_idregs[] = { | 21 | */ |
69 | { .name = "ID_AA64PFR0_EL1", | 22 | #ifdef CONFIG_TCG |
70 | - .exported_bits = 0x000f000f00ff0000, | 23 | -static void handle_semihosting(CPUState *cs) |
71 | - .fixed_bits = 0x0000000000000011 }, | 24 | +static void tcg_handle_semihosting(CPUState *cs) |
72 | + .exported_bits = R_ID_AA64PFR0_FP_MASK | | 25 | { |
73 | + R_ID_AA64PFR0_ADVSIMD_MASK | | 26 | ARMCPU *cpu = ARM_CPU(cs); |
74 | + R_ID_AA64PFR0_SVE_MASK | | 27 | CPUARMState *env = &cpu->env; |
75 | + R_ID_AA64PFR0_DIT_MASK, | 28 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) |
76 | + .fixed_bits = (0x1 << R_ID_AA64PFR0_EL0_SHIFT) | | 29 | */ |
77 | + (0x1 << R_ID_AA64PFR0_EL1_SHIFT) }, | 30 | #ifdef CONFIG_TCG |
78 | { .name = "ID_AA64PFR1_EL1", | 31 | if (cs->exception_index == EXCP_SEMIHOST) { |
79 | - .exported_bits = 0x00000000000000f0 }, | 32 | - handle_semihosting(cs); |
80 | + .exported_bits = R_ID_AA64PFR1_BT_MASK | | 33 | + tcg_handle_semihosting(cs); |
81 | + R_ID_AA64PFR1_SSBS_MASK | | 34 | return; |
82 | + R_ID_AA64PFR1_MTE_MASK | | 35 | } |
83 | + R_ID_AA64PFR1_SME_MASK }, | ||
84 | { .name = "ID_AA64PFR*_EL1_RESERVED", | ||
85 | - .is_glob = true }, | ||
86 | - { .name = "ID_AA64ZFR0_EL1" }, | ||
87 | + .is_glob = true }, | ||
88 | + { .name = "ID_AA64ZFR0_EL1", | ||
89 | + .exported_bits = R_ID_AA64ZFR0_SVEVER_MASK | | ||
90 | + R_ID_AA64ZFR0_AES_MASK | | ||
91 | + R_ID_AA64ZFR0_BITPERM_MASK | | ||
92 | + R_ID_AA64ZFR0_BFLOAT16_MASK | | ||
93 | + R_ID_AA64ZFR0_SHA3_MASK | | ||
94 | + R_ID_AA64ZFR0_SM4_MASK | | ||
95 | + R_ID_AA64ZFR0_I8MM_MASK | | ||
96 | + R_ID_AA64ZFR0_F32MM_MASK | | ||
97 | + R_ID_AA64ZFR0_F64MM_MASK }, | ||
98 | + { .name = "ID_AA64SMFR0_EL1", | ||
99 | + .exported_bits = R_ID_AA64SMFR0_F32F32_MASK | | ||
100 | + R_ID_AA64SMFR0_B16F32_MASK | | ||
101 | + R_ID_AA64SMFR0_F16F32_MASK | | ||
102 | + R_ID_AA64SMFR0_I8I32_MASK | | ||
103 | + R_ID_AA64SMFR0_F64F64_MASK | | ||
104 | + R_ID_AA64SMFR0_I16I64_MASK | | ||
105 | + R_ID_AA64SMFR0_FA64_MASK }, | ||
106 | { .name = "ID_AA64MMFR0_EL1", | ||
107 | - .fixed_bits = 0x00000000ff000000 }, | ||
108 | - { .name = "ID_AA64MMFR1_EL1" }, | ||
109 | + .exported_bits = R_ID_AA64MMFR0_ECV_MASK, | ||
110 | + .fixed_bits = (0xf << R_ID_AA64MMFR0_TGRAN64_SHIFT) | | ||
111 | + (0xf << R_ID_AA64MMFR0_TGRAN4_SHIFT) }, | ||
112 | + { .name = "ID_AA64MMFR1_EL1", | ||
113 | + .exported_bits = R_ID_AA64MMFR1_AFP_MASK }, | ||
114 | + { .name = "ID_AA64MMFR2_EL1", | ||
115 | + .exported_bits = R_ID_AA64MMFR2_AT_MASK }, | ||
116 | { .name = "ID_AA64MMFR*_EL1_RESERVED", | ||
117 | - .is_glob = true }, | ||
118 | + .is_glob = true }, | ||
119 | { .name = "ID_AA64DFR0_EL1", | ||
120 | - .fixed_bits = 0x0000000000000006 }, | ||
121 | - { .name = "ID_AA64DFR1_EL1" }, | ||
122 | + .fixed_bits = (0x6 << R_ID_AA64DFR0_DEBUGVER_SHIFT) }, | ||
123 | + { .name = "ID_AA64DFR1_EL1" }, | ||
124 | { .name = "ID_AA64DFR*_EL1_RESERVED", | ||
125 | - .is_glob = true }, | ||
126 | + .is_glob = true }, | ||
127 | { .name = "ID_AA64AFR*", | ||
128 | - .is_glob = true }, | ||
129 | + .is_glob = true }, | ||
130 | { .name = "ID_AA64ISAR0_EL1", | ||
131 | - .exported_bits = 0x00fffffff0fffff0 }, | ||
132 | + .exported_bits = R_ID_AA64ISAR0_AES_MASK | | ||
133 | + R_ID_AA64ISAR0_SHA1_MASK | | ||
134 | + R_ID_AA64ISAR0_SHA2_MASK | | ||
135 | + R_ID_AA64ISAR0_CRC32_MASK | | ||
136 | + R_ID_AA64ISAR0_ATOMIC_MASK | | ||
137 | + R_ID_AA64ISAR0_RDM_MASK | | ||
138 | + R_ID_AA64ISAR0_SHA3_MASK | | ||
139 | + R_ID_AA64ISAR0_SM3_MASK | | ||
140 | + R_ID_AA64ISAR0_SM4_MASK | | ||
141 | + R_ID_AA64ISAR0_DP_MASK | | ||
142 | + R_ID_AA64ISAR0_FHM_MASK | | ||
143 | + R_ID_AA64ISAR0_TS_MASK | | ||
144 | + R_ID_AA64ISAR0_RNDR_MASK }, | ||
145 | { .name = "ID_AA64ISAR1_EL1", | ||
146 | - .exported_bits = 0x000000f0ffffffff }, | ||
147 | + .exported_bits = R_ID_AA64ISAR1_DPB_MASK | | ||
148 | + R_ID_AA64ISAR1_APA_MASK | | ||
149 | + R_ID_AA64ISAR1_API_MASK | | ||
150 | + R_ID_AA64ISAR1_JSCVT_MASK | | ||
151 | + R_ID_AA64ISAR1_FCMA_MASK | | ||
152 | + R_ID_AA64ISAR1_LRCPC_MASK | | ||
153 | + R_ID_AA64ISAR1_GPA_MASK | | ||
154 | + R_ID_AA64ISAR1_GPI_MASK | | ||
155 | + R_ID_AA64ISAR1_FRINTTS_MASK | | ||
156 | + R_ID_AA64ISAR1_SB_MASK | | ||
157 | + R_ID_AA64ISAR1_BF16_MASK | | ||
158 | + R_ID_AA64ISAR1_DGH_MASK | | ||
159 | + R_ID_AA64ISAR1_I8MM_MASK }, | ||
160 | + { .name = "ID_AA64ISAR2_EL1", | ||
161 | + .exported_bits = R_ID_AA64ISAR2_WFXT_MASK | | ||
162 | + R_ID_AA64ISAR2_RPRES_MASK | | ||
163 | + R_ID_AA64ISAR2_GPA3_MASK | | ||
164 | + R_ID_AA64ISAR2_APA3_MASK }, | ||
165 | { .name = "ID_AA64ISAR*_EL1_RESERVED", | ||
166 | - .is_glob = true }, | ||
167 | + .is_glob = true }, | ||
168 | }; | ||
169 | modify_arm_cp_regs(v8_idregs, v8_user_idregs); | ||
170 | #endif | ||
171 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
172 | #ifdef CONFIG_USER_ONLY | ||
173 | static const ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = { | ||
174 | { .name = "MIDR_EL1", | ||
175 | - .exported_bits = 0x00000000ffffffff }, | ||
176 | - { .name = "REVIDR_EL1" }, | ||
177 | + .exported_bits = R_MIDR_EL1_REVISION_MASK | | ||
178 | + R_MIDR_EL1_PARTNUM_MASK | | ||
179 | + R_MIDR_EL1_ARCHITECTURE_MASK | | ||
180 | + R_MIDR_EL1_VARIANT_MASK | | ||
181 | + R_MIDR_EL1_IMPLEMENTER_MASK }, | ||
182 | + { .name = "REVIDR_EL1" }, | ||
183 | }; | ||
184 | modify_arm_cp_regs(id_v8_midr_cp_reginfo, id_v8_user_midr_cp_reginfo); | ||
185 | #endif | 36 | #endif |
186 | -- | 37 | -- |
187 | 2.25.1 | 38 | 2.34.1 |
39 | |||
40 | diff view generated by jsdifflib |
1 | For FEAT_EVT, the HCR_EL2.TID4 trap allows trapping of the cache ID | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | registers CCSIDR_EL1, CCSIDR2_EL1, CLIDR_EL1 and CSSELR_EL1 (and | ||
3 | their AArch32 equivalents). This is a subset of the registers | ||
4 | trapped by HCR_EL2.TID2, which includes all of these and also the | ||
5 | CTR_EL0 register. | ||
6 | 2 | ||
7 | Our implementation already uses a separate access function for | 3 | for "all" builds (tcg + kvm), we want to avoid doing |
8 | CTR_EL0 (ctr_el0_access()), so all of the registers currently using | 4 | the psci check if tcg is built-in, but not enabled. |
9 | access_aa64_tid2() should also be checking TID4. Make that function | ||
10 | check both TID2 and TID4, and rename it appropriately. | ||
11 | 5 | ||
6 | Signed-off-by: Claudio Fontana <cfontana@suse.de> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
9 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | --- | 11 | --- |
15 | target/arm/helper.c | 17 +++++++++-------- | 12 | target/arm/helper.c | 3 ++- |
16 | 1 file changed, 9 insertions(+), 8 deletions(-) | 13 | 1 file changed, 2 insertions(+), 1 deletion(-) |
17 | 14 | ||
18 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper.c | 17 | --- a/target/arm/helper.c |
21 | +++ b/target/arm/helper.c | 18 | +++ b/target/arm/helper.c |
22 | @@ -XXX,XX +XXX,XX @@ static void scr_reset(CPUARMState *env, const ARMCPRegInfo *ri) | 19 | @@ -XXX,XX +XXX,XX @@ |
23 | scr_write(env, ri, 0); | 20 | #include "hw/irq.h" |
24 | } | 21 | #include "sysemu/cpu-timers.h" |
25 | 22 | #include "sysemu/kvm.h" | |
26 | -static CPAccessResult access_aa64_tid2(CPUARMState *env, | 23 | +#include "sysemu/tcg.h" |
27 | - const ARMCPRegInfo *ri, | 24 | #include "qapi/qapi-commands-machine-target.h" |
28 | - bool isread) | 25 | #include "qapi/error.h" |
29 | +static CPAccessResult access_tid4(CPUARMState *env, | 26 | #include "qemu/guest-random.h" |
30 | + const ARMCPRegInfo *ri, | 27 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) |
31 | + bool isread) | 28 | env->exception.syndrome); |
32 | { | ||
33 | - if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TID2)) { | ||
34 | + if (arm_current_el(env) == 1 && | ||
35 | + (arm_hcr_el2_eff(env) & (HCR_TID2 | HCR_TID4))) { | ||
36 | return CP_ACCESS_TRAP_EL2; | ||
37 | } | 29 | } |
38 | 30 | ||
39 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | 31 | - if (arm_is_psci_call(cpu, cs->exception_index)) { |
40 | { .name = "CCSIDR", .state = ARM_CP_STATE_BOTH, | 32 | + if (tcg_enabled() && arm_is_psci_call(cpu, cs->exception_index)) { |
41 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 0, | 33 | arm_handle_psci_call(cpu); |
42 | .access = PL1_R, | 34 | qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n"); |
43 | - .accessfn = access_aa64_tid2, | 35 | return; |
44 | + .accessfn = access_tid4, | ||
45 | .readfn = ccsidr_read, .type = ARM_CP_NO_RAW }, | ||
46 | { .name = "CSSELR", .state = ARM_CP_STATE_BOTH, | ||
47 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 2, .opc2 = 0, | ||
48 | .access = PL1_RW, | ||
49 | - .accessfn = access_aa64_tid2, | ||
50 | + .accessfn = access_tid4, | ||
51 | .writefn = csselr_write, .resetvalue = 0, | ||
52 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.csselr_s), | ||
53 | offsetof(CPUARMState, cp15.csselr_ns) } }, | ||
54 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ccsidr2_reginfo[] = { | ||
55 | { .name = "CCSIDR2", .state = ARM_CP_STATE_BOTH, | ||
56 | .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 2, | ||
57 | .access = PL1_R, | ||
58 | - .accessfn = access_aa64_tid2, | ||
59 | + .accessfn = access_tid4, | ||
60 | .readfn = ccsidr2_read, .type = ARM_CP_NO_RAW }, | ||
61 | }; | ||
62 | |||
63 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
64 | .name = "CLIDR", .state = ARM_CP_STATE_BOTH, | ||
65 | .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 1, | ||
66 | .access = PL1_R, .type = ARM_CP_CONST, | ||
67 | - .accessfn = access_aa64_tid2, | ||
68 | + .accessfn = access_tid4, | ||
69 | .resetvalue = cpu->clidr | ||
70 | }; | ||
71 | define_one_arm_cp_reg(cpu, &clidr); | ||
72 | -- | 36 | -- |
73 | 2.25.1 | 37 | 2.34.1 |
38 | |||
39 | diff view generated by jsdifflib |
1 | For FEAT_EVT, the HCR_EL2.TTLBIS bit allows trapping on EL1 use of | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | TLB maintenance instructions that operate on the inner shareable | ||
3 | domain: | ||
4 | 2 | ||
5 | AArch64: | 3 | Signed-off-by: Claudio Fontana <cfontana@suse.de> |
6 | TLBI VMALLE1IS, TLBI VAE1IS, TLBI ASIDE1IS, TLBI VAAE1IS, | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | TLBI VALE1IS, TLBI VAALE1IS, TLBI RVAE1IS, TLBI RVAAE1IS, | 5 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
8 | TLBI RVALE1IS, and TLBI RVAALE1IS. | 6 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | |||
10 | AArch32: | ||
11 | TLBIALLIS, TLBIMVAIS, TLBIASIDIS, TLBIMVAAIS, TLBIMVALIS, | ||
12 | and TLBIMVAALIS. | ||
13 | |||
14 | Add the trapping support. | ||
15 | |||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | --- | 8 | --- |
19 | target/arm/helper.c | 43 +++++++++++++++++++++++++++---------------- | 9 | target/arm/helper.c | 12 +++++++----- |
20 | 1 file changed, 27 insertions(+), 16 deletions(-) | 10 | 1 file changed, 7 insertions(+), 5 deletions(-) |
21 | 11 | ||
22 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 12 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
23 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/helper.c | 14 | --- a/target/arm/helper.c |
25 | +++ b/target/arm/helper.c | 15 | +++ b/target/arm/helper.c |
26 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_ttlb(CPUARMState *env, const ARMCPRegInfo *ri, | 16 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) |
27 | return CP_ACCESS_OK; | 17 | unsigned int cur_el = arm_current_el(env); |
28 | } | 18 | int rt; |
29 | 19 | ||
30 | +/* Check for traps from EL1 due to HCR_EL2.TTLB or TTLBIS. */ | 20 | - /* |
31 | +static CPAccessResult access_ttlbis(CPUARMState *env, const ARMCPRegInfo *ri, | 21 | - * Note that new_el can never be 0. If cur_el is 0, then |
32 | + bool isread) | 22 | - * el0_a64 is is_a64(), else el0_a64 is ignored. |
33 | +{ | 23 | - */ |
34 | + if (arm_current_el(env) == 1 && | 24 | - aarch64_sve_change_el(env, cur_el, new_el, is_a64(env)); |
35 | + (arm_hcr_el2_eff(env) & (HCR_TTLB | HCR_TTLBIS))) { | 25 | + if (tcg_enabled()) { |
36 | + return CP_ACCESS_TRAP_EL2; | 26 | + /* |
27 | + * Note that new_el can never be 0. If cur_el is 0, then | ||
28 | + * el0_a64 is is_a64(), else el0_a64 is ignored. | ||
29 | + */ | ||
30 | + aarch64_sve_change_el(env, cur_el, new_el, is_a64(env)); | ||
37 | + } | 31 | + } |
38 | + return CP_ACCESS_OK; | 32 | |
39 | +} | 33 | if (cur_el < new_el) { |
40 | + | 34 | /* |
41 | static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
42 | { | ||
43 | ARMCPU *cpu = env_archcpu(env); | ||
44 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
45 | static const ARMCPRegInfo v7mp_cp_reginfo[] = { | ||
46 | /* 32 bit TLB invalidates, Inner Shareable */ | ||
47 | { .name = "TLBIALLIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, | ||
48 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
49 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlbis, | ||
50 | .writefn = tlbiall_is_write }, | ||
51 | { .name = "TLBIMVAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1, | ||
52 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
53 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlbis, | ||
54 | .writefn = tlbimva_is_write }, | ||
55 | { .name = "TLBIASIDIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2, | ||
56 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
57 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlbis, | ||
58 | .writefn = tlbiasid_is_write }, | ||
59 | { .name = "TLBIMVAAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, | ||
60 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
61 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlbis, | ||
62 | .writefn = tlbimvaa_is_write }, | ||
63 | }; | ||
64 | |||
65 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
66 | /* TLBI operations */ | ||
67 | { .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64, | ||
68 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, | ||
69 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
70 | + .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
71 | .writefn = tlbi_aa64_vmalle1is_write }, | ||
72 | { .name = "TLBI_VAE1IS", .state = ARM_CP_STATE_AA64, | ||
73 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1, | ||
74 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
75 | + .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
76 | .writefn = tlbi_aa64_vae1is_write }, | ||
77 | { .name = "TLBI_ASIDE1IS", .state = ARM_CP_STATE_AA64, | ||
78 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2, | ||
79 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
80 | + .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
81 | .writefn = tlbi_aa64_vmalle1is_write }, | ||
82 | { .name = "TLBI_VAAE1IS", .state = ARM_CP_STATE_AA64, | ||
83 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, | ||
84 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
85 | + .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
86 | .writefn = tlbi_aa64_vae1is_write }, | ||
87 | { .name = "TLBI_VALE1IS", .state = ARM_CP_STATE_AA64, | ||
88 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5, | ||
89 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
90 | + .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
91 | .writefn = tlbi_aa64_vae1is_write }, | ||
92 | { .name = "TLBI_VAALE1IS", .state = ARM_CP_STATE_AA64, | ||
93 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7, | ||
94 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
95 | + .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
96 | .writefn = tlbi_aa64_vae1is_write }, | ||
97 | { .name = "TLBI_VMALLE1", .state = ARM_CP_STATE_AA64, | ||
98 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0, | ||
99 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
100 | #endif | ||
101 | /* TLB invalidate last level of translation table walk */ | ||
102 | { .name = "TLBIMVALIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5, | ||
103 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
104 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlbis, | ||
105 | .writefn = tlbimva_is_write }, | ||
106 | { .name = "TLBIMVAALIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7, | ||
107 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
108 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlbis, | ||
109 | .writefn = tlbimvaa_is_write }, | ||
110 | { .name = "TLBIMVAL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5, | ||
111 | .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
112 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pauth_reginfo[] = { | ||
113 | static const ARMCPRegInfo tlbirange_reginfo[] = { | ||
114 | { .name = "TLBI_RVAE1IS", .state = ARM_CP_STATE_AA64, | ||
115 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 2, .opc2 = 1, | ||
116 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
117 | + .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
118 | .writefn = tlbi_aa64_rvae1is_write }, | ||
119 | { .name = "TLBI_RVAAE1IS", .state = ARM_CP_STATE_AA64, | ||
120 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 2, .opc2 = 3, | ||
121 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
122 | + .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
123 | .writefn = tlbi_aa64_rvae1is_write }, | ||
124 | { .name = "TLBI_RVALE1IS", .state = ARM_CP_STATE_AA64, | ||
125 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 2, .opc2 = 5, | ||
126 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
127 | + .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
128 | .writefn = tlbi_aa64_rvae1is_write }, | ||
129 | { .name = "TLBI_RVAALE1IS", .state = ARM_CP_STATE_AA64, | ||
130 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 2, .opc2 = 7, | ||
131 | - .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
132 | + .access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW, | ||
133 | .writefn = tlbi_aa64_rvae1is_write }, | ||
134 | { .name = "TLBI_RVAE1OS", .state = ARM_CP_STATE_AA64, | ||
135 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 1, | ||
136 | -- | 35 | -- |
137 | 2.25.1 | 36 | 2.34.1 |
37 | |||
38 | diff view generated by jsdifflib |
1 | Now we have converted TYPE_ARM_GIC_COMMON, we can convert the | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | TYPE_ARM_GIC_KVM subclass to 3-phase reset. | ||
3 | 2 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Move this earlier to make the next patch diff cleaner. While here |
4 | update the comment slightly to not give the impression that the | ||
5 | misalignment affects only TCG. | ||
6 | |||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Message-id: 20221109161444.3397405-5-peter.maydell@linaro.org | 9 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
10 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | 12 | --- |
9 | hw/intc/arm_gic_kvm.c | 14 +++++++++----- | 13 | target/arm/machine.c | 18 +++++++++--------- |
10 | 1 file changed, 9 insertions(+), 5 deletions(-) | 14 | 1 file changed, 9 insertions(+), 9 deletions(-) |
11 | 15 | ||
12 | diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c | 16 | diff --git a/target/arm/machine.c b/target/arm/machine.c |
13 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/intc/arm_gic_kvm.c | 18 | --- a/target/arm/machine.c |
15 | +++ b/hw/intc/arm_gic_kvm.c | 19 | +++ b/target/arm/machine.c |
16 | @@ -XXX,XX +XXX,XX @@ DECLARE_OBJ_CHECKERS(GICState, KVMARMGICClass, | 20 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) |
17 | struct KVMARMGICClass { | 21 | } |
18 | ARMGICCommonClass parent_class; | ||
19 | DeviceRealize parent_realize; | ||
20 | - void (*parent_reset)(DeviceState *dev); | ||
21 | + ResettablePhases parent_phases; | ||
22 | }; | ||
23 | |||
24 | void kvm_arm_gic_set_irq(uint32_t num_irq, int irq, int level) | ||
25 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_get(GICState *s) | ||
26 | } | 22 | } |
27 | } | 23 | |
28 | 24 | + /* | |
29 | -static void kvm_arm_gic_reset(DeviceState *dev) | 25 | + * Misaligned thumb pc is architecturally impossible. Fail the |
30 | +static void kvm_arm_gic_reset_hold(Object *obj) | 26 | + * incoming migration. For TCG it would trigger the assert in |
31 | { | 27 | + * thumb_tr_translate_insn(). |
32 | - GICState *s = ARM_GIC_COMMON(dev); | 28 | + */ |
33 | + GICState *s = ARM_GIC_COMMON(obj); | 29 | + if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) { |
34 | KVMARMGICClass *kgc = KVM_ARM_GIC_GET_CLASS(s); | 30 | + return -1; |
35 | |||
36 | - kgc->parent_reset(dev); | ||
37 | + if (kgc->parent_phases.hold) { | ||
38 | + kgc->parent_phases.hold(obj); | ||
39 | + } | 31 | + } |
40 | 32 | + | |
41 | if (kvm_arm_gic_can_save_restore(s)) { | 33 | hw_breakpoint_update_all(cpu); |
42 | kvm_arm_gic_put(s); | 34 | hw_watchpoint_update_all(cpu); |
43 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_realize(DeviceState *dev, Error **errp) | 35 | |
44 | static void kvm_arm_gic_class_init(ObjectClass *klass, void *data) | 36 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) |
45 | { | 37 | } |
46 | DeviceClass *dc = DEVICE_CLASS(klass); | 38 | } |
47 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | 39 | |
48 | ARMGICCommonClass *agcc = ARM_GIC_COMMON_CLASS(klass); | 40 | - /* |
49 | KVMARMGICClass *kgc = KVM_ARM_GIC_CLASS(klass); | 41 | - * Misaligned thumb pc is architecturally impossible. |
50 | 42 | - * We have an assert in thumb_tr_translate_insn to verify this. | |
51 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_class_init(ObjectClass *klass, void *data) | 43 | - * Fail an incoming migrate to avoid this assert. |
52 | agcc->post_load = kvm_arm_gic_put; | 44 | - */ |
53 | device_class_set_parent_realize(dc, kvm_arm_gic_realize, | 45 | - if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) { |
54 | &kgc->parent_realize); | 46 | - return -1; |
55 | - device_class_set_parent_reset(dc, kvm_arm_gic_reset, &kgc->parent_reset); | 47 | - } |
56 | + resettable_class_set_parent_phases(rc, NULL, kvm_arm_gic_reset_hold, NULL, | 48 | - |
57 | + &kgc->parent_phases); | 49 | if (!kvm_enabled()) { |
58 | } | 50 | pmu_op_finish(&cpu->env); |
59 | 51 | } | |
60 | static const TypeInfo kvm_arm_gic_info = { | ||
61 | -- | 52 | -- |
62 | 2.25.1 | 53 | 2.34.1 |
63 | 54 | ||
64 | 55 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | This introduces virt_set_high_memmap() helper. The logic of high | 3 | Since commit cf7c6d1004 ("target/arm: Split out cpregs.h") we now have |
4 | memory region address assignment is moved to the helper. The intention | 4 | a cpregs.h header which is more suitable for this code. |
5 | is to make the subsequent optimization for high memory region address | 5 | |
6 | assignment easier. | 6 | Code moved verbatim. |
7 | 7 | ||
8 | No functional change intended. | 8 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
9 | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
10 | Signed-off-by: Gavin Shan <gshan@redhat.com> | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 11 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
12 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | ||
13 | Reviewed-by: Marc Zyngier <maz@kernel.org> | ||
14 | Tested-by: Zhenyu Zhang <zhenyzha@redhat.com> | ||
15 | Message-id: 20221029224307.138822-2-gshan@redhat.com | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 13 | --- |
18 | hw/arm/virt.c | 74 ++++++++++++++++++++++++++++----------------------- | 14 | target/arm/cpregs.h | 98 +++++++++++++++++++++++++++++++++++++++++++++ |
19 | 1 file changed, 41 insertions(+), 33 deletions(-) | 15 | target/arm/cpu.h | 91 ----------------------------------------- |
20 | 16 | 2 files changed, 98 insertions(+), 91 deletions(-) | |
21 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 17 | |
18 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/arm/virt.c | 20 | --- a/target/arm/cpregs.h |
24 | +++ b/hw/arm/virt.c | 21 | +++ b/target/arm/cpregs.h |
25 | @@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) | 22 | @@ -XXX,XX +XXX,XX @@ enum { |
26 | return arm_cpu_mp_affinity(idx, clustersz); | 23 | ARM_CP_SME = 1 << 19, |
27 | } | 24 | }; |
28 | 25 | ||
29 | +static void virt_set_high_memmap(VirtMachineState *vms, | 26 | +/* |
30 | + hwaddr base, int pa_bits) | 27 | + * Interface for defining coprocessor registers. |
28 | + * Registers are defined in tables of arm_cp_reginfo structs | ||
29 | + * which are passed to define_arm_cp_regs(). | ||
30 | + */ | ||
31 | + | ||
32 | +/* | ||
33 | + * When looking up a coprocessor register we look for it | ||
34 | + * via an integer which encodes all of: | ||
35 | + * coprocessor number | ||
36 | + * Crn, Crm, opc1, opc2 fields | ||
37 | + * 32 or 64 bit register (ie is it accessed via MRC/MCR | ||
38 | + * or via MRRC/MCRR?) | ||
39 | + * non-secure/secure bank (AArch32 only) | ||
40 | + * We allow 4 bits for opc1 because MRRC/MCRR have a 4 bit field. | ||
41 | + * (In this case crn and opc2 should be zero.) | ||
42 | + * For AArch64, there is no 32/64 bit size distinction; | ||
43 | + * instead all registers have a 2 bit op0, 3 bit op1 and op2, | ||
44 | + * and 4 bit CRn and CRm. The encoding patterns are chosen | ||
45 | + * to be easy to convert to and from the KVM encodings, and also | ||
46 | + * so that the hashtable can contain both AArch32 and AArch64 | ||
47 | + * registers (to allow for interprocessing where we might run | ||
48 | + * 32 bit code on a 64 bit core). | ||
49 | + */ | ||
50 | +/* | ||
51 | + * This bit is private to our hashtable cpreg; in KVM register | ||
52 | + * IDs the AArch64/32 distinction is the KVM_REG_ARM/ARM64 | ||
53 | + * in the upper bits of the 64 bit ID. | ||
54 | + */ | ||
55 | +#define CP_REG_AA64_SHIFT 28 | ||
56 | +#define CP_REG_AA64_MASK (1 << CP_REG_AA64_SHIFT) | ||
57 | + | ||
58 | +/* | ||
59 | + * To enable banking of coprocessor registers depending on ns-bit we | ||
60 | + * add a bit to distinguish between secure and non-secure cpregs in the | ||
61 | + * hashtable. | ||
62 | + */ | ||
63 | +#define CP_REG_NS_SHIFT 29 | ||
64 | +#define CP_REG_NS_MASK (1 << CP_REG_NS_SHIFT) | ||
65 | + | ||
66 | +#define ENCODE_CP_REG(cp, is64, ns, crn, crm, opc1, opc2) \ | ||
67 | + ((ns) << CP_REG_NS_SHIFT | ((cp) << 16) | ((is64) << 15) | \ | ||
68 | + ((crn) << 11) | ((crm) << 7) | ((opc1) << 3) | (opc2)) | ||
69 | + | ||
70 | +#define ENCODE_AA64_CP_REG(cp, crn, crm, op0, op1, op2) \ | ||
71 | + (CP_REG_AA64_MASK | \ | ||
72 | + ((cp) << CP_REG_ARM_COPROC_SHIFT) | \ | ||
73 | + ((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \ | ||
74 | + ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \ | ||
75 | + ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \ | ||
76 | + ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \ | ||
77 | + ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT)) | ||
78 | + | ||
79 | +/* | ||
80 | + * Convert a full 64 bit KVM register ID to the truncated 32 bit | ||
81 | + * version used as a key for the coprocessor register hashtable | ||
82 | + */ | ||
83 | +static inline uint32_t kvm_to_cpreg_id(uint64_t kvmid) | ||
31 | +{ | 84 | +{ |
32 | + int i; | 85 | + uint32_t cpregid = kvmid; |
33 | + | 86 | + if ((kvmid & CP_REG_ARCH_MASK) == CP_REG_ARM64) { |
34 | + for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) { | 87 | + cpregid |= CP_REG_AA64_MASK; |
35 | + hwaddr size = extended_memmap[i].size; | 88 | + } else { |
36 | + bool fits; | 89 | + if ((kvmid & CP_REG_SIZE_MASK) == CP_REG_SIZE_U64) { |
37 | + | 90 | + cpregid |= (1 << 15); |
38 | + base = ROUND_UP(base, size); | 91 | + } |
39 | + vms->memmap[i].base = base; | ||
40 | + vms->memmap[i].size = size; | ||
41 | + | 92 | + |
42 | + /* | 93 | + /* |
43 | + * Check each device to see if they fit in the PA space, | 94 | + * KVM is always non-secure so add the NS flag on AArch32 register |
44 | + * moving highest_gpa as we go. | 95 | + * entries. |
45 | + * | ||
46 | + * For each device that doesn't fit, disable it. | ||
47 | + */ | 96 | + */ |
48 | + fits = (base + size) <= BIT_ULL(pa_bits); | 97 | + cpregid |= 1 << CP_REG_NS_SHIFT; |
49 | + if (fits) { | 98 | + } |
50 | + vms->highest_gpa = base + size - 1; | 99 | + return cpregid; |
100 | +} | ||
101 | + | ||
102 | +/* | ||
103 | + * Convert a truncated 32 bit hashtable key into the full | ||
104 | + * 64 bit KVM register ID. | ||
105 | + */ | ||
106 | +static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) | ||
107 | +{ | ||
108 | + uint64_t kvmid; | ||
109 | + | ||
110 | + if (cpregid & CP_REG_AA64_MASK) { | ||
111 | + kvmid = cpregid & ~CP_REG_AA64_MASK; | ||
112 | + kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM64; | ||
113 | + } else { | ||
114 | + kvmid = cpregid & ~(1 << 15); | ||
115 | + if (cpregid & (1 << 15)) { | ||
116 | + kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM; | ||
117 | + } else { | ||
118 | + kvmid |= CP_REG_SIZE_U32 | CP_REG_ARM; | ||
51 | + } | 119 | + } |
52 | + | ||
53 | + switch (i) { | ||
54 | + case VIRT_HIGH_GIC_REDIST2: | ||
55 | + vms->highmem_redists &= fits; | ||
56 | + break; | ||
57 | + case VIRT_HIGH_PCIE_ECAM: | ||
58 | + vms->highmem_ecam &= fits; | ||
59 | + break; | ||
60 | + case VIRT_HIGH_PCIE_MMIO: | ||
61 | + vms->highmem_mmio &= fits; | ||
62 | + break; | ||
63 | + } | ||
64 | + | ||
65 | + base += size; | ||
66 | + } | 120 | + } |
121 | + return kvmid; | ||
67 | +} | 122 | +} |
68 | + | 123 | + |
69 | static void virt_set_memmap(VirtMachineState *vms, int pa_bits) | 124 | /* |
125 | * Valid values for ARMCPRegInfo state field, indicating which of | ||
126 | * the AArch32 and AArch64 execution states this register is visible in. | ||
127 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
128 | index XXXXXXX..XXXXXXX 100644 | ||
129 | --- a/target/arm/cpu.h | ||
130 | +++ b/target/arm/cpu.h | ||
131 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_list(void); | ||
132 | uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx, | ||
133 | uint32_t cur_el, bool secure); | ||
134 | |||
135 | -/* Interface for defining coprocessor registers. | ||
136 | - * Registers are defined in tables of arm_cp_reginfo structs | ||
137 | - * which are passed to define_arm_cp_regs(). | ||
138 | - */ | ||
139 | - | ||
140 | -/* When looking up a coprocessor register we look for it | ||
141 | - * via an integer which encodes all of: | ||
142 | - * coprocessor number | ||
143 | - * Crn, Crm, opc1, opc2 fields | ||
144 | - * 32 or 64 bit register (ie is it accessed via MRC/MCR | ||
145 | - * or via MRRC/MCRR?) | ||
146 | - * non-secure/secure bank (AArch32 only) | ||
147 | - * We allow 4 bits for opc1 because MRRC/MCRR have a 4 bit field. | ||
148 | - * (In this case crn and opc2 should be zero.) | ||
149 | - * For AArch64, there is no 32/64 bit size distinction; | ||
150 | - * instead all registers have a 2 bit op0, 3 bit op1 and op2, | ||
151 | - * and 4 bit CRn and CRm. The encoding patterns are chosen | ||
152 | - * to be easy to convert to and from the KVM encodings, and also | ||
153 | - * so that the hashtable can contain both AArch32 and AArch64 | ||
154 | - * registers (to allow for interprocessing where we might run | ||
155 | - * 32 bit code on a 64 bit core). | ||
156 | - */ | ||
157 | -/* This bit is private to our hashtable cpreg; in KVM register | ||
158 | - * IDs the AArch64/32 distinction is the KVM_REG_ARM/ARM64 | ||
159 | - * in the upper bits of the 64 bit ID. | ||
160 | - */ | ||
161 | -#define CP_REG_AA64_SHIFT 28 | ||
162 | -#define CP_REG_AA64_MASK (1 << CP_REG_AA64_SHIFT) | ||
163 | - | ||
164 | -/* To enable banking of coprocessor registers depending on ns-bit we | ||
165 | - * add a bit to distinguish between secure and non-secure cpregs in the | ||
166 | - * hashtable. | ||
167 | - */ | ||
168 | -#define CP_REG_NS_SHIFT 29 | ||
169 | -#define CP_REG_NS_MASK (1 << CP_REG_NS_SHIFT) | ||
170 | - | ||
171 | -#define ENCODE_CP_REG(cp, is64, ns, crn, crm, opc1, opc2) \ | ||
172 | - ((ns) << CP_REG_NS_SHIFT | ((cp) << 16) | ((is64) << 15) | \ | ||
173 | - ((crn) << 11) | ((crm) << 7) | ((opc1) << 3) | (opc2)) | ||
174 | - | ||
175 | -#define ENCODE_AA64_CP_REG(cp, crn, crm, op0, op1, op2) \ | ||
176 | - (CP_REG_AA64_MASK | \ | ||
177 | - ((cp) << CP_REG_ARM_COPROC_SHIFT) | \ | ||
178 | - ((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \ | ||
179 | - ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \ | ||
180 | - ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \ | ||
181 | - ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \ | ||
182 | - ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT)) | ||
183 | - | ||
184 | -/* Convert a full 64 bit KVM register ID to the truncated 32 bit | ||
185 | - * version used as a key for the coprocessor register hashtable | ||
186 | - */ | ||
187 | -static inline uint32_t kvm_to_cpreg_id(uint64_t kvmid) | ||
188 | -{ | ||
189 | - uint32_t cpregid = kvmid; | ||
190 | - if ((kvmid & CP_REG_ARCH_MASK) == CP_REG_ARM64) { | ||
191 | - cpregid |= CP_REG_AA64_MASK; | ||
192 | - } else { | ||
193 | - if ((kvmid & CP_REG_SIZE_MASK) == CP_REG_SIZE_U64) { | ||
194 | - cpregid |= (1 << 15); | ||
195 | - } | ||
196 | - | ||
197 | - /* KVM is always non-secure so add the NS flag on AArch32 register | ||
198 | - * entries. | ||
199 | - */ | ||
200 | - cpregid |= 1 << CP_REG_NS_SHIFT; | ||
201 | - } | ||
202 | - return cpregid; | ||
203 | -} | ||
204 | - | ||
205 | -/* Convert a truncated 32 bit hashtable key into the full | ||
206 | - * 64 bit KVM register ID. | ||
207 | - */ | ||
208 | -static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid) | ||
209 | -{ | ||
210 | - uint64_t kvmid; | ||
211 | - | ||
212 | - if (cpregid & CP_REG_AA64_MASK) { | ||
213 | - kvmid = cpregid & ~CP_REG_AA64_MASK; | ||
214 | - kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM64; | ||
215 | - } else { | ||
216 | - kvmid = cpregid & ~(1 << 15); | ||
217 | - if (cpregid & (1 << 15)) { | ||
218 | - kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM; | ||
219 | - } else { | ||
220 | - kvmid |= CP_REG_SIZE_U32 | CP_REG_ARM; | ||
221 | - } | ||
222 | - } | ||
223 | - return kvmid; | ||
224 | -} | ||
225 | - | ||
226 | /* Return the highest implemented Exception Level */ | ||
227 | static inline int arm_highest_el(CPUARMState *env) | ||
70 | { | 228 | { |
71 | MachineState *ms = MACHINE(vms); | ||
72 | @@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits) | ||
73 | /* We know for sure that at least the memory fits in the PA space */ | ||
74 | vms->highest_gpa = memtop - 1; | ||
75 | |||
76 | - for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) { | ||
77 | - hwaddr size = extended_memmap[i].size; | ||
78 | - bool fits; | ||
79 | - | ||
80 | - base = ROUND_UP(base, size); | ||
81 | - vms->memmap[i].base = base; | ||
82 | - vms->memmap[i].size = size; | ||
83 | - | ||
84 | - /* | ||
85 | - * Check each device to see if they fit in the PA space, | ||
86 | - * moving highest_gpa as we go. | ||
87 | - * | ||
88 | - * For each device that doesn't fit, disable it. | ||
89 | - */ | ||
90 | - fits = (base + size) <= BIT_ULL(pa_bits); | ||
91 | - if (fits) { | ||
92 | - vms->highest_gpa = base + size - 1; | ||
93 | - } | ||
94 | - | ||
95 | - switch (i) { | ||
96 | - case VIRT_HIGH_GIC_REDIST2: | ||
97 | - vms->highmem_redists &= fits; | ||
98 | - break; | ||
99 | - case VIRT_HIGH_PCIE_ECAM: | ||
100 | - vms->highmem_ecam &= fits; | ||
101 | - break; | ||
102 | - case VIRT_HIGH_PCIE_MMIO: | ||
103 | - vms->highmem_mmio &= fits; | ||
104 | - break; | ||
105 | - } | ||
106 | - | ||
107 | - base += size; | ||
108 | - } | ||
109 | + virt_set_high_memmap(vms, base, pa_bits); | ||
110 | |||
111 | if (device_memory_size > 0) { | ||
112 | ms->device_memory = g_malloc0(sizeof(*ms->device_memory)); | ||
113 | -- | 229 | -- |
114 | 2.25.1 | 230 | 2.34.1 |
231 | |||
232 | diff view generated by jsdifflib |
1 | Convert the TYPE_ARM_GICV3_ITS_COMMON parent class to 3-phase reset. | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | If a test was tagged with the "accel" tag and the specified | ||
4 | accelerator it not present in the qemu binary, cancel the test. | ||
5 | |||
6 | We can now write tests without explicit calls to require_accelerator, | ||
7 | just the tag is enough. | ||
8 | |||
9 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20221109161444.3397405-8-peter.maydell@linaro.org | ||
7 | --- | 13 | --- |
8 | hw/intc/arm_gicv3_its_common.c | 7 ++++--- | 14 | tests/avocado/avocado_qemu/__init__.py | 4 ++++ |
9 | 1 file changed, 4 insertions(+), 3 deletions(-) | 15 | 1 file changed, 4 insertions(+) |
10 | 16 | ||
11 | diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c | 17 | diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py |
12 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/intc/arm_gicv3_its_common.c | 19 | --- a/tests/avocado/avocado_qemu/__init__.py |
14 | +++ b/hw/intc/arm_gicv3_its_common.c | 20 | +++ b/tests/avocado/avocado_qemu/__init__.py |
15 | @@ -XXX,XX +XXX,XX @@ void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops, | 21 | @@ -XXX,XX +XXX,XX @@ def setUp(self): |
16 | msi_nonbroken = true; | 22 | |
17 | } | 23 | super().setUp('qemu-system-') |
18 | 24 | ||
19 | -static void gicv3_its_common_reset(DeviceState *dev) | 25 | + accel_required = self._get_unique_tag_val('accel') |
20 | +static void gicv3_its_common_reset_hold(Object *obj) | 26 | + if accel_required: |
21 | { | 27 | + self.require_accelerator(accel_required) |
22 | - GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev); | 28 | + |
23 | + GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj); | 29 | self.machine = self.params.get('machine', |
24 | 30 | default=self._get_unique_tag_val('machine')) | |
25 | s->ctlr = 0; | ||
26 | s->cbaser = 0; | ||
27 | @@ -XXX,XX +XXX,XX @@ static void gicv3_its_common_reset(DeviceState *dev) | ||
28 | static void gicv3_its_common_class_init(ObjectClass *klass, void *data) | ||
29 | { | ||
30 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
31 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
32 | |||
33 | - dc->reset = gicv3_its_common_reset; | ||
34 | + rc->phases.hold = gicv3_its_common_reset_hold; | ||
35 | dc->vmsd = &vmstate_its; | ||
36 | } | ||
37 | 31 | ||
38 | -- | 32 | -- |
39 | 2.25.1 | 33 | 2.34.1 |
40 | 34 | ||
41 | 35 | diff view generated by jsdifflib |
1 | Convert the TYPE_ARM_GIC_COMMON device to 3-phase reset. This is a | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | simple no-behaviour-change conversion. | ||
3 | 2 | ||
3 | This allows the test to be skipped when TCG is not present in the QEMU | ||
4 | binary. | ||
5 | |||
6 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20221109161444.3397405-4-peter.maydell@linaro.org | ||
8 | --- | 10 | --- |
9 | hw/intc/arm_gic_common.c | 7 ++++--- | 11 | tests/avocado/boot_linux_console.py | 1 + |
10 | 1 file changed, 4 insertions(+), 3 deletions(-) | 12 | tests/avocado/reverse_debugging.py | 8 ++++++++ |
13 | 2 files changed, 9 insertions(+) | ||
11 | 14 | ||
12 | diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c | 15 | diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py |
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/intc/arm_gic_common.c | 17 | --- a/tests/avocado/boot_linux_console.py |
15 | +++ b/hw/intc/arm_gic_common.c | 18 | +++ b/tests/avocado/boot_linux_console.py |
16 | @@ -XXX,XX +XXX,XX @@ static inline void arm_gic_common_reset_irq_state(GICState *s, int first_cpu, | 19 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_uboot_netbsd9(self): |
17 | } | 20 | |
18 | } | 21 | def test_aarch64_raspi3_atf(self): |
19 | 22 | """ | |
20 | -static void arm_gic_common_reset(DeviceState *dev) | 23 | + :avocado: tags=accel:tcg |
21 | +static void arm_gic_common_reset_hold(Object *obj) | 24 | :avocado: tags=arch:aarch64 |
22 | { | 25 | :avocado: tags=machine:raspi3b |
23 | - GICState *s = ARM_GIC_COMMON(dev); | 26 | :avocado: tags=cpu:cortex-a53 |
24 | + GICState *s = ARM_GIC_COMMON(obj); | 27 | diff --git a/tests/avocado/reverse_debugging.py b/tests/avocado/reverse_debugging.py |
25 | int i, j; | 28 | index XXXXXXX..XXXXXXX 100644 |
26 | int resetprio; | 29 | --- a/tests/avocado/reverse_debugging.py |
27 | 30 | +++ b/tests/avocado/reverse_debugging.py | |
28 | @@ -XXX,XX +XXX,XX @@ static Property arm_gic_common_properties[] = { | 31 | @@ -XXX,XX +XXX,XX @@ def reverse_debugging(self, shift=7, args=None): |
29 | static void arm_gic_common_class_init(ObjectClass *klass, void *data) | 32 | vm.shutdown() |
30 | { | 33 | |
31 | DeviceClass *dc = DEVICE_CLASS(klass); | 34 | class ReverseDebugging_X86_64(ReverseDebugging): |
32 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | 35 | + """ |
33 | ARMLinuxBootIfClass *albifc = ARM_LINUX_BOOT_IF_CLASS(klass); | 36 | + :avocado: tags=accel:tcg |
34 | 37 | + """ | |
35 | - dc->reset = arm_gic_common_reset; | 38 | + |
36 | + rc->phases.hold = arm_gic_common_reset_hold; | 39 | REG_PC = 0x10 |
37 | dc->realize = arm_gic_common_realize; | 40 | REG_CS = 0x12 |
38 | device_class_set_props(dc, arm_gic_common_properties); | 41 | def get_pc(self, g): |
39 | dc->vmsd = &vmstate_gic; | 42 | @@ -XXX,XX +XXX,XX @@ def test_x86_64_pc(self): |
43 | self.reverse_debugging() | ||
44 | |||
45 | class ReverseDebugging_AArch64(ReverseDebugging): | ||
46 | + """ | ||
47 | + :avocado: tags=accel:tcg | ||
48 | + """ | ||
49 | + | ||
50 | REG_PC = 32 | ||
51 | |||
52 | # unidentified gitlab timeout problem | ||
40 | -- | 53 | -- |
41 | 2.25.1 | 54 | 2.34.1 |
42 | 55 | ||
43 | 56 | diff view generated by jsdifflib |
1 | From: Gavin Shan <gshan@redhat.com> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | This renames variable 'size' to 'region_size' in virt_set_high_memmap(). | 3 | Now that the cortex-a15 is under CONFIG_TCG, use as default CPU for a |
4 | Its counterpart ('region_base') will be introduced in next patch. | 4 | KVM-only build the 'max' cpu. |
5 | 5 | ||
6 | No functional change intended. | 6 | Note that we cannot use 'host' here because the qtests can run without |
7 | any other accelerator (than qtest) and 'host' depends on KVM being | ||
8 | enabled. | ||
7 | 9 | ||
8 | Signed-off-by: Gavin Shan <gshan@redhat.com> | 10 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 11 | Acked-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> | 12 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
11 | Reviewed-by: Marc Zyngier <maz@kernel.org> | ||
12 | Tested-by: Zhenyu Zhang <zhenyzha@redhat.com> | ||
13 | Message-id: 20221029224307.138822-3-gshan@redhat.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 14 | --- |
16 | hw/arm/virt.c | 15 ++++++++------- | 15 | hw/arm/virt.c | 4 ++++ |
17 | 1 file changed, 8 insertions(+), 7 deletions(-) | 16 | 1 file changed, 4 insertions(+) |
18 | 17 | ||
19 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 18 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
20 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/virt.c | 20 | --- a/hw/arm/virt.c |
22 | +++ b/hw/arm/virt.c | 21 | +++ b/hw/arm/virt.c |
23 | @@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) | 22 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data) |
24 | static void virt_set_high_memmap(VirtMachineState *vms, | 23 | mc->minimum_page_bits = 12; |
25 | hwaddr base, int pa_bits) | 24 | mc->possible_cpu_arch_ids = virt_possible_cpu_arch_ids; |
26 | { | 25 | mc->cpu_index_to_instance_props = virt_cpu_index_to_props; |
27 | + hwaddr region_size; | 26 | +#ifdef CONFIG_TCG |
28 | + bool fits; | 27 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); |
29 | int i; | 28 | +#else |
30 | 29 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("max"); | |
31 | for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) { | 30 | +#endif |
32 | - hwaddr size = extended_memmap[i].size; | 31 | mc->get_default_cpu_node_id = virt_get_default_cpu_node_id; |
33 | - bool fits; | 32 | mc->kvm_type = virt_kvm_type; |
34 | + region_size = extended_memmap[i].size; | 33 | assert(!mc->get_hotplug_handler); |
35 | |||
36 | - base = ROUND_UP(base, size); | ||
37 | + base = ROUND_UP(base, region_size); | ||
38 | vms->memmap[i].base = base; | ||
39 | - vms->memmap[i].size = size; | ||
40 | + vms->memmap[i].size = region_size; | ||
41 | |||
42 | /* | ||
43 | * Check each device to see if they fit in the PA space, | ||
44 | @@ -XXX,XX +XXX,XX @@ static void virt_set_high_memmap(VirtMachineState *vms, | ||
45 | * | ||
46 | * For each device that doesn't fit, disable it. | ||
47 | */ | ||
48 | - fits = (base + size) <= BIT_ULL(pa_bits); | ||
49 | + fits = (base + region_size) <= BIT_ULL(pa_bits); | ||
50 | if (fits) { | ||
51 | - vms->highest_gpa = base + size - 1; | ||
52 | + vms->highest_gpa = base + region_size - 1; | ||
53 | } | ||
54 | |||
55 | switch (i) { | ||
56 | @@ -XXX,XX +XXX,XX @@ static void virt_set_high_memmap(VirtMachineState *vms, | ||
57 | break; | ||
58 | } | ||
59 | |||
60 | - base += size; | ||
61 | + base += region_size; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | -- | 34 | -- |
66 | 2.25.1 | 35 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Schspa Shi <schspa@gmail.com> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | We use 32bit value for linux,initrd-[start/end], when we have | 3 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
4 | loader_start > 4GB, there will be a wrong initrd_start passed | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | to the kernel, and the kernel will report the following warning. | 5 | Acked-by: Thomas Huth <thuth@redhat.com> |
6 | |||
7 | [ 0.000000] ------------[ cut here ]------------ | ||
8 | [ 0.000000] initrd not fully accessible via the linear mapping -- please check your bootloader ... | ||
9 | [ 0.000000] WARNING: CPU: 0 PID: 0 at arch/arm64/mm/init.c:355 arm64_memblock_init+0x158/0x244 | ||
10 | [ 0.000000] Modules linked in: | ||
11 | [ 0.000000] CPU: 0 PID: 0 Comm: swapper Tainted: G W 6.1.0-rc3-13250-g30a0b95b1335-dirty #28 | ||
12 | [ 0.000000] Hardware name: Horizon Sigi Virtual development board (DT) | ||
13 | [ 0.000000] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) | ||
14 | [ 0.000000] pc : arm64_memblock_init+0x158/0x244 | ||
15 | [ 0.000000] lr : arm64_memblock_init+0x158/0x244 | ||
16 | [ 0.000000] sp : ffff800009273df0 | ||
17 | [ 0.000000] x29: ffff800009273df0 x28: 0000001000cc0010 x27: 0000800000000000 | ||
18 | [ 0.000000] x26: 000000000050a3e2 x25: ffff800008b46000 x24: ffff800008b46000 | ||
19 | [ 0.000000] x23: ffff800008a53000 x22: ffff800009420000 x21: ffff800008a53000 | ||
20 | [ 0.000000] x20: 0000000004000000 x19: 0000000004000000 x18: 00000000ffff1020 | ||
21 | [ 0.000000] x17: 6568632065736165 x16: 6c70202d2d20676e x15: 697070616d207261 | ||
22 | [ 0.000000] x14: 656e696c20656874 x13: 0a2e2e2e20726564 x12: 0000000000000000 | ||
23 | [ 0.000000] x11: 0000000000000000 x10: 00000000ffffffff x9 : 0000000000000000 | ||
24 | [ 0.000000] x8 : 0000000000000000 x7 : 796c6c756620746f x6 : 6e20647274696e69 | ||
25 | [ 0.000000] x5 : ffff8000093c7c47 x4 : ffff800008a2102f x3 : ffff800009273a88 | ||
26 | [ 0.000000] x2 : 80000000fffff038 x1 : 00000000000000c0 x0 : 0000000000000056 | ||
27 | [ 0.000000] Call trace: | ||
28 | [ 0.000000] arm64_memblock_init+0x158/0x244 | ||
29 | [ 0.000000] setup_arch+0x164/0x1cc | ||
30 | [ 0.000000] start_kernel+0x94/0x4ac | ||
31 | [ 0.000000] __primary_switched+0xb4/0xbc | ||
32 | [ 0.000000] ---[ end trace 0000000000000000 ]--- | ||
33 | [ 0.000000] Zone ranges: | ||
34 | [ 0.000000] DMA [mem 0x0000001000000000-0x0000001007ffffff] | ||
35 | |||
36 | This doesn't affect any machine types we currently support, because | ||
37 | for all of our machine types the RAM starts well below the 4GB | ||
38 | mark, but it does demonstrate that we're not currently writing | ||
39 | the device-tree properties quite as intended. | ||
40 | |||
41 | To fix it, we can change it to write these values to the dtb using a | ||
42 | type width matching #address-cells. This is the intended size for | ||
43 | these dtb properties, and is how u-boot, for instance, writes them, | ||
44 | although in practice the Linux kernel will cope with them being any | ||
45 | width as long as they're big enough to fit the value. | ||
46 | |||
47 | Signed-off-by: Schspa Shi <schspa@gmail.com> | ||
48 | Message-id: 20221129160724.75667-1-schspa@gmail.com | ||
49 | [PMM: tweaked commit message] | ||
50 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
51 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
52 | --- | 7 | --- |
53 | hw/arm/boot.c | 10 ++++++---- | 8 | tests/qtest/arm-cpu-features.c | 28 ++++++++++++++++++---------- |
54 | 1 file changed, 6 insertions(+), 4 deletions(-) | 9 | 1 file changed, 18 insertions(+), 10 deletions(-) |
55 | 10 | ||
56 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 11 | diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c |
57 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
58 | --- a/hw/arm/boot.c | 13 | --- a/tests/qtest/arm-cpu-features.c |
59 | +++ b/hw/arm/boot.c | 14 | +++ b/tests/qtest/arm-cpu-features.c |
60 | @@ -XXX,XX +XXX,XX @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, | 15 | @@ -XXX,XX +XXX,XX @@ |
16 | #define SVE_MAX_VQ 16 | ||
17 | |||
18 | #define MACHINE "-machine virt,gic-version=max -accel tcg " | ||
19 | -#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accel tcg " | ||
20 | +#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm " | ||
21 | #define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \ | ||
22 | " 'arguments': { 'type': 'full', " | ||
23 | #define QUERY_TAIL "}}" | ||
24 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
25 | { | ||
26 | g_test_init(&argc, &argv, NULL); | ||
27 | |||
28 | - qtest_add_data_func("/arm/query-cpu-model-expansion", | ||
29 | - NULL, test_query_cpu_model_expansion); | ||
30 | + if (qtest_has_accel("tcg")) { | ||
31 | + qtest_add_data_func("/arm/query-cpu-model-expansion", | ||
32 | + NULL, test_query_cpu_model_expansion); | ||
33 | + } | ||
34 | + | ||
35 | + if (!g_str_equal(qtest_get_arch(), "aarch64")) { | ||
36 | + goto out; | ||
37 | + } | ||
38 | |||
39 | /* | ||
40 | * For now we only run KVM specific tests with AArch64 QEMU in | ||
41 | * order avoid attempting to run an AArch32 QEMU with KVM on | ||
42 | * AArch64 hosts. That won't work and isn't easy to detect. | ||
43 | */ | ||
44 | - if (g_str_equal(qtest_get_arch(), "aarch64") && qtest_has_accel("kvm")) { | ||
45 | + if (qtest_has_accel("kvm")) { | ||
46 | /* | ||
47 | * This tests target the 'host' CPU type, so register it only if | ||
48 | * KVM is available. | ||
49 | */ | ||
50 | qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", | ||
51 | NULL, test_query_cpu_model_expansion_kvm); | ||
52 | - } | ||
53 | |||
54 | - if (g_str_equal(qtest_get_arch(), "aarch64")) { | ||
55 | - qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8", | ||
56 | - NULL, sve_tests_sve_max_vq_8); | ||
57 | - qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off", | ||
58 | - NULL, sve_tests_sve_off); | ||
59 | qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off", | ||
60 | NULL, sve_tests_sve_off_kvm); | ||
61 | } | 61 | } |
62 | 62 | ||
63 | if (binfo->initrd_size) { | 63 | + if (qtest_has_accel("tcg")) { |
64 | - rc = qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start", | 64 | + qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8", |
65 | - binfo->initrd_start); | 65 | + NULL, sve_tests_sve_max_vq_8); |
66 | + rc = qemu_fdt_setprop_sized_cells(fdt, "/chosen", "linux,initrd-start", | 66 | + qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off", |
67 | + acells, binfo->initrd_start); | 67 | + NULL, sve_tests_sve_off); |
68 | if (rc < 0) { | 68 | + } |
69 | fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n"); | 69 | + |
70 | goto fail; | 70 | +out: |
71 | } | 71 | return g_test_run(); |
72 | 72 | } | |
73 | - rc = qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", | ||
74 | - binfo->initrd_start + binfo->initrd_size); | ||
75 | + rc = qemu_fdt_setprop_sized_cells(fdt, "/chosen", "linux,initrd-end", | ||
76 | + acells, | ||
77 | + binfo->initrd_start + | ||
78 | + binfo->initrd_size); | ||
79 | if (rc < 0) { | ||
80 | fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); | ||
81 | goto fail; | ||
82 | -- | 73 | -- |
83 | 2.25.1 | 74 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Luke Starrett <lukes@xsightlabs.com> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | The ARM GICv3 TRM describes that the ITLinesNumber field of GICD_TYPER | 3 | These tests set -accel tcg, so restrict them to when TCG is present. |
4 | register: | ||
5 | 4 | ||
6 | "indicates the maximum SPI INTID that the GIC implementation supports" | 5 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
7 | 6 | Acked-by: Richard Henderson <richard.henderson@linaro.org> | |
8 | As SPI #0 is absolute IRQ #32, the max SPI INTID should have accounted | 7 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
9 | for the internal 16x SGI's and 16x PPI's. However, the original GICv3 | ||
10 | model subtracted off the SGI/PPI. Cosmetically this can be seen at OS | ||
11 | boot (Linux) showing 32 shy of what should be there, i.e.: | ||
12 | |||
13 | [ 0.000000] GICv3: 224 SPIs implemented | ||
14 | |||
15 | Though in hw/arm/virt.c, the machine is configured for 256 SPI's. ARM | ||
16 | virt machine likely doesn't have a problem with this because the upper | ||
17 | 32 IRQ's don't actually have anything meaningful wired. But, this does | ||
18 | become a functional issue on a custom use case which wants to make use | ||
19 | of these IRQ's. Additionally, boot code (i.e. TF-A) will only init up | ||
20 | to the number (blocks of 32) that it believes to actually be there. | ||
21 | |||
22 | Signed-off-by: Luke Starrett <lukes@xsightlabs.com> | ||
23 | Message-id: AM9P193MB168473D99B761E204E032095D40D9@AM9P193MB1684.EURP193.PROD.OUTLOOK.COM | ||
24 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
26 | --- | 9 | --- |
27 | hw/intc/arm_gicv3_dist.c | 4 ++-- | 10 | tests/qtest/meson.build | 4 ++-- |
28 | 1 file changed, 2 insertions(+), 2 deletions(-) | 11 | 1 file changed, 2 insertions(+), 2 deletions(-) |
29 | 12 | ||
30 | diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c | 13 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build |
31 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/hw/intc/arm_gicv3_dist.c | 15 | --- a/tests/qtest/meson.build |
33 | +++ b/hw/intc/arm_gicv3_dist.c | 16 | +++ b/tests/qtest/meson.build |
34 | @@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset, | 17 | @@ -XXX,XX +XXX,XX @@ qtests_arm = \ |
35 | * MBIS == 0 (message-based SPIs not supported) | 18 | # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional |
36 | * SecurityExtn == 1 if security extns supported | 19 | qtests_aarch64 = \ |
37 | * CPUNumber == 0 since for us ARE is always 1 | 20 | (cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) + \ |
38 | - * ITLinesNumber == (num external irqs / 32) - 1 | 21 | - (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \ |
39 | + * ITLinesNumber == (((max SPI IntID + 1) / 32) - 1) | 22 | - (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \ |
40 | */ | 23 | + (config_all.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? \ |
41 | - int itlinesnumber = ((s->num_irq - GIC_INTERNAL) / 32) - 1; | 24 | + ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + \ |
42 | + int itlinesnumber = (s->num_irq / 32) - 1; | 25 | (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \ |
43 | /* | 26 | (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \ |
44 | * SecurityExtn must be RAZ if GICD_CTLR.DS == 1, and | 27 | ['arm-cpu-features', |
45 | * "security extensions not supported" always implies DS == 1, | ||
46 | -- | 28 | -- |
47 | 2.25.1 | 29 | 2.34.1 | diff view generated by jsdifflib |