1 | Small pile of bug fixes for rc1. I've included my patches to get | 1 | The following changes since commit 4cc10cae64c51e17844dc4358481c393d7bf1ed4: |
---|---|---|---|
2 | our docs building with Sphinx 3, just for convenience... | ||
3 | 2 | ||
4 | -- PMM | 3 | Merge remote-tracking branch 'remotes/bonzini-gitlab/tags/for-upstream' into staging (2021-05-06 18:56:17 +0100) |
5 | |||
6 | The following changes since commit b149dea55cce97cb226683d06af61984a1c11e96: | ||
7 | |||
8 | Merge remote-tracking branch 'remotes/cschoenebeck/tags/pull-9p-20201102' into staging (2020-11-02 10:57:48 +0000) | ||
9 | 4 | ||
10 | are available in the Git repository at: | 5 | are available in the Git repository at: |
11 | 6 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201102 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210510 |
13 | 8 | ||
14 | for you to fetch changes up to ffb4fbf90a2f63c9cb33e4bb9f854c79bf04ca4a: | 9 | for you to fetch changes up to 8f96812baa53005f32aece3e30b140826c20aa19: |
15 | 10 | ||
16 | tests/qtest/npcm7xx_rng-test: Disable randomness tests (2020-11-02 16:52:18 +0000) | 11 | hw/arm/xlnx: Fix PHY address for xilinx-zynq-a9 (2021-05-10 13:24:09 +0100) |
17 | 12 | ||
18 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
19 | target-arm queue: | 14 | target-arm queue: |
20 | * target/arm: Fix Neon emulation bugs on big-endian hosts | 15 | * docs: fix link in sbsa description |
21 | * target/arm: fix handling of HCR.FB | 16 | * linux-user/aarch64: Enable hwcap for RND, BTI, and MTE |
22 | * target/arm: fix LORID_EL1 access check | 17 | * target/arm: Fix tlbbits calculation in tlbi_aa64_vae2is_write() |
23 | * disas/capstone: Fix monitor disassembly of >32 bytes | 18 | * target/arm: Split neon and vfp translation to their own |
24 | * hw/arm/smmuv3: Fix potential integer overflow (CID 1432363) | 19 | compilation units |
25 | * hw/arm/boot: fix SVE for EL3 direct kernel boot | 20 | * target/arm: Make WFI a NOP for userspace emulators |
26 | * hw/display/omap_lcdc: Fix potential NULL pointer dereference | 21 | * hw/sd/omap_mmc: Use device_cold_reset() instead of |
27 | * hw/display/exynos4210_fimd: Fix potential NULL pointer dereference | 22 | device_legacy_reset() |
28 | * target/arm: Get correct MMU index for other-security-state | 23 | * include: More fixes for 'extern "C"' block use |
29 | * configure: Test that gio libs from pkg-config work | 24 | * hw/arm/imx25_pdk: Fix error message for invalid RAM size |
30 | * hw/intc/arm_gicv3_cpuif: Make GIC maintenance interrupts work | 25 | * hw/arm/mps2-tz: Implement AN524 memory remapping via machine property |
31 | * docs: Fix building with Sphinx 3 | 26 | * hw/arm/xlnx: Fix PHY address for xilinx-zynq-a9 |
32 | * tests/qtest/npcm7xx_rng-test: Disable randomness tests | ||
33 | 27 | ||
34 | ---------------------------------------------------------------- | 28 | ---------------------------------------------------------------- |
35 | AlexChen (2): | 29 | Alex Bennée (1): |
36 | hw/display/omap_lcdc: Fix potential NULL pointer dereference | 30 | docs: fix link in sbsa description |
37 | hw/display/exynos4210_fimd: Fix potential NULL pointer dereference | ||
38 | 31 | ||
39 | Peter Maydell (9): | 32 | Guenter Roeck (1): |
40 | target/arm: Fix float16 pairwise Neon ops on big-endian hosts | 33 | hw/arm/xlnx: Fix PHY address for xilinx-zynq-a9 |
41 | target/arm: Fix VUDOT/VSDOT (scalar) on big-endian hosts | 34 | |
42 | disas/capstone: Fix monitor disassembly of >32 bytes | 35 | Peter Maydell (22): |
43 | target/arm: Get correct MMU index for other-security-state | 36 | target/arm: Fix tlbbits calculation in tlbi_aa64_vae2is_write() |
44 | configure: Test that gio libs from pkg-config work | 37 | target/arm: Move constant expanders to translate.h |
45 | hw/intc/arm_gicv3_cpuif: Make GIC maintenance interrupts work | 38 | target/arm: Share unallocated_encoding() and gen_exception_insn() |
46 | scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments | 39 | target/arm: Make functions used by m-nocp global |
47 | qemu-option-trace.rst.inc: Don't use option:: markup | 40 | target/arm: Split m-nocp trans functions into their own file |
48 | tests/qtest/npcm7xx_rng-test: Disable randomness tests | 41 | target/arm: Move gen_aa32 functions to translate-a32.h |
42 | target/arm: Move vfp_{load, store}_reg{32, 64} to translate-vfp.c.inc | ||
43 | target/arm: Make functions used by translate-vfp global | ||
44 | target/arm: Make translate-vfp.c.inc its own compilation unit | ||
45 | target/arm: Move vfp_reg_ptr() to translate-neon.c.inc | ||
46 | target/arm: Delete unused typedef | ||
47 | target/arm: Move NeonGenThreeOpEnvFn typedef to translate.h | ||
48 | target/arm: Make functions used by translate-neon global | ||
49 | target/arm: Make translate-neon.c.inc its own compilation unit | ||
50 | target/arm: Make WFI a NOP for userspace emulators | ||
51 | hw/sd/omap_mmc: Use device_cold_reset() instead of device_legacy_reset() | ||
52 | osdep: Make os-win32.h and os-posix.h handle 'extern "C"' themselves | ||
53 | include/qemu/bswap.h: Handle being included outside extern "C" block | ||
54 | include/disas/dis-asm.h: Handle being included outside 'extern "C"' | ||
55 | hw/misc/mps2-scc: Add "QEMU interface" comment | ||
56 | hw/misc/mps2-scc: Support using CFG0 bit 0 for remapping | ||
57 | hw/arm/mps2-tz: Implement AN524 memory remapping via machine property | ||
49 | 58 | ||
50 | Philippe Mathieu-Daudé (1): | 59 | Philippe Mathieu-Daudé (1): |
51 | hw/arm/smmuv3: Fix potential integer overflow (CID 1432363) | 60 | hw/arm/imx25_pdk: Fix error message for invalid RAM size |
52 | 61 | ||
53 | Richard Henderson (11): | 62 | Richard Henderson (1): |
54 | target/arm: Introduce neon_full_reg_offset | 63 | linux-user/aarch64: Enable hwcap for RND, BTI, and MTE |
55 | target/arm: Move neon_element_offset to translate.c | ||
56 | target/arm: Use neon_element_offset in neon_load/store_reg | ||
57 | target/arm: Use neon_element_offset in vfp_reg_offset | ||
58 | target/arm: Add read/write_neon_element32 | ||
59 | target/arm: Expand read/write_neon_element32 to all MemOp | ||
60 | target/arm: Rename neon_load_reg32 to vfp_load_reg32 | ||
61 | target/arm: Add read/write_neon_element64 | ||
62 | target/arm: Rename neon_load_reg64 to vfp_load_reg64 | ||
63 | target/arm: Simplify do_long_3d and do_2scalar_long | ||
64 | target/arm: Improve do_prewiden_3d | ||
65 | 64 | ||
66 | Rémi Denis-Courmont (3): | 65 | docs/system/arm/mps2.rst | 10 + |
67 | target/arm: fix handling of HCR.FB | 66 | docs/system/arm/sbsa.rst | 2 +- |
68 | target/arm: fix LORID_EL1 access check | 67 | include/disas/dis-asm.h | 12 +- |
69 | hw/arm/boot: fix SVE for EL3 direct kernel boot | 68 | include/hw/misc/mps2-scc.h | 21 ++ |
69 | include/qemu/bswap.h | 26 ++- | ||
70 | include/qemu/osdep.h | 8 +- | ||
71 | include/sysemu/os-posix.h | 8 + | ||
72 | include/sysemu/os-win32.h | 8 + | ||
73 | target/arm/translate-a32.h | 144 +++++++++++++ | ||
74 | target/arm/translate-a64.h | 2 - | ||
75 | target/arm/translate.h | 29 +++ | ||
76 | hw/arm/imx25_pdk.c | 5 +- | ||
77 | hw/arm/mps2-tz.c | 108 +++++++++- | ||
78 | hw/arm/xilinx_zynq.c | 2 +- | ||
79 | hw/misc/mps2-scc.c | 13 +- | ||
80 | hw/sd/omap_mmc.c | 2 +- | ||
81 | linux-user/elfload.c | 13 ++ | ||
82 | target/arm/helper.c | 2 +- | ||
83 | target/arm/op_helper.c | 12 ++ | ||
84 | target/arm/translate-a64.c | 15 -- | ||
85 | target/arm/translate-m-nocp.c | 221 ++++++++++++++++++++ | ||
86 | .../arm/{translate-neon.c.inc => translate-neon.c} | 19 +- | ||
87 | .../arm/{translate-vfp.c.inc => translate-vfp.c} | 230 +++------------------ | ||
88 | target/arm/translate.c | 200 ++++-------------- | ||
89 | disas/arm-a64.cc | 2 - | ||
90 | disas/nanomips.cpp | 2 - | ||
91 | target/arm/meson.build | 15 +- | ||
92 | 27 files changed, 718 insertions(+), 413 deletions(-) | ||
93 | create mode 100644 target/arm/translate-a32.h | ||
94 | create mode 100644 target/arm/translate-m-nocp.c | ||
95 | rename target/arm/{translate-neon.c.inc => translate-neon.c} (99%) | ||
96 | rename target/arm/{translate-vfp.c.inc => translate-vfp.c} (94%) | ||
70 | 97 | ||
71 | docs/qemu-option-trace.rst.inc | 6 +- | ||
72 | configure | 10 +- | ||
73 | include/hw/intc/arm_gicv3_common.h | 1 - | ||
74 | disas/capstone.c | 2 +- | ||
75 | hw/arm/boot.c | 3 + | ||
76 | hw/arm/smmuv3.c | 3 +- | ||
77 | hw/display/exynos4210_fimd.c | 4 +- | ||
78 | hw/display/omap_lcdc.c | 10 +- | ||
79 | hw/intc/arm_gicv3_cpuif.c | 5 +- | ||
80 | target/arm/helper.c | 24 +- | ||
81 | target/arm/m_helper.c | 3 +- | ||
82 | target/arm/translate.c | 153 +++++++++--- | ||
83 | target/arm/vec_helper.c | 12 +- | ||
84 | tests/qtest/npcm7xx_rng-test.c | 14 +- | ||
85 | scripts/kernel-doc | 18 +- | ||
86 | target/arm/translate-neon.c.inc | 472 ++++++++++++++++++++----------------- | ||
87 | target/arm/translate-vfp.c.inc | 341 +++++++++++---------------- | ||
88 | 17 files changed, 588 insertions(+), 493 deletions(-) | ||
89 | diff view generated by jsdifflib |
1 | From: AlexChen <alex.chen@huawei.com> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In omap_lcd_interrupts(), the pointer omap_lcd is dereferinced before | 3 | A trailing _ makes all the difference to the rendered link. |
4 | being check if it is valid, which may lead to NULL pointer dereference. | ||
5 | So move the assignment to surface after checking that the omap_lcd is valid | ||
6 | and move surface_bits_per_pixel(surface) to after the surface assignment. | ||
7 | 4 | ||
8 | Reported-by: Euler Robot <euler.robot@huawei.com> | 5 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> |
9 | Signed-off-by: AlexChen <alex.chen@huawei.com> | 6 | Message-id: 20210428131316.31390-1-alex.bennee@linaro.org |
10 | Message-id: 5F9CDB8A.9000001@huawei.com | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 9 | --- |
14 | hw/display/omap_lcdc.c | 10 +++++++--- | 10 | docs/system/arm/sbsa.rst | 2 +- |
15 | 1 file changed, 7 insertions(+), 3 deletions(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
16 | 12 | ||
17 | diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c | 13 | diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/display/omap_lcdc.c | 15 | --- a/docs/system/arm/sbsa.rst |
20 | +++ b/hw/display/omap_lcdc.c | 16 | +++ b/docs/system/arm/sbsa.rst |
21 | @@ -XXX,XX +XXX,XX @@ static void omap_lcd_interrupts(struct omap_lcd_panel_s *s) | 17 | @@ -XXX,XX +XXX,XX @@ Arm Server Base System Architecture Reference board (``sbsa-ref``) |
22 | static void omap_update_display(void *opaque) | 18 | While the `virt` board is a generic board platform that doesn't match |
23 | { | 19 | any real hardware the `sbsa-ref` board intends to look like real |
24 | struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque; | 20 | hardware. The `Server Base System Architecture |
25 | - DisplaySurface *surface = qemu_console_surface(omap_lcd->con); | 21 | -<https://developer.arm.com/documentation/den0029/latest>` defines a |
26 | + DisplaySurface *surface; | 22 | +<https://developer.arm.com/documentation/den0029/latest>`_ defines a |
27 | draw_line_func draw_line; | 23 | minimum base line of hardware support and importantly how the firmware |
28 | int size, height, first, last; | 24 | reports that to any operating system. It is a static system that |
29 | int width, linesize, step, bpp, frame_offset; | 25 | reports a very minimal DT to the firmware for non-discoverable |
30 | hwaddr frame_base; | ||
31 | |||
32 | - if (!omap_lcd || omap_lcd->plm == 1 || !omap_lcd->enable || | ||
33 | - !surface_bits_per_pixel(surface)) { | ||
34 | + if (!omap_lcd || omap_lcd->plm == 1 || !omap_lcd->enable) { | ||
35 | + return; | ||
36 | + } | ||
37 | + | ||
38 | + surface = qemu_console_surface(omap_lcd->con); | ||
39 | + if (!surface_bits_per_pixel(surface)) { | ||
40 | return; | ||
41 | } | ||
42 | |||
43 | -- | 26 | -- |
44 | 2.20.1 | 27 | 2.20.1 |
45 | 28 | ||
46 | 29 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In both cases, we can sink the write-back and perform | 3 | These three features are already enabled by TCG, but are missing |
4 | the accumulate into the normal destination temps. | 4 | their hwcap bits. Update HWCAP2 from linux v5.12. |
5 | 5 | ||
6 | Cc: qemu-stable@nongnu.org (for 6.0.1) | ||
7 | Buglink: https://bugs.launchpad.net/bugs/1926044 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20201030022618.785675-11-richard.henderson@linaro.org | 9 | Message-id: 20210427214108.88503-1-richard.henderson@linaro.org |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | target/arm/translate-neon.c.inc | 23 +++++++++-------------- | 12 | linux-user/elfload.c | 13 +++++++++++++ |
12 | 1 file changed, 9 insertions(+), 14 deletions(-) | 13 | 1 file changed, 13 insertions(+) |
13 | 14 | ||
14 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 15 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-neon.c.inc | 17 | --- a/linux-user/elfload.c |
17 | +++ b/target/arm/translate-neon.c.inc | 18 | +++ b/linux-user/elfload.c |
18 | @@ -XXX,XX +XXX,XX @@ static bool do_long_3d(DisasContext *s, arg_3diff *a, | 19 | @@ -XXX,XX +XXX,XX @@ enum { |
19 | if (accfn) { | 20 | ARM_HWCAP2_A64_SVESM4 = 1 << 6, |
20 | tmp = tcg_temp_new_i64(); | 21 | ARM_HWCAP2_A64_FLAGM2 = 1 << 7, |
21 | read_neon_element64(tmp, a->vd, 0, MO_64); | 22 | ARM_HWCAP2_A64_FRINT = 1 << 8, |
22 | - accfn(tmp, tmp, rd0); | 23 | + ARM_HWCAP2_A64_SVEI8MM = 1 << 9, |
23 | - write_neon_element64(tmp, a->vd, 0, MO_64); | 24 | + ARM_HWCAP2_A64_SVEF32MM = 1 << 10, |
24 | + accfn(rd0, tmp, rd0); | 25 | + ARM_HWCAP2_A64_SVEF64MM = 1 << 11, |
25 | read_neon_element64(tmp, a->vd, 1, MO_64); | 26 | + ARM_HWCAP2_A64_SVEBF16 = 1 << 12, |
26 | - accfn(tmp, tmp, rd1); | 27 | + ARM_HWCAP2_A64_I8MM = 1 << 13, |
27 | - write_neon_element64(tmp, a->vd, 1, MO_64); | 28 | + ARM_HWCAP2_A64_BF16 = 1 << 14, |
28 | + accfn(rd1, tmp, rd1); | 29 | + ARM_HWCAP2_A64_DGH = 1 << 15, |
29 | tcg_temp_free_i64(tmp); | 30 | + ARM_HWCAP2_A64_RNG = 1 << 16, |
30 | - } else { | 31 | + ARM_HWCAP2_A64_BTI = 1 << 17, |
31 | - write_neon_element64(rd0, a->vd, 0, MO_64); | 32 | + ARM_HWCAP2_A64_MTE = 1 << 18, |
32 | - write_neon_element64(rd1, a->vd, 1, MO_64); | 33 | }; |
33 | } | 34 | |
34 | 35 | #define ELF_HWCAP get_elf_hwcap() | |
35 | + write_neon_element64(rd0, a->vd, 0, MO_64); | 36 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap2(void) |
36 | + write_neon_element64(rd1, a->vd, 1, MO_64); | 37 | GET_FEATURE_ID(aa64_dcpodp, ARM_HWCAP2_A64_DCPODP); |
37 | tcg_temp_free_i64(rd0); | 38 | GET_FEATURE_ID(aa64_condm_5, ARM_HWCAP2_A64_FLAGM2); |
38 | tcg_temp_free_i64(rd1); | 39 | GET_FEATURE_ID(aa64_frint, ARM_HWCAP2_A64_FRINT); |
39 | 40 | + GET_FEATURE_ID(aa64_rndr, ARM_HWCAP2_A64_RNG); | |
40 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar_long(DisasContext *s, arg_2scalar *a, | 41 | + GET_FEATURE_ID(aa64_bti, ARM_HWCAP2_A64_BTI); |
41 | if (accfn) { | 42 | + GET_FEATURE_ID(aa64_mte, ARM_HWCAP2_A64_MTE); |
42 | TCGv_i64 t64 = tcg_temp_new_i64(); | 43 | |
43 | read_neon_element64(t64, a->vd, 0, MO_64); | 44 | return hwcaps; |
44 | - accfn(t64, t64, rn0_64); | 45 | } |
45 | - write_neon_element64(t64, a->vd, 0, MO_64); | ||
46 | + accfn(rn0_64, t64, rn0_64); | ||
47 | read_neon_element64(t64, a->vd, 1, MO_64); | ||
48 | - accfn(t64, t64, rn1_64); | ||
49 | - write_neon_element64(t64, a->vd, 1, MO_64); | ||
50 | + accfn(rn1_64, t64, rn1_64); | ||
51 | tcg_temp_free_i64(t64); | ||
52 | - } else { | ||
53 | - write_neon_element64(rn0_64, a->vd, 0, MO_64); | ||
54 | - write_neon_element64(rn1_64, a->vd, 1, MO_64); | ||
55 | } | ||
56 | + | ||
57 | + write_neon_element64(rn0_64, a->vd, 0, MO_64); | ||
58 | + write_neon_element64(rn1_64, a->vd, 1, MO_64); | ||
59 | tcg_temp_free_i64(rn0_64); | ||
60 | tcg_temp_free_i64(rn1_64); | ||
61 | return true; | ||
62 | -- | 46 | -- |
63 | 2.20.1 | 47 | 2.20.1 |
64 | 48 | ||
65 | 49 | diff view generated by jsdifflib |
1 | From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 1 | In tlbi_aa64_vae2is_write() the calculation |
---|---|---|---|
2 | bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2, | ||
3 | pageaddr) | ||
2 | 4 | ||
3 | Secure mode is not exempted from checking SCR_EL3.TLOR, and in the | 5 | has the two arms of the ?: expression reversed. Fix the bug. |
4 | future HCR_EL2.TLOR when S-EL2 is enabled. | ||
5 | 6 | ||
6 | Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 7 | Fixes: b6ad6062f1e5 |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reported-by: Rebecca Cran <rebecca@nuviainc.com> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | ||
12 | Reviewed-by: Rebecca Cran <rebecca@nuviainc.com> | ||
13 | Message-id: 20210420123106.10861-1-peter.maydell@linaro.org | ||
9 | --- | 14 | --- |
10 | target/arm/helper.c | 19 +++++-------------- | 15 | target/arm/helper.c | 2 +- |
11 | 1 file changed, 5 insertions(+), 14 deletions(-) | 16 | 1 file changed, 1 insertion(+), 1 deletion(-) |
12 | 17 | ||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 18 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 20 | --- a/target/arm/helper.c |
16 | +++ b/target/arm/helper.c | 21 | +++ b/target/arm/helper.c |
17 | @@ -XXX,XX +XXX,XX @@ static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) | 22 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri, |
18 | #endif | 23 | uint64_t pageaddr = sextract64(value << 12, 0, 56); |
19 | 24 | bool secure = arm_is_secure_below_el3(env); | |
20 | /* Shared logic between LORID and the rest of the LOR* registers. | 25 | int mask = secure ? ARMMMUIdxBit_SE2 : ARMMMUIdxBit_E2; |
21 | - * Secure state has already been delt with. | 26 | - int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2, |
22 | + * Secure state exclusion has already been dealt with. | 27 | + int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_SE2 : ARMMMUIdx_E2, |
23 | */ | 28 | pageaddr); |
24 | -static CPAccessResult access_lor_ns(CPUARMState *env) | 29 | |
25 | +static CPAccessResult access_lor_ns(CPUARMState *env, | 30 | tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, mask, bits); |
26 | + const ARMCPRegInfo *ri, bool isread) | ||
27 | { | ||
28 | int el = arm_current_el(env); | ||
29 | |||
30 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_lor_ns(CPUARMState *env) | ||
31 | return CP_ACCESS_OK; | ||
32 | } | ||
33 | |||
34 | -static CPAccessResult access_lorid(CPUARMState *env, const ARMCPRegInfo *ri, | ||
35 | - bool isread) | ||
36 | -{ | ||
37 | - if (arm_is_secure_below_el3(env)) { | ||
38 | - /* Access ok in secure mode. */ | ||
39 | - return CP_ACCESS_OK; | ||
40 | - } | ||
41 | - return access_lor_ns(env); | ||
42 | -} | ||
43 | - | ||
44 | static CPAccessResult access_lor_other(CPUARMState *env, | ||
45 | const ARMCPRegInfo *ri, bool isread) | ||
46 | { | ||
47 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_lor_other(CPUARMState *env, | ||
48 | /* Access denied in secure mode. */ | ||
49 | return CP_ACCESS_TRAP; | ||
50 | } | ||
51 | - return access_lor_ns(env); | ||
52 | + return access_lor_ns(env, ri, isread); | ||
53 | } | ||
54 | |||
55 | /* | ||
56 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lor_reginfo[] = { | ||
57 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
58 | { .name = "LORID_EL1", .state = ARM_CP_STATE_AA64, | ||
59 | .opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7, | ||
60 | - .access = PL1_R, .accessfn = access_lorid, | ||
61 | + .access = PL1_R, .accessfn = access_lor_ns, | ||
62 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
63 | REGINFO_SENTINEL | ||
64 | }; | ||
65 | -- | 31 | -- |
66 | 2.20.1 | 32 | 2.20.1 |
67 | 33 | ||
68 | 34 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Some of the constant expanders defined in translate.c are generically |
---|---|---|---|
2 | useful and will be used by the separate C files for VFP and Neon once | ||
3 | they are created; move the expander definitions to translate.h. | ||
2 | 4 | ||
3 | These are the only users of neon_reg_offset, so remove that. | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210430132740.10391-2-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/translate.h | 24 ++++++++++++++++++++++++ | ||
11 | target/arm/translate.c | 24 ------------------------ | ||
12 | 2 files changed, 24 insertions(+), 24 deletions(-) | ||
4 | 13 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 14 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
6 | Message-id: 20201030022618.785675-4-richard.henderson@linaro.org | 15 | index XXXXXXX..XXXXXXX 100644 |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | --- a/target/arm/translate.h |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | +++ b/target/arm/translate.h |
9 | --- | 18 | @@ -XXX,XX +XXX,XX @@ extern TCGv_i32 cpu_NF, cpu_ZF, cpu_CF, cpu_VF; |
10 | target/arm/translate.c | 14 ++------------ | 19 | extern TCGv_i64 cpu_exclusive_addr; |
11 | 1 file changed, 2 insertions(+), 12 deletions(-) | 20 | extern TCGv_i64 cpu_exclusive_val; |
12 | 21 | ||
22 | +/* | ||
23 | + * Constant expanders for the decoders. | ||
24 | + */ | ||
25 | + | ||
26 | +static inline int negate(DisasContext *s, int x) | ||
27 | +{ | ||
28 | + return -x; | ||
29 | +} | ||
30 | + | ||
31 | +static inline int plus_2(DisasContext *s, int x) | ||
32 | +{ | ||
33 | + return x + 2; | ||
34 | +} | ||
35 | + | ||
36 | +static inline int times_2(DisasContext *s, int x) | ||
37 | +{ | ||
38 | + return x * 2; | ||
39 | +} | ||
40 | + | ||
41 | +static inline int times_4(DisasContext *s, int x) | ||
42 | +{ | ||
43 | + return x * 4; | ||
44 | +} | ||
45 | + | ||
46 | static inline int arm_dc_feature(DisasContext *dc, int feature) | ||
47 | { | ||
48 | return (dc->features & (1ULL << feature)) != 0; | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 49 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
14 | index XXXXXXX..XXXXXXX 100644 | 50 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 51 | --- a/target/arm/translate.c |
16 | +++ b/target/arm/translate.c | 52 | +++ b/target/arm/translate.c |
17 | @@ -XXX,XX +XXX,XX @@ static inline long vfp_reg_offset(bool dp, unsigned reg) | 53 | @@ -XXX,XX +XXX,XX @@ static void arm_gen_condlabel(DisasContext *s) |
18 | } | 54 | } |
19 | } | 55 | } |
20 | 56 | ||
21 | -/* Return the offset of a 32-bit piece of a NEON register. | 57 | -/* |
22 | - zero is the least significant end of the register. */ | 58 | - * Constant expanders for the decoders. |
23 | -static inline long | 59 | - */ |
24 | -neon_reg_offset (int reg, int n) | 60 | - |
61 | -static int negate(DisasContext *s, int x) | ||
25 | -{ | 62 | -{ |
26 | - int sreg; | 63 | - return -x; |
27 | - sreg = reg * 2 + n; | ||
28 | - return vfp_reg_offset(0, sreg); | ||
29 | -} | 64 | -} |
30 | - | 65 | - |
31 | static TCGv_i32 neon_load_reg(int reg, int pass) | 66 | -static int plus_2(DisasContext *s, int x) |
32 | { | 67 | -{ |
33 | TCGv_i32 tmp = tcg_temp_new_i32(); | 68 | - return x + 2; |
34 | - tcg_gen_ld_i32(tmp, cpu_env, neon_reg_offset(reg, pass)); | 69 | -} |
35 | + tcg_gen_ld_i32(tmp, cpu_env, neon_element_offset(reg, pass, MO_32)); | 70 | - |
36 | return tmp; | 71 | -static int times_2(DisasContext *s, int x) |
37 | } | 72 | -{ |
38 | 73 | - return x * 2; | |
39 | static void neon_store_reg(int reg, int pass, TCGv_i32 var) | 74 | -} |
40 | { | 75 | - |
41 | - tcg_gen_st_i32(var, cpu_env, neon_reg_offset(reg, pass)); | 76 | -static int times_4(DisasContext *s, int x) |
42 | + tcg_gen_st_i32(var, cpu_env, neon_element_offset(reg, pass, MO_32)); | 77 | -{ |
43 | tcg_temp_free_i32(var); | 78 | - return x * 4; |
44 | } | 79 | -} |
45 | 80 | - | |
81 | /* Flags for the disas_set_da_iss info argument: | ||
82 | * lower bits hold the Rt register number, higher bits are flags. | ||
83 | */ | ||
46 | -- | 84 | -- |
47 | 2.20.1 | 85 | 2.20.1 |
48 | 86 | ||
49 | 87 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The unallocated_encoding() function is the same in both |
---|---|---|---|
2 | translate-a64.c and translate.c; make the translate.c function global | ||
3 | and drop the translate-a64.c version. To do this we need to also | ||
4 | share gen_exception_insn(), which currently exists in two slightly | ||
5 | different versions for A32 and A64: merge those into a single | ||
6 | function that can work for both. | ||
2 | 7 | ||
3 | This seems a bit more readable than using offsetof CPU_DoubleU. | 8 | This will be useful for splitting up translate.c, which will require |
9 | unallocated_encoding() to no longer be file-local. It's also | ||
10 | hopefully less confusing to have only one version of the function | ||
11 | rather than two. | ||
4 | 12 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20201030022618.785675-5-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20210430132740.10391-3-peter.maydell@linaro.org | ||
9 | --- | 16 | --- |
10 | target/arm/translate.c | 13 ++++--------- | 17 | target/arm/translate-a64.h | 2 -- |
11 | 1 file changed, 4 insertions(+), 9 deletions(-) | 18 | target/arm/translate.h | 3 +++ |
19 | target/arm/translate-a64.c | 15 --------------- | ||
20 | target/arm/translate.c | 14 +++++++++----- | ||
21 | 4 files changed, 12 insertions(+), 22 deletions(-) | ||
12 | 22 | ||
23 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/target/arm/translate-a64.h | ||
26 | +++ b/target/arm/translate-a64.h | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | #ifndef TARGET_ARM_TRANSLATE_A64_H | ||
29 | #define TARGET_ARM_TRANSLATE_A64_H | ||
30 | |||
31 | -void unallocated_encoding(DisasContext *s); | ||
32 | - | ||
33 | #define unsupported_encoding(s, insn) \ | ||
34 | do { \ | ||
35 | qemu_log_mask(LOG_UNIMP, \ | ||
36 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/translate.h | ||
39 | +++ b/target/arm/translate.h | ||
40 | @@ -XXX,XX +XXX,XX @@ void arm_free_cc(DisasCompare *cmp); | ||
41 | void arm_jump_cc(DisasCompare *cmp, TCGLabel *label); | ||
42 | void arm_gen_test_cc(int cc, TCGLabel *label); | ||
43 | MemOp pow2_align(unsigned i); | ||
44 | +void unallocated_encoding(DisasContext *s); | ||
45 | +void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, | ||
46 | + uint32_t syn, uint32_t target_el); | ||
47 | |||
48 | /* Return state of Alternate Half-precision flag, caller frees result */ | ||
49 | static inline TCGv_i32 get_ahp_flag(void) | ||
50 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/target/arm/translate-a64.c | ||
53 | +++ b/target/arm/translate-a64.c | ||
54 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, uint64_t pc, int excp) | ||
55 | s->base.is_jmp = DISAS_NORETURN; | ||
56 | } | ||
57 | |||
58 | -static void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, | ||
59 | - uint32_t syndrome, uint32_t target_el) | ||
60 | -{ | ||
61 | - gen_a64_set_pc_im(pc); | ||
62 | - gen_exception(excp, syndrome, target_el); | ||
63 | - s->base.is_jmp = DISAS_NORETURN; | ||
64 | -} | ||
65 | - | ||
66 | static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syndrome) | ||
67 | { | ||
68 | TCGv_i32 tcg_syn; | ||
69 | @@ -XXX,XX +XXX,XX @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) | ||
70 | } | ||
71 | } | ||
72 | |||
73 | -void unallocated_encoding(DisasContext *s) | ||
74 | -{ | ||
75 | - /* Unallocated and reserved encodings are uncategorized */ | ||
76 | - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
77 | - default_exception_el(s)); | ||
78 | -} | ||
79 | - | ||
80 | static void init_tmp_a64_array(DisasContext *s) | ||
81 | { | ||
82 | #ifdef CONFIG_DEBUG_TCG | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 83 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
14 | index XXXXXXX..XXXXXXX 100644 | 84 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 85 | --- a/target/arm/translate.c |
16 | +++ b/target/arm/translate.c | 86 | +++ b/target/arm/translate.c |
17 | @@ -XXX,XX +XXX,XX @@ static long neon_element_offset(int reg, int element, MemOp size) | 87 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, uint32_t pc, int excp) |
18 | return neon_full_reg_offset(reg) + ofs; | 88 | s->base.is_jmp = DISAS_NORETURN; |
19 | } | 89 | } |
20 | 90 | ||
21 | -static inline long vfp_reg_offset(bool dp, unsigned reg) | 91 | -static void gen_exception_insn(DisasContext *s, uint32_t pc, int excp, |
22 | +/* Return the offset of a VFP Dreg (dp = true) or VFP Sreg (dp = false). */ | 92 | - int syn, uint32_t target_el) |
23 | +static long vfp_reg_offset(bool dp, unsigned reg) | 93 | +void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, |
94 | + uint32_t syn, uint32_t target_el) | ||
24 | { | 95 | { |
25 | if (dp) { | 96 | - gen_set_condexec(s); |
26 | - return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]); | 97 | - gen_set_pc_im(s, pc); |
27 | + return neon_element_offset(reg, 0, MO_64); | 98 | + if (s->aarch64) { |
28 | } else { | 99 | + gen_a64_set_pc_im(pc); |
29 | - long ofs = offsetof(CPUARMState, vfp.zregs[reg >> 2].d[(reg >> 1) & 1]); | 100 | + } else { |
30 | - if (reg & 1) { | 101 | + gen_set_condexec(s); |
31 | - ofs += offsetof(CPU_DoubleU, l.upper); | 102 | + gen_set_pc_im(s, pc); |
32 | - } else { | 103 | + } |
33 | - ofs += offsetof(CPU_DoubleU, l.lower); | 104 | gen_exception(excp, syn, target_el); |
34 | - } | 105 | s->base.is_jmp = DISAS_NORETURN; |
35 | - return ofs; | ||
36 | + return neon_element_offset(reg >> 1, reg & 1, MO_32); | ||
37 | } | ||
38 | } | 106 | } |
39 | 107 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) | |
108 | s->base.is_jmp = DISAS_NORETURN; | ||
109 | } | ||
110 | |||
111 | -static void unallocated_encoding(DisasContext *s) | ||
112 | +void unallocated_encoding(DisasContext *s) | ||
113 | { | ||
114 | /* Unallocated and reserved encodings are uncategorized */ | ||
115 | gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), | ||
40 | -- | 116 | -- |
41 | 2.20.1 | 117 | 2.20.1 |
42 | 118 | ||
43 | 119 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | We want to split out the .c.inc files which are currently included |
---|---|---|---|
2 | 2 | into translate.c so they are separate compilation units. To do this | |
3 | We can then use this to improve VMOV (scalar to gp) and | 3 | we need to make some functions which are currently file-local to |
4 | VMOV (gp to scalar) so that we simply perform the memory | 4 | translate.c have global scope; create a translate-a32.h paralleling |
5 | operation that we wanted, rather than inserting or | 5 | the existing translate-a64.h as a place for these declarations to |
6 | extracting from a 32-bit quantity. | 6 | live, so that code moved into the new compilation units can call |
7 | 7 | them. | |
8 | These were the last uses of neon_load/store_reg, so remove them. | 8 | |
9 | 9 | The functions made global here are those required by the | |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | m-nocp.decode functions, except that I have converted the whole |
11 | Message-id: 20201030022618.785675-7-richard.henderson@linaro.org | 11 | family of {read,write}_neon_element* and also both the load_cpu and |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | store_cpu functions for consistency, even though m-nocp only wants a |
13 | few functions from each. | ||
14 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-id: 20210430132740.10391-4-peter.maydell@linaro.org | ||
14 | --- | 18 | --- |
15 | target/arm/translate.c | 50 +++++++++++++----------- | 19 | target/arm/translate-a32.h | 57 ++++++++++++++++++++++++++++++++++ |
16 | target/arm/translate-vfp.c.inc | 71 +++++----------------------------- | 20 | target/arm/translate.c | 39 +++++------------------ |
17 | 2 files changed, 37 insertions(+), 84 deletions(-) | 21 | target/arm/translate-vfp.c.inc | 2 +- |
18 | 22 | 3 files changed, 65 insertions(+), 33 deletions(-) | |
23 | create mode 100644 target/arm/translate-a32.h | ||
24 | |||
25 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h | ||
26 | new file mode 100644 | ||
27 | index XXXXXXX..XXXXXXX | ||
28 | --- /dev/null | ||
29 | +++ b/target/arm/translate-a32.h | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | +/* | ||
32 | + * AArch32 translation, common definitions. | ||
33 | + * | ||
34 | + * Copyright (c) 2021 Linaro, Ltd. | ||
35 | + * | ||
36 | + * This library is free software; you can redistribute it and/or | ||
37 | + * modify it under the terms of the GNU Lesser General Public | ||
38 | + * License as published by the Free Software Foundation; either | ||
39 | + * version 2.1 of the License, or (at your option) any later version. | ||
40 | + * | ||
41 | + * This library is distributed in the hope that it will be useful, | ||
42 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
43 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
44 | + * Lesser General Public License for more details. | ||
45 | + * | ||
46 | + * You should have received a copy of the GNU Lesser General Public | ||
47 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
48 | + */ | ||
49 | + | ||
50 | +#ifndef TARGET_ARM_TRANSLATE_A64_H | ||
51 | +#define TARGET_ARM_TRANSLATE_A64_H | ||
52 | + | ||
53 | +void load_reg_var(DisasContext *s, TCGv_i32 var, int reg); | ||
54 | +void arm_gen_condlabel(DisasContext *s); | ||
55 | +bool vfp_access_check(DisasContext *s); | ||
56 | +void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop); | ||
57 | +void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop); | ||
58 | +void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop); | ||
59 | +void write_neon_element64(TCGv_i64 src, int reg, int ele, MemOp memop); | ||
60 | + | ||
61 | +static inline TCGv_i32 load_cpu_offset(int offset) | ||
62 | +{ | ||
63 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
64 | + tcg_gen_ld_i32(tmp, cpu_env, offset); | ||
65 | + return tmp; | ||
66 | +} | ||
67 | + | ||
68 | +#define load_cpu_field(name) load_cpu_offset(offsetof(CPUARMState, name)) | ||
69 | + | ||
70 | +static inline void store_cpu_offset(TCGv_i32 var, int offset) | ||
71 | +{ | ||
72 | + tcg_gen_st_i32(var, cpu_env, offset); | ||
73 | + tcg_temp_free_i32(var); | ||
74 | +} | ||
75 | + | ||
76 | +#define store_cpu_field(var, name) \ | ||
77 | + store_cpu_offset(var, offsetof(CPUARMState, name)) | ||
78 | + | ||
79 | +/* Create a new temporary and set it to the value of a CPU register. */ | ||
80 | +static inline TCGv_i32 load_reg(DisasContext *s, int reg) | ||
81 | +{ | ||
82 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
83 | + load_reg_var(s, tmp, reg); | ||
84 | + return tmp; | ||
85 | +} | ||
86 | + | ||
87 | +#endif | ||
19 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 88 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
20 | index XXXXXXX..XXXXXXX 100644 | 89 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/translate.c | 90 | --- a/target/arm/translate.c |
22 | +++ b/target/arm/translate.c | 91 | +++ b/target/arm/translate.c |
23 | @@ -XXX,XX +XXX,XX @@ static long neon_full_reg_offset(unsigned reg) | 92 | @@ -XXX,XX +XXX,XX @@ |
24 | * Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | 93 | #define ENABLE_ARCH_8 arm_dc_feature(s, ARM_FEATURE_V8) |
25 | * where 0 is the least significant end of the register. | 94 | |
26 | */ | 95 | #include "translate.h" |
27 | -static long neon_element_offset(int reg, int element, MemOp size) | 96 | +#include "translate-a32.h" |
28 | +static long neon_element_offset(int reg, int element, MemOp memop) | 97 | |
29 | { | 98 | #if defined(CONFIG_USER_ONLY) |
30 | - int element_size = 1 << size; | 99 | #define IS_USER(s) 1 |
31 | + int element_size = 1 << (memop & MO_SIZE); | 100 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void) |
32 | int ofs = element * element_size; | 101 | } |
33 | #ifdef HOST_WORDS_BIGENDIAN | 102 | |
34 | /* | 103 | /* Generate a label used for skipping this instruction */ |
35 | @@ -XXX,XX +XXX,XX @@ static long vfp_reg_offset(bool dp, unsigned reg) | 104 | -static void arm_gen_condlabel(DisasContext *s) |
36 | } | 105 | +void arm_gen_condlabel(DisasContext *s) |
37 | } | 106 | { |
38 | 107 | if (!s->condjmp) { | |
39 | -static TCGv_i32 neon_load_reg(int reg, int pass) | 108 | s->condlabel = gen_new_label(); |
109 | @@ -XXX,XX +XXX,XX @@ static inline int get_a32_user_mem_index(DisasContext *s) | ||
110 | } | ||
111 | } | ||
112 | |||
113 | -static inline TCGv_i32 load_cpu_offset(int offset) | ||
40 | -{ | 114 | -{ |
41 | - TCGv_i32 tmp = tcg_temp_new_i32(); | 115 | - TCGv_i32 tmp = tcg_temp_new_i32(); |
42 | - tcg_gen_ld_i32(tmp, cpu_env, neon_element_offset(reg, pass, MO_32)); | 116 | - tcg_gen_ld_i32(tmp, cpu_env, offset); |
43 | - return tmp; | 117 | - return tmp; |
44 | -} | 118 | -} |
45 | - | 119 | - |
46 | -static void neon_store_reg(int reg, int pass, TCGv_i32 var) | 120 | -#define load_cpu_field(name) load_cpu_offset(offsetof(CPUARMState, name)) |
121 | - | ||
122 | -static inline void store_cpu_offset(TCGv_i32 var, int offset) | ||
47 | -{ | 123 | -{ |
48 | - tcg_gen_st_i32(var, cpu_env, neon_element_offset(reg, pass, MO_32)); | 124 | - tcg_gen_st_i32(var, cpu_env, offset); |
49 | - tcg_temp_free_i32(var); | 125 | - tcg_temp_free_i32(var); |
50 | -} | 126 | -} |
51 | - | 127 | - |
52 | static inline void neon_load_reg64(TCGv_i64 var, int reg) | 128 | -#define store_cpu_field(var, name) \ |
53 | { | 129 | - store_cpu_offset(var, offsetof(CPUARMState, name)) |
54 | tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg)); | 130 | - |
55 | @@ -XXX,XX +XXX,XX @@ static inline void neon_store_reg32(TCGv_i32 var, int reg) | 131 | /* The architectural value of PC. */ |
132 | static uint32_t read_pc(DisasContext *s) | ||
133 | { | ||
134 | @@ -XXX,XX +XXX,XX @@ static uint32_t read_pc(DisasContext *s) | ||
135 | } | ||
136 | |||
137 | /* Set a variable to the value of a CPU register. */ | ||
138 | -static void load_reg_var(DisasContext *s, TCGv_i32 var, int reg) | ||
139 | +void load_reg_var(DisasContext *s, TCGv_i32 var, int reg) | ||
140 | { | ||
141 | if (reg == 15) { | ||
142 | tcg_gen_movi_i32(var, read_pc(s)); | ||
143 | @@ -XXX,XX +XXX,XX @@ static void load_reg_var(DisasContext *s, TCGv_i32 var, int reg) | ||
144 | } | ||
145 | } | ||
146 | |||
147 | -/* Create a new temporary and set it to the value of a CPU register. */ | ||
148 | -static inline TCGv_i32 load_reg(DisasContext *s, int reg) | ||
149 | -{ | ||
150 | - TCGv_i32 tmp = tcg_temp_new_i32(); | ||
151 | - load_reg_var(s, tmp, reg); | ||
152 | - return tmp; | ||
153 | -} | ||
154 | - | ||
155 | /* | ||
156 | * Create a new temp, REG + OFS, except PC is ALIGN(PC, 4). | ||
157 | * This is used for load/store for which use of PC implies (literal), | ||
158 | @@ -XXX,XX +XXX,XX @@ static inline void vfp_store_reg32(TCGv_i32 var, int reg) | ||
56 | tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); | 159 | tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); |
57 | } | 160 | } |
58 | 161 | ||
59 | -static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp size) | 162 | -static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop) |
60 | +static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop) | 163 | +void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop) |
61 | { | 164 | { |
62 | - long off = neon_element_offset(reg, ele, size); | 165 | long off = neon_element_offset(reg, ele, memop); |
63 | + long off = neon_element_offset(reg, ele, memop); | 166 | |
64 | 167 | @@ -XXX,XX +XXX,XX @@ static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop) | |
65 | - switch (size) { | 168 | } |
66 | - case MO_32: | 169 | } |
67 | + switch (memop) { | 170 | |
68 | + case MO_SB: | 171 | -static void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop) |
69 | + tcg_gen_ld8s_i32(dest, cpu_env, off); | 172 | +void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop) |
70 | + break; | 173 | { |
71 | + case MO_UB: | 174 | long off = neon_element_offset(reg, ele, memop); |
72 | + tcg_gen_ld8u_i32(dest, cpu_env, off); | 175 | |
73 | + break; | 176 | @@ -XXX,XX +XXX,XX @@ static void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop) |
74 | + case MO_SW: | 177 | } |
75 | + tcg_gen_ld16s_i32(dest, cpu_env, off); | 178 | } |
76 | + break; | 179 | |
77 | + case MO_UW: | 180 | -static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop) |
78 | + tcg_gen_ld16u_i32(dest, cpu_env, off); | 181 | +void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop) |
79 | + break; | 182 | { |
80 | + case MO_UL: | 183 | long off = neon_element_offset(reg, ele, memop); |
81 | + case MO_SL: | 184 | |
82 | tcg_gen_ld_i32(dest, cpu_env, off); | 185 | @@ -XXX,XX +XXX,XX @@ static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop) |
83 | break; | 186 | } |
84 | default: | 187 | } |
85 | @@ -XXX,XX +XXX,XX @@ static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp size) | 188 | |
86 | } | 189 | -static void write_neon_element64(TCGv_i64 src, int reg, int ele, MemOp memop) |
87 | } | 190 | +void write_neon_element64(TCGv_i64 src, int reg, int ele, MemOp memop) |
88 | 191 | { | |
89 | -static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp size) | 192 | long off = neon_element_offset(reg, ele, memop); |
90 | +static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop) | 193 | |
91 | { | ||
92 | - long off = neon_element_offset(reg, ele, size); | ||
93 | + long off = neon_element_offset(reg, ele, memop); | ||
94 | |||
95 | - switch (size) { | ||
96 | + switch (memop) { | ||
97 | + case MO_8: | ||
98 | + tcg_gen_st8_i32(src, cpu_env, off); | ||
99 | + break; | ||
100 | + case MO_16: | ||
101 | + tcg_gen_st16_i32(src, cpu_env, off); | ||
102 | + break; | ||
103 | case MO_32: | ||
104 | tcg_gen_st_i32(src, cpu_env, off); | ||
105 | break; | ||
106 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | 194 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
107 | index XXXXXXX..XXXXXXX 100644 | 195 | index XXXXXXX..XXXXXXX 100644 |
108 | --- a/target/arm/translate-vfp.c.inc | 196 | --- a/target/arm/translate-vfp.c.inc |
109 | +++ b/target/arm/translate-vfp.c.inc | 197 | +++ b/target/arm/translate-vfp.c.inc |
110 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) | 198 | @@ -XXX,XX +XXX,XX @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) |
111 | { | 199 | * The most usual kind of VFP access check, for everything except |
112 | /* VMOV scalar to general purpose register */ | 200 | * FMXR/FMRX to the always-available special registers. |
113 | TCGv_i32 tmp; | 201 | */ |
114 | - int pass; | 202 | -static bool vfp_access_check(DisasContext *s) |
115 | - uint32_t offset; | 203 | +bool vfp_access_check(DisasContext *s) |
116 | 204 | { | |
117 | - /* SIZE == 2 is a VFP instruction; otherwise NEON. */ | 205 | return full_vfp_access_check(s, false); |
118 | - if (a->size == 2 | ||
119 | + /* SIZE == MO_32 is a VFP instruction; otherwise NEON. */ | ||
120 | + if (a->size == MO_32 | ||
121 | ? !dc_isar_feature(aa32_fpsp_v2, s) | ||
122 | : !arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
123 | return false; | ||
124 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) | ||
125 | return false; | ||
126 | } | ||
127 | |||
128 | - offset = a->index << a->size; | ||
129 | - pass = extract32(offset, 2, 1); | ||
130 | - offset = extract32(offset, 0, 2) * 8; | ||
131 | - | ||
132 | if (!vfp_access_check(s)) { | ||
133 | return true; | ||
134 | } | ||
135 | |||
136 | - tmp = neon_load_reg(a->vn, pass); | ||
137 | - switch (a->size) { | ||
138 | - case 0: | ||
139 | - if (offset) { | ||
140 | - tcg_gen_shri_i32(tmp, tmp, offset); | ||
141 | - } | ||
142 | - if (a->u) { | ||
143 | - gen_uxtb(tmp); | ||
144 | - } else { | ||
145 | - gen_sxtb(tmp); | ||
146 | - } | ||
147 | - break; | ||
148 | - case 1: | ||
149 | - if (a->u) { | ||
150 | - if (offset) { | ||
151 | - tcg_gen_shri_i32(tmp, tmp, 16); | ||
152 | - } else { | ||
153 | - gen_uxth(tmp); | ||
154 | - } | ||
155 | - } else { | ||
156 | - if (offset) { | ||
157 | - tcg_gen_sari_i32(tmp, tmp, 16); | ||
158 | - } else { | ||
159 | - gen_sxth(tmp); | ||
160 | - } | ||
161 | - } | ||
162 | - break; | ||
163 | - case 2: | ||
164 | - break; | ||
165 | - } | ||
166 | + tmp = tcg_temp_new_i32(); | ||
167 | + read_neon_element32(tmp, a->vn, a->index, a->size | (a->u ? 0 : MO_SIGN)); | ||
168 | store_reg(s, a->rt, tmp); | ||
169 | |||
170 | return true; | ||
171 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) | ||
172 | static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a) | ||
173 | { | ||
174 | /* VMOV general purpose register to scalar */ | ||
175 | - TCGv_i32 tmp, tmp2; | ||
176 | - int pass; | ||
177 | - uint32_t offset; | ||
178 | + TCGv_i32 tmp; | ||
179 | |||
180 | - /* SIZE == 2 is a VFP instruction; otherwise NEON. */ | ||
181 | - if (a->size == 2 | ||
182 | + /* SIZE == MO_32 is a VFP instruction; otherwise NEON. */ | ||
183 | + if (a->size == MO_32 | ||
184 | ? !dc_isar_feature(aa32_fpsp_v2, s) | ||
185 | : !arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
186 | return false; | ||
187 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a) | ||
188 | return false; | ||
189 | } | ||
190 | |||
191 | - offset = a->index << a->size; | ||
192 | - pass = extract32(offset, 2, 1); | ||
193 | - offset = extract32(offset, 0, 2) * 8; | ||
194 | - | ||
195 | if (!vfp_access_check(s)) { | ||
196 | return true; | ||
197 | } | ||
198 | |||
199 | tmp = load_reg(s, a->rt); | ||
200 | - switch (a->size) { | ||
201 | - case 0: | ||
202 | - tmp2 = neon_load_reg(a->vn, pass); | ||
203 | - tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 8); | ||
204 | - tcg_temp_free_i32(tmp2); | ||
205 | - break; | ||
206 | - case 1: | ||
207 | - tmp2 = neon_load_reg(a->vn, pass); | ||
208 | - tcg_gen_deposit_i32(tmp, tmp2, tmp, offset, 16); | ||
209 | - tcg_temp_free_i32(tmp2); | ||
210 | - break; | ||
211 | - case 2: | ||
212 | - break; | ||
213 | - } | ||
214 | - neon_store_reg(a->vn, pass, tmp); | ||
215 | + write_neon_element32(tmp, a->vn, a->index, a->size); | ||
216 | + tcg_temp_free_i32(tmp); | ||
217 | |||
218 | return true; | ||
219 | } | 206 | } |
220 | -- | 207 | -- |
221 | 2.20.1 | 208 | 2.20.1 |
222 | 209 | ||
223 | 210 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Currently the trans functions for m-nocp.decode all live in |
---|---|---|---|
2 | translate-vfp.inc.c; move them out into their own translation unit, | ||
3 | translate-m-nocp.c. | ||
2 | 4 | ||
3 | The only uses of this function are for loading VFP | 5 | The trans_* functions here are pure code motion with no changes. |
4 | single-precision values, and nothing to do with NEON. | ||
5 | 6 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20201030022618.785675-8-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210430132740.10391-5-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | target/arm/translate.c | 4 +- | 11 | target/arm/translate-a32.h | 3 + |
12 | target/arm/translate-vfp.c.inc | 184 ++++++++++++++++----------------- | 12 | target/arm/translate-m-nocp.c | 221 +++++++++++++++++++++++++++++++++ |
13 | 2 files changed, 94 insertions(+), 94 deletions(-) | 13 | target/arm/translate.c | 1 - |
14 | target/arm/translate-vfp.c.inc | 196 ----------------------------- | ||
15 | target/arm/meson.build | 3 +- | ||
16 | 5 files changed, 226 insertions(+), 198 deletions(-) | ||
17 | create mode 100644 target/arm/translate-m-nocp.c | ||
14 | 18 | ||
19 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/arm/translate-a32.h | ||
22 | +++ b/target/arm/translate-a32.h | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | #ifndef TARGET_ARM_TRANSLATE_A64_H | ||
25 | #define TARGET_ARM_TRANSLATE_A64_H | ||
26 | |||
27 | +/* Prototypes for autogenerated disassembler functions */ | ||
28 | +bool disas_m_nocp(DisasContext *dc, uint32_t insn); | ||
29 | + | ||
30 | void load_reg_var(DisasContext *s, TCGv_i32 var, int reg); | ||
31 | void arm_gen_condlabel(DisasContext *s); | ||
32 | bool vfp_access_check(DisasContext *s); | ||
33 | diff --git a/target/arm/translate-m-nocp.c b/target/arm/translate-m-nocp.c | ||
34 | new file mode 100644 | ||
35 | index XXXXXXX..XXXXXXX | ||
36 | --- /dev/null | ||
37 | +++ b/target/arm/translate-m-nocp.c | ||
38 | @@ -XXX,XX +XXX,XX @@ | ||
39 | +/* | ||
40 | + * ARM translation: M-profile NOCP special-case instructions | ||
41 | + * | ||
42 | + * Copyright (c) 2020 Linaro, Ltd. | ||
43 | + * | ||
44 | + * This library is free software; you can redistribute it and/or | ||
45 | + * modify it under the terms of the GNU Lesser General Public | ||
46 | + * License as published by the Free Software Foundation; either | ||
47 | + * version 2.1 of the License, or (at your option) any later version. | ||
48 | + * | ||
49 | + * This library is distributed in the hope that it will be useful, | ||
50 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
51 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
52 | + * Lesser General Public License for more details. | ||
53 | + * | ||
54 | + * You should have received a copy of the GNU Lesser General Public | ||
55 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
56 | + */ | ||
57 | + | ||
58 | +#include "qemu/osdep.h" | ||
59 | +#include "tcg/tcg-op.h" | ||
60 | +#include "translate.h" | ||
61 | +#include "translate-a32.h" | ||
62 | + | ||
63 | +#include "decode-m-nocp.c.inc" | ||
64 | + | ||
65 | +/* | ||
66 | + * Decode VLLDM and VLSTM are nonstandard because: | ||
67 | + * * if there is no FPU then these insns must NOP in | ||
68 | + * Secure state and UNDEF in Nonsecure state | ||
69 | + * * if there is an FPU then these insns do not have | ||
70 | + * the usual behaviour that vfp_access_check() provides of | ||
71 | + * being controlled by CPACR/NSACR enable bits or the | ||
72 | + * lazy-stacking logic. | ||
73 | + */ | ||
74 | +static bool trans_VLLDM_VLSTM(DisasContext *s, arg_VLLDM_VLSTM *a) | ||
75 | +{ | ||
76 | + TCGv_i32 fptr; | ||
77 | + | ||
78 | + if (!arm_dc_feature(s, ARM_FEATURE_M) || | ||
79 | + !arm_dc_feature(s, ARM_FEATURE_V8)) { | ||
80 | + return false; | ||
81 | + } | ||
82 | + | ||
83 | + if (a->op) { | ||
84 | + /* | ||
85 | + * T2 encoding ({D0-D31} reglist): v8.1M and up. We choose not | ||
86 | + * to take the IMPDEF option to make memory accesses to the stack | ||
87 | + * slots that correspond to the D16-D31 registers (discarding | ||
88 | + * read data and writing UNKNOWN values), so for us the T2 | ||
89 | + * encoding behaves identically to the T1 encoding. | ||
90 | + */ | ||
91 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
92 | + return false; | ||
93 | + } | ||
94 | + } else { | ||
95 | + /* | ||
96 | + * T1 encoding ({D0-D15} reglist); undef if we have 32 Dregs. | ||
97 | + * This is currently architecturally impossible, but we add the | ||
98 | + * check to stay in line with the pseudocode. Note that we must | ||
99 | + * emit code for the UNDEF so it takes precedence over the NOCP. | ||
100 | + */ | ||
101 | + if (dc_isar_feature(aa32_simd_r32, s)) { | ||
102 | + unallocated_encoding(s); | ||
103 | + return true; | ||
104 | + } | ||
105 | + } | ||
106 | + | ||
107 | + /* | ||
108 | + * If not secure, UNDEF. We must emit code for this | ||
109 | + * rather than returning false so that this takes | ||
110 | + * precedence over the m-nocp.decode NOCP fallback. | ||
111 | + */ | ||
112 | + if (!s->v8m_secure) { | ||
113 | + unallocated_encoding(s); | ||
114 | + return true; | ||
115 | + } | ||
116 | + /* If no fpu, NOP. */ | ||
117 | + if (!dc_isar_feature(aa32_vfp, s)) { | ||
118 | + return true; | ||
119 | + } | ||
120 | + | ||
121 | + fptr = load_reg(s, a->rn); | ||
122 | + if (a->l) { | ||
123 | + gen_helper_v7m_vlldm(cpu_env, fptr); | ||
124 | + } else { | ||
125 | + gen_helper_v7m_vlstm(cpu_env, fptr); | ||
126 | + } | ||
127 | + tcg_temp_free_i32(fptr); | ||
128 | + | ||
129 | + /* End the TB, because we have updated FP control bits */ | ||
130 | + s->base.is_jmp = DISAS_UPDATE_EXIT; | ||
131 | + return true; | ||
132 | +} | ||
133 | + | ||
134 | +static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a) | ||
135 | +{ | ||
136 | + int btmreg, topreg; | ||
137 | + TCGv_i64 zero; | ||
138 | + TCGv_i32 aspen, sfpa; | ||
139 | + | ||
140 | + if (!dc_isar_feature(aa32_m_sec_state, s)) { | ||
141 | + /* Before v8.1M, fall through in decode to NOCP check */ | ||
142 | + return false; | ||
143 | + } | ||
144 | + | ||
145 | + /* Explicitly UNDEF because this takes precedence over NOCP */ | ||
146 | + if (!arm_dc_feature(s, ARM_FEATURE_M_MAIN) || !s->v8m_secure) { | ||
147 | + unallocated_encoding(s); | ||
148 | + return true; | ||
149 | + } | ||
150 | + | ||
151 | + if (!dc_isar_feature(aa32_vfp_simd, s)) { | ||
152 | + /* NOP if we have neither FP nor MVE */ | ||
153 | + return true; | ||
154 | + } | ||
155 | + | ||
156 | + /* | ||
157 | + * If FPCCR.ASPEN != 0 && CONTROL_S.SFPA == 0 then there is no | ||
158 | + * active floating point context so we must NOP (without doing | ||
159 | + * any lazy state preservation or the NOCP check). | ||
160 | + */ | ||
161 | + aspen = load_cpu_field(v7m.fpccr[M_REG_S]); | ||
162 | + sfpa = load_cpu_field(v7m.control[M_REG_S]); | ||
163 | + tcg_gen_andi_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
164 | + tcg_gen_xori_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | ||
165 | + tcg_gen_andi_i32(sfpa, sfpa, R_V7M_CONTROL_SFPA_MASK); | ||
166 | + tcg_gen_or_i32(sfpa, sfpa, aspen); | ||
167 | + arm_gen_condlabel(s); | ||
168 | + tcg_gen_brcondi_i32(TCG_COND_EQ, sfpa, 0, s->condlabel); | ||
169 | + | ||
170 | + if (s->fp_excp_el != 0) { | ||
171 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
172 | + syn_uncategorized(), s->fp_excp_el); | ||
173 | + return true; | ||
174 | + } | ||
175 | + | ||
176 | + topreg = a->vd + a->imm - 1; | ||
177 | + btmreg = a->vd; | ||
178 | + | ||
179 | + /* Convert to Sreg numbers if the insn specified in Dregs */ | ||
180 | + if (a->size == 3) { | ||
181 | + topreg = topreg * 2 + 1; | ||
182 | + btmreg *= 2; | ||
183 | + } | ||
184 | + | ||
185 | + if (topreg > 63 || (topreg > 31 && !(topreg & 1))) { | ||
186 | + /* UNPREDICTABLE: we choose to undef */ | ||
187 | + unallocated_encoding(s); | ||
188 | + return true; | ||
189 | + } | ||
190 | + | ||
191 | + /* Silently ignore requests to clear D16-D31 if they don't exist */ | ||
192 | + if (topreg > 31 && !dc_isar_feature(aa32_simd_r32, s)) { | ||
193 | + topreg = 31; | ||
194 | + } | ||
195 | + | ||
196 | + if (!vfp_access_check(s)) { | ||
197 | + return true; | ||
198 | + } | ||
199 | + | ||
200 | + /* Zero the Sregs from btmreg to topreg inclusive. */ | ||
201 | + zero = tcg_const_i64(0); | ||
202 | + if (btmreg & 1) { | ||
203 | + write_neon_element64(zero, btmreg >> 1, 1, MO_32); | ||
204 | + btmreg++; | ||
205 | + } | ||
206 | + for (; btmreg + 1 <= topreg; btmreg += 2) { | ||
207 | + write_neon_element64(zero, btmreg >> 1, 0, MO_64); | ||
208 | + } | ||
209 | + if (btmreg == topreg) { | ||
210 | + write_neon_element64(zero, btmreg >> 1, 0, MO_32); | ||
211 | + btmreg++; | ||
212 | + } | ||
213 | + assert(btmreg == topreg + 1); | ||
214 | + /* TODO: when MVE is implemented, zero VPR here */ | ||
215 | + return true; | ||
216 | +} | ||
217 | + | ||
218 | +static bool trans_NOCP(DisasContext *s, arg_nocp *a) | ||
219 | +{ | ||
220 | + /* | ||
221 | + * Handle M-profile early check for disabled coprocessor: | ||
222 | + * all we need to do here is emit the NOCP exception if | ||
223 | + * the coprocessor is disabled. Otherwise we return false | ||
224 | + * and the real VFP/etc decode will handle the insn. | ||
225 | + */ | ||
226 | + assert(arm_dc_feature(s, ARM_FEATURE_M)); | ||
227 | + | ||
228 | + if (a->cp == 11) { | ||
229 | + a->cp = 10; | ||
230 | + } | ||
231 | + if (arm_dc_feature(s, ARM_FEATURE_V8_1M) && | ||
232 | + (a->cp == 8 || a->cp == 9 || a->cp == 14 || a->cp == 15)) { | ||
233 | + /* in v8.1M cp 8, 9, 14, 15 also are governed by the cp10 enable */ | ||
234 | + a->cp = 10; | ||
235 | + } | ||
236 | + | ||
237 | + if (a->cp != 10) { | ||
238 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
239 | + syn_uncategorized(), default_exception_el(s)); | ||
240 | + return true; | ||
241 | + } | ||
242 | + | ||
243 | + if (s->fp_excp_el != 0) { | ||
244 | + gen_exception_insn(s, s->pc_curr, EXCP_NOCP, | ||
245 | + syn_uncategorized(), s->fp_excp_el); | ||
246 | + return true; | ||
247 | + } | ||
248 | + | ||
249 | + return false; | ||
250 | +} | ||
251 | + | ||
252 | +static bool trans_NOCP_8_1(DisasContext *s, arg_nocp *a) | ||
253 | +{ | ||
254 | + /* This range needs a coprocessor check for v8.1M and later only */ | ||
255 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
256 | + return false; | ||
257 | + } | ||
258 | + return trans_NOCP(s, a); | ||
259 | +} | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 260 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
16 | index XXXXXXX..XXXXXXX 100644 | 261 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 262 | --- a/target/arm/translate.c |
18 | +++ b/target/arm/translate.c | 263 | +++ b/target/arm/translate.c |
19 | @@ -XXX,XX +XXX,XX @@ static inline void neon_store_reg64(TCGv_i64 var, int reg) | 264 | @@ -XXX,XX +XXX,XX @@ static TCGv_ptr vfp_reg_ptr(bool dp, int reg) |
20 | tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(1, reg)); | 265 | #define ARM_CP_RW_BIT (1 << 20) |
21 | } | 266 | |
22 | 267 | /* Include the VFP and Neon decoders */ | |
23 | -static inline void neon_load_reg32(TCGv_i32 var, int reg) | 268 | -#include "decode-m-nocp.c.inc" |
24 | +static inline void vfp_load_reg32(TCGv_i32 var, int reg) | 269 | #include "translate-vfp.c.inc" |
25 | { | 270 | #include "translate-neon.c.inc" |
26 | tcg_gen_ld_i32(var, cpu_env, vfp_reg_offset(false, reg)); | 271 | |
27 | } | ||
28 | |||
29 | -static inline void neon_store_reg32(TCGv_i32 var, int reg) | ||
30 | +static inline void vfp_store_reg32(TCGv_i32 var, int reg) | ||
31 | { | ||
32 | tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); | ||
33 | } | ||
34 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | 272 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
35 | index XXXXXXX..XXXXXXX 100644 | 273 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/translate-vfp.c.inc | 274 | --- a/target/arm/translate-vfp.c.inc |
37 | +++ b/target/arm/translate-vfp.c.inc | 275 | +++ b/target/arm/translate-vfp.c.inc |
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | 276 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a) |
39 | frn = tcg_temp_new_i32(); | ||
40 | frm = tcg_temp_new_i32(); | ||
41 | dest = tcg_temp_new_i32(); | ||
42 | - neon_load_reg32(frn, rn); | ||
43 | - neon_load_reg32(frm, rm); | ||
44 | + vfp_load_reg32(frn, rn); | ||
45 | + vfp_load_reg32(frm, rm); | ||
46 | switch (a->cc) { | ||
47 | case 0: /* eq: Z */ | ||
48 | tcg_gen_movcond_i32(TCG_COND_EQ, dest, cpu_ZF, zero, | ||
49 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
50 | if (sz == 1) { | ||
51 | tcg_gen_andi_i32(dest, dest, 0xffff); | ||
52 | } | ||
53 | - neon_store_reg32(dest, rd); | ||
54 | + vfp_store_reg32(dest, rd); | ||
55 | tcg_temp_free_i32(frn); | ||
56 | tcg_temp_free_i32(frm); | ||
57 | tcg_temp_free_i32(dest); | ||
58 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) | ||
59 | TCGv_i32 tcg_res; | ||
60 | tcg_op = tcg_temp_new_i32(); | ||
61 | tcg_res = tcg_temp_new_i32(); | ||
62 | - neon_load_reg32(tcg_op, rm); | ||
63 | + vfp_load_reg32(tcg_op, rm); | ||
64 | if (sz == 1) { | ||
65 | gen_helper_rinth(tcg_res, tcg_op, fpst); | ||
66 | } else { | ||
67 | gen_helper_rints(tcg_res, tcg_op, fpst); | ||
68 | } | ||
69 | - neon_store_reg32(tcg_res, rd); | ||
70 | + vfp_store_reg32(tcg_res, rd); | ||
71 | tcg_temp_free_i32(tcg_op); | ||
72 | tcg_temp_free_i32(tcg_res); | ||
73 | } | ||
74 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
75 | gen_helper_vfp_tould(tcg_res, tcg_double, tcg_shift, fpst); | ||
76 | } | ||
77 | tcg_gen_extrl_i64_i32(tcg_tmp, tcg_res); | ||
78 | - neon_store_reg32(tcg_tmp, rd); | ||
79 | + vfp_store_reg32(tcg_tmp, rd); | ||
80 | tcg_temp_free_i32(tcg_tmp); | ||
81 | tcg_temp_free_i64(tcg_res); | ||
82 | tcg_temp_free_i64(tcg_double); | ||
83 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
84 | TCGv_i32 tcg_single, tcg_res; | ||
85 | tcg_single = tcg_temp_new_i32(); | ||
86 | tcg_res = tcg_temp_new_i32(); | ||
87 | - neon_load_reg32(tcg_single, rm); | ||
88 | + vfp_load_reg32(tcg_single, rm); | ||
89 | if (sz == 1) { | ||
90 | if (is_signed) { | ||
91 | gen_helper_vfp_toslh(tcg_res, tcg_single, tcg_shift, fpst); | ||
92 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
93 | gen_helper_vfp_touls(tcg_res, tcg_single, tcg_shift, fpst); | ||
94 | } | ||
95 | } | ||
96 | - neon_store_reg32(tcg_res, rd); | ||
97 | + vfp_store_reg32(tcg_res, rd); | ||
98 | tcg_temp_free_i32(tcg_res); | ||
99 | tcg_temp_free_i32(tcg_single); | ||
100 | } | ||
101 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_half(DisasContext *s, arg_VMOV_single *a) | ||
102 | if (a->l) { | ||
103 | /* VFP to general purpose register */ | ||
104 | tmp = tcg_temp_new_i32(); | ||
105 | - neon_load_reg32(tmp, a->vn); | ||
106 | + vfp_load_reg32(tmp, a->vn); | ||
107 | tcg_gen_andi_i32(tmp, tmp, 0xffff); | ||
108 | store_reg(s, a->rt, tmp); | ||
109 | } else { | ||
110 | /* general purpose register to VFP */ | ||
111 | tmp = load_reg(s, a->rt); | ||
112 | tcg_gen_andi_i32(tmp, tmp, 0xffff); | ||
113 | - neon_store_reg32(tmp, a->vn); | ||
114 | + vfp_store_reg32(tmp, a->vn); | ||
115 | tcg_temp_free_i32(tmp); | ||
116 | } | ||
117 | |||
118 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_single(DisasContext *s, arg_VMOV_single *a) | ||
119 | if (a->l) { | ||
120 | /* VFP to general purpose register */ | ||
121 | tmp = tcg_temp_new_i32(); | ||
122 | - neon_load_reg32(tmp, a->vn); | ||
123 | + vfp_load_reg32(tmp, a->vn); | ||
124 | if (a->rt == 15) { | ||
125 | /* Set the 4 flag bits in the CPSR. */ | ||
126 | gen_set_nzcv(tmp); | ||
127 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_single(DisasContext *s, arg_VMOV_single *a) | ||
128 | } else { | ||
129 | /* general purpose register to VFP */ | ||
130 | tmp = load_reg(s, a->rt); | ||
131 | - neon_store_reg32(tmp, a->vn); | ||
132 | + vfp_store_reg32(tmp, a->vn); | ||
133 | tcg_temp_free_i32(tmp); | ||
134 | } | ||
135 | |||
136 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_64_sp(DisasContext *s, arg_VMOV_64_sp *a) | ||
137 | if (a->op) { | ||
138 | /* fpreg to gpreg */ | ||
139 | tmp = tcg_temp_new_i32(); | ||
140 | - neon_load_reg32(tmp, a->vm); | ||
141 | + vfp_load_reg32(tmp, a->vm); | ||
142 | store_reg(s, a->rt, tmp); | ||
143 | tmp = tcg_temp_new_i32(); | ||
144 | - neon_load_reg32(tmp, a->vm + 1); | ||
145 | + vfp_load_reg32(tmp, a->vm + 1); | ||
146 | store_reg(s, a->rt2, tmp); | ||
147 | } else { | ||
148 | /* gpreg to fpreg */ | ||
149 | tmp = load_reg(s, a->rt); | ||
150 | - neon_store_reg32(tmp, a->vm); | ||
151 | + vfp_store_reg32(tmp, a->vm); | ||
152 | tcg_temp_free_i32(tmp); | ||
153 | tmp = load_reg(s, a->rt2); | ||
154 | - neon_store_reg32(tmp, a->vm + 1); | ||
155 | + vfp_store_reg32(tmp, a->vm + 1); | ||
156 | tcg_temp_free_i32(tmp); | ||
157 | } | ||
158 | |||
159 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_64_dp(DisasContext *s, arg_VMOV_64_dp *a) | ||
160 | if (a->op) { | ||
161 | /* fpreg to gpreg */ | ||
162 | tmp = tcg_temp_new_i32(); | ||
163 | - neon_load_reg32(tmp, a->vm * 2); | ||
164 | + vfp_load_reg32(tmp, a->vm * 2); | ||
165 | store_reg(s, a->rt, tmp); | ||
166 | tmp = tcg_temp_new_i32(); | ||
167 | - neon_load_reg32(tmp, a->vm * 2 + 1); | ||
168 | + vfp_load_reg32(tmp, a->vm * 2 + 1); | ||
169 | store_reg(s, a->rt2, tmp); | ||
170 | } else { | ||
171 | /* gpreg to fpreg */ | ||
172 | tmp = load_reg(s, a->rt); | ||
173 | - neon_store_reg32(tmp, a->vm * 2); | ||
174 | + vfp_store_reg32(tmp, a->vm * 2); | ||
175 | tcg_temp_free_i32(tmp); | ||
176 | tmp = load_reg(s, a->rt2); | ||
177 | - neon_store_reg32(tmp, a->vm * 2 + 1); | ||
178 | + vfp_store_reg32(tmp, a->vm * 2 + 1); | ||
179 | tcg_temp_free_i32(tmp); | ||
180 | } | ||
181 | |||
182 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_hp(DisasContext *s, arg_VLDR_VSTR_sp *a) | ||
183 | tmp = tcg_temp_new_i32(); | ||
184 | if (a->l) { | ||
185 | gen_aa32_ld16u(s, tmp, addr, get_mem_index(s)); | ||
186 | - neon_store_reg32(tmp, a->vd); | ||
187 | + vfp_store_reg32(tmp, a->vd); | ||
188 | } else { | ||
189 | - neon_load_reg32(tmp, a->vd); | ||
190 | + vfp_load_reg32(tmp, a->vd); | ||
191 | gen_aa32_st16(s, tmp, addr, get_mem_index(s)); | ||
192 | } | ||
193 | tcg_temp_free_i32(tmp); | ||
194 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a) | ||
195 | tmp = tcg_temp_new_i32(); | ||
196 | if (a->l) { | ||
197 | gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
198 | - neon_store_reg32(tmp, a->vd); | ||
199 | + vfp_store_reg32(tmp, a->vd); | ||
200 | } else { | ||
201 | - neon_load_reg32(tmp, a->vd); | ||
202 | + vfp_load_reg32(tmp, a->vd); | ||
203 | gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | ||
204 | } | ||
205 | tcg_temp_free_i32(tmp); | ||
206 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) | ||
207 | if (a->l) { | ||
208 | /* load */ | ||
209 | gen_aa32_ld32u(s, tmp, addr, get_mem_index(s)); | ||
210 | - neon_store_reg32(tmp, a->vd + i); | ||
211 | + vfp_store_reg32(tmp, a->vd + i); | ||
212 | } else { | ||
213 | /* store */ | ||
214 | - neon_load_reg32(tmp, a->vd + i); | ||
215 | + vfp_load_reg32(tmp, a->vd + i); | ||
216 | gen_aa32_st32(s, tmp, addr, get_mem_index(s)); | ||
217 | } | ||
218 | tcg_gen_addi_i32(addr, addr, offset); | ||
219 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn, | ||
220 | fd = tcg_temp_new_i32(); | ||
221 | fpst = fpstatus_ptr(FPST_FPCR); | ||
222 | |||
223 | - neon_load_reg32(f0, vn); | ||
224 | - neon_load_reg32(f1, vm); | ||
225 | + vfp_load_reg32(f0, vn); | ||
226 | + vfp_load_reg32(f1, vm); | ||
227 | |||
228 | for (;;) { | ||
229 | if (reads_vd) { | ||
230 | - neon_load_reg32(fd, vd); | ||
231 | + vfp_load_reg32(fd, vd); | ||
232 | } | ||
233 | fn(fd, f0, f1, fpst); | ||
234 | - neon_store_reg32(fd, vd); | ||
235 | + vfp_store_reg32(fd, vd); | ||
236 | |||
237 | if (veclen == 0) { | ||
238 | break; | ||
239 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_sp(DisasContext *s, VFPGen3OpSPFn *fn, | ||
240 | veclen--; | ||
241 | vd = vfp_advance_sreg(vd, delta_d); | ||
242 | vn = vfp_advance_sreg(vn, delta_d); | ||
243 | - neon_load_reg32(f0, vn); | ||
244 | + vfp_load_reg32(f0, vn); | ||
245 | if (delta_m) { | ||
246 | vm = vfp_advance_sreg(vm, delta_m); | ||
247 | - neon_load_reg32(f1, vm); | ||
248 | + vfp_load_reg32(f1, vm); | ||
249 | } | ||
250 | } | ||
251 | |||
252 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_hp(DisasContext *s, VFPGen3OpSPFn *fn, | ||
253 | fd = tcg_temp_new_i32(); | ||
254 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
255 | |||
256 | - neon_load_reg32(f0, vn); | ||
257 | - neon_load_reg32(f1, vm); | ||
258 | + vfp_load_reg32(f0, vn); | ||
259 | + vfp_load_reg32(f1, vm); | ||
260 | |||
261 | if (reads_vd) { | ||
262 | - neon_load_reg32(fd, vd); | ||
263 | + vfp_load_reg32(fd, vd); | ||
264 | } | ||
265 | fn(fd, f0, f1, fpst); | ||
266 | - neon_store_reg32(fd, vd); | ||
267 | + vfp_store_reg32(fd, vd); | ||
268 | |||
269 | tcg_temp_free_i32(f0); | ||
270 | tcg_temp_free_i32(f1); | ||
271 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) | ||
272 | f0 = tcg_temp_new_i32(); | ||
273 | fd = tcg_temp_new_i32(); | ||
274 | |||
275 | - neon_load_reg32(f0, vm); | ||
276 | + vfp_load_reg32(f0, vm); | ||
277 | |||
278 | for (;;) { | ||
279 | fn(fd, f0); | ||
280 | - neon_store_reg32(fd, vd); | ||
281 | + vfp_store_reg32(fd, vd); | ||
282 | |||
283 | if (veclen == 0) { | ||
284 | break; | ||
285 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) | ||
286 | /* single source one-many */ | ||
287 | while (veclen--) { | ||
288 | vd = vfp_advance_sreg(vd, delta_d); | ||
289 | - neon_store_reg32(fd, vd); | ||
290 | + vfp_store_reg32(fd, vd); | ||
291 | } | ||
292 | break; | ||
293 | } | ||
294 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) | ||
295 | veclen--; | ||
296 | vd = vfp_advance_sreg(vd, delta_d); | ||
297 | vm = vfp_advance_sreg(vm, delta_m); | ||
298 | - neon_load_reg32(f0, vm); | ||
299 | + vfp_load_reg32(f0, vm); | ||
300 | } | ||
301 | |||
302 | tcg_temp_free_i32(f0); | ||
303 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_hp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) | ||
304 | } | ||
305 | |||
306 | f0 = tcg_temp_new_i32(); | ||
307 | - neon_load_reg32(f0, vm); | ||
308 | + vfp_load_reg32(f0, vm); | ||
309 | fn(f0, f0); | ||
310 | - neon_store_reg32(f0, vd); | ||
311 | + vfp_store_reg32(f0, vd); | ||
312 | tcg_temp_free_i32(f0); | ||
313 | |||
314 | return true; | ||
315 | @@ -XXX,XX +XXX,XX @@ static bool do_vfm_hp(DisasContext *s, arg_VFMA_sp *a, bool neg_n, bool neg_d) | ||
316 | vm = tcg_temp_new_i32(); | ||
317 | vd = tcg_temp_new_i32(); | ||
318 | |||
319 | - neon_load_reg32(vn, a->vn); | ||
320 | - neon_load_reg32(vm, a->vm); | ||
321 | + vfp_load_reg32(vn, a->vn); | ||
322 | + vfp_load_reg32(vm, a->vm); | ||
323 | if (neg_n) { | ||
324 | /* VFNMS, VFMS */ | ||
325 | gen_helper_vfp_negh(vn, vn); | ||
326 | } | ||
327 | - neon_load_reg32(vd, a->vd); | ||
328 | + vfp_load_reg32(vd, a->vd); | ||
329 | if (neg_d) { | ||
330 | /* VFNMA, VFNMS */ | ||
331 | gen_helper_vfp_negh(vd, vd); | ||
332 | } | ||
333 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
334 | gen_helper_vfp_muladdh(vd, vn, vm, vd, fpst); | ||
335 | - neon_store_reg32(vd, a->vd); | ||
336 | + vfp_store_reg32(vd, a->vd); | ||
337 | |||
338 | tcg_temp_free_ptr(fpst); | ||
339 | tcg_temp_free_i32(vn); | ||
340 | @@ -XXX,XX +XXX,XX @@ static bool do_vfm_sp(DisasContext *s, arg_VFMA_sp *a, bool neg_n, bool neg_d) | ||
341 | vm = tcg_temp_new_i32(); | ||
342 | vd = tcg_temp_new_i32(); | ||
343 | |||
344 | - neon_load_reg32(vn, a->vn); | ||
345 | - neon_load_reg32(vm, a->vm); | ||
346 | + vfp_load_reg32(vn, a->vn); | ||
347 | + vfp_load_reg32(vm, a->vm); | ||
348 | if (neg_n) { | ||
349 | /* VFNMS, VFMS */ | ||
350 | gen_helper_vfp_negs(vn, vn); | ||
351 | } | ||
352 | - neon_load_reg32(vd, a->vd); | ||
353 | + vfp_load_reg32(vd, a->vd); | ||
354 | if (neg_d) { | ||
355 | /* VFNMA, VFNMS */ | ||
356 | gen_helper_vfp_negs(vd, vd); | ||
357 | } | ||
358 | fpst = fpstatus_ptr(FPST_FPCR); | ||
359 | gen_helper_vfp_muladds(vd, vn, vm, vd, fpst); | ||
360 | - neon_store_reg32(vd, a->vd); | ||
361 | + vfp_store_reg32(vd, a->vd); | ||
362 | |||
363 | tcg_temp_free_ptr(fpst); | ||
364 | tcg_temp_free_i32(vn); | ||
365 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_hp(DisasContext *s, arg_VMOV_imm_sp *a) | ||
366 | } | ||
367 | |||
368 | fd = tcg_const_i32(vfp_expand_imm(MO_16, a->imm)); | ||
369 | - neon_store_reg32(fd, a->vd); | ||
370 | + vfp_store_reg32(fd, a->vd); | ||
371 | tcg_temp_free_i32(fd); | ||
372 | return true; | 277 | return true; |
373 | } | 278 | } |
374 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a) | 279 | |
375 | fd = tcg_const_i32(vfp_expand_imm(MO_32, a->imm)); | 280 | -/* |
376 | 281 | - * Decode VLLDM and VLSTM are nonstandard because: | |
377 | for (;;) { | 282 | - * * if there is no FPU then these insns must NOP in |
378 | - neon_store_reg32(fd, vd); | 283 | - * Secure state and UNDEF in Nonsecure state |
379 | + vfp_store_reg32(fd, vd); | 284 | - * * if there is an FPU then these insns do not have |
380 | 285 | - * the usual behaviour that vfp_access_check() provides of | |
381 | if (veclen == 0) { | 286 | - * being controlled by CPACR/NSACR enable bits or the |
382 | break; | 287 | - * lazy-stacking logic. |
383 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_hp(DisasContext *s, arg_VCMP_sp *a) | 288 | - */ |
384 | vd = tcg_temp_new_i32(); | 289 | -static bool trans_VLLDM_VLSTM(DisasContext *s, arg_VLLDM_VLSTM *a) |
385 | vm = tcg_temp_new_i32(); | 290 | -{ |
386 | 291 | - TCGv_i32 fptr; | |
387 | - neon_load_reg32(vd, a->vd); | 292 | - |
388 | + vfp_load_reg32(vd, a->vd); | 293 | - if (!arm_dc_feature(s, ARM_FEATURE_M) || |
389 | if (a->z) { | 294 | - !arm_dc_feature(s, ARM_FEATURE_V8)) { |
390 | tcg_gen_movi_i32(vm, 0); | 295 | - return false; |
391 | } else { | 296 | - } |
392 | - neon_load_reg32(vm, a->vm); | 297 | - |
393 | + vfp_load_reg32(vm, a->vm); | 298 | - if (a->op) { |
394 | } | 299 | - /* |
395 | 300 | - * T2 encoding ({D0-D31} reglist): v8.1M and up. We choose not | |
396 | if (a->e) { | 301 | - * to take the IMPDEF option to make memory accesses to the stack |
397 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_sp(DisasContext *s, arg_VCMP_sp *a) | 302 | - * slots that correspond to the D16-D31 registers (discarding |
398 | vd = tcg_temp_new_i32(); | 303 | - * read data and writing UNKNOWN values), so for us the T2 |
399 | vm = tcg_temp_new_i32(); | 304 | - * encoding behaves identically to the T1 encoding. |
400 | 305 | - */ | |
401 | - neon_load_reg32(vd, a->vd); | 306 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
402 | + vfp_load_reg32(vd, a->vd); | 307 | - return false; |
403 | if (a->z) { | 308 | - } |
404 | tcg_gen_movi_i32(vm, 0); | 309 | - } else { |
405 | } else { | 310 | - /* |
406 | - neon_load_reg32(vm, a->vm); | 311 | - * T1 encoding ({D0-D15} reglist); undef if we have 32 Dregs. |
407 | + vfp_load_reg32(vm, a->vm); | 312 | - * This is currently architecturally impossible, but we add the |
408 | } | 313 | - * check to stay in line with the pseudocode. Note that we must |
409 | 314 | - * emit code for the UNDEF so it takes precedence over the NOCP. | |
410 | if (a->e) { | 315 | - */ |
411 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f32_f16(DisasContext *s, arg_VCVT_f32_f16 *a) | 316 | - if (dc_isar_feature(aa32_simd_r32, s)) { |
412 | /* The T bit tells us if we want the low or high 16 bits of Vm */ | 317 | - unallocated_encoding(s); |
413 | tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t)); | 318 | - return true; |
414 | gen_helper_vfp_fcvt_f16_to_f32(tmp, tmp, fpst, ahp_mode); | 319 | - } |
415 | - neon_store_reg32(tmp, a->vd); | 320 | - } |
416 | + vfp_store_reg32(tmp, a->vd); | 321 | - |
417 | tcg_temp_free_i32(ahp_mode); | 322 | - /* |
418 | tcg_temp_free_ptr(fpst); | 323 | - * If not secure, UNDEF. We must emit code for this |
419 | tcg_temp_free_i32(tmp); | 324 | - * rather than returning false so that this takes |
420 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f32(DisasContext *s, arg_VCVT_f16_f32 *a) | 325 | - * precedence over the m-nocp.decode NOCP fallback. |
421 | ahp_mode = get_ahp_flag(); | 326 | - */ |
422 | tmp = tcg_temp_new_i32(); | 327 | - if (!s->v8m_secure) { |
423 | 328 | - unallocated_encoding(s); | |
424 | - neon_load_reg32(tmp, a->vm); | 329 | - return true; |
425 | + vfp_load_reg32(tmp, a->vm); | 330 | - } |
426 | gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp_mode); | 331 | - /* If no fpu, NOP. */ |
427 | tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t)); | 332 | - if (!dc_isar_feature(aa32_vfp, s)) { |
428 | tcg_temp_free_i32(ahp_mode); | 333 | - return true; |
429 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_hp(DisasContext *s, arg_VRINTR_sp *a) | 334 | - } |
430 | } | 335 | - |
431 | 336 | - fptr = load_reg(s, a->rn); | |
432 | tmp = tcg_temp_new_i32(); | 337 | - if (a->l) { |
433 | - neon_load_reg32(tmp, a->vm); | 338 | - gen_helper_v7m_vlldm(cpu_env, fptr); |
434 | + vfp_load_reg32(tmp, a->vm); | 339 | - } else { |
435 | fpst = fpstatus_ptr(FPST_FPCR_F16); | 340 | - gen_helper_v7m_vlstm(cpu_env, fptr); |
436 | gen_helper_rinth(tmp, tmp, fpst); | 341 | - } |
437 | - neon_store_reg32(tmp, a->vd); | 342 | - tcg_temp_free_i32(fptr); |
438 | + vfp_store_reg32(tmp, a->vd); | 343 | - |
439 | tcg_temp_free_ptr(fpst); | 344 | - /* End the TB, because we have updated FP control bits */ |
440 | tcg_temp_free_i32(tmp); | 345 | - s->base.is_jmp = DISAS_UPDATE_EXIT; |
441 | return true; | 346 | - return true; |
442 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_sp(DisasContext *s, arg_VRINTR_sp *a) | 347 | -} |
443 | } | 348 | - |
444 | 349 | -static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a) | |
445 | tmp = tcg_temp_new_i32(); | 350 | -{ |
446 | - neon_load_reg32(tmp, a->vm); | 351 | - int btmreg, topreg; |
447 | + vfp_load_reg32(tmp, a->vm); | 352 | - TCGv_i64 zero; |
448 | fpst = fpstatus_ptr(FPST_FPCR); | 353 | - TCGv_i32 aspen, sfpa; |
449 | gen_helper_rints(tmp, tmp, fpst); | 354 | - |
450 | - neon_store_reg32(tmp, a->vd); | 355 | - if (!dc_isar_feature(aa32_m_sec_state, s)) { |
451 | + vfp_store_reg32(tmp, a->vd); | 356 | - /* Before v8.1M, fall through in decode to NOCP check */ |
452 | tcg_temp_free_ptr(fpst); | 357 | - return false; |
453 | tcg_temp_free_i32(tmp); | 358 | - } |
454 | return true; | 359 | - |
455 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_hp(DisasContext *s, arg_VRINTZ_sp *a) | 360 | - /* Explicitly UNDEF because this takes precedence over NOCP */ |
456 | } | 361 | - if (!arm_dc_feature(s, ARM_FEATURE_M_MAIN) || !s->v8m_secure) { |
457 | 362 | - unallocated_encoding(s); | |
458 | tmp = tcg_temp_new_i32(); | 363 | - return true; |
459 | - neon_load_reg32(tmp, a->vm); | 364 | - } |
460 | + vfp_load_reg32(tmp, a->vm); | 365 | - |
461 | fpst = fpstatus_ptr(FPST_FPCR_F16); | 366 | - if (!dc_isar_feature(aa32_vfp_simd, s)) { |
462 | tcg_rmode = tcg_const_i32(float_round_to_zero); | 367 | - /* NOP if we have neither FP nor MVE */ |
463 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | 368 | - return true; |
464 | gen_helper_rinth(tmp, tmp, fpst); | 369 | - } |
465 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | 370 | - |
466 | - neon_store_reg32(tmp, a->vd); | 371 | - /* |
467 | + vfp_store_reg32(tmp, a->vd); | 372 | - * If FPCCR.ASPEN != 0 && CONTROL_S.SFPA == 0 then there is no |
468 | tcg_temp_free_ptr(fpst); | 373 | - * active floating point context so we must NOP (without doing |
469 | tcg_temp_free_i32(tcg_rmode); | 374 | - * any lazy state preservation or the NOCP check). |
470 | tcg_temp_free_i32(tmp); | 375 | - */ |
471 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_sp(DisasContext *s, arg_VRINTZ_sp *a) | 376 | - aspen = load_cpu_field(v7m.fpccr[M_REG_S]); |
472 | } | 377 | - sfpa = load_cpu_field(v7m.control[M_REG_S]); |
473 | 378 | - tcg_gen_andi_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); | |
474 | tmp = tcg_temp_new_i32(); | 379 | - tcg_gen_xori_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK); |
475 | - neon_load_reg32(tmp, a->vm); | 380 | - tcg_gen_andi_i32(sfpa, sfpa, R_V7M_CONTROL_SFPA_MASK); |
476 | + vfp_load_reg32(tmp, a->vm); | 381 | - tcg_gen_or_i32(sfpa, sfpa, aspen); |
477 | fpst = fpstatus_ptr(FPST_FPCR); | 382 | - arm_gen_condlabel(s); |
478 | tcg_rmode = tcg_const_i32(float_round_to_zero); | 383 | - tcg_gen_brcondi_i32(TCG_COND_EQ, sfpa, 0, s->condlabel); |
479 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | 384 | - |
480 | gen_helper_rints(tmp, tmp, fpst); | 385 | - if (s->fp_excp_el != 0) { |
481 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | 386 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, |
482 | - neon_store_reg32(tmp, a->vd); | 387 | - syn_uncategorized(), s->fp_excp_el); |
483 | + vfp_store_reg32(tmp, a->vd); | 388 | - return true; |
484 | tcg_temp_free_ptr(fpst); | 389 | - } |
485 | tcg_temp_free_i32(tcg_rmode); | 390 | - |
486 | tcg_temp_free_i32(tmp); | 391 | - topreg = a->vd + a->imm - 1; |
487 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_hp(DisasContext *s, arg_VRINTX_sp *a) | 392 | - btmreg = a->vd; |
488 | } | 393 | - |
489 | 394 | - /* Convert to Sreg numbers if the insn specified in Dregs */ | |
490 | tmp = tcg_temp_new_i32(); | 395 | - if (a->size == 3) { |
491 | - neon_load_reg32(tmp, a->vm); | 396 | - topreg = topreg * 2 + 1; |
492 | + vfp_load_reg32(tmp, a->vm); | 397 | - btmreg *= 2; |
493 | fpst = fpstatus_ptr(FPST_FPCR_F16); | 398 | - } |
494 | gen_helper_rinth_exact(tmp, tmp, fpst); | 399 | - |
495 | - neon_store_reg32(tmp, a->vd); | 400 | - if (topreg > 63 || (topreg > 31 && !(topreg & 1))) { |
496 | + vfp_store_reg32(tmp, a->vd); | 401 | - /* UNPREDICTABLE: we choose to undef */ |
497 | tcg_temp_free_ptr(fpst); | 402 | - unallocated_encoding(s); |
498 | tcg_temp_free_i32(tmp); | 403 | - return true; |
499 | return true; | 404 | - } |
500 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_sp(DisasContext *s, arg_VRINTX_sp *a) | 405 | - |
501 | } | 406 | - /* Silently ignore requests to clear D16-D31 if they don't exist */ |
502 | 407 | - if (topreg > 31 && !dc_isar_feature(aa32_simd_r32, s)) { | |
503 | tmp = tcg_temp_new_i32(); | 408 | - topreg = 31; |
504 | - neon_load_reg32(tmp, a->vm); | 409 | - } |
505 | + vfp_load_reg32(tmp, a->vm); | 410 | - |
506 | fpst = fpstatus_ptr(FPST_FPCR); | 411 | - if (!vfp_access_check(s)) { |
507 | gen_helper_rints_exact(tmp, tmp, fpst); | 412 | - return true; |
508 | - neon_store_reg32(tmp, a->vd); | 413 | - } |
509 | + vfp_store_reg32(tmp, a->vd); | 414 | - |
510 | tcg_temp_free_ptr(fpst); | 415 | - /* Zero the Sregs from btmreg to topreg inclusive. */ |
511 | tcg_temp_free_i32(tmp); | 416 | - zero = tcg_const_i64(0); |
512 | return true; | 417 | - if (btmreg & 1) { |
513 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a) | 418 | - write_neon_element64(zero, btmreg >> 1, 1, MO_32); |
514 | 419 | - btmreg++; | |
515 | vm = tcg_temp_new_i32(); | 420 | - } |
516 | vd = tcg_temp_new_i64(); | 421 | - for (; btmreg + 1 <= topreg; btmreg += 2) { |
517 | - neon_load_reg32(vm, a->vm); | 422 | - write_neon_element64(zero, btmreg >> 1, 0, MO_64); |
518 | + vfp_load_reg32(vm, a->vm); | 423 | - } |
519 | gen_helper_vfp_fcvtds(vd, vm, cpu_env); | 424 | - if (btmreg == topreg) { |
520 | neon_store_reg64(vd, a->vd); | 425 | - write_neon_element64(zero, btmreg >> 1, 0, MO_32); |
521 | tcg_temp_free_i32(vm); | 426 | - btmreg++; |
522 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a) | 427 | - } |
523 | vm = tcg_temp_new_i64(); | 428 | - assert(btmreg == topreg + 1); |
524 | neon_load_reg64(vm, a->vm); | 429 | - /* TODO: when MVE is implemented, zero VPR here */ |
525 | gen_helper_vfp_fcvtsd(vd, vm, cpu_env); | 430 | - return true; |
526 | - neon_store_reg32(vd, a->vd); | 431 | -} |
527 | + vfp_store_reg32(vd, a->vd); | 432 | - |
528 | tcg_temp_free_i32(vd); | 433 | -static bool trans_NOCP(DisasContext *s, arg_nocp *a) |
529 | tcg_temp_free_i64(vm); | 434 | -{ |
530 | return true; | 435 | - /* |
531 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_hp(DisasContext *s, arg_VCVT_int_sp *a) | 436 | - * Handle M-profile early check for disabled coprocessor: |
532 | } | 437 | - * all we need to do here is emit the NOCP exception if |
533 | 438 | - * the coprocessor is disabled. Otherwise we return false | |
534 | vm = tcg_temp_new_i32(); | 439 | - * and the real VFP/etc decode will handle the insn. |
535 | - neon_load_reg32(vm, a->vm); | 440 | - */ |
536 | + vfp_load_reg32(vm, a->vm); | 441 | - assert(arm_dc_feature(s, ARM_FEATURE_M)); |
537 | fpst = fpstatus_ptr(FPST_FPCR_F16); | 442 | - |
538 | if (a->s) { | 443 | - if (a->cp == 11) { |
539 | /* i32 -> f16 */ | 444 | - a->cp = 10; |
540 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_hp(DisasContext *s, arg_VCVT_int_sp *a) | 445 | - } |
541 | /* u32 -> f16 */ | 446 | - if (arm_dc_feature(s, ARM_FEATURE_V8_1M) && |
542 | gen_helper_vfp_uitoh(vm, vm, fpst); | 447 | - (a->cp == 8 || a->cp == 9 || a->cp == 14 || a->cp == 15)) { |
543 | } | 448 | - /* in v8.1M cp 8, 9, 14, 15 also are governed by the cp10 enable */ |
544 | - neon_store_reg32(vm, a->vd); | 449 | - a->cp = 10; |
545 | + vfp_store_reg32(vm, a->vd); | 450 | - } |
546 | tcg_temp_free_i32(vm); | 451 | - |
547 | tcg_temp_free_ptr(fpst); | 452 | - if (a->cp != 10) { |
548 | return true; | 453 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, |
549 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a) | 454 | - syn_uncategorized(), default_exception_el(s)); |
550 | } | 455 | - return true; |
551 | 456 | - } | |
552 | vm = tcg_temp_new_i32(); | 457 | - |
553 | - neon_load_reg32(vm, a->vm); | 458 | - if (s->fp_excp_el != 0) { |
554 | + vfp_load_reg32(vm, a->vm); | 459 | - gen_exception_insn(s, s->pc_curr, EXCP_NOCP, |
555 | fpst = fpstatus_ptr(FPST_FPCR); | 460 | - syn_uncategorized(), s->fp_excp_el); |
556 | if (a->s) { | 461 | - return true; |
557 | /* i32 -> f32 */ | 462 | - } |
558 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a) | 463 | - |
559 | /* u32 -> f32 */ | 464 | - return false; |
560 | gen_helper_vfp_uitos(vm, vm, fpst); | 465 | -} |
561 | } | 466 | - |
562 | - neon_store_reg32(vm, a->vd); | 467 | -static bool trans_NOCP_8_1(DisasContext *s, arg_nocp *a) |
563 | + vfp_store_reg32(vm, a->vd); | 468 | -{ |
564 | tcg_temp_free_i32(vm); | 469 | - /* This range needs a coprocessor check for v8.1M and later only */ |
565 | tcg_temp_free_ptr(fpst); | 470 | - if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
566 | return true; | 471 | - return false; |
567 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a) | 472 | - } |
568 | 473 | - return trans_NOCP(s, a); | |
569 | vm = tcg_temp_new_i32(); | 474 | -} |
570 | vd = tcg_temp_new_i64(); | 475 | - |
571 | - neon_load_reg32(vm, a->vm); | 476 | static bool trans_VINS(DisasContext *s, arg_VINS *a) |
572 | + vfp_load_reg32(vm, a->vm); | 477 | { |
573 | fpst = fpstatus_ptr(FPST_FPCR); | 478 | TCGv_i32 rd, rm; |
574 | if (a->s) { | 479 | diff --git a/target/arm/meson.build b/target/arm/meson.build |
575 | /* i32 -> f64 */ | 480 | index XXXXXXX..XXXXXXX 100644 |
576 | @@ -XXX,XX +XXX,XX @@ static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a) | 481 | --- a/target/arm/meson.build |
577 | vd = tcg_temp_new_i32(); | 482 | +++ b/target/arm/meson.build |
578 | neon_load_reg64(vm, a->vm); | 483 | @@ -XXX,XX +XXX,XX @@ gen = [ |
579 | gen_helper_vjcvt(vd, vm, cpu_env); | 484 | decodetree.process('neon-ls.decode', extra_args: '--static-decode=disas_neon_ls'), |
580 | - neon_store_reg32(vd, a->vd); | 485 | decodetree.process('vfp.decode', extra_args: '--static-decode=disas_vfp'), |
581 | + vfp_store_reg32(vd, a->vd); | 486 | decodetree.process('vfp-uncond.decode', extra_args: '--static-decode=disas_vfp_uncond'), |
582 | tcg_temp_free_i64(vm); | 487 | - decodetree.process('m-nocp.decode', extra_args: '--static-decode=disas_m_nocp'), |
583 | tcg_temp_free_i32(vd); | 488 | + decodetree.process('m-nocp.decode', extra_args: '--decode=disas_m_nocp'), |
584 | return true; | 489 | decodetree.process('a32.decode', extra_args: '--static-decode=disas_a32'), |
585 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_hp(DisasContext *s, arg_VCVT_fix_sp *a) | 490 | decodetree.process('a32-uncond.decode', extra_args: '--static-decode=disas_a32_uncond'), |
586 | frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm); | 491 | decodetree.process('t32.decode', extra_args: '--static-decode=disas_t32'), |
587 | 492 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(files( | |
588 | vd = tcg_temp_new_i32(); | 493 | 'op_helper.c', |
589 | - neon_load_reg32(vd, a->vd); | 494 | 'tlb_helper.c', |
590 | + vfp_load_reg32(vd, a->vd); | 495 | 'translate.c', |
591 | 496 | + 'translate-m-nocp.c', | |
592 | fpst = fpstatus_ptr(FPST_FPCR_F16); | 497 | 'vec_helper.c', |
593 | shift = tcg_const_i32(frac_bits); | 498 | 'vfp_helper.c', |
594 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_hp(DisasContext *s, arg_VCVT_fix_sp *a) | 499 | 'cpu_tcg.c', |
595 | g_assert_not_reached(); | ||
596 | } | ||
597 | |||
598 | - neon_store_reg32(vd, a->vd); | ||
599 | + vfp_store_reg32(vd, a->vd); | ||
600 | tcg_temp_free_i32(vd); | ||
601 | tcg_temp_free_i32(shift); | ||
602 | tcg_temp_free_ptr(fpst); | ||
603 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
604 | frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm); | ||
605 | |||
606 | vd = tcg_temp_new_i32(); | ||
607 | - neon_load_reg32(vd, a->vd); | ||
608 | + vfp_load_reg32(vd, a->vd); | ||
609 | |||
610 | fpst = fpstatus_ptr(FPST_FPCR); | ||
611 | shift = tcg_const_i32(frac_bits); | ||
612 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_sp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
613 | g_assert_not_reached(); | ||
614 | } | ||
615 | |||
616 | - neon_store_reg32(vd, a->vd); | ||
617 | + vfp_store_reg32(vd, a->vd); | ||
618 | tcg_temp_free_i32(vd); | ||
619 | tcg_temp_free_i32(shift); | ||
620 | tcg_temp_free_ptr(fpst); | ||
621 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_hp_int(DisasContext *s, arg_VCVT_sp_int *a) | ||
622 | |||
623 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
624 | vm = tcg_temp_new_i32(); | ||
625 | - neon_load_reg32(vm, a->vm); | ||
626 | + vfp_load_reg32(vm, a->vm); | ||
627 | |||
628 | if (a->s) { | ||
629 | if (a->rz) { | ||
630 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_hp_int(DisasContext *s, arg_VCVT_sp_int *a) | ||
631 | gen_helper_vfp_touih(vm, vm, fpst); | ||
632 | } | ||
633 | } | ||
634 | - neon_store_reg32(vm, a->vd); | ||
635 | + vfp_store_reg32(vm, a->vd); | ||
636 | tcg_temp_free_i32(vm); | ||
637 | tcg_temp_free_ptr(fpst); | ||
638 | return true; | ||
639 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp_int(DisasContext *s, arg_VCVT_sp_int *a) | ||
640 | |||
641 | fpst = fpstatus_ptr(FPST_FPCR); | ||
642 | vm = tcg_temp_new_i32(); | ||
643 | - neon_load_reg32(vm, a->vm); | ||
644 | + vfp_load_reg32(vm, a->vm); | ||
645 | |||
646 | if (a->s) { | ||
647 | if (a->rz) { | ||
648 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp_int(DisasContext *s, arg_VCVT_sp_int *a) | ||
649 | gen_helper_vfp_touis(vm, vm, fpst); | ||
650 | } | ||
651 | } | ||
652 | - neon_store_reg32(vm, a->vd); | ||
653 | + vfp_store_reg32(vm, a->vd); | ||
654 | tcg_temp_free_i32(vm); | ||
655 | tcg_temp_free_ptr(fpst); | ||
656 | return true; | ||
657 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a) | ||
658 | gen_helper_vfp_touid(vd, vm, fpst); | ||
659 | } | ||
660 | } | ||
661 | - neon_store_reg32(vd, a->vd); | ||
662 | + vfp_store_reg32(vd, a->vd); | ||
663 | tcg_temp_free_i32(vd); | ||
664 | tcg_temp_free_i64(vm); | ||
665 | tcg_temp_free_ptr(fpst); | ||
666 | @@ -XXX,XX +XXX,XX @@ static bool trans_VINS(DisasContext *s, arg_VINS *a) | ||
667 | /* Insert low half of Vm into high half of Vd */ | ||
668 | rm = tcg_temp_new_i32(); | ||
669 | rd = tcg_temp_new_i32(); | ||
670 | - neon_load_reg32(rm, a->vm); | ||
671 | - neon_load_reg32(rd, a->vd); | ||
672 | + vfp_load_reg32(rm, a->vm); | ||
673 | + vfp_load_reg32(rd, a->vd); | ||
674 | tcg_gen_deposit_i32(rd, rd, rm, 16, 16); | ||
675 | - neon_store_reg32(rd, a->vd); | ||
676 | + vfp_store_reg32(rd, a->vd); | ||
677 | tcg_temp_free_i32(rm); | ||
678 | tcg_temp_free_i32(rd); | ||
679 | return true; | ||
680 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOVX(DisasContext *s, arg_VINS *a) | ||
681 | |||
682 | /* Set Vd to high half of Vm */ | ||
683 | rm = tcg_temp_new_i32(); | ||
684 | - neon_load_reg32(rm, a->vm); | ||
685 | + vfp_load_reg32(rm, a->vm); | ||
686 | tcg_gen_shri_i32(rm, rm, 16); | ||
687 | - neon_store_reg32(rm, a->vd); | ||
688 | + vfp_store_reg32(rm, a->vd); | ||
689 | tcg_temp_free_i32(rm); | ||
690 | return true; | ||
691 | } | ||
692 | -- | 500 | -- |
693 | 2.20.1 | 501 | 2.20.1 |
694 | 502 | ||
695 | 503 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Move the various gen_aa32* functions and macros out of translate.c |
---|---|---|---|
2 | and into translate-a32.h. | ||
2 | 3 | ||
3 | Model these off the aa64 read/write_vec_element functions. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Use it within translate-neon.c.inc. The new functions do | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | not allocate or free temps, so this rearranges the calling | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | code a bit. | 7 | Message-id: 20210430132740.10391-6-peter.maydell@linaro.org |
8 | --- | ||
9 | target/arm/translate-a32.h | 53 ++++++++++++++++++++++++++++++++++++++ | ||
10 | target/arm/translate.c | 51 ++++++++++++------------------------ | ||
11 | 2 files changed, 69 insertions(+), 35 deletions(-) | ||
7 | 12 | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 13 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h |
9 | Message-id: 20201030022618.785675-6-richard.henderson@linaro.org | 14 | index XXXXXXX..XXXXXXX 100644 |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | --- a/target/arm/translate-a32.h |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | +++ b/target/arm/translate-a32.h |
12 | --- | 17 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 load_reg(DisasContext *s, int reg) |
13 | target/arm/translate.c | 26 ++++ | 18 | return tmp; |
14 | target/arm/translate-neon.c.inc | 256 ++++++++++++++++++++------------ | 19 | } |
15 | 2 files changed, 183 insertions(+), 99 deletions(-) | 20 | |
16 | 21 | +void gen_aa32_ld_internal_i32(DisasContext *s, TCGv_i32 val, | |
22 | + TCGv_i32 a32, int index, MemOp opc); | ||
23 | +void gen_aa32_st_internal_i32(DisasContext *s, TCGv_i32 val, | ||
24 | + TCGv_i32 a32, int index, MemOp opc); | ||
25 | +void gen_aa32_ld_internal_i64(DisasContext *s, TCGv_i64 val, | ||
26 | + TCGv_i32 a32, int index, MemOp opc); | ||
27 | +void gen_aa32_st_internal_i64(DisasContext *s, TCGv_i64 val, | ||
28 | + TCGv_i32 a32, int index, MemOp opc); | ||
29 | +void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
30 | + int index, MemOp opc); | ||
31 | +void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
32 | + int index, MemOp opc); | ||
33 | +void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
34 | + int index, MemOp opc); | ||
35 | +void gen_aa32_st_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
36 | + int index, MemOp opc); | ||
37 | + | ||
38 | +#define DO_GEN_LD(SUFF, OPC) \ | ||
39 | + static inline void gen_aa32_ld##SUFF(DisasContext *s, TCGv_i32 val, \ | ||
40 | + TCGv_i32 a32, int index) \ | ||
41 | + { \ | ||
42 | + gen_aa32_ld_i32(s, val, a32, index, OPC); \ | ||
43 | + } | ||
44 | + | ||
45 | +#define DO_GEN_ST(SUFF, OPC) \ | ||
46 | + static inline void gen_aa32_st##SUFF(DisasContext *s, TCGv_i32 val, \ | ||
47 | + TCGv_i32 a32, int index) \ | ||
48 | + { \ | ||
49 | + gen_aa32_st_i32(s, val, a32, index, OPC); \ | ||
50 | + } | ||
51 | + | ||
52 | +static inline void gen_aa32_ld64(DisasContext *s, TCGv_i64 val, | ||
53 | + TCGv_i32 a32, int index) | ||
54 | +{ | ||
55 | + gen_aa32_ld_i64(s, val, a32, index, MO_Q); | ||
56 | +} | ||
57 | + | ||
58 | +static inline void gen_aa32_st64(DisasContext *s, TCGv_i64 val, | ||
59 | + TCGv_i32 a32, int index) | ||
60 | +{ | ||
61 | + gen_aa32_st_i64(s, val, a32, index, MO_Q); | ||
62 | +} | ||
63 | + | ||
64 | +DO_GEN_LD(8u, MO_UB) | ||
65 | +DO_GEN_LD(16u, MO_UW) | ||
66 | +DO_GEN_LD(32u, MO_UL) | ||
67 | +DO_GEN_ST(8, MO_UB) | ||
68 | +DO_GEN_ST(16, MO_UW) | ||
69 | +DO_GEN_ST(32, MO_UL) | ||
70 | + | ||
71 | +#undef DO_GEN_LD | ||
72 | +#undef DO_GEN_ST | ||
73 | + | ||
74 | #endif | ||
17 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 75 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
18 | index XXXXXXX..XXXXXXX 100644 | 76 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate.c | 77 | --- a/target/arm/translate.c |
20 | +++ b/target/arm/translate.c | 78 | +++ b/target/arm/translate.c |
21 | @@ -XXX,XX +XXX,XX @@ static inline void neon_store_reg32(TCGv_i32 var, int reg) | 79 | @@ -XXX,XX +XXX,XX @@ static TCGv gen_aa32_addr(DisasContext *s, TCGv_i32 a32, MemOp op) |
22 | tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); | 80 | * Internal routines are used for NEON cases where the endianness |
81 | * and/or alignment has already been taken into account and manipulated. | ||
82 | */ | ||
83 | -static void gen_aa32_ld_internal_i32(DisasContext *s, TCGv_i32 val, | ||
84 | - TCGv_i32 a32, int index, MemOp opc) | ||
85 | +void gen_aa32_ld_internal_i32(DisasContext *s, TCGv_i32 val, | ||
86 | + TCGv_i32 a32, int index, MemOp opc) | ||
87 | { | ||
88 | TCGv addr = gen_aa32_addr(s, a32, opc); | ||
89 | tcg_gen_qemu_ld_i32(val, addr, index, opc); | ||
90 | tcg_temp_free(addr); | ||
23 | } | 91 | } |
24 | 92 | ||
25 | +static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp size) | 93 | -static void gen_aa32_st_internal_i32(DisasContext *s, TCGv_i32 val, |
26 | +{ | 94 | - TCGv_i32 a32, int index, MemOp opc) |
27 | + long off = neon_element_offset(reg, ele, size); | 95 | +void gen_aa32_st_internal_i32(DisasContext *s, TCGv_i32 val, |
28 | + | 96 | + TCGv_i32 a32, int index, MemOp opc) |
29 | + switch (size) { | ||
30 | + case MO_32: | ||
31 | + tcg_gen_ld_i32(dest, cpu_env, off); | ||
32 | + break; | ||
33 | + default: | ||
34 | + g_assert_not_reached(); | ||
35 | + } | ||
36 | +} | ||
37 | + | ||
38 | +static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp size) | ||
39 | +{ | ||
40 | + long off = neon_element_offset(reg, ele, size); | ||
41 | + | ||
42 | + switch (size) { | ||
43 | + case MO_32: | ||
44 | + tcg_gen_st_i32(src, cpu_env, off); | ||
45 | + break; | ||
46 | + default: | ||
47 | + g_assert_not_reached(); | ||
48 | + } | ||
49 | +} | ||
50 | + | ||
51 | static TCGv_ptr vfp_reg_ptr(bool dp, int reg) | ||
52 | { | 97 | { |
53 | TCGv_ptr ret = tcg_temp_new_ptr(); | 98 | TCGv addr = gen_aa32_addr(s, a32, opc); |
54 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 99 | tcg_gen_qemu_st_i32(val, addr, index, opc); |
55 | index XXXXXXX..XXXXXXX 100644 | 100 | tcg_temp_free(addr); |
56 | --- a/target/arm/translate-neon.c.inc | ||
57 | +++ b/target/arm/translate-neon.c.inc | ||
58 | @@ -XXX,XX +XXX,XX @@ static bool do_3same_pair(DisasContext *s, arg_3same *a, NeonGenTwoOpFn *fn) | ||
59 | * early. Since Q is 0 there are always just two passes, so instead | ||
60 | * of a complicated loop over each pass we just unroll. | ||
61 | */ | ||
62 | - tmp = neon_load_reg(a->vn, 0); | ||
63 | - tmp2 = neon_load_reg(a->vn, 1); | ||
64 | + tmp = tcg_temp_new_i32(); | ||
65 | + tmp2 = tcg_temp_new_i32(); | ||
66 | + tmp3 = tcg_temp_new_i32(); | ||
67 | + | ||
68 | + read_neon_element32(tmp, a->vn, 0, MO_32); | ||
69 | + read_neon_element32(tmp2, a->vn, 1, MO_32); | ||
70 | fn(tmp, tmp, tmp2); | ||
71 | - tcg_temp_free_i32(tmp2); | ||
72 | |||
73 | - tmp3 = neon_load_reg(a->vm, 0); | ||
74 | - tmp2 = neon_load_reg(a->vm, 1); | ||
75 | + read_neon_element32(tmp3, a->vm, 0, MO_32); | ||
76 | + read_neon_element32(tmp2, a->vm, 1, MO_32); | ||
77 | fn(tmp3, tmp3, tmp2); | ||
78 | - tcg_temp_free_i32(tmp2); | ||
79 | |||
80 | - neon_store_reg(a->vd, 0, tmp); | ||
81 | - neon_store_reg(a->vd, 1, tmp3); | ||
82 | + write_neon_element32(tmp, a->vd, 0, MO_32); | ||
83 | + write_neon_element32(tmp3, a->vd, 1, MO_32); | ||
84 | + | ||
85 | + tcg_temp_free_i32(tmp); | ||
86 | + tcg_temp_free_i32(tmp2); | ||
87 | + tcg_temp_free_i32(tmp3); | ||
88 | return true; | ||
89 | } | 101 | } |
90 | 102 | ||
91 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | 103 | -static void gen_aa32_ld_internal_i64(DisasContext *s, TCGv_i64 val, |
92 | * 2-reg-and-shift operations, size < 3 case, where the | 104 | - TCGv_i32 a32, int index, MemOp opc) |
93 | * helper needs to be passed cpu_env. | 105 | +void gen_aa32_ld_internal_i64(DisasContext *s, TCGv_i64 val, |
94 | */ | 106 | + TCGv_i32 a32, int index, MemOp opc) |
95 | - TCGv_i32 constimm; | 107 | { |
96 | + TCGv_i32 constimm, tmp; | 108 | TCGv addr = gen_aa32_addr(s, a32, opc); |
97 | int pass; | 109 | |
98 | 110 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_ld_internal_i64(DisasContext *s, TCGv_i64 val, | |
99 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | 111 | tcg_temp_free(addr); |
100 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | 112 | } |
101 | * by immediate using the variable shift operations. | 113 | |
102 | */ | 114 | -static void gen_aa32_st_internal_i64(DisasContext *s, TCGv_i64 val, |
103 | constimm = tcg_const_i32(dup_const(a->size, a->shift)); | 115 | - TCGv_i32 a32, int index, MemOp opc) |
104 | + tmp = tcg_temp_new_i32(); | 116 | +void gen_aa32_st_internal_i64(DisasContext *s, TCGv_i64 val, |
105 | 117 | + TCGv_i32 a32, int index, MemOp opc) | |
106 | for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | 118 | { |
107 | - TCGv_i32 tmp = neon_load_reg(a->vm, pass); | 119 | TCGv addr = gen_aa32_addr(s, a32, opc); |
108 | + read_neon_element32(tmp, a->vm, pass, MO_32); | 120 | |
109 | fn(tmp, cpu_env, tmp, constimm); | 121 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_internal_i64(DisasContext *s, TCGv_i64 val, |
110 | - neon_store_reg(a->vd, pass, tmp); | 122 | tcg_temp_free(addr); |
111 | + write_neon_element32(tmp, a->vd, pass, MO_32); | 123 | } |
124 | |||
125 | -static void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
126 | - int index, MemOp opc) | ||
127 | +void gen_aa32_ld_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
128 | + int index, MemOp opc) | ||
129 | { | ||
130 | gen_aa32_ld_internal_i32(s, val, a32, index, finalize_memop(s, opc)); | ||
131 | } | ||
132 | |||
133 | -static void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
134 | - int index, MemOp opc) | ||
135 | +void gen_aa32_st_i32(DisasContext *s, TCGv_i32 val, TCGv_i32 a32, | ||
136 | + int index, MemOp opc) | ||
137 | { | ||
138 | gen_aa32_st_internal_i32(s, val, a32, index, finalize_memop(s, opc)); | ||
139 | } | ||
140 | |||
141 | -static void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
142 | - int index, MemOp opc) | ||
143 | +void gen_aa32_ld_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
144 | + int index, MemOp opc) | ||
145 | { | ||
146 | gen_aa32_ld_internal_i64(s, val, a32, index, finalize_memop(s, opc)); | ||
147 | } | ||
148 | |||
149 | -static void gen_aa32_st_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
150 | - int index, MemOp opc) | ||
151 | +void gen_aa32_st_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
152 | + int index, MemOp opc) | ||
153 | { | ||
154 | gen_aa32_st_internal_i64(s, val, a32, index, finalize_memop(s, opc)); | ||
155 | } | ||
156 | @@ -XXX,XX +XXX,XX @@ static void gen_aa32_st_i64(DisasContext *s, TCGv_i64 val, TCGv_i32 a32, | ||
157 | gen_aa32_st_i32(s, val, a32, index, OPC); \ | ||
112 | } | 158 | } |
113 | + tcg_temp_free_i32(tmp); | 159 | |
114 | tcg_temp_free_i32(constimm); | 160 | -static inline void gen_aa32_ld64(DisasContext *s, TCGv_i64 val, |
115 | return true; | 161 | - TCGv_i32 a32, int index) |
116 | } | 162 | -{ |
117 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a, | 163 | - gen_aa32_ld_i64(s, val, a32, index, MO_Q); |
118 | constimm = tcg_const_i64(-a->shift); | 164 | -} |
119 | rm1 = tcg_temp_new_i64(); | 165 | - |
120 | rm2 = tcg_temp_new_i64(); | 166 | -static inline void gen_aa32_st64(DisasContext *s, TCGv_i64 val, |
121 | + rd = tcg_temp_new_i32(); | 167 | - TCGv_i32 a32, int index) |
122 | 168 | -{ | |
123 | /* Load both inputs first to avoid potential overwrite if rm == rd */ | 169 | - gen_aa32_st_i64(s, val, a32, index, MO_Q); |
124 | neon_load_reg64(rm1, a->vm); | 170 | -} |
125 | neon_load_reg64(rm2, a->vm + 1); | 171 | - |
126 | 172 | -DO_GEN_LD(8u, MO_UB) | |
127 | shiftfn(rm1, rm1, constimm); | 173 | -DO_GEN_LD(16u, MO_UW) |
128 | - rd = tcg_temp_new_i32(); | 174 | -DO_GEN_LD(32u, MO_UL) |
129 | narrowfn(rd, cpu_env, rm1); | 175 | -DO_GEN_ST(8, MO_UB) |
130 | - neon_store_reg(a->vd, 0, rd); | 176 | -DO_GEN_ST(16, MO_UW) |
131 | + write_neon_element32(rd, a->vd, 0, MO_32); | 177 | -DO_GEN_ST(32, MO_UL) |
132 | 178 | - | |
133 | shiftfn(rm2, rm2, constimm); | 179 | static inline void gen_hvc(DisasContext *s, int imm16) |
134 | - rd = tcg_temp_new_i32(); | ||
135 | narrowfn(rd, cpu_env, rm2); | ||
136 | - neon_store_reg(a->vd, 1, rd); | ||
137 | + write_neon_element32(rd, a->vd, 1, MO_32); | ||
138 | |||
139 | + tcg_temp_free_i32(rd); | ||
140 | tcg_temp_free_i64(rm1); | ||
141 | tcg_temp_free_i64(rm2); | ||
142 | tcg_temp_free_i64(constimm); | ||
143 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | ||
144 | constimm = tcg_const_i32(imm); | ||
145 | |||
146 | /* Load all inputs first to avoid potential overwrite */ | ||
147 | - rm1 = neon_load_reg(a->vm, 0); | ||
148 | - rm2 = neon_load_reg(a->vm, 1); | ||
149 | - rm3 = neon_load_reg(a->vm + 1, 0); | ||
150 | - rm4 = neon_load_reg(a->vm + 1, 1); | ||
151 | + rm1 = tcg_temp_new_i32(); | ||
152 | + rm2 = tcg_temp_new_i32(); | ||
153 | + rm3 = tcg_temp_new_i32(); | ||
154 | + rm4 = tcg_temp_new_i32(); | ||
155 | + read_neon_element32(rm1, a->vm, 0, MO_32); | ||
156 | + read_neon_element32(rm2, a->vm, 1, MO_32); | ||
157 | + read_neon_element32(rm3, a->vm, 2, MO_32); | ||
158 | + read_neon_element32(rm4, a->vm, 3, MO_32); | ||
159 | rtmp = tcg_temp_new_i64(); | ||
160 | |||
161 | shiftfn(rm1, rm1, constimm); | ||
162 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | ||
163 | tcg_temp_free_i32(rm2); | ||
164 | |||
165 | narrowfn(rm1, cpu_env, rtmp); | ||
166 | - neon_store_reg(a->vd, 0, rm1); | ||
167 | + write_neon_element32(rm1, a->vd, 0, MO_32); | ||
168 | + tcg_temp_free_i32(rm1); | ||
169 | |||
170 | shiftfn(rm3, rm3, constimm); | ||
171 | shiftfn(rm4, rm4, constimm); | ||
172 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | ||
173 | |||
174 | narrowfn(rm3, cpu_env, rtmp); | ||
175 | tcg_temp_free_i64(rtmp); | ||
176 | - neon_store_reg(a->vd, 1, rm3); | ||
177 | + write_neon_element32(rm3, a->vd, 1, MO_32); | ||
178 | + tcg_temp_free_i32(rm3); | ||
179 | return true; | ||
180 | } | ||
181 | |||
182 | @@ -XXX,XX +XXX,XX @@ static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a, | ||
183 | widen_mask = dup_const(a->size + 1, widen_mask); | ||
184 | } | ||
185 | |||
186 | - rm0 = neon_load_reg(a->vm, 0); | ||
187 | - rm1 = neon_load_reg(a->vm, 1); | ||
188 | + rm0 = tcg_temp_new_i32(); | ||
189 | + rm1 = tcg_temp_new_i32(); | ||
190 | + read_neon_element32(rm0, a->vm, 0, MO_32); | ||
191 | + read_neon_element32(rm1, a->vm, 1, MO_32); | ||
192 | tmp = tcg_temp_new_i64(); | ||
193 | |||
194 | widenfn(tmp, rm0); | ||
195 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
196 | if (src1_wide) { | ||
197 | neon_load_reg64(rn0_64, a->vn); | ||
198 | } else { | ||
199 | - TCGv_i32 tmp = neon_load_reg(a->vn, 0); | ||
200 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
201 | + read_neon_element32(tmp, a->vn, 0, MO_32); | ||
202 | widenfn(rn0_64, tmp); | ||
203 | tcg_temp_free_i32(tmp); | ||
204 | } | ||
205 | - rm = neon_load_reg(a->vm, 0); | ||
206 | + rm = tcg_temp_new_i32(); | ||
207 | + read_neon_element32(rm, a->vm, 0, MO_32); | ||
208 | |||
209 | widenfn(rm_64, rm); | ||
210 | tcg_temp_free_i32(rm); | ||
211 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
212 | if (src1_wide) { | ||
213 | neon_load_reg64(rn1_64, a->vn + 1); | ||
214 | } else { | ||
215 | - TCGv_i32 tmp = neon_load_reg(a->vn, 1); | ||
216 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
217 | + read_neon_element32(tmp, a->vn, 1, MO_32); | ||
218 | widenfn(rn1_64, tmp); | ||
219 | tcg_temp_free_i32(tmp); | ||
220 | } | ||
221 | - rm = neon_load_reg(a->vm, 1); | ||
222 | + rm = tcg_temp_new_i32(); | ||
223 | + read_neon_element32(rm, a->vm, 1, MO_32); | ||
224 | |||
225 | neon_store_reg64(rn0_64, a->vd); | ||
226 | |||
227 | @@ -XXX,XX +XXX,XX @@ static bool do_narrow_3d(DisasContext *s, arg_3diff *a, | ||
228 | |||
229 | narrowfn(rd1, rn_64); | ||
230 | |||
231 | - neon_store_reg(a->vd, 0, rd0); | ||
232 | - neon_store_reg(a->vd, 1, rd1); | ||
233 | + write_neon_element32(rd0, a->vd, 0, MO_32); | ||
234 | + write_neon_element32(rd1, a->vd, 1, MO_32); | ||
235 | |||
236 | + tcg_temp_free_i32(rd0); | ||
237 | + tcg_temp_free_i32(rd1); | ||
238 | tcg_temp_free_i64(rn_64); | ||
239 | tcg_temp_free_i64(rm_64); | ||
240 | |||
241 | @@ -XXX,XX +XXX,XX @@ static bool do_long_3d(DisasContext *s, arg_3diff *a, | ||
242 | rd0 = tcg_temp_new_i64(); | ||
243 | rd1 = tcg_temp_new_i64(); | ||
244 | |||
245 | - rn = neon_load_reg(a->vn, 0); | ||
246 | - rm = neon_load_reg(a->vm, 0); | ||
247 | + rn = tcg_temp_new_i32(); | ||
248 | + rm = tcg_temp_new_i32(); | ||
249 | + read_neon_element32(rn, a->vn, 0, MO_32); | ||
250 | + read_neon_element32(rm, a->vm, 0, MO_32); | ||
251 | opfn(rd0, rn, rm); | ||
252 | - tcg_temp_free_i32(rn); | ||
253 | - tcg_temp_free_i32(rm); | ||
254 | |||
255 | - rn = neon_load_reg(a->vn, 1); | ||
256 | - rm = neon_load_reg(a->vm, 1); | ||
257 | + read_neon_element32(rn, a->vn, 1, MO_32); | ||
258 | + read_neon_element32(rm, a->vm, 1, MO_32); | ||
259 | opfn(rd1, rn, rm); | ||
260 | tcg_temp_free_i32(rn); | ||
261 | tcg_temp_free_i32(rm); | ||
262 | @@ -XXX,XX +XXX,XX @@ static void gen_neon_dup_high16(TCGv_i32 var) | ||
263 | |||
264 | static inline TCGv_i32 neon_get_scalar(int size, int reg) | ||
265 | { | 180 | { |
266 | - TCGv_i32 tmp; | 181 | /* The pre HVC helper handles cases when HVC gets trapped |
267 | - if (size == 1) { | ||
268 | - tmp = neon_load_reg(reg & 7, reg >> 4); | ||
269 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
270 | + if (size == MO_16) { | ||
271 | + read_neon_element32(tmp, reg & 7, reg >> 4, MO_32); | ||
272 | if (reg & 8) { | ||
273 | gen_neon_dup_high16(tmp); | ||
274 | } else { | ||
275 | gen_neon_dup_low16(tmp); | ||
276 | } | ||
277 | } else { | ||
278 | - tmp = neon_load_reg(reg & 15, reg >> 4); | ||
279 | + read_neon_element32(tmp, reg & 15, reg >> 4, MO_32); | ||
280 | } | ||
281 | return tmp; | ||
282 | } | ||
283 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar(DisasContext *s, arg_2scalar *a, | ||
284 | * perform an accumulation operation of that result into the | ||
285 | * destination. | ||
286 | */ | ||
287 | - TCGv_i32 scalar; | ||
288 | + TCGv_i32 scalar, tmp; | ||
289 | int pass; | ||
290 | |||
291 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
292 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar(DisasContext *s, arg_2scalar *a, | ||
293 | } | ||
294 | |||
295 | scalar = neon_get_scalar(a->size, a->vm); | ||
296 | + tmp = tcg_temp_new_i32(); | ||
297 | |||
298 | for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
299 | - TCGv_i32 tmp = neon_load_reg(a->vn, pass); | ||
300 | + read_neon_element32(tmp, a->vn, pass, MO_32); | ||
301 | opfn(tmp, tmp, scalar); | ||
302 | if (accfn) { | ||
303 | - TCGv_i32 rd = neon_load_reg(a->vd, pass); | ||
304 | + TCGv_i32 rd = tcg_temp_new_i32(); | ||
305 | + read_neon_element32(rd, a->vd, pass, MO_32); | ||
306 | accfn(tmp, rd, tmp); | ||
307 | tcg_temp_free_i32(rd); | ||
308 | } | ||
309 | - neon_store_reg(a->vd, pass, tmp); | ||
310 | + write_neon_element32(tmp, a->vd, pass, MO_32); | ||
311 | } | ||
312 | + tcg_temp_free_i32(tmp); | ||
313 | tcg_temp_free_i32(scalar); | ||
314 | return true; | ||
315 | } | ||
316 | @@ -XXX,XX +XXX,XX @@ static bool do_vqrdmlah_2sc(DisasContext *s, arg_2scalar *a, | ||
317 | * performs a kind of fused op-then-accumulate using a helper | ||
318 | * function that takes all of rd, rn and the scalar at once. | ||
319 | */ | ||
320 | - TCGv_i32 scalar; | ||
321 | + TCGv_i32 scalar, rn, rd; | ||
322 | int pass; | ||
323 | |||
324 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
325 | @@ -XXX,XX +XXX,XX @@ static bool do_vqrdmlah_2sc(DisasContext *s, arg_2scalar *a, | ||
326 | } | ||
327 | |||
328 | scalar = neon_get_scalar(a->size, a->vm); | ||
329 | + rn = tcg_temp_new_i32(); | ||
330 | + rd = tcg_temp_new_i32(); | ||
331 | |||
332 | for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
333 | - TCGv_i32 rn = neon_load_reg(a->vn, pass); | ||
334 | - TCGv_i32 rd = neon_load_reg(a->vd, pass); | ||
335 | + read_neon_element32(rn, a->vn, pass, MO_32); | ||
336 | + read_neon_element32(rd, a->vd, pass, MO_32); | ||
337 | opfn(rd, cpu_env, rn, scalar, rd); | ||
338 | - tcg_temp_free_i32(rn); | ||
339 | - neon_store_reg(a->vd, pass, rd); | ||
340 | + write_neon_element32(rd, a->vd, pass, MO_32); | ||
341 | } | ||
342 | + tcg_temp_free_i32(rn); | ||
343 | + tcg_temp_free_i32(rd); | ||
344 | tcg_temp_free_i32(scalar); | ||
345 | |||
346 | return true; | ||
347 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar_long(DisasContext *s, arg_2scalar *a, | ||
348 | scalar = neon_get_scalar(a->size, a->vm); | ||
349 | |||
350 | /* Load all inputs before writing any outputs, in case of overlap */ | ||
351 | - rn = neon_load_reg(a->vn, 0); | ||
352 | + rn = tcg_temp_new_i32(); | ||
353 | + read_neon_element32(rn, a->vn, 0, MO_32); | ||
354 | rn0_64 = tcg_temp_new_i64(); | ||
355 | opfn(rn0_64, rn, scalar); | ||
356 | - tcg_temp_free_i32(rn); | ||
357 | |||
358 | - rn = neon_load_reg(a->vn, 1); | ||
359 | + read_neon_element32(rn, a->vn, 1, MO_32); | ||
360 | rn1_64 = tcg_temp_new_i64(); | ||
361 | opfn(rn1_64, rn, scalar); | ||
362 | tcg_temp_free_i32(rn); | ||
363 | @@ -XXX,XX +XXX,XX @@ static bool trans_VTBL(DisasContext *s, arg_VTBL *a) | ||
364 | return false; | ||
365 | } | ||
366 | n <<= 3; | ||
367 | + tmp = tcg_temp_new_i32(); | ||
368 | if (a->op) { | ||
369 | - tmp = neon_load_reg(a->vd, 0); | ||
370 | + read_neon_element32(tmp, a->vd, 0, MO_32); | ||
371 | } else { | ||
372 | - tmp = tcg_temp_new_i32(); | ||
373 | tcg_gen_movi_i32(tmp, 0); | ||
374 | } | ||
375 | - tmp2 = neon_load_reg(a->vm, 0); | ||
376 | + tmp2 = tcg_temp_new_i32(); | ||
377 | + read_neon_element32(tmp2, a->vm, 0, MO_32); | ||
378 | ptr1 = vfp_reg_ptr(true, a->vn); | ||
379 | tmp4 = tcg_const_i32(n); | ||
380 | gen_helper_neon_tbl(tmp2, tmp2, tmp, ptr1, tmp4); | ||
381 | - tcg_temp_free_i32(tmp); | ||
382 | + | ||
383 | if (a->op) { | ||
384 | - tmp = neon_load_reg(a->vd, 1); | ||
385 | + read_neon_element32(tmp, a->vd, 1, MO_32); | ||
386 | } else { | ||
387 | - tmp = tcg_temp_new_i32(); | ||
388 | tcg_gen_movi_i32(tmp, 0); | ||
389 | } | ||
390 | - tmp3 = neon_load_reg(a->vm, 1); | ||
391 | + tmp3 = tcg_temp_new_i32(); | ||
392 | + read_neon_element32(tmp3, a->vm, 1, MO_32); | ||
393 | gen_helper_neon_tbl(tmp3, tmp3, tmp, ptr1, tmp4); | ||
394 | + tcg_temp_free_i32(tmp); | ||
395 | tcg_temp_free_i32(tmp4); | ||
396 | tcg_temp_free_ptr(ptr1); | ||
397 | - neon_store_reg(a->vd, 0, tmp2); | ||
398 | - neon_store_reg(a->vd, 1, tmp3); | ||
399 | - tcg_temp_free_i32(tmp); | ||
400 | + | ||
401 | + write_neon_element32(tmp2, a->vd, 0, MO_32); | ||
402 | + write_neon_element32(tmp3, a->vd, 1, MO_32); | ||
403 | + tcg_temp_free_i32(tmp2); | ||
404 | + tcg_temp_free_i32(tmp3); | ||
405 | return true; | ||
406 | } | ||
407 | |||
408 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDUP_scalar(DisasContext *s, arg_VDUP_scalar *a) | ||
409 | static bool trans_VREV64(DisasContext *s, arg_VREV64 *a) | ||
410 | { | ||
411 | int pass, half; | ||
412 | + TCGv_i32 tmp[2]; | ||
413 | |||
414 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
415 | return false; | ||
416 | @@ -XXX,XX +XXX,XX @@ static bool trans_VREV64(DisasContext *s, arg_VREV64 *a) | ||
417 | return true; | ||
418 | } | ||
419 | |||
420 | - for (pass = 0; pass < (a->q ? 2 : 1); pass++) { | ||
421 | - TCGv_i32 tmp[2]; | ||
422 | + tmp[0] = tcg_temp_new_i32(); | ||
423 | + tmp[1] = tcg_temp_new_i32(); | ||
424 | |||
425 | + for (pass = 0; pass < (a->q ? 2 : 1); pass++) { | ||
426 | for (half = 0; half < 2; half++) { | ||
427 | - tmp[half] = neon_load_reg(a->vm, pass * 2 + half); | ||
428 | + read_neon_element32(tmp[half], a->vm, pass * 2 + half, MO_32); | ||
429 | switch (a->size) { | ||
430 | case 0: | ||
431 | tcg_gen_bswap32_i32(tmp[half], tmp[half]); | ||
432 | @@ -XXX,XX +XXX,XX @@ static bool trans_VREV64(DisasContext *s, arg_VREV64 *a) | ||
433 | g_assert_not_reached(); | ||
434 | } | ||
435 | } | ||
436 | - neon_store_reg(a->vd, pass * 2, tmp[1]); | ||
437 | - neon_store_reg(a->vd, pass * 2 + 1, tmp[0]); | ||
438 | + write_neon_element32(tmp[1], a->vd, pass * 2, MO_32); | ||
439 | + write_neon_element32(tmp[0], a->vd, pass * 2 + 1, MO_32); | ||
440 | } | ||
441 | + | ||
442 | + tcg_temp_free_i32(tmp[0]); | ||
443 | + tcg_temp_free_i32(tmp[1]); | ||
444 | return true; | ||
445 | } | ||
446 | |||
447 | @@ -XXX,XX +XXX,XX @@ static bool do_2misc_pairwise(DisasContext *s, arg_2misc *a, | ||
448 | rm0_64 = tcg_temp_new_i64(); | ||
449 | rm1_64 = tcg_temp_new_i64(); | ||
450 | rd_64 = tcg_temp_new_i64(); | ||
451 | - tmp = neon_load_reg(a->vm, pass * 2); | ||
452 | + | ||
453 | + tmp = tcg_temp_new_i32(); | ||
454 | + read_neon_element32(tmp, a->vm, pass * 2, MO_32); | ||
455 | widenfn(rm0_64, tmp); | ||
456 | - tcg_temp_free_i32(tmp); | ||
457 | - tmp = neon_load_reg(a->vm, pass * 2 + 1); | ||
458 | + read_neon_element32(tmp, a->vm, pass * 2 + 1, MO_32); | ||
459 | widenfn(rm1_64, tmp); | ||
460 | tcg_temp_free_i32(tmp); | ||
461 | + | ||
462 | opfn(rd_64, rm0_64, rm1_64); | ||
463 | tcg_temp_free_i64(rm0_64); | ||
464 | tcg_temp_free_i64(rm1_64); | ||
465 | @@ -XXX,XX +XXX,XX @@ static bool do_vmovn(DisasContext *s, arg_2misc *a, | ||
466 | narrowfn(rd0, cpu_env, rm); | ||
467 | neon_load_reg64(rm, a->vm + 1); | ||
468 | narrowfn(rd1, cpu_env, rm); | ||
469 | - neon_store_reg(a->vd, 0, rd0); | ||
470 | - neon_store_reg(a->vd, 1, rd1); | ||
471 | + write_neon_element32(rd0, a->vd, 0, MO_32); | ||
472 | + write_neon_element32(rd1, a->vd, 1, MO_32); | ||
473 | + tcg_temp_free_i32(rd0); | ||
474 | + tcg_temp_free_i32(rd1); | ||
475 | tcg_temp_free_i64(rm); | ||
476 | return true; | ||
477 | } | ||
478 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL(DisasContext *s, arg_2misc *a) | ||
479 | } | ||
480 | |||
481 | rd = tcg_temp_new_i64(); | ||
482 | + rm0 = tcg_temp_new_i32(); | ||
483 | + rm1 = tcg_temp_new_i32(); | ||
484 | |||
485 | - rm0 = neon_load_reg(a->vm, 0); | ||
486 | - rm1 = neon_load_reg(a->vm, 1); | ||
487 | + read_neon_element32(rm0, a->vm, 0, MO_32); | ||
488 | + read_neon_element32(rm1, a->vm, 1, MO_32); | ||
489 | |||
490 | widenfn(rd, rm0); | ||
491 | tcg_gen_shli_i64(rd, rd, 8 << a->size); | ||
492 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_F16_F32(DisasContext *s, arg_2misc *a) | ||
493 | |||
494 | fpst = fpstatus_ptr(FPST_STD); | ||
495 | ahp = get_ahp_flag(); | ||
496 | - tmp = neon_load_reg(a->vm, 0); | ||
497 | + tmp = tcg_temp_new_i32(); | ||
498 | + read_neon_element32(tmp, a->vm, 0, MO_32); | ||
499 | gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp); | ||
500 | - tmp2 = neon_load_reg(a->vm, 1); | ||
501 | + tmp2 = tcg_temp_new_i32(); | ||
502 | + read_neon_element32(tmp2, a->vm, 1, MO_32); | ||
503 | gen_helper_vfp_fcvt_f32_to_f16(tmp2, tmp2, fpst, ahp); | ||
504 | tcg_gen_shli_i32(tmp2, tmp2, 16); | ||
505 | tcg_gen_or_i32(tmp2, tmp2, tmp); | ||
506 | - tcg_temp_free_i32(tmp); | ||
507 | - tmp = neon_load_reg(a->vm, 2); | ||
508 | + read_neon_element32(tmp, a->vm, 2, MO_32); | ||
509 | gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp); | ||
510 | - tmp3 = neon_load_reg(a->vm, 3); | ||
511 | - neon_store_reg(a->vd, 0, tmp2); | ||
512 | + tmp3 = tcg_temp_new_i32(); | ||
513 | + read_neon_element32(tmp3, a->vm, 3, MO_32); | ||
514 | + write_neon_element32(tmp2, a->vd, 0, MO_32); | ||
515 | + tcg_temp_free_i32(tmp2); | ||
516 | gen_helper_vfp_fcvt_f32_to_f16(tmp3, tmp3, fpst, ahp); | ||
517 | tcg_gen_shli_i32(tmp3, tmp3, 16); | ||
518 | tcg_gen_or_i32(tmp3, tmp3, tmp); | ||
519 | - neon_store_reg(a->vd, 1, tmp3); | ||
520 | + write_neon_element32(tmp3, a->vd, 1, MO_32); | ||
521 | + tcg_temp_free_i32(tmp3); | ||
522 | tcg_temp_free_i32(tmp); | ||
523 | tcg_temp_free_i32(ahp); | ||
524 | tcg_temp_free_ptr(fpst); | ||
525 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_F32_F16(DisasContext *s, arg_2misc *a) | ||
526 | fpst = fpstatus_ptr(FPST_STD); | ||
527 | ahp = get_ahp_flag(); | ||
528 | tmp3 = tcg_temp_new_i32(); | ||
529 | - tmp = neon_load_reg(a->vm, 0); | ||
530 | - tmp2 = neon_load_reg(a->vm, 1); | ||
531 | + tmp2 = tcg_temp_new_i32(); | ||
532 | + tmp = tcg_temp_new_i32(); | ||
533 | + read_neon_element32(tmp, a->vm, 0, MO_32); | ||
534 | + read_neon_element32(tmp2, a->vm, 1, MO_32); | ||
535 | tcg_gen_ext16u_i32(tmp3, tmp); | ||
536 | gen_helper_vfp_fcvt_f16_to_f32(tmp3, tmp3, fpst, ahp); | ||
537 | - neon_store_reg(a->vd, 0, tmp3); | ||
538 | + write_neon_element32(tmp3, a->vd, 0, MO_32); | ||
539 | tcg_gen_shri_i32(tmp, tmp, 16); | ||
540 | gen_helper_vfp_fcvt_f16_to_f32(tmp, tmp, fpst, ahp); | ||
541 | - neon_store_reg(a->vd, 1, tmp); | ||
542 | - tmp3 = tcg_temp_new_i32(); | ||
543 | + write_neon_element32(tmp, a->vd, 1, MO_32); | ||
544 | + tcg_temp_free_i32(tmp); | ||
545 | tcg_gen_ext16u_i32(tmp3, tmp2); | ||
546 | gen_helper_vfp_fcvt_f16_to_f32(tmp3, tmp3, fpst, ahp); | ||
547 | - neon_store_reg(a->vd, 2, tmp3); | ||
548 | + write_neon_element32(tmp3, a->vd, 2, MO_32); | ||
549 | + tcg_temp_free_i32(tmp3); | ||
550 | tcg_gen_shri_i32(tmp2, tmp2, 16); | ||
551 | gen_helper_vfp_fcvt_f16_to_f32(tmp2, tmp2, fpst, ahp); | ||
552 | - neon_store_reg(a->vd, 3, tmp2); | ||
553 | + write_neon_element32(tmp2, a->vd, 3, MO_32); | ||
554 | + tcg_temp_free_i32(tmp2); | ||
555 | tcg_temp_free_i32(ahp); | ||
556 | tcg_temp_free_ptr(fpst); | ||
557 | |||
558 | @@ -XXX,XX +XXX,XX @@ DO_2M_CRYPTO(SHA256SU0, aa32_sha2, 2) | ||
559 | |||
560 | static bool do_2misc(DisasContext *s, arg_2misc *a, NeonGenOneOpFn *fn) | ||
561 | { | ||
562 | + TCGv_i32 tmp; | ||
563 | int pass; | ||
564 | |||
565 | /* Handle a 2-reg-misc operation by iterating 32 bits at a time */ | ||
566 | @@ -XXX,XX +XXX,XX @@ static bool do_2misc(DisasContext *s, arg_2misc *a, NeonGenOneOpFn *fn) | ||
567 | return true; | ||
568 | } | ||
569 | |||
570 | + tmp = tcg_temp_new_i32(); | ||
571 | for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
572 | - TCGv_i32 tmp = neon_load_reg(a->vm, pass); | ||
573 | + read_neon_element32(tmp, a->vm, pass, MO_32); | ||
574 | fn(tmp, tmp); | ||
575 | - neon_store_reg(a->vd, pass, tmp); | ||
576 | + write_neon_element32(tmp, a->vd, pass, MO_32); | ||
577 | } | ||
578 | + tcg_temp_free_i32(tmp); | ||
579 | |||
580 | return true; | ||
581 | } | ||
582 | @@ -XXX,XX +XXX,XX @@ static bool trans_VTRN(DisasContext *s, arg_2misc *a) | ||
583 | return true; | ||
584 | } | ||
585 | |||
586 | - if (a->size == 2) { | ||
587 | + tmp = tcg_temp_new_i32(); | ||
588 | + tmp2 = tcg_temp_new_i32(); | ||
589 | + if (a->size == MO_32) { | ||
590 | for (pass = 0; pass < (a->q ? 4 : 2); pass += 2) { | ||
591 | - tmp = neon_load_reg(a->vm, pass); | ||
592 | - tmp2 = neon_load_reg(a->vd, pass + 1); | ||
593 | - neon_store_reg(a->vm, pass, tmp2); | ||
594 | - neon_store_reg(a->vd, pass + 1, tmp); | ||
595 | + read_neon_element32(tmp, a->vm, pass, MO_32); | ||
596 | + read_neon_element32(tmp2, a->vd, pass + 1, MO_32); | ||
597 | + write_neon_element32(tmp2, a->vm, pass, MO_32); | ||
598 | + write_neon_element32(tmp, a->vd, pass + 1, MO_32); | ||
599 | } | ||
600 | } else { | ||
601 | for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
602 | - tmp = neon_load_reg(a->vm, pass); | ||
603 | - tmp2 = neon_load_reg(a->vd, pass); | ||
604 | - if (a->size == 0) { | ||
605 | + read_neon_element32(tmp, a->vm, pass, MO_32); | ||
606 | + read_neon_element32(tmp2, a->vd, pass, MO_32); | ||
607 | + if (a->size == MO_8) { | ||
608 | gen_neon_trn_u8(tmp, tmp2); | ||
609 | } else { | ||
610 | gen_neon_trn_u16(tmp, tmp2); | ||
611 | } | ||
612 | - neon_store_reg(a->vm, pass, tmp2); | ||
613 | - neon_store_reg(a->vd, pass, tmp); | ||
614 | + write_neon_element32(tmp2, a->vm, pass, MO_32); | ||
615 | + write_neon_element32(tmp, a->vd, pass, MO_32); | ||
616 | } | ||
617 | } | ||
618 | + tcg_temp_free_i32(tmp); | ||
619 | + tcg_temp_free_i32(tmp2); | ||
620 | return true; | ||
621 | } | ||
622 | -- | 182 | -- |
623 | 2.20.1 | 183 | 2.20.1 |
624 | 184 | ||
625 | 185 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The functions vfp_load_reg32(), vfp_load_reg64(), vfp_store_reg32() |
---|---|---|---|
2 | and vfp_store_reg64() are used only in translate-vfp.c.inc. Move | ||
3 | them to that file. | ||
2 | 4 | ||
3 | The only uses of this function are for loading VFP | ||
4 | double-precision values, and nothing to do with NEON. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20201030022618.785675-10-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210430132740.10391-7-peter.maydell@linaro.org | ||
10 | --- | 9 | --- |
11 | target/arm/translate.c | 8 ++-- | 10 | target/arm/translate.c | 20 -------------------- |
12 | target/arm/translate-vfp.c.inc | 84 +++++++++++++++++----------------- | 11 | target/arm/translate-vfp.c.inc | 20 ++++++++++++++++++++ |
13 | 2 files changed, 46 insertions(+), 46 deletions(-) | 12 | 2 files changed, 20 insertions(+), 20 deletions(-) |
14 | 13 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 14 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 16 | --- a/target/arm/translate.c |
18 | +++ b/target/arm/translate.c | 17 | +++ b/target/arm/translate.c |
19 | @@ -XXX,XX +XXX,XX @@ static long vfp_reg_offset(bool dp, unsigned reg) | 18 | @@ -XXX,XX +XXX,XX @@ static long vfp_reg_offset(bool dp, unsigned reg) |
20 | } | 19 | } |
21 | } | 20 | } |
22 | 21 | ||
23 | -static inline void neon_load_reg64(TCGv_i64 var, int reg) | 22 | -static inline void vfp_load_reg64(TCGv_i64 var, int reg) |
24 | +static inline void vfp_load_reg64(TCGv_i64 var, int reg) | 23 | -{ |
24 | - tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(true, reg)); | ||
25 | -} | ||
26 | - | ||
27 | -static inline void vfp_store_reg64(TCGv_i64 var, int reg) | ||
28 | -{ | ||
29 | - tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(true, reg)); | ||
30 | -} | ||
31 | - | ||
32 | -static inline void vfp_load_reg32(TCGv_i32 var, int reg) | ||
33 | -{ | ||
34 | - tcg_gen_ld_i32(var, cpu_env, vfp_reg_offset(false, reg)); | ||
35 | -} | ||
36 | - | ||
37 | -static inline void vfp_store_reg32(TCGv_i32 var, int reg) | ||
38 | -{ | ||
39 | - tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); | ||
40 | -} | ||
41 | - | ||
42 | void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop) | ||
25 | { | 43 | { |
26 | - tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg)); | 44 | long off = neon_element_offset(reg, ele, memop); |
27 | + tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(true, reg)); | ||
28 | } | ||
29 | |||
30 | -static inline void neon_store_reg64(TCGv_i64 var, int reg) | ||
31 | +static inline void vfp_store_reg64(TCGv_i64 var, int reg) | ||
32 | { | ||
33 | - tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(1, reg)); | ||
34 | + tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(true, reg)); | ||
35 | } | ||
36 | |||
37 | static inline void vfp_load_reg32(TCGv_i32 var, int reg) | ||
38 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | 45 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc |
39 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/target/arm/translate-vfp.c.inc | 47 | --- a/target/arm/translate-vfp.c.inc |
41 | +++ b/target/arm/translate-vfp.c.inc | 48 | +++ b/target/arm/translate-vfp.c.inc |
42 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | 49 | @@ -XXX,XX +XXX,XX @@ |
43 | tcg_gen_ext_i32_i64(nf, cpu_NF); | 50 | #include "decode-vfp.c.inc" |
44 | tcg_gen_ext_i32_i64(vf, cpu_VF); | 51 | #include "decode-vfp-uncond.c.inc" |
45 | 52 | ||
46 | - neon_load_reg64(frn, rn); | 53 | +static inline void vfp_load_reg64(TCGv_i64 var, int reg) |
47 | - neon_load_reg64(frm, rm); | 54 | +{ |
48 | + vfp_load_reg64(frn, rn); | 55 | + tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(true, reg)); |
49 | + vfp_load_reg64(frm, rm); | 56 | +} |
50 | switch (a->cc) { | 57 | + |
51 | case 0: /* eq: Z */ | 58 | +static inline void vfp_store_reg64(TCGv_i64 var, int reg) |
52 | tcg_gen_movcond_i64(TCG_COND_EQ, dest, zf, zero, | 59 | +{ |
53 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | 60 | + tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(true, reg)); |
54 | tcg_temp_free_i64(tmp); | 61 | +} |
55 | break; | 62 | + |
56 | } | 63 | +static inline void vfp_load_reg32(TCGv_i32 var, int reg) |
57 | - neon_store_reg64(dest, rd); | 64 | +{ |
58 | + vfp_store_reg64(dest, rd); | 65 | + tcg_gen_ld_i32(var, cpu_env, vfp_reg_offset(false, reg)); |
59 | tcg_temp_free_i64(frn); | 66 | +} |
60 | tcg_temp_free_i64(frm); | 67 | + |
61 | tcg_temp_free_i64(dest); | 68 | +static inline void vfp_store_reg32(TCGv_i32 var, int reg) |
62 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) | 69 | +{ |
63 | TCGv_i64 tcg_res; | 70 | + tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); |
64 | tcg_op = tcg_temp_new_i64(); | 71 | +} |
65 | tcg_res = tcg_temp_new_i64(); | 72 | + |
66 | - neon_load_reg64(tcg_op, rm); | 73 | /* |
67 | + vfp_load_reg64(tcg_op, rm); | 74 | * The imm8 encodes the sign bit, enough bits to represent an exponent in |
68 | gen_helper_rintd(tcg_res, tcg_op, fpst); | 75 | * the range 01....1xx to 10....0xx, and the most significant 4 bits of |
69 | - neon_store_reg64(tcg_res, rd); | ||
70 | + vfp_store_reg64(tcg_res, rd); | ||
71 | tcg_temp_free_i64(tcg_op); | ||
72 | tcg_temp_free_i64(tcg_res); | ||
73 | } else { | ||
74 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT(DisasContext *s, arg_VCVT *a) | ||
75 | tcg_double = tcg_temp_new_i64(); | ||
76 | tcg_res = tcg_temp_new_i64(); | ||
77 | tcg_tmp = tcg_temp_new_i32(); | ||
78 | - neon_load_reg64(tcg_double, rm); | ||
79 | + vfp_load_reg64(tcg_double, rm); | ||
80 | if (is_signed) { | ||
81 | gen_helper_vfp_tosld(tcg_res, tcg_double, tcg_shift, fpst); | ||
82 | } else { | ||
83 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a) | ||
84 | tmp = tcg_temp_new_i64(); | ||
85 | if (a->l) { | ||
86 | gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); | ||
87 | - neon_store_reg64(tmp, a->vd); | ||
88 | + vfp_store_reg64(tmp, a->vd); | ||
89 | } else { | ||
90 | - neon_load_reg64(tmp, a->vd); | ||
91 | + vfp_load_reg64(tmp, a->vd); | ||
92 | gen_aa32_st64(s, tmp, addr, get_mem_index(s)); | ||
93 | } | ||
94 | tcg_temp_free_i64(tmp); | ||
95 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) | ||
96 | if (a->l) { | ||
97 | /* load */ | ||
98 | gen_aa32_ld64(s, tmp, addr, get_mem_index(s)); | ||
99 | - neon_store_reg64(tmp, a->vd + i); | ||
100 | + vfp_store_reg64(tmp, a->vd + i); | ||
101 | } else { | ||
102 | /* store */ | ||
103 | - neon_load_reg64(tmp, a->vd + i); | ||
104 | + vfp_load_reg64(tmp, a->vd + i); | ||
105 | gen_aa32_st64(s, tmp, addr, get_mem_index(s)); | ||
106 | } | ||
107 | tcg_gen_addi_i32(addr, addr, offset); | ||
108 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, | ||
109 | fd = tcg_temp_new_i64(); | ||
110 | fpst = fpstatus_ptr(FPST_FPCR); | ||
111 | |||
112 | - neon_load_reg64(f0, vn); | ||
113 | - neon_load_reg64(f1, vm); | ||
114 | + vfp_load_reg64(f0, vn); | ||
115 | + vfp_load_reg64(f1, vm); | ||
116 | |||
117 | for (;;) { | ||
118 | if (reads_vd) { | ||
119 | - neon_load_reg64(fd, vd); | ||
120 | + vfp_load_reg64(fd, vd); | ||
121 | } | ||
122 | fn(fd, f0, f1, fpst); | ||
123 | - neon_store_reg64(fd, vd); | ||
124 | + vfp_store_reg64(fd, vd); | ||
125 | |||
126 | if (veclen == 0) { | ||
127 | break; | ||
128 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_3op_dp(DisasContext *s, VFPGen3OpDPFn *fn, | ||
129 | veclen--; | ||
130 | vd = vfp_advance_dreg(vd, delta_d); | ||
131 | vn = vfp_advance_dreg(vn, delta_d); | ||
132 | - neon_load_reg64(f0, vn); | ||
133 | + vfp_load_reg64(f0, vn); | ||
134 | if (delta_m) { | ||
135 | vm = vfp_advance_dreg(vm, delta_m); | ||
136 | - neon_load_reg64(f1, vm); | ||
137 | + vfp_load_reg64(f1, vm); | ||
138 | } | ||
139 | } | ||
140 | |||
141 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) | ||
142 | f0 = tcg_temp_new_i64(); | ||
143 | fd = tcg_temp_new_i64(); | ||
144 | |||
145 | - neon_load_reg64(f0, vm); | ||
146 | + vfp_load_reg64(f0, vm); | ||
147 | |||
148 | for (;;) { | ||
149 | fn(fd, f0); | ||
150 | - neon_store_reg64(fd, vd); | ||
151 | + vfp_store_reg64(fd, vd); | ||
152 | |||
153 | if (veclen == 0) { | ||
154 | break; | ||
155 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) | ||
156 | /* single source one-many */ | ||
157 | while (veclen--) { | ||
158 | vd = vfp_advance_dreg(vd, delta_d); | ||
159 | - neon_store_reg64(fd, vd); | ||
160 | + vfp_store_reg64(fd, vd); | ||
161 | } | ||
162 | break; | ||
163 | } | ||
164 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) | ||
165 | veclen--; | ||
166 | vd = vfp_advance_dreg(vd, delta_d); | ||
167 | vd = vfp_advance_dreg(vm, delta_m); | ||
168 | - neon_load_reg64(f0, vm); | ||
169 | + vfp_load_reg64(f0, vm); | ||
170 | } | ||
171 | |||
172 | tcg_temp_free_i64(f0); | ||
173 | @@ -XXX,XX +XXX,XX @@ static bool do_vfm_dp(DisasContext *s, arg_VFMA_dp *a, bool neg_n, bool neg_d) | ||
174 | vm = tcg_temp_new_i64(); | ||
175 | vd = tcg_temp_new_i64(); | ||
176 | |||
177 | - neon_load_reg64(vn, a->vn); | ||
178 | - neon_load_reg64(vm, a->vm); | ||
179 | + vfp_load_reg64(vn, a->vn); | ||
180 | + vfp_load_reg64(vm, a->vm); | ||
181 | if (neg_n) { | ||
182 | /* VFNMS, VFMS */ | ||
183 | gen_helper_vfp_negd(vn, vn); | ||
184 | } | ||
185 | - neon_load_reg64(vd, a->vd); | ||
186 | + vfp_load_reg64(vd, a->vd); | ||
187 | if (neg_d) { | ||
188 | /* VFNMA, VFNMS */ | ||
189 | gen_helper_vfp_negd(vd, vd); | ||
190 | } | ||
191 | fpst = fpstatus_ptr(FPST_FPCR); | ||
192 | gen_helper_vfp_muladdd(vd, vn, vm, vd, fpst); | ||
193 | - neon_store_reg64(vd, a->vd); | ||
194 | + vfp_store_reg64(vd, a->vd); | ||
195 | |||
196 | tcg_temp_free_ptr(fpst); | ||
197 | tcg_temp_free_i64(vn); | ||
198 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) | ||
199 | fd = tcg_const_i64(vfp_expand_imm(MO_64, a->imm)); | ||
200 | |||
201 | for (;;) { | ||
202 | - neon_store_reg64(fd, vd); | ||
203 | + vfp_store_reg64(fd, vd); | ||
204 | |||
205 | if (veclen == 0) { | ||
206 | break; | ||
207 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_dp(DisasContext *s, arg_VCMP_dp *a) | ||
208 | vd = tcg_temp_new_i64(); | ||
209 | vm = tcg_temp_new_i64(); | ||
210 | |||
211 | - neon_load_reg64(vd, a->vd); | ||
212 | + vfp_load_reg64(vd, a->vd); | ||
213 | if (a->z) { | ||
214 | tcg_gen_movi_i64(vm, 0); | ||
215 | } else { | ||
216 | - neon_load_reg64(vm, a->vm); | ||
217 | + vfp_load_reg64(vm, a->vm); | ||
218 | } | ||
219 | |||
220 | if (a->e) { | ||
221 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) | ||
222 | tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t)); | ||
223 | vd = tcg_temp_new_i64(); | ||
224 | gen_helper_vfp_fcvt_f16_to_f64(vd, tmp, fpst, ahp_mode); | ||
225 | - neon_store_reg64(vd, a->vd); | ||
226 | + vfp_store_reg64(vd, a->vd); | ||
227 | tcg_temp_free_i32(ahp_mode); | ||
228 | tcg_temp_free_ptr(fpst); | ||
229 | tcg_temp_free_i32(tmp); | ||
230 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f64(DisasContext *s, arg_VCVT_f16_f64 *a) | ||
231 | tmp = tcg_temp_new_i32(); | ||
232 | vm = tcg_temp_new_i64(); | ||
233 | |||
234 | - neon_load_reg64(vm, a->vm); | ||
235 | + vfp_load_reg64(vm, a->vm); | ||
236 | gen_helper_vfp_fcvt_f64_to_f16(tmp, vm, fpst, ahp_mode); | ||
237 | tcg_temp_free_i64(vm); | ||
238 | tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t)); | ||
239 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_dp(DisasContext *s, arg_VRINTR_dp *a) | ||
240 | } | ||
241 | |||
242 | tmp = tcg_temp_new_i64(); | ||
243 | - neon_load_reg64(tmp, a->vm); | ||
244 | + vfp_load_reg64(tmp, a->vm); | ||
245 | fpst = fpstatus_ptr(FPST_FPCR); | ||
246 | gen_helper_rintd(tmp, tmp, fpst); | ||
247 | - neon_store_reg64(tmp, a->vd); | ||
248 | + vfp_store_reg64(tmp, a->vd); | ||
249 | tcg_temp_free_ptr(fpst); | ||
250 | tcg_temp_free_i64(tmp); | ||
251 | return true; | ||
252 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_dp(DisasContext *s, arg_VRINTZ_dp *a) | ||
253 | } | ||
254 | |||
255 | tmp = tcg_temp_new_i64(); | ||
256 | - neon_load_reg64(tmp, a->vm); | ||
257 | + vfp_load_reg64(tmp, a->vm); | ||
258 | fpst = fpstatus_ptr(FPST_FPCR); | ||
259 | tcg_rmode = tcg_const_i32(float_round_to_zero); | ||
260 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
261 | gen_helper_rintd(tmp, tmp, fpst); | ||
262 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
263 | - neon_store_reg64(tmp, a->vd); | ||
264 | + vfp_store_reg64(tmp, a->vd); | ||
265 | tcg_temp_free_ptr(fpst); | ||
266 | tcg_temp_free_i64(tmp); | ||
267 | tcg_temp_free_i32(tcg_rmode); | ||
268 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_dp(DisasContext *s, arg_VRINTX_dp *a) | ||
269 | } | ||
270 | |||
271 | tmp = tcg_temp_new_i64(); | ||
272 | - neon_load_reg64(tmp, a->vm); | ||
273 | + vfp_load_reg64(tmp, a->vm); | ||
274 | fpst = fpstatus_ptr(FPST_FPCR); | ||
275 | gen_helper_rintd_exact(tmp, tmp, fpst); | ||
276 | - neon_store_reg64(tmp, a->vd); | ||
277 | + vfp_store_reg64(tmp, a->vd); | ||
278 | tcg_temp_free_ptr(fpst); | ||
279 | tcg_temp_free_i64(tmp); | ||
280 | return true; | ||
281 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a) | ||
282 | vd = tcg_temp_new_i64(); | ||
283 | vfp_load_reg32(vm, a->vm); | ||
284 | gen_helper_vfp_fcvtds(vd, vm, cpu_env); | ||
285 | - neon_store_reg64(vd, a->vd); | ||
286 | + vfp_store_reg64(vd, a->vd); | ||
287 | tcg_temp_free_i32(vm); | ||
288 | tcg_temp_free_i64(vd); | ||
289 | return true; | ||
290 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a) | ||
291 | |||
292 | vd = tcg_temp_new_i32(); | ||
293 | vm = tcg_temp_new_i64(); | ||
294 | - neon_load_reg64(vm, a->vm); | ||
295 | + vfp_load_reg64(vm, a->vm); | ||
296 | gen_helper_vfp_fcvtsd(vd, vm, cpu_env); | ||
297 | vfp_store_reg32(vd, a->vd); | ||
298 | tcg_temp_free_i32(vd); | ||
299 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a) | ||
300 | /* u32 -> f64 */ | ||
301 | gen_helper_vfp_uitod(vd, vm, fpst); | ||
302 | } | ||
303 | - neon_store_reg64(vd, a->vd); | ||
304 | + vfp_store_reg64(vd, a->vd); | ||
305 | tcg_temp_free_i32(vm); | ||
306 | tcg_temp_free_i64(vd); | ||
307 | tcg_temp_free_ptr(fpst); | ||
308 | @@ -XXX,XX +XXX,XX @@ static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a) | ||
309 | |||
310 | vm = tcg_temp_new_i64(); | ||
311 | vd = tcg_temp_new_i32(); | ||
312 | - neon_load_reg64(vm, a->vm); | ||
313 | + vfp_load_reg64(vm, a->vm); | ||
314 | gen_helper_vjcvt(vd, vm, cpu_env); | ||
315 | vfp_store_reg32(vd, a->vd); | ||
316 | tcg_temp_free_i64(vm); | ||
317 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) | ||
318 | frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm); | ||
319 | |||
320 | vd = tcg_temp_new_i64(); | ||
321 | - neon_load_reg64(vd, a->vd); | ||
322 | + vfp_load_reg64(vd, a->vd); | ||
323 | |||
324 | fpst = fpstatus_ptr(FPST_FPCR); | ||
325 | shift = tcg_const_i32(frac_bits); | ||
326 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_dp(DisasContext *s, arg_VCVT_fix_dp *a) | ||
327 | g_assert_not_reached(); | ||
328 | } | ||
329 | |||
330 | - neon_store_reg64(vd, a->vd); | ||
331 | + vfp_store_reg64(vd, a->vd); | ||
332 | tcg_temp_free_i64(vd); | ||
333 | tcg_temp_free_i32(shift); | ||
334 | tcg_temp_free_ptr(fpst); | ||
335 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp_int(DisasContext *s, arg_VCVT_dp_int *a) | ||
336 | fpst = fpstatus_ptr(FPST_FPCR); | ||
337 | vm = tcg_temp_new_i64(); | ||
338 | vd = tcg_temp_new_i32(); | ||
339 | - neon_load_reg64(vm, a->vm); | ||
340 | + vfp_load_reg64(vm, a->vm); | ||
341 | |||
342 | if (a->s) { | ||
343 | if (a->rz) { | ||
344 | -- | 76 | -- |
345 | 2.20.1 | 77 | 2.20.1 |
346 | 78 | ||
347 | 79 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Make the remaining functions which are needed by translate-vfp.c.inc |
---|---|---|---|
2 | global. | ||
2 | 3 | ||
3 | Replace all uses of neon_load/store_reg64 within translate-neon.c.inc. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210430132740.10391-8-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/translate-a32.h | 18 ++++++++++++++++++ | ||
10 | target/arm/translate.c | 25 ++++++++----------------- | ||
11 | 2 files changed, 26 insertions(+), 17 deletions(-) | ||
4 | 12 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 13 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h |
6 | Message-id: 20201030022618.785675-9-richard.henderson@linaro.org | 14 | index XXXXXXX..XXXXXXX 100644 |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | --- a/target/arm/translate-a32.h |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | +++ b/target/arm/translate-a32.h |
9 | --- | 17 | @@ -XXX,XX +XXX,XX @@ void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop); |
10 | target/arm/translate.c | 26 +++++++++ | 18 | void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop); |
11 | target/arm/translate-neon.c.inc | 94 ++++++++++++++++----------------- | 19 | void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop); |
12 | 2 files changed, 73 insertions(+), 47 deletions(-) | 20 | void write_neon_element64(TCGv_i64 src, int reg, int ele, MemOp memop); |
13 | 21 | +TCGv_i32 add_reg_for_lit(DisasContext *s, int reg, int ofs); | |
22 | +void gen_set_cpsr(TCGv_i32 var, uint32_t mask); | ||
23 | +void gen_set_condexec(DisasContext *s); | ||
24 | +void gen_set_pc_im(DisasContext *s, target_ulong val); | ||
25 | +void gen_lookup_tb(DisasContext *s); | ||
26 | +long vfp_reg_offset(bool dp, unsigned reg); | ||
27 | +long neon_full_reg_offset(unsigned reg); | ||
28 | |||
29 | static inline TCGv_i32 load_cpu_offset(int offset) | ||
30 | { | ||
31 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 load_reg(DisasContext *s, int reg) | ||
32 | return tmp; | ||
33 | } | ||
34 | |||
35 | +void store_reg(DisasContext *s, int reg, TCGv_i32 var); | ||
36 | + | ||
37 | void gen_aa32_ld_internal_i32(DisasContext *s, TCGv_i32 val, | ||
38 | TCGv_i32 a32, int index, MemOp opc); | ||
39 | void gen_aa32_st_internal_i32(DisasContext *s, TCGv_i32 val, | ||
40 | @@ -XXX,XX +XXX,XX @@ DO_GEN_ST(32, MO_UL) | ||
41 | #undef DO_GEN_LD | ||
42 | #undef DO_GEN_ST | ||
43 | |||
44 | +#if defined(CONFIG_USER_ONLY) | ||
45 | +#define IS_USER(s) 1 | ||
46 | +#else | ||
47 | +#define IS_USER(s) (s->user) | ||
48 | +#endif | ||
49 | + | ||
50 | +/* Set NZCV flags from the high 4 bits of var. */ | ||
51 | +#define gen_set_nzcv(var) gen_set_cpsr(var, CPSR_NZCV) | ||
52 | + | ||
53 | #endif | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 54 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
15 | index XXXXXXX..XXXXXXX 100644 | 55 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 56 | --- a/target/arm/translate.c |
17 | +++ b/target/arm/translate.c | 57 | +++ b/target/arm/translate.c |
18 | @@ -XXX,XX +XXX,XX @@ static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop) | 58 | @@ -XXX,XX +XXX,XX @@ |
59 | #include "translate.h" | ||
60 | #include "translate-a32.h" | ||
61 | |||
62 | -#if defined(CONFIG_USER_ONLY) | ||
63 | -#define IS_USER(s) 1 | ||
64 | -#else | ||
65 | -#define IS_USER(s) (s->user) | ||
66 | -#endif | ||
67 | - | ||
68 | /* These are TCG temporaries used only by the legacy iwMMXt decoder */ | ||
69 | static TCGv_i64 cpu_V0, cpu_V1, cpu_M0; | ||
70 | /* These are TCG globals which alias CPUARMState fields */ | ||
71 | @@ -XXX,XX +XXX,XX @@ void load_reg_var(DisasContext *s, TCGv_i32 var, int reg) | ||
72 | * This is used for load/store for which use of PC implies (literal), | ||
73 | * or ADD that implies ADR. | ||
74 | */ | ||
75 | -static TCGv_i32 add_reg_for_lit(DisasContext *s, int reg, int ofs) | ||
76 | +TCGv_i32 add_reg_for_lit(DisasContext *s, int reg, int ofs) | ||
77 | { | ||
78 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
79 | |||
80 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 add_reg_for_lit(DisasContext *s, int reg, int ofs) | ||
81 | |||
82 | /* Set a CPU register. The source must be a temporary and will be | ||
83 | marked as dead. */ | ||
84 | -static void store_reg(DisasContext *s, int reg, TCGv_i32 var) | ||
85 | +void store_reg(DisasContext *s, int reg, TCGv_i32 var) | ||
86 | { | ||
87 | if (reg == 15) { | ||
88 | /* In Thumb mode, we must ignore bit 0. | ||
89 | @@ -XXX,XX +XXX,XX @@ static void store_sp_checked(DisasContext *s, TCGv_i32 var) | ||
90 | #define gen_sxtb16(var) gen_helper_sxtb16(var, var) | ||
91 | #define gen_uxtb16(var) gen_helper_uxtb16(var, var) | ||
92 | |||
93 | - | ||
94 | -static inline void gen_set_cpsr(TCGv_i32 var, uint32_t mask) | ||
95 | +void gen_set_cpsr(TCGv_i32 var, uint32_t mask) | ||
96 | { | ||
97 | TCGv_i32 tmp_mask = tcg_const_i32(mask); | ||
98 | gen_helper_cpsr_write(cpu_env, var, tmp_mask); | ||
99 | tcg_temp_free_i32(tmp_mask); | ||
100 | } | ||
101 | -/* Set NZCV flags from the high 4 bits of var. */ | ||
102 | -#define gen_set_nzcv(var) gen_set_cpsr(var, CPSR_NZCV) | ||
103 | |||
104 | static void gen_exception_internal(int excp) | ||
105 | { | ||
106 | @@ -XXX,XX +XXX,XX @@ void arm_gen_test_cc(int cc, TCGLabel *label) | ||
107 | arm_free_cc(&cmp); | ||
108 | } | ||
109 | |||
110 | -static inline void gen_set_condexec(DisasContext *s) | ||
111 | +void gen_set_condexec(DisasContext *s) | ||
112 | { | ||
113 | if (s->condexec_mask) { | ||
114 | uint32_t val = (s->condexec_cond << 4) | (s->condexec_mask >> 1); | ||
115 | @@ -XXX,XX +XXX,XX @@ static inline void gen_set_condexec(DisasContext *s) | ||
19 | } | 116 | } |
20 | } | 117 | } |
21 | 118 | ||
22 | +static void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop) | 119 | -static inline void gen_set_pc_im(DisasContext *s, target_ulong val) |
23 | +{ | 120 | +void gen_set_pc_im(DisasContext *s, target_ulong val) |
24 | + long off = neon_element_offset(reg, ele, memop); | ||
25 | + | ||
26 | + switch (memop) { | ||
27 | + case MO_Q: | ||
28 | + tcg_gen_ld_i64(dest, cpu_env, off); | ||
29 | + break; | ||
30 | + default: | ||
31 | + g_assert_not_reached(); | ||
32 | + } | ||
33 | +} | ||
34 | + | ||
35 | static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop) | ||
36 | { | 121 | { |
37 | long off = neon_element_offset(reg, ele, memop); | 122 | tcg_gen_movi_i32(cpu_R[15], val); |
38 | @@ -XXX,XX +XXX,XX @@ static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop) | ||
39 | } | ||
40 | } | 123 | } |
41 | 124 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_el(DisasContext *s, int excp, uint32_t syn, | |
42 | +static void write_neon_element64(TCGv_i64 src, int reg, int ele, MemOp memop) | 125 | } |
43 | +{ | 126 | |
44 | + long off = neon_element_offset(reg, ele, memop); | 127 | /* Force a TB lookup after an instruction that changes the CPU state. */ |
45 | + | 128 | -static inline void gen_lookup_tb(DisasContext *s) |
46 | + switch (memop) { | 129 | +void gen_lookup_tb(DisasContext *s) |
47 | + case MO_64: | ||
48 | + tcg_gen_st_i64(src, cpu_env, off); | ||
49 | + break; | ||
50 | + default: | ||
51 | + g_assert_not_reached(); | ||
52 | + } | ||
53 | +} | ||
54 | + | ||
55 | static TCGv_ptr vfp_reg_ptr(bool dp, int reg) | ||
56 | { | 130 | { |
57 | TCGv_ptr ret = tcg_temp_new_ptr(); | 131 | tcg_gen_movi_i32(cpu_R[15], s->base.pc_next); |
58 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 132 | s->base.is_jmp = DISAS_EXIT; |
59 | index XXXXXXX..XXXXXXX 100644 | 133 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) |
60 | --- a/target/arm/translate-neon.c.inc | 134 | /* |
61 | +++ b/target/arm/translate-neon.c.inc | 135 | * Return the offset of a "full" NEON Dreg. |
62 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_64(DisasContext *s, arg_2reg_shift *a, | 136 | */ |
63 | for (pass = 0; pass < a->q + 1; pass++) { | 137 | -static long neon_full_reg_offset(unsigned reg) |
64 | TCGv_i64 tmp = tcg_temp_new_i64(); | 138 | +long neon_full_reg_offset(unsigned reg) |
65 | 139 | { | |
66 | - neon_load_reg64(tmp, a->vm + pass); | 140 | return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]); |
67 | + read_neon_element64(tmp, a->vm, pass, MO_64); | ||
68 | fn(tmp, cpu_env, tmp, constimm); | ||
69 | - neon_store_reg64(tmp, a->vd + pass); | ||
70 | + write_neon_element64(tmp, a->vd, pass, MO_64); | ||
71 | tcg_temp_free_i64(tmp); | ||
72 | } | ||
73 | tcg_temp_free_i64(constimm); | ||
74 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a, | ||
75 | rd = tcg_temp_new_i32(); | ||
76 | |||
77 | /* Load both inputs first to avoid potential overwrite if rm == rd */ | ||
78 | - neon_load_reg64(rm1, a->vm); | ||
79 | - neon_load_reg64(rm2, a->vm + 1); | ||
80 | + read_neon_element64(rm1, a->vm, 0, MO_64); | ||
81 | + read_neon_element64(rm2, a->vm, 1, MO_64); | ||
82 | |||
83 | shiftfn(rm1, rm1, constimm); | ||
84 | narrowfn(rd, cpu_env, rm1); | ||
85 | @@ -XXX,XX +XXX,XX @@ static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a, | ||
86 | tcg_gen_shli_i64(tmp, tmp, a->shift); | ||
87 | tcg_gen_andi_i64(tmp, tmp, ~widen_mask); | ||
88 | } | ||
89 | - neon_store_reg64(tmp, a->vd); | ||
90 | + write_neon_element64(tmp, a->vd, 0, MO_64); | ||
91 | |||
92 | widenfn(tmp, rm1); | ||
93 | tcg_temp_free_i32(rm1); | ||
94 | @@ -XXX,XX +XXX,XX @@ static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a, | ||
95 | tcg_gen_shli_i64(tmp, tmp, a->shift); | ||
96 | tcg_gen_andi_i64(tmp, tmp, ~widen_mask); | ||
97 | } | ||
98 | - neon_store_reg64(tmp, a->vd + 1); | ||
99 | + write_neon_element64(tmp, a->vd, 1, MO_64); | ||
100 | tcg_temp_free_i64(tmp); | ||
101 | return true; | ||
102 | } | 141 | } |
103 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | 142 | @@ -XXX,XX +XXX,XX @@ static long neon_element_offset(int reg, int element, MemOp memop) |
104 | rm_64 = tcg_temp_new_i64(); | 143 | } |
105 | 144 | ||
106 | if (src1_wide) { | 145 | /* Return the offset of a VFP Dreg (dp = true) or VFP Sreg (dp = false). */ |
107 | - neon_load_reg64(rn0_64, a->vn); | 146 | -static long vfp_reg_offset(bool dp, unsigned reg) |
108 | + read_neon_element64(rn0_64, a->vn, 0, MO_64); | 147 | +long vfp_reg_offset(bool dp, unsigned reg) |
109 | } else { | 148 | { |
110 | TCGv_i32 tmp = tcg_temp_new_i32(); | 149 | if (dp) { |
111 | read_neon_element32(tmp, a->vn, 0, MO_32); | 150 | return neon_element_offset(reg, 0, MO_64); |
112 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
113 | * avoid incorrect results if a narrow input overlaps with the result. | ||
114 | */ | ||
115 | if (src1_wide) { | ||
116 | - neon_load_reg64(rn1_64, a->vn + 1); | ||
117 | + read_neon_element64(rn1_64, a->vn, 1, MO_64); | ||
118 | } else { | ||
119 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
120 | read_neon_element32(tmp, a->vn, 1, MO_32); | ||
121 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
122 | rm = tcg_temp_new_i32(); | ||
123 | read_neon_element32(rm, a->vm, 1, MO_32); | ||
124 | |||
125 | - neon_store_reg64(rn0_64, a->vd); | ||
126 | + write_neon_element64(rn0_64, a->vd, 0, MO_64); | ||
127 | |||
128 | widenfn(rm_64, rm); | ||
129 | tcg_temp_free_i32(rm); | ||
130 | opfn(rn1_64, rn1_64, rm_64); | ||
131 | - neon_store_reg64(rn1_64, a->vd + 1); | ||
132 | + write_neon_element64(rn1_64, a->vd, 1, MO_64); | ||
133 | |||
134 | tcg_temp_free_i64(rn0_64); | ||
135 | tcg_temp_free_i64(rn1_64); | ||
136 | @@ -XXX,XX +XXX,XX @@ static bool do_narrow_3d(DisasContext *s, arg_3diff *a, | ||
137 | rd0 = tcg_temp_new_i32(); | ||
138 | rd1 = tcg_temp_new_i32(); | ||
139 | |||
140 | - neon_load_reg64(rn_64, a->vn); | ||
141 | - neon_load_reg64(rm_64, a->vm); | ||
142 | + read_neon_element64(rn_64, a->vn, 0, MO_64); | ||
143 | + read_neon_element64(rm_64, a->vm, 0, MO_64); | ||
144 | |||
145 | opfn(rn_64, rn_64, rm_64); | ||
146 | |||
147 | narrowfn(rd0, rn_64); | ||
148 | |||
149 | - neon_load_reg64(rn_64, a->vn + 1); | ||
150 | - neon_load_reg64(rm_64, a->vm + 1); | ||
151 | + read_neon_element64(rn_64, a->vn, 1, MO_64); | ||
152 | + read_neon_element64(rm_64, a->vm, 1, MO_64); | ||
153 | |||
154 | opfn(rn_64, rn_64, rm_64); | ||
155 | |||
156 | @@ -XXX,XX +XXX,XX @@ static bool do_long_3d(DisasContext *s, arg_3diff *a, | ||
157 | /* Don't store results until after all loads: they might overlap */ | ||
158 | if (accfn) { | ||
159 | tmp = tcg_temp_new_i64(); | ||
160 | - neon_load_reg64(tmp, a->vd); | ||
161 | + read_neon_element64(tmp, a->vd, 0, MO_64); | ||
162 | accfn(tmp, tmp, rd0); | ||
163 | - neon_store_reg64(tmp, a->vd); | ||
164 | - neon_load_reg64(tmp, a->vd + 1); | ||
165 | + write_neon_element64(tmp, a->vd, 0, MO_64); | ||
166 | + read_neon_element64(tmp, a->vd, 1, MO_64); | ||
167 | accfn(tmp, tmp, rd1); | ||
168 | - neon_store_reg64(tmp, a->vd + 1); | ||
169 | + write_neon_element64(tmp, a->vd, 1, MO_64); | ||
170 | tcg_temp_free_i64(tmp); | ||
171 | } else { | ||
172 | - neon_store_reg64(rd0, a->vd); | ||
173 | - neon_store_reg64(rd1, a->vd + 1); | ||
174 | + write_neon_element64(rd0, a->vd, 0, MO_64); | ||
175 | + write_neon_element64(rd1, a->vd, 1, MO_64); | ||
176 | } | ||
177 | |||
178 | tcg_temp_free_i64(rd0); | ||
179 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar_long(DisasContext *s, arg_2scalar *a, | ||
180 | |||
181 | if (accfn) { | ||
182 | TCGv_i64 t64 = tcg_temp_new_i64(); | ||
183 | - neon_load_reg64(t64, a->vd); | ||
184 | + read_neon_element64(t64, a->vd, 0, MO_64); | ||
185 | accfn(t64, t64, rn0_64); | ||
186 | - neon_store_reg64(t64, a->vd); | ||
187 | - neon_load_reg64(t64, a->vd + 1); | ||
188 | + write_neon_element64(t64, a->vd, 0, MO_64); | ||
189 | + read_neon_element64(t64, a->vd, 1, MO_64); | ||
190 | accfn(t64, t64, rn1_64); | ||
191 | - neon_store_reg64(t64, a->vd + 1); | ||
192 | + write_neon_element64(t64, a->vd, 1, MO_64); | ||
193 | tcg_temp_free_i64(t64); | ||
194 | } else { | ||
195 | - neon_store_reg64(rn0_64, a->vd); | ||
196 | - neon_store_reg64(rn1_64, a->vd + 1); | ||
197 | + write_neon_element64(rn0_64, a->vd, 0, MO_64); | ||
198 | + write_neon_element64(rn1_64, a->vd, 1, MO_64); | ||
199 | } | ||
200 | tcg_temp_free_i64(rn0_64); | ||
201 | tcg_temp_free_i64(rn1_64); | ||
202 | @@ -XXX,XX +XXX,XX @@ static bool trans_VEXT(DisasContext *s, arg_VEXT *a) | ||
203 | right = tcg_temp_new_i64(); | ||
204 | dest = tcg_temp_new_i64(); | ||
205 | |||
206 | - neon_load_reg64(right, a->vn); | ||
207 | - neon_load_reg64(left, a->vm); | ||
208 | + read_neon_element64(right, a->vn, 0, MO_64); | ||
209 | + read_neon_element64(left, a->vm, 0, MO_64); | ||
210 | tcg_gen_extract2_i64(dest, right, left, a->imm * 8); | ||
211 | - neon_store_reg64(dest, a->vd); | ||
212 | + write_neon_element64(dest, a->vd, 0, MO_64); | ||
213 | |||
214 | tcg_temp_free_i64(left); | ||
215 | tcg_temp_free_i64(right); | ||
216 | @@ -XXX,XX +XXX,XX @@ static bool trans_VEXT(DisasContext *s, arg_VEXT *a) | ||
217 | destright = tcg_temp_new_i64(); | ||
218 | |||
219 | if (a->imm < 8) { | ||
220 | - neon_load_reg64(right, a->vn); | ||
221 | - neon_load_reg64(middle, a->vn + 1); | ||
222 | + read_neon_element64(right, a->vn, 0, MO_64); | ||
223 | + read_neon_element64(middle, a->vn, 1, MO_64); | ||
224 | tcg_gen_extract2_i64(destright, right, middle, a->imm * 8); | ||
225 | - neon_load_reg64(left, a->vm); | ||
226 | + read_neon_element64(left, a->vm, 0, MO_64); | ||
227 | tcg_gen_extract2_i64(destleft, middle, left, a->imm * 8); | ||
228 | } else { | ||
229 | - neon_load_reg64(right, a->vn + 1); | ||
230 | - neon_load_reg64(middle, a->vm); | ||
231 | + read_neon_element64(right, a->vn, 1, MO_64); | ||
232 | + read_neon_element64(middle, a->vm, 0, MO_64); | ||
233 | tcg_gen_extract2_i64(destright, right, middle, (a->imm - 8) * 8); | ||
234 | - neon_load_reg64(left, a->vm + 1); | ||
235 | + read_neon_element64(left, a->vm, 1, MO_64); | ||
236 | tcg_gen_extract2_i64(destleft, middle, left, (a->imm - 8) * 8); | ||
237 | } | ||
238 | |||
239 | - neon_store_reg64(destright, a->vd); | ||
240 | - neon_store_reg64(destleft, a->vd + 1); | ||
241 | + write_neon_element64(destright, a->vd, 0, MO_64); | ||
242 | + write_neon_element64(destleft, a->vd, 1, MO_64); | ||
243 | |||
244 | tcg_temp_free_i64(destright); | ||
245 | tcg_temp_free_i64(destleft); | ||
246 | @@ -XXX,XX +XXX,XX @@ static bool do_2misc_pairwise(DisasContext *s, arg_2misc *a, | ||
247 | |||
248 | if (accfn) { | ||
249 | TCGv_i64 tmp64 = tcg_temp_new_i64(); | ||
250 | - neon_load_reg64(tmp64, a->vd + pass); | ||
251 | + read_neon_element64(tmp64, a->vd, pass, MO_64); | ||
252 | accfn(rd_64, tmp64, rd_64); | ||
253 | tcg_temp_free_i64(tmp64); | ||
254 | } | ||
255 | - neon_store_reg64(rd_64, a->vd + pass); | ||
256 | + write_neon_element64(rd_64, a->vd, pass, MO_64); | ||
257 | tcg_temp_free_i64(rd_64); | ||
258 | } | ||
259 | return true; | ||
260 | @@ -XXX,XX +XXX,XX @@ static bool do_vmovn(DisasContext *s, arg_2misc *a, | ||
261 | rd0 = tcg_temp_new_i32(); | ||
262 | rd1 = tcg_temp_new_i32(); | ||
263 | |||
264 | - neon_load_reg64(rm, a->vm); | ||
265 | + read_neon_element64(rm, a->vm, 0, MO_64); | ||
266 | narrowfn(rd0, cpu_env, rm); | ||
267 | - neon_load_reg64(rm, a->vm + 1); | ||
268 | + read_neon_element64(rm, a->vm, 1, MO_64); | ||
269 | narrowfn(rd1, cpu_env, rm); | ||
270 | write_neon_element32(rd0, a->vd, 0, MO_32); | ||
271 | write_neon_element32(rd1, a->vd, 1, MO_32); | ||
272 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL(DisasContext *s, arg_2misc *a) | ||
273 | |||
274 | widenfn(rd, rm0); | ||
275 | tcg_gen_shli_i64(rd, rd, 8 << a->size); | ||
276 | - neon_store_reg64(rd, a->vd); | ||
277 | + write_neon_element64(rd, a->vd, 0, MO_64); | ||
278 | widenfn(rd, rm1); | ||
279 | tcg_gen_shli_i64(rd, rd, 8 << a->size); | ||
280 | - neon_store_reg64(rd, a->vd + 1); | ||
281 | + write_neon_element64(rd, a->vd, 1, MO_64); | ||
282 | |||
283 | tcg_temp_free_i64(rd); | ||
284 | tcg_temp_free_i32(rm0); | ||
285 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSWP(DisasContext *s, arg_2misc *a) | ||
286 | rm = tcg_temp_new_i64(); | ||
287 | rd = tcg_temp_new_i64(); | ||
288 | for (pass = 0; pass < (a->q ? 2 : 1); pass++) { | ||
289 | - neon_load_reg64(rm, a->vm + pass); | ||
290 | - neon_load_reg64(rd, a->vd + pass); | ||
291 | - neon_store_reg64(rm, a->vd + pass); | ||
292 | - neon_store_reg64(rd, a->vm + pass); | ||
293 | + read_neon_element64(rm, a->vm, pass, MO_64); | ||
294 | + read_neon_element64(rd, a->vd, pass, MO_64); | ||
295 | + write_neon_element64(rm, a->vd, pass, MO_64); | ||
296 | + write_neon_element64(rd, a->vm, pass, MO_64); | ||
297 | } | ||
298 | tcg_temp_free_i64(rm); | ||
299 | tcg_temp_free_i64(rd); | ||
300 | -- | 151 | -- |
301 | 2.20.1 | 152 | 2.20.1 |
302 | 153 | ||
303 | 154 | diff view generated by jsdifflib |
1 | Sphinx 3.2 is pickier than earlier versions about the option:: markup, | 1 | Switch translate-vfp.c.inc from being #included into translate.c |
---|---|---|---|
2 | and complains about our usage in qemu-option-trace.rst: | 2 | to being its own compilation unit. |
3 | |||
4 | ../../docs/qemu-option-trace.rst.inc:4:Malformed option description | ||
5 | '[enable=]PATTERN', should look like "opt", "-opt args", "--opt args", | ||
6 | "/opt args" or "+opt args" | ||
7 | |||
8 | In this file, we're really trying to document the different parts of | ||
9 | the top-level --trace option, which qemu-nbd.rst and qemu-img.rst | ||
10 | have already introduced with an option:: markup. So it's not right | ||
11 | to use option:: here anyway. Switch to a different markup | ||
12 | (definition lists) which gives about the same formatted output. | ||
13 | |||
14 | (Unlike option::, this markup doesn't produce index entries; but | ||
15 | at the moment we don't do anything much with indexes anyway, and | ||
16 | in any case I think it doesn't make much sense to have individual | ||
17 | index entries for the sub-parts of the --trace option.) | ||
18 | 3 | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
21 | Tested-by: Stefan Hajnoczi <stefanha@redhat.com> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
22 | Message-id: 20201030174700.7204-3-peter.maydell@linaro.org | 7 | Message-id: 20210430132740.10391-9-peter.maydell@linaro.org |
23 | --- | 8 | --- |
24 | docs/qemu-option-trace.rst.inc | 6 +++--- | 9 | target/arm/translate-a32.h | 2 ++ |
25 | 1 file changed, 3 insertions(+), 3 deletions(-) | 10 | target/arm/{translate-vfp.c.inc => translate-vfp.c} | 12 +++++++----- |
11 | target/arm/translate.c | 3 +-- | ||
12 | target/arm/meson.build | 5 +++-- | ||
13 | 4 files changed, 13 insertions(+), 9 deletions(-) | ||
14 | rename target/arm/{translate-vfp.c.inc => translate-vfp.c} (99%) | ||
26 | 15 | ||
27 | diff --git a/docs/qemu-option-trace.rst.inc b/docs/qemu-option-trace.rst.inc | 16 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h |
28 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/docs/qemu-option-trace.rst.inc | 18 | --- a/target/arm/translate-a32.h |
30 | +++ b/docs/qemu-option-trace.rst.inc | 19 | +++ b/target/arm/translate-a32.h |
31 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
32 | 21 | ||
33 | Specify tracing options. | 22 | /* Prototypes for autogenerated disassembler functions */ |
34 | 23 | bool disas_m_nocp(DisasContext *dc, uint32_t insn); | |
35 | -.. option:: [enable=]PATTERN | 24 | +bool disas_vfp(DisasContext *s, uint32_t insn); |
36 | +``[enable=]PATTERN`` | 25 | +bool disas_vfp_uncond(DisasContext *s, uint32_t insn); |
37 | 26 | ||
38 | Immediately enable events matching *PATTERN* | 27 | void load_reg_var(DisasContext *s, TCGv_i32 var, int reg); |
39 | (either event name or a globbing pattern). This option is only | 28 | void arm_gen_condlabel(DisasContext *s); |
40 | @@ -XXX,XX +XXX,XX @@ Specify tracing options. | 29 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c |
41 | 30 | similarity index 99% | |
42 | Use :option:`-trace help` to print a list of names of trace points. | 31 | rename from target/arm/translate-vfp.c.inc |
43 | 32 | rename to target/arm/translate-vfp.c | |
44 | -.. option:: events=FILE | 33 | index XXXXXXX..XXXXXXX 100644 |
45 | +``events=FILE`` | 34 | --- a/target/arm/translate-vfp.c.inc |
46 | 35 | +++ b/target/arm/translate-vfp.c | |
47 | Immediately enable events listed in *FILE*. | 36 | @@ -XXX,XX +XXX,XX @@ |
48 | The file must contain one event name (as listed in the ``trace-events-all`` | 37 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
49 | @@ -XXX,XX +XXX,XX @@ Specify tracing options. | 38 | */ |
50 | available if QEMU has been compiled with the ``simple``, ``log`` or | 39 | |
51 | ``ftrace`` tracing backend. | 40 | -/* |
52 | 41 | - * This file is intended to be included from translate.c; it uses | |
53 | -.. option:: file=FILE | 42 | - * some macros and definitions provided by that file. |
54 | +``file=FILE`` | 43 | - * It might be possible to convert it to a standalone .c file eventually. |
55 | 44 | - */ | |
56 | Log output traces to *FILE*. | 45 | +#include "qemu/osdep.h" |
57 | This option is only available if QEMU has been compiled with | 46 | +#include "tcg/tcg-op.h" |
47 | +#include "tcg/tcg-op-gvec.h" | ||
48 | +#include "exec/exec-all.h" | ||
49 | +#include "exec/gen-icount.h" | ||
50 | +#include "translate.h" | ||
51 | +#include "translate-a32.h" | ||
52 | |||
53 | /* Include the generated VFP decoder */ | ||
54 | #include "decode-vfp.c.inc" | ||
55 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/target/arm/translate.c | ||
58 | +++ b/target/arm/translate.c | ||
59 | @@ -XXX,XX +XXX,XX @@ static TCGv_ptr vfp_reg_ptr(bool dp, int reg) | ||
60 | |||
61 | #define ARM_CP_RW_BIT (1 << 20) | ||
62 | |||
63 | -/* Include the VFP and Neon decoders */ | ||
64 | -#include "translate-vfp.c.inc" | ||
65 | +/* Include the Neon decoder */ | ||
66 | #include "translate-neon.c.inc" | ||
67 | |||
68 | static inline void iwmmxt_load_reg(TCGv_i64 var, int reg) | ||
69 | diff --git a/target/arm/meson.build b/target/arm/meson.build | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/meson.build | ||
72 | +++ b/target/arm/meson.build | ||
73 | @@ -XXX,XX +XXX,XX @@ gen = [ | ||
74 | decodetree.process('neon-shared.decode', extra_args: '--static-decode=disas_neon_shared'), | ||
75 | decodetree.process('neon-dp.decode', extra_args: '--static-decode=disas_neon_dp'), | ||
76 | decodetree.process('neon-ls.decode', extra_args: '--static-decode=disas_neon_ls'), | ||
77 | - decodetree.process('vfp.decode', extra_args: '--static-decode=disas_vfp'), | ||
78 | - decodetree.process('vfp-uncond.decode', extra_args: '--static-decode=disas_vfp_uncond'), | ||
79 | + decodetree.process('vfp.decode', extra_args: '--decode=disas_vfp'), | ||
80 | + decodetree.process('vfp-uncond.decode', extra_args: '--decode=disas_vfp_uncond'), | ||
81 | decodetree.process('m-nocp.decode', extra_args: '--decode=disas_m_nocp'), | ||
82 | decodetree.process('a32.decode', extra_args: '--static-decode=disas_a32'), | ||
83 | decodetree.process('a32-uncond.decode', extra_args: '--static-decode=disas_a32_uncond'), | ||
84 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(files( | ||
85 | 'tlb_helper.c', | ||
86 | 'translate.c', | ||
87 | 'translate-m-nocp.c', | ||
88 | + 'translate-vfp.c', | ||
89 | 'vec_helper.c', | ||
90 | 'vfp_helper.c', | ||
91 | 'cpu_tcg.c', | ||
58 | -- | 92 | -- |
59 | 2.20.1 | 93 | 2.20.1 |
60 | 94 | ||
61 | 95 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The function vfp_reg_ptr() is used only in translate-neon.c.inc; |
---|---|---|---|
2 | move it there. | ||
2 | 3 | ||
3 | This will shortly have users outside of translate-neon.c.inc. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20201030022618.785675-3-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210430132740.10391-10-peter.maydell@linaro.org | ||
9 | --- | 8 | --- |
10 | target/arm/translate.c | 20 ++++++++++++++++++++ | 9 | target/arm/translate.c | 7 ------- |
11 | target/arm/translate-neon.c.inc | 19 ------------------- | 10 | target/arm/translate-neon.c.inc | 7 +++++++ |
12 | 2 files changed, 20 insertions(+), 19 deletions(-) | 11 | 2 files changed, 7 insertions(+), 7 deletions(-) |
13 | 12 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 13 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 15 | --- a/target/arm/translate.c |
17 | +++ b/target/arm/translate.c | 16 | +++ b/target/arm/translate.c |
18 | @@ -XXX,XX +XXX,XX @@ static long neon_full_reg_offset(unsigned reg) | 17 | @@ -XXX,XX +XXX,XX @@ void write_neon_element64(TCGv_i64 src, int reg, int ele, MemOp memop) |
19 | return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]); | 18 | } |
20 | } | 19 | } |
21 | 20 | ||
22 | +/* | 21 | -static TCGv_ptr vfp_reg_ptr(bool dp, int reg) |
23 | + * Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | 22 | -{ |
24 | + * where 0 is the least significant end of the register. | 23 | - TCGv_ptr ret = tcg_temp_new_ptr(); |
25 | + */ | 24 | - tcg_gen_addi_ptr(ret, cpu_env, vfp_reg_offset(dp, reg)); |
26 | +static long neon_element_offset(int reg, int element, MemOp size) | 25 | - return ret; |
27 | +{ | 26 | -} |
28 | + int element_size = 1 << size; | 27 | - |
29 | + int ofs = element * element_size; | 28 | #define ARM_CP_RW_BIT (1 << 20) |
30 | +#ifdef HOST_WORDS_BIGENDIAN | 29 | |
31 | + /* | 30 | /* Include the Neon decoder */ |
32 | + * Calculate the offset assuming fully little-endian, | ||
33 | + * then XOR to account for the order of the 8-byte units. | ||
34 | + */ | ||
35 | + if (element_size < 8) { | ||
36 | + ofs ^= 8 - element_size; | ||
37 | + } | ||
38 | +#endif | ||
39 | + return neon_full_reg_offset(reg) + ofs; | ||
40 | +} | ||
41 | + | ||
42 | static inline long vfp_reg_offset(bool dp, unsigned reg) | ||
43 | { | ||
44 | if (dp) { | ||
45 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 31 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc |
46 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/target/arm/translate-neon.c.inc | 33 | --- a/target/arm/translate-neon.c.inc |
48 | +++ b/target/arm/translate-neon.c.inc | 34 | +++ b/target/arm/translate-neon.c.inc |
49 | @@ -XXX,XX +XXX,XX @@ static inline int neon_3same_fp_size(DisasContext *s, int x) | 35 | @@ -XXX,XX +XXX,XX @@ static inline int neon_3same_fp_size(DisasContext *s, int x) |
50 | #include "decode-neon-ls.c.inc" | 36 | #include "decode-neon-ls.c.inc" |
51 | #include "decode-neon-shared.c.inc" | 37 | #include "decode-neon-shared.c.inc" |
52 | 38 | ||
53 | -/* Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | 39 | +static TCGv_ptr vfp_reg_ptr(bool dp, int reg) |
54 | - * where 0 is the least significant end of the register. | 40 | +{ |
55 | - */ | 41 | + TCGv_ptr ret = tcg_temp_new_ptr(); |
56 | -static inline long | 42 | + tcg_gen_addi_ptr(ret, cpu_env, vfp_reg_offset(dp, reg)); |
57 | -neon_element_offset(int reg, int element, MemOp size) | 43 | + return ret; |
58 | -{ | 44 | +} |
59 | - int element_size = 1 << size; | 45 | + |
60 | - int ofs = element * element_size; | ||
61 | -#ifdef HOST_WORDS_BIGENDIAN | ||
62 | - /* Calculate the offset assuming fully little-endian, | ||
63 | - * then XOR to account for the order of the 8-byte units. | ||
64 | - */ | ||
65 | - if (element_size < 8) { | ||
66 | - ofs ^= 8 - element_size; | ||
67 | - } | ||
68 | -#endif | ||
69 | - return neon_full_reg_offset(reg) + ofs; | ||
70 | -} | ||
71 | - | ||
72 | static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop) | 46 | static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop) |
73 | { | 47 | { |
74 | long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | 48 | long offset = neon_element_offset(reg, ele, mop & MO_SIZE); |
75 | -- | 49 | -- |
76 | 2.20.1 | 50 | 2.20.1 |
77 | 51 | ||
78 | 52 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The VFPGenFixPointFn typedef is unused; delete it. |
---|---|---|---|
2 | 2 | ||
3 | We can use proper widening loads to extend 32-bit inputs, | ||
4 | and skip the "widenfn" step. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20201030022618.785675-12-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
6 | Message-id: 20210430132740.10391-11-peter.maydell@linaro.org | ||
10 | --- | 7 | --- |
11 | target/arm/translate.c | 6 +++ | 8 | target/arm/translate.c | 2 -- |
12 | target/arm/translate-neon.c.inc | 66 ++++++++++++++++++--------------- | 9 | 1 file changed, 2 deletions(-) |
13 | 2 files changed, 43 insertions(+), 29 deletions(-) | ||
14 | 10 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 11 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
16 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 13 | --- a/target/arm/translate.c |
18 | +++ b/target/arm/translate.c | 14 | +++ b/target/arm/translate.c |
19 | @@ -XXX,XX +XXX,XX @@ static void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop) | 15 | @@ -XXX,XX +XXX,XX @@ static const char * const regnames[] = |
20 | long off = neon_element_offset(reg, ele, memop); | 16 | /* Function prototypes for gen_ functions calling Neon helpers. */ |
21 | 17 | typedef void NeonGenThreeOpEnvFn(TCGv_i32, TCGv_env, TCGv_i32, | |
22 | switch (memop) { | 18 | TCGv_i32, TCGv_i32); |
23 | + case MO_SL: | 19 | -/* Function prototypes for gen_ functions for fix point conversions */ |
24 | + tcg_gen_ld32s_i64(dest, cpu_env, off); | 20 | -typedef void VFPGenFixPointFn(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr); |
25 | + break; | 21 | |
26 | + case MO_UL: | 22 | /* initialize TCG globals. */ |
27 | + tcg_gen_ld32u_i64(dest, cpu_env, off); | 23 | void arm_translate_init(void) |
28 | + break; | ||
29 | case MO_Q: | ||
30 | tcg_gen_ld_i64(dest, cpu_env, off); | ||
31 | break; | ||
32 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/translate-neon.c.inc | ||
35 | +++ b/target/arm/translate-neon.c.inc | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool trans_Vimm_1r(DisasContext *s, arg_1reg_imm *a) | ||
37 | static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
38 | NeonGenWidenFn *widenfn, | ||
39 | NeonGenTwo64OpFn *opfn, | ||
40 | - bool src1_wide) | ||
41 | + int src1_mop, int src2_mop) | ||
42 | { | ||
43 | /* 3-regs different lengths, prewidening case (VADDL/VSUBL/VAADW/VSUBW) */ | ||
44 | TCGv_i64 rn0_64, rn1_64, rm_64; | ||
45 | - TCGv_i32 rm; | ||
46 | |||
47 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
48 | return false; | ||
49 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
50 | return false; | ||
51 | } | ||
52 | |||
53 | - if (!widenfn || !opfn) { | ||
54 | + if (!opfn) { | ||
55 | /* size == 3 case, which is an entirely different insn group */ | ||
56 | return false; | ||
57 | } | ||
58 | |||
59 | - if ((a->vd & 1) || (src1_wide && (a->vn & 1))) { | ||
60 | + if ((a->vd & 1) || (src1_mop == MO_Q && (a->vn & 1))) { | ||
61 | return false; | ||
62 | } | ||
63 | |||
64 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
65 | rn1_64 = tcg_temp_new_i64(); | ||
66 | rm_64 = tcg_temp_new_i64(); | ||
67 | |||
68 | - if (src1_wide) { | ||
69 | - read_neon_element64(rn0_64, a->vn, 0, MO_64); | ||
70 | + if (src1_mop >= 0) { | ||
71 | + read_neon_element64(rn0_64, a->vn, 0, src1_mop); | ||
72 | } else { | ||
73 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
74 | read_neon_element32(tmp, a->vn, 0, MO_32); | ||
75 | widenfn(rn0_64, tmp); | ||
76 | tcg_temp_free_i32(tmp); | ||
77 | } | ||
78 | - rm = tcg_temp_new_i32(); | ||
79 | - read_neon_element32(rm, a->vm, 0, MO_32); | ||
80 | + if (src2_mop >= 0) { | ||
81 | + read_neon_element64(rm_64, a->vm, 0, src2_mop); | ||
82 | + } else { | ||
83 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
84 | + read_neon_element32(tmp, a->vm, 0, MO_32); | ||
85 | + widenfn(rm_64, tmp); | ||
86 | + tcg_temp_free_i32(tmp); | ||
87 | + } | ||
88 | |||
89 | - widenfn(rm_64, rm); | ||
90 | - tcg_temp_free_i32(rm); | ||
91 | opfn(rn0_64, rn0_64, rm_64); | ||
92 | |||
93 | /* | ||
94 | * Load second pass inputs before storing the first pass result, to | ||
95 | * avoid incorrect results if a narrow input overlaps with the result. | ||
96 | */ | ||
97 | - if (src1_wide) { | ||
98 | - read_neon_element64(rn1_64, a->vn, 1, MO_64); | ||
99 | + if (src1_mop >= 0) { | ||
100 | + read_neon_element64(rn1_64, a->vn, 1, src1_mop); | ||
101 | } else { | ||
102 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
103 | read_neon_element32(tmp, a->vn, 1, MO_32); | ||
104 | widenfn(rn1_64, tmp); | ||
105 | tcg_temp_free_i32(tmp); | ||
106 | } | ||
107 | - rm = tcg_temp_new_i32(); | ||
108 | - read_neon_element32(rm, a->vm, 1, MO_32); | ||
109 | + if (src2_mop >= 0) { | ||
110 | + read_neon_element64(rm_64, a->vm, 1, src2_mop); | ||
111 | + } else { | ||
112 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
113 | + read_neon_element32(tmp, a->vm, 1, MO_32); | ||
114 | + widenfn(rm_64, tmp); | ||
115 | + tcg_temp_free_i32(tmp); | ||
116 | + } | ||
117 | |||
118 | write_neon_element64(rn0_64, a->vd, 0, MO_64); | ||
119 | |||
120 | - widenfn(rm_64, rm); | ||
121 | - tcg_temp_free_i32(rm); | ||
122 | opfn(rn1_64, rn1_64, rm_64); | ||
123 | write_neon_element64(rn1_64, a->vd, 1, MO_64); | ||
124 | |||
125 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
126 | return true; | ||
127 | } | ||
128 | |||
129 | -#define DO_PREWIDEN(INSN, S, EXT, OP, SRC1WIDE) \ | ||
130 | +#define DO_PREWIDEN(INSN, S, OP, SRC1WIDE, SIGN) \ | ||
131 | static bool trans_##INSN##_3d(DisasContext *s, arg_3diff *a) \ | ||
132 | { \ | ||
133 | static NeonGenWidenFn * const widenfn[] = { \ | ||
134 | gen_helper_neon_widen_##S##8, \ | ||
135 | gen_helper_neon_widen_##S##16, \ | ||
136 | - tcg_gen_##EXT##_i32_i64, \ | ||
137 | - NULL, \ | ||
138 | + NULL, NULL, \ | ||
139 | }; \ | ||
140 | static NeonGenTwo64OpFn * const addfn[] = { \ | ||
141 | gen_helper_neon_##OP##l_u16, \ | ||
142 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | ||
143 | tcg_gen_##OP##_i64, \ | ||
144 | NULL, \ | ||
145 | }; \ | ||
146 | - return do_prewiden_3d(s, a, widenfn[a->size], \ | ||
147 | - addfn[a->size], SRC1WIDE); \ | ||
148 | + int narrow_mop = a->size == MO_32 ? MO_32 | SIGN : -1; \ | ||
149 | + return do_prewiden_3d(s, a, widenfn[a->size], addfn[a->size], \ | ||
150 | + SRC1WIDE ? MO_Q : narrow_mop, \ | ||
151 | + narrow_mop); \ | ||
152 | } | ||
153 | |||
154 | -DO_PREWIDEN(VADDL_S, s, ext, add, false) | ||
155 | -DO_PREWIDEN(VADDL_U, u, extu, add, false) | ||
156 | -DO_PREWIDEN(VSUBL_S, s, ext, sub, false) | ||
157 | -DO_PREWIDEN(VSUBL_U, u, extu, sub, false) | ||
158 | -DO_PREWIDEN(VADDW_S, s, ext, add, true) | ||
159 | -DO_PREWIDEN(VADDW_U, u, extu, add, true) | ||
160 | -DO_PREWIDEN(VSUBW_S, s, ext, sub, true) | ||
161 | -DO_PREWIDEN(VSUBW_U, u, extu, sub, true) | ||
162 | +DO_PREWIDEN(VADDL_S, s, add, false, MO_SIGN) | ||
163 | +DO_PREWIDEN(VADDL_U, u, add, false, 0) | ||
164 | +DO_PREWIDEN(VSUBL_S, s, sub, false, MO_SIGN) | ||
165 | +DO_PREWIDEN(VSUBL_U, u, sub, false, 0) | ||
166 | +DO_PREWIDEN(VADDW_S, s, add, true, MO_SIGN) | ||
167 | +DO_PREWIDEN(VADDW_U, u, add, true, 0) | ||
168 | +DO_PREWIDEN(VSUBW_S, s, sub, true, MO_SIGN) | ||
169 | +DO_PREWIDEN(VSUBW_U, u, sub, true, 0) | ||
170 | |||
171 | static bool do_narrow_3d(DisasContext *s, arg_3diff *a, | ||
172 | NeonGenTwo64OpFn *opfn, NeonGenNarrowFn *narrowfn) | ||
173 | -- | 24 | -- |
174 | 2.20.1 | 25 | 2.20.1 |
175 | 26 | ||
176 | 27 | diff view generated by jsdifflib |
1 | In arm_v7m_mmu_idx_for_secstate() we get the 'priv' level to pass to | 1 | Move the NeonGenThreeOpEnvFn typedef to translate.h together |
---|---|---|---|
2 | armv7m_mmu_idx_for_secstate_and_priv() by calling arm_current_el(). | 2 | with the other similar typedefs. |
3 | This is incorrect when the security state being queried is not the | ||
4 | current one, because arm_current_el() uses the current security state | ||
5 | to determine which of the banked CONTROL.nPRIV bits to look at. | ||
6 | The effect was that if (for instance) Secure state was in privileged | ||
7 | mode but Non-Secure was not then we would return the wrong MMU index. | ||
8 | |||
9 | The only places where we are using this function in a way that could | ||
10 | trigger this bug are for the stack loads during a v8M function-return | ||
11 | and for the instruction fetch of a v8M SG insn. | ||
12 | |||
13 | Fix the bug by expanding out the M-profile version of the | ||
14 | arm_current_el() logic inline so it can use the passed in secstate | ||
15 | rather than env->v7m.secure. | ||
16 | 3 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
19 | Message-id: 20201022164408.13214-1-peter.maydell@linaro.org | 6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
7 | Message-id: 20210430132740.10391-12-peter.maydell@linaro.org | ||
20 | --- | 8 | --- |
21 | target/arm/m_helper.c | 3 ++- | 9 | target/arm/translate.h | 2 ++ |
22 | 1 file changed, 2 insertions(+), 1 deletion(-) | 10 | target/arm/translate.c | 3 --- |
11 | 2 files changed, 2 insertions(+), 3 deletions(-) | ||
23 | 12 | ||
24 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 13 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
25 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/m_helper.c | 15 | --- a/target/arm/translate.h |
27 | +++ b/target/arm/m_helper.c | 16 | +++ b/target/arm/translate.h |
28 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | 17 | @@ -XXX,XX +XXX,XX @@ typedef void NeonGenOneOpFn(TCGv_i32, TCGv_i32); |
29 | /* Return the MMU index for a v7M CPU in the specified security state */ | 18 | typedef void NeonGenOneOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32); |
30 | ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | 19 | typedef void NeonGenTwoOpFn(TCGv_i32, TCGv_i32, TCGv_i32); |
31 | { | 20 | typedef void NeonGenTwoOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32); |
32 | - bool priv = arm_current_el(env) != 0; | 21 | +typedef void NeonGenThreeOpEnvFn(TCGv_i32, TCGv_env, TCGv_i32, |
33 | + bool priv = arm_v7m_is_handler_mode(env) || | 22 | + TCGv_i32, TCGv_i32); |
34 | + !(env->v7m.control[secstate] & 1); | 23 | typedef void NeonGenTwo64OpFn(TCGv_i64, TCGv_i64, TCGv_i64); |
35 | 24 | typedef void NeonGenTwo64OpEnvFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i64); | |
36 | return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); | 25 | typedef void NeonGenNarrowFn(TCGv_i32, TCGv_i64); |
37 | } | 26 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/target/arm/translate.c | ||
29 | +++ b/target/arm/translate.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static const char * const regnames[] = | ||
31 | { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | ||
32 | "r8", "r9", "r10", "r11", "r12", "r13", "r14", "pc" }; | ||
33 | |||
34 | -/* Function prototypes for gen_ functions calling Neon helpers. */ | ||
35 | -typedef void NeonGenThreeOpEnvFn(TCGv_i32, TCGv_env, TCGv_i32, | ||
36 | - TCGv_i32, TCGv_i32); | ||
37 | |||
38 | /* initialize TCG globals. */ | ||
39 | void arm_translate_init(void) | ||
38 | -- | 40 | -- |
39 | 2.20.1 | 41 | 2.20.1 |
40 | 42 | ||
41 | 43 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Make the remaining functions needed by the translate-neon code |
---|---|---|---|
2 | global. | ||
2 | 3 | ||
3 | This function makes it clear that we're talking about the whole | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | register, and not the 32-bit piece at index 0. This fixes a bug | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
5 | when running on a big-endian host. | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20210430132740.10391-13-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/translate-a32.h | 8 ++++++++ | ||
10 | target/arm/translate.c | 10 ++-------- | ||
11 | 2 files changed, 10 insertions(+), 8 deletions(-) | ||
6 | 12 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 13 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h |
8 | Message-id: 20201030022618.785675-2-richard.henderson@linaro.org | 14 | index XXXXXXX..XXXXXXX 100644 |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | --- a/target/arm/translate-a32.h |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | +++ b/target/arm/translate-a32.h |
11 | --- | 17 | @@ -XXX,XX +XXX,XX @@ void gen_set_pc_im(DisasContext *s, target_ulong val); |
12 | target/arm/translate.c | 8 ++++++ | 18 | void gen_lookup_tb(DisasContext *s); |
13 | target/arm/translate-neon.c.inc | 44 ++++++++++++++++----------------- | 19 | long vfp_reg_offset(bool dp, unsigned reg); |
14 | target/arm/translate-vfp.c.inc | 2 +- | 20 | long neon_full_reg_offset(unsigned reg); |
15 | 3 files changed, 31 insertions(+), 23 deletions(-) | 21 | +long neon_element_offset(int reg, int element, MemOp memop); |
16 | 22 | +void gen_rev16(TCGv_i32 dest, TCGv_i32 var); | |
23 | |||
24 | static inline TCGv_i32 load_cpu_offset(int offset) | ||
25 | { | ||
26 | @@ -XXX,XX +XXX,XX @@ DO_GEN_ST(32, MO_UL) | ||
27 | /* Set NZCV flags from the high 4 bits of var. */ | ||
28 | #define gen_set_nzcv(var) gen_set_cpsr(var, CPSR_NZCV) | ||
29 | |||
30 | +/* Swap low and high halfwords. */ | ||
31 | +static inline void gen_swap_half(TCGv_i32 dest, TCGv_i32 var) | ||
32 | +{ | ||
33 | + tcg_gen_rotri_i32(dest, var, 16); | ||
34 | +} | ||
35 | + | ||
36 | #endif | ||
17 | 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 |
18 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate.c | 39 | --- a/target/arm/translate.c |
20 | +++ b/target/arm/translate.c | 40 | +++ b/target/arm/translate.c |
21 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) | 41 | @@ -XXX,XX +XXX,XX @@ static void gen_smul_dual(TCGv_i32 a, TCGv_i32 b) |
22 | unallocated_encoding(s); | ||
23 | } | 42 | } |
24 | 43 | ||
25 | +/* | 44 | /* Byteswap each halfword. */ |
26 | + * Return the offset of a "full" NEON Dreg. | 45 | -static void gen_rev16(TCGv_i32 dest, TCGv_i32 var) |
27 | + */ | 46 | +void gen_rev16(TCGv_i32 dest, TCGv_i32 var) |
28 | +static long neon_full_reg_offset(unsigned reg) | ||
29 | +{ | ||
30 | + return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]); | ||
31 | +} | ||
32 | + | ||
33 | static inline long vfp_reg_offset(bool dp, unsigned reg) | ||
34 | { | 47 | { |
35 | if (dp) { | 48 | TCGv_i32 tmp = tcg_temp_new_i32(); |
36 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 49 | TCGv_i32 mask = tcg_const_i32(0x00ff00ff); |
37 | index XXXXXXX..XXXXXXX 100644 | 50 | @@ -XXX,XX +XXX,XX @@ static void gen_revsh(TCGv_i32 dest, TCGv_i32 var) |
38 | --- a/target/arm/translate-neon.c.inc | 51 | tcg_gen_ext16s_i32(dest, var); |
39 | +++ b/target/arm/translate-neon.c.inc | ||
40 | @@ -XXX,XX +XXX,XX @@ neon_element_offset(int reg, int element, MemOp size) | ||
41 | ofs ^= 8 - element_size; | ||
42 | } | ||
43 | #endif | ||
44 | - return neon_reg_offset(reg, 0) + ofs; | ||
45 | + return neon_full_reg_offset(reg) + ofs; | ||
46 | } | 52 | } |
47 | 53 | ||
48 | static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop) | 54 | -/* Swap low and high halfwords. */ |
49 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | 55 | -static void gen_swap_half(TCGv_i32 dest, TCGv_i32 var) |
50 | * We cannot write 16 bytes at once because the | 56 | -{ |
51 | * destination is unaligned. | 57 | - tcg_gen_rotri_i32(dest, var, 16); |
52 | */ | 58 | -} |
53 | - tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0), | 59 | - |
54 | + tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(vd), | 60 | /* Dual 16-bit add. Result placed in t0 and t1 is marked as dead. |
55 | 8, 8, tmp); | 61 | tmp = (t0 ^ t1) & 0x8000; |
56 | - tcg_gen_gvec_mov(0, neon_reg_offset(vd + 1, 0), | 62 | t0 &= ~0x8000; |
57 | - neon_reg_offset(vd, 0), 8, 8); | 63 | @@ -XXX,XX +XXX,XX @@ long neon_full_reg_offset(unsigned reg) |
58 | + tcg_gen_gvec_mov(0, neon_full_reg_offset(vd + 1), | 64 | * Return the offset of a 2**SIZE piece of a NEON register, at index ELE, |
59 | + neon_full_reg_offset(vd), 8, 8); | 65 | * where 0 is the least significant end of the register. |
60 | } else { | 66 | */ |
61 | - tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0), | 67 | -static long neon_element_offset(int reg, int element, MemOp memop) |
62 | + tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(vd), | 68 | +long neon_element_offset(int reg, int element, MemOp memop) |
63 | vec_size, vec_size, tmp); | ||
64 | } | ||
65 | tcg_gen_addi_i32(addr, addr, 1 << size); | ||
66 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a) | ||
67 | static bool do_3same(DisasContext *s, arg_3same *a, GVecGen3Fn fn) | ||
68 | { | 69 | { |
69 | int vec_size = a->q ? 16 : 8; | 70 | int element_size = 1 << (memop & MO_SIZE); |
70 | - int rd_ofs = neon_reg_offset(a->vd, 0); | 71 | int ofs = element * element_size; |
71 | - int rn_ofs = neon_reg_offset(a->vn, 0); | ||
72 | - int rm_ofs = neon_reg_offset(a->vm, 0); | ||
73 | + int rd_ofs = neon_full_reg_offset(a->vd); | ||
74 | + int rn_ofs = neon_full_reg_offset(a->vn); | ||
75 | + int rm_ofs = neon_full_reg_offset(a->vm); | ||
76 | |||
77 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
78 | return false; | ||
79 | @@ -XXX,XX +XXX,XX @@ static bool do_vector_2sh(DisasContext *s, arg_2reg_shift *a, GVecGen2iFn *fn) | ||
80 | { | ||
81 | /* Handle a 2-reg-shift insn which can be vectorized. */ | ||
82 | int vec_size = a->q ? 16 : 8; | ||
83 | - int rd_ofs = neon_reg_offset(a->vd, 0); | ||
84 | - int rm_ofs = neon_reg_offset(a->vm, 0); | ||
85 | + int rd_ofs = neon_full_reg_offset(a->vd); | ||
86 | + int rm_ofs = neon_full_reg_offset(a->vm); | ||
87 | |||
88 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
89 | return false; | ||
90 | @@ -XXX,XX +XXX,XX @@ static bool do_fp_2sh(DisasContext *s, arg_2reg_shift *a, | ||
91 | { | ||
92 | /* FP operations in 2-reg-and-shift group */ | ||
93 | int vec_size = a->q ? 16 : 8; | ||
94 | - int rd_ofs = neon_reg_offset(a->vd, 0); | ||
95 | - int rm_ofs = neon_reg_offset(a->vm, 0); | ||
96 | + int rd_ofs = neon_full_reg_offset(a->vd); | ||
97 | + int rm_ofs = neon_full_reg_offset(a->vm); | ||
98 | TCGv_ptr fpst; | ||
99 | |||
100 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
101 | @@ -XXX,XX +XXX,XX @@ static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a, | ||
102 | return true; | ||
103 | } | ||
104 | |||
105 | - reg_ofs = neon_reg_offset(a->vd, 0); | ||
106 | + reg_ofs = neon_full_reg_offset(a->vd); | ||
107 | vec_size = a->q ? 16 : 8; | ||
108 | imm = asimd_imm_const(a->imm, a->cmode, a->op); | ||
109 | |||
110 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMULL_P_3d(DisasContext *s, arg_3diff *a) | ||
111 | return true; | ||
112 | } | ||
113 | |||
114 | - tcg_gen_gvec_3_ool(neon_reg_offset(a->vd, 0), | ||
115 | - neon_reg_offset(a->vn, 0), | ||
116 | - neon_reg_offset(a->vm, 0), | ||
117 | + tcg_gen_gvec_3_ool(neon_full_reg_offset(a->vd), | ||
118 | + neon_full_reg_offset(a->vn), | ||
119 | + neon_full_reg_offset(a->vm), | ||
120 | 16, 16, 0, fn_gvec); | ||
121 | return true; | ||
122 | } | ||
123 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar_fp_vec(DisasContext *s, arg_2scalar *a, | ||
124 | { | ||
125 | /* Two registers and a scalar, using gvec */ | ||
126 | int vec_size = a->q ? 16 : 8; | ||
127 | - int rd_ofs = neon_reg_offset(a->vd, 0); | ||
128 | - int rn_ofs = neon_reg_offset(a->vn, 0); | ||
129 | + int rd_ofs = neon_full_reg_offset(a->vd); | ||
130 | + int rn_ofs = neon_full_reg_offset(a->vn); | ||
131 | int rm_ofs; | ||
132 | int idx; | ||
133 | TCGv_ptr fpstatus; | ||
134 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar_fp_vec(DisasContext *s, arg_2scalar *a, | ||
135 | /* a->vm is M:Vm, which encodes both register and index */ | ||
136 | idx = extract32(a->vm, a->size + 2, 2); | ||
137 | a->vm = extract32(a->vm, 0, a->size + 2); | ||
138 | - rm_ofs = neon_reg_offset(a->vm, 0); | ||
139 | + rm_ofs = neon_full_reg_offset(a->vm); | ||
140 | |||
141 | fpstatus = fpstatus_ptr(a->size == 1 ? FPST_STD_F16 : FPST_STD); | ||
142 | tcg_gen_gvec_3_ptr(rd_ofs, rn_ofs, rm_ofs, fpstatus, | ||
143 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDUP_scalar(DisasContext *s, arg_VDUP_scalar *a) | ||
144 | return true; | ||
145 | } | ||
146 | |||
147 | - tcg_gen_gvec_dup_mem(a->size, neon_reg_offset(a->vd, 0), | ||
148 | + tcg_gen_gvec_dup_mem(a->size, neon_full_reg_offset(a->vd), | ||
149 | neon_element_offset(a->vm, a->index, a->size), | ||
150 | a->q ? 16 : 8, a->q ? 16 : 8); | ||
151 | return true; | ||
152 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_F32_F16(DisasContext *s, arg_2misc *a) | ||
153 | static bool do_2misc_vec(DisasContext *s, arg_2misc *a, GVecGen2Fn *fn) | ||
154 | { | ||
155 | int vec_size = a->q ? 16 : 8; | ||
156 | - int rd_ofs = neon_reg_offset(a->vd, 0); | ||
157 | - int rm_ofs = neon_reg_offset(a->vm, 0); | ||
158 | + int rd_ofs = neon_full_reg_offset(a->vd); | ||
159 | + int rm_ofs = neon_full_reg_offset(a->vm); | ||
160 | |||
161 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
162 | return false; | ||
163 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/target/arm/translate-vfp.c.inc | ||
166 | +++ b/target/arm/translate-vfp.c.inc | ||
167 | @@ -XXX,XX +XXX,XX @@ static bool trans_VDUP(DisasContext *s, arg_VDUP *a) | ||
168 | } | ||
169 | |||
170 | tmp = load_reg(s, a->rt); | ||
171 | - tcg_gen_gvec_dup_i32(size, neon_reg_offset(a->vn, 0), | ||
172 | + tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(a->vn), | ||
173 | vec_size, vec_size, tmp); | ||
174 | tcg_temp_free_i32(tmp); | ||
175 | |||
176 | -- | 72 | -- |
177 | 2.20.1 | 73 | 2.20.1 |
178 | 74 | ||
179 | 75 | diff view generated by jsdifflib |
1 | The randomness tests in the NPCM7xx RNG test fail intermittently | 1 | Switch translate-neon.c.inc from being #included into translate.c |
---|---|---|---|
2 | but fairly frequently. On my machine running the test in a loop: | 2 | to being its own compilation unit. |
3 | while QTEST_QEMU_BINARY=./qemu-system-aarch64 ./tests/qtest/npcm7xx_rng-test; do true; done | ||
4 | |||
5 | will fail in less than a minute with an error like: | ||
6 | ERROR:../../tests/qtest/npcm7xx_rng-test.c:256:test_first_byte_runs: | ||
7 | assertion failed (calc_runs_p(buf.l, sizeof(buf) * BITS_PER_BYTE) > 0.01): (0.00286205989 > 0.01) | ||
8 | |||
9 | (Failures have been observed on all 4 of the randomness tests, | ||
10 | not just first_byte_runs.) | ||
11 | |||
12 | It's not clear why these tests are failing like this, but intermittent | ||
13 | failures make CI and merge testing awkward, so disable running them | ||
14 | unless a developer specifically sets QEMU_TEST_FLAKY_RNG_TESTS when | ||
15 | running the test suite, until we work out the cause. | ||
16 | 3 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
19 | Message-id: 20201102152454.8287-1-peter.maydell@linaro.org | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
20 | Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com> | 7 | Message-id: 20210430132740.10391-14-peter.maydell@linaro.org |
21 | --- | 8 | --- |
22 | tests/qtest/npcm7xx_rng-test.c | 14 ++++++++++---- | 9 | target/arm/translate-a32.h | 3 +++ |
23 | 1 file changed, 10 insertions(+), 4 deletions(-) | 10 | .../arm/{translate-neon.c.inc => translate-neon.c} | 12 +++++++----- |
11 | target/arm/translate.c | 3 --- | ||
12 | target/arm/meson.build | 7 ++++--- | ||
13 | 4 files changed, 14 insertions(+), 11 deletions(-) | ||
14 | rename target/arm/{translate-neon.c.inc => translate-neon.c} (99%) | ||
24 | 15 | ||
25 | diff --git a/tests/qtest/npcm7xx_rng-test.c b/tests/qtest/npcm7xx_rng-test.c | 16 | diff --git a/target/arm/translate-a32.h b/target/arm/translate-a32.h |
26 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/tests/qtest/npcm7xx_rng-test.c | 18 | --- a/target/arm/translate-a32.h |
28 | +++ b/tests/qtest/npcm7xx_rng-test.c | 19 | +++ b/target/arm/translate-a32.h |
29 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | 20 | @@ -XXX,XX +XXX,XX @@ |
30 | 21 | bool disas_m_nocp(DisasContext *dc, uint32_t insn); | |
31 | qtest_add_func("npcm7xx_rng/enable_disable", test_enable_disable); | 22 | bool disas_vfp(DisasContext *s, uint32_t insn); |
32 | qtest_add_func("npcm7xx_rng/rosel", test_rosel); | 23 | bool disas_vfp_uncond(DisasContext *s, uint32_t insn); |
33 | - qtest_add_func("npcm7xx_rng/continuous/monobit", test_continuous_monobit); | 24 | +bool disas_neon_dp(DisasContext *s, uint32_t insn); |
34 | - qtest_add_func("npcm7xx_rng/continuous/runs", test_continuous_runs); | 25 | +bool disas_neon_ls(DisasContext *s, uint32_t insn); |
35 | - qtest_add_func("npcm7xx_rng/first_byte/monobit", test_first_byte_monobit); | 26 | +bool disas_neon_shared(DisasContext *s, uint32_t insn); |
36 | - qtest_add_func("npcm7xx_rng/first_byte/runs", test_first_byte_runs); | 27 | |
37 | + /* | 28 | void load_reg_var(DisasContext *s, TCGv_i32 var, int reg); |
38 | + * These tests fail intermittently; only run them on explicit | 29 | void arm_gen_condlabel(DisasContext *s); |
39 | + * request until we figure out why. | 30 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c |
40 | + */ | 31 | similarity index 99% |
41 | + if (getenv("QEMU_TEST_FLAKY_RNG_TESTS")) { | 32 | rename from target/arm/translate-neon.c.inc |
42 | + qtest_add_func("npcm7xx_rng/continuous/monobit", test_continuous_monobit); | 33 | rename to target/arm/translate-neon.c |
43 | + qtest_add_func("npcm7xx_rng/continuous/runs", test_continuous_runs); | 34 | index XXXXXXX..XXXXXXX 100644 |
44 | + qtest_add_func("npcm7xx_rng/first_byte/monobit", test_first_byte_monobit); | 35 | --- a/target/arm/translate-neon.c.inc |
45 | + qtest_add_func("npcm7xx_rng/first_byte/runs", test_first_byte_runs); | 36 | +++ b/target/arm/translate-neon.c |
46 | + } | 37 | @@ -XXX,XX +XXX,XX @@ |
47 | 38 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. | |
48 | qtest_start("-machine npcm750-evb"); | 39 | */ |
49 | ret = g_test_run(); | 40 | |
41 | -/* | ||
42 | - * This file is intended to be included from translate.c; it uses | ||
43 | - * some macros and definitions provided by that file. | ||
44 | - * It might be possible to convert it to a standalone .c file eventually. | ||
45 | - */ | ||
46 | +#include "qemu/osdep.h" | ||
47 | +#include "tcg/tcg-op.h" | ||
48 | +#include "tcg/tcg-op-gvec.h" | ||
49 | +#include "exec/exec-all.h" | ||
50 | +#include "exec/gen-icount.h" | ||
51 | +#include "translate.h" | ||
52 | +#include "translate-a32.h" | ||
53 | |||
54 | static inline int plus1(DisasContext *s, int x) | ||
55 | { | ||
56 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/translate.c | ||
59 | +++ b/target/arm/translate.c | ||
60 | @@ -XXX,XX +XXX,XX @@ void write_neon_element64(TCGv_i64 src, int reg, int ele, MemOp memop) | ||
61 | |||
62 | #define ARM_CP_RW_BIT (1 << 20) | ||
63 | |||
64 | -/* Include the Neon decoder */ | ||
65 | -#include "translate-neon.c.inc" | ||
66 | - | ||
67 | static inline void iwmmxt_load_reg(TCGv_i64 var, int reg) | ||
68 | { | ||
69 | tcg_gen_ld_i64(var, cpu_env, offsetof(CPUARMState, iwmmxt.regs[reg])); | ||
70 | diff --git a/target/arm/meson.build b/target/arm/meson.build | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/target/arm/meson.build | ||
73 | +++ b/target/arm/meson.build | ||
74 | @@ -XXX,XX +XXX,XX @@ | ||
75 | gen = [ | ||
76 | decodetree.process('sve.decode', extra_args: '--decode=disas_sve'), | ||
77 | - decodetree.process('neon-shared.decode', extra_args: '--static-decode=disas_neon_shared'), | ||
78 | - decodetree.process('neon-dp.decode', extra_args: '--static-decode=disas_neon_dp'), | ||
79 | - decodetree.process('neon-ls.decode', extra_args: '--static-decode=disas_neon_ls'), | ||
80 | + decodetree.process('neon-shared.decode', extra_args: '--decode=disas_neon_shared'), | ||
81 | + decodetree.process('neon-dp.decode', extra_args: '--decode=disas_neon_dp'), | ||
82 | + decodetree.process('neon-ls.decode', extra_args: '--decode=disas_neon_ls'), | ||
83 | decodetree.process('vfp.decode', extra_args: '--decode=disas_vfp'), | ||
84 | decodetree.process('vfp-uncond.decode', extra_args: '--decode=disas_vfp_uncond'), | ||
85 | decodetree.process('m-nocp.decode', extra_args: '--decode=disas_m_nocp'), | ||
86 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(files( | ||
87 | 'tlb_helper.c', | ||
88 | 'translate.c', | ||
89 | 'translate-m-nocp.c', | ||
90 | + 'translate-neon.c', | ||
91 | 'translate-vfp.c', | ||
92 | 'vec_helper.c', | ||
93 | 'vfp_helper.c', | ||
50 | -- | 94 | -- |
51 | 2.20.1 | 95 | 2.20.1 |
52 | 96 | ||
53 | 97 | diff view generated by jsdifflib |
1 | In gicv3_init_cpuif() we copy the ARMCPU gicv3_maintenance_interrupt | 1 | The WFI insn is not system-mode only, though it doesn't usually make |
---|---|---|---|
2 | into the GICv3CPUState struct's maintenance_irq field. This will | 2 | a huge amount of sense for userspace code to execute it. Currently |
3 | only work if the board happens to have already wired up the CPU | 3 | if you try it in qemu-arm then the helper function will raise an |
4 | maintenance IRQ before the GIC was realized. Unfortunately this is | 4 | EXCP_HLT exception, which is not covered by the switch in cpu_loop() |
5 | not the case for the 'virt' board, and so the value that gets copied | 5 | and results in an abort: |
6 | is NULL (since a qemu_irq is really a pointer to an IRQState struct | ||
7 | under the hood). The effect is that the CPU interface code never | ||
8 | actually raises the maintenance interrupt line. | ||
9 | 6 | ||
10 | Instead, since the GICv3CPUState has a pointer to the CPUState, make | 7 | qemu: unhandled CPU exception 0x10001 - aborting |
11 | the dereference at the point where we want to raise the interrupt, to | 8 | R00=00000001 R01=408003e4 R02=408003ec R03=000102ec |
12 | avoid an implicit requirement on board code to wire things up in a | 9 | R04=00010a28 R05=00010158 R06=00087460 R07=00010158 |
13 | particular order. | 10 | R08=00000000 R09=00000000 R10=00085b7c R11=408002a4 |
11 | R12=408002b8 R13=408002a0 R14=0001057c R15=000102f8 | ||
12 | PSR=60000010 -ZC- A usr32 | ||
13 | qemu:handle_cpu_signal received signal outside vCPU context @ pc=0x7fcbfa4f0a12 | ||
14 | 14 | ||
15 | Reported-by: Jose Martins <josemartins90@gmail.com> | 15 | Make the WFI helper function return immediately in the usermode |
16 | emulator. This turns WFI into a NOP, which is OK because: | ||
17 | * architecturally "WFI is a NOP" is a permitted implementation | ||
18 | * aarch64 Linux kernels use the SCTLR_EL1.nTWI bit to trap | ||
19 | userspace WFI and NOP it (though aarch32 kernels currently | ||
20 | just let WFI do whatever it would do) | ||
21 | |||
22 | We could in theory make the translate.c code special case user-mode | ||
23 | emulation and NOP the insn entirely rather than making the helper | ||
24 | do nothing, but because no real world code will be trying to | ||
25 | execute WFI we don't care about efficiency and the helper provides | ||
26 | a single place where we can make the change rather than having | ||
27 | to touch multiple places in translate.c and translate-a64.c. | ||
28 | |||
29 | Fixes: https://bugs.launchpad.net/qemu/+bug/1926759 | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Message-id: 20201009153904.28529-1-peter.maydell@linaro.org | 31 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
18 | Reviewed-by: Luc Michel <luc@lmichel.fr> | 32 | Message-id: 20210430162212.825-1-peter.maydell@linaro.org |
19 | --- | 33 | --- |
20 | include/hw/intc/arm_gicv3_common.h | 1 - | 34 | target/arm/op_helper.c | 12 ++++++++++++ |
21 | hw/intc/arm_gicv3_cpuif.c | 5 ++--- | 35 | 1 file changed, 12 insertions(+) |
22 | 2 files changed, 2 insertions(+), 4 deletions(-) | ||
23 | 36 | ||
24 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | 37 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c |
25 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/intc/arm_gicv3_common.h | 39 | --- a/target/arm/op_helper.c |
27 | +++ b/include/hw/intc/arm_gicv3_common.h | 40 | +++ b/target/arm/op_helper.c |
28 | @@ -XXX,XX +XXX,XX @@ struct GICv3CPUState { | 41 | @@ -XXX,XX +XXX,XX @@ static inline int check_wfx_trap(CPUARMState *env, bool is_wfe) |
29 | qemu_irq parent_fiq; | 42 | |
30 | qemu_irq parent_virq; | 43 | void HELPER(wfi)(CPUARMState *env, uint32_t insn_len) |
31 | qemu_irq parent_vfiq; | 44 | { |
32 | - qemu_irq maintenance_irq; | 45 | +#ifdef CONFIG_USER_ONLY |
33 | 46 | + /* | |
34 | /* Redistributor */ | 47 | + * WFI in the user-mode emulator is technically permitted but not |
35 | uint32_t level; /* Current IRQ level */ | 48 | + * something any real-world code would do. AArch64 Linux kernels |
36 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | 49 | + * trap it via SCTRL_EL1.nTWI and make it an (expensive) NOP; |
37 | index XXXXXXX..XXXXXXX 100644 | 50 | + * AArch32 kernels don't trap it so it will delay a bit. |
38 | --- a/hw/intc/arm_gicv3_cpuif.c | 51 | + * For QEMU, make it NOP here, because trying to raise EXCP_HLT |
39 | +++ b/hw/intc/arm_gicv3_cpuif.c | 52 | + * would trigger an abort. |
40 | @@ -XXX,XX +XXX,XX @@ static void gicv3_cpuif_virt_update(GICv3CPUState *cs) | 53 | + */ |
41 | int irqlevel = 0; | 54 | + return; |
42 | int fiqlevel = 0; | 55 | +#else |
43 | int maintlevel = 0; | 56 | CPUState *cs = env_cpu(env); |
44 | + ARMCPU *cpu = ARM_CPU(cs->cpu); | 57 | int target_el = check_wfx_trap(env, false); |
45 | 58 | ||
46 | idx = hppvi_index(cs); | 59 | @@ -XXX,XX +XXX,XX @@ void HELPER(wfi)(CPUARMState *env, uint32_t insn_len) |
47 | trace_gicv3_cpuif_virt_update(gicv3_redist_affid(cs), idx); | 60 | cs->exception_index = EXCP_HLT; |
48 | @@ -XXX,XX +XXX,XX @@ static void gicv3_cpuif_virt_update(GICv3CPUState *cs) | 61 | cs->halted = 1; |
49 | 62 | cpu_loop_exit(cs); | |
50 | qemu_set_irq(cs->parent_vfiq, fiqlevel); | 63 | +#endif |
51 | qemu_set_irq(cs->parent_virq, irqlevel); | ||
52 | - qemu_set_irq(cs->maintenance_irq, maintlevel); | ||
53 | + qemu_set_irq(cpu->gicv3_maintenance_interrupt, maintlevel); | ||
54 | } | 64 | } |
55 | 65 | ||
56 | static uint64_t icv_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | 66 | void HELPER(wfe)(CPUARMState *env) |
57 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) | ||
58 | && cpu->gic_num_lrs) { | ||
59 | int j; | ||
60 | |||
61 | - cs->maintenance_irq = cpu->gicv3_maintenance_interrupt; | ||
62 | - | ||
63 | cs->num_list_regs = cpu->gic_num_lrs; | ||
64 | cs->vpribits = cpu->gic_vpribits; | ||
65 | cs->vprebits = cpu->gic_vprebits; | ||
66 | -- | 67 | -- |
67 | 2.20.1 | 68 | 2.20.1 |
68 | 69 | ||
69 | 70 | diff view generated by jsdifflib |
1 | If we're using the capstone disassembler, disassembly of a run of | 1 | The omap_mmc_reset() function resets its SD card via |
---|---|---|---|
2 | instructions more than 32 bytes long disassembles the wrong data for | 2 | device_legacy_reset(). We know that the SD card does not have a qbus |
3 | instructions beyond the 32 byte mark: | 3 | of its own, so the new device_cold_reset() function (which resets |
4 | both the device and its child buses) is equivalent here to | ||
5 | device_legacy_reset() and we can just switch to the new API. | ||
4 | 6 | ||
5 | (qemu) xp /16x 0x100 | ||
6 | 0000000000000100: 0x00000005 0x54410001 0x00000001 0x00001000 | ||
7 | 0000000000000110: 0x00000000 0x00000004 0x54410002 0x3c000000 | ||
8 | 0000000000000120: 0x00000000 0x00000004 0x54410009 0x74736574 | ||
9 | 0000000000000130: 0x00000000 0x00000000 0x00000000 0x00000000 | ||
10 | (qemu) xp /16i 0x100 | ||
11 | 0x00000100: 00000005 andeq r0, r0, r5 | ||
12 | 0x00000104: 54410001 strbpl r0, [r1], #-1 | ||
13 | 0x00000108: 00000001 andeq r0, r0, r1 | ||
14 | 0x0000010c: 00001000 andeq r1, r0, r0 | ||
15 | 0x00000110: 00000000 andeq r0, r0, r0 | ||
16 | 0x00000114: 00000004 andeq r0, r0, r4 | ||
17 | 0x00000118: 54410002 strbpl r0, [r1], #-2 | ||
18 | 0x0000011c: 3c000000 .byte 0x00, 0x00, 0x00, 0x3c | ||
19 | 0x00000120: 54410001 strbpl r0, [r1], #-1 | ||
20 | 0x00000124: 00000001 andeq r0, r0, r1 | ||
21 | 0x00000128: 00001000 andeq r1, r0, r0 | ||
22 | 0x0000012c: 00000000 andeq r0, r0, r0 | ||
23 | 0x00000130: 00000004 andeq r0, r0, r4 | ||
24 | 0x00000134: 54410002 strbpl r0, [r1], #-2 | ||
25 | 0x00000138: 3c000000 .byte 0x00, 0x00, 0x00, 0x3c | ||
26 | 0x0000013c: 00000000 andeq r0, r0, r0 | ||
27 | |||
28 | Here the disassembly of 0x120..0x13f is using the data that is in | ||
29 | 0x104..0x123. | ||
30 | |||
31 | This is caused by passing the wrong value to the read_memory_func(). | ||
32 | The intention is that at this point in the loop the 'cap_buf' buffer | ||
33 | already contains 'csize' bytes of data for the instruction at guest | ||
34 | addr 'pc', and we want to read in an extra 'tsize' bytes. Those | ||
35 | extra bytes are therefore at 'pc + csize', not 'pc'. On the first | ||
36 | time through the loop 'csize' happens to be zero, so the initial read | ||
37 | of 32 bytes into cap_buf is correct and as long as the disassembly | ||
38 | never needs to read more data we return the correct information. | ||
39 | |||
40 | Use the correct guest address in the call to read_memory_func(). | ||
41 | |||
42 | Cc: qemu-stable@nongnu.org | ||
43 | Fixes: https://bugs.launchpad.net/qemu/+bug/1900779 | ||
44 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
45 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
46 | Message-id: 20201022132445.25039-1-peter.maydell@linaro.org | 9 | Message-id: 20210430222348.8514-1-peter.maydell@linaro.org |
47 | --- | 10 | --- |
48 | disas/capstone.c | 2 +- | 11 | hw/sd/omap_mmc.c | 2 +- |
49 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
50 | 13 | ||
51 | diff --git a/disas/capstone.c b/disas/capstone.c | 14 | diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c |
52 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/disas/capstone.c | 16 | --- a/hw/sd/omap_mmc.c |
54 | +++ b/disas/capstone.c | 17 | +++ b/hw/sd/omap_mmc.c |
55 | @@ -XXX,XX +XXX,XX @@ bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count) | 18 | @@ -XXX,XX +XXX,XX @@ void omap_mmc_reset(struct omap_mmc_s *host) |
56 | 19 | * into any bus, and we must reset it manually. When omap_mmc is | |
57 | /* Make certain that we can make progress. */ | 20 | * QOMified this must move into the QOM reset function. |
58 | assert(tsize != 0); | 21 | */ |
59 | - info->read_memory_func(pc, cap_buf + csize, tsize, info); | 22 | - device_legacy_reset(DEVICE(host->card)); |
60 | + info->read_memory_func(pc + csize, cap_buf + csize, tsize, info); | 23 | + device_cold_reset(DEVICE(host->card)); |
61 | csize += tsize; | 24 | } |
62 | 25 | ||
63 | if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { | 26 | static uint64_t omap_mmc_read(void *opaque, hwaddr offset, |
64 | -- | 27 | -- |
65 | 2.20.1 | 28 | 2.20.1 |
66 | 29 | ||
67 | 30 | diff view generated by jsdifflib |
1 | The kerneldoc script currently emits Sphinx markup for a macro with | 1 | Both os-win32.h and os-posix.h include system header files. Instead |
---|---|---|---|
2 | arguments that uses the c:function directive. This is correct for | 2 | of having osdep.h include them inside its 'extern "C"' block, make |
3 | Sphinx versions earlier than Sphinx 3, where c:macro doesn't allow | 3 | these headers handle that themselves, so that we don't include the |
4 | documentation of macros with arguments and c:function is not picky | 4 | system headers inside 'extern "C"'. |
5 | about the syntax of what it is passed. However, in Sphinx 3 the | ||
6 | c:macro directive was enhanced to support macros with arguments, | ||
7 | and c:function was made more picky about what syntax it accepted. | ||
8 | 5 | ||
9 | When kerneldoc is told that it needs to produce output for Sphinx | 6 | This doesn't fix any current problems, but it's conceptually the |
10 | 3 or later, make it emit c:function only for functions and c:macro | 7 | right way to handle system headers. |
11 | for macros with arguments. We assume that anything with a return | ||
12 | type is a function and anything without is a macro. | ||
13 | |||
14 | This fixes the Sphinx error: | ||
15 | |||
16 | /home/petmay01/linaro/qemu-from-laptop/qemu/docs/../include/qom/object.h:155:Error in declarator | ||
17 | If declarator-id with parameters (e.g., 'void f(int arg)'): | ||
18 | Invalid C declaration: Expected identifier in nested name. [error at 25] | ||
19 | DECLARE_INSTANCE_CHECKER ( InstanceType, OBJ_NAME, TYPENAME) | ||
20 | -------------------------^ | ||
21 | If parenthesis in noptr-declarator (e.g., 'void (*f(int arg))(double)'): | ||
22 | Error in declarator or parameters | ||
23 | Invalid C declaration: Expecting "(" in parameters. [error at 39] | ||
24 | DECLARE_INSTANCE_CHECKER ( InstanceType, OBJ_NAME, TYPENAME) | ||
25 | ---------------------------------------^ | ||
26 | 8 | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
29 | Tested-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
30 | Message-id: 20201030174700.7204-2-peter.maydell@linaro.org | ||
31 | --- | 11 | --- |
32 | scripts/kernel-doc | 18 +++++++++++++++++- | 12 | include/qemu/osdep.h | 8 ++++---- |
33 | 1 file changed, 17 insertions(+), 1 deletion(-) | 13 | include/sysemu/os-posix.h | 8 ++++++++ |
14 | include/sysemu/os-win32.h | 8 ++++++++ | ||
15 | 3 files changed, 20 insertions(+), 4 deletions(-) | ||
34 | 16 | ||
35 | diff --git a/scripts/kernel-doc b/scripts/kernel-doc | 17 | diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h |
36 | index XXXXXXX..XXXXXXX 100755 | 18 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/scripts/kernel-doc | 19 | --- a/include/qemu/osdep.h |
38 | +++ b/scripts/kernel-doc | 20 | +++ b/include/qemu/osdep.h |
39 | @@ -XXX,XX +XXX,XX @@ sub output_function_rst(%) { | 21 | @@ -XXX,XX +XXX,XX @@ QEMU_EXTERN_C int daemon(int, int); |
40 | output_highlight_rst($args{'purpose'}); | 22 | */ |
41 | $start = "\n\n**Syntax**\n\n ``"; | 23 | #include "glib-compat.h" |
42 | } else { | 24 | |
43 | - print ".. c:function:: "; | 25 | -#ifdef __cplusplus |
44 | + if ((split(/\./, $sphinx_version))[0] >= 3) { | 26 | -extern "C" { |
45 | + # Sphinx 3 and later distinguish macros and functions and | 27 | -#endif |
46 | + # complain if you use c:function with something that's not | 28 | - |
47 | + # syntactically valid as a function declaration. | 29 | #ifdef _WIN32 |
48 | + # We assume that anything with a return type is a function | 30 | #include "sysemu/os-win32.h" |
49 | + # and anything without is a macro. | 31 | #endif |
50 | + if ($args{'functiontype'} ne "") { | 32 | @@ -XXX,XX +XXX,XX @@ extern "C" { |
51 | + print ".. c:function:: "; | 33 | #include "sysemu/os-posix.h" |
52 | + } else { | 34 | #endif |
53 | + print ".. c:macro:: "; | 35 | |
54 | + } | 36 | +#ifdef __cplusplus |
55 | + } else { | 37 | +extern "C" { |
56 | + # Older Sphinx don't support documenting macros that take | 38 | +#endif |
57 | + # arguments with c:macro, and don't complain about the use | 39 | + |
58 | + # of c:function for this. | 40 | #include "qemu/typedefs.h" |
59 | + print ".. c:function:: "; | 41 | |
60 | + } | 42 | /* |
61 | } | 43 | diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h |
62 | if ($args{'functiontype'} ne "") { | 44 | index XXXXXXX..XXXXXXX 100644 |
63 | $start .= $args{'functiontype'} . " " . $args{'function'} . " ("; | 45 | --- a/include/sysemu/os-posix.h |
46 | +++ b/include/sysemu/os-posix.h | ||
47 | @@ -XXX,XX +XXX,XX @@ | ||
48 | #include <sys/sysmacros.h> | ||
49 | #endif | ||
50 | |||
51 | +#ifdef __cplusplus | ||
52 | +extern "C" { | ||
53 | +#endif | ||
54 | + | ||
55 | void os_set_line_buffering(void); | ||
56 | void os_set_proc_name(const char *s); | ||
57 | void os_setup_signal_handling(void); | ||
58 | @@ -XXX,XX +XXX,XX @@ static inline void qemu_funlockfile(FILE *f) | ||
59 | funlockfile(f); | ||
60 | } | ||
61 | |||
62 | +#ifdef __cplusplus | ||
63 | +} | ||
64 | +#endif | ||
65 | + | ||
66 | #endif | ||
67 | diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/include/sysemu/os-win32.h | ||
70 | +++ b/include/sysemu/os-win32.h | ||
71 | @@ -XXX,XX +XXX,XX @@ | ||
72 | #include <windows.h> | ||
73 | #include <ws2tcpip.h> | ||
74 | |||
75 | +#ifdef __cplusplus | ||
76 | +extern "C" { | ||
77 | +#endif | ||
78 | + | ||
79 | #if defined(_WIN64) | ||
80 | /* On w64, setjmp is implemented by _setjmp which needs a second parameter. | ||
81 | * If this parameter is NULL, longjump does no stack unwinding. | ||
82 | @@ -XXX,XX +XXX,XX @@ ssize_t qemu_recv_wrap(int sockfd, void *buf, size_t len, int flags); | ||
83 | ssize_t qemu_recvfrom_wrap(int sockfd, void *buf, size_t len, int flags, | ||
84 | struct sockaddr *addr, socklen_t *addrlen); | ||
85 | |||
86 | +#ifdef __cplusplus | ||
87 | +} | ||
88 | +#endif | ||
89 | + | ||
90 | #endif | ||
64 | -- | 91 | -- |
65 | 2.20.1 | 92 | 2.20.1 |
66 | 93 | ||
67 | 94 | diff view generated by jsdifflib |
1 | On some hosts (eg Ubuntu Bionic) pkg-config returns a set of | 1 | Make bswap.h handle being included outside an 'extern "C"' block: |
---|---|---|---|
2 | libraries for gio-2.0 which don't actually work when compiling | 2 | all system headers are included first, then all declarations are |
3 | statically. (Specifically, the returned library string includes | 3 | put inside an 'extern "C"' block. |
4 | -lmount, but not -lblkid which -lmount depends upon, so linking | ||
5 | fails due to missing symbols.) | ||
6 | 4 | ||
7 | Check that the libraries work, and don't enable gio if they don't, | 5 | This requires a little rearrangement as currently we have an ifdef |
8 | in the same way we do for gnutls. | 6 | ladder that has some system includes and some local declarations |
7 | or definitions, and we need to separate those out. | ||
8 | |||
9 | We want to do this because dis-asm.h includes bswap.h, dis-asm.h | ||
10 | may need to be included from C++ files, and system headers should | ||
11 | not be included within 'extern "C"' blocks. | ||
9 | 12 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
13 | Message-id: 20200928160402.7961-1-peter.maydell@linaro.org | ||
14 | --- | 15 | --- |
15 | configure | 10 +++++++++- | 16 | include/qemu/bswap.h | 26 ++++++++++++++++++++++---- |
16 | 1 file changed, 9 insertions(+), 1 deletion(-) | 17 | 1 file changed, 22 insertions(+), 4 deletions(-) |
17 | 18 | ||
18 | diff --git a/configure b/configure | 19 | diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h |
19 | index XXXXXXX..XXXXXXX 100755 | 20 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/configure | 21 | --- a/include/qemu/bswap.h |
21 | +++ b/configure | 22 | +++ b/include/qemu/bswap.h |
22 | @@ -XXX,XX +XXX,XX @@ if test "$static" = yes && test "$mingw32" = yes; then | 23 | @@ -XXX,XX +XXX,XX @@ |
23 | fi | 24 | #ifndef BSWAP_H |
24 | 25 | #define BSWAP_H | |
25 | if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then | 26 | |
26 | - gio=yes | 27 | -#include "fpu/softfloat-types.h" |
27 | gio_cflags=$($pkg_config --cflags gio-2.0) | 28 | - |
28 | gio_libs=$($pkg_config --libs gio-2.0) | 29 | #ifdef CONFIG_MACHINE_BSWAP_H |
29 | gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0) | 30 | # include <sys/endian.h> |
30 | if [ ! -x "$gdbus_codegen" ]; then | 31 | # include <machine/bswap.h> |
31 | gdbus_codegen= | 32 | @@ -XXX,XX +XXX,XX @@ |
32 | fi | 33 | # include <endian.h> |
33 | + # Check that the libraries actually work -- Ubuntu 18.04 ships | 34 | #elif defined(CONFIG_BYTESWAP_H) |
34 | + # with pkg-config --static --libs data for gio-2.0 that is missing | 35 | # include <byteswap.h> |
35 | + # -lblkid and will give a link error. | 36 | +#define BSWAP_FROM_BYTESWAP |
36 | + write_c_skeleton | 37 | +# else |
37 | + if compile_prog "" "gio_libs" ; then | 38 | +#define BSWAP_FROM_FALLBACKS |
38 | + gio=yes | 39 | +#endif /* ! CONFIG_MACHINE_BSWAP_H */ |
39 | + else | 40 | |
40 | + gio=no | 41 | +#ifdef __cplusplus |
41 | + fi | 42 | +extern "C" { |
42 | else | 43 | +#endif |
43 | gio=no | 44 | + |
44 | fi | 45 | +#include "fpu/softfloat-types.h" |
46 | + | ||
47 | +#ifdef BSWAP_FROM_BYTESWAP | ||
48 | static inline uint16_t bswap16(uint16_t x) | ||
49 | { | ||
50 | return bswap_16(x); | ||
51 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t bswap64(uint64_t x) | ||
52 | { | ||
53 | return bswap_64(x); | ||
54 | } | ||
55 | -# else | ||
56 | +#endif | ||
57 | + | ||
58 | +#ifdef BSWAP_FROM_FALLBACKS | ||
59 | static inline uint16_t bswap16(uint16_t x) | ||
60 | { | ||
61 | return (((x & 0x00ff) << 8) | | ||
62 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t bswap64(uint64_t x) | ||
63 | ((x & 0x00ff000000000000ULL) >> 40) | | ||
64 | ((x & 0xff00000000000000ULL) >> 56)); | ||
65 | } | ||
66 | -#endif /* ! CONFIG_MACHINE_BSWAP_H */ | ||
67 | +#endif | ||
68 | + | ||
69 | +#undef BSWAP_FROM_BYTESWAP | ||
70 | +#undef BSWAP_FROM_FALLBACKS | ||
71 | |||
72 | static inline void bswap16s(uint16_t *s) | ||
73 | { | ||
74 | @@ -XXX,XX +XXX,XX @@ DO_STN_LDN_P(be) | ||
75 | #undef le_bswaps | ||
76 | #undef be_bswaps | ||
77 | |||
78 | +#ifdef __cplusplus | ||
79 | +} | ||
80 | +#endif | ||
81 | + | ||
82 | #endif /* BSWAP_H */ | ||
45 | -- | 83 | -- |
46 | 2.20.1 | 84 | 2.20.1 |
47 | 85 | ||
48 | 86 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Make dis-asm.h handle being included outside an 'extern "C"' block; |
---|---|---|---|
2 | this allows us to remove the 'extern "C"' blocks that our two C++ | ||
3 | files that include it are using. | ||
2 | 4 | ||
3 | Use the BIT_ULL() macro to ensure we use 64-bit arithmetic. | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | This fixes the following Coverity issue (OVERFLOW_BEFORE_WIDEN): | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | --- | ||
8 | include/disas/dis-asm.h | 12 ++++++++++-- | ||
9 | disas/arm-a64.cc | 2 -- | ||
10 | disas/nanomips.cpp | 2 -- | ||
11 | 3 files changed, 10 insertions(+), 6 deletions(-) | ||
5 | 12 | ||
6 | CID 1432363 (#1 of 1): Unintentional integer overflow: | 13 | diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h |
7 | |||
8 | overflow_before_widen: | ||
9 | Potentially overflowing expression 1 << scale with type int | ||
10 | (32 bits, signed) is evaluated using 32-bit arithmetic, and | ||
11 | then used in a context that expects an expression of type | ||
12 | hwaddr (64 bits, unsigned). | ||
13 | |||
14 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
15 | Acked-by: Eric Auger <eric.auger@redhat.com> | ||
16 | Message-id: 20201030144617.1535064-1-philmd@redhat.com | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | ||
20 | hw/arm/smmuv3.c | 3 ++- | ||
21 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
22 | |||
23 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
24 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/arm/smmuv3.c | 15 | --- a/include/disas/dis-asm.h |
26 | +++ b/hw/arm/smmuv3.c | 16 | +++ b/include/disas/dis-asm.h |
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | #ifndef DISAS_DIS_ASM_H | ||
19 | #define DISAS_DIS_ASM_H | ||
20 | |||
21 | +#include "qemu/bswap.h" | ||
22 | + | ||
23 | +#ifdef __cplusplus | ||
24 | +extern "C" { | ||
25 | +#endif | ||
26 | + | ||
27 | typedef void *PTR; | ||
28 | typedef uint64_t bfd_vma; | ||
29 | typedef int64_t bfd_signed_vma; | ||
30 | @@ -XXX,XX +XXX,XX @@ bool cap_disas_plugin(disassemble_info *info, uint64_t pc, size_t size); | ||
31 | |||
32 | /* from libbfd */ | ||
33 | |||
34 | -#include "qemu/bswap.h" | ||
35 | - | ||
36 | static inline bfd_vma bfd_getl64(const bfd_byte *addr) | ||
37 | { | ||
38 | return ldq_le_p(addr); | ||
39 | @@ -XXX,XX +XXX,XX @@ static inline bfd_vma bfd_getb16(const bfd_byte *addr) | ||
40 | |||
41 | typedef bool bfd_boolean; | ||
42 | |||
43 | +#ifdef __cplusplus | ||
44 | +} | ||
45 | +#endif | ||
46 | + | ||
47 | #endif /* DISAS_DIS_ASM_H */ | ||
48 | diff --git a/disas/arm-a64.cc b/disas/arm-a64.cc | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/disas/arm-a64.cc | ||
51 | +++ b/disas/arm-a64.cc | ||
27 | @@ -XXX,XX +XXX,XX @@ | 52 | @@ -XXX,XX +XXX,XX @@ |
28 | */ | 53 | */ |
29 | 54 | ||
30 | #include "qemu/osdep.h" | 55 | #include "qemu/osdep.h" |
31 | +#include "qemu/bitops.h" | 56 | -extern "C" { |
32 | #include "hw/irq.h" | 57 | #include "disas/dis-asm.h" |
33 | #include "hw/sysbus.h" | 58 | -} |
34 | #include "migration/vmstate.h" | 59 | |
35 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | 60 | #include "vixl/a64/disasm-a64.h" |
36 | scale = CMD_SCALE(cmd); | 61 | |
37 | num = CMD_NUM(cmd); | 62 | diff --git a/disas/nanomips.cpp b/disas/nanomips.cpp |
38 | ttl = CMD_TTL(cmd); | 63 | index XXXXXXX..XXXXXXX 100644 |
39 | - num_pages = (num + 1) * (1 << (scale)); | 64 | --- a/disas/nanomips.cpp |
40 | + num_pages = (num + 1) * BIT_ULL(scale); | 65 | +++ b/disas/nanomips.cpp |
41 | } | 66 | @@ -XXX,XX +XXX,XX @@ |
42 | 67 | */ | |
43 | if (type == SMMU_CMD_TLBI_NH_VA) { | 68 | |
69 | #include "qemu/osdep.h" | ||
70 | -extern "C" { | ||
71 | #include "disas/dis-asm.h" | ||
72 | -} | ||
73 | |||
74 | #include <cstring> | ||
75 | #include <stdexcept> | ||
44 | -- | 76 | -- |
45 | 2.20.1 | 77 | 2.20.1 |
46 | 78 | ||
47 | 79 | diff view generated by jsdifflib |
1 | From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | HCR should be applied when NS is set, not when it is cleared. | 3 | The i.MX25 PDK board has 2 banks for SDRAM, each can |
4 | address up to 256 MiB. So the total RAM usable for this | ||
5 | board is 512M. When we ask for more we get a misleading | ||
6 | error message: | ||
4 | 7 | ||
5 | Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 8 | $ qemu-system-arm -M imx25-pdk -m 513M |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | qemu-system-arm: Invalid RAM size, should be 128 MiB |
10 | |||
11 | Update the error message to better match the reality: | ||
12 | |||
13 | $ qemu-system-arm -M imx25-pdk -m 513M | ||
14 | qemu-system-arm: RAM size more than 512 MiB is not supported | ||
15 | |||
16 | Fixes: bf350daae02 ("arm/imx25_pdk: drop RAM size fixup") | ||
17 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
20 | Message-id: 20210407225608.1882855-1-f4bug@amsat.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 22 | --- |
9 | target/arm/helper.c | 5 ++--- | 23 | hw/arm/imx25_pdk.c | 5 ++--- |
10 | 1 file changed, 2 insertions(+), 3 deletions(-) | 24 | 1 file changed, 2 insertions(+), 3 deletions(-) |
11 | 25 | ||
12 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 26 | diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c |
13 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/helper.c | 28 | --- a/hw/arm/imx25_pdk.c |
15 | +++ b/target/arm/helper.c | 29 | +++ b/hw/arm/imx25_pdk.c |
16 | @@ -XXX,XX +XXX,XX @@ static void tlbimvaa_is_write(CPUARMState *env, const ARMCPRegInfo *ri, | 30 | @@ -XXX,XX +XXX,XX @@ static struct arm_boot_info imx25_pdk_binfo; |
17 | 31 | ||
18 | /* | 32 | static void imx25_pdk_init(MachineState *machine) |
19 | * Non-IS variants of TLB operations are upgraded to | ||
20 | - * IS versions if we are at NS EL1 and HCR_EL2.FB is set to | ||
21 | + * IS versions if we are at EL1 and HCR_EL2.FB is effectively set to | ||
22 | * force broadcast of these operations. | ||
23 | */ | ||
24 | static bool tlb_force_broadcast(CPUARMState *env) | ||
25 | { | 33 | { |
26 | - return (env->cp15.hcr_el2 & HCR_FB) && | 34 | - MachineClass *mc = MACHINE_GET_CLASS(machine); |
27 | - arm_current_el(env) == 1 && arm_is_secure_below_el3(env); | 35 | IMX25PDK *s = g_new0(IMX25PDK, 1); |
28 | + return arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_FB); | 36 | unsigned int ram_size; |
29 | } | 37 | unsigned int alias_offset; |
30 | 38 | @@ -XXX,XX +XXX,XX @@ static void imx25_pdk_init(MachineState *machine) | |
31 | static void tlbiall_write(CPUARMState *env, const ARMCPRegInfo *ri, | 39 | |
40 | /* We need to initialize our memory */ | ||
41 | if (machine->ram_size > (FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE)) { | ||
42 | - char *sz = size_to_str(mc->default_ram_size); | ||
43 | - error_report("Invalid RAM size, should be %s", sz); | ||
44 | + char *sz = size_to_str(FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE); | ||
45 | + error_report("RAM size more than %s is not supported", sz); | ||
46 | g_free(sz); | ||
47 | exit(EXIT_FAILURE); | ||
48 | } | ||
32 | -- | 49 | -- |
33 | 2.20.1 | 50 | 2.20.1 |
34 | 51 | ||
35 | 52 | diff view generated by jsdifflib |
1 | From: AlexChen <alex.chen@huawei.com> | 1 | The MPS2 SCC device doesn't have any documentation of its properties; |
---|---|---|---|
2 | add a "QEMU interface" format comment describing them. | ||
2 | 3 | ||
3 | In exynos4210_fimd_update(), the pointer s is dereferinced before | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | being check if it is valid, which may lead to NULL pointer dereference. | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | So move the assignment to global_width after checking that the s is valid. | 6 | Message-id: 20210504120912.23094-2-peter.maydell@linaro.org |
7 | --- | ||
8 | include/hw/misc/mps2-scc.h | 12 ++++++++++++ | ||
9 | 1 file changed, 12 insertions(+) | ||
6 | 10 | ||
7 | Reported-by: Euler Robot <euler.robot@huawei.com> | 11 | diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h |
8 | Signed-off-by: Alex Chen <alex.chen@huawei.com> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 5F9F8D88.9030102@huawei.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/display/exynos4210_fimd.c | 4 +++- | ||
14 | 1 file changed, 3 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/display/exynos4210_fimd.c | 13 | --- a/include/hw/misc/mps2-scc.h |
19 | +++ b/hw/display/exynos4210_fimd.c | 14 | +++ b/include/hw/misc/mps2-scc.h |
20 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_fimd_update(void *opaque) | 15 | @@ -XXX,XX +XXX,XX @@ |
21 | bool blend = false; | 16 | * (at your option) any later version. |
22 | uint8_t *host_fb_addr; | 17 | */ |
23 | bool is_dirty = false; | 18 | |
24 | - const int global_width = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1; | 19 | +/* |
25 | + int global_width; | 20 | + * This is a model of the Serial Communication Controller (SCC) |
26 | 21 | + * block found in most MPS FPGA images. | |
27 | if (!s || !s->console || !s->enabled || | 22 | + * |
28 | surface_bits_per_pixel(qemu_console_surface(s->console)) == 0) { | 23 | + * QEMU interface: |
29 | return; | 24 | + * + sysbus MMIO region 0: the register bank |
30 | } | 25 | + * + QOM property "scc-cfg4": value of the read-only CFG4 register |
31 | + | 26 | + * + QOM property "scc-aid": value of the read-only SCC_AID register |
32 | + global_width = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1; | 27 | + * + QOM property "scc-id": value of the read-only SCC_ID register |
33 | exynos4210_update_resolution(s); | 28 | + * + QOM property array "oscclk": reset values of the OSCCLK registers |
34 | surface = qemu_console_surface(s->console); | 29 | + * (which are accessed via the SYS_CFG channel provided by this device) |
30 | + */ | ||
31 | #ifndef MPS2_SCC_H | ||
32 | #define MPS2_SCC_H | ||
35 | 33 | ||
36 | -- | 34 | -- |
37 | 2.20.1 | 35 | 2.20.1 |
38 | 36 | ||
39 | 37 | diff view generated by jsdifflib |
1 | The helper functions for performing the udot/sdot operations against | 1 | On some boards, SCC config register CFG0 bit 0 controls whether |
---|---|---|---|
2 | a scalar were not using an address-swizzling macro when converting | 2 | parts of the board memory map are remapped. Support this with: |
3 | the index of the scalar element into a pointer into the vm array. | 3 | * a device property scc-cfg0 so the board can specify the |
4 | This had no effect on little-endian hosts but meant we generated | 4 | initial value of the CFG0 register |
5 | incorrect results on big-endian hosts. | 5 | * an outbound GPIO line which tracks bit 0 and which the board |
6 | 6 | can wire up to provide the remapping | |
7 | For these insns, the index is indexing over group of 4 8-bit values, | ||
8 | so 32 bits per indexed entity, and H4() is therefore what we want. | ||
9 | (For Neon the only possible input indexes are 0 and 1.) | ||
10 | 7 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
14 | Message-id: 20201028191712.4910-3-peter.maydell@linaro.org | 11 | Message-id: 20210504120912.23094-3-peter.maydell@linaro.org |
15 | --- | 12 | --- |
16 | target/arm/vec_helper.c | 4 ++-- | 13 | include/hw/misc/mps2-scc.h | 9 +++++++++ |
17 | 1 file changed, 2 insertions(+), 2 deletions(-) | 14 | hw/misc/mps2-scc.c | 13 ++++++++++--- |
15 | 2 files changed, 19 insertions(+), 3 deletions(-) | ||
18 | 16 | ||
19 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | 17 | diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h |
20 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/vec_helper.c | 19 | --- a/include/hw/misc/mps2-scc.h |
22 | +++ b/target/arm/vec_helper.c | 20 | +++ b/include/hw/misc/mps2-scc.h |
23 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_sdot_idx_b)(void *vd, void *vn, void *vm, uint32_t desc) | 21 | @@ -XXX,XX +XXX,XX @@ |
24 | intptr_t index = simd_data(desc); | 22 | * + QOM property "scc-cfg4": value of the read-only CFG4 register |
25 | uint32_t *d = vd; | 23 | * + QOM property "scc-aid": value of the read-only SCC_AID register |
26 | int8_t *n = vn; | 24 | * + QOM property "scc-id": value of the read-only SCC_ID register |
27 | - int8_t *m_indexed = (int8_t *)vm + index * 4; | 25 | + * + QOM property "scc-cfg0": reset value of the CFG0 register |
28 | + int8_t *m_indexed = (int8_t *)vm + H4(index) * 4; | 26 | * + QOM property array "oscclk": reset values of the OSCCLK registers |
29 | 27 | * (which are accessed via the SYS_CFG channel provided by this device) | |
30 | /* Notice the special case of opr_sz == 8, from aa64/aa32 advsimd. | 28 | + * + named GPIO output "remap": this tracks the value of CFG0 register |
31 | * Otherwise opr_sz is a multiple of 16. | 29 | + * bit 0. Boards where this bit controls memory remapping should |
32 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_udot_idx_b)(void *vd, void *vn, void *vm, uint32_t desc) | 30 | + * connect this GPIO line to a function performing that mapping. |
33 | intptr_t index = simd_data(desc); | 31 | + * Boards where bit 0 has no special function should leave the GPIO |
34 | uint32_t *d = vd; | 32 | + * output disconnected. |
35 | uint8_t *n = vn; | 33 | */ |
36 | - uint8_t *m_indexed = (uint8_t *)vm + index * 4; | 34 | #ifndef MPS2_SCC_H |
37 | + uint8_t *m_indexed = (uint8_t *)vm + H4(index) * 4; | 35 | #define MPS2_SCC_H |
38 | 36 | @@ -XXX,XX +XXX,XX @@ struct MPS2SCC { | |
39 | /* Notice the special case of opr_sz == 8, from aa64/aa32 advsimd. | 37 | uint32_t num_oscclk; |
40 | * Otherwise opr_sz is a multiple of 16. | 38 | uint32_t *oscclk; |
39 | uint32_t *oscclk_reset; | ||
40 | + uint32_t cfg0_reset; | ||
41 | + | ||
42 | + qemu_irq remap; | ||
43 | }; | ||
44 | |||
45 | #endif | ||
46 | diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/misc/mps2-scc.c | ||
49 | +++ b/hw/misc/mps2-scc.c | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | #include "qemu/bitops.h" | ||
52 | #include "trace.h" | ||
53 | #include "hw/sysbus.h" | ||
54 | +#include "hw/irq.h" | ||
55 | #include "migration/vmstate.h" | ||
56 | #include "hw/registerfields.h" | ||
57 | #include "hw/misc/mps2-scc.h" | ||
58 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value, | ||
59 | switch (offset) { | ||
60 | case A_CFG0: | ||
61 | /* | ||
62 | - * TODO on some boards bit 0 controls RAM remapping; | ||
63 | - * on others bit 1 is CPU_WAIT. | ||
64 | + * On some boards bit 0 controls board-specific remapping; | ||
65 | + * we always reflect bit 0 in the 'remap' GPIO output line, | ||
66 | + * and let the board wire it up or not as it chooses. | ||
67 | + * TODO on some boards bit 1 is CPU_WAIT. | ||
68 | */ | ||
69 | s->cfg0 = value; | ||
70 | + qemu_set_irq(s->remap, s->cfg0 & 1); | ||
71 | break; | ||
72 | case A_CFG1: | ||
73 | s->cfg1 = value; | ||
74 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_reset(DeviceState *dev) | ||
75 | int i; | ||
76 | |||
77 | trace_mps2_scc_reset(); | ||
78 | - s->cfg0 = 0; | ||
79 | + s->cfg0 = s->cfg0_reset; | ||
80 | s->cfg1 = 0; | ||
81 | s->cfg2 = 0; | ||
82 | s->cfg5 = 0; | ||
83 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_init(Object *obj) | ||
84 | |||
85 | memory_region_init_io(&s->iomem, obj, &mps2_scc_ops, s, "mps2-scc", 0x1000); | ||
86 | sysbus_init_mmio(sbd, &s->iomem); | ||
87 | + qdev_init_gpio_out_named(DEVICE(obj), &s->remap, "remap", 1); | ||
88 | } | ||
89 | |||
90 | static void mps2_scc_realize(DeviceState *dev, Error **errp) | ||
91 | @@ -XXX,XX +XXX,XX @@ static Property mps2_scc_properties[] = { | ||
92 | DEFINE_PROP_UINT32("scc-cfg4", MPS2SCC, cfg4, 0), | ||
93 | DEFINE_PROP_UINT32("scc-aid", MPS2SCC, aid, 0), | ||
94 | DEFINE_PROP_UINT32("scc-id", MPS2SCC, id, 0), | ||
95 | + /* Reset value for CFG0 register */ | ||
96 | + DEFINE_PROP_UINT32("scc-cfg0", MPS2SCC, cfg0_reset, 0), | ||
97 | /* | ||
98 | * These are the initial settings for the source clocks on the board. | ||
99 | * In hardware they can be configured via a config file read by the | ||
41 | -- | 100 | -- |
42 | 2.20.1 | 101 | 2.20.1 |
43 | 102 | ||
44 | 103 | diff view generated by jsdifflib |
1 | In the neon_padd/pmax/pmin helpers for float16, a cut-and-paste error | 1 | The AN524 FPGA image supports two memory maps, which differ in where |
---|---|---|---|
2 | meant we were using the H4() address swizzler macro rather than the | 2 | the QSPI and BRAM are. In the default map, the BRAM is at |
3 | H2() which is required for 2-byte data. This had no effect on | 3 | 0x0000_0000, and the QSPI at 0x2800_0000. In the second map, they |
4 | little-endian hosts but meant we put the result data into the | 4 | are the other way around. |
5 | destination Dreg in the wrong order on big-endian hosts. | 5 | |
6 | In hardware, the initial mapping can be selected by the user by | ||
7 | writing either "REMAP: BRAM" (the default) or "REMAP: QSPI" in the | ||
8 | board configuration file. The board config file is acted on by the | ||
9 | "Motherboard Configuration Controller", which is an entirely separate | ||
10 | microcontroller on the dev board but outside the FPGA. | ||
11 | |||
12 | The guest can also dynamically change the mapping via the SCC | ||
13 | CFG_REG0 register. | ||
14 | |||
15 | Implement this functionality for QEMU, using a machine property | ||
16 | "remap" with valid values "BRAM" and "QSPI" to allow the user to set | ||
17 | the initial mapping, in the same way they can on the FPGA, and | ||
18 | wiring up the bit from the SCC register to also switch the mapping. | ||
6 | 19 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 22 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
10 | Message-id: 20201028191712.4910-2-peter.maydell@linaro.org | 23 | Message-id: 20210504120912.23094-4-peter.maydell@linaro.org |
11 | --- | 24 | --- |
12 | target/arm/vec_helper.c | 8 ++++---- | 25 | docs/system/arm/mps2.rst | 10 ++++ |
13 | 1 file changed, 4 insertions(+), 4 deletions(-) | 26 | hw/arm/mps2-tz.c | 108 ++++++++++++++++++++++++++++++++++++++- |
14 | 27 | 2 files changed, 117 insertions(+), 1 deletion(-) | |
15 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | 28 | |
29 | diff --git a/docs/system/arm/mps2.rst b/docs/system/arm/mps2.rst | ||
16 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/vec_helper.c | 31 | --- a/docs/system/arm/mps2.rst |
18 | +++ b/target/arm/vec_helper.c | 32 | +++ b/docs/system/arm/mps2.rst |
19 | @@ -XXX,XX +XXX,XX @@ DO_ABA(gvec_uaba_d, uint64_t) | 33 | @@ -XXX,XX +XXX,XX @@ Differences between QEMU and real hardware: |
20 | r2 = float16_##OP(m[H2(0)], m[H2(1)], fpst); \ | 34 | flash, but only as simple ROM, so attempting to rewrite the flash |
21 | r3 = float16_##OP(m[H2(2)], m[H2(3)], fpst); \ | 35 | from the guest will fail |
22 | \ | 36 | - QEMU does not model the USB controller in MPS3 boards |
23 | - d[H4(0)] = r0; \ | 37 | + |
24 | - d[H4(1)] = r1; \ | 38 | +Machine-specific options |
25 | - d[H4(2)] = r2; \ | 39 | +"""""""""""""""""""""""" |
26 | - d[H4(3)] = r3; \ | 40 | + |
27 | + d[H2(0)] = r0; \ | 41 | +The following machine-specific options are supported: |
28 | + d[H2(1)] = r1; \ | 42 | + |
29 | + d[H2(2)] = r2; \ | 43 | +remap |
30 | + d[H2(3)] = r3; \ | 44 | + Supported for ``mps3-an524`` only. |
45 | + Set ``BRAM``/``QSPI`` to select the initial memory mapping. The | ||
46 | + default is ``BRAM``. | ||
47 | diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/arm/mps2-tz.c | ||
50 | +++ b/hw/arm/mps2-tz.c | ||
51 | @@ -XXX,XX +XXX,XX @@ | ||
52 | #include "hw/boards.h" | ||
53 | #include "exec/address-spaces.h" | ||
54 | #include "sysemu/sysemu.h" | ||
55 | +#include "sysemu/reset.h" | ||
56 | #include "hw/misc/unimp.h" | ||
57 | #include "hw/char/cmsdk-apb-uart.h" | ||
58 | #include "hw/timer/cmsdk-apb-timer.h" | ||
59 | @@ -XXX,XX +XXX,XX @@ | ||
60 | #include "hw/core/split-irq.h" | ||
61 | #include "hw/qdev-clock.h" | ||
62 | #include "qom/object.h" | ||
63 | +#include "hw/irq.h" | ||
64 | |||
65 | #define MPS2TZ_NUMIRQ_MAX 96 | ||
66 | #define MPS2TZ_RAM_MAX 5 | ||
67 | @@ -XXX,XX +XXX,XX @@ struct MPS2TZMachineState { | ||
68 | SplitIRQ cpu_irq_splitter[MPS2TZ_NUMIRQ_MAX]; | ||
69 | Clock *sysclk; | ||
70 | Clock *s32kclk; | ||
71 | + | ||
72 | + bool remap; | ||
73 | + qemu_irq remap_irq; | ||
74 | }; | ||
75 | |||
76 | #define TYPE_MPS2TZ_MACHINE "mps2tz" | ||
77 | @@ -XXX,XX +XXX,XX @@ static const RAMInfo an505_raminfo[] = { { | ||
78 | }, | ||
79 | }; | ||
80 | |||
81 | +/* | ||
82 | + * Note that the addresses and MPC numbering here should match up | ||
83 | + * with those used in remap_memory(), which can swap the BRAM and QSPI. | ||
84 | + */ | ||
85 | static const RAMInfo an524_raminfo[] = { { | ||
86 | .name = "bram", | ||
87 | .base = 0x00000000, | ||
88 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_scc(MPS2TZMachineState *mms, void *opaque, | ||
89 | |||
90 | object_initialize_child(OBJECT(mms), "scc", scc, TYPE_MPS2_SCC); | ||
91 | sccdev = DEVICE(scc); | ||
92 | + qdev_prop_set_uint32(sccdev, "scc-cfg0", mms->remap ? 1 : 0); | ||
93 | qdev_prop_set_uint32(sccdev, "scc-cfg4", 0x2); | ||
94 | qdev_prop_set_uint32(sccdev, "scc-aid", 0x00200008); | ||
95 | qdev_prop_set_uint32(sccdev, "scc-id", mmc->scc_id); | ||
96 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_mpc(MPS2TZMachineState *mms, void *opaque, | ||
97 | return sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 0); | ||
98 | } | ||
99 | |||
100 | +static hwaddr boot_mem_base(MPS2TZMachineState *mms) | ||
101 | +{ | ||
102 | + /* | ||
103 | + * Return the canonical address of the block which will be mapped | ||
104 | + * at address 0x0 (i.e. where the vector table is). | ||
105 | + * This is usually 0, but if the AN524 alternate memory map is | ||
106 | + * enabled it will be the base address of the QSPI block. | ||
107 | + */ | ||
108 | + return mms->remap ? 0x28000000 : 0; | ||
109 | +} | ||
110 | + | ||
111 | +static void remap_memory(MPS2TZMachineState *mms, int map) | ||
112 | +{ | ||
113 | + /* | ||
114 | + * Remap the memory for the AN524. 'map' is the value of | ||
115 | + * SCC CFG_REG0 bit 0, i.e. 0 for the default map and 1 | ||
116 | + * for the "option 1" mapping where QSPI is at address 0. | ||
117 | + * | ||
118 | + * Effectively we need to swap around the "upstream" ends of | ||
119 | + * MPC 0 and MPC 1. | ||
120 | + */ | ||
121 | + MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | ||
122 | + int i; | ||
123 | + | ||
124 | + if (mmc->fpga_type != FPGA_AN524) { | ||
125 | + return; | ||
126 | + } | ||
127 | + | ||
128 | + memory_region_transaction_begin(); | ||
129 | + for (i = 0; i < 2; i++) { | ||
130 | + TZMPC *mpc = &mms->mpc[i]; | ||
131 | + MemoryRegion *upstream = sysbus_mmio_get_region(SYS_BUS_DEVICE(mpc), 1); | ||
132 | + hwaddr addr = (i ^ map) ? 0x28000000 : 0; | ||
133 | + | ||
134 | + memory_region_set_address(upstream, addr); | ||
135 | + } | ||
136 | + memory_region_transaction_commit(); | ||
137 | +} | ||
138 | + | ||
139 | +static void remap_irq_fn(void *opaque, int n, int level) | ||
140 | +{ | ||
141 | + MPS2TZMachineState *mms = opaque; | ||
142 | + | ||
143 | + remap_memory(mms, level); | ||
144 | +} | ||
145 | + | ||
146 | static MemoryRegion *make_dma(MPS2TZMachineState *mms, void *opaque, | ||
147 | const char *name, hwaddr size, | ||
148 | const int *irqs) | ||
149 | @@ -XXX,XX +XXX,XX @@ static uint32_t boot_ram_size(MPS2TZMachineState *mms) | ||
150 | MPS2TZMachineClass *mmc = MPS2TZ_MACHINE_GET_CLASS(mms); | ||
151 | |||
152 | for (p = mmc->raminfo; p->name; p++) { | ||
153 | - if (p->base == 0) { | ||
154 | + if (p->base == boot_mem_base(mms)) { | ||
155 | return p->size; | ||
156 | } | ||
31 | } | 157 | } |
32 | 158 | @@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine) | |
33 | DO_NEON_PAIRWISE(neon_padd, add) | 159 | |
160 | create_non_mpc_ram(mms); | ||
161 | |||
162 | + if (mmc->fpga_type == FPGA_AN524) { | ||
163 | + /* | ||
164 | + * Connect the line from the SCC so that we can remap when the | ||
165 | + * guest updates that register. | ||
166 | + */ | ||
167 | + mms->remap_irq = qemu_allocate_irq(remap_irq_fn, mms, 0); | ||
168 | + qdev_connect_gpio_out_named(DEVICE(&mms->scc), "remap", 0, | ||
169 | + mms->remap_irq); | ||
170 | + } | ||
171 | + | ||
172 | armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename, | ||
173 | boot_ram_size(mms)); | ||
174 | } | ||
175 | @@ -XXX,XX +XXX,XX @@ static void mps2_tz_idau_check(IDAUInterface *ii, uint32_t address, | ||
176 | *iregion = region; | ||
177 | } | ||
178 | |||
179 | +static char *mps2_get_remap(Object *obj, Error **errp) | ||
180 | +{ | ||
181 | + MPS2TZMachineState *mms = MPS2TZ_MACHINE(obj); | ||
182 | + const char *val = mms->remap ? "QSPI" : "BRAM"; | ||
183 | + return g_strdup(val); | ||
184 | +} | ||
185 | + | ||
186 | +static void mps2_set_remap(Object *obj, const char *value, Error **errp) | ||
187 | +{ | ||
188 | + MPS2TZMachineState *mms = MPS2TZ_MACHINE(obj); | ||
189 | + | ||
190 | + if (!strcmp(value, "BRAM")) { | ||
191 | + mms->remap = false; | ||
192 | + } else if (!strcmp(value, "QSPI")) { | ||
193 | + mms->remap = true; | ||
194 | + } else { | ||
195 | + error_setg(errp, "Invalid remap value"); | ||
196 | + error_append_hint(errp, "Valid values are BRAM and QSPI.\n"); | ||
197 | + } | ||
198 | +} | ||
199 | + | ||
200 | +static void mps2_machine_reset(MachineState *machine) | ||
201 | +{ | ||
202 | + MPS2TZMachineState *mms = MPS2TZ_MACHINE(machine); | ||
203 | + | ||
204 | + /* | ||
205 | + * Set the initial memory mapping before triggering the reset of | ||
206 | + * the rest of the system, so that the guest image loader and CPU | ||
207 | + * reset see the correct mapping. | ||
208 | + */ | ||
209 | + remap_memory(mms, mms->remap); | ||
210 | + qemu_devices_reset(); | ||
211 | +} | ||
212 | + | ||
213 | static void mps2tz_class_init(ObjectClass *oc, void *data) | ||
214 | { | ||
215 | MachineClass *mc = MACHINE_CLASS(oc); | ||
216 | IDAUInterfaceClass *iic = IDAU_INTERFACE_CLASS(oc); | ||
217 | |||
218 | mc->init = mps2tz_common_init; | ||
219 | + mc->reset = mps2_machine_reset; | ||
220 | iic->check = mps2_tz_idau_check; | ||
221 | } | ||
222 | |||
223 | @@ -XXX,XX +XXX,XX @@ static void mps3tz_an524_class_init(ObjectClass *oc, void *data) | ||
224 | mmc->raminfo = an524_raminfo; | ||
225 | mmc->armsse_type = TYPE_SSE200; | ||
226 | mps2tz_set_default_ram_info(mmc); | ||
227 | + | ||
228 | + object_class_property_add_str(oc, "remap", mps2_get_remap, mps2_set_remap); | ||
229 | + object_class_property_set_description(oc, "remap", | ||
230 | + "Set memory mapping. Valid values " | ||
231 | + "are BRAM (default) and QSPI."); | ||
232 | } | ||
233 | |||
234 | static void mps3tz_an547_class_init(ObjectClass *oc, void *data) | ||
34 | -- | 235 | -- |
35 | 2.20.1 | 236 | 2.20.1 |
36 | 237 | ||
37 | 238 | diff view generated by jsdifflib |
1 | From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 1 | From: Guenter Roeck <linux@roeck-us.net> |
---|---|---|---|
2 | 2 | ||
3 | When booting a CPU with EL3 using the -kernel flag, set up CPTR_EL3 so | 3 | Commit dfc388797cc4 ("hw/arm: xlnx: Set all boards' GEM 'phy-addr' |
4 | that SVE will not trap to EL3. | 4 | property value to 23") configured the PHY address for xilinx-zynq-a9 |
5 | to 23. When trying to boot xilinx-zynq-a9 with zynq-zc702.dtb or | ||
6 | zynq-zc706.dtb, this results in the following error message when | ||
7 | trying to use the Ethernet interface. | ||
5 | 8 | ||
6 | Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 9 | macb e000b000.ethernet eth0: Could not attach PHY (-19) |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | |
8 | Message-id: 20201030151541.11976-1-remi@remlab.net | 11 | The devicetree files for ZC702 and ZC706 configure PHY address 7. The |
12 | documentation for the ZC702 and ZC706 evaluation boards suggest that the | ||
13 | PHY address is 7, not 23. Other boards use PHY address 0, 1, 3, or 7. | ||
14 | I was unable to find a documentation or a devicetree file suggesting | ||
15 | or using PHY address 23. The Ethernet interface starts working with | ||
16 | zynq-zc702.dtb and zynq-zc706.dtb when setting the PHY address to 7, | ||
17 | so let's use it. | ||
18 | |||
19 | Cc: Bin Meng <bin.meng@windriver.com> | ||
20 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
21 | Reviewed-by: Bin Meng <bmeng.cn@gmail.com> | ||
22 | Acked-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | ||
23 | Message-id: 20210504124140.1100346-1-linux@roeck-us.net | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 25 | --- |
11 | hw/arm/boot.c | 3 +++ | 26 | hw/arm/xilinx_zynq.c | 2 +- |
12 | 1 file changed, 3 insertions(+) | 27 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 28 | ||
14 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 29 | diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c |
15 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/boot.c | 31 | --- a/hw/arm/xilinx_zynq.c |
17 | +++ b/hw/arm/boot.c | 32 | +++ b/hw/arm/xilinx_zynq.c |
18 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | 33 | @@ -XXX,XX +XXX,XX @@ static void gem_init(NICInfo *nd, uint32_t base, qemu_irq irq) |
19 | if (cpu_isar_feature(aa64_mte, cpu)) { | 34 | qemu_check_nic_model(nd, TYPE_CADENCE_GEM); |
20 | env->cp15.scr_el3 |= SCR_ATA; | 35 | qdev_set_nic_properties(dev, nd); |
21 | } | 36 | } |
22 | + if (cpu_isar_feature(aa64_sve, cpu)) { | 37 | - object_property_set_int(OBJECT(dev), "phy-addr", 23, &error_abort); |
23 | + env->cp15.cptr_el[3] |= CPTR_EZ; | 38 | + object_property_set_int(OBJECT(dev), "phy-addr", 7, &error_abort); |
24 | + } | 39 | s = SYS_BUS_DEVICE(dev); |
25 | /* AArch64 kernels never boot in secure mode */ | 40 | sysbus_realize_and_unref(s, &error_fatal); |
26 | assert(!info->secure_boot); | 41 | sysbus_mmio_map(s, 0, base); |
27 | /* This hook is only supported for AArch32 currently: | ||
28 | -- | 42 | -- |
29 | 2.20.1 | 43 | 2.20.1 |
30 | 44 | ||
31 | 45 | diff view generated by jsdifflib |