1
The following changes since commit b10d00d8811fa4eed4862963273d7353ce310c82:
1
I don't have anything else queued up at the moment, so this is just
2
Richard's SME patches.
2
3
3
Merge remote-tracking branch 'remotes/kraxel/tags/seabios-20220118-pull-request' into staging (2022-01-19 18:46:28 +0000)
4
-- PMM
5
6
The following changes since commit 63b38f6c85acd312c2cab68554abf33adf4ee2b3:
7
8
Merge tag 'pull-target-arm-20220707' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2022-07-08 06:17:11 +0530)
4
9
5
are available in the Git repository at:
10
are available in the Git repository at:
6
11
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220120
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220711
8
13
9
for you to fetch changes up to 9705e3c1dcff96b0b3c7e594b6cd68d27d6c4ced:
14
for you to fetch changes up to f9982ceaf26df27d15547a3a7990a95019e9e3a8:
10
15
11
hw/intc/arm_gicv3: Check for !MEMTX_OK instead of MEMTX_ERROR (2022-01-20 11:47:54 +0000)
16
linux-user/aarch64: Add SME related hwcap entries (2022-07-11 13:43:52 +0100)
12
17
13
----------------------------------------------------------------
18
----------------------------------------------------------------
14
target-arm:
19
target-arm:
15
* hw/intc/arm_gicv3_its: Fix various minor bugs
20
* Implement SME emulation, for both system and linux-user
16
* hw/arm/aspeed: Add the i3c device to the AST2600 SoC
17
* hw/arm: kudo: add lm75s behind bus 1 switch at 75
18
* hw/arm/virt: Fix support for running guests on hosts
19
with restricted IPA ranges
20
* hw/intc/arm_gic: Allow reset of the running priority
21
* hw/intc/arm_gic: Implement read of GICC_IIDR
22
* hw/arm/virt: Support for virtio-mem-pci
23
* hw/arm/virt: Support CPU cluster on ARM virt machine
24
* docs/can: convert to restructuredText
25
* hw/net: Move MV88W8618 network device out of hw/arm/ directory
26
* hw/arm/virt: KVM: Enable PAuth when supported by the host
27
21
28
----------------------------------------------------------------
22
----------------------------------------------------------------
29
Gavin Shan (2):
23
Richard Henderson (45):
30
virtio-mem: Correct default THP size for ARM64
24
target/arm: Handle SME in aarch64_cpu_dump_state
31
hw/arm/virt: Support for virtio-mem-pci
25
target/arm: Add infrastructure for disas_sme
26
target/arm: Trap non-streaming usage when Streaming SVE is active
27
target/arm: Mark ADR as non-streaming
28
target/arm: Mark RDFFR, WRFFR, SETFFR as non-streaming
29
target/arm: Mark BDEP, BEXT, BGRP, COMPACT, FEXPA, FTSSEL as non-streaming
30
target/arm: Mark PMULL, FMMLA as non-streaming
31
target/arm: Mark FTSMUL, FTMAD, FADDA as non-streaming
32
target/arm: Mark SMMLA, UMMLA, USMMLA as non-streaming
33
target/arm: Mark string/histo/crypto as non-streaming
34
target/arm: Mark gather/scatter load/store as non-streaming
35
target/arm: Mark gather prefetch as non-streaming
36
target/arm: Mark LDFF1 and LDNF1 as non-streaming
37
target/arm: Mark LD1RO as non-streaming
38
target/arm: Add SME enablement checks
39
target/arm: Handle SME in sve_access_check
40
target/arm: Implement SME RDSVL, ADDSVL, ADDSPL
41
target/arm: Implement SME ZERO
42
target/arm: Implement SME MOVA
43
target/arm: Implement SME LD1, ST1
44
target/arm: Export unpredicated ld/st from translate-sve.c
45
target/arm: Implement SME LDR, STR
46
target/arm: Implement SME ADDHA, ADDVA
47
target/arm: Implement FMOPA, FMOPS (non-widening)
48
target/arm: Implement BFMOPA, BFMOPS
49
target/arm: Implement FMOPA, FMOPS (widening)
50
target/arm: Implement SME integer outer product
51
target/arm: Implement PSEL
52
target/arm: Implement REVD
53
target/arm: Implement SCLAMP, UCLAMP
54
target/arm: Reset streaming sve state on exception boundaries
55
target/arm: Enable SME for -cpu max
56
linux-user/aarch64: Clear tpidr2_el0 if CLONE_SETTLS
57
linux-user/aarch64: Reset PSTATE.SM on syscalls
58
linux-user/aarch64: Add SM bit to SVE signal context
59
linux-user/aarch64: Tidy target_restore_sigframe error return
60
linux-user/aarch64: Do not allow duplicate or short sve records
61
linux-user/aarch64: Verify extra record lock succeeded
62
linux-user/aarch64: Move sve record checks into restore
63
linux-user/aarch64: Implement SME signal handling
64
linux-user: Rename sve prctls
65
linux-user/aarch64: Implement PR_SME_GET_VL, PR_SME_SET_VL
66
target/arm: Only set ZEN in reset if SVE present
67
target/arm: Enable SME for user-only
68
linux-user/aarch64: Add SME related hwcap entries
32
69
33
Lucas Ramage (1):
70
docs/system/arm/emulation.rst | 4 +
34
docs/can: convert to restructuredText
71
linux-user/aarch64/target_cpu.h | 5 +-
35
72
linux-user/aarch64/target_prctl.h | 62 +-
36
Marc Zyngier (7):
73
target/arm/cpu.h | 7 +
37
hw/arm/virt: KVM: Enable PAuth when supported by the host
74
target/arm/helper-sme.h | 126 ++++
38
hw/arm/virt: Add a control for the the highmem PCIe MMIO
75
target/arm/helper-sve.h | 4 +
39
hw/arm/virt: Add a control for the the highmem redistributors
76
target/arm/helper.h | 18 +
40
hw/arm/virt: Honor highmem setting when computing the memory map
77
target/arm/translate-a64.h | 45 ++
41
hw/arm/virt: Use the PA range to compute the memory map
78
target/arm/translate.h | 16 +
42
hw/arm/virt: Disable highmem devices that don't fit in the PA range
79
target/arm/sme-fa64.decode | 60 ++
43
hw/arm/virt: Drop superfluous checks against highmem
80
target/arm/sme.decode | 88 +++
44
81
target/arm/sve.decode | 41 +-
45
Patrick Venture (1):
82
linux-user/aarch64/cpu_loop.c | 9 +
46
hw/arm: kudo add lm75s behind bus 1 switch at 75
83
linux-user/aarch64/signal.c | 243 ++++++--
47
84
linux-user/elfload.c | 20 +
48
Peter Maydell (13):
85
linux-user/syscall.c | 28 +-
49
hw/intc/arm_gicv3_its: Fix event ID bounds checks
86
target/arm/cpu.c | 35 +-
50
hw/intc/arm_gicv3_its: Convert int ID check to num_intids convention
87
target/arm/cpu64.c | 11 +
51
hw/intc/arm_gicv3_its: Fix handling of process_its_cmd() return value
88
target/arm/helper.c | 56 +-
52
hw/intc/arm_gicv3_its: Don't use data if reading command failed
89
target/arm/sme_helper.c | 1140 +++++++++++++++++++++++++++++++++++++
53
hw/intc/arm_gicv3_its: Use enum for return value of process_* functions
90
target/arm/sve_helper.c | 28 +
54
hw/intc/arm_gicv3_its: Fix return codes in process_its_cmd()
91
target/arm/translate-a64.c | 103 +++-
55
hw/intc/arm_gicv3_its: Refactor process_its_cmd() to reduce nesting
92
target/arm/translate-sme.c | 373 ++++++++++++
56
hw/intc/arm_gicv3_its: Fix return codes in process_mapti()
93
target/arm/translate-sve.c | 393 ++++++++++---
57
hw/intc/arm_gicv3_its: Fix return codes in process_mapc()
94
target/arm/translate-vfp.c | 12 +
58
hw/intc/arm_gicv3_its: Fix return codes in process_mapd()
95
target/arm/translate.c | 2 +
59
hw/intc/arm_gicv3_its: Factor out "find address of table entry" code
96
target/arm/vec_helper.c | 24 +
60
hw/intc/arm_gicv3_its: Check indexes before use, not after
97
target/arm/meson.build | 3 +
61
hw/intc/arm_gicv3_its: Range-check ICID before indexing into collection table
98
28 files changed, 2821 insertions(+), 135 deletions(-)
62
99
create mode 100644 target/arm/sme-fa64.decode
63
Petr Pavlu (2):
100
create mode 100644 target/arm/sme.decode
64
hw/intc/arm_gic: Implement read of GICC_IIDR
101
create mode 100644 target/arm/translate-sme.c
65
hw/intc/arm_gic: Allow reset of the running priority
66
67
Philippe Mathieu-Daudé (4):
68
hw: Move MARVELL_88W8618 Kconfig from audio/ to arm/
69
hw/arm/musicpal: Fix coding style of code related to MV88W8618 device
70
hw/net: Move MV88W8618 network device out of hw/arm/ directory
71
hw/intc/arm_gicv3: Check for !MEMTX_OK instead of MEMTX_ERROR
72
73
Troy Lee (2):
74
hw/misc/aspeed_i3c.c: Introduce a dummy AST2600 I3C model.
75
hw/arm/aspeed: Add the i3c device to the AST2600 SoC
76
77
Yanan Wang (6):
78
hw/arm/virt: Support CPU cluster on ARM virt machine
79
hw/arm/virt: Support cluster level in DT cpu-map
80
hw/acpi/aml-build: Improve scalability of PPTT generation
81
tests/acpi/bios-tables-test: Allow changes to virt/PPTT file
82
hw/acpi/aml-build: Support cluster level in PPTT generation
83
tests/acpi/bios-table-test: Update expected virt/PPTT file
84
85
docs/system/arm/cpu-features.rst | 4 -
86
docs/system/device-emulation.rst | 1 +
87
docs/{can.txt => system/devices/can.rst} | 90 +++---
88
include/hw/arm/aspeed_soc.h | 3 +
89
include/hw/arm/virt.h | 5 +-
90
include/hw/misc/aspeed_i3c.h | 48 +++
91
include/hw/net/mv88w8618_eth.h | 12 +
92
target/arm/cpu.h | 1 +
93
hw/acpi/aml-build.c | 68 +++--
94
hw/arm/aspeed_ast2600.c | 16 +
95
hw/arm/musicpal.c | 381 +-----------------------
96
hw/arm/npcm7xx_boards.c | 10 +-
97
hw/arm/virt-acpi-build.c | 10 +-
98
hw/arm/virt.c | 184 ++++++++++--
99
hw/intc/arm_gic.c | 11 +
100
hw/intc/arm_gicv3_its.c | 492 ++++++++++++++-----------------
101
hw/intc/arm_gicv3_redist.c | 4 +-
102
hw/misc/aspeed_i3c.c | 381 ++++++++++++++++++++++++
103
hw/net/mv88w8618_eth.c | 403 +++++++++++++++++++++++++
104
hw/virtio/virtio-mem.c | 36 ++-
105
target/arm/cpu.c | 16 +-
106
target/arm/cpu64.c | 31 +-
107
target/arm/kvm64.c | 21 ++
108
MAINTAINERS | 2 +
109
hw/arm/Kconfig | 4 +
110
hw/audio/Kconfig | 3 -
111
hw/misc/meson.build | 1 +
112
hw/misc/trace-events | 6 +
113
hw/net/meson.build | 1 +
114
qemu-options.hx | 10 +
115
tests/data/acpi/virt/PPTT | Bin 76 -> 96 bytes
116
31 files changed, 1473 insertions(+), 782 deletions(-)
117
rename docs/{can.txt => system/devices/can.rst} (68%)
118
create mode 100644 include/hw/misc/aspeed_i3c.h
119
create mode 100644 include/hw/net/mv88w8618_eth.h
120
create mode 100644 hw/misc/aspeed_i3c.c
121
create mode 100644 hw/net/mv88w8618_eth.c
122
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Dump SVCR, plus use the correct access check for Streaming Mode.
4
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220708151540.18136-2-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/cpu.c | 17 ++++++++++++++++-
11
1 file changed, 16 insertions(+), 1 deletion(-)
12
13
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.c
16
+++ b/target/arm/cpu.c
17
@@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
18
int i;
19
int el = arm_current_el(env);
20
const char *ns_status;
21
+ bool sve;
22
23
qemu_fprintf(f, " PC=%016" PRIx64 " ", env->pc);
24
for (i = 0; i < 32; i++) {
25
@@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
26
el,
27
psr & PSTATE_SP ? 'h' : 't');
28
29
+ if (cpu_isar_feature(aa64_sme, cpu)) {
30
+ qemu_fprintf(f, " SVCR=%08" PRIx64 " %c%c",
31
+ env->svcr,
32
+ (FIELD_EX64(env->svcr, SVCR, ZA) ? 'Z' : '-'),
33
+ (FIELD_EX64(env->svcr, SVCR, SM) ? 'S' : '-'));
34
+ }
35
if (cpu_isar_feature(aa64_bti, cpu)) {
36
qemu_fprintf(f, " BTYPE=%d", (psr & PSTATE_BTYPE) >> 10);
37
}
38
@@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
39
qemu_fprintf(f, " FPCR=%08x FPSR=%08x\n",
40
vfp_get_fpcr(env), vfp_get_fpsr(env));
41
42
- if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) == 0) {
43
+ if (cpu_isar_feature(aa64_sme, cpu) && FIELD_EX64(env->svcr, SVCR, SM)) {
44
+ sve = sme_exception_el(env, el) == 0;
45
+ } else if (cpu_isar_feature(aa64_sve, cpu)) {
46
+ sve = sve_exception_el(env, el) == 0;
47
+ } else {
48
+ sve = false;
49
+ }
50
+
51
+ if (sve) {
52
int j, zcr_len = sve_vqm1_for_el(env, el);
53
54
for (i = 0; i <= FFR_PRED_NUM; i++) {
55
--
56
2.25.1
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
The Marvell 88W8618 network device is hidden in the Musicpal
3
This includes the build rules for the decoder, and the
4
machine. Move it into a new unit file under the hw/net/ directory.
4
new file for translation, but excludes any instructions.
5
5
6
Acked-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220107184429.423572-4-f4bug@amsat.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-3-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
include/hw/net/mv88w8618_eth.h | 12 +
11
target/arm/translate-a64.h | 1 +
13
hw/arm/musicpal.c | 381 +------------------------------
12
target/arm/sme.decode | 20 ++++++++++++++++++++
14
hw/net/mv88w8618_eth.c | 403 +++++++++++++++++++++++++++++++++
13
target/arm/translate-a64.c | 7 ++++++-
15
MAINTAINERS | 2 +
14
target/arm/translate-sme.c | 35 +++++++++++++++++++++++++++++++++++
16
hw/net/meson.build | 1 +
15
target/arm/meson.build | 2 ++
17
5 files changed, 419 insertions(+), 380 deletions(-)
16
5 files changed, 64 insertions(+), 1 deletion(-)
18
create mode 100644 include/hw/net/mv88w8618_eth.h
17
create mode 100644 target/arm/sme.decode
19
create mode 100644 hw/net/mv88w8618_eth.c
18
create mode 100644 target/arm/translate-sme.c
20
19
21
diff --git a/include/hw/net/mv88w8618_eth.h b/include/hw/net/mv88w8618_eth.h
20
diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/translate-a64.h
23
+++ b/target/arm/translate-a64.h
24
@@ -XXX,XX +XXX,XX @@ static inline int pred_gvec_reg_size(DisasContext *s)
25
}
26
27
bool disas_sve(DisasContext *, uint32_t);
28
+bool disas_sme(DisasContext *, uint32_t);
29
30
void gen_gvec_rax1(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
31
uint32_t rm_ofs, uint32_t opr_sz, uint32_t max_sz);
32
diff --git a/target/arm/sme.decode b/target/arm/sme.decode
22
new file mode 100644
33
new file mode 100644
23
index XXXXXXX..XXXXXXX
34
index XXXXXXX..XXXXXXX
24
--- /dev/null
35
--- /dev/null
25
+++ b/include/hw/net/mv88w8618_eth.h
36
+++ b/target/arm/sme.decode
26
@@ -XXX,XX +XXX,XX @@
37
@@ -XXX,XX +XXX,XX @@
27
+/* SPDX-License-Identifier: GPL-2.0-or-later */
38
+# AArch64 SME instruction descriptions
28
+/*
39
+#
29
+ * Marvell MV88W8618 / Freecom MusicPal emulation.
40
+# Copyright (c) 2022 Linaro, Ltd
30
+ *
41
+#
31
+ * Copyright (c) 2008-2021 QEMU contributors
42
+# This library is free software; you can redistribute it and/or
32
+ */
43
+# modify it under the terms of the GNU Lesser General Public
33
+#ifndef HW_NET_MV88W8618_H
44
+# License as published by the Free Software Foundation; either
34
+#define HW_NET_MV88W8618_H
45
+# version 2.1 of the License, or (at your option) any later version.
46
+#
47
+# This library is distributed in the hope that it will be useful,
48
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
49
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
50
+# Lesser General Public License for more details.
51
+#
52
+# You should have received a copy of the GNU Lesser General Public
53
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
35
+
54
+
36
+#define TYPE_MV88W8618_ETH "mv88w8618_eth"
55
+#
37
+
56
+# This file is processed by scripts/decodetree.py
38
+#endif
57
+#
39
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
58
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
40
index XXXXXXX..XXXXXXX 100644
59
index XXXXXXX..XXXXXXX 100644
41
--- a/hw/arm/musicpal.c
60
--- a/target/arm/translate-a64.c
42
+++ b/hw/arm/musicpal.c
61
+++ b/target/arm/translate-a64.c
43
@@ -XXX,XX +XXX,XX @@
62
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
44
#include "ui/pixel_ops.h"
63
}
45
#include "qemu/cutils.h"
64
46
#include "qom/object.h"
65
switch (extract32(insn, 25, 4)) {
47
+#include "hw/net/mv88w8618_eth.h"
66
- case 0x0: case 0x1: case 0x3: /* UNALLOCATED */
48
67
+ case 0x0:
49
#define MP_MISC_BASE 0x80002000
68
+ if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) {
50
#define MP_MISC_SIZE 0x00001000
69
+ unallocated_encoding(s);
51
70
+ }
52
#define MP_ETH_BASE 0x80008000
71
+ break;
53
-#define MP_ETH_SIZE 0x00001000
72
+ case 0x1: case 0x3: /* UNALLOCATED */
54
73
unallocated_encoding(s);
55
#define MP_WLAN_BASE 0x8000C000
74
break;
56
#define MP_WLAN_SIZE 0x00000800
75
case 0x2:
57
@@ -XXX,XX +XXX,XX @@
76
diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c
58
/* Wolfson 8750 I2C address */
59
#define MP_WM_ADDR 0x1A
60
61
-/* Ethernet register offsets */
62
-#define MP_ETH_SMIR 0x010
63
-#define MP_ETH_PCXR 0x408
64
-#define MP_ETH_SDCMR 0x448
65
-#define MP_ETH_ICR 0x450
66
-#define MP_ETH_IMR 0x458
67
-#define MP_ETH_FRDP0 0x480
68
-#define MP_ETH_FRDP1 0x484
69
-#define MP_ETH_FRDP2 0x488
70
-#define MP_ETH_FRDP3 0x48C
71
-#define MP_ETH_CRDP0 0x4A0
72
-#define MP_ETH_CRDP1 0x4A4
73
-#define MP_ETH_CRDP2 0x4A8
74
-#define MP_ETH_CRDP3 0x4AC
75
-#define MP_ETH_CTDP0 0x4E0
76
-#define MP_ETH_CTDP1 0x4E4
77
-
78
-/* MII PHY access */
79
-#define MP_ETH_SMIR_DATA 0x0000FFFF
80
-#define MP_ETH_SMIR_ADDR 0x03FF0000
81
-#define MP_ETH_SMIR_OPCODE (1 << 26) /* Read value */
82
-#define MP_ETH_SMIR_RDVALID (1 << 27)
83
-
84
-/* PHY registers */
85
-#define MP_ETH_PHY1_BMSR 0x00210000
86
-#define MP_ETH_PHY1_PHYSID1 0x00410000
87
-#define MP_ETH_PHY1_PHYSID2 0x00610000
88
-
89
-#define MP_PHY_BMSR_LINK 0x0004
90
-#define MP_PHY_BMSR_AUTONEG 0x0008
91
-
92
-#define MP_PHY_88E3015 0x01410E20
93
-
94
-/* TX descriptor status */
95
-#define MP_ETH_TX_OWN (1U << 31)
96
-
97
-/* RX descriptor status */
98
-#define MP_ETH_RX_OWN (1U << 31)
99
-
100
-/* Interrupt cause/mask bits */
101
-#define MP_ETH_IRQ_RX_BIT 0
102
-#define MP_ETH_IRQ_RX (1 << MP_ETH_IRQ_RX_BIT)
103
-#define MP_ETH_IRQ_TXHI_BIT 2
104
-#define MP_ETH_IRQ_TXLO_BIT 3
105
-
106
-/* Port config bits */
107
-#define MP_ETH_PCXR_2BSM_BIT 28 /* 2-byte incoming suffix */
108
-
109
-/* SDMA command bits */
110
-#define MP_ETH_CMD_TXHI (1 << 23)
111
-#define MP_ETH_CMD_TXLO (1 << 22)
112
-
113
-typedef struct mv88w8618_tx_desc {
114
- uint32_t cmdstat;
115
- uint16_t res;
116
- uint16_t bytes;
117
- uint32_t buffer;
118
- uint32_t next;
119
-} mv88w8618_tx_desc;
120
-
121
-typedef struct mv88w8618_rx_desc {
122
- uint32_t cmdstat;
123
- uint16_t bytes;
124
- uint16_t buffer_size;
125
- uint32_t buffer;
126
- uint32_t next;
127
-} mv88w8618_rx_desc;
128
-
129
-#define TYPE_MV88W8618_ETH "mv88w8618_eth"
130
-OBJECT_DECLARE_SIMPLE_TYPE(mv88w8618_eth_state, MV88W8618_ETH)
131
-
132
-struct mv88w8618_eth_state {
133
- /*< private >*/
134
- SysBusDevice parent_obj;
135
- /*< public >*/
136
-
137
- MemoryRegion iomem;
138
- qemu_irq irq;
139
- MemoryRegion *dma_mr;
140
- AddressSpace dma_as;
141
- uint32_t smir;
142
- uint32_t icr;
143
- uint32_t imr;
144
- int mmio_index;
145
- uint32_t vlan_header;
146
- uint32_t tx_queue[2];
147
- uint32_t rx_queue[4];
148
- uint32_t frx_queue[4];
149
- uint32_t cur_rx[4];
150
- NICState *nic;
151
- NICConf conf;
152
-};
153
-
154
-static void eth_rx_desc_put(AddressSpace *dma_as, uint32_t addr,
155
- mv88w8618_rx_desc *desc)
156
-{
157
- cpu_to_le32s(&desc->cmdstat);
158
- cpu_to_le16s(&desc->bytes);
159
- cpu_to_le16s(&desc->buffer_size);
160
- cpu_to_le32s(&desc->buffer);
161
- cpu_to_le32s(&desc->next);
162
- dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
163
-}
164
-
165
-static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr,
166
- mv88w8618_rx_desc *desc)
167
-{
168
- dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
169
- le32_to_cpus(&desc->cmdstat);
170
- le16_to_cpus(&desc->bytes);
171
- le16_to_cpus(&desc->buffer_size);
172
- le32_to_cpus(&desc->buffer);
173
- le32_to_cpus(&desc->next);
174
-}
175
-
176
-static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
177
-{
178
- mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
179
- uint32_t desc_addr;
180
- mv88w8618_rx_desc desc;
181
- int i;
182
-
183
- for (i = 0; i < 4; i++) {
184
- desc_addr = s->cur_rx[i];
185
- if (!desc_addr) {
186
- continue;
187
- }
188
- do {
189
- eth_rx_desc_get(&s->dma_as, desc_addr, &desc);
190
- if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) {
191
- dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header,
192
- buf, size, MEMTXATTRS_UNSPECIFIED);
193
- desc.bytes = size + s->vlan_header;
194
- desc.cmdstat &= ~MP_ETH_RX_OWN;
195
- s->cur_rx[i] = desc.next;
196
-
197
- s->icr |= MP_ETH_IRQ_RX;
198
- if (s->icr & s->imr) {
199
- qemu_irq_raise(s->irq);
200
- }
201
- eth_rx_desc_put(&s->dma_as, desc_addr, &desc);
202
- return size;
203
- }
204
- desc_addr = desc.next;
205
- } while (desc_addr != s->rx_queue[i]);
206
- }
207
- return size;
208
-}
209
-
210
-static void eth_tx_desc_put(AddressSpace *dma_as, uint32_t addr,
211
- mv88w8618_tx_desc *desc)
212
-{
213
- cpu_to_le32s(&desc->cmdstat);
214
- cpu_to_le16s(&desc->res);
215
- cpu_to_le16s(&desc->bytes);
216
- cpu_to_le32s(&desc->buffer);
217
- cpu_to_le32s(&desc->next);
218
- dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
219
-}
220
-
221
-static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr,
222
- mv88w8618_tx_desc *desc)
223
-{
224
- dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
225
- le32_to_cpus(&desc->cmdstat);
226
- le16_to_cpus(&desc->res);
227
- le16_to_cpus(&desc->bytes);
228
- le32_to_cpus(&desc->buffer);
229
- le32_to_cpus(&desc->next);
230
-}
231
-
232
-static void eth_send(mv88w8618_eth_state *s, int queue_index)
233
-{
234
- uint32_t desc_addr = s->tx_queue[queue_index];
235
- mv88w8618_tx_desc desc;
236
- uint32_t next_desc;
237
- uint8_t buf[2048];
238
- int len;
239
-
240
- do {
241
- eth_tx_desc_get(&s->dma_as, desc_addr, &desc);
242
- next_desc = desc.next;
243
- if (desc.cmdstat & MP_ETH_TX_OWN) {
244
- len = desc.bytes;
245
- if (len < 2048) {
246
- dma_memory_read(&s->dma_as, desc.buffer, buf, len,
247
- MEMTXATTRS_UNSPECIFIED);
248
- qemu_send_packet(qemu_get_queue(s->nic), buf, len);
249
- }
250
- desc.cmdstat &= ~MP_ETH_TX_OWN;
251
- s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
252
- eth_tx_desc_put(&s->dma_as, desc_addr, &desc);
253
- }
254
- desc_addr = next_desc;
255
- } while (desc_addr != s->tx_queue[queue_index]);
256
-}
257
-
258
-static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset,
259
- unsigned size)
260
-{
261
- mv88w8618_eth_state *s = opaque;
262
-
263
- switch (offset) {
264
- case MP_ETH_SMIR:
265
- if (s->smir & MP_ETH_SMIR_OPCODE) {
266
- switch (s->smir & MP_ETH_SMIR_ADDR) {
267
- case MP_ETH_PHY1_BMSR:
268
- return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |
269
- MP_ETH_SMIR_RDVALID;
270
- case MP_ETH_PHY1_PHYSID1:
271
- return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;
272
- case MP_ETH_PHY1_PHYSID2:
273
- return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;
274
- default:
275
- return MP_ETH_SMIR_RDVALID;
276
- }
277
- }
278
- return 0;
279
-
280
- case MP_ETH_ICR:
281
- return s->icr;
282
-
283
- case MP_ETH_IMR:
284
- return s->imr;
285
-
286
- case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
287
- return s->frx_queue[(offset - MP_ETH_FRDP0) / 4];
288
-
289
- case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
290
- return s->rx_queue[(offset - MP_ETH_CRDP0) / 4];
291
-
292
- case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
293
- return s->tx_queue[(offset - MP_ETH_CTDP0) / 4];
294
-
295
- default:
296
- return 0;
297
- }
298
-}
299
-
300
-static void mv88w8618_eth_write(void *opaque, hwaddr offset,
301
- uint64_t value, unsigned size)
302
-{
303
- mv88w8618_eth_state *s = opaque;
304
-
305
- switch (offset) {
306
- case MP_ETH_SMIR:
307
- s->smir = value;
308
- break;
309
-
310
- case MP_ETH_PCXR:
311
- s->vlan_header = ((value >> MP_ETH_PCXR_2BSM_BIT) & 1) * 2;
312
- break;
313
-
314
- case MP_ETH_SDCMR:
315
- if (value & MP_ETH_CMD_TXHI) {
316
- eth_send(s, 1);
317
- }
318
- if (value & MP_ETH_CMD_TXLO) {
319
- eth_send(s, 0);
320
- }
321
- if (value & (MP_ETH_CMD_TXHI | MP_ETH_CMD_TXLO) && s->icr & s->imr) {
322
- qemu_irq_raise(s->irq);
323
- }
324
- break;
325
-
326
- case MP_ETH_ICR:
327
- s->icr &= value;
328
- break;
329
-
330
- case MP_ETH_IMR:
331
- s->imr = value;
332
- if (s->icr & s->imr) {
333
- qemu_irq_raise(s->irq);
334
- }
335
- break;
336
-
337
- case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
338
- s->frx_queue[(offset - MP_ETH_FRDP0) / 4] = value;
339
- break;
340
-
341
- case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
342
- s->rx_queue[(offset - MP_ETH_CRDP0) / 4] =
343
- s->cur_rx[(offset - MP_ETH_CRDP0) / 4] = value;
344
- break;
345
-
346
- case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
347
- s->tx_queue[(offset - MP_ETH_CTDP0) / 4] = value;
348
- break;
349
- }
350
-}
351
-
352
-static const MemoryRegionOps mv88w8618_eth_ops = {
353
- .read = mv88w8618_eth_read,
354
- .write = mv88w8618_eth_write,
355
- .endianness = DEVICE_NATIVE_ENDIAN,
356
-};
357
-
358
-static void eth_cleanup(NetClientState *nc)
359
-{
360
- mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
361
-
362
- s->nic = NULL;
363
-}
364
-
365
-static NetClientInfo net_mv88w8618_info = {
366
- .type = NET_CLIENT_DRIVER_NIC,
367
- .size = sizeof(NICState),
368
- .receive = eth_receive,
369
- .cleanup = eth_cleanup,
370
-};
371
-
372
-static void mv88w8618_eth_init(Object *obj)
373
-{
374
- SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
375
- DeviceState *dev = DEVICE(sbd);
376
- mv88w8618_eth_state *s = MV88W8618_ETH(dev);
377
-
378
- sysbus_init_irq(sbd, &s->irq);
379
- memory_region_init_io(&s->iomem, obj, &mv88w8618_eth_ops, s,
380
- "mv88w8618-eth", MP_ETH_SIZE);
381
- sysbus_init_mmio(sbd, &s->iomem);
382
-}
383
-
384
-static void mv88w8618_eth_realize(DeviceState *dev, Error **errp)
385
-{
386
- mv88w8618_eth_state *s = MV88W8618_ETH(dev);
387
-
388
- if (!s->dma_mr) {
389
- error_setg(errp, TYPE_MV88W8618_ETH " 'dma-memory' link not set");
390
- return;
391
- }
392
-
393
- address_space_init(&s->dma_as, s->dma_mr, "emac-dma");
394
- s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf,
395
- object_get_typename(OBJECT(dev)), dev->id, s);
396
-}
397
-
398
-static const VMStateDescription mv88w8618_eth_vmsd = {
399
- .name = "mv88w8618_eth",
400
- .version_id = 1,
401
- .minimum_version_id = 1,
402
- .fields = (VMStateField[]) {
403
- VMSTATE_UINT32(smir, mv88w8618_eth_state),
404
- VMSTATE_UINT32(icr, mv88w8618_eth_state),
405
- VMSTATE_UINT32(imr, mv88w8618_eth_state),
406
- VMSTATE_UINT32(vlan_header, mv88w8618_eth_state),
407
- VMSTATE_UINT32_ARRAY(tx_queue, mv88w8618_eth_state, 2),
408
- VMSTATE_UINT32_ARRAY(rx_queue, mv88w8618_eth_state, 4),
409
- VMSTATE_UINT32_ARRAY(frx_queue, mv88w8618_eth_state, 4),
410
- VMSTATE_UINT32_ARRAY(cur_rx, mv88w8618_eth_state, 4),
411
- VMSTATE_END_OF_LIST()
412
- }
413
-};
414
-
415
-static Property mv88w8618_eth_properties[] = {
416
- DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf),
417
- DEFINE_PROP_LINK("dma-memory", mv88w8618_eth_state, dma_mr,
418
- TYPE_MEMORY_REGION, MemoryRegion *),
419
- DEFINE_PROP_END_OF_LIST(),
420
-};
421
-
422
-static void mv88w8618_eth_class_init(ObjectClass *klass, void *data)
423
-{
424
- DeviceClass *dc = DEVICE_CLASS(klass);
425
-
426
- dc->vmsd = &mv88w8618_eth_vmsd;
427
- device_class_set_props(dc, mv88w8618_eth_properties);
428
- dc->realize = mv88w8618_eth_realize;
429
-}
430
-
431
-static const TypeInfo mv88w8618_eth_info = {
432
- .name = TYPE_MV88W8618_ETH,
433
- .parent = TYPE_SYS_BUS_DEVICE,
434
- .instance_size = sizeof(mv88w8618_eth_state),
435
- .instance_init = mv88w8618_eth_init,
436
- .class_init = mv88w8618_eth_class_init,
437
-};
438
-
439
/* LCD register offsets */
440
#define MP_LCD_IRQCTRL 0x180
441
#define MP_LCD_IRQSTAT 0x184
442
@@ -XXX,XX +XXX,XX @@ static void musicpal_register_types(void)
443
type_register_static(&mv88w8618_pic_info);
444
type_register_static(&mv88w8618_pit_info);
445
type_register_static(&mv88w8618_flashcfg_info);
446
- type_register_static(&mv88w8618_eth_info);
447
type_register_static(&mv88w8618_wlan_info);
448
type_register_static(&musicpal_lcd_info);
449
type_register_static(&musicpal_gpio_info);
450
diff --git a/hw/net/mv88w8618_eth.c b/hw/net/mv88w8618_eth.c
451
new file mode 100644
77
new file mode 100644
452
index XXXXXXX..XXXXXXX
78
index XXXXXXX..XXXXXXX
453
--- /dev/null
79
--- /dev/null
454
+++ b/hw/net/mv88w8618_eth.c
80
+++ b/target/arm/translate-sme.c
455
@@ -XXX,XX +XXX,XX @@
81
@@ -XXX,XX +XXX,XX @@
456
+/* SPDX-License-Identifier: GPL-2.0-or-later */
457
+/*
82
+/*
458
+ * Marvell MV88W8618 / Freecom MusicPal emulation.
83
+ * AArch64 SME translation
459
+ *
84
+ *
460
+ * Copyright (c) 2008 Jan Kiszka
85
+ * Copyright (c) 2022 Linaro, Ltd
86
+ *
87
+ * This library is free software; you can redistribute it and/or
88
+ * modify it under the terms of the GNU Lesser General Public
89
+ * License as published by the Free Software Foundation; either
90
+ * version 2.1 of the License, or (at your option) any later version.
91
+ *
92
+ * This library is distributed in the hope that it will be useful,
93
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
94
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
95
+ * Lesser General Public License for more details.
96
+ *
97
+ * You should have received a copy of the GNU Lesser General Public
98
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
461
+ */
99
+ */
462
+
100
+
463
+#include "qemu/osdep.h"
101
+#include "qemu/osdep.h"
464
+#include "qapi/error.h"
102
+#include "cpu.h"
465
+#include "hw/qdev-properties.h"
103
+#include "tcg/tcg-op.h"
466
+#include "hw/sysbus.h"
104
+#include "tcg/tcg-op-gvec.h"
467
+#include "hw/irq.h"
105
+#include "tcg/tcg-gvec-desc.h"
468
+#include "hw/net/mv88w8618_eth.h"
106
+#include "translate.h"
469
+#include "migration/vmstate.h"
107
+#include "exec/helper-gen.h"
470
+#include "sysemu/dma.h"
108
+#include "translate-a64.h"
471
+#include "net/net.h"
109
+#include "fpu/softfloat.h"
472
+
110
+
473
+#define MP_ETH_SIZE 0x00001000
474
+
111
+
475
+/* Ethernet register offsets */
112
+/*
476
+#define MP_ETH_SMIR 0x010
113
+ * Include the generated decoder.
477
+#define MP_ETH_PCXR 0x408
114
+ */
478
+#define MP_ETH_SDCMR 0x448
479
+#define MP_ETH_ICR 0x450
480
+#define MP_ETH_IMR 0x458
481
+#define MP_ETH_FRDP0 0x480
482
+#define MP_ETH_FRDP1 0x484
483
+#define MP_ETH_FRDP2 0x488
484
+#define MP_ETH_FRDP3 0x48C
485
+#define MP_ETH_CRDP0 0x4A0
486
+#define MP_ETH_CRDP1 0x4A4
487
+#define MP_ETH_CRDP2 0x4A8
488
+#define MP_ETH_CRDP3 0x4AC
489
+#define MP_ETH_CTDP0 0x4E0
490
+#define MP_ETH_CTDP1 0x4E4
491
+
115
+
492
+/* MII PHY access */
116
+#include "decode-sme.c.inc"
493
+#define MP_ETH_SMIR_DATA 0x0000FFFF
117
diff --git a/target/arm/meson.build b/target/arm/meson.build
494
+#define MP_ETH_SMIR_ADDR 0x03FF0000
495
+#define MP_ETH_SMIR_OPCODE (1 << 26) /* Read value */
496
+#define MP_ETH_SMIR_RDVALID (1 << 27)
497
+
498
+/* PHY registers */
499
+#define MP_ETH_PHY1_BMSR 0x00210000
500
+#define MP_ETH_PHY1_PHYSID1 0x00410000
501
+#define MP_ETH_PHY1_PHYSID2 0x00610000
502
+
503
+#define MP_PHY_BMSR_LINK 0x0004
504
+#define MP_PHY_BMSR_AUTONEG 0x0008
505
+
506
+#define MP_PHY_88E3015 0x01410E20
507
+
508
+/* TX descriptor status */
509
+#define MP_ETH_TX_OWN (1U << 31)
510
+
511
+/* RX descriptor status */
512
+#define MP_ETH_RX_OWN (1U << 31)
513
+
514
+/* Interrupt cause/mask bits */
515
+#define MP_ETH_IRQ_RX_BIT 0
516
+#define MP_ETH_IRQ_RX (1 << MP_ETH_IRQ_RX_BIT)
517
+#define MP_ETH_IRQ_TXHI_BIT 2
518
+#define MP_ETH_IRQ_TXLO_BIT 3
519
+
520
+/* Port config bits */
521
+#define MP_ETH_PCXR_2BSM_BIT 28 /* 2-byte incoming suffix */
522
+
523
+/* SDMA command bits */
524
+#define MP_ETH_CMD_TXHI (1 << 23)
525
+#define MP_ETH_CMD_TXLO (1 << 22)
526
+
527
+typedef struct mv88w8618_tx_desc {
528
+ uint32_t cmdstat;
529
+ uint16_t res;
530
+ uint16_t bytes;
531
+ uint32_t buffer;
532
+ uint32_t next;
533
+} mv88w8618_tx_desc;
534
+
535
+typedef struct mv88w8618_rx_desc {
536
+ uint32_t cmdstat;
537
+ uint16_t bytes;
538
+ uint16_t buffer_size;
539
+ uint32_t buffer;
540
+ uint32_t next;
541
+} mv88w8618_rx_desc;
542
+
543
+OBJECT_DECLARE_SIMPLE_TYPE(mv88w8618_eth_state, MV88W8618_ETH)
544
+
545
+struct mv88w8618_eth_state {
546
+ /*< private >*/
547
+ SysBusDevice parent_obj;
548
+ /*< public >*/
549
+
550
+ MemoryRegion iomem;
551
+ qemu_irq irq;
552
+ MemoryRegion *dma_mr;
553
+ AddressSpace dma_as;
554
+ uint32_t smir;
555
+ uint32_t icr;
556
+ uint32_t imr;
557
+ int mmio_index;
558
+ uint32_t vlan_header;
559
+ uint32_t tx_queue[2];
560
+ uint32_t rx_queue[4];
561
+ uint32_t frx_queue[4];
562
+ uint32_t cur_rx[4];
563
+ NICState *nic;
564
+ NICConf conf;
565
+};
566
+
567
+static void eth_rx_desc_put(AddressSpace *dma_as, uint32_t addr,
568
+ mv88w8618_rx_desc *desc)
569
+{
570
+ cpu_to_le32s(&desc->cmdstat);
571
+ cpu_to_le16s(&desc->bytes);
572
+ cpu_to_le16s(&desc->buffer_size);
573
+ cpu_to_le32s(&desc->buffer);
574
+ cpu_to_le32s(&desc->next);
575
+ dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
576
+}
577
+
578
+static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr,
579
+ mv88w8618_rx_desc *desc)
580
+{
581
+ dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
582
+ le32_to_cpus(&desc->cmdstat);
583
+ le16_to_cpus(&desc->bytes);
584
+ le16_to_cpus(&desc->buffer_size);
585
+ le32_to_cpus(&desc->buffer);
586
+ le32_to_cpus(&desc->next);
587
+}
588
+
589
+static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
590
+{
591
+ mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
592
+ uint32_t desc_addr;
593
+ mv88w8618_rx_desc desc;
594
+ int i;
595
+
596
+ for (i = 0; i < 4; i++) {
597
+ desc_addr = s->cur_rx[i];
598
+ if (!desc_addr) {
599
+ continue;
600
+ }
601
+ do {
602
+ eth_rx_desc_get(&s->dma_as, desc_addr, &desc);
603
+ if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) {
604
+ dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header,
605
+ buf, size, MEMTXATTRS_UNSPECIFIED);
606
+ desc.bytes = size + s->vlan_header;
607
+ desc.cmdstat &= ~MP_ETH_RX_OWN;
608
+ s->cur_rx[i] = desc.next;
609
+
610
+ s->icr |= MP_ETH_IRQ_RX;
611
+ if (s->icr & s->imr) {
612
+ qemu_irq_raise(s->irq);
613
+ }
614
+ eth_rx_desc_put(&s->dma_as, desc_addr, &desc);
615
+ return size;
616
+ }
617
+ desc_addr = desc.next;
618
+ } while (desc_addr != s->rx_queue[i]);
619
+ }
620
+ return size;
621
+}
622
+
623
+static void eth_tx_desc_put(AddressSpace *dma_as, uint32_t addr,
624
+ mv88w8618_tx_desc *desc)
625
+{
626
+ cpu_to_le32s(&desc->cmdstat);
627
+ cpu_to_le16s(&desc->res);
628
+ cpu_to_le16s(&desc->bytes);
629
+ cpu_to_le32s(&desc->buffer);
630
+ cpu_to_le32s(&desc->next);
631
+ dma_memory_write(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
632
+}
633
+
634
+static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr,
635
+ mv88w8618_tx_desc *desc)
636
+{
637
+ dma_memory_read(dma_as, addr, desc, sizeof(*desc), MEMTXATTRS_UNSPECIFIED);
638
+ le32_to_cpus(&desc->cmdstat);
639
+ le16_to_cpus(&desc->res);
640
+ le16_to_cpus(&desc->bytes);
641
+ le32_to_cpus(&desc->buffer);
642
+ le32_to_cpus(&desc->next);
643
+}
644
+
645
+static void eth_send(mv88w8618_eth_state *s, int queue_index)
646
+{
647
+ uint32_t desc_addr = s->tx_queue[queue_index];
648
+ mv88w8618_tx_desc desc;
649
+ uint32_t next_desc;
650
+ uint8_t buf[2048];
651
+ int len;
652
+
653
+ do {
654
+ eth_tx_desc_get(&s->dma_as, desc_addr, &desc);
655
+ next_desc = desc.next;
656
+ if (desc.cmdstat & MP_ETH_TX_OWN) {
657
+ len = desc.bytes;
658
+ if (len < 2048) {
659
+ dma_memory_read(&s->dma_as, desc.buffer, buf, len,
660
+ MEMTXATTRS_UNSPECIFIED);
661
+ qemu_send_packet(qemu_get_queue(s->nic), buf, len);
662
+ }
663
+ desc.cmdstat &= ~MP_ETH_TX_OWN;
664
+ s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
665
+ eth_tx_desc_put(&s->dma_as, desc_addr, &desc);
666
+ }
667
+ desc_addr = next_desc;
668
+ } while (desc_addr != s->tx_queue[queue_index]);
669
+}
670
+
671
+static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset,
672
+ unsigned size)
673
+{
674
+ mv88w8618_eth_state *s = opaque;
675
+
676
+ switch (offset) {
677
+ case MP_ETH_SMIR:
678
+ if (s->smir & MP_ETH_SMIR_OPCODE) {
679
+ switch (s->smir & MP_ETH_SMIR_ADDR) {
680
+ case MP_ETH_PHY1_BMSR:
681
+ return MP_PHY_BMSR_LINK | MP_PHY_BMSR_AUTONEG |
682
+ MP_ETH_SMIR_RDVALID;
683
+ case MP_ETH_PHY1_PHYSID1:
684
+ return (MP_PHY_88E3015 >> 16) | MP_ETH_SMIR_RDVALID;
685
+ case MP_ETH_PHY1_PHYSID2:
686
+ return (MP_PHY_88E3015 & 0xFFFF) | MP_ETH_SMIR_RDVALID;
687
+ default:
688
+ return MP_ETH_SMIR_RDVALID;
689
+ }
690
+ }
691
+ return 0;
692
+
693
+ case MP_ETH_ICR:
694
+ return s->icr;
695
+
696
+ case MP_ETH_IMR:
697
+ return s->imr;
698
+
699
+ case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
700
+ return s->frx_queue[(offset - MP_ETH_FRDP0) / 4];
701
+
702
+ case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
703
+ return s->rx_queue[(offset - MP_ETH_CRDP0) / 4];
704
+
705
+ case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
706
+ return s->tx_queue[(offset - MP_ETH_CTDP0) / 4];
707
+
708
+ default:
709
+ return 0;
710
+ }
711
+}
712
+
713
+static void mv88w8618_eth_write(void *opaque, hwaddr offset,
714
+ uint64_t value, unsigned size)
715
+{
716
+ mv88w8618_eth_state *s = opaque;
717
+
718
+ switch (offset) {
719
+ case MP_ETH_SMIR:
720
+ s->smir = value;
721
+ break;
722
+
723
+ case MP_ETH_PCXR:
724
+ s->vlan_header = ((value >> MP_ETH_PCXR_2BSM_BIT) & 1) * 2;
725
+ break;
726
+
727
+ case MP_ETH_SDCMR:
728
+ if (value & MP_ETH_CMD_TXHI) {
729
+ eth_send(s, 1);
730
+ }
731
+ if (value & MP_ETH_CMD_TXLO) {
732
+ eth_send(s, 0);
733
+ }
734
+ if (value & (MP_ETH_CMD_TXHI | MP_ETH_CMD_TXLO) && s->icr & s->imr) {
735
+ qemu_irq_raise(s->irq);
736
+ }
737
+ break;
738
+
739
+ case MP_ETH_ICR:
740
+ s->icr &= value;
741
+ break;
742
+
743
+ case MP_ETH_IMR:
744
+ s->imr = value;
745
+ if (s->icr & s->imr) {
746
+ qemu_irq_raise(s->irq);
747
+ }
748
+ break;
749
+
750
+ case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
751
+ s->frx_queue[(offset - MP_ETH_FRDP0) / 4] = value;
752
+ break;
753
+
754
+ case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
755
+ s->rx_queue[(offset - MP_ETH_CRDP0) / 4] =
756
+ s->cur_rx[(offset - MP_ETH_CRDP0) / 4] = value;
757
+ break;
758
+
759
+ case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
760
+ s->tx_queue[(offset - MP_ETH_CTDP0) / 4] = value;
761
+ break;
762
+ }
763
+}
764
+
765
+static const MemoryRegionOps mv88w8618_eth_ops = {
766
+ .read = mv88w8618_eth_read,
767
+ .write = mv88w8618_eth_write,
768
+ .endianness = DEVICE_NATIVE_ENDIAN,
769
+};
770
+
771
+static void eth_cleanup(NetClientState *nc)
772
+{
773
+ mv88w8618_eth_state *s = qemu_get_nic_opaque(nc);
774
+
775
+ s->nic = NULL;
776
+}
777
+
778
+static NetClientInfo net_mv88w8618_info = {
779
+ .type = NET_CLIENT_DRIVER_NIC,
780
+ .size = sizeof(NICState),
781
+ .receive = eth_receive,
782
+ .cleanup = eth_cleanup,
783
+};
784
+
785
+static void mv88w8618_eth_init(Object *obj)
786
+{
787
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
788
+ DeviceState *dev = DEVICE(sbd);
789
+ mv88w8618_eth_state *s = MV88W8618_ETH(dev);
790
+
791
+ sysbus_init_irq(sbd, &s->irq);
792
+ memory_region_init_io(&s->iomem, obj, &mv88w8618_eth_ops, s,
793
+ "mv88w8618-eth", MP_ETH_SIZE);
794
+ sysbus_init_mmio(sbd, &s->iomem);
795
+}
796
+
797
+static void mv88w8618_eth_realize(DeviceState *dev, Error **errp)
798
+{
799
+ mv88w8618_eth_state *s = MV88W8618_ETH(dev);
800
+
801
+ if (!s->dma_mr) {
802
+ error_setg(errp, TYPE_MV88W8618_ETH " 'dma-memory' link not set");
803
+ return;
804
+ }
805
+
806
+ address_space_init(&s->dma_as, s->dma_mr, "emac-dma");
807
+ s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf,
808
+ object_get_typename(OBJECT(dev)), dev->id, s);
809
+}
810
+
811
+static const VMStateDescription mv88w8618_eth_vmsd = {
812
+ .name = "mv88w8618_eth",
813
+ .version_id = 1,
814
+ .minimum_version_id = 1,
815
+ .fields = (VMStateField[]) {
816
+ VMSTATE_UINT32(smir, mv88w8618_eth_state),
817
+ VMSTATE_UINT32(icr, mv88w8618_eth_state),
818
+ VMSTATE_UINT32(imr, mv88w8618_eth_state),
819
+ VMSTATE_UINT32(vlan_header, mv88w8618_eth_state),
820
+ VMSTATE_UINT32_ARRAY(tx_queue, mv88w8618_eth_state, 2),
821
+ VMSTATE_UINT32_ARRAY(rx_queue, mv88w8618_eth_state, 4),
822
+ VMSTATE_UINT32_ARRAY(frx_queue, mv88w8618_eth_state, 4),
823
+ VMSTATE_UINT32_ARRAY(cur_rx, mv88w8618_eth_state, 4),
824
+ VMSTATE_END_OF_LIST()
825
+ }
826
+};
827
+
828
+static Property mv88w8618_eth_properties[] = {
829
+ DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf),
830
+ DEFINE_PROP_LINK("dma-memory", mv88w8618_eth_state, dma_mr,
831
+ TYPE_MEMORY_REGION, MemoryRegion *),
832
+ DEFINE_PROP_END_OF_LIST(),
833
+};
834
+
835
+static void mv88w8618_eth_class_init(ObjectClass *klass, void *data)
836
+{
837
+ DeviceClass *dc = DEVICE_CLASS(klass);
838
+
839
+ dc->vmsd = &mv88w8618_eth_vmsd;
840
+ device_class_set_props(dc, mv88w8618_eth_properties);
841
+ dc->realize = mv88w8618_eth_realize;
842
+}
843
+
844
+static const TypeInfo mv88w8618_eth_info = {
845
+ .name = TYPE_MV88W8618_ETH,
846
+ .parent = TYPE_SYS_BUS_DEVICE,
847
+ .instance_size = sizeof(mv88w8618_eth_state),
848
+ .instance_init = mv88w8618_eth_init,
849
+ .class_init = mv88w8618_eth_class_init,
850
+};
851
+
852
+static void musicpal_register_types(void)
853
+{
854
+ type_register_static(&mv88w8618_eth_info);
855
+}
856
+
857
+type_init(musicpal_register_types)
858
+
859
diff --git a/MAINTAINERS b/MAINTAINERS
860
index XXXXXXX..XXXXXXX 100644
118
index XXXXXXX..XXXXXXX 100644
861
--- a/MAINTAINERS
119
--- a/target/arm/meson.build
862
+++ b/MAINTAINERS
120
+++ b/target/arm/meson.build
863
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
121
@@ -XXX,XX +XXX,XX @@
864
L: qemu-arm@nongnu.org
122
gen = [
865
S: Odd Fixes
123
decodetree.process('sve.decode', extra_args: '--decode=disas_sve'),
866
F: hw/arm/musicpal.c
124
+ decodetree.process('sme.decode', extra_args: '--decode=disas_sme'),
867
+F: hw/net/mv88w8618_eth.c
125
decodetree.process('neon-shared.decode', extra_args: '--decode=disas_neon_shared'),
868
+F: include/hw/net/mv88w8618_eth.h
126
decodetree.process('neon-dp.decode', extra_args: '--decode=disas_neon_dp'),
869
F: docs/system/arm/musicpal.rst
127
decodetree.process('neon-ls.decode', extra_args: '--decode=disas_neon_ls'),
870
128
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files(
871
Nuvoton NPCM7xx
129
'sme_helper.c',
872
diff --git a/hw/net/meson.build b/hw/net/meson.build
130
'translate-a64.c',
873
index XXXXXXX..XXXXXXX 100644
131
'translate-sve.c',
874
--- a/hw/net/meson.build
132
+ 'translate-sme.c',
875
+++ b/hw/net/meson.build
133
))
876
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ALLWINNER_EMAC', if_true: files('allwinner_emac.c')
134
877
softmmu_ss.add(when: 'CONFIG_ALLWINNER_SUN8I_EMAC', if_true: files('allwinner-sun8i-emac.c'))
135
arm_softmmu_ss = ss.source_set()
878
softmmu_ss.add(when: 'CONFIG_IMX_FEC', if_true: files('imx_fec.c'))
879
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-emac.c'))
880
+softmmu_ss.add(when: 'CONFIG_MARVELL_88W8618', if_true: files('mv88w8618_eth.c'))
881
882
softmmu_ss.add(when: 'CONFIG_CADENCE', if_true: files('cadence_gem.c'))
883
softmmu_ss.add(when: 'CONFIG_STELLARIS_ENET', if_true: files('stellaris_enet.c'))
884
--
136
--
885
2.25.1
137
2.25.1
886
887
diff view generated by jsdifflib
1
From: Marc Zyngier <maz@kernel.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Add basic support for Pointer Authentication when running a KVM
3
This new behaviour is in the ARM pseudocode function
4
guest and that the host supports it, loosely based on the SVE
4
AArch64.CheckFPAdvSIMDEnabled, which applies to AArch32
5
support.
5
via AArch32.CheckAdvSIMDOrFPEnabled when the EL to which
6
6
the trap would be delivered is in AArch64 mode.
7
Although the feature is enabled by default when the host advertises
7
8
it, it is possible to disable it by setting the 'pauth=off' CPU
8
Given that ARMv9 drops support for AArch32 outside EL0, the trap EL
9
property. The 'pauth' comment is removed from cpu-features.rst,
9
detection ought to be trivially true, but the pseudocode still contains
10
as it is now common to both TCG and KVM.
10
a number of conditions, and QEMU has not yet committed to dropping A32
11
11
support for EL[12] when v9 features are present.
12
Tested on an Apple M1 running 5.16-rc6.
12
13
13
Since the computation of SME_TRAP_NONSTREAMING is necessarily different
14
Cc: Eric Auger <eric.auger@redhat.com>
14
for the two modes, we might as well preserve bits within TBFLAG_ANY and
15
Cc: Richard Henderson <richard.henderson@linaro.org>
15
allocate separate bits within TBFLAG_A32 and TBFLAG_A64 instead.
16
Cc: Peter Maydell <peter.maydell@linaro.org>
16
17
Reviewed-by: Andrew Jones <drjones@redhat.com>
17
Note that DDI0616A.a has typos for bits [22:21] of LD1RO in the table
18
Signed-off-by: Marc Zyngier <maz@kernel.org>
18
of instructions illegal in streaming mode.
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
20
Message-id: 20220107150154.2490308-1-maz@kernel.org
20
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
21
[PMM: fixed indentation]
21
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
22
Message-id: 20220708151540.18136-4-richard.henderson@linaro.org
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
---
24
---
24
docs/system/arm/cpu-features.rst | 4 ----
25
target/arm/cpu.h | 7 +++
25
target/arm/cpu.h | 1 +
26
target/arm/translate.h | 4 ++
26
target/arm/cpu.c | 16 +++++-----------
27
target/arm/sme-fa64.decode | 90 ++++++++++++++++++++++++++++++++++++++
27
target/arm/cpu64.c | 31 +++++++++++++++++++++++++++----
28
target/arm/helper.c | 41 +++++++++++++++++
28
target/arm/kvm64.c | 21 +++++++++++++++++++++
29
target/arm/translate-a64.c | 40 ++++++++++++++++-
29
5 files changed, 54 insertions(+), 19 deletions(-)
30
target/arm/translate-vfp.c | 12 +++++
30
31
target/arm/translate.c | 2 +
31
diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst
32
target/arm/meson.build | 1 +
32
index XXXXXXX..XXXXXXX 100644
33
8 files changed, 195 insertions(+), 2 deletions(-)
33
--- a/docs/system/arm/cpu-features.rst
34
create mode 100644 target/arm/sme-fa64.decode
34
+++ b/docs/system/arm/cpu-features.rst
35
35
@@ -XXX,XX +XXX,XX @@ TCG VCPU Features
36
TCG VCPU features are CPU features that are specific to TCG.
37
Below is the list of TCG VCPU features and their descriptions.
38
39
- pauth Enable or disable ``FEAT_Pauth``, pointer
40
- authentication. By default, the feature is
41
- enabled with ``-cpu max``.
42
-
43
pauth-impdef When ``FEAT_Pauth`` is enabled, either the
44
*impdef* (Implementation Defined) algorithm
45
is enabled or the *architected* QARMA algorithm
46
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
36
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
47
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
48
--- a/target/arm/cpu.h
38
--- a/target/arm/cpu.h
49
+++ b/target/arm/cpu.h
39
+++ b/target/arm/cpu.h
50
@@ -XXX,XX +XXX,XX @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);
40
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, HSTR_ACTIVE, 9, 1)
51
void aarch64_sve_change_el(CPUARMState *env, int old_el,
41
* the same thing as the current security state of the processor!
52
int new_el, bool el0_a64);
42
*/
53
void aarch64_add_sve_properties(Object *obj);
43
FIELD(TBFLAG_A32, NS, 10, 1)
54
+void aarch64_add_pauth_properties(Object *obj);
44
+/*
45
+ * Indicates that SME Streaming mode is active, and SMCR_ELx.FA64 is not.
46
+ * This requires an SME trap from AArch32 mode when using NEON.
47
+ */
48
+FIELD(TBFLAG_A32, SME_TRAP_NONSTREAMING, 11, 1)
55
49
56
/*
50
/*
57
* SVE registers are encoded in KVM's memory in an endianness-invariant format.
51
* Bit usage when in AArch32 state, for M-profile only.
58
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
52
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, SMEEXC_EL, 20, 2)
59
index XXXXXXX..XXXXXXX 100644
53
FIELD(TBFLAG_A64, PSTATE_SM, 22, 1)
60
--- a/target/arm/cpu.c
54
FIELD(TBFLAG_A64, PSTATE_ZA, 23, 1)
61
+++ b/target/arm/cpu.c
55
FIELD(TBFLAG_A64, SVL, 24, 4)
62
@@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)
56
+/* Indicates that SME Streaming mode is active, and SMCR_ELx.FA64 is not. */
63
return;
57
+FIELD(TBFLAG_A64, SME_TRAP_NONSTREAMING, 28, 1)
58
59
/*
60
* Helpers for using the above.
61
diff --git a/target/arm/translate.h b/target/arm/translate.h
62
index XXXXXXX..XXXXXXX 100644
63
--- a/target/arm/translate.h
64
+++ b/target/arm/translate.h
65
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
66
bool pstate_sm;
67
/* True if PSTATE.ZA is set. */
68
bool pstate_za;
69
+ /* True if non-streaming insns should raise an SME Streaming exception. */
70
+ bool sme_trap_nonstreaming;
71
+ /* True if the current instruction is non-streaming. */
72
+ bool is_nonstreaming;
73
/* True if MVE insns are definitely not predicated by VPR or LTPSIZE */
74
bool mve_no_pred;
75
/*
76
diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode
77
new file mode 100644
78
index XXXXXXX..XXXXXXX
79
--- /dev/null
80
+++ b/target/arm/sme-fa64.decode
81
@@ -XXX,XX +XXX,XX @@
82
+# AArch64 SME allowed instruction decoding
83
+#
84
+# Copyright (c) 2022 Linaro, Ltd
85
+#
86
+# This library is free software; you can redistribute it and/or
87
+# modify it under the terms of the GNU Lesser General Public
88
+# License as published by the Free Software Foundation; either
89
+# version 2.1 of the License, or (at your option) any later version.
90
+#
91
+# This library is distributed in the hope that it will be useful,
92
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
93
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
94
+# Lesser General Public License for more details.
95
+#
96
+# You should have received a copy of the GNU Lesser General Public
97
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
98
+
99
+#
100
+# This file is processed by scripts/decodetree.py
101
+#
102
+
103
+# These patterns are taken from Appendix E1.1 of DDI0616 A.a,
104
+# Arm Architecture Reference Manual Supplement,
105
+# The Scalable Matrix Extension (SME), for Armv9-A
106
+
107
+{
108
+ [
109
+ OK 0-00 1110 0000 0001 0010 11-- ---- ---- # SMOV W|Xd,Vn.B[0]
110
+ OK 0-00 1110 0000 0010 0010 11-- ---- ---- # SMOV W|Xd,Vn.H[0]
111
+ OK 0100 1110 0000 0100 0010 11-- ---- ---- # SMOV Xd,Vn.S[0]
112
+ OK 0000 1110 0000 0001 0011 11-- ---- ---- # UMOV Wd,Vn.B[0]
113
+ OK 0000 1110 0000 0010 0011 11-- ---- ---- # UMOV Wd,Vn.H[0]
114
+ OK 0000 1110 0000 0100 0011 11-- ---- ---- # UMOV Wd,Vn.S[0]
115
+ OK 0100 1110 0000 1000 0011 11-- ---- ---- # UMOV Xd,Vn.D[0]
116
+ ]
117
+ FAIL 0--0 111- ---- ---- ---- ---- ---- ---- # Advanced SIMD vector operations
118
+}
119
+
120
+{
121
+ [
122
+ OK 0101 1110 --1- ---- 11-1 11-- ---- ---- # FMULX/FRECPS/FRSQRTS (scalar)
123
+ OK 0101 1110 -10- ---- 00-1 11-- ---- ---- # FMULX/FRECPS/FRSQRTS (scalar, FP16)
124
+ OK 01-1 1110 1-10 0001 11-1 10-- ---- ---- # FRECPE/FRSQRTE/FRECPX (scalar)
125
+ OK 01-1 1110 1111 1001 11-1 10-- ---- ---- # FRECPE/FRSQRTE/FRECPX (scalar, FP16)
126
+ ]
127
+ FAIL 01-1 111- ---- ---- ---- ---- ---- ---- # Advanced SIMD single-element operations
128
+}
129
+
130
+FAIL 0-00 110- ---- ---- ---- ---- ---- ---- # Advanced SIMD structure load/store
131
+FAIL 1100 1110 ---- ---- ---- ---- ---- ---- # Advanced SIMD cryptography extensions
132
+FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS
133
+
134
+# These are the "avoidance of doubt" final table of Illegal Advanced SIMD instructions
135
+# We don't actually need to include these, as the default is OK.
136
+# -001 111- ---- ---- ---- ---- ---- ---- # Scalar floating-point operations
137
+# --10 110- ---- ---- ---- ---- ---- ---- # Load/store pair of FP registers
138
+# --01 1100 ---- ---- ---- ---- ---- ---- # Load FP register (PC-relative literal)
139
+# --11 1100 --0- ---- ---- ---- ---- ---- # Load/store FP register (unscaled imm)
140
+# --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset)
141
+# --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm)
142
+
143
+FAIL 0000 0100 --1- ---- 1010 ---- ---- ---- # ADR
144
+FAIL 0000 0100 --1- ---- 1011 -0-- ---- ---- # FTSSEL, FEXPA
145
+FAIL 0000 0101 --10 0001 100- ---- ---- ---- # COMPACT
146
+FAIL 0010 0101 --01 100- 1111 000- ---0 ---- # RDFFR, RDFFRS
147
+FAIL 0010 0101 --10 1--- 1001 ---- ---- ---- # WRFFR, SETFFR
148
+FAIL 0100 0101 --0- ---- 1011 ---- ---- ---- # BDEP, BEXT, BGRP
149
+FAIL 0100 0101 000- ---- 0110 1--- ---- ---- # PMULLB, PMULLT (128b result)
150
+FAIL 0110 0100 --1- ---- 1110 01-- ---- ---- # FMMLA, BFMMLA
151
+FAIL 0110 0101 --0- ---- 0000 11-- ---- ---- # FTSMUL
152
+FAIL 0110 0101 --01 0--- 100- ---- ---- ---- # FTMAD
153
+FAIL 0110 0101 --01 1--- 001- ---- ---- ---- # FADDA
154
+FAIL 0100 0101 --0- ---- 1001 10-- ---- ---- # SMMLA, UMMLA, USMMLA
155
+FAIL 0100 0101 --1- ---- 1--- ---- ---- ---- # SVE2 string/histo/crypto instructions
156
+FAIL 1000 010- -00- ---- 10-- ---- ---- ---- # SVE2 32-bit gather NT load (vector+scalar)
157
+FAIL 1000 010- -00- ---- 111- ---- ---- ---- # SVE 32-bit gather prefetch (vector+imm)
158
+FAIL 1000 0100 0-1- ---- 0--- ---- ---- ---- # SVE 32-bit gather prefetch (scalar+vector)
159
+FAIL 1000 010- -01- ---- 1--- ---- ---- ---- # SVE 32-bit gather load (vector+imm)
160
+FAIL 1000 0100 0-0- ---- 0--- ---- ---- ---- # SVE 32-bit gather load byte (scalar+vector)
161
+FAIL 1000 0100 1--- ---- 0--- ---- ---- ---- # SVE 32-bit gather load half (scalar+vector)
162
+FAIL 1000 0101 0--- ---- 0--- ---- ---- ---- # SVE 32-bit gather load word (scalar+vector)
163
+FAIL 1010 010- ---- ---- 011- ---- ---- ---- # SVE contiguous FF load (scalar+scalar)
164
+FAIL 1010 010- ---1 ---- 101- ---- ---- ---- # SVE contiguous NF load (scalar+imm)
165
+FAIL 1010 010- -01- ---- 000- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+scalar)
166
+FAIL 1010 010- -010 ---- 001- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+imm)
167
+FAIL 1100 010- ---- ---- ---- ---- ---- ---- # SVE 64-bit gather load/prefetch
168
+FAIL 1110 010- -00- ---- 001- ---- ---- ---- # SVE2 64-bit scatter NT store (vector+scalar)
169
+FAIL 1110 010- -10- ---- 001- ---- ---- ---- # SVE2 32-bit scatter NT store (vector+scalar)
170
+FAIL 1110 010- ---- ---- 1-0- ---- ---- ---- # SVE scatter store (scalar+32-bit vector)
171
+FAIL 1110 010- ---- ---- 101- ---- ---- ---- # SVE scatter store (misc)
172
diff --git a/target/arm/helper.c b/target/arm/helper.c
173
index XXXXXXX..XXXXXXX 100644
174
--- a/target/arm/helper.c
175
+++ b/target/arm/helper.c
176
@@ -XXX,XX +XXX,XX @@ int sme_exception_el(CPUARMState *env, int el)
177
return 0;
178
}
179
180
+/* This corresponds to the ARM pseudocode function IsFullA64Enabled(). */
181
+static bool sme_fa64(CPUARMState *env, int el)
182
+{
183
+ if (!cpu_isar_feature(aa64_sme_fa64, env_archcpu(env))) {
184
+ return false;
185
+ }
186
+
187
+ if (el <= 1 && !el_is_in_host(env, el)) {
188
+ if (!FIELD_EX64(env->vfp.smcr_el[1], SMCR, FA64)) {
189
+ return false;
190
+ }
191
+ }
192
+ if (el <= 2 && arm_is_el2_enabled(env)) {
193
+ if (!FIELD_EX64(env->vfp.smcr_el[2], SMCR, FA64)) {
194
+ return false;
195
+ }
196
+ }
197
+ if (arm_feature(env, ARM_FEATURE_EL3)) {
198
+ if (!FIELD_EX64(env->vfp.smcr_el[3], SMCR, FA64)) {
199
+ return false;
200
+ }
201
+ }
202
+
203
+ return true;
204
+}
205
+
206
/*
207
* Given that SVE is enabled, return the vector length for EL.
208
*/
209
@@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el,
210
DP_TBFLAG_ANY(flags, PSTATE__IL, 1);
211
}
212
213
+ /*
214
+ * The SME exception we are testing for is raised via
215
+ * AArch64.CheckFPAdvSIMDEnabled(), as called from
216
+ * AArch32.CheckAdvSIMDOrFPEnabled().
217
+ */
218
+ if (el == 0
219
+ && FIELD_EX64(env->svcr, SVCR, SM)
220
+ && (!arm_is_el2_enabled(env)
221
+ || (arm_el_is_aa64(env, 2) && !(env->cp15.hcr_el2 & HCR_TGE)))
222
+ && arm_el_is_aa64(env, 1)
223
+ && !sme_fa64(env, el)) {
224
+ DP_TBFLAG_A32(flags, SME_TRAP_NONSTREAMING, 1);
225
+ }
226
+
227
return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags);
228
}
229
230
@@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
64
}
231
}
65
232
if (FIELD_EX64(env->svcr, SVCR, SM)) {
66
- /*
233
DP_TBFLAG_A64(flags, PSTATE_SM, 1);
67
- * KVM does not support modifications to this feature.
234
+ DP_TBFLAG_A64(flags, SME_TRAP_NONSTREAMING, !sme_fa64(env, el));
68
- * We have not registered the cpu properties when KVM
69
- * is in use, so the user will not be able to set them.
70
- */
71
- if (!kvm_enabled()) {
72
- arm_cpu_pauth_finalize(cpu, &local_err);
73
- if (local_err != NULL) {
74
- error_propagate(errp, local_err);
75
- return;
76
- }
77
+ arm_cpu_pauth_finalize(cpu, &local_err);
78
+ if (local_err != NULL) {
79
+ error_propagate(errp, local_err);
80
+ return;
81
}
235
}
82
}
236
DP_TBFLAG_A64(flags, PSTATE_ZA, FIELD_EX64(env->svcr, SVCR, ZA));
83
237
}
84
@@ -XXX,XX +XXX,XX @@ static void arm_host_initfn(Object *obj)
238
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
85
kvm_arm_set_cpu_features_from_host(cpu);
239
index XXXXXXX..XXXXXXX 100644
86
if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
240
--- a/target/arm/translate-a64.c
87
aarch64_add_sve_properties(obj);
241
+++ b/target/arm/translate-a64.c
88
+ aarch64_add_pauth_properties(obj);
242
@@ -XXX,XX +XXX,XX @@ static void do_vec_ld(DisasContext *s, int destidx, int element,
89
}
243
* unallocated-encoding checks (otherwise the syndrome information
90
#else
244
* for the resulting exception will be incorrect).
91
hvf_arm_set_cpu_features_from_host(cpu);
245
*/
92
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
246
-static bool fp_access_check(DisasContext *s)
93
index XXXXXXX..XXXXXXX 100644
247
+static bool fp_access_check_only(DisasContext *s)
94
--- a/target/arm/cpu64.c
248
{
95
+++ b/target/arm/cpu64.c
249
if (s->fp_excp_el) {
96
@@ -XXX,XX +XXX,XX @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
250
assert(!s->fp_access_checked);
97
int arch_val = 0, impdef_val = 0;
251
@@ -XXX,XX +XXX,XX @@ static bool fp_access_check(DisasContext *s)
98
uint64_t t;
252
return true;
99
100
+ /* Exit early if PAuth is enabled, and fall through to disable it */
101
+ if (kvm_enabled() && cpu->prop_pauth) {
102
+ if (!cpu_isar_feature(aa64_pauth, cpu)) {
103
+ error_setg(errp, "'pauth' feature not supported by KVM on this host");
104
+ }
105
+
106
+ return;
107
+ }
108
+
109
/* TODO: Handle HaveEnhancedPAC, HaveEnhancedPAC2, HaveFPAC. */
110
if (cpu->prop_pauth) {
111
if (cpu->prop_pauth_impdef) {
112
@@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pauth_property =
113
static Property arm_cpu_pauth_impdef_property =
114
DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false);
115
116
+void aarch64_add_pauth_properties(Object *obj)
117
+{
118
+ ARMCPU *cpu = ARM_CPU(obj);
119
+
120
+ /* Default to PAUTH on, with the architected algorithm on TCG. */
121
+ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property);
122
+ if (kvm_enabled()) {
123
+ /*
124
+ * Mirror PAuth support from the probed sysregs back into the
125
+ * property for KVM. Is it just a bit backward? Yes it is!
126
+ */
127
+ cpu->prop_pauth = cpu_isar_feature(aa64_pauth, cpu);
128
+ } else {
129
+ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property);
130
+ }
131
+}
132
+
133
/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
134
* otherwise, a CPU with as many features enabled as our emulation supports.
135
* The version of '-cpu max' for qemu-system-arm is defined in cpu.c;
136
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
137
cpu->dcz_blocksize = 7; /* 512 bytes */
138
#endif
139
140
- /* Default to PAUTH on, with the architected algorithm. */
141
- qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property);
142
- qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property);
143
-
144
bitmap_fill(cpu->sve_vq_supported, ARM_MAX_VQ);
145
}
146
147
+ aarch64_add_pauth_properties(obj);
148
aarch64_add_sve_properties(obj);
149
object_property_add(obj, "sve-max-vq", "uint32", cpu_max_get_sve_max_vq,
150
cpu_max_set_sve_max_vq, NULL, NULL);
151
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
152
index XXXXXXX..XXXXXXX 100644
153
--- a/target/arm/kvm64.c
154
+++ b/target/arm/kvm64.c
155
@@ -XXX,XX +XXX,XX @@ static int read_sys_reg64(int fd, uint64_t *pret, uint64_t id)
156
return ioctl(fd, KVM_GET_ONE_REG, &idreg);
157
}
253
}
158
254
159
+static bool kvm_arm_pauth_supported(void)
255
+static bool fp_access_check(DisasContext *s)
160
+{
256
+{
161
+ return (kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_ADDRESS) &&
257
+ if (!fp_access_check_only(s)) {
162
+ kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_GENERIC));
258
+ return false;
163
+}
259
+ }
164
+
260
+ if (s->sme_trap_nonstreaming && s->is_nonstreaming) {
165
bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
261
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
166
{
262
+ syn_smetrap(SME_ET_Streaming, false));
167
/* Identify the feature bits corresponding to the host CPU, and
263
+ return false;
168
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
264
+ }
169
*/
265
+ return true;
170
struct kvm_vcpu_init init = { .target = -1, };
266
+}
267
+
268
/* Check that SVE access is enabled. If it is, return true.
269
* If not, emit code to generate an appropriate exception and return false.
270
*/
271
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
272
default:
273
g_assert_not_reached();
274
}
275
- if ((ri->type & ARM_CP_FPU) && !fp_access_check(s)) {
276
+ if ((ri->type & ARM_CP_FPU) && !fp_access_check_only(s)) {
277
return;
278
} else if ((ri->type & ARM_CP_SVE) && !sve_access_check(s)) {
279
return;
280
@@ -XXX,XX +XXX,XX @@ static void disas_data_proc_simd_fp(DisasContext *s, uint32_t insn)
281
}
282
}
283
284
+/*
285
+ * Include the generated SME FA64 decoder.
286
+ */
287
+
288
+#include "decode-sme-fa64.c.inc"
289
+
290
+static bool trans_OK(DisasContext *s, arg_OK *a)
291
+{
292
+ return true;
293
+}
294
+
295
+static bool trans_FAIL(DisasContext *s, arg_OK *a)
296
+{
297
+ s->is_nonstreaming = true;
298
+ return true;
299
+}
300
+
301
/**
302
* is_guarded_page:
303
* @env: The cpu environment
304
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase,
305
dc->mte_active[1] = EX_TBFLAG_A64(tb_flags, MTE0_ACTIVE);
306
dc->pstate_sm = EX_TBFLAG_A64(tb_flags, PSTATE_SM);
307
dc->pstate_za = EX_TBFLAG_A64(tb_flags, PSTATE_ZA);
308
+ dc->sme_trap_nonstreaming = EX_TBFLAG_A64(tb_flags, SME_TRAP_NONSTREAMING);
309
dc->vec_len = 0;
310
dc->vec_stride = 0;
311
dc->cp_regs = arm_cpu->cp_regs;
312
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
313
}
314
}
315
316
+ s->is_nonstreaming = false;
317
+ if (s->sme_trap_nonstreaming) {
318
+ disas_sme_fa64(s, insn);
319
+ }
320
+
321
switch (extract32(insn, 25, 4)) {
322
case 0x0:
323
if (!extract32(insn, 31, 1) || !disas_sme(s, insn)) {
324
diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c
325
index XXXXXXX..XXXXXXX 100644
326
--- a/target/arm/translate-vfp.c
327
+++ b/target/arm/translate-vfp.c
328
@@ -XXX,XX +XXX,XX @@ static bool vfp_access_check_a(DisasContext *s, bool ignore_vfp_enabled)
329
return false;
330
}
171
331
172
+ /*
332
+ /*
173
+ * Ask for Pointer Authentication if supported. We can't play the
333
+ * Note that rebuild_hflags_a32 has already accounted for being in EL0
174
+ * SVE trick of synthesising the ID reg as KVM won't tell us
334
+ * and the higher EL in A64 mode, etc. Unlike A64 mode, there do not
175
+ * whether we have the architected or IMPDEF version of PAuth, so
335
+ * appear to be any insns which touch VFP which are allowed.
176
+ * we have to use the actual ID regs.
177
+ */
336
+ */
178
+ if (kvm_arm_pauth_supported()) {
337
+ if (s->sme_trap_nonstreaming) {
179
+ init.features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS |
338
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
180
+ 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC);
339
+ syn_smetrap(SME_ET_Streaming,
181
+ }
340
+ s->base.pc_next - s->pc_curr == 2));
182
+
341
+ return false;
183
if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) {
342
+ }
184
return false;
343
+
185
}
344
if (!s->vfp_enabled && !ignore_vfp_enabled) {
186
@@ -XXX,XX +XXX,XX @@ int kvm_arch_init_vcpu(CPUState *cs)
345
assert(!arm_dc_feature(s, ARM_FEATURE_M));
187
assert(kvm_arm_sve_supported());
346
unallocated_encoding(s);
188
cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE;
347
diff --git a/target/arm/translate.c b/target/arm/translate.c
189
}
348
index XXXXXXX..XXXXXXX 100644
190
+ if (cpu_isar_feature(aa64_pauth, cpu)) {
349
--- a/target/arm/translate.c
191
+ cpu->kvm_init_features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS |
350
+++ b/target/arm/translate.c
192
+ 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC);
351
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
193
+ }
352
dc->vec_len = EX_TBFLAG_A32(tb_flags, VECLEN);
194
353
dc->vec_stride = EX_TBFLAG_A32(tb_flags, VECSTRIDE);
195
/* Do KVM_ARM_VCPU_INIT ioctl */
354
}
196
ret = kvm_arm_vcpu_init(cs);
355
+ dc->sme_trap_nonstreaming =
356
+ EX_TBFLAG_A32(tb_flags, SME_TRAP_NONSTREAMING);
357
}
358
dc->cp_regs = cpu->cp_regs;
359
dc->features = env->features;
360
diff --git a/target/arm/meson.build b/target/arm/meson.build
361
index XXXXXXX..XXXXXXX 100644
362
--- a/target/arm/meson.build
363
+++ b/target/arm/meson.build
364
@@ -XXX,XX +XXX,XX @@
365
gen = [
366
decodetree.process('sve.decode', extra_args: '--decode=disas_sve'),
367
decodetree.process('sme.decode', extra_args: '--decode=disas_sme'),
368
+ decodetree.process('sme-fa64.decode', extra_args: '--static-decode=disas_sme_fa64'),
369
decodetree.process('neon-shared.decode', extra_args: '--decode=disas_neon_shared'),
370
decodetree.process('neon-dp.decode', extra_args: '--decode=disas_neon_dp'),
371
decodetree.process('neon-ls.decode', extra_args: '--decode=disas_neon_ls'),
197
--
372
--
198
2.25.1
373
2.25.1
199
200
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Mark ADR as a non-streaming instruction, which should trap
4
if full a64 support is not enabled in streaming mode.
5
6
Removing entries from sme-fa64.decode is an easy way to see
7
what remains to be done.
8
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20220708151540.18136-5-richard.henderson@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/translate.h | 7 +++++++
15
target/arm/sme-fa64.decode | 1 -
16
target/arm/translate-sve.c | 8 ++++----
17
3 files changed, 11 insertions(+), 5 deletions(-)
18
19
diff --git a/target/arm/translate.h b/target/arm/translate.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/translate.h
22
+++ b/target/arm/translate.h
23
@@ -XXX,XX +XXX,XX @@ uint64_t asimd_imm_const(uint32_t imm, int cmode, int op);
24
static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
25
{ return dc_isar_feature(FEAT, s) && FUNC(s, __VA_ARGS__); }
26
27
+#define TRANS_FEAT_NONSTREAMING(NAME, FEAT, FUNC, ...) \
28
+ static bool trans_##NAME(DisasContext *s, arg_##NAME *a) \
29
+ { \
30
+ s->is_nonstreaming = true; \
31
+ return dc_isar_feature(FEAT, s) && FUNC(s, __VA_ARGS__); \
32
+ }
33
+
34
#endif /* TARGET_ARM_TRANSLATE_H */
35
diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode
36
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/sme-fa64.decode
38
+++ b/target/arm/sme-fa64.decode
39
@@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS
40
# --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset)
41
# --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm)
42
43
-FAIL 0000 0100 --1- ---- 1010 ---- ---- ---- # ADR
44
FAIL 0000 0100 --1- ---- 1011 -0-- ---- ---- # FTSSEL, FEXPA
45
FAIL 0000 0101 --10 0001 100- ---- ---- ---- # COMPACT
46
FAIL 0010 0101 --01 100- 1111 000- ---0 ---- # RDFFR, RDFFRS
47
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/translate-sve.c
50
+++ b/target/arm/translate-sve.c
51
@@ -XXX,XX +XXX,XX @@ static bool do_adr(DisasContext *s, arg_rrri *a, gen_helper_gvec_3 *fn)
52
return gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, a->imm);
53
}
54
55
-TRANS_FEAT(ADR_p32, aa64_sve, do_adr, a, gen_helper_sve_adr_p32)
56
-TRANS_FEAT(ADR_p64, aa64_sve, do_adr, a, gen_helper_sve_adr_p64)
57
-TRANS_FEAT(ADR_s32, aa64_sve, do_adr, a, gen_helper_sve_adr_s32)
58
-TRANS_FEAT(ADR_u32, aa64_sve, do_adr, a, gen_helper_sve_adr_u32)
59
+TRANS_FEAT_NONSTREAMING(ADR_p32, aa64_sve, do_adr, a, gen_helper_sve_adr_p32)
60
+TRANS_FEAT_NONSTREAMING(ADR_p64, aa64_sve, do_adr, a, gen_helper_sve_adr_p64)
61
+TRANS_FEAT_NONSTREAMING(ADR_s32, aa64_sve, do_adr, a, gen_helper_sve_adr_s32)
62
+TRANS_FEAT_NONSTREAMING(ADR_u32, aa64_sve, do_adr, a, gen_helper_sve_adr_u32)
63
64
/*
65
*** SVE Integer Misc - Unpredicated Group
66
--
67
2.25.1
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Mark these as a non-streaming instructions, which should trap
4
if full a64 support is not enabled in streaming mode.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-6-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/sme-fa64.decode | 2 --
12
target/arm/translate-sve.c | 9 ++++++---
13
2 files changed, 6 insertions(+), 5 deletions(-)
14
15
diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/sme-fa64.decode
18
+++ b/target/arm/sme-fa64.decode
19
@@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS
20
21
FAIL 0000 0100 --1- ---- 1011 -0-- ---- ---- # FTSSEL, FEXPA
22
FAIL 0000 0101 --10 0001 100- ---- ---- ---- # COMPACT
23
-FAIL 0010 0101 --01 100- 1111 000- ---0 ---- # RDFFR, RDFFRS
24
-FAIL 0010 0101 --10 1--- 1001 ---- ---- ---- # WRFFR, SETFFR
25
FAIL 0100 0101 --0- ---- 1011 ---- ---- ---- # BDEP, BEXT, BGRP
26
FAIL 0100 0101 000- ---- 0110 1--- ---- ---- # PMULLB, PMULLT (128b result)
27
FAIL 0110 0100 --1- ---- 1110 01-- ---- ---- # FMMLA, BFMMLA
28
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/translate-sve.c
31
+++ b/target/arm/translate-sve.c
32
@@ -XXX,XX +XXX,XX @@ static bool do_predset(DisasContext *s, int esz, int rd, int pat, bool setflag)
33
TRANS_FEAT(PTRUE, aa64_sve, do_predset, a->esz, a->rd, a->pat, a->s)
34
35
/* Note pat == 31 is #all, to set all elements. */
36
-TRANS_FEAT(SETFFR, aa64_sve, do_predset, 0, FFR_PRED_NUM, 31, false)
37
+TRANS_FEAT_NONSTREAMING(SETFFR, aa64_sve,
38
+ do_predset, 0, FFR_PRED_NUM, 31, false)
39
40
/* Note pat == 32 is #unimp, to set no elements. */
41
TRANS_FEAT(PFALSE, aa64_sve, do_predset, 0, a->rd, 32, false)
42
@@ -XXX,XX +XXX,XX @@ static bool trans_RDFFR_p(DisasContext *s, arg_RDFFR_p *a)
43
.rd = a->rd, .pg = a->pg, .s = a->s,
44
.rn = FFR_PRED_NUM, .rm = FFR_PRED_NUM,
45
};
46
+
47
+ s->is_nonstreaming = true;
48
return trans_AND_pppp(s, &alt_a);
49
}
50
51
-TRANS_FEAT(RDFFR, aa64_sve, do_mov_p, a->rd, FFR_PRED_NUM)
52
-TRANS_FEAT(WRFFR, aa64_sve, do_mov_p, FFR_PRED_NUM, a->rn)
53
+TRANS_FEAT_NONSTREAMING(RDFFR, aa64_sve, do_mov_p, a->rd, FFR_PRED_NUM)
54
+TRANS_FEAT_NONSTREAMING(WRFFR, aa64_sve, do_mov_p, FFR_PRED_NUM, a->rn)
55
56
static bool do_pfirst_pnext(DisasContext *s, arg_rr_esz *a,
57
void (*gen_fn)(TCGv_i32, TCGv_ptr,
58
--
59
2.25.1
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Mark these as a non-streaming instructions, which should trap
4
if full a64 support is not enabled in streaming mode.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-7-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/sme-fa64.decode | 3 ---
12
target/arm/translate-sve.c | 22 ++++++++++++----------
13
2 files changed, 12 insertions(+), 13 deletions(-)
14
15
diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/sme-fa64.decode
18
+++ b/target/arm/sme-fa64.decode
19
@@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS
20
# --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset)
21
# --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm)
22
23
-FAIL 0000 0100 --1- ---- 1011 -0-- ---- ---- # FTSSEL, FEXPA
24
-FAIL 0000 0101 --10 0001 100- ---- ---- ---- # COMPACT
25
-FAIL 0100 0101 --0- ---- 1011 ---- ---- ---- # BDEP, BEXT, BGRP
26
FAIL 0100 0101 000- ---- 0110 1--- ---- ---- # PMULLB, PMULLT (128b result)
27
FAIL 0110 0100 --1- ---- 1110 01-- ---- ---- # FMMLA, BFMMLA
28
FAIL 0110 0101 --0- ---- 0000 11-- ---- ---- # FTSMUL
29
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/arm/translate-sve.c
32
+++ b/target/arm/translate-sve.c
33
@@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_2 * const fexpa_fns[4] = {
34
NULL, gen_helper_sve_fexpa_h,
35
gen_helper_sve_fexpa_s, gen_helper_sve_fexpa_d,
36
};
37
-TRANS_FEAT(FEXPA, aa64_sve, gen_gvec_ool_zz,
38
- fexpa_fns[a->esz], a->rd, a->rn, 0)
39
+TRANS_FEAT_NONSTREAMING(FEXPA, aa64_sve, gen_gvec_ool_zz,
40
+ fexpa_fns[a->esz], a->rd, a->rn, 0)
41
42
static gen_helper_gvec_3 * const ftssel_fns[4] = {
43
NULL, gen_helper_sve_ftssel_h,
44
gen_helper_sve_ftssel_s, gen_helper_sve_ftssel_d,
45
};
46
-TRANS_FEAT(FTSSEL, aa64_sve, gen_gvec_ool_arg_zzz, ftssel_fns[a->esz], a, 0)
47
+TRANS_FEAT_NONSTREAMING(FTSSEL, aa64_sve, gen_gvec_ool_arg_zzz,
48
+ ftssel_fns[a->esz], a, 0)
49
50
/*
51
*** SVE Predicate Logical Operations Group
52
@@ -XXX,XX +XXX,XX @@ TRANS_FEAT(TRN2_q, aa64_sve_f64mm, gen_gvec_ool_arg_zzz,
53
static gen_helper_gvec_3 * const compact_fns[4] = {
54
NULL, NULL, gen_helper_sve_compact_s, gen_helper_sve_compact_d
55
};
56
-TRANS_FEAT(COMPACT, aa64_sve, gen_gvec_ool_arg_zpz, compact_fns[a->esz], a, 0)
57
+TRANS_FEAT_NONSTREAMING(COMPACT, aa64_sve, gen_gvec_ool_arg_zpz,
58
+ compact_fns[a->esz], a, 0)
59
60
/* Call the helper that computes the ARM LastActiveElement pseudocode
61
* function, scaled by the element size. This includes the not found
62
@@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3 * const bext_fns[4] = {
63
gen_helper_sve2_bext_b, gen_helper_sve2_bext_h,
64
gen_helper_sve2_bext_s, gen_helper_sve2_bext_d,
65
};
66
-TRANS_FEAT(BEXT, aa64_sve2_bitperm, gen_gvec_ool_arg_zzz,
67
- bext_fns[a->esz], a, 0)
68
+TRANS_FEAT_NONSTREAMING(BEXT, aa64_sve2_bitperm, gen_gvec_ool_arg_zzz,
69
+ bext_fns[a->esz], a, 0)
70
71
static gen_helper_gvec_3 * const bdep_fns[4] = {
72
gen_helper_sve2_bdep_b, gen_helper_sve2_bdep_h,
73
gen_helper_sve2_bdep_s, gen_helper_sve2_bdep_d,
74
};
75
-TRANS_FEAT(BDEP, aa64_sve2_bitperm, gen_gvec_ool_arg_zzz,
76
- bdep_fns[a->esz], a, 0)
77
+TRANS_FEAT_NONSTREAMING(BDEP, aa64_sve2_bitperm, gen_gvec_ool_arg_zzz,
78
+ bdep_fns[a->esz], a, 0)
79
80
static gen_helper_gvec_3 * const bgrp_fns[4] = {
81
gen_helper_sve2_bgrp_b, gen_helper_sve2_bgrp_h,
82
gen_helper_sve2_bgrp_s, gen_helper_sve2_bgrp_d,
83
};
84
-TRANS_FEAT(BGRP, aa64_sve2_bitperm, gen_gvec_ool_arg_zzz,
85
- bgrp_fns[a->esz], a, 0)
86
+TRANS_FEAT_NONSTREAMING(BGRP, aa64_sve2_bitperm, gen_gvec_ool_arg_zzz,
87
+ bgrp_fns[a->esz], a, 0)
88
89
static gen_helper_gvec_3 * const cadd_fns[4] = {
90
gen_helper_sve2_cadd_b, gen_helper_sve2_cadd_h,
91
--
92
2.25.1
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Mark these as a non-streaming instructions, which should trap
4
if full a64 support is not enabled in streaming mode.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-8-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/sme-fa64.decode | 2 --
12
target/arm/translate-sve.c | 24 +++++++++++++++---------
13
2 files changed, 15 insertions(+), 11 deletions(-)
14
15
diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/sme-fa64.decode
18
+++ b/target/arm/sme-fa64.decode
19
@@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS
20
# --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset)
21
# --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm)
22
23
-FAIL 0100 0101 000- ---- 0110 1--- ---- ---- # PMULLB, PMULLT (128b result)
24
-FAIL 0110 0100 --1- ---- 1110 01-- ---- ---- # FMMLA, BFMMLA
25
FAIL 0110 0101 --0- ---- 0000 11-- ---- ---- # FTSMUL
26
FAIL 0110 0101 --01 0--- 100- ---- ---- ---- # FTMAD
27
FAIL 0110 0101 --01 1--- 001- ---- ---- ---- # FADDA
28
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/translate-sve.c
31
+++ b/target/arm/translate-sve.c
32
@@ -XXX,XX +XXX,XX @@ static bool do_trans_pmull(DisasContext *s, arg_rrr_esz *a, bool sel)
33
gen_helper_gvec_pmull_q, gen_helper_sve2_pmull_h,
34
NULL, gen_helper_sve2_pmull_d,
35
};
36
- if (a->esz == 0
37
- ? !dc_isar_feature(aa64_sve2_pmull128, s)
38
- : !dc_isar_feature(aa64_sve, s)) {
39
+
40
+ if (a->esz == 0) {
41
+ if (!dc_isar_feature(aa64_sve2_pmull128, s)) {
42
+ return false;
43
+ }
44
+ s->is_nonstreaming = true;
45
+ } else if (!dc_isar_feature(aa64_sve, s)) {
46
return false;
47
}
48
return gen_gvec_ool_arg_zzz(s, fns[a->esz], a, sel);
49
@@ -XXX,XX +XXX,XX @@ DO_ZPZZ_FP(FMINP, aa64_sve2, sve2_fminp_zpzz)
50
* SVE Integer Multiply-Add (unpredicated)
51
*/
52
53
-TRANS_FEAT(FMMLA_s, aa64_sve_f32mm, gen_gvec_fpst_zzzz, gen_helper_fmmla_s,
54
- a->rd, a->rn, a->rm, a->ra, 0, FPST_FPCR)
55
-TRANS_FEAT(FMMLA_d, aa64_sve_f64mm, gen_gvec_fpst_zzzz, gen_helper_fmmla_d,
56
- a->rd, a->rn, a->rm, a->ra, 0, FPST_FPCR)
57
+TRANS_FEAT_NONSTREAMING(FMMLA_s, aa64_sve_f32mm, gen_gvec_fpst_zzzz,
58
+ gen_helper_fmmla_s, a->rd, a->rn, a->rm, a->ra,
59
+ 0, FPST_FPCR)
60
+TRANS_FEAT_NONSTREAMING(FMMLA_d, aa64_sve_f64mm, gen_gvec_fpst_zzzz,
61
+ gen_helper_fmmla_d, a->rd, a->rn, a->rm, a->ra,
62
+ 0, FPST_FPCR)
63
64
static gen_helper_gvec_4 * const sqdmlal_zzzw_fns[] = {
65
NULL, gen_helper_sve2_sqdmlal_zzzw_h,
66
@@ -XXX,XX +XXX,XX @@ TRANS_FEAT(BFDOT_zzzz, aa64_sve_bf16, gen_gvec_ool_arg_zzzz,
67
TRANS_FEAT(BFDOT_zzxz, aa64_sve_bf16, gen_gvec_ool_arg_zzxz,
68
gen_helper_gvec_bfdot_idx, a)
69
70
-TRANS_FEAT(BFMMLA, aa64_sve_bf16, gen_gvec_ool_arg_zzzz,
71
- gen_helper_gvec_bfmmla, a, 0)
72
+TRANS_FEAT_NONSTREAMING(BFMMLA, aa64_sve_bf16, gen_gvec_ool_arg_zzzz,
73
+ gen_helper_gvec_bfmmla, a, 0)
74
75
static bool do_BFMLAL_zzzw(DisasContext *s, arg_rrrr_esz *a, bool sel)
76
{
77
--
78
2.25.1
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Mark these as a non-streaming instructions, which should trap
4
if full a64 support is not enabled in streaming mode.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-9-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/sme-fa64.decode | 3 ---
12
target/arm/translate-sve.c | 15 +++++++++++----
13
2 files changed, 11 insertions(+), 7 deletions(-)
14
15
diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/sme-fa64.decode
18
+++ b/target/arm/sme-fa64.decode
19
@@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS
20
# --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset)
21
# --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm)
22
23
-FAIL 0110 0101 --0- ---- 0000 11-- ---- ---- # FTSMUL
24
-FAIL 0110 0101 --01 0--- 100- ---- ---- ---- # FTMAD
25
-FAIL 0110 0101 --01 1--- 001- ---- ---- ---- # FADDA
26
FAIL 0100 0101 --0- ---- 1001 10-- ---- ---- # SMMLA, UMMLA, USMMLA
27
FAIL 0100 0101 --1- ---- 1--- ---- ---- ---- # SVE2 string/histo/crypto instructions
28
FAIL 1000 010- -00- ---- 10-- ---- ---- ---- # SVE2 32-bit gather NT load (vector+scalar)
29
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/arm/translate-sve.c
32
+++ b/target/arm/translate-sve.c
33
@@ -XXX,XX +XXX,XX @@ static gen_helper_gvec_3_ptr * const ftmad_fns[4] = {
34
NULL, gen_helper_sve_ftmad_h,
35
gen_helper_sve_ftmad_s, gen_helper_sve_ftmad_d,
36
};
37
-TRANS_FEAT(FTMAD, aa64_sve, gen_gvec_fpst_zzz,
38
- ftmad_fns[a->esz], a->rd, a->rn, a->rm, a->imm,
39
- a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR)
40
+TRANS_FEAT_NONSTREAMING(FTMAD, aa64_sve, gen_gvec_fpst_zzz,
41
+ ftmad_fns[a->esz], a->rd, a->rn, a->rm, a->imm,
42
+ a->esz == MO_16 ? FPST_FPCR_F16 : FPST_FPCR)
43
44
/*
45
*** SVE Floating Point Accumulating Reduction Group
46
@@ -XXX,XX +XXX,XX @@ static bool trans_FADDA(DisasContext *s, arg_rprr_esz *a)
47
if (a->esz == 0 || !dc_isar_feature(aa64_sve, s)) {
48
return false;
49
}
50
+ s->is_nonstreaming = true;
51
if (!sve_access_check(s)) {
52
return true;
53
}
54
@@ -XXX,XX +XXX,XX @@ static bool trans_FADDA(DisasContext *s, arg_rprr_esz *a)
55
DO_FP3(FADD_zzz, fadd)
56
DO_FP3(FSUB_zzz, fsub)
57
DO_FP3(FMUL_zzz, fmul)
58
-DO_FP3(FTSMUL, ftsmul)
59
DO_FP3(FRECPS, recps)
60
DO_FP3(FRSQRTS, rsqrts)
61
62
#undef DO_FP3
63
64
+static gen_helper_gvec_3_ptr * const ftsmul_fns[4] = {
65
+ NULL, gen_helper_gvec_ftsmul_h,
66
+ gen_helper_gvec_ftsmul_s, gen_helper_gvec_ftsmul_d
67
+};
68
+TRANS_FEAT_NONSTREAMING(FTSMUL, aa64_sve, gen_gvec_fpst_arg_zzz,
69
+ ftsmul_fns[a->esz], a, 0)
70
+
71
/*
72
*** SVE Floating Point Arithmetic - Predicated Group
73
*/
74
--
75
2.25.1
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Mark these as a non-streaming instructions, which should trap
4
if full a64 support is not enabled in streaming mode.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-10-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/sme-fa64.decode | 1 -
12
target/arm/translate-sve.c | 12 ++++++------
13
2 files changed, 6 insertions(+), 7 deletions(-)
14
15
diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/sme-fa64.decode
18
+++ b/target/arm/sme-fa64.decode
19
@@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS
20
# --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset)
21
# --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm)
22
23
-FAIL 0100 0101 --0- ---- 1001 10-- ---- ---- # SMMLA, UMMLA, USMMLA
24
FAIL 0100 0101 --1- ---- 1--- ---- ---- ---- # SVE2 string/histo/crypto instructions
25
FAIL 1000 010- -00- ---- 10-- ---- ---- ---- # SVE2 32-bit gather NT load (vector+scalar)
26
FAIL 1000 010- -00- ---- 111- ---- ---- ---- # SVE 32-bit gather prefetch (vector+imm)
27
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/translate-sve.c
30
+++ b/target/arm/translate-sve.c
31
@@ -XXX,XX +XXX,XX @@ TRANS_FEAT(FMLALT_zzxw, aa64_sve2, do_FMLAL_zzxw, a, false, true)
32
TRANS_FEAT(FMLSLB_zzxw, aa64_sve2, do_FMLAL_zzxw, a, true, false)
33
TRANS_FEAT(FMLSLT_zzxw, aa64_sve2, do_FMLAL_zzxw, a, true, true)
34
35
-TRANS_FEAT(SMMLA, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz,
36
- gen_helper_gvec_smmla_b, a, 0)
37
-TRANS_FEAT(USMMLA, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz,
38
- gen_helper_gvec_usmmla_b, a, 0)
39
-TRANS_FEAT(UMMLA, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz,
40
- gen_helper_gvec_ummla_b, a, 0)
41
+TRANS_FEAT_NONSTREAMING(SMMLA, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz,
42
+ gen_helper_gvec_smmla_b, a, 0)
43
+TRANS_FEAT_NONSTREAMING(USMMLA, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz,
44
+ gen_helper_gvec_usmmla_b, a, 0)
45
+TRANS_FEAT_NONSTREAMING(UMMLA, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz,
46
+ gen_helper_gvec_ummla_b, a, 0)
47
48
TRANS_FEAT(BFDOT_zzzz, aa64_sve_bf16, gen_gvec_ool_arg_zzzz,
49
gen_helper_gvec_bfdot, a, 0)
50
--
51
2.25.1
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Quoting Peter Maydell:
3
Mark these as non-streaming instructions, which should trap
4
if full a64 support is not enabled in streaming mode.
4
5
5
"These MEMTX_* aren't from the memory transaction
6
API functions; they're just being used by gicd_readl() and
7
friends as a way to indicate a success/failure so that the
8
actual MemoryRegionOps read/write fns like gicv3_dist_read()
9
can log a guest error."
10
11
We are going to introduce more MemTxResult bits, so it is
12
safer to check for !MEMTX_OK rather than MEMTX_ERROR.
13
14
Reviewed-by: Peter Xu <peterx@redhat.com>
15
Reviewed-by: David Hildenbrand <david@redhat.com>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
18
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Message-id: 20220708151540.18136-11-richard.henderson@linaro.org
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
10
---
21
hw/intc/arm_gicv3_redist.c | 4 ++--
11
target/arm/sme-fa64.decode | 1 -
22
1 file changed, 2 insertions(+), 2 deletions(-)
12
target/arm/translate-sve.c | 35 ++++++++++++++++++-----------------
13
2 files changed, 18 insertions(+), 18 deletions(-)
23
14
24
diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c
15
diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode
25
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/intc/arm_gicv3_redist.c
17
--- a/target/arm/sme-fa64.decode
27
+++ b/hw/intc/arm_gicv3_redist.c
18
+++ b/target/arm/sme-fa64.decode
28
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_read(void *opaque, hwaddr offset, uint64_t *data,
19
@@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS
29
break;
20
# --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset)
30
}
21
# --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm)
31
22
32
- if (r == MEMTX_ERROR) {
23
-FAIL 0100 0101 --1- ---- 1--- ---- ---- ---- # SVE2 string/histo/crypto instructions
33
+ if (r != MEMTX_OK) {
24
FAIL 1000 010- -00- ---- 10-- ---- ---- ---- # SVE2 32-bit gather NT load (vector+scalar)
34
qemu_log_mask(LOG_GUEST_ERROR,
25
FAIL 1000 010- -00- ---- 111- ---- ---- ---- # SVE 32-bit gather prefetch (vector+imm)
35
"%s: invalid guest read at offset " TARGET_FMT_plx
26
FAIL 1000 0100 0-1- ---- 0--- ---- ---- ---- # SVE 32-bit gather prefetch (scalar+vector)
36
" size %u\n", __func__, offset, size);
27
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
37
@@ -XXX,XX +XXX,XX @@ MemTxResult gicv3_redist_write(void *opaque, hwaddr offset, uint64_t data,
28
index XXXXXXX..XXXXXXX 100644
38
break;
29
--- a/target/arm/translate-sve.c
39
}
30
+++ b/target/arm/translate-sve.c
40
31
@@ -XXX,XX +XXX,XX @@ DO_SVE2_ZZZ_NARROW(RSUBHNT, rsubhnt)
41
- if (r == MEMTX_ERROR) {
32
static gen_helper_gvec_flags_4 * const match_fns[4] = {
42
+ if (r != MEMTX_OK) {
33
gen_helper_sve2_match_ppzz_b, gen_helper_sve2_match_ppzz_h, NULL, NULL
43
qemu_log_mask(LOG_GUEST_ERROR,
34
};
44
"%s: invalid guest write at offset " TARGET_FMT_plx
35
-TRANS_FEAT(MATCH, aa64_sve2, do_ppzz_flags, a, match_fns[a->esz])
45
" size %u\n", __func__, offset, size);
36
+TRANS_FEAT_NONSTREAMING(MATCH, aa64_sve2, do_ppzz_flags, a, match_fns[a->esz])
37
38
static gen_helper_gvec_flags_4 * const nmatch_fns[4] = {
39
gen_helper_sve2_nmatch_ppzz_b, gen_helper_sve2_nmatch_ppzz_h, NULL, NULL
40
};
41
-TRANS_FEAT(NMATCH, aa64_sve2, do_ppzz_flags, a, nmatch_fns[a->esz])
42
+TRANS_FEAT_NONSTREAMING(NMATCH, aa64_sve2, do_ppzz_flags, a, nmatch_fns[a->esz])
43
44
static gen_helper_gvec_4 * const histcnt_fns[4] = {
45
NULL, NULL, gen_helper_sve2_histcnt_s, gen_helper_sve2_histcnt_d
46
};
47
-TRANS_FEAT(HISTCNT, aa64_sve2, gen_gvec_ool_arg_zpzz,
48
- histcnt_fns[a->esz], a, 0)
49
+TRANS_FEAT_NONSTREAMING(HISTCNT, aa64_sve2, gen_gvec_ool_arg_zpzz,
50
+ histcnt_fns[a->esz], a, 0)
51
52
-TRANS_FEAT(HISTSEG, aa64_sve2, gen_gvec_ool_arg_zzz,
53
- a->esz == 0 ? gen_helper_sve2_histseg : NULL, a, 0)
54
+TRANS_FEAT_NONSTREAMING(HISTSEG, aa64_sve2, gen_gvec_ool_arg_zzz,
55
+ a->esz == 0 ? gen_helper_sve2_histseg : NULL, a, 0)
56
57
DO_ZPZZ_FP(FADDP, aa64_sve2, sve2_faddp_zpzz)
58
DO_ZPZZ_FP(FMAXNMP, aa64_sve2, sve2_fmaxnmp_zpzz)
59
@@ -XXX,XX +XXX,XX @@ TRANS_FEAT(SQRDCMLAH_zzzz, aa64_sve2, gen_gvec_ool_zzzz,
60
TRANS_FEAT(USDOT_zzzz, aa64_sve_i8mm, gen_gvec_ool_arg_zzzz,
61
a->esz == 2 ? gen_helper_gvec_usdot_b : NULL, a, 0)
62
63
-TRANS_FEAT(AESMC, aa64_sve2_aes, gen_gvec_ool_zz,
64
- gen_helper_crypto_aesmc, a->rd, a->rd, a->decrypt)
65
+TRANS_FEAT_NONSTREAMING(AESMC, aa64_sve2_aes, gen_gvec_ool_zz,
66
+ gen_helper_crypto_aesmc, a->rd, a->rd, a->decrypt)
67
68
-TRANS_FEAT(AESE, aa64_sve2_aes, gen_gvec_ool_arg_zzz,
69
- gen_helper_crypto_aese, a, false)
70
-TRANS_FEAT(AESD, aa64_sve2_aes, gen_gvec_ool_arg_zzz,
71
- gen_helper_crypto_aese, a, true)
72
+TRANS_FEAT_NONSTREAMING(AESE, aa64_sve2_aes, gen_gvec_ool_arg_zzz,
73
+ gen_helper_crypto_aese, a, false)
74
+TRANS_FEAT_NONSTREAMING(AESD, aa64_sve2_aes, gen_gvec_ool_arg_zzz,
75
+ gen_helper_crypto_aese, a, true)
76
77
-TRANS_FEAT(SM4E, aa64_sve2_sm4, gen_gvec_ool_arg_zzz,
78
- gen_helper_crypto_sm4e, a, 0)
79
-TRANS_FEAT(SM4EKEY, aa64_sve2_sm4, gen_gvec_ool_arg_zzz,
80
- gen_helper_crypto_sm4ekey, a, 0)
81
+TRANS_FEAT_NONSTREAMING(SM4E, aa64_sve2_sm4, gen_gvec_ool_arg_zzz,
82
+ gen_helper_crypto_sm4e, a, 0)
83
+TRANS_FEAT_NONSTREAMING(SM4EKEY, aa64_sve2_sm4, gen_gvec_ool_arg_zzz,
84
+ gen_helper_crypto_sm4ekey, a, 0)
85
86
-TRANS_FEAT(RAX1, aa64_sve2_sha3, gen_gvec_fn_arg_zzz, gen_gvec_rax1, a)
87
+TRANS_FEAT_NONSTREAMING(RAX1, aa64_sve2_sha3, gen_gvec_fn_arg_zzz,
88
+ gen_gvec_rax1, a)
89
90
TRANS_FEAT(FCVTNT_sh, aa64_sve2, gen_gvec_fpst_arg_zpz,
91
gen_helper_sve2_fcvtnt_sh, a, 0, FPST_FPCR)
46
--
92
--
47
2.25.1
93
2.25.1
48
49
diff view generated by jsdifflib
1
In process_cmdq(), we read 64 bits of the command packet, which
1
From: Richard Henderson <richard.henderson@linaro.org>
2
contain the command identifier, which we then switch() on to dispatch
3
to an appropriate sub-function. However, if address_space_ldq_le()
4
reports a memory transaction failure, we still read the command
5
identifier out of the data and switch() on it. Restructure the code
6
so that we stop immediately (stalling the command queue) in this
7
case.
8
2
3
Mark these as a non-streaming instructions, which should trap
4
if full a64 support is not enabled in streaming mode.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-12-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20220111171048.3545974-5-peter.maydell@linaro.org
13
---
10
---
14
hw/intc/arm_gicv3_its.c | 7 ++++++-
11
target/arm/sme-fa64.decode | 9 ---------
15
1 file changed, 6 insertions(+), 1 deletion(-)
12
target/arm/translate-sve.c | 6 ++++++
13
2 files changed, 6 insertions(+), 9 deletions(-)
16
14
17
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
15
diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/intc/arm_gicv3_its.c
17
--- a/target/arm/sme-fa64.decode
20
+++ b/hw/intc/arm_gicv3_its.c
18
+++ b/target/arm/sme-fa64.decode
21
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
19
@@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS
22
data = address_space_ldq_le(as, s->cq.base_addr + cq_offset,
20
# --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset)
23
MEMTXATTRS_UNSPECIFIED, &res);
21
# --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm)
24
if (res != MEMTX_OK) {
22
25
- result = false;
23
-FAIL 1000 010- -00- ---- 10-- ---- ---- ---- # SVE2 32-bit gather NT load (vector+scalar)
26
+ s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, STALLED, 1);
24
FAIL 1000 010- -00- ---- 111- ---- ---- ---- # SVE 32-bit gather prefetch (vector+imm)
27
+ qemu_log_mask(LOG_GUEST_ERROR,
25
FAIL 1000 0100 0-1- ---- 0--- ---- ---- ---- # SVE 32-bit gather prefetch (scalar+vector)
28
+ "%s: could not read command at 0x%" PRIx64 "\n",
26
-FAIL 1000 010- -01- ---- 1--- ---- ---- ---- # SVE 32-bit gather load (vector+imm)
29
+ __func__, s->cq.base_addr + cq_offset);
27
-FAIL 1000 0100 0-0- ---- 0--- ---- ---- ---- # SVE 32-bit gather load byte (scalar+vector)
30
+ break;
28
-FAIL 1000 0100 1--- ---- 0--- ---- ---- ---- # SVE 32-bit gather load half (scalar+vector)
31
}
29
-FAIL 1000 0101 0--- ---- 0--- ---- ---- ---- # SVE 32-bit gather load word (scalar+vector)
32
+
30
FAIL 1010 010- ---- ---- 011- ---- ---- ---- # SVE contiguous FF load (scalar+scalar)
33
cmd = (data & CMD_MASK);
31
FAIL 1010 010- ---1 ---- 101- ---- ---- ---- # SVE contiguous NF load (scalar+imm)
34
32
FAIL 1010 010- -01- ---- 000- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+scalar)
35
switch (cmd) {
33
FAIL 1010 010- -010 ---- 001- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+imm)
34
FAIL 1100 010- ---- ---- ---- ---- ---- ---- # SVE 64-bit gather load/prefetch
35
-FAIL 1110 010- -00- ---- 001- ---- ---- ---- # SVE2 64-bit scatter NT store (vector+scalar)
36
-FAIL 1110 010- -10- ---- 001- ---- ---- ---- # SVE2 32-bit scatter NT store (vector+scalar)
37
-FAIL 1110 010- ---- ---- 1-0- ---- ---- ---- # SVE scatter store (scalar+32-bit vector)
38
-FAIL 1110 010- ---- ---- 101- ---- ---- ---- # SVE scatter store (misc)
39
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/translate-sve.c
42
+++ b/target/arm/translate-sve.c
43
@@ -XXX,XX +XXX,XX @@ static bool trans_LD1_zprz(DisasContext *s, arg_LD1_zprz *a)
44
if (!dc_isar_feature(aa64_sve, s)) {
45
return false;
46
}
47
+ s->is_nonstreaming = true;
48
if (!sve_access_check(s)) {
49
return true;
50
}
51
@@ -XXX,XX +XXX,XX @@ static bool trans_LD1_zpiz(DisasContext *s, arg_LD1_zpiz *a)
52
if (!dc_isar_feature(aa64_sve, s)) {
53
return false;
54
}
55
+ s->is_nonstreaming = true;
56
if (!sve_access_check(s)) {
57
return true;
58
}
59
@@ -XXX,XX +XXX,XX @@ static bool trans_LDNT1_zprz(DisasContext *s, arg_LD1_zprz *a)
60
if (!dc_isar_feature(aa64_sve2, s)) {
61
return false;
62
}
63
+ s->is_nonstreaming = true;
64
if (!sve_access_check(s)) {
65
return true;
66
}
67
@@ -XXX,XX +XXX,XX @@ static bool trans_ST1_zprz(DisasContext *s, arg_ST1_zprz *a)
68
if (!dc_isar_feature(aa64_sve, s)) {
69
return false;
70
}
71
+ s->is_nonstreaming = true;
72
if (!sve_access_check(s)) {
73
return true;
74
}
75
@@ -XXX,XX +XXX,XX @@ static bool trans_ST1_zpiz(DisasContext *s, arg_ST1_zpiz *a)
76
if (!dc_isar_feature(aa64_sve, s)) {
77
return false;
78
}
79
+ s->is_nonstreaming = true;
80
if (!sve_access_check(s)) {
81
return true;
82
}
83
@@ -XXX,XX +XXX,XX @@ static bool trans_STNT1_zprz(DisasContext *s, arg_ST1_zprz *a)
84
if (!dc_isar_feature(aa64_sve2, s)) {
85
return false;
86
}
87
+ s->is_nonstreaming = true;
88
if (!sve_access_check(s)) {
89
return true;
90
}
36
--
91
--
37
2.25.1
92
2.25.1
38
39
diff view generated by jsdifflib
1
Fix process_mapc() to consistently return CMD_STALL for memory
1
From: Richard Henderson <richard.henderson@linaro.org>
2
errors and CMD_CONTINUE for parameter errors, as we claim in the
3
comments that we do.
4
2
3
Mark these as a non-streaming instructions, which should trap if full
4
a64 support is not enabled in streaming mode. In this case, introduce
5
PRF_ns (prefetch non-streaming) to handle the checks.
6
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220708151540.18136-13-richard.henderson@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-10-peter.maydell@linaro.org
9
---
11
---
10
hw/intc/arm_gicv3_its.c | 8 +++-----
12
target/arm/sme-fa64.decode | 3 ---
11
1 file changed, 3 insertions(+), 5 deletions(-)
13
target/arm/sve.decode | 10 +++++-----
14
target/arm/translate-sve.c | 11 +++++++++++
15
3 files changed, 16 insertions(+), 8 deletions(-)
12
16
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
17
diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode
14
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
19
--- a/target/arm/sme-fa64.decode
16
+++ b/hw/intc/arm_gicv3_its.c
20
+++ b/target/arm/sme-fa64.decode
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
21
@@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS
18
uint64_t rdbase;
22
# --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset)
19
bool valid;
23
# --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm)
20
MemTxResult res = MEMTX_OK;
24
21
- ItsCmdResult result = CMD_STALL;
25
-FAIL 1000 010- -00- ---- 111- ---- ---- ---- # SVE 32-bit gather prefetch (vector+imm)
22
uint64_t value;
26
-FAIL 1000 0100 0-1- ---- 0--- ---- ---- ---- # SVE 32-bit gather prefetch (scalar+vector)
23
27
FAIL 1010 010- ---- ---- 011- ---- ---- ---- # SVE contiguous FF load (scalar+scalar)
24
offset += NUM_BYTES_IN_DW;
28
FAIL 1010 010- ---1 ---- 101- ---- ---- ---- # SVE contiguous NF load (scalar+imm)
25
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
29
FAIL 1010 010- -01- ---- 000- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+scalar)
26
MEMTXATTRS_UNSPECIFIED, &res);
30
FAIL 1010 010- -010 ---- 001- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+imm)
27
31
-FAIL 1100 010- ---- ---- ---- ---- ---- ---- # SVE 64-bit gather load/prefetch
28
if (res != MEMTX_OK) {
32
diff --git a/target/arm/sve.decode b/target/arm/sve.decode
29
- return result;
33
index XXXXXXX..XXXXXXX 100644
30
+ return CMD_STALL;
34
--- a/target/arm/sve.decode
31
}
35
+++ b/target/arm/sve.decode
32
36
@@ -XXX,XX +XXX,XX @@ LD1RO_zpri 1010010 .. 01 0.... 001 ... ..... ..... \
33
icid = value & ICID_MASK;
37
@rpri_load_msz nreg=0
34
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
38
35
* we ignore this command and move onto the next
39
# SVE 32-bit gather prefetch (scalar plus 32-bit scaled offsets)
36
* command in the queue
40
-PRF 1000010 00 -1 ----- 0-- --- ----- 0 ----
37
*/
41
+PRF_ns 1000010 00 -1 ----- 0-- --- ----- 0 ----
38
- } else {
42
39
- result = update_cte(s, icid, valid, rdbase) ? CMD_CONTINUE : CMD_STALL;
43
# SVE 32-bit gather prefetch (vector plus immediate)
40
+ return CMD_CONTINUE;
44
-PRF 1000010 -- 00 ----- 111 --- ----- 0 ----
41
}
45
+PRF_ns 1000010 -- 00 ----- 111 --- ----- 0 ----
42
46
43
- return result;
47
# SVE contiguous prefetch (scalar plus immediate)
44
+ return update_cte(s, icid, valid, rdbase) ? CMD_CONTINUE : CMD_STALL;
48
PRF 1000010 11 1- ----- 0-- --- ----- 0 ----
49
@@ -XXX,XX +XXX,XX @@ LD1_zpiz 1100010 .. 01 ..... 1.. ... ..... ..... \
50
@rpri_g_load esz=3
51
52
# SVE 64-bit gather prefetch (scalar plus 64-bit scaled offsets)
53
-PRF 1100010 00 11 ----- 1-- --- ----- 0 ----
54
+PRF_ns 1100010 00 11 ----- 1-- --- ----- 0 ----
55
56
# SVE 64-bit gather prefetch (scalar plus unpacked 32-bit scaled offsets)
57
-PRF 1100010 00 -1 ----- 0-- --- ----- 0 ----
58
+PRF_ns 1100010 00 -1 ----- 0-- --- ----- 0 ----
59
60
# SVE 64-bit gather prefetch (vector plus immediate)
61
-PRF 1100010 -- 00 ----- 111 --- ----- 0 ----
62
+PRF_ns 1100010 -- 00 ----- 111 --- ----- 0 ----
63
64
### SVE Memory Store Group
65
66
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
67
index XXXXXXX..XXXXXXX 100644
68
--- a/target/arm/translate-sve.c
69
+++ b/target/arm/translate-sve.c
70
@@ -XXX,XX +XXX,XX @@ static bool trans_PRF_rr(DisasContext *s, arg_PRF_rr *a)
71
return true;
45
}
72
}
46
73
47
static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
74
+static bool trans_PRF_ns(DisasContext *s, arg_PRF_ns *a)
75
+{
76
+ if (!dc_isar_feature(aa64_sve, s)) {
77
+ return false;
78
+ }
79
+ /* Prefetch is a nop within QEMU. */
80
+ s->is_nonstreaming = true;
81
+ (void)sve_access_check(s);
82
+ return true;
83
+}
84
+
85
/*
86
* Move Prefix
87
*
48
--
88
--
49
2.25.1
89
2.25.1
50
51
diff view generated by jsdifflib
1
process_its_cmd() returns a bool, like all the other process_ functions.
1
From: Richard Henderson <richard.henderson@linaro.org>
2
However we were putting its return value into 'res', not 'result',
3
which meant we would ignore it when deciding whether to continue
4
or stall the command queue. Fix the typo.
5
2
3
Mark these as a non-streaming instructions, which should trap
4
if full a64 support is not enabled in streaming mode.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-14-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Message-id: 20220111171048.3545974-4-peter.maydell@linaro.org
11
---
10
---
12
hw/intc/arm_gicv3_its.c | 4 ++--
11
target/arm/sme-fa64.decode | 2 --
13
1 file changed, 2 insertions(+), 2 deletions(-)
12
target/arm/translate-sve.c | 2 ++
13
2 files changed, 2 insertions(+), 2 deletions(-)
14
14
15
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
15
diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/arm_gicv3_its.c
17
--- a/target/arm/sme-fa64.decode
18
+++ b/hw/intc/arm_gicv3_its.c
18
+++ b/target/arm/sme-fa64.decode
19
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
19
@@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS
20
20
# --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset)
21
switch (cmd) {
21
# --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm)
22
case GITS_CMD_INT:
22
23
- res = process_its_cmd(s, data, cq_offset, INTERRUPT);
23
-FAIL 1010 010- ---- ---- 011- ---- ---- ---- # SVE contiguous FF load (scalar+scalar)
24
+ result = process_its_cmd(s, data, cq_offset, INTERRUPT);
24
-FAIL 1010 010- ---1 ---- 101- ---- ---- ---- # SVE contiguous NF load (scalar+imm)
25
break;
25
FAIL 1010 010- -01- ---- 000- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+scalar)
26
case GITS_CMD_CLEAR:
26
FAIL 1010 010- -010 ---- 001- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+imm)
27
- res = process_its_cmd(s, data, cq_offset, CLEAR);
27
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
28
+ result = process_its_cmd(s, data, cq_offset, CLEAR);
28
index XXXXXXX..XXXXXXX 100644
29
break;
29
--- a/target/arm/translate-sve.c
30
case GITS_CMD_SYNC:
30
+++ b/target/arm/translate-sve.c
31
/*
31
@@ -XXX,XX +XXX,XX @@ static bool trans_LDFF1_zprr(DisasContext *s, arg_rprr_load *a)
32
if (!dc_isar_feature(aa64_sve, s)) {
33
return false;
34
}
35
+ s->is_nonstreaming = true;
36
if (sve_access_check(s)) {
37
TCGv_i64 addr = new_tmp_a64(s);
38
tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), dtype_msz(a->dtype));
39
@@ -XXX,XX +XXX,XX @@ static bool trans_LDNF1_zpri(DisasContext *s, arg_rpri_load *a)
40
if (!dc_isar_feature(aa64_sve, s)) {
41
return false;
42
}
43
+ s->is_nonstreaming = true;
44
if (sve_access_check(s)) {
45
int vsz = vec_full_reg_size(s);
46
int elements = vsz >> dtype_esz[a->dtype];
32
--
47
--
33
2.25.1
48
2.25.1
34
35
diff view generated by jsdifflib
1
The bounds check on the number of interrupt IDs is correct, but
1
From: Richard Henderson <richard.henderson@linaro.org>
2
doesn't match our convention; change the variable name, initialize it
3
to the 2^n value rather than (2^n)-1, and use >= instead of > in the
4
comparison.
5
2
3
Mark these as a non-streaming instructions, which should trap
4
if full a64 support is not enabled in streaming mode.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-15-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Message-id: 20220111171048.3545974-3-peter.maydell@linaro.org
9
---
10
---
10
hw/intc/arm_gicv3_its.c | 6 +++---
11
target/arm/sme-fa64.decode | 3 ---
11
1 file changed, 3 insertions(+), 3 deletions(-)
12
target/arm/translate-sve.c | 2 ++
13
2 files changed, 2 insertions(+), 3 deletions(-)
12
14
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
15
diff --git a/target/arm/sme-fa64.decode b/target/arm/sme-fa64.decode
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
17
--- a/target/arm/sme-fa64.decode
16
+++ b/hw/intc/arm_gicv3_its.c
18
+++ b/target/arm/sme-fa64.decode
17
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
19
@@ -XXX,XX +XXX,XX @@ FAIL 0001 1110 0111 1110 0000 00-- ---- ---- # FJCVTZS
18
uint32_t devid, eventid;
20
# --11 1100 --0- ---- ---- ---- ---- ---- # Load/store FP register (unscaled imm)
19
uint32_t pIntid = 0;
21
# --11 1100 --1- ---- ---- ---- ---- --10 # Load/store FP register (register offset)
20
uint64_t num_eventids;
22
# --11 1101 ---- ---- ---- ---- ---- ---- # Load/store FP register (scaled imm)
21
- uint32_t max_Intid;
23
-
22
+ uint32_t num_intids;
24
-FAIL 1010 010- -01- ---- 000- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+scalar)
23
bool dte_valid;
25
-FAIL 1010 010- -010 ---- 001- ---- ---- ---- # SVE load & replicate 32 bytes (scalar+imm)
24
MemTxResult res = MEMTX_OK;
26
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
25
uint16_t icid = 0;
27
index XXXXXXX..XXXXXXX 100644
26
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
28
--- a/target/arm/translate-sve.c
29
+++ b/target/arm/translate-sve.c
30
@@ -XXX,XX +XXX,XX @@ static bool trans_LD1RO_zprr(DisasContext *s, arg_rprr_load *a)
31
if (a->rm == 31) {
32
return false;
27
}
33
}
28
dte_valid = FIELD_EX64(dte, DTE, VALID);
34
+ s->is_nonstreaming = true;
29
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
35
if (sve_access_check(s)) {
30
- max_Intid = (1ULL << (GICD_TYPER_IDBITS + 1)) - 1;
36
TCGv_i64 addr = new_tmp_a64(s);
31
+ num_intids = 1ULL << (GICD_TYPER_IDBITS + 1);
37
tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), dtype_msz(a->dtype));
32
38
@@ -XXX,XX +XXX,XX @@ static bool trans_LD1RO_zpri(DisasContext *s, arg_rpri_load *a)
33
if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids)
39
if (!dc_isar_feature(aa64_sve_f64mm, s)) {
34
|| !dte_valid || (eventid >= num_eventids) ||
40
return false;
35
- (((pIntid < GICV3_LPI_INTID_START) || (pIntid > max_Intid)) &&
41
}
36
+ (((pIntid < GICV3_LPI_INTID_START) || (pIntid >= num_intids)) &&
42
+ s->is_nonstreaming = true;
37
(pIntid != INTID_SPURIOUS))) {
43
if (sve_access_check(s)) {
38
qemu_log_mask(LOG_GUEST_ERROR,
44
TCGv_i64 addr = new_tmp_a64(s);
39
"%s: invalid command attributes "
45
tcg_gen_addi_i64(addr, cpu_reg_sp(s, a->rn), a->imm * 32);
40
--
46
--
41
2.25.1
47
2.25.1
42
43
diff view generated by jsdifflib
1
From: Gavin Shan <gshan@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
The default block size is same as to the THP size, which is either
3
These functions will be used to verify that the cpu
4
retrieved from "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size"
4
is in the correct state for a given instruction.
5
or hardcoded to 2MB. There are flaws in both mechanisms and this
6
intends to fix them up.
7
5
8
* When "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size" is
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
used to getting the THP size, 32MB and 512MB are valid values
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
when we have 16KB and 64KB page size on ARM64.
8
Message-id: 20220708151540.18136-16-richard.henderson@linaro.org
11
12
* When the hardcoded THP size is used, 2MB, 32MB and 512MB are
13
valid values when we have 4KB, 16KB and 64KB page sizes on
14
ARM64.
15
16
Co-developed-by: David Hildenbrand <david@redhat.com>
17
Signed-off-by: Gavin Shan <gshan@redhat.com>
18
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
19
Reviewed-by: David Hildenbrand <david@redhat.com>
20
Message-id: 20220111063329.74447-2-gshan@redhat.com
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
10
---
23
hw/virtio/virtio-mem.c | 32 ++++++++++++++++++++------------
11
target/arm/translate-a64.h | 21 +++++++++++++++++++++
24
1 file changed, 20 insertions(+), 12 deletions(-)
12
target/arm/translate-a64.c | 34 ++++++++++++++++++++++++++++++++++
13
2 files changed, 55 insertions(+)
25
14
26
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
15
diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h
27
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/virtio/virtio-mem.c
17
--- a/target/arm/translate-a64.h
29
+++ b/hw/virtio/virtio-mem.c
18
+++ b/target/arm/translate-a64.h
30
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ void write_fp_dreg(DisasContext *s, int reg, TCGv_i64 v);
31
*/
20
bool logic_imm_decode_wmask(uint64_t *result, unsigned int immn,
32
#define VIRTIO_MEM_MIN_BLOCK_SIZE ((uint32_t)(1 * MiB))
21
unsigned int imms, unsigned int immr);
33
22
bool sve_access_check(DisasContext *s);
34
-#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
23
+bool sme_enabled_check(DisasContext *s);
35
- defined(__powerpc64__)
24
+bool sme_enabled_check_with_svcr(DisasContext *s, unsigned);
36
-#define VIRTIO_MEM_DEFAULT_THP_SIZE ((uint32_t)(2 * MiB))
25
+
37
-#else
26
+/* This function corresponds to CheckStreamingSVEEnabled. */
38
- /* fallback to 1 MiB (e.g., the THP size on s390x) */
27
+static inline bool sme_sm_enabled_check(DisasContext *s)
39
-#define VIRTIO_MEM_DEFAULT_THP_SIZE VIRTIO_MEM_MIN_BLOCK_SIZE
40
+static uint32_t virtio_mem_default_thp_size(void)
41
+{
28
+{
42
+ uint32_t default_thp_size = VIRTIO_MEM_MIN_BLOCK_SIZE;
29
+ return sme_enabled_check_with_svcr(s, R_SVCR_SM_MASK);
30
+}
43
+
31
+
44
+#if defined(__x86_64__) || defined(__arm__) || defined(__powerpc64__)
32
+/* This function corresponds to CheckSMEAndZAEnabled. */
45
+ default_thp_size = 2 * MiB;
33
+static inline bool sme_za_enabled_check(DisasContext *s)
46
+#elif defined(__aarch64__)
34
+{
47
+ if (qemu_real_host_page_size == 4 * KiB) {
35
+ return sme_enabled_check_with_svcr(s, R_SVCR_ZA_MASK);
48
+ default_thp_size = 2 * MiB;
36
+}
49
+ } else if (qemu_real_host_page_size == 16 * KiB) {
37
+
50
+ default_thp_size = 32 * MiB;
38
+/* Note that this function corresponds to CheckStreamingSVEAndZAEnabled. */
51
+ } else if (qemu_real_host_page_size == 64 * KiB) {
39
+static inline bool sme_smza_enabled_check(DisasContext *s)
52
+ default_thp_size = 512 * MiB;
40
+{
41
+ return sme_enabled_check_with_svcr(s, R_SVCR_SM_MASK | R_SVCR_ZA_MASK);
42
+}
43
+
44
TCGv_i64 clean_data_tbi(DisasContext *s, TCGv_i64 addr);
45
TCGv_i64 gen_mte_check1(DisasContext *s, TCGv_i64 addr, bool is_write,
46
bool tag_checked, int log2_size);
47
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/translate-a64.c
50
+++ b/target/arm/translate-a64.c
51
@@ -XXX,XX +XXX,XX @@ static bool sme_access_check(DisasContext *s)
52
return true;
53
}
54
55
+/* This function corresponds to CheckSMEEnabled. */
56
+bool sme_enabled_check(DisasContext *s)
57
+{
58
+ /*
59
+ * Note that unlike sve_excp_el, we have not constrained sme_excp_el
60
+ * to be zero when fp_excp_el has priority. This is because we need
61
+ * sme_excp_el by itself for cpregs access checks.
62
+ */
63
+ if (!s->fp_excp_el || s->sme_excp_el < s->fp_excp_el) {
64
+ s->fp_access_checked = true;
65
+ return sme_access_check(s);
53
+ }
66
+ }
54
#endif
67
+ return fp_access_check_only(s);
55
68
+}
56
+ return default_thp_size;
69
+
70
+/* Common subroutine for CheckSMEAnd*Enabled. */
71
+bool sme_enabled_check_with_svcr(DisasContext *s, unsigned req)
72
+{
73
+ if (!sme_enabled_check(s)) {
74
+ return false;
75
+ }
76
+ if (FIELD_EX64(req, SVCR, SM) && !s->pstate_sm) {
77
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
78
+ syn_smetrap(SME_ET_NotStreaming, false));
79
+ return false;
80
+ }
81
+ if (FIELD_EX64(req, SVCR, ZA) && !s->pstate_za) {
82
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
83
+ syn_smetrap(SME_ET_InactiveZA, false));
84
+ return false;
85
+ }
86
+ return true;
57
+}
87
+}
58
+
88
+
59
/*
89
/*
60
* We want to have a reasonable default block size such that
90
* This utility function is for doing register extension with an
61
* 1. We avoid splitting THPs when unplugging memory, which degrades
91
* optional shift. You will likely want to pass a temporary for the
62
@@ -XXX,XX +XXX,XX @@ static uint32_t virtio_mem_thp_size(void)
63
if (g_file_get_contents(HPAGE_PMD_SIZE_PATH, &content, NULL, NULL) &&
64
!qemu_strtou64(content, &endptr, 0, &tmp) &&
65
(!endptr || *endptr == '\n')) {
66
- /*
67
- * Sanity-check the value, if it's too big (e.g., aarch64 with 64k base
68
- * pages) or weird, fallback to something smaller.
69
- */
70
- if (!tmp || !is_power_of_2(tmp) || tmp > 16 * MiB) {
71
+ /* Sanity-check the value and fallback to something reasonable. */
72
+ if (!tmp || !is_power_of_2(tmp)) {
73
warn_report("Read unsupported THP size: %" PRIx64, tmp);
74
} else {
75
thp_size = tmp;
76
@@ -XXX,XX +XXX,XX @@ static uint32_t virtio_mem_thp_size(void)
77
}
78
79
if (!thp_size) {
80
- thp_size = VIRTIO_MEM_DEFAULT_THP_SIZE;
81
+ thp_size = virtio_mem_default_thp_size();
82
warn_report("Could not detect THP size, falling back to %" PRIx64
83
" MiB.", thp_size / MiB);
84
}
85
--
92
--
86
2.25.1
93
2.25.1
87
88
diff view generated by jsdifflib
1
Fix process_mapd() to consistently return CMD_STALL for memory
1
From: Richard Henderson <richard.henderson@linaro.org>
2
errors and CMD_CONTINUE for parameter errors, as we claim in the
3
comments that we do.
4
2
3
The pseudocode for CheckSVEEnabled gains a check for Streaming
4
SVE mode, and for SME present but SVE absent.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-17-richard.henderson@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-11-peter.maydell@linaro.org
9
---
10
---
10
hw/intc/arm_gicv3_its.c | 10 ++++------
11
target/arm/translate-a64.c | 22 ++++++++++++++++------
11
1 file changed, 4 insertions(+), 6 deletions(-)
12
1 file changed, 16 insertions(+), 6 deletions(-)
12
13
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
14
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
16
--- a/target/arm/translate-a64.c
16
+++ b/hw/intc/arm_gicv3_its.c
17
+++ b/target/arm/translate-a64.c
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
18
@@ -XXX,XX +XXX,XX @@ static bool fp_access_check(DisasContext *s)
18
uint64_t itt_addr;
19
return true;
19
bool valid;
20
}
20
MemTxResult res = MEMTX_OK;
21
21
- ItsCmdResult result = CMD_STALL;
22
-/* Check that SVE access is enabled. If it is, return true.
22
23
+/*
23
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
24
+ * Check that SVE access is enabled. If it is, return true.
24
25
* If not, emit code to generate an appropriate exception and return false.
25
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
26
+ * This function corresponds to CheckSVEEnabled().
26
MEMTXATTRS_UNSPECIFIED, &res);
27
*/
27
28
bool sve_access_check(DisasContext *s)
28
if (res != MEMTX_OK) {
29
{
29
- return result;
30
- if (s->sve_excp_el) {
30
+ return CMD_STALL;
31
- assert(!s->sve_access_checked);
32
- s->sve_access_checked = true;
33
-
34
+ if (s->pstate_sm || !dc_isar_feature(aa64_sve, s)) {
35
+ assert(dc_isar_feature(aa64_sme, s));
36
+ if (!sme_sm_enabled_check(s)) {
37
+ goto fail_exit;
38
+ }
39
+ } else if (s->sve_excp_el) {
40
gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
41
syn_sve_access_trap(), s->sve_excp_el);
42
- return false;
43
+ goto fail_exit;
31
}
44
}
32
45
s->sve_access_checked = true;
33
size = (value & SIZE_MASK);
46
return fp_access_check(s);
34
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
47
+
35
MEMTXATTRS_UNSPECIFIED, &res);
48
+ fail_exit:
36
49
+ /* Assert that we only raise one exception per instruction. */
37
if (res != MEMTX_OK) {
50
+ assert(!s->sve_access_checked);
38
- return result;
51
+ s->sve_access_checked = true;
39
+ return CMD_STALL;
52
+ return false;
40
}
41
42
itt_addr = (value & ITTADDR_MASK) >> ITTADDR_SHIFT;
43
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
44
* we ignore this command and move onto the next
45
* command in the queue
46
*/
47
- } else {
48
- result = update_dte(s, devid, valid, size, itt_addr) ? CMD_CONTINUE : CMD_STALL;
49
+ return CMD_CONTINUE;
50
}
51
52
- return result;
53
+ return update_dte(s, devid, valid, size, itt_addr) ? CMD_CONTINUE : CMD_STALL;
54
}
53
}
55
54
56
/*
55
/*
57
--
56
--
58
2.25.1
57
2.25.1
59
60
diff view generated by jsdifflib
1
The ITS has several tables which all share a similar format,
1
From: Richard Henderson <richard.henderson@linaro.org>
2
described by the TableDesc struct: the guest may configure them
3
to be a single-level table or a two-level table. Currently we
4
open-code the process of finding the table entry in all the
5
functions which read or write the device table or the collection
6
table. Factor out the "get the address of the table entry"
7
logic into a new function, so that the code which needs to
8
read or write a table entry only needs to call table_entry_addr()
9
and then perform a suitable load or store to that address.
10
2
11
Note that the error handling is slightly complicated because
3
These SME instructions are nominally within the SVE decode space,
12
we want to handle two cases differently:
4
so we add them to sve.decode and translate-sve.c.
13
* failure to read the L1 table entry should end up causing
14
a command stall, like other kinds of DMA error
15
* an L1 table entry that says there is no L2 table for this
16
index (ie whose valid bit is 0) must result in us treating
17
the table entry as not-valid on read, and discarding
18
writes (this is mandated by the spec)
19
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-18-richard.henderson@linaro.org
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
22
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
23
Message-id: 20220111171048.3545974-12-peter.maydell@linaro.org
24
---
10
---
25
hw/intc/arm_gicv3_its.c | 212 +++++++++++++---------------------------
11
target/arm/translate-a64.h | 12 ++++++++++++
26
1 file changed, 70 insertions(+), 142 deletions(-)
12
target/arm/sve.decode | 5 ++++-
13
target/arm/translate-sve.c | 38 ++++++++++++++++++++++++++++++++++++++
14
3 files changed, 54 insertions(+), 1 deletion(-)
27
15
28
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
16
diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h
29
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/intc/arm_gicv3_its.c
18
--- a/target/arm/translate-a64.h
31
+++ b/hw/intc/arm_gicv3_its.c
19
+++ b/target/arm/translate-a64.h
32
@@ -XXX,XX +XXX,XX @@ static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz)
20
@@ -XXX,XX +XXX,XX @@ static inline int vec_full_reg_size(DisasContext *s)
33
return result;
21
return s->vl;
34
}
22
}
35
23
36
+static uint64_t table_entry_addr(GICv3ITSState *s, TableDesc *td,
24
+/* Return the byte size of the vector register, SVL / 8. */
37
+ uint32_t idx, MemTxResult *res)
25
+static inline int streaming_vec_reg_size(DisasContext *s)
38
+{
26
+{
39
+ /*
27
+ return s->svl;
40
+ * Given a TableDesc describing one of the ITS in-guest-memory
41
+ * tables and an index into it, return the guest address
42
+ * corresponding to that table entry.
43
+ * If there was a memory error reading the L1 table of an
44
+ * indirect table, *res is set accordingly, and we return -1.
45
+ * If the L1 table entry is marked not valid, we return -1 with
46
+ * *res set to MEMTX_OK.
47
+ *
48
+ * The specification defines the format of level 1 entries of a
49
+ * 2-level table, but the format of level 2 entries and the format
50
+ * of flat-mapped tables is IMPDEF.
51
+ */
52
+ AddressSpace *as = &s->gicv3->dma_as;
53
+ uint32_t l2idx;
54
+ uint64_t l2;
55
+ uint32_t num_l2_entries;
56
+
57
+ *res = MEMTX_OK;
58
+
59
+ if (!td->indirect) {
60
+ /* Single level table */
61
+ return td->base_addr + idx * td->entry_sz;
62
+ }
63
+
64
+ /* Two level table */
65
+ l2idx = idx / (td->page_sz / L1TABLE_ENTRY_SIZE);
66
+
67
+ l2 = address_space_ldq_le(as,
68
+ td->base_addr + (l2idx * L1TABLE_ENTRY_SIZE),
69
+ MEMTXATTRS_UNSPECIFIED, res);
70
+ if (*res != MEMTX_OK) {
71
+ return -1;
72
+ }
73
+ if (!(l2 & L2_TABLE_VALID_MASK)) {
74
+ return -1;
75
+ }
76
+
77
+ num_l2_entries = td->page_sz / td->entry_sz;
78
+ return (l2 & ((1ULL << 51) - 1)) + (idx % num_l2_entries) * td->entry_sz;
79
+}
28
+}
80
+
29
+
81
static bool get_cte(GICv3ITSState *s, uint16_t icid, uint64_t *cte,
30
/*
82
MemTxResult *res)
31
* Return the offset info CPUARMState of the predicate vector register Pn.
32
* Note for this purpose, FFR is P16.
33
@@ -XXX,XX +XXX,XX @@ static inline int pred_full_reg_size(DisasContext *s)
34
return s->vl >> 3;
35
}
36
37
+/* Return the byte size of the predicate register, SVL / 64. */
38
+static inline int streaming_pred_reg_size(DisasContext *s)
39
+{
40
+ return s->svl >> 3;
41
+}
42
+
43
/*
44
* Round up the size of a register to a size allowed by
45
* the tcg vector infrastructure. Any operation which uses this
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 @@ INDEX_ri 00000100 esz:2 1 imm:s5 010001 rn:5 rd:5
51
# SVE index generation (register start, register increment)
52
INDEX_rr 00000100 .. 1 ..... 010011 ..... ..... @rd_rn_rm
53
54
-### SVE Stack Allocation Group
55
+### SVE / Streaming SVE Stack Allocation Group
56
57
# SVE stack frame adjustment
58
ADDVL 00000100 001 ..... 01010 ...... ..... @rd_rn_i6
59
+ADDSVL 00000100 001 ..... 01011 ...... ..... @rd_rn_i6
60
ADDPL 00000100 011 ..... 01010 ...... ..... @rd_rn_i6
61
+ADDSPL 00000100 011 ..... 01011 ...... ..... @rd_rn_i6
62
63
# SVE stack frame size
64
RDVL 00000100 101 11111 01010 imm:s6 rd:5
65
+RDSVL 00000100 101 11111 01011 imm:s6 rd:5
66
67
### SVE Bitwise Shift - Unpredicated Group
68
69
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/target/arm/translate-sve.c
72
+++ b/target/arm/translate-sve.c
73
@@ -XXX,XX +XXX,XX @@ static bool trans_ADDVL(DisasContext *s, arg_ADDVL *a)
74
return true;
75
}
76
77
+static bool trans_ADDSVL(DisasContext *s, arg_ADDSVL *a)
78
+{
79
+ if (!dc_isar_feature(aa64_sme, s)) {
80
+ return false;
81
+ }
82
+ if (sme_enabled_check(s)) {
83
+ TCGv_i64 rd = cpu_reg_sp(s, a->rd);
84
+ TCGv_i64 rn = cpu_reg_sp(s, a->rn);
85
+ tcg_gen_addi_i64(rd, rn, a->imm * streaming_vec_reg_size(s));
86
+ }
87
+ return true;
88
+}
89
+
90
static bool trans_ADDPL(DisasContext *s, arg_ADDPL *a)
83
{
91
{
84
AddressSpace *as = &s->gicv3->dma_as;
92
if (!dc_isar_feature(aa64_sve, s)) {
85
- uint64_t l2t_addr;
93
@@ -XXX,XX +XXX,XX @@ static bool trans_ADDPL(DisasContext *s, arg_ADDPL *a)
86
- uint64_t value;
94
return true;
87
- bool valid_l2t;
88
- uint32_t l2t_id;
89
- uint32_t num_l2_entries;
90
+ uint64_t entry_addr = table_entry_addr(s, &s->ct, icid, res);
91
92
- if (s->ct.indirect) {
93
- l2t_id = icid / (s->ct.page_sz / L1TABLE_ENTRY_SIZE);
94
-
95
- value = address_space_ldq_le(as,
96
- s->ct.base_addr +
97
- (l2t_id * L1TABLE_ENTRY_SIZE),
98
- MEMTXATTRS_UNSPECIFIED, res);
99
-
100
- if (*res == MEMTX_OK) {
101
- valid_l2t = (value & L2_TABLE_VALID_MASK) != 0;
102
-
103
- if (valid_l2t) {
104
- num_l2_entries = s->ct.page_sz / s->ct.entry_sz;
105
-
106
- l2t_addr = value & ((1ULL << 51) - 1);
107
-
108
- *cte = address_space_ldq_le(as, l2t_addr +
109
- ((icid % num_l2_entries) * GITS_CTE_SIZE),
110
- MEMTXATTRS_UNSPECIFIED, res);
111
- }
112
- }
113
- } else {
114
- /* Flat level table */
115
- *cte = address_space_ldq_le(as, s->ct.base_addr +
116
- (icid * GITS_CTE_SIZE),
117
- MEMTXATTRS_UNSPECIFIED, res);
118
+ if (entry_addr == -1) {
119
+ return false; /* not valid */
120
}
121
122
+ *cte = address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, res);
123
return FIELD_EX64(*cte, CTE, VALID);
124
}
95
}
125
96
126
@@ -XXX,XX +XXX,XX @@ static bool get_ite(GICv3ITSState *s, uint32_t eventid, uint64_t dte,
97
+static bool trans_ADDSPL(DisasContext *s, arg_ADDSPL *a)
127
static uint64_t get_dte(GICv3ITSState *s, uint32_t devid, MemTxResult *res)
98
+{
99
+ if (!dc_isar_feature(aa64_sme, s)) {
100
+ return false;
101
+ }
102
+ if (sme_enabled_check(s)) {
103
+ TCGv_i64 rd = cpu_reg_sp(s, a->rd);
104
+ TCGv_i64 rn = cpu_reg_sp(s, a->rn);
105
+ tcg_gen_addi_i64(rd, rn, a->imm * streaming_pred_reg_size(s));
106
+ }
107
+ return true;
108
+}
109
+
110
static bool trans_RDVL(DisasContext *s, arg_RDVL *a)
128
{
111
{
129
AddressSpace *as = &s->gicv3->dma_as;
112
if (!dc_isar_feature(aa64_sve, s)) {
130
- uint64_t l2t_addr;
113
@@ -XXX,XX +XXX,XX @@ static bool trans_RDVL(DisasContext *s, arg_RDVL *a)
131
- uint64_t value;
114
return true;
132
- bool valid_l2t;
133
- uint32_t l2t_id;
134
- uint32_t num_l2_entries;
135
+ uint64_t entry_addr = table_entry_addr(s, &s->dt, devid, res);
136
137
- if (s->dt.indirect) {
138
- l2t_id = devid / (s->dt.page_sz / L1TABLE_ENTRY_SIZE);
139
-
140
- value = address_space_ldq_le(as,
141
- s->dt.base_addr +
142
- (l2t_id * L1TABLE_ENTRY_SIZE),
143
- MEMTXATTRS_UNSPECIFIED, res);
144
-
145
- if (*res == MEMTX_OK) {
146
- valid_l2t = (value & L2_TABLE_VALID_MASK) != 0;
147
-
148
- if (valid_l2t) {
149
- num_l2_entries = s->dt.page_sz / s->dt.entry_sz;
150
-
151
- l2t_addr = value & ((1ULL << 51) - 1);
152
-
153
- value = address_space_ldq_le(as, l2t_addr +
154
- ((devid % num_l2_entries) * GITS_DTE_SIZE),
155
- MEMTXATTRS_UNSPECIFIED, res);
156
- }
157
- }
158
- } else {
159
- /* Flat level table */
160
- value = address_space_ldq_le(as, s->dt.base_addr +
161
- (devid * GITS_DTE_SIZE),
162
- MEMTXATTRS_UNSPECIFIED, res);
163
+ if (entry_addr == -1) {
164
+ return 0; /* a DTE entry with the Valid bit clear */
165
}
166
-
167
- return value;
168
+ return address_space_ldq_le(as, entry_addr, MEMTXATTRS_UNSPECIFIED, res);
169
}
115
}
170
116
117
+static bool trans_RDSVL(DisasContext *s, arg_RDSVL *a)
118
+{
119
+ if (!dc_isar_feature(aa64_sme, s)) {
120
+ return false;
121
+ }
122
+ if (sme_enabled_check(s)) {
123
+ TCGv_i64 reg = cpu_reg(s, a->rd);
124
+ tcg_gen_movi_i64(reg, a->imm * streaming_vec_reg_size(s));
125
+ }
126
+ return true;
127
+}
128
+
171
/*
129
/*
172
@@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
130
*** SVE Compute Vector Address Group
173
uint64_t rdbase)
131
*/
174
{
175
AddressSpace *as = &s->gicv3->dma_as;
176
- uint64_t value;
177
- uint64_t l2t_addr;
178
- bool valid_l2t;
179
- uint32_t l2t_id;
180
- uint32_t num_l2_entries;
181
+ uint64_t entry_addr;
182
uint64_t cte = 0;
183
MemTxResult res = MEMTX_OK;
184
185
@@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
186
cte = FIELD_DP64(cte, CTE, RDBASE, rdbase);
187
}
188
189
- /*
190
- * The specification defines the format of level 1 entries of a
191
- * 2-level table, but the format of level 2 entries and the format
192
- * of flat-mapped tables is IMPDEF.
193
- */
194
- if (s->ct.indirect) {
195
- l2t_id = icid / (s->ct.page_sz / L1TABLE_ENTRY_SIZE);
196
-
197
- value = address_space_ldq_le(as,
198
- s->ct.base_addr +
199
- (l2t_id * L1TABLE_ENTRY_SIZE),
200
- MEMTXATTRS_UNSPECIFIED, &res);
201
-
202
- if (res != MEMTX_OK) {
203
- return false;
204
- }
205
-
206
- valid_l2t = (value & L2_TABLE_VALID_MASK) != 0;
207
-
208
- if (valid_l2t) {
209
- num_l2_entries = s->ct.page_sz / s->ct.entry_sz;
210
-
211
- l2t_addr = value & ((1ULL << 51) - 1);
212
-
213
- address_space_stq_le(as, l2t_addr +
214
- ((icid % num_l2_entries) * GITS_CTE_SIZE),
215
- cte, MEMTXATTRS_UNSPECIFIED, &res);
216
- }
217
- } else {
218
- /* Flat level table */
219
- address_space_stq_le(as, s->ct.base_addr + (icid * GITS_CTE_SIZE),
220
- cte, MEMTXATTRS_UNSPECIFIED, &res);
221
- }
222
+ entry_addr = table_entry_addr(s, &s->ct, icid, &res);
223
if (res != MEMTX_OK) {
224
+ /* memory access error: stall */
225
return false;
226
- } else {
227
+ }
228
+ if (entry_addr == -1) {
229
+ /* No L2 table for this index: discard write and continue */
230
return true;
231
}
232
+
233
+ address_space_stq_le(as, entry_addr, cte, MEMTXATTRS_UNSPECIFIED, &res);
234
+ return res == MEMTX_OK;
235
}
236
237
static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
238
@@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
239
uint8_t size, uint64_t itt_addr)
240
{
241
AddressSpace *as = &s->gicv3->dma_as;
242
- uint64_t value;
243
- uint64_t l2t_addr;
244
- bool valid_l2t;
245
- uint32_t l2t_id;
246
- uint32_t num_l2_entries;
247
+ uint64_t entry_addr;
248
uint64_t dte = 0;
249
MemTxResult res = MEMTX_OK;
250
251
@@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
252
return true;
253
}
254
255
- /*
256
- * The specification defines the format of level 1 entries of a
257
- * 2-level table, but the format of level 2 entries and the format
258
- * of flat-mapped tables is IMPDEF.
259
- */
260
- if (s->dt.indirect) {
261
- l2t_id = devid / (s->dt.page_sz / L1TABLE_ENTRY_SIZE);
262
-
263
- value = address_space_ldq_le(as,
264
- s->dt.base_addr +
265
- (l2t_id * L1TABLE_ENTRY_SIZE),
266
- MEMTXATTRS_UNSPECIFIED, &res);
267
-
268
- if (res != MEMTX_OK) {
269
- return false;
270
- }
271
-
272
- valid_l2t = (value & L2_TABLE_VALID_MASK) != 0;
273
-
274
- if (valid_l2t) {
275
- num_l2_entries = s->dt.page_sz / s->dt.entry_sz;
276
-
277
- l2t_addr = value & ((1ULL << 51) - 1);
278
-
279
- address_space_stq_le(as, l2t_addr +
280
- ((devid % num_l2_entries) * GITS_DTE_SIZE),
281
- dte, MEMTXATTRS_UNSPECIFIED, &res);
282
- }
283
- } else {
284
- /* Flat level table */
285
- address_space_stq_le(as, s->dt.base_addr + (devid * GITS_DTE_SIZE),
286
- dte, MEMTXATTRS_UNSPECIFIED, &res);
287
- }
288
+ entry_addr = table_entry_addr(s, &s->dt, devid, &res);
289
if (res != MEMTX_OK) {
290
+ /* memory access error: stall */
291
return false;
292
- } else {
293
+ }
294
+ if (entry_addr == -1) {
295
+ /* No L2 table for this index: discard write and continue */
296
return true;
297
}
298
+ address_space_stq_le(as, entry_addr, dte, MEMTXATTRS_UNSPECIFIED, &res);
299
+ return res == MEMTX_OK;
300
}
301
302
static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
303
--
132
--
304
2.25.1
133
2.25.1
305
306
diff view generated by jsdifflib
1
From: Gavin Shan <gshan@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This supports virtio-mem-pci device on "virt" platform, by simply
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
following the implementation on x86.
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
5
Message-id: 20220708151540.18136-19-richard.henderson@linaro.org
6
* This implements the hotplug handlers to support virtio-mem-pci
7
device hot-add, while the hot-remove isn't supported as we have
8
on x86.
9
10
* The block size is 512MB on ARM64 instead of 128MB on x86.
11
12
* It has been passing the tests with various combinations like 64KB
13
and 4KB page sizes on host and guest, different memory device
14
backends like normal, transparent huge page and HugeTLB, plus
15
migration.
16
17
Co-developed-by: David Hildenbrand <david@redhat.com>
18
Co-developed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
19
Signed-off-by: Gavin Shan <gshan@redhat.com>
20
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
21
Reviewed-by: David Hildenbrand <david@redhat.com>
22
Message-id: 20220111063329.74447-3-gshan@redhat.com
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
---
7
---
25
hw/arm/virt.c | 70 ++++++++++++++++++++++++++++++++++++++++++
8
target/arm/helper-sme.h | 2 ++
26
hw/virtio/virtio-mem.c | 4 ++-
9
target/arm/sme.decode | 4 ++++
27
hw/arm/Kconfig | 1 +
10
target/arm/sme_helper.c | 25 +++++++++++++++++++++++++
28
3 files changed, 74 insertions(+), 1 deletion(-)
11
target/arm/translate-sme.c | 13 +++++++++++++
12
4 files changed, 44 insertions(+)
29
13
30
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
14
diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h
31
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/arm/virt.c
16
--- a/target/arm/helper-sme.h
33
+++ b/hw/arm/virt.c
17
+++ b/target/arm/helper-sme.h
34
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@
35
#include "hw/arm/smmuv3.h"
19
36
#include "hw/acpi/acpi.h"
20
DEF_HELPER_FLAGS_2(set_pstate_sm, TCG_CALL_NO_RWG, void, env, i32)
37
#include "target/arm/internals.h"
21
DEF_HELPER_FLAGS_2(set_pstate_za, TCG_CALL_NO_RWG, void, env, i32)
38
+#include "hw/mem/memory-device.h"
22
+
39
#include "hw/mem/pc-dimm.h"
23
+DEF_HELPER_FLAGS_3(sme_zero, TCG_CALL_NO_RWG, void, env, i32, i32)
40
#include "hw/mem/nvdimm.h"
24
diff --git a/target/arm/sme.decode b/target/arm/sme.decode
41
#include "hw/acpi/generic_event_device.h"
25
index XXXXXXX..XXXXXXX 100644
42
+#include "hw/virtio/virtio-mem-pci.h"
26
--- a/target/arm/sme.decode
43
#include "hw/virtio/virtio-iommu.h"
27
+++ b/target/arm/sme.decode
44
#include "hw/char/pl011.h"
28
@@ -XXX,XX +XXX,XX @@
45
#include "qemu/guest-random.h"
29
#
46
@@ -XXX,XX +XXX,XX @@ static void virt_memory_plug(HotplugHandler *hotplug_dev,
30
# This file is processed by scripts/decodetree.py
47
dev, &error_abort);
31
#
32
+
33
+### SME Misc
34
+
35
+ZERO 11000000 00 001 00000000000 imm:8
36
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/sme_helper.c
39
+++ b/target/arm/sme_helper.c
40
@@ -XXX,XX +XXX,XX @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i)
41
memset(env->zarray, 0, sizeof(env->zarray));
42
}
48
}
43
}
49
44
+
50
+static void virt_virtio_md_pci_pre_plug(HotplugHandler *hotplug_dev,
45
+void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl)
51
+ DeviceState *dev, Error **errp)
52
+{
46
+{
53
+ HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
47
+ uint32_t i;
54
+ Error *local_err = NULL;
55
+
48
+
56
+ if (!hotplug_dev2 && dev->hotplugged) {
49
+ /*
57
+ /*
50
+ * Special case clearing the entire ZA space.
58
+ * Without a bus hotplug handler, we cannot control the plug/unplug
51
+ * This falls into the CONSTRAINED UNPREDICTABLE zeroing of any
59
+ * order. We should never reach this point when hotplugging on ARM.
52
+ * parts of the ZA storage outside of SVL.
60
+ * However, it's nice to add a safety net, similar to what we have
53
+ */
61
+ * on x86.
54
+ if (imm == 0xff) {
62
+ */
55
+ memset(env->zarray, 0, sizeof(env->zarray));
63
+ error_setg(errp, "hotplug of virtio based memory devices not supported"
64
+ " on this bus.");
65
+ return;
56
+ return;
66
+ }
57
+ }
67
+ /*
68
+ * First, see if we can plug this memory device at all. If that
69
+ * succeeds, branch of to the actual hotplug handler.
70
+ */
71
+ memory_device_pre_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev), NULL,
72
+ &local_err);
73
+ if (!local_err && hotplug_dev2) {
74
+ hotplug_handler_pre_plug(hotplug_dev2, dev, &local_err);
75
+ }
76
+ error_propagate(errp, local_err);
77
+}
78
+
79
+static void virt_virtio_md_pci_plug(HotplugHandler *hotplug_dev,
80
+ DeviceState *dev, Error **errp)
81
+{
82
+ HotplugHandler *hotplug_dev2 = qdev_get_bus_hotplug_handler(dev);
83
+ Error *local_err = NULL;
84
+
58
+
85
+ /*
59
+ /*
86
+ * Plug the memory device first and then branch off to the actual
60
+ * Recall that ZAnH.D[m] is spread across ZA[n+8*m],
87
+ * hotplug handler. If that one fails, we can easily undo the memory
61
+ * so each row is discontiguous within ZA[].
88
+ * device bits.
89
+ */
62
+ */
90
+ memory_device_plug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
63
+ for (i = 0; i < svl; i++) {
91
+ if (hotplug_dev2) {
64
+ if (imm & (1 << (i % 8))) {
92
+ hotplug_handler_plug(hotplug_dev2, dev, &local_err);
65
+ memset(&env->zarray[i], 0, svl);
93
+ if (local_err) {
94
+ memory_device_unplug(MEMORY_DEVICE(dev), MACHINE(hotplug_dev));
95
+ }
66
+ }
96
+ }
67
+ }
97
+ error_propagate(errp, local_err);
98
+}
68
+}
99
+
69
diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c
100
+static void virt_virtio_md_pci_unplug_request(HotplugHandler *hotplug_dev,
70
index XXXXXXX..XXXXXXX 100644
101
+ DeviceState *dev, Error **errp)
71
--- a/target/arm/translate-sme.c
102
+{
72
+++ b/target/arm/translate-sme.c
103
+ /* We don't support hot unplug of virtio based memory devices */
73
@@ -XXX,XX +XXX,XX @@
104
+ error_setg(errp, "virtio based memory devices cannot be unplugged.");
74
*/
105
+}
75
76
#include "decode-sme.c.inc"
106
+
77
+
107
+
78
+
108
static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
79
+static bool trans_ZERO(DisasContext *s, arg_ZERO *a)
109
DeviceState *dev, Error **errp)
80
+{
110
{
81
+ if (!dc_isar_feature(aa64_sme, s)) {
111
@@ -XXX,XX +XXX,XX @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
82
+ return false;
112
113
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
114
virt_memory_pre_plug(hotplug_dev, dev, errp);
115
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) {
116
+ virt_virtio_md_pci_pre_plug(hotplug_dev, dev, errp);
117
} else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
118
hwaddr db_start = 0, db_end = 0;
119
char *resv_prop_str;
120
@@ -XXX,XX +XXX,XX @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,
121
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
122
virt_memory_plug(hotplug_dev, dev, errp);
123
}
124
+
125
+ if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) {
126
+ virt_virtio_md_pci_plug(hotplug_dev, dev, errp);
127
+ }
83
+ }
128
+
84
+ if (sme_za_enabled_check(s)) {
129
if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
85
+ gen_helper_sme_zero(cpu_env, tcg_constant_i32(a->imm),
130
PCIDevice *pdev = PCI_DEVICE(dev);
86
+ tcg_constant_i32(streaming_vec_reg_size(s)));
131
87
+ }
132
@@ -XXX,XX +XXX,XX @@ static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev,
88
+ return true;
133
{
89
+}
134
if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
135
virt_dimm_unplug_request(hotplug_dev, dev, errp);
136
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI)) {
137
+ virt_virtio_md_pci_unplug_request(hotplug_dev, dev, errp);
138
} else {
139
error_setg(errp, "device unplug request for unsupported device"
140
" type: %s", object_get_typename(OBJECT(dev)));
141
@@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine,
142
143
if (device_is_dynamic_sysbus(mc, dev) ||
144
object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) ||
145
+ object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MEM_PCI) ||
146
object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
147
return HOTPLUG_HANDLER(machine);
148
}
149
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
150
index XXXXXXX..XXXXXXX 100644
151
--- a/hw/virtio/virtio-mem.c
152
+++ b/hw/virtio/virtio-mem.c
153
@@ -XXX,XX +XXX,XX @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
154
* The memory block size corresponds mostly to the section size.
155
*
156
* This allows e.g., to add 20MB with a section size of 128MB on x86_64, and
157
- * a section size of 1GB on arm64 (as long as the start address is properly
158
+ * a section size of 512MB on arm64 (as long as the start address is properly
159
* aligned, similar to ordinary DIMMs).
160
*
161
* We can change this at any time and maybe even make it configurable if
162
@@ -XXX,XX +XXX,XX @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
163
*/
164
#if defined(TARGET_X86_64) || defined(TARGET_I386)
165
#define VIRTIO_MEM_USABLE_EXTENT (2 * (128 * MiB))
166
+#elif defined(TARGET_ARM)
167
+#define VIRTIO_MEM_USABLE_EXTENT (2 * (512 * MiB))
168
#else
169
#error VIRTIO_MEM_USABLE_EXTENT not defined
170
#endif
171
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
172
index XXXXXXX..XXXXXXX 100644
173
--- a/hw/arm/Kconfig
174
+++ b/hw/arm/Kconfig
175
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
176
select ACPI_HW_REDUCED
177
select ACPI_APEI
178
select ACPI_VIOT
179
+ select VIRTIO_MEM_SUPPORTED
180
181
config CHEETAH
182
bool
183
--
90
--
184
2.25.1
91
2.25.1
185
186
diff view generated by jsdifflib
1
From: Marc Zyngier <maz@kernel.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Just like we can control the enablement of the highmem PCIe region
3
We can reuse the SVE functions for implementing moves to/from
4
using highmem_ecam, let's add a control for the highmem GICv3
4
horizontal tile slices, but we need new ones for moves to/from
5
redistributor region.
5
vertical tile slices.
6
6
7
Similarily to highmem_ecam, these redistributors are disabled when
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
highmem is off.
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
9
Message-id: 20220708151540.18136-20-richard.henderson@linaro.org
10
Reviewed-by: Andrew Jones <drjones@redhat.com>
11
Signed-off-by: Marc Zyngier <maz@kernel.org>
12
Reviewed-by: Eric Auger <eric.auger@redhat.com>
13
Message-id: 20220114140741.1358263-3-maz@kernel.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
11
---
16
include/hw/arm/virt.h | 4 +++-
12
target/arm/helper-sme.h | 12 +++
17
hw/arm/virt-acpi-build.c | 2 ++
13
target/arm/helper-sve.h | 2 +
18
hw/arm/virt.c | 2 ++
14
target/arm/translate-a64.h | 8 ++
19
3 files changed, 7 insertions(+), 1 deletion(-)
15
target/arm/translate.h | 5 ++
16
target/arm/sme.decode | 15 ++++
17
target/arm/sme_helper.c | 151 ++++++++++++++++++++++++++++++++++++-
18
target/arm/sve_helper.c | 12 +++
19
target/arm/translate-sme.c | 127 +++++++++++++++++++++++++++++++
20
8 files changed, 331 insertions(+), 1 deletion(-)
20
21
21
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
22
diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h
22
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/arm/virt.h
24
--- a/target/arm/helper-sme.h
24
+++ b/include/hw/arm/virt.h
25
+++ b/target/arm/helper-sme.h
25
@@ -XXX,XX +XXX,XX @@ struct VirtMachineState {
26
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(set_pstate_sm, TCG_CALL_NO_RWG, void, env, i32)
26
bool highmem;
27
DEF_HELPER_FLAGS_2(set_pstate_za, TCG_CALL_NO_RWG, void, env, i32)
27
bool highmem_ecam;
28
28
bool highmem_mmio;
29
DEF_HELPER_FLAGS_3(sme_zero, TCG_CALL_NO_RWG, void, env, i32, i32)
29
+ bool highmem_redists;
30
+
30
bool its;
31
+/* Move to/from vertical array slices, i.e. columns, so 'c'. */
31
bool tcg_its;
32
+DEF_HELPER_FLAGS_4(sme_mova_cz_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
32
bool virt;
33
+DEF_HELPER_FLAGS_4(sme_mova_zc_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
33
@@ -XXX,XX +XXX,XX @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)
34
+DEF_HELPER_FLAGS_4(sme_mova_cz_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
34
35
+DEF_HELPER_FLAGS_4(sme_mova_zc_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
35
assert(vms->gic_version == VIRT_GIC_VERSION_3);
36
+DEF_HELPER_FLAGS_4(sme_mova_cz_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
36
37
+DEF_HELPER_FLAGS_4(sme_mova_zc_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
37
- return MACHINE(vms)->smp.cpus > redist0_capacity ? 2 : 1;
38
+DEF_HELPER_FLAGS_4(sme_mova_cz_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
38
+ return (MACHINE(vms)->smp.cpus > redist0_capacity &&
39
+DEF_HELPER_FLAGS_4(sme_mova_zc_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
39
+ vms->highmem_redists) ? 2 : 1;
40
+DEF_HELPER_FLAGS_4(sme_mova_cz_q, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
41
+DEF_HELPER_FLAGS_4(sme_mova_zc_q, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
42
diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h
43
index XXXXXXX..XXXXXXX 100644
44
--- a/target/arm/helper-sve.h
45
+++ b/target/arm/helper-sve.h
46
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(sve_sel_zpzz_s, TCG_CALL_NO_RWG,
47
void, ptr, ptr, ptr, ptr, i32)
48
DEF_HELPER_FLAGS_5(sve_sel_zpzz_d, TCG_CALL_NO_RWG,
49
void, ptr, ptr, ptr, ptr, i32)
50
+DEF_HELPER_FLAGS_5(sve_sel_zpzz_q, TCG_CALL_NO_RWG,
51
+ void, ptr, ptr, ptr, ptr, i32)
52
53
DEF_HELPER_FLAGS_5(sve2_addp_zpzz_b, TCG_CALL_NO_RWG,
54
void, ptr, ptr, ptr, ptr, i32)
55
diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h
56
index XXXXXXX..XXXXXXX 100644
57
--- a/target/arm/translate-a64.h
58
+++ b/target/arm/translate-a64.h
59
@@ -XXX,XX +XXX,XX @@ static inline int pred_gvec_reg_size(DisasContext *s)
60
return size_for_gvec(pred_full_reg_size(s));
40
}
61
}
41
62
42
#endif /* QEMU_ARM_VIRT_H */
63
+/* Return a newly allocated pointer to the predicate register. */
43
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
64
+static inline TCGv_ptr pred_full_reg_ptr(DisasContext *s, int regno)
44
index XXXXXXX..XXXXXXX 100644
65
+{
45
--- a/hw/arm/virt-acpi-build.c
66
+ TCGv_ptr ret = tcg_temp_new_ptr();
46
+++ b/hw/arm/virt-acpi-build.c
67
+ tcg_gen_addi_ptr(ret, cpu_env, pred_full_reg_offset(s, regno));
47
@@ -XXX,XX +XXX,XX @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
68
+ return ret;
48
acpi_add_table(table_offsets, tables_blob);
69
+}
49
build_fadt_rev5(tables_blob, tables->linker, vms, dsdt);
70
+
50
71
bool disas_sve(DisasContext *, uint32_t);
51
+ vms->highmem_redists &= vms->highmem;
72
bool disas_sme(DisasContext *, uint32_t);
52
+
73
53
acpi_add_table(table_offsets, tables_blob);
74
diff --git a/target/arm/translate.h b/target/arm/translate.h
54
build_madt(tables_blob, tables->linker, vms);
75
index XXXXXXX..XXXXXXX 100644
55
76
--- a/target/arm/translate.h
56
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
77
+++ b/target/arm/translate.h
57
index XXXXXXX..XXXXXXX 100644
78
@@ -XXX,XX +XXX,XX @@ static inline int plus_2(DisasContext *s, int x)
58
--- a/hw/arm/virt.c
79
return x + 2;
59
+++ b/hw/arm/virt.c
80
}
60
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
81
61
virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
82
+static inline int plus_12(DisasContext *s, int x)
62
83
+{
63
vms->highmem_mmio &= vms->highmem;
84
+ return x + 12;
64
+ vms->highmem_redists &= vms->highmem;
85
+}
65
86
+
66
create_gic(vms, sysmem);
87
static inline int times_2(DisasContext *s, int x)
67
88
{
68
@@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj)
89
return x * 2;
69
90
diff --git a/target/arm/sme.decode b/target/arm/sme.decode
70
vms->highmem_ecam = !vmc->no_highmem_ecam;
91
index XXXXXXX..XXXXXXX 100644
71
vms->highmem_mmio = true;
92
--- a/target/arm/sme.decode
72
+ vms->highmem_redists = true;
93
+++ b/target/arm/sme.decode
73
94
@@ -XXX,XX +XXX,XX @@
74
if (vmc->no_its) {
95
### SME Misc
75
vms->its = false;
96
97
ZERO 11000000 00 001 00000000000 imm:8
98
+
99
+### SME Move into/from Array
100
+
101
+%mova_rs 13:2 !function=plus_12
102
+&mova esz rs pg zr za_imm v:bool to_vec:bool
103
+
104
+MOVA 11000000 esz:2 00000 0 v:1 .. pg:3 zr:5 0 za_imm:4 \
105
+ &mova to_vec=0 rs=%mova_rs
106
+MOVA 11000000 11 00000 1 v:1 .. pg:3 zr:5 0 za_imm:4 \
107
+ &mova to_vec=0 rs=%mova_rs esz=4
108
+
109
+MOVA 11000000 esz:2 00001 0 v:1 .. pg:3 0 za_imm:4 zr:5 \
110
+ &mova to_vec=1 rs=%mova_rs
111
+MOVA 11000000 11 00001 1 v:1 .. pg:3 0 za_imm:4 zr:5 \
112
+ &mova to_vec=1 rs=%mova_rs esz=4
113
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
114
index XXXXXXX..XXXXXXX 100644
115
--- a/target/arm/sme_helper.c
116
+++ b/target/arm/sme_helper.c
117
@@ -XXX,XX +XXX,XX @@
118
119
#include "qemu/osdep.h"
120
#include "cpu.h"
121
-#include "internals.h"
122
+#include "tcg/tcg-gvec-desc.h"
123
#include "exec/helper-proto.h"
124
+#include "qemu/int128.h"
125
+#include "vec_internal.h"
126
127
/* ResetSVEState */
128
void arm_reset_sve_state(CPUARMState *env)
129
@@ -XXX,XX +XXX,XX @@ void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl)
130
}
131
}
132
}
133
+
134
+
135
+/*
136
+ * When considering the ZA storage as an array of elements of
137
+ * type T, the index within that array of the Nth element of
138
+ * a vertical slice of a tile can be calculated like this,
139
+ * regardless of the size of type T. This is because the tiles
140
+ * are interleaved, so if type T is size N bytes then row 1 of
141
+ * the tile is N rows away from row 0. The division by N to
142
+ * convert a byte offset into an array index and the multiplication
143
+ * by N to convert from vslice-index-within-the-tile to
144
+ * the index within the ZA storage cancel out.
145
+ */
146
+#define tile_vslice_index(i) ((i) * sizeof(ARMVectorReg))
147
+
148
+/*
149
+ * When doing byte arithmetic on the ZA storage, the element
150
+ * byteoff bytes away in a tile vertical slice is always this
151
+ * many bytes away in the ZA storage, regardless of the
152
+ * size of the tile element, assuming that byteoff is a multiple
153
+ * of the element size. Again this is because of the interleaving
154
+ * of the tiles. For instance if we have 1 byte per element then
155
+ * each row of the ZA storage has one byte of the vslice data,
156
+ * and (counting from 0) byte 8 goes in row 8 of the storage
157
+ * at offset (8 * row-size-in-bytes).
158
+ * If we have 8 bytes per element then each row of the ZA storage
159
+ * has 8 bytes of the data, but there are 8 interleaved tiles and
160
+ * so byte 8 of the data goes into row 1 of the tile,
161
+ * which is again row 8 of the storage, so the offset is still
162
+ * (8 * row-size-in-bytes). Similarly for other element sizes.
163
+ */
164
+#define tile_vslice_offset(byteoff) ((byteoff) * sizeof(ARMVectorReg))
165
+
166
+
167
+/*
168
+ * Move Zreg vector to ZArray column.
169
+ */
170
+#define DO_MOVA_C(NAME, TYPE, H) \
171
+void HELPER(NAME)(void *za, void *vn, void *vg, uint32_t desc) \
172
+{ \
173
+ int i, oprsz = simd_oprsz(desc); \
174
+ for (i = 0; i < oprsz; ) { \
175
+ uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); \
176
+ do { \
177
+ if (pg & 1) { \
178
+ *(TYPE *)(za + tile_vslice_offset(i)) = *(TYPE *)(vn + H(i)); \
179
+ } \
180
+ i += sizeof(TYPE); \
181
+ pg >>= sizeof(TYPE); \
182
+ } while (i & 15); \
183
+ } \
184
+}
185
+
186
+DO_MOVA_C(sme_mova_cz_b, uint8_t, H1)
187
+DO_MOVA_C(sme_mova_cz_h, uint16_t, H1_2)
188
+DO_MOVA_C(sme_mova_cz_s, uint32_t, H1_4)
189
+
190
+void HELPER(sme_mova_cz_d)(void *za, void *vn, void *vg, uint32_t desc)
191
+{
192
+ int i, oprsz = simd_oprsz(desc) / 8;
193
+ uint8_t *pg = vg;
194
+ uint64_t *n = vn;
195
+ uint64_t *a = za;
196
+
197
+ for (i = 0; i < oprsz; i++) {
198
+ if (pg[H1(i)] & 1) {
199
+ a[tile_vslice_index(i)] = n[i];
200
+ }
201
+ }
202
+}
203
+
204
+void HELPER(sme_mova_cz_q)(void *za, void *vn, void *vg, uint32_t desc)
205
+{
206
+ int i, oprsz = simd_oprsz(desc) / 16;
207
+ uint16_t *pg = vg;
208
+ Int128 *n = vn;
209
+ Int128 *a = za;
210
+
211
+ /*
212
+ * Int128 is used here simply to copy 16 bytes, and to simplify
213
+ * the address arithmetic.
214
+ */
215
+ for (i = 0; i < oprsz; i++) {
216
+ if (pg[H2(i)] & 1) {
217
+ a[tile_vslice_index(i)] = n[i];
218
+ }
219
+ }
220
+}
221
+
222
+#undef DO_MOVA_C
223
+
224
+/*
225
+ * Move ZArray column to Zreg vector.
226
+ */
227
+#define DO_MOVA_Z(NAME, TYPE, H) \
228
+void HELPER(NAME)(void *vd, void *za, void *vg, uint32_t desc) \
229
+{ \
230
+ int i, oprsz = simd_oprsz(desc); \
231
+ for (i = 0; i < oprsz; ) { \
232
+ uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); \
233
+ do { \
234
+ if (pg & 1) { \
235
+ *(TYPE *)(vd + H(i)) = *(TYPE *)(za + tile_vslice_offset(i)); \
236
+ } \
237
+ i += sizeof(TYPE); \
238
+ pg >>= sizeof(TYPE); \
239
+ } while (i & 15); \
240
+ } \
241
+}
242
+
243
+DO_MOVA_Z(sme_mova_zc_b, uint8_t, H1)
244
+DO_MOVA_Z(sme_mova_zc_h, uint16_t, H1_2)
245
+DO_MOVA_Z(sme_mova_zc_s, uint32_t, H1_4)
246
+
247
+void HELPER(sme_mova_zc_d)(void *vd, void *za, void *vg, uint32_t desc)
248
+{
249
+ int i, oprsz = simd_oprsz(desc) / 8;
250
+ uint8_t *pg = vg;
251
+ uint64_t *d = vd;
252
+ uint64_t *a = za;
253
+
254
+ for (i = 0; i < oprsz; i++) {
255
+ if (pg[H1(i)] & 1) {
256
+ d[i] = a[tile_vslice_index(i)];
257
+ }
258
+ }
259
+}
260
+
261
+void HELPER(sme_mova_zc_q)(void *vd, void *za, void *vg, uint32_t desc)
262
+{
263
+ int i, oprsz = simd_oprsz(desc) / 16;
264
+ uint16_t *pg = vg;
265
+ Int128 *d = vd;
266
+ Int128 *a = za;
267
+
268
+ /*
269
+ * Int128 is used here simply to copy 16 bytes, and to simplify
270
+ * the address arithmetic.
271
+ */
272
+ for (i = 0; i < oprsz; i++, za += sizeof(ARMVectorReg)) {
273
+ if (pg[H2(i)] & 1) {
274
+ d[i] = a[tile_vslice_index(i)];
275
+ }
276
+ }
277
+}
278
+
279
+#undef DO_MOVA_Z
280
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
281
index XXXXXXX..XXXXXXX 100644
282
--- a/target/arm/sve_helper.c
283
+++ b/target/arm/sve_helper.c
284
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_sel_zpzz_d)(void *vd, void *vn, void *vm,
285
}
286
}
287
288
+void HELPER(sve_sel_zpzz_q)(void *vd, void *vn, void *vm,
289
+ void *vg, uint32_t desc)
290
+{
291
+ intptr_t i, opr_sz = simd_oprsz(desc) / 16;
292
+ Int128 *d = vd, *n = vn, *m = vm;
293
+ uint16_t *pg = vg;
294
+
295
+ for (i = 0; i < opr_sz; i += 1) {
296
+ d[i] = (pg[H2(i)] & 1 ? n : m)[i];
297
+ }
298
+}
299
+
300
/* Two operand comparison controlled by a predicate.
301
* ??? It is very tempting to want to be able to expand this inline
302
* with x86 instructions, e.g.
303
diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c
304
index XXXXXXX..XXXXXXX 100644
305
--- a/target/arm/translate-sme.c
306
+++ b/target/arm/translate-sme.c
307
@@ -XXX,XX +XXX,XX @@
308
#include "decode-sme.c.inc"
309
310
311
+/*
312
+ * Resolve tile.size[index] to a host pointer, where tile and index
313
+ * are always decoded together, dependent on the element size.
314
+ */
315
+static TCGv_ptr get_tile_rowcol(DisasContext *s, int esz, int rs,
316
+ int tile_index, bool vertical)
317
+{
318
+ int tile = tile_index >> (4 - esz);
319
+ int index = esz == MO_128 ? 0 : extract32(tile_index, 0, 4 - esz);
320
+ int pos, len, offset;
321
+ TCGv_i32 tmp;
322
+ TCGv_ptr addr;
323
+
324
+ /* Compute the final index, which is Rs+imm. */
325
+ tmp = tcg_temp_new_i32();
326
+ tcg_gen_trunc_tl_i32(tmp, cpu_reg(s, rs));
327
+ tcg_gen_addi_i32(tmp, tmp, index);
328
+
329
+ /* Prepare a power-of-two modulo via extraction of @len bits. */
330
+ len = ctz32(streaming_vec_reg_size(s)) - esz;
331
+
332
+ if (vertical) {
333
+ /*
334
+ * Compute the byte offset of the index within the tile:
335
+ * (index % (svl / size)) * size
336
+ * = (index % (svl >> esz)) << esz
337
+ * Perform the power-of-two modulo via extraction of the low @len bits.
338
+ * Perform the multiply by shifting left by @pos bits.
339
+ * Perform these operations simultaneously via deposit into zero.
340
+ */
341
+ pos = esz;
342
+ tcg_gen_deposit_z_i32(tmp, tmp, pos, len);
343
+
344
+ /*
345
+ * For big-endian, adjust the indexed column byte offset within
346
+ * the uint64_t host words that make up env->zarray[].
347
+ */
348
+ if (HOST_BIG_ENDIAN && esz < MO_64) {
349
+ tcg_gen_xori_i32(tmp, tmp, 8 - (1 << esz));
350
+ }
351
+ } else {
352
+ /*
353
+ * Compute the byte offset of the index within the tile:
354
+ * (index % (svl / size)) * (size * sizeof(row))
355
+ * = (index % (svl >> esz)) << (esz + log2(sizeof(row)))
356
+ */
357
+ pos = esz + ctz32(sizeof(ARMVectorReg));
358
+ tcg_gen_deposit_z_i32(tmp, tmp, pos, len);
359
+
360
+ /* Row slices are always aligned and need no endian adjustment. */
361
+ }
362
+
363
+ /* The tile byte offset within env->zarray is the row. */
364
+ offset = tile * sizeof(ARMVectorReg);
365
+
366
+ /* Include the byte offset of zarray to make this relative to env. */
367
+ offset += offsetof(CPUARMState, zarray);
368
+ tcg_gen_addi_i32(tmp, tmp, offset);
369
+
370
+ /* Add the byte offset to env to produce the final pointer. */
371
+ addr = tcg_temp_new_ptr();
372
+ tcg_gen_ext_i32_ptr(addr, tmp);
373
+ tcg_temp_free_i32(tmp);
374
+ tcg_gen_add_ptr(addr, addr, cpu_env);
375
+
376
+ return addr;
377
+}
378
+
379
static bool trans_ZERO(DisasContext *s, arg_ZERO *a)
380
{
381
if (!dc_isar_feature(aa64_sme, s)) {
382
@@ -XXX,XX +XXX,XX @@ static bool trans_ZERO(DisasContext *s, arg_ZERO *a)
383
}
384
return true;
385
}
386
+
387
+static bool trans_MOVA(DisasContext *s, arg_MOVA *a)
388
+{
389
+ static gen_helper_gvec_4 * const h_fns[5] = {
390
+ gen_helper_sve_sel_zpzz_b, gen_helper_sve_sel_zpzz_h,
391
+ gen_helper_sve_sel_zpzz_s, gen_helper_sve_sel_zpzz_d,
392
+ gen_helper_sve_sel_zpzz_q
393
+ };
394
+ static gen_helper_gvec_3 * const cz_fns[5] = {
395
+ gen_helper_sme_mova_cz_b, gen_helper_sme_mova_cz_h,
396
+ gen_helper_sme_mova_cz_s, gen_helper_sme_mova_cz_d,
397
+ gen_helper_sme_mova_cz_q,
398
+ };
399
+ static gen_helper_gvec_3 * const zc_fns[5] = {
400
+ gen_helper_sme_mova_zc_b, gen_helper_sme_mova_zc_h,
401
+ gen_helper_sme_mova_zc_s, gen_helper_sme_mova_zc_d,
402
+ gen_helper_sme_mova_zc_q,
403
+ };
404
+
405
+ TCGv_ptr t_za, t_zr, t_pg;
406
+ TCGv_i32 t_desc;
407
+ int svl;
408
+
409
+ if (!dc_isar_feature(aa64_sme, s)) {
410
+ return false;
411
+ }
412
+ if (!sme_smza_enabled_check(s)) {
413
+ return true;
414
+ }
415
+
416
+ t_za = get_tile_rowcol(s, a->esz, a->rs, a->za_imm, a->v);
417
+ t_zr = vec_full_reg_ptr(s, a->zr);
418
+ t_pg = pred_full_reg_ptr(s, a->pg);
419
+
420
+ svl = streaming_vec_reg_size(s);
421
+ t_desc = tcg_constant_i32(simd_desc(svl, svl, 0));
422
+
423
+ if (a->v) {
424
+ /* Vertical slice -- use sme mova helpers. */
425
+ if (a->to_vec) {
426
+ zc_fns[a->esz](t_zr, t_za, t_pg, t_desc);
427
+ } else {
428
+ cz_fns[a->esz](t_za, t_zr, t_pg, t_desc);
429
+ }
430
+ } else {
431
+ /* Horizontal slice -- reuse sve sel helpers. */
432
+ if (a->to_vec) {
433
+ h_fns[a->esz](t_zr, t_za, t_zr, t_pg, t_desc);
434
+ } else {
435
+ h_fns[a->esz](t_za, t_zr, t_za, t_pg, t_desc);
436
+ }
437
+ }
438
+
439
+ tcg_temp_free_ptr(t_za);
440
+ tcg_temp_free_ptr(t_zr);
441
+ tcg_temp_free_ptr(t_pg);
442
+
443
+ return true;
444
+}
76
--
445
--
77
2.25.1
446
2.25.1
78
79
diff view generated by jsdifflib
1
From: Marc Zyngier <maz@kernel.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
In order to only keep the highmem devices that actually fit in
3
We cannot reuse the SVE functions for LD[1-4] and ST[1-4],
4
the PA range, check their location against the range and update
4
because those functions accept only a Zreg register number.
5
highest_gpa if they fit. If they don't, mark them as disabled.
5
For SME, we want to pass a pointer into ZA storage.
6
6
7
Signed-off-by: Marc Zyngier <maz@kernel.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220114140741.1358263-6-maz@kernel.org
9
Message-id: 20220708151540.18136-21-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
hw/arm/virt.c | 34 ++++++++++++++++++++++++++++------
12
target/arm/helper-sme.h | 82 +++++
13
1 file changed, 28 insertions(+), 6 deletions(-)
13
target/arm/sme.decode | 9 +
14
target/arm/sme_helper.c | 595 +++++++++++++++++++++++++++++++++++++
15
target/arm/translate-sme.c | 70 +++++
16
4 files changed, 756 insertions(+)
14
17
15
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
18
diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h
16
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/virt.c
20
--- a/target/arm/helper-sme.h
18
+++ b/hw/arm/virt.c
21
+++ b/target/arm/helper-sme.h
19
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(sme_mova_cz_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
20
base = vms->memmap[VIRT_MEM].base + LEGACY_RAMLIMIT_BYTES;
23
DEF_HELPER_FLAGS_4(sme_mova_zc_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
21
}
24
DEF_HELPER_FLAGS_4(sme_mova_cz_q, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
22
25
DEF_HELPER_FLAGS_4(sme_mova_zc_q, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
23
+ /* We know for sure that at least the memory fits in the PA space */
26
+
24
+ vms->highest_gpa = memtop - 1;
27
+DEF_HELPER_FLAGS_5(sme_ld1b_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
25
+
28
+DEF_HELPER_FLAGS_5(sme_ld1b_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
26
for (i = VIRT_LOWMEMMAP_LAST; i < ARRAY_SIZE(extended_memmap); i++) {
29
+DEF_HELPER_FLAGS_5(sme_ld1b_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
27
hwaddr size = extended_memmap[i].size;
30
+DEF_HELPER_FLAGS_5(sme_ld1b_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
28
+ bool fits;
31
+
29
32
+DEF_HELPER_FLAGS_5(sme_ld1h_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
30
base = ROUND_UP(base, size);
33
+DEF_HELPER_FLAGS_5(sme_ld1h_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
31
vms->memmap[i].base = base;
34
+DEF_HELPER_FLAGS_5(sme_ld1h_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
32
vms->memmap[i].size = size;
35
+DEF_HELPER_FLAGS_5(sme_ld1h_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
33
+
36
+DEF_HELPER_FLAGS_5(sme_ld1h_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
37
+DEF_HELPER_FLAGS_5(sme_ld1h_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
38
+DEF_HELPER_FLAGS_5(sme_ld1h_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
39
+DEF_HELPER_FLAGS_5(sme_ld1h_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
40
+
41
+DEF_HELPER_FLAGS_5(sme_ld1s_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
42
+DEF_HELPER_FLAGS_5(sme_ld1s_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
43
+DEF_HELPER_FLAGS_5(sme_ld1s_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
44
+DEF_HELPER_FLAGS_5(sme_ld1s_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
45
+DEF_HELPER_FLAGS_5(sme_ld1s_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
46
+DEF_HELPER_FLAGS_5(sme_ld1s_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
47
+DEF_HELPER_FLAGS_5(sme_ld1s_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
48
+DEF_HELPER_FLAGS_5(sme_ld1s_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
49
+
50
+DEF_HELPER_FLAGS_5(sme_ld1d_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
51
+DEF_HELPER_FLAGS_5(sme_ld1d_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
52
+DEF_HELPER_FLAGS_5(sme_ld1d_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
53
+DEF_HELPER_FLAGS_5(sme_ld1d_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
54
+DEF_HELPER_FLAGS_5(sme_ld1d_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
55
+DEF_HELPER_FLAGS_5(sme_ld1d_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
56
+DEF_HELPER_FLAGS_5(sme_ld1d_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
57
+DEF_HELPER_FLAGS_5(sme_ld1d_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
58
+
59
+DEF_HELPER_FLAGS_5(sme_ld1q_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
60
+DEF_HELPER_FLAGS_5(sme_ld1q_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
61
+DEF_HELPER_FLAGS_5(sme_ld1q_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
62
+DEF_HELPER_FLAGS_5(sme_ld1q_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
63
+DEF_HELPER_FLAGS_5(sme_ld1q_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
64
+DEF_HELPER_FLAGS_5(sme_ld1q_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
65
+DEF_HELPER_FLAGS_5(sme_ld1q_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
66
+DEF_HELPER_FLAGS_5(sme_ld1q_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
67
+
68
+DEF_HELPER_FLAGS_5(sme_st1b_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
69
+DEF_HELPER_FLAGS_5(sme_st1b_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
70
+DEF_HELPER_FLAGS_5(sme_st1b_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
71
+DEF_HELPER_FLAGS_5(sme_st1b_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
72
+
73
+DEF_HELPER_FLAGS_5(sme_st1h_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
74
+DEF_HELPER_FLAGS_5(sme_st1h_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
75
+DEF_HELPER_FLAGS_5(sme_st1h_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
76
+DEF_HELPER_FLAGS_5(sme_st1h_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
77
+DEF_HELPER_FLAGS_5(sme_st1h_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
78
+DEF_HELPER_FLAGS_5(sme_st1h_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
79
+DEF_HELPER_FLAGS_5(sme_st1h_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
80
+DEF_HELPER_FLAGS_5(sme_st1h_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
81
+
82
+DEF_HELPER_FLAGS_5(sme_st1s_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
83
+DEF_HELPER_FLAGS_5(sme_st1s_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
84
+DEF_HELPER_FLAGS_5(sme_st1s_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
85
+DEF_HELPER_FLAGS_5(sme_st1s_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
86
+DEF_HELPER_FLAGS_5(sme_st1s_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
87
+DEF_HELPER_FLAGS_5(sme_st1s_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
88
+DEF_HELPER_FLAGS_5(sme_st1s_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
89
+DEF_HELPER_FLAGS_5(sme_st1s_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
90
+
91
+DEF_HELPER_FLAGS_5(sme_st1d_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
92
+DEF_HELPER_FLAGS_5(sme_st1d_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
93
+DEF_HELPER_FLAGS_5(sme_st1d_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
94
+DEF_HELPER_FLAGS_5(sme_st1d_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
95
+DEF_HELPER_FLAGS_5(sme_st1d_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
96
+DEF_HELPER_FLAGS_5(sme_st1d_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
97
+DEF_HELPER_FLAGS_5(sme_st1d_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
98
+DEF_HELPER_FLAGS_5(sme_st1d_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
99
+
100
+DEF_HELPER_FLAGS_5(sme_st1q_be_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
101
+DEF_HELPER_FLAGS_5(sme_st1q_le_h, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
102
+DEF_HELPER_FLAGS_5(sme_st1q_be_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
103
+DEF_HELPER_FLAGS_5(sme_st1q_le_v, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
104
+DEF_HELPER_FLAGS_5(sme_st1q_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
105
+DEF_HELPER_FLAGS_5(sme_st1q_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
106
+DEF_HELPER_FLAGS_5(sme_st1q_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
107
+DEF_HELPER_FLAGS_5(sme_st1q_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
108
diff --git a/target/arm/sme.decode b/target/arm/sme.decode
109
index XXXXXXX..XXXXXXX 100644
110
--- a/target/arm/sme.decode
111
+++ b/target/arm/sme.decode
112
@@ -XXX,XX +XXX,XX @@ MOVA 11000000 esz:2 00001 0 v:1 .. pg:3 0 za_imm:4 zr:5 \
113
&mova to_vec=1 rs=%mova_rs
114
MOVA 11000000 11 00001 1 v:1 .. pg:3 0 za_imm:4 zr:5 \
115
&mova to_vec=1 rs=%mova_rs esz=4
116
+
117
+### SME Memory
118
+
119
+&ldst esz rs pg rn rm za_imm v:bool st:bool
120
+
121
+LDST1 1110000 0 esz:2 st:1 rm:5 v:1 .. pg:3 rn:5 0 za_imm:4 \
122
+ &ldst rs=%mova_rs
123
+LDST1 1110000 111 st:1 rm:5 v:1 .. pg:3 rn:5 0 za_imm:4 \
124
+ &ldst esz=4 rs=%mova_rs
125
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
126
index XXXXXXX..XXXXXXX 100644
127
--- a/target/arm/sme_helper.c
128
+++ b/target/arm/sme_helper.c
129
@@ -XXX,XX +XXX,XX @@
130
131
#include "qemu/osdep.h"
132
#include "cpu.h"
133
+#include "internals.h"
134
#include "tcg/tcg-gvec-desc.h"
135
#include "exec/helper-proto.h"
136
+#include "exec/cpu_ldst.h"
137
+#include "exec/exec-all.h"
138
#include "qemu/int128.h"
139
#include "vec_internal.h"
140
+#include "sve_ldst_internal.h"
141
142
/* ResetSVEState */
143
void arm_reset_sve_state(CPUARMState *env)
144
@@ -XXX,XX +XXX,XX @@ void HELPER(sme_mova_zc_q)(void *vd, void *za, void *vg, uint32_t desc)
145
}
146
147
#undef DO_MOVA_Z
148
+
149
+/*
150
+ * Clear elements in a tile slice comprising len bytes.
151
+ */
152
+
153
+typedef void ClearFn(void *ptr, size_t off, size_t len);
154
+
155
+static void clear_horizontal(void *ptr, size_t off, size_t len)
156
+{
157
+ memset(ptr + off, 0, len);
158
+}
159
+
160
+static void clear_vertical_b(void *vptr, size_t off, size_t len)
161
+{
162
+ for (size_t i = 0; i < len; ++i) {
163
+ *(uint8_t *)(vptr + tile_vslice_offset(i + off)) = 0;
164
+ }
165
+}
166
+
167
+static void clear_vertical_h(void *vptr, size_t off, size_t len)
168
+{
169
+ for (size_t i = 0; i < len; i += 2) {
170
+ *(uint16_t *)(vptr + tile_vslice_offset(i + off)) = 0;
171
+ }
172
+}
173
+
174
+static void clear_vertical_s(void *vptr, size_t off, size_t len)
175
+{
176
+ for (size_t i = 0; i < len; i += 4) {
177
+ *(uint32_t *)(vptr + tile_vslice_offset(i + off)) = 0;
178
+ }
179
+}
180
+
181
+static void clear_vertical_d(void *vptr, size_t off, size_t len)
182
+{
183
+ for (size_t i = 0; i < len; i += 8) {
184
+ *(uint64_t *)(vptr + tile_vslice_offset(i + off)) = 0;
185
+ }
186
+}
187
+
188
+static void clear_vertical_q(void *vptr, size_t off, size_t len)
189
+{
190
+ for (size_t i = 0; i < len; i += 16) {
191
+ memset(vptr + tile_vslice_offset(i + off), 0, 16);
192
+ }
193
+}
194
+
195
+/*
196
+ * Copy elements from an array into a tile slice comprising len bytes.
197
+ */
198
+
199
+typedef void CopyFn(void *dst, const void *src, size_t len);
200
+
201
+static void copy_horizontal(void *dst, const void *src, size_t len)
202
+{
203
+ memcpy(dst, src, len);
204
+}
205
+
206
+static void copy_vertical_b(void *vdst, const void *vsrc, size_t len)
207
+{
208
+ const uint8_t *src = vsrc;
209
+ uint8_t *dst = vdst;
210
+ size_t i;
211
+
212
+ for (i = 0; i < len; ++i) {
213
+ dst[tile_vslice_index(i)] = src[i];
214
+ }
215
+}
216
+
217
+static void copy_vertical_h(void *vdst, const void *vsrc, size_t len)
218
+{
219
+ const uint16_t *src = vsrc;
220
+ uint16_t *dst = vdst;
221
+ size_t i;
222
+
223
+ for (i = 0; i < len / 2; ++i) {
224
+ dst[tile_vslice_index(i)] = src[i];
225
+ }
226
+}
227
+
228
+static void copy_vertical_s(void *vdst, const void *vsrc, size_t len)
229
+{
230
+ const uint32_t *src = vsrc;
231
+ uint32_t *dst = vdst;
232
+ size_t i;
233
+
234
+ for (i = 0; i < len / 4; ++i) {
235
+ dst[tile_vslice_index(i)] = src[i];
236
+ }
237
+}
238
+
239
+static void copy_vertical_d(void *vdst, const void *vsrc, size_t len)
240
+{
241
+ const uint64_t *src = vsrc;
242
+ uint64_t *dst = vdst;
243
+ size_t i;
244
+
245
+ for (i = 0; i < len / 8; ++i) {
246
+ dst[tile_vslice_index(i)] = src[i];
247
+ }
248
+}
249
+
250
+static void copy_vertical_q(void *vdst, const void *vsrc, size_t len)
251
+{
252
+ for (size_t i = 0; i < len; i += 16) {
253
+ memcpy(vdst + tile_vslice_offset(i), vsrc + i, 16);
254
+ }
255
+}
256
+
257
+/*
258
+ * Host and TLB primitives for vertical tile slice addressing.
259
+ */
260
+
261
+#define DO_LD(NAME, TYPE, HOST, TLB) \
262
+static inline void sme_##NAME##_v_host(void *za, intptr_t off, void *host) \
263
+{ \
264
+ TYPE val = HOST(host); \
265
+ *(TYPE *)(za + tile_vslice_offset(off)) = val; \
266
+} \
267
+static inline void sme_##NAME##_v_tlb(CPUARMState *env, void *za, \
268
+ intptr_t off, target_ulong addr, uintptr_t ra) \
269
+{ \
270
+ TYPE val = TLB(env, useronly_clean_ptr(addr), ra); \
271
+ *(TYPE *)(za + tile_vslice_offset(off)) = val; \
272
+}
273
+
274
+#define DO_ST(NAME, TYPE, HOST, TLB) \
275
+static inline void sme_##NAME##_v_host(void *za, intptr_t off, void *host) \
276
+{ \
277
+ TYPE val = *(TYPE *)(za + tile_vslice_offset(off)); \
278
+ HOST(host, val); \
279
+} \
280
+static inline void sme_##NAME##_v_tlb(CPUARMState *env, void *za, \
281
+ intptr_t off, target_ulong addr, uintptr_t ra) \
282
+{ \
283
+ TYPE val = *(TYPE *)(za + tile_vslice_offset(off)); \
284
+ TLB(env, useronly_clean_ptr(addr), val, ra); \
285
+}
286
+
287
+/*
288
+ * The ARMVectorReg elements are stored in host-endian 64-bit units.
289
+ * For 128-bit quantities, the sequence defined by the Elem[] pseudocode
290
+ * corresponds to storing the two 64-bit pieces in little-endian order.
291
+ */
292
+#define DO_LDQ(HNAME, VNAME, BE, HOST, TLB) \
293
+static inline void HNAME##_host(void *za, intptr_t off, void *host) \
294
+{ \
295
+ uint64_t val0 = HOST(host), val1 = HOST(host + 8); \
296
+ uint64_t *ptr = za + off; \
297
+ ptr[0] = BE ? val1 : val0, ptr[1] = BE ? val0 : val1; \
298
+} \
299
+static inline void VNAME##_v_host(void *za, intptr_t off, void *host) \
300
+{ \
301
+ HNAME##_host(za, tile_vslice_offset(off), host); \
302
+} \
303
+static inline void HNAME##_tlb(CPUARMState *env, void *za, intptr_t off, \
304
+ target_ulong addr, uintptr_t ra) \
305
+{ \
306
+ uint64_t val0 = TLB(env, useronly_clean_ptr(addr), ra); \
307
+ uint64_t val1 = TLB(env, useronly_clean_ptr(addr + 8), ra); \
308
+ uint64_t *ptr = za + off; \
309
+ ptr[0] = BE ? val1 : val0, ptr[1] = BE ? val0 : val1; \
310
+} \
311
+static inline void VNAME##_v_tlb(CPUARMState *env, void *za, intptr_t off, \
312
+ target_ulong addr, uintptr_t ra) \
313
+{ \
314
+ HNAME##_tlb(env, za, tile_vslice_offset(off), addr, ra); \
315
+}
316
+
317
+#define DO_STQ(HNAME, VNAME, BE, HOST, TLB) \
318
+static inline void HNAME##_host(void *za, intptr_t off, void *host) \
319
+{ \
320
+ uint64_t *ptr = za + off; \
321
+ HOST(host, ptr[BE]); \
322
+ HOST(host + 1, ptr[!BE]); \
323
+} \
324
+static inline void VNAME##_v_host(void *za, intptr_t off, void *host) \
325
+{ \
326
+ HNAME##_host(za, tile_vslice_offset(off), host); \
327
+} \
328
+static inline void HNAME##_tlb(CPUARMState *env, void *za, intptr_t off, \
329
+ target_ulong addr, uintptr_t ra) \
330
+{ \
331
+ uint64_t *ptr = za + off; \
332
+ TLB(env, useronly_clean_ptr(addr), ptr[BE], ra); \
333
+ TLB(env, useronly_clean_ptr(addr + 8), ptr[!BE], ra); \
334
+} \
335
+static inline void VNAME##_v_tlb(CPUARMState *env, void *za, intptr_t off, \
336
+ target_ulong addr, uintptr_t ra) \
337
+{ \
338
+ HNAME##_tlb(env, za, tile_vslice_offset(off), addr, ra); \
339
+}
340
+
341
+DO_LD(ld1b, uint8_t, ldub_p, cpu_ldub_data_ra)
342
+DO_LD(ld1h_be, uint16_t, lduw_be_p, cpu_lduw_be_data_ra)
343
+DO_LD(ld1h_le, uint16_t, lduw_le_p, cpu_lduw_le_data_ra)
344
+DO_LD(ld1s_be, uint32_t, ldl_be_p, cpu_ldl_be_data_ra)
345
+DO_LD(ld1s_le, uint32_t, ldl_le_p, cpu_ldl_le_data_ra)
346
+DO_LD(ld1d_be, uint64_t, ldq_be_p, cpu_ldq_be_data_ra)
347
+DO_LD(ld1d_le, uint64_t, ldq_le_p, cpu_ldq_le_data_ra)
348
+
349
+DO_LDQ(sve_ld1qq_be, sme_ld1q_be, 1, ldq_be_p, cpu_ldq_be_data_ra)
350
+DO_LDQ(sve_ld1qq_le, sme_ld1q_le, 0, ldq_le_p, cpu_ldq_le_data_ra)
351
+
352
+DO_ST(st1b, uint8_t, stb_p, cpu_stb_data_ra)
353
+DO_ST(st1h_be, uint16_t, stw_be_p, cpu_stw_be_data_ra)
354
+DO_ST(st1h_le, uint16_t, stw_le_p, cpu_stw_le_data_ra)
355
+DO_ST(st1s_be, uint32_t, stl_be_p, cpu_stl_be_data_ra)
356
+DO_ST(st1s_le, uint32_t, stl_le_p, cpu_stl_le_data_ra)
357
+DO_ST(st1d_be, uint64_t, stq_be_p, cpu_stq_be_data_ra)
358
+DO_ST(st1d_le, uint64_t, stq_le_p, cpu_stq_le_data_ra)
359
+
360
+DO_STQ(sve_st1qq_be, sme_st1q_be, 1, stq_be_p, cpu_stq_be_data_ra)
361
+DO_STQ(sve_st1qq_le, sme_st1q_le, 0, stq_le_p, cpu_stq_le_data_ra)
362
+
363
+#undef DO_LD
364
+#undef DO_ST
365
+#undef DO_LDQ
366
+#undef DO_STQ
367
+
368
+/*
369
+ * Common helper for all contiguous predicated loads.
370
+ */
371
+
372
+static inline QEMU_ALWAYS_INLINE
373
+void sme_ld1(CPUARMState *env, void *za, uint64_t *vg,
374
+ const target_ulong addr, uint32_t desc, const uintptr_t ra,
375
+ const int esz, uint32_t mtedesc, bool vertical,
376
+ sve_ldst1_host_fn *host_fn,
377
+ sve_ldst1_tlb_fn *tlb_fn,
378
+ ClearFn *clr_fn,
379
+ CopyFn *cpy_fn)
380
+{
381
+ const intptr_t reg_max = simd_oprsz(desc);
382
+ const intptr_t esize = 1 << esz;
383
+ intptr_t reg_off, reg_last;
384
+ SVEContLdSt info;
385
+ void *host;
386
+ int flags;
387
+
388
+ /* Find the active elements. */
389
+ if (!sve_cont_ldst_elements(&info, addr, vg, reg_max, esz, esize)) {
390
+ /* The entire predicate was false; no load occurs. */
391
+ clr_fn(za, 0, reg_max);
392
+ return;
393
+ }
394
+
395
+ /* Probe the page(s). Exit with exception for any invalid page. */
396
+ sve_cont_ldst_pages(&info, FAULT_ALL, env, addr, MMU_DATA_LOAD, ra);
397
+
398
+ /* Handle watchpoints for all active elements. */
399
+ sve_cont_ldst_watchpoints(&info, env, vg, addr, esize, esize,
400
+ BP_MEM_READ, ra);
401
+
402
+ /*
403
+ * Handle mte checks for all active elements.
404
+ * Since TBI must be set for MTE, !mtedesc => !mte_active.
405
+ */
406
+ if (mtedesc) {
407
+ sve_cont_ldst_mte_check(&info, env, vg, addr, esize, esize,
408
+ mtedesc, ra);
409
+ }
410
+
411
+ flags = info.page[0].flags | info.page[1].flags;
412
+ if (unlikely(flags != 0)) {
413
+#ifdef CONFIG_USER_ONLY
414
+ g_assert_not_reached();
415
+#else
34
+ /*
416
+ /*
35
+ * Check each device to see if they fit in the PA space,
417
+ * At least one page includes MMIO.
36
+ * moving highest_gpa as we go.
418
+ * Any bus operation can fail with cpu_transaction_failed,
37
+ *
419
+ * which for ARM will raise SyncExternal. Perform the load
38
+ * For each device that doesn't fit, disable it.
420
+ * into scratch memory to preserve register state until the end.
39
+ */
421
+ */
40
+ fits = (base + size) <= BIT_ULL(pa_bits);
422
+ ARMVectorReg scratch = { };
41
+ if (fits) {
423
+
42
+ vms->highest_gpa = base + size - 1;
424
+ reg_off = info.reg_off_first[0];
425
+ reg_last = info.reg_off_last[1];
426
+ if (reg_last < 0) {
427
+ reg_last = info.reg_off_split;
428
+ if (reg_last < 0) {
429
+ reg_last = info.reg_off_last[0];
430
+ }
43
+ }
431
+ }
44
+
432
+
45
+ switch (i) {
433
+ do {
46
+ case VIRT_HIGH_GIC_REDIST2:
434
+ uint64_t pg = vg[reg_off >> 6];
47
+ vms->highmem_redists &= fits;
435
+ do {
48
+ break;
436
+ if ((pg >> (reg_off & 63)) & 1) {
49
+ case VIRT_HIGH_PCIE_ECAM:
437
+ tlb_fn(env, &scratch, reg_off, addr + reg_off, ra);
50
+ vms->highmem_ecam &= fits;
438
+ }
51
+ break;
439
+ reg_off += esize;
52
+ case VIRT_HIGH_PCIE_MMIO:
440
+ } while (reg_off & 63);
53
+ vms->highmem_mmio &= fits;
441
+ } while (reg_off <= reg_last);
54
+ break;
442
+
443
+ cpy_fn(za, &scratch, reg_max);
444
+ return;
445
+#endif
446
+ }
447
+
448
+ /* The entire operation is in RAM, on valid pages. */
449
+
450
+ reg_off = info.reg_off_first[0];
451
+ reg_last = info.reg_off_last[0];
452
+ host = info.page[0].host;
453
+
454
+ if (!vertical) {
455
+ memset(za, 0, reg_max);
456
+ } else if (reg_off) {
457
+ clr_fn(za, 0, reg_off);
458
+ }
459
+
460
+ while (reg_off <= reg_last) {
461
+ uint64_t pg = vg[reg_off >> 6];
462
+ do {
463
+ if ((pg >> (reg_off & 63)) & 1) {
464
+ host_fn(za, reg_off, host + reg_off);
465
+ } else if (vertical) {
466
+ clr_fn(za, reg_off, esize);
467
+ }
468
+ reg_off += esize;
469
+ } while (reg_off <= reg_last && (reg_off & 63));
470
+ }
471
+
472
+ /*
473
+ * Use the slow path to manage the cross-page misalignment.
474
+ * But we know this is RAM and cannot trap.
475
+ */
476
+ reg_off = info.reg_off_split;
477
+ if (unlikely(reg_off >= 0)) {
478
+ tlb_fn(env, za, reg_off, addr + reg_off, ra);
479
+ }
480
+
481
+ reg_off = info.reg_off_first[1];
482
+ if (unlikely(reg_off >= 0)) {
483
+ reg_last = info.reg_off_last[1];
484
+ host = info.page[1].host;
485
+
486
+ do {
487
+ uint64_t pg = vg[reg_off >> 6];
488
+ do {
489
+ if ((pg >> (reg_off & 63)) & 1) {
490
+ host_fn(za, reg_off, host + reg_off);
491
+ } else if (vertical) {
492
+ clr_fn(za, reg_off, esize);
493
+ }
494
+ reg_off += esize;
495
+ } while (reg_off & 63);
496
+ } while (reg_off <= reg_last);
497
+ }
498
+}
499
+
500
+static inline QEMU_ALWAYS_INLINE
501
+void sme_ld1_mte(CPUARMState *env, void *za, uint64_t *vg,
502
+ target_ulong addr, uint32_t desc, uintptr_t ra,
503
+ const int esz, bool vertical,
504
+ sve_ldst1_host_fn *host_fn,
505
+ sve_ldst1_tlb_fn *tlb_fn,
506
+ ClearFn *clr_fn,
507
+ CopyFn *cpy_fn)
508
+{
509
+ uint32_t mtedesc = desc >> (SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
510
+ int bit55 = extract64(addr, 55, 1);
511
+
512
+ /* Remove mtedesc from the normal sve descriptor. */
513
+ desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
514
+
515
+ /* Perform gross MTE suppression early. */
516
+ if (!tbi_check(desc, bit55) ||
517
+ tcma_check(desc, bit55, allocation_tag_from_addr(addr))) {
518
+ mtedesc = 0;
519
+ }
520
+
521
+ sme_ld1(env, za, vg, addr, desc, ra, esz, mtedesc, vertical,
522
+ host_fn, tlb_fn, clr_fn, cpy_fn);
523
+}
524
+
525
+#define DO_LD(L, END, ESZ) \
526
+void HELPER(sme_ld1##L##END##_h)(CPUARMState *env, void *za, void *vg, \
527
+ target_ulong addr, uint32_t desc) \
528
+{ \
529
+ sme_ld1(env, za, vg, addr, desc, GETPC(), ESZ, 0, false, \
530
+ sve_ld1##L##L##END##_host, sve_ld1##L##L##END##_tlb, \
531
+ clear_horizontal, copy_horizontal); \
532
+} \
533
+void HELPER(sme_ld1##L##END##_v)(CPUARMState *env, void *za, void *vg, \
534
+ target_ulong addr, uint32_t desc) \
535
+{ \
536
+ sme_ld1(env, za, vg, addr, desc, GETPC(), ESZ, 0, true, \
537
+ sme_ld1##L##END##_v_host, sme_ld1##L##END##_v_tlb, \
538
+ clear_vertical_##L, copy_vertical_##L); \
539
+} \
540
+void HELPER(sme_ld1##L##END##_h_mte)(CPUARMState *env, void *za, void *vg, \
541
+ target_ulong addr, uint32_t desc) \
542
+{ \
543
+ sme_ld1_mte(env, za, vg, addr, desc, GETPC(), ESZ, false, \
544
+ sve_ld1##L##L##END##_host, sve_ld1##L##L##END##_tlb, \
545
+ clear_horizontal, copy_horizontal); \
546
+} \
547
+void HELPER(sme_ld1##L##END##_v_mte)(CPUARMState *env, void *za, void *vg, \
548
+ target_ulong addr, uint32_t desc) \
549
+{ \
550
+ sme_ld1_mte(env, za, vg, addr, desc, GETPC(), ESZ, true, \
551
+ sme_ld1##L##END##_v_host, sme_ld1##L##END##_v_tlb, \
552
+ clear_vertical_##L, copy_vertical_##L); \
553
+}
554
+
555
+DO_LD(b, , MO_8)
556
+DO_LD(h, _be, MO_16)
557
+DO_LD(h, _le, MO_16)
558
+DO_LD(s, _be, MO_32)
559
+DO_LD(s, _le, MO_32)
560
+DO_LD(d, _be, MO_64)
561
+DO_LD(d, _le, MO_64)
562
+DO_LD(q, _be, MO_128)
563
+DO_LD(q, _le, MO_128)
564
+
565
+#undef DO_LD
566
+
567
+/*
568
+ * Common helper for all contiguous predicated stores.
569
+ */
570
+
571
+static inline QEMU_ALWAYS_INLINE
572
+void sme_st1(CPUARMState *env, void *za, uint64_t *vg,
573
+ const target_ulong addr, uint32_t desc, const uintptr_t ra,
574
+ const int esz, uint32_t mtedesc, bool vertical,
575
+ sve_ldst1_host_fn *host_fn,
576
+ sve_ldst1_tlb_fn *tlb_fn)
577
+{
578
+ const intptr_t reg_max = simd_oprsz(desc);
579
+ const intptr_t esize = 1 << esz;
580
+ intptr_t reg_off, reg_last;
581
+ SVEContLdSt info;
582
+ void *host;
583
+ int flags;
584
+
585
+ /* Find the active elements. */
586
+ if (!sve_cont_ldst_elements(&info, addr, vg, reg_max, esz, esize)) {
587
+ /* The entire predicate was false; no store occurs. */
588
+ return;
589
+ }
590
+
591
+ /* Probe the page(s). Exit with exception for any invalid page. */
592
+ sve_cont_ldst_pages(&info, FAULT_ALL, env, addr, MMU_DATA_STORE, ra);
593
+
594
+ /* Handle watchpoints for all active elements. */
595
+ sve_cont_ldst_watchpoints(&info, env, vg, addr, esize, esize,
596
+ BP_MEM_WRITE, ra);
597
+
598
+ /*
599
+ * Handle mte checks for all active elements.
600
+ * Since TBI must be set for MTE, !mtedesc => !mte_active.
601
+ */
602
+ if (mtedesc) {
603
+ sve_cont_ldst_mte_check(&info, env, vg, addr, esize, esize,
604
+ mtedesc, ra);
605
+ }
606
+
607
+ flags = info.page[0].flags | info.page[1].flags;
608
+ if (unlikely(flags != 0)) {
609
+#ifdef CONFIG_USER_ONLY
610
+ g_assert_not_reached();
611
+#else
612
+ /*
613
+ * At least one page includes MMIO.
614
+ * Any bus operation can fail with cpu_transaction_failed,
615
+ * which for ARM will raise SyncExternal. We cannot avoid
616
+ * this fault and will leave with the store incomplete.
617
+ */
618
+ reg_off = info.reg_off_first[0];
619
+ reg_last = info.reg_off_last[1];
620
+ if (reg_last < 0) {
621
+ reg_last = info.reg_off_split;
622
+ if (reg_last < 0) {
623
+ reg_last = info.reg_off_last[0];
624
+ }
55
+ }
625
+ }
56
+
626
+
57
base += size;
627
+ do {
58
}
628
+ uint64_t pg = vg[reg_off >> 6];
59
629
+ do {
60
- /*
630
+ if ((pg >> (reg_off & 63)) & 1) {
61
- * If base fits within pa_bits, all good. If it doesn't, limit it
631
+ tlb_fn(env, za, reg_off, addr + reg_off, ra);
62
- * to the end of RAM, which is guaranteed to fit within pa_bits.
632
+ }
63
- */
633
+ reg_off += esize;
64
- vms->highest_gpa = (base <= BIT_ULL(pa_bits) ? base : memtop) - 1;
634
+ } while (reg_off & 63);
65
-
635
+ } while (reg_off <= reg_last);
66
if (device_memory_size > 0) {
636
+ return;
67
ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
637
+#endif
68
ms->device_memory->base = device_memory_base;
638
+ }
639
+
640
+ reg_off = info.reg_off_first[0];
641
+ reg_last = info.reg_off_last[0];
642
+ host = info.page[0].host;
643
+
644
+ while (reg_off <= reg_last) {
645
+ uint64_t pg = vg[reg_off >> 6];
646
+ do {
647
+ if ((pg >> (reg_off & 63)) & 1) {
648
+ host_fn(za, reg_off, host + reg_off);
649
+ }
650
+ reg_off += 1 << esz;
651
+ } while (reg_off <= reg_last && (reg_off & 63));
652
+ }
653
+
654
+ /*
655
+ * Use the slow path to manage the cross-page misalignment.
656
+ * But we know this is RAM and cannot trap.
657
+ */
658
+ reg_off = info.reg_off_split;
659
+ if (unlikely(reg_off >= 0)) {
660
+ tlb_fn(env, za, reg_off, addr + reg_off, ra);
661
+ }
662
+
663
+ reg_off = info.reg_off_first[1];
664
+ if (unlikely(reg_off >= 0)) {
665
+ reg_last = info.reg_off_last[1];
666
+ host = info.page[1].host;
667
+
668
+ do {
669
+ uint64_t pg = vg[reg_off >> 6];
670
+ do {
671
+ if ((pg >> (reg_off & 63)) & 1) {
672
+ host_fn(za, reg_off, host + reg_off);
673
+ }
674
+ reg_off += 1 << esz;
675
+ } while (reg_off & 63);
676
+ } while (reg_off <= reg_last);
677
+ }
678
+}
679
+
680
+static inline QEMU_ALWAYS_INLINE
681
+void sme_st1_mte(CPUARMState *env, void *za, uint64_t *vg, target_ulong addr,
682
+ uint32_t desc, uintptr_t ra, int esz, bool vertical,
683
+ sve_ldst1_host_fn *host_fn,
684
+ sve_ldst1_tlb_fn *tlb_fn)
685
+{
686
+ uint32_t mtedesc = desc >> (SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
687
+ int bit55 = extract64(addr, 55, 1);
688
+
689
+ /* Remove mtedesc from the normal sve descriptor. */
690
+ desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT);
691
+
692
+ /* Perform gross MTE suppression early. */
693
+ if (!tbi_check(desc, bit55) ||
694
+ tcma_check(desc, bit55, allocation_tag_from_addr(addr))) {
695
+ mtedesc = 0;
696
+ }
697
+
698
+ sme_st1(env, za, vg, addr, desc, ra, esz, mtedesc,
699
+ vertical, host_fn, tlb_fn);
700
+}
701
+
702
+#define DO_ST(L, END, ESZ) \
703
+void HELPER(sme_st1##L##END##_h)(CPUARMState *env, void *za, void *vg, \
704
+ target_ulong addr, uint32_t desc) \
705
+{ \
706
+ sme_st1(env, za, vg, addr, desc, GETPC(), ESZ, 0, false, \
707
+ sve_st1##L##L##END##_host, sve_st1##L##L##END##_tlb); \
708
+} \
709
+void HELPER(sme_st1##L##END##_v)(CPUARMState *env, void *za, void *vg, \
710
+ target_ulong addr, uint32_t desc) \
711
+{ \
712
+ sme_st1(env, za, vg, addr, desc, GETPC(), ESZ, 0, true, \
713
+ sme_st1##L##END##_v_host, sme_st1##L##END##_v_tlb); \
714
+} \
715
+void HELPER(sme_st1##L##END##_h_mte)(CPUARMState *env, void *za, void *vg, \
716
+ target_ulong addr, uint32_t desc) \
717
+{ \
718
+ sme_st1_mte(env, za, vg, addr, desc, GETPC(), ESZ, false, \
719
+ sve_st1##L##L##END##_host, sve_st1##L##L##END##_tlb); \
720
+} \
721
+void HELPER(sme_st1##L##END##_v_mte)(CPUARMState *env, void *za, void *vg, \
722
+ target_ulong addr, uint32_t desc) \
723
+{ \
724
+ sme_st1_mte(env, za, vg, addr, desc, GETPC(), ESZ, true, \
725
+ sme_st1##L##END##_v_host, sme_st1##L##END##_v_tlb); \
726
+}
727
+
728
+DO_ST(b, , MO_8)
729
+DO_ST(h, _be, MO_16)
730
+DO_ST(h, _le, MO_16)
731
+DO_ST(s, _be, MO_32)
732
+DO_ST(s, _le, MO_32)
733
+DO_ST(d, _be, MO_64)
734
+DO_ST(d, _le, MO_64)
735
+DO_ST(q, _be, MO_128)
736
+DO_ST(q, _le, MO_128)
737
+
738
+#undef DO_ST
739
diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c
740
index XXXXXXX..XXXXXXX 100644
741
--- a/target/arm/translate-sme.c
742
+++ b/target/arm/translate-sme.c
743
@@ -XXX,XX +XXX,XX @@ static bool trans_MOVA(DisasContext *s, arg_MOVA *a)
744
745
return true;
746
}
747
+
748
+static bool trans_LDST1(DisasContext *s, arg_LDST1 *a)
749
+{
750
+ typedef void GenLdSt1(TCGv_env, TCGv_ptr, TCGv_ptr, TCGv, TCGv_i32);
751
+
752
+ /*
753
+ * Indexed by [esz][be][v][mte][st], which is (except for load/store)
754
+ * also the order in which the elements appear in the function names,
755
+ * and so how we must concatenate the pieces.
756
+ */
757
+
758
+#define FN_LS(F) { gen_helper_sme_ld1##F, gen_helper_sme_st1##F }
759
+#define FN_MTE(F) { FN_LS(F), FN_LS(F##_mte) }
760
+#define FN_HV(F) { FN_MTE(F##_h), FN_MTE(F##_v) }
761
+#define FN_END(L, B) { FN_HV(L), FN_HV(B) }
762
+
763
+ static GenLdSt1 * const fns[5][2][2][2][2] = {
764
+ FN_END(b, b),
765
+ FN_END(h_le, h_be),
766
+ FN_END(s_le, s_be),
767
+ FN_END(d_le, d_be),
768
+ FN_END(q_le, q_be),
769
+ };
770
+
771
+#undef FN_LS
772
+#undef FN_MTE
773
+#undef FN_HV
774
+#undef FN_END
775
+
776
+ TCGv_ptr t_za, t_pg;
777
+ TCGv_i64 addr;
778
+ int svl, desc = 0;
779
+ bool be = s->be_data == MO_BE;
780
+ bool mte = s->mte_active[0];
781
+
782
+ if (!dc_isar_feature(aa64_sme, s)) {
783
+ return false;
784
+ }
785
+ if (!sme_smza_enabled_check(s)) {
786
+ return true;
787
+ }
788
+
789
+ t_za = get_tile_rowcol(s, a->esz, a->rs, a->za_imm, a->v);
790
+ t_pg = pred_full_reg_ptr(s, a->pg);
791
+ addr = tcg_temp_new_i64();
792
+
793
+ tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), a->esz);
794
+ tcg_gen_add_i64(addr, addr, cpu_reg_sp(s, a->rn));
795
+
796
+ if (mte) {
797
+ desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s));
798
+ desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid);
799
+ desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma);
800
+ desc = FIELD_DP32(desc, MTEDESC, WRITE, a->st);
801
+ desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (1 << a->esz) - 1);
802
+ desc <<= SVE_MTEDESC_SHIFT;
803
+ } else {
804
+ addr = clean_data_tbi(s, addr);
805
+ }
806
+ svl = streaming_vec_reg_size(s);
807
+ desc = simd_desc(svl, svl, desc);
808
+
809
+ fns[a->esz][be][a->v][mte][a->st](cpu_env, t_za, t_pg, addr,
810
+ tcg_constant_i32(desc));
811
+
812
+ tcg_temp_free_ptr(t_za);
813
+ tcg_temp_free_ptr(t_pg);
814
+ tcg_temp_free_i64(addr);
815
+ return true;
816
+}
69
--
817
--
70
2.25.1
818
2.25.1
71
72
diff view generated by jsdifflib
1
When an ITS detects an error in a command, it has an
1
From: Richard Henderson <richard.henderson@linaro.org>
2
implementation-defined (CONSTRAINED UNPREDICTABLE) choice of whether
3
to ignore the command, proceeding to the next one in the queue, or to
4
stall the ITS command queue, processing nothing further. The
5
behaviour required when the read of the command packet from memory
6
fails is less clearly documented, but the same set of choices as for
7
command errors seem reasonable.
8
2
9
The intention of the QEMU implementation, as documented in the
3
Add a TCGv_ptr base argument, which will be cpu_env for SVE.
10
comments, is that if we encounter a memory error reading the command
4
We will reuse this for SME save and restore array insns.
11
packet or one of the various data tables then we should stall, but
12
for command parameter errors we should ignore the queue and continue.
13
However, we don't actually do this. To get the desired behaviour,
14
the various process_* functions need to return true to cause
15
process_cmdq() to advance to the next command and keep processing,
16
and false to stall command processing. What they mostly do is return
17
false for any kind of error.
18
5
19
To make the code clearer, replace the 'bool' return from the process_
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
20
functions with an enum which may be either CMD_STALL or CMD_CONTINUE.
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
21
In this commit no behaviour changes; in subsequent commits we will
8
Message-id: 20220708151540.18136-22-richard.henderson@linaro.org
22
adjust the error-return paths for the process_ functions one by one.
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/translate-a64.h | 3 +++
12
target/arm/translate-sve.c | 48 ++++++++++++++++++++++++++++----------
13
2 files changed, 39 insertions(+), 12 deletions(-)
23
14
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h
25
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
26
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
27
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
28
Message-id: 20220111171048.3545974-6-peter.maydell@linaro.org
29
---
30
hw/intc/arm_gicv3_its.c | 59 ++++++++++++++++++++++++++---------------
31
1 file changed, 38 insertions(+), 21 deletions(-)
32
33
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
34
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/intc/arm_gicv3_its.c
17
--- a/target/arm/translate-a64.h
36
+++ b/hw/intc/arm_gicv3_its.c
18
+++ b/target/arm/translate-a64.h
37
@@ -XXX,XX +XXX,XX @@ typedef struct {
19
@@ -XXX,XX +XXX,XX @@ void gen_gvec_xar(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
38
uint64_t itel;
20
uint32_t rm_ofs, int64_t shift,
39
} IteEntry;
21
uint32_t opr_sz, uint32_t max_sz);
40
22
41
+/*
23
+void gen_sve_ldr(DisasContext *s, TCGv_ptr, int vofs, int len, int rn, int imm);
42
+ * The ITS spec permits a range of CONSTRAINED UNPREDICTABLE options
24
+void gen_sve_str(DisasContext *s, TCGv_ptr, int vofs, int len, int rn, int imm);
43
+ * if a command parameter is not correct. These include both "stall
44
+ * processing of the command queue" and "ignore this command, and
45
+ * keep processing the queue". In our implementation we choose that
46
+ * memory transaction errors reading the command packet provoke a
47
+ * stall, but errors in parameters cause us to ignore the command
48
+ * and continue processing.
49
+ * The process_* functions which handle individual ITS commands all
50
+ * return an ItsCmdResult which tells process_cmdq() whether it should
51
+ * stall or keep going.
52
+ */
53
+typedef enum ItsCmdResult {
54
+ CMD_STALL = 0,
55
+ CMD_CONTINUE = 1,
56
+} ItsCmdResult;
57
+
25
+
58
static uint64_t baser_base_addr(uint64_t value, uint32_t page_sz)
26
#endif /* TARGET_ARM_TRANSLATE_A64_H */
27
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/translate-sve.c
30
+++ b/target/arm/translate-sve.c
31
@@ -XXX,XX +XXX,XX @@ TRANS_FEAT(UCVTF_dd, aa64_sve, gen_gvec_fpst_arg_zpz,
32
* The load should begin at the address Rn + IMM.
33
*/
34
35
-static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
36
+void gen_sve_ldr(DisasContext *s, TCGv_ptr base, int vofs,
37
+ int len, int rn, int imm)
59
{
38
{
60
uint64_t result = 0;
39
int len_align = QEMU_ALIGN_DOWN(len, 8);
61
@@ -XXX,XX +XXX,XX @@ static uint64_t get_dte(GICv3ITSState *s, uint32_t devid, MemTxResult *res)
40
int len_remain = len % 8;
62
* 3. handling of ITS CLEAR command
41
@@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
63
* 4. handling of ITS DISCARD command
42
t0 = tcg_temp_new_i64();
64
*/
43
for (i = 0; i < len_align; i += 8) {
65
-static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
44
tcg_gen_qemu_ld_i64(t0, clean_addr, midx, MO_LEUQ);
66
- ItsCmdType cmd)
45
- tcg_gen_st_i64(t0, cpu_env, vofs + i);
67
+static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
46
+ tcg_gen_st_i64(t0, base, vofs + i);
68
+ uint32_t offset, ItsCmdType cmd)
47
tcg_gen_addi_i64(clean_addr, clean_addr, 8);
69
{
70
AddressSpace *as = &s->gicv3->dma_as;
71
uint32_t devid, eventid;
72
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
73
bool ite_valid = false;
74
uint64_t cte = 0;
75
bool cte_valid = false;
76
- bool result = false;
77
+ ItsCmdResult result = CMD_STALL;
78
uint64_t rdbase;
79
80
if (cmd == NONE) {
81
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
82
if (cmd == DISCARD) {
83
IteEntry ite = {};
84
/* remove mapping from interrupt translation table */
85
- result = update_ite(s, eventid, dte, ite);
86
+ result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
87
}
48
}
49
tcg_temp_free_i64(t0);
50
@@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
51
clean_addr = new_tmp_a64_local(s);
52
tcg_gen_mov_i64(clean_addr, t0);
53
54
+ if (base != cpu_env) {
55
+ TCGv_ptr b = tcg_temp_local_new_ptr();
56
+ tcg_gen_mov_ptr(b, base);
57
+ base = b;
58
+ }
59
+
60
gen_set_label(loop);
61
62
t0 = tcg_temp_new_i64();
63
@@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
64
tcg_gen_addi_i64(clean_addr, clean_addr, 8);
65
66
tp = tcg_temp_new_ptr();
67
- tcg_gen_add_ptr(tp, cpu_env, i);
68
+ tcg_gen_add_ptr(tp, base, i);
69
tcg_gen_addi_ptr(i, i, 8);
70
tcg_gen_st_i64(t0, tp, vofs);
71
tcg_temp_free_ptr(tp);
72
@@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
73
74
tcg_gen_brcondi_ptr(TCG_COND_LTU, i, len_align, loop);
75
tcg_temp_free_ptr(i);
76
+
77
+ if (base != cpu_env) {
78
+ tcg_temp_free_ptr(base);
79
+ assert(len_remain == 0);
80
+ }
88
}
81
}
89
82
90
return result;
83
/*
91
}
84
@@ -XXX,XX +XXX,XX @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
92
85
default:
93
-static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
86
g_assert_not_reached();
94
- bool ignore_pInt)
87
}
95
+static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
88
- tcg_gen_st_i64(t0, cpu_env, vofs + len_align);
96
+ uint32_t offset, bool ignore_pInt)
89
+ tcg_gen_st_i64(t0, base, vofs + len_align);
97
{
90
tcg_temp_free_i64(t0);
98
AddressSpace *as = &s->gicv3->dma_as;
99
uint32_t devid, eventid;
100
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
101
MemTxResult res = MEMTX_OK;
102
uint16_t icid = 0;
103
uint64_t dte = 0;
104
- bool result = false;
105
+ ItsCmdResult result = CMD_STALL;
106
107
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
108
offset += NUM_BYTES_IN_DW;
109
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
110
ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS);
111
ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid);
112
113
- result = update_ite(s, eventid, dte, ite);
114
+ result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
115
}
116
117
return result;
118
@@ -XXX,XX +XXX,XX @@ static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
119
}
91
}
120
}
92
}
121
93
122
-static bool process_mapc(GICv3ITSState *s, uint32_t offset)
94
/* Similarly for stores. */
123
+static ItsCmdResult process_mapc(GICv3ITSState *s, uint32_t offset)
95
-static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
96
+void gen_sve_str(DisasContext *s, TCGv_ptr base, int vofs,
97
+ int len, int rn, int imm)
124
{
98
{
125
AddressSpace *as = &s->gicv3->dma_as;
99
int len_align = QEMU_ALIGN_DOWN(len, 8);
126
uint16_t icid;
100
int len_remain = len % 8;
127
uint64_t rdbase;
101
@@ -XXX,XX +XXX,XX @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
128
bool valid;
102
129
MemTxResult res = MEMTX_OK;
103
t0 = tcg_temp_new_i64();
130
- bool result = false;
104
for (i = 0; i < len_align; i += 8) {
131
+ ItsCmdResult result = CMD_STALL;
105
- tcg_gen_ld_i64(t0, cpu_env, vofs + i);
132
uint64_t value;
106
+ tcg_gen_ld_i64(t0, base, vofs + i);
133
107
tcg_gen_qemu_st_i64(t0, clean_addr, midx, MO_LEUQ);
134
offset += NUM_BYTES_IN_DW;
108
tcg_gen_addi_i64(clean_addr, clean_addr, 8);
135
@@ -XXX,XX +XXX,XX @@ static bool process_mapc(GICv3ITSState *s, uint32_t offset)
109
}
136
* command in the queue
110
@@ -XXX,XX +XXX,XX @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
137
*/
111
clean_addr = new_tmp_a64_local(s);
138
} else {
112
tcg_gen_mov_i64(clean_addr, t0);
139
- result = update_cte(s, icid, valid, rdbase);
113
140
+ result = update_cte(s, icid, valid, rdbase) ? CMD_CONTINUE : CMD_STALL;
114
+ if (base != cpu_env) {
115
+ TCGv_ptr b = tcg_temp_local_new_ptr();
116
+ tcg_gen_mov_ptr(b, base);
117
+ base = b;
118
+ }
119
+
120
gen_set_label(loop);
121
122
t0 = tcg_temp_new_i64();
123
tp = tcg_temp_new_ptr();
124
- tcg_gen_add_ptr(tp, cpu_env, i);
125
+ tcg_gen_add_ptr(tp, base, i);
126
tcg_gen_ld_i64(t0, tp, vofs);
127
tcg_gen_addi_ptr(i, i, 8);
128
tcg_temp_free_ptr(tp);
129
@@ -XXX,XX +XXX,XX @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm)
130
131
tcg_gen_brcondi_ptr(TCG_COND_LTU, i, len_align, loop);
132
tcg_temp_free_ptr(i);
133
+
134
+ if (base != cpu_env) {
135
+ tcg_temp_free_ptr(base);
136
+ assert(len_remain == 0);
137
+ }
141
}
138
}
142
139
143
return result;
140
/* Predicate register stores can be any multiple of 2. */
144
@@ -XXX,XX +XXX,XX @@ static bool update_dte(GICv3ITSState *s, uint32_t devid, bool valid,
141
if (len_remain) {
142
t0 = tcg_temp_new_i64();
143
- tcg_gen_ld_i64(t0, cpu_env, vofs + len_align);
144
+ tcg_gen_ld_i64(t0, base, vofs + len_align);
145
146
switch (len_remain) {
147
case 2:
148
@@ -XXX,XX +XXX,XX @@ static bool trans_LDR_zri(DisasContext *s, arg_rri *a)
149
if (sve_access_check(s)) {
150
int size = vec_full_reg_size(s);
151
int off = vec_full_reg_offset(s, a->rd);
152
- do_ldr(s, off, size, a->rn, a->imm * size);
153
+ gen_sve_ldr(s, cpu_env, off, size, a->rn, a->imm * size);
145
}
154
}
155
return true;
146
}
156
}
147
157
@@ -XXX,XX +XXX,XX @@ static bool trans_LDR_pri(DisasContext *s, arg_rri *a)
148
-static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset)
158
if (sve_access_check(s)) {
149
+static ItsCmdResult process_mapd(GICv3ITSState *s, uint64_t value,
159
int size = pred_full_reg_size(s);
150
+ uint32_t offset)
160
int off = pred_full_reg_offset(s, a->rd);
151
{
161
- do_ldr(s, off, size, a->rn, a->imm * size);
152
AddressSpace *as = &s->gicv3->dma_as;
162
+ gen_sve_ldr(s, cpu_env, off, size, a->rn, a->imm * size);
153
uint32_t devid;
154
@@ -XXX,XX +XXX,XX @@ static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset)
155
uint64_t itt_addr;
156
bool valid;
157
MemTxResult res = MEMTX_OK;
158
- bool result = false;
159
+ ItsCmdResult result = CMD_STALL;
160
161
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
162
163
@@ -XXX,XX +XXX,XX @@ static bool process_mapd(GICv3ITSState *s, uint64_t value, uint32_t offset)
164
* command in the queue
165
*/
166
} else {
167
- result = update_dte(s, devid, valid, size, itt_addr);
168
+ result = update_dte(s, devid, valid, size, itt_addr) ? CMD_CONTINUE : CMD_STALL;
169
}
163
}
170
164
return true;
171
return result;
165
}
172
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
166
@@ -XXX,XX +XXX,XX @@ static bool trans_STR_zri(DisasContext *s, arg_rri *a)
173
uint64_t data;
167
if (sve_access_check(s)) {
174
AddressSpace *as = &s->gicv3->dma_as;
168
int size = vec_full_reg_size(s);
175
MemTxResult res = MEMTX_OK;
169
int off = vec_full_reg_offset(s, a->rd);
176
- bool result = true;
170
- do_str(s, off, size, a->rn, a->imm * size);
177
uint8_t cmd;
171
+ gen_sve_str(s, cpu_env, off, size, a->rn, a->imm * size);
178
int i;
179
180
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
181
}
172
}
182
173
return true;
183
while (wr_offset != rd_offset) {
174
}
184
+ ItsCmdResult result = CMD_CONTINUE;
175
@@ -XXX,XX +XXX,XX @@ static bool trans_STR_pri(DisasContext *s, arg_rri *a)
185
+
176
if (sve_access_check(s)) {
186
cq_offset = (rd_offset * GITS_CMDQ_ENTRY_SIZE);
177
int size = pred_full_reg_size(s);
187
data = address_space_ldq_le(as, s->cq.base_addr + cq_offset,
178
int off = pred_full_reg_offset(s, a->rd);
188
MEMTXATTRS_UNSPECIFIED, &res);
179
- do_str(s, off, size, a->rn, a->imm * size);
189
@@ -XXX,XX +XXX,XX @@ static void process_cmdq(GICv3ITSState *s)
180
+ gen_sve_str(s, cpu_env, off, size, a->rn, a->imm * size);
190
default:
191
break;
192
}
193
- if (result) {
194
+ if (result == CMD_CONTINUE) {
195
rd_offset++;
196
rd_offset %= s->cq.num_entries;
197
s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, OFFSET, rd_offset);
198
} else {
199
- /*
200
- * in this implementation, in case of dma read/write error
201
- * we stall the command processing
202
- */
203
+ /* CMD_STALL */
204
s->creadr = FIELD_DP64(s->creadr, GITS_CREADR, STALLED, 1);
205
qemu_log_mask(LOG_GUEST_ERROR,
206
- "%s: %x cmd processing failed\n", __func__, cmd);
207
+ "%s: 0x%x cmd processing failed, stalling\n",
208
+ __func__, cmd);
209
break;
210
}
211
}
181
}
182
return true;
183
}
212
--
184
--
213
2.25.1
185
2.25.1
214
215
diff view generated by jsdifflib
1
In process_its_cmd(), we read an ICID out of the interrupt table
1
From: Richard Henderson <richard.henderson@linaro.org>
2
entry, and then use it as an index into the collection table. Add a
3
check that it is within range for the collection table first.
4
2
5
This check is not strictly necessary, because:
3
We can reuse the SVE functions for LDR and STR, passing in the
6
* we range check the ICID from the guest before writing it into
4
base of the ZA vector and a zero offset.
7
the interrupt table entry, so the the only way to get an
8
out of range ICID in process_its_cmd() is if a badly-behaved
9
guest is writing directly to the interrupt table memory
10
* the collection table is in guest memory, so QEMU won't fall
11
over if we read off the end of it
12
5
13
However, it seems clearer to include the check.
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-23-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/sme.decode | 7 +++++++
12
target/arm/translate-sme.c | 24 ++++++++++++++++++++++++
13
2 files changed, 31 insertions(+)
14
14
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
diff --git a/target/arm/sme.decode b/target/arm/sme.decode
16
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
17
Message-id: 20220111171048.3545974-14-peter.maydell@linaro.org
18
---
19
hw/intc/arm_gicv3_its.c | 7 +++++++
20
1 file changed, 7 insertions(+)
21
22
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
23
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
24
--- a/hw/intc/arm_gicv3_its.c
17
--- a/target/arm/sme.decode
25
+++ b/hw/intc/arm_gicv3_its.c
18
+++ b/target/arm/sme.decode
26
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
19
@@ -XXX,XX +XXX,XX @@ LDST1 1110000 0 esz:2 st:1 rm:5 v:1 .. pg:3 rn:5 0 za_imm:4 \
27
return CMD_CONTINUE;
20
&ldst rs=%mova_rs
28
}
21
LDST1 1110000 111 st:1 rm:5 v:1 .. pg:3 rn:5 0 za_imm:4 \
29
22
&ldst esz=4 rs=%mova_rs
30
+ if (icid >= s->ct.num_ids) {
23
+
31
+ qemu_log_mask(LOG_GUEST_ERROR,
24
+&ldstr rv rn imm
32
+ "%s: invalid ICID 0x%x in ITE (table corrupted?)\n",
25
+@ldstr ....... ... . ...... .. ... rn:5 . imm:4 \
33
+ __func__, icid);
26
+ &ldstr rv=%mova_rs
34
+ return CMD_CONTINUE;
27
+
28
+LDR 1110000 100 0 000000 .. 000 ..... 0 .... @ldstr
29
+STR 1110000 100 1 000000 .. 000 ..... 0 .... @ldstr
30
diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/translate-sme.c
33
+++ b/target/arm/translate-sme.c
34
@@ -XXX,XX +XXX,XX @@ static bool trans_LDST1(DisasContext *s, arg_LDST1 *a)
35
tcg_temp_free_i64(addr);
36
return true;
37
}
38
+
39
+typedef void GenLdStR(DisasContext *, TCGv_ptr, int, int, int, int);
40
+
41
+static bool do_ldst_r(DisasContext *s, arg_ldstr *a, GenLdStR *fn)
42
+{
43
+ int svl = streaming_vec_reg_size(s);
44
+ int imm = a->imm;
45
+ TCGv_ptr base;
46
+
47
+ if (!sme_za_enabled_check(s)) {
48
+ return true;
35
+ }
49
+ }
36
+
50
+
37
cte_valid = get_cte(s, icid, &cte, &res);
51
+ /* ZA[n] equates to ZA0H.B[n]. */
38
if (res != MEMTX_OK) {
52
+ base = get_tile_rowcol(s, MO_8, a->rv, imm, false);
39
return CMD_STALL;
53
+
54
+ fn(s, base, 0, svl, a->rn, imm * svl);
55
+
56
+ tcg_temp_free_ptr(base);
57
+ return true;
58
+}
59
+
60
+TRANS_FEAT(LDR, aa64_sme, do_ldst_r, a, gen_sve_ldr)
61
+TRANS_FEAT(STR, aa64_sme, do_ldst_r, a, gen_sve_str)
40
--
62
--
41
2.25.1
63
2.25.1
42
43
diff view generated by jsdifflib
1
From: Troy Lee <troy_lee@aspeedtech.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Aspeed 2600 SDK enables I3C support by default. The I3C driver will try
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
to reset the device controller and set it up through device address table
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
register. This dummy model responds to these registers with default values
5
Message-id: 20220708151540.18136-24-richard.henderson@linaro.org
6
as listed in the ast2600v10 datasheet chapter 54.2.
7
8
This avoids a guest machine kernel panic due to referencing an
9
invalid kernel address if the device address table register isn't
10
set correctly.
11
12
Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
13
Reviewed-by: Graeme Gregory <quic_ggregory@quicinc.com>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
15
Tested-by: Graeme Gregory <quic_ggregory@quicinc.com>
16
Message-id: 20220111084546.4145785-2-troy_lee@aspeedtech.com
17
[PMM: tidied commit message]
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
7
---
20
include/hw/misc/aspeed_i3c.h | 48 +++++
8
target/arm/helper-sme.h | 5 +++
21
hw/misc/aspeed_i3c.c | 381 +++++++++++++++++++++++++++++++++++
9
target/arm/sme.decode | 11 +++++
22
hw/misc/meson.build | 1 +
10
target/arm/sme_helper.c | 90 ++++++++++++++++++++++++++++++++++++++
23
hw/misc/trace-events | 6 +
11
target/arm/translate-sme.c | 31 +++++++++++++
24
4 files changed, 436 insertions(+)
12
4 files changed, 137 insertions(+)
25
create mode 100644 include/hw/misc/aspeed_i3c.h
26
create mode 100644 hw/misc/aspeed_i3c.c
27
13
28
diff --git a/include/hw/misc/aspeed_i3c.h b/include/hw/misc/aspeed_i3c.h
14
diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h
29
new file mode 100644
15
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX
16
--- a/target/arm/helper-sme.h
31
--- /dev/null
17
+++ b/target/arm/helper-sme.h
32
+++ b/include/hw/misc/aspeed_i3c.h
18
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(sme_st1q_be_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i
33
@@ -XXX,XX +XXX,XX @@
19
DEF_HELPER_FLAGS_5(sme_st1q_le_h_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
34
+/*
20
DEF_HELPER_FLAGS_5(sme_st1q_be_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
35
+ * ASPEED I3C Controller
21
DEF_HELPER_FLAGS_5(sme_st1q_le_v_mte, TCG_CALL_NO_WG, void, env, ptr, ptr, tl, i32)
36
+ *
37
+ * Copyright (C) 2021 ASPEED Technology Inc.
38
+ *
39
+ * This code is licensed under the GPL version 2 or later. See
40
+ * the COPYING file in the top-level directory.
41
+ */
42
+
22
+
43
+#ifndef ASPEED_I3C_H
23
+DEF_HELPER_FLAGS_5(sme_addha_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
44
+#define ASPEED_I3C_H
24
+DEF_HELPER_FLAGS_5(sme_addva_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
25
+DEF_HELPER_FLAGS_5(sme_addha_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
26
+DEF_HELPER_FLAGS_5(sme_addva_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
27
diff --git a/target/arm/sme.decode b/target/arm/sme.decode
28
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/sme.decode
30
+++ b/target/arm/sme.decode
31
@@ -XXX,XX +XXX,XX @@ LDST1 1110000 111 st:1 rm:5 v:1 .. pg:3 rn:5 0 za_imm:4 \
32
33
LDR 1110000 100 0 000000 .. 000 ..... 0 .... @ldstr
34
STR 1110000 100 1 000000 .. 000 ..... 0 .... @ldstr
45
+
35
+
46
+#include "hw/sysbus.h"
36
+### SME Add Vector to Array
47
+
37
+
48
+#define TYPE_ASPEED_I3C "aspeed.i3c"
38
+&adda zad zn pm pn
49
+#define TYPE_ASPEED_I3C_DEVICE "aspeed.i3c.device"
39
+@adda_32 ........ .. ..... . pm:3 pn:3 zn:5 ... zad:2 &adda
50
+OBJECT_DECLARE_TYPE(AspeedI3CState, AspeedI3CClass, ASPEED_I3C)
40
+@adda_64 ........ .. ..... . pm:3 pn:3 zn:5 .. zad:3 &adda
51
+
41
+
52
+#define ASPEED_I3C_NR_REGS (0x70 >> 2)
42
+ADDHA_s 11000000 10 01000 0 ... ... ..... 000 .. @adda_32
53
+#define ASPEED_I3C_DEVICE_NR_REGS (0x300 >> 2)
43
+ADDVA_s 11000000 10 01000 1 ... ... ..... 000 .. @adda_32
54
+#define ASPEED_I3C_NR_DEVICES 6
44
+ADDHA_d 11000000 11 01000 0 ... ... ..... 00 ... @adda_64
45
+ADDVA_d 11000000 11 01000 1 ... ... ..... 00 ... @adda_64
46
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/arm/sme_helper.c
49
+++ b/target/arm/sme_helper.c
50
@@ -XXX,XX +XXX,XX @@ DO_ST(q, _be, MO_128)
51
DO_ST(q, _le, MO_128)
52
53
#undef DO_ST
55
+
54
+
56
+OBJECT_DECLARE_SIMPLE_TYPE(AspeedI3CDevice, ASPEED_I3C_DEVICE)
55
+void HELPER(sme_addha_s)(void *vzda, void *vzn, void *vpn,
57
+typedef struct AspeedI3CDevice {
56
+ void *vpm, uint32_t desc)
58
+ /* <private> */
57
+{
59
+ SysBusDevice parent;
58
+ intptr_t row, col, oprsz = simd_oprsz(desc) / 4;
59
+ uint64_t *pn = vpn, *pm = vpm;
60
+ uint32_t *zda = vzda, *zn = vzn;
60
+
61
+
61
+ /* <public> */
62
+ for (row = 0; row < oprsz; ) {
62
+ MemoryRegion mr;
63
+ uint64_t pa = pn[row >> 4];
63
+ qemu_irq irq;
64
+ do {
64
+
65
+ if (pa & 1) {
65
+ uint8_t id;
66
+ for (col = 0; col < oprsz; ) {
66
+ uint32_t regs[ASPEED_I3C_DEVICE_NR_REGS];
67
+ uint64_t pb = pm[col >> 4];
67
+} AspeedI3CDevice;
68
+ do {
68
+
69
+ if (pb & 1) {
69
+typedef struct AspeedI3CState {
70
+ zda[tile_vslice_index(row) + H4(col)] += zn[H4(col)];
70
+ /* <private> */
71
+ }
71
+ SysBusDevice parent;
72
+ pb >>= 4;
72
+
73
+ } while (++col & 15);
73
+ /* <public> */
74
+ }
74
+ MemoryRegion iomem;
75
+ }
75
+ MemoryRegion iomem_container;
76
+ pa >>= 4;
76
+ qemu_irq irq;
77
+ } while (++row & 15);
77
+
78
+ uint32_t regs[ASPEED_I3C_NR_REGS];
79
+ AspeedI3CDevice devices[ASPEED_I3C_NR_DEVICES];
80
+} AspeedI3CState;
81
+#endif /* ASPEED_I3C_H */
82
diff --git a/hw/misc/aspeed_i3c.c b/hw/misc/aspeed_i3c.c
83
new file mode 100644
84
index XXXXXXX..XXXXXXX
85
--- /dev/null
86
+++ b/hw/misc/aspeed_i3c.c
87
@@ -XXX,XX +XXX,XX @@
88
+/*
89
+ * ASPEED I3C Controller
90
+ *
91
+ * Copyright (C) 2021 ASPEED Technology Inc.
92
+ *
93
+ * This code is licensed under the GPL version 2 or later. See
94
+ * the COPYING file in the top-level directory.
95
+ */
96
+
97
+#include "qemu/osdep.h"
98
+#include "qemu/log.h"
99
+#include "qemu/error-report.h"
100
+#include "hw/misc/aspeed_i3c.h"
101
+#include "hw/registerfields.h"
102
+#include "hw/qdev-properties.h"
103
+#include "qapi/error.h"
104
+#include "migration/vmstate.h"
105
+#include "trace.h"
106
+
107
+/* I3C Controller Registers */
108
+REG32(I3C1_REG0, 0x10)
109
+REG32(I3C1_REG1, 0x14)
110
+ FIELD(I3C1_REG1, I2C_MODE, 0, 1)
111
+ FIELD(I3C1_REG1, SA_EN, 15, 1)
112
+REG32(I3C2_REG0, 0x20)
113
+REG32(I3C2_REG1, 0x24)
114
+ FIELD(I3C2_REG1, I2C_MODE, 0, 1)
115
+ FIELD(I3C2_REG1, SA_EN, 15, 1)
116
+REG32(I3C3_REG0, 0x30)
117
+REG32(I3C3_REG1, 0x34)
118
+ FIELD(I3C3_REG1, I2C_MODE, 0, 1)
119
+ FIELD(I3C3_REG1, SA_EN, 15, 1)
120
+REG32(I3C4_REG0, 0x40)
121
+REG32(I3C4_REG1, 0x44)
122
+ FIELD(I3C4_REG1, I2C_MODE, 0, 1)
123
+ FIELD(I3C4_REG1, SA_EN, 15, 1)
124
+REG32(I3C5_REG0, 0x50)
125
+REG32(I3C5_REG1, 0x54)
126
+ FIELD(I3C5_REG1, I2C_MODE, 0, 1)
127
+ FIELD(I3C5_REG1, SA_EN, 15, 1)
128
+REG32(I3C6_REG0, 0x60)
129
+REG32(I3C6_REG1, 0x64)
130
+ FIELD(I3C6_REG1, I2C_MODE, 0, 1)
131
+ FIELD(I3C6_REG1, SA_EN, 15, 1)
132
+
133
+/* I3C Device Registers */
134
+REG32(DEVICE_CTRL, 0x00)
135
+REG32(DEVICE_ADDR, 0x04)
136
+REG32(HW_CAPABILITY, 0x08)
137
+REG32(COMMAND_QUEUE_PORT, 0x0c)
138
+REG32(RESPONSE_QUEUE_PORT, 0x10)
139
+REG32(RX_TX_DATA_PORT, 0x14)
140
+REG32(IBI_QUEUE_STATUS, 0x18)
141
+REG32(IBI_QUEUE_DATA, 0x18)
142
+REG32(QUEUE_THLD_CTRL, 0x1c)
143
+REG32(DATA_BUFFER_THLD_CTRL, 0x20)
144
+REG32(IBI_QUEUE_CTRL, 0x24)
145
+REG32(IBI_MR_REQ_REJECT, 0x2c)
146
+REG32(IBI_SIR_REQ_REJECT, 0x30)
147
+REG32(RESET_CTRL, 0x34)
148
+REG32(SLV_EVENT_CTRL, 0x38)
149
+REG32(INTR_STATUS, 0x3c)
150
+REG32(INTR_STATUS_EN, 0x40)
151
+REG32(INTR_SIGNAL_EN, 0x44)
152
+REG32(INTR_FORCE, 0x48)
153
+REG32(QUEUE_STATUS_LEVEL, 0x4c)
154
+REG32(DATA_BUFFER_STATUS_LEVEL, 0x50)
155
+REG32(PRESENT_STATE, 0x54)
156
+REG32(CCC_DEVICE_STATUS, 0x58)
157
+REG32(DEVICE_ADDR_TABLE_POINTER, 0x5c)
158
+ FIELD(DEVICE_ADDR_TABLE_POINTER, DEPTH, 16, 16)
159
+ FIELD(DEVICE_ADDR_TABLE_POINTER, ADDR, 0, 16)
160
+REG32(DEV_CHAR_TABLE_POINTER, 0x60)
161
+REG32(VENDOR_SPECIFIC_REG_POINTER, 0x6c)
162
+REG32(SLV_MIPI_PID_VALUE, 0x70)
163
+REG32(SLV_PID_VALUE, 0x74)
164
+REG32(SLV_CHAR_CTRL, 0x78)
165
+REG32(SLV_MAX_LEN, 0x7c)
166
+REG32(MAX_READ_TURNAROUND, 0x80)
167
+REG32(MAX_DATA_SPEED, 0x84)
168
+REG32(SLV_DEBUG_STATUS, 0x88)
169
+REG32(SLV_INTR_REQ, 0x8c)
170
+REG32(DEVICE_CTRL_EXTENDED, 0xb0)
171
+REG32(SCL_I3C_OD_TIMING, 0xb4)
172
+REG32(SCL_I3C_PP_TIMING, 0xb8)
173
+REG32(SCL_I2C_FM_TIMING, 0xbc)
174
+REG32(SCL_I2C_FMP_TIMING, 0xc0)
175
+REG32(SCL_EXT_LCNT_TIMING, 0xc8)
176
+REG32(SCL_EXT_TERMN_LCNT_TIMING, 0xcc)
177
+REG32(BUS_FREE_TIMING, 0xd4)
178
+REG32(BUS_IDLE_TIMING, 0xd8)
179
+REG32(I3C_VER_ID, 0xe0)
180
+REG32(I3C_VER_TYPE, 0xe4)
181
+REG32(EXTENDED_CAPABILITY, 0xe8)
182
+REG32(SLAVE_CONFIG, 0xec)
183
+
184
+static const uint32_t ast2600_i3c_device_resets[ASPEED_I3C_DEVICE_NR_REGS] = {
185
+ [R_HW_CAPABILITY] = 0x000e00bf,
186
+ [R_QUEUE_THLD_CTRL] = 0x01000101,
187
+ [R_I3C_VER_ID] = 0x3130302a,
188
+ [R_I3C_VER_TYPE] = 0x6c633033,
189
+ [R_DEVICE_ADDR_TABLE_POINTER] = 0x00080280,
190
+ [R_DEV_CHAR_TABLE_POINTER] = 0x00020200,
191
+ [A_VENDOR_SPECIFIC_REG_POINTER] = 0x000000b0,
192
+ [R_SLV_MAX_LEN] = 0x00ff00ff,
193
+};
194
+
195
+static uint64_t aspeed_i3c_device_read(void *opaque, hwaddr offset,
196
+ unsigned size)
197
+{
198
+ AspeedI3CDevice *s = ASPEED_I3C_DEVICE(opaque);
199
+ uint32_t addr = offset >> 2;
200
+ uint64_t value;
201
+
202
+ switch (addr) {
203
+ case R_COMMAND_QUEUE_PORT:
204
+ value = 0;
205
+ break;
206
+ default:
207
+ value = s->regs[addr];
208
+ break;
209
+ }
210
+
211
+ trace_aspeed_i3c_device_read(s->id, offset, value);
212
+
213
+ return value;
214
+}
215
+
216
+static void aspeed_i3c_device_write(void *opaque, hwaddr offset,
217
+ uint64_t value, unsigned size)
218
+{
219
+ AspeedI3CDevice *s = ASPEED_I3C_DEVICE(opaque);
220
+ uint32_t addr = offset >> 2;
221
+
222
+ trace_aspeed_i3c_device_write(s->id, offset, value);
223
+
224
+ switch (addr) {
225
+ case R_HW_CAPABILITY:
226
+ case R_RESPONSE_QUEUE_PORT:
227
+ case R_IBI_QUEUE_DATA:
228
+ case R_QUEUE_STATUS_LEVEL:
229
+ case R_PRESENT_STATE:
230
+ case R_CCC_DEVICE_STATUS:
231
+ case R_DEVICE_ADDR_TABLE_POINTER:
232
+ case R_VENDOR_SPECIFIC_REG_POINTER:
233
+ case R_SLV_CHAR_CTRL:
234
+ case R_SLV_MAX_LEN:
235
+ case R_MAX_READ_TURNAROUND:
236
+ case R_I3C_VER_ID:
237
+ case R_I3C_VER_TYPE:
238
+ case R_EXTENDED_CAPABILITY:
239
+ qemu_log_mask(LOG_GUEST_ERROR,
240
+ "%s: write to readonly register[%02lx] = %08lx\n",
241
+ __func__, offset, value);
242
+ break;
243
+ case R_RX_TX_DATA_PORT:
244
+ break;
245
+ case R_RESET_CTRL:
246
+ break;
247
+ default:
248
+ s->regs[addr] = value;
249
+ break;
250
+ }
78
+ }
251
+}
79
+}
252
+
80
+
253
+static const VMStateDescription aspeed_i3c_device_vmstate = {
81
+void HELPER(sme_addha_d)(void *vzda, void *vzn, void *vpn,
254
+ .name = TYPE_ASPEED_I3C,
82
+ void *vpm, uint32_t desc)
255
+ .version_id = 1,
83
+{
256
+ .minimum_version_id = 1,
84
+ intptr_t row, col, oprsz = simd_oprsz(desc) / 8;
257
+ .fields = (VMStateField[]){
85
+ uint8_t *pn = vpn, *pm = vpm;
258
+ VMSTATE_UINT32_ARRAY(regs, AspeedI3CDevice, ASPEED_I3C_DEVICE_NR_REGS),
86
+ uint64_t *zda = vzda, *zn = vzn;
259
+ VMSTATE_END_OF_LIST(),
260
+ }
261
+};
262
+
87
+
263
+static const MemoryRegionOps aspeed_i3c_device_ops = {
88
+ for (row = 0; row < oprsz; ++row) {
264
+ .read = aspeed_i3c_device_read,
89
+ if (pn[H1(row)] & 1) {
265
+ .write = aspeed_i3c_device_write,
90
+ for (col = 0; col < oprsz; ++col) {
266
+ .endianness = DEVICE_LITTLE_ENDIAN,
91
+ if (pm[H1(col)] & 1) {
267
+};
92
+ zda[tile_vslice_index(row) + col] += zn[col];
268
+
93
+ }
269
+static void aspeed_i3c_device_reset(DeviceState *dev)
94
+ }
270
+{
271
+ AspeedI3CDevice *s = ASPEED_I3C_DEVICE(dev);
272
+
273
+ memcpy(s->regs, ast2600_i3c_device_resets, sizeof(s->regs));
274
+}
275
+
276
+static void aspeed_i3c_device_realize(DeviceState *dev, Error **errp)
277
+{
278
+ AspeedI3CDevice *s = ASPEED_I3C_DEVICE(dev);
279
+ g_autofree char *name = g_strdup_printf(TYPE_ASPEED_I3C_DEVICE ".%d",
280
+ s->id);
281
+
282
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
283
+
284
+ memory_region_init_io(&s->mr, OBJECT(s), &aspeed_i3c_device_ops,
285
+ s, name, ASPEED_I3C_DEVICE_NR_REGS << 2);
286
+}
287
+
288
+static uint64_t aspeed_i3c_read(void *opaque, hwaddr addr, unsigned int size)
289
+{
290
+ AspeedI3CState *s = ASPEED_I3C(opaque);
291
+ uint64_t val = 0;
292
+
293
+ val = s->regs[addr >> 2];
294
+
295
+ trace_aspeed_i3c_read(addr, val);
296
+
297
+ return val;
298
+}
299
+
300
+static void aspeed_i3c_write(void *opaque,
301
+ hwaddr addr,
302
+ uint64_t data,
303
+ unsigned int size)
304
+{
305
+ AspeedI3CState *s = ASPEED_I3C(opaque);
306
+
307
+ trace_aspeed_i3c_write(addr, data);
308
+
309
+ addr >>= 2;
310
+
311
+ /* I3C controller register */
312
+ switch (addr) {
313
+ case R_I3C1_REG1:
314
+ case R_I3C2_REG1:
315
+ case R_I3C3_REG1:
316
+ case R_I3C4_REG1:
317
+ case R_I3C5_REG1:
318
+ case R_I3C6_REG1:
319
+ if (data & R_I3C1_REG1_I2C_MODE_MASK) {
320
+ qemu_log_mask(LOG_UNIMP,
321
+ "%s: Not support I2C mode [%08lx]=%08lx",
322
+ __func__, addr << 2, data);
323
+ break;
324
+ }
95
+ }
325
+ if (data & R_I3C1_REG1_SA_EN_MASK) {
326
+ qemu_log_mask(LOG_UNIMP,
327
+ "%s: Not support slave mode [%08lx]=%08lx",
328
+ __func__, addr << 2, data);
329
+ break;
330
+ }
331
+ s->regs[addr] = data;
332
+ break;
333
+ default:
334
+ s->regs[addr] = data;
335
+ break;
336
+ }
96
+ }
337
+}
97
+}
338
+
98
+
339
+static const MemoryRegionOps aspeed_i3c_ops = {
99
+void HELPER(sme_addva_s)(void *vzda, void *vzn, void *vpn,
340
+ .read = aspeed_i3c_read,
100
+ void *vpm, uint32_t desc)
341
+ .write = aspeed_i3c_write,
101
+{
342
+ .endianness = DEVICE_LITTLE_ENDIAN,
102
+ intptr_t row, col, oprsz = simd_oprsz(desc) / 4;
343
+ .valid = {
103
+ uint64_t *pn = vpn, *pm = vpm;
344
+ .min_access_size = 1,
104
+ uint32_t *zda = vzda, *zn = vzn;
345
+ .max_access_size = 4,
346
+ }
347
+};
348
+
105
+
349
+static void aspeed_i3c_reset(DeviceState *dev)
106
+ for (row = 0; row < oprsz; ) {
350
+{
107
+ uint64_t pa = pn[row >> 4];
351
+ AspeedI3CState *s = ASPEED_I3C(dev);
108
+ do {
352
+ memset(s->regs, 0, sizeof(s->regs));
109
+ if (pa & 1) {
353
+}
110
+ uint32_t zn_row = zn[H4(row)];
354
+
111
+ for (col = 0; col < oprsz; ) {
355
+static void aspeed_i3c_instance_init(Object *obj)
112
+ uint64_t pb = pm[col >> 4];
356
+{
113
+ do {
357
+ AspeedI3CState *s = ASPEED_I3C(obj);
114
+ if (pb & 1) {
358
+ int i;
115
+ zda[tile_vslice_index(row) + H4(col)] += zn_row;
359
+
116
+ }
360
+ for (i = 0; i < ASPEED_I3C_NR_DEVICES; ++i) {
117
+ pb >>= 4;
361
+ object_initialize_child(obj, "device[*]", &s->devices[i],
118
+ } while (++col & 15);
362
+ TYPE_ASPEED_I3C_DEVICE);
119
+ }
120
+ }
121
+ pa >>= 4;
122
+ } while (++row & 15);
363
+ }
123
+ }
364
+}
124
+}
365
+
125
+
366
+static void aspeed_i3c_realize(DeviceState *dev, Error **errp)
126
+void HELPER(sme_addva_d)(void *vzda, void *vzn, void *vpn,
127
+ void *vpm, uint32_t desc)
367
+{
128
+{
368
+ int i;
129
+ intptr_t row, col, oprsz = simd_oprsz(desc) / 8;
369
+ AspeedI3CState *s = ASPEED_I3C(dev);
130
+ uint8_t *pn = vpn, *pm = vpm;
370
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
131
+ uint64_t *zda = vzda, *zn = vzn;
371
+
132
+
372
+ memory_region_init(&s->iomem_container, OBJECT(s),
133
+ for (row = 0; row < oprsz; ++row) {
373
+ TYPE_ASPEED_I3C ".container", 0x8000);
134
+ if (pn[H1(row)] & 1) {
135
+ uint64_t zn_row = zn[row];
136
+ for (col = 0; col < oprsz; ++col) {
137
+ if (pm[H1(col)] & 1) {
138
+ zda[tile_vslice_index(row) + col] += zn_row;
139
+ }
140
+ }
141
+ }
142
+ }
143
+}
144
diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c
145
index XXXXXXX..XXXXXXX 100644
146
--- a/target/arm/translate-sme.c
147
+++ b/target/arm/translate-sme.c
148
@@ -XXX,XX +XXX,XX @@ static bool do_ldst_r(DisasContext *s, arg_ldstr *a, GenLdStR *fn)
149
150
TRANS_FEAT(LDR, aa64_sme, do_ldst_r, a, gen_sve_ldr)
151
TRANS_FEAT(STR, aa64_sme, do_ldst_r, a, gen_sve_str)
374
+
152
+
375
+ sysbus_init_mmio(sbd, &s->iomem_container);
153
+static bool do_adda(DisasContext *s, arg_adda *a, MemOp esz,
154
+ gen_helper_gvec_4 *fn)
155
+{
156
+ int svl = streaming_vec_reg_size(s);
157
+ uint32_t desc = simd_desc(svl, svl, 0);
158
+ TCGv_ptr za, zn, pn, pm;
376
+
159
+
377
+ memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_i3c_ops, s,
160
+ if (!sme_smza_enabled_check(s)) {
378
+ TYPE_ASPEED_I3C ".regs", ASPEED_I3C_NR_REGS << 2);
161
+ return true;
379
+
380
+ memory_region_add_subregion(&s->iomem_container, 0x0, &s->iomem);
381
+
382
+ for (i = 0; i < ASPEED_I3C_NR_DEVICES; ++i) {
383
+ Object *dev = OBJECT(&s->devices[i]);
384
+
385
+ if (!object_property_set_uint(dev, "device-id", i, errp)) {
386
+ return;
387
+ }
388
+
389
+ if (!sysbus_realize(SYS_BUS_DEVICE(dev), errp)) {
390
+ return;
391
+ }
392
+
393
+ /*
394
+ * Register Address of I3CX Device =
395
+ * (Base Address of Global Register) + (Offset of I3CX) + Offset
396
+ * X = 0, 1, 2, 3, 4, 5
397
+ * Offset of I3C0 = 0x2000
398
+ * Offset of I3C1 = 0x3000
399
+ * Offset of I3C2 = 0x4000
400
+ * Offset of I3C3 = 0x5000
401
+ * Offset of I3C4 = 0x6000
402
+ * Offset of I3C5 = 0x7000
403
+ */
404
+ memory_region_add_subregion(&s->iomem_container,
405
+ 0x2000 + i * 0x1000, &s->devices[i].mr);
406
+ }
162
+ }
407
+
163
+
164
+ /* Sum XZR+zad to find ZAd. */
165
+ za = get_tile_rowcol(s, esz, 31, a->zad, false);
166
+ zn = vec_full_reg_ptr(s, a->zn);
167
+ pn = pred_full_reg_ptr(s, a->pn);
168
+ pm = pred_full_reg_ptr(s, a->pm);
169
+
170
+ fn(za, zn, pn, pm, tcg_constant_i32(desc));
171
+
172
+ tcg_temp_free_ptr(za);
173
+ tcg_temp_free_ptr(zn);
174
+ tcg_temp_free_ptr(pn);
175
+ tcg_temp_free_ptr(pm);
176
+ return true;
408
+}
177
+}
409
+
178
+
410
+static Property aspeed_i3c_device_properties[] = {
179
+TRANS_FEAT(ADDHA_s, aa64_sme, do_adda, a, MO_32, gen_helper_sme_addha_s)
411
+ DEFINE_PROP_UINT8("device-id", AspeedI3CDevice, id, 0),
180
+TRANS_FEAT(ADDVA_s, aa64_sme, do_adda, a, MO_32, gen_helper_sme_addva_s)
412
+ DEFINE_PROP_END_OF_LIST(),
181
+TRANS_FEAT(ADDHA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addha_d)
413
+};
182
+TRANS_FEAT(ADDVA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addva_d)
414
+
415
+static void aspeed_i3c_device_class_init(ObjectClass *klass, void *data)
416
+{
417
+ DeviceClass *dc = DEVICE_CLASS(klass);
418
+
419
+ dc->desc = "Aspeed I3C Device";
420
+ dc->realize = aspeed_i3c_device_realize;
421
+ dc->reset = aspeed_i3c_device_reset;
422
+ device_class_set_props(dc, aspeed_i3c_device_properties);
423
+}
424
+
425
+static const TypeInfo aspeed_i3c_device_info = {
426
+ .name = TYPE_ASPEED_I3C_DEVICE,
427
+ .parent = TYPE_SYS_BUS_DEVICE,
428
+ .instance_size = sizeof(AspeedI3CDevice),
429
+ .class_init = aspeed_i3c_device_class_init,
430
+};
431
+
432
+static const VMStateDescription vmstate_aspeed_i3c = {
433
+ .name = TYPE_ASPEED_I3C,
434
+ .version_id = 1,
435
+ .minimum_version_id = 1,
436
+ .fields = (VMStateField[]) {
437
+ VMSTATE_UINT32_ARRAY(regs, AspeedI3CState, ASPEED_I3C_NR_REGS),
438
+ VMSTATE_STRUCT_ARRAY(devices, AspeedI3CState, ASPEED_I3C_NR_DEVICES, 1,
439
+ aspeed_i3c_device_vmstate, AspeedI3CDevice),
440
+ VMSTATE_END_OF_LIST(),
441
+ }
442
+};
443
+
444
+static void aspeed_i3c_class_init(ObjectClass *klass, void *data)
445
+{
446
+ DeviceClass *dc = DEVICE_CLASS(klass);
447
+
448
+ dc->realize = aspeed_i3c_realize;
449
+ dc->reset = aspeed_i3c_reset;
450
+ dc->desc = "Aspeed I3C Controller";
451
+ dc->vmsd = &vmstate_aspeed_i3c;
452
+}
453
+
454
+static const TypeInfo aspeed_i3c_info = {
455
+ .name = TYPE_ASPEED_I3C,
456
+ .parent = TYPE_SYS_BUS_DEVICE,
457
+ .instance_init = aspeed_i3c_instance_init,
458
+ .instance_size = sizeof(AspeedI3CState),
459
+ .class_init = aspeed_i3c_class_init,
460
+};
461
+
462
+static void aspeed_i3c_register_types(void)
463
+{
464
+ type_register_static(&aspeed_i3c_device_info);
465
+ type_register_static(&aspeed_i3c_info);
466
+}
467
+
468
+type_init(aspeed_i3c_register_types);
469
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
470
index XXXXXXX..XXXXXXX 100644
471
--- a/hw/misc/meson.build
472
+++ b/hw/misc/meson.build
473
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c'))
474
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
475
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files(
476
'aspeed_hace.c',
477
+ 'aspeed_i3c.c',
478
'aspeed_lpc.c',
479
'aspeed_scu.c',
480
'aspeed_sdmc.c',
481
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
482
index XXXXXXX..XXXXXXX 100644
483
--- a/hw/misc/trace-events
484
+++ b/hw/misc/trace-events
485
@@ -XXX,XX +XXX,XX @@ armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU wri
486
# aspeed_xdma.c
487
aspeed_xdma_write(uint64_t offset, uint64_t data) "XDMA write: offset 0x%" PRIx64 " data 0x%" PRIx64
488
489
+# aspeed_i3c.c
490
+aspeed_i3c_read(uint64_t offset, uint64_t data) "I3C read: offset 0x%" PRIx64 " data 0x%" PRIx64
491
+aspeed_i3c_write(uint64_t offset, uint64_t data) "I3C write: offset 0x%" PRIx64 " data 0x%" PRIx64
492
+aspeed_i3c_device_read(uint32_t deviceid, uint64_t offset, uint64_t data) "I3C Dev[%u] read: offset 0x%" PRIx64 " data 0x%" PRIx64
493
+aspeed_i3c_device_write(uint32_t deviceid, uint64_t offset, uint64_t data) "I3C Dev[%u] write: offset 0x%" PRIx64 " data 0x%" PRIx64
494
+
495
# bcm2835_property.c
496
bcm2835_mbox_property(uint32_t tag, uint32_t bufsize, size_t resplen) "mbox property tag:0x%08x in_sz:%u out_sz:%zu"
497
498
--
183
--
499
2.25.1
184
2.25.1
500
501
diff view generated by jsdifflib
1
From: Yanan Wang <wangyanan55@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Support CPU cluster topology level in generation of ACPI
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Processor Properties Topology Table (PPTT).
4
Message-id: 20220708151540.18136-25-richard.henderson@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/helper-sme.h | 5 +++
9
target/arm/sme.decode | 9 +++++
10
target/arm/sme_helper.c | 69 ++++++++++++++++++++++++++++++++++++++
11
target/arm/translate-sme.c | 32 ++++++++++++++++++
12
4 files changed, 115 insertions(+)
5
13
6
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
14
diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h
7
Reviewed-by: Andrew Jones <drjones@redhat.com>
8
Message-id: 20220107083232.16256-6-wangyanan55@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/acpi/aml-build.c | 18 ++++++++++++++++++
12
1 file changed, 18 insertions(+)
13
14
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/acpi/aml-build.c
16
--- a/target/arm/helper-sme.h
17
+++ b/hw/acpi/aml-build.c
17
+++ b/target/arm/helper-sme.h
18
@@ -XXX,XX +XXX,XX @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags,
18
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(sme_addha_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
19
void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
19
DEF_HELPER_FLAGS_5(sme_addva_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
20
const char *oem_id, const char *oem_table_id)
20
DEF_HELPER_FLAGS_5(sme_addha_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
21
{
21
DEF_HELPER_FLAGS_5(sme_addva_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
22
+ MachineClass *mc = MACHINE_GET_CLASS(ms);
22
+
23
GQueue *list = g_queue_new();
23
+DEF_HELPER_FLAGS_7(sme_fmopa_s, TCG_CALL_NO_RWG,
24
guint pptt_start = table_data->len;
24
+ void, ptr, ptr, ptr, ptr, ptr, ptr, i32)
25
guint parent_offset;
25
+DEF_HELPER_FLAGS_7(sme_fmopa_d, TCG_CALL_NO_RWG,
26
@@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
26
+ void, ptr, ptr, ptr, ptr, ptr, ptr, i32)
27
0, socket, NULL, 0);
27
diff --git a/target/arm/sme.decode b/target/arm/sme.decode
28
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/sme.decode
30
+++ b/target/arm/sme.decode
31
@@ -XXX,XX +XXX,XX @@ ADDHA_s 11000000 10 01000 0 ... ... ..... 000 .. @adda_32
32
ADDVA_s 11000000 10 01000 1 ... ... ..... 000 .. @adda_32
33
ADDHA_d 11000000 11 01000 0 ... ... ..... 00 ... @adda_64
34
ADDVA_d 11000000 11 01000 1 ... ... ..... 00 ... @adda_64
35
+
36
+### SME Outer Product
37
+
38
+&op zad zn zm pm pn sub:bool
39
+@op_32 ........ ... zm:5 pm:3 pn:3 zn:5 sub:1 .. zad:2 &op
40
+@op_64 ........ ... zm:5 pm:3 pn:3 zn:5 sub:1 . zad:3 &op
41
+
42
+FMOPA_s 10000000 100 ..... ... ... ..... . 00 .. @op_32
43
+FMOPA_d 10000000 110 ..... ... ... ..... . 0 ... @op_64
44
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/target/arm/sme_helper.c
47
+++ b/target/arm/sme_helper.c
48
@@ -XXX,XX +XXX,XX @@
49
#include "exec/cpu_ldst.h"
50
#include "exec/exec-all.h"
51
#include "qemu/int128.h"
52
+#include "fpu/softfloat.h"
53
#include "vec_internal.h"
54
#include "sve_ldst_internal.h"
55
56
@@ -XXX,XX +XXX,XX @@ void HELPER(sme_addva_d)(void *vzda, void *vzn, void *vpn,
57
}
28
}
58
}
29
59
}
30
+ if (mc->smp_props.clusters_supported) {
31
+ length = g_queue_get_length(list);
32
+ for (i = 0; i < length; i++) {
33
+ int cluster;
34
+
60
+
35
+ parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
61
+void HELPER(sme_fmopa_s)(void *vza, void *vzn, void *vzm, void *vpn,
36
+ for (cluster = 0; cluster < ms->smp.clusters; cluster++) {
62
+ void *vpm, void *vst, uint32_t desc)
37
+ g_queue_push_tail(list,
63
+{
38
+ GUINT_TO_POINTER(table_data->len - pptt_start));
64
+ intptr_t row, col, oprsz = simd_maxsz(desc);
39
+ build_processor_hierarchy_node(
65
+ uint32_t neg = simd_data(desc) << 31;
40
+ table_data,
66
+ uint16_t *pn = vpn, *pm = vpm;
41
+ (0 << 0), /* not a physical package */
67
+ float_status fpst;
42
+ parent_offset, cluster, NULL, 0);
68
+
69
+ /*
70
+ * Make a copy of float_status because this operation does not
71
+ * update the cumulative fp exception status. It also produces
72
+ * default nans.
73
+ */
74
+ fpst = *(float_status *)vst;
75
+ set_default_nan_mode(true, &fpst);
76
+
77
+ for (row = 0; row < oprsz; ) {
78
+ uint16_t pa = pn[H2(row >> 4)];
79
+ do {
80
+ if (pa & 1) {
81
+ void *vza_row = vza + tile_vslice_offset(row);
82
+ uint32_t n = *(uint32_t *)(vzn + H1_4(row)) ^ neg;
83
+
84
+ for (col = 0; col < oprsz; ) {
85
+ uint16_t pb = pm[H2(col >> 4)];
86
+ do {
87
+ if (pb & 1) {
88
+ uint32_t *a = vza_row + H1_4(col);
89
+ uint32_t *m = vzm + H1_4(col);
90
+ *a = float32_muladd(n, *m, *a, 0, vst);
91
+ }
92
+ col += 4;
93
+ pb >>= 4;
94
+ } while (col & 15);
95
+ }
96
+ }
97
+ row += 4;
98
+ pa >>= 4;
99
+ } while (row & 15);
100
+ }
101
+}
102
+
103
+void HELPER(sme_fmopa_d)(void *vza, void *vzn, void *vzm, void *vpn,
104
+ void *vpm, void *vst, uint32_t desc)
105
+{
106
+ intptr_t row, col, oprsz = simd_oprsz(desc) / 8;
107
+ uint64_t neg = (uint64_t)simd_data(desc) << 63;
108
+ uint64_t *za = vza, *zn = vzn, *zm = vzm;
109
+ uint8_t *pn = vpn, *pm = vpm;
110
+ float_status fpst = *(float_status *)vst;
111
+
112
+ set_default_nan_mode(true, &fpst);
113
+
114
+ for (row = 0; row < oprsz; ++row) {
115
+ if (pn[H1(row)] & 1) {
116
+ uint64_t *za_row = &za[tile_vslice_index(row)];
117
+ uint64_t n = zn[row] ^ neg;
118
+
119
+ for (col = 0; col < oprsz; ++col) {
120
+ if (pm[H1(col)] & 1) {
121
+ uint64_t *a = &za_row[col];
122
+ *a = float64_muladd(n, zm[col], *a, 0, &fpst);
123
+ }
43
+ }
124
+ }
44
+ }
125
+ }
45
+ }
126
+ }
127
+}
128
diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c
129
index XXXXXXX..XXXXXXX 100644
130
--- a/target/arm/translate-sme.c
131
+++ b/target/arm/translate-sme.c
132
@@ -XXX,XX +XXX,XX @@ TRANS_FEAT(ADDHA_s, aa64_sme, do_adda, a, MO_32, gen_helper_sme_addha_s)
133
TRANS_FEAT(ADDVA_s, aa64_sme, do_adda, a, MO_32, gen_helper_sme_addva_s)
134
TRANS_FEAT(ADDHA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addha_d)
135
TRANS_FEAT(ADDVA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addva_d)
46
+
136
+
47
length = g_queue_get_length(list);
137
+static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz,
48
for (i = 0; i < length; i++) {
138
+ gen_helper_gvec_5_ptr *fn)
49
int core;
139
+{
140
+ int svl = streaming_vec_reg_size(s);
141
+ uint32_t desc = simd_desc(svl, svl, a->sub);
142
+ TCGv_ptr za, zn, zm, pn, pm, fpst;
143
+
144
+ if (!sme_smza_enabled_check(s)) {
145
+ return true;
146
+ }
147
+
148
+ /* Sum XZR+zad to find ZAd. */
149
+ za = get_tile_rowcol(s, esz, 31, a->zad, false);
150
+ zn = vec_full_reg_ptr(s, a->zn);
151
+ zm = vec_full_reg_ptr(s, a->zm);
152
+ pn = pred_full_reg_ptr(s, a->pn);
153
+ pm = pred_full_reg_ptr(s, a->pm);
154
+ fpst = fpstatus_ptr(FPST_FPCR);
155
+
156
+ fn(za, zn, zm, pn, pm, fpst, tcg_constant_i32(desc));
157
+
158
+ tcg_temp_free_ptr(za);
159
+ tcg_temp_free_ptr(zn);
160
+ tcg_temp_free_ptr(pn);
161
+ tcg_temp_free_ptr(pm);
162
+ tcg_temp_free_ptr(fpst);
163
+ return true;
164
+}
165
+
166
+TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_s)
167
+TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, MO_64, gen_helper_sme_fmopa_d)
50
--
168
--
51
2.25.1
169
2.25.1
52
53
diff view generated by jsdifflib
1
In process_its_cmd() and process_mapti() we must check the
1
From: Richard Henderson <richard.henderson@linaro.org>
2
event ID against a limit defined by the size field in the DTE,
3
which specifies the number of ID bits minus one. Convert
4
this code to our num_foo convention:
5
* change the variable names
6
* use uint64_t and 1ULL when calculating the number
7
of valid event IDs, because DTE.SIZE is 5 bits and
8
so num_eventids may be up to 2^32
9
* fix the off-by-one error in the comparison
10
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Message-id: 20220708151540.18136-26-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Message-id: 20220111171048.3545974-2-peter.maydell@linaro.org
14
---
7
---
15
hw/intc/arm_gicv3_its.c | 18 ++++++++++--------
8
target/arm/helper-sme.h | 2 ++
16
1 file changed, 10 insertions(+), 8 deletions(-)
9
target/arm/sme.decode | 2 ++
10
target/arm/sme_helper.c | 56 ++++++++++++++++++++++++++++++++++++++
11
target/arm/translate-sme.c | 30 ++++++++++++++++++++
12
4 files changed, 90 insertions(+)
17
13
18
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
14
diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h
19
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/intc/arm_gicv3_its.c
16
--- a/target/arm/helper-sme.h
21
+++ b/hw/intc/arm_gicv3_its.c
17
+++ b/target/arm/helper-sme.h
22
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
18
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_7(sme_fmopa_s, TCG_CALL_NO_RWG,
23
MemTxResult res = MEMTX_OK;
19
void, ptr, ptr, ptr, ptr, ptr, ptr, i32)
24
bool dte_valid;
20
DEF_HELPER_FLAGS_7(sme_fmopa_d, TCG_CALL_NO_RWG,
25
uint64_t dte = 0;
21
void, ptr, ptr, ptr, ptr, ptr, ptr, i32)
26
- uint32_t max_eventid;
22
+DEF_HELPER_FLAGS_6(sme_bfmopa, TCG_CALL_NO_RWG,
27
+ uint64_t num_eventids;
23
+ void, ptr, ptr, ptr, ptr, ptr, i32)
28
uint16_t icid = 0;
24
diff --git a/target/arm/sme.decode b/target/arm/sme.decode
29
uint32_t pIntid = 0;
25
index XXXXXXX..XXXXXXX 100644
30
bool ite_valid = false;
26
--- a/target/arm/sme.decode
31
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
27
+++ b/target/arm/sme.decode
32
dte_valid = FIELD_EX64(dte, DTE, VALID);
28
@@ -XXX,XX +XXX,XX @@ ADDVA_d 11000000 11 01000 1 ... ... ..... 00 ... @adda_64
33
29
34
if (dte_valid) {
30
FMOPA_s 10000000 100 ..... ... ... ..... . 00 .. @op_32
35
- max_eventid = 1UL << (FIELD_EX64(dte, DTE, SIZE) + 1);
31
FMOPA_d 10000000 110 ..... ... ... ..... . 0 ... @op_64
36
+ num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
32
+
37
33
+BFMOPA 10000001 100 ..... ... ... ..... . 00 .. @op_32
38
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
34
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
39
35
index XXXXXXX..XXXXXXX 100644
40
@@ -XXX,XX +XXX,XX @@ static bool process_its_cmd(GICv3ITSState *s, uint64_t value, uint32_t offset,
36
--- a/target/arm/sme_helper.c
41
dte_valid ? "valid" : "invalid",
37
+++ b/target/arm/sme_helper.c
42
ite_valid ? "valid" : "invalid",
38
@@ -XXX,XX +XXX,XX @@ void HELPER(sme_fmopa_d)(void *vza, void *vzn, void *vzm, void *vpn,
43
cte_valid ? "valid" : "invalid");
39
}
44
- } else if (eventid > max_eventid) {
45
+ } else if (eventid >= num_eventids) {
46
qemu_log_mask(LOG_GUEST_ERROR,
47
- "%s: invalid command attributes: eventid %d > %d\n",
48
- __func__, eventid, max_eventid);
49
+ "%s: invalid command attributes: eventid %d >= %"
50
+ PRId64 "\n",
51
+ __func__, eventid, num_eventids);
52
} else {
53
/*
54
* Current implementation only supports rdbase == procnum
55
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
56
AddressSpace *as = &s->gicv3->dma_as;
57
uint32_t devid, eventid;
58
uint32_t pIntid = 0;
59
- uint32_t max_eventid, max_Intid;
60
+ uint64_t num_eventids;
61
+ uint32_t max_Intid;
62
bool dte_valid;
63
MemTxResult res = MEMTX_OK;
64
uint16_t icid = 0;
65
@@ -XXX,XX +XXX,XX @@ static bool process_mapti(GICv3ITSState *s, uint64_t value, uint32_t offset,
66
return result;
67
}
40
}
68
dte_valid = FIELD_EX64(dte, DTE, VALID);
41
}
69
- max_eventid = 1UL << (FIELD_EX64(dte, DTE, SIZE) + 1);
42
+
70
+ num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
43
+/*
71
max_Intid = (1ULL << (GICD_TYPER_IDBITS + 1)) - 1;
44
+ * Alter PAIR as needed for controlling predicates being false,
72
45
+ * and for NEG on an enabled row element.
73
if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids)
46
+ */
74
- || !dte_valid || (eventid > max_eventid) ||
47
+static inline uint32_t f16mop_adj_pair(uint32_t pair, uint32_t pg, uint32_t neg)
75
+ || !dte_valid || (eventid >= num_eventids) ||
48
+{
76
(((pIntid < GICV3_LPI_INTID_START) || (pIntid > max_Intid)) &&
49
+ /*
77
(pIntid != INTID_SPURIOUS))) {
50
+ * The pseudocode uses a conditional negate after the conditional zero.
78
qemu_log_mask(LOG_GUEST_ERROR,
51
+ * It is simpler here to unconditionally negate before conditional zero.
52
+ */
53
+ pair ^= neg;
54
+ if (!(pg & 1)) {
55
+ pair &= 0xffff0000u;
56
+ }
57
+ if (!(pg & 4)) {
58
+ pair &= 0x0000ffffu;
59
+ }
60
+ return pair;
61
+}
62
+
63
+void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn,
64
+ void *vpm, uint32_t desc)
65
+{
66
+ intptr_t row, col, oprsz = simd_maxsz(desc);
67
+ uint32_t neg = simd_data(desc) * 0x80008000u;
68
+ uint16_t *pn = vpn, *pm = vpm;
69
+
70
+ for (row = 0; row < oprsz; ) {
71
+ uint16_t prow = pn[H2(row >> 4)];
72
+ do {
73
+ void *vza_row = vza + tile_vslice_offset(row);
74
+ uint32_t n = *(uint32_t *)(vzn + H1_4(row));
75
+
76
+ n = f16mop_adj_pair(n, prow, neg);
77
+
78
+ for (col = 0; col < oprsz; ) {
79
+ uint16_t pcol = pm[H2(col >> 4)];
80
+ do {
81
+ if (prow & pcol & 0b0101) {
82
+ uint32_t *a = vza_row + H1_4(col);
83
+ uint32_t m = *(uint32_t *)(vzm + H1_4(col));
84
+
85
+ m = f16mop_adj_pair(m, pcol, 0);
86
+ *a = bfdotadd(*a, n, m);
87
+
88
+ col += 4;
89
+ pcol >>= 4;
90
+ }
91
+ } while (col & 15);
92
+ }
93
+ row += 4;
94
+ prow >>= 4;
95
+ } while (row & 15);
96
+ }
97
+}
98
diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c
99
index XXXXXXX..XXXXXXX 100644
100
--- a/target/arm/translate-sme.c
101
+++ b/target/arm/translate-sme.c
102
@@ -XXX,XX +XXX,XX @@ TRANS_FEAT(ADDVA_s, aa64_sme, do_adda, a, MO_32, gen_helper_sme_addva_s)
103
TRANS_FEAT(ADDHA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addha_d)
104
TRANS_FEAT(ADDVA_d, aa64_sme_i16i64, do_adda, a, MO_64, gen_helper_sme_addva_d)
105
106
+static bool do_outprod(DisasContext *s, arg_op *a, MemOp esz,
107
+ gen_helper_gvec_5 *fn)
108
+{
109
+ int svl = streaming_vec_reg_size(s);
110
+ uint32_t desc = simd_desc(svl, svl, a->sub);
111
+ TCGv_ptr za, zn, zm, pn, pm;
112
+
113
+ if (!sme_smza_enabled_check(s)) {
114
+ return true;
115
+ }
116
+
117
+ /* Sum XZR+zad to find ZAd. */
118
+ za = get_tile_rowcol(s, esz, 31, a->zad, false);
119
+ zn = vec_full_reg_ptr(s, a->zn);
120
+ zm = vec_full_reg_ptr(s, a->zm);
121
+ pn = pred_full_reg_ptr(s, a->pn);
122
+ pm = pred_full_reg_ptr(s, a->pm);
123
+
124
+ fn(za, zn, zm, pn, pm, tcg_constant_i32(desc));
125
+
126
+ tcg_temp_free_ptr(za);
127
+ tcg_temp_free_ptr(zn);
128
+ tcg_temp_free_ptr(pn);
129
+ tcg_temp_free_ptr(pm);
130
+ return true;
131
+}
132
+
133
static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz,
134
gen_helper_gvec_5_ptr *fn)
135
{
136
@@ -XXX,XX +XXX,XX @@ static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz,
137
138
TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_s)
139
TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, MO_64, gen_helper_sme_fmopa_d)
140
+
141
+/* TODO: FEAT_EBF16 */
142
+TRANS_FEAT(BFMOPA, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_bfmopa)
79
--
143
--
80
2.25.1
144
2.25.1
81
82
diff view generated by jsdifflib
1
Fix process_mapti() to consistently return CMD_STALL for memory
1
From: Richard Henderson <richard.henderson@linaro.org>
2
errors and CMD_CONTINUE for parameter errors, as we claim in the
3
comments that we do.
4
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Message-id: 20220708151540.18136-27-richard.henderson@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-9-peter.maydell@linaro.org
9
---
7
---
10
hw/intc/arm_gicv3_its.c | 28 +++++++++++++---------------
8
target/arm/helper-sme.h | 2 ++
11
1 file changed, 13 insertions(+), 15 deletions(-)
9
target/arm/sme.decode | 1 +
10
target/arm/sme_helper.c | 74 ++++++++++++++++++++++++++++++++++++++
11
target/arm/translate-sme.c | 1 +
12
4 files changed, 78 insertions(+)
12
13
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
14
diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
16
--- a/target/arm/helper-sme.h
16
+++ b/hw/intc/arm_gicv3_its.c
17
+++ b/target/arm/helper-sme.h
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
18
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(sme_addva_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
18
MemTxResult res = MEMTX_OK;
19
DEF_HELPER_FLAGS_5(sme_addha_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
19
uint16_t icid = 0;
20
DEF_HELPER_FLAGS_5(sme_addva_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, ptr, i32)
20
uint64_t dte = 0;
21
21
- ItsCmdResult result = CMD_STALL;
22
+DEF_HELPER_FLAGS_7(sme_fmopa_h, TCG_CALL_NO_RWG,
22
+ IteEntry ite = {};
23
+ void, ptr, ptr, ptr, ptr, ptr, ptr, i32)
23
24
DEF_HELPER_FLAGS_7(sme_fmopa_s, TCG_CALL_NO_RWG,
24
devid = ((value & DEVID_MASK) >> DEVID_SHIFT);
25
void, ptr, ptr, ptr, ptr, ptr, ptr, i32)
25
offset += NUM_BYTES_IN_DW;
26
DEF_HELPER_FLAGS_7(sme_fmopa_d, TCG_CALL_NO_RWG,
26
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
27
diff --git a/target/arm/sme.decode b/target/arm/sme.decode
27
MEMTXATTRS_UNSPECIFIED, &res);
28
index XXXXXXX..XXXXXXX 100644
28
29
--- a/target/arm/sme.decode
29
if (res != MEMTX_OK) {
30
+++ b/target/arm/sme.decode
30
- return result;
31
@@ -XXX,XX +XXX,XX @@ FMOPA_s 10000000 100 ..... ... ... ..... . 00 .. @op_32
31
+ return CMD_STALL;
32
FMOPA_d 10000000 110 ..... ... ... ..... . 0 ... @op_64
32
}
33
33
34
BFMOPA 10000001 100 ..... ... ... ..... . 00 .. @op_32
34
eventid = (value & EVENTID_MASK);
35
+FMOPA_h 10000001 101 ..... ... ... ..... . 00 .. @op_32
35
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
36
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
36
MEMTXATTRS_UNSPECIFIED, &res);
37
index XXXXXXX..XXXXXXX 100644
37
38
--- a/target/arm/sme_helper.c
38
if (res != MEMTX_OK) {
39
+++ b/target/arm/sme_helper.c
39
- return result;
40
@@ -XXX,XX +XXX,XX @@ static inline uint32_t f16mop_adj_pair(uint32_t pair, uint32_t pg, uint32_t neg)
40
+ return CMD_STALL;
41
return pair;
41
}
42
}
42
43
43
icid = value & ICID_MASK;
44
+static float32 f16_dotadd(float32 sum, uint32_t e1, uint32_t e2,
44
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
45
+ float_status *s_std, float_status *s_odd)
45
dte = get_dte(s, devid, &res);
46
+{
46
47
+ float64 e1r = float16_to_float64(e1 & 0xffff, true, s_std);
47
if (res != MEMTX_OK) {
48
+ float64 e1c = float16_to_float64(e1 >> 16, true, s_std);
48
- return result;
49
+ float64 e2r = float16_to_float64(e2 & 0xffff, true, s_std);
49
+ return CMD_STALL;
50
+ float64 e2c = float16_to_float64(e2 >> 16, true, s_std);
50
}
51
+ float64 t64;
51
dte_valid = FIELD_EX64(dte, DTE, VALID);
52
+ float32 t32;
52
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
53
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
54
* we ignore this command and move onto the next
55
* command in the queue
56
*/
57
- } else {
58
- /* add ite entry to interrupt translation table */
59
- IteEntry ite = {};
60
- ite.itel = FIELD_DP64(ite.itel, ITE_L, VALID, dte_valid);
61
- ite.itel = FIELD_DP64(ite.itel, ITE_L, INTTYPE, ITE_INTTYPE_PHYSICAL);
62
- ite.itel = FIELD_DP64(ite.itel, ITE_L, INTID, pIntid);
63
- ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS);
64
- ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid);
65
-
66
- result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
67
+ return CMD_CONTINUE;
68
}
69
70
- return result;
71
+ /* add ite entry to interrupt translation table */
72
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, VALID, dte_valid);
73
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, INTTYPE, ITE_INTTYPE_PHYSICAL);
74
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, INTID, pIntid);
75
+ ite.itel = FIELD_DP64(ite.itel, ITE_L, DOORBELL, INTID_SPURIOUS);
76
+ ite.iteh = FIELD_DP32(ite.iteh, ITE_H, ICID, icid);
77
+
53
+
78
+ return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
54
+ /*
55
+ * The ARM pseudocode function FPDot performs both multiplies
56
+ * and the add with a single rounding operation. Emulate this
57
+ * by performing the first multiply in round-to-odd, then doing
58
+ * the second multiply as fused multiply-add, and rounding to
59
+ * float32 all in one step.
60
+ */
61
+ t64 = float64_mul(e1r, e2r, s_odd);
62
+ t64 = float64r32_muladd(e1c, e2c, t64, 0, s_std);
63
+
64
+ /* This conversion is exact, because we've already rounded. */
65
+ t32 = float64_to_float32(t64, s_std);
66
+
67
+ /* The final accumulation step is not fused. */
68
+ return float32_add(sum, t32, s_std);
69
+}
70
+
71
+void HELPER(sme_fmopa_h)(void *vza, void *vzn, void *vzm, void *vpn,
72
+ void *vpm, void *vst, uint32_t desc)
73
+{
74
+ intptr_t row, col, oprsz = simd_maxsz(desc);
75
+ uint32_t neg = simd_data(desc) * 0x80008000u;
76
+ uint16_t *pn = vpn, *pm = vpm;
77
+ float_status fpst_odd, fpst_std;
78
+
79
+ /*
80
+ * Make a copy of float_status because this operation does not
81
+ * update the cumulative fp exception status. It also produces
82
+ * default nans. Make a second copy with round-to-odd -- see above.
83
+ */
84
+ fpst_std = *(float_status *)vst;
85
+ set_default_nan_mode(true, &fpst_std);
86
+ fpst_odd = fpst_std;
87
+ set_float_rounding_mode(float_round_to_odd, &fpst_odd);
88
+
89
+ for (row = 0; row < oprsz; ) {
90
+ uint16_t prow = pn[H2(row >> 4)];
91
+ do {
92
+ void *vza_row = vza + tile_vslice_offset(row);
93
+ uint32_t n = *(uint32_t *)(vzn + H1_4(row));
94
+
95
+ n = f16mop_adj_pair(n, prow, neg);
96
+
97
+ for (col = 0; col < oprsz; ) {
98
+ uint16_t pcol = pm[H2(col >> 4)];
99
+ do {
100
+ if (prow & pcol & 0b0101) {
101
+ uint32_t *a = vza_row + H1_4(col);
102
+ uint32_t m = *(uint32_t *)(vzm + H1_4(col));
103
+
104
+ m = f16mop_adj_pair(m, pcol, 0);
105
+ *a = f16_dotadd(*a, n, m, &fpst_std, &fpst_odd);
106
+
107
+ col += 4;
108
+ pcol >>= 4;
109
+ }
110
+ } while (col & 15);
111
+ }
112
+ row += 4;
113
+ prow >>= 4;
114
+ } while (row & 15);
115
+ }
116
+}
117
+
118
void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn,
119
void *vpm, uint32_t desc)
120
{
121
diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c
122
index XXXXXXX..XXXXXXX 100644
123
--- a/target/arm/translate-sme.c
124
+++ b/target/arm/translate-sme.c
125
@@ -XXX,XX +XXX,XX @@ static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz,
126
return true;
79
}
127
}
80
128
81
static bool update_cte(GICv3ITSState *s, uint16_t icid, bool valid,
129
+TRANS_FEAT(FMOPA_h, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_h)
130
TRANS_FEAT(FMOPA_s, aa64_sme, do_outprod_fpst, a, MO_32, gen_helper_sme_fmopa_s)
131
TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, MO_64, gen_helper_sme_fmopa_d)
132
82
--
133
--
83
2.25.1
134
2.25.1
84
85
diff view generated by jsdifflib
1
From: Patrick Venture <venture@google.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Reviewed-by: Hao Wu <wuhaotsh@google.com>
3
This is SMOPA, SUMOPA, USMOPA_s, UMOPA, for both Int8 and Int16.
4
Signed-off-by: Patrick Venture <venture@google.com>
4
5
Message-id: 20220111172338.1525587-1-venture@google.com
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220708151540.18136-28-richard.henderson@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
---
9
hw/arm/npcm7xx_boards.c | 10 +++++++++-
10
target/arm/helper-sme.h | 16 ++++++++
10
1 file changed, 9 insertions(+), 1 deletion(-)
11
target/arm/sme.decode | 10 +++++
12
target/arm/sme_helper.c | 82 ++++++++++++++++++++++++++++++++++++++
13
target/arm/translate-sme.c | 10 +++++
14
4 files changed, 118 insertions(+)
11
15
12
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
16
diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h
13
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/arm/npcm7xx_boards.c
18
--- a/target/arm/helper-sme.h
15
+++ b/hw/arm/npcm7xx_boards.c
19
+++ b/target/arm/helper-sme.h
16
@@ -XXX,XX +XXX,XX @@ static void kudo_bmc_i2c_init(NPCM7xxState *soc)
20
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_7(sme_fmopa_d, TCG_CALL_NO_RWG,
17
{
21
void, ptr, ptr, ptr, ptr, ptr, ptr, i32)
18
I2CSlave *i2c_mux;
22
DEF_HELPER_FLAGS_6(sme_bfmopa, TCG_CALL_NO_RWG,
19
23
void, ptr, ptr, ptr, ptr, ptr, i32)
20
- i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), TYPE_PCA9548, 0x75);
24
+DEF_HELPER_FLAGS_6(sme_smopa_s, TCG_CALL_NO_RWG,
21
+ i2c_mux = i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1),
25
+ void, ptr, ptr, ptr, ptr, ptr, i32)
22
+ TYPE_PCA9548, 0x75);
26
+DEF_HELPER_FLAGS_6(sme_umopa_s, TCG_CALL_NO_RWG,
27
+ void, ptr, ptr, ptr, ptr, ptr, i32)
28
+DEF_HELPER_FLAGS_6(sme_sumopa_s, TCG_CALL_NO_RWG,
29
+ void, ptr, ptr, ptr, ptr, ptr, i32)
30
+DEF_HELPER_FLAGS_6(sme_usmopa_s, TCG_CALL_NO_RWG,
31
+ void, ptr, ptr, ptr, ptr, ptr, i32)
32
+DEF_HELPER_FLAGS_6(sme_smopa_d, TCG_CALL_NO_RWG,
33
+ void, ptr, ptr, ptr, ptr, ptr, i32)
34
+DEF_HELPER_FLAGS_6(sme_umopa_d, TCG_CALL_NO_RWG,
35
+ void, ptr, ptr, ptr, ptr, ptr, i32)
36
+DEF_HELPER_FLAGS_6(sme_sumopa_d, TCG_CALL_NO_RWG,
37
+ void, ptr, ptr, ptr, ptr, ptr, i32)
38
+DEF_HELPER_FLAGS_6(sme_usmopa_d, TCG_CALL_NO_RWG,
39
+ void, ptr, ptr, ptr, ptr, ptr, i32)
40
diff --git a/target/arm/sme.decode b/target/arm/sme.decode
41
index XXXXXXX..XXXXXXX 100644
42
--- a/target/arm/sme.decode
43
+++ b/target/arm/sme.decode
44
@@ -XXX,XX +XXX,XX @@ FMOPA_d 10000000 110 ..... ... ... ..... . 0 ... @op_64
45
46
BFMOPA 10000001 100 ..... ... ... ..... . 00 .. @op_32
47
FMOPA_h 10000001 101 ..... ... ... ..... . 00 .. @op_32
23
+
48
+
24
+ /* tmp105 is compatible with the lm75 */
49
+SMOPA_s 1010000 0 10 0 ..... ... ... ..... . 00 .. @op_32
25
+ i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 4), "tmp105", 0x5c);
50
+SUMOPA_s 1010000 0 10 1 ..... ... ... ..... . 00 .. @op_32
26
+ i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 5), "tmp105", 0x5c);
51
+USMOPA_s 1010000 1 10 0 ..... ... ... ..... . 00 .. @op_32
27
+ i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 6), "tmp105", 0x5c);
52
+UMOPA_s 1010000 1 10 1 ..... ... ... ..... . 00 .. @op_32
28
+ i2c_slave_create_simple(pca954x_i2c_get_bus(i2c_mux, 7), "tmp105", 0x5c);
29
+
53
+
30
i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), TYPE_PCA9548, 0x77);
54
+SMOPA_d 1010000 0 11 0 ..... ... ... ..... . 0 ... @op_64
31
55
+SUMOPA_d 1010000 0 11 1 ..... ... ... ..... . 0 ... @op_64
32
i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), TYPE_PCA9548, 0x77);
56
+USMOPA_d 1010000 1 11 0 ..... ... ... ..... . 0 ... @op_64
57
+UMOPA_d 1010000 1 11 1 ..... ... ... ..... . 0 ... @op_64
58
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/sme_helper.c
61
+++ b/target/arm/sme_helper.c
62
@@ -XXX,XX +XXX,XX @@ void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn,
63
} while (row & 15);
64
}
65
}
66
+
67
+typedef uint64_t IMOPFn(uint64_t, uint64_t, uint64_t, uint8_t, bool);
68
+
69
+static inline void do_imopa(uint64_t *za, uint64_t *zn, uint64_t *zm,
70
+ uint8_t *pn, uint8_t *pm,
71
+ uint32_t desc, IMOPFn *fn)
72
+{
73
+ intptr_t row, col, oprsz = simd_oprsz(desc) / 8;
74
+ bool neg = simd_data(desc);
75
+
76
+ for (row = 0; row < oprsz; ++row) {
77
+ uint8_t pa = pn[H1(row)];
78
+ uint64_t *za_row = &za[tile_vslice_index(row)];
79
+ uint64_t n = zn[row];
80
+
81
+ for (col = 0; col < oprsz; ++col) {
82
+ uint8_t pb = pm[H1(col)];
83
+ uint64_t *a = &za_row[col];
84
+
85
+ *a = fn(n, zm[col], *a, pa & pb, neg);
86
+ }
87
+ }
88
+}
89
+
90
+#define DEF_IMOP_32(NAME, NTYPE, MTYPE) \
91
+static uint64_t NAME(uint64_t n, uint64_t m, uint64_t a, uint8_t p, bool neg) \
92
+{ \
93
+ uint32_t sum0 = 0, sum1 = 0; \
94
+ /* Apply P to N as a mask, making the inactive elements 0. */ \
95
+ n &= expand_pred_b(p); \
96
+ sum0 += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \
97
+ sum0 += (NTYPE)(n >> 8) * (MTYPE)(m >> 8); \
98
+ sum0 += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \
99
+ sum0 += (NTYPE)(n >> 24) * (MTYPE)(m >> 24); \
100
+ sum1 += (NTYPE)(n >> 32) * (MTYPE)(m >> 32); \
101
+ sum1 += (NTYPE)(n >> 40) * (MTYPE)(m >> 40); \
102
+ sum1 += (NTYPE)(n >> 48) * (MTYPE)(m >> 48); \
103
+ sum1 += (NTYPE)(n >> 56) * (MTYPE)(m >> 56); \
104
+ if (neg) { \
105
+ sum0 = (uint32_t)a - sum0, sum1 = (uint32_t)(a >> 32) - sum1; \
106
+ } else { \
107
+ sum0 = (uint32_t)a + sum0, sum1 = (uint32_t)(a >> 32) + sum1; \
108
+ } \
109
+ return ((uint64_t)sum1 << 32) | sum0; \
110
+}
111
+
112
+#define DEF_IMOP_64(NAME, NTYPE, MTYPE) \
113
+static uint64_t NAME(uint64_t n, uint64_t m, uint64_t a, uint8_t p, bool neg) \
114
+{ \
115
+ uint64_t sum = 0; \
116
+ /* Apply P to N as a mask, making the inactive elements 0. */ \
117
+ n &= expand_pred_h(p); \
118
+ sum += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \
119
+ sum += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \
120
+ sum += (NTYPE)(n >> 32) * (MTYPE)(m >> 32); \
121
+ sum += (NTYPE)(n >> 48) * (MTYPE)(m >> 48); \
122
+ return neg ? a - sum : a + sum; \
123
+}
124
+
125
+DEF_IMOP_32(smopa_s, int8_t, int8_t)
126
+DEF_IMOP_32(umopa_s, uint8_t, uint8_t)
127
+DEF_IMOP_32(sumopa_s, int8_t, uint8_t)
128
+DEF_IMOP_32(usmopa_s, uint8_t, int8_t)
129
+
130
+DEF_IMOP_64(smopa_d, int16_t, int16_t)
131
+DEF_IMOP_64(umopa_d, uint16_t, uint16_t)
132
+DEF_IMOP_64(sumopa_d, int16_t, uint16_t)
133
+DEF_IMOP_64(usmopa_d, uint16_t, int16_t)
134
+
135
+#define DEF_IMOPH(NAME) \
136
+ void HELPER(sme_##NAME)(void *vza, void *vzn, void *vzm, void *vpn, \
137
+ void *vpm, uint32_t desc) \
138
+ { do_imopa(vza, vzn, vzm, vpn, vpm, desc, NAME); }
139
+
140
+DEF_IMOPH(smopa_s)
141
+DEF_IMOPH(umopa_s)
142
+DEF_IMOPH(sumopa_s)
143
+DEF_IMOPH(usmopa_s)
144
+DEF_IMOPH(smopa_d)
145
+DEF_IMOPH(umopa_d)
146
+DEF_IMOPH(sumopa_d)
147
+DEF_IMOPH(usmopa_d)
148
diff --git a/target/arm/translate-sme.c b/target/arm/translate-sme.c
149
index XXXXXXX..XXXXXXX 100644
150
--- a/target/arm/translate-sme.c
151
+++ b/target/arm/translate-sme.c
152
@@ -XXX,XX +XXX,XX @@ TRANS_FEAT(FMOPA_d, aa64_sme_f64f64, do_outprod_fpst, a, MO_64, gen_helper_sme_f
153
154
/* TODO: FEAT_EBF16 */
155
TRANS_FEAT(BFMOPA, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_bfmopa)
156
+
157
+TRANS_FEAT(SMOPA_s, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_smopa_s)
158
+TRANS_FEAT(UMOPA_s, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_umopa_s)
159
+TRANS_FEAT(SUMOPA_s, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_sumopa_s)
160
+TRANS_FEAT(USMOPA_s, aa64_sme, do_outprod, a, MO_32, gen_helper_sme_usmopa_s)
161
+
162
+TRANS_FEAT(SMOPA_d, aa64_sme_i16i64, do_outprod, a, MO_64, gen_helper_sme_smopa_d)
163
+TRANS_FEAT(UMOPA_d, aa64_sme_i16i64, do_outprod, a, MO_64, gen_helper_sme_umopa_d)
164
+TRANS_FEAT(SUMOPA_d, aa64_sme_i16i64, do_outprod, a, MO_64, gen_helper_sme_sumopa_d)
165
+TRANS_FEAT(USMOPA_d, aa64_sme_i16i64, do_outprod, a, MO_64, gen_helper_sme_usmopa_d)
33
--
166
--
34
2.25.1
167
2.25.1
35
36
diff view generated by jsdifflib
1
In a few places in the ITS command handling functions, we were
1
From: Richard Henderson <richard.henderson@linaro.org>
2
doing the range-check of an event ID or device ID only after using
3
it as a table index; move the checks to before the uses.
4
2
5
This misordering wouldn't have very bad effects because the
3
This is an SVE instruction that operates using the SVE vector
6
tables are in guest memory anyway.
4
length but that it is present only if SME is implemented.
7
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-29-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
Message-id: 20220111171048.3545974-13-peter.maydell@linaro.org
11
---
10
---
12
hw/intc/arm_gicv3_its.c | 42 ++++++++++++++++++++++++-----------------
11
target/arm/sve.decode | 20 +++++++++++++
13
1 file changed, 25 insertions(+), 17 deletions(-)
12
target/arm/translate-sve.c | 57 ++++++++++++++++++++++++++++++++++++++
13
2 files changed, 77 insertions(+)
14
14
15
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
15
diff --git a/target/arm/sve.decode b/target/arm/sve.decode
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/arm_gicv3_its.c
17
--- a/target/arm/sve.decode
18
+++ b/hw/intc/arm_gicv3_its.c
18
+++ b/target/arm/sve.decode
19
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
19
@@ -XXX,XX +XXX,XX @@ BFMLALT_zzxw 01100100 11 1 ..... 0100.1 ..... ..... @rrxr_3a esz=2
20
20
21
eventid = (value & EVENTID_MASK);
21
### SVE2 floating-point bfloat16 dot-product (indexed)
22
22
BFDOT_zzxz 01100100 01 1 ..... 010000 ..... ..... @rrxr_2 esz=2
23
+ if (devid >= s->dt.num_ids) {
23
+
24
+ qemu_log_mask(LOG_GUEST_ERROR,
24
+### SVE broadcast predicate element
25
+ "%s: invalid command attributes: devid %d>=%d",
25
+
26
+ __func__, devid, s->dt.num_ids);
26
+&psel esz pd pn pm rv imm
27
+ return CMD_CONTINUE;
27
+%psel_rv 16:2 !function=plus_12
28
+%psel_imm_b 22:2 19:2
29
+%psel_imm_h 22:2 20:1
30
+%psel_imm_s 22:2
31
+%psel_imm_d 23:1
32
+@psel ........ .. . ... .. .. pn:4 . pm:4 . pd:4 \
33
+ &psel rv=%psel_rv
34
+
35
+PSEL 00100101 .. 1 ..1 .. 01 .... 0 .... 0 .... \
36
+ @psel esz=0 imm=%psel_imm_b
37
+PSEL 00100101 .. 1 .10 .. 01 .... 0 .... 0 .... \
38
+ @psel esz=1 imm=%psel_imm_h
39
+PSEL 00100101 .. 1 100 .. 01 .... 0 .... 0 .... \
40
+ @psel esz=2 imm=%psel_imm_s
41
+PSEL 00100101 .1 1 000 .. 01 .... 0 .... 0 .... \
42
+ @psel esz=3 imm=%psel_imm_d
43
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/arm/translate-sve.c
46
+++ b/target/arm/translate-sve.c
47
@@ -XXX,XX +XXX,XX @@ static bool do_BFMLAL_zzxw(DisasContext *s, arg_rrxr_esz *a, bool sel)
48
49
TRANS_FEAT(BFMLALB_zzxw, aa64_sve_bf16, do_BFMLAL_zzxw, a, false)
50
TRANS_FEAT(BFMLALT_zzxw, aa64_sve_bf16, do_BFMLAL_zzxw, a, true)
51
+
52
+static bool trans_PSEL(DisasContext *s, arg_psel *a)
53
+{
54
+ int vl = vec_full_reg_size(s);
55
+ int pl = pred_gvec_reg_size(s);
56
+ int elements = vl >> a->esz;
57
+ TCGv_i64 tmp, didx, dbit;
58
+ TCGv_ptr ptr;
59
+
60
+ if (!dc_isar_feature(aa64_sme, s)) {
61
+ return false;
62
+ }
63
+ if (!sve_access_check(s)) {
64
+ return true;
28
+ }
65
+ }
29
+
66
+
30
dte = get_dte(s, devid, &res);
67
+ tmp = tcg_temp_new_i64();
31
68
+ dbit = tcg_temp_new_i64();
32
if (res != MEMTX_OK) {
69
+ didx = tcg_temp_new_i64();
33
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
70
+ ptr = tcg_temp_new_ptr();
34
71
+
35
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
72
+ /* Compute the predicate element. */
36
73
+ tcg_gen_addi_i64(tmp, cpu_reg(s, a->rv), a->imm);
37
+ if (eventid >= num_eventids) {
74
+ if (is_power_of_2(elements)) {
38
+ qemu_log_mask(LOG_GUEST_ERROR,
75
+ tcg_gen_andi_i64(tmp, tmp, elements - 1);
39
+ "%s: invalid command attributes: eventid %d >= %"
76
+ } else {
40
+ PRId64 "\n",
77
+ tcg_gen_remu_i64(tmp, tmp, tcg_constant_i64(elements));
41
+ __func__, eventid, num_eventids);
42
+ return CMD_CONTINUE;
43
+ }
78
+ }
44
+
79
+
45
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
80
+ /* Extract the predicate byte and bit indices. */
46
if (res != MEMTX_OK) {
81
+ tcg_gen_shli_i64(tmp, tmp, a->esz);
47
return CMD_STALL;
82
+ tcg_gen_andi_i64(dbit, tmp, 7);
48
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
83
+ tcg_gen_shri_i64(didx, tmp, 3);
49
return CMD_CONTINUE;
84
+ if (HOST_BIG_ENDIAN) {
50
}
85
+ tcg_gen_xori_i64(didx, didx, 7);
51
52
- if (devid >= s->dt.num_ids) {
53
- qemu_log_mask(LOG_GUEST_ERROR,
54
- "%s: invalid command attributes: devid %d>=%d",
55
- __func__, devid, s->dt.num_ids);
56
- return CMD_CONTINUE;
57
- }
58
- if (eventid >= num_eventids) {
59
- qemu_log_mask(LOG_GUEST_ERROR,
60
- "%s: invalid command attributes: eventid %d >= %"
61
- PRId64 "\n",
62
- __func__, eventid, num_eventids);
63
- return CMD_CONTINUE;
64
- }
65
-
66
/*
67
* Current implementation only supports rdbase == procnum
68
* Hence rdbase physical address is ignored
69
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
70
71
icid = value & ICID_MASK;
72
73
+ if (devid >= s->dt.num_ids) {
74
+ qemu_log_mask(LOG_GUEST_ERROR,
75
+ "%s: invalid command attributes: devid %d>=%d",
76
+ __func__, devid, s->dt.num_ids);
77
+ return CMD_CONTINUE;
78
+ }
86
+ }
79
+
87
+
80
dte = get_dte(s, devid, &res);
88
+ /* Load the predicate word. */
81
89
+ tcg_gen_trunc_i64_ptr(ptr, didx);
82
if (res != MEMTX_OK) {
90
+ tcg_gen_add_ptr(ptr, ptr, cpu_env);
83
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
91
+ tcg_gen_ld8u_i64(tmp, ptr, pred_full_reg_offset(s, a->pm));
84
num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
92
+
85
num_intids = 1ULL << (GICD_TYPER_IDBITS + 1);
93
+ /* Extract the predicate bit and replicate to MO_64. */
86
94
+ tcg_gen_shr_i64(tmp, tmp, dbit);
87
- if ((devid >= s->dt.num_ids) || (icid >= s->ct.num_ids)
95
+ tcg_gen_andi_i64(tmp, tmp, 1);
88
+ if ((icid >= s->ct.num_ids)
96
+ tcg_gen_neg_i64(tmp, tmp);
89
|| !dte_valid || (eventid >= num_eventids) ||
97
+
90
(((pIntid < GICV3_LPI_INTID_START) || (pIntid >= num_intids)) &&
98
+ /* Apply to either copy the source, or write zeros. */
91
(pIntid != INTID_SPURIOUS))) {
99
+ tcg_gen_gvec_ands(MO_64, pred_full_reg_offset(s, a->pd),
92
qemu_log_mask(LOG_GUEST_ERROR,
100
+ pred_full_reg_offset(s, a->pn), tmp, pl, pl);
93
"%s: invalid command attributes "
101
+
94
- "devid %d or icid %d or eventid %d or pIntid %d or"
102
+ tcg_temp_free_i64(tmp);
95
- "unmapped dte %d\n", __func__, devid, icid, eventid,
103
+ tcg_temp_free_i64(dbit);
96
+ "icid %d or eventid %d or pIntid %d or"
104
+ tcg_temp_free_i64(didx);
97
+ "unmapped dte %d\n", __func__, icid, eventid,
105
+ tcg_temp_free_ptr(ptr);
98
pIntid, dte_valid);
106
+ return true;
99
/*
107
+}
100
* in this implementation, in case of error
101
--
108
--
102
2.25.1
109
2.25.1
103
104
diff view generated by jsdifflib
1
From: Yanan Wang <wangyanan55@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Use g_queue APIs to reduce the nested loops and code indentation
3
This is an SVE instruction that operates using the SVE vector
4
with the processor hierarchy levels increasing. Consenquently,
4
length but that it is present only if SME is implemented.
5
it's more scalable to add new topology level to build_pptt.
6
5
7
No functional change intended.
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
8
Message-id: 20220708151540.18136-30-richard.henderson@linaro.org
10
Reviewed-by: Andrew Jones <drjones@redhat.com>
11
Message-id: 20220107083232.16256-4-wangyanan55@huawei.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
10
---
14
hw/acpi/aml-build.c | 50 +++++++++++++++++++++++++++++----------------
11
target/arm/helper-sve.h | 2 ++
15
1 file changed, 32 insertions(+), 18 deletions(-)
12
target/arm/sve.decode | 1 +
13
target/arm/sve_helper.c | 16 ++++++++++++++++
14
target/arm/translate-sve.c | 2 ++
15
4 files changed, 21 insertions(+)
16
16
17
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
17
diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h
18
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/acpi/aml-build.c
19
--- a/target/arm/helper-sve.h
20
+++ b/hw/acpi/aml-build.c
20
+++ b/target/arm/helper-sve.h
21
@@ -XXX,XX +XXX,XX @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags,
21
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(sve_revh_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
22
void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
22
23
const char *oem_id, const char *oem_table_id)
23
DEF_HELPER_FLAGS_4(sve_revw_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
24
{
24
25
- int pptt_start = table_data->len;
25
+DEF_HELPER_FLAGS_4(sme_revd_q, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
26
+ GQueue *list = g_queue_new();
27
+ guint pptt_start = table_data->len;
28
+ guint parent_offset;
29
+ guint length, i;
30
int uid = 0;
31
int socket;
32
AcpiTable table = { .sig = "PPTT", .rev = 2,
33
@@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
34
acpi_table_begin(&table, table_data);
35
36
for (socket = 0; socket < ms->smp.sockets; socket++) {
37
- uint32_t socket_offset = table_data->len - pptt_start;
38
- int core;
39
-
40
+ g_queue_push_tail(list,
41
+ GUINT_TO_POINTER(table_data->len - pptt_start));
42
build_processor_hierarchy_node(
43
table_data,
44
/*
45
@@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
46
*/
47
(1 << 0),
48
0, socket, NULL, 0);
49
+ }
50
51
+ length = g_queue_get_length(list);
52
+ for (i = 0; i < length; i++) {
53
+ int core;
54
+
26
+
55
+ parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
27
DEF_HELPER_FLAGS_4(sve_rbit_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
56
for (core = 0; core < ms->smp.cores; core++) {
28
DEF_HELPER_FLAGS_4(sve_rbit_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
57
- uint32_t core_offset = table_data->len - pptt_start;
29
DEF_HELPER_FLAGS_4(sve_rbit_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
58
- int thread;
30
diff --git a/target/arm/sve.decode b/target/arm/sve.decode
59
-
31
index XXXXXXX..XXXXXXX 100644
60
if (ms->smp.threads > 1) {
32
--- a/target/arm/sve.decode
61
+ g_queue_push_tail(list,
33
+++ b/target/arm/sve.decode
62
+ GUINT_TO_POINTER(table_data->len - pptt_start));
34
@@ -XXX,XX +XXX,XX @@ REVB 00000101 .. 1001 00 100 ... ..... ..... @rd_pg_rn
63
build_processor_hierarchy_node(
35
REVH 00000101 .. 1001 01 100 ... ..... ..... @rd_pg_rn
64
table_data,
36
REVW 00000101 .. 1001 10 100 ... ..... ..... @rd_pg_rn
65
(0 << 0), /* not a physical package */
37
RBIT 00000101 .. 1001 11 100 ... ..... ..... @rd_pg_rn
66
- socket_offset, core, NULL, 0);
38
+REVD 00000101 00 1011 10 100 ... ..... ..... @rd_pg_rn_e0
67
-
39
68
- for (thread = 0; thread < ms->smp.threads; thread++) {
40
# SVE vector splice (predicated, destructive)
69
- build_processor_hierarchy_node(
41
SPLICE 00000101 .. 101 100 100 ... ..... ..... @rdn_pg_rm
70
- table_data,
42
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
71
- (1 << 1) | /* ACPI Processor ID valid */
43
index XXXXXXX..XXXXXXX 100644
72
- (1 << 2) | /* Processor is a Thread */
44
--- a/target/arm/sve_helper.c
73
- (1 << 3), /* Node is a Leaf */
45
+++ b/target/arm/sve_helper.c
74
- core_offset, uid++, NULL, 0);
46
@@ -XXX,XX +XXX,XX @@ DO_ZPZ_D(sve_revh_d, uint64_t, hswap64)
75
- }
47
76
+ parent_offset, core, NULL, 0);
48
DO_ZPZ_D(sve_revw_d, uint64_t, wswap64)
77
} else {
49
78
build_processor_hierarchy_node(
50
+void HELPER(sme_revd_q)(void *vd, void *vn, void *vg, uint32_t desc)
79
table_data,
51
+{
80
(1 << 1) | /* ACPI Processor ID valid */
52
+ intptr_t i, opr_sz = simd_oprsz(desc) / 8;
81
(1 << 3), /* Node is a Leaf */
53
+ uint64_t *d = vd, *n = vn;
82
- socket_offset, uid++, NULL, 0);
54
+ uint8_t *pg = vg;
83
+ parent_offset, uid++, NULL, 0);
84
}
85
}
86
}
87
88
+ length = g_queue_get_length(list);
89
+ for (i = 0; i < length; i++) {
90
+ int thread;
91
+
55
+
92
+ parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
56
+ for (i = 0; i < opr_sz; i += 2) {
93
+ for (thread = 0; thread < ms->smp.threads; thread++) {
57
+ if (pg[H1(i)] & 1) {
94
+ build_processor_hierarchy_node(
58
+ uint64_t n0 = n[i + 0];
95
+ table_data,
59
+ uint64_t n1 = n[i + 1];
96
+ (1 << 1) | /* ACPI Processor ID valid */
60
+ d[i + 0] = n1;
97
+ (1 << 2) | /* Processor is a Thread */
61
+ d[i + 1] = n0;
98
+ (1 << 3), /* Node is a Leaf */
99
+ parent_offset, uid++, NULL, 0);
100
+ }
62
+ }
101
+ }
63
+ }
64
+}
102
+
65
+
103
+ g_queue_free(list);
66
DO_ZPZ(sve_rbit_b, uint8_t, H1, revbit8)
104
acpi_table_end(linker, &table);
67
DO_ZPZ(sve_rbit_h, uint16_t, H1_2, revbit16)
105
}
68
DO_ZPZ(sve_rbit_s, uint32_t, H1_4, revbit32)
69
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/target/arm/translate-sve.c
72
+++ b/target/arm/translate-sve.c
73
@@ -XXX,XX +XXX,XX @@ TRANS_FEAT(REVH, aa64_sve, gen_gvec_ool_arg_zpz, revh_fns[a->esz], a, 0)
74
TRANS_FEAT(REVW, aa64_sve, gen_gvec_ool_arg_zpz,
75
a->esz == 3 ? gen_helper_sve_revw_d : NULL, a, 0)
76
77
+TRANS_FEAT(REVD, aa64_sme, gen_gvec_ool_arg_zpz, gen_helper_sme_revd_q, a, 0)
78
+
79
TRANS_FEAT(SPLICE, aa64_sve, gen_gvec_ool_arg_zpzz,
80
gen_helper_sve_splice, a, a->esz)
106
81
107
--
82
--
108
2.25.1
83
2.25.1
109
110
diff view generated by jsdifflib
1
From: Marc Zyngier <maz@kernel.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Even when the VM is configured with highmem=off, the highest_gpa
3
This is an SVE instruction that operates using the SVE vector
4
field includes devices that are above the 4GiB limit.
4
length but that it is present only if SME is implemented.
5
Similarily, nothing seem to check that the memory is within
6
the limit set by the highmem=off option.
7
5
8
This leads to failures in virt_kvm_type() on systems that have
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
a crippled IPA range, as the reported IPA space is larger than
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
what it should be.
8
Message-id: 20220708151540.18136-31-richard.henderson@linaro.org
11
12
Instead, honor the user-specified limit to only use the devices
13
at the lowest end of the spectrum, and fail if we have memory
14
crossing the 4GiB limit.
15
16
Reviewed-by: Andrew Jones <drjones@redhat.com>
17
Reviewed-by: Eric Auger <eric.auger@redhat.com>
18
Signed-off-by: Marc Zyngier <maz@kernel.org>
19
Message-id: 20220114140741.1358263-4-maz@kernel.org
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
---
10
---
22
hw/arm/virt.c | 10 +++++++---
11
target/arm/helper.h | 18 +++++++
23
1 file changed, 7 insertions(+), 3 deletions(-)
12
target/arm/sve.decode | 5 ++
13
target/arm/translate-sve.c | 102 +++++++++++++++++++++++++++++++++++++
14
target/arm/vec_helper.c | 24 +++++++++
15
4 files changed, 149 insertions(+)
24
16
25
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
17
diff --git a/target/arm/helper.h b/target/arm/helper.h
26
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
27
--- a/hw/arm/virt.c
19
--- a/target/arm/helper.h
28
+++ b/hw/arm/virt.c
20
+++ b/target/arm/helper.h
29
@@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
21
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_6(gvec_bfmlal, TCG_CALL_NO_RWG,
30
static void virt_set_memmap(VirtMachineState *vms)
22
DEF_HELPER_FLAGS_6(gvec_bfmlal_idx, TCG_CALL_NO_RWG,
31
{
23
void, ptr, ptr, ptr, ptr, ptr, i32)
32
MachineState *ms = MACHINE(vms);
24
33
- hwaddr base, device_memory_base, device_memory_size;
25
+DEF_HELPER_FLAGS_5(gvec_sclamp_b, TCG_CALL_NO_RWG,
34
+ hwaddr base, device_memory_base, device_memory_size, memtop;
26
+ void, ptr, ptr, ptr, ptr, i32)
35
int i;
27
+DEF_HELPER_FLAGS_5(gvec_sclamp_h, TCG_CALL_NO_RWG,
36
28
+ void, ptr, ptr, ptr, ptr, i32)
37
vms->memmap = extended_memmap;
29
+DEF_HELPER_FLAGS_5(gvec_sclamp_s, TCG_CALL_NO_RWG,
38
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
30
+ void, ptr, ptr, ptr, ptr, i32)
39
device_memory_size = ms->maxram_size - ms->ram_size + ms->ram_slots * GiB;
31
+DEF_HELPER_FLAGS_5(gvec_sclamp_d, TCG_CALL_NO_RWG,
40
32
+ void, ptr, ptr, ptr, ptr, i32)
41
/* Base address of the high IO region */
33
+
42
- base = device_memory_base + ROUND_UP(device_memory_size, GiB);
34
+DEF_HELPER_FLAGS_5(gvec_uclamp_b, TCG_CALL_NO_RWG,
43
+ memtop = base = device_memory_base + ROUND_UP(device_memory_size, GiB);
35
+ void, ptr, ptr, ptr, ptr, i32)
44
+ if (!vms->highmem && memtop > 4 * GiB) {
36
+DEF_HELPER_FLAGS_5(gvec_uclamp_h, TCG_CALL_NO_RWG,
45
+ error_report("highmem=off, but memory crosses the 4GiB limit\n");
37
+ void, ptr, ptr, ptr, ptr, i32)
46
+ exit(EXIT_FAILURE);
38
+DEF_HELPER_FLAGS_5(gvec_uclamp_s, TCG_CALL_NO_RWG,
47
+ }
39
+ void, ptr, ptr, ptr, ptr, i32)
48
if (base < device_memory_base) {
40
+DEF_HELPER_FLAGS_5(gvec_uclamp_d, TCG_CALL_NO_RWG,
49
error_report("maxmem/slots too huge");
41
+ void, ptr, ptr, ptr, ptr, i32)
50
exit(EXIT_FAILURE);
42
+
51
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
43
#ifdef TARGET_AARCH64
52
vms->memmap[i].size = size;
44
#include "helper-a64.h"
53
base += size;
45
#include "helper-sve.h"
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 @@ PSEL 00100101 .. 1 100 .. 01 .... 0 .... 0 .... \
51
@psel esz=2 imm=%psel_imm_s
52
PSEL 00100101 .1 1 000 .. 01 .... 0 .... 0 .... \
53
@psel esz=3 imm=%psel_imm_d
54
+
55
+### SVE clamp
56
+
57
+SCLAMP 01000100 .. 0 ..... 110000 ..... ..... @rda_rn_rm
58
+UCLAMP 01000100 .. 0 ..... 110001 ..... ..... @rda_rn_rm
59
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
60
index XXXXXXX..XXXXXXX 100644
61
--- a/target/arm/translate-sve.c
62
+++ b/target/arm/translate-sve.c
63
@@ -XXX,XX +XXX,XX @@ static bool trans_PSEL(DisasContext *s, arg_psel *a)
64
tcg_temp_free_ptr(ptr);
65
return true;
66
}
67
+
68
+static void gen_sclamp_i32(TCGv_i32 d, TCGv_i32 n, TCGv_i32 m, TCGv_i32 a)
69
+{
70
+ tcg_gen_smax_i32(d, a, n);
71
+ tcg_gen_smin_i32(d, d, m);
72
+}
73
+
74
+static void gen_sclamp_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, TCGv_i64 a)
75
+{
76
+ tcg_gen_smax_i64(d, a, n);
77
+ tcg_gen_smin_i64(d, d, m);
78
+}
79
+
80
+static void gen_sclamp_vec(unsigned vece, TCGv_vec d, TCGv_vec n,
81
+ TCGv_vec m, TCGv_vec a)
82
+{
83
+ tcg_gen_smax_vec(vece, d, a, n);
84
+ tcg_gen_smin_vec(vece, d, d, m);
85
+}
86
+
87
+static void gen_sclamp(unsigned vece, uint32_t d, uint32_t n, uint32_t m,
88
+ uint32_t a, uint32_t oprsz, uint32_t maxsz)
89
+{
90
+ static const TCGOpcode vecop[] = {
91
+ INDEX_op_smin_vec, INDEX_op_smax_vec, 0
92
+ };
93
+ static const GVecGen4 ops[4] = {
94
+ { .fniv = gen_sclamp_vec,
95
+ .fno = gen_helper_gvec_sclamp_b,
96
+ .opt_opc = vecop,
97
+ .vece = MO_8 },
98
+ { .fniv = gen_sclamp_vec,
99
+ .fno = gen_helper_gvec_sclamp_h,
100
+ .opt_opc = vecop,
101
+ .vece = MO_16 },
102
+ { .fni4 = gen_sclamp_i32,
103
+ .fniv = gen_sclamp_vec,
104
+ .fno = gen_helper_gvec_sclamp_s,
105
+ .opt_opc = vecop,
106
+ .vece = MO_32 },
107
+ { .fni8 = gen_sclamp_i64,
108
+ .fniv = gen_sclamp_vec,
109
+ .fno = gen_helper_gvec_sclamp_d,
110
+ .opt_opc = vecop,
111
+ .vece = MO_64,
112
+ .prefer_i64 = TCG_TARGET_REG_BITS == 64 }
113
+ };
114
+ tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &ops[vece]);
115
+}
116
+
117
+TRANS_FEAT(SCLAMP, aa64_sme, gen_gvec_fn_arg_zzzz, gen_sclamp, a)
118
+
119
+static void gen_uclamp_i32(TCGv_i32 d, TCGv_i32 n, TCGv_i32 m, TCGv_i32 a)
120
+{
121
+ tcg_gen_umax_i32(d, a, n);
122
+ tcg_gen_umin_i32(d, d, m);
123
+}
124
+
125
+static void gen_uclamp_i64(TCGv_i64 d, TCGv_i64 n, TCGv_i64 m, TCGv_i64 a)
126
+{
127
+ tcg_gen_umax_i64(d, a, n);
128
+ tcg_gen_umin_i64(d, d, m);
129
+}
130
+
131
+static void gen_uclamp_vec(unsigned vece, TCGv_vec d, TCGv_vec n,
132
+ TCGv_vec m, TCGv_vec a)
133
+{
134
+ tcg_gen_umax_vec(vece, d, a, n);
135
+ tcg_gen_umin_vec(vece, d, d, m);
136
+}
137
+
138
+static void gen_uclamp(unsigned vece, uint32_t d, uint32_t n, uint32_t m,
139
+ uint32_t a, uint32_t oprsz, uint32_t maxsz)
140
+{
141
+ static const TCGOpcode vecop[] = {
142
+ INDEX_op_umin_vec, INDEX_op_umax_vec, 0
143
+ };
144
+ static const GVecGen4 ops[4] = {
145
+ { .fniv = gen_uclamp_vec,
146
+ .fno = gen_helper_gvec_uclamp_b,
147
+ .opt_opc = vecop,
148
+ .vece = MO_8 },
149
+ { .fniv = gen_uclamp_vec,
150
+ .fno = gen_helper_gvec_uclamp_h,
151
+ .opt_opc = vecop,
152
+ .vece = MO_16 },
153
+ { .fni4 = gen_uclamp_i32,
154
+ .fniv = gen_uclamp_vec,
155
+ .fno = gen_helper_gvec_uclamp_s,
156
+ .opt_opc = vecop,
157
+ .vece = MO_32 },
158
+ { .fni8 = gen_uclamp_i64,
159
+ .fniv = gen_uclamp_vec,
160
+ .fno = gen_helper_gvec_uclamp_d,
161
+ .opt_opc = vecop,
162
+ .vece = MO_64,
163
+ .prefer_i64 = TCG_TARGET_REG_BITS == 64 }
164
+ };
165
+ tcg_gen_gvec_4(d, n, m, a, oprsz, maxsz, &ops[vece]);
166
+}
167
+
168
+TRANS_FEAT(UCLAMP, aa64_sme, gen_gvec_fn_arg_zzzz, gen_uclamp, a)
169
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
170
index XXXXXXX..XXXXXXX 100644
171
--- a/target/arm/vec_helper.c
172
+++ b/target/arm/vec_helper.c
173
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_bfmlal_idx)(void *vd, void *vn, void *vm,
54
}
174
}
55
- vms->highest_gpa = base - 1;
175
clear_tail(d, opr_sz, simd_maxsz(desc));
56
+ vms->highest_gpa = (vms->highmem ? base : memtop) - 1;
176
}
57
if (device_memory_size > 0) {
177
+
58
ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
178
+#define DO_CLAMP(NAME, TYPE) \
59
ms->device_memory->base = device_memory_base;
179
+void HELPER(NAME)(void *d, void *n, void *m, void *a, uint32_t desc) \
180
+{ \
181
+ intptr_t i, opr_sz = simd_oprsz(desc); \
182
+ for (i = 0; i < opr_sz; i += sizeof(TYPE)) { \
183
+ TYPE aa = *(TYPE *)(a + i); \
184
+ TYPE nn = *(TYPE *)(n + i); \
185
+ TYPE mm = *(TYPE *)(m + i); \
186
+ TYPE dd = MIN(MAX(aa, nn), mm); \
187
+ *(TYPE *)(d + i) = dd; \
188
+ } \
189
+ clear_tail(d, opr_sz, simd_maxsz(desc)); \
190
+}
191
+
192
+DO_CLAMP(gvec_sclamp_b, int8_t)
193
+DO_CLAMP(gvec_sclamp_h, int16_t)
194
+DO_CLAMP(gvec_sclamp_s, int32_t)
195
+DO_CLAMP(gvec_sclamp_d, int64_t)
196
+
197
+DO_CLAMP(gvec_uclamp_b, uint8_t)
198
+DO_CLAMP(gvec_uclamp_h, uint16_t)
199
+DO_CLAMP(gvec_uclamp_s, uint32_t)
200
+DO_CLAMP(gvec_uclamp_d, uint64_t)
60
--
201
--
61
2.25.1
202
2.25.1
62
63
diff view generated by jsdifflib
1
From: Marc Zyngier <maz@kernel.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
The highmem attribute is nothing but another way to express the
3
We can handle both exception entry and exception return by
4
PA range of a VM. To support HW that has a smaller PA range then
4
hooking into aarch64_sve_change_el.
5
what QEMU assumes, pass this PA range to the virt_set_memmap()
6
function, allowing it to correctly exclude highmem devices
7
if they are outside of the PA range.
8
5
9
Signed-off-by: Marc Zyngier <maz@kernel.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20220114140741.1358263-5-maz@kernel.org
8
Message-id: 20220708151540.18136-32-richard.henderson@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
10
---
14
hw/arm/virt.c | 64 +++++++++++++++++++++++++++++++++++++++++----------
11
target/arm/helper.c | 15 +++++++++++++--
15
1 file changed, 52 insertions(+), 12 deletions(-)
12
1 file changed, 13 insertions(+), 2 deletions(-)
16
13
17
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/virt.c
16
--- a/target/arm/helper.c
20
+++ b/hw/arm/virt.c
17
+++ b/target/arm/helper.c
21
@@ -XXX,XX +XXX,XX @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)
18
@@ -XXX,XX +XXX,XX @@ void aarch64_sve_change_el(CPUARMState *env, int old_el,
22
return arm_cpu_mp_affinity(idx, clustersz);
19
return;
23
}
24
25
-static void virt_set_memmap(VirtMachineState *vms)
26
+static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
27
{
28
MachineState *ms = MACHINE(vms);
29
hwaddr base, device_memory_base, device_memory_size, memtop;
30
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
31
exit(EXIT_FAILURE);
32
}
20
}
33
21
22
+ old_a64 = old_el ? arm_el_is_aa64(env, old_el) : el0_a64;
23
+ new_a64 = new_el ? arm_el_is_aa64(env, new_el) : el0_a64;
24
+
34
+ /*
25
+ /*
35
+ * !highmem is exactly the same as limiting the PA space to 32bit,
26
+ * Both AArch64.TakeException and AArch64.ExceptionReturn
36
+ * irrespective of the underlying capabilities of the HW.
27
+ * invoke ResetSVEState when taking an exception from, or
28
+ * returning to, AArch32 state when PSTATE.SM is enabled.
37
+ */
29
+ */
38
+ if (!vms->highmem) {
30
+ if (old_a64 != new_a64 && FIELD_EX64(env->svcr, SVCR, SM)) {
39
+ pa_bits = 32;
31
+ arm_reset_sve_state(env);
32
+ return;
40
+ }
33
+ }
41
+
34
+
42
/*
35
/*
43
* We compute the base of the high IO region depending on the
36
* DDI0584A.d sec 3.2: "If SVE instructions are disabled or trapped
44
* amount of initial and device memory. The device memory start/size
37
* at ELx, or not available because the EL is in AArch32 state, then
45
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
38
@@ -XXX,XX +XXX,XX @@ void aarch64_sve_change_el(CPUARMState *env, int old_el,
46
39
* we already have the correct register contents when encountering the
47
/* Base address of the high IO region */
40
* vq0->vq0 transition between EL0->EL1.
48
memtop = base = device_memory_base + ROUND_UP(device_memory_size, GiB);
49
- if (!vms->highmem && memtop > 4 * GiB) {
50
- error_report("highmem=off, but memory crosses the 4GiB limit\n");
51
+ if (memtop > BIT_ULL(pa_bits)) {
52
+     error_report("Addressing limited to %d bits, but memory exceeds it by %llu bytes\n",
53
+             pa_bits, memtop - BIT_ULL(pa_bits));
54
exit(EXIT_FAILURE);
55
}
56
if (base < device_memory_base) {
57
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms)
58
vms->memmap[i].size = size;
59
base += size;
60
}
61
- vms->highest_gpa = (vms->highmem ? base : memtop) - 1;
62
+
63
+ /*
64
+ * If base fits within pa_bits, all good. If it doesn't, limit it
65
+ * to the end of RAM, which is guaranteed to fit within pa_bits.
66
+ */
67
+ vms->highest_gpa = (base <= BIT_ULL(pa_bits) ? base : memtop) - 1;
68
+
69
if (device_memory_size > 0) {
70
ms->device_memory = g_malloc0(sizeof(*ms->device_memory));
71
ms->device_memory->base = device_memory_base;
72
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
73
unsigned int smp_cpus = machine->smp.cpus;
74
unsigned int max_cpus = machine->smp.max_cpus;
75
76
+ if (!cpu_type_valid(machine->cpu_type)) {
77
+ error_report("mach-virt: CPU type %s not supported", machine->cpu_type);
78
+ exit(1);
79
+ }
80
+
81
+ possible_cpus = mc->possible_cpu_arch_ids(machine);
82
+
83
/*
84
* In accelerated mode, the memory map is computed earlier in kvm_type()
85
* to create a VM with the right number of IPA bits.
86
*/
41
*/
87
if (!vms->memmap) {
42
- old_a64 = old_el ? arm_el_is_aa64(env, old_el) : el0_a64;
88
- virt_set_memmap(vms);
43
old_len = (old_a64 && !sve_exception_el(env, old_el)
89
+ Object *cpuobj;
44
? sve_vqm1_for_el(env, old_el) : 0);
90
+ ARMCPU *armcpu;
45
- new_a64 = new_el ? arm_el_is_aa64(env, new_el) : el0_a64;
91
+ int pa_bits;
46
new_len = (new_a64 && !sve_exception_el(env, new_el)
92
+
47
? sve_vqm1_for_el(env, new_el) : 0);
93
+ /*
94
+ * Instanciate a temporary CPU object to find out about what
95
+ * we are about to deal with. Once this is done, get rid of
96
+ * the object.
97
+ */
98
+ cpuobj = object_new(possible_cpus->cpus[0].type);
99
+ armcpu = ARM_CPU(cpuobj);
100
+
101
+ if (object_property_get_bool(cpuobj, "aarch64", NULL)) {
102
+ pa_bits = arm_pamax(armcpu);
103
+ } else if (arm_feature(&armcpu->env, ARM_FEATURE_LPAE)) {
104
+ /* v7 with LPAE */
105
+ pa_bits = 40;
106
+ } else {
107
+ /* Anything else */
108
+ pa_bits = 32;
109
+ }
110
+
111
+ object_unref(cpuobj);
112
+
113
+ virt_set_memmap(vms, pa_bits);
114
}
115
116
/* We can probe only here because during property set
117
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
118
*/
119
finalize_gic_version(vms);
120
121
- if (!cpu_type_valid(machine->cpu_type)) {
122
- error_report("mach-virt: CPU type %s not supported", machine->cpu_type);
123
- exit(1);
124
- }
125
-
126
if (vms->secure) {
127
/*
128
* The Secure view of the world is the same as the NonSecure,
129
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
130
131
create_fdt(vms);
132
133
- possible_cpus = mc->possible_cpu_arch_ids(machine);
134
assert(possible_cpus->len == max_cpus);
135
for (n = 0; n < possible_cpus->len; n++) {
136
Object *cpuobj;
137
@@ -XXX,XX +XXX,XX @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
138
max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms, &fixed_ipa);
139
140
/* we freeze the memory map to compute the highest gpa */
141
- virt_set_memmap(vms);
142
+ virt_set_memmap(vms, max_vm_pa_size);
143
144
requested_pa_size = 64 - clz64(vms->highest_gpa);
145
48
146
--
49
--
147
2.25.1
50
2.25.1
148
149
diff view generated by jsdifflib
1
From: Marc Zyngier <maz@kernel.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Now that the devices present in the extended memory map are checked
3
Note that SME remains effectively disabled for user-only,
4
against the available PA space and disabled when they don't fit,
4
because we do not yet set CPACR_EL1.SMEN. This needs to
5
there is no need to keep the same checks against highmem, as
5
wait until the kernel ABI is implemented.
6
highmem really is a shortcut for the PA space being 32bit.
7
6
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Marc Zyngier <maz@kernel.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20220114140741.1358263-7-maz@kernel.org
9
Message-id: 20220708151540.18136-33-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
hw/arm/virt-acpi-build.c | 2 --
12
docs/system/arm/emulation.rst | 4 ++++
14
hw/arm/virt.c | 5 +----
13
target/arm/cpu64.c | 11 +++++++++++
15
2 files changed, 1 insertion(+), 6 deletions(-)
14
2 files changed, 15 insertions(+)
16
15
17
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
16
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
18
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/virt-acpi-build.c
18
--- a/docs/system/arm/emulation.rst
20
+++ b/hw/arm/virt-acpi-build.c
19
+++ b/docs/system/arm/emulation.rst
21
@@ -XXX,XX +XXX,XX @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
20
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
22
acpi_add_table(table_offsets, tables_blob);
21
- FEAT_SHA512 (Advanced SIMD SHA512 instructions)
23
build_fadt_rev5(tables_blob, tables->linker, vms, dsdt);
22
- FEAT_SM3 (Advanced SIMD SM3 instructions)
24
23
- FEAT_SM4 (Advanced SIMD SM4 instructions)
25
- vms->highmem_redists &= vms->highmem;
24
+- FEAT_SME (Scalable Matrix Extension)
26
-
25
+- FEAT_SME_FA64 (Full A64 instruction set in Streaming SVE mode)
27
acpi_add_table(table_offsets, tables_blob);
26
+- FEAT_SME_F64F64 (Double-precision floating-point outer product instructions)
28
build_madt(tables_blob, tables->linker, vms);
27
+- FEAT_SME_I16I64 (16-bit to 64-bit integer widening outer product instructions)
29
28
- FEAT_SPECRES (Speculation restriction instructions)
30
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
29
- FEAT_SSBS (Speculative Store Bypass Safe)
30
- FEAT_TLBIOS (TLB invalidate instructions in Outer Shareable domain)
31
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
31
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/arm/virt.c
33
--- a/target/arm/cpu64.c
33
+++ b/hw/arm/virt.c
34
+++ b/target/arm/cpu64.c
34
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
35
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
35
36
*/
36
virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
37
t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */
37
38
t = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT_DoubleFault */
38
- vms->highmem_mmio &= vms->highmem;
39
+ t = FIELD_DP64(t, ID_AA64PFR1, SME, 1); /* FEAT_SME */
39
- vms->highmem_redists &= vms->highmem;
40
t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */
40
-
41
cpu->isar.id_aa64pfr1 = t;
41
create_gic(vms, sysmem);
42
42
43
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
43
virt_cpu_post_init(vms, sysmem);
44
t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */
44
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
45
cpu->isar.id_aa64dfr0 = t;
45
machine->ram_size, "mach-virt.tag");
46
46
}
47
+ t = cpu->isar.id_aa64smfr0;
47
48
+ t = FIELD_DP64(t, ID_AA64SMFR0, F32F32, 1); /* FEAT_SME */
48
- vms->highmem_ecam &= vms->highmem && (!firmware_loaded || aarch64);
49
+ t = FIELD_DP64(t, ID_AA64SMFR0, B16F32, 1); /* FEAT_SME */
49
+ vms->highmem_ecam &= (!firmware_loaded || aarch64);
50
+ t = FIELD_DP64(t, ID_AA64SMFR0, F16F32, 1); /* FEAT_SME */
50
51
+ t = FIELD_DP64(t, ID_AA64SMFR0, I8I32, 0xf); /* FEAT_SME */
51
create_rtc(vms);
52
+ t = FIELD_DP64(t, ID_AA64SMFR0, F64F64, 1); /* FEAT_SME_F64F64 */
53
+ t = FIELD_DP64(t, ID_AA64SMFR0, I16I64, 0xf); /* FEAT_SME_I16I64 */
54
+ t = FIELD_DP64(t, ID_AA64SMFR0, FA64, 1); /* FEAT_SME_FA64 */
55
+ cpu->isar.id_aa64smfr0 = t;
56
+
57
/* Replicate the same data to the 32-bit id registers. */
58
aa32_max_features(cpu);
52
59
53
--
60
--
54
2.25.1
61
2.25.1
55
56
diff view generated by jsdifflib
1
From: Marc Zyngier <maz@kernel.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Just like we can control the enablement of the highmem PCIe ECAM
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
region using highmem_ecam, let's add a control for the highmem
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
PCIe MMIO region.
5
Message-id: 20220708151540.18136-34-richard.henderson@linaro.org
6
7
Similarily to highmem_ecam, this region is disabled when highmem
8
is off.
9
10
Signed-off-by: Marc Zyngier <maz@kernel.org>
11
Reviewed-by: Eric Auger <eric.auger@redhat.com>
12
Message-id: 20220114140741.1358263-2-maz@kernel.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
7
---
15
include/hw/arm/virt.h | 1 +
8
linux-user/aarch64/target_cpu.h | 5 ++++-
16
hw/arm/virt-acpi-build.c | 10 ++++------
9
1 file changed, 4 insertions(+), 1 deletion(-)
17
hw/arm/virt.c | 7 +++++--
18
3 files changed, 10 insertions(+), 8 deletions(-)
19
10
20
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
11
diff --git a/linux-user/aarch64/target_cpu.h b/linux-user/aarch64/target_cpu.h
21
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/arm/virt.h
13
--- a/linux-user/aarch64/target_cpu.h
23
+++ b/include/hw/arm/virt.h
14
+++ b/linux-user/aarch64/target_cpu.h
24
@@ -XXX,XX +XXX,XX @@ struct VirtMachineState {
15
@@ -XXX,XX +XXX,XX @@ static inline void cpu_clone_regs_parent(CPUARMState *env, unsigned flags)
25
bool secure;
16
26
bool highmem;
17
static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls)
27
bool highmem_ecam;
18
{
28
+ bool highmem_mmio;
19
- /* Note that AArch64 Linux keeps the TLS pointer in TPIDR; this is
29
bool its;
20
+ /*
30
bool tcg_its;
21
+ * Note that AArch64 Linux keeps the TLS pointer in TPIDR; this is
31
bool virt;
22
* different from AArch32 Linux, which uses TPIDRRO.
32
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
23
*/
33
index XXXXXXX..XXXXXXX 100644
24
env->cp15.tpidr_el[0] = newtls;
34
--- a/hw/arm/virt-acpi-build.c
25
+ /* TPIDR2_EL0 is cleared with CLONE_SETTLS. */
35
+++ b/hw/arm/virt-acpi-build.c
26
+ env->cp15.tpidr2_el0 = 0;
36
@@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_virtio(Aml *scope,
37
}
27
}
38
28
39
static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
29
static inline abi_ulong get_sp_from_cpustate(CPUARMState *state)
40
- uint32_t irq, bool use_highmem, bool highmem_ecam,
41
- VirtMachineState *vms)
42
+ uint32_t irq, VirtMachineState *vms)
43
{
44
- int ecam_id = VIRT_ECAM_ID(highmem_ecam);
45
+ int ecam_id = VIRT_ECAM_ID(vms->highmem_ecam);
46
struct GPEXConfig cfg = {
47
.mmio32 = memmap[VIRT_PCIE_MMIO],
48
.pio = memmap[VIRT_PCIE_PIO],
49
@@ -XXX,XX +XXX,XX @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
50
.bus = vms->bus,
51
};
52
53
- if (use_highmem) {
54
+ if (vms->highmem_mmio) {
55
cfg.mmio64 = memmap[VIRT_HIGH_PCIE_MMIO];
56
}
57
58
@@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
59
acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
60
acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
61
(irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
62
- acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE),
63
- vms->highmem, vms->highmem_ecam, vms);
64
+ acpi_dsdt_add_pci(scope, memmap, irqmap[VIRT_PCIE] + ARM_SPI_BASE, vms);
65
if (vms->acpi_dev) {
66
build_ged_aml(scope, "\\_SB."GED_DEVICE,
67
HOTPLUG_HANDLER(vms->acpi_dev),
68
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
69
index XXXXXXX..XXXXXXX 100644
70
--- a/hw/arm/virt.c
71
+++ b/hw/arm/virt.c
72
@@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms)
73
mmio_reg, base_mmio, size_mmio);
74
memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias);
75
76
- if (vms->highmem) {
77
+ if (vms->highmem_mmio) {
78
/* Map high MMIO space */
79
MemoryRegion *high_mmio_alias = g_new0(MemoryRegion, 1);
80
81
@@ -XXX,XX +XXX,XX @@ static void create_pcie(VirtMachineState *vms)
82
qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "reg",
83
2, base_ecam, 2, size_ecam);
84
85
- if (vms->highmem) {
86
+ if (vms->highmem_mmio) {
87
qemu_fdt_setprop_sized_cells(ms->fdt, nodename, "ranges",
88
1, FDT_PCI_RANGE_IOPORT, 2, 0,
89
2, base_pio, 2, size_pio,
90
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
91
92
virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
93
94
+ vms->highmem_mmio &= vms->highmem;
95
+
96
create_gic(vms, sysmem);
97
98
virt_cpu_post_init(vms, sysmem);
99
@@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj)
100
vms->gic_version = VIRT_GIC_VERSION_NOSEL;
101
102
vms->highmem_ecam = !vmc->no_highmem_ecam;
103
+ vms->highmem_mmio = true;
104
105
if (vmc->no_its) {
106
vms->its = false;
107
--
30
--
108
2.25.1
31
2.25.1
109
110
diff view generated by jsdifflib
1
From: Petr Pavlu <petr.pavlu@suse.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Implement support for reading GICC_IIDR. This register is used by the
4
Linux kernel to recognize that GICv2 with GICC_APRn is present.
5
6
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
7
Message-id: 20220113151916.17978-2-ppavlu@suse.cz
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220708151540.18136-35-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
7
---
11
hw/intc/arm_gic.c | 9 +++++++++
8
linux-user/aarch64/cpu_loop.c | 9 +++++++++
12
1 file changed, 9 insertions(+)
9
1 file changed, 9 insertions(+)
13
10
14
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
11
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
15
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/arm_gic.c
13
--- a/linux-user/aarch64/cpu_loop.c
17
+++ b/hw/intc/arm_gic.c
14
+++ b/linux-user/aarch64/cpu_loop.c
18
@@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_read(GICState *s, int cpu, int offset,
15
@@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env)
19
}
16
20
break;
17
switch (trapnr) {
21
}
18
case EXCP_SWI:
22
+ case 0xfc:
19
+ /*
23
+ if (s->revision == REV_11MPCORE) {
20
+ * On syscall, PSTATE.ZA is preserved, along with the ZA matrix.
24
+ /* Reserved on 11MPCore */
21
+ * PSTATE.SM is cleared, per SMSTOP, which does ResetSVEState.
25
+ *data = 0;
22
+ */
26
+ } else {
23
+ if (FIELD_EX64(env->svcr, SVCR, SM)) {
27
+ /* GICv1 or v2; Arm implementation */
24
+ env->svcr = FIELD_DP64(env->svcr, SVCR, SM, 0);
28
+ *data = (s->revision << 16) | 0x43b;
25
+ arm_rebuild_hflags(env);
29
+ }
26
+ arm_reset_sve_state(env);
30
+ break;
27
+ }
31
default:
28
ret = do_syscall(env,
32
qemu_log_mask(LOG_GUEST_ERROR,
29
env->xregs[8],
33
"gic_cpu_read: Bad offset %x\n", (int)offset);
30
env->xregs[0],
34
--
31
--
35
2.25.1
32
2.25.1
36
37
diff view generated by jsdifflib
1
From: Petr Pavlu <petr.pavlu@suse.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
When running Linux on a machine with GICv2, the kernel can crash while
3
Make sure to zero the currently reserved fields.
4
processing an interrupt and can subsequently start a kdump kernel from
5
the active interrupt handler. In such a case, the crashed kernel might
6
not gracefully signal the end of interrupt to the GICv2 hardware. The
7
kdump kernel will however try to reset the GIC state on startup to get
8
the controller into a sane state, in particular the kernel writes ones
9
to GICD_ICACTIVERn and wipes out GICC_APRn to make sure that no
10
interrupt is active.
11
4
12
The patch adds a logic to recalculate the running priority when
13
GICC_APRn/GICC_NSAPRn is written which makes sure that the mentioned
14
reset works with the GICv2 emulation in QEMU too and the kdump kernel
15
starts receiving interrupts.
16
17
The described scenario can be reproduced on an AArch64 QEMU virt machine
18
with a kdump-enabled Linux system by using the softdog module. The kdump
19
kernel will hang at some point because QEMU still thinks the running
20
priority is that of the timer interrupt and asserts no new interrupts to
21
the system:
22
$ modprobe softdog soft_margin=10 soft_panic=1
23
$ cat > /dev/watchdog
24
[Press Enter to start the watchdog, wait for its timeout and observe
25
that the kdump kernel hangs on startup.]
26
27
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
28
Message-id: 20220113151916.17978-3-ppavlu@suse.cz
29
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220708151540.18136-36-richard.henderson@linaro.org
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
31
---
9
---
32
hw/intc/arm_gic.c | 2 ++
10
linux-user/aarch64/signal.c | 9 ++++++++-
33
1 file changed, 2 insertions(+)
11
1 file changed, 8 insertions(+), 1 deletion(-)
34
12
35
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
13
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
36
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/intc/arm_gic.c
15
--- a/linux-user/aarch64/signal.c
38
+++ b/hw/intc/arm_gic.c
16
+++ b/linux-user/aarch64/signal.c
39
@@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset,
17
@@ -XXX,XX +XXX,XX @@ struct target_extra_context {
40
} else {
18
struct target_sve_context {
41
s->apr[regno][cpu] = value;
19
struct target_aarch64_ctx head;
42
}
20
uint16_t vl;
43
+ s->running_priority[cpu] = gic_get_prio_from_apr_bits(s, cpu);
21
- uint16_t reserved[3];
44
break;
22
+ uint16_t flags;
45
}
23
+ uint16_t reserved[2];
46
case 0xe0: case 0xe4: case 0xe8: case 0xec:
24
/* The actual SVE data immediately follows. It is laid out
47
@@ -XXX,XX +XXX,XX @@ static MemTxResult gic_cpu_write(GICState *s, int cpu, int offset,
25
* according to TARGET_SVE_SIG_{Z,P}REG_OFFSET, based off of
48
return MEMTX_OK;
26
* the original struct pointer.
49
}
27
@@ -XXX,XX +XXX,XX @@ struct target_sve_context {
50
s->nsapr[regno][cpu] = value;
28
#define TARGET_SVE_SIG_CONTEXT_SIZE(VQ) \
51
+ s->running_priority[cpu] = gic_get_prio_from_apr_bits(s, cpu);
29
(TARGET_SVE_SIG_PREG_OFFSET(VQ, 17))
52
break;
30
53
}
31
+#define TARGET_SVE_SIG_FLAG_SM 1
54
case 0x1000:
32
+
33
struct target_rt_sigframe {
34
struct target_siginfo info;
35
struct target_ucontext uc;
36
@@ -XXX,XX +XXX,XX @@ static void target_setup_sve_record(struct target_sve_context *sve,
37
{
38
int i, j;
39
40
+ memset(sve, 0, sizeof(*sve));
41
__put_user(TARGET_SVE_MAGIC, &sve->head.magic);
42
__put_user(size, &sve->head.size);
43
__put_user(vq * TARGET_SVE_VQ_BYTES, &sve->vl);
44
+ if (FIELD_EX64(env->svcr, SVCR, SM)) {
45
+ __put_user(TARGET_SVE_SIG_FLAG_SM, &sve->flags);
46
+ }
47
48
/* Note that SVE regs are stored as a byte stream, with each byte element
49
* at a subsequent address. This corresponds to a little-endian store
55
--
50
--
56
2.25.1
51
2.25.1
57
58
diff view generated by jsdifflib
1
Fix process_its_cmd() to consistently return CMD_STALL for
1
From: Richard Henderson <richard.henderson@linaro.org>
2
memory errors and CMD_CONTINUE for parameter errors, as
3
we claim in the comments that we do.
4
2
3
Fold the return value setting into the goto, so each
4
point of failure need not do both.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220708151540.18136-37-richard.henderson@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220111171048.3545974-7-peter.maydell@linaro.org
9
---
10
---
10
hw/intc/arm_gicv3_its.c | 22 +++++++++++-----------
11
linux-user/aarch64/signal.c | 26 +++++++++++---------------
11
1 file changed, 11 insertions(+), 11 deletions(-)
12
1 file changed, 11 insertions(+), 15 deletions(-)
12
13
13
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
14
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/arm_gicv3_its.c
16
--- a/linux-user/aarch64/signal.c
16
+++ b/hw/intc/arm_gicv3_its.c
17
+++ b/linux-user/aarch64/signal.c
17
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
18
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
18
bool ite_valid = false;
19
struct target_sve_context *sve = NULL;
19
uint64_t cte = 0;
20
uint64_t extra_datap = 0;
20
bool cte_valid = false;
21
bool used_extra = false;
21
- ItsCmdResult result = CMD_STALL;
22
- bool err = false;
22
uint64_t rdbase;
23
int vq = 0, sve_size = 0;
23
24
24
if (cmd == NONE) {
25
target_restore_general_frame(env, sf);
25
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
26
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
27
switch (magic) {
28
case 0:
29
if (size != 0) {
30
- err = true;
31
- goto exit;
32
+ goto err;
33
}
34
if (used_extra) {
35
ctx = NULL;
36
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
37
38
case TARGET_FPSIMD_MAGIC:
39
if (fpsimd || size != sizeof(struct target_fpsimd_context)) {
40
- err = true;
41
- goto exit;
42
+ goto err;
43
}
44
fpsimd = (struct target_fpsimd_context *)ctx;
45
break;
46
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
47
break;
48
}
49
}
50
- err = true;
51
- goto exit;
52
+ goto err;
53
54
case TARGET_EXTRA_MAGIC:
55
if (extra || size != sizeof(struct target_extra_context)) {
56
- err = true;
57
- goto exit;
58
+ goto err;
59
}
60
__get_user(extra_datap,
61
&((struct target_extra_context *)ctx)->datap);
62
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
63
/* Unknown record -- we certainly didn't generate it.
64
* Did we in fact get out of sync?
65
*/
66
- err = true;
67
- goto exit;
68
+ goto err;
69
}
70
ctx = (void *)ctx + size;
26
}
71
}
27
72
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
28
if (res != MEMTX_OK) {
73
if (fpsimd) {
29
- return result;
74
target_restore_fpsimd_record(env, fpsimd);
30
+ return CMD_STALL;
75
} else {
76
- err = true;
77
+ goto err;
31
}
78
}
32
79
33
eventid = (value & EVENTID_MASK);
80
/* SVE data, if present, overwrites FPSIMD data. */
34
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
81
if (sve) {
35
dte = get_dte(s, devid, &res);
82
target_restore_sve_record(env, sve, vq);
36
37
if (res != MEMTX_OK) {
38
- return result;
39
+ return CMD_STALL;
40
}
41
dte_valid = FIELD_EX64(dte, DTE, VALID);
42
43
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
44
ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
45
46
if (res != MEMTX_OK) {
47
- return result;
48
+ return CMD_STALL;
49
}
50
51
if (ite_valid) {
52
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
53
}
54
55
if (res != MEMTX_OK) {
56
- return result;
57
+ return CMD_STALL;
58
}
59
} else {
60
qemu_log_mask(LOG_GUEST_ERROR,
61
"%s: invalid command attributes: "
62
"invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n",
63
__func__, dte, devid, res);
64
- return result;
65
+ return CMD_CONTINUE;
66
}
67
68
69
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
70
qemu_log_mask(LOG_GUEST_ERROR,
71
"%s: invalid command attributes: devid %d>=%d",
72
__func__, devid, s->dt.num_ids);
73
-
74
+ return CMD_CONTINUE;
75
} else if (!dte_valid || !ite_valid || !cte_valid) {
76
qemu_log_mask(LOG_GUEST_ERROR,
77
"%s: invalid command attributes: "
78
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
79
dte_valid ? "valid" : "invalid",
80
ite_valid ? "valid" : "invalid",
81
cte_valid ? "valid" : "invalid");
82
+ return CMD_CONTINUE;
83
} else if (eventid >= num_eventids) {
84
qemu_log_mask(LOG_GUEST_ERROR,
85
"%s: invalid command attributes: eventid %d >= %"
86
PRId64 "\n",
87
__func__, eventid, num_eventids);
88
+ return CMD_CONTINUE;
89
} else {
90
/*
91
* Current implementation only supports rdbase == procnum
92
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
93
rdbase = FIELD_EX64(cte, CTE, RDBASE);
94
95
if (rdbase >= s->gicv3->num_cpu) {
96
- return result;
97
+ return CMD_CONTINUE;
98
}
99
100
if ((cmd == CLEAR) || (cmd == DISCARD)) {
101
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
102
if (cmd == DISCARD) {
103
IteEntry ite = {};
104
/* remove mapping from interrupt translation table */
105
- result = update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
106
+ return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
107
}
108
+ return CMD_CONTINUE;
109
}
83
}
110
-
84
-
111
- return result;
85
- exit:
86
unlock_user(extra, extra_datap, 0);
87
- return err;
88
+ return 0;
89
+
90
+ err:
91
+ unlock_user(extra, extra_datap, 0);
92
+ return 1;
112
}
93
}
113
94
114
static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
95
static abi_ulong get_sigframe(struct target_sigaction *ka,
115
--
96
--
116
2.25.1
97
2.25.1
117
118
diff view generated by jsdifflib
1
From: Lucas Ramage <lucas.ramage@infinite-omicron.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Buglink: https://gitlab.com/qemu-project/qemu/-/issues/527
3
In parse_user_sigframe, the kernel rejects duplicate sve records,
4
Signed-off-by: Lucas Ramage <lucas.ramage@infinite-omicron.com>
4
or records that are smaller than the header. We were silently
5
Message-id: 20220105205628.5491-1-oxr463@gmx.us
5
allowing these cases to pass, dropping the record.
6
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
[PMM: Move to docs/system/devices/ rather than top-level;
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
fix a pre-existing typo in passing]
9
Message-id: 20220708151540.18136-38-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
docs/system/device-emulation.rst | 1 +
12
linux-user/aarch64/signal.c | 5 ++++-
12
docs/{can.txt => system/devices/can.rst} | 90 +++++++++++-------------
13
1 file changed, 4 insertions(+), 1 deletion(-)
13
2 files changed, 41 insertions(+), 50 deletions(-)
14
rename docs/{can.txt => system/devices/can.rst} (68%)
15
14
16
diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst
15
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/docs/system/device-emulation.rst
17
--- a/linux-user/aarch64/signal.c
19
+++ b/docs/system/device-emulation.rst
18
+++ b/linux-user/aarch64/signal.c
20
@@ -XXX,XX +XXX,XX @@ Emulated Devices
19
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
21
.. toctree::
20
break;
22
:maxdepth: 1
21
23
22
case TARGET_SVE_MAGIC:
24
+ devices/can.rst
23
+ if (sve || size < sizeof(struct target_sve_context)) {
25
devices/ivshmem.rst
24
+ goto err;
26
devices/net.rst
25
+ }
27
devices/nvme.rst
26
if (cpu_isar_feature(aa64_sve, env_archcpu(env))) {
28
diff --git a/docs/can.txt b/docs/system/devices/can.rst
27
vq = sve_vq(env);
29
similarity index 68%
28
sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16);
30
rename from docs/can.txt
29
- if (!sve && size == sve_size) {
31
rename to docs/system/devices/can.rst
30
+ if (size == sve_size) {
32
index XXXXXXX..XXXXXXX 100644
31
sve = (struct target_sve_context *)ctx;
33
--- a/docs/can.txt
32
break;
34
+++ b/docs/system/devices/can.rst
33
}
35
@@ -XXX,XX +XXX,XX @@
36
-QEMU CAN bus emulation support
37
-==============================
38
-
39
+CAN Bus Emulation Support
40
+=========================
41
The CAN bus emulation provides mechanism to connect multiple
42
emulated CAN controller chips together by one or multiple CAN busses
43
(the controller device "canbus" parameter). The individual busses
44
@@ -XXX,XX +XXX,XX @@ emulated environment for testing and RTEMS GSoC slot has been donated
45
to work on CAN hardware emulation on QEMU.
46
47
Examples how to use CAN emulation for SJA1000 based boards
48
-==========================================================
49
-
50
+----------------------------------------------------------
51
When QEMU with CAN PCI support is compiled then one of the next
52
CAN boards can be selected
53
54
- (1) CAN bus Kvaser PCI CAN-S (single SJA1000 channel) boad. QEMU startup options
55
+(1) CAN bus Kvaser PCI CAN-S (single SJA1000 channel) board. QEMU startup options::
56
+
57
-object can-bus,id=canbus0
58
-device kvaser_pci,canbus=canbus0
59
- Add "can-host-socketcan" object to connect device to host system CAN bus
60
+
61
+Add "can-host-socketcan" object to connect device to host system CAN bus::
62
+
63
-object can-host-socketcan,id=canhost0,if=can0,canbus=canbus0
64
65
- (2) CAN bus PCM-3680I PCI (dual SJA1000 channel) emulation
66
+(2) CAN bus PCM-3680I PCI (dual SJA1000 channel) emulation::
67
+
68
-object can-bus,id=canbus0
69
-device pcm3680_pci,canbus0=canbus0,canbus1=canbus0
70
71
- another example:
72
+Another example::
73
+
74
-object can-bus,id=canbus0
75
-object can-bus,id=canbus1
76
-device pcm3680_pci,canbus0=canbus0,canbus1=canbus1
77
78
- (3) CAN bus MIOe-3680 PCI (dual SJA1000 channel) emulation
79
+(3) CAN bus MIOe-3680 PCI (dual SJA1000 channel) emulation::
80
+
81
-device mioe3680_pci,canbus0=canbus0
82
83
-
84
The ''kvaser_pci'' board/device model is compatible with and has been tested with
85
-''kvaser_pci'' driver included in mainline Linux kernel.
86
+the ''kvaser_pci'' driver included in mainline Linux kernel.
87
The tested setup was Linux 4.9 kernel on the host and guest side.
88
-Example for qemu-system-x86_64:
89
+
90
+Example for qemu-system-x86_64::
91
92
qemu-system-x86_64 -accel kvm -kernel /boot/vmlinuz-4.9.0-4-amd64 \
93
-initrd ramdisk.cpio \
94
@@ -XXX,XX +XXX,XX @@ Example for qemu-system-x86_64:
95
-device kvaser_pci,canbus=canbus0 \
96
-nographic -append "console=ttyS0"
97
98
-Example for qemu-system-arm:
99
+Example for qemu-system-arm::
100
101
qemu-system-arm -cpu arm1176 -m 256 -M versatilepb \
102
-kernel kernel-qemu-arm1176-versatilepb \
103
@@ -XXX,XX +XXX,XX @@ Example for qemu-system-arm:
104
The CAN interface of the host system has to be configured for proper
105
bitrate and set up. Configuration is not propagated from emulated
106
devices through bus to the physical host device. Example configuration
107
-for 1 Mbit/s
108
+for 1 Mbit/s::
109
110
ip link set can0 type can bitrate 1000000
111
ip link set can0 up
112
113
Virtual (host local only) can interface can be used on the host
114
-side instead of physical interface
115
+side instead of physical interface::
116
117
ip link add dev can0 type vcan
118
119
The CAN interface on the host side can be used to analyze CAN
120
-traffic with "candump" command which is included in "can-utils".
121
+traffic with "candump" command which is included in "can-utils"::
122
123
candump can0
124
125
CTU CAN FD support examples
126
-===========================
127
-
128
+---------------------------
129
This open-source core provides CAN FD support. CAN FD drames are
130
delivered even to the host systems when SocketCAN interface is found
131
CAN FD capable.
132
@@ -XXX,XX +XXX,XX @@ on the board.
133
Example how to connect the canbus0-bus (virtual wire) to the host
134
Linux system (SocketCAN used) and to both CTU CAN FD cores emulated
135
on the corresponding PCI card expects that host system CAN bus
136
-is setup according to the previous SJA1000 section.
137
+is setup according to the previous SJA1000 section::
138
139
qemu-system-x86_64 -enable-kvm -kernel /boot/vmlinuz-4.19.52+ \
140
-initrd ramdisk.cpio \
141
@@ -XXX,XX +XXX,XX @@ is setup according to the previous SJA1000 section.
142
-device ctucan_pci,canbus0=canbus0-bus,canbus1=canbus0-bus \
143
-nographic
144
145
-Setup of CTU CAN FD controller in a guest Linux system
146
+Setup of CTU CAN FD controller in a guest Linux system::
147
148
insmod ctucanfd.ko || modprobe ctucanfd
149
insmod ctucanfd_pci.ko || modprobe ctucanfd_pci
150
@@ -XXX,XX +XXX,XX @@ Setup of CTU CAN FD controller in a guest Linux system
151
/bin/ip link set $ifc up
152
done
153
154
-The test can run for example
155
+The test can run for example::
156
157
candump can1
158
159
-in the guest system and next commands in the host system for basic CAN
160
+in the guest system and next commands in the host system for basic CAN::
161
162
cangen can0
163
164
-for CAN FD without bitrate switch
165
+for CAN FD without bitrate switch::
166
167
cangen can0 -f
168
169
-and with bitrate switch
170
+and with bitrate switch::
171
172
cangen can0 -b
173
174
@@ -XXX,XX +XXX,XX @@ The test can be run viceversa, generate messages in the guest system and capture
175
in the host one and much more combinations.
176
177
Links to other resources
178
-========================
179
+------------------------
180
181
- (1) CAN related projects at Czech Technical University, Faculty of Electrical Engineering
182
- http://canbus.pages.fel.cvut.cz/
183
- (2) Repository with development can-pci branch at Czech Technical University
184
- https://gitlab.fel.cvut.cz/canbus/qemu-canbus
185
- (3) RTEMS page describing project
186
- https://devel.rtems.org/wiki/Developer/Simulators/QEMU/CANEmulation
187
- (4) RTLWS 2015 article about the project and its use with CANopen emulation
188
- http://cmp.felk.cvut.cz/~pisa/can/doc/rtlws-17-pisa-qemu-can.pdf
189
- (5) GNU/Linux, CAN and CANopen in Real-time Control Applications
190
- Slides from LinuxDays 2017 (include updated RTLWS 2015 content)
191
- https://www.linuxdays.cz/2017/video/Pavel_Pisa-CAN_canopen.pdf
192
- (6) Linux SocketCAN utilities
193
- https://github.com/linux-can/can-utils/
194
- (7) CTU CAN FD project including core VHDL design, Linux driver,
195
- test utilities etc.
196
- https://gitlab.fel.cvut.cz/canbus/ctucanfd_ip_core
197
- (8) CTU CAN FD Core Datasheet Documentation
198
- http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/Progdokum.pdf
199
- (9) CTU CAN FD Core System Architecture Documentation
200
- http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/ctu_can_fd_architecture.pdf
201
- (10) CTU CAN FD Driver Documentation
202
- http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/driver_doc/ctucanfd-driver.html
203
- (11) Integration with PCIe interfacing for Intel/Altera Cyclone IV based board
204
- https://gitlab.fel.cvut.cz/canbus/pcie-ctu_can_fd
205
+ (1) `CAN related projects at Czech Technical University, Faculty of Electrical Engineering <http://canbus.pages.fel.cvut.cz>`_
206
+ (2) `Repository with development can-pci branch at Czech Technical University <https://gitlab.fel.cvut.cz/canbus/qemu-canbus>`_
207
+ (3) `RTEMS page describing project <https://devel.rtems.org/wiki/Developer/Simulators/QEMU/CANEmulation>`_
208
+ (4) `RTLWS 2015 article about the project and its use with CANopen emulation <http://cmp.felk.cvut.cz/~pisa/can/doc/rtlws-17-pisa-qemu-can.pdf>`_
209
+ (5) `GNU/Linux, CAN and CANopen in Real-time Control Applications Slides from LinuxDays 2017 (include updated RTLWS 2015 content) <https://www.linuxdays.cz/2017/video/Pavel_Pisa-CAN_canopen.pdf>`_
210
+ (6) `Linux SocketCAN utilities <https://github.com/linux-can/can-utils>`_
211
+ (7) `CTU CAN FD project including core VHDL design, Linux driver, test utilities etc. <https://gitlab.fel.cvut.cz/canbus/ctucanfd_ip_core>`_
212
+ (8) `CTU CAN FD Core Datasheet Documentation <http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/Progdokum.pdf>`_
213
+ (9) `CTU CAN FD Core System Architecture Documentation <http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/ctu_can_fd_architecture.pdf>`_
214
+ (10) `CTU CAN FD Driver Documentation <http://canbus.pages.fel.cvut.cz/ctucanfd_ip_core/driver_doc/ctucanfd-driver.html>`_
215
+ (11) `Integration with PCIe interfacing for Intel/Altera Cyclone IV based board <https://gitlab.fel.cvut.cz/canbus/pcie-ctu_can_fd>`_
216
--
34
--
217
2.25.1
35
2.25.1
218
219
diff view generated by jsdifflib
1
From: Yanan Wang <wangyanan55@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Run ./tests/data/acpi/rebuild-expected-aml.sh from build directory
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
to update PPTT binary. Also empty bios-tables-test-allowed-diff.h.
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
5
Message-id: 20220708151540.18136-39-richard.henderson@linaro.org
6
The disassembled differences between actual and expected PPTT:
7
8
/*
9
* Intel ACPI Component Architecture
10
* AML/ASL+ Disassembler version 20200528 (64-bit version)
11
* Copyright (c) 2000 - 2020 Intel Corporation
12
*
13
- * Disassembly of tests/data/acpi/virt/PPTT, Tue Jan 4 12:51:11 2022
14
+ * Disassembly of /tmp/aml-2ZGOF1, Tue Jan 4 12:51:11 2022
15
*
16
* ACPI Data Table [PPTT]
17
*
18
* Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue
19
*/
20
21
[000h 0000 4] Signature : "PPTT" [Processor Properties Topology Table]
22
-[004h 0004 4] Table Length : 0000004C
23
+[004h 0004 4] Table Length : 00000060
24
[008h 0008 1] Revision : 02
25
-[009h 0009 1] Checksum : A8
26
+[009h 0009 1] Checksum : 48
27
[00Ah 0010 6] Oem ID : "BOCHS "
28
[010h 0016 8] Oem Table ID : "BXPC "
29
[018h 0024 4] Oem Revision : 00000001
30
[01Ch 0028 4] Asl Compiler ID : "BXPC"
31
[020h 0032 4] Asl Compiler Revision : 00000001
32
33
[024h 0036 1] Subtable Type : 00 [Processor Hierarchy Node]
34
[025h 0037 1] Length : 14
35
[026h 0038 2] Reserved : 0000
36
[028h 0040 4] Flags (decoded below) : 00000001
37
Physical package : 1
38
ACPI Processor ID valid : 0
39
Processor is a thread : 0
40
Node is a leaf : 0
41
Identical Implementation : 0
42
[02Ch 0044 4] Parent : 00000000
43
[030h 0048 4] ACPI Processor ID : 00000000
44
[034h 0052 4] Private Resource Number : 00000000
45
46
[038h 0056 1] Subtable Type : 00 [Processor Hierarchy Node]
47
[039h 0057 1] Length : 14
48
[03Ah 0058 2] Reserved : 0000
49
-[03Ch 0060 4] Flags (decoded below) : 0000000A
50
+[03Ch 0060 4] Flags (decoded below) : 00000000
51
Physical package : 0
52
- ACPI Processor ID valid : 1
53
+ ACPI Processor ID valid : 0
54
Processor is a thread : 0
55
- Node is a leaf : 1
56
+ Node is a leaf : 0
57
Identical Implementation : 0
58
[040h 0064 4] Parent : 00000024
59
[044h 0068 4] ACPI Processor ID : 00000000
60
[048h 0072 4] Private Resource Number : 00000000
61
62
-Raw Table Data: Length 76 (0x4C)
63
+[04Ch 0076 1] Subtable Type : 00 [Processor Hierarchy Node]
64
+[04Dh 0077 1] Length : 14
65
+[04Eh 0078 2] Reserved : 0000
66
+[050h 0080 4] Flags (decoded below) : 0000000A
67
+ Physical package : 0
68
+ ACPI Processor ID valid : 1
69
+ Processor is a thread : 0
70
+ Node is a leaf : 1
71
+ Identical Implementation : 0
72
+[054h 0084 4] Parent : 00000038
73
+[058h 0088 4] ACPI Processor ID : 00000000
74
+[05Ch 0092 4] Private Resource Number : 00000000
75
+
76
+Raw Table Data: Length 96 (0x60)
77
78
- 0000: 50 50 54 54 4C 00 00 00 02 A8 42 4F 43 48 53 20 // PPTTL.....BOCHS
79
+ 0000: 50 50 54 54 60 00 00 00 02 48 42 4F 43 48 53 20 // PPTT`....HBOCHS
80
0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC
81
0020: 01 00 00 00 00 14 00 00 01 00 00 00 00 00 00 00 // ................
82
- 0030: 00 00 00 00 00 00 00 00 00 14 00 00 0A 00 00 00 // ................
83
- 0040: 24 00 00 00 00 00 00 00 00 00 00 00 // $...........
84
+ 0030: 00 00 00 00 00 00 00 00 00 14 00 00 00 00 00 00 // ................
85
+ 0040: 24 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 // $...............
86
+ 0050: 0A 00 00 00 38 00 00 00 00 00 00 00 00 00 00 00 // ....8...........
87
88
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
89
Reviewed-by: Ani Sinha <ani@anisinha.ca>
90
Message-id: 20220107083232.16256-7-wangyanan55@huawei.com
91
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
92
---
7
---
93
tests/qtest/bios-tables-test-allowed-diff.h | 1 -
8
linux-user/aarch64/signal.c | 3 +++
94
tests/data/acpi/virt/PPTT | Bin 76 -> 96 bytes
9
1 file changed, 3 insertions(+)
95
2 files changed, 1 deletion(-)
96
10
97
diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
11
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
98
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
99
--- a/tests/qtest/bios-tables-test-allowed-diff.h
13
--- a/linux-user/aarch64/signal.c
100
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
14
+++ b/linux-user/aarch64/signal.c
101
@@ -1,2 +1 @@
15
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
102
/* List of comma-separated changed AML files to ignore */
16
__get_user(extra_size,
103
-"tests/data/acpi/virt/PPTT",
17
&((struct target_extra_context *)ctx)->size);
104
diff --git a/tests/data/acpi/virt/PPTT b/tests/data/acpi/virt/PPTT
18
extra = lock_user(VERIFY_READ, extra_datap, extra_size, 0);
105
index XXXXXXX..XXXXXXX 100644
19
+ if (!extra) {
106
GIT binary patch
20
+ return 1;
107
delta 53
21
+ }
108
pcmeZC;0g!`2}xjJU|{l?$YrDgWH5jU5Ca567#O&Klm(arApowi1QY-O
22
break;
109
23
110
delta 32
24
default:
111
fcmYfB;R*-{3GrcIU|?D?k;`ae01J-_kOKn%ZFdCM
112
113
--
25
--
114
2.25.1
26
2.25.1
115
116
diff view generated by jsdifflib
1
Refactor process_its_cmd() so that it consistently uses
1
From: Richard Henderson <richard.henderson@linaro.org>
2
the structure
3
do thing;
4
if (error condition) {
5
return early;
6
}
7
do next thing;
8
2
9
rather than doing some of the work nested inside if (not error)
3
Move the checks out of the parsing loop and into the
10
code blocks.
4
restore function. This more closely mirrors the code
5
structure in the kernel, and is slightly clearer.
11
6
7
Reject rather than silently skip incorrect VL and SVE record sizes,
8
bringing our checks in to line with those the kernel does.
9
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20220708151540.18136-40-richard.henderson@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20220111171048.3545974-8-peter.maydell@linaro.org
16
---
14
---
17
hw/intc/arm_gicv3_its.c | 103 +++++++++++++++++++---------------------
15
linux-user/aarch64/signal.c | 51 +++++++++++++++++++++++++------------
18
1 file changed, 50 insertions(+), 53 deletions(-)
16
1 file changed, 35 insertions(+), 16 deletions(-)
19
17
20
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
18
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
21
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/intc/arm_gicv3_its.c
20
--- a/linux-user/aarch64/signal.c
23
+++ b/hw/intc/arm_gicv3_its.c
21
+++ b/linux-user/aarch64/signal.c
24
@@ -XXX,XX +XXX,XX @@ static ItsCmdResult process_its_cmd(GICv3ITSState *s, uint64_t value,
22
@@ -XXX,XX +XXX,XX @@ static void target_restore_fpsimd_record(CPUARMState *env,
25
}
23
}
26
dte_valid = FIELD_EX64(dte, DTE, VALID);
24
}
27
25
28
- if (dte_valid) {
26
-static void target_restore_sve_record(CPUARMState *env,
29
- num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
27
- struct target_sve_context *sve, int vq)
30
-
28
+static bool target_restore_sve_record(CPUARMState *env,
31
- ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
29
+ struct target_sve_context *sve,
32
-
30
+ int size)
33
- if (res != MEMTX_OK) {
31
{
34
- return CMD_STALL;
32
- int i, j;
35
- }
33
+ int i, j, vl, vq;
36
-
34
37
- if (ite_valid) {
35
- /* Note that SVE regs are stored as a byte stream, with each byte element
38
- cte_valid = get_cte(s, icid, &cte, &res);
36
+ if (!cpu_isar_feature(aa64_sve, env_archcpu(env))) {
39
- }
37
+ return false;
40
-
41
- if (res != MEMTX_OK) {
42
- return CMD_STALL;
43
- }
44
- } else {
45
+ if (!dte_valid) {
46
qemu_log_mask(LOG_GUEST_ERROR,
47
"%s: invalid command attributes: "
48
- "invalid dte: %"PRIx64" for %d (MEM_TX: %d)\n",
49
- __func__, dte, devid, res);
50
+ "invalid dte: %"PRIx64" for %d\n",
51
+ __func__, dte, devid);
52
return CMD_CONTINUE;
53
}
54
55
+ num_eventids = 1ULL << (FIELD_EX64(dte, DTE, SIZE) + 1);
56
+
57
+ ite_valid = get_ite(s, eventid, dte, &icid, &pIntid, &res);
58
+ if (res != MEMTX_OK) {
59
+ return CMD_STALL;
60
+ }
38
+ }
61
+
39
+
62
+ if (!ite_valid) {
40
+ __get_user(vl, &sve->vl);
63
+ qemu_log_mask(LOG_GUEST_ERROR,
41
+ vq = sve_vq(env);
64
+ "%s: invalid command attributes: invalid ITE\n",
42
+
65
+ __func__);
43
+ /* Reject mismatched VL. */
66
+ return CMD_CONTINUE;
44
+ if (vl != vq * TARGET_SVE_VQ_BYTES) {
45
+ return false;
67
+ }
46
+ }
68
+
47
+
69
+ cte_valid = get_cte(s, icid, &cte, &res);
48
+ /* Accept empty record -- used to clear PSTATE.SM. */
70
+ if (res != MEMTX_OK) {
49
+ if (size <= sizeof(*sve)) {
71
+ return CMD_STALL;
50
+ return true;
72
+ }
73
+ if (!cte_valid) {
74
+ qemu_log_mask(LOG_GUEST_ERROR,
75
+ "%s: invalid command attributes: "
76
+ "invalid cte: %"PRIx64"\n",
77
+ __func__, cte);
78
+ return CMD_CONTINUE;
79
+ }
80
81
- /*
82
- * In this implementation, in case of guest errors we ignore the
83
- * command and move onto the next command in the queue.
84
- */
85
if (devid >= s->dt.num_ids) {
86
qemu_log_mask(LOG_GUEST_ERROR,
87
"%s: invalid command attributes: devid %d>=%d",
88
__func__, devid, s->dt.num_ids);
89
return CMD_CONTINUE;
90
- } else if (!dte_valid || !ite_valid || !cte_valid) {
91
- qemu_log_mask(LOG_GUEST_ERROR,
92
- "%s: invalid command attributes: "
93
- "dte: %s, ite: %s, cte: %s\n",
94
- __func__,
95
- dte_valid ? "valid" : "invalid",
96
- ite_valid ? "valid" : "invalid",
97
- cte_valid ? "valid" : "invalid");
98
- return CMD_CONTINUE;
99
- } else if (eventid >= num_eventids) {
100
+ }
101
+ if (eventid >= num_eventids) {
102
qemu_log_mask(LOG_GUEST_ERROR,
103
"%s: invalid command attributes: eventid %d >= %"
104
PRId64 "\n",
105
__func__, eventid, num_eventids);
106
return CMD_CONTINUE;
107
- } else {
108
- /*
109
- * Current implementation only supports rdbase == procnum
110
- * Hence rdbase physical address is ignored
111
- */
112
- rdbase = FIELD_EX64(cte, CTE, RDBASE);
113
+ }
114
115
- if (rdbase >= s->gicv3->num_cpu) {
116
- return CMD_CONTINUE;
117
- }
118
+ /*
119
+ * Current implementation only supports rdbase == procnum
120
+ * Hence rdbase physical address is ignored
121
+ */
122
+ rdbase = FIELD_EX64(cte, CTE, RDBASE);
123
124
- if ((cmd == CLEAR) || (cmd == DISCARD)) {
125
- gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 0);
126
- } else {
127
- gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 1);
128
- }
129
-
130
- if (cmd == DISCARD) {
131
- IteEntry ite = {};
132
- /* remove mapping from interrupt translation table */
133
- return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
134
- }
135
+ if (rdbase >= s->gicv3->num_cpu) {
136
return CMD_CONTINUE;
137
}
138
+
139
+ if ((cmd == CLEAR) || (cmd == DISCARD)) {
140
+ gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 0);
141
+ } else {
142
+ gicv3_redist_process_lpi(&s->gicv3->cpu[rdbase], pIntid, 1);
143
+ }
51
+ }
144
+
52
+
145
+ if (cmd == DISCARD) {
53
+ /* Reject non-empty but incomplete record. */
146
+ IteEntry ite = {};
54
+ if (size < TARGET_SVE_SIG_CONTEXT_SIZE(vq)) {
147
+ /* remove mapping from interrupt translation table */
55
+ return false;
148
+ return update_ite(s, eventid, dte, ite) ? CMD_CONTINUE : CMD_STALL;
149
+ }
56
+ }
150
+ return CMD_CONTINUE;
57
+
58
+ /*
59
+ * Note that SVE regs are stored as a byte stream, with each byte element
60
* at a subsequent address. This corresponds to a little-endian load
61
* of our 64-bit hunks.
62
*/
63
@@ -XXX,XX +XXX,XX @@ static void target_restore_sve_record(CPUARMState *env,
64
}
65
}
66
}
67
+ return true;
151
}
68
}
152
69
153
static ItsCmdResult process_mapti(GICv3ITSState *s, uint64_t value,
70
static int target_restore_sigframe(CPUARMState *env,
71
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
72
struct target_sve_context *sve = NULL;
73
uint64_t extra_datap = 0;
74
bool used_extra = false;
75
- int vq = 0, sve_size = 0;
76
+ int sve_size = 0;
77
78
target_restore_general_frame(env, sf);
79
80
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
81
if (sve || size < sizeof(struct target_sve_context)) {
82
goto err;
83
}
84
- if (cpu_isar_feature(aa64_sve, env_archcpu(env))) {
85
- vq = sve_vq(env);
86
- sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16);
87
- if (size == sve_size) {
88
- sve = (struct target_sve_context *)ctx;
89
- break;
90
- }
91
- }
92
- goto err;
93
+ sve = (struct target_sve_context *)ctx;
94
+ sve_size = size;
95
+ break;
96
97
case TARGET_EXTRA_MAGIC:
98
if (extra || size != sizeof(struct target_extra_context)) {
99
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
100
}
101
102
/* SVE data, if present, overwrites FPSIMD data. */
103
- if (sve) {
104
- target_restore_sve_record(env, sve, vq);
105
+ if (sve && !target_restore_sve_record(env, sve, sve_size)) {
106
+ goto err;
107
}
108
unlock_user(extra, extra_datap, 0);
109
return 0;
154
--
110
--
155
2.25.1
111
2.25.1
156
157
diff view generated by jsdifflib
1
From: Troy Lee <troy_lee@aspeedtech.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Add the new i3c device to the AST2600 SoC.
3
Set the SM bit in the SVE record on signal delivery, create the ZA record.
4
Restore SM and ZA state according to the records present on return.
4
5
5
Signed-off-by: Troy Lee <troy_lee@aspeedtech.com>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Graeme Gregory <quic_ggregory@quicinc.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Message-id: 20220708151540.18136-41-richard.henderson@linaro.org
8
Tested-by: Graeme Gregory <quic_ggregory@quicinc.com>
9
Message-id: 20220111084546.4145785-3-troy_lee@aspeedtech.com
10
[PMM: tidied commit message]
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
10
---
13
include/hw/arm/aspeed_soc.h | 3 +++
11
linux-user/aarch64/signal.c | 167 +++++++++++++++++++++++++++++++++---
14
hw/arm/aspeed_ast2600.c | 16 ++++++++++++++++
12
1 file changed, 154 insertions(+), 13 deletions(-)
15
2 files changed, 19 insertions(+)
16
13
17
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
14
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
18
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/aspeed_soc.h
16
--- a/linux-user/aarch64/signal.c
20
+++ b/include/hw/arm/aspeed_soc.h
17
+++ b/linux-user/aarch64/signal.c
21
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ struct target_sve_context {
22
#include "hw/timer/aspeed_timer.h"
19
23
#include "hw/rtc/aspeed_rtc.h"
20
#define TARGET_SVE_SIG_FLAG_SM 1
24
#include "hw/i2c/aspeed_i2c.h"
21
25
+#include "hw/misc/aspeed_i3c.h"
22
+#define TARGET_ZA_MAGIC 0x54366345
26
#include "hw/ssi/aspeed_smc.h"
23
+
27
#include "hw/misc/aspeed_hace.h"
24
+struct target_za_context {
28
#include "hw/watchdog/wdt_aspeed.h"
25
+ struct target_aarch64_ctx head;
29
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
26
+ uint16_t vl;
30
AspeedRtcState rtc;
27
+ uint16_t reserved[3];
31
AspeedTimerCtrlState timerctrl;
28
+ /* The actual ZA data immediately follows. */
32
AspeedI2CState i2c;
29
+};
33
+ AspeedI3CState i3c;
30
+
34
AspeedSCUState scu;
31
+#define TARGET_ZA_SIG_REGS_OFFSET \
35
AspeedHACEState hace;
32
+ QEMU_ALIGN_UP(sizeof(struct target_za_context), TARGET_SVE_VQ_BYTES)
36
AspeedXDMAState xdma;
33
+#define TARGET_ZA_SIG_ZAV_OFFSET(VQ, N) \
37
@@ -XXX,XX +XXX,XX @@ enum {
34
+ (TARGET_ZA_SIG_REGS_OFFSET + (VQ) * TARGET_SVE_VQ_BYTES * (N))
38
ASPEED_DEV_HACE,
35
+#define TARGET_ZA_SIG_CONTEXT_SIZE(VQ) \
39
ASPEED_DEV_DPMCU,
36
+ TARGET_ZA_SIG_ZAV_OFFSET(VQ, VQ * TARGET_SVE_VQ_BYTES)
40
ASPEED_DEV_DP,
37
+
41
+ ASPEED_DEV_I3C,
38
struct target_rt_sigframe {
42
};
39
struct target_siginfo info;
43
40
struct target_ucontext uc;
44
#endif /* ASPEED_SOC_H */
41
@@ -XXX,XX +XXX,XX @@ static void target_setup_end_record(struct target_aarch64_ctx *end)
45
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/arm/aspeed_ast2600.c
48
+++ b/hw/arm/aspeed_ast2600.c
49
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {
50
[ASPEED_DEV_UART1] = 0x1E783000,
51
[ASPEED_DEV_UART5] = 0x1E784000,
52
[ASPEED_DEV_VUART] = 0x1E787000,
53
+ [ASPEED_DEV_I3C] = 0x1E7A0000,
54
[ASPEED_DEV_SDRAM] = 0x80000000,
55
};
56
57
@@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = {
58
[ASPEED_DEV_ETH4] = 33,
59
[ASPEED_DEV_KCS] = 138, /* 138 -> 142 */
60
[ASPEED_DEV_DP] = 62,
61
+ [ASPEED_DEV_I3C] = 102, /* 102 -> 107 */
62
};
63
64
static qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int ctrl)
65
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
66
67
snprintf(typename, sizeof(typename), "aspeed.hace-%s", socname);
68
object_initialize_child(obj, "hace", &s->hace, typename);
69
+
70
+ object_initialize_child(obj, "i3c", &s->i3c, TYPE_ASPEED_I3C);
71
}
42
}
72
43
73
/*
44
static void target_setup_sve_record(struct target_sve_context *sve,
74
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
45
- CPUARMState *env, int vq, int size)
75
sysbus_mmio_map(SYS_BUS_DEVICE(&s->hace), 0, sc->memmap[ASPEED_DEV_HACE]);
46
+ CPUARMState *env, int size)
76
sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0,
47
{
77
aspeed_soc_get_irq(s, ASPEED_DEV_HACE));
48
- int i, j;
78
+
49
+ int i, j, vq = sve_vq(env);
79
+ /* I3C */
50
80
+ if (!sysbus_realize(SYS_BUS_DEVICE(&s->i3c), errp)) {
51
memset(sve, 0, sizeof(*sve));
52
__put_user(TARGET_SVE_MAGIC, &sve->head.magic);
53
@@ -XXX,XX +XXX,XX @@ static void target_setup_sve_record(struct target_sve_context *sve,
54
}
55
}
56
57
+static void target_setup_za_record(struct target_za_context *za,
58
+ CPUARMState *env, int size)
59
+{
60
+ int vq = sme_vq(env);
61
+ int vl = vq * TARGET_SVE_VQ_BYTES;
62
+ int i, j;
63
+
64
+ memset(za, 0, sizeof(*za));
65
+ __put_user(TARGET_ZA_MAGIC, &za->head.magic);
66
+ __put_user(size, &za->head.size);
67
+ __put_user(vl, &za->vl);
68
+
69
+ if (size == TARGET_ZA_SIG_CONTEXT_SIZE(0)) {
81
+ return;
70
+ return;
82
+ }
71
+ }
83
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]);
72
+ assert(size == TARGET_ZA_SIG_CONTEXT_SIZE(vq));
84
+ for (i = 0; i < ASPEED_I3C_NR_DEVICES; i++) {
73
+
85
+ qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore),
74
+ /*
86
+ sc->irqmap[ASPEED_DEV_I3C] + i);
75
+ * Note that ZA vectors are stored as a byte stream,
87
+ /* The AST2600 I3C controller has one IRQ per bus. */
76
+ * with each byte element at a subsequent address.
88
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->i3c.devices[i]), 0, irq);
77
+ */
89
+ }
78
+ for (i = 0; i < vl; ++i) {
79
+ uint64_t *z = (void *)za + TARGET_ZA_SIG_ZAV_OFFSET(vq, i);
80
+ for (j = 0; j < vq * 2; ++j) {
81
+ __put_user_e(env->zarray[i].d[j], z + j, le);
82
+ }
83
+ }
84
+}
85
+
86
static void target_restore_general_frame(CPUARMState *env,
87
struct target_rt_sigframe *sf)
88
{
89
@@ -XXX,XX +XXX,XX @@ static void target_restore_fpsimd_record(CPUARMState *env,
90
91
static bool target_restore_sve_record(CPUARMState *env,
92
struct target_sve_context *sve,
93
- int size)
94
+ int size, int *svcr)
95
{
96
- int i, j, vl, vq;
97
+ int i, j, vl, vq, flags;
98
+ bool sm;
99
100
- if (!cpu_isar_feature(aa64_sve, env_archcpu(env))) {
101
+ __get_user(vl, &sve->vl);
102
+ __get_user(flags, &sve->flags);
103
+
104
+ sm = flags & TARGET_SVE_SIG_FLAG_SM;
105
+
106
+ /* The cpu must support Streaming or Non-streaming SVE. */
107
+ if (sm
108
+ ? !cpu_isar_feature(aa64_sme, env_archcpu(env))
109
+ : !cpu_isar_feature(aa64_sve, env_archcpu(env))) {
110
return false;
111
}
112
113
- __get_user(vl, &sve->vl);
114
- vq = sve_vq(env);
115
+ /*
116
+ * Note that we cannot use sve_vq() because that depends on the
117
+ * current setting of PSTATE.SM, not the state to be restored.
118
+ */
119
+ vq = sve_vqm1_for_el_sm(env, 0, sm) + 1;
120
121
/* Reject mismatched VL. */
122
if (vl != vq * TARGET_SVE_VQ_BYTES) {
123
@@ -XXX,XX +XXX,XX @@ static bool target_restore_sve_record(CPUARMState *env,
124
return false;
125
}
126
127
+ *svcr = FIELD_DP64(*svcr, SVCR, SM, sm);
128
+
129
/*
130
* Note that SVE regs are stored as a byte stream, with each byte element
131
* at a subsequent address. This corresponds to a little-endian load
132
@@ -XXX,XX +XXX,XX @@ static bool target_restore_sve_record(CPUARMState *env,
133
return true;
90
}
134
}
91
135
92
static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data)
136
+static bool target_restore_za_record(CPUARMState *env,
137
+ struct target_za_context *za,
138
+ int size, int *svcr)
139
+{
140
+ int i, j, vl, vq;
141
+
142
+ if (!cpu_isar_feature(aa64_sme, env_archcpu(env))) {
143
+ return false;
144
+ }
145
+
146
+ __get_user(vl, &za->vl);
147
+ vq = sme_vq(env);
148
+
149
+ /* Reject mismatched VL. */
150
+ if (vl != vq * TARGET_SVE_VQ_BYTES) {
151
+ return false;
152
+ }
153
+
154
+ /* Accept empty record -- used to clear PSTATE.ZA. */
155
+ if (size <= TARGET_ZA_SIG_CONTEXT_SIZE(0)) {
156
+ return true;
157
+ }
158
+
159
+ /* Reject non-empty but incomplete record. */
160
+ if (size < TARGET_ZA_SIG_CONTEXT_SIZE(vq)) {
161
+ return false;
162
+ }
163
+
164
+ *svcr = FIELD_DP64(*svcr, SVCR, ZA, 1);
165
+
166
+ for (i = 0; i < vl; ++i) {
167
+ uint64_t *z = (void *)za + TARGET_ZA_SIG_ZAV_OFFSET(vq, i);
168
+ for (j = 0; j < vq * 2; ++j) {
169
+ __get_user_e(env->zarray[i].d[j], z + j, le);
170
+ }
171
+ }
172
+ return true;
173
+}
174
+
175
static int target_restore_sigframe(CPUARMState *env,
176
struct target_rt_sigframe *sf)
177
{
178
struct target_aarch64_ctx *ctx, *extra = NULL;
179
struct target_fpsimd_context *fpsimd = NULL;
180
struct target_sve_context *sve = NULL;
181
+ struct target_za_context *za = NULL;
182
uint64_t extra_datap = 0;
183
bool used_extra = false;
184
int sve_size = 0;
185
+ int za_size = 0;
186
+ int svcr = 0;
187
188
target_restore_general_frame(env, sf);
189
190
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
191
sve_size = size;
192
break;
193
194
+ case TARGET_ZA_MAGIC:
195
+ if (za || size < sizeof(struct target_za_context)) {
196
+ goto err;
197
+ }
198
+ za = (struct target_za_context *)ctx;
199
+ za_size = size;
200
+ break;
201
+
202
case TARGET_EXTRA_MAGIC:
203
if (extra || size != sizeof(struct target_extra_context)) {
204
goto err;
205
@@ -XXX,XX +XXX,XX @@ static int target_restore_sigframe(CPUARMState *env,
206
}
207
208
/* SVE data, if present, overwrites FPSIMD data. */
209
- if (sve && !target_restore_sve_record(env, sve, sve_size)) {
210
+ if (sve && !target_restore_sve_record(env, sve, sve_size, &svcr)) {
211
goto err;
212
}
213
+ if (za && !target_restore_za_record(env, za, za_size, &svcr)) {
214
+ goto err;
215
+ }
216
+ if (env->svcr != svcr) {
217
+ env->svcr = svcr;
218
+ arm_rebuild_hflags(env);
219
+ }
220
unlock_user(extra, extra_datap, 0);
221
return 0;
222
223
@@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
224
.total_size = offsetof(struct target_rt_sigframe,
225
uc.tuc_mcontext.__reserved),
226
};
227
- int fpsimd_ofs, fr_ofs, sve_ofs = 0, vq = 0, sve_size = 0;
228
+ int fpsimd_ofs, fr_ofs, sve_ofs = 0, za_ofs = 0;
229
+ int sve_size = 0, za_size = 0;
230
struct target_rt_sigframe *frame;
231
struct target_rt_frame_record *fr;
232
abi_ulong frame_addr, return_addr;
233
@@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
234
&layout);
235
236
/* SVE state needs saving only if it exists. */
237
- if (cpu_isar_feature(aa64_sve, env_archcpu(env))) {
238
- vq = sve_vq(env);
239
- sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(vq), 16);
240
+ if (cpu_isar_feature(aa64_sve, env_archcpu(env)) ||
241
+ cpu_isar_feature(aa64_sme, env_archcpu(env))) {
242
+ sve_size = QEMU_ALIGN_UP(TARGET_SVE_SIG_CONTEXT_SIZE(sve_vq(env)), 16);
243
sve_ofs = alloc_sigframe_space(sve_size, &layout);
244
}
245
+ if (cpu_isar_feature(aa64_sme, env_archcpu(env))) {
246
+ /* ZA state needs saving only if it is enabled. */
247
+ if (FIELD_EX64(env->svcr, SVCR, ZA)) {
248
+ za_size = TARGET_ZA_SIG_CONTEXT_SIZE(sme_vq(env));
249
+ } else {
250
+ za_size = TARGET_ZA_SIG_CONTEXT_SIZE(0);
251
+ }
252
+ za_ofs = alloc_sigframe_space(za_size, &layout);
253
+ }
254
255
if (layout.extra_ofs) {
256
/* Reserve space for the extra end marker. The standard end marker
257
@@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
258
target_setup_end_record((void *)frame + layout.extra_end_ofs);
259
}
260
if (sve_ofs) {
261
- target_setup_sve_record((void *)frame + sve_ofs, env, vq, sve_size);
262
+ target_setup_sve_record((void *)frame + sve_ofs, env, sve_size);
263
+ }
264
+ if (za_ofs) {
265
+ target_setup_za_record((void *)frame + za_ofs, env, za_size);
266
}
267
268
/* Set up the stack frame for unwinding. */
269
@@ -XXX,XX +XXX,XX @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
270
env->btype = 2;
271
}
272
273
+ /*
274
+ * Invoke the signal handler with both SM and ZA disabled.
275
+ * When clearing SM, ResetSVEState, per SMSTOP.
276
+ */
277
+ if (FIELD_EX64(env->svcr, SVCR, SM)) {
278
+ arm_reset_sve_state(env);
279
+ }
280
+ if (env->svcr) {
281
+ env->svcr = 0;
282
+ arm_rebuild_hflags(env);
283
+ }
284
+
285
if (info) {
286
tswap_siginfo(&frame->info, info);
287
env->xregs[1] = frame_addr + offsetof(struct target_rt_sigframe, info);
93
--
288
--
94
2.25.1
289
2.25.1
95
96
diff view generated by jsdifflib
1
From: Yanan Wang <wangyanan55@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
List test/data/acpi/virt/PPTT as the expected files allowed to
3
Add "sve" to the sve prctl functions, to distinguish
4
be changed in tests/qtest/bios-tables-test-allowed-diff.h
4
them from the coming "sme" prctls with similar names.
5
5
6
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Acked-by: Ani Sinha <ani@anisinha.ca>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220107083232.16256-5-wangyanan55@huawei.com
8
Message-id: 20220708151540.18136-42-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
10
---
11
tests/qtest/bios-tables-test-allowed-diff.h | 1 +
11
linux-user/aarch64/target_prctl.h | 8 ++++----
12
1 file changed, 1 insertion(+)
12
linux-user/syscall.c | 12 ++++++------
13
2 files changed, 10 insertions(+), 10 deletions(-)
13
14
14
diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h
15
diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/qtest/bios-tables-test-allowed-diff.h
17
--- a/linux-user/aarch64/target_prctl.h
17
+++ b/tests/qtest/bios-tables-test-allowed-diff.h
18
+++ b/linux-user/aarch64/target_prctl.h
18
@@ -1 +1,2 @@
19
@@ -XXX,XX +XXX,XX @@
19
/* List of comma-separated changed AML files to ignore */
20
#ifndef AARCH64_TARGET_PRCTL_H
20
+"tests/data/acpi/virt/PPTT",
21
#define AARCH64_TARGET_PRCTL_H
22
23
-static abi_long do_prctl_get_vl(CPUArchState *env)
24
+static abi_long do_prctl_sve_get_vl(CPUArchState *env)
25
{
26
ARMCPU *cpu = env_archcpu(env);
27
if (cpu_isar_feature(aa64_sve, cpu)) {
28
@@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_get_vl(CPUArchState *env)
29
}
30
return -TARGET_EINVAL;
31
}
32
-#define do_prctl_get_vl do_prctl_get_vl
33
+#define do_prctl_sve_get_vl do_prctl_sve_get_vl
34
35
-static abi_long do_prctl_set_vl(CPUArchState *env, abi_long arg2)
36
+static abi_long do_prctl_sve_set_vl(CPUArchState *env, abi_long arg2)
37
{
38
/*
39
* We cannot support either PR_SVE_SET_VL_ONEXEC or PR_SVE_VL_INHERIT.
40
@@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_set_vl(CPUArchState *env, abi_long arg2)
41
}
42
return -TARGET_EINVAL;
43
}
44
-#define do_prctl_set_vl do_prctl_set_vl
45
+#define do_prctl_sve_set_vl do_prctl_sve_set_vl
46
47
static abi_long do_prctl_reset_keys(CPUArchState *env, abi_long arg2)
48
{
49
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/linux-user/syscall.c
52
+++ b/linux-user/syscall.c
53
@@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_inval1(CPUArchState *env, abi_long arg2)
54
#ifndef do_prctl_set_fp_mode
55
#define do_prctl_set_fp_mode do_prctl_inval1
56
#endif
57
-#ifndef do_prctl_get_vl
58
-#define do_prctl_get_vl do_prctl_inval0
59
+#ifndef do_prctl_sve_get_vl
60
+#define do_prctl_sve_get_vl do_prctl_inval0
61
#endif
62
-#ifndef do_prctl_set_vl
63
-#define do_prctl_set_vl do_prctl_inval1
64
+#ifndef do_prctl_sve_set_vl
65
+#define do_prctl_sve_set_vl do_prctl_inval1
66
#endif
67
#ifndef do_prctl_reset_keys
68
#define do_prctl_reset_keys do_prctl_inval1
69
@@ -XXX,XX +XXX,XX @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,
70
case PR_SET_FP_MODE:
71
return do_prctl_set_fp_mode(env, arg2);
72
case PR_SVE_GET_VL:
73
- return do_prctl_get_vl(env);
74
+ return do_prctl_sve_get_vl(env);
75
case PR_SVE_SET_VL:
76
- return do_prctl_set_vl(env, arg2);
77
+ return do_prctl_sve_set_vl(env, arg2);
78
case PR_PAC_RESET_KEYS:
79
if (arg3 || arg4 || arg5) {
80
return -TARGET_EINVAL;
21
--
81
--
22
2.25.1
82
2.25.1
23
24
diff view generated by jsdifflib
1
From: Yanan Wang <wangyanan55@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Support one cluster level between core and physical package in the
3
These prctl set the Streaming SVE vector length, which may
4
cpu-map of Arm/virt devicetree. This is also consistent with Linux
4
be completely different from the Normal SVE vector length.
5
Doc "Documentation/devicetree/bindings/cpu/cpu-topology.txt".
6
5
7
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Andrew Jones <drjones@redhat.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220107083232.16256-3-wangyanan55@huawei.com
8
Message-id: 20220708151540.18136-43-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
hw/arm/virt.c | 15 ++++++++-------
11
linux-user/aarch64/target_prctl.h | 54 +++++++++++++++++++++++++++++++
13
1 file changed, 8 insertions(+), 7 deletions(-)
12
linux-user/syscall.c | 16 +++++++++
13
2 files changed, 70 insertions(+)
14
14
15
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
15
diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/virt.c
17
--- a/linux-user/aarch64/target_prctl.h
18
+++ b/hw/arm/virt.c
18
+++ b/linux-user/aarch64/target_prctl.h
19
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
19
@@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_sve_get_vl(CPUArchState *env)
20
* can contain several layers of clustering within a single physical
20
{
21
* package and cluster nodes can be contained in parent cluster nodes.
21
ARMCPU *cpu = env_archcpu(env);
22
*
22
if (cpu_isar_feature(aa64_sve, cpu)) {
23
- * Given that cluster is not yet supported in the vCPU topology,
23
+ /* PSTATE.SM is always unset on syscall entry. */
24
- * we currently generate one cluster node within each socket node
24
return sve_vq(env) * 16;
25
- * by default.
25
}
26
+ * Note: currently we only support one layer of clustering within
26
return -TARGET_EINVAL;
27
+ * each physical package.
27
@@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_sve_set_vl(CPUArchState *env, abi_long arg2)
28
*/
28
&& arg2 >= 0 && arg2 <= 512 * 16 && !(arg2 & 15)) {
29
qemu_fdt_add_subnode(ms->fdt, "/cpus/cpu-map");
29
uint32_t vq, old_vq;
30
30
31
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
31
+ /* PSTATE.SM is always unset on syscall entry. */
32
32
old_vq = sve_vq(env);
33
if (ms->smp.threads > 1) {
33
34
map_path = g_strdup_printf(
34
/*
35
- "/cpus/cpu-map/socket%d/cluster0/core%d/thread%d",
35
@@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_sve_set_vl(CPUArchState *env, abi_long arg2)
36
- cpu / (ms->smp.cores * ms->smp.threads),
36
}
37
+ "/cpus/cpu-map/socket%d/cluster%d/core%d/thread%d",
37
#define do_prctl_sve_set_vl do_prctl_sve_set_vl
38
+ cpu / (ms->smp.clusters * ms->smp.cores * ms->smp.threads),
38
39
+ (cpu / (ms->smp.cores * ms->smp.threads)) % ms->smp.clusters,
39
+static abi_long do_prctl_sme_get_vl(CPUArchState *env)
40
(cpu / ms->smp.threads) % ms->smp.cores,
40
+{
41
cpu % ms->smp.threads);
41
+ ARMCPU *cpu = env_archcpu(env);
42
} else {
42
+ if (cpu_isar_feature(aa64_sme, cpu)) {
43
map_path = g_strdup_printf(
43
+ return sme_vq(env) * 16;
44
- "/cpus/cpu-map/socket%d/cluster0/core%d",
44
+ }
45
- cpu / ms->smp.cores,
45
+ return -TARGET_EINVAL;
46
+ "/cpus/cpu-map/socket%d/cluster%d/core%d",
46
+}
47
+ cpu / (ms->smp.clusters * ms->smp.cores),
47
+#define do_prctl_sme_get_vl do_prctl_sme_get_vl
48
+ (cpu / ms->smp.cores) % ms->smp.clusters,
48
+
49
cpu % ms->smp.cores);
49
+static abi_long do_prctl_sme_set_vl(CPUArchState *env, abi_long arg2)
50
}
50
+{
51
qemu_fdt_add_path(ms->fdt, map_path);
51
+ /*
52
+ * We cannot support either PR_SME_SET_VL_ONEXEC or PR_SME_VL_INHERIT.
53
+ * Note the kernel definition of sve_vl_valid allows for VQ=512,
54
+ * i.e. VL=8192, even though the architectural maximum is VQ=16.
55
+ */
56
+ if (cpu_isar_feature(aa64_sme, env_archcpu(env))
57
+ && arg2 >= 0 && arg2 <= 512 * 16 && !(arg2 & 15)) {
58
+ int vq, old_vq;
59
+
60
+ old_vq = sme_vq(env);
61
+
62
+ /*
63
+ * Bound the value of vq, so that we know that it fits into
64
+ * the 4-bit field in SMCR_EL1. Because PSTATE.SM is cleared
65
+ * on syscall entry, we are not modifying the current SVE
66
+ * vector length.
67
+ */
68
+ vq = MAX(arg2 / 16, 1);
69
+ vq = MIN(vq, 16);
70
+ env->vfp.smcr_el[1] =
71
+ FIELD_DP64(env->vfp.smcr_el[1], SMCR, LEN, vq - 1);
72
+
73
+ /* Delay rebuilding hflags until we know if ZA must change. */
74
+ vq = sve_vqm1_for_el_sm(env, 0, true) + 1;
75
+
76
+ if (vq != old_vq) {
77
+ /*
78
+ * PSTATE.ZA state is cleared on any change to SVL.
79
+ * We need not call arm_rebuild_hflags because PSTATE.SM was
80
+ * cleared on syscall entry, so this hasn't changed VL.
81
+ */
82
+ env->svcr = FIELD_DP64(env->svcr, SVCR, ZA, 0);
83
+ arm_rebuild_hflags(env);
84
+ }
85
+ return vq * 16;
86
+ }
87
+ return -TARGET_EINVAL;
88
+}
89
+#define do_prctl_sme_set_vl do_prctl_sme_set_vl
90
+
91
static abi_long do_prctl_reset_keys(CPUArchState *env, abi_long arg2)
92
{
93
ARMCPU *cpu = env_archcpu(env);
94
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
95
index XXXXXXX..XXXXXXX 100644
96
--- a/linux-user/syscall.c
97
+++ b/linux-user/syscall.c
98
@@ -XXX,XX +XXX,XX @@ abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr)
99
#ifndef PR_SET_SYSCALL_USER_DISPATCH
100
# define PR_SET_SYSCALL_USER_DISPATCH 59
101
#endif
102
+#ifndef PR_SME_SET_VL
103
+# define PR_SME_SET_VL 63
104
+# define PR_SME_GET_VL 64
105
+# define PR_SME_VL_LEN_MASK 0xffff
106
+# define PR_SME_VL_INHERIT (1 << 17)
107
+#endif
108
109
#include "target_prctl.h"
110
111
@@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_inval1(CPUArchState *env, abi_long arg2)
112
#ifndef do_prctl_set_unalign
113
#define do_prctl_set_unalign do_prctl_inval1
114
#endif
115
+#ifndef do_prctl_sme_get_vl
116
+#define do_prctl_sme_get_vl do_prctl_inval0
117
+#endif
118
+#ifndef do_prctl_sme_set_vl
119
+#define do_prctl_sme_set_vl do_prctl_inval1
120
+#endif
121
122
static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,
123
abi_long arg3, abi_long arg4, abi_long arg5)
124
@@ -XXX,XX +XXX,XX @@ static abi_long do_prctl(CPUArchState *env, abi_long option, abi_long arg2,
125
return do_prctl_sve_get_vl(env);
126
case PR_SVE_SET_VL:
127
return do_prctl_sve_set_vl(env, arg2);
128
+ case PR_SME_GET_VL:
129
+ return do_prctl_sme_get_vl(env);
130
+ case PR_SME_SET_VL:
131
+ return do_prctl_sme_set_vl(env, arg2);
132
case PR_PAC_RESET_KEYS:
133
if (arg3 || arg4 || arg5) {
134
return -TARGET_EINVAL;
52
--
135
--
53
2.25.1
136
2.25.1
54
55
diff view generated by jsdifflib
1
From: Yanan Wang <wangyanan55@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
ARM64 machines like Kunpeng Family Server Chips have a level
3
There's no reason to set CPACR_EL1.ZEN if SVE disabled.
4
of hardware topology in which a group of CPU cores share L3
5
cache tag or L2 cache. For example, Kunpeng 920 typically
6
has 6 or 8 clusters in each NUMA node (also represent range
7
of CPU die), and each cluster has 4 CPU cores. All clusters
8
share L3 cache data, but CPU cores in each cluster share a
9
local L3 tag.
10
4
11
Running a guest kernel with Cluster-Aware Scheduling on the
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Hosts which have physical clusters, if we can design a vCPU
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
topology with cluster level for guest kernel and then have
7
Message-id: 20220708151540.18136-44-richard.henderson@linaro.org
14
a dedicated vCPU pinning, the guest will gain scheduling
15
performance improvement from cache affinity of CPU cluster.
16
17
So let's enable the support for this new parameter on ARM
18
virt machines. After this patch, we can define a 4-level
19
CPU hierarchy like: cpus=*,maxcpus=*,sockets=*,clusters=*,
20
cores=*,threads=*.
21
22
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
23
Reviewed-by: Andrew Jones <drjones@redhat.com>
24
Message-id: 20220107083232.16256-2-wangyanan55@huawei.com
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
---
9
---
27
hw/arm/virt.c | 1 +
10
target/arm/cpu.c | 7 +++----
28
qemu-options.hx | 10 ++++++++++
11
1 file changed, 3 insertions(+), 4 deletions(-)
29
2 files changed, 11 insertions(+)
30
12
31
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
13
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
32
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/arm/virt.c
15
--- a/target/arm/cpu.c
34
+++ b/hw/arm/virt.c
16
+++ b/target/arm/cpu.c
35
@@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
17
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev)
36
hc->unplug_request = virt_machine_device_unplug_request_cb;
18
/* and to the FP/Neon instructions */
37
hc->unplug = virt_machine_device_unplug_cb;
19
env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1,
38
mc->nvdimm_supported = true;
20
CPACR_EL1, FPEN, 3);
39
+ mc->smp_props.clusters_supported = true;
21
- /* and to the SVE instructions */
40
mc->auto_enable_numa_with_memhp = true;
22
- env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1,
41
mc->auto_enable_numa_with_memdev = true;
23
- CPACR_EL1, ZEN, 3);
42
mc->default_ram_id = "mach-virt.ram";
24
- /* with reasonable vector length */
43
diff --git a/qemu-options.hx b/qemu-options.hx
25
+ /* and to the SVE instructions, with default vector length */
44
index XXXXXXX..XXXXXXX 100644
26
if (cpu_isar_feature(aa64_sve, cpu)) {
45
--- a/qemu-options.hx
27
+ env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1,
46
+++ b/qemu-options.hx
28
+ CPACR_EL1, ZEN, 3);
47
@@ -XXX,XX +XXX,XX @@ SRST
29
env->vfp.zcr_el[1] = cpu->sve_default_vq - 1;
48
30
}
49
-smp 16,sockets=2,dies=2,cores=2,threads=2,maxcpus=16
31
/*
50
51
+ The following sub-option defines a CPU topology hierarchy (2 sockets
52
+ totally on the machine, 2 clusters per socket, 2 cores per cluster,
53
+ 2 threads per core) for ARM virt machines which support sockets/clusters
54
+ /cores/threads. Some members of the option can be omitted but their values
55
+ will be automatically computed:
56
+
57
+ ::
58
+
59
+ -smp 16,sockets=2,clusters=2,cores=2,threads=2,maxcpus=16
60
+
61
Historically preference was given to the coarsest topology parameters
62
when computing missing values (ie sockets preferred over cores, which
63
were preferred over threads), however, this behaviour is considered
64
--
32
--
65
2.25.1
33
2.25.1
66
67
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
The Marvell 88W8618 is a system-on-chip with an ARM core.
3
Enable SME, TPIDR2_EL0, and FA64 if supported by the cpu.
4
We implement its audio codecs and network interface.
5
Homogeneous SoC Kconfig are usually defined in the hw/$ARCH
6
directory. Move it there.
7
4
8
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 20220708151540.18136-45-richard.henderson@linaro.org
11
Message-id: 20220107184429.423572-2-f4bug@amsat.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
9
---
14
hw/arm/Kconfig | 3 +++
10
target/arm/cpu.c | 11 +++++++++++
15
hw/audio/Kconfig | 3 ---
11
1 file changed, 11 insertions(+)
16
2 files changed, 3 insertions(+), 3 deletions(-)
17
12
18
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
13
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
19
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/Kconfig
15
--- a/target/arm/cpu.c
21
+++ b/hw/arm/Kconfig
16
+++ b/target/arm/cpu.c
22
@@ -XXX,XX +XXX,XX @@ config MUSCA
17
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev)
23
select SPLIT_IRQ
18
CPACR_EL1, ZEN, 3);
24
select UNIMP
19
env->vfp.zcr_el[1] = cpu->sve_default_vq - 1;
25
20
}
26
+config MARVELL_88W8618
21
+ /* and for SME instructions, with default vector length, and TPIDR2 */
27
+ bool
22
+ if (cpu_isar_feature(aa64_sme, cpu)) {
28
+
23
+ env->cp15.sctlr_el[1] |= SCTLR_EnTP2;
29
config MUSICPAL
24
+ env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1,
30
bool
25
+ CPACR_EL1, SMEN, 3);
31
select OR_IRQ
26
+ env->vfp.smcr_el[1] = cpu->sme_default_vq - 1;
32
diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig
27
+ if (cpu_isar_feature(aa64_sme_fa64, cpu)) {
33
index XXXXXXX..XXXXXXX 100644
28
+ env->vfp.smcr_el[1] = FIELD_DP64(env->vfp.smcr_el[1],
34
--- a/hw/audio/Kconfig
29
+ SMCR, FA64, 1);
35
+++ b/hw/audio/Kconfig
30
+ }
36
@@ -XXX,XX +XXX,XX @@ config PL041
31
+ }
37
32
/*
38
config CS4231
33
* Enable 48-bit address space (TODO: take reserved_va into account).
39
bool
34
* Enable TBI0 but not TBI1.
40
-
41
-config MARVELL_88W8618
42
- bool
43
--
35
--
44
2.25.1
36
2.25.1
45
46
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
We are going to move this code, so fix its style first to avoid:
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
ERROR: spaces required around that '/' (ctx:VxV)
5
Message-id: 20220708151540.18136-46-richard.henderson@linaro.org
6
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20220107184429.423572-3-f4bug@amsat.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
7
---
12
hw/arm/musicpal.c | 14 +++++++-------
8
linux-user/elfload.c | 20 ++++++++++++++++++++
13
1 file changed, 7 insertions(+), 7 deletions(-)
9
1 file changed, 20 insertions(+)
14
10
15
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
11
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
16
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/musicpal.c
13
--- a/linux-user/elfload.c
18
+++ b/hw/arm/musicpal.c
14
+++ b/linux-user/elfload.c
19
@@ -XXX,XX +XXX,XX @@ static uint64_t mv88w8618_eth_read(void *opaque, hwaddr offset,
15
@@ -XXX,XX +XXX,XX @@ enum {
20
return s->imr;
16
ARM_HWCAP2_A64_RNG = 1 << 16,
21
17
ARM_HWCAP2_A64_BTI = 1 << 17,
22
case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
18
ARM_HWCAP2_A64_MTE = 1 << 18,
23
- return s->frx_queue[(offset - MP_ETH_FRDP0)/4];
19
+ ARM_HWCAP2_A64_ECV = 1 << 19,
24
+ return s->frx_queue[(offset - MP_ETH_FRDP0) / 4];
20
+ ARM_HWCAP2_A64_AFP = 1 << 20,
25
21
+ ARM_HWCAP2_A64_RPRES = 1 << 21,
26
case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
22
+ ARM_HWCAP2_A64_MTE3 = 1 << 22,
27
- return s->rx_queue[(offset - MP_ETH_CRDP0)/4];
23
+ ARM_HWCAP2_A64_SME = 1 << 23,
28
+ return s->rx_queue[(offset - MP_ETH_CRDP0) / 4];
24
+ ARM_HWCAP2_A64_SME_I16I64 = 1 << 24,
29
25
+ ARM_HWCAP2_A64_SME_F64F64 = 1 << 25,
30
case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
26
+ ARM_HWCAP2_A64_SME_I8I32 = 1 << 26,
31
- return s->tx_queue[(offset - MP_ETH_CTDP0)/4];
27
+ ARM_HWCAP2_A64_SME_F16F32 = 1 << 27,
32
+ return s->tx_queue[(offset - MP_ETH_CTDP0) / 4];
28
+ ARM_HWCAP2_A64_SME_B16F32 = 1 << 28,
33
29
+ ARM_HWCAP2_A64_SME_F32F32 = 1 << 29,
34
default:
30
+ ARM_HWCAP2_A64_SME_FA64 = 1 << 30,
35
return 0;
31
};
36
@@ -XXX,XX +XXX,XX @@ static void mv88w8618_eth_write(void *opaque, hwaddr offset,
32
37
break;
33
#define ELF_HWCAP get_elf_hwcap()
38
34
@@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap2(void)
39
case MP_ETH_FRDP0 ... MP_ETH_FRDP3:
35
GET_FEATURE_ID(aa64_rndr, ARM_HWCAP2_A64_RNG);
40
- s->frx_queue[(offset - MP_ETH_FRDP0)/4] = value;
36
GET_FEATURE_ID(aa64_bti, ARM_HWCAP2_A64_BTI);
41
+ s->frx_queue[(offset - MP_ETH_FRDP0) / 4] = value;
37
GET_FEATURE_ID(aa64_mte, ARM_HWCAP2_A64_MTE);
42
break;
38
+ GET_FEATURE_ID(aa64_sme, (ARM_HWCAP2_A64_SME |
43
39
+ ARM_HWCAP2_A64_SME_F32F32 |
44
case MP_ETH_CRDP0 ... MP_ETH_CRDP3:
40
+ ARM_HWCAP2_A64_SME_B16F32 |
45
- s->rx_queue[(offset - MP_ETH_CRDP0)/4] =
41
+ ARM_HWCAP2_A64_SME_F16F32 |
46
- s->cur_rx[(offset - MP_ETH_CRDP0)/4] = value;
42
+ ARM_HWCAP2_A64_SME_I8I32));
47
+ s->rx_queue[(offset - MP_ETH_CRDP0) / 4] =
43
+ GET_FEATURE_ID(aa64_sme_f64f64, ARM_HWCAP2_A64_SME_F64F64);
48
+ s->cur_rx[(offset - MP_ETH_CRDP0) / 4] = value;
44
+ GET_FEATURE_ID(aa64_sme_i16i64, ARM_HWCAP2_A64_SME_I16I64);
49
break;
45
+ GET_FEATURE_ID(aa64_sme_fa64, ARM_HWCAP2_A64_SME_FA64);
50
46
51
case MP_ETH_CTDP0 ... MP_ETH_CTDP1:
47
return hwcaps;
52
- s->tx_queue[(offset - MP_ETH_CTDP0)/4] = value;
53
+ s->tx_queue[(offset - MP_ETH_CTDP0) / 4] = value;
54
break;
55
}
56
}
48
}
57
--
49
--
58
2.25.1
50
2.25.1
59
60
diff view generated by jsdifflib