1 | target-arm queue, mostly SME preliminaries. | 1 | v3: fix test failure on 32-bit hosts due to new board defaulting to 2GB RAM. |
---|---|---|---|
2 | |||
3 | In the unlikely event we don't land the rest of SME before freeze | ||
4 | for 7.1 we can revert the docs/property changes included here. | ||
5 | 2 | ||
6 | -- PMM | 3 | -- PMM |
7 | 4 | ||
8 | The following changes since commit 097ccbbbaf2681df1e65542e5b7d2b2d0c66e2bc: | 5 | The following changes since commit 9a7beaad3dbba982f7a461d676b55a5c3851d312: |
9 | 6 | ||
10 | Merge tag 'qemu-sparc-20220626' of https://github.com/mcayland/qemu into staging (2022-06-27 05:21:05 +0530) | 7 | Merge remote-tracking branch 'remotes/alistair/tags/pull-riscv-to-apply-20210304' into staging (2021-03-05 10:47:46 +0000) |
11 | 8 | ||
12 | are available in the Git repository at: | 9 | are available in the Git repository at: |
13 | 10 | ||
14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220627 | 11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210308 |
15 | 12 | ||
16 | for you to fetch changes up to 59e1b8a22ea9f947d038ccac784de1020f266e14: | 13 | for you to fetch changes up to 50b52b18cdb9294ce83dd49bb60b8e55a6526ea0: |
17 | 14 | ||
18 | target/arm: Check V7VE as well as LPAE in arm_pamax (2022-06-27 11:18:17 +0100) | 15 | hw/arm/mps2: Update old infocenter.arm.com URLs (2021-03-08 11:54:16 +0000) |
19 | 16 | ||
20 | ---------------------------------------------------------------- | 17 | ---------------------------------------------------------------- |
21 | target-arm queue: | 18 | target-arm queue: |
22 | * sphinx: change default language to 'en' | 19 | * sbsa-ref: remove cortex-a53 from list of supported cpus |
23 | * Diagnose attempts to emulate EL3 in hvf as well as kvm | 20 | * sbsa-ref: add 'max' to list of allowed cpus |
24 | * More SME groundwork patches | 21 | * target/arm: Add support for FEAT_SSBS, Speculative Store Bypass Safe |
25 | * virt: Fix calculation of physical address space size | 22 | * npcm7xx: add EMC model |
26 | for v7VE CPUs (eg cortex-a15) | 23 | * xlnx-zynqmp: Remove obsolete 'has_rpu' property |
24 | * target/arm: Speed up aarch64 TBL/TBX | ||
25 | * virtio-mmio: improve virtio-mmio get_dev_path alog | ||
26 | * target/arm: Use TCF0 and TFSRE0 for unprivileged tag checks | ||
27 | * target/arm: Restrict v8M IDAU to TCG | ||
28 | * target/arm/cpu: Update coding style to make checkpatch.pl happy | ||
29 | * musicpal, tc6393xb, omap_lcdc, tcx: drop dead code for non-32-bit-RGB surfaces | ||
30 | * Add new board: mps3-an524 | ||
27 | 31 | ||
28 | ---------------------------------------------------------------- | 32 | ---------------------------------------------------------------- |
29 | Alexander Graf (2): | 33 | Doug Evans (3): |
30 | accel: Introduce current_accel_name() | 34 | hw/net: Add npcm7xx emc model |
31 | target/arm: Catch invalid kvm state also for hvf | 35 | hw/arm: Add npcm7xx emc model |
36 | tests/qtests: Add npcm7xx emc model test | ||
32 | 37 | ||
33 | Martin Liška (1): | 38 | Marcin Juszkiewicz (2): |
34 | sphinx: change default language to 'en' | 39 | sbsa-ref: remove cortex-a53 from list of supported cpus |
40 | sbsa-ref: add 'max' to list of allowed cpus | ||
35 | 41 | ||
36 | Richard Henderson (22): | 42 | Peter Collingbourne (1): |
37 | target/arm: Implement TPIDR2_EL0 | 43 | target/arm: Use TCF0 and TFSRE0 for unprivileged tag checks |
38 | target/arm: Add SMEEXC_EL to TB flags | ||
39 | target/arm: Add syn_smetrap | ||
40 | target/arm: Add ARM_CP_SME | ||
41 | target/arm: Add SVCR | ||
42 | target/arm: Add SMCR_ELx | ||
43 | target/arm: Add SMIDR_EL1, SMPRI_EL1, SMPRIMAP_EL2 | ||
44 | target/arm: Add PSTATE.{SM,ZA} to TB flags | ||
45 | target/arm: Add the SME ZA storage to CPUARMState | ||
46 | target/arm: Implement SMSTART, SMSTOP | ||
47 | target/arm: Move error for sve%d property to arm_cpu_sve_finalize | ||
48 | target/arm: Create ARMVQMap | ||
49 | target/arm: Generalize cpu_arm_{get,set}_vq | ||
50 | target/arm: Generalize cpu_arm_{get, set}_default_vec_len | ||
51 | target/arm: Move arm_cpu_*_finalize to internals.h | ||
52 | target/arm: Unexport aarch64_add_*_properties | ||
53 | target/arm: Add cpu properties for SME | ||
54 | target/arm: Introduce sve_vqm1_for_el_sm | ||
55 | target/arm: Add SVL to TB flags | ||
56 | target/arm: Move pred_{full, gvec}_reg_{offset, size} to translate-a64.h | ||
57 | target/arm: Extend arm_pamax to more than aarch64 | ||
58 | target/arm: Check V7VE as well as LPAE in arm_pamax | ||
59 | 44 | ||
60 | docs/conf.py | 2 +- | 45 | Peter Maydell (34): |
61 | docs/system/arm/cpu-features.rst | 56 ++++++++++ | 46 | hw/arm/musicpal: Remove dead code for non-32-bit-RGB surfaces |
62 | include/qemu/accel.h | 1 + | 47 | hw/display/tc6393xb: Remove dead code for handling non-32bpp surfaces |
63 | target/arm/cpregs.h | 5 + | 48 | hw/display/tc6393xb: Expand out macros in template header |
64 | target/arm/cpu.h | 103 ++++++++++++++----- | 49 | hw/display/tc6393xb: Inline tc6393xb_draw_graphic32() at its callsite |
65 | target/arm/helper-sme.h | 21 ++++ | 50 | hw/display/omap_lcdc: Expand out macros in template header |
66 | target/arm/helper.h | 1 + | 51 | hw/display/omap_lcdc: Drop broken bigendian ifdef |
67 | target/arm/internals.h | 4 + | 52 | hw/display/omap_lcdc: Fix coding style issues in template header |
68 | target/arm/syndrome.h | 14 +++ | 53 | hw/display/omap_lcdc: Inline template header into C file |
69 | target/arm/translate-a64.h | 38 +++++++ | 54 | hw/display/omap_lcdc: Delete unnecessary macro |
70 | target/arm/translate.h | 6 ++ | 55 | hw/display/tcx: Drop unnecessary code for handling BGR format outputs |
71 | accel/accel-common.c | 8 ++ | 56 | hw/arm/mps2-tz: Make SYSCLK frequency board-specific |
72 | hw/arm/virt.c | 10 +- | 57 | hw/misc/mps2-scc: Support configurable number of OSCCLK values |
73 | softmmu/vl.c | 3 +- | 58 | hw/arm/mps2-tz: Correct the OSCCLK settings for mps2-an505 and mps2-an511 |
74 | target/arm/cpu.c | 32 ++++-- | 59 | hw/arm/mps2-tz: Make the OSCCLK settings be configurable per-board |
75 | target/arm/cpu64.c | 205 ++++++++++++++++++++++++++++--------- | 60 | hw/misc/mps2-fpgaio: Make number of LEDs configurable by board |
76 | target/arm/helper.c | 213 +++++++++++++++++++++++++++++++++++++-- | 61 | hw/misc/mps2-fpgaio: Support SWITCH register |
77 | target/arm/kvm64.c | 2 +- | 62 | hw/arm/mps2-tz: Make FPGAIO switch and LED config per-board |
78 | target/arm/machine.c | 34 +++++++ | 63 | hw/arm/mps2-tz: Condition IRQ splitting on number of CPUs, not board type |
79 | target/arm/ptw.c | 26 +++-- | 64 | hw/arm/mps2-tz: Make number of IRQs board-specific |
80 | target/arm/sme_helper.c | 61 +++++++++++ | 65 | hw/misc/mps2-scc: Implement CFG_REG5 and CFG_REG6 for MPS3 AN524 |
81 | target/arm/translate-a64.c | 46 +++++++++ | 66 | hw/arm/mps2-tz: Correct wrong interrupt numbers for DMA and SPI |
82 | target/arm/translate-sve.c | 36 ------- | 67 | hw/arm/mps2-tz: Allow PPCPortInfo structures to specify device interrupts |
83 | target/arm/meson.build | 1 + | 68 | hw/arm/mps2-tz: Move device IRQ info to data structures |
84 | 24 files changed, 782 insertions(+), 146 deletions(-) | 69 | hw/arm/mps2-tz: Size the uart-irq-orgate based on the number of UARTs |
85 | create mode 100644 target/arm/helper-sme.h | 70 | hw/arm/mps2-tz: Allow boards to have different PPCInfo data |
86 | create mode 100644 target/arm/sme_helper.c | 71 | hw/arm/mps2-tz: Make RAM arrangement board-specific |
72 | hw/arm/mps2-tz: Set MachineClass default_ram info from RAMInfo data | ||
73 | hw/arm/mps2-tz: Support ROMs as well as RAMs | ||
74 | hw/arm/mps2-tz: Get armv7m_load_kernel() size argument from RAMInfo | ||
75 | hw/arm/mps2-tz: Add new mps3-an524 board | ||
76 | hw/arm/mps2-tz: Stub out USB controller for mps3-an524 | ||
77 | hw/arm/mps2-tz: Provide PL031 RTC on mps3-an524 | ||
78 | docs/system/arm/mps2.rst: Document the new mps3-an524 board | ||
79 | hw/arm/mps2: Update old infocenter.arm.com URLs | ||
87 | 80 | ||
81 | Philippe Mathieu-Daudé (4): | ||
82 | hw/arm/xlnx-zynqmp: Remove obsolete 'has_rpu' property | ||
83 | hw/i2c/npcm7xx_smbus: Simplify npcm7xx_smbus_init() | ||
84 | target/arm: Restrict v8M IDAU to TCG | ||
85 | target/arm/cpu: Update coding style to make checkpatch.pl happy | ||
86 | |||
87 | Rebecca Cran (3): | ||
88 | target/arm: Add support for FEAT_SSBS, Speculative Store Bypass Safe | ||
89 | target/arm: Enable FEAT_SSBS for "max" AARCH64 CPU | ||
90 | target/arm: Set ID_PFR2.SSBS to 1 for "max" 32-bit CPU | ||
91 | |||
92 | Richard Henderson (1): | ||
93 | target/arm: Speed up aarch64 TBL/TBX | ||
94 | |||
95 | schspa (1): | ||
96 | virtio-mmio: improve virtio-mmio get_dev_path alog | ||
97 | |||
98 | docs/system/arm/mps2.rst | 24 +- | ||
99 | docs/system/arm/nuvoton.rst | 3 +- | ||
100 | hw/display/omap_lcd_template.h | 169 -------- | ||
101 | hw/display/tc6393xb_template.h | 72 ---- | ||
102 | include/hw/arm/armsse.h | 4 +- | ||
103 | include/hw/arm/npcm7xx.h | 2 + | ||
104 | include/hw/arm/xlnx-zynqmp.h | 2 - | ||
105 | include/hw/misc/armsse-cpuid.h | 2 +- | ||
106 | include/hw/misc/armsse-mhu.h | 2 +- | ||
107 | include/hw/misc/iotkit-secctl.h | 2 +- | ||
108 | include/hw/misc/iotkit-sysctl.h | 2 +- | ||
109 | include/hw/misc/iotkit-sysinfo.h | 2 +- | ||
110 | include/hw/misc/mps2-fpgaio.h | 8 +- | ||
111 | include/hw/misc/mps2-scc.h | 10 +- | ||
112 | include/hw/net/npcm7xx_emc.h | 286 +++++++++++++ | ||
113 | target/arm/cpu.h | 15 +- | ||
114 | target/arm/helper-a64.h | 2 +- | ||
115 | target/arm/internals.h | 6 + | ||
116 | hw/arm/mps2-tz.c | 642 ++++++++++++++++++++++++----- | ||
117 | hw/arm/mps2.c | 5 + | ||
118 | hw/arm/musicpal.c | 64 ++- | ||
119 | hw/arm/npcm7xx.c | 50 ++- | ||
120 | hw/arm/sbsa-ref.c | 2 +- | ||
121 | hw/arm/xlnx-zynqmp.c | 6 - | ||
122 | hw/display/omap_lcdc.c | 129 +++++- | ||
123 | hw/display/tc6393xb.c | 48 +-- | ||
124 | hw/display/tcx.c | 31 +- | ||
125 | hw/i2c/npcm7xx_smbus.c | 1 - | ||
126 | hw/misc/armsse-cpuid.c | 2 +- | ||
127 | hw/misc/armsse-mhu.c | 2 +- | ||
128 | hw/misc/iotkit-sysctl.c | 2 +- | ||
129 | hw/misc/iotkit-sysinfo.c | 2 +- | ||
130 | hw/misc/mps2-fpgaio.c | 43 +- | ||
131 | hw/misc/mps2-scc.c | 93 ++++- | ||
132 | hw/net/npcm7xx_emc.c | 857 ++++++++++++++++++++++++++++++++++++++ | ||
133 | hw/virtio/virtio-mmio.c | 13 +- | ||
134 | target/arm/cpu.c | 23 +- | ||
135 | target/arm/cpu64.c | 5 + | ||
136 | target/arm/cpu_tcg.c | 8 + | ||
137 | target/arm/helper-a64.c | 32 -- | ||
138 | target/arm/helper.c | 39 +- | ||
139 | target/arm/mte_helper.c | 13 +- | ||
140 | target/arm/translate-a64.c | 70 +--- | ||
141 | target/arm/vec_helper.c | 48 +++ | ||
142 | tests/qtest/npcm7xx_emc-test.c | 862 +++++++++++++++++++++++++++++++++++++++ | ||
143 | hw/net/meson.build | 1 + | ||
144 | hw/net/trace-events | 17 + | ||
145 | tests/qtest/meson.build | 3 +- | ||
146 | 48 files changed, 3108 insertions(+), 618 deletions(-) | ||
147 | delete mode 100644 hw/display/omap_lcd_template.h | ||
148 | delete mode 100644 hw/display/tc6393xb_template.h | ||
149 | create mode 100644 include/hw/net/npcm7xx_emc.h | ||
150 | create mode 100644 hw/net/npcm7xx_emc.c | ||
151 | create mode 100644 tests/qtest/npcm7xx_emc-test.c | ||
152 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Martin Liška <mliska@suse.cz> | ||
2 | 1 | ||
3 | Fixes the following Sphinx warning (treated as error) starting | ||
4 | with 5.0 release: | ||
5 | |||
6 | Warning, treated as error: | ||
7 | Invalid configuration value found: 'language = None'. Update your configuration to a valid langauge code. Falling back to 'en' (English). | ||
8 | |||
9 | Signed-off-by: Martin Liska <mliska@suse.cz> | ||
10 | Message-id: e91e51ee-48ac-437e-6467-98b56ee40042@suse.cz | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | docs/conf.py | 2 +- | ||
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/docs/conf.py b/docs/conf.py | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/docs/conf.py | ||
20 | +++ b/docs/conf.py | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | # | ||
23 | # This is also used if you do content translation via gettext catalogs. | ||
24 | # Usually you set "language" from the command line for these cases. | ||
25 | -language = None | ||
26 | +language = 'en' | ||
27 | |||
28 | # List of patterns, relative to source directory, that match files and | ||
29 | # directories to ignore when looking for source files. | ||
30 | -- | ||
31 | 2.25.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alexander Graf <agraf@csgraf.de> | ||
2 | 1 | ||
3 | We need to fetch the name of the current accelerator in flexible error | ||
4 | messages more going forward. Let's create a helper that gives it to us | ||
5 | without casting in the target code. | ||
6 | |||
7 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220620192242.70573-1-agraf@csgraf.de | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/qemu/accel.h | 1 + | ||
13 | accel/accel-common.c | 8 ++++++++ | ||
14 | softmmu/vl.c | 3 +-- | ||
15 | 3 files changed, 10 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/include/qemu/accel.h b/include/qemu/accel.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/qemu/accel.h | ||
20 | +++ b/include/qemu/accel.h | ||
21 | @@ -XXX,XX +XXX,XX @@ typedef struct AccelClass { | ||
22 | |||
23 | AccelClass *accel_find(const char *opt_name); | ||
24 | AccelState *current_accel(void); | ||
25 | +const char *current_accel_name(void); | ||
26 | |||
27 | void accel_init_interfaces(AccelClass *ac); | ||
28 | |||
29 | diff --git a/accel/accel-common.c b/accel/accel-common.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/accel/accel-common.c | ||
32 | +++ b/accel/accel-common.c | ||
33 | @@ -XXX,XX +XXX,XX @@ AccelClass *accel_find(const char *opt_name) | ||
34 | return ac; | ||
35 | } | ||
36 | |||
37 | +/* Return the name of the current accelerator */ | ||
38 | +const char *current_accel_name(void) | ||
39 | +{ | ||
40 | + AccelClass *ac = ACCEL_GET_CLASS(current_accel()); | ||
41 | + | ||
42 | + return ac->name; | ||
43 | +} | ||
44 | + | ||
45 | static void accel_init_cpu_int_aux(ObjectClass *klass, void *opaque) | ||
46 | { | ||
47 | CPUClass *cc = CPU_CLASS(klass); | ||
48 | diff --git a/softmmu/vl.c b/softmmu/vl.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/softmmu/vl.c | ||
51 | +++ b/softmmu/vl.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static void configure_accelerators(const char *progname) | ||
53 | } | ||
54 | |||
55 | if (init_failed && !qtest_chrdev) { | ||
56 | - AccelClass *ac = ACCEL_GET_CLASS(current_accel()); | ||
57 | - error_report("falling back to %s", ac->name); | ||
58 | + error_report("falling back to %s", current_accel_name()); | ||
59 | } | ||
60 | |||
61 | if (icount_enabled() && !tcg_enabled()) { | ||
62 | -- | ||
63 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alexander Graf <agraf@csgraf.de> | ||
2 | 1 | ||
3 | Some features such as running in EL3 or running M profile code are | ||
4 | incompatible with virtualization as QEMU implements it today. To prevent | ||
5 | users from picking invalid configurations on other virt solutions like | ||
6 | Hvf, let's run the same checks there too. | ||
7 | |||
8 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1073 | ||
9 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220620192242.70573-2-agraf@csgraf.de | ||
12 | [PMM: Allow qtest accelerator too; tweak comment] | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | target/arm/cpu.c | 16 ++++++++++++---- | ||
16 | 1 file changed, 12 insertions(+), 4 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/cpu.c | ||
21 | +++ b/target/arm/cpu.c | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | #include "hw/boards.h" | ||
24 | #endif | ||
25 | #include "sysemu/tcg.h" | ||
26 | +#include "sysemu/qtest.h" | ||
27 | #include "sysemu/hw_accel.h" | ||
28 | #include "kvm_arm.h" | ||
29 | #include "disas/capstone.h" | ||
30 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
31 | } | ||
32 | } | ||
33 | |||
34 | - if (kvm_enabled()) { | ||
35 | + if (!tcg_enabled() && !qtest_enabled()) { | ||
36 | /* | ||
37 | + * We assume that no accelerator except TCG (and the "not really an | ||
38 | + * accelerator" qtest) can handle these features, because Arm hardware | ||
39 | + * virtualization can't virtualize them. | ||
40 | + * | ||
41 | * Catch all the cases which might cause us to create more than one | ||
42 | * address space for the CPU (otherwise we will assert() later in | ||
43 | * cpu_address_space_init()). | ||
44 | */ | ||
45 | if (arm_feature(env, ARM_FEATURE_M)) { | ||
46 | error_setg(errp, | ||
47 | - "Cannot enable KVM when using an M-profile guest CPU"); | ||
48 | + "Cannot enable %s when using an M-profile guest CPU", | ||
49 | + current_accel_name()); | ||
50 | return; | ||
51 | } | ||
52 | if (cpu->has_el3) { | ||
53 | error_setg(errp, | ||
54 | - "Cannot enable KVM when guest CPU has EL3 enabled"); | ||
55 | + "Cannot enable %s when guest CPU has EL3 enabled", | ||
56 | + current_accel_name()); | ||
57 | return; | ||
58 | } | ||
59 | if (cpu->tag_memory) { | ||
60 | error_setg(errp, | ||
61 | - "Cannot enable KVM when guest CPUs has MTE enabled"); | ||
62 | + "Cannot enable %s when guest CPUs has MTE enabled", | ||
63 | + current_accel_name()); | ||
64 | return; | ||
65 | } | ||
66 | } | ||
67 | -- | ||
68 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | This register is part of SME, but isn't closely related to the | ||
4 | rest of the extension. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-2-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 1 + | ||
12 | target/arm/helper.c | 32 ++++++++++++++++++++++++++++++++ | ||
13 | 2 files changed, 33 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.h | ||
18 | +++ b/target/arm/cpu.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
20 | }; | ||
21 | uint64_t tpidr_el[4]; | ||
22 | }; | ||
23 | + uint64_t tpidr2_el0; | ||
24 | /* The secure banks of these registers don't map anywhere */ | ||
25 | uint64_t tpidrurw_s; | ||
26 | uint64_t tpidrprw_s; | ||
27 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/target/arm/helper.c | ||
30 | +++ b/target/arm/helper.c | ||
31 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo zcr_reginfo[] = { | ||
32 | .writefn = zcr_write, .raw_writefn = raw_write }, | ||
33 | }; | ||
34 | |||
35 | +#ifdef TARGET_AARCH64 | ||
36 | +static CPAccessResult access_tpidr2(CPUARMState *env, const ARMCPRegInfo *ri, | ||
37 | + bool isread) | ||
38 | +{ | ||
39 | + int el = arm_current_el(env); | ||
40 | + | ||
41 | + if (el == 0) { | ||
42 | + uint64_t sctlr = arm_sctlr(env, el); | ||
43 | + if (!(sctlr & SCTLR_EnTP2)) { | ||
44 | + return CP_ACCESS_TRAP; | ||
45 | + } | ||
46 | + } | ||
47 | + /* TODO: FEAT_FGT */ | ||
48 | + if (el < 3 | ||
49 | + && arm_feature(env, ARM_FEATURE_EL3) | ||
50 | + && !(env->cp15.scr_el3 & SCR_ENTP2)) { | ||
51 | + return CP_ACCESS_TRAP_EL3; | ||
52 | + } | ||
53 | + return CP_ACCESS_OK; | ||
54 | +} | ||
55 | + | ||
56 | +static const ARMCPRegInfo sme_reginfo[] = { | ||
57 | + { .name = "TPIDR2_EL0", .state = ARM_CP_STATE_AA64, | ||
58 | + .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 5, | ||
59 | + .access = PL0_RW, .accessfn = access_tpidr2, | ||
60 | + .fieldoffset = offsetof(CPUARMState, cp15.tpidr2_el0) }, | ||
61 | +}; | ||
62 | +#endif /* TARGET_AARCH64 */ | ||
63 | + | ||
64 | void hw_watchpoint_update(ARMCPU *cpu, int n) | ||
65 | { | ||
66 | CPUARMState *env = &cpu->env; | ||
67 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
68 | } | ||
69 | |||
70 | #ifdef TARGET_AARCH64 | ||
71 | + if (cpu_isar_feature(aa64_sme, cpu)) { | ||
72 | + define_arm_cp_regs(cpu, sme_reginfo); | ||
73 | + } | ||
74 | if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
75 | define_arm_cp_regs(cpu, pauth_reginfo); | ||
76 | } | ||
77 | -- | ||
78 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | This is CheckSMEAccess, which is the basis for a set of | ||
4 | related tests for various SME cpregs and instructions. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-3-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 2 ++ | ||
12 | target/arm/translate.h | 1 + | ||
13 | target/arm/helper.c | 52 ++++++++++++++++++++++++++++++++++++++ | ||
14 | target/arm/translate-a64.c | 1 + | ||
15 | 4 files changed, 56 insertions(+) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env); | ||
22 | |||
23 | int fp_exception_el(CPUARMState *env, int cur_el); | ||
24 | int sve_exception_el(CPUARMState *env, int cur_el); | ||
25 | +int sme_exception_el(CPUARMState *env, int cur_el); | ||
26 | |||
27 | /** | ||
28 | * sve_vqm1_for_el: | ||
29 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, ATA, 15, 1) | ||
30 | FIELD(TBFLAG_A64, TCMA, 16, 2) | ||
31 | FIELD(TBFLAG_A64, MTE_ACTIVE, 18, 1) | ||
32 | FIELD(TBFLAG_A64, MTE0_ACTIVE, 19, 1) | ||
33 | +FIELD(TBFLAG_A64, SMEEXC_EL, 20, 2) | ||
34 | |||
35 | /* | ||
36 | * Helpers for using the above. | ||
37 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/translate.h | ||
40 | +++ b/target/arm/translate.h | ||
41 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
42 | bool ns; /* Use non-secure CPREG bank on access */ | ||
43 | int fp_excp_el; /* FP exception EL or 0 if enabled */ | ||
44 | int sve_excp_el; /* SVE exception EL or 0 if enabled */ | ||
45 | + int sme_excp_el; /* SME exception EL or 0 if enabled */ | ||
46 | int vl; /* current vector length in bytes */ | ||
47 | bool vfp_enabled; /* FP enabled via FPSCR.EN */ | ||
48 | int vec_len; | ||
49 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/helper.c | ||
52 | +++ b/target/arm/helper.c | ||
53 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | ||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | +/* | ||
58 | + * Return the exception level to which exceptions should be taken for SME. | ||
59 | + * C.f. the ARM pseudocode function CheckSMEAccess. | ||
60 | + */ | ||
61 | +int sme_exception_el(CPUARMState *env, int el) | ||
62 | +{ | ||
63 | +#ifndef CONFIG_USER_ONLY | ||
64 | + if (el <= 1 && !el_is_in_host(env, el)) { | ||
65 | + switch (FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, SMEN)) { | ||
66 | + case 1: | ||
67 | + if (el != 0) { | ||
68 | + break; | ||
69 | + } | ||
70 | + /* fall through */ | ||
71 | + case 0: | ||
72 | + case 2: | ||
73 | + return 1; | ||
74 | + } | ||
75 | + } | ||
76 | + | ||
77 | + if (el <= 2 && arm_is_el2_enabled(env)) { | ||
78 | + /* CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). */ | ||
79 | + if (env->cp15.hcr_el2 & HCR_E2H) { | ||
80 | + switch (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, SMEN)) { | ||
81 | + case 1: | ||
82 | + if (el != 0 || !(env->cp15.hcr_el2 & HCR_TGE)) { | ||
83 | + break; | ||
84 | + } | ||
85 | + /* fall through */ | ||
86 | + case 0: | ||
87 | + case 2: | ||
88 | + return 2; | ||
89 | + } | ||
90 | + } else { | ||
91 | + if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TSM)) { | ||
92 | + return 2; | ||
93 | + } | ||
94 | + } | ||
95 | + } | ||
96 | + | ||
97 | + /* CPTR_EL3. Since ESM is negative we must check for EL3. */ | ||
98 | + if (arm_feature(env, ARM_FEATURE_EL3) | ||
99 | + && !FIELD_EX64(env->cp15.cptr_el[3], CPTR_EL3, ESM)) { | ||
100 | + return 3; | ||
101 | + } | ||
102 | +#endif | ||
103 | + return 0; | ||
104 | +} | ||
105 | + | ||
106 | /* | ||
107 | * Given that SVE is enabled, return the vector length for EL. | ||
108 | */ | ||
109 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
110 | } | ||
111 | DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); | ||
112 | } | ||
113 | + if (cpu_isar_feature(aa64_sme, env_archcpu(env))) { | ||
114 | + DP_TBFLAG_A64(flags, SMEEXC_EL, sme_exception_el(env, el)); | ||
115 | + } | ||
116 | |||
117 | sctlr = regime_sctlr(env, stage1); | ||
118 | |||
119 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/target/arm/translate-a64.c | ||
122 | +++ b/target/arm/translate-a64.c | ||
123 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
124 | dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM); | ||
125 | dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL); | ||
126 | dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); | ||
127 | + dc->sme_excp_el = EX_TBFLAG_A64(tb_flags, SMEEXC_EL); | ||
128 | dc->vl = (EX_TBFLAG_A64(tb_flags, VL) + 1) * 16; | ||
129 | dc->pauth_active = EX_TBFLAG_A64(tb_flags, PAUTH_ACTIVE); | ||
130 | dc->bt = EX_TBFLAG_A64(tb_flags, BT); | ||
131 | -- | ||
132 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | This will be used for raising various traps for SME. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220620175235.60881-4-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/syndrome.h | 14 ++++++++++++++ | ||
11 | 1 file changed, 14 insertions(+) | ||
12 | |||
13 | diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/target/arm/syndrome.h | ||
16 | +++ b/target/arm/syndrome.h | ||
17 | @@ -XXX,XX +XXX,XX @@ enum arm_exception_class { | ||
18 | EC_AA64_SMC = 0x17, | ||
19 | EC_SYSTEMREGISTERTRAP = 0x18, | ||
20 | EC_SVEACCESSTRAP = 0x19, | ||
21 | + EC_SMETRAP = 0x1d, | ||
22 | EC_INSNABORT = 0x20, | ||
23 | EC_INSNABORT_SAME_EL = 0x21, | ||
24 | EC_PCALIGNMENT = 0x22, | ||
25 | @@ -XXX,XX +XXX,XX @@ enum arm_exception_class { | ||
26 | EC_AA64_BKPT = 0x3c, | ||
27 | }; | ||
28 | |||
29 | +typedef enum { | ||
30 | + SME_ET_AccessTrap, | ||
31 | + SME_ET_Streaming, | ||
32 | + SME_ET_NotStreaming, | ||
33 | + SME_ET_InactiveZA, | ||
34 | +} SMEExceptionType; | ||
35 | + | ||
36 | #define ARM_EL_EC_SHIFT 26 | ||
37 | #define ARM_EL_IL_SHIFT 25 | ||
38 | #define ARM_EL_ISV_SHIFT 24 | ||
39 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_sve_access_trap(void) | ||
40 | return EC_SVEACCESSTRAP << ARM_EL_EC_SHIFT; | ||
41 | } | ||
42 | |||
43 | +static inline uint32_t syn_smetrap(SMEExceptionType etype, bool is_16bit) | ||
44 | +{ | ||
45 | + return (EC_SMETRAP << ARM_EL_EC_SHIFT) | ||
46 | + | (is_16bit ? 0 : ARM_EL_IL) | etype; | ||
47 | +} | ||
48 | + | ||
49 | static inline uint32_t syn_pactrap(void) | ||
50 | { | ||
51 | return EC_PACTRAP << ARM_EL_EC_SHIFT; | ||
52 | -- | ||
53 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | This will be used for controlling access to SME cpregs. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220620175235.60881-5-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/cpregs.h | 5 +++++ | ||
11 | target/arm/translate-a64.c | 18 ++++++++++++++++++ | ||
12 | 2 files changed, 23 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/cpregs.h | ||
17 | +++ b/target/arm/cpregs.h | ||
18 | @@ -XXX,XX +XXX,XX @@ enum { | ||
19 | ARM_CP_EL3_NO_EL2_UNDEF = 1 << 16, | ||
20 | ARM_CP_EL3_NO_EL2_KEEP = 1 << 17, | ||
21 | ARM_CP_EL3_NO_EL2_C_NZ = 1 << 18, | ||
22 | + /* | ||
23 | + * Flag: Access check for this sysreg is constrained by the | ||
24 | + * ARM pseudocode function CheckSMEAccess(). | ||
25 | + */ | ||
26 | + ARM_CP_SME = 1 << 19, | ||
27 | }; | ||
28 | |||
29 | /* | ||
30 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/translate-a64.c | ||
33 | +++ b/target/arm/translate-a64.c | ||
34 | @@ -XXX,XX +XXX,XX @@ bool sve_access_check(DisasContext *s) | ||
35 | return fp_access_check(s); | ||
36 | } | ||
37 | |||
38 | +/* | ||
39 | + * Check that SME access is enabled, raise an exception if not. | ||
40 | + * Note that this function corresponds to CheckSMEAccess and is | ||
41 | + * only used directly for cpregs. | ||
42 | + */ | ||
43 | +static bool sme_access_check(DisasContext *s) | ||
44 | +{ | ||
45 | + if (s->sme_excp_el) { | ||
46 | + gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, | ||
47 | + syn_smetrap(SME_ET_AccessTrap, false), | ||
48 | + s->sme_excp_el); | ||
49 | + return false; | ||
50 | + } | ||
51 | + return true; | ||
52 | +} | ||
53 | + | ||
54 | /* | ||
55 | * This utility function is for doing register extension with an | ||
56 | * optional shift. You will likely want to pass a temporary for the | ||
57 | @@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, | ||
58 | return; | ||
59 | } else if ((ri->type & ARM_CP_SVE) && !sve_access_check(s)) { | ||
60 | return; | ||
61 | + } else if ((ri->type & ARM_CP_SME) && !sme_access_check(s)) { | ||
62 | + return; | ||
63 | } | ||
64 | |||
65 | if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { | ||
66 | -- | ||
67 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | This cpreg is used to access two new bits of PSTATE | ||
4 | that are not visible via any other mechanism. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-6-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 6 ++++++ | ||
12 | target/arm/helper.c | 13 +++++++++++++ | ||
13 | 2 files changed, 19 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.h | ||
18 | +++ b/target/arm/cpu.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
20 | * nRW (also known as M[4]) is kept, inverted, in env->aarch64 | ||
21 | * DAIF (exception masks) are kept in env->daif | ||
22 | * BTYPE is kept in env->btype | ||
23 | + * SM and ZA are kept in env->svcr | ||
24 | * all other bits are stored in their correct places in env->pstate | ||
25 | */ | ||
26 | uint32_t pstate; | ||
27 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
28 | uint32_t condexec_bits; /* IT bits. cpsr[15:10,26:25]. */ | ||
29 | uint32_t btype; /* BTI branch type. spsr[11:10]. */ | ||
30 | uint64_t daif; /* exception masks, in the bits they are in PSTATE */ | ||
31 | + uint64_t svcr; /* PSTATE.{SM,ZA} in the bits they are in SVCR */ | ||
32 | |||
33 | uint64_t elr_el[4]; /* AArch64 exception link regs */ | ||
34 | uint64_t sp_el[4]; /* AArch64 banked stack pointers */ | ||
35 | @@ -XXX,XX +XXX,XX @@ FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
36 | #define PSTATE_MODE_EL1t 4 | ||
37 | #define PSTATE_MODE_EL0t 0 | ||
38 | |||
39 | +/* PSTATE bits that are accessed via SVCR and not stored in SPSR_ELx. */ | ||
40 | +FIELD(SVCR, SM, 0, 1) | ||
41 | +FIELD(SVCR, ZA, 1, 1) | ||
42 | + | ||
43 | /* Write a new value to v7m.exception, thus transitioning into or out | ||
44 | * of Handler mode; this may result in a change of active stack pointer. | ||
45 | */ | ||
46 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/helper.c | ||
49 | +++ b/target/arm/helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tpidr2(CPUARMState *env, const ARMCPRegInfo *ri, | ||
51 | return CP_ACCESS_OK; | ||
52 | } | ||
53 | |||
54 | +static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
55 | + uint64_t value) | ||
56 | +{ | ||
57 | + value &= R_SVCR_SM_MASK | R_SVCR_ZA_MASK; | ||
58 | + /* TODO: Side effects. */ | ||
59 | + env->svcr = value; | ||
60 | +} | ||
61 | + | ||
62 | static const ARMCPRegInfo sme_reginfo[] = { | ||
63 | { .name = "TPIDR2_EL0", .state = ARM_CP_STATE_AA64, | ||
64 | .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 5, | ||
65 | .access = PL0_RW, .accessfn = access_tpidr2, | ||
66 | .fieldoffset = offsetof(CPUARMState, cp15.tpidr2_el0) }, | ||
67 | + { .name = "SVCR", .state = ARM_CP_STATE_AA64, | ||
68 | + .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 2, | ||
69 | + .access = PL0_RW, .type = ARM_CP_SME, | ||
70 | + .fieldoffset = offsetof(CPUARMState, svcr), | ||
71 | + .writefn = svcr_write, .raw_writefn = raw_write }, | ||
72 | }; | ||
73 | #endif /* TARGET_AARCH64 */ | ||
74 | |||
75 | -- | ||
76 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | These cpregs control the streaming vector length and whether the | ||
4 | full a64 instruction set is allowed while in streaming mode. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-7-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 8 ++++++-- | ||
12 | target/arm/helper.c | 41 +++++++++++++++++++++++++++++++++++++++++ | ||
13 | 2 files changed, 47 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.h | ||
18 | +++ b/target/arm/cpu.h | ||
19 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
20 | float_status standard_fp_status; | ||
21 | float_status standard_fp_status_f16; | ||
22 | |||
23 | - /* ZCR_EL[1-3] */ | ||
24 | - uint64_t zcr_el[4]; | ||
25 | + uint64_t zcr_el[4]; /* ZCR_EL[1-3] */ | ||
26 | + uint64_t smcr_el[4]; /* SMCR_EL[1-3] */ | ||
27 | } vfp; | ||
28 | uint64_t exclusive_addr; | ||
29 | uint64_t exclusive_val; | ||
30 | @@ -XXX,XX +XXX,XX @@ FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
31 | FIELD(SVCR, SM, 0, 1) | ||
32 | FIELD(SVCR, ZA, 1, 1) | ||
33 | |||
34 | +/* Fields for SMCR_ELx. */ | ||
35 | +FIELD(SMCR, LEN, 0, 4) | ||
36 | +FIELD(SMCR, FA64, 31, 1) | ||
37 | + | ||
38 | /* Write a new value to v7m.exception, thus transitioning into or out | ||
39 | * of Handler mode; this may result in a change of active stack pointer. | ||
40 | */ | ||
41 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/helper.c | ||
44 | +++ b/target/arm/helper.c | ||
45 | @@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) | ||
46 | */ | ||
47 | { K(3, 0, 1, 2, 0), K(3, 4, 1, 2, 0), K(3, 5, 1, 2, 0), | ||
48 | "ZCR_EL1", "ZCR_EL2", "ZCR_EL12", isar_feature_aa64_sve }, | ||
49 | + { K(3, 0, 1, 2, 6), K(3, 4, 1, 2, 6), K(3, 5, 1, 2, 6), | ||
50 | + "SMCR_EL1", "SMCR_EL2", "SMCR_EL12", isar_feature_aa64_sme }, | ||
51 | |||
52 | { K(3, 0, 5, 6, 0), K(3, 4, 5, 6, 0), K(3, 5, 5, 6, 0), | ||
53 | "TFSR_EL1", "TFSR_EL2", "TFSR_EL12", isar_feature_aa64_mte }, | ||
54 | @@ -XXX,XX +XXX,XX @@ static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
55 | env->svcr = value; | ||
56 | } | ||
57 | |||
58 | +static void smcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
59 | + uint64_t value) | ||
60 | +{ | ||
61 | + int cur_el = arm_current_el(env); | ||
62 | + int old_len = sve_vqm1_for_el(env, cur_el); | ||
63 | + int new_len; | ||
64 | + | ||
65 | + QEMU_BUILD_BUG_ON(ARM_MAX_VQ > R_SMCR_LEN_MASK + 1); | ||
66 | + value &= R_SMCR_LEN_MASK | R_SMCR_FA64_MASK; | ||
67 | + raw_write(env, ri, value); | ||
68 | + | ||
69 | + /* | ||
70 | + * Note that it is CONSTRAINED UNPREDICTABLE what happens to ZA storage | ||
71 | + * when SVL is widened (old values kept, or zeros). Choose to keep the | ||
72 | + * current values for simplicity. But for QEMU internals, we must still | ||
73 | + * apply the narrower SVL to the Zregs and Pregs -- see the comment | ||
74 | + * above aarch64_sve_narrow_vq. | ||
75 | + */ | ||
76 | + new_len = sve_vqm1_for_el(env, cur_el); | ||
77 | + if (new_len < old_len) { | ||
78 | + aarch64_sve_narrow_vq(env, new_len + 1); | ||
79 | + } | ||
80 | +} | ||
81 | + | ||
82 | static const ARMCPRegInfo sme_reginfo[] = { | ||
83 | { .name = "TPIDR2_EL0", .state = ARM_CP_STATE_AA64, | ||
84 | .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 5, | ||
85 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo sme_reginfo[] = { | ||
86 | .access = PL0_RW, .type = ARM_CP_SME, | ||
87 | .fieldoffset = offsetof(CPUARMState, svcr), | ||
88 | .writefn = svcr_write, .raw_writefn = raw_write }, | ||
89 | + { .name = "SMCR_EL1", .state = ARM_CP_STATE_AA64, | ||
90 | + .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 6, | ||
91 | + .access = PL1_RW, .type = ARM_CP_SME, | ||
92 | + .fieldoffset = offsetof(CPUARMState, vfp.smcr_el[1]), | ||
93 | + .writefn = smcr_write, .raw_writefn = raw_write }, | ||
94 | + { .name = "SMCR_EL2", .state = ARM_CP_STATE_AA64, | ||
95 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 6, | ||
96 | + .access = PL2_RW, .type = ARM_CP_SME, | ||
97 | + .fieldoffset = offsetof(CPUARMState, vfp.smcr_el[2]), | ||
98 | + .writefn = smcr_write, .raw_writefn = raw_write }, | ||
99 | + { .name = "SMCR_EL3", .state = ARM_CP_STATE_AA64, | ||
100 | + .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 6, | ||
101 | + .access = PL3_RW, .type = ARM_CP_SME, | ||
102 | + .fieldoffset = offsetof(CPUARMState, vfp.smcr_el[3]), | ||
103 | + .writefn = smcr_write, .raw_writefn = raw_write }, | ||
104 | }; | ||
105 | #endif /* TARGET_AARCH64 */ | ||
106 | |||
107 | -- | ||
108 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Implement the streaming mode identification register, and the | ||
4 | two streaming priority registers. For QEMU, they are all RES0. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-8-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper.c | 33 +++++++++++++++++++++++++++++++++ | ||
12 | 1 file changed, 33 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper.c | ||
17 | +++ b/target/arm/helper.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tpidr2(CPUARMState *env, const ARMCPRegInfo *ri, | ||
19 | return CP_ACCESS_OK; | ||
20 | } | ||
21 | |||
22 | +static CPAccessResult access_esm(CPUARMState *env, const ARMCPRegInfo *ri, | ||
23 | + bool isread) | ||
24 | +{ | ||
25 | + /* TODO: FEAT_FGT for SMPRI_EL1 but not SMPRIMAP_EL2 */ | ||
26 | + if (arm_current_el(env) < 3 | ||
27 | + && arm_feature(env, ARM_FEATURE_EL3) | ||
28 | + && !FIELD_EX64(env->cp15.cptr_el[3], CPTR_EL3, ESM)) { | ||
29 | + return CP_ACCESS_TRAP_EL3; | ||
30 | + } | ||
31 | + return CP_ACCESS_OK; | ||
32 | +} | ||
33 | + | ||
34 | static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
35 | uint64_t value) | ||
36 | { | ||
37 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo sme_reginfo[] = { | ||
38 | .access = PL3_RW, .type = ARM_CP_SME, | ||
39 | .fieldoffset = offsetof(CPUARMState, vfp.smcr_el[3]), | ||
40 | .writefn = smcr_write, .raw_writefn = raw_write }, | ||
41 | + { .name = "SMIDR_EL1", .state = ARM_CP_STATE_AA64, | ||
42 | + .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 6, | ||
43 | + .access = PL1_R, .accessfn = access_aa64_tid1, | ||
44 | + /* | ||
45 | + * IMPLEMENTOR = 0 (software) | ||
46 | + * REVISION = 0 (implementation defined) | ||
47 | + * SMPS = 0 (no streaming execution priority in QEMU) | ||
48 | + * AFFINITY = 0 (streaming sve mode not shared with other PEs) | ||
49 | + */ | ||
50 | + .type = ARM_CP_CONST, .resetvalue = 0, }, | ||
51 | + /* | ||
52 | + * Because SMIDR_EL1.SMPS is 0, SMPRI_EL1 and SMPRIMAP_EL2 are RES 0. | ||
53 | + */ | ||
54 | + { .name = "SMPRI_EL1", .state = ARM_CP_STATE_AA64, | ||
55 | + .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 4, | ||
56 | + .access = PL1_RW, .accessfn = access_esm, | ||
57 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
58 | + { .name = "SMPRIMAP_EL2", .state = ARM_CP_STATE_AA64, | ||
59 | + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 5, | ||
60 | + .access = PL2_RW, .accessfn = access_esm, | ||
61 | + .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
62 | }; | ||
63 | #endif /* TARGET_AARCH64 */ | ||
64 | |||
65 | -- | ||
66 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | These are required to determine if various insns | ||
4 | are allowed to issue. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-9-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 2 ++ | ||
12 | target/arm/translate.h | 4 ++++ | ||
13 | target/arm/helper.c | 4 ++++ | ||
14 | target/arm/translate-a64.c | 2 ++ | ||
15 | 4 files changed, 12 insertions(+) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, TCMA, 16, 2) | ||
22 | FIELD(TBFLAG_A64, MTE_ACTIVE, 18, 1) | ||
23 | FIELD(TBFLAG_A64, MTE0_ACTIVE, 19, 1) | ||
24 | FIELD(TBFLAG_A64, SMEEXC_EL, 20, 2) | ||
25 | +FIELD(TBFLAG_A64, PSTATE_SM, 22, 1) | ||
26 | +FIELD(TBFLAG_A64, PSTATE_ZA, 23, 1) | ||
27 | |||
28 | /* | ||
29 | * Helpers for using the above. | ||
30 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/translate.h | ||
33 | +++ b/target/arm/translate.h | ||
34 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
35 | bool align_mem; | ||
36 | /* True if PSTATE.IL is set */ | ||
37 | bool pstate_il; | ||
38 | + /* True if PSTATE.SM is set. */ | ||
39 | + bool pstate_sm; | ||
40 | + /* True if PSTATE.ZA is set. */ | ||
41 | + bool pstate_za; | ||
42 | /* True if MVE insns are definitely not predicated by VPR or LTPSIZE */ | ||
43 | bool mve_no_pred; | ||
44 | /* | ||
45 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/helper.c | ||
48 | +++ b/target/arm/helper.c | ||
49 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
50 | } | ||
51 | if (cpu_isar_feature(aa64_sme, env_archcpu(env))) { | ||
52 | DP_TBFLAG_A64(flags, SMEEXC_EL, sme_exception_el(env, el)); | ||
53 | + if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
54 | + DP_TBFLAG_A64(flags, PSTATE_SM, 1); | ||
55 | + } | ||
56 | + DP_TBFLAG_A64(flags, PSTATE_ZA, FIELD_EX64(env->svcr, SVCR, ZA)); | ||
57 | } | ||
58 | |||
59 | sctlr = regime_sctlr(env, stage1); | ||
60 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
61 | index XXXXXXX..XXXXXXX 100644 | ||
62 | --- a/target/arm/translate-a64.c | ||
63 | +++ b/target/arm/translate-a64.c | ||
64 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
65 | dc->ata = EX_TBFLAG_A64(tb_flags, ATA); | ||
66 | dc->mte_active[0] = EX_TBFLAG_A64(tb_flags, MTE_ACTIVE); | ||
67 | dc->mte_active[1] = EX_TBFLAG_A64(tb_flags, MTE0_ACTIVE); | ||
68 | + dc->pstate_sm = EX_TBFLAG_A64(tb_flags, PSTATE_SM); | ||
69 | + dc->pstate_za = EX_TBFLAG_A64(tb_flags, PSTATE_ZA); | ||
70 | dc->vec_len = 0; | ||
71 | dc->vec_stride = 0; | ||
72 | dc->cp_regs = arm_cpu->cp_regs; | ||
73 | -- | ||
74 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Place this late in the resettable section of the structure, | ||
4 | to keep the most common element offsets from being > 64k. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-10-richard.henderson@linaro.org | ||
9 | [PMM: expanded comment on zarray[] format] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 22 ++++++++++++++++++++++ | ||
13 | target/arm/machine.c | 34 ++++++++++++++++++++++++++++++++++ | ||
14 | 2 files changed, 56 insertions(+) | ||
15 | |||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/cpu.h | ||
19 | +++ b/target/arm/cpu.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { | ||
21 | } keys; | ||
22 | |||
23 | uint64_t scxtnum_el[4]; | ||
24 | + | ||
25 | + /* | ||
26 | + * SME ZA storage -- 256 x 256 byte array, with bytes in host word order, | ||
27 | + * as we do with vfp.zregs[]. This corresponds to the architectural ZA | ||
28 | + * array, where ZA[N] is in the least-significant bytes of env->zarray[N]. | ||
29 | + * When SVL is less than the architectural maximum, the accessible | ||
30 | + * storage is restricted, such that if the SVL is X bytes the guest can | ||
31 | + * see only the bottom X elements of zarray[], and only the least | ||
32 | + * significant X bytes of each element of the array. (In other words, | ||
33 | + * the observable part is always square.) | ||
34 | + * | ||
35 | + * The ZA storage can also be considered as a set of square tiles of | ||
36 | + * elements of different sizes. The mapping from tiles to the ZA array | ||
37 | + * is architecturally defined, such that for tiles of elements of esz | ||
38 | + * bytes, the Nth row (or "horizontal slice") of tile T is in | ||
39 | + * ZA[T + N * esz]. Note that this means that each tile is not contiguous | ||
40 | + * in the ZA storage, because its rows are striped through the ZA array. | ||
41 | + * | ||
42 | + * Because this is so large, keep this toward the end of the reset area, | ||
43 | + * to keep the offsets into the rest of the structure smaller. | ||
44 | + */ | ||
45 | + ARMVectorReg zarray[ARM_MAX_VQ * 16]; | ||
46 | #endif | ||
47 | |||
48 | #if defined(CONFIG_USER_ONLY) | ||
49 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/machine.c | ||
52 | +++ b/target/arm/machine.c | ||
53 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_sve = { | ||
54 | VMSTATE_END_OF_LIST() | ||
55 | } | ||
56 | }; | ||
57 | + | ||
58 | +static const VMStateDescription vmstate_vreg = { | ||
59 | + .name = "vreg", | ||
60 | + .version_id = 1, | ||
61 | + .minimum_version_id = 1, | ||
62 | + .fields = (VMStateField[]) { | ||
63 | + VMSTATE_UINT64_ARRAY(d, ARMVectorReg, ARM_MAX_VQ * 2), | ||
64 | + VMSTATE_END_OF_LIST() | ||
65 | + } | ||
66 | +}; | ||
67 | + | ||
68 | +static bool za_needed(void *opaque) | ||
69 | +{ | ||
70 | + ARMCPU *cpu = opaque; | ||
71 | + | ||
72 | + /* | ||
73 | + * When ZA storage is disabled, its contents are discarded. | ||
74 | + * It will be zeroed when ZA storage is re-enabled. | ||
75 | + */ | ||
76 | + return FIELD_EX64(cpu->env.svcr, SVCR, ZA); | ||
77 | +} | ||
78 | + | ||
79 | +static const VMStateDescription vmstate_za = { | ||
80 | + .name = "cpu/sme", | ||
81 | + .version_id = 1, | ||
82 | + .minimum_version_id = 1, | ||
83 | + .needed = za_needed, | ||
84 | + .fields = (VMStateField[]) { | ||
85 | + VMSTATE_STRUCT_ARRAY(env.zarray, ARMCPU, ARM_MAX_VQ * 16, 0, | ||
86 | + vmstate_vreg, ARMVectorReg), | ||
87 | + VMSTATE_END_OF_LIST() | ||
88 | + } | ||
89 | +}; | ||
90 | #endif /* AARCH64 */ | ||
91 | |||
92 | static bool serror_needed(void *opaque) | ||
93 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_arm_cpu = { | ||
94 | &vmstate_m_security, | ||
95 | #ifdef TARGET_AARCH64 | ||
96 | &vmstate_sve, | ||
97 | + &vmstate_za, | ||
98 | #endif | ||
99 | &vmstate_serror, | ||
100 | &vmstate_irq_line_state, | ||
101 | -- | ||
102 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | These two instructions are aliases of MSR (immediate). | ||
4 | Use the two helpers to properly implement svcr_write. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-11-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 1 + | ||
12 | target/arm/helper-sme.h | 21 +++++++++++++ | ||
13 | target/arm/helper.h | 1 + | ||
14 | target/arm/helper.c | 6 ++-- | ||
15 | target/arm/sme_helper.c | 61 ++++++++++++++++++++++++++++++++++++++ | ||
16 | target/arm/translate-a64.c | 24 +++++++++++++++ | ||
17 | target/arm/meson.build | 1 + | ||
18 | 7 files changed, 112 insertions(+), 3 deletions(-) | ||
19 | create mode 100644 target/arm/helper-sme.h | ||
20 | create mode 100644 target/arm/sme_helper.c | ||
21 | |||
22 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/target/arm/cpu.h | ||
25 | +++ b/target/arm/cpu.h | ||
26 | @@ -XXX,XX +XXX,XX @@ void aarch64_sve_change_el(CPUARMState *env, int old_el, | ||
27 | int new_el, bool el0_a64); | ||
28 | void aarch64_add_sve_properties(Object *obj); | ||
29 | void aarch64_add_pauth_properties(Object *obj); | ||
30 | +void arm_reset_sve_state(CPUARMState *env); | ||
31 | |||
32 | /* | ||
33 | * SVE registers are encoded in KVM's memory in an endianness-invariant format. | ||
34 | diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h | ||
35 | new file mode 100644 | ||
36 | index XXXXXXX..XXXXXXX | ||
37 | --- /dev/null | ||
38 | +++ b/target/arm/helper-sme.h | ||
39 | @@ -XXX,XX +XXX,XX @@ | ||
40 | +/* | ||
41 | + * AArch64 SME specific helper definitions | ||
42 | + * | ||
43 | + * Copyright (c) 2022 Linaro, Ltd | ||
44 | + * | ||
45 | + * This library is free software; you can redistribute it and/or | ||
46 | + * modify it under the terms of the GNU Lesser General Public | ||
47 | + * License as published by the Free Software Foundation; either | ||
48 | + * version 2.1 of the License, or (at your option) any later version. | ||
49 | + * | ||
50 | + * This library is distributed in the hope that it will be useful, | ||
51 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
52 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
53 | + * Lesser General Public License for more details. | ||
54 | + * | ||
55 | + * You should have received a copy of the GNU Lesser General Public | ||
56 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
57 | + */ | ||
58 | + | ||
59 | +DEF_HELPER_FLAGS_2(set_pstate_sm, TCG_CALL_NO_RWG, void, env, i32) | ||
60 | +DEF_HELPER_FLAGS_2(set_pstate_za, TCG_CALL_NO_RWG, void, env, i32) | ||
61 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/helper.h | ||
64 | +++ b/target/arm/helper.h | ||
65 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_6(gvec_bfmlal_idx, TCG_CALL_NO_RWG, | ||
66 | #ifdef TARGET_AARCH64 | ||
67 | #include "helper-a64.h" | ||
68 | #include "helper-sve.h" | ||
69 | +#include "helper-sme.h" | ||
70 | #endif | ||
71 | |||
72 | #include "helper-mve.h" | ||
73 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
74 | index XXXXXXX..XXXXXXX 100644 | ||
75 | --- a/target/arm/helper.c | ||
76 | +++ b/target/arm/helper.c | ||
77 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult access_esm(CPUARMState *env, const ARMCPRegInfo *ri, | ||
78 | static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
79 | uint64_t value) | ||
80 | { | ||
81 | - value &= R_SVCR_SM_MASK | R_SVCR_ZA_MASK; | ||
82 | - /* TODO: Side effects. */ | ||
83 | - env->svcr = value; | ||
84 | + helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM)); | ||
85 | + helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA)); | ||
86 | + arm_rebuild_hflags(env); | ||
87 | } | ||
88 | |||
89 | static void smcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
90 | diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c | ||
91 | new file mode 100644 | ||
92 | index XXXXXXX..XXXXXXX | ||
93 | --- /dev/null | ||
94 | +++ b/target/arm/sme_helper.c | ||
95 | @@ -XXX,XX +XXX,XX @@ | ||
96 | +/* | ||
97 | + * ARM SME Operations | ||
98 | + * | ||
99 | + * Copyright (c) 2022 Linaro, Ltd. | ||
100 | + * | ||
101 | + * This library is free software; you can redistribute it and/or | ||
102 | + * modify it under the terms of the GNU Lesser General Public | ||
103 | + * License as published by the Free Software Foundation; either | ||
104 | + * version 2.1 of the License, or (at your option) any later version. | ||
105 | + * | ||
106 | + * This library is distributed in the hope that it will be useful, | ||
107 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
108 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
109 | + * Lesser General Public License for more details. | ||
110 | + * | ||
111 | + * You should have received a copy of the GNU Lesser General Public | ||
112 | + * License along with this library; if not, see <http://www.gnu.org/licenses/>. | ||
113 | + */ | ||
114 | + | ||
115 | +#include "qemu/osdep.h" | ||
116 | +#include "cpu.h" | ||
117 | +#include "internals.h" | ||
118 | +#include "exec/helper-proto.h" | ||
119 | + | ||
120 | +/* ResetSVEState */ | ||
121 | +void arm_reset_sve_state(CPUARMState *env) | ||
122 | +{ | ||
123 | + memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs)); | ||
124 | + /* Recall that FFR is stored as pregs[16]. */ | ||
125 | + memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs)); | ||
126 | + vfp_set_fpcr(env, 0x0800009f); | ||
127 | +} | ||
128 | + | ||
129 | +void helper_set_pstate_sm(CPUARMState *env, uint32_t i) | ||
130 | +{ | ||
131 | + if (i == FIELD_EX64(env->svcr, SVCR, SM)) { | ||
132 | + return; | ||
133 | + } | ||
134 | + env->svcr ^= R_SVCR_SM_MASK; | ||
135 | + arm_reset_sve_state(env); | ||
136 | +} | ||
137 | + | ||
138 | +void helper_set_pstate_za(CPUARMState *env, uint32_t i) | ||
139 | +{ | ||
140 | + if (i == FIELD_EX64(env->svcr, SVCR, ZA)) { | ||
141 | + return; | ||
142 | + } | ||
143 | + env->svcr ^= R_SVCR_ZA_MASK; | ||
144 | + | ||
145 | + /* | ||
146 | + * ResetSMEState. | ||
147 | + * | ||
148 | + * SetPSTATE_ZA zeros on enable and disable. We can zero this only | ||
149 | + * on enable: while disabled, the storage is inaccessible and the | ||
150 | + * value does not matter. We're not saving the storage in vmstate | ||
151 | + * when disabled either. | ||
152 | + */ | ||
153 | + if (i) { | ||
154 | + memset(env->zarray, 0, sizeof(env->zarray)); | ||
155 | + } | ||
156 | +} | ||
157 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/target/arm/translate-a64.c | ||
160 | +++ b/target/arm/translate-a64.c | ||
161 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, | ||
162 | } | ||
163 | break; | ||
164 | |||
165 | + case 0x1b: /* SVCR* */ | ||
166 | + if (!dc_isar_feature(aa64_sme, s) || crm < 2 || crm > 7) { | ||
167 | + goto do_unallocated; | ||
168 | + } | ||
169 | + if (sme_access_check(s)) { | ||
170 | + bool i = crm & 1; | ||
171 | + bool changed = false; | ||
172 | + | ||
173 | + if ((crm & 2) && i != s->pstate_sm) { | ||
174 | + gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i)); | ||
175 | + changed = true; | ||
176 | + } | ||
177 | + if ((crm & 4) && i != s->pstate_za) { | ||
178 | + gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i)); | ||
179 | + changed = true; | ||
180 | + } | ||
181 | + if (changed) { | ||
182 | + gen_rebuild_hflags(s); | ||
183 | + } else { | ||
184 | + s->base.is_jmp = DISAS_NEXT; | ||
185 | + } | ||
186 | + } | ||
187 | + break; | ||
188 | + | ||
189 | default: | ||
190 | do_unallocated: | ||
191 | unallocated_encoding(s); | ||
192 | diff --git a/target/arm/meson.build b/target/arm/meson.build | ||
193 | index XXXXXXX..XXXXXXX 100644 | ||
194 | --- a/target/arm/meson.build | ||
195 | +++ b/target/arm/meson.build | ||
196 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files( | ||
197 | 'mte_helper.c', | ||
198 | 'pauth_helper.c', | ||
199 | 'sve_helper.c', | ||
200 | + 'sme_helper.c', | ||
201 | 'translate-a64.c', | ||
202 | 'translate-sve.c', | ||
203 | )) | ||
204 | -- | ||
205 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Keep all of the error messages together. This does mean that | ||
4 | when setting many sve length properties we'll only generate | ||
5 | one error, but we only really need one. | ||
6 | |||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220620175235.60881-12-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu64.c | 15 +++++++-------- | ||
13 | 1 file changed, 7 insertions(+), 8 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu64.c | ||
18 | +++ b/target/arm/cpu64.c | ||
19 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
20 | "using only sve<N> properties.\n"); | ||
21 | } else { | ||
22 | error_setg(errp, "cannot enable sve%d", vq * 128); | ||
23 | - error_append_hint(errp, "This CPU does not support " | ||
24 | - "the vector length %d-bits.\n", vq * 128); | ||
25 | + if (vq_supported) { | ||
26 | + error_append_hint(errp, "This CPU does not support " | ||
27 | + "the vector length %d-bits.\n", vq * 128); | ||
28 | + } else { | ||
29 | + error_append_hint(errp, "SVE not supported by KVM " | ||
30 | + "on this host\n"); | ||
31 | + } | ||
32 | } | ||
33 | return; | ||
34 | } else { | ||
35 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
36 | return; | ||
37 | } | ||
38 | |||
39 | - if (value && kvm_enabled() && !kvm_arm_sve_supported()) { | ||
40 | - error_setg(errp, "cannot enable %s", name); | ||
41 | - error_append_hint(errp, "SVE not supported by KVM on this host\n"); | ||
42 | - return; | ||
43 | - } | ||
44 | - | ||
45 | cpu->sve_vq_map = deposit32(cpu->sve_vq_map, vq - 1, 1, value); | ||
46 | cpu->sve_vq_init |= 1 << (vq - 1); | ||
47 | } | ||
48 | -- | ||
49 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Pull the three sve_vq_* values into a structure. | ||
4 | This will be reused for SME. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-13-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 29 ++++++++++++++--------------- | ||
12 | target/arm/cpu64.c | 22 +++++++++++----------- | ||
13 | target/arm/helper.c | 2 +- | ||
14 | target/arm/kvm64.c | 2 +- | ||
15 | 4 files changed, 27 insertions(+), 28 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ typedef enum ARMPSCIState { | ||
22 | |||
23 | typedef struct ARMISARegisters ARMISARegisters; | ||
24 | |||
25 | +/* | ||
26 | + * In map, each set bit is a supported vector length of (bit-number + 1) * 16 | ||
27 | + * bytes, i.e. each bit number + 1 is the vector length in quadwords. | ||
28 | + * | ||
29 | + * While processing properties during initialization, corresponding init bits | ||
30 | + * are set for bits in sve_vq_map that have been set by properties. | ||
31 | + * | ||
32 | + * Bits set in supported represent valid vector lengths for the CPU type. | ||
33 | + */ | ||
34 | +typedef struct { | ||
35 | + uint32_t map, init, supported; | ||
36 | +} ARMVQMap; | ||
37 | + | ||
38 | /** | ||
39 | * ARMCPU: | ||
40 | * @env: #CPUARMState | ||
41 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { | ||
42 | uint32_t sve_default_vq; | ||
43 | #endif | ||
44 | |||
45 | - /* | ||
46 | - * In sve_vq_map each set bit is a supported vector length of | ||
47 | - * (bit-number + 1) * 16 bytes, i.e. each bit number + 1 is the vector | ||
48 | - * length in quadwords. | ||
49 | - * | ||
50 | - * While processing properties during initialization, corresponding | ||
51 | - * sve_vq_init bits are set for bits in sve_vq_map that have been | ||
52 | - * set by properties. | ||
53 | - * | ||
54 | - * Bits set in sve_vq_supported represent valid vector lengths for | ||
55 | - * the CPU type. | ||
56 | - */ | ||
57 | - uint32_t sve_vq_map; | ||
58 | - uint32_t sve_vq_init; | ||
59 | - uint32_t sve_vq_supported; | ||
60 | + ARMVQMap sve_vq; | ||
61 | |||
62 | /* Generic timer counter frequency, in Hz */ | ||
63 | uint64_t gt_cntfrq_hz; | ||
64 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
65 | index XXXXXXX..XXXXXXX 100644 | ||
66 | --- a/target/arm/cpu64.c | ||
67 | +++ b/target/arm/cpu64.c | ||
68 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
69 | * any of the above. Finally, if SVE is not disabled, then at least one | ||
70 | * vector length must be enabled. | ||
71 | */ | ||
72 | - uint32_t vq_map = cpu->sve_vq_map; | ||
73 | - uint32_t vq_init = cpu->sve_vq_init; | ||
74 | + uint32_t vq_map = cpu->sve_vq.map; | ||
75 | + uint32_t vq_init = cpu->sve_vq.init; | ||
76 | uint32_t vq_supported; | ||
77 | uint32_t vq_mask = 0; | ||
78 | uint32_t tmp, vq, max_vq = 0; | ||
79 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
80 | */ | ||
81 | if (kvm_enabled()) { | ||
82 | if (kvm_arm_sve_supported()) { | ||
83 | - cpu->sve_vq_supported = kvm_arm_sve_get_vls(CPU(cpu)); | ||
84 | - vq_supported = cpu->sve_vq_supported; | ||
85 | + cpu->sve_vq.supported = kvm_arm_sve_get_vls(CPU(cpu)); | ||
86 | + vq_supported = cpu->sve_vq.supported; | ||
87 | } else { | ||
88 | assert(!cpu_isar_feature(aa64_sve, cpu)); | ||
89 | vq_supported = 0; | ||
90 | } | ||
91 | } else { | ||
92 | - vq_supported = cpu->sve_vq_supported; | ||
93 | + vq_supported = cpu->sve_vq.supported; | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) | ||
98 | |||
99 | /* From now on sve_max_vq is the actual maximum supported length. */ | ||
100 | cpu->sve_max_vq = max_vq; | ||
101 | - cpu->sve_vq_map = vq_map; | ||
102 | + cpu->sve_vq.map = vq_map; | ||
103 | } | ||
104 | |||
105 | static void cpu_max_get_sve_max_vq(Object *obj, Visitor *v, const char *name, | ||
106 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name, | ||
107 | if (!cpu_isar_feature(aa64_sve, cpu)) { | ||
108 | value = false; | ||
109 | } else { | ||
110 | - value = extract32(cpu->sve_vq_map, vq - 1, 1); | ||
111 | + value = extract32(cpu->sve_vq.map, vq - 1, 1); | ||
112 | } | ||
113 | visit_type_bool(v, name, &value, errp); | ||
114 | } | ||
115 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
116 | return; | ||
117 | } | ||
118 | |||
119 | - cpu->sve_vq_map = deposit32(cpu->sve_vq_map, vq - 1, 1, value); | ||
120 | - cpu->sve_vq_init |= 1 << (vq - 1); | ||
121 | + cpu->sve_vq.map = deposit32(cpu->sve_vq.map, vq - 1, 1, value); | ||
122 | + cpu->sve_vq.init |= 1 << (vq - 1); | ||
123 | } | ||
124 | |||
125 | static bool cpu_arm_get_sve(Object *obj, Error **errp) | ||
126 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
127 | cpu->dcz_blocksize = 7; /* 512 bytes */ | ||
128 | #endif | ||
129 | |||
130 | - cpu->sve_vq_supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); | ||
131 | + cpu->sve_vq.supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); | ||
132 | |||
133 | aarch64_add_pauth_properties(obj); | ||
134 | aarch64_add_sve_properties(obj); | ||
135 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a64fx_initfn(Object *obj) | ||
136 | |||
137 | /* The A64FX supports only 128, 256 and 512 bit vector lengths */ | ||
138 | aarch64_add_sve_properties(obj); | ||
139 | - cpu->sve_vq_supported = (1 << 0) /* 128bit */ | ||
140 | + cpu->sve_vq.supported = (1 << 0) /* 128bit */ | ||
141 | | (1 << 1) /* 256bit */ | ||
142 | | (1 << 3); /* 512bit */ | ||
143 | |||
144 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
145 | index XXXXXXX..XXXXXXX 100644 | ||
146 | --- a/target/arm/helper.c | ||
147 | +++ b/target/arm/helper.c | ||
148 | @@ -XXX,XX +XXX,XX @@ uint32_t sve_vqm1_for_el(CPUARMState *env, int el) | ||
149 | len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[3]); | ||
150 | } | ||
151 | |||
152 | - len = 31 - clz32(cpu->sve_vq_map & MAKE_64BIT_MASK(0, len + 1)); | ||
153 | + len = 31 - clz32(cpu->sve_vq.map & MAKE_64BIT_MASK(0, len + 1)); | ||
154 | return len; | ||
155 | } | ||
156 | |||
157 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/target/arm/kvm64.c | ||
160 | +++ b/target/arm/kvm64.c | ||
161 | @@ -XXX,XX +XXX,XX @@ uint32_t kvm_arm_sve_get_vls(CPUState *cs) | ||
162 | static int kvm_arm_sve_set_vls(CPUState *cs) | ||
163 | { | ||
164 | ARMCPU *cpu = ARM_CPU(cs); | ||
165 | - uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq_map }; | ||
166 | + uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq.map }; | ||
167 | struct kvm_one_reg reg = { | ||
168 | .id = KVM_REG_ARM64_SVE_VLS, | ||
169 | .addr = (uint64_t)&vls[0], | ||
170 | -- | ||
171 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Rename from cpu_arm_{get,set}_sve_vq, and take the | ||
4 | ARMVQMap as the opaque parameter. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-14-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu64.c | 29 +++++++++++++++-------------- | ||
12 | 1 file changed, 15 insertions(+), 14 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/cpu64.c | ||
17 | +++ b/target/arm/cpu64.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name, | ||
19 | } | ||
20 | |||
21 | /* | ||
22 | - * Note that cpu_arm_get/set_sve_vq cannot use the simpler | ||
23 | - * object_property_add_bool interface because they make use | ||
24 | - * of the contents of "name" to determine which bit on which | ||
25 | - * to operate. | ||
26 | + * Note that cpu_arm_{get,set}_vq cannot use the simpler | ||
27 | + * object_property_add_bool interface because they make use of the | ||
28 | + * contents of "name" to determine which bit on which to operate. | ||
29 | */ | ||
30 | -static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name, | ||
31 | - void *opaque, Error **errp) | ||
32 | +static void cpu_arm_get_vq(Object *obj, Visitor *v, const char *name, | ||
33 | + void *opaque, Error **errp) | ||
34 | { | ||
35 | ARMCPU *cpu = ARM_CPU(obj); | ||
36 | + ARMVQMap *vq_map = opaque; | ||
37 | uint32_t vq = atoi(&name[3]) / 128; | ||
38 | bool value; | ||
39 | |||
40 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name, | ||
41 | if (!cpu_isar_feature(aa64_sve, cpu)) { | ||
42 | value = false; | ||
43 | } else { | ||
44 | - value = extract32(cpu->sve_vq.map, vq - 1, 1); | ||
45 | + value = extract32(vq_map->map, vq - 1, 1); | ||
46 | } | ||
47 | visit_type_bool(v, name, &value, errp); | ||
48 | } | ||
49 | |||
50 | -static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
51 | - void *opaque, Error **errp) | ||
52 | +static void cpu_arm_set_vq(Object *obj, Visitor *v, const char *name, | ||
53 | + void *opaque, Error **errp) | ||
54 | { | ||
55 | - ARMCPU *cpu = ARM_CPU(obj); | ||
56 | + ARMVQMap *vq_map = opaque; | ||
57 | uint32_t vq = atoi(&name[3]) / 128; | ||
58 | bool value; | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name, | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | - cpu->sve_vq.map = deposit32(cpu->sve_vq.map, vq - 1, 1, value); | ||
65 | - cpu->sve_vq.init |= 1 << (vq - 1); | ||
66 | + vq_map->map = deposit32(vq_map->map, vq - 1, 1, value); | ||
67 | + vq_map->init |= 1 << (vq - 1); | ||
68 | } | ||
69 | |||
70 | static bool cpu_arm_get_sve(Object *obj, Error **errp) | ||
71 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_get_sve_default_vec_len(Object *obj, Visitor *v, | ||
72 | |||
73 | void aarch64_add_sve_properties(Object *obj) | ||
74 | { | ||
75 | + ARMCPU *cpu = ARM_CPU(obj); | ||
76 | uint32_t vq; | ||
77 | |||
78 | object_property_add_bool(obj, "sve", cpu_arm_get_sve, cpu_arm_set_sve); | ||
79 | @@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj) | ||
80 | for (vq = 1; vq <= ARM_MAX_VQ; ++vq) { | ||
81 | char name[8]; | ||
82 | sprintf(name, "sve%d", vq * 128); | ||
83 | - object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, | ||
84 | - cpu_arm_set_sve_vq, NULL, NULL); | ||
85 | + object_property_add(obj, name, "bool", cpu_arm_get_vq, | ||
86 | + cpu_arm_set_vq, NULL, &cpu->sve_vq); | ||
87 | } | ||
88 | |||
89 | #ifdef CONFIG_USER_ONLY | ||
90 | -- | ||
91 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Rename from cpu_arm_{get,set}_sve_default_vec_len, | ||
4 | and take the pointer to default_vq from opaque. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-15-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu64.c | 27 ++++++++++++++------------- | ||
12 | 1 file changed, 14 insertions(+), 13 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/cpu64.c | ||
17 | +++ b/target/arm/cpu64.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, bool value, Error **errp) | ||
19 | |||
20 | #ifdef CONFIG_USER_ONLY | ||
21 | /* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
22 | -static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v, | ||
23 | - const char *name, void *opaque, | ||
24 | - Error **errp) | ||
25 | +static void cpu_arm_set_default_vec_len(Object *obj, Visitor *v, | ||
26 | + const char *name, void *opaque, | ||
27 | + Error **errp) | ||
28 | { | ||
29 | - ARMCPU *cpu = ARM_CPU(obj); | ||
30 | + uint32_t *ptr_default_vq = opaque; | ||
31 | int32_t default_len, default_vq, remainder; | ||
32 | |||
33 | if (!visit_type_int32(v, name, &default_len, errp)) { | ||
34 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v, | ||
35 | |||
36 | /* Undocumented, but the kernel allows -1 to indicate "maximum". */ | ||
37 | if (default_len == -1) { | ||
38 | - cpu->sve_default_vq = ARM_MAX_VQ; | ||
39 | + *ptr_default_vq = ARM_MAX_VQ; | ||
40 | return; | ||
41 | } | ||
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v, | ||
44 | return; | ||
45 | } | ||
46 | |||
47 | - cpu->sve_default_vq = default_vq; | ||
48 | + *ptr_default_vq = default_vq; | ||
49 | } | ||
50 | |||
51 | -static void cpu_arm_get_sve_default_vec_len(Object *obj, Visitor *v, | ||
52 | - const char *name, void *opaque, | ||
53 | - Error **errp) | ||
54 | +static void cpu_arm_get_default_vec_len(Object *obj, Visitor *v, | ||
55 | + const char *name, void *opaque, | ||
56 | + Error **errp) | ||
57 | { | ||
58 | - ARMCPU *cpu = ARM_CPU(obj); | ||
59 | - int32_t value = cpu->sve_default_vq * 16; | ||
60 | + uint32_t *ptr_default_vq = opaque; | ||
61 | + int32_t value = *ptr_default_vq * 16; | ||
62 | |||
63 | visit_type_int32(v, name, &value, errp); | ||
64 | } | ||
65 | @@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj) | ||
66 | #ifdef CONFIG_USER_ONLY | ||
67 | /* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
68 | object_property_add(obj, "sve-default-vector-length", "int32", | ||
69 | - cpu_arm_get_sve_default_vec_len, | ||
70 | - cpu_arm_set_sve_default_vec_len, NULL, NULL); | ||
71 | + cpu_arm_get_default_vec_len, | ||
72 | + cpu_arm_set_default_vec_len, NULL, | ||
73 | + &cpu->sve_default_vq); | ||
74 | #endif | ||
75 | } | ||
76 | |||
77 | -- | ||
78 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Drop the aa32-only inline fallbacks, | ||
4 | and just use a couple of ifdefs. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-16-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 6 ------ | ||
12 | target/arm/internals.h | 3 +++ | ||
13 | target/arm/cpu.c | 2 ++ | ||
14 | 3 files changed, 5 insertions(+), 6 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/cpu.h | ||
19 | +++ b/target/arm/cpu.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef struct { | ||
21 | |||
22 | #ifdef TARGET_AARCH64 | ||
23 | # define ARM_MAX_VQ 16 | ||
24 | -void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); | ||
25 | -void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); | ||
26 | -void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp); | ||
27 | #else | ||
28 | # define ARM_MAX_VQ 1 | ||
29 | -static inline void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) { } | ||
30 | -static inline void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) { } | ||
31 | -static inline void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp) { } | ||
32 | #endif | ||
33 | |||
34 | typedef struct ARMVectorReg { | ||
35 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/internals.h | ||
38 | +++ b/target/arm/internals.h | ||
39 | @@ -XXX,XX +XXX,XX @@ int arm_gdb_get_svereg(CPUARMState *env, GByteArray *buf, int reg); | ||
40 | int arm_gdb_set_svereg(CPUARMState *env, uint8_t *buf, int reg); | ||
41 | int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg); | ||
42 | int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg); | ||
43 | +void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); | ||
44 | +void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); | ||
45 | +void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp); | ||
46 | #endif | ||
47 | |||
48 | #ifdef CONFIG_USER_ONLY | ||
49 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/target/arm/cpu.c | ||
52 | +++ b/target/arm/cpu.c | ||
53 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) | ||
54 | { | ||
55 | Error *local_err = NULL; | ||
56 | |||
57 | +#ifdef TARGET_AARCH64 | ||
58 | if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
59 | arm_cpu_sve_finalize(cpu, &local_err); | ||
60 | if (local_err != NULL) { | ||
61 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) | ||
62 | return; | ||
63 | } | ||
64 | } | ||
65 | +#endif | ||
66 | |||
67 | if (kvm_enabled()) { | ||
68 | kvm_arm_steal_time_finalize(cpu, &local_err); | ||
69 | -- | ||
70 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | These functions are not used outside cpu64.c, | ||
4 | so make them static. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-17-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 3 --- | ||
12 | target/arm/cpu64.c | 4 ++-- | ||
13 | 2 files changed, 2 insertions(+), 5 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.h | ||
18 | +++ b/target/arm/cpu.h | ||
19 | @@ -XXX,XX +XXX,XX @@ int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); | ||
20 | void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq); | ||
21 | void aarch64_sve_change_el(CPUARMState *env, int old_el, | ||
22 | int new_el, bool el0_a64); | ||
23 | -void aarch64_add_sve_properties(Object *obj); | ||
24 | -void aarch64_add_pauth_properties(Object *obj); | ||
25 | void arm_reset_sve_state(CPUARMState *env); | ||
26 | |||
27 | /* | ||
28 | @@ -XXX,XX +XXX,XX @@ static inline void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq) { } | ||
29 | static inline void aarch64_sve_change_el(CPUARMState *env, int o, | ||
30 | int n, bool a) | ||
31 | { } | ||
32 | -static inline void aarch64_add_sve_properties(Object *obj) { } | ||
33 | #endif | ||
34 | |||
35 | void aarch64_sync_32_to_64(CPUARMState *env); | ||
36 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/target/arm/cpu64.c | ||
39 | +++ b/target/arm/cpu64.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_get_default_vec_len(Object *obj, Visitor *v, | ||
41 | } | ||
42 | #endif | ||
43 | |||
44 | -void aarch64_add_sve_properties(Object *obj) | ||
45 | +static void aarch64_add_sve_properties(Object *obj) | ||
46 | { | ||
47 | ARMCPU *cpu = ARM_CPU(obj); | ||
48 | uint32_t vq; | ||
49 | @@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pauth_property = | ||
50 | static Property arm_cpu_pauth_impdef_property = | ||
51 | DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false); | ||
52 | |||
53 | -void aarch64_add_pauth_properties(Object *obj) | ||
54 | +static void aarch64_add_pauth_properties(Object *obj) | ||
55 | { | ||
56 | ARMCPU *cpu = ARM_CPU(obj); | ||
57 | |||
58 | -- | ||
59 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Mirror the properties for SVE. The main difference is | ||
4 | that any arbitrary set of powers of 2 may be supported, | ||
5 | and not the stricter constraints that apply to SVE. | ||
6 | |||
7 | Include a property to control FEAT_SME_FA64, as failing | ||
8 | to restrict the runtime to the proper subset of insns | ||
9 | could be a major point for bugs. | ||
10 | |||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Message-id: 20220620175235.60881-18-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | docs/system/arm/cpu-features.rst | 56 +++++++++++++++ | ||
17 | target/arm/cpu.h | 2 + | ||
18 | target/arm/internals.h | 1 + | ||
19 | target/arm/cpu.c | 14 +++- | ||
20 | target/arm/cpu64.c | 114 +++++++++++++++++++++++++++++-- | ||
21 | 5 files changed, 180 insertions(+), 7 deletions(-) | ||
22 | |||
23 | diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/docs/system/arm/cpu-features.rst | ||
26 | +++ b/docs/system/arm/cpu-features.rst | ||
27 | @@ -XXX,XX +XXX,XX @@ verbose command lines. However, the recommended way to select vector | ||
28 | lengths is to explicitly enable each desired length. Therefore only | ||
29 | example's (1), (4), and (6) exhibit recommended uses of the properties. | ||
30 | |||
31 | +SME CPU Property Examples | ||
32 | +------------------------- | ||
33 | + | ||
34 | + 1) Disable SME:: | ||
35 | + | ||
36 | + $ qemu-system-aarch64 -M virt -cpu max,sme=off | ||
37 | + | ||
38 | + 2) Implicitly enable all vector lengths for the ``max`` CPU type:: | ||
39 | + | ||
40 | + $ qemu-system-aarch64 -M virt -cpu max | ||
41 | + | ||
42 | + 3) Only enable the 256-bit vector length:: | ||
43 | + | ||
44 | + $ qemu-system-aarch64 -M virt -cpu max,sme256=on | ||
45 | + | ||
46 | + 3) Enable the 256-bit and 1024-bit vector lengths:: | ||
47 | + | ||
48 | + $ qemu-system-aarch64 -M virt -cpu max,sme256=on,sme1024=on | ||
49 | + | ||
50 | + 4) Disable the 512-bit vector length. This results in all the other | ||
51 | + lengths supported by ``max`` defaulting to enabled | ||
52 | + (128, 256, 1024 and 2048):: | ||
53 | + | ||
54 | + $ qemu-system-aarch64 -M virt -cpu max,sve512=off | ||
55 | + | ||
56 | SVE User-mode Default Vector Length Property | ||
57 | -------------------------------------------- | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ length supported by QEMU is 256. | ||
60 | |||
61 | If this property is set to ``-1`` then the default vector length | ||
62 | is set to the maximum possible length. | ||
63 | + | ||
64 | +SME CPU Properties | ||
65 | +================== | ||
66 | + | ||
67 | +The SME CPU properties are much like the SVE properties: ``sme`` is | ||
68 | +used to enable or disable the entire SME feature, and ``sme<N>`` is | ||
69 | +used to enable or disable specific vector lengths. Finally, | ||
70 | +``sme_fa64`` is used to enable or disable ``FEAT_SME_FA64``, which | ||
71 | +allows execution of the "full a64" instruction set while Streaming | ||
72 | +SVE mode is enabled. | ||
73 | + | ||
74 | +SME is not supported by KVM at this time. | ||
75 | + | ||
76 | +At least one vector length must be enabled when ``sme`` is enabled, | ||
77 | +and all vector lengths must be powers of 2. The maximum vector | ||
78 | +length supported by qemu is 2048 bits. Otherwise, there are no | ||
79 | +additional constraints on the set of vector lengths supported by SME. | ||
80 | + | ||
81 | +SME User-mode Default Vector Length Property | ||
82 | +-------------------------------------------- | ||
83 | + | ||
84 | +For qemu-aarch64, the cpu propery ``sme-default-vector-length=N`` is | ||
85 | +defined to mirror the Linux kernel parameter file | ||
86 | +``/proc/sys/abi/sme_default_vector_length``. The default length, ``N``, | ||
87 | +is in units of bytes and must be between 16 and 8192. | ||
88 | +If not specified, the default vector length is 32. | ||
89 | + | ||
90 | +As with ``sve-default-vector-length``, if the default length is larger | ||
91 | +than the maximum vector length enabled, the actual vector length will | ||
92 | +be reduced. If this property is set to ``-1`` then the default vector | ||
93 | +length is set to the maximum possible length. | ||
94 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
95 | index XXXXXXX..XXXXXXX 100644 | ||
96 | --- a/target/arm/cpu.h | ||
97 | +++ b/target/arm/cpu.h | ||
98 | @@ -XXX,XX +XXX,XX @@ struct ArchCPU { | ||
99 | #ifdef CONFIG_USER_ONLY | ||
100 | /* Used to set the default vector length at process start. */ | ||
101 | uint32_t sve_default_vq; | ||
102 | + uint32_t sme_default_vq; | ||
103 | #endif | ||
104 | |||
105 | ARMVQMap sve_vq; | ||
106 | + ARMVQMap sme_vq; | ||
107 | |||
108 | /* Generic timer counter frequency, in Hz */ | ||
109 | uint64_t gt_cntfrq_hz; | ||
110 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/target/arm/internals.h | ||
113 | +++ b/target/arm/internals.h | ||
114 | @@ -XXX,XX +XXX,XX @@ int arm_gdb_set_svereg(CPUARMState *env, uint8_t *buf, int reg); | ||
115 | int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg); | ||
116 | int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg); | ||
117 | void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp); | ||
118 | +void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp); | ||
119 | void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp); | ||
120 | void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp); | ||
121 | #endif | ||
122 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/target/arm/cpu.c | ||
125 | +++ b/target/arm/cpu.c | ||
126 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) | ||
127 | #ifdef CONFIG_USER_ONLY | ||
128 | # ifdef TARGET_AARCH64 | ||
129 | /* | ||
130 | - * The linux kernel defaults to 512-bit vectors, when sve is supported. | ||
131 | - * See documentation for /proc/sys/abi/sve_default_vector_length, and | ||
132 | - * our corresponding sve-default-vector-length cpu property. | ||
133 | + * The linux kernel defaults to 512-bit for SVE, and 256-bit for SME. | ||
134 | + * These values were chosen to fit within the default signal frame. | ||
135 | + * See documentation for /proc/sys/abi/{sve,sme}_default_vector_length, | ||
136 | + * and our corresponding cpu property. | ||
137 | */ | ||
138 | cpu->sve_default_vq = 4; | ||
139 | + cpu->sme_default_vq = 2; | ||
140 | # endif | ||
141 | #else | ||
142 | /* Our inbound IRQ and FIQ lines */ | ||
143 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) | ||
144 | return; | ||
145 | } | ||
146 | |||
147 | + arm_cpu_sme_finalize(cpu, &local_err); | ||
148 | + if (local_err != NULL) { | ||
149 | + error_propagate(errp, local_err); | ||
150 | + return; | ||
151 | + } | ||
152 | + | ||
153 | arm_cpu_pauth_finalize(cpu, &local_err); | ||
154 | if (local_err != NULL) { | ||
155 | error_propagate(errp, local_err); | ||
156 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
157 | index XXXXXXX..XXXXXXX 100644 | ||
158 | --- a/target/arm/cpu64.c | ||
159 | +++ b/target/arm/cpu64.c | ||
160 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_get_vq(Object *obj, Visitor *v, const char *name, | ||
161 | ARMCPU *cpu = ARM_CPU(obj); | ||
162 | ARMVQMap *vq_map = opaque; | ||
163 | uint32_t vq = atoi(&name[3]) / 128; | ||
164 | + bool sve = vq_map == &cpu->sve_vq; | ||
165 | bool value; | ||
166 | |||
167 | - /* All vector lengths are disabled when SVE is off. */ | ||
168 | - if (!cpu_isar_feature(aa64_sve, cpu)) { | ||
169 | + /* All vector lengths are disabled when feature is off. */ | ||
170 | + if (sve | ||
171 | + ? !cpu_isar_feature(aa64_sve, cpu) | ||
172 | + : !cpu_isar_feature(aa64_sme, cpu)) { | ||
173 | value = false; | ||
174 | } else { | ||
175 | value = extract32(vq_map->map, vq - 1, 1); | ||
176 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, bool value, Error **errp) | ||
177 | cpu->isar.id_aa64pfr0 = t; | ||
178 | } | ||
179 | |||
180 | +void arm_cpu_sme_finalize(ARMCPU *cpu, Error **errp) | ||
181 | +{ | ||
182 | + uint32_t vq_map = cpu->sme_vq.map; | ||
183 | + uint32_t vq_init = cpu->sme_vq.init; | ||
184 | + uint32_t vq_supported = cpu->sme_vq.supported; | ||
185 | + uint32_t vq; | ||
186 | + | ||
187 | + if (vq_map == 0) { | ||
188 | + if (!cpu_isar_feature(aa64_sme, cpu)) { | ||
189 | + cpu->isar.id_aa64smfr0 = 0; | ||
190 | + return; | ||
191 | + } | ||
192 | + | ||
193 | + /* TODO: KVM will require limitations via SMCR_EL2. */ | ||
194 | + vq_map = vq_supported & ~vq_init; | ||
195 | + | ||
196 | + if (vq_map == 0) { | ||
197 | + vq = ctz32(vq_supported) + 1; | ||
198 | + error_setg(errp, "cannot disable sme%d", vq * 128); | ||
199 | + error_append_hint(errp, "All SME vector lengths are disabled.\n"); | ||
200 | + error_append_hint(errp, "With SME enabled, at least one " | ||
201 | + "vector length must be enabled.\n"); | ||
202 | + return; | ||
203 | + } | ||
204 | + } else { | ||
205 | + if (!cpu_isar_feature(aa64_sme, cpu)) { | ||
206 | + vq = 32 - clz32(vq_map); | ||
207 | + error_setg(errp, "cannot enable sme%d", vq * 128); | ||
208 | + error_append_hint(errp, "SME must be enabled to enable " | ||
209 | + "vector lengths.\n"); | ||
210 | + error_append_hint(errp, "Add sme=on to the CPU property list.\n"); | ||
211 | + return; | ||
212 | + } | ||
213 | + /* TODO: KVM will require limitations via SMCR_EL2. */ | ||
214 | + } | ||
215 | + | ||
216 | + cpu->sme_vq.map = vq_map; | ||
217 | +} | ||
218 | + | ||
219 | +static bool cpu_arm_get_sme(Object *obj, Error **errp) | ||
220 | +{ | ||
221 | + ARMCPU *cpu = ARM_CPU(obj); | ||
222 | + return cpu_isar_feature(aa64_sme, cpu); | ||
223 | +} | ||
224 | + | ||
225 | +static void cpu_arm_set_sme(Object *obj, bool value, Error **errp) | ||
226 | +{ | ||
227 | + ARMCPU *cpu = ARM_CPU(obj); | ||
228 | + uint64_t t; | ||
229 | + | ||
230 | + t = cpu->isar.id_aa64pfr1; | ||
231 | + t = FIELD_DP64(t, ID_AA64PFR1, SME, value); | ||
232 | + cpu->isar.id_aa64pfr1 = t; | ||
233 | +} | ||
234 | + | ||
235 | +static bool cpu_arm_get_sme_fa64(Object *obj, Error **errp) | ||
236 | +{ | ||
237 | + ARMCPU *cpu = ARM_CPU(obj); | ||
238 | + return cpu_isar_feature(aa64_sme, cpu) && | ||
239 | + cpu_isar_feature(aa64_sme_fa64, cpu); | ||
240 | +} | ||
241 | + | ||
242 | +static void cpu_arm_set_sme_fa64(Object *obj, bool value, Error **errp) | ||
243 | +{ | ||
244 | + ARMCPU *cpu = ARM_CPU(obj); | ||
245 | + uint64_t t; | ||
246 | + | ||
247 | + t = cpu->isar.id_aa64smfr0; | ||
248 | + t = FIELD_DP64(t, ID_AA64SMFR0, FA64, value); | ||
249 | + cpu->isar.id_aa64smfr0 = t; | ||
250 | +} | ||
251 | + | ||
252 | #ifdef CONFIG_USER_ONLY | ||
253 | -/* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
254 | +/* Mirror linux /proc/sys/abi/{sve,sme}_default_vector_length. */ | ||
255 | static void cpu_arm_set_default_vec_len(Object *obj, Visitor *v, | ||
256 | const char *name, void *opaque, | ||
257 | Error **errp) | ||
258 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_default_vec_len(Object *obj, Visitor *v, | ||
259 | * and is the maximum architectural width of ZCR_ELx.LEN. | ||
260 | */ | ||
261 | if (remainder || default_vq < 1 || default_vq > 512) { | ||
262 | - error_setg(errp, "cannot set sve-default-vector-length"); | ||
263 | + ARMCPU *cpu = ARM_CPU(obj); | ||
264 | + const char *which = | ||
265 | + (ptr_default_vq == &cpu->sve_default_vq ? "sve" : "sme"); | ||
266 | + | ||
267 | + error_setg(errp, "cannot set %s-default-vector-length", which); | ||
268 | if (remainder) { | ||
269 | error_append_hint(errp, "Vector length not a multiple of 16\n"); | ||
270 | } else if (default_vq < 1) { | ||
271 | @@ -XXX,XX +XXX,XX @@ static void aarch64_add_sve_properties(Object *obj) | ||
272 | #endif | ||
273 | } | ||
274 | |||
275 | +static void aarch64_add_sme_properties(Object *obj) | ||
276 | +{ | ||
277 | + ARMCPU *cpu = ARM_CPU(obj); | ||
278 | + uint32_t vq; | ||
279 | + | ||
280 | + object_property_add_bool(obj, "sme", cpu_arm_get_sme, cpu_arm_set_sme); | ||
281 | + object_property_add_bool(obj, "sme_fa64", cpu_arm_get_sme_fa64, | ||
282 | + cpu_arm_set_sme_fa64); | ||
283 | + | ||
284 | + for (vq = 1; vq <= ARM_MAX_VQ; vq <<= 1) { | ||
285 | + char name[8]; | ||
286 | + sprintf(name, "sme%d", vq * 128); | ||
287 | + object_property_add(obj, name, "bool", cpu_arm_get_vq, | ||
288 | + cpu_arm_set_vq, NULL, &cpu->sme_vq); | ||
289 | + } | ||
290 | + | ||
291 | +#ifdef CONFIG_USER_ONLY | ||
292 | + /* Mirror linux /proc/sys/abi/sme_default_vector_length. */ | ||
293 | + object_property_add(obj, "sme-default-vector-length", "int32", | ||
294 | + cpu_arm_get_default_vec_len, | ||
295 | + cpu_arm_set_default_vec_len, NULL, | ||
296 | + &cpu->sme_default_vq); | ||
297 | +#endif | ||
298 | +} | ||
299 | + | ||
300 | void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) | ||
301 | { | ||
302 | int arch_val = 0, impdef_val = 0; | ||
303 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
304 | #endif | ||
305 | |||
306 | cpu->sve_vq.supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); | ||
307 | + cpu->sme_vq.supported = SVE_VQ_POW2_MAP; | ||
308 | |||
309 | aarch64_add_pauth_properties(obj); | ||
310 | aarch64_add_sve_properties(obj); | ||
311 | + aarch64_add_sme_properties(obj); | ||
312 | object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq, | ||
313 | cpu_max_set_sve_max_vq, NULL, NULL); | ||
314 | qdev_property_add_static(DEVICE(obj), &arm_cpu_lpa2_property); | ||
315 | -- | ||
316 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | When Streaming SVE mode is enabled, the size is taken from | ||
4 | SMCR_ELx instead of ZCR_ELx. The format is shared, but the | ||
5 | set of vector lengths is not. Further, Streaming SVE does | ||
6 | not require any particular length to be supported. | ||
7 | |||
8 | Adjust sve_vqm1_for_el to pass the current value of PSTATE.SM | ||
9 | to the new function. | ||
10 | |||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20220620175235.60881-19-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | target/arm/cpu.h | 9 +++++++-- | ||
17 | target/arm/helper.c | 32 +++++++++++++++++++++++++------- | ||
18 | 2 files changed, 32 insertions(+), 9 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/cpu.h | ||
23 | +++ b/target/arm/cpu.h | ||
24 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int cur_el); | ||
25 | int sme_exception_el(CPUARMState *env, int cur_el); | ||
26 | |||
27 | /** | ||
28 | - * sve_vqm1_for_el: | ||
29 | + * sve_vqm1_for_el_sm: | ||
30 | * @env: CPUARMState | ||
31 | * @el: exception level | ||
32 | + * @sm: streaming mode | ||
33 | * | ||
34 | - * Compute the current SVE vector length for @el, in units of | ||
35 | + * Compute the current vector length for @el & @sm, in units of | ||
36 | * Quadwords Minus 1 -- the same scale used for ZCR_ELx.LEN. | ||
37 | + * If @sm, compute for SVL, otherwise NVL. | ||
38 | */ | ||
39 | +uint32_t sve_vqm1_for_el_sm(CPUARMState *env, int el, bool sm); | ||
40 | + | ||
41 | +/* Likewise, but using @sm = PSTATE.SM. */ | ||
42 | uint32_t sve_vqm1_for_el(CPUARMState *env, int el); | ||
43 | |||
44 | static inline bool is_a64(CPUARMState *env) | ||
45 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/helper.c | ||
48 | +++ b/target/arm/helper.c | ||
49 | @@ -XXX,XX +XXX,XX @@ int sme_exception_el(CPUARMState *env, int el) | ||
50 | /* | ||
51 | * Given that SVE is enabled, return the vector length for EL. | ||
52 | */ | ||
53 | -uint32_t sve_vqm1_for_el(CPUARMState *env, int el) | ||
54 | +uint32_t sve_vqm1_for_el_sm(CPUARMState *env, int el, bool sm) | ||
55 | { | ||
56 | ARMCPU *cpu = env_archcpu(env); | ||
57 | - uint32_t len = cpu->sve_max_vq - 1; | ||
58 | + uint64_t *cr = env->vfp.zcr_el; | ||
59 | + uint32_t map = cpu->sve_vq.map; | ||
60 | + uint32_t len = ARM_MAX_VQ - 1; | ||
61 | + | ||
62 | + if (sm) { | ||
63 | + cr = env->vfp.smcr_el; | ||
64 | + map = cpu->sme_vq.map; | ||
65 | + } | ||
66 | |||
67 | if (el <= 1 && !el_is_in_host(env, el)) { | ||
68 | - len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[1]); | ||
69 | + len = MIN(len, 0xf & (uint32_t)cr[1]); | ||
70 | } | ||
71 | if (el <= 2 && arm_feature(env, ARM_FEATURE_EL2)) { | ||
72 | - len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[2]); | ||
73 | + len = MIN(len, 0xf & (uint32_t)cr[2]); | ||
74 | } | ||
75 | if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
76 | - len = MIN(len, 0xf & (uint32_t)env->vfp.zcr_el[3]); | ||
77 | + len = MIN(len, 0xf & (uint32_t)cr[3]); | ||
78 | } | ||
79 | |||
80 | - len = 31 - clz32(cpu->sve_vq.map & MAKE_64BIT_MASK(0, len + 1)); | ||
81 | - return len; | ||
82 | + map &= MAKE_64BIT_MASK(0, len + 1); | ||
83 | + if (map != 0) { | ||
84 | + return 31 - clz32(map); | ||
85 | + } | ||
86 | + | ||
87 | + /* Bit 0 is always set for Normal SVE -- not so for Streaming SVE. */ | ||
88 | + assert(sm); | ||
89 | + return ctz32(cpu->sme_vq.map); | ||
90 | +} | ||
91 | + | ||
92 | +uint32_t sve_vqm1_for_el(CPUARMState *env, int el) | ||
93 | +{ | ||
94 | + return sve_vqm1_for_el_sm(env, el, FIELD_EX64(env->svcr, SVCR, SM)); | ||
95 | } | ||
96 | |||
97 | static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
98 | -- | ||
99 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | We need SVL separate from VL for RDSVL et al, as well as | ||
4 | ZA storage loads and stores, which do not require PSTATE.SM. | ||
5 | |||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220620175235.60881-20-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 12 ++++++++++++ | ||
12 | target/arm/translate.h | 1 + | ||
13 | target/arm/helper.c | 8 +++++++- | ||
14 | target/arm/translate-a64.c | 1 + | ||
15 | 4 files changed, 21 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/cpu.h | ||
20 | +++ b/target/arm/cpu.h | ||
21 | @@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, MTE0_ACTIVE, 19, 1) | ||
22 | FIELD(TBFLAG_A64, SMEEXC_EL, 20, 2) | ||
23 | FIELD(TBFLAG_A64, PSTATE_SM, 22, 1) | ||
24 | FIELD(TBFLAG_A64, PSTATE_ZA, 23, 1) | ||
25 | +FIELD(TBFLAG_A64, SVL, 24, 4) | ||
26 | |||
27 | /* | ||
28 | * Helpers for using the above. | ||
29 | @@ -XXX,XX +XXX,XX @@ static inline int sve_vq(CPUARMState *env) | ||
30 | return EX_TBFLAG_A64(env->hflags, VL) + 1; | ||
31 | } | ||
32 | |||
33 | +/** | ||
34 | + * sme_vq | ||
35 | + * @env: the cpu context | ||
36 | + * | ||
37 | + * Return the SVL cached within env->hflags, in units of quadwords. | ||
38 | + */ | ||
39 | +static inline int sme_vq(CPUARMState *env) | ||
40 | +{ | ||
41 | + return EX_TBFLAG_A64(env->hflags, SVL) + 1; | ||
42 | +} | ||
43 | + | ||
44 | static inline bool bswap_code(bool sctlr_b) | ||
45 | { | ||
46 | #ifdef CONFIG_USER_ONLY | ||
47 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/translate.h | ||
50 | +++ b/target/arm/translate.h | ||
51 | @@ -XXX,XX +XXX,XX @@ typedef struct DisasContext { | ||
52 | int sve_excp_el; /* SVE exception EL or 0 if enabled */ | ||
53 | int sme_excp_el; /* SME exception EL or 0 if enabled */ | ||
54 | int vl; /* current vector length in bytes */ | ||
55 | + int svl; /* current streaming vector length in bytes */ | ||
56 | bool vfp_enabled; /* FP enabled via FPSCR.EN */ | ||
57 | int vec_len; | ||
58 | int vec_stride; | ||
59 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/target/arm/helper.c | ||
62 | +++ b/target/arm/helper.c | ||
63 | @@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, | ||
64 | DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); | ||
65 | } | ||
66 | if (cpu_isar_feature(aa64_sme, env_archcpu(env))) { | ||
67 | - DP_TBFLAG_A64(flags, SMEEXC_EL, sme_exception_el(env, el)); | ||
68 | + int sme_el = sme_exception_el(env, el); | ||
69 | + | ||
70 | + DP_TBFLAG_A64(flags, SMEEXC_EL, sme_el); | ||
71 | + if (sme_el == 0) { | ||
72 | + /* Similarly, do not compute SVL if SME is disabled. */ | ||
73 | + DP_TBFLAG_A64(flags, SVL, sve_vqm1_for_el_sm(env, el, true)); | ||
74 | + } | ||
75 | if (FIELD_EX64(env->svcr, SVCR, SM)) { | ||
76 | DP_TBFLAG_A64(flags, PSTATE_SM, 1); | ||
77 | } | ||
78 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
79 | index XXXXXXX..XXXXXXX 100644 | ||
80 | --- a/target/arm/translate-a64.c | ||
81 | +++ b/target/arm/translate-a64.c | ||
82 | @@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, | ||
83 | dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL); | ||
84 | dc->sme_excp_el = EX_TBFLAG_A64(tb_flags, SMEEXC_EL); | ||
85 | dc->vl = (EX_TBFLAG_A64(tb_flags, VL) + 1) * 16; | ||
86 | + dc->svl = (EX_TBFLAG_A64(tb_flags, SVL) + 1) * 16; | ||
87 | dc->pauth_active = EX_TBFLAG_A64(tb_flags, PAUTH_ACTIVE); | ||
88 | dc->bt = EX_TBFLAG_A64(tb_flags, BT); | ||
89 | dc->btype = EX_TBFLAG_A64(tb_flags, BTYPE); | ||
90 | -- | ||
91 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | We will need these functions in translate-sme.c. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220620175235.60881-21-richard.henderson@linaro.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/translate-a64.h | 38 ++++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-sve.c | 36 ------------------------------------ | ||
12 | 2 files changed, 38 insertions(+), 36 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/translate-a64.h | ||
17 | +++ b/target/arm/translate-a64.h | ||
18 | @@ -XXX,XX +XXX,XX @@ static inline int vec_full_reg_size(DisasContext *s) | ||
19 | return s->vl; | ||
20 | } | ||
21 | |||
22 | +/* | ||
23 | + * Return the offset info CPUARMState of the predicate vector register Pn. | ||
24 | + * Note for this purpose, FFR is P16. | ||
25 | + */ | ||
26 | +static inline int pred_full_reg_offset(DisasContext *s, int regno) | ||
27 | +{ | ||
28 | + return offsetof(CPUARMState, vfp.pregs[regno]); | ||
29 | +} | ||
30 | + | ||
31 | +/* Return the byte size of the whole predicate register, VL / 64. */ | ||
32 | +static inline int pred_full_reg_size(DisasContext *s) | ||
33 | +{ | ||
34 | + return s->vl >> 3; | ||
35 | +} | ||
36 | + | ||
37 | +/* | ||
38 | + * Round up the size of a register to a size allowed by | ||
39 | + * the tcg vector infrastructure. Any operation which uses this | ||
40 | + * size may assume that the bits above pred_full_reg_size are zero, | ||
41 | + * and must leave them the same way. | ||
42 | + * | ||
43 | + * Note that this is not needed for the vector registers as they | ||
44 | + * are always properly sized for tcg vectors. | ||
45 | + */ | ||
46 | +static inline int size_for_gvec(int size) | ||
47 | +{ | ||
48 | + if (size <= 8) { | ||
49 | + return 8; | ||
50 | + } else { | ||
51 | + return QEMU_ALIGN_UP(size, 16); | ||
52 | + } | ||
53 | +} | ||
54 | + | ||
55 | +static inline int pred_gvec_reg_size(DisasContext *s) | ||
56 | +{ | ||
57 | + return size_for_gvec(pred_full_reg_size(s)); | ||
58 | +} | ||
59 | + | ||
60 | bool disas_sve(DisasContext *, uint32_t); | ||
61 | |||
62 | void gen_gvec_rax1(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs, | ||
63 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/translate-sve.c | ||
66 | +++ b/target/arm/translate-sve.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static inline int msz_dtype(DisasContext *s, int msz) | ||
68 | * Implement all of the translator functions referenced by the decoder. | ||
69 | */ | ||
70 | |||
71 | -/* Return the offset info CPUARMState of the predicate vector register Pn. | ||
72 | - * Note for this purpose, FFR is P16. | ||
73 | - */ | ||
74 | -static inline int pred_full_reg_offset(DisasContext *s, int regno) | ||
75 | -{ | ||
76 | - return offsetof(CPUARMState, vfp.pregs[regno]); | ||
77 | -} | ||
78 | - | ||
79 | -/* Return the byte size of the whole predicate register, VL / 64. */ | ||
80 | -static inline int pred_full_reg_size(DisasContext *s) | ||
81 | -{ | ||
82 | - return s->vl >> 3; | ||
83 | -} | ||
84 | - | ||
85 | -/* Round up the size of a register to a size allowed by | ||
86 | - * the tcg vector infrastructure. Any operation which uses this | ||
87 | - * size may assume that the bits above pred_full_reg_size are zero, | ||
88 | - * and must leave them the same way. | ||
89 | - * | ||
90 | - * Note that this is not needed for the vector registers as they | ||
91 | - * are always properly sized for tcg vectors. | ||
92 | - */ | ||
93 | -static int size_for_gvec(int size) | ||
94 | -{ | ||
95 | - if (size <= 8) { | ||
96 | - return 8; | ||
97 | - } else { | ||
98 | - return QEMU_ALIGN_UP(size, 16); | ||
99 | - } | ||
100 | -} | ||
101 | - | ||
102 | -static int pred_gvec_reg_size(DisasContext *s) | ||
103 | -{ | ||
104 | - return size_for_gvec(pred_full_reg_size(s)); | ||
105 | -} | ||
106 | - | ||
107 | /* Invoke an out-of-line helper on 2 Zregs. */ | ||
108 | static bool gen_gvec_ool_zz(DisasContext *s, gen_helper_gvec_2 *fn, | ||
109 | int rd, int rn, int data) | ||
110 | -- | ||
111 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Move the code from hw/arm/virt.c that is supposed | ||
4 | to handle v7 into the one function. | ||
5 | |||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reported-by: He Zhe <zhe.he@windriver.com> | ||
8 | Message-id: 20220619001541.131672-2-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/virt.c | 10 +--------- | ||
13 | target/arm/ptw.c | 24 ++++++++++++++++-------- | ||
14 | 2 files changed, 17 insertions(+), 17 deletions(-) | ||
15 | |||
16 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/arm/virt.c | ||
19 | +++ b/hw/arm/virt.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
21 | cpuobj = object_new(possible_cpus->cpus[0].type); | ||
22 | armcpu = ARM_CPU(cpuobj); | ||
23 | |||
24 | - if (object_property_get_bool(cpuobj, "aarch64", NULL)) { | ||
25 | - pa_bits = arm_pamax(armcpu); | ||
26 | - } else if (arm_feature(&armcpu->env, ARM_FEATURE_LPAE)) { | ||
27 | - /* v7 with LPAE */ | ||
28 | - pa_bits = 40; | ||
29 | - } else { | ||
30 | - /* Anything else */ | ||
31 | - pa_bits = 32; | ||
32 | - } | ||
33 | + pa_bits = arm_pamax(armcpu); | ||
34 | |||
35 | object_unref(cpuobj); | ||
36 | |||
37 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/ptw.c | ||
40 | +++ b/target/arm/ptw.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static const uint8_t pamax_map[] = { | ||
42 | /* The cpu-specific constant value of PAMax; also used by hw/arm/virt. */ | ||
43 | unsigned int arm_pamax(ARMCPU *cpu) | ||
44 | { | ||
45 | - unsigned int parange = | ||
46 | - FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); | ||
47 | + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { | ||
48 | + unsigned int parange = | ||
49 | + FIELD_EX64(cpu->isar.id_aa64mmfr0, ID_AA64MMFR0, PARANGE); | ||
50 | |||
51 | - /* | ||
52 | - * id_aa64mmfr0 is a read-only register so values outside of the | ||
53 | - * supported mappings can be considered an implementation error. | ||
54 | - */ | ||
55 | - assert(parange < ARRAY_SIZE(pamax_map)); | ||
56 | - return pamax_map[parange]; | ||
57 | + /* | ||
58 | + * id_aa64mmfr0 is a read-only register so values outside of the | ||
59 | + * supported mappings can be considered an implementation error. | ||
60 | + */ | ||
61 | + assert(parange < ARRAY_SIZE(pamax_map)); | ||
62 | + return pamax_map[parange]; | ||
63 | + } | ||
64 | + if (arm_feature(&cpu->env, ARM_FEATURE_LPAE)) { | ||
65 | + /* v7 with LPAE */ | ||
66 | + return 40; | ||
67 | + } | ||
68 | + /* Anything else */ | ||
69 | + return 32; | ||
70 | } | ||
71 | |||
72 | /* | ||
73 | -- | ||
74 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | In machvirt_init we create a cpu but do not fully initialize it. | ||
4 | Thus the propagation of V7VE to LPAE has not been done, and we | ||
5 | compute the wrong value for some v7 cpus, e.g. cortex-a15. | ||
6 | |||
7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1078 | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Reported-by: He Zhe <zhe.he@windriver.com> | ||
10 | Message-id: 20220619001541.131672-3-richard.henderson@linaro.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/ptw.c | 8 +++++++- | ||
15 | 1 file changed, 7 insertions(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/ptw.c | ||
20 | +++ b/target/arm/ptw.c | ||
21 | @@ -XXX,XX +XXX,XX @@ unsigned int arm_pamax(ARMCPU *cpu) | ||
22 | assert(parange < ARRAY_SIZE(pamax_map)); | ||
23 | return pamax_map[parange]; | ||
24 | } | ||
25 | - if (arm_feature(&cpu->env, ARM_FEATURE_LPAE)) { | ||
26 | + | ||
27 | + /* | ||
28 | + * In machvirt_init, we call arm_pamax on a cpu that is not fully | ||
29 | + * initialized, so we can't rely on the propagation done in realize. | ||
30 | + */ | ||
31 | + if (arm_feature(&cpu->env, ARM_FEATURE_LPAE) || | ||
32 | + arm_feature(&cpu->env, ARM_FEATURE_V7VE)) { | ||
33 | /* v7 with LPAE */ | ||
34 | return 40; | ||
35 | } | ||
36 | -- | ||
37 | 2.25.1 | diff view generated by jsdifflib |