1 | Small pile of bug fixes for rc1. I've included my patches to get | 1 | Hi; this mostly contains the first slice of A64 decodetree |
---|---|---|---|
2 | our docs building with Sphinx 3, just for convenience... | 2 | patches, plus some other minor pieces. It also has the |
3 | enablement of MTE for KVM guests. | ||
3 | 4 | ||
5 | thanks | ||
4 | -- PMM | 6 | -- PMM |
5 | 7 | ||
6 | The following changes since commit b149dea55cce97cb226683d06af61984a1c11e96: | 8 | The following changes since commit d27e7c359330ba7020bdbed7ed2316cb4cf6ffc1: |
7 | 9 | ||
8 | Merge remote-tracking branch 'remotes/cschoenebeck/tags/pull-9p-20201102' into staging (2020-11-02 10:57:48 +0000) | 10 | qapi/parser: Drop two bad type hints for now (2023-05-17 10:18:33 -0700) |
9 | 11 | ||
10 | are available in the Git repository at: | 12 | are available in the Git repository at: |
11 | 13 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201102 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230518 |
13 | 15 | ||
14 | for you to fetch changes up to ffb4fbf90a2f63c9cb33e4bb9f854c79bf04ca4a: | 16 | for you to fetch changes up to 91608e2a44f36e79cb83f863b8a7bb57d2c98061: |
15 | 17 | ||
16 | tests/qtest/npcm7xx_rng-test: Disable randomness tests (2020-11-02 16:52:18 +0000) | 18 | docs: Convert u2f.txt to rST (2023-05-18 11:40:32 +0100) |
17 | 19 | ||
18 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
19 | target-arm queue: | 21 | target-arm queue: |
20 | * target/arm: Fix Neon emulation bugs on big-endian hosts | 22 | * Fix vd == vm overlap in sve_ldff1_z |
21 | * target/arm: fix handling of HCR.FB | 23 | * Add support for MTE with KVM guests |
22 | * target/arm: fix LORID_EL1 access check | 24 | * Add RAZ/WI handling for DBGDTR[TX|RX] |
23 | * disas/capstone: Fix monitor disassembly of >32 bytes | 25 | * Start of conversion of A64 decoder to decodetree |
24 | * hw/arm/smmuv3: Fix potential integer overflow (CID 1432363) | 26 | * Saturate L2CTLR_EL1 core count field rather than overflowing |
25 | * hw/arm/boot: fix SVE for EL3 direct kernel boot | 27 | * vexpress: Avoid trivial memory leak of 'flashalias' |
26 | * hw/display/omap_lcdc: Fix potential NULL pointer dereference | 28 | * sbsa-ref: switch default cpu core to Neoverse-N1 |
27 | * hw/display/exynos4210_fimd: Fix potential NULL pointer dereference | 29 | * sbsa-ref: use Bochs graphics card instead of VGA |
28 | * target/arm: Get correct MMU index for other-security-state | 30 | * MAINTAINERS: Add Marcin Juszkiewicz to sbsa-ref reviewer list |
29 | * configure: Test that gio libs from pkg-config work | 31 | * docs: Convert u2f.txt to rST |
30 | * hw/intc/arm_gicv3_cpuif: Make GIC maintenance interrupts work | ||
31 | * docs: Fix building with Sphinx 3 | ||
32 | * tests/qtest/npcm7xx_rng-test: Disable randomness tests | ||
33 | 32 | ||
34 | ---------------------------------------------------------------- | 33 | ---------------------------------------------------------------- |
35 | AlexChen (2): | 34 | Alex Bennée (1): |
36 | hw/display/omap_lcdc: Fix potential NULL pointer dereference | 35 | target/arm: add RAZ/WI handling for DBGDTR[TX|RX] |
37 | hw/display/exynos4210_fimd: Fix potential NULL pointer dereference | ||
38 | 36 | ||
39 | Peter Maydell (9): | 37 | Cornelia Huck (1): |
40 | target/arm: Fix float16 pairwise Neon ops on big-endian hosts | 38 | arm/kvm: add support for MTE |
41 | target/arm: Fix VUDOT/VSDOT (scalar) on big-endian hosts | ||
42 | disas/capstone: Fix monitor disassembly of >32 bytes | ||
43 | target/arm: Get correct MMU index for other-security-state | ||
44 | configure: Test that gio libs from pkg-config work | ||
45 | hw/intc/arm_gicv3_cpuif: Make GIC maintenance interrupts work | ||
46 | scripts/kerneldoc: For Sphinx 3 use c:macro for macros with arguments | ||
47 | qemu-option-trace.rst.inc: Don't use option:: markup | ||
48 | tests/qtest/npcm7xx_rng-test: Disable randomness tests | ||
49 | 39 | ||
50 | Philippe Mathieu-Daudé (1): | 40 | Marcin Juszkiewicz (3): |
51 | hw/arm/smmuv3: Fix potential integer overflow (CID 1432363) | 41 | sbsa-ref: switch default cpu core to Neoverse-N1 |
42 | Maintainers: add myself as reviewer for sbsa-ref | ||
43 | sbsa-ref: use Bochs graphics card instead of VGA | ||
52 | 44 | ||
53 | Richard Henderson (11): | 45 | Peter Maydell (14): |
54 | target/arm: Introduce neon_full_reg_offset | 46 | target/arm: Create decodetree skeleton for A64 |
55 | target/arm: Move neon_element_offset to translate.c | 47 | target/arm: Pull calls to disas_sve() and disas_sme() out of legacy decoder |
56 | target/arm: Use neon_element_offset in neon_load/store_reg | 48 | target/arm: Convert Extract instructions to decodetree |
57 | target/arm: Use neon_element_offset in vfp_reg_offset | 49 | target/arm: Convert unconditional branch immediate to decodetree |
58 | target/arm: Add read/write_neon_element32 | 50 | target/arm: Convert CBZ, CBNZ to decodetree |
59 | target/arm: Expand read/write_neon_element32 to all MemOp | 51 | target/arm: Convert TBZ, TBNZ to decodetree |
60 | target/arm: Rename neon_load_reg32 to vfp_load_reg32 | 52 | target/arm: Convert conditional branch insns to decodetree |
61 | target/arm: Add read/write_neon_element64 | 53 | target/arm: Convert BR, BLR, RET to decodetree |
62 | target/arm: Rename neon_load_reg64 to vfp_load_reg64 | 54 | target/arm: Convert BRA[AB]Z, BLR[AB]Z, RETA[AB] to decodetree |
63 | target/arm: Simplify do_long_3d and do_2scalar_long | 55 | target/arm: Convert BRAA, BRAB, BLRAA, BLRAB to decodetree |
64 | target/arm: Improve do_prewiden_3d | 56 | target/arm: Convert ERET, ERETAA, ERETAB to decodetree |
57 | target/arm: Saturate L2CTLR_EL1 core count field rather than overflowing | ||
58 | hw/arm/vexpress: Avoid trivial memory leak of 'flashalias' | ||
59 | docs: Convert u2f.txt to rST | ||
65 | 60 | ||
66 | Rémi Denis-Courmont (3): | 61 | Richard Henderson (10): |
67 | target/arm: fix handling of HCR.FB | 62 | target/arm: Fix vd == vm overlap in sve_ldff1_z |
68 | target/arm: fix LORID_EL1 access check | 63 | target/arm: Split out disas_a64_legacy |
69 | hw/arm/boot: fix SVE for EL3 direct kernel boot | 64 | target/arm: Convert PC-rel addressing to decodetree |
65 | target/arm: Split gen_add_CC and gen_sub_CC | ||
66 | target/arm: Convert Add/subtract (immediate) to decodetree | ||
67 | target/arm: Convert Add/subtract (immediate with tags) to decodetree | ||
68 | target/arm: Replace bitmask64 with MAKE_64BIT_MASK | ||
69 | target/arm: Convert Logical (immediate) to decodetree | ||
70 | target/arm: Convert Move wide (immediate) to decodetree | ||
71 | target/arm: Convert Bitfield to decodetree | ||
70 | 72 | ||
71 | docs/qemu-option-trace.rst.inc | 6 +- | 73 | MAINTAINERS | 1 + |
72 | configure | 10 +- | 74 | docs/system/device-emulation.rst | 1 + |
73 | include/hw/intc/arm_gicv3_common.h | 1 - | 75 | docs/system/devices/usb-u2f.rst | 93 +++ |
74 | disas/capstone.c | 2 +- | 76 | docs/system/devices/usb.rst | 2 +- |
75 | hw/arm/boot.c | 3 + | 77 | docs/u2f.txt | 110 ---- |
76 | hw/arm/smmuv3.c | 3 +- | 78 | target/arm/cpu.h | 4 + |
77 | hw/display/exynos4210_fimd.c | 4 +- | 79 | target/arm/kvm_arm.h | 19 + |
78 | hw/display/omap_lcdc.c | 10 +- | 80 | target/arm/tcg/translate.h | 5 + |
79 | hw/intc/arm_gicv3_cpuif.c | 5 +- | 81 | target/arm/tcg/a64.decode | 152 +++++ |
80 | target/arm/helper.c | 24 +- | 82 | hw/arm/sbsa-ref.c | 4 +- |
81 | target/arm/m_helper.c | 3 +- | 83 | hw/arm/vexpress.c | 40 +- |
82 | target/arm/translate.c | 153 +++++++++--- | 84 | hw/arm/virt.c | 73 ++- |
83 | target/arm/vec_helper.c | 12 +- | 85 | target/arm/cortex-regs.c | 11 +- |
84 | tests/qtest/npcm7xx_rng-test.c | 14 +- | 86 | target/arm/cpu.c | 9 +- |
85 | scripts/kernel-doc | 18 +- | 87 | target/arm/debug_helper.c | 11 +- |
86 | target/arm/translate-neon.c.inc | 472 ++++++++++++++++++++----------------- | 88 | target/arm/kvm.c | 35 + |
87 | target/arm/translate-vfp.c.inc | 341 +++++++++++---------------- | 89 | target/arm/kvm64.c | 5 + |
88 | 17 files changed, 588 insertions(+), 493 deletions(-) | 90 | target/arm/tcg/sve_helper.c | 6 + |
91 | target/arm/tcg/translate-a64.c | 1321 ++++++++++++++++---------------------- | ||
92 | target/arm/tcg/meson.build | 1 + | ||
93 | 20 files changed, 979 insertions(+), 924 deletions(-) | ||
94 | create mode 100644 docs/system/devices/usb-u2f.rst | ||
95 | delete mode 100644 docs/u2f.txt | ||
96 | create mode 100644 target/arm/tcg/a64.decode | ||
89 | 97 | diff view generated by jsdifflib |
1 | If we're using the capstone disassembler, disassembly of a run of | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | instructions more than 32 bytes long disassembles the wrong data for | ||
3 | instructions beyond the 32 byte mark: | ||
4 | 2 | ||
5 | (qemu) xp /16x 0x100 | 3 | The world outside moves to newer and newer cpu cores. Let move SBSA |
6 | 0000000000000100: 0x00000005 0x54410001 0x00000001 0x00001000 | 4 | Reference Platform to something newer as well. |
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 | 5 | ||
28 | Here the disassembly of 0x120..0x13f is using the data that is in | 6 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
29 | 0x104..0x123. | 7 | Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com> |
30 | 8 | Message-id: 20230506183417.1360427-1-marcin.juszkiewicz@linaro.org | |
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> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
45 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
46 | Message-id: 20201022132445.25039-1-peter.maydell@linaro.org | ||
47 | --- | 10 | --- |
48 | disas/capstone.c | 2 +- | 11 | hw/arm/sbsa-ref.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/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
52 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
53 | --- a/disas/capstone.c | 16 | --- a/hw/arm/sbsa-ref.c |
54 | +++ b/disas/capstone.c | 17 | +++ b/hw/arm/sbsa-ref.c |
55 | @@ -XXX,XX +XXX,XX @@ bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count) | 18 | @@ -XXX,XX +XXX,XX @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data) |
56 | 19 | ||
57 | /* Make certain that we can make progress. */ | 20 | mc->init = sbsa_ref_init; |
58 | assert(tsize != 0); | 21 | mc->desc = "QEMU 'SBSA Reference' ARM Virtual Machine"; |
59 | - info->read_memory_func(pc, cap_buf + csize, tsize, info); | 22 | - mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a57"); |
60 | + info->read_memory_func(pc + csize, cap_buf + csize, tsize, info); | 23 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("neoverse-n1"); |
61 | csize += tsize; | 24 | mc->max_cpus = 512; |
62 | 25 | mc->pci_allow_0_address = true; | |
63 | if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { | 26 | mc->minimum_page_bits = 12; |
64 | -- | 27 | -- |
65 | 2.20.1 | 28 | 2.34.1 |
66 | |||
67 | diff view generated by jsdifflib |
1 | From: AlexChen <alex.chen@huawei.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In omap_lcd_interrupts(), the pointer omap_lcd is dereferinced before | 3 | If vd == vm, copy vm to scratch, so that we can pre-zero |
4 | being check if it is valid, which may lead to NULL pointer dereference. | 4 | the output and still access the gather indicies. |
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 | 5 | ||
8 | Reported-by: Euler Robot <euler.robot@huawei.com> | 6 | Cc: qemu-stable@nongnu.org |
9 | Signed-off-by: AlexChen <alex.chen@huawei.com> | 7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1612 |
10 | Message-id: 5F9CDB8A.9000001@huawei.com | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20230504104232.1877774-1-richard.henderson@linaro.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 12 | --- |
14 | hw/display/omap_lcdc.c | 10 +++++++--- | 13 | target/arm/tcg/sve_helper.c | 6 ++++++ |
15 | 1 file changed, 7 insertions(+), 3 deletions(-) | 14 | 1 file changed, 6 insertions(+) |
16 | 15 | ||
17 | diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c | 16 | diff --git a/target/arm/tcg/sve_helper.c b/target/arm/tcg/sve_helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/display/omap_lcdc.c | 18 | --- a/target/arm/tcg/sve_helper.c |
20 | +++ b/hw/display/omap_lcdc.c | 19 | +++ b/target/arm/tcg/sve_helper.c |
21 | @@ -XXX,XX +XXX,XX @@ static void omap_lcd_interrupts(struct omap_lcd_panel_s *s) | 20 | @@ -XXX,XX +XXX,XX @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, |
22 | static void omap_update_display(void *opaque) | 21 | intptr_t reg_off; |
23 | { | 22 | SVEHostPage info; |
24 | struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque; | 23 | target_ulong addr, in_page; |
25 | - DisplaySurface *surface = qemu_console_surface(omap_lcd->con); | 24 | + ARMVectorReg scratch; |
26 | + DisplaySurface *surface; | 25 | |
27 | draw_line_func draw_line; | 26 | /* Skip to the first true predicate. */ |
28 | int size, height, first, last; | 27 | reg_off = find_next_active(vg, 0, reg_max, esz); |
29 | int width, linesize, step, bpp, frame_offset; | 28 | @@ -XXX,XX +XXX,XX @@ void sve_ldff1_z(CPUARMState *env, void *vd, uint64_t *vg, void *vm, |
30 | hwaddr frame_base; | 29 | return; |
31 | 30 | } | |
32 | - if (!omap_lcd || omap_lcd->plm == 1 || !omap_lcd->enable || | 31 | |
33 | - !surface_bits_per_pixel(surface)) { | 32 | + /* Protect against overlap between vd and vm. */ |
34 | + if (!omap_lcd || omap_lcd->plm == 1 || !omap_lcd->enable) { | 33 | + if (unlikely(vd == vm)) { |
35 | + return; | 34 | + vm = memcpy(&scratch, vm, reg_max); |
36 | + } | 35 | + } |
37 | + | 36 | + |
38 | + surface = qemu_console_surface(omap_lcd->con); | 37 | /* |
39 | + if (!surface_bits_per_pixel(surface)) { | 38 | * Probe the first element, allowing faults. |
40 | return; | 39 | */ |
41 | } | ||
42 | |||
43 | -- | 40 | -- |
44 | 2.20.1 | 41 | 2.34.1 |
45 | |||
46 | diff view generated by jsdifflib |
1 | From: AlexChen <alex.chen@huawei.com> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | In exynos4210_fimd_update(), the pointer s is dereferinced before | 3 | At Linaro I work on sbsa-ref, know direction it goes. |
4 | being check if it is valid, which may lead to NULL pointer dereference. | ||
5 | So move the assignment to global_width after checking that the s is valid. | ||
6 | 4 | ||
7 | Reported-by: Euler Robot <euler.robot@huawei.com> | 5 | May not get code details each time. |
8 | Signed-off-by: Alex Chen <alex.chen@huawei.com> | 6 | |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 7 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
10 | Message-id: 5F9F8D88.9030102@huawei.com | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | Message-id: 20230515143753.365591-1-marcin.juszkiewicz@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 11 | --- |
13 | hw/display/exynos4210_fimd.c | 4 +++- | 12 | MAINTAINERS | 1 + |
14 | 1 file changed, 3 insertions(+), 1 deletion(-) | 13 | 1 file changed, 1 insertion(+) |
15 | 14 | ||
16 | diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c | 15 | diff --git a/MAINTAINERS b/MAINTAINERS |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/display/exynos4210_fimd.c | 17 | --- a/MAINTAINERS |
19 | +++ b/hw/display/exynos4210_fimd.c | 18 | +++ b/MAINTAINERS |
20 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_fimd_update(void *opaque) | 19 | @@ -XXX,XX +XXX,XX @@ SBSA-REF |
21 | bool blend = false; | 20 | M: Radoslaw Biernacki <rad@semihalf.com> |
22 | uint8_t *host_fb_addr; | 21 | M: Peter Maydell <peter.maydell@linaro.org> |
23 | bool is_dirty = false; | 22 | R: Leif Lindholm <quic_llindhol@quicinc.com> |
24 | - const int global_width = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1; | 23 | +R: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
25 | + int global_width; | 24 | L: qemu-arm@nongnu.org |
26 | 25 | S: Maintained | |
27 | if (!s || !s->console || !s->enabled || | 26 | F: hw/arm/sbsa-ref.c |
28 | surface_bits_per_pixel(qemu_console_surface(s->console)) == 0) { | ||
29 | return; | ||
30 | } | ||
31 | + | ||
32 | + global_width = (s->vidtcon[2] & FIMD_VIDTCON2_SIZE_MASK) + 1; | ||
33 | exynos4210_update_resolution(s); | ||
34 | surface = qemu_console_surface(s->console); | ||
35 | |||
36 | -- | 27 | -- |
37 | 2.20.1 | 28 | 2.34.1 |
38 | 29 | ||
39 | 30 | diff view generated by jsdifflib |
1 | From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 1 | From: Cornelia Huck <cohuck@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | HCR should be applied when NS is set, not when it is cleared. | 3 | Extend the 'mte' property for the virt machine to cover KVM as |
4 | 4 | well. For KVM, we don't allocate tag memory, but instead enable the | |
5 | Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 5 | capability. |
6 | |||
7 | If MTE has been enabled, we need to disable migration, as we do not | ||
8 | yet have a way to migrate the tags as well. Therefore, MTE will stay | ||
9 | off with KVM unless requested explicitly. | ||
10 | |||
11 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20230428095533.21747-2-cohuck@redhat.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 16 | --- |
9 | target/arm/helper.c | 5 ++--- | 17 | target/arm/cpu.h | 4 +++ |
10 | 1 file changed, 2 insertions(+), 3 deletions(-) | 18 | target/arm/kvm_arm.h | 19 ++++++++++++ |
11 | 19 | hw/arm/virt.c | 73 +++++++++++++++++++++++++------------------- | |
12 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 20 | target/arm/cpu.c | 9 +++--- |
13 | index XXXXXXX..XXXXXXX 100644 | 21 | target/arm/kvm.c | 35 +++++++++++++++++++++ |
14 | --- a/target/arm/helper.c | 22 | target/arm/kvm64.c | 5 +++ |
15 | +++ b/target/arm/helper.c | 23 | 6 files changed, 109 insertions(+), 36 deletions(-) |
16 | @@ -XXX,XX +XXX,XX @@ static void tlbimvaa_is_write(CPUARMState *env, const ARMCPRegInfo *ri, | 24 | |
25 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/cpu.h | ||
28 | +++ b/target/arm/cpu.h | ||
29 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { | ||
30 | */ | ||
31 | uint32_t psci_conduit; | ||
32 | |||
33 | + /* CPU has Memory Tag Extension */ | ||
34 | + bool has_mte; | ||
35 | + | ||
36 | /* For v8M, initial value of the Secure VTOR */ | ||
37 | uint32_t init_svtor; | ||
38 | /* For v8M, initial value of the Non-secure VTOR */ | ||
39 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { | ||
40 | bool prop_pauth; | ||
41 | bool prop_pauth_impdef; | ||
42 | bool prop_lpa2; | ||
43 | + OnOffAuto prop_mte; | ||
44 | |||
45 | /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ | ||
46 | uint32_t dcz_blocksize; | ||
47 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/kvm_arm.h | ||
50 | +++ b/target/arm/kvm_arm.h | ||
51 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_pmu_supported(void); | ||
52 | */ | ||
53 | bool kvm_arm_sve_supported(void); | ||
54 | |||
55 | +/** | ||
56 | + * kvm_arm_mte_supported: | ||
57 | + * | ||
58 | + * Returns: true if KVM can enable MTE, and false otherwise. | ||
59 | + */ | ||
60 | +bool kvm_arm_mte_supported(void); | ||
61 | + | ||
62 | /** | ||
63 | * kvm_arm_get_max_vm_ipa_size: | ||
64 | * @ms: Machine state handle | ||
65 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa); | ||
66 | |||
67 | int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level); | ||
68 | |||
69 | +void kvm_arm_enable_mte(Object *cpuobj, Error **errp); | ||
70 | + | ||
71 | #else | ||
17 | 72 | ||
18 | /* | 73 | /* |
19 | * Non-IS variants of TLB operations are upgraded to | 74 | @@ -XXX,XX +XXX,XX @@ static inline bool kvm_arm_steal_time_supported(void) |
20 | - * IS versions if we are at NS EL1 and HCR_EL2.FB is set to | 75 | return false; |
21 | + * IS versions if we are at EL1 and HCR_EL2.FB is effectively set to | 76 | } |
22 | * force broadcast of these operations. | 77 | |
78 | +static inline bool kvm_arm_mte_supported(void) | ||
79 | +{ | ||
80 | + return false; | ||
81 | +} | ||
82 | + | ||
83 | /* | ||
84 | * These functions should never actually be called without KVM support. | ||
23 | */ | 85 | */ |
24 | static bool tlb_force_broadcast(CPUARMState *env) | 86 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t kvm_arm_sve_get_vls(CPUState *cs) |
87 | g_assert_not_reached(); | ||
88 | } | ||
89 | |||
90 | +static inline void kvm_arm_enable_mte(Object *cpuobj, Error **errp) | ||
91 | +{ | ||
92 | + g_assert_not_reached(); | ||
93 | +} | ||
94 | + | ||
95 | #endif | ||
96 | |||
97 | static inline const char *gic_class_name(void) | ||
98 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/hw/arm/virt.c | ||
101 | +++ b/hw/arm/virt.c | ||
102 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
103 | exit(1); | ||
104 | } | ||
105 | |||
106 | - if (vms->mte && (kvm_enabled() || hvf_enabled())) { | ||
107 | + if (vms->mte && hvf_enabled()) { | ||
108 | error_report("mach-virt: %s does not support providing " | ||
109 | "MTE to the guest CPU", | ||
110 | current_accel_name()); | ||
111 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
112 | } | ||
113 | |||
114 | if (vms->mte) { | ||
115 | - /* Create the memory region only once, but link to all cpus. */ | ||
116 | - if (!tag_sysmem) { | ||
117 | - /* | ||
118 | - * The property exists only if MemTag is supported. | ||
119 | - * If it is, we must allocate the ram to back that up. | ||
120 | - */ | ||
121 | - if (!object_property_find(cpuobj, "tag-memory")) { | ||
122 | - error_report("MTE requested, but not supported " | ||
123 | - "by the guest CPU"); | ||
124 | + if (tcg_enabled()) { | ||
125 | + /* Create the memory region only once, but link to all cpus. */ | ||
126 | + if (!tag_sysmem) { | ||
127 | + /* | ||
128 | + * The property exists only if MemTag is supported. | ||
129 | + * If it is, we must allocate the ram to back that up. | ||
130 | + */ | ||
131 | + if (!object_property_find(cpuobj, "tag-memory")) { | ||
132 | + error_report("MTE requested, but not supported " | ||
133 | + "by the guest CPU"); | ||
134 | + exit(1); | ||
135 | + } | ||
136 | + | ||
137 | + tag_sysmem = g_new(MemoryRegion, 1); | ||
138 | + memory_region_init(tag_sysmem, OBJECT(machine), | ||
139 | + "tag-memory", UINT64_MAX / 32); | ||
140 | + | ||
141 | + if (vms->secure) { | ||
142 | + secure_tag_sysmem = g_new(MemoryRegion, 1); | ||
143 | + memory_region_init(secure_tag_sysmem, OBJECT(machine), | ||
144 | + "secure-tag-memory", | ||
145 | + UINT64_MAX / 32); | ||
146 | + | ||
147 | + /* As with ram, secure-tag takes precedence over tag. */ | ||
148 | + memory_region_add_subregion_overlap(secure_tag_sysmem, | ||
149 | + 0, tag_sysmem, -1); | ||
150 | + } | ||
151 | + } | ||
152 | + | ||
153 | + object_property_set_link(cpuobj, "tag-memory", | ||
154 | + OBJECT(tag_sysmem), &error_abort); | ||
155 | + if (vms->secure) { | ||
156 | + object_property_set_link(cpuobj, "secure-tag-memory", | ||
157 | + OBJECT(secure_tag_sysmem), | ||
158 | + &error_abort); | ||
159 | + } | ||
160 | + } else if (kvm_enabled()) { | ||
161 | + if (!kvm_arm_mte_supported()) { | ||
162 | + error_report("MTE requested, but not supported by KVM"); | ||
163 | exit(1); | ||
164 | } | ||
165 | - | ||
166 | - tag_sysmem = g_new(MemoryRegion, 1); | ||
167 | - memory_region_init(tag_sysmem, OBJECT(machine), | ||
168 | - "tag-memory", UINT64_MAX / 32); | ||
169 | - | ||
170 | - if (vms->secure) { | ||
171 | - secure_tag_sysmem = g_new(MemoryRegion, 1); | ||
172 | - memory_region_init(secure_tag_sysmem, OBJECT(machine), | ||
173 | - "secure-tag-memory", UINT64_MAX / 32); | ||
174 | - | ||
175 | - /* As with ram, secure-tag takes precedence over tag. */ | ||
176 | - memory_region_add_subregion_overlap(secure_tag_sysmem, 0, | ||
177 | - tag_sysmem, -1); | ||
178 | - } | ||
179 | - } | ||
180 | - | ||
181 | - object_property_set_link(cpuobj, "tag-memory", OBJECT(tag_sysmem), | ||
182 | - &error_abort); | ||
183 | - if (vms->secure) { | ||
184 | - object_property_set_link(cpuobj, "secure-tag-memory", | ||
185 | - OBJECT(secure_tag_sysmem), | ||
186 | - &error_abort); | ||
187 | + kvm_arm_enable_mte(cpuobj, &error_abort); | ||
188 | } | ||
189 | } | ||
190 | |||
191 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
192 | index XXXXXXX..XXXXXXX 100644 | ||
193 | --- a/target/arm/cpu.c | ||
194 | +++ b/target/arm/cpu.c | ||
195 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj) | ||
196 | qdev_prop_allow_set_link_before_realize, | ||
197 | OBJ_PROP_LINK_STRONG); | ||
198 | } | ||
199 | + cpu->has_mte = true; | ||
200 | } | ||
201 | #endif | ||
202 | } | ||
203 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
204 | } | ||
205 | if (cpu->tag_memory) { | ||
206 | error_setg(errp, | ||
207 | - "Cannot enable %s when guest CPUs has MTE enabled", | ||
208 | + "Cannot enable %s when guest CPUs has tag memory enabled", | ||
209 | current_accel_name()); | ||
210 | return; | ||
211 | } | ||
212 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
213 | } | ||
214 | |||
215 | #ifndef CONFIG_USER_ONLY | ||
216 | - if (cpu->tag_memory == NULL && cpu_isar_feature(aa64_mte, cpu)) { | ||
217 | + if (!cpu->has_mte && cpu_isar_feature(aa64_mte, cpu)) { | ||
218 | /* | ||
219 | - * Disable the MTE feature bits if we do not have tag-memory | ||
220 | - * provided by the machine. | ||
221 | + * Disable the MTE feature bits if we do not have the feature | ||
222 | + * setup by the machine. | ||
223 | */ | ||
224 | cpu->isar.id_aa64pfr1 = | ||
225 | FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0); | ||
226 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
227 | index XXXXXXX..XXXXXXX 100644 | ||
228 | --- a/target/arm/kvm.c | ||
229 | +++ b/target/arm/kvm.c | ||
230 | @@ -XXX,XX +XXX,XX @@ | ||
231 | #include "hw/boards.h" | ||
232 | #include "hw/irq.h" | ||
233 | #include "qemu/log.h" | ||
234 | +#include "migration/blocker.h" | ||
235 | |||
236 | const KVMCapabilityInfo kvm_arch_required_capabilities[] = { | ||
237 | KVM_CAP_LAST_INFO | ||
238 | @@ -XXX,XX +XXX,XX @@ bool kvm_arch_cpu_check_are_resettable(void) | ||
239 | void kvm_arch_accel_class_init(ObjectClass *oc) | ||
25 | { | 240 | { |
26 | - return (env->cp15.hcr_el2 & HCR_FB) && | 241 | } |
27 | - arm_current_el(env) == 1 && arm_is_secure_below_el3(env); | 242 | + |
28 | + return arm_current_el(env) == 1 && (arm_hcr_el2_eff(env) & HCR_FB); | 243 | +void kvm_arm_enable_mte(Object *cpuobj, Error **errp) |
29 | } | 244 | +{ |
30 | 245 | + static bool tried_to_enable; | |
31 | static void tlbiall_write(CPUARMState *env, const ARMCPRegInfo *ri, | 246 | + static bool succeeded_to_enable; |
247 | + Error *mte_migration_blocker = NULL; | ||
248 | + int ret; | ||
249 | + | ||
250 | + if (!tried_to_enable) { | ||
251 | + /* | ||
252 | + * MTE on KVM is enabled on a per-VM basis (and retrying doesn't make | ||
253 | + * sense), and we only want a single migration blocker as well. | ||
254 | + */ | ||
255 | + tried_to_enable = true; | ||
256 | + | ||
257 | + ret = kvm_vm_enable_cap(kvm_state, KVM_CAP_ARM_MTE, 0); | ||
258 | + if (ret) { | ||
259 | + error_setg_errno(errp, -ret, "Failed to enable KVM_CAP_ARM_MTE"); | ||
260 | + return; | ||
261 | + } | ||
262 | + | ||
263 | + /* TODO: add proper migration support with MTE enabled */ | ||
264 | + error_setg(&mte_migration_blocker, | ||
265 | + "Live migration disabled due to MTE enabled"); | ||
266 | + if (migrate_add_blocker(mte_migration_blocker, errp)) { | ||
267 | + error_free(mte_migration_blocker); | ||
268 | + return; | ||
269 | + } | ||
270 | + succeeded_to_enable = true; | ||
271 | + } | ||
272 | + if (succeeded_to_enable) { | ||
273 | + object_property_set_bool(cpuobj, "has_mte", true, NULL); | ||
274 | + } | ||
275 | +} | ||
276 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
277 | index XXXXXXX..XXXXXXX 100644 | ||
278 | --- a/target/arm/kvm64.c | ||
279 | +++ b/target/arm/kvm64.c | ||
280 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_steal_time_supported(void) | ||
281 | return kvm_check_extension(kvm_state, KVM_CAP_STEAL_TIME); | ||
282 | } | ||
283 | |||
284 | +bool kvm_arm_mte_supported(void) | ||
285 | +{ | ||
286 | + return kvm_check_extension(kvm_state, KVM_CAP_ARM_MTE); | ||
287 | +} | ||
288 | + | ||
289 | QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN != 1); | ||
290 | |||
291 | uint32_t kvm_arm_sve_get_vls(CPUState *cs) | ||
32 | -- | 292 | -- |
33 | 2.20.1 | 293 | 2.34.1 |
34 | |||
35 | diff view generated by jsdifflib |
1 | From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 1 | From: Alex Bennée <alex.bennee@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When booting a CPU with EL3 using the -kernel flag, set up CPTR_EL3 so | 3 | The commit b3aa2f2128 (target/arm: provide stubs for more external |
4 | that SVE will not trap to EL3. | 4 | debug registers) was added to handle HyperV's unconditional usage of |
5 | Debug Communications Channel. It turns out that Linux will similarly | ||
6 | break if you enable CONFIG_HVC_DCC "ARM JTAG DCC console". | ||
5 | 7 | ||
6 | Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 8 | Extend the registers we RAZ/WI set to avoid this. |
9 | |||
10 | Cc: Anders Roxell <anders.roxell@linaro.org> | ||
11 | Cc: Evgeny Iakovlev <eiakovlev@linux.microsoft.com> | ||
12 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20201030151541.11976-1-remi@remlab.net | 14 | Message-id: 20230516104420.407912-1-alex.bennee@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 16 | --- |
11 | hw/arm/boot.c | 3 +++ | 17 | target/arm/debug_helper.c | 11 +++++++++-- |
12 | 1 file changed, 3 insertions(+) | 18 | 1 file changed, 9 insertions(+), 2 deletions(-) |
13 | 19 | ||
14 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 20 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c |
15 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/boot.c | 22 | --- a/target/arm/debug_helper.c |
17 | +++ b/hw/arm/boot.c | 23 | +++ b/target/arm/debug_helper.c |
18 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | 24 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { |
19 | if (cpu_isar_feature(aa64_mte, cpu)) { | 25 | .access = PL0_R, .accessfn = access_tdcc, |
20 | env->cp15.scr_el3 |= SCR_ATA; | 26 | .type = ARM_CP_CONST, .resetvalue = 0 }, |
21 | } | 27 | /* |
22 | + if (cpu_isar_feature(aa64_sve, cpu)) { | 28 | - * OSDTRRX_EL1/OSDTRTX_EL1 are used for save and restore of DBGDTRRX_EL0. |
23 | + env->cp15.cptr_el[3] |= CPTR_EZ; | 29 | - * It is a component of the Debug Communications Channel, which is not implemented. |
24 | + } | 30 | + * These registers belong to the Debug Communications Channel, |
25 | /* AArch64 kernels never boot in secure mode */ | 31 | + * which is not implemented. However we implement RAZ/WI behaviour |
26 | assert(!info->secure_boot); | 32 | + * with trapping to prevent spurious SIGILLs if the guest OS does |
27 | /* This hook is only supported for AArch32 currently: | 33 | + * access them as the support cannot be probed for. |
34 | */ | ||
35 | { .name = "OSDTRRX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, | ||
36 | .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 2, | ||
37 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = { | ||
38 | .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 2, | ||
39 | .access = PL1_RW, .accessfn = access_tdcc, | ||
40 | .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
41 | + /* DBGDTRTX_EL0/DBGDTRRX_EL0 depend on direction */ | ||
42 | + { .name = "DBGDTR_EL0", .state = ARM_CP_STATE_BOTH, .cp = 14, | ||
43 | + .opc0 = 2, .opc1 = 3, .crn = 0, .crm = 5, .opc2 = 0, | ||
44 | + .access = PL0_RW, .accessfn = access_tdcc, | ||
45 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
46 | /* | ||
47 | * OSECCR_EL1 provides a mechanism for an operating system | ||
48 | * to access the contents of EDECCR. EDECCR is not implemented though, | ||
28 | -- | 49 | -- |
29 | 2.20.1 | 50 | 2.34.1 |
30 | 51 | ||
31 | 52 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Use the BIT_ULL() macro to ensure we use 64-bit arithmetic. | 3 | Bochs card is normal PCI Express card so it fits better in system with |
4 | This fixes the following Coverity issue (OVERFLOW_BEFORE_WIDEN): | 4 | PCI Express bus. VGA is simple legacy PCI card. |
5 | 5 | ||
6 | CID 1432363 (#1 of 1): Unintentional integer overflow: | 6 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
7 | 7 | Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com> | |
8 | overflow_before_widen: | 8 | Message-id: 20230505120936.1097060-1-marcin.juszkiewicz@linaro.org |
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> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 10 | --- |
20 | hw/arm/smmuv3.c | 3 ++- | 11 | hw/arm/sbsa-ref.c | 2 +- |
21 | 1 file changed, 2 insertions(+), 1 deletion(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
22 | 13 | ||
23 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | 14 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
24 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/arm/smmuv3.c | 16 | --- a/hw/arm/sbsa-ref.c |
26 | +++ b/hw/arm/smmuv3.c | 17 | +++ b/hw/arm/sbsa-ref.c |
27 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(SBSAMachineState *sms) |
28 | */ | 19 | } |
29 | |||
30 | #include "qemu/osdep.h" | ||
31 | +#include "qemu/bitops.h" | ||
32 | #include "hw/irq.h" | ||
33 | #include "hw/sysbus.h" | ||
34 | #include "migration/vmstate.h" | ||
35 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
36 | scale = CMD_SCALE(cmd); | ||
37 | num = CMD_NUM(cmd); | ||
38 | ttl = CMD_TTL(cmd); | ||
39 | - num_pages = (num + 1) * (1 << (scale)); | ||
40 | + num_pages = (num + 1) * BIT_ULL(scale); | ||
41 | } | 20 | } |
42 | 21 | ||
43 | if (type == SMMU_CMD_TLBI_NH_VA) { | 22 | - pci_create_simple(pci->bus, -1, "VGA"); |
23 | + pci_create_simple(pci->bus, -1, "bochs-display"); | ||
24 | |||
25 | create_smmu(sms, pci->bus); | ||
26 | } | ||
44 | -- | 27 | -- |
45 | 2.20.1 | 28 | 2.34.1 |
46 | |||
47 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Model these off the aa64 read/write_vec_element functions. | 3 | Split out all of the decode stuff from aarch64_tr_translate_insn. |
4 | Use it within translate-neon.c.inc. The new functions do | 4 | Call it disas_a64_legacy to indicate it will be replaced. |
5 | not allocate or free temps, so this rearranges the calling | ||
6 | code a bit. | ||
7 | 5 | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20201030022618.785675-6-richard.henderson@linaro.org | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20230512144106.3608981-2-peter.maydell@linaro.org | ||
10 | [PMM: Rebased] | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 13 | --- |
13 | target/arm/translate.c | 26 ++++ | 14 | target/arm/tcg/translate-a64.c | 82 ++++++++++++++++++---------------- |
14 | target/arm/translate-neon.c.inc | 256 ++++++++++++++++++++------------ | 15 | 1 file changed, 44 insertions(+), 38 deletions(-) |
15 | 2 files changed, 183 insertions(+), 99 deletions(-) | ||
16 | 16 | ||
17 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 17 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
18 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate.c | 19 | --- a/target/arm/tcg/translate-a64.c |
20 | +++ b/target/arm/translate.c | 20 | +++ b/target/arm/tcg/translate-a64.c |
21 | @@ -XXX,XX +XXX,XX @@ static inline void neon_store_reg32(TCGv_i32 var, int reg) | 21 | @@ -XXX,XX +XXX,XX @@ static bool btype_destination_ok(uint32_t insn, bool bt, int btype) |
22 | tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); | 22 | return false; |
23 | } | 23 | } |
24 | 24 | ||
25 | +static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp size) | 25 | +/* C3.1 A64 instruction index by encoding */ |
26 | +static void disas_a64_legacy(DisasContext *s, uint32_t insn) | ||
26 | +{ | 27 | +{ |
27 | + long off = neon_element_offset(reg, ele, size); | 28 | + switch (extract32(insn, 25, 4)) { |
28 | + | 29 | + case 0x0: |
29 | + switch (size) { | 30 | + if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { |
30 | + case MO_32: | 31 | + unallocated_encoding(s); |
31 | + tcg_gen_ld_i32(dest, cpu_env, off); | 32 | + } |
33 | + break; | ||
34 | + case 0x1: case 0x3: /* UNALLOCATED */ | ||
35 | + unallocated_encoding(s); | ||
36 | + break; | ||
37 | + case 0x2: | ||
38 | + if (!disas_sve(s, insn)) { | ||
39 | + unallocated_encoding(s); | ||
40 | + } | ||
41 | + break; | ||
42 | + case 0x8: case 0x9: /* Data processing - immediate */ | ||
43 | + disas_data_proc_imm(s, insn); | ||
44 | + break; | ||
45 | + case 0xa: case 0xb: /* Branch, exception generation and system insns */ | ||
46 | + disas_b_exc_sys(s, insn); | ||
47 | + break; | ||
48 | + case 0x4: | ||
49 | + case 0x6: | ||
50 | + case 0xc: | ||
51 | + case 0xe: /* Loads and stores */ | ||
52 | + disas_ldst(s, insn); | ||
53 | + break; | ||
54 | + case 0x5: | ||
55 | + case 0xd: /* Data processing - register */ | ||
56 | + disas_data_proc_reg(s, insn); | ||
57 | + break; | ||
58 | + case 0x7: | ||
59 | + case 0xf: /* Data processing - SIMD and floating point */ | ||
60 | + disas_data_proc_simd_fp(s, insn); | ||
32 | + break; | 61 | + break; |
33 | + default: | 62 | + default: |
34 | + g_assert_not_reached(); | 63 | + assert(FALSE); /* all 15 cases should be handled above */ |
64 | + break; | ||
35 | + } | 65 | + } |
36 | +} | 66 | +} |
37 | + | 67 | + |
38 | +static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp size) | 68 | static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, |
39 | +{ | 69 | CPUState *cpu) |
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 | { | 70 | { |
53 | TCGv_ptr ret = tcg_temp_new_ptr(); | 71 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) |
54 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 72 | disas_sme_fa64(s, insn); |
55 | index XXXXXXX..XXXXXXX 100644 | ||
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 | } | ||
90 | |||
91 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | ||
92 | * 2-reg-and-shift operations, size < 3 case, where the | ||
93 | * helper needs to be passed cpu_env. | ||
94 | */ | ||
95 | - TCGv_i32 constimm; | ||
96 | + TCGv_i32 constimm, tmp; | ||
97 | int pass; | ||
98 | |||
99 | if (!arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
100 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_32(DisasContext *s, arg_2reg_shift *a, | ||
101 | * by immediate using the variable shift operations. | ||
102 | */ | ||
103 | constimm = tcg_const_i32(dup_const(a->size, a->shift)); | ||
104 | + tmp = tcg_temp_new_i32(); | ||
105 | |||
106 | for (pass = 0; pass < (a->q ? 4 : 2); pass++) { | ||
107 | - TCGv_i32 tmp = neon_load_reg(a->vm, pass); | ||
108 | + read_neon_element32(tmp, a->vm, pass, MO_32); | ||
109 | fn(tmp, cpu_env, tmp, constimm); | ||
110 | - neon_store_reg(a->vd, pass, tmp); | ||
111 | + write_neon_element32(tmp, a->vd, pass, MO_32); | ||
112 | } | 73 | } |
113 | + tcg_temp_free_i32(tmp); | 74 | |
114 | tcg_temp_free_i32(constimm); | 75 | - switch (extract32(insn, 25, 4)) { |
115 | return true; | 76 | - case 0x0: |
116 | } | 77 | - if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { |
117 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a, | 78 | - unallocated_encoding(s); |
118 | constimm = tcg_const_i64(-a->shift); | 79 | - } |
119 | rm1 = tcg_temp_new_i64(); | 80 | - break; |
120 | rm2 = tcg_temp_new_i64(); | 81 | - case 0x1: case 0x3: /* UNALLOCATED */ |
121 | + rd = tcg_temp_new_i32(); | 82 | - unallocated_encoding(s); |
122 | 83 | - break; | |
123 | /* Load both inputs first to avoid potential overwrite if rm == rd */ | 84 | - case 0x2: |
124 | neon_load_reg64(rm1, a->vm); | 85 | - if (!disas_sve(s, insn)) { |
125 | neon_load_reg64(rm2, a->vm + 1); | 86 | - unallocated_encoding(s); |
126 | 87 | - } | |
127 | shiftfn(rm1, rm1, constimm); | 88 | - break; |
128 | - rd = tcg_temp_new_i32(); | 89 | - case 0x8: case 0x9: /* Data processing - immediate */ |
129 | narrowfn(rd, cpu_env, rm1); | 90 | - disas_data_proc_imm(s, insn); |
130 | - neon_store_reg(a->vd, 0, rd); | 91 | - break; |
131 | + write_neon_element32(rd, a->vd, 0, MO_32); | 92 | - case 0xa: case 0xb: /* Branch, exception generation and system insns */ |
132 | 93 | - disas_b_exc_sys(s, insn); | |
133 | shiftfn(rm2, rm2, constimm); | 94 | - break; |
134 | - rd = tcg_temp_new_i32(); | 95 | - case 0x4: |
135 | narrowfn(rd, cpu_env, rm2); | 96 | - case 0x6: |
136 | - neon_store_reg(a->vd, 1, rd); | 97 | - case 0xc: |
137 | + write_neon_element32(rd, a->vd, 1, MO_32); | 98 | - case 0xe: /* Loads and stores */ |
138 | 99 | - disas_ldst(s, insn); | |
139 | + tcg_temp_free_i32(rd); | 100 | - break; |
140 | tcg_temp_free_i64(rm1); | 101 | - case 0x5: |
141 | tcg_temp_free_i64(rm2); | 102 | - case 0xd: /* Data processing - register */ |
142 | tcg_temp_free_i64(constimm); | 103 | - disas_data_proc_reg(s, insn); |
143 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_32(DisasContext *s, arg_2reg_shift *a, | 104 | - break; |
144 | constimm = tcg_const_i32(imm); | 105 | - case 0x7: |
145 | 106 | - case 0xf: /* Data processing - SIMD and floating point */ | |
146 | /* Load all inputs first to avoid potential overwrite */ | 107 | - disas_data_proc_simd_fp(s, insn); |
147 | - rm1 = neon_load_reg(a->vm, 0); | 108 | - break; |
148 | - rm2 = neon_load_reg(a->vm, 1); | 109 | - default: |
149 | - rm3 = neon_load_reg(a->vm + 1, 0); | 110 | - assert(FALSE); /* all 15 cases should be handled above */ |
150 | - rm4 = neon_load_reg(a->vm + 1, 1); | 111 | - break; |
151 | + rm1 = tcg_temp_new_i32(); | 112 | - } |
152 | + rm2 = tcg_temp_new_i32(); | 113 | + disas_a64_legacy(s, insn); |
153 | + rm3 = tcg_temp_new_i32(); | 114 | |
154 | + rm4 = tcg_temp_new_i32(); | 115 | /* |
155 | + read_neon_element32(rm1, a->vm, 0, MO_32); | 116 | * After execution of most insns, btype is reset to 0. |
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 | { | ||
266 | - TCGv_i32 tmp; | ||
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 | -- | 117 | -- |
623 | 2.20.1 | 118 | 2.34.1 |
624 | |||
625 | diff view generated by jsdifflib |
1 | The randomness tests in the NPCM7xx RNG test fail intermittently | 1 | The A64 translator uses a hand-written decoder for everything except |
---|---|---|---|
2 | but fairly frequently. On my machine running the test in a loop: | 2 | SVE or SME. It's fairly well structured, but it's becoming obvious |
3 | while QTEST_QEMU_BINARY=./qemu-system-aarch64 ./tests/qtest/npcm7xx_rng-test; do true; done | 3 | that it's still more painful to add instructions to than the A32 |
4 | translator, because putting a new instruction into the right place in | ||
5 | a hand-written decoder is much harder than adding new instruction | ||
6 | patterns to a decodetree file. | ||
4 | 7 | ||
5 | will fail in less than a minute with an error like: | 8 | As the first step in conversion to decodetree, create the skeleton of |
6 | ERROR:../../tests/qtest/npcm7xx_rng-test.c:256:test_first_byte_runs: | 9 | the decodetree decoder; where it does not handle instructions we will |
7 | assertion failed (calc_runs_p(buf.l, sizeof(buf) * BITS_PER_BYTE) > 0.01): (0.00286205989 > 0.01) | 10 | fall back to the legacy decoder (which will be for everything at the |
8 | 11 | moment, since there are no patterns in a64.decode). | |
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 | 12 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
19 | Message-id: 20201102152454.8287-1-peter.maydell@linaro.org | 15 | Message-id: 20230512144106.3608981-3-peter.maydell@linaro.org |
20 | Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com> | ||
21 | --- | 16 | --- |
22 | tests/qtest/npcm7xx_rng-test.c | 14 ++++++++++---- | 17 | target/arm/tcg/a64.decode | 20 ++++++++++++++++++++ |
23 | 1 file changed, 10 insertions(+), 4 deletions(-) | 18 | target/arm/tcg/translate-a64.c | 18 +++++++++++------- |
19 | target/arm/tcg/meson.build | 1 + | ||
20 | 3 files changed, 32 insertions(+), 7 deletions(-) | ||
21 | create mode 100644 target/arm/tcg/a64.decode | ||
24 | 22 | ||
25 | diff --git a/tests/qtest/npcm7xx_rng-test.c b/tests/qtest/npcm7xx_rng-test.c | 23 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
24 | new file mode 100644 | ||
25 | index XXXXXXX..XXXXXXX | ||
26 | --- /dev/null | ||
27 | +++ b/target/arm/tcg/a64.decode | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | +# AArch64 A64 allowed instruction decoding | ||
30 | +# | ||
31 | +# Copyright (c) 2023 Linaro, Ltd | ||
32 | +# | ||
33 | +# This library is free software; you can redistribute it and/or | ||
34 | +# modify it under the terms of the GNU Lesser General Public | ||
35 | +# License as published by the Free Software Foundation; either | ||
36 | +# version 2.1 of the License, or (at your option) any later version. | ||
37 | +# | ||
38 | +# This library is distributed in the hope that it will be useful, | ||
39 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
40 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
41 | +# Lesser General Public License for more details. | ||
42 | +# | ||
43 | +# You should have received a copy of the GNU Lesser General Public | ||
44 | +# License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
45 | + | ||
46 | +# | ||
47 | +# This file is processed by scripts/decodetree.py | ||
48 | +# | ||
49 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | 50 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/tests/qtest/npcm7xx_rng-test.c | 51 | --- a/target/arm/tcg/translate-a64.c |
28 | +++ b/tests/qtest/npcm7xx_rng-test.c | 52 | +++ b/target/arm/tcg/translate-a64.c |
29 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | 53 | @@ -XXX,XX +XXX,XX @@ enum a64_shift_type { |
30 | 54 | A64_SHIFT_TYPE_ROR = 3 | |
31 | qtest_add_func("npcm7xx_rng/enable_disable", test_enable_disable); | 55 | }; |
32 | qtest_add_func("npcm7xx_rng/rosel", test_rosel); | 56 | |
33 | - qtest_add_func("npcm7xx_rng/continuous/monobit", test_continuous_monobit); | 57 | +/* |
34 | - qtest_add_func("npcm7xx_rng/continuous/runs", test_continuous_runs); | 58 | + * Include the generated decoders. |
35 | - qtest_add_func("npcm7xx_rng/first_byte/monobit", test_first_byte_monobit); | 59 | + */ |
36 | - qtest_add_func("npcm7xx_rng/first_byte/runs", test_first_byte_runs); | 60 | + |
37 | + /* | 61 | +#include "decode-sme-fa64.c.inc" |
38 | + * These tests fail intermittently; only run them on explicit | 62 | +#include "decode-a64.c.inc" |
39 | + * request until we figure out why. | 63 | + |
40 | + */ | 64 | /* Table based decoder typedefs - used when the relevant bits for decode |
41 | + if (getenv("QEMU_TEST_FLAKY_RNG_TESTS")) { | 65 | * are too awkwardly scattered across the instruction (eg SIMD). |
42 | + qtest_add_func("npcm7xx_rng/continuous/monobit", test_continuous_monobit); | 66 | */ |
43 | + qtest_add_func("npcm7xx_rng/continuous/runs", test_continuous_runs); | 67 | @@ -XXX,XX +XXX,XX @@ static void disas_data_proc_simd_fp(DisasContext *s, uint32_t insn) |
44 | + qtest_add_func("npcm7xx_rng/first_byte/monobit", test_first_byte_monobit); | 68 | } |
45 | + qtest_add_func("npcm7xx_rng/first_byte/runs", test_first_byte_runs); | 69 | } |
70 | |||
71 | -/* | ||
72 | - * Include the generated SME FA64 decoder. | ||
73 | - */ | ||
74 | - | ||
75 | -#include "decode-sme-fa64.c.inc" | ||
76 | - | ||
77 | static bool trans_OK(DisasContext *s, arg_OK *a) | ||
78 | { | ||
79 | return true; | ||
80 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
81 | disas_sme_fa64(s, insn); | ||
82 | } | ||
83 | |||
84 | - disas_a64_legacy(s, insn); | ||
85 | + | ||
86 | + if (!disas_a64(s, insn)) { | ||
87 | + disas_a64_legacy(s, insn); | ||
46 | + } | 88 | + } |
47 | 89 | ||
48 | qtest_start("-machine npcm750-evb"); | 90 | /* |
49 | ret = g_test_run(); | 91 | * After execution of most insns, btype is reset to 0. |
92 | diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/tcg/meson.build | ||
95 | +++ b/target/arm/tcg/meson.build | ||
96 | @@ -XXX,XX +XXX,XX @@ gen = [ | ||
97 | decodetree.process('a32-uncond.decode', extra_args: '--static-decode=disas_a32_uncond'), | ||
98 | decodetree.process('t32.decode', extra_args: '--static-decode=disas_t32'), | ||
99 | decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-decode=disas_t16']), | ||
100 | + decodetree.process('a64.decode', extra_args: ['--static-decode=disas_a64']), | ||
101 | ] | ||
102 | |||
103 | arm_ss.add(gen) | ||
50 | -- | 104 | -- |
51 | 2.20.1 | 105 | 2.34.1 |
52 | |||
53 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The SVE and SME decode is already done by decodetree. Pull the calls | ||
2 | to these decoders out of the legacy decoder. This doesn't change | ||
3 | behaviour because all the patterns in sve.decode and sme.decode | ||
4 | already require the bits that the legacy decoder is decoding to have | ||
5 | the correct values. | ||
1 | 6 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20230512144106.3608981-4-peter.maydell@linaro.org | ||
10 | --- | ||
11 | target/arm/tcg/translate-a64.c | 20 ++++---------------- | ||
12 | 1 file changed, 4 insertions(+), 16 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/tcg/translate-a64.c | ||
17 | +++ b/target/arm/tcg/translate-a64.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static bool btype_destination_ok(uint32_t insn, bool bt, int btype) | ||
19 | static void disas_a64_legacy(DisasContext *s, uint32_t insn) | ||
20 | { | ||
21 | switch (extract32(insn, 25, 4)) { | ||
22 | - case 0x0: | ||
23 | - if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) { | ||
24 | - unallocated_encoding(s); | ||
25 | - } | ||
26 | - break; | ||
27 | - case 0x1: case 0x3: /* UNALLOCATED */ | ||
28 | - unallocated_encoding(s); | ||
29 | - break; | ||
30 | - case 0x2: | ||
31 | - if (!disas_sve(s, insn)) { | ||
32 | - unallocated_encoding(s); | ||
33 | - } | ||
34 | - break; | ||
35 | case 0x8: case 0x9: /* Data processing - immediate */ | ||
36 | disas_data_proc_imm(s, insn); | ||
37 | break; | ||
38 | @@ -XXX,XX +XXX,XX @@ static void disas_a64_legacy(DisasContext *s, uint32_t insn) | ||
39 | disas_data_proc_simd_fp(s, insn); | ||
40 | break; | ||
41 | default: | ||
42 | - assert(FALSE); /* all 15 cases should be handled above */ | ||
43 | + unallocated_encoding(s); | ||
44 | break; | ||
45 | } | ||
46 | } | ||
47 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
48 | disas_sme_fa64(s, insn); | ||
49 | } | ||
50 | |||
51 | - | ||
52 | - if (!disas_a64(s, insn)) { | ||
53 | + if (!disas_a64(s, insn) && | ||
54 | + !disas_sme(s, insn) && | ||
55 | + !disas_sve(s, insn)) { | ||
56 | disas_a64_legacy(s, insn); | ||
57 | } | ||
58 | |||
59 | -- | ||
60 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The only uses of this function are for loading VFP | 3 | Convert the ADR and ADRP instructions. |
4 | double-precision values, and nothing to do with NEON. | ||
5 | 4 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20201030022618.785675-10-richard.henderson@linaro.org | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20230512144106.3608981-5-peter.maydell@linaro.org | ||
9 | [PMM: Rebased] | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | target/arm/translate.c | 8 ++-- | 13 | target/arm/tcg/a64.decode | 13 ++++++++++++ |
12 | target/arm/translate-vfp.c.inc | 84 +++++++++++++++++----------------- | 14 | target/arm/tcg/translate-a64.c | 38 +++++++++++++--------------------- |
13 | 2 files changed, 46 insertions(+), 46 deletions(-) | 15 | 2 files changed, 27 insertions(+), 24 deletions(-) |
14 | 16 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 17 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 19 | --- a/target/arm/tcg/a64.decode |
18 | +++ b/target/arm/translate.c | 20 | +++ b/target/arm/tcg/a64.decode |
19 | @@ -XXX,XX +XXX,XX @@ static long vfp_reg_offset(bool dp, unsigned reg) | 21 | @@ -XXX,XX +XXX,XX @@ |
22 | # | ||
23 | # This file is processed by scripts/decodetree.py | ||
24 | # | ||
25 | + | ||
26 | +&ri rd imm | ||
27 | + | ||
28 | + | ||
29 | +### Data Processing - Immediate | ||
30 | + | ||
31 | +# PC-rel addressing | ||
32 | + | ||
33 | +%imm_pcrel 5:s19 29:2 | ||
34 | +@pcrel . .. ..... ................... rd:5 &ri imm=%imm_pcrel | ||
35 | + | ||
36 | +ADR 0 .. 10000 ................... ..... @pcrel | ||
37 | +ADRP 1 .. 10000 ................... ..... @pcrel | ||
38 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/tcg/translate-a64.c | ||
41 | +++ b/target/arm/tcg/translate-a64.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst(DisasContext *s, uint32_t insn) | ||
20 | } | 43 | } |
21 | } | 44 | } |
22 | 45 | ||
23 | -static inline void neon_load_reg64(TCGv_i64 var, int reg) | 46 | -/* PC-rel. addressing |
24 | +static inline void vfp_load_reg64(TCGv_i64 var, int reg) | 47 | - * 31 30 29 28 24 23 5 4 0 |
48 | - * +----+-------+-----------+-------------------+------+ | ||
49 | - * | op | immlo | 1 0 0 0 0 | immhi | Rd | | ||
50 | - * +----+-------+-----------+-------------------+------+ | ||
51 | +/* | ||
52 | + * PC-rel. addressing | ||
53 | */ | ||
54 | -static void disas_pc_rel_adr(DisasContext *s, uint32_t insn) | ||
55 | + | ||
56 | +static bool trans_ADR(DisasContext *s, arg_ri *a) | ||
25 | { | 57 | { |
26 | - tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg)); | 58 | - unsigned int page, rd; |
27 | + tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(true, reg)); | 59 | - int64_t offset; |
60 | + gen_pc_plus_diff(s, cpu_reg(s, a->rd), a->imm); | ||
61 | + return true; | ||
62 | +} | ||
63 | |||
64 | - page = extract32(insn, 31, 1); | ||
65 | - /* SignExtend(immhi:immlo) -> offset */ | ||
66 | - offset = sextract64(insn, 5, 19); | ||
67 | - offset = offset << 2 | extract32(insn, 29, 2); | ||
68 | - rd = extract32(insn, 0, 5); | ||
69 | +static bool trans_ADRP(DisasContext *s, arg_ri *a) | ||
70 | +{ | ||
71 | + int64_t offset = (int64_t)a->imm << 12; | ||
72 | |||
73 | - if (page) { | ||
74 | - /* ADRP (page based) */ | ||
75 | - offset <<= 12; | ||
76 | - /* The page offset is ok for CF_PCREL. */ | ||
77 | - offset -= s->pc_curr & 0xfff; | ||
78 | - } | ||
79 | - | ||
80 | - gen_pc_plus_diff(s, cpu_reg(s, rd), offset); | ||
81 | + /* The page offset is ok for CF_PCREL. */ | ||
82 | + offset -= s->pc_curr & 0xfff; | ||
83 | + gen_pc_plus_diff(s, cpu_reg(s, a->rd), offset); | ||
84 | + return true; | ||
28 | } | 85 | } |
29 | 86 | ||
30 | -static inline void neon_store_reg64(TCGv_i64 var, int reg) | 87 | /* |
31 | +static inline void vfp_store_reg64(TCGv_i64 var, int reg) | 88 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) |
89 | static void disas_data_proc_imm(DisasContext *s, uint32_t insn) | ||
32 | { | 90 | { |
33 | - tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(1, reg)); | 91 | switch (extract32(insn, 23, 6)) { |
34 | + tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(true, reg)); | 92 | - case 0x20: case 0x21: /* PC-rel. addressing */ |
35 | } | 93 | - disas_pc_rel_adr(s, insn); |
36 | 94 | - break; | |
37 | static inline void vfp_load_reg32(TCGv_i32 var, int reg) | 95 | case 0x22: /* Add/subtract (immediate) */ |
38 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | 96 | disas_add_sub_imm(s, insn); |
39 | index XXXXXXX..XXXXXXX 100644 | 97 | break; |
40 | --- a/target/arm/translate-vfp.c.inc | ||
41 | +++ b/target/arm/translate-vfp.c.inc | ||
42 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
43 | tcg_gen_ext_i32_i64(nf, cpu_NF); | ||
44 | tcg_gen_ext_i32_i64(vf, cpu_VF); | ||
45 | |||
46 | - neon_load_reg64(frn, rn); | ||
47 | - neon_load_reg64(frm, rm); | ||
48 | + vfp_load_reg64(frn, rn); | ||
49 | + vfp_load_reg64(frm, rm); | ||
50 | switch (a->cc) { | ||
51 | case 0: /* eq: Z */ | ||
52 | tcg_gen_movcond_i64(TCG_COND_EQ, dest, zf, zero, | ||
53 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *a) | ||
54 | tcg_temp_free_i64(tmp); | ||
55 | break; | ||
56 | } | ||
57 | - neon_store_reg64(dest, rd); | ||
58 | + vfp_store_reg64(dest, rd); | ||
59 | tcg_temp_free_i64(frn); | ||
60 | tcg_temp_free_i64(frm); | ||
61 | tcg_temp_free_i64(dest); | ||
62 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINT(DisasContext *s, arg_VRINT *a) | ||
63 | TCGv_i64 tcg_res; | ||
64 | tcg_op = tcg_temp_new_i64(); | ||
65 | tcg_res = tcg_temp_new_i64(); | ||
66 | - neon_load_reg64(tcg_op, rm); | ||
67 | + vfp_load_reg64(tcg_op, rm); | ||
68 | gen_helper_rintd(tcg_res, tcg_op, fpst); | ||
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 | -- | 98 | -- |
345 | 2.20.1 | 99 | 2.34.1 |
346 | |||
347 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We can then use this to improve VMOV (scalar to gp) and | 3 | Split out specific 32-bit and 64-bit functions. |
4 | VMOV (gp to scalar) so that we simply perform the memory | 4 | These carry the same signature as tcg_gen_add_i64, |
5 | operation that we wanted, rather than inserting or | 5 | and so will be easier to pass as callbacks. |
6 | extracting from a 32-bit quantity. | ||
7 | 6 | ||
8 | These were the last uses of neon_load/store_reg, so remove them. | 7 | Retain gen_add_CC and gen_sub_CC during conversion. |
9 | 8 | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20201030022618.785675-7-richard.henderson@linaro.org | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Message-id: 20230512144106.3608981-6-peter.maydell@linaro.org | ||
13 | [PMM: rebased] | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 16 | --- |
15 | target/arm/translate.c | 50 +++++++++++++----------- | 17 | target/arm/tcg/translate-a64.c | 149 +++++++++++++++++++-------------- |
16 | target/arm/translate-vfp.c.inc | 71 +++++----------------------------- | 18 | 1 file changed, 84 insertions(+), 65 deletions(-) |
17 | 2 files changed, 37 insertions(+), 84 deletions(-) | ||
18 | 19 | ||
19 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 20 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
20 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/translate.c | 22 | --- a/target/arm/tcg/translate-a64.c |
22 | +++ b/target/arm/translate.c | 23 | +++ b/target/arm/tcg/translate-a64.c |
23 | @@ -XXX,XX +XXX,XX @@ static long neon_full_reg_offset(unsigned reg) | 24 | @@ -XXX,XX +XXX,XX @@ static inline void gen_logic_CC(int sf, TCGv_i64 result) |
24 | * Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | 25 | } |
25 | * where 0 is the least significant end of the register. | 26 | |
26 | */ | 27 | /* dest = T0 + T1; compute C, N, V and Z flags */ |
27 | -static long neon_element_offset(int reg, int element, MemOp size) | 28 | +static void gen_add64_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) |
28 | +static long neon_element_offset(int reg, int element, MemOp memop) | 29 | +{ |
30 | + TCGv_i64 result, flag, tmp; | ||
31 | + result = tcg_temp_new_i64(); | ||
32 | + flag = tcg_temp_new_i64(); | ||
33 | + tmp = tcg_temp_new_i64(); | ||
34 | + | ||
35 | + tcg_gen_movi_i64(tmp, 0); | ||
36 | + tcg_gen_add2_i64(result, flag, t0, tmp, t1, tmp); | ||
37 | + | ||
38 | + tcg_gen_extrl_i64_i32(cpu_CF, flag); | ||
39 | + | ||
40 | + gen_set_NZ64(result); | ||
41 | + | ||
42 | + tcg_gen_xor_i64(flag, result, t0); | ||
43 | + tcg_gen_xor_i64(tmp, t0, t1); | ||
44 | + tcg_gen_andc_i64(flag, flag, tmp); | ||
45 | + tcg_gen_extrh_i64_i32(cpu_VF, flag); | ||
46 | + | ||
47 | + tcg_gen_mov_i64(dest, result); | ||
48 | +} | ||
49 | + | ||
50 | +static void gen_add32_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) | ||
51 | +{ | ||
52 | + TCGv_i32 t0_32 = tcg_temp_new_i32(); | ||
53 | + TCGv_i32 t1_32 = tcg_temp_new_i32(); | ||
54 | + TCGv_i32 tmp = tcg_temp_new_i32(); | ||
55 | + | ||
56 | + tcg_gen_movi_i32(tmp, 0); | ||
57 | + tcg_gen_extrl_i64_i32(t0_32, t0); | ||
58 | + tcg_gen_extrl_i64_i32(t1_32, t1); | ||
59 | + tcg_gen_add2_i32(cpu_NF, cpu_CF, t0_32, tmp, t1_32, tmp); | ||
60 | + tcg_gen_mov_i32(cpu_ZF, cpu_NF); | ||
61 | + tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); | ||
62 | + tcg_gen_xor_i32(tmp, t0_32, t1_32); | ||
63 | + tcg_gen_andc_i32(cpu_VF, cpu_VF, tmp); | ||
64 | + tcg_gen_extu_i32_i64(dest, cpu_NF); | ||
65 | +} | ||
66 | + | ||
67 | static void gen_add_CC(int sf, TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) | ||
29 | { | 68 | { |
30 | - int element_size = 1 << size; | 69 | if (sf) { |
31 | + int element_size = 1 << (memop & MO_SIZE); | 70 | - TCGv_i64 result, flag, tmp; |
32 | int ofs = element * element_size; | 71 | - result = tcg_temp_new_i64(); |
33 | #ifdef HOST_WORDS_BIGENDIAN | 72 | - flag = tcg_temp_new_i64(); |
34 | /* | 73 | - tmp = tcg_temp_new_i64(); |
35 | @@ -XXX,XX +XXX,XX @@ static long vfp_reg_offset(bool dp, unsigned reg) | 74 | - |
75 | - tcg_gen_movi_i64(tmp, 0); | ||
76 | - tcg_gen_add2_i64(result, flag, t0, tmp, t1, tmp); | ||
77 | - | ||
78 | - tcg_gen_extrl_i64_i32(cpu_CF, flag); | ||
79 | - | ||
80 | - gen_set_NZ64(result); | ||
81 | - | ||
82 | - tcg_gen_xor_i64(flag, result, t0); | ||
83 | - tcg_gen_xor_i64(tmp, t0, t1); | ||
84 | - tcg_gen_andc_i64(flag, flag, tmp); | ||
85 | - tcg_gen_extrh_i64_i32(cpu_VF, flag); | ||
86 | - | ||
87 | - tcg_gen_mov_i64(dest, result); | ||
88 | + gen_add64_CC(dest, t0, t1); | ||
89 | } else { | ||
90 | - /* 32 bit arithmetic */ | ||
91 | - TCGv_i32 t0_32 = tcg_temp_new_i32(); | ||
92 | - TCGv_i32 t1_32 = tcg_temp_new_i32(); | ||
93 | - TCGv_i32 tmp = tcg_temp_new_i32(); | ||
94 | - | ||
95 | - tcg_gen_movi_i32(tmp, 0); | ||
96 | - tcg_gen_extrl_i64_i32(t0_32, t0); | ||
97 | - tcg_gen_extrl_i64_i32(t1_32, t1); | ||
98 | - tcg_gen_add2_i32(cpu_NF, cpu_CF, t0_32, tmp, t1_32, tmp); | ||
99 | - tcg_gen_mov_i32(cpu_ZF, cpu_NF); | ||
100 | - tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); | ||
101 | - tcg_gen_xor_i32(tmp, t0_32, t1_32); | ||
102 | - tcg_gen_andc_i32(cpu_VF, cpu_VF, tmp); | ||
103 | - tcg_gen_extu_i32_i64(dest, cpu_NF); | ||
104 | + gen_add32_CC(dest, t0, t1); | ||
36 | } | 105 | } |
37 | } | 106 | } |
38 | 107 | ||
39 | -static TCGv_i32 neon_load_reg(int reg, int pass) | 108 | /* dest = T0 - T1; compute C, N, V and Z flags */ |
40 | -{ | 109 | +static void gen_sub64_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) |
41 | - TCGv_i32 tmp = tcg_temp_new_i32(); | 110 | +{ |
42 | - tcg_gen_ld_i32(tmp, cpu_env, neon_element_offset(reg, pass, MO_32)); | 111 | + /* 64 bit arithmetic */ |
43 | - return tmp; | 112 | + TCGv_i64 result, flag, tmp; |
44 | -} | 113 | + |
114 | + result = tcg_temp_new_i64(); | ||
115 | + flag = tcg_temp_new_i64(); | ||
116 | + tcg_gen_sub_i64(result, t0, t1); | ||
117 | + | ||
118 | + gen_set_NZ64(result); | ||
119 | + | ||
120 | + tcg_gen_setcond_i64(TCG_COND_GEU, flag, t0, t1); | ||
121 | + tcg_gen_extrl_i64_i32(cpu_CF, flag); | ||
122 | + | ||
123 | + tcg_gen_xor_i64(flag, result, t0); | ||
124 | + tmp = tcg_temp_new_i64(); | ||
125 | + tcg_gen_xor_i64(tmp, t0, t1); | ||
126 | + tcg_gen_and_i64(flag, flag, tmp); | ||
127 | + tcg_gen_extrh_i64_i32(cpu_VF, flag); | ||
128 | + tcg_gen_mov_i64(dest, result); | ||
129 | +} | ||
130 | + | ||
131 | +static void gen_sub32_CC(TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) | ||
132 | +{ | ||
133 | + /* 32 bit arithmetic */ | ||
134 | + TCGv_i32 t0_32 = tcg_temp_new_i32(); | ||
135 | + TCGv_i32 t1_32 = tcg_temp_new_i32(); | ||
136 | + TCGv_i32 tmp; | ||
137 | + | ||
138 | + tcg_gen_extrl_i64_i32(t0_32, t0); | ||
139 | + tcg_gen_extrl_i64_i32(t1_32, t1); | ||
140 | + tcg_gen_sub_i32(cpu_NF, t0_32, t1_32); | ||
141 | + tcg_gen_mov_i32(cpu_ZF, cpu_NF); | ||
142 | + tcg_gen_setcond_i32(TCG_COND_GEU, cpu_CF, t0_32, t1_32); | ||
143 | + tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); | ||
144 | + tmp = tcg_temp_new_i32(); | ||
145 | + tcg_gen_xor_i32(tmp, t0_32, t1_32); | ||
146 | + tcg_gen_and_i32(cpu_VF, cpu_VF, tmp); | ||
147 | + tcg_gen_extu_i32_i64(dest, cpu_NF); | ||
148 | +} | ||
149 | + | ||
150 | static void gen_sub_CC(int sf, TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) | ||
151 | { | ||
152 | if (sf) { | ||
153 | - /* 64 bit arithmetic */ | ||
154 | - TCGv_i64 result, flag, tmp; | ||
45 | - | 155 | - |
46 | -static void neon_store_reg(int reg, int pass, TCGv_i32 var) | 156 | - result = tcg_temp_new_i64(); |
47 | -{ | 157 | - flag = tcg_temp_new_i64(); |
48 | - tcg_gen_st_i32(var, cpu_env, neon_element_offset(reg, pass, MO_32)); | 158 | - tcg_gen_sub_i64(result, t0, t1); |
49 | - tcg_temp_free_i32(var); | ||
50 | -} | ||
51 | - | 159 | - |
52 | static inline void neon_load_reg64(TCGv_i64 var, int reg) | 160 | - gen_set_NZ64(result); |
53 | { | 161 | - |
54 | tcg_gen_ld_i64(var, cpu_env, vfp_reg_offset(1, reg)); | 162 | - tcg_gen_setcond_i64(TCG_COND_GEU, flag, t0, t1); |
55 | @@ -XXX,XX +XXX,XX @@ static inline void neon_store_reg32(TCGv_i32 var, int reg) | 163 | - tcg_gen_extrl_i64_i32(cpu_CF, flag); |
56 | tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); | 164 | - |
57 | } | 165 | - tcg_gen_xor_i64(flag, result, t0); |
58 | 166 | - tmp = tcg_temp_new_i64(); | |
59 | -static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp size) | 167 | - tcg_gen_xor_i64(tmp, t0, t1); |
60 | +static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop) | 168 | - tcg_gen_and_i64(flag, flag, tmp); |
61 | { | 169 | - tcg_gen_extrh_i64_i32(cpu_VF, flag); |
62 | - long off = neon_element_offset(reg, ele, size); | 170 | - tcg_gen_mov_i64(dest, result); |
63 | + long off = neon_element_offset(reg, ele, memop); | 171 | + gen_sub64_CC(dest, t0, t1); |
64 | 172 | } else { | |
65 | - switch (size) { | 173 | - /* 32 bit arithmetic */ |
66 | - case MO_32: | 174 | - TCGv_i32 t0_32 = tcg_temp_new_i32(); |
67 | + switch (memop) { | 175 | - TCGv_i32 t1_32 = tcg_temp_new_i32(); |
68 | + case MO_SB: | 176 | - TCGv_i32 tmp; |
69 | + tcg_gen_ld8s_i32(dest, cpu_env, off); | 177 | - |
70 | + break; | 178 | - tcg_gen_extrl_i64_i32(t0_32, t0); |
71 | + case MO_UB: | 179 | - tcg_gen_extrl_i64_i32(t1_32, t1); |
72 | + tcg_gen_ld8u_i32(dest, cpu_env, off); | 180 | - tcg_gen_sub_i32(cpu_NF, t0_32, t1_32); |
73 | + break; | 181 | - tcg_gen_mov_i32(cpu_ZF, cpu_NF); |
74 | + case MO_SW: | 182 | - tcg_gen_setcond_i32(TCG_COND_GEU, cpu_CF, t0_32, t1_32); |
75 | + tcg_gen_ld16s_i32(dest, cpu_env, off); | 183 | - tcg_gen_xor_i32(cpu_VF, cpu_NF, t0_32); |
76 | + break; | 184 | - tmp = tcg_temp_new_i32(); |
77 | + case MO_UW: | 185 | - tcg_gen_xor_i32(tmp, t0_32, t1_32); |
78 | + tcg_gen_ld16u_i32(dest, cpu_env, off); | 186 | - tcg_gen_and_i32(cpu_VF, cpu_VF, tmp); |
79 | + break; | 187 | - tcg_gen_extu_i32_i64(dest, cpu_NF); |
80 | + case MO_UL: | 188 | + gen_sub32_CC(dest, t0, t1); |
81 | + case MO_SL: | ||
82 | tcg_gen_ld_i32(dest, cpu_env, off); | ||
83 | break; | ||
84 | default: | ||
85 | @@ -XXX,XX +XXX,XX @@ static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp size) | ||
86 | } | 189 | } |
87 | } | 190 | } |
88 | 191 | ||
89 | -static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp size) | ||
90 | +static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop) | ||
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 | ||
107 | index XXXXXXX..XXXXXXX 100644 | ||
108 | --- a/target/arm/translate-vfp.c.inc | ||
109 | +++ 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) | ||
111 | { | ||
112 | /* VMOV scalar to general purpose register */ | ||
113 | TCGv_i32 tmp; | ||
114 | - int pass; | ||
115 | - uint32_t offset; | ||
116 | |||
117 | - /* SIZE == 2 is a VFP instruction; otherwise NEON. */ | ||
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 | } | ||
220 | -- | 192 | -- |
221 | 2.20.1 | 193 | 2.34.1 |
222 | |||
223 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This seems a bit more readable than using offsetof CPU_DoubleU. | 3 | Convert the ADD and SUB (immediate) instructions. |
4 | 4 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20201030022618.785675-5-richard.henderson@linaro.org | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20230512144106.3608981-7-peter.maydell@linaro.org | ||
9 | [PMM: Rebased; adjusted to use translate.h's TRANS macro] | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 12 | --- |
10 | target/arm/translate.c | 13 ++++--------- | 13 | target/arm/tcg/translate.h | 5 +++ |
11 | 1 file changed, 4 insertions(+), 9 deletions(-) | 14 | target/arm/tcg/a64.decode | 17 ++++++++ |
15 | target/arm/tcg/translate-a64.c | 73 ++++++++++------------------------ | ||
16 | 3 files changed, 42 insertions(+), 53 deletions(-) | ||
12 | 17 | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 18 | diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h |
14 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 20 | --- a/target/arm/tcg/translate.h |
16 | +++ b/target/arm/translate.c | 21 | +++ b/target/arm/tcg/translate.h |
17 | @@ -XXX,XX +XXX,XX @@ static long neon_element_offset(int reg, int element, MemOp size) | 22 | @@ -XXX,XX +XXX,XX @@ static inline int rsub_8(DisasContext *s, int x) |
18 | return neon_full_reg_offset(reg) + ofs; | 23 | return 8 - x; |
19 | } | 24 | } |
20 | 25 | ||
21 | -static inline long vfp_reg_offset(bool dp, unsigned reg) | 26 | +static inline int shl_12(DisasContext *s, int x) |
22 | +/* Return the offset of a VFP Dreg (dp = true) or VFP Sreg (dp = false). */ | 27 | +{ |
23 | +static long vfp_reg_offset(bool dp, unsigned reg) | 28 | + return x << 12; |
29 | +} | ||
30 | + | ||
31 | static inline int neon_3same_fp_size(DisasContext *s, int x) | ||
24 | { | 32 | { |
25 | if (dp) { | 33 | /* Convert 0==fp32, 1==fp16 into a MO_* value */ |
26 | - return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]); | 34 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
27 | + return neon_element_offset(reg, 0, MO_64); | 35 | index XXXXXXX..XXXXXXX 100644 |
28 | } else { | 36 | --- a/target/arm/tcg/a64.decode |
29 | - long ofs = offsetof(CPUARMState, vfp.zregs[reg >> 2].d[(reg >> 1) & 1]); | 37 | +++ b/target/arm/tcg/a64.decode |
30 | - if (reg & 1) { | 38 | @@ -XXX,XX +XXX,XX @@ |
31 | - ofs += offsetof(CPU_DoubleU, l.upper); | 39 | # |
32 | - } else { | 40 | |
33 | - ofs += offsetof(CPU_DoubleU, l.lower); | 41 | &ri rd imm |
34 | - } | 42 | +&rri_sf rd rn imm sf |
35 | - return ofs; | 43 | |
36 | + return neon_element_offset(reg >> 1, reg & 1, MO_32); | 44 | |
45 | ### Data Processing - Immediate | ||
46 | @@ -XXX,XX +XXX,XX @@ | ||
47 | |||
48 | ADR 0 .. 10000 ................... ..... @pcrel | ||
49 | ADRP 1 .. 10000 ................... ..... @pcrel | ||
50 | + | ||
51 | +# Add/subtract (immediate) | ||
52 | + | ||
53 | +%imm12_sh12 10:12 !function=shl_12 | ||
54 | +@addsub_imm sf:1 .. ...... . imm:12 rn:5 rd:5 | ||
55 | +@addsub_imm12 sf:1 .. ...... . ............ rn:5 rd:5 imm=%imm12_sh12 | ||
56 | + | ||
57 | +ADD_i . 00 100010 0 ............ ..... ..... @addsub_imm | ||
58 | +ADD_i . 00 100010 1 ............ ..... ..... @addsub_imm12 | ||
59 | +ADDS_i . 01 100010 0 ............ ..... ..... @addsub_imm | ||
60 | +ADDS_i . 01 100010 1 ............ ..... ..... @addsub_imm12 | ||
61 | + | ||
62 | +SUB_i . 10 100010 0 ............ ..... ..... @addsub_imm | ||
63 | +SUB_i . 10 100010 1 ............ ..... ..... @addsub_imm12 | ||
64 | +SUBS_i . 11 100010 0 ............ ..... ..... @addsub_imm | ||
65 | +SUBS_i . 11 100010 1 ............ ..... ..... @addsub_imm12 | ||
66 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/target/arm/tcg/translate-a64.c | ||
69 | +++ b/target/arm/tcg/translate-a64.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst(DisasContext *s, uint32_t insn) | ||
37 | } | 71 | } |
38 | } | 72 | } |
39 | 73 | ||
74 | +typedef void ArithTwoOp(TCGv_i64, TCGv_i64, TCGv_i64); | ||
75 | + | ||
76 | +static bool gen_rri(DisasContext *s, arg_rri_sf *a, | ||
77 | + bool rd_sp, bool rn_sp, ArithTwoOp *fn) | ||
78 | +{ | ||
79 | + TCGv_i64 tcg_rn = rn_sp ? cpu_reg_sp(s, a->rn) : cpu_reg(s, a->rn); | ||
80 | + TCGv_i64 tcg_rd = rd_sp ? cpu_reg_sp(s, a->rd) : cpu_reg(s, a->rd); | ||
81 | + TCGv_i64 tcg_imm = tcg_constant_i64(a->imm); | ||
82 | + | ||
83 | + fn(tcg_rd, tcg_rn, tcg_imm); | ||
84 | + if (!a->sf) { | ||
85 | + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); | ||
86 | + } | ||
87 | + return true; | ||
88 | +} | ||
89 | + | ||
90 | /* | ||
91 | * PC-rel. addressing | ||
92 | */ | ||
93 | @@ -XXX,XX +XXX,XX @@ static bool trans_ADRP(DisasContext *s, arg_ri *a) | ||
94 | |||
95 | /* | ||
96 | * Add/subtract (immediate) | ||
97 | - * | ||
98 | - * 31 30 29 28 23 22 21 10 9 5 4 0 | ||
99 | - * +--+--+--+-------------+--+-------------+-----+-----+ | ||
100 | - * |sf|op| S| 1 0 0 0 1 0 |sh| imm12 | Rn | Rd | | ||
101 | - * +--+--+--+-------------+--+-------------+-----+-----+ | ||
102 | - * | ||
103 | - * sf: 0 -> 32bit, 1 -> 64bit | ||
104 | - * op: 0 -> add , 1 -> sub | ||
105 | - * S: 1 -> set flags | ||
106 | - * sh: 1 -> LSL imm by 12 | ||
107 | */ | ||
108 | -static void disas_add_sub_imm(DisasContext *s, uint32_t insn) | ||
109 | -{ | ||
110 | - int rd = extract32(insn, 0, 5); | ||
111 | - int rn = extract32(insn, 5, 5); | ||
112 | - uint64_t imm = extract32(insn, 10, 12); | ||
113 | - bool shift = extract32(insn, 22, 1); | ||
114 | - bool setflags = extract32(insn, 29, 1); | ||
115 | - bool sub_op = extract32(insn, 30, 1); | ||
116 | - bool is_64bit = extract32(insn, 31, 1); | ||
117 | - | ||
118 | - TCGv_i64 tcg_rn = cpu_reg_sp(s, rn); | ||
119 | - TCGv_i64 tcg_rd = setflags ? cpu_reg(s, rd) : cpu_reg_sp(s, rd); | ||
120 | - TCGv_i64 tcg_result; | ||
121 | - | ||
122 | - if (shift) { | ||
123 | - imm <<= 12; | ||
124 | - } | ||
125 | - | ||
126 | - tcg_result = tcg_temp_new_i64(); | ||
127 | - if (!setflags) { | ||
128 | - if (sub_op) { | ||
129 | - tcg_gen_subi_i64(tcg_result, tcg_rn, imm); | ||
130 | - } else { | ||
131 | - tcg_gen_addi_i64(tcg_result, tcg_rn, imm); | ||
132 | - } | ||
133 | - } else { | ||
134 | - TCGv_i64 tcg_imm = tcg_constant_i64(imm); | ||
135 | - if (sub_op) { | ||
136 | - gen_sub_CC(is_64bit, tcg_result, tcg_rn, tcg_imm); | ||
137 | - } else { | ||
138 | - gen_add_CC(is_64bit, tcg_result, tcg_rn, tcg_imm); | ||
139 | - } | ||
140 | - } | ||
141 | - | ||
142 | - if (is_64bit) { | ||
143 | - tcg_gen_mov_i64(tcg_rd, tcg_result); | ||
144 | - } else { | ||
145 | - tcg_gen_ext32u_i64(tcg_rd, tcg_result); | ||
146 | - } | ||
147 | -} | ||
148 | +TRANS(ADD_i, gen_rri, a, 1, 1, tcg_gen_add_i64) | ||
149 | +TRANS(SUB_i, gen_rri, a, 1, 1, tcg_gen_sub_i64) | ||
150 | +TRANS(ADDS_i, gen_rri, a, 0, 1, a->sf ? gen_add64_CC : gen_add32_CC) | ||
151 | +TRANS(SUBS_i, gen_rri, a, 0, 1, a->sf ? gen_sub64_CC : gen_sub32_CC) | ||
152 | |||
153 | /* | ||
154 | * Add/subtract (immediate, with tags) | ||
155 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) | ||
156 | static void disas_data_proc_imm(DisasContext *s, uint32_t insn) | ||
157 | { | ||
158 | switch (extract32(insn, 23, 6)) { | ||
159 | - case 0x22: /* Add/subtract (immediate) */ | ||
160 | - disas_add_sub_imm(s, insn); | ||
161 | - break; | ||
162 | case 0x23: /* Add/subtract (immediate, with tags) */ | ||
163 | disas_add_sub_imm_with_tags(s, insn); | ||
164 | break; | ||
40 | -- | 165 | -- |
41 | 2.20.1 | 166 | 2.34.1 |
42 | |||
43 | 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 | Convert the ADDG and SUBG (immediate) instructions. |
4 | the accumulate into the normal destination temps. | ||
5 | 4 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20201030022618.785675-11-richard.henderson@linaro.org | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20230512144106.3608981-8-peter.maydell@linaro.org | ||
9 | [PMM: Rebased; use TRANS_FEAT()] | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | target/arm/translate-neon.c.inc | 23 +++++++++-------------- | 13 | target/arm/tcg/a64.decode | 8 +++++++ |
12 | 1 file changed, 9 insertions(+), 14 deletions(-) | 14 | target/arm/tcg/translate-a64.c | 38 ++++++++++------------------------ |
15 | 2 files changed, 19 insertions(+), 27 deletions(-) | ||
13 | 16 | ||
14 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 17 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-neon.c.inc | 19 | --- a/target/arm/tcg/a64.decode |
17 | +++ b/target/arm/translate-neon.c.inc | 20 | +++ b/target/arm/tcg/a64.decode |
18 | @@ -XXX,XX +XXX,XX @@ static bool do_long_3d(DisasContext *s, arg_3diff *a, | 21 | @@ -XXX,XX +XXX,XX @@ SUB_i . 10 100010 0 ............ ..... ..... @addsub_imm |
19 | if (accfn) { | 22 | SUB_i . 10 100010 1 ............ ..... ..... @addsub_imm12 |
20 | tmp = tcg_temp_new_i64(); | 23 | SUBS_i . 11 100010 0 ............ ..... ..... @addsub_imm |
21 | read_neon_element64(tmp, a->vd, 0, MO_64); | 24 | SUBS_i . 11 100010 1 ............ ..... ..... @addsub_imm12 |
22 | - accfn(tmp, tmp, rd0); | 25 | + |
23 | - write_neon_element64(tmp, a->vd, 0, MO_64); | 26 | +# Add/subtract (immediate with tags) |
24 | + accfn(rd0, tmp, rd0); | 27 | + |
25 | read_neon_element64(tmp, a->vd, 1, MO_64); | 28 | +&rri_tag rd rn uimm6 uimm4 |
26 | - accfn(tmp, tmp, rd1); | 29 | +@addsub_imm_tag . .. ...... . uimm6:6 .. uimm4:4 rn:5 rd:5 &rri_tag |
27 | - write_neon_element64(tmp, a->vd, 1, MO_64); | 30 | + |
28 | + accfn(rd1, tmp, rd1); | 31 | +ADDG_i 1 00 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag |
29 | tcg_temp_free_i64(tmp); | 32 | +SUBG_i 1 10 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag |
30 | - } else { | 33 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
31 | - write_neon_element64(rd0, a->vd, 0, MO_64); | 34 | index XXXXXXX..XXXXXXX 100644 |
32 | - write_neon_element64(rd1, a->vd, 1, MO_64); | 35 | --- a/target/arm/tcg/translate-a64.c |
36 | +++ b/target/arm/tcg/translate-a64.c | ||
37 | @@ -XXX,XX +XXX,XX @@ TRANS(SUBS_i, gen_rri, a, 0, 1, a->sf ? gen_sub64_CC : gen_sub32_CC) | ||
38 | |||
39 | /* | ||
40 | * Add/subtract (immediate, with tags) | ||
41 | - * | ||
42 | - * 31 30 29 28 23 22 21 16 14 10 9 5 4 0 | ||
43 | - * +--+--+--+-------------+--+---------+--+-------+-----+-----+ | ||
44 | - * |sf|op| S| 1 0 0 0 1 1 |o2| uimm6 |o3| uimm4 | Rn | Rd | | ||
45 | - * +--+--+--+-------------+--+---------+--+-------+-----+-----+ | ||
46 | - * | ||
47 | - * op: 0 -> add, 1 -> sub | ||
48 | */ | ||
49 | -static void disas_add_sub_imm_with_tags(DisasContext *s, uint32_t insn) | ||
50 | + | ||
51 | +static bool gen_add_sub_imm_with_tags(DisasContext *s, arg_rri_tag *a, | ||
52 | + bool sub_op) | ||
53 | { | ||
54 | - int rd = extract32(insn, 0, 5); | ||
55 | - int rn = extract32(insn, 5, 5); | ||
56 | - int uimm4 = extract32(insn, 10, 4); | ||
57 | - int uimm6 = extract32(insn, 16, 6); | ||
58 | - bool sub_op = extract32(insn, 30, 1); | ||
59 | TCGv_i64 tcg_rn, tcg_rd; | ||
60 | int imm; | ||
61 | |||
62 | - /* Test all of sf=1, S=0, o2=0, o3=0. */ | ||
63 | - if ((insn & 0xa040c000u) != 0x80000000u || | ||
64 | - !dc_isar_feature(aa64_mte_insn_reg, s)) { | ||
65 | - unallocated_encoding(s); | ||
66 | - return; | ||
67 | - } | ||
68 | - | ||
69 | - imm = uimm6 << LOG2_TAG_GRANULE; | ||
70 | + imm = a->uimm6 << LOG2_TAG_GRANULE; | ||
71 | if (sub_op) { | ||
72 | imm = -imm; | ||
33 | } | 73 | } |
34 | 74 | ||
35 | + write_neon_element64(rd0, a->vd, 0, MO_64); | 75 | - tcg_rn = cpu_reg_sp(s, rn); |
36 | + write_neon_element64(rd1, a->vd, 1, MO_64); | 76 | - tcg_rd = cpu_reg_sp(s, rd); |
37 | tcg_temp_free_i64(rd0); | 77 | + tcg_rn = cpu_reg_sp(s, a->rn); |
38 | tcg_temp_free_i64(rd1); | 78 | + tcg_rd = cpu_reg_sp(s, a->rd); |
39 | 79 | ||
40 | @@ -XXX,XX +XXX,XX @@ static bool do_2scalar_long(DisasContext *s, arg_2scalar *a, | 80 | if (s->ata) { |
41 | if (accfn) { | 81 | gen_helper_addsubg(tcg_rd, cpu_env, tcg_rn, |
42 | TCGv_i64 t64 = tcg_temp_new_i64(); | 82 | tcg_constant_i32(imm), |
43 | read_neon_element64(t64, a->vd, 0, MO_64); | 83 | - tcg_constant_i32(uimm4)); |
44 | - accfn(t64, t64, rn0_64); | 84 | + tcg_constant_i32(a->uimm4)); |
45 | - write_neon_element64(t64, a->vd, 0, MO_64); | 85 | } else { |
46 | + accfn(rn0_64, t64, rn0_64); | 86 | tcg_gen_addi_i64(tcg_rd, tcg_rn, imm); |
47 | read_neon_element64(t64, a->vd, 1, MO_64); | 87 | gen_address_with_allocation_tag0(tcg_rd, tcg_rd); |
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 | } | 88 | } |
89 | + return true; | ||
90 | } | ||
91 | |||
92 | +TRANS_FEAT(ADDG_i, aa64_mte_insn_reg, gen_add_sub_imm_with_tags, a, false) | ||
93 | +TRANS_FEAT(SUBG_i, aa64_mte_insn_reg, gen_add_sub_imm_with_tags, a, true) | ||
56 | + | 94 | + |
57 | + write_neon_element64(rn0_64, a->vd, 0, MO_64); | 95 | /* The input should be a value in the bottom e bits (with higher |
58 | + write_neon_element64(rn1_64, a->vd, 1, MO_64); | 96 | * bits zero); returns that value replicated into every element |
59 | tcg_temp_free_i64(rn0_64); | 97 | * of size e in a 64 bit integer. |
60 | tcg_temp_free_i64(rn1_64); | 98 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) |
61 | return true; | 99 | static void disas_data_proc_imm(DisasContext *s, uint32_t insn) |
100 | { | ||
101 | switch (extract32(insn, 23, 6)) { | ||
102 | - case 0x23: /* Add/subtract (immediate, with tags) */ | ||
103 | - disas_add_sub_imm_with_tags(s, insn); | ||
104 | - break; | ||
105 | case 0x24: /* Logical (immediate) */ | ||
106 | disas_logic_imm(s, insn); | ||
107 | break; | ||
62 | -- | 108 | -- |
63 | 2.20.1 | 109 | 2.34.1 |
64 | |||
65 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This will shortly have users outside of translate-neon.c.inc. | 3 | Use the bitops.h macro rather than rolling our own here. |
4 | 4 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 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> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20230512144106.3608981-9-peter.maydell@linaro.org | ||
9 | --- | 9 | --- |
10 | target/arm/translate.c | 20 ++++++++++++++++++++ | 10 | target/arm/tcg/translate-a64.c | 11 ++--------- |
11 | target/arm/translate-neon.c.inc | 19 ------------------- | 11 | 1 file changed, 2 insertions(+), 9 deletions(-) |
12 | 2 files changed, 20 insertions(+), 19 deletions(-) | ||
13 | 12 | ||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 13 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 15 | --- a/target/arm/tcg/translate-a64.c |
17 | +++ b/target/arm/translate.c | 16 | +++ b/target/arm/tcg/translate-a64.c |
18 | @@ -XXX,XX +XXX,XX @@ static long neon_full_reg_offset(unsigned reg) | 17 | @@ -XXX,XX +XXX,XX @@ static uint64_t bitfield_replicate(uint64_t mask, unsigned int e) |
19 | return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]); | 18 | return mask; |
20 | } | 19 | } |
21 | 20 | ||
22 | +/* | 21 | -/* Return a value with the bottom len bits set (where 0 < len <= 64) */ |
23 | + * Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | 22 | -static inline uint64_t bitmask64(unsigned int length) |
24 | + * where 0 is the least significant end of the register. | ||
25 | + */ | ||
26 | +static long neon_element_offset(int reg, int element, MemOp size) | ||
27 | +{ | ||
28 | + int element_size = 1 << size; | ||
29 | + int ofs = element * element_size; | ||
30 | +#ifdef HOST_WORDS_BIGENDIAN | ||
31 | + /* | ||
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 | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/translate-neon.c.inc | ||
48 | +++ b/target/arm/translate-neon.c.inc | ||
49 | @@ -XXX,XX +XXX,XX @@ static inline int neon_3same_fp_size(DisasContext *s, int x) | ||
50 | #include "decode-neon-ls.c.inc" | ||
51 | #include "decode-neon-shared.c.inc" | ||
52 | |||
53 | -/* Return the offset of a 2**SIZE piece of a NEON register, at index ELE, | ||
54 | - * where 0 is the least significant end of the register. | ||
55 | - */ | ||
56 | -static inline long | ||
57 | -neon_element_offset(int reg, int element, MemOp size) | ||
58 | -{ | 23 | -{ |
59 | - int element_size = 1 << size; | 24 | - assert(length > 0 && length <= 64); |
60 | - int ofs = element * element_size; | 25 | - return ~0ULL >> (64 - length); |
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 | -} | 26 | -} |
71 | - | 27 | - |
72 | static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop) | 28 | /* Simplified variant of pseudocode DecodeBitMasks() for the case where we |
73 | { | 29 | * only require the wmask. Returns false if the imms/immr/immn are a reserved |
74 | long offset = neon_element_offset(reg, ele, mop & MO_SIZE); | 30 | * value (ie should cause a guest UNDEF exception), and true if they are |
31 | @@ -XXX,XX +XXX,XX @@ bool logic_imm_decode_wmask(uint64_t *result, unsigned int immn, | ||
32 | /* Create the value of one element: s+1 set bits rotated | ||
33 | * by r within the element (which is e bits wide)... | ||
34 | */ | ||
35 | - mask = bitmask64(s + 1); | ||
36 | + mask = MAKE_64BIT_MASK(0, s + 1); | ||
37 | if (r) { | ||
38 | mask = (mask >> r) | (mask << (e - r)); | ||
39 | - mask &= bitmask64(e); | ||
40 | + mask &= MAKE_64BIT_MASK(0, e); | ||
41 | } | ||
42 | /* ...then replicate the element over the whole 64 bit value */ | ||
43 | mask = bitfield_replicate(mask, e); | ||
75 | -- | 44 | -- |
76 | 2.20.1 | 45 | 2.34.1 |
77 | |||
78 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The only uses of this function are for loading VFP | 3 | Convert the ADD, ORR, EOR, ANDS (immediate) instructions. |
4 | single-precision values, and nothing to do with NEON. | ||
5 | 4 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | 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> | 6 | 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 | Message-id: 20230512144106.3608981-10-peter.maydell@linaro.org | ||
9 | [PMM: rebased] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | 11 | --- |
11 | target/arm/translate.c | 4 +- | 12 | target/arm/tcg/a64.decode | 15 ++++++ |
12 | target/arm/translate-vfp.c.inc | 184 ++++++++++++++++----------------- | 13 | target/arm/tcg/translate-a64.c | 94 +++++++++++----------------------- |
13 | 2 files changed, 94 insertions(+), 94 deletions(-) | 14 | 2 files changed, 44 insertions(+), 65 deletions(-) |
14 | 15 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 16 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 18 | --- a/target/arm/tcg/a64.decode |
18 | +++ b/target/arm/translate.c | 19 | +++ b/target/arm/tcg/a64.decode |
19 | @@ -XXX,XX +XXX,XX @@ static inline void neon_store_reg64(TCGv_i64 var, int reg) | 20 | @@ -XXX,XX +XXX,XX @@ SUBS_i . 11 100010 1 ............ ..... ..... @addsub_imm12 |
20 | tcg_gen_st_i64(var, cpu_env, vfp_reg_offset(1, reg)); | 21 | |
22 | ADDG_i 1 00 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag | ||
23 | SUBG_i 1 10 100011 0 ...... 00 .... ..... ..... @addsub_imm_tag | ||
24 | + | ||
25 | +# Logical (immediate) | ||
26 | + | ||
27 | +&rri_log rd rn sf dbm | ||
28 | +@logic_imm_64 1 .. ...... dbm:13 rn:5 rd:5 &rri_log sf=1 | ||
29 | +@logic_imm_32 0 .. ...... 0 dbm:12 rn:5 rd:5 &rri_log sf=0 | ||
30 | + | ||
31 | +AND_i . 00 100100 . ...... ...... ..... ..... @logic_imm_64 | ||
32 | +AND_i . 00 100100 . ...... ...... ..... ..... @logic_imm_32 | ||
33 | +ORR_i . 01 100100 . ...... ...... ..... ..... @logic_imm_64 | ||
34 | +ORR_i . 01 100100 . ...... ...... ..... ..... @logic_imm_32 | ||
35 | +EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_64 | ||
36 | +EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_32 | ||
37 | +ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_64 | ||
38 | +ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_32 | ||
39 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/tcg/translate-a64.c | ||
42 | +++ b/target/arm/tcg/translate-a64.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static uint64_t bitfield_replicate(uint64_t mask, unsigned int e) | ||
44 | return mask; | ||
21 | } | 45 | } |
22 | 46 | ||
23 | -static inline void neon_load_reg32(TCGv_i32 var, int reg) | 47 | -/* Simplified variant of pseudocode DecodeBitMasks() for the case where we |
24 | +static inline void vfp_load_reg32(TCGv_i32 var, int reg) | 48 | +/* |
25 | { | 49 | + * Logical (immediate) |
26 | tcg_gen_ld_i32(var, cpu_env, vfp_reg_offset(false, reg)); | 50 | + */ |
27 | } | 51 | + |
28 | 52 | +/* | |
29 | -static inline void neon_store_reg32(TCGv_i32 var, int reg) | 53 | + * Simplified variant of pseudocode DecodeBitMasks() for the case where we |
30 | +static inline void vfp_store_reg32(TCGv_i32 var, int reg) | 54 | * only require the wmask. Returns false if the imms/immr/immn are a reserved |
31 | { | 55 | * value (ie should cause a guest UNDEF exception), and true if they are |
32 | tcg_gen_st_i32(var, cpu_env, vfp_reg_offset(false, reg)); | 56 | * valid, in which case the decoded bit pattern is written to result. |
33 | } | 57 | @@ -XXX,XX +XXX,XX @@ bool logic_imm_decode_wmask(uint64_t *result, unsigned int immn, |
34 | diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/translate-vfp.c.inc | ||
37 | +++ b/target/arm/translate-vfp.c.inc | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSEL(DisasContext *s, arg_VSEL *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; | 58 | return true; |
373 | } | 59 | } |
374 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_sp(DisasContext *s, arg_VMOV_imm_sp *a) | 60 | |
375 | fd = tcg_const_i32(vfp_expand_imm(MO_32, a->imm)); | 61 | -/* Logical (immediate) |
376 | 62 | - * 31 30 29 28 23 22 21 16 15 10 9 5 4 0 | |
377 | for (;;) { | 63 | - * +----+-----+-------------+---+------+------+------+------+ |
378 | - neon_store_reg32(fd, vd); | 64 | - * | sf | opc | 1 0 0 1 0 0 | N | immr | imms | Rn | Rd | |
379 | + vfp_store_reg32(fd, vd); | 65 | - * +----+-----+-------------+---+------+------+------+------+ |
380 | 66 | - */ | |
381 | if (veclen == 0) { | 67 | -static void disas_logic_imm(DisasContext *s, uint32_t insn) |
382 | break; | 68 | +static bool gen_rri_log(DisasContext *s, arg_rri_log *a, bool set_cc, |
383 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_hp(DisasContext *s, arg_VCMP_sp *a) | 69 | + void (*fn)(TCGv_i64, TCGv_i64, int64_t)) |
384 | vd = tcg_temp_new_i32(); | 70 | { |
385 | vm = tcg_temp_new_i32(); | 71 | - unsigned int sf, opc, is_n, immr, imms, rn, rd; |
386 | 72 | TCGv_i64 tcg_rd, tcg_rn; | |
387 | - neon_load_reg32(vd, a->vd); | 73 | - uint64_t wmask; |
388 | + vfp_load_reg32(vd, a->vd); | 74 | - bool is_and = false; |
389 | if (a->z) { | 75 | + uint64_t imm; |
390 | tcg_gen_movi_i32(vm, 0); | 76 | |
391 | } else { | 77 | - sf = extract32(insn, 31, 1); |
392 | - neon_load_reg32(vm, a->vm); | 78 | - opc = extract32(insn, 29, 2); |
393 | + vfp_load_reg32(vm, a->vm); | 79 | - is_n = extract32(insn, 22, 1); |
80 | - immr = extract32(insn, 16, 6); | ||
81 | - imms = extract32(insn, 10, 6); | ||
82 | - rn = extract32(insn, 5, 5); | ||
83 | - rd = extract32(insn, 0, 5); | ||
84 | - | ||
85 | - if (!sf && is_n) { | ||
86 | - unallocated_encoding(s); | ||
87 | - return; | ||
88 | + /* Some immediate field values are reserved. */ | ||
89 | + if (!logic_imm_decode_wmask(&imm, extract32(a->dbm, 12, 1), | ||
90 | + extract32(a->dbm, 0, 6), | ||
91 | + extract32(a->dbm, 6, 6))) { | ||
92 | + return false; | ||
93 | + } | ||
94 | + if (!a->sf) { | ||
95 | + imm &= 0xffffffffull; | ||
394 | } | 96 | } |
395 | 97 | ||
396 | if (a->e) { | 98 | - if (opc == 0x3) { /* ANDS */ |
397 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCMP_sp(DisasContext *s, arg_VCMP_sp *a) | 99 | - tcg_rd = cpu_reg(s, rd); |
398 | vd = tcg_temp_new_i32(); | 100 | - } else { |
399 | vm = tcg_temp_new_i32(); | 101 | - tcg_rd = cpu_reg_sp(s, rd); |
400 | 102 | - } | |
401 | - neon_load_reg32(vd, a->vd); | 103 | - tcg_rn = cpu_reg(s, rn); |
402 | + vfp_load_reg32(vd, a->vd); | 104 | + tcg_rd = set_cc ? cpu_reg(s, a->rd) : cpu_reg_sp(s, a->rd); |
403 | if (a->z) { | 105 | + tcg_rn = cpu_reg(s, a->rn); |
404 | tcg_gen_movi_i32(vm, 0); | 106 | |
405 | } else { | 107 | - if (!logic_imm_decode_wmask(&wmask, is_n, imms, immr)) { |
406 | - neon_load_reg32(vm, a->vm); | 108 | - /* some immediate field values are reserved */ |
407 | + vfp_load_reg32(vm, a->vm); | 109 | - unallocated_encoding(s); |
110 | - return; | ||
111 | + fn(tcg_rd, tcg_rn, imm); | ||
112 | + if (set_cc) { | ||
113 | + gen_logic_CC(a->sf, tcg_rd); | ||
408 | } | 114 | } |
409 | 115 | - | |
410 | if (a->e) { | 116 | - if (!sf) { |
411 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f32_f16(DisasContext *s, arg_VCVT_f32_f16 *a) | 117 | - wmask &= 0xffffffff; |
412 | /* The T bit tells us if we want the low or high 16 bits of Vm */ | 118 | - } |
413 | tcg_gen_ld16u_i32(tmp, cpu_env, vfp_f16_offset(a->vm, a->t)); | 119 | - |
414 | gen_helper_vfp_fcvt_f16_to_f32(tmp, tmp, fpst, ahp_mode); | 120 | - switch (opc) { |
415 | - neon_store_reg32(tmp, a->vd); | 121 | - case 0x3: /* ANDS */ |
416 | + vfp_store_reg32(tmp, a->vd); | 122 | - case 0x0: /* AND */ |
417 | tcg_temp_free_i32(ahp_mode); | 123 | - tcg_gen_andi_i64(tcg_rd, tcg_rn, wmask); |
418 | tcg_temp_free_ptr(fpst); | 124 | - is_and = true; |
419 | tcg_temp_free_i32(tmp); | 125 | - break; |
420 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f16_f32(DisasContext *s, arg_VCVT_f16_f32 *a) | 126 | - case 0x1: /* ORR */ |
421 | ahp_mode = get_ahp_flag(); | 127 | - tcg_gen_ori_i64(tcg_rd, tcg_rn, wmask); |
422 | tmp = tcg_temp_new_i32(); | 128 | - break; |
423 | 129 | - case 0x2: /* EOR */ | |
424 | - neon_load_reg32(tmp, a->vm); | 130 | - tcg_gen_xori_i64(tcg_rd, tcg_rn, wmask); |
425 | + vfp_load_reg32(tmp, a->vm); | 131 | - break; |
426 | gen_helper_vfp_fcvt_f32_to_f16(tmp, tmp, fpst, ahp_mode); | 132 | - default: |
427 | tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t)); | 133 | - assert(FALSE); /* must handle all above */ |
428 | tcg_temp_free_i32(ahp_mode); | 134 | - break; |
429 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_hp(DisasContext *s, arg_VRINTR_sp *a) | 135 | - } |
136 | - | ||
137 | - if (!sf && !is_and) { | ||
138 | - /* zero extend final result; we know we can skip this for AND | ||
139 | - * since the immediate had the high 32 bits clear. | ||
140 | - */ | ||
141 | + if (!a->sf) { | ||
142 | tcg_gen_ext32u_i64(tcg_rd, tcg_rd); | ||
430 | } | 143 | } |
431 | 144 | - | |
432 | tmp = tcg_temp_new_i32(); | 145 | - if (opc == 3) { /* ANDS */ |
433 | - neon_load_reg32(tmp, a->vm); | 146 | - gen_logic_CC(sf, tcg_rd); |
434 | + vfp_load_reg32(tmp, a->vm); | 147 | - } |
435 | fpst = fpstatus_ptr(FPST_FPCR_F16); | 148 | + return true; |
436 | gen_helper_rinth(tmp, tmp, fpst); | ||
437 | - neon_store_reg32(tmp, a->vd); | ||
438 | + vfp_store_reg32(tmp, a->vd); | ||
439 | tcg_temp_free_ptr(fpst); | ||
440 | tcg_temp_free_i32(tmp); | ||
441 | return true; | ||
442 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTR_sp(DisasContext *s, arg_VRINTR_sp *a) | ||
443 | } | ||
444 | |||
445 | tmp = tcg_temp_new_i32(); | ||
446 | - neon_load_reg32(tmp, a->vm); | ||
447 | + vfp_load_reg32(tmp, a->vm); | ||
448 | fpst = fpstatus_ptr(FPST_FPCR); | ||
449 | gen_helper_rints(tmp, tmp, fpst); | ||
450 | - neon_store_reg32(tmp, a->vd); | ||
451 | + vfp_store_reg32(tmp, a->vd); | ||
452 | tcg_temp_free_ptr(fpst); | ||
453 | tcg_temp_free_i32(tmp); | ||
454 | return true; | ||
455 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_hp(DisasContext *s, arg_VRINTZ_sp *a) | ||
456 | } | ||
457 | |||
458 | tmp = tcg_temp_new_i32(); | ||
459 | - neon_load_reg32(tmp, a->vm); | ||
460 | + vfp_load_reg32(tmp, a->vm); | ||
461 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
462 | tcg_rmode = tcg_const_i32(float_round_to_zero); | ||
463 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
464 | gen_helper_rinth(tmp, tmp, fpst); | ||
465 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
466 | - neon_store_reg32(tmp, a->vd); | ||
467 | + vfp_store_reg32(tmp, a->vd); | ||
468 | tcg_temp_free_ptr(fpst); | ||
469 | tcg_temp_free_i32(tcg_rmode); | ||
470 | tcg_temp_free_i32(tmp); | ||
471 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTZ_sp(DisasContext *s, arg_VRINTZ_sp *a) | ||
472 | } | ||
473 | |||
474 | tmp = tcg_temp_new_i32(); | ||
475 | - neon_load_reg32(tmp, a->vm); | ||
476 | + vfp_load_reg32(tmp, a->vm); | ||
477 | fpst = fpstatus_ptr(FPST_FPCR); | ||
478 | tcg_rmode = tcg_const_i32(float_round_to_zero); | ||
479 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
480 | gen_helper_rints(tmp, tmp, fpst); | ||
481 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
482 | - neon_store_reg32(tmp, a->vd); | ||
483 | + vfp_store_reg32(tmp, a->vd); | ||
484 | tcg_temp_free_ptr(fpst); | ||
485 | tcg_temp_free_i32(tcg_rmode); | ||
486 | tcg_temp_free_i32(tmp); | ||
487 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_hp(DisasContext *s, arg_VRINTX_sp *a) | ||
488 | } | ||
489 | |||
490 | tmp = tcg_temp_new_i32(); | ||
491 | - neon_load_reg32(tmp, a->vm); | ||
492 | + vfp_load_reg32(tmp, a->vm); | ||
493 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
494 | gen_helper_rinth_exact(tmp, tmp, fpst); | ||
495 | - neon_store_reg32(tmp, a->vd); | ||
496 | + vfp_store_reg32(tmp, a->vd); | ||
497 | tcg_temp_free_ptr(fpst); | ||
498 | tcg_temp_free_i32(tmp); | ||
499 | return true; | ||
500 | @@ -XXX,XX +XXX,XX @@ static bool trans_VRINTX_sp(DisasContext *s, arg_VRINTX_sp *a) | ||
501 | } | ||
502 | |||
503 | tmp = tcg_temp_new_i32(); | ||
504 | - neon_load_reg32(tmp, a->vm); | ||
505 | + vfp_load_reg32(tmp, a->vm); | ||
506 | fpst = fpstatus_ptr(FPST_FPCR); | ||
507 | gen_helper_rints_exact(tmp, tmp, fpst); | ||
508 | - neon_store_reg32(tmp, a->vd); | ||
509 | + vfp_store_reg32(tmp, a->vd); | ||
510 | tcg_temp_free_ptr(fpst); | ||
511 | tcg_temp_free_i32(tmp); | ||
512 | return true; | ||
513 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_sp(DisasContext *s, arg_VCVT_sp *a) | ||
514 | |||
515 | vm = tcg_temp_new_i32(); | ||
516 | vd = tcg_temp_new_i64(); | ||
517 | - neon_load_reg32(vm, a->vm); | ||
518 | + vfp_load_reg32(vm, a->vm); | ||
519 | gen_helper_vfp_fcvtds(vd, vm, cpu_env); | ||
520 | neon_store_reg64(vd, a->vd); | ||
521 | tcg_temp_free_i32(vm); | ||
522 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_dp(DisasContext *s, arg_VCVT_dp *a) | ||
523 | vm = tcg_temp_new_i64(); | ||
524 | neon_load_reg64(vm, a->vm); | ||
525 | gen_helper_vfp_fcvtsd(vd, vm, cpu_env); | ||
526 | - neon_store_reg32(vd, a->vd); | ||
527 | + vfp_store_reg32(vd, a->vd); | ||
528 | tcg_temp_free_i32(vd); | ||
529 | tcg_temp_free_i64(vm); | ||
530 | return true; | ||
531 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_hp(DisasContext *s, arg_VCVT_int_sp *a) | ||
532 | } | ||
533 | |||
534 | vm = tcg_temp_new_i32(); | ||
535 | - neon_load_reg32(vm, a->vm); | ||
536 | + vfp_load_reg32(vm, a->vm); | ||
537 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
538 | if (a->s) { | ||
539 | /* i32 -> f16 */ | ||
540 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_hp(DisasContext *s, arg_VCVT_int_sp *a) | ||
541 | /* u32 -> f16 */ | ||
542 | gen_helper_vfp_uitoh(vm, vm, fpst); | ||
543 | } | ||
544 | - neon_store_reg32(vm, a->vd); | ||
545 | + vfp_store_reg32(vm, a->vd); | ||
546 | tcg_temp_free_i32(vm); | ||
547 | tcg_temp_free_ptr(fpst); | ||
548 | return true; | ||
549 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a) | ||
550 | } | ||
551 | |||
552 | vm = tcg_temp_new_i32(); | ||
553 | - neon_load_reg32(vm, a->vm); | ||
554 | + vfp_load_reg32(vm, a->vm); | ||
555 | fpst = fpstatus_ptr(FPST_FPCR); | ||
556 | if (a->s) { | ||
557 | /* i32 -> f32 */ | ||
558 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_sp(DisasContext *s, arg_VCVT_int_sp *a) | ||
559 | /* u32 -> f32 */ | ||
560 | gen_helper_vfp_uitos(vm, vm, fpst); | ||
561 | } | ||
562 | - neon_store_reg32(vm, a->vd); | ||
563 | + vfp_store_reg32(vm, a->vd); | ||
564 | tcg_temp_free_i32(vm); | ||
565 | tcg_temp_free_ptr(fpst); | ||
566 | return true; | ||
567 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_int_dp(DisasContext *s, arg_VCVT_int_dp *a) | ||
568 | |||
569 | vm = tcg_temp_new_i32(); | ||
570 | vd = tcg_temp_new_i64(); | ||
571 | - neon_load_reg32(vm, a->vm); | ||
572 | + vfp_load_reg32(vm, a->vm); | ||
573 | fpst = fpstatus_ptr(FPST_FPCR); | ||
574 | if (a->s) { | ||
575 | /* i32 -> f64 */ | ||
576 | @@ -XXX,XX +XXX,XX @@ static bool trans_VJCVT(DisasContext *s, arg_VJCVT *a) | ||
577 | vd = tcg_temp_new_i32(); | ||
578 | neon_load_reg64(vm, a->vm); | ||
579 | gen_helper_vjcvt(vd, vm, cpu_env); | ||
580 | - neon_store_reg32(vd, a->vd); | ||
581 | + vfp_store_reg32(vd, a->vd); | ||
582 | tcg_temp_free_i64(vm); | ||
583 | tcg_temp_free_i32(vd); | ||
584 | return true; | ||
585 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_hp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
586 | frac_bits = (a->opc & 1) ? (32 - a->imm) : (16 - a->imm); | ||
587 | |||
588 | vd = tcg_temp_new_i32(); | ||
589 | - neon_load_reg32(vd, a->vd); | ||
590 | + vfp_load_reg32(vd, a->vd); | ||
591 | |||
592 | fpst = fpstatus_ptr(FPST_FPCR_F16); | ||
593 | shift = tcg_const_i32(frac_bits); | ||
594 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_fix_hp(DisasContext *s, arg_VCVT_fix_sp *a) | ||
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 | } | 149 | } |
150 | |||
151 | +TRANS(AND_i, gen_rri_log, a, false, tcg_gen_andi_i64) | ||
152 | +TRANS(ORR_i, gen_rri_log, a, false, tcg_gen_ori_i64) | ||
153 | +TRANS(EOR_i, gen_rri_log, a, false, tcg_gen_xori_i64) | ||
154 | +TRANS(ANDS_i, gen_rri_log, a, true, tcg_gen_andi_i64) | ||
155 | + | ||
156 | /* | ||
157 | * Move wide (immediate) | ||
158 | * | ||
159 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) | ||
160 | static void disas_data_proc_imm(DisasContext *s, uint32_t insn) | ||
161 | { | ||
162 | switch (extract32(insn, 23, 6)) { | ||
163 | - case 0x24: /* Logical (immediate) */ | ||
164 | - disas_logic_imm(s, insn); | ||
165 | - break; | ||
166 | case 0x25: /* Move wide (immediate) */ | ||
167 | disas_movw_imm(s, insn); | ||
168 | break; | ||
692 | -- | 169 | -- |
693 | 2.20.1 | 170 | 2.34.1 |
694 | |||
695 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This function makes it clear that we're talking about the whole | 3 | Convert the MON, MOVZ, MOVK instructions. |
4 | register, and not the 32-bit piece at index 0. This fixes a bug | ||
5 | when running on a big-endian host. | ||
6 | 4 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20201030022618.785675-2-richard.henderson@linaro.org | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20230512144106.3608981-11-peter.maydell@linaro.org | ||
9 | [PMM: Rebased] | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 12 | --- |
12 | target/arm/translate.c | 8 ++++++ | 13 | target/arm/tcg/a64.decode | 13 ++++++ |
13 | target/arm/translate-neon.c.inc | 44 ++++++++++++++++----------------- | 14 | target/arm/tcg/translate-a64.c | 73 ++++++++++++++-------------------- |
14 | target/arm/translate-vfp.c.inc | 2 +- | 15 | 2 files changed, 42 insertions(+), 44 deletions(-) |
15 | 3 files changed, 31 insertions(+), 23 deletions(-) | ||
16 | 16 | ||
17 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 17 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
18 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate.c | 19 | --- a/target/arm/tcg/a64.decode |
20 | +++ b/target/arm/translate.c | 20 | +++ b/target/arm/tcg/a64.decode |
21 | @@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm) | 21 | @@ -XXX,XX +XXX,XX @@ EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_64 |
22 | unallocated_encoding(s); | 22 | EOR_i . 10 100100 . ...... ...... ..... ..... @logic_imm_32 |
23 | } | 23 | ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_64 |
24 | 24 | ANDS_i . 11 100100 . ...... ...... ..... ..... @logic_imm_32 | |
25 | +/* | 25 | + |
26 | + * Return the offset of a "full" NEON Dreg. | 26 | +# Move wide (immediate) |
27 | + */ | 27 | + |
28 | +static long neon_full_reg_offset(unsigned reg) | 28 | +&movw rd sf imm hw |
29 | +@movw_64 1 .. ...... hw:2 imm:16 rd:5 &movw sf=1 | ||
30 | +@movw_32 0 .. ...... 0 hw:1 imm:16 rd:5 &movw sf=0 | ||
31 | + | ||
32 | +MOVN . 00 100101 .. ................ ..... @movw_64 | ||
33 | +MOVN . 00 100101 .. ................ ..... @movw_32 | ||
34 | +MOVZ . 10 100101 .. ................ ..... @movw_64 | ||
35 | +MOVZ . 10 100101 .. ................ ..... @movw_32 | ||
36 | +MOVK . 11 100101 .. ................ ..... @movw_64 | ||
37 | +MOVK . 11 100101 .. ................ ..... @movw_32 | ||
38 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/tcg/translate-a64.c | ||
41 | +++ b/target/arm/tcg/translate-a64.c | ||
42 | @@ -XXX,XX +XXX,XX @@ TRANS(ANDS_i, gen_rri_log, a, true, tcg_gen_andi_i64) | ||
43 | |||
44 | /* | ||
45 | * Move wide (immediate) | ||
46 | - * | ||
47 | - * 31 30 29 28 23 22 21 20 5 4 0 | ||
48 | - * +--+-----+-------------+-----+----------------+------+ | ||
49 | - * |sf| opc | 1 0 0 1 0 1 | hw | imm16 | Rd | | ||
50 | - * +--+-----+-------------+-----+----------------+------+ | ||
51 | - * | ||
52 | - * sf: 0 -> 32 bit, 1 -> 64 bit | ||
53 | - * opc: 00 -> N, 10 -> Z, 11 -> K | ||
54 | - * hw: shift/16 (0,16, and sf only 32, 48) | ||
55 | */ | ||
56 | -static void disas_movw_imm(DisasContext *s, uint32_t insn) | ||
57 | + | ||
58 | +static bool trans_MOVZ(DisasContext *s, arg_movw *a) | ||
59 | { | ||
60 | - int rd = extract32(insn, 0, 5); | ||
61 | - uint64_t imm = extract32(insn, 5, 16); | ||
62 | - int sf = extract32(insn, 31, 1); | ||
63 | - int opc = extract32(insn, 29, 2); | ||
64 | - int pos = extract32(insn, 21, 2) << 4; | ||
65 | - TCGv_i64 tcg_rd = cpu_reg(s, rd); | ||
66 | + int pos = a->hw << 4; | ||
67 | + tcg_gen_movi_i64(cpu_reg(s, a->rd), (uint64_t)a->imm << pos); | ||
68 | + return true; | ||
69 | +} | ||
70 | |||
71 | - if (!sf && (pos >= 32)) { | ||
72 | - unallocated_encoding(s); | ||
73 | - return; | ||
74 | - } | ||
75 | +static bool trans_MOVN(DisasContext *s, arg_movw *a) | ||
29 | +{ | 76 | +{ |
30 | + return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]); | 77 | + int pos = a->hw << 4; |
78 | + uint64_t imm = a->imm; | ||
79 | |||
80 | - switch (opc) { | ||
81 | - case 0: /* MOVN */ | ||
82 | - case 2: /* MOVZ */ | ||
83 | - imm <<= pos; | ||
84 | - if (opc == 0) { | ||
85 | - imm = ~imm; | ||
86 | - } | ||
87 | - if (!sf) { | ||
88 | - imm &= 0xffffffffu; | ||
89 | - } | ||
90 | - tcg_gen_movi_i64(tcg_rd, imm); | ||
91 | - break; | ||
92 | - case 3: /* MOVK */ | ||
93 | - tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_constant_i64(imm), pos, 16); | ||
94 | - if (!sf) { | ||
95 | - tcg_gen_ext32u_i64(tcg_rd, tcg_rd); | ||
96 | - } | ||
97 | - break; | ||
98 | - default: | ||
99 | - unallocated_encoding(s); | ||
100 | - break; | ||
101 | + imm = ~(imm << pos); | ||
102 | + if (!a->sf) { | ||
103 | + imm = (uint32_t)imm; | ||
104 | } | ||
105 | + tcg_gen_movi_i64(cpu_reg(s, a->rd), imm); | ||
106 | + return true; | ||
31 | +} | 107 | +} |
32 | + | 108 | + |
33 | static inline long vfp_reg_offset(bool dp, unsigned reg) | 109 | +static bool trans_MOVK(DisasContext *s, arg_movw *a) |
110 | +{ | ||
111 | + int pos = a->hw << 4; | ||
112 | + TCGv_i64 tcg_rd, tcg_im; | ||
113 | + | ||
114 | + tcg_rd = cpu_reg(s, a->rd); | ||
115 | + tcg_im = tcg_constant_i64(a->imm); | ||
116 | + tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_im, pos, 16); | ||
117 | + if (!a->sf) { | ||
118 | + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); | ||
119 | + } | ||
120 | + return true; | ||
121 | } | ||
122 | |||
123 | /* Bitfield | ||
124 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) | ||
125 | static void disas_data_proc_imm(DisasContext *s, uint32_t insn) | ||
34 | { | 126 | { |
35 | if (dp) { | 127 | switch (extract32(insn, 23, 6)) { |
36 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 128 | - case 0x25: /* Move wide (immediate) */ |
37 | index XXXXXXX..XXXXXXX 100644 | 129 | - disas_movw_imm(s, insn); |
38 | --- a/target/arm/translate-neon.c.inc | 130 | - break; |
39 | +++ b/target/arm/translate-neon.c.inc | 131 | case 0x26: /* Bitfield */ |
40 | @@ -XXX,XX +XXX,XX @@ neon_element_offset(int reg, int element, MemOp size) | 132 | disas_bitfield(s, insn); |
41 | ofs ^= 8 - element_size; | 133 | break; |
42 | } | ||
43 | #endif | ||
44 | - return neon_reg_offset(reg, 0) + ofs; | ||
45 | + return neon_full_reg_offset(reg) + ofs; | ||
46 | } | ||
47 | |||
48 | static void neon_load_element(TCGv_i32 var, int reg, int ele, MemOp mop) | ||
49 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a) | ||
50 | * We cannot write 16 bytes at once because the | ||
51 | * destination is unaligned. | ||
52 | */ | ||
53 | - tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0), | ||
54 | + tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(vd), | ||
55 | 8, 8, tmp); | ||
56 | - tcg_gen_gvec_mov(0, neon_reg_offset(vd + 1, 0), | ||
57 | - neon_reg_offset(vd, 0), 8, 8); | ||
58 | + tcg_gen_gvec_mov(0, neon_full_reg_offset(vd + 1), | ||
59 | + neon_full_reg_offset(vd), 8, 8); | ||
60 | } else { | ||
61 | - tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0), | ||
62 | + tcg_gen_gvec_dup_i32(size, neon_full_reg_offset(vd), | ||
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 | int vec_size = a->q ? 16 : 8; | ||
70 | - int rd_ofs = neon_reg_offset(a->vd, 0); | ||
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 | -- | 134 | -- |
177 | 2.20.1 | 135 | 2.34.1 |
178 | |||
179 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We can use proper widening loads to extend 32-bit inputs, | 3 | Convert the BFM, SBFM, UBFM instructions. |
4 | and skip the "widenfn" step. | ||
5 | 4 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | 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> | 6 | 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 | Message-id: 20230512144106.3608981-12-peter.maydell@linaro.org | ||
9 | [PMM: Rebased] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | 11 | --- |
11 | target/arm/translate.c | 6 +++ | 12 | target/arm/tcg/a64.decode | 13 +++ |
12 | target/arm/translate-neon.c.inc | 66 ++++++++++++++++++--------------- | 13 | target/arm/tcg/translate-a64.c | 144 ++++++++++++++++++--------------- |
13 | 2 files changed, 43 insertions(+), 29 deletions(-) | 14 | 2 files changed, 94 insertions(+), 63 deletions(-) |
14 | 15 | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 16 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 18 | --- a/target/arm/tcg/a64.decode |
18 | +++ b/target/arm/translate.c | 19 | +++ b/target/arm/tcg/a64.decode |
19 | @@ -XXX,XX +XXX,XX @@ static void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop) | 20 | @@ -XXX,XX +XXX,XX @@ MOVZ . 10 100101 .. ................ ..... @movw_64 |
20 | long off = neon_element_offset(reg, ele, memop); | 21 | MOVZ . 10 100101 .. ................ ..... @movw_32 |
21 | 22 | MOVK . 11 100101 .. ................ ..... @movw_64 | |
22 | switch (memop) { | 23 | MOVK . 11 100101 .. ................ ..... @movw_32 |
23 | + case MO_SL: | 24 | + |
24 | + tcg_gen_ld32s_i64(dest, cpu_env, off); | 25 | +# Bitfield |
25 | + break; | 26 | + |
26 | + case MO_UL: | 27 | +&bitfield rd rn sf immr imms |
27 | + tcg_gen_ld32u_i64(dest, cpu_env, off); | 28 | +@bitfield_64 1 .. ...... 1 immr:6 imms:6 rn:5 rd:5 &bitfield sf=1 |
28 | + break; | 29 | +@bitfield_32 0 .. ...... 0 0 immr:5 0 imms:5 rn:5 rd:5 &bitfield sf=0 |
29 | case MO_Q: | 30 | + |
30 | tcg_gen_ld_i64(dest, cpu_env, off); | 31 | +SBFM . 00 100110 . ...... ...... ..... ..... @bitfield_64 |
31 | break; | 32 | +SBFM . 00 100110 . ...... ...... ..... ..... @bitfield_32 |
32 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 33 | +BFM . 01 100110 . ...... ...... ..... ..... @bitfield_64 |
34 | +BFM . 01 100110 . ...... ...... ..... ..... @bitfield_32 | ||
35 | +UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_64 | ||
36 | +UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_32 | ||
37 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/target/arm/translate-neon.c.inc | 39 | --- a/target/arm/tcg/translate-a64.c |
35 | +++ b/target/arm/translate-neon.c.inc | 40 | +++ b/target/arm/tcg/translate-a64.c |
36 | @@ -XXX,XX +XXX,XX @@ static bool trans_Vimm_1r(DisasContext *s, arg_1reg_imm *a) | 41 | @@ -XXX,XX +XXX,XX @@ static bool trans_MOVK(DisasContext *s, arg_movw *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; | 42 | return true; |
127 | } | 43 | } |
128 | 44 | ||
129 | -#define DO_PREWIDEN(INSN, S, EXT, OP, SRC1WIDE) \ | 45 | -/* Bitfield |
130 | +#define DO_PREWIDEN(INSN, S, OP, SRC1WIDE, SIGN) \ | 46 | - * 31 30 29 28 23 22 21 16 15 10 9 5 4 0 |
131 | static bool trans_##INSN##_3d(DisasContext *s, arg_3diff *a) \ | 47 | - * +----+-----+-------------+---+------+------+------+------+ |
132 | { \ | 48 | - * | sf | opc | 1 0 0 1 1 0 | N | immr | imms | Rn | Rd | |
133 | static NeonGenWidenFn * const widenfn[] = { \ | 49 | - * +----+-----+-------------+---+------+------+------+------+ |
134 | gen_helper_neon_widen_##S##8, \ | 50 | +/* |
135 | gen_helper_neon_widen_##S##16, \ | 51 | + * Bitfield |
136 | - tcg_gen_##EXT##_i32_i64, \ | 52 | */ |
137 | - NULL, \ | 53 | -static void disas_bitfield(DisasContext *s, uint32_t insn) |
138 | + NULL, NULL, \ | 54 | + |
139 | }; \ | 55 | +static bool trans_SBFM(DisasContext *s, arg_SBFM *a) |
140 | static NeonGenTwo64OpFn * const addfn[] = { \ | 56 | { |
141 | gen_helper_neon_##OP##l_u16, \ | 57 | - unsigned int sf, n, opc, ri, si, rn, rd, bitsize, pos, len; |
142 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | 58 | - TCGv_i64 tcg_rd, tcg_tmp; |
143 | tcg_gen_##OP##_i64, \ | 59 | + TCGv_i64 tcg_rd = cpu_reg(s, a->rd); |
144 | NULL, \ | 60 | + TCGv_i64 tcg_tmp = read_cpu_reg(s, a->rn, 1); |
145 | }; \ | 61 | + unsigned int bitsize = a->sf ? 64 : 32; |
146 | - return do_prewiden_3d(s, a, widenfn[a->size], \ | 62 | + unsigned int ri = a->immr; |
147 | - addfn[a->size], SRC1WIDE); \ | 63 | + unsigned int si = a->imms; |
148 | + int narrow_mop = a->size == MO_32 ? MO_32 | SIGN : -1; \ | 64 | + unsigned int pos, len; |
149 | + return do_prewiden_3d(s, a, widenfn[a->size], addfn[a->size], \ | 65 | |
150 | + SRC1WIDE ? MO_Q : narrow_mop, \ | 66 | - sf = extract32(insn, 31, 1); |
151 | + narrow_mop); \ | 67 | - opc = extract32(insn, 29, 2); |
68 | - n = extract32(insn, 22, 1); | ||
69 | - ri = extract32(insn, 16, 6); | ||
70 | - si = extract32(insn, 10, 6); | ||
71 | - rn = extract32(insn, 5, 5); | ||
72 | - rd = extract32(insn, 0, 5); | ||
73 | - bitsize = sf ? 64 : 32; | ||
74 | - | ||
75 | - if (sf != n || ri >= bitsize || si >= bitsize || opc > 2) { | ||
76 | - unallocated_encoding(s); | ||
77 | - return; | ||
78 | - } | ||
79 | - | ||
80 | - tcg_rd = cpu_reg(s, rd); | ||
81 | - | ||
82 | - /* Suppress the zero-extend for !sf. Since RI and SI are constrained | ||
83 | - to be smaller than bitsize, we'll never reference data outside the | ||
84 | - low 32-bits anyway. */ | ||
85 | - tcg_tmp = read_cpu_reg(s, rn, 1); | ||
86 | - | ||
87 | - /* Recognize simple(r) extractions. */ | ||
88 | if (si >= ri) { | ||
89 | /* Wd<s-r:0> = Wn<s:r> */ | ||
90 | len = (si - ri) + 1; | ||
91 | - if (opc == 0) { /* SBFM: ASR, SBFX, SXTB, SXTH, SXTW */ | ||
92 | - tcg_gen_sextract_i64(tcg_rd, tcg_tmp, ri, len); | ||
93 | - goto done; | ||
94 | - } else if (opc == 2) { /* UBFM: UBFX, LSR, UXTB, UXTH */ | ||
95 | - tcg_gen_extract_i64(tcg_rd, tcg_tmp, ri, len); | ||
96 | - return; | ||
97 | + tcg_gen_sextract_i64(tcg_rd, tcg_tmp, ri, len); | ||
98 | + if (!a->sf) { | ||
99 | + tcg_gen_ext32u_i64(tcg_rd, tcg_rd); | ||
100 | } | ||
101 | - /* opc == 1, BFXIL fall through to deposit */ | ||
102 | + } else { | ||
103 | + /* Wd<32+s-r,32-r> = Wn<s:0> */ | ||
104 | + len = si + 1; | ||
105 | + pos = (bitsize - ri) & (bitsize - 1); | ||
106 | + | ||
107 | + if (len < ri) { | ||
108 | + /* | ||
109 | + * Sign extend the destination field from len to fill the | ||
110 | + * balance of the word. Let the deposit below insert all | ||
111 | + * of those sign bits. | ||
112 | + */ | ||
113 | + tcg_gen_sextract_i64(tcg_tmp, tcg_tmp, 0, len); | ||
114 | + len = ri; | ||
115 | + } | ||
116 | + | ||
117 | + /* | ||
118 | + * We start with zero, and we haven't modified any bits outside | ||
119 | + * bitsize, therefore no final zero-extension is unneeded for !sf. | ||
120 | + */ | ||
121 | + tcg_gen_deposit_z_i64(tcg_rd, tcg_tmp, pos, len); | ||
122 | + } | ||
123 | + return true; | ||
124 | +} | ||
125 | + | ||
126 | +static bool trans_UBFM(DisasContext *s, arg_UBFM *a) | ||
127 | +{ | ||
128 | + TCGv_i64 tcg_rd = cpu_reg(s, a->rd); | ||
129 | + TCGv_i64 tcg_tmp = read_cpu_reg(s, a->rn, 1); | ||
130 | + unsigned int bitsize = a->sf ? 64 : 32; | ||
131 | + unsigned int ri = a->immr; | ||
132 | + unsigned int si = a->imms; | ||
133 | + unsigned int pos, len; | ||
134 | + | ||
135 | + tcg_rd = cpu_reg(s, a->rd); | ||
136 | + tcg_tmp = read_cpu_reg(s, a->rn, 1); | ||
137 | + | ||
138 | + if (si >= ri) { | ||
139 | + /* Wd<s-r:0> = Wn<s:r> */ | ||
140 | + len = (si - ri) + 1; | ||
141 | + tcg_gen_extract_i64(tcg_rd, tcg_tmp, ri, len); | ||
142 | + } else { | ||
143 | + /* Wd<32+s-r,32-r> = Wn<s:0> */ | ||
144 | + len = si + 1; | ||
145 | + pos = (bitsize - ri) & (bitsize - 1); | ||
146 | + tcg_gen_deposit_z_i64(tcg_rd, tcg_tmp, pos, len); | ||
147 | + } | ||
148 | + return true; | ||
149 | +} | ||
150 | + | ||
151 | +static bool trans_BFM(DisasContext *s, arg_BFM *a) | ||
152 | +{ | ||
153 | + TCGv_i64 tcg_rd = cpu_reg(s, a->rd); | ||
154 | + TCGv_i64 tcg_tmp = read_cpu_reg(s, a->rn, 1); | ||
155 | + unsigned int bitsize = a->sf ? 64 : 32; | ||
156 | + unsigned int ri = a->immr; | ||
157 | + unsigned int si = a->imms; | ||
158 | + unsigned int pos, len; | ||
159 | + | ||
160 | + tcg_rd = cpu_reg(s, a->rd); | ||
161 | + tcg_tmp = read_cpu_reg(s, a->rn, 1); | ||
162 | + | ||
163 | + if (si >= ri) { | ||
164 | + /* Wd<s-r:0> = Wn<s:r> */ | ||
165 | tcg_gen_shri_i64(tcg_tmp, tcg_tmp, ri); | ||
166 | + len = (si - ri) + 1; | ||
167 | pos = 0; | ||
168 | } else { | ||
169 | - /* Handle the ri > si case with a deposit | ||
170 | - * Wd<32+s-r,32-r> = Wn<s:0> | ||
171 | - */ | ||
172 | + /* Wd<32+s-r,32-r> = Wn<s:0> */ | ||
173 | len = si + 1; | ||
174 | pos = (bitsize - ri) & (bitsize - 1); | ||
152 | } | 175 | } |
153 | 176 | ||
154 | -DO_PREWIDEN(VADDL_S, s, ext, add, false) | 177 | - if (opc == 0 && len < ri) { |
155 | -DO_PREWIDEN(VADDL_U, u, extu, add, false) | 178 | - /* SBFM: sign extend the destination field from len to fill |
156 | -DO_PREWIDEN(VSUBL_S, s, ext, sub, false) | 179 | - the balance of the word. Let the deposit below insert all |
157 | -DO_PREWIDEN(VSUBL_U, u, extu, sub, false) | 180 | - of those sign bits. */ |
158 | -DO_PREWIDEN(VADDW_S, s, ext, add, true) | 181 | - tcg_gen_sextract_i64(tcg_tmp, tcg_tmp, 0, len); |
159 | -DO_PREWIDEN(VADDW_U, u, extu, add, true) | 182 | - len = ri; |
160 | -DO_PREWIDEN(VSUBW_S, s, ext, sub, true) | 183 | - } |
161 | -DO_PREWIDEN(VSUBW_U, u, extu, sub, true) | 184 | - |
162 | +DO_PREWIDEN(VADDL_S, s, add, false, MO_SIGN) | 185 | - if (opc == 1) { /* BFM, BFXIL */ |
163 | +DO_PREWIDEN(VADDL_U, u, add, false, 0) | 186 | - tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, pos, len); |
164 | +DO_PREWIDEN(VSUBL_S, s, sub, false, MO_SIGN) | 187 | - } else { |
165 | +DO_PREWIDEN(VSUBL_U, u, sub, false, 0) | 188 | - /* SBFM or UBFM: We start with zero, and we haven't modified |
166 | +DO_PREWIDEN(VADDW_S, s, add, true, MO_SIGN) | 189 | - any bits outside bitsize, therefore the zero-extension |
167 | +DO_PREWIDEN(VADDW_U, u, add, true, 0) | 190 | - below is unneeded. */ |
168 | +DO_PREWIDEN(VSUBW_S, s, sub, true, MO_SIGN) | 191 | - tcg_gen_deposit_z_i64(tcg_rd, tcg_tmp, pos, len); |
169 | +DO_PREWIDEN(VSUBW_U, u, sub, true, 0) | 192 | - return; |
170 | 193 | - } | |
171 | static bool do_narrow_3d(DisasContext *s, arg_3diff *a, | 194 | - |
172 | NeonGenTwo64OpFn *opfn, NeonGenNarrowFn *narrowfn) | 195 | - done: |
196 | - if (!sf) { /* zero extend final result */ | ||
197 | + tcg_gen_deposit_i64(tcg_rd, tcg_rd, tcg_tmp, pos, len); | ||
198 | + if (!a->sf) { | ||
199 | tcg_gen_ext32u_i64(tcg_rd, tcg_rd); | ||
200 | } | ||
201 | + return true; | ||
202 | } | ||
203 | |||
204 | /* Extract | ||
205 | @@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn) | ||
206 | static void disas_data_proc_imm(DisasContext *s, uint32_t insn) | ||
207 | { | ||
208 | switch (extract32(insn, 23, 6)) { | ||
209 | - case 0x26: /* Bitfield */ | ||
210 | - disas_bitfield(s, insn); | ||
211 | - break; | ||
212 | case 0x27: /* Extract */ | ||
213 | disas_extract(s, insn); | ||
214 | break; | ||
173 | -- | 215 | -- |
174 | 2.20.1 | 216 | 2.34.1 |
175 | |||
176 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Convert the EXTR instruction to decodetree (this is the | ||
2 | only one in the 'Extract" class). This is the last of | ||
3 | the dp-immediate insns in the legacy decoder, so we | ||
4 | can now remove disas_data_proc_imm(). | ||
1 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20230512144106.3608981-13-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/tcg/a64.decode | 7 +++ | ||
11 | target/arm/tcg/translate-a64.c | 94 +++++++++++----------------------- | ||
12 | 2 files changed, 36 insertions(+), 65 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/tcg/a64.decode | ||
17 | +++ b/target/arm/tcg/a64.decode | ||
18 | @@ -XXX,XX +XXX,XX @@ BFM . 01 100110 . ...... ...... ..... ..... @bitfield_64 | ||
19 | BFM . 01 100110 . ...... ...... ..... ..... @bitfield_32 | ||
20 | UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_64 | ||
21 | UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_32 | ||
22 | + | ||
23 | +# Extract | ||
24 | + | ||
25 | +&extract rd rn rm imm sf | ||
26 | + | ||
27 | +EXTR 1 00 100111 1 0 rm:5 imm:6 rn:5 rd:5 &extract sf=1 | ||
28 | +EXTR 0 00 100111 0 0 rm:5 0 imm:5 rn:5 rd:5 &extract sf=0 | ||
29 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/tcg/translate-a64.c | ||
32 | +++ b/target/arm/tcg/translate-a64.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static bool trans_BFM(DisasContext *s, arg_BFM *a) | ||
34 | return true; | ||
35 | } | ||
36 | |||
37 | -/* Extract | ||
38 | - * 31 30 29 28 23 22 21 20 16 15 10 9 5 4 0 | ||
39 | - * +----+------+-------------+---+----+------+--------+------+------+ | ||
40 | - * | sf | op21 | 1 0 0 1 1 1 | N | o0 | Rm | imms | Rn | Rd | | ||
41 | - * +----+------+-------------+---+----+------+--------+------+------+ | ||
42 | - */ | ||
43 | -static void disas_extract(DisasContext *s, uint32_t insn) | ||
44 | +static bool trans_EXTR(DisasContext *s, arg_extract *a) | ||
45 | { | ||
46 | - unsigned int sf, n, rm, imm, rn, rd, bitsize, op21, op0; | ||
47 | + TCGv_i64 tcg_rd, tcg_rm, tcg_rn; | ||
48 | |||
49 | - sf = extract32(insn, 31, 1); | ||
50 | - n = extract32(insn, 22, 1); | ||
51 | - rm = extract32(insn, 16, 5); | ||
52 | - imm = extract32(insn, 10, 6); | ||
53 | - rn = extract32(insn, 5, 5); | ||
54 | - rd = extract32(insn, 0, 5); | ||
55 | - op21 = extract32(insn, 29, 2); | ||
56 | - op0 = extract32(insn, 21, 1); | ||
57 | - bitsize = sf ? 64 : 32; | ||
58 | + tcg_rd = cpu_reg(s, a->rd); | ||
59 | |||
60 | - if (sf != n || op21 || op0 || imm >= bitsize) { | ||
61 | - unallocated_encoding(s); | ||
62 | - } else { | ||
63 | - TCGv_i64 tcg_rd, tcg_rm, tcg_rn; | ||
64 | - | ||
65 | - tcg_rd = cpu_reg(s, rd); | ||
66 | - | ||
67 | - if (unlikely(imm == 0)) { | ||
68 | - /* tcg shl_i32/shl_i64 is undefined for 32/64 bit shifts, | ||
69 | - * so an extract from bit 0 is a special case. | ||
70 | - */ | ||
71 | - if (sf) { | ||
72 | - tcg_gen_mov_i64(tcg_rd, cpu_reg(s, rm)); | ||
73 | - } else { | ||
74 | - tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, rm)); | ||
75 | - } | ||
76 | + if (unlikely(a->imm == 0)) { | ||
77 | + /* | ||
78 | + * tcg shl_i32/shl_i64 is undefined for 32/64 bit shifts, | ||
79 | + * so an extract from bit 0 is a special case. | ||
80 | + */ | ||
81 | + if (a->sf) { | ||
82 | + tcg_gen_mov_i64(tcg_rd, cpu_reg(s, a->rm)); | ||
83 | } else { | ||
84 | - tcg_rm = cpu_reg(s, rm); | ||
85 | - tcg_rn = cpu_reg(s, rn); | ||
86 | + tcg_gen_ext32u_i64(tcg_rd, cpu_reg(s, a->rm)); | ||
87 | + } | ||
88 | + } else { | ||
89 | + tcg_rm = cpu_reg(s, a->rm); | ||
90 | + tcg_rn = cpu_reg(s, a->rn); | ||
91 | |||
92 | - if (sf) { | ||
93 | - /* Specialization to ROR happens in EXTRACT2. */ | ||
94 | - tcg_gen_extract2_i64(tcg_rd, tcg_rm, tcg_rn, imm); | ||
95 | + if (a->sf) { | ||
96 | + /* Specialization to ROR happens in EXTRACT2. */ | ||
97 | + tcg_gen_extract2_i64(tcg_rd, tcg_rm, tcg_rn, a->imm); | ||
98 | + } else { | ||
99 | + TCGv_i32 t0 = tcg_temp_new_i32(); | ||
100 | + | ||
101 | + tcg_gen_extrl_i64_i32(t0, tcg_rm); | ||
102 | + if (a->rm == a->rn) { | ||
103 | + tcg_gen_rotri_i32(t0, t0, a->imm); | ||
104 | } else { | ||
105 | - TCGv_i32 t0 = tcg_temp_new_i32(); | ||
106 | - | ||
107 | - tcg_gen_extrl_i64_i32(t0, tcg_rm); | ||
108 | - if (rm == rn) { | ||
109 | - tcg_gen_rotri_i32(t0, t0, imm); | ||
110 | - } else { | ||
111 | - TCGv_i32 t1 = tcg_temp_new_i32(); | ||
112 | - tcg_gen_extrl_i64_i32(t1, tcg_rn); | ||
113 | - tcg_gen_extract2_i32(t0, t0, t1, imm); | ||
114 | - } | ||
115 | - tcg_gen_extu_i32_i64(tcg_rd, t0); | ||
116 | + TCGv_i32 t1 = tcg_temp_new_i32(); | ||
117 | + tcg_gen_extrl_i64_i32(t1, tcg_rn); | ||
118 | + tcg_gen_extract2_i32(t0, t0, t1, a->imm); | ||
119 | } | ||
120 | + tcg_gen_extu_i32_i64(tcg_rd, t0); | ||
121 | } | ||
122 | } | ||
123 | -} | ||
124 | - | ||
125 | -/* Data processing - immediate */ | ||
126 | -static void disas_data_proc_imm(DisasContext *s, uint32_t insn) | ||
127 | -{ | ||
128 | - switch (extract32(insn, 23, 6)) { | ||
129 | - case 0x27: /* Extract */ | ||
130 | - disas_extract(s, insn); | ||
131 | - break; | ||
132 | - default: | ||
133 | - unallocated_encoding(s); | ||
134 | - break; | ||
135 | - } | ||
136 | + return true; | ||
137 | } | ||
138 | |||
139 | /* Shift a TCGv src by TCGv shift_amount, put result in dst. | ||
140 | @@ -XXX,XX +XXX,XX @@ static bool btype_destination_ok(uint32_t insn, bool bt, int btype) | ||
141 | static void disas_a64_legacy(DisasContext *s, uint32_t insn) | ||
142 | { | ||
143 | switch (extract32(insn, 25, 4)) { | ||
144 | - case 0x8: case 0x9: /* Data processing - immediate */ | ||
145 | - disas_data_proc_imm(s, insn); | ||
146 | - break; | ||
147 | case 0xa: case 0xb: /* Branch, exception generation and system insns */ | ||
148 | disas_b_exc_sys(s, insn); | ||
149 | break; | ||
150 | -- | ||
151 | 2.34.1 | diff view generated by jsdifflib |
1 | Sphinx 3.2 is pickier than earlier versions about the option:: markup, | 1 | Convert the unconditional branch immediate insns B and BL to |
---|---|---|---|
2 | and complains about our usage in qemu-option-trace.rst: | 2 | decodetree. |
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: Richard Henderson <richard.henderson@linaro.org> |
21 | Tested-by: Stefan Hajnoczi <stefanha@redhat.com> | 6 | Message-id: 20230512144106.3608981-14-peter.maydell@linaro.org |
22 | Message-id: 20201030174700.7204-3-peter.maydell@linaro.org | ||
23 | --- | 7 | --- |
24 | docs/qemu-option-trace.rst.inc | 6 +++--- | 8 | target/arm/tcg/a64.decode | 9 +++++++++ |
25 | 1 file changed, 3 insertions(+), 3 deletions(-) | 9 | target/arm/tcg/translate-a64.c | 31 +++++++++++-------------------- |
10 | 2 files changed, 20 insertions(+), 20 deletions(-) | ||
26 | 11 | ||
27 | diff --git a/docs/qemu-option-trace.rst.inc b/docs/qemu-option-trace.rst.inc | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
28 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/docs/qemu-option-trace.rst.inc | 14 | --- a/target/arm/tcg/a64.decode |
30 | +++ b/docs/qemu-option-trace.rst.inc | 15 | +++ b/target/arm/tcg/a64.decode |
31 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ |
32 | 17 | ||
33 | Specify tracing options. | 18 | &ri rd imm |
34 | 19 | &rri_sf rd rn imm sf | |
35 | -.. option:: [enable=]PATTERN | 20 | +&i imm |
36 | +``[enable=]PATTERN`` | 21 | |
37 | 22 | ||
38 | Immediately enable events matching *PATTERN* | 23 | ### Data Processing - Immediate |
39 | (either event name or a globbing pattern). This option is only | 24 | @@ -XXX,XX +XXX,XX @@ UBFM . 10 100110 . ...... ...... ..... ..... @bitfield_32 |
40 | @@ -XXX,XX +XXX,XX @@ Specify tracing options. | 25 | |
41 | 26 | EXTR 1 00 100111 1 0 rm:5 imm:6 rn:5 rd:5 &extract sf=1 | |
42 | Use :option:`-trace help` to print a list of names of trace points. | 27 | EXTR 0 00 100111 0 0 rm:5 0 imm:5 rn:5 rd:5 &extract sf=0 |
43 | 28 | + | |
44 | -.. option:: events=FILE | 29 | +# Branches |
45 | +``events=FILE`` | 30 | + |
46 | 31 | +%imm26 0:s26 !function=times_4 | |
47 | Immediately enable events listed in *FILE*. | 32 | +@branch . ..... .......................... &i imm=%imm26 |
48 | The file must contain one event name (as listed in the ``trace-events-all`` | 33 | + |
49 | @@ -XXX,XX +XXX,XX @@ Specify tracing options. | 34 | +B 0 00101 .......................... @branch |
50 | available if QEMU has been compiled with the ``simple``, ``log`` or | 35 | +BL 1 00101 .......................... @branch |
51 | ``ftrace`` tracing backend. | 36 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
52 | 37 | index XXXXXXX..XXXXXXX 100644 | |
53 | -.. option:: file=FILE | 38 | --- a/target/arm/tcg/translate-a64.c |
54 | +``file=FILE`` | 39 | +++ b/target/arm/tcg/translate-a64.c |
55 | 40 | @@ -XXX,XX +XXX,XX @@ static inline AArch64DecodeFn *lookup_disas_fn(const AArch64DecodeTable *table, | |
56 | Log output traces to *FILE*. | 41 | * match up with those in the manual. |
57 | This option is only available if QEMU has been compiled with | 42 | */ |
43 | |||
44 | -/* Unconditional branch (immediate) | ||
45 | - * 31 30 26 25 0 | ||
46 | - * +----+-----------+-------------------------------------+ | ||
47 | - * | op | 0 0 1 0 1 | imm26 | | ||
48 | - * +----+-----------+-------------------------------------+ | ||
49 | - */ | ||
50 | -static void disas_uncond_b_imm(DisasContext *s, uint32_t insn) | ||
51 | +static bool trans_B(DisasContext *s, arg_i *a) | ||
52 | { | ||
53 | - int64_t diff = sextract32(insn, 0, 26) * 4; | ||
54 | - | ||
55 | - if (insn & (1U << 31)) { | ||
56 | - /* BL Branch with link */ | ||
57 | - gen_pc_plus_diff(s, cpu_reg(s, 30), curr_insn_len(s)); | ||
58 | - } | ||
59 | - | ||
60 | - /* B Branch / BL Branch with link */ | ||
61 | reset_btype(s); | ||
62 | - gen_goto_tb(s, 0, diff); | ||
63 | + gen_goto_tb(s, 0, a->imm); | ||
64 | + return true; | ||
65 | +} | ||
66 | + | ||
67 | +static bool trans_BL(DisasContext *s, arg_i *a) | ||
68 | +{ | ||
69 | + gen_pc_plus_diff(s, cpu_reg(s, 30), curr_insn_len(s)); | ||
70 | + reset_btype(s); | ||
71 | + gen_goto_tb(s, 0, a->imm); | ||
72 | + return true; | ||
73 | } | ||
74 | |||
75 | /* Compare and branch (immediate) | ||
76 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
77 | static void disas_b_exc_sys(DisasContext *s, uint32_t insn) | ||
78 | { | ||
79 | switch (extract32(insn, 25, 7)) { | ||
80 | - case 0x0a: case 0x0b: | ||
81 | - case 0x4a: case 0x4b: /* Unconditional branch (immediate) */ | ||
82 | - disas_uncond_b_imm(s, insn); | ||
83 | - break; | ||
84 | case 0x1a: case 0x5a: /* Compare & branch (immediate) */ | ||
85 | disas_comp_b_imm(s, insn); | ||
86 | break; | ||
58 | -- | 87 | -- |
59 | 2.20.1 | 88 | 2.34.1 |
60 | |||
61 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Convert the compare-and-branch-immediate insns CBZ and CBNZ | ||
2 | to decodetree. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20230512144106.3608981-15-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/tcg/a64.decode | 5 +++++ | ||
9 | target/arm/tcg/translate-a64.c | 26 ++++++-------------------- | ||
10 | 2 files changed, 11 insertions(+), 20 deletions(-) | ||
11 | |||
12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/arm/tcg/a64.decode | ||
15 | +++ b/target/arm/tcg/a64.decode | ||
16 | @@ -XXX,XX +XXX,XX @@ EXTR 0 00 100111 0 0 rm:5 0 imm:5 rn:5 rd:5 &extract sf=0 | ||
17 | |||
18 | B 0 00101 .......................... @branch | ||
19 | BL 1 00101 .......................... @branch | ||
20 | + | ||
21 | +%imm19 5:s19 !function=times_4 | ||
22 | +&cbz rt imm sf nz | ||
23 | + | ||
24 | +CBZ sf:1 011010 nz:1 ................... rt:5 &cbz imm=%imm19 | ||
25 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/tcg/translate-a64.c | ||
28 | +++ b/target/arm/tcg/translate-a64.c | ||
29 | @@ -XXX,XX +XXX,XX @@ static bool trans_BL(DisasContext *s, arg_i *a) | ||
30 | return true; | ||
31 | } | ||
32 | |||
33 | -/* Compare and branch (immediate) | ||
34 | - * 31 30 25 24 23 5 4 0 | ||
35 | - * +----+-------------+----+---------------------+--------+ | ||
36 | - * | sf | 0 1 1 0 1 0 | op | imm19 | Rt | | ||
37 | - * +----+-------------+----+---------------------+--------+ | ||
38 | - */ | ||
39 | -static void disas_comp_b_imm(DisasContext *s, uint32_t insn) | ||
40 | + | ||
41 | +static bool trans_CBZ(DisasContext *s, arg_cbz *a) | ||
42 | { | ||
43 | - unsigned int sf, op, rt; | ||
44 | - int64_t diff; | ||
45 | DisasLabel match; | ||
46 | TCGv_i64 tcg_cmp; | ||
47 | |||
48 | - sf = extract32(insn, 31, 1); | ||
49 | - op = extract32(insn, 24, 1); /* 0: CBZ; 1: CBNZ */ | ||
50 | - rt = extract32(insn, 0, 5); | ||
51 | - diff = sextract32(insn, 5, 19) * 4; | ||
52 | - | ||
53 | - tcg_cmp = read_cpu_reg(s, rt, sf); | ||
54 | + tcg_cmp = read_cpu_reg(s, a->rt, a->sf); | ||
55 | reset_btype(s); | ||
56 | |||
57 | match = gen_disas_label(s); | ||
58 | - tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, | ||
59 | + tcg_gen_brcondi_i64(a->nz ? TCG_COND_NE : TCG_COND_EQ, | ||
60 | tcg_cmp, 0, match.label); | ||
61 | gen_goto_tb(s, 0, 4); | ||
62 | set_disas_label(s, match); | ||
63 | - gen_goto_tb(s, 1, diff); | ||
64 | + gen_goto_tb(s, 1, a->imm); | ||
65 | + return true; | ||
66 | } | ||
67 | |||
68 | /* Test and branch (immediate) | ||
69 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
70 | static void disas_b_exc_sys(DisasContext *s, uint32_t insn) | ||
71 | { | ||
72 | switch (extract32(insn, 25, 7)) { | ||
73 | - case 0x1a: case 0x5a: /* Compare & branch (immediate) */ | ||
74 | - disas_comp_b_imm(s, insn); | ||
75 | - break; | ||
76 | case 0x1b: case 0x5b: /* Test & branch (immediate) */ | ||
77 | disas_test_b_imm(s, insn); | ||
78 | break; | ||
79 | -- | ||
80 | 2.34.1 | diff view generated by jsdifflib |
1 | The kerneldoc script currently emits Sphinx markup for a macro with | 1 | Convert the test-and-branch-immediate insns TBZ and TBNZ |
---|---|---|---|
2 | arguments that uses the c:function directive. This is correct for | 2 | to decodetree. |
3 | Sphinx versions earlier than Sphinx 3, where c:macro doesn't allow | ||
4 | documentation of macros with arguments and c:function is not picky | ||
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 | |||
9 | When kerneldoc is told that it needs to produce output for Sphinx | ||
10 | 3 or later, make it emit c:function only for functions and c:macro | ||
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 | 3 | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
28 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
29 | Tested-by: Stefan Hajnoczi <stefanha@redhat.com> | 6 | Message-id: 20230512144106.3608981-16-peter.maydell@linaro.org |
30 | Message-id: 20201030174700.7204-2-peter.maydell@linaro.org | ||
31 | --- | 7 | --- |
32 | scripts/kernel-doc | 18 +++++++++++++++++- | 8 | target/arm/tcg/a64.decode | 6 ++++++ |
33 | 1 file changed, 17 insertions(+), 1 deletion(-) | 9 | target/arm/tcg/translate-a64.c | 25 +++++-------------------- |
10 | 2 files changed, 11 insertions(+), 20 deletions(-) | ||
34 | 11 | ||
35 | diff --git a/scripts/kernel-doc b/scripts/kernel-doc | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
36 | index XXXXXXX..XXXXXXX 100755 | 13 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/scripts/kernel-doc | 14 | --- a/target/arm/tcg/a64.decode |
38 | +++ b/scripts/kernel-doc | 15 | +++ b/target/arm/tcg/a64.decode |
39 | @@ -XXX,XX +XXX,XX @@ sub output_function_rst(%) { | 16 | @@ -XXX,XX +XXX,XX @@ BL 1 00101 .......................... @branch |
40 | output_highlight_rst($args{'purpose'}); | 17 | &cbz rt imm sf nz |
41 | $start = "\n\n**Syntax**\n\n ``"; | 18 | |
42 | } else { | 19 | CBZ sf:1 011010 nz:1 ................... rt:5 &cbz imm=%imm19 |
43 | - print ".. c:function:: "; | 20 | + |
44 | + if ((split(/\./, $sphinx_version))[0] >= 3) { | 21 | +%imm14 5:s14 !function=times_4 |
45 | + # Sphinx 3 and later distinguish macros and functions and | 22 | +%imm31_19 31:1 19:5 |
46 | + # complain if you use c:function with something that's not | 23 | +&tbz rt imm nz bitpos |
47 | + # syntactically valid as a function declaration. | 24 | + |
48 | + # We assume that anything with a return type is a function | 25 | +TBZ . 011011 nz:1 ..... .............. rt:5 &tbz imm=%imm14 bitpos=%imm31_19 |
49 | + # and anything without is a macro. | 26 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
50 | + if ($args{'functiontype'} ne "") { | 27 | index XXXXXXX..XXXXXXX 100644 |
51 | + print ".. c:function:: "; | 28 | --- a/target/arm/tcg/translate-a64.c |
52 | + } else { | 29 | +++ b/target/arm/tcg/translate-a64.c |
53 | + print ".. c:macro:: "; | 30 | @@ -XXX,XX +XXX,XX @@ static bool trans_CBZ(DisasContext *s, arg_cbz *a) |
54 | + } | 31 | return true; |
55 | + } else { | 32 | } |
56 | + # Older Sphinx don't support documenting macros that take | 33 | |
57 | + # arguments with c:macro, and don't complain about the use | 34 | -/* Test and branch (immediate) |
58 | + # of c:function for this. | 35 | - * 31 30 25 24 23 19 18 5 4 0 |
59 | + print ".. c:function:: "; | 36 | - * +----+-------------+----+-------+-------------+------+ |
60 | + } | 37 | - * | b5 | 0 1 1 0 1 1 | op | b40 | imm14 | Rt | |
61 | } | 38 | - * +----+-------------+----+-------+-------------+------+ |
62 | if ($args{'functiontype'} ne "") { | 39 | - */ |
63 | $start .= $args{'functiontype'} . " " . $args{'function'} . " ("; | 40 | -static void disas_test_b_imm(DisasContext *s, uint32_t insn) |
41 | +static bool trans_TBZ(DisasContext *s, arg_tbz *a) | ||
42 | { | ||
43 | - unsigned int bit_pos, op, rt; | ||
44 | - int64_t diff; | ||
45 | DisasLabel match; | ||
46 | TCGv_i64 tcg_cmp; | ||
47 | |||
48 | - bit_pos = (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5); | ||
49 | - op = extract32(insn, 24, 1); /* 0: TBZ; 1: TBNZ */ | ||
50 | - diff = sextract32(insn, 5, 14) * 4; | ||
51 | - rt = extract32(insn, 0, 5); | ||
52 | - | ||
53 | tcg_cmp = tcg_temp_new_i64(); | ||
54 | - tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, rt), (1ULL << bit_pos)); | ||
55 | + tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, a->rt), 1ULL << a->bitpos); | ||
56 | |||
57 | reset_btype(s); | ||
58 | |||
59 | match = gen_disas_label(s); | ||
60 | - tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, | ||
61 | + tcg_gen_brcondi_i64(a->nz ? TCG_COND_NE : TCG_COND_EQ, | ||
62 | tcg_cmp, 0, match.label); | ||
63 | gen_goto_tb(s, 0, 4); | ||
64 | set_disas_label(s, match); | ||
65 | - gen_goto_tb(s, 1, diff); | ||
66 | + gen_goto_tb(s, 1, a->imm); | ||
67 | + return true; | ||
68 | } | ||
69 | |||
70 | /* Conditional branch (immediate) | ||
71 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
72 | static void disas_b_exc_sys(DisasContext *s, uint32_t insn) | ||
73 | { | ||
74 | switch (extract32(insn, 25, 7)) { | ||
75 | - case 0x1b: case 0x5b: /* Test & branch (immediate) */ | ||
76 | - disas_test_b_imm(s, insn); | ||
77 | - break; | ||
78 | case 0x2a: /* Conditional branch (immediate) */ | ||
79 | disas_cond_b_imm(s, insn); | ||
80 | break; | ||
64 | -- | 81 | -- |
65 | 2.20.1 | 82 | 2.34.1 |
66 | |||
67 | diff view generated by jsdifflib |
1 | In gicv3_init_cpuif() we copy the ARMCPU gicv3_maintenance_interrupt | 1 | Convert the immediate conditional branch insn B.cond to |
---|---|---|---|
2 | into the GICv3CPUState struct's maintenance_irq field. This will | 2 | decodetree. |
3 | only work if the board happens to have already wired up the CPU | ||
4 | maintenance IRQ before the GIC was realized. Unfortunately this is | ||
5 | not the case for the 'virt' board, and so the value that gets copied | ||
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 | 3 | ||
10 | Instead, since the GICv3CPUState has a pointer to the CPUState, make | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | the dereference at the point where we want to raise the interrupt, to | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | avoid an implicit requirement on board code to wire things up in a | 6 | Message-id: 20230512144106.3608981-17-peter.maydell@linaro.org |
13 | particular order. | 7 | --- |
8 | target/arm/tcg/a64.decode | 2 ++ | ||
9 | target/arm/tcg/translate-a64.c | 30 ++++++------------------------ | ||
10 | 2 files changed, 8 insertions(+), 24 deletions(-) | ||
14 | 11 | ||
15 | Reported-by: Jose Martins <josemartins90@gmail.com> | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Message-id: 20201009153904.28529-1-peter.maydell@linaro.org | ||
18 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
19 | --- | ||
20 | include/hw/intc/arm_gicv3_common.h | 1 - | ||
21 | hw/intc/arm_gicv3_cpuif.c | 5 ++--- | ||
22 | 2 files changed, 2 insertions(+), 4 deletions(-) | ||
23 | |||
24 | diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/intc/arm_gicv3_common.h | 14 | --- a/target/arm/tcg/a64.decode |
27 | +++ b/include/hw/intc/arm_gicv3_common.h | 15 | +++ b/target/arm/tcg/a64.decode |
28 | @@ -XXX,XX +XXX,XX @@ struct GICv3CPUState { | 16 | @@ -XXX,XX +XXX,XX @@ CBZ sf:1 011010 nz:1 ................... rt:5 &cbz imm=%imm19 |
29 | qemu_irq parent_fiq; | 17 | &tbz rt imm nz bitpos |
30 | qemu_irq parent_virq; | 18 | |
31 | qemu_irq parent_vfiq; | 19 | TBZ . 011011 nz:1 ..... .............. rt:5 &tbz imm=%imm14 bitpos=%imm31_19 |
32 | - qemu_irq maintenance_irq; | 20 | + |
33 | 21 | +B_cond 0101010 0 ................... 0 cond:4 imm=%imm19 | |
34 | /* Redistributor */ | 22 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
35 | uint32_t level; /* Current IRQ level */ | ||
36 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/intc/arm_gicv3_cpuif.c | 24 | --- a/target/arm/tcg/translate-a64.c |
39 | +++ b/hw/intc/arm_gicv3_cpuif.c | 25 | +++ b/target/arm/tcg/translate-a64.c |
40 | @@ -XXX,XX +XXX,XX @@ static void gicv3_cpuif_virt_update(GICv3CPUState *cs) | 26 | @@ -XXX,XX +XXX,XX @@ static bool trans_TBZ(DisasContext *s, arg_tbz *a) |
41 | int irqlevel = 0; | 27 | return true; |
42 | int fiqlevel = 0; | ||
43 | int maintlevel = 0; | ||
44 | + ARMCPU *cpu = ARM_CPU(cs->cpu); | ||
45 | |||
46 | idx = hppvi_index(cs); | ||
47 | trace_gicv3_cpuif_virt_update(gicv3_redist_affid(cs), idx); | ||
48 | @@ -XXX,XX +XXX,XX @@ static void gicv3_cpuif_virt_update(GICv3CPUState *cs) | ||
49 | |||
50 | qemu_set_irq(cs->parent_vfiq, fiqlevel); | ||
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 | } | 28 | } |
55 | 29 | ||
56 | static uint64_t icv_ap_read(CPUARMState *env, const ARMCPRegInfo *ri) | 30 | -/* Conditional branch (immediate) |
57 | @@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s) | 31 | - * 31 25 24 23 5 4 3 0 |
58 | && cpu->gic_num_lrs) { | 32 | - * +---------------+----+---------------------+----+------+ |
59 | int j; | 33 | - * | 0 1 0 1 0 1 0 | o1 | imm19 | o0 | cond | |
60 | 34 | - * +---------------+----+---------------------+----+------+ | |
61 | - cs->maintenance_irq = cpu->gicv3_maintenance_interrupt; | 35 | - */ |
36 | -static void disas_cond_b_imm(DisasContext *s, uint32_t insn) | ||
37 | +static bool trans_B_cond(DisasContext *s, arg_B_cond *a) | ||
38 | { | ||
39 | - unsigned int cond; | ||
40 | - int64_t diff; | ||
62 | - | 41 | - |
63 | cs->num_list_regs = cpu->gic_num_lrs; | 42 | - if ((insn & (1 << 4)) || (insn & (1 << 24))) { |
64 | cs->vpribits = cpu->gic_vpribits; | 43 | - unallocated_encoding(s); |
65 | cs->vprebits = cpu->gic_vprebits; | 44 | - return; |
45 | - } | ||
46 | - diff = sextract32(insn, 5, 19) * 4; | ||
47 | - cond = extract32(insn, 0, 4); | ||
48 | - | ||
49 | reset_btype(s); | ||
50 | - if (cond < 0x0e) { | ||
51 | + if (a->cond < 0x0e) { | ||
52 | /* genuinely conditional branches */ | ||
53 | DisasLabel match = gen_disas_label(s); | ||
54 | - arm_gen_test_cc(cond, match.label); | ||
55 | + arm_gen_test_cc(a->cond, match.label); | ||
56 | gen_goto_tb(s, 0, 4); | ||
57 | set_disas_label(s, match); | ||
58 | - gen_goto_tb(s, 1, diff); | ||
59 | + gen_goto_tb(s, 1, a->imm); | ||
60 | } else { | ||
61 | /* 0xe and 0xf are both "always" conditions */ | ||
62 | - gen_goto_tb(s, 0, diff); | ||
63 | + gen_goto_tb(s, 0, a->imm); | ||
64 | } | ||
65 | + return true; | ||
66 | } | ||
67 | |||
68 | /* HINT instruction group, including various allocated HINTs */ | ||
69 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
70 | static void disas_b_exc_sys(DisasContext *s, uint32_t insn) | ||
71 | { | ||
72 | switch (extract32(insn, 25, 7)) { | ||
73 | - case 0x2a: /* Conditional branch (immediate) */ | ||
74 | - disas_cond_b_imm(s, insn); | ||
75 | - break; | ||
76 | case 0x6a: /* Exception generation / System */ | ||
77 | if (insn & (1 << 24)) { | ||
78 | if (extract32(insn, 22, 2) == 0) { | ||
66 | -- | 79 | -- |
67 | 2.20.1 | 80 | 2.34.1 |
68 | |||
69 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Convert the simple (non-pointer-auth) BR, BLR and RET insns |
---|---|---|---|
2 | to decodetree. | ||
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: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20230512144106.3608981-18-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/tcg/a64.decode | 5 ++++ | ||
9 | target/arm/tcg/translate-a64.c | 55 ++++++++++++++++++++++++++++++---- | ||
10 | 2 files changed, 54 insertions(+), 6 deletions(-) | ||
4 | 11 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
6 | Message-id: 20201030022618.785675-9-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/translate.c | 26 +++++++++ | ||
11 | target/arm/translate-neon.c.inc | 94 ++++++++++++++++----------------- | ||
12 | 2 files changed, 73 insertions(+), 47 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 14 | --- a/target/arm/tcg/a64.decode |
17 | +++ b/target/arm/translate.c | 15 | +++ b/target/arm/tcg/a64.decode |
18 | @@ -XXX,XX +XXX,XX @@ static void read_neon_element32(TCGv_i32 dest, int reg, int ele, MemOp memop) | 16 | @@ -XXX,XX +XXX,XX @@ |
19 | } | 17 | # This file is processed by scripts/decodetree.py |
18 | # | ||
19 | |||
20 | +&r rn | ||
21 | &ri rd imm | ||
22 | &rri_sf rd rn imm sf | ||
23 | &i imm | ||
24 | @@ -XXX,XX +XXX,XX @@ CBZ sf:1 011010 nz:1 ................... rt:5 &cbz imm=%imm19 | ||
25 | TBZ . 011011 nz:1 ..... .............. rt:5 &tbz imm=%imm14 bitpos=%imm31_19 | ||
26 | |||
27 | B_cond 0101010 0 ................... 0 cond:4 imm=%imm19 | ||
28 | + | ||
29 | +BR 1101011 0000 11111 000000 rn:5 00000 &r | ||
30 | +BLR 1101011 0001 11111 000000 rn:5 00000 &r | ||
31 | +RET 1101011 0010 11111 000000 rn:5 00000 &r | ||
32 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/tcg/translate-a64.c | ||
35 | +++ b/target/arm/tcg/translate-a64.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool trans_B_cond(DisasContext *s, arg_B_cond *a) | ||
37 | return true; | ||
20 | } | 38 | } |
21 | 39 | ||
22 | +static void read_neon_element64(TCGv_i64 dest, int reg, int ele, MemOp memop) | 40 | +static void set_btype_for_br(DisasContext *s, int rn) |
23 | +{ | 41 | +{ |
24 | + long off = neon_element_offset(reg, ele, memop); | 42 | + if (dc_isar_feature(aa64_bti, s)) { |
25 | + | 43 | + /* BR to {x16,x17} or !guard -> 1, else 3. */ |
26 | + switch (memop) { | 44 | + set_btype(s, rn == 16 || rn == 17 || !s->guarded_page ? 1 : 3); |
27 | + case MO_Q: | ||
28 | + tcg_gen_ld_i64(dest, cpu_env, off); | ||
29 | + break; | ||
30 | + default: | ||
31 | + g_assert_not_reached(); | ||
32 | + } | 45 | + } |
33 | +} | 46 | +} |
34 | + | 47 | + |
35 | static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop) | 48 | +static void set_btype_for_blr(DisasContext *s) |
36 | { | ||
37 | long off = neon_element_offset(reg, ele, memop); | ||
38 | @@ -XXX,XX +XXX,XX @@ static void write_neon_element32(TCGv_i32 src, int reg, int ele, MemOp memop) | ||
39 | } | ||
40 | } | ||
41 | |||
42 | +static void write_neon_element64(TCGv_i64 src, int reg, int ele, MemOp memop) | ||
43 | +{ | 49 | +{ |
44 | + long off = neon_element_offset(reg, ele, memop); | 50 | + if (dc_isar_feature(aa64_bti, s)) { |
45 | + | 51 | + /* BLR sets BTYPE to 2, regardless of source guarded page. */ |
46 | + switch (memop) { | 52 | + set_btype(s, 2); |
47 | + case MO_64: | ||
48 | + tcg_gen_st_i64(src, cpu_env, off); | ||
49 | + break; | ||
50 | + default: | ||
51 | + g_assert_not_reached(); | ||
52 | + } | 53 | + } |
53 | +} | 54 | +} |
54 | + | 55 | + |
55 | static TCGv_ptr vfp_reg_ptr(bool dp, int reg) | 56 | +static bool trans_BR(DisasContext *s, arg_r *a) |
56 | { | 57 | +{ |
57 | TCGv_ptr ret = tcg_temp_new_ptr(); | 58 | + gen_a64_set_pc(s, cpu_reg(s, a->rn)); |
58 | diff --git a/target/arm/translate-neon.c.inc b/target/arm/translate-neon.c.inc | 59 | + set_btype_for_br(s, a->rn); |
59 | index XXXXXXX..XXXXXXX 100644 | 60 | + s->base.is_jmp = DISAS_JUMP; |
60 | --- a/target/arm/translate-neon.c.inc | 61 | + return true; |
61 | +++ b/target/arm/translate-neon.c.inc | 62 | +} |
62 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_env_64(DisasContext *s, arg_2reg_shift *a, | 63 | + |
63 | for (pass = 0; pass < a->q + 1; pass++) { | 64 | +static bool trans_BLR(DisasContext *s, arg_r *a) |
64 | TCGv_i64 tmp = tcg_temp_new_i64(); | 65 | +{ |
65 | 66 | + TCGv_i64 dst = cpu_reg(s, a->rn); | |
66 | - neon_load_reg64(tmp, a->vm + pass); | 67 | + TCGv_i64 lr = cpu_reg(s, 30); |
67 | + read_neon_element64(tmp, a->vm, pass, MO_64); | 68 | + if (dst == lr) { |
68 | fn(tmp, cpu_env, tmp, constimm); | 69 | + TCGv_i64 tmp = tcg_temp_new_i64(); |
69 | - neon_store_reg64(tmp, a->vd + pass); | 70 | + tcg_gen_mov_i64(tmp, dst); |
70 | + write_neon_element64(tmp, a->vd, pass, MO_64); | 71 | + dst = tmp; |
71 | tcg_temp_free_i64(tmp); | 72 | + } |
72 | } | 73 | + gen_pc_plus_diff(s, lr, curr_insn_len(s)); |
73 | tcg_temp_free_i64(constimm); | 74 | + gen_a64_set_pc(s, dst); |
74 | @@ -XXX,XX +XXX,XX @@ static bool do_2shift_narrow_64(DisasContext *s, arg_2reg_shift *a, | 75 | + set_btype_for_blr(s); |
75 | rd = tcg_temp_new_i32(); | 76 | + s->base.is_jmp = DISAS_JUMP; |
76 | 77 | + return true; | |
77 | /* Load both inputs first to avoid potential overwrite if rm == rd */ | 78 | +} |
78 | - neon_load_reg64(rm1, a->vm); | 79 | + |
79 | - neon_load_reg64(rm2, a->vm + 1); | 80 | +static bool trans_RET(DisasContext *s, arg_r *a) |
80 | + read_neon_element64(rm1, a->vm, 0, MO_64); | 81 | +{ |
81 | + read_neon_element64(rm2, a->vm, 1, MO_64); | 82 | + gen_a64_set_pc(s, cpu_reg(s, a->rn)); |
82 | 83 | + s->base.is_jmp = DISAS_JUMP; | |
83 | shiftfn(rm1, rm1, constimm); | 84 | + return true; |
84 | narrowfn(rd, cpu_env, rm1); | 85 | +} |
85 | @@ -XXX,XX +XXX,XX @@ static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a, | 86 | + |
86 | tcg_gen_shli_i64(tmp, tmp, a->shift); | 87 | /* HINT instruction group, including various allocated HINTs */ |
87 | tcg_gen_andi_i64(tmp, tmp, ~widen_mask); | 88 | static void handle_hint(DisasContext *s, uint32_t insn, |
88 | } | 89 | unsigned int op1, unsigned int op2, unsigned int crm) |
89 | - neon_store_reg64(tmp, a->vd); | 90 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) |
90 | + write_neon_element64(tmp, a->vd, 0, MO_64); | 91 | btype_mod = opc; |
91 | 92 | switch (op3) { | |
92 | widenfn(tmp, rm1); | 93 | case 0: |
93 | tcg_temp_free_i32(rm1); | 94 | - /* BR, BLR, RET */ |
94 | @@ -XXX,XX +XXX,XX @@ static bool do_vshll_2sh(DisasContext *s, arg_2reg_shift *a, | 95 | - if (op4 != 0) { |
95 | tcg_gen_shli_i64(tmp, tmp, a->shift); | 96 | - goto do_unallocated; |
96 | tcg_gen_andi_i64(tmp, tmp, ~widen_mask); | 97 | - } |
97 | } | 98 | - dst = cpu_reg(s, rn); |
98 | - neon_store_reg64(tmp, a->vd + 1); | 99 | - break; |
99 | + write_neon_element64(tmp, a->vd, 1, MO_64); | 100 | + /* BR, BLR, RET : handled in decodetree */ |
100 | tcg_temp_free_i64(tmp); | 101 | + goto do_unallocated; |
101 | return true; | 102 | |
102 | } | 103 | case 2: |
103 | @@ -XXX,XX +XXX,XX @@ static bool do_prewiden_3d(DisasContext *s, arg_3diff *a, | 104 | case 3: |
104 | rm_64 = tcg_temp_new_i64(); | ||
105 | |||
106 | if (src1_wide) { | ||
107 | - neon_load_reg64(rn0_64, a->vn); | ||
108 | + read_neon_element64(rn0_64, a->vn, 0, MO_64); | ||
109 | } else { | ||
110 | TCGv_i32 tmp = tcg_temp_new_i32(); | ||
111 | read_neon_element32(tmp, a->vn, 0, MO_32); | ||
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 | -- | 105 | -- |
301 | 2.20.1 | 106 | 2.34.1 |
302 | |||
303 | diff view generated by jsdifflib |
1 | In the neon_padd/pmax/pmin helpers for float16, a cut-and-paste error | 1 | Convert the single-register pointer-authentication variants of BR, |
---|---|---|---|
2 | meant we were using the H4() address swizzler macro rather than the | 2 | BLR, RET to decodetree. (BRAA/BLRAA are in a different branch of |
3 | H2() which is required for 2-byte data. This had no effect on | 3 | the legacy decoder and will be dealt with in the next commit.) |
4 | little-endian hosts but meant we put the result data into the | ||
5 | destination Dreg in the wrong order on big-endian hosts. | ||
6 | 4 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 7 | Message-id: 20230512144106.3608981-19-peter.maydell@linaro.org |
10 | Message-id: 20201028191712.4910-2-peter.maydell@linaro.org | ||
11 | --- | 8 | --- |
12 | target/arm/vec_helper.c | 8 ++++---- | 9 | target/arm/tcg/a64.decode | 7 ++ |
13 | 1 file changed, 4 insertions(+), 4 deletions(-) | 10 | target/arm/tcg/translate-a64.c | 132 +++++++++++++++++++-------------- |
11 | 2 files changed, 84 insertions(+), 55 deletions(-) | ||
14 | 12 | ||
15 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | 13 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/vec_helper.c | 15 | --- a/target/arm/tcg/a64.decode |
18 | +++ b/target/arm/vec_helper.c | 16 | +++ b/target/arm/tcg/a64.decode |
19 | @@ -XXX,XX +XXX,XX @@ DO_ABA(gvec_uaba_d, uint64_t) | 17 | @@ -XXX,XX +XXX,XX @@ B_cond 0101010 0 ................... 0 cond:4 imm=%imm19 |
20 | r2 = float16_##OP(m[H2(0)], m[H2(1)], fpst); \ | 18 | BR 1101011 0000 11111 000000 rn:5 00000 &r |
21 | r3 = float16_##OP(m[H2(2)], m[H2(3)], fpst); \ | 19 | BLR 1101011 0001 11111 000000 rn:5 00000 &r |
22 | \ | 20 | RET 1101011 0010 11111 000000 rn:5 00000 &r |
23 | - d[H4(0)] = r0; \ | 21 | + |
24 | - d[H4(1)] = r1; \ | 22 | +&braz rn m |
25 | - d[H4(2)] = r2; \ | 23 | +BRAZ 1101011 0000 11111 00001 m:1 rn:5 11111 &braz # BRAAZ, BRABZ |
26 | - d[H4(3)] = r3; \ | 24 | +BLRAZ 1101011 0001 11111 00001 m:1 rn:5 11111 &braz # BLRAAZ, BLRABZ |
27 | + d[H2(0)] = r0; \ | 25 | + |
28 | + d[H2(1)] = r1; \ | 26 | +&reta m |
29 | + d[H2(2)] = r2; \ | 27 | +RETA 1101011 0010 11111 00001 m:1 11111 11111 &reta # RETAA, RETAB |
30 | + d[H2(3)] = r3; \ | 28 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/tcg/translate-a64.c | ||
31 | +++ b/target/arm/tcg/translate-a64.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static bool trans_RET(DisasContext *s, arg_r *a) | ||
33 | return true; | ||
34 | } | ||
35 | |||
36 | +static TCGv_i64 auth_branch_target(DisasContext *s, TCGv_i64 dst, | ||
37 | + TCGv_i64 modifier, bool use_key_a) | ||
38 | +{ | ||
39 | + TCGv_i64 truedst; | ||
40 | + /* | ||
41 | + * Return the branch target for a BRAA/RETA/etc, which is either | ||
42 | + * just the destination dst, or that value with the pauth check | ||
43 | + * done and the code removed from the high bits. | ||
44 | + */ | ||
45 | + if (!s->pauth_active) { | ||
46 | + return dst; | ||
47 | + } | ||
48 | + | ||
49 | + truedst = tcg_temp_new_i64(); | ||
50 | + if (use_key_a) { | ||
51 | + gen_helper_autia(truedst, cpu_env, dst, modifier); | ||
52 | + } else { | ||
53 | + gen_helper_autib(truedst, cpu_env, dst, modifier); | ||
54 | + } | ||
55 | + return truedst; | ||
56 | +} | ||
57 | + | ||
58 | +static bool trans_BRAZ(DisasContext *s, arg_braz *a) | ||
59 | +{ | ||
60 | + TCGv_i64 dst; | ||
61 | + | ||
62 | + if (!dc_isar_feature(aa64_pauth, s)) { | ||
63 | + return false; | ||
64 | + } | ||
65 | + | ||
66 | + dst = auth_branch_target(s, cpu_reg(s, a->rn), tcg_constant_i64(0), !a->m); | ||
67 | + gen_a64_set_pc(s, dst); | ||
68 | + set_btype_for_br(s, a->rn); | ||
69 | + s->base.is_jmp = DISAS_JUMP; | ||
70 | + return true; | ||
71 | +} | ||
72 | + | ||
73 | +static bool trans_BLRAZ(DisasContext *s, arg_braz *a) | ||
74 | +{ | ||
75 | + TCGv_i64 dst, lr; | ||
76 | + | ||
77 | + if (!dc_isar_feature(aa64_pauth, s)) { | ||
78 | + return false; | ||
79 | + } | ||
80 | + | ||
81 | + dst = auth_branch_target(s, cpu_reg(s, a->rn), tcg_constant_i64(0), !a->m); | ||
82 | + lr = cpu_reg(s, 30); | ||
83 | + if (dst == lr) { | ||
84 | + TCGv_i64 tmp = tcg_temp_new_i64(); | ||
85 | + tcg_gen_mov_i64(tmp, dst); | ||
86 | + dst = tmp; | ||
87 | + } | ||
88 | + gen_pc_plus_diff(s, lr, curr_insn_len(s)); | ||
89 | + gen_a64_set_pc(s, dst); | ||
90 | + set_btype_for_blr(s); | ||
91 | + s->base.is_jmp = DISAS_JUMP; | ||
92 | + return true; | ||
93 | +} | ||
94 | + | ||
95 | +static bool trans_RETA(DisasContext *s, arg_reta *a) | ||
96 | +{ | ||
97 | + TCGv_i64 dst; | ||
98 | + | ||
99 | + dst = auth_branch_target(s, cpu_reg(s, 30), cpu_X[31], !a->m); | ||
100 | + gen_a64_set_pc(s, dst); | ||
101 | + s->base.is_jmp = DISAS_JUMP; | ||
102 | + return true; | ||
103 | +} | ||
104 | + | ||
105 | /* HINT instruction group, including various allocated HINTs */ | ||
106 | static void handle_hint(DisasContext *s, uint32_t insn, | ||
107 | unsigned int op1, unsigned int op2, unsigned int crm) | ||
108 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
31 | } | 109 | } |
32 | 110 | ||
33 | DO_NEON_PAIRWISE(neon_padd, add) | 111 | switch (opc) { |
112 | - case 0: /* BR */ | ||
113 | - case 1: /* BLR */ | ||
114 | - case 2: /* RET */ | ||
115 | - btype_mod = opc; | ||
116 | - switch (op3) { | ||
117 | - case 0: | ||
118 | - /* BR, BLR, RET : handled in decodetree */ | ||
119 | - goto do_unallocated; | ||
120 | - | ||
121 | - case 2: | ||
122 | - case 3: | ||
123 | - if (!dc_isar_feature(aa64_pauth, s)) { | ||
124 | - goto do_unallocated; | ||
125 | - } | ||
126 | - if (opc == 2) { | ||
127 | - /* RETAA, RETAB */ | ||
128 | - if (rn != 0x1f || op4 != 0x1f) { | ||
129 | - goto do_unallocated; | ||
130 | - } | ||
131 | - rn = 30; | ||
132 | - modifier = cpu_X[31]; | ||
133 | - } else { | ||
134 | - /* BRAAZ, BRABZ, BLRAAZ, BLRABZ */ | ||
135 | - if (op4 != 0x1f) { | ||
136 | - goto do_unallocated; | ||
137 | - } | ||
138 | - modifier = tcg_constant_i64(0); | ||
139 | - } | ||
140 | - if (s->pauth_active) { | ||
141 | - dst = tcg_temp_new_i64(); | ||
142 | - if (op3 == 2) { | ||
143 | - gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); | ||
144 | - } else { | ||
145 | - gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); | ||
146 | - } | ||
147 | - } else { | ||
148 | - dst = cpu_reg(s, rn); | ||
149 | - } | ||
150 | - break; | ||
151 | - | ||
152 | - default: | ||
153 | - goto do_unallocated; | ||
154 | - } | ||
155 | - /* BLR also needs to load return address */ | ||
156 | - if (opc == 1) { | ||
157 | - TCGv_i64 lr = cpu_reg(s, 30); | ||
158 | - if (dst == lr) { | ||
159 | - TCGv_i64 tmp = tcg_temp_new_i64(); | ||
160 | - tcg_gen_mov_i64(tmp, dst); | ||
161 | - dst = tmp; | ||
162 | - } | ||
163 | - gen_pc_plus_diff(s, lr, curr_insn_len(s)); | ||
164 | - } | ||
165 | - gen_a64_set_pc(s, dst); | ||
166 | - break; | ||
167 | + case 0: | ||
168 | + case 1: | ||
169 | + case 2: | ||
170 | + /* | ||
171 | + * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ: | ||
172 | + * handled in decodetree | ||
173 | + */ | ||
174 | + goto do_unallocated; | ||
175 | |||
176 | case 8: /* BRAA */ | ||
177 | case 9: /* BLRAA */ | ||
34 | -- | 178 | -- |
35 | 2.20.1 | 179 | 2.34.1 |
36 | |||
37 | diff view generated by jsdifflib |
1 | From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 1 | Convert the last four BR-with-pointer-auth insns to decodetree. |
---|---|---|---|
2 | The remaining cases in the outer switch in disas_uncond_b_reg() | ||
3 | all return early rather than leaving the case statement, so we | ||
4 | can delete the now-unused code at the end of that function. | ||
2 | 5 | ||
3 | Secure mode is not exempted from checking SCR_EL3.TLOR, and in the | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | future HCR_EL2.TLOR when S-EL2 is enabled. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20230512144106.3608981-20-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/tcg/a64.decode | 4 ++ | ||
11 | target/arm/tcg/translate-a64.c | 97 ++++++++++++++-------------------- | ||
12 | 2 files changed, 43 insertions(+), 58 deletions(-) | ||
5 | 13 | ||
6 | Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com> | 14 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/helper.c | 19 +++++-------------- | ||
11 | 1 file changed, 5 insertions(+), 14 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/helper.c | 16 | --- a/target/arm/tcg/a64.decode |
16 | +++ b/target/arm/helper.c | 17 | +++ b/target/arm/tcg/a64.decode |
17 | @@ -XXX,XX +XXX,XX @@ static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri) | 18 | @@ -XXX,XX +XXX,XX @@ BLRAZ 1101011 0001 11111 00001 m:1 rn:5 11111 &braz # BLRAAZ, BLRABZ |
18 | #endif | 19 | |
19 | 20 | &reta m | |
20 | /* Shared logic between LORID and the rest of the LOR* registers. | 21 | RETA 1101011 0010 11111 00001 m:1 11111 11111 &reta # RETAA, RETAB |
21 | - * Secure state has already been delt with. | 22 | + |
22 | + * Secure state exclusion has already been dealt with. | 23 | +&bra rn rm m |
23 | */ | 24 | +BRA 1101011 1000 11111 00001 m:1 rn:5 rm:5 &bra # BRAA, BRAB |
24 | -static CPAccessResult access_lor_ns(CPUARMState *env) | 25 | +BLRA 1101011 1001 11111 00001 m:1 rn:5 rm:5 &bra # BLRAA, BLRAB |
25 | +static CPAccessResult access_lor_ns(CPUARMState *env, | 26 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
26 | + const ARMCPRegInfo *ri, bool isread) | 27 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/tcg/translate-a64.c | ||
29 | +++ b/target/arm/tcg/translate-a64.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static bool trans_RETA(DisasContext *s, arg_reta *a) | ||
31 | return true; | ||
32 | } | ||
33 | |||
34 | +static bool trans_BRA(DisasContext *s, arg_bra *a) | ||
35 | +{ | ||
36 | + TCGv_i64 dst; | ||
37 | + | ||
38 | + if (!dc_isar_feature(aa64_pauth, s)) { | ||
39 | + return false; | ||
40 | + } | ||
41 | + dst = auth_branch_target(s, cpu_reg(s,a->rn), cpu_reg_sp(s, a->rm), !a->m); | ||
42 | + gen_a64_set_pc(s, dst); | ||
43 | + set_btype_for_br(s, a->rn); | ||
44 | + s->base.is_jmp = DISAS_JUMP; | ||
45 | + return true; | ||
46 | +} | ||
47 | + | ||
48 | +static bool trans_BLRA(DisasContext *s, arg_bra *a) | ||
49 | +{ | ||
50 | + TCGv_i64 dst, lr; | ||
51 | + | ||
52 | + if (!dc_isar_feature(aa64_pauth, s)) { | ||
53 | + return false; | ||
54 | + } | ||
55 | + dst = auth_branch_target(s, cpu_reg(s, a->rn), cpu_reg_sp(s, a->rm), !a->m); | ||
56 | + lr = cpu_reg(s, 30); | ||
57 | + if (dst == lr) { | ||
58 | + TCGv_i64 tmp = tcg_temp_new_i64(); | ||
59 | + tcg_gen_mov_i64(tmp, dst); | ||
60 | + dst = tmp; | ||
61 | + } | ||
62 | + gen_pc_plus_diff(s, lr, curr_insn_len(s)); | ||
63 | + gen_a64_set_pc(s, dst); | ||
64 | + set_btype_for_blr(s); | ||
65 | + s->base.is_jmp = DISAS_JUMP; | ||
66 | + return true; | ||
67 | +} | ||
68 | + | ||
69 | /* HINT instruction group, including various allocated HINTs */ | ||
70 | static void handle_hint(DisasContext *s, uint32_t insn, | ||
71 | unsigned int op1, unsigned int op2, unsigned int crm) | ||
72 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
73 | static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
27 | { | 74 | { |
28 | int el = arm_current_el(env); | 75 | unsigned int opc, op2, op3, rn, op4; |
29 | 76 | - unsigned btype_mod = 2; /* 0: BR, 1: BLR, 2: other */ | |
30 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_lor_ns(CPUARMState *env) | 77 | TCGv_i64 dst; |
31 | return CP_ACCESS_OK; | 78 | TCGv_i64 modifier; |
79 | |||
80 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
81 | case 0: | ||
82 | case 1: | ||
83 | case 2: | ||
84 | + case 8: | ||
85 | + case 9: | ||
86 | /* | ||
87 | - * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ: | ||
88 | - * handled in decodetree | ||
89 | + * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ, | ||
90 | + * BRAA, BLRAA: handled in decodetree | ||
91 | */ | ||
92 | goto do_unallocated; | ||
93 | |||
94 | - case 8: /* BRAA */ | ||
95 | - case 9: /* BLRAA */ | ||
96 | - if (!dc_isar_feature(aa64_pauth, s)) { | ||
97 | - goto do_unallocated; | ||
98 | - } | ||
99 | - if ((op3 & ~1) != 2) { | ||
100 | - goto do_unallocated; | ||
101 | - } | ||
102 | - btype_mod = opc & 1; | ||
103 | - if (s->pauth_active) { | ||
104 | - dst = tcg_temp_new_i64(); | ||
105 | - modifier = cpu_reg_sp(s, op4); | ||
106 | - if (op3 == 2) { | ||
107 | - gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); | ||
108 | - } else { | ||
109 | - gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); | ||
110 | - } | ||
111 | - } else { | ||
112 | - dst = cpu_reg(s, rn); | ||
113 | - } | ||
114 | - /* BLRAA also needs to load return address */ | ||
115 | - if (opc == 9) { | ||
116 | - TCGv_i64 lr = cpu_reg(s, 30); | ||
117 | - if (dst == lr) { | ||
118 | - TCGv_i64 tmp = tcg_temp_new_i64(); | ||
119 | - tcg_gen_mov_i64(tmp, dst); | ||
120 | - dst = tmp; | ||
121 | - } | ||
122 | - gen_pc_plus_diff(s, lr, curr_insn_len(s)); | ||
123 | - } | ||
124 | - gen_a64_set_pc(s, dst); | ||
125 | - break; | ||
126 | - | ||
127 | case 4: /* ERET */ | ||
128 | if (s->current_el == 0) { | ||
129 | goto do_unallocated; | ||
130 | @@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
131 | unallocated_encoding(s); | ||
132 | return; | ||
133 | } | ||
134 | - | ||
135 | - switch (btype_mod) { | ||
136 | - case 0: /* BR */ | ||
137 | - if (dc_isar_feature(aa64_bti, s)) { | ||
138 | - /* BR to {x16,x17} or !guard -> 1, else 3. */ | ||
139 | - set_btype(s, rn == 16 || rn == 17 || !s->guarded_page ? 1 : 3); | ||
140 | - } | ||
141 | - break; | ||
142 | - | ||
143 | - case 1: /* BLR */ | ||
144 | - if (dc_isar_feature(aa64_bti, s)) { | ||
145 | - /* BLR sets BTYPE to 2, regardless of source guarded page. */ | ||
146 | - set_btype(s, 2); | ||
147 | - } | ||
148 | - break; | ||
149 | - | ||
150 | - default: /* RET or none of the above. */ | ||
151 | - /* BTYPE will be set to 0 by normal end-of-insn processing. */ | ||
152 | - break; | ||
153 | - } | ||
154 | - | ||
155 | - s->base.is_jmp = DISAS_JUMP; | ||
32 | } | 156 | } |
33 | 157 | ||
34 | -static CPAccessResult access_lorid(CPUARMState *env, const ARMCPRegInfo *ri, | 158 | /* Branches, exception generating and system instructions */ |
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 | -- | 159 | -- |
66 | 2.20.1 | 160 | 2.34.1 |
67 | |||
68 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Convert the exception-return insns ERET, ERETA and ERETB to |
---|---|---|---|
2 | decodetree. These were the last insns left in the legacy | ||
3 | decoder function disas_uncond_reg_b(), which allows us to | ||
4 | remove it. | ||
2 | 5 | ||
3 | These are the only users of neon_reg_offset, so remove that. | 6 | The old decoder explicitly decoded the DRPS instruction, |
7 | only in order to call unallocated_encoding() on it, exactly | ||
8 | as would have happened if it hadn't decoded it. This is | ||
9 | because this insn always UNDEFs unless the CPU is in | ||
10 | halting-debug state, which we don't emulate. So we list | ||
11 | the pattern in a comment in a64.decode, but don't actively | ||
12 | decode it. | ||
4 | 13 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20201030022618.785675-4-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Message-id: 20230512144106.3608981-21-peter.maydell@linaro.org | ||
9 | --- | 17 | --- |
10 | target/arm/translate.c | 14 ++------------ | 18 | target/arm/tcg/a64.decode | 8 ++ |
11 | 1 file changed, 2 insertions(+), 12 deletions(-) | 19 | target/arm/tcg/translate-a64.c | 163 +++++++++++---------------------- |
20 | 2 files changed, 63 insertions(+), 108 deletions(-) | ||
12 | 21 | ||
13 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 22 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
14 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate.c | 24 | --- a/target/arm/tcg/a64.decode |
16 | +++ b/target/arm/translate.c | 25 | +++ b/target/arm/tcg/a64.decode |
17 | @@ -XXX,XX +XXX,XX @@ static inline long vfp_reg_offset(bool dp, unsigned reg) | 26 | @@ -XXX,XX +XXX,XX @@ RETA 1101011 0010 11111 00001 m:1 11111 11111 &reta # RETAA, RETAB |
27 | &bra rn rm m | ||
28 | BRA 1101011 1000 11111 00001 m:1 rn:5 rm:5 &bra # BRAA, BRAB | ||
29 | BLRA 1101011 1001 11111 00001 m:1 rn:5 rm:5 &bra # BLRAA, BLRAB | ||
30 | + | ||
31 | +ERET 1101011 0100 11111 000000 11111 00000 | ||
32 | +ERETA 1101011 0100 11111 00001 m:1 11111 11111 &reta # ERETAA, ERETAB | ||
33 | + | ||
34 | +# We don't need to decode DRPS because it always UNDEFs except when | ||
35 | +# the processor is in halting debug state (which we don't implement). | ||
36 | +# The pattern is listed here as documentation. | ||
37 | +# DRPS 1101011 0101 11111 000000 11111 00000 | ||
38 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/target/arm/tcg/translate-a64.c | ||
41 | +++ b/target/arm/tcg/translate-a64.c | ||
42 | @@ -XXX,XX +XXX,XX @@ static bool trans_BLRA(DisasContext *s, arg_bra *a) | ||
43 | return true; | ||
44 | } | ||
45 | |||
46 | +static bool trans_ERET(DisasContext *s, arg_ERET *a) | ||
47 | +{ | ||
48 | + TCGv_i64 dst; | ||
49 | + | ||
50 | + if (s->current_el == 0) { | ||
51 | + return false; | ||
52 | + } | ||
53 | + if (s->fgt_eret) { | ||
54 | + gen_exception_insn_el(s, 0, EXCP_UDEF, 0, 2); | ||
55 | + return true; | ||
56 | + } | ||
57 | + dst = tcg_temp_new_i64(); | ||
58 | + tcg_gen_ld_i64(dst, cpu_env, | ||
59 | + offsetof(CPUARMState, elr_el[s->current_el])); | ||
60 | + | ||
61 | + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
62 | + gen_io_start(); | ||
63 | + } | ||
64 | + | ||
65 | + gen_helper_exception_return(cpu_env, dst); | ||
66 | + /* Must exit loop to check un-masked IRQs */ | ||
67 | + s->base.is_jmp = DISAS_EXIT; | ||
68 | + return true; | ||
69 | +} | ||
70 | + | ||
71 | +static bool trans_ERETA(DisasContext *s, arg_reta *a) | ||
72 | +{ | ||
73 | + TCGv_i64 dst; | ||
74 | + | ||
75 | + if (!dc_isar_feature(aa64_pauth, s)) { | ||
76 | + return false; | ||
77 | + } | ||
78 | + if (s->current_el == 0) { | ||
79 | + return false; | ||
80 | + } | ||
81 | + /* The FGT trap takes precedence over an auth trap. */ | ||
82 | + if (s->fgt_eret) { | ||
83 | + gen_exception_insn_el(s, 0, EXCP_UDEF, a->m ? 3 : 2, 2); | ||
84 | + return true; | ||
85 | + } | ||
86 | + dst = tcg_temp_new_i64(); | ||
87 | + tcg_gen_ld_i64(dst, cpu_env, | ||
88 | + offsetof(CPUARMState, elr_el[s->current_el])); | ||
89 | + | ||
90 | + dst = auth_branch_target(s, dst, cpu_X[31], !a->m); | ||
91 | + if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
92 | + gen_io_start(); | ||
93 | + } | ||
94 | + | ||
95 | + gen_helper_exception_return(cpu_env, dst); | ||
96 | + /* Must exit loop to check un-masked IRQs */ | ||
97 | + s->base.is_jmp = DISAS_EXIT; | ||
98 | + return true; | ||
99 | +} | ||
100 | + | ||
101 | /* HINT instruction group, including various allocated HINTs */ | ||
102 | static void handle_hint(DisasContext *s, uint32_t insn, | ||
103 | unsigned int op1, unsigned int op2, unsigned int crm) | ||
104 | @@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn) | ||
18 | } | 105 | } |
19 | } | 106 | } |
20 | 107 | ||
21 | -/* Return the offset of a 32-bit piece of a NEON register. | 108 | -/* Unconditional branch (register) |
22 | - zero is the least significant end of the register. */ | 109 | - * 31 25 24 21 20 16 15 10 9 5 4 0 |
23 | -static inline long | 110 | - * +---------------+-------+-------+-------+------+-------+ |
24 | -neon_reg_offset (int reg, int n) | 111 | - * | 1 1 0 1 0 1 1 | opc | op2 | op3 | Rn | op4 | |
112 | - * +---------------+-------+-------+-------+------+-------+ | ||
113 | - */ | ||
114 | -static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) | ||
25 | -{ | 115 | -{ |
26 | - int sreg; | 116 | - unsigned int opc, op2, op3, rn, op4; |
27 | - sreg = reg * 2 + n; | 117 | - TCGv_i64 dst; |
28 | - return vfp_reg_offset(0, sreg); | 118 | - TCGv_i64 modifier; |
119 | - | ||
120 | - opc = extract32(insn, 21, 4); | ||
121 | - op2 = extract32(insn, 16, 5); | ||
122 | - op3 = extract32(insn, 10, 6); | ||
123 | - rn = extract32(insn, 5, 5); | ||
124 | - op4 = extract32(insn, 0, 5); | ||
125 | - | ||
126 | - if (op2 != 0x1f) { | ||
127 | - goto do_unallocated; | ||
128 | - } | ||
129 | - | ||
130 | - switch (opc) { | ||
131 | - case 0: | ||
132 | - case 1: | ||
133 | - case 2: | ||
134 | - case 8: | ||
135 | - case 9: | ||
136 | - /* | ||
137 | - * BR, BLR, RET, RETAA, RETAB, BRAAZ, BRABZ, BLRAAZ, BLRABZ, | ||
138 | - * BRAA, BLRAA: handled in decodetree | ||
139 | - */ | ||
140 | - goto do_unallocated; | ||
141 | - | ||
142 | - case 4: /* ERET */ | ||
143 | - if (s->current_el == 0) { | ||
144 | - goto do_unallocated; | ||
145 | - } | ||
146 | - switch (op3) { | ||
147 | - case 0: /* ERET */ | ||
148 | - if (op4 != 0) { | ||
149 | - goto do_unallocated; | ||
150 | - } | ||
151 | - if (s->fgt_eret) { | ||
152 | - gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(op3), 2); | ||
153 | - return; | ||
154 | - } | ||
155 | - dst = tcg_temp_new_i64(); | ||
156 | - tcg_gen_ld_i64(dst, cpu_env, | ||
157 | - offsetof(CPUARMState, elr_el[s->current_el])); | ||
158 | - break; | ||
159 | - | ||
160 | - case 2: /* ERETAA */ | ||
161 | - case 3: /* ERETAB */ | ||
162 | - if (!dc_isar_feature(aa64_pauth, s)) { | ||
163 | - goto do_unallocated; | ||
164 | - } | ||
165 | - if (rn != 0x1f || op4 != 0x1f) { | ||
166 | - goto do_unallocated; | ||
167 | - } | ||
168 | - /* The FGT trap takes precedence over an auth trap. */ | ||
169 | - if (s->fgt_eret) { | ||
170 | - gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(op3), 2); | ||
171 | - return; | ||
172 | - } | ||
173 | - dst = tcg_temp_new_i64(); | ||
174 | - tcg_gen_ld_i64(dst, cpu_env, | ||
175 | - offsetof(CPUARMState, elr_el[s->current_el])); | ||
176 | - if (s->pauth_active) { | ||
177 | - modifier = cpu_X[31]; | ||
178 | - if (op3 == 2) { | ||
179 | - gen_helper_autia(dst, cpu_env, dst, modifier); | ||
180 | - } else { | ||
181 | - gen_helper_autib(dst, cpu_env, dst, modifier); | ||
182 | - } | ||
183 | - } | ||
184 | - break; | ||
185 | - | ||
186 | - default: | ||
187 | - goto do_unallocated; | ||
188 | - } | ||
189 | - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { | ||
190 | - gen_io_start(); | ||
191 | - } | ||
192 | - | ||
193 | - gen_helper_exception_return(cpu_env, dst); | ||
194 | - /* Must exit loop to check un-masked IRQs */ | ||
195 | - s->base.is_jmp = DISAS_EXIT; | ||
196 | - return; | ||
197 | - | ||
198 | - case 5: /* DRPS */ | ||
199 | - if (op3 != 0 || op4 != 0 || rn != 0x1f) { | ||
200 | - goto do_unallocated; | ||
201 | - } else { | ||
202 | - unallocated_encoding(s); | ||
203 | - } | ||
204 | - return; | ||
205 | - | ||
206 | - default: | ||
207 | - do_unallocated: | ||
208 | - unallocated_encoding(s); | ||
209 | - return; | ||
210 | - } | ||
29 | -} | 211 | -} |
30 | - | 212 | - |
31 | static TCGv_i32 neon_load_reg(int reg, int pass) | 213 | /* Branches, exception generating and system instructions */ |
214 | static void disas_b_exc_sys(DisasContext *s, uint32_t insn) | ||
32 | { | 215 | { |
33 | TCGv_i32 tmp = tcg_temp_new_i32(); | 216 | @@ -XXX,XX +XXX,XX @@ static void disas_b_exc_sys(DisasContext *s, uint32_t insn) |
34 | - tcg_gen_ld_i32(tmp, cpu_env, neon_reg_offset(reg, pass)); | 217 | disas_exc(s, insn); |
35 | + tcg_gen_ld_i32(tmp, cpu_env, neon_element_offset(reg, pass, MO_32)); | 218 | } |
36 | return tmp; | 219 | break; |
37 | } | 220 | - case 0x6b: /* Unconditional branch (register) */ |
38 | 221 | - disas_uncond_b_reg(s, insn); | |
39 | static void neon_store_reg(int reg, int pass, TCGv_i32 var) | 222 | - break; |
40 | { | 223 | default: |
41 | - tcg_gen_st_i32(var, cpu_env, neon_reg_offset(reg, pass)); | 224 | unallocated_encoding(s); |
42 | + tcg_gen_st_i32(var, cpu_env, neon_element_offset(reg, pass, MO_32)); | 225 | break; |
43 | tcg_temp_free_i32(var); | ||
44 | } | ||
45 | |||
46 | -- | 226 | -- |
47 | 2.20.1 | 227 | 2.34.1 |
48 | |||
49 | diff view generated by jsdifflib |
1 | In arm_v7m_mmu_idx_for_secstate() we get the 'priv' level to pass to | 1 | The IMPDEF sysreg L2CTLR_EL1 found on the Cortex-A35, A53, A57, A72 |
---|---|---|---|
2 | armv7m_mmu_idx_for_secstate_and_priv() by calling arm_current_el(). | 2 | and which we (arguably dubiously) also provide in '-cpu max' has a |
3 | This is incorrect when the security state being queried is not the | 3 | 2 bit field for the number of processors in the cluster. On real |
4 | current one, because arm_current_el() uses the current security state | 4 | hardware this must be sufficient because it can only be configured |
5 | to determine which of the banked CONTROL.nPRIV bits to look at. | 5 | with up to 4 CPUs in the cluster. However on QEMU if the board code |
6 | The effect was that if (for instance) Secure state was in privileged | 6 | does not explicitly configure the code into clusters with the right |
7 | mode but Non-Secure was not then we would return the wrong MMU index. | 7 | CPU count we default to "give the value assuming that all CPUs in |
8 | the system are in a single cluster", which might be too big to fit | ||
9 | in the field. | ||
8 | 10 | ||
9 | The only places where we are using this function in a way that could | 11 | Instead of just overflowing this 2-bit field, saturate to 3 (meaning |
10 | trigger this bug are for the stack loads during a v8M function-return | 12 | "4 CPUs", so at least we don't overwrite other fields in the register. |
11 | and for the instruction fetch of a v8M SG insn. | 13 | It's unlikely that any guest code really cares about the value in |
14 | this field; at least, if it does it probably also wants the system | ||
15 | to be more closely matching real hardware, i.e. not to have more | ||
16 | than 4 CPUs. | ||
12 | 17 | ||
13 | Fix the bug by expanding out the M-profile version of the | 18 | This issue has been present since the L2CTLR was first added in |
14 | arm_current_el() logic inline so it can use the passed in secstate | 19 | commit 377a44ec8f2fac5b back in 2014. It was only noticed because |
15 | rather than env->v7m.secure. | 20 | Coverity complains (CID 1509227) that the shift might overflow 32 bits |
21 | and inadvertently sign extend into the top half of the 64 bit value. | ||
16 | 22 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 24 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
19 | Message-id: 20201022164408.13214-1-peter.maydell@linaro.org | 25 | Message-id: 20230512170223.3801643-2-peter.maydell@linaro.org |
20 | --- | 26 | --- |
21 | target/arm/m_helper.c | 3 ++- | 27 | target/arm/cortex-regs.c | 11 +++++++++-- |
22 | 1 file changed, 2 insertions(+), 1 deletion(-) | 28 | 1 file changed, 9 insertions(+), 2 deletions(-) |
23 | 29 | ||
24 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 30 | diff --git a/target/arm/cortex-regs.c b/target/arm/cortex-regs.c |
25 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/m_helper.c | 32 | --- a/target/arm/cortex-regs.c |
27 | +++ b/target/arm/m_helper.c | 33 | +++ b/target/arm/cortex-regs.c |
28 | @@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env, | 34 | @@ -XXX,XX +XXX,XX @@ static uint64_t l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) |
29 | /* Return the MMU index for a v7M CPU in the specified security state */ | ||
30 | ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate) | ||
31 | { | 35 | { |
32 | - bool priv = arm_current_el(env) != 0; | 36 | ARMCPU *cpu = env_archcpu(env); |
33 | + bool priv = arm_v7m_is_handler_mode(env) || | 37 | |
34 | + !(env->v7m.control[secstate] & 1); | 38 | - /* Number of cores is in [25:24]; otherwise we RAZ */ |
35 | 39 | - return (cpu->core_count - 1) << 24; | |
36 | return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv); | 40 | + /* |
41 | + * Number of cores is in [25:24]; otherwise we RAZ. | ||
42 | + * If the board didn't configure the CPUs into clusters, | ||
43 | + * we default to "all CPUs in one cluster", which might be | ||
44 | + * more than the 4 that the hardware permits and which is | ||
45 | + * all you can report in this two-bit field. Saturate to | ||
46 | + * 0b11 (== 4 CPUs) rather than overflowing the field. | ||
47 | + */ | ||
48 | + return MIN(cpu->core_count - 1, 3) << 24; | ||
37 | } | 49 | } |
50 | |||
51 | static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { | ||
38 | -- | 52 | -- |
39 | 2.20.1 | 53 | 2.34.1 |
40 | |||
41 | diff view generated by jsdifflib |
1 | The helper functions for performing the udot/sdot operations against | 1 | In the vexpress board code, we allocate a new MemoryRegion at the top |
---|---|---|---|
2 | a scalar were not using an address-swizzling macro when converting | 2 | of vexpress_common_init() but only set it up and use it inside the |
3 | the index of the scalar element into a pointer into the vm array. | 3 | "if (map[VE_NORFLASHALIAS] != -1)" conditional, so we leak it if not. |
4 | This had no effect on little-endian hosts but meant we generated | 4 | This isn't a very interesting leak as it's a tiny amount of memory |
5 | incorrect results on big-endian hosts. | 5 | once at startup, but it's easy to fix. |
6 | 6 | ||
7 | For these insns, the index is indexing over group of 4 8-bit values, | 7 | We could silence Coverity simply by moving the g_new() into the |
8 | so 32 bits per indexed entity, and H4() is therefore what we want. | 8 | if() block, but this use of g_new(MemoryRegion, 1) is a legacy from |
9 | (For Neon the only possible input indexes are 0 and 1.) | 9 | when this board model was originally written; we wouldn't do that |
10 | if we wrote it today. The MemoryRegions are conceptually a part of | ||
11 | the board and must not go away until the whole board is done with | ||
12 | (at the end of the simulation), so they belong in its state struct. | ||
13 | |||
14 | This machine already has a VexpressMachineState struct that extends | ||
15 | MachineState, so statically put the MemoryRegions in there instead of | ||
16 | dynamically allocating them separately at runtime. | ||
17 | |||
18 | Spotted by Coverity (CID 1509083). | ||
10 | 19 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 21 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 22 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
14 | Message-id: 20201028191712.4910-3-peter.maydell@linaro.org | 23 | Message-id: 20230512170223.3801643-3-peter.maydell@linaro.org |
15 | --- | 24 | --- |
16 | target/arm/vec_helper.c | 4 ++-- | 25 | hw/arm/vexpress.c | 40 ++++++++++++++++++++-------------------- |
17 | 1 file changed, 2 insertions(+), 2 deletions(-) | 26 | 1 file changed, 20 insertions(+), 20 deletions(-) |
18 | 27 | ||
19 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | 28 | diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c |
20 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/vec_helper.c | 30 | --- a/hw/arm/vexpress.c |
22 | +++ b/target/arm/vec_helper.c | 31 | +++ b/hw/arm/vexpress.c |
23 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_sdot_idx_b)(void *vd, void *vn, void *vm, uint32_t desc) | 32 | @@ -XXX,XX +XXX,XX @@ struct VexpressMachineClass { |
24 | intptr_t index = simd_data(desc); | 33 | |
25 | uint32_t *d = vd; | 34 | struct VexpressMachineState { |
26 | int8_t *n = vn; | 35 | MachineState parent; |
27 | - int8_t *m_indexed = (int8_t *)vm + index * 4; | 36 | + MemoryRegion vram; |
28 | + int8_t *m_indexed = (int8_t *)vm + H4(index) * 4; | 37 | + MemoryRegion sram; |
29 | 38 | + MemoryRegion flashalias; | |
30 | /* Notice the special case of opr_sz == 8, from aa64/aa32 advsimd. | 39 | + MemoryRegion lowram; |
31 | * Otherwise opr_sz is a multiple of 16. | 40 | + MemoryRegion a15sram; |
32 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_udot_idx_b)(void *vd, void *vn, void *vm, uint32_t desc) | 41 | bool secure; |
33 | intptr_t index = simd_data(desc); | 42 | bool virt; |
34 | uint32_t *d = vd; | 43 | }; |
35 | uint8_t *n = vn; | 44 | @@ -XXX,XX +XXX,XX @@ struct VexpressMachineState { |
36 | - uint8_t *m_indexed = (uint8_t *)vm + index * 4; | 45 | #define TYPE_VEXPRESS_A15_MACHINE MACHINE_TYPE_NAME("vexpress-a15") |
37 | + uint8_t *m_indexed = (uint8_t *)vm + H4(index) * 4; | 46 | OBJECT_DECLARE_TYPE(VexpressMachineState, VexpressMachineClass, VEXPRESS_MACHINE) |
38 | 47 | ||
39 | /* Notice the special case of opr_sz == 8, from aa64/aa32 advsimd. | 48 | -typedef void DBoardInitFn(const VexpressMachineState *machine, |
40 | * Otherwise opr_sz is a multiple of 16. | 49 | +typedef void DBoardInitFn(VexpressMachineState *machine, |
50 | ram_addr_t ram_size, | ||
51 | const char *cpu_type, | ||
52 | qemu_irq *pic); | ||
53 | @@ -XXX,XX +XXX,XX @@ static void init_cpus(MachineState *ms, const char *cpu_type, | ||
54 | } | ||
55 | } | ||
56 | |||
57 | -static void a9_daughterboard_init(const VexpressMachineState *vms, | ||
58 | +static void a9_daughterboard_init(VexpressMachineState *vms, | ||
59 | ram_addr_t ram_size, | ||
60 | const char *cpu_type, | ||
61 | qemu_irq *pic) | ||
62 | { | ||
63 | MachineState *machine = MACHINE(vms); | ||
64 | MemoryRegion *sysmem = get_system_memory(); | ||
65 | - MemoryRegion *lowram = g_new(MemoryRegion, 1); | ||
66 | ram_addr_t low_ram_size; | ||
67 | |||
68 | if (ram_size > 0x40000000) { | ||
69 | @@ -XXX,XX +XXX,XX @@ static void a9_daughterboard_init(const VexpressMachineState *vms, | ||
70 | * address space should in theory be remappable to various | ||
71 | * things including ROM or RAM; we always map the RAM there. | ||
72 | */ | ||
73 | - memory_region_init_alias(lowram, NULL, "vexpress.lowmem", machine->ram, | ||
74 | - 0, low_ram_size); | ||
75 | - memory_region_add_subregion(sysmem, 0x0, lowram); | ||
76 | + memory_region_init_alias(&vms->lowram, NULL, "vexpress.lowmem", | ||
77 | + machine->ram, 0, low_ram_size); | ||
78 | + memory_region_add_subregion(sysmem, 0x0, &vms->lowram); | ||
79 | memory_region_add_subregion(sysmem, 0x60000000, machine->ram); | ||
80 | |||
81 | /* 0x1e000000 A9MPCore (SCU) private memory region */ | ||
82 | @@ -XXX,XX +XXX,XX @@ static VEDBoardInfo a9_daughterboard = { | ||
83 | .init = a9_daughterboard_init, | ||
84 | }; | ||
85 | |||
86 | -static void a15_daughterboard_init(const VexpressMachineState *vms, | ||
87 | +static void a15_daughterboard_init(VexpressMachineState *vms, | ||
88 | ram_addr_t ram_size, | ||
89 | const char *cpu_type, | ||
90 | qemu_irq *pic) | ||
91 | { | ||
92 | MachineState *machine = MACHINE(vms); | ||
93 | MemoryRegion *sysmem = get_system_memory(); | ||
94 | - MemoryRegion *sram = g_new(MemoryRegion, 1); | ||
95 | |||
96 | { | ||
97 | /* We have to use a separate 64 bit variable here to avoid the gcc | ||
98 | @@ -XXX,XX +XXX,XX @@ static void a15_daughterboard_init(const VexpressMachineState *vms, | ||
99 | /* 0x2b060000: SP805 watchdog: not modelled */ | ||
100 | /* 0x2b0a0000: PL341 dynamic memory controller: not modelled */ | ||
101 | /* 0x2e000000: system SRAM */ | ||
102 | - memory_region_init_ram(sram, NULL, "vexpress.a15sram", 0x10000, | ||
103 | + memory_region_init_ram(&vms->a15sram, NULL, "vexpress.a15sram", 0x10000, | ||
104 | &error_fatal); | ||
105 | - memory_region_add_subregion(sysmem, 0x2e000000, sram); | ||
106 | + memory_region_add_subregion(sysmem, 0x2e000000, &vms->a15sram); | ||
107 | |||
108 | /* 0x7ffb0000: DMA330 DMA controller: not modelled */ | ||
109 | /* 0x7ffd0000: PL354 static memory controller: not modelled */ | ||
110 | @@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine) | ||
111 | I2CBus *i2c; | ||
112 | ram_addr_t vram_size, sram_size; | ||
113 | MemoryRegion *sysmem = get_system_memory(); | ||
114 | - MemoryRegion *vram = g_new(MemoryRegion, 1); | ||
115 | - MemoryRegion *sram = g_new(MemoryRegion, 1); | ||
116 | - MemoryRegion *flashalias = g_new(MemoryRegion, 1); | ||
117 | - MemoryRegion *flash0mem; | ||
118 | const hwaddr *map = daughterboard->motherboard_map; | ||
119 | int i; | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine) | ||
122 | |||
123 | if (map[VE_NORFLASHALIAS] != -1) { | ||
124 | /* Map flash 0 as an alias into low memory */ | ||
125 | + MemoryRegion *flash0mem; | ||
126 | flash0mem = sysbus_mmio_get_region(SYS_BUS_DEVICE(pflash0), 0); | ||
127 | - memory_region_init_alias(flashalias, NULL, "vexpress.flashalias", | ||
128 | + memory_region_init_alias(&vms->flashalias, NULL, "vexpress.flashalias", | ||
129 | flash0mem, 0, VEXPRESS_FLASH_SIZE); | ||
130 | - memory_region_add_subregion(sysmem, map[VE_NORFLASHALIAS], flashalias); | ||
131 | + memory_region_add_subregion(sysmem, map[VE_NORFLASHALIAS], &vms->flashalias); | ||
132 | } | ||
133 | |||
134 | dinfo = drive_get(IF_PFLASH, 0, 1); | ||
135 | ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1", dinfo); | ||
136 | |||
137 | sram_size = 0x2000000; | ||
138 | - memory_region_init_ram(sram, NULL, "vexpress.sram", sram_size, | ||
139 | + memory_region_init_ram(&vms->sram, NULL, "vexpress.sram", sram_size, | ||
140 | &error_fatal); | ||
141 | - memory_region_add_subregion(sysmem, map[VE_SRAM], sram); | ||
142 | + memory_region_add_subregion(sysmem, map[VE_SRAM], &vms->sram); | ||
143 | |||
144 | vram_size = 0x800000; | ||
145 | - memory_region_init_ram(vram, NULL, "vexpress.vram", vram_size, | ||
146 | + memory_region_init_ram(&vms->vram, NULL, "vexpress.vram", vram_size, | ||
147 | &error_fatal); | ||
148 | - memory_region_add_subregion(sysmem, map[VE_VIDEORAM], vram); | ||
149 | + memory_region_add_subregion(sysmem, map[VE_VIDEORAM], &vms->vram); | ||
150 | |||
151 | /* 0x4e000000 LAN9118 Ethernet */ | ||
152 | if (nd_table[0].used) { | ||
41 | -- | 153 | -- |
42 | 2.20.1 | 154 | 2.34.1 |
43 | 155 | ||
44 | 156 | diff view generated by jsdifflib |
1 | On some hosts (eg Ubuntu Bionic) pkg-config returns a set of | 1 | Convert the u2f.txt file to rST, and place it in the right place |
---|---|---|---|
2 | libraries for gio-2.0 which don't actually work when compiling | 2 | in our manual layout. The old text didn't fit very well into our |
3 | statically. (Specifically, the returned library string includes | 3 | manual style, so the new version ends up looking like a rewrite, |
4 | -lmount, but not -lblkid which -lmount depends upon, so linking | 4 | although some of the original text is preserved: |
5 | fails due to missing symbols.) | 5 | |
6 | 6 | * the 'building' section of the old file is removed, since we | |
7 | Check that the libraries work, and don't enable gio if they don't, | 7 | generally assume that users have already built QEMU |
8 | in the same way we do for gnutls. | 8 | * some rather verbose text has been cut back |
9 | * document the passthrough device first, on the assumption | ||
10 | that's most likely to be of interest to users | ||
11 | * cut back on the duplication of text between sections | ||
12 | * format example command lines etc with rST | ||
13 | |||
14 | As it's a short document it seemed simplest to do this all | ||
15 | in one go rather than try to do a minimal syntactic conversion | ||
16 | and then clean up the wording and layout. | ||
9 | 17 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> | 19 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 20 | Message-id: 20230421163734.1152076-1-peter.maydell@linaro.org |
13 | Message-id: 20200928160402.7961-1-peter.maydell@linaro.org | ||
14 | --- | 21 | --- |
15 | configure | 10 +++++++++- | 22 | docs/system/device-emulation.rst | 1 + |
16 | 1 file changed, 9 insertions(+), 1 deletion(-) | 23 | docs/system/devices/usb-u2f.rst | 93 ++++++++++++++++++++++++++ |
17 | 24 | docs/system/devices/usb.rst | 2 +- | |
18 | diff --git a/configure b/configure | 25 | docs/u2f.txt | 110 ------------------------------- |
19 | index XXXXXXX..XXXXXXX 100755 | 26 | 4 files changed, 95 insertions(+), 111 deletions(-) |
20 | --- a/configure | 27 | create mode 100644 docs/system/devices/usb-u2f.rst |
21 | +++ b/configure | 28 | delete mode 100644 docs/u2f.txt |
22 | @@ -XXX,XX +XXX,XX @@ if test "$static" = yes && test "$mingw32" = yes; then | 29 | |
23 | fi | 30 | diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst |
24 | 31 | index XXXXXXX..XXXXXXX 100644 | |
25 | if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then | 32 | --- a/docs/system/device-emulation.rst |
26 | - gio=yes | 33 | +++ b/docs/system/device-emulation.rst |
27 | gio_cflags=$($pkg_config --cflags gio-2.0) | 34 | @@ -XXX,XX +XXX,XX @@ Emulated Devices |
28 | gio_libs=$($pkg_config --libs gio-2.0) | 35 | devices/virtio-pmem.rst |
29 | gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0) | 36 | devices/vhost-user-rng.rst |
30 | if [ ! -x "$gdbus_codegen" ]; then | 37 | devices/canokey.rst |
31 | gdbus_codegen= | 38 | + devices/usb-u2f.rst |
32 | fi | 39 | devices/igb.rst |
33 | + # Check that the libraries actually work -- Ubuntu 18.04 ships | 40 | diff --git a/docs/system/devices/usb-u2f.rst b/docs/system/devices/usb-u2f.rst |
34 | + # with pkg-config --static --libs data for gio-2.0 that is missing | 41 | new file mode 100644 |
35 | + # -lblkid and will give a link error. | 42 | index XXXXXXX..XXXXXXX |
36 | + write_c_skeleton | 43 | --- /dev/null |
37 | + if compile_prog "" "gio_libs" ; then | 44 | +++ b/docs/system/devices/usb-u2f.rst |
38 | + gio=yes | 45 | @@ -XXX,XX +XXX,XX @@ |
39 | + else | 46 | +Universal Second Factor (U2F) USB Key Device |
40 | + gio=no | 47 | +============================================ |
41 | + fi | 48 | + |
42 | else | 49 | +U2F is an open authentication standard that enables relying parties |
43 | gio=no | 50 | +exposed to the internet to offer a strong second factor option for end |
44 | fi | 51 | +user authentication. |
52 | + | ||
53 | +The second factor is provided by a device implementing the U2F | ||
54 | +protocol. In case of a USB U2F security key, it is a USB HID device | ||
55 | +that implements the U2F protocol. | ||
56 | + | ||
57 | +QEMU supports both pass-through of a host U2F key device to a VM, | ||
58 | +and software emulation of a U2F key. | ||
59 | + | ||
60 | +``u2f-passthru`` | ||
61 | +---------------- | ||
62 | + | ||
63 | +The ``u2f-passthru`` device allows you to connect a real hardware | ||
64 | +U2F key on your host to a guest VM. All requests made from the guest | ||
65 | +are passed through to the physical security key connected to the | ||
66 | +host machine and vice versa. | ||
67 | + | ||
68 | +In addition, the dedicated pass-through allows you to share a single | ||
69 | +U2F security key with several guest VMs, which is not possible with a | ||
70 | +simple host device assignment pass-through. | ||
71 | + | ||
72 | +You can specify the host U2F key to use with the ``hidraw`` | ||
73 | +option, which takes the host path to a Linux ``/dev/hidrawN`` device: | ||
74 | + | ||
75 | +.. parsed-literal:: | ||
76 | + |qemu_system| -usb -device u2f-passthru,hidraw=/dev/hidraw0 | ||
77 | + | ||
78 | +If you don't specify the device, the ``u2f-passthru`` device will | ||
79 | +autoscan to take the first U2F device it finds on the host (this | ||
80 | +requires a working libudev): | ||
81 | + | ||
82 | +.. parsed-literal:: | ||
83 | + |qemu_system| -usb -device u2f-passthru | ||
84 | + | ||
85 | +``u2f-emulated`` | ||
86 | +---------------- | ||
87 | + | ||
88 | +``u2f-emulated`` is a completely software emulated U2F device. | ||
89 | +It uses `libu2f-emu <https://github.com/MattGorko/libu2f-emu>`__ | ||
90 | +for the U2F key emulation. libu2f-emu | ||
91 | +provides a complete implementation of the U2F protocol device part for | ||
92 | +all specified transports given by the FIDO Alliance. | ||
93 | + | ||
94 | +To work, an emulated U2F device must have four elements: | ||
95 | + | ||
96 | + * ec x509 certificate | ||
97 | + * ec private key | ||
98 | + * counter (four bytes value) | ||
99 | + * 48 bytes of entropy (random bits) | ||
100 | + | ||
101 | +To use this type of device, these have to be configured, and these | ||
102 | +four elements must be passed one way or another. | ||
103 | + | ||
104 | +Assuming that you have a working libu2f-emu installed on the host, | ||
105 | +there are three possible ways to configure the ``u2f-emulated`` device: | ||
106 | + | ||
107 | + * ephemeral | ||
108 | + * setup directory | ||
109 | + * manual | ||
110 | + | ||
111 | +Ephemeral is the simplest way to configure; it lets the device generate | ||
112 | +all the elements it needs for a single use of the lifetime of the device. | ||
113 | +It is the default if you do not pass any other options to the device. | ||
114 | + | ||
115 | +.. parsed-literal:: | ||
116 | + |qemu_system| -usb -device u2f-emulated | ||
117 | + | ||
118 | +You can pass the device the path of a setup directory on the host | ||
119 | +using the ``dir`` option; the directory must contain these four files: | ||
120 | + | ||
121 | + * ``certificate.pem``: ec x509 certificate | ||
122 | + * ``private-key.pem``: ec private key | ||
123 | + * ``counter``: counter value | ||
124 | + * ``entropy``: 48 bytes of entropy | ||
125 | + | ||
126 | +.. parsed-literal:: | ||
127 | + |qemu_system| -usb -device u2f-emulated,dir=$dir | ||
128 | + | ||
129 | +You can also manually pass the device the paths to each of these files, | ||
130 | +if you don't want them all to be in the same directory, using the options | ||
131 | + | ||
132 | + * ``cert`` | ||
133 | + * ``priv`` | ||
134 | + * ``counter`` | ||
135 | + * ``entropy`` | ||
136 | + | ||
137 | +.. parsed-literal:: | ||
138 | + |qemu_system| -usb -device u2f-emulated,cert=$DIR1/$FILE1,priv=$DIR2/$FILE2,counter=$DIR3/$FILE3,entropy=$DIR4/$FILE4 | ||
139 | diff --git a/docs/system/devices/usb.rst b/docs/system/devices/usb.rst | ||
140 | index XXXXXXX..XXXXXXX 100644 | ||
141 | --- a/docs/system/devices/usb.rst | ||
142 | +++ b/docs/system/devices/usb.rst | ||
143 | @@ -XXX,XX +XXX,XX @@ option or the ``device_add`` monitor command. Available devices are: | ||
144 | USB audio device | ||
145 | |||
146 | ``u2f-{emulated,passthru}`` | ||
147 | - Universal Second Factor device | ||
148 | + :doc:`usb-u2f` | ||
149 | |||
150 | ``canokey`` | ||
151 | An Open-source Secure Key implementing FIDO2, OpenPGP, PIV and more. | ||
152 | diff --git a/docs/u2f.txt b/docs/u2f.txt | ||
153 | deleted file mode 100644 | ||
154 | index XXXXXXX..XXXXXXX | ||
155 | --- a/docs/u2f.txt | ||
156 | +++ /dev/null | ||
157 | @@ -XXX,XX +XXX,XX @@ | ||
158 | -QEMU U2F Key Device Documentation. | ||
159 | - | ||
160 | -Contents | ||
161 | -1. USB U2F key device | ||
162 | -2. Building | ||
163 | -3. Using u2f-emulated | ||
164 | -4. Using u2f-passthru | ||
165 | -5. Libu2f-emu | ||
166 | - | ||
167 | -1. USB U2F key device | ||
168 | - | ||
169 | -U2F is an open authentication standard that enables relying parties | ||
170 | -exposed to the internet to offer a strong second factor option for end | ||
171 | -user authentication. | ||
172 | - | ||
173 | -The standard brings many advantages to both parties, client and server, | ||
174 | -allowing to reduce over-reliance on passwords, it increases authentication | ||
175 | -security and simplifies passwords. | ||
176 | - | ||
177 | -The second factor is materialized by a device implementing the U2F | ||
178 | -protocol. In case of a USB U2F security key, it is a USB HID device | ||
179 | -that implements the U2F protocol. | ||
180 | - | ||
181 | -In QEMU, the USB U2F key device offers a dedicated support of U2F, allowing | ||
182 | -guest USB FIDO/U2F security keys operating in two possible modes: | ||
183 | -pass-through and emulated. | ||
184 | - | ||
185 | -The pass-through mode consists of passing all requests made from the guest | ||
186 | -to the physical security key connected to the host machine and vice versa. | ||
187 | -In addition, the dedicated pass-through allows to have a U2F security key | ||
188 | -shared on several guests which is not possible with a simple host device | ||
189 | -assignment pass-through. | ||
190 | - | ||
191 | -The emulated mode consists of completely emulating the behavior of an | ||
192 | -U2F device through software part. Libu2f-emu is used for that. | ||
193 | - | ||
194 | - | ||
195 | -2. Building | ||
196 | - | ||
197 | -To ensure the build of the u2f-emulated device variant which depends | ||
198 | -on libu2f-emu: configuring and building: | ||
199 | - | ||
200 | - ./configure --enable-u2f && make | ||
201 | - | ||
202 | -The pass-through mode is built by default on Linux. To take advantage | ||
203 | -of the autoscan option it provides, make sure you have a working libudev | ||
204 | -installed on the host. | ||
205 | - | ||
206 | - | ||
207 | -3. Using u2f-emulated | ||
208 | - | ||
209 | -To work, an emulated U2F device must have four elements: | ||
210 | - * ec x509 certificate | ||
211 | - * ec private key | ||
212 | - * counter (four bytes value) | ||
213 | - * 48 bytes of entropy (random bits) | ||
214 | - | ||
215 | -To use this type of device, this one has to be configured, and these | ||
216 | -four elements must be passed one way or another. | ||
217 | - | ||
218 | -Assuming that you have a working libu2f-emu installed on the host. | ||
219 | -There are three possible ways of configurations: | ||
220 | - * ephemeral | ||
221 | - * setup directory | ||
222 | - * manual | ||
223 | - | ||
224 | -Ephemeral is the simplest way to configure, it lets the device generate | ||
225 | -all the elements it needs for a single use of the lifetime of the device. | ||
226 | - | ||
227 | - qemu -usb -device u2f-emulated | ||
228 | - | ||
229 | -Setup directory allows to configure the device from a directory containing | ||
230 | -four files: | ||
231 | - * certificate.pem: ec x509 certificate | ||
232 | - * private-key.pem: ec private key | ||
233 | - * counter: counter value | ||
234 | - * entropy: 48 bytes of entropy | ||
235 | - | ||
236 | - qemu -usb -device u2f-emulated,dir=$dir | ||
237 | - | ||
238 | -Manual allows to configure the device more finely by specifying each | ||
239 | -of the elements necessary for the device: | ||
240 | - * cert | ||
241 | - * priv | ||
242 | - * counter | ||
243 | - * entropy | ||
244 | - | ||
245 | - qemu -usb -device u2f-emulated,cert=$DIR1/$FILE1,priv=$DIR2/$FILE2,counter=$DIR3/$FILE3,entropy=$DIR4/$FILE4 | ||
246 | - | ||
247 | - | ||
248 | -4. Using u2f-passthru | ||
249 | - | ||
250 | -On the host specify the u2f-passthru device with a suitable hidraw: | ||
251 | - | ||
252 | - qemu -usb -device u2f-passthru,hidraw=/dev/hidraw0 | ||
253 | - | ||
254 | -Alternately, the u2f-passthru device can autoscan to take the first | ||
255 | -U2F device it finds on the host (this requires a working libudev): | ||
256 | - | ||
257 | - qemu -usb -device u2f-passthru | ||
258 | - | ||
259 | - | ||
260 | -5. Libu2f-emu | ||
261 | - | ||
262 | -The u2f-emulated device uses libu2f-emu for the U2F key emulation. Libu2f-emu | ||
263 | -implements completely the U2F protocol device part for all specified | ||
264 | -transport given by the FIDO Alliance. | ||
265 | - | ||
266 | -For more information about libu2f-emu see this page: | ||
267 | -https://github.com/MattGorko/libu2f-emu. | ||
45 | -- | 268 | -- |
46 | 2.20.1 | 269 | 2.34.1 |
47 | |||
48 | diff view generated by jsdifflib |