1 | The following changes since commit a97978bcc2d1f650c7d411428806e5b03082b8c7: | 1 | The following changes since commit 5a67d7735d4162630769ef495cf813244fc850df: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/dg-gitlab/tags/ppc-for-6.1-20210603' into staging (2021-06-03 10:00:35 +0100) | 3 | Merge remote-tracking branch 'remotes/berrange-gitlab/tags/tls-deps-pull-request' into staging (2021-07-02 08:22:39 +0100) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210603 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210702 |
8 | 8 | ||
9 | for you to fetch changes up to 1c861885894d840235954060050d240259f5340b: | 9 | for you to fetch changes up to 04ea4d3cfd0a21b248ece8eb7a9436a3d9898dd8: |
10 | 10 | ||
11 | tests/unit/test-vmstate: Assert that dup() and mkstemp() succeed (2021-06-03 16:43:27 +0100) | 11 | target/arm: Implement MVE shifts by register (2021-07-02 11:48:38 +0100) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | target-arm queue: | 14 | target-arm queue: |
15 | * Some not-yet-enabled preliminaries for M-profile MVE support | 15 | * more MVE instructions |
16 | * Consistently use "Cortex-Axx", not "Cortex Axx" in docs, comments | 16 | * hw/gpio/gpio_pwr: use shutdown function for reboot |
17 | * docs: Fix installation of man pages with Sphinx 4.x | 17 | * target/arm: Check NaN mode before silencing NaN |
18 | * Mark LDS{MIN,MAX} as signed operations | 18 | * tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine |
19 | * Fix missing syndrome value for DAIF and PAC check exceptions | 19 | * hw/arm: Add basic power management to raspi. |
20 | * Implement BFloat16 extensions | 20 | * docs/system/arm: Add quanta-gbs-bmc, quanta-q7l1-bmc |
21 | * Refactoring of hvf accelerator code in preparation for aarch64 support | ||
22 | * Fix some coverity nits in test code | ||
23 | 21 | ||
24 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
25 | Alexander Graf (12): | 23 | Joe Komlodi (1): |
26 | hvf: Move assert_hvf_ok() into common directory | 24 | target/arm: Check NaN mode before silencing NaN |
27 | hvf: Move vcpu thread functions into common directory | ||
28 | hvf: Move cpu functions into common directory | ||
29 | hvf: Move hvf internal definitions into common header | ||
30 | hvf: Make hvf_set_phys_mem() static | ||
31 | hvf: Remove use of hv_uvaddr_t and hv_gpaddr_t | ||
32 | hvf: Split out common code on vcpu init and destroy | ||
33 | hvf: Use cpu_synchronize_state() | ||
34 | hvf: Make synchronize functions static | ||
35 | hvf: Remove hvf-accel-ops.h | ||
36 | hvf: Introduce hvf vcpu struct | ||
37 | hvf: Simplify post reset/init/loadvm hooks | ||
38 | 25 | ||
39 | Damien Goutte-Gattat (1): | 26 | Maxim Uvarov (1): |
40 | docs: Fix installation of man pages with Sphinx 4.x | 27 | hw/gpio/gpio_pwr: use shutdown function for reboot |
41 | 28 | ||
42 | Jamie Iles (4): | 29 | Nolan Leake (1): |
43 | target/arm: fix missing exception class | 30 | hw/arm: Add basic power management to raspi. |
44 | target/arm: fold do_raise_exception into raise_exception | ||
45 | target/arm: use raise_exception_ra for MTE check failure | ||
46 | target/arm: use raise_exception_ra for stack limit exception | ||
47 | 31 | ||
48 | Peter Maydell (15): | 32 | Patrick Venture (2): |
49 | target/arm: Add isar feature check functions for MVE | 33 | docs/system/arm: Add quanta-q7l1-bmc reference |
50 | target/arm: Update feature checks for insns which are "MVE or FP" | 34 | docs/system/arm: Add quanta-gbs-bmc reference |
51 | target/arm: Move fpsp/fpdp isar check into callers of do_vfp_2op_sp/dp | ||
52 | target/arm: Add MVE check to VMOV_reg_sp and VMOV_reg_dp | ||
53 | target/arm: Fix return values in fp_sysreg_checks() | ||
54 | target/arm: Implement M-profile VPR register | ||
55 | target/arm: Make FPSCR.LTPSIZE writable for MVE | ||
56 | target/arm: Allow board models to specify initial NS VTOR | ||
57 | arm: Consistently use "Cortex-Axx", not "Cortex Axx" | ||
58 | tests/qtest/bios-tables-test: Check for dup2() failure | ||
59 | tests/qtest/e1000e-test: Check qemu_recv() succeeded | ||
60 | tests/qtest/hd-geo-test: Fix checks on mkstemp() return value | ||
61 | tests/qtest/pflash-cfi02-test: Avoid potential integer overflow | ||
62 | tests/qtest/tpm-tests: Remove unnecessary NULL checks | ||
63 | tests/unit/test-vmstate: Assert that dup() and mkstemp() succeed | ||
64 | 35 | ||
65 | Richard Henderson (13): | 36 | Peter Maydell (18): |
66 | target/arm: Mark LDS{MIN,MAX} as signed operations | 37 | target/arm: Fix MVE widening/narrowing VLDR/VSTR offset calculation |
67 | target/arm: Add isar_feature_{aa32, aa64, aa64_sve}_bf16 | 38 | target/arm: Fix bugs in MVE VRMLALDAVH, VRMLSLDAVH |
68 | target/arm: Unify unallocated path in disas_fp_1src | 39 | target/arm: Make asimd_imm_const() public |
69 | target/arm: Implement scalar float32 to bfloat16 conversion | 40 | target/arm: Use asimd_imm_const for A64 decode |
70 | target/arm: Implement vector float32 to bfloat16 conversion | 41 | target/arm: Use dup_const() instead of bitfield_replicate() |
71 | softfpu: Add float_round_to_odd_inf | 42 | target/arm: Implement MVE logical immediate insns |
72 | target/arm: Implement bfloat16 dot product (vector) | 43 | target/arm: Implement MVE vector shift left by immediate insns |
73 | target/arm: Implement bfloat16 dot product (indexed) | 44 | target/arm: Implement MVE vector shift right by immediate insns |
74 | target/arm: Implement bfloat16 matrix multiply accumulate | 45 | target/arm: Implement MVE VSHLL |
75 | target/arm: Implement bfloat widening fma (vector) | 46 | target/arm: Implement MVE VSRI, VSLI |
76 | target/arm: Implement bfloat widening fma (indexed) | 47 | target/arm: Implement MVE VSHRN, VRSHRN |
77 | linux-user/aarch64: Enable hwcap bits for bfloat16 | 48 | target/arm: Implement MVE saturating narrowing shifts |
78 | target/arm: Enable BFloat16 extensions | 49 | target/arm: Implement MVE VSHLC |
50 | target/arm: Implement MVE VADDLV | ||
51 | target/arm: Implement MVE long shifts by immediate | ||
52 | target/arm: Implement MVE long shifts by register | ||
53 | target/arm: Implement MVE shifts by immediate | ||
54 | target/arm: Implement MVE shifts by register | ||
79 | 55 | ||
80 | docs/conf.py | 1 + | 56 | Philippe Mathieu-Daudé (1): |
81 | docs/system/arm/aspeed.rst | 4 +- | 57 | tests: Boot and halt a Linux guest on the Raspberry Pi 2 machine |
82 | docs/system/arm/nuvoton.rst | 6 +- | ||
83 | docs/system/arm/sabrelite.rst | 2 +- | ||
84 | include/fpu/softfloat-types.h | 4 +- | ||
85 | include/hw/arm/allwinner-h3.h | 2 +- | ||
86 | include/hw/arm/armv7m.h | 2 + | ||
87 | include/hw/core/cpu.h | 3 +- | ||
88 | include/sysemu/hvf_int.h | 58 +++++ | ||
89 | target/arm/cpu.h | 48 +++- | ||
90 | target/arm/helper-sve.h | 4 + | ||
91 | target/arm/helper.h | 15 ++ | ||
92 | target/i386/hvf/hvf-accel-ops.h | 23 -- | ||
93 | target/i386/hvf/hvf-i386.h | 33 +-- | ||
94 | target/i386/hvf/vmx.h | 24 +- | ||
95 | target/i386/hvf/x86hvf.h | 2 - | ||
96 | target/arm/neon-dp.decode | 1 + | ||
97 | target/arm/neon-shared.decode | 11 + | ||
98 | target/arm/sve.decode | 19 +- | ||
99 | target/arm/vfp.decode | 2 + | ||
100 | accel/hvf/hvf-accel-ops.c | 471 ++++++++++++++++++++++++++++++++++++++++ | ||
101 | accel/hvf/hvf-all.c | 47 ++++ | ||
102 | hw/arm/armv7m.c | 7 + | ||
103 | hw/arm/aspeed.c | 6 +- | ||
104 | hw/arm/mcimx6ul-evk.c | 2 +- | ||
105 | hw/arm/mcimx7d-sabre.c | 2 +- | ||
106 | hw/arm/npcm7xx_boards.c | 4 +- | ||
107 | hw/arm/sabrelite.c | 2 +- | ||
108 | hw/misc/npcm7xx_clk.c | 2 +- | ||
109 | linux-user/elfload.c | 2 + | ||
110 | target/arm/cpu.c | 13 ++ | ||
111 | target/arm/cpu64.c | 3 + | ||
112 | target/arm/cpu_tcg.c | 1 + | ||
113 | target/arm/m_helper.c | 5 +- | ||
114 | target/arm/machine.c | 20 ++ | ||
115 | target/arm/mte_helper.c | 12 +- | ||
116 | target/arm/op_helper.c | 32 ++- | ||
117 | target/arm/sve_helper.c | 2 + | ||
118 | target/arm/translate-a64.c | 155 +++++++++++-- | ||
119 | target/arm/translate-neon.c | 91 ++++++++ | ||
120 | target/arm/translate-sve.c | 112 ++++++++++ | ||
121 | target/arm/translate-vfp.c | 164 ++++++++++---- | ||
122 | target/arm/vec_helper.c | 140 +++++++++++- | ||
123 | target/arm/vfp_helper.c | 21 +- | ||
124 | target/i386/hvf/hvf-accel-ops.c | 146 ------------- | ||
125 | target/i386/hvf/hvf.c | 464 +++++---------------------------------- | ||
126 | target/i386/hvf/x86.c | 28 +-- | ||
127 | target/i386/hvf/x86_descr.c | 26 +-- | ||
128 | target/i386/hvf/x86_emu.c | 62 +++--- | ||
129 | target/i386/hvf/x86_mmu.c | 4 +- | ||
130 | target/i386/hvf/x86_task.c | 12 +- | ||
131 | target/i386/hvf/x86hvf.c | 222 +++++++++---------- | ||
132 | tests/qtest/bios-tables-test.c | 8 +- | ||
133 | tests/qtest/e1000e-test.c | 3 +- | ||
134 | tests/qtest/hd-geo-test.c | 4 +- | ||
135 | tests/qtest/pflash-cfi02-test.c | 2 +- | ||
136 | tests/qtest/tpm-tests.c | 12 +- | ||
137 | tests/unit/test-vmstate.c | 5 +- | ||
138 | fpu/softfloat-parts.c.inc | 6 +- | ||
139 | MAINTAINERS | 8 + | ||
140 | accel/hvf/meson.build | 7 + | ||
141 | accel/meson.build | 1 + | ||
142 | target/i386/hvf/meson.build | 1 - | ||
143 | 63 files changed, 1666 insertions(+), 935 deletions(-) | ||
144 | create mode 100644 include/sysemu/hvf_int.h | ||
145 | delete mode 100644 target/i386/hvf/hvf-accel-ops.h | ||
146 | create mode 100644 accel/hvf/hvf-accel-ops.c | ||
147 | create mode 100644 accel/hvf/hvf-all.c | ||
148 | delete mode 100644 target/i386/hvf/hvf-accel-ops.c | ||
149 | create mode 100644 accel/hvf/meson.build | ||
150 | 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: Damien Goutte-Gattat <dgouttegattat@incenp.org> | 1 | From: Patrick Venture <venture@google.com> |
---|---|---|---|
2 | 2 | ||
3 | The 4.x branch of Sphinx introduces a breaking change, as generated man | 3 | Adds a line-item reference to the supported quanta-q71l-bmc aspeed |
4 | pages are now written to subdirectories corresponding to the manual | 4 | entry. |
5 | section they belong to. This results in `make install` erroring out when | ||
6 | attempting to install the man pages, because they are not where it | ||
7 | expects to find them. | ||
8 | 5 | ||
9 | This patch restores the behavior of Sphinx 3.x regarding man pages. | 6 | Signed-off-by: Patrick Venture <venture@google.com> |
10 | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | |
11 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/256 | 8 | Message-id: 20210615192848.1065297-2-venture@google.com |
12 | Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org> | ||
13 | Message-id: 20210503161422.15028-1-dgouttegattat@incenp.org | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | --- | 10 | --- |
17 | docs/conf.py | 1 + | 11 | docs/system/arm/aspeed.rst | 1 + |
18 | 1 file changed, 1 insertion(+) | 12 | 1 file changed, 1 insertion(+) |
19 | 13 | ||
20 | diff --git a/docs/conf.py b/docs/conf.py | 14 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst |
21 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/docs/conf.py | 16 | --- a/docs/system/arm/aspeed.rst |
23 | +++ b/docs/conf.py | 17 | +++ b/docs/system/arm/aspeed.rst |
24 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ etc. |
25 | ['Stefan Hajnoczi <stefanha@redhat.com>', | 19 | AST2400 SoC based machines : |
26 | 'Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>'], 1), | 20 | |
27 | ] | 21 | - ``palmetto-bmc`` OpenPOWER Palmetto POWER8 BMC |
28 | +man_make_section_directory = False | 22 | +- ``quanta-q71l-bmc`` OpenBMC Quanta BMC |
29 | 23 | ||
30 | # -- Options for Texinfo output ------------------------------------------- | 24 | AST2500 SoC based machines : |
31 | 25 | ||
32 | -- | 26 | -- |
33 | 2.20.1 | 27 | 2.20.1 |
34 | 28 | ||
35 | 29 | diff view generated by jsdifflib |
1 | The official punctuation for Arm CPU names uses a hyphen, like | 1 | From: Patrick Venture <venture@google.com> |
---|---|---|---|
2 | "Cortex-A9". We mostly follow this, but in a few places usage | ||
3 | without the hyphen has crept in. Fix those so we consistently | ||
4 | use the same way of writing the CPU name. | ||
5 | 2 | ||
6 | This commit was created with: | 3 | Add line item reference to quanta-gbs-bmc machine. |
7 | git grep -z -l 'Cortex ' | xargs -0 sed -i 's/Cortex /Cortex-/' | ||
8 | 4 | ||
5 | Signed-off-by: Patrick Venture <venture@google.com> | ||
6 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
7 | Message-id: 20210615192848.1065297-3-venture@google.com | ||
8 | [PMM: fixed underline Sphinx warning] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
13 | Message-id: 20210527095152.10968-1-peter.maydell@linaro.org | ||
14 | --- | 10 | --- |
15 | docs/system/arm/aspeed.rst | 4 ++-- | 11 | docs/system/arm/nuvoton.rst | 5 +++-- |
16 | docs/system/arm/nuvoton.rst | 6 +++--- | 12 | 1 file changed, 3 insertions(+), 2 deletions(-) |
17 | docs/system/arm/sabrelite.rst | 2 +- | ||
18 | include/hw/arm/allwinner-h3.h | 2 +- | ||
19 | hw/arm/aspeed.c | 6 +++--- | ||
20 | hw/arm/mcimx6ul-evk.c | 2 +- | ||
21 | hw/arm/mcimx7d-sabre.c | 2 +- | ||
22 | hw/arm/npcm7xx_boards.c | 4 ++-- | ||
23 | hw/arm/sabrelite.c | 2 +- | ||
24 | hw/misc/npcm7xx_clk.c | 2 +- | ||
25 | 10 files changed, 16 insertions(+), 16 deletions(-) | ||
26 | 13 | ||
27 | diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/docs/system/arm/aspeed.rst | ||
30 | +++ b/docs/system/arm/aspeed.rst | ||
31 | @@ -XXX,XX +XXX,XX @@ The QEMU Aspeed machines model BMCs of various OpenPOWER systems and | ||
32 | Aspeed evaluation boards. They are based on different releases of the | ||
33 | Aspeed SoC : the AST2400 integrating an ARM926EJ-S CPU (400MHz), the | ||
34 | AST2500 with an ARM1176JZS CPU (800MHz) and more recently the AST2600 | ||
35 | -with dual cores ARM Cortex A7 CPUs (1.2GHz). | ||
36 | +with dual cores ARM Cortex-A7 CPUs (1.2GHz). | ||
37 | |||
38 | The SoC comes with RAM, Gigabit ethernet, USB, SD/MMC, USB, SPI, I2C, | ||
39 | etc. | ||
40 | @@ -XXX,XX +XXX,XX @@ AST2500 SoC based machines : | ||
41 | |||
42 | AST2600 SoC based machines : | ||
43 | |||
44 | -- ``ast2600-evb`` Aspeed AST2600 Evaluation board (Cortex A7) | ||
45 | +- ``ast2600-evb`` Aspeed AST2600 Evaluation board (Cortex-A7) | ||
46 | - ``tacoma-bmc`` OpenPOWER Witherspoon POWER9 AST2600 BMC | ||
47 | |||
48 | Supported devices | ||
49 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst | 14 | diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst |
50 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/docs/system/arm/nuvoton.rst | 16 | --- a/docs/system/arm/nuvoton.rst |
52 | +++ b/docs/system/arm/nuvoton.rst | 17 | +++ b/docs/system/arm/nuvoton.rst |
53 | @@ -XXX,XX +XXX,XX @@ Nuvoton iBMC boards (``npcm750-evb``, ``quanta-gsj``) | 18 | @@ -XXX,XX +XXX,XX @@ |
19 | -Nuvoton iBMC boards (``npcm750-evb``, ``quanta-gsj``) | ||
20 | -===================================================== | ||
21 | +Nuvoton iBMC boards (``*-bmc``, ``npcm750-evb``, ``quanta-gsj``) | ||
22 | +================================================================ | ||
54 | 23 | ||
55 | The `Nuvoton iBMC`_ chips (NPCM7xx) are a family of ARM-based SoCs that are | 24 | The `Nuvoton iBMC`_ chips (NPCM7xx) are a family of ARM-based SoCs that are |
56 | designed to be used as Baseboard Management Controllers (BMCs) in various | 25 | designed to be used as Baseboard Management Controllers (BMCs) in various |
57 | -servers. They all feature one or two ARM Cortex A9 CPU cores, as well as an | 26 | @@ -XXX,XX +XXX,XX @@ segment. The following machines are based on this chip : |
58 | +servers. They all feature one or two ARM Cortex-A9 CPU cores, as well as an | 27 | The NPCM730 SoC has two Cortex-A9 cores and is targeted for Data Center and |
59 | assortment of peripherals targeted for either Enterprise or Data Center / | ||
60 | Hyperscale applications. The former is a superset of the latter, so NPCM750 has | ||
61 | all the peripherals of NPCM730 and more. | ||
62 | |||
63 | .. _Nuvoton iBMC: https://www.nuvoton.com/products/cloud-computing/ibmc/ | ||
64 | |||
65 | -The NPCM750 SoC has two Cortex A9 cores and is targeted for the Enterprise | ||
66 | +The NPCM750 SoC has two Cortex-A9 cores and is targeted for the Enterprise | ||
67 | segment. The following machines are based on this chip : | ||
68 | |||
69 | - ``npcm750-evb`` Nuvoton NPCM750 Evaluation board | ||
70 | |||
71 | -The NPCM730 SoC has two Cortex A9 cores and is targeted for Data Center and | ||
72 | +The NPCM730 SoC has two Cortex-A9 cores and is targeted for Data Center and | ||
73 | Hyperscale applications. The following machines are based on this chip : | 28 | Hyperscale applications. The following machines are based on this chip : |
74 | 29 | ||
30 | +- ``quanta-gbs-bmc`` Quanta GBS server BMC | ||
75 | - ``quanta-gsj`` Quanta GSJ server BMC | 31 | - ``quanta-gsj`` Quanta GSJ server BMC |
76 | diff --git a/docs/system/arm/sabrelite.rst b/docs/system/arm/sabrelite.rst | 32 | |
77 | index XXXXXXX..XXXXXXX 100644 | 33 | There are also two more SoCs, NPCM710 and NPCM705, which are single-core |
78 | --- a/docs/system/arm/sabrelite.rst | ||
79 | +++ b/docs/system/arm/sabrelite.rst | ||
80 | @@ -XXX,XX +XXX,XX @@ Supported devices | ||
81 | |||
82 | The SABRE Lite machine supports the following devices: | ||
83 | |||
84 | - * Up to 4 Cortex A9 cores | ||
85 | + * Up to 4 Cortex-A9 cores | ||
86 | * Generic Interrupt Controller | ||
87 | * 1 Clock Controller Module | ||
88 | * 1 System Reset Controller | ||
89 | diff --git a/include/hw/arm/allwinner-h3.h b/include/hw/arm/allwinner-h3.h | ||
90 | index XXXXXXX..XXXXXXX 100644 | ||
91 | --- a/include/hw/arm/allwinner-h3.h | ||
92 | +++ b/include/hw/arm/allwinner-h3.h | ||
93 | @@ -XXX,XX +XXX,XX @@ | ||
94 | */ | ||
95 | |||
96 | /* | ||
97 | - * The Allwinner H3 is a System on Chip containing four ARM Cortex A7 | ||
98 | + * The Allwinner H3 is a System on Chip containing four ARM Cortex-A7 | ||
99 | * processor cores. Features and specifications include DDR2/DDR3 memory, | ||
100 | * SD/MMC storage cards, 10/100/1000Mbit Ethernet, USB 2.0, HDMI and | ||
101 | * various I/O modules. | ||
102 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/hw/arm/aspeed.c | ||
105 | +++ b/hw/arm/aspeed.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data) | ||
107 | MachineClass *mc = MACHINE_CLASS(oc); | ||
108 | AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
109 | |||
110 | - mc->desc = "Aspeed AST2600 EVB (Cortex A7)"; | ||
111 | + mc->desc = "Aspeed AST2600 EVB (Cortex-A7)"; | ||
112 | amc->soc_name = "ast2600-a1"; | ||
113 | amc->hw_strap1 = AST2600_EVB_HW_STRAP1; | ||
114 | amc->hw_strap2 = AST2600_EVB_HW_STRAP2; | ||
115 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_tacoma_class_init(ObjectClass *oc, void *data) | ||
116 | MachineClass *mc = MACHINE_CLASS(oc); | ||
117 | AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
118 | |||
119 | - mc->desc = "OpenPOWER Tacoma BMC (Cortex A7)"; | ||
120 | + mc->desc = "OpenPOWER Tacoma BMC (Cortex-A7)"; | ||
121 | amc->soc_name = "ast2600-a1"; | ||
122 | amc->hw_strap1 = TACOMA_BMC_HW_STRAP1; | ||
123 | amc->hw_strap2 = TACOMA_BMC_HW_STRAP2; | ||
124 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_rainier_class_init(ObjectClass *oc, void *data) | ||
125 | MachineClass *mc = MACHINE_CLASS(oc); | ||
126 | AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
127 | |||
128 | - mc->desc = "IBM Rainier BMC (Cortex A7)"; | ||
129 | + mc->desc = "IBM Rainier BMC (Cortex-A7)"; | ||
130 | amc->soc_name = "ast2600-a1"; | ||
131 | amc->hw_strap1 = RAINIER_BMC_HW_STRAP1; | ||
132 | amc->hw_strap2 = RAINIER_BMC_HW_STRAP2; | ||
133 | diff --git a/hw/arm/mcimx6ul-evk.c b/hw/arm/mcimx6ul-evk.c | ||
134 | index XXXXXXX..XXXXXXX 100644 | ||
135 | --- a/hw/arm/mcimx6ul-evk.c | ||
136 | +++ b/hw/arm/mcimx6ul-evk.c | ||
137 | @@ -XXX,XX +XXX,XX @@ static void mcimx6ul_evk_init(MachineState *machine) | ||
138 | |||
139 | static void mcimx6ul_evk_machine_init(MachineClass *mc) | ||
140 | { | ||
141 | - mc->desc = "Freescale i.MX6UL Evaluation Kit (Cortex A7)"; | ||
142 | + mc->desc = "Freescale i.MX6UL Evaluation Kit (Cortex-A7)"; | ||
143 | mc->init = mcimx6ul_evk_init; | ||
144 | mc->max_cpus = FSL_IMX6UL_NUM_CPUS; | ||
145 | mc->default_ram_id = "mcimx6ul-evk.ram"; | ||
146 | diff --git a/hw/arm/mcimx7d-sabre.c b/hw/arm/mcimx7d-sabre.c | ||
147 | index XXXXXXX..XXXXXXX 100644 | ||
148 | --- a/hw/arm/mcimx7d-sabre.c | ||
149 | +++ b/hw/arm/mcimx7d-sabre.c | ||
150 | @@ -XXX,XX +XXX,XX @@ static void mcimx7d_sabre_init(MachineState *machine) | ||
151 | |||
152 | static void mcimx7d_sabre_machine_init(MachineClass *mc) | ||
153 | { | ||
154 | - mc->desc = "Freescale i.MX7 DUAL SABRE (Cortex A7)"; | ||
155 | + mc->desc = "Freescale i.MX7 DUAL SABRE (Cortex-A7)"; | ||
156 | mc->init = mcimx7d_sabre_init; | ||
157 | mc->max_cpus = FSL_IMX7_NUM_CPUS; | ||
158 | mc->default_ram_id = "mcimx7d-sabre.ram"; | ||
159 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c | ||
160 | index XXXXXXX..XXXXXXX 100644 | ||
161 | --- a/hw/arm/npcm7xx_boards.c | ||
162 | +++ b/hw/arm/npcm7xx_boards.c | ||
163 | @@ -XXX,XX +XXX,XX @@ static void npcm750_evb_machine_class_init(ObjectClass *oc, void *data) | ||
164 | |||
165 | npcm7xx_set_soc_type(nmc, TYPE_NPCM750); | ||
166 | |||
167 | - mc->desc = "Nuvoton NPCM750 Evaluation Board (Cortex A9)"; | ||
168 | + mc->desc = "Nuvoton NPCM750 Evaluation Board (Cortex-A9)"; | ||
169 | mc->init = npcm750_evb_init; | ||
170 | mc->default_ram_size = 512 * MiB; | ||
171 | }; | ||
172 | @@ -XXX,XX +XXX,XX @@ static void gsj_machine_class_init(ObjectClass *oc, void *data) | ||
173 | |||
174 | npcm7xx_set_soc_type(nmc, TYPE_NPCM730); | ||
175 | |||
176 | - mc->desc = "Quanta GSJ (Cortex A9)"; | ||
177 | + mc->desc = "Quanta GSJ (Cortex-A9)"; | ||
178 | mc->init = quanta_gsj_init; | ||
179 | mc->default_ram_size = 512 * MiB; | ||
180 | }; | ||
181 | diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c | ||
182 | index XXXXXXX..XXXXXXX 100644 | ||
183 | --- a/hw/arm/sabrelite.c | ||
184 | +++ b/hw/arm/sabrelite.c | ||
185 | @@ -XXX,XX +XXX,XX @@ static void sabrelite_init(MachineState *machine) | ||
186 | |||
187 | static void sabrelite_machine_init(MachineClass *mc) | ||
188 | { | ||
189 | - mc->desc = "Freescale i.MX6 Quad SABRE Lite Board (Cortex A9)"; | ||
190 | + mc->desc = "Freescale i.MX6 Quad SABRE Lite Board (Cortex-A9)"; | ||
191 | mc->init = sabrelite_init; | ||
192 | mc->max_cpus = FSL_IMX6_NUM_CPUS; | ||
193 | mc->ignore_memory_transaction_failures = true; | ||
194 | diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c | ||
195 | index XXXXXXX..XXXXXXX 100644 | ||
196 | --- a/hw/misc/npcm7xx_clk.c | ||
197 | +++ b/hw/misc/npcm7xx_clk.c | ||
198 | @@ -XXX,XX +XXX,XX @@ | ||
199 | #define NPCM7XX_CLOCK_REF_HZ (25000000) | ||
200 | |||
201 | /* Register Field Definitions */ | ||
202 | -#define NPCM7XX_CLK_WDRCR_CA9C BIT(0) /* Cortex A9 Cores */ | ||
203 | +#define NPCM7XX_CLK_WDRCR_CA9C BIT(0) /* Cortex-A9 Cores */ | ||
204 | |||
205 | #define PLLCON_LOKI BIT(31) | ||
206 | #define PLLCON_LOKS BIT(30) | ||
207 | -- | 34 | -- |
208 | 2.20.1 | 35 | 2.20.1 |
209 | 36 | ||
210 | 37 | diff view generated by jsdifflib |
1 | From: Alexander Graf <agraf@csgraf.de> | 1 | From: Nolan Leake <nolan@sigbus.net> |
---|---|---|---|
2 | 2 | ||
3 | Until now, Hypervisor.framework has only been available on x86_64 systems. | 3 | This is just enough to make reboot and poweroff work. Works for |
4 | With Apple Silicon shipping now, it extends its reach to aarch64. To | 4 | linux, u-boot, and the arm trusted firmware. Not tested, but should |
5 | prepare for support for multiple architectures, let's start moving common | 5 | work for plan9, and bare-metal/hobby OSes, since they seem to generally |
6 | code out into its own accel directory. | 6 | do what linux does for reset. |
7 | 7 | ||
8 | This patch moves assert_hvf_ok() and introduces generic build infrastructure. | 8 | The watchdog timer functionality is not yet implemented. |
9 | 9 | ||
10 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | 10 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/64 |
11 | Reviewed-by: Sergio Lopez <slp@redhat.com> | 11 | Signed-off-by: Nolan Leake <nolan@sigbus.net> |
12 | Message-id: 20210519202253.76782-2-agraf@csgraf.de | 12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.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/] | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 18 | --- |
16 | include/sysemu/hvf_int.h | 18 +++++++++++++++ | 19 | include/hw/arm/bcm2835_peripherals.h | 3 +- |
17 | accel/hvf/hvf-all.c | 47 ++++++++++++++++++++++++++++++++++++++++ | 20 | include/hw/misc/bcm2835_powermgt.h | 29 +++++ |
18 | target/i386/hvf/hvf.c | 33 +--------------------------- | 21 | hw/arm/bcm2835_peripherals.c | 13 ++- |
19 | MAINTAINERS | 8 +++++++ | 22 | hw/misc/bcm2835_powermgt.c | 160 +++++++++++++++++++++++++++ |
20 | accel/hvf/meson.build | 6 +++++ | 23 | hw/misc/meson.build | 1 + |
21 | accel/meson.build | 1 + | 24 | 5 files changed, 204 insertions(+), 2 deletions(-) |
22 | 6 files changed, 81 insertions(+), 32 deletions(-) | 25 | create mode 100644 include/hw/misc/bcm2835_powermgt.h |
23 | create mode 100644 include/sysemu/hvf_int.h | 26 | create mode 100644 hw/misc/bcm2835_powermgt.c |
24 | create mode 100644 accel/hvf/hvf-all.c | 27 | |
25 | create mode 100644 accel/hvf/meson.build | 28 | diff --git a/include/hw/arm/bcm2835_peripherals.h b/include/hw/arm/bcm2835_peripherals.h |
26 | 29 | index XXXXXXX..XXXXXXX 100644 | |
27 | diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h | 30 | --- a/include/hw/arm/bcm2835_peripherals.h |
31 | +++ b/include/hw/arm/bcm2835_peripherals.h | ||
32 | @@ -XXX,XX +XXX,XX @@ | ||
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 | ||
28 | new file mode 100644 | 50 | new file mode 100644 |
29 | index XXXXXXX..XXXXXXX | 51 | index XXXXXXX..XXXXXXX |
30 | --- /dev/null | 52 | --- /dev/null |
31 | +++ b/include/sysemu/hvf_int.h | 53 | +++ b/include/hw/misc/bcm2835_powermgt.h |
32 | @@ -XXX,XX +XXX,XX @@ | 54 | @@ -XXX,XX +XXX,XX @@ |
33 | +/* | 55 | +/* |
34 | + * QEMU Hypervisor.framework (HVF) support | 56 | + * BCM2835 Power Management emulation |
57 | + * | ||
58 | + * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com> | ||
59 | + * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net> | ||
35 | + * | 60 | + * |
36 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 61 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
37 | + * See the COPYING file in the top-level directory. | 62 | + * See the COPYING file in the top-level directory. |
38 | + * | ||
39 | + */ | 63 | + */ |
40 | + | 64 | + |
41 | +/* header to be included in HVF-specific code */ | 65 | +#ifndef BCM2835_POWERMGT_H |
42 | + | 66 | +#define BCM2835_POWERMGT_H |
43 | +#ifndef HVF_INT_H | 67 | + |
44 | +#define HVF_INT_H | 68 | +#include "hw/sysbus.h" |
45 | + | 69 | +#include "qom/object.h" |
46 | +#include <Hypervisor/hv.h> | 70 | + |
47 | + | 71 | +#define TYPE_BCM2835_POWERMGT "bcm2835-powermgt" |
48 | +void assert_hvf_ok(hv_return_t ret); | 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 | +}; | ||
49 | + | 82 | + |
50 | +#endif | 83 | +#endif |
51 | diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c | 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); | ||
96 | } | ||
97 | |||
98 | static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
99 | @@ -XXX,XX +XXX,XX @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp) | ||
100 | qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ, | ||
101 | INTERRUPT_USB)); | ||
102 | |||
103 | + /* Power Management */ | ||
104 | + if (!sysbus_realize(SYS_BUS_DEVICE(&s->powermgt), errp)) { | ||
105 | + return; | ||
106 | + } | ||
107 | + | ||
108 | + memory_region_add_subregion(&s->peri_mr, PM_OFFSET, | ||
109 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->powermgt), 0)); | ||
110 | + | ||
111 | create_unimp(s, &s->txp, "bcm2835-txp", TXP_OFFSET, 0x1000); | ||
112 | create_unimp(s, &s->armtmr, "bcm2835-sp804", ARMCTRL_TIMER0_1_OFFSET, 0x40); | ||
113 | - create_unimp(s, &s->powermgt, "bcm2835-powermgt", PM_OFFSET, 0x114); | ||
114 | create_unimp(s, &s->i2s, "bcm2835-i2s", I2S_OFFSET, 0x100); | ||
115 | create_unimp(s, &s->smi, "bcm2835-smi", SMI_OFFSET, 0x100); | ||
116 | create_unimp(s, &s->spi[0], "bcm2835-spi0", SPI0_OFFSET, 0x20); | ||
117 | diff --git a/hw/misc/bcm2835_powermgt.c b/hw/misc/bcm2835_powermgt.c | ||
52 | new file mode 100644 | 118 | new file mode 100644 |
53 | index XXXXXXX..XXXXXXX | 119 | index XXXXXXX..XXXXXXX |
54 | --- /dev/null | 120 | --- /dev/null |
55 | +++ b/accel/hvf/hvf-all.c | 121 | +++ b/hw/misc/bcm2835_powermgt.c |
56 | @@ -XXX,XX +XXX,XX @@ | 122 | @@ -XXX,XX +XXX,XX @@ |
57 | +/* | 123 | +/* |
58 | + * QEMU Hypervisor.framework support | 124 | + * BCM2835 Power Management emulation |
59 | + * | 125 | + * |
60 | + * This work is licensed under the terms of the GNU GPL, version 2. See | 126 | + * Copyright (C) 2017 Marcin Chojnacki <marcinch7@gmail.com> |
61 | + * the COPYING file in the top-level directory. | 127 | + * Copyright (C) 2021 Nolan Leake <nolan@sigbus.net> |
62 | + * | 128 | + * |
63 | + * Contributions after 2012-01-13 are licensed under the terms of the | 129 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
64 | + * GNU GPL, version 2 or (at your option) any later version. | 130 | + * See the COPYING file in the top-level directory. |
65 | + */ | 131 | + */ |
66 | + | 132 | + |
67 | +#include "qemu/osdep.h" | 133 | +#include "qemu/osdep.h" |
68 | +#include "qemu-common.h" | 134 | +#include "qemu/log.h" |
69 | +#include "qemu/error-report.h" | 135 | +#include "qemu/module.h" |
70 | +#include "sysemu/hvf.h" | 136 | +#include "hw/misc/bcm2835_powermgt.h" |
71 | +#include "sysemu/hvf_int.h" | 137 | +#include "migration/vmstate.h" |
72 | + | 138 | +#include "sysemu/runstate.h" |
73 | +void assert_hvf_ok(hv_return_t ret) | 139 | + |
74 | +{ | 140 | +#define PASSWORD 0x5a000000 |
75 | + if (ret == HV_SUCCESS) { | 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); | ||
76 | + return; | 187 | + return; |
77 | + } | 188 | + } |
78 | + | 189 | + |
79 | + switch (ret) { | 190 | + value = value & ~PASSWORD_MASK; |
80 | + case HV_ERROR: | 191 | + |
81 | + error_report("Error: HV_ERROR"); | 192 | + switch (offset) { |
82 | + break; | 193 | + case R_RSTC: |
83 | + case HV_BUSY: | 194 | + s->rstc = value; |
84 | + error_report("Error: HV_BUSY"); | 195 | + if (value & V_RSTC_RESET) { |
85 | + break; | 196 | + if ((s->rsts & 0xfff) == V_RSTS_POWEROFF) { |
86 | + case HV_BAD_ARGUMENT: | 197 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); |
87 | + error_report("Error: HV_BAD_ARGUMENT"); | 198 | + } else { |
88 | + break; | 199 | + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); |
89 | + case HV_NO_RESOURCES: | 200 | + } |
90 | + error_report("Error: HV_NO_RESOURCES"); | 201 | + } |
91 | + break; | 202 | + break; |
92 | + case HV_NO_DEVICE: | 203 | + case R_RSTS: |
93 | + error_report("Error: HV_NO_DEVICE"); | 204 | + qemu_log_mask(LOG_UNIMP, |
94 | + break; | 205 | + "bcm2835_powermgt_write: RSTS\n"); |
95 | + case HV_UNSUPPORTED: | 206 | + s->rsts = value; |
96 | + error_report("Error: HV_UNSUPPORTED"); | 207 | + break; |
97 | + break; | 208 | + case R_WDOG: |
209 | + qemu_log_mask(LOG_UNIMP, | ||
210 | + "bcm2835_powermgt_write: WDOG\n"); | ||
211 | + s->wdog = value; | ||
212 | + break; | ||
213 | + | ||
98 | + default: | 214 | + default: |
99 | + error_report("Unknown Error"); | 215 | + qemu_log_mask(LOG_UNIMP, |
100 | + } | 216 | + "bcm2835_powermgt_write: Unknown offset 0x%08"HWADDR_PRIx |
101 | + | 217 | + "\n", offset); |
102 | + abort(); | 218 | + break; |
103 | +} | 219 | + } |
104 | diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c | 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 | ||
105 | index XXXXXXX..XXXXXXX 100644 | 284 | index XXXXXXX..XXXXXXX 100644 |
106 | --- a/target/i386/hvf/hvf.c | 285 | --- a/hw/misc/meson.build |
107 | +++ b/target/i386/hvf/hvf.c | 286 | +++ b/hw/misc/meson.build |
108 | @@ -XXX,XX +XXX,XX @@ | 287 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files( |
109 | #include "qemu/error-report.h" | 288 | 'bcm2835_rng.c', |
110 | 289 | 'bcm2835_thermal.c', | |
111 | #include "sysemu/hvf.h" | 290 | 'bcm2835_cprman.c', |
112 | +#include "sysemu/hvf_int.h" | 291 | + 'bcm2835_powermgt.c', |
113 | #include "sysemu/runstate.h" | 292 | )) |
114 | #include "hvf-i386.h" | 293 | softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) |
115 | #include "vmcs.h" | 294 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c', 'zynq-xadc.c')) |
116 | @@ -XXX,XX +XXX,XX @@ | ||
117 | |||
118 | HVFState *hvf_state; | ||
119 | |||
120 | -static void assert_hvf_ok(hv_return_t ret) | ||
121 | -{ | ||
122 | - if (ret == HV_SUCCESS) { | ||
123 | - return; | ||
124 | - } | ||
125 | - | ||
126 | - switch (ret) { | ||
127 | - case HV_ERROR: | ||
128 | - error_report("Error: HV_ERROR"); | ||
129 | - break; | ||
130 | - case HV_BUSY: | ||
131 | - error_report("Error: HV_BUSY"); | ||
132 | - break; | ||
133 | - case HV_BAD_ARGUMENT: | ||
134 | - error_report("Error: HV_BAD_ARGUMENT"); | ||
135 | - break; | ||
136 | - case HV_NO_RESOURCES: | ||
137 | - error_report("Error: HV_NO_RESOURCES"); | ||
138 | - break; | ||
139 | - case HV_NO_DEVICE: | ||
140 | - error_report("Error: HV_NO_DEVICE"); | ||
141 | - break; | ||
142 | - case HV_UNSUPPORTED: | ||
143 | - error_report("Error: HV_UNSUPPORTED"); | ||
144 | - break; | ||
145 | - default: | ||
146 | - error_report("Unknown Error"); | ||
147 | - } | ||
148 | - | ||
149 | - abort(); | ||
150 | -} | ||
151 | - | ||
152 | /* Memory slots */ | ||
153 | hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t size) | ||
154 | { | ||
155 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
156 | index XXXXXXX..XXXXXXX 100644 | ||
157 | --- a/MAINTAINERS | ||
158 | +++ b/MAINTAINERS | ||
159 | @@ -XXX,XX +XXX,XX @@ M: Roman Bolshakov <r.bolshakov@yadro.com> | ||
160 | W: https://wiki.qemu.org/Features/HVF | ||
161 | S: Maintained | ||
162 | F: target/i386/hvf/ | ||
163 | + | ||
164 | +HVF | ||
165 | +M: Cameron Esfahani <dirty@apple.com> | ||
166 | +M: Roman Bolshakov <r.bolshakov@yadro.com> | ||
167 | +W: https://wiki.qemu.org/Features/HVF | ||
168 | +S: Maintained | ||
169 | +F: accel/hvf/ | ||
170 | F: include/sysemu/hvf.h | ||
171 | +F: include/sysemu/hvf_int.h | ||
172 | |||
173 | WHPX CPUs | ||
174 | M: Sunil Muthuswamy <sunilmut@microsoft.com> | ||
175 | diff --git a/accel/hvf/meson.build b/accel/hvf/meson.build | ||
176 | new file mode 100644 | ||
177 | index XXXXXXX..XXXXXXX | ||
178 | --- /dev/null | ||
179 | +++ b/accel/hvf/meson.build | ||
180 | @@ -XXX,XX +XXX,XX @@ | ||
181 | +hvf_ss = ss.source_set() | ||
182 | +hvf_ss.add(files( | ||
183 | + 'hvf-all.c', | ||
184 | +)) | ||
185 | + | ||
186 | +specific_ss.add_all(when: 'CONFIG_HVF', if_true: hvf_ss) | ||
187 | diff --git a/accel/meson.build b/accel/meson.build | ||
188 | index XXXXXXX..XXXXXXX 100644 | ||
189 | --- a/accel/meson.build | ||
190 | +++ b/accel/meson.build | ||
191 | @@ -XXX,XX +XXX,XX @@ specific_ss.add(files('accel-common.c')) | ||
192 | softmmu_ss.add(files('accel-softmmu.c')) | ||
193 | user_ss.add(files('accel-user.c')) | ||
194 | |||
195 | +subdir('hvf') | ||
196 | subdir('qtest') | ||
197 | subdir('kvm') | ||
198 | subdir('tcg') | ||
199 | -- | 295 | -- |
200 | 2.20.1 | 296 | 2.20.1 |
201 | 297 | ||
202 | 298 | diff view generated by jsdifflib |
1 | From: Alexander Graf <agraf@csgraf.de> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | The hooks we have that call us after reset, init and loadvm really all | 3 | Add a test booting and quickly shutdown a raspi2 machine, |
4 | just want to say "The reference of all register state is in the QEMU | 4 | to test the power management model: |
5 | vcpu struct, please push it". | ||
6 | 5 | ||
7 | We already have a working pushing mechanism though called cpu->vcpu_dirty, | 6 | (1/1) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd: |
8 | so we can just reuse that for all of the above, syncing state properly the | 7 | console: [ 0.000000] Booting Linux on physical CPU 0xf00 |
9 | next time we actually execute a vCPU. | 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 |
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 | ||
10 | 44 | ||
11 | This fixes PSCI resets on ARM, as they modify CPU state even after the | 45 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
12 | post init call has completed, but before we execute the vCPU again. | 46 | Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> |
13 | 47 | Message-id: 20210531113837.1689775-1-f4bug@amsat.org | |
14 | To also make the scheme work for x86, we have to make sure we don't | ||
15 | move stale eflags into our env when the vcpu state is dirty. | ||
16 | |||
17 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
18 | Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com> | ||
19 | Tested-by: Roman Bolshakov <r.bolshakov@yadro.com> | ||
20 | Reviewed-by: Sergio Lopez <slp@redhat.com> | ||
21 | Message-id: 20210519202253.76782-13-agraf@csgraf.de | ||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 48 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | --- | 49 | --- |
24 | accel/hvf/hvf-accel-ops.c | 27 +++++++-------------------- | 50 | tests/acceptance/boot_linux_console.py | 43 ++++++++++++++++++++++++++ |
25 | target/i386/hvf/x86hvf.c | 5 ++++- | 51 | 1 file changed, 43 insertions(+) |
26 | 2 files changed, 11 insertions(+), 21 deletions(-) | ||
27 | 52 | ||
28 | diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c | 53 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py |
29 | index XXXXXXX..XXXXXXX 100644 | 54 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/accel/hvf/hvf-accel-ops.c | 55 | --- a/tests/acceptance/boot_linux_console.py |
31 | +++ b/accel/hvf/hvf-accel-ops.c | 56 | +++ b/tests/acceptance/boot_linux_console.py |
32 | @@ -XXX,XX +XXX,XX @@ static void hvf_cpu_synchronize_state(CPUState *cpu) | 57 | @@ -XXX,XX +XXX,XX @@ |
33 | } | 58 | from avocado import skip |
34 | } | 59 | from avocado import skipUnless |
35 | 60 | from avocado_qemu import Test | |
36 | -static void do_hvf_cpu_synchronize_post_reset(CPUState *cpu, | 61 | +from avocado_qemu import exec_command |
37 | - run_on_cpu_data arg) | 62 | from avocado_qemu import exec_command_and_wait_for_pattern |
38 | +static void do_hvf_cpu_synchronize_set_dirty(CPUState *cpu, | 63 | from avocado_qemu import interrupt_interactive_console_until_pattern |
39 | + run_on_cpu_data arg) | 64 | from avocado_qemu import wait_for_console_pattern |
40 | { | 65 | @@ -XXX,XX +XXX,XX @@ def test_arm_raspi2_uart0(self): |
41 | - hvf_put_registers(cpu); | 66 | """ |
42 | - cpu->vcpu_dirty = false; | 67 | self.do_test_arm_raspi2(0) |
43 | + /* QEMU state is the reference, push it to HVF now and on next entry */ | 68 | |
44 | + cpu->vcpu_dirty = true; | 69 | + def test_arm_raspi2_initrd(self): |
45 | } | 70 | + """ |
46 | 71 | + :avocado: tags=arch:arm | |
47 | static void hvf_cpu_synchronize_post_reset(CPUState *cpu) | 72 | + :avocado: tags=machine:raspi2 |
48 | { | 73 | + """ |
49 | - run_on_cpu(cpu, do_hvf_cpu_synchronize_post_reset, RUN_ON_CPU_NULL); | 74 | + deb_url = ('http://archive.raspberrypi.org/debian/' |
50 | -} | 75 | + 'pool/main/r/raspberrypi-firmware/' |
51 | - | 76 | + 'raspberrypi-kernel_1.20190215-1_armhf.deb') |
52 | -static void do_hvf_cpu_synchronize_post_init(CPUState *cpu, | 77 | + deb_hash = 'cd284220b32128c5084037553db3c482426f3972' |
53 | - run_on_cpu_data arg) | 78 | + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) |
54 | -{ | 79 | + kernel_path = self.extract_from_deb(deb_path, '/boot/kernel7.img') |
55 | - hvf_put_registers(cpu); | 80 | + dtb_path = self.extract_from_deb(deb_path, '/boot/bcm2709-rpi-2-b.dtb') |
56 | - cpu->vcpu_dirty = false; | 81 | + |
57 | + run_on_cpu(cpu, do_hvf_cpu_synchronize_set_dirty, RUN_ON_CPU_NULL); | 82 | + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' |
58 | } | 83 | + '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' |
59 | 84 | + 'arm/rootfs-armv7a.cpio.gz') | |
60 | static void hvf_cpu_synchronize_post_init(CPUState *cpu) | 85 | + initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c' |
61 | { | 86 | + initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) |
62 | - run_on_cpu(cpu, do_hvf_cpu_synchronize_post_init, RUN_ON_CPU_NULL); | 87 | + initrd_path = os.path.join(self.workdir, 'rootfs.cpio') |
63 | -} | 88 | + archive.gzip_uncompress(initrd_path_gz, initrd_path) |
64 | - | 89 | + |
65 | -static void do_hvf_cpu_synchronize_pre_loadvm(CPUState *cpu, | 90 | + self.vm.set_console() |
66 | - run_on_cpu_data arg) | 91 | + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + |
67 | -{ | 92 | + 'earlycon=pl011,0x3f201000 console=ttyAMA0 ' |
68 | - cpu->vcpu_dirty = true; | 93 | + 'panic=-1 noreboot ' + |
69 | + run_on_cpu(cpu, do_hvf_cpu_synchronize_set_dirty, RUN_ON_CPU_NULL); | 94 | + 'dwc_otg.fiq_fsm_enable=0') |
70 | } | 95 | + self.vm.add_args('-kernel', kernel_path, |
71 | 96 | + '-dtb', dtb_path, | |
72 | static void hvf_cpu_synchronize_pre_loadvm(CPUState *cpu) | 97 | + '-initrd', initrd_path, |
73 | { | 98 | + '-append', kernel_command_line, |
74 | - run_on_cpu(cpu, do_hvf_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL); | 99 | + '-no-reboot') |
75 | + run_on_cpu(cpu, do_hvf_cpu_synchronize_set_dirty, RUN_ON_CPU_NULL); | 100 | + self.vm.launch() |
76 | } | 101 | + self.wait_for_console_pattern('Boot successful.') |
77 | 102 | + | |
78 | static void hvf_set_dirty_tracking(MemoryRegionSection *section, bool on) | 103 | + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', |
79 | diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c | 104 | + 'BCM2835') |
80 | index XXXXXXX..XXXXXXX 100644 | 105 | + exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', |
81 | --- a/target/i386/hvf/x86hvf.c | 106 | + '/soc/cprman@7e101000') |
82 | +++ b/target/i386/hvf/x86hvf.c | 107 | + exec_command(self, 'halt') |
83 | @@ -XXX,XX +XXX,XX @@ int hvf_process_events(CPUState *cpu_state) | 108 | + # Wait for VM to shut down gracefully |
84 | X86CPU *cpu = X86_CPU(cpu_state); | 109 | + self.vm.wait() |
85 | CPUX86State *env = &cpu->env; | 110 | + |
86 | 111 | def test_arm_exynos4210_initrd(self): | |
87 | - env->eflags = rreg(cpu_state->hvf->fd, HV_X86_RFLAGS); | 112 | """ |
88 | + if (!cpu_state->vcpu_dirty) { | 113 | :avocado: tags=arch:arm |
89 | + /* light weight sync for CPU_INTERRUPT_HARD and IF_MASK */ | ||
90 | + env->eflags = rreg(cpu_state->hvf->fd, HV_X86_RFLAGS); | ||
91 | + } | ||
92 | |||
93 | if (cpu_state->interrupt_request & CPU_INTERRUPT_INIT) { | ||
94 | cpu_synchronize_state(cpu_state); | ||
95 | -- | 114 | -- |
96 | 2.20.1 | 115 | 2.20.1 |
97 | 116 | ||
98 | 117 | diff view generated by jsdifflib |
1 | The M-profile FPSCR has an LTPSIZE field, but if MVE is not | 1 | From: Joe Komlodi <joe.komlodi@xilinx.com> |
---|---|---|---|
2 | implemented it is read-only and always reads as 4; this is how QEMU | ||
3 | currently handles it. | ||
4 | 2 | ||
5 | Make the field writable when MVE is implemented. | 3 | If the CPU is running in default NaN mode (FPCR.DN == 1) and we execute |
4 | FRSQRTE, FRECPE, or FRECPX with a signaling NaN, parts_silence_nan_frac() will | ||
5 | assert due to fpst->default_nan_mode being set. | ||
6 | 6 | ||
7 | We can safely add the field to the MVE migration struct because | 7 | To avoid this, we check to see what NaN mode we're running in before we call |
8 | currently no CPUs enable MVE and so the migration struct is never | 8 | floatxx_silence_nan(). |
9 | used. | ||
10 | 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 | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20210520152840.24453-8-peter.maydell@linaro.org | ||
14 | --- | 15 | --- |
15 | target/arm/cpu.h | 3 ++- | 16 | target/arm/helper-a64.c | 12 +++++++++--- |
16 | target/arm/machine.c | 1 + | 17 | target/arm/vfp_helper.c | 24 ++++++++++++++++++------ |
17 | target/arm/vfp_helper.c | 9 ++++++--- | 18 | 2 files changed, 27 insertions(+), 9 deletions(-) |
18 | 3 files changed, 9 insertions(+), 4 deletions(-) | ||
19 | 19 | ||
20 | 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 |
21 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/cpu.h | 22 | --- a/target/arm/helper-a64.c |
23 | +++ b/target/arm/cpu.h | 23 | +++ b/target/arm/helper-a64.c |
24 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 24 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(frecpx_f16)(uint32_t a, void *fpstp) |
25 | uint32_t fpdscr[M_REG_NUM_BANKS]; | 25 | float16 nan = a; |
26 | uint32_t cpacr[M_REG_NUM_BANKS]; | 26 | if (float16_is_signaling_nan(a, fpst)) { |
27 | uint32_t nsacr; | 27 | float_raise(float_flag_invalid, fpst); |
28 | - int ltpsize; | 28 | - nan = float16_silence_nan(a, fpst); |
29 | + uint32_t ltpsize; | 29 | + if (!fpst->default_nan_mode) { |
30 | uint32_t vpr; | 30 | + nan = float16_silence_nan(a, fpst); |
31 | } v7m; | 31 | + } |
32 | 32 | } | |
33 | @@ -XXX,XX +XXX,XX @@ void vfp_set_fpscr(CPUARMState *env, uint32_t val); | 33 | if (fpst->default_nan_mode) { |
34 | 34 | nan = float16_default_nan(fpst); | |
35 | #define FPCR_LTPSIZE_SHIFT 16 /* LTPSIZE, M-profile only */ | 35 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(frecpx_f32)(float32 a, void *fpstp) |
36 | #define FPCR_LTPSIZE_MASK (7 << FPCR_LTPSIZE_SHIFT) | 36 | float32 nan = a; |
37 | +#define FPCR_LTPSIZE_LENGTH 3 | 37 | if (float32_is_signaling_nan(a, fpst)) { |
38 | 38 | float_raise(float_flag_invalid, fpst); | |
39 | #define FPCR_NZCV_MASK (FPCR_N | FPCR_Z | FPCR_C | FPCR_V) | 39 | - nan = float32_silence_nan(a, fpst); |
40 | #define FPCR_NZCVQC_MASK (FPCR_NZCV_MASK | FPCR_QC) | 40 | + if (!fpst->default_nan_mode) { |
41 | diff --git a/target/arm/machine.c b/target/arm/machine.c | 41 | + nan = float32_silence_nan(a, fpst); |
42 | index XXXXXXX..XXXXXXX 100644 | 42 | + } |
43 | --- a/target/arm/machine.c | 43 | } |
44 | +++ b/target/arm/machine.c | 44 | if (fpst->default_nan_mode) { |
45 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_mve = { | 45 | nan = float32_default_nan(fpst); |
46 | .needed = mve_needed, | 46 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(frecpx_f64)(float64 a, void *fpstp) |
47 | .fields = (VMStateField[]) { | 47 | float64 nan = a; |
48 | VMSTATE_UINT32(env.v7m.vpr, ARMCPU), | 48 | if (float64_is_signaling_nan(a, fpst)) { |
49 | + VMSTATE_UINT32(env.v7m.ltpsize, ARMCPU), | 49 | float_raise(float_flag_invalid, fpst); |
50 | VMSTATE_END_OF_LIST() | 50 | - nan = float64_silence_nan(a, fpst); |
51 | }, | 51 | + if (!fpst->default_nan_mode) { |
52 | }; | 52 | + nan = float64_silence_nan(a, fpst); |
53 | + } | ||
54 | } | ||
55 | if (fpst->default_nan_mode) { | ||
56 | nan = float64_default_nan(fpst); | ||
53 | 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 |
54 | index XXXXXXX..XXXXXXX 100644 | 58 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/target/arm/vfp_helper.c | 59 | --- a/target/arm/vfp_helper.c |
56 | +++ b/target/arm/vfp_helper.c | 60 | +++ b/target/arm/vfp_helper.c |
57 | @@ -XXX,XX +XXX,XX @@ uint32_t vfp_get_fpscr(CPUARMState *env) | 61 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(recpe_f16)(uint32_t input, void *fpstp) |
58 | 62 | float16 nan = f16; | |
59 | void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | 63 | if (float16_is_signaling_nan(f16, fpst)) { |
60 | { | 64 | float_raise(float_flag_invalid, fpst); |
61 | + ARMCPU *cpu = env_archcpu(env); | 65 | - nan = float16_silence_nan(f16, fpst); |
62 | + | 66 | + if (!fpst->default_nan_mode) { |
63 | /* When ARMv8.2-FP16 is not supported, FZ16 is RES0. */ | 67 | + nan = float16_silence_nan(f16, fpst); |
64 | - if (!cpu_isar_feature(any_fp16, env_archcpu(env))) { | 68 | + } |
65 | + if (!cpu_isar_feature(any_fp16, cpu)) { | 69 | } |
66 | val &= ~FPCR_FZ16; | 70 | if (fpst->default_nan_mode) { |
67 | } | 71 | nan = float16_default_nan(fpst); |
68 | 72 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(recpe_f32)(float32 input, void *fpstp) | |
69 | @@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val) | 73 | float32 nan = f32; |
70 | * because in v7A no-short-vector-support cores still had to | 74 | if (float32_is_signaling_nan(f32, fpst)) { |
71 | * allow Stride/Len to be written with the only effect that | 75 | float_raise(float_flag_invalid, fpst); |
72 | * some insns are required to UNDEF if the guest sets them. | 76 | - nan = float32_silence_nan(f32, fpst); |
73 | - * | 77 | + if (!fpst->default_nan_mode) { |
74 | - * TODO: if M-profile MVE implemented, set LTPSIZE. | 78 | + nan = float32_silence_nan(f32, fpst); |
75 | */ | 79 | + } |
76 | env->vfp.vec_len = extract32(val, 16, 3); | 80 | } |
77 | env->vfp.vec_stride = extract32(val, 20, 2); | 81 | if (fpst->default_nan_mode) { |
78 | + } else if (cpu_isar_feature(aa32_mve, cpu)) { | 82 | nan = float32_default_nan(fpst); |
79 | + env->v7m.ltpsize = extract32(val, FPCR_LTPSIZE_SHIFT, | 83 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(recpe_f64)(float64 input, void *fpstp) |
80 | + FPCR_LTPSIZE_LENGTH); | 84 | float64 nan = f64; |
81 | } | 85 | if (float64_is_signaling_nan(f64, fpst)) { |
82 | 86 | float_raise(float_flag_invalid, fpst); | |
83 | if (arm_feature(env, ARM_FEATURE_NEON)) { | 87 | - nan = float64_silence_nan(f64, fpst); |
88 | + if (!fpst->default_nan_mode) { | ||
89 | + nan = float64_silence_nan(f64, fpst); | ||
90 | + } | ||
91 | } | ||
92 | if (fpst->default_nan_mode) { | ||
93 | nan = float64_default_nan(fpst); | ||
94 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(rsqrte_f16)(uint32_t input, void *fpstp) | ||
95 | float16 nan = f16; | ||
96 | if (float16_is_signaling_nan(f16, s)) { | ||
97 | float_raise(float_flag_invalid, s); | ||
98 | - nan = float16_silence_nan(f16, s); | ||
99 | + if (!s->default_nan_mode) { | ||
100 | + nan = float16_silence_nan(f16, fpstp); | ||
101 | + } | ||
102 | } | ||
103 | if (s->default_nan_mode) { | ||
104 | nan = float16_default_nan(s); | ||
105 | @@ -XXX,XX +XXX,XX @@ float32 HELPER(rsqrte_f32)(float32 input, void *fpstp) | ||
106 | float32 nan = f32; | ||
107 | if (float32_is_signaling_nan(f32, s)) { | ||
108 | float_raise(float_flag_invalid, s); | ||
109 | - nan = float32_silence_nan(f32, s); | ||
110 | + if (!s->default_nan_mode) { | ||
111 | + nan = float32_silence_nan(f32, fpstp); | ||
112 | + } | ||
113 | } | ||
114 | if (s->default_nan_mode) { | ||
115 | nan = float32_default_nan(s); | ||
116 | @@ -XXX,XX +XXX,XX @@ float64 HELPER(rsqrte_f64)(float64 input, void *fpstp) | ||
117 | float64 nan = f64; | ||
118 | if (float64_is_signaling_nan(f64, s)) { | ||
119 | float_raise(float_flag_invalid, s); | ||
120 | - nan = float64_silence_nan(f64, s); | ||
121 | + if (!s->default_nan_mode) { | ||
122 | + nan = float64_silence_nan(f64, fpstp); | ||
123 | + } | ||
124 | } | ||
125 | if (s->default_nan_mode) { | ||
126 | nan = float64_default_nan(s); | ||
84 | -- | 127 | -- |
85 | 2.20.1 | 128 | 2.20.1 |
86 | 129 | ||
87 | 130 | diff view generated by jsdifflib |
1 | From: Jamie Iles <jamie@nuviainc.com> | 1 | From: Maxim Uvarov <maxim.uvarov@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The sequence cpu_restore_state() + raise_exception() is equivalent to | 3 | qemu has 2 type of functions: shutdown and reboot. Shutdown |
4 | raise_exception_ra(), so use that instead. (In this case we never | 4 | function has to be used for machine shutdown. Otherwise we cause |
5 | cared about the syndrome value, because M-profile doesn't use the | 5 | a reset with a bogus "cause" value, when we intended a shutdown. |
6 | syndrome; the old code was just written unnecessarily awkwardly.) | ||
7 | 6 | ||
8 | Cc: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> |
9 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Jamie Iles <jamie@nuviainc.com> | ||
11 | [PMM: Retain edited version of comment; rewrite commit message] | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20210625111842.3790-3-maxim.uvarov@linaro.org | ||
10 | [PMM: tweaked commit message] | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 12 | --- |
15 | target/arm/m_helper.c | 5 +---- | 13 | hw/gpio/gpio_pwr.c | 2 +- |
16 | target/arm/op_helper.c | 9 +++------ | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
17 | 2 files changed, 4 insertions(+), 10 deletions(-) | ||
18 | 15 | ||
19 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 16 | diff --git a/hw/gpio/gpio_pwr.c b/hw/gpio/gpio_pwr.c |
20 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/m_helper.c | 18 | --- a/hw/gpio/gpio_pwr.c |
22 | +++ b/target/arm/m_helper.c | 19 | +++ b/hw/gpio/gpio_pwr.c |
23 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | 20 | @@ -XXX,XX +XXX,XX @@ static void gpio_pwr_reset(void *opaque, int n, int level) |
24 | limit = is_psp ? env->v7m.psplim[false] : env->v7m.msplim[false]; | 21 | static void gpio_pwr_shutdown(void *opaque, int n, int level) |
25 | 22 | { | |
26 | if (val < limit) { | 23 | if (level) { |
27 | - CPUState *cs = env_cpu(env); | 24 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); |
28 | - | 25 | + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); |
29 | - cpu_restore_state(cs, GETPC(), true); | ||
30 | - raise_exception(env, EXCP_STKOF, 0, 1); | ||
31 | + raise_exception_ra(env, EXCP_STKOF, 0, 1, GETPC()); | ||
32 | } | ||
33 | |||
34 | if (is_psp) { | ||
35 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/op_helper.c | ||
38 | +++ b/target/arm/op_helper.c | ||
39 | @@ -XXX,XX +XXX,XX @@ void HELPER(v8m_stackcheck)(CPUARMState *env, uint32_t newvalue) | ||
40 | * raising an exception if the limit is breached. | ||
41 | */ | ||
42 | if (newvalue < v7m_sp_limit(env)) { | ||
43 | - CPUState *cs = env_cpu(env); | ||
44 | - | ||
45 | /* | ||
46 | * Stack limit exceptions are a rare case, so rather than syncing | ||
47 | - * PC/condbits before the call, we use cpu_restore_state() to | ||
48 | - * get them right before raising the exception. | ||
49 | + * PC/condbits before the call, we use raise_exception_ra() so | ||
50 | + * that cpu_restore_state() will sort them out. | ||
51 | */ | ||
52 | - cpu_restore_state(cs, GETPC(), true); | ||
53 | - raise_exception(env, EXCP_STKOF, 0, 1); | ||
54 | + raise_exception_ra(env, EXCP_STKOF, 0, 1, GETPC()); | ||
55 | } | 26 | } |
56 | } | 27 | } |
57 | 28 | ||
58 | -- | 29 | -- |
59 | 2.20.1 | 30 | 2.20.1 |
60 | 31 | ||
61 | 32 | diff view generated by jsdifflib |
1 | The do_vfp_2op_sp() and do_vfp_2op_dp() functions currently check | 1 | In do_ldst(), the calculation of the offset needs to be based on the |
---|---|---|---|
2 | whether floating point is supported via the aa32_fpdp_v2 and | 2 | size of the memory access, not the size of the elements in the |
3 | aa32_fpsp_v2 isar checks. For v8.1M MVE support, the VMOV_reg trans | 3 | vector. This meant we were getting it wrong for the widening and |
4 | functions (but not any of the others) need to update this to also | 4 | narrowing variants of the various VLDR and VSTR insns. |
5 | allow the insn if MVE is implemented. Move the check out of the do_ | ||
6 | function and into its callsites (which are all implemented via the | ||
7 | DO_VFP_2OP macro), so we have a place to change the check for the | ||
8 | VMOV insns. | ||
9 | 5 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20210520152840.24453-4-peter.maydell@linaro.org | 8 | Message-id: 20210628135835.6690-2-peter.maydell@linaro.org |
13 | --- | 9 | --- |
14 | target/arm/translate-vfp.c | 37 +++++++++++++++++++------------------ | 10 | target/arm/translate-mve.c | 17 +++++++++-------- |
15 | 1 file changed, 19 insertions(+), 18 deletions(-) | 11 | 1 file changed, 9 insertions(+), 8 deletions(-) |
16 | 12 | ||
17 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | 13 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
18 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/translate-vfp.c | 15 | --- a/target/arm/translate-mve.c |
20 | +++ b/target/arm/translate-vfp.c | 16 | +++ b/target/arm/translate-mve.c |
21 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_sp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) | 17 | @@ -XXX,XX +XXX,XX @@ static bool mve_skip_first_beat(DisasContext *s) |
22 | int veclen = s->vec_len; | ||
23 | TCGv_i32 f0, fd; | ||
24 | |||
25 | - if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
26 | - return false; | ||
27 | - } | ||
28 | + /* Note that the caller must check the aa32_fpsp_v2 feature. */ | ||
29 | |||
30 | if (!dc_isar_feature(aa32_fpshvec, s) && | ||
31 | (veclen != 0 || s->vec_stride != 0)) { | ||
32 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_hp(DisasContext *s, VFPGen2OpSPFn *fn, int vd, int vm) | ||
33 | */ | ||
34 | TCGv_i32 f0; | ||
35 | |||
36 | + /* Note that the caller must check the aa32_fp16_arith feature */ | ||
37 | + | ||
38 | if (!dc_isar_feature(aa32_fp16_arith, s)) { | ||
39 | return false; | ||
40 | } | 18 | } |
41 | @@ -XXX,XX +XXX,XX @@ static bool do_vfp_2op_dp(DisasContext *s, VFPGen2OpDPFn *fn, int vd, int vm) | ||
42 | int veclen = s->vec_len; | ||
43 | TCGv_i64 f0, fd; | ||
44 | |||
45 | - if (!dc_isar_feature(aa32_fpdp_v2, s)) { | ||
46 | - return false; | ||
47 | - } | ||
48 | + /* Note that the caller must check the aa32_fpdp_v2 feature. */ | ||
49 | |||
50 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
51 | if (!dc_isar_feature(aa32_simd_r32, s) && ((vd | vm) & 0x10)) { | ||
52 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) | ||
53 | return true; | ||
54 | } | 19 | } |
55 | 20 | ||
56 | -#define DO_VFP_2OP(INSN, PREC, FN) \ | 21 | -static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) |
57 | +#define DO_VFP_2OP(INSN, PREC, FN, CHECK) \ | 22 | +static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn, |
58 | static bool trans_##INSN##_##PREC(DisasContext *s, \ | 23 | + unsigned msize) |
59 | arg_##INSN##_##PREC *a) \ | 24 | { |
25 | TCGv_i32 addr; | ||
26 | uint32_t offset; | ||
27 | @@ -XXX,XX +XXX,XX @@ static bool do_ldst(DisasContext *s, arg_VLDR_VSTR *a, MVEGenLdStFn *fn) | ||
28 | return true; | ||
29 | } | ||
30 | |||
31 | - offset = a->imm << a->size; | ||
32 | + offset = a->imm << msize; | ||
33 | if (!a->a) { | ||
34 | offset = -offset; | ||
35 | } | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR(DisasContext *s, arg_VLDR_VSTR *a) | ||
37 | { gen_helper_mve_vstrw, gen_helper_mve_vldrw }, | ||
38 | { NULL, NULL } | ||
39 | }; | ||
40 | - return do_ldst(s, a, ldstfns[a->size][a->l]); | ||
41 | + return do_ldst(s, a, ldstfns[a->size][a->l], a->size); | ||
42 | } | ||
43 | |||
44 | -#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST) \ | ||
45 | +#define DO_VLDST_WIDE_NARROW(OP, SLD, ULD, ST, MSIZE) \ | ||
46 | static bool trans_##OP(DisasContext *s, arg_VLDR_VSTR *a) \ | ||
60 | { \ | 47 | { \ |
61 | + if (!dc_isar_feature(CHECK, s)) { \ | 48 | static MVEGenLdStFn * const ldstfns[2][2] = { \ |
62 | + return false; \ | 49 | { gen_helper_mve_##ST, gen_helper_mve_##SLD }, \ |
63 | + } \ | 50 | { NULL, gen_helper_mve_##ULD }, \ |
64 | return do_vfp_2op_##PREC(s, FN, a->vd, a->vm); \ | 51 | }; \ |
52 | - return do_ldst(s, a, ldstfns[a->u][a->l]); \ | ||
53 | + return do_ldst(s, a, ldstfns[a->u][a->l], MSIZE); \ | ||
65 | } | 54 | } |
66 | 55 | ||
67 | -DO_VFP_2OP(VMOV_reg, sp, tcg_gen_mov_i32) | 56 | -DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h) |
68 | -DO_VFP_2OP(VMOV_reg, dp, tcg_gen_mov_i64) | 57 | -DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w) |
69 | +DO_VFP_2OP(VMOV_reg, sp, tcg_gen_mov_i32, aa32_fpsp_v2) | 58 | -DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w) |
70 | +DO_VFP_2OP(VMOV_reg, dp, tcg_gen_mov_i64, aa32_fpdp_v2) | 59 | +DO_VLDST_WIDE_NARROW(VLDSTB_H, vldrb_sh, vldrb_uh, vstrb_h, MO_8) |
71 | 60 | +DO_VLDST_WIDE_NARROW(VLDSTB_W, vldrb_sw, vldrb_uw, vstrb_w, MO_8) | |
72 | -DO_VFP_2OP(VABS, hp, gen_helper_vfp_absh) | 61 | +DO_VLDST_WIDE_NARROW(VLDSTH_W, vldrh_sw, vldrh_uw, vstrh_w, MO_16) |
73 | -DO_VFP_2OP(VABS, sp, gen_helper_vfp_abss) | 62 | |
74 | -DO_VFP_2OP(VABS, dp, gen_helper_vfp_absd) | 63 | static bool trans_VDUP(DisasContext *s, arg_VDUP *a) |
75 | +DO_VFP_2OP(VABS, hp, gen_helper_vfp_absh, aa32_fp16_arith) | ||
76 | +DO_VFP_2OP(VABS, sp, gen_helper_vfp_abss, aa32_fpsp_v2) | ||
77 | +DO_VFP_2OP(VABS, dp, gen_helper_vfp_absd, aa32_fpdp_v2) | ||
78 | |||
79 | -DO_VFP_2OP(VNEG, hp, gen_helper_vfp_negh) | ||
80 | -DO_VFP_2OP(VNEG, sp, gen_helper_vfp_negs) | ||
81 | -DO_VFP_2OP(VNEG, dp, gen_helper_vfp_negd) | ||
82 | +DO_VFP_2OP(VNEG, hp, gen_helper_vfp_negh, aa32_fp16_arith) | ||
83 | +DO_VFP_2OP(VNEG, sp, gen_helper_vfp_negs, aa32_fpsp_v2) | ||
84 | +DO_VFP_2OP(VNEG, dp, gen_helper_vfp_negd, aa32_fpdp_v2) | ||
85 | |||
86 | static void gen_VSQRT_hp(TCGv_i32 vd, TCGv_i32 vm) | ||
87 | { | ||
88 | @@ -XXX,XX +XXX,XX @@ static void gen_VSQRT_dp(TCGv_i64 vd, TCGv_i64 vm) | ||
89 | gen_helper_vfp_sqrtd(vd, vm, cpu_env); | ||
90 | } | ||
91 | |||
92 | -DO_VFP_2OP(VSQRT, hp, gen_VSQRT_hp) | ||
93 | -DO_VFP_2OP(VSQRT, sp, gen_VSQRT_sp) | ||
94 | -DO_VFP_2OP(VSQRT, dp, gen_VSQRT_dp) | ||
95 | +DO_VFP_2OP(VSQRT, hp, gen_VSQRT_hp, aa32_fp16_arith) | ||
96 | +DO_VFP_2OP(VSQRT, sp, gen_VSQRT_sp, aa32_fpsp_v2) | ||
97 | +DO_VFP_2OP(VSQRT, dp, gen_VSQRT_dp, aa32_fpdp_v2) | ||
98 | |||
99 | static bool trans_VCMP_hp(DisasContext *s, arg_VCMP_sp *a) | ||
100 | { | 64 | { |
101 | -- | 65 | -- |
102 | 2.20.1 | 66 | 2.20.1 |
103 | 67 | ||
104 | 68 | diff view generated by jsdifflib |
1 | Some v8M instructions are present if either the floating point | 1 | The initial implementation of the MVE VRMLALDAVH and VRMLSLDAVH |
---|---|---|---|
2 | extension or MVE is implemented. Update our implementation of them | 2 | insns had some bugs: |
3 | to check for MVE as well as for FP. | 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 | ||
4 | 9 | ||
5 | This is all the insns which use CheckDecodeFaults(ExtType_MveOrFp) or | 10 | In particular, fixing the second of these allows us to recast |
6 | CheckDecodeFaults(ExtType_MveOrDpFp) in their pseudocode, which are | 11 | the implementation to avoid 128-bit arithmetic entirely. |
7 | essentially the loads and stores, moves and sysreg accesses, except | ||
8 | for VMOV_reg_sp and VMOV_reg_dp, which we handle in subsequent | ||
9 | patches because they need a refactor to provide a place to put the | ||
10 | new MVE check. | ||
11 | 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> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Message-id: 20210520152840.24453-3-peter.maydell@linaro.org | 19 | Message-id: 20210628135835.6690-3-peter.maydell@linaro.org |
15 | --- | 20 | --- |
16 | target/arm/translate-vfp.c | 48 +++++++++++++++++++++++--------------- | 21 | target/arm/mve_helper.c | 38 +++++++++++++++++++++----------------- |
17 | 1 file changed, 29 insertions(+), 19 deletions(-) | 22 | 1 file changed, 21 insertions(+), 17 deletions(-) |
18 | 23 | ||
19 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | 24 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
20 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/translate-vfp.c | 26 | --- a/target/arm/mve_helper.c |
22 | +++ b/target/arm/translate-vfp.c | 27 | +++ b/target/arm/mve_helper.c |
23 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_to_gp(DisasContext *s, arg_VMOV_to_gp *a) | 28 | @@ -XXX,XX +XXX,XX @@ |
24 | /* VMOV scalar to general purpose register */ | 29 | */ |
25 | TCGv_i32 tmp; | 30 | |
26 | 31 | #include "qemu/osdep.h" | |
27 | - /* SIZE == MO_32 is a VFP instruction; otherwise NEON. */ | 32 | -#include "qemu/int128.h" |
28 | - if (a->size == MO_32 | 33 | #include "cpu.h" |
29 | - ? !dc_isar_feature(aa32_fpsp_v2, s) | 34 | #include "internals.h" |
30 | - : !arm_dc_feature(s, ARM_FEATURE_NEON)) { | 35 | #include "vec_internal.h" |
31 | - return false; | 36 | @@ -XXX,XX +XXX,XX @@ DO_LDAV(vmlsldavsw, 4, int32_t, false, +=, -=) |
32 | + /* | 37 | DO_LDAV(vmlsldavxsw, 4, int32_t, true, +=, -=) |
33 | + * SIZE == MO_32 is a VFP instruction; otherwise NEON. MVE has | 38 | |
34 | + * all sizes, whether the CPU has fp or not. | 39 | /* |
35 | + */ | 40 | - * Rounding multiply add long dual accumulate high: we must keep |
36 | + if (!dc_isar_feature(aa32_mve, s)) { | 41 | - * a 72-bit internal accumulator value and return the top 64 bits. |
37 | + if (a->size == MO_32 | 42 | + * Rounding multiply add long dual accumulate high. In the pseudocode |
38 | + ? !dc_isar_feature(aa32_fpsp_v2, s) | 43 | + * this is implemented with a 72-bit internal accumulator value of which |
39 | + : !arm_dc_feature(s, ARM_FEATURE_NEON)) { | 44 | + * the top 64 bits are returned. We optimize this to avoid having to |
40 | + return false; | 45 | + * use 128-bit arithmetic -- we can do this because the 74-bit accumulator |
41 | + } | 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; \ | ||
42 | } | 81 | } |
43 | 82 | ||
44 | /* UNDEF accesses to D16-D31 if they don't exist */ | 83 | -DO_LDAVH(vrmlaldavhsw, 4, int32_t, false, int128_add, int128_add, int128_makes64) |
45 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_from_gp(DisasContext *s, arg_VMOV_from_gp *a) | 84 | -DO_LDAVH(vrmlaldavhxsw, 4, int32_t, true, int128_add, int128_add, int128_makes64) |
46 | /* VMOV general purpose register to scalar */ | 85 | +DO_LDAVH(vrmlaldavhsw, int32_t, int64_t, false, false) |
47 | TCGv_i32 tmp; | 86 | +DO_LDAVH(vrmlaldavhxsw, int32_t, int64_t, true, false) |
48 | 87 | ||
49 | - /* SIZE == MO_32 is a VFP instruction; otherwise NEON. */ | 88 | -DO_LDAVH(vrmlaldavhuw, 4, uint32_t, false, int128_add, int128_add, int128_make64) |
50 | - if (a->size == MO_32 | 89 | +DO_LDAVH(vrmlaldavhuw, uint32_t, uint64_t, false, false) |
51 | - ? !dc_isar_feature(aa32_fpsp_v2, s) | 90 | |
52 | - : !arm_dc_feature(s, ARM_FEATURE_NEON)) { | 91 | -DO_LDAVH(vrmlsldavhsw, 4, int32_t, false, int128_add, int128_sub, int128_makes64) |
53 | - return false; | 92 | -DO_LDAVH(vrmlsldavhxsw, 4, int32_t, true, int128_add, int128_sub, int128_makes64) |
54 | + /* | 93 | +DO_LDAVH(vrmlsldavhsw, int32_t, int64_t, false, true) |
55 | + * SIZE == MO_32 is a VFP instruction; otherwise NEON. MVE has | 94 | +DO_LDAVH(vrmlsldavhxsw, int32_t, int64_t, true, true) |
56 | + * all sizes, whether the CPU has fp or not. | 95 | |
57 | + */ | 96 | /* Vector add across vector */ |
58 | + if (!dc_isar_feature(aa32_mve, s)) { | 97 | #define DO_VADDV(OP, ESIZE, TYPE) \ |
59 | + if (a->size == MO_32 | ||
60 | + ? !dc_isar_feature(aa32_fpsp_v2, s) | ||
61 | + : !arm_dc_feature(s, ARM_FEATURE_NEON)) { | ||
62 | + return false; | ||
63 | + } | ||
64 | } | ||
65 | |||
66 | /* UNDEF accesses to D16-D31 if they don't exist */ | ||
67 | @@ -XXX,XX +XXX,XX @@ typedef enum FPSysRegCheckResult { | ||
68 | |||
69 | static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | ||
70 | { | ||
71 | - if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
72 | + if (!dc_isar_feature(aa32_fpsp_v2, s) && !dc_isar_feature(aa32_mve, s)) { | ||
73 | return FPSysRegCheckFailed; | ||
74 | } | ||
75 | |||
76 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_single(DisasContext *s, arg_VMOV_single *a) | ||
77 | { | ||
78 | TCGv_i32 tmp; | ||
79 | |||
80 | - if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
81 | + if (!dc_isar_feature(aa32_fpsp_v2, s) && !dc_isar_feature(aa32_mve, s)) { | ||
82 | return false; | ||
83 | } | ||
84 | |||
85 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_64_sp(DisasContext *s, arg_VMOV_64_sp *a) | ||
86 | { | ||
87 | TCGv_i32 tmp; | ||
88 | |||
89 | - if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
90 | + if (!dc_isar_feature(aa32_fpsp_v2, s) && !dc_isar_feature(aa32_mve, s)) { | ||
91 | return false; | ||
92 | } | ||
93 | |||
94 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_64_dp(DisasContext *s, arg_VMOV_64_dp *a) | ||
95 | * floating point register. Note that this does not require support | ||
96 | * for double precision arithmetic. | ||
97 | */ | ||
98 | - if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
99 | + if (!dc_isar_feature(aa32_fpsp_v2, s) && !dc_isar_feature(aa32_mve, s)) { | ||
100 | return false; | ||
101 | } | ||
102 | |||
103 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_hp(DisasContext *s, arg_VLDR_VSTR_sp *a) | ||
104 | uint32_t offset; | ||
105 | TCGv_i32 addr, tmp; | ||
106 | |||
107 | - if (!dc_isar_feature(aa32_fp16_arith, s)) { | ||
108 | + if (!dc_isar_feature(aa32_fpsp_v2, s) && !dc_isar_feature(aa32_mve, s)) { | ||
109 | return false; | ||
110 | } | ||
111 | |||
112 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_sp(DisasContext *s, arg_VLDR_VSTR_sp *a) | ||
113 | uint32_t offset; | ||
114 | TCGv_i32 addr, tmp; | ||
115 | |||
116 | - if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
117 | + if (!dc_isar_feature(aa32_fpsp_v2, s) && !dc_isar_feature(aa32_mve, s)) { | ||
118 | return false; | ||
119 | } | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDR_VSTR_dp(DisasContext *s, arg_VLDR_VSTR_dp *a) | ||
122 | TCGv_i64 tmp; | ||
123 | |||
124 | /* Note that this does not require support for double arithmetic. */ | ||
125 | - if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
126 | + if (!dc_isar_feature(aa32_fpsp_v2, s) && !dc_isar_feature(aa32_mve, s)) { | ||
127 | return false; | ||
128 | } | ||
129 | |||
130 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_sp(DisasContext *s, arg_VLDM_VSTM_sp *a) | ||
131 | TCGv_i32 addr, tmp; | ||
132 | int i, n; | ||
133 | |||
134 | - if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
135 | + if (!dc_isar_feature(aa32_fpsp_v2, s) && !dc_isar_feature(aa32_mve, s)) { | ||
136 | return false; | ||
137 | } | ||
138 | |||
139 | @@ -XXX,XX +XXX,XX @@ static bool trans_VLDM_VSTM_dp(DisasContext *s, arg_VLDM_VSTM_dp *a) | ||
140 | int i, n; | ||
141 | |||
142 | /* Note that this does not require support for double arithmetic. */ | ||
143 | - if (!dc_isar_feature(aa32_fpsp_v2, s)) { | ||
144 | + if (!dc_isar_feature(aa32_fpsp_v2, s) && !dc_isar_feature(aa32_mve, s)) { | ||
145 | return false; | ||
146 | } | ||
147 | |||
148 | -- | 98 | -- |
149 | 2.20.1 | 99 | 2.20.1 |
150 | 100 | ||
151 | 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 | This is BFDOT for both AArch64 AdvSIMD and SVE, | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | and VDOT.BF16 for AArch32 NEON. | 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> | 15 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
7 | Message-id: 20210525225817.400336-8-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/neon-shared.decode | 2 ++ | ||
13 | target/arm/sve.decode | 3 +++ | ||
14 | target/arm/translate-a64.c | 41 +++++++++++++++++++++++++++-------- | ||
15 | target/arm/translate-neon.c | 9 ++++++++ | ||
16 | target/arm/translate-sve.c | 12 ++++++++++ | ||
17 | target/arm/vec_helper.c | 20 +++++++++++++++++ | ||
18 | 7 files changed, 80 insertions(+), 9 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.h | 17 | --- a/target/arm/translate.h |
23 | +++ b/target/arm/helper.h | 18 | +++ b/target/arm/translate.h |
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_usmmla_b, TCG_CALL_NO_RWG, | 19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc) |
25 | 20 | return opc | s->be_data; | |
26 | DEF_HELPER_FLAGS_5(gvec_bfdot, TCG_CALL_NO_RWG, | 21 | } |
27 | void, ptr, ptr, ptr, ptr, i32) | 22 | |
28 | +DEF_HELPER_FLAGS_5(gvec_bfdot_idx, TCG_CALL_NO_RWG, | 23 | +/** |
29 | + void, ptr, ptr, ptr, ptr, i32) | 24 | + * asimd_imm_const: Expand an encoded SIMD constant value |
30 | 25 | + * | |
31 | #ifdef TARGET_AARCH64 | 26 | + * Expand a SIMD constant value. This is essentially the pseudocode |
32 | #include "helper-a64.h" | 27 | + * AdvSIMDExpandImm, except that we also perform the boolean NOT needed for |
33 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | 28 | + * VMVN and VBIC (when cmode < 14 && op == 1). |
34 | index XXXXXXX..XXXXXXX 100644 | 29 | + * |
35 | --- a/target/arm/neon-shared.decode | 30 | + * The combination cmode == 15 op == 1 is a reserved encoding for AArch32; |
36 | +++ b/target/arm/neon-shared.decode | 31 | + * callers must catch this. |
37 | @@ -XXX,XX +XXX,XX @@ VUSDOT_scalar 1111 1110 1 . 00 .... .... 1101 . q:1 index:1 0 vm:4 \ | 32 | + * |
38 | vn=%vn_dp vd=%vd_dp | 33 | + * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but |
39 | VSUDOT_scalar 1111 1110 1 . 00 .... .... 1101 . q:1 index:1 1 vm:4 \ | 34 | + * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A; |
40 | vn=%vn_dp vd=%vd_dp | 35 | + * we produce an immediate constant value of 0 in these cases. |
41 | +VDOT_b16_scal 1111 1110 0 . 00 .... .... 1101 . q:1 index:1 0 vm:4 \ | 36 | + */ |
42 | + vn=%vn_dp vd=%vd_dp | 37 | +uint64_t asimd_imm_const(uint32_t imm, int cmode, int op); |
43 | |||
44 | %vfml_scalar_q0_rm 0:3 5:1 | ||
45 | %vfml_scalar_q1_index 5:1 3:1 | ||
46 | diff --git a/target/arm/sve.decode b/target/arm/sve.decode | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/sve.decode | ||
49 | +++ b/target/arm/sve.decode | ||
50 | @@ -XXX,XX +XXX,XX @@ FMLALB_zzxw 01100100 10 1 ..... 0100.0 ..... ..... @rrxr_3a esz=2 | ||
51 | FMLALT_zzxw 01100100 10 1 ..... 0100.1 ..... ..... @rrxr_3a esz=2 | ||
52 | FMLSLB_zzxw 01100100 10 1 ..... 0110.0 ..... ..... @rrxr_3a esz=2 | ||
53 | FMLSLT_zzxw 01100100 10 1 ..... 0110.1 ..... ..... @rrxr_3a esz=2 | ||
54 | + | 38 | + |
55 | +### SVE2 floating-point bfloat16 dot-product (indexed) | 39 | #endif /* TARGET_ARM_TRANSLATE_H */ |
56 | +BFDOT_zzxz 01100100 01 1 ..... 010000 ..... ..... @rrxr_2 esz=2 | ||
57 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/target/arm/translate-a64.c | ||
60 | +++ b/target/arm/translate-a64.c | ||
61 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
62 | return; | ||
63 | } | ||
64 | break; | ||
65 | - case 0x0f: /* SUDOT, USDOT */ | ||
66 | - if (is_scalar || (size & 1) || !dc_isar_feature(aa64_i8mm, s)) { | ||
67 | + case 0x0f: | ||
68 | + switch (size) { | ||
69 | + case 0: /* SUDOT */ | ||
70 | + case 2: /* USDOT */ | ||
71 | + if (is_scalar || !dc_isar_feature(aa64_i8mm, s)) { | ||
72 | + unallocated_encoding(s); | ||
73 | + return; | ||
74 | + } | ||
75 | + break; | ||
76 | + case 1: /* BFDOT */ | ||
77 | + if (is_scalar || !dc_isar_feature(aa64_bf16, s)) { | ||
78 | + unallocated_encoding(s); | ||
79 | + return; | ||
80 | + } | ||
81 | + break; | ||
82 | + default: | ||
83 | unallocated_encoding(s); | ||
84 | return; | ||
85 | } | ||
86 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | ||
87 | u ? gen_helper_gvec_udot_idx_b | ||
88 | : gen_helper_gvec_sdot_idx_b); | ||
89 | return; | ||
90 | - case 0x0f: /* SUDOT, USDOT */ | ||
91 | - gen_gvec_op4_ool(s, is_q, rd, rn, rm, rd, index, | ||
92 | - extract32(insn, 23, 1) | ||
93 | - ? gen_helper_gvec_usdot_idx_b | ||
94 | - : gen_helper_gvec_sudot_idx_b); | ||
95 | - return; | ||
96 | - | ||
97 | + case 0x0f: | ||
98 | + switch (extract32(insn, 22, 2)) { | ||
99 | + case 0: /* SUDOT */ | ||
100 | + gen_gvec_op4_ool(s, is_q, rd, rn, rm, rd, index, | ||
101 | + gen_helper_gvec_sudot_idx_b); | ||
102 | + return; | ||
103 | + case 1: /* BFDOT */ | ||
104 | + gen_gvec_op4_ool(s, is_q, rd, rn, rm, rd, index, | ||
105 | + gen_helper_gvec_bfdot_idx); | ||
106 | + return; | ||
107 | + case 2: /* USDOT */ | ||
108 | + gen_gvec_op4_ool(s, is_q, rd, rn, rm, rd, index, | ||
109 | + gen_helper_gvec_usdot_idx_b); | ||
110 | + return; | ||
111 | + } | ||
112 | + g_assert_not_reached(); | ||
113 | case 0x11: /* FCMLA #0 */ | ||
114 | case 0x13: /* FCMLA #90 */ | ||
115 | case 0x15: /* FCMLA #180 */ | ||
116 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | 40 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c |
117 | index XXXXXXX..XXXXXXX 100644 | 41 | index XXXXXXX..XXXXXXX 100644 |
118 | --- a/target/arm/translate-neon.c | 42 | --- a/target/arm/translate-neon.c |
119 | +++ b/target/arm/translate-neon.c | 43 | +++ b/target/arm/translate-neon.c |
120 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSUDOT_scalar(DisasContext *s, arg_VSUDOT_scalar *a) | 44 | @@ -XXX,XX +XXX,XX @@ DO_FP_2SH(VCVT_UH, gen_helper_gvec_vcvt_uh) |
121 | gen_helper_gvec_sudot_idx_b); | 45 | DO_FP_2SH(VCVT_HS, gen_helper_gvec_vcvt_hs) |
46 | DO_FP_2SH(VCVT_HU, gen_helper_gvec_vcvt_hu) | ||
47 | |||
48 | -static uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | ||
49 | -{ | ||
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); | ||
109 | -} | ||
110 | - | ||
111 | static bool do_1reg_imm(DisasContext *s, arg_1reg_imm *a, | ||
112 | GVecGen2iFn *fn) | ||
113 | { | ||
114 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
115 | index XXXXXXX..XXXXXXX 100644 | ||
116 | --- a/target/arm/translate.c | ||
117 | +++ b/target/arm/translate.c | ||
118 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void) | ||
119 | a64_translate_init(); | ||
122 | } | 120 | } |
123 | 121 | ||
124 | +static bool trans_VDOT_b16_scal(DisasContext *s, arg_VDOT_b16_scal *a) | 122 | +uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) |
125 | +{ | 123 | +{ |
126 | + if (!dc_isar_feature(aa32_bf16, s)) { | 124 | + /* Expand the encoded constant as per AdvSIMDExpandImm pseudocode */ |
127 | + return false; | 125 | + switch (cmode) { |
126 | + case 0: case 1: | ||
127 | + /* no-op */ | ||
128 | + break; | ||
129 | + case 2: case 3: | ||
130 | + imm <<= 8; | ||
131 | + break; | ||
132 | + case 4: case 5: | ||
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; | ||
128 | + } | 172 | + } |
129 | + return do_neon_ddda(s, a->q * 6, a->vd, a->vn, a->vm, a->index, | 173 | + if (op) { |
130 | + gen_helper_gvec_bfdot_idx); | 174 | + imm = ~imm; |
175 | + } | ||
176 | + return dup_const(MO_32, imm); | ||
131 | +} | 177 | +} |
132 | + | 178 | + |
133 | static bool trans_VFML_scalar(DisasContext *s, arg_VFML_scalar *a) | 179 | /* Generate a label used for skipping this instruction */ |
180 | void arm_gen_condlabel(DisasContext *s) | ||
134 | { | 181 | { |
135 | int opr_sz; | ||
136 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
137 | index XXXXXXX..XXXXXXX 100644 | ||
138 | --- a/target/arm/translate-sve.c | ||
139 | +++ b/target/arm/translate-sve.c | ||
140 | @@ -XXX,XX +XXX,XX @@ static bool trans_BFDOT_zzzz(DisasContext *s, arg_rrrr_esz *a) | ||
141 | } | ||
142 | return true; | ||
143 | } | ||
144 | + | ||
145 | +static bool trans_BFDOT_zzxz(DisasContext *s, arg_rrxr_esz *a) | ||
146 | +{ | ||
147 | + if (!dc_isar_feature(aa64_sve_bf16, s)) { | ||
148 | + return false; | ||
149 | + } | ||
150 | + if (sve_access_check(s)) { | ||
151 | + gen_gvec_ool_zzzz(s, gen_helper_gvec_bfdot_idx, | ||
152 | + a->rd, a->rn, a->rm, a->ra, a->index); | ||
153 | + } | ||
154 | + return true; | ||
155 | +} | ||
156 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
157 | index XXXXXXX..XXXXXXX 100644 | ||
158 | --- a/target/arm/vec_helper.c | ||
159 | +++ b/target/arm/vec_helper.c | ||
160 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_bfdot)(void *vd, void *vn, void *vm, void *va, uint32_t desc) | ||
161 | } | ||
162 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
163 | } | ||
164 | + | ||
165 | +void HELPER(gvec_bfdot_idx)(void *vd, void *vn, void *vm, | ||
166 | + void *va, uint32_t desc) | ||
167 | +{ | ||
168 | + intptr_t i, j, opr_sz = simd_oprsz(desc); | ||
169 | + intptr_t index = simd_data(desc); | ||
170 | + intptr_t elements = opr_sz / 4; | ||
171 | + intptr_t eltspersegment = MIN(16 / 4, elements); | ||
172 | + float32 *d = vd, *a = va; | ||
173 | + uint32_t *n = vn, *m = vm; | ||
174 | + | ||
175 | + for (i = 0; i < elements; i += eltspersegment) { | ||
176 | + uint32_t m_idx = m[i + H4(index)]; | ||
177 | + | ||
178 | + for (j = i; j < i + eltspersegment; j++) { | ||
179 | + d[j] = bfdotadd(a[j], n[j], m_idx); | ||
180 | + } | ||
181 | + } | ||
182 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
183 | +} | ||
184 | -- | 182 | -- |
185 | 2.20.1 | 183 | 2.20.1 |
186 | 184 | ||
187 | 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 | The operands to tcg_gen_atomic_fetch_s{min,max}_i64 must | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | be signed, so that the inputs are properly extended. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Zero extend the result afterward, as needed. | 8 | Message-id: 20210628135835.6690-5-peter.maydell@linaro.org |
9 | --- | ||
10 | target/arm/translate.h | 3 +- | ||
11 | target/arm/translate-a64.c | 86 ++++---------------------------------- | ||
12 | target/arm/translate.c | 17 +++++++- | ||
13 | 3 files changed, 24 insertions(+), 82 deletions(-) | ||
6 | 14 | ||
7 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/364 | 15 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 16 | index XXXXXXX..XXXXXXX 100644 |
9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 17 | --- a/target/arm/translate.h |
10 | Message-id: 20210602020720.47679-1-richard.henderson@linaro.org | 18 | +++ b/target/arm/translate.h |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | @@ -XXX,XX +XXX,XX @@ static inline MemOp finalize_memop(DisasContext *s, MemOp opc) |
12 | --- | 20 | * VMVN and VBIC (when cmode < 14 && op == 1). |
13 | target/arm/translate-a64.c | 13 ++++++++++--- | 21 | * |
14 | 1 file changed, 10 insertions(+), 3 deletions(-) | 22 | * The combination cmode == 15 op == 1 is a reserved encoding for AArch32; |
15 | 23 | - * callers must catch this. | |
24 | + * callers must catch this; we return the 64-bit constant value defined | ||
25 | + * for AArch64. | ||
26 | * | ||
27 | * cmode = 2,3,4,5,6,7,10,11,12,13 imm=0 was UNPREDICTABLE in v7A but | ||
28 | * is either not unpredictable or merely CONSTRAINED UNPREDICTABLE in v8A; | ||
16 | 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 |
17 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 31 | --- a/target/arm/translate-a64.c |
19 | +++ b/target/arm/translate-a64.c | 32 | +++ b/target/arm/translate-a64.c |
20 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | 33 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) |
21 | int o3_opc = extract32(insn, 12, 4); | 34 | { |
22 | bool r = extract32(insn, 22, 1); | 35 | int rd = extract32(insn, 0, 5); |
23 | bool a = extract32(insn, 23, 1); | 36 | int cmode = extract32(insn, 12, 4); |
24 | - TCGv_i64 tcg_rs, clean_addr; | 37 | - int cmode_3_1 = extract32(cmode, 1, 3); |
25 | + TCGv_i64 tcg_rs, tcg_rt, clean_addr; | 38 | - int cmode_0 = extract32(cmode, 0, 1); |
26 | AtomicThreeOpFn *fn = NULL; | 39 | int o2 = extract32(insn, 11, 1); |
27 | + MemOp mop = s->be_data | size | MO_ALIGN; | 40 | uint64_t abcdefgh = extract32(insn, 5, 5) | (extract32(insn, 16, 3) << 5); |
28 | 41 | bool is_neg = extract32(insn, 29, 1); | |
29 | if (is_vector || !dc_isar_feature(aa64_atomics, s)) { | 42 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) |
30 | unallocated_encoding(s); | 43 | return; |
31 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | 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)) { | ||
133 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
134 | index XXXXXXX..XXXXXXX 100644 | ||
135 | --- a/target/arm/translate.c | ||
136 | +++ b/target/arm/translate.c | ||
137 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | ||
138 | case 14: | ||
139 | if (op) { | ||
140 | /* | ||
141 | - * This is the only case where the top and bottom 32 bits | ||
142 | - * of the encoded constant differ. | ||
143 | + * This and cmode == 15 op == 1 are the only cases where | ||
144 | + * the top and bottom 32 bits of the encoded constant differ. | ||
145 | */ | ||
146 | uint64_t imm64 = 0; | ||
147 | int n; | ||
148 | @@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op) | ||
149 | imm |= (imm << 8) | (imm << 16) | (imm << 24); | ||
32 | break; | 150 | break; |
33 | case 004: /* LDSMAX */ | 151 | case 15: |
34 | fn = tcg_gen_atomic_fetch_smax_i64; | 152 | + if (op) { |
35 | + mop |= MO_SIGN; | 153 | + /* Reserved encoding for AArch32; valid for AArch64 */ |
154 | + uint64_t imm64 = (uint64_t)(imm & 0x3f) << 48; | ||
155 | + if (imm & 0x80) { | ||
156 | + imm64 |= 0x8000000000000000ULL; | ||
157 | + } | ||
158 | + if (imm & 0x40) { | ||
159 | + imm64 |= 0x3fc0000000000000ULL; | ||
160 | + } else { | ||
161 | + imm64 |= 0x4000000000000000ULL; | ||
162 | + } | ||
163 | + return imm64; | ||
164 | + } | ||
165 | imm = ((imm & 0x80) << 24) | ((imm & 0x3f) << 19) | ||
166 | | ((imm & 0x40) ? (0x1f << 25) : (1 << 30)); | ||
36 | break; | 167 | break; |
37 | case 005: /* LDSMIN */ | ||
38 | fn = tcg_gen_atomic_fetch_smin_i64; | ||
39 | + mop |= MO_SIGN; | ||
40 | break; | ||
41 | case 006: /* LDUMAX */ | ||
42 | fn = tcg_gen_atomic_fetch_umax_i64; | ||
43 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | ||
44 | } | ||
45 | |||
46 | tcg_rs = read_cpu_reg(s, rs, true); | ||
47 | + tcg_rt = cpu_reg(s, rt); | ||
48 | |||
49 | if (o3_opc == 1) { /* LDCLR */ | ||
50 | tcg_gen_not_i64(tcg_rs, tcg_rs); | ||
51 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | ||
52 | /* The tcg atomic primitives are all full barriers. Therefore we | ||
53 | * can ignore the Acquire and Release bits of this instruction. | ||
54 | */ | ||
55 | - fn(cpu_reg(s, rt), clean_addr, tcg_rs, get_mem_index(s), | ||
56 | - s->be_data | size | MO_ALIGN); | ||
57 | + fn(tcg_rt, clean_addr, tcg_rs, get_mem_index(s), mop); | ||
58 | + | ||
59 | + if ((mop & MO_SIGN) && size != MO_64) { | ||
60 | + tcg_gen_ext32u_i64(tcg_rt, tcg_rt); | ||
61 | + } | ||
62 | } | ||
63 | |||
64 | /* | ||
65 | -- | 168 | -- |
66 | 2.20.1 | 169 | 2.20.1 |
67 | 170 | ||
68 | 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 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | (We can't replace the other use of bitfield_replicate() in this file, |
4 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | in logic_imm_decode_wmask(), because that location needs to handle 2 |
5 | Message-id: 20210525225817.400336-3-richard.henderson@linaro.org | 6 | and 4 bit elements, which dup_const() cannot.) |
7 | |||
6 | 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 | ||
7 | --- | 11 | --- |
8 | target/arm/translate-a64.c | 15 ++++++--------- | 12 | target/arm/translate-a64.c | 2 +- |
9 | 1 file changed, 6 insertions(+), 9 deletions(-) | 13 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 14 | ||
11 | 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 |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-a64.c | 17 | --- a/target/arm/translate-a64.c |
14 | +++ b/target/arm/translate-a64.c | 18 | +++ b/target/arm/translate-a64.c |
15 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) | 19 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn) |
16 | int rd = extract32(insn, 0, 5); | 20 | /* FMOV (vector, immediate) - half-precision */ |
17 | 21 | imm = vfp_expand_imm(MO_16, abcdefgh); | |
18 | if (mos) { | 22 | /* now duplicate across the lanes */ |
19 | - unallocated_encoding(s); | 23 | - imm = bitfield_replicate(imm, 16); |
20 | - return; | 24 | + imm = dup_const(MO_16, imm); |
21 | + goto do_unallocated; | 25 | } else { |
22 | } | 26 | imm = asimd_imm_const(abcdefgh, cmode, is_neg); |
23 | |||
24 | switch (opcode) { | ||
25 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) | ||
26 | /* FCVT between half, single and double precision */ | ||
27 | int dtype = extract32(opcode, 0, 2); | ||
28 | if (type == 2 || dtype == type) { | ||
29 | - unallocated_encoding(s); | ||
30 | - return; | ||
31 | + goto do_unallocated; | ||
32 | } | ||
33 | if (!fp_access_check(s)) { | ||
34 | return; | ||
35 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) | ||
36 | |||
37 | case 0x10 ... 0x13: /* FRINT{32,64}{X,Z} */ | ||
38 | if (type > 1 || !dc_isar_feature(aa64_frint, s)) { | ||
39 | - unallocated_encoding(s); | ||
40 | - return; | ||
41 | + goto do_unallocated; | ||
42 | } | ||
43 | /* fall through */ | ||
44 | case 0x0 ... 0x3: | ||
45 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) | ||
46 | break; | ||
47 | case 3: | ||
48 | if (!dc_isar_feature(aa64_fp16, s)) { | ||
49 | - unallocated_encoding(s); | ||
50 | - return; | ||
51 | + goto do_unallocated; | ||
52 | } | ||
53 | |||
54 | if (!fp_access_check(s)) { | ||
55 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) | ||
56 | handle_fp_1src_half(s, opcode, rd, rn); | ||
57 | break; | ||
58 | default: | ||
59 | - unallocated_encoding(s); | ||
60 | + goto do_unallocated; | ||
61 | } | ||
62 | break; | ||
63 | |||
64 | default: | ||
65 | + do_unallocated: | ||
66 | unallocated_encoding(s); | ||
67 | break; | ||
68 | } | 27 | } |
69 | -- | 28 | -- |
70 | 2.20.1 | 29 | 2.20.1 |
71 | 30 | ||
72 | 31 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 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 | This is BFMLAL{B,T} for both AArch64 AdvSIMD and SVE, | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | and VFMA{B,T}.BF16 for AArch32 NEON. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210628135835.6690-7-peter.maydell@linaro.org | ||
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(+) | ||
5 | 15 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210525225817.400336-10-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper.h | 3 +++ | ||
12 | target/arm/neon-shared.decode | 3 +++ | ||
13 | target/arm/sve.decode | 3 +++ | ||
14 | target/arm/translate-a64.c | 13 +++++++++---- | ||
15 | target/arm/translate-neon.c | 9 +++++++++ | ||
16 | target/arm/translate-sve.c | 30 ++++++++++++++++++++++++++++++ | ||
17 | target/arm/vec_helper.c | 16 ++++++++++++++++ | ||
18 | 7 files changed, 73 insertions(+), 4 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.h | 18 | --- a/target/arm/helper-mve.h |
23 | +++ b/target/arm/helper.h | 19 | +++ b/target/arm/helper-mve.h |
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_bfdot_idx, TCG_CALL_NO_RWG, | 20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvsh, TCG_CALL_NO_WG, i32, env, ptr, i32) |
25 | DEF_HELPER_FLAGS_5(gvec_bfmmla, TCG_CALL_NO_RWG, | 21 | DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) |
26 | void, ptr, ptr, ptr, ptr, i32) | 22 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
27 | 23 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) | |
28 | +DEF_HELPER_FLAGS_6(gvec_bfmlal, TCG_CALL_NO_RWG, | ||
29 | + void, ptr, ptr, ptr, ptr, ptr, i32) | ||
30 | + | 24 | + |
31 | #ifdef TARGET_AARCH64 | 25 | +DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) |
32 | #include "helper-a64.h" | 26 | +DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) |
33 | #include "helper-sve.h" | 27 | +DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) |
34 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | 28 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
35 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/neon-shared.decode | 30 | --- a/target/arm/mve.decode |
37 | +++ b/target/arm/neon-shared.decode | 31 | +++ b/target/arm/mve.decode |
38 | @@ -XXX,XX +XXX,XX @@ VUSMMLA 1111 1100 1.10 .... .... 1100 .1.0 .... \ | 32 | @@ -XXX,XX +XXX,XX @@ |
39 | VMMLA_b16 1111 1100 0.00 .... .... 1100 .1.0 .... \ | 33 | # VQDMULL has size in bit 28: 0 for 16 bit, 1 for 32 bit |
40 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | 34 | %size_28 28:1 !function=plus_1 |
41 | 35 | ||
42 | +VFMA_b16 1111 110 0 0.11 .... .... 1000 . q:1 . 1 .... \ | 36 | +# 1imm format immediate |
43 | + vm=%vm_dp vn=%vn_dp vd=%vd_dp | 37 | +%imm_28_16_0 28:1 16:3 0:4 |
44 | + | 38 | + |
45 | VCMLA_scalar 1111 1110 0 . rot:2 .... .... 1000 . q:1 index:1 0 vm:4 \ | 39 | &vldr_vstr rn qd imm p a w size l u |
46 | vn=%vn_dp vd=%vd_dp size=1 | 40 | &1op qd qm size |
47 | VCMLA_scalar 1111 1110 1 . rot:2 .... .... 1000 . q:1 . 0 .... \ | 41 | &2op qd qm qn size |
48 | diff --git a/target/arm/sve.decode b/target/arm/sve.decode | 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 | ||
49 | index XXXXXXX..XXXXXXX 100644 | 72 | index XXXXXXX..XXXXXXX 100644 |
50 | --- a/target/arm/sve.decode | 73 | --- a/target/arm/mve_helper.c |
51 | +++ b/target/arm/sve.decode | 74 | +++ b/target/arm/mve_helper.c |
52 | @@ -XXX,XX +XXX,XX @@ FMLALT_zzzw 01100100 10 1 ..... 10 0 00 1 ..... ..... @rda_rn_rm_e0 | 75 | @@ -XXX,XX +XXX,XX @@ DO_1OP(vnegw, 4, int32_t, DO_NEG) |
53 | FMLSLB_zzzw 01100100 10 1 ..... 10 1 00 0 ..... ..... @rda_rn_rm_e0 | 76 | DO_1OP(vfnegh, 8, uint64_t, DO_FNEGH) |
54 | FMLSLT_zzzw 01100100 10 1 ..... 10 1 00 1 ..... ..... @rda_rn_rm_e0 | 77 | DO_1OP(vfnegs, 8, uint64_t, DO_FNEGS) |
55 | 78 | ||
56 | +BFMLALB_zzzw 01100100 11 1 ..... 10 0 00 0 ..... ..... @rda_rn_rm_e0 | 79 | +/* |
57 | +BFMLALT_zzzw 01100100 11 1 ..... 10 0 00 1 ..... ..... @rda_rn_rm_e0 | 80 | + * 1 operand immediates: Vda is destination and possibly also one source. |
81 | + * All these insns work at 64-bit widths. | ||
82 | + */ | ||
83 | +#define DO_1OP_IMM(OP, FN) \ | ||
84 | + void HELPER(mve_##OP)(CPUARMState *env, void *vda, uint64_t imm) \ | ||
85 | + { \ | ||
86 | + uint64_t *da = vda; \ | ||
87 | + uint16_t mask = mve_element_mask(env); \ | ||
88 | + unsigned e; \ | ||
89 | + for (e = 0; e < 16 / 8; e++, mask >>= 8) { \ | ||
90 | + mergemask(&da[H8(e)], FN(da[H8(e)], imm), mask); \ | ||
91 | + } \ | ||
92 | + mve_advance_vpt(env); \ | ||
93 | + } | ||
58 | + | 94 | + |
59 | ### SVE2 floating-point bfloat16 dot-product | 95 | +#define DO_MOVI(N, I) (I) |
60 | BFDOT_zzzz 01100100 01 1 ..... 10 0 00 0 ..... ..... @rda_rn_rm_e0 | 96 | +#define DO_ANDI(N, I) ((N) & (I)) |
61 | 97 | +#define DO_ORRI(N, I) ((N) | (I)) | |
62 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 98 | + |
99 | +DO_1OP_IMM(vmovi, DO_MOVI) | ||
100 | +DO_1OP_IMM(vandi, DO_ANDI) | ||
101 | +DO_1OP_IMM(vorri, DO_ORRI) | ||
102 | + | ||
103 | #define DO_2OP(OP, ESIZE, TYPE, FN) \ | ||
104 | void HELPER(glue(mve_, OP))(CPUARMState *env, \ | ||
105 | void *vd, void *vn, void *vm) \ | ||
106 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | 107 | index XXXXXXX..XXXXXXX 100644 |
64 | --- a/target/arm/translate-a64.c | 108 | --- a/target/arm/translate-mve.c |
65 | +++ b/target/arm/translate-a64.c | 109 | +++ b/target/arm/translate-mve.c |
66 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | 110 | @@ -XXX,XX +XXX,XX @@ typedef void MVEGenTwoOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_ptr); |
67 | } | 111 | typedef void MVEGenTwoOpScalarFn(TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i32); |
68 | feature = dc_isar_feature(aa64_bf16, s); | 112 | typedef void MVEGenDualAccOpFn(TCGv_i64, TCGv_ptr, TCGv_ptr, TCGv_ptr, TCGv_i64); |
69 | break; | 113 | typedef void MVEGenVADDVFn(TCGv_i32, TCGv_ptr, TCGv_ptr, TCGv_i32); |
70 | - case 0x1f: /* BFDOT */ | 114 | +typedef void MVEGenOneOpImmFn(TCGv_ptr, TCGv_ptr, TCGv_i64); |
71 | + case 0x1f: | 115 | |
72 | switch (size) { | 116 | /* Return the offset of a Qn register (same semantics as aa32_vfp_qreg()) */ |
73 | - case 1: | 117 | static inline long mve_qreg_offset(unsigned reg) |
74 | + case 1: /* BFDOT */ | 118 | @@ -XXX,XX +XXX,XX @@ static bool trans_VADDV(DisasContext *s, arg_VADDV *a) |
75 | + case 3: /* BFMLAL{B,T} */ | 119 | mve_update_eci(s); |
76 | feature = dc_isar_feature(aa64_bf16, s); | ||
77 | break; | ||
78 | default: | ||
79 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
80 | case 0xd: /* BFMMLA */ | ||
81 | gen_gvec_op4_ool(s, is_q, rd, rn, rm, rd, 0, gen_helper_gvec_bfmmla); | ||
82 | return; | ||
83 | - case 0xf: /* BFDOT */ | ||
84 | + case 0xf: | ||
85 | switch (size) { | ||
86 | - case 1: | ||
87 | + case 1: /* BFDOT */ | ||
88 | gen_gvec_op4_ool(s, is_q, rd, rn, rm, rd, 0, gen_helper_gvec_bfdot); | ||
89 | break; | ||
90 | + case 3: /* BFMLAL{B,T} */ | ||
91 | + gen_gvec_op4_fpst(s, 1, rd, rn, rm, rd, false, is_q, | ||
92 | + gen_helper_gvec_bfmlal); | ||
93 | + break; | ||
94 | default: | ||
95 | g_assert_not_reached(); | ||
96 | } | ||
97 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
98 | index XXXXXXX..XXXXXXX 100644 | ||
99 | --- a/target/arm/translate-neon.c | ||
100 | +++ b/target/arm/translate-neon.c | ||
101 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMMLA_b16(DisasContext *s, arg_VMMLA_b16 *a) | ||
102 | return do_neon_ddda(s, 7, a->vd, a->vn, a->vm, 0, | ||
103 | gen_helper_gvec_bfmmla); | ||
104 | } | ||
105 | + | ||
106 | +static bool trans_VFMA_b16(DisasContext *s, arg_VFMA_b16 *a) | ||
107 | +{ | ||
108 | + if (!dc_isar_feature(aa32_bf16, s)) { | ||
109 | + return false; | ||
110 | + } | ||
111 | + return do_neon_ddda_fpst(s, 7, a->vd, a->vn, a->vm, a->q, FPST_STD, | ||
112 | + gen_helper_gvec_bfmlal); | ||
113 | +} | ||
114 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
115 | index XXXXXXX..XXXXXXX 100644 | ||
116 | --- a/target/arm/translate-sve.c | ||
117 | +++ b/target/arm/translate-sve.c | ||
118 | @@ -XXX,XX +XXX,XX @@ static bool trans_BFMMLA(DisasContext *s, arg_rrrr_esz *a) | ||
119 | } | ||
120 | return true; | 120 | return true; |
121 | } | 121 | } |
122 | + | 122 | + |
123 | +static bool do_BFMLAL_zzzw(DisasContext *s, arg_rrrr_esz *a, bool sel) | 123 | +static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn) |
124 | +{ | 124 | +{ |
125 | + if (!dc_isar_feature(aa64_sve_bf16, s)) { | 125 | + TCGv_ptr qd; |
126 | + uint64_t imm; | ||
127 | + | ||
128 | + if (!dc_isar_feature(aa32_mve, s) || | ||
129 | + !mve_check_qreg_bank(s, a->qd) || | ||
130 | + !fn) { | ||
126 | + return false; | 131 | + return false; |
127 | + } | 132 | + } |
128 | + if (sve_access_check(s)) { | 133 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
129 | + TCGv_ptr status = fpstatus_ptr(FPST_FPCR); | 134 | + return true; |
130 | + unsigned vsz = vec_full_reg_size(s); | 135 | + } |
131 | + | 136 | + |
132 | + tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, a->rd), | 137 | + imm = asimd_imm_const(a->imm, a->cmode, a->op); |
133 | + vec_full_reg_offset(s, a->rn), | 138 | + |
134 | + vec_full_reg_offset(s, a->rm), | 139 | + qd = mve_qreg_ptr(a->qd); |
135 | + vec_full_reg_offset(s, a->ra), | 140 | + fn(cpu_env, qd, tcg_constant_i64(imm)); |
136 | + status, vsz, vsz, sel, | 141 | + tcg_temp_free_ptr(qd); |
137 | + gen_helper_gvec_bfmlal); | 142 | + mve_update_eci(s); |
138 | + tcg_temp_free_ptr(status); | ||
139 | + } | ||
140 | + return true; | 143 | + return true; |
141 | +} | 144 | +} |
142 | + | 145 | + |
143 | +static bool trans_BFMLALB_zzzw(DisasContext *s, arg_rrrr_esz *a) | 146 | +static bool trans_Vimm_1r(DisasContext *s, arg_1imm *a) |
144 | +{ | 147 | +{ |
145 | + return do_BFMLAL_zzzw(s, a, false); | 148 | + /* Handle decode of cmode/op here between VORR/VBIC/VMOV */ |
146 | +} | 149 | + MVEGenOneOpImmFn *fn; |
147 | + | 150 | + |
148 | +static bool trans_BFMLALT_zzzw(DisasContext *s, arg_rrrr_esz *a) | 151 | + if ((a->cmode & 1) && a->cmode < 12) { |
149 | +{ | 152 | + if (a->op) { |
150 | + return do_BFMLAL_zzzw(s, a, true); | 153 | + /* |
151 | +} | 154 | + * For op=1, the immediate will be inverted by asimd_imm_const(), |
152 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | 155 | + * so the VBIC becomes a logical AND operation. |
153 | index XXXXXXX..XXXXXXX 100644 | 156 | + */ |
154 | --- a/target/arm/vec_helper.c | 157 | + fn = gen_helper_mve_vandi; |
155 | +++ b/target/arm/vec_helper.c | 158 | + } else { |
156 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_bfmmla)(void *vd, void *vn, void *vm, void *va, uint32_t desc) | 159 | + fn = gen_helper_mve_vorri; |
157 | } | 160 | + } |
158 | clear_tail(d, opr_sz, simd_maxsz(desc)); | 161 | + } else { |
159 | } | 162 | + /* There is one unallocated cmode/op combination in this space */ |
160 | + | 163 | + if (a->cmode == 15 && a->op == 1) { |
161 | +void HELPER(gvec_bfmlal)(void *vd, void *vn, void *vm, void *va, | 164 | + return false; |
162 | + void *stat, uint32_t desc) | 165 | + } |
163 | +{ | 166 | + /* asimd_imm_const() sorts out VMVNI vs VMOVI for us */ |
164 | + intptr_t i, opr_sz = simd_oprsz(desc); | 167 | + fn = gen_helper_mve_vmovi; |
165 | + intptr_t sel = simd_data(desc); | ||
166 | + float32 *d = vd, *a = va; | ||
167 | + bfloat16 *n = vn, *m = vm; | ||
168 | + | ||
169 | + for (i = 0; i < opr_sz / 4; ++i) { | ||
170 | + float32 nn = n[H2(i * 2 + sel)] << 16; | ||
171 | + float32 mm = m[H2(i * 2 + sel)] << 16; | ||
172 | + d[H4(i)] = float32_muladd(nn, mm, a[H4(i)], 0, stat); | ||
173 | + } | 168 | + } |
174 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | 169 | + return do_1imm(s, a, fn); |
175 | +} | 170 | +} |
176 | -- | 171 | -- |
177 | 2.20.1 | 172 | 2.20.1 |
178 | 173 | ||
179 | 174 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Implement the MVE shift-vector-left-by-immediate insns VSHL, VQSHL |
---|---|---|---|
2 | 2 | and VQSHLU. | |
3 | This is BFMLAL{B,T} for both AArch64 AdvSIMD and SVE, | 3 | |
4 | and VFMA{B,T}.BF16 for AArch32 NEON. | 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 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210525225817.400336-11-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210628135835.6690-8-peter.maydell@linaro.org | ||
10 | --- | 10 | --- |
11 | target/arm/helper.h | 2 ++ | 11 | target/arm/helper-mve.h | 16 +++++++++++ |
12 | target/arm/neon-shared.decode | 2 ++ | 12 | target/arm/mve.decode | 23 +++++++++++++++ |
13 | target/arm/sve.decode | 2 ++ | 13 | target/arm/mve_helper.c | 57 ++++++++++++++++++++++++++++++++++++++ |
14 | target/arm/translate-a64.c | 15 ++++++++++++++- | 14 | target/arm/translate-mve.c | 51 ++++++++++++++++++++++++++++++++++ |
15 | target/arm/translate-neon.c | 10 ++++++++++ | 15 | 4 files changed, 147 insertions(+) |
16 | target/arm/translate-sve.c | 30 ++++++++++++++++++++++++++++++ | 16 | |
17 | target/arm/vec_helper.c | 22 ++++++++++++++++++++++ | 17 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
18 | 7 files changed, 82 insertions(+), 1 deletion(-) | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | 19 | --- a/target/arm/helper-mve.h | |
20 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 20 | +++ b/target/arm/helper-mve.h |
21 | index XXXXXXX..XXXXXXX 100644 | 21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
22 | --- a/target/arm/helper.h | 22 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) |
23 | +++ b/target/arm/helper.h | 23 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) |
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_bfmmla, TCG_CALL_NO_RWG, | 24 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) |
25 | 25 | + | |
26 | DEF_HELPER_FLAGS_6(gvec_bfmlal, TCG_CALL_NO_RWG, | 26 | +DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
27 | void, ptr, ptr, ptr, ptr, ptr, i32) | 27 | +DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
28 | +DEF_HELPER_FLAGS_6(gvec_bfmlal_idx, TCG_CALL_NO_RWG, | 28 | +DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
29 | + void, ptr, ptr, ptr, ptr, ptr, i32) | 29 | + |
30 | 30 | +DEF_HELPER_FLAGS_4(mve_vqshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
31 | #ifdef TARGET_AARCH64 | 31 | +DEF_HELPER_FLAGS_4(mve_vqshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
32 | #include "helper-a64.h" | 32 | +DEF_HELPER_FLAGS_4(mve_vqshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
33 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | 33 | + |
34 | index XXXXXXX..XXXXXXX 100644 | 34 | +DEF_HELPER_FLAGS_4(mve_vqshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
35 | --- a/target/arm/neon-shared.decode | 35 | +DEF_HELPER_FLAGS_4(mve_vqshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
36 | +++ b/target/arm/neon-shared.decode | 36 | +DEF_HELPER_FLAGS_4(mve_vqshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
37 | @@ -XXX,XX +XXX,XX @@ VFML_scalar 1111 1110 0 . 0 s:1 .... .... 1000 . 0 . 1 index:1 ... \ | 37 | + |
38 | rm=%vfml_scalar_q0_rm vn=%vn_sp vd=%vd_dp q=0 | 38 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
39 | VFML_scalar 1111 1110 0 . 0 s:1 .... .... 1000 . 1 . 1 . rm:3 \ | 39 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
40 | index=%vfml_scalar_q1_index vn=%vn_dp vd=%vd_dp q=1 | 40 | +DEF_HELPER_FLAGS_4(mve_vqshlui_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
41 | +VFMA_b16_scal 1111 1110 0.11 .... .... 1000 . q:1 . 1 . vm:3 \ | 41 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
42 | + index=%vfml_scalar_q1_index vn=%vn_dp vd=%vd_dp | 42 | index XXXXXXX..XXXXXXX 100644 |
43 | diff --git a/target/arm/sve.decode b/target/arm/sve.decode | 43 | --- a/target/arm/mve.decode |
44 | index XXXXXXX..XXXXXXX 100644 | 44 | +++ b/target/arm/mve.decode |
45 | --- a/target/arm/sve.decode | 45 | @@ -XXX,XX +XXX,XX @@ |
46 | +++ b/target/arm/sve.decode | 46 | &2op qd qm qn size |
47 | @@ -XXX,XX +XXX,XX @@ FMLALB_zzxw 01100100 10 1 ..... 0100.0 ..... ..... @rrxr_3a esz=2 | 47 | &2scalar qd qn rm size |
48 | FMLALT_zzxw 01100100 10 1 ..... 0100.1 ..... ..... @rrxr_3a esz=2 | 48 | &1imm qd imm cmode op |
49 | FMLSLB_zzxw 01100100 10 1 ..... 0110.0 ..... ..... @rrxr_3a esz=2 | 49 | +&2shift qd qm shift size |
50 | FMLSLT_zzxw 01100100 10 1 ..... 0110.1 ..... ..... @rrxr_3a esz=2 | 50 | |
51 | +BFMLALB_zzxw 01100100 11 1 ..... 0100.0 ..... ..... @rrxr_3a esz=2 | 51 | @vldr_vstr ....... . . . . l:1 rn:4 ... ...... imm:7 &vldr_vstr qd=%qd u=0 |
52 | +BFMLALT_zzxw 01100100 11 1 ..... 0100.1 ..... ..... @rrxr_3a esz=2 | 52 | # Note that both Rn and Qd are 3 bits only (no D bit) |
53 | 53 | @@ -XXX,XX +XXX,XX @@ | |
54 | ### SVE2 floating-point bfloat16 dot-product (indexed) | 54 | @2scalar .... .... .. size:2 .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn |
55 | BFDOT_zzxz 01100100 01 1 ..... 010000 ..... ..... @rrxr_2 esz=2 | 55 | @2scalar_nosz .... .... .... .... .... .... .... rm:4 &2scalar qd=%qd qn=%qn |
56 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 56 | |
57 | index XXXXXXX..XXXXXXX 100644 | 57 | +@2_shl_b .... .... .. 001 shift:3 .... .... .... .... &2shift qd=%qd qm=%qm size=0 |
58 | --- a/target/arm/translate-a64.c | 58 | +@2_shl_h .... .... .. 01 shift:4 .... .... .... .... &2shift qd=%qd qm=%qm size=1 |
59 | +++ b/target/arm/translate-a64.c | 59 | +@2_shl_w .... .... .. 1 shift:5 .... .... .... .... &2shift qd=%qd qm=%qm size=2 |
60 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | 60 | + |
61 | unallocated_encoding(s); | 61 | # Vector loads and stores |
62 | return; | 62 | |
63 | } | 63 | # Widening loads and narrowing stores: |
64 | + size = MO_32; | 64 | @@ -XXX,XX +XXX,XX @@ VPST 1111 1110 0 . 11 000 1 ... 0 1111 0100 1101 mask=%mask_22_13 |
65 | break; | 65 | # So we have a single decode line and check the cmode/op in the |
66 | case 1: /* BFDOT */ | 66 | # trans function. |
67 | if (is_scalar || !dc_isar_feature(aa64_bf16, s)) { | 67 | Vimm_1r 111 . 1111 1 . 00 0 ... ... 0 .... 0 1 . 1 .... @1imm |
68 | unallocated_encoding(s); | 68 | + |
69 | return; | 69 | +# Shifts by immediate |
70 | } | 70 | + |
71 | + size = MO_32; | 71 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b |
72 | + break; | 72 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h |
73 | + case 3: /* BFMLAL{B,T} */ | 73 | +VSHLI 111 0 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w |
74 | + if (is_scalar || !dc_isar_feature(aa64_bf16, s)) { | 74 | + |
75 | + unallocated_encoding(s); | 75 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b |
76 | + return; | 76 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h |
77 | + } | 77 | +VQSHLI_S 111 0 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w |
78 | + /* can't set is_fp without other incorrect size checks */ | 78 | + |
79 | + size = MO_16; | 79 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_b |
80 | break; | 80 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_h |
81 | default: | 81 | +VQSHLI_U 111 1 1111 1 . ... ... ... 0 0111 0 1 . 1 ... 0 @2_shl_w |
82 | unallocated_encoding(s); | 82 | + |
83 | return; | 83 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_b |
84 | } | 84 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_h |
85 | - size = MO_32; | 85 | +VQSHLUI 111 1 1111 1 . ... ... ... 0 0110 0 1 . 1 ... 0 @2_shl_w |
86 | break; | 86 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
87 | case 0x11: /* FCMLA #0 */ | 87 | index XXXXXXX..XXXXXXX 100644 |
88 | case 0x13: /* FCMLA #90 */ | 88 | --- a/target/arm/mve_helper.c |
89 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn) | 89 | +++ b/target/arm/mve_helper.c |
90 | gen_gvec_op4_ool(s, is_q, rd, rn, rm, rd, index, | 90 | @@ -XXX,XX +XXX,XX @@ DO_2OP_SAT(vqsubsw, 4, int32_t, DO_SQSUB_W) |
91 | gen_helper_gvec_usdot_idx_b); | 91 | WRAP_QRSHL_HELPER(do_sqrshl_bhs, N, M, true, satp) |
92 | return; | 92 | #define DO_UQRSHL_OP(N, M, satp) \ |
93 | + case 3: /* BFMLAL{B,T} */ | 93 | WRAP_QRSHL_HELPER(do_uqrshl_bhs, N, M, true, satp) |
94 | + gen_gvec_op4_fpst(s, 1, rd, rn, rm, rd, 0, (index << 1) | is_q, | 94 | +#define DO_SUQSHL_OP(N, M, satp) \ |
95 | + gen_helper_gvec_bfmlal_idx); | 95 | + WRAP_QRSHL_HELPER(do_suqrshl_bhs, N, M, false, satp) |
96 | + return; | 96 | |
97 | } | 97 | DO_2OP_SAT_S(vqshls, DO_SQSHL_OP) |
98 | g_assert_not_reached(); | 98 | DO_2OP_SAT_U(vqshlu, DO_UQSHL_OP) |
99 | case 0x11: /* FCMLA #0 */ | 99 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvsw, 4, uint32_t) |
100 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | 100 | DO_VADDV(vaddvub, 1, uint8_t) |
101 | index XXXXXXX..XXXXXXX 100644 | 101 | DO_VADDV(vaddvuh, 2, uint16_t) |
102 | --- a/target/arm/translate-neon.c | 102 | DO_VADDV(vaddvuw, 4, uint32_t) |
103 | +++ b/target/arm/translate-neon.c | 103 | + |
104 | @@ -XXX,XX +XXX,XX @@ static bool trans_VFMA_b16(DisasContext *s, arg_VFMA_b16 *a) | 104 | +/* Shifts by immediate */ |
105 | return do_neon_ddda_fpst(s, 7, a->vd, a->vn, a->vm, a->q, FPST_STD, | 105 | +#define DO_2SHIFT(OP, ESIZE, TYPE, FN) \ |
106 | gen_helper_gvec_bfmlal); | 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); | ||
107 | } | 173 | } |
108 | + | 174 | + |
109 | +static bool trans_VFMA_b16_scal(DisasContext *s, arg_VFMA_b16_scal *a) | 175 | +static bool do_2shift(DisasContext *s, arg_2shift *a, MVEGenTwoOpShiftFn fn, |
176 | + bool negateshift) | ||
110 | +{ | 177 | +{ |
111 | + if (!dc_isar_feature(aa32_bf16, s)) { | 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) { | ||
112 | + return false; | 184 | + return false; |
113 | + } | 185 | + } |
114 | + return do_neon_ddda_fpst(s, 6, a->vd, a->vn, a->vm, | 186 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
115 | + (a->index << 1) | a->q, FPST_STD, | 187 | + return true; |
116 | + gen_helper_gvec_bfmlal_idx); | 188 | + } |
117 | +} | 189 | + |
118 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 190 | + /* |
119 | index XXXXXXX..XXXXXXX 100644 | 191 | + * When we handle a right shift insn using a left-shift helper |
120 | --- a/target/arm/translate-sve.c | 192 | + * which permits a negative shift count to indicate a right-shift, |
121 | +++ b/target/arm/translate-sve.c | 193 | + * we must negate the shift count. |
122 | @@ -XXX,XX +XXX,XX @@ static bool trans_BFMLALT_zzzw(DisasContext *s, arg_rrrr_esz *a) | 194 | + */ |
123 | { | 195 | + if (negateshift) { |
124 | return do_BFMLAL_zzzw(s, a, true); | 196 | + shift = -shift; |
125 | } | 197 | + } |
126 | + | 198 | + |
127 | +static bool do_BFMLAL_zzxw(DisasContext *s, arg_rrxr_esz *a, bool sel) | 199 | + qd = mve_qreg_ptr(a->qd); |
128 | +{ | 200 | + qm = mve_qreg_ptr(a->qm); |
129 | + if (!dc_isar_feature(aa64_sve_bf16, s)) { | 201 | + fn(cpu_env, qd, qm, tcg_constant_i32(shift)); |
130 | + return false; | 202 | + tcg_temp_free_ptr(qd); |
131 | + } | 203 | + tcg_temp_free_ptr(qm); |
132 | + if (sve_access_check(s)) { | 204 | + mve_update_eci(s); |
133 | + TCGv_ptr status = fpstatus_ptr(FPST_FPCR); | ||
134 | + unsigned vsz = vec_full_reg_size(s); | ||
135 | + | ||
136 | + tcg_gen_gvec_4_ptr(vec_full_reg_offset(s, a->rd), | ||
137 | + vec_full_reg_offset(s, a->rn), | ||
138 | + vec_full_reg_offset(s, a->rm), | ||
139 | + vec_full_reg_offset(s, a->ra), | ||
140 | + status, vsz, vsz, (a->index << 1) | sel, | ||
141 | + gen_helper_gvec_bfmlal_idx); | ||
142 | + tcg_temp_free_ptr(status); | ||
143 | + } | ||
144 | + return true; | 205 | + return true; |
145 | +} | 206 | +} |
146 | + | 207 | + |
147 | +static bool trans_BFMLALB_zzxw(DisasContext *s, arg_rrxr_esz *a) | 208 | +#define DO_2SHIFT(INSN, FN, NEGATESHIFT) \ |
148 | +{ | 209 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ |
149 | + return do_BFMLAL_zzxw(s, a, false); | 210 | + { \ |
150 | +} | 211 | + static MVEGenTwoOpShiftFn * const fns[] = { \ |
151 | + | 212 | + gen_helper_mve_##FN##b, \ |
152 | +static bool trans_BFMLALT_zzxw(DisasContext *s, arg_rrxr_esz *a) | 213 | + gen_helper_mve_##FN##h, \ |
153 | +{ | 214 | + gen_helper_mve_##FN##w, \ |
154 | + return do_BFMLAL_zzxw(s, a, true); | 215 | + NULL, \ |
155 | +} | 216 | + }; \ |
156 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | 217 | + return do_2shift(s, a, fns[a->size], NEGATESHIFT); \ |
157 | index XXXXXXX..XXXXXXX 100644 | 218 | + } |
158 | --- a/target/arm/vec_helper.c | 219 | + |
159 | +++ b/target/arm/vec_helper.c | 220 | +DO_2SHIFT(VSHLI, vshli_u, false) |
160 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_bfmlal)(void *vd, void *vn, void *vm, void *va, | 221 | +DO_2SHIFT(VQSHLI_S, vqshli_s, false) |
161 | } | 222 | +DO_2SHIFT(VQSHLI_U, vqshli_u, false) |
162 | clear_tail(d, opr_sz, simd_maxsz(desc)); | 223 | +DO_2SHIFT(VQSHLUI, vqshlui_s, false) |
163 | } | ||
164 | + | ||
165 | +void HELPER(gvec_bfmlal_idx)(void *vd, void *vn, void *vm, | ||
166 | + void *va, void *stat, uint32_t desc) | ||
167 | +{ | ||
168 | + intptr_t i, j, opr_sz = simd_oprsz(desc); | ||
169 | + intptr_t sel = extract32(desc, SIMD_DATA_SHIFT, 1); | ||
170 | + intptr_t index = extract32(desc, SIMD_DATA_SHIFT + 1, 3); | ||
171 | + intptr_t elements = opr_sz / 4; | ||
172 | + intptr_t eltspersegment = MIN(16 / 4, elements); | ||
173 | + float32 *d = vd, *a = va; | ||
174 | + bfloat16 *n = vn, *m = vm; | ||
175 | + | ||
176 | + for (i = 0; i < elements; i += eltspersegment) { | ||
177 | + float32 m_idx = m[H2(2 * i + index)] << 16; | ||
178 | + | ||
179 | + for (j = i; j < i + eltspersegment; j++) { | ||
180 | + float32 n_j = n[H2(2 * j + sel)] << 16; | ||
181 | + d[H4(j)] = float32_muladd(n_j, m_idx, a[H4(j)], 0, stat); | ||
182 | + } | ||
183 | + } | ||
184 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
185 | +} | ||
186 | -- | 224 | -- |
187 | 2.20.1 | 225 | 2.20.1 |
188 | 226 | ||
189 | 227 | diff view generated by jsdifflib |
1 | From: Alexander Graf <agraf@csgraf.de> | 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 | Until now, Hypervisor.framework has only been available on x86_64 systems. | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | With Apple Silicon shipping now, it extends its reach to aarch64. To | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | prepare for support for multiple architectures, let's start moving common | 8 | Message-id: 20210628135835.6690-9-peter.maydell@linaro.org |
6 | code out into its own accel directory. | 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 | This patch moves CPU and memory operations over. While at it, make sure | 18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
9 | the code is consumable on non-i386 systems. | ||
10 | |||
11 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
12 | Reviewed-by: Sergio Lopez <slp@redhat.com> | ||
13 | Message-id: 20210519202253.76782-4-agraf@csgraf.de | ||
14 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | include/sysemu/hvf_int.h | 4 + | ||
18 | target/i386/hvf/hvf-i386.h | 2 - | ||
19 | target/i386/hvf/x86hvf.h | 2 - | ||
20 | accel/hvf/hvf-accel-ops.c | 308 ++++++++++++++++++++++++++++++++++++- | ||
21 | target/i386/hvf/hvf.c | 302 ------------------------------------ | ||
22 | 5 files changed, 311 insertions(+), 307 deletions(-) | ||
23 | |||
24 | diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/sysemu/hvf_int.h | 20 | --- a/target/arm/helper-mve.h |
27 | +++ b/include/sysemu/hvf_int.h | 21 | +++ b/target/arm/helper-mve.h |
28 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) |
29 | 23 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) | |
30 | #include <Hypervisor/hv.h> | 24 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) |
31 | 25 | ||
32 | +void hvf_set_phys_mem(MemoryRegionSection *, bool); | 26 | +DEF_HELPER_FLAGS_4(mve_vshli_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
33 | void assert_hvf_ok(hv_return_t ret); | 27 | +DEF_HELPER_FLAGS_4(mve_vshli_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
34 | +hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); | 28 | +DEF_HELPER_FLAGS_4(mve_vshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
35 | +int hvf_put_registers(CPUState *); | 29 | + |
36 | +int hvf_get_registers(CPUState *); | 30 | DEF_HELPER_FLAGS_4(mve_vshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
37 | 31 | DEF_HELPER_FLAGS_4(mve_vshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
38 | #endif | 32 | DEF_HELPER_FLAGS_4(mve_vshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
39 | diff --git a/target/i386/hvf/hvf-i386.h b/target/i386/hvf/hvf-i386.h | 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 | ||
40 | index XXXXXXX..XXXXXXX 100644 | 46 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/i386/hvf/hvf-i386.h | 47 | --- a/target/arm/translate.h |
42 | +++ b/target/i386/hvf/hvf-i386.h | 48 | +++ b/target/arm/translate.h |
43 | @@ -XXX,XX +XXX,XX @@ struct HVFState { | 49 | @@ -XXX,XX +XXX,XX @@ static inline int times_2_plus_1(DisasContext *s, int x) |
44 | }; | 50 | return x * 2 + 1; |
45 | extern HVFState *hvf_state; | 51 | } |
46 | 52 | ||
47 | -void hvf_set_phys_mem(MemoryRegionSection *, bool); | 53 | +static inline int rsub_64(DisasContext *s, int x) |
48 | void hvf_handle_io(CPUArchState *, uint16_t, void *, int, int, int); | ||
49 | -hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); | ||
50 | |||
51 | #ifdef NEED_CPU_H | ||
52 | /* Functions exported to host specific mode */ | ||
53 | diff --git a/target/i386/hvf/x86hvf.h b/target/i386/hvf/x86hvf.h | ||
54 | index XXXXXXX..XXXXXXX 100644 | ||
55 | --- a/target/i386/hvf/x86hvf.h | ||
56 | +++ b/target/i386/hvf/x86hvf.h | ||
57 | @@ -XXX,XX +XXX,XX @@ | ||
58 | #include "x86_descr.h" | ||
59 | |||
60 | int hvf_process_events(CPUState *); | ||
61 | -int hvf_put_registers(CPUState *); | ||
62 | -int hvf_get_registers(CPUState *); | ||
63 | bool hvf_inject_interrupts(CPUState *); | ||
64 | void hvf_set_segment(struct CPUState *cpu, struct vmx_segment *vmx_seg, | ||
65 | SegmentCache *qseg, bool is_tr); | ||
66 | diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/accel/hvf/hvf-accel-ops.c | ||
69 | +++ b/accel/hvf/hvf-accel-ops.c | ||
70 | @@ -XXX,XX +XXX,XX @@ | ||
71 | #include "qemu/osdep.h" | ||
72 | #include "qemu/error-report.h" | ||
73 | #include "qemu/main-loop.h" | ||
74 | +#include "exec/address-spaces.h" | ||
75 | +#include "exec/exec-all.h" | ||
76 | +#include "sysemu/cpus.h" | ||
77 | #include "sysemu/hvf.h" | ||
78 | +#include "sysemu/hvf_int.h" | ||
79 | #include "sysemu/runstate.h" | ||
80 | -#include "target/i386/cpu.h" | ||
81 | #include "qemu/guest-random.h" | ||
82 | |||
83 | #include "hvf-accel-ops.h" | ||
84 | |||
85 | +HVFState *hvf_state; | ||
86 | + | ||
87 | +/* Memory slots */ | ||
88 | + | ||
89 | +hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t size) | ||
90 | +{ | 54 | +{ |
91 | + hvf_slot *slot; | 55 | + return 64 - x; |
92 | + int x; | ||
93 | + for (x = 0; x < hvf_state->num_slots; ++x) { | ||
94 | + slot = &hvf_state->slots[x]; | ||
95 | + if (slot->size && start < (slot->start + slot->size) && | ||
96 | + (start + size) > slot->start) { | ||
97 | + return slot; | ||
98 | + } | ||
99 | + } | ||
100 | + return NULL; | ||
101 | +} | 56 | +} |
102 | + | 57 | + |
103 | +struct mac_slot { | 58 | +static inline int rsub_32(DisasContext *s, int x) |
104 | + int present; | ||
105 | + uint64_t size; | ||
106 | + uint64_t gpa_start; | ||
107 | + uint64_t gva; | ||
108 | +}; | ||
109 | + | ||
110 | +struct mac_slot mac_slots[32]; | ||
111 | + | ||
112 | +static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags) | ||
113 | +{ | 59 | +{ |
114 | + struct mac_slot *macslot; | 60 | + return 32 - x; |
115 | + hv_return_t ret; | ||
116 | + | ||
117 | + macslot = &mac_slots[slot->slot_id]; | ||
118 | + | ||
119 | + if (macslot->present) { | ||
120 | + if (macslot->size != slot->size) { | ||
121 | + macslot->present = 0; | ||
122 | + ret = hv_vm_unmap(macslot->gpa_start, macslot->size); | ||
123 | + assert_hvf_ok(ret); | ||
124 | + } | ||
125 | + } | ||
126 | + | ||
127 | + if (!slot->size) { | ||
128 | + return 0; | ||
129 | + } | ||
130 | + | ||
131 | + macslot->present = 1; | ||
132 | + macslot->gpa_start = slot->start; | ||
133 | + macslot->size = slot->size; | ||
134 | + ret = hv_vm_map((hv_uvaddr_t)slot->mem, slot->start, slot->size, flags); | ||
135 | + assert_hvf_ok(ret); | ||
136 | + return 0; | ||
137 | +} | 61 | +} |
138 | + | 62 | + |
139 | +void hvf_set_phys_mem(MemoryRegionSection *section, bool add) | 63 | +static inline int rsub_16(DisasContext *s, int x) |
140 | +{ | 64 | +{ |
141 | + hvf_slot *mem; | 65 | + return 16 - x; |
142 | + MemoryRegion *area = section->mr; | ||
143 | + bool writeable = !area->readonly && !area->rom_device; | ||
144 | + hv_memory_flags_t flags; | ||
145 | + | ||
146 | + if (!memory_region_is_ram(area)) { | ||
147 | + if (writeable) { | ||
148 | + return; | ||
149 | + } else if (!memory_region_is_romd(area)) { | ||
150 | + /* | ||
151 | + * If the memory device is not in romd_mode, then we actually want | ||
152 | + * to remove the hvf memory slot so all accesses will trap. | ||
153 | + */ | ||
154 | + add = false; | ||
155 | + } | ||
156 | + } | ||
157 | + | ||
158 | + mem = hvf_find_overlap_slot( | ||
159 | + section->offset_within_address_space, | ||
160 | + int128_get64(section->size)); | ||
161 | + | ||
162 | + if (mem && add) { | ||
163 | + if (mem->size == int128_get64(section->size) && | ||
164 | + mem->start == section->offset_within_address_space && | ||
165 | + mem->mem == (memory_region_get_ram_ptr(area) + | ||
166 | + section->offset_within_region)) { | ||
167 | + return; /* Same region was attempted to register, go away. */ | ||
168 | + } | ||
169 | + } | ||
170 | + | ||
171 | + /* Region needs to be reset. set the size to 0 and remap it. */ | ||
172 | + if (mem) { | ||
173 | + mem->size = 0; | ||
174 | + if (do_hvf_set_memory(mem, 0)) { | ||
175 | + error_report("Failed to reset overlapping slot"); | ||
176 | + abort(); | ||
177 | + } | ||
178 | + } | ||
179 | + | ||
180 | + if (!add) { | ||
181 | + return; | ||
182 | + } | ||
183 | + | ||
184 | + if (area->readonly || | ||
185 | + (!memory_region_is_ram(area) && memory_region_is_romd(area))) { | ||
186 | + flags = HV_MEMORY_READ | HV_MEMORY_EXEC; | ||
187 | + } else { | ||
188 | + flags = HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC; | ||
189 | + } | ||
190 | + | ||
191 | + /* Now make a new slot. */ | ||
192 | + int x; | ||
193 | + | ||
194 | + for (x = 0; x < hvf_state->num_slots; ++x) { | ||
195 | + mem = &hvf_state->slots[x]; | ||
196 | + if (!mem->size) { | ||
197 | + break; | ||
198 | + } | ||
199 | + } | ||
200 | + | ||
201 | + if (x == hvf_state->num_slots) { | ||
202 | + error_report("No free slots"); | ||
203 | + abort(); | ||
204 | + } | ||
205 | + | ||
206 | + mem->size = int128_get64(section->size); | ||
207 | + mem->mem = memory_region_get_ram_ptr(area) + section->offset_within_region; | ||
208 | + mem->start = section->offset_within_address_space; | ||
209 | + mem->region = area; | ||
210 | + | ||
211 | + if (do_hvf_set_memory(mem, flags)) { | ||
212 | + error_report("Error registering new memory slot"); | ||
213 | + abort(); | ||
214 | + } | ||
215 | +} | 66 | +} |
216 | + | 67 | + |
217 | +static void do_hvf_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg) | 68 | +static inline int rsub_8(DisasContext *s, int x) |
218 | +{ | 69 | +{ |
219 | + if (!cpu->vcpu_dirty) { | 70 | + return 8 - x; |
220 | + hvf_get_registers(cpu); | ||
221 | + cpu->vcpu_dirty = true; | ||
222 | + } | ||
223 | +} | 71 | +} |
224 | + | 72 | + |
225 | +void hvf_cpu_synchronize_state(CPUState *cpu) | 73 | static inline int arm_dc_feature(DisasContext *dc, int feature) |
226 | +{ | 74 | { |
227 | + if (!cpu->vcpu_dirty) { | 75 | return (dc->features & (1ULL << feature)) != 0; |
228 | + run_on_cpu(cpu, do_hvf_cpu_synchronize_state, RUN_ON_CPU_NULL); | 76 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
229 | + } | 77 | index XXXXXXX..XXXXXXX 100644 |
230 | +} | 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 | ||
231 | + | 88 | + |
232 | +static void do_hvf_cpu_synchronize_post_reset(CPUState *cpu, | 89 | +@2_shr_b .... .... .. 001 ... .... .... .... .... &2shift qd=%qd qm=%qm \ |
233 | + run_on_cpu_data arg) | 90 | + size=0 shift=%rshift_i3 |
234 | +{ | 91 | +@2_shr_h .... .... .. 01 .... .... .... .... .... &2shift qd=%qd qm=%qm \ |
235 | + hvf_put_registers(cpu); | 92 | + size=1 shift=%rshift_i4 |
236 | + cpu->vcpu_dirty = false; | 93 | +@2_shr_w .... .... .. 1 ..... .... .... .... .... &2shift qd=%qd qm=%qm \ |
237 | +} | 94 | + size=2 shift=%rshift_i5 |
238 | + | 95 | + |
239 | +void hvf_cpu_synchronize_post_reset(CPUState *cpu) | 96 | # Vector loads and stores |
240 | +{ | 97 | |
241 | + run_on_cpu(cpu, do_hvf_cpu_synchronize_post_reset, RUN_ON_CPU_NULL); | 98 | # Widening loads and narrowing stores: |
242 | +} | 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 | ||
243 | + | 103 | + |
244 | +static void do_hvf_cpu_synchronize_post_init(CPUState *cpu, | 104 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b |
245 | + run_on_cpu_data arg) | 105 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h |
246 | +{ | 106 | +VSHRI_S 111 0 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w |
247 | + hvf_put_registers(cpu); | ||
248 | + cpu->vcpu_dirty = false; | ||
249 | +} | ||
250 | + | 107 | + |
251 | +void hvf_cpu_synchronize_post_init(CPUState *cpu) | 108 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_b |
252 | +{ | 109 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_h |
253 | + run_on_cpu(cpu, do_hvf_cpu_synchronize_post_init, RUN_ON_CPU_NULL); | 110 | +VSHRI_U 111 1 1111 1 . ... ... ... 0 0000 0 1 . 1 ... 0 @2_shr_w |
254 | +} | ||
255 | + | 111 | + |
256 | +static void do_hvf_cpu_synchronize_pre_loadvm(CPUState *cpu, | 112 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b |
257 | + run_on_cpu_data arg) | 113 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h |
258 | +{ | 114 | +VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w |
259 | + cpu->vcpu_dirty = true; | ||
260 | +} | ||
261 | + | 115 | + |
262 | +void hvf_cpu_synchronize_pre_loadvm(CPUState *cpu) | 116 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_b |
263 | +{ | 117 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_h |
264 | + run_on_cpu(cpu, do_hvf_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL); | 118 | +VRSHRI_U 111 1 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w |
265 | +} | 119 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
266 | + | ||
267 | +static void hvf_set_dirty_tracking(MemoryRegionSection *section, bool on) | ||
268 | +{ | ||
269 | + hvf_slot *slot; | ||
270 | + | ||
271 | + slot = hvf_find_overlap_slot( | ||
272 | + section->offset_within_address_space, | ||
273 | + int128_get64(section->size)); | ||
274 | + | ||
275 | + /* protect region against writes; begin tracking it */ | ||
276 | + if (on) { | ||
277 | + slot->flags |= HVF_SLOT_LOG; | ||
278 | + hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size, | ||
279 | + HV_MEMORY_READ); | ||
280 | + /* stop tracking region*/ | ||
281 | + } else { | ||
282 | + slot->flags &= ~HVF_SLOT_LOG; | ||
283 | + hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size, | ||
284 | + HV_MEMORY_READ | HV_MEMORY_WRITE); | ||
285 | + } | ||
286 | +} | ||
287 | + | ||
288 | +static void hvf_log_start(MemoryListener *listener, | ||
289 | + MemoryRegionSection *section, int old, int new) | ||
290 | +{ | ||
291 | + if (old != 0) { | ||
292 | + return; | ||
293 | + } | ||
294 | + | ||
295 | + hvf_set_dirty_tracking(section, 1); | ||
296 | +} | ||
297 | + | ||
298 | +static void hvf_log_stop(MemoryListener *listener, | ||
299 | + MemoryRegionSection *section, int old, int new) | ||
300 | +{ | ||
301 | + if (new != 0) { | ||
302 | + return; | ||
303 | + } | ||
304 | + | ||
305 | + hvf_set_dirty_tracking(section, 0); | ||
306 | +} | ||
307 | + | ||
308 | +static void hvf_log_sync(MemoryListener *listener, | ||
309 | + MemoryRegionSection *section) | ||
310 | +{ | ||
311 | + /* | ||
312 | + * sync of dirty pages is handled elsewhere; just make sure we keep | ||
313 | + * tracking the region. | ||
314 | + */ | ||
315 | + hvf_set_dirty_tracking(section, 1); | ||
316 | +} | ||
317 | + | ||
318 | +static void hvf_region_add(MemoryListener *listener, | ||
319 | + MemoryRegionSection *section) | ||
320 | +{ | ||
321 | + hvf_set_phys_mem(section, true); | ||
322 | +} | ||
323 | + | ||
324 | +static void hvf_region_del(MemoryListener *listener, | ||
325 | + MemoryRegionSection *section) | ||
326 | +{ | ||
327 | + hvf_set_phys_mem(section, false); | ||
328 | +} | ||
329 | + | ||
330 | +static MemoryListener hvf_memory_listener = { | ||
331 | + .priority = 10, | ||
332 | + .region_add = hvf_region_add, | ||
333 | + .region_del = hvf_region_del, | ||
334 | + .log_start = hvf_log_start, | ||
335 | + .log_stop = hvf_log_stop, | ||
336 | + .log_sync = hvf_log_sync, | ||
337 | +}; | ||
338 | + | ||
339 | +static void dummy_signal(int sig) | ||
340 | +{ | ||
341 | +} | ||
342 | + | ||
343 | +bool hvf_allowed; | ||
344 | + | ||
345 | +static int hvf_accel_init(MachineState *ms) | ||
346 | +{ | ||
347 | + int x; | ||
348 | + hv_return_t ret; | ||
349 | + HVFState *s; | ||
350 | + | ||
351 | + ret = hv_vm_create(HV_VM_DEFAULT); | ||
352 | + assert_hvf_ok(ret); | ||
353 | + | ||
354 | + s = g_new0(HVFState, 1); | ||
355 | + | ||
356 | + s->num_slots = 32; | ||
357 | + for (x = 0; x < s->num_slots; ++x) { | ||
358 | + s->slots[x].size = 0; | ||
359 | + s->slots[x].slot_id = x; | ||
360 | + } | ||
361 | + | ||
362 | + hvf_state = s; | ||
363 | + memory_listener_register(&hvf_memory_listener, &address_space_memory); | ||
364 | + return 0; | ||
365 | +} | ||
366 | + | ||
367 | +static void hvf_accel_class_init(ObjectClass *oc, void *data) | ||
368 | +{ | ||
369 | + AccelClass *ac = ACCEL_CLASS(oc); | ||
370 | + ac->name = "HVF"; | ||
371 | + ac->init_machine = hvf_accel_init; | ||
372 | + ac->allowed = &hvf_allowed; | ||
373 | +} | ||
374 | + | ||
375 | +static const TypeInfo hvf_accel_type = { | ||
376 | + .name = TYPE_HVF_ACCEL, | ||
377 | + .parent = TYPE_ACCEL, | ||
378 | + .class_init = hvf_accel_class_init, | ||
379 | +}; | ||
380 | + | ||
381 | +static void hvf_type_init(void) | ||
382 | +{ | ||
383 | + type_register_static(&hvf_accel_type); | ||
384 | +} | ||
385 | + | ||
386 | +type_init(hvf_type_init); | ||
387 | + | ||
388 | /* | ||
389 | * The HVF-specific vCPU thread function. This one should only run when the host | ||
390 | * CPU supports the VMX "unrestricted guest" feature. | ||
391 | diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c | ||
392 | index XXXXXXX..XXXXXXX 100644 | 120 | index XXXXXXX..XXXXXXX 100644 |
393 | --- a/target/i386/hvf/hvf.c | 121 | --- a/target/arm/mve_helper.c |
394 | +++ b/target/i386/hvf/hvf.c | 122 | +++ b/target/arm/mve_helper.c |
395 | @@ -XXX,XX +XXX,XX @@ | 123 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvuw, 4, uint32_t) |
396 | 124 | DO_2SHIFT(OP##b, 1, uint8_t, FN) \ | |
397 | #include "hvf-accel-ops.h" | 125 | DO_2SHIFT(OP##h, 2, uint16_t, FN) \ |
398 | 126 | DO_2SHIFT(OP##w, 4, uint32_t, FN) | |
399 | -HVFState *hvf_state; | 127 | +#define DO_2SHIFT_S(OP, FN) \ |
400 | - | 128 | + DO_2SHIFT(OP##b, 1, int8_t, FN) \ |
401 | -/* Memory slots */ | 129 | + DO_2SHIFT(OP##h, 2, int16_t, FN) \ |
402 | -hvf_slot *hvf_find_overlap_slot(uint64_t start, uint64_t size) | 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; | ||
163 | } | ||
164 | |||
165 | -static inline int rsub_64(DisasContext *s, int x) | ||
403 | -{ | 166 | -{ |
404 | - hvf_slot *slot; | 167 | - return 64 - x; |
405 | - int x; | ||
406 | - for (x = 0; x < hvf_state->num_slots; ++x) { | ||
407 | - slot = &hvf_state->slots[x]; | ||
408 | - if (slot->size && start < (slot->start + slot->size) && | ||
409 | - (start + size) > slot->start) { | ||
410 | - return slot; | ||
411 | - } | ||
412 | - } | ||
413 | - return NULL; | ||
414 | -} | 168 | -} |
415 | - | 169 | - |
416 | -struct mac_slot { | 170 | -static inline int rsub_32(DisasContext *s, int x) |
417 | - int present; | ||
418 | - uint64_t size; | ||
419 | - uint64_t gpa_start; | ||
420 | - uint64_t gva; | ||
421 | -}; | ||
422 | - | ||
423 | -struct mac_slot mac_slots[32]; | ||
424 | - | ||
425 | -static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags) | ||
426 | -{ | 171 | -{ |
427 | - struct mac_slot *macslot; | 172 | - return 32 - x; |
428 | - hv_return_t ret; | 173 | -} |
429 | - | 174 | -static inline int rsub_16(DisasContext *s, int x) |
430 | - macslot = &mac_slots[slot->slot_id]; | 175 | -{ |
431 | - | 176 | - return 16 - x; |
432 | - if (macslot->present) { | 177 | -} |
433 | - if (macslot->size != slot->size) { | 178 | -static inline int rsub_8(DisasContext *s, int x) |
434 | - macslot->present = 0; | 179 | -{ |
435 | - ret = hv_vm_unmap(macslot->gpa_start, macslot->size); | 180 | - return 8 - x; |
436 | - assert_hvf_ok(ret); | ||
437 | - } | ||
438 | - } | ||
439 | - | ||
440 | - if (!slot->size) { | ||
441 | - return 0; | ||
442 | - } | ||
443 | - | ||
444 | - macslot->present = 1; | ||
445 | - macslot->gpa_start = slot->start; | ||
446 | - macslot->size = slot->size; | ||
447 | - ret = hv_vm_map((hv_uvaddr_t)slot->mem, slot->start, slot->size, flags); | ||
448 | - assert_hvf_ok(ret); | ||
449 | - return 0; | ||
450 | -} | 181 | -} |
451 | - | 182 | - |
452 | -void hvf_set_phys_mem(MemoryRegionSection *section, bool add) | 183 | static inline int neon_3same_fp_size(DisasContext *s, int x) |
453 | -{ | ||
454 | - hvf_slot *mem; | ||
455 | - MemoryRegion *area = section->mr; | ||
456 | - bool writeable = !area->readonly && !area->rom_device; | ||
457 | - hv_memory_flags_t flags; | ||
458 | - | ||
459 | - if (!memory_region_is_ram(area)) { | ||
460 | - if (writeable) { | ||
461 | - return; | ||
462 | - } else if (!memory_region_is_romd(area)) { | ||
463 | - /* | ||
464 | - * If the memory device is not in romd_mode, then we actually want | ||
465 | - * to remove the hvf memory slot so all accesses will trap. | ||
466 | - */ | ||
467 | - add = false; | ||
468 | - } | ||
469 | - } | ||
470 | - | ||
471 | - mem = hvf_find_overlap_slot( | ||
472 | - section->offset_within_address_space, | ||
473 | - int128_get64(section->size)); | ||
474 | - | ||
475 | - if (mem && add) { | ||
476 | - if (mem->size == int128_get64(section->size) && | ||
477 | - mem->start == section->offset_within_address_space && | ||
478 | - mem->mem == (memory_region_get_ram_ptr(area) + | ||
479 | - section->offset_within_region)) { | ||
480 | - return; /* Same region was attempted to register, go away. */ | ||
481 | - } | ||
482 | - } | ||
483 | - | ||
484 | - /* Region needs to be reset. set the size to 0 and remap it. */ | ||
485 | - if (mem) { | ||
486 | - mem->size = 0; | ||
487 | - if (do_hvf_set_memory(mem, 0)) { | ||
488 | - error_report("Failed to reset overlapping slot"); | ||
489 | - abort(); | ||
490 | - } | ||
491 | - } | ||
492 | - | ||
493 | - if (!add) { | ||
494 | - return; | ||
495 | - } | ||
496 | - | ||
497 | - if (area->readonly || | ||
498 | - (!memory_region_is_ram(area) && memory_region_is_romd(area))) { | ||
499 | - flags = HV_MEMORY_READ | HV_MEMORY_EXEC; | ||
500 | - } else { | ||
501 | - flags = HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC; | ||
502 | - } | ||
503 | - | ||
504 | - /* Now make a new slot. */ | ||
505 | - int x; | ||
506 | - | ||
507 | - for (x = 0; x < hvf_state->num_slots; ++x) { | ||
508 | - mem = &hvf_state->slots[x]; | ||
509 | - if (!mem->size) { | ||
510 | - break; | ||
511 | - } | ||
512 | - } | ||
513 | - | ||
514 | - if (x == hvf_state->num_slots) { | ||
515 | - error_report("No free slots"); | ||
516 | - abort(); | ||
517 | - } | ||
518 | - | ||
519 | - mem->size = int128_get64(section->size); | ||
520 | - mem->mem = memory_region_get_ram_ptr(area) + section->offset_within_region; | ||
521 | - mem->start = section->offset_within_address_space; | ||
522 | - mem->region = area; | ||
523 | - | ||
524 | - if (do_hvf_set_memory(mem, flags)) { | ||
525 | - error_report("Error registering new memory slot"); | ||
526 | - abort(); | ||
527 | - } | ||
528 | -} | ||
529 | - | ||
530 | void vmx_update_tpr(CPUState *cpu) | ||
531 | { | 184 | { |
532 | /* TODO: need integrate APIC handling */ | 185 | /* Convert 0==fp32, 1==fp16 into a MO_* value */ |
533 | @@ -XXX,XX +XXX,XX @@ void hvf_handle_io(CPUArchState *env, uint16_t port, void *buffer, | ||
534 | } | ||
535 | } | ||
536 | |||
537 | -static void do_hvf_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg) | ||
538 | -{ | ||
539 | - if (!cpu->vcpu_dirty) { | ||
540 | - hvf_get_registers(cpu); | ||
541 | - cpu->vcpu_dirty = true; | ||
542 | - } | ||
543 | -} | ||
544 | - | ||
545 | -void hvf_cpu_synchronize_state(CPUState *cpu) | ||
546 | -{ | ||
547 | - if (!cpu->vcpu_dirty) { | ||
548 | - run_on_cpu(cpu, do_hvf_cpu_synchronize_state, RUN_ON_CPU_NULL); | ||
549 | - } | ||
550 | -} | ||
551 | - | ||
552 | -static void do_hvf_cpu_synchronize_post_reset(CPUState *cpu, | ||
553 | - run_on_cpu_data arg) | ||
554 | -{ | ||
555 | - hvf_put_registers(cpu); | ||
556 | - cpu->vcpu_dirty = false; | ||
557 | -} | ||
558 | - | ||
559 | -void hvf_cpu_synchronize_post_reset(CPUState *cpu) | ||
560 | -{ | ||
561 | - run_on_cpu(cpu, do_hvf_cpu_synchronize_post_reset, RUN_ON_CPU_NULL); | ||
562 | -} | ||
563 | - | ||
564 | -static void do_hvf_cpu_synchronize_post_init(CPUState *cpu, | ||
565 | - run_on_cpu_data arg) | ||
566 | -{ | ||
567 | - hvf_put_registers(cpu); | ||
568 | - cpu->vcpu_dirty = false; | ||
569 | -} | ||
570 | - | ||
571 | -void hvf_cpu_synchronize_post_init(CPUState *cpu) | ||
572 | -{ | ||
573 | - run_on_cpu(cpu, do_hvf_cpu_synchronize_post_init, RUN_ON_CPU_NULL); | ||
574 | -} | ||
575 | - | ||
576 | -static void do_hvf_cpu_synchronize_pre_loadvm(CPUState *cpu, | ||
577 | - run_on_cpu_data arg) | ||
578 | -{ | ||
579 | - cpu->vcpu_dirty = true; | ||
580 | -} | ||
581 | - | ||
582 | -void hvf_cpu_synchronize_pre_loadvm(CPUState *cpu) | ||
583 | -{ | ||
584 | - run_on_cpu(cpu, do_hvf_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL); | ||
585 | -} | ||
586 | - | ||
587 | static bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, uint64_t ept_qual) | ||
588 | { | ||
589 | int read, write; | ||
590 | @@ -XXX,XX +XXX,XX @@ static bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, uint64_t ept_qual) | ||
591 | return false; | ||
592 | } | ||
593 | |||
594 | -static void hvf_set_dirty_tracking(MemoryRegionSection *section, bool on) | ||
595 | -{ | ||
596 | - hvf_slot *slot; | ||
597 | - | ||
598 | - slot = hvf_find_overlap_slot( | ||
599 | - section->offset_within_address_space, | ||
600 | - int128_get64(section->size)); | ||
601 | - | ||
602 | - /* protect region against writes; begin tracking it */ | ||
603 | - if (on) { | ||
604 | - slot->flags |= HVF_SLOT_LOG; | ||
605 | - hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size, | ||
606 | - HV_MEMORY_READ); | ||
607 | - /* stop tracking region*/ | ||
608 | - } else { | ||
609 | - slot->flags &= ~HVF_SLOT_LOG; | ||
610 | - hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size, | ||
611 | - HV_MEMORY_READ | HV_MEMORY_WRITE); | ||
612 | - } | ||
613 | -} | ||
614 | - | ||
615 | -static void hvf_log_start(MemoryListener *listener, | ||
616 | - MemoryRegionSection *section, int old, int new) | ||
617 | -{ | ||
618 | - if (old != 0) { | ||
619 | - return; | ||
620 | - } | ||
621 | - | ||
622 | - hvf_set_dirty_tracking(section, 1); | ||
623 | -} | ||
624 | - | ||
625 | -static void hvf_log_stop(MemoryListener *listener, | ||
626 | - MemoryRegionSection *section, int old, int new) | ||
627 | -{ | ||
628 | - if (new != 0) { | ||
629 | - return; | ||
630 | - } | ||
631 | - | ||
632 | - hvf_set_dirty_tracking(section, 0); | ||
633 | -} | ||
634 | - | ||
635 | -static void hvf_log_sync(MemoryListener *listener, | ||
636 | - MemoryRegionSection *section) | ||
637 | -{ | ||
638 | - /* | ||
639 | - * sync of dirty pages is handled elsewhere; just make sure we keep | ||
640 | - * tracking the region. | ||
641 | - */ | ||
642 | - hvf_set_dirty_tracking(section, 1); | ||
643 | -} | ||
644 | - | ||
645 | -static void hvf_region_add(MemoryListener *listener, | ||
646 | - MemoryRegionSection *section) | ||
647 | -{ | ||
648 | - hvf_set_phys_mem(section, true); | ||
649 | -} | ||
650 | - | ||
651 | -static void hvf_region_del(MemoryListener *listener, | ||
652 | - MemoryRegionSection *section) | ||
653 | -{ | ||
654 | - hvf_set_phys_mem(section, false); | ||
655 | -} | ||
656 | - | ||
657 | -static MemoryListener hvf_memory_listener = { | ||
658 | - .priority = 10, | ||
659 | - .region_add = hvf_region_add, | ||
660 | - .region_del = hvf_region_del, | ||
661 | - .log_start = hvf_log_start, | ||
662 | - .log_stop = hvf_log_stop, | ||
663 | - .log_sync = hvf_log_sync, | ||
664 | -}; | ||
665 | - | ||
666 | void hvf_vcpu_destroy(CPUState *cpu) | ||
667 | { | ||
668 | X86CPU *x86_cpu = X86_CPU(cpu); | ||
669 | @@ -XXX,XX +XXX,XX @@ void hvf_vcpu_destroy(CPUState *cpu) | ||
670 | assert_hvf_ok(ret); | ||
671 | } | ||
672 | |||
673 | -static void dummy_signal(int sig) | ||
674 | -{ | ||
675 | -} | ||
676 | - | ||
677 | static void init_tsc_freq(CPUX86State *env) | ||
678 | { | ||
679 | size_t length; | ||
680 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) | ||
681 | |||
682 | return ret; | ||
683 | } | ||
684 | - | ||
685 | -bool hvf_allowed; | ||
686 | - | ||
687 | -static int hvf_accel_init(MachineState *ms) | ||
688 | -{ | ||
689 | - int x; | ||
690 | - hv_return_t ret; | ||
691 | - HVFState *s; | ||
692 | - | ||
693 | - ret = hv_vm_create(HV_VM_DEFAULT); | ||
694 | - assert_hvf_ok(ret); | ||
695 | - | ||
696 | - s = g_new0(HVFState, 1); | ||
697 | - | ||
698 | - s->num_slots = 32; | ||
699 | - for (x = 0; x < s->num_slots; ++x) { | ||
700 | - s->slots[x].size = 0; | ||
701 | - s->slots[x].slot_id = x; | ||
702 | - } | ||
703 | - | ||
704 | - hvf_state = s; | ||
705 | - memory_listener_register(&hvf_memory_listener, &address_space_memory); | ||
706 | - return 0; | ||
707 | -} | ||
708 | - | ||
709 | -static void hvf_accel_class_init(ObjectClass *oc, void *data) | ||
710 | -{ | ||
711 | - AccelClass *ac = ACCEL_CLASS(oc); | ||
712 | - ac->name = "HVF"; | ||
713 | - ac->init_machine = hvf_accel_init; | ||
714 | - ac->allowed = &hvf_allowed; | ||
715 | -} | ||
716 | - | ||
717 | -static const TypeInfo hvf_accel_type = { | ||
718 | - .name = TYPE_HVF_ACCEL, | ||
719 | - .parent = TYPE_ACCEL, | ||
720 | - .class_init = hvf_accel_class_init, | ||
721 | -}; | ||
722 | - | ||
723 | -static void hvf_type_init(void) | ||
724 | -{ | ||
725 | - type_register_static(&hvf_accel_type); | ||
726 | -} | ||
727 | - | ||
728 | -type_init(hvf_type_init); | ||
729 | -- | 186 | -- |
730 | 2.20.1 | 187 | 2.20.1 |
731 | 188 | ||
732 | 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 | Note that the SVE BFLOAT16 support does not require SVE2, | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | it is an independent extension. | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20210628135835.6690-10-peter.maydell@linaro.org | ||
9 | --- | ||
10 | target/arm/helper-mve.h | 9 +++++++ | ||
11 | target/arm/mve.decode | 53 +++++++++++++++++++++++++++++++++++--- | ||
12 | target/arm/mve_helper.c | 32 +++++++++++++++++++++++ | ||
13 | target/arm/translate-mve.c | 15 +++++++++++ | ||
14 | 4 files changed, 105 insertions(+), 4 deletions(-) | ||
5 | 15 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210525225817.400336-2-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/cpu.h | 15 +++++++++++++++ | ||
12 | 1 file changed, 15 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.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 @@ static inline bool isar_feature_aa32_predinv(const ARMISARegisters *id) | 20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshli_sw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
19 | return FIELD_EX32(id->id_isar6, ID_ISAR6, SPECRES) != 0; | 21 | DEF_HELPER_FLAGS_4(mve_vrshli_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
20 | } | 22 | DEF_HELPER_FLAGS_4(mve_vrshli_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | 23 | DEF_HELPER_FLAGS_4(mve_vrshli_uw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
22 | +static inline bool isar_feature_aa32_bf16(const ARMISARegisters *id) | 24 | + |
25 | +DEF_HELPER_FLAGS_4(mve_vshllbsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vshllbsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vshllbub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vshllbuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | +DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
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 | ||
23 | +{ | 60 | +{ |
24 | + return FIELD_EX32(id->id_isar6, ID_ISAR6, BF16) != 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 | ||
25 | +} | 67 | +} |
26 | + | 68 | + |
27 | static inline bool isar_feature_aa32_i8mm(const ARMISARegisters *id) | ||
28 | { | ||
29 | return FIELD_EX32(id->id_isar6, ID_ISAR6, I8MM) != 0; | ||
30 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_dcpodp(const ARMISARegisters *id) | ||
31 | return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, DPB) >= 2; | ||
32 | } | ||
33 | |||
34 | +static inline bool isar_feature_aa64_bf16(const ARMISARegisters *id) | ||
35 | +{ | 69 | +{ |
36 | + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, BF16) != 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 | ||
37 | +} | 74 | +} |
38 | + | 75 | + |
39 | static inline bool isar_feature_aa64_fp_simd(const ARMISARegisters *id) | ||
40 | { | ||
41 | /* We always set the AdvSIMD and FP fields identically. */ | ||
42 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_sve2_bitperm(const ARMISARegisters *id) | ||
43 | return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, BITPERM) != 0; | ||
44 | } | ||
45 | |||
46 | +static inline bool isar_feature_aa64_sve_bf16(const ARMISARegisters *id) | ||
47 | +{ | 76 | +{ |
48 | + return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, BFLOAT16) != 0; | 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 | ||
79 | + | ||
80 | + VRMULH_S 111 0 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
49 | +} | 81 | +} |
50 | + | 82 | + |
51 | static inline bool isar_feature_aa64_sve2_sha3(const ARMISARegisters *id) | 83 | +{ |
52 | { | 84 | + VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_b |
53 | return FIELD_EX64(id->id_aa64zfr0, ID_AA64ZFR0, SHA3) != 0; | 85 | + VSHLL_TU 111 1 1110 0 . 11 .. 01 ... 1 1110 0 0 . 0 ... 1 @2_shll_esize_h |
86 | + | ||
87 | + VRMULH_U 111 1 1110 0 . .. ...1 ... 1 1110 . 0 . 0 ... 1 @2op | ||
88 | +} | ||
89 | |||
90 | VMAX_S 111 0 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op | ||
91 | VMAX_U 111 1 1111 0 . .. ... 0 ... 0 0110 . 1 . 0 ... 0 @2op | ||
92 | @@ -XXX,XX +XXX,XX @@ VRSHRI_S 111 0 1111 1 . ... ... ... 0 0010 0 1 . 1 ... 0 @2_shr_w | ||
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 | ||
96 | + | ||
97 | +# VSHLL T1 encoding; the T2 VSHLL encoding is elsewhere in this file | ||
98 | +VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | ||
99 | +VSHLL_BS 111 0 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | ||
100 | + | ||
101 | +VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_b | ||
102 | +VSHLL_BU 111 1 1110 1 . 1 .. ... ... 0 1111 0 1 . 0 ... 0 @2_shll_h | ||
103 | + | ||
104 | +VSHLL_TS 111 0 1110 1 . 1 .. ... ... 1 1111 0 1 . 0 ... 0 @2_shll_b | ||
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); \ | ||
139 | + } | ||
140 | + | ||
141 | +#define DO_VSHLL_ALL(OP, TOP) \ | ||
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) | ||
54 | -- | 172 | -- |
55 | 2.20.1 | 173 | 2.20.1 |
56 | 174 | ||
57 | 175 | diff view generated by jsdifflib |
1 | If MVE is implemented for an M-profile CPU then it has a VPR | 1 | Implement the MVE VSRI and VSLI insns, which perform a |
---|---|---|---|
2 | register, which tracks predication information. | 2 | shift-and-insert operation. |
3 | |||
4 | Implement the read and write handling of this register, and | ||
5 | the migration of its state. | ||
6 | 3 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20210520152840.24453-7-peter.maydell@linaro.org | 6 | Message-id: 20210628135835.6690-11-peter.maydell@linaro.org |
10 | --- | 7 | --- |
11 | target/arm/cpu.h | 6 ++++++ | 8 | target/arm/helper-mve.h | 8 ++++++++ |
12 | target/arm/machine.c | 19 +++++++++++++++++++ | 9 | target/arm/mve.decode | 9 ++++++++ |
13 | target/arm/translate-vfp.c | 38 ++++++++++++++++++++++++++++++++++++++ | 10 | target/arm/mve_helper.c | 42 ++++++++++++++++++++++++++++++++++++++ |
14 | 3 files changed, 63 insertions(+) | 11 | target/arm/translate-mve.c | 3 +++ |
12 | 4 files changed, 62 insertions(+) | ||
15 | 13 | ||
16 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 14 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
17 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/cpu.h | 16 | --- a/target/arm/helper-mve.h |
19 | +++ b/target/arm/cpu.h | 17 | +++ b/target/arm/helper-mve.h |
20 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 18 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vshlltsb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | uint32_t cpacr[M_REG_NUM_BANKS]; | 19 | DEF_HELPER_FLAGS_4(mve_vshlltsh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
22 | uint32_t nsacr; | 20 | DEF_HELPER_FLAGS_4(mve_vshlltub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | int ltpsize; | 21 | DEF_HELPER_FLAGS_4(mve_vshlltuh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
24 | + uint32_t vpr; | 22 | + |
25 | } v7m; | 23 | +DEF_HELPER_FLAGS_4(mve_vsrib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
26 | 24 | +DEF_HELPER_FLAGS_4(mve_vsrih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
27 | /* Information associated with an exception about to be taken: | 25 | +DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
28 | @@ -XXX,XX +XXX,XX @@ FIELD(V7M_FPCCR, ASPEN, 31, 1) | 26 | + |
29 | R_V7M_FPCCR_UFRDY_MASK | \ | 27 | +DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
30 | R_V7M_FPCCR_ASPEN_MASK) | 28 | +DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
31 | 29 | +DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
32 | +/* v7M VPR bits */ | 30 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
33 | +FIELD(V7M_VPR, P0, 0, 16) | 31 | index XXXXXXX..XXXXXXX 100644 |
34 | +FIELD(V7M_VPR, MASK01, 16, 4) | 32 | --- a/target/arm/mve.decode |
35 | +FIELD(V7M_VPR, MASK23, 20, 4) | 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) | ||
36 | + | 96 | + |
37 | /* | 97 | /* |
38 | * System register ID fields. | 98 | * Long shifts taking half-sized inputs from top or bottom of the input |
39 | */ | 99 | * vector and producing a double-width result. ESIZE, TYPE are for |
40 | diff --git a/target/arm/machine.c b/target/arm/machine.c | 100 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
41 | index XXXXXXX..XXXXXXX 100644 | 101 | index XXXXXXX..XXXXXXX 100644 |
42 | --- a/target/arm/machine.c | 102 | --- a/target/arm/translate-mve.c |
43 | +++ b/target/arm/machine.c | 103 | +++ b/target/arm/translate-mve.c |
44 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_fp = { | 104 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT(VSHRI_U, vshli_u, true) |
45 | } | 105 | DO_2SHIFT(VRSHRI_S, vrshli_s, true) |
46 | }; | 106 | DO_2SHIFT(VRSHRI_U, vrshli_u, true) |
47 | 107 | ||
48 | +static bool mve_needed(void *opaque) | 108 | +DO_2SHIFT(VSRI, vsri, false) |
49 | +{ | 109 | +DO_2SHIFT(VSLI, vsli, false) |
50 | + ARMCPU *cpu = opaque; | ||
51 | + | 110 | + |
52 | + return cpu_isar_feature(aa32_mve, cpu); | 111 | #define DO_VSHLL(INSN, FN) \ |
53 | +} | 112 | static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ |
54 | + | 113 | { \ |
55 | +static const VMStateDescription vmstate_m_mve = { | ||
56 | + .name = "cpu/m/mve", | ||
57 | + .version_id = 1, | ||
58 | + .minimum_version_id = 1, | ||
59 | + .needed = mve_needed, | ||
60 | + .fields = (VMStateField[]) { | ||
61 | + VMSTATE_UINT32(env.v7m.vpr, ARMCPU), | ||
62 | + VMSTATE_END_OF_LIST() | ||
63 | + }, | ||
64 | +}; | ||
65 | + | ||
66 | static const VMStateDescription vmstate_m = { | ||
67 | .name = "cpu/m", | ||
68 | .version_id = 4, | ||
69 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = { | ||
70 | &vmstate_m_other_sp, | ||
71 | &vmstate_m_v8m, | ||
72 | &vmstate_m_fp, | ||
73 | + &vmstate_m_mve, | ||
74 | NULL | ||
75 | } | ||
76 | }; | ||
77 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/target/arm/translate-vfp.c | ||
80 | +++ b/target/arm/translate-vfp.c | ||
81 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | ||
82 | return FPSysRegCheckFailed; | ||
83 | } | ||
84 | break; | ||
85 | + case ARM_VFP_VPR: | ||
86 | + case ARM_VFP_P0: | ||
87 | + if (!dc_isar_feature(aa32_mve, s)) { | ||
88 | + return FPSysRegCheckFailed; | ||
89 | + } | ||
90 | + break; | ||
91 | default: | ||
92 | return FPSysRegCheckFailed; | ||
93 | } | ||
94 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno, | ||
95 | tcg_temp_free_i32(sfpa); | ||
96 | break; | ||
97 | } | ||
98 | + case ARM_VFP_VPR: | ||
99 | + /* Behaves as NOP if not privileged */ | ||
100 | + if (IS_USER(s)) { | ||
101 | + break; | ||
102 | + } | ||
103 | + tmp = loadfn(s, opaque); | ||
104 | + store_cpu_field(tmp, v7m.vpr); | ||
105 | + break; | ||
106 | + case ARM_VFP_P0: | ||
107 | + { | ||
108 | + TCGv_i32 vpr; | ||
109 | + tmp = loadfn(s, opaque); | ||
110 | + vpr = load_cpu_field(v7m.vpr); | ||
111 | + tcg_gen_deposit_i32(vpr, vpr, tmp, | ||
112 | + R_V7M_VPR_P0_SHIFT, R_V7M_VPR_P0_LENGTH); | ||
113 | + store_cpu_field(vpr, v7m.vpr); | ||
114 | + tcg_temp_free_i32(tmp); | ||
115 | + break; | ||
116 | + } | ||
117 | default: | ||
118 | g_assert_not_reached(); | ||
119 | } | ||
120 | @@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno, | ||
121 | tcg_temp_free_i32(fpscr); | ||
122 | break; | ||
123 | } | ||
124 | + case ARM_VFP_VPR: | ||
125 | + /* Behaves as NOP if not privileged */ | ||
126 | + if (IS_USER(s)) { | ||
127 | + break; | ||
128 | + } | ||
129 | + tmp = load_cpu_field(v7m.vpr); | ||
130 | + storefn(s, opaque, tmp); | ||
131 | + break; | ||
132 | + case ARM_VFP_P0: | ||
133 | + tmp = load_cpu_field(v7m.vpr); | ||
134 | + tcg_gen_extract_i32(tmp, tmp, R_V7M_VPR_P0_SHIFT, R_V7M_VPR_P0_LENGTH); | ||
135 | + storefn(s, opaque, tmp); | ||
136 | + break; | ||
137 | default: | ||
138 | g_assert_not_reached(); | ||
139 | } | ||
140 | -- | 114 | -- |
141 | 2.20.1 | 115 | 2.20.1 |
142 | 116 | ||
143 | 117 | diff view generated by jsdifflib |
1 | Split out the handling of VMOV_reg_sp and VMOV_reg_dp so that we can | 1 | Implement the MVE shift-right-and-narrow insn VSHRN and VRSHRN. |
---|---|---|---|
2 | permit the insns if either FP or MVE are present. | 2 | |
3 | do_urshr() is borrowed from sve_helper.c. | ||
3 | 4 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20210520152840.24453-5-peter.maydell@linaro.org | 7 | Message-id: 20210628135835.6690-12-peter.maydell@linaro.org |
7 | --- | 8 | --- |
8 | target/arm/translate-vfp.c | 15 +++++++++++++-- | 9 | target/arm/helper-mve.h | 10 ++++++++++ |
9 | 1 file changed, 13 insertions(+), 2 deletions(-) | 10 | target/arm/mve.decode | 11 +++++++++++ |
11 | target/arm/mve_helper.c | 40 ++++++++++++++++++++++++++++++++++++++ | ||
12 | target/arm/translate-mve.c | 15 ++++++++++++++ | ||
13 | 4 files changed, 76 insertions(+) | ||
10 | 14 | ||
11 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
12 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/target/arm/translate-vfp.c | 17 | --- a/target/arm/helper-mve.h |
14 | +++ b/target/arm/translate-vfp.c | 18 | +++ b/target/arm/helper-mve.h |
15 | @@ -XXX,XX +XXX,XX @@ static bool trans_VMOV_imm_dp(DisasContext *s, arg_VMOV_imm_dp *a) | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vsriw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
16 | return do_vfp_2op_##PREC(s, FN, a->vd, a->vm); \ | 20 | DEF_HELPER_FLAGS_4(mve_vslib, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
17 | } | 21 | DEF_HELPER_FLAGS_4(mve_vslih, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
18 | 22 | DEF_HELPER_FLAGS_4(mve_vsliw, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | |
19 | -DO_VFP_2OP(VMOV_reg, sp, tcg_gen_mov_i32, aa32_fpsp_v2) | 23 | + |
20 | -DO_VFP_2OP(VMOV_reg, dp, tcg_gen_mov_i64, aa32_fpdp_v2) | 24 | +DEF_HELPER_FLAGS_4(mve_vshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
21 | +#define DO_VFP_VMOV(INSN, PREC, FN) \ | 25 | +DEF_HELPER_FLAGS_4(mve_vshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
22 | + static bool trans_##INSN##_##PREC(DisasContext *s, \ | 26 | +DEF_HELPER_FLAGS_4(mve_vshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | + arg_##INSN##_##PREC *a) \ | 27 | +DEF_HELPER_FLAGS_4(mve_vshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
28 | + | ||
29 | +DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
30 | +DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/mve.decode | ||
36 | +++ b/target/arm/mve.decode | ||
37 | @@ -XXX,XX +XXX,XX @@ VSRI 111 1 1111 1 . ... ... ... 0 0100 0 1 . 1 ... 0 @2_shr_w | ||
38 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_b | ||
39 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_h | ||
40 | VSLI 111 1 1111 1 . ... ... ... 0 0101 0 1 . 1 ... 0 @2_shl_w | ||
41 | + | ||
42 | +# Narrowing shifts (which only support b and h sizes) | ||
43 | +VSHRNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | ||
44 | +VSHRNB 111 0 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | ||
45 | +VSHRNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | ||
46 | +VSHRNT 111 0 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | ||
47 | + | ||
48 | +VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_b | ||
49 | +VRSHRNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 1 @2_shr_h | ||
50 | +VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_b | ||
51 | +VRSHRNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 1 @2_shr_h | ||
52 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/target/arm/mve_helper.c | ||
55 | +++ b/target/arm/mve_helper.c | ||
56 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_INSERT(vsliw, 4, DO_SHL, SHL_MASK) | ||
57 | |||
58 | DO_VSHLL_ALL(vshllb, false) | ||
59 | DO_VSHLL_ALL(vshllt, true) | ||
60 | + | ||
61 | +/* | ||
62 | + * Narrowing right shifts, taking a double sized input, shifting it | ||
63 | + * and putting the result in either the top or bottom half of the output. | ||
64 | + * ESIZE, TYPE are the output, and LESIZE, LTYPE the input. | ||
65 | + */ | ||
66 | +#define DO_VSHRN(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ | ||
67 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ | ||
68 | + void *vm, uint32_t shift) \ | ||
24 | + { \ | 69 | + { \ |
25 | + if (!dc_isar_feature(aa32_fp##PREC##_v2, s) && \ | 70 | + LTYPE *m = vm; \ |
26 | + !dc_isar_feature(aa32_mve, s)) { \ | 71 | + TYPE *d = vd; \ |
27 | + return false; \ | 72 | + uint16_t mask = mve_element_mask(env); \ |
73 | + unsigned le; \ | ||
74 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
75 | + TYPE r = FN(m[H##LESIZE(le)], shift); \ | ||
76 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
28 | + } \ | 77 | + } \ |
29 | + return do_vfp_2op_##PREC(s, FN, a->vd, a->vm); \ | 78 | + mve_advance_vpt(env); \ |
30 | + } | 79 | + } |
31 | + | 80 | + |
32 | +DO_VFP_VMOV(VMOV_reg, sp, tcg_gen_mov_i32) | 81 | +#define DO_VSHRN_ALL(OP, FN) \ |
33 | +DO_VFP_VMOV(VMOV_reg, dp, tcg_gen_mov_i64) | 82 | + DO_VSHRN(OP##bb, false, 1, uint8_t, 2, uint16_t, FN) \ |
34 | 83 | + DO_VSHRN(OP##bh, false, 2, uint16_t, 4, uint32_t, FN) \ | |
35 | DO_VFP_2OP(VABS, hp, gen_helper_vfp_absh, aa32_fp16_arith) | 84 | + DO_VSHRN(OP##tb, true, 1, uint8_t, 2, uint16_t, FN) \ |
36 | DO_VFP_2OP(VABS, sp, gen_helper_vfp_abss, aa32_fpsp_v2) | 85 | + DO_VSHRN(OP##th, true, 2, uint16_t, 4, uint32_t, FN) |
86 | + | ||
87 | +static inline uint64_t do_urshr(uint64_t x, unsigned sh) | ||
88 | +{ | ||
89 | + if (likely(sh < 64)) { | ||
90 | + return (x >> sh) + ((x >> (sh - 1)) & 1); | ||
91 | + } else if (sh == 64) { | ||
92 | + return x >> 63; | ||
93 | + } else { | ||
94 | + return 0; | ||
95 | + } | ||
96 | +} | ||
97 | + | ||
98 | +DO_VSHRN_ALL(vshrn, DO_SHR) | ||
99 | +DO_VSHRN_ALL(vrshrn, do_urshr) | ||
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_VSHLL(VSHLL_BS, vshllbs) | ||
105 | DO_VSHLL(VSHLL_BU, vshllbu) | ||
106 | DO_VSHLL(VSHLL_TS, vshllts) | ||
107 | DO_VSHLL(VSHLL_TU, vshlltu) | ||
108 | + | ||
109 | +#define DO_2SHIFT_N(INSN, FN) \ | ||
110 | + static bool trans_##INSN(DisasContext *s, arg_2shift *a) \ | ||
111 | + { \ | ||
112 | + static MVEGenTwoOpShiftFn * const fns[] = { \ | ||
113 | + gen_helper_mve_##FN##b, \ | ||
114 | + gen_helper_mve_##FN##h, \ | ||
115 | + }; \ | ||
116 | + return do_2shift(s, a, fns[a->size], false); \ | ||
117 | + } | ||
118 | + | ||
119 | +DO_2SHIFT_N(VSHRNB, vshrnb) | ||
120 | +DO_2SHIFT_N(VSHRNT, vshrnt) | ||
121 | +DO_2SHIFT_N(VRSHRNB, vrshrnb) | ||
122 | +DO_2SHIFT_N(VRSHRNT, vrshrnt) | ||
37 | -- | 123 | -- |
38 | 2.20.1 | 124 | 2.20.1 |
39 | 125 | ||
40 | 126 | diff view generated by jsdifflib |
1 | Add the isar feature check functions we will need for v8.1M MVE: | 1 | Implement the MVE saturating shift-right-and-narrow insns |
---|---|---|---|
2 | * a check for MVE present: this corresponds to the pseudocode's | 2 | VQSHRN, VQSHRUN, VQRSHRN and VQRSHRUN. |
3 | CheckDecodeFaults(ExtType_Mve) | 3 | |
4 | * a check for the optional floating-point part of MVE: this | 4 | do_srshr() is borrowed from sve_helper.c. |
5 | corresponds to CheckDecodeFaults(ExtType_MveFp) | ||
6 | 5 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20210520152840.24453-2-peter.maydell@linaro.org | 8 | Message-id: 20210628135835.6690-13-peter.maydell@linaro.org |
10 | --- | 9 | --- |
11 | target/arm/cpu.h | 22 ++++++++++++++++++++++ | 10 | target/arm/helper-mve.h | 30 +++++++++++ |
12 | 1 file changed, 22 insertions(+) | 11 | target/arm/mve.decode | 28 ++++++++++ |
13 | 12 | target/arm/mve_helper.c | 104 +++++++++++++++++++++++++++++++++++++ | |
14 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 13 | target/arm/translate-mve.c | 12 +++++ |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | 4 files changed, 174 insertions(+) |
16 | --- a/target/arm/cpu.h | 15 | |
17 | +++ b/target/arm/cpu.h | 16 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
18 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id) | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/helper-mve.h | ||
19 | +++ b/target/arm/helper-mve.h | ||
20 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vrshrnbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
21 | DEF_HELPER_FLAGS_4(mve_vrshrnbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
22 | DEF_HELPER_FLAGS_4(mve_vrshrntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
23 | DEF_HELPER_FLAGS_4(mve_vrshrnth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
24 | + | ||
25 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
26 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
27 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
28 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
29 | + | ||
30 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
31 | +DEF_HELPER_FLAGS_4(mve_vqshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
32 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
33 | +DEF_HELPER_FLAGS_4(mve_vqshrnt_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
34 | + | ||
35 | +DEF_HELPER_FLAGS_4(mve_vqshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
36 | +DEF_HELPER_FLAGS_4(mve_vqshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
37 | +DEF_HELPER_FLAGS_4(mve_vqshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
38 | +DEF_HELPER_FLAGS_4(mve_vqshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
39 | + | ||
40 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
41 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
42 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_sb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
43 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_sh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
44 | + | ||
45 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
46 | +DEF_HELPER_FLAGS_4(mve_vqrshrnb_uh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
47 | +DEF_HELPER_FLAGS_4(mve_vqrshrnt_ub, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) | ||
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) | ||
19 | } | 95 | } |
20 | } | 96 | } |
21 | 97 | ||
22 | +static inline bool isar_feature_aa32_mve(const ARMISARegisters *id) | 98 | +static inline int64_t do_srshr(int64_t x, unsigned sh) |
23 | +{ | 99 | +{ |
24 | + /* | 100 | + if (likely(sh < 64)) { |
25 | + * Return true if MVE is supported (either integer or floating point). | 101 | + return (x >> sh) + ((x >> (sh - 1)) & 1); |
26 | + * We must check for M-profile as the MVFR1 field means something | 102 | + } else { |
27 | + * else for A-profile. | 103 | + /* Rounding the sign bit always produces 0. */ |
28 | + */ | 104 | + return 0; |
29 | + return isar_feature_aa32_mprofile(id) && | 105 | + } |
30 | + FIELD_EX32(id->mvfr1, MVFR1, MVE) > 0; | ||
31 | +} | 106 | +} |
32 | + | 107 | + |
33 | +static inline bool isar_feature_aa32_mve_fp(const ARMISARegisters *id) | 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) | ||
34 | +{ | 113 | +{ |
35 | + /* | 114 | + if (val > max) { |
36 | + * Return true if MVE is supported (either integer or floating point). | 115 | + *satp = true; |
37 | + * We must check for M-profile as the MVFR1 field means something | 116 | + return max; |
38 | + * else for A-profile. | 117 | + } else if (val < min) { |
39 | + */ | 118 | + *satp = true; |
40 | + return isar_feature_aa32_mprofile(id) && | 119 | + return min; |
41 | + FIELD_EX32(id->mvfr1, MVFR1, MVE) >= 2; | 120 | + } else { |
121 | + return val; | ||
122 | + } | ||
42 | +} | 123 | +} |
43 | + | 124 | + |
44 | static inline bool isar_feature_aa32_vfp_simd(const ARMISARegisters *id) | 125 | +/* Saturating narrowing right shifts */ |
45 | { | 126 | +#define DO_VSHRN_SAT(OP, TOP, ESIZE, TYPE, LESIZE, LTYPE, FN) \ |
46 | /* | 127 | + void HELPER(glue(mve_, OP))(CPUARMState *env, void *vd, \ |
128 | + void *vm, uint32_t shift) \ | ||
129 | + { \ | ||
130 | + LTYPE *m = vm; \ | ||
131 | + TYPE *d = vd; \ | ||
132 | + uint16_t mask = mve_element_mask(env); \ | ||
133 | + bool qc = false; \ | ||
134 | + unsigned le; \ | ||
135 | + for (le = 0; le < 16 / LESIZE; le++, mask >>= LESIZE) { \ | ||
136 | + bool sat = false; \ | ||
137 | + TYPE r = FN(m[H##LESIZE(le)], shift, &sat); \ | ||
138 | + mergemask(&d[H##ESIZE(le * 2 + TOP)], r, mask); \ | ||
139 | + qc |= sat && (mask & 1 << (TOP * ESIZE)); \ | ||
140 | + } \ | ||
141 | + if (qc) { \ | ||
142 | + env->vfp.qc[0] = qc; \ | ||
143 | + } \ | ||
144 | + mve_advance_vpt(env); \ | ||
145 | + } | ||
146 | + | ||
147 | +#define DO_VSHRN_SAT_UB(BOP, TOP, FN) \ | ||
148 | + DO_VSHRN_SAT(BOP, false, 1, uint8_t, 2, uint16_t, FN) \ | ||
149 | + DO_VSHRN_SAT(TOP, true, 1, uint8_t, 2, uint16_t, FN) | ||
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) | ||
47 | -- | 224 | -- |
48 | 2.20.1 | 225 | 2.20.1 |
49 | 226 | ||
50 | 227 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The fp_sysreg_checks() function is supposed to be returning an | ||
2 | FPSysRegCheckResult, which is an enum with three possible values. | ||
3 | However, three places in the function "return false" (a hangover from | ||
4 | a previous iteration of the design where the function just returned a | ||
5 | bool). Make these return FPSysRegCheckFailed instead (for no | ||
6 | functional change, since both false and FPSysRegCheckFailed are | ||
7 | zero). | ||
8 | 1 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20210520152840.24453-6-peter.maydell@linaro.org | ||
12 | --- | ||
13 | target/arm/translate-vfp.c | 6 +++--- | ||
14 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/translate-vfp.c | ||
19 | +++ b/target/arm/translate-vfp.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno) | ||
21 | break; | ||
22 | case ARM_VFP_FPSCR_NZCVQC: | ||
23 | if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
24 | - return false; | ||
25 | + return FPSysRegCheckFailed; | ||
26 | } | ||
27 | break; | ||
28 | case ARM_VFP_FPCXT_S: | ||
29 | case ARM_VFP_FPCXT_NS: | ||
30 | if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
31 | - return false; | ||
32 | + return FPSysRegCheckFailed; | ||
33 | } | ||
34 | if (!s->v8m_secure) { | ||
35 | - return false; | ||
36 | + return FPSysRegCheckFailed; | ||
37 | } | ||
38 | break; | ||
39 | default: | ||
40 | -- | ||
41 | 2.20.1 | ||
42 | |||
43 | diff view generated by jsdifflib |
1 | Currently we allow board models to specify the initial value of the | 1 | Implement the MVE VSHLC insn, which performs a shift left of the |
---|---|---|---|
2 | Secure VTOR register, using an init-svtor property on the TYPE_ARMV7M | 2 | entire vector with carry in bits provided from a general purpose |
3 | object which is plumbed through to the CPU. Allow board models to | 3 | register and carry out bits written back to that register. |
4 | also specify the initial value of the Non-secure VTOR via a similar | ||
5 | init-nsvtor property. | ||
6 | 4 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20210520152840.24453-10-peter.maydell@linaro.org | 7 | Message-id: 20210628135835.6690-14-peter.maydell@linaro.org |
10 | --- | 8 | --- |
11 | include/hw/arm/armv7m.h | 2 ++ | 9 | target/arm/helper-mve.h | 2 ++ |
12 | target/arm/cpu.h | 2 ++ | 10 | target/arm/mve.decode | 2 ++ |
13 | hw/arm/armv7m.c | 7 +++++++ | 11 | target/arm/mve_helper.c | 38 ++++++++++++++++++++++++++++++++++++++ |
14 | target/arm/cpu.c | 10 ++++++++++ | 12 | target/arm/translate-mve.c | 30 ++++++++++++++++++++++++++++++ |
15 | 4 files changed, 21 insertions(+) | 13 | 4 files changed, 72 insertions(+) |
16 | 14 | ||
17 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
18 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/armv7m.h | 17 | --- a/target/arm/helper-mve.h |
20 | +++ b/include/hw/arm/armv7m.h | 18 | +++ b/target/arm/helper-mve.h |
21 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(ARMv7MState, ARMV7M) | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunbb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
22 | * devices will be automatically layered on top of this view.) | 20 | DEF_HELPER_FLAGS_4(mve_vqrshrunbh, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | * + Property "idau": IDAU interface (forwarded to CPU object) | 21 | DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
24 | * + Property "init-svtor": secure VTOR reset value (forwarded to CPU object) | 22 | DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
25 | + * + Property "init-nsvtor": non-secure VTOR reset value (forwarded to CPU object) | 23 | + |
26 | * + Property "vfp": enable VFP (forwarded to CPU object) | 24 | +DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
27 | * + Property "dsp": enable DSP (forwarded to CPU object) | 25 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
28 | * + Property "enable-bitband": expose bitbanded IO | ||
29 | @@ -XXX,XX +XXX,XX @@ struct ARMv7MState { | ||
30 | MemoryRegion *board_memory; | ||
31 | Object *idau; | ||
32 | uint32_t init_svtor; | ||
33 | + uint32_t init_nsvtor; | ||
34 | bool enable_bitband; | ||
35 | bool start_powered_off; | ||
36 | bool vfp; | ||
37 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
39 | --- a/target/arm/cpu.h | 27 | --- a/target/arm/mve.decode |
40 | +++ b/target/arm/cpu.h | 28 | +++ b/target/arm/mve.decode |
41 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 29 | @@ -XXX,XX +XXX,XX @@ VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_b |
42 | 30 | VQRSHRUNB 111 1 1110 1 . ... ... ... 0 1111 1 1 . 0 ... 0 @2_shr_h | |
43 | /* For v8M, initial value of the Secure VTOR */ | 31 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_b |
44 | uint32_t init_svtor; | 32 | VQRSHRUNT 111 1 1110 1 . ... ... ... 1 1111 1 1 . 0 ... 0 @2_shr_h |
45 | + /* For v8M, initial value of the Non-secure VTOR */ | 33 | + |
46 | + uint32_t init_nsvtor; | 34 | +VSHLC 111 0 1110 1 . 1 imm:5 ... 0 1111 1100 rdm:4 qd=%qd |
47 | 35 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | |
48 | /* [QEMU_]KVM_ARM_TARGET_* constant for this CPU, or | ||
49 | * QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU type. | ||
50 | diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
52 | --- a/hw/arm/armv7m.c | 37 | --- a/target/arm/mve_helper.c |
53 | +++ b/hw/arm/armv7m.c | 38 | +++ b/target/arm/mve_helper.c |
54 | @@ -XXX,XX +XXX,XX @@ static void armv7m_realize(DeviceState *dev, Error **errp) | 39 | @@ -XXX,XX +XXX,XX @@ DO_VSHRN_SAT_UB(vqrshrnb_ub, vqrshrnt_ub, DO_RSHRN_UB) |
55 | return; | 40 | DO_VSHRN_SAT_UH(vqrshrnb_uh, vqrshrnt_uh, DO_RSHRN_UH) |
56 | } | 41 | DO_VSHRN_SAT_SB(vqrshrunbb, vqrshruntb, DO_RSHRUN_B) |
57 | } | 42 | DO_VSHRN_SAT_SH(vqrshrunbh, vqrshrunth, DO_RSHRUN_H) |
58 | + if (object_property_find(OBJECT(s->cpu), "init-nsvtor")) { | 43 | + |
59 | + if (!object_property_set_uint(OBJECT(s->cpu), "init-nsvtor", | 44 | +uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, |
60 | + s->init_nsvtor, errp)) { | 45 | + uint32_t shift) |
61 | + return; | 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)]; | ||
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); | ||
62 | + } | 76 | + } |
63 | + } | 77 | + } |
64 | if (object_property_find(OBJECT(s->cpu), "start-powered-off")) { | 78 | + mve_advance_vpt(env); |
65 | if (!object_property_set_bool(OBJECT(s->cpu), "start-powered-off", | 79 | + return rdm; |
66 | s->start_powered_off, errp)) { | 80 | +} |
67 | @@ -XXX,XX +XXX,XX @@ static Property armv7m_properties[] = { | 81 | diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c |
68 | MemoryRegion *), | ||
69 | DEFINE_PROP_LINK("idau", ARMv7MState, idau, TYPE_IDAU_INTERFACE, Object *), | ||
70 | DEFINE_PROP_UINT32("init-svtor", ARMv7MState, init_svtor, 0), | ||
71 | + DEFINE_PROP_UINT32("init-nsvtor", ARMv7MState, init_nsvtor, 0), | ||
72 | DEFINE_PROP_BOOL("enable-bitband", ARMv7MState, enable_bitband, false), | ||
73 | DEFINE_PROP_BOOL("start-powered-off", ARMv7MState, start_powered_off, | ||
74 | false), | ||
75 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
76 | index XXXXXXX..XXXXXXX 100644 | 82 | index XXXXXXX..XXXXXXX 100644 |
77 | --- a/target/arm/cpu.c | 83 | --- a/target/arm/translate-mve.c |
78 | +++ b/target/arm/cpu.c | 84 | +++ b/target/arm/translate-mve.c |
79 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) | 85 | @@ -XXX,XX +XXX,XX @@ DO_2SHIFT_N(VQRSHRNB_U, vqrshrnb_u) |
80 | env->regs[14] = 0xffffffff; | 86 | DO_2SHIFT_N(VQRSHRNT_U, vqrshrnt_u) |
81 | 87 | DO_2SHIFT_N(VQRSHRUNB, vqrshrunb) | |
82 | env->v7m.vecbase[M_REG_S] = cpu->init_svtor & 0xffffff80; | 88 | DO_2SHIFT_N(VQRSHRUNT, vqrshrunt) |
83 | + env->v7m.vecbase[M_REG_NS] = cpu->init_nsvtor & 0xffffff80; | 89 | + |
84 | 90 | +static bool trans_VSHLC(DisasContext *s, arg_VSHLC *a) | |
85 | /* Load the initial SP and PC from offset 0 and 4 in the vector table */ | 91 | +{ |
86 | vecbase = env->v7m.vecbase[env->v7m.secure]; | 92 | + /* |
87 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj) | 93 | + * Whole Vector Left Shift with Carry. The carry is taken |
88 | &cpu->init_svtor, | 94 | + * from a general purpose register and written back there. |
89 | OBJ_PROP_FLAG_READWRITE); | 95 | + * An imm of 0 means "shift by 32". |
90 | } | 96 | + */ |
91 | + if (arm_feature(&cpu->env, ARM_FEATURE_M)) { | 97 | + TCGv_ptr qd; |
92 | + /* | 98 | + TCGv_i32 rdm; |
93 | + * Initial value of the NS VTOR (for cores without the Security | 99 | + |
94 | + * extension, this is the only VTOR) | 100 | + if (!dc_isar_feature(aa32_mve, s) || !mve_check_qreg_bank(s, a->qd)) { |
95 | + */ | 101 | + return false; |
96 | + object_property_add_uint32_ptr(obj, "init-nsvtor", | ||
97 | + &cpu->init_nsvtor, | ||
98 | + OBJ_PROP_FLAG_READWRITE); | ||
99 | + } | 102 | + } |
100 | 103 | + if (a->rdm == 13 || a->rdm == 15) { | |
101 | qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property); | 104 | + /* CONSTRAINED UNPREDICTABLE: we UNDEF */ |
102 | 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 | +} | ||
103 | -- | 119 | -- |
104 | 2.20.1 | 120 | 2.20.1 |
105 | 121 | ||
106 | 122 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Jamie Iles <jamie@nuviainc.com> | ||
2 | 1 | ||
3 | The DAIF and PAC checks used raise_exception_ra to raise an exception | ||
4 | and unwind CPU state but raise_exception_ra is currently designed for | ||
5 | handling data aborts as the syndrome is partially precomputed and | ||
6 | encoded in the TB and then merged in merge_syn_data_abort when handling | ||
7 | the data abort. Using raise_exception_ra for DAIF and PAC checks | ||
8 | results in an empty syndrome being retrieved from data[2] in | ||
9 | restore_state_to_opc and setting ESR to 0. This manifested as: | ||
10 | |||
11 | kvm [571]: Unknown exception class: esr: 0x000000 – | ||
12 | Unknown/Uncategorized | ||
13 | |||
14 | when launching a KVM guest when the host qemu used a CPU supporting | ||
15 | EL2+pointer authentication and enabling pointer authentication in the | ||
16 | guest. | ||
17 | |||
18 | Rework raise_exception_ra such that the state is restored before raising | ||
19 | the exception so that the exception is not clobbered by | ||
20 | restore_state_to_opc. | ||
21 | |||
22 | Fixes: 0d43e1a2d29a ("target/arm: Add PAuth helpers") | ||
23 | Cc: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
25 | Signed-off-by: Jamie Iles <jamie@nuviainc.com> | ||
26 | [PMM: added comment] | ||
27 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
29 | --- | ||
30 | target/arm/op_helper.c | 11 +++++++++-- | ||
31 | 1 file changed, 9 insertions(+), 2 deletions(-) | ||
32 | |||
33 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/arm/op_helper.c | ||
36 | +++ b/target/arm/op_helper.c | ||
37 | @@ -XXX,XX +XXX,XX @@ void raise_exception(CPUARMState *env, uint32_t excp, | ||
38 | void raise_exception_ra(CPUARMState *env, uint32_t excp, uint32_t syndrome, | ||
39 | uint32_t target_el, uintptr_t ra) | ||
40 | { | ||
41 | - CPUState *cs = do_raise_exception(env, excp, syndrome, target_el); | ||
42 | - cpu_loop_exit_restore(cs, ra); | ||
43 | + CPUState *cs = env_cpu(env); | ||
44 | + | ||
45 | + /* | ||
46 | + * restore_state_to_opc() will set env->exception.syndrome, so | ||
47 | + * we must restore CPU state here before setting the syndrome | ||
48 | + * the caller passed us, and cannot use cpu_loop_exit_restore(). | ||
49 | + */ | ||
50 | + cpu_restore_state(cs, ra, true); | ||
51 | + raise_exception(env, excp, syndrome, target_el); | ||
52 | } | ||
53 | |||
54 | uint64_t HELPER(neon_tbl)(CPUARMState *env, uint32_t desc, | ||
55 | -- | ||
56 | 2.20.1 | ||
57 | |||
58 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Jamie Iles <jamie@nuviainc.com> | ||
2 | 1 | ||
3 | Now that there are no other users of do_raise_exception, fold it into | ||
4 | raise_exception. | ||
5 | |||
6 | Cc: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Jamie Iles <jamie@nuviainc.com> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/op_helper.c | 12 ++---------- | ||
13 | 1 file changed, 2 insertions(+), 10 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/op_helper.c | ||
18 | +++ b/target/arm/op_helper.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #define SIGNBIT (uint32_t)0x80000000 | ||
21 | #define SIGNBIT64 ((uint64_t)1 << 63) | ||
22 | |||
23 | -static CPUState *do_raise_exception(CPUARMState *env, uint32_t excp, | ||
24 | - uint32_t syndrome, uint32_t target_el) | ||
25 | +void raise_exception(CPUARMState *env, uint32_t excp, | ||
26 | + uint32_t syndrome, uint32_t target_el) | ||
27 | { | ||
28 | CPUState *cs = env_cpu(env); | ||
29 | |||
30 | @@ -XXX,XX +XXX,XX @@ static CPUState *do_raise_exception(CPUARMState *env, uint32_t excp, | ||
31 | cs->exception_index = excp; | ||
32 | env->exception.syndrome = syndrome; | ||
33 | env->exception.target_el = target_el; | ||
34 | - | ||
35 | - return cs; | ||
36 | -} | ||
37 | - | ||
38 | -void raise_exception(CPUARMState *env, uint32_t excp, | ||
39 | - uint32_t syndrome, uint32_t target_el) | ||
40 | -{ | ||
41 | - CPUState *cs = do_raise_exception(env, excp, syndrome, target_el); | ||
42 | cpu_loop_exit(cs); | ||
43 | } | ||
44 | |||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Jamie Iles <jamie@nuviainc.com> | ||
2 | 1 | ||
3 | Now that raise_exception_ra restores the state before raising the | ||
4 | exception we can use restore_exception_ra to perform the state restore + | ||
5 | exception raising without clobbering the syndrome. | ||
6 | |||
7 | Cc: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Jamie Iles <jamie@nuviainc.com> | ||
10 | [PMM: Keep the one line of the comment that is still relevant] | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | target/arm/mte_helper.c | 12 +++--------- | ||
15 | 1 file changed, 3 insertions(+), 9 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/mte_helper.c | ||
20 | +++ b/target/arm/mte_helper.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc, | ||
22 | |||
23 | switch (tcf) { | ||
24 | case 1: | ||
25 | - /* | ||
26 | - * Tag check fail causes a synchronous exception. | ||
27 | - * | ||
28 | - * In restore_state_to_opc, we set the exception syndrome | ||
29 | - * for the load or store operation. Unwind first so we | ||
30 | - * may overwrite that with the syndrome for the tag check. | ||
31 | - */ | ||
32 | - cpu_restore_state(env_cpu(env), ra, true); | ||
33 | + /* Tag check fail causes a synchronous exception. */ | ||
34 | env->exception.vaddress = dirty_ptr; | ||
35 | |||
36 | is_write = FIELD_EX32(desc, MTEDESC, WRITE); | ||
37 | syn = syn_data_abort_no_iss(arm_current_el(env) != 0, 0, 0, 0, 0, | ||
38 | is_write, 0x11); | ||
39 | - raise_exception(env, EXCP_DATA_ABORT, syn, exception_target_el(env)); | ||
40 | + raise_exception_ra(env, EXCP_DATA_ABORT, syn, | ||
41 | + exception_target_el(env), ra); | ||
42 | /* noreturn, but fall through to the assert anyway */ | ||
43 | |||
44 | case 0: | ||
45 | -- | ||
46 | 2.20.1 | ||
47 | |||
48 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 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 | This is BFMMLA for both AArch64 AdvSIMD and SVE, | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | and VMMLA.BF16 for AArch32 NEON. | 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(-) | ||
5 | 14 | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210525225817.400336-9-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/helper.h | 3 +++ | ||
12 | target/arm/neon-shared.decode | 2 ++ | ||
13 | target/arm/sve.decode | 6 +++-- | ||
14 | target/arm/translate-a64.c | 10 +++++++++ | ||
15 | target/arm/translate-neon.c | 9 ++++++++ | ||
16 | target/arm/translate-sve.c | 12 ++++++++++ | ||
17 | target/arm/vec_helper.c | 42 ++++++++++++++++++++++++++++++++++- | ||
18 | 7 files changed, 81 insertions(+), 3 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.h | 17 | --- a/target/arm/helper-mve.h |
23 | +++ b/target/arm/helper.h | 18 | +++ b/target/arm/helper-mve.h |
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_bfdot, TCG_CALL_NO_RWG, | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_vaddvuh, TCG_CALL_NO_WG, i32, env, ptr, i32) |
25 | DEF_HELPER_FLAGS_5(gvec_bfdot_idx, TCG_CALL_NO_RWG, | 20 | DEF_HELPER_FLAGS_3(mve_vaddvsw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
26 | void, ptr, ptr, ptr, ptr, i32) | 21 | DEF_HELPER_FLAGS_3(mve_vaddvuw, TCG_CALL_NO_WG, i32, env, ptr, i32) |
27 | 22 | ||
28 | +DEF_HELPER_FLAGS_5(gvec_bfmmla, TCG_CALL_NO_RWG, | 23 | +DEF_HELPER_FLAGS_3(mve_vaddlv_s, TCG_CALL_NO_WG, i64, env, ptr, i64) |
29 | + void, ptr, ptr, ptr, ptr, i32) | 24 | +DEF_HELPER_FLAGS_3(mve_vaddlv_u, TCG_CALL_NO_WG, i64, env, ptr, i64) |
30 | + | 25 | + |
31 | #ifdef TARGET_AARCH64 | 26 | DEF_HELPER_FLAGS_3(mve_vmovi, TCG_CALL_NO_WG, void, env, ptr, i64) |
32 | #include "helper-a64.h" | 27 | DEF_HELPER_FLAGS_3(mve_vandi, TCG_CALL_NO_WG, void, env, ptr, i64) |
33 | #include "helper-sve.h" | 28 | DEF_HELPER_FLAGS_3(mve_vorri, TCG_CALL_NO_WG, void, env, ptr, i64) |
34 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | 29 | diff --git a/target/arm/mve.decode b/target/arm/mve.decode |
35 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/neon-shared.decode | 31 | --- a/target/arm/mve.decode |
37 | +++ b/target/arm/neon-shared.decode | 32 | +++ b/target/arm/mve.decode |
38 | @@ -XXX,XX +XXX,XX @@ VUMMLA 1111 1100 0.10 .... .... 1100 .1.1 .... \ | 33 | @@ -XXX,XX +XXX,XX @@ VQDMULH_scalar 1110 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar |
39 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | 34 | VQRDMULH_scalar 1111 1110 0 . .. ... 1 ... 0 1110 . 110 .... @2scalar |
40 | VUSMMLA 1111 1100 1.10 .... .... 1100 .1.0 .... \ | 35 | |
41 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | 36 | # Vector add across vector |
42 | +VMMLA_b16 1111 1100 0.00 .... .... 1100 .1.0 .... \ | 37 | -VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo |
43 | + vm=%vm_dp vn=%vn_dp vd=%vd_dp | 38 | +{ |
44 | 39 | + VADDV 111 u:1 1110 1111 size:2 01 ... 0 1111 0 0 a:1 0 qm:3 0 rda=%rdalo | |
45 | VCMLA_scalar 1111 1110 0 . rot:2 .... .... 1000 . q:1 index:1 0 vm:4 \ | 40 | + VADDLV 111 u:1 1110 1 ... 1001 ... 0 1111 00 a:1 0 qm:3 0 \ |
46 | vn=%vn_dp vd=%vd_dp size=1 | 41 | + rdahi=%rdahi rdalo=%rdalo |
47 | diff --git a/target/arm/sve.decode b/target/arm/sve.decode | 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 | ||
48 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/target/arm/sve.decode | 48 | --- a/target/arm/mve_helper.c |
50 | +++ b/target/arm/sve.decode | 49 | +++ b/target/arm/mve_helper.c |
51 | @@ -XXX,XX +XXX,XX @@ SQRDCMLAH_zzzz 01000100 esz:2 0 rm:5 0011 rot:2 rn:5 rd:5 ra=%reg_movprfx | 50 | @@ -XXX,XX +XXX,XX @@ DO_VADDV(vaddvub, 1, uint8_t) |
52 | USDOT_zzzz 01000100 .. 0 ..... 011 110 ..... ..... @rda_rn_rm | 51 | DO_VADDV(vaddvuh, 2, uint16_t) |
53 | 52 | DO_VADDV(vaddvuw, 4, uint32_t) | |
54 | ### SVE2 floating point matrix multiply accumulate | 53 | |
55 | - | 54 | +#define DO_VADDLV(OP, TYPE, LTYPE) \ |
56 | -FMMLA 01100100 .. 1 ..... 111001 ..... ..... @rda_rn_rm | 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; | ||
82 | } | ||
83 | |||
84 | +static bool trans_VADDLV(DisasContext *s, arg_VADDLV *a) | ||
57 | +{ | 85 | +{ |
58 | + BFMMLA 01100100 01 1 ..... 111 001 ..... ..... @rda_rn_rm_e0 | 86 | + /* |
59 | + FMMLA 01100100 .. 1 ..... 111 001 ..... ..... @rda_rn_rm | 87 | + * Vector Add Long Across Vector: accumulate the 32-bit |
60 | +} | 88 | + * elements of the vector into a 64-bit result stored in |
61 | 89 | + * a pair of general-purpose registers. | |
62 | ### SVE2 Memory Gather Load Group | 90 | + * No need to check Qm's bank: it is only 3 bits in decode. |
63 | 91 | + */ | |
64 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 92 | + TCGv_ptr qm; |
65 | index XXXXXXX..XXXXXXX 100644 | 93 | + TCGv_i64 rda; |
66 | --- a/target/arm/translate-a64.c | 94 | + TCGv_i32 rdalo, rdahi; |
67 | +++ b/target/arm/translate-a64.c | ||
68 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
69 | } | ||
70 | feature = dc_isar_feature(aa64_fcma, s); | ||
71 | break; | ||
72 | + case 0x1d: /* BFMMLA */ | ||
73 | + if (size != MO_16 || !is_q) { | ||
74 | + unallocated_encoding(s); | ||
75 | + return; | ||
76 | + } | ||
77 | + feature = dc_isar_feature(aa64_bf16, s); | ||
78 | + break; | ||
79 | case 0x1f: /* BFDOT */ | ||
80 | switch (size) { | ||
81 | case 1: | ||
82 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
83 | } | ||
84 | return; | ||
85 | |||
86 | + case 0xd: /* BFMMLA */ | ||
87 | + gen_gvec_op4_ool(s, is_q, rd, rn, rm, rd, 0, gen_helper_gvec_bfmmla); | ||
88 | + return; | ||
89 | case 0xf: /* BFDOT */ | ||
90 | switch (size) { | ||
91 | case 1: | ||
92 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
93 | index XXXXXXX..XXXXXXX 100644 | ||
94 | --- a/target/arm/translate-neon.c | ||
95 | +++ b/target/arm/translate-neon.c | ||
96 | @@ -XXX,XX +XXX,XX @@ static bool trans_VUSMMLA(DisasContext *s, arg_VUSMMLA *a) | ||
97 | return do_neon_ddda(s, 7, a->vd, a->vn, a->vm, 0, | ||
98 | gen_helper_gvec_usmmla_b); | ||
99 | } | ||
100 | + | 95 | + |
101 | +static bool trans_VMMLA_b16(DisasContext *s, arg_VMMLA_b16 *a) | 96 | + if (!dc_isar_feature(aa32_mve, s)) { |
102 | +{ | ||
103 | + if (!dc_isar_feature(aa32_bf16, s)) { | ||
104 | + return false; | 97 | + return false; |
105 | + } | 98 | + } |
106 | + return do_neon_ddda(s, 7, a->vd, a->vn, a->vm, 0, | 99 | + /* |
107 | + gen_helper_gvec_bfmmla); | 100 | + * rdahi == 13 is UNPREDICTABLE; rdahi == 15 is a related |
108 | +} | 101 | + * encoding; rdalo always has bit 0 clear so cannot be 13 or 15. |
109 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 102 | + */ |
110 | index XXXXXXX..XXXXXXX 100644 | 103 | + if (a->rdahi == 13 || a->rdahi == 15) { |
111 | --- a/target/arm/translate-sve.c | ||
112 | +++ b/target/arm/translate-sve.c | ||
113 | @@ -XXX,XX +XXX,XX @@ static bool trans_BFDOT_zzxz(DisasContext *s, arg_rrxr_esz *a) | ||
114 | } | ||
115 | return true; | ||
116 | } | ||
117 | + | ||
118 | +static bool trans_BFMMLA(DisasContext *s, arg_rrrr_esz *a) | ||
119 | +{ | ||
120 | + if (!dc_isar_feature(aa64_sve_bf16, s)) { | ||
121 | + return false; | 104 | + return false; |
122 | + } | 105 | + } |
123 | + if (sve_access_check(s)) { | 106 | + if (!mve_eci_check(s) || !vfp_access_check(s)) { |
124 | + gen_gvec_ool_zzzz(s, gen_helper_gvec_bfmmla, | 107 | + return true; |
125 | + a->rd, a->rn, a->rm, a->ra, 0); | ||
126 | + } | 108 | + } |
109 | + | ||
110 | + /* | ||
111 | + * This insn is subject to beat-wise execution. Partial execution | ||
112 | + * of an A=0 (no-accumulate) insn which does not execute the first | ||
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); | ||
126 | + } | ||
127 | + | ||
128 | + qm = mve_qreg_ptr(a->qm); | ||
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); | ||
127 | + return true; | 144 | + return true; |
128 | +} | 145 | +} |
129 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
130 | index XXXXXXX..XXXXXXX 100644 | ||
131 | --- a/target/arm/vec_helper.c | ||
132 | +++ b/target/arm/vec_helper.c | ||
133 | @@ -XXX,XX +XXX,XX @@ static void do_mmla_b(void *vd, void *vn, void *vm, void *va, uint32_t desc, | ||
134 | * Process the entire segment at once, writing back the | ||
135 | * results only after we've consumed all of the inputs. | ||
136 | * | ||
137 | - * Key to indicies by column: | ||
138 | + * Key to indices by column: | ||
139 | * i j i j | ||
140 | */ | ||
141 | sum0 = a[H4(0 + 0)]; | ||
142 | @@ -XXX,XX +XXX,XX @@ void HELPER(gvec_bfdot_idx)(void *vd, void *vn, void *vm, | ||
143 | } | ||
144 | clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
145 | } | ||
146 | + | 146 | + |
147 | +void HELPER(gvec_bfmmla)(void *vd, void *vn, void *vm, void *va, uint32_t desc) | 147 | static bool do_1imm(DisasContext *s, arg_1imm *a, MVEGenOneOpImmFn *fn) |
148 | +{ | 148 | { |
149 | + intptr_t s, opr_sz = simd_oprsz(desc); | 149 | TCGv_ptr qd; |
150 | + float32 *d = vd, *a = va; | ||
151 | + uint32_t *n = vn, *m = vm; | ||
152 | + | ||
153 | + for (s = 0; s < opr_sz / 4; s += 4) { | ||
154 | + float32 sum00, sum01, sum10, sum11; | ||
155 | + | ||
156 | + /* | ||
157 | + * Process the entire segment at once, writing back the | ||
158 | + * results only after we've consumed all of the inputs. | ||
159 | + * | ||
160 | + * Key to indicies by column: | ||
161 | + * i j i k j k | ||
162 | + */ | ||
163 | + sum00 = a[s + H4(0 + 0)]; | ||
164 | + sum00 = bfdotadd(sum00, n[s + H4(0 + 0)], m[s + H4(0 + 0)]); | ||
165 | + sum00 = bfdotadd(sum00, n[s + H4(0 + 1)], m[s + H4(0 + 1)]); | ||
166 | + | ||
167 | + sum01 = a[s + H4(0 + 1)]; | ||
168 | + sum01 = bfdotadd(sum01, n[s + H4(0 + 0)], m[s + H4(2 + 0)]); | ||
169 | + sum01 = bfdotadd(sum01, n[s + H4(0 + 1)], m[s + H4(2 + 1)]); | ||
170 | + | ||
171 | + sum10 = a[s + H4(2 + 0)]; | ||
172 | + sum10 = bfdotadd(sum10, n[s + H4(2 + 0)], m[s + H4(0 + 0)]); | ||
173 | + sum10 = bfdotadd(sum10, n[s + H4(2 + 1)], m[s + H4(0 + 1)]); | ||
174 | + | ||
175 | + sum11 = a[s + H4(2 + 1)]; | ||
176 | + sum11 = bfdotadd(sum11, n[s + H4(2 + 0)], m[s + H4(2 + 0)]); | ||
177 | + sum11 = bfdotadd(sum11, n[s + H4(2 + 1)], m[s + H4(2 + 1)]); | ||
178 | + | ||
179 | + d[s + H4(0 + 0)] = sum00; | ||
180 | + d[s + H4(0 + 1)] = sum01; | ||
181 | + d[s + H4(2 + 0)] = sum10; | ||
182 | + d[s + H4(2 + 1)] = sum11; | ||
183 | + } | ||
184 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
185 | +} | ||
186 | -- | 150 | -- |
187 | 2.20.1 | 151 | 2.20.1 |
188 | 152 | ||
189 | 153 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 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 is BFCVT{N,T} for both AArch64 AdvSIMD and SVE, | 3 | and which operate only on general-purpose registers. They take up |
4 | and VCVT.BF16.F32 for AArch32 NEON. | 4 | the space which was previously UNPREDICTABLE MOVS and ORRS encodings |
5 | 5 | with Rm == 13 or 15. | |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Implement the long shifts by immediate, which perform shifts on a |
8 | Message-id: 20210525225817.400336-5-richard.henderson@linaro.org | 8 | pair of general-purpose registers treated as a 64-bit quantity, with |
9 | an immediate shift count between 1 and 32. | ||
10 | |||
11 | Awkwardly, because the MOVS and ORRS trans functions do not UNDEF for | ||
12 | the Rm==13,15 case, we need to explicitly emit code to UNDEF for the | ||
13 | cases where v8.1M now requires that. (Trying to change MOVS and ORRS | ||
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 | |||
9 | 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 | ||
10 | --- | 27 | --- |
11 | target/arm/helper-sve.h | 4 ++++ | 28 | target/arm/helper-mve.h | 3 ++ |
12 | target/arm/helper.h | 1 + | 29 | target/arm/translate.h | 1 + |
13 | target/arm/neon-dp.decode | 1 + | 30 | target/arm/t32.decode | 28 +++++++++++++ |
14 | target/arm/sve.decode | 2 ++ | 31 | target/arm/mve_helper.c | 10 +++++ |
15 | target/arm/sve_helper.c | 2 ++ | 32 | target/arm/translate.c | 90 +++++++++++++++++++++++++++++++++++++++++ |
16 | target/arm/translate-a64.c | 17 ++++++++++++++ | 33 | 5 files changed, 132 insertions(+) |
17 | target/arm/translate-neon.c | 45 +++++++++++++++++++++++++++++++++++++ | 34 | |
18 | target/arm/translate-sve.c | 16 +++++++++++++ | 35 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
19 | target/arm/vfp_helper.c | 7 ++++++ | 36 | index XXXXXXX..XXXXXXX 100644 |
20 | 9 files changed, 95 insertions(+) | 37 | --- a/target/arm/helper-mve.h |
21 | 38 | +++ b/target/arm/helper-mve.h | |
22 | diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h | 39 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshruntb, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
23 | index XXXXXXX..XXXXXXX 100644 | 40 | DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
24 | --- a/target/arm/helper-sve.h | 41 | |
25 | +++ b/target/arm/helper-sve.h | 42 | DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
26 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(sve_fcvt_hd, TCG_CALL_NO_RWG, | 43 | + |
27 | void, ptr, ptr, ptr, ptr, i32) | 44 | +DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
28 | DEF_HELPER_FLAGS_5(sve_fcvt_sd, TCG_CALL_NO_RWG, | 45 | +DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
29 | void, ptr, ptr, ptr, ptr, i32) | 46 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
30 | +DEF_HELPER_FLAGS_5(sve_bfcvt, TCG_CALL_NO_RWG, | 47 | index XXXXXXX..XXXXXXX 100644 |
31 | + void, ptr, ptr, ptr, ptr, i32) | 48 | --- a/target/arm/translate.h |
32 | 49 | +++ b/target/arm/translate.h | |
33 | DEF_HELPER_FLAGS_5(sve_fcvtzs_hh, TCG_CALL_NO_RWG, | 50 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); |
34 | void, ptr, ptr, ptr, ptr, i32) | 51 | typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); |
35 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(sve2_fcvtnt_sh, TCG_CALL_NO_RWG, | 52 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); |
36 | void, ptr, ptr, ptr, ptr, i32) | 53 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); |
37 | DEF_HELPER_FLAGS_5(sve2_fcvtnt_ds, TCG_CALL_NO_RWG, | 54 | +typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); |
38 | void, ptr, ptr, ptr, ptr, i32) | 55 | |
39 | +DEF_HELPER_FLAGS_5(sve_bfcvtnt, TCG_CALL_NO_RWG, | 56 | /** |
40 | + void, ptr, ptr, ptr, ptr, i32) | 57 | * arm_tbflags_from_tb: |
41 | 58 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode | |
42 | DEF_HELPER_FLAGS_5(sve2_fcvtlt_hs, TCG_CALL_NO_RWG, | 59 | index XXXXXXX..XXXXXXX 100644 |
43 | void, ptr, ptr, ptr, ptr, i32) | 60 | --- a/target/arm/t32.decode |
44 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 61 | +++ b/target/arm/t32.decode |
45 | index XXXXXXX..XXXXXXX 100644 | 62 | @@ -XXX,XX +XXX,XX @@ |
46 | --- a/target/arm/helper.h | 63 | &mcr !extern cp opc1 crn crm opc2 rt |
47 | +++ b/target/arm/helper.h | 64 | &mcrr !extern cp opc1 crm rt rt2 |
48 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_cmped, void, f64, f64, env) | 65 | |
49 | DEF_HELPER_2(vfp_fcvtds, f64, f32, env) | 66 | +&mve_shl_ri rdalo rdahi shim |
50 | DEF_HELPER_2(vfp_fcvtsd, f32, f64, env) | 67 | + |
51 | DEF_HELPER_FLAGS_2(bfcvt, TCG_CALL_NO_RWG, i32, f32, ptr) | 68 | +# rdahi: bits [3:1] from insn, bit 0 is 1 |
52 | +DEF_HELPER_FLAGS_2(bfcvt_pair, TCG_CALL_NO_RWG, i32, i64, ptr) | 69 | +# rdalo: bits [3:1] from insn, bit 0 is 0 |
53 | 70 | +%rdahi_9 9:3 !function=times_2_plus_1 | |
54 | DEF_HELPER_2(vfp_uitoh, f16, i32, ptr) | 71 | +%rdalo_17 17:3 !function=times_2 |
55 | DEF_HELPER_2(vfp_uitos, f32, i32, ptr) | 72 | + |
56 | diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode | 73 | # Data-processing (register) |
57 | index XXXXXXX..XXXXXXX 100644 | 74 | |
58 | --- a/target/arm/neon-dp.decode | 75 | %imm5_12_6 12:3 6:2 |
59 | +++ b/target/arm/neon-dp.decode | 76 | @@ -XXX,XX +XXX,XX @@ |
60 | @@ -XXX,XX +XXX,XX @@ Vimm_1r 1111 001 . 1 . 000 ... .... cmode:4 0 . op:1 1 .... @1reg_imm | 77 | @S_xrr_shi ....... .... . rn:4 .... .... .. shty:2 rm:4 \ |
61 | VRINTZ 1111 001 11 . 11 .. 10 .... 0 1011 . . 0 .... @2misc | 78 | &s_rrr_shi shim=%imm5_12_6 s=1 rd=0 |
62 | 79 | ||
63 | VCVT_F16_F32 1111 001 11 . 11 .. 10 .... 0 1100 0 . 0 .... @2misc_q0 | 80 | +@mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \ |
64 | + VCVT_B16_F32 1111 001 11 . 11 .. 10 .... 0 1100 1 . 0 .... @2misc_q0 | 81 | + &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 |
65 | 82 | + | |
66 | VRINTM 1111 001 11 . 11 .. 10 .... 0 1101 . . 0 .... @2misc | 83 | { |
67 | 84 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi | |
68 | diff --git a/target/arm/sve.decode b/target/arm/sve.decode | 85 | AND_rrri 1110101 0000 . .... 0 ... .... .... .... @s_rrr_shi |
69 | index XXXXXXX..XXXXXXX 100644 | 86 | } |
70 | --- a/target/arm/sve.decode | 87 | BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi |
71 | +++ b/target/arm/sve.decode | 88 | { |
72 | @@ -XXX,XX +XXX,XX @@ FNMLS_zpzzz 01100101 .. 1 ..... 111 ... ..... ..... @rdn_pg_rm_ra | 89 | + # The v8.1M MVE shift insns overlap in encoding with MOVS/ORRS |
73 | # SVE floating-point convert precision | 90 | + # and are distinguished by having Rm==13 or 15. Those are UNPREDICTABLE |
74 | FCVT_sh 01100101 10 0010 00 101 ... ..... ..... @rd_pg_rn_e0 | 91 | + # cases for MOVS/ORRS. We decode the MVE cases first, ensuring that |
75 | FCVT_hs 01100101 10 0010 01 101 ... ..... ..... @rd_pg_rn_e0 | 92 | + # they explicitly call unallocated_encoding() for cases that must UNDEF |
76 | +BFCVT 01100101 10 0010 10 101 ... ..... ..... @rd_pg_rn_e0 | 93 | + # (eg "using a new shift insn on a v8.1M CPU without MVE"), and letting |
77 | FCVT_dh 01100101 11 0010 00 101 ... ..... ..... @rd_pg_rn_e0 | 94 | + # the rest fall through (where ORR_rrri and MOV_rxri will end up |
78 | FCVT_hd 01100101 11 0010 01 101 ... ..... ..... @rd_pg_rn_e0 | 95 | + # handling them as r13 and r15 accesses with the same semantics as A32). |
79 | FCVT_ds 01100101 11 0010 10 101 ... ..... ..... @rd_pg_rn_e0 | 96 | + [ |
80 | @@ -XXX,XX +XXX,XX @@ RAX1 01000101 00 1 ..... 11110 1 ..... ..... @rd_rn_rm_e0 | 97 | + LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri |
81 | FCVTXNT_ds 01100100 00 0010 10 101 ... ..... ..... @rd_pg_rn_e0 | 98 | + LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri |
82 | FCVTX_ds 01100101 00 0010 10 101 ... ..... ..... @rd_pg_rn_e0 | 99 | + ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri |
83 | FCVTNT_sh 01100100 10 0010 00 101 ... ..... ..... @rd_pg_rn_e0 | 100 | + |
84 | +BFCVTNT 01100100 10 0010 10 101 ... ..... ..... @rd_pg_rn_e0 | 101 | + UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri |
85 | FCVTLT_hs 01100100 10 0010 01 101 ... ..... ..... @rd_pg_rn_e0 | 102 | + URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri |
86 | FCVTNT_ds 01100100 11 0010 10 101 ... ..... ..... @rd_pg_rn_e0 | 103 | + SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri |
87 | FCVTLT_sd 01100100 11 0010 11 101 ... ..... ..... @rd_pg_rn_e0 | 104 | + SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri |
88 | diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c | 105 | + ] |
89 | index XXXXXXX..XXXXXXX 100644 | 106 | + |
90 | --- a/target/arm/sve_helper.c | 107 | MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi |
91 | +++ b/target/arm/sve_helper.c | 108 | ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi |
92 | @@ -XXX,XX +XXX,XX @@ static inline uint64_t vfp_float64_to_uint64_rtz(float64 f, float_status *s) | 109 | } |
93 | 110 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c | |
94 | DO_ZPZ_FP(sve_fcvt_sh, uint32_t, H1_4, sve_f32_to_f16) | 111 | index XXXXXXX..XXXXXXX 100644 |
95 | DO_ZPZ_FP(sve_fcvt_hs, uint32_t, H1_4, sve_f16_to_f32) | 112 | --- a/target/arm/mve_helper.c |
96 | +DO_ZPZ_FP(sve_bfcvt, uint32_t, H1_4, float32_to_bfloat16) | 113 | +++ b/target/arm/mve_helper.c |
97 | DO_ZPZ_FP(sve_fcvt_dh, uint64_t, , sve_f64_to_f16) | 114 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_vshlc)(CPUARMState *env, void *vd, uint32_t rdm, |
98 | DO_ZPZ_FP(sve_fcvt_hd, uint64_t, , sve_f16_to_f64) | 115 | mve_advance_vpt(env); |
99 | DO_ZPZ_FP(sve_fcvt_ds, uint64_t, , float64_to_float32) | 116 | return rdm; |
100 | @@ -XXX,XX +XXX,XX @@ void HELPER(NAME)(void *vd, void *vn, void *vg, void *status, uint32_t desc) \ | 117 | } |
101 | } while (i != 0); \ | 118 | + |
102 | } | 119 | +uint64_t HELPER(mve_sqshll)(CPUARMState *env, uint64_t n, uint32_t shift) |
103 | 120 | +{ | |
104 | +DO_FCVTNT(sve_bfcvtnt, uint32_t, uint16_t, H1_4, H1_2, float32_to_bfloat16) | 121 | + return do_sqrshl_d(n, (int8_t)shift, false, &env->QF); |
105 | DO_FCVTNT(sve2_fcvtnt_sh, uint32_t, uint16_t, H1_4, H1_2, sve_f32_to_f16) | 122 | +} |
106 | DO_FCVTNT(sve2_fcvtnt_ds, uint64_t, uint32_t, , H1_4, float64_to_float32) | 123 | + |
107 | 124 | +uint64_t HELPER(mve_uqshll)(CPUARMState *env, uint64_t n, uint32_t shift) | |
108 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 125 | +{ |
109 | index XXXXXXX..XXXXXXX 100644 | 126 | + return do_uqrshl_d(n, (int8_t)shift, false, &env->QF); |
110 | --- a/target/arm/translate-a64.c | 127 | +} |
111 | +++ b/target/arm/translate-a64.c | 128 | diff --git a/target/arm/translate.c b/target/arm/translate.c |
112 | @@ -XXX,XX +XXX,XX @@ static void handle_2misc_narrow(DisasContext *s, bool scalar, | 129 | index XXXXXXX..XXXXXXX 100644 |
113 | tcg_temp_free_i32(ahp); | 130 | --- a/target/arm/translate.c |
114 | } | 131 | +++ b/target/arm/translate.c |
115 | break; | 132 | @@ -XXX,XX +XXX,XX @@ static bool trans_MOVT(DisasContext *s, arg_MOVW *a) |
116 | + case 0x36: /* BFCVTN, BFCVTN2 */ | ||
117 | + { | ||
118 | + TCGv_ptr fpst = fpstatus_ptr(FPST_FPCR); | ||
119 | + gen_helper_bfcvt_pair(tcg_res[pass], tcg_op, fpst); | ||
120 | + tcg_temp_free_ptr(fpst); | ||
121 | + } | ||
122 | + break; | ||
123 | case 0x56: /* FCVTXN, FCVTXN2 */ | ||
124 | /* 64 bit to 32 bit float conversion | ||
125 | * with von Neumann rounding (round to odd) | ||
126 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn) | ||
127 | } | ||
128 | handle_2misc_narrow(s, false, opcode, 0, is_q, size - 1, rn, rd); | ||
129 | return; | ||
130 | + case 0x36: /* BFCVTN, BFCVTN2 */ | ||
131 | + if (!dc_isar_feature(aa64_bf16, s) || size != 2) { | ||
132 | + unallocated_encoding(s); | ||
133 | + return; | ||
134 | + } | ||
135 | + if (!fp_access_check(s)) { | ||
136 | + return; | ||
137 | + } | ||
138 | + handle_2misc_narrow(s, false, opcode, 0, is_q, size - 1, rn, rd); | ||
139 | + return; | ||
140 | case 0x17: /* FCVTL, FCVTL2 */ | ||
141 | if (!fp_access_check(s)) { | ||
142 | return; | ||
143 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
144 | index XXXXXXX..XXXXXXX 100644 | ||
145 | --- a/target/arm/translate-neon.c | ||
146 | +++ b/target/arm/translate-neon.c | ||
147 | @@ -XXX,XX +XXX,XX @@ static bool trans_VSHLL(DisasContext *s, arg_2misc *a) | ||
148 | return true; | 133 | return true; |
149 | } | 134 | } |
150 | 135 | ||
151 | +static bool trans_VCVT_B16_F32(DisasContext *s, arg_2misc *a) | 136 | +/* |
152 | +{ | 137 | + * v8.1M MVE wide-shifts |
153 | + TCGv_ptr fpst; | 138 | + */ |
154 | + TCGv_i64 tmp; | 139 | +static bool do_mve_shl_ri(DisasContext *s, arg_mve_shl_ri *a, |
155 | + TCGv_i32 dst0, dst1; | 140 | + WideShiftImmFn *fn) |
156 | + | 141 | +{ |
157 | + if (!dc_isar_feature(aa32_bf16, s)) { | 142 | + TCGv_i64 rda; |
143 | + TCGv_i32 rdalo, rdahi; | ||
144 | + | ||
145 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
146 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
158 | + return false; | 147 | + return false; |
159 | + } | 148 | + } |
160 | + | 149 | + if (a->rdahi == 15) { |
161 | + /* UNDEF accesses to D16-D31 if they don't exist. */ | 150 | + /* These are a different encoding (SQSHL/SRSHR/UQSHL/URSHR) */ |
162 | + if (!dc_isar_feature(aa32_simd_r32, s) && | ||
163 | + ((a->vd | a->vm) & 0x10)) { | ||
164 | + return false; | 151 | + return false; |
165 | + } | 152 | + } |
166 | + | 153 | + if (!dc_isar_feature(aa32_mve, s) || |
167 | + if ((a->vm & 1) || (a->size != 1)) { | 154 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || |
168 | + return false; | 155 | + a->rdahi == 13) { |
169 | + } | 156 | + /* RdaHi == 13 is UNPREDICTABLE; we choose to UNDEF */ |
170 | + | 157 | + unallocated_encoding(s); |
171 | + if (!vfp_access_check(s)) { | ||
172 | + return true; | 158 | + return true; |
173 | + } | 159 | + } |
174 | + | 160 | + |
175 | + fpst = fpstatus_ptr(FPST_STD); | 161 | + if (a->shim == 0) { |
176 | + tmp = tcg_temp_new_i64(); | 162 | + a->shim = 32; |
177 | + dst0 = tcg_temp_new_i32(); | 163 | + } |
178 | + dst1 = tcg_temp_new_i32(); | 164 | + |
179 | + | 165 | + rda = tcg_temp_new_i64(); |
180 | + read_neon_element64(tmp, a->vm, 0, MO_64); | 166 | + rdalo = load_reg(s, a->rdalo); |
181 | + gen_helper_bfcvt_pair(dst0, tmp, fpst); | 167 | + rdahi = load_reg(s, a->rdahi); |
182 | + | 168 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); |
183 | + read_neon_element64(tmp, a->vm, 1, MO_64); | 169 | + |
184 | + gen_helper_bfcvt_pair(dst1, tmp, fpst); | 170 | + fn(rda, rda, a->shim); |
185 | + | 171 | + |
186 | + write_neon_element32(dst0, a->vd, 0, MO_32); | 172 | + tcg_gen_extrl_i64_i32(rdalo, rda); |
187 | + write_neon_element32(dst1, a->vd, 1, MO_32); | 173 | + tcg_gen_extrh_i64_i32(rdahi, rda); |
188 | + | 174 | + store_reg(s, a->rdalo, rdalo); |
189 | + tcg_temp_free_i64(tmp); | 175 | + store_reg(s, a->rdahi, rdahi); |
190 | + tcg_temp_free_i32(dst0); | 176 | + tcg_temp_free_i64(rda); |
191 | + tcg_temp_free_i32(dst1); | 177 | + |
192 | + tcg_temp_free_ptr(fpst); | ||
193 | + return true; | 178 | + return true; |
194 | +} | 179 | +} |
195 | + | 180 | + |
196 | static bool trans_VCVT_F16_F32(DisasContext *s, arg_2misc *a) | 181 | +static bool trans_ASRL_ri(DisasContext *s, arg_mve_shl_ri *a) |
197 | { | 182 | +{ |
198 | TCGv_ptr fpst; | 183 | + return do_mve_shl_ri(s, a, tcg_gen_sari_i64); |
199 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | 184 | +} |
200 | index XXXXXXX..XXXXXXX 100644 | 185 | + |
201 | --- a/target/arm/translate-sve.c | 186 | +static bool trans_LSLL_ri(DisasContext *s, arg_mve_shl_ri *a) |
202 | +++ b/target/arm/translate-sve.c | 187 | +{ |
203 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVT_hs(DisasContext *s, arg_rpr_esz *a) | 188 | + return do_mve_shl_ri(s, a, tcg_gen_shli_i64); |
204 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvt_hs); | 189 | +} |
205 | } | 190 | + |
206 | 191 | +static bool trans_LSRL_ri(DisasContext *s, arg_mve_shl_ri *a) | |
207 | +static bool trans_BFCVT(DisasContext *s, arg_rpr_esz *a) | 192 | +{ |
208 | +{ | 193 | + return do_mve_shl_ri(s, a, tcg_gen_shri_i64); |
209 | + if (!dc_isar_feature(aa64_sve_bf16, s)) { | 194 | +} |
210 | + return false; | 195 | + |
211 | + } | 196 | +static void gen_mve_sqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift) |
212 | + return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_bfcvt); | 197 | +{ |
213 | +} | 198 | + gen_helper_mve_sqshll(r, cpu_env, n, tcg_constant_i32(shift)); |
214 | + | 199 | +} |
215 | static bool trans_FCVT_dh(DisasContext *s, arg_rpr_esz *a) | 200 | + |
216 | { | 201 | +static bool trans_SQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a) |
217 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_fcvt_dh); | 202 | +{ |
218 | @@ -XXX,XX +XXX,XX @@ static bool trans_FCVTNT_sh(DisasContext *s, arg_rpr_esz *a) | 203 | + return do_mve_shl_ri(s, a, gen_mve_sqshll); |
219 | return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve2_fcvtnt_sh); | 204 | +} |
220 | } | 205 | + |
221 | 206 | +static void gen_mve_uqshll(TCGv_i64 r, TCGv_i64 n, int64_t shift) | |
222 | +static bool trans_BFCVTNT(DisasContext *s, arg_rpr_esz *a) | 207 | +{ |
223 | +{ | 208 | + gen_helper_mve_uqshll(r, cpu_env, n, tcg_constant_i32(shift)); |
224 | + if (!dc_isar_feature(aa64_sve_bf16, s)) { | 209 | +} |
225 | + return false; | 210 | + |
226 | + } | 211 | +static bool trans_UQSHLL_ri(DisasContext *s, arg_mve_shl_ri *a) |
227 | + return do_zpz_ptr(s, a->rd, a->rn, a->pg, false, gen_helper_sve_bfcvtnt); | 212 | +{ |
228 | +} | 213 | + return do_mve_shl_ri(s, a, gen_mve_uqshll); |
229 | + | 214 | +} |
230 | static bool trans_FCVTNT_ds(DisasContext *s, arg_rpr_esz *a) | 215 | + |
231 | { | 216 | +static bool trans_SRSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) |
232 | if (!dc_isar_feature(aa64_sve2, s)) { | 217 | +{ |
233 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 218 | + return do_mve_shl_ri(s, a, gen_srshr64_i64); |
234 | index XXXXXXX..XXXXXXX 100644 | 219 | +} |
235 | --- a/target/arm/vfp_helper.c | 220 | + |
236 | +++ b/target/arm/vfp_helper.c | 221 | +static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) |
237 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(bfcvt)(float32 x, void *status) | 222 | +{ |
238 | return float32_to_bfloat16(x, status); | 223 | + return do_mve_shl_ri(s, a, gen_urshr64_i64); |
239 | } | ||
240 | |||
241 | +uint32_t HELPER(bfcvt_pair)(uint64_t pair, void *status) | ||
242 | +{ | ||
243 | + bfloat16 lo = float32_to_bfloat16(extract64(pair, 0, 32), status); | ||
244 | + bfloat16 hi = float32_to_bfloat16(extract64(pair, 32, 32), status); | ||
245 | + return deposit32(lo, 16, 16, hi); | ||
246 | +} | 224 | +} |
247 | + | 225 | + |
248 | /* | 226 | /* |
249 | * VFP3 fixed point conversion. The AArch32 versions of fix-to-float | 227 | * Multiply and multiply accumulate |
250 | * must always round-to-nearest; the AArch64 ones honour the FPSCR | 228 | */ |
251 | -- | 229 | -- |
252 | 2.20.1 | 230 | 2.20.1 |
253 | 231 | ||
254 | 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 | This is the 64-bit BFCVT and the 32-bit VCVT{B,T}.BF16.F32. | 3 | the shift count in another general-purpose register, which might be |
4 | 4 | either positive or negative. | |
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 5 | |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Like the long-shifts-by-immediate, these encodings sit in the space |
7 | Message-id: 20210525225817.400336-4-richard.henderson@linaro.org | 7 | that was previously the UNPREDICTABLE MOVS/ORRS with Rm==13,15. |
8 | Because LSLL_rr and ASRL_rr overlap with both MOV_rxri/ORR_rrri and | ||
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 | |||
8 | 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 | ||
9 | --- | 15 | --- |
10 | target/arm/helper.h | 1 + | 16 | target/arm/helper-mve.h | 6 +++ |
11 | target/arm/vfp.decode | 2 ++ | 17 | target/arm/translate.h | 1 + |
12 | target/arm/translate-a64.c | 19 +++++++++++++++++++ | 18 | target/arm/t32.decode | 16 +++++-- |
13 | target/arm/translate-vfp.c | 24 ++++++++++++++++++++++++ | 19 | target/arm/mve_helper.c | 93 +++++++++++++++++++++++++++++++++++++++++ |
14 | target/arm/vfp_helper.c | 5 +++++ | 20 | target/arm/translate.c | 69 ++++++++++++++++++++++++++++++ |
15 | 5 files changed, 51 insertions(+) | 21 | 5 files changed, 182 insertions(+), 3 deletions(-) |
16 | 22 | ||
17 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 23 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
18 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.h | 25 | --- a/target/arm/helper-mve.h |
20 | +++ b/target/arm/helper.h | 26 | +++ b/target/arm/helper-mve.h |
21 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_cmped, void, f64, f64, env) | 27 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(mve_vqrshrunth, TCG_CALL_NO_WG, void, env, ptr, ptr, i32) |
22 | 28 | ||
23 | DEF_HELPER_2(vfp_fcvtds, f64, f32, env) | 29 | DEF_HELPER_FLAGS_4(mve_vshlc, TCG_CALL_NO_WG, i32, env, ptr, i32, i32) |
24 | DEF_HELPER_2(vfp_fcvtsd, f32, f64, env) | 30 | |
25 | +DEF_HELPER_FLAGS_2(bfcvt, TCG_CALL_NO_RWG, i32, f32, ptr) | 31 | +DEF_HELPER_FLAGS_3(mve_sshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) |
26 | 32 | +DEF_HELPER_FLAGS_3(mve_ushll, TCG_CALL_NO_RWG, i64, env, i64, i32) | |
27 | DEF_HELPER_2(vfp_uitoh, f16, i32, ptr) | 33 | DEF_HELPER_FLAGS_3(mve_sqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
28 | DEF_HELPER_2(vfp_uitos, f32, i32, ptr) | 34 | DEF_HELPER_FLAGS_3(mve_uqshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
29 | diff --git a/target/arm/vfp.decode b/target/arm/vfp.decode | 35 | +DEF_HELPER_FLAGS_3(mve_sqrshrl, TCG_CALL_NO_RWG, i64, env, i64, i32) |
30 | index XXXXXXX..XXXXXXX 100644 | 36 | +DEF_HELPER_FLAGS_3(mve_uqrshll, TCG_CALL_NO_RWG, i64, env, i64, i32) |
31 | --- a/target/arm/vfp.decode | 37 | +DEF_HELPER_FLAGS_3(mve_sqrshrl48, TCG_CALL_NO_RWG, i64, env, i64, i32) |
32 | +++ b/target/arm/vfp.decode | 38 | +DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) |
33 | @@ -XXX,XX +XXX,XX @@ VCVT_f64_f16 ---- 1110 1.11 0010 .... 1011 t:1 1.0 .... \ | 39 | diff --git a/target/arm/translate.h b/target/arm/translate.h |
34 | 40 | index XXXXXXX..XXXXXXX 100644 | |
35 | # VCVTB and VCVTT to f16: Vd format is always vd_sp; | 41 | --- a/target/arm/translate.h |
36 | # Vm format depends on size bit | 42 | +++ b/target/arm/translate.h |
37 | +VCVT_b16_f32 ---- 1110 1.11 0011 .... 1001 t:1 1.0 .... \ | 43 | @@ -XXX,XX +XXX,XX @@ typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); |
38 | + vd=%vd_sp vm=%vm_sp | 44 | typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); |
39 | VCVT_f16_f32 ---- 1110 1.11 0011 .... 1010 t:1 1.0 .... \ | 45 | typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp); |
40 | vd=%vd_sp vm=%vm_sp | 46 | typedef void WideShiftImmFn(TCGv_i64, TCGv_i64, int64_t shift); |
41 | VCVT_f16_f64 ---- 1110 1.11 0011 .... 1011 t:1 1.0 .... \ | 47 | +typedef void WideShiftFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i32); |
42 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 48 | |
43 | index XXXXXXX..XXXXXXX 100644 | 49 | /** |
44 | --- a/target/arm/translate-a64.c | 50 | * arm_tbflags_from_tb: |
45 | +++ b/target/arm/translate-a64.c | 51 | diff --git a/target/arm/t32.decode b/target/arm/t32.decode |
46 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn) | 52 | index XXXXXXX..XXXXXXX 100644 |
47 | case 0x3: /* FSQRT */ | 53 | --- a/target/arm/t32.decode |
48 | gen_helper_vfp_sqrts(tcg_res, tcg_op, cpu_env); | 54 | +++ b/target/arm/t32.decode |
49 | goto done; | 55 | @@ -XXX,XX +XXX,XX @@ |
50 | + case 0x6: /* BFCVT */ | 56 | &mcrr !extern cp opc1 crm rt rt2 |
51 | + gen_fpst = gen_helper_bfcvt; | 57 | |
52 | + break; | 58 | &mve_shl_ri rdalo rdahi shim |
53 | case 0x8: /* FRINTN */ | 59 | +&mve_shl_rr rdalo rdahi rm |
54 | case 0x9: /* FRINTP */ | 60 | |
55 | case 0xa: /* FRINTM */ | 61 | # rdahi: bits [3:1] from insn, bit 0 is 1 |
56 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn) | 62 | # rdalo: bits [3:1] from insn, bit 0 is 0 |
57 | } | 63 | @@ -XXX,XX +XXX,XX @@ |
58 | break; | 64 | |
59 | 65 | @mve_shl_ri ....... .... . ... . . ... ... . .. .. .... \ | |
60 | + case 0x6: | 66 | &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 |
61 | + switch (type) { | 67 | +@mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \ |
62 | + case 1: /* BFCVT */ | 68 | + &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 |
63 | + if (!dc_isar_feature(aa64_bf16, s)) { | 69 | |
64 | + goto do_unallocated; | 70 | { |
65 | + } | 71 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi |
66 | + if (!fp_access_check(s)) { | 72 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi |
67 | + return; | 73 | URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri |
68 | + } | 74 | SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri |
69 | + handle_fp_1src_single(s, opcode, rd, rn); | 75 | SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri |
70 | + break; | 76 | + |
71 | + default: | 77 | + LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr |
72 | + goto do_unallocated; | 78 | + ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr |
73 | + } | 79 | + UQRSHLL64_rr 1110101 0010 1 ... 1 .... ... 1 0000 1101 @mve_shl_rr |
74 | + break; | 80 | + SQRSHRL64_rr 1110101 0010 1 ... 1 .... ... 1 0010 1101 @mve_shl_rr |
75 | + | 81 | + UQRSHLL48_rr 1110101 0010 1 ... 1 .... ... 1 1000 1101 @mve_shl_rr |
76 | default: | 82 | + SQRSHRL48_rr 1110101 0010 1 ... 1 .... ... 1 1010 1101 @mve_shl_rr |
77 | do_unallocated: | 83 | ] |
78 | unallocated_encoding(s); | 84 | |
79 | diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c | 85 | MOV_rxri 1110101 0010 . 1111 0 ... .... .... .... @s_rxr_shi |
80 | index XXXXXXX..XXXXXXX 100644 | 86 | ORR_rrri 1110101 0010 . .... 0 ... .... .... .... @s_rrr_shi |
81 | --- a/target/arm/translate-vfp.c | 87 | + |
82 | +++ b/target/arm/translate-vfp.c | 88 | + # v8.1M CSEL and friends |
83 | @@ -XXX,XX +XXX,XX @@ static bool trans_VCVT_f64_f16(DisasContext *s, arg_VCVT_f64_f16 *a) | 89 | + CSEL 1110101 0010 1 rn:4 10 op:2 rd:4 fcond:4 rm:4 |
84 | return true; | 90 | } |
85 | } | 91 | { |
86 | 92 | MVN_rxri 1110101 0011 . 1111 0 ... .... .... .... @s_rxr_shi | |
87 | +static bool trans_VCVT_b16_f32(DisasContext *s, arg_VCVT_b16_f32 *a) | 93 | @@ -XXX,XX +XXX,XX @@ SBC_rrri 1110101 1011 . .... 0 ... .... .... .... @s_rrr_shi |
88 | +{ | 94 | } |
89 | + TCGv_ptr fpst; | 95 | RSB_rrri 1110101 1110 . .... 0 ... .... .... .... @s_rrr_shi |
90 | + TCGv_i32 tmp; | 96 | |
91 | + | 97 | -# v8.1M CSEL and friends |
92 | + if (!dc_isar_feature(aa32_bf16, s)) { | 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 | +} | ||
211 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
212 | index XXXXXXX..XXXXXXX 100644 | ||
213 | --- a/target/arm/translate.c | ||
214 | +++ b/target/arm/translate.c | ||
215 | @@ -XXX,XX +XXX,XX @@ static bool trans_URSHRL_ri(DisasContext *s, arg_mve_shl_ri *a) | ||
216 | return do_mve_shl_ri(s, a, gen_urshr64_i64); | ||
217 | } | ||
218 | |||
219 | +static bool do_mve_shl_rr(DisasContext *s, arg_mve_shl_rr *a, WideShiftFn *fn) | ||
220 | +{ | ||
221 | + TCGv_i64 rda; | ||
222 | + TCGv_i32 rdalo, rdahi; | ||
223 | + | ||
224 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { | ||
225 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
93 | + return false; | 226 | + return false; |
94 | + } | 227 | + } |
95 | + | 228 | + if (a->rdahi == 15) { |
96 | + if (!vfp_access_check(s)) { | 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); | ||
97 | + return true; | 238 | + return true; |
98 | + } | 239 | + } |
99 | + | 240 | + |
100 | + fpst = fpstatus_ptr(FPST_FPCR); | 241 | + rda = tcg_temp_new_i64(); |
101 | + tmp = tcg_temp_new_i32(); | 242 | + rdalo = load_reg(s, a->rdalo); |
102 | + | 243 | + rdahi = load_reg(s, a->rdahi); |
103 | + vfp_load_reg32(tmp, a->vm); | 244 | + tcg_gen_concat_i32_i64(rda, rdalo, rdahi); |
104 | + gen_helper_bfcvt(tmp, tmp, fpst); | 245 | + |
105 | + tcg_gen_st16_i32(tmp, cpu_env, vfp_f16_offset(a->vd, a->t)); | 246 | + /* The helper takes care of the sign-extension of the low 8 bits of Rm */ |
106 | + tcg_temp_free_ptr(fpst); | 247 | + fn(rda, cpu_env, rda, cpu_R[a->rm]); |
107 | + tcg_temp_free_i32(tmp); | 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 | + | ||
108 | + return true; | 255 | + return true; |
109 | +} | 256 | +} |
110 | + | 257 | + |
111 | static bool trans_VCVT_f16_f32(DisasContext *s, arg_VCVT_f16_f32 *a) | 258 | +static bool trans_LSLL_rr(DisasContext *s, arg_mve_shl_rr *a) |
112 | { | 259 | +{ |
113 | TCGv_ptr fpst; | 260 | + return do_mve_shl_rr(s, a, gen_helper_mve_ushll); |
114 | diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c | 261 | +} |
115 | index XXXXXXX..XXXXXXX 100644 | 262 | + |
116 | --- a/target/arm/vfp_helper.c | 263 | +static bool trans_ASRL_rr(DisasContext *s, arg_mve_shl_rr *a) |
117 | +++ b/target/arm/vfp_helper.c | 264 | +{ |
118 | @@ -XXX,XX +XXX,XX @@ float32 VFP_HELPER(fcvts, d)(float64 x, CPUARMState *env) | 265 | + return do_mve_shl_rr(s, a, gen_helper_mve_sshrl); |
119 | return float64_to_float32(x, &env->vfp.fp_status); | 266 | +} |
120 | } | 267 | + |
121 | 268 | +static bool trans_UQRSHLL64_rr(DisasContext *s, arg_mve_shl_rr *a) | |
122 | +uint32_t HELPER(bfcvt)(float32 x, void *status) | 269 | +{ |
123 | +{ | 270 | + return do_mve_shl_rr(s, a, gen_helper_mve_uqrshll); |
124 | + return float32_to_bfloat16(x, status); | 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); | ||
125 | +} | 286 | +} |
126 | + | 287 | + |
127 | /* | 288 | /* |
128 | * VFP3 fixed point conversion. The AArch32 versions of fix-to-float | 289 | * Multiply and multiply accumulate |
129 | * must always round-to-nearest; the AArch64 ones honour the FPSCR | 290 | */ |
130 | -- | 291 | -- |
131 | 2.20.1 | 292 | 2.20.1 |
132 | 293 | ||
133 | 294 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | For Arm BFDOT and BFMMLA, we need a version of round-to-odd | ||
4 | that overflows to infinity, instead of the max normal number. | ||
5 | |||
6 | Cc: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210525225817.400336-6-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/fpu/softfloat-types.h | 4 +++- | ||
13 | fpu/softfloat-parts.c.inc | 6 ++++-- | ||
14 | 2 files changed, 7 insertions(+), 3 deletions(-) | ||
15 | |||
16 | diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/fpu/softfloat-types.h | ||
19 | +++ b/include/fpu/softfloat-types.h | ||
20 | @@ -XXX,XX +XXX,XX @@ typedef enum __attribute__((__packed__)) { | ||
21 | float_round_up = 2, | ||
22 | float_round_to_zero = 3, | ||
23 | float_round_ties_away = 4, | ||
24 | - /* Not an IEEE rounding mode: round to the closest odd mantissa value */ | ||
25 | + /* Not an IEEE rounding mode: round to closest odd, overflow to max */ | ||
26 | float_round_to_odd = 5, | ||
27 | + /* Not an IEEE rounding mode: round to closest odd, overflow to inf */ | ||
28 | + float_round_to_odd_inf = 6, | ||
29 | } FloatRoundMode; | ||
30 | |||
31 | /* | ||
32 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/fpu/softfloat-parts.c.inc | ||
35 | +++ b/fpu/softfloat-parts.c.inc | ||
36 | @@ -XXX,XX +XXX,XX @@ static void partsN(uncanon)(FloatPartsN *p, float_status *s, | ||
37 | g_assert_not_reached(); | ||
38 | } | ||
39 | |||
40 | + overflow_norm = false; | ||
41 | switch (s->float_rounding_mode) { | ||
42 | case float_round_nearest_even: | ||
43 | - overflow_norm = false; | ||
44 | inc = ((p->frac_lo & roundeven_mask) != frac_lsbm1 ? frac_lsbm1 : 0); | ||
45 | break; | ||
46 | case float_round_ties_away: | ||
47 | - overflow_norm = false; | ||
48 | inc = frac_lsbm1; | ||
49 | break; | ||
50 | case float_round_to_zero: | ||
51 | @@ -XXX,XX +XXX,XX @@ static void partsN(uncanon)(FloatPartsN *p, float_status *s, | ||
52 | break; | ||
53 | case float_round_to_odd: | ||
54 | overflow_norm = true; | ||
55 | + /* fall through */ | ||
56 | + case float_round_to_odd_inf: | ||
57 | inc = p->frac_lo & frac_lsb ? 0 : round_mask; | ||
58 | break; | ||
59 | default: | ||
60 | @@ -XXX,XX +XXX,XX @@ static void partsN(uncanon)(FloatPartsN *p, float_status *s, | ||
61 | ? frac_lsbm1 : 0); | ||
62 | break; | ||
63 | case float_round_to_odd: | ||
64 | + case float_round_to_odd_inf: | ||
65 | inc = p->frac_lo & frac_lsb ? 0 : round_mask; | ||
66 | break; | ||
67 | default: | ||
68 | -- | ||
69 | 2.20.1 | ||
70 | |||
71 | diff view generated by jsdifflib |
1 | From: Alexander Graf <agraf@csgraf.de> | 1 | Implement the MVE shifts by immediate, which perform shifts |
---|---|---|---|
2 | 2 | on a single general-purpose register. | |
3 | Until now, Hypervisor.framework has only been available on x86_64 systems. | 3 | |
4 | With Apple Silicon shipping now, it extends its reach to aarch64. To | 4 | These patterns overlap with the long-shift-by-immediates, |
5 | prepare for support for multiple architectures, let's start moving common | 5 | so we have to rearrange the grouping a little here. |
6 | code out into its own accel directory. | 6 | |
7 | |||
8 | This patch splits the vcpu init and destroy functions into a generic and | ||
9 | an architecture specific portion. This also allows us to move the generic | ||
10 | functions into the generic hvf code, removing exported functions. | ||
11 | |||
12 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
13 | Reviewed-by: Sergio Lopez <slp@redhat.com> | ||
14 | Message-id: 20210519202253.76782-8-agraf@csgraf.de | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | 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 | ||
17 | --- | 10 | --- |
18 | accel/hvf/hvf-accel-ops.h | 2 -- | 11 | target/arm/helper-mve.h | 3 ++ |
19 | include/sysemu/hvf_int.h | 2 ++ | 12 | target/arm/translate.h | 1 + |
20 | accel/hvf/hvf-accel-ops.c | 30 ++++++++++++++++++++++++++++++ | 13 | target/arm/t32.decode | 31 ++++++++++++++----- |
21 | target/i386/hvf/hvf.c | 23 ++--------------------- | 14 | target/arm/mve_helper.c | 10 ++++++ |
22 | 4 files changed, 34 insertions(+), 23 deletions(-) | 15 | target/arm/translate.c | 68 +++++++++++++++++++++++++++++++++++++++-- |
23 | 16 | 5 files changed, 104 insertions(+), 9 deletions(-) | |
24 | diff --git a/accel/hvf/hvf-accel-ops.h b/accel/hvf/hvf-accel-ops.h | 17 | |
25 | index XXXXXXX..XXXXXXX 100644 | 18 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
26 | --- a/accel/hvf/hvf-accel-ops.h | 19 | index XXXXXXX..XXXXXXX 100644 |
27 | +++ b/accel/hvf/hvf-accel-ops.h | 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 | ||
28 | @@ -XXX,XX +XXX,XX @@ | 45 | @@ -XXX,XX +XXX,XX @@ |
29 | 46 | ||
30 | #include "sysemu/cpus.h" | 47 | &mve_shl_ri rdalo rdahi shim |
31 | 48 | &mve_shl_rr rdalo rdahi rm | |
32 | -int hvf_init_vcpu(CPUState *); | 49 | +&mve_sh_ri rda shim |
33 | int hvf_vcpu_exec(CPUState *); | 50 | |
34 | void hvf_cpu_synchronize_state(CPUState *); | 51 | # rdahi: bits [3:1] from insn, bit 0 is 1 |
35 | void hvf_cpu_synchronize_post_reset(CPUState *); | 52 | # rdalo: bits [3:1] from insn, bit 0 is 0 |
36 | void hvf_cpu_synchronize_post_init(CPUState *); | 53 | @@ -XXX,XX +XXX,XX @@ |
37 | void hvf_cpu_synchronize_pre_loadvm(CPUState *); | 54 | &mve_shl_ri shim=%imm5_12_6 rdalo=%rdalo_17 rdahi=%rdahi_9 |
38 | -void hvf_vcpu_destroy(CPUState *); | 55 | @mve_shl_rr ....... .... . ... . rm:4 ... . .. .. .... \ |
39 | 56 | &mve_shl_rr rdalo=%rdalo_17 rdahi=%rdahi_9 | |
40 | #endif /* HVF_CPUS_H */ | 57 | +@mve_sh_ri ....... .... . rda:4 . ... ... . .. .. .... \ |
41 | diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h | 58 | + &mve_sh_ri shim=%imm5_12_6 |
42 | index XXXXXXX..XXXXXXX 100644 | 59 | |
43 | --- a/include/sysemu/hvf_int.h | 60 | { |
44 | +++ b/include/sysemu/hvf_int.h | 61 | TST_xrri 1110101 0000 1 .... 0 ... 1111 .... .... @S_xrr_shi |
45 | @@ -XXX,XX +XXX,XX @@ struct HVFState { | 62 | @@ -XXX,XX +XXX,XX @@ BIC_rrri 1110101 0001 . .... 0 ... .... .... .... @s_rrr_shi |
46 | extern HVFState *hvf_state; | 63 | # the rest fall through (where ORR_rrri and MOV_rxri will end up |
47 | 64 | # handling them as r13 and r15 accesses with the same semantics as A32). | |
48 | void assert_hvf_ok(hv_return_t ret); | 65 | [ |
49 | +int hvf_arch_init_vcpu(CPUState *cpu); | 66 | - LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri |
50 | +void hvf_arch_vcpu_destroy(CPUState *cpu); | 67 | - LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri |
51 | hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); | 68 | - ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri |
52 | int hvf_put_registers(CPUState *); | 69 | + { |
53 | int hvf_get_registers(CPUState *); | 70 | + UQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 00 1111 @mve_sh_ri |
54 | diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c | 71 | + LSLL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 00 1111 @mve_shl_ri |
55 | index XXXXXXX..XXXXXXX 100644 | 72 | + UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri |
56 | --- a/accel/hvf/hvf-accel-ops.c | 73 | + } |
57 | +++ b/accel/hvf/hvf-accel-ops.c | 74 | |
58 | @@ -XXX,XX +XXX,XX @@ static void hvf_type_init(void) | 75 | - UQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 00 1111 @mve_shl_ri |
59 | 76 | - URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri | |
60 | type_init(hvf_type_init); | 77 | - SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri |
61 | 78 | - SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri | |
62 | +static void hvf_vcpu_destroy(CPUState *cpu) | 79 | + { |
63 | +{ | 80 | + URSHR_ri 1110101 0010 1 .... 0 ... 1111 .. 01 1111 @mve_sh_ri |
64 | + hv_return_t ret = hv_vcpu_destroy(cpu->hvf_fd); | 81 | + LSRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 01 1111 @mve_shl_ri |
65 | + assert_hvf_ok(ret); | 82 | + URSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 01 1111 @mve_shl_ri |
66 | + | 83 | + } |
67 | + hvf_arch_vcpu_destroy(cpu); | 84 | + |
68 | +} | 85 | + { |
69 | + | 86 | + SRSHR_ri 1110101 0010 1 .... 0 ... 1111 .. 10 1111 @mve_sh_ri |
70 | +static int hvf_init_vcpu(CPUState *cpu) | 87 | + ASRL_ri 1110101 0010 1 ... 0 0 ... ... 1 .. 10 1111 @mve_shl_ri |
71 | +{ | 88 | + SRSHRL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 10 1111 @mve_shl_ri |
72 | + int r; | 89 | + } |
73 | + | 90 | + |
74 | + /* init cpu signals */ | 91 | + { |
75 | + sigset_t set; | 92 | + SQSHL_ri 1110101 0010 1 .... 0 ... 1111 .. 11 1111 @mve_sh_ri |
76 | + struct sigaction sigact; | 93 | + SQSHLL_ri 1110101 0010 1 ... 1 0 ... ... 1 .. 11 1111 @mve_shl_ri |
77 | + | 94 | + } |
78 | + memset(&sigact, 0, sizeof(sigact)); | 95 | |
79 | + sigact.sa_handler = dummy_signal; | 96 | LSLL_rr 1110101 0010 1 ... 0 .... ... 1 0000 1101 @mve_shl_rr |
80 | + sigaction(SIG_IPI, &sigact, NULL); | 97 | ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr |
81 | + | 98 | diff --git a/target/arm/mve_helper.c b/target/arm/mve_helper.c |
82 | + pthread_sigmask(SIG_BLOCK, NULL, &set); | 99 | index XXXXXXX..XXXXXXX 100644 |
83 | + sigdelset(&set, SIG_IPI); | 100 | --- a/target/arm/mve_helper.c |
84 | + | 101 | +++ b/target/arm/mve_helper.c |
85 | + r = hv_vcpu_create((hv_vcpuid_t *)&cpu->hvf_fd, HV_VCPU_DEFAULT); | 102 | @@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mve_uqrshll48)(CPUARMState *env, uint64_t n, uint32_t shift) |
86 | + cpu->vcpu_dirty = 1; | 103 | { |
87 | + assert_hvf_ok(r); | 104 | return do_uqrshl48_d(n, (int8_t)shift, true, &env->QF); |
88 | + | 105 | } |
89 | + return hvf_arch_init_vcpu(cpu); | 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); | ||
90 | +} | 206 | +} |
91 | + | 207 | + |
92 | /* | 208 | /* |
93 | * The HVF-specific vCPU thread function. This one should only run when the host | 209 | * Multiply and multiply accumulate |
94 | * CPU supports the VMX "unrestricted guest" feature. | 210 | */ |
95 | diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c | ||
96 | index XXXXXXX..XXXXXXX 100644 | ||
97 | --- a/target/i386/hvf/hvf.c | ||
98 | +++ b/target/i386/hvf/hvf.c | ||
99 | @@ -XXX,XX +XXX,XX @@ static bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, uint64_t ept_qual) | ||
100 | return false; | ||
101 | } | ||
102 | |||
103 | -void hvf_vcpu_destroy(CPUState *cpu) | ||
104 | +void hvf_arch_vcpu_destroy(CPUState *cpu) | ||
105 | { | ||
106 | X86CPU *x86_cpu = X86_CPU(cpu); | ||
107 | CPUX86State *env = &x86_cpu->env; | ||
108 | |||
109 | - hv_return_t ret = hv_vcpu_destroy((hv_vcpuid_t)cpu->hvf_fd); | ||
110 | g_free(env->hvf_mmio_buf); | ||
111 | - assert_hvf_ok(ret); | ||
112 | } | ||
113 | |||
114 | static void init_tsc_freq(CPUX86State *env) | ||
115 | @@ -XXX,XX +XXX,XX @@ static inline bool apic_bus_freq_is_known(CPUX86State *env) | ||
116 | return env->apic_bus_freq != 0; | ||
117 | } | ||
118 | |||
119 | -int hvf_init_vcpu(CPUState *cpu) | ||
120 | +int hvf_arch_init_vcpu(CPUState *cpu) | ||
121 | { | ||
122 | - | ||
123 | X86CPU *x86cpu = X86_CPU(cpu); | ||
124 | CPUX86State *env = &x86cpu->env; | ||
125 | - int r; | ||
126 | - | ||
127 | - /* init cpu signals */ | ||
128 | - sigset_t set; | ||
129 | - struct sigaction sigact; | ||
130 | - | ||
131 | - memset(&sigact, 0, sizeof(sigact)); | ||
132 | - sigact.sa_handler = dummy_signal; | ||
133 | - sigaction(SIG_IPI, &sigact, NULL); | ||
134 | - | ||
135 | - pthread_sigmask(SIG_BLOCK, NULL, &set); | ||
136 | - sigdelset(&set, SIG_IPI); | ||
137 | |||
138 | init_emu(); | ||
139 | init_decoder(); | ||
140 | @@ -XXX,XX +XXX,XX @@ int hvf_init_vcpu(CPUState *cpu) | ||
141 | } | ||
142 | } | ||
143 | |||
144 | - r = hv_vcpu_create((hv_vcpuid_t *)&cpu->hvf_fd, HV_VCPU_DEFAULT); | ||
145 | - cpu->vcpu_dirty = 1; | ||
146 | - assert_hvf_ok(r); | ||
147 | - | ||
148 | if (hv_vmx_read_capability(HV_VMX_CAP_PINBASED, | ||
149 | &hvf_state->hvf_caps->vmx_cap_pinbased)) { | ||
150 | abort(); | ||
151 | -- | 211 | -- |
152 | 2.20.1 | 212 | 2.20.1 |
153 | 213 | ||
154 | 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 | This is BFDOT for both AArch64 AdvSIMD and SVE, | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | and VDOT.BF16 for AArch32 NEON. | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20210628135835.6690-19-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/arm/helper-mve.h | 2 ++ | ||
9 | target/arm/translate.h | 1 + | ||
10 | target/arm/t32.decode | 18 ++++++++++++++---- | ||
11 | target/arm/mve_helper.c | 10 ++++++++++ | ||
12 | target/arm/translate.c | 30 ++++++++++++++++++++++++++++++ | ||
13 | 5 files changed, 57 insertions(+), 4 deletions(-) | ||
5 | 14 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 15 | diff --git a/target/arm/helper-mve.h b/target/arm/helper-mve.h |
7 | Message-id: 20210525225817.400336-7-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 | 3 +++ | ||
12 | target/arm/neon-shared.decode | 2 ++ | ||
13 | target/arm/sve.decode | 3 +++ | ||
14 | target/arm/translate-a64.c | 20 ++++++++++++++++++ | ||
15 | target/arm/translate-neon.c | 9 ++++++++ | ||
16 | target/arm/translate-sve.c | 12 +++++++++++ | ||
17 | target/arm/vec_helper.c | 40 +++++++++++++++++++++++++++++++++++ | ||
18 | 7 files changed, 89 insertions(+) | ||
19 | |||
20 | diff --git a/target/arm/helper.h b/target/arm/helper.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/target/arm/helper.h | 17 | --- a/target/arm/helper-mve.h |
23 | +++ b/target/arm/helper.h | 18 | +++ b/target/arm/helper-mve.h |
24 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_ummla_b, TCG_CALL_NO_RWG, | 19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(mve_uqrshll48, TCG_CALL_NO_RWG, i64, env, i64, i32) |
25 | DEF_HELPER_FLAGS_5(gvec_usmmla_b, TCG_CALL_NO_RWG, | 20 | |
26 | void, ptr, ptr, ptr, ptr, i32) | 21 | DEF_HELPER_FLAGS_3(mve_uqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) |
27 | 22 | DEF_HELPER_FLAGS_3(mve_sqshl, TCG_CALL_NO_RWG, i32, env, i32, i32) | |
28 | +DEF_HELPER_FLAGS_5(gvec_bfdot, TCG_CALL_NO_RWG, | 23 | +DEF_HELPER_FLAGS_3(mve_uqrshl, TCG_CALL_NO_RWG, i32, env, i32, i32) |
29 | + void, ptr, ptr, ptr, ptr, 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 | + } | ||
30 | + | 70 | + |
31 | #ifdef TARGET_AARCH64 | 71 | + { |
32 | #include "helper-a64.h" | 72 | + SQRSHR_rr 1110101 0010 1 .... .... 1111 0010 1101 @mve_sh_rr |
33 | #include "helper-sve.h" | 73 | + ASRL_rr 1110101 0010 1 ... 0 .... ... 1 0010 1101 @mve_shl_rr |
34 | diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode | 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 | ||
35 | index XXXXXXX..XXXXXXX 100644 | 81 | index XXXXXXX..XXXXXXX 100644 |
36 | --- a/target/arm/neon-shared.decode | 82 | --- a/target/arm/mve_helper.c |
37 | +++ b/target/arm/neon-shared.decode | 83 | +++ b/target/arm/mve_helper.c |
38 | @@ -XXX,XX +XXX,XX @@ VUDOT 1111 110 00 . 10 .... .... 1101 . q:1 . 1 .... \ | 84 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mve_sqshl)(CPUARMState *env, uint32_t n, uint32_t shift) |
39 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | 85 | { |
40 | VUSDOT 1111 110 01 . 10 .... .... 1101 . q:1 . 0 .... \ | 86 | return do_sqrshl_bhs(n, (int8_t)shift, 32, false, &env->QF); |
41 | vm=%vm_dp vn=%vn_dp vd=%vd_dp | 87 | } |
42 | +VDOT_b16 1111 110 00 . 00 .... .... 1101 . q:1 . 0 .... \ | 88 | + |
43 | + vm=%vm_dp vn=%vn_dp vd=%vd_dp | 89 | +uint32_t HELPER(mve_uqrshl)(CPUARMState *env, uint32_t n, uint32_t shift) |
44 | 90 | +{ | |
45 | # VFM[AS]L | 91 | + return do_uqrshl_bhs(n, (int8_t)shift, 32, true, &env->QF); |
46 | VFML 1111 110 0 s:1 . 10 .... .... 1000 . 0 . 1 .... \ | 92 | +} |
47 | diff --git a/target/arm/sve.decode b/target/arm/sve.decode | 93 | + |
94 | +uint32_t HELPER(mve_sqrshr)(CPUARMState *env, uint32_t n, uint32_t shift) | ||
95 | +{ | ||
96 | + return do_sqrshl_bhs(n, -(int8_t)shift, 32, true, &env->QF); | ||
97 | +} | ||
98 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | 99 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/target/arm/sve.decode | 100 | --- a/target/arm/translate.c |
50 | +++ b/target/arm/sve.decode | 101 | +++ b/target/arm/translate.c |
51 | @@ -XXX,XX +XXX,XX @@ FMLALT_zzzw 01100100 10 1 ..... 10 0 00 1 ..... ..... @rda_rn_rm_e0 | 102 | @@ -XXX,XX +XXX,XX @@ static bool trans_UQSHL_ri(DisasContext *s, arg_mve_sh_ri *a) |
52 | FMLSLB_zzzw 01100100 10 1 ..... 10 1 00 0 ..... ..... @rda_rn_rm_e0 | 103 | return do_mve_sh_ri(s, a, gen_mve_uqshl); |
53 | FMLSLT_zzzw 01100100 10 1 ..... 10 1 00 1 ..... ..... @rda_rn_rm_e0 | ||
54 | |||
55 | +### SVE2 floating-point bfloat16 dot-product | ||
56 | +BFDOT_zzzz 01100100 01 1 ..... 10 0 00 0 ..... ..... @rda_rn_rm_e0 | ||
57 | + | ||
58 | ### SVE2 floating-point multiply-add long (indexed) | ||
59 | FMLALB_zzxw 01100100 10 1 ..... 0100.0 ..... ..... @rrxr_3a esz=2 | ||
60 | FMLALT_zzxw 01100100 10 1 ..... 0100.1 ..... ..... @rrxr_3a esz=2 | ||
61 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/translate-a64.c | ||
64 | +++ b/target/arm/translate-a64.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
66 | } | ||
67 | feature = dc_isar_feature(aa64_fcma, s); | ||
68 | break; | ||
69 | + case 0x1f: /* BFDOT */ | ||
70 | + switch (size) { | ||
71 | + case 1: | ||
72 | + feature = dc_isar_feature(aa64_bf16, s); | ||
73 | + break; | ||
74 | + default: | ||
75 | + unallocated_encoding(s); | ||
76 | + return; | ||
77 | + } | ||
78 | + break; | ||
79 | default: | ||
80 | unallocated_encoding(s); | ||
81 | return; | ||
82 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_three_reg_same_extra(DisasContext *s, uint32_t insn) | ||
83 | } | ||
84 | return; | ||
85 | |||
86 | + case 0xf: /* BFDOT */ | ||
87 | + switch (size) { | ||
88 | + case 1: | ||
89 | + gen_gvec_op4_ool(s, is_q, rd, rn, rm, rd, 0, gen_helper_gvec_bfdot); | ||
90 | + break; | ||
91 | + default: | ||
92 | + g_assert_not_reached(); | ||
93 | + } | ||
94 | + return; | ||
95 | + | ||
96 | default: | ||
97 | g_assert_not_reached(); | ||
98 | } | ||
99 | diff --git a/target/arm/translate-neon.c b/target/arm/translate-neon.c | ||
100 | index XXXXXXX..XXXXXXX 100644 | ||
101 | --- a/target/arm/translate-neon.c | ||
102 | +++ b/target/arm/translate-neon.c | ||
103 | @@ -XXX,XX +XXX,XX @@ static bool trans_VUSDOT(DisasContext *s, arg_VUSDOT *a) | ||
104 | gen_helper_gvec_usdot_b); | ||
105 | } | 104 | } |
106 | 105 | ||
107 | +static bool trans_VDOT_b16(DisasContext *s, arg_VDOT_b16 *a) | 106 | +static bool do_mve_sh_rr(DisasContext *s, arg_mve_sh_rr *a, ShiftFn *fn) |
108 | +{ | 107 | +{ |
109 | + if (!dc_isar_feature(aa32_bf16, s)) { | 108 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { |
109 | + /* Decode falls through to ORR/MOV UNPREDICTABLE handling */ | ||
110 | + return false; | 110 | + return false; |
111 | + } | 111 | + } |
112 | + return do_neon_ddda(s, a->q * 7, a->vd, a->vn, a->vm, 0, | 112 | + if (!dc_isar_feature(aa32_mve, s) || |
113 | + gen_helper_gvec_bfdot); | 113 | + !arm_dc_feature(s, ARM_FEATURE_M_MAIN) || |
114 | + a->rda == 13 || a->rda == 15 || a->rm == 13 || a->rm == 15 || | ||
115 | + a->rm == a->rda) { | ||
116 | + /* These rda/rm cases are UNPREDICTABLE; we choose to UNDEF */ | ||
117 | + unallocated_encoding(s); | ||
118 | + return true; | ||
119 | + } | ||
120 | + | ||
121 | + /* The helper takes care of the sign-extension of the low 8 bits of Rm */ | ||
122 | + fn(cpu_R[a->rda], cpu_env, cpu_R[a->rda], cpu_R[a->rm]); | ||
123 | + return true; | ||
114 | +} | 124 | +} |
115 | + | 125 | + |
116 | static bool trans_VFML(DisasContext *s, arg_VFML *a) | 126 | +static bool trans_SQRSHR_rr(DisasContext *s, arg_mve_sh_rr *a) |
117 | { | ||
118 | int opr_sz; | ||
119 | diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c | ||
120 | index XXXXXXX..XXXXXXX 100644 | ||
121 | --- a/target/arm/translate-sve.c | ||
122 | +++ b/target/arm/translate-sve.c | ||
123 | @@ -XXX,XX +XXX,XX @@ static bool trans_UMMLA(DisasContext *s, arg_rrrr_esz *a) | ||
124 | { | ||
125 | return do_i8mm_zzzz_ool(s, a, gen_helper_gvec_ummla_b, 0); | ||
126 | } | ||
127 | + | ||
128 | +static bool trans_BFDOT_zzzz(DisasContext *s, arg_rrrr_esz *a) | ||
129 | +{ | 127 | +{ |
130 | + if (!dc_isar_feature(aa64_sve_bf16, s)) { | 128 | + return do_mve_sh_rr(s, a, gen_helper_mve_sqrshr); |
131 | + return false; | ||
132 | + } | ||
133 | + if (sve_access_check(s)) { | ||
134 | + gen_gvec_ool_zzzz(s, gen_helper_gvec_bfdot, | ||
135 | + a->rd, a->rn, a->rm, a->ra, 0); | ||
136 | + } | ||
137 | + return true; | ||
138 | +} | ||
139 | diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c | ||
140 | index XXXXXXX..XXXXXXX 100644 | ||
141 | --- a/target/arm/vec_helper.c | ||
142 | +++ b/target/arm/vec_helper.c | ||
143 | @@ -XXX,XX +XXX,XX @@ static void do_mmla_b(void *vd, void *vn, void *vm, void *va, uint32_t desc, | ||
144 | DO_MMLA_B(gvec_smmla_b, do_smmla_b) | ||
145 | DO_MMLA_B(gvec_ummla_b, do_ummla_b) | ||
146 | DO_MMLA_B(gvec_usmmla_b, do_usmmla_b) | ||
147 | + | ||
148 | +/* | ||
149 | + * BFloat16 Dot Product | ||
150 | + */ | ||
151 | + | ||
152 | +static float32 bfdotadd(float32 sum, uint32_t e1, uint32_t e2) | ||
153 | +{ | ||
154 | + /* FPCR is ignored for BFDOT and BFMMLA. */ | ||
155 | + float_status bf_status = { | ||
156 | + .tininess_before_rounding = float_tininess_before_rounding, | ||
157 | + .float_rounding_mode = float_round_to_odd_inf, | ||
158 | + .flush_to_zero = true, | ||
159 | + .flush_inputs_to_zero = true, | ||
160 | + .default_nan_mode = true, | ||
161 | + }; | ||
162 | + float32 t1, t2; | ||
163 | + | ||
164 | + /* | ||
165 | + * Extract each BFloat16 from the element pair, and shift | ||
166 | + * them such that they become float32. | ||
167 | + */ | ||
168 | + t1 = float32_mul(e1 << 16, e2 << 16, &bf_status); | ||
169 | + t2 = float32_mul(e1 & 0xffff0000u, e2 & 0xffff0000u, &bf_status); | ||
170 | + t1 = float32_add(t1, t2, &bf_status); | ||
171 | + t1 = float32_add(sum, t1, &bf_status); | ||
172 | + | ||
173 | + return t1; | ||
174 | +} | 129 | +} |
175 | + | 130 | + |
176 | +void HELPER(gvec_bfdot)(void *vd, void *vn, void *vm, void *va, uint32_t desc) | 131 | +static bool trans_UQRSHL_rr(DisasContext *s, arg_mve_sh_rr *a) |
177 | +{ | 132 | +{ |
178 | + intptr_t i, opr_sz = simd_oprsz(desc); | 133 | + return do_mve_sh_rr(s, a, gen_helper_mve_uqrshl); |
179 | + float32 *d = vd, *a = va; | 134 | +} |
180 | + uint32_t *n = vn, *m = vm; | ||
181 | + | 135 | + |
182 | + for (i = 0; i < opr_sz / 4; ++i) { | 136 | /* |
183 | + d[i] = bfdotadd(a[i], n[i], m[i]); | 137 | * Multiply and multiply accumulate |
184 | + } | 138 | */ |
185 | + clear_tail(d, opr_sz, simd_maxsz(desc)); | ||
186 | +} | ||
187 | -- | 139 | -- |
188 | 2.20.1 | 140 | 2.20.1 |
189 | 141 | ||
190 | 142 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
4 | Message-id: 20210525225817.400336-12-richard.henderson@linaro.org | ||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | linux-user/elfload.c | 2 ++ | ||
9 | 1 file changed, 2 insertions(+) | ||
10 | |||
11 | diff --git a/linux-user/elfload.c b/linux-user/elfload.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/linux-user/elfload.c | ||
14 | +++ b/linux-user/elfload.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap2(void) | ||
16 | GET_FEATURE_ID(aa64_sve_i8mm, ARM_HWCAP2_A64_SVEI8MM); | ||
17 | GET_FEATURE_ID(aa64_sve_f32mm, ARM_HWCAP2_A64_SVEF32MM); | ||
18 | GET_FEATURE_ID(aa64_sve_f64mm, ARM_HWCAP2_A64_SVEF64MM); | ||
19 | + GET_FEATURE_ID(aa64_sve_bf16, ARM_HWCAP2_A64_SVEBF16); | ||
20 | GET_FEATURE_ID(aa64_i8mm, ARM_HWCAP2_A64_I8MM); | ||
21 | + GET_FEATURE_ID(aa64_bf16, ARM_HWCAP2_A64_BF16); | ||
22 | GET_FEATURE_ID(aa64_rndr, ARM_HWCAP2_A64_RNG); | ||
23 | GET_FEATURE_ID(aa64_bti, ARM_HWCAP2_A64_BTI); | ||
24 | GET_FEATURE_ID(aa64_mte, ARM_HWCAP2_A64_MTE); | ||
25 | -- | ||
26 | 2.20.1 | ||
27 | |||
28 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Richard Henderson <richard.henderson@linaro.org> | ||
2 | 1 | ||
3 | Disable BF16 again for !have_neon and !have_vfp during realize. | ||
4 | |||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20210525225817.400336-13-richard.henderson@linaro.org | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | target/arm/cpu.c | 3 +++ | ||
11 | target/arm/cpu64.c | 3 +++ | ||
12 | target/arm/cpu_tcg.c | 1 + | ||
13 | 3 files changed, 7 insertions(+) | ||
14 | |||
15 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.c | ||
18 | +++ b/target/arm/cpu.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
20 | |||
21 | u = cpu->isar.id_isar6; | ||
22 | u = FIELD_DP32(u, ID_ISAR6, JSCVT, 0); | ||
23 | + u = FIELD_DP32(u, ID_ISAR6, BF16, 0); | ||
24 | cpu->isar.id_isar6 = u; | ||
25 | |||
26 | u = cpu->isar.mvfr0; | ||
27 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
28 | |||
29 | t = cpu->isar.id_aa64isar1; | ||
30 | t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 0); | ||
31 | + t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 0); | ||
32 | t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 0); | ||
33 | cpu->isar.id_aa64isar1 = t; | ||
34 | |||
35 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) | ||
36 | u = cpu->isar.id_isar6; | ||
37 | u = FIELD_DP32(u, ID_ISAR6, DP, 0); | ||
38 | u = FIELD_DP32(u, ID_ISAR6, FHM, 0); | ||
39 | + u = FIELD_DP32(u, ID_ISAR6, BF16, 0); | ||
40 | u = FIELD_DP32(u, ID_ISAR6, I8MM, 0); | ||
41 | cpu->isar.id_isar6 = u; | ||
42 | |||
43 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/target/arm/cpu64.c | ||
46 | +++ b/target/arm/cpu64.c | ||
47 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
48 | t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); | ||
49 | t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); | ||
50 | t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); | ||
51 | + t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); | ||
52 | t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1); | ||
53 | t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* ARMv8.4-RCPC */ | ||
54 | t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); | ||
55 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
56 | t = FIELD_DP64(t, ID_AA64ZFR0, SVEVER, 1); | ||
57 | t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* PMULL */ | ||
58 | t = FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1); | ||
59 | + t = FIELD_DP64(t, ID_AA64ZFR0, BFLOAT16, 1); | ||
60 | t = FIELD_DP64(t, ID_AA64ZFR0, SHA3, 1); | ||
61 | t = FIELD_DP64(t, ID_AA64ZFR0, SM4, 1); | ||
62 | t = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1); | ||
63 | @@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj) | ||
64 | u = FIELD_DP32(u, ID_ISAR6, FHM, 1); | ||
65 | u = FIELD_DP32(u, ID_ISAR6, SB, 1); | ||
66 | u = FIELD_DP32(u, ID_ISAR6, SPECRES, 1); | ||
67 | + u = FIELD_DP32(u, ID_ISAR6, BF16, 1); | ||
68 | u = FIELD_DP32(u, ID_ISAR6, I8MM, 1); | ||
69 | cpu->isar.id_isar6 = u; | ||
70 | |||
71 | diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c | ||
72 | index XXXXXXX..XXXXXXX 100644 | ||
73 | --- a/target/arm/cpu_tcg.c | ||
74 | +++ b/target/arm/cpu_tcg.c | ||
75 | @@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj) | ||
76 | t = FIELD_DP32(t, ID_ISAR6, FHM, 1); | ||
77 | t = FIELD_DP32(t, ID_ISAR6, SB, 1); | ||
78 | t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); | ||
79 | + t = FIELD_DP32(t, ID_ISAR6, BF16, 1); | ||
80 | t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); | ||
81 | cpu->isar.id_isar6 = t; | ||
82 | |||
83 | -- | ||
84 | 2.20.1 | ||
85 | |||
86 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alexander Graf <agraf@csgraf.de> | ||
2 | 1 | ||
3 | Until now, Hypervisor.framework has only been available on x86_64 systems. | ||
4 | With Apple Silicon shipping now, it extends its reach to aarch64. To | ||
5 | prepare for support for multiple architectures, let's start moving common | ||
6 | code out into its own accel directory. | ||
7 | |||
8 | This patch moves the vCPU thread loop over. | ||
9 | |||
10 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
11 | Reviewed-by: Sergio Lopez <slp@redhat.com> | ||
12 | Message-id: 20210519202253.76782-3-agraf@csgraf.de | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | {target/i386 => accel}/hvf/hvf-accel-ops.h | 0 | ||
17 | {target/i386 => accel}/hvf/hvf-accel-ops.c | 0 | ||
18 | target/i386/hvf/x86hvf.c | 2 +- | ||
19 | accel/hvf/meson.build | 1 + | ||
20 | target/i386/hvf/meson.build | 1 - | ||
21 | 5 files changed, 2 insertions(+), 2 deletions(-) | ||
22 | rename {target/i386 => accel}/hvf/hvf-accel-ops.h (100%) | ||
23 | rename {target/i386 => accel}/hvf/hvf-accel-ops.c (100%) | ||
24 | |||
25 | diff --git a/target/i386/hvf/hvf-accel-ops.h b/accel/hvf/hvf-accel-ops.h | ||
26 | similarity index 100% | ||
27 | rename from target/i386/hvf/hvf-accel-ops.h | ||
28 | rename to accel/hvf/hvf-accel-ops.h | ||
29 | diff --git a/target/i386/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c | ||
30 | similarity index 100% | ||
31 | rename from target/i386/hvf/hvf-accel-ops.c | ||
32 | rename to accel/hvf/hvf-accel-ops.c | ||
33 | diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/target/i386/hvf/x86hvf.c | ||
36 | +++ b/target/i386/hvf/x86hvf.c | ||
37 | @@ -XXX,XX +XXX,XX @@ | ||
38 | #include <Hypervisor/hv.h> | ||
39 | #include <Hypervisor/hv_vmx.h> | ||
40 | |||
41 | -#include "hvf-accel-ops.h" | ||
42 | +#include "accel/hvf/hvf-accel-ops.h" | ||
43 | |||
44 | void hvf_set_segment(struct CPUState *cpu, struct vmx_segment *vmx_seg, | ||
45 | SegmentCache *qseg, bool is_tr) | ||
46 | diff --git a/accel/hvf/meson.build b/accel/hvf/meson.build | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/accel/hvf/meson.build | ||
49 | +++ b/accel/hvf/meson.build | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | hvf_ss = ss.source_set() | ||
52 | hvf_ss.add(files( | ||
53 | 'hvf-all.c', | ||
54 | + 'hvf-accel-ops.c', | ||
55 | )) | ||
56 | |||
57 | specific_ss.add_all(when: 'CONFIG_HVF', if_true: hvf_ss) | ||
58 | diff --git a/target/i386/hvf/meson.build b/target/i386/hvf/meson.build | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/target/i386/hvf/meson.build | ||
61 | +++ b/target/i386/hvf/meson.build | ||
62 | @@ -XXX,XX +XXX,XX @@ | ||
63 | i386_softmmu_ss.add(when: [hvf, 'CONFIG_HVF'], if_true: files( | ||
64 | 'hvf.c', | ||
65 | - 'hvf-accel-ops.c', | ||
66 | 'x86.c', | ||
67 | 'x86_cpuid.c', | ||
68 | 'x86_decode.c', | ||
69 | -- | ||
70 | 2.20.1 | ||
71 | |||
72 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alexander Graf <agraf@csgraf.de> | ||
2 | 1 | ||
3 | Until now, Hypervisor.framework has only been available on x86_64 systems. | ||
4 | With Apple Silicon shipping now, it extends its reach to aarch64. To | ||
5 | prepare for support for multiple architectures, let's start moving common | ||
6 | code out into its own accel directory. | ||
7 | |||
8 | This patch moves a few internal struct and constant defines over. | ||
9 | |||
10 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
11 | Reviewed-by: Sergio Lopez <slp@redhat.com> | ||
12 | Message-id: 20210519202253.76782-5-agraf@csgraf.de | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | include/sysemu/hvf_int.h | 30 ++++++++++++++++++++++++++++++ | ||
17 | target/i386/hvf/hvf-i386.h | 31 +------------------------------ | ||
18 | 2 files changed, 31 insertions(+), 30 deletions(-) | ||
19 | |||
20 | diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/include/sysemu/hvf_int.h | ||
23 | +++ b/include/sysemu/hvf_int.h | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | |||
26 | #include <Hypervisor/hv.h> | ||
27 | |||
28 | +/* hvf_slot flags */ | ||
29 | +#define HVF_SLOT_LOG (1 << 0) | ||
30 | + | ||
31 | +typedef struct hvf_slot { | ||
32 | + uint64_t start; | ||
33 | + uint64_t size; | ||
34 | + uint8_t *mem; | ||
35 | + int slot_id; | ||
36 | + uint32_t flags; | ||
37 | + MemoryRegion *region; | ||
38 | +} hvf_slot; | ||
39 | + | ||
40 | +typedef struct hvf_vcpu_caps { | ||
41 | + uint64_t vmx_cap_pinbased; | ||
42 | + uint64_t vmx_cap_procbased; | ||
43 | + uint64_t vmx_cap_procbased2; | ||
44 | + uint64_t vmx_cap_entry; | ||
45 | + uint64_t vmx_cap_exit; | ||
46 | + uint64_t vmx_cap_preemption_timer; | ||
47 | +} hvf_vcpu_caps; | ||
48 | + | ||
49 | +struct HVFState { | ||
50 | + AccelState parent; | ||
51 | + hvf_slot slots[32]; | ||
52 | + int num_slots; | ||
53 | + | ||
54 | + hvf_vcpu_caps *hvf_caps; | ||
55 | +}; | ||
56 | +extern HVFState *hvf_state; | ||
57 | + | ||
58 | void hvf_set_phys_mem(MemoryRegionSection *, bool); | ||
59 | void assert_hvf_ok(hv_return_t ret); | ||
60 | hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); | ||
61 | diff --git a/target/i386/hvf/hvf-i386.h b/target/i386/hvf/hvf-i386.h | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/i386/hvf/hvf-i386.h | ||
64 | +++ b/target/i386/hvf/hvf-i386.h | ||
65 | @@ -XXX,XX +XXX,XX @@ | ||
66 | |||
67 | #include "qemu/accel.h" | ||
68 | #include "sysemu/hvf.h" | ||
69 | +#include "sysemu/hvf_int.h" | ||
70 | #include "cpu.h" | ||
71 | #include "x86.h" | ||
72 | |||
73 | -/* hvf_slot flags */ | ||
74 | -#define HVF_SLOT_LOG (1 << 0) | ||
75 | - | ||
76 | -typedef struct hvf_slot { | ||
77 | - uint64_t start; | ||
78 | - uint64_t size; | ||
79 | - uint8_t *mem; | ||
80 | - int slot_id; | ||
81 | - uint32_t flags; | ||
82 | - MemoryRegion *region; | ||
83 | -} hvf_slot; | ||
84 | - | ||
85 | -typedef struct hvf_vcpu_caps { | ||
86 | - uint64_t vmx_cap_pinbased; | ||
87 | - uint64_t vmx_cap_procbased; | ||
88 | - uint64_t vmx_cap_procbased2; | ||
89 | - uint64_t vmx_cap_entry; | ||
90 | - uint64_t vmx_cap_exit; | ||
91 | - uint64_t vmx_cap_preemption_timer; | ||
92 | -} hvf_vcpu_caps; | ||
93 | - | ||
94 | -struct HVFState { | ||
95 | - AccelState parent; | ||
96 | - hvf_slot slots[32]; | ||
97 | - int num_slots; | ||
98 | - | ||
99 | - hvf_vcpu_caps *hvf_caps; | ||
100 | -}; | ||
101 | -extern HVFState *hvf_state; | ||
102 | - | ||
103 | void hvf_handle_io(CPUArchState *, uint16_t, void *, int, int, int); | ||
104 | |||
105 | #ifdef NEED_CPU_H | ||
106 | -- | ||
107 | 2.20.1 | ||
108 | |||
109 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alexander Graf <agraf@csgraf.de> | ||
2 | 1 | ||
3 | The hvf_set_phys_mem() function is only called within the same file. | ||
4 | Make it static. | ||
5 | |||
6 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
7 | Reviewed-by: Sergio Lopez <slp@redhat.com> | ||
8 | Message-id: 20210519202253.76782-6-agraf@csgraf.de | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/sysemu/hvf_int.h | 1 - | ||
13 | accel/hvf/hvf-accel-ops.c | 2 +- | ||
14 | 2 files changed, 1 insertion(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/sysemu/hvf_int.h | ||
19 | +++ b/include/sysemu/hvf_int.h | ||
20 | @@ -XXX,XX +XXX,XX @@ struct HVFState { | ||
21 | }; | ||
22 | extern HVFState *hvf_state; | ||
23 | |||
24 | -void hvf_set_phys_mem(MemoryRegionSection *, bool); | ||
25 | void assert_hvf_ok(hv_return_t ret); | ||
26 | hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); | ||
27 | int hvf_put_registers(CPUState *); | ||
28 | diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/accel/hvf/hvf-accel-ops.c | ||
31 | +++ b/accel/hvf/hvf-accel-ops.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags) | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | -void hvf_set_phys_mem(MemoryRegionSection *section, bool add) | ||
37 | +static void hvf_set_phys_mem(MemoryRegionSection *section, bool add) | ||
38 | { | ||
39 | hvf_slot *mem; | ||
40 | MemoryRegion *area = section->mr; | ||
41 | -- | ||
42 | 2.20.1 | ||
43 | |||
44 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alexander Graf <agraf@csgraf.de> | ||
2 | 1 | ||
3 | The ARM version of Hypervisor.framework no longer defines these two | ||
4 | types, so let's just revert to standard ones. | ||
5 | |||
6 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
7 | Reviewed-by: Sergio Lopez <slp@redhat.com> | ||
8 | Message-id: 20210519202253.76782-7-agraf@csgraf.de | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | accel/hvf/hvf-accel-ops.c | 6 +++--- | ||
13 | 1 file changed, 3 insertions(+), 3 deletions(-) | ||
14 | |||
15 | diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/accel/hvf/hvf-accel-ops.c | ||
18 | +++ b/accel/hvf/hvf-accel-ops.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static int do_hvf_set_memory(hvf_slot *slot, hv_memory_flags_t flags) | ||
20 | macslot->present = 1; | ||
21 | macslot->gpa_start = slot->start; | ||
22 | macslot->size = slot->size; | ||
23 | - ret = hv_vm_map((hv_uvaddr_t)slot->mem, slot->start, slot->size, flags); | ||
24 | + ret = hv_vm_map(slot->mem, slot->start, slot->size, flags); | ||
25 | assert_hvf_ok(ret); | ||
26 | return 0; | ||
27 | } | ||
28 | @@ -XXX,XX +XXX,XX @@ static void hvf_set_dirty_tracking(MemoryRegionSection *section, bool on) | ||
29 | /* protect region against writes; begin tracking it */ | ||
30 | if (on) { | ||
31 | slot->flags |= HVF_SLOT_LOG; | ||
32 | - hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size, | ||
33 | + hv_vm_protect((uintptr_t)slot->start, (size_t)slot->size, | ||
34 | HV_MEMORY_READ); | ||
35 | /* stop tracking region*/ | ||
36 | } else { | ||
37 | slot->flags &= ~HVF_SLOT_LOG; | ||
38 | - hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size, | ||
39 | + hv_vm_protect((uintptr_t)slot->start, (size_t)slot->size, | ||
40 | HV_MEMORY_READ | HV_MEMORY_WRITE); | ||
41 | } | ||
42 | } | ||
43 | -- | ||
44 | 2.20.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alexander Graf <agraf@csgraf.de> | ||
2 | 1 | ||
3 | There is no reason to call the hvf specific hvf_cpu_synchronize_state() | ||
4 | when we can just use the generic cpu_synchronize_state() instead. This | ||
5 | allows us to have less dependency on internal function definitions and | ||
6 | allows us to make hvf_cpu_synchronize_state() static. | ||
7 | |||
8 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
9 | Reviewed-by: Sergio Lopez <slp@redhat.com> | ||
10 | Message-id: 20210519202253.76782-9-agraf@csgraf.de | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | accel/hvf/hvf-accel-ops.h | 1 - | ||
15 | accel/hvf/hvf-accel-ops.c | 2 +- | ||
16 | target/i386/hvf/x86hvf.c | 9 ++++----- | ||
17 | 3 files changed, 5 insertions(+), 7 deletions(-) | ||
18 | |||
19 | diff --git a/accel/hvf/hvf-accel-ops.h b/accel/hvf/hvf-accel-ops.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/accel/hvf/hvf-accel-ops.h | ||
22 | +++ b/accel/hvf/hvf-accel-ops.h | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | #include "sysemu/cpus.h" | ||
25 | |||
26 | int hvf_vcpu_exec(CPUState *); | ||
27 | -void hvf_cpu_synchronize_state(CPUState *); | ||
28 | void hvf_cpu_synchronize_post_reset(CPUState *); | ||
29 | void hvf_cpu_synchronize_post_init(CPUState *); | ||
30 | void hvf_cpu_synchronize_pre_loadvm(CPUState *); | ||
31 | diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/accel/hvf/hvf-accel-ops.c | ||
34 | +++ b/accel/hvf/hvf-accel-ops.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static void do_hvf_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data arg) | ||
36 | } | ||
37 | } | ||
38 | |||
39 | -void hvf_cpu_synchronize_state(CPUState *cpu) | ||
40 | +static void hvf_cpu_synchronize_state(CPUState *cpu) | ||
41 | { | ||
42 | if (!cpu->vcpu_dirty) { | ||
43 | run_on_cpu(cpu, do_hvf_cpu_synchronize_state, RUN_ON_CPU_NULL); | ||
44 | diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/target/i386/hvf/x86hvf.c | ||
47 | +++ b/target/i386/hvf/x86hvf.c | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | #include "cpu.h" | ||
50 | #include "x86_descr.h" | ||
51 | #include "x86_decode.h" | ||
52 | +#include "sysemu/hw_accel.h" | ||
53 | |||
54 | #include "hw/i386/apic_internal.h" | ||
55 | |||
56 | #include <Hypervisor/hv.h> | ||
57 | #include <Hypervisor/hv_vmx.h> | ||
58 | |||
59 | -#include "accel/hvf/hvf-accel-ops.h" | ||
60 | - | ||
61 | void hvf_set_segment(struct CPUState *cpu, struct vmx_segment *vmx_seg, | ||
62 | SegmentCache *qseg, bool is_tr) | ||
63 | { | ||
64 | @@ -XXX,XX +XXX,XX @@ int hvf_process_events(CPUState *cpu_state) | ||
65 | env->eflags = rreg(cpu_state->hvf_fd, HV_X86_RFLAGS); | ||
66 | |||
67 | if (cpu_state->interrupt_request & CPU_INTERRUPT_INIT) { | ||
68 | - hvf_cpu_synchronize_state(cpu_state); | ||
69 | + cpu_synchronize_state(cpu_state); | ||
70 | do_cpu_init(cpu); | ||
71 | } | ||
72 | |||
73 | @@ -XXX,XX +XXX,XX @@ int hvf_process_events(CPUState *cpu_state) | ||
74 | cpu_state->halted = 0; | ||
75 | } | ||
76 | if (cpu_state->interrupt_request & CPU_INTERRUPT_SIPI) { | ||
77 | - hvf_cpu_synchronize_state(cpu_state); | ||
78 | + cpu_synchronize_state(cpu_state); | ||
79 | do_cpu_sipi(cpu); | ||
80 | } | ||
81 | if (cpu_state->interrupt_request & CPU_INTERRUPT_TPR) { | ||
82 | cpu_state->interrupt_request &= ~CPU_INTERRUPT_TPR; | ||
83 | - hvf_cpu_synchronize_state(cpu_state); | ||
84 | + cpu_synchronize_state(cpu_state); | ||
85 | apic_handle_tpr_access_report(cpu->apic_state, env->eip, | ||
86 | env->tpr_access_type); | ||
87 | } | ||
88 | -- | ||
89 | 2.20.1 | ||
90 | |||
91 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alexander Graf <agraf@csgraf.de> | ||
2 | 1 | ||
3 | The hvf accel synchronize functions are only used as input for local | ||
4 | callback functions, so we can make them static. | ||
5 | |||
6 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
7 | Reviewed-by: Sergio Lopez <slp@redhat.com> | ||
8 | Message-id: 20210519202253.76782-10-agraf@csgraf.de | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | accel/hvf/hvf-accel-ops.h | 3 --- | ||
13 | accel/hvf/hvf-accel-ops.c | 6 +++--- | ||
14 | 2 files changed, 3 insertions(+), 6 deletions(-) | ||
15 | |||
16 | diff --git a/accel/hvf/hvf-accel-ops.h b/accel/hvf/hvf-accel-ops.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/accel/hvf/hvf-accel-ops.h | ||
19 | +++ b/accel/hvf/hvf-accel-ops.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #include "sysemu/cpus.h" | ||
22 | |||
23 | int hvf_vcpu_exec(CPUState *); | ||
24 | -void hvf_cpu_synchronize_post_reset(CPUState *); | ||
25 | -void hvf_cpu_synchronize_post_init(CPUState *); | ||
26 | -void hvf_cpu_synchronize_pre_loadvm(CPUState *); | ||
27 | |||
28 | #endif /* HVF_CPUS_H */ | ||
29 | diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/accel/hvf/hvf-accel-ops.c | ||
32 | +++ b/accel/hvf/hvf-accel-ops.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void do_hvf_cpu_synchronize_post_reset(CPUState *cpu, | ||
34 | cpu->vcpu_dirty = false; | ||
35 | } | ||
36 | |||
37 | -void hvf_cpu_synchronize_post_reset(CPUState *cpu) | ||
38 | +static void hvf_cpu_synchronize_post_reset(CPUState *cpu) | ||
39 | { | ||
40 | run_on_cpu(cpu, do_hvf_cpu_synchronize_post_reset, RUN_ON_CPU_NULL); | ||
41 | } | ||
42 | @@ -XXX,XX +XXX,XX @@ static void do_hvf_cpu_synchronize_post_init(CPUState *cpu, | ||
43 | cpu->vcpu_dirty = false; | ||
44 | } | ||
45 | |||
46 | -void hvf_cpu_synchronize_post_init(CPUState *cpu) | ||
47 | +static void hvf_cpu_synchronize_post_init(CPUState *cpu) | ||
48 | { | ||
49 | run_on_cpu(cpu, do_hvf_cpu_synchronize_post_init, RUN_ON_CPU_NULL); | ||
50 | } | ||
51 | @@ -XXX,XX +XXX,XX @@ static void do_hvf_cpu_synchronize_pre_loadvm(CPUState *cpu, | ||
52 | cpu->vcpu_dirty = true; | ||
53 | } | ||
54 | |||
55 | -void hvf_cpu_synchronize_pre_loadvm(CPUState *cpu) | ||
56 | +static void hvf_cpu_synchronize_pre_loadvm(CPUState *cpu) | ||
57 | { | ||
58 | run_on_cpu(cpu, do_hvf_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL); | ||
59 | } | ||
60 | -- | ||
61 | 2.20.1 | ||
62 | |||
63 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alexander Graf <agraf@csgraf.de> | ||
2 | 1 | ||
3 | We can move the definition of hvf_vcpu_exec() into our internal | ||
4 | hvf header, obsoleting the need for hvf-accel-ops.h. | ||
5 | |||
6 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
7 | Reviewed-by: Sergio Lopez <slp@redhat.com> | ||
8 | Message-id: 20210519202253.76782-11-agraf@csgraf.de | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | accel/hvf/hvf-accel-ops.h | 17 ----------------- | ||
13 | include/sysemu/hvf_int.h | 1 + | ||
14 | accel/hvf/hvf-accel-ops.c | 2 -- | ||
15 | target/i386/hvf/hvf.c | 2 -- | ||
16 | 4 files changed, 1 insertion(+), 21 deletions(-) | ||
17 | delete mode 100644 accel/hvf/hvf-accel-ops.h | ||
18 | |||
19 | diff --git a/accel/hvf/hvf-accel-ops.h b/accel/hvf/hvf-accel-ops.h | ||
20 | deleted file mode 100644 | ||
21 | index XXXXXXX..XXXXXXX | ||
22 | --- a/accel/hvf/hvf-accel-ops.h | ||
23 | +++ /dev/null | ||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | -/* | ||
26 | - * Accelerator CPUS Interface | ||
27 | - * | ||
28 | - * Copyright 2020 SUSE LLC | ||
29 | - * | ||
30 | - * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
31 | - * See the COPYING file in the top-level directory. | ||
32 | - */ | ||
33 | - | ||
34 | -#ifndef HVF_CPUS_H | ||
35 | -#define HVF_CPUS_H | ||
36 | - | ||
37 | -#include "sysemu/cpus.h" | ||
38 | - | ||
39 | -int hvf_vcpu_exec(CPUState *); | ||
40 | - | ||
41 | -#endif /* HVF_CPUS_H */ | ||
42 | diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h | ||
43 | index XXXXXXX..XXXXXXX 100644 | ||
44 | --- a/include/sysemu/hvf_int.h | ||
45 | +++ b/include/sysemu/hvf_int.h | ||
46 | @@ -XXX,XX +XXX,XX @@ extern HVFState *hvf_state; | ||
47 | void assert_hvf_ok(hv_return_t ret); | ||
48 | int hvf_arch_init_vcpu(CPUState *cpu); | ||
49 | void hvf_arch_vcpu_destroy(CPUState *cpu); | ||
50 | +int hvf_vcpu_exec(CPUState *); | ||
51 | hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); | ||
52 | int hvf_put_registers(CPUState *); | ||
53 | int hvf_get_registers(CPUState *); | ||
54 | diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/accel/hvf/hvf-accel-ops.c | ||
57 | +++ b/accel/hvf/hvf-accel-ops.c | ||
58 | @@ -XXX,XX +XXX,XX @@ | ||
59 | #include "sysemu/runstate.h" | ||
60 | #include "qemu/guest-random.h" | ||
61 | |||
62 | -#include "hvf-accel-ops.h" | ||
63 | - | ||
64 | HVFState *hvf_state; | ||
65 | |||
66 | /* Memory slots */ | ||
67 | diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/target/i386/hvf/hvf.c | ||
70 | +++ b/target/i386/hvf/hvf.c | ||
71 | @@ -XXX,XX +XXX,XX @@ | ||
72 | #include "qemu/accel.h" | ||
73 | #include "target/i386/cpu.h" | ||
74 | |||
75 | -#include "hvf-accel-ops.h" | ||
76 | - | ||
77 | void vmx_update_tpr(CPUState *cpu) | ||
78 | { | ||
79 | /* TODO: need integrate APIC handling */ | ||
80 | -- | ||
81 | 2.20.1 | ||
82 | |||
83 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alexander Graf <agraf@csgraf.de> | ||
2 | 1 | ||
3 | We will need more than a single field for hvf going forward. To keep | ||
4 | the global vcpu struct uncluttered, let's allocate a special hvf vcpu | ||
5 | struct, similar to how hax does it. | ||
6 | |||
7 | Signed-off-by: Alexander Graf <agraf@csgraf.de> | ||
8 | Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com> | ||
9 | Tested-by: Roman Bolshakov <r.bolshakov@yadro.com> | ||
10 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
11 | Reviewed-by: Sergio Lopez <slp@redhat.com> | ||
12 | Message-id: 20210519202253.76782-12-agraf@csgraf.de | ||
13 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | include/hw/core/cpu.h | 3 +- | ||
17 | include/sysemu/hvf_int.h | 4 + | ||
18 | target/i386/hvf/vmx.h | 24 +++-- | ||
19 | accel/hvf/hvf-accel-ops.c | 8 +- | ||
20 | target/i386/hvf/hvf.c | 104 +++++++++--------- | ||
21 | target/i386/hvf/x86.c | 28 ++--- | ||
22 | target/i386/hvf/x86_descr.c | 26 ++--- | ||
23 | target/i386/hvf/x86_emu.c | 62 +++++------ | ||
24 | target/i386/hvf/x86_mmu.c | 4 +- | ||
25 | target/i386/hvf/x86_task.c | 12 +-- | ||
26 | target/i386/hvf/x86hvf.c | 210 ++++++++++++++++++------------------ | ||
27 | 11 files changed, 248 insertions(+), 237 deletions(-) | ||
28 | |||
29 | diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/include/hw/core/cpu.h | ||
32 | +++ b/include/hw/core/cpu.h | ||
33 | @@ -XXX,XX +XXX,XX @@ struct KVMState; | ||
34 | struct kvm_run; | ||
35 | |||
36 | struct hax_vcpu_state; | ||
37 | +struct hvf_vcpu_state; | ||
38 | |||
39 | #define TB_JMP_CACHE_BITS 12 | ||
40 | #define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS) | ||
41 | @@ -XXX,XX +XXX,XX @@ struct CPUState { | ||
42 | |||
43 | struct hax_vcpu_state *hax_vcpu; | ||
44 | |||
45 | - int hvf_fd; | ||
46 | + struct hvf_vcpu_state *hvf; | ||
47 | |||
48 | /* track IOMMUs whose translations we've cached in the TCG TLB */ | ||
49 | GArray *iommu_notifiers; | ||
50 | diff --git a/include/sysemu/hvf_int.h b/include/sysemu/hvf_int.h | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/include/sysemu/hvf_int.h | ||
53 | +++ b/include/sysemu/hvf_int.h | ||
54 | @@ -XXX,XX +XXX,XX @@ struct HVFState { | ||
55 | }; | ||
56 | extern HVFState *hvf_state; | ||
57 | |||
58 | +struct hvf_vcpu_state { | ||
59 | + int fd; | ||
60 | +}; | ||
61 | + | ||
62 | void assert_hvf_ok(hv_return_t ret); | ||
63 | int hvf_arch_init_vcpu(CPUState *cpu); | ||
64 | void hvf_arch_vcpu_destroy(CPUState *cpu); | ||
65 | diff --git a/target/i386/hvf/vmx.h b/target/i386/hvf/vmx.h | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/i386/hvf/vmx.h | ||
68 | +++ b/target/i386/hvf/vmx.h | ||
69 | @@ -XXX,XX +XXX,XX @@ | ||
70 | #include "vmcs.h" | ||
71 | #include "cpu.h" | ||
72 | #include "x86.h" | ||
73 | +#include "sysemu/hvf.h" | ||
74 | +#include "sysemu/hvf_int.h" | ||
75 | |||
76 | #include "exec/address-spaces.h" | ||
77 | |||
78 | @@ -XXX,XX +XXX,XX @@ static inline void macvm_set_rip(CPUState *cpu, uint64_t rip) | ||
79 | uint64_t val; | ||
80 | |||
81 | /* BUG, should take considering overlap.. */ | ||
82 | - wreg(cpu->hvf_fd, HV_X86_RIP, rip); | ||
83 | + wreg(cpu->hvf->fd, HV_X86_RIP, rip); | ||
84 | env->eip = rip; | ||
85 | |||
86 | /* after moving forward in rip, we need to clean INTERRUPTABILITY */ | ||
87 | - val = rvmcs(cpu->hvf_fd, VMCS_GUEST_INTERRUPTIBILITY); | ||
88 | + val = rvmcs(cpu->hvf->fd, VMCS_GUEST_INTERRUPTIBILITY); | ||
89 | if (val & (VMCS_INTERRUPTIBILITY_STI_BLOCKING | | ||
90 | VMCS_INTERRUPTIBILITY_MOVSS_BLOCKING)) { | ||
91 | env->hflags &= ~HF_INHIBIT_IRQ_MASK; | ||
92 | - wvmcs(cpu->hvf_fd, VMCS_GUEST_INTERRUPTIBILITY, | ||
93 | + wvmcs(cpu->hvf->fd, VMCS_GUEST_INTERRUPTIBILITY, | ||
94 | val & ~(VMCS_INTERRUPTIBILITY_STI_BLOCKING | | ||
95 | VMCS_INTERRUPTIBILITY_MOVSS_BLOCKING)); | ||
96 | } | ||
97 | @@ -XXX,XX +XXX,XX @@ static inline void vmx_clear_nmi_blocking(CPUState *cpu) | ||
98 | CPUX86State *env = &x86_cpu->env; | ||
99 | |||
100 | env->hflags2 &= ~HF2_NMI_MASK; | ||
101 | - uint32_t gi = (uint32_t) rvmcs(cpu->hvf_fd, VMCS_GUEST_INTERRUPTIBILITY); | ||
102 | + uint32_t gi = (uint32_t) rvmcs(cpu->hvf->fd, VMCS_GUEST_INTERRUPTIBILITY); | ||
103 | gi &= ~VMCS_INTERRUPTIBILITY_NMI_BLOCKING; | ||
104 | - wvmcs(cpu->hvf_fd, VMCS_GUEST_INTERRUPTIBILITY, gi); | ||
105 | + wvmcs(cpu->hvf->fd, VMCS_GUEST_INTERRUPTIBILITY, gi); | ||
106 | } | ||
107 | |||
108 | static inline void vmx_set_nmi_blocking(CPUState *cpu) | ||
109 | @@ -XXX,XX +XXX,XX @@ static inline void vmx_set_nmi_blocking(CPUState *cpu) | ||
110 | CPUX86State *env = &x86_cpu->env; | ||
111 | |||
112 | env->hflags2 |= HF2_NMI_MASK; | ||
113 | - uint32_t gi = (uint32_t)rvmcs(cpu->hvf_fd, VMCS_GUEST_INTERRUPTIBILITY); | ||
114 | + uint32_t gi = (uint32_t)rvmcs(cpu->hvf->fd, VMCS_GUEST_INTERRUPTIBILITY); | ||
115 | gi |= VMCS_INTERRUPTIBILITY_NMI_BLOCKING; | ||
116 | - wvmcs(cpu->hvf_fd, VMCS_GUEST_INTERRUPTIBILITY, gi); | ||
117 | + wvmcs(cpu->hvf->fd, VMCS_GUEST_INTERRUPTIBILITY, gi); | ||
118 | } | ||
119 | |||
120 | static inline void vmx_set_nmi_window_exiting(CPUState *cpu) | ||
121 | { | ||
122 | uint64_t val; | ||
123 | - val = rvmcs(cpu->hvf_fd, VMCS_PRI_PROC_BASED_CTLS); | ||
124 | - wvmcs(cpu->hvf_fd, VMCS_PRI_PROC_BASED_CTLS, val | | ||
125 | + val = rvmcs(cpu->hvf->fd, VMCS_PRI_PROC_BASED_CTLS); | ||
126 | + wvmcs(cpu->hvf->fd, VMCS_PRI_PROC_BASED_CTLS, val | | ||
127 | VMCS_PRI_PROC_BASED_CTLS_NMI_WINDOW_EXITING); | ||
128 | |||
129 | } | ||
130 | @@ -XXX,XX +XXX,XX @@ static inline void vmx_clear_nmi_window_exiting(CPUState *cpu) | ||
131 | { | ||
132 | |||
133 | uint64_t val; | ||
134 | - val = rvmcs(cpu->hvf_fd, VMCS_PRI_PROC_BASED_CTLS); | ||
135 | - wvmcs(cpu->hvf_fd, VMCS_PRI_PROC_BASED_CTLS, val & | ||
136 | + val = rvmcs(cpu->hvf->fd, VMCS_PRI_PROC_BASED_CTLS); | ||
137 | + wvmcs(cpu->hvf->fd, VMCS_PRI_PROC_BASED_CTLS, val & | ||
138 | ~VMCS_PRI_PROC_BASED_CTLS_NMI_WINDOW_EXITING); | ||
139 | } | ||
140 | |||
141 | diff --git a/accel/hvf/hvf-accel-ops.c b/accel/hvf/hvf-accel-ops.c | ||
142 | index XXXXXXX..XXXXXXX 100644 | ||
143 | --- a/accel/hvf/hvf-accel-ops.c | ||
144 | +++ b/accel/hvf/hvf-accel-ops.c | ||
145 | @@ -XXX,XX +XXX,XX @@ type_init(hvf_type_init); | ||
146 | |||
147 | static void hvf_vcpu_destroy(CPUState *cpu) | ||
148 | { | ||
149 | - hv_return_t ret = hv_vcpu_destroy(cpu->hvf_fd); | ||
150 | + hv_return_t ret = hv_vcpu_destroy(cpu->hvf->fd); | ||
151 | assert_hvf_ok(ret); | ||
152 | |||
153 | hvf_arch_vcpu_destroy(cpu); | ||
154 | + g_free(cpu->hvf); | ||
155 | + cpu->hvf = NULL; | ||
156 | } | ||
157 | |||
158 | static int hvf_init_vcpu(CPUState *cpu) | ||
159 | { | ||
160 | int r; | ||
161 | |||
162 | + cpu->hvf = g_malloc0(sizeof(*cpu->hvf)); | ||
163 | + | ||
164 | /* init cpu signals */ | ||
165 | sigset_t set; | ||
166 | struct sigaction sigact; | ||
167 | @@ -XXX,XX +XXX,XX @@ static int hvf_init_vcpu(CPUState *cpu) | ||
168 | pthread_sigmask(SIG_BLOCK, NULL, &set); | ||
169 | sigdelset(&set, SIG_IPI); | ||
170 | |||
171 | - r = hv_vcpu_create((hv_vcpuid_t *)&cpu->hvf_fd, HV_VCPU_DEFAULT); | ||
172 | + r = hv_vcpu_create((hv_vcpuid_t *)&cpu->hvf->fd, HV_VCPU_DEFAULT); | ||
173 | cpu->vcpu_dirty = 1; | ||
174 | assert_hvf_ok(r); | ||
175 | |||
176 | diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c | ||
177 | index XXXXXXX..XXXXXXX 100644 | ||
178 | --- a/target/i386/hvf/hvf.c | ||
179 | +++ b/target/i386/hvf/hvf.c | ||
180 | @@ -XXX,XX +XXX,XX @@ void vmx_update_tpr(CPUState *cpu) | ||
181 | int tpr = cpu_get_apic_tpr(x86_cpu->apic_state) << 4; | ||
182 | int irr = apic_get_highest_priority_irr(x86_cpu->apic_state); | ||
183 | |||
184 | - wreg(cpu->hvf_fd, HV_X86_TPR, tpr); | ||
185 | + wreg(cpu->hvf->fd, HV_X86_TPR, tpr); | ||
186 | if (irr == -1) { | ||
187 | - wvmcs(cpu->hvf_fd, VMCS_TPR_THRESHOLD, 0); | ||
188 | + wvmcs(cpu->hvf->fd, VMCS_TPR_THRESHOLD, 0); | ||
189 | } else { | ||
190 | - wvmcs(cpu->hvf_fd, VMCS_TPR_THRESHOLD, (irr > tpr) ? tpr >> 4 : | ||
191 | + wvmcs(cpu->hvf->fd, VMCS_TPR_THRESHOLD, (irr > tpr) ? tpr >> 4 : | ||
192 | irr >> 4); | ||
193 | } | ||
194 | } | ||
195 | @@ -XXX,XX +XXX,XX @@ void vmx_update_tpr(CPUState *cpu) | ||
196 | static void update_apic_tpr(CPUState *cpu) | ||
197 | { | ||
198 | X86CPU *x86_cpu = X86_CPU(cpu); | ||
199 | - int tpr = rreg(cpu->hvf_fd, HV_X86_TPR) >> 4; | ||
200 | + int tpr = rreg(cpu->hvf->fd, HV_X86_TPR) >> 4; | ||
201 | cpu_set_apic_tpr(x86_cpu->apic_state, tpr); | ||
202 | } | ||
203 | |||
204 | @@ -XXX,XX +XXX,XX @@ int hvf_arch_init_vcpu(CPUState *cpu) | ||
205 | } | ||
206 | |||
207 | /* set VMCS control fields */ | ||
208 | - wvmcs(cpu->hvf_fd, VMCS_PIN_BASED_CTLS, | ||
209 | + wvmcs(cpu->hvf->fd, VMCS_PIN_BASED_CTLS, | ||
210 | cap2ctrl(hvf_state->hvf_caps->vmx_cap_pinbased, | ||
211 | VMCS_PIN_BASED_CTLS_EXTINT | | ||
212 | VMCS_PIN_BASED_CTLS_NMI | | ||
213 | VMCS_PIN_BASED_CTLS_VNMI)); | ||
214 | - wvmcs(cpu->hvf_fd, VMCS_PRI_PROC_BASED_CTLS, | ||
215 | + wvmcs(cpu->hvf->fd, VMCS_PRI_PROC_BASED_CTLS, | ||
216 | cap2ctrl(hvf_state->hvf_caps->vmx_cap_procbased, | ||
217 | VMCS_PRI_PROC_BASED_CTLS_HLT | | ||
218 | VMCS_PRI_PROC_BASED_CTLS_MWAIT | | ||
219 | VMCS_PRI_PROC_BASED_CTLS_TSC_OFFSET | | ||
220 | VMCS_PRI_PROC_BASED_CTLS_TPR_SHADOW) | | ||
221 | VMCS_PRI_PROC_BASED_CTLS_SEC_CONTROL); | ||
222 | - wvmcs(cpu->hvf_fd, VMCS_SEC_PROC_BASED_CTLS, | ||
223 | + wvmcs(cpu->hvf->fd, VMCS_SEC_PROC_BASED_CTLS, | ||
224 | cap2ctrl(hvf_state->hvf_caps->vmx_cap_procbased2, | ||
225 | VMCS_PRI_PROC_BASED2_CTLS_APIC_ACCESSES)); | ||
226 | |||
227 | - wvmcs(cpu->hvf_fd, VMCS_ENTRY_CTLS, cap2ctrl(hvf_state->hvf_caps->vmx_cap_entry, | ||
228 | + wvmcs(cpu->hvf->fd, VMCS_ENTRY_CTLS, cap2ctrl(hvf_state->hvf_caps->vmx_cap_entry, | ||
229 | 0)); | ||
230 | - wvmcs(cpu->hvf_fd, VMCS_EXCEPTION_BITMAP, 0); /* Double fault */ | ||
231 | + wvmcs(cpu->hvf->fd, VMCS_EXCEPTION_BITMAP, 0); /* Double fault */ | ||
232 | |||
233 | - wvmcs(cpu->hvf_fd, VMCS_TPR_THRESHOLD, 0); | ||
234 | + wvmcs(cpu->hvf->fd, VMCS_TPR_THRESHOLD, 0); | ||
235 | |||
236 | x86cpu = X86_CPU(cpu); | ||
237 | x86cpu->env.xsave_buf = qemu_memalign(4096, 4096); | ||
238 | |||
239 | - hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_STAR, 1); | ||
240 | - hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_LSTAR, 1); | ||
241 | - hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_CSTAR, 1); | ||
242 | - hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_FMASK, 1); | ||
243 | - hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_FSBASE, 1); | ||
244 | - hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_GSBASE, 1); | ||
245 | - hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_KERNELGSBASE, 1); | ||
246 | - hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_TSC_AUX, 1); | ||
247 | - hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_IA32_TSC, 1); | ||
248 | - hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_IA32_SYSENTER_CS, 1); | ||
249 | - hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_IA32_SYSENTER_EIP, 1); | ||
250 | - hv_vcpu_enable_native_msr(cpu->hvf_fd, MSR_IA32_SYSENTER_ESP, 1); | ||
251 | + hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_STAR, 1); | ||
252 | + hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_LSTAR, 1); | ||
253 | + hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_CSTAR, 1); | ||
254 | + hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_FMASK, 1); | ||
255 | + hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_FSBASE, 1); | ||
256 | + hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_GSBASE, 1); | ||
257 | + hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_KERNELGSBASE, 1); | ||
258 | + hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_TSC_AUX, 1); | ||
259 | + hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_IA32_TSC, 1); | ||
260 | + hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_IA32_SYSENTER_CS, 1); | ||
261 | + hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_IA32_SYSENTER_EIP, 1); | ||
262 | + hv_vcpu_enable_native_msr(cpu->hvf->fd, MSR_IA32_SYSENTER_ESP, 1); | ||
263 | |||
264 | return 0; | ||
265 | } | ||
266 | @@ -XXX,XX +XXX,XX @@ static void hvf_store_events(CPUState *cpu, uint32_t ins_len, uint64_t idtvec_in | ||
267 | } | ||
268 | if (idtvec_info & VMCS_IDT_VEC_ERRCODE_VALID) { | ||
269 | env->has_error_code = true; | ||
270 | - env->error_code = rvmcs(cpu->hvf_fd, VMCS_IDT_VECTORING_ERROR); | ||
271 | + env->error_code = rvmcs(cpu->hvf->fd, VMCS_IDT_VECTORING_ERROR); | ||
272 | } | ||
273 | } | ||
274 | - if ((rvmcs(cpu->hvf_fd, VMCS_GUEST_INTERRUPTIBILITY) & | ||
275 | + if ((rvmcs(cpu->hvf->fd, VMCS_GUEST_INTERRUPTIBILITY) & | ||
276 | VMCS_INTERRUPTIBILITY_NMI_BLOCKING)) { | ||
277 | env->hflags2 |= HF2_NMI_MASK; | ||
278 | } else { | ||
279 | env->hflags2 &= ~HF2_NMI_MASK; | ||
280 | } | ||
281 | - if (rvmcs(cpu->hvf_fd, VMCS_GUEST_INTERRUPTIBILITY) & | ||
282 | + if (rvmcs(cpu->hvf->fd, VMCS_GUEST_INTERRUPTIBILITY) & | ||
283 | (VMCS_INTERRUPTIBILITY_STI_BLOCKING | | ||
284 | VMCS_INTERRUPTIBILITY_MOVSS_BLOCKING)) { | ||
285 | env->hflags |= HF_INHIBIT_IRQ_MASK; | ||
286 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) | ||
287 | return EXCP_HLT; | ||
288 | } | ||
289 | |||
290 | - hv_return_t r = hv_vcpu_run(cpu->hvf_fd); | ||
291 | + hv_return_t r = hv_vcpu_run(cpu->hvf->fd); | ||
292 | assert_hvf_ok(r); | ||
293 | |||
294 | /* handle VMEXIT */ | ||
295 | - uint64_t exit_reason = rvmcs(cpu->hvf_fd, VMCS_EXIT_REASON); | ||
296 | - uint64_t exit_qual = rvmcs(cpu->hvf_fd, VMCS_EXIT_QUALIFICATION); | ||
297 | - uint32_t ins_len = (uint32_t)rvmcs(cpu->hvf_fd, | ||
298 | + uint64_t exit_reason = rvmcs(cpu->hvf->fd, VMCS_EXIT_REASON); | ||
299 | + uint64_t exit_qual = rvmcs(cpu->hvf->fd, VMCS_EXIT_QUALIFICATION); | ||
300 | + uint32_t ins_len = (uint32_t)rvmcs(cpu->hvf->fd, | ||
301 | VMCS_EXIT_INSTRUCTION_LENGTH); | ||
302 | |||
303 | - uint64_t idtvec_info = rvmcs(cpu->hvf_fd, VMCS_IDT_VECTORING_INFO); | ||
304 | + uint64_t idtvec_info = rvmcs(cpu->hvf->fd, VMCS_IDT_VECTORING_INFO); | ||
305 | |||
306 | hvf_store_events(cpu, ins_len, idtvec_info); | ||
307 | - rip = rreg(cpu->hvf_fd, HV_X86_RIP); | ||
308 | - env->eflags = rreg(cpu->hvf_fd, HV_X86_RFLAGS); | ||
309 | + rip = rreg(cpu->hvf->fd, HV_X86_RIP); | ||
310 | + env->eflags = rreg(cpu->hvf->fd, HV_X86_RFLAGS); | ||
311 | |||
312 | qemu_mutex_lock_iothread(); | ||
313 | |||
314 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) | ||
315 | case EXIT_REASON_EPT_FAULT: | ||
316 | { | ||
317 | hvf_slot *slot; | ||
318 | - uint64_t gpa = rvmcs(cpu->hvf_fd, VMCS_GUEST_PHYSICAL_ADDRESS); | ||
319 | + uint64_t gpa = rvmcs(cpu->hvf->fd, VMCS_GUEST_PHYSICAL_ADDRESS); | ||
320 | |||
321 | if (((idtvec_info & VMCS_IDT_VEC_VALID) == 0) && | ||
322 | ((exit_qual & EXIT_QUAL_NMIUDTI) != 0)) { | ||
323 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) | ||
324 | store_regs(cpu); | ||
325 | break; | ||
326 | } else if (!string && !in) { | ||
327 | - RAX(env) = rreg(cpu->hvf_fd, HV_X86_RAX); | ||
328 | + RAX(env) = rreg(cpu->hvf->fd, HV_X86_RAX); | ||
329 | hvf_handle_io(env, port, &RAX(env), 1, size, 1); | ||
330 | macvm_set_rip(cpu, rip + ins_len); | ||
331 | break; | ||
332 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) | ||
333 | break; | ||
334 | } | ||
335 | case EXIT_REASON_CPUID: { | ||
336 | - uint32_t rax = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RAX); | ||
337 | - uint32_t rbx = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RBX); | ||
338 | - uint32_t rcx = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RCX); | ||
339 | - uint32_t rdx = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RDX); | ||
340 | + uint32_t rax = (uint32_t)rreg(cpu->hvf->fd, HV_X86_RAX); | ||
341 | + uint32_t rbx = (uint32_t)rreg(cpu->hvf->fd, HV_X86_RBX); | ||
342 | + uint32_t rcx = (uint32_t)rreg(cpu->hvf->fd, HV_X86_RCX); | ||
343 | + uint32_t rdx = (uint32_t)rreg(cpu->hvf->fd, HV_X86_RDX); | ||
344 | |||
345 | if (rax == 1) { | ||
346 | /* CPUID1.ecx.OSXSAVE needs to know CR4 */ | ||
347 | - env->cr[4] = rvmcs(cpu->hvf_fd, VMCS_GUEST_CR4); | ||
348 | + env->cr[4] = rvmcs(cpu->hvf->fd, VMCS_GUEST_CR4); | ||
349 | } | ||
350 | hvf_cpu_x86_cpuid(env, rax, rcx, &rax, &rbx, &rcx, &rdx); | ||
351 | |||
352 | - wreg(cpu->hvf_fd, HV_X86_RAX, rax); | ||
353 | - wreg(cpu->hvf_fd, HV_X86_RBX, rbx); | ||
354 | - wreg(cpu->hvf_fd, HV_X86_RCX, rcx); | ||
355 | - wreg(cpu->hvf_fd, HV_X86_RDX, rdx); | ||
356 | + wreg(cpu->hvf->fd, HV_X86_RAX, rax); | ||
357 | + wreg(cpu->hvf->fd, HV_X86_RBX, rbx); | ||
358 | + wreg(cpu->hvf->fd, HV_X86_RCX, rcx); | ||
359 | + wreg(cpu->hvf->fd, HV_X86_RDX, rdx); | ||
360 | |||
361 | macvm_set_rip(cpu, rip + ins_len); | ||
362 | break; | ||
363 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) | ||
364 | case EXIT_REASON_XSETBV: { | ||
365 | X86CPU *x86_cpu = X86_CPU(cpu); | ||
366 | CPUX86State *env = &x86_cpu->env; | ||
367 | - uint32_t eax = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RAX); | ||
368 | - uint32_t ecx = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RCX); | ||
369 | - uint32_t edx = (uint32_t)rreg(cpu->hvf_fd, HV_X86_RDX); | ||
370 | + uint32_t eax = (uint32_t)rreg(cpu->hvf->fd, HV_X86_RAX); | ||
371 | + uint32_t ecx = (uint32_t)rreg(cpu->hvf->fd, HV_X86_RCX); | ||
372 | + uint32_t edx = (uint32_t)rreg(cpu->hvf->fd, HV_X86_RDX); | ||
373 | |||
374 | if (ecx) { | ||
375 | macvm_set_rip(cpu, rip + ins_len); | ||
376 | break; | ||
377 | } | ||
378 | env->xcr0 = ((uint64_t)edx << 32) | eax; | ||
379 | - wreg(cpu->hvf_fd, HV_X86_XCR0, env->xcr0 | 1); | ||
380 | + wreg(cpu->hvf->fd, HV_X86_XCR0, env->xcr0 | 1); | ||
381 | macvm_set_rip(cpu, rip + ins_len); | ||
382 | break; | ||
383 | } | ||
384 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) | ||
385 | |||
386 | switch (cr) { | ||
387 | case 0x0: { | ||
388 | - macvm_set_cr0(cpu->hvf_fd, RRX(env, reg)); | ||
389 | + macvm_set_cr0(cpu->hvf->fd, RRX(env, reg)); | ||
390 | break; | ||
391 | } | ||
392 | case 4: { | ||
393 | - macvm_set_cr4(cpu->hvf_fd, RRX(env, reg)); | ||
394 | + macvm_set_cr4(cpu->hvf->fd, RRX(env, reg)); | ||
395 | break; | ||
396 | } | ||
397 | case 8: { | ||
398 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) | ||
399 | break; | ||
400 | } | ||
401 | case EXIT_REASON_TASK_SWITCH: { | ||
402 | - uint64_t vinfo = rvmcs(cpu->hvf_fd, VMCS_IDT_VECTORING_INFO); | ||
403 | + uint64_t vinfo = rvmcs(cpu->hvf->fd, VMCS_IDT_VECTORING_INFO); | ||
404 | x68_segment_selector sel = {.sel = exit_qual & 0xffff}; | ||
405 | vmx_handle_task_switch(cpu, sel, (exit_qual >> 30) & 0x3, | ||
406 | vinfo & VMCS_INTR_VALID, vinfo & VECTORING_INFO_VECTOR_MASK, vinfo | ||
407 | @@ -XXX,XX +XXX,XX @@ int hvf_vcpu_exec(CPUState *cpu) | ||
408 | break; | ||
409 | } | ||
410 | case EXIT_REASON_RDPMC: | ||
411 | - wreg(cpu->hvf_fd, HV_X86_RAX, 0); | ||
412 | - wreg(cpu->hvf_fd, HV_X86_RDX, 0); | ||
413 | + wreg(cpu->hvf->fd, HV_X86_RAX, 0); | ||
414 | + wreg(cpu->hvf->fd, HV_X86_RDX, 0); | ||
415 | macvm_set_rip(cpu, rip + ins_len); | ||
416 | break; | ||
417 | case VMX_REASON_VMCALL: | ||
418 | diff --git a/target/i386/hvf/x86.c b/target/i386/hvf/x86.c | ||
419 | index XXXXXXX..XXXXXXX 100644 | ||
420 | --- a/target/i386/hvf/x86.c | ||
421 | +++ b/target/i386/hvf/x86.c | ||
422 | @@ -XXX,XX +XXX,XX @@ bool x86_read_segment_descriptor(struct CPUState *cpu, | ||
423 | } | ||
424 | |||
425 | if (GDT_SEL == sel.ti) { | ||
426 | - base = rvmcs(cpu->hvf_fd, VMCS_GUEST_GDTR_BASE); | ||
427 | - limit = rvmcs(cpu->hvf_fd, VMCS_GUEST_GDTR_LIMIT); | ||
428 | + base = rvmcs(cpu->hvf->fd, VMCS_GUEST_GDTR_BASE); | ||
429 | + limit = rvmcs(cpu->hvf->fd, VMCS_GUEST_GDTR_LIMIT); | ||
430 | } else { | ||
431 | - base = rvmcs(cpu->hvf_fd, VMCS_GUEST_LDTR_BASE); | ||
432 | - limit = rvmcs(cpu->hvf_fd, VMCS_GUEST_LDTR_LIMIT); | ||
433 | + base = rvmcs(cpu->hvf->fd, VMCS_GUEST_LDTR_BASE); | ||
434 | + limit = rvmcs(cpu->hvf->fd, VMCS_GUEST_LDTR_LIMIT); | ||
435 | } | ||
436 | |||
437 | if (sel.index * 8 >= limit) { | ||
438 | @@ -XXX,XX +XXX,XX @@ bool x86_write_segment_descriptor(struct CPUState *cpu, | ||
439 | uint32_t limit; | ||
440 | |||
441 | if (GDT_SEL == sel.ti) { | ||
442 | - base = rvmcs(cpu->hvf_fd, VMCS_GUEST_GDTR_BASE); | ||
443 | - limit = rvmcs(cpu->hvf_fd, VMCS_GUEST_GDTR_LIMIT); | ||
444 | + base = rvmcs(cpu->hvf->fd, VMCS_GUEST_GDTR_BASE); | ||
445 | + limit = rvmcs(cpu->hvf->fd, VMCS_GUEST_GDTR_LIMIT); | ||
446 | } else { | ||
447 | - base = rvmcs(cpu->hvf_fd, VMCS_GUEST_LDTR_BASE); | ||
448 | - limit = rvmcs(cpu->hvf_fd, VMCS_GUEST_LDTR_LIMIT); | ||
449 | + base = rvmcs(cpu->hvf->fd, VMCS_GUEST_LDTR_BASE); | ||
450 | + limit = rvmcs(cpu->hvf->fd, VMCS_GUEST_LDTR_LIMIT); | ||
451 | } | ||
452 | |||
453 | if (sel.index * 8 >= limit) { | ||
454 | @@ -XXX,XX +XXX,XX @@ bool x86_write_segment_descriptor(struct CPUState *cpu, | ||
455 | bool x86_read_call_gate(struct CPUState *cpu, struct x86_call_gate *idt_desc, | ||
456 | int gate) | ||
457 | { | ||
458 | - target_ulong base = rvmcs(cpu->hvf_fd, VMCS_GUEST_IDTR_BASE); | ||
459 | - uint32_t limit = rvmcs(cpu->hvf_fd, VMCS_GUEST_IDTR_LIMIT); | ||
460 | + target_ulong base = rvmcs(cpu->hvf->fd, VMCS_GUEST_IDTR_BASE); | ||
461 | + uint32_t limit = rvmcs(cpu->hvf->fd, VMCS_GUEST_IDTR_LIMIT); | ||
462 | |||
463 | memset(idt_desc, 0, sizeof(*idt_desc)); | ||
464 | if (gate * 8 >= limit) { | ||
465 | @@ -XXX,XX +XXX,XX @@ bool x86_read_call_gate(struct CPUState *cpu, struct x86_call_gate *idt_desc, | ||
466 | |||
467 | bool x86_is_protected(struct CPUState *cpu) | ||
468 | { | ||
469 | - uint64_t cr0 = rvmcs(cpu->hvf_fd, VMCS_GUEST_CR0); | ||
470 | + uint64_t cr0 = rvmcs(cpu->hvf->fd, VMCS_GUEST_CR0); | ||
471 | return cr0 & CR0_PE; | ||
472 | } | ||
473 | |||
474 | @@ -XXX,XX +XXX,XX @@ bool x86_is_v8086(struct CPUState *cpu) | ||
475 | |||
476 | bool x86_is_long_mode(struct CPUState *cpu) | ||
477 | { | ||
478 | - return rvmcs(cpu->hvf_fd, VMCS_GUEST_IA32_EFER) & MSR_EFER_LMA; | ||
479 | + return rvmcs(cpu->hvf->fd, VMCS_GUEST_IA32_EFER) & MSR_EFER_LMA; | ||
480 | } | ||
481 | |||
482 | bool x86_is_long64_mode(struct CPUState *cpu) | ||
483 | @@ -XXX,XX +XXX,XX @@ bool x86_is_long64_mode(struct CPUState *cpu) | ||
484 | |||
485 | bool x86_is_paging_mode(struct CPUState *cpu) | ||
486 | { | ||
487 | - uint64_t cr0 = rvmcs(cpu->hvf_fd, VMCS_GUEST_CR0); | ||
488 | + uint64_t cr0 = rvmcs(cpu->hvf->fd, VMCS_GUEST_CR0); | ||
489 | return cr0 & CR0_PG; | ||
490 | } | ||
491 | |||
492 | bool x86_is_pae_enabled(struct CPUState *cpu) | ||
493 | { | ||
494 | - uint64_t cr4 = rvmcs(cpu->hvf_fd, VMCS_GUEST_CR4); | ||
495 | + uint64_t cr4 = rvmcs(cpu->hvf->fd, VMCS_GUEST_CR4); | ||
496 | return cr4 & CR4_PAE; | ||
497 | } | ||
498 | |||
499 | diff --git a/target/i386/hvf/x86_descr.c b/target/i386/hvf/x86_descr.c | ||
500 | index XXXXXXX..XXXXXXX 100644 | ||
501 | --- a/target/i386/hvf/x86_descr.c | ||
502 | +++ b/target/i386/hvf/x86_descr.c | ||
503 | @@ -XXX,XX +XXX,XX @@ static const struct vmx_segment_field { | ||
504 | |||
505 | uint32_t vmx_read_segment_limit(CPUState *cpu, X86Seg seg) | ||
506 | { | ||
507 | - return (uint32_t)rvmcs(cpu->hvf_fd, vmx_segment_fields[seg].limit); | ||
508 | + return (uint32_t)rvmcs(cpu->hvf->fd, vmx_segment_fields[seg].limit); | ||
509 | } | ||
510 | |||
511 | uint32_t vmx_read_segment_ar(CPUState *cpu, X86Seg seg) | ||
512 | { | ||
513 | - return (uint32_t)rvmcs(cpu->hvf_fd, vmx_segment_fields[seg].ar_bytes); | ||
514 | + return (uint32_t)rvmcs(cpu->hvf->fd, vmx_segment_fields[seg].ar_bytes); | ||
515 | } | ||
516 | |||
517 | uint64_t vmx_read_segment_base(CPUState *cpu, X86Seg seg) | ||
518 | { | ||
519 | - return rvmcs(cpu->hvf_fd, vmx_segment_fields[seg].base); | ||
520 | + return rvmcs(cpu->hvf->fd, vmx_segment_fields[seg].base); | ||
521 | } | ||
522 | |||
523 | x68_segment_selector vmx_read_segment_selector(CPUState *cpu, X86Seg seg) | ||
524 | { | ||
525 | x68_segment_selector sel; | ||
526 | - sel.sel = rvmcs(cpu->hvf_fd, vmx_segment_fields[seg].selector); | ||
527 | + sel.sel = rvmcs(cpu->hvf->fd, vmx_segment_fields[seg].selector); | ||
528 | return sel; | ||
529 | } | ||
530 | |||
531 | void vmx_write_segment_selector(struct CPUState *cpu, x68_segment_selector selector, X86Seg seg) | ||
532 | { | ||
533 | - wvmcs(cpu->hvf_fd, vmx_segment_fields[seg].selector, selector.sel); | ||
534 | + wvmcs(cpu->hvf->fd, vmx_segment_fields[seg].selector, selector.sel); | ||
535 | } | ||
536 | |||
537 | void vmx_read_segment_descriptor(struct CPUState *cpu, struct vmx_segment *desc, X86Seg seg) | ||
538 | { | ||
539 | - desc->sel = rvmcs(cpu->hvf_fd, vmx_segment_fields[seg].selector); | ||
540 | - desc->base = rvmcs(cpu->hvf_fd, vmx_segment_fields[seg].base); | ||
541 | - desc->limit = rvmcs(cpu->hvf_fd, vmx_segment_fields[seg].limit); | ||
542 | - desc->ar = rvmcs(cpu->hvf_fd, vmx_segment_fields[seg].ar_bytes); | ||
543 | + desc->sel = rvmcs(cpu->hvf->fd, vmx_segment_fields[seg].selector); | ||
544 | + desc->base = rvmcs(cpu->hvf->fd, vmx_segment_fields[seg].base); | ||
545 | + desc->limit = rvmcs(cpu->hvf->fd, vmx_segment_fields[seg].limit); | ||
546 | + desc->ar = rvmcs(cpu->hvf->fd, vmx_segment_fields[seg].ar_bytes); | ||
547 | } | ||
548 | |||
549 | void vmx_write_segment_descriptor(CPUState *cpu, struct vmx_segment *desc, X86Seg seg) | ||
550 | { | ||
551 | const struct vmx_segment_field *sf = &vmx_segment_fields[seg]; | ||
552 | |||
553 | - wvmcs(cpu->hvf_fd, sf->base, desc->base); | ||
554 | - wvmcs(cpu->hvf_fd, sf->limit, desc->limit); | ||
555 | - wvmcs(cpu->hvf_fd, sf->selector, desc->sel); | ||
556 | - wvmcs(cpu->hvf_fd, sf->ar_bytes, desc->ar); | ||
557 | + wvmcs(cpu->hvf->fd, sf->base, desc->base); | ||
558 | + wvmcs(cpu->hvf->fd, sf->limit, desc->limit); | ||
559 | + wvmcs(cpu->hvf->fd, sf->selector, desc->sel); | ||
560 | + wvmcs(cpu->hvf->fd, sf->ar_bytes, desc->ar); | ||
561 | } | ||
562 | |||
563 | void x86_segment_descriptor_to_vmx(struct CPUState *cpu, x68_segment_selector selector, struct x86_segment_descriptor *desc, struct vmx_segment *vmx_desc) | ||
564 | diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c | ||
565 | index XXXXXXX..XXXXXXX 100644 | ||
566 | --- a/target/i386/hvf/x86_emu.c | ||
567 | +++ b/target/i386/hvf/x86_emu.c | ||
568 | @@ -XXX,XX +XXX,XX @@ void simulate_rdmsr(struct CPUState *cpu) | ||
569 | |||
570 | switch (msr) { | ||
571 | case MSR_IA32_TSC: | ||
572 | - val = rdtscp() + rvmcs(cpu->hvf_fd, VMCS_TSC_OFFSET); | ||
573 | + val = rdtscp() + rvmcs(cpu->hvf->fd, VMCS_TSC_OFFSET); | ||
574 | break; | ||
575 | case MSR_IA32_APICBASE: | ||
576 | val = cpu_get_apic_base(X86_CPU(cpu)->apic_state); | ||
577 | @@ -XXX,XX +XXX,XX @@ void simulate_rdmsr(struct CPUState *cpu) | ||
578 | val = x86_cpu->ucode_rev; | ||
579 | break; | ||
580 | case MSR_EFER: | ||
581 | - val = rvmcs(cpu->hvf_fd, VMCS_GUEST_IA32_EFER); | ||
582 | + val = rvmcs(cpu->hvf->fd, VMCS_GUEST_IA32_EFER); | ||
583 | break; | ||
584 | case MSR_FSBASE: | ||
585 | - val = rvmcs(cpu->hvf_fd, VMCS_GUEST_FS_BASE); | ||
586 | + val = rvmcs(cpu->hvf->fd, VMCS_GUEST_FS_BASE); | ||
587 | break; | ||
588 | case MSR_GSBASE: | ||
589 | - val = rvmcs(cpu->hvf_fd, VMCS_GUEST_GS_BASE); | ||
590 | + val = rvmcs(cpu->hvf->fd, VMCS_GUEST_GS_BASE); | ||
591 | break; | ||
592 | case MSR_KERNELGSBASE: | ||
593 | - val = rvmcs(cpu->hvf_fd, VMCS_HOST_FS_BASE); | ||
594 | + val = rvmcs(cpu->hvf->fd, VMCS_HOST_FS_BASE); | ||
595 | break; | ||
596 | case MSR_STAR: | ||
597 | abort(); | ||
598 | @@ -XXX,XX +XXX,XX @@ void simulate_wrmsr(struct CPUState *cpu) | ||
599 | cpu_set_apic_base(X86_CPU(cpu)->apic_state, data); | ||
600 | break; | ||
601 | case MSR_FSBASE: | ||
602 | - wvmcs(cpu->hvf_fd, VMCS_GUEST_FS_BASE, data); | ||
603 | + wvmcs(cpu->hvf->fd, VMCS_GUEST_FS_BASE, data); | ||
604 | break; | ||
605 | case MSR_GSBASE: | ||
606 | - wvmcs(cpu->hvf_fd, VMCS_GUEST_GS_BASE, data); | ||
607 | + wvmcs(cpu->hvf->fd, VMCS_GUEST_GS_BASE, data); | ||
608 | break; | ||
609 | case MSR_KERNELGSBASE: | ||
610 | - wvmcs(cpu->hvf_fd, VMCS_HOST_FS_BASE, data); | ||
611 | + wvmcs(cpu->hvf->fd, VMCS_HOST_FS_BASE, data); | ||
612 | break; | ||
613 | case MSR_STAR: | ||
614 | abort(); | ||
615 | @@ -XXX,XX +XXX,XX @@ void simulate_wrmsr(struct CPUState *cpu) | ||
616 | break; | ||
617 | case MSR_EFER: | ||
618 | /*printf("new efer %llx\n", EFER(cpu));*/ | ||
619 | - wvmcs(cpu->hvf_fd, VMCS_GUEST_IA32_EFER, data); | ||
620 | + wvmcs(cpu->hvf->fd, VMCS_GUEST_IA32_EFER, data); | ||
621 | if (data & MSR_EFER_NXE) { | ||
622 | - hv_vcpu_invalidate_tlb(cpu->hvf_fd); | ||
623 | + hv_vcpu_invalidate_tlb(cpu->hvf->fd); | ||
624 | } | ||
625 | break; | ||
626 | case MSR_MTRRphysBase(0): | ||
627 | @@ -XXX,XX +XXX,XX @@ void load_regs(struct CPUState *cpu) | ||
628 | CPUX86State *env = &x86_cpu->env; | ||
629 | |||
630 | int i = 0; | ||
631 | - RRX(env, R_EAX) = rreg(cpu->hvf_fd, HV_X86_RAX); | ||
632 | - RRX(env, R_EBX) = rreg(cpu->hvf_fd, HV_X86_RBX); | ||
633 | - RRX(env, R_ECX) = rreg(cpu->hvf_fd, HV_X86_RCX); | ||
634 | - RRX(env, R_EDX) = rreg(cpu->hvf_fd, HV_X86_RDX); | ||
635 | - RRX(env, R_ESI) = rreg(cpu->hvf_fd, HV_X86_RSI); | ||
636 | - RRX(env, R_EDI) = rreg(cpu->hvf_fd, HV_X86_RDI); | ||
637 | - RRX(env, R_ESP) = rreg(cpu->hvf_fd, HV_X86_RSP); | ||
638 | - RRX(env, R_EBP) = rreg(cpu->hvf_fd, HV_X86_RBP); | ||
639 | + RRX(env, R_EAX) = rreg(cpu->hvf->fd, HV_X86_RAX); | ||
640 | + RRX(env, R_EBX) = rreg(cpu->hvf->fd, HV_X86_RBX); | ||
641 | + RRX(env, R_ECX) = rreg(cpu->hvf->fd, HV_X86_RCX); | ||
642 | + RRX(env, R_EDX) = rreg(cpu->hvf->fd, HV_X86_RDX); | ||
643 | + RRX(env, R_ESI) = rreg(cpu->hvf->fd, HV_X86_RSI); | ||
644 | + RRX(env, R_EDI) = rreg(cpu->hvf->fd, HV_X86_RDI); | ||
645 | + RRX(env, R_ESP) = rreg(cpu->hvf->fd, HV_X86_RSP); | ||
646 | + RRX(env, R_EBP) = rreg(cpu->hvf->fd, HV_X86_RBP); | ||
647 | for (i = 8; i < 16; i++) { | ||
648 | - RRX(env, i) = rreg(cpu->hvf_fd, HV_X86_RAX + i); | ||
649 | + RRX(env, i) = rreg(cpu->hvf->fd, HV_X86_RAX + i); | ||
650 | } | ||
651 | |||
652 | - env->eflags = rreg(cpu->hvf_fd, HV_X86_RFLAGS); | ||
653 | + env->eflags = rreg(cpu->hvf->fd, HV_X86_RFLAGS); | ||
654 | rflags_to_lflags(env); | ||
655 | - env->eip = rreg(cpu->hvf_fd, HV_X86_RIP); | ||
656 | + env->eip = rreg(cpu->hvf->fd, HV_X86_RIP); | ||
657 | } | ||
658 | |||
659 | void store_regs(struct CPUState *cpu) | ||
660 | @@ -XXX,XX +XXX,XX @@ void store_regs(struct CPUState *cpu) | ||
661 | CPUX86State *env = &x86_cpu->env; | ||
662 | |||
663 | int i = 0; | ||
664 | - wreg(cpu->hvf_fd, HV_X86_RAX, RAX(env)); | ||
665 | - wreg(cpu->hvf_fd, HV_X86_RBX, RBX(env)); | ||
666 | - wreg(cpu->hvf_fd, HV_X86_RCX, RCX(env)); | ||
667 | - wreg(cpu->hvf_fd, HV_X86_RDX, RDX(env)); | ||
668 | - wreg(cpu->hvf_fd, HV_X86_RSI, RSI(env)); | ||
669 | - wreg(cpu->hvf_fd, HV_X86_RDI, RDI(env)); | ||
670 | - wreg(cpu->hvf_fd, HV_X86_RBP, RBP(env)); | ||
671 | - wreg(cpu->hvf_fd, HV_X86_RSP, RSP(env)); | ||
672 | + wreg(cpu->hvf->fd, HV_X86_RAX, RAX(env)); | ||
673 | + wreg(cpu->hvf->fd, HV_X86_RBX, RBX(env)); | ||
674 | + wreg(cpu->hvf->fd, HV_X86_RCX, RCX(env)); | ||
675 | + wreg(cpu->hvf->fd, HV_X86_RDX, RDX(env)); | ||
676 | + wreg(cpu->hvf->fd, HV_X86_RSI, RSI(env)); | ||
677 | + wreg(cpu->hvf->fd, HV_X86_RDI, RDI(env)); | ||
678 | + wreg(cpu->hvf->fd, HV_X86_RBP, RBP(env)); | ||
679 | + wreg(cpu->hvf->fd, HV_X86_RSP, RSP(env)); | ||
680 | for (i = 8; i < 16; i++) { | ||
681 | - wreg(cpu->hvf_fd, HV_X86_RAX + i, RRX(env, i)); | ||
682 | + wreg(cpu->hvf->fd, HV_X86_RAX + i, RRX(env, i)); | ||
683 | } | ||
684 | |||
685 | lflags_to_rflags(env); | ||
686 | - wreg(cpu->hvf_fd, HV_X86_RFLAGS, env->eflags); | ||
687 | + wreg(cpu->hvf->fd, HV_X86_RFLAGS, env->eflags); | ||
688 | macvm_set_rip(cpu, env->eip); | ||
689 | } | ||
690 | |||
691 | diff --git a/target/i386/hvf/x86_mmu.c b/target/i386/hvf/x86_mmu.c | ||
692 | index XXXXXXX..XXXXXXX 100644 | ||
693 | --- a/target/i386/hvf/x86_mmu.c | ||
694 | +++ b/target/i386/hvf/x86_mmu.c | ||
695 | @@ -XXX,XX +XXX,XX @@ static bool test_pt_entry(struct CPUState *cpu, struct gpt_translation *pt, | ||
696 | pt->err_code |= MMU_PAGE_PT; | ||
697 | } | ||
698 | |||
699 | - uint32_t cr0 = rvmcs(cpu->hvf_fd, VMCS_GUEST_CR0); | ||
700 | + uint32_t cr0 = rvmcs(cpu->hvf->fd, VMCS_GUEST_CR0); | ||
701 | /* check protection */ | ||
702 | if (cr0 & CR0_WP) { | ||
703 | if (pt->write_access && !pte_write_access(pte)) { | ||
704 | @@ -XXX,XX +XXX,XX @@ static bool walk_gpt(struct CPUState *cpu, target_ulong addr, int err_code, | ||
705 | { | ||
706 | int top_level, level; | ||
707 | bool is_large = false; | ||
708 | - target_ulong cr3 = rvmcs(cpu->hvf_fd, VMCS_GUEST_CR3); | ||
709 | + target_ulong cr3 = rvmcs(cpu->hvf->fd, VMCS_GUEST_CR3); | ||
710 | uint64_t page_mask = pae ? PAE_PTE_PAGE_MASK : LEGACY_PTE_PAGE_MASK; | ||
711 | |||
712 | memset(pt, 0, sizeof(*pt)); | ||
713 | diff --git a/target/i386/hvf/x86_task.c b/target/i386/hvf/x86_task.c | ||
714 | index XXXXXXX..XXXXXXX 100644 | ||
715 | --- a/target/i386/hvf/x86_task.c | ||
716 | +++ b/target/i386/hvf/x86_task.c | ||
717 | @@ -XXX,XX +XXX,XX @@ static void load_state_from_tss32(CPUState *cpu, struct x86_tss_segment32 *tss) | ||
718 | X86CPU *x86_cpu = X86_CPU(cpu); | ||
719 | CPUX86State *env = &x86_cpu->env; | ||
720 | |||
721 | - wvmcs(cpu->hvf_fd, VMCS_GUEST_CR3, tss->cr3); | ||
722 | + wvmcs(cpu->hvf->fd, VMCS_GUEST_CR3, tss->cr3); | ||
723 | |||
724 | env->eip = tss->eip; | ||
725 | env->eflags = tss->eflags | 2; | ||
726 | @@ -XXX,XX +XXX,XX @@ static int task_switch_32(CPUState *cpu, x68_segment_selector tss_sel, x68_segme | ||
727 | |||
728 | void vmx_handle_task_switch(CPUState *cpu, x68_segment_selector tss_sel, int reason, bool gate_valid, uint8_t gate, uint64_t gate_type) | ||
729 | { | ||
730 | - uint64_t rip = rreg(cpu->hvf_fd, HV_X86_RIP); | ||
731 | + uint64_t rip = rreg(cpu->hvf->fd, HV_X86_RIP); | ||
732 | if (!gate_valid || (gate_type != VMCS_INTR_T_HWEXCEPTION && | ||
733 | gate_type != VMCS_INTR_T_HWINTR && | ||
734 | gate_type != VMCS_INTR_T_NMI)) { | ||
735 | - int ins_len = rvmcs(cpu->hvf_fd, VMCS_EXIT_INSTRUCTION_LENGTH); | ||
736 | + int ins_len = rvmcs(cpu->hvf->fd, VMCS_EXIT_INSTRUCTION_LENGTH); | ||
737 | macvm_set_rip(cpu, rip + ins_len); | ||
738 | return; | ||
739 | } | ||
740 | @@ -XXX,XX +XXX,XX @@ void vmx_handle_task_switch(CPUState *cpu, x68_segment_selector tss_sel, int rea | ||
741 | //ret = task_switch_16(cpu, tss_sel, old_tss_sel, old_tss_base, &next_tss_desc); | ||
742 | VM_PANIC("task_switch_16"); | ||
743 | |||
744 | - macvm_set_cr0(cpu->hvf_fd, rvmcs(cpu->hvf_fd, VMCS_GUEST_CR0) | CR0_TS); | ||
745 | + macvm_set_cr0(cpu->hvf->fd, rvmcs(cpu->hvf->fd, VMCS_GUEST_CR0) | CR0_TS); | ||
746 | x86_segment_descriptor_to_vmx(cpu, tss_sel, &next_tss_desc, &vmx_seg); | ||
747 | vmx_write_segment_descriptor(cpu, &vmx_seg, R_TR); | ||
748 | |||
749 | store_regs(cpu); | ||
750 | |||
751 | - hv_vcpu_invalidate_tlb(cpu->hvf_fd); | ||
752 | - hv_vcpu_flush(cpu->hvf_fd); | ||
753 | + hv_vcpu_invalidate_tlb(cpu->hvf->fd); | ||
754 | + hv_vcpu_flush(cpu->hvf->fd); | ||
755 | } | ||
756 | diff --git a/target/i386/hvf/x86hvf.c b/target/i386/hvf/x86hvf.c | ||
757 | index XXXXXXX..XXXXXXX 100644 | ||
758 | --- a/target/i386/hvf/x86hvf.c | ||
759 | +++ b/target/i386/hvf/x86hvf.c | ||
760 | @@ -XXX,XX +XXX,XX @@ void hvf_put_xsave(CPUState *cpu_state) | ||
761 | |||
762 | x86_cpu_xsave_all_areas(X86_CPU(cpu_state), xsave); | ||
763 | |||
764 | - if (hv_vcpu_write_fpstate(cpu_state->hvf_fd, (void*)xsave, 4096)) { | ||
765 | + if (hv_vcpu_write_fpstate(cpu_state->hvf->fd, (void*)xsave, 4096)) { | ||
766 | abort(); | ||
767 | } | ||
768 | } | ||
769 | @@ -XXX,XX +XXX,XX @@ void hvf_put_segments(CPUState *cpu_state) | ||
770 | CPUX86State *env = &X86_CPU(cpu_state)->env; | ||
771 | struct vmx_segment seg; | ||
772 | |||
773 | - wvmcs(cpu_state->hvf_fd, VMCS_GUEST_IDTR_LIMIT, env->idt.limit); | ||
774 | - wvmcs(cpu_state->hvf_fd, VMCS_GUEST_IDTR_BASE, env->idt.base); | ||
775 | + wvmcs(cpu_state->hvf->fd, VMCS_GUEST_IDTR_LIMIT, env->idt.limit); | ||
776 | + wvmcs(cpu_state->hvf->fd, VMCS_GUEST_IDTR_BASE, env->idt.base); | ||
777 | |||
778 | - wvmcs(cpu_state->hvf_fd, VMCS_GUEST_GDTR_LIMIT, env->gdt.limit); | ||
779 | - wvmcs(cpu_state->hvf_fd, VMCS_GUEST_GDTR_BASE, env->gdt.base); | ||
780 | + wvmcs(cpu_state->hvf->fd, VMCS_GUEST_GDTR_LIMIT, env->gdt.limit); | ||
781 | + wvmcs(cpu_state->hvf->fd, VMCS_GUEST_GDTR_BASE, env->gdt.base); | ||
782 | |||
783 | - /* wvmcs(cpu_state->hvf_fd, VMCS_GUEST_CR2, env->cr[2]); */ | ||
784 | - wvmcs(cpu_state->hvf_fd, VMCS_GUEST_CR3, env->cr[3]); | ||
785 | + /* wvmcs(cpu_state->hvf->fd, VMCS_GUEST_CR2, env->cr[2]); */ | ||
786 | + wvmcs(cpu_state->hvf->fd, VMCS_GUEST_CR3, env->cr[3]); | ||
787 | vmx_update_tpr(cpu_state); | ||
788 | - wvmcs(cpu_state->hvf_fd, VMCS_GUEST_IA32_EFER, env->efer); | ||
789 | + wvmcs(cpu_state->hvf->fd, VMCS_GUEST_IA32_EFER, env->efer); | ||
790 | |||
791 | - macvm_set_cr4(cpu_state->hvf_fd, env->cr[4]); | ||
792 | - macvm_set_cr0(cpu_state->hvf_fd, env->cr[0]); | ||
793 | + macvm_set_cr4(cpu_state->hvf->fd, env->cr[4]); | ||
794 | + macvm_set_cr0(cpu_state->hvf->fd, env->cr[0]); | ||
795 | |||
796 | hvf_set_segment(cpu_state, &seg, &env->segs[R_CS], false); | ||
797 | vmx_write_segment_descriptor(cpu_state, &seg, R_CS); | ||
798 | @@ -XXX,XX +XXX,XX @@ void hvf_put_segments(CPUState *cpu_state) | ||
799 | hvf_set_segment(cpu_state, &seg, &env->ldt, false); | ||
800 | vmx_write_segment_descriptor(cpu_state, &seg, R_LDTR); | ||
801 | |||
802 | - hv_vcpu_flush(cpu_state->hvf_fd); | ||
803 | + hv_vcpu_flush(cpu_state->hvf->fd); | ||
804 | } | ||
805 | |||
806 | void hvf_put_msrs(CPUState *cpu_state) | ||
807 | { | ||
808 | CPUX86State *env = &X86_CPU(cpu_state)->env; | ||
809 | |||
810 | - hv_vcpu_write_msr(cpu_state->hvf_fd, MSR_IA32_SYSENTER_CS, | ||
811 | + hv_vcpu_write_msr(cpu_state->hvf->fd, MSR_IA32_SYSENTER_CS, | ||
812 | env->sysenter_cs); | ||
813 | - hv_vcpu_write_msr(cpu_state->hvf_fd, MSR_IA32_SYSENTER_ESP, | ||
814 | + hv_vcpu_write_msr(cpu_state->hvf->fd, MSR_IA32_SYSENTER_ESP, | ||
815 | env->sysenter_esp); | ||
816 | - hv_vcpu_write_msr(cpu_state->hvf_fd, MSR_IA32_SYSENTER_EIP, | ||
817 | + hv_vcpu_write_msr(cpu_state->hvf->fd, MSR_IA32_SYSENTER_EIP, | ||
818 | env->sysenter_eip); | ||
819 | |||
820 | - hv_vcpu_write_msr(cpu_state->hvf_fd, MSR_STAR, env->star); | ||
821 | + hv_vcpu_write_msr(cpu_state->hvf->fd, MSR_STAR, env->star); | ||
822 | |||
823 | #ifdef TARGET_X86_64 | ||
824 | - hv_vcpu_write_msr(cpu_state->hvf_fd, MSR_CSTAR, env->cstar); | ||
825 | - hv_vcpu_write_msr(cpu_state->hvf_fd, MSR_KERNELGSBASE, env->kernelgsbase); | ||
826 | - hv_vcpu_write_msr(cpu_state->hvf_fd, MSR_FMASK, env->fmask); | ||
827 | - hv_vcpu_write_msr(cpu_state->hvf_fd, MSR_LSTAR, env->lstar); | ||
828 | + hv_vcpu_write_msr(cpu_state->hvf->fd, MSR_CSTAR, env->cstar); | ||
829 | + hv_vcpu_write_msr(cpu_state->hvf->fd, MSR_KERNELGSBASE, env->kernelgsbase); | ||
830 | + hv_vcpu_write_msr(cpu_state->hvf->fd, MSR_FMASK, env->fmask); | ||
831 | + hv_vcpu_write_msr(cpu_state->hvf->fd, MSR_LSTAR, env->lstar); | ||
832 | #endif | ||
833 | |||
834 | - hv_vcpu_write_msr(cpu_state->hvf_fd, MSR_GSBASE, env->segs[R_GS].base); | ||
835 | - hv_vcpu_write_msr(cpu_state->hvf_fd, MSR_FSBASE, env->segs[R_FS].base); | ||
836 | + hv_vcpu_write_msr(cpu_state->hvf->fd, MSR_GSBASE, env->segs[R_GS].base); | ||
837 | + hv_vcpu_write_msr(cpu_state->hvf->fd, MSR_FSBASE, env->segs[R_FS].base); | ||
838 | } | ||
839 | |||
840 | |||
841 | @@ -XXX,XX +XXX,XX @@ void hvf_get_xsave(CPUState *cpu_state) | ||
842 | |||
843 | xsave = X86_CPU(cpu_state)->env.xsave_buf; | ||
844 | |||
845 | - if (hv_vcpu_read_fpstate(cpu_state->hvf_fd, (void*)xsave, 4096)) { | ||
846 | + if (hv_vcpu_read_fpstate(cpu_state->hvf->fd, (void*)xsave, 4096)) { | ||
847 | abort(); | ||
848 | } | ||
849 | |||
850 | @@ -XXX,XX +XXX,XX @@ void hvf_get_segments(CPUState *cpu_state) | ||
851 | vmx_read_segment_descriptor(cpu_state, &seg, R_LDTR); | ||
852 | hvf_get_segment(&env->ldt, &seg); | ||
853 | |||
854 | - env->idt.limit = rvmcs(cpu_state->hvf_fd, VMCS_GUEST_IDTR_LIMIT); | ||
855 | - env->idt.base = rvmcs(cpu_state->hvf_fd, VMCS_GUEST_IDTR_BASE); | ||
856 | - env->gdt.limit = rvmcs(cpu_state->hvf_fd, VMCS_GUEST_GDTR_LIMIT); | ||
857 | - env->gdt.base = rvmcs(cpu_state->hvf_fd, VMCS_GUEST_GDTR_BASE); | ||
858 | + env->idt.limit = rvmcs(cpu_state->hvf->fd, VMCS_GUEST_IDTR_LIMIT); | ||
859 | + env->idt.base = rvmcs(cpu_state->hvf->fd, VMCS_GUEST_IDTR_BASE); | ||
860 | + env->gdt.limit = rvmcs(cpu_state->hvf->fd, VMCS_GUEST_GDTR_LIMIT); | ||
861 | + env->gdt.base = rvmcs(cpu_state->hvf->fd, VMCS_GUEST_GDTR_BASE); | ||
862 | |||
863 | - env->cr[0] = rvmcs(cpu_state->hvf_fd, VMCS_GUEST_CR0); | ||
864 | + env->cr[0] = rvmcs(cpu_state->hvf->fd, VMCS_GUEST_CR0); | ||
865 | env->cr[2] = 0; | ||
866 | - env->cr[3] = rvmcs(cpu_state->hvf_fd, VMCS_GUEST_CR3); | ||
867 | - env->cr[4] = rvmcs(cpu_state->hvf_fd, VMCS_GUEST_CR4); | ||
868 | + env->cr[3] = rvmcs(cpu_state->hvf->fd, VMCS_GUEST_CR3); | ||
869 | + env->cr[4] = rvmcs(cpu_state->hvf->fd, VMCS_GUEST_CR4); | ||
870 | |||
871 | - env->efer = rvmcs(cpu_state->hvf_fd, VMCS_GUEST_IA32_EFER); | ||
872 | + env->efer = rvmcs(cpu_state->hvf->fd, VMCS_GUEST_IA32_EFER); | ||
873 | } | ||
874 | |||
875 | void hvf_get_msrs(CPUState *cpu_state) | ||
876 | @@ -XXX,XX +XXX,XX @@ void hvf_get_msrs(CPUState *cpu_state) | ||
877 | CPUX86State *env = &X86_CPU(cpu_state)->env; | ||
878 | uint64_t tmp; | ||
879 | |||
880 | - hv_vcpu_read_msr(cpu_state->hvf_fd, MSR_IA32_SYSENTER_CS, &tmp); | ||
881 | + hv_vcpu_read_msr(cpu_state->hvf->fd, MSR_IA32_SYSENTER_CS, &tmp); | ||
882 | env->sysenter_cs = tmp; | ||
883 | |||
884 | - hv_vcpu_read_msr(cpu_state->hvf_fd, MSR_IA32_SYSENTER_ESP, &tmp); | ||
885 | + hv_vcpu_read_msr(cpu_state->hvf->fd, MSR_IA32_SYSENTER_ESP, &tmp); | ||
886 | env->sysenter_esp = tmp; | ||
887 | |||
888 | - hv_vcpu_read_msr(cpu_state->hvf_fd, MSR_IA32_SYSENTER_EIP, &tmp); | ||
889 | + hv_vcpu_read_msr(cpu_state->hvf->fd, MSR_IA32_SYSENTER_EIP, &tmp); | ||
890 | env->sysenter_eip = tmp; | ||
891 | |||
892 | - hv_vcpu_read_msr(cpu_state->hvf_fd, MSR_STAR, &env->star); | ||
893 | + hv_vcpu_read_msr(cpu_state->hvf->fd, MSR_STAR, &env->star); | ||
894 | |||
895 | #ifdef TARGET_X86_64 | ||
896 | - hv_vcpu_read_msr(cpu_state->hvf_fd, MSR_CSTAR, &env->cstar); | ||
897 | - hv_vcpu_read_msr(cpu_state->hvf_fd, MSR_KERNELGSBASE, &env->kernelgsbase); | ||
898 | - hv_vcpu_read_msr(cpu_state->hvf_fd, MSR_FMASK, &env->fmask); | ||
899 | - hv_vcpu_read_msr(cpu_state->hvf_fd, MSR_LSTAR, &env->lstar); | ||
900 | + hv_vcpu_read_msr(cpu_state->hvf->fd, MSR_CSTAR, &env->cstar); | ||
901 | + hv_vcpu_read_msr(cpu_state->hvf->fd, MSR_KERNELGSBASE, &env->kernelgsbase); | ||
902 | + hv_vcpu_read_msr(cpu_state->hvf->fd, MSR_FMASK, &env->fmask); | ||
903 | + hv_vcpu_read_msr(cpu_state->hvf->fd, MSR_LSTAR, &env->lstar); | ||
904 | #endif | ||
905 | |||
906 | - hv_vcpu_read_msr(cpu_state->hvf_fd, MSR_IA32_APICBASE, &tmp); | ||
907 | + hv_vcpu_read_msr(cpu_state->hvf->fd, MSR_IA32_APICBASE, &tmp); | ||
908 | |||
909 | - env->tsc = rdtscp() + rvmcs(cpu_state->hvf_fd, VMCS_TSC_OFFSET); | ||
910 | + env->tsc = rdtscp() + rvmcs(cpu_state->hvf->fd, VMCS_TSC_OFFSET); | ||
911 | } | ||
912 | |||
913 | int hvf_put_registers(CPUState *cpu_state) | ||
914 | @@ -XXX,XX +XXX,XX @@ int hvf_put_registers(CPUState *cpu_state) | ||
915 | X86CPU *x86cpu = X86_CPU(cpu_state); | ||
916 | CPUX86State *env = &x86cpu->env; | ||
917 | |||
918 | - wreg(cpu_state->hvf_fd, HV_X86_RAX, env->regs[R_EAX]); | ||
919 | - wreg(cpu_state->hvf_fd, HV_X86_RBX, env->regs[R_EBX]); | ||
920 | - wreg(cpu_state->hvf_fd, HV_X86_RCX, env->regs[R_ECX]); | ||
921 | - wreg(cpu_state->hvf_fd, HV_X86_RDX, env->regs[R_EDX]); | ||
922 | - wreg(cpu_state->hvf_fd, HV_X86_RBP, env->regs[R_EBP]); | ||
923 | - wreg(cpu_state->hvf_fd, HV_X86_RSP, env->regs[R_ESP]); | ||
924 | - wreg(cpu_state->hvf_fd, HV_X86_RSI, env->regs[R_ESI]); | ||
925 | - wreg(cpu_state->hvf_fd, HV_X86_RDI, env->regs[R_EDI]); | ||
926 | - wreg(cpu_state->hvf_fd, HV_X86_R8, env->regs[8]); | ||
927 | - wreg(cpu_state->hvf_fd, HV_X86_R9, env->regs[9]); | ||
928 | - wreg(cpu_state->hvf_fd, HV_X86_R10, env->regs[10]); | ||
929 | - wreg(cpu_state->hvf_fd, HV_X86_R11, env->regs[11]); | ||
930 | - wreg(cpu_state->hvf_fd, HV_X86_R12, env->regs[12]); | ||
931 | - wreg(cpu_state->hvf_fd, HV_X86_R13, env->regs[13]); | ||
932 | - wreg(cpu_state->hvf_fd, HV_X86_R14, env->regs[14]); | ||
933 | - wreg(cpu_state->hvf_fd, HV_X86_R15, env->regs[15]); | ||
934 | - wreg(cpu_state->hvf_fd, HV_X86_RFLAGS, env->eflags); | ||
935 | - wreg(cpu_state->hvf_fd, HV_X86_RIP, env->eip); | ||
936 | + wreg(cpu_state->hvf->fd, HV_X86_RAX, env->regs[R_EAX]); | ||
937 | + wreg(cpu_state->hvf->fd, HV_X86_RBX, env->regs[R_EBX]); | ||
938 | + wreg(cpu_state->hvf->fd, HV_X86_RCX, env->regs[R_ECX]); | ||
939 | + wreg(cpu_state->hvf->fd, HV_X86_RDX, env->regs[R_EDX]); | ||
940 | + wreg(cpu_state->hvf->fd, HV_X86_RBP, env->regs[R_EBP]); | ||
941 | + wreg(cpu_state->hvf->fd, HV_X86_RSP, env->regs[R_ESP]); | ||
942 | + wreg(cpu_state->hvf->fd, HV_X86_RSI, env->regs[R_ESI]); | ||
943 | + wreg(cpu_state->hvf->fd, HV_X86_RDI, env->regs[R_EDI]); | ||
944 | + wreg(cpu_state->hvf->fd, HV_X86_R8, env->regs[8]); | ||
945 | + wreg(cpu_state->hvf->fd, HV_X86_R9, env->regs[9]); | ||
946 | + wreg(cpu_state->hvf->fd, HV_X86_R10, env->regs[10]); | ||
947 | + wreg(cpu_state->hvf->fd, HV_X86_R11, env->regs[11]); | ||
948 | + wreg(cpu_state->hvf->fd, HV_X86_R12, env->regs[12]); | ||
949 | + wreg(cpu_state->hvf->fd, HV_X86_R13, env->regs[13]); | ||
950 | + wreg(cpu_state->hvf->fd, HV_X86_R14, env->regs[14]); | ||
951 | + wreg(cpu_state->hvf->fd, HV_X86_R15, env->regs[15]); | ||
952 | + wreg(cpu_state->hvf->fd, HV_X86_RFLAGS, env->eflags); | ||
953 | + wreg(cpu_state->hvf->fd, HV_X86_RIP, env->eip); | ||
954 | |||
955 | - wreg(cpu_state->hvf_fd, HV_X86_XCR0, env->xcr0); | ||
956 | + wreg(cpu_state->hvf->fd, HV_X86_XCR0, env->xcr0); | ||
957 | |||
958 | hvf_put_xsave(cpu_state); | ||
959 | |||
960 | @@ -XXX,XX +XXX,XX @@ int hvf_put_registers(CPUState *cpu_state) | ||
961 | |||
962 | hvf_put_msrs(cpu_state); | ||
963 | |||
964 | - wreg(cpu_state->hvf_fd, HV_X86_DR0, env->dr[0]); | ||
965 | - wreg(cpu_state->hvf_fd, HV_X86_DR1, env->dr[1]); | ||
966 | - wreg(cpu_state->hvf_fd, HV_X86_DR2, env->dr[2]); | ||
967 | - wreg(cpu_state->hvf_fd, HV_X86_DR3, env->dr[3]); | ||
968 | - wreg(cpu_state->hvf_fd, HV_X86_DR4, env->dr[4]); | ||
969 | - wreg(cpu_state->hvf_fd, HV_X86_DR5, env->dr[5]); | ||
970 | - wreg(cpu_state->hvf_fd, HV_X86_DR6, env->dr[6]); | ||
971 | - wreg(cpu_state->hvf_fd, HV_X86_DR7, env->dr[7]); | ||
972 | + wreg(cpu_state->hvf->fd, HV_X86_DR0, env->dr[0]); | ||
973 | + wreg(cpu_state->hvf->fd, HV_X86_DR1, env->dr[1]); | ||
974 | + wreg(cpu_state->hvf->fd, HV_X86_DR2, env->dr[2]); | ||
975 | + wreg(cpu_state->hvf->fd, HV_X86_DR3, env->dr[3]); | ||
976 | + wreg(cpu_state->hvf->fd, HV_X86_DR4, env->dr[4]); | ||
977 | + wreg(cpu_state->hvf->fd, HV_X86_DR5, env->dr[5]); | ||
978 | + wreg(cpu_state->hvf->fd, HV_X86_DR6, env->dr[6]); | ||
979 | + wreg(cpu_state->hvf->fd, HV_X86_DR7, env->dr[7]); | ||
980 | |||
981 | return 0; | ||
982 | } | ||
983 | @@ -XXX,XX +XXX,XX @@ int hvf_get_registers(CPUState *cpu_state) | ||
984 | X86CPU *x86cpu = X86_CPU(cpu_state); | ||
985 | CPUX86State *env = &x86cpu->env; | ||
986 | |||
987 | - env->regs[R_EAX] = rreg(cpu_state->hvf_fd, HV_X86_RAX); | ||
988 | - env->regs[R_EBX] = rreg(cpu_state->hvf_fd, HV_X86_RBX); | ||
989 | - env->regs[R_ECX] = rreg(cpu_state->hvf_fd, HV_X86_RCX); | ||
990 | - env->regs[R_EDX] = rreg(cpu_state->hvf_fd, HV_X86_RDX); | ||
991 | - env->regs[R_EBP] = rreg(cpu_state->hvf_fd, HV_X86_RBP); | ||
992 | - env->regs[R_ESP] = rreg(cpu_state->hvf_fd, HV_X86_RSP); | ||
993 | - env->regs[R_ESI] = rreg(cpu_state->hvf_fd, HV_X86_RSI); | ||
994 | - env->regs[R_EDI] = rreg(cpu_state->hvf_fd, HV_X86_RDI); | ||
995 | - env->regs[8] = rreg(cpu_state->hvf_fd, HV_X86_R8); | ||
996 | - env->regs[9] = rreg(cpu_state->hvf_fd, HV_X86_R9); | ||
997 | - env->regs[10] = rreg(cpu_state->hvf_fd, HV_X86_R10); | ||
998 | - env->regs[11] = rreg(cpu_state->hvf_fd, HV_X86_R11); | ||
999 | - env->regs[12] = rreg(cpu_state->hvf_fd, HV_X86_R12); | ||
1000 | - env->regs[13] = rreg(cpu_state->hvf_fd, HV_X86_R13); | ||
1001 | - env->regs[14] = rreg(cpu_state->hvf_fd, HV_X86_R14); | ||
1002 | - env->regs[15] = rreg(cpu_state->hvf_fd, HV_X86_R15); | ||
1003 | + env->regs[R_EAX] = rreg(cpu_state->hvf->fd, HV_X86_RAX); | ||
1004 | + env->regs[R_EBX] = rreg(cpu_state->hvf->fd, HV_X86_RBX); | ||
1005 | + env->regs[R_ECX] = rreg(cpu_state->hvf->fd, HV_X86_RCX); | ||
1006 | + env->regs[R_EDX] = rreg(cpu_state->hvf->fd, HV_X86_RDX); | ||
1007 | + env->regs[R_EBP] = rreg(cpu_state->hvf->fd, HV_X86_RBP); | ||
1008 | + env->regs[R_ESP] = rreg(cpu_state->hvf->fd, HV_X86_RSP); | ||
1009 | + env->regs[R_ESI] = rreg(cpu_state->hvf->fd, HV_X86_RSI); | ||
1010 | + env->regs[R_EDI] = rreg(cpu_state->hvf->fd, HV_X86_RDI); | ||
1011 | + env->regs[8] = rreg(cpu_state->hvf->fd, HV_X86_R8); | ||
1012 | + env->regs[9] = rreg(cpu_state->hvf->fd, HV_X86_R9); | ||
1013 | + env->regs[10] = rreg(cpu_state->hvf->fd, HV_X86_R10); | ||
1014 | + env->regs[11] = rreg(cpu_state->hvf->fd, HV_X86_R11); | ||
1015 | + env->regs[12] = rreg(cpu_state->hvf->fd, HV_X86_R12); | ||
1016 | + env->regs[13] = rreg(cpu_state->hvf->fd, HV_X86_R13); | ||
1017 | + env->regs[14] = rreg(cpu_state->hvf->fd, HV_X86_R14); | ||
1018 | + env->regs[15] = rreg(cpu_state->hvf->fd, HV_X86_R15); | ||
1019 | |||
1020 | - env->eflags = rreg(cpu_state->hvf_fd, HV_X86_RFLAGS); | ||
1021 | - env->eip = rreg(cpu_state->hvf_fd, HV_X86_RIP); | ||
1022 | + env->eflags = rreg(cpu_state->hvf->fd, HV_X86_RFLAGS); | ||
1023 | + env->eip = rreg(cpu_state->hvf->fd, HV_X86_RIP); | ||
1024 | |||
1025 | hvf_get_xsave(cpu_state); | ||
1026 | - env->xcr0 = rreg(cpu_state->hvf_fd, HV_X86_XCR0); | ||
1027 | + env->xcr0 = rreg(cpu_state->hvf->fd, HV_X86_XCR0); | ||
1028 | |||
1029 | hvf_get_segments(cpu_state); | ||
1030 | hvf_get_msrs(cpu_state); | ||
1031 | |||
1032 | - env->dr[0] = rreg(cpu_state->hvf_fd, HV_X86_DR0); | ||
1033 | - env->dr[1] = rreg(cpu_state->hvf_fd, HV_X86_DR1); | ||
1034 | - env->dr[2] = rreg(cpu_state->hvf_fd, HV_X86_DR2); | ||
1035 | - env->dr[3] = rreg(cpu_state->hvf_fd, HV_X86_DR3); | ||
1036 | - env->dr[4] = rreg(cpu_state->hvf_fd, HV_X86_DR4); | ||
1037 | - env->dr[5] = rreg(cpu_state->hvf_fd, HV_X86_DR5); | ||
1038 | - env->dr[6] = rreg(cpu_state->hvf_fd, HV_X86_DR6); | ||
1039 | - env->dr[7] = rreg(cpu_state->hvf_fd, HV_X86_DR7); | ||
1040 | + env->dr[0] = rreg(cpu_state->hvf->fd, HV_X86_DR0); | ||
1041 | + env->dr[1] = rreg(cpu_state->hvf->fd, HV_X86_DR1); | ||
1042 | + env->dr[2] = rreg(cpu_state->hvf->fd, HV_X86_DR2); | ||
1043 | + env->dr[3] = rreg(cpu_state->hvf->fd, HV_X86_DR3); | ||
1044 | + env->dr[4] = rreg(cpu_state->hvf->fd, HV_X86_DR4); | ||
1045 | + env->dr[5] = rreg(cpu_state->hvf->fd, HV_X86_DR5); | ||
1046 | + env->dr[6] = rreg(cpu_state->hvf->fd, HV_X86_DR6); | ||
1047 | + env->dr[7] = rreg(cpu_state->hvf->fd, HV_X86_DR7); | ||
1048 | |||
1049 | x86_update_hflags(env); | ||
1050 | return 0; | ||
1051 | @@ -XXX,XX +XXX,XX @@ int hvf_get_registers(CPUState *cpu_state) | ||
1052 | static void vmx_set_int_window_exiting(CPUState *cpu) | ||
1053 | { | ||
1054 | uint64_t val; | ||
1055 | - val = rvmcs(cpu->hvf_fd, VMCS_PRI_PROC_BASED_CTLS); | ||
1056 | - wvmcs(cpu->hvf_fd, VMCS_PRI_PROC_BASED_CTLS, val | | ||
1057 | + val = rvmcs(cpu->hvf->fd, VMCS_PRI_PROC_BASED_CTLS); | ||
1058 | + wvmcs(cpu->hvf->fd, VMCS_PRI_PROC_BASED_CTLS, val | | ||
1059 | VMCS_PRI_PROC_BASED_CTLS_INT_WINDOW_EXITING); | ||
1060 | } | ||
1061 | |||
1062 | void vmx_clear_int_window_exiting(CPUState *cpu) | ||
1063 | { | ||
1064 | uint64_t val; | ||
1065 | - val = rvmcs(cpu->hvf_fd, VMCS_PRI_PROC_BASED_CTLS); | ||
1066 | - wvmcs(cpu->hvf_fd, VMCS_PRI_PROC_BASED_CTLS, val & | ||
1067 | + val = rvmcs(cpu->hvf->fd, VMCS_PRI_PROC_BASED_CTLS); | ||
1068 | + wvmcs(cpu->hvf->fd, VMCS_PRI_PROC_BASED_CTLS, val & | ||
1069 | ~VMCS_PRI_PROC_BASED_CTLS_INT_WINDOW_EXITING); | ||
1070 | } | ||
1071 | |||
1072 | @@ -XXX,XX +XXX,XX @@ bool hvf_inject_interrupts(CPUState *cpu_state) | ||
1073 | uint64_t info = 0; | ||
1074 | if (have_event) { | ||
1075 | info = vector | intr_type | VMCS_INTR_VALID; | ||
1076 | - uint64_t reason = rvmcs(cpu_state->hvf_fd, VMCS_EXIT_REASON); | ||
1077 | + uint64_t reason = rvmcs(cpu_state->hvf->fd, VMCS_EXIT_REASON); | ||
1078 | if (env->nmi_injected && reason != EXIT_REASON_TASK_SWITCH) { | ||
1079 | vmx_clear_nmi_blocking(cpu_state); | ||
1080 | } | ||
1081 | @@ -XXX,XX +XXX,XX @@ bool hvf_inject_interrupts(CPUState *cpu_state) | ||
1082 | info &= ~(1 << 12); /* clear undefined bit */ | ||
1083 | if (intr_type == VMCS_INTR_T_SWINTR || | ||
1084 | intr_type == VMCS_INTR_T_SWEXCEPTION) { | ||
1085 | - wvmcs(cpu_state->hvf_fd, VMCS_ENTRY_INST_LENGTH, env->ins_len); | ||
1086 | + wvmcs(cpu_state->hvf->fd, VMCS_ENTRY_INST_LENGTH, env->ins_len); | ||
1087 | } | ||
1088 | |||
1089 | if (env->has_error_code) { | ||
1090 | - wvmcs(cpu_state->hvf_fd, VMCS_ENTRY_EXCEPTION_ERROR, | ||
1091 | + wvmcs(cpu_state->hvf->fd, VMCS_ENTRY_EXCEPTION_ERROR, | ||
1092 | env->error_code); | ||
1093 | /* Indicate that VMCS_ENTRY_EXCEPTION_ERROR is valid */ | ||
1094 | info |= VMCS_INTR_DEL_ERRCODE; | ||
1095 | } | ||
1096 | /*printf("reinject %lx err %d\n", info, err);*/ | ||
1097 | - wvmcs(cpu_state->hvf_fd, VMCS_ENTRY_INTR_INFO, info); | ||
1098 | + wvmcs(cpu_state->hvf->fd, VMCS_ENTRY_INTR_INFO, info); | ||
1099 | }; | ||
1100 | } | ||
1101 | |||
1102 | @@ -XXX,XX +XXX,XX @@ bool hvf_inject_interrupts(CPUState *cpu_state) | ||
1103 | if (!(env->hflags2 & HF2_NMI_MASK) && !(info & VMCS_INTR_VALID)) { | ||
1104 | cpu_state->interrupt_request &= ~CPU_INTERRUPT_NMI; | ||
1105 | info = VMCS_INTR_VALID | VMCS_INTR_T_NMI | EXCP02_NMI; | ||
1106 | - wvmcs(cpu_state->hvf_fd, VMCS_ENTRY_INTR_INFO, info); | ||
1107 | + wvmcs(cpu_state->hvf->fd, VMCS_ENTRY_INTR_INFO, info); | ||
1108 | } else { | ||
1109 | vmx_set_nmi_window_exiting(cpu_state); | ||
1110 | } | ||
1111 | @@ -XXX,XX +XXX,XX @@ bool hvf_inject_interrupts(CPUState *cpu_state) | ||
1112 | int line = cpu_get_pic_interrupt(&x86cpu->env); | ||
1113 | cpu_state->interrupt_request &= ~CPU_INTERRUPT_HARD; | ||
1114 | if (line >= 0) { | ||
1115 | - wvmcs(cpu_state->hvf_fd, VMCS_ENTRY_INTR_INFO, line | | ||
1116 | + wvmcs(cpu_state->hvf->fd, VMCS_ENTRY_INTR_INFO, line | | ||
1117 | VMCS_INTR_VALID | VMCS_INTR_T_HWINTR); | ||
1118 | } | ||
1119 | } | ||
1120 | @@ -XXX,XX +XXX,XX @@ int hvf_process_events(CPUState *cpu_state) | ||
1121 | X86CPU *cpu = X86_CPU(cpu_state); | ||
1122 | CPUX86State *env = &cpu->env; | ||
1123 | |||
1124 | - env->eflags = rreg(cpu_state->hvf_fd, HV_X86_RFLAGS); | ||
1125 | + env->eflags = rreg(cpu_state->hvf->fd, HV_X86_RFLAGS); | ||
1126 | |||
1127 | if (cpu_state->interrupt_request & CPU_INTERRUPT_INIT) { | ||
1128 | cpu_synchronize_state(cpu_state); | ||
1129 | -- | ||
1130 | 2.20.1 | ||
1131 | |||
1132 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Coverity notes that we don't check for dup2() failing. Add some | ||
2 | assertions so that if it does ever happen we get some indication. | ||
3 | (This is similar to how we handle other "don't expect this syscall to | ||
4 | fail" checks in this test code.) | ||
5 | 1 | ||
6 | Fixes: Coverity CID 1432346 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> | ||
9 | Message-id: 20210525134458.6675-2-peter.maydell@linaro.org | ||
10 | --- | ||
11 | tests/qtest/bios-tables-test.c | 8 ++++++-- | ||
12 | 1 file changed, 6 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/tests/qtest/bios-tables-test.c | ||
17 | +++ b/tests/qtest/bios-tables-test.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void test_acpi_asl(test_data *data) | ||
19 | exp_sdt->asl_file, sdt->asl_file); | ||
20 | int out = dup(STDOUT_FILENO); | ||
21 | int ret G_GNUC_UNUSED; | ||
22 | + int dupret; | ||
23 | |||
24 | - dup2(STDERR_FILENO, STDOUT_FILENO); | ||
25 | + g_assert(out >= 0); | ||
26 | + dupret = dup2(STDERR_FILENO, STDOUT_FILENO); | ||
27 | + g_assert(dupret >= 0); | ||
28 | ret = system(diff) ; | ||
29 | - dup2(out, STDOUT_FILENO); | ||
30 | + dupret = dup2(out, STDOUT_FILENO); | ||
31 | + g_assert(dupret >= 0); | ||
32 | close(out); | ||
33 | g_free(diff); | ||
34 | } | ||
35 | -- | ||
36 | 2.20.1 | ||
37 | |||
38 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The e1000e_send_verify() test calls qemu_recv() but doesn't | ||
2 | check that the call succeeded, which annoys Coverity. Add | ||
3 | an explicit test check for the length of the data. | ||
4 | 1 | ||
5 | (This is a test check, not a "we assume this syscall always | ||
6 | succeeds", so we use g_assert_cmpint() rather than g_assert().) | ||
7 | |||
8 | Fixes: Coverity CID 1432324 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> | ||
11 | Message-id: 20210525134458.6675-3-peter.maydell@linaro.org | ||
12 | --- | ||
13 | tests/qtest/e1000e-test.c | 3 ++- | ||
14 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/tests/qtest/e1000e-test.c b/tests/qtest/e1000e-test.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/tests/qtest/e1000e-test.c | ||
19 | +++ b/tests/qtest/e1000e-test.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void e1000e_send_verify(QE1000E *d, int *test_sockets, QGuestAllocator *a | ||
21 | /* Check data sent to the backend */ | ||
22 | ret = qemu_recv(test_sockets[0], &recv_len, sizeof(recv_len), 0); | ||
23 | g_assert_cmpint(ret, == , sizeof(recv_len)); | ||
24 | - qemu_recv(test_sockets[0], buffer, 64, 0); | ||
25 | + ret = qemu_recv(test_sockets[0], buffer, 64, 0); | ||
26 | + g_assert_cmpint(ret, >=, 5); | ||
27 | g_assert_cmpstr(buffer, == , "TEST"); | ||
28 | |||
29 | /* Free test data buffer */ | ||
30 | -- | ||
31 | 2.20.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Coverity notices that the checks against mkstemp() failing in | ||
2 | create_qcow2_with_mbr() are wrong: mkstemp returns -1 on failure but | ||
3 | the check is just "g_assert(fd)". Fix to use "g_assert(fd >= 0)", | ||
4 | matching the correct check in create_test_img(). | ||
5 | 1 | ||
6 | Fixes: Coverity CID 1432274 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> | ||
10 | Message-id: 20210525134458.6675-4-peter.maydell@linaro.org | ||
11 | --- | ||
12 | tests/qtest/hd-geo-test.c | 4 ++-- | ||
13 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tests/qtest/hd-geo-test.c | ||
18 | +++ b/tests/qtest/hd-geo-test.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static char *create_qcow2_with_mbr(MBRpartitions mbr, uint64_t sectors) | ||
20 | } | ||
21 | |||
22 | fd = mkstemp(raw_path); | ||
23 | - g_assert(fd); | ||
24 | + g_assert(fd >= 0); | ||
25 | close(fd); | ||
26 | |||
27 | fd = open(raw_path, O_WRONLY); | ||
28 | @@ -XXX,XX +XXX,XX @@ static char *create_qcow2_with_mbr(MBRpartitions mbr, uint64_t sectors) | ||
29 | close(fd); | ||
30 | |||
31 | fd = mkstemp(qcow2_path); | ||
32 | - g_assert(fd); | ||
33 | + g_assert(fd >= 0); | ||
34 | close(fd); | ||
35 | |||
36 | qemu_img_path = getenv("QTEST_QEMU_IMG"); | ||
37 | -- | ||
38 | 2.20.1 | ||
39 | |||
40 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Coverity points out that we calculate a 64-bit value using 32-bit | ||
2 | arithmetic; add the cast to force the multiply to be done as 64-bits. | ||
3 | (The overflow will never happen with the current test data.) | ||
4 | 1 | ||
5 | Fixes: Coverity CID 1432320 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> | ||
9 | Message-id: 20210525134458.6675-5-peter.maydell@linaro.org | ||
10 | --- | ||
11 | tests/qtest/pflash-cfi02-test.c | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/tests/qtest/pflash-cfi02-test.c b/tests/qtest/pflash-cfi02-test.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/tests/qtest/pflash-cfi02-test.c | ||
17 | +++ b/tests/qtest/pflash-cfi02-test.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static void test_geometry(const void *opaque) | ||
19 | |||
20 | for (int region = 0; region < nb_erase_regions; ++region) { | ||
21 | for (uint32_t i = 0; i < c->nb_blocs[region]; ++i) { | ||
22 | - uint64_t byte_addr = i * c->sector_len[region]; | ||
23 | + uint64_t byte_addr = (uint64_t)i * c->sector_len[region]; | ||
24 | g_assert_cmphex(flash_read(c, byte_addr), ==, bank_mask(c)); | ||
25 | } | ||
26 | } | ||
27 | -- | ||
28 | 2.20.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Coverity points out that in tpm_test_swtpm_migration_test() we | ||
2 | assume that src_tpm_addr and dst_tpm_addr are non-NULL (we | ||
3 | pass them to tpm_util_migration_start_qemu() which will | ||
4 | unconditionally dereference them) but then later explicitly | ||
5 | check them for NULL. Remove the pointless checks. | ||
6 | 1 | ||
7 | Fixes: Coverity CID 1432367, 1432359 | ||
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
11 | Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> | ||
12 | Message-id: 20210525134458.6675-6-peter.maydell@linaro.org | ||
13 | --- | ||
14 | tests/qtest/tpm-tests.c | 12 ++++-------- | ||
15 | 1 file changed, 4 insertions(+), 8 deletions(-) | ||
16 | |||
17 | diff --git a/tests/qtest/tpm-tests.c b/tests/qtest/tpm-tests.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/tests/qtest/tpm-tests.c | ||
20 | +++ b/tests/qtest/tpm-tests.c | ||
21 | @@ -XXX,XX +XXX,XX @@ void tpm_test_swtpm_migration_test(const char *src_tpm_path, | ||
22 | qtest_quit(src_qemu); | ||
23 | |||
24 | tpm_util_swtpm_kill(dst_tpm_pid); | ||
25 | - if (dst_tpm_addr) { | ||
26 | - g_unlink(dst_tpm_addr->u.q_unix.path); | ||
27 | - qapi_free_SocketAddress(dst_tpm_addr); | ||
28 | - } | ||
29 | + g_unlink(dst_tpm_addr->u.q_unix.path); | ||
30 | + qapi_free_SocketAddress(dst_tpm_addr); | ||
31 | |||
32 | tpm_util_swtpm_kill(src_tpm_pid); | ||
33 | - if (src_tpm_addr) { | ||
34 | - g_unlink(src_tpm_addr->u.q_unix.path); | ||
35 | - qapi_free_SocketAddress(src_tpm_addr); | ||
36 | - } | ||
37 | + g_unlink(src_tpm_addr->u.q_unix.path); | ||
38 | + qapi_free_SocketAddress(src_tpm_addr); | ||
39 | } | ||
40 | -- | ||
41 | 2.20.1 | ||
42 | |||
43 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Coverity complains that we don't check for failures from dup() | ||
2 | and mkstemp(); add asserts that these syscalls succeeded. | ||
3 | 1 | ||
4 | Fixes: Coverity CID 1432516, 1432574 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
8 | Message-id: 20210525134458.6675-7-peter.maydell@linaro.org | ||
9 | --- | ||
10 | tests/unit/test-vmstate.c | 5 ++++- | ||
11 | 1 file changed, 4 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tests/unit/test-vmstate.c | ||
16 | +++ b/tests/unit/test-vmstate.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static int temp_fd; | ||
18 | /* Duplicate temp_fd and seek to the beginning of the file */ | ||
19 | static QEMUFile *open_test_file(bool write) | ||
20 | { | ||
21 | - int fd = dup(temp_fd); | ||
22 | + int fd; | ||
23 | QIOChannel *ioc; | ||
24 | QEMUFile *f; | ||
25 | |||
26 | + fd = dup(temp_fd); | ||
27 | + g_assert(fd >= 0); | ||
28 | lseek(fd, 0, SEEK_SET); | ||
29 | if (write) { | ||
30 | g_assert_cmpint(ftruncate(fd, 0), ==, 0); | ||
31 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv) | ||
32 | g_autofree char *temp_file = g_strdup_printf("%s/vmst.test.XXXXXX", | ||
33 | g_get_tmp_dir()); | ||
34 | temp_fd = mkstemp(temp_file); | ||
35 | + g_assert(temp_fd >= 0); | ||
36 | |||
37 | module_call_init(MODULE_INIT_QOM); | ||
38 | |||
39 | -- | ||
40 | 2.20.1 | ||
41 | |||
42 | diff view generated by jsdifflib |