1 | target-arm queue: | 1 | Not very much here, but several people have fallen over |
---|---|---|---|
2 | * mostly my latest v8M stuff, plus a couple of minor patches | 2 | the vector operation segfault bug, so let's get the fix |
3 | into master. | ||
3 | 4 | ||
4 | The following changes since commit a0b261db8c030813e30a39eae47359ac2a37f7e2: | 5 | thanks |
6 | -- PMM | ||
5 | 7 | ||
6 | Merge remote-tracking branch 'remotes/ehabkost/tags/python-next-pull-request' into staging (2017-10-12 10:02:09 +0100) | 8 | The following changes since commit d418238dca7b4e0b124135827ead3076233052b1: |
7 | 9 | ||
8 | are available in the git repository at: | 10 | Merge remote-tracking branch 'remotes/rth/tags/pull-rng-20190522' into staging (2019-05-23 12:57:17 +0100) |
9 | 11 | ||
10 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20171012 | 12 | are available in the Git repository at: |
11 | 13 | ||
12 | for you to fetch changes up to cf5f7937b05c84d5565134f058c00cd48304a117: | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190523 |
13 | 15 | ||
14 | nvic: Fix miscalculation of offsets into ITNS array (2017-10-12 16:33:16 +0100) | 16 | for you to fetch changes up to 98e4f4fdb8ea05d840f51f47125924c2bb9df2df: |
17 | |||
18 | hw/arm/exynos4210: QOM'ify the Exynos4210 SoC (2019-05-23 14:47:44 +0100) | ||
15 | 19 | ||
16 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
17 | target-arm queue: | 21 | target-arm queue: |
18 | * v8M: SG, BLXNS, secure-return | 22 | * exynos4210: QOM'ify the Exynos4210 SoC |
19 | * v8M: fixes for coverity issues in previous patches | 23 | * exynos4210: Add DMA support for the Exynos4210 |
20 | * arm: fix armv7m_init() declaration to match definition | 24 | * arm_gicv3: Fix writes to ICC_CTLR_EL3 |
21 | * watchdog/aspeed: fix variable type to store reload value | 25 | * arm_gicv3: Fix write of ICH_VMCR_EL2.{VBPR0, VBPR1} |
26 | * target/arm: Fix vector operation segfault | ||
27 | * target/arm: Minor improvements to BFXIL, EXTR | ||
22 | 28 | ||
23 | ---------------------------------------------------------------- | 29 | ---------------------------------------------------------------- |
24 | Cédric Le Goater (1): | 30 | Alistair Francis (1): |
25 | watchdog/aspeed: fix variable type to store reload value | 31 | target/arm: Fix vector operation segfault |
26 | 32 | ||
27 | Igor Mammedov (1): | 33 | Guenter Roeck (1): |
28 | arm: fix armv7m_init() declaration to match definition | 34 | hw/arm/exynos4210: Add DMA support for the Exynos4210 |
29 | 35 | ||
30 | Peter Maydell (11): | 36 | Peter Maydell (5): |
31 | target/arm: Add M profile secure MMU index values to get_a32_user_mem_index() | 37 | arm: Move system_clock_scale to armv7m_systick.h |
32 | target/arm: Implement SG instruction | 38 | arm: Remove unnecessary includes of hw/arm/arm.h |
33 | target/arm: Implement BLXNS | 39 | arm: Rename hw/arm/arm.h to hw/arm/boot.h |
34 | target/arm: Implement secure function return | 40 | hw/intc/arm_gicv3: Fix write of ICH_VMCR_EL2.{VBPR0, VBPR1} |
35 | target-arm: Don't check for "Thumb2 or M profile" for not-Thumb1 | 41 | hw/intc/arm_gicv3: Fix writes to ICC_CTLR_EL3 |
36 | target/arm: Pull Thumb insn word loads up to top level | ||
37 | target-arm: Simplify insn_crosses_page() | ||
38 | target/arm: Support some Thumb insns being always unconditional | ||
39 | target/arm: Implement SG instruction corner cases | ||
40 | nvic: Add missing 'break' | ||
41 | nvic: Fix miscalculation of offsets into ITNS array | ||
42 | 42 | ||
43 | include/hw/arm/arm.h | 2 +- | 43 | Philippe Mathieu-Daudé (3): |
44 | target/arm/helper.h | 1 + | 44 | hw/arm/exynos4: Remove unuseful debug code |
45 | target/arm/internals.h | 8 ++ | 45 | hw/arm/exynos4: Use the IEC binary prefix definitions |
46 | hw/intc/armv7m_nvic.c | 5 +- | 46 | hw/arm/exynos4210: QOM'ify the Exynos4210 SoC |
47 | hw/watchdog/wdt_aspeed.c | 4 +- | ||
48 | target/arm/helper.c | 306 ++++++++++++++++++++++++++++++++++++++++++++-- | ||
49 | target/arm/translate.c | 310 ++++++++++++++++++++++++++++++++--------------- | ||
50 | 7 files changed, 521 insertions(+), 115 deletions(-) | ||
51 | 47 | ||
48 | Richard Henderson (2): | ||
49 | target/arm: Use extract2 for EXTR | ||
50 | target/arm: Simplify BFXIL expansion | ||
51 | |||
52 | include/hw/arm/allwinner-a10.h | 2 +- | ||
53 | include/hw/arm/aspeed_soc.h | 1 - | ||
54 | include/hw/arm/bcm2836.h | 1 - | ||
55 | include/hw/arm/{arm.h => boot.h} | 12 +++------ | ||
56 | include/hw/arm/exynos4210.h | 9 +++++-- | ||
57 | include/hw/arm/fsl-imx25.h | 2 +- | ||
58 | include/hw/arm/fsl-imx31.h | 2 +- | ||
59 | include/hw/arm/fsl-imx6.h | 2 +- | ||
60 | include/hw/arm/fsl-imx6ul.h | 2 +- | ||
61 | include/hw/arm/fsl-imx7.h | 2 +- | ||
62 | include/hw/arm/virt.h | 2 +- | ||
63 | include/hw/arm/xlnx-versal.h | 2 +- | ||
64 | include/hw/arm/xlnx-zynqmp.h | 2 +- | ||
65 | include/hw/timer/armv7m_systick.h | 22 ++++++++++++++++ | ||
66 | hw/arm/armsse.c | 2 +- | ||
67 | hw/arm/armv7m.c | 2 +- | ||
68 | hw/arm/aspeed.c | 2 +- | ||
69 | hw/arm/boot.c | 2 +- | ||
70 | hw/arm/collie.c | 2 +- | ||
71 | hw/arm/exynos4210.c | 54 ++++++++++++++++++++++++++++++++++++--- | ||
72 | hw/arm/exynos4_boards.c | 40 ++++++++--------------------- | ||
73 | hw/arm/highbank.c | 2 +- | ||
74 | hw/arm/integratorcp.c | 2 +- | ||
75 | hw/arm/mainstone.c | 2 +- | ||
76 | hw/arm/microbit.c | 2 +- | ||
77 | hw/arm/mps2-tz.c | 2 +- | ||
78 | hw/arm/mps2.c | 2 +- | ||
79 | hw/arm/msf2-soc.c | 1 - | ||
80 | hw/arm/msf2-som.c | 2 +- | ||
81 | hw/arm/musca.c | 2 +- | ||
82 | hw/arm/musicpal.c | 2 +- | ||
83 | hw/arm/netduino2.c | 2 +- | ||
84 | hw/arm/nrf51_soc.c | 2 +- | ||
85 | hw/arm/nseries.c | 2 +- | ||
86 | hw/arm/omap1.c | 2 +- | ||
87 | hw/arm/omap2.c | 2 +- | ||
88 | hw/arm/omap_sx1.c | 2 +- | ||
89 | hw/arm/palm.c | 2 +- | ||
90 | hw/arm/raspi.c | 2 +- | ||
91 | hw/arm/realview.c | 2 +- | ||
92 | hw/arm/spitz.c | 2 +- | ||
93 | hw/arm/stellaris.c | 2 +- | ||
94 | hw/arm/stm32f205_soc.c | 2 +- | ||
95 | hw/arm/strongarm.c | 2 +- | ||
96 | hw/arm/tosa.c | 2 +- | ||
97 | hw/arm/versatilepb.c | 2 +- | ||
98 | hw/arm/vexpress.c | 2 +- | ||
99 | hw/arm/virt.c | 2 +- | ||
100 | hw/arm/xilinx_zynq.c | 2 +- | ||
101 | hw/arm/xlnx-versal.c | 2 +- | ||
102 | hw/arm/z2.c | 2 +- | ||
103 | hw/intc/arm_gicv3_cpuif.c | 6 ++--- | ||
104 | hw/intc/armv7m_nvic.c | 1 - | ||
105 | target/arm/arm-semi.c | 1 - | ||
106 | target/arm/cpu.c | 1 - | ||
107 | target/arm/cpu64.c | 1 - | ||
108 | target/arm/kvm.c | 1 - | ||
109 | target/arm/kvm32.c | 1 - | ||
110 | target/arm/kvm64.c | 1 - | ||
111 | target/arm/translate-a64.c | 44 ++++++++++++++++--------------- | ||
112 | target/arm/translate.c | 4 +-- | ||
113 | 61 files changed, 164 insertions(+), 123 deletions(-) | ||
114 | rename include/hw/arm/{arm.h => boot.h} (96%) | ||
115 | diff view generated by jsdifflib |
1 | The common situation of the SG instruction is that it is | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | executed from S&NSC memory by a CPU in NS state. That case | ||
3 | is handled by v7m_handle_execute_nsc(). However the instruction | ||
4 | also has defined behaviour in a couple of other cases: | ||
5 | * SG instruction in NS memory (behaves as a NOP) | ||
6 | * SG in S memory but CPU already secure (clears IT bits and | ||
7 | does nothing else) | ||
8 | * SG instruction in v8M without Security Extension (NOP) | ||
9 | 2 | ||
10 | These can be implemented in translate.c. | 3 | This is, after all, how we implement extract2 in tcg/aarch64. |
11 | 4 | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20190514011129.11330-2-richard.henderson@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 1507556919-24992-10-git-send-email-peter.maydell@linaro.org | ||
15 | --- | 9 | --- |
16 | target/arm/translate.c | 23 ++++++++++++++++++++++- | 10 | target/arm/translate-a64.c | 38 ++++++++++++++++++++------------------ |
17 | 1 file changed, 22 insertions(+), 1 deletion(-) | 11 | 1 file changed, 20 insertions(+), 18 deletions(-) |
18 | 12 | ||
19 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
20 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/translate.c | 15 | --- a/target/arm/translate-a64.c |
22 | +++ b/target/arm/translate.c | 16 | +++ b/target/arm/translate-a64.c |
23 | @@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(DisasContext *s, uint32_t insn) | 17 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) |
24 | * - load/store doubleword, load/store exclusive, ldacq/strel, | 18 | } else { |
25 | * table branch. | 19 | tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, rm)); |
26 | */ | 20 | } |
27 | - if (insn & 0x01200000) { | 21 | - } else if (rm == rn) { /* ROR */ |
28 | + if (insn == 0xe97fe97f && arm_dc_feature(s, ARM_FEATURE_M) && | 22 | - tcg_rm = cpu_reg(s, rm); |
29 | + arm_dc_feature(s, ARM_FEATURE_V8)) { | 23 | - if (sf) { |
30 | + /* 0b1110_1001_0111_1111_1110_1001_0111_111 | 24 | - tcg_gen_rotri_i64(tcg_rd, tcg_rm, imm); |
31 | + * - SG (v8M only) | 25 | - } else { |
32 | + * The bulk of the behaviour for this instruction is implemented | 26 | - TCGv_i32 tmp = tcg_temp_new_i32(); |
33 | + * in v7m_handle_execute_nsc(), which deals with the insn when | 27 | - tcg_gen_extrl_i64_i32(tmp, tcg_rm); |
34 | + * it is executed by a CPU in non-secure state from memory | 28 | - tcg_gen_rotri_i32(tmp, tmp, imm); |
35 | + * which is Secure & NonSecure-Callable. | 29 | - tcg_gen_extu_i32_i64(tcg_rd, tmp); |
36 | + * Here we only need to handle the remaining cases: | 30 | - tcg_temp_free_i32(tmp); |
37 | + * * in NS memory (including the "security extension not | 31 | - } |
38 | + * implemented" case) : NOP | 32 | } else { |
39 | + * * in S memory but CPU already secure (clear IT bits) | 33 | - tcg_rm = read_cpu_reg(s, rm, sf); |
40 | + * We know that the attribute for the memory this insn is | 34 | - tcg_rn = read_cpu_reg(s, rn, sf); |
41 | + * in must match the current CPU state, because otherwise | 35 | - tcg_gen_shri_i64(tcg_rm, tcg_rm, imm); |
42 | + * get_phys_addr_pmsav8 would have generated an exception. | 36 | - tcg_gen_shli_i64(tcg_rn, tcg_rn, bitsize - imm); |
43 | + */ | 37 | - tcg_gen_or_i64(tcg_rd, tcg_rm, tcg_rn); |
44 | + if (s->v8m_secure) { | 38 | - if (!sf) { |
45 | + /* Like the IT insn, we don't need to generate any code */ | 39 | - tcg_gen_ext32u_i64(tcg_rd, tcg_rd); |
46 | + s->condexec_cond = 0; | 40 | + tcg_rm = cpu_reg(s, rm); |
47 | + s->condexec_mask = 0; | 41 | + tcg_rn = cpu_reg(s, rn); |
42 | + | ||
43 | + if (sf) { | ||
44 | + /* Specialization to ROR happens in EXTRACT2. */ | ||
45 | + tcg_gen_extract2_i64(tcg_rd, tcg_rm, tcg_rn, imm); | ||
46 | + } else { | ||
47 | + TCGv_i32 t0 = tcg_temp_new_i32(); | ||
48 | + | ||
49 | + tcg_gen_extrl_i64_i32(t0, tcg_rm); | ||
50 | + if (rm == rn) { | ||
51 | + tcg_gen_rotri_i32(t0, t0, imm); | ||
52 | + } else { | ||
53 | + TCGv_i32 t1 = tcg_temp_new_i32(); | ||
54 | + tcg_gen_extrl_i64_i32(t1, tcg_rn); | ||
55 | + tcg_gen_extract2_i32(t0, t0, t1, imm); | ||
56 | + tcg_temp_free_i32(t1); | ||
48 | + } | 57 | + } |
49 | + } else if (insn & 0x01200000) { | 58 | + tcg_gen_extu_i32_i64(tcg_rd, t0); |
50 | /* 0b1110_1000_x11x_xxxx_xxxx_xxxx_xxxx_xxxx | 59 | + tcg_temp_free_i32(t0); |
51 | * - load/store dual (post-indexed) | 60 | } |
52 | * 0b1111_1001_x10x_xxxx_xxxx_xxxx_xxxx_xxxx | 61 | } |
62 | } | ||
53 | -- | 63 | -- |
54 | 2.7.4 | 64 | 2.20.1 |
55 | 65 | ||
56 | 66 | diff view generated by jsdifflib |
1 | A few Thumb instructions are always unconditional even inside an | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | IT block (as opposed to being UNPREDICTABLE if used inside an | ||
3 | IT block): BKPT, the v8M SG instruction, and the A profile | ||
4 | HLT (debug halt) instruction. | ||
5 | 2 | ||
6 | This means we need to suppress the jump-over-instruction-on-condfail | 3 | The mask implied by the extract is redundant with the one |
7 | code generation (though the IT state still advances as usual and | 4 | implied by the deposit. Also, fix spelling of BFXIL. |
8 | subsequent insns in the IT block may be conditional). | ||
9 | 5 | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20190514011129.11330-3-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 1507556919-24992-9-git-send-email-peter.maydell@linaro.org | ||
13 | --- | 10 | --- |
14 | target/arm/translate.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- | 11 | target/arm/translate-a64.c | 6 +++--- |
15 | 1 file changed, 47 insertions(+), 1 deletion(-) | 12 | 1 file changed, 3 insertions(+), 3 deletions(-) |
16 | 13 | ||
17 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate.c | 16 | --- a/target/arm/translate-a64.c |
20 | +++ b/target/arm/translate.c | 17 | +++ b/target/arm/translate-a64.c |
21 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 18 | @@ -XXX,XX +XXX,XX @@ static void disas_bitfield(DisasContext *s, uint32_t insn) |
22 | in init_disas_context by adjusting max_insns. */ | 19 | tcg_gen_extract_i64(tcg_rd, tcg_tmp, ri, len); |
23 | } | 20 | return; |
24 | 21 | } | |
25 | +static bool thumb_insn_is_unconditional(DisasContext *s, uint32_t insn) | 22 | - /* opc == 1, BXFIL fall through to deposit */ |
26 | +{ | 23 | - tcg_gen_extract_i64(tcg_tmp, tcg_tmp, ri, len); |
27 | + /* Return true if this Thumb insn is always unconditional, | 24 | + /* opc == 1, BFXIL fall through to deposit */ |
28 | + * even inside an IT block. This is true of only a very few | 25 | + tcg_gen_shri_i64(tcg_tmp, tcg_tmp, ri); |
29 | + * instructions: BKPT, HLT, and SG. | 26 | pos = 0; |
30 | + * | 27 | } else { |
31 | + * A larger class of instructions are UNPREDICTABLE if used | 28 | /* Handle the ri > si case with a deposit |
32 | + * inside an IT block; we do not need to detect those here, because | 29 | @@ -XXX,XX +XXX,XX @@ static void disas_bitfield(DisasContext *s, uint32_t insn) |
33 | + * what we do by default (perform the cc check and update the IT | 30 | len = ri; |
34 | + * bits state machine) is a permitted CONSTRAINED UNPREDICTABLE | ||
35 | + * choice for those situations. | ||
36 | + * | ||
37 | + * insn is either a 16-bit or a 32-bit instruction; the two are | ||
38 | + * distinguishable because for the 16-bit case the top 16 bits | ||
39 | + * are zeroes, and that isn't a valid 32-bit encoding. | ||
40 | + */ | ||
41 | + if ((insn & 0xffffff00) == 0xbe00) { | ||
42 | + /* BKPT */ | ||
43 | + return true; | ||
44 | + } | ||
45 | + | ||
46 | + if ((insn & 0xffffffc0) == 0xba80 && arm_dc_feature(s, ARM_FEATURE_V8) && | ||
47 | + !arm_dc_feature(s, ARM_FEATURE_M)) { | ||
48 | + /* HLT: v8A only. This is unconditional even when it is going to | ||
49 | + * UNDEF; see the v8A ARM ARM DDI0487B.a H3.3. | ||
50 | + * For v7 cores this was a plain old undefined encoding and so | ||
51 | + * honours its cc check. (We might be using the encoding as | ||
52 | + * a semihosting trap, but we don't change the cc check behaviour | ||
53 | + * on that account, because a debugger connected to a real v7A | ||
54 | + * core and emulating semihosting traps by catching the UNDEF | ||
55 | + * exception would also only see cases where the cc check passed. | ||
56 | + * No guest code should be trying to do a HLT semihosting trap | ||
57 | + * in an IT block anyway. | ||
58 | + */ | ||
59 | + return true; | ||
60 | + } | ||
61 | + | ||
62 | + if (insn == 0xe97fe97f && arm_dc_feature(s, ARM_FEATURE_V8) && | ||
63 | + arm_dc_feature(s, ARM_FEATURE_M)) { | ||
64 | + /* SG: v8M only */ | ||
65 | + return true; | ||
66 | + } | ||
67 | + | ||
68 | + return false; | ||
69 | +} | ||
70 | + | ||
71 | static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
72 | { | ||
73 | DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
74 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
75 | dc->pc += 2; | ||
76 | } | 31 | } |
77 | 32 | ||
78 | - if (dc->condexec_mask) { | 33 | - if (opc == 1) { /* BFM, BXFIL */ |
79 | + if (dc->condexec_mask && !thumb_insn_is_unconditional(dc, insn)) { | 34 | + if (opc == 1) { /* BFM, BFXIL */ |
80 | uint32_t cond = dc->condexec_cond; | 35 | tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, pos, len); |
81 | 36 | } else { | |
82 | if (cond != 0x0e) { /* Skip conditional when condition is AL. */ | 37 | /* SBFM or UBFM: We start with zero, and we haven't modified |
83 | -- | 38 | -- |
84 | 2.7.4 | 39 | 2.20.1 |
85 | 40 | ||
86 | 41 | diff view generated by jsdifflib |
1 | Recent changes have left insn_crosses_page() more complicated | 1 | From: Alistair Francis <alistair.francis@wdc.com> |
---|---|---|---|
2 | than it needed to be: | ||
3 | * it's only called from thumb_tr_translate_insn() so we know | ||
4 | for certain that we're looking at a Thumb insn | ||
5 | * the caller's check for dc->pc >= dc->next_page_start - 3 | ||
6 | means that dc->pc can't possibly be 4 aligned, so there's | ||
7 | no need to check that (the check was partly there to ensure | ||
8 | that we didn't treat an ARM insn as Thumb, I think) | ||
9 | * we now have thumb_insn_is_16bit() which lets us do a precise | ||
10 | check of the length of the next insn, rather than opencoding | ||
11 | an inaccurate check | ||
12 | 2 | ||
13 | Simplify it down to just loading the first half of the insn | 3 | Commit 89e68b575 "target/arm: Use vector operations for saturation" |
14 | and calling thumb_insn_is_16bit() on it. | 4 | causes this abort() when booting QEMU ARM with a Cortex-A15: |
15 | 5 | ||
6 | 0 0x00007ffff4c2382f in raise () at /usr/lib/libc.so.6 | ||
7 | 1 0x00007ffff4c0e672 in abort () at /usr/lib/libc.so.6 | ||
8 | 2 0x00005555559c1839 in disas_neon_data_insn (insn=<optimized out>, s=<optimized out>) at ./target/arm/translate.c:6673 | ||
9 | 3 0x00005555559c1839 in disas_neon_data_insn (s=<optimized out>, insn=<optimized out>) at ./target/arm/translate.c:6386 | ||
10 | 4 0x00005555559cd8a4 in disas_arm_insn (insn=4081107068, s=0x7fffe59a9510) at ./target/arm/translate.c:9289 | ||
11 | 5 0x00005555559cd8a4 in arm_tr_translate_insn (dcbase=0x7fffe59a9510, cpu=<optimized out>) at ./target/arm/translate.c:13612 | ||
12 | 6 0x00005555558d1d39 in translator_loop (ops=0x5555561cc580 <arm_translator_ops>, db=0x7fffe59a9510, cpu=0x55555686a2f0, tb=<optimized out>, max_insns=<optimized out>) at ./accel/tcg/translator.c:96 | ||
13 | 7 0x00005555559d10d4 in gen_intermediate_code (cpu=cpu@entry=0x55555686a2f0, tb=tb@entry=0x7fffd7840080 <code_gen_buffer+126091347>, max_insns=max_insns@entry=512) at ./target/arm/translate.c:13901 | ||
14 | 8 0x00005555558d06b9 in tb_gen_code (cpu=cpu@entry=0x55555686a2f0, pc=3067096216, cs_base=0, flags=192, cflags=-16252928, cflags@entry=524288) at ./accel/tcg/translate-all.c:1736 | ||
15 | 9 0x00005555558ce467 in tb_find (cf_mask=524288, tb_exit=1, last_tb=0x7fffd783e640 <code_gen_buffer+126084627>, cpu=0x1) at ./accel/tcg/cpu-exec.c:407 | ||
16 | 10 0x00005555558ce467 in cpu_exec (cpu=cpu@entry=0x55555686a2f0) at ./accel/tcg/cpu-exec.c:728 | ||
17 | 11 0x000055555588b0cf in tcg_cpu_exec (cpu=0x55555686a2f0) at ./cpus.c:1431 | ||
18 | 12 0x000055555588d223 in qemu_tcg_cpu_thread_fn (arg=0x55555686a2f0) at ./cpus.c:1735 | ||
19 | 13 0x000055555588d223 in qemu_tcg_cpu_thread_fn (arg=arg@entry=0x55555686a2f0) at ./cpus.c:1709 | ||
20 | 14 0x0000555555d2629a in qemu_thread_start (args=<optimized out>) at ./util/qemu-thread-posix.c:502 | ||
21 | 15 0x00007ffff4db8a92 in start_thread () at /usr/lib/libpthread. | ||
22 | |||
23 | This patch ensures that we don't hit the abort() in the second switch | ||
24 | case in disas_neon_data_insn() as we will return from the first case. | ||
25 | |||
26 | Signed-off-by: Alistair Francis <alistair.francis@wdc.com> | ||
27 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
28 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
29 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
30 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
31 | Message-id: ad91b397f360b2fc7f4087e476f7df5b04d42ddb.1558021877.git.alistair.francis@wdc.com | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | Message-id: 1507556919-24992-8-git-send-email-peter.maydell@linaro.org | ||
19 | --- | 33 | --- |
20 | target/arm/translate.c | 27 ++++++--------------------- | 34 | target/arm/translate.c | 4 ++-- |
21 | 1 file changed, 6 insertions(+), 21 deletions(-) | 35 | 1 file changed, 2 insertions(+), 2 deletions(-) |
22 | 36 | ||
23 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 37 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
24 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/arm/translate.c | 39 | --- a/target/arm/translate.c |
26 | +++ b/target/arm/translate.c | 40 | +++ b/target/arm/translate.c |
27 | @@ -XXX,XX +XXX,XX @@ static bool insn_crosses_page(CPUARMState *env, DisasContext *s) | 41 | @@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn) |
28 | { | 42 | tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc), |
29 | /* Return true if the insn at dc->pc might cross a page boundary. | 43 | rn_ofs, rm_ofs, vec_size, vec_size, |
30 | * (False positives are OK, false negatives are not.) | 44 | (u ? uqadd_op : sqadd_op) + size); |
31 | + * We know this is a Thumb insn, and our caller ensures we are | 45 | - break; |
32 | + * only called if dc->pc is less than 4 bytes from the page | 46 | + return 0; |
33 | + * boundary, so we cross the page if the first 16 bits indicate | 47 | |
34 | + * that this is a 32 bit insn. | 48 | case NEON_3R_VQSUB: |
35 | */ | 49 | tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc), |
36 | - uint16_t insn; | 50 | rn_ofs, rm_ofs, vec_size, vec_size, |
37 | + uint16_t insn = arm_lduw_code(env, s->pc, s->sctlr_b); | 51 | (u ? uqsub_op : sqsub_op) + size); |
38 | 52 | - break; | |
39 | - if ((s->pc & 3) == 0) { | 53 | + return 0; |
40 | - /* At a 4-aligned address we can't be crossing a page */ | 54 | |
41 | - return false; | 55 | case NEON_3R_VMUL: /* VMUL */ |
42 | - } | 56 | if (u) { |
43 | - | ||
44 | - /* This must be a Thumb insn */ | ||
45 | - insn = arm_lduw_code(env, s->pc, s->sctlr_b); | ||
46 | - | ||
47 | - if ((insn >> 11) >= 0x1d) { | ||
48 | - /* Top five bits 0b11101 / 0b11110 / 0b11111 : this is the | ||
49 | - * First half of a 32-bit Thumb insn. Thumb-1 cores might | ||
50 | - * end up actually treating this as two 16-bit insns (see the | ||
51 | - * code at the start of disas_thumb2_insn()) but we don't bother | ||
52 | - * to check for that as it is unlikely, and false positives here | ||
53 | - * are harmless. | ||
54 | - */ | ||
55 | - return true; | ||
56 | - } | ||
57 | - /* Definitely a 16-bit insn, can't be crossing a page. */ | ||
58 | - return false; | ||
59 | + return !thumb_insn_is_16bit(s, insn); | ||
60 | } | ||
61 | |||
62 | static int arm_tr_init_disas_context(DisasContextBase *dcbase, | ||
63 | -- | 57 | -- |
64 | 2.7.4 | 58 | 2.20.1 |
65 | 59 | ||
66 | 60 | diff view generated by jsdifflib |
1 | From: Igor Mammedov <imammedo@redhat.com> | 1 | The system_clock_scale global is used only by the armv7m systick |
---|---|---|---|
2 | device; move the extern declaration to the armv7m_systick.h header, | ||
3 | and expand the comment to explain what it is and that it should | ||
4 | ideally be replaced with a different approach. | ||
2 | 5 | ||
3 | s/cpu_model/cpu_type/ that has been forgotten during | ||
4 | conversion (ba1ba5cc), while touching the line also | ||
5 | fixup alignment. | ||
6 | |||
7 | Signed-off-by: Igor Mammedov <imammedo@redhat.com> | ||
8 | Message-id: 1507710805-221721-1-git-send-email-imammedo@redhat.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190516163857.6430-2-peter.maydell@linaro.org | ||
11 | --- | 10 | --- |
12 | include/hw/arm/arm.h | 2 +- | 11 | include/hw/arm/arm.h | 4 ---- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | include/hw/timer/armv7m_systick.h | 22 ++++++++++++++++++++++ |
13 | 2 files changed, 22 insertions(+), 4 deletions(-) | ||
14 | 14 | ||
15 | diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h | 15 | diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/arm.h | 17 | --- a/include/hw/arm/arm.h |
18 | +++ b/include/hw/arm/arm.h | 18 | +++ b/include/hw/arm/arm.h |
19 | @@ -XXX,XX +XXX,XX @@ typedef enum { | 19 | @@ -XXX,XX +XXX,XX @@ void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu, |
20 | 20 | const struct arm_boot_info *info, | |
21 | /* armv7m.c */ | 21 | hwaddr mvbar_addr); |
22 | DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq, | 22 | |
23 | - const char *kernel_filename, const char *cpu_model); | 23 | -/* Multiplication factor to convert from system clock ticks to qemu timer |
24 | + const char *kernel_filename, const char *cpu_type); | 24 | - ticks. */ |
25 | /** | 25 | -extern int system_clock_scale; |
26 | * armv7m_load_kernel: | 26 | - |
27 | * @cpu: CPU | 27 | #endif /* HW_ARM_H */ |
28 | diff --git a/include/hw/timer/armv7m_systick.h b/include/hw/timer/armv7m_systick.h | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/include/hw/timer/armv7m_systick.h | ||
31 | +++ b/include/hw/timer/armv7m_systick.h | ||
32 | @@ -XXX,XX +XXX,XX @@ typedef struct SysTickState { | ||
33 | qemu_irq irq; | ||
34 | } SysTickState; | ||
35 | |||
36 | +/* | ||
37 | + * Multiplication factor to convert from system clock ticks to qemu timer | ||
38 | + * ticks. This should be set (by board code, usually) to a value | ||
39 | + * equal to NANOSECONDS_PER_SECOND / frq, where frq is the clock frequency | ||
40 | + * in Hz of the CPU. | ||
41 | + * | ||
42 | + * This value is used by the systick device when it is running in | ||
43 | + * its "use the CPU clock" mode (ie when SYST_CSR.CLKSOURCE == 1) to | ||
44 | + * set how fast the timer should tick. | ||
45 | + * | ||
46 | + * TODO: we should refactor this so that rather than using a global | ||
47 | + * we use a device property or something similar. This is complicated | ||
48 | + * because (a) the property would need to be plumbed through from the | ||
49 | + * board code down through various layers to the systick device | ||
50 | + * and (b) the property needs to be modifiable after realize, because | ||
51 | + * the stellaris board uses this to implement the behaviour where the | ||
52 | + * guest can reprogram the PLL registers to downclock the CPU, and the | ||
53 | + * systick device needs to react accordingly. Possibly this should | ||
54 | + * be deferred until we have a good API for modelling clock trees. | ||
55 | + */ | ||
56 | +extern int system_clock_scale; | ||
57 | + | ||
58 | #endif | ||
28 | -- | 59 | -- |
29 | 2.7.4 | 60 | 2.20.1 |
30 | 61 | ||
31 | 62 | diff view generated by jsdifflib |
1 | Coverity points out that we forgot the 'break' for | 1 | The hw/arm/arm.h header now only includes declarations relating |
---|---|---|---|
2 | the SAU_CTRL write case (CID1381683). This has | 2 | to boot.c code, so it is only needed by Arm board or SoC code. |
3 | no actual visible consequences because it happens | 3 | Remove some unnecessary inclusions of it from target/arm files |
4 | that the following case is effectively a no-op. | 4 | and from hw/intc/armv7m_nvic.c. |
5 | 5 | ||
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> | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
8 | Message-id: 1507742676-9908-1-git-send-email-peter.maydell@linaro.org | 8 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Message-id: 20190516163857.6430-3-peter.maydell@linaro.org |
10 | --- | 10 | --- |
11 | hw/intc/armv7m_nvic.c | 1 + | 11 | hw/intc/armv7m_nvic.c | 1 - |
12 | 1 file changed, 1 insertion(+) | 12 | target/arm/arm-semi.c | 1 - |
13 | target/arm/cpu.c | 1 - | ||
14 | target/arm/cpu64.c | 1 - | ||
15 | target/arm/kvm.c | 1 - | ||
16 | target/arm/kvm32.c | 1 - | ||
17 | target/arm/kvm64.c | 1 - | ||
18 | 7 files changed, 7 deletions(-) | ||
13 | 19 | ||
14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 20 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
15 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/intc/armv7m_nvic.c | 22 | --- a/hw/intc/armv7m_nvic.c |
17 | +++ b/hw/intc/armv7m_nvic.c | 23 | +++ b/hw/intc/armv7m_nvic.c |
18 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | 24 | @@ -XXX,XX +XXX,XX @@ |
19 | return; | 25 | #include "cpu.h" |
20 | } | 26 | #include "hw/sysbus.h" |
21 | cpu->env.sau.ctrl = value & 3; | 27 | #include "qemu/timer.h" |
22 | + break; | 28 | -#include "hw/arm/arm.h" |
23 | case 0xdd4: /* SAU_TYPE */ | 29 | #include "hw/intc/armv7m_nvic.h" |
24 | if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { | 30 | #include "target/arm/cpu.h" |
25 | goto bad_offset; | 31 | #include "exec/exec-all.h" |
32 | diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/arm-semi.c | ||
35 | +++ b/target/arm/arm-semi.c | ||
36 | @@ -XXX,XX +XXX,XX @@ | ||
37 | #else | ||
38 | #include "qemu-common.h" | ||
39 | #include "exec/gdbstub.h" | ||
40 | -#include "hw/arm/arm.h" | ||
41 | #include "qemu/cutils.h" | ||
42 | #endif | ||
43 | |||
44 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/cpu.c | ||
47 | +++ b/target/arm/cpu.c | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | #if !defined(CONFIG_USER_ONLY) | ||
50 | #include "hw/loader.h" | ||
51 | #endif | ||
52 | -#include "hw/arm/arm.h" | ||
53 | #include "sysemu/sysemu.h" | ||
54 | #include "sysemu/hw_accel.h" | ||
55 | #include "kvm_arm.h" | ||
56 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/cpu64.c | ||
59 | +++ b/target/arm/cpu64.c | ||
60 | @@ -XXX,XX +XXX,XX @@ | ||
61 | #if !defined(CONFIG_USER_ONLY) | ||
62 | #include "hw/loader.h" | ||
63 | #endif | ||
64 | -#include "hw/arm/arm.h" | ||
65 | #include "sysemu/sysemu.h" | ||
66 | #include "sysemu/kvm.h" | ||
67 | #include "kvm_arm.h" | ||
68 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/target/arm/kvm.c | ||
71 | +++ b/target/arm/kvm.c | ||
72 | @@ -XXX,XX +XXX,XX @@ | ||
73 | #include "cpu.h" | ||
74 | #include "trace.h" | ||
75 | #include "internals.h" | ||
76 | -#include "hw/arm/arm.h" | ||
77 | #include "hw/pci/pci.h" | ||
78 | #include "exec/memattrs.h" | ||
79 | #include "exec/address-spaces.h" | ||
80 | diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/arm/kvm32.c | ||
83 | +++ b/target/arm/kvm32.c | ||
84 | @@ -XXX,XX +XXX,XX @@ | ||
85 | #include "sysemu/kvm.h" | ||
86 | #include "kvm_arm.h" | ||
87 | #include "internals.h" | ||
88 | -#include "hw/arm/arm.h" | ||
89 | #include "qemu/log.h" | ||
90 | |||
91 | static inline void set_feature(uint64_t *features, int feature) | ||
92 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/kvm64.c | ||
95 | +++ b/target/arm/kvm64.c | ||
96 | @@ -XXX,XX +XXX,XX @@ | ||
97 | #include "sysemu/kvm.h" | ||
98 | #include "kvm_arm.h" | ||
99 | #include "internals.h" | ||
100 | -#include "hw/arm/arm.h" | ||
101 | |||
102 | static bool have_guest_debug; | ||
103 | |||
26 | -- | 104 | -- |
27 | 2.7.4 | 105 | 2.20.1 |
28 | 106 | ||
29 | 107 | diff view generated by jsdifflib |
1 | Secure function return happens when a non-secure function has been | 1 | The header file hw/arm/arm.h now includes only declarations |
---|---|---|---|
2 | called using BLXNS and so has a particular magic LR value (either | 2 | relating to hw/arm/boot.c functionality. Rename it accordingly, |
3 | 0xfefffffe or 0xfeffffff). The function return via BX behaves | 3 | and adjust its header comment. |
4 | specially when the new PC value is this magic value, in the same | ||
5 | way that exception returns are handled. | ||
6 | 4 | ||
7 | Adjust our BX excret guards so that they recognize the function | 5 | The bulk of this commit was created via |
8 | return magic number as well, and perform the function-return | 6 | perl -pi -e 's|hw/arm/arm.h|hw/arm/boot.h|' hw/arm/*.c include/hw/arm/*.h |
9 | unstacking in do_v7m_exception_exit(). | 7 | |
8 | In a few cases we can just delete the #include: | ||
9 | hw/arm/msf2-soc.c, include/hw/arm/aspeed_soc.h and | ||
10 | include/hw/arm/bcm2836.h did not require it. | ||
10 | 11 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
14 | Message-id: 1507556919-24992-5-git-send-email-peter.maydell@linaro.org | 15 | Message-id: 20190516163857.6430-4-peter.maydell@linaro.org |
15 | --- | 16 | --- |
16 | target/arm/internals.h | 7 +++ | 17 | include/hw/arm/allwinner-a10.h | 2 +- |
17 | target/arm/helper.c | 115 +++++++++++++++++++++++++++++++++++++++++++++---- | 18 | include/hw/arm/aspeed_soc.h | 1 - |
18 | target/arm/translate.c | 14 +++++- | 19 | include/hw/arm/bcm2836.h | 1 - |
19 | 3 files changed, 126 insertions(+), 10 deletions(-) | 20 | include/hw/arm/{arm.h => boot.h} | 8 ++++---- |
21 | include/hw/arm/fsl-imx25.h | 2 +- | ||
22 | include/hw/arm/fsl-imx31.h | 2 +- | ||
23 | include/hw/arm/fsl-imx6.h | 2 +- | ||
24 | include/hw/arm/fsl-imx6ul.h | 2 +- | ||
25 | include/hw/arm/fsl-imx7.h | 2 +- | ||
26 | include/hw/arm/virt.h | 2 +- | ||
27 | include/hw/arm/xlnx-versal.h | 2 +- | ||
28 | include/hw/arm/xlnx-zynqmp.h | 2 +- | ||
29 | hw/arm/armsse.c | 2 +- | ||
30 | hw/arm/armv7m.c | 2 +- | ||
31 | hw/arm/aspeed.c | 2 +- | ||
32 | hw/arm/boot.c | 2 +- | ||
33 | hw/arm/collie.c | 2 +- | ||
34 | hw/arm/exynos4210.c | 2 +- | ||
35 | hw/arm/exynos4_boards.c | 2 +- | ||
36 | hw/arm/highbank.c | 2 +- | ||
37 | hw/arm/integratorcp.c | 2 +- | ||
38 | hw/arm/mainstone.c | 2 +- | ||
39 | hw/arm/microbit.c | 2 +- | ||
40 | hw/arm/mps2-tz.c | 2 +- | ||
41 | hw/arm/mps2.c | 2 +- | ||
42 | hw/arm/msf2-soc.c | 1 - | ||
43 | hw/arm/msf2-som.c | 2 +- | ||
44 | hw/arm/musca.c | 2 +- | ||
45 | hw/arm/musicpal.c | 2 +- | ||
46 | hw/arm/netduino2.c | 2 +- | ||
47 | hw/arm/nrf51_soc.c | 2 +- | ||
48 | hw/arm/nseries.c | 2 +- | ||
49 | hw/arm/omap1.c | 2 +- | ||
50 | hw/arm/omap2.c | 2 +- | ||
51 | hw/arm/omap_sx1.c | 2 +- | ||
52 | hw/arm/palm.c | 2 +- | ||
53 | hw/arm/raspi.c | 2 +- | ||
54 | hw/arm/realview.c | 2 +- | ||
55 | hw/arm/spitz.c | 2 +- | ||
56 | hw/arm/stellaris.c | 2 +- | ||
57 | hw/arm/stm32f205_soc.c | 2 +- | ||
58 | hw/arm/strongarm.c | 2 +- | ||
59 | hw/arm/tosa.c | 2 +- | ||
60 | hw/arm/versatilepb.c | 2 +- | ||
61 | hw/arm/vexpress.c | 2 +- | ||
62 | hw/arm/virt.c | 2 +- | ||
63 | hw/arm/xilinx_zynq.c | 2 +- | ||
64 | hw/arm/xlnx-versal.c | 2 +- | ||
65 | hw/arm/z2.c | 2 +- | ||
66 | 49 files changed, 49 insertions(+), 52 deletions(-) | ||
67 | rename include/hw/arm/{arm.h => boot.h} (98%) | ||
20 | 68 | ||
21 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 69 | diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h |
22 | index XXXXXXX..XXXXXXX 100644 | 70 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/internals.h | 71 | --- a/include/hw/arm/allwinner-a10.h |
24 | +++ b/target/arm/internals.h | 72 | +++ b/include/hw/arm/allwinner-a10.h |
25 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_EXCRET, DCRS, 5, 1) | 73 | @@ -XXX,XX +XXX,XX @@ |
26 | FIELD(V7M_EXCRET, S, 6, 1) | 74 | #include "qemu-common.h" |
27 | FIELD(V7M_EXCRET, RES1, 7, 25) /* including the must-be-1 prefix */ | 75 | #include "qemu/error-report.h" |
28 | 76 | #include "hw/char/serial.h" | |
29 | +/* Minimum value which is a magic number for exception return */ | 77 | -#include "hw/arm/arm.h" |
30 | +#define EXC_RETURN_MIN_MAGIC 0xff000000 | 78 | +#include "hw/arm/boot.h" |
31 | +/* Minimum number which is a magic number for function or exception return | 79 | #include "hw/timer/allwinner-a10-pit.h" |
32 | + * when using v8M security extension | 80 | #include "hw/intc/allwinner-a10-pic.h" |
33 | + */ | 81 | #include "hw/net/allwinner_emac.h" |
34 | +#define FNC_RETURN_MIN_MAGIC 0xfefffffe | 82 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
35 | + | 83 | index XXXXXXX..XXXXXXX 100644 |
36 | /* We use a few fake FSR values for internal purposes in M profile. | 84 | --- a/include/hw/arm/aspeed_soc.h |
37 | * M profile cores don't have A/R format FSRs, but currently our | 85 | +++ b/include/hw/arm/aspeed_soc.h |
38 | * get_phys_addr() code assumes A/R profile and reports failures via | 86 | @@ -XXX,XX +XXX,XX @@ |
39 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 87 | #ifndef ASPEED_SOC_H |
40 | index XXXXXXX..XXXXXXX 100644 | 88 | #define ASPEED_SOC_H |
41 | --- a/target/arm/helper.c | 89 | |
42 | +++ b/target/arm/helper.c | 90 | -#include "hw/arm/arm.h" |
43 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | 91 | #include "hw/intc/aspeed_vic.h" |
44 | * - if the return value is a magic value, do exception return (like BX) | 92 | #include "hw/misc/aspeed_scu.h" |
45 | * - otherwise bit 0 of the return value is the target security state | 93 | #include "hw/misc/aspeed_sdmc.h" |
46 | */ | 94 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h |
47 | - if (dest >= 0xff000000) { | 95 | index XXXXXXX..XXXXXXX 100644 |
48 | + uint32_t min_magic; | 96 | --- a/include/hw/arm/bcm2836.h |
49 | + | 97 | +++ b/include/hw/arm/bcm2836.h |
50 | + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { | 98 | @@ -XXX,XX +XXX,XX @@ |
51 | + /* Covers FNC_RETURN and EXC_RETURN magic */ | 99 | #ifndef BCM2836_H |
52 | + min_magic = FNC_RETURN_MIN_MAGIC; | 100 | #define BCM2836_H |
53 | + } else { | 101 | |
54 | + /* EXC_RETURN magic only */ | 102 | -#include "hw/arm/arm.h" |
55 | + min_magic = EXC_RETURN_MIN_MAGIC; | 103 | #include "hw/arm/bcm2835_peripherals.h" |
56 | + } | 104 | #include "hw/intc/bcm2836_control.h" |
57 | + | 105 | |
58 | + if (dest >= min_magic) { | 106 | diff --git a/include/hw/arm/arm.h b/include/hw/arm/boot.h |
59 | /* This is an exception return magic value; put it where | 107 | similarity index 98% |
60 | * do_v7m_exception_exit() expects and raise EXCEPTION_EXIT. | 108 | rename from include/hw/arm/arm.h |
61 | * Note that if we ever add gen_ss_advance() singlestep support to | 109 | rename to include/hw/arm/boot.h |
62 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | 110 | index XXXXXXX..XXXXXXX 100644 |
63 | bool exc_secure = false; | 111 | --- a/include/hw/arm/arm.h |
64 | bool return_to_secure; | 112 | +++ b/include/hw/arm/boot.h |
65 | 113 | @@ -XXX,XX +XXX,XX @@ | |
66 | - /* We can only get here from an EXCP_EXCEPTION_EXIT, and | 114 | /* |
67 | - * gen_bx_excret() enforces the architectural rule | 115 | - * Misc ARM declarations |
68 | - * that jumps to magic addresses don't have magic behaviour unless | 116 | + * ARM kernel loader. |
69 | - * we're in Handler mode (compare pseudocode BXWritePC()). | 117 | * |
70 | + /* If we're not in Handler mode then jumps to magic exception-exit | 118 | * Copyright (c) 2006 CodeSourcery. |
71 | + * addresses don't have magic behaviour. However for the v8M | 119 | * Written by Paul Brook |
72 | + * security extensions the magic secure-function-return has to | 120 | @@ -XXX,XX +XXX,XX @@ |
73 | + * work in thread mode too, so to avoid doing an extra check in | 121 | * |
74 | + * the generated code we allow exception-exit magic to also cause the | 122 | */ |
75 | + * internal exception and bring us here in thread mode. Correct code | 123 | |
76 | + * will never try to do this (the following insn fetch will always | 124 | -#ifndef HW_ARM_H |
77 | + * fault) so we the overhead of having taken an unnecessary exception | 125 | -#define HW_ARM_H |
78 | + * doesn't matter. | 126 | +#ifndef HW_ARM_BOOT_H |
79 | */ | 127 | +#define HW_ARM_BOOT_H |
80 | - assert(arm_v7m_is_handler_mode(env)); | 128 | |
81 | + if (!arm_v7m_is_handler_mode(env)) { | 129 | #include "exec/memory.h" |
82 | + return; | 130 | #include "target/arm/cpu-qom.h" |
83 | + } | 131 | @@ -XXX,XX +XXX,XX @@ void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu, |
84 | 132 | const struct arm_boot_info *info, | |
85 | /* In the spec pseudocode ExceptionReturn() is called directly | 133 | hwaddr mvbar_addr); |
86 | * from BXWritePC() and gets the full target PC value including | 134 | |
87 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | 135 | -#endif /* HW_ARM_H */ |
88 | qemu_log_mask(CPU_LOG_INT, "...successful exception return\n"); | 136 | +#endif /* HW_ARM_BOOT_H */ |
89 | } | 137 | diff --git a/include/hw/arm/fsl-imx25.h b/include/hw/arm/fsl-imx25.h |
90 | 138 | index XXXXXXX..XXXXXXX 100644 | |
91 | +static bool do_v7m_function_return(ARMCPU *cpu) | 139 | --- a/include/hw/arm/fsl-imx25.h |
92 | +{ | 140 | +++ b/include/hw/arm/fsl-imx25.h |
93 | + /* v8M security extensions magic function return. | 141 | @@ -XXX,XX +XXX,XX @@ |
94 | + * We may either: | 142 | #ifndef FSL_IMX25_H |
95 | + * (1) throw an exception (longjump) | 143 | #define FSL_IMX25_H |
96 | + * (2) return true if we successfully handled the function return | 144 | |
97 | + * (3) return false if we failed a consistency check and have | 145 | -#include "hw/arm/arm.h" |
98 | + * pended a UsageFault that needs to be taken now | 146 | +#include "hw/arm/boot.h" |
99 | + * | 147 | #include "hw/intc/imx_avic.h" |
100 | + * At this point the magic return value is split between env->regs[15] | 148 | #include "hw/misc/imx25_ccm.h" |
101 | + * and env->thumb. We don't bother to reconstitute it because we don't | 149 | #include "hw/char/imx_serial.h" |
102 | + * need it (all values are handled the same way). | 150 | diff --git a/include/hw/arm/fsl-imx31.h b/include/hw/arm/fsl-imx31.h |
103 | + */ | 151 | index XXXXXXX..XXXXXXX 100644 |
104 | + CPUARMState *env = &cpu->env; | 152 | --- a/include/hw/arm/fsl-imx31.h |
105 | + uint32_t newpc, newpsr, newpsr_exc; | 153 | +++ b/include/hw/arm/fsl-imx31.h |
106 | + | 154 | @@ -XXX,XX +XXX,XX @@ |
107 | + qemu_log_mask(CPU_LOG_INT, "...really v7M secure function return\n"); | 155 | #ifndef FSL_IMX31_H |
108 | + | 156 | #define FSL_IMX31_H |
109 | + { | 157 | |
110 | + bool threadmode, spsel; | 158 | -#include "hw/arm/arm.h" |
111 | + TCGMemOpIdx oi; | 159 | +#include "hw/arm/boot.h" |
112 | + ARMMMUIdx mmu_idx; | 160 | #include "hw/intc/imx_avic.h" |
113 | + uint32_t *frame_sp_p; | 161 | #include "hw/misc/imx31_ccm.h" |
114 | + uint32_t frameptr; | 162 | #include "hw/char/imx_serial.h" |
115 | + | 163 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h |
116 | + /* Pull the return address and IPSR from the Secure stack */ | 164 | index XXXXXXX..XXXXXXX 100644 |
117 | + threadmode = !arm_v7m_is_handler_mode(env); | 165 | --- a/include/hw/arm/fsl-imx6.h |
118 | + spsel = env->v7m.control[M_REG_S] & R_V7M_CONTROL_SPSEL_MASK; | 166 | +++ b/include/hw/arm/fsl-imx6.h |
119 | + | 167 | @@ -XXX,XX +XXX,XX @@ |
120 | + frame_sp_p = get_v7m_sp_ptr(env, true, threadmode, spsel); | 168 | #ifndef FSL_IMX6_H |
121 | + frameptr = *frame_sp_p; | 169 | #define FSL_IMX6_H |
122 | + | 170 | |
123 | + /* These loads may throw an exception (for MPU faults). We want to | 171 | -#include "hw/arm/arm.h" |
124 | + * do them as secure, so work out what MMU index that is. | 172 | +#include "hw/arm/boot.h" |
125 | + */ | 173 | #include "hw/cpu/a9mpcore.h" |
126 | + mmu_idx = arm_v7m_mmu_idx_for_secstate(env, true); | 174 | #include "hw/misc/imx6_ccm.h" |
127 | + oi = make_memop_idx(MO_LE, arm_to_core_mmu_idx(mmu_idx)); | 175 | #include "hw/misc/imx6_src.h" |
128 | + newpc = helper_le_ldul_mmu(env, frameptr, oi, 0); | 176 | diff --git a/include/hw/arm/fsl-imx6ul.h b/include/hw/arm/fsl-imx6ul.h |
129 | + newpsr = helper_le_ldul_mmu(env, frameptr + 4, oi, 0); | 177 | index XXXXXXX..XXXXXXX 100644 |
130 | + | 178 | --- a/include/hw/arm/fsl-imx6ul.h |
131 | + /* Consistency checks on new IPSR */ | 179 | +++ b/include/hw/arm/fsl-imx6ul.h |
132 | + newpsr_exc = newpsr & XPSR_EXCP; | 180 | @@ -XXX,XX +XXX,XX @@ |
133 | + if (!((env->v7m.exception == 0 && newpsr_exc == 0) || | 181 | #ifndef FSL_IMX6UL_H |
134 | + (env->v7m.exception == 1 && newpsr_exc != 0))) { | 182 | #define FSL_IMX6UL_H |
135 | + /* Pend the fault and tell our caller to take it */ | 183 | |
136 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK; | 184 | -#include "hw/arm/arm.h" |
137 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | 185 | +#include "hw/arm/boot.h" |
138 | + env->v7m.secure); | 186 | #include "hw/cpu/a15mpcore.h" |
139 | + qemu_log_mask(CPU_LOG_INT, | 187 | #include "hw/misc/imx6ul_ccm.h" |
140 | + "...taking INVPC UsageFault: " | 188 | #include "hw/misc/imx6_src.h" |
141 | + "IPSR consistency check failed\n"); | 189 | diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h |
142 | + return false; | 190 | index XXXXXXX..XXXXXXX 100644 |
143 | + } | 191 | --- a/include/hw/arm/fsl-imx7.h |
144 | + | 192 | +++ b/include/hw/arm/fsl-imx7.h |
145 | + *frame_sp_p = frameptr + 8; | 193 | @@ -XXX,XX +XXX,XX @@ |
146 | + } | 194 | #ifndef FSL_IMX7_H |
147 | + | 195 | #define FSL_IMX7_H |
148 | + /* This invalidates frame_sp_p */ | 196 | |
149 | + switch_v7m_security_state(env, true); | 197 | -#include "hw/arm/arm.h" |
150 | + env->v7m.exception = newpsr_exc; | 198 | +#include "hw/arm/boot.h" |
151 | + env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK; | 199 | #include "hw/cpu/a15mpcore.h" |
152 | + if (newpsr & XPSR_SFPA) { | 200 | #include "hw/intc/imx_gpcv2.h" |
153 | + env->v7m.control[M_REG_S] |= R_V7M_CONTROL_SFPA_MASK; | 201 | #include "hw/misc/imx7_ccm.h" |
154 | + } | 202 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h |
155 | + xpsr_write(env, 0, XPSR_IT); | 203 | index XXXXXXX..XXXXXXX 100644 |
156 | + env->thumb = newpc & 1; | 204 | --- a/include/hw/arm/virt.h |
157 | + env->regs[15] = newpc & ~1; | 205 | +++ b/include/hw/arm/virt.h |
158 | + | 206 | @@ -XXX,XX +XXX,XX @@ |
159 | + qemu_log_mask(CPU_LOG_INT, "...function return successful\n"); | 207 | #include "exec/hwaddr.h" |
160 | + return true; | 208 | #include "qemu/notify.h" |
161 | +} | 209 | #include "hw/boards.h" |
162 | + | 210 | -#include "hw/arm/arm.h" |
163 | static void arm_log_exception(int idx) | 211 | +#include "hw/arm/boot.h" |
212 | #include "hw/block/flash.h" | ||
213 | #include "sysemu/kvm.h" | ||
214 | #include "hw/intc/arm_gicv3_common.h" | ||
215 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | ||
216 | index XXXXXXX..XXXXXXX 100644 | ||
217 | --- a/include/hw/arm/xlnx-versal.h | ||
218 | +++ b/include/hw/arm/xlnx-versal.h | ||
219 | @@ -XXX,XX +XXX,XX @@ | ||
220 | #define XLNX_VERSAL_H | ||
221 | |||
222 | #include "hw/sysbus.h" | ||
223 | -#include "hw/arm/arm.h" | ||
224 | +#include "hw/arm/boot.h" | ||
225 | #include "hw/intc/arm_gicv3.h" | ||
226 | |||
227 | #define TYPE_XLNX_VERSAL "xlnx-versal" | ||
228 | diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h | ||
229 | index XXXXXXX..XXXXXXX 100644 | ||
230 | --- a/include/hw/arm/xlnx-zynqmp.h | ||
231 | +++ b/include/hw/arm/xlnx-zynqmp.h | ||
232 | @@ -XXX,XX +XXX,XX @@ | ||
233 | #ifndef XLNX_ZYNQMP_H | ||
234 | |||
235 | #include "qemu-common.h" | ||
236 | -#include "hw/arm/arm.h" | ||
237 | +#include "hw/arm/boot.h" | ||
238 | #include "hw/intc/arm_gic.h" | ||
239 | #include "hw/net/cadence_gem.h" | ||
240 | #include "hw/char/cadence_uart.h" | ||
241 | diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c | ||
242 | index XXXXXXX..XXXXXXX 100644 | ||
243 | --- a/hw/arm/armsse.c | ||
244 | +++ b/hw/arm/armsse.c | ||
245 | @@ -XXX,XX +XXX,XX @@ | ||
246 | #include "hw/sysbus.h" | ||
247 | #include "hw/registerfields.h" | ||
248 | #include "hw/arm/armsse.h" | ||
249 | -#include "hw/arm/arm.h" | ||
250 | +#include "hw/arm/boot.h" | ||
251 | |||
252 | /* Format of the System Information block SYS_CONFIG register */ | ||
253 | typedef enum SysConfigFormat { | ||
254 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | ||
255 | index XXXXXXX..XXXXXXX 100644 | ||
256 | --- a/hw/arm/armv7m.c | ||
257 | +++ b/hw/arm/armv7m.c | ||
258 | @@ -XXX,XX +XXX,XX @@ | ||
259 | #include "qemu-common.h" | ||
260 | #include "cpu.h" | ||
261 | #include "hw/sysbus.h" | ||
262 | -#include "hw/arm/arm.h" | ||
263 | +#include "hw/arm/boot.h" | ||
264 | #include "hw/loader.h" | ||
265 | #include "elf.h" | ||
266 | #include "sysemu/qtest.h" | ||
267 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
268 | index XXXXXXX..XXXXXXX 100644 | ||
269 | --- a/hw/arm/aspeed.c | ||
270 | +++ b/hw/arm/aspeed.c | ||
271 | @@ -XXX,XX +XXX,XX @@ | ||
272 | #include "qemu-common.h" | ||
273 | #include "cpu.h" | ||
274 | #include "exec/address-spaces.h" | ||
275 | -#include "hw/arm/arm.h" | ||
276 | +#include "hw/arm/boot.h" | ||
277 | #include "hw/arm/aspeed.h" | ||
278 | #include "hw/arm/aspeed_soc.h" | ||
279 | #include "hw/boards.h" | ||
280 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | ||
281 | index XXXXXXX..XXXXXXX 100644 | ||
282 | --- a/hw/arm/boot.c | ||
283 | +++ b/hw/arm/boot.c | ||
284 | @@ -XXX,XX +XXX,XX @@ | ||
285 | #include "qapi/error.h" | ||
286 | #include <libfdt.h> | ||
287 | #include "hw/hw.h" | ||
288 | -#include "hw/arm/arm.h" | ||
289 | +#include "hw/arm/boot.h" | ||
290 | #include "hw/arm/linux-boot-if.h" | ||
291 | #include "sysemu/kvm.h" | ||
292 | #include "sysemu/sysemu.h" | ||
293 | diff --git a/hw/arm/collie.c b/hw/arm/collie.c | ||
294 | index XXXXXXX..XXXXXXX 100644 | ||
295 | --- a/hw/arm/collie.c | ||
296 | +++ b/hw/arm/collie.c | ||
297 | @@ -XXX,XX +XXX,XX @@ | ||
298 | #include "hw/sysbus.h" | ||
299 | #include "hw/boards.h" | ||
300 | #include "strongarm.h" | ||
301 | -#include "hw/arm/arm.h" | ||
302 | +#include "hw/arm/boot.h" | ||
303 | #include "hw/block/flash.h" | ||
304 | #include "exec/address-spaces.h" | ||
305 | #include "cpu.h" | ||
306 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
307 | index XXXXXXX..XXXXXXX 100644 | ||
308 | --- a/hw/arm/exynos4210.c | ||
309 | +++ b/hw/arm/exynos4210.c | ||
310 | @@ -XXX,XX +XXX,XX @@ | ||
311 | #include "hw/boards.h" | ||
312 | #include "sysemu/sysemu.h" | ||
313 | #include "hw/sysbus.h" | ||
314 | -#include "hw/arm/arm.h" | ||
315 | +#include "hw/arm/boot.h" | ||
316 | #include "hw/loader.h" | ||
317 | #include "hw/arm/exynos4210.h" | ||
318 | #include "hw/sd/sdhci.h" | ||
319 | diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c | ||
320 | index XXXXXXX..XXXXXXX 100644 | ||
321 | --- a/hw/arm/exynos4_boards.c | ||
322 | +++ b/hw/arm/exynos4_boards.c | ||
323 | @@ -XXX,XX +XXX,XX @@ | ||
324 | #include "sysemu/sysemu.h" | ||
325 | #include "hw/sysbus.h" | ||
326 | #include "net/net.h" | ||
327 | -#include "hw/arm/arm.h" | ||
328 | +#include "hw/arm/boot.h" | ||
329 | #include "exec/address-spaces.h" | ||
330 | #include "hw/arm/exynos4210.h" | ||
331 | #include "hw/net/lan9118.h" | ||
332 | diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c | ||
333 | index XXXXXXX..XXXXXXX 100644 | ||
334 | --- a/hw/arm/highbank.c | ||
335 | +++ b/hw/arm/highbank.c | ||
336 | @@ -XXX,XX +XXX,XX @@ | ||
337 | #include "qemu/osdep.h" | ||
338 | #include "qapi/error.h" | ||
339 | #include "hw/sysbus.h" | ||
340 | -#include "hw/arm/arm.h" | ||
341 | +#include "hw/arm/boot.h" | ||
342 | #include "hw/loader.h" | ||
343 | #include "net/net.h" | ||
344 | #include "sysemu/kvm.h" | ||
345 | diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c | ||
346 | index XXXXXXX..XXXXXXX 100644 | ||
347 | --- a/hw/arm/integratorcp.c | ||
348 | +++ b/hw/arm/integratorcp.c | ||
349 | @@ -XXX,XX +XXX,XX @@ | ||
350 | #include "cpu.h" | ||
351 | #include "hw/sysbus.h" | ||
352 | #include "hw/boards.h" | ||
353 | -#include "hw/arm/arm.h" | ||
354 | +#include "hw/arm/boot.h" | ||
355 | #include "hw/misc/arm_integrator_debug.h" | ||
356 | #include "hw/net/smc91c111.h" | ||
357 | #include "net/net.h" | ||
358 | diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c | ||
359 | index XXXXXXX..XXXXXXX 100644 | ||
360 | --- a/hw/arm/mainstone.c | ||
361 | +++ b/hw/arm/mainstone.c | ||
362 | @@ -XXX,XX +XXX,XX @@ | ||
363 | #include "qapi/error.h" | ||
364 | #include "hw/hw.h" | ||
365 | #include "hw/arm/pxa.h" | ||
366 | -#include "hw/arm/arm.h" | ||
367 | +#include "hw/arm/boot.h" | ||
368 | #include "net/net.h" | ||
369 | #include "hw/net/smc91c111.h" | ||
370 | #include "hw/boards.h" | ||
371 | diff --git a/hw/arm/microbit.c b/hw/arm/microbit.c | ||
372 | index XXXXXXX..XXXXXXX 100644 | ||
373 | --- a/hw/arm/microbit.c | ||
374 | +++ b/hw/arm/microbit.c | ||
375 | @@ -XXX,XX +XXX,XX @@ | ||
376 | #include "qemu/osdep.h" | ||
377 | #include "qapi/error.h" | ||
378 | #include "hw/boards.h" | ||
379 | -#include "hw/arm/arm.h" | ||
380 | +#include "hw/arm/boot.h" | ||
381 | #include "sysemu/sysemu.h" | ||
382 | #include "exec/address-spaces.h" | ||
383 | |||
384 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | ||
385 | index XXXXXXX..XXXXXXX 100644 | ||
386 | --- a/hw/arm/mps2-tz.c | ||
387 | +++ b/hw/arm/mps2-tz.c | ||
388 | @@ -XXX,XX +XXX,XX @@ | ||
389 | #include "qemu/osdep.h" | ||
390 | #include "qapi/error.h" | ||
391 | #include "qemu/error-report.h" | ||
392 | -#include "hw/arm/arm.h" | ||
393 | +#include "hw/arm/boot.h" | ||
394 | #include "hw/arm/armv7m.h" | ||
395 | #include "hw/or-irq.h" | ||
396 | #include "hw/boards.h" | ||
397 | diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c | ||
398 | index XXXXXXX..XXXXXXX 100644 | ||
399 | --- a/hw/arm/mps2.c | ||
400 | +++ b/hw/arm/mps2.c | ||
401 | @@ -XXX,XX +XXX,XX @@ | ||
402 | #include "qemu/osdep.h" | ||
403 | #include "qapi/error.h" | ||
404 | #include "qemu/error-report.h" | ||
405 | -#include "hw/arm/arm.h" | ||
406 | +#include "hw/arm/boot.h" | ||
407 | #include "hw/arm/armv7m.h" | ||
408 | #include "hw/or-irq.h" | ||
409 | #include "hw/boards.h" | ||
410 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c | ||
411 | index XXXXXXX..XXXXXXX 100644 | ||
412 | --- a/hw/arm/msf2-soc.c | ||
413 | +++ b/hw/arm/msf2-soc.c | ||
414 | @@ -XXX,XX +XXX,XX @@ | ||
415 | #include "qemu/units.h" | ||
416 | #include "qapi/error.h" | ||
417 | #include "qemu-common.h" | ||
418 | -#include "hw/arm/arm.h" | ||
419 | #include "exec/address-spaces.h" | ||
420 | #include "hw/char/serial.h" | ||
421 | #include "hw/boards.h" | ||
422 | diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c | ||
423 | index XXXXXXX..XXXXXXX 100644 | ||
424 | --- a/hw/arm/msf2-som.c | ||
425 | +++ b/hw/arm/msf2-som.c | ||
426 | @@ -XXX,XX +XXX,XX @@ | ||
427 | #include "qapi/error.h" | ||
428 | #include "qemu/error-report.h" | ||
429 | #include "hw/boards.h" | ||
430 | -#include "hw/arm/arm.h" | ||
431 | +#include "hw/arm/boot.h" | ||
432 | #include "exec/address-spaces.h" | ||
433 | #include "hw/arm/msf2-soc.h" | ||
434 | #include "cpu.h" | ||
435 | diff --git a/hw/arm/musca.c b/hw/arm/musca.c | ||
436 | index XXXXXXX..XXXXXXX 100644 | ||
437 | --- a/hw/arm/musca.c | ||
438 | +++ b/hw/arm/musca.c | ||
439 | @@ -XXX,XX +XXX,XX @@ | ||
440 | #include "qapi/error.h" | ||
441 | #include "exec/address-spaces.h" | ||
442 | #include "sysemu/sysemu.h" | ||
443 | -#include "hw/arm/arm.h" | ||
444 | +#include "hw/arm/boot.h" | ||
445 | #include "hw/arm/armsse.h" | ||
446 | #include "hw/boards.h" | ||
447 | #include "hw/char/pl011.h" | ||
448 | diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c | ||
449 | index XXXXXXX..XXXXXXX 100644 | ||
450 | --- a/hw/arm/musicpal.c | ||
451 | +++ b/hw/arm/musicpal.c | ||
452 | @@ -XXX,XX +XXX,XX @@ | ||
453 | #include "qemu-common.h" | ||
454 | #include "cpu.h" | ||
455 | #include "hw/sysbus.h" | ||
456 | -#include "hw/arm/arm.h" | ||
457 | +#include "hw/arm/boot.h" | ||
458 | #include "net/net.h" | ||
459 | #include "sysemu/sysemu.h" | ||
460 | #include "hw/boards.h" | ||
461 | diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c | ||
462 | index XXXXXXX..XXXXXXX 100644 | ||
463 | --- a/hw/arm/netduino2.c | ||
464 | +++ b/hw/arm/netduino2.c | ||
465 | @@ -XXX,XX +XXX,XX @@ | ||
466 | #include "hw/boards.h" | ||
467 | #include "qemu/error-report.h" | ||
468 | #include "hw/arm/stm32f205_soc.h" | ||
469 | -#include "hw/arm/arm.h" | ||
470 | +#include "hw/arm/boot.h" | ||
471 | |||
472 | static void netduino2_init(MachineState *machine) | ||
164 | { | 473 | { |
165 | if (qemu_loglevel_mask(CPU_LOG_INT)) { | 474 | diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c |
166 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 475 | index XXXXXXX..XXXXXXX 100644 |
167 | case EXCP_IRQ: | 476 | --- a/hw/arm/nrf51_soc.c |
168 | break; | 477 | +++ b/hw/arm/nrf51_soc.c |
169 | case EXCP_EXCEPTION_EXIT: | 478 | @@ -XXX,XX +XXX,XX @@ |
170 | - do_v7m_exception_exit(cpu); | 479 | #include "qemu/osdep.h" |
171 | - return; | 480 | #include "qapi/error.h" |
172 | + if (env->regs[15] < EXC_RETURN_MIN_MAGIC) { | 481 | #include "qemu-common.h" |
173 | + /* Must be v8M security extension function return */ | 482 | -#include "hw/arm/arm.h" |
174 | + assert(env->regs[15] >= FNC_RETURN_MIN_MAGIC); | 483 | +#include "hw/arm/boot.h" |
175 | + assert(arm_feature(env, ARM_FEATURE_M_SECURITY)); | 484 | #include "hw/sysbus.h" |
176 | + if (do_v7m_function_return(cpu)) { | 485 | #include "hw/boards.h" |
177 | + return; | 486 | #include "hw/misc/unimp.h" |
178 | + } | 487 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c |
179 | + } else { | 488 | index XXXXXXX..XXXXXXX 100644 |
180 | + do_v7m_exception_exit(cpu); | 489 | --- a/hw/arm/nseries.c |
181 | + return; | 490 | +++ b/hw/arm/nseries.c |
182 | + } | 491 | @@ -XXX,XX +XXX,XX @@ |
183 | + break; | 492 | #include "qemu/bswap.h" |
184 | default: | 493 | #include "sysemu/sysemu.h" |
185 | cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); | 494 | #include "hw/arm/omap.h" |
186 | return; /* Never happens. Keep compiler happy. */ | 495 | -#include "hw/arm/arm.h" |
187 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 496 | +#include "hw/arm/boot.h" |
188 | index XXXXXXX..XXXXXXX 100644 | 497 | #include "hw/irq.h" |
189 | --- a/target/arm/translate.c | 498 | #include "ui/console.h" |
190 | +++ b/target/arm/translate.c | 499 | #include "hw/boards.h" |
191 | @@ -XXX,XX +XXX,XX @@ static inline void gen_bx_excret(DisasContext *s, TCGv_i32 var) | 500 | diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c |
192 | * s->base.is_jmp that we need to do the rest of the work later. | 501 | index XXXXXXX..XXXXXXX 100644 |
193 | */ | 502 | --- a/hw/arm/omap1.c |
194 | gen_bx(s, var); | 503 | +++ b/hw/arm/omap1.c |
195 | - if (s->v7m_handler_mode && arm_dc_feature(s, ARM_FEATURE_M)) { | 504 | @@ -XXX,XX +XXX,XX @@ |
196 | + if (arm_dc_feature(s, ARM_FEATURE_M_SECURITY) || | 505 | #include "cpu.h" |
197 | + (s->v7m_handler_mode && arm_dc_feature(s, ARM_FEATURE_M))) { | 506 | #include "hw/boards.h" |
198 | s->base.is_jmp = DISAS_BX_EXCRET; | 507 | #include "hw/hw.h" |
199 | } | 508 | -#include "hw/arm/arm.h" |
200 | } | 509 | +#include "hw/arm/boot.h" |
201 | @@ -XXX,XX +XXX,XX @@ static inline void gen_bx_excret_final_code(DisasContext *s) | 510 | #include "hw/arm/omap.h" |
202 | { | 511 | #include "sysemu/sysemu.h" |
203 | /* Generate the code to finish possible exception return and end the TB */ | 512 | #include "hw/arm/soc_dma.h" |
204 | TCGLabel *excret_label = gen_new_label(); | 513 | diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c |
205 | + uint32_t min_magic; | 514 | index XXXXXXX..XXXXXXX 100644 |
206 | + | 515 | --- a/hw/arm/omap2.c |
207 | + if (arm_dc_feature(s, ARM_FEATURE_M_SECURITY)) { | 516 | +++ b/hw/arm/omap2.c |
208 | + /* Covers FNC_RETURN and EXC_RETURN magic */ | 517 | @@ -XXX,XX +XXX,XX @@ |
209 | + min_magic = FNC_RETURN_MIN_MAGIC; | 518 | #include "sysemu/qtest.h" |
210 | + } else { | 519 | #include "hw/boards.h" |
211 | + /* EXC_RETURN magic only */ | 520 | #include "hw/hw.h" |
212 | + min_magic = EXC_RETURN_MIN_MAGIC; | 521 | -#include "hw/arm/arm.h" |
213 | + } | 522 | +#include "hw/arm/boot.h" |
214 | 523 | #include "hw/arm/omap.h" | |
215 | /* Is the new PC value in the magic range indicating exception return? */ | 524 | #include "sysemu/sysemu.h" |
216 | - tcg_gen_brcondi_i32(TCG_COND_GEU, cpu_R[15], 0xff000000, excret_label); | 525 | #include "qemu/timer.h" |
217 | + tcg_gen_brcondi_i32(TCG_COND_GEU, cpu_R[15], min_magic, excret_label); | 526 | diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c |
218 | /* No: end the TB as we would for a DISAS_JMP */ | 527 | index XXXXXXX..XXXXXXX 100644 |
219 | if (is_singlestepping(s)) { | 528 | --- a/hw/arm/omap_sx1.c |
220 | gen_singlestep_exception(s); | 529 | +++ b/hw/arm/omap_sx1.c |
530 | @@ -XXX,XX +XXX,XX @@ | ||
531 | #include "ui/console.h" | ||
532 | #include "hw/arm/omap.h" | ||
533 | #include "hw/boards.h" | ||
534 | -#include "hw/arm/arm.h" | ||
535 | +#include "hw/arm/boot.h" | ||
536 | #include "hw/block/flash.h" | ||
537 | #include "sysemu/qtest.h" | ||
538 | #include "exec/address-spaces.h" | ||
539 | diff --git a/hw/arm/palm.c b/hw/arm/palm.c | ||
540 | index XXXXXXX..XXXXXXX 100644 | ||
541 | --- a/hw/arm/palm.c | ||
542 | +++ b/hw/arm/palm.c | ||
543 | @@ -XXX,XX +XXX,XX @@ | ||
544 | #include "ui/console.h" | ||
545 | #include "hw/arm/omap.h" | ||
546 | #include "hw/boards.h" | ||
547 | -#include "hw/arm/arm.h" | ||
548 | +#include "hw/arm/boot.h" | ||
549 | #include "hw/input/tsc2xxx.h" | ||
550 | #include "hw/loader.h" | ||
551 | #include "exec/address-spaces.h" | ||
552 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | ||
553 | index XXXXXXX..XXXXXXX 100644 | ||
554 | --- a/hw/arm/raspi.c | ||
555 | +++ b/hw/arm/raspi.c | ||
556 | @@ -XXX,XX +XXX,XX @@ | ||
557 | #include "qemu/error-report.h" | ||
558 | #include "hw/boards.h" | ||
559 | #include "hw/loader.h" | ||
560 | -#include "hw/arm/arm.h" | ||
561 | +#include "hw/arm/boot.h" | ||
562 | #include "sysemu/sysemu.h" | ||
563 | |||
564 | #define SMPBOOT_ADDR 0x300 /* this should leave enough space for ATAGS */ | ||
565 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c | ||
566 | index XXXXXXX..XXXXXXX 100644 | ||
567 | --- a/hw/arm/realview.c | ||
568 | +++ b/hw/arm/realview.c | ||
569 | @@ -XXX,XX +XXX,XX @@ | ||
570 | #include "qemu-common.h" | ||
571 | #include "cpu.h" | ||
572 | #include "hw/sysbus.h" | ||
573 | -#include "hw/arm/arm.h" | ||
574 | +#include "hw/arm/boot.h" | ||
575 | #include "hw/arm/primecell.h" | ||
576 | #include "hw/net/lan9118.h" | ||
577 | #include "hw/net/smc91c111.h" | ||
578 | diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c | ||
579 | index XXXXXXX..XXXXXXX 100644 | ||
580 | --- a/hw/arm/spitz.c | ||
581 | +++ b/hw/arm/spitz.c | ||
582 | @@ -XXX,XX +XXX,XX @@ | ||
583 | #include "qapi/error.h" | ||
584 | #include "hw/hw.h" | ||
585 | #include "hw/arm/pxa.h" | ||
586 | -#include "hw/arm/arm.h" | ||
587 | +#include "hw/arm/boot.h" | ||
588 | #include "sysemu/sysemu.h" | ||
589 | #include "hw/pcmcia.h" | ||
590 | #include "hw/i2c/i2c.h" | ||
591 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
592 | index XXXXXXX..XXXXXXX 100644 | ||
593 | --- a/hw/arm/stellaris.c | ||
594 | +++ b/hw/arm/stellaris.c | ||
595 | @@ -XXX,XX +XXX,XX @@ | ||
596 | #include "qapi/error.h" | ||
597 | #include "hw/sysbus.h" | ||
598 | #include "hw/ssi/ssi.h" | ||
599 | -#include "hw/arm/arm.h" | ||
600 | +#include "hw/arm/boot.h" | ||
601 | #include "qemu/timer.h" | ||
602 | #include "hw/i2c/i2c.h" | ||
603 | #include "net/net.h" | ||
604 | diff --git a/hw/arm/stm32f205_soc.c b/hw/arm/stm32f205_soc.c | ||
605 | index XXXXXXX..XXXXXXX 100644 | ||
606 | --- a/hw/arm/stm32f205_soc.c | ||
607 | +++ b/hw/arm/stm32f205_soc.c | ||
608 | @@ -XXX,XX +XXX,XX @@ | ||
609 | #include "qemu/osdep.h" | ||
610 | #include "qapi/error.h" | ||
611 | #include "qemu-common.h" | ||
612 | -#include "hw/arm/arm.h" | ||
613 | +#include "hw/arm/boot.h" | ||
614 | #include "exec/address-spaces.h" | ||
615 | #include "hw/arm/stm32f205_soc.h" | ||
616 | |||
617 | diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c | ||
618 | index XXXXXXX..XXXXXXX 100644 | ||
619 | --- a/hw/arm/strongarm.c | ||
620 | +++ b/hw/arm/strongarm.c | ||
621 | @@ -XXX,XX +XXX,XX @@ | ||
622 | #include "hw/sysbus.h" | ||
623 | #include "strongarm.h" | ||
624 | #include "qemu/error-report.h" | ||
625 | -#include "hw/arm/arm.h" | ||
626 | +#include "hw/arm/boot.h" | ||
627 | #include "chardev/char-fe.h" | ||
628 | #include "chardev/char-serial.h" | ||
629 | #include "sysemu/sysemu.h" | ||
630 | diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c | ||
631 | index XXXXXXX..XXXXXXX 100644 | ||
632 | --- a/hw/arm/tosa.c | ||
633 | +++ b/hw/arm/tosa.c | ||
634 | @@ -XXX,XX +XXX,XX @@ | ||
635 | #include "qapi/error.h" | ||
636 | #include "hw/hw.h" | ||
637 | #include "hw/arm/pxa.h" | ||
638 | -#include "hw/arm/arm.h" | ||
639 | +#include "hw/arm/boot.h" | ||
640 | #include "hw/arm/sharpsl.h" | ||
641 | #include "hw/pcmcia.h" | ||
642 | #include "hw/boards.h" | ||
643 | diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c | ||
644 | index XXXXXXX..XXXXXXX 100644 | ||
645 | --- a/hw/arm/versatilepb.c | ||
646 | +++ b/hw/arm/versatilepb.c | ||
647 | @@ -XXX,XX +XXX,XX @@ | ||
648 | #include "qemu-common.h" | ||
649 | #include "cpu.h" | ||
650 | #include "hw/sysbus.h" | ||
651 | -#include "hw/arm/arm.h" | ||
652 | +#include "hw/arm/boot.h" | ||
653 | #include "hw/net/smc91c111.h" | ||
654 | #include "net/net.h" | ||
655 | #include "sysemu/sysemu.h" | ||
656 | diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c | ||
657 | index XXXXXXX..XXXXXXX 100644 | ||
658 | --- a/hw/arm/vexpress.c | ||
659 | +++ b/hw/arm/vexpress.c | ||
660 | @@ -XXX,XX +XXX,XX @@ | ||
661 | #include "qemu-common.h" | ||
662 | #include "cpu.h" | ||
663 | #include "hw/sysbus.h" | ||
664 | -#include "hw/arm/arm.h" | ||
665 | +#include "hw/arm/boot.h" | ||
666 | #include "hw/arm/primecell.h" | ||
667 | #include "hw/net/lan9118.h" | ||
668 | #include "hw/i2c/i2c.h" | ||
669 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
670 | index XXXXXXX..XXXXXXX 100644 | ||
671 | --- a/hw/arm/virt.c | ||
672 | +++ b/hw/arm/virt.c | ||
673 | @@ -XXX,XX +XXX,XX @@ | ||
674 | #include "qemu/option.h" | ||
675 | #include "qapi/error.h" | ||
676 | #include "hw/sysbus.h" | ||
677 | -#include "hw/arm/arm.h" | ||
678 | +#include "hw/arm/boot.h" | ||
679 | #include "hw/arm/primecell.h" | ||
680 | #include "hw/arm/virt.h" | ||
681 | #include "hw/block/flash.h" | ||
682 | diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c | ||
683 | index XXXXXXX..XXXXXXX 100644 | ||
684 | --- a/hw/arm/xilinx_zynq.c | ||
685 | +++ b/hw/arm/xilinx_zynq.c | ||
686 | @@ -XXX,XX +XXX,XX @@ | ||
687 | #include "qemu-common.h" | ||
688 | #include "cpu.h" | ||
689 | #include "hw/sysbus.h" | ||
690 | -#include "hw/arm/arm.h" | ||
691 | +#include "hw/arm/boot.h" | ||
692 | #include "net/net.h" | ||
693 | #include "exec/address-spaces.h" | ||
694 | #include "sysemu/sysemu.h" | ||
695 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
696 | index XXXXXXX..XXXXXXX 100644 | ||
697 | --- a/hw/arm/xlnx-versal.c | ||
698 | +++ b/hw/arm/xlnx-versal.c | ||
699 | @@ -XXX,XX +XXX,XX @@ | ||
700 | #include "net/net.h" | ||
701 | #include "sysemu/sysemu.h" | ||
702 | #include "sysemu/kvm.h" | ||
703 | -#include "hw/arm/arm.h" | ||
704 | +#include "hw/arm/boot.h" | ||
705 | #include "kvm_arm.h" | ||
706 | #include "hw/misc/unimp.h" | ||
707 | #include "hw/intc/arm_gicv3_common.h" | ||
708 | diff --git a/hw/arm/z2.c b/hw/arm/z2.c | ||
709 | index XXXXXXX..XXXXXXX 100644 | ||
710 | --- a/hw/arm/z2.c | ||
711 | +++ b/hw/arm/z2.c | ||
712 | @@ -XXX,XX +XXX,XX @@ | ||
713 | #include "qemu/osdep.h" | ||
714 | #include "hw/hw.h" | ||
715 | #include "hw/arm/pxa.h" | ||
716 | -#include "hw/arm/arm.h" | ||
717 | +#include "hw/arm/boot.h" | ||
718 | #include "hw/i2c/i2c.h" | ||
719 | #include "hw/ssi/ssi.h" | ||
720 | #include "hw/boards.h" | ||
221 | -- | 721 | -- |
222 | 2.7.4 | 722 | 2.20.1 |
223 | 723 | ||
224 | 724 | diff view generated by jsdifflib |
1 | Refactor the Thumb decode to do the loads of the instruction words at | 1 | In ich_vmcr_write() we enforce "writes of BPR fields to less than |
---|---|---|---|
2 | the top level rather than only loading the second half of a 32-bit | 2 | their minimum sets them to the minimum" by doing a "read vbpr and |
3 | Thumb insn in the middle of the decode. | 3 | write it back" operation. A typo here meant that we weren't handling |
4 | 4 | writes to these fields correctly, because we were reading from VBPR0 | |
5 | This is simple apart from the awkward case of Thumb1, where the | 5 | but writing to VBPR1. |
6 | BL/BLX prefix and suffix instructions live in what in Thumb2 is the | ||
7 | 32-bit insn space. To handle these we decode enough to identify | ||
8 | whether we're looking at a prefix/suffix that we handle as a 16 bit | ||
9 | insn, or a prefix that we're going to merge with the following suffix | ||
10 | to consider as a 32 bit insn. The translation of the 16 bit cases | ||
11 | then moves from disas_thumb2_insn() to disas_thumb_insn(). | ||
12 | |||
13 | The refactoring has the benefit that we don't need to pass the | ||
14 | CPUARMState* down into the decoder code any more, but the major | ||
15 | reason for doing this is that some Thumb instructions must be always | ||
16 | unconditional regardless of the IT state bits, so we need to know the | ||
17 | whole insn before we emit the "skip this insn if the IT bits and cond | ||
18 | state tell us to" code. (The always unconditional insns are BKPT, | ||
19 | HLT and SG; the last of these is 32 bits.) | ||
20 | 6 | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
23 | Message-id: 1507556919-24992-7-git-send-email-peter.maydell@linaro.org | 9 | Message-id: 20190520162809.2677-4-peter.maydell@linaro.org |
24 | --- | 10 | --- |
25 | target/arm/translate.c | 178 ++++++++++++++++++++++++++++++------------------- | 11 | hw/intc/arm_gicv3_cpuif.c | 2 +- |
26 | 1 file changed, 108 insertions(+), 70 deletions(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
27 | 13 | ||
28 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c |
29 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/translate.c | 16 | --- a/hw/intc/arm_gicv3_cpuif.c |
31 | +++ b/target/arm/translate.c | 17 | +++ b/hw/intc/arm_gicv3_cpuif.c |
32 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 18 | @@ -XXX,XX +XXX,XX @@ static void ich_vmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, |
33 | } | 19 | /* Enforce "writing BPRs to less than minimum sets them to the minimum" |
34 | } | 20 | * by reading and writing back the fields. |
35 | 21 | */ | |
36 | +static bool thumb_insn_is_16bit(DisasContext *s, uint32_t insn) | 22 | - write_vbpr(cs, GICV3_G1, read_vbpr(cs, GICV3_G0)); |
37 | +{ | 23 | + write_vbpr(cs, GICV3_G0, read_vbpr(cs, GICV3_G0)); |
38 | + /* Return true if this is a 16 bit instruction. We must be precise | 24 | write_vbpr(cs, GICV3_G1, read_vbpr(cs, GICV3_G1)); |
39 | + * about this (matching the decode). We assume that s->pc still | 25 | |
40 | + * points to the first 16 bits of the insn. | 26 | gicv3_cpuif_virt_update(cs); |
41 | + */ | ||
42 | + if ((insn >> 11) < 0x1d) { | ||
43 | + /* Definitely a 16-bit instruction */ | ||
44 | + return true; | ||
45 | + } | ||
46 | + | ||
47 | + /* Top five bits 0b11101 / 0b11110 / 0b11111 : this is the | ||
48 | + * first half of a 32-bit Thumb insn. Thumb-1 cores might | ||
49 | + * end up actually treating this as two 16-bit insns, though, | ||
50 | + * if it's half of a bl/blx pair that might span a page boundary. | ||
51 | + */ | ||
52 | + if (arm_dc_feature(s, ARM_FEATURE_THUMB2)) { | ||
53 | + /* Thumb2 cores (including all M profile ones) always treat | ||
54 | + * 32-bit insns as 32-bit. | ||
55 | + */ | ||
56 | + return false; | ||
57 | + } | ||
58 | + | ||
59 | + if ((insn >> 11) == 0x1e && (s->pc < s->next_page_start - 3)) { | ||
60 | + /* 0b1111_0xxx_xxxx_xxxx : BL/BLX prefix, and the suffix | ||
61 | + * is not on the next page; we merge this into a 32-bit | ||
62 | + * insn. | ||
63 | + */ | ||
64 | + return false; | ||
65 | + } | ||
66 | + /* 0b1110_1xxx_xxxx_xxxx : BLX suffix (or UNDEF); | ||
67 | + * 0b1111_1xxx_xxxx_xxxx : BL suffix; | ||
68 | + * 0b1111_0xxx_xxxx_xxxx : BL/BLX prefix on the end of a page | ||
69 | + * -- handle as single 16 bit insn | ||
70 | + */ | ||
71 | + return true; | ||
72 | +} | ||
73 | + | ||
74 | /* Return true if this is a Thumb-2 logical op. */ | ||
75 | static int | ||
76 | thumb2_logic_op(int op) | ||
77 | @@ -XXX,XX +XXX,XX @@ gen_thumb2_data_op(DisasContext *s, int op, int conds, uint32_t shifter_out, | ||
78 | |||
79 | /* Translate a 32-bit thumb instruction. Returns nonzero if the instruction | ||
80 | is not legal. */ | ||
81 | -static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw1) | ||
82 | +static int disas_thumb2_insn(DisasContext *s, uint32_t insn) | ||
83 | { | ||
84 | - uint32_t insn, imm, shift, offset; | ||
85 | + uint32_t imm, shift, offset; | ||
86 | uint32_t rd, rn, rm, rs; | ||
87 | TCGv_i32 tmp; | ||
88 | TCGv_i32 tmp2; | ||
89 | @@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw | ||
90 | int conds; | ||
91 | int logic_cc; | ||
92 | |||
93 | - if (!arm_dc_feature(s, ARM_FEATURE_THUMB2)) { | ||
94 | - /* Thumb-1 cores may need to treat bl and blx as a pair of | ||
95 | - 16-bit instructions to get correct prefetch abort behavior. */ | ||
96 | - insn = insn_hw1; | ||
97 | - if ((insn & (1 << 12)) == 0) { | ||
98 | - ARCH(5); | ||
99 | - /* Second half of blx. */ | ||
100 | - offset = ((insn & 0x7ff) << 1); | ||
101 | - tmp = load_reg(s, 14); | ||
102 | - tcg_gen_addi_i32(tmp, tmp, offset); | ||
103 | - tcg_gen_andi_i32(tmp, tmp, 0xfffffffc); | ||
104 | - | ||
105 | - tmp2 = tcg_temp_new_i32(); | ||
106 | - tcg_gen_movi_i32(tmp2, s->pc | 1); | ||
107 | - store_reg(s, 14, tmp2); | ||
108 | - gen_bx(s, tmp); | ||
109 | - return 0; | ||
110 | - } | ||
111 | - if (insn & (1 << 11)) { | ||
112 | - /* Second half of bl. */ | ||
113 | - offset = ((insn & 0x7ff) << 1) | 1; | ||
114 | - tmp = load_reg(s, 14); | ||
115 | - tcg_gen_addi_i32(tmp, tmp, offset); | ||
116 | - | ||
117 | - tmp2 = tcg_temp_new_i32(); | ||
118 | - tcg_gen_movi_i32(tmp2, s->pc | 1); | ||
119 | - store_reg(s, 14, tmp2); | ||
120 | - gen_bx(s, tmp); | ||
121 | - return 0; | ||
122 | - } | ||
123 | - if ((s->pc & ~TARGET_PAGE_MASK) == 0) { | ||
124 | - /* Instruction spans a page boundary. Implement it as two | ||
125 | - 16-bit instructions in case the second half causes an | ||
126 | - prefetch abort. */ | ||
127 | - offset = ((int32_t)insn << 21) >> 9; | ||
128 | - tcg_gen_movi_i32(cpu_R[14], s->pc + 2 + offset); | ||
129 | - return 0; | ||
130 | - } | ||
131 | - /* Fall through to 32-bit decode. */ | ||
132 | - } | ||
133 | - | ||
134 | - insn = arm_lduw_code(env, s->pc, s->sctlr_b); | ||
135 | - s->pc += 2; | ||
136 | - insn |= (uint32_t)insn_hw1 << 16; | ||
137 | - | ||
138 | + /* The only 32 bit insn that's allowed for Thumb1 is the combined | ||
139 | + * BL/BLX prefix and suffix. | ||
140 | + */ | ||
141 | if ((insn & 0xf800e800) != 0xf000e800) { | ||
142 | ARCH(6T2); | ||
143 | } | ||
144 | @@ -XXX,XX +XXX,XX @@ illegal_op: | ||
145 | return 1; | ||
146 | } | ||
147 | |||
148 | -static void disas_thumb_insn(CPUARMState *env, DisasContext *s) | ||
149 | +static void disas_thumb_insn(DisasContext *s, uint32_t insn) | ||
150 | { | ||
151 | - uint32_t val, insn, op, rm, rn, rd, shift, cond; | ||
152 | + uint32_t val, op, rm, rn, rd, shift, cond; | ||
153 | int32_t offset; | ||
154 | int i; | ||
155 | TCGv_i32 tmp; | ||
156 | TCGv_i32 tmp2; | ||
157 | TCGv_i32 addr; | ||
158 | |||
159 | - if (s->condexec_mask) { | ||
160 | - cond = s->condexec_cond; | ||
161 | - if (cond != 0x0e) { /* Skip conditional when condition is AL. */ | ||
162 | - s->condlabel = gen_new_label(); | ||
163 | - arm_gen_test_cc(cond ^ 1, s->condlabel); | ||
164 | - s->condjmp = 1; | ||
165 | - } | ||
166 | - } | ||
167 | - | ||
168 | - insn = arm_lduw_code(env, s->pc, s->sctlr_b); | ||
169 | - s->pc += 2; | ||
170 | - | ||
171 | switch (insn >> 12) { | ||
172 | case 0: case 1: | ||
173 | |||
174 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) | ||
175 | |||
176 | case 14: | ||
177 | if (insn & (1 << 11)) { | ||
178 | - if (disas_thumb2_insn(env, s, insn)) | ||
179 | - goto undef32; | ||
180 | + /* thumb_insn_is_16bit() ensures we can't get here for | ||
181 | + * a Thumb2 CPU, so this must be a thumb1 split BL/BLX: | ||
182 | + * 0b1110_1xxx_xxxx_xxxx : BLX suffix (or UNDEF) | ||
183 | + */ | ||
184 | + assert(!arm_dc_feature(s, ARM_FEATURE_THUMB2)); | ||
185 | + ARCH(5); | ||
186 | + offset = ((insn & 0x7ff) << 1); | ||
187 | + tmp = load_reg(s, 14); | ||
188 | + tcg_gen_addi_i32(tmp, tmp, offset); | ||
189 | + tcg_gen_andi_i32(tmp, tmp, 0xfffffffc); | ||
190 | + | ||
191 | + tmp2 = tcg_temp_new_i32(); | ||
192 | + tcg_gen_movi_i32(tmp2, s->pc | 1); | ||
193 | + store_reg(s, 14, tmp2); | ||
194 | + gen_bx(s, tmp); | ||
195 | break; | ||
196 | } | ||
197 | /* unconditional branch */ | ||
198 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) | ||
199 | break; | ||
200 | |||
201 | case 15: | ||
202 | - if (disas_thumb2_insn(env, s, insn)) | ||
203 | - goto undef32; | ||
204 | + /* thumb_insn_is_16bit() ensures we can't get here for | ||
205 | + * a Thumb2 CPU, so this must be a thumb1 split BL/BLX. | ||
206 | + */ | ||
207 | + assert(!arm_dc_feature(s, ARM_FEATURE_THUMB2)); | ||
208 | + | ||
209 | + if (insn & (1 << 11)) { | ||
210 | + /* 0b1111_1xxx_xxxx_xxxx : BL suffix */ | ||
211 | + offset = ((insn & 0x7ff) << 1) | 1; | ||
212 | + tmp = load_reg(s, 14); | ||
213 | + tcg_gen_addi_i32(tmp, tmp, offset); | ||
214 | + | ||
215 | + tmp2 = tcg_temp_new_i32(); | ||
216 | + tcg_gen_movi_i32(tmp2, s->pc | 1); | ||
217 | + store_reg(s, 14, tmp2); | ||
218 | + gen_bx(s, tmp); | ||
219 | + } else { | ||
220 | + /* 0b1111_0xxx_xxxx_xxxx : BL/BLX prefix */ | ||
221 | + uint32_t uoffset = ((int32_t)insn << 21) >> 9; | ||
222 | + | ||
223 | + tcg_gen_movi_i32(cpu_R[14], s->pc + 2 + uoffset); | ||
224 | + } | ||
225 | break; | ||
226 | } | ||
227 | return; | ||
228 | -undef32: | ||
229 | - gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized(), | ||
230 | - default_exception_el(s)); | ||
231 | - return; | ||
232 | illegal_op: | ||
233 | undef: | ||
234 | gen_exception_insn(s, 2, EXCP_UDEF, syn_uncategorized(), | ||
235 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
236 | { | ||
237 | DisasContext *dc = container_of(dcbase, DisasContext, base); | ||
238 | CPUARMState *env = cpu->env_ptr; | ||
239 | + uint32_t insn; | ||
240 | + bool is_16bit; | ||
241 | |||
242 | if (arm_pre_translate_insn(dc)) { | ||
243 | return; | ||
244 | } | ||
245 | |||
246 | - disas_thumb_insn(env, dc); | ||
247 | + insn = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
248 | + is_16bit = thumb_insn_is_16bit(dc, insn); | ||
249 | + dc->pc += 2; | ||
250 | + if (!is_16bit) { | ||
251 | + uint32_t insn2 = arm_lduw_code(env, dc->pc, dc->sctlr_b); | ||
252 | + | ||
253 | + insn = insn << 16 | insn2; | ||
254 | + dc->pc += 2; | ||
255 | + } | ||
256 | + | ||
257 | + if (dc->condexec_mask) { | ||
258 | + uint32_t cond = dc->condexec_cond; | ||
259 | + | ||
260 | + if (cond != 0x0e) { /* Skip conditional when condition is AL. */ | ||
261 | + dc->condlabel = gen_new_label(); | ||
262 | + arm_gen_test_cc(cond ^ 1, dc->condlabel); | ||
263 | + dc->condjmp = 1; | ||
264 | + } | ||
265 | + } | ||
266 | + | ||
267 | + if (is_16bit) { | ||
268 | + disas_thumb_insn(dc, insn); | ||
269 | + } else { | ||
270 | + disas_thumb2_insn(dc, insn); | ||
271 | + } | ||
272 | |||
273 | /* Advance the Thumb condexec condition. */ | ||
274 | if (dc->condexec_mask) { | ||
275 | -- | 27 | -- |
276 | 2.7.4 | 28 | 2.20.1 |
277 | 29 | ||
278 | 30 | diff view generated by jsdifflib |
1 | This calculation of the first exception vector in | 1 | The ICC_CTLR_EL3 register includes some bits which are aliases |
---|---|---|---|
2 | the ITNS<n> register being accessed: | 2 | of bits in the ICC_CTLR_EL1(S) and (NS) registers. QEMU chooses |
3 | int startvec = 32 * (offset - 0x380) + NVIC_FIRST_IRQ; | 3 | to keep those bits in the cs->icc_ctlr_el1[] struct fields. |
4 | 4 | Unfortunately a missing '~' in the code to update the bits | |
5 | is incorrect, because offset is in bytes, so we only want | 5 | in those fields meant that writing to ICC_CTLR_EL3 would corrupt |
6 | to multiply by 8. | 6 | the ICC_CLTR_EL1 register values. |
7 | |||
8 | Spotted by Coverity (CID 1381484, CID 1381488), though it is | ||
9 | not correct that it actually overflows the buffer, because | ||
10 | we have a 'startvec + i < s->num_irq' guard. | ||
11 | 7 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
14 | Message-id: 1507650856-11718-1-git-send-email-peter.maydell@linaro.org | 10 | Message-id: 20190520162809.2677-5-peter.maydell@linaro.org |
15 | --- | 11 | --- |
16 | hw/intc/armv7m_nvic.c | 4 ++-- | 12 | hw/intc/arm_gicv3_cpuif.c | 4 ++-- |
17 | 1 file changed, 2 insertions(+), 2 deletions(-) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
18 | 14 | ||
19 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 15 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c |
20 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/intc/armv7m_nvic.c | 17 | --- a/hw/intc/arm_gicv3_cpuif.c |
22 | +++ b/hw/intc/armv7m_nvic.c | 18 | +++ b/hw/intc/arm_gicv3_cpuif.c |
23 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 19 | @@ -XXX,XX +XXX,XX @@ static void icc_ctlr_el3_write(CPUARMState *env, const ARMCPRegInfo *ri, |
24 | return ((s->num_irq - NVIC_FIRST_IRQ) / 32) - 1; | 20 | trace_gicv3_icc_ctlr_el3_write(gicv3_redist_affid(cs), value); |
25 | case 0x380 ... 0x3bf: /* NVIC_ITNS<n> */ | 21 | |
26 | { | 22 | /* *_EL1NS and *_EL1S bits are aliases into the ICC_CTLR_EL1 bits. */ |
27 | - int startvec = 32 * (offset - 0x380) + NVIC_FIRST_IRQ; | 23 | - cs->icc_ctlr_el1[GICV3_NS] &= (ICC_CTLR_EL1_CBPR | ICC_CTLR_EL1_EOIMODE); |
28 | + int startvec = 8 * (offset - 0x380) + NVIC_FIRST_IRQ; | 24 | + cs->icc_ctlr_el1[GICV3_NS] &= ~(ICC_CTLR_EL1_CBPR | ICC_CTLR_EL1_EOIMODE); |
29 | int i; | 25 | if (value & ICC_CTLR_EL3_EOIMODE_EL1NS) { |
30 | 26 | cs->icc_ctlr_el1[GICV3_NS] |= ICC_CTLR_EL1_EOIMODE; | |
31 | if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { | 27 | } |
32 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | 28 | @@ -XXX,XX +XXX,XX @@ static void icc_ctlr_el3_write(CPUARMState *env, const ARMCPRegInfo *ri, |
33 | switch (offset) { | 29 | cs->icc_ctlr_el1[GICV3_NS] |= ICC_CTLR_EL1_CBPR; |
34 | case 0x380 ... 0x3bf: /* NVIC_ITNS<n> */ | 30 | } |
35 | { | 31 | |
36 | - int startvec = 32 * (offset - 0x380) + NVIC_FIRST_IRQ; | 32 | - cs->icc_ctlr_el1[GICV3_S] &= (ICC_CTLR_EL1_CBPR | ICC_CTLR_EL1_EOIMODE); |
37 | + int startvec = 8 * (offset - 0x380) + NVIC_FIRST_IRQ; | 33 | + cs->icc_ctlr_el1[GICV3_S] &= ~(ICC_CTLR_EL1_CBPR | ICC_CTLR_EL1_EOIMODE); |
38 | int i; | 34 | if (value & ICC_CTLR_EL3_EOIMODE_EL1S) { |
39 | 35 | cs->icc_ctlr_el1[GICV3_S] |= ICC_CTLR_EL1_EOIMODE; | |
40 | if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) { | 36 | } |
41 | -- | 37 | -- |
42 | 2.7.4 | 38 | 2.20.1 |
43 | 39 | ||
44 | 40 | diff view generated by jsdifflib |
1 | The code which implements the Thumb1 split BL/BLX instructions | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | is guarded by a check on "not M or THUMB2". All we really need | ||
3 | to check here is "not THUMB2" (and we assume that elsewhere too, | ||
4 | eg in the ARCH(6T2) test that UNDEFs the Thumb2 insns). | ||
5 | 2 | ||
6 | This doesn't change behaviour because all M profile cores | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | have Thumb2 and so ARM_FEATURE_M implies ARM_FEATURE_THUMB2. | 4 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
8 | (v6M implements a very restricted subset of Thumb2, but we | 5 | Message-id: 20190520214342.13709-2-philmd@redhat.com |
9 | can cross that bridge when we get to it with appropriate | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | feature bits.) | 7 | --- |
8 | hw/arm/exynos4_boards.c | 24 ------------------------ | ||
9 | 1 file changed, 24 deletions(-) | ||
11 | 10 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 1507556919-24992-6-git-send-email-peter.maydell@linaro.org | ||
15 | --- | ||
16 | target/arm/translate.c | 3 +-- | ||
17 | 1 file changed, 1 insertion(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/translate.c | 13 | --- a/hw/arm/exynos4_boards.c |
22 | +++ b/target/arm/translate.c | 14 | +++ b/hw/arm/exynos4_boards.c |
23 | @@ -XXX,XX +XXX,XX @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw | 15 | @@ -XXX,XX +XXX,XX @@ |
24 | int conds; | 16 | #include "hw/net/lan9118.h" |
25 | int logic_cc; | 17 | #include "hw/boards.h" |
26 | 18 | ||
27 | - if (!(arm_dc_feature(s, ARM_FEATURE_THUMB2) | 19 | -#undef DEBUG |
28 | - || arm_dc_feature(s, ARM_FEATURE_M))) { | 20 | - |
29 | + if (!arm_dc_feature(s, ARM_FEATURE_THUMB2)) { | 21 | -//#define DEBUG |
30 | /* Thumb-1 cores may need to treat bl and blx as a pair of | 22 | - |
31 | 16-bit instructions to get correct prefetch abort behavior. */ | 23 | -#ifdef DEBUG |
32 | insn = insn_hw1; | 24 | - #undef PRINT_DEBUG |
25 | - #define PRINT_DEBUG(fmt, args...) \ | ||
26 | - do { \ | ||
27 | - fprintf(stderr, " [%s:%d] "fmt, __func__, __LINE__, ##args); \ | ||
28 | - } while (0) | ||
29 | -#else | ||
30 | - #define PRINT_DEBUG(fmt, args...) do {} while (0) | ||
31 | -#endif | ||
32 | - | ||
33 | #define SMDK_LAN9118_BASE_ADDR 0x05000000 | ||
34 | |||
35 | typedef enum Exynos4BoardType { | ||
36 | @@ -XXX,XX +XXX,XX @@ exynos4_boards_init_common(MachineState *machine, | ||
37 | exynos4_board_binfo.gic_cpu_if_addr = | ||
38 | EXYNOS4210_SMP_PRIVATE_BASE_ADDR + 0x100; | ||
39 | |||
40 | - PRINT_DEBUG("\n ram_size: %luMiB [0x%08lx]\n" | ||
41 | - " kernel_filename: %s\n" | ||
42 | - " kernel_cmdline: %s\n" | ||
43 | - " initrd_filename: %s\n", | ||
44 | - exynos4_board_ram_size[board_type] / 1048576, | ||
45 | - exynos4_board_ram_size[board_type], | ||
46 | - machine->kernel_filename, | ||
47 | - machine->kernel_cmdline, | ||
48 | - machine->initrd_filename); | ||
49 | - | ||
50 | exynos4_boards_init_ram(s, get_system_memory(), | ||
51 | exynos4_board_ram_size[board_type]); | ||
52 | |||
33 | -- | 53 | -- |
34 | 2.7.4 | 54 | 2.20.1 |
35 | 55 | ||
36 | 56 | diff view generated by jsdifflib |
1 | From: Cédric Le Goater <clg@kaod.org> | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Initially from Anton D. Kachalov" <mouse@yandex-team.ru> but the SoB was | 3 | It eases code review, unit is explicit. |
4 | missing. | ||
5 | 4 | ||
6 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 5 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> |
7 | Acked-by: Andrew Jeffery <andrew@aj.id.au> | 6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
8 | Message-id: 20170920064915.30027-1-clg@kaod.org | 7 | Message-id: 20190520214342.13709-3-philmd@redhat.com |
9 | [clg: change commit log and subject | ||
10 | replace UL suffix by ULL ] | ||
11 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 9 | --- |
15 | hw/watchdog/wdt_aspeed.c | 4 ++-- | 10 | hw/arm/exynos4_boards.c | 5 +++-- |
16 | 1 file changed, 2 insertions(+), 2 deletions(-) | 11 | 1 file changed, 3 insertions(+), 2 deletions(-) |
17 | 12 | ||
18 | diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c | 13 | diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c |
19 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/watchdog/wdt_aspeed.c | 15 | --- a/hw/arm/exynos4_boards.c |
21 | +++ b/hw/watchdog/wdt_aspeed.c | 16 | +++ b/hw/arm/exynos4_boards.c |
22 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_wdt_read(void *opaque, hwaddr offset, unsigned size) | 17 | @@ -XXX,XX +XXX,XX @@ |
23 | 18 | */ | |
24 | static void aspeed_wdt_reload(AspeedWDTState *s, bool pclk) | 19 | |
25 | { | 20 | #include "qemu/osdep.h" |
26 | - uint32_t reload; | 21 | +#include "qemu/units.h" |
27 | + uint64_t reload; | 22 | #include "qapi/error.h" |
28 | 23 | #include "qemu/error-report.h" | |
29 | if (pclk) { | 24 | #include "qemu-common.h" |
30 | reload = muldiv64(s->regs[WDT_RELOAD_VALUE], NANOSECONDS_PER_SECOND, | 25 | @@ -XXX,XX +XXX,XX @@ static int exynos4_board_smp_bootreg_addr[EXYNOS4_NUM_OF_BOARDS] = { |
31 | s->pclk_freq); | 26 | }; |
32 | } else { | 27 | |
33 | - reload = s->regs[WDT_RELOAD_VALUE] * 1000; | 28 | static unsigned long exynos4_board_ram_size[EXYNOS4_NUM_OF_BOARDS] = { |
34 | + reload = s->regs[WDT_RELOAD_VALUE] * 1000ULL; | 29 | - [EXYNOS4_BOARD_NURI] = 0x40000000, |
35 | } | 30 | - [EXYNOS4_BOARD_SMDKC210] = 0x40000000, |
36 | 31 | + [EXYNOS4_BOARD_NURI] = 1 * GiB, | |
37 | if (aspeed_wdt_is_enabled(s)) { | 32 | + [EXYNOS4_BOARD_SMDKC210] = 1 * GiB, |
33 | }; | ||
34 | |||
35 | static struct arm_boot_info exynos4_board_binfo = { | ||
38 | -- | 36 | -- |
39 | 2.7.4 | 37 | 2.20.1 |
40 | 38 | ||
41 | 39 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Add the M profile secure MMU index values to the switch in | ||
2 | get_a32_user_mem_index() so that LDRT/STRT work correctly | ||
3 | rather than asserting at translate time. | ||
4 | 1 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 1507556919-24992-2-git-send-email-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/translate.c | 4 ++++ | ||
10 | 1 file changed, 4 insertions(+) | ||
11 | |||
12 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/translate.c | ||
15 | +++ b/target/arm/translate.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static inline int get_a32_user_mem_index(DisasContext *s) | ||
17 | case ARMMMUIdx_MPriv: | ||
18 | case ARMMMUIdx_MNegPri: | ||
19 | return arm_to_core_mmu_idx(ARMMMUIdx_MUser); | ||
20 | + case ARMMMUIdx_MSUser: | ||
21 | + case ARMMMUIdx_MSPriv: | ||
22 | + case ARMMMUIdx_MSNegPri: | ||
23 | + return arm_to_core_mmu_idx(ARMMMUIdx_MSUser); | ||
24 | case ARMMMUIdx_S2NS: | ||
25 | default: | ||
26 | g_assert_not_reached(); | ||
27 | -- | ||
28 | 2.7.4 | ||
29 | |||
30 | diff view generated by jsdifflib |
1 | Implement the BLXNS instruction, which allows secure code to | 1 | From: Guenter Roeck <linux@roeck-us.net> |
---|---|---|---|
2 | call non-secure code. | ||
3 | 2 | ||
3 | QEMU already supports pl330. Instantiate it for Exynos4210. | ||
4 | |||
5 | Relevant part of Linux arch/arm/boot/dts/exynos4.dtsi: | ||
6 | |||
7 | / { | ||
8 | soc: soc { | ||
9 | amba { | ||
10 | pdma0: pdma@12680000 { | ||
11 | compatible = "arm,pl330", "arm,primecell"; | ||
12 | reg = <0x12680000 0x1000>; | ||
13 | interrupts = <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>; | ||
14 | clocks = <&clock CLK_PDMA0>; | ||
15 | clock-names = "apb_pclk"; | ||
16 | #dma-cells = <1>; | ||
17 | #dma-channels = <8>; | ||
18 | #dma-requests = <32>; | ||
19 | }; | ||
20 | pdma1: pdma@12690000 { | ||
21 | compatible = "arm,pl330", "arm,primecell"; | ||
22 | reg = <0x12690000 0x1000>; | ||
23 | interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>; | ||
24 | clocks = <&clock CLK_PDMA1>; | ||
25 | clock-names = "apb_pclk"; | ||
26 | #dma-cells = <1>; | ||
27 | #dma-channels = <8>; | ||
28 | #dma-requests = <32>; | ||
29 | }; | ||
30 | mdma1: mdma@12850000 { | ||
31 | compatible = "arm,pl330", "arm,primecell"; | ||
32 | reg = <0x12850000 0x1000>; | ||
33 | interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>; | ||
34 | clocks = <&clock CLK_MDMA>; | ||
35 | clock-names = "apb_pclk"; | ||
36 | #dma-cells = <1>; | ||
37 | #dma-channels = <8>; | ||
38 | #dma-requests = <1>; | ||
39 | }; | ||
40 | }; | ||
41 | }; | ||
42 | }; | ||
43 | |||
44 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
45 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
46 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
47 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
48 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
49 | Message-id: 20190520214342.13709-4-philmd@redhat.com | ||
50 | [PMD: Do not set default qdev properties, create the controllers in the SoC | ||
51 | rather than the board (Peter Maydell), add dtsi in commit message] | ||
52 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
53 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 54 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 1507556919-24992-4-git-send-email-peter.maydell@linaro.org | ||
7 | --- | 55 | --- |
8 | target/arm/helper.h | 1 + | 56 | hw/arm/exynos4210.c | 26 ++++++++++++++++++++++++++ |
9 | target/arm/internals.h | 1 + | 57 | 1 file changed, 26 insertions(+) |
10 | target/arm/helper.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate.c | 17 +++++++++++++-- | ||
12 | 4 files changed, 76 insertions(+), 2 deletions(-) | ||
13 | 58 | ||
14 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 59 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
15 | index XXXXXXX..XXXXXXX 100644 | 60 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.h | 61 | --- a/hw/arm/exynos4210.c |
17 | +++ b/target/arm/helper.h | 62 | +++ b/hw/arm/exynos4210.c |
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_msr, void, env, i32, i32) | 63 | @@ -XXX,XX +XXX,XX @@ |
19 | DEF_HELPER_2(v7m_mrs, i32, env, i32) | 64 | /* EHCI */ |
20 | 65 | #define EXYNOS4210_EHCI_BASE_ADDR 0x12580000 | |
21 | DEF_HELPER_2(v7m_bxns, void, env, i32) | 66 | |
22 | +DEF_HELPER_2(v7m_blxns, void, env, i32) | 67 | +/* DMA */ |
23 | 68 | +#define EXYNOS4210_PL330_BASE0_ADDR 0x12680000 | |
24 | DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32) | 69 | +#define EXYNOS4210_PL330_BASE1_ADDR 0x12690000 |
25 | DEF_HELPER_3(set_cp_reg, void, env, ptr, i32) | 70 | +#define EXYNOS4210_PL330_BASE2_ADDR 0x12850000 |
26 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 71 | + |
27 | index XXXXXXX..XXXXXXX 100644 | 72 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, |
28 | --- a/target/arm/internals.h | 73 | 0x09, 0x00, 0x00, 0x00 }; |
29 | +++ b/target/arm/internals.h | 74 | |
30 | @@ -XXX,XX +XXX,XX @@ static inline bool excp_is_internal(int excp) | 75 | @@ -XXX,XX +XXX,XX @@ static uint64_t exynos4210_calc_affinity(int cpu) |
31 | FIELD(V7M_CONTROL, NPRIV, 0, 1) | 76 | return (0x9 << ARM_AFF1_SHIFT) | cpu; |
32 | FIELD(V7M_CONTROL, SPSEL, 1, 1) | ||
33 | FIELD(V7M_CONTROL, FPCA, 2, 1) | ||
34 | +FIELD(V7M_CONTROL, SFPA, 3, 1) | ||
35 | |||
36 | /* Bit definitions for v7M exception return payload */ | ||
37 | FIELD(V7M_EXCRET, ES, 0, 1) | ||
38 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/helper.c | ||
41 | +++ b/target/arm/helper.c | ||
42 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | ||
43 | g_assert_not_reached(); | ||
44 | } | 77 | } |
45 | 78 | ||
46 | +void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | 79 | +static void pl330_create(uint32_t base, qemu_irq irq, int nreq) |
47 | +{ | 80 | +{ |
48 | + /* translate.c should never generate calls here in user-only mode */ | 81 | + SysBusDevice *busdev; |
49 | + g_assert_not_reached(); | 82 | + DeviceState *dev; |
83 | + | ||
84 | + dev = qdev_create(NULL, "pl330"); | ||
85 | + qdev_prop_set_uint8(dev, "num_periph_req", nreq); | ||
86 | + qdev_init_nofail(dev); | ||
87 | + busdev = SYS_BUS_DEVICE(dev); | ||
88 | + sysbus_mmio_map(busdev, 0, base); | ||
89 | + sysbus_connect_irq(busdev, 0, irq); | ||
50 | +} | 90 | +} |
51 | + | 91 | + |
52 | void switch_mode(CPUARMState *env, int mode) | 92 | Exynos4210State *exynos4210_init(MemoryRegion *system_mem) |
53 | { | 93 | { |
54 | ARMCPU *cpu = arm_env_get_cpu(env); | 94 | Exynos4210State *s = g_new0(Exynos4210State, 1); |
55 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) | 95 | @@ -XXX,XX +XXX,XX @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem) |
56 | env->regs[15] = dest & ~1; | 96 | sysbus_create_simple(TYPE_EXYNOS4210_EHCI, EXYNOS4210_EHCI_BASE_ADDR, |
97 | s->irq_table[exynos4210_get_irq(28, 3)]); | ||
98 | |||
99 | + /*** DMA controllers ***/ | ||
100 | + pl330_create(EXYNOS4210_PL330_BASE0_ADDR, | ||
101 | + qemu_irq_invert(s->irq_table[exynos4210_get_irq(35, 1)]), 32); | ||
102 | + pl330_create(EXYNOS4210_PL330_BASE1_ADDR, | ||
103 | + qemu_irq_invert(s->irq_table[exynos4210_get_irq(36, 1)]), 32); | ||
104 | + pl330_create(EXYNOS4210_PL330_BASE2_ADDR, | ||
105 | + qemu_irq_invert(s->irq_table[exynos4210_get_irq(34, 1)]), 1); | ||
106 | + | ||
107 | return s; | ||
57 | } | 108 | } |
58 | |||
59 | +void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest) | ||
60 | +{ | ||
61 | + /* Handle v7M BLXNS: | ||
62 | + * - bit 0 of the destination address is the target security state | ||
63 | + */ | ||
64 | + | ||
65 | + /* At this point regs[15] is the address just after the BLXNS */ | ||
66 | + uint32_t nextinst = env->regs[15] | 1; | ||
67 | + uint32_t sp = env->regs[13] - 8; | ||
68 | + uint32_t saved_psr; | ||
69 | + | ||
70 | + /* translate.c will have made BLXNS UNDEF unless we're secure */ | ||
71 | + assert(env->v7m.secure); | ||
72 | + | ||
73 | + if (dest & 1) { | ||
74 | + /* target is Secure, so this is just a normal BLX, | ||
75 | + * except that the low bit doesn't indicate Thumb/not. | ||
76 | + */ | ||
77 | + env->regs[14] = nextinst; | ||
78 | + env->thumb = 1; | ||
79 | + env->regs[15] = dest & ~1; | ||
80 | + return; | ||
81 | + } | ||
82 | + | ||
83 | + /* Target is non-secure: first push a stack frame */ | ||
84 | + if (!QEMU_IS_ALIGNED(sp, 8)) { | ||
85 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
86 | + "BLXNS with misaligned SP is UNPREDICTABLE\n"); | ||
87 | + } | ||
88 | + | ||
89 | + saved_psr = env->v7m.exception; | ||
90 | + if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK) { | ||
91 | + saved_psr |= XPSR_SFPA; | ||
92 | + } | ||
93 | + | ||
94 | + /* Note that these stores can throw exceptions on MPU faults */ | ||
95 | + cpu_stl_data(env, sp, nextinst); | ||
96 | + cpu_stl_data(env, sp + 4, saved_psr); | ||
97 | + | ||
98 | + env->regs[13] = sp; | ||
99 | + env->regs[14] = 0xfeffffff; | ||
100 | + if (arm_v7m_is_handler_mode(env)) { | ||
101 | + /* Write a dummy value to IPSR, to avoid leaking the current secure | ||
102 | + * exception number to non-secure code. This is guaranteed not | ||
103 | + * to cause write_v7m_exception() to actually change stacks. | ||
104 | + */ | ||
105 | + write_v7m_exception(env, 1); | ||
106 | + } | ||
107 | + switch_v7m_security_state(env, 0); | ||
108 | + env->thumb = 1; | ||
109 | + env->regs[15] = dest; | ||
110 | +} | ||
111 | + | ||
112 | static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode, | ||
113 | bool spsel) | ||
114 | { | ||
115 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
116 | index XXXXXXX..XXXXXXX 100644 | ||
117 | --- a/target/arm/translate.c | ||
118 | +++ b/target/arm/translate.c | ||
119 | @@ -XXX,XX +XXX,XX @@ static inline void gen_bxns(DisasContext *s, int rm) | ||
120 | s->base.is_jmp = DISAS_EXIT; | ||
121 | } | ||
122 | |||
123 | +static inline void gen_blxns(DisasContext *s, int rm) | ||
124 | +{ | ||
125 | + TCGv_i32 var = load_reg(s, rm); | ||
126 | + | ||
127 | + /* We don't need to sync condexec state, for the same reason as bxns. | ||
128 | + * We do however need to set the PC, because the blxns helper reads it. | ||
129 | + * The blxns helper may throw an exception. | ||
130 | + */ | ||
131 | + gen_set_pc_im(s, s->pc); | ||
132 | + gen_helper_v7m_blxns(cpu_env, var); | ||
133 | + tcg_temp_free_i32(var); | ||
134 | + s->base.is_jmp = DISAS_EXIT; | ||
135 | +} | ||
136 | + | ||
137 | /* Variant of store_reg which uses branch&exchange logic when storing | ||
138 | to r15 in ARM architecture v7 and above. The source must be a temporary | ||
139 | and will be marked as dead. */ | ||
140 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) | ||
141 | goto undef; | ||
142 | } | ||
143 | if (link) { | ||
144 | - /* BLXNS: not yet implemented */ | ||
145 | - goto undef; | ||
146 | + gen_blxns(s, rm); | ||
147 | } else { | ||
148 | gen_bxns(s, rm); | ||
149 | } | ||
150 | -- | 109 | -- |
151 | 2.7.4 | 110 | 2.20.1 |
152 | 111 | ||
153 | 112 | diff view generated by jsdifflib |
1 | Implement the SG instruction, which we emulate 'by hand' in the | 1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> |
---|---|---|---|
2 | exception handling code path. | ||
3 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
4 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
5 | Message-id: 20190520214342.13709-5-philmd@redhat.com | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 1507556919-24992-3-git-send-email-peter.maydell@linaro.org | ||
7 | --- | 7 | --- |
8 | target/arm/helper.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++-- | 8 | include/hw/arm/exynos4210.h | 9 +++++++-- |
9 | 1 file changed, 127 insertions(+), 5 deletions(-) | 9 | hw/arm/exynos4210.c | 28 ++++++++++++++++++++++++---- |
10 | hw/arm/exynos4_boards.c | 9 ++++++--- | ||
11 | 3 files changed, 37 insertions(+), 9 deletions(-) | ||
10 | 12 | ||
11 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 13 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
12 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/helper.c | 15 | --- a/include/hw/arm/exynos4210.h |
14 | +++ b/target/arm/helper.c | 16 | +++ b/include/hw/arm/exynos4210.h |
15 | @@ -XXX,XX +XXX,XX @@ typedef struct V8M_SAttributes { | 17 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210Irq { |
16 | bool irvalid; | 18 | } Exynos4210Irq; |
17 | } V8M_SAttributes; | 19 | |
18 | 20 | typedef struct Exynos4210State { | |
19 | +static void v8m_security_lookup(CPUARMState *env, uint32_t address, | 21 | + /*< private >*/ |
20 | + MMUAccessType access_type, ARMMMUIdx mmu_idx, | 22 | + SysBusDevice parent_obj; |
21 | + V8M_SAttributes *sattrs); | 23 | + /*< public >*/ |
24 | ARMCPU *cpu[EXYNOS4210_NCPUS]; | ||
25 | Exynos4210Irq irqs; | ||
26 | qemu_irq *irq_table; | ||
27 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210State { | ||
28 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; | ||
29 | } Exynos4210State; | ||
30 | |||
31 | +#define TYPE_EXYNOS4210_SOC "exynos4210" | ||
32 | +#define EXYNOS4210_SOC(obj) \ | ||
33 | + OBJECT_CHECK(Exynos4210State, obj, TYPE_EXYNOS4210_SOC) | ||
22 | + | 34 | + |
23 | /* Definitions for the PMCCNTR and PMCR registers */ | 35 | void exynos4210_write_secondary(ARMCPU *cpu, |
24 | #define PMCRD 0x8 | 36 | const struct arm_boot_info *info); |
25 | #define PMCRC 0x4 | 37 | |
26 | @@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx) | 38 | -Exynos4210State *exynos4210_init(MemoryRegion *system_mem); |
27 | } | 39 | - |
40 | /* Initialize exynos4210 IRQ subsystem stub */ | ||
41 | qemu_irq *exynos4210_init_irq(Exynos4210Irq *env); | ||
42 | |||
43 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/hw/arm/exynos4210.c | ||
46 | +++ b/hw/arm/exynos4210.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static void pl330_create(uint32_t base, qemu_irq irq, int nreq) | ||
48 | sysbus_connect_irq(busdev, 0, irq); | ||
28 | } | 49 | } |
29 | 50 | ||
30 | +static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, | 51 | -Exynos4210State *exynos4210_init(MemoryRegion *system_mem) |
31 | + uint32_t addr, uint16_t *insn) | 52 | +static void exynos4210_realize(DeviceState *socdev, Error **errp) |
53 | { | ||
54 | - Exynos4210State *s = g_new0(Exynos4210State, 1); | ||
55 | + Exynos4210State *s = EXYNOS4210_SOC(socdev); | ||
56 | + MemoryRegion *system_mem = get_system_memory(); | ||
57 | qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS]; | ||
58 | SysBusDevice *busdev; | ||
59 | DeviceState *dev; | ||
60 | @@ -XXX,XX +XXX,XX @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem) | ||
61 | qemu_irq_invert(s->irq_table[exynos4210_get_irq(36, 1)]), 32); | ||
62 | pl330_create(EXYNOS4210_PL330_BASE2_ADDR, | ||
63 | qemu_irq_invert(s->irq_table[exynos4210_get_irq(34, 1)]), 1); | ||
64 | - | ||
65 | - return s; | ||
66 | } | ||
67 | + | ||
68 | +static void exynos4210_class_init(ObjectClass *klass, void *data) | ||
32 | +{ | 69 | +{ |
33 | + /* Load a 16-bit portion of a v7M instruction, returning true on success, | 70 | + DeviceClass *dc = DEVICE_CLASS(klass); |
34 | + * or false on failure (in which case we will have pended the appropriate | ||
35 | + * exception). | ||
36 | + * We need to do the instruction fetch's MPU and SAU checks | ||
37 | + * like this because there is no MMU index that would allow | ||
38 | + * doing the load with a single function call. Instead we must | ||
39 | + * first check that the security attributes permit the load | ||
40 | + * and that they don't mismatch on the two halves of the instruction, | ||
41 | + * and then we do the load as a secure load (ie using the security | ||
42 | + * attributes of the address, not the CPU, as architecturally required). | ||
43 | + */ | ||
44 | + CPUState *cs = CPU(cpu); | ||
45 | + CPUARMState *env = &cpu->env; | ||
46 | + V8M_SAttributes sattrs = {}; | ||
47 | + MemTxAttrs attrs = {}; | ||
48 | + ARMMMUFaultInfo fi = {}; | ||
49 | + MemTxResult txres; | ||
50 | + target_ulong page_size; | ||
51 | + hwaddr physaddr; | ||
52 | + int prot; | ||
53 | + uint32_t fsr; | ||
54 | + | 71 | + |
55 | + v8m_security_lookup(env, addr, MMU_INST_FETCH, mmu_idx, &sattrs); | 72 | + dc->realize = exynos4210_realize; |
56 | + if (!sattrs.nsc || sattrs.ns) { | ||
57 | + /* This must be the second half of the insn, and it straddles a | ||
58 | + * region boundary with the second half not being S&NSC. | ||
59 | + */ | ||
60 | + env->v7m.sfsr |= R_V7M_SFSR_INVEP_MASK; | ||
61 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
62 | + qemu_log_mask(CPU_LOG_INT, | ||
63 | + "...really SecureFault with SFSR.INVEP\n"); | ||
64 | + return false; | ||
65 | + } | ||
66 | + if (get_phys_addr(env, addr, MMU_INST_FETCH, mmu_idx, | ||
67 | + &physaddr, &attrs, &prot, &page_size, &fsr, &fi)) { | ||
68 | + /* the MPU lookup failed */ | ||
69 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK; | ||
70 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM, env->v7m.secure); | ||
71 | + qemu_log_mask(CPU_LOG_INT, "...really MemManage with CFSR.IACCVIOL\n"); | ||
72 | + return false; | ||
73 | + } | ||
74 | + *insn = address_space_lduw_le(arm_addressspace(cs, attrs), physaddr, | ||
75 | + attrs, &txres); | ||
76 | + if (txres != MEMTX_OK) { | ||
77 | + env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_IBUSERR_MASK; | ||
78 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); | ||
79 | + qemu_log_mask(CPU_LOG_INT, "...really BusFault with CFSR.IBUSERR\n"); | ||
80 | + return false; | ||
81 | + } | ||
82 | + return true; | ||
83 | +} | 73 | +} |
84 | + | 74 | + |
85 | +static bool v7m_handle_execute_nsc(ARMCPU *cpu) | 75 | +static const TypeInfo exynos4210_info = { |
76 | + .name = TYPE_EXYNOS4210_SOC, | ||
77 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
78 | + .instance_size = sizeof(Exynos4210State), | ||
79 | + .class_init = exynos4210_class_init, | ||
80 | +}; | ||
81 | + | ||
82 | +static void exynos4210_register_types(void) | ||
86 | +{ | 83 | +{ |
87 | + /* Check whether this attempt to execute code in a Secure & NS-Callable | 84 | + type_register_static(&exynos4210_info); |
88 | + * memory region is for an SG instruction; if so, then emulate the | ||
89 | + * effect of the SG instruction and return true. Otherwise pend | ||
90 | + * the correct kind of exception and return false. | ||
91 | + */ | ||
92 | + CPUARMState *env = &cpu->env; | ||
93 | + ARMMMUIdx mmu_idx; | ||
94 | + uint16_t insn; | ||
95 | + | ||
96 | + /* We should never get here unless get_phys_addr_pmsav8() caused | ||
97 | + * an exception for NS executing in S&NSC memory. | ||
98 | + */ | ||
99 | + assert(!env->v7m.secure); | ||
100 | + assert(arm_feature(env, ARM_FEATURE_M_SECURITY)); | ||
101 | + | ||
102 | + /* We want to do the MPU lookup as secure; work out what mmu_idx that is */ | ||
103 | + mmu_idx = arm_v7m_mmu_idx_for_secstate(env, true); | ||
104 | + | ||
105 | + if (!v7m_read_half_insn(cpu, mmu_idx, env->regs[15], &insn)) { | ||
106 | + return false; | ||
107 | + } | ||
108 | + | ||
109 | + if (!env->thumb) { | ||
110 | + goto gen_invep; | ||
111 | + } | ||
112 | + | ||
113 | + if (insn != 0xe97f) { | ||
114 | + /* Not an SG instruction first half (we choose the IMPDEF | ||
115 | + * early-SG-check option). | ||
116 | + */ | ||
117 | + goto gen_invep; | ||
118 | + } | ||
119 | + | ||
120 | + if (!v7m_read_half_insn(cpu, mmu_idx, env->regs[15] + 2, &insn)) { | ||
121 | + return false; | ||
122 | + } | ||
123 | + | ||
124 | + if (insn != 0xe97f) { | ||
125 | + /* Not an SG instruction second half (yes, both halves of the SG | ||
126 | + * insn have the same hex value) | ||
127 | + */ | ||
128 | + goto gen_invep; | ||
129 | + } | ||
130 | + | ||
131 | + /* OK, we have confirmed that we really have an SG instruction. | ||
132 | + * We know we're NS in S memory so don't need to repeat those checks. | ||
133 | + */ | ||
134 | + qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32 | ||
135 | + ", executing it\n", env->regs[15]); | ||
136 | + env->regs[14] &= ~1; | ||
137 | + switch_v7m_security_state(env, true); | ||
138 | + xpsr_write(env, 0, XPSR_IT); | ||
139 | + env->regs[15] += 4; | ||
140 | + return true; | ||
141 | + | ||
142 | +gen_invep: | ||
143 | + env->v7m.sfsr |= R_V7M_SFSR_INVEP_MASK; | ||
144 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | ||
145 | + qemu_log_mask(CPU_LOG_INT, | ||
146 | + "...really SecureFault with SFSR.INVEP\n"); | ||
147 | + return false; | ||
148 | +} | 85 | +} |
149 | + | 86 | + |
150 | void arm_v7m_cpu_do_interrupt(CPUState *cs) | 87 | +type_init(exynos4210_register_types) |
151 | { | 88 | diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c |
152 | ARMCPU *cpu = ARM_CPU(cs); | 89 | index XXXXXXX..XXXXXXX 100644 |
153 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 90 | --- a/hw/arm/exynos4_boards.c |
154 | * the SG instruction have the same security attributes.) | 91 | +++ b/hw/arm/exynos4_boards.c |
155 | * Everything else must generate an INVEP SecureFault, so we | 92 | @@ -XXX,XX +XXX,XX @@ typedef enum Exynos4BoardType { |
156 | * emulate the SG instruction here. | 93 | } Exynos4BoardType; |
157 | - * TODO: actually emulate SG. | 94 | |
158 | */ | 95 | typedef struct Exynos4BoardState { |
159 | - env->v7m.sfsr |= R_V7M_SFSR_INVEP_MASK; | 96 | - Exynos4210State *soc; |
160 | - armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false); | 97 | + Exynos4210State soc; |
161 | - qemu_log_mask(CPU_LOG_INT, | 98 | MemoryRegion dram0_mem; |
162 | - "...really SecureFault with SFSR.INVEP\n"); | 99 | MemoryRegion dram1_mem; |
163 | + if (v7m_handle_execute_nsc(cpu)) { | 100 | } Exynos4BoardState; |
164 | + return; | 101 | @@ -XXX,XX +XXX,XX @@ exynos4_boards_init_common(MachineState *machine, |
165 | + } | 102 | exynos4_boards_init_ram(s, get_system_memory(), |
166 | break; | 103 | exynos4_board_ram_size[board_type]); |
167 | case M_FAKE_FSR_SFAULT: | 104 | |
168 | /* Various flavours of SecureFault for attempts to execute or | 105 | - s->soc = exynos4210_init(get_system_memory()); |
106 | + object_initialize(&s->soc, sizeof(s->soc), TYPE_EXYNOS4210_SOC); | ||
107 | + qdev_set_parent_bus(DEVICE(&s->soc), sysbus_get_default()); | ||
108 | + object_property_set_bool(OBJECT(&s->soc), true, "realized", | ||
109 | + &error_fatal); | ||
110 | |||
111 | return s; | ||
112 | } | ||
113 | @@ -XXX,XX +XXX,XX @@ static void smdkc210_init(MachineState *machine) | ||
114 | EXYNOS4_BOARD_SMDKC210); | ||
115 | |||
116 | lan9215_init(SMDK_LAN9118_BASE_ADDR, | ||
117 | - qemu_irq_invert(s->soc->irq_table[exynos4210_get_irq(37, 1)])); | ||
118 | + qemu_irq_invert(s->soc.irq_table[exynos4210_get_irq(37, 1)])); | ||
119 | arm_load_kernel(ARM_CPU(first_cpu), &exynos4_board_binfo); | ||
120 | } | ||
121 | |||
169 | -- | 122 | -- |
170 | 2.7.4 | 123 | 2.20.1 |
171 | 124 | ||
172 | 125 | diff view generated by jsdifflib |