1 | Hi; here's the first target-arm pullreq for the 7.0 cycle. | 1 | Hi; here's a target-arm pullreq. Mostly this is some decodetree |
---|---|---|---|
2 | conversion patches from me, plus a scattering of other bug fixes. | ||
2 | 3 | ||
3 | thanks | 4 | thanks |
4 | -- PMM | 5 | -- PMM |
5 | 6 | ||
6 | The following changes since commit 76b56fdfc9fa43ec6e5986aee33f108c6c6a511e: | 7 | The following changes since commit e3660cc1e3cb136af50c0eaaeac27943c2438d1d: |
7 | 8 | ||
8 | Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (2021-12-14 12:46:18 -0800) | 9 | Merge tag 'pull-loongarch-20230616' of https://gitlab.com/gaosong/qemu into staging (2023-06-16 12:30:16 +0200) |
9 | 10 | ||
10 | are available in the Git repository at: | 11 | are available in the Git repository at: |
11 | 12 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20211215 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230619 |
13 | 14 | ||
14 | for you to fetch changes up to aed176558806674d030a8305d989d4e6a5073359: | 15 | for you to fetch changes up to 074259c0f2ac40042dce766d870318cc22f388eb: |
15 | 16 | ||
16 | tests/acpi: add expected blob for VIOT test on virt machine (2021-12-15 10:35:26 +0000) | 17 | hw/misc/bcm2835_property: Handle CORE_CLK_ID firmware property (2023-06-19 15:27:21 +0100) |
17 | 18 | ||
18 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
19 | target-arm queue: | 20 | target-arm queue: |
20 | * ITS: error reporting cleanup | 21 | * Fix return value from LDSMIN/LDSMAX 8/16 bit atomics |
21 | * aspeed: improve documentation | 22 | * Return correct result for LDG when ATA=0 |
22 | * Fix STM32F2XX USART data register readout | 23 | * Conversion of system insns, loads and stores to decodetree |
23 | * allow emulated GICv3 to be disabled in non-TCG builds | 24 | * hw/intc/allwinner-a10-pic: Handle IRQ levels other than 0 or 1 |
24 | * fix exception priority for singlestep, misaligned PC, bp, etc | 25 | * hw/sd/allwinner-sdhost: Don't send non-boolean IRQ line levels |
25 | * Correct calculation of tlb range invalidate length | 26 | * hw/timer/nrf51_timer: Don't lose time when timer is queried in tight loop |
26 | * npcm7xx_emc: fix missing queue_flush | 27 | * hw/arm/Kconfig: sbsa-ref uses Bochs display |
27 | * virt: Add VIOT ACPI table for virtio-iommu | 28 | * imx_serial: set wake bit when we receive a data byte |
28 | * target/i386: Use assert() to sanity-check b1 in SSE decode | 29 | * docs: sbsa: document board to firmware interface |
29 | * Don't include qemu-common unnecessarily | 30 | * hw/misc/bcm2835_property: avoid hard-coded constants |
30 | 31 | ||
31 | ---------------------------------------------------------------- | 32 | ---------------------------------------------------------------- |
32 | Alex Bennée (1): | 33 | Marcin Juszkiewicz (2): |
33 | hw/intc: clean-up error reporting for failed ITS cmd | 34 | hw/arm/Kconfig: sbsa-ref uses Bochs display |
35 | docs: sbsa: document board to firmware interface | ||
34 | 36 | ||
35 | Jean-Philippe Brucker (8): | 37 | Martin Kaiser (1): |
36 | hw/arm/virt-acpi-build: Add VIOT table for virtio-iommu | 38 | imx_serial: set wake bit when we receive a data byte |
37 | hw/arm/virt: Remove device tree restriction for virtio-iommu | ||
38 | hw/arm/virt: Reject instantiation of multiple IOMMUs | ||
39 | hw/arm/virt: Use object_property_set instead of qdev_prop_set | ||
40 | tests/acpi: allow updates of VIOT expected data files | ||
41 | tests/acpi: add test case for VIOT | ||
42 | tests/acpi: add expected blobs for VIOT test on q35 machine | ||
43 | tests/acpi: add expected blob for VIOT test on virt machine | ||
44 | 39 | ||
45 | Joel Stanley (4): | 40 | Peter Maydell (26): |
46 | docs: aspeed: Add new boards | 41 | target/arm: Fix return value from LDSMIN/LDSMAX 8/16 bit atomics |
47 | docs: aspeed: Update OpenBMC image URL | 42 | target/arm: Return correct result for LDG when ATA=0 |
48 | docs: aspeed: Give an example of booting a kernel | 43 | target/arm: Pass memop to gen_mte_check1_mmuidx() in reg_imm9 decode |
49 | docs: aspeed: ADC is now modelled | 44 | target/arm: Consistently use finalize_memop_asimd() for ASIMD loads/stores |
45 | target/arm: Convert hint instruction space to decodetree | ||
46 | target/arm: Convert barrier insns to decodetree | ||
47 | target/arm: Convert CFINV, XAFLAG and AXFLAG to decodetree | ||
48 | target/arm: Convert MSR (immediate) to decodetree | ||
49 | target/arm: Convert MSR (reg), MRS, SYS, SYSL to decodetree | ||
50 | target/arm: Convert exception generation instructions to decodetree | ||
51 | target/arm: Convert load/store exclusive and ordered to decodetree | ||
52 | target/arm: Convert LDXP, STXP, CASP, CAS to decodetree | ||
53 | target/arm: Convert load reg (literal) group to decodetree | ||
54 | target/arm: Convert load/store-pair to decodetree | ||
55 | target/arm: Convert ld/st reg+imm9 insns to decodetree | ||
56 | target/arm: Convert LDR/STR with 12-bit immediate to decodetree | ||
57 | target/arm: Convert LDR/STR reg+reg to decodetree | ||
58 | target/arm: Convert atomic memory ops to decodetree | ||
59 | target/arm: Convert load (pointer auth) insns to decodetree | ||
60 | target/arm: Convert LDAPR/STLR (imm) to decodetree | ||
61 | target/arm: Convert load/store (multiple structures) to decodetree | ||
62 | target/arm: Convert load/store single structure to decodetree | ||
63 | target/arm: Convert load/store tags insns to decodetree | ||
64 | hw/intc/allwinner-a10-pic: Handle IRQ levels other than 0 or 1 | ||
65 | hw/sd/allwinner-sdhost: Don't send non-boolean IRQ line levels | ||
66 | hw/timer/nrf51_timer: Don't lose time when timer is queried in tight loop | ||
50 | 67 | ||
51 | Olivier Hériveaux (1): | 68 | Sergey Kambalin (4): |
52 | Fix STM32F2XX USART data register readout | 69 | hw/arm/raspi: Import Linux raspi definitions as 'raspberrypi-fw-defs.h' |
70 | hw/misc/bcm2835_property: Use 'raspberrypi-fw-defs.h' definitions | ||
71 | hw/misc/bcm2835_property: Replace magic frequency values by definitions | ||
72 | hw/misc/bcm2835_property: Handle CORE_CLK_ID firmware property | ||
53 | 73 | ||
54 | Patrick Venture (1): | 74 | docs/system/arm/sbsa.rst | 38 +- |
55 | hw/net: npcm7xx_emc fix missing queue_flush | 75 | include/hw/arm/raspi_platform.h | 10 + |
56 | 76 | include/hw/char/imx_serial.h | 1 + | |
57 | Peter Maydell (6): | 77 | include/hw/misc/raspberrypi-fw-defs.h | 163 ++ |
58 | target/i386: Use assert() to sanity-check b1 in SSE decode | 78 | target/arm/tcg/a64.decode | 403 ++++ |
59 | include/hw/i386: Don't include qemu-common.h in .h files | 79 | hw/char/imx_serial.c | 5 +- |
60 | target/hexagon/cpu.h: don't include qemu-common.h | 80 | hw/intc/allwinner-a10-pic.c | 2 +- |
61 | target/rx/cpu.h: Don't include qemu-common.h | 81 | hw/misc/bcm2835_property.c | 112 +- |
62 | hw/arm: Don't include qemu-common.h unnecessarily | 82 | hw/sd/allwinner-sdhost.c | 2 +- |
63 | target/arm: Correct calculation of tlb range invalidate length | 83 | hw/timer/nrf51_timer.c | 7 +- |
64 | 84 | target/arm/tcg/translate-a64.c | 3319 +++++++++++++++------------------ | |
65 | Philippe Mathieu-Daudé (2): | 85 | hw/arm/Kconfig | 1 + |
66 | hw/intc/arm_gicv3: Extract gicv3_set_gicv3state from arm_gicv3_cpuif.c | 86 | 12 files changed, 2157 insertions(+), 1906 deletions(-) |
67 | hw/intc/arm_gicv3: Introduce CONFIG_ARM_GIC_TCG Kconfig selector | 87 | create mode 100644 include/hw/misc/raspberrypi-fw-defs.h |
68 | |||
69 | Richard Henderson (10): | ||
70 | target/arm: Hoist pc_next to a local variable in aarch64_tr_translate_insn | ||
71 | target/arm: Hoist pc_next to a local variable in arm_tr_translate_insn | ||
72 | target/arm: Hoist pc_next to a local variable in thumb_tr_translate_insn | ||
73 | target/arm: Split arm_pre_translate_insn | ||
74 | target/arm: Advance pc for arch single-step exception | ||
75 | target/arm: Split compute_fsr_fsc out of arm_deliver_fault | ||
76 | target/arm: Take an exception if PC is misaligned | ||
77 | target/arm: Assert thumb pc is aligned | ||
78 | target/arm: Suppress bp for exceptions with more priority | ||
79 | tests/tcg: Add arm and aarch64 pc alignment tests | ||
80 | |||
81 | docs/system/arm/aspeed.rst | 26 ++++++++++++---- | ||
82 | include/hw/i386/microvm.h | 1 - | ||
83 | include/hw/i386/x86.h | 1 - | ||
84 | target/arm/helper.h | 1 + | ||
85 | target/arm/syndrome.h | 5 +++ | ||
86 | target/hexagon/cpu.h | 1 - | ||
87 | target/rx/cpu.h | 1 - | ||
88 | hw/arm/boot.c | 1 - | ||
89 | hw/arm/digic_boards.c | 1 - | ||
90 | hw/arm/highbank.c | 1 - | ||
91 | hw/arm/npcm7xx_boards.c | 1 - | ||
92 | hw/arm/sbsa-ref.c | 1 - | ||
93 | hw/arm/stm32f405_soc.c | 1 - | ||
94 | hw/arm/vexpress.c | 1 - | ||
95 | hw/arm/virt-acpi-build.c | 7 +++++ | ||
96 | hw/arm/virt.c | 21 ++++++------- | ||
97 | hw/char/stm32f2xx_usart.c | 3 +- | ||
98 | hw/intc/arm_gicv3.c | 2 +- | ||
99 | hw/intc/arm_gicv3_cpuif.c | 10 +----- | ||
100 | hw/intc/arm_gicv3_cpuif_common.c | 22 +++++++++++++ | ||
101 | hw/intc/arm_gicv3_its.c | 39 +++++++++++++++-------- | ||
102 | hw/net/npcm7xx_emc.c | 18 +++++------ | ||
103 | hw/virtio/virtio-iommu-pci.c | 12 ++------ | ||
104 | linux-user/aarch64/cpu_loop.c | 46 ++++++++++++++++------------ | ||
105 | linux-user/hexagon/cpu_loop.c | 1 + | ||
106 | target/arm/debug_helper.c | 23 ++++++++++++++ | ||
107 | target/arm/gdbstub.c | 9 ++++-- | ||
108 | target/arm/helper.c | 6 ++-- | ||
109 | target/arm/machine.c | 10 ++++++ | ||
110 | target/arm/tlb_helper.c | 63 ++++++++++++++++++++++++++++---------- | ||
111 | target/arm/translate-a64.c | 23 ++++++++++++-- | ||
112 | target/arm/translate.c | 58 ++++++++++++++++++++++++++--------- | ||
113 | target/i386/tcg/translate.c | 12 ++------ | ||
114 | tests/qtest/bios-tables-test.c | 38 +++++++++++++++++++++++ | ||
115 | tests/tcg/aarch64/pcalign-a64.c | 37 ++++++++++++++++++++++ | ||
116 | tests/tcg/arm/pcalign-a32.c | 46 ++++++++++++++++++++++++++++ | ||
117 | hw/arm/Kconfig | 1 + | ||
118 | hw/intc/Kconfig | 5 +++ | ||
119 | hw/intc/meson.build | 11 ++++--- | ||
120 | tests/data/acpi/q35/DSDT.viot | Bin 0 -> 9398 bytes | ||
121 | tests/data/acpi/q35/VIOT.viot | Bin 0 -> 112 bytes | ||
122 | tests/data/acpi/virt/VIOT | Bin 0 -> 88 bytes | ||
123 | tests/tcg/aarch64/Makefile.target | 4 +-- | ||
124 | tests/tcg/arm/Makefile.target | 4 +++ | ||
125 | 44 files changed, 429 insertions(+), 145 deletions(-) | ||
126 | create mode 100644 hw/intc/arm_gicv3_cpuif_common.c | ||
127 | create mode 100644 tests/tcg/aarch64/pcalign-a64.c | ||
128 | create mode 100644 tests/tcg/arm/pcalign-a32.c | ||
129 | create mode 100644 tests/data/acpi/q35/DSDT.viot | ||
130 | create mode 100644 tests/data/acpi/q35/VIOT.viot | ||
131 | create mode 100644 tests/data/acpi/virt/VIOT | ||
132 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | The atomic memory operations are supposed to return the old memory |
---|---|---|---|
2 | data value in the destination register. This value is not | ||
3 | sign-extended, even if the operation is the signed minimum or | ||
4 | maximum. (In the pseudocode for the instructions the returned data | ||
5 | value is passed to ZeroExtend() to create the value in the register.) | ||
2 | 6 | ||
3 | The VIOT blob contains the following: | 7 | We got this wrong because we were doing a 32-to-64 zero extend on the |
8 | result for 8 and 16 bit data values, rather than the correct amount | ||
9 | of zero extension. | ||
4 | 10 | ||
5 | [000h 0000 4] Signature : "VIOT" [Virtual I/O Translation Table] | 11 | Fix the bug by using ext8u and ext16u for the MO_8 and MO_16 data |
6 | [004h 0004 4] Table Length : 00000058 | 12 | sizes rather than ext32u. |
7 | [008h 0008 1] Revision : 00 | ||
8 | [009h 0009 1] Checksum : 66 | ||
9 | [00Ah 0010 6] Oem ID : "BOCHS " | ||
10 | [010h 0016 8] Oem Table ID : "BXPC " | ||
11 | [018h 0024 4] Oem Revision : 00000001 | ||
12 | [01Ch 0028 4] Asl Compiler ID : "BXPC" | ||
13 | [020h 0032 4] Asl Compiler Revision : 00000001 | ||
14 | 13 | ||
15 | [024h 0036 2] Node count : 0002 | 14 | Cc: qemu-stable@nongnu.org |
16 | [026h 0038 2] Node offset : 0030 | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | [028h 0040 8] Reserved : 0000000000000000 | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-id: 20230602155223.2040685-2-peter.maydell@linaro.org | ||
18 | --- | ||
19 | target/arm/tcg/translate-a64.c | 18 ++++++++++++++++-- | ||
20 | 1 file changed, 16 insertions(+), 2 deletions(-) | ||
18 | 21 | ||
19 | [030h 0048 1] Type : 03 [VirtIO-PCI IOMMU] | 22 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
20 | [031h 0049 1] Reserved : 00 | ||
21 | [032h 0050 2] Length : 0010 | ||
22 | |||
23 | [034h 0052 2] PCI Segment : 0000 | ||
24 | [036h 0054 2] PCI BDF number : 0008 | ||
25 | [038h 0056 8] Reserved : 0000000000000000 | ||
26 | |||
27 | [040h 0064 1] Type : 01 [PCI Range] | ||
28 | [041h 0065 1] Reserved : 00 | ||
29 | [042h 0066 2] Length : 0018 | ||
30 | |||
31 | [044h 0068 4] Endpoint start : 00000000 | ||
32 | [048h 0072 2] PCI Segment start : 0000 | ||
33 | [04Ah 0074 2] PCI Segment end : 0000 | ||
34 | [04Ch 0076 2] PCI BDF start : 0000 | ||
35 | [04Eh 0078 2] PCI BDF end : 00FF | ||
36 | [050h 0080 2] Output node : 0030 | ||
37 | [052h 0082 6] Reserved : 000000000000 | ||
38 | |||
39 | Acked-by: Ani Sinha <ani@anisinha.ca> | ||
40 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
41 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
42 | Message-id: 20211210170415.583179-9-jean-philippe@linaro.org | ||
43 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
44 | --- | ||
45 | tests/qtest/bios-tables-test-allowed-diff.h | 1 - | ||
46 | tests/data/acpi/virt/VIOT | Bin 0 -> 88 bytes | ||
47 | 2 files changed, 1 deletion(-) | ||
48 | |||
49 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | ||
50 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | 24 | --- a/target/arm/tcg/translate-a64.c |
52 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | 25 | +++ b/target/arm/tcg/translate-a64.c |
53 | @@ -1,2 +1 @@ | 26 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, |
54 | /* List of comma-separated changed AML files to ignore */ | 27 | */ |
55 | -"tests/data/acpi/virt/VIOT", | 28 | fn(tcg_rt, clean_addr, tcg_rs, get_mem_index(s), mop); |
56 | diff --git a/tests/data/acpi/virt/VIOT b/tests/data/acpi/virt/VIOT | 29 | |
57 | index XXXXXXX..XXXXXXX 100644 | 30 | - if ((mop & MO_SIGN) && size != MO_64) { |
58 | GIT binary patch | 31 | - tcg_gen_ext32u_i64(tcg_rt, tcg_rt); |
59 | literal 88 | 32 | + if (mop & MO_SIGN) { |
60 | zcmWIZ^bd((0D?3pe`k+i1*eDrX9XZ&1PX!JAexE60Hgv8m>C3sGzXN&z`)2L0cSHX | 33 | + switch (size) { |
61 | I{D-Rq0Q5fy0RR91 | 34 | + case MO_8: |
62 | 35 | + tcg_gen_ext8u_i64(tcg_rt, tcg_rt); | |
63 | literal 0 | 36 | + break; |
64 | HcmV?d00001 | 37 | + case MO_16: |
65 | 38 | + tcg_gen_ext16u_i64(tcg_rt, tcg_rt); | |
39 | + break; | ||
40 | + case MO_32: | ||
41 | + tcg_gen_ext32u_i64(tcg_rt, tcg_rt); | ||
42 | + break; | ||
43 | + case MO_64: | ||
44 | + break; | ||
45 | + default: | ||
46 | + g_assert_not_reached(); | ||
47 | + } | ||
48 | } | ||
49 | } | ||
50 | |||
66 | -- | 51 | -- |
67 | 2.25.1 | 52 | 2.34.1 |
68 | |||
69 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | The LDG instruction loads the tag from a memory address (identified |
---|---|---|---|
2 | by [Xn + offset]), and then merges that tag into the destination | ||
3 | register Xt. We implemented this correctly for the case when | ||
4 | allocation tags are enabled, but didn't get it right when ATA=0: | ||
5 | instead of merging the tag bits into Xt, we merged them into the | ||
6 | memory address [Xn + offset] and then set Xt to that. | ||
2 | 7 | ||
3 | Create empty data files and allow updates for the upcoming VIOT tests. | 8 | Merge the tag bits into the old Xt value, as they should be. |
4 | 9 | ||
5 | Acked-by: Igor Mammedov <imammedo@redhat.com> | 10 | Cc: qemu-stable@nongnu.org |
6 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 11 | Fixes: c15294c1e36a7dd9b25 ("target/arm: Implement LDG, STG, ST2G instructions") |
7 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | 12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20211210170415.583179-6-jean-philippe@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 14 | --- |
11 | tests/qtest/bios-tables-test-allowed-diff.h | 3 +++ | 15 | target/arm/tcg/translate-a64.c | 6 +++++- |
12 | tests/data/acpi/q35/DSDT.viot | 0 | 16 | 1 file changed, 5 insertions(+), 1 deletion(-) |
13 | tests/data/acpi/q35/VIOT.viot | 0 | ||
14 | tests/data/acpi/virt/VIOT | 0 | ||
15 | 4 files changed, 3 insertions(+) | ||
16 | create mode 100644 tests/data/acpi/q35/DSDT.viot | ||
17 | create mode 100644 tests/data/acpi/q35/VIOT.viot | ||
18 | create mode 100644 tests/data/acpi/virt/VIOT | ||
19 | 17 | ||
20 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | 18 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
21 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | 20 | --- a/target/arm/tcg/translate-a64.c |
23 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | 21 | +++ b/target/arm/tcg/translate-a64.c |
24 | @@ -1 +1,4 @@ | 22 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_tag(DisasContext *s, uint32_t insn) |
25 | /* List of comma-separated changed AML files to ignore */ | 23 | if (s->ata) { |
26 | +"tests/data/acpi/virt/VIOT", | 24 | gen_helper_ldg(tcg_rt, cpu_env, addr, tcg_rt); |
27 | +"tests/data/acpi/q35/DSDT.viot", | 25 | } else { |
28 | +"tests/data/acpi/q35/VIOT.viot", | 26 | + /* |
29 | diff --git a/tests/data/acpi/q35/DSDT.viot b/tests/data/acpi/q35/DSDT.viot | 27 | + * Tag access disabled: we must check for aborts on the load |
30 | new file mode 100644 | 28 | + * load from [rn+offset], and then insert a 0 tag into rt. |
31 | index XXXXXXX..XXXXXXX | 29 | + */ |
32 | diff --git a/tests/data/acpi/q35/VIOT.viot b/tests/data/acpi/q35/VIOT.viot | 30 | clean_addr = clean_data_tbi(s, addr); |
33 | new file mode 100644 | 31 | gen_probe_access(s, clean_addr, MMU_DATA_LOAD, MO_8); |
34 | index XXXXXXX..XXXXXXX | 32 | - gen_address_with_allocation_tag0(tcg_rt, addr); |
35 | diff --git a/tests/data/acpi/virt/VIOT b/tests/data/acpi/virt/VIOT | 33 | + gen_address_with_allocation_tag0(tcg_rt, tcg_rt); |
36 | new file mode 100644 | 34 | } |
37 | index XXXXXXX..XXXXXXX | 35 | } else { |
36 | tcg_rt = cpu_reg_sp(s, rt); | ||
38 | -- | 37 | -- |
39 | 2.25.1 | 38 | 2.34.1 |
40 | |||
41 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | In disas_ldst_reg_imm9() we missed one place where a call to |
---|---|---|---|
2 | a gen_mte_check* function should now be passed the memop we | ||
3 | have created rather than just being passed the size. Fix this. | ||
2 | 4 | ||
3 | Move it to the supported list. | 5 | Fixes: 0a9091424d ("target/arm: Pass memop to gen_mte_check1*") |
4 | |||
5 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
6 | Message-id: 20211117065752.330632-5-joel@jms.id.au | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | --- | 9 | --- |
9 | docs/system/arm/aspeed.rst | 2 +- | 10 | target/arm/tcg/translate-a64.c | 2 +- |
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
11 | 12 | ||
12 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | 13 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
13 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/docs/system/arm/aspeed.rst | 15 | --- a/target/arm/tcg/translate-a64.c |
15 | +++ b/docs/system/arm/aspeed.rst | 16 | +++ b/target/arm/tcg/translate-a64.c |
16 | @@ -XXX,XX +XXX,XX @@ Supported devices | 17 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_imm9(DisasContext *s, uint32_t insn, |
17 | * Front LEDs (PCA9552 on I2C bus) | 18 | |
18 | * LPC Peripheral Controller (a subset of subdevices are supported) | 19 | clean_addr = gen_mte_check1_mmuidx(s, dirty_addr, is_store, |
19 | * Hash/Crypto Engine (HACE) - Hash support only. TODO: HMAC and RSA | 20 | writeback || rn != 31, |
20 | + * ADC | 21 | - size, is_unpriv, memidx); |
21 | 22 | + memop, is_unpriv, memidx); | |
22 | 23 | ||
23 | Missing devices | 24 | if (is_vector) { |
24 | --------------- | 25 | if (is_store) { |
25 | |||
26 | * Coprocessor support | ||
27 | - * ADC (out of tree implementation) | ||
28 | * PWM and Fan Controller | ||
29 | * Slave GPIO Controller | ||
30 | * Super I/O Controller | ||
31 | -- | 26 | -- |
32 | 2.25.1 | 27 | 2.34.1 |
33 | 28 | ||
34 | 29 | diff view generated by jsdifflib |
1 | In the SSE decode function gen_sse(), we combine a byte | 1 | In the recent refactoring we missed a few places which should be |
---|---|---|---|
2 | 'b' and a value 'b1' which can be [0..3], and switch on them: | 2 | calling finalize_memop_asimd() for ASIMD loads and stores but |
3 | b |= (b1 << 8); | 3 | instead are just calling finalize_memop(); fix these. |
4 | switch (b) { | ||
5 | ... | ||
6 | default: | ||
7 | unknown_op: | ||
8 | gen_unknown_opcode(env, s); | ||
9 | return; | ||
10 | } | ||
11 | 4 | ||
12 | In three cases inside this switch, we were then also checking for | 5 | For the disas_ldst_single_struct() and disas_ldst_multiple_struct() |
13 | "if (b1 >= 2) { goto unknown_op; }". | 6 | cases, this is not a behaviour change because there the size |
14 | However, this can never happen, because the 'case' values in each place | 7 | is never MO_128 and the two finalize functions do the same thing. |
15 | are 0x0nn or 0x1nn and the switch will have directed the b1 == (2, 3) | ||
16 | cases to the default already. | ||
17 | 8 | ||
18 | This check was added in commit c045af25a52e9 in 2010; the added code | ||
19 | was unnecessary then as well, and was apparently intended only to | ||
20 | ensure that we never accidentally ended up indexing off the end | ||
21 | of an sse_op_table with only 2 entries as a result of future bugs | ||
22 | in the decode logic. | ||
23 | |||
24 | Change the checks to assert() instead, and make sure they're always | ||
25 | immediately before the array access they are protecting. | ||
26 | |||
27 | Fixes: Coverity CID 1460207 | ||
28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
29 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
30 | --- | 11 | --- |
31 | target/i386/tcg/translate.c | 12 +++--------- | 12 | target/arm/tcg/translate-a64.c | 10 ++++++---- |
32 | 1 file changed, 3 insertions(+), 9 deletions(-) | 13 | 1 file changed, 6 insertions(+), 4 deletions(-) |
33 | 14 | ||
34 | diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c | 15 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
35 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/i386/tcg/translate.c | 17 | --- a/target/arm/tcg/translate-a64.c |
37 | +++ b/target/i386/tcg/translate.c | 18 | +++ b/target/arm/tcg/translate-a64.c |
38 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, | 19 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_roffset(DisasContext *s, uint32_t insn, |
39 | case 0x171: /* shift xmm, im */ | 20 | if (!fp_access_check(s)) { |
40 | case 0x172: | 21 | return; |
41 | case 0x173: | 22 | } |
42 | - if (b1 >= 2) { | 23 | + memop = finalize_memop_asimd(s, size); |
43 | - goto unknown_op; | 24 | } else { |
44 | - } | 25 | if (size == 3 && opc == 2) { |
45 | val = x86_ldub_code(env, s); | 26 | /* PRFM - prefetch */ |
46 | if (is_xmm) { | 27 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_roffset(DisasContext *s, uint32_t insn, |
47 | tcg_gen_movi_tl(s->T0, val); | 28 | is_store = (opc == 0); |
48 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, | 29 | is_signed = !is_store && extract32(opc, 1, 1); |
49 | offsetof(CPUX86State, mmx_t0.MMX_L(1))); | 30 | is_extended = (size < 3) && extract32(opc, 0, 1); |
50 | op1_offset = offsetof(CPUX86State,mmx_t0); | 31 | + memop = finalize_memop(s, size + is_signed * MO_SIGN); |
51 | } | 32 | } |
52 | + assert(b1 < 2); | 33 | |
53 | sse_fn_epp = sse_op_table2[((b - 1) & 3) * 8 + | 34 | if (rn == 31) { |
54 | (((modrm >> 3)) & 7)][b1]; | 35 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_roffset(DisasContext *s, uint32_t insn, |
55 | if (!sse_fn_epp) { | 36 | |
56 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, | 37 | tcg_gen_add_i64(dirty_addr, dirty_addr, tcg_rm); |
57 | rm = modrm & 7; | 38 | |
58 | reg = ((modrm >> 3) & 7) | REX_R(s); | 39 | - memop = finalize_memop(s, size + is_signed * MO_SIGN); |
59 | mod = (modrm >> 6) & 3; | 40 | clean_addr = gen_mte_check1(s, dirty_addr, is_store, true, memop); |
60 | - if (b1 >= 2) { | 41 | |
61 | - goto unknown_op; | 42 | if (is_vector) { |
62 | - } | 43 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_unsigned_imm(DisasContext *s, uint32_t insn, |
63 | 44 | if (!fp_access_check(s)) { | |
64 | + assert(b1 < 2); | 45 | return; |
65 | sse_fn_epp = sse_op_table6[b].op[b1]; | 46 | } |
66 | if (!sse_fn_epp) { | 47 | + memop = finalize_memop_asimd(s, size); |
67 | goto unknown_op; | 48 | } else { |
68 | @@ -XXX,XX +XXX,XX @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b, | 49 | if (size == 3 && opc == 2) { |
69 | rm = modrm & 7; | 50 | /* PRFM - prefetch */ |
70 | reg = ((modrm >> 3) & 7) | REX_R(s); | 51 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_unsigned_imm(DisasContext *s, uint32_t insn, |
71 | mod = (modrm >> 6) & 3; | 52 | is_store = (opc == 0); |
72 | - if (b1 >= 2) { | 53 | is_signed = !is_store && extract32(opc, 1, 1); |
73 | - goto unknown_op; | 54 | is_extended = (size < 3) && extract32(opc, 0, 1); |
74 | - } | 55 | + memop = finalize_memop(s, size + is_signed * MO_SIGN); |
75 | 56 | } | |
76 | + assert(b1 < 2); | 57 | |
77 | sse_fn_eppi = sse_op_table7[b].op[b1]; | 58 | if (rn == 31) { |
78 | if (!sse_fn_eppi) { | 59 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_unsigned_imm(DisasContext *s, uint32_t insn, |
79 | goto unknown_op; | 60 | offset = imm12 << size; |
61 | tcg_gen_addi_i64(dirty_addr, dirty_addr, offset); | ||
62 | |||
63 | - memop = finalize_memop(s, size + is_signed * MO_SIGN); | ||
64 | clean_addr = gen_mte_check1(s, dirty_addr, is_store, rn != 31, memop); | ||
65 | |||
66 | if (is_vector) { | ||
67 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
68 | * promote consecutive little-endian elements below. | ||
69 | */ | ||
70 | clean_addr = gen_mte_checkN(s, tcg_rn, is_store, is_postidx || rn != 31, | ||
71 | - total, finalize_memop(s, size)); | ||
72 | + total, finalize_memop_asimd(s, size)); | ||
73 | |||
74 | /* | ||
75 | * Consecutive little-endian elements from a single register | ||
76 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | ||
77 | total = selem << scale; | ||
78 | tcg_rn = cpu_reg_sp(s, rn); | ||
79 | |||
80 | - mop = finalize_memop(s, scale); | ||
81 | + mop = finalize_memop_asimd(s, scale); | ||
82 | |||
83 | clean_addr = gen_mte_checkN(s, tcg_rn, !is_load, is_postidx || rn != 31, | ||
84 | total, mop); | ||
80 | -- | 85 | -- |
81 | 2.25.1 | 86 | 2.34.1 |
82 | |||
83 | diff view generated by jsdifflib |
1 | The qemu-common.h header is not supposed to be included from any | 1 | Convert the various instructions in the hint instruction space |
---|---|---|---|
2 | other header files, only from .c files (as documented in a comment at | 2 | to decodetree. |
3 | the start of it). | ||
4 | |||
5 | Nothing actually relies on target/rx/cpu.h including it, so we can | ||
6 | just drop the include. | ||
7 | 3 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Message-id: 20230602155223.2040685-3-peter.maydell@linaro.org |
11 | Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> | ||
12 | Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp> | ||
13 | Message-id: 20211129200510.1233037-4-peter.maydell@linaro.org | ||
14 | --- | 7 | --- |
15 | target/rx/cpu.h | 1 - | 8 | target/arm/tcg/a64.decode | 31 ++++ |
16 | 1 file changed, 1 deletion(-) | 9 | target/arm/tcg/translate-a64.c | 277 ++++++++++++++++++--------------- |
10 | 2 files changed, 185 insertions(+), 123 deletions(-) | ||
17 | 11 | ||
18 | diff --git a/target/rx/cpu.h b/target/rx/cpu.h | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
19 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/rx/cpu.h | 14 | --- a/target/arm/tcg/a64.decode |
21 | +++ b/target/rx/cpu.h | 15 | +++ b/target/arm/tcg/a64.decode |
22 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ ERETA 1101011 0100 11111 00001 m:1 11111 11111 &reta # ERETAA, ERETAB |
23 | #define RX_CPU_H | 17 | # the processor is in halting debug state (which we don't implement). |
24 | 18 | # The pattern is listed here as documentation. | |
25 | #include "qemu/bitops.h" | 19 | # DRPS 1101011 0101 11111 000000 11111 00000 |
26 | -#include "qemu-common.h" | 20 | + |
27 | #include "hw/registerfields.h" | 21 | +# Hint instruction group |
28 | #include "cpu-qom.h" | 22 | +{ |
29 | 23 | + [ | |
24 | + YIELD 1101 0101 0000 0011 0010 0000 001 11111 | ||
25 | + WFE 1101 0101 0000 0011 0010 0000 010 11111 | ||
26 | + WFI 1101 0101 0000 0011 0010 0000 011 11111 | ||
27 | + # We implement WFE to never block, so our SEV/SEVL are NOPs | ||
28 | + # SEV 1101 0101 0000 0011 0010 0000 100 11111 | ||
29 | + # SEVL 1101 0101 0000 0011 0010 0000 101 11111 | ||
30 | + # Our DGL is a NOP because we don't merge memory accesses anyway. | ||
31 | + # DGL 1101 0101 0000 0011 0010 0000 110 11111 | ||
32 | + XPACLRI 1101 0101 0000 0011 0010 0000 111 11111 | ||
33 | + PACIA1716 1101 0101 0000 0011 0010 0001 000 11111 | ||
34 | + PACIB1716 1101 0101 0000 0011 0010 0001 010 11111 | ||
35 | + AUTIA1716 1101 0101 0000 0011 0010 0001 100 11111 | ||
36 | + AUTIB1716 1101 0101 0000 0011 0010 0001 110 11111 | ||
37 | + ESB 1101 0101 0000 0011 0010 0010 000 11111 | ||
38 | + PACIAZ 1101 0101 0000 0011 0010 0011 000 11111 | ||
39 | + PACIASP 1101 0101 0000 0011 0010 0011 001 11111 | ||
40 | + PACIBZ 1101 0101 0000 0011 0010 0011 010 11111 | ||
41 | + PACIBSP 1101 0101 0000 0011 0010 0011 011 11111 | ||
42 | + AUTIAZ 1101 0101 0000 0011 0010 0011 100 11111 | ||
43 | + AUTIASP 1101 0101 0000 0011 0010 0011 101 11111 | ||
44 | + AUTIBZ 1101 0101 0000 0011 0010 0011 110 11111 | ||
45 | + AUTIBSP 1101 0101 0000 0011 0010 0011 111 11111 | ||
46 | + ] | ||
47 | + # The canonical NOP has CRm == op2 == 0, but all of the space | ||
48 | + # that isn't specifically allocated to an instruction must NOP | ||
49 | + NOP 1101 0101 0000 0011 0010 ---- --- 11111 | ||
50 | +} | ||
51 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/tcg/translate-a64.c | ||
54 | +++ b/target/arm/tcg/translate-a64.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static bool trans_ERETA(DisasContext *s, arg_reta *a) | ||
56 | return true; | ||
57 | } | ||
58 | |||
59 | -/* HINT instruction group, including various allocated HINTs */ | ||
60 | -static void handle_hint(DisasContext *s, uint32_t insn, | ||
61 | - unsigned int op1, unsigned int op2, unsigned int crm) | ||
62 | +static bool trans_NOP(DisasContext *s, arg_NOP *a) | ||
63 | { | ||
64 | - unsigned int selector = crm << 3 | op2; | ||
65 | + return true; | ||
66 | +} | ||
67 | |||
68 | - if (op1 != 3) { | ||
69 | - unallocated_encoding(s); | ||
70 | - return; | ||
71 | +static bool trans_YIELD(DisasContext *s, arg_YIELD *a) | ||
72 | +{ | ||
73 | + /* | ||
74 | + * When running in MTTCG we don't generate jumps to the yield and | ||
75 | + * WFE helpers as it won't affect the scheduling of other vCPUs. | ||
76 | + * If we wanted to more completely model WFE/SEV so we don't busy | ||
77 | + * spin unnecessarily we would need to do something more involved. | ||
78 | + */ | ||
79 | + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { | ||
80 | + s->base.is_jmp = DISAS_YIELD; | ||
81 | } | ||
82 | + return true; | ||
83 | +} | ||
84 | |||
85 | - switch (selector) { | ||
86 | - case 0b00000: /* NOP */ | ||
87 | - break; | ||
88 | - case 0b00011: /* WFI */ | ||
89 | - s->base.is_jmp = DISAS_WFI; | ||
90 | - break; | ||
91 | - case 0b00001: /* YIELD */ | ||
92 | - /* When running in MTTCG we don't generate jumps to the yield and | ||
93 | - * WFE helpers as it won't affect the scheduling of other vCPUs. | ||
94 | - * If we wanted to more completely model WFE/SEV so we don't busy | ||
95 | - * spin unnecessarily we would need to do something more involved. | ||
96 | +static bool trans_WFI(DisasContext *s, arg_WFI *a) | ||
97 | +{ | ||
98 | + s->base.is_jmp = DISAS_WFI; | ||
99 | + return true; | ||
100 | +} | ||
101 | + | ||
102 | +static bool trans_WFE(DisasContext *s, arg_WFI *a) | ||
103 | +{ | ||
104 | + /* | ||
105 | + * When running in MTTCG we don't generate jumps to the yield and | ||
106 | + * WFE helpers as it won't affect the scheduling of other vCPUs. | ||
107 | + * If we wanted to more completely model WFE/SEV so we don't busy | ||
108 | + * spin unnecessarily we would need to do something more involved. | ||
109 | + */ | ||
110 | + if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { | ||
111 | + s->base.is_jmp = DISAS_WFE; | ||
112 | + } | ||
113 | + return true; | ||
114 | +} | ||
115 | + | ||
116 | +static bool trans_XPACLRI(DisasContext *s, arg_XPACLRI *a) | ||
117 | +{ | ||
118 | + if (s->pauth_active) { | ||
119 | + gen_helper_xpaci(cpu_X[30], cpu_env, cpu_X[30]); | ||
120 | + } | ||
121 | + return true; | ||
122 | +} | ||
123 | + | ||
124 | +static bool trans_PACIA1716(DisasContext *s, arg_PACIA1716 *a) | ||
125 | +{ | ||
126 | + if (s->pauth_active) { | ||
127 | + gen_helper_pacia(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
128 | + } | ||
129 | + return true; | ||
130 | +} | ||
131 | + | ||
132 | +static bool trans_PACIB1716(DisasContext *s, arg_PACIB1716 *a) | ||
133 | +{ | ||
134 | + if (s->pauth_active) { | ||
135 | + gen_helper_pacib(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
136 | + } | ||
137 | + return true; | ||
138 | +} | ||
139 | + | ||
140 | +static bool trans_AUTIA1716(DisasContext *s, arg_AUTIA1716 *a) | ||
141 | +{ | ||
142 | + if (s->pauth_active) { | ||
143 | + gen_helper_autia(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
144 | + } | ||
145 | + return true; | ||
146 | +} | ||
147 | + | ||
148 | +static bool trans_AUTIB1716(DisasContext *s, arg_AUTIB1716 *a) | ||
149 | +{ | ||
150 | + if (s->pauth_active) { | ||
151 | + gen_helper_autib(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
152 | + } | ||
153 | + return true; | ||
154 | +} | ||
155 | + | ||
156 | +static bool trans_ESB(DisasContext *s, arg_ESB *a) | ||
157 | +{ | ||
158 | + /* Without RAS, we must implement this as NOP. */ | ||
159 | + if (dc_isar_feature(aa64_ras, s)) { | ||
160 | + /* | ||
161 | + * QEMU does not have a source of physical SErrors, | ||
162 | + * so we are only concerned with virtual SErrors. | ||
163 | + * The pseudocode in the ARM for this case is | ||
164 | + * if PSTATE.EL IN {EL0, EL1} && EL2Enabled() then | ||
165 | + * AArch64.vESBOperation(); | ||
166 | + * Most of the condition can be evaluated at translation time. | ||
167 | + * Test for EL2 present, and defer test for SEL2 to runtime. | ||
168 | */ | ||
169 | - if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { | ||
170 | - s->base.is_jmp = DISAS_YIELD; | ||
171 | + if (s->current_el <= 1 && arm_dc_feature(s, ARM_FEATURE_EL2)) { | ||
172 | + gen_helper_vesb(cpu_env); | ||
173 | } | ||
174 | - break; | ||
175 | - case 0b00010: /* WFE */ | ||
176 | - if (!(tb_cflags(s->base.tb) & CF_PARALLEL)) { | ||
177 | - s->base.is_jmp = DISAS_WFE; | ||
178 | - } | ||
179 | - break; | ||
180 | - case 0b00100: /* SEV */ | ||
181 | - case 0b00101: /* SEVL */ | ||
182 | - case 0b00110: /* DGH */ | ||
183 | - /* we treat all as NOP at least for now */ | ||
184 | - break; | ||
185 | - case 0b00111: /* XPACLRI */ | ||
186 | - if (s->pauth_active) { | ||
187 | - gen_helper_xpaci(cpu_X[30], cpu_env, cpu_X[30]); | ||
188 | - } | ||
189 | - break; | ||
190 | - case 0b01000: /* PACIA1716 */ | ||
191 | - if (s->pauth_active) { | ||
192 | - gen_helper_pacia(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
193 | - } | ||
194 | - break; | ||
195 | - case 0b01010: /* PACIB1716 */ | ||
196 | - if (s->pauth_active) { | ||
197 | - gen_helper_pacib(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
198 | - } | ||
199 | - break; | ||
200 | - case 0b01100: /* AUTIA1716 */ | ||
201 | - if (s->pauth_active) { | ||
202 | - gen_helper_autia(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
203 | - } | ||
204 | - break; | ||
205 | - case 0b01110: /* AUTIB1716 */ | ||
206 | - if (s->pauth_active) { | ||
207 | - gen_helper_autib(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]); | ||
208 | - } | ||
209 | - break; | ||
210 | - case 0b10000: /* ESB */ | ||
211 | - /* Without RAS, we must implement this as NOP. */ | ||
212 | - if (dc_isar_feature(aa64_ras, s)) { | ||
213 | - /* | ||
214 | - * QEMU does not have a source of physical SErrors, | ||
215 | - * so we are only concerned with virtual SErrors. | ||
216 | - * The pseudocode in the ARM for this case is | ||
217 | - * if PSTATE.EL IN {EL0, EL1} && EL2Enabled() then | ||
218 | - * AArch64.vESBOperation(); | ||
219 | - * Most of the condition can be evaluated at translation time. | ||
220 | - * Test for EL2 present, and defer test for SEL2 to runtime. | ||
221 | - */ | ||
222 | - if (s->current_el <= 1 && arm_dc_feature(s, ARM_FEATURE_EL2)) { | ||
223 | - gen_helper_vesb(cpu_env); | ||
224 | - } | ||
225 | - } | ||
226 | - break; | ||
227 | - case 0b11000: /* PACIAZ */ | ||
228 | - if (s->pauth_active) { | ||
229 | - gen_helper_pacia(cpu_X[30], cpu_env, cpu_X[30], | ||
230 | - tcg_constant_i64(0)); | ||
231 | - } | ||
232 | - break; | ||
233 | - case 0b11001: /* PACIASP */ | ||
234 | - if (s->pauth_active) { | ||
235 | - gen_helper_pacia(cpu_X[30], cpu_env, cpu_X[30], cpu_X[31]); | ||
236 | - } | ||
237 | - break; | ||
238 | - case 0b11010: /* PACIBZ */ | ||
239 | - if (s->pauth_active) { | ||
240 | - gen_helper_pacib(cpu_X[30], cpu_env, cpu_X[30], | ||
241 | - tcg_constant_i64(0)); | ||
242 | - } | ||
243 | - break; | ||
244 | - case 0b11011: /* PACIBSP */ | ||
245 | - if (s->pauth_active) { | ||
246 | - gen_helper_pacib(cpu_X[30], cpu_env, cpu_X[30], cpu_X[31]); | ||
247 | - } | ||
248 | - break; | ||
249 | - case 0b11100: /* AUTIAZ */ | ||
250 | - if (s->pauth_active) { | ||
251 | - gen_helper_autia(cpu_X[30], cpu_env, cpu_X[30], | ||
252 | - tcg_constant_i64(0)); | ||
253 | - } | ||
254 | - break; | ||
255 | - case 0b11101: /* AUTIASP */ | ||
256 | - if (s->pauth_active) { | ||
257 | - gen_helper_autia(cpu_X[30], cpu_env, cpu_X[30], cpu_X[31]); | ||
258 | - } | ||
259 | - break; | ||
260 | - case 0b11110: /* AUTIBZ */ | ||
261 | - if (s->pauth_active) { | ||
262 | - gen_helper_autib(cpu_X[30], cpu_env, cpu_X[30], | ||
263 | - tcg_constant_i64(0)); | ||
264 | - } | ||
265 | - break; | ||
266 | - case 0b11111: /* AUTIBSP */ | ||
267 | - if (s->pauth_active) { | ||
268 | - gen_helper_autib(cpu_X[30], cpu_env, cpu_X[30], cpu_X[31]); | ||
269 | - } | ||
270 | - break; | ||
271 | - default: | ||
272 | - /* default specified as NOP equivalent */ | ||
273 | - break; | ||
274 | } | ||
275 | + return true; | ||
276 | +} | ||
277 | + | ||
278 | +static bool trans_PACIAZ(DisasContext *s, arg_PACIAZ *a) | ||
279 | +{ | ||
280 | + if (s->pauth_active) { | ||
281 | + gen_helper_pacia(cpu_X[30], cpu_env, cpu_X[30], tcg_constant_i64(0)); | ||
282 | + } | ||
283 | + return true; | ||
284 | +} | ||
285 | + | ||
286 | +static bool trans_PACIASP(DisasContext *s, arg_PACIASP *a) | ||
287 | +{ | ||
288 | + if (s->pauth_active) { | ||
289 | + gen_helper_pacia(cpu_X[30], cpu_env, cpu_X[30], cpu_X[31]); | ||
290 | + } | ||
291 | + return true; | ||
292 | +} | ||
293 | + | ||
294 | +static bool trans_PACIBZ(DisasContext *s, arg_PACIBZ *a) | ||
295 | +{ | ||
296 | + if (s->pauth_active) { | ||
297 | + gen_helper_pacib(cpu_X[30], cpu_env, cpu_X[30], tcg_constant_i64(0)); | ||
298 | + } | ||
299 | + return true; | ||
300 | +} | ||
301 | + | ||
302 | +static bool trans_PACIBSP(DisasContext *s, arg_PACIBSP *a) | ||
303 | +{ | ||
304 | + if (s->pauth_active) { | ||
305 | + gen_helper_pacib(cpu_X[30], cpu_env, cpu_X[30], cpu_X[31]); | ||
306 | + } | ||
307 | + return true; | ||
308 | +} | ||
309 | + | ||
310 | +static bool trans_AUTIAZ(DisasContext *s, arg_AUTIAZ *a) | ||
311 | +{ | ||
312 | + if (s->pauth_active) { | ||
313 | + gen_helper_autia(cpu_X[30], cpu_env, cpu_X[30], tcg_constant_i64(0)); | ||
314 | + } | ||
315 | + return true; | ||
316 | +} | ||
317 | + | ||
318 | +static bool trans_AUTIASP(DisasContext *s, arg_AUTIASP *a) | ||
319 | +{ | ||
320 | + if (s->pauth_active) { | ||
321 | + gen_helper_autia(cpu_X[30], cpu_env, cpu_X[30], cpu_X[31]); | ||
322 | + } | ||
323 | + return true; | ||
324 | +} | ||
325 | + | ||
326 | +static bool trans_AUTIBZ(DisasContext *s, arg_AUTIBZ *a) | ||
327 | +{ | ||
328 | + if (s->pauth_active) { | ||
329 | + gen_helper_autib(cpu_X[30], cpu_env, cpu_X[30], tcg_constant_i64(0)); | ||
330 | + } | ||
331 | + return true; | ||
332 | +} | ||
333 | + | ||
334 | +static bool trans_AUTIBSP(DisasContext *s, arg_AUTIBSP *a) | ||
335 | +{ | ||
336 | + if (s->pauth_active) { | ||
337 | + gen_helper_autib(cpu_X[30], cpu_env, cpu_X[30], cpu_X[31]); | ||
338 | + } | ||
339 | + return true; | ||
340 | } | ||
341 | |||
342 | static void gen_clrex(DisasContext *s, uint32_t insn) | ||
343 | @@ -XXX,XX +XXX,XX @@ static void disas_system(DisasContext *s, uint32_t insn) | ||
344 | return; | ||
345 | } | ||
346 | switch (crn) { | ||
347 | - case 2: /* HINT (including allocated hints like NOP, YIELD, etc) */ | ||
348 | - handle_hint(s, insn, op1, op2, crm); | ||
349 | - break; | ||
350 | case 3: /* CLREX, DSB, DMB, ISB */ | ||
351 | handle_sync(s, insn, op1, op2, crm); | ||
352 | break; | ||
30 | -- | 353 | -- |
31 | 2.25.1 | 354 | 2.34.1 |
32 | |||
33 | diff view generated by jsdifflib |
1 | A lot of C files in hw/arm include qemu-common.h when they don't | 1 | Convert the insns in the "Barriers" instruction class to |
---|---|---|---|
2 | need anything from it. Drop the include lines. | 2 | decodetree: CLREX, DSB, DMB, ISB and SB. |
3 | |||
4 | omap1.c, pxa2xx.c and strongarm.c retain the include because they | ||
5 | use it for the prototype of qemu_get_timedate(). | ||
6 | 3 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Message-id: 20230602155223.2040685-4-peter.maydell@linaro.org |
10 | Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Reviewed-by: Yoshinori Sato <ysato@users.sourceforge.jp> | ||
12 | Message-id: 20211129200510.1233037-5-peter.maydell@linaro.org | ||
13 | --- | 8 | --- |
14 | hw/arm/boot.c | 1 - | 9 | target/arm/tcg/a64.decode | 7 +++ |
15 | hw/arm/digic_boards.c | 1 - | 10 | target/arm/tcg/translate-a64.c | 92 ++++++++++++++-------------------- |
16 | hw/arm/highbank.c | 1 - | 11 | 2 files changed, 46 insertions(+), 53 deletions(-) |
17 | hw/arm/npcm7xx_boards.c | 1 - | ||
18 | hw/arm/sbsa-ref.c | 1 - | ||
19 | hw/arm/stm32f405_soc.c | 1 - | ||
20 | hw/arm/vexpress.c | 1 - | ||
21 | hw/arm/virt.c | 1 - | ||
22 | 8 files changed, 8 deletions(-) | ||
23 | 12 | ||
24 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 13 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
25 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/arm/boot.c | 15 | --- a/target/arm/tcg/a64.decode |
27 | +++ b/hw/arm/boot.c | 16 | +++ b/target/arm/tcg/a64.decode |
28 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ ERETA 1101011 0100 11111 00001 m:1 11111 11111 &reta # ERETAA, ERETAB |
29 | */ | 18 | # that isn't specifically allocated to an instruction must NOP |
30 | 19 | NOP 1101 0101 0000 0011 0010 ---- --- 11111 | |
31 | #include "qemu/osdep.h" | 20 | } |
32 | -#include "qemu-common.h" | 21 | + |
33 | #include "qemu/datadir.h" | 22 | +# Barriers |
34 | #include "qemu/error-report.h" | 23 | + |
35 | #include "qapi/error.h" | 24 | +CLREX 1101 0101 0000 0011 0011 ---- 010 11111 |
36 | diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c | 25 | +DSB_DMB 1101 0101 0000 0011 0011 domain:2 types:2 10- 11111 |
26 | +ISB 1101 0101 0000 0011 0011 ---- 110 11111 | ||
27 | +SB 1101 0101 0000 0011 0011 0000 111 11111 | ||
28 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/arm/digic_boards.c | 30 | --- a/target/arm/tcg/translate-a64.c |
39 | +++ b/hw/arm/digic_boards.c | 31 | +++ b/target/arm/tcg/translate-a64.c |
40 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ static bool trans_AUTIBSP(DisasContext *s, arg_AUTIBSP *a) |
41 | 33 | return true; | |
42 | #include "qemu/osdep.h" | 34 | } |
43 | #include "qapi/error.h" | 35 | |
44 | -#include "qemu-common.h" | 36 | -static void gen_clrex(DisasContext *s, uint32_t insn) |
45 | #include "qemu/datadir.h" | 37 | +static bool trans_CLREX(DisasContext *s, arg_CLREX *a) |
46 | #include "hw/boards.h" | 38 | { |
47 | #include "qemu/error-report.h" | 39 | tcg_gen_movi_i64(cpu_exclusive_addr, -1); |
48 | diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c | 40 | + return true; |
49 | index XXXXXXX..XXXXXXX 100644 | 41 | } |
50 | --- a/hw/arm/highbank.c | 42 | |
51 | +++ b/hw/arm/highbank.c | 43 | -/* CLREX, DSB, DMB, ISB */ |
52 | @@ -XXX,XX +XXX,XX @@ | 44 | -static void handle_sync(DisasContext *s, uint32_t insn, |
53 | */ | 45 | - unsigned int op1, unsigned int op2, unsigned int crm) |
54 | 46 | +static bool trans_DSB_DMB(DisasContext *s, arg_DSB_DMB *a) | |
55 | #include "qemu/osdep.h" | 47 | { |
56 | -#include "qemu-common.h" | 48 | + /* We handle DSB and DMB the same way */ |
57 | #include "qemu/datadir.h" | 49 | TCGBar bar; |
58 | #include "qapi/error.h" | 50 | |
59 | #include "hw/sysbus.h" | 51 | - if (op1 != 3) { |
60 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c | 52 | - unallocated_encoding(s); |
61 | index XXXXXXX..XXXXXXX 100644 | 53 | - return; |
62 | --- a/hw/arm/npcm7xx_boards.c | 54 | + switch (a->types) { |
63 | +++ b/hw/arm/npcm7xx_boards.c | 55 | + case 1: /* MBReqTypes_Reads */ |
64 | @@ -XXX,XX +XXX,XX @@ | 56 | + bar = TCG_BAR_SC | TCG_MO_LD_LD | TCG_MO_LD_ST; |
65 | #include "hw/qdev-core.h" | 57 | + break; |
66 | #include "hw/qdev-properties.h" | 58 | + case 2: /* MBReqTypes_Writes */ |
67 | #include "qapi/error.h" | 59 | + bar = TCG_BAR_SC | TCG_MO_ST_ST; |
68 | -#include "qemu-common.h" | 60 | + break; |
69 | #include "qemu/datadir.h" | 61 | + default: /* MBReqTypes_All */ |
70 | #include "qemu/units.h" | 62 | + bar = TCG_BAR_SC | TCG_MO_ALL; |
71 | #include "sysemu/blockdev.h" | 63 | + break; |
72 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | 64 | } |
73 | index XXXXXXX..XXXXXXX 100644 | 65 | + tcg_gen_mb(bar); |
74 | --- a/hw/arm/sbsa-ref.c | 66 | + return true; |
75 | +++ b/hw/arm/sbsa-ref.c | 67 | +} |
76 | @@ -XXX,XX +XXX,XX @@ | 68 | |
77 | */ | 69 | - switch (op2) { |
78 | 70 | - case 2: /* CLREX */ | |
79 | #include "qemu/osdep.h" | 71 | - gen_clrex(s, insn); |
80 | -#include "qemu-common.h" | 72 | - return; |
81 | #include "qemu/datadir.h" | 73 | - case 4: /* DSB */ |
82 | #include "qapi/error.h" | 74 | - case 5: /* DMB */ |
83 | #include "qemu/error-report.h" | 75 | - switch (crm & 3) { |
84 | diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c | 76 | - case 1: /* MBReqTypes_Reads */ |
85 | index XXXXXXX..XXXXXXX 100644 | 77 | - bar = TCG_BAR_SC | TCG_MO_LD_LD | TCG_MO_LD_ST; |
86 | --- a/hw/arm/stm32f405_soc.c | 78 | - break; |
87 | +++ b/hw/arm/stm32f405_soc.c | 79 | - case 2: /* MBReqTypes_Writes */ |
88 | @@ -XXX,XX +XXX,XX @@ | 80 | - bar = TCG_BAR_SC | TCG_MO_ST_ST; |
89 | 81 | - break; | |
90 | #include "qemu/osdep.h" | 82 | - default: /* MBReqTypes_All */ |
91 | #include "qapi/error.h" | 83 | - bar = TCG_BAR_SC | TCG_MO_ALL; |
92 | -#include "qemu-common.h" | 84 | - break; |
93 | #include "exec/address-spaces.h" | 85 | - } |
94 | #include "sysemu/sysemu.h" | 86 | - tcg_gen_mb(bar); |
95 | #include "hw/arm/stm32f405_soc.h" | 87 | - return; |
96 | diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c | 88 | - case 6: /* ISB */ |
97 | index XXXXXXX..XXXXXXX 100644 | 89 | - /* We need to break the TB after this insn to execute |
98 | --- a/hw/arm/vexpress.c | 90 | - * a self-modified code correctly and also to take |
99 | +++ b/hw/arm/vexpress.c | 91 | - * any pending interrupts immediately. |
100 | @@ -XXX,XX +XXX,XX @@ | 92 | - */ |
101 | 93 | - reset_btype(s); | |
102 | #include "qemu/osdep.h" | 94 | - gen_goto_tb(s, 0, 4); |
103 | #include "qapi/error.h" | 95 | - return; |
104 | -#include "qemu-common.h" | 96 | +static bool trans_ISB(DisasContext *s, arg_ISB *a) |
105 | #include "qemu/datadir.h" | 97 | +{ |
106 | #include "cpu.h" | 98 | + /* |
107 | #include "hw/sysbus.h" | 99 | + * We need to break the TB after this insn to execute |
108 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 100 | + * self-modifying code correctly and also to take |
109 | index XXXXXXX..XXXXXXX 100644 | 101 | + * any pending interrupts immediately. |
110 | --- a/hw/arm/virt.c | 102 | + */ |
111 | +++ b/hw/arm/virt.c | 103 | + reset_btype(s); |
112 | @@ -XXX,XX +XXX,XX @@ | 104 | + gen_goto_tb(s, 0, 4); |
113 | */ | 105 | + return true; |
114 | 106 | +} | |
115 | #include "qemu/osdep.h" | 107 | |
116 | -#include "qemu-common.h" | 108 | - case 7: /* SB */ |
117 | #include "qemu/datadir.h" | 109 | - if (crm != 0 || !dc_isar_feature(aa64_sb, s)) { |
118 | #include "qemu/units.h" | 110 | - goto do_unallocated; |
119 | #include "qemu/option.h" | 111 | - } |
112 | - /* | ||
113 | - * TODO: There is no speculation barrier opcode for TCG; | ||
114 | - * MB and end the TB instead. | ||
115 | - */ | ||
116 | - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
117 | - gen_goto_tb(s, 0, 4); | ||
118 | - return; | ||
119 | - | ||
120 | - default: | ||
121 | - do_unallocated: | ||
122 | - unallocated_encoding(s); | ||
123 | - return; | ||
124 | +static bool trans_SB(DisasContext *s, arg_SB *a) | ||
125 | +{ | ||
126 | + if (!dc_isar_feature(aa64_sb, s)) { | ||
127 | + return false; | ||
128 | } | ||
129 | + /* | ||
130 | + * TODO: There is no speculation barrier opcode for TCG; | ||
131 | + * MB and end the TB instead. | ||
132 | + */ | ||
133 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
134 | + gen_goto_tb(s, 0, 4); | ||
135 | + return true; | ||
136 | } | ||
137 | |||
138 | static void gen_xaflag(void) | ||
139 | @@ -XXX,XX +XXX,XX @@ static void disas_system(DisasContext *s, uint32_t insn) | ||
140 | return; | ||
141 | } | ||
142 | switch (crn) { | ||
143 | - case 3: /* CLREX, DSB, DMB, ISB */ | ||
144 | - handle_sync(s, insn, op1, op2, crm); | ||
145 | - break; | ||
146 | case 4: /* MSR (immediate) */ | ||
147 | handle_msr_i(s, insn, op1, op2, crm); | ||
148 | break; | ||
120 | -- | 149 | -- |
121 | 2.25.1 | 150 | 2.34.1 |
122 | 151 | ||
123 | 152 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Convert the CFINV, XAFLAG and AXFLAG insns to decodetree. |
---|---|---|---|
2 | The old decoder handles these in handle_msr_i(), but | ||
3 | the architecture defines them as separate instructions | ||
4 | from MSR (immediate). | ||
2 | 5 | ||
3 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20230602155223.2040685-5-peter.maydell@linaro.org | ||
6 | --- | 9 | --- |
7 | tests/tcg/aarch64/pcalign-a64.c | 37 +++++++++++++++++++++++++ | 10 | target/arm/tcg/a64.decode | 6 ++++ |
8 | tests/tcg/arm/pcalign-a32.c | 46 +++++++++++++++++++++++++++++++ | 11 | target/arm/tcg/translate-a64.c | 53 +++++++++++++++++----------------- |
9 | tests/tcg/aarch64/Makefile.target | 4 +-- | 12 | 2 files changed, 32 insertions(+), 27 deletions(-) |
10 | tests/tcg/arm/Makefile.target | 4 +++ | ||
11 | 4 files changed, 89 insertions(+), 2 deletions(-) | ||
12 | create mode 100644 tests/tcg/aarch64/pcalign-a64.c | ||
13 | create mode 100644 tests/tcg/arm/pcalign-a32.c | ||
14 | 13 | ||
15 | diff --git a/tests/tcg/aarch64/pcalign-a64.c b/tests/tcg/aarch64/pcalign-a64.c | 14 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
16 | new file mode 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | index XXXXXXX..XXXXXXX | 16 | --- a/target/arm/tcg/a64.decode |
18 | --- /dev/null | 17 | +++ b/target/arm/tcg/a64.decode |
19 | +++ b/tests/tcg/aarch64/pcalign-a64.c | 18 | @@ -XXX,XX +XXX,XX @@ CLREX 1101 0101 0000 0011 0011 ---- 010 11111 |
20 | @@ -XXX,XX +XXX,XX @@ | 19 | DSB_DMB 1101 0101 0000 0011 0011 domain:2 types:2 10- 11111 |
21 | +/* Test PC misalignment exception */ | 20 | ISB 1101 0101 0000 0011 0011 ---- 110 11111 |
21 | SB 1101 0101 0000 0011 0011 0000 111 11111 | ||
22 | + | 22 | + |
23 | +#include <assert.h> | 23 | +# PSTATE |
24 | +#include <signal.h> | ||
25 | +#include <stdlib.h> | ||
26 | +#include <stdio.h> | ||
27 | + | 24 | + |
28 | +static void *expected; | 25 | +CFINV 1101 0101 0000 0 000 0100 0000 000 11111 |
29 | + | 26 | +XAFLAG 1101 0101 0000 0 000 0100 0000 001 11111 |
30 | +static void sigbus(int sig, siginfo_t *info, void *vuc) | 27 | +AXFLAG 1101 0101 0000 0 000 0100 0000 010 11111 |
31 | +{ | 28 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c |
32 | + assert(info->si_code == BUS_ADRALN); | 29 | index XXXXXXX..XXXXXXX 100644 |
33 | + assert(info->si_addr == expected); | 30 | --- a/target/arm/tcg/translate-a64.c |
34 | + exit(EXIT_SUCCESS); | 31 | +++ b/target/arm/tcg/translate-a64.c |
32 | @@ -XXX,XX +XXX,XX @@ static bool trans_SB(DisasContext *s, arg_SB *a) | ||
33 | return true; | ||
34 | } | ||
35 | |||
36 | -static void gen_xaflag(void) | ||
37 | +static bool trans_CFINV(DisasContext *s, arg_CFINV *a) | ||
38 | { | ||
39 | - TCGv_i32 z = tcg_temp_new_i32(); | ||
40 | + if (!dc_isar_feature(aa64_condm_4, s)) { | ||
41 | + return false; | ||
42 | + } | ||
43 | + tcg_gen_xori_i32(cpu_CF, cpu_CF, 1); | ||
44 | + return true; | ||
35 | +} | 45 | +} |
36 | + | 46 | + |
37 | +int main() | 47 | +static bool trans_XAFLAG(DisasContext *s, arg_XAFLAG *a) |
38 | +{ | 48 | +{ |
39 | + void *tmp; | 49 | + TCGv_i32 z; |
40 | + | 50 | + |
41 | + struct sigaction sa = { | 51 | + if (!dc_isar_feature(aa64_condm_5, s)) { |
42 | + .sa_sigaction = sigbus, | 52 | + return false; |
43 | + .sa_flags = SA_SIGINFO | ||
44 | + }; | ||
45 | + | ||
46 | + if (sigaction(SIGBUS, &sa, NULL) < 0) { | ||
47 | + perror("sigaction"); | ||
48 | + return EXIT_FAILURE; | ||
49 | + } | 53 | + } |
50 | + | 54 | + |
51 | + asm volatile("adr %0, 1f + 1\n\t" | 55 | + z = tcg_temp_new_i32(); |
52 | + "str %0, %1\n\t" | 56 | |
53 | + "br %0\n" | 57 | tcg_gen_setcondi_i32(TCG_COND_EQ, z, cpu_ZF, 0); |
54 | + "1:" | 58 | |
55 | + : "=&r"(tmp), "=m"(expected)); | 59 | @@ -XXX,XX +XXX,XX @@ static void gen_xaflag(void) |
56 | + abort(); | 60 | |
57 | +} | 61 | /* C | Z */ |
58 | diff --git a/tests/tcg/arm/pcalign-a32.c b/tests/tcg/arm/pcalign-a32.c | 62 | tcg_gen_or_i32(cpu_CF, cpu_CF, z); |
59 | new file mode 100644 | ||
60 | index XXXXXXX..XXXXXXX | ||
61 | --- /dev/null | ||
62 | +++ b/tests/tcg/arm/pcalign-a32.c | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | +/* Test PC misalignment exception */ | ||
65 | + | 63 | + |
66 | +#ifdef __thumb__ | 64 | + return true; |
67 | +#error "This test must be compiled for ARM" | 65 | } |
68 | +#endif | 66 | |
69 | + | 67 | -static void gen_axflag(void) |
70 | +#include <assert.h> | 68 | +static bool trans_AXFLAG(DisasContext *s, arg_AXFLAG *a) |
71 | +#include <signal.h> | 69 | { |
72 | +#include <stdlib.h> | 70 | + if (!dc_isar_feature(aa64_condm_5, s)) { |
73 | +#include <stdio.h> | 71 | + return false; |
74 | + | ||
75 | +static void *expected; | ||
76 | + | ||
77 | +static void sigbus(int sig, siginfo_t *info, void *vuc) | ||
78 | +{ | ||
79 | + assert(info->si_code == BUS_ADRALN); | ||
80 | + assert(info->si_addr == expected); | ||
81 | + exit(EXIT_SUCCESS); | ||
82 | +} | ||
83 | + | ||
84 | +int main() | ||
85 | +{ | ||
86 | + void *tmp; | ||
87 | + | ||
88 | + struct sigaction sa = { | ||
89 | + .sa_sigaction = sigbus, | ||
90 | + .sa_flags = SA_SIGINFO | ||
91 | + }; | ||
92 | + | ||
93 | + if (sigaction(SIGBUS, &sa, NULL) < 0) { | ||
94 | + perror("sigaction"); | ||
95 | + return EXIT_FAILURE; | ||
96 | + } | 72 | + } |
97 | + | 73 | + |
98 | + asm volatile("adr %0, 1f + 2\n\t" | 74 | tcg_gen_sari_i32(cpu_VF, cpu_VF, 31); /* V ? -1 : 0 */ |
99 | + "str %0, %1\n\t" | 75 | tcg_gen_andc_i32(cpu_CF, cpu_CF, cpu_VF); /* C & !V */ |
100 | + "bx %0\n" | 76 | |
101 | + "1:" | 77 | @@ -XXX,XX +XXX,XX @@ static void gen_axflag(void) |
102 | + : "=&r"(tmp), "=m"(expected)); | 78 | |
79 | tcg_gen_movi_i32(cpu_NF, 0); | ||
80 | tcg_gen_movi_i32(cpu_VF, 0); | ||
103 | + | 81 | + |
104 | + /* | 82 | + return true; |
105 | + * From v8, it is CONSTRAINED UNPREDICTABLE whether BXWritePC aligns | 83 | } |
106 | + * the address or not. If so, we can legitimately fall through. | 84 | |
107 | + */ | 85 | /* MSR (immediate) - move immediate to processor state field */ |
108 | + return EXIT_SUCCESS; | 86 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, |
109 | +} | 87 | s->base.is_jmp = DISAS_TOO_MANY; |
110 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | 88 | |
111 | index XXXXXXX..XXXXXXX 100644 | 89 | switch (op) { |
112 | --- a/tests/tcg/aarch64/Makefile.target | 90 | - case 0x00: /* CFINV */ |
113 | +++ b/tests/tcg/aarch64/Makefile.target | 91 | - if (crm != 0 || !dc_isar_feature(aa64_condm_4, s)) { |
114 | @@ -XXX,XX +XXX,XX @@ VPATH += $(ARM_SRC) | 92 | - goto do_unallocated; |
115 | AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64 | 93 | - } |
116 | VPATH += $(AARCH64_SRC) | 94 | - tcg_gen_xori_i32(cpu_CF, cpu_CF, 1); |
117 | 95 | - s->base.is_jmp = DISAS_NEXT; | |
118 | -# Float-convert Tests | 96 | - break; |
119 | -AARCH64_TESTS=fcvt | 97 | - |
120 | +# Base architecture tests | 98 | - case 0x01: /* XAFlag */ |
121 | +AARCH64_TESTS=fcvt pcalign-a64 | 99 | - if (crm != 0 || !dc_isar_feature(aa64_condm_5, s)) { |
122 | 100 | - goto do_unallocated; | |
123 | fcvt: LDFLAGS+=-lm | 101 | - } |
124 | 102 | - gen_xaflag(); | |
125 | diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target | 103 | - s->base.is_jmp = DISAS_NEXT; |
126 | index XXXXXXX..XXXXXXX 100644 | 104 | - break; |
127 | --- a/tests/tcg/arm/Makefile.target | 105 | - |
128 | +++ b/tests/tcg/arm/Makefile.target | 106 | - case 0x02: /* AXFlag */ |
129 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt | 107 | - if (crm != 0 || !dc_isar_feature(aa64_condm_5, s)) { |
130 | $(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") | 108 | - goto do_unallocated; |
131 | $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) | 109 | - } |
132 | 110 | - gen_axflag(); | |
133 | +# PC alignment test | 111 | - s->base.is_jmp = DISAS_NEXT; |
134 | +ARM_TESTS += pcalign-a32 | 112 | - break; |
135 | +pcalign-a32: CFLAGS+=-marm | 113 | - |
136 | + | 114 | case 0x03: /* UAO */ |
137 | ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y) | 115 | if (!dc_isar_feature(aa64_uao, s) || s->current_el == 0) { |
138 | 116 | goto do_unallocated; | |
139 | # Semihosting smoke test for linux-user | ||
140 | -- | 117 | -- |
141 | 2.25.1 | 118 | 2.34.1 |
142 | |||
143 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | Convert the MSR (immediate) insn to decodetree. Our implementation |
---|---|---|---|
2 | has basically no commonality between the different destinations, | ||
3 | so we decode the destination register in a64.decode. | ||
2 | 4 | ||
3 | virtio-iommu is now supported with ACPI VIOT as well as device tree. | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Remove the restriction that prevents from instantiating a virtio-iommu | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | device under ACPI. | 7 | Message-id: 20230602155223.2040685-6-peter.maydell@linaro.org |
8 | --- | ||
9 | target/arm/tcg/a64.decode | 13 ++ | ||
10 | target/arm/tcg/translate-a64.c | 251 ++++++++++++++++----------------- | ||
11 | 2 files changed, 136 insertions(+), 128 deletions(-) | ||
6 | 12 | ||
7 | Acked-by: Igor Mammedov <imammedo@redhat.com> | 13 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
9 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
10 | Message-id: 20211210170415.583179-3-jean-philippe@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/arm/virt.c | 10 ++-------- | ||
14 | hw/virtio/virtio-iommu-pci.c | 12 ++---------- | ||
15 | 2 files changed, 4 insertions(+), 18 deletions(-) | ||
16 | |||
17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/virt.c | 15 | --- a/target/arm/tcg/a64.decode |
20 | +++ b/hw/arm/virt.c | 16 | +++ b/target/arm/tcg/a64.decode |
21 | @@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, | 17 | @@ -XXX,XX +XXX,XX @@ SB 1101 0101 0000 0011 0011 0000 111 11111 |
22 | MachineClass *mc = MACHINE_GET_CLASS(machine); | 18 | CFINV 1101 0101 0000 0 000 0100 0000 000 11111 |
23 | 19 | XAFLAG 1101 0101 0000 0 000 0100 0000 001 11111 | |
24 | if (device_is_dynamic_sysbus(mc, dev) || | 20 | AXFLAG 1101 0101 0000 0 000 0100 0000 010 11111 |
25 | - (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { | 21 | + |
26 | + object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) || | 22 | +# These are architecturally all "MSR (immediate)"; we decode the destination |
27 | + object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { | 23 | +# register too because there is no commonality in our implementation. |
28 | return HOTPLUG_HANDLER(machine); | 24 | +@msr_i .... .... .... . ... .... imm:4 ... ..... |
25 | +MSR_i_UAO 1101 0101 0000 0 000 0100 .... 011 11111 @msr_i | ||
26 | +MSR_i_PAN 1101 0101 0000 0 000 0100 .... 100 11111 @msr_i | ||
27 | +MSR_i_SPSEL 1101 0101 0000 0 000 0100 .... 101 11111 @msr_i | ||
28 | +MSR_i_SBSS 1101 0101 0000 0 011 0100 .... 001 11111 @msr_i | ||
29 | +MSR_i_DIT 1101 0101 0000 0 011 0100 .... 010 11111 @msr_i | ||
30 | +MSR_i_TCO 1101 0101 0000 0 011 0100 .... 100 11111 @msr_i | ||
31 | +MSR_i_DAIFSET 1101 0101 0000 0 011 0100 .... 110 11111 @msr_i | ||
32 | +MSR_i_DAIFCLEAR 1101 0101 0000 0 011 0100 .... 111 11111 @msr_i | ||
33 | +MSR_i_SVCR 1101 0101 0000 0 011 0100 0 mask:2 imm:1 011 11111 | ||
34 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/target/arm/tcg/translate-a64.c | ||
37 | +++ b/target/arm/tcg/translate-a64.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static bool trans_AXFLAG(DisasContext *s, arg_AXFLAG *a) | ||
39 | return true; | ||
40 | } | ||
41 | |||
42 | -/* MSR (immediate) - move immediate to processor state field */ | ||
43 | -static void handle_msr_i(DisasContext *s, uint32_t insn, | ||
44 | - unsigned int op1, unsigned int op2, unsigned int crm) | ||
45 | +static bool trans_MSR_i_UAO(DisasContext *s, arg_i *a) | ||
46 | { | ||
47 | - int op = op1 << 3 | op2; | ||
48 | - | ||
49 | - /* End the TB by default, chaining is ok. */ | ||
50 | - s->base.is_jmp = DISAS_TOO_MANY; | ||
51 | - | ||
52 | - switch (op) { | ||
53 | - case 0x03: /* UAO */ | ||
54 | - if (!dc_isar_feature(aa64_uao, s) || s->current_el == 0) { | ||
55 | - goto do_unallocated; | ||
56 | - } | ||
57 | - if (crm & 1) { | ||
58 | - set_pstate_bits(PSTATE_UAO); | ||
59 | - } else { | ||
60 | - clear_pstate_bits(PSTATE_UAO); | ||
61 | - } | ||
62 | - gen_rebuild_hflags(s); | ||
63 | - break; | ||
64 | - | ||
65 | - case 0x04: /* PAN */ | ||
66 | - if (!dc_isar_feature(aa64_pan, s) || s->current_el == 0) { | ||
67 | - goto do_unallocated; | ||
68 | - } | ||
69 | - if (crm & 1) { | ||
70 | - set_pstate_bits(PSTATE_PAN); | ||
71 | - } else { | ||
72 | - clear_pstate_bits(PSTATE_PAN); | ||
73 | - } | ||
74 | - gen_rebuild_hflags(s); | ||
75 | - break; | ||
76 | - | ||
77 | - case 0x05: /* SPSel */ | ||
78 | - if (s->current_el == 0) { | ||
79 | - goto do_unallocated; | ||
80 | - } | ||
81 | - gen_helper_msr_i_spsel(cpu_env, tcg_constant_i32(crm & PSTATE_SP)); | ||
82 | - break; | ||
83 | - | ||
84 | - case 0x19: /* SSBS */ | ||
85 | - if (!dc_isar_feature(aa64_ssbs, s)) { | ||
86 | - goto do_unallocated; | ||
87 | - } | ||
88 | - if (crm & 1) { | ||
89 | - set_pstate_bits(PSTATE_SSBS); | ||
90 | - } else { | ||
91 | - clear_pstate_bits(PSTATE_SSBS); | ||
92 | - } | ||
93 | - /* Don't need to rebuild hflags since SSBS is a nop */ | ||
94 | - break; | ||
95 | - | ||
96 | - case 0x1a: /* DIT */ | ||
97 | - if (!dc_isar_feature(aa64_dit, s)) { | ||
98 | - goto do_unallocated; | ||
99 | - } | ||
100 | - if (crm & 1) { | ||
101 | - set_pstate_bits(PSTATE_DIT); | ||
102 | - } else { | ||
103 | - clear_pstate_bits(PSTATE_DIT); | ||
104 | - } | ||
105 | - /* There's no need to rebuild hflags because DIT is a nop */ | ||
106 | - break; | ||
107 | - | ||
108 | - case 0x1e: /* DAIFSet */ | ||
109 | - gen_helper_msr_i_daifset(cpu_env, tcg_constant_i32(crm)); | ||
110 | - break; | ||
111 | - | ||
112 | - case 0x1f: /* DAIFClear */ | ||
113 | - gen_helper_msr_i_daifclear(cpu_env, tcg_constant_i32(crm)); | ||
114 | - /* For DAIFClear, exit the cpu loop to re-evaluate pending IRQs. */ | ||
115 | - s->base.is_jmp = DISAS_UPDATE_EXIT; | ||
116 | - break; | ||
117 | - | ||
118 | - case 0x1c: /* TCO */ | ||
119 | - if (dc_isar_feature(aa64_mte, s)) { | ||
120 | - /* Full MTE is enabled -- set the TCO bit as directed. */ | ||
121 | - if (crm & 1) { | ||
122 | - set_pstate_bits(PSTATE_TCO); | ||
123 | - } else { | ||
124 | - clear_pstate_bits(PSTATE_TCO); | ||
125 | - } | ||
126 | - gen_rebuild_hflags(s); | ||
127 | - /* Many factors, including TCO, go into MTE_ACTIVE. */ | ||
128 | - s->base.is_jmp = DISAS_UPDATE_NOCHAIN; | ||
129 | - } else if (dc_isar_feature(aa64_mte_insn_reg, s)) { | ||
130 | - /* Only "instructions accessible at EL0" -- PSTATE.TCO is WI. */ | ||
131 | - s->base.is_jmp = DISAS_NEXT; | ||
132 | - } else { | ||
133 | - goto do_unallocated; | ||
134 | - } | ||
135 | - break; | ||
136 | - | ||
137 | - case 0x1b: /* SVCR* */ | ||
138 | - if (!dc_isar_feature(aa64_sme, s) || crm < 2 || crm > 7) { | ||
139 | - goto do_unallocated; | ||
140 | - } | ||
141 | - if (sme_access_check(s)) { | ||
142 | - int old = s->pstate_sm | (s->pstate_za << 1); | ||
143 | - int new = (crm & 1) * 3; | ||
144 | - int msk = (crm >> 1) & 3; | ||
145 | - | ||
146 | - if ((old ^ new) & msk) { | ||
147 | - /* At least one bit changes. */ | ||
148 | - gen_helper_set_svcr(cpu_env, tcg_constant_i32(new), | ||
149 | - tcg_constant_i32(msk)); | ||
150 | - } else { | ||
151 | - s->base.is_jmp = DISAS_NEXT; | ||
152 | - } | ||
153 | - } | ||
154 | - break; | ||
155 | - | ||
156 | - default: | ||
157 | - do_unallocated: | ||
158 | - unallocated_encoding(s); | ||
159 | - return; | ||
160 | + if (!dc_isar_feature(aa64_uao, s) || s->current_el == 0) { | ||
161 | + return false; | ||
29 | } | 162 | } |
30 | - if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) { | 163 | + if (a->imm & 1) { |
31 | - VirtMachineState *vms = VIRT_MACHINE(machine); | 164 | + set_pstate_bits(PSTATE_UAO); |
32 | - | 165 | + } else { |
33 | - if (!vms->bootinfo.firmware_loaded || !virt_is_acpi_enabled(vms)) { | 166 | + clear_pstate_bits(PSTATE_UAO); |
34 | - return HOTPLUG_HANDLER(machine); | 167 | + } |
35 | - } | 168 | + gen_rebuild_hflags(s); |
36 | - } | 169 | + s->base.is_jmp = DISAS_TOO_MANY; |
37 | return NULL; | 170 | + return true; |
171 | +} | ||
172 | + | ||
173 | +static bool trans_MSR_i_PAN(DisasContext *s, arg_i *a) | ||
174 | +{ | ||
175 | + if (!dc_isar_feature(aa64_pan, s) || s->current_el == 0) { | ||
176 | + return false; | ||
177 | + } | ||
178 | + if (a->imm & 1) { | ||
179 | + set_pstate_bits(PSTATE_PAN); | ||
180 | + } else { | ||
181 | + clear_pstate_bits(PSTATE_PAN); | ||
182 | + } | ||
183 | + gen_rebuild_hflags(s); | ||
184 | + s->base.is_jmp = DISAS_TOO_MANY; | ||
185 | + return true; | ||
186 | +} | ||
187 | + | ||
188 | +static bool trans_MSR_i_SPSEL(DisasContext *s, arg_i *a) | ||
189 | +{ | ||
190 | + if (s->current_el == 0) { | ||
191 | + return false; | ||
192 | + } | ||
193 | + gen_helper_msr_i_spsel(cpu_env, tcg_constant_i32(a->imm & PSTATE_SP)); | ||
194 | + s->base.is_jmp = DISAS_TOO_MANY; | ||
195 | + return true; | ||
196 | +} | ||
197 | + | ||
198 | +static bool trans_MSR_i_SBSS(DisasContext *s, arg_i *a) | ||
199 | +{ | ||
200 | + if (!dc_isar_feature(aa64_ssbs, s)) { | ||
201 | + return false; | ||
202 | + } | ||
203 | + if (a->imm & 1) { | ||
204 | + set_pstate_bits(PSTATE_SSBS); | ||
205 | + } else { | ||
206 | + clear_pstate_bits(PSTATE_SSBS); | ||
207 | + } | ||
208 | + /* Don't need to rebuild hflags since SSBS is a nop */ | ||
209 | + s->base.is_jmp = DISAS_TOO_MANY; | ||
210 | + return true; | ||
211 | +} | ||
212 | + | ||
213 | +static bool trans_MSR_i_DIT(DisasContext *s, arg_i *a) | ||
214 | +{ | ||
215 | + if (!dc_isar_feature(aa64_dit, s)) { | ||
216 | + return false; | ||
217 | + } | ||
218 | + if (a->imm & 1) { | ||
219 | + set_pstate_bits(PSTATE_DIT); | ||
220 | + } else { | ||
221 | + clear_pstate_bits(PSTATE_DIT); | ||
222 | + } | ||
223 | + /* There's no need to rebuild hflags because DIT is a nop */ | ||
224 | + s->base.is_jmp = DISAS_TOO_MANY; | ||
225 | + return true; | ||
226 | +} | ||
227 | + | ||
228 | +static bool trans_MSR_i_TCO(DisasContext *s, arg_i *a) | ||
229 | +{ | ||
230 | + if (dc_isar_feature(aa64_mte, s)) { | ||
231 | + /* Full MTE is enabled -- set the TCO bit as directed. */ | ||
232 | + if (a->imm & 1) { | ||
233 | + set_pstate_bits(PSTATE_TCO); | ||
234 | + } else { | ||
235 | + clear_pstate_bits(PSTATE_TCO); | ||
236 | + } | ||
237 | + gen_rebuild_hflags(s); | ||
238 | + /* Many factors, including TCO, go into MTE_ACTIVE. */ | ||
239 | + s->base.is_jmp = DISAS_UPDATE_NOCHAIN; | ||
240 | + return true; | ||
241 | + } else if (dc_isar_feature(aa64_mte_insn_reg, s)) { | ||
242 | + /* Only "instructions accessible at EL0" -- PSTATE.TCO is WI. */ | ||
243 | + return true; | ||
244 | + } else { | ||
245 | + /* Insn not present */ | ||
246 | + return false; | ||
247 | + } | ||
248 | +} | ||
249 | + | ||
250 | +static bool trans_MSR_i_DAIFSET(DisasContext *s, arg_i *a) | ||
251 | +{ | ||
252 | + gen_helper_msr_i_daifset(cpu_env, tcg_constant_i32(a->imm)); | ||
253 | + s->base.is_jmp = DISAS_TOO_MANY; | ||
254 | + return true; | ||
255 | +} | ||
256 | + | ||
257 | +static bool trans_MSR_i_DAIFCLEAR(DisasContext *s, arg_i *a) | ||
258 | +{ | ||
259 | + gen_helper_msr_i_daifclear(cpu_env, tcg_constant_i32(a->imm)); | ||
260 | + /* Exit the cpu loop to re-evaluate pending IRQs. */ | ||
261 | + s->base.is_jmp = DISAS_UPDATE_EXIT; | ||
262 | + return true; | ||
263 | +} | ||
264 | + | ||
265 | +static bool trans_MSR_i_SVCR(DisasContext *s, arg_MSR_i_SVCR *a) | ||
266 | +{ | ||
267 | + if (!dc_isar_feature(aa64_sme, s) || a->mask == 0) { | ||
268 | + return false; | ||
269 | + } | ||
270 | + if (sme_access_check(s)) { | ||
271 | + int old = s->pstate_sm | (s->pstate_za << 1); | ||
272 | + int new = a->imm * 3; | ||
273 | + | ||
274 | + if ((old ^ new) & a->mask) { | ||
275 | + /* At least one bit changes. */ | ||
276 | + gen_helper_set_svcr(cpu_env, tcg_constant_i32(new), | ||
277 | + tcg_constant_i32(a->mask)); | ||
278 | + s->base.is_jmp = DISAS_TOO_MANY; | ||
279 | + } | ||
280 | + } | ||
281 | + return true; | ||
38 | } | 282 | } |
39 | 283 | ||
40 | diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c | 284 | static void gen_get_nzcv(TCGv_i64 tcg_rt) |
41 | index XXXXXXX..XXXXXXX 100644 | 285 | @@ -XXX,XX +XXX,XX @@ static void disas_system(DisasContext *s, uint32_t insn) |
42 | --- a/hw/virtio/virtio-iommu-pci.c | 286 | rt = extract32(insn, 0, 5); |
43 | +++ b/hw/virtio/virtio-iommu-pci.c | 287 | |
44 | @@ -XXX,XX +XXX,XX @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) | 288 | if (op0 == 0) { |
45 | VirtIOIOMMU *s = VIRTIO_IOMMU(vdev); | 289 | - if (l || rt != 31) { |
46 | 290 | - unallocated_encoding(s); | |
47 | if (!qdev_get_machine_hotplug_handler(DEVICE(vpci_dev))) { | 291 | - return; |
48 | - MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); | 292 | - } |
49 | - | 293 | - switch (crn) { |
50 | - error_setg(errp, | 294 | - case 4: /* MSR (immediate) */ |
51 | - "%s machine fails to create iommu-map device tree bindings", | 295 | - handle_msr_i(s, insn, op1, op2, crm); |
52 | - mc->name); | 296 | - break; |
53 | - error_append_hint(errp, | 297 | - default: |
54 | - "Check your machine implements a hotplug handler " | 298 | - unallocated_encoding(s); |
55 | - "for the virtio-iommu-pci device\n"); | 299 | - break; |
56 | - error_append_hint(errp, "Check the guest is booted without FW or with " | 300 | - } |
57 | - "-no-acpi\n"); | 301 | + unallocated_encoding(s); |
58 | + error_setg(errp, "Check your machine implements a hotplug handler " | ||
59 | + "for the virtio-iommu-pci device"); | ||
60 | return; | 302 | return; |
61 | } | 303 | } |
62 | for (int i = 0; i < s->nb_reserved_regions; i++) { | 304 | handle_sys(s, insn, l, op0, op1, op2, crn, crm, rt); |
63 | -- | 305 | -- |
64 | 2.25.1 | 306 | 2.34.1 |
65 | |||
66 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | Convert MSR (reg), MRS, SYS, SYSL to decodetree. For QEMU these are |
---|---|---|---|
2 | all essentially the same instruction (system register access). | ||
2 | 3 | ||
3 | To propagate errors to the caller of the pre_plug callback, use the | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | object_poperty_set*() functions directly instead of the qdev_prop_set*() | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | helpers. | 6 | Message-id: 20230602155223.2040685-7-peter.maydell@linaro.org |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | --- | ||
9 | target/arm/tcg/a64.decode | 8 ++++++++ | ||
10 | target/arm/tcg/translate-a64.c | 32 +++++--------------------------- | ||
11 | 2 files changed, 13 insertions(+), 27 deletions(-) | ||
6 | 12 | ||
7 | Suggested-by: Igor Mammedov <imammedo@redhat.com> | 13 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
9 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
11 | Message-id: 20211210170415.583179-5-jean-philippe@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/arm/virt.c | 5 +++-- | ||
15 | 1 file changed, 3 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/virt.c | 15 | --- a/target/arm/tcg/a64.decode |
20 | +++ b/hw/arm/virt.c | 16 | +++ b/target/arm/tcg/a64.decode |
21 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, | 17 | @@ -XXX,XX +XXX,XX @@ MSR_i_TCO 1101 0101 0000 0 011 0100 .... 100 11111 @msr_i |
22 | db_start, db_end, | 18 | MSR_i_DAIFSET 1101 0101 0000 0 011 0100 .... 110 11111 @msr_i |
23 | VIRTIO_IOMMU_RESV_MEM_T_MSI); | 19 | MSR_i_DAIFCLEAR 1101 0101 0000 0 011 0100 .... 111 11111 @msr_i |
24 | 20 | MSR_i_SVCR 1101 0101 0000 0 011 0100 0 mask:2 imm:1 011 11111 | |
25 | - qdev_prop_set_uint32(dev, "len-reserved-regions", 1); | 21 | + |
26 | - qdev_prop_set_string(dev, "reserved-regions[0]", resv_prop_str); | 22 | +# MRS, MSR (register), SYS, SYSL. These are all essentially the |
27 | + object_property_set_uint(OBJECT(dev), "len-reserved-regions", 1, errp); | 23 | +# same instruction as far as QEMU is concerned. |
28 | + object_property_set_str(OBJECT(dev), "reserved-regions[0]", | 24 | +# NB: op0 is bits [20:19], but op0=0b00 is other insns, so we have |
29 | + resv_prop_str, errp); | 25 | +# to hand-decode it. |
30 | g_free(resv_prop_str); | 26 | +SYS 1101 0101 00 l:1 01 op1:3 crn:4 crm:4 op2:3 rt:5 op0=1 |
27 | +SYS 1101 0101 00 l:1 10 op1:3 crn:4 crm:4 op2:3 rt:5 op0=2 | ||
28 | +SYS 1101 0101 00 l:1 11 op1:3 crn:4 crm:4 op2:3 rt:5 op0=3 | ||
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 void gen_sysreg_undef(DisasContext *s, bool isread, | ||
34 | * These are all essentially the same insn in 'read' and 'write' | ||
35 | * versions, with varying op0 fields. | ||
36 | */ | ||
37 | -static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
38 | +static void handle_sys(DisasContext *s, bool isread, | ||
39 | unsigned int op0, unsigned int op1, unsigned int op2, | ||
40 | unsigned int crn, unsigned int crm, unsigned int rt) | ||
41 | { | ||
42 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
31 | } | 43 | } |
32 | } | 44 | } |
45 | |||
46 | -/* System | ||
47 | - * 31 22 21 20 19 18 16 15 12 11 8 7 5 4 0 | ||
48 | - * +---------------------+---+-----+-----+-------+-------+-----+------+ | ||
49 | - * | 1 1 0 1 0 1 0 1 0 0 | L | op0 | op1 | CRn | CRm | op2 | Rt | | ||
50 | - * +---------------------+---+-----+-----+-------+-------+-----+------+ | ||
51 | - */ | ||
52 | -static void disas_system(DisasContext *s, uint32_t insn) | ||
53 | +static bool trans_SYS(DisasContext *s, arg_SYS *a) | ||
54 | { | ||
55 | - unsigned int l, op0, op1, crn, crm, op2, rt; | ||
56 | - l = extract32(insn, 21, 1); | ||
57 | - op0 = extract32(insn, 19, 2); | ||
58 | - op1 = extract32(insn, 16, 3); | ||
59 | - crn = extract32(insn, 12, 4); | ||
60 | - crm = extract32(insn, 8, 4); | ||
61 | - op2 = extract32(insn, 5, 3); | ||
62 | - rt = extract32(insn, 0, 5); | ||
63 | - | ||
64 | - if (op0 == 0) { | ||
65 | - unallocated_encoding(s); | ||
66 | - return; | ||
67 | - } | ||
68 | - handle_sys(s, insn, l, op0, op1, op2, crn, crm, rt); | ||
69 | + handle_sys(s, a->l, a->op0, a->op1, a->op2, a->crn, a->crm, a->rt); | ||
70 | + return true; | ||
71 | } | ||
72 | |||
73 | /* Exception generation | ||
74 | @@ -XXX,XX +XXX,XX @@ static void disas_b_exc_sys(DisasContext *s, uint32_t insn) | ||
75 | switch (extract32(insn, 25, 7)) { | ||
76 | case 0x6a: /* Exception generation / System */ | ||
77 | if (insn & (1 << 24)) { | ||
78 | - if (extract32(insn, 22, 2) == 0) { | ||
79 | - disas_system(s, insn); | ||
80 | - } else { | ||
81 | - unallocated_encoding(s); | ||
82 | - } | ||
83 | + unallocated_encoding(s); | ||
84 | } else { | ||
85 | disas_exc(s, insn); | ||
86 | } | ||
33 | -- | 87 | -- |
34 | 2.25.1 | 88 | 2.34.1 |
35 | 89 | ||
36 | 90 | diff view generated by jsdifflib |
1 | The qemu-common.h header is not supposed to be included from any | 1 | Convert the exception generation instructions SVC, HVC, SMC, BRK and |
---|---|---|---|
2 | other header files, only from .c files (as documented in a comment at | 2 | HLT to decodetree. |
3 | the start of it). | ||
4 | 3 | ||
5 | Move the include to linux-user/hexagon/cpu_loop.c, which needs it for | 4 | The old decoder decoded the halting-debug insnns DCPS1, DCPS2 and |
6 | the declaration of cpu_exec_step_atomic(). | 5 | DCPS3 just in order to then make them UNDEF; as with DRPS, we don't |
6 | bother to decode them, but document the patterns in a64.decode. | ||
7 | 7 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 10 | Message-id: 20230602155223.2040685-8-peter.maydell@linaro.org |
11 | Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> | ||
12 | Message-id: 20211129200510.1233037-3-peter.maydell@linaro.org | ||
13 | --- | 11 | --- |
14 | target/hexagon/cpu.h | 1 - | 12 | target/arm/tcg/a64.decode | 15 +++ |
15 | linux-user/hexagon/cpu_loop.c | 1 + | 13 | target/arm/tcg/translate-a64.c | 173 ++++++++++++--------------------- |
16 | 2 files changed, 1 insertion(+), 1 deletion(-) | 14 | 2 files changed, 79 insertions(+), 109 deletions(-) |
17 | 15 | ||
18 | diff --git a/target/hexagon/cpu.h b/target/hexagon/cpu.h | 16 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
19 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/hexagon/cpu.h | 18 | --- a/target/arm/tcg/a64.decode |
21 | +++ b/target/hexagon/cpu.h | 19 | +++ b/target/arm/tcg/a64.decode |
22 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUHexagonState CPUHexagonState; | 20 | @@ -XXX,XX +XXX,XX @@ MSR_i_SVCR 1101 0101 0000 0 011 0100 0 mask:2 imm:1 011 11111 |
23 | 21 | SYS 1101 0101 00 l:1 01 op1:3 crn:4 crm:4 op2:3 rt:5 op0=1 | |
24 | #include "fpu/softfloat-types.h" | 22 | SYS 1101 0101 00 l:1 10 op1:3 crn:4 crm:4 op2:3 rt:5 op0=2 |
25 | 23 | SYS 1101 0101 00 l:1 11 op1:3 crn:4 crm:4 op2:3 rt:5 op0=3 | |
26 | -#include "qemu-common.h" | 24 | + |
27 | #include "exec/cpu-defs.h" | 25 | +# Exception generation |
28 | #include "hex_regs.h" | 26 | + |
29 | #include "mmvec/mmvec.h" | 27 | +@i16 .... .... ... imm:16 ... .. &i |
30 | diff --git a/linux-user/hexagon/cpu_loop.c b/linux-user/hexagon/cpu_loop.c | 28 | +SVC 1101 0100 000 ................ 000 01 @i16 |
29 | +HVC 1101 0100 000 ................ 000 10 @i16 | ||
30 | +SMC 1101 0100 000 ................ 000 11 @i16 | ||
31 | +BRK 1101 0100 001 ................ 000 00 @i16 | ||
32 | +HLT 1101 0100 010 ................ 000 00 @i16 | ||
33 | +# These insns always UNDEF unless in halting debug state, which | ||
34 | +# we don't implement. So we don't need to decode them. The patterns | ||
35 | +# are listed here as documentation. | ||
36 | +# DCPS1 1101 0100 101 ................ 000 01 @i16 | ||
37 | +# DCPS2 1101 0100 101 ................ 000 10 @i16 | ||
38 | +# DCPS3 1101 0100 101 ................ 000 11 @i16 | ||
39 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/linux-user/hexagon/cpu_loop.c | 41 | --- a/target/arm/tcg/translate-a64.c |
33 | +++ b/linux-user/hexagon/cpu_loop.c | 42 | +++ b/target/arm/tcg/translate-a64.c |
34 | @@ -XXX,XX +XXX,XX @@ | 43 | @@ -XXX,XX +XXX,XX @@ static bool trans_SYS(DisasContext *s, arg_SYS *a) |
35 | */ | 44 | return true; |
36 | 45 | } | |
37 | #include "qemu/osdep.h" | 46 | |
38 | +#include "qemu-common.h" | 47 | -/* Exception generation |
39 | #include "qemu.h" | 48 | - * |
40 | #include "user-internals.h" | 49 | - * 31 24 23 21 20 5 4 2 1 0 |
41 | #include "cpu_loop-common.h" | 50 | - * +-----------------+-----+------------------------+-----+----+ |
51 | - * | 1 1 0 1 0 1 0 0 | opc | imm16 | op2 | LL | | ||
52 | - * +-----------------------+------------------------+----------+ | ||
53 | - */ | ||
54 | -static void disas_exc(DisasContext *s, uint32_t insn) | ||
55 | +static bool trans_SVC(DisasContext *s, arg_i *a) | ||
56 | { | ||
57 | - int opc = extract32(insn, 21, 3); | ||
58 | - int op2_ll = extract32(insn, 0, 5); | ||
59 | - int imm16 = extract32(insn, 5, 16); | ||
60 | - uint32_t syndrome; | ||
61 | - | ||
62 | - switch (opc) { | ||
63 | - case 0: | ||
64 | - /* For SVC, HVC and SMC we advance the single-step state | ||
65 | - * machine before taking the exception. This is architecturally | ||
66 | - * mandated, to ensure that single-stepping a system call | ||
67 | - * instruction works properly. | ||
68 | - */ | ||
69 | - switch (op2_ll) { | ||
70 | - case 1: /* SVC */ | ||
71 | - syndrome = syn_aa64_svc(imm16); | ||
72 | - if (s->fgt_svc) { | ||
73 | - gen_exception_insn_el(s, 0, EXCP_UDEF, syndrome, 2); | ||
74 | - break; | ||
75 | - } | ||
76 | - gen_ss_advance(s); | ||
77 | - gen_exception_insn(s, 4, EXCP_SWI, syndrome); | ||
78 | - break; | ||
79 | - case 2: /* HVC */ | ||
80 | - if (s->current_el == 0) { | ||
81 | - unallocated_encoding(s); | ||
82 | - break; | ||
83 | - } | ||
84 | - /* The pre HVC helper handles cases when HVC gets trapped | ||
85 | - * as an undefined insn by runtime configuration. | ||
86 | - */ | ||
87 | - gen_a64_update_pc(s, 0); | ||
88 | - gen_helper_pre_hvc(cpu_env); | ||
89 | - gen_ss_advance(s); | ||
90 | - gen_exception_insn_el(s, 4, EXCP_HVC, syn_aa64_hvc(imm16), 2); | ||
91 | - break; | ||
92 | - case 3: /* SMC */ | ||
93 | - if (s->current_el == 0) { | ||
94 | - unallocated_encoding(s); | ||
95 | - break; | ||
96 | - } | ||
97 | - gen_a64_update_pc(s, 0); | ||
98 | - gen_helper_pre_smc(cpu_env, tcg_constant_i32(syn_aa64_smc(imm16))); | ||
99 | - gen_ss_advance(s); | ||
100 | - gen_exception_insn_el(s, 4, EXCP_SMC, syn_aa64_smc(imm16), 3); | ||
101 | - break; | ||
102 | - default: | ||
103 | - unallocated_encoding(s); | ||
104 | - break; | ||
105 | - } | ||
106 | - break; | ||
107 | - case 1: | ||
108 | - if (op2_ll != 0) { | ||
109 | - unallocated_encoding(s); | ||
110 | - break; | ||
111 | - } | ||
112 | - /* BRK */ | ||
113 | - gen_exception_bkpt_insn(s, syn_aa64_bkpt(imm16)); | ||
114 | - break; | ||
115 | - case 2: | ||
116 | - if (op2_ll != 0) { | ||
117 | - unallocated_encoding(s); | ||
118 | - break; | ||
119 | - } | ||
120 | - /* HLT. This has two purposes. | ||
121 | - * Architecturally, it is an external halting debug instruction. | ||
122 | - * Since QEMU doesn't implement external debug, we treat this as | ||
123 | - * it is required for halting debug disabled: it will UNDEF. | ||
124 | - * Secondly, "HLT 0xf000" is the A64 semihosting syscall instruction. | ||
125 | - */ | ||
126 | - if (semihosting_enabled(s->current_el == 0) && imm16 == 0xf000) { | ||
127 | - gen_exception_internal_insn(s, EXCP_SEMIHOST); | ||
128 | - } else { | ||
129 | - unallocated_encoding(s); | ||
130 | - } | ||
131 | - break; | ||
132 | - case 5: | ||
133 | - if (op2_ll < 1 || op2_ll > 3) { | ||
134 | - unallocated_encoding(s); | ||
135 | - break; | ||
136 | - } | ||
137 | - /* DCPS1, DCPS2, DCPS3 */ | ||
138 | - unallocated_encoding(s); | ||
139 | - break; | ||
140 | - default: | ||
141 | - unallocated_encoding(s); | ||
142 | - break; | ||
143 | + /* | ||
144 | + * For SVC, HVC and SMC we advance the single-step state | ||
145 | + * machine before taking the exception. This is architecturally | ||
146 | + * mandated, to ensure that single-stepping a system call | ||
147 | + * instruction works properly. | ||
148 | + */ | ||
149 | + uint32_t syndrome = syn_aa64_svc(a->imm); | ||
150 | + if (s->fgt_svc) { | ||
151 | + gen_exception_insn_el(s, 0, EXCP_UDEF, syndrome, 2); | ||
152 | + return true; | ||
153 | } | ||
154 | + gen_ss_advance(s); | ||
155 | + gen_exception_insn(s, 4, EXCP_SWI, syndrome); | ||
156 | + return true; | ||
157 | } | ||
158 | |||
159 | -/* Branches, exception generating and system instructions */ | ||
160 | -static void disas_b_exc_sys(DisasContext *s, uint32_t insn) | ||
161 | +static bool trans_HVC(DisasContext *s, arg_i *a) | ||
162 | { | ||
163 | - switch (extract32(insn, 25, 7)) { | ||
164 | - case 0x6a: /* Exception generation / System */ | ||
165 | - if (insn & (1 << 24)) { | ||
166 | - unallocated_encoding(s); | ||
167 | - } else { | ||
168 | - disas_exc(s, insn); | ||
169 | - } | ||
170 | - break; | ||
171 | - default: | ||
172 | + if (s->current_el == 0) { | ||
173 | unallocated_encoding(s); | ||
174 | - break; | ||
175 | + return true; | ||
176 | } | ||
177 | + /* | ||
178 | + * The pre HVC helper handles cases when HVC gets trapped | ||
179 | + * as an undefined insn by runtime configuration. | ||
180 | + */ | ||
181 | + gen_a64_update_pc(s, 0); | ||
182 | + gen_helper_pre_hvc(cpu_env); | ||
183 | + /* Architecture requires ss advance before we do the actual work */ | ||
184 | + gen_ss_advance(s); | ||
185 | + gen_exception_insn_el(s, 4, EXCP_HVC, syn_aa64_hvc(a->imm), 2); | ||
186 | + return true; | ||
187 | +} | ||
188 | + | ||
189 | +static bool trans_SMC(DisasContext *s, arg_i *a) | ||
190 | +{ | ||
191 | + if (s->current_el == 0) { | ||
192 | + unallocated_encoding(s); | ||
193 | + return true; | ||
194 | + } | ||
195 | + gen_a64_update_pc(s, 0); | ||
196 | + gen_helper_pre_smc(cpu_env, tcg_constant_i32(syn_aa64_smc(a->imm))); | ||
197 | + /* Architecture requires ss advance before we do the actual work */ | ||
198 | + gen_ss_advance(s); | ||
199 | + gen_exception_insn_el(s, 4, EXCP_SMC, syn_aa64_smc(a->imm), 3); | ||
200 | + return true; | ||
201 | +} | ||
202 | + | ||
203 | +static bool trans_BRK(DisasContext *s, arg_i *a) | ||
204 | +{ | ||
205 | + gen_exception_bkpt_insn(s, syn_aa64_bkpt(a->imm)); | ||
206 | + return true; | ||
207 | +} | ||
208 | + | ||
209 | +static bool trans_HLT(DisasContext *s, arg_i *a) | ||
210 | +{ | ||
211 | + /* | ||
212 | + * HLT. This has two purposes. | ||
213 | + * Architecturally, it is an external halting debug instruction. | ||
214 | + * Since QEMU doesn't implement external debug, we treat this as | ||
215 | + * it is required for halting debug disabled: it will UNDEF. | ||
216 | + * Secondly, "HLT 0xf000" is the A64 semihosting syscall instruction. | ||
217 | + */ | ||
218 | + if (semihosting_enabled(s->current_el == 0) && a->imm == 0xf000) { | ||
219 | + gen_exception_internal_insn(s, EXCP_SEMIHOST); | ||
220 | + } else { | ||
221 | + unallocated_encoding(s); | ||
222 | + } | ||
223 | + return true; | ||
224 | } | ||
225 | |||
226 | /* | ||
227 | @@ -XXX,XX +XXX,XX @@ static bool btype_destination_ok(uint32_t insn, bool bt, int btype) | ||
228 | static void disas_a64_legacy(DisasContext *s, uint32_t insn) | ||
229 | { | ||
230 | switch (extract32(insn, 25, 4)) { | ||
231 | - case 0xa: case 0xb: /* Branch, exception generation and system insns */ | ||
232 | - disas_b_exc_sys(s, insn); | ||
233 | - break; | ||
234 | case 0x4: | ||
235 | case 0x6: | ||
236 | case 0xc: | ||
42 | -- | 237 | -- |
43 | 2.25.1 | 238 | 2.34.1 |
44 | |||
45 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Convert the instructions in the load/store exclusive (STXR, |
---|---|---|---|
2 | 2 | STLXR, LDXR, LDAXR) and load/store ordered (STLR, STLLR, | |
3 | Create arm_check_ss_active and arm_check_kernelpage. | 3 | LDAR, LDLAR) to decodetree. |
4 | 4 | ||
5 | Reverse the order of the tests. While it doesn't matter in practice, | 5 | Note that for STLR, STLLR, LDAR, LDLAR this fixes an under-decoding |
6 | because only user-only has a kernel page and user-only never sets | 6 | in the legacy decoder where we were not checking that the RES1 bits |
7 | ss_active, ss_active has priority over execution exceptions and it | 7 | in the Rs and Rt2 fields were set. |
8 | is best to keep them in the proper order. | 8 | |
9 | 9 | The new function ldst_iss_sf() is equivalent to the existing | |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | disas_ldst_compute_iss_sf(), but it takes the pre-decoded 'ext' field |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | rather than taking an undecoded two-bit opc field and extracting |
12 | 'ext' from it. Once all the loads and stores have been converted | ||
13 | to decodetree disas_ldst_compute_iss_sf() will be unused and | ||
14 | can be deleted. | ||
15 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
18 | Message-id: 20230602155223.2040685-9-peter.maydell@linaro.org | ||
13 | --- | 19 | --- |
14 | target/arm/translate.c | 10 +++++++--- | 20 | target/arm/tcg/a64.decode | 11 +++ |
15 | 1 file changed, 7 insertions(+), 3 deletions(-) | 21 | target/arm/tcg/translate-a64.c | 154 ++++++++++++++++++++------------- |
16 | 22 | 2 files changed, 103 insertions(+), 62 deletions(-) | |
17 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 23 | |
24 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode | ||
18 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate.c | 26 | --- a/target/arm/tcg/a64.decode |
20 | +++ b/target/arm/translate.c | 27 | +++ b/target/arm/tcg/a64.decode |
21 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) | 28 | @@ -XXX,XX +XXX,XX @@ HLT 1101 0100 010 ................ 000 00 @i16 |
22 | dc->insn_start = tcg_last_op(); | 29 | # DCPS1 1101 0100 101 ................ 000 01 @i16 |
30 | # DCPS2 1101 0100 101 ................ 000 10 @i16 | ||
31 | # DCPS3 1101 0100 101 ................ 000 11 @i16 | ||
32 | + | ||
33 | +# Loads and stores | ||
34 | + | ||
35 | +&stxr rn rt rt2 rs sz lasr | ||
36 | +&stlr rn rt sz lasr | ||
37 | +@stxr sz:2 ...... ... rs:5 lasr:1 rt2:5 rn:5 rt:5 &stxr | ||
38 | +@stlr sz:2 ...... ... ..... lasr:1 ..... rn:5 rt:5 &stlr | ||
39 | +STXR .. 001000 000 ..... . ..... ..... ..... @stxr # inc STLXR | ||
40 | +LDXR .. 001000 010 ..... . ..... ..... ..... @stxr # inc LDAXR | ||
41 | +STLR .. 001000 100 11111 . 11111 ..... ..... @stlr # inc STLLR | ||
42 | +LDAR .. 001000 110 11111 . 11111 ..... ..... @stlr # inc LDLAR | ||
43 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/tcg/translate-a64.c | ||
46 | +++ b/target/arm/tcg/translate-a64.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static bool disas_ldst_compute_iss_sf(int size, bool is_signed, int opc) | ||
48 | return regsize == 64; | ||
23 | } | 49 | } |
24 | 50 | ||
25 | -static bool arm_pre_translate_insn(DisasContext *dc) | 51 | +static bool ldst_iss_sf(int size, bool sign, bool ext) |
26 | +static bool arm_check_kernelpage(DisasContext *dc) | 52 | +{ |
27 | { | 53 | + |
28 | #ifdef CONFIG_USER_ONLY | 54 | + if (sign) { |
29 | /* Intercept jump to the magic kernel page. */ | 55 | + /* |
30 | @@ -XXX,XX +XXX,XX @@ static bool arm_pre_translate_insn(DisasContext *dc) | 56 | + * Signed loads are 64 bit results if we are not going to |
31 | return true; | 57 | + * do a zero-extend from 32 to 64 after the load. |
58 | + * (For a store, sign and ext are always false.) | ||
59 | + */ | ||
60 | + return !ext; | ||
61 | + } else { | ||
62 | + /* Unsigned loads/stores work at the specified size */ | ||
63 | + return size == MO_64; | ||
64 | + } | ||
65 | +} | ||
66 | + | ||
67 | +static bool trans_STXR(DisasContext *s, arg_stxr *a) | ||
68 | +{ | ||
69 | + if (a->rn == 31) { | ||
70 | + gen_check_sp_alignment(s); | ||
71 | + } | ||
72 | + if (a->lasr) { | ||
73 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | ||
74 | + } | ||
75 | + gen_store_exclusive(s, a->rs, a->rt, a->rt2, a->rn, a->sz, false); | ||
76 | + return true; | ||
77 | +} | ||
78 | + | ||
79 | +static bool trans_LDXR(DisasContext *s, arg_stxr *a) | ||
80 | +{ | ||
81 | + if (a->rn == 31) { | ||
82 | + gen_check_sp_alignment(s); | ||
83 | + } | ||
84 | + gen_load_exclusive(s, a->rt, a->rt2, a->rn, a->sz, false); | ||
85 | + if (a->lasr) { | ||
86 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
87 | + } | ||
88 | + return true; | ||
89 | +} | ||
90 | + | ||
91 | +static bool trans_STLR(DisasContext *s, arg_stlr *a) | ||
92 | +{ | ||
93 | + TCGv_i64 clean_addr; | ||
94 | + MemOp memop; | ||
95 | + bool iss_sf = ldst_iss_sf(a->sz, false, false); | ||
96 | + | ||
97 | + /* | ||
98 | + * StoreLORelease is the same as Store-Release for QEMU, but | ||
99 | + * needs the feature-test. | ||
100 | + */ | ||
101 | + if (!a->lasr && !dc_isar_feature(aa64_lor, s)) { | ||
102 | + return false; | ||
103 | + } | ||
104 | + /* Generate ISS for non-exclusive accesses including LASR. */ | ||
105 | + if (a->rn == 31) { | ||
106 | + gen_check_sp_alignment(s); | ||
107 | + } | ||
108 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | ||
109 | + memop = check_ordered_align(s, a->rn, 0, true, a->sz); | ||
110 | + clean_addr = gen_mte_check1(s, cpu_reg_sp(s, a->rn), | ||
111 | + true, a->rn != 31, memop); | ||
112 | + do_gpr_st(s, cpu_reg(s, a->rt), clean_addr, memop, true, a->rt, | ||
113 | + iss_sf, a->lasr); | ||
114 | + return true; | ||
115 | +} | ||
116 | + | ||
117 | +static bool trans_LDAR(DisasContext *s, arg_stlr *a) | ||
118 | +{ | ||
119 | + TCGv_i64 clean_addr; | ||
120 | + MemOp memop; | ||
121 | + bool iss_sf = ldst_iss_sf(a->sz, false, false); | ||
122 | + | ||
123 | + /* LoadLOAcquire is the same as Load-Acquire for QEMU. */ | ||
124 | + if (!a->lasr && !dc_isar_feature(aa64_lor, s)) { | ||
125 | + return false; | ||
126 | + } | ||
127 | + /* Generate ISS for non-exclusive accesses including LASR. */ | ||
128 | + if (a->rn == 31) { | ||
129 | + gen_check_sp_alignment(s); | ||
130 | + } | ||
131 | + memop = check_ordered_align(s, a->rn, 0, false, a->sz); | ||
132 | + clean_addr = gen_mte_check1(s, cpu_reg_sp(s, a->rn), | ||
133 | + false, a->rn != 31, memop); | ||
134 | + do_gpr_ld(s, cpu_reg(s, a->rt), clean_addr, memop, false, true, | ||
135 | + a->rt, iss_sf, a->lasr); | ||
136 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
137 | + return true; | ||
138 | +} | ||
139 | + | ||
140 | /* Load/store exclusive | ||
141 | * | ||
142 | * 31 30 29 24 23 22 21 20 16 15 14 10 9 5 4 0 | ||
143 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | ||
144 | int is_lasr = extract32(insn, 15, 1); | ||
145 | int o2_L_o1_o0 = extract32(insn, 21, 3) * 2 | is_lasr; | ||
146 | int size = extract32(insn, 30, 2); | ||
147 | - TCGv_i64 clean_addr; | ||
148 | - MemOp memop; | ||
149 | |||
150 | switch (o2_L_o1_o0) { | ||
151 | - case 0x0: /* STXR */ | ||
152 | - case 0x1: /* STLXR */ | ||
153 | - if (rn == 31) { | ||
154 | - gen_check_sp_alignment(s); | ||
155 | - } | ||
156 | - if (is_lasr) { | ||
157 | - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | ||
158 | - } | ||
159 | - gen_store_exclusive(s, rs, rt, rt2, rn, size, false); | ||
160 | - return; | ||
161 | - | ||
162 | - case 0x4: /* LDXR */ | ||
163 | - case 0x5: /* LDAXR */ | ||
164 | - if (rn == 31) { | ||
165 | - gen_check_sp_alignment(s); | ||
166 | - } | ||
167 | - gen_load_exclusive(s, rt, rt2, rn, size, false); | ||
168 | - if (is_lasr) { | ||
169 | - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
170 | - } | ||
171 | - return; | ||
172 | - | ||
173 | - case 0x8: /* STLLR */ | ||
174 | - if (!dc_isar_feature(aa64_lor, s)) { | ||
175 | - break; | ||
176 | - } | ||
177 | - /* StoreLORelease is the same as Store-Release for QEMU. */ | ||
178 | - /* fall through */ | ||
179 | - case 0x9: /* STLR */ | ||
180 | - /* Generate ISS for non-exclusive accesses including LASR. */ | ||
181 | - if (rn == 31) { | ||
182 | - gen_check_sp_alignment(s); | ||
183 | - } | ||
184 | - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | ||
185 | - memop = check_ordered_align(s, rn, 0, true, size); | ||
186 | - clean_addr = gen_mte_check1(s, cpu_reg_sp(s, rn), | ||
187 | - true, rn != 31, memop); | ||
188 | - do_gpr_st(s, cpu_reg(s, rt), clean_addr, memop, true, rt, | ||
189 | - disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | ||
190 | - return; | ||
191 | - | ||
192 | - case 0xc: /* LDLAR */ | ||
193 | - if (!dc_isar_feature(aa64_lor, s)) { | ||
194 | - break; | ||
195 | - } | ||
196 | - /* LoadLOAcquire is the same as Load-Acquire for QEMU. */ | ||
197 | - /* fall through */ | ||
198 | - case 0xd: /* LDAR */ | ||
199 | - /* Generate ISS for non-exclusive accesses including LASR. */ | ||
200 | - if (rn == 31) { | ||
201 | - gen_check_sp_alignment(s); | ||
202 | - } | ||
203 | - memop = check_ordered_align(s, rn, 0, false, size); | ||
204 | - clean_addr = gen_mte_check1(s, cpu_reg_sp(s, rn), | ||
205 | - false, rn != 31, memop); | ||
206 | - do_gpr_ld(s, cpu_reg(s, rt), clean_addr, memop, false, true, | ||
207 | - rt, disas_ldst_compute_iss_sf(size, false, 0), is_lasr); | ||
208 | - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
209 | - return; | ||
210 | - | ||
211 | case 0x2: case 0x3: /* CASP / STXP */ | ||
212 | if (size & 2) { /* STXP / STLXP */ | ||
213 | if (rn == 31) { | ||
214 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn) | ||
215 | return; | ||
216 | } | ||
217 | break; | ||
218 | + default: | ||
219 | + /* Handled in decodetree */ | ||
220 | + break; | ||
32 | } | 221 | } |
33 | #endif | 222 | unallocated_encoding(s); |
34 | + return false; | 223 | } |
35 | +} | ||
36 | |||
37 | +static bool arm_check_ss_active(DisasContext *dc) | ||
38 | +{ | ||
39 | if (dc->ss_active && !dc->pstate_ss) { | ||
40 | /* Singlestep state is Active-pending. | ||
41 | * If we're in this state at the start of a TB then either | ||
42 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
43 | uint32_t pc = dc->base.pc_next; | ||
44 | unsigned int insn; | ||
45 | |||
46 | - if (arm_pre_translate_insn(dc)) { | ||
47 | + if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { | ||
48 | dc->base.pc_next = pc + 4; | ||
49 | return; | ||
50 | } | ||
51 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | ||
52 | uint32_t insn; | ||
53 | bool is_16bit; | ||
54 | |||
55 | - if (arm_pre_translate_insn(dc)) { | ||
56 | + if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { | ||
57 | dc->base.pc_next = pc + 2; | ||
58 | return; | ||
59 | } | ||
60 | -- | 224 | -- |
61 | 2.25.1 | 225 | 2.34.1 |
62 | |||
63 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | Convert the load/store exclusive pair (LDXP, STXP, LDAXP, STLXP), |
---|---|---|---|
2 | compare-and-swap pair (CASP, CASPA, CASPAL, CASPL), and compare-and | ||
3 | swap (CAS, CASA, CASAL, CASL) instructions to decodetree. | ||
2 | 4 | ||
3 | Add two test cases for VIOT, one on the q35 machine and the other on | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | virt. To test complex topologies the q35 test has two PCIe buses that | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | bypass the IOMMU (and are therefore not described by VIOT), and two | 7 | Message-id: 20230602155223.2040685-10-peter.maydell@linaro.org |
6 | buses that are translated by virtio-iommu. | 8 | --- |
9 | target/arm/tcg/a64.decode | 11 +++ | ||
10 | target/arm/tcg/translate-a64.c | 121 ++++++++++++--------------------- | ||
11 | 2 files changed, 53 insertions(+), 79 deletions(-) | ||
7 | 12 | ||
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | 13 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
9 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
11 | Message-id: 20211210170415.583179-7-jean-philippe@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | tests/qtest/bios-tables-test.c | 38 ++++++++++++++++++++++++++++++++++ | ||
15 | 1 file changed, 38 insertions(+) | ||
16 | |||
17 | diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/tests/qtest/bios-tables-test.c | 15 | --- a/target/arm/tcg/a64.decode |
20 | +++ b/tests/qtest/bios-tables-test.c | 16 | +++ b/target/arm/tcg/a64.decode |
21 | @@ -XXX,XX +XXX,XX @@ static void test_acpi_virt_tcg(void) | 17 | @@ -XXX,XX +XXX,XX @@ HLT 1101 0100 010 ................ 000 00 @i16 |
22 | free_test_data(&data); | 18 | &stlr rn rt sz lasr |
19 | @stxr sz:2 ...... ... rs:5 lasr:1 rt2:5 rn:5 rt:5 &stxr | ||
20 | @stlr sz:2 ...... ... ..... lasr:1 ..... rn:5 rt:5 &stlr | ||
21 | +%imm1_30_p2 30:1 !function=plus_2 | ||
22 | +@stxp .. ...... ... rs:5 lasr:1 rt2:5 rn:5 rt:5 &stxr sz=%imm1_30_p2 | ||
23 | STXR .. 001000 000 ..... . ..... ..... ..... @stxr # inc STLXR | ||
24 | LDXR .. 001000 010 ..... . ..... ..... ..... @stxr # inc LDAXR | ||
25 | STLR .. 001000 100 11111 . 11111 ..... ..... @stlr # inc STLLR | ||
26 | LDAR .. 001000 110 11111 . 11111 ..... ..... @stlr # inc LDLAR | ||
27 | + | ||
28 | +STXP 1 . 001000 001 ..... . ..... ..... ..... @stxp # inc STLXP | ||
29 | +LDXP 1 . 001000 011 ..... . ..... ..... ..... @stxp # inc LDAXP | ||
30 | + | ||
31 | +# CASP, CASPA, CASPAL, CASPL (we don't decode the bits that determine | ||
32 | +# acquire/release semantics because QEMU's cmpxchg always has those) | ||
33 | +CASP 0 . 001000 0 - 1 rs:5 - 11111 rn:5 rt:5 sz=%imm1_30_p2 | ||
34 | +# CAS, CASA, CASAL, CASL | ||
35 | +CAS sz:2 001000 1 - 1 rs:5 - 11111 rn:5 rt:5 | ||
36 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/tcg/translate-a64.c | ||
39 | +++ b/target/arm/tcg/translate-a64.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDAR(DisasContext *s, arg_stlr *a) | ||
41 | return true; | ||
23 | } | 42 | } |
24 | 43 | ||
25 | +static void test_acpi_q35_viot(void) | 44 | -/* Load/store exclusive |
26 | +{ | 45 | - * |
27 | + test_data data = { | 46 | - * 31 30 29 24 23 22 21 20 16 15 14 10 9 5 4 0 |
28 | + .machine = MACHINE_Q35, | 47 | - * +-----+-------------+----+---+----+------+----+-------+------+------+ |
29 | + .variant = ".viot", | 48 | - * | sz | 0 0 1 0 0 0 | o2 | L | o1 | Rs | o0 | Rt2 | Rn | Rt | |
30 | + }; | 49 | - * +-----+-------------+----+---+----+------+----+-------+------+------+ |
31 | + | 50 | - * |
32 | + /* | 51 | - * sz: 00 -> 8 bit, 01 -> 16 bit, 10 -> 32 bit, 11 -> 64 bit |
33 | + * To keep things interesting, two buses bypass the IOMMU. | 52 | - * L: 0 -> store, 1 -> load |
34 | + * VIOT should only describes the other two buses. | 53 | - * o2: 0 -> exclusive, 1 -> not |
35 | + */ | 54 | - * o1: 0 -> single register, 1 -> register pair |
36 | + test_acpi_one("-machine default_bus_bypass_iommu=on " | 55 | - * o0: 1 -> load-acquire/store-release, 0 -> not |
37 | + "-device virtio-iommu-pci " | 56 | - */ |
38 | + "-device pxb-pcie,bus_nr=0x10,id=pcie.100,bus=pcie.0 " | 57 | -static void disas_ldst_excl(DisasContext *s, uint32_t insn) |
39 | + "-device pxb-pcie,bus_nr=0x20,id=pcie.200,bus=pcie.0,bypass_iommu=on " | 58 | +static bool trans_STXP(DisasContext *s, arg_stxr *a) |
40 | + "-device pxb-pcie,bus_nr=0x30,id=pcie.300,bus=pcie.0", | 59 | { |
41 | + &data); | 60 | - int rt = extract32(insn, 0, 5); |
42 | + free_test_data(&data); | 61 | - int rn = extract32(insn, 5, 5); |
62 | - int rt2 = extract32(insn, 10, 5); | ||
63 | - int rs = extract32(insn, 16, 5); | ||
64 | - int is_lasr = extract32(insn, 15, 1); | ||
65 | - int o2_L_o1_o0 = extract32(insn, 21, 3) * 2 | is_lasr; | ||
66 | - int size = extract32(insn, 30, 2); | ||
67 | - | ||
68 | - switch (o2_L_o1_o0) { | ||
69 | - case 0x2: case 0x3: /* CASP / STXP */ | ||
70 | - if (size & 2) { /* STXP / STLXP */ | ||
71 | - if (rn == 31) { | ||
72 | - gen_check_sp_alignment(s); | ||
73 | - } | ||
74 | - if (is_lasr) { | ||
75 | - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | ||
76 | - } | ||
77 | - gen_store_exclusive(s, rs, rt, rt2, rn, size, true); | ||
78 | - return; | ||
79 | - } | ||
80 | - if (rt2 == 31 | ||
81 | - && ((rt | rs) & 1) == 0 | ||
82 | - && dc_isar_feature(aa64_atomics, s)) { | ||
83 | - /* CASP / CASPL */ | ||
84 | - gen_compare_and_swap_pair(s, rs, rt, rn, size | 2); | ||
85 | - return; | ||
86 | - } | ||
87 | - break; | ||
88 | - | ||
89 | - case 0x6: case 0x7: /* CASPA / LDXP */ | ||
90 | - if (size & 2) { /* LDXP / LDAXP */ | ||
91 | - if (rn == 31) { | ||
92 | - gen_check_sp_alignment(s); | ||
93 | - } | ||
94 | - gen_load_exclusive(s, rt, rt2, rn, size, true); | ||
95 | - if (is_lasr) { | ||
96 | - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
97 | - } | ||
98 | - return; | ||
99 | - } | ||
100 | - if (rt2 == 31 | ||
101 | - && ((rt | rs) & 1) == 0 | ||
102 | - && dc_isar_feature(aa64_atomics, s)) { | ||
103 | - /* CASPA / CASPAL */ | ||
104 | - gen_compare_and_swap_pair(s, rs, rt, rn, size | 2); | ||
105 | - return; | ||
106 | - } | ||
107 | - break; | ||
108 | - | ||
109 | - case 0xa: /* CAS */ | ||
110 | - case 0xb: /* CASL */ | ||
111 | - case 0xe: /* CASA */ | ||
112 | - case 0xf: /* CASAL */ | ||
113 | - if (rt2 == 31 && dc_isar_feature(aa64_atomics, s)) { | ||
114 | - gen_compare_and_swap(s, rs, rt, rn, size); | ||
115 | - return; | ||
116 | - } | ||
117 | - break; | ||
118 | - default: | ||
119 | - /* Handled in decodetree */ | ||
120 | - break; | ||
121 | + if (a->rn == 31) { | ||
122 | + gen_check_sp_alignment(s); | ||
123 | } | ||
124 | - unallocated_encoding(s); | ||
125 | + if (a->lasr) { | ||
126 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | ||
127 | + } | ||
128 | + gen_store_exclusive(s, a->rs, a->rt, a->rt2, a->rn, a->sz, true); | ||
129 | + return true; | ||
43 | +} | 130 | +} |
44 | + | 131 | + |
45 | +static void test_acpi_virt_viot(void) | 132 | +static bool trans_LDXP(DisasContext *s, arg_stxr *a) |
46 | +{ | 133 | +{ |
47 | + test_data data = { | 134 | + if (a->rn == 31) { |
48 | + .machine = "virt", | 135 | + gen_check_sp_alignment(s); |
49 | + .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", | 136 | + } |
50 | + .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", | 137 | + gen_load_exclusive(s, a->rt, a->rt2, a->rn, a->sz, true); |
51 | + .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2", | 138 | + if (a->lasr) { |
52 | + .ram_start = 0x40000000ULL, | 139 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); |
53 | + .scan_len = 128ULL * 1024 * 1024, | 140 | + } |
54 | + }; | 141 | + return true; |
55 | + | ||
56 | + test_acpi_one("-cpu cortex-a57 " | ||
57 | + "-device virtio-iommu-pci", &data); | ||
58 | + free_test_data(&data); | ||
59 | +} | 142 | +} |
60 | + | 143 | + |
61 | static void test_oem_fields(test_data *data) | 144 | +static bool trans_CASP(DisasContext *s, arg_CASP *a) |
145 | +{ | ||
146 | + if (!dc_isar_feature(aa64_atomics, s)) { | ||
147 | + return false; | ||
148 | + } | ||
149 | + if (((a->rt | a->rs) & 1) != 0) { | ||
150 | + return false; | ||
151 | + } | ||
152 | + | ||
153 | + gen_compare_and_swap_pair(s, a->rs, a->rt, a->rn, a->sz); | ||
154 | + return true; | ||
155 | +} | ||
156 | + | ||
157 | +static bool trans_CAS(DisasContext *s, arg_CAS *a) | ||
158 | +{ | ||
159 | + if (!dc_isar_feature(aa64_atomics, s)) { | ||
160 | + return false; | ||
161 | + } | ||
162 | + gen_compare_and_swap(s, a->rs, a->rt, a->rn, a->sz); | ||
163 | + return true; | ||
164 | } | ||
165 | |||
166 | /* | ||
167 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_tag(DisasContext *s, uint32_t insn) | ||
168 | static void disas_ldst(DisasContext *s, uint32_t insn) | ||
62 | { | 169 | { |
63 | int i; | 170 | switch (extract32(insn, 24, 6)) { |
64 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) | 171 | - case 0x08: /* Load/store exclusive */ |
65 | qtest_add_func("acpi/q35/kvm/xapic", test_acpi_q35_kvm_xapic); | 172 | - disas_ldst_excl(s, insn); |
66 | qtest_add_func("acpi/q35/kvm/dmar", test_acpi_q35_kvm_dmar); | 173 | - break; |
67 | } | 174 | case 0x18: case 0x1c: /* Load register (literal) */ |
68 | + qtest_add_func("acpi/q35/viot", test_acpi_q35_viot); | 175 | disas_ld_lit(s, insn); |
69 | } else if (strcmp(arch, "aarch64") == 0) { | 176 | break; |
70 | if (has_tcg) { | ||
71 | qtest_add_func("acpi/virt", test_acpi_virt_tcg); | ||
72 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) | ||
73 | qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp); | ||
74 | qtest_add_func("acpi/virt/pxb", test_acpi_virt_tcg_pxb); | ||
75 | qtest_add_func("acpi/virt/oem-fields", test_acpi_oem_fields_virt); | ||
76 | + qtest_add_func("acpi/virt/viot", test_acpi_virt_viot); | ||
77 | } | ||
78 | } | ||
79 | ret = g_test_run(); | ||
80 | -- | 177 | -- |
81 | 2.25.1 | 178 | 2.34.1 |
82 | |||
83 | diff view generated by jsdifflib |
1 | The qemu-common.h header is not supposed to be included from any | 1 | Convert the "Load register (literal)" instruction class to |
---|---|---|---|
2 | other header files, only from .c files (as documented in a comment at | 2 | decodetree. |
3 | the start of it). | ||
4 | |||
5 | include/hw/i386/x86.h and include/hw/i386/microvm.h break this rule. | ||
6 | In fact, the include is not required at all, so we can just drop it | ||
7 | from both files. | ||
8 | 3 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | Message-id: 20230602155223.2040685-11-peter.maydell@linaro.org |
12 | Message-id: 20211129200510.1233037-2-peter.maydell@linaro.org | ||
13 | --- | 7 | --- |
14 | include/hw/i386/microvm.h | 1 - | 8 | target/arm/tcg/a64.decode | 13 ++++++ |
15 | include/hw/i386/x86.h | 1 - | 9 | target/arm/tcg/translate-a64.c | 76 ++++++++++------------------------ |
16 | 2 files changed, 2 deletions(-) | 10 | 2 files changed, 35 insertions(+), 54 deletions(-) |
17 | 11 | ||
18 | diff --git a/include/hw/i386/microvm.h b/include/hw/i386/microvm.h | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
19 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/i386/microvm.h | 14 | --- a/target/arm/tcg/a64.decode |
21 | +++ b/include/hw/i386/microvm.h | 15 | +++ b/target/arm/tcg/a64.decode |
22 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ LDXP 1 . 001000 011 ..... . ..... ..... ..... @stxp # inc LDAXP |
23 | #ifndef HW_I386_MICROVM_H | 17 | CASP 0 . 001000 0 - 1 rs:5 - 11111 rn:5 rt:5 sz=%imm1_30_p2 |
24 | #define HW_I386_MICROVM_H | 18 | # CAS, CASA, CASAL, CASL |
25 | 19 | CAS sz:2 001000 1 - 1 rs:5 - 11111 rn:5 rt:5 | |
26 | -#include "qemu-common.h" | 20 | + |
27 | #include "exec/hwaddr.h" | 21 | +&ldlit rt imm sz sign |
28 | #include "qemu/notify.h" | 22 | +@ldlit .. ... . .. ................... rt:5 &ldlit imm=%imm19 |
29 | 23 | + | |
30 | diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h | 24 | +LD_lit 00 011 0 00 ................... ..... @ldlit sz=2 sign=0 |
25 | +LD_lit 01 011 0 00 ................... ..... @ldlit sz=3 sign=0 | ||
26 | +LD_lit 10 011 0 00 ................... ..... @ldlit sz=2 sign=1 | ||
27 | +LD_lit_v 00 011 1 00 ................... ..... @ldlit sz=2 sign=0 | ||
28 | +LD_lit_v 01 011 1 00 ................... ..... @ldlit sz=3 sign=0 | ||
29 | +LD_lit_v 10 011 1 00 ................... ..... @ldlit sz=4 sign=0 | ||
30 | + | ||
31 | +# PRFM | ||
32 | +NOP 11 011 0 00 ------------------- ----- | ||
33 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/include/hw/i386/x86.h | 35 | --- a/target/arm/tcg/translate-a64.c |
33 | +++ b/include/hw/i386/x86.h | 36 | +++ b/target/arm/tcg/translate-a64.c |
34 | @@ -XXX,XX +XXX,XX @@ | 37 | @@ -XXX,XX +XXX,XX @@ static bool trans_CAS(DisasContext *s, arg_CAS *a) |
35 | #ifndef HW_I386_X86_H | 38 | return true; |
36 | #define HW_I386_X86_H | 39 | } |
37 | 40 | ||
38 | -#include "qemu-common.h" | 41 | -/* |
39 | #include "exec/hwaddr.h" | 42 | - * Load register (literal) |
40 | #include "qemu/notify.h" | 43 | - * |
41 | 44 | - * 31 30 29 27 26 25 24 23 5 4 0 | |
45 | - * +-----+-------+---+-----+-------------------+-------+ | ||
46 | - * | opc | 0 1 1 | V | 0 0 | imm19 | Rt | | ||
47 | - * +-----+-------+---+-----+-------------------+-------+ | ||
48 | - * | ||
49 | - * V: 1 -> vector (simd/fp) | ||
50 | - * opc (non-vector): 00 -> 32 bit, 01 -> 64 bit, | ||
51 | - * 10-> 32 bit signed, 11 -> prefetch | ||
52 | - * opc (vector): 00 -> 32 bit, 01 -> 64 bit, 10 -> 128 bit (11 unallocated) | ||
53 | - */ | ||
54 | -static void disas_ld_lit(DisasContext *s, uint32_t insn) | ||
55 | +static bool trans_LD_lit(DisasContext *s, arg_ldlit *a) | ||
56 | { | ||
57 | - int rt = extract32(insn, 0, 5); | ||
58 | - int64_t imm = sextract32(insn, 5, 19) << 2; | ||
59 | - bool is_vector = extract32(insn, 26, 1); | ||
60 | - int opc = extract32(insn, 30, 2); | ||
61 | - bool is_signed = false; | ||
62 | - int size = 2; | ||
63 | - TCGv_i64 tcg_rt, clean_addr; | ||
64 | + bool iss_sf = ldst_iss_sf(a->sz, a->sign, false); | ||
65 | + TCGv_i64 tcg_rt = cpu_reg(s, a->rt); | ||
66 | + TCGv_i64 clean_addr = tcg_temp_new_i64(); | ||
67 | + MemOp memop = finalize_memop(s, a->sz + a->sign * MO_SIGN); | ||
68 | + | ||
69 | + gen_pc_plus_diff(s, clean_addr, a->imm); | ||
70 | + do_gpr_ld(s, tcg_rt, clean_addr, memop, | ||
71 | + false, true, a->rt, iss_sf, false); | ||
72 | + return true; | ||
73 | +} | ||
74 | + | ||
75 | +static bool trans_LD_lit_v(DisasContext *s, arg_ldlit *a) | ||
76 | +{ | ||
77 | + /* Load register (literal), vector version */ | ||
78 | + TCGv_i64 clean_addr; | ||
79 | MemOp memop; | ||
80 | |||
81 | - if (is_vector) { | ||
82 | - if (opc == 3) { | ||
83 | - unallocated_encoding(s); | ||
84 | - return; | ||
85 | - } | ||
86 | - size = 2 + opc; | ||
87 | - if (!fp_access_check(s)) { | ||
88 | - return; | ||
89 | - } | ||
90 | - memop = finalize_memop_asimd(s, size); | ||
91 | - } else { | ||
92 | - if (opc == 3) { | ||
93 | - /* PRFM (literal) : prefetch */ | ||
94 | - return; | ||
95 | - } | ||
96 | - size = 2 + extract32(opc, 0, 1); | ||
97 | - is_signed = extract32(opc, 1, 1); | ||
98 | - memop = finalize_memop(s, size + is_signed * MO_SIGN); | ||
99 | + if (!fp_access_check(s)) { | ||
100 | + return true; | ||
101 | } | ||
102 | - | ||
103 | - tcg_rt = cpu_reg(s, rt); | ||
104 | - | ||
105 | + memop = finalize_memop_asimd(s, a->sz); | ||
106 | clean_addr = tcg_temp_new_i64(); | ||
107 | - gen_pc_plus_diff(s, clean_addr, imm); | ||
108 | - | ||
109 | - if (is_vector) { | ||
110 | - do_fp_ld(s, rt, clean_addr, memop); | ||
111 | - } else { | ||
112 | - /* Only unsigned 32bit loads target 32bit registers. */ | ||
113 | - bool iss_sf = opc != 0; | ||
114 | - do_gpr_ld(s, tcg_rt, clean_addr, memop, false, true, rt, iss_sf, false); | ||
115 | - } | ||
116 | + gen_pc_plus_diff(s, clean_addr, a->imm); | ||
117 | + do_fp_ld(s, a->rt, clean_addr, memop); | ||
118 | + return true; | ||
119 | } | ||
120 | |||
121 | /* | ||
122 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_tag(DisasContext *s, uint32_t insn) | ||
123 | static void disas_ldst(DisasContext *s, uint32_t insn) | ||
124 | { | ||
125 | switch (extract32(insn, 24, 6)) { | ||
126 | - case 0x18: case 0x1c: /* Load register (literal) */ | ||
127 | - disas_ld_lit(s, insn); | ||
128 | - break; | ||
129 | case 0x28: case 0x29: | ||
130 | case 0x2c: case 0x2d: /* Load/store pair (all forms) */ | ||
131 | disas_ldst_pair(s, insn); | ||
42 | -- | 132 | -- |
43 | 2.25.1 | 133 | 2.34.1 |
44 | |||
45 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Convert the load/store register pair insns (LDP, STP, |
---|---|---|---|
2 | LDNP, STNP, LDPSW, STGP) to decodetree. | ||
2 | 3 | ||
3 | We will reuse this section of arm_deliver_fault for | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | raising pc alignment faults. | 5 | Message-id: 20230602155223.2040685-12-peter.maydell@linaro.org |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | --- | ||
8 | target/arm/tcg/a64.decode | 61 +++++ | ||
9 | target/arm/tcg/translate-a64.c | 422 ++++++++++++++++----------------- | ||
10 | 2 files changed, 268 insertions(+), 215 deletions(-) | ||
5 | 11 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 12 | 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/tlb_helper.c | 45 +++++++++++++++++++++++++---------------- | ||
11 | 1 file changed, 28 insertions(+), 17 deletions(-) | ||
12 | |||
13 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/tlb_helper.c | 14 | --- a/target/arm/tcg/a64.decode |
16 | +++ b/target/arm/tlb_helper.c | 15 | +++ b/target/arm/tcg/a64.decode |
17 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | 16 | @@ -XXX,XX +XXX,XX @@ LD_lit_v 10 011 1 00 ................... ..... @ldlit sz=4 sign=0 |
18 | return syn; | 17 | |
18 | # PRFM | ||
19 | NOP 11 011 0 00 ------------------- ----- | ||
20 | + | ||
21 | +&ldstpair rt2 rt rn imm sz sign w p | ||
22 | +@ldstpair .. ... . ... . imm:s7 rt2:5 rn:5 rt:5 &ldstpair | ||
23 | + | ||
24 | +# STNP, LDNP: Signed offset, non-temporal hint. We don't emulate caches | ||
25 | +# so we ignore hints about data access patterns, and handle these like | ||
26 | +# plain signed offset. | ||
27 | +STP 00 101 0 000 0 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=0 w=0 | ||
28 | +LDP 00 101 0 000 1 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=0 w=0 | ||
29 | +STP 10 101 0 000 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=0 | ||
30 | +LDP 10 101 0 000 1 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=0 | ||
31 | +STP_v 00 101 1 000 0 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=0 w=0 | ||
32 | +LDP_v 00 101 1 000 1 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=0 w=0 | ||
33 | +STP_v 01 101 1 000 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=0 | ||
34 | +LDP_v 01 101 1 000 1 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=0 | ||
35 | +STP_v 10 101 1 000 0 ....... ..... ..... ..... @ldstpair sz=4 sign=0 p=0 w=0 | ||
36 | +LDP_v 10 101 1 000 1 ....... ..... ..... ..... @ldstpair sz=4 sign=0 p=0 w=0 | ||
37 | + | ||
38 | +# STP and LDP: post-indexed | ||
39 | +STP 00 101 0 001 0 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=1 w=1 | ||
40 | +LDP 00 101 0 001 1 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=1 w=1 | ||
41 | +LDP 01 101 0 001 1 ....... ..... ..... ..... @ldstpair sz=2 sign=1 p=1 w=1 | ||
42 | +STP 10 101 0 001 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=1 w=1 | ||
43 | +LDP 10 101 0 001 1 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=1 w=1 | ||
44 | +STP_v 00 101 1 001 0 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=1 w=1 | ||
45 | +LDP_v 00 101 1 001 1 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=1 w=1 | ||
46 | +STP_v 01 101 1 001 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=1 w=1 | ||
47 | +LDP_v 01 101 1 001 1 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=1 w=1 | ||
48 | +STP_v 10 101 1 001 0 ....... ..... ..... ..... @ldstpair sz=4 sign=0 p=1 w=1 | ||
49 | +LDP_v 10 101 1 001 1 ....... ..... ..... ..... @ldstpair sz=4 sign=0 p=1 w=1 | ||
50 | + | ||
51 | +# STP and LDP: offset | ||
52 | +STP 00 101 0 010 0 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=0 w=0 | ||
53 | +LDP 00 101 0 010 1 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=0 w=0 | ||
54 | +LDP 01 101 0 010 1 ....... ..... ..... ..... @ldstpair sz=2 sign=1 p=0 w=0 | ||
55 | +STP 10 101 0 010 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=0 | ||
56 | +LDP 10 101 0 010 1 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=0 | ||
57 | +STP_v 00 101 1 010 0 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=0 w=0 | ||
58 | +LDP_v 00 101 1 010 1 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=0 w=0 | ||
59 | +STP_v 01 101 1 010 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=0 | ||
60 | +LDP_v 01 101 1 010 1 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=0 | ||
61 | +STP_v 10 101 1 010 0 ....... ..... ..... ..... @ldstpair sz=4 sign=0 p=0 w=0 | ||
62 | +LDP_v 10 101 1 010 1 ....... ..... ..... ..... @ldstpair sz=4 sign=0 p=0 w=0 | ||
63 | + | ||
64 | +# STP and LDP: pre-indexed | ||
65 | +STP 00 101 0 011 0 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=0 w=1 | ||
66 | +LDP 00 101 0 011 1 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=0 w=1 | ||
67 | +LDP 01 101 0 011 1 ....... ..... ..... ..... @ldstpair sz=2 sign=1 p=0 w=1 | ||
68 | +STP 10 101 0 011 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=1 | ||
69 | +LDP 10 101 0 011 1 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=1 | ||
70 | +STP_v 00 101 1 011 0 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=0 w=1 | ||
71 | +LDP_v 00 101 1 011 1 ....... ..... ..... ..... @ldstpair sz=2 sign=0 p=0 w=1 | ||
72 | +STP_v 01 101 1 011 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=1 | ||
73 | +LDP_v 01 101 1 011 1 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=1 | ||
74 | +STP_v 10 101 1 011 0 ....... ..... ..... ..... @ldstpair sz=4 sign=0 p=0 w=1 | ||
75 | +LDP_v 10 101 1 011 1 ....... ..... ..... ..... @ldstpair sz=4 sign=0 p=0 w=1 | ||
76 | + | ||
77 | +# STGP: store tag and pair | ||
78 | +STGP 01 101 0 001 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=1 w=1 | ||
79 | +STGP 01 101 0 010 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=0 | ||
80 | +STGP 01 101 0 011 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=1 | ||
81 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/target/arm/tcg/translate-a64.c | ||
84 | +++ b/target/arm/tcg/translate-a64.c | ||
85 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD_lit_v(DisasContext *s, arg_ldlit *a) | ||
86 | return true; | ||
19 | } | 87 | } |
20 | 88 | ||
21 | -static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, | 89 | -/* |
22 | - MMUAccessType access_type, | 90 | - * LDNP (Load Pair - non-temporal hint) |
23 | - int mmu_idx, ARMMMUFaultInfo *fi) | 91 | - * LDP (Load Pair - non vector) |
24 | +static uint32_t compute_fsr_fsc(CPUARMState *env, ARMMMUFaultInfo *fi, | 92 | - * LDPSW (Load Pair Signed Word - non vector) |
25 | + int target_el, int mmu_idx, uint32_t *ret_fsc) | 93 | - * STNP (Store Pair - non-temporal hint) |
94 | - * STP (Store Pair - non vector) | ||
95 | - * LDNP (Load Pair of SIMD&FP - non-temporal hint) | ||
96 | - * LDP (Load Pair of SIMD&FP) | ||
97 | - * STNP (Store Pair of SIMD&FP - non-temporal hint) | ||
98 | - * STP (Store Pair of SIMD&FP) | ||
99 | - * | ||
100 | - * 31 30 29 27 26 25 24 23 22 21 15 14 10 9 5 4 0 | ||
101 | - * +-----+-------+---+---+-------+---+-----------------------------+ | ||
102 | - * | opc | 1 0 1 | V | 0 | index | L | imm7 | Rt2 | Rn | Rt | | ||
103 | - * +-----+-------+---+---+-------+---+-------+-------+------+------+ | ||
104 | - * | ||
105 | - * opc: LDP/STP/LDNP/STNP 00 -> 32 bit, 10 -> 64 bit | ||
106 | - * LDPSW/STGP 01 | ||
107 | - * LDP/STP/LDNP/STNP (SIMD) 00 -> 32 bit, 01 -> 64 bit, 10 -> 128 bit | ||
108 | - * V: 0 -> GPR, 1 -> Vector | ||
109 | - * idx: 00 -> signed offset with non-temporal hint, 01 -> post-index, | ||
110 | - * 10 -> signed offset, 11 -> pre-index | ||
111 | - * L: 0 -> Store 1 -> Load | ||
112 | - * | ||
113 | - * Rt, Rt2 = GPR or SIMD registers to be stored | ||
114 | - * Rn = general purpose register containing address | ||
115 | - * imm7 = signed offset (multiple of 4 or 8 depending on size) | ||
116 | - */ | ||
117 | -static void disas_ldst_pair(DisasContext *s, uint32_t insn) | ||
118 | +static void op_addr_ldstpair_pre(DisasContext *s, arg_ldstpair *a, | ||
119 | + TCGv_i64 *clean_addr, TCGv_i64 *dirty_addr, | ||
120 | + uint64_t offset, bool is_store, MemOp mop) | ||
26 | { | 121 | { |
27 | - CPUARMState *env = &cpu->env; | 122 | - int rt = extract32(insn, 0, 5); |
28 | - int target_el; | 123 | - int rn = extract32(insn, 5, 5); |
29 | - bool same_el; | 124 | - int rt2 = extract32(insn, 10, 5); |
30 | - uint32_t syn, exc, fsr, fsc; | 125 | - uint64_t offset = sextract64(insn, 15, 7); |
31 | ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); | 126 | - int index = extract32(insn, 23, 2); |
32 | - | 127 | - bool is_vector = extract32(insn, 26, 1); |
33 | - target_el = exception_target_el(env); | 128 | - bool is_load = extract32(insn, 22, 1); |
34 | - if (fi->stage2) { | 129 | - int opc = extract32(insn, 30, 2); |
35 | - target_el = 2; | 130 | - bool is_signed = false; |
36 | - env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; | 131 | - bool postindex = false; |
37 | - if (arm_is_secure_below_el3(env) && fi->s1ns) { | 132 | - bool wback = false; |
38 | - env->cp15.hpfar_el2 |= HPFAR_NS; | 133 | - bool set_tag = false; |
39 | - } | 134 | - TCGv_i64 clean_addr, dirty_addr; |
135 | - MemOp mop; | ||
136 | - int size; | ||
137 | - | ||
138 | - if (opc == 3) { | ||
139 | - unallocated_encoding(s); | ||
140 | - return; | ||
40 | - } | 141 | - } |
41 | - same_el = (arm_current_el(env) == target_el); | 142 | - |
42 | + uint32_t fsr, fsc; | 143 | - if (is_vector) { |
43 | 144 | - size = 2 + opc; | |
44 | if (target_el == 2 || arm_el_is_aa64(env, target_el) || | 145 | - } else if (opc == 1 && !is_load) { |
45 | arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { | 146 | - /* STGP */ |
46 | @@ -XXX,XX +XXX,XX @@ static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, | 147 | - if (!dc_isar_feature(aa64_mte_insn_reg, s) || index == 0) { |
47 | fsc = 0x3f; | 148 | - unallocated_encoding(s); |
149 | - return; | ||
150 | - } | ||
151 | - size = 3; | ||
152 | - set_tag = true; | ||
153 | - } else { | ||
154 | - size = 2 + extract32(opc, 1, 1); | ||
155 | - is_signed = extract32(opc, 0, 1); | ||
156 | - if (!is_load && is_signed) { | ||
157 | - unallocated_encoding(s); | ||
158 | - return; | ||
159 | - } | ||
160 | - } | ||
161 | - | ||
162 | - switch (index) { | ||
163 | - case 1: /* post-index */ | ||
164 | - postindex = true; | ||
165 | - wback = true; | ||
166 | - break; | ||
167 | - case 0: | ||
168 | - /* signed offset with "non-temporal" hint. Since we don't emulate | ||
169 | - * caches we don't care about hints to the cache system about | ||
170 | - * data access patterns, and handle this identically to plain | ||
171 | - * signed offset. | ||
172 | - */ | ||
173 | - if (is_signed) { | ||
174 | - /* There is no non-temporal-hint version of LDPSW */ | ||
175 | - unallocated_encoding(s); | ||
176 | - return; | ||
177 | - } | ||
178 | - postindex = false; | ||
179 | - break; | ||
180 | - case 2: /* signed offset, rn not updated */ | ||
181 | - postindex = false; | ||
182 | - break; | ||
183 | - case 3: /* pre-index */ | ||
184 | - postindex = false; | ||
185 | - wback = true; | ||
186 | - break; | ||
187 | - } | ||
188 | - | ||
189 | - if (is_vector && !fp_access_check(s)) { | ||
190 | - return; | ||
191 | - } | ||
192 | - | ||
193 | - offset <<= (set_tag ? LOG2_TAG_GRANULE : size); | ||
194 | - | ||
195 | - if (rn == 31) { | ||
196 | + if (a->rn == 31) { | ||
197 | gen_check_sp_alignment(s); | ||
48 | } | 198 | } |
49 | 199 | ||
50 | + *ret_fsc = fsc; | 200 | - dirty_addr = read_cpu_reg_sp(s, rn, 1); |
51 | + return fsr; | 201 | - if (!postindex) { |
202 | + *dirty_addr = read_cpu_reg_sp(s, a->rn, 1); | ||
203 | + if (!a->p) { | ||
204 | + tcg_gen_addi_i64(*dirty_addr, *dirty_addr, offset); | ||
205 | + } | ||
206 | + | ||
207 | + *clean_addr = gen_mte_checkN(s, *dirty_addr, is_store, | ||
208 | + (a->w || a->rn != 31), 2 << a->sz, mop); | ||
52 | +} | 209 | +} |
53 | + | 210 | + |
54 | +static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr, | 211 | +static void op_addr_ldstpair_post(DisasContext *s, arg_ldstpair *a, |
55 | + MMUAccessType access_type, | 212 | + TCGv_i64 dirty_addr, uint64_t offset) |
56 | + int mmu_idx, ARMMMUFaultInfo *fi) | ||
57 | +{ | 213 | +{ |
58 | + CPUARMState *env = &cpu->env; | 214 | + if (a->w) { |
59 | + int target_el; | 215 | + if (a->p) { |
60 | + bool same_el; | 216 | + tcg_gen_addi_i64(dirty_addr, dirty_addr, offset); |
61 | + uint32_t syn, exc, fsr, fsc; | ||
62 | + | ||
63 | + target_el = exception_target_el(env); | ||
64 | + if (fi->stage2) { | ||
65 | + target_el = 2; | ||
66 | + env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4; | ||
67 | + if (arm_is_secure_below_el3(env) && fi->s1ns) { | ||
68 | + env->cp15.hpfar_el2 |= HPFAR_NS; | ||
69 | + } | 217 | + } |
70 | + } | 218 | + tcg_gen_mov_i64(cpu_reg_sp(s, a->rn), dirty_addr); |
71 | + same_el = (arm_current_el(env) == target_el); | 219 | + } |
72 | + | 220 | +} |
73 | + fsr = compute_fsr_fsc(env, fi, target_el, mmu_idx, &fsc); | 221 | + |
74 | + | 222 | +static bool trans_STP(DisasContext *s, arg_ldstpair *a) |
75 | if (access_type == MMU_INST_FETCH) { | 223 | +{ |
76 | syn = syn_insn_abort(same_el, fi->ea, fi->s1ptw, fsc); | 224 | + uint64_t offset = a->imm << a->sz; |
77 | exc = EXCP_PREFETCH_ABORT; | 225 | + TCGv_i64 clean_addr, dirty_addr, tcg_rt, tcg_rt2; |
226 | + MemOp mop = finalize_memop(s, a->sz); | ||
227 | + | ||
228 | + op_addr_ldstpair_pre(s, a, &clean_addr, &dirty_addr, offset, true, mop); | ||
229 | + tcg_rt = cpu_reg(s, a->rt); | ||
230 | + tcg_rt2 = cpu_reg(s, a->rt2); | ||
231 | + /* | ||
232 | + * We built mop above for the single logical access -- rebuild it | ||
233 | + * now for the paired operation. | ||
234 | + * | ||
235 | + * With LSE2, non-sign-extending pairs are treated atomically if | ||
236 | + * aligned, and if unaligned one of the pair will be completely | ||
237 | + * within a 16-byte block and that element will be atomic. | ||
238 | + * Otherwise each element is separately atomic. | ||
239 | + * In all cases, issue one operation with the correct atomicity. | ||
240 | + */ | ||
241 | + mop = a->sz + 1; | ||
242 | + if (s->align_mem) { | ||
243 | + mop |= (a->sz == 2 ? MO_ALIGN_4 : MO_ALIGN_8); | ||
244 | + } | ||
245 | + mop = finalize_memop_pair(s, mop); | ||
246 | + if (a->sz == 2) { | ||
247 | + TCGv_i64 tmp = tcg_temp_new_i64(); | ||
248 | + | ||
249 | + if (s->be_data == MO_LE) { | ||
250 | + tcg_gen_concat32_i64(tmp, tcg_rt, tcg_rt2); | ||
251 | + } else { | ||
252 | + tcg_gen_concat32_i64(tmp, tcg_rt2, tcg_rt); | ||
253 | + } | ||
254 | + tcg_gen_qemu_st_i64(tmp, clean_addr, get_mem_index(s), mop); | ||
255 | + } else { | ||
256 | + TCGv_i128 tmp = tcg_temp_new_i128(); | ||
257 | + | ||
258 | + if (s->be_data == MO_LE) { | ||
259 | + tcg_gen_concat_i64_i128(tmp, tcg_rt, tcg_rt2); | ||
260 | + } else { | ||
261 | + tcg_gen_concat_i64_i128(tmp, tcg_rt2, tcg_rt); | ||
262 | + } | ||
263 | + tcg_gen_qemu_st_i128(tmp, clean_addr, get_mem_index(s), mop); | ||
264 | + } | ||
265 | + op_addr_ldstpair_post(s, a, dirty_addr, offset); | ||
266 | + return true; | ||
267 | +} | ||
268 | + | ||
269 | +static bool trans_LDP(DisasContext *s, arg_ldstpair *a) | ||
270 | +{ | ||
271 | + uint64_t offset = a->imm << a->sz; | ||
272 | + TCGv_i64 clean_addr, dirty_addr, tcg_rt, tcg_rt2; | ||
273 | + MemOp mop = finalize_memop(s, a->sz); | ||
274 | + | ||
275 | + op_addr_ldstpair_pre(s, a, &clean_addr, &dirty_addr, offset, false, mop); | ||
276 | + tcg_rt = cpu_reg(s, a->rt); | ||
277 | + tcg_rt2 = cpu_reg(s, a->rt2); | ||
278 | + | ||
279 | + /* | ||
280 | + * We built mop above for the single logical access -- rebuild it | ||
281 | + * now for the paired operation. | ||
282 | + * | ||
283 | + * With LSE2, non-sign-extending pairs are treated atomically if | ||
284 | + * aligned, and if unaligned one of the pair will be completely | ||
285 | + * within a 16-byte block and that element will be atomic. | ||
286 | + * Otherwise each element is separately atomic. | ||
287 | + * In all cases, issue one operation with the correct atomicity. | ||
288 | + * | ||
289 | + * This treats sign-extending loads like zero-extending loads, | ||
290 | + * since that reuses the most code below. | ||
291 | + */ | ||
292 | + mop = a->sz + 1; | ||
293 | + if (s->align_mem) { | ||
294 | + mop |= (a->sz == 2 ? MO_ALIGN_4 : MO_ALIGN_8); | ||
295 | + } | ||
296 | + mop = finalize_memop_pair(s, mop); | ||
297 | + if (a->sz == 2) { | ||
298 | + int o2 = s->be_data == MO_LE ? 32 : 0; | ||
299 | + int o1 = o2 ^ 32; | ||
300 | + | ||
301 | + tcg_gen_qemu_ld_i64(tcg_rt, clean_addr, get_mem_index(s), mop); | ||
302 | + if (a->sign) { | ||
303 | + tcg_gen_sextract_i64(tcg_rt2, tcg_rt, o2, 32); | ||
304 | + tcg_gen_sextract_i64(tcg_rt, tcg_rt, o1, 32); | ||
305 | + } else { | ||
306 | + tcg_gen_extract_i64(tcg_rt2, tcg_rt, o2, 32); | ||
307 | + tcg_gen_extract_i64(tcg_rt, tcg_rt, o1, 32); | ||
308 | + } | ||
309 | + } else { | ||
310 | + TCGv_i128 tmp = tcg_temp_new_i128(); | ||
311 | + | ||
312 | + tcg_gen_qemu_ld_i128(tmp, clean_addr, get_mem_index(s), mop); | ||
313 | + if (s->be_data == MO_LE) { | ||
314 | + tcg_gen_extr_i128_i64(tcg_rt, tcg_rt2, tmp); | ||
315 | + } else { | ||
316 | + tcg_gen_extr_i128_i64(tcg_rt2, tcg_rt, tmp); | ||
317 | + } | ||
318 | + } | ||
319 | + op_addr_ldstpair_post(s, a, dirty_addr, offset); | ||
320 | + return true; | ||
321 | +} | ||
322 | + | ||
323 | +static bool trans_STP_v(DisasContext *s, arg_ldstpair *a) | ||
324 | +{ | ||
325 | + uint64_t offset = a->imm << a->sz; | ||
326 | + TCGv_i64 clean_addr, dirty_addr; | ||
327 | + MemOp mop; | ||
328 | + | ||
329 | + if (!fp_access_check(s)) { | ||
330 | + return true; | ||
331 | + } | ||
332 | + | ||
333 | + /* LSE2 does not merge FP pairs; leave these as separate operations. */ | ||
334 | + mop = finalize_memop_asimd(s, a->sz); | ||
335 | + op_addr_ldstpair_pre(s, a, &clean_addr, &dirty_addr, offset, true, mop); | ||
336 | + do_fp_st(s, a->rt, clean_addr, mop); | ||
337 | + tcg_gen_addi_i64(clean_addr, clean_addr, 1 << a->sz); | ||
338 | + do_fp_st(s, a->rt2, clean_addr, mop); | ||
339 | + op_addr_ldstpair_post(s, a, dirty_addr, offset); | ||
340 | + return true; | ||
341 | +} | ||
342 | + | ||
343 | +static bool trans_LDP_v(DisasContext *s, arg_ldstpair *a) | ||
344 | +{ | ||
345 | + uint64_t offset = a->imm << a->sz; | ||
346 | + TCGv_i64 clean_addr, dirty_addr; | ||
347 | + MemOp mop; | ||
348 | + | ||
349 | + if (!fp_access_check(s)) { | ||
350 | + return true; | ||
351 | + } | ||
352 | + | ||
353 | + /* LSE2 does not merge FP pairs; leave these as separate operations. */ | ||
354 | + mop = finalize_memop_asimd(s, a->sz); | ||
355 | + op_addr_ldstpair_pre(s, a, &clean_addr, &dirty_addr, offset, false, mop); | ||
356 | + do_fp_ld(s, a->rt, clean_addr, mop); | ||
357 | + tcg_gen_addi_i64(clean_addr, clean_addr, 1 << a->sz); | ||
358 | + do_fp_ld(s, a->rt2, clean_addr, mop); | ||
359 | + op_addr_ldstpair_post(s, a, dirty_addr, offset); | ||
360 | + return true; | ||
361 | +} | ||
362 | + | ||
363 | +static bool trans_STGP(DisasContext *s, arg_ldstpair *a) | ||
364 | +{ | ||
365 | + TCGv_i64 clean_addr, dirty_addr, tcg_rt, tcg_rt2; | ||
366 | + uint64_t offset = a->imm << LOG2_TAG_GRANULE; | ||
367 | + MemOp mop; | ||
368 | + TCGv_i128 tmp; | ||
369 | + | ||
370 | + if (!dc_isar_feature(aa64_mte_insn_reg, s)) { | ||
371 | + return false; | ||
372 | + } | ||
373 | + | ||
374 | + if (a->rn == 31) { | ||
375 | + gen_check_sp_alignment(s); | ||
376 | + } | ||
377 | + | ||
378 | + dirty_addr = read_cpu_reg_sp(s, a->rn, 1); | ||
379 | + if (!a->p) { | ||
380 | tcg_gen_addi_i64(dirty_addr, dirty_addr, offset); | ||
381 | } | ||
382 | |||
383 | - if (set_tag) { | ||
384 | - if (!s->ata) { | ||
385 | - /* | ||
386 | - * TODO: We could rely on the stores below, at least for | ||
387 | - * system mode, if we arrange to add MO_ALIGN_16. | ||
388 | - */ | ||
389 | - gen_helper_stg_stub(cpu_env, dirty_addr); | ||
390 | - } else if (tb_cflags(s->base.tb) & CF_PARALLEL) { | ||
391 | - gen_helper_stg_parallel(cpu_env, dirty_addr, dirty_addr); | ||
392 | - } else { | ||
393 | - gen_helper_stg(cpu_env, dirty_addr, dirty_addr); | ||
394 | - } | ||
395 | - } | ||
396 | - | ||
397 | - if (is_vector) { | ||
398 | - mop = finalize_memop_asimd(s, size); | ||
399 | - } else { | ||
400 | - mop = finalize_memop(s, size); | ||
401 | - } | ||
402 | - clean_addr = gen_mte_checkN(s, dirty_addr, !is_load, | ||
403 | - (wback || rn != 31) && !set_tag, | ||
404 | - 2 << size, mop); | ||
405 | - | ||
406 | - if (is_vector) { | ||
407 | - /* LSE2 does not merge FP pairs; leave these as separate operations. */ | ||
408 | - if (is_load) { | ||
409 | - do_fp_ld(s, rt, clean_addr, mop); | ||
410 | - } else { | ||
411 | - do_fp_st(s, rt, clean_addr, mop); | ||
412 | - } | ||
413 | - tcg_gen_addi_i64(clean_addr, clean_addr, 1 << size); | ||
414 | - if (is_load) { | ||
415 | - do_fp_ld(s, rt2, clean_addr, mop); | ||
416 | - } else { | ||
417 | - do_fp_st(s, rt2, clean_addr, mop); | ||
418 | - } | ||
419 | - } else { | ||
420 | - TCGv_i64 tcg_rt = cpu_reg(s, rt); | ||
421 | - TCGv_i64 tcg_rt2 = cpu_reg(s, rt2); | ||
422 | - | ||
423 | + if (!s->ata) { | ||
424 | /* | ||
425 | - * We built mop above for the single logical access -- rebuild it | ||
426 | - * now for the paired operation. | ||
427 | - * | ||
428 | - * With LSE2, non-sign-extending pairs are treated atomically if | ||
429 | - * aligned, and if unaligned one of the pair will be completely | ||
430 | - * within a 16-byte block and that element will be atomic. | ||
431 | - * Otherwise each element is separately atomic. | ||
432 | - * In all cases, issue one operation with the correct atomicity. | ||
433 | - * | ||
434 | - * This treats sign-extending loads like zero-extending loads, | ||
435 | - * since that reuses the most code below. | ||
436 | + * TODO: We could rely on the stores below, at least for | ||
437 | + * system mode, if we arrange to add MO_ALIGN_16. | ||
438 | */ | ||
439 | - mop = size + 1; | ||
440 | - if (s->align_mem) { | ||
441 | - mop |= (size == 2 ? MO_ALIGN_4 : MO_ALIGN_8); | ||
442 | - } | ||
443 | - mop = finalize_memop_pair(s, mop); | ||
444 | - | ||
445 | - if (is_load) { | ||
446 | - if (size == 2) { | ||
447 | - int o2 = s->be_data == MO_LE ? 32 : 0; | ||
448 | - int o1 = o2 ^ 32; | ||
449 | - | ||
450 | - tcg_gen_qemu_ld_i64(tcg_rt, clean_addr, get_mem_index(s), mop); | ||
451 | - if (is_signed) { | ||
452 | - tcg_gen_sextract_i64(tcg_rt2, tcg_rt, o2, 32); | ||
453 | - tcg_gen_sextract_i64(tcg_rt, tcg_rt, o1, 32); | ||
454 | - } else { | ||
455 | - tcg_gen_extract_i64(tcg_rt2, tcg_rt, o2, 32); | ||
456 | - tcg_gen_extract_i64(tcg_rt, tcg_rt, o1, 32); | ||
457 | - } | ||
458 | - } else { | ||
459 | - TCGv_i128 tmp = tcg_temp_new_i128(); | ||
460 | - | ||
461 | - tcg_gen_qemu_ld_i128(tmp, clean_addr, get_mem_index(s), mop); | ||
462 | - if (s->be_data == MO_LE) { | ||
463 | - tcg_gen_extr_i128_i64(tcg_rt, tcg_rt2, tmp); | ||
464 | - } else { | ||
465 | - tcg_gen_extr_i128_i64(tcg_rt2, tcg_rt, tmp); | ||
466 | - } | ||
467 | - } | ||
468 | - } else { | ||
469 | - if (size == 2) { | ||
470 | - TCGv_i64 tmp = tcg_temp_new_i64(); | ||
471 | - | ||
472 | - if (s->be_data == MO_LE) { | ||
473 | - tcg_gen_concat32_i64(tmp, tcg_rt, tcg_rt2); | ||
474 | - } else { | ||
475 | - tcg_gen_concat32_i64(tmp, tcg_rt2, tcg_rt); | ||
476 | - } | ||
477 | - tcg_gen_qemu_st_i64(tmp, clean_addr, get_mem_index(s), mop); | ||
478 | - } else { | ||
479 | - TCGv_i128 tmp = tcg_temp_new_i128(); | ||
480 | - | ||
481 | - if (s->be_data == MO_LE) { | ||
482 | - tcg_gen_concat_i64_i128(tmp, tcg_rt, tcg_rt2); | ||
483 | - } else { | ||
484 | - tcg_gen_concat_i64_i128(tmp, tcg_rt2, tcg_rt); | ||
485 | - } | ||
486 | - tcg_gen_qemu_st_i128(tmp, clean_addr, get_mem_index(s), mop); | ||
487 | - } | ||
488 | - } | ||
489 | + gen_helper_stg_stub(cpu_env, dirty_addr); | ||
490 | + } else if (tb_cflags(s->base.tb) & CF_PARALLEL) { | ||
491 | + gen_helper_stg_parallel(cpu_env, dirty_addr, dirty_addr); | ||
492 | + } else { | ||
493 | + gen_helper_stg(cpu_env, dirty_addr, dirty_addr); | ||
494 | } | ||
495 | |||
496 | - if (wback) { | ||
497 | - if (postindex) { | ||
498 | - tcg_gen_addi_i64(dirty_addr, dirty_addr, offset); | ||
499 | - } | ||
500 | - tcg_gen_mov_i64(cpu_reg_sp(s, rn), dirty_addr); | ||
501 | + mop = finalize_memop(s, a->sz); | ||
502 | + clean_addr = gen_mte_checkN(s, dirty_addr, true, false, 2 << a->sz, mop); | ||
503 | + | ||
504 | + tcg_rt = cpu_reg(s, a->rt); | ||
505 | + tcg_rt2 = cpu_reg(s, a->rt2); | ||
506 | + | ||
507 | + assert(a->sz == 3); | ||
508 | + | ||
509 | + tmp = tcg_temp_new_i128(); | ||
510 | + if (s->be_data == MO_LE) { | ||
511 | + tcg_gen_concat_i64_i128(tmp, tcg_rt, tcg_rt2); | ||
512 | + } else { | ||
513 | + tcg_gen_concat_i64_i128(tmp, tcg_rt2, tcg_rt); | ||
514 | } | ||
515 | + tcg_gen_qemu_st_i128(tmp, clean_addr, get_mem_index(s), mop); | ||
516 | + | ||
517 | + op_addr_ldstpair_post(s, a, dirty_addr, offset); | ||
518 | + return true; | ||
519 | } | ||
520 | |||
521 | /* | ||
522 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_tag(DisasContext *s, uint32_t insn) | ||
523 | static void disas_ldst(DisasContext *s, uint32_t insn) | ||
524 | { | ||
525 | switch (extract32(insn, 24, 6)) { | ||
526 | - case 0x28: case 0x29: | ||
527 | - case 0x2c: case 0x2d: /* Load/store pair (all forms) */ | ||
528 | - disas_ldst_pair(s, insn); | ||
529 | - break; | ||
530 | case 0x38: case 0x39: | ||
531 | case 0x3c: case 0x3d: /* Load/store register (all forms) */ | ||
532 | disas_ldst_reg(s, insn); | ||
78 | -- | 533 | -- |
79 | 2.25.1 | 534 | 2.34.1 |
80 | |||
81 | diff view generated by jsdifflib |
1 | The calculation of the length of TLB range invalidate operations | 1 | Convert the load and store instructions which use a 9-bit |
---|---|---|---|
2 | in tlbi_aa64_range_get_length() is incorrect in two ways: | 2 | immediate offset to decodetree. |
3 | * the NUM field is 5 bits, but we read only 4 bits | ||
4 | * we miscalculate the page_shift value, because of an | ||
5 | off-by-one error: | ||
6 | TG 0b00 is invalid | ||
7 | TG 0b01 is 4K granule size == 4096 == 2^12 | ||
8 | TG 0b10 is 16K granule size == 16384 == 2^14 | ||
9 | TG 0b11 is 64K granule size == 65536 == 2^16 | ||
10 | so page_shift should be (TG - 1) * 2 + 12 | ||
11 | 3 | ||
12 | Thanks to the bug report submitter Cha HyunSoo for identifying | ||
13 | both these errors. | ||
14 | |||
15 | Fixes: 84940ed82552d3c ("target/arm: Add support for FEAT_TLBIRANGE") | ||
16 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/734 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
19 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Message-id: 20230602155223.2040685-13-peter.maydell@linaro.org |
20 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
21 | Message-id: 20211130173257.1274194-1-peter.maydell@linaro.org | ||
22 | --- | 7 | --- |
23 | target/arm/helper.c | 6 +++--- | 8 | target/arm/tcg/a64.decode | 69 +++++++++++ |
24 | 1 file changed, 3 insertions(+), 3 deletions(-) | 9 | target/arm/tcg/translate-a64.c | 206 ++++++++++++++------------------- |
10 | 2 files changed, 153 insertions(+), 122 deletions(-) | ||
25 | 11 | ||
26 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
27 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/helper.c | 14 | --- a/target/arm/tcg/a64.decode |
29 | +++ b/target/arm/helper.c | 15 | +++ b/target/arm/tcg/a64.decode |
30 | @@ -XXX,XX +XXX,XX @@ static uint64_t tlbi_aa64_range_get_length(CPUARMState *env, | 16 | @@ -XXX,XX +XXX,XX @@ LDP_v 10 101 1 011 1 ....... ..... ..... ..... @ldstpair sz=4 sign=0 p |
31 | uint64_t exponent; | 17 | STGP 01 101 0 001 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=1 w=1 |
32 | uint64_t length; | 18 | STGP 01 101 0 010 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=0 |
33 | 19 | STGP 01 101 0 011 0 ....... ..... ..... ..... @ldstpair sz=3 sign=0 p=0 w=1 | |
34 | - num = extract64(value, 39, 4); | 20 | + |
35 | + num = extract64(value, 39, 5); | 21 | +# Load/store register (unscaled immediate) |
36 | scale = extract64(value, 44, 2); | 22 | +&ldst_imm rt rn imm sz sign w p unpriv ext |
37 | page_size_granule = extract64(value, 46, 2); | 23 | +@ldst_imm .. ... . .. .. . imm:s9 .. rn:5 rt:5 &ldst_imm unpriv=0 p=0 w=0 |
38 | 24 | +@ldst_imm_pre .. ... . .. .. . imm:s9 .. rn:5 rt:5 &ldst_imm unpriv=0 p=0 w=1 | |
39 | - page_shift = page_size_granule * 2 + 12; | 25 | +@ldst_imm_post .. ... . .. .. . imm:s9 .. rn:5 rt:5 &ldst_imm unpriv=0 p=1 w=1 |
40 | - | 26 | +@ldst_imm_user .. ... . .. .. . imm:s9 .. rn:5 rt:5 &ldst_imm unpriv=1 p=0 w=0 |
41 | if (page_size_granule == 0) { | 27 | + |
42 | qemu_log_mask(LOG_GUEST_ERROR, "Invalid page size granule %d\n", | 28 | +STR_i sz:2 111 0 00 00 0 ......... 00 ..... ..... @ldst_imm sign=0 ext=0 |
43 | page_size_granule); | 29 | +LDR_i 00 111 0 00 01 0 ......... 00 ..... ..... @ldst_imm sign=0 ext=1 sz=0 |
44 | return 0; | 30 | +LDR_i 01 111 0 00 01 0 ......... 00 ..... ..... @ldst_imm sign=0 ext=1 sz=1 |
31 | +LDR_i 10 111 0 00 01 0 ......... 00 ..... ..... @ldst_imm sign=0 ext=1 sz=2 | ||
32 | +LDR_i 11 111 0 00 01 0 ......... 00 ..... ..... @ldst_imm sign=0 ext=0 sz=3 | ||
33 | +LDR_i 00 111 0 00 10 0 ......... 00 ..... ..... @ldst_imm sign=1 ext=0 sz=0 | ||
34 | +LDR_i 01 111 0 00 10 0 ......... 00 ..... ..... @ldst_imm sign=1 ext=0 sz=1 | ||
35 | +LDR_i 10 111 0 00 10 0 ......... 00 ..... ..... @ldst_imm sign=1 ext=0 sz=2 | ||
36 | +LDR_i 00 111 0 00 11 0 ......... 00 ..... ..... @ldst_imm sign=1 ext=1 sz=0 | ||
37 | +LDR_i 01 111 0 00 11 0 ......... 00 ..... ..... @ldst_imm sign=1 ext=1 sz=1 | ||
38 | + | ||
39 | +STR_i sz:2 111 0 00 00 0 ......... 01 ..... ..... @ldst_imm_post sign=0 ext=0 | ||
40 | +LDR_i 00 111 0 00 01 0 ......... 01 ..... ..... @ldst_imm_post sign=0 ext=1 sz=0 | ||
41 | +LDR_i 01 111 0 00 01 0 ......... 01 ..... ..... @ldst_imm_post sign=0 ext=1 sz=1 | ||
42 | +LDR_i 10 111 0 00 01 0 ......... 01 ..... ..... @ldst_imm_post sign=0 ext=1 sz=2 | ||
43 | +LDR_i 11 111 0 00 01 0 ......... 01 ..... ..... @ldst_imm_post sign=0 ext=0 sz=3 | ||
44 | +LDR_i 00 111 0 00 10 0 ......... 01 ..... ..... @ldst_imm_post sign=1 ext=0 sz=0 | ||
45 | +LDR_i 01 111 0 00 10 0 ......... 01 ..... ..... @ldst_imm_post sign=1 ext=0 sz=1 | ||
46 | +LDR_i 10 111 0 00 10 0 ......... 01 ..... ..... @ldst_imm_post sign=1 ext=0 sz=2 | ||
47 | +LDR_i 00 111 0 00 11 0 ......... 01 ..... ..... @ldst_imm_post sign=1 ext=1 sz=0 | ||
48 | +LDR_i 01 111 0 00 11 0 ......... 01 ..... ..... @ldst_imm_post sign=1 ext=1 sz=1 | ||
49 | + | ||
50 | +STR_i sz:2 111 0 00 00 0 ......... 10 ..... ..... @ldst_imm_user sign=0 ext=0 | ||
51 | +LDR_i 00 111 0 00 01 0 ......... 10 ..... ..... @ldst_imm_user sign=0 ext=1 sz=0 | ||
52 | +LDR_i 01 111 0 00 01 0 ......... 10 ..... ..... @ldst_imm_user sign=0 ext=1 sz=1 | ||
53 | +LDR_i 10 111 0 00 01 0 ......... 10 ..... ..... @ldst_imm_user sign=0 ext=1 sz=2 | ||
54 | +LDR_i 11 111 0 00 01 0 ......... 10 ..... ..... @ldst_imm_user sign=0 ext=0 sz=3 | ||
55 | +LDR_i 00 111 0 00 10 0 ......... 10 ..... ..... @ldst_imm_user sign=1 ext=0 sz=0 | ||
56 | +LDR_i 01 111 0 00 10 0 ......... 10 ..... ..... @ldst_imm_user sign=1 ext=0 sz=1 | ||
57 | +LDR_i 10 111 0 00 10 0 ......... 10 ..... ..... @ldst_imm_user sign=1 ext=0 sz=2 | ||
58 | +LDR_i 00 111 0 00 11 0 ......... 10 ..... ..... @ldst_imm_user sign=1 ext=1 sz=0 | ||
59 | +LDR_i 01 111 0 00 11 0 ......... 10 ..... ..... @ldst_imm_user sign=1 ext=1 sz=1 | ||
60 | + | ||
61 | +STR_i sz:2 111 0 00 00 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 ext=0 | ||
62 | +LDR_i 00 111 0 00 01 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 ext=1 sz=0 | ||
63 | +LDR_i 01 111 0 00 01 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 ext=1 sz=1 | ||
64 | +LDR_i 10 111 0 00 01 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 ext=1 sz=2 | ||
65 | +LDR_i 11 111 0 00 01 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 ext=0 sz=3 | ||
66 | +LDR_i 00 111 0 00 10 0 ......... 11 ..... ..... @ldst_imm_pre sign=1 ext=0 sz=0 | ||
67 | +LDR_i 01 111 0 00 10 0 ......... 11 ..... ..... @ldst_imm_pre sign=1 ext=0 sz=1 | ||
68 | +LDR_i 10 111 0 00 10 0 ......... 11 ..... ..... @ldst_imm_pre sign=1 ext=0 sz=2 | ||
69 | +LDR_i 00 111 0 00 11 0 ......... 11 ..... ..... @ldst_imm_pre sign=1 ext=1 sz=0 | ||
70 | +LDR_i 01 111 0 00 11 0 ......... 11 ..... ..... @ldst_imm_pre sign=1 ext=1 sz=1 | ||
71 | + | ||
72 | +# PRFM : prefetch memory: a no-op for QEMU | ||
73 | +NOP 11 111 0 00 10 0 --------- 00 ----- ----- | ||
74 | + | ||
75 | +STR_v_i sz:2 111 1 00 00 0 ......... 00 ..... ..... @ldst_imm sign=0 ext=0 | ||
76 | +STR_v_i 00 111 1 00 10 0 ......... 00 ..... ..... @ldst_imm sign=0 ext=0 sz=4 | ||
77 | +LDR_v_i sz:2 111 1 00 01 0 ......... 00 ..... ..... @ldst_imm sign=0 ext=0 | ||
78 | +LDR_v_i 00 111 1 00 11 0 ......... 00 ..... ..... @ldst_imm sign=0 ext=0 sz=4 | ||
79 | + | ||
80 | +STR_v_i sz:2 111 1 00 00 0 ......... 01 ..... ..... @ldst_imm_post sign=0 ext=0 | ||
81 | +STR_v_i 00 111 1 00 10 0 ......... 01 ..... ..... @ldst_imm_post sign=0 ext=0 sz=4 | ||
82 | +LDR_v_i sz:2 111 1 00 01 0 ......... 01 ..... ..... @ldst_imm_post sign=0 ext=0 | ||
83 | +LDR_v_i 00 111 1 00 11 0 ......... 01 ..... ..... @ldst_imm_post sign=0 ext=0 sz=4 | ||
84 | + | ||
85 | +STR_v_i sz:2 111 1 00 00 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 ext=0 | ||
86 | +STR_v_i 00 111 1 00 10 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 ext=0 sz=4 | ||
87 | +LDR_v_i sz:2 111 1 00 01 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 ext=0 | ||
88 | +LDR_v_i 00 111 1 00 11 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 ext=0 sz=4 | ||
89 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/target/arm/tcg/translate-a64.c | ||
92 | +++ b/target/arm/tcg/translate-a64.c | ||
93 | @@ -XXX,XX +XXX,XX @@ static bool trans_STGP(DisasContext *s, arg_ldstpair *a) | ||
94 | return true; | ||
95 | } | ||
96 | |||
97 | -/* | ||
98 | - * Load/store (immediate post-indexed) | ||
99 | - * Load/store (immediate pre-indexed) | ||
100 | - * Load/store (unscaled immediate) | ||
101 | - * | ||
102 | - * 31 30 29 27 26 25 24 23 22 21 20 12 11 10 9 5 4 0 | ||
103 | - * +----+-------+---+-----+-----+---+--------+-----+------+------+ | ||
104 | - * |size| 1 1 1 | V | 0 0 | opc | 0 | imm9 | idx | Rn | Rt | | ||
105 | - * +----+-------+---+-----+-----+---+--------+-----+------+------+ | ||
106 | - * | ||
107 | - * idx = 01 -> post-indexed, 11 pre-indexed, 00 unscaled imm. (no writeback) | ||
108 | - 10 -> unprivileged | ||
109 | - * V = 0 -> non-vector | ||
110 | - * size: 00 -> 8 bit, 01 -> 16 bit, 10 -> 32 bit, 11 -> 64bit | ||
111 | - * opc: 00 -> store, 01 -> loadu, 10 -> loads 64, 11 -> loads 32 | ||
112 | - */ | ||
113 | -static void disas_ldst_reg_imm9(DisasContext *s, uint32_t insn, | ||
114 | - int opc, | ||
115 | - int size, | ||
116 | - int rt, | ||
117 | - bool is_vector) | ||
118 | +static void op_addr_ldst_imm_pre(DisasContext *s, arg_ldst_imm *a, | ||
119 | + TCGv_i64 *clean_addr, TCGv_i64 *dirty_addr, | ||
120 | + uint64_t offset, bool is_store, MemOp mop) | ||
121 | { | ||
122 | - int rn = extract32(insn, 5, 5); | ||
123 | - int imm9 = sextract32(insn, 12, 9); | ||
124 | - int idx = extract32(insn, 10, 2); | ||
125 | - bool is_signed = false; | ||
126 | - bool is_store = false; | ||
127 | - bool is_extended = false; | ||
128 | - bool is_unpriv = (idx == 2); | ||
129 | - bool iss_valid; | ||
130 | - bool post_index; | ||
131 | - bool writeback; | ||
132 | int memidx; | ||
133 | - MemOp memop; | ||
134 | - TCGv_i64 clean_addr, dirty_addr; | ||
135 | |||
136 | - if (is_vector) { | ||
137 | - size |= (opc & 2) << 1; | ||
138 | - if (size > 4 || is_unpriv) { | ||
139 | - unallocated_encoding(s); | ||
140 | - return; | ||
141 | - } | ||
142 | - is_store = ((opc & 1) == 0); | ||
143 | - if (!fp_access_check(s)) { | ||
144 | - return; | ||
145 | - } | ||
146 | - memop = finalize_memop_asimd(s, size); | ||
147 | - } else { | ||
148 | - if (size == 3 && opc == 2) { | ||
149 | - /* PRFM - prefetch */ | ||
150 | - if (idx != 0) { | ||
151 | - unallocated_encoding(s); | ||
152 | - return; | ||
153 | - } | ||
154 | - return; | ||
155 | - } | ||
156 | - if (opc == 3 && size > 1) { | ||
157 | - unallocated_encoding(s); | ||
158 | - return; | ||
159 | - } | ||
160 | - is_store = (opc == 0); | ||
161 | - is_signed = !is_store && extract32(opc, 1, 1); | ||
162 | - is_extended = (size < 3) && extract32(opc, 0, 1); | ||
163 | - memop = finalize_memop(s, size + is_signed * MO_SIGN); | ||
164 | - } | ||
165 | - | ||
166 | - switch (idx) { | ||
167 | - case 0: | ||
168 | - case 2: | ||
169 | - post_index = false; | ||
170 | - writeback = false; | ||
171 | - break; | ||
172 | - case 1: | ||
173 | - post_index = true; | ||
174 | - writeback = true; | ||
175 | - break; | ||
176 | - case 3: | ||
177 | - post_index = false; | ||
178 | - writeback = true; | ||
179 | - break; | ||
180 | - default: | ||
181 | - g_assert_not_reached(); | ||
182 | - } | ||
183 | - | ||
184 | - iss_valid = !is_vector && !writeback; | ||
185 | - | ||
186 | - if (rn == 31) { | ||
187 | + if (a->rn == 31) { | ||
188 | gen_check_sp_alignment(s); | ||
45 | } | 189 | } |
46 | 190 | ||
47 | + page_shift = (page_size_granule - 1) * 2 + 12; | 191 | - dirty_addr = read_cpu_reg_sp(s, rn, 1); |
48 | + | 192 | - if (!post_index) { |
49 | exponent = (5 * scale) + 1; | 193 | - tcg_gen_addi_i64(dirty_addr, dirty_addr, imm9); |
50 | length = (num + 1) << (exponent + page_shift); | 194 | + *dirty_addr = read_cpu_reg_sp(s, a->rn, 1); |
51 | 195 | + if (!a->p) { | |
196 | + tcg_gen_addi_i64(*dirty_addr, *dirty_addr, offset); | ||
197 | } | ||
198 | + memidx = a->unpriv ? get_a64_user_mem_index(s) : get_mem_index(s); | ||
199 | + *clean_addr = gen_mte_check1_mmuidx(s, *dirty_addr, is_store, | ||
200 | + a->w || a->rn != 31, | ||
201 | + mop, a->unpriv, memidx); | ||
202 | +} | ||
203 | |||
204 | - memidx = is_unpriv ? get_a64_user_mem_index(s) : get_mem_index(s); | ||
205 | - | ||
206 | - clean_addr = gen_mte_check1_mmuidx(s, dirty_addr, is_store, | ||
207 | - writeback || rn != 31, | ||
208 | - memop, is_unpriv, memidx); | ||
209 | - | ||
210 | - if (is_vector) { | ||
211 | - if (is_store) { | ||
212 | - do_fp_st(s, rt, clean_addr, memop); | ||
213 | - } else { | ||
214 | - do_fp_ld(s, rt, clean_addr, memop); | ||
215 | - } | ||
216 | - } else { | ||
217 | - TCGv_i64 tcg_rt = cpu_reg(s, rt); | ||
218 | - bool iss_sf = disas_ldst_compute_iss_sf(size, is_signed, opc); | ||
219 | - | ||
220 | - if (is_store) { | ||
221 | - do_gpr_st_memidx(s, tcg_rt, clean_addr, memop, memidx, | ||
222 | - iss_valid, rt, iss_sf, false); | ||
223 | - } else { | ||
224 | - do_gpr_ld_memidx(s, tcg_rt, clean_addr, memop, | ||
225 | - is_extended, memidx, | ||
226 | - iss_valid, rt, iss_sf, false); | ||
227 | +static void op_addr_ldst_imm_post(DisasContext *s, arg_ldst_imm *a, | ||
228 | + TCGv_i64 dirty_addr, uint64_t offset) | ||
229 | +{ | ||
230 | + if (a->w) { | ||
231 | + if (a->p) { | ||
232 | + tcg_gen_addi_i64(dirty_addr, dirty_addr, offset); | ||
233 | } | ||
234 | + tcg_gen_mov_i64(cpu_reg_sp(s, a->rn), dirty_addr); | ||
235 | } | ||
236 | +} | ||
237 | |||
238 | - if (writeback) { | ||
239 | - TCGv_i64 tcg_rn = cpu_reg_sp(s, rn); | ||
240 | - if (post_index) { | ||
241 | - tcg_gen_addi_i64(dirty_addr, dirty_addr, imm9); | ||
242 | - } | ||
243 | - tcg_gen_mov_i64(tcg_rn, dirty_addr); | ||
244 | +static bool trans_STR_i(DisasContext *s, arg_ldst_imm *a) | ||
245 | +{ | ||
246 | + bool iss_sf, iss_valid = !a->w; | ||
247 | + TCGv_i64 clean_addr, dirty_addr, tcg_rt; | ||
248 | + int memidx = a->unpriv ? get_a64_user_mem_index(s) : get_mem_index(s); | ||
249 | + MemOp mop = finalize_memop(s, a->sz + a->sign * MO_SIGN); | ||
250 | + | ||
251 | + op_addr_ldst_imm_pre(s, a, &clean_addr, &dirty_addr, a->imm, true, mop); | ||
252 | + | ||
253 | + tcg_rt = cpu_reg(s, a->rt); | ||
254 | + iss_sf = ldst_iss_sf(a->sz, a->sign, a->ext); | ||
255 | + | ||
256 | + do_gpr_st_memidx(s, tcg_rt, clean_addr, mop, memidx, | ||
257 | + iss_valid, a->rt, iss_sf, false); | ||
258 | + op_addr_ldst_imm_post(s, a, dirty_addr, a->imm); | ||
259 | + return true; | ||
260 | +} | ||
261 | + | ||
262 | +static bool trans_LDR_i(DisasContext *s, arg_ldst_imm *a) | ||
263 | +{ | ||
264 | + bool iss_sf, iss_valid = !a->w; | ||
265 | + TCGv_i64 clean_addr, dirty_addr, tcg_rt; | ||
266 | + int memidx = a->unpriv ? get_a64_user_mem_index(s) : get_mem_index(s); | ||
267 | + MemOp mop = finalize_memop(s, a->sz + a->sign * MO_SIGN); | ||
268 | + | ||
269 | + op_addr_ldst_imm_pre(s, a, &clean_addr, &dirty_addr, a->imm, false, mop); | ||
270 | + | ||
271 | + tcg_rt = cpu_reg(s, a->rt); | ||
272 | + iss_sf = ldst_iss_sf(a->sz, a->sign, a->ext); | ||
273 | + | ||
274 | + do_gpr_ld_memidx(s, tcg_rt, clean_addr, mop, | ||
275 | + a->ext, memidx, iss_valid, a->rt, iss_sf, false); | ||
276 | + op_addr_ldst_imm_post(s, a, dirty_addr, a->imm); | ||
277 | + return true; | ||
278 | +} | ||
279 | + | ||
280 | +static bool trans_STR_v_i(DisasContext *s, arg_ldst_imm *a) | ||
281 | +{ | ||
282 | + TCGv_i64 clean_addr, dirty_addr; | ||
283 | + MemOp mop; | ||
284 | + | ||
285 | + if (!fp_access_check(s)) { | ||
286 | + return true; | ||
287 | } | ||
288 | + mop = finalize_memop_asimd(s, a->sz); | ||
289 | + op_addr_ldst_imm_pre(s, a, &clean_addr, &dirty_addr, a->imm, true, mop); | ||
290 | + do_fp_st(s, a->rt, clean_addr, mop); | ||
291 | + op_addr_ldst_imm_post(s, a, dirty_addr, a->imm); | ||
292 | + return true; | ||
293 | +} | ||
294 | + | ||
295 | +static bool trans_LDR_v_i(DisasContext *s, arg_ldst_imm *a) | ||
296 | +{ | ||
297 | + TCGv_i64 clean_addr, dirty_addr; | ||
298 | + MemOp mop; | ||
299 | + | ||
300 | + if (!fp_access_check(s)) { | ||
301 | + return true; | ||
302 | + } | ||
303 | + mop = finalize_memop_asimd(s, a->sz); | ||
304 | + op_addr_ldst_imm_pre(s, a, &clean_addr, &dirty_addr, a->imm, false, mop); | ||
305 | + do_fp_ld(s, a->rt, clean_addr, mop); | ||
306 | + op_addr_ldst_imm_post(s, a, dirty_addr, a->imm); | ||
307 | + return true; | ||
308 | } | ||
309 | |||
310 | /* | ||
311 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg(DisasContext *s, uint32_t insn) | ||
312 | switch (extract32(insn, 24, 2)) { | ||
313 | case 0: | ||
314 | if (extract32(insn, 21, 1) == 0) { | ||
315 | - /* Load/store register (unscaled immediate) | ||
316 | - * Load/store immediate pre/post-indexed | ||
317 | - * Load/store register unprivileged | ||
318 | - */ | ||
319 | - disas_ldst_reg_imm9(s, insn, opc, size, rt, is_vector); | ||
320 | - return; | ||
321 | + break; | ||
322 | } | ||
323 | switch (extract32(insn, 10, 2)) { | ||
324 | case 0: | ||
52 | -- | 325 | -- |
53 | 2.25.1 | 326 | 2.34.1 |
54 | |||
55 | diff view generated by jsdifflib |
1 | From: Patrick Venture <venture@google.com> | 1 | Convert the LDR and STR instructions which use a 12-bit immediate |
---|---|---|---|
2 | offset to decodetree. We can reuse the existing LDR and STR | ||
3 | trans functions for these. | ||
2 | 4 | ||
3 | The rx_active boolean change to true should always trigger a try_read | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | call that flushes the queue. | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20230602155223.2040685-14-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/tcg/a64.decode | 25 ++++++++ | ||
10 | target/arm/tcg/translate-a64.c | 104 +++++---------------------------- | ||
11 | 2 files changed, 41 insertions(+), 88 deletions(-) | ||
5 | 12 | ||
6 | Signed-off-by: Patrick Venture <venture@google.com> | 13 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20211203221002.1719306-1-venture@google.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | hw/net/npcm7xx_emc.c | 18 ++++++++---------- | ||
12 | 1 file changed, 8 insertions(+), 10 deletions(-) | ||
13 | |||
14 | diff --git a/hw/net/npcm7xx_emc.c b/hw/net/npcm7xx_emc.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/net/npcm7xx_emc.c | 15 | --- a/target/arm/tcg/a64.decode |
17 | +++ b/hw/net/npcm7xx_emc.c | 16 | +++ b/target/arm/tcg/a64.decode |
18 | @@ -XXX,XX +XXX,XX @@ static void emc_halt_rx(NPCM7xxEMCState *emc, uint32_t mista_flag) | 17 | @@ -XXX,XX +XXX,XX @@ STR_v_i sz:2 111 1 00 00 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 |
19 | emc_set_mista(emc, mista_flag); | 18 | STR_v_i 00 111 1 00 10 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 ext=0 sz=4 |
20 | } | 19 | LDR_v_i sz:2 111 1 00 01 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 ext=0 |
21 | 20 | LDR_v_i 00 111 1 00 11 0 ......... 11 ..... ..... @ldst_imm_pre sign=0 ext=0 sz=4 | |
22 | +static void emc_enable_rx_and_flush(NPCM7xxEMCState *emc) | 21 | + |
22 | +# Load/store with an unsigned 12 bit immediate, which is scaled by the | ||
23 | +# element size. The function gets the sz:imm and returns the scaled immediate. | ||
24 | +%uimm_scaled 10:12 sz:3 !function=uimm_scaled | ||
25 | + | ||
26 | +@ldst_uimm .. ... . .. .. ............ rn:5 rt:5 &ldst_imm unpriv=0 p=0 w=0 imm=%uimm_scaled | ||
27 | + | ||
28 | +STR_i sz:2 111 0 01 00 ............ ..... ..... @ldst_uimm sign=0 ext=0 | ||
29 | +LDR_i 00 111 0 01 01 ............ ..... ..... @ldst_uimm sign=0 ext=1 sz=0 | ||
30 | +LDR_i 01 111 0 01 01 ............ ..... ..... @ldst_uimm sign=0 ext=1 sz=1 | ||
31 | +LDR_i 10 111 0 01 01 ............ ..... ..... @ldst_uimm sign=0 ext=1 sz=2 | ||
32 | +LDR_i 11 111 0 01 01 ............ ..... ..... @ldst_uimm sign=0 ext=0 sz=3 | ||
33 | +LDR_i 00 111 0 01 10 ............ ..... ..... @ldst_uimm sign=1 ext=0 sz=0 | ||
34 | +LDR_i 01 111 0 01 10 ............ ..... ..... @ldst_uimm sign=1 ext=0 sz=1 | ||
35 | +LDR_i 10 111 0 01 10 ............ ..... ..... @ldst_uimm sign=1 ext=0 sz=2 | ||
36 | +LDR_i 00 111 0 01 11 ............ ..... ..... @ldst_uimm sign=1 ext=1 sz=0 | ||
37 | +LDR_i 01 111 0 01 11 ............ ..... ..... @ldst_uimm sign=1 ext=1 sz=1 | ||
38 | + | ||
39 | +# PRFM | ||
40 | +NOP 11 111 0 01 10 ------------ ----- ----- | ||
41 | + | ||
42 | +STR_v_i sz:2 111 1 01 00 ............ ..... ..... @ldst_uimm sign=0 ext=0 | ||
43 | +STR_v_i 00 111 1 01 10 ............ ..... ..... @ldst_uimm sign=0 ext=0 sz=4 | ||
44 | +LDR_v_i sz:2 111 1 01 01 ............ ..... ..... @ldst_uimm sign=0 ext=0 | ||
45 | +LDR_v_i 00 111 1 01 11 ............ ..... ..... @ldst_uimm sign=0 ext=0 sz=4 | ||
46 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/tcg/translate-a64.c | ||
49 | +++ b/target/arm/tcg/translate-a64.c | ||
50 | @@ -XXX,XX +XXX,XX @@ enum a64_shift_type { | ||
51 | A64_SHIFT_TYPE_ROR = 3 | ||
52 | }; | ||
53 | |||
54 | +/* | ||
55 | + * Helpers for extracting complex instruction fields | ||
56 | + */ | ||
57 | + | ||
58 | +/* | ||
59 | + * For load/store with an unsigned 12 bit immediate scaled by the element | ||
60 | + * size. The input has the immediate field in bits [14:3] and the element | ||
61 | + * size in [2:0]. | ||
62 | + */ | ||
63 | +static int uimm_scaled(DisasContext *s, int x) | ||
23 | +{ | 64 | +{ |
24 | + emc->rx_active = true; | 65 | + unsigned imm = x >> 3; |
25 | + qemu_flush_queued_packets(qemu_get_queue(emc->nic)); | 66 | + unsigned scale = extract32(x, 0, 3); |
67 | + return imm << scale; | ||
26 | +} | 68 | +} |
27 | + | 69 | + |
28 | static void emc_set_next_tx_descriptor(NPCM7xxEMCState *emc, | 70 | /* |
29 | const NPCM7xxEMCTxDesc *tx_desc, | 71 | * Include the generated decoders. |
30 | uint32_t desc_addr) | 72 | */ |
31 | @@ -XXX,XX +XXX,XX @@ static ssize_t emc_receive(NetClientState *nc, const uint8_t *buf, size_t len1) | 73 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_roffset(DisasContext *s, uint32_t insn, |
32 | return len; | 74 | } |
33 | } | 75 | } |
34 | 76 | ||
35 | -static void emc_try_receive_next_packet(NPCM7xxEMCState *emc) | 77 | -/* |
78 | - * Load/store (unsigned immediate) | ||
79 | - * | ||
80 | - * 31 30 29 27 26 25 24 23 22 21 10 9 5 | ||
81 | - * +----+-------+---+-----+-----+------------+-------+------+ | ||
82 | - * |size| 1 1 1 | V | 0 1 | opc | imm12 | Rn | Rt | | ||
83 | - * +----+-------+---+-----+-----+------------+-------+------+ | ||
84 | - * | ||
85 | - * For non-vector: | ||
86 | - * size: 00-> byte, 01 -> 16 bit, 10 -> 32bit, 11 -> 64bit | ||
87 | - * opc: 00 -> store, 01 -> loadu, 10 -> loads 64, 11 -> loads 32 | ||
88 | - * For vector: | ||
89 | - * size is opc<1>:size<1:0> so 100 -> 128 bit; 110 and 111 unallocated | ||
90 | - * opc<0>: 0 -> store, 1 -> load | ||
91 | - * Rn: base address register (inc SP) | ||
92 | - * Rt: target register | ||
93 | - */ | ||
94 | -static void disas_ldst_reg_unsigned_imm(DisasContext *s, uint32_t insn, | ||
95 | - int opc, | ||
96 | - int size, | ||
97 | - int rt, | ||
98 | - bool is_vector) | ||
36 | -{ | 99 | -{ |
37 | - if (emc_can_receive(qemu_get_queue(emc->nic))) { | 100 | - int rn = extract32(insn, 5, 5); |
38 | - qemu_flush_queued_packets(qemu_get_queue(emc->nic)); | 101 | - unsigned int imm12 = extract32(insn, 10, 12); |
102 | - unsigned int offset; | ||
103 | - TCGv_i64 clean_addr, dirty_addr; | ||
104 | - bool is_store; | ||
105 | - bool is_signed = false; | ||
106 | - bool is_extended = false; | ||
107 | - MemOp memop; | ||
108 | - | ||
109 | - if (is_vector) { | ||
110 | - size |= (opc & 2) << 1; | ||
111 | - if (size > 4) { | ||
112 | - unallocated_encoding(s); | ||
113 | - return; | ||
114 | - } | ||
115 | - is_store = !extract32(opc, 0, 1); | ||
116 | - if (!fp_access_check(s)) { | ||
117 | - return; | ||
118 | - } | ||
119 | - memop = finalize_memop_asimd(s, size); | ||
120 | - } else { | ||
121 | - if (size == 3 && opc == 2) { | ||
122 | - /* PRFM - prefetch */ | ||
123 | - return; | ||
124 | - } | ||
125 | - if (opc == 3 && size > 1) { | ||
126 | - unallocated_encoding(s); | ||
127 | - return; | ||
128 | - } | ||
129 | - is_store = (opc == 0); | ||
130 | - is_signed = !is_store && extract32(opc, 1, 1); | ||
131 | - is_extended = (size < 3) && extract32(opc, 0, 1); | ||
132 | - memop = finalize_memop(s, size + is_signed * MO_SIGN); | ||
133 | - } | ||
134 | - | ||
135 | - if (rn == 31) { | ||
136 | - gen_check_sp_alignment(s); | ||
137 | - } | ||
138 | - dirty_addr = read_cpu_reg_sp(s, rn, 1); | ||
139 | - offset = imm12 << size; | ||
140 | - tcg_gen_addi_i64(dirty_addr, dirty_addr, offset); | ||
141 | - | ||
142 | - clean_addr = gen_mte_check1(s, dirty_addr, is_store, rn != 31, memop); | ||
143 | - | ||
144 | - if (is_vector) { | ||
145 | - if (is_store) { | ||
146 | - do_fp_st(s, rt, clean_addr, memop); | ||
147 | - } else { | ||
148 | - do_fp_ld(s, rt, clean_addr, memop); | ||
149 | - } | ||
150 | - } else { | ||
151 | - TCGv_i64 tcg_rt = cpu_reg(s, rt); | ||
152 | - bool iss_sf = disas_ldst_compute_iss_sf(size, is_signed, opc); | ||
153 | - if (is_store) { | ||
154 | - do_gpr_st(s, tcg_rt, clean_addr, memop, true, rt, iss_sf, false); | ||
155 | - } else { | ||
156 | - do_gpr_ld(s, tcg_rt, clean_addr, memop, | ||
157 | - is_extended, true, rt, iss_sf, false); | ||
158 | - } | ||
39 | - } | 159 | - } |
40 | -} | 160 | -} |
41 | - | 161 | - |
42 | static uint64_t npcm7xx_emc_read(void *opaque, hwaddr offset, unsigned size) | 162 | /* Atomic memory operations |
43 | { | 163 | * |
44 | NPCM7xxEMCState *emc = opaque; | 164 | * 31 30 27 26 24 22 21 16 15 12 10 5 0 |
45 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_emc_write(void *opaque, hwaddr offset, | 165 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg(DisasContext *s, uint32_t insn) |
46 | emc->regs[REG_MGSTA] |= REG_MGSTA_RXHA; | 166 | return; |
47 | } | ||
48 | if (value & REG_MCMDR_RXON) { | ||
49 | - emc->rx_active = true; | ||
50 | + emc_enable_rx_and_flush(emc); | ||
51 | } else { | ||
52 | emc_halt_rx(emc, 0); | ||
53 | } | ||
54 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_emc_write(void *opaque, hwaddr offset, | ||
55 | break; | ||
56 | case REG_RSDR: | ||
57 | if (emc->regs[REG_MCMDR] & REG_MCMDR_RXON) { | ||
58 | - emc->rx_active = true; | ||
59 | - emc_try_receive_next_packet(emc); | ||
60 | + emc_enable_rx_and_flush(emc); | ||
61 | } | 167 | } |
62 | break; | 168 | break; |
63 | case REG_MIIDA: | 169 | - case 1: |
170 | - disas_ldst_reg_unsigned_imm(s, insn, opc, size, rt, is_vector); | ||
171 | - return; | ||
172 | } | ||
173 | unallocated_encoding(s); | ||
174 | } | ||
64 | -- | 175 | -- |
65 | 2.25.1 | 176 | 2.34.1 |
66 | |||
67 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | Convert the LDR and STR instructions which take a register |
---|---|---|---|
2 | plus register offset to decodetree. | ||
2 | 3 | ||
3 | We do not support instantiating multiple IOMMUs. Before adding a | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | virtio-iommu, check that no other IOMMU is present. This will detect | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | both "iommu=smmuv3" machine parameter and another virtio-iommu instance. | 6 | Message-id: 20230602155223.2040685-15-peter.maydell@linaro.org |
7 | --- | ||
8 | target/arm/tcg/a64.decode | 22 +++++ | ||
9 | target/arm/tcg/translate-a64.c | 173 +++++++++++++++------------------ | ||
10 | 2 files changed, 103 insertions(+), 92 deletions(-) | ||
6 | 11 | ||
7 | Fixes: 70e89132c9 ("hw/arm/virt: Add the virtio-iommu device tree mappings") | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
8 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
9 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
10 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
11 | Message-id: 20211210170415.583179-4-jean-philippe@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/arm/virt.c | 5 +++++ | ||
15 | 1 file changed, 5 insertions(+) | ||
16 | |||
17 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/virt.c | 14 | --- a/target/arm/tcg/a64.decode |
20 | +++ b/hw/arm/virt.c | 15 | +++ b/target/arm/tcg/a64.decode |
21 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, | 16 | @@ -XXX,XX +XXX,XX @@ STR_v_i sz:2 111 1 01 00 ............ ..... ..... @ldst_uimm sign=0 ext= |
22 | hwaddr db_start = 0, db_end = 0; | 17 | STR_v_i 00 111 1 01 10 ............ ..... ..... @ldst_uimm sign=0 ext=0 sz=4 |
23 | char *resv_prop_str; | 18 | LDR_v_i sz:2 111 1 01 01 ............ ..... ..... @ldst_uimm sign=0 ext=0 |
24 | 19 | LDR_v_i 00 111 1 01 11 ............ ..... ..... @ldst_uimm sign=0 ext=0 sz=4 | |
25 | + if (vms->iommu != VIRT_IOMMU_NONE) { | 20 | + |
26 | + error_setg(errp, "virt machine does not support multiple IOMMUs"); | 21 | +# Load/store with register offset |
27 | + return; | 22 | +&ldst rm rn rt sign ext sz opt s |
28 | + } | 23 | +@ldst .. ... . .. .. . rm:5 opt:3 s:1 .. rn:5 rt:5 &ldst |
29 | + | 24 | +STR sz:2 111 0 00 00 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=0 |
30 | switch (vms->msi_controller) { | 25 | +LDR 00 111 0 00 01 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=1 sz=0 |
31 | case VIRT_MSI_CTRL_NONE: | 26 | +LDR 01 111 0 00 01 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=1 sz=1 |
27 | +LDR 10 111 0 00 01 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=1 sz=2 | ||
28 | +LDR 11 111 0 00 01 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=0 sz=3 | ||
29 | +LDR 00 111 0 00 10 1 ..... ... . 10 ..... ..... @ldst sign=1 ext=0 sz=0 | ||
30 | +LDR 01 111 0 00 10 1 ..... ... . 10 ..... ..... @ldst sign=1 ext=0 sz=1 | ||
31 | +LDR 10 111 0 00 10 1 ..... ... . 10 ..... ..... @ldst sign=1 ext=0 sz=2 | ||
32 | +LDR 00 111 0 00 11 1 ..... ... . 10 ..... ..... @ldst sign=1 ext=1 sz=0 | ||
33 | +LDR 01 111 0 00 11 1 ..... ... . 10 ..... ..... @ldst sign=1 ext=1 sz=1 | ||
34 | + | ||
35 | +# PRFM | ||
36 | +NOP 11 111 0 00 10 1 ----- -1- - 10 ----- ----- | ||
37 | + | ||
38 | +STR_v sz:2 111 1 00 00 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=0 | ||
39 | +STR_v 00 111 1 00 10 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=0 sz=4 | ||
40 | +LDR_v sz:2 111 1 00 01 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=0 | ||
41 | +LDR_v 00 111 1 00 11 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=0 sz=4 | ||
42 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/target/arm/tcg/translate-a64.c | ||
45 | +++ b/target/arm/tcg/translate-a64.c | ||
46 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDR_v_i(DisasContext *s, arg_ldst_imm *a) | ||
47 | return true; | ||
48 | } | ||
49 | |||
50 | -/* | ||
51 | - * Load/store (register offset) | ||
52 | - * | ||
53 | - * 31 30 29 27 26 25 24 23 22 21 20 16 15 13 12 11 10 9 5 4 0 | ||
54 | - * +----+-------+---+-----+-----+---+------+-----+--+-----+----+----+ | ||
55 | - * |size| 1 1 1 | V | 0 0 | opc | 1 | Rm | opt | S| 1 0 | Rn | Rt | | ||
56 | - * +----+-------+---+-----+-----+---+------+-----+--+-----+----+----+ | ||
57 | - * | ||
58 | - * For non-vector: | ||
59 | - * size: 00-> byte, 01 -> 16 bit, 10 -> 32bit, 11 -> 64bit | ||
60 | - * opc: 00 -> store, 01 -> loadu, 10 -> loads 64, 11 -> loads 32 | ||
61 | - * For vector: | ||
62 | - * size is opc<1>:size<1:0> so 100 -> 128 bit; 110 and 111 unallocated | ||
63 | - * opc<0>: 0 -> store, 1 -> load | ||
64 | - * V: 1 -> vector/simd | ||
65 | - * opt: extend encoding (see DecodeRegExtend) | ||
66 | - * S: if S=1 then scale (essentially index by sizeof(size)) | ||
67 | - * Rt: register to transfer into/out of | ||
68 | - * Rn: address register or SP for base | ||
69 | - * Rm: offset register or ZR for offset | ||
70 | - */ | ||
71 | -static void disas_ldst_reg_roffset(DisasContext *s, uint32_t insn, | ||
72 | - int opc, | ||
73 | - int size, | ||
74 | - int rt, | ||
75 | - bool is_vector) | ||
76 | +static void op_addr_ldst_pre(DisasContext *s, arg_ldst *a, | ||
77 | + TCGv_i64 *clean_addr, TCGv_i64 *dirty_addr, | ||
78 | + bool is_store, MemOp memop) | ||
79 | { | ||
80 | - int rn = extract32(insn, 5, 5); | ||
81 | - int shift = extract32(insn, 12, 1); | ||
82 | - int rm = extract32(insn, 16, 5); | ||
83 | - int opt = extract32(insn, 13, 3); | ||
84 | - bool is_signed = false; | ||
85 | - bool is_store = false; | ||
86 | - bool is_extended = false; | ||
87 | - TCGv_i64 tcg_rm, clean_addr, dirty_addr; | ||
88 | - MemOp memop; | ||
89 | + TCGv_i64 tcg_rm; | ||
90 | |||
91 | - if (extract32(opt, 1, 1) == 0) { | ||
92 | - unallocated_encoding(s); | ||
93 | - return; | ||
94 | - } | ||
95 | - | ||
96 | - if (is_vector) { | ||
97 | - size |= (opc & 2) << 1; | ||
98 | - if (size > 4) { | ||
99 | - unallocated_encoding(s); | ||
100 | - return; | ||
101 | - } | ||
102 | - is_store = !extract32(opc, 0, 1); | ||
103 | - if (!fp_access_check(s)) { | ||
104 | - return; | ||
105 | - } | ||
106 | - memop = finalize_memop_asimd(s, size); | ||
107 | - } else { | ||
108 | - if (size == 3 && opc == 2) { | ||
109 | - /* PRFM - prefetch */ | ||
110 | - return; | ||
111 | - } | ||
112 | - if (opc == 3 && size > 1) { | ||
113 | - unallocated_encoding(s); | ||
114 | - return; | ||
115 | - } | ||
116 | - is_store = (opc == 0); | ||
117 | - is_signed = !is_store && extract32(opc, 1, 1); | ||
118 | - is_extended = (size < 3) && extract32(opc, 0, 1); | ||
119 | - memop = finalize_memop(s, size + is_signed * MO_SIGN); | ||
120 | - } | ||
121 | - | ||
122 | - if (rn == 31) { | ||
123 | + if (a->rn == 31) { | ||
124 | gen_check_sp_alignment(s); | ||
125 | } | ||
126 | - dirty_addr = read_cpu_reg_sp(s, rn, 1); | ||
127 | + *dirty_addr = read_cpu_reg_sp(s, a->rn, 1); | ||
128 | |||
129 | - tcg_rm = read_cpu_reg(s, rm, 1); | ||
130 | - ext_and_shift_reg(tcg_rm, tcg_rm, opt, shift ? size : 0); | ||
131 | + tcg_rm = read_cpu_reg(s, a->rm, 1); | ||
132 | + ext_and_shift_reg(tcg_rm, tcg_rm, a->opt, a->s ? a->sz : 0); | ||
133 | |||
134 | - tcg_gen_add_i64(dirty_addr, dirty_addr, tcg_rm); | ||
135 | + tcg_gen_add_i64(*dirty_addr, *dirty_addr, tcg_rm); | ||
136 | + *clean_addr = gen_mte_check1(s, *dirty_addr, is_store, true, memop); | ||
137 | +} | ||
138 | |||
139 | - clean_addr = gen_mte_check1(s, dirty_addr, is_store, true, memop); | ||
140 | +static bool trans_LDR(DisasContext *s, arg_ldst *a) | ||
141 | +{ | ||
142 | + TCGv_i64 clean_addr, dirty_addr, tcg_rt; | ||
143 | + bool iss_sf = ldst_iss_sf(a->sz, a->sign, a->ext); | ||
144 | + MemOp memop; | ||
145 | |||
146 | - if (is_vector) { | ||
147 | - if (is_store) { | ||
148 | - do_fp_st(s, rt, clean_addr, memop); | ||
149 | - } else { | ||
150 | - do_fp_ld(s, rt, clean_addr, memop); | ||
151 | - } | ||
152 | - } else { | ||
153 | - TCGv_i64 tcg_rt = cpu_reg(s, rt); | ||
154 | - bool iss_sf = disas_ldst_compute_iss_sf(size, is_signed, opc); | ||
155 | - | ||
156 | - if (is_store) { | ||
157 | - do_gpr_st(s, tcg_rt, clean_addr, memop, | ||
158 | - true, rt, iss_sf, false); | ||
159 | - } else { | ||
160 | - do_gpr_ld(s, tcg_rt, clean_addr, memop, | ||
161 | - is_extended, true, rt, iss_sf, false); | ||
162 | - } | ||
163 | + if (extract32(a->opt, 1, 1) == 0) { | ||
164 | + return false; | ||
165 | } | ||
166 | + | ||
167 | + memop = finalize_memop(s, a->sz + a->sign * MO_SIGN); | ||
168 | + op_addr_ldst_pre(s, a, &clean_addr, &dirty_addr, false, memop); | ||
169 | + tcg_rt = cpu_reg(s, a->rt); | ||
170 | + do_gpr_ld(s, tcg_rt, clean_addr, memop, | ||
171 | + a->ext, true, a->rt, iss_sf, false); | ||
172 | + return true; | ||
173 | +} | ||
174 | + | ||
175 | +static bool trans_STR(DisasContext *s, arg_ldst *a) | ||
176 | +{ | ||
177 | + TCGv_i64 clean_addr, dirty_addr, tcg_rt; | ||
178 | + bool iss_sf = ldst_iss_sf(a->sz, a->sign, a->ext); | ||
179 | + MemOp memop; | ||
180 | + | ||
181 | + if (extract32(a->opt, 1, 1) == 0) { | ||
182 | + return false; | ||
183 | + } | ||
184 | + | ||
185 | + memop = finalize_memop(s, a->sz); | ||
186 | + op_addr_ldst_pre(s, a, &clean_addr, &dirty_addr, true, memop); | ||
187 | + tcg_rt = cpu_reg(s, a->rt); | ||
188 | + do_gpr_st(s, tcg_rt, clean_addr, memop, true, a->rt, iss_sf, false); | ||
189 | + return true; | ||
190 | +} | ||
191 | + | ||
192 | +static bool trans_LDR_v(DisasContext *s, arg_ldst *a) | ||
193 | +{ | ||
194 | + TCGv_i64 clean_addr, dirty_addr; | ||
195 | + MemOp memop; | ||
196 | + | ||
197 | + if (extract32(a->opt, 1, 1) == 0) { | ||
198 | + return false; | ||
199 | + } | ||
200 | + | ||
201 | + if (!fp_access_check(s)) { | ||
202 | + return true; | ||
203 | + } | ||
204 | + | ||
205 | + memop = finalize_memop_asimd(s, a->sz); | ||
206 | + op_addr_ldst_pre(s, a, &clean_addr, &dirty_addr, false, memop); | ||
207 | + do_fp_ld(s, a->rt, clean_addr, memop); | ||
208 | + return true; | ||
209 | +} | ||
210 | + | ||
211 | +static bool trans_STR_v(DisasContext *s, arg_ldst *a) | ||
212 | +{ | ||
213 | + TCGv_i64 clean_addr, dirty_addr; | ||
214 | + MemOp memop; | ||
215 | + | ||
216 | + if (extract32(a->opt, 1, 1) == 0) { | ||
217 | + return false; | ||
218 | + } | ||
219 | + | ||
220 | + if (!fp_access_check(s)) { | ||
221 | + return true; | ||
222 | + } | ||
223 | + | ||
224 | + memop = finalize_memop_asimd(s, a->sz); | ||
225 | + op_addr_ldst_pre(s, a, &clean_addr, &dirty_addr, true, memop); | ||
226 | + do_fp_st(s, a->rt, clean_addr, memop); | ||
227 | + return true; | ||
228 | } | ||
229 | |||
230 | /* Atomic memory operations | ||
231 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_ldapr_stlr(DisasContext *s, uint32_t insn) | ||
232 | static void disas_ldst_reg(DisasContext *s, uint32_t insn) | ||
233 | { | ||
234 | int rt = extract32(insn, 0, 5); | ||
235 | - int opc = extract32(insn, 22, 2); | ||
236 | bool is_vector = extract32(insn, 26, 1); | ||
237 | int size = extract32(insn, 30, 2); | ||
238 | |||
239 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg(DisasContext *s, uint32_t insn) | ||
240 | disas_ldst_atomic(s, insn, size, rt, is_vector); | ||
241 | return; | ||
242 | case 2: | ||
243 | - disas_ldst_reg_roffset(s, insn, opc, size, rt, is_vector); | ||
244 | - return; | ||
245 | + break; | ||
246 | default: | ||
247 | disas_ldst_pac(s, insn, size, rt, is_vector); | ||
32 | return; | 248 | return; |
33 | -- | 249 | -- |
34 | 2.25.1 | 250 | 2.34.1 |
35 | |||
36 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Convert the insns in the atomic memory operations group to |
---|---|---|---|
2 | decodetree. | ||
2 | 3 | ||
3 | Misaligned thumb PC is architecturally impossible. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Assert is better than proceeding, in case we've missed | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | something somewhere. | 6 | Message-id: 20230602155223.2040685-16-peter.maydell@linaro.org |
7 | --- | ||
8 | target/arm/tcg/a64.decode | 15 ++++ | ||
9 | target/arm/tcg/translate-a64.c | 153 ++++++++++++--------------------- | ||
10 | 2 files changed, 70 insertions(+), 98 deletions(-) | ||
6 | 11 | ||
7 | Expand a comment about aligning the pc in gdbstub. | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
8 | Fail an incoming migrate if a thumb pc is misaligned. | ||
9 | |||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/gdbstub.c | 9 +++++++-- | ||
15 | target/arm/machine.c | 10 ++++++++++ | ||
16 | target/arm/translate.c | 3 +++ | ||
17 | 3 files changed, 20 insertions(+), 2 deletions(-) | ||
18 | |||
19 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/gdbstub.c | 14 | --- a/target/arm/tcg/a64.decode |
22 | +++ b/target/arm/gdbstub.c | 15 | +++ b/target/arm/tcg/a64.decode |
23 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | 16 | @@ -XXX,XX +XXX,XX @@ STR_v sz:2 111 1 00 00 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=0 |
24 | 17 | STR_v 00 111 1 00 10 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=0 sz=4 | |
25 | tmp = ldl_p(mem_buf); | 18 | LDR_v sz:2 111 1 00 01 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=0 |
26 | 19 | LDR_v 00 111 1 00 11 1 ..... ... . 10 ..... ..... @ldst sign=0 ext=0 sz=4 | |
27 | - /* Mask out low bit of PC to workaround gdb bugs. This will probably | 20 | + |
28 | - cause problems if we ever implement the Jazelle DBX extensions. */ | 21 | +# Atomic memory operations |
22 | +&atomic rs rn rt a r sz | ||
23 | +@atomic sz:2 ... . .. a:1 r:1 . rs:5 . ... .. rn:5 rt:5 &atomic | ||
24 | +LDADD .. 111 0 00 . . 1 ..... 0000 00 ..... ..... @atomic | ||
25 | +LDCLR .. 111 0 00 . . 1 ..... 0001 00 ..... ..... @atomic | ||
26 | +LDEOR .. 111 0 00 . . 1 ..... 0010 00 ..... ..... @atomic | ||
27 | +LDSET .. 111 0 00 . . 1 ..... 0011 00 ..... ..... @atomic | ||
28 | +LDSMAX .. 111 0 00 . . 1 ..... 0100 00 ..... ..... @atomic | ||
29 | +LDSMIN .. 111 0 00 . . 1 ..... 0101 00 ..... ..... @atomic | ||
30 | +LDUMAX .. 111 0 00 . . 1 ..... 0110 00 ..... ..... @atomic | ||
31 | +LDUMIN .. 111 0 00 . . 1 ..... 0111 00 ..... ..... @atomic | ||
32 | +SWP .. 111 0 00 . . 1 ..... 1000 00 ..... ..... @atomic | ||
33 | + | ||
34 | +LDAPR sz:2 111 0 00 1 0 1 11111 1100 00 rn:5 rt:5 | ||
35 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/tcg/translate-a64.c | ||
38 | +++ b/target/arm/tcg/translate-a64.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static bool trans_STR_v(DisasContext *s, arg_ldst *a) | ||
40 | return true; | ||
41 | } | ||
42 | |||
43 | -/* Atomic memory operations | ||
44 | - * | ||
45 | - * 31 30 27 26 24 22 21 16 15 12 10 5 0 | ||
46 | - * +------+-------+---+-----+-----+---+----+----+-----+-----+----+-----+ | ||
47 | - * | size | 1 1 1 | V | 0 0 | A R | 1 | Rs | o3 | opc | 0 0 | Rn | Rt | | ||
48 | - * +------+-------+---+-----+-----+--------+----+-----+-----+----+-----+ | ||
49 | - * | ||
50 | - * Rt: the result register | ||
51 | - * Rn: base address or SP | ||
52 | - * Rs: the source register for the operation | ||
53 | - * V: vector flag (always 0 as of v8.3) | ||
54 | - * A: acquire flag | ||
55 | - * R: release flag | ||
56 | - */ | ||
57 | -static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | ||
58 | - int size, int rt, bool is_vector) | ||
59 | + | ||
60 | +static bool do_atomic_ld(DisasContext *s, arg_atomic *a, AtomicThreeOpFn *fn, | ||
61 | + int sign, bool invert) | ||
62 | { | ||
63 | - int rs = extract32(insn, 16, 5); | ||
64 | - int rn = extract32(insn, 5, 5); | ||
65 | - int o3_opc = extract32(insn, 12, 4); | ||
66 | - bool r = extract32(insn, 22, 1); | ||
67 | - bool a = extract32(insn, 23, 1); | ||
68 | - TCGv_i64 tcg_rs, tcg_rt, clean_addr; | ||
69 | - AtomicThreeOpFn *fn = NULL; | ||
70 | - MemOp mop = size; | ||
71 | + MemOp mop = a->sz | sign; | ||
72 | + TCGv_i64 clean_addr, tcg_rs, tcg_rt; | ||
73 | |||
74 | - if (is_vector || !dc_isar_feature(aa64_atomics, s)) { | ||
75 | - unallocated_encoding(s); | ||
76 | - return; | ||
77 | - } | ||
78 | - switch (o3_opc) { | ||
79 | - case 000: /* LDADD */ | ||
80 | - fn = tcg_gen_atomic_fetch_add_i64; | ||
81 | - break; | ||
82 | - case 001: /* LDCLR */ | ||
83 | - fn = tcg_gen_atomic_fetch_and_i64; | ||
84 | - break; | ||
85 | - case 002: /* LDEOR */ | ||
86 | - fn = tcg_gen_atomic_fetch_xor_i64; | ||
87 | - break; | ||
88 | - case 003: /* LDSET */ | ||
89 | - fn = tcg_gen_atomic_fetch_or_i64; | ||
90 | - break; | ||
91 | - case 004: /* LDSMAX */ | ||
92 | - fn = tcg_gen_atomic_fetch_smax_i64; | ||
93 | - mop |= MO_SIGN; | ||
94 | - break; | ||
95 | - case 005: /* LDSMIN */ | ||
96 | - fn = tcg_gen_atomic_fetch_smin_i64; | ||
97 | - mop |= MO_SIGN; | ||
98 | - break; | ||
99 | - case 006: /* LDUMAX */ | ||
100 | - fn = tcg_gen_atomic_fetch_umax_i64; | ||
101 | - break; | ||
102 | - case 007: /* LDUMIN */ | ||
103 | - fn = tcg_gen_atomic_fetch_umin_i64; | ||
104 | - break; | ||
105 | - case 010: /* SWP */ | ||
106 | - fn = tcg_gen_atomic_xchg_i64; | ||
107 | - break; | ||
108 | - case 014: /* LDAPR, LDAPRH, LDAPRB */ | ||
109 | - if (!dc_isar_feature(aa64_rcpc_8_3, s) || | ||
110 | - rs != 31 || a != 1 || r != 0) { | ||
111 | - unallocated_encoding(s); | ||
112 | - return; | ||
113 | - } | ||
114 | - break; | ||
115 | - default: | ||
116 | - unallocated_encoding(s); | ||
117 | - return; | ||
118 | - } | ||
119 | - | ||
120 | - if (rn == 31) { | ||
121 | + if (a->rn == 31) { | ||
122 | gen_check_sp_alignment(s); | ||
123 | } | ||
124 | - | ||
125 | - mop = check_atomic_align(s, rn, mop); | ||
126 | - clean_addr = gen_mte_check1(s, cpu_reg_sp(s, rn), false, rn != 31, mop); | ||
127 | - | ||
128 | - if (o3_opc == 014) { | ||
129 | - /* | ||
130 | - * LDAPR* are a special case because they are a simple load, not a | ||
131 | - * fetch-and-do-something op. | ||
132 | - * The architectural consistency requirements here are weaker than | ||
133 | - * full load-acquire (we only need "load-acquire processor consistent"), | ||
134 | - * but we choose to implement them as full LDAQ. | ||
135 | - */ | ||
136 | - do_gpr_ld(s, cpu_reg(s, rt), clean_addr, mop, false, | ||
137 | - true, rt, disas_ldst_compute_iss_sf(size, false, 0), true); | ||
138 | - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
139 | - return; | ||
140 | - } | ||
141 | - | ||
142 | - tcg_rs = read_cpu_reg(s, rs, true); | ||
143 | - tcg_rt = cpu_reg(s, rt); | ||
144 | - | ||
145 | - if (o3_opc == 1) { /* LDCLR */ | ||
146 | + mop = check_atomic_align(s, a->rn, mop); | ||
147 | + clean_addr = gen_mte_check1(s, cpu_reg_sp(s, a->rn), false, | ||
148 | + a->rn != 31, mop); | ||
149 | + tcg_rs = read_cpu_reg(s, a->rs, true); | ||
150 | + tcg_rt = cpu_reg(s, a->rt); | ||
151 | + if (invert) { | ||
152 | tcg_gen_not_i64(tcg_rs, tcg_rs); | ||
153 | } | ||
154 | - | ||
155 | - /* The tcg atomic primitives are all full barriers. Therefore we | ||
29 | + /* | 156 | + /* |
30 | + * Mask out low bits of PC to workaround gdb bugs. | 157 | + * The tcg atomic primitives are all full barriers. Therefore we |
31 | + * This avoids an assert in thumb_tr_translate_insn, because it is | 158 | * can ignore the Acquire and Release bits of this instruction. |
32 | + * architecturally impossible to misalign the pc. | 159 | */ |
33 | + * This will probably cause problems if we ever implement the | 160 | fn(tcg_rt, clean_addr, tcg_rs, get_mem_index(s), mop); |
34 | + * Jazelle DBX extensions. | 161 | |
35 | + */ | 162 | if (mop & MO_SIGN) { |
36 | if (n == 15) { | 163 | - switch (size) { |
37 | tmp &= ~1; | 164 | + switch (a->sz) { |
38 | } | 165 | case MO_8: |
39 | diff --git a/target/arm/machine.c b/target/arm/machine.c | 166 | tcg_gen_ext8u_i64(tcg_rt, tcg_rt); |
40 | index XXXXXXX..XXXXXXX 100644 | 167 | break; |
41 | --- a/target/arm/machine.c | 168 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, |
42 | +++ b/target/arm/machine.c | 169 | g_assert_not_reached(); |
43 | @@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id) | ||
44 | return -1; | ||
45 | } | 170 | } |
46 | } | 171 | } |
47 | + | 172 | + return true; |
173 | +} | ||
174 | + | ||
175 | +TRANS_FEAT(LDADD, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_add_i64, 0, false) | ||
176 | +TRANS_FEAT(LDCLR, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_and_i64, 0, true) | ||
177 | +TRANS_FEAT(LDEOR, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_xor_i64, 0, false) | ||
178 | +TRANS_FEAT(LDSET, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_or_i64, 0, false) | ||
179 | +TRANS_FEAT(LDSMAX, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_smax_i64, MO_SIGN, false) | ||
180 | +TRANS_FEAT(LDSMIN, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_smin_i64, MO_SIGN, false) | ||
181 | +TRANS_FEAT(LDUMAX, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_umax_i64, 0, false) | ||
182 | +TRANS_FEAT(LDUMIN, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_fetch_umin_i64, 0, false) | ||
183 | +TRANS_FEAT(SWP, aa64_atomics, do_atomic_ld, a, tcg_gen_atomic_xchg_i64, 0, false) | ||
184 | + | ||
185 | +static bool trans_LDAPR(DisasContext *s, arg_LDAPR *a) | ||
186 | +{ | ||
187 | + bool iss_sf = ldst_iss_sf(a->sz, false, false); | ||
188 | + TCGv_i64 clean_addr; | ||
189 | + MemOp mop; | ||
190 | + | ||
191 | + if (!dc_isar_feature(aa64_atomics, s) || | ||
192 | + !dc_isar_feature(aa64_rcpc_8_3, s)) { | ||
193 | + return false; | ||
194 | + } | ||
195 | + if (a->rn == 31) { | ||
196 | + gen_check_sp_alignment(s); | ||
197 | + } | ||
198 | + mop = check_atomic_align(s, a->rn, a->sz); | ||
199 | + clean_addr = gen_mte_check1(s, cpu_reg_sp(s, a->rn), false, | ||
200 | + a->rn != 31, mop); | ||
48 | + /* | 201 | + /* |
49 | + * Misaligned thumb pc is architecturally impossible. | 202 | + * LDAPR* are a special case because they are a simple load, not a |
50 | + * We have an assert in thumb_tr_translate_insn to verify this. | 203 | + * fetch-and-do-something op. |
51 | + * Fail an incoming migrate to avoid this assert. | 204 | + * The architectural consistency requirements here are weaker than |
205 | + * full load-acquire (we only need "load-acquire processor consistent"), | ||
206 | + * but we choose to implement them as full LDAQ. | ||
52 | + */ | 207 | + */ |
53 | + if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) { | 208 | + do_gpr_ld(s, cpu_reg(s, a->rt), clean_addr, mop, false, |
54 | + return -1; | 209 | + true, a->rt, iss_sf, true); |
55 | + } | 210 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); |
56 | + | 211 | + return true; |
57 | if (!kvm_enabled()) { | 212 | } |
58 | pmu_op_finish(&cpu->env); | 213 | |
59 | } | 214 | /* |
60 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 215 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg(DisasContext *s, uint32_t insn) |
61 | index XXXXXXX..XXXXXXX 100644 | 216 | } |
62 | --- a/target/arm/translate.c | 217 | switch (extract32(insn, 10, 2)) { |
63 | +++ b/target/arm/translate.c | 218 | case 0: |
64 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 219 | - disas_ldst_atomic(s, insn, size, rt, is_vector); |
65 | uint32_t insn; | 220 | - return; |
66 | bool is_16bit; | 221 | case 2: |
67 | 222 | break; | |
68 | + /* Misaligned thumb PC is architecturally impossible. */ | 223 | default: |
69 | + assert((dc->base.pc_next & 1) == 0); | ||
70 | + | ||
71 | if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { | ||
72 | dc->base.pc_next = pc + 2; | ||
73 | return; | ||
74 | -- | 224 | -- |
75 | 2.25.1 | 225 | 2.34.1 |
76 | |||
77 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Convert the instructions in the load/store register (pointer |
---|---|---|---|
2 | authentication) group ot decodetree: LDRAA, LDRAB. | ||
2 | 3 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20230602155223.2040685-17-peter.maydell@linaro.org | ||
6 | --- | 8 | --- |
7 | target/arm/translate.c | 16 ++++++++-------- | 9 | target/arm/tcg/a64.decode | 7 +++ |
8 | 1 file changed, 8 insertions(+), 8 deletions(-) | 10 | target/arm/tcg/translate-a64.c | 83 +++++++--------------------------- |
11 | 2 files changed, 23 insertions(+), 67 deletions(-) | ||
9 | 12 | ||
10 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 13 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
11 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/target/arm/translate.c | 15 | --- a/target/arm/tcg/a64.decode |
13 | +++ b/target/arm/translate.c | 16 | +++ b/target/arm/tcg/a64.decode |
14 | @@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 17 | @@ -XXX,XX +XXX,XX @@ LDUMIN .. 111 0 00 . . 1 ..... 0111 00 ..... ..... @atomic |
18 | SWP .. 111 0 00 . . 1 ..... 1000 00 ..... ..... @atomic | ||
19 | |||
20 | LDAPR sz:2 111 0 00 1 0 1 11111 1100 00 rn:5 rt:5 | ||
21 | + | ||
22 | +# Load/store register (pointer authentication) | ||
23 | + | ||
24 | +# LDRA immediate is 10 bits signed and scaled, but the bits aren't all contiguous | ||
25 | +%ldra_imm 22:s1 12:9 !function=times_2 | ||
26 | + | ||
27 | +LDRA 11 111 0 00 m:1 . 1 ......... w:1 1 rn:5 rt:5 imm=%ldra_imm | ||
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_LDAPR(DisasContext *s, arg_LDAPR *a) | ||
33 | return true; | ||
34 | } | ||
35 | |||
36 | -/* | ||
37 | - * PAC memory operations | ||
38 | - * | ||
39 | - * 31 30 27 26 24 22 21 12 11 10 5 0 | ||
40 | - * +------+-------+---+-----+-----+---+--------+---+---+----+-----+ | ||
41 | - * | size | 1 1 1 | V | 0 0 | M S | 1 | imm9 | W | 1 | Rn | Rt | | ||
42 | - * +------+-------+---+-----+-----+---+--------+---+---+----+-----+ | ||
43 | - * | ||
44 | - * Rt: the result register | ||
45 | - * Rn: base address or SP | ||
46 | - * V: vector flag (always 0 as of v8.3) | ||
47 | - * M: clear for key DA, set for key DB | ||
48 | - * W: pre-indexing flag | ||
49 | - * S: sign for imm9. | ||
50 | - */ | ||
51 | -static void disas_ldst_pac(DisasContext *s, uint32_t insn, | ||
52 | - int size, int rt, bool is_vector) | ||
53 | +static bool trans_LDRA(DisasContext *s, arg_LDRA *a) | ||
15 | { | 54 | { |
16 | DisasContext *dc = container_of(dcbase, DisasContext, base); | 55 | - int rn = extract32(insn, 5, 5); |
17 | CPUARMState *env = cpu->env_ptr; | 56 | - bool is_wback = extract32(insn, 11, 1); |
18 | + uint32_t pc = dc->base.pc_next; | 57 | - bool use_key_a = !extract32(insn, 23, 1); |
19 | uint32_t insn; | 58 | - int offset; |
20 | bool is_16bit; | 59 | TCGv_i64 clean_addr, dirty_addr, tcg_rt; |
21 | 60 | MemOp memop; | |
22 | if (arm_pre_translate_insn(dc)) { | 61 | |
23 | - dc->base.pc_next += 2; | 62 | - if (size != 3 || is_vector || !dc_isar_feature(aa64_pauth, s)) { |
24 | + dc->base.pc_next = pc + 2; | 63 | - unallocated_encoding(s); |
25 | return; | 64 | - return; |
65 | + /* Load with pointer authentication */ | ||
66 | + if (!dc_isar_feature(aa64_pauth, s)) { | ||
67 | + return false; | ||
26 | } | 68 | } |
27 | 69 | ||
28 | - dc->pc_curr = dc->base.pc_next; | 70 | - if (rn == 31) { |
29 | - insn = arm_lduw_code(env, &dc->base, dc->base.pc_next, dc->sctlr_b); | 71 | + if (a->rn == 31) { |
30 | + dc->pc_curr = pc; | 72 | gen_check_sp_alignment(s); |
31 | + insn = arm_lduw_code(env, &dc->base, pc, dc->sctlr_b); | 73 | } |
32 | is_16bit = thumb_insn_is_16bit(dc, dc->base.pc_next, insn); | 74 | - dirty_addr = read_cpu_reg_sp(s, rn, 1); |
33 | - dc->base.pc_next += 2; | 75 | + dirty_addr = read_cpu_reg_sp(s, a->rn, 1); |
34 | + pc += 2; | 76 | |
35 | if (!is_16bit) { | 77 | if (s->pauth_active) { |
36 | - uint32_t insn2 = arm_lduw_code(env, &dc->base, dc->base.pc_next, | 78 | - if (use_key_a) { |
37 | - dc->sctlr_b); | 79 | + if (!a->m) { |
80 | gen_helper_autda(dirty_addr, cpu_env, dirty_addr, | ||
81 | tcg_constant_i64(0)); | ||
82 | } else { | ||
83 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_pac(DisasContext *s, uint32_t insn, | ||
84 | } | ||
85 | } | ||
86 | |||
87 | - /* Form the 10-bit signed, scaled offset. */ | ||
88 | - offset = (extract32(insn, 22, 1) << 9) | extract32(insn, 12, 9); | ||
89 | - offset = sextract32(offset << size, 0, 10 + size); | ||
90 | - tcg_gen_addi_i64(dirty_addr, dirty_addr, offset); | ||
91 | + tcg_gen_addi_i64(dirty_addr, dirty_addr, a->imm); | ||
92 | |||
93 | - memop = finalize_memop(s, size); | ||
94 | + memop = finalize_memop(s, MO_64); | ||
95 | |||
96 | /* Note that "clean" and "dirty" here refer to TBI not PAC. */ | ||
97 | clean_addr = gen_mte_check1(s, dirty_addr, false, | ||
98 | - is_wback || rn != 31, memop); | ||
99 | + a->w || a->rn != 31, memop); | ||
100 | |||
101 | - tcg_rt = cpu_reg(s, rt); | ||
102 | + tcg_rt = cpu_reg(s, a->rt); | ||
103 | do_gpr_ld(s, tcg_rt, clean_addr, memop, | ||
104 | - /* extend */ false, /* iss_valid */ !is_wback, | ||
105 | - /* iss_srt */ rt, /* iss_sf */ true, /* iss_ar */ false); | ||
106 | + /* extend */ false, /* iss_valid */ !a->w, | ||
107 | + /* iss_srt */ a->rt, /* iss_sf */ true, /* iss_ar */ false); | ||
108 | |||
109 | - if (is_wback) { | ||
110 | - tcg_gen_mov_i64(cpu_reg_sp(s, rn), dirty_addr); | ||
111 | + if (a->w) { | ||
112 | + tcg_gen_mov_i64(cpu_reg_sp(s, a->rn), dirty_addr); | ||
113 | } | ||
114 | + return true; | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_ldapr_stlr(DisasContext *s, uint32_t insn) | ||
119 | } | ||
120 | } | ||
121 | |||
122 | -/* Load/store register (all forms) */ | ||
123 | -static void disas_ldst_reg(DisasContext *s, uint32_t insn) | ||
124 | -{ | ||
125 | - int rt = extract32(insn, 0, 5); | ||
126 | - bool is_vector = extract32(insn, 26, 1); | ||
127 | - int size = extract32(insn, 30, 2); | ||
38 | - | 128 | - |
39 | + uint32_t insn2 = arm_lduw_code(env, &dc->base, pc, dc->sctlr_b); | 129 | - switch (extract32(insn, 24, 2)) { |
40 | insn = insn << 16 | insn2; | 130 | - case 0: |
41 | - dc->base.pc_next += 2; | 131 | - if (extract32(insn, 21, 1) == 0) { |
42 | + pc += 2; | 132 | - break; |
43 | } | 133 | - } |
44 | + dc->base.pc_next = pc; | 134 | - switch (extract32(insn, 10, 2)) { |
45 | dc->insn = insn; | 135 | - case 0: |
46 | 136 | - case 2: | |
47 | if (dc->pstate_il) { | 137 | - break; |
138 | - default: | ||
139 | - disas_ldst_pac(s, insn, size, rt, is_vector); | ||
140 | - return; | ||
141 | - } | ||
142 | - break; | ||
143 | - } | ||
144 | - unallocated_encoding(s); | ||
145 | -} | ||
146 | - | ||
147 | /* AdvSIMD load/store multiple structures | ||
148 | * | ||
149 | * 31 30 29 23 22 21 16 15 12 11 10 9 5 4 0 | ||
150 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_tag(DisasContext *s, uint32_t insn) | ||
151 | static void disas_ldst(DisasContext *s, uint32_t insn) | ||
152 | { | ||
153 | switch (extract32(insn, 24, 6)) { | ||
154 | - case 0x38: case 0x39: | ||
155 | - case 0x3c: case 0x3d: /* Load/store register (all forms) */ | ||
156 | - disas_ldst_reg(s, insn); | ||
157 | - break; | ||
158 | case 0x0c: /* AdvSIMD load/store multiple structures */ | ||
159 | disas_ldst_multiple_struct(s, insn); | ||
160 | break; | ||
48 | -- | 161 | -- |
49 | 2.25.1 | 162 | 2.34.1 |
50 | 163 | ||
51 | 164 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | Convert the instructions in the LDAPR/STLR (unscaled immediate) |
---|---|---|---|
2 | group to decodetree. | ||
2 | 3 | ||
3 | The TYPE_ARM_GICV3 device is an emulated one. When using | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | KVM, it is recommended to use the TYPE_KVM_ARM_GICV3 device | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | (which uses in-kernel support). | 6 | Message-id: 20230602155223.2040685-18-peter.maydell@linaro.org |
7 | --- | ||
8 | target/arm/tcg/a64.decode | 10 +++ | ||
9 | target/arm/tcg/translate-a64.c | 132 ++++++++++++--------------------- | ||
10 | 2 files changed, 56 insertions(+), 86 deletions(-) | ||
6 | 11 | ||
7 | When using --with-devices-FOO, it is possible to build a | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
8 | binary with a specific set of devices. When this binary is | ||
9 | restricted to KVM accelerator, the TYPE_ARM_GICV3 device is | ||
10 | irrelevant, and it is desirable to remove it from the binary. | ||
11 | |||
12 | Therefore introduce the CONFIG_ARM_GIC_TCG Kconfig selector | ||
13 | which select the files required to have the TYPE_ARM_GICV3 | ||
14 | device, but also allowing to de-select this device. | ||
15 | |||
16 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Message-id: 20211115223619.2599282-3-philmd@redhat.com | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | hw/intc/arm_gicv3.c | 2 +- | ||
22 | hw/intc/Kconfig | 5 +++++ | ||
23 | hw/intc/meson.build | 10 ++++++---- | ||
24 | 3 files changed, 12 insertions(+), 5 deletions(-) | ||
25 | |||
26 | diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/intc/arm_gicv3.c | 14 | --- a/target/arm/tcg/a64.decode |
29 | +++ b/hw/intc/arm_gicv3.c | 15 | +++ b/target/arm/tcg/a64.decode |
30 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ LDAPR sz:2 111 0 00 1 0 1 11111 1100 00 rn:5 rt:5 |
31 | /* | 17 | %ldra_imm 22:s1 12:9 !function=times_2 |
32 | - * ARM Generic Interrupt Controller v3 | 18 | |
33 | + * ARM Generic Interrupt Controller v3 (emulation) | 19 | LDRA 11 111 0 00 m:1 . 1 ......... w:1 1 rn:5 rt:5 imm=%ldra_imm |
34 | * | 20 | + |
35 | * Copyright (c) 2015 Huawei. | 21 | +&ldapr_stlr_i rn rt imm sz sign ext |
36 | * Copyright (c) 2016 Linaro Limited | 22 | +@ldapr_stlr_i .. ...... .. . imm:9 .. rn:5 rt:5 &ldapr_stlr_i |
37 | diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig | 23 | +STLR_i sz:2 011001 00 0 ......... 00 ..... ..... @ldapr_stlr_i sign=0 ext=0 |
24 | +LDAPR_i sz:2 011001 01 0 ......... 00 ..... ..... @ldapr_stlr_i sign=0 ext=0 | ||
25 | +LDAPR_i 00 011001 10 0 ......... 00 ..... ..... @ldapr_stlr_i sign=1 ext=0 sz=0 | ||
26 | +LDAPR_i 01 011001 10 0 ......... 00 ..... ..... @ldapr_stlr_i sign=1 ext=0 sz=1 | ||
27 | +LDAPR_i 10 011001 10 0 ......... 00 ..... ..... @ldapr_stlr_i sign=1 ext=0 sz=2 | ||
28 | +LDAPR_i 00 011001 11 0 ......... 00 ..... ..... @ldapr_stlr_i sign=1 ext=1 sz=0 | ||
29 | +LDAPR_i 01 011001 11 0 ......... 00 ..... ..... @ldapr_stlr_i sign=1 ext=1 sz=1 | ||
30 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/hw/intc/Kconfig | 32 | --- a/target/arm/tcg/translate-a64.c |
40 | +++ b/hw/intc/Kconfig | 33 | +++ b/target/arm/tcg/translate-a64.c |
41 | @@ -XXX,XX +XXX,XX @@ config APIC | 34 | @@ -XXX,XX +XXX,XX @@ static void gen_compare_and_swap_pair(DisasContext *s, int rs, int rt, |
42 | select MSI_NONBROKEN | 35 | } |
43 | select I8259 | 36 | } |
44 | 37 | ||
45 | +config ARM_GIC_TCG | 38 | -/* Update the Sixty-Four bit (SF) registersize. This logic is derived |
46 | + bool | 39 | +/* |
47 | + default y | 40 | + * Compute the ISS.SF bit for syndrome information if an exception |
48 | + depends on ARM_GIC && TCG | 41 | + * is taken on a load or store. This indicates whether the instruction |
49 | + | 42 | + * is accessing a 32-bit or 64-bit register. This logic is derived |
50 | config ARM_GIC_KVM | 43 | * from the ARMv8 specs for LDR (Shared decode for all encodings). |
51 | bool | 44 | */ |
52 | default y | 45 | -static bool disas_ldst_compute_iss_sf(int size, bool is_signed, int opc) |
53 | diff --git a/hw/intc/meson.build b/hw/intc/meson.build | 46 | -{ |
54 | index XXXXXXX..XXXXXXX 100644 | 47 | - int opc0 = extract32(opc, 0, 1); |
55 | --- a/hw/intc/meson.build | 48 | - int regsize; |
56 | +++ b/hw/intc/meson.build | 49 | - |
57 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARM_GIC', if_true: files( | 50 | - if (is_signed) { |
58 | 'arm_gic.c', | 51 | - regsize = opc0 ? 32 : 64; |
59 | 'arm_gic_common.c', | 52 | - } else { |
60 | 'arm_gicv2m.c', | 53 | - regsize = size == 3 ? 64 : 32; |
61 | - 'arm_gicv3.c', | 54 | - } |
62 | 'arm_gicv3_common.c', | 55 | - return regsize == 64; |
63 | - 'arm_gicv3_dist.c', | 56 | -} |
64 | 'arm_gicv3_its_common.c', | 57 | - |
65 | - 'arm_gicv3_redist.c', | 58 | static bool ldst_iss_sf(int size, bool sign, bool ext) |
66 | +)) | 59 | { |
67 | +softmmu_ss.add(when: 'CONFIG_ARM_GIC_TCG', if_true: files( | 60 | |
68 | + 'arm_gicv3.c', | 61 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDRA(DisasContext *s, arg_LDRA *a) |
69 | + 'arm_gicv3_dist.c', | 62 | return true; |
70 | 'arm_gicv3_its.c', | 63 | } |
71 | + 'arm_gicv3_redist.c', | 64 | |
72 | )) | 65 | -/* |
73 | softmmu_ss.add(when: 'CONFIG_ETRAXFS', if_true: files('etraxfs_pic.c')) | 66 | - * LDAPR/STLR (unscaled immediate) |
74 | softmmu_ss.add(when: 'CONFIG_HEATHROW_PIC', if_true: files('heathrow_pic.c')) | 67 | - * |
75 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true: files('xlnx-pmu-iomod-in | 68 | - * 31 30 24 22 21 12 10 5 0 |
76 | specific_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: files('allwinner-a10-pic.c')) | 69 | - * +------+-------------+-----+---+--------+-----+----+-----+ |
77 | specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic.c', 'apic_common.c')) | 70 | - * | size | 0 1 1 0 0 1 | opc | 0 | imm9 | 0 0 | Rn | Rt | |
78 | specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif_common.c')) | 71 | - * +------+-------------+-----+---+--------+-----+----+-----+ |
79 | -specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif.c')) | 72 | - * |
80 | +specific_ss.add(when: 'CONFIG_ARM_GIC_TCG', if_true: files('arm_gicv3_cpuif.c')) | 73 | - * Rt: source or destination register |
81 | specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true: files('arm_gic_kvm.c')) | 74 | - * Rn: base register |
82 | specific_ss.add(when: ['CONFIG_ARM_GIC_KVM', 'TARGET_AARCH64'], if_true: files('arm_gicv3_kvm.c', 'arm_gicv3_its_kvm.c')) | 75 | - * imm9: unscaled immediate offset |
83 | specific_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_nvic.c')) | 76 | - * opc: 00: STLUR*, 01/10/11: various LDAPUR* |
77 | - * size: size of load/store | ||
78 | - */ | ||
79 | -static void disas_ldst_ldapr_stlr(DisasContext *s, uint32_t insn) | ||
80 | +static bool trans_LDAPR_i(DisasContext *s, arg_ldapr_stlr_i *a) | ||
81 | { | ||
82 | - int rt = extract32(insn, 0, 5); | ||
83 | - int rn = extract32(insn, 5, 5); | ||
84 | - int offset = sextract32(insn, 12, 9); | ||
85 | - int opc = extract32(insn, 22, 2); | ||
86 | - int size = extract32(insn, 30, 2); | ||
87 | TCGv_i64 clean_addr, dirty_addr; | ||
88 | - bool is_store = false; | ||
89 | - bool extend = false; | ||
90 | - bool iss_sf; | ||
91 | - MemOp mop = size; | ||
92 | + MemOp mop = a->sz | (a->sign ? MO_SIGN : 0); | ||
93 | + bool iss_sf = ldst_iss_sf(a->sz, a->sign, a->ext); | ||
94 | |||
95 | if (!dc_isar_feature(aa64_rcpc_8_4, s)) { | ||
96 | - unallocated_encoding(s); | ||
97 | - return; | ||
98 | + return false; | ||
99 | } | ||
100 | |||
101 | - switch (opc) { | ||
102 | - case 0: /* STLURB */ | ||
103 | - is_store = true; | ||
104 | - break; | ||
105 | - case 1: /* LDAPUR* */ | ||
106 | - break; | ||
107 | - case 2: /* LDAPURS* 64-bit variant */ | ||
108 | - if (size == 3) { | ||
109 | - unallocated_encoding(s); | ||
110 | - return; | ||
111 | - } | ||
112 | - mop |= MO_SIGN; | ||
113 | - break; | ||
114 | - case 3: /* LDAPURS* 32-bit variant */ | ||
115 | - if (size > 1) { | ||
116 | - unallocated_encoding(s); | ||
117 | - return; | ||
118 | - } | ||
119 | - mop |= MO_SIGN; | ||
120 | - extend = true; /* zero-extend 32->64 after signed load */ | ||
121 | - break; | ||
122 | - default: | ||
123 | - g_assert_not_reached(); | ||
124 | - } | ||
125 | - | ||
126 | - iss_sf = disas_ldst_compute_iss_sf(size, (mop & MO_SIGN) != 0, opc); | ||
127 | - | ||
128 | - if (rn == 31) { | ||
129 | + if (a->rn == 31) { | ||
130 | gen_check_sp_alignment(s); | ||
131 | } | ||
132 | |||
133 | - mop = check_ordered_align(s, rn, offset, is_store, mop); | ||
134 | - | ||
135 | - dirty_addr = read_cpu_reg_sp(s, rn, 1); | ||
136 | - tcg_gen_addi_i64(dirty_addr, dirty_addr, offset); | ||
137 | + mop = check_ordered_align(s, a->rn, a->imm, false, mop); | ||
138 | + dirty_addr = read_cpu_reg_sp(s, a->rn, 1); | ||
139 | + tcg_gen_addi_i64(dirty_addr, dirty_addr, a->imm); | ||
140 | clean_addr = clean_data_tbi(s, dirty_addr); | ||
141 | |||
142 | - if (is_store) { | ||
143 | - /* Store-Release semantics */ | ||
144 | - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | ||
145 | - do_gpr_st(s, cpu_reg(s, rt), clean_addr, mop, true, rt, iss_sf, true); | ||
146 | - } else { | ||
147 | - /* | ||
148 | - * Load-AcquirePC semantics; we implement as the slightly more | ||
149 | - * restrictive Load-Acquire. | ||
150 | - */ | ||
151 | - do_gpr_ld(s, cpu_reg(s, rt), clean_addr, mop, | ||
152 | - extend, true, rt, iss_sf, true); | ||
153 | - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
154 | + /* | ||
155 | + * Load-AcquirePC semantics; we implement as the slightly more | ||
156 | + * restrictive Load-Acquire. | ||
157 | + */ | ||
158 | + do_gpr_ld(s, cpu_reg(s, a->rt), clean_addr, mop, a->ext, true, | ||
159 | + a->rt, iss_sf, true); | ||
160 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); | ||
161 | + return true; | ||
162 | +} | ||
163 | + | ||
164 | +static bool trans_STLR_i(DisasContext *s, arg_ldapr_stlr_i *a) | ||
165 | +{ | ||
166 | + TCGv_i64 clean_addr, dirty_addr; | ||
167 | + MemOp mop = a->sz; | ||
168 | + bool iss_sf = ldst_iss_sf(a->sz, a->sign, a->ext); | ||
169 | + | ||
170 | + if (!dc_isar_feature(aa64_rcpc_8_4, s)) { | ||
171 | + return false; | ||
172 | } | ||
173 | + | ||
174 | + /* TODO: ARMv8.4-LSE SCTLR.nAA */ | ||
175 | + | ||
176 | + if (a->rn == 31) { | ||
177 | + gen_check_sp_alignment(s); | ||
178 | + } | ||
179 | + | ||
180 | + mop = check_ordered_align(s, a->rn, a->imm, true, mop); | ||
181 | + dirty_addr = read_cpu_reg_sp(s, a->rn, 1); | ||
182 | + tcg_gen_addi_i64(dirty_addr, dirty_addr, a->imm); | ||
183 | + clean_addr = clean_data_tbi(s, dirty_addr); | ||
184 | + | ||
185 | + /* Store-Release semantics */ | ||
186 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); | ||
187 | + do_gpr_st(s, cpu_reg(s, a->rt), clean_addr, mop, true, a->rt, iss_sf, true); | ||
188 | + return true; | ||
189 | } | ||
190 | |||
191 | /* AdvSIMD load/store multiple structures | ||
192 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst(DisasContext *s, uint32_t insn) | ||
193 | case 0x19: | ||
194 | if (extract32(insn, 21, 1) != 0) { | ||
195 | disas_ldst_tag(s, insn); | ||
196 | - } else if (extract32(insn, 10, 2) == 0) { | ||
197 | - disas_ldst_ldapr_stlr(s, insn); | ||
198 | } else { | ||
199 | unallocated_encoding(s); | ||
200 | } | ||
84 | -- | 201 | -- |
85 | 2.25.1 | 202 | 2.34.1 |
86 | |||
87 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Convert the instructions in the ASIMD load/store multiple structures |
---|---|---|---|
2 | instruction classes to decodetree. | ||
2 | 3 | ||
3 | Both single-step and pc alignment faults have priority over | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | breakpoint exceptions. | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20230602155223.2040685-19-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/tcg/a64.decode | 20 +++ | ||
9 | target/arm/tcg/translate-a64.c | 222 ++++++++++++++++----------------- | ||
10 | 2 files changed, 131 insertions(+), 111 deletions(-) | ||
5 | 11 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/debug_helper.c | 23 +++++++++++++++++++++++ | ||
11 | 1 file changed, 23 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/debug_helper.c | 14 | --- a/target/arm/tcg/a64.decode |
16 | +++ b/target/arm/debug_helper.c | 15 | +++ b/target/arm/tcg/a64.decode |
17 | @@ -XXX,XX +XXX,XX @@ bool arm_debug_check_breakpoint(CPUState *cs) | 16 | @@ -XXX,XX +XXX,XX @@ LDAPR_i 01 011001 10 0 ......... 00 ..... ..... @ldapr_stlr_i sign=1 ext |
17 | LDAPR_i 10 011001 10 0 ......... 00 ..... ..... @ldapr_stlr_i sign=1 ext=0 sz=2 | ||
18 | LDAPR_i 00 011001 11 0 ......... 00 ..... ..... @ldapr_stlr_i sign=1 ext=1 sz=0 | ||
19 | LDAPR_i 01 011001 11 0 ......... 00 ..... ..... @ldapr_stlr_i sign=1 ext=1 sz=1 | ||
20 | + | ||
21 | +# Load/store multiple structures | ||
22 | +# The 4-bit opcode in [15:12] encodes repeat count and structure elements | ||
23 | +&ldst_mult rm rn rt sz q p rpt selem | ||
24 | +@ldst_mult . q:1 ...... p:1 . . rm:5 .... sz:2 rn:5 rt:5 &ldst_mult | ||
25 | +ST_mult 0 . 001100 . 0 0 ..... 0000 .. ..... ..... @ldst_mult rpt=1 selem=4 | ||
26 | +ST_mult 0 . 001100 . 0 0 ..... 0010 .. ..... ..... @ldst_mult rpt=4 selem=1 | ||
27 | +ST_mult 0 . 001100 . 0 0 ..... 0100 .. ..... ..... @ldst_mult rpt=1 selem=3 | ||
28 | +ST_mult 0 . 001100 . 0 0 ..... 0110 .. ..... ..... @ldst_mult rpt=3 selem=1 | ||
29 | +ST_mult 0 . 001100 . 0 0 ..... 0111 .. ..... ..... @ldst_mult rpt=1 selem=1 | ||
30 | +ST_mult 0 . 001100 . 0 0 ..... 1000 .. ..... ..... @ldst_mult rpt=1 selem=2 | ||
31 | +ST_mult 0 . 001100 . 0 0 ..... 1010 .. ..... ..... @ldst_mult rpt=2 selem=1 | ||
32 | + | ||
33 | +LD_mult 0 . 001100 . 1 0 ..... 0000 .. ..... ..... @ldst_mult rpt=1 selem=4 | ||
34 | +LD_mult 0 . 001100 . 1 0 ..... 0010 .. ..... ..... @ldst_mult rpt=4 selem=1 | ||
35 | +LD_mult 0 . 001100 . 1 0 ..... 0100 .. ..... ..... @ldst_mult rpt=1 selem=3 | ||
36 | +LD_mult 0 . 001100 . 1 0 ..... 0110 .. ..... ..... @ldst_mult rpt=3 selem=1 | ||
37 | +LD_mult 0 . 001100 . 1 0 ..... 0111 .. ..... ..... @ldst_mult rpt=1 selem=1 | ||
38 | +LD_mult 0 . 001100 . 1 0 ..... 1000 .. ..... ..... @ldst_mult rpt=1 selem=2 | ||
39 | +LD_mult 0 . 001100 . 1 0 ..... 1010 .. ..... ..... @ldst_mult rpt=2 selem=1 | ||
40 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/target/arm/tcg/translate-a64.c | ||
43 | +++ b/target/arm/tcg/translate-a64.c | ||
44 | @@ -XXX,XX +XXX,XX @@ static bool trans_STLR_i(DisasContext *s, arg_ldapr_stlr_i *a) | ||
45 | return true; | ||
46 | } | ||
47 | |||
48 | -/* AdvSIMD load/store multiple structures | ||
49 | - * | ||
50 | - * 31 30 29 23 22 21 16 15 12 11 10 9 5 4 0 | ||
51 | - * +---+---+---------------+---+-------------+--------+------+------+------+ | ||
52 | - * | 0 | Q | 0 0 1 1 0 0 0 | L | 0 0 0 0 0 0 | opcode | size | Rn | Rt | | ||
53 | - * +---+---+---------------+---+-------------+--------+------+------+------+ | ||
54 | - * | ||
55 | - * AdvSIMD load/store multiple structures (post-indexed) | ||
56 | - * | ||
57 | - * 31 30 29 23 22 21 20 16 15 12 11 10 9 5 4 0 | ||
58 | - * +---+---+---------------+---+---+---------+--------+------+------+------+ | ||
59 | - * | 0 | Q | 0 0 1 1 0 0 1 | L | 0 | Rm | opcode | size | Rn | Rt | | ||
60 | - * +---+---+---------------+---+---+---------+--------+------+------+------+ | ||
61 | - * | ||
62 | - * Rt: first (or only) SIMD&FP register to be transferred | ||
63 | - * Rn: base address or SP | ||
64 | - * Rm (post-index only): post-index register (when !31) or size dependent #imm | ||
65 | - */ | ||
66 | -static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
67 | +static bool trans_LD_mult(DisasContext *s, arg_ldst_mult *a) | ||
18 | { | 68 | { |
19 | ARMCPU *cpu = ARM_CPU(cs); | 69 | - int rt = extract32(insn, 0, 5); |
20 | CPUARMState *env = &cpu->env; | 70 | - int rn = extract32(insn, 5, 5); |
21 | + target_ulong pc; | 71 | - int rm = extract32(insn, 16, 5); |
22 | int n; | 72 | - int size = extract32(insn, 10, 2); |
73 | - int opcode = extract32(insn, 12, 4); | ||
74 | - bool is_store = !extract32(insn, 22, 1); | ||
75 | - bool is_postidx = extract32(insn, 23, 1); | ||
76 | - bool is_q = extract32(insn, 30, 1); | ||
77 | TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; | ||
78 | MemOp endian, align, mop; | ||
79 | |||
80 | int total; /* total bytes */ | ||
81 | int elements; /* elements per vector */ | ||
82 | - int rpt; /* num iterations */ | ||
83 | - int selem; /* structure elements */ | ||
84 | int r; | ||
85 | + int size = a->sz; | ||
86 | |||
87 | - if (extract32(insn, 31, 1) || extract32(insn, 21, 1)) { | ||
88 | - unallocated_encoding(s); | ||
89 | - return; | ||
90 | + if (!a->p && a->rm != 0) { | ||
91 | + /* For non-postindexed accesses the Rm field must be 0 */ | ||
92 | + return false; | ||
93 | } | ||
94 | - | ||
95 | - if (!is_postidx && rm != 0) { | ||
96 | - unallocated_encoding(s); | ||
97 | - return; | ||
98 | + if (size == 3 && !a->q && a->selem != 1) { | ||
99 | + return false; | ||
100 | } | ||
101 | - | ||
102 | - /* From the shared decode logic */ | ||
103 | - switch (opcode) { | ||
104 | - case 0x0: | ||
105 | - rpt = 1; | ||
106 | - selem = 4; | ||
107 | - break; | ||
108 | - case 0x2: | ||
109 | - rpt = 4; | ||
110 | - selem = 1; | ||
111 | - break; | ||
112 | - case 0x4: | ||
113 | - rpt = 1; | ||
114 | - selem = 3; | ||
115 | - break; | ||
116 | - case 0x6: | ||
117 | - rpt = 3; | ||
118 | - selem = 1; | ||
119 | - break; | ||
120 | - case 0x7: | ||
121 | - rpt = 1; | ||
122 | - selem = 1; | ||
123 | - break; | ||
124 | - case 0x8: | ||
125 | - rpt = 1; | ||
126 | - selem = 2; | ||
127 | - break; | ||
128 | - case 0xa: | ||
129 | - rpt = 2; | ||
130 | - selem = 1; | ||
131 | - break; | ||
132 | - default: | ||
133 | - unallocated_encoding(s); | ||
134 | - return; | ||
135 | - } | ||
136 | - | ||
137 | - if (size == 3 && !is_q && selem != 1) { | ||
138 | - /* reserved */ | ||
139 | - unallocated_encoding(s); | ||
140 | - return; | ||
141 | - } | ||
142 | - | ||
143 | if (!fp_access_check(s)) { | ||
144 | - return; | ||
145 | + return true; | ||
146 | } | ||
147 | |||
148 | - if (rn == 31) { | ||
149 | + if (a->rn == 31) { | ||
150 | gen_check_sp_alignment(s); | ||
151 | } | ||
152 | |||
153 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
154 | endian = MO_LE; | ||
155 | } | ||
156 | |||
157 | - total = rpt * selem * (is_q ? 16 : 8); | ||
158 | - tcg_rn = cpu_reg_sp(s, rn); | ||
159 | + total = a->rpt * a->selem * (a->q ? 16 : 8); | ||
160 | + tcg_rn = cpu_reg_sp(s, a->rn); | ||
23 | 161 | ||
24 | /* | 162 | /* |
25 | @@ -XXX,XX +XXX,XX @@ bool arm_debug_check_breakpoint(CPUState *cs) | 163 | * Issue the MTE check vs the logical repeat count, before we |
26 | return false; | 164 | * promote consecutive little-endian elements below. |
27 | } | 165 | */ |
28 | 166 | - clean_addr = gen_mte_checkN(s, tcg_rn, is_store, is_postidx || rn != 31, | |
167 | - total, finalize_memop_asimd(s, size)); | ||
168 | + clean_addr = gen_mte_checkN(s, tcg_rn, false, a->p || a->rn != 31, total, | ||
169 | + finalize_memop_asimd(s, size)); | ||
170 | |||
171 | /* | ||
172 | * Consecutive little-endian elements from a single register | ||
173 | * can be promoted to a larger little-endian operation. | ||
174 | */ | ||
175 | align = MO_ALIGN; | ||
176 | - if (selem == 1 && endian == MO_LE) { | ||
177 | + if (a->selem == 1 && endian == MO_LE) { | ||
178 | align = pow2_align(size); | ||
179 | size = 3; | ||
180 | } | ||
181 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn) | ||
182 | } | ||
183 | mop = endian | size | align; | ||
184 | |||
185 | - elements = (is_q ? 16 : 8) >> size; | ||
186 | + elements = (a->q ? 16 : 8) >> size; | ||
187 | tcg_ebytes = tcg_constant_i64(1 << size); | ||
188 | - for (r = 0; r < rpt; r++) { | ||
189 | + for (r = 0; r < a->rpt; r++) { | ||
190 | int e; | ||
191 | for (e = 0; e < elements; e++) { | ||
192 | int xs; | ||
193 | - for (xs = 0; xs < selem; xs++) { | ||
194 | - int tt = (rt + r + xs) % 32; | ||
195 | - if (is_store) { | ||
196 | - do_vec_st(s, tt, e, clean_addr, mop); | ||
197 | - } else { | ||
198 | - do_vec_ld(s, tt, e, clean_addr, mop); | ||
199 | - } | ||
200 | + for (xs = 0; xs < a->selem; xs++) { | ||
201 | + int tt = (a->rt + r + xs) % 32; | ||
202 | + do_vec_ld(s, tt, e, clean_addr, mop); | ||
203 | tcg_gen_add_i64(clean_addr, clean_addr, tcg_ebytes); | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | |||
208 | - if (!is_store) { | ||
209 | - /* For non-quad operations, setting a slice of the low | ||
210 | - * 64 bits of the register clears the high 64 bits (in | ||
211 | - * the ARM ARM pseudocode this is implicit in the fact | ||
212 | - * that 'rval' is a 64 bit wide variable). | ||
213 | - * For quad operations, we might still need to zero the | ||
214 | - * high bits of SVE. | ||
215 | - */ | ||
216 | - for (r = 0; r < rpt * selem; r++) { | ||
217 | - int tt = (rt + r) % 32; | ||
218 | - clear_vec_high(s, is_q, tt); | ||
29 | + /* | 219 | + /* |
30 | + * Single-step exceptions have priority over breakpoint exceptions. | 220 | + * For non-quad operations, setting a slice of the low 64 bits of |
31 | + * If single-step state is active-pending, suppress the bp. | 221 | + * the register clears the high 64 bits (in the ARM ARM pseudocode |
222 | + * this is implicit in the fact that 'rval' is a 64 bit wide | ||
223 | + * variable). For quad operations, we might still need to zero | ||
224 | + * the high bits of SVE. | ||
32 | + */ | 225 | + */ |
33 | + if (arm_singlestep_active(env) && !(env->pstate & PSTATE_SS)) { | 226 | + for (r = 0; r < a->rpt * a->selem; r++) { |
227 | + int tt = (a->rt + r) % 32; | ||
228 | + clear_vec_high(s, a->q, tt); | ||
229 | + } | ||
230 | + | ||
231 | + if (a->p) { | ||
232 | + if (a->rm == 31) { | ||
233 | + tcg_gen_addi_i64(tcg_rn, tcg_rn, total); | ||
234 | + } else { | ||
235 | + tcg_gen_add_i64(tcg_rn, tcg_rn, cpu_reg(s, a->rm)); | ||
236 | + } | ||
237 | + } | ||
238 | + return true; | ||
239 | +} | ||
240 | + | ||
241 | +static bool trans_ST_mult(DisasContext *s, arg_ldst_mult *a) | ||
242 | +{ | ||
243 | + TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; | ||
244 | + MemOp endian, align, mop; | ||
245 | + | ||
246 | + int total; /* total bytes */ | ||
247 | + int elements; /* elements per vector */ | ||
248 | + int r; | ||
249 | + int size = a->sz; | ||
250 | + | ||
251 | + if (!a->p && a->rm != 0) { | ||
252 | + /* For non-postindexed accesses the Rm field must be 0 */ | ||
34 | + return false; | 253 | + return false; |
35 | + } | 254 | + } |
255 | + if (size == 3 && !a->q && a->selem != 1) { | ||
256 | + return false; | ||
257 | + } | ||
258 | + if (!fp_access_check(s)) { | ||
259 | + return true; | ||
260 | + } | ||
261 | + | ||
262 | + if (a->rn == 31) { | ||
263 | + gen_check_sp_alignment(s); | ||
264 | + } | ||
265 | + | ||
266 | + /* For our purposes, bytes are always little-endian. */ | ||
267 | + endian = s->be_data; | ||
268 | + if (size == 0) { | ||
269 | + endian = MO_LE; | ||
270 | + } | ||
271 | + | ||
272 | + total = a->rpt * a->selem * (a->q ? 16 : 8); | ||
273 | + tcg_rn = cpu_reg_sp(s, a->rn); | ||
36 | + | 274 | + |
37 | + /* | 275 | + /* |
38 | + * PC alignment faults have priority over breakpoint exceptions. | 276 | + * Issue the MTE check vs the logical repeat count, before we |
277 | + * promote consecutive little-endian elements below. | ||
39 | + */ | 278 | + */ |
40 | + pc = is_a64(env) ? env->pc : env->regs[15]; | 279 | + clean_addr = gen_mte_checkN(s, tcg_rn, true, a->p || a->rn != 31, total, |
41 | + if ((is_a64(env) || !env->thumb) && (pc & 3) != 0) { | 280 | + finalize_memop_asimd(s, size)); |
42 | + return false; | ||
43 | + } | ||
44 | + | 281 | + |
45 | + /* | 282 | + /* |
46 | + * Instruction aborts have priority over breakpoint exceptions. | 283 | + * Consecutive little-endian elements from a single register |
47 | + * TODO: We would need to look up the page for PC and verify that | 284 | + * can be promoted to a larger little-endian operation. |
48 | + * it is present and executable. | ||
49 | + */ | 285 | + */ |
50 | + | 286 | + align = MO_ALIGN; |
51 | for (n = 0; n < ARRAY_SIZE(env->cpu_breakpoint); n++) { | 287 | + if (a->selem == 1 && endian == MO_LE) { |
52 | if (bp_wp_matches(cpu, n, false)) { | 288 | + align = pow2_align(size); |
53 | return true; | 289 | + size = 3; |
290 | + } | ||
291 | + if (!s->align_mem) { | ||
292 | + align = 0; | ||
293 | + } | ||
294 | + mop = endian | size | align; | ||
295 | + | ||
296 | + elements = (a->q ? 16 : 8) >> size; | ||
297 | + tcg_ebytes = tcg_constant_i64(1 << size); | ||
298 | + for (r = 0; r < a->rpt; r++) { | ||
299 | + int e; | ||
300 | + for (e = 0; e < elements; e++) { | ||
301 | + int xs; | ||
302 | + for (xs = 0; xs < a->selem; xs++) { | ||
303 | + int tt = (a->rt + r + xs) % 32; | ||
304 | + do_vec_st(s, tt, e, clean_addr, mop); | ||
305 | + tcg_gen_add_i64(clean_addr, clean_addr, tcg_ebytes); | ||
306 | + } | ||
307 | } | ||
308 | } | ||
309 | |||
310 | - if (is_postidx) { | ||
311 | - if (rm == 31) { | ||
312 | + if (a->p) { | ||
313 | + if (a->rm == 31) { | ||
314 | tcg_gen_addi_i64(tcg_rn, tcg_rn, total); | ||
315 | } else { | ||
316 | - tcg_gen_add_i64(tcg_rn, tcg_rn, cpu_reg(s, rm)); | ||
317 | + tcg_gen_add_i64(tcg_rn, tcg_rn, cpu_reg(s, a->rm)); | ||
318 | } | ||
319 | } | ||
320 | + return true; | ||
321 | } | ||
322 | |||
323 | /* AdvSIMD load/store single structure | ||
324 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_tag(DisasContext *s, uint32_t insn) | ||
325 | static void disas_ldst(DisasContext *s, uint32_t insn) | ||
326 | { | ||
327 | switch (extract32(insn, 24, 6)) { | ||
328 | - case 0x0c: /* AdvSIMD load/store multiple structures */ | ||
329 | - disas_ldst_multiple_struct(s, insn); | ||
330 | - break; | ||
331 | case 0x0d: /* AdvSIMD load/store single structure */ | ||
332 | disas_ldst_single_struct(s, insn); | ||
333 | break; | ||
54 | -- | 334 | -- |
55 | 2.25.1 | 335 | 2.34.1 |
56 | |||
57 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | Convert the ASIMD load/store single structure insns to decodetree. |
---|---|---|---|
2 | 2 | ||
3 | Add expected blobs of the VIOT and DSDT table for the VIOT test on the | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | q35 machine. | 4 | Message-id: 20230602155223.2040685-20-peter.maydell@linaro.org |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | --- | ||
7 | target/arm/tcg/a64.decode | 34 +++++ | ||
8 | target/arm/tcg/translate-a64.c | 219 +++++++++++++++------------------ | ||
9 | 2 files changed, 136 insertions(+), 117 deletions(-) | ||
5 | 10 | ||
6 | Since the test instantiates a virtio device and two PCIe expander | 11 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
7 | bridges, DSDT.viot has more blocks than the base DSDT. | 12 | index XXXXXXX..XXXXXXX 100644 |
8 | 13 | --- a/target/arm/tcg/a64.decode | |
9 | The VIOT table generated for the q35 test is: | 14 | +++ b/target/arm/tcg/a64.decode |
10 | 15 | @@ -XXX,XX +XXX,XX @@ LD_mult 0 . 001100 . 1 0 ..... 0110 .. ..... ..... @ldst_mult rpt=3 sele | |
11 | [000h 0000 4] Signature : "VIOT" [Virtual I/O Translation Table] | 16 | LD_mult 0 . 001100 . 1 0 ..... 0111 .. ..... ..... @ldst_mult rpt=1 selem=1 |
12 | [004h 0004 4] Table Length : 00000070 | 17 | LD_mult 0 . 001100 . 1 0 ..... 1000 .. ..... ..... @ldst_mult rpt=1 selem=2 |
13 | [008h 0008 1] Revision : 00 | 18 | LD_mult 0 . 001100 . 1 0 ..... 1010 .. ..... ..... @ldst_mult rpt=2 selem=1 |
14 | [009h 0009 1] Checksum : 3D | 19 | + |
15 | [00Ah 0010 6] Oem ID : "BOCHS " | 20 | +# Load/store single structure |
16 | [010h 0016 8] Oem Table ID : "BXPC " | 21 | +&ldst_single rm rn rt p selem index scale |
17 | [018h 0024 4] Oem Revision : 00000001 | 22 | + |
18 | [01Ch 0028 4] Asl Compiler ID : "BXPC" | 23 | +%ldst_single_selem 13:1 21:1 !function=plus_1 |
19 | [020h 0032 4] Asl Compiler Revision : 00000001 | 24 | + |
20 | 25 | +%ldst_single_index_b 30:1 10:3 | |
21 | [024h 0036 2] Node count : 0003 | 26 | +%ldst_single_index_h 30:1 11:2 |
22 | [026h 0038 2] Node offset : 0030 | 27 | +%ldst_single_index_s 30:1 12:1 |
23 | [028h 0040 8] Reserved : 0000000000000000 | 28 | + |
24 | 29 | +@ldst_single_b .. ...... p:1 .. rm:5 ...... rn:5 rt:5 \ | |
25 | [030h 0048 1] Type : 03 [VirtIO-PCI IOMMU] | 30 | + &ldst_single scale=0 selem=%ldst_single_selem \ |
26 | [031h 0049 1] Reserved : 00 | 31 | + index=%ldst_single_index_b |
27 | [032h 0050 2] Length : 0010 | 32 | +@ldst_single_h .. ...... p:1 .. rm:5 ...... rn:5 rt:5 \ |
28 | 33 | + &ldst_single scale=1 selem=%ldst_single_selem \ | |
29 | [034h 0052 2] PCI Segment : 0000 | 34 | + index=%ldst_single_index_h |
30 | [036h 0054 2] PCI BDF number : 0010 | 35 | +@ldst_single_s .. ...... p:1 .. rm:5 ...... rn:5 rt:5 \ |
31 | [038h 0056 8] Reserved : 0000000000000000 | 36 | + &ldst_single scale=2 selem=%ldst_single_selem \ |
32 | 37 | + index=%ldst_single_index_s | |
33 | [040h 0064 1] Type : 01 [PCI Range] | 38 | +@ldst_single_d . index:1 ...... p:1 .. rm:5 ...... rn:5 rt:5 \ |
34 | [041h 0065 1] Reserved : 00 | 39 | + &ldst_single scale=3 selem=%ldst_single_selem |
35 | [042h 0066 2] Length : 0018 | 40 | + |
36 | 41 | +ST_single 0 . 001101 . 0 . ..... 00 . ... ..... ..... @ldst_single_b | |
37 | [044h 0068 4] Endpoint start : 00003000 | 42 | +ST_single 0 . 001101 . 0 . ..... 01 . ..0 ..... ..... @ldst_single_h |
38 | [048h 0072 2] PCI Segment start : 0000 | 43 | +ST_single 0 . 001101 . 0 . ..... 10 . .00 ..... ..... @ldst_single_s |
39 | [04Ah 0074 2] PCI Segment end : 0000 | 44 | +ST_single 0 . 001101 . 0 . ..... 10 . 001 ..... ..... @ldst_single_d |
40 | [04Ch 0076 2] PCI BDF start : 3000 | 45 | + |
41 | [04Eh 0078 2] PCI BDF end : 30FF | 46 | +LD_single 0 . 001101 . 1 . ..... 00 . ... ..... ..... @ldst_single_b |
42 | [050h 0080 2] Output node : 0030 | 47 | +LD_single 0 . 001101 . 1 . ..... 01 . ..0 ..... ..... @ldst_single_h |
43 | [052h 0082 6] Reserved : 000000000000 | 48 | +LD_single 0 . 001101 . 1 . ..... 10 . .00 ..... ..... @ldst_single_s |
44 | 49 | +LD_single 0 . 001101 . 1 . ..... 10 . 001 ..... ..... @ldst_single_d | |
45 | [058h 0088 1] Type : 01 [PCI Range] | 50 | + |
46 | [059h 0089 1] Reserved : 00 | 51 | +# Replicating load case |
47 | [05Ah 0090 2] Length : 0018 | 52 | +LD_single_repl 0 q:1 001101 p:1 1 . rm:5 11 . 0 scale:2 rn:5 rt:5 selem=%ldst_single_selem |
48 | 53 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | |
49 | [05Ch 0092 4] Endpoint start : 00001000 | 54 | index XXXXXXX..XXXXXXX 100644 |
50 | [060h 0096 2] PCI Segment start : 0000 | 55 | --- a/target/arm/tcg/translate-a64.c |
51 | [062h 0098 2] PCI Segment end : 0000 | 56 | +++ b/target/arm/tcg/translate-a64.c |
52 | [064h 0100 2] PCI BDF start : 1000 | 57 | @@ -XXX,XX +XXX,XX @@ static bool trans_ST_mult(DisasContext *s, arg_ldst_mult *a) |
53 | [066h 0102 2] PCI BDF end : 10FF | 58 | return true; |
54 | [068h 0104 2] Output node : 0030 | 59 | } |
55 | [06Ah 0106 6] Reserved : 000000000000 | 60 | |
56 | 61 | -/* AdvSIMD load/store single structure | |
57 | And the DSDT diff is: | 62 | - * |
58 | 63 | - * 31 30 29 23 22 21 20 16 15 13 12 11 10 9 5 4 0 | |
59 | @@ -XXX,XX +XXX,XX @@ | 64 | - * +---+---+---------------+-----+-----------+-----+---+------+------+------+ |
60 | * | 65 | - * | 0 | Q | 0 0 1 1 0 1 0 | L R | 0 0 0 0 0 | opc | S | size | Rn | Rt | |
61 | * Disassembling to symbolic ASL+ operators | 66 | - * +---+---+---------------+-----+-----------+-----+---+------+------+------+ |
62 | * | 67 | - * |
63 | - * Disassembly of tests/data/acpi/q35/DSDT, Fri Dec 10 15:03:08 2021 | 68 | - * AdvSIMD load/store single structure (post-indexed) |
64 | + * Disassembly of /tmp/aml-H9Y5D1, Fri Dec 10 15:02:27 2021 | 69 | - * |
65 | * | 70 | - * 31 30 29 23 22 21 20 16 15 13 12 11 10 9 5 4 0 |
66 | * Original Table Header: | 71 | - * +---+---+---------------+-----+-----------+-----+---+------+------+------+ |
67 | * Signature "DSDT" | 72 | - * | 0 | Q | 0 0 1 1 0 1 1 | L R | Rm | opc | S | size | Rn | Rt | |
68 | - * Length 0x00002061 (8289) | 73 | - * +---+---+---------------+-----+-----------+-----+---+------+------+------+ |
69 | + * Length 0x000024B6 (9398) | 74 | - * |
70 | * Revision 0x01 **** 32-bit table (V1), no 64-bit math support | 75 | - * Rt: first (or only) SIMD&FP register to be transferred |
71 | - * Checksum 0xFA | 76 | - * Rn: base address or SP |
72 | + * Checksum 0xA7 | 77 | - * Rm (post-index only): post-index register (when !31) or size dependent #imm |
73 | * OEM ID "BOCHS " | 78 | - * index = encoded in Q:S:size dependent on size |
74 | * OEM Table ID "BXPC " | 79 | - * |
75 | * OEM Revision 0x00000001 (1) | 80 | - * lane_size = encoded in R, opc |
76 | @@ -XXX,XX +XXX,XX @@ | 81 | - * transfer width = encoded in opc, S, size |
82 | - */ | ||
83 | -static void disas_ldst_single_struct(DisasContext *s, uint32_t insn) | ||
84 | +static bool trans_ST_single(DisasContext *s, arg_ldst_single *a) | ||
85 | { | ||
86 | - int rt = extract32(insn, 0, 5); | ||
87 | - int rn = extract32(insn, 5, 5); | ||
88 | - int rm = extract32(insn, 16, 5); | ||
89 | - int size = extract32(insn, 10, 2); | ||
90 | - int S = extract32(insn, 12, 1); | ||
91 | - int opc = extract32(insn, 13, 3); | ||
92 | - int R = extract32(insn, 21, 1); | ||
93 | - int is_load = extract32(insn, 22, 1); | ||
94 | - int is_postidx = extract32(insn, 23, 1); | ||
95 | - int is_q = extract32(insn, 30, 1); | ||
96 | - | ||
97 | - int scale = extract32(opc, 1, 2); | ||
98 | - int selem = (extract32(opc, 0, 1) << 1 | R) + 1; | ||
99 | - bool replicate = false; | ||
100 | - int index = is_q << 3 | S << 2 | size; | ||
101 | - int xs, total; | ||
102 | + int xs, total, rt; | ||
103 | TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; | ||
104 | MemOp mop; | ||
105 | |||
106 | - if (extract32(insn, 31, 1)) { | ||
107 | - unallocated_encoding(s); | ||
108 | - return; | ||
109 | + if (!a->p && a->rm != 0) { | ||
110 | + return false; | ||
111 | } | ||
112 | - if (!is_postidx && rm != 0) { | ||
113 | - unallocated_encoding(s); | ||
114 | - return; | ||
115 | - } | ||
116 | - | ||
117 | - switch (scale) { | ||
118 | - case 3: | ||
119 | - if (!is_load || S) { | ||
120 | - unallocated_encoding(s); | ||
121 | - return; | ||
122 | - } | ||
123 | - scale = size; | ||
124 | - replicate = true; | ||
125 | - break; | ||
126 | - case 0: | ||
127 | - break; | ||
128 | - case 1: | ||
129 | - if (extract32(size, 0, 1)) { | ||
130 | - unallocated_encoding(s); | ||
131 | - return; | ||
132 | - } | ||
133 | - index >>= 1; | ||
134 | - break; | ||
135 | - case 2: | ||
136 | - if (extract32(size, 1, 1)) { | ||
137 | - unallocated_encoding(s); | ||
138 | - return; | ||
139 | - } | ||
140 | - if (!extract32(size, 0, 1)) { | ||
141 | - index >>= 2; | ||
142 | - } else { | ||
143 | - if (S) { | ||
144 | - unallocated_encoding(s); | ||
145 | - return; | ||
146 | - } | ||
147 | - index >>= 3; | ||
148 | - scale = 3; | ||
149 | - } | ||
150 | - break; | ||
151 | - default: | ||
152 | - g_assert_not_reached(); | ||
153 | - } | ||
154 | - | ||
155 | if (!fp_access_check(s)) { | ||
156 | - return; | ||
157 | + return true; | ||
158 | } | ||
159 | |||
160 | - if (rn == 31) { | ||
161 | + if (a->rn == 31) { | ||
162 | gen_check_sp_alignment(s); | ||
163 | } | ||
164 | |||
165 | - total = selem << scale; | ||
166 | - tcg_rn = cpu_reg_sp(s, rn); | ||
167 | + total = a->selem << a->scale; | ||
168 | + tcg_rn = cpu_reg_sp(s, a->rn); | ||
169 | |||
170 | - mop = finalize_memop_asimd(s, scale); | ||
171 | - | ||
172 | - clean_addr = gen_mte_checkN(s, tcg_rn, !is_load, is_postidx || rn != 31, | ||
173 | + mop = finalize_memop_asimd(s, a->scale); | ||
174 | + clean_addr = gen_mte_checkN(s, tcg_rn, true, a->p || a->rn != 31, | ||
175 | total, mop); | ||
176 | |||
177 | - tcg_ebytes = tcg_constant_i64(1 << scale); | ||
178 | - for (xs = 0; xs < selem; xs++) { | ||
179 | - if (replicate) { | ||
180 | - /* Load and replicate to all elements */ | ||
181 | - TCGv_i64 tcg_tmp = tcg_temp_new_i64(); | ||
182 | - | ||
183 | - tcg_gen_qemu_ld_i64(tcg_tmp, clean_addr, get_mem_index(s), mop); | ||
184 | - tcg_gen_gvec_dup_i64(scale, vec_full_reg_offset(s, rt), | ||
185 | - (is_q + 1) * 8, vec_full_reg_size(s), | ||
186 | - tcg_tmp); | ||
187 | - } else { | ||
188 | - /* Load/store one element per register */ | ||
189 | - if (is_load) { | ||
190 | - do_vec_ld(s, rt, index, clean_addr, mop); | ||
191 | - } else { | ||
192 | - do_vec_st(s, rt, index, clean_addr, mop); | ||
193 | - } | ||
194 | - } | ||
195 | + tcg_ebytes = tcg_constant_i64(1 << a->scale); | ||
196 | + for (xs = 0, rt = a->rt; xs < a->selem; xs++, rt = (rt + 1) % 32) { | ||
197 | + do_vec_st(s, rt, a->index, clean_addr, mop); | ||
198 | tcg_gen_add_i64(clean_addr, clean_addr, tcg_ebytes); | ||
199 | - rt = (rt + 1) % 32; | ||
200 | } | ||
201 | |||
202 | - if (is_postidx) { | ||
203 | - if (rm == 31) { | ||
204 | + if (a->p) { | ||
205 | + if (a->rm == 31) { | ||
206 | tcg_gen_addi_i64(tcg_rn, tcg_rn, total); | ||
207 | } else { | ||
208 | - tcg_gen_add_i64(tcg_rn, tcg_rn, cpu_reg(s, rm)); | ||
209 | + tcg_gen_add_i64(tcg_rn, tcg_rn, cpu_reg(s, a->rm)); | ||
77 | } | 210 | } |
78 | } | 211 | } |
79 | 212 | + return true; | |
80 | + Scope (\_SB) | 213 | +} |
81 | + { | 214 | + |
82 | + Device (PC30) | 215 | +static bool trans_LD_single(DisasContext *s, arg_ldst_single *a) |
83 | + { | 216 | +{ |
84 | + Name (_UID, 0x30) // _UID: Unique ID | 217 | + int xs, total, rt; |
85 | + Name (_BBN, 0x30) // _BBN: BIOS Bus Number | 218 | + TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; |
86 | + Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */) // _HID: Hardware ID | 219 | + MemOp mop; |
87 | + Name (_CID, EisaId ("PNP0A03") /* PCI Bus */) // _CID: Compatible ID | 220 | + |
88 | + Method (_OSC, 4, NotSerialized) // _OSC: Operating System Capabilities | 221 | + if (!a->p && a->rm != 0) { |
89 | + { | 222 | + return false; |
90 | + CreateDWordField (Arg3, Zero, CDW1) | 223 | + } |
91 | + If ((Arg0 == ToUUID ("33db4d5b-1ff7-401c-9657-7441c03dd766") /* PCI Host Bridge Device */)) | 224 | + if (!fp_access_check(s)) { |
92 | + { | 225 | + return true; |
93 | + CreateDWordField (Arg3, 0x04, CDW2) | 226 | + } |
94 | + CreateDWordField (Arg3, 0x08, CDW3) | 227 | + |
95 | + Local0 = CDW3 /* \_SB_.PC30._OSC.CDW3 */ | 228 | + if (a->rn == 31) { |
96 | + Local0 &= 0x1F | 229 | + gen_check_sp_alignment(s); |
97 | + If ((Arg1 != One)) | 230 | + } |
98 | + { | 231 | + |
99 | + CDW1 |= 0x08 | 232 | + total = a->selem << a->scale; |
100 | + } | 233 | + tcg_rn = cpu_reg_sp(s, a->rn); |
101 | + | 234 | + |
102 | + If ((CDW3 != Local0)) | 235 | + mop = finalize_memop_asimd(s, a->scale); |
103 | + { | 236 | + clean_addr = gen_mte_checkN(s, tcg_rn, false, a->p || a->rn != 31, |
104 | + CDW1 |= 0x10 | 237 | + total, mop); |
105 | + } | 238 | + |
106 | + | 239 | + tcg_ebytes = tcg_constant_i64(1 << a->scale); |
107 | + CDW3 = Local0 | 240 | + for (xs = 0, rt = a->rt; xs < a->selem; xs++, rt = (rt + 1) % 32) { |
108 | + } | 241 | + do_vec_ld(s, rt, a->index, clean_addr, mop); |
109 | + Else | 242 | + tcg_gen_add_i64(clean_addr, clean_addr, tcg_ebytes); |
110 | + { | 243 | + } |
111 | + CDW1 |= 0x04 | 244 | + |
112 | + } | 245 | + if (a->p) { |
113 | + | 246 | + if (a->rm == 31) { |
114 | + Return (Arg3) | 247 | + tcg_gen_addi_i64(tcg_rn, tcg_rn, total); |
115 | + } | 248 | + } else { |
116 | + | 249 | + tcg_gen_add_i64(tcg_rn, tcg_rn, cpu_reg(s, a->rm)); |
117 | + Method (_PRT, 0, NotSerialized) // _PRT: PCI Routing Table | ||
118 | + { | ||
119 | + Local0 = Package (0x80){} | ||
120 | + Local1 = Zero | ||
121 | + While ((Local1 < 0x80)) | ||
122 | + { | ||
123 | + Local2 = (Local1 >> 0x02) | ||
124 | + Local3 = ((Local1 + Local2) & 0x03) | ||
125 | + If ((Local3 == Zero)) | ||
126 | + { | ||
127 | + Local4 = Package (0x04) | ||
128 | + { | ||
129 | + Zero, | ||
130 | + Zero, | ||
131 | + LNKD, | ||
132 | + Zero | ||
133 | + } | ||
134 | + } | ||
135 | + | ||
136 | + If ((Local3 == One)) | ||
137 | + { | ||
138 | + Local4 = Package (0x04) | ||
139 | + { | ||
140 | + Zero, | ||
141 | + Zero, | ||
142 | + LNKA, | ||
143 | + Zero | ||
144 | + } | ||
145 | + } | ||
146 | + | ||
147 | + If ((Local3 == 0x02)) | ||
148 | + { | ||
149 | + Local4 = Package (0x04) | ||
150 | + { | ||
151 | + Zero, | ||
152 | + Zero, | ||
153 | + LNKB, | ||
154 | + Zero | ||
155 | + } | ||
156 | + } | ||
157 | + | ||
158 | + If ((Local3 == 0x03)) | ||
159 | + { | ||
160 | + Local4 = Package (0x04) | ||
161 | + { | ||
162 | + Zero, | ||
163 | + Zero, | ||
164 | + LNKC, | ||
165 | + Zero | ||
166 | + } | ||
167 | + } | ||
168 | + | ||
169 | + Local4 [Zero] = ((Local2 << 0x10) | 0xFFFF) | ||
170 | + Local4 [One] = (Local1 & 0x03) | ||
171 | + Local0 [Local1] = Local4 | ||
172 | + Local1++ | ||
173 | + } | ||
174 | + | ||
175 | + Return (Local0) | ||
176 | + } | ||
177 | + | ||
178 | + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings | ||
179 | + { | ||
180 | + WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | ||
181 | + 0x0000, // Granularity | ||
182 | + 0x0030, // Range Minimum | ||
183 | + 0x0030, // Range Maximum | ||
184 | + 0x0000, // Translation Offset | ||
185 | + 0x0001, // Length | ||
186 | + ,, ) | ||
187 | + }) | ||
188 | + } | 250 | + } |
189 | + } | 251 | + } |
190 | + | 252 | + return true; |
191 | + Scope (\_SB) | 253 | +} |
192 | + { | 254 | + |
193 | + Device (PC20) | 255 | +static bool trans_LD_single_repl(DisasContext *s, arg_LD_single_repl *a) |
194 | + { | 256 | +{ |
195 | + Name (_UID, 0x20) // _UID: Unique ID | 257 | + int xs, total, rt; |
196 | + Name (_BBN, 0x20) // _BBN: BIOS Bus Number | 258 | + TCGv_i64 clean_addr, tcg_rn, tcg_ebytes; |
197 | + Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */) // _HID: Hardware ID | 259 | + MemOp mop; |
198 | + Name (_CID, EisaId ("PNP0A03") /* PCI Bus */) // _CID: Compatible ID | 260 | + |
199 | + Method (_OSC, 4, NotSerialized) // _OSC: Operating System Capabilities | 261 | + if (!a->p && a->rm != 0) { |
200 | + { | 262 | + return false; |
201 | + CreateDWordField (Arg3, Zero, CDW1) | 263 | + } |
202 | + If ((Arg0 == ToUUID ("33db4d5b-1ff7-401c-9657-7441c03dd766") /* PCI Host Bridge Device */)) | 264 | + if (!fp_access_check(s)) { |
203 | + { | 265 | + return true; |
204 | + CreateDWordField (Arg3, 0x04, CDW2) | 266 | + } |
205 | + CreateDWordField (Arg3, 0x08, CDW3) | 267 | + |
206 | + Local0 = CDW3 /* \_SB_.PC20._OSC.CDW3 */ | 268 | + if (a->rn == 31) { |
207 | + Local0 &= 0x1F | 269 | + gen_check_sp_alignment(s); |
208 | + If ((Arg1 != One)) | 270 | + } |
209 | + { | 271 | + |
210 | + CDW1 |= 0x08 | 272 | + total = a->selem << a->scale; |
211 | + } | 273 | + tcg_rn = cpu_reg_sp(s, a->rn); |
212 | + | 274 | + |
213 | + If ((CDW3 != Local0)) | 275 | + mop = finalize_memop_asimd(s, a->scale); |
214 | + { | 276 | + clean_addr = gen_mte_checkN(s, tcg_rn, false, a->p || a->rn != 31, |
215 | + CDW1 |= 0x10 | 277 | + total, mop); |
216 | + } | 278 | + |
217 | + | 279 | + tcg_ebytes = tcg_constant_i64(1 << a->scale); |
218 | + CDW3 = Local0 | 280 | + for (xs = 0, rt = a->rt; xs < a->selem; xs++, rt = (rt + 1) % 32) { |
219 | + } | 281 | + /* Load and replicate to all elements */ |
220 | + Else | 282 | + TCGv_i64 tcg_tmp = tcg_temp_new_i64(); |
221 | + { | 283 | + |
222 | + CDW1 |= 0x04 | 284 | + tcg_gen_qemu_ld_i64(tcg_tmp, clean_addr, get_mem_index(s), mop); |
223 | + } | 285 | + tcg_gen_gvec_dup_i64(a->scale, vec_full_reg_offset(s, rt), |
224 | + | 286 | + (a->q + 1) * 8, vec_full_reg_size(s), tcg_tmp); |
225 | + Return (Arg3) | 287 | + tcg_gen_add_i64(clean_addr, clean_addr, tcg_ebytes); |
226 | + } | 288 | + } |
227 | + | 289 | + |
228 | + Method (_PRT, 0, NotSerialized) // _PRT: PCI Routing Table | 290 | + if (a->p) { |
229 | + { | 291 | + if (a->rm == 31) { |
230 | + Local0 = Package (0x80){} | 292 | + tcg_gen_addi_i64(tcg_rn, tcg_rn, total); |
231 | + Local1 = Zero | 293 | + } else { |
232 | + While ((Local1 < 0x80)) | 294 | + tcg_gen_add_i64(tcg_rn, tcg_rn, cpu_reg(s, a->rm)); |
233 | + { | ||
234 | + Local2 = (Local1 >> 0x02) | ||
235 | + Local3 = ((Local1 + Local2) & 0x03) | ||
236 | + If ((Local3 == Zero)) | ||
237 | + { | ||
238 | + Local4 = Package (0x04) | ||
239 | + { | ||
240 | + Zero, | ||
241 | + Zero, | ||
242 | + LNKD, | ||
243 | + Zero | ||
244 | + } | ||
245 | + } | ||
246 | + | ||
247 | + If ((Local3 == One)) | ||
248 | + { | ||
249 | + Local4 = Package (0x04) | ||
250 | + { | ||
251 | + Zero, | ||
252 | + Zero, | ||
253 | + LNKA, | ||
254 | + Zero | ||
255 | + } | ||
256 | + } | ||
257 | + | ||
258 | + If ((Local3 == 0x02)) | ||
259 | + { | ||
260 | + Local4 = Package (0x04) | ||
261 | + { | ||
262 | + Zero, | ||
263 | + Zero, | ||
264 | + LNKB, | ||
265 | + Zero | ||
266 | + } | ||
267 | + } | ||
268 | + | ||
269 | + If ((Local3 == 0x03)) | ||
270 | + { | ||
271 | + Local4 = Package (0x04) | ||
272 | + { | ||
273 | + Zero, | ||
274 | + Zero, | ||
275 | + LNKC, | ||
276 | + Zero | ||
277 | + } | ||
278 | + } | ||
279 | + | ||
280 | + Local4 [Zero] = ((Local2 << 0x10) | 0xFFFF) | ||
281 | + Local4 [One] = (Local1 & 0x03) | ||
282 | + Local0 [Local1] = Local4 | ||
283 | + Local1++ | ||
284 | + } | ||
285 | + | ||
286 | + Return (Local0) | ||
287 | + } | ||
288 | + | ||
289 | + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings | ||
290 | + { | ||
291 | + WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | ||
292 | + 0x0000, // Granularity | ||
293 | + 0x0020, // Range Minimum | ||
294 | + 0x0020, // Range Maximum | ||
295 | + 0x0000, // Translation Offset | ||
296 | + 0x0001, // Length | ||
297 | + ,, ) | ||
298 | + }) | ||
299 | + } | 295 | + } |
300 | + } | 296 | + } |
301 | + | 297 | + return true; |
302 | + Scope (\_SB) | 298 | } |
303 | + { | 299 | |
304 | + Device (PC10) | 300 | /* |
305 | + { | 301 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_tag(DisasContext *s, uint32_t insn) |
306 | + Name (_UID, 0x10) // _UID: Unique ID | 302 | static void disas_ldst(DisasContext *s, uint32_t insn) |
307 | + Name (_BBN, 0x10) // _BBN: BIOS Bus Number | 303 | { |
308 | + Name (_HID, EisaId ("PNP0A08") /* PCI Express Bus */) // _HID: Hardware ID | 304 | switch (extract32(insn, 24, 6)) { |
309 | + Name (_CID, EisaId ("PNP0A03") /* PCI Bus */) // _CID: Compatible ID | 305 | - case 0x0d: /* AdvSIMD load/store single structure */ |
310 | + Method (_OSC, 4, NotSerialized) // _OSC: Operating System Capabilities | 306 | - disas_ldst_single_struct(s, insn); |
311 | + { | 307 | - break; |
312 | + CreateDWordField (Arg3, Zero, CDW1) | 308 | case 0x19: |
313 | + If ((Arg0 == ToUUID ("33db4d5b-1ff7-401c-9657-7441c03dd766") /* PCI Host Bridge Device */)) | 309 | if (extract32(insn, 21, 1) != 0) { |
314 | + { | 310 | disas_ldst_tag(s, insn); |
315 | + CreateDWordField (Arg3, 0x04, CDW2) | ||
316 | + CreateDWordField (Arg3, 0x08, CDW3) | ||
317 | + Local0 = CDW3 /* \_SB_.PC10._OSC.CDW3 */ | ||
318 | + Local0 &= 0x1F | ||
319 | + If ((Arg1 != One)) | ||
320 | + { | ||
321 | + CDW1 |= 0x08 | ||
322 | + } | ||
323 | + | ||
324 | + If ((CDW3 != Local0)) | ||
325 | + { | ||
326 | + CDW1 |= 0x10 | ||
327 | + } | ||
328 | + | ||
329 | + CDW3 = Local0 | ||
330 | + } | ||
331 | + Else | ||
332 | + { | ||
333 | + CDW1 |= 0x04 | ||
334 | + } | ||
335 | + | ||
336 | + Return (Arg3) | ||
337 | + } | ||
338 | + | ||
339 | + Method (_PRT, 0, NotSerialized) // _PRT: PCI Routing Table | ||
340 | + { | ||
341 | + Local0 = Package (0x80){} | ||
342 | + Local1 = Zero | ||
343 | + While ((Local1 < 0x80)) | ||
344 | + { | ||
345 | + Local2 = (Local1 >> 0x02) | ||
346 | + Local3 = ((Local1 + Local2) & 0x03) | ||
347 | + If ((Local3 == Zero)) | ||
348 | + { | ||
349 | + Local4 = Package (0x04) | ||
350 | + { | ||
351 | + Zero, | ||
352 | + Zero, | ||
353 | + LNKD, | ||
354 | + Zero | ||
355 | + } | ||
356 | + } | ||
357 | + | ||
358 | + If ((Local3 == One)) | ||
359 | + { | ||
360 | + Local4 = Package (0x04) | ||
361 | + { | ||
362 | + Zero, | ||
363 | + Zero, | ||
364 | + LNKA, | ||
365 | + Zero | ||
366 | + } | ||
367 | + } | ||
368 | + | ||
369 | + If ((Local3 == 0x02)) | ||
370 | + { | ||
371 | + Local4 = Package (0x04) | ||
372 | + { | ||
373 | + Zero, | ||
374 | + Zero, | ||
375 | + LNKB, | ||
376 | + Zero | ||
377 | + } | ||
378 | + } | ||
379 | + | ||
380 | + If ((Local3 == 0x03)) | ||
381 | + { | ||
382 | + Local4 = Package (0x04) | ||
383 | + { | ||
384 | + Zero, | ||
385 | + Zero, | ||
386 | + LNKC, | ||
387 | + Zero | ||
388 | + } | ||
389 | + } | ||
390 | + | ||
391 | + Local4 [Zero] = ((Local2 << 0x10) | 0xFFFF) | ||
392 | + Local4 [One] = (Local1 & 0x03) | ||
393 | + Local0 [Local1] = Local4 | ||
394 | + Local1++ | ||
395 | + } | ||
396 | + | ||
397 | + Return (Local0) | ||
398 | + } | ||
399 | + | ||
400 | + Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings | ||
401 | + { | ||
402 | + WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | ||
403 | + 0x0000, // Granularity | ||
404 | + 0x0010, // Range Minimum | ||
405 | + 0x0010, // Range Maximum | ||
406 | + 0x0000, // Translation Offset | ||
407 | + 0x0001, // Length | ||
408 | + ,, ) | ||
409 | + }) | ||
410 | + } | ||
411 | + } | ||
412 | + | ||
413 | Scope (\_SB.PCI0) | ||
414 | { | ||
415 | Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings | ||
416 | @@ -XXX,XX +XXX,XX @@ | ||
417 | WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, | ||
418 | 0x0000, // Granularity | ||
419 | 0x0000, // Range Minimum | ||
420 | - 0x00FF, // Range Maximum | ||
421 | + 0x000F, // Range Maximum | ||
422 | 0x0000, // Translation Offset | ||
423 | - 0x0100, // Length | ||
424 | + 0x0010, // Length | ||
425 | ,, ) | ||
426 | IO (Decode16, | ||
427 | 0x0CF8, // Range Minimum | ||
428 | @@ -XXX,XX +XXX,XX @@ | ||
429 | } | ||
430 | } | ||
431 | |||
432 | + Device (S10) | ||
433 | + { | ||
434 | + Name (_ADR, 0x00020000) // _ADR: Address | ||
435 | + } | ||
436 | + | ||
437 | + Device (S18) | ||
438 | + { | ||
439 | + Name (_ADR, 0x00030000) // _ADR: Address | ||
440 | + } | ||
441 | + | ||
442 | + Device (S20) | ||
443 | + { | ||
444 | + Name (_ADR, 0x00040000) // _ADR: Address | ||
445 | + } | ||
446 | + | ||
447 | + Device (S28) | ||
448 | + { | ||
449 | + Name (_ADR, 0x00050000) // _ADR: Address | ||
450 | + } | ||
451 | + | ||
452 | Method (PCNT, 0, NotSerialized) | ||
453 | { | ||
454 | } | ||
455 | |||
456 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
457 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
458 | Message-id: 20211210170415.583179-8-jean-philippe@linaro.org | ||
459 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
460 | --- | ||
461 | tests/qtest/bios-tables-test-allowed-diff.h | 2 -- | ||
462 | tests/data/acpi/q35/DSDT.viot | Bin 0 -> 9398 bytes | ||
463 | tests/data/acpi/q35/VIOT.viot | Bin 0 -> 112 bytes | ||
464 | 3 files changed, 2 deletions(-) | ||
465 | |||
466 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | ||
467 | index XXXXXXX..XXXXXXX 100644 | ||
468 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | ||
469 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | ||
470 | @@ -XXX,XX +XXX,XX @@ | ||
471 | /* List of comma-separated changed AML files to ignore */ | ||
472 | "tests/data/acpi/virt/VIOT", | ||
473 | -"tests/data/acpi/q35/DSDT.viot", | ||
474 | -"tests/data/acpi/q35/VIOT.viot", | ||
475 | diff --git a/tests/data/acpi/q35/DSDT.viot b/tests/data/acpi/q35/DSDT.viot | ||
476 | index XXXXXXX..XXXXXXX 100644 | ||
477 | GIT binary patch | ||
478 | literal 9398 | ||
479 | zcmeHNO>7&-8J*>iv|O&FB}G~Oi$yp||57BBoWHhc5OS9yDTx$CQgH$r;8Idr*-4Q_ | ||
480 | z5(9Az1F`}niVsB-)<KW7p`g9Br(A2Gm-gmc1N78GFS!;)e2V(MnH_0{q<{#yMgn&C | ||
481 | zn|*J-d9yqFhO_H6z19~`FlPL*u<DkZ*}|)JH;X@mF-FI<cPg<fti9tEN*yB^i5czN | ||
482 | zNq&q?!OZ;BE3B7{KWzJ-`Tn~f`9?Qj8~2^N8{Oc8J%57{==w%rS#;nOCp*nTr@iZ1 | ||
483 | zb+?i;JLQUJ=O0?8*>S~D)a>NF1~WVB6^~_B#yhJ`H+JU@=6aXs`?Yv)J2h=N?drcS | ||
484 | zeLZ*n<<Bm^n}6`jfBx#u8&(W}1?)}iF9o#mZ~E2+zwdn7yK3AbIzKnxpZ>JRPm3~# | ||
485 | z&ICS{+_OayRW-l=Mtk=~uaS3o8z<_udd|(wqg`&JnVPfCe>BUOO`Su3e>pff_^UW% | ||
486 | z&JE^NO`)=Amg~iqRB1pPscP?(>#ZuY8GHCmlEvD$9g3%4Db~Dfz2SATnddvrR-Oe^ | ||
487 | z;s;dJec!hnzi)ri^I6YN9vtkm{^TdUF8h7gX8-<Qe4p)GQ=)AtYx2VcwdLVAEXEjG | ||
488 | z^Mj|UHPqkj-LsWuzQem1>F3atdZn=zv3$#RmZzSHN+6-yyU#8cJb=YDilX&sl}vNm | ||
489 | znkgAR^O<3kj4if>{ly5fwRfMWuC5=lrlvKPX~i#654Cp}R_d*JS$9laZ$ra6)<ns8 | ||
490 | zFZy28G%xP(nit&F>LDi%G<tIc=TY=gl$jSD&Uv!Yat~XR46h%rI$!}a%!|xG7u8Zn | ||
491 | zeY8_|n=K>xz_v_W8VX$W-Fg-qFWcT}7MCyz{%%{ia7hZ>Law-k6NOr}VI&_48U=2l | ||
492 | zwqDKFE8eTwwozDdms#e?x?5a|v>&JF;2_v0L~z5n%BYU^52<*cWuD4|GYUm@1+?)) | ||
493 | zte^45>Rz)t*<T5V#={r>@t@{%?^i#W{i=HAZ*Dc9y59Va-+#P!jrGs;u38a{fLr`N | ||
494 | zvT@rUu>DljxJ?^&Z?-?vyJn3C>3D=qux{Y*bs5|5n)Qmi$TD^Zdn4GU$ocJS2Hh-< | ||
495 | z`xPI^^+v0nUVdjMos8k`WGl7hA`{03ju%<lrgAHSpd^DRf-*}_#Ly0mB!LSfVgWcQ | ||
496 | z&T$@~G9)JI=hz5m0vkrel+Xy{Oh7pkAu-V!j*W7rY(bO}Q$nMH2`FbGB&N)QaV4<4 | ||
497 | zo)~9JXiP9=;}NPl<C@MmXG&;XFlFNrsyfFsonxFSp<}vEgsRSQP3O3#b6nSnP}ON_ | ||
498 | zI!#Tdsp~|j>ckUB>FI=~GokB5sOq#dotCE4(sd$KbtW~PNlj-`*NIToiD#j5J#9^= | ||
499 | zt?NXn>YUJYPG~wObe#xQos*i*NloXZt`niEb4t@WrRki~bs|)CI+{*L)9L6s5vn>< | ||
500 | zn$DD_Go|Z9sOn5>I@6lYw5}7Os&iV?Ij!lO)^#FOb!If38BJ$K*NIToIiu;E(R9w} | ||
501 | zIuWWmPiZ<&X*y5oIuWWmF_XaEC!a&Jn$B5WCqh-{X-(&8P3LJ{Cqh-{8P3dyPr@^t | ||
502 | zSqL9?X9Uwd3W@23*s~h*tj0X6GZCuHa~kuU#yqDp5vt7d8uPryJg+kms?5hU=3^T3 | ||
503 | zF`bD}WnSP+=`t5MQ$FJ_2&Q~+BP6E0f^%BVIW6a$o)e+SX~IDBih-7z6{O~7YTy`& | ||
504 | zLjy&Cv?7QikV#>n0>>@MV8oK`Gmun34-FKdlm-J8SZSaNlnhir4-FI{S|bfqV8e)V | ||
505 | zss<{chX#reE#g=hsKAC%sF6d-Km}BWs!kZFsFpKfpbC@>6rprQGEjt4Ck#|zITHq| | ||
506 | zK*>M_l;<P^MJRQ`Kn0dFVW0|>3{*fllMEE0)CmI>Sk8ojDo`>|0p(0GP=xY&!axO< | ||
507 | zGhv_#lnhirIg<<&q0|Wj6<E%MfhtfkPyyvkGEjt4Ck#|zITHq|K*>M_lrzad5lWpf | ||
508 | zP=V!47^ngz0~JutBm+e#b;3XemNQ|X3X}{~Ksl2P6rt1!0~J`#gn=qhGEf2KOfpb} | ||
509 | zQYQ>lU^x>8szAv=1(Y+%KoLrvFi?TzOc<yFB?A>u&LjgxD0RX>1(q{mpbC@>R6seC | ||
510 | z3>2Z%2?G^a&V+#~P%=;f<xDbAgi<FARA4z12C6{GKn0XD$v_cGoiI>=<xCi;0wn_# | ||
511 | zP|hR+MJRQ`Kn0dFVW0|>3{*fllMEE0)CmI>Sk8ojDo`>|0p(0GP=rz^3{+q_69%e4 | ||
512 | z$v_2^Gs!>^N}VuJf#pmXr~)Me6;RG314Srx!axxz28u{EP=u<1B2)}iVZuNaCK;&0 | ||
513 | zBm-5LFi?dF167!0pbC==RAItE6($T+VUmF=Ofpb~2?JG_Fi?d_2C6X0Kouqo6p_5T | ||
514 | zFi=FeV!SiSKoR0H$dH(_Z(*Q_WZ%L-5y`$K14StNmJAdjmWs}HV4<vU_xO+1efmLq | ||
515 | zZ;W>N_U)fP6Qy6Nw5mbt9Y(#emWSi66=>tq#xoh#Ue=0qyhxi8ZOUe5y0V7VfPUhp | ||
516 | zwX=;ymc+i5%sg9Ja~lZ&8oAV@mHc>&CHP9v4R(jhtT?un;O4e9#pno)Xkh7OWgK&a | ||
517 | zyj=3Iv0OuoK_;5rOr5f(Kb~ZXDBO+V`OWYo#_C08imwChQxnjdd?wZLDou8aj;$SD | ||
518 | zGDYiA3<$Tu<JnHL(KPOChi#zrR32t83}naR$+ym4P_h?z_5#|cW-nw$XD_sOtE62l | ||
519 | zrD3@*)NVyiklt0&yF9%+klsBey&I<Y2E<!f(E8TuJte)z(|ZHyy<^gQVfx}=`q&B5 | ||
520 | z7nSryp1wGczIaUfVwiq$Fn#<4=@*ssi#+|}K>EdF(l3VTOM~ghPLRH&q%ZOGrGfON | ||
521 | zW73zx^yR_y<0nX8R??Sw`tm^f@-gYlNFSp|*<gA{q?Zp5Oe-+l#rmyYmKozi9y=P> | ||
522 | zVReJU*h=ZuVXiS$ohTbw-O#v9>(yZbGE|)?8(H1ZIKvV!jWa0>vy!3eMA^vdhQ>`s | ||
523 | zuMSg{q3T50$m)j1!HixV<}X9liL#N^4c*tL^y)CF8LCc{jjV3yKAqL8!%SzWI#H%q | ||
524 | z=bSrQ&)%JCRttF5g4Zf`6l?y@>PzD7MA^D>wBlcH6r1ucwJ<p0O%rZ?JzIY3-QdmZ | ||
525 | zzs|n>`a5r3e|z)wcUaqS>nqFQ-8x}eCF4u`OWUxqst-@1rSmUs%WmKP5e0dcb?e2N | ||
526 | z;Z|x*!);VwF|Yuhqs^khqOM!@u*jY!WYldISF(V6`BoNd&6Qfk3>X#SuD^7J>p_D= | ||
527 | zBPa51y^_n#=cpOt#Zf$ya$Ae9Mfz56n|<i!a=ELS@)%a{^NIH3SDuN<R~sah1km#P | ||
528 | zU@?*f%<rG=4W1wgfi;C?_n|W@%lm$&8YfvNOJodIg&IcIpIJQRHr<+ej11GQ6)&eF | ||
529 | z2Lam*jIH}#y0>KnY%4JQfOYS$*uU%f#@$U6`N8I3N-lV?5ErFCdv~xDmu2(wexld4 | ||
530 | z4v^;aVAT2k6GJ^m*FD(Wqc(Qg^)6a<?}h$zLoj}4;PP!+(O{@!a1y-hoAhF_7!z+6 | ||
531 | zslpAmNtYbjHrw-~#SPVk_FUf>-Obg6yV`8o$8_`PyJe_;bY5_EMBfBfWU!Q=*9HsG | ||
532 | z%_Cda{@_Krr!oHVhv9+y+T5qR8zZ2aZ>5r!$*|f$^U%yBUYfR&B!+EYy_PwL!BeUi | ||
533 | zJH^}r3r9Q+B)X@Z)fk=P13w&7x#wBtXTZ)g>WITPg5r&pQc!nmyrmk#S(>>b9xnNr | ||
534 | zx_b#v9Xv-Y><Wb%?S^0Xe&<)bbKl_=Z|3C$tf|F<bYzE*mfHB;uC)`q-?buaBe?l? | ||
535 | zcLTpK*k<49Z32`K?|nSBMFqxTK^_IE-li2fEGdK~(ZdoKBl6ab4a;Hler#`xvEXJG | ||
536 | zb?<E%EZExfX>jcOVhS*0rS~RS1dA#xhkv@Nct@#q?LyeKS<$uFec!bw>{@uu$gZ6a | ||
537 | zyVen1i{1BKd%~`D7|m$;U0a<I*3I7%^N%N%lGYdU_GS!gaR8T$NA@GzFi~z`l7hdl | ||
538 | zarZy6590|88pi(1zq;V(>38zM0sT&<zX;R5$1w3;`_JMG`;&I&0Y23DMx1%@(w(R9 | ||
539 | z4M$j;D5J+Gy%fijRQsctzFKf&cv|BAz#YLq3CZJWDdtL4u1u1|mkdcUp7|sxJC+?Y | ||
540 | z_@@s`v3j}Q7*z>6X~cwUxUL8G1KT)_XTp!KAbs;vCp{K3&~_X@+ew=-D}v`2MbFV0 | ||
541 | zQsVsL=rXi-pI*G|iiz;VTCutgUs)hDzV1+4?8KcoP3xROf<M%qC6lgVdpFt4<-|uM | ||
542 | z=#rl_b1#YjSIl6Toj2z_hOZcKupkdE(LozC(fN=FY(x|sk)ym|;Rq2E1xJWD%Z!ol | ||
543 | Gu>S+TT-130 | ||
544 | |||
545 | literal 0 | ||
546 | HcmV?d00001 | ||
547 | |||
548 | diff --git a/tests/data/acpi/q35/VIOT.viot b/tests/data/acpi/q35/VIOT.viot | ||
549 | index XXXXXXX..XXXXXXX 100644 | ||
550 | GIT binary patch | ||
551 | literal 112 | ||
552 | zcmWIZ^baXu00LVle`k+i1*eDrX9XZ&1PX!JAex!M0Hgv8m>C3sGzdcgBZCA3T-xBj | ||
553 | Q0Zb)W9Hva*zW_`e0M!8s0RR91 | ||
554 | |||
555 | literal 0 | ||
556 | HcmV?d00001 | ||
557 | |||
558 | -- | 311 | -- |
559 | 2.25.1 | 312 | 2.34.1 |
560 | |||
561 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Convert the instructions in the load/store memory tags instruction |
---|---|---|---|
2 | group to decodetree. | ||
2 | 3 | ||
3 | For A64, any input to an indirect branch can cause this. | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20230602155223.2040685-21-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/tcg/a64.decode | 25 +++ | ||
9 | target/arm/tcg/translate-a64.c | 360 ++++++++++++++++----------------- | ||
10 | 2 files changed, 199 insertions(+), 186 deletions(-) | ||
4 | 11 | ||
5 | For A32, many indirect branch paths force the branch to be aligned, | 12 | diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode |
6 | but BXWritePC does not. This includes the BX instruction but also | ||
7 | other interworking changes to PC. Prior to v8, this case is UNDEFINED. | ||
8 | With v8, this is CONSTRAINED UNPREDICTABLE and may either raise an | ||
9 | exception or force align the PC. | ||
10 | |||
11 | We choose to raise an exception because we have the infrastructure, | ||
12 | it makes the generated code for gen_bx simpler, and it has the | ||
13 | possibility of catching more guest bugs. | ||
14 | |||
15 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | --- | ||
19 | target/arm/helper.h | 1 + | ||
20 | target/arm/syndrome.h | 5 ++++ | ||
21 | linux-user/aarch64/cpu_loop.c | 46 ++++++++++++++++++++--------------- | ||
22 | target/arm/tlb_helper.c | 18 ++++++++++++++ | ||
23 | target/arm/translate-a64.c | 15 ++++++++++++ | ||
24 | target/arm/translate.c | 22 ++++++++++++++++- | ||
25 | 6 files changed, 87 insertions(+), 20 deletions(-) | ||
26 | |||
27 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/target/arm/helper.h | 14 | --- a/target/arm/tcg/a64.decode |
30 | +++ b/target/arm/helper.h | 15 | +++ b/target/arm/tcg/a64.decode |
31 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE, | 16 | @@ -XXX,XX +XXX,XX @@ LD_single 0 . 001101 . 1 . ..... 10 . 001 ..... ..... @ldst_single_d |
32 | DEF_HELPER_2(exception_internal, void, env, i32) | 17 | |
33 | DEF_HELPER_4(exception_with_syndrome, void, env, i32, i32, i32) | 18 | # Replicating load case |
34 | DEF_HELPER_2(exception_bkpt_insn, void, env, i32) | 19 | LD_single_repl 0 q:1 001101 p:1 1 . rm:5 11 . 0 scale:2 rn:5 rt:5 selem=%ldst_single_selem |
35 | +DEF_HELPER_2(exception_pc_alignment, noreturn, env, tl) | 20 | + |
36 | DEF_HELPER_1(setend, void, env) | 21 | +%tag_offset 12:s9 !function=scale_by_log2_tag_granule |
37 | DEF_HELPER_2(wfi, void, env, i32) | 22 | +&ldst_tag rn rt imm p w |
38 | DEF_HELPER_1(wfe, void, env) | 23 | +@ldst_tag ........ .. . ......... .. rn:5 rt:5 &ldst_tag imm=%tag_offset |
39 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h | 24 | +@ldst_tag_mult ........ .. . 000000000 .. rn:5 rt:5 &ldst_tag imm=0 |
25 | + | ||
26 | +STZGM 11011001 00 1 ......... 00 ..... ..... @ldst_tag_mult p=0 w=0 | ||
27 | +STG 11011001 00 1 ......... 01 ..... ..... @ldst_tag p=1 w=1 | ||
28 | +STG 11011001 00 1 ......... 10 ..... ..... @ldst_tag p=0 w=0 | ||
29 | +STG 11011001 00 1 ......... 11 ..... ..... @ldst_tag p=0 w=1 | ||
30 | + | ||
31 | +LDG 11011001 01 1 ......... 00 ..... ..... @ldst_tag p=0 w=0 | ||
32 | +STZG 11011001 01 1 ......... 01 ..... ..... @ldst_tag p=1 w=1 | ||
33 | +STZG 11011001 01 1 ......... 10 ..... ..... @ldst_tag p=0 w=0 | ||
34 | +STZG 11011001 01 1 ......... 11 ..... ..... @ldst_tag p=0 w=1 | ||
35 | + | ||
36 | +STGM 11011001 10 1 ......... 00 ..... ..... @ldst_tag_mult p=0 w=0 | ||
37 | +ST2G 11011001 10 1 ......... 01 ..... ..... @ldst_tag p=1 w=1 | ||
38 | +ST2G 11011001 10 1 ......... 10 ..... ..... @ldst_tag p=0 w=0 | ||
39 | +ST2G 11011001 10 1 ......... 11 ..... ..... @ldst_tag p=0 w=1 | ||
40 | + | ||
41 | +LDGM 11011001 11 1 ......... 00 ..... ..... @ldst_tag_mult p=0 w=0 | ||
42 | +STZ2G 11011001 11 1 ......... 01 ..... ..... @ldst_tag p=1 w=1 | ||
43 | +STZ2G 11011001 11 1 ......... 10 ..... ..... @ldst_tag p=0 w=0 | ||
44 | +STZ2G 11011001 11 1 ......... 11 ..... ..... @ldst_tag p=0 w=1 | ||
45 | diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/arm/syndrome.h | 47 | --- a/target/arm/tcg/translate-a64.c |
42 | +++ b/target/arm/syndrome.h | 48 | +++ b/target/arm/tcg/translate-a64.c |
43 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_illegalstate(void) | 49 | @@ -XXX,XX +XXX,XX @@ static int uimm_scaled(DisasContext *s, int x) |
44 | return (EC_ILLEGALSTATE << ARM_EL_EC_SHIFT) | ARM_EL_IL; | 50 | return imm << scale; |
45 | } | 51 | } |
46 | 52 | ||
47 | +static inline uint32_t syn_pcalignment(void) | 53 | +/* For load/store memory tags: scale offset by LOG2_TAG_GRANULE */ |
54 | +static int scale_by_log2_tag_granule(DisasContext *s, int x) | ||
48 | +{ | 55 | +{ |
49 | + return (EC_PCALIGNMENT << ARM_EL_EC_SHIFT) | ARM_EL_IL; | 56 | + return x << LOG2_TAG_GRANULE; |
50 | +} | 57 | +} |
51 | + | 58 | + |
52 | #endif /* TARGET_ARM_SYNDROME_H */ | 59 | /* |
53 | diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c | 60 | * Include the generated decoders. |
54 | index XXXXXXX..XXXXXXX 100644 | 61 | */ |
55 | --- a/linux-user/aarch64/cpu_loop.c | 62 | @@ -XXX,XX +XXX,XX @@ static bool trans_LD_single_repl(DisasContext *s, arg_LD_single_repl *a) |
56 | +++ b/linux-user/aarch64/cpu_loop.c | 63 | return true; |
57 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) | ||
58 | break; | ||
59 | case EXCP_PREFETCH_ABORT: | ||
60 | case EXCP_DATA_ABORT: | ||
61 | - /* We should only arrive here with EC in {DATAABORT, INSNABORT}. */ | ||
62 | ec = syn_get_ec(env->exception.syndrome); | ||
63 | - assert(ec == EC_DATAABORT || ec == EC_INSNABORT); | ||
64 | - | ||
65 | - /* Both EC have the same format for FSC, or close enough. */ | ||
66 | - fsc = extract32(env->exception.syndrome, 0, 6); | ||
67 | - switch (fsc) { | ||
68 | - case 0x04 ... 0x07: /* Translation fault, level {0-3} */ | ||
69 | - si_signo = TARGET_SIGSEGV; | ||
70 | - si_code = TARGET_SEGV_MAPERR; | ||
71 | + switch (ec) { | ||
72 | + case EC_DATAABORT: | ||
73 | + case EC_INSNABORT: | ||
74 | + /* Both EC have the same format for FSC, or close enough. */ | ||
75 | + fsc = extract32(env->exception.syndrome, 0, 6); | ||
76 | + switch (fsc) { | ||
77 | + case 0x04 ... 0x07: /* Translation fault, level {0-3} */ | ||
78 | + si_signo = TARGET_SIGSEGV; | ||
79 | + si_code = TARGET_SEGV_MAPERR; | ||
80 | + break; | ||
81 | + case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ | ||
82 | + case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ | ||
83 | + si_signo = TARGET_SIGSEGV; | ||
84 | + si_code = TARGET_SEGV_ACCERR; | ||
85 | + break; | ||
86 | + case 0x11: /* Synchronous Tag Check Fault */ | ||
87 | + si_signo = TARGET_SIGSEGV; | ||
88 | + si_code = TARGET_SEGV_MTESERR; | ||
89 | + break; | ||
90 | + case 0x21: /* Alignment fault */ | ||
91 | + si_signo = TARGET_SIGBUS; | ||
92 | + si_code = TARGET_BUS_ADRALN; | ||
93 | + break; | ||
94 | + default: | ||
95 | + g_assert_not_reached(); | ||
96 | + } | ||
97 | break; | ||
98 | - case 0x09 ... 0x0b: /* Access flag fault, level {1-3} */ | ||
99 | - case 0x0d ... 0x0f: /* Permission fault, level {1-3} */ | ||
100 | - si_signo = TARGET_SIGSEGV; | ||
101 | - si_code = TARGET_SEGV_ACCERR; | ||
102 | - break; | ||
103 | - case 0x11: /* Synchronous Tag Check Fault */ | ||
104 | - si_signo = TARGET_SIGSEGV; | ||
105 | - si_code = TARGET_SEGV_MTESERR; | ||
106 | - break; | ||
107 | - case 0x21: /* Alignment fault */ | ||
108 | + case EC_PCALIGNMENT: | ||
109 | si_signo = TARGET_SIGBUS; | ||
110 | si_code = TARGET_BUS_ADRALN; | ||
111 | break; | ||
112 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c | ||
113 | index XXXXXXX..XXXXXXX 100644 | ||
114 | --- a/target/arm/tlb_helper.c | ||
115 | +++ b/target/arm/tlb_helper.c | ||
116 | @@ -XXX,XX +XXX,XX @@ | ||
117 | #include "cpu.h" | ||
118 | #include "internals.h" | ||
119 | #include "exec/exec-all.h" | ||
120 | +#include "exec/helper-proto.h" | ||
121 | |||
122 | static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | ||
123 | unsigned int target_el, | ||
124 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, | ||
125 | arm_deliver_fault(cpu, vaddr, access_type, mmu_idx, &fi); | ||
126 | } | 64 | } |
127 | 65 | ||
128 | +void helper_exception_pc_alignment(CPUARMState *env, target_ulong pc) | 66 | -/* |
67 | - * Load/Store memory tags | ||
68 | - * | ||
69 | - * 31 30 29 24 22 21 12 10 5 0 | ||
70 | - * +-----+-------------+-----+---+------+-----+------+------+ | ||
71 | - * | 1 1 | 0 1 1 0 0 1 | op1 | 1 | imm9 | op2 | Rn | Rt | | ||
72 | - * +-----+-------------+-----+---+------+-----+------+------+ | ||
73 | - */ | ||
74 | -static void disas_ldst_tag(DisasContext *s, uint32_t insn) | ||
75 | +static bool trans_STZGM(DisasContext *s, arg_ldst_tag *a) | ||
76 | { | ||
77 | - int rt = extract32(insn, 0, 5); | ||
78 | - int rn = extract32(insn, 5, 5); | ||
79 | - uint64_t offset = sextract64(insn, 12, 9) << LOG2_TAG_GRANULE; | ||
80 | - int op2 = extract32(insn, 10, 2); | ||
81 | - int op1 = extract32(insn, 22, 2); | ||
82 | - bool is_load = false, is_pair = false, is_zero = false, is_mult = false; | ||
83 | - int index = 0; | ||
84 | TCGv_i64 addr, clean_addr, tcg_rt; | ||
85 | + int size = 4 << s->dcz_blocksize; | ||
86 | |||
87 | - /* We checked insn bits [29:24,21] in the caller. */ | ||
88 | - if (extract32(insn, 30, 2) != 3) { | ||
89 | - goto do_unallocated; | ||
90 | + if (!dc_isar_feature(aa64_mte, s)) { | ||
91 | + return false; | ||
92 | + } | ||
93 | + if (s->current_el == 0) { | ||
94 | + return false; | ||
95 | } | ||
96 | |||
97 | - /* | ||
98 | - * @index is a tri-state variable which has 3 states: | ||
99 | - * < 0 : post-index, writeback | ||
100 | - * = 0 : signed offset | ||
101 | - * > 0 : pre-index, writeback | ||
102 | - */ | ||
103 | - switch (op1) { | ||
104 | - case 0: | ||
105 | - if (op2 != 0) { | ||
106 | - /* STG */ | ||
107 | - index = op2 - 2; | ||
108 | - } else { | ||
109 | - /* STZGM */ | ||
110 | - if (s->current_el == 0 || offset != 0) { | ||
111 | - goto do_unallocated; | ||
112 | - } | ||
113 | - is_mult = is_zero = true; | ||
114 | - } | ||
115 | - break; | ||
116 | - case 1: | ||
117 | - if (op2 != 0) { | ||
118 | - /* STZG */ | ||
119 | - is_zero = true; | ||
120 | - index = op2 - 2; | ||
121 | - } else { | ||
122 | - /* LDG */ | ||
123 | - is_load = true; | ||
124 | - } | ||
125 | - break; | ||
126 | - case 2: | ||
127 | - if (op2 != 0) { | ||
128 | - /* ST2G */ | ||
129 | - is_pair = true; | ||
130 | - index = op2 - 2; | ||
131 | - } else { | ||
132 | - /* STGM */ | ||
133 | - if (s->current_el == 0 || offset != 0) { | ||
134 | - goto do_unallocated; | ||
135 | - } | ||
136 | - is_mult = true; | ||
137 | - } | ||
138 | - break; | ||
139 | - case 3: | ||
140 | - if (op2 != 0) { | ||
141 | - /* STZ2G */ | ||
142 | - is_pair = is_zero = true; | ||
143 | - index = op2 - 2; | ||
144 | - } else { | ||
145 | - /* LDGM */ | ||
146 | - if (s->current_el == 0 || offset != 0) { | ||
147 | - goto do_unallocated; | ||
148 | - } | ||
149 | - is_mult = is_load = true; | ||
150 | - } | ||
151 | - break; | ||
152 | - | ||
153 | - default: | ||
154 | - do_unallocated: | ||
155 | - unallocated_encoding(s); | ||
156 | - return; | ||
157 | - } | ||
158 | - | ||
159 | - if (is_mult | ||
160 | - ? !dc_isar_feature(aa64_mte, s) | ||
161 | - : !dc_isar_feature(aa64_mte_insn_reg, s)) { | ||
162 | - goto do_unallocated; | ||
163 | - } | ||
164 | - | ||
165 | - if (rn == 31) { | ||
166 | + if (a->rn == 31) { | ||
167 | gen_check_sp_alignment(s); | ||
168 | } | ||
169 | |||
170 | - addr = read_cpu_reg_sp(s, rn, true); | ||
171 | - if (index >= 0) { | ||
172 | + addr = read_cpu_reg_sp(s, a->rn, true); | ||
173 | + tcg_gen_addi_i64(addr, addr, a->imm); | ||
174 | + tcg_rt = cpu_reg(s, a->rt); | ||
175 | + | ||
176 | + if (s->ata) { | ||
177 | + gen_helper_stzgm_tags(cpu_env, addr, tcg_rt); | ||
178 | + } | ||
179 | + /* | ||
180 | + * The non-tags portion of STZGM is mostly like DC_ZVA, | ||
181 | + * except the alignment happens before the access. | ||
182 | + */ | ||
183 | + clean_addr = clean_data_tbi(s, addr); | ||
184 | + tcg_gen_andi_i64(clean_addr, clean_addr, -size); | ||
185 | + gen_helper_dc_zva(cpu_env, clean_addr); | ||
186 | + return true; | ||
187 | +} | ||
188 | + | ||
189 | +static bool trans_STGM(DisasContext *s, arg_ldst_tag *a) | ||
129 | +{ | 190 | +{ |
130 | + ARMMMUFaultInfo fi = { .type = ARMFault_Alignment }; | 191 | + TCGv_i64 addr, clean_addr, tcg_rt; |
131 | + int target_el = exception_target_el(env); | 192 | + |
132 | + int mmu_idx = cpu_mmu_index(env, true); | 193 | + if (!dc_isar_feature(aa64_mte, s)) { |
133 | + uint32_t fsc; | 194 | + return false; |
134 | + | 195 | + } |
135 | + env->exception.vaddress = pc; | 196 | + if (s->current_el == 0) { |
136 | + | 197 | + return false; |
137 | + /* | 198 | + } |
138 | + * Note that the fsc is not applicable to this exception, | 199 | + |
139 | + * since any syndrome is pcalignment not insn_abort. | 200 | + if (a->rn == 31) { |
140 | + */ | 201 | + gen_check_sp_alignment(s); |
141 | + env->exception.fsr = compute_fsr_fsc(env, &fi, target_el, mmu_idx, &fsc); | 202 | + } |
142 | + raise_exception(env, EXCP_PREFETCH_ABORT, syn_pcalignment(), target_el); | 203 | + |
204 | + addr = read_cpu_reg_sp(s, a->rn, true); | ||
205 | + tcg_gen_addi_i64(addr, addr, a->imm); | ||
206 | + tcg_rt = cpu_reg(s, a->rt); | ||
207 | + | ||
208 | + if (s->ata) { | ||
209 | + gen_helper_stgm(cpu_env, addr, tcg_rt); | ||
210 | + } else { | ||
211 | + MMUAccessType acc = MMU_DATA_STORE; | ||
212 | + int size = 4 << GMID_EL1_BS; | ||
213 | + | ||
214 | + clean_addr = clean_data_tbi(s, addr); | ||
215 | + tcg_gen_andi_i64(clean_addr, clean_addr, -size); | ||
216 | + gen_probe_access(s, clean_addr, acc, size); | ||
217 | + } | ||
218 | + return true; | ||
143 | +} | 219 | +} |
144 | + | 220 | + |
145 | #if !defined(CONFIG_USER_ONLY) | 221 | +static bool trans_LDGM(DisasContext *s, arg_ldst_tag *a) |
146 | 222 | +{ | |
147 | /* | 223 | + TCGv_i64 addr, clean_addr, tcg_rt; |
148 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 224 | + |
149 | index XXXXXXX..XXXXXXX 100644 | 225 | + if (!dc_isar_feature(aa64_mte, s)) { |
150 | --- a/target/arm/translate-a64.c | 226 | + return false; |
151 | +++ b/target/arm/translate-a64.c | 227 | + } |
152 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 228 | + if (s->current_el == 0) { |
153 | uint64_t pc = s->base.pc_next; | 229 | + return false; |
154 | uint32_t insn; | 230 | + } |
155 | 231 | + | |
156 | + /* Singlestep exceptions have the highest priority. */ | 232 | + if (a->rn == 31) { |
157 | if (s->ss_active && !s->pstate_ss) { | 233 | + gen_check_sp_alignment(s); |
158 | /* Singlestep state is Active-pending. | 234 | + } |
159 | * If we're in this state at the start of a TB then either | 235 | + |
160 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 236 | + addr = read_cpu_reg_sp(s, a->rn, true); |
161 | return; | 237 | + tcg_gen_addi_i64(addr, addr, a->imm); |
162 | } | 238 | + tcg_rt = cpu_reg(s, a->rt); |
163 | 239 | + | |
164 | + if (pc & 3) { | 240 | + if (s->ata) { |
241 | + gen_helper_ldgm(tcg_rt, cpu_env, addr); | ||
242 | + } else { | ||
243 | + MMUAccessType acc = MMU_DATA_LOAD; | ||
244 | + int size = 4 << GMID_EL1_BS; | ||
245 | + | ||
246 | + clean_addr = clean_data_tbi(s, addr); | ||
247 | + tcg_gen_andi_i64(clean_addr, clean_addr, -size); | ||
248 | + gen_probe_access(s, clean_addr, acc, size); | ||
249 | + /* The result tags are zeros. */ | ||
250 | + tcg_gen_movi_i64(tcg_rt, 0); | ||
251 | + } | ||
252 | + return true; | ||
253 | +} | ||
254 | + | ||
255 | +static bool trans_LDG(DisasContext *s, arg_ldst_tag *a) | ||
256 | +{ | ||
257 | + TCGv_i64 addr, clean_addr, tcg_rt; | ||
258 | + | ||
259 | + if (!dc_isar_feature(aa64_mte_insn_reg, s)) { | ||
260 | + return false; | ||
261 | + } | ||
262 | + | ||
263 | + if (a->rn == 31) { | ||
264 | + gen_check_sp_alignment(s); | ||
265 | + } | ||
266 | + | ||
267 | + addr = read_cpu_reg_sp(s, a->rn, true); | ||
268 | + if (!a->p) { | ||
269 | /* pre-index or signed offset */ | ||
270 | - tcg_gen_addi_i64(addr, addr, offset); | ||
271 | + tcg_gen_addi_i64(addr, addr, a->imm); | ||
272 | } | ||
273 | |||
274 | - if (is_mult) { | ||
275 | - tcg_rt = cpu_reg(s, rt); | ||
276 | + tcg_gen_andi_i64(addr, addr, -TAG_GRANULE); | ||
277 | + tcg_rt = cpu_reg(s, a->rt); | ||
278 | + if (s->ata) { | ||
279 | + gen_helper_ldg(tcg_rt, cpu_env, addr, tcg_rt); | ||
280 | + } else { | ||
165 | + /* | 281 | + /* |
166 | + * PC alignment fault. This has priority over the instruction abort | 282 | + * Tag access disabled: we must check for aborts on the load |
167 | + * that we would receive from a translation fault via arm_ldl_code. | 283 | + * load from [rn+offset], and then insert a 0 tag into rt. |
168 | + * This should only be possible after an indirect branch, at the | ||
169 | + * start of the TB. | ||
170 | + */ | 284 | + */ |
171 | + assert(s->base.num_insns == 1); | 285 | + clean_addr = clean_data_tbi(s, addr); |
172 | + gen_helper_exception_pc_alignment(cpu_env, tcg_constant_tl(pc)); | 286 | + gen_probe_access(s, clean_addr, MMU_DATA_LOAD, MO_8); |
173 | + s->base.is_jmp = DISAS_NORETURN; | 287 | + gen_address_with_allocation_tag0(tcg_rt, tcg_rt); |
174 | + s->base.pc_next = QEMU_ALIGN_UP(pc, 4); | 288 | + } |
175 | + return; | 289 | |
176 | + } | 290 | - if (is_zero) { |
177 | + | 291 | - int size = 4 << s->dcz_blocksize; |
178 | s->pc_curr = pc; | 292 | - |
179 | insn = arm_ldl_code(env, &s->base, pc, s->sctlr_b); | 293 | - if (s->ata) { |
180 | s->insn = insn; | 294 | - gen_helper_stzgm_tags(cpu_env, addr, tcg_rt); |
181 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 295 | - } |
182 | index XXXXXXX..XXXXXXX 100644 | 296 | - /* |
183 | --- a/target/arm/translate.c | 297 | - * The non-tags portion of STZGM is mostly like DC_ZVA, |
184 | +++ b/target/arm/translate.c | 298 | - * except the alignment happens before the access. |
185 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 299 | - */ |
186 | uint32_t pc = dc->base.pc_next; | 300 | - clean_addr = clean_data_tbi(s, addr); |
187 | unsigned int insn; | 301 | - tcg_gen_andi_i64(clean_addr, clean_addr, -size); |
188 | 302 | - gen_helper_dc_zva(cpu_env, clean_addr); | |
189 | - if (arm_check_ss_active(dc) || arm_check_kernelpage(dc)) { | 303 | - } else if (s->ata) { |
190 | + /* Singlestep exceptions have the highest priority. */ | 304 | - if (is_load) { |
191 | + if (arm_check_ss_active(dc)) { | 305 | - gen_helper_ldgm(tcg_rt, cpu_env, addr); |
192 | + dc->base.pc_next = pc + 4; | 306 | - } else { |
193 | + return; | 307 | - gen_helper_stgm(cpu_env, addr, tcg_rt); |
194 | + } | 308 | - } |
195 | + | 309 | - } else { |
196 | + if (pc & 3) { | 310 | - MMUAccessType acc = is_load ? MMU_DATA_LOAD : MMU_DATA_STORE; |
311 | - int size = 4 << GMID_EL1_BS; | ||
312 | - | ||
313 | - clean_addr = clean_data_tbi(s, addr); | ||
314 | - tcg_gen_andi_i64(clean_addr, clean_addr, -size); | ||
315 | - gen_probe_access(s, clean_addr, acc, size); | ||
316 | - | ||
317 | - if (is_load) { | ||
318 | - /* The result tags are zeros. */ | ||
319 | - tcg_gen_movi_i64(tcg_rt, 0); | ||
320 | - } | ||
321 | + if (a->w) { | ||
322 | + /* pre-index or post-index */ | ||
323 | + if (a->p) { | ||
324 | + /* post-index */ | ||
325 | + tcg_gen_addi_i64(addr, addr, a->imm); | ||
326 | } | ||
327 | - return; | ||
328 | + tcg_gen_mov_i64(cpu_reg_sp(s, a->rn), addr); | ||
329 | + } | ||
330 | + return true; | ||
331 | +} | ||
332 | + | ||
333 | +static bool do_STG(DisasContext *s, arg_ldst_tag *a, bool is_zero, bool is_pair) | ||
334 | +{ | ||
335 | + TCGv_i64 addr, tcg_rt; | ||
336 | + | ||
337 | + if (a->rn == 31) { | ||
338 | + gen_check_sp_alignment(s); | ||
339 | } | ||
340 | |||
341 | - if (is_load) { | ||
342 | - tcg_gen_andi_i64(addr, addr, -TAG_GRANULE); | ||
343 | - tcg_rt = cpu_reg(s, rt); | ||
344 | - if (s->ata) { | ||
345 | - gen_helper_ldg(tcg_rt, cpu_env, addr, tcg_rt); | ||
346 | + addr = read_cpu_reg_sp(s, a->rn, true); | ||
347 | + if (!a->p) { | ||
348 | + /* pre-index or signed offset */ | ||
349 | + tcg_gen_addi_i64(addr, addr, a->imm); | ||
350 | + } | ||
351 | + tcg_rt = cpu_reg_sp(s, a->rt); | ||
352 | + if (!s->ata) { | ||
197 | + /* | 353 | + /* |
198 | + * PC alignment fault. This has priority over the instruction abort | 354 | + * For STG and ST2G, we need to check alignment and probe memory. |
199 | + * that we would receive from a translation fault via arm_ldl_code | 355 | + * TODO: For STZG and STZ2G, we could rely on the stores below, |
200 | + * (or the execution of the kernelpage entrypoint). This should only | 356 | + * at least for system mode; user-only won't enforce alignment. |
201 | + * be possible after an indirect branch, at the start of the TB. | ||
202 | + */ | 357 | + */ |
203 | + assert(dc->base.num_insns == 1); | 358 | + if (is_pair) { |
204 | + gen_helper_exception_pc_alignment(cpu_env, tcg_constant_tl(pc)); | 359 | + gen_helper_st2g_stub(cpu_env, addr); |
205 | + dc->base.is_jmp = DISAS_NORETURN; | 360 | } else { |
206 | + dc->base.pc_next = QEMU_ALIGN_UP(pc, 4); | 361 | - /* |
207 | + return; | 362 | - * Tag access disabled: we must check for aborts on the load |
208 | + } | 363 | - * load from [rn+offset], and then insert a 0 tag into rt. |
209 | + | 364 | - */ |
210 | + if (arm_check_kernelpage(dc)) { | 365 | - clean_addr = clean_data_tbi(s, addr); |
211 | dc->base.pc_next = pc + 4; | 366 | - gen_probe_access(s, clean_addr, MMU_DATA_LOAD, MO_8); |
212 | return; | 367 | - gen_address_with_allocation_tag0(tcg_rt, tcg_rt); |
213 | } | 368 | + gen_helper_stg_stub(cpu_env, addr); |
369 | + } | ||
370 | + } else if (tb_cflags(s->base.tb) & CF_PARALLEL) { | ||
371 | + if (is_pair) { | ||
372 | + gen_helper_st2g_parallel(cpu_env, addr, tcg_rt); | ||
373 | + } else { | ||
374 | + gen_helper_stg_parallel(cpu_env, addr, tcg_rt); | ||
375 | } | ||
376 | } else { | ||
377 | - tcg_rt = cpu_reg_sp(s, rt); | ||
378 | - if (!s->ata) { | ||
379 | - /* | ||
380 | - * For STG and ST2G, we need to check alignment and probe memory. | ||
381 | - * TODO: For STZG and STZ2G, we could rely on the stores below, | ||
382 | - * at least for system mode; user-only won't enforce alignment. | ||
383 | - */ | ||
384 | - if (is_pair) { | ||
385 | - gen_helper_st2g_stub(cpu_env, addr); | ||
386 | - } else { | ||
387 | - gen_helper_stg_stub(cpu_env, addr); | ||
388 | - } | ||
389 | - } else if (tb_cflags(s->base.tb) & CF_PARALLEL) { | ||
390 | - if (is_pair) { | ||
391 | - gen_helper_st2g_parallel(cpu_env, addr, tcg_rt); | ||
392 | - } else { | ||
393 | - gen_helper_stg_parallel(cpu_env, addr, tcg_rt); | ||
394 | - } | ||
395 | + if (is_pair) { | ||
396 | + gen_helper_st2g(cpu_env, addr, tcg_rt); | ||
397 | } else { | ||
398 | - if (is_pair) { | ||
399 | - gen_helper_st2g(cpu_env, addr, tcg_rt); | ||
400 | - } else { | ||
401 | - gen_helper_stg(cpu_env, addr, tcg_rt); | ||
402 | - } | ||
403 | + gen_helper_stg(cpu_env, addr, tcg_rt); | ||
404 | } | ||
405 | } | ||
406 | |||
407 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_tag(DisasContext *s, uint32_t insn) | ||
408 | } | ||
409 | } | ||
410 | |||
411 | - if (index != 0) { | ||
412 | + if (a->w) { | ||
413 | /* pre-index or post-index */ | ||
414 | - if (index < 0) { | ||
415 | + if (a->p) { | ||
416 | /* post-index */ | ||
417 | - tcg_gen_addi_i64(addr, addr, offset); | ||
418 | + tcg_gen_addi_i64(addr, addr, a->imm); | ||
419 | } | ||
420 | - tcg_gen_mov_i64(cpu_reg_sp(s, rn), addr); | ||
421 | + tcg_gen_mov_i64(cpu_reg_sp(s, a->rn), addr); | ||
422 | } | ||
423 | + return true; | ||
424 | } | ||
425 | |||
426 | -/* Loads and stores */ | ||
427 | -static void disas_ldst(DisasContext *s, uint32_t insn) | ||
428 | -{ | ||
429 | - switch (extract32(insn, 24, 6)) { | ||
430 | - case 0x19: | ||
431 | - if (extract32(insn, 21, 1) != 0) { | ||
432 | - disas_ldst_tag(s, insn); | ||
433 | - } else { | ||
434 | - unallocated_encoding(s); | ||
435 | - } | ||
436 | - break; | ||
437 | - default: | ||
438 | - unallocated_encoding(s); | ||
439 | - break; | ||
440 | - } | ||
441 | -} | ||
442 | +TRANS_FEAT(STG, aa64_mte_insn_reg, do_STG, a, false, false) | ||
443 | +TRANS_FEAT(STZG, aa64_mte_insn_reg, do_STG, a, true, false) | ||
444 | +TRANS_FEAT(ST2G, aa64_mte_insn_reg, do_STG, a, false, true) | ||
445 | +TRANS_FEAT(STZ2G, aa64_mte_insn_reg, do_STG, a, true, true) | ||
446 | |||
447 | typedef void ArithTwoOp(TCGv_i64, TCGv_i64, TCGv_i64); | ||
448 | |||
449 | @@ -XXX,XX +XXX,XX @@ static bool btype_destination_ok(uint32_t insn, bool bt, int btype) | ||
450 | static void disas_a64_legacy(DisasContext *s, uint32_t insn) | ||
451 | { | ||
452 | switch (extract32(insn, 25, 4)) { | ||
453 | - case 0x4: | ||
454 | - case 0x6: | ||
455 | - case 0xc: | ||
456 | - case 0xe: /* Loads and stores */ | ||
457 | - disas_ldst(s, insn); | ||
458 | - break; | ||
459 | case 0x5: | ||
460 | case 0xd: /* Data processing - register */ | ||
461 | disas_data_proc_reg(s, insn); | ||
214 | -- | 462 | -- |
215 | 2.25.1 | 463 | 2.34.1 |
216 | |||
217 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | In commit 2c5fa0778c3b430 we fixed an endianness bug in the Allwinner |
---|---|---|---|
2 | A10 PIC model; however in the process we introduced a regression. | ||
3 | This is because the old code was robust against the incoming 'level' | ||
4 | argument being something other than 0 or 1, whereas the new code was | ||
5 | not. | ||
2 | 6 | ||
3 | This is the latest URL for the OpenBMC CI. The old URL still works, but | 7 | In particular, the allwinner-sdhost code treats its IRQ line |
4 | redirects. | 8 | as 0-vs-non-0 rather than 0-vs-1, so when the SD controller |
9 | set its IRQ line for any reason other than transmit the | ||
10 | interrupt controller would ignore it. The observed effect | ||
11 | was a guest timeout when rebooting the guest kernel. | ||
5 | 12 | ||
6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 13 | Handle level values other than 0 or 1, to restore the old |
7 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 14 | behaviour. |
8 | Message-id: 20211117065752.330632-3-joel@jms.id.au | 15 | |
16 | Fixes: 2c5fa0778c3b430 ("hw/intc/allwinner-a10-pic: Don't use set_bit()/clear_bit()") | ||
17 | Cc: qemu-stable@nongnu.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
20 | Tested-by: Guenter Roeck <linux@roeck-us.net> | ||
21 | Message-id: 20230606104609.3692557-2-peter.maydell@linaro.org | ||
10 | --- | 22 | --- |
11 | docs/system/arm/aspeed.rst | 2 +- | 23 | hw/intc/allwinner-a10-pic.c | 2 +- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 24 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 25 | ||
14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | 26 | diff --git a/hw/intc/allwinner-a10-pic.c b/hw/intc/allwinner-a10-pic.c |
15 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/docs/system/arm/aspeed.rst | 28 | --- a/hw/intc/allwinner-a10-pic.c |
17 | +++ b/docs/system/arm/aspeed.rst | 29 | +++ b/hw/intc/allwinner-a10-pic.c |
18 | @@ -XXX,XX +XXX,XX @@ The Aspeed machines can be started using the ``-kernel`` option to | 30 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_pic_set_irq(void *opaque, int irq, int level) |
19 | load a Linux kernel or from a firmware. Images can be downloaded from | 31 | AwA10PICState *s = opaque; |
20 | the OpenBMC jenkins : | 32 | uint32_t *pending_reg = &s->irq_pending[irq / 32]; |
21 | 33 | ||
22 | - https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/distro=ubuntu,label=docker-builder | 34 | - *pending_reg = deposit32(*pending_reg, irq % 32, 1, level); |
23 | + https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/ | 35 | + *pending_reg = deposit32(*pending_reg, irq % 32, 1, !!level); |
24 | 36 | aw_a10_pic_update(s); | |
25 | or directly from the OpenBMC GitHub release repository : | 37 | } |
26 | 38 | ||
27 | -- | 39 | -- |
28 | 2.25.1 | 40 | 2.34.1 |
29 | 41 | ||
30 | 42 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | QEMU allows qemu_irq lines to transfer arbitrary integers. However |
---|---|---|---|
2 | the convention is that for a simple IRQ line the values transferred | ||
3 | are always 0 and 1. The A10 SD controller device instead assumes a | ||
4 | 0-vs-non-0 convention, which happens to work with the interrupt | ||
5 | controller it is wired up to. | ||
2 | 6 | ||
3 | While trying to debug a GIC ITS failure I saw some guest errors that | 7 | Coerce the value to boolean to follow our usual convention. |
4 | had poor formatting as well as leaving me confused as to what failed. | ||
5 | As most of the checks aren't possible without a valid dte split that | ||
6 | check apart and then check the other conditions in steps. This avoids | ||
7 | us relying on undefined data. | ||
8 | 8 | ||
9 | I still get a failure with the current kvm-unit-tests but at least I | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | know (partially) why now: | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Tested-by: Guenter Roeck <linux@roeck-us.net> | ||
12 | Message-id: 20230606104609.3692557-3-peter.maydell@linaro.org | ||
13 | --- | ||
14 | hw/sd/allwinner-sdhost.c | 2 +- | ||
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
11 | 16 | ||
12 | Exception return from AArch64 EL1 to AArch64 EL1 PC 0x40080588 | 17 | diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c |
13 | PASS: gicv3: its-trigger: inv/invall: dev2/eventid=20 now triggers an LPI | ||
14 | ITS: MAPD devid=2 size = 0x8 itt=0x40430000 valid=0 | ||
15 | INT dev_id=2 event_id=20 | ||
16 | process_its_cmd: invalid command attributes: invalid dte: 0 for 2 (MEM_TX: 0) | ||
17 | PASS: gicv3: its-trigger: mapd valid=false: no LPI after device unmap | ||
18 | SUMMARY: 6 tests, 1 unexpected failures | ||
19 | |||
20 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
21 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | Message-id: 20211112170454.3158925-1-alex.bennee@linaro.org | ||
23 | Cc: Shashi Mallela <shashi.mallela@linaro.org> | ||
24 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
26 | --- | ||
27 | hw/intc/arm_gicv3_its.c | 39 +++++++++++++++++++++++++++------------ | ||
28 | 1 file changed, 27 insertions(+), 12 deletions(-) | ||
29 | |||
30 | diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/hw/intc/arm_gicv3_its.c | 19 | --- a/hw/sd/allwinner-sdhost.c |
33 | +++ b/hw/intc/arm_gicv3_its.c | 20 | +++ b/hw/sd/allwinner-sdhost.c |
34 | @@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset, | 21 | @@ -XXX,XX +XXX,XX @@ static void allwinner_sdhost_update_irq(AwSdHostState *s) |
35 | if (res != MEMTX_OK) { | ||
36 | return result; | ||
37 | } | ||
38 | + } else { | ||
39 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
40 | + "%s: invalid command attributes: " | ||
41 | + "invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n", | ||
42 | + __func__, dte, devid, res); | ||
43 | + return result; | ||
44 | } | 22 | } |
45 | 23 | ||
46 | - if ((devid > s->dt.maxids.max_devids) || !dte_valid || !ite_valid || | 24 | trace_allwinner_sdhost_update_irq(irq); |
47 | - !cte_valid || (eventid > max_eventid)) { | 25 | - qemu_set_irq(s->irq, irq); |
48 | + | 26 | + qemu_set_irq(s->irq, !!irq); |
49 | + /* | 27 | } |
50 | + * In this implementation, in case of guest errors we ignore the | 28 | |
51 | + * command and move onto the next command in the queue. | 29 | static void allwinner_sdhost_update_transfer_cnt(AwSdHostState *s, |
52 | + */ | ||
53 | + if (devid > s->dt.maxids.max_devids) { | ||
54 | qemu_log_mask(LOG_GUEST_ERROR, | ||
55 | - "%s: invalid command attributes " | ||
56 | - "devid %d or eventid %d or invalid dte %d or" | ||
57 | - "invalid cte %d or invalid ite %d\n", | ||
58 | - __func__, devid, eventid, dte_valid, cte_valid, | ||
59 | - ite_valid); | ||
60 | - /* | ||
61 | - * in this implementation, in case of error | ||
62 | - * we ignore this command and move onto the next | ||
63 | - * command in the queue | ||
64 | - */ | ||
65 | + "%s: invalid command attributes: devid %d>%d", | ||
66 | + __func__, devid, s->dt.maxids.max_devids); | ||
67 | + | ||
68 | + } else if (!dte_valid || !ite_valid || !cte_valid) { | ||
69 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
70 | + "%s: invalid command attributes: " | ||
71 | + "dte: %s, ite: %s, cte: %s\n", | ||
72 | + __func__, | ||
73 | + dte_valid ? "valid" : "invalid", | ||
74 | + ite_valid ? "valid" : "invalid", | ||
75 | + cte_valid ? "valid" : "invalid"); | ||
76 | + } else if (eventid > max_eventid) { | ||
77 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
78 | + "%s: invalid command attributes: eventid %d > %d\n", | ||
79 | + __func__, eventid, max_eventid); | ||
80 | } else { | ||
81 | /* | ||
82 | * Current implementation only supports rdbase == procnum | ||
83 | -- | 30 | -- |
84 | 2.25.1 | 31 | 2.34.1 |
85 | 32 | ||
86 | 33 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | The nrf51_timer has a free-running counter which we implement using |
---|---|---|---|
2 | the pattern of using two fields (update_counter_ns, counter) to track | ||
3 | the last point at which we calculated the counter value, and the | ||
4 | counter value at that time. Then we can find the current counter | ||
5 | value by converting the difference in wall-clock time between then | ||
6 | and now to a tick count that we need to add to the counter value. | ||
2 | 7 | ||
3 | Add X11, FP5280G2, G220A, Rainier and Fuji. Mention that Swift will be | 8 | Unfortunately the nrf51_timer's implementation of this has a bug |
4 | removed in v7.0. | 9 | which means it loses time every time update_counter() is called. |
10 | After updating s->counter it always sets s->update_counter_ns to | ||
11 | 'now', even though the actual point when s->counter hit the new value | ||
12 | will be some point in the past (half a tick, say). In the worst case | ||
13 | (guest code in a tight loop reading the counter, icount mode) the | ||
14 | counter is continually queried less than a tick after it was last | ||
15 | read, so s->counter never advances but s->update_counter_ns does, and | ||
16 | the guest never makes forward progress. | ||
5 | 17 | ||
6 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 18 | The fix for this is to only advance update_counter_ns to the |
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 19 | timestamp of the last tick, not all the way to 'now'. (This is the |
8 | Message-id: 20211117065752.330632-2-joel@jms.id.au | 20 | pattern used in hw/misc/mps2-fpgaio.c's counter.) |
21 | |||
22 | Cc: qemu-stable@nongnu.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
24 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
25 | Message-id: 20230606134917.3782215-1-peter.maydell@linaro.org | ||
10 | --- | 26 | --- |
11 | docs/system/arm/aspeed.rst | 7 ++++++- | 27 | hw/timer/nrf51_timer.c | 7 ++++++- |
12 | 1 file changed, 6 insertions(+), 1 deletion(-) | 28 | 1 file changed, 6 insertions(+), 1 deletion(-) |
13 | 29 | ||
14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | 30 | diff --git a/hw/timer/nrf51_timer.c b/hw/timer/nrf51_timer.c |
15 | index XXXXXXX..XXXXXXX 100644 | 31 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/docs/system/arm/aspeed.rst | 32 | --- a/hw/timer/nrf51_timer.c |
17 | +++ b/docs/system/arm/aspeed.rst | 33 | +++ b/hw/timer/nrf51_timer.c |
18 | @@ -XXX,XX +XXX,XX @@ AST2400 SoC based machines : | 34 | @@ -XXX,XX +XXX,XX @@ static uint32_t update_counter(NRF51TimerState *s, int64_t now) |
19 | 35 | uint32_t ticks = ns_to_ticks(s, now - s->update_counter_ns); | |
20 | - ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC | 36 | |
21 | - ``quanta-q71l-bmc`` OpenBMC Quanta BMC | 37 | s->counter = (s->counter + ticks) % BIT(bitwidths[s->bitmode]); |
22 | +- ``supermicrox11-bmc`` Supermicro X11 BMC | 38 | - s->update_counter_ns = now; |
23 | 39 | + /* | |
24 | AST2500 SoC based machines : | 40 | + * Only advance the sync time to the timestamp of the last tick, |
25 | 41 | + * not all the way to 'now', so we don't lose time if we do | |
26 | @@ -XXX,XX +XXX,XX @@ AST2500 SoC based machines : | 42 | + * multiple resyncs in a single tick. |
27 | - ``romulus-bmc`` OpenPOWER Romulus POWER9 BMC | 43 | + */ |
28 | - ``witherspoon-bmc`` OpenPOWER Witherspoon POWER9 BMC | 44 | + s->update_counter_ns += ticks_to_ns(s, ticks); |
29 | - ``sonorapass-bmc`` OCP SonoraPass BMC | 45 | return ticks; |
30 | -- ``swift-bmc`` OpenPOWER Swift BMC POWER9 | 46 | } |
31 | +- ``swift-bmc`` OpenPOWER Swift BMC POWER9 (to be removed in v7.0) | 47 | |
32 | +- ``fp5280g2-bmc`` Inspur FP5280G2 BMC | ||
33 | +- ``g220a-bmc`` Bytedance G220A BMC | ||
34 | |||
35 | AST2600 SoC based machines : | ||
36 | |||
37 | - ``ast2600-evb`` Aspeed AST2600 Evaluation board (Cortex-A7) | ||
38 | - ``tacoma-bmc`` OpenPOWER Witherspoon POWER9 AST2600 BMC | ||
39 | +- ``rainier-bmc`` IBM Rainier POWER10 BMC | ||
40 | +- ``fuji-bmc`` Facebook Fuji BMC | ||
41 | |||
42 | Supported devices | ||
43 | ----------------- | ||
44 | -- | 48 | -- |
45 | 2.25.1 | 49 | 2.34.1 |
46 | |||
47 | diff view generated by jsdifflib |
1 | From: Jean-Philippe Brucker <jean-philippe@linaro.org> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When a virtio-iommu is instantiated, describe it using the ACPI VIOT | 3 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
4 | table. | 4 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
5 | 5 | Message-id: 20230607092112.655098-1-marcin.juszkiewicz@linaro.org | |
6 | Acked-by: Igor Mammedov <imammedo@redhat.com> | ||
7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
8 | Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
9 | Message-id: 20211210170415.583179-2-jean-philippe@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 7 | --- |
12 | hw/arm/virt-acpi-build.c | 7 +++++++ | 8 | hw/arm/Kconfig | 1 + |
13 | hw/arm/Kconfig | 1 + | 9 | 1 file changed, 1 insertion(+) |
14 | 2 files changed, 8 insertions(+) | ||
15 | 10 | ||
16 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/arm/virt-acpi-build.c | ||
19 | +++ b/hw/arm/virt-acpi-build.c | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #include "kvm_arm.h" | ||
22 | #include "migration/vmstate.h" | ||
23 | #include "hw/acpi/ghes.h" | ||
24 | +#include "hw/acpi/viot.h" | ||
25 | |||
26 | #define ARM_SPI_BASE 32 | ||
27 | |||
28 | @@ -XXX,XX +XXX,XX @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) | ||
29 | } | ||
30 | #endif | ||
31 | |||
32 | + if (vms->iommu == VIRT_IOMMU_VIRTIO) { | ||
33 | + acpi_add_table(table_offsets, tables_blob); | ||
34 | + build_viot(ms, tables_blob, tables->linker, vms->virtio_iommu_bdf, | ||
35 | + vms->oem_id, vms->oem_table_id); | ||
36 | + } | ||
37 | + | ||
38 | /* XSDT is pointed to by RSDP */ | ||
39 | xsdt = tables_blob->len; | ||
40 | build_xsdt(tables_blob, tables->linker, table_offsets, vms->oem_id, | ||
41 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | 11 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
42 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/hw/arm/Kconfig | 13 | --- a/hw/arm/Kconfig |
44 | +++ b/hw/arm/Kconfig | 14 | +++ b/hw/arm/Kconfig |
45 | @@ -XXX,XX +XXX,XX @@ config ARM_VIRT | 15 | @@ -XXX,XX +XXX,XX @@ config SBSA_REF |
46 | select DIMM | 16 | select PL061 # GPIO |
47 | select ACPI_HW_REDUCED | 17 | select USB_EHCI_SYSBUS |
48 | select ACPI_APEI | 18 | select WDT_SBSA |
49 | + select ACPI_VIOT | 19 | + select BOCHS_DISPLAY |
50 | 20 | ||
51 | config CHEETAH | 21 | config SABRELITE |
52 | bool | 22 | bool |
53 | -- | 23 | -- |
54 | 2.25.1 | 24 | 2.34.1 |
55 | |||
56 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Martin Kaiser <martin@kaiser.cx> |
---|---|---|---|
2 | 2 | ||
3 | The size of the code covered by a TranslationBlock cannot be 0; | 3 | The Linux kernel added a flood check for RX data recently in commit |
4 | this is checked via assert in tb_gen_code. | 4 | 496a4471b7c3 ("serial: imx: work-around for hardware RX flood"). This |
5 | check uses the wake bit in the UART status register 2. The wake bit | ||
6 | indicates that the receiver detected a start bit on the RX line. If the | ||
7 | kernel sees a number of RX interrupts without the wake bit being set, it | ||
8 | treats this as spurious data and resets the UART port. imx_serial does | ||
9 | never set the wake bit and triggers the kernel's flood check. | ||
5 | 10 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | This patch adds support for the wake bit. wake is set when we receive a |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | new character (it's not set for break events). It seems that wake is |
13 | cleared by the kernel driver, the hardware does not have to clear it | ||
14 | automatically after data was read. | ||
15 | |||
16 | The wake bit can be configured as an interrupt source. Support this | ||
17 | mechanism as well. | ||
18 | |||
19 | Co-developed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
20 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
21 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
22 | Signed-off-by: Martin Kaiser <martin@kaiser.cx> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 24 | --- |
10 | target/arm/translate-a64.c | 1 + | 25 | include/hw/char/imx_serial.h | 1 + |
11 | 1 file changed, 1 insertion(+) | 26 | hw/char/imx_serial.c | 5 ++++- |
27 | 2 files changed, 5 insertions(+), 1 deletion(-) | ||
12 | 28 | ||
13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 29 | diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h |
14 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate-a64.c | 31 | --- a/include/hw/char/imx_serial.h |
16 | +++ b/target/arm/translate-a64.c | 32 | +++ b/include/hw/char/imx_serial.h |
17 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 33 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(IMXSerialState, IMX_SERIAL) |
18 | assert(s->base.num_insns == 1); | 34 | |
19 | gen_swstep_exception(s, 0, 0); | 35 | #define UCR4_DREN BIT(0) /* Receive Data Ready interrupt enable */ |
20 | s->base.is_jmp = DISAS_NORETURN; | 36 | #define UCR4_TCEN BIT(3) /* TX complete interrupt enable */ |
21 | + s->base.pc_next = pc + 4; | 37 | +#define UCR4_WKEN BIT(7) /* WAKE interrupt enable */ |
22 | return; | 38 | |
23 | } | 39 | #define UTS1_TXEMPTY (1<<6) |
40 | #define UTS1_RXEMPTY (1<<5) | ||
41 | diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/hw/char/imx_serial.c | ||
44 | +++ b/hw/char/imx_serial.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void imx_update(IMXSerialState *s) | ||
46 | * TCEN and TXDC are both bit 3 | ||
47 | * RDR and DREN are both bit 0 | ||
48 | */ | ||
49 | - mask |= s->ucr4 & (UCR4_TCEN | UCR4_DREN); | ||
50 | + mask |= s->ucr4 & (UCR4_WKEN | UCR4_TCEN | UCR4_DREN); | ||
51 | |||
52 | usr2 = s->usr2 & mask; | ||
53 | |||
54 | @@ -XXX,XX +XXX,XX @@ static void imx_put_data(void *opaque, uint32_t value) | ||
55 | |||
56 | static void imx_receive(void *opaque, const uint8_t *buf, int size) | ||
57 | { | ||
58 | + IMXSerialState *s = (IMXSerialState *)opaque; | ||
59 | + | ||
60 | + s->usr2 |= USR2_WAKE; | ||
61 | imx_put_data(opaque, *buf); | ||
62 | } | ||
24 | 63 | ||
25 | -- | 64 | -- |
26 | 2.25.1 | 65 | 2.34.1 |
27 | 66 | ||
28 | 67 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | We plan to add more hardware information into DeviceTree to limit amount |
4 | of hardcoded values in firmware. | ||
5 | |||
6 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> | ||
7 | Message-id: 20230531171834.236569-1-marcin.juszkiewicz@linaro.org | ||
8 | [PMM: fix format nits, add text about platform version fields from | ||
9 | a comment in the C source file] | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | --- | 12 | --- |
7 | target/arm/translate.c | 9 +++++---- | 13 | docs/system/arm/sbsa.rst | 38 +++++++++++++++++++++++++++++++------- |
8 | 1 file changed, 5 insertions(+), 4 deletions(-) | 14 | 1 file changed, 31 insertions(+), 7 deletions(-) |
9 | 15 | ||
10 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 16 | diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst |
11 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/target/arm/translate.c | 18 | --- a/docs/system/arm/sbsa.rst |
13 | +++ b/target/arm/translate.c | 19 | +++ b/docs/system/arm/sbsa.rst |
14 | @@ -XXX,XX +XXX,XX @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 20 | @@ -XXX,XX +XXX,XX @@ any real hardware the ``sbsa-ref`` board intends to look like real |
15 | { | 21 | hardware. The `Server Base System Architecture |
16 | DisasContext *dc = container_of(dcbase, DisasContext, base); | 22 | <https://developer.arm.com/documentation/den0029/latest>`_ defines a |
17 | CPUARMState *env = cpu->env_ptr; | 23 | minimum base line of hardware support and importantly how the firmware |
18 | + uint32_t pc = dc->base.pc_next; | 24 | -reports that to any operating system. It is a static system that |
19 | unsigned int insn; | 25 | -reports a very minimal DT to the firmware for non-discoverable |
20 | 26 | -information about components affected by the qemu command line (i.e. | |
21 | if (arm_pre_translate_insn(dc)) { | 27 | -cpus and memory). As a result it must have a firmware specifically |
22 | - dc->base.pc_next += 4; | 28 | -built to expect a certain hardware layout (as you would in a real |
23 | + dc->base.pc_next = pc + 4; | 29 | -machine). |
24 | return; | 30 | +reports that to any operating system. |
25 | } | 31 | |
26 | 32 | It is intended to be a machine for developing firmware and testing | |
27 | - dc->pc_curr = dc->base.pc_next; | 33 | standards compliance with operating systems. |
28 | - insn = arm_ldl_code(env, &dc->base, dc->base.pc_next, dc->sctlr_b); | 34 | @@ -XXX,XX +XXX,XX @@ standards compliance with operating systems. |
29 | + dc->pc_curr = pc; | 35 | Supported devices |
30 | + insn = arm_ldl_code(env, &dc->base, pc, dc->sctlr_b); | 36 | """"""""""""""""" |
31 | dc->insn = insn; | 37 | |
32 | - dc->base.pc_next += 4; | 38 | -The sbsa-ref board supports: |
33 | + dc->base.pc_next = pc + 4; | 39 | +The ``sbsa-ref`` board supports: |
34 | disas_arm_insn(dc, insn); | 40 | |
35 | 41 | - A configurable number of AArch64 CPUs | |
36 | arm_post_translate_insn(dc); | 42 | - GIC version 3 |
43 | @@ -XXX,XX +XXX,XX @@ The sbsa-ref board supports: | ||
44 | - Bochs display adapter on PCIe bus | ||
45 | - A generic SBSA watchdog device | ||
46 | |||
47 | + | ||
48 | +Board to firmware interface | ||
49 | +""""""""""""""""""""""""""" | ||
50 | + | ||
51 | +``sbsa-ref`` is a static system that reports a very minimal devicetree to the | ||
52 | +firmware for non-discoverable information about system components. This | ||
53 | +includes both internal hardware and parts affected by the qemu command line | ||
54 | +(i.e. CPUs and memory). As a result it must have a firmware specifically built | ||
55 | +to expect a certain hardware layout (as you would in a real machine). | ||
56 | + | ||
57 | +DeviceTree information | ||
58 | +'''''''''''''''''''''' | ||
59 | + | ||
60 | +The devicetree provided by the board model to the firmware is not intended | ||
61 | +to be a complete compliant DT. It currently reports: | ||
62 | + | ||
63 | + - CPUs | ||
64 | + - memory | ||
65 | + - platform version | ||
66 | + - GIC addresses | ||
67 | + | ||
68 | +The platform version is only for informing platform firmware about | ||
69 | +what kind of ``sbsa-ref`` board it is running on. It is neither | ||
70 | +a QEMU versioned machine type nor a reflection of the level of the | ||
71 | +SBSA/SystemReady SR support provided. | ||
72 | + | ||
73 | +The ``machine-version-major`` value is updated when changes breaking | ||
74 | +fw compatibility are introduced. The ``machine-version-minor`` value | ||
75 | +is updated when features are added that don't break fw compatibility. | ||
37 | -- | 76 | -- |
38 | 2.25.1 | 77 | 2.34.1 |
39 | |||
40 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 1 | From: Sergey Kambalin <sergey.kambalin@auriga.com> |
---|---|---|---|
2 | 2 | ||
3 | gicv3_set_gicv3state() is used by arm_gicv3_common.c in | 3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> |
4 | arm_gicv3_common_realize(). Since we want to restrict | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | arm_gicv3_cpuif.c to TCG, extract gicv3_set_gicv3state() | 5 | Acked-by: Richard Henderson <richard.henderson@linaro.org> |
6 | to a new file. Add this file to the meson 'specific' | 6 | Message-id: 20230612223456.33824-2-philmd@linaro.org |
7 | source set, since it needs access to "cpu.h". | 7 | Message-Id: <20230531155258.8361-1-sergey.kambalin@auriga.com> |
8 | 8 | [PMD: Split from bigger patch: 1/4] | |
9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20211115223619.2599282-2-philmd@redhat.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 11 | --- |
14 | hw/intc/arm_gicv3_cpuif.c | 10 +--------- | 12 | include/hw/misc/raspberrypi-fw-defs.h | 163 ++++++++++++++++++++++++++ |
15 | hw/intc/arm_gicv3_cpuif_common.c | 22 ++++++++++++++++++++++ | 13 | 1 file changed, 163 insertions(+) |
16 | hw/intc/meson.build | 1 + | 14 | create mode 100644 include/hw/misc/raspberrypi-fw-defs.h |
17 | 3 files changed, 24 insertions(+), 9 deletions(-) | ||
18 | create mode 100644 hw/intc/arm_gicv3_cpuif_common.c | ||
19 | 15 | ||
20 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | 16 | diff --git a/include/hw/misc/raspberrypi-fw-defs.h b/include/hw/misc/raspberrypi-fw-defs.h |
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/intc/arm_gicv3_cpuif.c | ||
23 | +++ b/hw/intc/arm_gicv3_cpuif.c | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | /* | ||
26 | - * ARM Generic Interrupt Controller v3 | ||
27 | + * ARM Generic Interrupt Controller v3 (emulation) | ||
28 | * | ||
29 | * Copyright (c) 2016 Linaro Limited | ||
30 | * Written by Peter Maydell | ||
31 | @@ -XXX,XX +XXX,XX @@ | ||
32 | #include "hw/irq.h" | ||
33 | #include "cpu.h" | ||
34 | |||
35 | -void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s) | ||
36 | -{ | ||
37 | - ARMCPU *arm_cpu = ARM_CPU(cpu); | ||
38 | - CPUARMState *env = &arm_cpu->env; | ||
39 | - | ||
40 | - env->gicv3state = (void *)s; | ||
41 | -}; | ||
42 | - | ||
43 | static GICv3CPUState *icc_cs_from_env(CPUARMState *env) | ||
44 | { | ||
45 | return env->gicv3state; | ||
46 | diff --git a/hw/intc/arm_gicv3_cpuif_common.c b/hw/intc/arm_gicv3_cpuif_common.c | ||
47 | new file mode 100644 | 17 | new file mode 100644 |
48 | index XXXXXXX..XXXXXXX | 18 | index XXXXXXX..XXXXXXX |
49 | --- /dev/null | 19 | --- /dev/null |
50 | +++ b/hw/intc/arm_gicv3_cpuif_common.c | 20 | +++ b/include/hw/misc/raspberrypi-fw-defs.h |
51 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ |
52 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
53 | +/* | 22 | +/* |
54 | + * ARM Generic Interrupt Controller v3 | 23 | + * Raspberry Pi firmware definitions |
55 | + * | 24 | + * |
56 | + * Copyright (c) 2016 Linaro Limited | 25 | + * Copyright (C) 2022 Auriga LLC, based on Linux kernel |
57 | + * Written by Peter Maydell | 26 | + * `include/soc/bcm2835/raspberrypi-firmware.h` (Copyright © 2015 Broadcom) |
58 | + * | 27 | + * |
59 | + * This code is licensed under the GPL, version 2 or (at your option) | 28 | + * SPDX-License-Identifier: GPL-2.0-or-later |
60 | + * any later version. | ||
61 | + */ | 29 | + */ |
62 | + | 30 | + |
31 | +#ifndef INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_ | ||
32 | +#define INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_ | ||
33 | + | ||
63 | +#include "qemu/osdep.h" | 34 | +#include "qemu/osdep.h" |
64 | +#include "gicv3_internal.h" | ||
65 | +#include "cpu.h" | ||
66 | + | 35 | + |
67 | +void gicv3_set_gicv3state(CPUState *cpu, GICv3CPUState *s) | 36 | +enum rpi_firmware_property_tag { |
68 | +{ | 37 | + RPI_FWREQ_PROPERTY_END = 0, |
69 | + ARMCPU *arm_cpu = ARM_CPU(cpu); | 38 | + RPI_FWREQ_GET_FIRMWARE_REVISION = 0x00000001, |
70 | + CPUARMState *env = &arm_cpu->env; | 39 | + RPI_FWREQ_GET_FIRMWARE_VARIANT = 0x00000002, |
40 | + RPI_FWREQ_GET_FIRMWARE_HASH = 0x00000003, | ||
71 | + | 41 | + |
72 | + env->gicv3state = (void *)s; | 42 | + RPI_FWREQ_SET_CURSOR_INFO = 0x00008010, |
43 | + RPI_FWREQ_SET_CURSOR_STATE = 0x00008011, | ||
44 | + | ||
45 | + RPI_FWREQ_GET_BOARD_MODEL = 0x00010001, | ||
46 | + RPI_FWREQ_GET_BOARD_REVISION = 0x00010002, | ||
47 | + RPI_FWREQ_GET_BOARD_MAC_ADDRESS = 0x00010003, | ||
48 | + RPI_FWREQ_GET_BOARD_SERIAL = 0x00010004, | ||
49 | + RPI_FWREQ_GET_ARM_MEMORY = 0x00010005, | ||
50 | + RPI_FWREQ_GET_VC_MEMORY = 0x00010006, | ||
51 | + RPI_FWREQ_GET_CLOCKS = 0x00010007, | ||
52 | + RPI_FWREQ_GET_POWER_STATE = 0x00020001, | ||
53 | + RPI_FWREQ_GET_TIMING = 0x00020002, | ||
54 | + RPI_FWREQ_SET_POWER_STATE = 0x00028001, | ||
55 | + RPI_FWREQ_GET_CLOCK_STATE = 0x00030001, | ||
56 | + RPI_FWREQ_GET_CLOCK_RATE = 0x00030002, | ||
57 | + RPI_FWREQ_GET_VOLTAGE = 0x00030003, | ||
58 | + RPI_FWREQ_GET_MAX_CLOCK_RATE = 0x00030004, | ||
59 | + RPI_FWREQ_GET_MAX_VOLTAGE = 0x00030005, | ||
60 | + RPI_FWREQ_GET_TEMPERATURE = 0x00030006, | ||
61 | + RPI_FWREQ_GET_MIN_CLOCK_RATE = 0x00030007, | ||
62 | + RPI_FWREQ_GET_MIN_VOLTAGE = 0x00030008, | ||
63 | + RPI_FWREQ_GET_TURBO = 0x00030009, | ||
64 | + RPI_FWREQ_GET_MAX_TEMPERATURE = 0x0003000a, | ||
65 | + RPI_FWREQ_GET_STC = 0x0003000b, | ||
66 | + RPI_FWREQ_ALLOCATE_MEMORY = 0x0003000c, | ||
67 | + RPI_FWREQ_LOCK_MEMORY = 0x0003000d, | ||
68 | + RPI_FWREQ_UNLOCK_MEMORY = 0x0003000e, | ||
69 | + RPI_FWREQ_RELEASE_MEMORY = 0x0003000f, | ||
70 | + RPI_FWREQ_EXECUTE_CODE = 0x00030010, | ||
71 | + RPI_FWREQ_EXECUTE_QPU = 0x00030011, | ||
72 | + RPI_FWREQ_SET_ENABLE_QPU = 0x00030012, | ||
73 | + RPI_FWREQ_GET_DISPMANX_RESOURCE_MEM_HANDLE = 0x00030014, | ||
74 | + RPI_FWREQ_GET_EDID_BLOCK = 0x00030020, | ||
75 | + RPI_FWREQ_GET_CUSTOMER_OTP = 0x00030021, | ||
76 | + RPI_FWREQ_GET_EDID_BLOCK_DISPLAY = 0x00030023, | ||
77 | + RPI_FWREQ_GET_DOMAIN_STATE = 0x00030030, | ||
78 | + RPI_FWREQ_GET_THROTTLED = 0x00030046, | ||
79 | + RPI_FWREQ_GET_CLOCK_MEASURED = 0x00030047, | ||
80 | + RPI_FWREQ_NOTIFY_REBOOT = 0x00030048, | ||
81 | + RPI_FWREQ_SET_CLOCK_STATE = 0x00038001, | ||
82 | + RPI_FWREQ_SET_CLOCK_RATE = 0x00038002, | ||
83 | + RPI_FWREQ_SET_VOLTAGE = 0x00038003, | ||
84 | + RPI_FWREQ_SET_MAX_CLOCK_RATE = 0x00038004, | ||
85 | + RPI_FWREQ_SET_MIN_CLOCK_RATE = 0x00038007, | ||
86 | + RPI_FWREQ_SET_TURBO = 0x00038009, | ||
87 | + RPI_FWREQ_SET_CUSTOMER_OTP = 0x00038021, | ||
88 | + RPI_FWREQ_SET_DOMAIN_STATE = 0x00038030, | ||
89 | + RPI_FWREQ_GET_GPIO_STATE = 0x00030041, | ||
90 | + RPI_FWREQ_SET_GPIO_STATE = 0x00038041, | ||
91 | + RPI_FWREQ_SET_SDHOST_CLOCK = 0x00038042, | ||
92 | + RPI_FWREQ_GET_GPIO_CONFIG = 0x00030043, | ||
93 | + RPI_FWREQ_SET_GPIO_CONFIG = 0x00038043, | ||
94 | + RPI_FWREQ_GET_PERIPH_REG = 0x00030045, | ||
95 | + RPI_FWREQ_SET_PERIPH_REG = 0x00038045, | ||
96 | + RPI_FWREQ_GET_POE_HAT_VAL = 0x00030049, | ||
97 | + RPI_FWREQ_SET_POE_HAT_VAL = 0x00038049, | ||
98 | + RPI_FWREQ_SET_POE_HAT_VAL_OLD = 0x00030050, | ||
99 | + RPI_FWREQ_NOTIFY_XHCI_RESET = 0x00030058, | ||
100 | + RPI_FWREQ_GET_REBOOT_FLAGS = 0x00030064, | ||
101 | + RPI_FWREQ_SET_REBOOT_FLAGS = 0x00038064, | ||
102 | + RPI_FWREQ_NOTIFY_DISPLAY_DONE = 0x00030066, | ||
103 | + | ||
104 | + /* Dispmanx TAGS */ | ||
105 | + RPI_FWREQ_FRAMEBUFFER_ALLOCATE = 0x00040001, | ||
106 | + RPI_FWREQ_FRAMEBUFFER_BLANK = 0x00040002, | ||
107 | + RPI_FWREQ_FRAMEBUFFER_GET_PHYSICAL_WIDTH_HEIGHT = 0x00040003, | ||
108 | + RPI_FWREQ_FRAMEBUFFER_GET_VIRTUAL_WIDTH_HEIGHT = 0x00040004, | ||
109 | + RPI_FWREQ_FRAMEBUFFER_GET_DEPTH = 0x00040005, | ||
110 | + RPI_FWREQ_FRAMEBUFFER_GET_PIXEL_ORDER = 0x00040006, | ||
111 | + RPI_FWREQ_FRAMEBUFFER_GET_ALPHA_MODE = 0x00040007, | ||
112 | + RPI_FWREQ_FRAMEBUFFER_GET_PITCH = 0x00040008, | ||
113 | + RPI_FWREQ_FRAMEBUFFER_GET_VIRTUAL_OFFSET = 0x00040009, | ||
114 | + RPI_FWREQ_FRAMEBUFFER_GET_OVERSCAN = 0x0004000a, | ||
115 | + RPI_FWREQ_FRAMEBUFFER_GET_PALETTE = 0x0004000b, | ||
116 | + RPI_FWREQ_FRAMEBUFFER_GET_LAYER = 0x0004000c, | ||
117 | + RPI_FWREQ_FRAMEBUFFER_GET_TRANSFORM = 0x0004000d, | ||
118 | + RPI_FWREQ_FRAMEBUFFER_GET_VSYNC = 0x0004000e, | ||
119 | + RPI_FWREQ_FRAMEBUFFER_GET_TOUCHBUF = 0x0004000f, | ||
120 | + RPI_FWREQ_FRAMEBUFFER_GET_GPIOVIRTBUF = 0x00040010, | ||
121 | + RPI_FWREQ_FRAMEBUFFER_RELEASE = 0x00048001, | ||
122 | + RPI_FWREQ_FRAMEBUFFER_GET_DISPLAY_ID = 0x00040016, | ||
123 | + RPI_FWREQ_FRAMEBUFFER_SET_DISPLAY_NUM = 0x00048013, | ||
124 | + RPI_FWREQ_FRAMEBUFFER_GET_NUM_DISPLAYS = 0x00040013, | ||
125 | + RPI_FWREQ_FRAMEBUFFER_GET_DISPLAY_SETTINGS = 0x00040014, | ||
126 | + RPI_FWREQ_FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT = 0x00044003, | ||
127 | + RPI_FWREQ_FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT = 0x00044004, | ||
128 | + RPI_FWREQ_FRAMEBUFFER_TEST_DEPTH = 0x00044005, | ||
129 | + RPI_FWREQ_FRAMEBUFFER_TEST_PIXEL_ORDER = 0x00044006, | ||
130 | + RPI_FWREQ_FRAMEBUFFER_TEST_ALPHA_MODE = 0x00044007, | ||
131 | + RPI_FWREQ_FRAMEBUFFER_TEST_VIRTUAL_OFFSET = 0x00044009, | ||
132 | + RPI_FWREQ_FRAMEBUFFER_TEST_OVERSCAN = 0x0004400a, | ||
133 | + RPI_FWREQ_FRAMEBUFFER_TEST_PALETTE = 0x0004400b, | ||
134 | + RPI_FWREQ_FRAMEBUFFER_TEST_LAYER = 0x0004400c, | ||
135 | + RPI_FWREQ_FRAMEBUFFER_TEST_TRANSFORM = 0x0004400d, | ||
136 | + RPI_FWREQ_FRAMEBUFFER_TEST_VSYNC = 0x0004400e, | ||
137 | + RPI_FWREQ_FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT = 0x00048003, | ||
138 | + RPI_FWREQ_FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT = 0x00048004, | ||
139 | + RPI_FWREQ_FRAMEBUFFER_SET_DEPTH = 0x00048005, | ||
140 | + RPI_FWREQ_FRAMEBUFFER_SET_PIXEL_ORDER = 0x00048006, | ||
141 | + RPI_FWREQ_FRAMEBUFFER_SET_ALPHA_MODE = 0x00048007, | ||
142 | + RPI_FWREQ_FRAMEBUFFER_SET_PITCH = 0x00048008, | ||
143 | + RPI_FWREQ_FRAMEBUFFER_SET_VIRTUAL_OFFSET = 0x00048009, | ||
144 | + RPI_FWREQ_FRAMEBUFFER_SET_OVERSCAN = 0x0004800a, | ||
145 | + RPI_FWREQ_FRAMEBUFFER_SET_PALETTE = 0x0004800b, | ||
146 | + | ||
147 | + RPI_FWREQ_FRAMEBUFFER_SET_TOUCHBUF = 0x0004801f, | ||
148 | + RPI_FWREQ_FRAMEBUFFER_SET_GPIOVIRTBUF = 0x00048020, | ||
149 | + RPI_FWREQ_FRAMEBUFFER_SET_VSYNC = 0x0004800e, | ||
150 | + RPI_FWREQ_FRAMEBUFFER_SET_LAYER = 0x0004800c, | ||
151 | + RPI_FWREQ_FRAMEBUFFER_SET_TRANSFORM = 0x0004800d, | ||
152 | + RPI_FWREQ_FRAMEBUFFER_SET_BACKLIGHT = 0x0004800f, | ||
153 | + | ||
154 | + RPI_FWREQ_VCHIQ_INIT = 0x00048010, | ||
155 | + | ||
156 | + RPI_FWREQ_SET_PLANE = 0x00048015, | ||
157 | + RPI_FWREQ_GET_DISPLAY_TIMING = 0x00040017, | ||
158 | + RPI_FWREQ_SET_TIMING = 0x00048017, | ||
159 | + RPI_FWREQ_GET_DISPLAY_CFG = 0x00040018, | ||
160 | + RPI_FWREQ_SET_DISPLAY_POWER = 0x00048019, | ||
161 | + RPI_FWREQ_GET_COMMAND_LINE = 0x00050001, | ||
162 | + RPI_FWREQ_GET_DMA_CHANNELS = 0x00060001, | ||
73 | +}; | 163 | +}; |
74 | diff --git a/hw/intc/meson.build b/hw/intc/meson.build | 164 | + |
75 | index XXXXXXX..XXXXXXX 100644 | 165 | +enum rpi_firmware_clk_id { |
76 | --- a/hw/intc/meson.build | 166 | + RPI_FIRMWARE_EMMC_CLK_ID = 1, |
77 | +++ b/hw/intc/meson.build | 167 | + RPI_FIRMWARE_UART_CLK_ID, |
78 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true: files('xlnx-pmu-iomod-in | 168 | + RPI_FIRMWARE_ARM_CLK_ID, |
79 | 169 | + RPI_FIRMWARE_CORE_CLK_ID, | |
80 | specific_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true: files('allwinner-a10-pic.c')) | 170 | + RPI_FIRMWARE_V3D_CLK_ID, |
81 | specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic.c', 'apic_common.c')) | 171 | + RPI_FIRMWARE_H264_CLK_ID, |
82 | +specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif_common.c')) | 172 | + RPI_FIRMWARE_ISP_CLK_ID, |
83 | specific_ss.add(when: 'CONFIG_ARM_GIC', if_true: files('arm_gicv3_cpuif.c')) | 173 | + RPI_FIRMWARE_SDRAM_CLK_ID, |
84 | specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true: files('arm_gic_kvm.c')) | 174 | + RPI_FIRMWARE_PIXEL_CLK_ID, |
85 | specific_ss.add(when: ['CONFIG_ARM_GIC_KVM', 'TARGET_AARCH64'], if_true: files('arm_gicv3_kvm.c', 'arm_gicv3_its_kvm.c')) | 175 | + RPI_FIRMWARE_PWM_CLK_ID, |
176 | + RPI_FIRMWARE_HEVC_CLK_ID, | ||
177 | + RPI_FIRMWARE_EMMC2_CLK_ID, | ||
178 | + RPI_FIRMWARE_M2MC_CLK_ID, | ||
179 | + RPI_FIRMWARE_PIXEL_BVB_CLK_ID, | ||
180 | + RPI_FIRMWARE_VEC_CLK_ID, | ||
181 | + RPI_FIRMWARE_NUM_CLK_ID, | ||
182 | +}; | ||
183 | + | ||
184 | +#endif /* INCLUDE_HW_MISC_RASPBERRYPI_FW_DEFS_H_ */ | ||
86 | -- | 185 | -- |
87 | 2.25.1 | 186 | 2.34.1 |
88 | 187 | ||
89 | 188 | diff view generated by jsdifflib |
1 | From: Olivier Hériveaux <olivier.heriveaux@ledger.fr> | 1 | From: Sergey Kambalin <sergey.kambalin@auriga.com> |
---|---|---|---|
2 | 2 | ||
3 | Fix issue where the data register may be overwritten by next character | 3 | Replace magic property values by a proper definition, |
4 | reception before being read and returned. | 4 | removing redundant comments. |
5 | 5 | ||
6 | Signed-off-by: Olivier Hériveaux <olivier.heriveaux@ledger.fr> | 6 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20211128120723.4053-1-olivier.heriveaux@ledger.fr | 9 | Message-id: 20230612223456.33824-3-philmd@linaro.org |
10 | Message-Id: <20230531155258.8361-1-sergey.kambalin@auriga.com> | ||
11 | [PMD: Split from bigger patch: 2/4] | ||
12 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 14 | --- |
12 | hw/char/stm32f2xx_usart.c | 3 ++- | 15 | hw/misc/bcm2835_property.c | 101 +++++++++++++++++++------------------ |
13 | 1 file changed, 2 insertions(+), 1 deletion(-) | 16 | 1 file changed, 51 insertions(+), 50 deletions(-) |
14 | 17 | ||
15 | diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c | 18 | diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c |
16 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/char/stm32f2xx_usart.c | 20 | --- a/hw/misc/bcm2835_property.c |
18 | +++ b/hw/char/stm32f2xx_usart.c | 21 | +++ b/hw/misc/bcm2835_property.c |
19 | @@ -XXX,XX +XXX,XX @@ static uint64_t stm32f2xx_usart_read(void *opaque, hwaddr addr, | 22 | @@ -XXX,XX +XXX,XX @@ |
20 | return retvalue; | 23 | #include "migration/vmstate.h" |
21 | case USART_DR: | 24 | #include "hw/irq.h" |
22 | DB_PRINT("Value: 0x%" PRIx32 ", %c\n", s->usart_dr, (char) s->usart_dr); | 25 | #include "hw/misc/bcm2835_mbox_defs.h" |
23 | + retvalue = s->usart_dr & 0x3FF; | 26 | +#include "hw/misc/raspberrypi-fw-defs.h" |
24 | s->usart_sr &= ~USART_SR_RXNE; | 27 | #include "sysemu/dma.h" |
25 | qemu_chr_fe_accept_input(&s->chr); | 28 | #include "qemu/log.h" |
26 | qemu_set_irq(s->irq, 0); | 29 | #include "qemu/module.h" |
27 | - return s->usart_dr & 0x3FF; | 30 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) |
28 | + return retvalue; | 31 | /* @(value + 8) : Request/response indicator */ |
29 | case USART_BRR: | 32 | resplen = 0; |
30 | return s->usart_brr; | 33 | switch (tag) { |
31 | case USART_CR1: | 34 | - case 0x00000000: /* End tag */ |
35 | + case RPI_FWREQ_PROPERTY_END: | ||
36 | break; | ||
37 | - case 0x00000001: /* Get firmware revision */ | ||
38 | + case RPI_FWREQ_GET_FIRMWARE_REVISION: | ||
39 | stl_le_phys(&s->dma_as, value + 12, 346337); | ||
40 | resplen = 4; | ||
41 | break; | ||
42 | - case 0x00010001: /* Get board model */ | ||
43 | + case RPI_FWREQ_GET_BOARD_MODEL: | ||
44 | qemu_log_mask(LOG_UNIMP, | ||
45 | "bcm2835_property: 0x%08x get board model NYI\n", | ||
46 | tag); | ||
47 | resplen = 4; | ||
48 | break; | ||
49 | - case 0x00010002: /* Get board revision */ | ||
50 | + case RPI_FWREQ_GET_BOARD_REVISION: | ||
51 | stl_le_phys(&s->dma_as, value + 12, s->board_rev); | ||
52 | resplen = 4; | ||
53 | break; | ||
54 | - case 0x00010003: /* Get board MAC address */ | ||
55 | + case RPI_FWREQ_GET_BOARD_MAC_ADDRESS: | ||
56 | resplen = sizeof(s->macaddr.a); | ||
57 | dma_memory_write(&s->dma_as, value + 12, s->macaddr.a, resplen, | ||
58 | MEMTXATTRS_UNSPECIFIED); | ||
59 | break; | ||
60 | - case 0x00010004: /* Get board serial */ | ||
61 | + case RPI_FWREQ_GET_BOARD_SERIAL: | ||
62 | qemu_log_mask(LOG_UNIMP, | ||
63 | "bcm2835_property: 0x%08x get board serial NYI\n", | ||
64 | tag); | ||
65 | resplen = 8; | ||
66 | break; | ||
67 | - case 0x00010005: /* Get ARM memory */ | ||
68 | + case RPI_FWREQ_GET_ARM_MEMORY: | ||
69 | /* base */ | ||
70 | stl_le_phys(&s->dma_as, value + 12, 0); | ||
71 | /* size */ | ||
72 | stl_le_phys(&s->dma_as, value + 16, s->fbdev->vcram_base); | ||
73 | resplen = 8; | ||
74 | break; | ||
75 | - case 0x00010006: /* Get VC memory */ | ||
76 | + case RPI_FWREQ_GET_VC_MEMORY: | ||
77 | /* base */ | ||
78 | stl_le_phys(&s->dma_as, value + 12, s->fbdev->vcram_base); | ||
79 | /* size */ | ||
80 | stl_le_phys(&s->dma_as, value + 16, s->fbdev->vcram_size); | ||
81 | resplen = 8; | ||
82 | break; | ||
83 | - case 0x00028001: /* Set power state */ | ||
84 | + case RPI_FWREQ_SET_POWER_STATE: | ||
85 | /* Assume that whatever device they asked for exists, | ||
86 | * and we'll just claim we set it to the desired state | ||
87 | */ | ||
88 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) | ||
89 | |||
90 | /* Clocks */ | ||
91 | |||
92 | - case 0x00030001: /* Get clock state */ | ||
93 | + case RPI_FWREQ_GET_CLOCK_STATE: | ||
94 | stl_le_phys(&s->dma_as, value + 16, 0x1); | ||
95 | resplen = 8; | ||
96 | break; | ||
97 | |||
98 | - case 0x00038001: /* Set clock state */ | ||
99 | + case RPI_FWREQ_SET_CLOCK_STATE: | ||
100 | qemu_log_mask(LOG_UNIMP, | ||
101 | "bcm2835_property: 0x%08x set clock state NYI\n", | ||
102 | tag); | ||
103 | resplen = 8; | ||
104 | break; | ||
105 | |||
106 | - case 0x00030002: /* Get clock rate */ | ||
107 | - case 0x00030004: /* Get max clock rate */ | ||
108 | - case 0x00030007: /* Get min clock rate */ | ||
109 | + case RPI_FWREQ_GET_CLOCK_RATE: | ||
110 | + case RPI_FWREQ_GET_MAX_CLOCK_RATE: | ||
111 | + case RPI_FWREQ_GET_MIN_CLOCK_RATE: | ||
112 | switch (ldl_le_phys(&s->dma_as, value + 12)) { | ||
113 | - case 1: /* EMMC */ | ||
114 | + case RPI_FIRMWARE_EMMC_CLK_ID: | ||
115 | stl_le_phys(&s->dma_as, value + 16, 50000000); | ||
116 | break; | ||
117 | - case 2: /* UART */ | ||
118 | + case RPI_FIRMWARE_UART_CLK_ID: | ||
119 | stl_le_phys(&s->dma_as, value + 16, 3000000); | ||
120 | break; | ||
121 | default: | ||
122 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) | ||
123 | resplen = 8; | ||
124 | break; | ||
125 | |||
126 | - case 0x00038002: /* Set clock rate */ | ||
127 | - case 0x00038004: /* Set max clock rate */ | ||
128 | - case 0x00038007: /* Set min clock rate */ | ||
129 | + case RPI_FWREQ_SET_CLOCK_RATE: | ||
130 | + case RPI_FWREQ_SET_MAX_CLOCK_RATE: | ||
131 | + case RPI_FWREQ_SET_MIN_CLOCK_RATE: | ||
132 | qemu_log_mask(LOG_UNIMP, | ||
133 | "bcm2835_property: 0x%08x set clock rate NYI\n", | ||
134 | tag); | ||
135 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) | ||
136 | |||
137 | /* Temperature */ | ||
138 | |||
139 | - case 0x00030006: /* Get temperature */ | ||
140 | + case RPI_FWREQ_GET_TEMPERATURE: | ||
141 | stl_le_phys(&s->dma_as, value + 16, 25000); | ||
142 | resplen = 8; | ||
143 | break; | ||
144 | |||
145 | - case 0x0003000A: /* Get max temperature */ | ||
146 | + case RPI_FWREQ_GET_MAX_TEMPERATURE: | ||
147 | stl_le_phys(&s->dma_as, value + 16, 99000); | ||
148 | resplen = 8; | ||
149 | break; | ||
150 | |||
151 | /* Frame buffer */ | ||
152 | |||
153 | - case 0x00040001: /* Allocate buffer */ | ||
154 | + case RPI_FWREQ_FRAMEBUFFER_ALLOCATE: | ||
155 | stl_le_phys(&s->dma_as, value + 12, fbconfig.base); | ||
156 | stl_le_phys(&s->dma_as, value + 16, | ||
157 | bcm2835_fb_get_size(&fbconfig)); | ||
158 | resplen = 8; | ||
159 | break; | ||
160 | - case 0x00048001: /* Release buffer */ | ||
161 | + case RPI_FWREQ_FRAMEBUFFER_RELEASE: | ||
162 | resplen = 0; | ||
163 | break; | ||
164 | - case 0x00040002: /* Blank screen */ | ||
165 | + case RPI_FWREQ_FRAMEBUFFER_BLANK: | ||
166 | resplen = 4; | ||
167 | break; | ||
168 | - case 0x00044003: /* Test physical display width/height */ | ||
169 | - case 0x00044004: /* Test virtual display width/height */ | ||
170 | + case RPI_FWREQ_FRAMEBUFFER_TEST_PHYSICAL_WIDTH_HEIGHT: | ||
171 | + case RPI_FWREQ_FRAMEBUFFER_TEST_VIRTUAL_WIDTH_HEIGHT: | ||
172 | resplen = 8; | ||
173 | break; | ||
174 | - case 0x00048003: /* Set physical display width/height */ | ||
175 | + case RPI_FWREQ_FRAMEBUFFER_SET_PHYSICAL_WIDTH_HEIGHT: | ||
176 | fbconfig.xres = ldl_le_phys(&s->dma_as, value + 12); | ||
177 | fbconfig.yres = ldl_le_phys(&s->dma_as, value + 16); | ||
178 | bcm2835_fb_validate_config(&fbconfig); | ||
179 | fbconfig_updated = true; | ||
180 | /* fall through */ | ||
181 | - case 0x00040003: /* Get physical display width/height */ | ||
182 | + case RPI_FWREQ_FRAMEBUFFER_GET_PHYSICAL_WIDTH_HEIGHT: | ||
183 | stl_le_phys(&s->dma_as, value + 12, fbconfig.xres); | ||
184 | stl_le_phys(&s->dma_as, value + 16, fbconfig.yres); | ||
185 | resplen = 8; | ||
186 | break; | ||
187 | - case 0x00048004: /* Set virtual display width/height */ | ||
188 | + case RPI_FWREQ_FRAMEBUFFER_SET_VIRTUAL_WIDTH_HEIGHT: | ||
189 | fbconfig.xres_virtual = ldl_le_phys(&s->dma_as, value + 12); | ||
190 | fbconfig.yres_virtual = ldl_le_phys(&s->dma_as, value + 16); | ||
191 | bcm2835_fb_validate_config(&fbconfig); | ||
192 | fbconfig_updated = true; | ||
193 | /* fall through */ | ||
194 | - case 0x00040004: /* Get virtual display width/height */ | ||
195 | + case RPI_FWREQ_FRAMEBUFFER_GET_VIRTUAL_WIDTH_HEIGHT: | ||
196 | stl_le_phys(&s->dma_as, value + 12, fbconfig.xres_virtual); | ||
197 | stl_le_phys(&s->dma_as, value + 16, fbconfig.yres_virtual); | ||
198 | resplen = 8; | ||
199 | break; | ||
200 | - case 0x00044005: /* Test depth */ | ||
201 | + case RPI_FWREQ_FRAMEBUFFER_TEST_DEPTH: | ||
202 | resplen = 4; | ||
203 | break; | ||
204 | - case 0x00048005: /* Set depth */ | ||
205 | + case RPI_FWREQ_FRAMEBUFFER_SET_DEPTH: | ||
206 | fbconfig.bpp = ldl_le_phys(&s->dma_as, value + 12); | ||
207 | bcm2835_fb_validate_config(&fbconfig); | ||
208 | fbconfig_updated = true; | ||
209 | /* fall through */ | ||
210 | - case 0x00040005: /* Get depth */ | ||
211 | + case RPI_FWREQ_FRAMEBUFFER_GET_DEPTH: | ||
212 | stl_le_phys(&s->dma_as, value + 12, fbconfig.bpp); | ||
213 | resplen = 4; | ||
214 | break; | ||
215 | - case 0x00044006: /* Test pixel order */ | ||
216 | + case RPI_FWREQ_FRAMEBUFFER_TEST_PIXEL_ORDER: | ||
217 | resplen = 4; | ||
218 | break; | ||
219 | - case 0x00048006: /* Set pixel order */ | ||
220 | + case RPI_FWREQ_FRAMEBUFFER_SET_PIXEL_ORDER: | ||
221 | fbconfig.pixo = ldl_le_phys(&s->dma_as, value + 12); | ||
222 | bcm2835_fb_validate_config(&fbconfig); | ||
223 | fbconfig_updated = true; | ||
224 | /* fall through */ | ||
225 | - case 0x00040006: /* Get pixel order */ | ||
226 | + case RPI_FWREQ_FRAMEBUFFER_GET_PIXEL_ORDER: | ||
227 | stl_le_phys(&s->dma_as, value + 12, fbconfig.pixo); | ||
228 | resplen = 4; | ||
229 | break; | ||
230 | - case 0x00044007: /* Test pixel alpha */ | ||
231 | + case RPI_FWREQ_FRAMEBUFFER_TEST_ALPHA_MODE: | ||
232 | resplen = 4; | ||
233 | break; | ||
234 | - case 0x00048007: /* Set alpha */ | ||
235 | + case RPI_FWREQ_FRAMEBUFFER_SET_ALPHA_MODE: | ||
236 | fbconfig.alpha = ldl_le_phys(&s->dma_as, value + 12); | ||
237 | bcm2835_fb_validate_config(&fbconfig); | ||
238 | fbconfig_updated = true; | ||
239 | /* fall through */ | ||
240 | - case 0x00040007: /* Get alpha */ | ||
241 | + case RPI_FWREQ_FRAMEBUFFER_GET_ALPHA_MODE: | ||
242 | stl_le_phys(&s->dma_as, value + 12, fbconfig.alpha); | ||
243 | resplen = 4; | ||
244 | break; | ||
245 | - case 0x00040008: /* Get pitch */ | ||
246 | + case RPI_FWREQ_FRAMEBUFFER_GET_PITCH: | ||
247 | stl_le_phys(&s->dma_as, value + 12, | ||
248 | bcm2835_fb_get_pitch(&fbconfig)); | ||
249 | resplen = 4; | ||
250 | break; | ||
251 | - case 0x00044009: /* Test virtual offset */ | ||
252 | + case RPI_FWREQ_FRAMEBUFFER_TEST_VIRTUAL_OFFSET: | ||
253 | resplen = 8; | ||
254 | break; | ||
255 | - case 0x00048009: /* Set virtual offset */ | ||
256 | + case RPI_FWREQ_FRAMEBUFFER_SET_VIRTUAL_OFFSET: | ||
257 | fbconfig.xoffset = ldl_le_phys(&s->dma_as, value + 12); | ||
258 | fbconfig.yoffset = ldl_le_phys(&s->dma_as, value + 16); | ||
259 | bcm2835_fb_validate_config(&fbconfig); | ||
260 | fbconfig_updated = true; | ||
261 | /* fall through */ | ||
262 | - case 0x00040009: /* Get virtual offset */ | ||
263 | + case RPI_FWREQ_FRAMEBUFFER_GET_VIRTUAL_OFFSET: | ||
264 | stl_le_phys(&s->dma_as, value + 12, fbconfig.xoffset); | ||
265 | stl_le_phys(&s->dma_as, value + 16, fbconfig.yoffset); | ||
266 | resplen = 8; | ||
267 | break; | ||
268 | - case 0x0004000a: /* Get/Test/Set overscan */ | ||
269 | - case 0x0004400a: | ||
270 | - case 0x0004800a: | ||
271 | + case RPI_FWREQ_FRAMEBUFFER_GET_OVERSCAN: | ||
272 | + case RPI_FWREQ_FRAMEBUFFER_TEST_OVERSCAN: | ||
273 | + case RPI_FWREQ_FRAMEBUFFER_SET_OVERSCAN: | ||
274 | stl_le_phys(&s->dma_as, value + 12, 0); | ||
275 | stl_le_phys(&s->dma_as, value + 16, 0); | ||
276 | stl_le_phys(&s->dma_as, value + 20, 0); | ||
277 | stl_le_phys(&s->dma_as, value + 24, 0); | ||
278 | resplen = 16; | ||
279 | break; | ||
280 | - case 0x0004800b: /* Set palette */ | ||
281 | + case RPI_FWREQ_FRAMEBUFFER_SET_PALETTE: | ||
282 | offset = ldl_le_phys(&s->dma_as, value + 12); | ||
283 | length = ldl_le_phys(&s->dma_as, value + 16); | ||
284 | n = 0; | ||
285 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) | ||
286 | stl_le_phys(&s->dma_as, value + 12, 0); | ||
287 | resplen = 4; | ||
288 | break; | ||
289 | - case 0x00040013: /* Get number of displays */ | ||
290 | + case RPI_FWREQ_FRAMEBUFFER_GET_NUM_DISPLAYS: | ||
291 | stl_le_phys(&s->dma_as, value + 12, 1); | ||
292 | resplen = 4; | ||
293 | break; | ||
294 | |||
295 | - case 0x00060001: /* Get DMA channels */ | ||
296 | + case RPI_FWREQ_GET_DMA_CHANNELS: | ||
297 | /* channels 2-5 */ | ||
298 | stl_le_phys(&s->dma_as, value + 12, 0x003C); | ||
299 | resplen = 4; | ||
300 | break; | ||
301 | |||
302 | - case 0x00050001: /* Get command line */ | ||
303 | + case RPI_FWREQ_GET_COMMAND_LINE: | ||
304 | /* | ||
305 | * We follow the firmware behaviour: no NUL terminator is | ||
306 | * written to the buffer, and if the buffer is too short | ||
32 | -- | 307 | -- |
33 | 2.25.1 | 308 | 2.34.1 |
34 | 309 | ||
35 | 310 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Sergey Kambalin <sergey.kambalin@auriga.com> |
---|---|---|---|
2 | 2 | ||
3 | A common use case for the ASPEED machine is to boot a Linux kernel. | 3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> |
4 | Provide a full example command line. | 4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
5 | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | |
6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 6 | Message-id: 20230612223456.33824-4-philmd@linaro.org |
7 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 7 | Message-Id: <20230531155258.8361-1-sergey.kambalin@auriga.com> |
8 | Message-id: 20211117065752.330632-4-joel@jms.id.au | 8 | [PMD: Split from bigger patch: 4/4] |
9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 11 | --- |
11 | docs/system/arm/aspeed.rst | 15 ++++++++++++--- | 12 | include/hw/arm/raspi_platform.h | 5 +++++ |
12 | 1 file changed, 12 insertions(+), 3 deletions(-) | 13 | hw/misc/bcm2835_property.c | 8 +++++--- |
14 | 2 files changed, 10 insertions(+), 3 deletions(-) | ||
13 | 15 | ||
14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | 16 | diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/docs/system/arm/aspeed.rst | 18 | --- a/include/hw/arm/raspi_platform.h |
17 | +++ b/docs/system/arm/aspeed.rst | 19 | +++ b/include/hw/arm/raspi_platform.h |
18 | @@ -XXX,XX +XXX,XX @@ Missing devices | 20 | @@ -XXX,XX +XXX,XX @@ |
19 | Boot options | 21 | #define INTERRUPT_ILLEGAL_TYPE0 6 |
20 | ------------ | 22 | #define INTERRUPT_ILLEGAL_TYPE1 7 |
21 | 23 | ||
22 | -The Aspeed machines can be started using the ``-kernel`` option to | 24 | +/* Clock rates */ |
23 | -load a Linux kernel or from a firmware. Images can be downloaded from | 25 | +#define RPI_FIRMWARE_EMMC_CLK_RATE 50000000 |
24 | -the OpenBMC jenkins : | 26 | +#define RPI_FIRMWARE_UART_CLK_RATE 3000000 |
25 | +The Aspeed machines can be started using the ``-kernel`` and ``-dtb`` options | 27 | +#define RPI_FIRMWARE_DEFAULT_CLK_RATE 700000000 |
26 | +to load a Linux kernel or from a firmware. Images can be downloaded from the | ||
27 | +OpenBMC jenkins : | ||
28 | |||
29 | https://jenkins.openbmc.org/job/ci-openbmc/lastSuccessfulBuild/ | ||
30 | |||
31 | @@ -XXX,XX +XXX,XX @@ or directly from the OpenBMC GitHub release repository : | ||
32 | |||
33 | https://github.com/openbmc/openbmc/releases | ||
34 | |||
35 | +To boot a kernel directly from a Linux build tree: | ||
36 | + | 28 | + |
37 | +.. code-block:: bash | 29 | #endif |
38 | + | 30 | diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c |
39 | + $ qemu-system-arm -M ast2600-evb -nographic \ | 31 | index XXXXXXX..XXXXXXX 100644 |
40 | + -kernel arch/arm/boot/zImage \ | 32 | --- a/hw/misc/bcm2835_property.c |
41 | + -dtb arch/arm/boot/dts/aspeed-ast2600-evb.dtb \ | 33 | +++ b/hw/misc/bcm2835_property.c |
42 | + -initrd rootfs.cpio | 34 | @@ -XXX,XX +XXX,XX @@ |
43 | + | 35 | #include "qemu/log.h" |
44 | The image should be attached as an MTD drive. Run : | 36 | #include "qemu/module.h" |
45 | 37 | #include "trace.h" | |
46 | .. code-block:: bash | 38 | +#include "hw/arm/raspi_platform.h" |
39 | |||
40 | /* https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface */ | ||
41 | |||
42 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) | ||
43 | case RPI_FWREQ_GET_MIN_CLOCK_RATE: | ||
44 | switch (ldl_le_phys(&s->dma_as, value + 12)) { | ||
45 | case RPI_FIRMWARE_EMMC_CLK_ID: | ||
46 | - stl_le_phys(&s->dma_as, value + 16, 50000000); | ||
47 | + stl_le_phys(&s->dma_as, value + 16, RPI_FIRMWARE_EMMC_CLK_RATE); | ||
48 | break; | ||
49 | case RPI_FIRMWARE_UART_CLK_ID: | ||
50 | - stl_le_phys(&s->dma_as, value + 16, 3000000); | ||
51 | + stl_le_phys(&s->dma_as, value + 16, RPI_FIRMWARE_UART_CLK_RATE); | ||
52 | break; | ||
53 | default: | ||
54 | - stl_le_phys(&s->dma_as, value + 16, 700000000); | ||
55 | + stl_le_phys(&s->dma_as, value + 16, | ||
56 | + RPI_FIRMWARE_DEFAULT_CLK_RATE); | ||
57 | break; | ||
58 | } | ||
59 | resplen = 8; | ||
47 | -- | 60 | -- |
48 | 2.25.1 | 61 | 2.34.1 |
49 | 62 | ||
50 | 63 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Sergey Kambalin <sergey.kambalin@auriga.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 3 | Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
5 | Message-id: 20230612223456.33824-5-philmd@linaro.org | ||
6 | Message-Id: <20230531155258.8361-1-sergey.kambalin@auriga.com> | ||
7 | [PMD: Split from bigger patch: 3/4] | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | [PMM: added a comment about RPI_FIRMWARE_CORE_CLK_RATE | ||
10 | really being SoC-specific] | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | --- | 13 | --- |
7 | target/arm/translate-a64.c | 7 ++++--- | 14 | include/hw/arm/raspi_platform.h | 5 +++++ |
8 | 1 file changed, 4 insertions(+), 3 deletions(-) | 15 | hw/misc/bcm2835_property.c | 3 +++ |
16 | 2 files changed, 8 insertions(+) | ||
9 | 17 | ||
10 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 18 | diff --git a/include/hw/arm/raspi_platform.h b/include/hw/arm/raspi_platform.h |
11 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/target/arm/translate-a64.c | 20 | --- a/include/hw/arm/raspi_platform.h |
13 | +++ b/target/arm/translate-a64.c | 21 | +++ b/include/hw/arm/raspi_platform.h |
14 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 22 | @@ -XXX,XX +XXX,XX @@ |
15 | { | 23 | /* Clock rates */ |
16 | DisasContext *s = container_of(dcbase, DisasContext, base); | 24 | #define RPI_FIRMWARE_EMMC_CLK_RATE 50000000 |
17 | CPUARMState *env = cpu->env_ptr; | 25 | #define RPI_FIRMWARE_UART_CLK_RATE 3000000 |
18 | + uint64_t pc = s->base.pc_next; | 26 | +/* |
19 | uint32_t insn; | 27 | + * TODO: this is really SoC-specific; we might want to |
20 | 28 | + * set it per-SoC if it turns out any guests care. | |
21 | if (s->ss_active && !s->pstate_ss) { | 29 | + */ |
22 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) | 30 | +#define RPI_FIRMWARE_CORE_CLK_RATE 350000000 |
23 | return; | 31 | #define RPI_FIRMWARE_DEFAULT_CLK_RATE 700000000 |
24 | } | 32 | |
25 | 33 | #endif | |
26 | - s->pc_curr = s->base.pc_next; | 34 | diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c |
27 | - insn = arm_ldl_code(env, &s->base, s->base.pc_next, s->sctlr_b); | 35 | index XXXXXXX..XXXXXXX 100644 |
28 | + s->pc_curr = pc; | 36 | --- a/hw/misc/bcm2835_property.c |
29 | + insn = arm_ldl_code(env, &s->base, pc, s->sctlr_b); | 37 | +++ b/hw/misc/bcm2835_property.c |
30 | s->insn = insn; | 38 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_property_mbox_push(BCM2835PropertyState *s, uint32_t value) |
31 | - s->base.pc_next += 4; | 39 | case RPI_FIRMWARE_UART_CLK_ID: |
32 | + s->base.pc_next = pc + 4; | 40 | stl_le_phys(&s->dma_as, value + 16, RPI_FIRMWARE_UART_CLK_RATE); |
33 | 41 | break; | |
34 | s->fp_access_checked = false; | 42 | + case RPI_FIRMWARE_CORE_CLK_ID: |
35 | s->sve_access_checked = false; | 43 | + stl_le_phys(&s->dma_as, value + 16, RPI_FIRMWARE_CORE_CLK_RATE); |
44 | + break; | ||
45 | default: | ||
46 | stl_le_phys(&s->dma_as, value + 16, | ||
47 | RPI_FIRMWARE_DEFAULT_CLK_RATE); | ||
36 | -- | 48 | -- |
37 | 2.25.1 | 49 | 2.34.1 |
38 | 50 | ||
39 | 51 | diff view generated by jsdifflib |