1 | First ARM pullreq of the 2.10 cycle... | 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 | 4 | ||
6 | The following changes since commit 64c8ed97cceabac4fafe17fca8d88ef08183f439: | 5 | are available in the Git repository at: |
7 | 6 | ||
8 | Open 2.10 development tree (2017-04-20 15:42:31 +0100) | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230216 |
9 | 8 | ||
10 | are available in the git repository at: | 9 | for you to fetch changes up to caf01d6a435d9f4a95aeae2f9fc6cb8b889b1fb8: |
11 | 10 | ||
12 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20170420 | 11 | tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG (2023-02-16 16:28:53 +0000) |
13 | |||
14 | for you to fetch changes up to f4e8e4edda875cab9df91dc4ae9767f7cb1f50aa: | ||
15 | |||
16 | arm: Remove workarounds for old M-profile exception return implementation (2017-04-20 17:39:17 +0100) | ||
17 | 12 | ||
18 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
19 | target-arm queue: | 14 | target-arm queue: |
20 | * implement M profile exception return properly | 15 | * Some mostly M-profile-related code cleanups |
21 | * cadence GEM: fix multiqueue handling bugs | 16 | * avocado: Retire the boot_linux.py AArch64 TCG tests |
22 | * pxa2xx.c: QOMify a device | 17 | * hw/arm/smmuv3: Add GBPA register |
23 | * arm/kvm: Remove trailing newlines from error_report() | 18 | * arm/virt: don't try to spell out the accelerator |
24 | * stellaris: Don't hw_error() on bad register accesses | 19 | * hw/arm: Attach PSPI module to NPCM7XX SoC |
25 | * Add assertion about FSC format for syndrome registers | 20 | * Some cleanup/refactoring patches aiming towards |
26 | * Move excnames[] array into arm_log_exceptions() | 21 | allowing building Arm targets without CONFIG_TCG |
27 | * exynos: minor code cleanups | ||
28 | * hw/arm/boot: take Linux/arm64 TEXT_OFFSET header field into account | ||
29 | * Fix APSR writes via M profile MSR | ||
30 | 22 | ||
31 | ---------------------------------------------------------------- | 23 | ---------------------------------------------------------------- |
32 | Alistair Francis (5): | 24 | Alex Bennée (1): |
33 | cadence_gem: Read the correct queue descriptor | 25 | tests/avocado: retire the Aarch64 TCG tests from boot_linux.py |
34 | cadence_gem: Correct the multi-queue can rx logic | ||
35 | cadence_gem: Correct the interupt logic | ||
36 | cadence_gem: Make the revision a property | ||
37 | xlnx-zynqmp: Set the Cadence GEM revision | ||
38 | 26 | ||
39 | Ard Biesheuvel (1): | 27 | Claudio Fontana (3): |
40 | hw/arm/boot: take Linux/arm64 TEXT_OFFSET header field into account | 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() | ||
41 | 31 | ||
42 | Ishani Chugh (1): | 32 | Cornelia Huck (1): |
43 | arm/kvm: Remove trailing newlines from error_report() | 33 | arm/virt: don't try to spell out the accelerator |
44 | 34 | ||
45 | Krzysztof Kozlowski (3): | 35 | Fabiano Rosas (7): |
46 | hw/arm/exynos: Convert fprintf to qemu_log_mask/error_report | 36 | target/arm: Move PC alignment check |
47 | hw/char/exynos4210_uart: Constify static array and few arguments | 37 | target/arm: Move cpregs code out of cpu.h |
48 | hw/misc/exynos4210_pmu: Reorder local variables for readability | 38 | tests/avocado: Skip tests that require a missing accelerator |
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 | ||
49 | 43 | ||
50 | Peter Maydell (13): | 44 | Hao Wu (3): |
51 | target/arm: Add missing entries to excnames[] for log strings | 45 | MAINTAINERS: Add myself to maintainers and remove Havard |
52 | arm: Move excnames[] array into arm_log_exceptions() | 46 | hw/ssi: Add Nuvoton PSPI Module |
53 | target/arm: Add assertion about FSC format for syndrome registers | 47 | hw/arm: Attach PSPI module to NPCM7XX SoC |
54 | stellaris: Don't hw_error() on bad register accesses | ||
55 | arm: Don't implement BXJ on M-profile CPUs | ||
56 | arm: Thumb shift operations should not permit interworking branches | ||
57 | arm: Factor out "generate right kind of step exception" | ||
58 | arm: Move gen_set_condexec() and gen_set_pc_im() up in the file | ||
59 | arm: Move condition-failed codepath generation out of if() | ||
60 | arm: Abstract out "are we singlestepping" test to utility function | ||
61 | arm: Track M profile handler mode state in TB flags | ||
62 | arm: Implement M profile exception return properly | ||
63 | arm: Remove workarounds for old M-profile exception return implementation | ||
64 | 48 | ||
65 | Suramya Shah (1): | 49 | Jean-Philippe Brucker (2): |
66 | hw/arm: Qomify pxa2xx.c | 50 | hw/arm/smmu-common: Support 64-bit addresses |
51 | hw/arm/smmu-common: Fix TTB1 handling | ||
67 | 52 | ||
68 | include/hw/net/cadence_gem.h | 1 + | 53 | Mostafa Saleh (1): |
69 | target/arm/cpu.h | 10 +++ | 54 | hw/arm/smmuv3: Add GBPA register |
70 | target/arm/internals.h | 21 ----- | ||
71 | target/arm/translate.h | 5 ++ | ||
72 | hw/arm/boot.c | 64 ++++++++++++--- | ||
73 | hw/arm/exynos4_boards.c | 7 +- | ||
74 | hw/arm/pxa2xx.c | 14 ++-- | ||
75 | hw/arm/stellaris.c | 60 ++++++++------ | ||
76 | hw/arm/xlnx-zynqmp.c | 6 +- | ||
77 | hw/char/exynos4210_uart.c | 8 +- | ||
78 | hw/misc/exynos4210_pmu.c | 4 +- | ||
79 | hw/net/cadence_gem.c | 45 +++++++---- | ||
80 | hw/timer/exynos4210_mct.c | 6 +- | ||
81 | hw/timer/exynos4210_pwm.c | 13 ++-- | ||
82 | hw/timer/exynos4210_rtc.c | 19 ++--- | ||
83 | target/arm/cpu.c | 43 +--------- | ||
84 | target/arm/helper.c | 19 +++++ | ||
85 | target/arm/kvm64.c | 4 +- | ||
86 | target/arm/op_helper.c | 23 ++++-- | ||
87 | target/arm/translate.c | 181 +++++++++++++++++++++++++++++-------------- | ||
88 | 20 files changed, 341 insertions(+), 212 deletions(-) | ||
89 | 55 | ||
56 | Philippe Mathieu-Daudé (12): | ||
57 | hw/intc/armv7m_nvic: Use OBJECT_DECLARE_SIMPLE_TYPE() macro | ||
58 | target/arm: Simplify arm_v7m_mmu_idx_for_secstate() for user emulation | ||
59 | target/arm: Reduce arm_v7m_mmu_idx_[all/for_secstate_and_priv]() scope | ||
60 | target/arm: Constify ID_PFR1 on user emulation | ||
61 | target/arm: Convert CPUARMState::eabi to boolean | ||
62 | target/arm: Avoid resetting CPUARMState::eabi field | ||
63 | target/arm: Restrict CPUARMState::gicv3state to sysemu | ||
64 | target/arm: Restrict CPUARMState::arm_boot_info to sysemu | ||
65 | target/arm: Restrict CPUARMState::nvic to sysemu | ||
66 | target/arm: Store CPUARMState::nvic as NVICState* | ||
67 | target/arm: Declare CPU <-> NVIC helpers in 'hw/intc/armv7m_nvic.h' | ||
68 | hw/arm: Add missing XLNX_ZYNQMP_ARM -> USB_DWC3 Kconfig dependency | ||
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 | On M profile, return from exceptions happen when code in Handler mode | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | executes one of the following function call return instructions: | ||
3 | * POP or LDM which loads the PC | ||
4 | * LDR to PC | ||
5 | * BX register | ||
6 | and the new PC value is 0xFFxxxxxx. | ||
7 | 2 | ||
8 | QEMU tries to implement this by not treating the instruction | 3 | Manually convert to OBJECT_DECLARE_SIMPLE_TYPE() macro, |
9 | specially but then catching the attempt to execute from the magic | 4 | similarly to automatic conversion from commit 8063396bf3 |
10 | address value. This is not ideal, because: | 5 | ("Use OBJECT_DECLARE_SIMPLE_TYPE when possible"). |
11 | * there are guest visible differences from the architecturally | ||
12 | specified behaviour (for instance jumping to 0xFFxxxxxx via a | ||
13 | different instruction should not cause an exception return but it | ||
14 | will in the QEMU implementation) | ||
15 | * we have to account for it in various places (like refusing to take | ||
16 | an interrupt if the PC is at a magic value, and making sure that | ||
17 | the MPU doesn't deny execution at the magic value addresses) | ||
18 | 6 | ||
19 | Drop these hacks, and instead implement exception return the way the | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
20 | architecture specifies -- by having the relevant instructions check | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
21 | for the magic value and raise the 'do an exception return' QEMU | 9 | Message-id: 20230206223502.25122-2-philmd@linaro.org |
22 | internal exception immediately. | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | ||
12 | include/hw/intc/armv7m_nvic.h | 5 +---- | ||
13 | 1 file changed, 1 insertion(+), 4 deletions(-) | ||
23 | 14 | ||
24 | The effect on the generated code is minor: | 15 | diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h |
25 | |||
26 | bx lr, old code (and new code for Thread mode): | ||
27 | TCG: | ||
28 | mov_i32 tmp5,r14 | ||
29 | movi_i32 tmp6,$0xfffffffffffffffe | ||
30 | and_i32 pc,tmp5,tmp6 | ||
31 | movi_i32 tmp6,$0x1 | ||
32 | and_i32 tmp5,tmp5,tmp6 | ||
33 | st_i32 tmp5,env,$0x218 | ||
34 | exit_tb $0x0 | ||
35 | set_label $L0 | ||
36 | exit_tb $0x7f2aabd61993 | ||
37 | x86_64 generated code: | ||
38 | 0x7f2aabe87019: mov %ebx,%ebp | ||
39 | 0x7f2aabe8701b: and $0xfffffffffffffffe,%ebp | ||
40 | 0x7f2aabe8701e: mov %ebp,0x3c(%r14) | ||
41 | 0x7f2aabe87022: and $0x1,%ebx | ||
42 | 0x7f2aabe87025: mov %ebx,0x218(%r14) | ||
43 | 0x7f2aabe8702c: xor %eax,%eax | ||
44 | 0x7f2aabe8702e: jmpq 0x7f2aabe7c016 | ||
45 | |||
46 | bx lr, new code when in Handler mode: | ||
47 | TCG: | ||
48 | mov_i32 tmp5,r14 | ||
49 | movi_i32 tmp6,$0xfffffffffffffffe | ||
50 | and_i32 pc,tmp5,tmp6 | ||
51 | movi_i32 tmp6,$0x1 | ||
52 | and_i32 tmp5,tmp5,tmp6 | ||
53 | st_i32 tmp5,env,$0x218 | ||
54 | movi_i32 tmp5,$0xffffffffff000000 | ||
55 | brcond_i32 pc,tmp5,geu,$L1 | ||
56 | exit_tb $0x0 | ||
57 | set_label $L1 | ||
58 | movi_i32 tmp5,$0x8 | ||
59 | call exception_internal,$0x0,$0,env,tmp5 | ||
60 | x86_64 generated code: | ||
61 | 0x7fe8fa1264e3: mov %ebp,%ebx | ||
62 | 0x7fe8fa1264e5: and $0xfffffffffffffffe,%ebx | ||
63 | 0x7fe8fa1264e8: mov %ebx,0x3c(%r14) | ||
64 | 0x7fe8fa1264ec: and $0x1,%ebp | ||
65 | 0x7fe8fa1264ef: mov %ebp,0x218(%r14) | ||
66 | 0x7fe8fa1264f6: cmp $0xff000000,%ebx | ||
67 | 0x7fe8fa1264fc: jae 0x7fe8fa126509 | ||
68 | 0x7fe8fa126502: xor %eax,%eax | ||
69 | 0x7fe8fa126504: jmpq 0x7fe8fa122016 | ||
70 | 0x7fe8fa126509: mov %r14,%rdi | ||
71 | 0x7fe8fa12650c: mov $0x8,%esi | ||
72 | 0x7fe8fa126511: mov $0x56095dbeccf5,%r10 | ||
73 | 0x7fe8fa12651b: callq *%r10 | ||
74 | |||
75 | which is a difference of one cmp/branch-not-taken. This will | ||
76 | be lost in the noise of having to exit generated code and | ||
77 | look up the next TB anyway. | ||
78 | |||
79 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
80 | Reviewed-by: Richard Henderson <rth@twiddle.net> | ||
81 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
82 | Message-id: 1491844419-12485-9-git-send-email-peter.maydell@linaro.org | ||
83 | --- | ||
84 | target/arm/translate.h | 4 +++ | ||
85 | target/arm/translate.c | 66 +++++++++++++++++++++++++++++++++++++++++++++----- | ||
86 | 2 files changed, 64 insertions(+), 6 deletions(-) | ||
87 | |||
88 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
89 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
90 | --- a/target/arm/translate.h | 17 | --- a/include/hw/intc/armv7m_nvic.h |
91 | +++ b/target/arm/translate.h | 18 | +++ b/include/hw/intc/armv7m_nvic.h |
92 | @@ -XXX,XX +XXX,XX @@ static void disas_set_insn_syndrome(DisasContext *s, uint32_t syn) | 19 | @@ -XXX,XX +XXX,XX @@ |
93 | #define DISAS_HVC 8 | 20 | #include "qom/object.h" |
94 | #define DISAS_SMC 9 | 21 | |
95 | #define DISAS_YIELD 10 | 22 | #define TYPE_NVIC "armv7m_nvic" |
96 | +/* M profile branch which might be an exception return (and so needs | 23 | - |
97 | + * custom end-of-TB code) | 24 | -typedef struct NVICState NVICState; |
98 | + */ | 25 | -DECLARE_INSTANCE_CHECKER(NVICState, NVIC, |
99 | +#define DISAS_BX_EXCRET 11 | 26 | - TYPE_NVIC) |
100 | 27 | +OBJECT_DECLARE_SIMPLE_TYPE(NVICState, NVIC) | |
101 | #ifdef TARGET_AARCH64 | 28 | |
102 | void a64_translate_init(void); | 29 | /* Highest permitted number of exceptions (architectural limit) */ |
103 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 30 | #define NVIC_MAX_VECTORS 512 |
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/target/arm/translate.c | ||
106 | +++ b/target/arm/translate.c | ||
107 | @@ -XXX,XX +XXX,XX @@ static inline void gen_bx(DisasContext *s, TCGv_i32 var) | ||
108 | store_cpu_field(var, thumb); | ||
109 | } | ||
110 | |||
111 | +/* Set PC and Thumb state from var. var is marked as dead. | ||
112 | + * For M-profile CPUs, include logic to detect exception-return | ||
113 | + * branches and handle them. This is needed for Thumb POP/LDM to PC, LDR to PC, | ||
114 | + * and BX reg, and no others, and happens only for code in Handler mode. | ||
115 | + */ | ||
116 | +static inline void gen_bx_excret(DisasContext *s, TCGv_i32 var) | ||
117 | +{ | ||
118 | + /* Generate the same code here as for a simple bx, but flag via | ||
119 | + * s->is_jmp that we need to do the rest of the work later. | ||
120 | + */ | ||
121 | + gen_bx(s, var); | ||
122 | + if (s->v7m_handler_mode && arm_dc_feature(s, ARM_FEATURE_M)) { | ||
123 | + s->is_jmp = DISAS_BX_EXCRET; | ||
124 | + } | ||
125 | +} | ||
126 | + | ||
127 | +static inline void gen_bx_excret_final_code(DisasContext *s) | ||
128 | +{ | ||
129 | + /* Generate the code to finish possible exception return and end the TB */ | ||
130 | + TCGLabel *excret_label = gen_new_label(); | ||
131 | + | ||
132 | + /* Is the new PC value in the magic range indicating exception return? */ | ||
133 | + tcg_gen_brcondi_i32(TCG_COND_GEU, cpu_R[15], 0xff000000, excret_label); | ||
134 | + /* No: end the TB as we would for a DISAS_JMP */ | ||
135 | + if (is_singlestepping(s)) { | ||
136 | + gen_singlestep_exception(s); | ||
137 | + } else { | ||
138 | + tcg_gen_exit_tb(0); | ||
139 | + } | ||
140 | + gen_set_label(excret_label); | ||
141 | + /* Yes: this is an exception return. | ||
142 | + * At this point in runtime env->regs[15] and env->thumb will hold | ||
143 | + * the exception-return magic number, which do_v7m_exception_exit() | ||
144 | + * will read. Nothing else will be able to see those values because | ||
145 | + * the cpu-exec main loop guarantees that we will always go straight | ||
146 | + * from raising the exception to the exception-handling code. | ||
147 | + * | ||
148 | + * gen_ss_advance(s) does nothing on M profile currently but | ||
149 | + * calling it is conceptually the right thing as we have executed | ||
150 | + * this instruction (compare SWI, HVC, SMC handling). | ||
151 | + */ | ||
152 | + gen_ss_advance(s); | ||
153 | + gen_exception_internal(EXCP_EXCEPTION_EXIT); | ||
154 | +} | ||
155 | + | ||
156 | /* Variant of store_reg which uses branch&exchange logic when storing | ||
157 | to r15 in ARM architecture v7 and above. The source must be a temporary | ||
158 | and will be marked as dead. */ | ||
159 | @@ -XXX,XX +XXX,XX @@ static inline void store_reg_bx(DisasContext *s, int reg, TCGv_i32 var) | ||
160 | static inline void store_reg_from_load(DisasContext *s, int reg, TCGv_i32 var) | ||
161 | { | ||
162 | if (reg == 15 && ENABLE_ARCH_5) { | ||
163 | - gen_bx(s, var); | ||
164 | + gen_bx_excret(s, var); | ||
165 | } else { | ||
166 | store_reg(s, reg, var); | ||
167 | } | ||
168 | @@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw | ||
169 | tmp = tcg_temp_new_i32(); | ||
170 | gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
171 | if (i == 15) { | ||
172 | - gen_bx(s, tmp); | ||
173 | + gen_bx_excret(s, tmp); | ||
174 | } else if (i == rn) { | ||
175 | loaded_var = tmp; | ||
176 | loaded_base = 1; | ||
177 | @@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw | ||
178 | goto illegal_op; | ||
179 | } | ||
180 | if (rs == 15) { | ||
181 | - gen_bx(s, tmp); | ||
182 | + gen_bx_excret(s, tmp); | ||
183 | } else { | ||
184 | store_reg(s, rs, tmp); | ||
185 | } | ||
186 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) | ||
187 | tmp2 = tcg_temp_new_i32(); | ||
188 | tcg_gen_movi_i32(tmp2, val); | ||
189 | store_reg(s, 14, tmp2); | ||
190 | + gen_bx(s, tmp); | ||
191 | + } else { | ||
192 | + /* Only BX works as exception-return, not BLX */ | ||
193 | + gen_bx_excret(s, tmp); | ||
194 | } | ||
195 | - /* already thumb, no need to check */ | ||
196 | - gen_bx(s, tmp); | ||
197 | break; | ||
198 | } | ||
199 | break; | ||
200 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | ||
201 | instruction was a conditional branch or trap, and the PC has | ||
202 | already been written. */ | ||
203 | gen_set_condexec(dc); | ||
204 | - if (unlikely(is_singlestepping(dc))) { | ||
205 | + if (dc->is_jmp == DISAS_BX_EXCRET) { | ||
206 | + /* Exception return branches need some special case code at the | ||
207 | + * end of the TB, which is complex enough that it has to | ||
208 | + * handle the single-step vs not and the condition-failed | ||
209 | + * insn codepath itself. | ||
210 | + */ | ||
211 | + gen_bx_excret_final_code(dc); | ||
212 | + } else if (unlikely(is_singlestepping(dc))) { | ||
213 | /* Unconditional and "condition passed" instruction codepath. */ | ||
214 | switch (dc->is_jmp) { | ||
215 | case DISAS_SWI: | ||
216 | -- | 31 | -- |
217 | 2.7.4 | 32 | 2.34.1 |
218 | 33 | ||
219 | 34 | diff view generated by jsdifflib |
1 | We now test for "are we singlestepping" in several places and | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | it's not a trivial check because we need to care about both | ||
3 | architectural singlestep and QEMU gdbstub singlestep. We're | ||
4 | also about to add another place that needs to make this check, | ||
5 | so pull the condition out into a function. | ||
6 | 2 | ||
3 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20230206223502.25122-3-philmd@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <rth@twiddle.net> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 1491844419-12485-7-git-send-email-peter.maydell@linaro.org | ||
11 | --- | 8 | --- |
12 | target/arm/translate.c | 20 +++++++++++++++----- | 9 | target/arm/m_helper.c | 11 ++++++++--- |
13 | 1 file changed, 15 insertions(+), 5 deletions(-) | 10 | 1 file changed, 8 insertions(+), 3 deletions(-) |
14 | 11 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 12 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 14 | --- a/target/arm/m_helper.c |
18 | +++ b/target/arm/translate.c | 15 | +++ b/target/arm/m_helper.c |
19 | @@ -XXX,XX +XXX,XX @@ static void gen_singlestep_exception(DisasContext *s) | 16 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) |
20 | } | 17 | return 0; |
21 | } | 18 | } |
22 | 19 | ||
23 | +static inline bool is_singlestepping(DisasContext *s) | 20 | -#else |
21 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | ||
24 | +{ | 22 | +{ |
25 | + /* Return true if we are singlestepping either because of | 23 | + return ARMMMUIdx_MUser; |
26 | + * architectural singlestep or QEMU gdbstub singlestep. This does | ||
27 | + * not include the command line '-singlestep' mode which is rather | ||
28 | + * misnamed as it only means "one instruction per TB" and doesn't | ||
29 | + * affect the code we generate. | ||
30 | + */ | ||
31 | + return s->singlestep_enabled || s->ss_active; | ||
32 | +} | 24 | +} |
33 | + | 25 | + |
34 | static void gen_smul_dual(TCGv_i32 a, TCGv_i32 b) | 26 | +#else /* !CONFIG_USER_ONLY */ |
27 | |||
28 | /* | ||
29 | * What kind of stack write are we doing? This affects how exceptions | ||
30 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
31 | return tt_resp; | ||
32 | } | ||
33 | |||
34 | -#endif /* !CONFIG_USER_ONLY */ | ||
35 | - | ||
36 | ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | ||
37 | bool secstate, bool priv, bool negpri) | ||
35 | { | 38 | { |
36 | TCGv_i32 tmp1 = tcg_temp_new_i32(); | 39 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) |
37 | @@ -XXX,XX +XXX,XX @@ static inline void gen_goto_tb(DisasContext *s, int n, target_ulong dest) | 40 | |
38 | 41 | return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); | |
39 | static inline void gen_jmp (DisasContext *s, uint32_t dest) | 42 | } |
40 | { | 43 | + |
41 | - if (unlikely(s->singlestep_enabled || s->ss_active)) { | 44 | +#endif /* !CONFIG_USER_ONLY */ |
42 | + if (unlikely(is_singlestepping(s))) { | ||
43 | /* An indirect jump so that we still trigger the debug exception. */ | ||
44 | if (s->thumb) | ||
45 | dest |= 1; | ||
46 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | ||
47 | ((dc->pc >= next_page_start - 3) && insn_crosses_page(env, dc)); | ||
48 | |||
49 | } while (!dc->is_jmp && !tcg_op_buf_full() && | ||
50 | - !cs->singlestep_enabled && | ||
51 | + !is_singlestepping(dc) && | ||
52 | !singlestep && | ||
53 | - !dc->ss_active && | ||
54 | !end_of_page && | ||
55 | num_insns < max_insns); | ||
56 | |||
57 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | ||
58 | instruction was a conditional branch or trap, and the PC has | ||
59 | already been written. */ | ||
60 | gen_set_condexec(dc); | ||
61 | - if (unlikely(cs->singlestep_enabled || dc->ss_active)) { | ||
62 | + if (unlikely(is_singlestepping(dc))) { | ||
63 | /* Unconditional and "condition passed" instruction codepath. */ | ||
64 | switch (dc->is_jmp) { | ||
65 | case DISAS_SWI: | ||
66 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | ||
67 | /* "Condition failed" instruction codepath for the branch/trap insn */ | ||
68 | gen_set_label(dc->condlabel); | ||
69 | gen_set_condexec(dc); | ||
70 | - if (unlikely(cs->singlestep_enabled || dc->ss_active)) { | ||
71 | + if (unlikely(is_singlestepping(dc))) { | ||
72 | gen_set_pc_im(dc, dc->pc); | ||
73 | gen_singlestep_exception(dc); | ||
74 | } else { | ||
75 | -- | 45 | -- |
76 | 2.7.4 | 46 | 2.34.1 |
77 | 47 | ||
78 | 48 | diff view generated by jsdifflib |
1 | Move the utility routines gen_set_condexec() and gen_set_pc_im() | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | up in the file, as we will want to use them from a function | ||
3 | placed earlier in the file than their current location. | ||
4 | 2 | ||
3 | arm_v7m_mmu_idx_all() and arm_v7m_mmu_idx_for_secstate_and_priv() | ||
4 | are only used for system emulation in m_helper.c. | ||
5 | Move the definitions to avoid prototype forward declarations. | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230206223502.25122-4-philmd@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <rth@twiddle.net> | ||
8 | Message-id: 1491844419-12485-5-git-send-email-peter.maydell@linaro.org | ||
9 | --- | 11 | --- |
10 | target/arm/translate.c | 31 +++++++++++++++---------------- | 12 | target/arm/internals.h | 14 -------- |
11 | 1 file changed, 15 insertions(+), 16 deletions(-) | 13 | target/arm/m_helper.c | 74 +++++++++++++++++++++--------------------- |
14 | 2 files changed, 37 insertions(+), 51 deletions(-) | ||
12 | 15 | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 16 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 18 | --- a/target/arm/internals.h |
16 | +++ b/target/arm/translate.c | 19 | +++ b/target/arm/internals.h |
17 | @@ -XXX,XX +XXX,XX @@ static const uint8_t table_logic_cc[16] = { | 20 | @@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx core_to_aa64_mmu_idx(int mmu_idx) |
18 | 1, /* mvn */ | 21 | |
19 | }; | 22 | int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx); |
20 | 23 | ||
21 | +static inline void gen_set_condexec(DisasContext *s) | 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) | ||
22 | +{ | 51 | +{ |
23 | + if (s->condexec_mask) { | 52 | + ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; |
24 | + uint32_t val = (s->condexec_cond << 4) | (s->condexec_mask >> 1); | 53 | + |
25 | + TCGv_i32 tmp = tcg_temp_new_i32(); | 54 | + if (priv) { |
26 | + tcg_gen_movi_i32(tmp, val); | 55 | + mmu_idx |= ARM_MMU_IDX_M_PRIV; |
27 | + store_cpu_field(tmp, condexec_bits); | ||
28 | + } | 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; | ||
29 | +} | 67 | +} |
30 | + | 68 | + |
31 | +static inline void gen_set_pc_im(DisasContext *s, target_ulong val) | 69 | +static ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, |
70 | + bool secstate, bool priv) | ||
32 | +{ | 71 | +{ |
33 | + tcg_gen_movi_i32(cpu_R[15], val); | 72 | + bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate); |
73 | + | ||
74 | + return arm_v7m_mmu_idx_all(env, secstate, priv, negpri); | ||
34 | +} | 75 | +} |
35 | + | 76 | + |
36 | /* Set PC and Thumb state from an immediate address. */ | 77 | +/* Return the MMU index for a v7M CPU in the specified security state */ |
37 | static inline void gen_bx_im(DisasContext *s, uint32_t addr) | 78 | +ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) |
38 | { | 79 | +{ |
39 | @@ -XXX,XX +XXX,XX @@ DO_GEN_ST(8, MO_UB) | 80 | + bool priv = arm_v7m_is_handler_mode(env) || |
40 | DO_GEN_ST(16, MO_UW) | 81 | + !(env->v7m.control[secstate] & 1); |
41 | DO_GEN_ST(32, MO_UL) | 82 | + |
42 | 83 | + return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); | |
43 | -static inline void gen_set_pc_im(DisasContext *s, target_ulong val) | 84 | +} |
85 | + | ||
86 | /* | ||
87 | * What kind of stack write are we doing? This affects how exceptions | ||
88 | * generated during the stacking are treated. | ||
89 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op) | ||
90 | return tt_resp; | ||
91 | } | ||
92 | |||
93 | -ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env, | ||
94 | - bool secstate, bool priv, bool negpri) | ||
44 | -{ | 95 | -{ |
45 | - tcg_gen_movi_i32(cpu_R[15], val); | 96 | - ARMMMUIdx mmu_idx = ARM_MMU_IDX_M; |
97 | - | ||
98 | - if (priv) { | ||
99 | - mmu_idx |= ARM_MMU_IDX_M_PRIV; | ||
100 | - } | ||
101 | - | ||
102 | - if (negpri) { | ||
103 | - mmu_idx |= ARM_MMU_IDX_M_NEGPRI; | ||
104 | - } | ||
105 | - | ||
106 | - if (secstate) { | ||
107 | - mmu_idx |= ARM_MMU_IDX_M_S; | ||
108 | - } | ||
109 | - | ||
110 | - return mmu_idx; | ||
46 | -} | 111 | -} |
47 | - | 112 | - |
48 | static inline void gen_hvc(DisasContext *s, int imm16) | 113 | -ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, |
49 | { | 114 | - bool secstate, bool priv) |
50 | /* The pre HVC helper handles cases when HVC gets trapped | ||
51 | @@ -XXX,XX +XXX,XX @@ static inline void gen_smc(DisasContext *s) | ||
52 | s->is_jmp = DISAS_SMC; | ||
53 | } | ||
54 | |||
55 | -static inline void | ||
56 | -gen_set_condexec (DisasContext *s) | ||
57 | -{ | 115 | -{ |
58 | - if (s->condexec_mask) { | 116 | - bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate); |
59 | - uint32_t val = (s->condexec_cond << 4) | (s->condexec_mask >> 1); | 117 | - |
60 | - TCGv_i32 tmp = tcg_temp_new_i32(); | 118 | - return arm_v7m_mmu_idx_all(env, secstate, priv, negpri); |
61 | - tcg_gen_movi_i32(tmp, val); | ||
62 | - store_cpu_field(tmp, condexec_bits); | ||
63 | - } | ||
64 | -} | 119 | -} |
65 | - | 120 | - |
66 | static void gen_exception_internal_insn(DisasContext *s, int offset, int excp) | 121 | -/* Return the MMU index for a v7M CPU in the specified security state */ |
67 | { | 122 | -ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) |
68 | gen_set_condexec(s); | 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 */ | ||
69 | -- | 131 | -- |
70 | 2.7.4 | 132 | 2.34.1 |
71 | 133 | ||
72 | 134 | diff view generated by jsdifflib |
1 | Current recommended style is to log a guest error on bad register | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | accesses, not kill the whole system with hw_error(). Change the | ||
3 | hw_error() calls to log as LOG_GUEST_ERROR or LOG_UNIMP or use | ||
4 | g_assert_not_reached() as appropriate. | ||
5 | 2 | ||
3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Message-id: 20230206223502.25122-5-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 1491486314-25823-1-git-send-email-peter.maydell@linaro.org | ||
9 | --- | 7 | --- |
10 | hw/arm/stellaris.c | 60 +++++++++++++++++++++++++++++++++--------------------- | 8 | target/arm/helper.c | 12 ++++++++++-- |
11 | 1 file changed, 37 insertions(+), 23 deletions(-) | 9 | 1 file changed, 10 insertions(+), 2 deletions(-) |
12 | 10 | ||
13 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | 11 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/stellaris.c | 13 | --- a/target/arm/helper.c |
16 | +++ b/hw/arm/stellaris.c | 14 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ static void gptm_reload(gptm_state *s, int n, int reset) | 15 | @@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu) |
18 | } else if (s->mode[n] == 0xa) { | ||
19 | /* PWM mode. Not implemented. */ | ||
20 | } else { | ||
21 | - hw_error("TODO: 16-bit timer mode 0x%x\n", s->mode[n]); | ||
22 | + qemu_log_mask(LOG_UNIMP, | ||
23 | + "GPTM: 16-bit timer mode unimplemented: 0x%x\n", | ||
24 | + s->mode[n]); | ||
25 | + return; | ||
26 | } | ||
27 | s->tick[n] = tick; | ||
28 | timer_mod(s->timer[n], tick); | ||
29 | @@ -XXX,XX +XXX,XX @@ static void gptm_tick(void *opaque) | ||
30 | } else if (s->mode[n] == 0xa) { | ||
31 | /* PWM mode. Not implemented. */ | ||
32 | } else { | ||
33 | - hw_error("TODO: 16-bit timer mode 0x%x\n", s->mode[n]); | ||
34 | + qemu_log_mask(LOG_UNIMP, | ||
35 | + "GPTM: 16-bit timer mode unimplemented: 0x%x\n", | ||
36 | + s->mode[n]); | ||
37 | } | ||
38 | gptm_update_irq(s); | ||
39 | } | ||
40 | @@ -XXX,XX +XXX,XX @@ static void gptm_write(void *opaque, hwaddr offset, | ||
41 | s->match_prescale[0] = value; | ||
42 | break; | ||
43 | default: | ||
44 | - hw_error("gptm_write: Bad offset 0x%x\n", (int)offset); | ||
45 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
46 | + "GPTM: read at bad offset 0x%x\n", (int)offset); | ||
47 | } | ||
48 | gptm_update_irq(s); | ||
49 | } | ||
50 | @@ -XXX,XX +XXX,XX @@ static int ssys_board_class(const ssys_state *s) | ||
51 | } | ||
52 | /* for unknown classes, fall through */ | ||
53 | default: | ||
54 | - hw_error("ssys_board_class: Unknown class 0x%08x\n", did0); | ||
55 | + /* This can only happen if the hardwired constant did0 value | ||
56 | + * in this board's stellaris_board_info struct is wrong. | ||
57 | + */ | ||
58 | + g_assert_not_reached(); | ||
59 | } | 16 | } |
60 | } | 17 | } |
61 | 18 | ||
62 | @@ -XXX,XX +XXX,XX @@ static uint64_t ssys_read(void *opaque, hwaddr offset, | 19 | +#ifndef CONFIG_USER_ONLY |
63 | case DID0_CLASS_SANDSTORM: | 20 | /* |
64 | return pllcfg_sandstorm[xtal]; | 21 | * We don't know until after realize whether there's a GICv3 |
65 | default: | 22 | * attached, and that is what registers the gicv3 sysregs. |
66 | - hw_error("ssys_read: Unhandled class for PLLCFG read.\n"); | 23 | @@ -XXX,XX +XXX,XX @@ static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri) |
67 | - return 0; | 24 | return pfr1; |
68 | + g_assert_not_reached(); | ||
69 | } | ||
70 | } | ||
71 | case 0x070: /* RCC2 */ | ||
72 | @@ -XXX,XX +XXX,XX @@ static uint64_t ssys_read(void *opaque, hwaddr offset, | ||
73 | case 0x1e4: /* USER1 */ | ||
74 | return s->user1; | ||
75 | default: | ||
76 | - hw_error("ssys_read: Bad offset 0x%x\n", (int)offset); | ||
77 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
78 | + "SSYS: read at bad offset 0x%x\n", (int)offset); | ||
79 | return 0; | ||
80 | } | ||
81 | } | 25 | } |
82 | @@ -XXX,XX +XXX,XX @@ static void ssys_write(void *opaque, hwaddr offset, | 26 | |
83 | s->ldoarst = value; | 27 | -#ifndef CONFIG_USER_ONLY |
84 | break; | 28 | static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) |
85 | default: | 29 | { |
86 | - hw_error("ssys_write: Bad offset 0x%x\n", (int)offset); | 30 | ARMCPU *cpu = env_archcpu(env); |
87 | + qemu_log_mask(LOG_GUEST_ERROR, | 31 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
88 | + "SSYS: write at bad offset 0x%x\n", (int)offset); | 32 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 1, |
89 | } | 33 | .access = PL1_R, .type = ARM_CP_NO_RAW, |
90 | ssys_update(s); | 34 | .accessfn = access_aa32_tid3, |
91 | } | 35 | +#ifdef CONFIG_USER_ONLY |
92 | @@ -XXX,XX +XXX,XX @@ static uint64_t stellaris_i2c_read(void *opaque, hwaddr offset, | 36 | + .type = ARM_CP_CONST, |
93 | case 0x20: /* MCR */ | 37 | + .resetvalue = cpu->isar.id_pfr1, |
94 | return s->mcr; | 38 | +#else |
95 | default: | 39 | + .type = ARM_CP_NO_RAW, |
96 | - hw_error("strllaris_i2c_read: Bad offset 0x%x\n", (int)offset); | 40 | + .accessfn = access_aa32_tid3, |
97 | + qemu_log_mask(LOG_GUEST_ERROR, | 41 | .readfn = id_pfr1_read, |
98 | + "stellaris_i2c: read at bad offset 0x%x\n", (int)offset); | 42 | - .writefn = arm_cp_write_ignore }, |
99 | return 0; | 43 | + .writefn = arm_cp_write_ignore |
100 | } | 44 | +#endif |
101 | } | 45 | + }, |
102 | @@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_write(void *opaque, hwaddr offset, | 46 | { .name = "ID_DFR0", .state = ARM_CP_STATE_BOTH, |
103 | s->mris &= ~value; | 47 | .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 2, |
104 | break; | 48 | .access = PL1_R, .type = ARM_CP_CONST, |
105 | case 0x20: /* MCR */ | ||
106 | - if (value & 1) | ||
107 | - hw_error( | ||
108 | - "stellaris_i2c_write: Loopback not implemented\n"); | ||
109 | - if (value & 0x20) | ||
110 | - hw_error( | ||
111 | - "stellaris_i2c_write: Slave mode not implemented\n"); | ||
112 | + if (value & 1) { | ||
113 | + qemu_log_mask(LOG_UNIMP, "stellaris_i2c: Loopback not implemented"); | ||
114 | + } | ||
115 | + if (value & 0x20) { | ||
116 | + qemu_log_mask(LOG_UNIMP, | ||
117 | + "stellaris_i2c: Slave mode not implemented"); | ||
118 | + } | ||
119 | s->mcr = value & 0x31; | ||
120 | break; | ||
121 | default: | ||
122 | - hw_error("stellaris_i2c_write: Bad offset 0x%x\n", | ||
123 | - (int)offset); | ||
124 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
125 | + "stellaris_i2c: write at bad offset 0x%x\n", (int)offset); | ||
126 | } | ||
127 | stellaris_i2c_update(s); | ||
128 | } | ||
129 | @@ -XXX,XX +XXX,XX @@ static uint64_t stellaris_adc_read(void *opaque, hwaddr offset, | ||
130 | case 0x30: /* SAC */ | ||
131 | return s->sac; | ||
132 | default: | ||
133 | - hw_error("strllaris_adc_read: Bad offset 0x%x\n", | ||
134 | - (int)offset); | ||
135 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
136 | + "stellaris_adc: read at bad offset 0x%x\n", (int)offset); | ||
137 | return 0; | ||
138 | } | ||
139 | } | ||
140 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_write(void *opaque, hwaddr offset, | ||
141 | return; | ||
142 | case 0x04: /* SSCTL */ | ||
143 | if (value != 6) { | ||
144 | - hw_error("ADC: Unimplemented sequence %" PRIx64 "\n", | ||
145 | - value); | ||
146 | + qemu_log_mask(LOG_UNIMP, | ||
147 | + "ADC: Unimplemented sequence %" PRIx64 "\n", | ||
148 | + value); | ||
149 | } | ||
150 | s->ssctl[n] = value; | ||
151 | return; | ||
152 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_write(void *opaque, hwaddr offset, | ||
153 | s->sspri = value; | ||
154 | break; | ||
155 | case 0x28: /* PSSI */ | ||
156 | - hw_error("Not implemented: ADC sample initiate\n"); | ||
157 | + qemu_log_mask(LOG_UNIMP, "ADC: sample initiate unimplemented"); | ||
158 | break; | ||
159 | case 0x30: /* SAC */ | ||
160 | s->sac = value; | ||
161 | break; | ||
162 | default: | ||
163 | - hw_error("stellaris_adc_write: Bad offset 0x%x\n", (int)offset); | ||
164 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
165 | + "stellaris_adc: write at bad offset 0x%x\n", (int)offset); | ||
166 | } | ||
167 | stellaris_adc_update(s); | ||
168 | } | ||
169 | -- | 49 | -- |
170 | 2.7.4 | 50 | 2.34.1 |
171 | 51 | ||
172 | 52 | diff view generated by jsdifflib |
1 | For M profile exception-return handling we'd like to generate different | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | code for some instructions depending on whether we are in Handler | ||
3 | mode or Thread mode. This isn't the same as "are we privileged | ||
4 | or user", so we need an extra bit in the TB flags to distinguish. | ||
5 | 2 | ||
3 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20230206223502.25122-6-philmd@linaro.org | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <rth@twiddle.net> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Message-id: 1491844419-12485-8-git-send-email-peter.maydell@linaro.org | ||
10 | --- | 8 | --- |
11 | target/arm/cpu.h | 9 +++++++++ | 9 | linux-user/user-internals.h | 2 +- |
12 | target/arm/translate.h | 1 + | 10 | target/arm/cpu.h | 2 +- |
13 | target/arm/translate.c | 1 + | 11 | linux-user/arm/cpu_loop.c | 4 ++-- |
14 | 3 files changed, 11 insertions(+) | 12 | 3 files changed, 4 insertions(+), 4 deletions(-) |
15 | 13 | ||
14 | diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/linux-user/user-internals.h | ||
17 | +++ b/linux-user/user-internals.h | ||
18 | @@ -XXX,XX +XXX,XX @@ void print_termios(void *arg); | ||
19 | #ifdef TARGET_ARM | ||
20 | static inline int regpairs_aligned(CPUArchState *cpu_env, int num) | ||
21 | { | ||
22 | - return cpu_env->eabi == 1; | ||
23 | + return cpu_env->eabi; | ||
24 | } | ||
25 | #elif defined(TARGET_MIPS) && defined(TARGET_ABI_MIPSO32) | ||
26 | static inline int regpairs_aligned(CPUArchState *cpu_env, int num) { return 1; } | ||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 27 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
17 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 29 | --- a/target/arm/cpu.h |
19 | +++ b/target/arm/cpu.h | 30 | +++ b/target/arm/cpu.h |
20 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) | 31 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
21 | #define ARM_TBFLAG_NS_MASK (1 << ARM_TBFLAG_NS_SHIFT) | 32 | |
22 | #define ARM_TBFLAG_BE_DATA_SHIFT 20 | 33 | #if defined(CONFIG_USER_ONLY) |
23 | #define ARM_TBFLAG_BE_DATA_MASK (1 << ARM_TBFLAG_BE_DATA_SHIFT) | 34 | /* For usermode syscall translation. */ |
24 | +/* For M profile only, Handler (ie not Thread) mode */ | 35 | - int eabi; |
25 | +#define ARM_TBFLAG_HANDLER_SHIFT 21 | 36 | + bool eabi; |
26 | +#define ARM_TBFLAG_HANDLER_MASK (1 << ARM_TBFLAG_HANDLER_SHIFT) | 37 | #endif |
27 | 38 | ||
28 | /* Bit usage when in AArch64 state */ | 39 | struct CPUBreakpoint *cpu_breakpoint[16]; |
29 | #define ARM_TBFLAG_TBI0_SHIFT 0 /* TBI0 for EL0/1 or TBI for EL2/3 */ | 40 | diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c |
30 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) | ||
31 | (((F) & ARM_TBFLAG_NS_MASK) >> ARM_TBFLAG_NS_SHIFT) | ||
32 | #define ARM_TBFLAG_BE_DATA(F) \ | ||
33 | (((F) & ARM_TBFLAG_BE_DATA_MASK) >> ARM_TBFLAG_BE_DATA_SHIFT) | ||
34 | +#define ARM_TBFLAG_HANDLER(F) \ | ||
35 | + (((F) & ARM_TBFLAG_HANDLER_MASK) >> ARM_TBFLAG_HANDLER_SHIFT) | ||
36 | #define ARM_TBFLAG_TBI0(F) \ | ||
37 | (((F) & ARM_TBFLAG_TBI0_MASK) >> ARM_TBFLAG_TBI0_SHIFT) | ||
38 | #define ARM_TBFLAG_TBI1(F) \ | ||
39 | @@ -XXX,XX +XXX,XX @@ static inline void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | ||
40 | } | ||
41 | *flags |= fp_exception_el(env) << ARM_TBFLAG_FPEXC_EL_SHIFT; | ||
42 | |||
43 | + if (env->v7m.exception != 0) { | ||
44 | + *flags |= ARM_TBFLAG_HANDLER_MASK; | ||
45 | + } | ||
46 | + | ||
47 | *cs_base = 0; | ||
48 | } | ||
49 | |||
50 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
51 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
52 | --- a/target/arm/translate.h | 42 | --- a/linux-user/arm/cpu_loop.c |
53 | +++ b/target/arm/translate.h | 43 | +++ b/linux-user/arm/cpu_loop.c |
54 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | 44 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) |
55 | bool vfp_enabled; /* FP enabled via FPSCR.EN */ | 45 | break; |
56 | int vec_len; | 46 | case EXCP_SWI: |
57 | int vec_stride; | 47 | { |
58 | + bool v7m_handler_mode; | 48 | - env->eabi = 1; |
59 | /* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI | 49 | + env->eabi = true; |
60 | * so that top level loop can generate correct syndrome information. | 50 | /* system call */ |
61 | */ | 51 | if (env->thumb) { |
62 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 52 | /* Thumb is always EABI style with syscall number in r7 */ |
63 | index XXXXXXX..XXXXXXX 100644 | 53 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) |
64 | --- a/target/arm/translate.c | 54 | * > 0xfffff and are handled below as out-of-range. |
65 | +++ b/target/arm/translate.c | 55 | */ |
66 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | 56 | n ^= ARM_SYSCALL_BASE; |
67 | dc->vec_len = ARM_TBFLAG_VECLEN(tb->flags); | 57 | - env->eabi = 0; |
68 | dc->vec_stride = ARM_TBFLAG_VECSTRIDE(tb->flags); | 58 | + env->eabi = false; |
69 | dc->c15_cpar = ARM_TBFLAG_XSCALE_CPAR(tb->flags); | 59 | } |
70 | + dc->v7m_handler_mode = ARM_TBFLAG_HANDLER(tb->flags); | 60 | } |
71 | dc->cp_regs = cpu->cp_regs; | ||
72 | dc->features = env->features; | ||
73 | 61 | ||
74 | -- | 62 | -- |
75 | 2.7.4 | 63 | 2.34.1 |
76 | 64 | ||
77 | 65 | diff view generated by jsdifflib |
1 | For M-profile CPUs, the BXJ instruction does not exist at all, and | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | the encoding should always UNDEF. We were accidentally implementing | ||
3 | it to behave like A-profile BXJ; correct the error. | ||
4 | 2 | ||
3 | Although the 'eabi' field is only used in user emulation where | ||
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. | ||
6 | |||
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 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <rth@twiddle.net> | ||
8 | Message-id: 1491844419-12485-2-git-send-email-peter.maydell@linaro.org | ||
9 | --- | 11 | --- |
10 | target/arm/translate.c | 7 ++++++- | 12 | target/arm/cpu.h | 9 ++++----- |
11 | 1 file changed, 6 insertions(+), 1 deletion(-) | 13 | 1 file changed, 4 insertions(+), 5 deletions(-) |
12 | 14 | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.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/target/arm/translate.c | 17 | --- a/target/arm/cpu.h |
16 | +++ b/target/arm/translate.c | 18 | +++ b/target/arm/cpu.h |
17 | @@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw | 19 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
18 | } | 20 | ARMVectorReg zarray[ARM_MAX_VQ * 16]; |
19 | break; | 21 | #endif |
20 | case 4: /* bxj */ | 22 | |
21 | - /* Trivial implementation equivalent to bx. */ | 23 | -#if defined(CONFIG_USER_ONLY) |
22 | + /* Trivial implementation equivalent to bx. | 24 | - /* For usermode syscall translation. */ |
23 | + * This instruction doesn't exist at all for M-profile. | 25 | - bool eabi; |
24 | + */ | 26 | -#endif |
25 | + if (arm_dc_feature(s, ARM_FEATURE_M)) { | 27 | - |
26 | + goto illegal_op; | 28 | struct CPUBreakpoint *cpu_breakpoint[16]; |
27 | + } | 29 | struct CPUWatchpoint *cpu_watchpoint[16]; |
28 | tmp = load_reg(s, rn); | 30 | |
29 | gen_bx(s, tmp); | 31 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
30 | break; | 32 | const struct arm_boot_info *boot_info; |
33 | /* Store GICv3CPUState to access from this struct */ | ||
34 | void *gicv3state; | ||
35 | +#if defined(CONFIG_USER_ONLY) | ||
36 | + /* For usermode syscall translation. */ | ||
37 | + bool eabi; | ||
38 | +#endif /* CONFIG_USER_ONLY */ | ||
39 | |||
40 | #ifdef TARGET_TAGGED_ADDRESSES | ||
41 | /* Linux syscall tagged address support */ | ||
31 | -- | 42 | -- |
32 | 2.7.4 | 43 | 2.34.1 |
33 | 44 | ||
34 | 45 | diff view generated by jsdifflib |
1 | The excnames[] array is defined in internals.h because we used | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | to use it from two different source files for handling logging | ||
3 | of AArch32 and AArch64 exception entry. Refactoring means that | ||
4 | it's now used only in arm_log_exception() in helper.c, so move | ||
5 | the array into that function. | ||
6 | 2 | ||
7 | Suggested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Message-id: 20230206223502.25122-8-philmd@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Message-id: 1491821097-5647-1-git-send-email-peter.maydell@linaro.org | ||
11 | --- | 7 | --- |
12 | target/arm/cpu.h | 2 +- | 8 | target/arm/cpu.h | 3 ++- |
13 | target/arm/internals.h | 23 ----------------------- | 9 | 1 file changed, 2 insertions(+), 1 deletion(-) |
14 | target/arm/helper.c | 19 +++++++++++++++++++ | ||
15 | 3 files changed, 20 insertions(+), 24 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 @@ | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
22 | #define EXCP_SEMIHOST 16 /* semihosting call */ | 16 | |
23 | #define EXCP_NOCP 17 /* v7M NOCP UsageFault */ | 17 | void *nvic; |
24 | #define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */ | 18 | const struct arm_boot_info *boot_info; |
25 | -/* NB: new EXCP_ defines should be added to the excnames[] array too */ | 19 | +#if !defined(CONFIG_USER_ONLY) |
26 | +/* NB: add new EXCP_ defines to the array in arm_log_exception() too */ | 20 | /* Store GICv3CPUState to access from this struct */ |
27 | 21 | void *gicv3state; | |
28 | #define ARMV7M_EXCP_RESET 1 | 22 | -#if defined(CONFIG_USER_ONLY) |
29 | #define ARMV7M_EXCP_NMI 2 | 23 | +#else /* CONFIG_USER_ONLY */ |
30 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 24 | /* For usermode syscall translation. */ |
31 | index XXXXXXX..XXXXXXX 100644 | 25 | bool eabi; |
32 | --- a/target/arm/internals.h | 26 | #endif /* CONFIG_USER_ONLY */ |
33 | +++ b/target/arm/internals.h | ||
34 | @@ -XXX,XX +XXX,XX @@ static inline bool excp_is_internal(int excp) | ||
35 | || excp == EXCP_SEMIHOST; | ||
36 | } | ||
37 | |||
38 | -/* Exception names for debug logging; note that not all of these | ||
39 | - * precisely correspond to architectural exceptions. | ||
40 | - */ | ||
41 | -static const char * const excnames[] = { | ||
42 | - [EXCP_UDEF] = "Undefined Instruction", | ||
43 | - [EXCP_SWI] = "SVC", | ||
44 | - [EXCP_PREFETCH_ABORT] = "Prefetch Abort", | ||
45 | - [EXCP_DATA_ABORT] = "Data Abort", | ||
46 | - [EXCP_IRQ] = "IRQ", | ||
47 | - [EXCP_FIQ] = "FIQ", | ||
48 | - [EXCP_BKPT] = "Breakpoint", | ||
49 | - [EXCP_EXCEPTION_EXIT] = "QEMU v7M exception exit", | ||
50 | - [EXCP_KERNEL_TRAP] = "QEMU intercept of kernel commpage", | ||
51 | - [EXCP_HVC] = "Hypervisor Call", | ||
52 | - [EXCP_HYP_TRAP] = "Hypervisor Trap", | ||
53 | - [EXCP_SMC] = "Secure Monitor Call", | ||
54 | - [EXCP_VIRQ] = "Virtual IRQ", | ||
55 | - [EXCP_VFIQ] = "Virtual FIQ", | ||
56 | - [EXCP_SEMIHOST] = "Semihosting call", | ||
57 | - [EXCP_NOCP] = "v7M NOCP UsageFault", | ||
58 | - [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | ||
59 | -}; | ||
60 | - | ||
61 | /* Scale factor for generic timers, ie number of ns per tick. | ||
62 | * This gives a 62.5MHz timer. | ||
63 | */ | ||
64 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/helper.c | ||
67 | +++ b/target/arm/helper.c | ||
68 | @@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx) | ||
69 | { | ||
70 | if (qemu_loglevel_mask(CPU_LOG_INT)) { | ||
71 | const char *exc = NULL; | ||
72 | + static const char * const excnames[] = { | ||
73 | + [EXCP_UDEF] = "Undefined Instruction", | ||
74 | + [EXCP_SWI] = "SVC", | ||
75 | + [EXCP_PREFETCH_ABORT] = "Prefetch Abort", | ||
76 | + [EXCP_DATA_ABORT] = "Data Abort", | ||
77 | + [EXCP_IRQ] = "IRQ", | ||
78 | + [EXCP_FIQ] = "FIQ", | ||
79 | + [EXCP_BKPT] = "Breakpoint", | ||
80 | + [EXCP_EXCEPTION_EXIT] = "QEMU v7M exception exit", | ||
81 | + [EXCP_KERNEL_TRAP] = "QEMU intercept of kernel commpage", | ||
82 | + [EXCP_HVC] = "Hypervisor Call", | ||
83 | + [EXCP_HYP_TRAP] = "Hypervisor Trap", | ||
84 | + [EXCP_SMC] = "Secure Monitor Call", | ||
85 | + [EXCP_VIRQ] = "Virtual IRQ", | ||
86 | + [EXCP_VFIQ] = "Virtual FIQ", | ||
87 | + [EXCP_SEMIHOST] = "Semihosting call", | ||
88 | + [EXCP_NOCP] = "v7M NOCP UsageFault", | ||
89 | + [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | ||
90 | + }; | ||
91 | |||
92 | if (idx >= 0 && idx < ARRAY_SIZE(excnames)) { | ||
93 | exc = excnames[idx]; | ||
94 | -- | 27 | -- |
95 | 2.7.4 | 28 | 2.34.1 |
96 | 29 | ||
97 | 30 | diff view generated by jsdifflib |
1 | In Thumb mode, the only instructions which can cause an interworking | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | branch by writing the PC are BLX, BX, BXJ, LDR, POP and LDM. Unlike | ||
3 | ARM mode, data processing instructions which target the PC do not | ||
4 | cause interworking branches. | ||
5 | 2 | ||
6 | When we added support for doing interworking branches on writes to | 3 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | PC from data processing instructions in commit 21aeb3430ce7ba, we | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | accidentally changed a Thumb instruction to have interworking | 5 | Message-id: 20230206223502.25122-9-philmd@linaro.org |
9 | branch behaviour for writes to PC. (MOV, MOVS register-shifted | ||
10 | register, encoding T2; this is the standard encoding for | ||
11 | LSL/LSR/ASR/ROR (register).) | ||
12 | |||
13 | For this encoding, behaviour with Rd == R15 is specified as | ||
14 | UNPREDICTABLE, so allowing an interworking branch is within | ||
15 | spec, but it's confusing and differs from our handling of this | ||
16 | class of UNPREDICTABLE for other Thumb ALU operations. Make | ||
17 | it perform a simple (non-interworking) branch like the others. | ||
18 | |||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Richard Henderson <rth@twiddle.net> | ||
21 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
22 | Message-id: 1491844419-12485-3-git-send-email-peter.maydell@linaro.org | ||
23 | --- | 7 | --- |
24 | target/arm/translate.c | 2 +- | 8 | target/arm/cpu.h | 2 +- |
25 | 1 file changed, 1 insertion(+), 1 deletion(-) | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
26 | 10 | ||
27 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 11 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
28 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/translate.c | 13 | --- a/target/arm/cpu.h |
30 | +++ b/target/arm/translate.c | 14 | +++ b/target/arm/cpu.h |
31 | @@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
32 | gen_arm_shift_reg(tmp, op, tmp2, logic_cc); | 16 | } sau; |
33 | if (logic_cc) | 17 | |
34 | gen_logic_CC(tmp); | 18 | void *nvic; |
35 | - store_reg_bx(s, rd, tmp); | 19 | - const struct arm_boot_info *boot_info; |
36 | + store_reg(s, rd, tmp); | 20 | #if !defined(CONFIG_USER_ONLY) |
37 | break; | 21 | + const struct arm_boot_info *boot_info; |
38 | case 1: /* Sign/zero extend. */ | 22 | /* Store GICv3CPUState to access from this struct */ |
39 | op = (insn >> 20) & 7; | 23 | void *gicv3state; |
24 | #else /* CONFIG_USER_ONLY */ | ||
40 | -- | 25 | -- |
41 | 2.7.4 | 26 | 2.34.1 |
42 | 27 | ||
43 | 28 | diff view generated by jsdifflib |
1 | Recent changes have added new EXCP_ values to ARM but forgot | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | to update the excnames[] array which is used to provide | ||
3 | human-readable strings when printing information about the | ||
4 | exception for debug logging. Add the missing entries, and | ||
5 | add a comment to the list of #defines to help avoid the mistake | ||
6 | being repeated in future. | ||
7 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20230206223502.25122-10-philmd@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
10 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
11 | Message-id: 1491486340-25988-1-git-send-email-peter.maydell@linaro.org | ||
12 | --- | 7 | --- |
13 | target/arm/cpu.h | 1 + | 8 | target/arm/cpu.h | 2 +- |
14 | target/arm/internals.h | 2 ++ | 9 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 2 files changed, 3 insertions(+) | ||
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 @@ | 15 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
22 | #define EXCP_SEMIHOST 16 /* semihosting call */ | 16 | uint32_t ctrl; |
23 | #define EXCP_NOCP 17 /* v7M NOCP UsageFault */ | 17 | } sau; |
24 | #define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */ | 18 | |
25 | +/* NB: new EXCP_ defines should be added to the excnames[] array too */ | 19 | - void *nvic; |
26 | 20 | #if !defined(CONFIG_USER_ONLY) | |
27 | #define ARMV7M_EXCP_RESET 1 | 21 | + void *nvic; |
28 | #define ARMV7M_EXCP_NMI 2 | 22 | const struct arm_boot_info *boot_info; |
29 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 23 | /* Store GICv3CPUState to access from this struct */ |
30 | index XXXXXXX..XXXXXXX 100644 | 24 | void *gicv3state; |
31 | --- a/target/arm/internals.h | ||
32 | +++ b/target/arm/internals.h | ||
33 | @@ -XXX,XX +XXX,XX @@ static const char * const excnames[] = { | ||
34 | [EXCP_VIRQ] = "Virtual IRQ", | ||
35 | [EXCP_VFIQ] = "Virtual FIQ", | ||
36 | [EXCP_SEMIHOST] = "Semihosting call", | ||
37 | + [EXCP_NOCP] = "v7M NOCP UsageFault", | ||
38 | + [EXCP_INVSTATE] = "v7M INVSTATE UsageFault", | ||
39 | }; | ||
40 | |||
41 | /* Scale factor for generic timers, ie number of ns per tick. | ||
42 | -- | 25 | -- |
43 | 2.7.4 | 26 | 2.34.1 |
44 | 27 | ||
45 | 28 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | |
2 | |||
3 | There is no point in using a void pointer to access the NVIC. | ||
4 | Use the real type to avoid casting it while debugging. | ||
5 | |||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20230206223502.25122-11-philmd@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 46 ++++++++++++++++++++++--------------------- | ||
12 | hw/intc/armv7m_nvic.c | 38 ++++++++++++----------------------- | ||
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); | ||
307 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
308 | index XXXXXXX..XXXXXXX 100644 | ||
309 | --- a/target/arm/cpu.c | ||
310 | +++ b/target/arm/cpu.c | ||
311 | @@ -XXX,XX +XXX,XX @@ | ||
312 | #if !defined(CONFIG_USER_ONLY) | ||
313 | #include "hw/loader.h" | ||
314 | #include "hw/boards.h" | ||
315 | +#include "hw/intc/armv7m_nvic.h" | ||
316 | #endif | ||
317 | #include "sysemu/tcg.h" | ||
318 | #include "sysemu/qtest.h" | ||
319 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
320 | index XXXXXXX..XXXXXXX 100644 | ||
321 | --- a/target/arm/m_helper.c | ||
322 | +++ b/target/arm/m_helper.c | ||
323 | @@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr, | ||
324 | * that we will need later in order to do lazy FP reg stacking. | ||
325 | */ | ||
326 | bool is_secure = env->v7m.secure; | ||
327 | - void *nvic = env->nvic; | ||
328 | + NVICState *nvic = env->nvic; | ||
329 | /* | ||
330 | * Some bits are unbanked and live always in fpccr[M_REG_S]; some bits | ||
331 | * are banked and we want to update the bit in the bank for the | ||
332 | -- | ||
333 | 2.34.1 | ||
334 | |||
335 | diff view generated by jsdifflib |
1 | Now that we've rewritten M-profile exception return so that the magic | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | PC values are not visible to other parts of QEMU, we can delete the | 2 | |
3 | special casing of them elsewhere. | 3 | While dozens of files include "cpu.h", only 3 files require |
4 | 4 | these NVIC helper declarations. | |
5 | |||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Message-id: 20230206223502.25122-12-philmd@linaro.org | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <rth@twiddle.net> | ||
8 | Message-id: 1491844419-12485-10-git-send-email-peter.maydell@linaro.org | ||
9 | --- | 10 | --- |
10 | target/arm/cpu.c | 43 ++----------------------------------------- | 11 | include/hw/intc/armv7m_nvic.h | 123 ++++++++++++++++++++++++++++++++++ |
11 | target/arm/translate.c | 8 -------- | 12 | target/arm/cpu.h | 123 ---------------------------------- |
12 | 2 files changed, 2 insertions(+), 49 deletions(-) | 13 | target/arm/cpu.c | 4 +- |
13 | 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(). | ||
14 | 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 |
15 | index XXXXXXX..XXXXXXX 100644 | 285 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.c | 286 | --- a/target/arm/cpu.c |
17 | +++ b/target/arm/cpu.c | 287 | +++ b/target/arm/cpu.c |
18 | @@ -XXX,XX +XXX,XX @@ bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | 288 | @@ -XXX,XX +XXX,XX @@ |
19 | } | 289 | #if !defined(CONFIG_USER_ONLY) |
20 | 290 | #include "hw/loader.h" | |
21 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | 291 | #include "hw/boards.h" |
22 | -static void arm_v7m_unassigned_access(CPUState *cpu, hwaddr addr, | 292 | +#ifdef CONFIG_TCG |
23 | - bool is_write, bool is_exec, int opaque, | 293 | #include "hw/intc/armv7m_nvic.h" |
24 | - unsigned size) | 294 | -#endif |
25 | -{ | 295 | +#endif /* CONFIG_TCG */ |
26 | - ARMCPU *arm = ARM_CPU(cpu); | 296 | +#endif /* !CONFIG_USER_ONLY */ |
27 | - CPUARMState *env = &arm->env; | 297 | #include "sysemu/tcg.h" |
28 | - | 298 | #include "sysemu/qtest.h" |
29 | - /* ARMv7-M interrupt return works by loading a magic value into the PC. | 299 | #include "sysemu/hw_accel.h" |
30 | - * On real hardware the load causes the return to occur. The qemu | 300 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c |
31 | - * implementation performs the jump normally, then does the exception | 301 | index XXXXXXX..XXXXXXX 100644 |
32 | - * return by throwing a special exception when when the CPU tries to | 302 | --- a/target/arm/cpu_tcg.c |
33 | - * execute code at the magic address. | 303 | +++ b/target/arm/cpu_tcg.c |
34 | - */ | 304 | @@ -XXX,XX +XXX,XX @@ |
35 | - if (env->v7m.exception != 0 && addr >= 0xfffffff0 && is_exec) { | 305 | #include "hw/boards.h" |
36 | - cpu->exception_index = EXCP_EXCEPTION_EXIT; | ||
37 | - cpu_loop_exit(cpu); | ||
38 | - } | ||
39 | - | ||
40 | - /* In real hardware an attempt to access parts of the address space | ||
41 | - * with nothing there will usually cause an external abort. | ||
42 | - * However our QEMU board models are often missing device models where | ||
43 | - * the guest can boot anyway with the default read-as-zero/writes-ignored | ||
44 | - * behaviour that you get without a QEMU unassigned_access hook. | ||
45 | - * So just return here to retain that default behaviour. | ||
46 | - */ | ||
47 | -} | ||
48 | - | ||
49 | static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
50 | { | ||
51 | CPUClass *cc = CPU_GET_CLASS(cs); | ||
52 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
53 | CPUARMState *env = &cpu->env; | ||
54 | bool ret = false; | ||
55 | |||
56 | - /* ARMv7-M interrupt return works by loading a magic value | ||
57 | - * into the PC. On real hardware the load causes the | ||
58 | - * return to occur. The qemu implementation performs the | ||
59 | - * jump normally, then does the exception return when the | ||
60 | - * CPU tries to execute code at the magic address. | ||
61 | - * This will cause the magic PC value to be pushed to | ||
62 | - * the stack if an interrupt occurred at the wrong time. | ||
63 | - * We avoid this by disabling interrupts when | ||
64 | - * pc contains a magic address. | ||
65 | - * | ||
66 | - * ARMv7-M interrupt masking works differently than -A or -R. | ||
67 | + /* ARMv7-M interrupt masking works differently than -A or -R. | ||
68 | * There is no FIQ/IRQ distinction. Instead of I and F bits | ||
69 | * masking FIQ and IRQ interrupts, an exception is taken only | ||
70 | * if it is higher priority than the current execution priority | ||
71 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | ||
72 | * currently active exception). | ||
73 | */ | ||
74 | if (interrupt_request & CPU_INTERRUPT_HARD | ||
75 | - && (armv7m_nvic_can_take_pending_exception(env->nvic)) | ||
76 | - && (env->regs[15] < 0xfffffff0)) { | ||
77 | + && (armv7m_nvic_can_take_pending_exception(env->nvic))) { | ||
78 | cs->exception_index = EXCP_IRQ; | ||
79 | cc->do_interrupt(cs); | ||
80 | ret = true; | ||
81 | @@ -XXX,XX +XXX,XX @@ static void arm_v7m_class_init(ObjectClass *oc, void *data) | ||
82 | cc->do_interrupt = arm_v7m_cpu_do_interrupt; | ||
83 | #endif | 306 | #endif |
84 | 307 | #include "cpregs.h" | |
85 | - cc->do_unassigned_access = arm_v7m_unassigned_access; | 308 | +#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) |
86 | cc->cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt; | 309 | +#include "hw/intc/armv7m_nvic.h" |
87 | } | 310 | +#endif |
88 | 311 | ||
89 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 312 | |
90 | index XXXXXXX..XXXXXXX 100644 | 313 | /* Share AArch32 -cpu max features with AArch64. */ |
91 | --- a/target/arm/translate.c | 314 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c |
92 | +++ b/target/arm/translate.c | 315 | index XXXXXXX..XXXXXXX 100644 |
93 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | 316 | --- a/target/arm/m_helper.c |
94 | dc->is_jmp = DISAS_EXC; | 317 | +++ b/target/arm/m_helper.c |
95 | break; | 318 | @@ -XXX,XX +XXX,XX @@ |
96 | } | 319 | #include "exec/cpu_ldst.h" |
97 | -#else | 320 | #include "semihosting/common-semi.h" |
98 | - if (arm_dc_feature(dc, ARM_FEATURE_M)) { | ||
99 | - /* Branches to the magic exception-return addresses should | ||
100 | - * already have been caught via the arm_v7m_unassigned_access hook, | ||
101 | - * and never get here. | ||
102 | - */ | ||
103 | - assert(dc->pc < 0xfffffff0); | ||
104 | - } | ||
105 | #endif | 321 | #endif |
106 | 322 | +#if !defined(CONFIG_USER_ONLY) | |
107 | if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { | 323 | +#include "hw/intc/armv7m_nvic.h" |
324 | +#endif | ||
325 | |||
326 | static void v7m_msr_xpsr(CPUARMState *env, uint32_t mask, | ||
327 | uint32_t reg, uint32_t val) | ||
108 | -- | 328 | -- |
109 | 2.7.4 | 329 | 2.34.1 |
110 | 330 | ||
111 | 331 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Alex Bennée <alex.bennee@linaro.org> | |
2 | |||
3 | The two TCG tests for GICv2 and GICv3 are very heavy weight distros | ||
4 | that take a long time to boot up, especially for an --enable-debug | ||
5 | build. The total code coverage they give is: | ||
6 | |||
7 | Overall coverage rate: | ||
8 | lines......: 11.2% (59584 of 530123 lines) | ||
9 | functions..: 15.0% (7436 of 49443 functions) | ||
10 | branches...: 6.3% (19273 of 303933 branches) | ||
11 | |||
12 | We already get pretty close to that with the machine_aarch64_virt | ||
13 | tests which only does one full boot (~120s vs ~600s) of alpine. We | ||
14 | expand the kernel+initrd boot (~8s) to test both GICs and also add an | ||
15 | RNG device and a block device to generate a few IRQs and exercise the | ||
16 | storage layer. With that we get to a coverage of: | ||
17 | |||
18 | Overall coverage rate: | ||
19 | lines......: 11.0% (58121 of 530123 lines) | ||
20 | functions..: 14.9% (7343 of 49443 functions) | ||
21 | branches...: 6.0% (18269 of 303933 branches) | ||
22 | |||
23 | which I feel is close enough given the massive time saving. If we want | ||
24 | to target any more sub-systems we can use lighter weight more directed | ||
25 | tests. | ||
26 | |||
27 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
28 | Reviewed-by: Fabiano Rosas <farosas@suse.de> | ||
29 | Acked-by: Richard Henderson <richard.henderson@linaro.org> | ||
30 | Message-id: 20230203181632.2919715-1-alex.bennee@linaro.org | ||
31 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
33 | --- | ||
34 | tests/avocado/boot_linux.py | 48 ++++---------------- | ||
35 | tests/avocado/machine_aarch64_virt.py | 63 ++++++++++++++++++++++++--- | ||
36 | 2 files changed, 65 insertions(+), 46 deletions(-) | ||
37 | |||
38 | diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/tests/avocado/boot_linux.py | ||
41 | +++ b/tests/avocado/boot_linux.py | ||
42 | @@ -XXX,XX +XXX,XX @@ def test_pc_q35_kvm(self): | ||
43 | self.launch_and_wait(set_up_ssh_connection=False) | ||
44 | |||
45 | |||
46 | -# For Aarch64 we only boot KVM tests in CI as the TCG tests are very | ||
47 | -# heavyweight. There are lighter weight distros which we use in the | ||
48 | -# machine_aarch64_virt.py tests. | ||
49 | +# For Aarch64 we only boot KVM tests in CI as booting the current | ||
50 | +# Fedora OS in TCG tests is very heavyweight. There are lighter weight | ||
51 | +# distros which we use in the machine_aarch64_virt.py tests. | ||
52 | class BootLinuxAarch64(LinuxTest): | ||
53 | """ | ||
54 | :avocado: tags=arch:aarch64 | ||
55 | :avocado: tags=machine:virt | ||
56 | - :avocado: tags=machine:gic-version=2 | ||
57 | """ | ||
58 | timeout = 720 | ||
59 | |||
60 | - def add_common_args(self): | ||
61 | - self.vm.add_args('-bios', | ||
62 | - os.path.join(BUILD_DIR, 'pc-bios', | ||
63 | - 'edk2-aarch64-code.fd')) | ||
64 | - self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0') | ||
65 | - self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom') | ||
66 | - | ||
67 | - @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') | ||
68 | - def test_fedora_cloud_tcg_gicv2(self): | ||
69 | - """ | ||
70 | - :avocado: tags=accel:tcg | ||
71 | - :avocado: tags=cpu:max | ||
72 | - :avocado: tags=device:gicv2 | ||
73 | - """ | ||
74 | - self.require_accelerator("tcg") | ||
75 | - self.vm.add_args("-accel", "tcg") | ||
76 | - self.vm.add_args("-cpu", "max,lpa2=off") | ||
77 | - self.vm.add_args("-machine", "virt,gic-version=2") | ||
78 | - self.add_common_args() | ||
79 | - self.launch_and_wait(set_up_ssh_connection=False) | ||
80 | - | ||
81 | - @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') | ||
82 | - def test_fedora_cloud_tcg_gicv3(self): | ||
83 | - """ | ||
84 | - :avocado: tags=accel:tcg | ||
85 | - :avocado: tags=cpu:max | ||
86 | - :avocado: tags=device:gicv3 | ||
87 | - """ | ||
88 | - self.require_accelerator("tcg") | ||
89 | - self.vm.add_args("-accel", "tcg") | ||
90 | - self.vm.add_args("-cpu", "max,lpa2=off") | ||
91 | - self.vm.add_args("-machine", "virt,gic-version=3") | ||
92 | - self.add_common_args() | ||
93 | - self.launch_and_wait(set_up_ssh_connection=False) | ||
94 | - | ||
95 | def test_virt_kvm(self): | ||
96 | """ | ||
97 | :avocado: tags=accel:kvm | ||
98 | @@ -XXX,XX +XXX,XX @@ def test_virt_kvm(self): | ||
99 | self.require_accelerator("kvm") | ||
100 | self.vm.add_args("-accel", "kvm") | ||
101 | self.vm.add_args("-machine", "virt,gic-version=host") | ||
102 | - self.add_common_args() | ||
103 | + self.vm.add_args('-bios', | ||
104 | + os.path.join(BUILD_DIR, 'pc-bios', | ||
105 | + 'edk2-aarch64-code.fd')) | ||
106 | + self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0') | ||
107 | + self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom') | ||
108 | self.launch_and_wait(set_up_ssh_connection=False) | ||
109 | |||
110 | |||
111 | diff --git a/tests/avocado/machine_aarch64_virt.py b/tests/avocado/machine_aarch64_virt.py | ||
112 | index XXXXXXX..XXXXXXX 100644 | ||
113 | --- a/tests/avocado/machine_aarch64_virt.py | ||
114 | +++ b/tests/avocado/machine_aarch64_virt.py | ||
115 | @@ -XXX,XX +XXX,XX @@ | ||
116 | |||
117 | import time | ||
118 | import os | ||
119 | +import logging | ||
120 | |||
121 | from avocado_qemu import QemuSystemTest | ||
122 | from avocado_qemu import wait_for_console_pattern | ||
123 | from avocado_qemu import exec_command | ||
124 | from avocado_qemu import BUILD_DIR | ||
125 | +from avocado.utils import process | ||
126 | +from avocado.utils.path import find_command | ||
127 | |||
128 | class Aarch64VirtMachine(QemuSystemTest): | ||
129 | KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' | ||
130 | @@ -XXX,XX +XXX,XX @@ def test_alpine_virt_tcg_gic_max(self): | ||
131 | self.wait_for_console_pattern('Welcome to Alpine Linux 3.16') | ||
132 | |||
133 | |||
134 | - def test_aarch64_virt(self): | ||
135 | + def common_aarch64_virt(self, machine): | ||
136 | """ | ||
137 | - :avocado: tags=arch:aarch64 | ||
138 | - :avocado: tags=machine:virt | ||
139 | - :avocado: tags=accel:tcg | ||
140 | - :avocado: tags=cpu:max | ||
141 | + Common code to launch basic virt machine with kernel+initrd | ||
142 | + and a scratch disk. | ||
143 | """ | ||
144 | + logger = logging.getLogger('aarch64_virt') | ||
145 | + | ||
146 | kernel_url = ('https://fileserver.linaro.org/s/' | ||
147 | 'z6B2ARM7DQT3HWN/download') | ||
148 | - | ||
149 | kernel_hash = 'ed11daab50c151dde0e1e9c9cb8b2d9bd3215347' | ||
150 | kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) | ||
151 | |||
152 | @@ -XXX,XX +XXX,XX @@ def test_aarch64_virt(self): | ||
153 | 'console=ttyAMA0') | ||
154 | self.require_accelerator("tcg") | ||
155 | self.vm.add_args('-cpu', 'max,pauth-impdef=on', | ||
156 | + '-machine', machine, | ||
157 | '-accel', 'tcg', | ||
158 | '-kernel', kernel_path, | ||
159 | '-append', kernel_command_line) | ||
160 | + | ||
161 | + # A RNG offers an easy way to generate a few IRQs | ||
162 | + self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0') | ||
163 | + self.vm.add_args('-object', | ||
164 | + 'rng-random,id=rng0,filename=/dev/urandom') | ||
165 | + | ||
166 | + # Also add a scratch block device | ||
167 | + logger.info('creating scratch qcow2 image') | ||
168 | + image_path = os.path.join(self.workdir, 'scratch.qcow2') | ||
169 | + qemu_img = os.path.join(BUILD_DIR, 'qemu-img') | ||
170 | + if not os.path.exists(qemu_img): | ||
171 | + qemu_img = find_command('qemu-img', False) | ||
172 | + if qemu_img is False: | ||
173 | + self.cancel('Could not find "qemu-img", which is required to ' | ||
174 | + 'create the temporary qcow2 image') | ||
175 | + cmd = '%s create -f qcow2 %s 8M' % (qemu_img, image_path) | ||
176 | + process.run(cmd) | ||
177 | + | ||
178 | + # Add the device | ||
179 | + self.vm.add_args('-blockdev', | ||
180 | + f"driver=qcow2,file.driver=file,file.filename={image_path},node-name=scratch") | ||
181 | + self.vm.add_args('-device', | ||
182 | + 'virtio-blk-device,drive=scratch') | ||
183 | + | ||
184 | self.vm.launch() | ||
185 | self.wait_for_console_pattern('Welcome to Buildroot') | ||
186 | time.sleep(0.1) | ||
187 | exec_command(self, 'root') | ||
188 | time.sleep(0.1) | ||
189 | + exec_command(self, 'dd if=/dev/hwrng of=/dev/vda bs=512 count=4') | ||
190 | + time.sleep(0.1) | ||
191 | + exec_command(self, 'md5sum /dev/vda') | ||
192 | + time.sleep(0.1) | ||
193 | + exec_command(self, 'cat /proc/interrupts') | ||
194 | + time.sleep(0.1) | ||
195 | exec_command(self, 'cat /proc/self/maps') | ||
196 | time.sleep(0.1) | ||
197 | + | ||
198 | + def test_aarch64_virt_gicv3(self): | ||
199 | + """ | ||
200 | + :avocado: tags=arch:aarch64 | ||
201 | + :avocado: tags=machine:virt | ||
202 | + :avocado: tags=accel:tcg | ||
203 | + :avocado: tags=cpu:max | ||
204 | + """ | ||
205 | + self.common_aarch64_virt("virt,gic_version=3") | ||
206 | + | ||
207 | + def test_aarch64_virt_gicv2(self): | ||
208 | + """ | ||
209 | + :avocado: tags=arch:aarch64 | ||
210 | + :avocado: tags=machine:virt | ||
211 | + :avocado: tags=accel:tcg | ||
212 | + :avocado: tags=cpu:max | ||
213 | + """ | ||
214 | + self.common_aarch64_virt("virt,gic-version=2") | ||
215 | -- | ||
216 | 2.34.1 | ||
217 | |||
218 | diff view generated by jsdifflib |
1 | From: Suramya Shah <shah.suramya@gmail.com> | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Suramya Shah <shah.suramya@gmail.com> | 3 | GBPA register can be used to globally abort all |
4 | Message-id: 20170415180316.2694-1-shah.suramya@gmail.com | 4 | transactions. |
5 | |||
6 | It is described in the SMMU manual in "6.3.14 SMMU_GBPA". | ||
7 | ABORT reset value is IMPLEMENTATION DEFINED, it is chosen to | ||
8 | be zero(Do not abort incoming transactions). | ||
9 | |||
10 | Other fields have default values of Use Incoming. | ||
11 | |||
12 | If UPDATE is not set, the write is ignored. This is the only permitted | ||
13 | behavior in SMMUv3.2 and later.(6.3.14.1 Update procedure) | ||
14 | |||
15 | As this patch adds a new state to the SMMU (GBPA), it is added | ||
16 | in a new subsection for forward migration compatibility. | ||
17 | GBPA is only migrated if its value is different from the reset value. | ||
18 | It does this to be backward migration compatible if SW didn't write | ||
19 | the register. | ||
20 | |||
21 | Signed-off-by: Mostafa Saleh <smostafa@google.com> | ||
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: Peter Maydell <peter.maydell@linaro.org> | 26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 27 | --- |
8 | hw/arm/pxa2xx.c | 14 ++++++-------- | 28 | hw/arm/smmuv3-internal.h | 7 +++++++ |
9 | 1 file changed, 6 insertions(+), 8 deletions(-) | 29 | include/hw/arm/smmuv3.h | 1 + |
30 | hw/arm/smmuv3.c | 43 +++++++++++++++++++++++++++++++++++++++- | ||
31 | 3 files changed, 50 insertions(+), 1 deletion(-) | ||
10 | 32 | ||
11 | diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c | 33 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
12 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/arm/pxa2xx.c | 35 | --- a/hw/arm/smmuv3-internal.h |
14 | +++ b/hw/arm/pxa2xx.c | 36 | +++ b/hw/arm/smmuv3-internal.h |
15 | @@ -XXX,XX +XXX,XX @@ static void pxa2xx_ssp_reset(DeviceState *d) | 37 | @@ -XXX,XX +XXX,XX @@ REG32(CR0ACK, 0x24) |
16 | s->rx_start = s->rx_level = 0; | 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; | ||
17 | } | 72 | } |
18 | 73 | ||
19 | -static int pxa2xx_ssp_init(SysBusDevice *sbd) | 74 | static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr, STE *buf, |
20 | +static void pxa2xx_ssp_init(Object *obj) | 75 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, |
21 | { | 76 | qemu_mutex_lock(&s->mutex); |
22 | - DeviceState *dev = DEVICE(sbd); | 77 | |
23 | - PXA2xxSSPState *s = PXA2XX_SSP(dev); | 78 | if (!smmu_enabled(s)) { |
24 | - | 79 | - status = SMMU_TRANS_DISABLE; |
25 | + DeviceState *dev = DEVICE(obj); | 80 | + if (FIELD_EX32(s->gbpa, GBPA, ABORT)) { |
26 | + PXA2xxSSPState *s = PXA2XX_SSP(obj); | 81 | + status = SMMU_TRANS_ABORT; |
27 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | 82 | + } else { |
28 | sysbus_init_irq(sbd, &s->irq); | 83 | + status = SMMU_TRANS_DISABLE; |
29 | 84 | + } | |
30 | - memory_region_init_io(&s->iomem, OBJECT(s), &pxa2xx_ssp_ops, s, | 85 | goto epilogue; |
31 | + memory_region_init_io(&s->iomem, obj, &pxa2xx_ssp_ops, s, | 86 | } |
32 | "pxa2xx-ssp", 0x1000); | 87 | |
33 | sysbus_init_mmio(sbd, &s->iomem); | 88 | @@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_writel(SMMUv3State *s, hwaddr offset, |
34 | 89 | case A_GERROR_IRQ_CFG2: | |
35 | s->bus = ssi_create_bus(dev, "ssi"); | 90 | s->gerror_irq_cfg2 = data; |
36 | - return 0; | 91 | return MEMTX_OK; |
37 | } | 92 | + case A_GBPA: |
38 | 93 | + /* | |
39 | /* Real-Time Clock */ | 94 | + * If UPDATE is not set, the write is ignored. This is the only |
40 | @@ -XXX,XX +XXX,XX @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size) | 95 | + * permitted behavior in SMMUv3.2 and later. |
41 | 96 | + */ | |
42 | static void pxa2xx_ssp_class_init(ObjectClass *klass, void *data) | 97 | + if (data & R_GBPA_UPDATE_MASK) { |
43 | { | 98 | + /* Ignore update bit as write is synchronous. */ |
44 | - SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass); | 99 | + s->gbpa = data & ~R_GBPA_UPDATE_MASK; |
45 | DeviceClass *dc = DEVICE_CLASS(klass); | 100 | + } |
46 | 101 | + return MEMTX_OK; | |
47 | - sdc->init = pxa2xx_ssp_init; | 102 | case A_STRTAB_BASE: /* 64b */ |
48 | dc->reset = pxa2xx_ssp_reset; | 103 | s->strtab_base = deposit64(s->strtab_base, 0, 32, data); |
49 | dc->vmsd = &vmstate_pxa2xx_ssp; | 104 | return MEMTX_OK; |
50 | } | 105 | @@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_readl(SMMUv3State *s, hwaddr offset, |
51 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo pxa2xx_ssp_info = { | 106 | case A_STATUSR: |
52 | .name = TYPE_PXA2XX_SSP, | 107 | *data = s->statusr; |
53 | .parent = TYPE_SYS_BUS_DEVICE, | 108 | return MEMTX_OK; |
54 | .instance_size = sizeof(PXA2xxSSPState), | 109 | + case A_GBPA: |
55 | + .instance_init = pxa2xx_ssp_init, | 110 | + *data = s->gbpa; |
56 | .class_init = pxa2xx_ssp_class_init, | 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 | }, | ||
57 | }; | 117 | }; |
58 | 118 | ||
119 | +static bool smmuv3_gbpa_needed(void *opaque) | ||
120 | +{ | ||
121 | + SMMUv3State *s = opaque; | ||
122 | + | ||
123 | + /* Only migrate GBPA if it has different reset value. */ | ||
124 | + return s->gbpa != SMMU_GBPA_RESET_VAL; | ||
125 | +} | ||
126 | + | ||
127 | +static const VMStateDescription vmstate_gbpa = { | ||
128 | + .name = "smmuv3/gbpa", | ||
129 | + .version_id = 1, | ||
130 | + .minimum_version_id = 1, | ||
131 | + .needed = smmuv3_gbpa_needed, | ||
132 | + .fields = (VMStateField[]) { | ||
133 | + VMSTATE_UINT32(gbpa, SMMUv3State), | ||
134 | + VMSTATE_END_OF_LIST() | ||
135 | + } | ||
136 | +}; | ||
137 | + | ||
138 | static const VMStateDescription vmstate_smmuv3 = { | ||
139 | .name = "smmuv3", | ||
140 | .version_id = 1, | ||
141 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3 = { | ||
142 | |||
143 | VMSTATE_END_OF_LIST(), | ||
144 | }, | ||
145 | + .subsections = (const VMStateDescription * []) { | ||
146 | + &vmstate_gbpa, | ||
147 | + NULL | ||
148 | + } | ||
149 | }; | ||
150 | |||
151 | static void smmuv3_instance_init(Object *obj) | ||
59 | -- | 152 | -- |
60 | 2.7.4 | 153 | 2.34.1 |
61 | |||
62 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair.francis@xilinx.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> | 3 | Since commit acc0b8b05a when running the ZynqMP ZCU102 board with |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | a QEMU configured using --without-default-devices, we get: |
5 | Message-id: 026dbe01a1d42619eee30ce3f2079741bf04bc73.1491947224.git.alistair.francis@xilinx.com | 5 | |
6 | $ qemu-system-aarch64 -M xlnx-zcu102 | ||
7 | qemu-system-aarch64: missing object type 'usb_dwc3' | ||
8 | Abort trap: 6 | ||
9 | |||
10 | Fix by adding the missing Kconfig dependency. | ||
11 | |||
12 | Fixes: acc0b8b05a ("hw/arm/xlnx-zynqmp: Connect ZynqMP's USB controllers") | ||
13 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
14 | Message-id: 20230216092327.2203-1-philmd@linaro.org | ||
15 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 17 | --- |
8 | hw/arm/xlnx-zynqmp.c | 6 +++++- | 18 | hw/arm/Kconfig | 1 + |
9 | 1 file changed, 5 insertions(+), 1 deletion(-) | 19 | 1 file changed, 1 insertion(+) |
10 | 20 | ||
11 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | 21 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
12 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/arm/xlnx-zynqmp.c | 23 | --- a/hw/arm/Kconfig |
14 | +++ b/hw/arm/xlnx-zynqmp.c | 24 | +++ b/hw/arm/Kconfig |
15 | @@ -XXX,XX +XXX,XX @@ | 25 | @@ -XXX,XX +XXX,XX @@ config XLNX_ZYNQMP_ARM |
16 | #define ARM_PHYS_TIMER_PPI 30 | 26 | select XLNX_CSU_DMA |
17 | #define ARM_VIRT_TIMER_PPI 27 | 27 | select XLNX_ZYNQMP |
18 | 28 | select XLNX_ZDMA | |
19 | +#define GEM_REVISION 0x40070106 | 29 | + select USB_DWC3 |
20 | + | 30 | |
21 | #define GIC_BASE_ADDR 0xf9000000 | 31 | config XLNX_VERSAL |
22 | #define GIC_DIST_ADDR 0xf9010000 | 32 | bool |
23 | #define GIC_CPU_ADDR 0xf9020000 | ||
24 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | ||
25 | qemu_check_nic_model(nd, TYPE_CADENCE_GEM); | ||
26 | qdev_set_nic_properties(DEVICE(&s->gem[i]), nd); | ||
27 | } | ||
28 | + object_property_set_int(OBJECT(&s->gem[i]), GEM_REVISION, "revision", | ||
29 | + &error_abort); | ||
30 | object_property_set_int(OBJECT(&s->gem[i]), 2, "num-priority-queues", | ||
31 | - &error_abort); | ||
32 | + &error_abort); | ||
33 | object_property_set_bool(OBJECT(&s->gem[i]), true, "realized", &err); | ||
34 | if (err) { | ||
35 | error_propagate(errp, err); | ||
36 | -- | 33 | -- |
37 | 2.7.4 | 34 | 2.34.1 |
38 | 35 | ||
39 | 36 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair.francis@xilinx.com> | 1 | From: Cornelia Huck <cohuck@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Correct the buffer descriptor busy logic to work correctly when using | 3 | Just use current_accel_name() directly. |
4 | multiple queues. | ||
5 | 4 | ||
6 | Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> | 5 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> |
7 | Message-id: 8a7e8059984e27d46a276a66299d035a0afd280f.1491947224.git.alistair.francis@xilinx.com | 6 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | 9 | --- |
11 | hw/net/cadence_gem.c | 17 ++++++++++------- | 10 | hw/arm/virt.c | 6 +++--- |
12 | 1 file changed, 10 insertions(+), 7 deletions(-) | 11 | 1 file changed, 3 insertions(+), 3 deletions(-) |
13 | 12 | ||
14 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.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/net/cadence_gem.c | 15 | --- a/hw/arm/virt.c |
17 | +++ b/hw/net/cadence_gem.c | 16 | +++ b/hw/arm/virt.c |
18 | @@ -XXX,XX +XXX,XX @@ static int gem_can_receive(NetClientState *nc) | 17 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) |
18 | if (vms->secure && (kvm_enabled() || hvf_enabled())) { | ||
19 | error_report("mach-virt: %s does not support providing " | ||
20 | "Security extensions (TrustZone) to the guest CPU", | ||
21 | - kvm_enabled() ? "KVM" : "HVF"); | ||
22 | + current_accel_name()); | ||
23 | exit(1); | ||
19 | } | 24 | } |
20 | 25 | ||
21 | for (i = 0; i < s->num_priority_queues; i++) { | 26 | if (vms->virt && (kvm_enabled() || hvf_enabled())) { |
22 | - if (rx_desc_get_ownership(s->rx_desc[i]) == 1) { | 27 | error_report("mach-virt: %s does not support providing " |
23 | - if (s->can_rx_state != 2) { | 28 | "Virtualization extensions to the guest CPU", |
24 | - s->can_rx_state = 2; | 29 | - kvm_enabled() ? "KVM" : "HVF"); |
25 | - DB_PRINT("can't receive - busy buffer descriptor (q%d) 0x%x\n", | 30 | + current_accel_name()); |
26 | - i, s->rx_desc_addr[i]); | 31 | exit(1); |
27 | - } | ||
28 | - return 0; | ||
29 | + if (rx_desc_get_ownership(s->rx_desc[i]) != 1) { | ||
30 | + break; | ||
31 | + } | ||
32 | + }; | ||
33 | + | ||
34 | + if (i == s->num_priority_queues) { | ||
35 | + if (s->can_rx_state != 2) { | ||
36 | + s->can_rx_state = 2; | ||
37 | + DB_PRINT("can't receive - all the buffer descriptors are busy\n"); | ||
38 | } | ||
39 | + return 0; | ||
40 | } | 32 | } |
41 | 33 | ||
42 | if (s->can_rx_state != 0) { | 34 | if (vms->mte && (kvm_enabled() || hvf_enabled())) { |
35 | error_report("mach-virt: %s does not support providing " | ||
36 | "MTE to the guest CPU", | ||
37 | - kvm_enabled() ? "KVM" : "HVF"); | ||
38 | + current_accel_name()); | ||
39 | exit(1); | ||
40 | } | ||
41 | |||
43 | -- | 42 | -- |
44 | 2.7.4 | 43 | 2.34.1 |
45 | |||
46 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Hao Wu <wuhaotsh@google.com> | ||
1 | 2 | ||
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. | ||
6 | |||
7 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
8 | Acked-by: Havard Skinnemoen <hskinnemoen@google.com> | ||
9 | Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org> | ||
10 | Message-id: 20230208235433.3989937-2-wuhaotsh@google.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | MAINTAINERS | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/MAINTAINERS | ||
19 | +++ b/MAINTAINERS | ||
20 | @@ -XXX,XX +XXX,XX @@ F: include/hw/net/mv88w8618_eth.h | ||
21 | F: docs/system/arm/musicpal.rst | ||
22 | |||
23 | Nuvoton NPCM7xx | ||
24 | -M: Havard Skinnemoen <hskinnemoen@google.com> | ||
25 | M: Tyrone Ting <kfting@nuvoton.com> | ||
26 | +M: Hao Wu <wuhaotsh@google.com> | ||
27 | L: qemu-arm@nongnu.org | ||
28 | S: Supported | ||
29 | F: hw/*/npcm7xx* | ||
30 | -- | ||
31 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair.francis@xilinx.com> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | This patch fixes two mistakes in the interrupt logic. | 3 | Nuvoton's PSPI is a general purpose SPI module which enables |
4 | connections to SPI-based peripheral devices. | ||
4 | 5 | ||
5 | First we only trigger single-queue or multi-queue interrupts if the status | 6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
6 | register is set. This logic was already used for non multi-queue interrupts | 7 | Reviewed-by: Chris Rauer <crauer@google.com> |
7 | but it also applies to multi-queue interrupts. | 8 | Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org> |
9 | Message-id: 20230208235433.3989937-3-wuhaotsh@google.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | MAINTAINERS | 6 +- | ||
13 | include/hw/ssi/npcm_pspi.h | 53 +++++++++ | ||
14 | hw/ssi/npcm_pspi.c | 221 +++++++++++++++++++++++++++++++++++++ | ||
15 | hw/ssi/meson.build | 2 +- | ||
16 | hw/ssi/trace-events | 5 + | ||
17 | 5 files changed, 283 insertions(+), 4 deletions(-) | ||
18 | create mode 100644 include/hw/ssi/npcm_pspi.h | ||
19 | create mode 100644 hw/ssi/npcm_pspi.c | ||
8 | 20 | ||
9 | Secondly we need to lower the interrupts if the ISR isn't set. As part | 21 | diff --git a/MAINTAINERS b/MAINTAINERS |
10 | of this we can remove the other interrupt lowering logic and consolidate | ||
11 | it inside gem_update_int_status(). | ||
12 | |||
13 | Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> | ||
14 | Message-id: 438bcc014f8f8a2f8f68f322cb6a53f4c04688c2.1491947224.git.alistair.francis@xilinx.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | hw/net/cadence_gem.c | 18 +++++++++++++----- | ||
19 | 1 file changed, 13 insertions(+), 5 deletions(-) | ||
20 | |||
21 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/net/cadence_gem.c | 23 | --- a/MAINTAINERS |
24 | +++ b/hw/net/cadence_gem.c | 24 | +++ b/MAINTAINERS |
25 | @@ -XXX,XX +XXX,XX @@ static void gem_update_int_status(CadenceGEMState *s) | 25 | @@ -XXX,XX +XXX,XX @@ M: Tyrone Ting <kfting@nuvoton.com> |
26 | { | 26 | M: Hao Wu <wuhaotsh@google.com> |
27 | int i; | 27 | L: qemu-arm@nongnu.org |
28 | 28 | S: Supported | |
29 | - if ((s->num_priority_queues == 1) && s->regs[GEM_ISR]) { | 29 | -F: hw/*/npcm7xx* |
30 | + if (!s->regs[GEM_ISR]) { | 30 | -F: include/hw/*/npcm7xx* |
31 | + /* ISR isn't set, clear all the interrupts */ | 31 | -F: tests/qtest/npcm7xx* |
32 | + for (i = 0; i < s->num_priority_queues; ++i) { | 32 | +F: hw/*/npcm* |
33 | + qemu_set_irq(s->irq[i], 0); | 33 | +F: include/hw/*/npcm* |
34 | +F: tests/qtest/npcm* | ||
35 | F: pc-bios/npcm7xx_bootrom.bin | ||
36 | F: roms/vbootrom | ||
37 | F: docs/system/arm/nuvoton.rst | ||
38 | diff --git a/include/hw/ssi/npcm_pspi.h b/include/hw/ssi/npcm_pspi.h | ||
39 | new file mode 100644 | ||
40 | index XXXXXXX..XXXXXXX | ||
41 | --- /dev/null | ||
42 | +++ b/include/hw/ssi/npcm_pspi.h | ||
43 | @@ -XXX,XX +XXX,XX @@ | ||
44 | +/* | ||
45 | + * Nuvoton Peripheral SPI Module | ||
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" | ||
129 | +#include "qemu/units.h" | ||
130 | + | ||
131 | +#include "trace.h" | ||
132 | + | ||
133 | +REG16(PSPI_DATA, 0x0) | ||
134 | +REG16(PSPI_CTL1, 0x2) | ||
135 | + FIELD(PSPI_CTL1, SPIEN, 0, 1) | ||
136 | + FIELD(PSPI_CTL1, MOD, 2, 1) | ||
137 | + FIELD(PSPI_CTL1, EIR, 5, 1) | ||
138 | + FIELD(PSPI_CTL1, EIW, 6, 1) | ||
139 | + FIELD(PSPI_CTL1, SCM, 7, 1) | ||
140 | + FIELD(PSPI_CTL1, SCIDL, 8, 1) | ||
141 | + FIELD(PSPI_CTL1, SCDV, 9, 7) | ||
142 | +REG16(PSPI_STAT, 0x4) | ||
143 | + FIELD(PSPI_STAT, BSY, 0, 1) | ||
144 | + FIELD(PSPI_STAT, RBF, 1, 1) | ||
145 | + | ||
146 | +static void npcm_pspi_update_irq(NPCMPSPIState *s) | ||
147 | +{ | ||
148 | + int level = 0; | ||
149 | + | ||
150 | + /* Only fire IRQ when the module is enabled. */ | ||
151 | + if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, SPIEN)) { | ||
152 | + /* Update interrupt as BSY is cleared. */ | ||
153 | + if ((!FIELD_EX16(s->regs[R_PSPI_STAT], PSPI_STAT, BSY)) && | ||
154 | + FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, EIW)) { | ||
155 | + level = 1; | ||
34 | + } | 156 | + } |
157 | + | ||
158 | + /* Update interrupt as RBF is set. */ | ||
159 | + if (FIELD_EX16(s->regs[R_PSPI_STAT], PSPI_STAT, RBF) && | ||
160 | + FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, EIR)) { | ||
161 | + level = 1; | ||
162 | + } | ||
163 | + } | ||
164 | + qemu_set_irq(s->irq, level); | ||
165 | +} | ||
166 | + | ||
167 | +static uint16_t npcm_pspi_read_data(NPCMPSPIState *s) | ||
168 | +{ | ||
169 | + uint16_t value = s->regs[R_PSPI_DATA]; | ||
170 | + | ||
171 | + /* Clear stat bits as the value are read out. */ | ||
172 | + s->regs[R_PSPI_STAT] = 0; | ||
173 | + | ||
174 | + return value; | ||
175 | +} | ||
176 | + | ||
177 | +static void npcm_pspi_write_data(NPCMPSPIState *s, uint16_t data) | ||
178 | +{ | ||
179 | + uint16_t value = 0; | ||
180 | + | ||
181 | + if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, MOD)) { | ||
182 | + value = ssi_transfer(s->spi, extract16(data, 8, 8)) << 8; | ||
183 | + } | ||
184 | + value |= ssi_transfer(s->spi, extract16(data, 0, 8)); | ||
185 | + s->regs[R_PSPI_DATA] = value; | ||
186 | + | ||
187 | + /* Mark data as available */ | ||
188 | + s->regs[R_PSPI_STAT] = R_PSPI_STAT_BSY_MASK | R_PSPI_STAT_RBF_MASK; | ||
189 | +} | ||
190 | + | ||
191 | +/* Control register read handler. */ | ||
192 | +static uint64_t npcm_pspi_ctrl_read(void *opaque, hwaddr addr, | ||
193 | + unsigned int size) | ||
194 | +{ | ||
195 | + NPCMPSPIState *s = opaque; | ||
196 | + uint16_t value; | ||
197 | + | ||
198 | + switch (addr) { | ||
199 | + case A_PSPI_DATA: | ||
200 | + value = npcm_pspi_read_data(s); | ||
201 | + break; | ||
202 | + | ||
203 | + case A_PSPI_CTL1: | ||
204 | + value = s->regs[R_PSPI_CTL1]; | ||
205 | + break; | ||
206 | + | ||
207 | + case A_PSPI_STAT: | ||
208 | + value = s->regs[R_PSPI_STAT]; | ||
209 | + break; | ||
210 | + | ||
211 | + default: | ||
212 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
213 | + "%s: write to invalid offset 0x%" PRIx64 "\n", | ||
214 | + DEVICE(s)->canonical_path, addr); | ||
215 | + return 0; | ||
216 | + } | ||
217 | + trace_npcm_pspi_ctrl_read(DEVICE(s)->canonical_path, addr, value); | ||
218 | + npcm_pspi_update_irq(s); | ||
219 | + | ||
220 | + return value; | ||
221 | +} | ||
222 | + | ||
223 | +/* Control register write handler. */ | ||
224 | +static void npcm_pspi_ctrl_write(void *opaque, hwaddr addr, uint64_t v, | ||
225 | + unsigned int size) | ||
226 | +{ | ||
227 | + NPCMPSPIState *s = opaque; | ||
228 | + uint16_t value = v; | ||
229 | + | ||
230 | + trace_npcm_pspi_ctrl_write(DEVICE(s)->canonical_path, addr, value); | ||
231 | + | ||
232 | + switch (addr) { | ||
233 | + case A_PSPI_DATA: | ||
234 | + npcm_pspi_write_data(s, value); | ||
235 | + break; | ||
236 | + | ||
237 | + case A_PSPI_CTL1: | ||
238 | + s->regs[R_PSPI_CTL1] = value; | ||
239 | + break; | ||
240 | + | ||
241 | + case A_PSPI_STAT: | ||
242 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
243 | + "%s: write to read-only register PSPI_STAT: 0x%08" | ||
244 | + PRIx64 "\n", DEVICE(s)->canonical_path, v); | ||
245 | + break; | ||
246 | + | ||
247 | + default: | ||
248 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
249 | + "%s: write to invalid offset 0x%" PRIx64 "\n", | ||
250 | + DEVICE(s)->canonical_path, addr); | ||
35 | + return; | 251 | + return; |
36 | + } | 252 | + } |
37 | + | 253 | + npcm_pspi_update_irq(s); |
38 | + /* If we get here we know s->regs[GEM_ISR] is set, so we don't need to | 254 | +} |
39 | + * check it again. | 255 | + |
40 | + */ | 256 | +static const MemoryRegionOps npcm_pspi_ctrl_ops = { |
41 | + if (s->num_priority_queues == 1) { | 257 | + .read = npcm_pspi_ctrl_read, |
42 | /* No priority queues, just trigger the interrupt */ | 258 | + .write = npcm_pspi_ctrl_write, |
43 | DB_PRINT("asserting int.\n"); | 259 | + .endianness = DEVICE_LITTLE_ENDIAN, |
44 | qemu_set_irq(s->irq[0], 1); | 260 | + .valid = { |
45 | @@ -XXX,XX +XXX,XX @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size) | 261 | + .min_access_size = 1, |
46 | { | 262 | + .max_access_size = 2, |
47 | CadenceGEMState *s; | 263 | + .unaligned = false, |
48 | uint32_t retval; | 264 | + }, |
49 | - int i; | 265 | + .impl = { |
50 | s = (CadenceGEMState *)opaque; | 266 | + .min_access_size = 2, |
51 | 267 | + .max_access_size = 2, | |
52 | offset >>= 2; | 268 | + .unaligned = false, |
53 | @@ -XXX,XX +XXX,XX @@ static uint64_t gem_read(void *opaque, hwaddr offset, unsigned size) | 269 | + }, |
54 | switch (offset) { | 270 | +}; |
55 | case GEM_ISR: | 271 | + |
56 | DB_PRINT("lowering irqs on ISR read\n"); | 272 | +static void npcm_pspi_enter_reset(Object *obj, ResetType type) |
57 | - for (i = 0; i < s->num_priority_queues; ++i) { | 273 | +{ |
58 | - qemu_set_irq(s->irq[i], 0); | 274 | + NPCMPSPIState *s = NPCM_PSPI(obj); |
59 | - } | 275 | + |
60 | + /* The interrupts get updated at the end of the function. */ | 276 | + trace_npcm_pspi_enter_reset(DEVICE(obj)->canonical_path, type); |
61 | break; | 277 | + memset(s->regs, 0, sizeof(s->regs)); |
62 | case GEM_PHYMNTNC: | 278 | +} |
63 | if (retval & GEM_PHYMNTNC_OP_R) { | 279 | + |
280 | +static void npcm_pspi_realize(DeviceState *dev, Error **errp) | ||
281 | +{ | ||
282 | + NPCMPSPIState *s = NPCM_PSPI(dev); | ||
283 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | ||
284 | + Object *obj = OBJECT(dev); | ||
285 | + | ||
286 | + s->spi = ssi_create_bus(dev, "pspi"); | ||
287 | + memory_region_init_io(&s->mmio, obj, &npcm_pspi_ctrl_ops, s, | ||
288 | + "mmio", 4 * KiB); | ||
289 | + sysbus_init_mmio(sbd, &s->mmio); | ||
290 | + sysbus_init_irq(sbd, &s->irq); | ||
291 | +} | ||
292 | + | ||
293 | +static const VMStateDescription vmstate_npcm_pspi = { | ||
294 | + .name = "npcm-pspi", | ||
295 | + .version_id = 0, | ||
296 | + .minimum_version_id = 0, | ||
297 | + .fields = (VMStateField[]) { | ||
298 | + VMSTATE_UINT16_ARRAY(regs, NPCMPSPIState, NPCM_PSPI_NR_REGS), | ||
299 | + VMSTATE_END_OF_LIST(), | ||
300 | + }, | ||
301 | +}; | ||
302 | + | ||
303 | + | ||
304 | +static void npcm_pspi_class_init(ObjectClass *klass, void *data) | ||
305 | +{ | ||
306 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
307 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
308 | + | ||
309 | + dc->desc = "NPCM Peripheral SPI Module"; | ||
310 | + dc->realize = npcm_pspi_realize; | ||
311 | + dc->vmsd = &vmstate_npcm_pspi; | ||
312 | + rc->phases.enter = npcm_pspi_enter_reset; | ||
313 | +} | ||
314 | + | ||
315 | +static const TypeInfo npcm_pspi_types[] = { | ||
316 | + { | ||
317 | + .name = TYPE_NPCM_PSPI, | ||
318 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
319 | + .instance_size = sizeof(NPCMPSPIState), | ||
320 | + .class_init = npcm_pspi_class_init, | ||
321 | + }, | ||
322 | +}; | ||
323 | +DEFINE_TYPES(npcm_pspi_types); | ||
324 | diff --git a/hw/ssi/meson.build b/hw/ssi/meson.build | ||
325 | index XXXXXXX..XXXXXXX 100644 | ||
326 | --- a/hw/ssi/meson.build | ||
327 | +++ b/hw/ssi/meson.build | ||
328 | @@ -XXX,XX +XXX,XX @@ | ||
329 | softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_smc.c')) | ||
330 | softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-spi.c')) | ||
331 | -softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c')) | ||
332 | +softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c', 'npcm_pspi.c')) | ||
333 | softmmu_ss.add(when: 'CONFIG_PL022', if_true: files('pl022.c')) | ||
334 | softmmu_ss.add(when: 'CONFIG_SIFIVE_SPI', if_true: files('sifive_spi.c')) | ||
335 | softmmu_ss.add(when: 'CONFIG_SSI', if_true: files('ssi.c')) | ||
336 | diff --git a/hw/ssi/trace-events b/hw/ssi/trace-events | ||
337 | index XXXXXXX..XXXXXXX 100644 | ||
338 | --- a/hw/ssi/trace-events | ||
339 | +++ b/hw/ssi/trace-events | ||
340 | @@ -XXX,XX +XXX,XX @@ npcm7xx_fiu_ctrl_write(const char *id, uint64_t addr, uint32_t data) "%s offset: | ||
341 | npcm7xx_fiu_flash_read(const char *id, int cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64 | ||
342 | npcm7xx_fiu_flash_write(const char *id, unsigned cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64 | ||
343 | |||
344 | +# npcm_pspi.c | ||
345 | +npcm_pspi_enter_reset(const char *id, int reset_type) "%s reset type: %d" | ||
346 | +npcm_pspi_ctrl_read(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16 | ||
347 | +npcm_pspi_ctrl_write(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16 | ||
348 | + | ||
349 | # ibex_spi_host.c | ||
350 | |||
351 | ibex_spi_host_reset(const char *msg) "%s" | ||
64 | -- | 352 | -- |
65 | 2.7.4 | 353 | 2.34.1 |
66 | |||
67 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | The static array exynos4210_uart_regs with register values is not | 3 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
4 | modified so it can be made const. | 4 | Reviewed-by: Titus Rwantare <titusr@google.com> |
5 | 5 | Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org> | |
6 | Few other functions accept driver or uart state as an argument but they | 6 | Message-id: 20230208235433.3989937-4-wuhaotsh@google.com |
7 | do not change it and do not cast it so this can be made const for code | ||
8 | safeness. | ||
9 | |||
10 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | ||
11 | Message-id: 20170313184750.429-3-krzk@kernel.org | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 8 | --- |
15 | hw/char/exynos4210_uart.c | 8 ++++---- | 9 | docs/system/arm/nuvoton.rst | 2 +- |
16 | 1 file changed, 4 insertions(+), 4 deletions(-) | 10 | include/hw/arm/npcm7xx.h | 2 ++ |
11 | hw/arm/npcm7xx.c | 25 +++++++++++++++++++++++-- | ||
12 | 3 files changed, 26 insertions(+), 3 deletions(-) | ||
17 | 13 | ||
18 | diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c | 14 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/char/exynos4210_uart.c | 16 | --- a/docs/system/arm/nuvoton.rst |
21 | +++ b/hw/char/exynos4210_uart.c | 17 | +++ b/docs/system/arm/nuvoton.rst |
22 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210UartReg { | 18 | @@ -XXX,XX +XXX,XX @@ Supported devices |
23 | uint32_t reset_value; | 19 | * SMBus controller (SMBF) |
24 | } Exynos4210UartReg; | 20 | * Ethernet controller (EMC) |
25 | 21 | * Tachometer | |
26 | -static Exynos4210UartReg exynos4210_uart_regs[] = { | 22 | + * Peripheral SPI controller (PSPI) |
27 | +static const Exynos4210UartReg exynos4210_uart_regs[] = { | 23 | |
28 | {"ULCON", ULCON, 0x00000000}, | 24 | Missing devices |
29 | {"UCON", UCON, 0x00003000}, | 25 | --------------- |
30 | {"UFCON", UFCON, 0x00000000}, | 26 | @@ -XXX,XX +XXX,XX @@ Missing devices |
31 | @@ -XXX,XX +XXX,XX @@ static uint8_t fifo_retrieve(Exynos4210UartFIFO *q) | 27 | |
32 | return ret; | 28 | * Ethernet controller (GMAC) |
29 | * USB device (USBD) | ||
30 | - * Peripheral SPI controller (PSPI) | ||
31 | * SD/MMC host | ||
32 | * PECI interface | ||
33 | * PCI and PCIe root complex and bridges | ||
34 | diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/include/hw/arm/npcm7xx.h | ||
37 | +++ b/include/hw/arm/npcm7xx.h | ||
38 | @@ -XXX,XX +XXX,XX @@ | ||
39 | #include "hw/nvram/npcm7xx_otp.h" | ||
40 | #include "hw/timer/npcm7xx_timer.h" | ||
41 | #include "hw/ssi/npcm7xx_fiu.h" | ||
42 | +#include "hw/ssi/npcm_pspi.h" | ||
43 | #include "hw/usb/hcd-ehci.h" | ||
44 | #include "hw/usb/hcd-ohci.h" | ||
45 | #include "target/arm/cpu.h" | ||
46 | @@ -XXX,XX +XXX,XX @@ struct NPCM7xxState { | ||
47 | NPCM7xxFIUState fiu[2]; | ||
48 | NPCM7xxEMCState emc[2]; | ||
49 | NPCM7xxSDHCIState mmc; | ||
50 | + NPCMPSPIState pspi[2]; | ||
51 | }; | ||
52 | |||
53 | #define TYPE_NPCM7XX "npcm7xx" | ||
54 | diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/arm/npcm7xx.c | ||
57 | +++ b/hw/arm/npcm7xx.c | ||
58 | @@ -XXX,XX +XXX,XX @@ enum NPCM7xxInterrupt { | ||
59 | NPCM7XX_EMC1RX_IRQ = 15, | ||
60 | NPCM7XX_EMC1TX_IRQ, | ||
61 | NPCM7XX_MMC_IRQ = 26, | ||
62 | + NPCM7XX_PSPI2_IRQ = 28, | ||
63 | + NPCM7XX_PSPI1_IRQ = 31, | ||
64 | NPCM7XX_TIMER0_IRQ = 32, /* Timer Module 0 */ | ||
65 | NPCM7XX_TIMER1_IRQ, | ||
66 | NPCM7XX_TIMER2_IRQ, | ||
67 | @@ -XXX,XX +XXX,XX @@ static const hwaddr npcm7xx_emc_addr[] = { | ||
68 | 0xf0826000, | ||
69 | }; | ||
70 | |||
71 | +/* Register base address for each PSPI Module */ | ||
72 | +static const hwaddr npcm7xx_pspi_addr[] = { | ||
73 | + 0xf0200000, | ||
74 | + 0xf0201000, | ||
75 | +}; | ||
76 | + | ||
77 | static const struct { | ||
78 | hwaddr regs_addr; | ||
79 | uint32_t unconnected_pins; | ||
80 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_init(Object *obj) | ||
81 | object_initialize_child(obj, "emc[*]", &s->emc[i], TYPE_NPCM7XX_EMC); | ||
82 | } | ||
83 | |||
84 | + for (i = 0; i < ARRAY_SIZE(s->pspi); i++) { | ||
85 | + object_initialize_child(obj, "pspi[*]", &s->pspi[i], TYPE_NPCM_PSPI); | ||
86 | + } | ||
87 | + | ||
88 | object_initialize_child(obj, "mmc", &s->mmc, TYPE_NPCM7XX_SDHCI); | ||
33 | } | 89 | } |
34 | 90 | ||
35 | -static int fifo_elements_number(Exynos4210UartFIFO *q) | 91 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) |
36 | +static int fifo_elements_number(const Exynos4210UartFIFO *q) | 92 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc), 0, |
37 | { | 93 | npcm7xx_irq(s, NPCM7XX_MMC_IRQ)); |
38 | if (q->sp < q->rp) { | 94 | |
39 | return q->size - q->rp + q->sp; | 95 | + /* PSPI */ |
40 | @@ -XXX,XX +XXX,XX @@ static int fifo_elements_number(Exynos4210UartFIFO *q) | 96 | + QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_pspi_addr) != ARRAY_SIZE(s->pspi)); |
41 | return q->sp - q->rp; | 97 | + for (i = 0; i < ARRAY_SIZE(s->pspi); i++) { |
42 | } | 98 | + SysBusDevice *sbd = SYS_BUS_DEVICE(&s->pspi[i]); |
43 | 99 | + int irq = (i == 0) ? NPCM7XX_PSPI1_IRQ : NPCM7XX_PSPI2_IRQ; | |
44 | -static int fifo_empty_elements_number(Exynos4210UartFIFO *q) | 100 | + |
45 | +static int fifo_empty_elements_number(const Exynos4210UartFIFO *q) | 101 | + sysbus_realize(sbd, &error_abort); |
46 | { | 102 | + sysbus_mmio_map(sbd, 0, npcm7xx_pspi_addr[i]); |
47 | return q->size - fifo_elements_number(q); | 103 | + sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, irq)); |
48 | } | 104 | + } |
49 | @@ -XXX,XX +XXX,XX @@ static void fifo_reset(Exynos4210UartFIFO *q) | 105 | + |
50 | q->rp = 0; | 106 | create_unimplemented_device("npcm7xx.shm", 0xc0001000, 4 * KiB); |
51 | } | 107 | create_unimplemented_device("npcm7xx.vdmx", 0xe0800000, 4 * KiB); |
52 | 108 | create_unimplemented_device("npcm7xx.pcierc", 0xe1000000, 64 * KiB); | |
53 | -static uint32_t exynos4210_uart_Tx_FIFO_trigger_level(Exynos4210UartState *s) | 109 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) |
54 | +static uint32_t exynos4210_uart_Tx_FIFO_trigger_level(const Exynos4210UartState *s) | 110 | create_unimplemented_device("npcm7xx.peci", 0xf0100000, 4 * KiB); |
55 | { | 111 | create_unimplemented_device("npcm7xx.siox[1]", 0xf0101000, 4 * KiB); |
56 | uint32_t level = 0; | 112 | create_unimplemented_device("npcm7xx.siox[2]", 0xf0102000, 4 * KiB); |
57 | uint32_t reg; | 113 | - create_unimplemented_device("npcm7xx.pspi1", 0xf0200000, 4 * KiB); |
114 | - create_unimplemented_device("npcm7xx.pspi2", 0xf0201000, 4 * KiB); | ||
115 | create_unimplemented_device("npcm7xx.ahbpci", 0xf0400000, 1 * MiB); | ||
116 | create_unimplemented_device("npcm7xx.mcphy", 0xf05f0000, 64 * KiB); | ||
117 | create_unimplemented_device("npcm7xx.gmac1", 0xf0802000, 8 * KiB); | ||
58 | -- | 118 | -- |
59 | 2.7.4 | 119 | 2.34.1 |
60 | |||
61 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
1 | 2 | ||
3 | Addresses targeting the second translation table (TTB1) in the SMMU have | ||
4 | all upper bits set. Ensure the IOMMU region covers all 64 bits. | ||
5 | |||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
9 | Message-id: 20230214171921.1917916-2-jean-philippe@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/arm/smmu-common.h | 2 -- | ||
13 | hw/arm/smmu-common.c | 2 +- | ||
14 | 2 files changed, 1 insertion(+), 3 deletions(-) | ||
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 | */ | ||
29 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/arm/smmu-common.c | ||
32 | +++ b/hw/arm/smmu-common.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn) | ||
34 | |||
35 | memory_region_init_iommu(&sdev->iommu, sizeof(sdev->iommu), | ||
36 | s->mrtypename, | ||
37 | - OBJECT(s), name, 1ULL << SMMU_MAX_VA_BITS); | ||
38 | + OBJECT(s), name, UINT64_MAX); | ||
39 | address_space_init(&sdev->as, | ||
40 | MEMORY_REGION(&sdev->iommu), name); | ||
41 | trace_smmu_add_mr(name); | ||
42 | -- | ||
43 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
1 | 2 | ||
3 | Addresses targeting the second translation table (TTB1) in the SMMU have | ||
4 | all upper bits set (except for the top byte when TBI is enabled). Fix | ||
5 | the TTB1 check. | ||
6 | |||
7 | Reported-by: Ola Hugosson <ola.hugosson@arm.com> | ||
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
11 | Message-id: 20230214171921.1917916-3-jean-philippe@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/arm/smmu-common.c | 2 +- | ||
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/hw/arm/smmu-common.c | ||
20 | +++ b/hw/arm/smmu-common.c | ||
21 | @@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova) | ||
22 | /* there is a ttbr0 region and we are in it (high bits all zero) */ | ||
23 | return &cfg->tt[0]; | ||
24 | } else if (cfg->tt[1].tsz && | ||
25 | - !extract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte)) { | ||
26 | + sextract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte) == -1) { | ||
27 | /* there is a ttbr1 region and we are in it (high bits all one) */ | ||
28 | return &cfg->tt[1]; | ||
29 | } else if (!cfg->tt[0].tsz) { | ||
30 | -- | ||
31 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair.francis@xilinx.com> | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | Read the correct descriptor instead of hardcoding the first (q=0). | 3 | make it clearer from the name that this is a tcg-only function. |
4 | 4 | ||
5 | Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> | 5 | Signed-off-by: Claudio Fontana <cfontana@suse.de> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 988b183dcf951856d8b3379f7e911ec95233bbf4.1491947224.git.alistair.francis@xilinx.com | 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 | hw/net/cadence_gem.c | 4 ++-- | 12 | target/arm/helper.c | 4 ++-- |
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
13 | 14 | ||
14 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.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/hw/net/cadence_gem.c | 17 | --- a/target/arm/helper.c |
17 | +++ b/hw/net/cadence_gem.c | 18 | +++ b/target/arm/helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static void gem_get_rx_desc(CadenceGEMState *s, int q) | 19 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) |
20 | * trapped to the hypervisor in KVM. | ||
21 | */ | ||
22 | #ifdef CONFIG_TCG | ||
23 | -static void handle_semihosting(CPUState *cs) | ||
24 | +static void tcg_handle_semihosting(CPUState *cs) | ||
19 | { | 25 | { |
20 | DB_PRINT("read descriptor 0x%x\n", (unsigned)s->rx_desc_addr[q]); | 26 | ARMCPU *cpu = ARM_CPU(cs); |
21 | /* read current descriptor */ | 27 | CPUARMState *env = &cpu->env; |
22 | - cpu_physical_memory_read(s->rx_desc_addr[0], | 28 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) |
23 | - (uint8_t *)s->rx_desc[0], sizeof(s->rx_desc[0])); | 29 | */ |
24 | + cpu_physical_memory_read(s->rx_desc_addr[q], | 30 | #ifdef CONFIG_TCG |
25 | + (uint8_t *)s->rx_desc[q], sizeof(s->rx_desc[q])); | 31 | if (cs->exception_index == EXCP_SEMIHOST) { |
26 | 32 | - handle_semihosting(cs); | |
27 | /* Descriptor owned by software ? */ | 33 | + tcg_handle_semihosting(cs); |
28 | if (rx_desc_get_ownership(s->rx_desc[q]) == 1) { | 34 | return; |
35 | } | ||
36 | #endif | ||
29 | -- | 37 | -- |
30 | 2.7.4 | 38 | 2.34.1 |
31 | 39 | ||
32 | 40 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | qemu_log_mask() and error_report() are preferred over fprintf() for | 3 | for "all" builds (tcg + kvm), we want to avoid doing |
4 | logging errors. Also remove square brackets [] and additional new line | 4 | the psci check if tcg is built-in, but not enabled. |
5 | characters in printed messages. | ||
6 | 5 | ||
7 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | 6 | Signed-off-by: Claudio Fontana <cfontana@suse.de> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20170313184750.429-2-krzk@kernel.org | 8 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
10 | [PMM: wrapped long line] | 9 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 11 | --- |
14 | hw/arm/exynos4_boards.c | 7 ++++--- | 12 | target/arm/helper.c | 3 ++- |
15 | hw/timer/exynos4210_mct.c | 6 ++++-- | 13 | 1 file changed, 2 insertions(+), 1 deletion(-) |
16 | hw/timer/exynos4210_pwm.c | 13 +++++++------ | ||
17 | hw/timer/exynos4210_rtc.c | 19 ++++++++++--------- | ||
18 | 4 files changed, 25 insertions(+), 20 deletions(-) | ||
19 | 14 | ||
20 | diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/exynos4_boards.c | 17 | --- a/target/arm/helper.c |
23 | +++ b/hw/arm/exynos4_boards.c | 18 | +++ b/target/arm/helper.c |
24 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
25 | */ | 20 | #include "hw/irq.h" |
26 | 21 | #include "sysemu/cpu-timers.h" | |
27 | #include "qemu/osdep.h" | 22 | #include "sysemu/kvm.h" |
28 | +#include "qemu/error-report.h" | 23 | +#include "sysemu/tcg.h" |
29 | #include "qemu-common.h" | 24 | #include "qapi/qapi-commands-machine-target.h" |
30 | #include "cpu.h" | 25 | #include "qapi/error.h" |
31 | #include "sysemu/sysemu.h" | 26 | #include "qemu/guest-random.h" |
32 | @@ -XXX,XX +XXX,XX @@ static Exynos4210State *exynos4_boards_init_common(MachineState *machine, | 27 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) |
33 | MachineClass *mc = MACHINE_GET_CLASS(machine); | 28 | env->exception.syndrome); |
34 | |||
35 | if (smp_cpus != EXYNOS4210_NCPUS && !qtest_enabled()) { | ||
36 | - fprintf(stderr, "%s board supports only %d CPU cores. Ignoring smp_cpus" | ||
37 | - " value.\n", | ||
38 | - mc->name, EXYNOS4210_NCPUS); | ||
39 | + error_report("%s board supports only %d CPU cores, ignoring smp_cpus" | ||
40 | + " value", | ||
41 | + mc->name, EXYNOS4210_NCPUS); | ||
42 | } | 29 | } |
43 | 30 | ||
44 | exynos4_board_binfo.ram_size = exynos4_board_ram_size[board_type]; | 31 | - if (arm_is_psci_call(cpu, cs->exception_index)) { |
45 | diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c | 32 | + if (tcg_enabled() && arm_is_psci_call(cpu, cs->exception_index)) { |
46 | index XXXXXXX..XXXXXXX 100644 | 33 | arm_handle_psci_call(cpu); |
47 | --- a/hw/timer/exynos4210_mct.c | 34 | qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n"); |
48 | +++ b/hw/timer/exynos4210_mct.c | 35 | return; |
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | */ | ||
51 | |||
52 | #include "qemu/osdep.h" | ||
53 | +#include "qemu/log.h" | ||
54 | #include "hw/sysbus.h" | ||
55 | #include "qemu/timer.h" | ||
56 | #include "qemu/main-loop.h" | ||
57 | @@ -XXX,XX +XXX,XX @@ break; | ||
58 | case L0_TCNTO: case L1_TCNTO: | ||
59 | case L0_ICNTO: case L1_ICNTO: | ||
60 | case L0_FRCNTO: case L1_FRCNTO: | ||
61 | - fprintf(stderr, "\n[exynos4210.mct: write to RO register " | ||
62 | - TARGET_FMT_plx "]\n\n", offset); | ||
63 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
64 | + "exynos4210.mct: write to RO register " TARGET_FMT_plx, | ||
65 | + offset); | ||
66 | break; | ||
67 | |||
68 | case L0_INT_CSTAT: case L1_INT_CSTAT: | ||
69 | diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/hw/timer/exynos4210_pwm.c | ||
72 | +++ b/hw/timer/exynos4210_pwm.c | ||
73 | @@ -XXX,XX +XXX,XX @@ | ||
74 | */ | ||
75 | |||
76 | #include "qemu/osdep.h" | ||
77 | +#include "qemu/log.h" | ||
78 | #include "hw/sysbus.h" | ||
79 | #include "qemu/timer.h" | ||
80 | #include "qemu-common.h" | ||
81 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_pwm_read(void *opaque, hwaddr offset, | ||
82 | break; | ||
83 | |||
84 | default: | ||
85 | - fprintf(stderr, | ||
86 | - "[exynos4210.pwm: bad read offset " TARGET_FMT_plx "]\n", | ||
87 | - offset); | ||
88 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
89 | + "exynos4210.pwm: bad read offset " TARGET_FMT_plx, | ||
90 | + offset); | ||
91 | break; | ||
92 | } | ||
93 | return value; | ||
94 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_write(void *opaque, hwaddr offset, | ||
95 | break; | ||
96 | |||
97 | default: | ||
98 | - fprintf(stderr, | ||
99 | - "[exynos4210.pwm: bad write offset " TARGET_FMT_plx "]\n", | ||
100 | - offset); | ||
101 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
102 | + "exynos4210.pwm: bad write offset " TARGET_FMT_plx, | ||
103 | + offset); | ||
104 | break; | ||
105 | |||
106 | } | ||
107 | diff --git a/hw/timer/exynos4210_rtc.c b/hw/timer/exynos4210_rtc.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | ||
109 | --- a/hw/timer/exynos4210_rtc.c | ||
110 | +++ b/hw/timer/exynos4210_rtc.c | ||
111 | @@ -XXX,XX +XXX,XX @@ | ||
112 | */ | ||
113 | |||
114 | #include "qemu/osdep.h" | ||
115 | +#include "qemu/log.h" | ||
116 | #include "hw/sysbus.h" | ||
117 | #include "qemu/timer.h" | ||
118 | #include "qemu-common.h" | ||
119 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_rtc_read(void *opaque, hwaddr offset, | ||
120 | break; | ||
121 | |||
122 | default: | ||
123 | - fprintf(stderr, | ||
124 | - "[exynos4210.rtc: bad read offset " TARGET_FMT_plx "]\n", | ||
125 | - offset); | ||
126 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
127 | + "exynos4210.rtc: bad read offset " TARGET_FMT_plx, | ||
128 | + offset); | ||
129 | break; | ||
130 | } | ||
131 | return value; | ||
132 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_rtc_write(void *opaque, hwaddr offset, | ||
133 | if (value > TICNT_THRESHOLD) { | ||
134 | s->reg_ticcnt = value; | ||
135 | } else { | ||
136 | - fprintf(stderr, | ||
137 | - "[exynos4210.rtc: bad TICNT value %u ]\n", | ||
138 | - (uint32_t)value); | ||
139 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
140 | + "exynos4210.rtc: bad TICNT value %u", | ||
141 | + (uint32_t)value); | ||
142 | } | ||
143 | break; | ||
144 | |||
145 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_rtc_write(void *opaque, hwaddr offset, | ||
146 | break; | ||
147 | |||
148 | default: | ||
149 | - fprintf(stderr, | ||
150 | - "[exynos4210.rtc: bad write offset " TARGET_FMT_plx "]\n", | ||
151 | - offset); | ||
152 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
153 | + "exynos4210.rtc: bad write offset " TARGET_FMT_plx, | ||
154 | + offset); | ||
155 | break; | ||
156 | |||
157 | } | ||
158 | -- | 36 | -- |
159 | 2.7.4 | 37 | 2.34.1 |
160 | 38 | ||
161 | 39 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair.francis@xilinx.com> | 1 | From: Claudio Fontana <cfontana@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | Expose the Cadence GEM revision as a property. | 3 | Signed-off-by: Claudio Fontana <cfontana@suse.de> |
4 | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
5 | Signed-off-by: Alistair Francis <alistair.francis@xilinx.com> | 5 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 541324373cf87b50f8be0439a0cb89f5028b016f.1491947224.git.alistair.francis@xilinx.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/net/cadence_gem.h | 1 + | 9 | target/arm/helper.c | 12 +++++++----- |
12 | hw/net/cadence_gem.c | 6 +++++- | 10 | 1 file changed, 7 insertions(+), 5 deletions(-) |
13 | 2 files changed, 6 insertions(+), 1 deletion(-) | ||
14 | 11 | ||
15 | diff --git a/include/hw/net/cadence_gem.h b/include/hw/net/cadence_gem.h | 12 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/net/cadence_gem.h | 14 | --- a/target/arm/helper.c |
18 | +++ b/include/hw/net/cadence_gem.h | 15 | +++ b/target/arm/helper.c |
19 | @@ -XXX,XX +XXX,XX @@ typedef struct CadenceGEMState { | 16 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) |
20 | uint8_t num_priority_queues; | 17 | unsigned int cur_el = arm_current_el(env); |
21 | uint8_t num_type1_screeners; | 18 | int rt; |
22 | uint8_t num_type2_screeners; | 19 | |
23 | + uint32_t revision; | 20 | - /* |
24 | 21 | - * Note that new_el can never be 0. If cur_el is 0, then | |
25 | /* GEM registers backing store */ | 22 | - * el0_a64 is is_a64(), else el0_a64 is ignored. |
26 | uint32_t regs[CADENCE_GEM_MAXREG]; | 23 | - */ |
27 | diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c | 24 | - aarch64_sve_change_el(env, cur_el, new_el, is_a64(env)); |
28 | index XXXXXXX..XXXXXXX 100644 | 25 | + if (tcg_enabled()) { |
29 | --- a/hw/net/cadence_gem.c | 26 | + /* |
30 | +++ b/hw/net/cadence_gem.c | 27 | + * Note that new_el can never be 0. If cur_el is 0, then |
31 | @@ -XXX,XX +XXX,XX @@ | 28 | + * el0_a64 is is_a64(), else el0_a64 is ignored. |
32 | #define DESC_1_RX_SOF 0x00004000 | 29 | + */ |
33 | #define DESC_1_RX_EOF 0x00008000 | 30 | + aarch64_sve_change_el(env, cur_el, new_el, is_a64(env)); |
34 | 31 | + } | |
35 | +#define GEM_MODID_VALUE 0x00020118 | 32 | |
36 | + | 33 | if (cur_el < new_el) { |
37 | static inline unsigned tx_desc_get_buffer(unsigned *desc) | 34 | /* |
38 | { | ||
39 | return desc[0]; | ||
40 | @@ -XXX,XX +XXX,XX @@ static void gem_reset(DeviceState *d) | ||
41 | s->regs[GEM_TXPAUSE] = 0x0000ffff; | ||
42 | s->regs[GEM_TXPARTIALSF] = 0x000003ff; | ||
43 | s->regs[GEM_RXPARTIALSF] = 0x000003ff; | ||
44 | - s->regs[GEM_MODID] = 0x00020118; | ||
45 | + s->regs[GEM_MODID] = s->revision; | ||
46 | s->regs[GEM_DESCONF] = 0x02500111; | ||
47 | s->regs[GEM_DESCONF2] = 0x2ab13fff; | ||
48 | s->regs[GEM_DESCONF5] = 0x002f2145; | ||
49 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_cadence_gem = { | ||
50 | |||
51 | static Property gem_properties[] = { | ||
52 | DEFINE_NIC_PROPERTIES(CadenceGEMState, conf), | ||
53 | + DEFINE_PROP_UINT32("revision", CadenceGEMState, revision, | ||
54 | + GEM_MODID_VALUE), | ||
55 | DEFINE_PROP_UINT8("num-priority-queues", CadenceGEMState, | ||
56 | num_priority_queues, 1), | ||
57 | DEFINE_PROP_UINT8("num-type1-screeners", CadenceGEMState, | ||
58 | -- | 35 | -- |
59 | 2.7.4 | 36 | 2.34.1 |
60 | 37 | ||
61 | 38 | diff view generated by jsdifflib |
1 | Move the code to generate the "condition failed" instruction | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | codepath out of the if (singlestepping) {} else {}. This | ||
3 | will allow adding support for handling a new is_jmp type | ||
4 | which can't be neatly split into "singlestepping case" | ||
5 | versus "not singlestepping case". | ||
6 | 2 | ||
3 | Move this earlier to make the next patch diff cleaner. While here | ||
4 | update the comment slightly to not give the impression that the | ||
5 | misalignment affects only TCG. | ||
6 | |||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
10 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Reviewed-by: Richard Henderson <rth@twiddle.net> | ||
10 | Message-id: 1491844419-12485-6-git-send-email-peter.maydell@linaro.org | ||
11 | --- | 12 | --- |
12 | target/arm/translate.c | 24 +++++++++++------------- | 13 | target/arm/machine.c | 18 +++++++++--------- |
13 | 1 file changed, 11 insertions(+), 13 deletions(-) | 14 | 1 file changed, 9 insertions(+), 9 deletions(-) |
14 | 15 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 16 | diff --git a/target/arm/machine.c b/target/arm/machine.c |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 18 | --- a/target/arm/machine.c |
18 | +++ b/target/arm/translate.c | 19 | +++ b/target/arm/machine.c |
19 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | 20 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) |
20 | /* At this stage dc->condjmp will only be set when the skipped | ||
21 | instruction was a conditional branch or trap, and the PC has | ||
22 | already been written. */ | ||
23 | + gen_set_condexec(dc); | ||
24 | if (unlikely(cs->singlestep_enabled || dc->ss_active)) { | ||
25 | /* Unconditional and "condition passed" instruction codepath. */ | ||
26 | - gen_set_condexec(dc); | ||
27 | switch (dc->is_jmp) { | ||
28 | case DISAS_SWI: | ||
29 | gen_ss_advance(dc); | ||
30 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | ||
31 | /* FIXME: Single stepping a WFI insn will not halt the CPU. */ | ||
32 | gen_singlestep_exception(dc); | ||
33 | } | 21 | } |
34 | - if (dc->condjmp) { | 22 | } |
35 | - /* "Condition failed" instruction codepath. */ | 23 | |
36 | - gen_set_label(dc->condlabel); | 24 | + /* |
37 | - gen_set_condexec(dc); | 25 | + * Misaligned thumb pc is architecturally impossible. Fail the |
38 | - gen_set_pc_im(dc, dc->pc); | 26 | + * incoming migration. For TCG it would trigger the assert in |
39 | - gen_singlestep_exception(dc); | 27 | + * thumb_tr_translate_insn(). |
40 | - } | 28 | + */ |
41 | } else { | 29 | + if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) { |
42 | /* While branches must always occur at the end of an IT block, | 30 | + return -1; |
43 | there are a few other things that can cause us to terminate | ||
44 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | ||
45 | - Hardware watchpoints. | ||
46 | Hardware breakpoints have already been handled and skip this code. | ||
47 | */ | ||
48 | - gen_set_condexec(dc); | ||
49 | switch(dc->is_jmp) { | ||
50 | case DISAS_NEXT: | ||
51 | gen_goto_tb(dc, 1, dc->pc); | ||
52 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | ||
53 | gen_exception(EXCP_SMC, syn_aa32_smc(), 3); | ||
54 | break; | ||
55 | } | ||
56 | - if (dc->condjmp) { | ||
57 | - gen_set_label(dc->condlabel); | ||
58 | - gen_set_condexec(dc); | ||
59 | + } | 31 | + } |
60 | + | 32 | + |
61 | + if (dc->condjmp) { | 33 | hw_breakpoint_update_all(cpu); |
62 | + /* "Condition failed" instruction codepath for the branch/trap insn */ | 34 | hw_watchpoint_update_all(cpu); |
63 | + gen_set_label(dc->condlabel); | 35 | |
64 | + gen_set_condexec(dc); | 36 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) |
65 | + if (unlikely(cs->singlestep_enabled || dc->ss_active)) { | ||
66 | + gen_set_pc_im(dc, dc->pc); | ||
67 | + gen_singlestep_exception(dc); | ||
68 | + } else { | ||
69 | gen_goto_tb(dc, 1, dc->pc); | ||
70 | - dc->condjmp = 0; | ||
71 | } | 37 | } |
72 | } | 38 | } |
73 | 39 | ||
40 | - /* | ||
41 | - * Misaligned thumb pc is architecturally impossible. | ||
42 | - * We have an assert in thumb_tr_translate_insn to verify this. | ||
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 | } | ||
74 | -- | 52 | -- |
75 | 2.7.4 | 53 | 2.34.1 |
76 | 54 | ||
77 | 55 | diff view generated by jsdifflib |
1 | We currently have two places that do: | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | if (dc->ss_active) { | 2 | |
3 | gen_step_complete_exception(dc); | 3 | Since commit cf7c6d1004 ("target/arm: Split out cpregs.h") we now have |
4 | } else { | 4 | a cpregs.h header which is more suitable for this code. |
5 | gen_exception_internal(EXCP_DEBUG); | 5 | |
6 | } | 6 | Code moved verbatim. |
7 | 7 | ||
8 | Factor this out into its own function, as we're about to add | 8 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
9 | a third place that needs the same logic. | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
11 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Reviewed-by: Richard Henderson <rth@twiddle.net> | ||
14 | Message-id: 1491844419-12485-4-git-send-email-peter.maydell@linaro.org | ||
15 | --- | 13 | --- |
16 | target/arm/translate.c | 28 ++++++++++++++++------------ | 14 | target/arm/cpregs.h | 98 +++++++++++++++++++++++++++++++++++++++++++++ |
17 | 1 file changed, 16 insertions(+), 12 deletions(-) | 15 | target/arm/cpu.h | 91 ----------------------------------------- |
18 | 16 | 2 files changed, 98 insertions(+), 91 deletions(-) | |
19 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 17 | |
18 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/translate.c | 20 | --- a/target/arm/cpregs.h |
22 | +++ b/target/arm/translate.c | 21 | +++ b/target/arm/cpregs.h |
23 | @@ -XXX,XX +XXX,XX @@ static void gen_step_complete_exception(DisasContext *s) | 22 | @@ -XXX,XX +XXX,XX @@ enum { |
24 | s->is_jmp = DISAS_EXC; | 23 | ARM_CP_SME = 1 << 19, |
25 | } | 24 | }; |
26 | 25 | ||
27 | +static void gen_singlestep_exception(DisasContext *s) | 26 | +/* |
27 | + * Interface for defining coprocessor registers. | ||
28 | + * Registers are defined in tables of arm_cp_reginfo structs | ||
29 | + * which are passed to define_arm_cp_regs(). | ||
30 | + */ | ||
31 | + | ||
32 | +/* | ||
33 | + * When looking up a coprocessor register we look for it | ||
34 | + * via an integer which encodes all of: | ||
35 | + * coprocessor number | ||
36 | + * Crn, Crm, opc1, opc2 fields | ||
37 | + * 32 or 64 bit register (ie is it accessed via MRC/MCR | ||
38 | + * or via MRRC/MCRR?) | ||
39 | + * non-secure/secure bank (AArch32 only) | ||
40 | + * We allow 4 bits for opc1 because MRRC/MCRR have a 4 bit field. | ||
41 | + * (In this case crn and opc2 should be zero.) | ||
42 | + * For AArch64, there is no 32/64 bit size distinction; | ||
43 | + * instead all registers have a 2 bit op0, 3 bit op1 and op2, | ||
44 | + * and 4 bit CRn and CRm. The encoding patterns are chosen | ||
45 | + * to be easy to convert to and from the KVM encodings, and also | ||
46 | + * so that the hashtable can contain both AArch32 and AArch64 | ||
47 | + * registers (to allow for interprocessing where we might run | ||
48 | + * 32 bit code on a 64 bit core). | ||
49 | + */ | ||
50 | +/* | ||
51 | + * This bit is private to our hashtable cpreg; in KVM register | ||
52 | + * IDs the AArch64/32 distinction is the KVM_REG_ARM/ARM64 | ||
53 | + * in the upper bits of the 64 bit ID. | ||
54 | + */ | ||
55 | +#define CP_REG_AA64_SHIFT 28 | ||
56 | +#define CP_REG_AA64_MASK (1 << CP_REG_AA64_SHIFT) | ||
57 | + | ||
58 | +/* | ||
59 | + * To enable banking of coprocessor registers depending on ns-bit we | ||
60 | + * add a bit to distinguish between secure and non-secure cpregs in the | ||
61 | + * hashtable. | ||
62 | + */ | ||
63 | +#define CP_REG_NS_SHIFT 29 | ||
64 | +#define CP_REG_NS_MASK (1 << CP_REG_NS_SHIFT) | ||
65 | + | ||
66 | +#define ENCODE_CP_REG(cp, is64, ns, crn, crm, opc1, opc2) \ | ||
67 | + ((ns) << CP_REG_NS_SHIFT | ((cp) << 16) | ((is64) << 15) | \ | ||
68 | + ((crn) << 11) | ((crm) << 7) | ((opc1) << 3) | (opc2)) | ||
69 | + | ||
70 | +#define ENCODE_AA64_CP_REG(cp, crn, crm, op0, op1, op2) \ | ||
71 | + (CP_REG_AA64_MASK | \ | ||
72 | + ((cp) << CP_REG_ARM_COPROC_SHIFT) | \ | ||
73 | + ((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \ | ||
74 | + ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \ | ||
75 | + ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \ | ||
76 | + ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \ | ||
77 | + ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT)) | ||
78 | + | ||
79 | +/* | ||
80 | + * Convert a full 64 bit KVM register ID to the truncated 32 bit | ||
81 | + * version used as a key for the coprocessor register hashtable | ||
82 | + */ | ||
83 | +static inline uint32_t kvm_to_cpreg_id(uint64_t kvmid) | ||
28 | +{ | 84 | +{ |
29 | + /* Generate the right kind of exception for singlestep, which is | 85 | + uint32_t cpregid = kvmid; |
30 | + * either the architectural singlestep or EXCP_DEBUG for QEMU's | 86 | + if ((kvmid & CP_REG_ARCH_MASK) == CP_REG_ARM64) { |
31 | + * gdb singlestepping. | 87 | + cpregid |= CP_REG_AA64_MASK; |
32 | + */ | ||
33 | + if (s->ss_active) { | ||
34 | + gen_step_complete_exception(s); | ||
35 | + } else { | 88 | + } else { |
36 | + gen_exception_internal(EXCP_DEBUG); | 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; | ||
37 | + } | 98 | + } |
99 | + return cpregid; | ||
38 | +} | 100 | +} |
39 | + | 101 | + |
40 | static void gen_smul_dual(TCGv_i32 a, TCGv_i32 b) | 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; | ||
119 | + } | ||
120 | + } | ||
121 | + return kvmid; | ||
122 | +} | ||
123 | + | ||
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) | ||
41 | { | 228 | { |
42 | TCGv_i32 tmp1 = tcg_temp_new_i32(); | ||
43 | @@ -XXX,XX +XXX,XX @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) | ||
44 | gen_set_pc_im(dc, dc->pc); | ||
45 | /* fall through */ | ||
46 | default: | ||
47 | - if (dc->ss_active) { | ||
48 | - gen_step_complete_exception(dc); | ||
49 | - } else { | ||
50 | - /* FIXME: Single stepping a WFI insn will not halt | ||
51 | - the CPU. */ | ||
52 | - gen_exception_internal(EXCP_DEBUG); | ||
53 | - } | ||
54 | + /* FIXME: Single stepping a WFI insn will not halt the CPU. */ | ||
55 | + gen_singlestep_exception(dc); | ||
56 | } | ||
57 | if (dc->condjmp) { | ||
58 | /* "Condition failed" instruction codepath. */ | ||
59 | gen_set_label(dc->condlabel); | ||
60 | gen_set_condexec(dc); | ||
61 | gen_set_pc_im(dc, dc->pc); | ||
62 | - if (dc->ss_active) { | ||
63 | - gen_step_complete_exception(dc); | ||
64 | - } else { | ||
65 | - gen_exception_internal(EXCP_DEBUG); | ||
66 | - } | ||
67 | + gen_singlestep_exception(dc); | ||
68 | } | ||
69 | } else { | ||
70 | /* While branches must always occur at the end of an IT block, | ||
71 | -- | 229 | -- |
72 | 2.7.4 | 230 | 2.34.1 |
73 | 231 | ||
74 | 232 | diff view generated by jsdifflib |
1 | From: Ishani Chugh <chugh.ishani@research.iiit.ac.in> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in> | 3 | If a test was tagged with the "accel" tag and the specified |
4 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | 4 | accelerator it not present in the qemu binary, cancel the test. |
5 | Message-id: 1491629987-6826-1-git-send-email-chugh.ishani@research.iiit.ac.in | 5 | |
6 | We can now write tests without explicit calls to require_accelerator, | ||
7 | just the tag is enough. | ||
8 | |||
9 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 13 | --- |
8 | target/arm/kvm64.c | 4 ++-- | 14 | tests/avocado/avocado_qemu/__init__.py | 4 ++++ |
9 | 1 file changed, 2 insertions(+), 2 deletions(-) | 15 | 1 file changed, 4 insertions(+) |
10 | 16 | ||
11 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | 17 | diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py |
12 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/kvm64.c | 19 | --- a/tests/avocado/avocado_qemu/__init__.py |
14 | +++ b/target/arm/kvm64.c | 20 | +++ b/tests/avocado/avocado_qemu/__init__.py |
15 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit) | 21 | @@ -XXX,XX +XXX,XX @@ def setUp(self): |
16 | * single step at this point so something has gone wrong. | 22 | |
17 | */ | 23 | super().setUp('qemu-system-') |
18 | error_report("%s: guest single-step while debugging unsupported" | 24 | |
19 | - " (%"PRIx64", %"PRIx32")\n", | 25 | + accel_required = self._get_unique_tag_val('accel') |
20 | + " (%"PRIx64", %"PRIx32")", | 26 | + if accel_required: |
21 | __func__, env->pc, debug_exit->hsr); | 27 | + self.require_accelerator(accel_required) |
22 | return false; | 28 | + |
23 | } | 29 | self.machine = self.params.get('machine', |
24 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit) | 30 | default=self._get_unique_tag_val('machine')) |
25 | break; | ||
26 | } | ||
27 | default: | ||
28 | - error_report("%s: unhandled debug exit (%"PRIx32", %"PRIx64")\n", | ||
29 | + error_report("%s: unhandled debug exit (%"PRIx32", %"PRIx64")", | ||
30 | __func__, debug_exit->hsr, env->pc); | ||
31 | } | ||
32 | 31 | ||
33 | -- | 32 | -- |
34 | 2.7.4 | 33 | 2.34.1 |
35 | 34 | ||
36 | 35 | diff view generated by jsdifflib |
1 | In tlb_fill() we construct a syndrome register value from a | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | fault status register value which is filled in by arm_tlb_fill(). | ||
3 | arm_tlb_fill() returns FSR values which might be in the format | ||
4 | used with short-format page descriptors, or the format used | ||
5 | with long-format (LPAE) descriptors. The syndrome register | ||
6 | always uses LPAE-format FSR status codes. | ||
7 | 2 | ||
8 | It isn't actually possible to end up delivering a syndrome | 3 | This allows the test to be skipped when TCG is not present in the QEMU |
9 | register value to the guest for a fault which is reported | 4 | binary. |
10 | with a short-format FSR (that kind of stage 1 fault will only | ||
11 | happen for an AArch32 translation regime which doesn't have | ||
12 | a syndrome register, and can never be redirected to an AArch64 | ||
13 | or Hyp exception level). Add an assertion which checks this, | ||
14 | and adjust the code so that we construct a syndrome with | ||
15 | an invalid status code, rather than allowing set bits in | ||
16 | the FSR input to randomly corrupt other fields in the syndrome. | ||
17 | 5 | ||
6 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
20 | Message-id: 1491486152-24304-1-git-send-email-peter.maydell@linaro.org | ||
21 | --- | 10 | --- |
22 | target/arm/op_helper.c | 23 ++++++++++++++++++----- | 11 | tests/avocado/boot_linux_console.py | 1 + |
23 | 1 file changed, 18 insertions(+), 5 deletions(-) | 12 | tests/avocado/reverse_debugging.py | 8 ++++++++ |
13 | 2 files changed, 9 insertions(+) | ||
24 | 14 | ||
25 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | 15 | diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py |
26 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/target/arm/op_helper.c | 17 | --- a/tests/avocado/boot_linux_console.py |
28 | +++ b/target/arm/op_helper.c | 18 | +++ b/tests/avocado/boot_linux_console.py |
29 | @@ -XXX,XX +XXX,XX @@ void tlb_fill(CPUState *cs, target_ulong addr, MMUAccessType access_type, | 19 | @@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_uboot_netbsd9(self): |
30 | if (unlikely(ret)) { | 20 | |
31 | ARMCPU *cpu = ARM_CPU(cs); | 21 | def test_aarch64_raspi3_atf(self): |
32 | CPUARMState *env = &cpu->env; | 22 | """ |
33 | - uint32_t syn, exc; | 23 | + :avocado: tags=accel:tcg |
34 | + uint32_t syn, exc, fsc; | 24 | :avocado: tags=arch:aarch64 |
35 | unsigned int target_el; | 25 | :avocado: tags=machine:raspi3b |
36 | bool same_el; | 26 | :avocado: tags=cpu:cortex-a53 |
37 | 27 | diff --git a/tests/avocado/reverse_debugging.py b/tests/avocado/reverse_debugging.py | |
38 | @@ -XXX,XX +XXX,XX @@ void tlb_fill(CPUState *cs, target_ulong addr, MMUAccessType access_type, | 28 | index XXXXXXX..XXXXXXX 100644 |
39 | env->cp15.hpfar_el2 = extract64(fi.s2addr, 12, 47) << 4; | 29 | --- a/tests/avocado/reverse_debugging.py |
40 | } | 30 | +++ b/tests/avocado/reverse_debugging.py |
41 | same_el = arm_current_el(env) == target_el; | 31 | @@ -XXX,XX +XXX,XX @@ def reverse_debugging(self, shift=7, args=None): |
42 | - /* AArch64 syndrome does not have an LPAE bit */ | 32 | vm.shutdown() |
43 | - syn = fsr & ~(1 << 9); | 33 | |
34 | class ReverseDebugging_X86_64(ReverseDebugging): | ||
35 | + """ | ||
36 | + :avocado: tags=accel:tcg | ||
37 | + """ | ||
44 | + | 38 | + |
45 | + if (fsr & (1 << 9)) { | 39 | REG_PC = 0x10 |
46 | + /* LPAE format fault status register : bottom 6 bits are | 40 | REG_CS = 0x12 |
47 | + * status code in the same form as needed for syndrome | 41 | def get_pc(self, g): |
48 | + */ | 42 | @@ -XXX,XX +XXX,XX @@ def test_x86_64_pc(self): |
49 | + fsc = extract32(fsr, 0, 6); | 43 | self.reverse_debugging() |
50 | + } else { | 44 | |
51 | + /* Short format FSR : this fault will never actually be reported | 45 | class ReverseDebugging_AArch64(ReverseDebugging): |
52 | + * to an EL that uses a syndrome register. Check that here, | 46 | + """ |
53 | + * and use a (currently) reserved FSR code in case the constructed | 47 | + :avocado: tags=accel:tcg |
54 | + * syndrome does leak into the guest somehow. | 48 | + """ |
55 | + */ | 49 | + |
56 | + assert(target_el != 2 && !arm_el_is_aa64(env, target_el)); | 50 | REG_PC = 32 |
57 | + fsc = 0x3f; | 51 | |
58 | + } | 52 | # unidentified gitlab timeout problem |
59 | |||
60 | /* For insn and data aborts we assume there is no instruction syndrome | ||
61 | * information; this is always true for exceptions reported to EL1. | ||
62 | */ | ||
63 | if (access_type == MMU_INST_FETCH) { | ||
64 | - syn = syn_insn_abort(same_el, 0, fi.s1ptw, syn); | ||
65 | + syn = syn_insn_abort(same_el, 0, fi.s1ptw, fsc); | ||
66 | exc = EXCP_PREFETCH_ABORT; | ||
67 | } else { | ||
68 | syn = merge_syn_data_abort(env->exception.syndrome, target_el, | ||
69 | same_el, fi.s1ptw, | ||
70 | - access_type == MMU_DATA_STORE, syn); | ||
71 | + access_type == MMU_DATA_STORE, fsc); | ||
72 | if (access_type == MMU_DATA_STORE | ||
73 | && arm_feature(env, ARM_FEATURE_V6)) { | ||
74 | fsr |= (1 << 11); | ||
75 | -- | 53 | -- |
76 | 2.7.4 | 54 | 2.34.1 |
77 | 55 | ||
78 | 56 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Fabiano Rosas <farosas@suse.de> | ||
1 | 2 | ||
3 | Now that the cortex-a15 is under CONFIG_TCG, use as default CPU for a | ||
4 | KVM-only build the 'max' cpu. | ||
5 | |||
6 | Note that we cannot use 'host' here because the qtests can run without | ||
7 | any other accelerator (than qtest) and 'host' depends on KVM being | ||
8 | enabled. | ||
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> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/arm/virt.c | 4 ++++ | ||
16 | 1 file changed, 4 insertions(+) | ||
17 | |||
18 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/hw/arm/virt.c | ||
21 | +++ b/hw/arm/virt.c | ||
22 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data) | ||
23 | mc->minimum_page_bits = 12; | ||
24 | mc->possible_cpu_arch_ids = virt_possible_cpu_arch_ids; | ||
25 | mc->cpu_index_to_instance_props = virt_cpu_index_to_props; | ||
26 | +#ifdef CONFIG_TCG | ||
27 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); | ||
28 | +#else | ||
29 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("max"); | ||
30 | +#endif | ||
31 | mc->get_default_cpu_node_id = virt_get_default_cpu_node_id; | ||
32 | mc->kvm_type = virt_kvm_type; | ||
33 | assert(!mc->get_hotplug_handler); | ||
34 | -- | ||
35 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Ard Biesheuvel <ard.biesheuvel@linaro.org> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | The arm64 boot protocol stipulates that the kernel must be loaded | 3 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
4 | TEXT_OFFSET bytes beyond a 2 MB aligned base address, where TEXT_OFFSET | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | could be any 4 KB multiple between 0 and 2 MB, and whose value can be | 5 | Acked-by: Thomas Huth <thuth@redhat.com> |
6 | found in the header of the Image file. | ||
7 | |||
8 | So after attempts to load the arm64 kernel image as an ELF file or as a | ||
9 | U-Boot image have failed (both of which have their own way of specifying | ||
10 | the load offset), try to determine the TEXT_OFFSET from the image after | ||
11 | loading it but before mapping it as a ROM mapping into the guest address | ||
12 | space. | ||
13 | |||
14 | Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Message-id: 1489414630-21609-1-git-send-email-ard.biesheuvel@linaro.org | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 7 | --- |
19 | hw/arm/boot.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++---------- | 8 | tests/qtest/arm-cpu-features.c | 28 ++++++++++++++++++---------- |
20 | 1 file changed, 53 insertions(+), 11 deletions(-) | 9 | 1 file changed, 18 insertions(+), 10 deletions(-) |
21 | 10 | ||
22 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 11 | diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c |
23 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/arm/boot.c | 13 | --- a/tests/qtest/arm-cpu-features.c |
25 | +++ b/hw/arm/boot.c | 14 | +++ b/tests/qtest/arm-cpu-features.c |
26 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ |
27 | #define KERNEL_LOAD_ADDR 0x00010000 | 16 | #define SVE_MAX_VQ 16 |
28 | #define KERNEL64_LOAD_ADDR 0x00080000 | 17 | |
29 | 18 | #define MACHINE "-machine virt,gic-version=max -accel tcg " | |
30 | +#define ARM64_TEXT_OFFSET_OFFSET 8 | 19 | -#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accel tcg " |
31 | +#define ARM64_MAGIC_OFFSET 56 | 20 | +#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm " |
32 | + | 21 | #define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \ |
33 | typedef enum { | 22 | " 'arguments': { 'type': 'full', " |
34 | FIXUP_NONE = 0, /* do nothing */ | 23 | #define QUERY_TAIL "}}" |
35 | FIXUP_TERMINATOR, /* end of insns */ | 24 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) |
36 | @@ -XXX,XX +XXX,XX @@ static uint64_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry, | 25 | { |
37 | return ret; | 26 | g_test_init(&argc, &argv, NULL); |
38 | } | 27 | |
39 | 28 | - qtest_add_data_func("/arm/query-cpu-model-expansion", | |
40 | +static uint64_t load_aarch64_image(const char *filename, hwaddr mem_base, | 29 | - NULL, test_query_cpu_model_expansion); |
41 | + hwaddr *entry) | 30 | + if (qtest_has_accel("tcg")) { |
42 | +{ | 31 | + qtest_add_data_func("/arm/query-cpu-model-expansion", |
43 | + hwaddr kernel_load_offset = KERNEL64_LOAD_ADDR; | 32 | + NULL, test_query_cpu_model_expansion); |
44 | + uint8_t *buffer; | ||
45 | + int size; | ||
46 | + | ||
47 | + /* On aarch64, it's the bootloader's job to uncompress the kernel. */ | ||
48 | + size = load_image_gzipped_buffer(filename, LOAD_IMAGE_MAX_GUNZIP_BYTES, | ||
49 | + &buffer); | ||
50 | + | ||
51 | + if (size < 0) { | ||
52 | + gsize len; | ||
53 | + | ||
54 | + /* Load as raw file otherwise */ | ||
55 | + if (!g_file_get_contents(filename, (char **)&buffer, &len, NULL)) { | ||
56 | + return -1; | ||
57 | + } | ||
58 | + size = len; | ||
59 | + } | 33 | + } |
60 | + | 34 | + |
61 | + /* check the arm64 magic header value -- very old kernels may not have it */ | 35 | + if (!g_str_equal(qtest_get_arch(), "aarch64")) { |
62 | + if (memcmp(buffer + ARM64_MAGIC_OFFSET, "ARM\x64", 4) == 0) { | 36 | + goto out; |
63 | + uint64_t hdrvals[2]; | 37 | + } |
64 | + | 38 | |
65 | + /* The arm64 Image header has text_offset and image_size fields at 8 and | 39 | /* |
66 | + * 16 bytes into the Image header, respectively. The text_offset field | 40 | * For now we only run KVM specific tests with AArch64 QEMU in |
67 | + * is only valid if the image_size is non-zero. | 41 | * order avoid attempting to run an AArch32 QEMU with KVM on |
68 | + */ | 42 | * AArch64 hosts. That won't work and isn't easy to detect. |
69 | + memcpy(&hdrvals, buffer + ARM64_TEXT_OFFSET_OFFSET, sizeof(hdrvals)); | 43 | */ |
70 | + if (hdrvals[1] != 0) { | 44 | - if (g_str_equal(qtest_get_arch(), "aarch64") && qtest_has_accel("kvm")) { |
71 | + kernel_load_offset = le64_to_cpu(hdrvals[0]); | 45 | + if (qtest_has_accel("kvm")) { |
72 | + } | 46 | /* |
47 | * This tests target the 'host' CPU type, so register it only if | ||
48 | * KVM is available. | ||
49 | */ | ||
50 | qtest_add_data_func("/arm/kvm/query-cpu-model-expansion", | ||
51 | NULL, test_query_cpu_model_expansion_kvm); | ||
52 | - } | ||
53 | |||
54 | - if (g_str_equal(qtest_get_arch(), "aarch64")) { | ||
55 | - qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8", | ||
56 | - NULL, sve_tests_sve_max_vq_8); | ||
57 | - qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off", | ||
58 | - NULL, sve_tests_sve_off); | ||
59 | qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off", | ||
60 | NULL, sve_tests_sve_off_kvm); | ||
61 | } | ||
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); | ||
73 | + } | 68 | + } |
74 | + | 69 | + |
75 | + *entry = mem_base + kernel_load_offset; | 70 | +out: |
76 | + rom_add_blob_fixed(filename, buffer, size, *entry); | 71 | return g_test_run(); |
77 | + | 72 | } |
78 | + g_free(buffer); | ||
79 | + | ||
80 | + return size; | ||
81 | +} | ||
82 | + | ||
83 | static void arm_load_kernel_notify(Notifier *notifier, void *data) | ||
84 | { | ||
85 | CPUState *cs; | ||
86 | @@ -XXX,XX +XXX,XX @@ static void arm_load_kernel_notify(Notifier *notifier, void *data) | ||
87 | int is_linux = 0; | ||
88 | uint64_t elf_entry, elf_low_addr, elf_high_addr; | ||
89 | int elf_machine; | ||
90 | - hwaddr entry, kernel_load_offset; | ||
91 | + hwaddr entry; | ||
92 | static const ARMInsnFixup *primary_loader; | ||
93 | ArmLoadKernelNotifier *n = DO_UPCAST(ArmLoadKernelNotifier, | ||
94 | notifier, notifier); | ||
95 | @@ -XXX,XX +XXX,XX @@ static void arm_load_kernel_notify(Notifier *notifier, void *data) | ||
96 | |||
97 | if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
98 | primary_loader = bootloader_aarch64; | ||
99 | - kernel_load_offset = KERNEL64_LOAD_ADDR; | ||
100 | elf_machine = EM_AARCH64; | ||
101 | } else { | ||
102 | primary_loader = bootloader; | ||
103 | if (!info->write_board_setup) { | ||
104 | primary_loader += BOOTLOADER_NO_BOARD_SETUP_OFFSET; | ||
105 | } | ||
106 | - kernel_load_offset = KERNEL_LOAD_ADDR; | ||
107 | elf_machine = EM_ARM; | ||
108 | } | ||
109 | |||
110 | @@ -XXX,XX +XXX,XX @@ static void arm_load_kernel_notify(Notifier *notifier, void *data) | ||
111 | kernel_size = load_uimage(info->kernel_filename, &entry, NULL, | ||
112 | &is_linux, NULL, NULL); | ||
113 | } | ||
114 | - /* On aarch64, it's the bootloader's job to uncompress the kernel. */ | ||
115 | if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64) && kernel_size < 0) { | ||
116 | - entry = info->loader_start + kernel_load_offset; | ||
117 | - kernel_size = load_image_gzipped(info->kernel_filename, entry, | ||
118 | - info->ram_size - kernel_load_offset); | ||
119 | + kernel_size = load_aarch64_image(info->kernel_filename, | ||
120 | + info->loader_start, &entry); | ||
121 | is_linux = 1; | ||
122 | - } | ||
123 | - if (kernel_size < 0) { | ||
124 | - entry = info->loader_start + kernel_load_offset; | ||
125 | + } else if (kernel_size < 0) { | ||
126 | + /* 32-bit ARM */ | ||
127 | + entry = info->loader_start + KERNEL_LOAD_ADDR; | ||
128 | kernel_size = load_image_targphys(info->kernel_filename, entry, | ||
129 | - info->ram_size - kernel_load_offset); | ||
130 | + info->ram_size - KERNEL_LOAD_ADDR); | ||
131 | is_linux = 1; | ||
132 | } | ||
133 | if (kernel_size < 0) { | ||
134 | -- | 73 | -- |
135 | 2.7.4 | 74 | 2.34.1 |
136 | |||
137 | diff view generated by jsdifflib |
1 | From: Krzysztof Kozlowski <krzk@kernel.org> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | Short declaration of 'i' was in the middle of declarations with | 3 | These tests set -accel tcg, so restrict them to when TCG is present. |
4 | assignments. Make it a little bit more readable. Additionally switch | ||
5 | from "unsigned" to "unsigned int" as this pattern is more widely used. | ||
6 | No functional change. | ||
7 | 4 | ||
8 | Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> | 5 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Acked-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Message-id: 20170313184750.429-4-krzk@kernel.org | 7 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 9 | --- |
14 | hw/misc/exynos4210_pmu.c | 4 ++-- | 10 | tests/qtest/meson.build | 4 ++-- |
15 | 1 file changed, 2 insertions(+), 2 deletions(-) | 11 | 1 file changed, 2 insertions(+), 2 deletions(-) |
16 | 12 | ||
17 | diff --git a/hw/misc/exynos4210_pmu.c b/hw/misc/exynos4210_pmu.c | 13 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/misc/exynos4210_pmu.c | 15 | --- a/tests/qtest/meson.build |
20 | +++ b/hw/misc/exynos4210_pmu.c | 16 | +++ b/tests/qtest/meson.build |
21 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_pmu_read(void *opaque, hwaddr offset, | 17 | @@ -XXX,XX +XXX,XX @@ qtests_arm = \ |
22 | unsigned size) | 18 | # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional |
23 | { | 19 | qtests_aarch64 = \ |
24 | Exynos4210PmuState *s = (Exynos4210PmuState *)opaque; | 20 | (cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) + \ |
25 | - unsigned i; | 21 | - (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \ |
26 | const Exynos4210PmuReg *reg_p = exynos4210_pmu_regs; | 22 | - (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \ |
27 | + unsigned int i; | 23 | + (config_all.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? \ |
28 | 24 | + ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + \ | |
29 | for (i = 0; i < PMU_NUM_OF_REGISTERS; i++) { | 25 | (config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \ |
30 | if (reg_p->offset == offset) { | 26 | (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \ |
31 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_pmu_write(void *opaque, hwaddr offset, | 27 | ['arm-cpu-features', |
32 | uint64_t val, unsigned size) | ||
33 | { | ||
34 | Exynos4210PmuState *s = (Exynos4210PmuState *)opaque; | ||
35 | - unsigned i; | ||
36 | const Exynos4210PmuReg *reg_p = exynos4210_pmu_regs; | ||
37 | + unsigned int i; | ||
38 | |||
39 | for (i = 0; i < PMU_NUM_OF_REGISTERS; i++) { | ||
40 | if (reg_p->offset == offset) { | ||
41 | -- | 28 | -- |
42 | 2.7.4 | 29 | 2.34.1 |
43 | |||
44 | diff view generated by jsdifflib |