1 | Nothing much exciting here, but it's 37 patches worth... | 1 | The following changes since commit 003ba52a8b327180e284630b289c6ece5a3e08b9: |
---|---|---|---|
2 | 2 | ||
3 | thanks | 3 | Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-02-16 11:16:39 +0000) |
4 | -- PMM | ||
5 | |||
6 | The following changes since commit e64a62df378a746c0b257105959613c9f8122e59: | ||
7 | |||
8 | Merge remote-tracking branch 'remotes/stsquad/tags/pull-testing-040320-1' into staging (2020-03-05 12:13:51 +0000) | ||
9 | 4 | ||
10 | are available in the Git repository at: | 5 | are available in the Git repository at: |
11 | 6 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200305 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230216 |
13 | 8 | ||
14 | for you to fetch changes up to 597d61a3b1f94c53a3aaa77671697c0c5f797dbf: | 9 | for you to fetch changes up to caf01d6a435d9f4a95aeae2f9fc6cb8b889b1fb8: |
15 | 10 | ||
16 | target/arm: Clean address for DC ZVA (2020-03-05 16:09:21 +0000) | 11 | tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG (2023-02-16 16:28:53 +0000) |
17 | 12 | ||
18 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
19 | * versal: Implement ADMA | 14 | target-arm queue: |
20 | * Implement (trivially) ARMv8.2-TTCNP | 15 | * Some mostly M-profile-related code cleanups |
21 | * hw/arm/smmu-common: a fix to smmu_find_smmu_pcibus | 16 | * avocado: Retire the boot_linux.py AArch64 TCG tests |
22 | * Remove unnecessary endianness-handling on some boards | 17 | * hw/arm/smmuv3: Add GBPA register |
23 | * Avoid minor memory leaks from timer_new in some devices | 18 | * arm/virt: don't try to spell out the accelerator |
24 | * Honour more of the HCR_EL2 trap bits | 19 | * hw/arm: Attach PSPI module to NPCM7XX SoC |
25 | * Complain rather than ignoring bad command line options for cubieboard | 20 | * Some cleanup/refactoring patches aiming towards |
26 | * Honour TBI for DC ZVA and exception return | 21 | allowing building Arm targets without CONFIG_TCG |
27 | 22 | ||
28 | ---------------------------------------------------------------- | 23 | ---------------------------------------------------------------- |
29 | Edgar E. Iglesias (2): | 24 | Alex Bennée (1): |
30 | hw/arm: versal: Add support for the LPD ADMAs | 25 | tests/avocado: retire the Aarch64 TCG tests from boot_linux.py |
31 | hw/arm: versal: Generate xlnx-versal-virt zdma FDT nodes | ||
32 | 26 | ||
33 | Eric Auger (1): | 27 | Claudio Fontana (3): |
34 | hw/arm/smmu-common: a fix to smmu_find_smmu_pcibus | 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() | ||
35 | 31 | ||
36 | Niek Linnenbank (4): | 32 | Cornelia Huck (1): |
37 | hw/arm/cubieboard: use ARM Cortex-A8 as the default CPU in machine definition | 33 | arm/virt: don't try to spell out the accelerator |
38 | hw/arm/cubieboard: restrict allowed CPU type to ARM Cortex-A8 | ||
39 | hw/arm/cubieboard: restrict allowed RAM size to 512MiB and 1GiB | ||
40 | hw/arm/cubieboard: report error when using unsupported -bios argument | ||
41 | 34 | ||
42 | Pan Nengyuan (4): | 35 | Fabiano Rosas (7): |
43 | hw/arm/pxa2xx: move timer_new from init() into realize() to avoid memleaks | 36 | target/arm: Move PC alignment check |
44 | hw/arm/spitz: move timer_new from init() into realize() to avoid memleaks | 37 | target/arm: Move cpregs code out of cpu.h |
45 | hw/arm/strongarm: move timer_new from init() into realize() to avoid memleaks | 38 | tests/avocado: Skip tests that require a missing accelerator |
46 | hw/timer/cadence_ttc: move timer_new from init() into realize() to avoid memleaks | 39 | tests/avocado: Tag TCG tests with accel:tcg |
40 | target/arm: Use "max" as default cpu for the virt machine with KVM | ||
41 | tests/qtest: arm-cpu-features: Match tests to required accelerators | ||
42 | tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG | ||
47 | 43 | ||
48 | Peter Maydell (1): | 44 | Hao Wu (3): |
49 | target/arm: Implement (trivially) ARMv8.2-TTCNP | 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 | ||
50 | 48 | ||
51 | Philippe Mathieu-Daudé (6): | 49 | Jean-Philippe Brucker (2): |
52 | hw/arm/smmu-common: Simplify smmu_find_smmu_pcibus() logic | 50 | hw/arm/smmu-common: Support 64-bit addresses |
53 | hw/arm/gumstix: Simplify since the machines are little-endian only | 51 | hw/arm/smmu-common: Fix TTB1 handling |
54 | hw/arm/mainstone: Simplify since the machines are little-endian only | ||
55 | hw/arm/omap_sx1: Simplify since the machines are little-endian only | ||
56 | hw/arm/z2: Simplify since the machines are little-endian only | ||
57 | hw/arm/musicpal: Simplify since the machines are little-endian only | ||
58 | 52 | ||
59 | Richard Henderson (19): | 53 | Mostafa Saleh (1): |
60 | target/arm: Improve masking of HCR/HCR2 RES0 bits | 54 | hw/arm/smmuv3: Add GBPA register |
61 | target/arm: Add HCR_EL2 bit definitions from ARMv8.6 | ||
62 | target/arm: Disable has_el2 and has_el3 for user-only | ||
63 | target/arm: Remove EL2 and EL3 setup from user-only | ||
64 | target/arm: Improve masking in arm_hcr_el2_eff | ||
65 | target/arm: Honor the HCR_EL2.{TVM,TRVM} bits | ||
66 | target/arm: Honor the HCR_EL2.TSW bit | ||
67 | target/arm: Honor the HCR_EL2.TACR bit | ||
68 | target/arm: Honor the HCR_EL2.TPCP bit | ||
69 | target/arm: Honor the HCR_EL2.TPU bit | ||
70 | target/arm: Honor the HCR_EL2.TTLB bit | ||
71 | tests/tcg/aarch64: Add newline in pauth-1 printf | ||
72 | target/arm: Replicate TBI/TBID bits for single range regimes | ||
73 | target/arm: Optimize cpu_mmu_index | ||
74 | target/arm: Introduce core_to_aa64_mmu_idx | ||
75 | target/arm: Apply TBI to ESR_ELx in helper_exception_return | ||
76 | target/arm: Move helper_dc_zva to helper-a64.c | ||
77 | target/arm: Use DEF_HELPER_FLAGS for helper_dc_zva | ||
78 | target/arm: Clean address for DC ZVA | ||
79 | 55 | ||
80 | include/hw/arm/xlnx-versal.h | 6 + | 56 | Philippe Mathieu-Daudé (12): |
81 | target/arm/cpu.h | 30 ++-- | 57 | hw/intc/armv7m_nvic: Use OBJECT_DECLARE_SIMPLE_TYPE() macro |
82 | target/arm/helper-a64.h | 1 + | 58 | target/arm: Simplify arm_v7m_mmu_idx_for_secstate() for user emulation |
83 | target/arm/helper.h | 1 - | 59 | target/arm: Reduce arm_v7m_mmu_idx_[all/for_secstate_and_priv]() scope |
84 | target/arm/internals.h | 6 + | 60 | target/arm: Constify ID_PFR1 on user emulation |
85 | hw/arm/cubieboard.c | 29 +++- | 61 | target/arm: Convert CPUARMState::eabi to boolean |
86 | hw/arm/gumstix.c | 16 +- | 62 | target/arm: Avoid resetting CPUARMState::eabi field |
87 | hw/arm/mainstone.c | 8 +- | 63 | target/arm: Restrict CPUARMState::gicv3state to sysemu |
88 | hw/arm/musicpal.c | 10 -- | 64 | target/arm: Restrict CPUARMState::arm_boot_info to sysemu |
89 | hw/arm/omap_sx1.c | 11 +- | 65 | target/arm: Restrict CPUARMState::nvic to sysemu |
90 | hw/arm/pxa2xx.c | 17 +- | 66 | target/arm: Store CPUARMState::nvic as NVICState* |
91 | hw/arm/smmu-common.c | 20 +-- | 67 | target/arm: Declare CPU <-> NVIC helpers in 'hw/intc/armv7m_nvic.h' |
92 | hw/arm/spitz.c | 8 +- | 68 | hw/arm: Add missing XLNX_ZYNQMP_ARM -> USB_DWC3 Kconfig dependency |
93 | hw/arm/strongarm.c | 18 ++- | ||
94 | hw/arm/xlnx-versal-virt.c | 28 ++++ | ||
95 | hw/arm/xlnx-versal.c | 24 +++ | ||
96 | hw/arm/z2.c | 8 +- | ||
97 | hw/timer/cadence_ttc.c | 18 ++- | ||
98 | target/arm/cpu.c | 13 +- | ||
99 | target/arm/cpu64.c | 2 + | ||
100 | target/arm/helper-a64.c | 114 ++++++++++++- | ||
101 | target/arm/helper.c | 373 ++++++++++++++++++++++++++++++------------- | ||
102 | target/arm/op_helper.c | 93 ----------- | ||
103 | target/arm/translate-a64.c | 4 +- | ||
104 | tests/tcg/aarch64/pauth-1.c | 2 +- | ||
105 | 25 files changed, 551 insertions(+), 309 deletions(-) | ||
106 | 69 | ||
70 | MAINTAINERS | 8 +- | ||
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 | ||
107 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This data access was forgotten when we added support for cleaning | 3 | Manually convert to OBJECT_DECLARE_SIMPLE_TYPE() macro, |
4 | addresses of TBI information. | 4 | similarly to automatic conversion from commit 8063396bf3 |
5 | ("Use OBJECT_DECLARE_SIMPLE_TYPE when possible"). | ||
5 | 6 | ||
6 | Fixes: 3a471103ac1823ba | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Message-id: 20230206223502.25122-2-philmd@linaro.org |
9 | Message-id: 20200302175829.2183-8-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | target/arm/translate-a64.c | 2 +- | 12 | include/hw/intc/armv7m_nvic.h | 5 +---- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 13 | 1 file changed, 1 insertion(+), 4 deletions(-) |
14 | 14 | ||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 15 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 17 | --- a/include/hw/intc/armv7m_nvic.h |
18 | +++ b/target/arm/translate-a64.c | 18 | +++ b/include/hw/intc/armv7m_nvic.h |
19 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | 19 | @@ -XXX,XX +XXX,XX @@ |
20 | return; | 20 | #include "qom/object.h" |
21 | case ARM_CP_DC_ZVA: | 21 | |
22 | /* Writes clear the aligned block of memory which rt points into. */ | 22 | #define TYPE_NVIC "armv7m_nvic" |
23 | - tcg_rt = cpu_reg(s, rt); | 23 | - |
24 | + tcg_rt = clean_data_tbi(s, cpu_reg(s, rt)); | 24 | -typedef struct NVICState NVICState; |
25 | gen_helper_dc_zva(cpu_env, tcg_rt); | 25 | -DECLARE_INSTANCE_CHECKER(NVICState, NVIC, |
26 | return; | 26 | - TYPE_NVIC) |
27 | default: | 27 | +OBJECT_DECLARE_SIMPLE_TYPE(NVICState, NVIC) |
28 | |||
29 | /* Highest permitted number of exceptions (architectural limit) */ | ||
30 | #define NVIC_MAX_VECTORS 512 | ||
28 | -- | 31 | -- |
29 | 2.20.1 | 32 | 2.34.1 |
30 | 33 | ||
31 | 34 | diff view generated by jsdifflib |
1 | From: Pan Nengyuan <pannengyuan@huawei.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | There are some memleaks when we call 'device_list_properties'. This patch move timer_new from init into realize to fix it. | 3 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> |
4 | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
5 | Reported-by: Euler Robot <euler.robot@huawei.com> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com> | 6 | Message-id: 20230206223502.25122-3-philmd@linaro.org |
7 | Message-id: 20200227025055.14341-4-pannengyuan@huawei.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 8 | --- |
11 | hw/arm/spitz.c | 8 +++++++- | 9 | target/arm/m_helper.c | 11 ++++++++--- |
12 | 1 file changed, 7 insertions(+), 1 deletion(-) | 10 | 1 file changed, 8 insertions(+), 3 deletions(-) |
13 | 11 | ||
14 | diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c | 12 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/spitz.c | 14 | --- a/target/arm/m_helper.c |
17 | +++ b/hw/arm/spitz.c | 15 | +++ b/target/arm/m_helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static void spitz_keyboard_init(Object *obj) | 16 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) |
19 | 17 | return 0; | |
20 | spitz_keyboard_pre_map(s); | ||
21 | |||
22 | - s->kbdtimer = timer_new_ns(QEMU_CLOCK_VIRTUAL, spitz_keyboard_tick, s); | ||
23 | qdev_init_gpio_in(dev, spitz_keyboard_strobe, SPITZ_KEY_STROBE_NUM); | ||
24 | qdev_init_gpio_out(dev, s->sense, SPITZ_KEY_SENSE_NUM); | ||
25 | } | 18 | } |
26 | 19 | ||
27 | +static void spitz_keyboard_realize(DeviceState *dev, Error **errp) | 20 | -#else |
21 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | ||
28 | +{ | 22 | +{ |
29 | + SpitzKeyboardState *s = SPITZ_KEYBOARD(dev); | 23 | + return ARMMMUIdx_MUser; |
30 | + s->kbdtimer = timer_new_ns(QEMU_CLOCK_VIRTUAL, spitz_keyboard_tick, s); | ||
31 | +} | 24 | +} |
32 | + | 25 | + |
33 | /* LCD backlight controller */ | 26 | +#else /* !CONFIG_USER_ONLY */ |
34 | 27 | ||
35 | #define LCDTG_RESCTL 0x00 | 28 | /* |
36 | @@ -XXX,XX +XXX,XX @@ static void spitz_keyboard_class_init(ObjectClass *klass, void *data) | 29 | * What kind of stack write are we doing? This affects how exceptions |
37 | DeviceClass *dc = DEVICE_CLASS(klass); | 30 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) |
38 | 31 | return tt_resp; | |
39 | dc->vmsd = &vmstate_spitz_kbd; | ||
40 | + dc->realize = spitz_keyboard_realize; | ||
41 | } | 32 | } |
42 | 33 | ||
43 | static const TypeInfo spitz_keyboard_info = { | 34 | -#endif /* !CONFIG_USER_ONLY */ |
35 | - | ||
36 | ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | ||
37 | bool secstate, bool priv, bool negpri) | ||
38 | { | ||
39 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | ||
40 | |||
41 | return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); | ||
42 | } | ||
43 | + | ||
44 | +#endif /* !CONFIG_USER_ONLY */ | ||
44 | -- | 45 | -- |
45 | 2.20.1 | 46 | 2.34.1 |
46 | 47 | ||
47 | 48 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | If by context we know that we're in AArch64 mode, we need not | 3 | arm_v7m_mmu_idx_all() and arm_v7m_mmu_idx_for_secstate_and_priv() |
4 | test for M-profile when reconstructing the full ARMMMUIdx. | 4 | are only used for system emulation in m_helper.c. |
5 | Move the definitions to avoid prototype forward declarations. | ||
5 | 6 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Message-id: 20230206223502.25122-4-philmd@linaro.org |
9 | Message-id: 20200302175829.2183-4-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | target/arm/internals.h | 6 ++++++ | 12 | target/arm/internals.h | 14 -------- |
13 | target/arm/translate-a64.c | 2 +- | 13 | target/arm/m_helper.c | 74 +++++++++++++++++++++--------------------- |
14 | 2 files changed, 7 insertions(+), 1 deletion(-) | 14 | 2 files changed, 37 insertions(+), 51 deletions(-) |
15 | 15 | ||
16 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 16 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/internals.h | 18 | --- a/target/arm/internals.h |
19 | +++ b/target/arm/internals.h | 19 | +++ b/target/arm/internals.h |
20 | @@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx core_to_arm_mmu_idx(CPUARMState *env, int mmu_idx) | 20 | @@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx core_to_aa64_mmu_idx(int mmu_idx) |
21 | } | 21 | |
22 | } | 22 | int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx); |
23 | 23 | ||
24 | +static inline ARMMMUIdx core_to_aa64_mmu_idx(int mmu_idx) | 24 | -/* |
25 | - * Return the MMU index for a v7M CPU with all relevant information | ||
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) | ||
25 | +{ | 51 | +{ |
26 | + /* AArch64 is always a-profile. */ | 52 | + ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; |
27 | + return mmu_idx | ARM_MMU_IDX_A; | 53 | + |
54 | + if (priv) { | ||
55 | + mmu_idx |= ARM_MMU_IDX_M_PRIV; | ||
56 | + } | ||
57 | + | ||
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; | ||
28 | +} | 67 | +} |
29 | + | 68 | + |
30 | int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx); | 69 | +static ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, |
31 | 70 | + bool secstate, bool priv) | |
71 | +{ | ||
72 | + bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate); | ||
73 | + | ||
74 | + return arm_v7m_mmu_idx_all(env, secstate, priv, negpri); | ||
75 | +} | ||
76 | + | ||
77 | +/* Return the MMU index for a v7M CPU in the specified security state */ | ||
78 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | ||
79 | +{ | ||
80 | + bool priv = arm_v7m_is_handler_mode(env) || | ||
81 | + !(env->v7m.control[secstate] & 1); | ||
82 | + | ||
83 | + return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); | ||
84 | +} | ||
85 | + | ||
32 | /* | 86 | /* |
33 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 87 | * What kind of stack write are we doing? This affects how exceptions |
34 | index XXXXXXX..XXXXXXX 100644 | 88 | * generated during the stacking are treated. |
35 | --- a/target/arm/translate-a64.c | 89 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) |
36 | +++ b/target/arm/translate-a64.c | 90 | return tt_resp; |
37 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | 91 | } |
38 | dc->condexec_mask = 0; | 92 | |
39 | dc->condexec_cond = 0; | 93 | -ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, |
40 | core_mmu_idx = FIELD_EX32(tb_flags, TBFLAG_ANY, MMUIDX); | 94 | - bool secstate, bool priv, bool negpri) |
41 | - dc->mmu_idx = core_to_arm_mmu_idx(env, core_mmu_idx); | 95 | -{ |
42 | + dc->mmu_idx = core_to_aa64_mmu_idx(core_mmu_idx); | 96 | - ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; |
43 | dc->tbii = FIELD_EX32(tb_flags, TBFLAG_A64, TBII); | 97 | - |
44 | dc->tbid = FIELD_EX32(tb_flags, TBFLAG_A64, TBID); | 98 | - if (priv) { |
45 | dc->current_el = arm_mmu_idx_to_el(dc->mmu_idx); | 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 */ | ||
46 | -- | 131 | -- |
47 | 2.20.1 | 132 | 2.34.1 |
48 | 133 | ||
49 | 134 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Replicate the single TBI bit from TCR_EL2 and TCR_EL3 so that | 3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
4 | we can unconditionally use pointer bit 55 to index into our | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | composite TBI1:TBI0 field. | 5 | Message-id: 20230206223502.25122-5-philmd@linaro.org |
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20200302175829.2183-2-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 7 | --- |
13 | target/arm/helper.c | 6 ++++-- | 8 | target/arm/helper.c | 12 ++++++++++-- |
14 | 1 file changed, 4 insertions(+), 2 deletions(-) | 9 | 1 file changed, 10 insertions(+), 2 deletions(-) |
15 | 10 | ||
16 | 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 |
17 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper.c | 13 | --- a/target/arm/helper.c |
19 | +++ b/target/arm/helper.c | 14 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx) | 15 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) |
21 | } else if (mmu_idx == ARMMMUIdx_Stage2) { | ||
22 | return 0; /* VTCR_EL2 */ | ||
23 | } else { | ||
24 | - return extract32(tcr, 20, 1); | ||
25 | + /* Replicate the single TBI bit so we always have 2 bits. */ | ||
26 | + return extract32(tcr, 20, 1) * 3; | ||
27 | } | 16 | } |
28 | } | 17 | } |
29 | 18 | ||
30 | @@ -XXX,XX +XXX,XX @@ static int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx) | 19 | +#ifndef CONFIG_USER_ONLY |
31 | } else if (mmu_idx == ARMMMUIdx_Stage2) { | 20 | /* |
32 | return 0; /* VTCR_EL2 */ | 21 | * We don't know until after realize whether there's a GICv3 |
33 | } else { | 22 | * attached, and that is what registers the gicv3 sysregs. |
34 | - return extract32(tcr, 29, 1); | 23 | @@ -XXX,XX +XXX,XX @@ static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri) |
35 | + /* Replicate the single TBID bit so we always have 2 bits. */ | 24 | return pfr1; |
36 | + return extract32(tcr, 29, 1) * 3; | ||
37 | } | ||
38 | } | 25 | } |
39 | 26 | ||
27 | -#ifndef CONFIG_USER_ONLY | ||
28 | static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
29 | { | ||
30 | ARMCPU *cpu = env_archcpu(env); | ||
31 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
32 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 1, | ||
33 | .access = PL1_R, .type = ARM_CP_NO_RAW, | ||
34 | .accessfn = access_aa32_tid3, | ||
35 | +#ifdef CONFIG_USER_ONLY | ||
36 | + .type = ARM_CP_CONST, | ||
37 | + .resetvalue = cpu->isar.id_pfr1, | ||
38 | +#else | ||
39 | + .type = ARM_CP_NO_RAW, | ||
40 | + .accessfn = access_aa32_tid3, | ||
41 | .readfn = id_pfr1_read, | ||
42 | - .writefn = arm_cp_write_ignore }, | ||
43 | + .writefn = arm_cp_write_ignore | ||
44 | +#endif | ||
45 | + }, | ||
46 | { .name = "ID_DFR0", .state = ARM_CP_STATE_BOTH, | ||
47 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 2, | ||
48 | .access = PL1_R, .type = ARM_CP_CONST, | ||
40 | -- | 49 | -- |
41 | 2.20.1 | 50 | 2.34.1 |
42 | 51 | ||
43 | 52 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add support for the Versal LPD ADMAs. | 3 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> |
4 | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | 6 | Message-id: 20230206223502.25122-6-philmd@linaro.org |
7 | Reviewed-by: KONRAD Frederic <frederic.konrad@adacore.com> | ||
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 8 | --- |
11 | include/hw/arm/xlnx-versal.h | 6 ++++++ | 9 | linux-user/user-internals.h | 2 +- |
12 | hw/arm/xlnx-versal.c | 24 ++++++++++++++++++++++++ | 10 | target/arm/cpu.h | 2 +- |
13 | 2 files changed, 30 insertions(+) | 11 | linux-user/arm/cpu_loop.c | 4 ++-- |
12 | 3 files changed, 4 insertions(+), 4 deletions(-) | ||
14 | 13 | ||
15 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 14 | diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/xlnx-versal.h | 16 | --- a/linux-user/user-internals.h |
18 | +++ b/include/hw/arm/xlnx-versal.h | 17 | +++ b/linux-user/user-internals.h |
19 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ void print_termios(void *arg); |
20 | #define XLNX_VERSAL_NR_ACPUS 2 | 19 | #ifdef TARGET_ARM |
21 | #define XLNX_VERSAL_NR_UARTS 2 | 20 | static inline int regpairs_aligned(CPUArchState *cpu_env, int num) |
22 | #define XLNX_VERSAL_NR_GEMS 2 | 21 | { |
23 | +#define XLNX_VERSAL_NR_ADMAS 8 | 22 | - return cpu_env->eabi == 1; |
24 | #define XLNX_VERSAL_NR_IRQS 192 | 23 | + return cpu_env->eabi; |
25 | 24 | } | |
26 | typedef struct Versal { | 25 | #elif defined(TARGET_MIPS) && defined(TARGET_ABI_MIPSO32) |
27 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | 26 | static inline int regpairs_aligned(CPUArchState *cpu_env, int num) { return 1; } |
28 | struct { | 27 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
29 | SysBusDevice *uart[XLNX_VERSAL_NR_UARTS]; | ||
30 | SysBusDevice *gem[XLNX_VERSAL_NR_GEMS]; | ||
31 | + SysBusDevice *adma[XLNX_VERSAL_NR_ADMAS]; | ||
32 | } iou; | ||
33 | } lpd; | ||
34 | |||
35 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | ||
36 | #define VERSAL_GEM0_WAKE_IRQ_0 57 | ||
37 | #define VERSAL_GEM1_IRQ_0 58 | ||
38 | #define VERSAL_GEM1_WAKE_IRQ_0 59 | ||
39 | +#define VERSAL_ADMA_IRQ_0 60 | ||
40 | |||
41 | /* Architecturally reserved IRQs suitable for virtualization. */ | ||
42 | #define VERSAL_RSVD_IRQ_FIRST 111 | ||
43 | @@ -XXX,XX +XXX,XX @@ typedef struct Versal { | ||
44 | #define MM_GEM1 0xff0d0000U | ||
45 | #define MM_GEM1_SIZE 0x10000 | ||
46 | |||
47 | +#define MM_ADMA_CH0 0xffa80000U | ||
48 | +#define MM_ADMA_CH0_SIZE 0x10000 | ||
49 | + | ||
50 | #define MM_OCM 0xfffc0000U | ||
51 | #define MM_OCM_SIZE 0x40000 | ||
52 | |||
53 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/hw/arm/xlnx-versal.c | 29 | --- a/target/arm/cpu.h |
56 | +++ b/hw/arm/xlnx-versal.c | 30 | +++ b/target/arm/cpu.h |
57 | @@ -XXX,XX +XXX,XX @@ static void versal_create_gems(Versal *s, qemu_irq *pic) | 31 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
58 | } | 32 | |
59 | } | 33 | #if defined(CONFIG_USER_ONLY) |
60 | 34 | /* For usermode syscall translation. */ | |
61 | +static void versal_create_admas(Versal *s, qemu_irq *pic) | 35 | - int eabi; |
62 | +{ | 36 | + bool eabi; |
63 | + int i; | 37 | #endif |
64 | + | 38 | |
65 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.adma); i++) { | 39 | struct CPUBreakpoint *cpu_breakpoint[16]; |
66 | + char *name = g_strdup_printf("adma%d", i); | 40 | diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c |
67 | + DeviceState *dev; | 41 | index XXXXXXX..XXXXXXX 100644 |
68 | + MemoryRegion *mr; | 42 | --- a/linux-user/arm/cpu_loop.c |
69 | + | 43 | +++ b/linux-user/arm/cpu_loop.c |
70 | + dev = qdev_create(NULL, "xlnx.zdma"); | 44 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) |
71 | + s->lpd.iou.adma[i] = SYS_BUS_DEVICE(dev); | 45 | break; |
72 | + object_property_add_child(OBJECT(s), name, OBJECT(dev), &error_fatal); | 46 | case EXCP_SWI: |
73 | + qdev_init_nofail(dev); | 47 | { |
74 | + | 48 | - env->eabi = 1; |
75 | + mr = sysbus_mmio_get_region(s->lpd.iou.adma[i], 0); | 49 | + env->eabi = true; |
76 | + memory_region_add_subregion(&s->mr_ps, | 50 | /* system call */ |
77 | + MM_ADMA_CH0 + i * MM_ADMA_CH0_SIZE, mr); | 51 | if (env->thumb) { |
78 | + | 52 | /* Thumb is always EABI style with syscall number in r7 */ |
79 | + sysbus_connect_irq(s->lpd.iou.adma[i], 0, pic[VERSAL_ADMA_IRQ_0 + i]); | 53 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) |
80 | + g_free(name); | 54 | * > 0xfffff and are handled below as out-of-range. |
81 | + } | 55 | */ |
82 | +} | 56 | n ^= ARM_SYSCALL_BASE; |
83 | + | 57 | - env->eabi = 0; |
84 | /* This takes the board allocated linear DDR memory and creates aliases | 58 | + env->eabi = false; |
85 | * for each split DDR range/aperture on the Versal address map. | 59 | } |
86 | */ | 60 | } |
87 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | ||
88 | versal_create_apu_gic(s, pic); | ||
89 | versal_create_uarts(s, pic); | ||
90 | versal_create_gems(s, pic); | ||
91 | + versal_create_admas(s, pic); | ||
92 | versal_map_ddr(s); | ||
93 | versal_unimp(s); | ||
94 | 61 | ||
95 | -- | 62 | -- |
96 | 2.20.1 | 63 | 2.34.1 |
97 | 64 | ||
98 | 65 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com> | ||
2 | 1 | ||
3 | Generate xlnx-versal-virt zdma FDT nodes. | ||
4 | |||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
6 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
7 | Reviewed-by: KONRAD Frederic <frederic.konrad@adacore.com> | ||
8 | Reviewed-by: Luc Michel <luc.michel@greensocs.com> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/arm/xlnx-versal-virt.c | 28 ++++++++++++++++++++++++++++ | ||
12 | 1 file changed, 28 insertions(+) | ||
13 | |||
14 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/arm/xlnx-versal-virt.c | ||
17 | +++ b/hw/arm/xlnx-versal-virt.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_gem_nodes(VersalVirt *s) | ||
19 | } | ||
20 | } | ||
21 | |||
22 | +static void fdt_add_zdma_nodes(VersalVirt *s) | ||
23 | +{ | ||
24 | + const char clocknames[] = "clk_main\0clk_apb"; | ||
25 | + const char compat[] = "xlnx,zynqmp-dma-1.0"; | ||
26 | + int i; | ||
27 | + | ||
28 | + for (i = XLNX_VERSAL_NR_ADMAS - 1; i >= 0; i--) { | ||
29 | + uint64_t addr = MM_ADMA_CH0 + MM_ADMA_CH0_SIZE * i; | ||
30 | + char *name = g_strdup_printf("/dma@%" PRIx64, addr); | ||
31 | + | ||
32 | + qemu_fdt_add_subnode(s->fdt, name); | ||
33 | + | ||
34 | + qemu_fdt_setprop_cell(s->fdt, name, "xlnx,bus-width", 64); | ||
35 | + qemu_fdt_setprop_cells(s->fdt, name, "clocks", | ||
36 | + s->phandle.clk_25Mhz, s->phandle.clk_25Mhz); | ||
37 | + qemu_fdt_setprop(s->fdt, name, "clock-names", | ||
38 | + clocknames, sizeof(clocknames)); | ||
39 | + qemu_fdt_setprop_cells(s->fdt, name, "interrupts", | ||
40 | + GIC_FDT_IRQ_TYPE_SPI, VERSAL_ADMA_IRQ_0 + i, | ||
41 | + GIC_FDT_IRQ_FLAGS_LEVEL_HI); | ||
42 | + qemu_fdt_setprop_sized_cells(s->fdt, name, "reg", | ||
43 | + 2, addr, 2, 0x1000); | ||
44 | + qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat)); | ||
45 | + g_free(name); | ||
46 | + } | ||
47 | +} | ||
48 | + | ||
49 | static void fdt_nop_memory_nodes(void *fdt, Error **errp) | ||
50 | { | ||
51 | Error *err = NULL; | ||
52 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine) | ||
53 | fdt_add_uart_nodes(s); | ||
54 | fdt_add_gic_nodes(s); | ||
55 | fdt_add_timer_nodes(s); | ||
56 | + fdt_add_zdma_nodes(s); | ||
57 | fdt_add_cpu_nodes(s, psci_conduit); | ||
58 | fdt_add_clk_node(s, "/clk125", 125000000, s->phandle.clk_125Mhz); | ||
59 | fdt_add_clk_node(s, "/clk25", 25000000, s->phandle.clk_25Mhz); | ||
60 | -- | ||
61 | 2.20.1 | ||
62 | |||
63 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The ARMv8.2-TTCNP extension allows an implementation to optimize by | ||
2 | sharing TLB entries between multiple cores, provided that software | ||
3 | declares that it's ready to deal with this by setting a CnP bit in | ||
4 | the TTBRn_ELx. It is mandatory from ARMv8.2 onward. | ||
5 | 1 | ||
6 | For QEMU's TLB implementation, sharing TLB entries between different | ||
7 | cores would not really benefit us and would be a lot of work to | ||
8 | implement. So we implement this extension in the "trivial" manner: | ||
9 | we allow the guest to set and read back the CnP bit, but don't change | ||
10 | our behaviour (this is an architecturally valid implementation | ||
11 | choice). | ||
12 | |||
13 | The only code path which looks at the TTBRn_ELx values for the | ||
14 | long-descriptor format where the CnP bit is defined is already doing | ||
15 | enough masking to not get confused when the CnP bit at the bottom of | ||
16 | the register is set, so we can simply add a comment noting why we're | ||
17 | relying on that mask. | ||
18 | |||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-id: 20200225193822.18874-1-peter.maydell@linaro.org | ||
22 | --- | ||
23 | target/arm/cpu.c | 1 + | ||
24 | target/arm/cpu64.c | 2 ++ | ||
25 | target/arm/helper.c | 4 ++++ | ||
26 | 3 files changed, 7 insertions(+) | ||
27 | |||
28 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/cpu.c | ||
31 | +++ b/target/arm/cpu.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | ||
33 | t = cpu->isar.id_mmfr4; | ||
34 | t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
35 | t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
36 | + t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
37 | cpu->isar.id_mmfr4 = t; | ||
38 | } | ||
39 | #endif | ||
40 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/cpu64.c | ||
43 | +++ b/target/arm/cpu64.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
45 | |||
46 | t = cpu->isar.id_aa64mmfr2; | ||
47 | t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); | ||
48 | + t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* TTCNP */ | ||
49 | cpu->isar.id_aa64mmfr2 = t; | ||
50 | |||
51 | /* Replicate the same data to the 32-bit id registers. */ | ||
52 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
53 | u = cpu->isar.id_mmfr4; | ||
54 | u = FIELD_DP32(u, ID_MMFR4, HPDS, 1); /* AA32HPD */ | ||
55 | u = FIELD_DP32(u, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ | ||
56 | + u = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */ | ||
57 | cpu->isar.id_mmfr4 = u; | ||
58 | |||
59 | u = cpu->isar.id_aa64dfr0; | ||
60 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/helper.c | ||
63 | +++ b/target/arm/helper.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, | ||
65 | |||
66 | /* Now we can extract the actual base address from the TTBR */ | ||
67 | descaddr = extract64(ttbr, 0, 48); | ||
68 | + /* | ||
69 | + * We rely on this masking to clear the RES0 bits at the bottom of the TTBR | ||
70 | + * and also to mask out CnP (bit 0) which could validly be non-zero. | ||
71 | + */ | ||
72 | descaddr &= ~indexmask; | ||
73 | |||
74 | /* The address field in the descriptor goes up to bit 39 for ARMv7 | ||
75 | -- | ||
76 | 2.20.1 | ||
77 | |||
78 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We only build the little-endian softmmu configurations. Checking | 3 | Although the 'eabi' field is only used in user emulation where |
4 | for big endian is pointless, remove the unused code. | 4 | CPU reset doesn't occur, it doesn't belong to the area to reset. |
5 | Move it after the 'end_reset_fields' for consistency. | ||
5 | 6 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Message-id: 20230206223502.25122-7-philmd@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | hw/arm/omap_sx1.c | 11 ++--------- | 12 | target/arm/cpu.h | 9 ++++----- |
11 | 1 file changed, 2 insertions(+), 9 deletions(-) | 13 | 1 file changed, 4 insertions(+), 5 deletions(-) |
12 | 14 | ||
13 | diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/omap_sx1.c | 17 | --- a/target/arm/cpu.h |
16 | +++ b/hw/arm/omap_sx1.c | 18 | +++ b/target/arm/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version) | 19 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
18 | DriveInfo *dinfo; | 20 | ARMVectorReg zarray[ARM_MAX_VQ * 16]; |
19 | int fl_idx; | 21 | #endif |
20 | uint32_t flash_size = flash0_size; | 22 | |
21 | - int be; | 23 | -#if defined(CONFIG_USER_ONLY) |
22 | 24 | - /* For usermode syscall translation. */ | |
23 | if (machine->ram_size != mc->default_ram_size) { | 25 | - bool eabi; |
24 | char *sz = size_to_str(mc->default_ram_size); | ||
25 | @@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version) | ||
26 | OMAP_CS2_BASE, &cs[3]); | ||
27 | |||
28 | fl_idx = 0; | ||
29 | -#ifdef TARGET_WORDS_BIGENDIAN | ||
30 | - be = 1; | ||
31 | -#else | ||
32 | - be = 0; | ||
33 | -#endif | 26 | -#endif |
34 | - | 27 | - |
35 | if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { | 28 | struct CPUBreakpoint *cpu_breakpoint[16]; |
36 | if (!pflash_cfi01_register(OMAP_CS0_BASE, | 29 | struct CPUWatchpoint *cpu_watchpoint[16]; |
37 | "omap_sx1.flash0-1", flash_size, | 30 | |
38 | blk_by_legacy_dinfo(dinfo), | 31 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
39 | - sector_size, 4, 0, 0, 0, 0, be)) { | 32 | const struct arm_boot_info *boot_info; |
40 | + sector_size, 4, 0, 0, 0, 0, 0)) { | 33 | /* Store GICv3CPUState to access from this struct */ |
41 | fprintf(stderr, "qemu: Error registering flash memory %d.\n", | 34 | void *gicv3state; |
42 | fl_idx); | 35 | +#if defined(CONFIG_USER_ONLY) |
43 | } | 36 | + /* For usermode syscall translation. */ |
44 | @@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version) | 37 | + bool eabi; |
45 | if (!pflash_cfi01_register(OMAP_CS1_BASE, | 38 | +#endif /* CONFIG_USER_ONLY */ |
46 | "omap_sx1.flash1-1", flash1_size, | 39 | |
47 | blk_by_legacy_dinfo(dinfo), | 40 | #ifdef TARGET_TAGGED_ADDRESSES |
48 | - sector_size, 4, 0, 0, 0, 0, be)) { | 41 | /* Linux syscall tagged address support */ |
49 | + sector_size, 4, 0, 0, 0, 0, 0)) { | ||
50 | fprintf(stderr, "qemu: Error registering flash memory %d.\n", | ||
51 | fl_idx); | ||
52 | } | ||
53 | -- | 42 | -- |
54 | 2.20.1 | 43 | 2.34.1 |
55 | 44 | ||
56 | 45 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We now cache the core mmu_idx in env->hflags. Rather than recompute | 3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
4 | from scratch, extract the field. All of the uses of cpu_mmu_index | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | within target/arm are within helpers, and env->hflags is always stable | 5 | Message-id: 20230206223502.25122-8-philmd@linaro.org |
6 | within a translation block from whence helpers are called. | ||
7 | |||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20200302175829.2183-3-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 7 | --- |
13 | target/arm/cpu.h | 23 +++++++++++++---------- | 8 | target/arm/cpu.h | 3 ++- |
14 | target/arm/helper.c | 5 ----- | 9 | 1 file changed, 2 insertions(+), 1 deletion(-) |
15 | 2 files changed, 13 insertions(+), 15 deletions(-) | ||
16 | 10 | ||
17 | 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 |
18 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/cpu.h | 13 | --- a/target/arm/cpu.h |
20 | +++ b/target/arm/cpu.h | 14 | +++ b/target/arm/cpu.h |
21 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdxBit { | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
22 | 16 | ||
23 | #define MMU_USER_IDX 0 | 17 | void *nvic; |
24 | 18 | const struct arm_boot_info *boot_info; | |
25 | -/** | 19 | +#if !defined(CONFIG_USER_ONLY) |
26 | - * cpu_mmu_index: | 20 | /* Store GICv3CPUState to access from this struct */ |
27 | - * @env: The cpu environment | 21 | void *gicv3state; |
28 | - * @ifetch: True for code access, false for data access. | 22 | -#if defined(CONFIG_USER_ONLY) |
29 | - * | 23 | +#else /* CONFIG_USER_ONLY */ |
30 | - * Return the core mmu index for the current translation regime. | 24 | /* For usermode syscall translation. */ |
31 | - * This function is used by generic TCG code paths. | 25 | bool eabi; |
32 | - */ | 26 | #endif /* CONFIG_USER_ONLY */ |
33 | -int cpu_mmu_index(CPUARMState *env, bool ifetch); | ||
34 | - | ||
35 | /* Indexes used when registering address spaces with cpu_address_space_init */ | ||
36 | typedef enum ARMASIdx { | ||
37 | ARMASIdx_NS = 0, | ||
38 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, BTYPE, 10, 2) /* Not cached. */ | ||
39 | FIELD(TBFLAG_A64, TBID, 12, 2) | ||
40 | FIELD(TBFLAG_A64, UNPRIV, 14, 1) | ||
41 | |||
42 | +/** | ||
43 | + * cpu_mmu_index: | ||
44 | + * @env: The cpu environment | ||
45 | + * @ifetch: True for code access, false for data access. | ||
46 | + * | ||
47 | + * Return the core mmu index for the current translation regime. | ||
48 | + * This function is used by generic TCG code paths. | ||
49 | + */ | ||
50 | +static inline int cpu_mmu_index(CPUARMState *env, bool ifetch) | ||
51 | +{ | ||
52 | + return FIELD_EX32(env->hflags, TBFLAG_ANY, MMUIDX); | ||
53 | +} | ||
54 | + | ||
55 | static inline bool bswap_code(bool sctlr_b) | ||
56 | { | ||
57 | #ifdef CONFIG_USER_ONLY | ||
58 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/helper.c | ||
61 | +++ b/target/arm/helper.c | ||
62 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env) | ||
63 | return arm_mmu_idx_el(env, arm_current_el(env)); | ||
64 | } | ||
65 | |||
66 | -int cpu_mmu_index(CPUARMState *env, bool ifetch) | ||
67 | -{ | ||
68 | - return arm_to_core_mmu_idx(arm_mmu_idx(env)); | ||
69 | -} | ||
70 | - | ||
71 | #ifndef CONFIG_USER_ONLY | ||
72 | ARMMMUIdx arm_stage1_mmu_idx(CPUARMState *env) | ||
73 | { | ||
74 | -- | 27 | -- |
75 | 2.20.1 | 28 | 2.34.1 |
76 | 29 | ||
77 | 30 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The function does not write registers, and only reads them by | 3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
4 | implication via the exception path. | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | 5 | Message-id: 20230206223502.25122-9-philmd@linaro.org | |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20200302175829.2183-7-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 7 | --- |
12 | target/arm/helper-a64.h | 2 +- | 8 | target/arm/cpu.h | 2 +- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 10 | ||
15 | diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h | 11 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
16 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper-a64.h | 13 | --- a/target/arm/cpu.h |
18 | +++ b/target/arm/helper-a64.h | 14 | +++ b/target/arm/cpu.h |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr) | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
20 | DEF_HELPER_2(sqrt_f16, f16, f16, ptr) | 16 | } sau; |
21 | 17 | ||
22 | DEF_HELPER_2(exception_return, void, env, i64) | 18 | void *nvic; |
23 | -DEF_HELPER_2(dc_zva, void, env, i64) | 19 | - const struct arm_boot_info *boot_info; |
24 | +DEF_HELPER_FLAGS_2(dc_zva, TCG_CALL_NO_WG, void, env, i64) | 20 | #if !defined(CONFIG_USER_ONLY) |
25 | 21 | + const struct arm_boot_info *boot_info; | |
26 | DEF_HELPER_FLAGS_3(pacia, TCG_CALL_NO_WG, i64, env, i64, i64) | 22 | /* Store GICv3CPUState to access from this struct */ |
27 | DEF_HELPER_FLAGS_3(pacib, TCG_CALL_NO_WG, i64, env, i64, i64) | 23 | void *gicv3state; |
24 | #else /* CONFIG_USER_ONLY */ | ||
28 | -- | 25 | -- |
29 | 2.20.1 | 26 | 2.34.1 |
30 | 27 | ||
31 | 28 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | Message-id: 20200229012811.24129-3-richard.henderson@linaro.org | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Message-id: 20230206223502.25122-10-philmd@linaro.org |
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 7 | --- |
8 | target/arm/cpu.h | 7 +++++++ | 8 | target/arm/cpu.h | 2 +- |
9 | 1 file changed, 7 insertions(+) | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 10 | ||
11 | 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 |
12 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/cpu.h | 13 | --- a/target/arm/cpu.h |
14 | +++ b/target/arm/cpu.h | 14 | +++ b/target/arm/cpu.h |
15 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
16 | #define HCR_TERR (1ULL << 36) | 16 | uint32_t ctrl; |
17 | #define HCR_TEA (1ULL << 37) | 17 | } sau; |
18 | #define HCR_MIOCNCE (1ULL << 38) | 18 | |
19 | +/* RES0 bit 39 */ | 19 | - void *nvic; |
20 | #define HCR_APK (1ULL << 40) | 20 | #if !defined(CONFIG_USER_ONLY) |
21 | #define HCR_API (1ULL << 41) | 21 | + void *nvic; |
22 | #define HCR_NV (1ULL << 42) | 22 | const struct arm_boot_info *boot_info; |
23 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | 23 | /* Store GICv3CPUState to access from this struct */ |
24 | #define HCR_NV2 (1ULL << 45) | 24 | void *gicv3state; |
25 | #define HCR_FWB (1ULL << 46) | ||
26 | #define HCR_FIEN (1ULL << 47) | ||
27 | +/* RES0 bit 48 */ | ||
28 | #define HCR_TID4 (1ULL << 49) | ||
29 | #define HCR_TICAB (1ULL << 50) | ||
30 | +#define HCR_AMVOFFEN (1ULL << 51) | ||
31 | #define HCR_TOCU (1ULL << 52) | ||
32 | +#define HCR_ENSCXT (1ULL << 53) | ||
33 | #define HCR_TTLBIS (1ULL << 54) | ||
34 | #define HCR_TTLBOS (1ULL << 55) | ||
35 | #define HCR_ATA (1ULL << 56) | ||
36 | #define HCR_DCT (1ULL << 57) | ||
37 | +#define HCR_TID5 (1ULL << 58) | ||
38 | +#define HCR_TWEDEN (1ULL << 59) | ||
39 | +#define HCR_TWEDEL MAKE_64BIT_MASK(60, 4) | ||
40 | |||
41 | #define SCR_NS (1U << 0) | ||
42 | #define SCR_IRQ (1U << 1) | ||
43 | -- | 25 | -- |
44 | 2.20.1 | 26 | 2.34.1 |
45 | 27 | ||
46 | 28 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We have disabled EL2 and EL3 for user-only, which means that these | 3 | There is no point in using a void pointer to access the NVIC. |
4 | registers "don't exist" and should not be set. | 4 | Use the real type to avoid casting it while debugging. |
5 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Message-id: 20200229012811.24129-5-richard.henderson@linaro.org | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Message-id: 20230206223502.25122-11-philmd@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | target/arm/cpu.c | 6 ------ | 11 | target/arm/cpu.h | 46 ++++++++++++++++++++++--------------------- |
12 | 1 file changed, 6 deletions(-) | 12 | hw/intc/armv7m_nvic.c | 38 ++++++++++++----------------------- |
13 | 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); | ||
14 | 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 |
15 | index XXXXXXX..XXXXXXX 100644 | 308 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.c | 309 | --- a/target/arm/cpu.c |
17 | +++ b/target/arm/cpu.c | 310 | +++ b/target/arm/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | 311 | @@ -XXX,XX +XXX,XX @@ |
19 | /* Enable all PAC keys. */ | 312 | #if !defined(CONFIG_USER_ONLY) |
20 | env->cp15.sctlr_el[1] |= (SCTLR_EnIA | SCTLR_EnIB | | 313 | #include "hw/loader.h" |
21 | SCTLR_EnDA | SCTLR_EnDB); | 314 | #include "hw/boards.h" |
22 | - /* Enable all PAC instructions */ | 315 | +#include "hw/intc/armv7m_nvic.h" |
23 | - env->cp15.hcr_el2 |= HCR_API; | 316 | #endif |
24 | - env->cp15.scr_el3 |= SCR_API; | 317 | #include "sysemu/tcg.h" |
25 | /* and to the FP/Neon instructions */ | 318 | #include "sysemu/qtest.h" |
26 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3); | 319 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
27 | /* and to the SVE instructions */ | 320 | index XXXXXXX..XXXXXXX 100644 |
28 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 16, 2, 3); | 321 | --- a/target/arm/m_helper.c |
29 | - env->cp15.cptr_el[3] |= CPTR_EZ; | 322 | +++ b/target/arm/m_helper.c |
30 | /* with maximum vector length */ | 323 | @@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr, |
31 | env->vfp.zcr_el[1] = cpu_isar_feature(aa64_sve, cpu) ? | 324 | * that we will need later in order to do lazy FP reg stacking. |
32 | cpu->sve_max_vq - 1 : 0; | 325 | */ |
33 | - env->vfp.zcr_el[2] = env->vfp.zcr_el[1]; | 326 | bool is_secure = env->v7m.secure; |
34 | - env->vfp.zcr_el[3] = env->vfp.zcr_el[1]; | 327 | - void *nvic = env->nvic; |
35 | /* | 328 | + NVICState *nvic = env->nvic; |
36 | * Enable TBI0 and TBI1. While the real kernel only enables TBI0, | 329 | /* |
37 | * turning on both here will produce smaller code and otherwise | 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 | ||
38 | -- | 332 | -- |
39 | 2.20.1 | 333 | 2.34.1 |
40 | 334 | ||
41 | 335 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In arm_cpu_reset, we configure many system registers so that user-only | 3 | While dozens of files include "cpu.h", only 3 files require |
4 | behaves as it should with a minimum of ifdefs. However, we do not set | 4 | these NVIC helper declarations. |
5 | all of the system registers as required for a cpu with EL2 and EL3. | 5 | |
6 | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
7 | Disabling EL2 and EL3 mean that we will not look at those registers, | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | which means that we don't have to worry about configuring them. | 8 | Message-id: 20230206223502.25122-12-philmd@linaro.org |
9 | |||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20200229012811.24129-4-richard.henderson@linaro.org | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 10 | --- |
15 | target/arm/cpu.c | 6 ++++-- | 11 | include/hw/intc/armv7m_nvic.h | 123 ++++++++++++++++++++++++++++++++++ |
16 | 1 file changed, 4 insertions(+), 2 deletions(-) | 12 | target/arm/cpu.h | 123 ---------------------------------- |
17 | 13 | target/arm/cpu.c | 4 +- | |
14 | target/arm/cpu_tcg.c | 3 + | ||
15 | target/arm/m_helper.c | 3 + | ||
16 | 5 files changed, 132 insertions(+), 124 deletions(-) | ||
17 | |||
18 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/hw/intc/armv7m_nvic.h | ||
21 | +++ b/include/hw/intc/armv7m_nvic.h | ||
22 | @@ -XXX,XX +XXX,XX @@ struct NVICState { | ||
23 | qemu_irq sysresetreq; | ||
24 | }; | ||
25 | |||
26 | +/* Interface between CPU and Interrupt controller. */ | ||
27 | +/** | ||
28 | + * armv7m_nvic_set_pending: mark the specified exception as pending | ||
29 | + * @s: the NVIC | ||
30 | + * @irq: the exception number to mark pending | ||
31 | + * @secure: false for non-banked exceptions or for the nonsecure | ||
32 | + * version of a banked exception, true for the secure version of a banked | ||
33 | + * exception. | ||
34 | + * | ||
35 | + * Marks the specified exception as pending. Note that we will assert() | ||
36 | + * if @secure is true and @irq does not specify one of the fixed set | ||
37 | + * of architecturally banked exceptions. | ||
38 | + */ | ||
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(). | ||
18 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 284 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
19 | index XXXXXXX..XXXXXXX 100644 | 285 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/cpu.c | 286 | --- a/target/arm/cpu.c |
21 | +++ b/target/arm/cpu.c | 287 | +++ b/target/arm/cpu.c |
22 | @@ -XXX,XX +XXX,XX @@ static Property arm_cpu_reset_hivecs_property = | 288 | @@ -XXX,XX +XXX,XX @@ |
23 | static Property arm_cpu_rvbar_property = | 289 | #if !defined(CONFIG_USER_ONLY) |
24 | DEFINE_PROP_UINT64("rvbar", ARMCPU, rvbar, 0); | 290 | #include "hw/loader.h" |
25 | 291 | #include "hw/boards.h" | |
26 | +#ifndef CONFIG_USER_ONLY | 292 | +#ifdef CONFIG_TCG |
27 | static Property arm_cpu_has_el2_property = | 293 | #include "hw/intc/armv7m_nvic.h" |
28 | DEFINE_PROP_BOOL("has_el2", ARMCPU, has_el2, true); | 294 | -#endif |
29 | 295 | +#endif /* CONFIG_TCG */ | |
30 | static Property arm_cpu_has_el3_property = | 296 | +#endif /* !CONFIG_USER_ONLY */ |
31 | DEFINE_PROP_BOOL("has_el3", ARMCPU, has_el3, true); | 297 | #include "sysemu/tcg.h" |
298 | #include "sysemu/qtest.h" | ||
299 | #include "sysemu/hw_accel.h" | ||
300 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
301 | index XXXXXXX..XXXXXXX 100644 | ||
302 | --- a/target/arm/cpu_tcg.c | ||
303 | +++ b/target/arm/cpu_tcg.c | ||
304 | @@ -XXX,XX +XXX,XX @@ | ||
305 | #include "hw/boards.h" | ||
306 | #endif | ||
307 | #include "cpregs.h" | ||
308 | +#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) | ||
309 | +#include "hw/intc/armv7m_nvic.h" | ||
32 | +#endif | 310 | +#endif |
33 | 311 | ||
34 | static Property arm_cpu_cfgend_property = | 312 | |
35 | DEFINE_PROP_BOOL("cfgend", ARMCPU, cfgend, false); | 313 | /* Share AArch32 -cpu max features with AArch64. */ |
36 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj) | 314 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
37 | qdev_property_add_static(DEVICE(obj), &arm_cpu_rvbar_property); | 315 | index XXXXXXX..XXXXXXX 100644 |
38 | } | 316 | --- a/target/arm/m_helper.c |
39 | 317 | +++ b/target/arm/m_helper.c | |
40 | +#ifndef CONFIG_USER_ONLY | 318 | @@ -XXX,XX +XXX,XX @@ |
41 | if (arm_feature(&cpu->env, ARM_FEATURE_EL3)) { | 319 | #include "exec/cpu_ldst.h" |
42 | /* Add the has_el3 state CPU property only if EL3 is allowed. This will | 320 | #include "semihosting/common-semi.h" |
43 | * prevent "has_el3" from existing on CPUs which cannot support EL3. | 321 | #endif |
44 | */ | 322 | +#if !defined(CONFIG_USER_ONLY) |
45 | qdev_property_add_static(DEVICE(obj), &arm_cpu_has_el3_property); | 323 | +#include "hw/intc/armv7m_nvic.h" |
46 | |||
47 | -#ifndef CONFIG_USER_ONLY | ||
48 | object_property_add_link(obj, "secure-memory", | ||
49 | TYPE_MEMORY_REGION, | ||
50 | (Object **)&cpu->secure_memory, | ||
51 | qdev_prop_allow_set_link_before_realize, | ||
52 | OBJ_PROP_LINK_STRONG, | ||
53 | &error_abort); | ||
54 | -#endif | ||
55 | } | ||
56 | |||
57 | if (arm_feature(&cpu->env, ARM_FEATURE_EL2)) { | ||
58 | qdev_property_add_static(DEVICE(obj), &arm_cpu_has_el2_property); | ||
59 | } | ||
60 | +#endif | 324 | +#endif |
61 | 325 | ||
62 | if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { | 326 | static void v7m_msr_xpsr(CPUARMState *env, uint32_t mask, |
63 | cpu->has_pmu = true; | 327 | uint32_t reg, uint32_t val) |
64 | -- | 328 | -- |
65 | 2.20.1 | 329 | 2.34.1 |
66 | 330 | ||
67 | 331 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We missed this case within AArch64.ExceptionReturn. | 3 | The two TCG tests for GICv2 and GICv3 are very heavy weight distros |
4 | 4 | that take a long time to boot up, especially for an --enable-debug | |
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | build. The total code coverage they give is: |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | |
7 | Message-id: 20200302175829.2183-5-richard.henderson@linaro.org | 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> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 33 | --- |
10 | target/arm/helper-a64.c | 23 ++++++++++++++++++++++- | 34 | tests/avocado/boot_linux.py | 48 ++++---------------- |
11 | 1 file changed, 22 insertions(+), 1 deletion(-) | 35 | tests/avocado/machine_aarch64_virt.py | 63 ++++++++++++++++++++++++--- |
12 | 36 | 2 files changed, 65 insertions(+), 46 deletions(-) | |
13 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | 37 | |
38 | diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py | ||
14 | index XXXXXXX..XXXXXXX 100644 | 39 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper-a64.c | 40 | --- a/tests/avocado/boot_linux.py |
16 | +++ b/target/arm/helper-a64.c | 41 | +++ b/tests/avocado/boot_linux.py |
17 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) | 42 | @@ -XXX,XX +XXX,XX @@ def test_pc_q35_kvm(self): |
18 | "AArch32 EL%d PC 0x%" PRIx32 "\n", | 43 | self.launch_and_wait(set_up_ssh_connection=False) |
19 | cur_el, new_el, env->regs[15]); | 44 | |
20 | } else { | 45 | |
21 | + int tbii; | 46 | -# For Aarch64 we only boot KVM tests in CI as the TCG tests are very |
22 | + | 47 | -# heavyweight. There are lighter weight distros which we use in the |
23 | env->aarch64 = 1; | 48 | -# machine_aarch64_virt.py tests. |
24 | spsr &= aarch64_pstate_valid_mask(&env_archcpu(env)->isar); | 49 | +# For Aarch64 we only boot KVM tests in CI as booting the current |
25 | pstate_write(env, spsr); | 50 | +# Fedora OS in TCG tests is very heavyweight. There are lighter weight |
26 | @@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc) | 51 | +# distros which we use in the machine_aarch64_virt.py tests. |
27 | env->pstate &= ~PSTATE_SS; | 52 | class BootLinuxAarch64(LinuxTest): |
28 | } | 53 | """ |
29 | aarch64_restore_sp(env, new_el); | 54 | :avocado: tags=arch:aarch64 |
30 | - env->pc = new_pc; | 55 | :avocado: tags=machine:virt |
31 | helper_rebuild_hflags_a64(env, new_el); | 56 | - :avocado: tags=machine:gic-version=2 |
32 | + | 57 | """ |
33 | + /* | 58 | timeout = 720 |
34 | + * Apply TBI to the exception return address. We had to delay this | 59 | |
35 | + * until after we selected the new EL, so that we could select the | 60 | - def add_common_args(self): |
36 | + * correct TBI+TBID bits. This is made easier by waiting until after | 61 | - self.vm.add_args('-bios', |
37 | + * the hflags rebuild, since we can pull the composite TBII field | 62 | - os.path.join(BUILD_DIR, 'pc-bios', |
38 | + * from there. | 63 | - 'edk2-aarch64-code.fd')) |
39 | + */ | 64 | - self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0') |
40 | + tbii = FIELD_EX32(env->hflags, TBFLAG_A64, TBII); | 65 | - self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom') |
41 | + if ((tbii >> extract64(new_pc, 55, 1)) & 1) { | 66 | - |
42 | + /* TBI is enabled. */ | 67 | - @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') |
43 | + int core_mmu_idx = cpu_mmu_index(env, false); | 68 | - def test_fedora_cloud_tcg_gicv2(self): |
44 | + if (regime_has_2_ranges(core_to_aa64_mmu_idx(core_mmu_idx))) { | 69 | - """ |
45 | + new_pc = sextract64(new_pc, 0, 56); | 70 | - :avocado: tags=accel:tcg |
46 | + } else { | 71 | - :avocado: tags=cpu:max |
47 | + new_pc = extract64(new_pc, 0, 56); | 72 | - :avocado: tags=device:gicv2 |
48 | + } | 73 | - """ |
49 | + } | 74 | - self.require_accelerator("tcg") |
50 | + env->pc = new_pc; | 75 | - self.vm.add_args("-accel", "tcg") |
51 | + | 76 | - self.vm.add_args("-cpu", "max,lpa2=off") |
52 | qemu_log_mask(CPU_LOG_INT, "Exception return from AArch64 EL%d to " | 77 | - self.vm.add_args("-machine", "virt,gic-version=2") |
53 | "AArch64 EL%d PC 0x%" PRIx64 "\n", | 78 | - self.add_common_args() |
54 | cur_el, new_el, env->pc); | 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") | ||
55 | -- | 215 | -- |
56 | 2.20.1 | 216 | 2.34.1 |
57 | 217 | ||
58 | 218 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | 2 | ||
3 | This bit traps EL1 access to tlb maintenance insns. | 3 | GBPA register can be used to globally abort all |
4 | transactions. | ||
4 | 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> | ||
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
23 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
24 | Message-id: 20230214094009.2445653-1-smostafa@google.com | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 25 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20200229012811.24129-12-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 27 | --- |
10 | target/arm/helper.c | 85 +++++++++++++++++++++++++++++---------------- | 28 | hw/arm/smmuv3-internal.h | 7 +++++++ |
11 | 1 file changed, 55 insertions(+), 30 deletions(-) | 29 | include/hw/arm/smmuv3.h | 1 + |
30 | hw/arm/smmuv3.c | 43 +++++++++++++++++++++++++++++++++++++++- | ||
31 | 3 files changed, 50 insertions(+), 1 deletion(-) | ||
12 | 32 | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 33 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
14 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 35 | --- a/hw/arm/smmuv3-internal.h |
16 | +++ b/target/arm/helper.c | 36 | +++ b/hw/arm/smmuv3-internal.h |
17 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tacr(CPUARMState *env, const ARMCPRegInfo *ri, | 37 | @@ -XXX,XX +XXX,XX @@ REG32(CR0ACK, 0x24) |
18 | return CP_ACCESS_OK; | 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) | ||
51 | diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/include/hw/arm/smmuv3.h | ||
54 | +++ b/include/hw/arm/smmuv3.h | ||
55 | @@ -XXX,XX +XXX,XX @@ struct SMMUv3State { | ||
56 | uint32_t cr[3]; | ||
57 | uint32_t cr0ack; | ||
58 | uint32_t statusr; | ||
59 | + uint32_t gbpa; | ||
60 | uint32_t irq_ctrl; | ||
61 | uint32_t gerror; | ||
62 | uint32_t gerrorn; | ||
63 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/hw/arm/smmuv3.c | ||
66 | +++ b/hw/arm/smmuv3.c | ||
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; | ||
19 | } | 72 | } |
20 | 73 | ||
21 | +/* Check for traps from EL1 due to HCR_EL2.TTLB. */ | 74 | static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr, STE *buf, |
22 | +static CPAccessResult access_ttlb(CPUARMState *env, const ARMCPRegInfo *ri, | 75 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, |
23 | + bool isread) | 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; | ||
86 | } | ||
87 | |||
88 | @@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_writel(SMMUv3State *s, hwaddr offset, | ||
89 | case A_GERROR_IRQ_CFG2: | ||
90 | s->gerror_irq_cfg2 = data; | ||
91 | return MEMTX_OK; | ||
92 | + case A_GBPA: | ||
93 | + /* | ||
94 | + * If UPDATE is not set, the write is ignored. This is the only | ||
95 | + * permitted behavior in SMMUv3.2 and later. | ||
96 | + */ | ||
97 | + if (data & R_GBPA_UPDATE_MASK) { | ||
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) | ||
24 | +{ | 120 | +{ |
25 | + if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TTLB)) { | 121 | + SMMUv3State *s = opaque; |
26 | + return CP_ACCESS_TRAP_EL2; | 122 | + |
27 | + } | 123 | + /* Only migrate GBPA if it has different reset value. */ |
28 | + return CP_ACCESS_OK; | 124 | + return s->gbpa != SMMU_GBPA_RESET_VAL; |
29 | +} | 125 | +} |
30 | + | 126 | + |
31 | static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 127 | +static const VMStateDescription vmstate_gbpa = { |
32 | { | 128 | + .name = "smmuv3/gbpa", |
33 | ARMCPU *cpu = env_archcpu(env); | 129 | + .version_id = 1, |
34 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | 130 | + .minimum_version_id = 1, |
35 | .type = ARM_CP_NO_RAW, .access = PL1_R, .readfn = isr_read }, | 131 | + .needed = smmuv3_gbpa_needed, |
36 | /* 32 bit ITLB invalidates */ | 132 | + .fields = (VMStateField[]) { |
37 | { .name = "ITLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 0, | 133 | + VMSTATE_UINT32(gbpa, SMMUv3State), |
38 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiall_write }, | 134 | + VMSTATE_END_OF_LIST() |
39 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | 135 | + } |
40 | + .writefn = tlbiall_write }, | 136 | +}; |
41 | { .name = "ITLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 1, | 137 | + |
42 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_write }, | 138 | static const VMStateDescription vmstate_smmuv3 = { |
43 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | 139 | .name = "smmuv3", |
44 | + .writefn = tlbimva_write }, | 140 | .version_id = 1, |
45 | { .name = "ITLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 2, | 141 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3 = { |
46 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiasid_write }, | 142 | |
47 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | 143 | VMSTATE_END_OF_LIST(), |
48 | + .writefn = tlbiasid_write }, | 144 | }, |
49 | /* 32 bit DTLB invalidates */ | 145 | + .subsections = (const VMStateDescription * []) { |
50 | { .name = "DTLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 0, | 146 | + &vmstate_gbpa, |
51 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiall_write }, | 147 | + NULL |
52 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | 148 | + } |
53 | + .writefn = tlbiall_write }, | ||
54 | { .name = "DTLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 1, | ||
55 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_write }, | ||
56 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
57 | + .writefn = tlbimva_write }, | ||
58 | { .name = "DTLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 2, | ||
59 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiasid_write }, | ||
60 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
61 | + .writefn = tlbiasid_write }, | ||
62 | /* 32 bit TLB invalidates */ | ||
63 | { .name = "TLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0, | ||
64 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiall_write }, | ||
65 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
66 | + .writefn = tlbiall_write }, | ||
67 | { .name = "TLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 1, | ||
68 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_write }, | ||
69 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
70 | + .writefn = tlbimva_write }, | ||
71 | { .name = "TLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 2, | ||
72 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiasid_write }, | ||
73 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
74 | + .writefn = tlbiasid_write }, | ||
75 | { .name = "TLBIMVAA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, | ||
76 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimvaa_write }, | ||
77 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
78 | + .writefn = tlbimvaa_write }, | ||
79 | REGINFO_SENTINEL | ||
80 | }; | 149 | }; |
81 | 150 | ||
82 | static const ARMCPRegInfo v7mp_cp_reginfo[] = { | 151 | static void smmuv3_instance_init(Object *obj) |
83 | /* 32 bit TLB invalidates, Inner Shareable */ | ||
84 | { .name = "TLBIALLIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, | ||
85 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbiall_is_write }, | ||
86 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
87 | + .writefn = tlbiall_is_write }, | ||
88 | { .name = "TLBIMVAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1, | ||
89 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_is_write }, | ||
90 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
91 | + .writefn = tlbimva_is_write }, | ||
92 | { .name = "TLBIASIDIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2, | ||
93 | - .type = ARM_CP_NO_RAW, .access = PL1_W, | ||
94 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
95 | .writefn = tlbiasid_is_write }, | ||
96 | { .name = "TLBIMVAAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, | ||
97 | - .type = ARM_CP_NO_RAW, .access = PL1_W, | ||
98 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
99 | .writefn = tlbimvaa_is_write }, | ||
100 | REGINFO_SENTINEL | ||
101 | }; | ||
102 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
103 | /* TLBI operations */ | ||
104 | { .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64, | ||
105 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, | ||
106 | - .access = PL1_W, .type = ARM_CP_NO_RAW, | ||
107 | + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
108 | .writefn = tlbi_aa64_vmalle1is_write }, | ||
109 | { .name = "TLBI_VAE1IS", .state = ARM_CP_STATE_AA64, | ||
110 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1, | ||
111 | - .access = PL1_W, .type = ARM_CP_NO_RAW, | ||
112 | + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
113 | .writefn = tlbi_aa64_vae1is_write }, | ||
114 | { .name = "TLBI_ASIDE1IS", .state = ARM_CP_STATE_AA64, | ||
115 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2, | ||
116 | - .access = PL1_W, .type = ARM_CP_NO_RAW, | ||
117 | + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
118 | .writefn = tlbi_aa64_vmalle1is_write }, | ||
119 | { .name = "TLBI_VAAE1IS", .state = ARM_CP_STATE_AA64, | ||
120 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, | ||
121 | - .access = PL1_W, .type = ARM_CP_NO_RAW, | ||
122 | + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
123 | .writefn = tlbi_aa64_vae1is_write }, | ||
124 | { .name = "TLBI_VALE1IS", .state = ARM_CP_STATE_AA64, | ||
125 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5, | ||
126 | - .access = PL1_W, .type = ARM_CP_NO_RAW, | ||
127 | + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
128 | .writefn = tlbi_aa64_vae1is_write }, | ||
129 | { .name = "TLBI_VAALE1IS", .state = ARM_CP_STATE_AA64, | ||
130 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7, | ||
131 | - .access = PL1_W, .type = ARM_CP_NO_RAW, | ||
132 | + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
133 | .writefn = tlbi_aa64_vae1is_write }, | ||
134 | { .name = "TLBI_VMALLE1", .state = ARM_CP_STATE_AA64, | ||
135 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0, | ||
136 | - .access = PL1_W, .type = ARM_CP_NO_RAW, | ||
137 | + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
138 | .writefn = tlbi_aa64_vmalle1_write }, | ||
139 | { .name = "TLBI_VAE1", .state = ARM_CP_STATE_AA64, | ||
140 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 1, | ||
141 | - .access = PL1_W, .type = ARM_CP_NO_RAW, | ||
142 | + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
143 | .writefn = tlbi_aa64_vae1_write }, | ||
144 | { .name = "TLBI_ASIDE1", .state = ARM_CP_STATE_AA64, | ||
145 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 2, | ||
146 | - .access = PL1_W, .type = ARM_CP_NO_RAW, | ||
147 | + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
148 | .writefn = tlbi_aa64_vmalle1_write }, | ||
149 | { .name = "TLBI_VAAE1", .state = ARM_CP_STATE_AA64, | ||
150 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, | ||
151 | - .access = PL1_W, .type = ARM_CP_NO_RAW, | ||
152 | + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
153 | .writefn = tlbi_aa64_vae1_write }, | ||
154 | { .name = "TLBI_VALE1", .state = ARM_CP_STATE_AA64, | ||
155 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5, | ||
156 | - .access = PL1_W, .type = ARM_CP_NO_RAW, | ||
157 | + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
158 | .writefn = tlbi_aa64_vae1_write }, | ||
159 | { .name = "TLBI_VAALE1", .state = ARM_CP_STATE_AA64, | ||
160 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 7, | ||
161 | - .access = PL1_W, .type = ARM_CP_NO_RAW, | ||
162 | + .access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW, | ||
163 | .writefn = tlbi_aa64_vae1_write }, | ||
164 | { .name = "TLBI_IPAS2E1IS", .state = ARM_CP_STATE_AA64, | ||
165 | .opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 1, | ||
166 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
167 | #endif | ||
168 | /* TLB invalidate last level of translation table walk */ | ||
169 | { .name = "TLBIMVALIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5, | ||
170 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_is_write }, | ||
171 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
172 | + .writefn = tlbimva_is_write }, | ||
173 | { .name = "TLBIMVAALIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7, | ||
174 | - .type = ARM_CP_NO_RAW, .access = PL1_W, | ||
175 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
176 | .writefn = tlbimvaa_is_write }, | ||
177 | { .name = "TLBIMVAL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5, | ||
178 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimva_write }, | ||
179 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
180 | + .writefn = tlbimva_write }, | ||
181 | { .name = "TLBIMVAAL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 7, | ||
182 | - .type = ARM_CP_NO_RAW, .access = PL1_W, .writefn = tlbimvaa_write }, | ||
183 | + .type = ARM_CP_NO_RAW, .access = PL1_W, .accessfn = access_ttlb, | ||
184 | + .writefn = tlbimvaa_write }, | ||
185 | { .name = "TLBIMVALH", .cp = 15, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 5, | ||
186 | .type = ARM_CP_NO_RAW, .access = PL2_W, | ||
187 | .writefn = tlbimva_hyp_write }, | ||
188 | -- | 152 | -- |
189 | 2.20.1 | 153 | 2.34.1 |
190 | |||
191 | diff view generated by jsdifflib |
1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The Cubieboard machine does not support the -bios argument. | 3 | Since commit acc0b8b05a when running the ZynqMP ZCU102 board with |
4 | Report an error when -bios is used and exit immediately. | 4 | a QEMU configured using --without-default-devices, we get: |
5 | 5 | ||
6 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | 6 | $ qemu-system-aarch64 -M xlnx-zcu102 |
7 | Message-id: 20200227220149.6845-5-nieklinnenbank@gmail.com | 7 | qemu-system-aarch64: missing object type 'usb_dwc3' |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Abort trap: 6 |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 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> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 17 | --- |
12 | hw/arm/cubieboard.c | 7 +++++++ | 18 | hw/arm/Kconfig | 1 + |
13 | 1 file changed, 7 insertions(+) | 19 | 1 file changed, 1 insertion(+) |
14 | 20 | ||
15 | diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c | 21 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
16 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/cubieboard.c | 23 | --- a/hw/arm/Kconfig |
18 | +++ b/hw/arm/cubieboard.c | 24 | +++ b/hw/arm/Kconfig |
19 | @@ -XXX,XX +XXX,XX @@ | 25 | @@ -XXX,XX +XXX,XX @@ config XLNX_ZYNQMP_ARM |
20 | #include "exec/address-spaces.h" | 26 | select XLNX_CSU_DMA |
21 | #include "qapi/error.h" | 27 | select XLNX_ZYNQMP |
22 | #include "cpu.h" | 28 | select XLNX_ZDMA |
23 | +#include "sysemu/sysemu.h" | 29 | + select USB_DWC3 |
24 | #include "hw/sysbus.h" | 30 | |
25 | #include "hw/boards.h" | 31 | config XLNX_VERSAL |
26 | #include "hw/arm/allwinner-a10.h" | 32 | bool |
27 | @@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine) | ||
28 | AwA10State *a10; | ||
29 | Error *err = NULL; | ||
30 | |||
31 | + /* BIOS is not supported by this board */ | ||
32 | + if (bios_name) { | ||
33 | + error_report("BIOS not supported for this machine"); | ||
34 | + exit(1); | ||
35 | + } | ||
36 | + | ||
37 | /* This board has fixed size RAM (512MiB or 1GiB) */ | ||
38 | if (machine->ram_size != 512 * MiB && | ||
39 | machine->ram_size != 1 * GiB) { | ||
40 | -- | 33 | -- |
41 | 2.20.1 | 34 | 2.34.1 |
42 | 35 | ||
43 | 36 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Cornelia Huck <cohuck@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | As the Connex and Verdex machines only boot in little-endian, | 3 | Just use current_accel_name() directly. |
4 | we can simplify the code. | ||
5 | 4 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> |
7 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 9 | --- |
11 | hw/arm/gumstix.c | 16 ++-------------- | 10 | hw/arm/virt.c | 6 +++--- |
12 | 1 file changed, 2 insertions(+), 14 deletions(-) | 11 | 1 file changed, 3 insertions(+), 3 deletions(-) |
13 | 12 | ||
14 | diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c | 13 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/gumstix.c | 15 | --- a/hw/arm/virt.c |
17 | +++ b/hw/arm/gumstix.c | 16 | +++ b/hw/arm/virt.c |
18 | @@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine) | 17 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
19 | { | 18 | if (vms->secure && (kvm_enabled() || hvf_enabled())) { |
20 | PXA2xxState *cpu; | 19 | error_report("mach-virt: %s does not support providing " |
21 | DriveInfo *dinfo; | 20 | "Security extensions (TrustZone) to the guest CPU", |
22 | - int be; | 21 | - kvm_enabled() ? "KVM" : "HVF"); |
23 | MemoryRegion *address_space_mem = get_system_memory(); | 22 | + current_accel_name()); |
24 | |||
25 | uint32_t connex_rom = 0x01000000; | ||
26 | @@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine) | ||
27 | exit(1); | 23 | exit(1); |
28 | } | 24 | } |
29 | 25 | ||
30 | -#ifdef TARGET_WORDS_BIGENDIAN | 26 | if (vms->virt && (kvm_enabled() || hvf_enabled())) { |
31 | - be = 1; | 27 | error_report("mach-virt: %s does not support providing " |
32 | -#else | 28 | "Virtualization extensions to the guest CPU", |
33 | - be = 0; | 29 | - kvm_enabled() ? "KVM" : "HVF"); |
34 | -#endif | 30 | + current_accel_name()); |
35 | if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom, | ||
36 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
37 | - sector_len, 2, 0, 0, 0, 0, be)) { | ||
38 | + sector_len, 2, 0, 0, 0, 0, 0)) { | ||
39 | error_report("Error registering flash memory"); | ||
40 | exit(1); | 31 | exit(1); |
41 | } | 32 | } |
42 | @@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine) | 33 | |
43 | { | 34 | if (vms->mte && (kvm_enabled() || hvf_enabled())) { |
44 | PXA2xxState *cpu; | 35 | error_report("mach-virt: %s does not support providing " |
45 | DriveInfo *dinfo; | 36 | "MTE to the guest CPU", |
46 | - int be; | 37 | - kvm_enabled() ? "KVM" : "HVF"); |
47 | MemoryRegion *address_space_mem = get_system_memory(); | 38 | + current_accel_name()); |
48 | |||
49 | uint32_t verdex_rom = 0x02000000; | ||
50 | @@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine) | ||
51 | exit(1); | 39 | exit(1); |
52 | } | 40 | } |
53 | 41 | ||
54 | -#ifdef TARGET_WORDS_BIGENDIAN | ||
55 | - be = 1; | ||
56 | -#else | ||
57 | - be = 0; | ||
58 | -#endif | ||
59 | if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom, | ||
60 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
61 | - sector_len, 2, 0, 0, 0, 0, be)) { | ||
62 | + sector_len, 2, 0, 0, 0, 0, 0)) { | ||
63 | error_report("Error registering flash memory"); | ||
64 | exit(1); | ||
65 | } | ||
66 | -- | 42 | -- |
67 | 2.20.1 | 43 | 2.34.1 |
68 | |||
69 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Make the output just a bit prettier when running by hand. | 3 | Havard is no longer working on the Nuvoton systems for a while |
4 | and won't be able to do any work on it in the future. So I'll | ||
5 | take over maintaining the Nuvoton system from him. | ||
4 | 6 | ||
5 | Cc: Alex Bennée <alex.bennee@linaro.org> | 7 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Acked-by: Havard Skinnemoen <hskinnemoen@google.com> |
7 | Message-id: 20200229012811.24129-13-richard.henderson@linaro.org | 9 | Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Message-id: 20230208235433.3989937-2-wuhaotsh@google.com |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | tests/tcg/aarch64/pauth-1.c | 2 +- | 13 | MAINTAINERS | 2 +- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 15 | ||
14 | diff --git a/tests/tcg/aarch64/pauth-1.c b/tests/tcg/aarch64/pauth-1.c | 16 | diff --git a/MAINTAINERS b/MAINTAINERS |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/tests/tcg/aarch64/pauth-1.c | 18 | --- a/MAINTAINERS |
17 | +++ b/tests/tcg/aarch64/pauth-1.c | 19 | +++ b/MAINTAINERS |
18 | @@ -XXX,XX +XXX,XX @@ int main() | 20 | @@ -XXX,XX +XXX,XX @@ F: include/hw/net/mv88w8618_eth.h |
19 | } | 21 | F: docs/system/arm/musicpal.rst |
20 | 22 | ||
21 | perc = (float) count / (float) (TESTS * 2); | 23 | Nuvoton NPCM7xx |
22 | - printf("Ptr Check: %0.2f%%", perc * 100.0); | 24 | -M: Havard Skinnemoen <hskinnemoen@google.com> |
23 | + printf("Ptr Check: %0.2f%%\n", perc * 100.0); | 25 | M: Tyrone Ting <kfting@nuvoton.com> |
24 | assert(perc > 0.95); | 26 | +M: Hao Wu <wuhaotsh@google.com> |
25 | return 0; | 27 | L: qemu-arm@nongnu.org |
26 | } | 28 | S: Supported |
29 | F: hw/*/npcm7xx* | ||
27 | -- | 30 | -- |
28 | 2.20.1 | 31 | 2.34.1 |
29 | |||
30 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | This is an aarch64-only function. Move it out of the shared file. | 3 | Nuvoton's PSPI is a general purpose SPI module which enables |
4 | This patch is code movement only. | 4 | connections to SPI-based peripheral devices. |
5 | 5 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Chris Rauer <crauer@google.com> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org> |
9 | Message-id: 20200302175829.2183-6-richard.henderson@linaro.org | 9 | Message-id: 20230208235433.3989937-3-wuhaotsh@google.com |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 11 | --- |
12 | target/arm/helper-a64.h | 1 + | 12 | MAINTAINERS | 6 +- |
13 | target/arm/helper.h | 1 - | 13 | include/hw/ssi/npcm_pspi.h | 53 +++++++++ |
14 | target/arm/helper-a64.c | 91 ++++++++++++++++++++++++++++++++++++++++ | 14 | hw/ssi/npcm_pspi.c | 221 +++++++++++++++++++++++++++++++++++++ |
15 | target/arm/op_helper.c | 93 ----------------------------------------- | 15 | hw/ssi/meson.build | 2 +- |
16 | 4 files changed, 92 insertions(+), 94 deletions(-) | 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 | ||
17 | 20 | ||
18 | diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h | 21 | diff --git a/MAINTAINERS b/MAINTAINERS |
19 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/helper-a64.h | 23 | --- a/MAINTAINERS |
21 | +++ b/target/arm/helper-a64.h | 24 | +++ b/MAINTAINERS |
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(advsimd_f16touinth, i32, f16, ptr) | 25 | @@ -XXX,XX +XXX,XX @@ M: Tyrone Ting <kfting@nuvoton.com> |
23 | DEF_HELPER_2(sqrt_f16, f16, f16, ptr) | 26 | M: Hao Wu <wuhaotsh@google.com> |
24 | 27 | L: qemu-arm@nongnu.org | |
25 | DEF_HELPER_2(exception_return, void, env, i64) | 28 | S: Supported |
26 | +DEF_HELPER_2(dc_zva, void, env, i64) | 29 | -F: hw/*/npcm7xx* |
27 | 30 | -F: include/hw/*/npcm7xx* | |
28 | DEF_HELPER_FLAGS_3(pacia, TCG_CALL_NO_WG, i64, env, i64, i64) | 31 | -F: tests/qtest/npcm7xx* |
29 | DEF_HELPER_FLAGS_3(pacib, TCG_CALL_NO_WG, i64, env, i64, i64) | 32 | +F: hw/*/npcm* |
30 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 33 | +F: include/hw/*/npcm* |
31 | index XXXXXXX..XXXXXXX 100644 | 34 | +F: tests/qtest/npcm* |
32 | --- a/target/arm/helper.h | 35 | F: pc-bios/npcm7xx_bootrom.bin |
33 | +++ b/target/arm/helper.h | 36 | F: roms/vbootrom |
34 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) | 37 | F: docs/system/arm/nuvoton.rst |
35 | 38 | diff --git a/include/hw/ssi/npcm_pspi.h b/include/hw/ssi/npcm_pspi.h | |
36 | DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | 39 | new file mode 100644 |
37 | DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) | 40 | index XXXXXXX..XXXXXXX |
38 | -DEF_HELPER_2(dc_zva, void, env, i64) | 41 | --- /dev/null |
39 | 42 | +++ b/include/hw/ssi/npcm_pspi.h | |
40 | DEF_HELPER_FLAGS_5(gvec_qrdmlah_s16, TCG_CALL_NO_RWG, | ||
41 | void, ptr, ptr, ptr, ptr, i32) | ||
42 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/helper-a64.c | ||
45 | +++ b/target/arm/helper-a64.c | ||
46 | @@ -XXX,XX +XXX,XX @@ | 43 | @@ -XXX,XX +XXX,XX @@ |
47 | */ | 44 | +/* |
48 | 45 | + * Nuvoton Peripheral SPI Module | |
49 | #include "qemu/osdep.h" | 46 | + * |
47 | + * Copyright 2023 Google LLC | ||
48 | + * | ||
49 | + * This program is free software; you can redistribute it and/or modify it | ||
50 | + * under the terms of the GNU General Public License as published by the | ||
51 | + * Free Software Foundation; either version 2 of the License, or | ||
52 | + * (at your option) any later version. | ||
53 | + * | ||
54 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
55 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
56 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
57 | + * for more details. | ||
58 | + */ | ||
59 | +#ifndef NPCM_PSPI_H | ||
60 | +#define NPCM_PSPI_H | ||
61 | + | ||
62 | +#include "hw/ssi/ssi.h" | ||
63 | +#include "hw/sysbus.h" | ||
64 | + | ||
65 | +/* | ||
66 | + * Number of registers in our device state structure. Don't change this without | ||
67 | + * incrementing the version_id in the vmstate. | ||
68 | + */ | ||
69 | +#define NPCM_PSPI_NR_REGS 3 | ||
70 | + | ||
71 | +/** | ||
72 | + * NPCMPSPIState - Device state for one Flash Interface Unit. | ||
73 | + * @parent: System bus device. | ||
74 | + * @mmio: Memory region for register access. | ||
75 | + * @spi: The SPI bus mastered by this controller. | ||
76 | + * @regs: Register contents. | ||
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" | ||
50 | +#include "qemu/units.h" | 129 | +#include "qemu/units.h" |
51 | #include "cpu.h" | 130 | + |
52 | #include "exec/gdbstub.h" | 131 | +#include "trace.h" |
53 | #include "exec/helper-proto.h" | 132 | + |
54 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sqrt_f16)(uint32_t a, void *fpstp) | 133 | +REG16(PSPI_DATA, 0x0) |
55 | return float16_sqrt(a, s); | 134 | +REG16(PSPI_CTL1, 0x2) |
56 | } | 135 | + FIELD(PSPI_CTL1, SPIEN, 0, 1) |
57 | 136 | + FIELD(PSPI_CTL1, MOD, 2, 1) | |
58 | +void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | 137 | + FIELD(PSPI_CTL1, EIR, 5, 1) |
59 | +{ | 138 | + FIELD(PSPI_CTL1, EIW, 6, 1) |
60 | + /* | 139 | + FIELD(PSPI_CTL1, SCM, 7, 1) |
61 | + * Implement DC ZVA, which zeroes a fixed-length block of memory. | 140 | + FIELD(PSPI_CTL1, SCIDL, 8, 1) |
62 | + * Note that we do not implement the (architecturally mandated) | 141 | + FIELD(PSPI_CTL1, SCDV, 9, 7) |
63 | + * alignment fault for attempts to use this on Device memory | 142 | +REG16(PSPI_STAT, 0x4) |
64 | + * (which matches the usual QEMU behaviour of not implementing either | 143 | + FIELD(PSPI_STAT, BSY, 0, 1) |
65 | + * alignment faults or any memory attribute handling). | 144 | + FIELD(PSPI_STAT, RBF, 1, 1) |
66 | + */ | 145 | + |
67 | 146 | +static void npcm_pspi_update_irq(NPCMPSPIState *s) | |
68 | + ARMCPU *cpu = env_archcpu(env); | 147 | +{ |
69 | + uint64_t blocklen = 4 << cpu->dcz_blocksize; | 148 | + int level = 0; |
70 | + uint64_t vaddr = vaddr_in & ~(blocklen - 1); | 149 | + |
71 | + | 150 | + /* Only fire IRQ when the module is enabled. */ |
72 | +#ifndef CONFIG_USER_ONLY | 151 | + if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, SPIEN)) { |
73 | + { | 152 | + /* Update interrupt as BSY is cleared. */ |
74 | + /* | 153 | + if ((!FIELD_EX16(s->regs[R_PSPI_STAT], PSPI_STAT, BSY)) && |
75 | + * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than | 154 | + FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, EIW)) { |
76 | + * the block size so we might have to do more than one TLB lookup. | 155 | + level = 1; |
77 | + * We know that in fact for any v8 CPU the page size is at least 4K | ||
78 | + * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only | ||
79 | + * 1K as an artefact of legacy v5 subpage support being present in the | ||
80 | + * same QEMU executable. So in practice the hostaddr[] array has | ||
81 | + * two entries, given the current setting of TARGET_PAGE_BITS_MIN. | ||
82 | + */ | ||
83 | + int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE); | ||
84 | + void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)]; | ||
85 | + int try, i; | ||
86 | + unsigned mmu_idx = cpu_mmu_index(env, false); | ||
87 | + TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); | ||
88 | + | ||
89 | + assert(maxidx <= ARRAY_SIZE(hostaddr)); | ||
90 | + | ||
91 | + for (try = 0; try < 2; try++) { | ||
92 | + | ||
93 | + for (i = 0; i < maxidx; i++) { | ||
94 | + hostaddr[i] = tlb_vaddr_to_host(env, | ||
95 | + vaddr + TARGET_PAGE_SIZE * i, | ||
96 | + 1, mmu_idx); | ||
97 | + if (!hostaddr[i]) { | ||
98 | + break; | ||
99 | + } | ||
100 | + } | ||
101 | + if (i == maxidx) { | ||
102 | + /* | ||
103 | + * If it's all in the TLB it's fair game for just writing to; | ||
104 | + * we know we don't need to update dirty status, etc. | ||
105 | + */ | ||
106 | + for (i = 0; i < maxidx - 1; i++) { | ||
107 | + memset(hostaddr[i], 0, TARGET_PAGE_SIZE); | ||
108 | + } | ||
109 | + memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE)); | ||
110 | + return; | ||
111 | + } | ||
112 | + /* | ||
113 | + * OK, try a store and see if we can populate the tlb. This | ||
114 | + * might cause an exception if the memory isn't writable, | ||
115 | + * in which case we will longjmp out of here. We must for | ||
116 | + * this purpose use the actual register value passed to us | ||
117 | + * so that we get the fault address right. | ||
118 | + */ | ||
119 | + helper_ret_stb_mmu(env, vaddr_in, 0, oi, GETPC()); | ||
120 | + /* Now we can populate the other TLB entries, if any */ | ||
121 | + for (i = 0; i < maxidx; i++) { | ||
122 | + uint64_t va = vaddr + TARGET_PAGE_SIZE * i; | ||
123 | + if (va != (vaddr_in & TARGET_PAGE_MASK)) { | ||
124 | + helper_ret_stb_mmu(env, va, 0, oi, GETPC()); | ||
125 | + } | ||
126 | + } | ||
127 | + } | 156 | + } |
128 | + | 157 | + |
129 | + /* | 158 | + /* Update interrupt as RBF is set. */ |
130 | + * Slow path (probably attempt to do this to an I/O device or | 159 | + if (FIELD_EX16(s->regs[R_PSPI_STAT], PSPI_STAT, RBF) && |
131 | + * similar, or clearing of a block of code we have translations | 160 | + FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, EIR)) { |
132 | + * cached for). Just do a series of byte writes as the architecture | 161 | + level = 1; |
133 | + * demands. It's not worth trying to use a cpu_physical_memory_map(), | ||
134 | + * memset(), unmap() sequence here because: | ||
135 | + * + we'd need to account for the blocksize being larger than a page | ||
136 | + * + the direct-RAM access case is almost always going to be dealt | ||
137 | + * with in the fastpath code above, so there's no speed benefit | ||
138 | + * + we would have to deal with the map returning NULL because the | ||
139 | + * bounce buffer was in use | ||
140 | + */ | ||
141 | + for (i = 0; i < blocklen; i++) { | ||
142 | + helper_ret_stb_mmu(env, vaddr + i, 0, oi, GETPC()); | ||
143 | + } | 162 | + } |
144 | + } | 163 | + } |
145 | +#else | 164 | + qemu_set_irq(s->irq, level); |
146 | + memset(g2h(vaddr), 0, blocklen); | 165 | +} |
147 | +#endif | 166 | + |
148 | +} | 167 | +static uint16_t npcm_pspi_read_data(NPCMPSPIState *s) |
149 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | 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 | ||
150 | index XXXXXXX..XXXXXXX 100644 | 325 | index XXXXXXX..XXXXXXX 100644 |
151 | --- a/target/arm/op_helper.c | 326 | --- a/hw/ssi/meson.build |
152 | +++ b/target/arm/op_helper.c | 327 | +++ b/hw/ssi/meson.build |
153 | @@ -XXX,XX +XXX,XX @@ | 328 | @@ -XXX,XX +XXX,XX @@ |
154 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. | 329 | softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_smc.c')) |
155 | */ | 330 | softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-spi.c')) |
156 | #include "qemu/osdep.h" | 331 | -softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c')) |
157 | -#include "qemu/units.h" | 332 | +softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c', 'npcm_pspi.c')) |
158 | #include "qemu/log.h" | 333 | softmmu_ss.add(when: 'CONFIG_PL022', if_true: files('pl022.c')) |
159 | #include "qemu/main-loop.h" | 334 | softmmu_ss.add(when: 'CONFIG_SIFIVE_SPI', if_true: files('sifive_spi.c')) |
160 | #include "cpu.h" | 335 | softmmu_ss.add(when: 'CONFIG_SSI', if_true: files('ssi.c')) |
161 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(ror_cc)(CPUARMState *env, uint32_t x, uint32_t i) | 336 | diff --git a/hw/ssi/trace-events b/hw/ssi/trace-events |
162 | return ((uint32_t)x >> shift) | (x << (32 - shift)); | 337 | index XXXXXXX..XXXXXXX 100644 |
163 | } | 338 | --- a/hw/ssi/trace-events |
164 | } | 339 | +++ b/hw/ssi/trace-events |
165 | - | 340 | @@ -XXX,XX +XXX,XX @@ npcm7xx_fiu_ctrl_write(const char *id, uint64_t addr, uint32_t data) "%s offset: |
166 | -void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in) | 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 |
167 | -{ | 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 |
168 | - /* | 343 | |
169 | - * Implement DC ZVA, which zeroes a fixed-length block of memory. | 344 | +# npcm_pspi.c |
170 | - * Note that we do not implement the (architecturally mandated) | 345 | +npcm_pspi_enter_reset(const char *id, int reset_type) "%s reset type: %d" |
171 | - * alignment fault for attempts to use this on Device memory | 346 | +npcm_pspi_ctrl_read(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16 |
172 | - * (which matches the usual QEMU behaviour of not implementing either | 347 | +npcm_pspi_ctrl_write(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16 |
173 | - * alignment faults or any memory attribute handling). | 348 | + |
174 | - */ | 349 | # ibex_spi_host.c |
175 | - | 350 | |
176 | - ARMCPU *cpu = env_archcpu(env); | 351 | ibex_spi_host_reset(const char *msg) "%s" |
177 | - uint64_t blocklen = 4 << cpu->dcz_blocksize; | ||
178 | - uint64_t vaddr = vaddr_in & ~(blocklen - 1); | ||
179 | - | ||
180 | -#ifndef CONFIG_USER_ONLY | ||
181 | - { | ||
182 | - /* | ||
183 | - * Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than | ||
184 | - * the block size so we might have to do more than one TLB lookup. | ||
185 | - * We know that in fact for any v8 CPU the page size is at least 4K | ||
186 | - * and the block size must be 2K or less, but TARGET_PAGE_SIZE is only | ||
187 | - * 1K as an artefact of legacy v5 subpage support being present in the | ||
188 | - * same QEMU executable. So in practice the hostaddr[] array has | ||
189 | - * two entries, given the current setting of TARGET_PAGE_BITS_MIN. | ||
190 | - */ | ||
191 | - int maxidx = DIV_ROUND_UP(blocklen, TARGET_PAGE_SIZE); | ||
192 | - void *hostaddr[DIV_ROUND_UP(2 * KiB, 1 << TARGET_PAGE_BITS_MIN)]; | ||
193 | - int try, i; | ||
194 | - unsigned mmu_idx = cpu_mmu_index(env, false); | ||
195 | - TCGMemOpIdx oi = make_memop_idx(MO_UB, mmu_idx); | ||
196 | - | ||
197 | - assert(maxidx <= ARRAY_SIZE(hostaddr)); | ||
198 | - | ||
199 | - for (try = 0; try < 2; try++) { | ||
200 | - | ||
201 | - for (i = 0; i < maxidx; i++) { | ||
202 | - hostaddr[i] = tlb_vaddr_to_host(env, | ||
203 | - vaddr + TARGET_PAGE_SIZE * i, | ||
204 | - 1, mmu_idx); | ||
205 | - if (!hostaddr[i]) { | ||
206 | - break; | ||
207 | - } | ||
208 | - } | ||
209 | - if (i == maxidx) { | ||
210 | - /* | ||
211 | - * If it's all in the TLB it's fair game for just writing to; | ||
212 | - * we know we don't need to update dirty status, etc. | ||
213 | - */ | ||
214 | - for (i = 0; i < maxidx - 1; i++) { | ||
215 | - memset(hostaddr[i], 0, TARGET_PAGE_SIZE); | ||
216 | - } | ||
217 | - memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE)); | ||
218 | - return; | ||
219 | - } | ||
220 | - /* | ||
221 | - * OK, try a store and see if we can populate the tlb. This | ||
222 | - * might cause an exception if the memory isn't writable, | ||
223 | - * in which case we will longjmp out of here. We must for | ||
224 | - * this purpose use the actual register value passed to us | ||
225 | - * so that we get the fault address right. | ||
226 | - */ | ||
227 | - helper_ret_stb_mmu(env, vaddr_in, 0, oi, GETPC()); | ||
228 | - /* Now we can populate the other TLB entries, if any */ | ||
229 | - for (i = 0; i < maxidx; i++) { | ||
230 | - uint64_t va = vaddr + TARGET_PAGE_SIZE * i; | ||
231 | - if (va != (vaddr_in & TARGET_PAGE_MASK)) { | ||
232 | - helper_ret_stb_mmu(env, va, 0, oi, GETPC()); | ||
233 | - } | ||
234 | - } | ||
235 | - } | ||
236 | - | ||
237 | - /* | ||
238 | - * Slow path (probably attempt to do this to an I/O device or | ||
239 | - * similar, or clearing of a block of code we have translations | ||
240 | - * cached for). Just do a series of byte writes as the architecture | ||
241 | - * demands. It's not worth trying to use a cpu_physical_memory_map(), | ||
242 | - * memset(), unmap() sequence here because: | ||
243 | - * + we'd need to account for the blocksize being larger than a page | ||
244 | - * + the direct-RAM access case is almost always going to be dealt | ||
245 | - * with in the fastpath code above, so there's no speed benefit | ||
246 | - * + we would have to deal with the map returning NULL because the | ||
247 | - * bounce buffer was in use | ||
248 | - */ | ||
249 | - for (i = 0; i < blocklen; i++) { | ||
250 | - helper_ret_stb_mmu(env, vaddr + i, 0, oi, GETPC()); | ||
251 | - } | ||
252 | - } | ||
253 | -#else | ||
254 | - memset(g2h(vaddr), 0, blocklen); | ||
255 | -#endif | ||
256 | -} | ||
257 | -- | 352 | -- |
258 | 2.20.1 | 353 | 2.34.1 |
259 | |||
260 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | This bit traps EL1 access to cache maintenance insns that operate | 3 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
4 | to the point of unification. There are no longer any references to | 4 | Reviewed-by: Titus Rwantare <titusr@google.com> |
5 | plain aa64_cacheop_access, so remove it. | 5 | Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org> |
6 | 6 | Message-id: 20230208235433.3989937-4-wuhaotsh@google.com | |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200229012811.24129-11-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 8 | --- |
12 | target/arm/helper.c | 53 +++++++++++++++++++++++++++------------------ | 9 | docs/system/arm/nuvoton.rst | 2 +- |
13 | 1 file changed, 32 insertions(+), 21 deletions(-) | 10 | include/hw/arm/npcm7xx.h | 2 ++ |
11 | hw/arm/npcm7xx.c | 25 +++++++++++++++++++++++-- | ||
12 | 3 files changed, 26 insertions(+), 3 deletions(-) | ||
14 | 13 | ||
15 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 14 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper.c | 16 | --- a/docs/system/arm/nuvoton.rst |
18 | +++ b/target/arm/helper.c | 17 | +++ b/docs/system/arm/nuvoton.rst |
19 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo uao_reginfo = { | 18 | @@ -XXX,XX +XXX,XX @@ Supported devices |
20 | .readfn = aa64_uao_read, .writefn = aa64_uao_write | 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]; | ||
21 | }; | 51 | }; |
22 | 52 | ||
23 | -static CPAccessResult aa64_cacheop_access(CPUARMState *env, | 53 | #define TYPE_NPCM7XX "npcm7xx" |
24 | - const ARMCPRegInfo *ri, | 54 | diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c |
25 | - bool isread) | 55 | index XXXXXXX..XXXXXXX 100644 |
26 | -{ | 56 | --- a/hw/arm/npcm7xx.c |
27 | - /* Cache invalidate/clean: NOP, but EL0 must UNDEF unless | 57 | +++ b/hw/arm/npcm7xx.c |
28 | - * SCTLR_EL1.UCI is set. | 58 | @@ -XXX,XX +XXX,XX @@ enum NPCM7xxInterrupt { |
29 | - */ | 59 | NPCM7XX_EMC1RX_IRQ = 15, |
30 | - if (arm_current_el(env) == 0 && !(arm_sctlr(env, 0) & SCTLR_UCI)) { | 60 | NPCM7XX_EMC1TX_IRQ, |
31 | - return CP_ACCESS_TRAP; | 61 | NPCM7XX_MMC_IRQ = 26, |
32 | - } | 62 | + NPCM7XX_PSPI2_IRQ = 28, |
33 | - return CP_ACCESS_OK; | 63 | + NPCM7XX_PSPI1_IRQ = 31, |
34 | -} | 64 | NPCM7XX_TIMER0_IRQ = 32, /* Timer Module 0 */ |
35 | - | 65 | NPCM7XX_TIMER1_IRQ, |
36 | static CPAccessResult aa64_cacheop_poc_access(CPUARMState *env, | 66 | NPCM7XX_TIMER2_IRQ, |
37 | const ARMCPRegInfo *ri, | 67 | @@ -XXX,XX +XXX,XX @@ static const hwaddr npcm7xx_emc_addr[] = { |
38 | bool isread) | 68 | 0xf0826000, |
39 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult aa64_cacheop_poc_access(CPUARMState *env, | 69 | }; |
40 | return CP_ACCESS_OK; | 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); | ||
41 | } | 89 | } |
42 | 90 | ||
43 | +static CPAccessResult aa64_cacheop_pou_access(CPUARMState *env, | 91 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) |
44 | + const ARMCPRegInfo *ri, | 92 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc), 0, |
45 | + bool isread) | 93 | npcm7xx_irq(s, NPCM7XX_MMC_IRQ)); |
46 | +{ | 94 | |
47 | + /* Cache invalidate/clean to Point of Unification... */ | 95 | + /* PSPI */ |
48 | + switch (arm_current_el(env)) { | 96 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_pspi_addr) != ARRAY_SIZE(s->pspi)); |
49 | + case 0: | 97 | + for (i = 0; i < ARRAY_SIZE(s->pspi); i++) { |
50 | + /* ... EL0 must UNDEF unless SCTLR_EL1.UCI is set. */ | 98 | + SysBusDevice *sbd = SYS_BUS_DEVICE(&s->pspi[i]); |
51 | + if (!(arm_sctlr(env, 0) & SCTLR_UCI)) { | 99 | + int irq = (i == 0) ? NPCM7XX_PSPI1_IRQ : NPCM7XX_PSPI2_IRQ; |
52 | + return CP_ACCESS_TRAP; | 100 | + |
53 | + } | 101 | + sysbus_realize(sbd, &error_abort); |
54 | + /* fall through */ | 102 | + sysbus_mmio_map(sbd, 0, npcm7xx_pspi_addr[i]); |
55 | + case 1: | 103 | + sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, irq)); |
56 | + /* ... EL1 must trap to EL2 if HCR_EL2.TPU is set. */ | ||
57 | + if (arm_hcr_el2_eff(env) & HCR_TPU) { | ||
58 | + return CP_ACCESS_TRAP_EL2; | ||
59 | + } | ||
60 | + break; | ||
61 | + } | 104 | + } |
62 | + return CP_ACCESS_OK; | ||
63 | +} | ||
64 | + | 105 | + |
65 | /* See: D4.7.2 TLB maintenance requirements and the TLB maintenance instructions | 106 | create_unimplemented_device("npcm7xx.shm", 0xc0001000, 4 * KiB); |
66 | * Page D4-1736 (DDI0487A.b) | 107 | create_unimplemented_device("npcm7xx.vdmx", 0xe0800000, 4 * KiB); |
67 | */ | 108 | create_unimplemented_device("npcm7xx.pcierc", 0xe1000000, 64 * KiB); |
68 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | 109 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) |
69 | /* Cache ops: all NOPs since we don't emulate caches */ | 110 | create_unimplemented_device("npcm7xx.peci", 0xf0100000, 4 * KiB); |
70 | { .name = "IC_IALLUIS", .state = ARM_CP_STATE_AA64, | 111 | create_unimplemented_device("npcm7xx.siox[1]", 0xf0101000, 4 * KiB); |
71 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0, | 112 | create_unimplemented_device("npcm7xx.siox[2]", 0xf0102000, 4 * KiB); |
72 | - .access = PL1_W, .type = ARM_CP_NOP }, | 113 | - create_unimplemented_device("npcm7xx.pspi1", 0xf0200000, 4 * KiB); |
73 | + .access = PL1_W, .type = ARM_CP_NOP, | 114 | - create_unimplemented_device("npcm7xx.pspi2", 0xf0201000, 4 * KiB); |
74 | + .accessfn = aa64_cacheop_pou_access }, | 115 | create_unimplemented_device("npcm7xx.ahbpci", 0xf0400000, 1 * MiB); |
75 | { .name = "IC_IALLU", .state = ARM_CP_STATE_AA64, | 116 | create_unimplemented_device("npcm7xx.mcphy", 0xf05f0000, 64 * KiB); |
76 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 0, | 117 | create_unimplemented_device("npcm7xx.gmac1", 0xf0802000, 8 * KiB); |
77 | - .access = PL1_W, .type = ARM_CP_NOP }, | ||
78 | + .access = PL1_W, .type = ARM_CP_NOP, | ||
79 | + .accessfn = aa64_cacheop_pou_access }, | ||
80 | { .name = "IC_IVAU", .state = ARM_CP_STATE_AA64, | ||
81 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 5, .opc2 = 1, | ||
82 | .access = PL0_W, .type = ARM_CP_NOP, | ||
83 | - .accessfn = aa64_cacheop_access }, | ||
84 | + .accessfn = aa64_cacheop_pou_access }, | ||
85 | { .name = "DC_IVAC", .state = ARM_CP_STATE_AA64, | ||
86 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, | ||
87 | .access = PL1_W, .accessfn = aa64_cacheop_poc_access, | ||
88 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
89 | { .name = "DC_CVAU", .state = ARM_CP_STATE_AA64, | ||
90 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 11, .opc2 = 1, | ||
91 | .access = PL0_W, .type = ARM_CP_NOP, | ||
92 | - .accessfn = aa64_cacheop_access }, | ||
93 | + .accessfn = aa64_cacheop_pou_access }, | ||
94 | { .name = "DC_CIVAC", .state = ARM_CP_STATE_AA64, | ||
95 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 1, | ||
96 | .access = PL0_W, .type = ARM_CP_NOP, | ||
97 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
98 | .writefn = tlbiipas2_is_write }, | ||
99 | /* 32 bit cache operations */ | ||
100 | { .name = "ICIALLUIS", .cp = 15, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0, | ||
101 | - .type = ARM_CP_NOP, .access = PL1_W }, | ||
102 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, | ||
103 | { .name = "BPIALLUIS", .cp = 15, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 6, | ||
104 | .type = ARM_CP_NOP, .access = PL1_W }, | ||
105 | { .name = "ICIALLU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 0, | ||
106 | - .type = ARM_CP_NOP, .access = PL1_W }, | ||
107 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, | ||
108 | { .name = "ICIMVAU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 1, | ||
109 | - .type = ARM_CP_NOP, .access = PL1_W }, | ||
110 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, | ||
111 | { .name = "BPIALL", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 6, | ||
112 | .type = ARM_CP_NOP, .access = PL1_W }, | ||
113 | { .name = "BPIMVA", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 7, | ||
114 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
115 | { .name = "DCCSW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, | ||
116 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
117 | { .name = "DCCMVAU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 11, .opc2 = 1, | ||
118 | - .type = ARM_CP_NOP, .access = PL1_W }, | ||
119 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access }, | ||
120 | { .name = "DCCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 1, | ||
121 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_poc_access }, | ||
122 | { .name = "DCCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, | ||
123 | -- | 118 | -- |
124 | 2.20.1 | 119 | 2.34.1 |
125 | |||
126 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Make sure a null SMMUPciBus is returned in case we were | 3 | Addresses targeting the second translation table (TTB1) in the SMMU have |
4 | not able to identify a pci bus matching the @bus_num. | 4 | all upper bits set. Ensure the IOMMU region covers all 64 bits. |
5 | 5 | ||
6 | This matches the fix done on intel iommu in commit: | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | a2e1cd41ccfe796529abfd1b6aeb1dd4393762a2 | 7 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
8 | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | |
9 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 9 | Message-id: 20230214171921.1917916-2-jean-philippe@linaro.org |
10 | Reviewed-by: Peter Xu <peterx@redhat.com> | ||
11 | Message-Id: <20200226172628.17449-1-eric.auger@redhat.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
13 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 11 | --- |
16 | hw/arm/smmu-common.c | 1 + | 12 | include/hw/arm/smmu-common.h | 2 -- |
17 | 1 file changed, 1 insertion(+) | 13 | hw/arm/smmu-common.c | 2 +- |
14 | 2 files changed, 1 insertion(+), 3 deletions(-) | ||
18 | 15 | ||
16 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/hw/arm/smmu-common.h | ||
19 | +++ b/include/hw/arm/smmu-common.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #define SMMU_PCI_DEVFN_MAX 256 | ||
22 | #define SMMU_PCI_DEVFN(sid) (sid & 0xFF) | ||
23 | |||
24 | -#define SMMU_MAX_VA_BITS 48 | ||
25 | - | ||
26 | /* | ||
27 | * Page table walk error types | ||
28 | */ | ||
19 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | 29 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c |
20 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/smmu-common.c | 31 | --- a/hw/arm/smmu-common.c |
22 | +++ b/hw/arm/smmu-common.c | 32 | +++ b/hw/arm/smmu-common.c |
23 | @@ -XXX,XX +XXX,XX @@ SMMUPciBus *smmu_find_smmu_pcibus(SMMUState *s, uint8_t bus_num) | 33 | @@ -XXX,XX +XXX,XX @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) |
24 | return smmu_pci_bus; | 34 | |
25 | } | 35 | memory_region_init_iommu(&sdev->iommu, sizeof(sdev->iommu), |
26 | } | 36 | s->mrtypename, |
27 | + smmu_pci_bus = NULL; | 37 | - OBJECT(s), name, 1ULL << SMMU_MAX_VA_BITS); |
28 | } | 38 | + OBJECT(s), name, UINT64_MAX); |
29 | return smmu_pci_bus; | 39 | address_space_init(&sdev->as, |
30 | } | 40 | MEMORY_REGION(&sdev->iommu), name); |
41 | trace_smmu_add_mr(name); | ||
31 | -- | 42 | -- |
32 | 2.20.1 | 43 | 2.34.1 |
33 | |||
34 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The smmu_find_smmu_pcibus() function was introduced (in commit | 3 | Addresses targeting the second translation table (TTB1) in the SMMU have |
4 | cac994ef43b) in a code format that could return an incorrect | 4 | all upper bits set (except for the top byte when TBI is enabled). Fix |
5 | pointer, which was then fixed by the previous commit. | 5 | the TTB1 check. |
6 | We could have avoided this by writing the if() statement | ||
7 | differently. Do it now, in case this function is re-used. | ||
8 | The code is easier to review (harder to miss bugs). | ||
9 | 6 | ||
10 | Acked-by: Eric Auger <eric.auger@redhat.com> | 7 | Reported-by: Ola Hugosson <ola.hugosson@arm.com> |
11 | Reviewed-by: Peter Xu <peterx@redhat.com> | 8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
12 | Signed-off-by: Philippe Mathieu-Daudé <philmd@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 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 13 | --- |
15 | hw/arm/smmu-common.c | 25 +++++++++++++------------ | 14 | hw/arm/smmu-common.c | 2 +- |
16 | 1 file changed, 13 insertions(+), 12 deletions(-) | 15 | 1 file changed, 1 insertion(+), 1 deletion(-) |
17 | 16 | ||
18 | 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 |
19 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/arm/smmu-common.c | 19 | --- a/hw/arm/smmu-common.c |
21 | +++ b/hw/arm/smmu-common.c | 20 | +++ b/hw/arm/smmu-common.c |
22 | @@ -XXX,XX +XXX,XX @@ inline int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, | 21 | @@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova) |
23 | SMMUPciBus *smmu_find_smmu_pcibus(SMMUState *s, uint8_t bus_num) | 22 | /* there is a ttbr0 region and we are in it (high bits all zero) */ |
24 | { | 23 | return &cfg->tt[0]; |
25 | SMMUPciBus *smmu_pci_bus = s->smmu_pcibus_by_bus_num[bus_num]; | 24 | } else if (cfg->tt[1].tsz && |
26 | + GHashTableIter iter; | 25 | - !extract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte)) { |
27 | 26 | + sextract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte) == -1) { | |
28 | - if (!smmu_pci_bus) { | 27 | /* there is a ttbr1 region and we are in it (high bits all one) */ |
29 | - GHashTableIter iter; | 28 | return &cfg->tt[1]; |
30 | - | 29 | } else if (!cfg->tt[0].tsz) { |
31 | - g_hash_table_iter_init(&iter, s->smmu_pcibus_by_busptr); | ||
32 | - while (g_hash_table_iter_next(&iter, NULL, (void **)&smmu_pci_bus)) { | ||
33 | - if (pci_bus_num(smmu_pci_bus->bus) == bus_num) { | ||
34 | - s->smmu_pcibus_by_bus_num[bus_num] = smmu_pci_bus; | ||
35 | - return smmu_pci_bus; | ||
36 | - } | ||
37 | - } | ||
38 | - smmu_pci_bus = NULL; | ||
39 | + if (smmu_pci_bus) { | ||
40 | + return smmu_pci_bus; | ||
41 | } | ||
42 | - return smmu_pci_bus; | ||
43 | + | ||
44 | + g_hash_table_iter_init(&iter, s->smmu_pcibus_by_busptr); | ||
45 | + while (g_hash_table_iter_next(&iter, NULL, (void **)&smmu_pci_bus)) { | ||
46 | + if (pci_bus_num(smmu_pci_bus->bus) == bus_num) { | ||
47 | + s->smmu_pcibus_by_bus_num[bus_num] = smmu_pci_bus; | ||
48 | + return smmu_pci_bus; | ||
49 | + } | ||
50 | + } | ||
51 | + | ||
52 | + return NULL; | ||
53 | } | ||
54 | |||
55 | static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) | ||
56 | -- | 30 | -- |
57 | 2.20.1 | 31 | 2.34.1 |
58 | |||
59 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | We only build the little-endian softmmu configurations. Checking | ||
4 | for big endian is pointless, remove the unused code. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/arm/mainstone.c | 8 +------- | ||
11 | 1 file changed, 1 insertion(+), 7 deletions(-) | ||
12 | |||
13 | diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/arm/mainstone.c | ||
16 | +++ b/hw/arm/mainstone.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MemoryRegion *address_space_mem, | ||
18 | DeviceState *mst_irq; | ||
19 | DriveInfo *dinfo; | ||
20 | int i; | ||
21 | - int be; | ||
22 | MemoryRegion *rom = g_new(MemoryRegion, 1); | ||
23 | |||
24 | /* Setup CPU & memory */ | ||
25 | @@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MemoryRegion *address_space_mem, | ||
26 | memory_region_set_readonly(rom, true); | ||
27 | memory_region_add_subregion(address_space_mem, 0, rom); | ||
28 | |||
29 | -#ifdef TARGET_WORDS_BIGENDIAN | ||
30 | - be = 1; | ||
31 | -#else | ||
32 | - be = 0; | ||
33 | -#endif | ||
34 | /* There are two 32MiB flash devices on the board */ | ||
35 | for (i = 0; i < 2; i ++) { | ||
36 | dinfo = drive_get(IF_PFLASH, 0, i); | ||
37 | @@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MemoryRegion *address_space_mem, | ||
38 | i ? "mainstone.flash1" : "mainstone.flash0", | ||
39 | MAINSTONE_FLASH, | ||
40 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
41 | - sector_len, 4, 0, 0, 0, 0, be)) { | ||
42 | + sector_len, 4, 0, 0, 0, 0, 0)) { | ||
43 | error_report("Error registering flash memory"); | ||
44 | exit(1); | ||
45 | } | ||
46 | -- | ||
47 | 2.20.1 | ||
48 | |||
49 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
2 | 1 | ||
3 | We only build the little-endian softmmu configurations. Checking | ||
4 | for big endian is pointless, remove the unused code. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/arm/z2.c | 8 +------- | ||
11 | 1 file changed, 1 insertion(+), 7 deletions(-) | ||
12 | |||
13 | diff --git a/hw/arm/z2.c b/hw/arm/z2.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/arm/z2.c | ||
16 | +++ b/hw/arm/z2.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine) | ||
18 | uint32_t sector_len = 0x10000; | ||
19 | PXA2xxState *mpu; | ||
20 | DriveInfo *dinfo; | ||
21 | - int be; | ||
22 | void *z2_lcd; | ||
23 | I2CBus *bus; | ||
24 | DeviceState *wm; | ||
25 | @@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine) | ||
26 | /* Setup CPU & memory */ | ||
27 | mpu = pxa270_init(address_space_mem, z2_binfo.ram_size, machine->cpu_type); | ||
28 | |||
29 | -#ifdef TARGET_WORDS_BIGENDIAN | ||
30 | - be = 1; | ||
31 | -#else | ||
32 | - be = 0; | ||
33 | -#endif | ||
34 | dinfo = drive_get(IF_PFLASH, 0, 0); | ||
35 | if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE, | ||
36 | dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, | ||
37 | - sector_len, 4, 0, 0, 0, 0, be)) { | ||
38 | + sector_len, 4, 0, 0, 0, 0, 0)) { | ||
39 | error_report("Error registering flash memory"); | ||
40 | exit(1); | ||
41 | } | ||
42 | -- | ||
43 | 2.20.1 | ||
44 | |||
45 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | This bit traps EL1 access to cache maintenance insns that operate | 3 | make it clearer from the name that this is a tcg-only function. |
4 | to the point of coherency or persistence. | ||
5 | 4 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Claudio Fontana <cfontana@suse.de> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
8 | Message-id: 20200229012811.24129-10-richard.henderson@linaro.org | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | target/arm/helper.c | 39 +++++++++++++++++++++++++++++++-------- | 12 | target/arm/helper.c | 4 ++-- |
12 | 1 file changed, 31 insertions(+), 8 deletions(-) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
13 | 14 | ||
14 | 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 |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 17 | --- a/target/arm/helper.c |
17 | +++ b/target/arm/helper.c | 18 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult aa64_cacheop_access(CPUARMState *env, | 19 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) |
19 | return CP_ACCESS_OK; | 20 | * trapped to the hypervisor in KVM. |
20 | } | ||
21 | |||
22 | +static CPAccessResult aa64_cacheop_poc_access(CPUARMState *env, | ||
23 | + const ARMCPRegInfo *ri, | ||
24 | + bool isread) | ||
25 | +{ | ||
26 | + /* Cache invalidate/clean to Point of Coherency or Persistence... */ | ||
27 | + switch (arm_current_el(env)) { | ||
28 | + case 0: | ||
29 | + /* ... EL0 must UNDEF unless SCTLR_EL1.UCI is set. */ | ||
30 | + if (!(arm_sctlr(env, 0) & SCTLR_UCI)) { | ||
31 | + return CP_ACCESS_TRAP; | ||
32 | + } | ||
33 | + /* fall through */ | ||
34 | + case 1: | ||
35 | + /* ... EL1 must trap to EL2 if HCR_EL2.TPCP is set. */ | ||
36 | + if (arm_hcr_el2_eff(env) & HCR_TPCP) { | ||
37 | + return CP_ACCESS_TRAP_EL2; | ||
38 | + } | ||
39 | + break; | ||
40 | + } | ||
41 | + return CP_ACCESS_OK; | ||
42 | +} | ||
43 | + | ||
44 | /* See: D4.7.2 TLB maintenance requirements and the TLB maintenance instructions | ||
45 | * Page D4-1736 (DDI0487A.b) | ||
46 | */ | 21 | */ |
47 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | 22 | #ifdef CONFIG_TCG |
48 | .accessfn = aa64_cacheop_access }, | 23 | -static void handle_semihosting(CPUState *cs) |
49 | { .name = "DC_IVAC", .state = ARM_CP_STATE_AA64, | 24 | +static void tcg_handle_semihosting(CPUState *cs) |
50 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, | 25 | { |
51 | - .access = PL1_W, .type = ARM_CP_NOP }, | 26 | ARMCPU *cpu = ARM_CPU(cs); |
52 | + .access = PL1_W, .accessfn = aa64_cacheop_poc_access, | 27 | CPUARMState *env = &cpu->env; |
53 | + .type = ARM_CP_NOP }, | 28 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) |
54 | { .name = "DC_ISW", .state = ARM_CP_STATE_AA64, | 29 | */ |
55 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 2, | 30 | #ifdef CONFIG_TCG |
56 | .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, | 31 | if (cs->exception_index == EXCP_SEMIHOST) { |
57 | { .name = "DC_CVAC", .state = ARM_CP_STATE_AA64, | 32 | - handle_semihosting(cs); |
58 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 1, | 33 | + tcg_handle_semihosting(cs); |
59 | .access = PL0_W, .type = ARM_CP_NOP, | 34 | return; |
60 | - .accessfn = aa64_cacheop_access }, | 35 | } |
61 | + .accessfn = aa64_cacheop_poc_access }, | 36 | #endif |
62 | { .name = "DC_CSW", .state = ARM_CP_STATE_AA64, | ||
63 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, | ||
64 | .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, | ||
65 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
66 | { .name = "DC_CIVAC", .state = ARM_CP_STATE_AA64, | ||
67 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 1, | ||
68 | .access = PL0_W, .type = ARM_CP_NOP, | ||
69 | - .accessfn = aa64_cacheop_access }, | ||
70 | + .accessfn = aa64_cacheop_poc_access }, | ||
71 | { .name = "DC_CISW", .state = ARM_CP_STATE_AA64, | ||
72 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, | ||
73 | .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, | ||
74 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
75 | { .name = "BPIMVA", .cp = 15, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 7, | ||
76 | .type = ARM_CP_NOP, .access = PL1_W }, | ||
77 | { .name = "DCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, | ||
78 | - .type = ARM_CP_NOP, .access = PL1_W }, | ||
79 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_poc_access }, | ||
80 | { .name = "DCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 2, | ||
81 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
82 | { .name = "DCCMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 1, | ||
83 | - .type = ARM_CP_NOP, .access = PL1_W }, | ||
84 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_poc_access }, | ||
85 | { .name = "DCCSW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, | ||
86 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
87 | { .name = "DCCMVAU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 11, .opc2 = 1, | ||
88 | .type = ARM_CP_NOP, .access = PL1_W }, | ||
89 | { .name = "DCCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 1, | ||
90 | - .type = ARM_CP_NOP, .access = PL1_W }, | ||
91 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_poc_access }, | ||
92 | { .name = "DCCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, | ||
93 | .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
94 | /* MMU Domain access control / MPU write buffer control */ | ||
95 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpop_reg[] = { | ||
96 | { .name = "DC_CVAP", .state = ARM_CP_STATE_AA64, | ||
97 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 1, | ||
98 | .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | ||
99 | - .accessfn = aa64_cacheop_access, .writefn = dccvap_writefn }, | ||
100 | + .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, | ||
101 | REGINFO_SENTINEL | ||
102 | }; | ||
103 | |||
104 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpodp_reg[] = { | ||
105 | { .name = "DC_CVADP", .state = ARM_CP_STATE_AA64, | ||
106 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 1, | ||
107 | .access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END, | ||
108 | - .accessfn = aa64_cacheop_access, .writefn = dccvap_writefn }, | ||
109 | + .accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn }, | ||
110 | REGINFO_SENTINEL | ||
111 | }; | ||
112 | #endif /*CONFIG_USER_ONLY*/ | ||
113 | -- | 37 | -- |
114 | 2.20.1 | 38 | 2.34.1 |
115 | 39 | ||
116 | 40 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | This bit traps EL1 access to the auxiliary control registers. | 3 | for "all" builds (tcg + kvm), we want to avoid doing |
4 | the psci check if tcg is built-in, but not enabled. | ||
4 | 5 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Claudio Fontana <cfontana@suse.de> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20200229012811.24129-9-richard.henderson@linaro.org | 8 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
9 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | target/arm/helper.c | 18 ++++++++++++++---- | 12 | target/arm/helper.c | 3 ++- |
11 | 1 file changed, 14 insertions(+), 4 deletions(-) | 13 | 1 file changed, 2 insertions(+), 1 deletion(-) |
12 | 14 | ||
13 | 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 |
14 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 17 | --- a/target/arm/helper.c |
16 | +++ b/target/arm/helper.c | 18 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tsw(CPUARMState *env, const ARMCPRegInfo *ri, | 19 | @@ -XXX,XX +XXX,XX @@ |
18 | return CP_ACCESS_OK; | 20 | #include "hw/irq.h" |
19 | } | 21 | #include "sysemu/cpu-timers.h" |
20 | 22 | #include "sysemu/kvm.h" | |
21 | +/* Check for traps from EL1 due to HCR_EL2.TACR. */ | 23 | +#include "sysemu/tcg.h" |
22 | +static CPAccessResult access_tacr(CPUARMState *env, const ARMCPRegInfo *ri, | 24 | #include "qapi/qapi-commands-machine-target.h" |
23 | + bool isread) | 25 | #include "qapi/error.h" |
24 | +{ | 26 | #include "qemu/guest-random.h" |
25 | + if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TACR)) { | 27 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) |
26 | + return CP_ACCESS_TRAP_EL2; | 28 | env->exception.syndrome); |
27 | + } | 29 | } |
28 | + return CP_ACCESS_OK; | 30 | |
29 | +} | 31 | - if (arm_is_psci_call(cpu, cs->exception_index)) { |
30 | + | 32 | + if (tcg_enabled() && arm_is_psci_call(cpu, cs->exception_index)) { |
31 | static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 33 | arm_handle_psci_call(cpu); |
32 | { | 34 | qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n"); |
33 | ARMCPU *cpu = env_archcpu(env); | 35 | return; |
34 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1cp_reginfo[] = { | ||
35 | static const ARMCPRegInfo actlr2_hactlr2_reginfo[] = { | ||
36 | { .name = "ACTLR2", .state = ARM_CP_STATE_AA32, | ||
37 | .cp = 15, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 3, | ||
38 | - .access = PL1_RW, .type = ARM_CP_CONST, | ||
39 | - .resetvalue = 0 }, | ||
40 | + .access = PL1_RW, .accessfn = access_tacr, | ||
41 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
42 | { .name = "HACTLR2", .state = ARM_CP_STATE_AA32, | ||
43 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 3, | ||
44 | .access = PL2_RW, .type = ARM_CP_CONST, | ||
45 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
46 | ARMCPRegInfo auxcr_reginfo[] = { | ||
47 | { .name = "ACTLR_EL1", .state = ARM_CP_STATE_BOTH, | ||
48 | .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 1, | ||
49 | - .access = PL1_RW, .type = ARM_CP_CONST, | ||
50 | - .resetvalue = cpu->reset_auxcr }, | ||
51 | + .access = PL1_RW, .accessfn = access_tacr, | ||
52 | + .type = ARM_CP_CONST, .resetvalue = cpu->reset_auxcr }, | ||
53 | { .name = "ACTLR_EL2", .state = ARM_CP_STATE_BOTH, | ||
54 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 1, | ||
55 | .access = PL2_RW, .type = ARM_CP_CONST, | ||
56 | -- | 36 | -- |
57 | 2.20.1 | 37 | 2.34.1 |
58 | 38 | ||
59 | 39 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | Don't merely start with v8.0, handle v7VE as well. Ensure that writes | 3 | Signed-off-by: Claudio Fontana <cfontana@suse.de> |
4 | from aarch32 mode do not change bits in the other half of the register. | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Protect reads of aa64 id registers with ARM_FEATURE_AARCH64. | 5 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
6 | 6 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
7 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20200229012811.24129-2-richard.henderson@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 8 | --- |
13 | target/arm/helper.c | 38 +++++++++++++++++++++++++------------- | 9 | target/arm/helper.c | 12 +++++++----- |
14 | 1 file changed, 25 insertions(+), 13 deletions(-) | 10 | 1 file changed, 7 insertions(+), 5 deletions(-) |
15 | 11 | ||
16 | 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 |
17 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper.c | 14 | --- a/target/arm/helper.c |
19 | +++ b/target/arm/helper.c | 15 | +++ b/target/arm/helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { | 16 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) |
21 | REGINFO_SENTINEL | 17 | unsigned int cur_el = arm_current_el(env); |
22 | }; | 18 | int rt; |
23 | 19 | ||
24 | -static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 20 | - /* |
25 | +static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) | 21 | - * Note that new_el can never be 0. If cur_el is 0, then |
26 | { | 22 | - * el0_a64 is is_a64(), else el0_a64 is ignored. |
27 | ARMCPU *cpu = env_archcpu(env); | 23 | - */ |
28 | - /* Begin with bits defined in base ARMv8.0. */ | 24 | - aarch64_sve_change_el(env, cur_el, new_el, is_a64(env)); |
29 | - uint64_t valid_mask = MAKE_64BIT_MASK(0, 34); | 25 | + if (tcg_enabled()) { |
30 | + | 26 | + /* |
31 | + if (arm_feature(env, ARM_FEATURE_V8)) { | 27 | + * Note that new_el can never be 0. If cur_el is 0, then |
32 | + valid_mask |= MAKE_64BIT_MASK(0, 34); /* ARMv8.0 */ | 28 | + * el0_a64 is is_a64(), else el0_a64 is ignored. |
33 | + } else { | 29 | + */ |
34 | + valid_mask |= MAKE_64BIT_MASK(0, 28); /* ARMv7VE */ | 30 | + aarch64_sve_change_el(env, cur_el, new_el, is_a64(env)); |
35 | + } | 31 | + } |
36 | 32 | ||
37 | if (arm_feature(env, ARM_FEATURE_EL3)) { | 33 | if (cur_el < new_el) { |
38 | valid_mask &= ~HCR_HCD; | 34 | /* |
39 | @@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
40 | */ | ||
41 | valid_mask &= ~HCR_TSC; | ||
42 | } | ||
43 | - if (cpu_isar_feature(aa64_vh, cpu)) { | ||
44 | - valid_mask |= HCR_E2H; | ||
45 | - } | ||
46 | - if (cpu_isar_feature(aa64_lor, cpu)) { | ||
47 | - valid_mask |= HCR_TLOR; | ||
48 | - } | ||
49 | - if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
50 | - valid_mask |= HCR_API | HCR_APK; | ||
51 | + | ||
52 | + if (arm_feature(env, ARM_FEATURE_AARCH64)) { | ||
53 | + if (cpu_isar_feature(aa64_vh, cpu)) { | ||
54 | + valid_mask |= HCR_E2H; | ||
55 | + } | ||
56 | + if (cpu_isar_feature(aa64_lor, cpu)) { | ||
57 | + valid_mask |= HCR_TLOR; | ||
58 | + } | ||
59 | + if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
60 | + valid_mask |= HCR_API | HCR_APK; | ||
61 | + } | ||
62 | } | ||
63 | |||
64 | /* Clear RES0 bits. */ | ||
65 | @@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
66 | arm_cpu_update_vfiq(cpu); | ||
67 | } | ||
68 | |||
69 | +static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
70 | +{ | ||
71 | + do_hcr_write(env, value, 0); | ||
72 | +} | ||
73 | + | ||
74 | static void hcr_writehigh(CPUARMState *env, const ARMCPRegInfo *ri, | ||
75 | uint64_t value) | ||
76 | { | ||
77 | /* Handle HCR2 write, i.e. write to high half of HCR_EL2 */ | ||
78 | value = deposit64(env->cp15.hcr_el2, 32, 32, value); | ||
79 | - hcr_write(env, NULL, value); | ||
80 | + do_hcr_write(env, value, MAKE_64BIT_MASK(0, 32)); | ||
81 | } | ||
82 | |||
83 | static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri, | ||
84 | @@ -XXX,XX +XXX,XX @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri, | ||
85 | { | ||
86 | /* Handle HCR write, i.e. write to low half of HCR_EL2 */ | ||
87 | value = deposit64(env->cp15.hcr_el2, 0, 32, value); | ||
88 | - hcr_write(env, NULL, value); | ||
89 | + do_hcr_write(env, value, MAKE_64BIT_MASK(32, 32)); | ||
90 | } | ||
91 | |||
92 | /* | ||
93 | -- | 35 | -- |
94 | 2.20.1 | 36 | 2.34.1 |
95 | 37 | ||
96 | 38 | diff view generated by jsdifflib |
1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | The Cubieboard contains either 512MiB or 1GiB of onboard RAM [1]. | 3 | Move this earlier to make the next patch diff cleaner. While here |
4 | Prevent changing RAM to a different size which could break user programs. | 4 | update the comment slightly to not give the impression that the |
5 | misalignment affects only TCG. | ||
5 | 6 | ||
6 | [1] http://linux-sunxi.org/Cubieboard | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
8 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | 9 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
9 | Message-id: 20200227220149.6845-4-nieklinnenbank@gmail.com | 10 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 12 | --- |
14 | hw/arm/cubieboard.c | 8 ++++++++ | 13 | target/arm/machine.c | 18 +++++++++--------- |
15 | 1 file changed, 8 insertions(+) | 14 | 1 file changed, 9 insertions(+), 9 deletions(-) |
16 | 15 | ||
17 | diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c | 16 | diff --git a/target/arm/machine.c b/target/arm/machine.c |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/cubieboard.c | 18 | --- a/target/arm/machine.c |
20 | +++ b/hw/arm/cubieboard.c | 19 | +++ b/target/arm/machine.c |
21 | @@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine) | 20 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) |
22 | AwA10State *a10; | 21 | } |
23 | Error *err = NULL; | 22 | } |
24 | 23 | ||
25 | + /* This board has fixed size RAM (512MiB or 1GiB) */ | 24 | + /* |
26 | + if (machine->ram_size != 512 * MiB && | 25 | + * Misaligned thumb pc is architecturally impossible. Fail the |
27 | + machine->ram_size != 1 * GiB) { | 26 | + * incoming migration. For TCG it would trigger the assert in |
28 | + error_report("This machine can only be used with 512MiB or 1GiB RAM"); | 27 | + * thumb_tr_translate_insn(). |
29 | + exit(1); | 28 | + */ |
29 | + if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) { | ||
30 | + return -1; | ||
30 | + } | 31 | + } |
31 | + | 32 | + |
32 | /* Only allow Cortex-A8 for this board */ | 33 | hw_breakpoint_update_all(cpu); |
33 | if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a8")) != 0) { | 34 | hw_watchpoint_update_all(cpu); |
34 | error_report("This board can only be used with cortex-a8 CPU"); | 35 | |
35 | @@ -XXX,XX +XXX,XX @@ static void cubieboard_machine_init(MachineClass *mc) | 36 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) |
36 | { | 37 | } |
37 | mc->desc = "cubietech cubieboard (Cortex-A8)"; | 38 | } |
38 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a8"); | 39 | |
39 | + mc->default_ram_size = 1 * GiB; | 40 | - /* |
40 | mc->init = cubieboard_init; | 41 | - * Misaligned thumb pc is architecturally impossible. |
41 | mc->block_default_type = IF_IDE; | 42 | - * We have an assert in thumb_tr_translate_insn to verify this. |
42 | mc->units_per_default_bus = 1; | 43 | - * Fail an incoming migrate to avoid this assert. |
44 | - */ | ||
45 | - if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) { | ||
46 | - return -1; | ||
47 | - } | ||
48 | - | ||
49 | if (!kvm_enabled()) { | ||
50 | pmu_op_finish(&cpu->env); | ||
51 | } | ||
43 | -- | 52 | -- |
44 | 2.20.1 | 53 | 2.34.1 |
45 | 54 | ||
46 | 55 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | These bits trap EL1 access to various virtual memory controls. | 3 | Since commit cf7c6d1004 ("target/arm: Split out cpregs.h") we now have |
4 | 4 | a cpregs.h header which is more suitable for this code. | |
5 | Buglink: https://bugs.launchpad.net/bugs/1855072 | 5 | |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Code moved verbatim. |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | |
8 | Message-id: 20200229012811.24129-7-richard.henderson@linaro.org | 8 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 13 | --- |
11 | target/arm/helper.c | 82 ++++++++++++++++++++++++++++++--------------- | 14 | target/arm/cpregs.h | 98 +++++++++++++++++++++++++++++++++++++++++++++ |
12 | 1 file changed, 55 insertions(+), 27 deletions(-) | 15 | target/arm/cpu.h | 91 ----------------------------------------- |
13 | 16 | 2 files changed, 98 insertions(+), 91 deletions(-) | |
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 17 | |
18 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 20 | --- a/target/arm/cpregs.h |
17 | +++ b/target/arm/helper.c | 21 | +++ b/target/arm/cpregs.h |
18 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tpm(CPUARMState *env, const ARMCPRegInfo *ri, | 22 | @@ -XXX,XX +XXX,XX @@ enum { |
19 | return CP_ACCESS_OK; | 23 | ARM_CP_SME = 1 << 19, |
20 | } | 24 | }; |
21 | 25 | ||
22 | +/* Check for traps from EL1 due to HCR_EL2.TVM and HCR_EL2.TRVM. */ | 26 | +/* |
23 | +static CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri, | 27 | + * Interface for defining coprocessor registers. |
24 | + bool isread) | 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) | ||
25 | +{ | 84 | +{ |
26 | + if (arm_current_el(env) == 1) { | 85 | + uint32_t cpregid = kvmid; |
27 | + uint64_t trap = isread ? HCR_TRVM : HCR_TVM; | 86 | + if ((kvmid & CP_REG_ARCH_MASK) == CP_REG_ARM64) { |
28 | + if (arm_hcr_el2_eff(env) & trap) { | 87 | + cpregid |= CP_REG_AA64_MASK; |
29 | + return CP_ACCESS_TRAP_EL2; | 88 | + } else { |
89 | + if ((kvmid & CP_REG_SIZE_MASK) == CP_REG_SIZE_U64) { | ||
90 | + cpregid |= (1 << 15); | ||
91 | + } | ||
92 | + | ||
93 | + /* | ||
94 | + * KVM is always non-secure so add the NS flag on AArch32 register | ||
95 | + * entries. | ||
96 | + */ | ||
97 | + cpregid |= 1 << CP_REG_NS_SHIFT; | ||
98 | + } | ||
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; | ||
30 | + } | 119 | + } |
31 | + } | 120 | + } |
32 | + return CP_ACCESS_OK; | 121 | + return kvmid; |
33 | +} | 122 | +} |
34 | + | 123 | + |
35 | static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 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) | ||
36 | { | 228 | { |
37 | ARMCPU *cpu = env_archcpu(env); | ||
38 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cp_reginfo[] = { | ||
39 | */ | ||
40 | { .name = "CONTEXTIDR_EL1", .state = ARM_CP_STATE_BOTH, | ||
41 | .opc0 = 3, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 1, | ||
42 | - .access = PL1_RW, .secure = ARM_CP_SECSTATE_NS, | ||
43 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
44 | + .secure = ARM_CP_SECSTATE_NS, | ||
45 | .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[1]), | ||
46 | .resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, }, | ||
47 | { .name = "CONTEXTIDR_S", .state = ARM_CP_STATE_AA32, | ||
48 | .cp = 15, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 1, | ||
49 | - .access = PL1_RW, .secure = ARM_CP_SECSTATE_S, | ||
50 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
51 | + .secure = ARM_CP_SECSTATE_S, | ||
52 | .fieldoffset = offsetof(CPUARMState, cp15.contextidr_s), | ||
53 | .resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, }, | ||
54 | REGINFO_SENTINEL | ||
55 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v8_cp_reginfo[] = { | ||
56 | /* MMU Domain access control / MPU write buffer control */ | ||
57 | { .name = "DACR", | ||
58 | .cp = 15, .opc1 = CP_ANY, .crn = 3, .crm = CP_ANY, .opc2 = CP_ANY, | ||
59 | - .access = PL1_RW, .resetvalue = 0, | ||
60 | + .access = PL1_RW, .accessfn = access_tvm_trvm, .resetvalue = 0, | ||
61 | .writefn = dacr_write, .raw_writefn = raw_write, | ||
62 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.dacr_s), | ||
63 | offsetoflow32(CPUARMState, cp15.dacr_ns) } }, | ||
64 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = { | ||
65 | { .name = "DMB", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 5, | ||
66 | .access = PL0_W, .type = ARM_CP_NOP }, | ||
67 | { .name = "IFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 2, | ||
68 | - .access = PL1_RW, | ||
69 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
70 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ifar_s), | ||
71 | offsetof(CPUARMState, cp15.ifar_ns) }, | ||
72 | .resetvalue = 0, }, | ||
73 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
74 | */ | ||
75 | { .name = "AFSR0_EL1", .state = ARM_CP_STATE_BOTH, | ||
76 | .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 1, .opc2 = 0, | ||
77 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
78 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
79 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
80 | { .name = "AFSR1_EL1", .state = ARM_CP_STATE_BOTH, | ||
81 | .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 1, .opc2 = 1, | ||
82 | - .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
83 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
84 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
85 | /* MAIR can just read-as-written because we don't implement caches | ||
86 | * and so don't need to care about memory attributes. | ||
87 | */ | ||
88 | { .name = "MAIR_EL1", .state = ARM_CP_STATE_AA64, | ||
89 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 0, | ||
90 | - .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.mair_el[1]), | ||
91 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
92 | + .fieldoffset = offsetof(CPUARMState, cp15.mair_el[1]), | ||
93 | .resetvalue = 0 }, | ||
94 | { .name = "MAIR_EL3", .state = ARM_CP_STATE_AA64, | ||
95 | .opc0 = 3, .opc1 = 6, .crn = 10, .crm = 2, .opc2 = 0, | ||
96 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = { | ||
97 | * handled in the field definitions. | ||
98 | */ | ||
99 | { .name = "MAIR0", .state = ARM_CP_STATE_AA32, | ||
100 | - .cp = 15, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 0, .access = PL1_RW, | ||
101 | + .cp = 15, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 0, | ||
102 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
103 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.mair0_s), | ||
104 | offsetof(CPUARMState, cp15.mair0_ns) }, | ||
105 | .resetfn = arm_cp_reset_ignore }, | ||
106 | { .name = "MAIR1", .state = ARM_CP_STATE_AA32, | ||
107 | - .cp = 15, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 1, .access = PL1_RW, | ||
108 | + .cp = 15, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 1, | ||
109 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
110 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.mair1_s), | ||
111 | offsetof(CPUARMState, cp15.mair1_ns) }, | ||
112 | .resetfn = arm_cp_reset_ignore }, | ||
113 | @@ -XXX,XX +XXX,XX @@ static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
114 | |||
115 | static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = { | ||
116 | { .name = "DFSR", .cp = 15, .crn = 5, .crm = 0, .opc1 = 0, .opc2 = 0, | ||
117 | - .access = PL1_RW, .type = ARM_CP_ALIAS, | ||
118 | + .access = PL1_RW, .accessfn = access_tvm_trvm, .type = ARM_CP_ALIAS, | ||
119 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.dfsr_s), | ||
120 | offsetoflow32(CPUARMState, cp15.dfsr_ns) }, }, | ||
121 | { .name = "IFSR", .cp = 15, .crn = 5, .crm = 0, .opc1 = 0, .opc2 = 1, | ||
122 | - .access = PL1_RW, .resetvalue = 0, | ||
123 | + .access = PL1_RW, .accessfn = access_tvm_trvm, .resetvalue = 0, | ||
124 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.ifsr_s), | ||
125 | offsetoflow32(CPUARMState, cp15.ifsr_ns) } }, | ||
126 | { .name = "DFAR", .cp = 15, .opc1 = 0, .crn = 6, .crm = 0, .opc2 = 0, | ||
127 | - .access = PL1_RW, .resetvalue = 0, | ||
128 | + .access = PL1_RW, .accessfn = access_tvm_trvm, .resetvalue = 0, | ||
129 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.dfar_s), | ||
130 | offsetof(CPUARMState, cp15.dfar_ns) } }, | ||
131 | { .name = "FAR_EL1", .state = ARM_CP_STATE_AA64, | ||
132 | .opc0 = 3, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 0, | ||
133 | - .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.far_el[1]), | ||
134 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
135 | + .fieldoffset = offsetof(CPUARMState, cp15.far_el[1]), | ||
136 | .resetvalue = 0, }, | ||
137 | REGINFO_SENTINEL | ||
138 | }; | ||
139 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = { | ||
140 | static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
141 | { .name = "ESR_EL1", .state = ARM_CP_STATE_AA64, | ||
142 | .opc0 = 3, .crn = 5, .crm = 2, .opc1 = 0, .opc2 = 0, | ||
143 | - .access = PL1_RW, | ||
144 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
145 | .fieldoffset = offsetof(CPUARMState, cp15.esr_el[1]), .resetvalue = 0, }, | ||
146 | { .name = "TTBR0_EL1", .state = ARM_CP_STATE_BOTH, | ||
147 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 0, | ||
148 | - .access = PL1_RW, .writefn = vmsa_ttbr_write, .resetvalue = 0, | ||
149 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
150 | + .writefn = vmsa_ttbr_write, .resetvalue = 0, | ||
151 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s), | ||
152 | offsetof(CPUARMState, cp15.ttbr0_ns) } }, | ||
153 | { .name = "TTBR1_EL1", .state = ARM_CP_STATE_BOTH, | ||
154 | .opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 1, | ||
155 | - .access = PL1_RW, .writefn = vmsa_ttbr_write, .resetvalue = 0, | ||
156 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
157 | + .writefn = vmsa_ttbr_write, .resetvalue = 0, | ||
158 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), | ||
159 | offsetof(CPUARMState, cp15.ttbr1_ns) } }, | ||
160 | { .name = "TCR_EL1", .state = ARM_CP_STATE_AA64, | ||
161 | .opc0 = 3, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 2, | ||
162 | - .access = PL1_RW, .writefn = vmsa_tcr_el12_write, | ||
163 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
164 | + .writefn = vmsa_tcr_el12_write, | ||
165 | .resetfn = vmsa_ttbcr_reset, .raw_writefn = raw_write, | ||
166 | .fieldoffset = offsetof(CPUARMState, cp15.tcr_el[1]) }, | ||
167 | { .name = "TTBCR", .cp = 15, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 2, | ||
168 | - .access = PL1_RW, .type = ARM_CP_ALIAS, .writefn = vmsa_ttbcr_write, | ||
169 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
170 | + .type = ARM_CP_ALIAS, .writefn = vmsa_ttbcr_write, | ||
171 | .raw_writefn = vmsa_ttbcr_raw_write, | ||
172 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tcr_el[3]), | ||
173 | offsetoflow32(CPUARMState, cp15.tcr_el[1])} }, | ||
174 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { | ||
175 | */ | ||
176 | static const ARMCPRegInfo ttbcr2_reginfo = { | ||
177 | .name = "TTBCR2", .cp = 15, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 3, | ||
178 | - .access = PL1_RW, .type = ARM_CP_ALIAS, | ||
179 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
180 | + .type = ARM_CP_ALIAS, | ||
181 | .bank_fieldoffsets = { offsetofhigh32(CPUARMState, cp15.tcr_el[3]), | ||
182 | offsetofhigh32(CPUARMState, cp15.tcr_el[1]) }, | ||
183 | }; | ||
184 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lpae_cp_reginfo[] = { | ||
185 | /* NOP AMAIR0/1 */ | ||
186 | { .name = "AMAIR0", .state = ARM_CP_STATE_BOTH, | ||
187 | .opc0 = 3, .crn = 10, .crm = 3, .opc1 = 0, .opc2 = 0, | ||
188 | - .access = PL1_RW, .type = ARM_CP_CONST, | ||
189 | - .resetvalue = 0 }, | ||
190 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
191 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
192 | /* AMAIR1 is mapped to AMAIR_EL1[63:32] */ | ||
193 | { .name = "AMAIR1", .cp = 15, .crn = 10, .crm = 3, .opc1 = 0, .opc2 = 1, | ||
194 | - .access = PL1_RW, .type = ARM_CP_CONST, | ||
195 | - .resetvalue = 0 }, | ||
196 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
197 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
198 | { .name = "PAR", .cp = 15, .crm = 7, .opc1 = 0, | ||
199 | .access = PL1_RW, .type = ARM_CP_64BIT, .resetvalue = 0, | ||
200 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.par_s), | ||
201 | offsetof(CPUARMState, cp15.par_ns)} }, | ||
202 | { .name = "TTBR0", .cp = 15, .crm = 2, .opc1 = 0, | ||
203 | - .access = PL1_RW, .type = ARM_CP_64BIT | ARM_CP_ALIAS, | ||
204 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
205 | + .type = ARM_CP_64BIT | ARM_CP_ALIAS, | ||
206 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s), | ||
207 | offsetof(CPUARMState, cp15.ttbr0_ns) }, | ||
208 | .writefn = vmsa_ttbr_write, }, | ||
209 | { .name = "TTBR1", .cp = 15, .crm = 2, .opc1 = 1, | ||
210 | - .access = PL1_RW, .type = ARM_CP_64BIT | ARM_CP_ALIAS, | ||
211 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
212 | + .type = ARM_CP_64BIT | ARM_CP_ALIAS, | ||
213 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s), | ||
214 | offsetof(CPUARMState, cp15.ttbr1_ns) }, | ||
215 | .writefn = vmsa_ttbr_write, }, | ||
216 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
217 | .type = ARM_CP_NOP, .access = PL1_W }, | ||
218 | /* MMU Domain access control / MPU write buffer control */ | ||
219 | { .name = "DACR", .cp = 15, .opc1 = 0, .crn = 3, .crm = 0, .opc2 = 0, | ||
220 | - .access = PL1_RW, .resetvalue = 0, | ||
221 | + .access = PL1_RW, .accessfn = access_tvm_trvm, .resetvalue = 0, | ||
222 | .writefn = dacr_write, .raw_writefn = raw_write, | ||
223 | .bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.dacr_s), | ||
224 | offsetoflow32(CPUARMState, cp15.dacr_ns) } }, | ||
225 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
226 | ARMCPRegInfo sctlr = { | ||
227 | .name = "SCTLR", .state = ARM_CP_STATE_BOTH, | ||
228 | .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 0, | ||
229 | - .access = PL1_RW, | ||
230 | + .access = PL1_RW, .accessfn = access_tvm_trvm, | ||
231 | .bank_fieldoffsets = { offsetof(CPUARMState, cp15.sctlr_s), | ||
232 | offsetof(CPUARMState, cp15.sctlr_ns) }, | ||
233 | .writefn = sctlr_write, .resetvalue = cpu->reset_sctlr, | ||
234 | -- | 229 | -- |
235 | 2.20.1 | 230 | 2.34.1 |
236 | 231 | ||
237 | 232 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | We only build the little-endian softmmu configurations. Checking | 3 | If a test was tagged with the "accel" tag and the specified |
4 | for big endian is pointless, remove the unused code. | 4 | accelerator it not present in the qemu binary, cancel the test. |
5 | 5 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 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> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 13 | --- |
10 | hw/arm/musicpal.c | 10 ---------- | 14 | tests/avocado/avocado_qemu/__init__.py | 4 ++++ |
11 | 1 file changed, 10 deletions(-) | 15 | 1 file changed, 4 insertions(+) |
12 | 16 | ||
13 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c | 17 | diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py |
14 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/musicpal.c | 19 | --- a/tests/avocado/avocado_qemu/__init__.py |
16 | +++ b/hw/arm/musicpal.c | 20 | +++ b/tests/avocado/avocado_qemu/__init__.py |
17 | @@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine) | 21 | @@ -XXX,XX +XXX,XX @@ def setUp(self): |
18 | * 0xFF800000 (if there is 8 MB flash). So remap flash access if the | 22 | |
19 | * image is smaller than 32 MB. | 23 | super().setUp('qemu-system-') |
20 | */ | 24 | |
21 | -#ifdef TARGET_WORDS_BIGENDIAN | 25 | + accel_required = self._get_unique_tag_val('accel') |
22 | - pflash_cfi02_register(0x100000000ULL - MP_FLASH_SIZE_MAX, | 26 | + if accel_required: |
23 | - "musicpal.flash", flash_size, | 27 | + self.require_accelerator(accel_required) |
24 | - blk, 0x10000, | 28 | + |
25 | - MP_FLASH_SIZE_MAX / flash_size, | 29 | self.machine = self.params.get('machine', |
26 | - 2, 0x00BF, 0x236D, 0x0000, 0x0000, | 30 | default=self._get_unique_tag_val('machine')) |
27 | - 0x5555, 0x2AAA, 1); | ||
28 | -#else | ||
29 | pflash_cfi02_register(0x100000000ULL - MP_FLASH_SIZE_MAX, | ||
30 | "musicpal.flash", flash_size, | ||
31 | blk, 0x10000, | ||
32 | MP_FLASH_SIZE_MAX / flash_size, | ||
33 | 2, 0x00BF, 0x236D, 0x0000, 0x0000, | ||
34 | 0x5555, 0x2AAA, 0); | ||
35 | -#endif | ||
36 | - | ||
37 | } | ||
38 | sysbus_create_simple(TYPE_MV88W8618_FLASHCFG, MP_FLASHCFG_BASE, NULL); | ||
39 | 31 | ||
40 | -- | 32 | -- |
41 | 2.20.1 | 33 | 2.34.1 |
42 | 34 | ||
43 | 35 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Pan Nengyuan <pannengyuan@huawei.com> | ||
2 | 1 | ||
3 | There are some memleaks when we call 'device_list_properties'. This patch move timer_new from init into realize to fix it. | ||
4 | |||
5 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
6 | Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com> | ||
7 | Message-id: 20200227025055.14341-3-pannengyuan@huawei.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/arm/pxa2xx.c | 17 +++++++++++------ | ||
12 | 1 file changed, 11 insertions(+), 6 deletions(-) | ||
13 | |||
14 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/arm/pxa2xx.c | ||
17 | +++ b/hw/arm/pxa2xx.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_rtc_init(Object *obj) | ||
19 | s->last_rtcpicr = 0; | ||
20 | s->last_hz = s->last_sw = s->last_pi = qemu_clock_get_ms(rtc_clock); | ||
21 | |||
22 | + sysbus_init_irq(dev, &s->rtc_irq); | ||
23 | + | ||
24 | + memory_region_init_io(&s->iomem, obj, &pxa2xx_rtc_ops, s, | ||
25 | + "pxa2xx-rtc", 0x10000); | ||
26 | + sysbus_init_mmio(dev, &s->iomem); | ||
27 | +} | ||
28 | + | ||
29 | +static void pxa2xx_rtc_realize(DeviceState *dev, Error **errp) | ||
30 | +{ | ||
31 | + PXA2xxRTCState *s = PXA2XX_RTC(dev); | ||
32 | s->rtc_hz = timer_new_ms(rtc_clock, pxa2xx_rtc_hz_tick, s); | ||
33 | s->rtc_rdal1 = timer_new_ms(rtc_clock, pxa2xx_rtc_rdal1_tick, s); | ||
34 | s->rtc_rdal2 = timer_new_ms(rtc_clock, pxa2xx_rtc_rdal2_tick, s); | ||
35 | s->rtc_swal1 = timer_new_ms(rtc_clock, pxa2xx_rtc_swal1_tick, s); | ||
36 | s->rtc_swal2 = timer_new_ms(rtc_clock, pxa2xx_rtc_swal2_tick, s); | ||
37 | s->rtc_pi = timer_new_ms(rtc_clock, pxa2xx_rtc_pi_tick, s); | ||
38 | - | ||
39 | - sysbus_init_irq(dev, &s->rtc_irq); | ||
40 | - | ||
41 | - memory_region_init_io(&s->iomem, obj, &pxa2xx_rtc_ops, s, | ||
42 | - "pxa2xx-rtc", 0x10000); | ||
43 | - sysbus_init_mmio(dev, &s->iomem); | ||
44 | } | ||
45 | |||
46 | static int pxa2xx_rtc_pre_save(void *opaque) | ||
47 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_rtc_sysbus_class_init(ObjectClass *klass, void *data) | ||
48 | |||
49 | dc->desc = "PXA2xx RTC Controller"; | ||
50 | dc->vmsd = &vmstate_pxa2xx_rtc_regs; | ||
51 | + dc->realize = pxa2xx_rtc_realize; | ||
52 | } | ||
53 | |||
54 | static const TypeInfo pxa2xx_rtc_sysbus_info = { | ||
55 | -- | ||
56 | 2.20.1 | ||
57 | |||
58 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Pan Nengyuan <pannengyuan@huawei.com> | ||
2 | 1 | ||
3 | There are some memleaks when we call 'device_list_properties'. This patch move timer_new from init into realize to fix it. | ||
4 | |||
5 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
6 | Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com> | ||
7 | Message-id: 20200227025055.14341-5-pannengyuan@huawei.com | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/arm/strongarm.c | 18 ++++++++++++------ | ||
12 | 1 file changed, 12 insertions(+), 6 deletions(-) | ||
13 | |||
14 | diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/hw/arm/strongarm.c | ||
17 | +++ b/hw/arm/strongarm.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void strongarm_rtc_init(Object *obj) | ||
19 | s->last_rcnr = (uint32_t) mktimegm(&tm); | ||
20 | s->last_hz = qemu_clock_get_ms(rtc_clock); | ||
21 | |||
22 | - s->rtc_alarm = timer_new_ms(rtc_clock, strongarm_rtc_alarm_tick, s); | ||
23 | - s->rtc_hz = timer_new_ms(rtc_clock, strongarm_rtc_hz_tick, s); | ||
24 | - | ||
25 | sysbus_init_irq(dev, &s->rtc_irq); | ||
26 | sysbus_init_irq(dev, &s->rtc_hz_irq); | ||
27 | |||
28 | @@ -XXX,XX +XXX,XX @@ static void strongarm_rtc_init(Object *obj) | ||
29 | sysbus_init_mmio(dev, &s->iomem); | ||
30 | } | ||
31 | |||
32 | +static void strongarm_rtc_realize(DeviceState *dev, Error **errp) | ||
33 | +{ | ||
34 | + StrongARMRTCState *s = STRONGARM_RTC(dev); | ||
35 | + s->rtc_alarm = timer_new_ms(rtc_clock, strongarm_rtc_alarm_tick, s); | ||
36 | + s->rtc_hz = timer_new_ms(rtc_clock, strongarm_rtc_hz_tick, s); | ||
37 | +} | ||
38 | + | ||
39 | static int strongarm_rtc_pre_save(void *opaque) | ||
40 | { | ||
41 | StrongARMRTCState *s = opaque; | ||
42 | @@ -XXX,XX +XXX,XX @@ static void strongarm_rtc_sysbus_class_init(ObjectClass *klass, void *data) | ||
43 | |||
44 | dc->desc = "StrongARM RTC Controller"; | ||
45 | dc->vmsd = &vmstate_strongarm_rtc_regs; | ||
46 | + dc->realize = strongarm_rtc_realize; | ||
47 | } | ||
48 | |||
49 | static const TypeInfo strongarm_rtc_sysbus_info = { | ||
50 | @@ -XXX,XX +XXX,XX @@ static void strongarm_uart_init(Object *obj) | ||
51 | "uart", 0x10000); | ||
52 | sysbus_init_mmio(dev, &s->iomem); | ||
53 | sysbus_init_irq(dev, &s->irq); | ||
54 | - | ||
55 | - s->rx_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, strongarm_uart_rx_to, s); | ||
56 | - s->tx_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, strongarm_uart_tx, s); | ||
57 | } | ||
58 | |||
59 | static void strongarm_uart_realize(DeviceState *dev, Error **errp) | ||
60 | { | ||
61 | StrongARMUARTState *s = STRONGARM_UART(dev); | ||
62 | |||
63 | + s->rx_timeout_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, | ||
64 | + strongarm_uart_rx_to, | ||
65 | + s); | ||
66 | + s->tx_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, strongarm_uart_tx, s); | ||
67 | qemu_chr_fe_set_handlers(&s->chr, | ||
68 | strongarm_uart_can_receive, | ||
69 | strongarm_uart_receive, | ||
70 | -- | ||
71 | 2.20.1 | ||
72 | |||
73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Pan Nengyuan <pannengyuan@huawei.com> | ||
2 | 1 | ||
3 | There are some memleaks when we call 'device_list_properties'. This patch move timer_new from init into realize to fix it. | ||
4 | |||
5 | Reported-by: Euler Robot <euler.robot@huawei.com> | ||
6 | Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com> | ||
7 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
8 | Message-id: 20200227025055.14341-7-pannengyuan@huawei.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/timer/cadence_ttc.c | 18 ++++++++++++------ | ||
13 | 1 file changed, 12 insertions(+), 6 deletions(-) | ||
14 | |||
15 | diff --git a/hw/timer/cadence_ttc.c b/hw/timer/cadence_ttc.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/timer/cadence_ttc.c | ||
18 | +++ b/hw/timer/cadence_ttc.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void cadence_timer_init(uint32_t freq, CadenceTimerState *s) | ||
20 | static void cadence_ttc_init(Object *obj) | ||
21 | { | ||
22 | CadenceTTCState *s = CADENCE_TTC(obj); | ||
23 | - int i; | ||
24 | - | ||
25 | - for (i = 0; i < 3; ++i) { | ||
26 | - cadence_timer_init(133000000, &s->timer[i]); | ||
27 | - sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->timer[i].irq); | ||
28 | - } | ||
29 | |||
30 | memory_region_init_io(&s->iomem, obj, &cadence_ttc_ops, s, | ||
31 | "timer", 0x1000); | ||
32 | sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem); | ||
33 | } | ||
34 | |||
35 | +static void cadence_ttc_realize(DeviceState *dev, Error **errp) | ||
36 | +{ | ||
37 | + CadenceTTCState *s = CADENCE_TTC(dev); | ||
38 | + int i; | ||
39 | + | ||
40 | + for (i = 0; i < 3; ++i) { | ||
41 | + cadence_timer_init(133000000, &s->timer[i]); | ||
42 | + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->timer[i].irq); | ||
43 | + } | ||
44 | +} | ||
45 | + | ||
46 | static int cadence_timer_pre_save(void *opaque) | ||
47 | { | ||
48 | cadence_timer_sync((CadenceTimerState *)opaque); | ||
49 | @@ -XXX,XX +XXX,XX @@ static void cadence_ttc_class_init(ObjectClass *klass, void *data) | ||
50 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
51 | |||
52 | dc->vmsd = &vmstate_cadence_ttc; | ||
53 | + dc->realize = cadence_ttc_realize; | ||
54 | } | ||
55 | |||
56 | static const TypeInfo cadence_ttc_info = { | ||
57 | -- | ||
58 | 2.20.1 | ||
59 | |||
60 | diff view generated by jsdifflib |
1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | The Cubieboard has an ARM Cortex-A8. Instead of simply ignoring a | 3 | This allows the test to be skipped when TCG is not present in the QEMU |
4 | bogus -cpu option provided by the user, give them an error message so | 4 | binary. |
5 | they know their command line is wrong. | ||
6 | 5 | ||
7 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | 6 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
8 | Message-id: 20200227220149.6845-3-nieklinnenbank@gmail.com | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | [PMM: tweaked commit message] | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | hw/arm/cubieboard.c | 10 +++++++++- | 11 | tests/avocado/boot_linux_console.py | 1 + |
15 | 1 file changed, 9 insertions(+), 1 deletion(-) | 12 | tests/avocado/reverse_debugging.py | 8 ++++++++ |
13 | 2 files changed, 9 insertions(+) | ||
16 | 14 | ||
17 | diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c | 15 | diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/cubieboard.c | 17 | --- a/tests/avocado/boot_linux_console.py |
20 | +++ b/hw/arm/cubieboard.c | 18 | +++ b/tests/avocado/boot_linux_console.py |
21 | @@ -XXX,XX +XXX,XX @@ static struct arm_boot_info cubieboard_binfo = { | 19 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_uboot_netbsd9(self): |
22 | 20 | ||
23 | static void cubieboard_init(MachineState *machine) | 21 | def test_aarch64_raspi3_atf(self): |
24 | { | 22 | """ |
25 | - AwA10State *a10 = AW_A10(object_new(TYPE_AW_A10)); | 23 | + :avocado: tags=accel:tcg |
26 | + AwA10State *a10; | 24 | :avocado: tags=arch:aarch64 |
27 | Error *err = NULL; | 25 | :avocado: tags=machine:raspi3b |
28 | 26 | :avocado: tags=cpu:cortex-a53 | |
29 | + /* Only allow Cortex-A8 for this board */ | 27 | diff --git a/tests/avocado/reverse_debugging.py b/tests/avocado/reverse_debugging.py |
30 | + if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a8")) != 0) { | 28 | index XXXXXXX..XXXXXXX 100644 |
31 | + error_report("This board can only be used with cortex-a8 CPU"); | 29 | --- a/tests/avocado/reverse_debugging.py |
32 | + exit(1); | 30 | +++ b/tests/avocado/reverse_debugging.py |
33 | + } | 31 | @@ -XXX,XX +XXX,XX @@ def reverse_debugging(self, shift=7, args=None): |
32 | vm.shutdown() | ||
33 | |||
34 | class ReverseDebugging_X86_64(ReverseDebugging): | ||
35 | + """ | ||
36 | + :avocado: tags=accel:tcg | ||
37 | + """ | ||
34 | + | 38 | + |
35 | + a10 = AW_A10(object_new(TYPE_AW_A10)); | 39 | REG_PC = 0x10 |
40 | REG_CS = 0x12 | ||
41 | def get_pc(self, g): | ||
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 | + """ | ||
36 | + | 49 | + |
37 | object_property_set_int(OBJECT(&a10->emac), 1, "phy-addr", &err); | 50 | REG_PC = 32 |
38 | if (err != NULL) { | 51 | |
39 | error_reportf_err(err, "Couldn't set phy address: "); | 52 | # unidentified gitlab timeout problem |
40 | -- | 53 | -- |
41 | 2.20.1 | 54 | 2.34.1 |
42 | 55 | ||
43 | 56 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | These bits trap EL1 access to set/way cache maintenance insns. | 3 | Now that the cortex-a15 is under CONFIG_TCG, use as default CPU for a |
4 | KVM-only build the 'max' cpu. | ||
4 | 5 | ||
5 | Buglink: https://bugs.launchpad.net/bugs/1863685 | 6 | Note that we cannot use 'host' here because the qtests can run without |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | any other accelerator (than qtest) and 'host' depends on KVM being |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | enabled. |
8 | Message-id: 20200229012811.24129-8-richard.henderson@linaro.org | 9 | |
10 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
11 | Acked-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 14 | --- |
11 | target/arm/helper.c | 22 ++++++++++++++++------ | 15 | hw/arm/virt.c | 4 ++++ |
12 | 1 file changed, 16 insertions(+), 6 deletions(-) | 16 | 1 file changed, 4 insertions(+) |
13 | 17 | ||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 18 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 20 | --- a/hw/arm/virt.c |
17 | +++ b/target/arm/helper.c | 21 | +++ b/hw/arm/virt.c |
18 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tvm_trvm(CPUARMState *env, const ARMCPRegInfo *ri, | 22 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data) |
19 | return CP_ACCESS_OK; | 23 | mc->minimum_page_bits = 12; |
20 | } | 24 | mc->possible_cpu_arch_ids = virt_possible_cpu_arch_ids; |
21 | 25 | mc->cpu_index_to_instance_props = virt_cpu_index_to_props; | |
22 | +/* Check for traps from EL1 due to HCR_EL2.TSW. */ | 26 | +#ifdef CONFIG_TCG |
23 | +static CPAccessResult access_tsw(CPUARMState *env, const ARMCPRegInfo *ri, | 27 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); |
24 | + bool isread) | 28 | +#else |
25 | +{ | 29 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("max"); |
26 | + if (arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_TSW)) { | 30 | +#endif |
27 | + return CP_ACCESS_TRAP_EL2; | 31 | mc->get_default_cpu_node_id = virt_get_default_cpu_node_id; |
28 | + } | 32 | mc->kvm_type = virt_kvm_type; |
29 | + return CP_ACCESS_OK; | 33 | assert(!mc->get_hotplug_handler); |
30 | +} | ||
31 | + | ||
32 | static void dacr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
33 | { | ||
34 | ARMCPU *cpu = env_archcpu(env); | ||
35 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
36 | .access = PL1_W, .type = ARM_CP_NOP }, | ||
37 | { .name = "DC_ISW", .state = ARM_CP_STATE_AA64, | ||
38 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 2, | ||
39 | - .access = PL1_W, .type = ARM_CP_NOP }, | ||
40 | + .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, | ||
41 | { .name = "DC_CVAC", .state = ARM_CP_STATE_AA64, | ||
42 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 1, | ||
43 | .access = PL0_W, .type = ARM_CP_NOP, | ||
44 | .accessfn = aa64_cacheop_access }, | ||
45 | { .name = "DC_CSW", .state = ARM_CP_STATE_AA64, | ||
46 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, | ||
47 | - .access = PL1_W, .type = ARM_CP_NOP }, | ||
48 | + .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, | ||
49 | { .name = "DC_CVAU", .state = ARM_CP_STATE_AA64, | ||
50 | .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 11, .opc2 = 1, | ||
51 | .access = PL0_W, .type = ARM_CP_NOP, | ||
52 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
53 | .accessfn = aa64_cacheop_access }, | ||
54 | { .name = "DC_CISW", .state = ARM_CP_STATE_AA64, | ||
55 | .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, | ||
56 | - .access = PL1_W, .type = ARM_CP_NOP }, | ||
57 | + .access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP }, | ||
58 | /* TLBI operations */ | ||
59 | { .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64, | ||
60 | .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, | ||
61 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = { | ||
62 | { .name = "DCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1, | ||
63 | .type = ARM_CP_NOP, .access = PL1_W }, | ||
64 | { .name = "DCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 2, | ||
65 | - .type = ARM_CP_NOP, .access = PL1_W }, | ||
66 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
67 | { .name = "DCCMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 1, | ||
68 | .type = ARM_CP_NOP, .access = PL1_W }, | ||
69 | { .name = "DCCSW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2, | ||
70 | - .type = ARM_CP_NOP, .access = PL1_W }, | ||
71 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
72 | { .name = "DCCMVAU", .cp = 15, .opc1 = 0, .crn = 7, .crm = 11, .opc2 = 1, | ||
73 | .type = ARM_CP_NOP, .access = PL1_W }, | ||
74 | { .name = "DCCIMVAC", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 1, | ||
75 | .type = ARM_CP_NOP, .access = PL1_W }, | ||
76 | { .name = "DCCISW", .cp = 15, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2, | ||
77 | - .type = ARM_CP_NOP, .access = PL1_W }, | ||
78 | + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, | ||
79 | /* MMU Domain access control / MPU write buffer control */ | ||
80 | { .name = "DACR", .cp = 15, .opc1 = 0, .crn = 3, .crm = 0, .opc2 = 0, | ||
81 | .access = PL1_RW, .accessfn = access_tvm_trvm, .resetvalue = 0, | ||
82 | -- | 34 | -- |
83 | 2.20.1 | 35 | 2.34.1 |
84 | |||
85 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | Update the {TGE,E2H} == '11' masking to ARMv8.6. | 3 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
4 | If EL2 is configured for aarch32, disable all of | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | the bits that are RES0 in aarch32 mode. | 5 | Acked-by: Thomas Huth <thuth@redhat.com> |
6 | |||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200229012811.24129-6-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 7 | --- |
12 | target/arm/helper.c | 31 +++++++++++++++++++++++++++---- | 8 | tests/qtest/arm-cpu-features.c | 28 ++++++++++++++++++---------- |
13 | 1 file changed, 27 insertions(+), 4 deletions(-) | 9 | 1 file changed, 18 insertions(+), 10 deletions(-) |
14 | 10 | ||
15 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 11 | diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c |
16 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper.c | 13 | --- a/tests/qtest/arm-cpu-features.c |
18 | +++ b/target/arm/helper.c | 14 | +++ b/tests/qtest/arm-cpu-features.c |
19 | @@ -XXX,XX +XXX,XX @@ uint64_t arm_hcr_el2_eff(CPUARMState *env) | 15 | @@ -XXX,XX +XXX,XX @@ |
20 | * Since the v8.4 language applies to the entire register, and | 16 | #define SVE_MAX_VQ 16 |
21 | * appears to be backward compatible, use that. | 17 | |
22 | */ | 18 | #define MACHINE "-machine virt,gic-version=max -accel tcg " |
23 | - ret = 0; | 19 | -#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accel tcg " |
24 | - } else if (ret & HCR_TGE) { | 20 | +#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm " |
25 | - /* These bits are up-to-date as of ARMv8.4. */ | 21 | #define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \ |
26 | + return 0; | 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); | ||
27 | + } | 33 | + } |
28 | + | 34 | + |
29 | + /* | 35 | + if (!g_str_equal(qtest_get_arch(), "aarch64")) { |
30 | + * For a cpu that supports both aarch64 and aarch32, we can set bits | 36 | + goto out; |
31 | + * in HCR_EL2 (e.g. via EL3) that are RES0 when we enter EL2 as aa32. | 37 | + } |
32 | + * Ignore all of the bits in HCR+HCR2 that are not valid for aarch32. | 38 | |
33 | + */ | 39 | /* |
34 | + if (!arm_el_is_aa64(env, 2)) { | 40 | * For now we only run KVM specific tests with AArch64 QEMU in |
35 | + uint64_t aa32_valid; | 41 | * order avoid attempting to run an AArch32 QEMU with KVM on |
36 | + | 42 | * AArch64 hosts. That won't work and isn't easy to detect. |
37 | + /* | 43 | */ |
38 | + * These bits are up-to-date as of ARMv8.6. | 44 | - if (g_str_equal(qtest_get_arch(), "aarch64") && qtest_has_accel("kvm")) { |
39 | + * For HCR, it's easiest to list just the 2 bits that are invalid. | 45 | + if (qtest_has_accel("kvm")) { |
40 | + * For HCR2, list those that are valid. | 46 | /* |
41 | + */ | 47 | * This tests target the 'host' CPU type, so register it only if |
42 | + aa32_valid = MAKE_64BIT_MASK(0, 32) & ~(HCR_RW | HCR_TDZ); | 48 | * KVM is available. |
43 | + aa32_valid |= (HCR_CD | HCR_ID | HCR_TERR | HCR_TEA | HCR_MIOCNCE | | 49 | */ |
44 | + HCR_TID4 | HCR_TICAB | HCR_TOCU | HCR_TTLBIS); | 50 | qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", |
45 | + ret &= aa32_valid; | 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 | } | ||
62 | |||
63 | + if (qtest_has_accel("tcg")) { | ||
64 | + qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8", | ||
65 | + NULL, sve_tests_sve_max_vq_8); | ||
66 | + qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off", | ||
67 | + NULL, sve_tests_sve_off); | ||
46 | + } | 68 | + } |
47 | + | 69 | + |
48 | + if (ret & HCR_TGE) { | 70 | +out: |
49 | + /* These bits are up-to-date as of ARMv8.6. */ | 71 | return g_test_run(); |
50 | if (ret & HCR_E2H) { | 72 | } |
51 | ret &= ~(HCR_VM | HCR_FMO | HCR_IMO | HCR_AMO | | ||
52 | HCR_BSU_MASK | HCR_DC | HCR_TWI | HCR_TWE | | ||
53 | HCR_TID0 | HCR_TID2 | HCR_TPCP | HCR_TPU | | ||
54 | - HCR_TDZ | HCR_CD | HCR_ID | HCR_MIOCNCE); | ||
55 | + HCR_TDZ | HCR_CD | HCR_ID | HCR_MIOCNCE | | ||
56 | + HCR_TID4 | HCR_TICAB | HCR_TOCU | HCR_ENSCXT | | ||
57 | + HCR_TTLBIS | HCR_TTLBOS | HCR_TID5); | ||
58 | } else { | ||
59 | ret |= HCR_FMO | HCR_IMO | HCR_AMO; | ||
60 | } | ||
61 | -- | 73 | -- |
62 | 2.20.1 | 74 | 2.34.1 |
63 | |||
64 | diff view generated by jsdifflib |
1 | From: Niek Linnenbank <nieklinnenbank@gmail.com> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | The Cubieboard is a singleboard computer with an Allwinner A10 System-on-Chip [1]. | 3 | These tests set -accel tcg, so restrict them to when TCG is present. |
4 | As documented in the Allwinner A10 User Manual V1.5 [2], the SoC has an ARM | ||
5 | Cortex-A8 processor. Currently the Cubieboard machine definition specifies the | ||
6 | ARM Cortex-A9 in its description and as the default CPU. | ||
7 | 4 | ||
8 | This patch corrects the Cubieboard machine definition to use the ARM Cortex-A8. | 5 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
9 | 6 | Acked-by: Richard Henderson <richard.henderson@linaro.org> | |
10 | The only user-visible effect is that our textual description of the | 7 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
11 | machine was wrong, because hw/arm/allwinner-a10.c always creates a | ||
12 | Cortex-A8 CPU regardless of the default value in the MachineClass struct. | ||
13 | |||
14 | [1] http://docs.cubieboard.org/products/start#cubieboard1 | ||
15 | [2] https://linux-sunxi.org/File:Allwinner_A10_User_manual_V1.5.pdf | ||
16 | |||
17 | Fixes: 8a863c8120994981a099 | ||
18 | Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com> | ||
19 | Message-id: 20200227220149.6845-2-nieklinnenbank@gmail.com | ||
20 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
21 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | [note in commit message that the bug didn't have much visible effect] | ||
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
24 | --- | 9 | --- |
25 | hw/arm/cubieboard.c | 4 ++-- | 10 | tests/qtest/meson.build | 4 ++-- |
26 | 1 file changed, 2 insertions(+), 2 deletions(-) | 11 | 1 file changed, 2 insertions(+), 2 deletions(-) |
27 | 12 | ||
28 | diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c | 13 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build |
29 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/hw/arm/cubieboard.c | 15 | --- a/tests/qtest/meson.build |
31 | +++ b/hw/arm/cubieboard.c | 16 | +++ b/tests/qtest/meson.build |
32 | @@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine) | 17 | @@ -XXX,XX +XXX,XX @@ qtests_arm = \ |
33 | 18 | # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional | |
34 | static void cubieboard_machine_init(MachineClass *mc) | 19 | qtests_aarch64 = \ |
35 | { | 20 | (cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) + \ |
36 | - mc->desc = "cubietech cubieboard (Cortex-A9)"; | 21 | - (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \ |
37 | - mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a9"); | 22 | - (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \ |
38 | + mc->desc = "cubietech cubieboard (Cortex-A8)"; | 23 | + (config_all.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? \ |
39 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a8"); | 24 | + ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + \ |
40 | mc->init = cubieboard_init; | 25 | (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \ |
41 | mc->block_default_type = IF_IDE; | 26 | (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \ |
42 | mc->units_per_default_bus = 1; | 27 | ['arm-cpu-features', |
43 | -- | 28 | -- |
44 | 2.20.1 | 29 | 2.34.1 |
45 | |||
46 | diff view generated by jsdifflib |