1 | target-arm queue for softfreeze: | 1 | The following changes since commit 5a67d7735d4162630769ef495cf813244fc850df: |
---|---|---|---|
2 | This has all the big stuff I want to get in for softfreeze; | ||
3 | there may be one or two smaller patches I pick up later in | ||
4 | the week. | ||
5 | 2 | ||
6 | thanks | 3 | Merge remote-tracking branch 'remotes/berrange-gitlab/tags/tls-deps-pull-request' into staging (2021-07-02 08:22:39 +0100) |
7 | -- PMM | ||
8 | |||
9 | The following changes since commit 0984a157c1c053394adbf64ed7de97f1aebe6a2d: | ||
10 | |||
11 | Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging (2019-03-05 09:33:20 +0000) | ||
12 | 4 | ||
13 | are available in the Git repository at: | 5 | are available in the Git repository at: |
14 | 6 | ||
15 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190305 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210702 |
16 | 8 | ||
17 | for you to fetch changes up to 566528f823d1a2e9eb2d7b2ed839547cb31bfc34: | 9 | for you to fetch changes up to 04ea4d3cfd0a21b248ece8eb7a9436a3d9898dd8: |
18 | 10 | ||
19 | hw/arm/stellaris: Implement watchdog timer (2019-03-05 15:55:09 +0000) | 11 | target/arm: Implement MVE shifts by register (2021-07-02 11:48:38 +0100) |
20 | 12 | ||
21 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
22 | target-arm queue: | 14 | target-arm queue: |
23 | * Fix PC test for LDM (exception return) | 15 | * more MVE instructions |
24 | * Implement ARMv8.0-SB | 16 | * hw/gpio/gpio_pwr: use shutdown function for reboot |
25 | * Implement ARMv8.0-PredInv | 17 | * target/arm: Check NaN mode before silencing NaN |
26 | * Implement ARMv8.4-CondM | 18 | * tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine |
27 | * Implement ARMv8.5-CondM | 19 | * hw/arm: Add basic power management to raspi. |
28 | * Implement ARMv8.5-FRINT | 20 | * docs/system/arm: Add quanta-gbs-bmc, quanta-q7l1-bmc |
29 | * hw/arm/stellaris: Implement watchdog timer | ||
30 | * virt: support more than 255GB of RAM | ||
31 | 21 | ||
32 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
33 | Eric Auger (9): | 23 | Joe Komlodi (1): |
34 | hw/arm/virt: Rename highmem IO regions | 24 | target/arm: Check NaN mode before silencing NaN |
35 | hw/arm/virt: Split the memory map description | ||
36 | hw/boards: Add a MachineState parameter to kvm_type callback | ||
37 | kvm: add kvm_arm_get_max_vm_ipa_size | ||
38 | vl: Set machine ram_size, maxram_size and ram_slots earlier | ||
39 | hw/arm/virt: Dynamic memory map depending on RAM requirements | ||
40 | hw/arm/virt: Implement kvm_type function for 4.0 machine | ||
41 | hw/arm/virt: Check the VCPU PA range in TCG mode | ||
42 | hw/arm/virt: Bump the 255GB initial RAM limit | ||
43 | 25 | ||
44 | Michel Heily (1): | 26 | Maxim Uvarov (1): |
45 | hw/arm/stellaris: Implement watchdog timer | 27 | hw/gpio/gpio_pwr: use shutdown function for reboot |
46 | 28 | ||
47 | Richard Henderson (11): | 29 | Nolan Leake (1): |
48 | target/arm: Fix PC test for LDM (exception return) | 30 | hw/arm: Add basic power management to raspi. |
49 | target/arm: Split out arm_sctlr | ||
50 | target/arm: Implement ARMv8.0-SB | ||
51 | target/arm: Implement ARMv8.0-PredInv | ||
52 | target/arm: Split helper_msr_i_pstate into 3 | ||
53 | target/arm: Add set/clear_pstate_bits, share gen_ss_advance | ||
54 | target/arm: Rearrange disas_data_proc_reg | ||
55 | target/arm: Implement ARMv8.4-CondM | ||
56 | target/arm: Implement ARMv8.5-CondM | ||
57 | target/arm: Restructure handle_fp_1src_{single, double} | ||
58 | target/arm: Implement ARMv8.5-FRINT | ||
59 | 31 | ||
60 | Shameer Kolothum (1): | 32 | Patrick Venture (2): |
61 | hw/arm/boot: introduce fdt_add_memory_node helper | 33 | docs/system/arm: Add quanta-q7l1-bmc reference |
34 | docs/system/arm: Add quanta-gbs-bmc reference | ||
62 | 35 | ||
63 | include/hw/arm/virt.h | 16 +- | 36 | Peter Maydell (18): |
64 | include/hw/boards.h | 5 +- | 37 | target/arm: Fix MVE widening/narrowing VLDR/VSTR offset calculation |
65 | include/hw/watchdog/cmsdk-apb-watchdog.h | 8 + | 38 | target/arm: Fix bugs in MVE VRMLALDAVH, VRMLSLDAVH |
66 | target/arm/cpu.h | 64 ++++- | 39 | target/arm: Make asimd_imm_const() public |
67 | target/arm/helper-a64.h | 3 + | 40 | target/arm: Use asimd_imm_const for A64 decode |
68 | target/arm/helper.h | 8 +- | 41 | target/arm: Use dup_const() instead of bitfield_replicate() |
69 | target/arm/internals.h | 15 + | 42 | target/arm: Implement MVE logical immediate insns |
70 | target/arm/kvm_arm.h | 13 + | 43 | target/arm: Implement MVE vector shift left by immediate insns |
71 | target/arm/translate.h | 34 +++ | 44 | target/arm: Implement MVE vector shift right by immediate insns |
72 | accel/kvm/kvm-all.c | 2 +- | 45 | target/arm: Implement MVE VSHLL |
73 | hw/arm/boot.c | 54 ++-- | 46 | target/arm: Implement MVE VSRI, VSLI |
74 | hw/arm/stellaris.c | 22 +- | 47 | target/arm: Implement MVE VSHRN, VRSHRN |
75 | hw/arm/virt-acpi-build.c | 10 +- | 48 | target/arm: Implement MVE saturating narrowing shifts |
76 | hw/arm/virt.c | 196 ++++++++++--- | 49 | target/arm: Implement MVE VSHLC |
77 | hw/ppc/mac_newworld.c | 3 +- | 50 | target/arm: Implement MVE VADDLV |
78 | hw/ppc/mac_oldworld.c | 2 +- | 51 | target/arm: Implement MVE long shifts by immediate |
79 | hw/ppc/spapr.c | 2 +- | 52 | target/arm: Implement MVE long shifts by register |
80 | hw/watchdog/cmsdk-apb-watchdog.c | 74 ++++- | 53 | target/arm: Implement MVE shifts by immediate |
81 | linux-user/elfload.c | 2 + | 54 | target/arm: Implement MVE shifts by register |
82 | target/arm/cpu.c | 2 + | ||
83 | target/arm/cpu64.c | 6 + | ||
84 | target/arm/helper-a64.c | 30 ++ | ||
85 | target/arm/helper.c | 63 +++- | ||
86 | target/arm/kvm.c | 10 + | ||
87 | target/arm/op_helper.c | 47 --- | ||
88 | target/arm/translate-a64.c | 478 +++++++++++++++++++++++-------- | ||
89 | target/arm/translate.c | 35 ++- | ||
90 | target/arm/vfp_helper.c | 96 +++++++ | ||
91 | vl.c | 6 +- | ||
92 | 29 files changed, 1032 insertions(+), 274 deletions(-) | ||
93 | 55 | ||
56 | Philippe Mathieu-Daudé (1): | ||
57 | tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine | ||
58 | |||
59 | docs/system/arm/aspeed.rst | 1 + | ||
60 | docs/system/arm/nuvoton.rst | 5 +- | ||
61 | include/hw/arm/bcm2835_peripherals.h | 3 +- | ||
62 | include/hw/misc/bcm2835_powermgt.h | 29 ++ | ||
63 | target/arm/helper-mve.h | 108 +++++++ | ||
64 | target/arm/translate.h | 41 +++ | ||
65 | target/arm/mve.decode | 177 ++++++++++- | ||
66 | target/arm/t32.decode | 71 ++++- | ||
67 | hw/arm/bcm2835_peripherals.c | 13 +- | ||
68 | hw/gpio/gpio_pwr.c | 2 +- | ||
69 | hw/misc/bcm2835_powermgt.c | 160 ++++++++++ | ||
70 | target/arm/helper-a64.c | 12 +- | ||
71 | target/arm/mve_helper.c | 524 +++++++++++++++++++++++++++++++-- | ||
72 | target/arm/translate-a64.c | 86 +----- | ||
73 | target/arm/translate-mve.c | 261 +++++++++++++++- | ||
74 | target/arm/translate-neon.c | 81 ----- | ||
75 | target/arm/translate.c | 327 +++++++++++++++++++- | ||
76 | target/arm/vfp_helper.c | 24 +- | ||
77 | hw/misc/meson.build | 1 + | ||
78 | tests/acceptance/boot_linux_console.py | 43 +++ | ||
79 | 20 files changed, 1760 insertions(+), 209 deletions(-) | ||
80 | create mode 100644 include/hw/misc/bcm2835_powermgt.h | ||
81 | create mode 100644 hw/misc/bcm2835_powermgt.c | ||
82 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Patrick Venture <venture@google.com> |
---|---|---|---|
2 | 2 | ||
3 | This will allow sharing code that adjusts rmode beyond | 3 | Adds a line-item reference to the supported quanta-q71l-bmc aspeed |
4 | the existing users. | 4 | entry. |
5 | 5 | ||
6 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 6 | Signed-off-by: Patrick Venture <venture@google.com> |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
8 | Message-id: 20190301200501.16533-10-richard.henderson@linaro.org | 8 | Message-id: 20210615192848.1065297-2-venture@google.com |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | target/arm/translate-a64.c | 90 +++++++++++++++++++++----------------- | 11 | docs/system/arm/aspeed.rst | 1 + |
13 | 1 file changed, 49 insertions(+), 41 deletions(-) | 12 | 1 file changed, 1 insertion(+) |
14 | 13 | ||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 16 | --- a/docs/system/arm/aspeed.rst |
18 | +++ b/target/arm/translate-a64.c | 17 | +++ b/docs/system/arm/aspeed.rst |
19 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) | 18 | @@ -XXX,XX +XXX,XX @@ etc. |
20 | /* Floating-point data-processing (1 source) - single precision */ | 19 | AST2400 SoC based machines : |
21 | static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn) | 20 | |
22 | { | 21 | - ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC |
23 | + void (*gen_fpst)(TCGv_i32, TCGv_i32, TCGv_ptr); | 22 | +- ``quanta-q71l-bmc`` OpenBMC Quanta BMC |
24 | + TCGv_i32 tcg_op, tcg_res; | 23 | |
25 | TCGv_ptr fpst; | 24 | AST2500 SoC based machines : |
26 | - TCGv_i32 tcg_op; | 25 | |
27 | - TCGv_i32 tcg_res; | ||
28 | + int rmode = -1; | ||
29 | |||
30 | - fpst = get_fpstatus_ptr(false); | ||
31 | tcg_op = read_fp_sreg(s, rn); | ||
32 | tcg_res = tcg_temp_new_i32(); | ||
33 | |||
34 | switch (opcode) { | ||
35 | case 0x0: /* FMOV */ | ||
36 | tcg_gen_mov_i32(tcg_res, tcg_op); | ||
37 | - break; | ||
38 | + goto done; | ||
39 | case 0x1: /* FABS */ | ||
40 | gen_helper_vfp_abss(tcg_res, tcg_op); | ||
41 | - break; | ||
42 | + goto done; | ||
43 | case 0x2: /* FNEG */ | ||
44 | gen_helper_vfp_negs(tcg_res, tcg_op); | ||
45 | - break; | ||
46 | + goto done; | ||
47 | case 0x3: /* FSQRT */ | ||
48 | gen_helper_vfp_sqrts(tcg_res, tcg_op, cpu_env); | ||
49 | - break; | ||
50 | + goto done; | ||
51 | case 0x8: /* FRINTN */ | ||
52 | case 0x9: /* FRINTP */ | ||
53 | case 0xa: /* FRINTM */ | ||
54 | case 0xb: /* FRINTZ */ | ||
55 | case 0xc: /* FRINTA */ | ||
56 | - { | ||
57 | - TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7)); | ||
58 | - | ||
59 | - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
60 | - gen_helper_rints(tcg_res, tcg_op, fpst); | ||
61 | - | ||
62 | - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
63 | - tcg_temp_free_i32(tcg_rmode); | ||
64 | + rmode = arm_rmode_to_sf(opcode & 7); | ||
65 | + gen_fpst = gen_helper_rints; | ||
66 | break; | ||
67 | - } | ||
68 | case 0xe: /* FRINTX */ | ||
69 | - gen_helper_rints_exact(tcg_res, tcg_op, fpst); | ||
70 | + gen_fpst = gen_helper_rints_exact; | ||
71 | break; | ||
72 | case 0xf: /* FRINTI */ | ||
73 | - gen_helper_rints(tcg_res, tcg_op, fpst); | ||
74 | + gen_fpst = gen_helper_rints; | ||
75 | break; | ||
76 | default: | ||
77 | - abort(); | ||
78 | + g_assert_not_reached(); | ||
79 | } | ||
80 | |||
81 | - write_fp_sreg(s, rd, tcg_res); | ||
82 | - | ||
83 | + fpst = get_fpstatus_ptr(false); | ||
84 | + if (rmode >= 0) { | ||
85 | + TCGv_i32 tcg_rmode = tcg_const_i32(rmode); | ||
86 | + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
87 | + gen_fpst(tcg_res, tcg_op, fpst); | ||
88 | + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
89 | + tcg_temp_free_i32(tcg_rmode); | ||
90 | + } else { | ||
91 | + gen_fpst(tcg_res, tcg_op, fpst); | ||
92 | + } | ||
93 | tcg_temp_free_ptr(fpst); | ||
94 | + | ||
95 | + done: | ||
96 | + write_fp_sreg(s, rd, tcg_res); | ||
97 | tcg_temp_free_i32(tcg_op); | ||
98 | tcg_temp_free_i32(tcg_res); | ||
99 | } | ||
100 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn) | ||
101 | /* Floating-point data-processing (1 source) - double precision */ | ||
102 | static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn) | ||
103 | { | ||
104 | + void (*gen_fpst)(TCGv_i64, TCGv_i64, TCGv_ptr); | ||
105 | + TCGv_i64 tcg_op, tcg_res; | ||
106 | TCGv_ptr fpst; | ||
107 | - TCGv_i64 tcg_op; | ||
108 | - TCGv_i64 tcg_res; | ||
109 | + int rmode = -1; | ||
110 | |||
111 | switch (opcode) { | ||
112 | case 0x0: /* FMOV */ | ||
113 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn) | ||
114 | return; | ||
115 | } | ||
116 | |||
117 | - fpst = get_fpstatus_ptr(false); | ||
118 | tcg_op = read_fp_dreg(s, rn); | ||
119 | tcg_res = tcg_temp_new_i64(); | ||
120 | |||
121 | switch (opcode) { | ||
122 | case 0x1: /* FABS */ | ||
123 | gen_helper_vfp_absd(tcg_res, tcg_op); | ||
124 | - break; | ||
125 | + goto done; | ||
126 | case 0x2: /* FNEG */ | ||
127 | gen_helper_vfp_negd(tcg_res, tcg_op); | ||
128 | - break; | ||
129 | + goto done; | ||
130 | case 0x3: /* FSQRT */ | ||
131 | gen_helper_vfp_sqrtd(tcg_res, tcg_op, cpu_env); | ||
132 | - break; | ||
133 | + goto done; | ||
134 | case 0x8: /* FRINTN */ | ||
135 | case 0x9: /* FRINTP */ | ||
136 | case 0xa: /* FRINTM */ | ||
137 | case 0xb: /* FRINTZ */ | ||
138 | case 0xc: /* FRINTA */ | ||
139 | - { | ||
140 | - TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7)); | ||
141 | - | ||
142 | - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
143 | - gen_helper_rintd(tcg_res, tcg_op, fpst); | ||
144 | - | ||
145 | - gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
146 | - tcg_temp_free_i32(tcg_rmode); | ||
147 | + rmode = arm_rmode_to_sf(opcode & 7); | ||
148 | + gen_fpst = gen_helper_rintd; | ||
149 | break; | ||
150 | - } | ||
151 | case 0xe: /* FRINTX */ | ||
152 | - gen_helper_rintd_exact(tcg_res, tcg_op, fpst); | ||
153 | + gen_fpst = gen_helper_rintd_exact; | ||
154 | break; | ||
155 | case 0xf: /* FRINTI */ | ||
156 | - gen_helper_rintd(tcg_res, tcg_op, fpst); | ||
157 | + gen_fpst = gen_helper_rintd; | ||
158 | break; | ||
159 | default: | ||
160 | - abort(); | ||
161 | + g_assert_not_reached(); | ||
162 | } | ||
163 | |||
164 | - write_fp_dreg(s, rd, tcg_res); | ||
165 | - | ||
166 | + fpst = get_fpstatus_ptr(false); | ||
167 | + if (rmode >= 0) { | ||
168 | + TCGv_i32 tcg_rmode = tcg_const_i32(rmode); | ||
169 | + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
170 | + gen_fpst(tcg_res, tcg_op, fpst); | ||
171 | + gen_helper_set_rmode(tcg_rmode, tcg_rmode, fpst); | ||
172 | + tcg_temp_free_i32(tcg_rmode); | ||
173 | + } else { | ||
174 | + gen_fpst(tcg_res, tcg_op, fpst); | ||
175 | + } | ||
176 | tcg_temp_free_ptr(fpst); | ||
177 | + | ||
178 | + done: | ||
179 | + write_fp_dreg(s, rd, tcg_res); | ||
180 | tcg_temp_free_i64(tcg_op); | ||
181 | tcg_temp_free_i64(tcg_res); | ||
182 | } | ||
183 | -- | 26 | -- |
184 | 2.20.1 | 27 | 2.20.1 |
185 | 28 | ||
186 | 29 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Patrick Venture <venture@google.com> |
---|---|---|---|
2 | 2 | ||
3 | The machine RAM attributes will need to be analyzed during the | 3 | Add line item reference to quanta-gbs-bmc machine. |
4 | configure_accelerator() process. especially kvm_type() arm64 | ||
5 | machine callback will use them to know how many IPA/GPA bits are | ||
6 | needed to model the whole RAM range. So let's assign those machine | ||
7 | state fields before calling configure_accelerator. | ||
8 | 4 | ||
9 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 5 | Signed-off-by: Patrick Venture <venture@google.com> |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
11 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | 7 | Message-id: 20210615192848.1065297-3-venture@google.com |
12 | Message-id: 20190304101339.25970-7-eric.auger@redhat.com | 8 | [PMM: fixed underline Sphinx warning] |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 10 | --- |
15 | vl.c | 6 +++--- | 11 | docs/system/arm/nuvoton.rst | 5 +++-- |
16 | 1 file changed, 3 insertions(+), 3 deletions(-) | 12 | 1 file changed, 3 insertions(+), 2 deletions(-) |
17 | 13 | ||
18 | diff --git a/vl.c b/vl.c | 14 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/vl.c | 16 | --- a/docs/system/arm/nuvoton.rst |
21 | +++ b/vl.c | 17 | +++ b/docs/system/arm/nuvoton.rst |
22 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp) | 18 | @@ -XXX,XX +XXX,XX @@ |
23 | machine_opts = qemu_get_machine_opts(); | 19 | -Nuvoton iBMC boards (``npcm750-evb``, ``quanta-gsj``) |
24 | qemu_opt_foreach(machine_opts, machine_set_property, current_machine, | 20 | -===================================================== |
25 | &error_fatal); | 21 | +Nuvoton iBMC boards (``*-bmc``, ``npcm750-evb``, ``quanta-gsj``) |
26 | + current_machine->ram_size = ram_size; | 22 | +================================================================ |
27 | + current_machine->maxram_size = maxram_size; | 23 | |
28 | + current_machine->ram_slots = ram_slots; | 24 | The `Nuvoton iBMC`_ chips (NPCM7xx) are a family of ARM-based SoCs that are |
29 | 25 | designed to be used as Baseboard Management Controllers (BMCs) in various | |
30 | configure_accelerator(current_machine, argv[0]); | 26 | @@ -XXX,XX +XXX,XX @@ segment. The following machines are based on this chip : |
31 | 27 | The NPCM730 SoC has two Cortex-A9 cores and is targeted for Data Center and | |
32 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv, char **envp) | 28 | Hyperscale applications. The following machines are based on this chip : |
33 | replay_checkpoint(CHECKPOINT_INIT); | 29 | |
34 | qdev_machine_init(); | 30 | +- ``quanta-gbs-bmc`` Quanta GBS server BMC |
35 | 31 | - ``quanta-gsj`` Quanta GSJ server BMC | |
36 | - current_machine->ram_size = ram_size; | 32 | |
37 | - current_machine->maxram_size = maxram_size; | 33 | There are also two more SoCs, NPCM710 and NPCM705, which are single-core |
38 | - current_machine->ram_slots = ram_slots; | ||
39 | current_machine->boot_order = boot_order; | ||
40 | |||
41 | /* parse features once if machine provides default cpu_type */ | ||
42 | -- | 34 | -- |
43 | 2.20.1 | 35 | 2.20.1 |
44 | 36 | ||
45 | 37 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Nolan Leake <nolan@sigbus.net> |
---|---|---|---|
2 | 2 | ||
3 | Minimize the number of places that will need updating when | 3 | This is just enough to make reboot and poweroff work. Works for |
4 | the virtual host extensions are added. | 4 | linux, u-boot, and the arm trusted firmware. Not tested, but should |
5 | 5 | work for plan9, and bare-metal/hobby OSes, since they seem to generally | |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | do what linux does for reset. |
7 | Message-id: 20190301200501.16533-2-richard.henderson@linaro.org | 7 | |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | The watchdog timer functionality is not yet implemented. |
9 | |||
10 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/64 | ||
11 | Signed-off-by: Nolan Leake <nolan@sigbus.net> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Message-id: 20210625210209.1870217-1-nolan@sigbus.net | ||
15 | [PMM: tweaked commit title; fixed region size to 0x200; | ||
16 | moved header file to include/] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 18 | --- |
11 | target/arm/cpu.h | 26 ++++++++++++++++---------- | 19 | include/hw/arm/bcm2835_peripherals.h | 3 +- |
12 | target/arm/helper.c | 8 ++------ | 20 | include/hw/misc/bcm2835_powermgt.h | 29 +++++ |
13 | 2 files changed, 18 insertions(+), 16 deletions(-) | 21 | hw/arm/bcm2835_peripherals.c | 13 ++- |
14 | 22 | hw/misc/bcm2835_powermgt.c | 160 +++++++++++++++++++++++++++ | |
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 23 | hw/misc/meson.build | 1 + |
24 | 5 files changed, 204 insertions(+), 2 deletions(-) | ||
25 | create mode 100644 include/hw/misc/bcm2835_powermgt.h | ||
26 | create mode 100644 hw/misc/bcm2835_powermgt.c | ||
27 | |||
28 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/cpu.h | 30 | --- a/include/hw/arm/bcm2835_peripherals.h |
18 | +++ b/target/arm/cpu.h | 31 | +++ b/include/hw/arm/bcm2835_peripherals.h |
19 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_sctlr_b(CPUARMState *env) | 32 | @@ -XXX,XX +XXX,XX @@ |
20 | (env->cp15.sctlr_el[1] & SCTLR_B) != 0; | 33 | #include "hw/misc/bcm2835_mphi.h" |
34 | #include "hw/misc/bcm2835_thermal.h" | ||
35 | #include "hw/misc/bcm2835_cprman.h" | ||
36 | +#include "hw/misc/bcm2835_powermgt.h" | ||
37 | #include "hw/sd/sdhci.h" | ||
38 | #include "hw/sd/bcm2835_sdhost.h" | ||
39 | #include "hw/gpio/bcm2835_gpio.h" | ||
40 | @@ -XXX,XX +XXX,XX @@ struct BCM2835PeripheralState { | ||
41 | BCM2835MphiState mphi; | ||
42 | UnimplementedDeviceState txp; | ||
43 | UnimplementedDeviceState armtmr; | ||
44 | - UnimplementedDeviceState powermgt; | ||
45 | + BCM2835PowerMgtState powermgt; | ||
46 | BCM2835CprmanState cprman; | ||
47 | PL011State uart0; | ||
48 | BCM2835AuxState aux; | ||
49 | diff --git a/include/hw/misc/bcm2835_powermgt.h b/include/hw/misc/bcm2835_powermgt.h | ||
50 | new file mode 100644 | ||
51 | index XXXXXXX..XXXXXXX | ||
52 | --- /dev/null | ||
53 | +++ b/include/hw/misc/bcm2835_powermgt.h | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | +/* | ||
56 | + * BCM2835 Power Management emulation | ||
57 | + * | ||
58 | + * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com> | ||
59 | + * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net> | ||
60 | + * | ||
61 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
62 | + * See the COPYING file in the top-level directory. | ||
63 | + */ | ||
64 | + | ||
65 | +#ifndef BCM2835_POWERMGT_H | ||
66 | +#define BCM2835_POWERMGT_H | ||
67 | + | ||
68 | +#include "hw/sysbus.h" | ||
69 | +#include "qom/object.h" | ||
70 | + | ||
71 | +#define TYPE_BCM2835_POWERMGT "bcm2835-powermgt" | ||
72 | +OBJECT_DECLARE_SIMPLE_TYPE(BCM2835PowerMgtState, BCM2835_POWERMGT) | ||
73 | + | ||
74 | +struct BCM2835PowerMgtState { | ||
75 | + SysBusDevice busdev; | ||
76 | + MemoryRegion iomem; | ||
77 | + | ||
78 | + uint32_t rstc; | ||
79 | + uint32_t rsts; | ||
80 | + uint32_t wdog; | ||
81 | +}; | ||
82 | + | ||
83 | +#endif | ||
84 | diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/hw/arm/bcm2835_peripherals.c | ||
87 | +++ b/hw/arm/bcm2835_peripherals.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_init(Object *obj) | ||
89 | |||
90 | object_property_add_const_link(OBJECT(&s->dwc2), "dma-mr", | ||
91 | OBJECT(&s->gpu_bus_mr)); | ||
92 | + | ||
93 | + /* Power Management */ | ||
94 | + object_initialize_child(obj, "powermgt", &s->powermgt, | ||
95 | + TYPE_BCM2835_POWERMGT); | ||
21 | } | 96 | } |
22 | 97 | ||
23 | +static inline uint64_t arm_sctlr(CPUARMState *env, int el) | 98 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) |
24 | +{ | 99 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) |
25 | + if (el == 0) { | 100 | qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, |
26 | + /* FIXME: ARMv8.1-VHE S2 translation regime. */ | 101 | INTERRUPT_USB)); |
27 | + return env->cp15.sctlr_el[1]; | 102 | |
28 | + } else { | 103 | + /* Power Management */ |
29 | + return env->cp15.sctlr_el[el]; | 104 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->powermgt), errp)) { |
30 | + } | 105 | + return; |
31 | +} | 106 | + } |
32 | + | 107 | + |
33 | + | 108 | + memory_region_add_subregion(&s->peri_mr, PM_OFFSET, |
34 | /* Return true if the processor is in big-endian mode. */ | 109 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->powermgt), 0)); |
35 | static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) | 110 | + |
36 | { | 111 | create_unimp(s, &s->txp, "bcm2835-txp", TXP_OFFSET, 0x1000); |
37 | - int cur_el; | 112 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); |
38 | - | 113 | - create_unimp(s, &s->powermgt, "bcm2835-powermgt", PM_OFFSET, 0x114); |
39 | /* In 32bit endianness is determined by looking at CPSR's E bit */ | 114 | create_unimp(s, &s->i2s, "bcm2835-i2s", I2S_OFFSET, 0x100); |
40 | if (!is_a64(env)) { | 115 | create_unimp(s, &s->smi, "bcm2835-smi", SMI_OFFSET, 0x100); |
41 | return | 116 | create_unimp(s, &s->spi[0], "bcm2835-spi0", SPI0_OFFSET, 0x20); |
42 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) | 117 | diff --git a/hw/misc/bcm2835_powermgt.c b/hw/misc/bcm2835_powermgt.c |
43 | arm_sctlr_b(env) || | 118 | new file mode 100644 |
44 | #endif | 119 | index XXXXXXX..XXXXXXX |
45 | ((env->uncached_cpsr & CPSR_E) ? 1 : 0); | 120 | --- /dev/null |
46 | + } else { | 121 | +++ b/hw/misc/bcm2835_powermgt.c |
47 | + int cur_el = arm_current_el(env); | 122 | @@ -XXX,XX +XXX,XX @@ |
48 | + uint64_t sctlr = arm_sctlr(env, cur_el); | 123 | +/* |
49 | + | 124 | + * BCM2835 Power Management emulation |
50 | + return (sctlr & (cur_el ? SCTLR_EE : SCTLR_E0E)) != 0; | 125 | + * |
51 | } | 126 | + * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com> |
52 | - | 127 | + * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net> |
53 | - cur_el = arm_current_el(env); | 128 | + * |
54 | - | 129 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
55 | - if (cur_el == 0) { | 130 | + * See the COPYING file in the top-level directory. |
56 | - return (env->cp15.sctlr_el[1] & SCTLR_E0E) != 0; | 131 | + */ |
57 | - } | 132 | + |
58 | - | 133 | +#include "qemu/osdep.h" |
59 | - return (env->cp15.sctlr_el[cur_el] & SCTLR_EE) != 0; | 134 | +#include "qemu/log.h" |
60 | } | 135 | +#include "qemu/module.h" |
61 | 136 | +#include "hw/misc/bcm2835_powermgt.h" | |
62 | #include "exec/cpu-all.h" | 137 | +#include "migration/vmstate.h" |
63 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 138 | +#include "sysemu/runstate.h" |
139 | + | ||
140 | +#define PASSWORD 0x5a000000 | ||
141 | +#define PASSWORD_MASK 0xff000000 | ||
142 | + | ||
143 | +#define R_RSTC 0x1c | ||
144 | +#define V_RSTC_RESET 0x20 | ||
145 | +#define R_RSTS 0x20 | ||
146 | +#define V_RSTS_POWEROFF 0x555 /* Linux uses partition 63 to indicate halt. */ | ||
147 | +#define R_WDOG 0x24 | ||
148 | + | ||
149 | +static uint64_t bcm2835_powermgt_read(void *opaque, hwaddr offset, | ||
150 | + unsigned size) | ||
151 | +{ | ||
152 | + BCM2835PowerMgtState *s = (BCM2835PowerMgtState *)opaque; | ||
153 | + uint32_t res = 0; | ||
154 | + | ||
155 | + switch (offset) { | ||
156 | + case R_RSTC: | ||
157 | + res = s->rstc; | ||
158 | + break; | ||
159 | + case R_RSTS: | ||
160 | + res = s->rsts; | ||
161 | + break; | ||
162 | + case R_WDOG: | ||
163 | + res = s->wdog; | ||
164 | + break; | ||
165 | + | ||
166 | + default: | ||
167 | + qemu_log_mask(LOG_UNIMP, | ||
168 | + "bcm2835_powermgt_read: Unknown offset 0x%08"HWADDR_PRIx | ||
169 | + "\n", offset); | ||
170 | + res = 0; | ||
171 | + break; | ||
172 | + } | ||
173 | + | ||
174 | + return res; | ||
175 | +} | ||
176 | + | ||
177 | +static void bcm2835_powermgt_write(void *opaque, hwaddr offset, | ||
178 | + uint64_t value, unsigned size) | ||
179 | +{ | ||
180 | + BCM2835PowerMgtState *s = (BCM2835PowerMgtState *)opaque; | ||
181 | + | ||
182 | + if ((value & PASSWORD_MASK) != PASSWORD) { | ||
183 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
184 | + "bcm2835_powermgt_write: Bad password 0x%"PRIx64 | ||
185 | + " at offset 0x%08"HWADDR_PRIx"\n", | ||
186 | + value, offset); | ||
187 | + return; | ||
188 | + } | ||
189 | + | ||
190 | + value = value & ~PASSWORD_MASK; | ||
191 | + | ||
192 | + switch (offset) { | ||
193 | + case R_RSTC: | ||
194 | + s->rstc = value; | ||
195 | + if (value & V_RSTC_RESET) { | ||
196 | + if ((s->rsts & 0xfff) == V_RSTS_POWEROFF) { | ||
197 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); | ||
198 | + } else { | ||
199 | + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
200 | + } | ||
201 | + } | ||
202 | + break; | ||
203 | + case R_RSTS: | ||
204 | + qemu_log_mask(LOG_UNIMP, | ||
205 | + "bcm2835_powermgt_write: RSTS\n"); | ||
206 | + s->rsts = value; | ||
207 | + break; | ||
208 | + case R_WDOG: | ||
209 | + qemu_log_mask(LOG_UNIMP, | ||
210 | + "bcm2835_powermgt_write: WDOG\n"); | ||
211 | + s->wdog = value; | ||
212 | + break; | ||
213 | + | ||
214 | + default: | ||
215 | + qemu_log_mask(LOG_UNIMP, | ||
216 | + "bcm2835_powermgt_write: Unknown offset 0x%08"HWADDR_PRIx | ||
217 | + "\n", offset); | ||
218 | + break; | ||
219 | + } | ||
220 | +} | ||
221 | + | ||
222 | +static const MemoryRegionOps bcm2835_powermgt_ops = { | ||
223 | + .read = bcm2835_powermgt_read, | ||
224 | + .write = bcm2835_powermgt_write, | ||
225 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
226 | + .impl.min_access_size = 4, | ||
227 | + .impl.max_access_size = 4, | ||
228 | +}; | ||
229 | + | ||
230 | +static const VMStateDescription vmstate_bcm2835_powermgt = { | ||
231 | + .name = TYPE_BCM2835_POWERMGT, | ||
232 | + .version_id = 1, | ||
233 | + .minimum_version_id = 1, | ||
234 | + .fields = (VMStateField[]) { | ||
235 | + VMSTATE_UINT32(rstc, BCM2835PowerMgtState), | ||
236 | + VMSTATE_UINT32(rsts, BCM2835PowerMgtState), | ||
237 | + VMSTATE_UINT32(wdog, BCM2835PowerMgtState), | ||
238 | + VMSTATE_END_OF_LIST() | ||
239 | + } | ||
240 | +}; | ||
241 | + | ||
242 | +static void bcm2835_powermgt_init(Object *obj) | ||
243 | +{ | ||
244 | + BCM2835PowerMgtState *s = BCM2835_POWERMGT(obj); | ||
245 | + | ||
246 | + memory_region_init_io(&s->iomem, obj, &bcm2835_powermgt_ops, s, | ||
247 | + TYPE_BCM2835_POWERMGT, 0x200); | ||
248 | + sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem); | ||
249 | +} | ||
250 | + | ||
251 | +static void bcm2835_powermgt_reset(DeviceState *dev) | ||
252 | +{ | ||
253 | + BCM2835PowerMgtState *s = BCM2835_POWERMGT(dev); | ||
254 | + | ||
255 | + /* https://elinux.org/BCM2835_registers#PM */ | ||
256 | + s->rstc = 0x00000102; | ||
257 | + s->rsts = 0x00001000; | ||
258 | + s->wdog = 0x00000000; | ||
259 | +} | ||
260 | + | ||
261 | +static void bcm2835_powermgt_class_init(ObjectClass *klass, void *data) | ||
262 | +{ | ||
263 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
264 | + | ||
265 | + dc->reset = bcm2835_powermgt_reset; | ||
266 | + dc->vmsd = &vmstate_bcm2835_powermgt; | ||
267 | +} | ||
268 | + | ||
269 | +static TypeInfo bcm2835_powermgt_info = { | ||
270 | + .name = TYPE_BCM2835_POWERMGT, | ||
271 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
272 | + .instance_size = sizeof(BCM2835PowerMgtState), | ||
273 | + .class_init = bcm2835_powermgt_class_init, | ||
274 | + .instance_init = bcm2835_powermgt_init, | ||
275 | +}; | ||
276 | + | ||
277 | +static void bcm2835_powermgt_register_types(void) | ||
278 | +{ | ||
279 | + type_register_static(&bcm2835_powermgt_info); | ||
280 | +} | ||
281 | + | ||
282 | +type_init(bcm2835_powermgt_register_types) | ||
283 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
64 | index XXXXXXX..XXXXXXX 100644 | 284 | index XXXXXXX..XXXXXXX 100644 |
65 | --- a/target/arm/helper.c | 285 | --- a/hw/misc/meson.build |
66 | +++ b/target/arm/helper.c | 286 | +++ b/hw/misc/meson.build |
67 | @@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, | 287 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files( |
68 | flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); | 288 | 'bcm2835_rng.c', |
69 | } | 289 | 'bcm2835_thermal.c', |
70 | 290 | 'bcm2835_cprman.c', | |
71 | - if (current_el == 0) { | 291 | + 'bcm2835_powermgt.c', |
72 | - /* FIXME: ARMv8.1-VHE S2 translation regime. */ | 292 | )) |
73 | - sctlr = env->cp15.sctlr_el[1]; | 293 | softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) |
74 | - } else { | 294 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c', 'zynq-xadc.c')) |
75 | - sctlr = env->cp15.sctlr_el[current_el]; | ||
76 | - } | ||
77 | + sctlr = arm_sctlr(env, current_el); | ||
78 | + | ||
79 | if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
80 | /* | ||
81 | * In order to save space in flags, we record only whether | ||
82 | -- | 295 | -- |
83 | 2.20.1 | 296 | 2.20.1 |
84 | 297 | ||
85 | 298 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | In preparation for a split of the memory map into a static | 3 | Add a test booting and quickly shutdown a raspi2 machine, |
4 | part and a dynamic part floating after the RAM, let's rename the | 4 | to test the power management model: |
5 | regions located after the RAM | ||
6 | 5 | ||
7 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 6 | (1/1) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd: |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | console: [ 0.000000] Booting Linux on physical CPU 0xf00 |
9 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | 8 | console: [ 0.000000] Linux version 4.14.98-v7+ (dom@dom-XPS-13-9370) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611)) #1200 SMP Tue Feb 12 20:27:48 GMT 2019 |
10 | Message-id: 20190304101339.25970-3-eric.auger@redhat.com | 9 | console: [ 0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d |
10 | console: [ 0.000000] CPU: div instructions available: patching division code | ||
11 | console: [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache | ||
12 | console: [ 0.000000] OF: fdt: Machine model: Raspberry Pi 2 Model B | ||
13 | ... | ||
14 | console: Boot successful. | ||
15 | console: cat /proc/cpuinfo | ||
16 | console: / # cat /proc/cpuinfo | ||
17 | ... | ||
18 | console: processor : 3 | ||
19 | console: model name : ARMv7 Processor rev 5 (v7l) | ||
20 | console: BogoMIPS : 125.00 | ||
21 | console: Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm | ||
22 | console: CPU implementer : 0x41 | ||
23 | console: CPU architecture: 7 | ||
24 | console: CPU variant : 0x0 | ||
25 | console: CPU part : 0xc07 | ||
26 | console: CPU revision : 5 | ||
27 | console: Hardware : BCM2835 | ||
28 | console: Revision : 0000 | ||
29 | console: Serial : 0000000000000000 | ||
30 | console: cat /proc/iomem | ||
31 | console: / # cat /proc/iomem | ||
32 | console: 00000000-3bffffff : System RAM | ||
33 | console: 00008000-00afffff : Kernel code | ||
34 | console: 00c00000-00d468ef : Kernel data | ||
35 | console: 3f006000-3f006fff : dwc_otg | ||
36 | console: 3f007000-3f007eff : /soc/dma@7e007000 | ||
37 | console: 3f00b880-3f00b8bf : /soc/mailbox@7e00b880 | ||
38 | console: 3f100000-3f100027 : /soc/watchdog@7e100000 | ||
39 | console: 3f101000-3f102fff : /soc/cprman@7e101000 | ||
40 | console: 3f200000-3f2000b3 : /soc/gpio@7e200000 | ||
41 | PASS (24.59 s) | ||
42 | RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0 | ||
43 | JOB TIME : 25.02 s | ||
44 | |||
45 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
46 | Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> | ||
47 | Message-id: 20210531113837.1689775-1-f4bug@amsat.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 48 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 49 | --- |
13 | include/hw/arm/virt.h | 8 ++++---- | 50 | tests/acceptance/boot_linux_console.py | 43 ++++++++++++++++++++++++++ |
14 | hw/arm/virt-acpi-build.c | 10 ++++++---- | 51 | 1 file changed, 43 insertions(+) |
15 | hw/arm/virt.c | 33 ++++++++++++++++++--------------- | ||
16 | 3 files changed, 28 insertions(+), 23 deletions(-) | ||
17 | 52 | ||
18 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | 53 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py |
19 | index XXXXXXX..XXXXXXX 100644 | 54 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/arm/virt.h | 55 | --- a/tests/acceptance/boot_linux_console.py |
21 | +++ b/include/hw/arm/virt.h | 56 | +++ b/tests/acceptance/boot_linux_console.py |
22 | @@ -XXX,XX +XXX,XX @@ enum { | 57 | @@ -XXX,XX +XXX,XX @@ |
23 | VIRT_GIC_VCPU, | 58 | from avocado import skip |
24 | VIRT_GIC_ITS, | 59 | from avocado import skipUnless |
25 | VIRT_GIC_REDIST, | 60 | from avocado_qemu import Test |
26 | - VIRT_GIC_REDIST2, | 61 | +from avocado_qemu import exec_command |
27 | + VIRT_HIGH_GIC_REDIST2, | 62 | from avocado_qemu import exec_command_and_wait_for_pattern |
28 | VIRT_SMMU, | 63 | from avocado_qemu import interrupt_interactive_console_until_pattern |
29 | VIRT_UART, | 64 | from avocado_qemu import wait_for_console_pattern |
30 | VIRT_MMIO, | 65 | @@ -XXX,XX +XXX,XX @@ def test_arm_raspi2_uart0(self): |
31 | @@ -XXX,XX +XXX,XX @@ enum { | 66 | """ |
32 | VIRT_PCIE_MMIO, | 67 | self.do_test_arm_raspi2(0) |
33 | VIRT_PCIE_PIO, | 68 | |
34 | VIRT_PCIE_ECAM, | 69 | + def test_arm_raspi2_initrd(self): |
35 | - VIRT_PCIE_ECAM_HIGH, | 70 | + """ |
36 | + VIRT_HIGH_PCIE_ECAM, | 71 | + :avocado: tags=arch:arm |
37 | VIRT_PLATFORM_BUS, | 72 | + :avocado: tags=machine:raspi2 |
38 | - VIRT_PCIE_MMIO_HIGH, | 73 | + """ |
39 | + VIRT_HIGH_PCIE_MMIO, | 74 | + deb_url = ('http://archive.raspberrypi.org/debian/' |
40 | VIRT_GPIO, | 75 | + 'pool/main/r/raspberrypi-firmware/' |
41 | VIRT_SECURE_UART, | 76 | + 'raspberrypi-kernel_1.20190215-1_armhf.deb') |
42 | VIRT_SECURE_MEM, | 77 | + deb_hash = 'cd284220b32128c5084037553db3c482426f3972' |
43 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 78 | + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
44 | int psci_conduit; | 79 | + kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img') |
45 | } VirtMachineState; | 80 | + dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb') |
46 | 81 | + | |
47 | -#define VIRT_ECAM_ID(high) (high ? VIRT_PCIE_ECAM_HIGH : VIRT_PCIE_ECAM) | 82 | + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' |
48 | +#define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) | 83 | + '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' |
49 | 84 | + 'arm/rootfs-armv7a.cpio.gz') | |
50 | #define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") | 85 | + initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c' |
51 | #define VIRT_MACHINE(obj) \ | 86 | + initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) |
52 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | 87 | + initrd_path = os.path.join(self.workdir, 'rootfs.cpio') |
53 | index XXXXXXX..XXXXXXX 100644 | 88 | + archive.gzip_uncompress(initrd_path_gz, initrd_path) |
54 | --- a/hw/arm/virt-acpi-build.c | 89 | + |
55 | +++ b/hw/arm/virt-acpi-build.c | 90 | + self.vm.set_console() |
56 | @@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, | 91 | + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
57 | size_pio)); | 92 | + 'earlycon=pl011,0x3f201000 console=ttyAMA0 ' |
58 | 93 | + 'panic=-1 noreboot ' + | |
59 | if (use_highmem) { | 94 | + 'dwc_otg.fiq_fsm_enable=0') |
60 | - hwaddr base_mmio_high = memmap[VIRT_PCIE_MMIO_HIGH].base; | 95 | + self.vm.add_args('-kernel', kernel_path, |
61 | - hwaddr size_mmio_high = memmap[VIRT_PCIE_MMIO_HIGH].size; | 96 | + '-dtb', dtb_path, |
62 | + hwaddr base_mmio_high = memmap[VIRT_HIGH_PCIE_MMIO].base; | 97 | + '-initrd', initrd_path, |
63 | + hwaddr size_mmio_high = memmap[VIRT_HIGH_PCIE_MMIO].size; | 98 | + '-append', kernel_command_line, |
64 | 99 | + '-no-reboot') | |
65 | aml_append(rbuf, | 100 | + self.vm.launch() |
66 | aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED, | 101 | + self.wait_for_console_pattern('Boot successful.') |
67 | @@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 102 | + |
68 | gicr = acpi_data_push(table_data, sizeof(*gicr)); | 103 | + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', |
69 | gicr->type = ACPI_APIC_GENERIC_REDISTRIBUTOR; | 104 | + 'BCM2835') |
70 | gicr->length = sizeof(*gicr); | 105 | + exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', |
71 | - gicr->base_address = cpu_to_le64(memmap[VIRT_GIC_REDIST2].base); | 106 | + '/soc/cprman@7e101000') |
72 | - gicr->range_length = cpu_to_le32(memmap[VIRT_GIC_REDIST2].size); | 107 | + exec_command(self, 'halt') |
73 | + gicr->base_address = | 108 | + # Wait for VM to shut down gracefully |
74 | + cpu_to_le64(memmap[VIRT_HIGH_GIC_REDIST2].base); | 109 | + self.vm.wait() |
75 | + gicr->range_length = | 110 | + |
76 | + cpu_to_le32(memmap[VIRT_HIGH_GIC_REDIST2].size); | 111 | def test_arm_exynos4210_initrd(self): |
77 | } | 112 | """ |
78 | 113 | :avocado: tags=arch:arm | |
79 | if (its_class_name() && !vmc->no_its) { | ||
80 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/hw/arm/virt.c | ||
83 | +++ b/hw/arm/virt.c | ||
84 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry a15memmap[] = { | ||
85 | [VIRT_PCIE_ECAM] = { 0x3f000000, 0x01000000 }, | ||
86 | [VIRT_MEM] = { 0x40000000, RAMLIMIT_BYTES }, | ||
87 | /* Additional 64 MB redist region (can contain up to 512 redistributors) */ | ||
88 | - [VIRT_GIC_REDIST2] = { 0x4000000000ULL, 0x4000000 }, | ||
89 | - [VIRT_PCIE_ECAM_HIGH] = { 0x4010000000ULL, 0x10000000 }, | ||
90 | + [VIRT_HIGH_GIC_REDIST2] = { 0x4000000000ULL, 0x4000000 }, | ||
91 | + [VIRT_HIGH_PCIE_ECAM] = { 0x4010000000ULL, 0x10000000 }, | ||
92 | /* Second PCIe window, 512GB wide at the 512GB boundary */ | ||
93 | - [VIRT_PCIE_MMIO_HIGH] = { 0x8000000000ULL, 0x8000000000ULL }, | ||
94 | + [VIRT_HIGH_PCIE_MMIO] = { 0x8000000000ULL, 0x8000000000ULL }, | ||
95 | }; | ||
96 | |||
97 | static const int a15irqmap[] = { | ||
98 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_gic_node(VirtMachineState *vms) | ||
99 | 2, vms->memmap[VIRT_GIC_REDIST].size); | ||
100 | } else { | ||
101 | qemu_fdt_setprop_sized_cells(vms->fdt, nodename, "reg", | ||
102 | - 2, vms->memmap[VIRT_GIC_DIST].base, | ||
103 | - 2, vms->memmap[VIRT_GIC_DIST].size, | ||
104 | - 2, vms->memmap[VIRT_GIC_REDIST].base, | ||
105 | - 2, vms->memmap[VIRT_GIC_REDIST].size, | ||
106 | - 2, vms->memmap[VIRT_GIC_REDIST2].base, | ||
107 | - 2, vms->memmap[VIRT_GIC_REDIST2].size); | ||
108 | + 2, vms->memmap[VIRT_GIC_DIST].base, | ||
109 | + 2, vms->memmap[VIRT_GIC_DIST].size, | ||
110 | + 2, vms->memmap[VIRT_GIC_REDIST].base, | ||
111 | + 2, vms->memmap[VIRT_GIC_REDIST].size, | ||
112 | + 2, vms->memmap[VIRT_HIGH_GIC_REDIST2].base, | ||
113 | + 2, vms->memmap[VIRT_HIGH_GIC_REDIST2].size); | ||
114 | } | ||
115 | |||
116 | if (vms->virt) { | ||
117 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic) | ||
118 | |||
119 | if (nb_redist_regions == 2) { | ||
120 | uint32_t redist1_capacity = | ||
121 | - vms->memmap[VIRT_GIC_REDIST2].size / GICV3_REDIST_SIZE; | ||
122 | + vms->memmap[VIRT_HIGH_GIC_REDIST2].size / GICV3_REDIST_SIZE; | ||
123 | |||
124 | qdev_prop_set_uint32(gicdev, "redist-region-count[1]", | ||
125 | MIN(smp_cpus - redist0_count, redist1_capacity)); | ||
126 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic) | ||
127 | if (type == 3) { | ||
128 | sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_REDIST].base); | ||
129 | if (nb_redist_regions == 2) { | ||
130 | - sysbus_mmio_map(gicbusdev, 2, vms->memmap[VIRT_GIC_REDIST2].base); | ||
131 | + sysbus_mmio_map(gicbusdev, 2, | ||
132 | + vms->memmap[VIRT_HIGH_GIC_REDIST2].base); | ||
133 | } | ||
134 | } else { | ||
135 | sysbus_mmio_map(gicbusdev, 1, vms->memmap[VIRT_GIC_CPU].base); | ||
136 | @@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms, qemu_irq *pic) | ||
137 | { | ||
138 | hwaddr base_mmio = vms->memmap[VIRT_PCIE_MMIO].base; | ||
139 | hwaddr size_mmio = vms->memmap[VIRT_PCIE_MMIO].size; | ||
140 | - hwaddr base_mmio_high = vms->memmap[VIRT_PCIE_MMIO_HIGH].base; | ||
141 | - hwaddr size_mmio_high = vms->memmap[VIRT_PCIE_MMIO_HIGH].size; | ||
142 | + hwaddr base_mmio_high = vms->memmap[VIRT_HIGH_PCIE_MMIO].base; | ||
143 | + hwaddr size_mmio_high = vms->memmap[VIRT_HIGH_PCIE_MMIO].size; | ||
144 | hwaddr base_pio = vms->memmap[VIRT_PCIE_PIO].base; | ||
145 | hwaddr size_pio = vms->memmap[VIRT_PCIE_PIO].size; | ||
146 | hwaddr base_ecam, size_ecam; | ||
147 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
148 | * many redistributors we can fit into the memory map. | ||
149 | */ | ||
150 | if (vms->gic_version == 3) { | ||
151 | - virt_max_cpus = vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; | ||
152 | - virt_max_cpus += vms->memmap[VIRT_GIC_REDIST2].size / GICV3_REDIST_SIZE; | ||
153 | + virt_max_cpus = | ||
154 | + vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; | ||
155 | + virt_max_cpus += | ||
156 | + vms->memmap[VIRT_HIGH_GIC_REDIST2].size / GICV3_REDIST_SIZE; | ||
157 | } else { | ||
158 | virt_max_cpus = GIC_NCPU; | ||
159 | } | ||
160 | -- | 114 | -- |
161 | 2.20.1 | 115 | 2.20.1 |
162 | 116 | ||
163 | 117 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Joe Komlodi <joe.komlodi@xilinx.com> |
---|---|---|---|
2 | 2 | ||
3 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 3 | If the CPU is running in default NaN mode (FPCR.DN == 1) and we execute |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | FRSQRTE, FRECPE, or FRECPX with a signaling NaN, parts_silence_nan_frac() will |
5 | Message-id: 20190301200501.16533-11-richard.henderson@linaro.org | 5 | assert due to fpst->default_nan_mode being set. |
6 | |||
7 | To avoid this, we check to see what NaN mode we're running in before we call | ||
8 | floatxx_silence_nan(). | ||
9 | |||
10 | Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 1624662174-175828-2-git-send-email-joe.komlodi@xilinx.com | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 15 | --- |
9 | target/arm/cpu.h | 5 ++ | 16 | target/arm/helper-a64.c | 12 +++++++++--- |
10 | target/arm/helper.h | 5 ++ | 17 | target/arm/vfp_helper.c | 24 ++++++++++++++++++------ |
11 | target/arm/cpu64.c | 1 + | 18 | 2 files changed, 27 insertions(+), 9 deletions(-) |
12 | target/arm/translate-a64.c | 71 ++++++++++++++++++++++++++-- | ||
13 | target/arm/vfp_helper.c | 96 ++++++++++++++++++++++++++++++++++++++ | ||
14 | 5 files changed, 173 insertions(+), 5 deletions(-) | ||
15 | 19 | ||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 20 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c |
17 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 22 | --- a/target/arm/helper-a64.c |
19 | +++ b/target/arm/cpu.h | 23 | +++ b/target/arm/helper-a64.c |
20 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_predinv(const ARMISARegisters *id) | 24 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp) |
21 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SPECRES) != 0; | 25 | float16 nan = a; |
22 | } | 26 | if (float16_is_signaling_nan(a, fpst)) { |
23 | 27 | float_raise(float_flag_invalid, fpst); | |
24 | +static inline bool isar_feature_aa64_frint(const ARMISARegisters *id) | 28 | - nan = float16_silence_nan(a, fpst); |
25 | +{ | 29 | + if (!fpst->default_nan_mode) { |
26 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, FRINTTS) != 0; | 30 | + nan = float16_silence_nan(a, fpst); |
27 | +} | 31 | + } |
28 | + | ||
29 | static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) | ||
30 | { | ||
31 | /* We always set the AdvSIMD and FP fields identically wrt FP16. */ | ||
32 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/target/arm/helper.h | ||
35 | +++ b/target/arm/helper.h | ||
36 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_fmlal_idx_a32, TCG_CALL_NO_RWG, | ||
37 | DEF_HELPER_FLAGS_5(gvec_fmlal_idx_a64, TCG_CALL_NO_RWG, | ||
38 | void, ptr, ptr, ptr, ptr, i32) | ||
39 | |||
40 | +DEF_HELPER_FLAGS_2(frint32_s, TCG_CALL_NO_RWG, f32, f32, ptr) | ||
41 | +DEF_HELPER_FLAGS_2(frint64_s, TCG_CALL_NO_RWG, f32, f32, ptr) | ||
42 | +DEF_HELPER_FLAGS_2(frint32_d, TCG_CALL_NO_RWG, f64, f64, ptr) | ||
43 | +DEF_HELPER_FLAGS_2(frint64_d, TCG_CALL_NO_RWG, f64, f64, ptr) | ||
44 | + | ||
45 | #ifdef TARGET_AARCH64 | ||
46 | #include "helper-a64.h" | ||
47 | #include "helper-sve.h" | ||
48 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/cpu64.c | ||
51 | +++ b/target/arm/cpu64.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
53 | t = FIELD_DP64(t, ID_AA64ISAR1, GPI, 0); | ||
54 | t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); | ||
55 | t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); | ||
56 | + t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1); | ||
57 | cpu->isar.id_aa64isar1 = t; | ||
58 | |||
59 | t = cpu->isar.id_aa64pfr0; | ||
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 handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn) | ||
65 | case 0xf: /* FRINTI */ | ||
66 | gen_fpst = gen_helper_rints; | ||
67 | break; | ||
68 | + case 0x10: /* FRINT32Z */ | ||
69 | + rmode = float_round_to_zero; | ||
70 | + gen_fpst = gen_helper_frint32_s; | ||
71 | + break; | ||
72 | + case 0x11: /* FRINT32X */ | ||
73 | + gen_fpst = gen_helper_frint32_s; | ||
74 | + break; | ||
75 | + case 0x12: /* FRINT64Z */ | ||
76 | + rmode = float_round_to_zero; | ||
77 | + gen_fpst = gen_helper_frint64_s; | ||
78 | + break; | ||
79 | + case 0x13: /* FRINT64X */ | ||
80 | + gen_fpst = gen_helper_frint64_s; | ||
81 | + break; | ||
82 | default: | ||
83 | g_assert_not_reached(); | ||
84 | } | ||
85 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn) | ||
86 | case 0xf: /* FRINTI */ | ||
87 | gen_fpst = gen_helper_rintd; | ||
88 | break; | ||
89 | + case 0x10: /* FRINT32Z */ | ||
90 | + rmode = float_round_to_zero; | ||
91 | + gen_fpst = gen_helper_frint32_d; | ||
92 | + break; | ||
93 | + case 0x11: /* FRINT32X */ | ||
94 | + gen_fpst = gen_helper_frint32_d; | ||
95 | + break; | ||
96 | + case 0x12: /* FRINT64Z */ | ||
97 | + rmode = float_round_to_zero; | ||
98 | + gen_fpst = gen_helper_frint64_d; | ||
99 | + break; | ||
100 | + case 0x13: /* FRINT64X */ | ||
101 | + gen_fpst = gen_helper_frint64_d; | ||
102 | + break; | ||
103 | default: | ||
104 | g_assert_not_reached(); | ||
105 | } | ||
106 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) | ||
107 | handle_fp_fcvt(s, opcode, rd, rn, dtype, type); | ||
108 | break; | ||
109 | } | ||
110 | + | ||
111 | + case 0x10 ... 0x13: /* FRINT{32,64}{X,Z} */ | ||
112 | + if (type > 1 || !dc_isar_feature(aa64_frint, s)) { | ||
113 | + unallocated_encoding(s); | ||
114 | + return; | ||
115 | + } | ||
116 | + /* fall through */ | ||
117 | case 0x0 ... 0x3: | ||
118 | case 0x8 ... 0xc: | ||
119 | case 0xe ... 0xf: | ||
120 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) | ||
121 | if (!fp_access_check(s)) { | ||
122 | return; | ||
123 | } | ||
124 | - | ||
125 | handle_fp_1src_single(s, opcode, rd, rn); | ||
126 | break; | ||
127 | case 1: | ||
128 | if (!fp_access_check(s)) { | ||
129 | return; | ||
130 | } | ||
131 | - | ||
132 | handle_fp_1src_double(s, opcode, rd, rn); | ||
133 | break; | ||
134 | case 3: | ||
135 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) | ||
136 | if (!fp_access_check(s)) { | ||
137 | return; | ||
138 | } | ||
139 | - | ||
140 | handle_fp_1src_half(s, opcode, rd, rn); | ||
141 | break; | ||
142 | default: | ||
143 | unallocated_encoding(s); | ||
144 | } | 32 | } |
145 | break; | 33 | if (fpst->default_nan_mode) { |
146 | + | 34 | nan = float16_default_nan(fpst); |
147 | default: | 35 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp) |
148 | unallocated_encoding(s); | 36 | float32 nan = a; |
149 | break; | 37 | if (float32_is_signaling_nan(a, fpst)) { |
150 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_64(DisasContext *s, int opcode, bool u, | 38 | float_raise(float_flag_invalid, fpst); |
151 | case 0x59: /* FRINTX */ | 39 | - nan = float32_silence_nan(a, fpst); |
152 | gen_helper_rintd_exact(tcg_rd, tcg_rn, tcg_fpstatus); | 40 | + if (!fpst->default_nan_mode) { |
153 | break; | 41 | + nan = float32_silence_nan(a, fpst); |
154 | + case 0x1e: /* FRINT32Z */ | 42 | + } |
155 | + case 0x5e: /* FRINT32X */ | ||
156 | + gen_helper_frint32_d(tcg_rd, tcg_rn, tcg_fpstatus); | ||
157 | + break; | ||
158 | + case 0x1f: /* FRINT64Z */ | ||
159 | + case 0x5f: /* FRINT64X */ | ||
160 | + gen_helper_frint64_d(tcg_rd, tcg_rn, tcg_fpstatus); | ||
161 | + break; | ||
162 | default: | ||
163 | g_assert_not_reached(); | ||
164 | } | ||
165 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) | ||
166 | } | 43 | } |
167 | break; | 44 | if (fpst->default_nan_mode) { |
168 | case 0xc ... 0xf: | 45 | nan = float32_default_nan(fpst); |
169 | - case 0x16 ... 0x1d: | 46 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp) |
170 | - case 0x1f: | 47 | float64 nan = a; |
171 | + case 0x16 ... 0x1f: | 48 | if (float64_is_signaling_nan(a, fpst)) { |
172 | { | 49 | float_raise(float_flag_invalid, fpst); |
173 | /* Floating point: U, size[1] and opcode indicate operation; | 50 | - nan = float64_silence_nan(a, fpst); |
174 | * size[0] indicates single or double precision. | 51 | + if (!fpst->default_nan_mode) { |
175 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) | 52 | + nan = float64_silence_nan(a, fpst); |
176 | } | ||
177 | need_fpstatus = true; | ||
178 | break; | ||
179 | + case 0x1e: /* FRINT32Z */ | ||
180 | + case 0x1f: /* FRINT64Z */ | ||
181 | + need_rmode = true; | ||
182 | + rmode = FPROUNDING_ZERO; | ||
183 | + /* fall through */ | ||
184 | + case 0x5e: /* FRINT32X */ | ||
185 | + case 0x5f: /* FRINT64X */ | ||
186 | + need_fpstatus = true; | ||
187 | + if ((size == 3 && !is_q) || !dc_isar_feature(aa64_frint, s)) { | ||
188 | + unallocated_encoding(s); | ||
189 | + return; | ||
190 | + } | 53 | + } |
191 | + break; | 54 | } |
192 | default: | 55 | if (fpst->default_nan_mode) { |
193 | unallocated_encoding(s); | 56 | nan = float64_default_nan(fpst); |
194 | return; | ||
195 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) | ||
196 | case 0x7c: /* URSQRTE */ | ||
197 | gen_helper_rsqrte_u32(tcg_res, tcg_op, tcg_fpstatus); | ||
198 | break; | ||
199 | + case 0x1e: /* FRINT32Z */ | ||
200 | + case 0x5e: /* FRINT32X */ | ||
201 | + gen_helper_frint32_s(tcg_res, tcg_op, tcg_fpstatus); | ||
202 | + break; | ||
203 | + case 0x1f: /* FRINT64Z */ | ||
204 | + case 0x5f: /* FRINT64X */ | ||
205 | + gen_helper_frint64_s(tcg_res, tcg_op, tcg_fpstatus); | ||
206 | + break; | ||
207 | default: | ||
208 | g_assert_not_reached(); | ||
209 | } | ||
210 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 57 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c |
211 | index XXXXXXX..XXXXXXX 100644 | 58 | index XXXXXXX..XXXXXXX 100644 |
212 | --- a/target/arm/vfp_helper.c | 59 | --- a/target/arm/vfp_helper.c |
213 | +++ b/target/arm/vfp_helper.c | 60 | +++ b/target/arm/vfp_helper.c |
214 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vjcvt)(float64 value, CPUARMState *env) | 61 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) |
215 | 62 | float16 nan = f16; | |
216 | return result; | 63 | if (float16_is_signaling_nan(f16, fpst)) { |
217 | } | 64 | float_raise(float_flag_invalid, fpst); |
218 | + | 65 | - nan = float16_silence_nan(f16, fpst); |
219 | +/* Round a float32 to an integer that fits in int32_t or int64_t. */ | 66 | + if (!fpst->default_nan_mode) { |
220 | +static float32 frint_s(float32 f, float_status *fpst, int intsize) | 67 | + nan = float16_silence_nan(f16, fpst); |
221 | +{ | 68 | + } |
222 | + int old_flags = get_float_exception_flags(fpst); | 69 | } |
223 | + uint32_t exp = extract32(f, 23, 8); | 70 | if (fpst->default_nan_mode) { |
224 | + | 71 | nan = float16_default_nan(fpst); |
225 | + if (unlikely(exp == 0xff)) { | 72 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(recpe_f32)(float32 input, void *fpstp) |
226 | + /* NaN or Inf. */ | 73 | float32 nan = f32; |
227 | + goto overflow; | 74 | if (float32_is_signaling_nan(f32, fpst)) { |
228 | + } | 75 | float_raise(float_flag_invalid, fpst); |
229 | + | 76 | - nan = float32_silence_nan(f32, fpst); |
230 | + /* Round and re-extract the exponent. */ | 77 | + if (!fpst->default_nan_mode) { |
231 | + f = float32_round_to_int(f, fpst); | 78 | + nan = float32_silence_nan(f32, fpst); |
232 | + exp = extract32(f, 23, 8); | 79 | + } |
233 | + | 80 | } |
234 | + /* Validate the range of the result. */ | 81 | if (fpst->default_nan_mode) { |
235 | + if (exp < 126 + intsize) { | 82 | nan = float32_default_nan(fpst); |
236 | + /* abs(F) <= INT{N}_MAX */ | 83 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp) |
237 | + return f; | 84 | float64 nan = f64; |
238 | + } | 85 | if (float64_is_signaling_nan(f64, fpst)) { |
239 | + if (exp == 126 + intsize) { | 86 | float_raise(float_flag_invalid, fpst); |
240 | + uint32_t sign = extract32(f, 31, 1); | 87 | - nan = float64_silence_nan(f64, fpst); |
241 | + uint32_t frac = extract32(f, 0, 23); | 88 | + if (!fpst->default_nan_mode) { |
242 | + if (sign && frac == 0) { | 89 | + nan = float64_silence_nan(f64, fpst); |
243 | + /* F == INT{N}_MIN */ | 90 | + } |
244 | + return f; | 91 | } |
245 | + } | 92 | if (fpst->default_nan_mode) { |
246 | + } | 93 | nan = float64_default_nan(fpst); |
247 | + | 94 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) |
248 | + overflow: | 95 | float16 nan = f16; |
249 | + /* | 96 | if (float16_is_signaling_nan(f16, s)) { |
250 | + * Raise Invalid and return INT{N}_MIN as a float. Revert any | 97 | float_raise(float_flag_invalid, s); |
251 | + * inexact exception float32_round_to_int may have raised. | 98 | - nan = float16_silence_nan(f16, s); |
252 | + */ | 99 | + if (!s->default_nan_mode) { |
253 | + set_float_exception_flags(old_flags | float_flag_invalid, fpst); | 100 | + nan = float16_silence_nan(f16, fpstp); |
254 | + return (0x100u + 126u + intsize) << 23; | 101 | + } |
255 | +} | 102 | } |
256 | + | 103 | if (s->default_nan_mode) { |
257 | +float32 HELPER(frint32_s)(float32 f, void *fpst) | 104 | nan = float16_default_nan(s); |
258 | +{ | 105 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) |
259 | + return frint_s(f, fpst, 32); | 106 | float32 nan = f32; |
260 | +} | 107 | if (float32_is_signaling_nan(f32, s)) { |
261 | + | 108 | float_raise(float_flag_invalid, s); |
262 | +float32 HELPER(frint64_s)(float32 f, void *fpst) | 109 | - nan = float32_silence_nan(f32, s); |
263 | +{ | 110 | + if (!s->default_nan_mode) { |
264 | + return frint_s(f, fpst, 64); | 111 | + nan = float32_silence_nan(f32, fpstp); |
265 | +} | 112 | + } |
266 | + | 113 | } |
267 | +/* Round a float64 to an integer that fits in int32_t or int64_t. */ | 114 | if (s->default_nan_mode) { |
268 | +static float64 frint_d(float64 f, float_status *fpst, int intsize) | 115 | nan = float32_default_nan(s); |
269 | +{ | 116 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) |
270 | + int old_flags = get_float_exception_flags(fpst); | 117 | float64 nan = f64; |
271 | + uint32_t exp = extract64(f, 52, 11); | 118 | if (float64_is_signaling_nan(f64, s)) { |
272 | + | 119 | float_raise(float_flag_invalid, s); |
273 | + if (unlikely(exp == 0x7ff)) { | 120 | - nan = float64_silence_nan(f64, s); |
274 | + /* NaN or Inf. */ | 121 | + if (!s->default_nan_mode) { |
275 | + goto overflow; | 122 | + nan = float64_silence_nan(f64, fpstp); |
276 | + } | 123 | + } |
277 | + | 124 | } |
278 | + /* Round and re-extract the exponent. */ | 125 | if (s->default_nan_mode) { |
279 | + f = float64_round_to_int(f, fpst); | 126 | nan = float64_default_nan(s); |
280 | + exp = extract64(f, 52, 11); | ||
281 | + | ||
282 | + /* Validate the range of the result. */ | ||
283 | + if (exp < 1022 + intsize) { | ||
284 | + /* abs(F) <= INT{N}_MAX */ | ||
285 | + return f; | ||
286 | + } | ||
287 | + if (exp == 1022 + intsize) { | ||
288 | + uint64_t sign = extract64(f, 63, 1); | ||
289 | + uint64_t frac = extract64(f, 0, 52); | ||
290 | + if (sign && frac == 0) { | ||
291 | + /* F == INT{N}_MIN */ | ||
292 | + return f; | ||
293 | + } | ||
294 | + } | ||
295 | + | ||
296 | + overflow: | ||
297 | + /* | ||
298 | + * Raise Invalid and return INT{N}_MIN as a float. Revert any | ||
299 | + * inexact exception float64_round_to_int may have raised. | ||
300 | + */ | ||
301 | + set_float_exception_flags(old_flags | float_flag_invalid, fpst); | ||
302 | + return (uint64_t)(0x800 + 1022 + intsize) << 52; | ||
303 | +} | ||
304 | + | ||
305 | +float64 HELPER(frint32_d)(float64 f, void *fpst) | ||
306 | +{ | ||
307 | + return frint_d(f, fpst, 32); | ||
308 | +} | ||
309 | + | ||
310 | +float64 HELPER(frint64_d)(float64 f, void *fpst) | ||
311 | +{ | ||
312 | + return frint_d(f, fpst, 64); | ||
313 | +} | ||
314 | -- | 127 | -- |
315 | 2.20.1 | 128 | 2.20.1 |
316 | 129 | ||
317 | 130 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | From: Maxim Uvarov <maxim.uvarov@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | On ARM, the kvm_type will be resolved by querying the KVMState. | 3 | qemu has 2 type of functions: shutdown and reboot. Shutdown |
4 | Let's add the MachineState handle to the callback so that we | 4 | function has to be used for machine shutdown. Otherwise we cause |
5 | can retrieve the KVMState handle. in kvm_init, when the callback | 5 | a reset with a bogus "cause" value, when we intended a shutdown. |
6 | is called, the kvm_state variable is not yet set. | ||
7 | 6 | ||
8 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 7 | Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> |
9 | Acked-by: David Gibson <david@gibson.dropbear.id.au> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | 9 | Message-id: 20210625111842.3790-3-maxim.uvarov@linaro.org |
12 | Message-id: 20190304101339.25970-5-eric.auger@redhat.com | 10 | [PMM: tweaked commit message] |
13 | [ppc parts] | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | 12 | --- |
18 | include/hw/boards.h | 5 ++++- | 13 | hw/gpio/gpio_pwr.c | 2 +- |
19 | accel/kvm/kvm-all.c | 2 +- | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
20 | hw/ppc/mac_newworld.c | 3 +-- | ||
21 | hw/ppc/mac_oldworld.c | 2 +- | ||
22 | hw/ppc/spapr.c | 2 +- | ||
23 | 5 files changed, 8 insertions(+), 6 deletions(-) | ||
24 | 15 | ||
25 | diff --git a/include/hw/boards.h b/include/hw/boards.h | 16 | diff --git a/hw/gpio/gpio_pwr.c b/hw/gpio/gpio_pwr.c |
26 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/include/hw/boards.h | 18 | --- a/hw/gpio/gpio_pwr.c |
28 | +++ b/include/hw/boards.h | 19 | +++ b/hw/gpio/gpio_pwr.c |
29 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 20 | @@ -XXX,XX +XXX,XX @@ static void gpio_pwr_reset(void *opaque, int n, int level) |
30 | * should instead use "unimplemented-device" for all memory ranges where | 21 | static void gpio_pwr_shutdown(void *opaque, int n, int level) |
31 | * the guest will attempt to probe for a device that QEMU doesn't | ||
32 | * implement and a stub device is required. | ||
33 | + * @kvm_type: | ||
34 | + * Return the type of KVM corresponding to the kvm-type string option or | ||
35 | + * computed based on other criteria such as the host kernel capabilities. | ||
36 | */ | ||
37 | struct MachineClass { | ||
38 | /*< private >*/ | ||
39 | @@ -XXX,XX +XXX,XX @@ struct MachineClass { | ||
40 | void (*init)(MachineState *state); | ||
41 | void (*reset)(void); | ||
42 | void (*hot_add_cpu)(const int64_t id, Error **errp); | ||
43 | - int (*kvm_type)(const char *arg); | ||
44 | + int (*kvm_type)(MachineState *machine, const char *arg); | ||
45 | |||
46 | BlockInterfaceType block_default_type; | ||
47 | int units_per_default_bus; | ||
48 | diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/accel/kvm/kvm-all.c | ||
51 | +++ b/accel/kvm/kvm-all.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static int kvm_init(MachineState *ms) | ||
53 | |||
54 | kvm_type = qemu_opt_get(qemu_get_machine_opts(), "kvm-type"); | ||
55 | if (mc->kvm_type) { | ||
56 | - type = mc->kvm_type(kvm_type); | ||
57 | + type = mc->kvm_type(ms, kvm_type); | ||
58 | } else if (kvm_type) { | ||
59 | ret = -EINVAL; | ||
60 | fprintf(stderr, "Invalid argument kvm-type=%s\n", kvm_type); | ||
61 | diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/hw/ppc/mac_newworld.c | ||
64 | +++ b/hw/ppc/mac_newworld.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static char *core99_fw_dev_path(FWPathProvider *p, BusState *bus, | ||
66 | |||
67 | return NULL; | ||
68 | } | ||
69 | - | ||
70 | -static int core99_kvm_type(const char *arg) | ||
71 | +static int core99_kvm_type(MachineState *machine, const char *arg) | ||
72 | { | 22 | { |
73 | /* Always force PR KVM */ | 23 | if (level) { |
74 | return 2; | 24 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); |
75 | diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c | 25 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); |
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/hw/ppc/mac_oldworld.c | ||
78 | +++ b/hw/ppc/mac_oldworld.c | ||
79 | @@ -XXX,XX +XXX,XX @@ static char *heathrow_fw_dev_path(FWPathProvider *p, BusState *bus, | ||
80 | return NULL; | ||
81 | } | ||
82 | |||
83 | -static int heathrow_kvm_type(const char *arg) | ||
84 | +static int heathrow_kvm_type(MachineState *machine, const char *arg) | ||
85 | { | ||
86 | /* Always force PR KVM */ | ||
87 | return 2; | ||
88 | diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c | ||
89 | index XXXXXXX..XXXXXXX 100644 | ||
90 | --- a/hw/ppc/spapr.c | ||
91 | +++ b/hw/ppc/spapr.c | ||
92 | @@ -XXX,XX +XXX,XX @@ static void spapr_machine_init(MachineState *machine) | ||
93 | } | 26 | } |
94 | } | 27 | } |
95 | 28 | ||
96 | -static int spapr_kvm_type(const char *vm_type) | ||
97 | +static int spapr_kvm_type(MachineState *machine, const char *vm_type) | ||
98 | { | ||
99 | if (!vm_type) { | ||
100 | return 0; | ||
101 | -- | 29 | -- |
102 | 2.20.1 | 30 | 2.20.1 |
103 | 31 | ||
104 | 32 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | In do_ldst(), the calculation of the offset needs to be based on the |
---|---|---|---|
2 | size of the memory access, not the size of the elements in the | ||
3 | vector. This meant we were getting it wrong for the widening and | ||
4 | narrowing variants of the various VLDR and VSTR insns. | ||
2 | 5 | ||
3 | Up to now the memory map has been static and the high IO region | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | base has always been 256GiB. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210628135835.6690-2-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/translate-mve.c | 17 +++++++++-------- | ||
11 | 1 file changed, 9 insertions(+), 8 deletions(-) | ||
5 | 12 | ||
6 | This patch modifies the virt_set_memmap() function, which freezes | 13 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
7 | the memory map, so that the high IO range base becomes floating, | ||
8 | located after the initial RAM and the device memory. | ||
9 | |||
10 | The function computes | ||
11 | - the base of the device memory, | ||
12 | - the size of the device memory, | ||
13 | - the high IO region base | ||
14 | - the highest GPA used in the memory map. | ||
15 | |||
16 | Entries of the high IO region are assigned a base address. The | ||
17 | device memory is initialized. | ||
18 | |||
19 | The highest GPA used in the memory map will be used at VM creation | ||
20 | to choose the requested IPA size. | ||
21 | |||
22 | Setting all the existing highmem IO regions beyond the RAM | ||
23 | allows to have a single contiguous RAM region (initial RAM and | ||
24 | possible hotpluggable device memory). That way we do not need | ||
25 | to do invasive changes in the EDK2 FW to support a dynamic | ||
26 | RAM base. | ||
27 | |||
28 | Still the user cannot request an initial RAM size greater than 255GB. | ||
29 | |||
30 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
31 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
32 | Message-id: 20190304101339.25970-8-eric.auger@redhat.com | ||
33 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
34 | --- | ||
35 | include/hw/arm/virt.h | 1 + | ||
36 | hw/arm/virt.c | 52 ++++++++++++++++++++++++++++++++++++++----- | ||
37 | 2 files changed, 47 insertions(+), 6 deletions(-) | ||
38 | |||
39 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/include/hw/arm/virt.h | 15 | --- a/target/arm/translate-mve.c |
42 | +++ b/include/hw/arm/virt.h | 16 | +++ b/target/arm/translate-mve.c |
43 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 17 | @@ -XXX,XX +XXX,XX @@ static bool mve_skip_first_beat(DisasContext *s) |
44 | uint32_t msi_phandle; | 18 | } |
45 | uint32_t iommu_phandle; | 19 | } |
46 | int psci_conduit; | 20 | |
47 | + hwaddr highest_gpa; | 21 | -static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) |
48 | } VirtMachineState; | 22 | +static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn, |
49 | 23 | + unsigned msize) | |
50 | #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) | ||
51 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/hw/arm/virt.c | ||
54 | +++ b/hw/arm/virt.c | ||
55 | @@ -XXX,XX +XXX,XX @@ | ||
56 | #include "qapi/visitor.h" | ||
57 | #include "standard-headers/linux/input.h" | ||
58 | #include "hw/arm/smmuv3.h" | ||
59 | +#include "hw/acpi/acpi.h" | ||
60 | |||
61 | #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ | ||
62 | static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | * of a terabyte of RAM will be doing it on a host with more than a | ||
65 | * terabyte of physical address space.) | ||
66 | */ | ||
67 | -#define RAMLIMIT_GB 255 | ||
68 | -#define RAMLIMIT_BYTES (RAMLIMIT_GB * 1024ULL * 1024 * 1024) | ||
69 | +#define LEGACY_RAMLIMIT_GB 255 | ||
70 | +#define LEGACY_RAMLIMIT_BYTES (LEGACY_RAMLIMIT_GB * GiB) | ||
71 | |||
72 | /* Addresses and sizes of our components. | ||
73 | * 0..128MB is space for a flash device so we can run bootrom code such as UEFI. | ||
74 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry base_memmap[] = { | ||
75 | [VIRT_PCIE_MMIO] = { 0x10000000, 0x2eff0000 }, | ||
76 | [VIRT_PCIE_PIO] = { 0x3eff0000, 0x00010000 }, | ||
77 | [VIRT_PCIE_ECAM] = { 0x3f000000, 0x01000000 }, | ||
78 | - [VIRT_MEM] = { 0x40000000, RAMLIMIT_BYTES }, | ||
79 | + /* Actual RAM size depends on initial RAM and device memory settings */ | ||
80 | + [VIRT_MEM] = { GiB, LEGACY_RAMLIMIT_BYTES }, | ||
81 | }; | ||
82 | |||
83 | /* | ||
84 | @@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) | ||
85 | |||
86 | static void virt_set_memmap(VirtMachineState *vms) | ||
87 | { | 24 | { |
88 | - hwaddr base; | 25 | TCGv_i32 addr; |
89 | + MachineState *ms = MACHINE(vms); | 26 | uint32_t offset; |
90 | + hwaddr base, device_memory_base, device_memory_size; | 27 | @@ -XXX,XX +XXX,XX @@ static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) |
91 | int i; | 28 | return true; |
92 | |||
93 | vms->memmap = extended_memmap; | ||
94 | @@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms) | ||
95 | vms->memmap[i] = base_memmap[i]; | ||
96 | } | 29 | } |
97 | 30 | ||
98 | - base = 256 * GiB; /* Top of the legacy initial RAM region */ | 31 | - offset = a->imm << a->size; |
99 | + if (ms->ram_slots > ACPI_MAX_RAM_SLOTS) { | 32 | + offset = a->imm << msize; |
100 | + error_report("unsupported number of memory slots: %"PRIu64, | 33 | if (!a->a) { |
101 | + ms->ram_slots); | 34 | offset = -offset; |
102 | + exit(EXIT_FAILURE); | ||
103 | + } | ||
104 | + | ||
105 | + /* | ||
106 | + * We compute the base of the high IO region depending on the | ||
107 | + * amount of initial and device memory. The device memory start/size | ||
108 | + * is aligned on 1GiB. We never put the high IO region below 256GiB | ||
109 | + * so that if maxram_size is < 255GiB we keep the legacy memory map. | ||
110 | + * The device region size assumes 1GiB page max alignment per slot. | ||
111 | + */ | ||
112 | + device_memory_base = | ||
113 | + ROUND_UP(vms->memmap[VIRT_MEM].base + ms->ram_size, GiB); | ||
114 | + device_memory_size = ms->maxram_size - ms->ram_size + ms->ram_slots * GiB; | ||
115 | + | ||
116 | + /* Base address of the high IO region */ | ||
117 | + base = device_memory_base + ROUND_UP(device_memory_size, GiB); | ||
118 | + if (base < device_memory_base) { | ||
119 | + error_report("maxmem/slots too huge"); | ||
120 | + exit(EXIT_FAILURE); | ||
121 | + } | ||
122 | + if (base < vms->memmap[VIRT_MEM].base + LEGACY_RAMLIMIT_BYTES) { | ||
123 | + base = vms->memmap[VIRT_MEM].base + LEGACY_RAMLIMIT_BYTES; | ||
124 | + } | ||
125 | |||
126 | for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) { | ||
127 | hwaddr size = extended_memmap[i].size; | ||
128 | @@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms) | ||
129 | vms->memmap[i].size = size; | ||
130 | base += size; | ||
131 | } | 35 | } |
132 | + vms->highest_gpa = base - 1; | 36 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a) |
133 | + if (device_memory_size > 0) { | 37 | { gen_helper_mve_vstrw, gen_helper_mve_vldrw }, |
134 | + ms->device_memory = g_malloc0(sizeof(*ms->device_memory)); | 38 | { NULL, NULL } |
135 | + ms->device_memory->base = device_memory_base; | 39 | }; |
136 | + memory_region_init(&ms->device_memory->mr, OBJECT(vms), | 40 | - return do_ldst(s, a, ldstfns[a->size][a->l]); |
137 | + "device-memory", device_memory_size); | 41 | + return do_ldst(s, a, ldstfns[a->size][a->l], a->size); |
138 | + } | ||
139 | } | 42 | } |
140 | 43 | ||
141 | static void machvirt_init(MachineState *machine) | 44 | -#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST) \ |
142 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 45 | +#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST, MSIZE) \ |
143 | vms->smp_cpus = smp_cpus; | 46 | static bool trans_##OP(DisasContext *s, arg_VLDR_VSTR *a) \ |
144 | 47 | { \ | |
145 | if (machine->ram_size > vms->memmap[VIRT_MEM].size) { | 48 | static MVEGenLdStFn * const ldstfns[2][2] = { \ |
146 | - error_report("mach-virt: cannot model more than %dGB RAM", RAMLIMIT_GB); | 49 | { gen_helper_mve_##ST, gen_helper_mve_##SLD }, \ |
147 | + error_report("mach-virt: cannot model more than %dGB RAM", | 50 | { NULL, gen_helper_mve_##ULD }, \ |
148 | + LEGACY_RAMLIMIT_GB); | 51 | }; \ |
149 | exit(1); | 52 | - return do_ldst(s, a, ldstfns[a->u][a->l]); \ |
53 | + return do_ldst(s, a, ldstfns[a->u][a->l], MSIZE); \ | ||
150 | } | 54 | } |
151 | 55 | ||
152 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 56 | -DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h) |
153 | memory_region_allocate_system_memory(ram, NULL, "mach-virt.ram", | 57 | -DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w) |
154 | machine->ram_size); | 58 | -DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w) |
155 | memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram); | 59 | +DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h, MO_8) |
156 | + if (machine->device_memory) { | 60 | +DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w, MO_8) |
157 | + memory_region_add_subregion(sysmem, machine->device_memory->base, | 61 | +DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w, MO_16) |
158 | + &machine->device_memory->mr); | 62 | |
159 | + } | 63 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) |
160 | 64 | { | |
161 | create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem); | ||
162 | |||
163 | -- | 65 | -- |
164 | 2.20.1 | 66 | 2.20.1 |
165 | 67 | ||
166 | 68 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The initial implementation of the MVE VRMLALDAVH and VRMLSLDAVH | ||
2 | insns had some bugs: | ||
3 | * the 32x32 multiply of elements was being done as 32x32->32, | ||
4 | not 32x32->64 | ||
5 | * we were incorrectly maintaining the accumulator in its full | ||
6 | 72-bit form across all 4 beats of the insn; in the pseudocode | ||
7 | it is squashed back into the 64 bits of the RdaHi:RdaLo | ||
8 | registers after each beat | ||
1 | 9 | ||
10 | In particular, fixing the second of these allows us to recast | ||
11 | the implementation to avoid 128-bit arithmetic entirely. | ||
12 | |||
13 | Since the element size here is always 4, we can also drop the | ||
14 | parameterization of ESIZE to make the code a little more readable. | ||
15 | |||
16 | Suggested-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20210628135835.6690-3-peter.maydell@linaro.org | ||
20 | --- | ||
21 | target/arm/mve_helper.c | 38 +++++++++++++++++++++----------------- | ||
22 | 1 file changed, 21 insertions(+), 17 deletions(-) | ||
23 | |||
24 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/target/arm/mve_helper.c | ||
27 | +++ b/target/arm/mve_helper.c | ||
28 | @@ -XXX,XX +XXX,XX @@ | ||
29 | */ | ||
30 | |||
31 | #include "qemu/osdep.h" | ||
32 | -#include "qemu/int128.h" | ||
33 | #include "cpu.h" | ||
34 | #include "internals.h" | ||
35 | #include "vec_internal.h" | ||
36 | @@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=) | ||
37 | DO_LDAV(vmlsldavxsw, 4, int32_t, true, +=, -=) | ||
38 | |||
39 | /* | ||
40 | - * Rounding multiply add long dual accumulate high: we must keep | ||
41 | - * a 72-bit internal accumulator value and return the top 64 bits. | ||
42 | + * Rounding multiply add long dual accumulate high. In the pseudocode | ||
43 | + * this is implemented with a 72-bit internal accumulator value of which | ||
44 | + * the top 64 bits are returned. We optimize this to avoid having to | ||
45 | + * use 128-bit arithmetic -- we can do this because the 74-bit accumulator | ||
46 | + * is squashed back into 64-bits after each beat. | ||
47 | */ | ||
48 | -#define DO_LDAVH(OP, ESIZE, TYPE, XCHG, EVENACC, ODDACC, TO128) \ | ||
49 | +#define DO_LDAVH(OP, TYPE, LTYPE, XCHG, SUB) \ | ||
50 | uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vn, \ | ||
51 | void *vm, uint64_t a) \ | ||
52 | { \ | ||
53 | uint16_t mask = mve_element_mask(env); \ | ||
54 | unsigned e; \ | ||
55 | TYPE *n = vn, *m = vm; \ | ||
56 | - Int128 acc = int128_lshift(TO128(a), 8); \ | ||
57 | - for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
58 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
59 | if (mask & 1) { \ | ||
60 | + LTYPE mul; \ | ||
61 | if (e & 1) { \ | ||
62 | - acc = ODDACC(acc, TO128(n[H##ESIZE(e - 1 * XCHG)] * \ | ||
63 | - m[H##ESIZE(e)])); \ | ||
64 | + mul = (LTYPE)n[H4(e - 1 * XCHG)] * m[H4(e)]; \ | ||
65 | + if (SUB) { \ | ||
66 | + mul = -mul; \ | ||
67 | + } \ | ||
68 | } else { \ | ||
69 | - acc = EVENACC(acc, TO128(n[H##ESIZE(e + 1 * XCHG)] * \ | ||
70 | - m[H##ESIZE(e)])); \ | ||
71 | + mul = (LTYPE)n[H4(e + 1 * XCHG)] * m[H4(e)]; \ | ||
72 | } \ | ||
73 | - acc = int128_add(acc, int128_make64(1 << 7)); \ | ||
74 | + mul = (mul >> 8) + ((mul >> 7) & 1); \ | ||
75 | + a += mul; \ | ||
76 | } \ | ||
77 | } \ | ||
78 | mve_advance_vpt(env); \ | ||
79 | - return int128_getlo(int128_rshift(acc, 8)); \ | ||
80 | + return a; \ | ||
81 | } | ||
82 | |||
83 | -DO_LDAVH(vrmlaldavhsw, 4, int32_t, false, int128_add, int128_add, int128_makes64) | ||
84 | -DO_LDAVH(vrmlaldavhxsw, 4, int32_t, true, int128_add, int128_add, int128_makes64) | ||
85 | +DO_LDAVH(vrmlaldavhsw, int32_t, int64_t, false, false) | ||
86 | +DO_LDAVH(vrmlaldavhxsw, int32_t, int64_t, true, false) | ||
87 | |||
88 | -DO_LDAVH(vrmlaldavhuw, 4, uint32_t, false, int128_add, int128_add, int128_make64) | ||
89 | +DO_LDAVH(vrmlaldavhuw, uint32_t, uint64_t, false, false) | ||
90 | |||
91 | -DO_LDAVH(vrmlsldavhsw, 4, int32_t, false, int128_add, int128_sub, int128_makes64) | ||
92 | -DO_LDAVH(vrmlsldavhxsw, 4, int32_t, true, int128_add, int128_sub, int128_makes64) | ||
93 | +DO_LDAVH(vrmlsldavhsw, int32_t, int64_t, false, true) | ||
94 | +DO_LDAVH(vrmlsldavhxsw, int32_t, int64_t, true, true) | ||
95 | |||
96 | /* Vector add across vector */ | ||
97 | #define DO_VADDV(OP, ESIZE, TYPE) \ | ||
98 | -- | ||
99 | 2.20.1 | ||
100 | |||
101 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The function asimd_imm_const() in translate-neon.c is an |
---|---|---|---|
2 | implementation of the pseudocode AdvSIMDExpandImm(), which we will | ||
3 | also want for MVE. Move the implementation to translate.c, with a | ||
4 | prototype in translate.h. | ||
2 | 5 | ||
3 | We do not need an out-of-line helper for manipulating bits in pstate. | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | While changing things, share the implementation of gen_ss_advance. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210628135835.6690-4-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/translate.h | 16 ++++++++++ | ||
11 | target/arm/translate-neon.c | 63 ------------------------------------- | ||
12 | target/arm/translate.c | 57 +++++++++++++++++++++++++++++++++ | ||
13 | 3 files changed, 73 insertions(+), 63 deletions(-) | ||
5 | 14 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20190301200501.16533-6-richard.henderson@linaro.org | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper.h | 2 -- | ||
12 | target/arm/translate.h | 34 ++++++++++++++++++++++++++++++++++ | ||
13 | target/arm/op_helper.c | 5 ----- | ||
14 | target/arm/translate-a64.c | 11 ----------- | ||
15 | target/arm/translate.c | 11 ----------- | ||
16 | 5 files changed, 34 insertions(+), 29 deletions(-) | ||
17 | |||
18 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper.h | ||
21 | +++ b/target/arm/helper.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(get_cp_reg, i32, env, ptr) | ||
23 | DEF_HELPER_3(set_cp_reg64, void, env, ptr, i64) | ||
24 | DEF_HELPER_2(get_cp_reg64, i64, env, ptr) | ||
25 | |||
26 | -DEF_HELPER_1(clear_pstate_ss, void, env) | ||
27 | - | ||
28 | DEF_HELPER_2(get_r13_banked, i32, env, i32) | ||
29 | DEF_HELPER_3(set_r13_banked, void, env, i32, i32) | ||
30 | |||
31 | diff --git a/target/arm/translate.h b/target/arm/translate.h | 15 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
32 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/target/arm/translate.h | 17 | --- a/target/arm/translate.h |
34 | +++ b/target/arm/translate.h | 18 | +++ b/target/arm/translate.h |
35 | @@ -XXX,XX +XXX,XX @@ static inline TCGv_i32 get_ahp_flag(void) | 19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc) |
36 | return ret; | 20 | return opc | s->be_data; |
37 | } | 21 | } |
38 | 22 | ||
39 | +/* Set bits within PSTATE. */ | 23 | +/** |
40 | +static inline void set_pstate_bits(uint32_t bits) | 24 | + * asimd_imm_const: Expand an encoded SIMD constant value |
41 | +{ | 25 | + * |
42 | + TCGv_i32 p = tcg_temp_new_i32(); | 26 | + * Expand a SIMD constant value. This is essentially the pseudocode |
27 | + * AdvSIMDExpandImm, except that we also perform the boolean NOT needed for | ||
28 | + * VMVN and VBIC (when cmode < 14 && op == 1). | ||
29 | + * | ||
30 | + * The combination cmode == 15 op == 1 is a reserved encoding for AArch32; | ||
31 | + * callers must catch this. | ||
32 | + * | ||
33 | + * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but | ||
34 | + * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A; | ||
35 | + * we produce an immediate constant value of 0 in these cases. | ||
36 | + */ | ||
37 | +uint64_t asimd_imm_const(uint32_t imm, int cmode, int op); | ||
43 | + | 38 | + |
44 | + tcg_debug_assert(!(bits & CACHED_PSTATE_BITS)); | 39 | #endif /* TARGET_ARM_TRANSLATE_H */ |
45 | + | 40 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c |
46 | + tcg_gen_ld_i32(p, cpu_env, offsetof(CPUARMState, pstate)); | ||
47 | + tcg_gen_ori_i32(p, p, bits); | ||
48 | + tcg_gen_st_i32(p, cpu_env, offsetof(CPUARMState, pstate)); | ||
49 | + tcg_temp_free_i32(p); | ||
50 | +} | ||
51 | + | ||
52 | +/* Clear bits within PSTATE. */ | ||
53 | +static inline void clear_pstate_bits(uint32_t bits) | ||
54 | +{ | ||
55 | + TCGv_i32 p = tcg_temp_new_i32(); | ||
56 | + | ||
57 | + tcg_debug_assert(!(bits & CACHED_PSTATE_BITS)); | ||
58 | + | ||
59 | + tcg_gen_ld_i32(p, cpu_env, offsetof(CPUARMState, pstate)); | ||
60 | + tcg_gen_andi_i32(p, p, ~bits); | ||
61 | + tcg_gen_st_i32(p, cpu_env, offsetof(CPUARMState, pstate)); | ||
62 | + tcg_temp_free_i32(p); | ||
63 | +} | ||
64 | + | ||
65 | +/* If the singlestep state is Active-not-pending, advance to Active-pending. */ | ||
66 | +static inline void gen_ss_advance(DisasContext *s) | ||
67 | +{ | ||
68 | + if (s->ss_active) { | ||
69 | + s->pstate_ss = 0; | ||
70 | + clear_pstate_bits(PSTATE_SS); | ||
71 | + } | ||
72 | +} | ||
73 | |||
74 | /* Vector operations shared between ARM and AArch64. */ | ||
75 | extern const GVecGen3 bsl_op; | ||
76 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
78 | --- a/target/arm/op_helper.c | 42 | --- a/target/arm/translate-neon.c |
79 | +++ b/target/arm/op_helper.c | 43 | +++ b/target/arm/translate-neon.c |
80 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(get_cp_reg64)(CPUARMState *env, void *rip) | 44 | @@ -XXX,XX +XXX,XX @@ DO_FP_2SH(VCVT_UH, gen_helper_gvec_vcvt_uh) |
81 | return res; | 45 | DO_FP_2SH(VCVT_HS, gen_helper_gvec_vcvt_hs) |
82 | } | 46 | DO_FP_2SH(VCVT_HU, gen_helper_gvec_vcvt_hu) |
83 | 47 | ||
84 | -void HELPER(clear_pstate_ss)(CPUARMState *env) | 48 | -static uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) |
85 | -{ | 49 | -{ |
86 | - env->pstate &= ~PSTATE_SS; | 50 | - /* |
51 | - * Expand the encoded constant. | ||
52 | - * Note that cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 is UNPREDICTABLE. | ||
53 | - * We choose to not special-case this and will behave as if a | ||
54 | - * valid constant encoding of 0 had been given. | ||
55 | - * cmode = 15 op = 1 must UNDEF; we assume decode has handled that. | ||
56 | - */ | ||
57 | - switch (cmode) { | ||
58 | - case 0: case 1: | ||
59 | - /* no-op */ | ||
60 | - break; | ||
61 | - case 2: case 3: | ||
62 | - imm <<= 8; | ||
63 | - break; | ||
64 | - case 4: case 5: | ||
65 | - imm <<= 16; | ||
66 | - break; | ||
67 | - case 6: case 7: | ||
68 | - imm <<= 24; | ||
69 | - break; | ||
70 | - case 8: case 9: | ||
71 | - imm |= imm << 16; | ||
72 | - break; | ||
73 | - case 10: case 11: | ||
74 | - imm = (imm << 8) | (imm << 24); | ||
75 | - break; | ||
76 | - case 12: | ||
77 | - imm = (imm << 8) | 0xff; | ||
78 | - break; | ||
79 | - case 13: | ||
80 | - imm = (imm << 16) | 0xffff; | ||
81 | - break; | ||
82 | - case 14: | ||
83 | - if (op) { | ||
84 | - /* | ||
85 | - * This is the only case where the top and bottom 32 bits | ||
86 | - * of the encoded constant differ. | ||
87 | - */ | ||
88 | - uint64_t imm64 = 0; | ||
89 | - int n; | ||
90 | - | ||
91 | - for (n = 0; n < 8; n++) { | ||
92 | - if (imm & (1 << n)) { | ||
93 | - imm64 |= (0xffULL << (n * 8)); | ||
94 | - } | ||
95 | - } | ||
96 | - return imm64; | ||
97 | - } | ||
98 | - imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
99 | - break; | ||
100 | - case 15: | ||
101 | - imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
102 | - | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
103 | - break; | ||
104 | - } | ||
105 | - if (op) { | ||
106 | - imm = ~imm; | ||
107 | - } | ||
108 | - return dup_const(MO_32, imm); | ||
87 | -} | 109 | -} |
88 | - | 110 | - |
89 | void HELPER(pre_hvc)(CPUARMState *env) | 111 | static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a, |
112 | GVecGen2iFn *fn) | ||
90 | { | 113 | { |
91 | ARMCPU *cpu = arm_env_get_cpu(env); | ||
92 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/translate-a64.c | ||
95 | +++ b/target/arm/translate-a64.c | ||
96 | @@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, int offset, | ||
97 | s->base.is_jmp = DISAS_NORETURN; | ||
98 | } | ||
99 | |||
100 | -static void gen_ss_advance(DisasContext *s) | ||
101 | -{ | ||
102 | - /* If the singlestep state is Active-not-pending, advance to | ||
103 | - * Active-pending. | ||
104 | - */ | ||
105 | - if (s->ss_active) { | ||
106 | - s->pstate_ss = 0; | ||
107 | - gen_helper_clear_pstate_ss(cpu_env); | ||
108 | - } | ||
109 | -} | ||
110 | - | ||
111 | static void gen_step_complete_exception(DisasContext *s) | ||
112 | { | ||
113 | /* We just completed step of an insn. Move from Active-not-pending | ||
114 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 114 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
115 | index XXXXXXX..XXXXXXX 100644 | 115 | index XXXXXXX..XXXXXXX 100644 |
116 | --- a/target/arm/translate.c | 116 | --- a/target/arm/translate.c |
117 | +++ b/target/arm/translate.c | 117 | +++ b/target/arm/translate.c |
118 | @@ -XXX,XX +XXX,XX @@ static void gen_exception(int excp, uint32_t syndrome, uint32_t target_el) | 118 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void) |
119 | tcg_temp_free_i32(tcg_excp); | 119 | a64_translate_init(); |
120 | } | 120 | } |
121 | 121 | ||
122 | -static void gen_ss_advance(DisasContext *s) | 122 | +uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) |
123 | -{ | 123 | +{ |
124 | - /* If the singlestep state is Active-not-pending, advance to | 124 | + /* Expand the encoded constant as per AdvSIMDExpandImm pseudocode */ |
125 | - * Active-pending. | 125 | + switch (cmode) { |
126 | - */ | 126 | + case 0: case 1: |
127 | - if (s->ss_active) { | 127 | + /* no-op */ |
128 | - s->pstate_ss = 0; | 128 | + break; |
129 | - gen_helper_clear_pstate_ss(cpu_env); | 129 | + case 2: case 3: |
130 | - } | 130 | + imm <<= 8; |
131 | -} | 131 | + break; |
132 | - | 132 | + case 4: case 5: |
133 | static void gen_step_complete_exception(DisasContext *s) | 133 | + imm <<= 16; |
134 | + break; | ||
135 | + case 6: case 7: | ||
136 | + imm <<= 24; | ||
137 | + break; | ||
138 | + case 8: case 9: | ||
139 | + imm |= imm << 16; | ||
140 | + break; | ||
141 | + case 10: case 11: | ||
142 | + imm = (imm << 8) | (imm << 24); | ||
143 | + break; | ||
144 | + case 12: | ||
145 | + imm = (imm << 8) | 0xff; | ||
146 | + break; | ||
147 | + case 13: | ||
148 | + imm = (imm << 16) | 0xffff; | ||
149 | + break; | ||
150 | + case 14: | ||
151 | + if (op) { | ||
152 | + /* | ||
153 | + * This is the only case where the top and bottom 32 bits | ||
154 | + * of the encoded constant differ. | ||
155 | + */ | ||
156 | + uint64_t imm64 = 0; | ||
157 | + int n; | ||
158 | + | ||
159 | + for (n = 0; n < 8; n++) { | ||
160 | + if (imm & (1 << n)) { | ||
161 | + imm64 |= (0xffULL << (n * 8)); | ||
162 | + } | ||
163 | + } | ||
164 | + return imm64; | ||
165 | + } | ||
166 | + imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
167 | + break; | ||
168 | + case 15: | ||
169 | + imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
170 | + | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
171 | + break; | ||
172 | + } | ||
173 | + if (op) { | ||
174 | + imm = ~imm; | ||
175 | + } | ||
176 | + return dup_const(MO_32, imm); | ||
177 | +} | ||
178 | + | ||
179 | /* Generate a label used for skipping this instruction */ | ||
180 | void arm_gen_condlabel(DisasContext *s) | ||
134 | { | 181 | { |
135 | /* We just completed step of an insn. Move from Active-not-pending | ||
136 | -- | 182 | -- |
137 | 2.20.1 | 183 | 2.20.1 |
138 | 184 | ||
139 | 185 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The A64 AdvSIMD modified-immediate grouping uses almost the same |
---|---|---|---|
2 | constant encoding that A32 Neon does; reuse asimd_imm_const() (to | ||
3 | which we add the AArch64-specific case for cmode 15 op 1) instead of | ||
4 | reimplementing it all. | ||
2 | 5 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20190301200501.16533-3-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-5-peter.maydell@linaro.org | ||
7 | --- | 9 | --- |
8 | target/arm/cpu.h | 10 ++++++++++ | 10 | target/arm/translate.h | 3 +- |
9 | linux-user/elfload.c | 1 + | 11 | target/arm/translate-a64.c | 86 ++++---------------------------------- |
10 | target/arm/cpu.c | 1 + | 12 | target/arm/translate.c | 17 +++++++- |
11 | target/arm/cpu64.c | 2 ++ | 13 | 3 files changed, 24 insertions(+), 82 deletions(-) |
12 | target/arm/translate-a64.c | 14 ++++++++++++++ | ||
13 | target/arm/translate.c | 22 ++++++++++++++++++++++ | ||
14 | 6 files changed, 50 insertions(+) | ||
15 | 14 | ||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/translate.h |
19 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/translate.h |
20 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_fhm(const ARMISARegisters *id) | 19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc) |
21 | return FIELD_EX32(id->id_isar6, ID_ISAR6, FHM) != 0; | 20 | * VMVN and VBIC (when cmode < 14 && op == 1). |
22 | } | 21 | * |
23 | 22 | * The combination cmode == 15 op == 1 is a reserved encoding for AArch32; | |
24 | +static inline bool isar_feature_aa32_sb(const ARMISARegisters *id) | 23 | - * callers must catch this. |
25 | +{ | 24 | + * callers must catch this; we return the 64-bit constant value defined |
26 | + return FIELD_EX32(id->id_isar6, ID_ISAR6, SB) != 0; | 25 | + * for AArch64. |
27 | +} | 26 | * |
28 | + | 27 | * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but |
29 | static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) | 28 | * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A; |
30 | { | ||
31 | /* | ||
32 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id) | ||
33 | FIELD_DP64(0, ID_AA64ISAR1, GPI, 0xf))) != 0; | ||
34 | } | ||
35 | |||
36 | +static inline bool isar_feature_aa64_sb(const ARMISARegisters *id) | ||
37 | +{ | ||
38 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SB) != 0; | ||
39 | +} | ||
40 | + | ||
41 | static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) | ||
42 | { | ||
43 | /* We always set the AdvSIMD and FP fields identically wrt FP16. */ | ||
44 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/linux-user/elfload.c | ||
47 | +++ b/linux-user/elfload.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | ||
49 | GET_FEATURE_ID(aa64_pauth, ARM_HWCAP_A64_PACA | ARM_HWCAP_A64_PACG); | ||
50 | GET_FEATURE_ID(aa64_fhm, ARM_HWCAP_A64_ASIMDFHM); | ||
51 | GET_FEATURE_ID(aa64_jscvt, ARM_HWCAP_A64_JSCVT); | ||
52 | + GET_FEATURE_ID(aa64_sb, ARM_HWCAP_A64_SB); | ||
53 | |||
54 | #undef GET_FEATURE_ID | ||
55 | |||
56 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/cpu.c | ||
59 | +++ b/target/arm/cpu.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | ||
61 | t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); | ||
62 | t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
63 | t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
64 | + t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
65 | cpu->isar.id_isar6 = t; | ||
66 | |||
67 | t = cpu->id_mmfr4; | ||
68 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/target/arm/cpu64.c | ||
71 | +++ b/target/arm/cpu64.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
73 | t = FIELD_DP64(t, ID_AA64ISAR1, API, 0); | ||
74 | t = FIELD_DP64(t, ID_AA64ISAR1, GPA, 1); | ||
75 | t = FIELD_DP64(t, ID_AA64ISAR1, GPI, 0); | ||
76 | + t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); | ||
77 | cpu->isar.id_aa64isar1 = t; | ||
78 | |||
79 | t = cpu->isar.id_aa64pfr0; | ||
80 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
81 | u = FIELD_DP32(u, ID_ISAR6, JSCVT, 1); | ||
82 | u = FIELD_DP32(u, ID_ISAR6, DP, 1); | ||
83 | u = FIELD_DP32(u, ID_ISAR6, FHM, 1); | ||
84 | + u = FIELD_DP32(u, ID_ISAR6, SB, 1); | ||
85 | cpu->isar.id_isar6 = u; | ||
86 | |||
87 | /* | ||
88 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 29 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
89 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
90 | --- a/target/arm/translate-a64.c | 31 | --- a/target/arm/translate-a64.c |
91 | +++ b/target/arm/translate-a64.c | 32 | +++ b/target/arm/translate-a64.c |
92 | @@ -XXX,XX +XXX,XX @@ static void handle_sync(DisasContext *s, uint32_t insn, | 33 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) |
93 | reset_btype(s); | 34 | { |
94 | gen_goto_tb(s, 0, s->pc); | 35 | int rd = extract32(insn, 0, 5); |
95 | return; | 36 | int cmode = extract32(insn, 12, 4); |
96 | + | 37 | - int cmode_3_1 = extract32(cmode, 1, 3); |
97 | + case 7: /* SB */ | 38 | - int cmode_0 = extract32(cmode, 0, 1); |
98 | + if (crm != 0 || !dc_isar_feature(aa64_sb, s)) { | 39 | int o2 = extract32(insn, 11, 1); |
99 | + goto do_unallocated; | 40 | uint64_t abcdefgh = extract32(insn, 5, 5) | (extract32(insn, 16, 3) << 5); |
100 | + } | 41 | bool is_neg = extract32(insn, 29, 1); |
101 | + /* | 42 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) |
102 | + * TODO: There is no speculation barrier opcode for TCG; | ||
103 | + * MB and end the TB instead. | ||
104 | + */ | ||
105 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | ||
106 | + gen_goto_tb(s, 0, s->pc); | ||
107 | + return; | ||
108 | + | ||
109 | default: | ||
110 | + do_unallocated: | ||
111 | unallocated_encoding(s); | ||
112 | return; | 43 | return; |
113 | } | 44 | } |
45 | |||
46 | - /* See AdvSIMDExpandImm() in ARM ARM */ | ||
47 | - switch (cmode_3_1) { | ||
48 | - case 0: /* Replicate(Zeros(24):imm8, 2) */ | ||
49 | - case 1: /* Replicate(Zeros(16):imm8:Zeros(8), 2) */ | ||
50 | - case 2: /* Replicate(Zeros(8):imm8:Zeros(16), 2) */ | ||
51 | - case 3: /* Replicate(imm8:Zeros(24), 2) */ | ||
52 | - { | ||
53 | - int shift = cmode_3_1 * 8; | ||
54 | - imm = bitfield_replicate(abcdefgh << shift, 32); | ||
55 | - break; | ||
56 | - } | ||
57 | - case 4: /* Replicate(Zeros(8):imm8, 4) */ | ||
58 | - case 5: /* Replicate(imm8:Zeros(8), 4) */ | ||
59 | - { | ||
60 | - int shift = (cmode_3_1 & 0x1) * 8; | ||
61 | - imm = bitfield_replicate(abcdefgh << shift, 16); | ||
62 | - break; | ||
63 | - } | ||
64 | - case 6: | ||
65 | - if (cmode_0) { | ||
66 | - /* Replicate(Zeros(8):imm8:Ones(16), 2) */ | ||
67 | - imm = (abcdefgh << 16) | 0xffff; | ||
68 | - } else { | ||
69 | - /* Replicate(Zeros(16):imm8:Ones(8), 2) */ | ||
70 | - imm = (abcdefgh << 8) | 0xff; | ||
71 | - } | ||
72 | - imm = bitfield_replicate(imm, 32); | ||
73 | - break; | ||
74 | - case 7: | ||
75 | - if (!cmode_0 && !is_neg) { | ||
76 | - imm = bitfield_replicate(abcdefgh, 8); | ||
77 | - } else if (!cmode_0 && is_neg) { | ||
78 | - int i; | ||
79 | - imm = 0; | ||
80 | - for (i = 0; i < 8; i++) { | ||
81 | - if ((abcdefgh) & (1 << i)) { | ||
82 | - imm |= 0xffULL << (i * 8); | ||
83 | - } | ||
84 | - } | ||
85 | - } else if (cmode_0) { | ||
86 | - if (is_neg) { | ||
87 | - imm = (abcdefgh & 0x3f) << 48; | ||
88 | - if (abcdefgh & 0x80) { | ||
89 | - imm |= 0x8000000000000000ULL; | ||
90 | - } | ||
91 | - if (abcdefgh & 0x40) { | ||
92 | - imm |= 0x3fc0000000000000ULL; | ||
93 | - } else { | ||
94 | - imm |= 0x4000000000000000ULL; | ||
95 | - } | ||
96 | - } else { | ||
97 | - if (o2) { | ||
98 | - /* FMOV (vector, immediate) - half-precision */ | ||
99 | - imm = vfp_expand_imm(MO_16, abcdefgh); | ||
100 | - /* now duplicate across the lanes */ | ||
101 | - imm = bitfield_replicate(imm, 16); | ||
102 | - } else { | ||
103 | - imm = (abcdefgh & 0x3f) << 19; | ||
104 | - if (abcdefgh & 0x80) { | ||
105 | - imm |= 0x80000000; | ||
106 | - } | ||
107 | - if (abcdefgh & 0x40) { | ||
108 | - imm |= 0x3e000000; | ||
109 | - } else { | ||
110 | - imm |= 0x40000000; | ||
111 | - } | ||
112 | - imm |= (imm << 32); | ||
113 | - } | ||
114 | - } | ||
115 | - } | ||
116 | - break; | ||
117 | - default: | ||
118 | - g_assert_not_reached(); | ||
119 | - } | ||
120 | - | ||
121 | - if (cmode_3_1 != 7 && is_neg) { | ||
122 | - imm = ~imm; | ||
123 | + if (cmode == 15 && o2 && !is_neg) { | ||
124 | + /* FMOV (vector, immediate) - half-precision */ | ||
125 | + imm = vfp_expand_imm(MO_16, abcdefgh); | ||
126 | + /* now duplicate across the lanes */ | ||
127 | + imm = bitfield_replicate(imm, 16); | ||
128 | + } else { | ||
129 | + imm = asimd_imm_const(abcdefgh, cmode, is_neg); | ||
130 | } | ||
131 | |||
132 | if (!((cmode & 0x9) == 0x1 || (cmode & 0xd) == 0x9)) { | ||
114 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 133 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
115 | index XXXXXXX..XXXXXXX 100644 | 134 | index XXXXXXX..XXXXXXX 100644 |
116 | --- a/target/arm/translate.c | 135 | --- a/target/arm/translate.c |
117 | +++ b/target/arm/translate.c | 136 | +++ b/target/arm/translate.c |
118 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 137 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) |
119 | */ | 138 | case 14: |
120 | gen_goto_tb(s, 0, s->pc & ~1); | 139 | if (op) { |
121 | return; | 140 | /* |
122 | + case 7: /* sb */ | 141 | - * This is the only case where the top and bottom 32 bits |
123 | + if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | 142 | - * of the encoded constant differ. |
124 | + goto illegal_op; | 143 | + * This and cmode == 15 op == 1 are the only cases where |
125 | + } | 144 | + * the top and bottom 32 bits of the encoded constant differ. |
126 | + /* | 145 | */ |
127 | + * TODO: There is no speculation barrier opcode | 146 | uint64_t imm64 = 0; |
128 | + * for TCG; MB and end the TB instead. | 147 | int n; |
129 | + */ | 148 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) |
130 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | 149 | imm |= (imm << 8) | (imm << 16) | (imm << 24); |
131 | + gen_goto_tb(s, 0, s->pc & ~1); | 150 | break; |
132 | + return; | 151 | case 15: |
133 | default: | 152 | + if (op) { |
134 | goto illegal_op; | 153 | + /* Reserved encoding for AArch32; valid for AArch64 */ |
135 | } | 154 | + uint64_t imm64 = (uint64_t)(imm & 0x3f) << 48; |
136 | @@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) | 155 | + if (imm & 0x80) { |
137 | */ | 156 | + imm64 |= 0x8000000000000000ULL; |
138 | gen_goto_tb(s, 0, s->pc & ~1); | 157 | + } |
139 | break; | 158 | + if (imm & 0x40) { |
140 | + case 7: /* sb */ | 159 | + imm64 |= 0x3fc0000000000000ULL; |
141 | + if ((insn & 0xf) || !dc_isar_feature(aa32_sb, s)) { | 160 | + } else { |
142 | + goto illegal_op; | 161 | + imm64 |= 0x4000000000000000ULL; |
143 | + } | 162 | + } |
144 | + /* | 163 | + return imm64; |
145 | + * TODO: There is no speculation barrier opcode | 164 | + } |
146 | + * for TCG; MB and end the TB instead. | 165 | imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) |
147 | + */ | 166 | | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); |
148 | + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC); | 167 | break; |
149 | + gen_goto_tb(s, 0, s->pc & ~1); | ||
150 | + break; | ||
151 | default: | ||
152 | goto illegal_op; | ||
153 | } | ||
154 | -- | 168 | -- |
155 | 2.20.1 | 169 | 2.20.1 |
156 | 170 | ||
157 | 171 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Use dup_const() instead of bitfield_replicate() in |
---|---|---|---|
2 | disas_simd_mod_imm(). | ||
2 | 3 | ||
3 | This decoding more closely matches the ARMv8.4 Table C4-6, | 4 | (We can't replace the other use of bitfield_replicate() in this file, |
4 | Encoding table for Data Processing - Register Group. | 5 | in logic_imm_decode_wmask(), because that location needs to handle 2 |
6 | and 4 bit elements, which dup_const() cannot.) | ||
5 | 7 | ||
6 | In particular, op2 == 0 is now more than just Add/sub (with carry). | ||
7 | |||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20190301200501.16533-7-richard.henderson@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20210628135835.6690-6-peter.maydell@linaro.org | ||
12 | --- | 11 | --- |
13 | target/arm/translate-a64.c | 98 ++++++++++++++++++++++---------------- | 12 | target/arm/translate-a64.c | 2 +- |
14 | 1 file changed, 57 insertions(+), 41 deletions(-) | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
15 | 14 | ||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 17 | --- a/target/arm/translate-a64.c |
19 | +++ b/target/arm/translate-a64.c | 18 | +++ b/target/arm/translate-a64.c |
20 | @@ -XXX,XX +XXX,XX @@ static void disas_data_proc_3src(DisasContext *s, uint32_t insn) | 19 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) |
21 | } | 20 | /* FMOV (vector, immediate) - half-precision */ |
22 | 21 | imm = vfp_expand_imm(MO_16, abcdefgh); | |
23 | /* Add/subtract (with carry) | 22 | /* now duplicate across the lanes */ |
24 | - * 31 30 29 28 27 26 25 24 23 22 21 20 16 15 10 9 5 4 0 | 23 | - imm = bitfield_replicate(imm, 16); |
25 | - * +--+--+--+------------------------+------+---------+------+-----+ | 24 | + imm = dup_const(MO_16, imm); |
26 | - * |sf|op| S| 1 1 0 1 0 0 0 0 | rm | opcode2 | Rn | Rd | | 25 | } else { |
27 | - * +--+--+--+------------------------+------+---------+------+-----+ | 26 | imm = asimd_imm_const(abcdefgh, cmode, is_neg); |
28 | - * [000000] | ||
29 | + * 31 30 29 28 27 26 25 24 23 22 21 20 16 15 10 9 5 4 0 | ||
30 | + * +--+--+--+------------------------+------+-------------+------+-----+ | ||
31 | + * |sf|op| S| 1 1 0 1 0 0 0 0 | rm | 0 0 0 0 0 0 | Rn | Rd | | ||
32 | + * +--+--+--+------------------------+------+-------------+------+-----+ | ||
33 | */ | ||
34 | |||
35 | static void disas_adc_sbc(DisasContext *s, uint32_t insn) | ||
36 | @@ -XXX,XX +XXX,XX @@ static void disas_adc_sbc(DisasContext *s, uint32_t insn) | ||
37 | unsigned int sf, op, setflags, rm, rn, rd; | ||
38 | TCGv_i64 tcg_y, tcg_rn, tcg_rd; | ||
39 | |||
40 | - if (extract32(insn, 10, 6) != 0) { | ||
41 | - unallocated_encoding(s); | ||
42 | - return; | ||
43 | - } | ||
44 | - | ||
45 | sf = extract32(insn, 31, 1); | ||
46 | op = extract32(insn, 30, 1); | ||
47 | setflags = extract32(insn, 29, 1); | ||
48 | @@ -XXX,XX +XXX,XX @@ static void disas_data_proc_2src(DisasContext *s, uint32_t insn) | ||
49 | } | ||
50 | } | ||
51 | |||
52 | -/* Data processing - register */ | ||
53 | +/* | ||
54 | + * Data processing - register | ||
55 | + * 31 30 29 28 25 21 20 16 10 0 | ||
56 | + * +--+---+--+---+-------+-----+-------+-------+---------+ | ||
57 | + * | |op0| |op1| 1 0 1 | op2 | | op3 | | | ||
58 | + * +--+---+--+---+-------+-----+-------+-------+---------+ | ||
59 | + */ | ||
60 | static void disas_data_proc_reg(DisasContext *s, uint32_t insn) | ||
61 | { | ||
62 | - switch (extract32(insn, 24, 5)) { | ||
63 | - case 0x0a: /* Logical (shifted register) */ | ||
64 | - disas_logic_reg(s, insn); | ||
65 | - break; | ||
66 | - case 0x0b: /* Add/subtract */ | ||
67 | - if (insn & (1 << 21)) { /* (extended register) */ | ||
68 | - disas_add_sub_ext_reg(s, insn); | ||
69 | + int op0 = extract32(insn, 30, 1); | ||
70 | + int op1 = extract32(insn, 28, 1); | ||
71 | + int op2 = extract32(insn, 21, 4); | ||
72 | + int op3 = extract32(insn, 10, 6); | ||
73 | + | ||
74 | + if (!op1) { | ||
75 | + if (op2 & 8) { | ||
76 | + if (op2 & 1) { | ||
77 | + /* Add/sub (extended register) */ | ||
78 | + disas_add_sub_ext_reg(s, insn); | ||
79 | + } else { | ||
80 | + /* Add/sub (shifted register) */ | ||
81 | + disas_add_sub_reg(s, insn); | ||
82 | + } | ||
83 | } else { | ||
84 | - disas_add_sub_reg(s, insn); | ||
85 | + /* Logical (shifted register) */ | ||
86 | + disas_logic_reg(s, insn); | ||
87 | } | ||
88 | - break; | ||
89 | - case 0x1b: /* Data-processing (3 source) */ | ||
90 | - disas_data_proc_3src(s, insn); | ||
91 | - break; | ||
92 | - case 0x1a: | ||
93 | - switch (extract32(insn, 21, 3)) { | ||
94 | - case 0x0: /* Add/subtract (with carry) */ | ||
95 | + return; | ||
96 | + } | ||
97 | + | ||
98 | + switch (op2) { | ||
99 | + case 0x0: | ||
100 | + switch (op3) { | ||
101 | + case 0x00: /* Add/subtract (with carry) */ | ||
102 | disas_adc_sbc(s, insn); | ||
103 | break; | ||
104 | - case 0x2: /* Conditional compare */ | ||
105 | - disas_cc(s, insn); /* both imm and reg forms */ | ||
106 | - break; | ||
107 | - case 0x4: /* Conditional select */ | ||
108 | - disas_cond_select(s, insn); | ||
109 | - break; | ||
110 | - case 0x6: /* Data-processing */ | ||
111 | - if (insn & (1 << 30)) { /* (1 source) */ | ||
112 | - disas_data_proc_1src(s, insn); | ||
113 | - } else { /* (2 source) */ | ||
114 | - disas_data_proc_2src(s, insn); | ||
115 | - } | ||
116 | - break; | ||
117 | + | ||
118 | default: | ||
119 | - unallocated_encoding(s); | ||
120 | - break; | ||
121 | + goto do_unallocated; | ||
122 | } | ||
123 | break; | ||
124 | + | ||
125 | + case 0x2: /* Conditional compare */ | ||
126 | + disas_cc(s, insn); /* both imm and reg forms */ | ||
127 | + break; | ||
128 | + | ||
129 | + case 0x4: /* Conditional select */ | ||
130 | + disas_cond_select(s, insn); | ||
131 | + break; | ||
132 | + | ||
133 | + case 0x6: /* Data-processing */ | ||
134 | + if (op0) { /* (1 source) */ | ||
135 | + disas_data_proc_1src(s, insn); | ||
136 | + } else { /* (2 source) */ | ||
137 | + disas_data_proc_2src(s, insn); | ||
138 | + } | ||
139 | + break; | ||
140 | + case 0x8 ... 0xf: /* (3 source) */ | ||
141 | + disas_data_proc_3src(s, insn); | ||
142 | + break; | ||
143 | + | ||
144 | default: | ||
145 | + do_unallocated: | ||
146 | unallocated_encoding(s); | ||
147 | break; | ||
148 | } | 27 | } |
149 | -- | 28 | -- |
150 | 2.20.1 | 29 | 2.20.1 |
151 | 30 | ||
152 | 31 | diff view generated by jsdifflib |
1 | From: Michel Heily <michelheily@gmail.com> | 1 | Implement the MVE logical-immediate insns (VMOV, VMVN, |
---|---|---|---|
2 | VORR and VBIC). These have essentially the same encoding | ||
3 | as their Neon equivalents, and we implement the decode | ||
4 | in the same way. | ||
2 | 5 | ||
3 | Implement the watchdog timer for the stellaris boards. | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | This device is a close variant of the CMSDK APB watchdog | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | device, so we can model it by subclassing that device and | 8 | Message-id: 20210628135835.6690-7-peter.maydell@linaro.org |
6 | tweaking the behaviour of some of its registers. | 9 | --- |
10 | target/arm/helper-mve.h | 4 +++ | ||
11 | target/arm/mve.decode | 17 +++++++++++++ | ||
12 | target/arm/mve_helper.c | 24 ++++++++++++++++++ | ||
13 | target/arm/translate-mve.c | 50 ++++++++++++++++++++++++++++++++++++++ | ||
14 | 4 files changed, 95 insertions(+) | ||
7 | 15 | ||
8 | Signed-off-by: Michel Heily <michelheily@gmail.com> | 16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
9 | Reviewed-by: Peter Maydell <petser.maydell@linaro.org> | ||
10 | [PMM: rewrote commit message, fixed a few checkpatch nits, | ||
11 | added comment giving the URL of the spec for the Stellaris | ||
12 | variant of the watchdog device] | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | include/hw/watchdog/cmsdk-apb-watchdog.h | 8 +++ | ||
16 | hw/arm/stellaris.c | 22 ++++++- | ||
17 | hw/watchdog/cmsdk-apb-watchdog.c | 74 +++++++++++++++++++++++- | ||
18 | 3 files changed, 100 insertions(+), 4 deletions(-) | ||
19 | |||
20 | diff --git a/include/hw/watchdog/cmsdk-apb-watchdog.h b/include/hw/watchdog/cmsdk-apb-watchdog.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/watchdog/cmsdk-apb-watchdog.h | 18 | --- a/target/arm/helper-mve.h |
23 | +++ b/include/hw/watchdog/cmsdk-apb-watchdog.h | 19 | +++ b/target/arm/helper-mve.h |
20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
21 | DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
22 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
23 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
24 | + | ||
25 | +DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
26 | +DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
27 | +DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
28 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/mve.decode | ||
31 | +++ b/target/arm/mve.decode | ||
24 | @@ -XXX,XX +XXX,XX @@ | 32 | @@ -XXX,XX +XXX,XX @@ |
25 | #define CMSDK_APB_WATCHDOG(obj) OBJECT_CHECK(CMSDKAPBWatchdog, (obj), \ | 33 | # VQDMULL has size in bit 28: 0 for 16 bit, 1 for 32 bit |
26 | TYPE_CMSDK_APB_WATCHDOG) | 34 | %size_28 28:1 !function=plus_1 |
35 | |||
36 | +# 1imm format immediate | ||
37 | +%imm_28_16_0 28:1 16:3 0:4 | ||
38 | + | ||
39 | &vldr_vstr rn qd imm p a w size l u | ||
40 | &1op qd qm size | ||
41 | &2op qd qm qn size | ||
42 | &2scalar qd qn rm size | ||
43 | +&1imm qd imm cmode op | ||
44 | |||
45 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
46 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
47 | @@ -XXX,XX +XXX,XX @@ | ||
48 | @2op_nosz .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn size=0 | ||
49 | @2op_sz28 .... .... .... .... .... .... .... .... &2op qd=%qd qm=%qm qn=%qn \ | ||
50 | size=%size_28 | ||
51 | +@1imm .... .... .... .... .... cmode:4 .. op:1 . .... &1imm qd=%qd imm=%imm_28_16_0 | ||
52 | |||
53 | # The _rev suffix indicates that Vn and Vm are reversed. This is | ||
54 | # the case for shifts. In the Arm ARM these insns are documented | ||
55 | @@ -XXX,XX +XXX,XX @@ VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rd | ||
56 | # Predicate operations | ||
57 | %mask_22_13 22:1 13:3 | ||
58 | VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
59 | + | ||
60 | +# Logical immediate operations (1 reg and modified-immediate) | ||
61 | + | ||
62 | +# The cmode/op bits here decode VORR/VBIC/VMOV/VMVN, but | ||
63 | +# not in a way we can conveniently represent in decodetree without | ||
64 | +# a lot of repetition: | ||
65 | +# VORR: op=0, (cmode & 1) && cmode < 12 | ||
66 | +# VBIC: op=1, (cmode & 1) && cmode < 12 | ||
67 | +# VMOV: everything else | ||
68 | +# So we have a single decode line and check the cmode/op in the | ||
69 | +# trans function. | ||
70 | +Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm | ||
71 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/mve_helper.c | ||
74 | +++ b/target/arm/mve_helper.c | ||
75 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vnegw, 4, int32_t, DO_NEG) | ||
76 | DO_1OP(vfnegh, 8, uint64_t, DO_FNEGH) | ||
77 | DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS) | ||
27 | 78 | ||
28 | +/* | 79 | +/* |
29 | + * This shares the same struct (and cast macro) as the base | 80 | + * 1 operand immediates: Vda is destination and possibly also one source. |
30 | + * cmsdk-apb-watchdog device. | 81 | + * All these insns work at 64-bit widths. |
31 | + */ | 82 | + */ |
32 | +#define TYPE_LUMINARY_WATCHDOG "luminary-watchdog" | 83 | +#define DO_1OP_IMM(OP, FN) \ |
33 | + | 84 | + void HELPER(mve_##OP)(CPUARMState *env, void *vda, uint64_t imm) \ |
34 | typedef struct CMSDKAPBWatchdog { | 85 | + { \ |
35 | /*< private >*/ | 86 | + uint64_t *da = vda; \ |
36 | SysBusDevice parent_obj; | 87 | + uint16_t mask = mve_element_mask(env); \ |
37 | @@ -XXX,XX +XXX,XX @@ typedef struct CMSDKAPBWatchdog { | 88 | + unsigned e; \ |
38 | MemoryRegion iomem; | 89 | + for (e = 0; e < 16 / 8; e++, mask >>= 8) { \ |
39 | qemu_irq wdogint; | 90 | + mergemask(&da[H8(e)], FN(da[H8(e)], imm), mask); \ |
40 | uint32_t wdogclk_frq; | 91 | + } \ |
41 | + bool is_luminary; | 92 | + mve_advance_vpt(env); \ |
42 | struct ptimer_state *timer; | ||
43 | |||
44 | uint32_t control; | ||
45 | @@ -XXX,XX +XXX,XX @@ typedef struct CMSDKAPBWatchdog { | ||
46 | uint32_t itcr; | ||
47 | uint32_t itop; | ||
48 | uint32_t resetstatus; | ||
49 | + const uint32_t *id; | ||
50 | } CMSDKAPBWatchdog; | ||
51 | |||
52 | #endif | ||
53 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/hw/arm/stellaris.c | ||
56 | +++ b/hw/arm/stellaris.c | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | #include "sysemu/sysemu.h" | ||
59 | #include "hw/arm/armv7m.h" | ||
60 | #include "hw/char/pl011.h" | ||
61 | +#include "hw/watchdog/cmsdk-apb-watchdog.h" | ||
62 | #include "hw/misc/unimp.h" | ||
63 | #include "cpu.h" | ||
64 | |||
65 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
66 | * Stellaris LM3S6965 Microcontroller Data Sheet (rev I) | ||
67 | * http://www.ti.com/lit/ds/symlink/lm3s6965.pdf | ||
68 | * | ||
69 | - * 40000000 wdtimer (unimplemented) | ||
70 | + * 40000000 wdtimer | ||
71 | * 40002000 i2c (unimplemented) | ||
72 | * 40004000 GPIO | ||
73 | * 40005000 GPIO | ||
74 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
75 | stellaris_sys_init(0x400fe000, qdev_get_gpio_in(nvic, 28), | ||
76 | board, nd_table[0].macaddr.a); | ||
77 | |||
78 | + | ||
79 | + if (board->dc1 & (1 << 3)) { /* watchdog present */ | ||
80 | + dev = qdev_create(NULL, TYPE_LUMINARY_WATCHDOG); | ||
81 | + | ||
82 | + /* system_clock_scale is valid now */ | ||
83 | + uint32_t mainclk = NANOSECONDS_PER_SECOND / system_clock_scale; | ||
84 | + qdev_prop_set_uint32(dev, "wdogclk-frq", mainclk); | ||
85 | + | ||
86 | + qdev_init_nofail(dev); | ||
87 | + sysbus_mmio_map(SYS_BUS_DEVICE(dev), | ||
88 | + 0, | ||
89 | + 0x40000000u); | ||
90 | + sysbus_connect_irq(SYS_BUS_DEVICE(dev), | ||
91 | + 0, | ||
92 | + qdev_get_gpio_in(nvic, 18)); | ||
93 | + } | 93 | + } |
94 | + | 94 | + |
95 | +#define DO_MOVI(N, I) (I) | ||
96 | +#define DO_ANDI(N, I) ((N) & (I)) | ||
97 | +#define DO_ORRI(N, I) ((N) | (I)) | ||
95 | + | 98 | + |
96 | for (i = 0; i < 7; i++) { | 99 | +DO_1OP_IMM(vmovi, DO_MOVI) |
97 | if (board->dc4 & (1 << i)) { | 100 | +DO_1OP_IMM(vandi, DO_ANDI) |
98 | gpio_dev[i] = sysbus_create_simple("pl061_luminary", gpio_addr[i], | 101 | +DO_1OP_IMM(vorri, DO_ORRI) |
99 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | 102 | + |
100 | /* Add dummy regions for the devices we don't implement yet, | 103 | #define DO_2OP(OP, ESIZE, TYPE, FN) \ |
101 | * so guest accesses don't cause unlogged crashes. | 104 | void HELPER(glue(mve_, OP))(CPUARMState *env, \ |
102 | */ | 105 | void *vd, void *vn, void *vm) \ |
103 | - create_unimplemented_device("wdtimer", 0x40000000, 0x1000); | 106 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
104 | create_unimplemented_device("i2c-0", 0x40002000, 0x1000); | ||
105 | create_unimplemented_device("i2c-2", 0x40021000, 0x1000); | ||
106 | create_unimplemented_device("PWM", 0x40028000, 0x1000); | ||
107 | diff --git a/hw/watchdog/cmsdk-apb-watchdog.c b/hw/watchdog/cmsdk-apb-watchdog.c | ||
108 | index XXXXXXX..XXXXXXX 100644 | 107 | index XXXXXXX..XXXXXXX 100644 |
109 | --- a/hw/watchdog/cmsdk-apb-watchdog.c | 108 | --- a/target/arm/translate-mve.c |
110 | +++ b/hw/watchdog/cmsdk-apb-watchdog.c | 109 | +++ b/target/arm/translate-mve.c |
111 | @@ -XXX,XX +XXX,XX @@ | 110 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); |
112 | * System Design Kit (CMSDK) and documented in the Cortex-M System | 111 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); |
113 | * Design Kit Technical Reference Manual (ARM DDI0479C): | 112 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); |
114 | * https://developer.arm.com/products/system-design/system-design-kits/cortex-m-system-design-kit | 113 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); |
115 | + * | 114 | +typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); |
116 | + * We also support the variant of this device found in the TI | 115 | |
117 | + * Stellaris/Luminary boards and documented in: | 116 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ |
118 | + * http://www.ti.com/lit/ds/symlink/lm3s6965.pdf | 117 | static inline long mve_qreg_offset(unsigned reg) |
119 | */ | 118 | @@ -XXX,XX +XXX,XX @@ static bool trans_VADDV(DisasContext *s, arg_VADDV *a) |
120 | 119 | mve_update_eci(s); | |
121 | #include "qemu/osdep.h" | 120 | return true; |
122 | @@ -XXX,XX +XXX,XX @@ REG32(WDOGINTCLR, 0xc) | 121 | } |
123 | REG32(WDOGRIS, 0x10) | ||
124 | FIELD(WDOGRIS, INT, 0, 1) | ||
125 | REG32(WDOGMIS, 0x14) | ||
126 | +REG32(WDOGTEST, 0x418) /* only in Stellaris/Luminary version of the device */ | ||
127 | REG32(WDOGLOCK, 0xc00) | ||
128 | #define WDOG_UNLOCK_VALUE 0x1ACCE551 | ||
129 | REG32(WDOGITCR, 0xf00) | ||
130 | @@ -XXX,XX +XXX,XX @@ REG32(CID2, 0xff8) | ||
131 | REG32(CID3, 0xffc) | ||
132 | |||
133 | /* PID/CID values */ | ||
134 | -static const int watchdog_id[] = { | ||
135 | +static const uint32_t cmsdk_apb_watchdog_id[] = { | ||
136 | 0x04, 0x00, 0x00, 0x00, /* PID4..PID7 */ | ||
137 | 0x24, 0xb8, 0x1b, 0x00, /* PID0..PID3 */ | ||
138 | 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */ | ||
139 | }; | ||
140 | |||
141 | +static const uint32_t luminary_watchdog_id[] = { | ||
142 | + 0x00, 0x00, 0x00, 0x00, /* PID4..PID7 */ | ||
143 | + 0x05, 0x18, 0x18, 0x01, /* PID0..PID3 */ | ||
144 | + 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */ | ||
145 | +}; | ||
146 | + | 122 | + |
147 | static bool cmsdk_apb_watchdog_intstatus(CMSDKAPBWatchdog *s) | 123 | +static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn) |
148 | { | 124 | +{ |
149 | /* Return masked interrupt status */ | 125 | + TCGv_ptr qd; |
150 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_update(CMSDKAPBWatchdog *s) | 126 | + uint64_t imm; |
151 | bool wdogres; | ||
152 | |||
153 | if (s->itcr) { | ||
154 | + /* | ||
155 | + * Not checking that !s->is_luminary since s->itcr can't be written | ||
156 | + * when s->is_luminary in the first place. | ||
157 | + */ | ||
158 | wdogint = s->itop & R_WDOGITOP_WDOGINT_MASK; | ||
159 | wdogres = s->itop & R_WDOGITOP_WDOGRES_MASK; | ||
160 | } else { | ||
161 | @@ -XXX,XX +XXX,XX @@ static uint64_t cmsdk_apb_watchdog_read(void *opaque, hwaddr offset, | ||
162 | r = s->lock; | ||
163 | break; | ||
164 | case A_WDOGITCR: | ||
165 | + if (s->is_luminary) { | ||
166 | + goto bad_offset; | ||
167 | + } | ||
168 | r = s->itcr; | ||
169 | break; | ||
170 | case A_PID4 ... A_CID3: | ||
171 | - r = watchdog_id[(offset - A_PID4) / 4]; | ||
172 | + r = s->id[(offset - A_PID4) / 4]; | ||
173 | break; | ||
174 | case A_WDOGINTCLR: | ||
175 | case A_WDOGITOP: | ||
176 | + if (s->is_luminary) { | ||
177 | + goto bad_offset; | ||
178 | + } | ||
179 | qemu_log_mask(LOG_GUEST_ERROR, | ||
180 | "CMSDK APB watchdog read: read of WO offset %x\n", | ||
181 | (int)offset); | ||
182 | r = 0; | ||
183 | break; | ||
184 | + case A_WDOGTEST: | ||
185 | + if (!s->is_luminary) { | ||
186 | + goto bad_offset; | ||
187 | + } | ||
188 | + qemu_log_mask(LOG_UNIMP, | ||
189 | + "Luminary watchdog read: stall not implemented\n"); | ||
190 | + r = 0; | ||
191 | + break; | ||
192 | default: | ||
193 | +bad_offset: | ||
194 | qemu_log_mask(LOG_GUEST_ERROR, | ||
195 | "CMSDK APB watchdog read: bad offset %x\n", (int)offset); | ||
196 | r = 0; | ||
197 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_write(void *opaque, hwaddr offset, | ||
198 | ptimer_run(s->timer, 0); | ||
199 | break; | ||
200 | case A_WDOGCONTROL: | ||
201 | + if (s->is_luminary && 0 != (R_WDOGCONTROL_INTEN_MASK & s->control)) { | ||
202 | + /* | ||
203 | + * The Luminary version of this device ignores writes to | ||
204 | + * this register after the guest has enabled interrupts | ||
205 | + * (so they can only be disabled again via reset). | ||
206 | + */ | ||
207 | + break; | ||
208 | + } | ||
209 | s->control = value & R_WDOGCONTROL_VALID_MASK; | ||
210 | cmsdk_apb_watchdog_update(s); | ||
211 | break; | ||
212 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_write(void *opaque, hwaddr offset, | ||
213 | s->lock = (value != WDOG_UNLOCK_VALUE); | ||
214 | break; | ||
215 | case A_WDOGITCR: | ||
216 | + if (s->is_luminary) { | ||
217 | + goto bad_offset; | ||
218 | + } | ||
219 | s->itcr = value & R_WDOGITCR_VALID_MASK; | ||
220 | cmsdk_apb_watchdog_update(s); | ||
221 | break; | ||
222 | case A_WDOGITOP: | ||
223 | + if (s->is_luminary) { | ||
224 | + goto bad_offset; | ||
225 | + } | ||
226 | s->itop = value & R_WDOGITOP_VALID_MASK; | ||
227 | cmsdk_apb_watchdog_update(s); | ||
228 | break; | ||
229 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_write(void *opaque, hwaddr offset, | ||
230 | "CMSDK APB watchdog write: write to RO offset 0x%x\n", | ||
231 | (int)offset); | ||
232 | break; | ||
233 | + case A_WDOGTEST: | ||
234 | + if (!s->is_luminary) { | ||
235 | + goto bad_offset; | ||
236 | + } | ||
237 | + qemu_log_mask(LOG_UNIMP, | ||
238 | + "Luminary watchdog write: stall not implemented\n"); | ||
239 | + break; | ||
240 | default: | ||
241 | +bad_offset: | ||
242 | qemu_log_mask(LOG_GUEST_ERROR, | ||
243 | "CMSDK APB watchdog write: bad offset 0x%x\n", | ||
244 | (int)offset); | ||
245 | @@ -XXX,XX +XXX,XX @@ static void cmsdk_apb_watchdog_init(Object *obj) | ||
246 | s, "cmsdk-apb-watchdog", 0x1000); | ||
247 | sysbus_init_mmio(sbd, &s->iomem); | ||
248 | sysbus_init_irq(sbd, &s->wdogint); | ||
249 | + | 127 | + |
250 | + s->is_luminary = false; | 128 | + if (!dc_isar_feature(aa32_mve, s) || |
251 | + s->id = cmsdk_apb_watchdog_id; | 129 | + !mve_check_qreg_bank(s, a->qd) || |
252 | } | 130 | + !fn) { |
253 | 131 | + return false; | |
254 | static void cmsdk_apb_watchdog_realize(DeviceState *dev, Error **errp) | 132 | + } |
255 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo cmsdk_apb_watchdog_info = { | 133 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
256 | .class_init = cmsdk_apb_watchdog_class_init, | 134 | + return true; |
257 | }; | 135 | + } |
258 | |||
259 | +static void luminary_watchdog_init(Object *obj) | ||
260 | +{ | ||
261 | + CMSDKAPBWatchdog *s = CMSDK_APB_WATCHDOG(obj); | ||
262 | + | 136 | + |
263 | + s->is_luminary = true; | 137 | + imm = asimd_imm_const(a->imm, a->cmode, a->op); |
264 | + s->id = luminary_watchdog_id; | 138 | + |
139 | + qd = mve_qreg_ptr(a->qd); | ||
140 | + fn(cpu_env, qd, tcg_constant_i64(imm)); | ||
141 | + tcg_temp_free_ptr(qd); | ||
142 | + mve_update_eci(s); | ||
143 | + return true; | ||
265 | +} | 144 | +} |
266 | + | 145 | + |
267 | +static const TypeInfo luminary_watchdog_info = { | 146 | +static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a) |
268 | + .name = TYPE_LUMINARY_WATCHDOG, | 147 | +{ |
269 | + .parent = TYPE_CMSDK_APB_WATCHDOG, | 148 | + /* Handle decode of cmode/op here between VORR/VBIC/VMOV */ |
270 | + .instance_init = luminary_watchdog_init | 149 | + MVEGenOneOpImmFn *fn; |
271 | +}; | ||
272 | + | 150 | + |
273 | static void cmsdk_apb_watchdog_register_types(void) | 151 | + if ((a->cmode & 1) && a->cmode < 12) { |
274 | { | 152 | + if (a->op) { |
275 | type_register_static(&cmsdk_apb_watchdog_info); | 153 | + /* |
276 | + type_register_static(&luminary_watchdog_info); | 154 | + * For op=1, the immediate will be inverted by asimd_imm_const(), |
277 | } | 155 | + * so the VBIC becomes a logical AND operation. |
278 | 156 | + */ | |
279 | type_init(cmsdk_apb_watchdog_register_types); | 157 | + fn = gen_helper_mve_vandi; |
158 | + } else { | ||
159 | + fn = gen_helper_mve_vorri; | ||
160 | + } | ||
161 | + } else { | ||
162 | + /* There is one unallocated cmode/op combination in this space */ | ||
163 | + if (a->cmode == 15 && a->op == 1) { | ||
164 | + return false; | ||
165 | + } | ||
166 | + /* asimd_imm_const() sorts out VMVNI vs VMOVI for us */ | ||
167 | + fn = gen_helper_mve_vmovi; | ||
168 | + } | ||
169 | + return do_1imm(s, a, fn); | ||
170 | +} | ||
280 | -- | 171 | -- |
281 | 2.20.1 | 172 | 2.20.1 |
282 | 173 | ||
283 | 174 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | Implement the MVE shift-vector-left-by-immediate insns VSHL, VQSHL |
---|---|---|---|
2 | 2 | and VQSHLU. | |
3 | Add the kvm_arm_get_max_vm_ipa_size() helper that returns the | 3 | |
4 | number of bits in the IPA address space supported by KVM. | 4 | The size-and-immediate encoding here is the same as Neon, and we |
5 | 5 | handle it the same way neon-dp.decode does. | |
6 | This capability needs to be known to create the VM with a | 6 | |
7 | specific IPA max size (kvm_type passed along KVM_CREATE_VM ioctl. | ||
8 | |||
9 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
10 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
11 | Message-id: 20190304101339.25970-6-eric.auger@redhat.com | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210628135835.6690-8-peter.maydell@linaro.org | ||
13 | --- | 10 | --- |
14 | target/arm/kvm_arm.h | 13 +++++++++++++ | 11 | target/arm/helper-mve.h | 16 +++++++++++ |
15 | target/arm/kvm.c | 10 ++++++++++ | 12 | target/arm/mve.decode | 23 +++++++++++++++ |
16 | 2 files changed, 23 insertions(+) | 13 | target/arm/mve_helper.c | 57 ++++++++++++++++++++++++++++++++++++++ |
17 | 14 | target/arm/translate-mve.c | 51 ++++++++++++++++++++++++++++++++++ | |
18 | diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h | 15 | 4 files changed, 147 insertions(+) |
19 | index XXXXXXX..XXXXXXX 100644 | 16 | |
20 | --- a/target/arm/kvm_arm.h | 17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
21 | +++ b/target/arm/kvm_arm.h | 18 | index XXXXXXX..XXXXXXX 100644 |
22 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf); | 19 | --- a/target/arm/helper-mve.h |
23 | */ | 20 | +++ b/target/arm/helper-mve.h |
24 | void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); | 21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
25 | 22 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | |
26 | +/** | 23 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) |
27 | + * kvm_arm_get_max_vm_ipa_size - Returns the number of bits in the | 24 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) |
28 | + * IPA address space supported by KVM | 25 | + |
29 | + * | 26 | +DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
30 | + * @ms: Machine state handle | 27 | +DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
31 | + */ | 28 | +DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
32 | +int kvm_arm_get_max_vm_ipa_size(MachineState *ms); | 29 | + |
33 | + | 30 | +DEF_HELPER_FLAGS_4(mve_vqshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
34 | /** | 31 | +DEF_HELPER_FLAGS_4(mve_vqshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
35 | * kvm_arm_sync_mpstate_to_kvm | 32 | +DEF_HELPER_FLAGS_4(mve_vqshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
36 | * @cpu: ARMCPU | 33 | + |
37 | @@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) | 34 | +DEF_HELPER_FLAGS_4(mve_vqshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
38 | cpu->host_cpu_probe_failed = true; | 35 | +DEF_HELPER_FLAGS_4(mve_vqshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
36 | +DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | + | ||
38 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/mve.decode | ||
44 | +++ b/target/arm/mve.decode | ||
45 | @@ -XXX,XX +XXX,XX @@ | ||
46 | &2op qd qm qn size | ||
47 | &2scalar qd qn rm size | ||
48 | &1imm qd imm cmode op | ||
49 | +&2shift qd qm shift size | ||
50 | |||
51 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 | ||
52 | # Note that both Rn and Qd are 3 bits only (no D bit) | ||
53 | @@ -XXX,XX +XXX,XX @@ | ||
54 | @2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | ||
55 | @2scalar_nosz .... .... .... .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn | ||
56 | |||
57 | +@2_shl_b .... .... .. 001 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0 | ||
58 | +@2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | ||
59 | +@2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | ||
60 | + | ||
61 | # Vector loads and stores | ||
62 | |||
63 | # Widening loads and narrowing stores: | ||
64 | @@ -XXX,XX +XXX,XX @@ VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 | ||
65 | # So we have a single decode line and check the cmode/op in the | ||
66 | # trans function. | ||
67 | Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm | ||
68 | + | ||
69 | +# Shifts by immediate | ||
70 | + | ||
71 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | ||
72 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | ||
73 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | ||
74 | + | ||
75 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b | ||
76 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h | ||
77 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
78 | + | ||
79 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b | ||
80 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h | ||
81 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
82 | + | ||
83 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b | ||
84 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h | ||
85 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w | ||
86 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/target/arm/mve_helper.c | ||
89 | +++ b/target/arm/mve_helper.c | ||
90 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT(vqsubsw, 4, int32_t, DO_SQSUB_W) | ||
91 | WRAP_QRSHL_HELPER(do_sqrshl_bhs, N, M, true, satp) | ||
92 | #define DO_UQRSHL_OP(N, M, satp) \ | ||
93 | WRAP_QRSHL_HELPER(do_uqrshl_bhs, N, M, true, satp) | ||
94 | +#define DO_SUQSHL_OP(N, M, satp) \ | ||
95 | + WRAP_QRSHL_HELPER(do_suqrshl_bhs, N, M, false, satp) | ||
96 | |||
97 | DO_2OP_SAT_S(vqshls, DO_SQSHL_OP) | ||
98 | DO_2OP_SAT_U(vqshlu, DO_UQSHL_OP) | ||
99 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvsw, 4, uint32_t) | ||
100 | DO_VADDV(vaddvub, 1, uint8_t) | ||
101 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
102 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
103 | + | ||
104 | +/* Shifts by immediate */ | ||
105 | +#define DO_2SHIFT(OP, ESIZE, TYPE, FN) \ | ||
106 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
107 | + void *vm, uint32_t shift) \ | ||
108 | + { \ | ||
109 | + TYPE *d = vd, *m = vm; \ | ||
110 | + uint16_t mask = mve_element_mask(env); \ | ||
111 | + unsigned e; \ | ||
112 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
113 | + mergemask(&d[H##ESIZE(e)], \ | ||
114 | + FN(m[H##ESIZE(e)], shift), mask); \ | ||
115 | + } \ | ||
116 | + mve_advance_vpt(env); \ | ||
117 | + } | ||
118 | + | ||
119 | +#define DO_2SHIFT_SAT(OP, ESIZE, TYPE, FN) \ | ||
120 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
121 | + void *vm, uint32_t shift) \ | ||
122 | + { \ | ||
123 | + TYPE *d = vd, *m = vm; \ | ||
124 | + uint16_t mask = mve_element_mask(env); \ | ||
125 | + unsigned e; \ | ||
126 | + bool qc = false; \ | ||
127 | + for (e = 0; e < 16 / ESIZE; e++, mask >>= ESIZE) { \ | ||
128 | + bool sat = false; \ | ||
129 | + mergemask(&d[H##ESIZE(e)], \ | ||
130 | + FN(m[H##ESIZE(e)], shift, &sat), mask); \ | ||
131 | + qc |= sat & mask & 1; \ | ||
132 | + } \ | ||
133 | + if (qc) { \ | ||
134 | + env->vfp.qc[0] = qc; \ | ||
135 | + } \ | ||
136 | + mve_advance_vpt(env); \ | ||
137 | + } | ||
138 | + | ||
139 | +/* provide unsigned 2-op shift helpers for all sizes */ | ||
140 | +#define DO_2SHIFT_U(OP, FN) \ | ||
141 | + DO_2SHIFT(OP##b, 1, uint8_t, FN) \ | ||
142 | + DO_2SHIFT(OP##h, 2, uint16_t, FN) \ | ||
143 | + DO_2SHIFT(OP##w, 4, uint32_t, FN) | ||
144 | + | ||
145 | +#define DO_2SHIFT_SAT_U(OP, FN) \ | ||
146 | + DO_2SHIFT_SAT(OP##b, 1, uint8_t, FN) \ | ||
147 | + DO_2SHIFT_SAT(OP##h, 2, uint16_t, FN) \ | ||
148 | + DO_2SHIFT_SAT(OP##w, 4, uint32_t, FN) | ||
149 | +#define DO_2SHIFT_SAT_S(OP, FN) \ | ||
150 | + DO_2SHIFT_SAT(OP##b, 1, int8_t, FN) \ | ||
151 | + DO_2SHIFT_SAT(OP##h, 2, int16_t, FN) \ | ||
152 | + DO_2SHIFT_SAT(OP##w, 4, int32_t, FN) | ||
153 | + | ||
154 | +DO_2SHIFT_U(vshli_u, DO_VSHLU) | ||
155 | +DO_2SHIFT_SAT_U(vqshli_u, DO_UQSHL_OP) | ||
156 | +DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
157 | +DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
158 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
159 | index XXXXXXX..XXXXXXX 100644 | ||
160 | --- a/target/arm/translate-mve.c | ||
161 | +++ b/target/arm/translate-mve.c | ||
162 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenLdStFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
163 | typedef void MVEGenOneOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
164 | typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
165 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
166 | +typedef void MVEGenTwoOpShiftFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
167 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
168 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
169 | typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); | ||
170 | @@ -XXX,XX +XXX,XX @@ static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a) | ||
171 | } | ||
172 | return do_1imm(s, a, fn); | ||
39 | } | 173 | } |
40 | 174 | + | |
41 | +static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | 175 | +static bool do_2shift(DisasContext *s, arg_2shift *a, MVEGenTwoOpShiftFn fn, |
176 | + bool negateshift) | ||
42 | +{ | 177 | +{ |
43 | + return -ENOENT; | 178 | + TCGv_ptr qd, qm; |
179 | + int shift = a->shift; | ||
180 | + | ||
181 | + if (!dc_isar_feature(aa32_mve, s) || | ||
182 | + !mve_check_qreg_bank(s, a->qd | a->qm) || | ||
183 | + !fn) { | ||
184 | + return false; | ||
185 | + } | ||
186 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
187 | + return true; | ||
188 | + } | ||
189 | + | ||
190 | + /* | ||
191 | + * When we handle a right shift insn using a left-shift helper | ||
192 | + * which permits a negative shift count to indicate a right-shift, | ||
193 | + * we must negate the shift count. | ||
194 | + */ | ||
195 | + if (negateshift) { | ||
196 | + shift = -shift; | ||
197 | + } | ||
198 | + | ||
199 | + qd = mve_qreg_ptr(a->qd); | ||
200 | + qm = mve_qreg_ptr(a->qm); | ||
201 | + fn(cpu_env, qd, qm, tcg_constant_i32(shift)); | ||
202 | + tcg_temp_free_ptr(qd); | ||
203 | + tcg_temp_free_ptr(qm); | ||
204 | + mve_update_eci(s); | ||
205 | + return true; | ||
44 | +} | 206 | +} |
45 | + | 207 | + |
46 | static inline int kvm_arm_vgic_probe(void) | 208 | +#define DO_2SHIFT(INSN, FN, NEGATESHIFT) \ |
47 | { | 209 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ |
48 | return 0; | 210 | + { \ |
49 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | 211 | + static MVEGenTwoOpShiftFn * const fns[] = { \ |
50 | index XXXXXXX..XXXXXXX 100644 | 212 | + gen_helper_mve_##FN##b, \ |
51 | --- a/target/arm/kvm.c | 213 | + gen_helper_mve_##FN##h, \ |
52 | +++ b/target/arm/kvm.c | 214 | + gen_helper_mve_##FN##w, \ |
53 | @@ -XXX,XX +XXX,XX @@ | 215 | + NULL, \ |
54 | #include "qemu/error-report.h" | 216 | + }; \ |
55 | #include "sysemu/sysemu.h" | 217 | + return do_2shift(s, a, fns[a->size], NEGATESHIFT); \ |
56 | #include "sysemu/kvm.h" | 218 | + } |
57 | +#include "sysemu/kvm_int.h" | 219 | + |
58 | #include "kvm_arm.h" | 220 | +DO_2SHIFT(VSHLI, vshli_u, false) |
59 | #include "cpu.h" | 221 | +DO_2SHIFT(VQSHLI_S, vqshli_s, false) |
60 | #include "trace.h" | 222 | +DO_2SHIFT(VQSHLI_U, vqshli_u, false) |
61 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) | 223 | +DO_2SHIFT(VQSHLUI, vqshlui_s, false) |
62 | env->features = arm_host_cpu_features.features; | ||
63 | } | ||
64 | |||
65 | +int kvm_arm_get_max_vm_ipa_size(MachineState *ms) | ||
66 | +{ | ||
67 | + KVMState *s = KVM_STATE(ms->accelerator); | ||
68 | + int ret; | ||
69 | + | ||
70 | + ret = kvm_check_extension(s, KVM_CAP_ARM_VM_IPA_SIZE); | ||
71 | + return ret > 0 ? ret : 40; | ||
72 | +} | ||
73 | + | ||
74 | int kvm_arch_init(MachineState *ms, KVMState *s) | ||
75 | { | ||
76 | /* For ARM interrupt delivery is always asynchronous, | ||
77 | -- | 224 | -- |
78 | 2.20.1 | 225 | 2.20.1 |
79 | 226 | ||
80 | 227 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE vector shift right by immediate insns VSHRI and |
---|---|---|---|
2 | VRSHRI. As with Neon, we implement these by using helper functions | ||
3 | which perform left shifts but allow negative shift counts to indicate | ||
4 | right shifts. | ||
2 | 5 | ||
3 | The EL0+UMA check is unique to DAIF. While SPSel had avoided the | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | check by nature of already checking EL >= 1, the other post v8.0 | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | extensions to MSR (imm) allow EL0 and do not require UMA. Avoid | 8 | Message-id: 20210628135835.6690-9-peter.maydell@linaro.org |
6 | the unconditional write to pc and use raise_exception_ra to unwind. | 9 | --- |
10 | target/arm/helper-mve.h | 12 ++++++++++++ | ||
11 | target/arm/translate.h | 20 ++++++++++++++++++++ | ||
12 | target/arm/mve.decode | 28 ++++++++++++++++++++++++++++ | ||
13 | target/arm/mve_helper.c | 7 +++++++ | ||
14 | target/arm/translate-mve.c | 5 +++++ | ||
15 | target/arm/translate-neon.c | 18 ------------------ | ||
16 | 6 files changed, 72 insertions(+), 18 deletions(-) | ||
7 | 17 | ||
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
9 | Message-id: 20190301200501.16533-5-richard.henderson@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/helper-a64.h | 3 +++ | ||
14 | target/arm/helper.h | 1 - | ||
15 | target/arm/internals.h | 15 ++++++++++++++ | ||
16 | target/arm/helper-a64.c | 30 +++++++++++++++++++++++++++ | ||
17 | target/arm/op_helper.c | 42 -------------------------------------- | ||
18 | target/arm/translate-a64.c | 41 ++++++++++++++++++++++--------------- | ||
19 | 6 files changed, 73 insertions(+), 59 deletions(-) | ||
20 | |||
21 | diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h | ||
22 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/helper-a64.h | 20 | --- a/target/arm/helper-mve.h |
24 | +++ b/target/arm/helper-a64.h | 21 | +++ b/target/arm/helper-mve.h |
25 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) |
26 | DEF_HELPER_FLAGS_2(udiv64, TCG_CALL_NO_RWG_SE, i64, i64, i64) | 23 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) |
27 | DEF_HELPER_FLAGS_2(sdiv64, TCG_CALL_NO_RWG_SE, s64, s64, s64) | 24 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) |
28 | DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64) | 25 | |
29 | +DEF_HELPER_2(msr_i_spsel, void, env, i32) | 26 | +DEF_HELPER_FLAGS_4(mve_vshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
30 | +DEF_HELPER_2(msr_i_daifset, void, env, i32) | 27 | +DEF_HELPER_FLAGS_4(mve_vshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
31 | +DEF_HELPER_2(msr_i_daifclear, void, env, i32) | 28 | +DEF_HELPER_FLAGS_4(mve_vshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
32 | DEF_HELPER_3(vfp_cmph_a64, i64, f16, f16, ptr) | 29 | + |
33 | DEF_HELPER_3(vfp_cmpeh_a64, i64, f16, f16, ptr) | 30 | DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
34 | DEF_HELPER_3(vfp_cmps_a64, i64, f32, f32, ptr) | 31 | DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
35 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 32 | DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
33 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
34 | DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
35 | DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | + | ||
38 | +DEF_HELPER_FLAGS_4(mve_vrshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | +DEF_HELPER_FLAGS_4(mve_vrshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
40 | +DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | + | ||
42 | +DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
43 | +DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
44 | +DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
45 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
37 | --- a/target/arm/helper.h | 47 | --- a/target/arm/translate.h |
38 | +++ b/target/arm/helper.h | 48 | +++ b/target/arm/translate.h |
39 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(get_cp_reg, i32, env, ptr) | 49 | @@ -XXX,XX +XXX,XX @@ static inline int times_2_plus_1(DisasContext *s, int x) |
40 | DEF_HELPER_3(set_cp_reg64, void, env, ptr, i64) | 50 | return x * 2 + 1; |
41 | DEF_HELPER_2(get_cp_reg64, i64, env, ptr) | 51 | } |
42 | 52 | ||
43 | -DEF_HELPER_3(msr_i_pstate, void, env, i32, i32) | 53 | +static inline int rsub_64(DisasContext *s, int x) |
44 | DEF_HELPER_1(clear_pstate_ss, void, env) | ||
45 | |||
46 | DEF_HELPER_2(get_r13_banked, i32, env, i32) | ||
47 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/internals.h | ||
50 | +++ b/target/arm/internals.h | ||
51 | @@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, | ||
52 | ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va, | ||
53 | ARMMMUIdx mmu_idx, bool data); | ||
54 | |||
55 | +static inline int exception_target_el(CPUARMState *env) | ||
56 | +{ | 54 | +{ |
57 | + int target_el = MAX(1, arm_current_el(env)); | 55 | + return 64 - x; |
58 | + | ||
59 | + /* | ||
60 | + * No such thing as secure EL1 if EL3 is aarch32, | ||
61 | + * so update the target EL to EL3 in this case. | ||
62 | + */ | ||
63 | + if (arm_is_secure(env) && !arm_el_is_aa64(env, 3) && target_el == 1) { | ||
64 | + target_el = 3; | ||
65 | + } | ||
66 | + | ||
67 | + return target_el; | ||
68 | +} | 56 | +} |
69 | + | 57 | + |
70 | #endif | 58 | +static inline int rsub_32(DisasContext *s, int x) |
71 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/helper-a64.c | ||
74 | +++ b/target/arm/helper-a64.c | ||
75 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(rbit64)(uint64_t x) | ||
76 | return revbit64(x); | ||
77 | } | ||
78 | |||
79 | +void HELPER(msr_i_spsel)(CPUARMState *env, uint32_t imm) | ||
80 | +{ | 59 | +{ |
81 | + update_spsel(env, imm); | 60 | + return 32 - x; |
82 | +} | 61 | +} |
83 | + | 62 | + |
84 | +static void daif_check(CPUARMState *env, uint32_t op, | 63 | +static inline int rsub_16(DisasContext *s, int x) |
85 | + uint32_t imm, uintptr_t ra) | ||
86 | +{ | 64 | +{ |
87 | + /* DAIF update to PSTATE. This is OK from EL0 only if UMA is set. */ | 65 | + return 16 - x; |
88 | + if (arm_current_el(env) == 0 && !(env->cp15.sctlr_el[1] & SCTLR_UMA)) { | ||
89 | + raise_exception_ra(env, EXCP_UDEF, | ||
90 | + syn_aa64_sysregtrap(0, extract32(op, 0, 3), | ||
91 | + extract32(op, 3, 3), 4, | ||
92 | + imm, 0x1f, 0), | ||
93 | + exception_target_el(env), ra); | ||
94 | + } | ||
95 | +} | 66 | +} |
96 | + | 67 | + |
97 | +void HELPER(msr_i_daifset)(CPUARMState *env, uint32_t imm) | 68 | +static inline int rsub_8(DisasContext *s, int x) |
98 | +{ | 69 | +{ |
99 | + daif_check(env, 0x1e, imm, GETPC()); | 70 | + return 8 - x; |
100 | + env->daif |= (imm << 6) & PSTATE_DAIF; | ||
101 | +} | 71 | +} |
102 | + | 72 | + |
103 | +void HELPER(msr_i_daifclear)(CPUARMState *env, uint32_t imm) | 73 | static inline int arm_dc_feature(DisasContext *dc, int feature) |
104 | +{ | 74 | { |
105 | + daif_check(env, 0x1f, imm, GETPC()); | 75 | return (dc->features & (1ULL << feature)) != 0; |
106 | + env->daif &= ~((imm << 6) & PSTATE_DAIF); | 76 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
107 | +} | 77 | index XXXXXXX..XXXXXXX 100644 |
78 | --- a/target/arm/mve.decode | ||
79 | +++ b/target/arm/mve.decode | ||
80 | @@ -XXX,XX +XXX,XX @@ | ||
81 | @2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | ||
82 | @2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | ||
83 | |||
84 | +# Right shifts are encoded as N - shift, where N is the element size in bits. | ||
85 | +%rshift_i5 16:5 !function=rsub_32 | ||
86 | +%rshift_i4 16:4 !function=rsub_16 | ||
87 | +%rshift_i3 16:3 !function=rsub_8 | ||
108 | + | 88 | + |
109 | /* Convert a softfloat float_relation_ (as returned by | 89 | +@2_shr_b .... .... .. 001 ... .... .... .... .... &2shift qd=%qd qm=%qm \ |
110 | * the float*_compare functions) to the correct ARM | 90 | + size=0 shift=%rshift_i3 |
111 | * NZCV flag state. | 91 | +@2_shr_h .... .... .. 01 .... .... .... .... .... &2shift qd=%qd qm=%qm \ |
112 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | 92 | + size=1 shift=%rshift_i4 |
93 | +@2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \ | ||
94 | + size=2 shift=%rshift_i5 | ||
95 | + | ||
96 | # Vector loads and stores | ||
97 | |||
98 | # Widening loads and narrowing stores: | ||
99 | @@ -XXX,XX +XXX,XX @@ VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w | ||
100 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b | ||
101 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h | ||
102 | VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w | ||
103 | + | ||
104 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b | ||
105 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h | ||
106 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w | ||
107 | + | ||
108 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b | ||
109 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h | ||
110 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w | ||
111 | + | ||
112 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
113 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
114 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
115 | + | ||
116 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b | ||
117 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
118 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
119 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
113 | index XXXXXXX..XXXXXXX 100644 | 120 | index XXXXXXX..XXXXXXX 100644 |
114 | --- a/target/arm/op_helper.c | 121 | --- a/target/arm/mve_helper.c |
115 | +++ b/target/arm/op_helper.c | 122 | +++ b/target/arm/mve_helper.c |
116 | @@ -XXX,XX +XXX,XX @@ void raise_exception_ra(CPUARMState *env, uint32_t excp, uint32_t syndrome, | 123 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t) |
117 | cpu_loop_exit_restore(cs, ra); | 124 | DO_2SHIFT(OP##b, 1, uint8_t, FN) \ |
125 | DO_2SHIFT(OP##h, 2, uint16_t, FN) \ | ||
126 | DO_2SHIFT(OP##w, 4, uint32_t, FN) | ||
127 | +#define DO_2SHIFT_S(OP, FN) \ | ||
128 | + DO_2SHIFT(OP##b, 1, int8_t, FN) \ | ||
129 | + DO_2SHIFT(OP##h, 2, int16_t, FN) \ | ||
130 | + DO_2SHIFT(OP##w, 4, int32_t, FN) | ||
131 | |||
132 | #define DO_2SHIFT_SAT_U(OP, FN) \ | ||
133 | DO_2SHIFT_SAT(OP##b, 1, uint8_t, FN) \ | ||
134 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t) | ||
135 | DO_2SHIFT_SAT(OP##w, 4, int32_t, FN) | ||
136 | |||
137 | DO_2SHIFT_U(vshli_u, DO_VSHLU) | ||
138 | +DO_2SHIFT_S(vshli_s, DO_VSHLS) | ||
139 | DO_2SHIFT_SAT_U(vqshli_u, DO_UQSHL_OP) | ||
140 | DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
141 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
142 | +DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
143 | +DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
144 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
145 | index XXXXXXX..XXXXXXX 100644 | ||
146 | --- a/target/arm/translate-mve.c | ||
147 | +++ b/target/arm/translate-mve.c | ||
148 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHLI, vshli_u, false) | ||
149 | DO_2SHIFT(VQSHLI_S, vqshli_s, false) | ||
150 | DO_2SHIFT(VQSHLI_U, vqshli_u, false) | ||
151 | DO_2SHIFT(VQSHLUI, vqshlui_s, false) | ||
152 | +/* These right shifts use a left-shift helper with negated shift count */ | ||
153 | +DO_2SHIFT(VSHRI_S, vshli_s, true) | ||
154 | +DO_2SHIFT(VSHRI_U, vshli_u, true) | ||
155 | +DO_2SHIFT(VRSHRI_S, vrshli_s, true) | ||
156 | +DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
157 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
158 | index XXXXXXX..XXXXXXX 100644 | ||
159 | --- a/target/arm/translate-neon.c | ||
160 | +++ b/target/arm/translate-neon.c | ||
161 | @@ -XXX,XX +XXX,XX @@ static inline int plus1(DisasContext *s, int x) | ||
162 | return x + 1; | ||
118 | } | 163 | } |
119 | 164 | ||
120 | -static int exception_target_el(CPUARMState *env) | 165 | -static inline int rsub_64(DisasContext *s, int x) |
121 | -{ | 166 | -{ |
122 | - int target_el = MAX(1, arm_current_el(env)); | 167 | - return 64 - x; |
123 | - | ||
124 | - /* No such thing as secure EL1 if EL3 is aarch32, so update the target EL | ||
125 | - * to EL3 in this case. | ||
126 | - */ | ||
127 | - if (arm_is_secure(env) && !arm_el_is_aa64(env, 3) && target_el == 1) { | ||
128 | - target_el = 3; | ||
129 | - } | ||
130 | - | ||
131 | - return target_el; | ||
132 | -} | 168 | -} |
133 | - | 169 | - |
134 | uint32_t HELPER(neon_tbl)(uint32_t ireg, uint32_t def, void *vn, | 170 | -static inline int rsub_32(DisasContext *s, int x) |
135 | uint32_t maxindex) | ||
136 | { | ||
137 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(get_cp_reg64)(CPUARMState *env, void *rip) | ||
138 | return res; | ||
139 | } | ||
140 | |||
141 | -void HELPER(msr_i_pstate)(CPUARMState *env, uint32_t op, uint32_t imm) | ||
142 | -{ | 171 | -{ |
143 | - /* MSR_i to update PSTATE. This is OK from EL0 only if UMA is set. | 172 | - return 32 - x; |
144 | - * Note that SPSel is never OK from EL0; we rely on handle_msr_i() | 173 | -} |
145 | - * to catch that case at translate time. | 174 | -static inline int rsub_16(DisasContext *s, int x) |
146 | - */ | 175 | -{ |
147 | - if (arm_current_el(env) == 0 && !(env->cp15.sctlr_el[1] & SCTLR_UMA)) { | 176 | - return 16 - x; |
148 | - uint32_t syndrome = syn_aa64_sysregtrap(0, extract32(op, 0, 3), | 177 | -} |
149 | - extract32(op, 3, 3), 4, | 178 | -static inline int rsub_8(DisasContext *s, int x) |
150 | - imm, 0x1f, 0); | 179 | -{ |
151 | - raise_exception(env, EXCP_UDEF, syndrome, exception_target_el(env)); | 180 | - return 8 - x; |
152 | - } | ||
153 | - | ||
154 | - switch (op) { | ||
155 | - case 0x05: /* SPSel */ | ||
156 | - update_spsel(env, imm); | ||
157 | - break; | ||
158 | - case 0x1e: /* DAIFSet */ | ||
159 | - env->daif |= (imm << 6) & PSTATE_DAIF; | ||
160 | - break; | ||
161 | - case 0x1f: /* DAIFClear */ | ||
162 | - env->daif &= ~((imm << 6) & PSTATE_DAIF); | ||
163 | - break; | ||
164 | - default: | ||
165 | - g_assert_not_reached(); | ||
166 | - } | ||
167 | -} | 181 | -} |
168 | - | 182 | - |
169 | void HELPER(clear_pstate_ss)(CPUARMState *env) | 183 | static inline int neon_3same_fp_size(DisasContext *s, int x) |
170 | { | 184 | { |
171 | env->pstate &= ~PSTATE_SS; | 185 | /* Convert 0==fp32, 1==fp16 into a MO_* value */ |
172 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
173 | index XXXXXXX..XXXXXXX 100644 | ||
174 | --- a/target/arm/translate-a64.c | ||
175 | +++ b/target/arm/translate-a64.c | ||
176 | @@ -XXX,XX +XXX,XX @@ static void handle_sync(DisasContext *s, uint32_t insn, | ||
177 | static void handle_msr_i(DisasContext *s, uint32_t insn, | ||
178 | unsigned int op1, unsigned int op2, unsigned int crm) | ||
179 | { | ||
180 | + TCGv_i32 t1; | ||
181 | int op = op1 << 3 | op2; | ||
182 | + | ||
183 | + /* End the TB by default, chaining is ok. */ | ||
184 | + s->base.is_jmp = DISAS_TOO_MANY; | ||
185 | + | ||
186 | switch (op) { | ||
187 | case 0x05: /* SPSel */ | ||
188 | if (s->current_el == 0) { | ||
189 | - unallocated_encoding(s); | ||
190 | - return; | ||
191 | + goto do_unallocated; | ||
192 | } | ||
193 | - /* fall through */ | ||
194 | - case 0x1e: /* DAIFSet */ | ||
195 | - case 0x1f: /* DAIFClear */ | ||
196 | - { | ||
197 | - TCGv_i32 tcg_imm = tcg_const_i32(crm); | ||
198 | - TCGv_i32 tcg_op = tcg_const_i32(op); | ||
199 | - gen_a64_set_pc_im(s->pc - 4); | ||
200 | - gen_helper_msr_i_pstate(cpu_env, tcg_op, tcg_imm); | ||
201 | - tcg_temp_free_i32(tcg_imm); | ||
202 | - tcg_temp_free_i32(tcg_op); | ||
203 | - /* For DAIFClear, exit the cpu loop to re-evaluate pending IRQs. */ | ||
204 | - gen_a64_set_pc_im(s->pc); | ||
205 | - s->base.is_jmp = (op == 0x1f ? DISAS_EXIT : DISAS_JUMP); | ||
206 | + t1 = tcg_const_i32(crm & PSTATE_SP); | ||
207 | + gen_helper_msr_i_spsel(cpu_env, t1); | ||
208 | + tcg_temp_free_i32(t1); | ||
209 | break; | ||
210 | - } | ||
211 | + | ||
212 | + case 0x1e: /* DAIFSet */ | ||
213 | + t1 = tcg_const_i32(crm); | ||
214 | + gen_helper_msr_i_daifset(cpu_env, t1); | ||
215 | + tcg_temp_free_i32(t1); | ||
216 | + break; | ||
217 | + | ||
218 | + case 0x1f: /* DAIFClear */ | ||
219 | + t1 = tcg_const_i32(crm); | ||
220 | + gen_helper_msr_i_daifclear(cpu_env, t1); | ||
221 | + tcg_temp_free_i32(t1); | ||
222 | + /* For DAIFClear, exit the cpu loop to re-evaluate pending IRQs. */ | ||
223 | + s->base.is_jmp = DISAS_UPDATE; | ||
224 | + break; | ||
225 | + | ||
226 | default: | ||
227 | + do_unallocated: | ||
228 | unallocated_encoding(s); | ||
229 | return; | ||
230 | } | ||
231 | -- | 186 | -- |
232 | 2.20.1 | 187 | 2.20.1 |
233 | 188 | ||
234 | 189 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE VHLL (vector shift left long) insn. This has two |
---|---|---|---|
2 | encodings: the T1 encoding is the usual shift-by-immediate format, | ||
3 | and the T2 encoding is a special case where the shift count is always | ||
4 | equal to the element size. | ||
2 | 5 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20190301200501.16533-4-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-10-peter.maydell@linaro.org | ||
7 | --- | 9 | --- |
8 | target/arm/cpu.h | 13 ++++++++++- | 10 | target/arm/helper-mve.h | 9 +++++++ |
9 | target/arm/cpu.c | 1 + | 11 | target/arm/mve.decode | 53 +++++++++++++++++++++++++++++++++++--- |
10 | target/arm/cpu64.c | 2 ++ | 12 | target/arm/mve_helper.c | 32 +++++++++++++++++++++++ |
11 | target/arm/helper.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ | 13 | target/arm/translate-mve.c | 15 +++++++++++ |
12 | 4 files changed, 70 insertions(+), 1 deletion(-) | 14 | 4 files changed, 105 insertions(+), 4 deletions(-) |
13 | 15 | ||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/cpu.h | 18 | --- a/target/arm/helper-mve.h |
17 | +++ b/target/arm/cpu.h | 19 | +++ b/target/arm/helper-mve.h |
18 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | 20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
19 | #define SCTLR_R (1U << 9) /* up to v6; RAZ in v7 */ | 21 | DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
20 | #define SCTLR_UMA (1U << 9) /* v8 onward, AArch64 only */ | 22 | DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | #define SCTLR_F (1U << 10) /* up to v6 */ | 23 | DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
22 | -#define SCTLR_SW (1U << 10) /* v7, RES0 in v8 */ | 24 | + |
23 | +#define SCTLR_SW (1U << 10) /* v7 */ | 25 | +DEF_HELPER_FLAGS_4(mve_vshllbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
24 | +#define SCTLR_EnRCTX (1U << 10) /* in v8.0-PredInv */ | 26 | +DEF_HELPER_FLAGS_4(mve_vshllbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
25 | #define SCTLR_Z (1U << 11) /* in v7, RES1 in v8 */ | 27 | +DEF_HELPER_FLAGS_4(mve_vshllbub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
26 | #define SCTLR_EOS (1U << 11) /* v8.5-ExS */ | 28 | +DEF_HELPER_FLAGS_4(mve_vshllbuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
27 | #define SCTLR_I (1U << 12) | 29 | +DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
28 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_sb(const ARMISARegisters *id) | 30 | +DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
29 | return FIELD_EX32(id->id_isar6, ID_ISAR6, SB) != 0; | 31 | +DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
30 | } | 32 | +DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
31 | 33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | |
32 | +static inline bool isar_feature_aa32_predinv(const ARMISARegisters *id) | 34 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/mve.decode | ||
36 | +++ b/target/arm/mve.decode | ||
37 | @@ -XXX,XX +XXX,XX @@ | ||
38 | @2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | ||
39 | @2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 | ||
40 | |||
41 | +@2_shll_b .... .... ... 01 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0 | ||
42 | +@2_shll_h .... .... ... 1 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 | ||
43 | +# VSHLL encoding T2 where shift == esize | ||
44 | +@2_shll_esize_b .... .... .... 00 .. .... .... .... .... &2shift \ | ||
45 | + qd=%qd qm=%qm size=0 shift=8 | ||
46 | +@2_shll_esize_h .... .... .... 01 .. .... .... .... .... &2shift \ | ||
47 | + qd=%qd qm=%qm size=1 shift=16 | ||
48 | + | ||
49 | # Right shifts are encoded as N - shift, where N is the element size in bits. | ||
50 | %rshift_i5 16:5 !function=rsub_32 | ||
51 | %rshift_i4 16:4 !function=rsub_16 | ||
52 | @@ -XXX,XX +XXX,XX @@ VADD 1110 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op | ||
53 | VSUB 1111 1111 0 . .. ... 0 ... 0 1000 . 1 . 0 ... 0 @2op | ||
54 | VMUL 1110 1111 0 . .. ... 0 ... 0 1001 . 1 . 1 ... 0 @2op | ||
55 | |||
56 | -VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
57 | -VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
58 | +# The VSHLL T2 encoding is not a @2op pattern, but is here because it | ||
59 | +# overlaps what would be size=0b11 VMULH/VRMULH | ||
33 | +{ | 60 | +{ |
34 | + return FIELD_EX32(id->id_isar6, ID_ISAR6, SPECRES) != 0; | 61 | + VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b |
62 | + VSHLL_BS 111 0 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
63 | |||
64 | -VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
65 | -VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
66 | + VMULH_S 111 0 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
35 | +} | 67 | +} |
36 | + | 68 | + |
37 | static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) | ||
38 | { | ||
39 | /* | ||
40 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_sb(const ARMISARegisters *id) | ||
41 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SB) != 0; | ||
42 | } | ||
43 | |||
44 | +static inline bool isar_feature_aa64_predinv(const ARMISARegisters *id) | ||
45 | +{ | 69 | +{ |
46 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SPECRES) != 0; | 70 | + VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_b |
71 | + VSHLL_BU 111 1 1110 0 . 11 .. 01 ... 0 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
72 | + | ||
73 | + VMULH_U 111 1 1110 0 . .. ...1 ... 0 1110 . 0 . 0 ... 1 @2op | ||
47 | +} | 74 | +} |
48 | + | 75 | + |
49 | static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) | ||
50 | { | ||
51 | /* We always set the AdvSIMD and FP fields identically wrt FP16. */ | ||
52 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/cpu.c | ||
55 | +++ b/target/arm/cpu.c | ||
56 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | ||
57 | t = FIELD_DP32(t, ID_ISAR6, DP, 1); | ||
58 | t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
59 | t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
60 | + t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
61 | cpu->isar.id_isar6 = t; | ||
62 | |||
63 | t = cpu->id_mmfr4; | ||
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 @@ static void aarch64_max_initfn(Object *obj) | ||
69 | t = FIELD_DP64(t, ID_AA64ISAR1, GPA, 1); | ||
70 | t = FIELD_DP64(t, ID_AA64ISAR1, GPI, 0); | ||
71 | t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); | ||
72 | + t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); | ||
73 | cpu->isar.id_aa64isar1 = t; | ||
74 | |||
75 | t = cpu->isar.id_aa64pfr0; | ||
76 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
77 | u = FIELD_DP32(u, ID_ISAR6, DP, 1); | ||
78 | u = FIELD_DP32(u, ID_ISAR6, FHM, 1); | ||
79 | u = FIELD_DP32(u, ID_ISAR6, SB, 1); | ||
80 | + u = FIELD_DP32(u, ID_ISAR6, SPECRES, 1); | ||
81 | cpu->isar.id_isar6 = u; | ||
82 | |||
83 | /* | ||
84 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/target/arm/helper.c | ||
87 | +++ b/target/arm/helper.c | ||
88 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pauth_reginfo[] = { | ||
89 | }; | ||
90 | #endif | ||
91 | |||
92 | +static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri, | ||
93 | + bool isread) | ||
94 | +{ | 76 | +{ |
95 | + int el = arm_current_el(env); | 77 | + VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b |
78 | + VSHLL_TS 111 0 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h | ||
96 | + | 79 | + |
97 | + if (el == 0) { | 80 | + VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op |
98 | + uint64_t sctlr = arm_sctlr(env, el); | ||
99 | + if (!(sctlr & SCTLR_EnRCTX)) { | ||
100 | + return CP_ACCESS_TRAP; | ||
101 | + } | ||
102 | + } else if (el == 1) { | ||
103 | + uint64_t hcr = arm_hcr_el2_eff(env); | ||
104 | + if (hcr & HCR_NV) { | ||
105 | + return CP_ACCESS_TRAP_EL2; | ||
106 | + } | ||
107 | + } | ||
108 | + return CP_ACCESS_OK; | ||
109 | +} | 81 | +} |
110 | + | 82 | + |
111 | +static const ARMCPRegInfo predinv_reginfo[] = { | 83 | +{ |
112 | + { .name = "CFP_RCTX", .state = ARM_CP_STATE_AA64, | 84 | + VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b |
113 | + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 3, .opc2 = 4, | 85 | + VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h |
114 | + .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, | ||
115 | + { .name = "DVP_RCTX", .state = ARM_CP_STATE_AA64, | ||
116 | + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 3, .opc2 = 5, | ||
117 | + .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, | ||
118 | + { .name = "CPP_RCTX", .state = ARM_CP_STATE_AA64, | ||
119 | + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 3, .opc2 = 7, | ||
120 | + .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, | ||
121 | + /* | ||
122 | + * Note the AArch32 opcodes have a different OPC1. | ||
123 | + */ | ||
124 | + { .name = "CFPRCTX", .state = ARM_CP_STATE_AA32, | ||
125 | + .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 4, | ||
126 | + .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, | ||
127 | + { .name = "DVPRCTX", .state = ARM_CP_STATE_AA32, | ||
128 | + .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 5, | ||
129 | + .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, | ||
130 | + { .name = "CPPRCTX", .state = ARM_CP_STATE_AA32, | ||
131 | + .cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 7, | ||
132 | + .type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv }, | ||
133 | + REGINFO_SENTINEL | ||
134 | +}; | ||
135 | + | 86 | + |
136 | void register_cp_regs_for_features(ARMCPU *cpu) | 87 | + VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op |
137 | { | 88 | +} |
138 | /* Register all the coprocessor registers based on feature bits */ | 89 | |
139 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 90 | VMAX_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op |
140 | define_arm_cp_regs(cpu, pauth_reginfo); | 91 | VMAX_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op |
141 | } | 92 | @@ -XXX,XX +XXX,XX @@ VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w |
142 | #endif | 93 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b |
94 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h | ||
95 | VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
143 | + | 96 | + |
144 | + /* | 97 | +# VSHLL T1 encoding; the T2 VSHLL encoding is elsewhere in this file |
145 | + * While all v8.0 cpus support aarch64, QEMU does have configurations | 98 | +VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b |
146 | + * that do not set ID_AA64ISAR1, e.g. user-only qemu-arm -cpu max, | 99 | +VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h |
147 | + * which will set ID_ISAR6. | 100 | + |
148 | + */ | 101 | +VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b |
149 | + if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64) | 102 | +VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h |
150 | + ? cpu_isar_feature(aa64_predinv, cpu) | 103 | + |
151 | + : cpu_isar_feature(aa32_predinv, cpu)) { | 104 | +VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b |
152 | + define_arm_cp_regs(cpu, predinv_reginfo); | 105 | +VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h |
106 | + | ||
107 | +VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
108 | +VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
109 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
110 | index XXXXXXX..XXXXXXX 100644 | ||
111 | --- a/target/arm/mve_helper.c | ||
112 | +++ b/target/arm/mve_helper.c | ||
113 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshli_s, DO_SQSHL_OP) | ||
114 | DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
115 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
116 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
117 | + | ||
118 | +/* | ||
119 | + * Long shifts taking half-sized inputs from top or bottom of the input | ||
120 | + * vector and producing a double-width result. ESIZE, TYPE are for | ||
121 | + * the input, and LESIZE, LTYPE for the output. | ||
122 | + * Unlike the normal shift helpers, we do not handle negative shift counts, | ||
123 | + * because the long shift is strictly left-only. | ||
124 | + */ | ||
125 | +#define DO_VSHLL(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE) \ | ||
126 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
127 | + void *vm, uint32_t shift) \ | ||
128 | + { \ | ||
129 | + LTYPE *d = vd; \ | ||
130 | + TYPE *m = vm; \ | ||
131 | + uint16_t mask = mve_element_mask(env); \ | ||
132 | + unsigned le; \ | ||
133 | + assert(shift <= 16); \ | ||
134 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
135 | + LTYPE r = (LTYPE)m[H##ESIZE(le * 2 + TOP)] << shift; \ | ||
136 | + mergemask(&d[H##LESIZE(le)], r, mask); \ | ||
137 | + } \ | ||
138 | + mve_advance_vpt(env); \ | ||
153 | + } | 139 | + } |
154 | } | 140 | + |
155 | 141 | +#define DO_VSHLL_ALL(OP, TOP) \ | |
156 | void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) | 142 | + DO_VSHLL(OP##sb, TOP, 1, int8_t, 2, int16_t) \ |
143 | + DO_VSHLL(OP##ub, TOP, 1, uint8_t, 2, uint16_t) \ | ||
144 | + DO_VSHLL(OP##sh, TOP, 2, int16_t, 4, int32_t) \ | ||
145 | + DO_VSHLL(OP##uh, TOP, 2, uint16_t, 4, uint32_t) \ | ||
146 | + | ||
147 | +DO_VSHLL_ALL(vshllb, false) | ||
148 | +DO_VSHLL_ALL(vshllt, true) | ||
149 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
150 | index XXXXXXX..XXXXXXX 100644 | ||
151 | --- a/target/arm/translate-mve.c | ||
152 | +++ b/target/arm/translate-mve.c | ||
153 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_S, vshli_s, true) | ||
154 | DO_2SHIFT(VSHRI_U, vshli_u, true) | ||
155 | DO_2SHIFT(VRSHRI_S, vrshli_s, true) | ||
156 | DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
157 | + | ||
158 | +#define DO_VSHLL(INSN, FN) \ | ||
159 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
160 | + { \ | ||
161 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
162 | + gen_helper_mve_##FN##b, \ | ||
163 | + gen_helper_mve_##FN##h, \ | ||
164 | + }; \ | ||
165 | + return do_2shift(s, a, fns[a->size], false); \ | ||
166 | + } | ||
167 | + | ||
168 | +DO_VSHLL(VSHLL_BS, vshllbs) | ||
169 | +DO_VSHLL(VSHLL_BU, vshllbu) | ||
170 | +DO_VSHLL(VSHLL_TS, vshllts) | ||
171 | +DO_VSHLL(VSHLL_TU, vshlltu) | ||
157 | -- | 172 | -- |
158 | 2.20.1 | 173 | 2.20.1 |
159 | 174 | ||
160 | 175 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Implement the MVE VSRI and VSLI insns, which perform a | ||
2 | shift-and-insert operation. | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210628135835.6690-11-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 8 ++++++++ | ||
9 | target/arm/mve.decode | 9 ++++++++ | ||
10 | target/arm/mve_helper.c | 42 ++++++++++++++++++++++++++++++++++++++ | ||
11 | target/arm/translate-mve.c | 3 +++ | ||
12 | 4 files changed, 62 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/helper-mve.h | ||
17 | +++ b/target/arm/helper-mve.h | ||
18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
19 | DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
20 | DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
21 | DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | + | ||
23 | +DEF_HELPER_FLAGS_4(mve_vsrib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | +DEF_HELPER_FLAGS_4(mve_vsrih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
25 | +DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | + | ||
27 | +DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/mve.decode | ||
33 | +++ b/target/arm/mve.decode | ||
34 | @@ -XXX,XX +XXX,XX @@ VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
35 | |||
36 | VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
37 | VSHLL_TU 111 1 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_h | ||
38 | + | ||
39 | +# Shift-and-insert | ||
40 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_b | ||
41 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_h | ||
42 | +VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w | ||
43 | + | ||
44 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | ||
45 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | ||
46 | +VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | ||
47 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/mve_helper.c | ||
50 | +++ b/target/arm/mve_helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_SAT_S(vqshlui_s, DO_SUQSHL_OP) | ||
52 | DO_2SHIFT_U(vrshli_u, DO_VRSHLU) | ||
53 | DO_2SHIFT_S(vrshli_s, DO_VRSHLS) | ||
54 | |||
55 | +/* Shift-and-insert; we always work with 64 bits at a time */ | ||
56 | +#define DO_2SHIFT_INSERT(OP, ESIZE, SHIFTFN, MASKFN) \ | ||
57 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
58 | + void *vm, uint32_t shift) \ | ||
59 | + { \ | ||
60 | + uint64_t *d = vd, *m = vm; \ | ||
61 | + uint16_t mask; \ | ||
62 | + uint64_t shiftmask; \ | ||
63 | + unsigned e; \ | ||
64 | + if (shift == 0 || shift == ESIZE * 8) { \ | ||
65 | + /* \ | ||
66 | + * Only VSLI can shift by 0; only VSRI can shift by <dt>. \ | ||
67 | + * The generic logic would give the right answer for 0 but \ | ||
68 | + * fails for <dt>. \ | ||
69 | + */ \ | ||
70 | + goto done; \ | ||
71 | + } \ | ||
72 | + assert(shift < ESIZE * 8); \ | ||
73 | + mask = mve_element_mask(env); \ | ||
74 | + /* ESIZE / 2 gives the MO_* value if ESIZE is in [1,2,4] */ \ | ||
75 | + shiftmask = dup_const(ESIZE / 2, MASKFN(ESIZE * 8, shift)); \ | ||
76 | + for (e = 0; e < 16 / 8; e++, mask >>= 8) { \ | ||
77 | + uint64_t r = (SHIFTFN(m[H8(e)], shift) & shiftmask) | \ | ||
78 | + (d[H8(e)] & ~shiftmask); \ | ||
79 | + mergemask(&d[H8(e)], r, mask); \ | ||
80 | + } \ | ||
81 | +done: \ | ||
82 | + mve_advance_vpt(env); \ | ||
83 | + } | ||
84 | + | ||
85 | +#define DO_SHL(N, SHIFT) ((N) << (SHIFT)) | ||
86 | +#define DO_SHR(N, SHIFT) ((N) >> (SHIFT)) | ||
87 | +#define SHL_MASK(EBITS, SHIFT) MAKE_64BIT_MASK((SHIFT), (EBITS) - (SHIFT)) | ||
88 | +#define SHR_MASK(EBITS, SHIFT) MAKE_64BIT_MASK(0, (EBITS) - (SHIFT)) | ||
89 | + | ||
90 | +DO_2SHIFT_INSERT(vsrib, 1, DO_SHR, SHR_MASK) | ||
91 | +DO_2SHIFT_INSERT(vsrih, 2, DO_SHR, SHR_MASK) | ||
92 | +DO_2SHIFT_INSERT(vsriw, 4, DO_SHR, SHR_MASK) | ||
93 | +DO_2SHIFT_INSERT(vslib, 1, DO_SHL, SHL_MASK) | ||
94 | +DO_2SHIFT_INSERT(vslih, 2, DO_SHL, SHL_MASK) | ||
95 | +DO_2SHIFT_INSERT(vsliw, 4, DO_SHL, SHL_MASK) | ||
96 | + | ||
97 | /* | ||
98 | * Long shifts taking half-sized inputs from top or bottom of the input | ||
99 | * vector and producing a double-width result. ESIZE, TYPE are for | ||
100 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
101 | index XXXXXXX..XXXXXXX 100644 | ||
102 | --- a/target/arm/translate-mve.c | ||
103 | +++ b/target/arm/translate-mve.c | ||
104 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_U, vshli_u, true) | ||
105 | DO_2SHIFT(VRSHRI_S, vrshli_s, true) | ||
106 | DO_2SHIFT(VRSHRI_U, vrshli_u, true) | ||
107 | |||
108 | +DO_2SHIFT(VSRI, vsri, false) | ||
109 | +DO_2SHIFT(VSLI, vsli, false) | ||
110 | + | ||
111 | #define DO_VSHLL(INSN, FN) \ | ||
112 | static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
113 | { \ | ||
114 | -- | ||
115 | 2.20.1 | ||
116 | |||
117 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | Implement the MVE shift-right-and-narrow insn VSHRN and VRSHRN. |
---|---|---|---|
2 | 2 | ||
3 | In the prospect to introduce an extended memory map supporting more | 3 | do_urshr() is borrowed from sve_helper.c. |
4 | RAM, let's split the memory map array into two parts: | ||
5 | 4 | ||
6 | - the former a15memmap, renamed base_memmap, contains regions below | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | and including the RAM. MemMapEntries initialized in this array | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | have a static size and base address. | 7 | Message-id: 20210628135835.6690-12-peter.maydell@linaro.org |
9 | - extended_memmap, only initialized with entries located after the | 8 | --- |
10 | RAM. MemMapEntries initialized in this array only get their size | 9 | target/arm/helper-mve.h | 10 ++++++++++ |
11 | initialized. Their base address is dynamically computed depending | 10 | target/arm/mve.decode | 11 +++++++++++ |
12 | on the the top of the RAM, with same alignment as their size. | 11 | target/arm/mve_helper.c | 40 ++++++++++++++++++++++++++++++++++++++ |
12 | target/arm/translate-mve.c | 15 ++++++++++++++ | ||
13 | 4 files changed, 76 insertions(+) | ||
13 | 14 | ||
14 | Eventually base_memmap entries are copied into the extended_memmap | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
15 | array. Using two separate arrays however clarifies which entries | ||
16 | are statically allocated and those which are dynamically allocated. | ||
17 | |||
18 | This new split will allow to grow the RAM size without changing the | ||
19 | description of the high IO entries. | ||
20 | |||
21 | We introduce a new virt_set_memmap() helper function which | ||
22 | "freezes" the memory map. We call it in machvirt_init as | ||
23 | memory attributes of the machine are not yet set when | ||
24 | virt_instance_init() gets called. | ||
25 | |||
26 | The memory map is unchanged (the top of the initial RAM still is | ||
27 | 256GiB). Then come the high IO regions with same layout as before. | ||
28 | |||
29 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
30 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
31 | Message-id: 20190304101339.25970-4-eric.auger@redhat.com | ||
32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
33 | --- | ||
34 | include/hw/arm/virt.h | 13 +++++++---- | ||
35 | hw/arm/virt.c | 50 +++++++++++++++++++++++++++++++++++++------ | ||
36 | 2 files changed, 53 insertions(+), 10 deletions(-) | ||
37 | |||
38 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/include/hw/arm/virt.h | 17 | --- a/target/arm/helper-mve.h |
41 | +++ b/include/hw/arm/virt.h | 18 | +++ b/target/arm/helper-mve.h |
42 | @@ -XXX,XX +XXX,XX @@ enum { | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
43 | VIRT_GIC_VCPU, | 20 | DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
44 | VIRT_GIC_ITS, | 21 | DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
45 | VIRT_GIC_REDIST, | 22 | DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
46 | - VIRT_HIGH_GIC_REDIST2, | ||
47 | VIRT_SMMU, | ||
48 | VIRT_UART, | ||
49 | VIRT_MMIO, | ||
50 | @@ -XXX,XX +XXX,XX @@ enum { | ||
51 | VIRT_PCIE_MMIO, | ||
52 | VIRT_PCIE_PIO, | ||
53 | VIRT_PCIE_ECAM, | ||
54 | - VIRT_HIGH_PCIE_ECAM, | ||
55 | VIRT_PLATFORM_BUS, | ||
56 | - VIRT_HIGH_PCIE_MMIO, | ||
57 | VIRT_GPIO, | ||
58 | VIRT_SECURE_UART, | ||
59 | VIRT_SECURE_MEM, | ||
60 | + VIRT_LOWMEMMAP_LAST, | ||
61 | +}; | ||
62 | + | 23 | + |
63 | +/* indices of IO regions located after the RAM */ | 24 | +DEF_HELPER_FLAGS_4(mve_vshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
64 | +enum { | 25 | +DEF_HELPER_FLAGS_4(mve_vshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
65 | + VIRT_HIGH_GIC_REDIST2 = VIRT_LOWMEMMAP_LAST, | 26 | +DEF_HELPER_FLAGS_4(mve_vshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
66 | + VIRT_HIGH_PCIE_ECAM, | 27 | +DEF_HELPER_FLAGS_4(mve_vshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
67 | + VIRT_HIGH_PCIE_MMIO, | 28 | + |
68 | }; | 29 | +DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
69 | 30 | +DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
70 | typedef enum VirtIOMMUType { | 31 | +DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
71 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 32 | +DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
72 | int32_t gic_version; | 33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
73 | VirtIOMMUType iommu; | ||
74 | struct arm_boot_info bootinfo; | ||
75 | - const MemMapEntry *memmap; | ||
76 | + MemMapEntry *memmap; | ||
77 | const int *irqmap; | ||
78 | int smp_cpus; | ||
79 | void *fdt; | ||
80 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
82 | --- a/hw/arm/virt.c | 35 | --- a/target/arm/mve.decode |
83 | +++ b/hw/arm/virt.c | 36 | +++ b/target/arm/mve.decode |
84 | @@ -XXX,XX +XXX,XX @@ | 37 | @@ -XXX,XX +XXX,XX @@ VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w |
85 | */ | 38 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b |
86 | 39 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | |
87 | #include "qemu/osdep.h" | 40 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w |
88 | +#include "qemu/units.h" | 41 | + |
89 | #include "qapi/error.h" | 42 | +# Narrowing shifts (which only support b and h sizes) |
90 | #include "hw/sysbus.h" | 43 | +VSHRNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b |
91 | #include "hw/arm/arm.h" | 44 | +VSHRNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h |
92 | @@ -XXX,XX +XXX,XX @@ | 45 | +VSHRNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b |
93 | * Note that devices should generally be placed at multiples of 0x10000, | 46 | +VSHRNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h |
94 | * to accommodate guests using 64K pages. | 47 | + |
95 | */ | 48 | +VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b |
96 | -static const MemMapEntry a15memmap[] = { | 49 | +VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h |
97 | +static const MemMapEntry base_memmap[] = { | 50 | +VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b |
98 | /* Space up to 0x8000000 is reserved for a boot ROM */ | 51 | +VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h |
99 | [VIRT_FLASH] = { 0, 0x08000000 }, | 52 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
100 | [VIRT_CPUPERIPHS] = { 0x08000000, 0x00020000 }, | 53 | index XXXXXXX..XXXXXXX 100644 |
101 | @@ -XXX,XX +XXX,XX @@ static const MemMapEntry a15memmap[] = { | 54 | --- a/target/arm/mve_helper.c |
102 | [VIRT_PCIE_PIO] = { 0x3eff0000, 0x00010000 }, | 55 | +++ b/target/arm/mve_helper.c |
103 | [VIRT_PCIE_ECAM] = { 0x3f000000, 0x01000000 }, | 56 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_INSERT(vsliw, 4, DO_SHL, SHL_MASK) |
104 | [VIRT_MEM] = { 0x40000000, RAMLIMIT_BYTES }, | 57 | |
105 | +}; | 58 | DO_VSHLL_ALL(vshllb, false) |
59 | DO_VSHLL_ALL(vshllt, true) | ||
106 | + | 60 | + |
107 | +/* | 61 | +/* |
108 | + * Highmem IO Regions: This memory map is floating, located after the RAM. | 62 | + * Narrowing right shifts, taking a double sized input, shifting it |
109 | + * Each MemMapEntry base (GPA) will be dynamically computed, depending on the | 63 | + * and putting the result in either the top or bottom half of the output. |
110 | + * top of the RAM, so that its base get the same alignment as the size, | 64 | + * ESIZE, TYPE are the output, and LESIZE, LTYPE the input. |
111 | + * ie. a 512GiB entry will be aligned on a 512GiB boundary. If there is | ||
112 | + * less than 256GiB of RAM, the floating area starts at the 256GiB mark. | ||
113 | + * Note the extended_memmap is sized so that it eventually also includes the | ||
114 | + * base_memmap entries (VIRT_HIGH_GIC_REDIST2 index is greater than the last | ||
115 | + * index of base_memmap). | ||
116 | + */ | 65 | + */ |
117 | +static MemMapEntry extended_memmap[] = { | 66 | +#define DO_VSHRN(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ |
118 | /* Additional 64 MB redist region (can contain up to 512 redistributors) */ | 67 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ |
119 | - [VIRT_HIGH_GIC_REDIST2] = { 0x4000000000ULL, 0x4000000 }, | 68 | + void *vm, uint32_t shift) \ |
120 | - [VIRT_HIGH_PCIE_ECAM] = { 0x4010000000ULL, 0x10000000 }, | 69 | + { \ |
121 | - /* Second PCIe window, 512GB wide at the 512GB boundary */ | 70 | + LTYPE *m = vm; \ |
122 | - [VIRT_HIGH_PCIE_MMIO] = { 0x8000000000ULL, 0x8000000000ULL }, | 71 | + TYPE *d = vd; \ |
123 | + [VIRT_HIGH_GIC_REDIST2] = { 0x0, 64 * MiB }, | 72 | + uint16_t mask = mve_element_mask(env); \ |
124 | + [VIRT_HIGH_PCIE_ECAM] = { 0x0, 256 * MiB }, | 73 | + unsigned le; \ |
125 | + /* Second PCIe window */ | 74 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ |
126 | + [VIRT_HIGH_PCIE_MMIO] = { 0x0, 512 * GiB }, | 75 | + TYPE r = FN(m[H##LESIZE(le)], shift); \ |
127 | }; | 76 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ |
128 | 77 | + } \ | |
129 | static const int a15irqmap[] = { | 78 | + mve_advance_vpt(env); \ |
130 | @@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) | ||
131 | return arm_cpu_mp_affinity(idx, clustersz); | ||
132 | } | ||
133 | |||
134 | +static void virt_set_memmap(VirtMachineState *vms) | ||
135 | +{ | ||
136 | + hwaddr base; | ||
137 | + int i; | ||
138 | + | ||
139 | + vms->memmap = extended_memmap; | ||
140 | + | ||
141 | + for (i = 0; i < ARRAY_SIZE(base_memmap); i++) { | ||
142 | + vms->memmap[i] = base_memmap[i]; | ||
143 | + } | 79 | + } |
144 | + | 80 | + |
145 | + base = 256 * GiB; /* Top of the legacy initial RAM region */ | 81 | +#define DO_VSHRN_ALL(OP, FN) \ |
82 | + DO_VSHRN(OP##bb, false, 1, uint8_t, 2, uint16_t, FN) \ | ||
83 | + DO_VSHRN(OP##bh, false, 2, uint16_t, 4, uint32_t, FN) \ | ||
84 | + DO_VSHRN(OP##tb, true, 1, uint8_t, 2, uint16_t, FN) \ | ||
85 | + DO_VSHRN(OP##th, true, 2, uint16_t, 4, uint32_t, FN) | ||
146 | + | 86 | + |
147 | + for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) { | 87 | +static inline uint64_t do_urshr(uint64_t x, unsigned sh) |
148 | + hwaddr size = extended_memmap[i].size; | 88 | +{ |
149 | + | 89 | + if (likely(sh < 64)) { |
150 | + base = ROUND_UP(base, size); | 90 | + return (x >> sh) + ((x >> (sh - 1)) & 1); |
151 | + vms->memmap[i].base = base; | 91 | + } else if (sh == 64) { |
152 | + vms->memmap[i].size = size; | 92 | + return x >> 63; |
153 | + base += size; | 93 | + } else { |
94 | + return 0; | ||
154 | + } | 95 | + } |
155 | +} | 96 | +} |
156 | + | 97 | + |
157 | static void machvirt_init(MachineState *machine) | 98 | +DO_VSHRN_ALL(vshrn, DO_SHR) |
158 | { | 99 | +DO_VSHRN_ALL(vrshrn, do_urshr) |
159 | VirtMachineState *vms = VIRT_MACHINE(machine); | 100 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
160 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 101 | index XXXXXXX..XXXXXXX 100644 |
161 | bool firmware_loaded = bios_name || drive_get(IF_PFLASH, 0, 0); | 102 | --- a/target/arm/translate-mve.c |
162 | bool aarch64 = true; | 103 | +++ b/target/arm/translate-mve.c |
163 | 104 | @@ -XXX,XX +XXX,XX @@ DO_VSHLL(VSHLL_BS, vshllbs) | |
164 | + virt_set_memmap(vms); | 105 | DO_VSHLL(VSHLL_BU, vshllbu) |
106 | DO_VSHLL(VSHLL_TS, vshllts) | ||
107 | DO_VSHLL(VSHLL_TU, vshlltu) | ||
165 | + | 108 | + |
166 | /* We can probe only here because during property set | 109 | +#define DO_2SHIFT_N(INSN, FN) \ |
167 | * KVM is not available yet | 110 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ |
168 | */ | 111 | + { \ |
169 | @@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj) | 112 | + static MVEGenTwoOpShiftFn * const fns[] = { \ |
170 | "Valid values are none and smmuv3", | 113 | + gen_helper_mve_##FN##b, \ |
171 | NULL); | 114 | + gen_helper_mve_##FN##h, \ |
172 | 115 | + }; \ | |
173 | - vms->memmap = a15memmap; | 116 | + return do_2shift(s, a, fns[a->size], false); \ |
174 | vms->irqmap = a15irqmap; | 117 | + } |
175 | } | 118 | + |
176 | 119 | +DO_2SHIFT_N(VSHRNB, vshrnb) | |
120 | +DO_2SHIFT_N(VSHRNT, vshrnt) | ||
121 | +DO_2SHIFT_N(VRSHRNB, vrshrnb) | ||
122 | +DO_2SHIFT_N(VRSHRNT, vrshrnt) | ||
177 | -- | 123 | -- |
178 | 2.20.1 | 124 | 2.20.1 |
179 | 125 | ||
180 | 126 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE saturating shift-right-and-narrow insns |
---|---|---|---|
2 | 2 | VQSHRN, VQSHRUN, VQRSHRN and VQRSHRUN. | |
3 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | 3 | |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 4 | do_srshr() is borrowed from sve_helper.c. |
5 | Message-id: 20190301200501.16533-9-richard.henderson@linaro.org | 5 | |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210628135835.6690-13-peter.maydell@linaro.org | ||
8 | --- | 9 | --- |
9 | target/arm/cpu.h | 5 ++++ | 10 | target/arm/helper-mve.h | 30 +++++++++++ |
10 | target/arm/cpu64.c | 2 +- | 11 | target/arm/mve.decode | 28 ++++++++++ |
11 | target/arm/translate-a64.c | 58 ++++++++++++++++++++++++++++++++++++++ | 12 | target/arm/mve_helper.c | 104 +++++++++++++++++++++++++++++++++++++ |
12 | 3 files changed, 64 insertions(+), 1 deletion(-) | 13 | target/arm/translate-mve.c | 12 +++++ |
13 | 14 | 4 files changed, 174 insertions(+) | |
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | |
15 | index XXXXXXX..XXXXXXX 100644 | 16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
16 | --- a/target/arm/cpu.h | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | +++ b/target/arm/cpu.h | 18 | --- a/target/arm/helper-mve.h |
18 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_condm_4(const ARMISARegisters *id) | 19 | +++ b/target/arm/helper-mve.h |
19 | return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TS) != 0; | 20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
20 | } | 21 | DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | 22 | DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
22 | +static inline bool isar_feature_aa64_condm_5(const ARMISARegisters *id) | 23 | DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | +{ | 24 | + |
24 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TS) >= 2; | 25 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
25 | +} | 26 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
26 | + | 27 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
27 | static inline bool isar_feature_aa64_jscvt(const ARMISARegisters *id) | 28 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
28 | { | 29 | + |
29 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, JSCVT) != 0; | 30 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
30 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | 31 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
31 | index XXXXXXX..XXXXXXX 100644 | 32 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
32 | --- a/target/arm/cpu64.c | 33 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
33 | +++ b/target/arm/cpu64.c | 34 | + |
34 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | 35 | +DEF_HELPER_FLAGS_4(mve_vqshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
35 | t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); | 36 | +DEF_HELPER_FLAGS_4(mve_vqshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
36 | t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); | 37 | +DEF_HELPER_FLAGS_4(mve_vqshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
37 | t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1); | 38 | +DEF_HELPER_FLAGS_4(mve_vqshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
38 | - t = FIELD_DP64(t, ID_AA64ISAR0, TS, 1); | 39 | + |
39 | + t = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* v8.5-CondM */ | 40 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
40 | cpu->isar.id_aa64isar0 = t; | 41 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
41 | 42 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
42 | t = cpu->isar.id_aa64isar1; | 43 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
43 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 44 | + |
44 | index XXXXXXX..XXXXXXX 100644 | 45 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
45 | --- a/target/arm/translate-a64.c | 46 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
46 | +++ b/target/arm/translate-a64.c | 47 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
47 | @@ -XXX,XX +XXX,XX @@ static void handle_sync(DisasContext *s, uint32_t insn, | 48 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
49 | + | ||
50 | +DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
51 | +DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
52 | +DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
53 | +DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
54 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/target/arm/mve.decode | ||
57 | +++ b/target/arm/mve.decode | ||
58 | @@ -XXX,XX +XXX,XX @@ VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | ||
59 | VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | ||
60 | VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | ||
61 | VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | ||
62 | + | ||
63 | +VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b | ||
64 | +VQSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h | ||
65 | +VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b | ||
66 | +VQSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h | ||
67 | +VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_b | ||
68 | +VQSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 0 @2_shr_h | ||
69 | +VQSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_b | ||
70 | +VQSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 0 @2_shr_h | ||
71 | + | ||
72 | +VQSHRUNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | ||
73 | +VQSHRUNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | ||
74 | +VQSHRUNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
75 | +VQSHRUNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
76 | + | ||
77 | +VQRSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_b | ||
78 | +VQRSHRNB_S 111 0 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_h | ||
79 | +VQRSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_b | ||
80 | +VQRSHRNT_S 111 0 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_h | ||
81 | +VQRSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_b | ||
82 | +VQRSHRNB_U 111 1 1110 1 . ... ... ... 0 1111 0 1 . 0 ... 1 @2_shr_h | ||
83 | +VQRSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_b | ||
84 | +VQRSHRNT_U 111 1 1110 1 . ... ... ... 1 1111 0 1 . 0 ... 1 @2_shr_h | ||
85 | + | ||
86 | +VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | ||
87 | +VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | ||
88 | +VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
89 | +VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
90 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/mve_helper.c | ||
93 | +++ b/target/arm/mve_helper.c | ||
94 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t do_urshr(uint64_t x, unsigned sh) | ||
48 | } | 95 | } |
49 | } | 96 | } |
50 | 97 | ||
51 | +static void gen_xaflag(void) | 98 | +static inline int64_t do_srshr(int64_t x, unsigned sh) |
52 | +{ | 99 | +{ |
53 | + TCGv_i32 z = tcg_temp_new_i32(); | 100 | + if (likely(sh < 64)) { |
54 | + | 101 | + return (x >> sh) + ((x >> (sh - 1)) & 1); |
55 | + tcg_gen_setcondi_i32(TCG_COND_EQ, z, cpu_ZF, 0); | 102 | + } else { |
56 | + | 103 | + /* Rounding the sign bit always produces 0. */ |
57 | + /* | 104 | + return 0; |
58 | + * (!C & !Z) << 31 | 105 | + } |
59 | + * (!(C | Z)) << 31 | ||
60 | + * ~((C | Z) << 31) | ||
61 | + * ~-(C | Z) | ||
62 | + * (C | Z) - 1 | ||
63 | + */ | ||
64 | + tcg_gen_or_i32(cpu_NF, cpu_CF, z); | ||
65 | + tcg_gen_subi_i32(cpu_NF, cpu_NF, 1); | ||
66 | + | ||
67 | + /* !(Z & C) */ | ||
68 | + tcg_gen_and_i32(cpu_ZF, z, cpu_CF); | ||
69 | + tcg_gen_xori_i32(cpu_ZF, cpu_ZF, 1); | ||
70 | + | ||
71 | + /* (!C & Z) << 31 -> -(Z & ~C) */ | ||
72 | + tcg_gen_andc_i32(cpu_VF, z, cpu_CF); | ||
73 | + tcg_gen_neg_i32(cpu_VF, cpu_VF); | ||
74 | + | ||
75 | + /* C | Z */ | ||
76 | + tcg_gen_or_i32(cpu_CF, cpu_CF, z); | ||
77 | + | ||
78 | + tcg_temp_free_i32(z); | ||
79 | +} | 106 | +} |
80 | + | 107 | + |
81 | +static void gen_axflag(void) | 108 | DO_VSHRN_ALL(vshrn, DO_SHR) |
109 | DO_VSHRN_ALL(vrshrn, do_urshr) | ||
110 | + | ||
111 | +static inline int32_t do_sat_bhs(int64_t val, int64_t min, int64_t max, | ||
112 | + bool *satp) | ||
82 | +{ | 113 | +{ |
83 | + tcg_gen_sari_i32(cpu_VF, cpu_VF, 31); /* V ? -1 : 0 */ | 114 | + if (val > max) { |
84 | + tcg_gen_andc_i32(cpu_CF, cpu_CF, cpu_VF); /* C & !V */ | 115 | + *satp = true; |
85 | + | 116 | + return max; |
86 | + /* !(Z | V) -> !(!ZF | V) -> ZF & !V -> ZF & ~VF */ | 117 | + } else if (val < min) { |
87 | + tcg_gen_andc_i32(cpu_ZF, cpu_ZF, cpu_VF); | 118 | + *satp = true; |
88 | + | 119 | + return min; |
89 | + tcg_gen_movi_i32(cpu_NF, 0); | 120 | + } else { |
90 | + tcg_gen_movi_i32(cpu_VF, 0); | 121 | + return val; |
122 | + } | ||
91 | +} | 123 | +} |
92 | + | 124 | + |
93 | /* MSR (immediate) - move immediate to processor state field */ | 125 | +/* Saturating narrowing right shifts */ |
94 | static void handle_msr_i(DisasContext *s, uint32_t insn, | 126 | +#define DO_VSHRN_SAT(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ |
95 | unsigned int op1, unsigned int op2, unsigned int crm) | 127 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ |
96 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, | 128 | + void *vm, uint32_t shift) \ |
97 | s->base.is_jmp = DISAS_NEXT; | 129 | + { \ |
98 | break; | 130 | + LTYPE *m = vm; \ |
99 | 131 | + TYPE *d = vd; \ | |
100 | + case 0x01: /* XAFlag */ | 132 | + uint16_t mask = mve_element_mask(env); \ |
101 | + if (crm != 0 || !dc_isar_feature(aa64_condm_5, s)) { | 133 | + bool qc = false; \ |
102 | + goto do_unallocated; | 134 | + unsigned le; \ |
103 | + } | 135 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ |
104 | + gen_xaflag(); | 136 | + bool sat = false; \ |
105 | + s->base.is_jmp = DISAS_NEXT; | 137 | + TYPE r = FN(m[H##LESIZE(le)], shift, &sat); \ |
106 | + break; | 138 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ |
107 | + | 139 | + qc |= sat && (mask & 1 << (TOP * ESIZE)); \ |
108 | + case 0x02: /* AXFlag */ | 140 | + } \ |
109 | + if (crm != 0 || !dc_isar_feature(aa64_condm_5, s)) { | 141 | + if (qc) { \ |
110 | + goto do_unallocated; | 142 | + env->vfp.qc[0] = qc; \ |
111 | + } | 143 | + } \ |
112 | + gen_axflag(); | 144 | + mve_advance_vpt(env); \ |
113 | + s->base.is_jmp = DISAS_NEXT; | 145 | + } |
114 | + break; | 146 | + |
115 | + | 147 | +#define DO_VSHRN_SAT_UB(BOP, TOP, FN) \ |
116 | case 0x05: /* SPSel */ | 148 | + DO_VSHRN_SAT(BOP, false, 1, uint8_t, 2, uint16_t, FN) \ |
117 | if (s->current_el == 0) { | 149 | + DO_VSHRN_SAT(TOP, true, 1, uint8_t, 2, uint16_t, FN) |
118 | goto do_unallocated; | 150 | + |
151 | +#define DO_VSHRN_SAT_UH(BOP, TOP, FN) \ | ||
152 | + DO_VSHRN_SAT(BOP, false, 2, uint16_t, 4, uint32_t, FN) \ | ||
153 | + DO_VSHRN_SAT(TOP, true, 2, uint16_t, 4, uint32_t, FN) | ||
154 | + | ||
155 | +#define DO_VSHRN_SAT_SB(BOP, TOP, FN) \ | ||
156 | + DO_VSHRN_SAT(BOP, false, 1, int8_t, 2, int16_t, FN) \ | ||
157 | + DO_VSHRN_SAT(TOP, true, 1, int8_t, 2, int16_t, FN) | ||
158 | + | ||
159 | +#define DO_VSHRN_SAT_SH(BOP, TOP, FN) \ | ||
160 | + DO_VSHRN_SAT(BOP, false, 2, int16_t, 4, int32_t, FN) \ | ||
161 | + DO_VSHRN_SAT(TOP, true, 2, int16_t, 4, int32_t, FN) | ||
162 | + | ||
163 | +#define DO_SHRN_SB(N, M, SATP) \ | ||
164 | + do_sat_bhs((int64_t)(N) >> (M), INT8_MIN, INT8_MAX, SATP) | ||
165 | +#define DO_SHRN_UB(N, M, SATP) \ | ||
166 | + do_sat_bhs((uint64_t)(N) >> (M), 0, UINT8_MAX, SATP) | ||
167 | +#define DO_SHRUN_B(N, M, SATP) \ | ||
168 | + do_sat_bhs((int64_t)(N) >> (M), 0, UINT8_MAX, SATP) | ||
169 | + | ||
170 | +#define DO_SHRN_SH(N, M, SATP) \ | ||
171 | + do_sat_bhs((int64_t)(N) >> (M), INT16_MIN, INT16_MAX, SATP) | ||
172 | +#define DO_SHRN_UH(N, M, SATP) \ | ||
173 | + do_sat_bhs((uint64_t)(N) >> (M), 0, UINT16_MAX, SATP) | ||
174 | +#define DO_SHRUN_H(N, M, SATP) \ | ||
175 | + do_sat_bhs((int64_t)(N) >> (M), 0, UINT16_MAX, SATP) | ||
176 | + | ||
177 | +#define DO_RSHRN_SB(N, M, SATP) \ | ||
178 | + do_sat_bhs(do_srshr(N, M), INT8_MIN, INT8_MAX, SATP) | ||
179 | +#define DO_RSHRN_UB(N, M, SATP) \ | ||
180 | + do_sat_bhs(do_urshr(N, M), 0, UINT8_MAX, SATP) | ||
181 | +#define DO_RSHRUN_B(N, M, SATP) \ | ||
182 | + do_sat_bhs(do_srshr(N, M), 0, UINT8_MAX, SATP) | ||
183 | + | ||
184 | +#define DO_RSHRN_SH(N, M, SATP) \ | ||
185 | + do_sat_bhs(do_srshr(N, M), INT16_MIN, INT16_MAX, SATP) | ||
186 | +#define DO_RSHRN_UH(N, M, SATP) \ | ||
187 | + do_sat_bhs(do_urshr(N, M), 0, UINT16_MAX, SATP) | ||
188 | +#define DO_RSHRUN_H(N, M, SATP) \ | ||
189 | + do_sat_bhs(do_srshr(N, M), 0, UINT16_MAX, SATP) | ||
190 | + | ||
191 | +DO_VSHRN_SAT_SB(vqshrnb_sb, vqshrnt_sb, DO_SHRN_SB) | ||
192 | +DO_VSHRN_SAT_SH(vqshrnb_sh, vqshrnt_sh, DO_SHRN_SH) | ||
193 | +DO_VSHRN_SAT_UB(vqshrnb_ub, vqshrnt_ub, DO_SHRN_UB) | ||
194 | +DO_VSHRN_SAT_UH(vqshrnb_uh, vqshrnt_uh, DO_SHRN_UH) | ||
195 | +DO_VSHRN_SAT_SB(vqshrunbb, vqshruntb, DO_SHRUN_B) | ||
196 | +DO_VSHRN_SAT_SH(vqshrunbh, vqshrunth, DO_SHRUN_H) | ||
197 | + | ||
198 | +DO_VSHRN_SAT_SB(vqrshrnb_sb, vqrshrnt_sb, DO_RSHRN_SB) | ||
199 | +DO_VSHRN_SAT_SH(vqrshrnb_sh, vqrshrnt_sh, DO_RSHRN_SH) | ||
200 | +DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB) | ||
201 | +DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) | ||
202 | +DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) | ||
203 | +DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) | ||
204 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
205 | index XXXXXXX..XXXXXXX 100644 | ||
206 | --- a/target/arm/translate-mve.c | ||
207 | +++ b/target/arm/translate-mve.c | ||
208 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_N(VSHRNB, vshrnb) | ||
209 | DO_2SHIFT_N(VSHRNT, vshrnt) | ||
210 | DO_2SHIFT_N(VRSHRNB, vrshrnb) | ||
211 | DO_2SHIFT_N(VRSHRNT, vrshrnt) | ||
212 | +DO_2SHIFT_N(VQSHRNB_S, vqshrnb_s) | ||
213 | +DO_2SHIFT_N(VQSHRNT_S, vqshrnt_s) | ||
214 | +DO_2SHIFT_N(VQSHRNB_U, vqshrnb_u) | ||
215 | +DO_2SHIFT_N(VQSHRNT_U, vqshrnt_u) | ||
216 | +DO_2SHIFT_N(VQSHRUNB, vqshrunb) | ||
217 | +DO_2SHIFT_N(VQSHRUNT, vqshrunt) | ||
218 | +DO_2SHIFT_N(VQRSHRNB_S, vqrshrnb_s) | ||
219 | +DO_2SHIFT_N(VQRSHRNT_S, vqrshrnt_s) | ||
220 | +DO_2SHIFT_N(VQRSHRNB_U, vqrshrnb_u) | ||
221 | +DO_2SHIFT_N(VQRSHRNT_U, vqrshrnt_u) | ||
222 | +DO_2SHIFT_N(VQRSHRUNB, vqrshrunb) | ||
223 | +DO_2SHIFT_N(VQRSHRUNT, vqrshrunt) | ||
119 | -- | 224 | -- |
120 | 2.20.1 | 225 | 2.20.1 |
121 | 226 | ||
122 | 227 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | Implement the MVE VSHLC insn, which performs a shift left of the |
---|---|---|---|
2 | entire vector with carry in bits provided from a general purpose | ||
3 | register and carry out bits written back to that register. | ||
2 | 4 | ||
3 | We are about to allow the memory map to grow beyond 1TB and | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | potentially overshoot the VCPU AA64MMFR0.PARANGE. | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20210628135835.6690-14-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/helper-mve.h | 2 ++ | ||
10 | target/arm/mve.decode | 2 ++ | ||
11 | target/arm/mve_helper.c | 38 ++++++++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 30 ++++++++++++++++++++++++++++++ | ||
13 | 4 files changed, 72 insertions(+) | ||
5 | 14 | ||
6 | In aarch64 mode and when highmem is set, let's check the VCPU | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
7 | PA range is sufficient to address the highest GPA of the memory | ||
8 | map. | ||
9 | |||
10 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
12 | Message-id: 20190304101339.25970-10-eric.auger@redhat.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | hw/arm/virt.c | 17 +++++++++++++++++ | ||
16 | 1 file changed, 17 insertions(+) | ||
17 | |||
18 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/arm/virt.c | 17 | --- a/target/arm/helper-mve.h |
21 | +++ b/hw/arm/virt.c | 18 | +++ b/target/arm/helper-mve.h |
22 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | #include "standard-headers/linux/input.h" | 20 | DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
24 | #include "hw/arm/smmuv3.h" | 21 | DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
25 | #include "hw/acpi/acpi.h" | 22 | DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
26 | +#include "target/arm/internals.h" | ||
27 | |||
28 | #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ | ||
29 | static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ | ||
30 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
31 | fdt_add_timer_nodes(vms); | ||
32 | fdt_add_cpu_nodes(vms); | ||
33 | |||
34 | + if (!kvm_enabled()) { | ||
35 | + ARMCPU *cpu = ARM_CPU(first_cpu); | ||
36 | + bool aarch64 = object_property_get_bool(OBJECT(cpu), "aarch64", NULL); | ||
37 | + | 23 | + |
38 | + if (aarch64 && vms->highmem) { | 24 | +DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
39 | + int requested_pa_size, pamax = arm_pamax(cpu); | 25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/mve.decode | ||
28 | +++ b/target/arm/mve.decode | ||
29 | @@ -XXX,XX +XXX,XX @@ VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b | ||
30 | VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | ||
31 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b | ||
32 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h | ||
40 | + | 33 | + |
41 | + requested_pa_size = 64 - clz64(vms->highest_gpa); | 34 | +VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd |
42 | + if (pamax < requested_pa_size) { | 35 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
43 | + error_report("VCPU supports less PA bits (%d) than requested " | 36 | index XXXXXXX..XXXXXXX 100644 |
44 | + "by the memory map (%d)", pamax, requested_pa_size); | 37 | --- a/target/arm/mve_helper.c |
45 | + exit(1); | 38 | +++ b/target/arm/mve_helper.c |
39 | @@ -XXX,XX +XXX,XX @@ DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB) | ||
40 | DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) | ||
41 | DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) | ||
42 | DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) | ||
43 | + | ||
44 | +uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
45 | + uint32_t shift) | ||
46 | +{ | ||
47 | + uint32_t *d = vd; | ||
48 | + uint16_t mask = mve_element_mask(env); | ||
49 | + unsigned e; | ||
50 | + uint32_t r; | ||
51 | + | ||
52 | + /* | ||
53 | + * For each 32-bit element, we shift it left, bringing in the | ||
54 | + * low 'shift' bits of rdm at the bottom. Bits shifted out at | ||
55 | + * the top become the new rdm, if the predicate mask permits. | ||
56 | + * The final rdm value is returned to update the register. | ||
57 | + * shift == 0 here means "shift by 32 bits". | ||
58 | + */ | ||
59 | + if (shift == 0) { | ||
60 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { | ||
61 | + r = rdm; | ||
62 | + if (mask & 1) { | ||
63 | + rdm = d[H4(e)]; | ||
46 | + } | 64 | + } |
65 | + mergemask(&d[H4(e)], r, mask); | ||
66 | + } | ||
67 | + } else { | ||
68 | + uint32_t shiftmask = MAKE_64BIT_MASK(0, shift); | ||
69 | + | ||
70 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { | ||
71 | + r = (d[H4(e)] << shift) | (rdm & shiftmask); | ||
72 | + if (mask & 1) { | ||
73 | + rdm = d[H4(e)] >> (32 - shift); | ||
74 | + } | ||
75 | + mergemask(&d[H4(e)], r, mask); | ||
47 | + } | 76 | + } |
48 | + } | 77 | + } |
78 | + mve_advance_vpt(env); | ||
79 | + return rdm; | ||
80 | +} | ||
81 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
82 | index XXXXXXX..XXXXXXX 100644 | ||
83 | --- a/target/arm/translate-mve.c | ||
84 | +++ b/target/arm/translate-mve.c | ||
85 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_N(VQRSHRNB_U, vqrshrnb_u) | ||
86 | DO_2SHIFT_N(VQRSHRNT_U, vqrshrnt_u) | ||
87 | DO_2SHIFT_N(VQRSHRUNB, vqrshrunb) | ||
88 | DO_2SHIFT_N(VQRSHRUNT, vqrshrunt) | ||
49 | + | 89 | + |
50 | memory_region_allocate_system_memory(ram, NULL, "mach-virt.ram", | 90 | +static bool trans_VSHLC(DisasContext *s, arg_VSHLC *a) |
51 | machine->ram_size); | 91 | +{ |
52 | memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram); | 92 | + /* |
93 | + * Whole Vector Left Shift with Carry. The carry is taken | ||
94 | + * from a general purpose register and written back there. | ||
95 | + * An imm of 0 means "shift by 32". | ||
96 | + */ | ||
97 | + TCGv_ptr qd; | ||
98 | + TCGv_i32 rdm; | ||
99 | + | ||
100 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd)) { | ||
101 | + return false; | ||
102 | + } | ||
103 | + if (a->rdm == 13 || a->rdm == 15) { | ||
104 | + /* CONSTRAINED UNPREDICTABLE: we UNDEF */ | ||
105 | + return false; | ||
106 | + } | ||
107 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
108 | + return true; | ||
109 | + } | ||
110 | + | ||
111 | + qd = mve_qreg_ptr(a->qd); | ||
112 | + rdm = load_reg(s, a->rdm); | ||
113 | + gen_helper_mve_vshlc(rdm, cpu_env, qd, rdm, tcg_constant_i32(a->imm)); | ||
114 | + store_reg(s, a->rdm, rdm); | ||
115 | + tcg_temp_free_ptr(qd); | ||
116 | + mve_update_eci(s); | ||
117 | + return true; | ||
118 | +} | ||
53 | -- | 119 | -- |
54 | 2.20.1 | 120 | 2.20.1 |
55 | 121 | ||
56 | 122 | diff view generated by jsdifflib |
1 | From: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> | 1 | Implement the MVE VADDLV insn; this is similar to VADDV, except |
---|---|---|---|
2 | that it accumulates 32-bit elements into a 64-bit accumulator | ||
3 | stored in a pair of general-purpose registers. | ||
2 | 4 | ||
3 | We introduce an helper to create a memory node. | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20210628135835.6690-15-peter.maydell@linaro.org | ||
8 | --- | ||
9 | target/arm/helper-mve.h | 3 ++ | ||
10 | target/arm/mve.decode | 6 +++- | ||
11 | target/arm/mve_helper.c | 19 ++++++++++++ | ||
12 | target/arm/translate-mve.c | 63 ++++++++++++++++++++++++++++++++++++++ | ||
13 | 4 files changed, 90 insertions(+), 1 deletion(-) | ||
4 | 14 | ||
5 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
6 | Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> | ||
7 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20190304101339.25970-2-eric.auger@redhat.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/boot.c | 54 ++++++++++++++++++++++++++++++++------------------- | ||
13 | 1 file changed, 34 insertions(+), 20 deletions(-) | ||
14 | |||
15 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/boot.c | 17 | --- a/target/arm/helper-mve.h |
18 | +++ b/hw/arm/boot.c | 18 | +++ b/target/arm/helper-mve.h |
19 | @@ -XXX,XX +XXX,XX @@ static void set_kernel_args_old(const struct arm_boot_info *info, | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) |
20 | } | 20 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
21 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | ||
22 | |||
23 | +DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
24 | +DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) | ||
25 | + | ||
26 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
27 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
28 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) | ||
29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/mve.decode | ||
32 | +++ b/target/arm/mve.decode | ||
33 | @@ -XXX,XX +XXX,XX @@ VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
34 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar | ||
35 | |||
36 | # Vector add across vector | ||
37 | -VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
38 | +{ | ||
39 | + VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | ||
40 | + VADDLV 111 u:1 1110 1 ... 1001 ... 0 1111 00 a:1 0 qm:3 0 \ | ||
41 | + rdahi=%rdahi rdalo=%rdalo | ||
42 | +} | ||
43 | |||
44 | # Predicate operations | ||
45 | %mask_22_13 22:1 13:3 | ||
46 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/mve_helper.c | ||
49 | +++ b/target/arm/mve_helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvub, 1, uint8_t) | ||
51 | DO_VADDV(vaddvuh, 2, uint16_t) | ||
52 | DO_VADDV(vaddvuw, 4, uint32_t) | ||
53 | |||
54 | +#define DO_VADDLV(OP, TYPE, LTYPE) \ | ||
55 | + uint64_t HELPER(glue(mve_, OP))(CPUARMState *env, void *vm, \ | ||
56 | + uint64_t ra) \ | ||
57 | + { \ | ||
58 | + uint16_t mask = mve_element_mask(env); \ | ||
59 | + unsigned e; \ | ||
60 | + TYPE *m = vm; \ | ||
61 | + for (e = 0; e < 16 / 4; e++, mask >>= 4) { \ | ||
62 | + if (mask & 1) { \ | ||
63 | + ra += (LTYPE)m[H4(e)]; \ | ||
64 | + } \ | ||
65 | + } \ | ||
66 | + mve_advance_vpt(env); \ | ||
67 | + return ra; \ | ||
68 | + } \ | ||
69 | + | ||
70 | +DO_VADDLV(vaddlv_s, int32_t, int64_t) | ||
71 | +DO_VADDLV(vaddlv_u, uint32_t, uint64_t) | ||
72 | + | ||
73 | /* Shifts by immediate */ | ||
74 | #define DO_2SHIFT(OP, ESIZE, TYPE, FN) \ | ||
75 | void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
76 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/target/arm/translate-mve.c | ||
79 | +++ b/target/arm/translate-mve.c | ||
80 | @@ -XXX,XX +XXX,XX @@ static bool trans_VADDV(DisasContext *s, arg_VADDV *a) | ||
81 | return true; | ||
21 | } | 82 | } |
22 | 83 | ||
23 | +static int fdt_add_memory_node(void *fdt, uint32_t acells, hwaddr mem_base, | 84 | +static bool trans_VADDLV(DisasContext *s, arg_VADDLV *a) |
24 | + uint32_t scells, hwaddr mem_len, | ||
25 | + int numa_node_id) | ||
26 | +{ | 85 | +{ |
27 | + char *nodename; | 86 | + /* |
28 | + int ret; | 87 | + * Vector Add Long Across Vector: accumulate the 32-bit |
88 | + * elements of the vector into a 64-bit result stored in | ||
89 | + * a pair of general-purpose registers. | ||
90 | + * No need to check Qm's bank: it is only 3 bits in decode. | ||
91 | + */ | ||
92 | + TCGv_ptr qm; | ||
93 | + TCGv_i64 rda; | ||
94 | + TCGv_i32 rdalo, rdahi; | ||
29 | + | 95 | + |
30 | + nodename = g_strdup_printf("/memory@%" PRIx64, mem_base); | 96 | + if (!dc_isar_feature(aa32_mve, s)) { |
31 | + qemu_fdt_add_subnode(fdt, nodename); | 97 | + return false; |
32 | + qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); | 98 | + } |
33 | + ret = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", acells, mem_base, | 99 | + /* |
34 | + scells, mem_len); | 100 | + * rdahi == 13 is UNPREDICTABLE; rdahi == 15 is a related |
35 | + if (ret < 0) { | 101 | + * encoding; rdalo always has bit 0 clear so cannot be 13 or 15. |
36 | + goto out; | 102 | + */ |
103 | + if (a->rdahi == 13 || a->rdahi == 15) { | ||
104 | + return false; | ||
105 | + } | ||
106 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { | ||
107 | + return true; | ||
37 | + } | 108 | + } |
38 | + | 109 | + |
39 | + /* only set the NUMA ID if it is specified */ | 110 | + /* |
40 | + if (numa_node_id >= 0) { | 111 | + * This insn is subject to beat-wise execution. Partial execution |
41 | + ret = qemu_fdt_setprop_cell(fdt, nodename, | 112 | + * of an A=0 (no-accumulate) insn which does not execute the first |
42 | + "numa-node-id", numa_node_id); | 113 | + * beat must start with the current value of RdaHi:RdaLo, not zero. |
114 | + */ | ||
115 | + if (a->a || mve_skip_first_beat(s)) { | ||
116 | + /* Accumulate input from RdaHi:RdaLo */ | ||
117 | + rda = tcg_temp_new_i64(); | ||
118 | + rdalo = load_reg(s, a->rdalo); | ||
119 | + rdahi = load_reg(s, a->rdahi); | ||
120 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); | ||
121 | + tcg_temp_free_i32(rdalo); | ||
122 | + tcg_temp_free_i32(rdahi); | ||
123 | + } else { | ||
124 | + /* Accumulate starting at zero */ | ||
125 | + rda = tcg_const_i64(0); | ||
43 | + } | 126 | + } |
44 | +out: | 127 | + |
45 | + g_free(nodename); | 128 | + qm = mve_qreg_ptr(a->qm); |
46 | + return ret; | 129 | + if (a->u) { |
130 | + gen_helper_mve_vaddlv_u(rda, cpu_env, qm, rda); | ||
131 | + } else { | ||
132 | + gen_helper_mve_vaddlv_s(rda, cpu_env, qm, rda); | ||
133 | + } | ||
134 | + tcg_temp_free_ptr(qm); | ||
135 | + | ||
136 | + rdalo = tcg_temp_new_i32(); | ||
137 | + rdahi = tcg_temp_new_i32(); | ||
138 | + tcg_gen_extrl_i64_i32(rdalo, rda); | ||
139 | + tcg_gen_extrh_i64_i32(rdahi, rda); | ||
140 | + store_reg(s, a->rdalo, rdalo); | ||
141 | + store_reg(s, a->rdahi, rdahi); | ||
142 | + tcg_temp_free_i64(rda); | ||
143 | + mve_update_eci(s); | ||
144 | + return true; | ||
47 | +} | 145 | +} |
48 | + | 146 | + |
49 | static void fdt_add_psci_node(void *fdt) | 147 | static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn) |
50 | { | 148 | { |
51 | uint32_t cpu_suspend_fn; | 149 | TCGv_ptr qd; |
52 | @@ -XXX,XX +XXX,XX @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, | ||
53 | void *fdt = NULL; | ||
54 | int size, rc, n = 0; | ||
55 | uint32_t acells, scells; | ||
56 | - char *nodename; | ||
57 | unsigned int i; | ||
58 | hwaddr mem_base, mem_len; | ||
59 | char **node_path; | ||
60 | @@ -XXX,XX +XXX,XX @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, | ||
61 | mem_base = binfo->loader_start; | ||
62 | for (i = 0; i < nb_numa_nodes; i++) { | ||
63 | mem_len = numa_info[i].node_mem; | ||
64 | - nodename = g_strdup_printf("/memory@%" PRIx64, mem_base); | ||
65 | - qemu_fdt_add_subnode(fdt, nodename); | ||
66 | - qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); | ||
67 | - rc = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", | ||
68 | - acells, mem_base, | ||
69 | - scells, mem_len); | ||
70 | + rc = fdt_add_memory_node(fdt, acells, mem_base, | ||
71 | + scells, mem_len, i); | ||
72 | if (rc < 0) { | ||
73 | - fprintf(stderr, "couldn't set %s/reg for node %d\n", nodename, | ||
74 | - i); | ||
75 | + fprintf(stderr, "couldn't add /memory@%"PRIx64" node\n", | ||
76 | + mem_base); | ||
77 | goto fail; | ||
78 | } | ||
79 | |||
80 | - qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", i); | ||
81 | mem_base += mem_len; | ||
82 | - g_free(nodename); | ||
83 | } | ||
84 | } else { | ||
85 | - nodename = g_strdup_printf("/memory@%" PRIx64, binfo->loader_start); | ||
86 | - qemu_fdt_add_subnode(fdt, nodename); | ||
87 | - qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); | ||
88 | - | ||
89 | - rc = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", | ||
90 | - acells, binfo->loader_start, | ||
91 | - scells, binfo->ram_size); | ||
92 | + rc = fdt_add_memory_node(fdt, acells, binfo->loader_start, | ||
93 | + scells, binfo->ram_size, -1); | ||
94 | if (rc < 0) { | ||
95 | - fprintf(stderr, "couldn't set %s reg\n", nodename); | ||
96 | + fprintf(stderr, "couldn't add /memory@%"PRIx64" node\n", | ||
97 | + binfo->loader_start); | ||
98 | goto fail; | ||
99 | } | ||
100 | - g_free(nodename); | ||
101 | } | ||
102 | |||
103 | rc = fdt_path_offset(fdt, "/chosen"); | ||
104 | -- | 150 | -- |
105 | 2.20.1 | 151 | 2.20.1 |
106 | 152 | ||
107 | 153 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | The MVE extension to v8.1M includes some new shift instructions which |
---|---|---|---|
2 | 2 | sit entirely within the non-coprocessor part of the encoding space | |
3 | This patch implements the machine class kvm_type() callback. | 3 | and which operate only on general-purpose registers. They take up |
4 | It returns the number of bits requested to implement the whole GPA | 4 | the space which was previously UNPREDICTABLE MOVS and ORRS encodings |
5 | range including the RAM and IO regions located beyond. | 5 | with Rm == 13 or 15. |
6 | The returned value is passed though the KVM_CREATE_VM ioctl and | 6 | |
7 | this allows KVM to set the stage2 tables dynamically. | 7 | Implement the long shifts by immediate, which perform shifts on a |
8 | 8 | pair of general-purpose registers treated as a 64-bit quantity, with | |
9 | To compute the highest GPA used in the memory map, kvm_type() | 9 | an immediate shift count between 1 and 32. |
10 | must freeze the memory map by calling virt_set_memmap(). | 10 | |
11 | 11 | Awkwardly, because the MOVS and ORRS trans functions do not UNDEF for | |
12 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | 12 | the Rm==13,15 case, we need to explicitly emit code to UNDEF for the |
13 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | 13 | cases where v8.1M now requires that. (Trying to change MOVS and ORRS |
14 | Message-id: 20190304101339.25970-9-eric.auger@redhat.com | 14 | is too difficult, because the functions that generate the code are |
15 | shared between a dozen different kinds of arithmetic or logical | ||
16 | instruction for all A32, T16 and T32 encodings, and for some insns | ||
17 | and some encodings Rm==13,15 are valid.) | ||
18 | |||
19 | We make the helper functions we need for UQSHLL and SQSHLL take | ||
20 | a 32-bit value which the helper casts to int8_t because we'll need | ||
21 | these helpers also for the shift-by-register insns, where the shift | ||
22 | count might be < 0 or > 32. | ||
23 | |||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
26 | Message-id: 20210628135835.6690-16-peter.maydell@linaro.org | ||
16 | --- | 27 | --- |
17 | hw/arm/virt.c | 39 ++++++++++++++++++++++++++++++++++++++- | 28 | target/arm/helper-mve.h | 3 ++ |
18 | 1 file changed, 38 insertions(+), 1 deletion(-) | 29 | target/arm/translate.h | 1 + |
19 | 30 | target/arm/t32.decode | 28 +++++++++++++ | |
20 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 31 | target/arm/mve_helper.c | 10 +++++ |
21 | index XXXXXXX..XXXXXXX 100644 | 32 | target/arm/translate.c | 90 +++++++++++++++++++++++++++++++++++++++++ |
22 | --- a/hw/arm/virt.c | 33 | 5 files changed, 132 insertions(+) |
23 | +++ b/hw/arm/virt.c | 34 | |
24 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 35 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
25 | bool firmware_loaded = bios_name || drive_get(IF_PFLASH, 0, 0); | 36 | index XXXXXXX..XXXXXXX 100644 |
26 | bool aarch64 = true; | 37 | --- a/target/arm/helper-mve.h |
27 | 38 | +++ b/target/arm/helper-mve.h | |
28 | - virt_set_memmap(vms); | 39 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
29 | + /* | 40 | DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
30 | + * In accelerated mode, the memory map is computed earlier in kvm_type() | 41 | |
31 | + * to create a VM with the right number of IPA bits. | 42 | DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
32 | + */ | 43 | + |
33 | + if (!vms->memmap) { | 44 | +DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
34 | + virt_set_memmap(vms); | 45 | +DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
35 | + } | 46 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
36 | 47 | index XXXXXXX..XXXXXXX 100644 | |
37 | /* We can probe only here because during property set | 48 | --- a/target/arm/translate.h |
38 | * KVM is not available yet | 49 | +++ b/target/arm/translate.h |
39 | @@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, | 50 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); |
40 | return NULL; | 51 | typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); |
41 | } | 52 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); |
53 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
54 | +typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | ||
55 | |||
56 | /** | ||
57 | * arm_tbflags_from_tb: | ||
58 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/arm/t32.decode | ||
61 | +++ b/target/arm/t32.decode | ||
62 | @@ -XXX,XX +XXX,XX @@ | ||
63 | &mcr !extern cp opc1 crn crm opc2 rt | ||
64 | &mcrr !extern cp opc1 crm rt rt2 | ||
65 | |||
66 | +&mve_shl_ri rdalo rdahi shim | ||
67 | + | ||
68 | +# rdahi: bits [3:1] from insn, bit 0 is 1 | ||
69 | +# rdalo: bits [3:1] from insn, bit 0 is 0 | ||
70 | +%rdahi_9 9:3 !function=times_2_plus_1 | ||
71 | +%rdalo_17 17:3 !function=times_2 | ||
72 | + | ||
73 | # Data-processing (register) | ||
74 | |||
75 | %imm5_12_6 12:3 6:2 | ||
76 | @@ -XXX,XX +XXX,XX @@ | ||
77 | @S_xrr_shi ....... .... . rn:4 .... .... .. shty:2 rm:4 \ | ||
78 | &s_rrr_shi shim=%imm5_12_6 s=1 rd=0 | ||
79 | |||
80 | +@mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \ | ||
81 | + &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
82 | + | ||
83 | { | ||
84 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | ||
85 | AND_rrri 1110101 0000 . .... 0 ... .... .... .... @s_rrr_shi | ||
86 | } | ||
87 | BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | ||
88 | { | ||
89 | + # The v8.1M MVE shift insns overlap in encoding with MOVS/ORRS | ||
90 | + # and are distinguished by having Rm==13 or 15. Those are UNPREDICTABLE | ||
91 | + # cases for MOVS/ORRS. We decode the MVE cases first, ensuring that | ||
92 | + # they explicitly call unallocated_encoding() for cases that must UNDEF | ||
93 | + # (eg "using a new shift insn on a v8.1M CPU without MVE"), and letting | ||
94 | + # the rest fall through (where ORR_rrri and MOV_rxri will end up | ||
95 | + # handling them as r13 and r15 accesses with the same semantics as A32). | ||
96 | + [ | ||
97 | + LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
98 | + LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
99 | + ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
100 | + | ||
101 | + UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri | ||
102 | + URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
103 | + SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
104 | + SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
105 | + ] | ||
106 | + | ||
107 | MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi | ||
108 | ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi | ||
109 | } | ||
110 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
111 | index XXXXXXX..XXXXXXX 100644 | ||
112 | --- a/target/arm/mve_helper.c | ||
113 | +++ b/target/arm/mve_helper.c | ||
114 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
115 | mve_advance_vpt(env); | ||
116 | return rdm; | ||
117 | } | ||
118 | + | ||
119 | +uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
120 | +{ | ||
121 | + return do_sqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
122 | +} | ||
123 | + | ||
124 | +uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
125 | +{ | ||
126 | + return do_uqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
127 | +} | ||
128 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
129 | index XXXXXXX..XXXXXXX 100644 | ||
130 | --- a/target/arm/translate.c | ||
131 | +++ b/target/arm/translate.c | ||
132 | @@ -XXX,XX +XXX,XX @@ static bool trans_MOVT(DisasContext *s, arg_MOVW *a) | ||
133 | return true; | ||
134 | } | ||
42 | 135 | ||
43 | +/* | 136 | +/* |
44 | + * for arm64 kvm_type [7-0] encodes the requested number of bits | 137 | + * v8.1M MVE wide-shifts |
45 | + * in the IPA address space | ||
46 | + */ | 138 | + */ |
47 | +static int virt_kvm_type(MachineState *ms, const char *type_str) | 139 | +static bool do_mve_shl_ri(DisasContext *s, arg_mve_shl_ri *a, |
48 | +{ | 140 | + WideShiftImmFn *fn) |
49 | + VirtMachineState *vms = VIRT_MACHINE(ms); | 141 | +{ |
50 | + int max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms); | 142 | + TCGv_i64 rda; |
51 | + int requested_pa_size; | 143 | + TCGv_i32 rdalo, rdahi; |
52 | + | 144 | + |
53 | + /* we freeze the memory map to compute the highest gpa */ | 145 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
54 | + virt_set_memmap(vms); | 146 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ |
55 | + | 147 | + return false; |
56 | + requested_pa_size = 64 - clz64(vms->highest_gpa); | 148 | + } |
57 | + | 149 | + if (a->rdahi == 15) { |
58 | + if (requested_pa_size > max_vm_pa_size) { | 150 | + /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */ |
59 | + error_report("-m and ,maxmem option values " | 151 | + return false; |
60 | + "require an IPA range (%d bits) larger than " | 152 | + } |
61 | + "the one supported by the host (%d bits)", | 153 | + if (!dc_isar_feature(aa32_mve, s) || |
62 | + requested_pa_size, max_vm_pa_size); | 154 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || |
63 | + exit(1); | 155 | + a->rdahi == 13) { |
64 | + } | 156 | + /* RdaHi == 13 is UNPREDICTABLE; we choose to UNDEF */ |
65 | + /* | 157 | + unallocated_encoding(s); |
66 | + * By default we return 0 which corresponds to an implicit legacy | 158 | + return true; |
67 | + * 40b IPA setting. Otherwise we return the actual requested PA | 159 | + } |
68 | + * logsize | 160 | + |
69 | + */ | 161 | + if (a->shim == 0) { |
70 | + return requested_pa_size > 40 ? requested_pa_size : 0; | 162 | + a->shim = 32; |
71 | +} | 163 | + } |
72 | + | 164 | + |
73 | static void virt_machine_class_init(ObjectClass *oc, void *data) | 165 | + rda = tcg_temp_new_i64(); |
74 | { | 166 | + rdalo = load_reg(s, a->rdalo); |
75 | MachineClass *mc = MACHINE_CLASS(oc); | 167 | + rdahi = load_reg(s, a->rdahi); |
76 | @@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data) | 168 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); |
77 | mc->cpu_index_to_instance_props = virt_cpu_index_to_props; | 169 | + |
78 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); | 170 | + fn(rda, rda, a->shim); |
79 | mc->get_default_cpu_node_id = virt_get_default_cpu_node_id; | 171 | + |
80 | + mc->kvm_type = virt_kvm_type; | 172 | + tcg_gen_extrl_i64_i32(rdalo, rda); |
81 | assert(!mc->get_hotplug_handler); | 173 | + tcg_gen_extrh_i64_i32(rdahi, rda); |
82 | mc->get_hotplug_handler = virt_machine_get_hotplug_handler; | 174 | + store_reg(s, a->rdalo, rdalo); |
83 | hc->plug = virt_machine_device_plug_cb; | 175 | + store_reg(s, a->rdahi, rdahi); |
176 | + tcg_temp_free_i64(rda); | ||
177 | + | ||
178 | + return true; | ||
179 | +} | ||
180 | + | ||
181 | +static bool trans_ASRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
182 | +{ | ||
183 | + return do_mve_shl_ri(s, a, tcg_gen_sari_i64); | ||
184 | +} | ||
185 | + | ||
186 | +static bool trans_LSLL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
187 | +{ | ||
188 | + return do_mve_shl_ri(s, a, tcg_gen_shli_i64); | ||
189 | +} | ||
190 | + | ||
191 | +static bool trans_LSRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
192 | +{ | ||
193 | + return do_mve_shl_ri(s, a, tcg_gen_shri_i64); | ||
194 | +} | ||
195 | + | ||
196 | +static void gen_mve_sqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift) | ||
197 | +{ | ||
198 | + gen_helper_mve_sqshll(r, cpu_env, n, tcg_constant_i32(shift)); | ||
199 | +} | ||
200 | + | ||
201 | +static bool trans_SQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
202 | +{ | ||
203 | + return do_mve_shl_ri(s, a, gen_mve_sqshll); | ||
204 | +} | ||
205 | + | ||
206 | +static void gen_mve_uqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift) | ||
207 | +{ | ||
208 | + gen_helper_mve_uqshll(r, cpu_env, n, tcg_constant_i32(shift)); | ||
209 | +} | ||
210 | + | ||
211 | +static bool trans_UQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
212 | +{ | ||
213 | + return do_mve_shl_ri(s, a, gen_mve_uqshll); | ||
214 | +} | ||
215 | + | ||
216 | +static bool trans_SRSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
217 | +{ | ||
218 | + return do_mve_shl_ri(s, a, gen_srshr64_i64); | ||
219 | +} | ||
220 | + | ||
221 | +static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
222 | +{ | ||
223 | + return do_mve_shl_ri(s, a, gen_urshr64_i64); | ||
224 | +} | ||
225 | + | ||
226 | /* | ||
227 | * Multiply and multiply accumulate | ||
228 | */ | ||
84 | -- | 229 | -- |
85 | 2.20.1 | 230 | 2.20.1 |
86 | 231 | ||
87 | 232 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE long shifts by register, which perform shifts on a |
---|---|---|---|
2 | 2 | pair of general-purpose registers treated as a 64-bit quantity, with | |
3 | Found by inspection: Rn is the base register against which the | 3 | the shift count in another general-purpose register, which might be |
4 | load began; I is the register within the mask being processed. | 4 | either positive or negative. |
5 | The exception return should of course be processed from the loaded PC. | 5 | |
6 | 6 | Like the long-shifts-by-immediate, these encodings sit in the space | |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | that was previously the UNPREDICTABLE MOVS/ORRS with Rm==13,15. |
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 8 | Because LSLL_rr and ASRL_rr overlap with both MOV_rxri/ORR_rrri and |
9 | Message-id: 20190301202921.21209-1-richard.henderson@linaro.org | 9 | also with CSEL (as one of the previously-UNPREDICTABLE Rm==13 cases), |
10 | we have to move the CSEL pattern into the same decodetree group. | ||
11 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20210628135835.6690-17-peter.maydell@linaro.org | ||
11 | --- | 15 | --- |
12 | target/arm/translate.c | 2 +- | 16 | target/arm/helper-mve.h | 6 +++ |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 17 | target/arm/translate.h | 1 + |
14 | 18 | target/arm/t32.decode | 16 +++++-- | |
19 | target/arm/mve_helper.c | 93 +++++++++++++++++++++++++++++++++++++++++ | ||
20 | target/arm/translate.c | 69 ++++++++++++++++++++++++++++++ | ||
21 | 5 files changed, 182 insertions(+), 3 deletions(-) | ||
22 | |||
23 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/target/arm/helper-mve.h | ||
26 | +++ b/target/arm/helper-mve.h | ||
27 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | |||
29 | DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) | ||
30 | |||
31 | +DEF_HELPER_FLAGS_3(mve_sshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
32 | +DEF_HELPER_FLAGS_3(mve_ushll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
33 | DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
34 | DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
35 | +DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
36 | +DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
37 | +DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
38 | +DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
39 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/translate.h | ||
42 | +++ b/target/arm/translate.h | ||
43 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); | ||
44 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
45 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
46 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | ||
47 | +typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); | ||
48 | |||
49 | /** | ||
50 | * arm_tbflags_from_tb: | ||
51 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/t32.decode | ||
54 | +++ b/target/arm/t32.decode | ||
55 | @@ -XXX,XX +XXX,XX @@ | ||
56 | &mcrr !extern cp opc1 crm rt rt2 | ||
57 | |||
58 | &mve_shl_ri rdalo rdahi shim | ||
59 | +&mve_shl_rr rdalo rdahi rm | ||
60 | |||
61 | # rdahi: bits [3:1] from insn, bit 0 is 1 | ||
62 | # rdalo: bits [3:1] from insn, bit 0 is 0 | ||
63 | @@ -XXX,XX +XXX,XX @@ | ||
64 | |||
65 | @mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \ | ||
66 | &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
67 | +@mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \ | ||
68 | + &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
69 | |||
70 | { | ||
71 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | ||
72 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | ||
73 | URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
74 | SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
75 | SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
76 | + | ||
77 | + LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | ||
78 | + ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | ||
79 | + UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr | ||
80 | + SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr | ||
81 | + UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr | ||
82 | + SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr | ||
83 | ] | ||
84 | |||
85 | MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi | ||
86 | ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi | ||
87 | + | ||
88 | + # v8.1M CSEL and friends | ||
89 | + CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4 | ||
90 | } | ||
91 | { | ||
92 | MVN_rxri 1110101 0011 . 1111 0 ... .... .... .... @s_rxr_shi | ||
93 | @@ -XXX,XX +XXX,XX @@ SBC_rrri 1110101 1011 . .... 0 ... .... .... .... @s_rrr_shi | ||
94 | } | ||
95 | RSB_rrri 1110101 1110 . .... 0 ... .... .... .... @s_rrr_shi | ||
96 | |||
97 | -# v8.1M CSEL and friends | ||
98 | -CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4 | ||
99 | - | ||
100 | # Data-processing (register-shifted register) | ||
101 | |||
102 | MOV_rxrr 1111 1010 0 shty:2 s:1 rm:4 1111 rd:4 0000 rs:4 \ | ||
103 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/target/arm/mve_helper.c | ||
106 | +++ b/target/arm/mve_helper.c | ||
107 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, | ||
108 | return rdm; | ||
109 | } | ||
110 | |||
111 | +uint64_t HELPER(mve_sshrl)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
112 | +{ | ||
113 | + return do_sqrshl_d(n, -(int8_t)shift, false, NULL); | ||
114 | +} | ||
115 | + | ||
116 | +uint64_t HELPER(mve_ushll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
117 | +{ | ||
118 | + return do_uqrshl_d(n, (int8_t)shift, false, NULL); | ||
119 | +} | ||
120 | + | ||
121 | uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
122 | { | ||
123 | return do_sqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
124 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
125 | { | ||
126 | return do_uqrshl_d(n, (int8_t)shift, false, &env->QF); | ||
127 | } | ||
128 | + | ||
129 | +uint64_t HELPER(mve_sqrshrl)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
130 | +{ | ||
131 | + return do_sqrshl_d(n, -(int8_t)shift, true, &env->QF); | ||
132 | +} | ||
133 | + | ||
134 | +uint64_t HELPER(mve_uqrshll)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
135 | +{ | ||
136 | + return do_uqrshl_d(n, (int8_t)shift, true, &env->QF); | ||
137 | +} | ||
138 | + | ||
139 | +/* Operate on 64-bit values, but saturate at 48 bits */ | ||
140 | +static inline int64_t do_sqrshl48_d(int64_t src, int64_t shift, | ||
141 | + bool round, uint32_t *sat) | ||
142 | +{ | ||
143 | + if (shift <= -48) { | ||
144 | + /* Rounding the sign bit always produces 0. */ | ||
145 | + if (round) { | ||
146 | + return 0; | ||
147 | + } | ||
148 | + return src >> 63; | ||
149 | + } else if (shift < 0) { | ||
150 | + if (round) { | ||
151 | + src >>= -shift - 1; | ||
152 | + return (src >> 1) + (src & 1); | ||
153 | + } | ||
154 | + return src >> -shift; | ||
155 | + } else if (shift < 48) { | ||
156 | + int64_t val = src << shift; | ||
157 | + int64_t extval = sextract64(val, 0, 48); | ||
158 | + if (!sat || val == extval) { | ||
159 | + return extval; | ||
160 | + } | ||
161 | + } else if (!sat || src == 0) { | ||
162 | + return 0; | ||
163 | + } | ||
164 | + | ||
165 | + *sat = 1; | ||
166 | + return (1ULL << 47) - (src >= 0); | ||
167 | +} | ||
168 | + | ||
169 | +/* Operate on 64-bit values, but saturate at 48 bits */ | ||
170 | +static inline uint64_t do_uqrshl48_d(uint64_t src, int64_t shift, | ||
171 | + bool round, uint32_t *sat) | ||
172 | +{ | ||
173 | + uint64_t val, extval; | ||
174 | + | ||
175 | + if (shift <= -(48 + round)) { | ||
176 | + return 0; | ||
177 | + } else if (shift < 0) { | ||
178 | + if (round) { | ||
179 | + val = src >> (-shift - 1); | ||
180 | + val = (val >> 1) + (val & 1); | ||
181 | + } else { | ||
182 | + val = src >> -shift; | ||
183 | + } | ||
184 | + extval = extract64(val, 0, 48); | ||
185 | + if (!sat || val == extval) { | ||
186 | + return extval; | ||
187 | + } | ||
188 | + } else if (shift < 48) { | ||
189 | + uint64_t val = src << shift; | ||
190 | + uint64_t extval = extract64(val, 0, 48); | ||
191 | + if (!sat || val == extval) { | ||
192 | + return extval; | ||
193 | + } | ||
194 | + } else if (!sat || src == 0) { | ||
195 | + return 0; | ||
196 | + } | ||
197 | + | ||
198 | + *sat = 1; | ||
199 | + return MAKE_64BIT_MASK(0, 48); | ||
200 | +} | ||
201 | + | ||
202 | +uint64_t HELPER(mve_sqrshrl48)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
203 | +{ | ||
204 | + return do_sqrshl48_d(n, -(int8_t)shift, true, &env->QF); | ||
205 | +} | ||
206 | + | ||
207 | +uint64_t HELPER(mve_uqrshll48)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
208 | +{ | ||
209 | + return do_uqrshl48_d(n, (int8_t)shift, true, &env->QF); | ||
210 | +} | ||
15 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 211 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
16 | index XXXXXXX..XXXXXXX 100644 | 212 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate.c | 213 | --- a/target/arm/translate.c |
18 | +++ b/target/arm/translate.c | 214 | +++ b/target/arm/translate.c |
19 | @@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) | 215 | @@ -XXX,XX +XXX,XX @@ static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) |
20 | } else if (i == rn) { | 216 | return do_mve_shl_ri(s, a, gen_urshr64_i64); |
21 | loaded_var = tmp; | 217 | } |
22 | loaded_base = 1; | 218 | |
23 | - } else if (rn == 15 && exc_return) { | 219 | +static bool do_mve_shl_rr(DisasContext *s, arg_mve_shl_rr *a, WideShiftFn *fn) |
24 | + } else if (i == 15 && exc_return) { | 220 | +{ |
25 | store_pc_exc_ret(s, tmp); | 221 | + TCGv_i64 rda; |
26 | } else { | 222 | + TCGv_i32 rdalo, rdahi; |
27 | store_reg_from_load(s, i, tmp); | 223 | + |
224 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
225 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
226 | + return false; | ||
227 | + } | ||
228 | + if (a->rdahi == 15) { | ||
229 | + /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */ | ||
230 | + return false; | ||
231 | + } | ||
232 | + if (!dc_isar_feature(aa32_mve, s) || | ||
233 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || | ||
234 | + a->rdahi == 13 || a->rm == 13 || a->rm == 15 || | ||
235 | + a->rm == a->rdahi || a->rm == a->rdalo) { | ||
236 | + /* These rdahi/rdalo/rm cases are UNPREDICTABLE; we choose to UNDEF */ | ||
237 | + unallocated_encoding(s); | ||
238 | + return true; | ||
239 | + } | ||
240 | + | ||
241 | + rda = tcg_temp_new_i64(); | ||
242 | + rdalo = load_reg(s, a->rdalo); | ||
243 | + rdahi = load_reg(s, a->rdahi); | ||
244 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); | ||
245 | + | ||
246 | + /* The helper takes care of the sign-extension of the low 8 bits of Rm */ | ||
247 | + fn(rda, cpu_env, rda, cpu_R[a->rm]); | ||
248 | + | ||
249 | + tcg_gen_extrl_i64_i32(rdalo, rda); | ||
250 | + tcg_gen_extrh_i64_i32(rdahi, rda); | ||
251 | + store_reg(s, a->rdalo, rdalo); | ||
252 | + store_reg(s, a->rdahi, rdahi); | ||
253 | + tcg_temp_free_i64(rda); | ||
254 | + | ||
255 | + return true; | ||
256 | +} | ||
257 | + | ||
258 | +static bool trans_LSLL_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
259 | +{ | ||
260 | + return do_mve_shl_rr(s, a, gen_helper_mve_ushll); | ||
261 | +} | ||
262 | + | ||
263 | +static bool trans_ASRL_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
264 | +{ | ||
265 | + return do_mve_shl_rr(s, a, gen_helper_mve_sshrl); | ||
266 | +} | ||
267 | + | ||
268 | +static bool trans_UQRSHLL64_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
269 | +{ | ||
270 | + return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll); | ||
271 | +} | ||
272 | + | ||
273 | +static bool trans_SQRSHRL64_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
274 | +{ | ||
275 | + return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl); | ||
276 | +} | ||
277 | + | ||
278 | +static bool trans_UQRSHLL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
279 | +{ | ||
280 | + return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll48); | ||
281 | +} | ||
282 | + | ||
283 | +static bool trans_SQRSHRL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
284 | +{ | ||
285 | + return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl48); | ||
286 | +} | ||
287 | + | ||
288 | /* | ||
289 | * Multiply and multiply accumulate | ||
290 | */ | ||
28 | -- | 291 | -- |
29 | 2.20.1 | 292 | 2.20.1 |
30 | 293 | ||
31 | 294 | diff view generated by jsdifflib |
1 | From: Eric Auger <eric.auger@redhat.com> | 1 | Implement the MVE shifts by immediate, which perform shifts |
---|---|---|---|
2 | 2 | on a single general-purpose register. | |
3 | Now we have the extended memory map (high IO regions beyond the | 3 | |
4 | scalable RAM) and dynamic IPA range support at KVM/ARM level | 4 | These patterns overlap with the long-shift-by-immediates, |
5 | we can bump the legacy 255GB initial RAM limit. The actual maximum | 5 | so we have to rearrange the grouping a little here. |
6 | RAM size now depends on the physical CPU and host kernel, in | 6 | |
7 | accelerated mode. In TCG mode, it depends on the VCPU | ||
8 | AA64MMFR0.PARANGE. | ||
9 | |||
10 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
12 | Message-id: 20190304101339.25970-11-eric.auger@redhat.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210628135835.6690-18-peter.maydell@linaro.org | ||
14 | --- | 10 | --- |
15 | hw/arm/virt.c | 21 +-------------------- | 11 | target/arm/helper-mve.h | 3 ++ |
16 | 1 file changed, 1 insertion(+), 20 deletions(-) | 12 | target/arm/translate.h | 1 + |
17 | 13 | target/arm/t32.decode | 31 ++++++++++++++----- | |
18 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | 14 | target/arm/mve_helper.c | 10 ++++++ |
19 | index XXXXXXX..XXXXXXX 100644 | 15 | target/arm/translate.c | 68 +++++++++++++++++++++++++++++++++++++++-- |
20 | --- a/hw/arm/virt.c | 16 | 5 files changed, 104 insertions(+), 9 deletions(-) |
21 | +++ b/hw/arm/virt.c | 17 | |
18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/helper-mve.h | ||
21 | +++ b/target/arm/helper-mve.h | ||
22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
23 | DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
24 | DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
25 | DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) | ||
26 | + | ||
27 | +DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
28 | +DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
29 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/arm/translate.h | ||
32 | +++ b/target/arm/translate.h | ||
33 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); | ||
34 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
35 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | ||
36 | typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); | ||
37 | +typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift); | ||
38 | |||
39 | /** | ||
40 | * arm_tbflags_from_tb: | ||
41 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/target/arm/t32.decode | ||
44 | +++ b/target/arm/t32.decode | ||
22 | @@ -XXX,XX +XXX,XX @@ | 45 | @@ -XXX,XX +XXX,XX @@ |
23 | 46 | ||
24 | #define PLATFORM_BUS_NUM_IRQS 64 | 47 | &mve_shl_ri rdalo rdahi shim |
25 | 48 | &mve_shl_rr rdalo rdahi rm | |
26 | -/* RAM limit in GB. Since VIRT_MEM starts at the 1GB mark, this means | 49 | +&mve_sh_ri rda shim |
27 | - * RAM can go up to the 256GB mark, leaving 256GB of the physical | 50 | |
28 | - * address space unallocated and free for future use between 256G and 512G. | 51 | # rdahi: bits [3:1] from insn, bit 0 is 1 |
29 | - * If we need to provide more RAM to VMs in the future then we need to: | 52 | # rdalo: bits [3:1] from insn, bit 0 is 0 |
30 | - * * allocate a second bank of RAM starting at 2TB and working up | 53 | @@ -XXX,XX +XXX,XX @@ |
31 | - * * fix the DT and ACPI table generation code in QEMU to correctly | 54 | &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 |
32 | - * report two split lumps of RAM to the guest | 55 | @mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \ |
33 | - * * fix KVM in the host kernel to allow guests with >40 bit address spaces | 56 | &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 |
34 | - * (We don't want to fill all the way up to 512GB with RAM because | 57 | +@mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \ |
35 | - * we might want it for non-RAM purposes later. Conversely it seems | 58 | + &mve_sh_ri shim=%imm5_12_6 |
36 | - * reasonable to assume that anybody configuring a VM with a quarter | 59 | |
37 | - * of a terabyte of RAM will be doing it on a host with more than a | 60 | { |
38 | - * terabyte of physical address space.) | 61 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi |
39 | - */ | 62 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi |
40 | +/* Legacy RAM limit in GB (< version 4.0) */ | 63 | # the rest fall through (where ORR_rrri and MOV_rxri will end up |
41 | #define LEGACY_RAMLIMIT_GB 255 | 64 | # handling them as r13 and r15 accesses with the same semantics as A32). |
42 | #define LEGACY_RAMLIMIT_BYTES (LEGACY_RAMLIMIT_GB * GiB) | 65 | [ |
43 | 66 | - LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri | |
44 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | 67 | - LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri |
45 | 68 | - ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri | |
46 | vms->smp_cpus = smp_cpus; | 69 | + { |
47 | 70 | + UQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 00 1111 @mve_sh_ri | |
48 | - if (machine->ram_size > vms->memmap[VIRT_MEM].size) { | 71 | + LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri |
49 | - error_report("mach-virt: cannot model more than %dGB RAM", | 72 | + UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri |
50 | - LEGACY_RAMLIMIT_GB); | 73 | + } |
51 | - exit(1); | 74 | |
52 | - } | 75 | - UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri |
53 | - | 76 | - URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri |
54 | if (vms->virt && kvm_enabled()) { | 77 | - SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri |
55 | error_report("mach-virt: KVM does not support providing " | 78 | - SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri |
56 | "Virtualization extensions to the guest CPU"); | 79 | + { |
80 | + URSHR_ri 1110101 0010 1 .... 0 ... 1111 .. 01 1111 @mve_sh_ri | ||
81 | + LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
82 | + URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | ||
83 | + } | ||
84 | + | ||
85 | + { | ||
86 | + SRSHR_ri 1110101 0010 1 .... 0 ... 1111 .. 10 1111 @mve_sh_ri | ||
87 | + ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
88 | + SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri | ||
89 | + } | ||
90 | + | ||
91 | + { | ||
92 | + SQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 11 1111 @mve_sh_ri | ||
93 | + SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
94 | + } | ||
95 | |||
96 | LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | ||
97 | ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | ||
98 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
99 | index XXXXXXX..XXXXXXX 100644 | ||
100 | --- a/target/arm/mve_helper.c | ||
101 | +++ b/target/arm/mve_helper.c | ||
102 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqrshll48)(CPUARMState *env, uint64_t n, uint32_t shift) | ||
103 | { | ||
104 | return do_uqrshl48_d(n, (int8_t)shift, true, &env->QF); | ||
105 | } | ||
106 | + | ||
107 | +uint32_t HELPER(mve_uqshl)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
108 | +{ | ||
109 | + return do_uqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); | ||
110 | +} | ||
111 | + | ||
112 | +uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
113 | +{ | ||
114 | + return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); | ||
115 | +} | ||
116 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/target/arm/translate.c | ||
119 | +++ b/target/arm/translate.c | ||
120 | @@ -XXX,XX +XXX,XX @@ static void gen_srshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh) | ||
121 | |||
122 | static void gen_srshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh) | ||
123 | { | ||
124 | - TCGv_i32 t = tcg_temp_new_i32(); | ||
125 | + TCGv_i32 t; | ||
126 | |||
127 | + /* Handle shift by the input size for the benefit of trans_SRSHR_ri */ | ||
128 | + if (sh == 32) { | ||
129 | + tcg_gen_movi_i32(d, 0); | ||
130 | + return; | ||
131 | + } | ||
132 | + t = tcg_temp_new_i32(); | ||
133 | tcg_gen_extract_i32(t, a, sh - 1, 1); | ||
134 | tcg_gen_sari_i32(d, a, sh); | ||
135 | tcg_gen_add_i32(d, d, t); | ||
136 | @@ -XXX,XX +XXX,XX @@ static void gen_urshr16_i64(TCGv_i64 d, TCGv_i64 a, int64_t sh) | ||
137 | |||
138 | static void gen_urshr32_i32(TCGv_i32 d, TCGv_i32 a, int32_t sh) | ||
139 | { | ||
140 | - TCGv_i32 t = tcg_temp_new_i32(); | ||
141 | + TCGv_i32 t; | ||
142 | |||
143 | + /* Handle shift by the input size for the benefit of trans_URSHR_ri */ | ||
144 | + if (sh == 32) { | ||
145 | + tcg_gen_extract_i32(d, a, sh - 1, 1); | ||
146 | + return; | ||
147 | + } | ||
148 | + t = tcg_temp_new_i32(); | ||
149 | tcg_gen_extract_i32(t, a, sh - 1, 1); | ||
150 | tcg_gen_shri_i32(d, a, sh); | ||
151 | tcg_gen_add_i32(d, d, t); | ||
152 | @@ -XXX,XX +XXX,XX @@ static bool trans_SQRSHRL48_rr(DisasContext *s, arg_mve_shl_rr *a) | ||
153 | return do_mve_shl_rr(s, a, gen_helper_mve_sqrshrl48); | ||
154 | } | ||
155 | |||
156 | +static bool do_mve_sh_ri(DisasContext *s, arg_mve_sh_ri *a, ShiftImmFn *fn) | ||
157 | +{ | ||
158 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
159 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
160 | + return false; | ||
161 | + } | ||
162 | + if (!dc_isar_feature(aa32_mve, s) || | ||
163 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || | ||
164 | + a->rda == 13 || a->rda == 15) { | ||
165 | + /* These rda cases are UNPREDICTABLE; we choose to UNDEF */ | ||
166 | + unallocated_encoding(s); | ||
167 | + return true; | ||
168 | + } | ||
169 | + | ||
170 | + if (a->shim == 0) { | ||
171 | + a->shim = 32; | ||
172 | + } | ||
173 | + fn(cpu_R[a->rda], cpu_R[a->rda], a->shim); | ||
174 | + | ||
175 | + return true; | ||
176 | +} | ||
177 | + | ||
178 | +static bool trans_URSHR_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
179 | +{ | ||
180 | + return do_mve_sh_ri(s, a, gen_urshr32_i32); | ||
181 | +} | ||
182 | + | ||
183 | +static bool trans_SRSHR_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
184 | +{ | ||
185 | + return do_mve_sh_ri(s, a, gen_srshr32_i32); | ||
186 | +} | ||
187 | + | ||
188 | +static void gen_mve_sqshl(TCGv_i32 r, TCGv_i32 n, int32_t shift) | ||
189 | +{ | ||
190 | + gen_helper_mve_sqshl(r, cpu_env, n, tcg_constant_i32(shift)); | ||
191 | +} | ||
192 | + | ||
193 | +static bool trans_SQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
194 | +{ | ||
195 | + return do_mve_sh_ri(s, a, gen_mve_sqshl); | ||
196 | +} | ||
197 | + | ||
198 | +static void gen_mve_uqshl(TCGv_i32 r, TCGv_i32 n, int32_t shift) | ||
199 | +{ | ||
200 | + gen_helper_mve_uqshl(r, cpu_env, n, tcg_constant_i32(shift)); | ||
201 | +} | ||
202 | + | ||
203 | +static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) | ||
204 | +{ | ||
205 | + return do_mve_sh_ri(s, a, gen_mve_uqshl); | ||
206 | +} | ||
207 | + | ||
208 | /* | ||
209 | * Multiply and multiply accumulate | ||
210 | */ | ||
57 | -- | 211 | -- |
58 | 2.20.1 | 212 | 2.20.1 |
59 | 213 | ||
60 | 214 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE shifts by register, which perform |
---|---|---|---|
2 | shifts on a single general-purpose register. | ||
2 | 3 | ||
3 | Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com> | ||
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20190301200501.16533-8-richard.henderson@linaro.org | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | [PMM: fixed up block comment style] | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210628135835.6690-19-peter.maydell@linaro.org | ||
9 | --- | 7 | --- |
10 | target/arm/cpu.h | 5 ++ | 8 | target/arm/helper-mve.h | 2 ++ |
11 | linux-user/elfload.c | 1 + | 9 | target/arm/translate.h | 1 + |
12 | target/arm/cpu64.c | 1 + | 10 | target/arm/t32.decode | 18 ++++++++++++++---- |
13 | target/arm/translate-a64.c | 99 +++++++++++++++++++++++++++++++++++++- | 11 | target/arm/mve_helper.c | 10 ++++++++++ |
14 | 4 files changed, 105 insertions(+), 1 deletion(-) | 12 | target/arm/translate.c | 30 ++++++++++++++++++++++++++++++ |
13 | 5 files changed, 57 insertions(+), 4 deletions(-) | ||
15 | 14 | ||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 17 | --- a/target/arm/helper-mve.h |
19 | +++ b/target/arm/cpu.h | 18 | +++ b/target/arm/helper-mve.h |
20 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fhm(const ARMISARegisters *id) | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) |
21 | return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, FHM) != 0; | 20 | |
21 | DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
22 | DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
23 | +DEF_HELPER_FLAGS_3(mve_uqrshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
24 | +DEF_HELPER_FLAGS_3(mve_sqrshr, TCG_CALL_NO_RWG, i32, env, i32, i32) | ||
25 | diff --git a/target/arm/translate.h b/target/arm/translate.h | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/target/arm/translate.h | ||
28 | +++ b/target/arm/translate.h | ||
29 | @@ -XXX,XX +XXX,XX @@ typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); | ||
30 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); | ||
31 | typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); | ||
32 | typedef void ShiftImmFn(TCGv_i32, TCGv_i32, int32_t shift); | ||
33 | +typedef void ShiftFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32); | ||
34 | |||
35 | /** | ||
36 | * arm_tbflags_from_tb: | ||
37 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/target/arm/t32.decode | ||
40 | +++ b/target/arm/t32.decode | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | &mve_shl_ri rdalo rdahi shim | ||
43 | &mve_shl_rr rdalo rdahi rm | ||
44 | &mve_sh_ri rda shim | ||
45 | +&mve_sh_rr rda rm | ||
46 | |||
47 | # rdahi: bits [3:1] from insn, bit 0 is 1 | ||
48 | # rdalo: bits [3:1] from insn, bit 0 is 0 | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | ||
51 | @mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \ | ||
52 | &mve_sh_ri shim=%imm5_12_6 | ||
53 | +@mve_sh_rr ....... .... . rda:4 rm:4 .... .... .... &mve_sh_rr | ||
54 | |||
55 | { | ||
56 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | ||
57 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi | ||
58 | SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | ||
59 | } | ||
60 | |||
61 | - LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | ||
62 | - ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | ||
63 | - UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr | ||
64 | - SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr | ||
65 | + { | ||
66 | + UQRSHL_rr 1110101 0010 1 .... .... 1111 0000 1101 @mve_sh_rr | ||
67 | + LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr | ||
68 | + UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr | ||
69 | + } | ||
70 | + | ||
71 | + { | ||
72 | + SQRSHR_rr 1110101 0010 1 .... .... 1111 0010 1101 @mve_sh_rr | ||
73 | + ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr | ||
74 | + SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr | ||
75 | + } | ||
76 | + | ||
77 | UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr | ||
78 | SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr | ||
79 | ] | ||
80 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
81 | index XXXXXXX..XXXXXXX 100644 | ||
82 | --- a/target/arm/mve_helper.c | ||
83 | +++ b/target/arm/mve_helper.c | ||
84 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
85 | { | ||
86 | return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); | ||
22 | } | 87 | } |
23 | 88 | + | |
24 | +static inline bool isar_feature_aa64_condm_4(const ARMISARegisters *id) | 89 | +uint32_t HELPER(mve_uqrshl)(CPUARMState *env, uint32_t n, uint32_t shift) |
25 | +{ | 90 | +{ |
26 | + return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TS) != 0; | 91 | + return do_uqrshl_bhs(n, (int8_t)shift, 32, true, &env->QF); |
27 | +} | 92 | +} |
28 | + | 93 | + |
29 | static inline bool isar_feature_aa64_jscvt(const ARMISARegisters *id) | 94 | +uint32_t HELPER(mve_sqrshr)(CPUARMState *env, uint32_t n, uint32_t shift) |
30 | { | 95 | +{ |
31 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, JSCVT) != 0; | 96 | + return do_sqrshl_bhs(n, -(int8_t)shift, 32, true, &env->QF); |
32 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | 97 | +} |
98 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | 99 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/linux-user/elfload.c | 100 | --- a/target/arm/translate.c |
35 | +++ b/linux-user/elfload.c | 101 | +++ b/target/arm/translate.c |
36 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void) | 102 | @@ -XXX,XX +XXX,XX @@ static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) |
37 | GET_FEATURE_ID(aa64_fhm, ARM_HWCAP_A64_ASIMDFHM); | 103 | return do_mve_sh_ri(s, a, gen_mve_uqshl); |
38 | GET_FEATURE_ID(aa64_jscvt, ARM_HWCAP_A64_JSCVT); | ||
39 | GET_FEATURE_ID(aa64_sb, ARM_HWCAP_A64_SB); | ||
40 | + GET_FEATURE_ID(aa64_condm_4, ARM_HWCAP_A64_FLAGM); | ||
41 | |||
42 | #undef GET_FEATURE_ID | ||
43 | |||
44 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/arm/cpu64.c | ||
47 | +++ b/target/arm/cpu64.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
49 | t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); | ||
50 | t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); | ||
51 | t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1); | ||
52 | + t = FIELD_DP64(t, ID_AA64ISAR0, TS, 1); | ||
53 | cpu->isar.id_aa64isar0 = t; | ||
54 | |||
55 | t = cpu->isar.id_aa64isar1; | ||
56 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/target/arm/translate-a64.c | ||
59 | +++ b/target/arm/translate-a64.c | ||
60 | @@ -XXX,XX +XXX,XX @@ static void handle_msr_i(DisasContext *s, uint32_t insn, | ||
61 | s->base.is_jmp = DISAS_TOO_MANY; | ||
62 | |||
63 | switch (op) { | ||
64 | + case 0x00: /* CFINV */ | ||
65 | + if (crm != 0 || !dc_isar_feature(aa64_condm_4, s)) { | ||
66 | + goto do_unallocated; | ||
67 | + } | ||
68 | + tcg_gen_xori_i32(cpu_CF, cpu_CF, 1); | ||
69 | + s->base.is_jmp = DISAS_NEXT; | ||
70 | + break; | ||
71 | + | ||
72 | case 0x05: /* SPSel */ | ||
73 | if (s->current_el == 0) { | ||
74 | goto do_unallocated; | ||
75 | @@ -XXX,XX +XXX,XX @@ static void gen_get_nzcv(TCGv_i64 tcg_rt) | ||
76 | } | 104 | } |
77 | 105 | ||
78 | static void gen_set_nzcv(TCGv_i64 tcg_rt) | 106 | +static bool do_mve_sh_rr(DisasContext *s, arg_mve_sh_rr *a, ShiftFn *fn) |
79 | - | ||
80 | { | ||
81 | TCGv_i32 nzcv = tcg_temp_new_i32(); | ||
82 | |||
83 | @@ -XXX,XX +XXX,XX @@ static void disas_adc_sbc(DisasContext *s, uint32_t insn) | ||
84 | } | ||
85 | } | ||
86 | |||
87 | +/* | ||
88 | + * Rotate right into flags | ||
89 | + * 31 30 29 21 15 10 5 4 0 | ||
90 | + * +--+--+--+-----------------+--------+-----------+------+--+------+ | ||
91 | + * |sf|op| S| 1 1 0 1 0 0 0 0 | imm6 | 0 0 0 0 1 | Rn |o2| mask | | ||
92 | + * +--+--+--+-----------------+--------+-----------+------+--+------+ | ||
93 | + */ | ||
94 | +static void disas_rotate_right_into_flags(DisasContext *s, uint32_t insn) | ||
95 | +{ | 107 | +{ |
96 | + int mask = extract32(insn, 0, 4); | 108 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
97 | + int o2 = extract32(insn, 4, 1); | 109 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ |
98 | + int rn = extract32(insn, 5, 5); | 110 | + return false; |
99 | + int imm6 = extract32(insn, 15, 6); | 111 | + } |
100 | + int sf_op_s = extract32(insn, 29, 3); | 112 | + if (!dc_isar_feature(aa32_mve, s) || |
101 | + TCGv_i64 tcg_rn; | 113 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || |
102 | + TCGv_i32 nzcv; | 114 | + a->rda == 13 || a->rda == 15 || a->rm == 13 || a->rm == 15 || |
103 | + | 115 | + a->rm == a->rda) { |
104 | + if (sf_op_s != 5 || o2 != 0 || !dc_isar_feature(aa64_condm_4, s)) { | 116 | + /* These rda/rm cases are UNPREDICTABLE; we choose to UNDEF */ |
105 | + unallocated_encoding(s); | 117 | + unallocated_encoding(s); |
106 | + return; | 118 | + return true; |
107 | + } | 119 | + } |
108 | + | 120 | + |
109 | + tcg_rn = read_cpu_reg(s, rn, 1); | 121 | + /* The helper takes care of the sign-extension of the low 8 bits of Rm */ |
110 | + tcg_gen_rotri_i64(tcg_rn, tcg_rn, imm6); | 122 | + fn(cpu_R[a->rda], cpu_env, cpu_R[a->rda], cpu_R[a->rm]); |
111 | + | 123 | + return true; |
112 | + nzcv = tcg_temp_new_i32(); | ||
113 | + tcg_gen_extrl_i64_i32(nzcv, tcg_rn); | ||
114 | + | ||
115 | + if (mask & 8) { /* N */ | ||
116 | + tcg_gen_shli_i32(cpu_NF, nzcv, 31 - 3); | ||
117 | + } | ||
118 | + if (mask & 4) { /* Z */ | ||
119 | + tcg_gen_not_i32(cpu_ZF, nzcv); | ||
120 | + tcg_gen_andi_i32(cpu_ZF, cpu_ZF, 4); | ||
121 | + } | ||
122 | + if (mask & 2) { /* C */ | ||
123 | + tcg_gen_extract_i32(cpu_CF, nzcv, 1, 1); | ||
124 | + } | ||
125 | + if (mask & 1) { /* V */ | ||
126 | + tcg_gen_shli_i32(cpu_VF, nzcv, 31 - 0); | ||
127 | + } | ||
128 | + | ||
129 | + tcg_temp_free_i32(nzcv); | ||
130 | +} | 124 | +} |
131 | + | 125 | + |
132 | +/* | 126 | +static bool trans_SQRSHR_rr(DisasContext *s, arg_mve_sh_rr *a) |
133 | + * Evaluate into flags | ||
134 | + * 31 30 29 21 15 14 10 5 4 0 | ||
135 | + * +--+--+--+-----------------+---------+----+---------+------+--+------+ | ||
136 | + * |sf|op| S| 1 1 0 1 0 0 0 0 | opcode2 | sz | 0 0 1 0 | Rn |o3| mask | | ||
137 | + * +--+--+--+-----------------+---------+----+---------+------+--+------+ | ||
138 | + */ | ||
139 | +static void disas_evaluate_into_flags(DisasContext *s, uint32_t insn) | ||
140 | +{ | 127 | +{ |
141 | + int o3_mask = extract32(insn, 0, 5); | 128 | + return do_mve_sh_rr(s, a, gen_helper_mve_sqrshr); |
142 | + int rn = extract32(insn, 5, 5); | ||
143 | + int o2 = extract32(insn, 15, 6); | ||
144 | + int sz = extract32(insn, 14, 1); | ||
145 | + int sf_op_s = extract32(insn, 29, 3); | ||
146 | + TCGv_i32 tmp; | ||
147 | + int shift; | ||
148 | + | ||
149 | + if (sf_op_s != 1 || o2 != 0 || o3_mask != 0xd || | ||
150 | + !dc_isar_feature(aa64_condm_4, s)) { | ||
151 | + unallocated_encoding(s); | ||
152 | + return; | ||
153 | + } | ||
154 | + shift = sz ? 16 : 24; /* SETF16 or SETF8 */ | ||
155 | + | ||
156 | + tmp = tcg_temp_new_i32(); | ||
157 | + tcg_gen_extrl_i64_i32(tmp, cpu_reg(s, rn)); | ||
158 | + tcg_gen_shli_i32(cpu_NF, tmp, shift); | ||
159 | + tcg_gen_shli_i32(cpu_VF, tmp, shift - 1); | ||
160 | + tcg_gen_mov_i32(cpu_ZF, cpu_NF); | ||
161 | + tcg_gen_xor_i32(cpu_VF, cpu_VF, cpu_NF); | ||
162 | + tcg_temp_free_i32(tmp); | ||
163 | +} | 129 | +} |
164 | + | 130 | + |
165 | /* Conditional compare (immediate / register) | 131 | +static bool trans_UQRSHL_rr(DisasContext *s, arg_mve_sh_rr *a) |
166 | * 31 30 29 28 27 26 25 24 23 22 21 20 16 15 12 11 10 9 5 4 3 0 | 132 | +{ |
167 | * +--+--+--+------------------------+--------+------+----+--+------+--+-----+ | 133 | + return do_mve_sh_rr(s, a, gen_helper_mve_uqrshl); |
168 | @@ -XXX,XX +XXX,XX @@ static void disas_data_proc_reg(DisasContext *s, uint32_t insn) | 134 | +} |
169 | disas_adc_sbc(s, insn); | ||
170 | break; | ||
171 | |||
172 | + case 0x01: /* Rotate right into flags */ | ||
173 | + case 0x21: | ||
174 | + disas_rotate_right_into_flags(s, insn); | ||
175 | + break; | ||
176 | + | 135 | + |
177 | + case 0x02: /* Evaluate into flags */ | 136 | /* |
178 | + case 0x12: | 137 | * Multiply and multiply accumulate |
179 | + case 0x22: | 138 | */ |
180 | + case 0x32: | ||
181 | + disas_evaluate_into_flags(s, insn); | ||
182 | + break; | ||
183 | + | ||
184 | default: | ||
185 | goto do_unallocated; | ||
186 | } | ||
187 | -- | 139 | -- |
188 | 2.20.1 | 140 | 2.20.1 |
189 | 141 | ||
190 | 142 | diff view generated by jsdifflib |