1
ARM queue: mostly patches from me, but also the Smartfusion2 board.
1
target-arm queue: the big stuff here is the final part of
2
rth's patches for Cortex-A76 and Neoverse-N1 support;
3
also present are Gavin's NUMA series and a few other things.
2
4
3
thanks
5
thanks
4
-- PMM
6
-- PMM
5
7
6
The following changes since commit 9ee660e7c138595224b65ddc1c5712549f0a278c:
8
The following changes since commit 554623226f800acf48a2ed568900c1c968ec9a8b:
7
9
8
Merge remote-tracking branch 'remotes/yongbok/tags/mips-20170921' into staging (2017-09-21 14:40:32 +0100)
10
Merge tag 'qemu-sparc-20220508' of https://github.com/mcayland/qemu into staging (2022-05-08 17:03:26 -0500)
9
11
10
are available in the git repository at:
12
are available in the Git repository at:
11
13
12
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20170921
14
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220509
13
15
14
for you to fetch changes up to 6d262dcb7d108eda93813574c2061398084dc795:
16
for you to fetch changes up to ae9141d4a3265553503bf07d3574b40f84615a34:
15
17
16
msf2: Add Emcraft's Smartfusion2 SOM kit (2017-09-21 16:36:56 +0100)
18
hw/acpi/aml-build: Use existing CPU topology to build PPTT table (2022-05-09 11:47:55 +0100)
17
19
18
----------------------------------------------------------------
20
----------------------------------------------------------------
19
target-arm queue:
21
target-arm queue:
20
* more preparatory work for v8M support
22
* MAINTAINERS/.mailmap: update email for Leif Lindholm
21
* convert some omap devices away from old_mmio
23
* hw/arm: add version information to sbsa-ref machine DT
22
* remove out of date ARM ARM section references in comments
24
* Enable new features for -cpu max:
23
* add the Smartfusion2 board
25
FEAT_Debugv8p2, FEAT_Debugv8p4, FEAT_RAS (minimal version only),
26
FEAT_IESB, FEAT_CSV2, FEAT_CSV2_2, FEAT_CSV3, FEAT_DGH
27
* Emulate Cortex-A76
28
* Emulate Neoverse-N1
29
* Fix the virt board default NUMA topology
24
30
25
----------------------------------------------------------------
31
----------------------------------------------------------------
26
Peter Maydell (26):
32
Gavin Shan (6):
27
target/arm: Implement MSR/MRS access to NS banked registers
33
qapi/machine.json: Add cluster-id
28
nvic: Add banked exception states
34
qtest/numa-test: Specify CPU topology in aarch64_numa_cpu()
29
nvic: Add cached vectpending_is_s_banked state
35
hw/arm/virt: Consider SMP configuration in CPU topology
30
nvic: Add cached vectpending_prio state
36
qtest/numa-test: Correct CPU and NUMA association in aarch64_numa_cpu()
31
nvic: Implement AIRCR changes for v8M
37
hw/arm/virt: Fix CPU's default NUMA node ID
32
nvic: Make ICSR.RETTOBASE handle banked exceptions
38
hw/acpi/aml-build: Use existing CPU topology to build PPTT table
33
nvic: Implement NVIC_ITNS<n> registers
34
nvic: Handle banked exceptions in nvic_recompute_state()
35
nvic: Make set_pending and clear_pending take a secure parameter
36
nvic: Make SHPR registers banked
37
nvic: Compare group priority for escalation to HF
38
nvic: In escalation to HardFault, support HF not being priority -1
39
nvic: Implement v8M changes to fixed priority exceptions
40
nvic: Disable the non-secure HardFault if AIRCR.BFHFNMINS is clear
41
nvic: Handle v8M changes in nvic_exec_prio()
42
target/arm: Handle banking in negative-execution-priority check in cpu_mmu_index()
43
nvic: Make ICSR banked for v8M
44
nvic: Make SHCSR banked for v8M
45
nvic: Support banked exceptions in acknowledge and complete
46
target/arm: Remove out of date ARM ARM section references in A64 decoder
47
hw/arm/palm.c: Don't use old_mmio for static_ops
48
hw/gpio/omap_gpio.c: Don't use old_mmio
49
hw/timer/omap_synctimer.c: Don't use old_mmio
50
hw/timer/omap_gptimer: Don't use old_mmio
51
hw/i2c/omap_i2c.c: Don't use old_mmio
52
hw/arm/omap2.c: Don't use old_mmio
53
39
54
Subbaraya Sundeep (5):
40
Leif Lindholm (2):
55
msf2: Add Smartfusion2 System timer
41
MAINTAINERS/.mailmap: update email for Leif Lindholm
56
msf2: Microsemi Smartfusion2 System Register block
42
hw/arm: add versioning to sbsa-ref machine DT
57
msf2: Add Smartfusion2 SPI controller
58
msf2: Add Smartfusion2 SoC
59
msf2: Add Emcraft's Smartfusion2 SOM kit
60
43
61
hw/arm/Makefile.objs | 1 +
44
Richard Henderson (24):
62
hw/misc/Makefile.objs | 1 +
45
target/arm: Handle cpreg registration for missing EL
63
hw/ssi/Makefile.objs | 1 +
46
target/arm: Drop EL3 no EL2 fallbacks
64
hw/timer/Makefile.objs | 1 +
47
target/arm: Merge zcr reginfo
65
include/hw/arm/msf2-soc.h | 67 +++
48
target/arm: Adjust definition of CONTEXTIDR_EL2
66
include/hw/intc/armv7m_nvic.h | 33 +-
49
target/arm: Move cortex impdef sysregs to cpu_tcg.c
67
include/hw/misc/msf2-sysreg.h | 77 ++++
50
target/arm: Update qemu-system-arm -cpu max to cortex-a57
68
include/hw/ssi/mss-spi.h | 58 +++
51
target/arm: Set ID_DFR0.PerfMon for qemu-system-arm -cpu max
69
include/hw/timer/mss-timer.h | 64 +++
52
target/arm: Split out aa32_max_features
70
target/arm/cpu.h | 62 ++-
53
target/arm: Annotate arm_max_initfn with FEAT identifiers
71
hw/arm/msf2-soc.c | 238 +++++++++++
54
target/arm: Use field names for manipulating EL2 and EL3 modes
72
hw/arm/msf2-som.c | 105 +++++
55
target/arm: Enable FEAT_Debugv8p2 for -cpu max
73
hw/arm/omap2.c | 49 ++-
56
target/arm: Enable FEAT_Debugv8p4 for -cpu max
74
hw/arm/palm.c | 30 +-
57
target/arm: Add minimal RAS registers
75
hw/gpio/omap_gpio.c | 26 +-
58
target/arm: Enable SCR and HCR bits for RAS
76
hw/i2c/omap_i2c.c | 44 +-
59
target/arm: Implement virtual SError exceptions
77
hw/intc/armv7m_nvic.c | 913 ++++++++++++++++++++++++++++++++++------
60
target/arm: Implement ESB instruction
78
hw/misc/msf2-sysreg.c | 160 +++++++
61
target/arm: Enable FEAT_RAS for -cpu max
79
hw/ssi/mss-spi.c | 404 ++++++++++++++++++
62
target/arm: Enable FEAT_IESB for -cpu max
80
hw/timer/mss-timer.c | 289 +++++++++++++
63
target/arm: Enable FEAT_CSV2 for -cpu max
81
hw/timer/omap_gptimer.c | 49 ++-
64
target/arm: Enable FEAT_CSV2_2 for -cpu max
82
hw/timer/omap_synctimer.c | 35 +-
65
target/arm: Enable FEAT_CSV3 for -cpu max
83
target/arm/cpu.c | 7 +
66
target/arm: Enable FEAT_DGH for -cpu max
84
target/arm/helper.c | 142 ++++++-
67
target/arm: Define cortex-a76
85
target/arm/translate-a64.c | 227 +++++-----
68
target/arm: Define neoverse-n1
86
default-configs/arm-softmmu.mak | 1 +
87
hw/intc/trace-events | 13 +-
88
hw/misc/trace-events | 5 +
89
28 files changed, 2735 insertions(+), 367 deletions(-)
90
create mode 100644 include/hw/arm/msf2-soc.h
91
create mode 100644 include/hw/misc/msf2-sysreg.h
92
create mode 100644 include/hw/ssi/mss-spi.h
93
create mode 100644 include/hw/timer/mss-timer.h
94
create mode 100644 hw/arm/msf2-soc.c
95
create mode 100644 hw/arm/msf2-som.c
96
create mode 100644 hw/misc/msf2-sysreg.c
97
create mode 100644 hw/ssi/mss-spi.c
98
create mode 100644 hw/timer/mss-timer.c
99
69
70
docs/system/arm/emulation.rst | 10 +
71
docs/system/arm/virt.rst | 2 +
72
qapi/machine.json | 6 +-
73
target/arm/cpregs.h | 11 +
74
target/arm/cpu.h | 23 ++
75
target/arm/helper.h | 1 +
76
target/arm/internals.h | 16 ++
77
target/arm/syndrome.h | 5 +
78
target/arm/a32.decode | 16 +-
79
target/arm/t32.decode | 18 +-
80
hw/acpi/aml-build.c | 111 ++++----
81
hw/arm/sbsa-ref.c | 16 ++
82
hw/arm/virt.c | 21 +-
83
hw/core/machine-hmp-cmds.c | 4 +
84
hw/core/machine.c | 16 ++
85
target/arm/cpu.c | 66 ++++-
86
target/arm/cpu64.c | 353 ++++++++++++++-----------
87
target/arm/cpu_tcg.c | 227 +++++++++++-----
88
target/arm/helper.c | 600 +++++++++++++++++++++++++-----------------
89
target/arm/op_helper.c | 43 +++
90
target/arm/translate-a64.c | 18 ++
91
target/arm/translate.c | 23 ++
92
tests/qtest/numa-test.c | 19 +-
93
.mailmap | 3 +-
94
MAINTAINERS | 2 +-
95
25 files changed, 1068 insertions(+), 562 deletions(-)
diff view generated by jsdifflib
1
From: Subbaraya Sundeep <sundeep.lkml@gmail.com>
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
2
2
3
Added Sytem register block of Smartfusion2.
3
NUVIA was acquired by Qualcomm in March 2021, but kept functioning on
4
This block has PLL registers which are accessed by guest.
4
separate infrastructure for a transitional period. We've now switched
5
over to contributing as Qualcomm Innovation Center (quicinc), so update
6
my email address to reflect this.
5
7
6
Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com>
8
Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
7
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
9
Message-id: 20220505113740.75565-1-quic_llindhol@quicinc.com
8
Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Cc: Leif Lindholm <leif@nuviainc.com>
9
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Cc: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20170920201737.25723-3-f4bug@amsat.org
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
[Fixed commit message typo]
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
15
---
13
hw/misc/Makefile.objs | 1 +
16
.mailmap | 3 ++-
14
include/hw/misc/msf2-sysreg.h | 77 ++++++++++++++++++++
17
MAINTAINERS | 2 +-
15
hw/misc/msf2-sysreg.c | 160 ++++++++++++++++++++++++++++++++++++++++++
18
2 files changed, 3 insertions(+), 2 deletions(-)
16
hw/misc/trace-events | 5 ++
17
4 files changed, 243 insertions(+)
18
create mode 100644 include/hw/misc/msf2-sysreg.h
19
create mode 100644 hw/misc/msf2-sysreg.c
20
19
21
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
20
diff --git a/.mailmap b/.mailmap
22
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/misc/Makefile.objs
22
--- a/.mailmap
24
+++ b/hw/misc/Makefile.objs
23
+++ b/.mailmap
25
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_HYPERV_TESTDEV) += hyperv_testdev.o
24
@@ -XXX,XX +XXX,XX @@ Greg Kurz <groug@kaod.org> <gkurz@linux.vnet.ibm.com>
26
obj-$(CONFIG_AUX) += auxbus.o
25
Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com>
27
obj-$(CONFIG_ASPEED_SOC) += aspeed_scu.o aspeed_sdmc.o
26
Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn>
28
obj-y += mmio_interface.o
27
James Hogan <jhogan@kernel.org> <james.hogan@imgtec.com>
29
+obj-$(CONFIG_MSF2) += msf2-sysreg.o
28
-Leif Lindholm <leif@nuviainc.com> <leif.lindholm@linaro.org>
30
diff --git a/include/hw/misc/msf2-sysreg.h b/include/hw/misc/msf2-sysreg.h
29
+Leif Lindholm <quic_llindhol@quicinc.com> <leif.lindholm@linaro.org>
31
new file mode 100644
30
+Leif Lindholm <quic_llindhol@quicinc.com> <leif@nuviainc.com>
32
index XXXXXXX..XXXXXXX
31
Radoslaw Biernacki <rad@semihalf.com> <radoslaw.biernacki@linaro.org>
33
--- /dev/null
32
Paul Burton <paulburton@kernel.org> <paul.burton@mips.com>
34
+++ b/include/hw/misc/msf2-sysreg.h
33
Paul Burton <paulburton@kernel.org> <paul.burton@imgtec.com>
35
@@ -XXX,XX +XXX,XX @@
34
diff --git a/MAINTAINERS b/MAINTAINERS
36
+/*
37
+ * Microsemi SmartFusion2 SYSREG
38
+ *
39
+ * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>
40
+ *
41
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
42
+ * of this software and associated documentation files (the "Software"), to deal
43
+ * in the Software without restriction, including without limitation the rights
44
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
45
+ * copies of the Software, and to permit persons to whom the Software is
46
+ * furnished to do so, subject to the following conditions:
47
+ *
48
+ * The above copyright notice and this permission notice shall be included in
49
+ * all copies or substantial portions of the Software.
50
+ *
51
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
54
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
56
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
57
+ * THE SOFTWARE.
58
+ */
59
+
60
+#ifndef HW_MSF2_SYSREG_H
61
+#define HW_MSF2_SYSREG_H
62
+
63
+#include "hw/sysbus.h"
64
+
65
+enum {
66
+ ESRAM_CR = 0x00 / 4,
67
+ ESRAM_MAX_LAT,
68
+ DDR_CR,
69
+ ENVM_CR,
70
+ ENVM_REMAP_BASE_CR,
71
+ ENVM_REMAP_FAB_CR,
72
+ CC_CR,
73
+ CC_REGION_CR,
74
+ CC_LOCK_BASE_ADDR_CR,
75
+ CC_FLUSH_INDX_CR,
76
+ DDRB_BUF_TIMER_CR,
77
+ DDRB_NB_ADDR_CR,
78
+ DDRB_NB_SIZE_CR,
79
+ DDRB_CR,
80
+
81
+ SOFT_RESET_CR = 0x48 / 4,
82
+ M3_CR,
83
+
84
+ GPIO_SYSRESET_SEL_CR = 0x58 / 4,
85
+
86
+ MDDR_CR = 0x60 / 4,
87
+
88
+ MSSDDR_PLL_STATUS_LOW_CR = 0x90 / 4,
89
+ MSSDDR_PLL_STATUS_HIGH_CR,
90
+ MSSDDR_FACC1_CR,
91
+ MSSDDR_FACC2_CR,
92
+
93
+ MSSDDR_PLL_STATUS = 0x150 / 4,
94
+};
95
+
96
+#define MSF2_SYSREG_MMIO_SIZE 0x300
97
+
98
+#define TYPE_MSF2_SYSREG "msf2-sysreg"
99
+#define MSF2_SYSREG(obj) OBJECT_CHECK(MSF2SysregState, (obj), TYPE_MSF2_SYSREG)
100
+
101
+typedef struct MSF2SysregState {
102
+ SysBusDevice parent_obj;
103
+
104
+ MemoryRegion iomem;
105
+
106
+ uint8_t apb0div;
107
+ uint8_t apb1div;
108
+
109
+ uint32_t regs[MSF2_SYSREG_MMIO_SIZE / 4];
110
+} MSF2SysregState;
111
+
112
+#endif /* HW_MSF2_SYSREG_H */
113
diff --git a/hw/misc/msf2-sysreg.c b/hw/misc/msf2-sysreg.c
114
new file mode 100644
115
index XXXXXXX..XXXXXXX
116
--- /dev/null
117
+++ b/hw/misc/msf2-sysreg.c
118
@@ -XXX,XX +XXX,XX @@
119
+/*
120
+ * System Register block model of Microsemi SmartFusion2.
121
+ *
122
+ * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>
123
+ *
124
+ * This program is free software; you can redistribute it and/or
125
+ * modify it under the terms of the GNU General Public License
126
+ * as published by the Free Software Foundation; either version
127
+ * 2 of the License, or (at your option) any later version.
128
+ *
129
+ * You should have received a copy of the GNU General Public License along
130
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
131
+ */
132
+
133
+#include "qemu/osdep.h"
134
+#include "qapi/error.h"
135
+#include "qemu/log.h"
136
+#include "hw/misc/msf2-sysreg.h"
137
+#include "qemu/error-report.h"
138
+#include "trace.h"
139
+
140
+static inline int msf2_divbits(uint32_t div)
141
+{
142
+ int r = ctz32(div);
143
+
144
+ return (div < 8) ? r : r + 1;
145
+}
146
+
147
+static void msf2_sysreg_reset(DeviceState *d)
148
+{
149
+ MSF2SysregState *s = MSF2_SYSREG(d);
150
+
151
+ s->regs[MSSDDR_PLL_STATUS_LOW_CR] = 0x021A2358;
152
+ s->regs[MSSDDR_PLL_STATUS] = 0x3;
153
+ s->regs[MSSDDR_FACC1_CR] = msf2_divbits(s->apb0div) << 5 |
154
+ msf2_divbits(s->apb1div) << 2;
155
+}
156
+
157
+static uint64_t msf2_sysreg_read(void *opaque, hwaddr offset,
158
+ unsigned size)
159
+{
160
+ MSF2SysregState *s = opaque;
161
+ uint32_t ret = 0;
162
+
163
+ offset >>= 2;
164
+ if (offset < ARRAY_SIZE(s->regs)) {
165
+ ret = s->regs[offset];
166
+ trace_msf2_sysreg_read(offset << 2, ret);
167
+ } else {
168
+ qemu_log_mask(LOG_GUEST_ERROR,
169
+ "%s: Bad offset 0x%08" HWADDR_PRIx "\n", __func__,
170
+ offset << 2);
171
+ }
172
+
173
+ return ret;
174
+}
175
+
176
+static void msf2_sysreg_write(void *opaque, hwaddr offset,
177
+ uint64_t val, unsigned size)
178
+{
179
+ MSF2SysregState *s = opaque;
180
+ uint32_t newval = val;
181
+
182
+ offset >>= 2;
183
+
184
+ switch (offset) {
185
+ case MSSDDR_PLL_STATUS:
186
+ trace_msf2_sysreg_write_pll_status();
187
+ break;
188
+
189
+ case ESRAM_CR:
190
+ case DDR_CR:
191
+ case ENVM_REMAP_BASE_CR:
192
+ if (newval != s->regs[offset]) {
193
+ qemu_log_mask(LOG_UNIMP,
194
+ TYPE_MSF2_SYSREG": remapping not supported\n");
195
+ }
196
+ break;
197
+
198
+ default:
199
+ if (offset < ARRAY_SIZE(s->regs)) {
200
+ trace_msf2_sysreg_write(offset << 2, newval, s->regs[offset]);
201
+ s->regs[offset] = newval;
202
+ } else {
203
+ qemu_log_mask(LOG_GUEST_ERROR,
204
+ "%s: Bad offset 0x%08" HWADDR_PRIx "\n", __func__,
205
+ offset << 2);
206
+ }
207
+ break;
208
+ }
209
+}
210
+
211
+static const MemoryRegionOps sysreg_ops = {
212
+ .read = msf2_sysreg_read,
213
+ .write = msf2_sysreg_write,
214
+ .endianness = DEVICE_NATIVE_ENDIAN,
215
+};
216
+
217
+static void msf2_sysreg_init(Object *obj)
218
+{
219
+ MSF2SysregState *s = MSF2_SYSREG(obj);
220
+
221
+ memory_region_init_io(&s->iomem, obj, &sysreg_ops, s, TYPE_MSF2_SYSREG,
222
+ MSF2_SYSREG_MMIO_SIZE);
223
+ sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
224
+}
225
+
226
+static const VMStateDescription vmstate_msf2_sysreg = {
227
+ .name = TYPE_MSF2_SYSREG,
228
+ .version_id = 1,
229
+ .minimum_version_id = 1,
230
+ .fields = (VMStateField[]) {
231
+ VMSTATE_UINT32_ARRAY(regs, MSF2SysregState, MSF2_SYSREG_MMIO_SIZE / 4),
232
+ VMSTATE_END_OF_LIST()
233
+ }
234
+};
235
+
236
+static Property msf2_sysreg_properties[] = {
237
+ /* default divisors in Libero GUI */
238
+ DEFINE_PROP_UINT8("apb0divisor", MSF2SysregState, apb0div, 2),
239
+ DEFINE_PROP_UINT8("apb1divisor", MSF2SysregState, apb1div, 2),
240
+ DEFINE_PROP_END_OF_LIST(),
241
+};
242
+
243
+static void msf2_sysreg_realize(DeviceState *dev, Error **errp)
244
+{
245
+ MSF2SysregState *s = MSF2_SYSREG(dev);
246
+
247
+ if ((s->apb0div > 32 || !is_power_of_2(s->apb0div))
248
+ || (s->apb1div > 32 || !is_power_of_2(s->apb1div))) {
249
+ error_setg(errp, "Invalid apb divisor value");
250
+ error_append_hint(errp, "apb divisor must be a power of 2"
251
+ " and maximum value is 32\n");
252
+ }
253
+}
254
+
255
+static void msf2_sysreg_class_init(ObjectClass *klass, void *data)
256
+{
257
+ DeviceClass *dc = DEVICE_CLASS(klass);
258
+
259
+ dc->vmsd = &vmstate_msf2_sysreg;
260
+ dc->reset = msf2_sysreg_reset;
261
+ dc->props = msf2_sysreg_properties;
262
+ dc->realize = msf2_sysreg_realize;
263
+}
264
+
265
+static const TypeInfo msf2_sysreg_info = {
266
+ .name = TYPE_MSF2_SYSREG,
267
+ .parent = TYPE_SYS_BUS_DEVICE,
268
+ .class_init = msf2_sysreg_class_init,
269
+ .instance_size = sizeof(MSF2SysregState),
270
+ .instance_init = msf2_sysreg_init,
271
+};
272
+
273
+static void msf2_sysreg_register_types(void)
274
+{
275
+ type_register_static(&msf2_sysreg_info);
276
+}
277
+
278
+type_init(msf2_sysreg_register_types)
279
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
280
index XXXXXXX..XXXXXXX 100644
35
index XXXXXXX..XXXXXXX 100644
281
--- a/hw/misc/trace-events
36
--- a/MAINTAINERS
282
+++ b/hw/misc/trace-events
37
+++ b/MAINTAINERS
283
@@ -XXX,XX +XXX,XX @@ mps2_scc_reset(void) "MPS2 SCC: reset"
38
@@ -XXX,XX +XXX,XX @@ F: include/hw/ssi/imx_spi.h
284
mps2_scc_leds(char led7, char led6, char led5, char led4, char led3, char led2, char led1, char led0) "MPS2 SCC LEDs: %c%c%c%c%c%c%c%c"
39
SBSA-REF
285
mps2_scc_cfg_write(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config write: function %d device %d data 0x%" PRIx32
40
M: Radoslaw Biernacki <rad@semihalf.com>
286
mps2_scc_cfg_read(unsigned function, unsigned device, uint32_t value) "MPS2 SCC config read: function %d device %d data 0x%" PRIx32
41
M: Peter Maydell <peter.maydell@linaro.org>
287
+
42
-R: Leif Lindholm <leif@nuviainc.com>
288
+# hw/misc/msf2-sysreg.c
43
+R: Leif Lindholm <quic_llindhol@quicinc.com>
289
+msf2_sysreg_write(uint64_t offset, uint32_t val, uint32_t prev) "msf2-sysreg write: addr 0x%08" HWADDR_PRIx " data 0x%" PRIx32 " prev 0x%" PRIx32
44
L: qemu-arm@nongnu.org
290
+msf2_sysreg_read(uint64_t offset, uint32_t val) "msf2-sysreg read: addr 0x%08" HWADDR_PRIx " data 0x%08" PRIx32
45
S: Maintained
291
+msf2_sysreg_write_pll_status(void) "Invalid write to read only PLL status register"
46
F: hw/arm/sbsa-ref.c
292
--
47
--
293
2.7.4
48
2.25.1
294
49
295
50
diff view generated by jsdifflib
1
Update the nvic_recompute_state() code to handle the security
1
From: Richard Henderson <richard.henderson@linaro.org>
2
extension and its associated banked registers.
2
3
3
More gracefully handle cpregs when EL2 and/or EL3 are missing.
4
Code that uses the resulting cached state (ie the irq
4
If the reg is entirely inaccessible, do not register it at all.
5
acknowledge and complete code) will be updated in a later
5
If the reg is for EL2, and EL3 is present but EL2 is not,
6
commit.
6
either discard, squash to res0, const, or keep unchanged.
7
7
8
Per rule RJFFP, mark the 4 aarch32 hypervisor access registers
9
with ARM_CP_EL3_NO_EL2_KEEP, and mark all of the EL2 address
10
translation and tlb invalidation "regs" ARM_CP_EL3_NO_EL2_UNDEF.
11
Mark the 2 virtualization processor id regs ARM_CP_EL3_NO_EL2_C_NZ.
12
13
This will simplify cpreg registration for conditional arm features.
14
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20220506180242.216785-2-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 1505240046-11454-9-git-send-email-peter.maydell@linaro.org
11
---
19
---
12
hw/intc/armv7m_nvic.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++--
20
target/arm/cpregs.h | 11 +++
13
hw/intc/trace-events | 1 +
21
target/arm/helper.c | 178 ++++++++++++++++++++++++++++++--------------
14
2 files changed, 147 insertions(+), 5 deletions(-)
22
2 files changed, 133 insertions(+), 56 deletions(-)
15
23
16
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
24
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
17
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/intc/armv7m_nvic.c
26
--- a/target/arm/cpregs.h
19
+++ b/hw/intc/armv7m_nvic.c
27
+++ b/target/arm/cpregs.h
20
@@ -XXX,XX +XXX,XX @@
28
@@ -XXX,XX +XXX,XX @@ enum {
21
* (higher than the highest possible priority value)
29
ARM_CP_SVE = 1 << 14,
22
*/
30
/* Flag: Do not expose in gdb sysreg xml. */
23
#define NVIC_NOEXC_PRIO 0x100
31
ARM_CP_NO_GDB = 1 << 15,
24
+/* Maximum priority of non-secure exceptions when AIRCR.PRIS is set */
32
+ /*
25
+#define NVIC_NS_PRIO_LIMIT 0x80
33
+ * Flags: If EL3 but not EL2...
26
34
+ * - UNDEF: discard the cpreg,
27
static const uint8_t nvic_id[] = {
35
+ * - KEEP: retain the cpreg as is,
28
0x00, 0xb0, 0x1b, 0x00, 0x0d, 0xe0, 0x05, 0xb1
36
+ * - C_NZ: set const on the cpreg, but retain resetvalue,
29
@@ -XXX,XX +XXX,XX @@ static bool nvic_isrpending(NVICState *s)
37
+ * - else: set const on the cpreg, zero resetvalue, aka RES0.
30
return false;
38
+ * See rule RJFFP in section D1.1.3 of DDI0487H.a.
31
}
32
33
+static bool exc_is_banked(int exc)
34
+{
35
+ /* Return true if this is one of the limited set of exceptions which
36
+ * are banked (and thus have state in sec_vectors[])
37
+ */
39
+ */
38
+ return exc == ARMV7M_EXCP_HARD ||
40
+ ARM_CP_EL3_NO_EL2_UNDEF = 1 << 16,
39
+ exc == ARMV7M_EXCP_MEM ||
41
+ ARM_CP_EL3_NO_EL2_KEEP = 1 << 17,
40
+ exc == ARMV7M_EXCP_USAGE ||
42
+ ARM_CP_EL3_NO_EL2_C_NZ = 1 << 18,
41
+ exc == ARMV7M_EXCP_SVC ||
43
};
42
+ exc == ARMV7M_EXCP_PENDSV ||
44
43
+ exc == ARMV7M_EXCP_SYSTICK;
45
/*
44
+}
46
diff --git a/target/arm/helper.c b/target/arm/helper.c
45
+
47
index XXXXXXX..XXXXXXX 100644
46
/* Return a mask word which clears the subpriority bits from
48
--- a/target/arm/helper.c
47
* a priority value for an M-profile exception, leaving only
49
+++ b/target/arm/helper.c
48
* the group priority.
50
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
49
*/
51
.access = PL1_RW, .readfn = spsel_read, .writefn = spsel_write },
50
-static inline uint32_t nvic_gprio_mask(NVICState *s)
52
{ .name = "FPEXC32_EL2", .state = ARM_CP_STATE_AA64,
51
+static inline uint32_t nvic_gprio_mask(NVICState *s, bool secure)
53
.opc0 = 3, .opc1 = 4, .crn = 5, .crm = 3, .opc2 = 0,
52
+{
54
- .access = PL2_RW, .type = ARM_CP_ALIAS | ARM_CP_FPU,
53
+ return ~0U << (s->prigroup[secure] + 1);
55
+ .access = PL2_RW,
54
+}
56
+ .type = ARM_CP_ALIAS | ARM_CP_FPU | ARM_CP_EL3_NO_EL2_KEEP,
55
+
57
.fieldoffset = offsetof(CPUARMState, vfp.xregs[ARM_VFP_FPEXC]) },
56
+static bool exc_targets_secure(NVICState *s, int exc)
58
{ .name = "DACR32_EL2", .state = ARM_CP_STATE_AA64,
57
+{
59
.opc0 = 3, .opc1 = 4, .crn = 3, .crm = 0, .opc2 = 0,
58
+ /* Return true if this non-banked exception targets Secure state. */
60
- .access = PL2_RW, .resetvalue = 0,
59
+ if (!arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY)) {
61
+ .access = PL2_RW, .resetvalue = 0, .type = ARM_CP_EL3_NO_EL2_KEEP,
60
+ return false;
62
.writefn = dacr_write, .raw_writefn = raw_write,
61
+ }
63
.fieldoffset = offsetof(CPUARMState, cp15.dacr32_el2) },
62
+
64
{ .name = "IFSR32_EL2", .state = ARM_CP_STATE_AA64,
63
+ if (exc >= NVIC_FIRST_IRQ) {
65
.opc0 = 3, .opc1 = 4, .crn = 5, .crm = 0, .opc2 = 1,
64
+ return !s->itns[exc];
66
- .access = PL2_RW, .resetvalue = 0,
65
+ }
67
+ .access = PL2_RW, .resetvalue = 0, .type = ARM_CP_EL3_NO_EL2_KEEP,
66
+
68
.fieldoffset = offsetof(CPUARMState, cp15.ifsr32_el2) },
67
+ /* Function shouldn't be called for banked exceptions. */
69
{ .name = "SPSR_IRQ", .state = ARM_CP_STATE_AA64,
68
+ assert(!exc_is_banked(exc));
70
.type = ARM_CP_ALIAS,
69
+
71
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
70
+ switch (exc) {
72
.writefn = tlbimva_hyp_is_write },
71
+ case ARMV7M_EXCP_NMI:
73
{ .name = "TLBI_ALLE2", .state = ARM_CP_STATE_AA64,
72
+ case ARMV7M_EXCP_BUS:
74
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 0,
73
+ return !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK);
75
- .type = ARM_CP_NO_RAW, .access = PL2_W,
74
+ case ARMV7M_EXCP_SECURE:
76
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
75
+ return true;
77
.writefn = tlbi_aa64_alle2_write },
76
+ case ARMV7M_EXCP_DEBUG:
78
{ .name = "TLBI_VAE2", .state = ARM_CP_STATE_AA64,
77
+ /* TODO: controlled by DEMCR.SDME, which we don't yet implement */
79
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 1,
78
+ return false;
80
- .type = ARM_CP_NO_RAW, .access = PL2_W,
79
+ default:
81
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
80
+ /* reset, and reserved (unused) low exception numbers.
82
.writefn = tlbi_aa64_vae2_write },
81
+ * We'll get called by code that loops through all the exception
83
{ .name = "TLBI_VALE2", .state = ARM_CP_STATE_AA64,
82
+ * numbers, but it doesn't matter what we return here as these
84
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 5,
83
+ * non-existent exceptions will never be pended or active.
85
- .access = PL2_W, .type = ARM_CP_NO_RAW,
86
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
87
.writefn = tlbi_aa64_vae2_write },
88
{ .name = "TLBI_ALLE2IS", .state = ARM_CP_STATE_AA64,
89
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 0,
90
- .access = PL2_W, .type = ARM_CP_NO_RAW,
91
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
92
.writefn = tlbi_aa64_alle2is_write },
93
{ .name = "TLBI_VAE2IS", .state = ARM_CP_STATE_AA64,
94
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 1,
95
- .type = ARM_CP_NO_RAW, .access = PL2_W,
96
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
97
.writefn = tlbi_aa64_vae2is_write },
98
{ .name = "TLBI_VALE2IS", .state = ARM_CP_STATE_AA64,
99
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 5,
100
- .access = PL2_W, .type = ARM_CP_NO_RAW,
101
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
102
.writefn = tlbi_aa64_vae2is_write },
103
#ifndef CONFIG_USER_ONLY
104
/* Unlike the other EL2-related AT operations, these must
105
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
106
{ .name = "AT_S1E2R", .state = ARM_CP_STATE_AA64,
107
.opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 0,
108
.access = PL2_W, .accessfn = at_s1e2_access,
109
- .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, .writefn = ats_write64 },
110
+ .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC | ARM_CP_EL3_NO_EL2_UNDEF,
111
+ .writefn = ats_write64 },
112
{ .name = "AT_S1E2W", .state = ARM_CP_STATE_AA64,
113
.opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 1,
114
.access = PL2_W, .accessfn = at_s1e2_access,
115
- .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC, .writefn = ats_write64 },
116
+ .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC | ARM_CP_EL3_NO_EL2_UNDEF,
117
+ .writefn = ats_write64 },
118
/* The AArch32 ATS1H* operations are CONSTRAINED UNPREDICTABLE
119
* if EL2 is not implemented; we choose to UNDEF. Behaviour at EL3
120
* with SCR.NS == 0 outside Monitor mode is UNPREDICTABLE; we choose
121
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
122
{ .name = "DBGVCR32_EL2", .state = ARM_CP_STATE_AA64,
123
.opc0 = 2, .opc1 = 4, .crn = 0, .crm = 7, .opc2 = 0,
124
.access = PL2_RW, .accessfn = access_tda,
125
- .type = ARM_CP_NOP },
126
+ .type = ARM_CP_NOP | ARM_CP_EL3_NO_EL2_KEEP },
127
/* Dummy MDCCINT_EL1, since we don't implement the Debug Communications
128
* Channel but Linux may try to access this register. The 32-bit
129
* alias is DBGDCCINT.
130
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = {
131
.access = PL2_W, .type = ARM_CP_NOP },
132
{ .name = "TLBI_RVAE2IS", .state = ARM_CP_STATE_AA64,
133
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 2, .opc2 = 1,
134
- .access = PL2_W, .type = ARM_CP_NO_RAW,
135
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
136
.writefn = tlbi_aa64_rvae2is_write },
137
{ .name = "TLBI_RVALE2IS", .state = ARM_CP_STATE_AA64,
138
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 2, .opc2 = 5,
139
- .access = PL2_W, .type = ARM_CP_NO_RAW,
140
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
141
.writefn = tlbi_aa64_rvae2is_write },
142
{ .name = "TLBI_RIPAS2E1", .state = ARM_CP_STATE_AA64,
143
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 2,
144
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = {
145
.access = PL2_W, .type = ARM_CP_NOP },
146
{ .name = "TLBI_RVAE2OS", .state = ARM_CP_STATE_AA64,
147
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 5, .opc2 = 1,
148
- .access = PL2_W, .type = ARM_CP_NO_RAW,
149
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
150
.writefn = tlbi_aa64_rvae2is_write },
151
{ .name = "TLBI_RVALE2OS", .state = ARM_CP_STATE_AA64,
152
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 5, .opc2 = 5,
153
- .access = PL2_W, .type = ARM_CP_NO_RAW,
154
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
155
.writefn = tlbi_aa64_rvae2is_write },
156
{ .name = "TLBI_RVAE2", .state = ARM_CP_STATE_AA64,
157
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 6, .opc2 = 1,
158
- .access = PL2_W, .type = ARM_CP_NO_RAW,
159
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
160
.writefn = tlbi_aa64_rvae2_write },
161
{ .name = "TLBI_RVALE2", .state = ARM_CP_STATE_AA64,
162
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 6, .opc2 = 5,
163
- .access = PL2_W, .type = ARM_CP_NO_RAW,
164
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
165
.writefn = tlbi_aa64_rvae2_write },
166
{ .name = "TLBI_RVAE3IS", .state = ARM_CP_STATE_AA64,
167
.opc0 = 1, .opc1 = 6, .crn = 8, .crm = 2, .opc2 = 1,
168
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = {
169
.writefn = tlbi_aa64_vae1is_write },
170
{ .name = "TLBI_ALLE2OS", .state = ARM_CP_STATE_AA64,
171
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 0,
172
- .access = PL2_W, .type = ARM_CP_NO_RAW,
173
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
174
.writefn = tlbi_aa64_alle2is_write },
175
{ .name = "TLBI_VAE2OS", .state = ARM_CP_STATE_AA64,
176
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 1,
177
- .access = PL2_W, .type = ARM_CP_NO_RAW,
178
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
179
.writefn = tlbi_aa64_vae2is_write },
180
{ .name = "TLBI_ALLE1OS", .state = ARM_CP_STATE_AA64,
181
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 4,
182
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = {
183
.writefn = tlbi_aa64_alle1is_write },
184
{ .name = "TLBI_VALE2OS", .state = ARM_CP_STATE_AA64,
185
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 5,
186
- .access = PL2_W, .type = ARM_CP_NO_RAW,
187
+ .access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
188
.writefn = tlbi_aa64_vae2is_write },
189
{ .name = "TLBI_VMALLS12E1OS", .state = ARM_CP_STATE_AA64,
190
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 6,
191
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
192
{ .name = "VPIDR", .state = ARM_CP_STATE_AA32,
193
.cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0,
194
.access = PL2_RW, .accessfn = access_el3_aa32ns,
195
- .resetvalue = cpu->midr, .type = ARM_CP_ALIAS,
196
+ .resetvalue = cpu->midr,
197
+ .type = ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ,
198
.fieldoffset = offsetoflow32(CPUARMState, cp15.vpidr_el2) },
199
{ .name = "VPIDR_EL2", .state = ARM_CP_STATE_AA64,
200
.opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0,
201
.access = PL2_RW, .resetvalue = cpu->midr,
202
+ .type = ARM_CP_EL3_NO_EL2_C_NZ,
203
.fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) },
204
{ .name = "VMPIDR", .state = ARM_CP_STATE_AA32,
205
.cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5,
206
.access = PL2_RW, .accessfn = access_el3_aa32ns,
207
- .resetvalue = vmpidr_def, .type = ARM_CP_ALIAS,
208
+ .resetvalue = vmpidr_def,
209
+ .type = ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ,
210
.fieldoffset = offsetoflow32(CPUARMState, cp15.vmpidr_el2) },
211
{ .name = "VMPIDR_EL2", .state = ARM_CP_STATE_AA64,
212
.opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5,
213
- .access = PL2_RW,
214
- .resetvalue = vmpidr_def,
215
+ .access = PL2_RW, .resetvalue = vmpidr_def,
216
+ .type = ARM_CP_EL3_NO_EL2_C_NZ,
217
.fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) },
218
};
219
define_arm_cp_regs(cpu, vpidr_regs);
220
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
221
int crm, int opc1, int opc2,
222
const char *name)
223
{
224
+ CPUARMState *env = &cpu->env;
225
uint32_t key;
226
ARMCPRegInfo *r2;
227
bool is64 = r->type & ARM_CP_64BIT;
228
bool ns = secstate & ARM_CP_SECSTATE_NS;
229
int cp = r->cp;
230
- bool isbanked;
231
size_t name_len;
232
+ bool make_const;
233
234
switch (state) {
235
case ARM_CP_STATE_AA32:
236
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
237
}
238
}
239
240
+ /*
241
+ * Eliminate registers that are not present because the EL is missing.
242
+ * Doing this here makes it easier to put all registers for a given
243
+ * feature into the same ARMCPRegInfo array and define them all at once.
244
+ */
245
+ make_const = false;
246
+ if (arm_feature(env, ARM_FEATURE_EL3)) {
247
+ /*
248
+ * An EL2 register without EL2 but with EL3 is (usually) RES0.
249
+ * See rule RJFFP in section D1.1.3 of DDI0487H.a.
84
+ */
250
+ */
85
+ return true;
251
+ int min_el = ctz32(r->access) / 2;
86
+ }
252
+ if (min_el == 2 && !arm_feature(env, ARM_FEATURE_EL2)) {
87
+}
253
+ if (r->type & ARM_CP_EL3_NO_EL2_UNDEF) {
88
+
254
+ return;
89
+static int exc_group_prio(NVICState *s, int rawprio, bool targets_secure)
90
+{
91
+ /* Return the group priority for this exception, given its raw
92
+ * (group-and-subgroup) priority value and whether it is targeting
93
+ * secure state or not.
94
+ */
95
+ if (rawprio < 0) {
96
+ return rawprio;
97
+ }
98
+ rawprio &= nvic_gprio_mask(s, targets_secure);
99
+ /* AIRCR.PRIS causes us to squash all NS priorities into the
100
+ * lower half of the total range
101
+ */
102
+ if (!targets_secure &&
103
+ (s->cpu->env.v7m.aircr & R_V7M_AIRCR_PRIS_MASK)) {
104
+ rawprio = (rawprio >> 1) + NVIC_NS_PRIO_LIMIT;
105
+ }
106
+ return rawprio;
107
+}
108
+
109
+/* Recompute vectpending and exception_prio for a CPU which implements
110
+ * the Security extension
111
+ */
112
+static void nvic_recompute_state_secure(NVICState *s)
113
{
114
- return ~0U << (s->prigroup[M_REG_NS] + 1);
115
+ int i, bank;
116
+ int pend_prio = NVIC_NOEXC_PRIO;
117
+ int active_prio = NVIC_NOEXC_PRIO;
118
+ int pend_irq = 0;
119
+ bool pending_is_s_banked = false;
120
+
121
+ /* R_CQRV: precedence is by:
122
+ * - lowest group priority; if both the same then
123
+ * - lowest subpriority; if both the same then
124
+ * - lowest exception number; if both the same (ie banked) then
125
+ * - secure exception takes precedence
126
+ * Compare pseudocode RawExecutionPriority.
127
+ * Annoyingly, now we have two prigroup values (for S and NS)
128
+ * we can't do the loop comparison on raw priority values.
129
+ */
130
+ for (i = 1; i < s->num_irq; i++) {
131
+ for (bank = M_REG_S; bank >= M_REG_NS; bank--) {
132
+ VecInfo *vec;
133
+ int prio;
134
+ bool targets_secure;
135
+
136
+ if (bank == M_REG_S) {
137
+ if (!exc_is_banked(i)) {
138
+ continue;
139
+ }
140
+ vec = &s->sec_vectors[i];
141
+ targets_secure = true;
142
+ } else {
143
+ vec = &s->vectors[i];
144
+ targets_secure = !exc_is_banked(i) && exc_targets_secure(s, i);
145
+ }
255
+ }
146
+
256
+ make_const = !(r->type & ARM_CP_EL3_NO_EL2_KEEP);
147
+ prio = exc_group_prio(s, vec->prio, targets_secure);
257
+ }
148
+ if (vec->enabled && vec->pending && prio < pend_prio) {
258
+ } else {
149
+ pend_prio = prio;
259
+ CPAccessRights max_el = (arm_feature(env, ARM_FEATURE_EL2)
150
+ pend_irq = i;
260
+ ? PL2_RW : PL1_RW);
151
+ pending_is_s_banked = (bank == M_REG_S);
261
+ if ((r->access & max_el) == 0) {
152
+ }
262
+ return;
153
+ if (vec->active && prio < active_prio) {
154
+ active_prio = prio;
155
+ }
156
+ }
263
+ }
157
+ }
264
+ }
158
+
265
+
159
+ s->vectpending_is_s_banked = pending_is_s_banked;
266
/* Combine cpreg and name into one allocation. */
160
+ s->vectpending = pend_irq;
267
name_len = strlen(name) + 1;
161
+ s->vectpending_prio = pend_prio;
268
r2 = g_malloc(sizeof(*r2) + name_len);
162
+ s->exception_prio = active_prio;
269
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
163
+
270
r2->opaque = opaque;
164
+ trace_nvic_recompute_state_secure(s->vectpending,
165
+ s->vectpending_is_s_banked,
166
+ s->vectpending_prio,
167
+ s->exception_prio);
168
}
169
170
/* Recompute vectpending and exception_prio */
171
@@ -XXX,XX +XXX,XX @@ static void nvic_recompute_state(NVICState *s)
172
int active_prio = NVIC_NOEXC_PRIO;
173
int pend_irq = 0;
174
175
+ /* In theory we could write one function that handled both
176
+ * the "security extension present" and "not present"; however
177
+ * the security related changes significantly complicate the
178
+ * recomputation just by themselves and mixing both cases together
179
+ * would be even worse, so we retain a separate non-secure-only
180
+ * version for CPUs which don't implement the security extension.
181
+ */
182
+ if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY)) {
183
+ nvic_recompute_state_secure(s);
184
+ return;
185
+ }
186
+
187
for (i = 1; i < s->num_irq; i++) {
188
VecInfo *vec = &s->vectors[i];
189
190
@@ -XXX,XX +XXX,XX @@ static void nvic_recompute_state(NVICState *s)
191
}
271
}
192
272
193
if (active_prio > 0) {
273
- isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1];
194
- active_prio &= nvic_gprio_mask(s);
274
- if (isbanked) {
195
+ active_prio &= nvic_gprio_mask(s, false);
275
+ if (make_const) {
276
+ /* This should not have been a very special register to begin. */
277
+ int old_special = r2->type & ARM_CP_SPECIAL_MASK;
278
+ assert(old_special == 0 || old_special == ARM_CP_NOP);
279
/*
280
- * Register is banked (using both entries in array).
281
- * Overwriting fieldoffset as the array is only used to define
282
- * banked registers but later only fieldoffset is used.
283
+ * Set the special function to CONST, retaining the other flags.
284
+ * This is important for e.g. ARM_CP_SVE so that we still
285
+ * take the SVE trap if CPTR_EL3.EZ == 0.
286
*/
287
- r2->fieldoffset = r->bank_fieldoffsets[ns];
288
- }
289
+ r2->type = (r2->type & ~ARM_CP_SPECIAL_MASK) | ARM_CP_CONST;
290
+ /*
291
+ * Usually, these registers become RES0, but there are a few
292
+ * special cases like VPIDR_EL2 which have a constant non-zero
293
+ * value with writes ignored.
294
+ */
295
+ if (!(r->type & ARM_CP_EL3_NO_EL2_C_NZ)) {
296
+ r2->resetvalue = 0;
297
+ }
298
+ /*
299
+ * ARM_CP_CONST has precedence, so removing the callbacks and
300
+ * offsets are not strictly necessary, but it is potentially
301
+ * less confusing to debug later.
302
+ */
303
+ r2->readfn = NULL;
304
+ r2->writefn = NULL;
305
+ r2->raw_readfn = NULL;
306
+ r2->raw_writefn = NULL;
307
+ r2->resetfn = NULL;
308
+ r2->fieldoffset = 0;
309
+ r2->bank_fieldoffsets[0] = 0;
310
+ r2->bank_fieldoffsets[1] = 0;
311
+ } else {
312
+ bool isbanked = r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1];
313
314
- if (state == ARM_CP_STATE_AA32) {
315
if (isbanked) {
316
/*
317
- * If the register is banked then we don't need to migrate or
318
- * reset the 32-bit instance in certain cases:
319
- *
320
- * 1) If the register has both 32-bit and 64-bit instances then we
321
- * can count on the 64-bit instance taking care of the
322
- * non-secure bank.
323
- * 2) If ARMv8 is enabled then we can count on a 64-bit version
324
- * taking care of the secure bank. This requires that separate
325
- * 32 and 64-bit definitions are provided.
326
+ * Register is banked (using both entries in array).
327
+ * Overwriting fieldoffset as the array is only used to define
328
+ * banked registers but later only fieldoffset is used.
329
*/
330
- if ((r->state == ARM_CP_STATE_BOTH && ns) ||
331
- (arm_feature(&cpu->env, ARM_FEATURE_V8) && !ns)) {
332
+ r2->fieldoffset = r->bank_fieldoffsets[ns];
333
+ }
334
+ if (state == ARM_CP_STATE_AA32) {
335
+ if (isbanked) {
336
+ /*
337
+ * If the register is banked then we don't need to migrate or
338
+ * reset the 32-bit instance in certain cases:
339
+ *
340
+ * 1) If the register has both 32-bit and 64-bit instances
341
+ * then we can count on the 64-bit instance taking care
342
+ * of the non-secure bank.
343
+ * 2) If ARMv8 is enabled then we can count on a 64-bit
344
+ * version taking care of the secure bank. This requires
345
+ * that separate 32 and 64-bit definitions are provided.
346
+ */
347
+ if ((r->state == ARM_CP_STATE_BOTH && ns) ||
348
+ (arm_feature(env, ARM_FEATURE_V8) && !ns)) {
349
+ r2->type |= ARM_CP_ALIAS;
350
+ }
351
+ } else if ((secstate != r->secure) && !ns) {
352
+ /*
353
+ * The register is not banked so we only want to allow
354
+ * migration of the non-secure instance.
355
+ */
356
r2->type |= ARM_CP_ALIAS;
357
}
358
- } else if ((secstate != r->secure) && !ns) {
359
- /*
360
- * The register is not banked so we only want to allow migration
361
- * of the non-secure instance.
362
- */
363
- r2->type |= ARM_CP_ALIAS;
364
- }
365
366
- if (HOST_BIG_ENDIAN &&
367
- r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) {
368
- r2->fieldoffset += sizeof(uint32_t);
369
+ if (HOST_BIG_ENDIAN &&
370
+ r->state == ARM_CP_STATE_BOTH && r2->fieldoffset) {
371
+ r2->fieldoffset += sizeof(uint32_t);
372
+ }
373
}
196
}
374
}
197
375
198
if (pend_prio > 0) {
376
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
199
- pend_prio &= nvic_gprio_mask(s);
377
* multiple times. Special registers (ie NOP/WFI) are
200
+ pend_prio &= nvic_gprio_mask(s, false);
378
* never migratable and not even raw-accessible.
379
*/
380
- if (r->type & ARM_CP_SPECIAL_MASK) {
381
+ if (r2->type & ARM_CP_SPECIAL_MASK) {
382
r2->type |= ARM_CP_NO_RAW;
201
}
383
}
202
384
if (((r->crm == CP_ANY) && crm != 0) ||
203
s->vectpending = pend_irq;
204
@@ -XXX,XX +XXX,XX @@ static inline int nvic_exec_prio(NVICState *s)
205
} else if (env->v7m.primask[env->v7m.secure]) {
206
running = 0;
207
} else if (env->v7m.basepri[env->v7m.secure] > 0) {
208
- running = env->v7m.basepri[env->v7m.secure] & nvic_gprio_mask(s);
209
+ running = env->v7m.basepri[env->v7m.secure] &
210
+ nvic_gprio_mask(s, env->v7m.secure);
211
} else {
212
running = NVIC_NOEXC_PRIO; /* lower than any possible priority */
213
}
214
diff --git a/hw/intc/trace-events b/hw/intc/trace-events
215
index XXXXXXX..XXXXXXX 100644
216
--- a/hw/intc/trace-events
217
+++ b/hw/intc/trace-events
218
@@ -XXX,XX +XXX,XX @@ gicv3_redist_send_sgi(uint32_t cpu, int irq) "GICv3 redistributor 0x%x pending S
219
220
# hw/intc/armv7m_nvic.c
221
nvic_recompute_state(int vectpending, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d vectpending_prio %d exception_prio %d"
222
+nvic_recompute_state_secure(int vectpending, bool vectpending_is_s_banked, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d is_s_banked %d vectpending_prio %d exception_prio %d"
223
nvic_set_prio(int irq, uint8_t prio) "NVIC set irq %d priority %d"
224
nvic_irq_update(int vectpending, int pendprio, int exception_prio, int level) "NVIC vectpending %d pending prio %d exception_prio %d: setting irq line to %d"
225
nvic_escalate_prio(int irq, int irqprio, int runprio) "NVIC escalating irq %d to HardFault: insufficient priority %d >= %d"
226
--
385
--
227
2.7.4
386
2.25.1
228
229
diff view generated by jsdifflib
1
From: Subbaraya Sundeep <sundeep.lkml@gmail.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Emulated Emcraft's Smartfusion2 System On Module starter
3
Drop el3_no_el2_cp_reginfo, el3_no_el2_v8_cp_reginfo, and the local
4
kit.
4
vpidr_regs definition, and rely on the squashing to ARM_CP_CONST
5
5
while registering for v8.
6
Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com>
6
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
This is a behavior change for v7 cpus with Security Extensions and
8
Message-id: 20170920201737.25723-6-f4bug@amsat.org
8
without Virtualization Extensions, in that the virtualization cpregs
9
[PMD: drop cpu_model to directly use cpu type]
9
are now correctly not present. This would be a migration compatibility
10
break, except that we have an existing bug in which migration of 32-bit
11
cpus with Security Extensions enabled does not work.
12
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20220506180242.216785-3-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
17
---
12
hw/arm/Makefile.objs | 2 +-
18
target/arm/helper.c | 158 ++++----------------------------------------
13
hw/arm/msf2-som.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++
19
1 file changed, 13 insertions(+), 145 deletions(-)
14
2 files changed, 106 insertions(+), 1 deletion(-)
20
15
create mode 100644 hw/arm/msf2-som.c
21
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
17
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
18
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/Makefile.objs
23
--- a/target/arm/helper.c
20
+++ b/hw/arm/Makefile.objs
24
+++ b/target/arm/helper.c
21
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
25
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
22
obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o
26
.fieldoffset = offsetoflow32(CPUARMState, cp15.mdcr_el3) },
23
obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o
27
};
24
obj-$(CONFIG_MPS2) += mps2.o
28
25
-obj-$(CONFIG_MSF2) += msf2-soc.o
29
-/* Used to describe the behaviour of EL2 regs when EL2 does not exist. */
26
+obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o
30
-static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = {
27
diff --git a/hw/arm/msf2-som.c b/hw/arm/msf2-som.c
31
- { .name = "VBAR_EL2", .state = ARM_CP_STATE_BOTH,
28
new file mode 100644
32
- .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 0,
29
index XXXXXXX..XXXXXXX
33
- .access = PL2_RW,
30
--- /dev/null
34
- .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore },
31
+++ b/hw/arm/msf2-som.c
35
- { .name = "HCR_EL2", .state = ARM_CP_STATE_BOTH,
32
@@ -XXX,XX +XXX,XX @@
36
- .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
33
+/*
37
- .access = PL2_RW,
34
+ * SmartFusion2 SOM starter kit(from Emcraft) emulation.
38
- .type = ARM_CP_CONST, .resetvalue = 0 },
35
+ *
39
- { .name = "HACR_EL2", .state = ARM_CP_STATE_BOTH,
36
+ * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>
40
- .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 7,
37
+ *
41
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
38
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
42
- { .name = "ESR_EL2", .state = ARM_CP_STATE_BOTH,
39
+ * of this software and associated documentation files (the "Software"), to deal
43
- .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 2, .opc2 = 0,
40
+ * in the Software without restriction, including without limitation the rights
44
- .access = PL2_RW,
41
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
45
- .type = ARM_CP_CONST, .resetvalue = 0 },
42
+ * copies of the Software, and to permit persons to whom the Software is
46
- { .name = "CPTR_EL2", .state = ARM_CP_STATE_BOTH,
43
+ * furnished to do so, subject to the following conditions:
47
- .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 2,
44
+ *
48
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
45
+ * The above copyright notice and this permission notice shall be included in
49
- { .name = "MAIR_EL2", .state = ARM_CP_STATE_BOTH,
46
+ * all copies or substantial portions of the Software.
50
- .opc0 = 3, .opc1 = 4, .crn = 10, .crm = 2, .opc2 = 0,
47
+ *
51
- .access = PL2_RW, .type = ARM_CP_CONST,
48
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52
- .resetvalue = 0 },
49
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53
- { .name = "HMAIR1", .state = ARM_CP_STATE_AA32,
50
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
54
- .cp = 15, .opc1 = 4, .crn = 10, .crm = 2, .opc2 = 1,
51
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
52
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
56
- { .name = "AMAIR_EL2", .state = ARM_CP_STATE_BOTH,
53
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
57
- .opc0 = 3, .opc1 = 4, .crn = 10, .crm = 3, .opc2 = 0,
54
+ * THE SOFTWARE.
58
- .access = PL2_RW, .type = ARM_CP_CONST,
55
+ */
59
- .resetvalue = 0 },
56
+
60
- { .name = "HAMAIR1", .state = ARM_CP_STATE_AA32,
57
+#include "qemu/osdep.h"
61
- .cp = 15, .opc1 = 4, .crn = 10, .crm = 3, .opc2 = 1,
58
+#include "qapi/error.h"
62
- .access = PL2_RW, .type = ARM_CP_CONST,
59
+#include "qemu/error-report.h"
63
- .resetvalue = 0 },
60
+#include "hw/boards.h"
64
- { .name = "AFSR0_EL2", .state = ARM_CP_STATE_BOTH,
61
+#include "hw/arm/arm.h"
65
- .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 1, .opc2 = 0,
62
+#include "exec/address-spaces.h"
66
- .access = PL2_RW, .type = ARM_CP_CONST,
63
+#include "qemu/cutils.h"
67
- .resetvalue = 0 },
64
+#include "hw/arm/msf2-soc.h"
68
- { .name = "AFSR1_EL2", .state = ARM_CP_STATE_BOTH,
65
+#include "cpu.h"
69
- .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 1, .opc2 = 1,
66
+
70
- .access = PL2_RW, .type = ARM_CP_CONST,
67
+#define DDR_BASE_ADDRESS 0xA0000000
71
- .resetvalue = 0 },
68
+#define DDR_SIZE (64 * M_BYTE)
72
- { .name = "TCR_EL2", .state = ARM_CP_STATE_BOTH,
69
+
73
- .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 2,
70
+#define M2S010_ENVM_SIZE (256 * K_BYTE)
74
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
71
+#define M2S010_ESRAM_SIZE (64 * K_BYTE)
75
- { .name = "VTCR_EL2", .state = ARM_CP_STATE_BOTH,
72
+
76
- .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 2,
73
+static void emcraft_sf2_s2s010_init(MachineState *machine)
77
- .access = PL2_RW, .accessfn = access_el3_aa32ns,
74
+{
78
- .type = ARM_CP_CONST, .resetvalue = 0 },
75
+ DeviceState *dev;
79
- { .name = "VTTBR", .state = ARM_CP_STATE_AA32,
76
+ DeviceState *spi_flash;
80
- .cp = 15, .opc1 = 6, .crm = 2,
77
+ MSF2State *soc;
81
- .access = PL2_RW, .accessfn = access_el3_aa32ns,
78
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
82
- .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
79
+ DriveInfo *dinfo = drive_get_next(IF_MTD);
83
- { .name = "VTTBR_EL2", .state = ARM_CP_STATE_AA64,
80
+ qemu_irq cs_line;
84
- .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 0,
81
+ SSIBus *spi_bus;
85
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
82
+ MemoryRegion *sysmem = get_system_memory();
86
- { .name = "SCTLR_EL2", .state = ARM_CP_STATE_BOTH,
83
+ MemoryRegion *ddr = g_new(MemoryRegion, 1);
87
- .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 0,
84
+
88
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
85
+ if (strcmp(machine->cpu_type, mc->default_cpu_type) != 0) {
89
- { .name = "TPIDR_EL2", .state = ARM_CP_STATE_BOTH,
86
+ error_report("This board can only be used with CPU %s",
90
- .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 2,
87
+ mc->default_cpu_type);
91
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
88
+ }
92
- { .name = "TTBR0_EL2", .state = ARM_CP_STATE_AA64,
89
+
93
- .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 0,
90
+ memory_region_init_ram(ddr, NULL, "ddr-ram", DDR_SIZE,
94
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
91
+ &error_fatal);
95
- { .name = "HTTBR", .cp = 15, .opc1 = 4, .crm = 2,
92
+ memory_region_add_subregion(sysmem, DDR_BASE_ADDRESS, ddr);
96
- .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_CONST,
93
+
97
- .resetvalue = 0 },
94
+ dev = qdev_create(NULL, TYPE_MSF2_SOC);
98
- { .name = "CNTHCTL_EL2", .state = ARM_CP_STATE_BOTH,
95
+ qdev_prop_set_string(dev, "part-name", "M2S010");
99
- .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 1, .opc2 = 0,
96
+ qdev_prop_set_string(dev, "cpu-type", mc->default_cpu_type);
100
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
97
+
101
- { .name = "CNTVOFF_EL2", .state = ARM_CP_STATE_AA64,
98
+ qdev_prop_set_uint64(dev, "eNVM-size", M2S010_ENVM_SIZE);
102
- .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 0, .opc2 = 3,
99
+ qdev_prop_set_uint64(dev, "eSRAM-size", M2S010_ESRAM_SIZE);
103
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
104
- { .name = "CNTVOFF", .cp = 15, .opc1 = 4, .crm = 14,
105
- .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_CONST,
106
- .resetvalue = 0 },
107
- { .name = "CNTHP_CVAL_EL2", .state = ARM_CP_STATE_AA64,
108
- .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 2,
109
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
110
- { .name = "CNTHP_CVAL", .cp = 15, .opc1 = 6, .crm = 14,
111
- .access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_CONST,
112
- .resetvalue = 0 },
113
- { .name = "CNTHP_TVAL_EL2", .state = ARM_CP_STATE_BOTH,
114
- .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 0,
115
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
116
- { .name = "CNTHP_CTL_EL2", .state = ARM_CP_STATE_BOTH,
117
- .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 1,
118
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
119
- { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH,
120
- .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1,
121
- .access = PL2_RW, .accessfn = access_tda,
122
- .type = ARM_CP_CONST, .resetvalue = 0 },
123
- { .name = "HPFAR_EL2", .state = ARM_CP_STATE_BOTH,
124
- .opc0 = 3, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 4,
125
- .access = PL2_RW, .accessfn = access_el3_aa32ns,
126
- .type = ARM_CP_CONST, .resetvalue = 0 },
127
- { .name = "HSTR_EL2", .state = ARM_CP_STATE_BOTH,
128
- .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 3,
129
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
130
- { .name = "FAR_EL2", .state = ARM_CP_STATE_BOTH,
131
- .opc0 = 3, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 0,
132
- .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
133
- { .name = "HIFAR", .state = ARM_CP_STATE_AA32,
134
- .type = ARM_CP_CONST,
135
- .cp = 15, .opc1 = 4, .crn = 6, .crm = 0, .opc2 = 2,
136
- .access = PL2_RW, .resetvalue = 0 },
137
-};
138
-
139
-/* Ditto, but for registers which exist in ARMv8 but not v7 */
140
-static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = {
141
- { .name = "HCR2", .state = ARM_CP_STATE_AA32,
142
- .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4,
143
- .access = PL2_RW,
144
- .type = ARM_CP_CONST, .resetvalue = 0 },
145
-};
146
-
147
static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
148
{
149
ARMCPU *cpu = env_archcpu(env);
150
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
151
define_arm_cp_regs(cpu, v8_idregs);
152
define_arm_cp_regs(cpu, v8_cp_reginfo);
153
}
154
- if (arm_feature(env, ARM_FEATURE_EL2)) {
100
+
155
+
101
+ /*
156
+ /*
102
+ * CPU clock and peripheral clocks(APB0, APB1)are configurable
157
+ * Register the base EL2 cpregs.
103
+ * in Libero. CPU clock is divided by APB0 and APB1 divisors for
158
+ * Pre v8, these registers are implemented only as part of the
104
+ * peripherals. Emcraft's SoM kit comes with these settings by default.
159
+ * Virtualization Extensions (EL2 present). Beginning with v8,
160
+ * if EL2 is missing but EL3 is enabled, mostly these become
161
+ * RES0 from EL3, with some specific exceptions.
105
+ */
162
+ */
106
+ qdev_prop_set_uint32(dev, "m3clk", 142 * 1000000);
163
+ if (arm_feature(env, ARM_FEATURE_EL2)
107
+ qdev_prop_set_uint32(dev, "apb0div", 2);
164
+ || (arm_feature(env, ARM_FEATURE_EL3)
108
+ qdev_prop_set_uint32(dev, "apb1div", 2);
165
+ && arm_feature(env, ARM_FEATURE_V8))) {
166
uint64_t vmpidr_def = mpidr_read_val(env);
167
ARMCPRegInfo vpidr_regs[] = {
168
{ .name = "VPIDR", .state = ARM_CP_STATE_AA32,
169
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
170
};
171
define_one_arm_cp_reg(cpu, &rvbar);
172
}
173
- } else {
174
- /* If EL2 is missing but higher ELs are enabled, we need to
175
- * register the no_el2 reginfos.
176
- */
177
- if (arm_feature(env, ARM_FEATURE_EL3)) {
178
- /* When EL3 exists but not EL2, VPIDR and VMPIDR take the value
179
- * of MIDR_EL1 and MPIDR_EL1.
180
- */
181
- ARMCPRegInfo vpidr_regs[] = {
182
- { .name = "VPIDR_EL2", .state = ARM_CP_STATE_BOTH,
183
- .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0,
184
- .access = PL2_RW, .accessfn = access_el3_aa32ns,
185
- .type = ARM_CP_CONST, .resetvalue = cpu->midr,
186
- .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) },
187
- { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_BOTH,
188
- .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5,
189
- .access = PL2_RW, .accessfn = access_el3_aa32ns,
190
- .type = ARM_CP_NO_RAW,
191
- .writefn = arm_cp_write_ignore, .readfn = mpidr_read },
192
- };
193
- define_arm_cp_regs(cpu, vpidr_regs);
194
- define_arm_cp_regs(cpu, el3_no_el2_cp_reginfo);
195
- if (arm_feature(env, ARM_FEATURE_V8)) {
196
- define_arm_cp_regs(cpu, el3_no_el2_v8_cp_reginfo);
197
- }
198
- }
199
}
109
+
200
+
110
+ object_property_set_bool(OBJECT(dev), true, "realized", &error_fatal);
201
+ /* Register the base EL3 cpregs. */
111
+
202
if (arm_feature(env, ARM_FEATURE_EL3)) {
112
+ soc = MSF2_SOC(dev);
203
define_arm_cp_regs(cpu, el3_cp_reginfo);
113
+
204
ARMCPRegInfo el3_regs[] = {
114
+ /* Attach SPI flash to SPI0 controller */
115
+ spi_bus = (SSIBus *)qdev_get_child_bus(dev, "spi0");
116
+ spi_flash = ssi_create_slave_no_init(spi_bus, "s25sl12801");
117
+ qdev_prop_set_uint8(spi_flash, "spansion-cr2nv", 1);
118
+ if (dinfo) {
119
+ qdev_prop_set_drive(spi_flash, "drive", blk_by_legacy_dinfo(dinfo),
120
+ &error_fatal);
121
+ }
122
+ qdev_init_nofail(spi_flash);
123
+ cs_line = qdev_get_gpio_in_named(spi_flash, SSI_GPIO_CS, 0);
124
+ sysbus_connect_irq(SYS_BUS_DEVICE(&soc->spi[0]), 1, cs_line);
125
+
126
+ armv7m_load_kernel(ARM_CPU(first_cpu), machine->kernel_filename,
127
+ soc->envm_size);
128
+}
129
+
130
+static void emcraft_sf2_machine_init(MachineClass *mc)
131
+{
132
+ mc->desc = "SmartFusion2 SOM kit from Emcraft (M2S010)";
133
+ mc->init = emcraft_sf2_s2s010_init;
134
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m3");
135
+}
136
+
137
+DEFINE_MACHINE("emcraft-sf2", emcraft_sf2_machine_init)
138
--
205
--
139
2.7.4
206
2.25.1
140
141
diff view generated by jsdifflib
1
Don't use old_mmio in the memory region ops struct.
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Drop zcr_no_el2_reginfo and merge the 3 registers into one array,
4
now that ZCR_EL2 can be squashed to RES0 and ZCR_EL3 dropped
5
while registering.
6
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220506180242.216785-4-richard.henderson@linaro.org
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 1505580378-9044-7-git-send-email-peter.maydell@linaro.org
6
---
11
---
7
hw/arm/omap2.c | 49 +++++++++++++++++++++++++++++++++++++------------
12
target/arm/helper.c | 55 ++++++++++++++-------------------------------
8
1 file changed, 37 insertions(+), 12 deletions(-)
13
1 file changed, 17 insertions(+), 38 deletions(-)
9
14
10
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
11
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
12
--- a/hw/arm/omap2.c
17
--- a/target/arm/helper.c
13
+++ b/hw/arm/omap2.c
18
+++ b/target/arm/helper.c
14
@@ -XXX,XX +XXX,XX @@ static void omap_sysctl_write(void *opaque, hwaddr addr,
19
@@ -XXX,XX +XXX,XX @@ static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
15
}
20
}
16
}
21
}
17
22
18
+static uint64_t omap_sysctl_readfn(void *opaque, hwaddr addr,
23
-static const ARMCPRegInfo zcr_el1_reginfo = {
19
+ unsigned size)
24
- .name = "ZCR_EL1", .state = ARM_CP_STATE_AA64,
20
+{
25
- .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0,
21
+ switch (size) {
26
- .access = PL1_RW, .type = ARM_CP_SVE,
22
+ case 1:
27
- .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]),
23
+ return omap_sysctl_read8(opaque, addr);
28
- .writefn = zcr_write, .raw_writefn = raw_write
24
+ case 2:
29
-};
25
+ return omap_badwidth_read32(opaque, addr); /* TODO */
30
-
26
+ case 4:
31
-static const ARMCPRegInfo zcr_el2_reginfo = {
27
+ return omap_sysctl_read(opaque, addr);
32
- .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64,
28
+ default:
33
- .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0,
29
+ g_assert_not_reached();
34
- .access = PL2_RW, .type = ARM_CP_SVE,
30
+ }
35
- .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]),
31
+}
36
- .writefn = zcr_write, .raw_writefn = raw_write
32
+
37
-};
33
+static void omap_sysctl_writefn(void *opaque, hwaddr addr,
38
-
34
+ uint64_t value, unsigned size)
39
-static const ARMCPRegInfo zcr_no_el2_reginfo = {
35
+{
40
- .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64,
36
+ switch (size) {
41
- .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0,
37
+ case 1:
42
- .access = PL2_RW, .type = ARM_CP_SVE,
38
+ omap_sysctl_write8(opaque, addr, value);
43
- .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore
39
+ break;
44
-};
40
+ case 2:
45
-
41
+ omap_badwidth_write32(opaque, addr, value); /* TODO */
46
-static const ARMCPRegInfo zcr_el3_reginfo = {
42
+ break;
47
- .name = "ZCR_EL3", .state = ARM_CP_STATE_AA64,
43
+ case 4:
48
- .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0,
44
+ omap_sysctl_write(opaque, addr, value);
49
- .access = PL3_RW, .type = ARM_CP_SVE,
45
+ break;
50
- .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]),
46
+ default:
51
- .writefn = zcr_write, .raw_writefn = raw_write
47
+ g_assert_not_reached();
52
+static const ARMCPRegInfo zcr_reginfo[] = {
48
+ }
53
+ { .name = "ZCR_EL1", .state = ARM_CP_STATE_AA64,
49
+}
54
+ .opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 0,
50
+
55
+ .access = PL1_RW, .type = ARM_CP_SVE,
51
static const MemoryRegionOps omap_sysctl_ops = {
56
+ .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[1]),
52
- .old_mmio = {
57
+ .writefn = zcr_write, .raw_writefn = raw_write },
53
- .read = {
58
+ { .name = "ZCR_EL2", .state = ARM_CP_STATE_AA64,
54
- omap_sysctl_read8,
59
+ .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 0,
55
- omap_badwidth_read32,    /* TODO */
60
+ .access = PL2_RW, .type = ARM_CP_SVE,
56
- omap_sysctl_read,
61
+ .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[2]),
57
- },
62
+ .writefn = zcr_write, .raw_writefn = raw_write },
58
- .write = {
63
+ { .name = "ZCR_EL3", .state = ARM_CP_STATE_AA64,
59
- omap_sysctl_write8,
64
+ .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 2, .opc2 = 0,
60
- omap_badwidth_write32,    /* TODO */
65
+ .access = PL3_RW, .type = ARM_CP_SVE,
61
- omap_sysctl_write,
66
+ .fieldoffset = offsetof(CPUARMState, vfp.zcr_el[3]),
62
- },
67
+ .writefn = zcr_write, .raw_writefn = raw_write },
63
- },
64
+ .read = omap_sysctl_readfn,
65
+ .write = omap_sysctl_writefn,
66
+ .valid.min_access_size = 1,
67
+ .valid.max_access_size = 4,
68
.endianness = DEVICE_NATIVE_ENDIAN,
69
};
68
};
70
69
70
void hw_watchpoint_update(ARMCPU *cpu, int n)
71
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
72
}
73
74
if (cpu_isar_feature(aa64_sve, cpu)) {
75
- define_one_arm_cp_reg(cpu, &zcr_el1_reginfo);
76
- if (arm_feature(env, ARM_FEATURE_EL2)) {
77
- define_one_arm_cp_reg(cpu, &zcr_el2_reginfo);
78
- } else {
79
- define_one_arm_cp_reg(cpu, &zcr_no_el2_reginfo);
80
- }
81
- if (arm_feature(env, ARM_FEATURE_EL3)) {
82
- define_one_arm_cp_reg(cpu, &zcr_el3_reginfo);
83
- }
84
+ define_arm_cp_regs(cpu, zcr_reginfo);
85
}
86
87
#ifdef TARGET_AARCH64
71
--
88
--
72
2.7.4
89
2.25.1
73
74
diff view generated by jsdifflib
1
For the v8M security extension, some exceptions must be banked
1
From: Richard Henderson <richard.henderson@linaro.org>
2
between security states. Add the new vecinfo array which holds
3
the state for the banked exceptions and migrate it if the
4
CPU the NVIC is attached to implements the security extension.
5
2
3
This register is present for either VHE or Debugv8p2.
4
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220506180242.216785-5-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
---
9
---
9
include/hw/intc/armv7m_nvic.h | 14 ++++++++++++
10
target/arm/helper.c | 15 +++++++++++----
10
hw/intc/armv7m_nvic.c | 53 ++++++++++++++++++++++++++++++++++++++++++-
11
1 file changed, 11 insertions(+), 4 deletions(-)
11
2 files changed, 66 insertions(+), 1 deletion(-)
12
12
13
diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
15
--- a/include/hw/intc/armv7m_nvic.h
15
--- a/target/arm/helper.c
16
+++ b/include/hw/intc/armv7m_nvic.h
16
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo jazelle_regs[] = {
18
18
.access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
19
/* Highest permitted number of exceptions (architectural limit) */
20
#define NVIC_MAX_VECTORS 512
21
+/* Number of internal exceptions */
22
+#define NVIC_INTERNAL_VECTORS 16
23
24
typedef struct VecInfo {
25
/* Exception priorities can range from -3 to 255; only the unmodifiable
26
@@ -XXX,XX +XXX,XX @@ typedef struct NVICState {
27
ARMCPU *cpu;
28
29
VecInfo vectors[NVIC_MAX_VECTORS];
30
+ /* If the v8M security extension is implemented, some of the internal
31
+ * exceptions are banked between security states (ie there exists both
32
+ * a Secure and a NonSecure version of the exception and its state):
33
+ * HardFault, MemManage, UsageFault, SVCall, PendSV, SysTick (R_PJHV)
34
+ * The rest (including all the external exceptions) are not banked, though
35
+ * they may be configurable to target either Secure or NonSecure state.
36
+ * We store the secure exception state in sec_vectors[] for the banked
37
+ * exceptions, and otherwise use only vectors[] (including for exceptions
38
+ * like SecureFault that unconditionally target Secure state).
39
+ * Entries in sec_vectors[] for non-banked exception numbers are unused.
40
+ */
41
+ VecInfo sec_vectors[NVIC_INTERNAL_VECTORS];
42
uint32_t prigroup;
43
44
/* vectpending and exception_prio are both cached state that can
45
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/intc/armv7m_nvic.c
48
+++ b/hw/intc/armv7m_nvic.c
49
@@ -XXX,XX +XXX,XX @@
50
* For historical reasons QEMU tends to use "interrupt" and
51
* "exception" more or less interchangeably.
52
*/
53
-#define NVIC_FIRST_IRQ 16
54
+#define NVIC_FIRST_IRQ NVIC_INTERNAL_VECTORS
55
#define NVIC_MAX_IRQ (NVIC_MAX_VECTORS - NVIC_FIRST_IRQ)
56
57
/* Effective running priority of the CPU when no exception is active
58
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_VecInfo = {
59
}
60
};
19
};
61
20
62
+static bool nvic_security_needed(void *opaque)
21
+static const ARMCPRegInfo contextidr_el2 = {
63
+{
22
+ .name = "CONTEXTIDR_EL2", .state = ARM_CP_STATE_AA64,
64
+ NVICState *s = opaque;
23
+ .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 1,
65
+
24
+ .access = PL2_RW,
66
+ return arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY);
25
+ .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[2])
67
+}
68
+
69
+static int nvic_security_post_load(void *opaque, int version_id)
70
+{
71
+ NVICState *s = opaque;
72
+ int i;
73
+
74
+ /* Check for out of range priority settings */
75
+ if (s->sec_vectors[ARMV7M_EXCP_HARD].prio != -1) {
76
+ return 1;
77
+ }
78
+ for (i = ARMV7M_EXCP_MEM; i < ARRAY_SIZE(s->sec_vectors); i++) {
79
+ if (s->sec_vectors[i].prio & ~0xff) {
80
+ return 1;
81
+ }
82
+ }
83
+ return 0;
84
+}
85
+
86
+static const VMStateDescription vmstate_nvic_security = {
87
+ .name = "nvic/m-security",
88
+ .version_id = 1,
89
+ .minimum_version_id = 1,
90
+ .needed = nvic_security_needed,
91
+ .post_load = &nvic_security_post_load,
92
+ .fields = (VMStateField[]) {
93
+ VMSTATE_STRUCT_ARRAY(sec_vectors, NVICState, NVIC_INTERNAL_VECTORS, 1,
94
+ vmstate_VecInfo, VecInfo),
95
+ VMSTATE_END_OF_LIST()
96
+ }
97
+};
26
+};
98
+
27
+
99
static const VMStateDescription vmstate_nvic = {
28
static const ARMCPRegInfo vhe_reginfo[] = {
100
.name = "armv7m_nvic",
29
- { .name = "CONTEXTIDR_EL2", .state = ARM_CP_STATE_AA64,
101
.version_id = 4,
30
- .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 1,
102
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_nvic = {
31
- .access = PL2_RW,
103
vmstate_VecInfo, VecInfo),
32
- .fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[2]) },
104
VMSTATE_UINT32(prigroup, NVICState),
33
{ .name = "TTBR1_EL2", .state = ARM_CP_STATE_AA64,
105
VMSTATE_END_OF_LIST()
34
.opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 1,
106
+ },
35
.access = PL2_RW, .writefn = vmsa_tcr_ttbr_el2_write,
107
+ .subsections = (const VMStateDescription*[]) {
36
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
108
+ &vmstate_nvic_security,
37
define_one_arm_cp_reg(cpu, &ssbs_reginfo);
109
+ NULL
110
}
38
}
111
};
39
112
40
+ if (cpu_isar_feature(aa64_vh, cpu) ||
113
@@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_reset(DeviceState *dev)
41
+ cpu_isar_feature(aa64_debugv8p2, cpu)) {
114
s->vectors[ARMV7M_EXCP_NMI].prio = -2;
42
+ define_one_arm_cp_reg(cpu, &contextidr_el2);
115
s->vectors[ARMV7M_EXCP_HARD].prio = -1;
116
117
+ if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY)) {
118
+ s->sec_vectors[ARMV7M_EXCP_HARD].enabled = 1;
119
+ s->sec_vectors[ARMV7M_EXCP_SVC].enabled = 1;
120
+ s->sec_vectors[ARMV7M_EXCP_PENDSV].enabled = 1;
121
+ s->sec_vectors[ARMV7M_EXCP_SYSTICK].enabled = 1;
122
+
123
+ /* AIRCR.BFHFNMINS resets to 0 so Secure HF is priority -1 (R_CMTC) */
124
+ s->sec_vectors[ARMV7M_EXCP_HARD].prio = -1;
125
+ }
43
+ }
126
+
44
if (arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu)) {
127
/* Strictly speaking the reset handler should be enabled.
45
define_arm_cp_regs(cpu, vhe_reginfo);
128
* However, we don't simulate soft resets through the NVIC,
46
}
129
* and the reset vector should never be pended.
130
--
47
--
131
2.7.4
48
2.25.1
132
133
diff view generated by jsdifflib
1
Drop the use of old_mmio in the omap2_gpio memory ops.
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Previously we were defining some of these in user-only mode,
4
but none of them are accessible from user-only, therefore
5
define them only in system mode.
6
7
This will shortly be used from cpu_tcg.c also.
8
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20220506180242.216785-6-richard.henderson@linaro.org
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 1505580378-9044-3-git-send-email-peter.maydell@linaro.org
6
---
13
---
7
hw/gpio/omap_gpio.c | 26 ++++++++++++--------------
14
target/arm/internals.h | 6 ++++
8
1 file changed, 12 insertions(+), 14 deletions(-)
15
target/arm/cpu64.c | 64 +++---------------------------------------
9
16
target/arm/cpu_tcg.c | 59 ++++++++++++++++++++++++++++++++++++++
10
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
17
3 files changed, 69 insertions(+), 60 deletions(-)
18
19
diff --git a/target/arm/internals.h b/target/arm/internals.h
11
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
12
--- a/hw/gpio/omap_gpio.c
21
--- a/target/arm/internals.h
13
+++ b/hw/gpio/omap_gpio.c
22
+++ b/target/arm/internals.h
14
@@ -XXX,XX +XXX,XX @@ static void omap2_gpio_module_write(void *opaque, hwaddr addr,
23
@@ -XXX,XX +XXX,XX @@ int aarch64_fpu_gdb_get_reg(CPUARMState *env, GByteArray *buf, int reg);
15
}
24
int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg);
25
#endif
26
27
+#ifdef CONFIG_USER_ONLY
28
+static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { }
29
+#else
30
+void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu);
31
+#endif
32
+
33
#endif
34
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/target/arm/cpu64.c
37
+++ b/target/arm/cpu64.c
38
@@ -XXX,XX +XXX,XX @@
39
#include "hvf_arm.h"
40
#include "qapi/visitor.h"
41
#include "hw/qdev-properties.h"
42
-#include "cpregs.h"
43
+#include "internals.h"
44
45
46
-#ifndef CONFIG_USER_ONLY
47
-static uint64_t a57_a53_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
48
-{
49
- ARMCPU *cpu = env_archcpu(env);
50
-
51
- /* Number of cores is in [25:24]; otherwise we RAZ */
52
- return (cpu->core_count - 1) << 24;
53
-}
54
-#endif
55
-
56
-static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = {
57
-#ifndef CONFIG_USER_ONLY
58
- { .name = "L2CTLR_EL1", .state = ARM_CP_STATE_AA64,
59
- .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 2,
60
- .access = PL1_RW, .readfn = a57_a53_l2ctlr_read,
61
- .writefn = arm_cp_write_ignore },
62
- { .name = "L2CTLR",
63
- .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 2,
64
- .access = PL1_RW, .readfn = a57_a53_l2ctlr_read,
65
- .writefn = arm_cp_write_ignore },
66
-#endif
67
- { .name = "L2ECTLR_EL1", .state = ARM_CP_STATE_AA64,
68
- .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 3,
69
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
70
- { .name = "L2ECTLR",
71
- .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 3,
72
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
73
- { .name = "L2ACTLR", .state = ARM_CP_STATE_BOTH,
74
- .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 0, .opc2 = 0,
75
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
76
- { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64,
77
- .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 0,
78
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
79
- { .name = "CPUACTLR",
80
- .cp = 15, .opc1 = 0, .crm = 15,
81
- .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
82
- { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64,
83
- .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 1,
84
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
85
- { .name = "CPUECTLR",
86
- .cp = 15, .opc1 = 1, .crm = 15,
87
- .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
88
- { .name = "CPUMERRSR_EL1", .state = ARM_CP_STATE_AA64,
89
- .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 2,
90
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
91
- { .name = "CPUMERRSR",
92
- .cp = 15, .opc1 = 2, .crm = 15,
93
- .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
94
- { .name = "L2MERRSR_EL1", .state = ARM_CP_STATE_AA64,
95
- .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 3,
96
- .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
97
- { .name = "L2MERRSR",
98
- .cp = 15, .opc1 = 3, .crm = 15,
99
- .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
100
-};
101
-
102
static void aarch64_a57_initfn(Object *obj)
103
{
104
ARMCPU *cpu = ARM_CPU(obj);
105
@@ -XXX,XX +XXX,XX @@ static void aarch64_a57_initfn(Object *obj)
106
cpu->gic_num_lrs = 4;
107
cpu->gic_vpribits = 5;
108
cpu->gic_vprebits = 5;
109
- define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
110
+ define_cortex_a72_a57_a53_cp_reginfo(cpu);
16
}
111
}
17
112
18
-static uint32_t omap2_gpio_module_readp(void *opaque, hwaddr addr)
113
static void aarch64_a53_initfn(Object *obj)
19
+static uint64_t omap2_gpio_module_readp(void *opaque, hwaddr addr,
114
@@ -XXX,XX +XXX,XX @@ static void aarch64_a53_initfn(Object *obj)
20
+ unsigned size)
115
cpu->gic_num_lrs = 4;
21
{
116
cpu->gic_vpribits = 5;
22
return omap2_gpio_module_read(opaque, addr & ~3) >> ((addr & 3) << 3);
117
cpu->gic_vprebits = 5;
118
- define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
119
+ define_cortex_a72_a57_a53_cp_reginfo(cpu);
23
}
120
}
24
121
25
static void omap2_gpio_module_writep(void *opaque, hwaddr addr,
122
static void aarch64_a72_initfn(Object *obj)
26
- uint32_t value)
123
@@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj)
27
+ uint64_t value, unsigned size)
124
cpu->gic_num_lrs = 4;
28
{
125
cpu->gic_vpribits = 5;
29
uint32_t cur = 0;
126
cpu->gic_vprebits = 5;
30
uint32_t mask = 0xffff;
127
- define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
31
128
+ define_cortex_a72_a57_a53_cp_reginfo(cpu);
32
+ if (size == 4) {
33
+ omap2_gpio_module_write(opaque, addr, value);
34
+ return;
35
+ }
36
+
37
switch (addr & ~3) {
38
case 0x00:    /* GPIO_REVISION */
39
case 0x14:    /* GPIO_SYSSTATUS */
40
@@ -XXX,XX +XXX,XX @@ static void omap2_gpio_module_writep(void *opaque, hwaddr addr,
41
}
129
}
42
130
43
static const MemoryRegionOps omap2_gpio_module_ops = {
131
void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
44
- .old_mmio = {
132
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
45
- .read = {
133
index XXXXXXX..XXXXXXX 100644
46
- omap2_gpio_module_readp,
134
--- a/target/arm/cpu_tcg.c
47
- omap2_gpio_module_readp,
135
+++ b/target/arm/cpu_tcg.c
48
- omap2_gpio_module_read,
136
@@ -XXX,XX +XXX,XX @@
49
- },
137
#endif
50
- .write = {
138
#include "cpregs.h"
51
- omap2_gpio_module_writep,
139
52
- omap2_gpio_module_writep,
140
+#ifndef CONFIG_USER_ONLY
53
- omap2_gpio_module_write,
141
+static uint64_t l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
54
- },
142
+{
55
- },
143
+ ARMCPU *cpu = env_archcpu(env);
56
+ .read = omap2_gpio_module_readp,
144
+
57
+ .write = omap2_gpio_module_writep,
145
+ /* Number of cores is in [25:24]; otherwise we RAZ */
58
+ .valid.min_access_size = 1,
146
+ return (cpu->core_count - 1) << 24;
59
+ .valid.max_access_size = 4,
147
+}
60
.endianness = DEVICE_NATIVE_ENDIAN,
148
+
61
};
149
+static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = {
150
+ { .name = "L2CTLR_EL1", .state = ARM_CP_STATE_AA64,
151
+ .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 2,
152
+ .access = PL1_RW, .readfn = l2ctlr_read,
153
+ .writefn = arm_cp_write_ignore },
154
+ { .name = "L2CTLR",
155
+ .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 2,
156
+ .access = PL1_RW, .readfn = l2ctlr_read,
157
+ .writefn = arm_cp_write_ignore },
158
+ { .name = "L2ECTLR_EL1", .state = ARM_CP_STATE_AA64,
159
+ .opc0 = 3, .opc1 = 1, .crn = 11, .crm = 0, .opc2 = 3,
160
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
161
+ { .name = "L2ECTLR",
162
+ .cp = 15, .opc1 = 1, .crn = 9, .crm = 0, .opc2 = 3,
163
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
164
+ { .name = "L2ACTLR", .state = ARM_CP_STATE_BOTH,
165
+ .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 0, .opc2 = 0,
166
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
167
+ { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64,
168
+ .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 0,
169
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
170
+ { .name = "CPUACTLR",
171
+ .cp = 15, .opc1 = 0, .crm = 15,
172
+ .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
173
+ { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64,
174
+ .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 1,
175
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
176
+ { .name = "CPUECTLR",
177
+ .cp = 15, .opc1 = 1, .crm = 15,
178
+ .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
179
+ { .name = "CPUMERRSR_EL1", .state = ARM_CP_STATE_AA64,
180
+ .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 2,
181
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
182
+ { .name = "CPUMERRSR",
183
+ .cp = 15, .opc1 = 2, .crm = 15,
184
+ .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
185
+ { .name = "L2MERRSR_EL1", .state = ARM_CP_STATE_AA64,
186
+ .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 2, .opc2 = 3,
187
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
188
+ { .name = "L2MERRSR",
189
+ .cp = 15, .opc1 = 3, .crm = 15,
190
+ .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 },
191
+};
192
+
193
+void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu)
194
+{
195
+ define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
196
+}
197
+#endif /* !CONFIG_USER_ONLY */
198
+
199
/* CPU models. These are not needed for the AArch64 linux-user build. */
200
#if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64)
62
201
63
--
202
--
64
2.7.4
203
2.25.1
65
66
diff view generated by jsdifflib
1
Don't use old_mmio in the memory region ops struct.
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Instead of starting with cortex-a15 and adding v8 features to
4
a v7 cpu, begin with a v8 cpu stripped of its aarch64 features.
5
This fixes the long-standing to-do where we only enabled v8
6
features for user-only.
7
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20220506180242.216785-7-richard.henderson@linaro.org
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 1505580378-9044-6-git-send-email-peter.maydell@linaro.org
6
---
12
---
7
hw/i2c/omap_i2c.c | 44 ++++++++++++++++++++++++++++++++------------
13
target/arm/cpu_tcg.c | 151 ++++++++++++++++++++++++++-----------------
8
1 file changed, 32 insertions(+), 12 deletions(-)
14
1 file changed, 92 insertions(+), 59 deletions(-)
9
15
10
diff --git a/hw/i2c/omap_i2c.c b/hw/i2c/omap_i2c.c
16
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
11
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
12
--- a/hw/i2c/omap_i2c.c
18
--- a/target/arm/cpu_tcg.c
13
+++ b/hw/i2c/omap_i2c.c
19
+++ b/target/arm/cpu_tcg.c
14
@@ -XXX,XX +XXX,XX @@ static void omap_i2c_writeb(void *opaque, hwaddr addr,
20
@@ -XXX,XX +XXX,XX @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)
15
}
21
static void arm_max_initfn(Object *obj)
22
{
23
ARMCPU *cpu = ARM_CPU(obj);
24
+ uint32_t t;
25
26
- cortex_a15_initfn(obj);
27
+ /* aarch64_a57_initfn, advertising none of the aarch64 features */
28
+ cpu->dtb_compatible = "arm,cortex-a57";
29
+ set_feature(&cpu->env, ARM_FEATURE_V8);
30
+ set_feature(&cpu->env, ARM_FEATURE_NEON);
31
+ set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
32
+ set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
33
+ set_feature(&cpu->env, ARM_FEATURE_EL2);
34
+ set_feature(&cpu->env, ARM_FEATURE_EL3);
35
+ set_feature(&cpu->env, ARM_FEATURE_PMU);
36
+ cpu->midr = 0x411fd070;
37
+ cpu->revidr = 0x00000000;
38
+ cpu->reset_fpsid = 0x41034070;
39
+ cpu->isar.mvfr0 = 0x10110222;
40
+ cpu->isar.mvfr1 = 0x12111111;
41
+ cpu->isar.mvfr2 = 0x00000043;
42
+ cpu->ctr = 0x8444c004;
43
+ cpu->reset_sctlr = 0x00c50838;
44
+ cpu->isar.id_pfr0 = 0x00000131;
45
+ cpu->isar.id_pfr1 = 0x00011011;
46
+ cpu->isar.id_dfr0 = 0x03010066;
47
+ cpu->id_afr0 = 0x00000000;
48
+ cpu->isar.id_mmfr0 = 0x10101105;
49
+ cpu->isar.id_mmfr1 = 0x40000000;
50
+ cpu->isar.id_mmfr2 = 0x01260000;
51
+ cpu->isar.id_mmfr3 = 0x02102211;
52
+ cpu->isar.id_isar0 = 0x02101110;
53
+ cpu->isar.id_isar1 = 0x13112111;
54
+ cpu->isar.id_isar2 = 0x21232042;
55
+ cpu->isar.id_isar3 = 0x01112131;
56
+ cpu->isar.id_isar4 = 0x00011142;
57
+ cpu->isar.id_isar5 = 0x00011121;
58
+ cpu->isar.id_isar6 = 0;
59
+ cpu->isar.dbgdidr = 0x3516d000;
60
+ cpu->clidr = 0x0a200023;
61
+ cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */
62
+ cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */
63
+ cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */
64
+ define_cortex_a72_a57_a53_cp_reginfo(cpu);
65
66
- /* old-style VFP short-vector support */
67
- cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
68
+ /* Add additional features supported by QEMU */
69
+ t = cpu->isar.id_isar5;
70
+ t = FIELD_DP32(t, ID_ISAR5, AES, 2);
71
+ t = FIELD_DP32(t, ID_ISAR5, SHA1, 1);
72
+ t = FIELD_DP32(t, ID_ISAR5, SHA2, 1);
73
+ t = FIELD_DP32(t, ID_ISAR5, CRC32, 1);
74
+ t = FIELD_DP32(t, ID_ISAR5, RDM, 1);
75
+ t = FIELD_DP32(t, ID_ISAR5, VCMA, 1);
76
+ cpu->isar.id_isar5 = t;
77
+
78
+ t = cpu->isar.id_isar6;
79
+ t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1);
80
+ t = FIELD_DP32(t, ID_ISAR6, DP, 1);
81
+ t = FIELD_DP32(t, ID_ISAR6, FHM, 1);
82
+ t = FIELD_DP32(t, ID_ISAR6, SB, 1);
83
+ t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1);
84
+ t = FIELD_DP32(t, ID_ISAR6, BF16, 1);
85
+ t = FIELD_DP32(t, ID_ISAR6, I8MM, 1);
86
+ cpu->isar.id_isar6 = t;
87
+
88
+ t = cpu->isar.mvfr1;
89
+ t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */
90
+ t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */
91
+ cpu->isar.mvfr1 = t;
92
+
93
+ t = cpu->isar.mvfr2;
94
+ t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */
95
+ t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */
96
+ cpu->isar.mvfr2 = t;
97
+
98
+ t = cpu->isar.id_mmfr3;
99
+ t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */
100
+ cpu->isar.id_mmfr3 = t;
101
+
102
+ t = cpu->isar.id_mmfr4;
103
+ t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */
104
+ t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
105
+ t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */
106
+ t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */
107
+ cpu->isar.id_mmfr4 = t;
108
+
109
+ t = cpu->isar.id_pfr0;
110
+ t = FIELD_DP32(t, ID_PFR0, DIT, 1);
111
+ cpu->isar.id_pfr0 = t;
112
+
113
+ t = cpu->isar.id_pfr2;
114
+ t = FIELD_DP32(t, ID_PFR2, SSBS, 1);
115
+ cpu->isar.id_pfr2 = t;
116
117
#ifdef CONFIG_USER_ONLY
118
/*
119
- * We don't set these in system emulation mode for the moment,
120
- * since we don't correctly set (all of) the ID registers to
121
- * advertise them.
122
+ * Break with true ARMv8 and add back old-style VFP short-vector support.
123
+ * Only do this for user-mode, where -cpu max is the default, so that
124
+ * older v6 and v7 programs are more likely to work without adjustment.
125
*/
126
- set_feature(&cpu->env, ARM_FEATURE_V8);
127
- {
128
- uint32_t t;
129
-
130
- t = cpu->isar.id_isar5;
131
- t = FIELD_DP32(t, ID_ISAR5, AES, 2);
132
- t = FIELD_DP32(t, ID_ISAR5, SHA1, 1);
133
- t = FIELD_DP32(t, ID_ISAR5, SHA2, 1);
134
- t = FIELD_DP32(t, ID_ISAR5, CRC32, 1);
135
- t = FIELD_DP32(t, ID_ISAR5, RDM, 1);
136
- t = FIELD_DP32(t, ID_ISAR5, VCMA, 1);
137
- cpu->isar.id_isar5 = t;
138
-
139
- t = cpu->isar.id_isar6;
140
- t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1);
141
- t = FIELD_DP32(t, ID_ISAR6, DP, 1);
142
- t = FIELD_DP32(t, ID_ISAR6, FHM, 1);
143
- t = FIELD_DP32(t, ID_ISAR6, SB, 1);
144
- t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1);
145
- t = FIELD_DP32(t, ID_ISAR6, BF16, 1);
146
- t = FIELD_DP32(t, ID_ISAR6, I8MM, 1);
147
- cpu->isar.id_isar6 = t;
148
-
149
- t = cpu->isar.mvfr1;
150
- t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */
151
- t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */
152
- cpu->isar.mvfr1 = t;
153
-
154
- t = cpu->isar.mvfr2;
155
- t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */
156
- t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */
157
- cpu->isar.mvfr2 = t;
158
-
159
- t = cpu->isar.id_mmfr3;
160
- t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */
161
- cpu->isar.id_mmfr3 = t;
162
-
163
- t = cpu->isar.id_mmfr4;
164
- t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */
165
- t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
166
- t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */
167
- t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */
168
- cpu->isar.id_mmfr4 = t;
169
-
170
- t = cpu->isar.id_pfr0;
171
- t = FIELD_DP32(t, ID_PFR0, DIT, 1);
172
- cpu->isar.id_pfr0 = t;
173
-
174
- t = cpu->isar.id_pfr2;
175
- t = FIELD_DP32(t, ID_PFR2, SSBS, 1);
176
- cpu->isar.id_pfr2 = t;
177
- }
178
-#endif /* CONFIG_USER_ONLY */
179
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
180
+#endif
16
}
181
}
17
182
#endif /* !TARGET_AARCH64 */
18
+static uint64_t omap_i2c_readfn(void *opaque, hwaddr addr,
19
+ unsigned size)
20
+{
21
+ switch (size) {
22
+ case 2:
23
+ return omap_i2c_read(opaque, addr);
24
+ default:
25
+ return omap_badwidth_read16(opaque, addr);
26
+ }
27
+}
28
+
29
+static void omap_i2c_writefn(void *opaque, hwaddr addr,
30
+ uint64_t value, unsigned size)
31
+{
32
+ switch (size) {
33
+ case 1:
34
+ /* Only the last fifo write can be 8 bit. */
35
+ omap_i2c_writeb(opaque, addr, value);
36
+ break;
37
+ case 2:
38
+ omap_i2c_write(opaque, addr, value);
39
+ break;
40
+ default:
41
+ omap_badwidth_write16(opaque, addr, value);
42
+ break;
43
+ }
44
+}
45
+
46
static const MemoryRegionOps omap_i2c_ops = {
47
- .old_mmio = {
48
- .read = {
49
- omap_badwidth_read16,
50
- omap_i2c_read,
51
- omap_badwidth_read16,
52
- },
53
- .write = {
54
- omap_i2c_writeb, /* Only the last fifo write can be 8 bit. */
55
- omap_i2c_write,
56
- omap_badwidth_write16,
57
- },
58
- },
59
+ .read = omap_i2c_readfn,
60
+ .write = omap_i2c_writefn,
61
+ .valid.min_access_size = 1,
62
+ .valid.max_access_size = 4,
63
.endianness = DEVICE_NATIVE_ENDIAN,
64
};
65
183
66
--
184
--
67
2.7.4
185
2.25.1
68
69
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
We set this for qemu-system-aarch64, but failed to do so
4
for the strictly 32-bit emulation.
5
6
Fixes: 3bec78447a9 ("target/arm: Provide ARMv8.4-PMU in '-cpu max'")
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220506180242.216785-8-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/cpu_tcg.c | 4 ++++
13
1 file changed, 4 insertions(+)
14
15
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu_tcg.c
18
+++ b/target/arm/cpu_tcg.c
19
@@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj)
20
t = FIELD_DP32(t, ID_PFR2, SSBS, 1);
21
cpu->isar.id_pfr2 = t;
22
23
+ t = cpu->isar.id_dfr0;
24
+ t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */
25
+ cpu->isar.id_dfr0 = t;
26
+
27
#ifdef CONFIG_USER_ONLY
28
/*
29
* Break with true ARMv8 and add back old-style VFP short-vector support.
30
--
31
2.25.1
diff view generated by jsdifflib
1
From: Subbaraya Sundeep <sundeep.lkml@gmail.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Modelled System Timer in Microsemi's Smartfusion2 Soc.
3
Share the code to set AArch32 max features so that we no
4
Timer has two 32bit down counters and two interrupts.
4
longer have code drift between qemu{-system,}-{arm,aarch64}.
5
5
6
Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20220506180242.216785-9-richard.henderson@linaro.org
9
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Message-id: 20170920201737.25723-2-f4bug@amsat.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
10
---
13
hw/timer/Makefile.objs | 1 +
11
target/arm/internals.h | 2 +
14
include/hw/timer/mss-timer.h | 64 ++++++++++
12
target/arm/cpu64.c | 50 +-----------------
15
hw/timer/mss-timer.c | 289 +++++++++++++++++++++++++++++++++++++++++++
13
target/arm/cpu_tcg.c | 114 ++++++++++++++++++++++-------------------
16
3 files changed, 354 insertions(+)
14
3 files changed, 65 insertions(+), 101 deletions(-)
17
create mode 100644 include/hw/timer/mss-timer.h
18
create mode 100644 hw/timer/mss-timer.c
19
15
20
diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
16
diff --git a/target/arm/internals.h b/target/arm/internals.h
21
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/timer/Makefile.objs
18
--- a/target/arm/internals.h
23
+++ b/hw/timer/Makefile.objs
19
+++ b/target/arm/internals.h
24
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_ASPEED_SOC) += aspeed_timer.o
20
@@ -XXX,XX +XXX,XX @@ static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { }
25
21
void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu);
26
common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o
22
#endif
27
common-obj-$(CONFIG_CMSDK_APB_TIMER) += cmsdk-apb-timer.o
23
28
+common-obj-$(CONFIG_MSF2) += mss-timer.o
24
+void aa32_max_features(ARMCPU *cpu);
29
diff --git a/include/hw/timer/mss-timer.h b/include/hw/timer/mss-timer.h
25
+
30
new file mode 100644
26
#endif
31
index XXXXXXX..XXXXXXX
27
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
32
--- /dev/null
28
index XXXXXXX..XXXXXXX 100644
33
+++ b/include/hw/timer/mss-timer.h
29
--- a/target/arm/cpu64.c
30
+++ b/target/arm/cpu64.c
31
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
32
{
33
ARMCPU *cpu = ARM_CPU(obj);
34
uint64_t t;
35
- uint32_t u;
36
37
if (kvm_enabled() || hvf_enabled()) {
38
/* With KVM or HVF, '-cpu max' is identical to '-cpu host' */
39
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
40
t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1);
41
cpu->isar.id_aa64zfr0 = t;
42
43
- /* Replicate the same data to the 32-bit id registers. */
44
- u = cpu->isar.id_isar5;
45
- u = FIELD_DP32(u, ID_ISAR5, AES, 2); /* AES + PMULL */
46
- u = FIELD_DP32(u, ID_ISAR5, SHA1, 1);
47
- u = FIELD_DP32(u, ID_ISAR5, SHA2, 1);
48
- u = FIELD_DP32(u, ID_ISAR5, CRC32, 1);
49
- u = FIELD_DP32(u, ID_ISAR5, RDM, 1);
50
- u = FIELD_DP32(u, ID_ISAR5, VCMA, 1);
51
- cpu->isar.id_isar5 = u;
52
-
53
- u = cpu->isar.id_isar6;
54
- u = FIELD_DP32(u, ID_ISAR6, JSCVT, 1);
55
- u = FIELD_DP32(u, ID_ISAR6, DP, 1);
56
- u = FIELD_DP32(u, ID_ISAR6, FHM, 1);
57
- u = FIELD_DP32(u, ID_ISAR6, SB, 1);
58
- u = FIELD_DP32(u, ID_ISAR6, SPECRES, 1);
59
- u = FIELD_DP32(u, ID_ISAR6, BF16, 1);
60
- u = FIELD_DP32(u, ID_ISAR6, I8MM, 1);
61
- cpu->isar.id_isar6 = u;
62
-
63
- u = cpu->isar.id_pfr0;
64
- u = FIELD_DP32(u, ID_PFR0, DIT, 1);
65
- cpu->isar.id_pfr0 = u;
66
-
67
- u = cpu->isar.id_pfr2;
68
- u = FIELD_DP32(u, ID_PFR2, SSBS, 1);
69
- cpu->isar.id_pfr2 = u;
70
-
71
- u = cpu->isar.id_mmfr3;
72
- u = FIELD_DP32(u, ID_MMFR3, PAN, 2); /* ATS1E1 */
73
- cpu->isar.id_mmfr3 = u;
74
-
75
- u = cpu->isar.id_mmfr4;
76
- u = FIELD_DP32(u, ID_MMFR4, HPDS, 1); /* AA32HPD */
77
- u = FIELD_DP32(u, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
78
- u = FIELD_DP32(u, ID_MMFR4, CNP, 1); /* TTCNP */
79
- u = FIELD_DP32(u, ID_MMFR4, XNX, 1); /* TTS2UXN */
80
- cpu->isar.id_mmfr4 = u;
81
-
82
t = cpu->isar.id_aa64dfr0;
83
t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */
84
cpu->isar.id_aa64dfr0 = t;
85
86
- u = cpu->isar.id_dfr0;
87
- u = FIELD_DP32(u, ID_DFR0, PERFMON, 5); /* v8.4-PMU */
88
- cpu->isar.id_dfr0 = u;
89
-
90
- u = cpu->isar.mvfr1;
91
- u = FIELD_DP32(u, MVFR1, FPHP, 3); /* v8.2-FP16 */
92
- u = FIELD_DP32(u, MVFR1, SIMDHP, 2); /* v8.2-FP16 */
93
- cpu->isar.mvfr1 = u;
94
+ /* Replicate the same data to the 32-bit id registers. */
95
+ aa32_max_features(cpu);
96
97
#ifdef CONFIG_USER_ONLY
98
/*
99
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
100
index XXXXXXX..XXXXXXX 100644
101
--- a/target/arm/cpu_tcg.c
102
+++ b/target/arm/cpu_tcg.c
34
@@ -XXX,XX +XXX,XX @@
103
@@ -XXX,XX +XXX,XX @@
35
+/*
104
#endif
36
+ * Microsemi SmartFusion2 Timer.
105
#include "cpregs.h"
37
+ *
106
38
+ * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>
107
+
39
+ *
108
+/* Share AArch32 -cpu max features with AArch64. */
40
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
109
+void aa32_max_features(ARMCPU *cpu)
41
+ * of this software and associated documentation files (the "Software"), to deal
42
+ * in the Software without restriction, including without limitation the rights
43
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
44
+ * copies of the Software, and to permit persons to whom the Software is
45
+ * furnished to do so, subject to the following conditions:
46
+ *
47
+ * The above copyright notice and this permission notice shall be included in
48
+ * all copies or substantial portions of the Software.
49
+ *
50
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
51
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
52
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
53
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
54
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
55
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
56
+ * THE SOFTWARE.
57
+ */
58
+
59
+#ifndef HW_MSS_TIMER_H
60
+#define HW_MSS_TIMER_H
61
+
62
+#include "hw/sysbus.h"
63
+#include "hw/ptimer.h"
64
+
65
+#define TYPE_MSS_TIMER "mss-timer"
66
+#define MSS_TIMER(obj) OBJECT_CHECK(MSSTimerState, \
67
+ (obj), TYPE_MSS_TIMER)
68
+
69
+/*
70
+ * There are two 32-bit down counting timers.
71
+ * Timers 1 and 2 can be concatenated into a single 64-bit Timer
72
+ * that operates either in Periodic mode or in One-shot mode.
73
+ * Writing 1 to the TIM64_MODE register bit 0 sets the Timers in 64-bit mode.
74
+ * In 64-bit mode, writing to the 32-bit registers has no effect.
75
+ * Similarly, in 32-bit mode, writing to the 64-bit mode registers
76
+ * has no effect. Only two 32-bit timers are supported currently.
77
+ */
78
+#define NUM_TIMERS 2
79
+
80
+#define R_TIM1_MAX 6
81
+
82
+struct Msf2Timer {
83
+ QEMUBH *bh;
84
+ ptimer_state *ptimer;
85
+
86
+ uint32_t regs[R_TIM1_MAX];
87
+ qemu_irq irq;
88
+};
89
+
90
+typedef struct MSSTimerState {
91
+ SysBusDevice parent_obj;
92
+
93
+ MemoryRegion mmio;
94
+ uint32_t freq_hz;
95
+ struct Msf2Timer timers[NUM_TIMERS];
96
+} MSSTimerState;
97
+
98
+#endif /* HW_MSS_TIMER_H */
99
diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c
100
new file mode 100644
101
index XXXXXXX..XXXXXXX
102
--- /dev/null
103
+++ b/hw/timer/mss-timer.c
104
@@ -XXX,XX +XXX,XX @@
105
+/*
106
+ * Block model of System timer present in
107
+ * Microsemi's SmartFusion2 and SmartFusion SoCs.
108
+ *
109
+ * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>.
110
+ *
111
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
112
+ * of this software and associated documentation files (the "Software"), to deal
113
+ * in the Software without restriction, including without limitation the rights
114
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
115
+ * copies of the Software, and to permit persons to whom the Software is
116
+ * furnished to do so, subject to the following conditions:
117
+ *
118
+ * The above copyright notice and this permission notice shall be included in
119
+ * all copies or substantial portions of the Software.
120
+ *
121
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
122
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
123
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
124
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
125
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
126
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
127
+ * THE SOFTWARE.
128
+ */
129
+
130
+#include "qemu/osdep.h"
131
+#include "qemu/main-loop.h"
132
+#include "qemu/log.h"
133
+#include "hw/timer/mss-timer.h"
134
+
135
+#ifndef MSS_TIMER_ERR_DEBUG
136
+#define MSS_TIMER_ERR_DEBUG 0
137
+#endif
138
+
139
+#define DB_PRINT_L(lvl, fmt, args...) do { \
140
+ if (MSS_TIMER_ERR_DEBUG >= lvl) { \
141
+ qemu_log("%s: " fmt "\n", __func__, ## args); \
142
+ } \
143
+} while (0);
144
+
145
+#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args)
146
+
147
+#define R_TIM_VAL 0
148
+#define R_TIM_LOADVAL 1
149
+#define R_TIM_BGLOADVAL 2
150
+#define R_TIM_CTRL 3
151
+#define R_TIM_RIS 4
152
+#define R_TIM_MIS 5
153
+
154
+#define TIMER_CTRL_ENBL (1 << 0)
155
+#define TIMER_CTRL_ONESHOT (1 << 1)
156
+#define TIMER_CTRL_INTR (1 << 2)
157
+#define TIMER_RIS_ACK (1 << 0)
158
+#define TIMER_RST_CLR (1 << 6)
159
+#define TIMER_MODE (1 << 0)
160
+
161
+static void timer_update_irq(struct Msf2Timer *st)
162
+{
110
+{
163
+ bool isr, ier;
111
+ uint32_t t;
164
+
112
+
165
+ isr = !!(st->regs[R_TIM_RIS] & TIMER_RIS_ACK);
113
+ /* Add additional features supported by QEMU */
166
+ ier = !!(st->regs[R_TIM_CTRL] & TIMER_CTRL_INTR);
114
+ t = cpu->isar.id_isar5;
167
+ qemu_set_irq(st->irq, (ier && isr));
115
+ t = FIELD_DP32(t, ID_ISAR5, AES, 2);
116
+ t = FIELD_DP32(t, ID_ISAR5, SHA1, 1);
117
+ t = FIELD_DP32(t, ID_ISAR5, SHA2, 1);
118
+ t = FIELD_DP32(t, ID_ISAR5, CRC32, 1);
119
+ t = FIELD_DP32(t, ID_ISAR5, RDM, 1);
120
+ t = FIELD_DP32(t, ID_ISAR5, VCMA, 1);
121
+ cpu->isar.id_isar5 = t;
122
+
123
+ t = cpu->isar.id_isar6;
124
+ t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1);
125
+ t = FIELD_DP32(t, ID_ISAR6, DP, 1);
126
+ t = FIELD_DP32(t, ID_ISAR6, FHM, 1);
127
+ t = FIELD_DP32(t, ID_ISAR6, SB, 1);
128
+ t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1);
129
+ t = FIELD_DP32(t, ID_ISAR6, BF16, 1);
130
+ t = FIELD_DP32(t, ID_ISAR6, I8MM, 1);
131
+ cpu->isar.id_isar6 = t;
132
+
133
+ t = cpu->isar.mvfr1;
134
+ t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */
135
+ t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */
136
+ cpu->isar.mvfr1 = t;
137
+
138
+ t = cpu->isar.mvfr2;
139
+ t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */
140
+ t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */
141
+ cpu->isar.mvfr2 = t;
142
+
143
+ t = cpu->isar.id_mmfr3;
144
+ t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */
145
+ cpu->isar.id_mmfr3 = t;
146
+
147
+ t = cpu->isar.id_mmfr4;
148
+ t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */
149
+ t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
150
+ t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */
151
+ t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */
152
+ cpu->isar.id_mmfr4 = t;
153
+
154
+ t = cpu->isar.id_pfr0;
155
+ t = FIELD_DP32(t, ID_PFR0, DIT, 1);
156
+ cpu->isar.id_pfr0 = t;
157
+
158
+ t = cpu->isar.id_pfr2;
159
+ t = FIELD_DP32(t, ID_PFR2, SSBS, 1);
160
+ cpu->isar.id_pfr2 = t;
161
+
162
+ t = cpu->isar.id_dfr0;
163
+ t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */
164
+ cpu->isar.id_dfr0 = t;
168
+}
165
+}
169
+
166
+
170
+static void timer_update(struct Msf2Timer *st)
167
#ifndef CONFIG_USER_ONLY
171
+{
168
static uint64_t l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
172
+ uint64_t count;
169
{
173
+
170
@@ -XXX,XX +XXX,XX @@ static void arm_v7m_class_init(ObjectClass *oc, void *data)
174
+ if (!(st->regs[R_TIM_CTRL] & TIMER_CTRL_ENBL)) {
171
static void arm_max_initfn(Object *obj)
175
+ ptimer_stop(st->ptimer);
172
{
176
+ return;
173
ARMCPU *cpu = ARM_CPU(obj);
177
+ }
174
- uint32_t t;
178
+
175
179
+ count = st->regs[R_TIM_LOADVAL];
176
/* aarch64_a57_initfn, advertising none of the aarch64 features */
180
+ ptimer_set_limit(st->ptimer, count, 1);
177
cpu->dtb_compatible = "arm,cortex-a57";
181
+ ptimer_run(st->ptimer, 1);
178
@@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj)
182
+}
179
cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */
183
+
180
define_cortex_a72_a57_a53_cp_reginfo(cpu);
184
+static uint64_t
181
185
+timer_read(void *opaque, hwaddr offset, unsigned int size)
182
- /* Add additional features supported by QEMU */
186
+{
183
- t = cpu->isar.id_isar5;
187
+ MSSTimerState *t = opaque;
184
- t = FIELD_DP32(t, ID_ISAR5, AES, 2);
188
+ hwaddr addr;
185
- t = FIELD_DP32(t, ID_ISAR5, SHA1, 1);
189
+ struct Msf2Timer *st;
186
- t = FIELD_DP32(t, ID_ISAR5, SHA2, 1);
190
+ uint32_t ret = 0;
187
- t = FIELD_DP32(t, ID_ISAR5, CRC32, 1);
191
+ int timer = 0;
188
- t = FIELD_DP32(t, ID_ISAR5, RDM, 1);
192
+ int isr;
189
- t = FIELD_DP32(t, ID_ISAR5, VCMA, 1);
193
+ int ier;
190
- cpu->isar.id_isar5 = t;
194
+
191
-
195
+ addr = offset >> 2;
192
- t = cpu->isar.id_isar6;
196
+ /*
193
- t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1);
197
+ * Two independent timers has same base address.
194
- t = FIELD_DP32(t, ID_ISAR6, DP, 1);
198
+ * Based on address passed figure out which timer is being used.
195
- t = FIELD_DP32(t, ID_ISAR6, FHM, 1);
199
+ */
196
- t = FIELD_DP32(t, ID_ISAR6, SB, 1);
200
+ if ((addr >= R_TIM1_MAX) && (addr < NUM_TIMERS * R_TIM1_MAX)) {
197
- t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1);
201
+ timer = 1;
198
- t = FIELD_DP32(t, ID_ISAR6, BF16, 1);
202
+ addr -= R_TIM1_MAX;
199
- t = FIELD_DP32(t, ID_ISAR6, I8MM, 1);
203
+ }
200
- cpu->isar.id_isar6 = t;
204
+
201
-
205
+ st = &t->timers[timer];
202
- t = cpu->isar.mvfr1;
206
+
203
- t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */
207
+ switch (addr) {
204
- t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */
208
+ case R_TIM_VAL:
205
- cpu->isar.mvfr1 = t;
209
+ ret = ptimer_get_count(st->ptimer);
206
-
210
+ break;
207
- t = cpu->isar.mvfr2;
211
+
208
- t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */
212
+ case R_TIM_MIS:
209
- t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */
213
+ isr = !!(st->regs[R_TIM_RIS] & TIMER_RIS_ACK);
210
- cpu->isar.mvfr2 = t;
214
+ ier = !!(st->regs[R_TIM_CTRL] & TIMER_CTRL_INTR);
211
-
215
+ ret = ier & isr;
212
- t = cpu->isar.id_mmfr3;
216
+ break;
213
- t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */
217
+
214
- cpu->isar.id_mmfr3 = t;
218
+ default:
215
-
219
+ if (addr < R_TIM1_MAX) {
216
- t = cpu->isar.id_mmfr4;
220
+ ret = st->regs[addr];
217
- t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */
221
+ } else {
218
- t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
222
+ qemu_log_mask(LOG_GUEST_ERROR,
219
- t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */
223
+ TYPE_MSS_TIMER": 64-bit mode not supported\n");
220
- t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */
224
+ return ret;
221
- cpu->isar.id_mmfr4 = t;
225
+ }
222
-
226
+ break;
223
- t = cpu->isar.id_pfr0;
227
+ }
224
- t = FIELD_DP32(t, ID_PFR0, DIT, 1);
228
+
225
- cpu->isar.id_pfr0 = t;
229
+ DB_PRINT("timer=%d 0x%" HWADDR_PRIx "=0x%" PRIx32, timer, offset,
226
-
230
+ ret);
227
- t = cpu->isar.id_pfr2;
231
+ return ret;
228
- t = FIELD_DP32(t, ID_PFR2, SSBS, 1);
232
+}
229
- cpu->isar.id_pfr2 = t;
233
+
230
-
234
+static void
231
- t = cpu->isar.id_dfr0;
235
+timer_write(void *opaque, hwaddr offset,
232
- t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */
236
+ uint64_t val64, unsigned int size)
233
- cpu->isar.id_dfr0 = t;
237
+{
234
+ aa32_max_features(cpu);
238
+ MSSTimerState *t = opaque;
235
239
+ hwaddr addr;
236
#ifdef CONFIG_USER_ONLY
240
+ struct Msf2Timer *st;
237
/*
241
+ int timer = 0;
242
+ uint32_t value = val64;
243
+
244
+ addr = offset >> 2;
245
+ /*
246
+ * Two independent timers has same base address.
247
+ * Based on addr passed figure out which timer is being used.
248
+ */
249
+ if ((addr >= R_TIM1_MAX) && (addr < NUM_TIMERS * R_TIM1_MAX)) {
250
+ timer = 1;
251
+ addr -= R_TIM1_MAX;
252
+ }
253
+
254
+ st = &t->timers[timer];
255
+
256
+ DB_PRINT("addr=0x%" HWADDR_PRIx " val=0x%" PRIx32 " (timer=%d)", offset,
257
+ value, timer);
258
+
259
+ switch (addr) {
260
+ case R_TIM_CTRL:
261
+ st->regs[R_TIM_CTRL] = value;
262
+ timer_update(st);
263
+ break;
264
+
265
+ case R_TIM_RIS:
266
+ if (value & TIMER_RIS_ACK) {
267
+ st->regs[R_TIM_RIS] &= ~TIMER_RIS_ACK;
268
+ }
269
+ break;
270
+
271
+ case R_TIM_LOADVAL:
272
+ st->regs[R_TIM_LOADVAL] = value;
273
+ if (st->regs[R_TIM_CTRL] & TIMER_CTRL_ENBL) {
274
+ timer_update(st);
275
+ }
276
+ break;
277
+
278
+ case R_TIM_BGLOADVAL:
279
+ st->regs[R_TIM_BGLOADVAL] = value;
280
+ st->regs[R_TIM_LOADVAL] = value;
281
+ break;
282
+
283
+ case R_TIM_VAL:
284
+ case R_TIM_MIS:
285
+ break;
286
+
287
+ default:
288
+ if (addr < R_TIM1_MAX) {
289
+ st->regs[addr] = value;
290
+ } else {
291
+ qemu_log_mask(LOG_GUEST_ERROR,
292
+ TYPE_MSS_TIMER": 64-bit mode not supported\n");
293
+ return;
294
+ }
295
+ break;
296
+ }
297
+ timer_update_irq(st);
298
+}
299
+
300
+static const MemoryRegionOps timer_ops = {
301
+ .read = timer_read,
302
+ .write = timer_write,
303
+ .endianness = DEVICE_NATIVE_ENDIAN,
304
+ .valid = {
305
+ .min_access_size = 1,
306
+ .max_access_size = 4
307
+ }
308
+};
309
+
310
+static void timer_hit(void *opaque)
311
+{
312
+ struct Msf2Timer *st = opaque;
313
+
314
+ st->regs[R_TIM_RIS] |= TIMER_RIS_ACK;
315
+
316
+ if (!(st->regs[R_TIM_CTRL] & TIMER_CTRL_ONESHOT)) {
317
+ timer_update(st);
318
+ }
319
+ timer_update_irq(st);
320
+}
321
+
322
+static void mss_timer_init(Object *obj)
323
+{
324
+ MSSTimerState *t = MSS_TIMER(obj);
325
+ int i;
326
+
327
+ /* Init all the ptimers. */
328
+ for (i = 0; i < NUM_TIMERS; i++) {
329
+ struct Msf2Timer *st = &t->timers[i];
330
+
331
+ st->bh = qemu_bh_new(timer_hit, st);
332
+ st->ptimer = ptimer_init(st->bh, PTIMER_POLICY_DEFAULT);
333
+ ptimer_set_freq(st->ptimer, t->freq_hz);
334
+ sysbus_init_irq(SYS_BUS_DEVICE(obj), &st->irq);
335
+ }
336
+
337
+ memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t, TYPE_MSS_TIMER,
338
+ NUM_TIMERS * R_TIM1_MAX * 4);
339
+ sysbus_init_mmio(SYS_BUS_DEVICE(obj), &t->mmio);
340
+}
341
+
342
+static const VMStateDescription vmstate_timers = {
343
+ .name = "mss-timer-block",
344
+ .version_id = 1,
345
+ .minimum_version_id = 1,
346
+ .fields = (VMStateField[]) {
347
+ VMSTATE_PTIMER(ptimer, struct Msf2Timer),
348
+ VMSTATE_UINT32_ARRAY(regs, struct Msf2Timer, R_TIM1_MAX),
349
+ VMSTATE_END_OF_LIST()
350
+ }
351
+};
352
+
353
+static const VMStateDescription vmstate_mss_timer = {
354
+ .name = TYPE_MSS_TIMER,
355
+ .version_id = 1,
356
+ .minimum_version_id = 1,
357
+ .fields = (VMStateField[]) {
358
+ VMSTATE_UINT32(freq_hz, MSSTimerState),
359
+ VMSTATE_STRUCT_ARRAY(timers, MSSTimerState, NUM_TIMERS, 0,
360
+ vmstate_timers, struct Msf2Timer),
361
+ VMSTATE_END_OF_LIST()
362
+ }
363
+};
364
+
365
+static Property mss_timer_properties[] = {
366
+ /* Libero GUI shows 100Mhz as default for clocks */
367
+ DEFINE_PROP_UINT32("clock-frequency", MSSTimerState, freq_hz,
368
+ 100 * 1000000),
369
+ DEFINE_PROP_END_OF_LIST(),
370
+};
371
+
372
+static void mss_timer_class_init(ObjectClass *klass, void *data)
373
+{
374
+ DeviceClass *dc = DEVICE_CLASS(klass);
375
+
376
+ dc->props = mss_timer_properties;
377
+ dc->vmsd = &vmstate_mss_timer;
378
+}
379
+
380
+static const TypeInfo mss_timer_info = {
381
+ .name = TYPE_MSS_TIMER,
382
+ .parent = TYPE_SYS_BUS_DEVICE,
383
+ .instance_size = sizeof(MSSTimerState),
384
+ .instance_init = mss_timer_init,
385
+ .class_init = mss_timer_class_init,
386
+};
387
+
388
+static void mss_timer_register_types(void)
389
+{
390
+ type_register_static(&mss_timer_info);
391
+}
392
+
393
+type_init(mss_timer_register_types)
394
--
238
--
395
2.7.4
239
2.25.1
396
397
diff view generated by jsdifflib
1
Don't use the old_mmio in the memory region ops struct.
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Update the legacy feature names to the current names.
4
Provide feature names for id changes that were not marked.
5
Sort the field updates into increasing bitfield order.
6
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220506180242.216785-10-richard.henderson@linaro.org
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 1505580378-9044-4-git-send-email-peter.maydell@linaro.org
6
---
11
---
7
hw/timer/omap_synctimer.c | 35 +++++++++++++++++++++--------------
12
target/arm/cpu64.c | 100 +++++++++++++++++++++----------------------
8
1 file changed, 21 insertions(+), 14 deletions(-)
13
target/arm/cpu_tcg.c | 48 ++++++++++-----------
14
2 files changed, 74 insertions(+), 74 deletions(-)
9
15
10
diff --git a/hw/timer/omap_synctimer.c b/hw/timer/omap_synctimer.c
16
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
11
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
12
--- a/hw/timer/omap_synctimer.c
18
--- a/target/arm/cpu64.c
13
+++ b/hw/timer/omap_synctimer.c
19
+++ b/target/arm/cpu64.c
14
@@ -XXX,XX +XXX,XX @@ static uint32_t omap_synctimer_readh(void *opaque, hwaddr addr)
20
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
15
}
21
cpu->midr = t;
22
23
t = cpu->isar.id_aa64isar0;
24
- t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* AES + PMULL */
25
- t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);
26
- t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* SHA512 */
27
+ t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */
28
+ t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */
29
+ t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* FEAT_SHA512 */
30
t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);
31
- t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2);
32
- t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1);
33
- t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1);
34
- t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1);
35
- t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1);
36
- t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);
37
- t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1);
38
- t = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* v8.5-CondM */
39
- t = FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */
40
- t = FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1);
41
+ t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2); /* FEAT_LSE */
42
+ t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1); /* FEAT_RDM */
43
+ t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1); /* FEAT_SHA3 */
44
+ t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1); /* FEAT_SM3 */
45
+ t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1); /* FEAT_SM4 */
46
+ t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1); /* FEAT_DotProd */
47
+ t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1); /* FEAT_FHM */
48
+ t = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* FEAT_FlagM2 */
49
+ t = FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */
50
+ t = FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1); /* FEAT_RNG */
51
cpu->isar.id_aa64isar0 = t;
52
53
t = cpu->isar.id_aa64isar1;
54
- t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2);
55
- t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1);
56
- t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1);
57
- t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1);
58
- t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1);
59
- t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1);
60
- t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1);
61
- t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* ARMv8.4-RCPC */
62
- t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1);
63
+ t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); /* FEAT_DPB2 */
64
+ t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); /* FEAT_JSCVT */
65
+ t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); /* FEAT_FCMA */
66
+ t = FIELD_DP64(t, ID_AA64ISAR1, LRCPC, 2); /* FEAT_LRCPC2 */
67
+ t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1); /* FEAT_FRINTTS */
68
+ t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); /* FEAT_SB */
69
+ t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); /* FEAT_SPECRES */
70
+ t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); /* FEAT_BF16 */
71
+ t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); /* FEAT_I8MM */
72
cpu->isar.id_aa64isar1 = t;
73
74
t = cpu->isar.id_aa64pfr0;
75
+ t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */
76
+ t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */
77
t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
78
- t = FIELD_DP64(t, ID_AA64PFR0, FP, 1);
79
- t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1);
80
- t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1);
81
- t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1);
82
+ t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */
83
+ t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */
84
cpu->isar.id_aa64pfr0 = t;
85
86
t = cpu->isar.id_aa64pfr1;
87
- t = FIELD_DP64(t, ID_AA64PFR1, BT, 1);
88
- t = FIELD_DP64(t, ID_AA64PFR1, SSBS, 2);
89
+ t = FIELD_DP64(t, ID_AA64PFR1, BT, 1); /* FEAT_BTI */
90
+ t = FIELD_DP64(t, ID_AA64PFR1, SSBS, 2); /* FEAT_SSBS2 */
91
/*
92
* Begin with full support for MTE. This will be downgraded to MTE=0
93
* during realize if the board provides no tag memory, much like
94
* we do for EL2 with the virtualization=on property.
95
*/
96
- t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3);
97
+ t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */
98
cpu->isar.id_aa64pfr1 = t;
99
100
t = cpu->isar.id_aa64mmfr0;
101
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
102
cpu->isar.id_aa64mmfr0 = t;
103
104
t = cpu->isar.id_aa64mmfr1;
105
- t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* HPD */
106
- t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1);
107
- t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1);
108
- t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */
109
- t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */
110
- t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* TTS2UXN */
111
+ t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */
112
+ t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */
113
+ t = FIELD_DP64(t, ID_AA64MMFR1, HPDS, 1); /* FEAT_HPDS */
114
+ t = FIELD_DP64(t, ID_AA64MMFR1, LO, 1); /* FEAT_LOR */
115
+ t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* FEAT_PAN2 */
116
+ t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */
117
cpu->isar.id_aa64mmfr1 = t;
118
119
t = cpu->isar.id_aa64mmfr2;
120
- t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1);
121
- t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* TTCNP */
122
- t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* TTST */
123
- t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */
124
- t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */
125
- t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */
126
+ t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* FEAT_TTCNP */
127
+ t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); /* FEAT_UAO */
128
+ t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */
129
+ t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* FEAT_TTST */
130
+ t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */
131
+ t = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */
132
cpu->isar.id_aa64mmfr2 = t;
133
134
t = cpu->isar.id_aa64zfr0;
135
t = FIELD_DP64(t, ID_AA64ZFR0, SVEVER, 1);
136
- t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* PMULL */
137
- t = FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1);
138
- t = FIELD_DP64(t, ID_AA64ZFR0, BFLOAT16, 1);
139
- t = FIELD_DP64(t, ID_AA64ZFR0, SHA3, 1);
140
- t = FIELD_DP64(t, ID_AA64ZFR0, SM4, 1);
141
- t = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1);
142
- t = FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1);
143
- t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1);
144
+ t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* FEAT_SVE_PMULL128 */
145
+ t = FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1); /* FEAT_SVE_BitPerm */
146
+ t = FIELD_DP64(t, ID_AA64ZFR0, BFLOAT16, 1); /* FEAT_BF16 */
147
+ t = FIELD_DP64(t, ID_AA64ZFR0, SHA3, 1); /* FEAT_SVE_SHA3 */
148
+ t = FIELD_DP64(t, ID_AA64ZFR0, SM4, 1); /* FEAT_SVE_SM4 */
149
+ t = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1); /* FEAT_I8MM */
150
+ t = FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1); /* FEAT_F32MM */
151
+ t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); /* FEAT_F64MM */
152
cpu->isar.id_aa64zfr0 = t;
153
154
t = cpu->isar.id_aa64dfr0;
155
- t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */
156
+ t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */
157
cpu->isar.id_aa64dfr0 = t;
158
159
/* Replicate the same data to the 32-bit id registers. */
160
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
161
index XXXXXXX..XXXXXXX 100644
162
--- a/target/arm/cpu_tcg.c
163
+++ b/target/arm/cpu_tcg.c
164
@@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu)
165
166
/* Add additional features supported by QEMU */
167
t = cpu->isar.id_isar5;
168
- t = FIELD_DP32(t, ID_ISAR5, AES, 2);
169
- t = FIELD_DP32(t, ID_ISAR5, SHA1, 1);
170
- t = FIELD_DP32(t, ID_ISAR5, SHA2, 1);
171
+ t = FIELD_DP32(t, ID_ISAR5, AES, 2); /* FEAT_PMULL */
172
+ t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); /* FEAT_SHA1 */
173
+ t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); /* FEAT_SHA256 */
174
t = FIELD_DP32(t, ID_ISAR5, CRC32, 1);
175
- t = FIELD_DP32(t, ID_ISAR5, RDM, 1);
176
- t = FIELD_DP32(t, ID_ISAR5, VCMA, 1);
177
+ t = FIELD_DP32(t, ID_ISAR5, RDM, 1); /* FEAT_RDM */
178
+ t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); /* FEAT_FCMA */
179
cpu->isar.id_isar5 = t;
180
181
t = cpu->isar.id_isar6;
182
- t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1);
183
- t = FIELD_DP32(t, ID_ISAR6, DP, 1);
184
- t = FIELD_DP32(t, ID_ISAR6, FHM, 1);
185
- t = FIELD_DP32(t, ID_ISAR6, SB, 1);
186
- t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1);
187
- t = FIELD_DP32(t, ID_ISAR6, BF16, 1);
188
- t = FIELD_DP32(t, ID_ISAR6, I8MM, 1);
189
+ t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); /* FEAT_JSCVT */
190
+ t = FIELD_DP32(t, ID_ISAR6, DP, 1); /* Feat_DotProd */
191
+ t = FIELD_DP32(t, ID_ISAR6, FHM, 1); /* FEAT_FHM */
192
+ t = FIELD_DP32(t, ID_ISAR6, SB, 1); /* FEAT_SB */
193
+ t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); /* FEAT_SPECRES */
194
+ t = FIELD_DP32(t, ID_ISAR6, BF16, 1); /* FEAT_AA32BF16 */
195
+ t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); /* FEAT_AA32I8MM */
196
cpu->isar.id_isar6 = t;
197
198
t = cpu->isar.mvfr1;
199
- t = FIELD_DP32(t, MVFR1, FPHP, 3); /* v8.2-FP16 */
200
- t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* v8.2-FP16 */
201
+ t = FIELD_DP32(t, MVFR1, FPHP, 3); /* FEAT_FP16 */
202
+ t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* FEAT_FP16 */
203
cpu->isar.mvfr1 = t;
204
205
t = cpu->isar.mvfr2;
206
- t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */
207
- t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */
208
+ t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */
209
+ t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */
210
cpu->isar.mvfr2 = t;
211
212
t = cpu->isar.id_mmfr3;
213
- t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* ATS1E1 */
214
+ t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* FEAT_PAN2 */
215
cpu->isar.id_mmfr3 = t;
216
217
t = cpu->isar.id_mmfr4;
218
- t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */
219
- t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
220
- t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */
221
- t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */
222
+ t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* FEAT_AA32HPD */
223
+ t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
224
+ t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */
225
+ t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX*/
226
cpu->isar.id_mmfr4 = t;
227
228
t = cpu->isar.id_pfr0;
229
- t = FIELD_DP32(t, ID_PFR0, DIT, 1);
230
+ t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */
231
cpu->isar.id_pfr0 = t;
232
233
t = cpu->isar.id_pfr2;
234
- t = FIELD_DP32(t, ID_PFR2, SSBS, 1);
235
+ t = FIELD_DP32(t, ID_PFR2, SSBS, 1); /* FEAT_SSBS */
236
cpu->isar.id_pfr2 = t;
237
238
t = cpu->isar.id_dfr0;
239
- t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* v8.4-PMU */
240
+ t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* FEAT_PMUv3p4 */
241
cpu->isar.id_dfr0 = t;
16
}
242
}
17
243
18
-static void omap_synctimer_write(void *opaque, hwaddr addr,
19
- uint32_t value)
20
+static uint64_t omap_synctimer_readfn(void *opaque, hwaddr addr,
21
+ unsigned size)
22
+{
23
+ switch (size) {
24
+ case 1:
25
+ return omap_badwidth_read32(opaque, addr);
26
+ case 2:
27
+ return omap_synctimer_readh(opaque, addr);
28
+ case 4:
29
+ return omap_synctimer_readw(opaque, addr);
30
+ default:
31
+ g_assert_not_reached();
32
+ }
33
+}
34
+
35
+static void omap_synctimer_writefn(void *opaque, hwaddr addr,
36
+ uint64_t value, unsigned size)
37
{
38
OMAP_BAD_REG(addr);
39
}
40
41
static const MemoryRegionOps omap_synctimer_ops = {
42
- .old_mmio = {
43
- .read = {
44
- omap_badwidth_read32,
45
- omap_synctimer_readh,
46
- omap_synctimer_readw,
47
- },
48
- .write = {
49
- omap_badwidth_write32,
50
- omap_synctimer_write,
51
- omap_synctimer_write,
52
- },
53
- },
54
+ .read = omap_synctimer_readfn,
55
+ .write = omap_synctimer_writefn,
56
+ .valid.min_access_size = 1,
57
+ .valid.max_access_size = 4,
58
.endianness = DEVICE_NATIVE_ENDIAN,
59
};
60
61
--
244
--
62
2.7.4
245
2.25.1
63
64
diff view generated by jsdifflib
1
If AIRCR.BFHFNMINS is clear, then although NonSecure HardFault
1
From: Richard Henderson <richard.henderson@linaro.org>
2
can still be pended via SHCSR.HARDFAULTPENDED it mustn't actually
3
preempt execution. The simple way to achieve this is to clear the
4
enable bit for it, since the enable bit isn't guest visible.
5
2
3
Use FIELD_DP{32,64} to manipulate id_pfr1 and id_aa64pfr0
4
during arm_cpu_realizefn.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220506180242.216785-11-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: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 1505240046-11454-15-git-send-email-peter.maydell@linaro.org
9
---
10
---
10
hw/intc/armv7m_nvic.c | 12 ++++++++++--
11
target/arm/cpu.c | 22 +++++++++++++---------
11
1 file changed, 10 insertions(+), 2 deletions(-)
12
1 file changed, 13 insertions(+), 9 deletions(-)
12
13
13
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
14
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/intc/armv7m_nvic.c
16
--- a/target/arm/cpu.c
16
+++ b/hw/intc/armv7m_nvic.c
17
+++ b/target/arm/cpu.c
17
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
18
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
18
(R_V7M_AIRCR_SYSRESETREQS_MASK |
19
*/
19
R_V7M_AIRCR_BFHFNMINS_MASK |
20
unset_feature(env, ARM_FEATURE_EL3);
20
R_V7M_AIRCR_PRIS_MASK);
21
21
- /* BFHFNMINS changes the priority of Secure HardFault */
22
- /* Disable the security extension feature bits in the processor feature
22
+ /* BFHFNMINS changes the priority of Secure HardFault, and
23
- * registers as well. These are id_pfr1[7:4] and id_aa64pfr0[15:12].
23
+ * allows a pending Non-secure HardFault to preempt (which
24
+ /*
24
+ * we implement by marking it enabled).
25
+ * Disable the security extension feature bits in the processor
25
+ */
26
+ * feature registers as well.
26
if (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
27
*/
27
s->sec_vectors[ARMV7M_EXCP_HARD].prio = -3;
28
- cpu->isar.id_pfr1 &= ~0xf0;
28
+ s->vectors[ARMV7M_EXCP_HARD].enabled = 1;
29
- cpu->isar.id_aa64pfr0 &= ~0xf000;
29
} else {
30
+ cpu->isar.id_pfr1 = FIELD_DP32(cpu->isar.id_pfr1, ID_PFR1, SECURITY, 0);
30
s->sec_vectors[ARMV7M_EXCP_HARD].prio = -1;
31
+ cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0,
31
+ s->vectors[ARMV7M_EXCP_HARD].enabled = 0;
32
+ ID_AA64PFR0, EL3, 0);
32
}
33
}
34
nvic_irq_update(s);
35
@@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_reset(DeviceState *dev)
36
NVICState *s = NVIC(dev);
37
38
s->vectors[ARMV7M_EXCP_NMI].enabled = 1;
39
- s->vectors[ARMV7M_EXCP_HARD].enabled = 1;
40
/* MEM, BUS, and USAGE are enabled through
41
* the System Handler Control register
42
*/
43
@@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_reset(DeviceState *dev)
44
45
/* AIRCR.BFHFNMINS resets to 0 so Secure HF is priority -1 (R_CMTC) */
46
s->sec_vectors[ARMV7M_EXCP_HARD].prio = -1;
47
+ /* If AIRCR.BFHFNMINS is 0 then NS HF is (effectively) disabled */
48
+ s->vectors[ARMV7M_EXCP_HARD].enabled = 0;
49
+ } else {
50
+ s->vectors[ARMV7M_EXCP_HARD].enabled = 1;
51
}
33
}
52
34
53
/* Strictly speaking the reset handler should be enabled.
35
if (!cpu->has_el2) {
36
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
37
}
38
39
if (!arm_feature(env, ARM_FEATURE_EL2)) {
40
- /* Disable the hypervisor feature bits in the processor feature
41
- * registers if we don't have EL2. These are id_pfr1[15:12] and
42
- * id_aa64pfr0_el1[11:8].
43
+ /*
44
+ * Disable the hypervisor feature bits in the processor feature
45
+ * registers if we don't have EL2.
46
*/
47
- cpu->isar.id_aa64pfr0 &= ~0xf00;
48
- cpu->isar.id_pfr1 &= ~0xf000;
49
+ cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0,
50
+ ID_AA64PFR0, EL2, 0);
51
+ cpu->isar.id_pfr1 = FIELD_DP32(cpu->isar.id_pfr1,
52
+ ID_PFR1, VIRTUALIZATION, 0);
53
}
54
55
#ifndef CONFIG_USER_ONLY
54
--
56
--
55
2.7.4
57
2.25.1
56
57
diff view generated by jsdifflib
1
The Application Interrupt and Reset Control Register has some changes
1
From: Richard Henderson <richard.henderson@linaro.org>
2
for v8M:
3
* new bits SYSRESETREQS, BFHFNMINS and PRIS: these all have
4
real state if the security extension is implemented and otherwise
5
are constant
6
* the PRIGROUP field is banked between security states
7
* non-secure code can be blocked from using the SYSRESET bit
8
to reset the system if SYSRESETREQS is set
9
2
10
Implement the new state and the changes to register read and write.
3
The only portion of FEAT_Debugv8p2 that is relevant to QEMU
11
For the moment we ignore the effects of the secure PRIGROUP.
4
is CONTEXTIDR_EL2, which is also conditionally implemented
12
We will implement the effects of PRIS and BFHFNMIS later.
5
with FEAT_VHE. The rest of the debug extension concerns the
6
External debug interface, which is outside the scope of QEMU.
13
7
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20220506180242.216785-12-richard.henderson@linaro.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Message-id: 1505240046-11454-6-git-send-email-peter.maydell@linaro.org
17
---
12
---
18
include/hw/intc/armv7m_nvic.h | 3 ++-
13
docs/system/arm/emulation.rst | 1 +
19
target/arm/cpu.h | 12 +++++++++++
14
target/arm/cpu.c | 1 +
20
hw/intc/armv7m_nvic.c | 49 +++++++++++++++++++++++++++++++++----------
15
target/arm/cpu64.c | 1 +
21
target/arm/cpu.c | 7 +++++++
16
target/arm/cpu_tcg.c | 2 ++
22
4 files changed, 59 insertions(+), 12 deletions(-)
17
4 files changed, 5 insertions(+)
23
18
24
diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h
19
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
25
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/intc/armv7m_nvic.h
21
--- a/docs/system/arm/emulation.rst
27
+++ b/include/hw/intc/armv7m_nvic.h
22
+++ b/docs/system/arm/emulation.rst
28
@@ -XXX,XX +XXX,XX @@ typedef struct NVICState {
23
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
29
* Entries in sec_vectors[] for non-banked exception numbers are unused.
24
- FEAT_BTI (Branch Target Identification)
30
*/
25
- FEAT_DIT (Data Independent Timing instructions)
31
VecInfo sec_vectors[NVIC_INTERNAL_VECTORS];
26
- FEAT_DPB (DC CVAP instruction)
32
- uint32_t prigroup;
27
+- FEAT_Debugv8p2 (Debug changes for v8.2)
33
+ /* The PRIGROUP field in AIRCR is banked */
28
- FEAT_DotProd (Advanced SIMD dot product instructions)
34
+ uint32_t prigroup[M_REG_NUM_BANKS];
29
- FEAT_FCMA (Floating-point complex number instructions)
35
30
- FEAT_FHM (Floating-point half-precision multiplication instructions)
36
/* The following fields are all cached state that can be recalculated
37
* from the vectors[] and sec_vectors[] arrays and the prigroup field:
38
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
39
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/cpu.h
41
+++ b/target/arm/cpu.h
42
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
43
int exception;
44
uint32_t primask[M_REG_NUM_BANKS];
45
uint32_t faultmask[M_REG_NUM_BANKS];
46
+ uint32_t aircr; /* only holds r/w state if security extn implemented */
47
uint32_t secure; /* Is CPU in Secure state? (not guest visible) */
48
} v7m;
49
50
@@ -XXX,XX +XXX,XX @@ FIELD(V7M_CCR, STKALIGN, 9, 1)
51
FIELD(V7M_CCR, DC, 16, 1)
52
FIELD(V7M_CCR, IC, 17, 1)
53
54
+/* V7M AIRCR bits */
55
+FIELD(V7M_AIRCR, VECTRESET, 0, 1)
56
+FIELD(V7M_AIRCR, VECTCLRACTIVE, 1, 1)
57
+FIELD(V7M_AIRCR, SYSRESETREQ, 2, 1)
58
+FIELD(V7M_AIRCR, SYSRESETREQS, 3, 1)
59
+FIELD(V7M_AIRCR, PRIGROUP, 8, 3)
60
+FIELD(V7M_AIRCR, BFHFNMINS, 13, 1)
61
+FIELD(V7M_AIRCR, PRIS, 14, 1)
62
+FIELD(V7M_AIRCR, ENDIANNESS, 15, 1)
63
+FIELD(V7M_AIRCR, VECTKEY, 16, 16)
64
+
65
/* V7M CFSR bits for MMFSR */
66
FIELD(V7M_CFSR, IACCVIOL, 0, 1)
67
FIELD(V7M_CFSR, DACCVIOL, 1, 1)
68
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
69
index XXXXXXX..XXXXXXX 100644
70
--- a/hw/intc/armv7m_nvic.c
71
+++ b/hw/intc/armv7m_nvic.c
72
@@ -XXX,XX +XXX,XX @@ static bool nvic_isrpending(NVICState *s)
73
*/
74
static inline uint32_t nvic_gprio_mask(NVICState *s)
75
{
76
- return ~0U << (s->prigroup + 1);
77
+ return ~0U << (s->prigroup[M_REG_NS] + 1);
78
}
79
80
/* Recompute vectpending and exception_prio */
81
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
82
return val;
83
case 0xd08: /* Vector Table Offset. */
84
return cpu->env.v7m.vecbase[attrs.secure];
85
- case 0xd0c: /* Application Interrupt/Reset Control. */
86
- return 0xfa050000 | (s->prigroup << 8);
87
+ case 0xd0c: /* Application Interrupt/Reset Control (AIRCR) */
88
+ val = 0xfa050000 | (s->prigroup[attrs.secure] << 8);
89
+ if (attrs.secure) {
90
+ /* s->aircr stores PRIS, BFHFNMINS, SYSRESETREQS */
91
+ val |= cpu->env.v7m.aircr;
92
+ } else {
93
+ if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
94
+ /* BFHFNMINS is R/O from NS; other bits are RAZ/WI. If
95
+ * security isn't supported then BFHFNMINS is RAO (and
96
+ * the bit in env.v7m.aircr is always set).
97
+ */
98
+ val |= cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK;
99
+ }
100
+ }
101
+ return val;
102
case 0xd10: /* System Control. */
103
/* TODO: Implement SLEEPONEXIT. */
104
return 0;
105
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
106
case 0xd08: /* Vector Table Offset. */
107
cpu->env.v7m.vecbase[attrs.secure] = value & 0xffffff80;
108
break;
109
- case 0xd0c: /* Application Interrupt/Reset Control. */
110
- if ((value >> 16) == 0x05fa) {
111
- if (value & 4) {
112
- qemu_irq_pulse(s->sysresetreq);
113
+ case 0xd0c: /* Application Interrupt/Reset Control (AIRCR) */
114
+ if ((value >> R_V7M_AIRCR_VECTKEY_SHIFT) == 0x05fa) {
115
+ if (value & R_V7M_AIRCR_SYSRESETREQ_MASK) {
116
+ if (attrs.secure ||
117
+ !(cpu->env.v7m.aircr & R_V7M_AIRCR_SYSRESETREQS_MASK)) {
118
+ qemu_irq_pulse(s->sysresetreq);
119
+ }
120
}
121
- if (value & 2) {
122
+ if (value & R_V7M_AIRCR_VECTCLRACTIVE_MASK) {
123
qemu_log_mask(LOG_GUEST_ERROR,
124
"Setting VECTCLRACTIVE when not in DEBUG mode "
125
"is UNPREDICTABLE\n");
126
}
127
- if (value & 1) {
128
+ if (value & R_V7M_AIRCR_VECTRESET_MASK) {
129
+ /* NB: this bit is RES0 in v8M */
130
qemu_log_mask(LOG_GUEST_ERROR,
131
"Setting VECTRESET when not in DEBUG mode "
132
"is UNPREDICTABLE\n");
133
}
134
- s->prigroup = extract32(value, 8, 3);
135
+ s->prigroup[attrs.secure] = extract32(value,
136
+ R_V7M_AIRCR_PRIGROUP_SHIFT,
137
+ R_V7M_AIRCR_PRIGROUP_LENGTH);
138
+ if (attrs.secure) {
139
+ /* These bits are only writable by secure */
140
+ cpu->env.v7m.aircr = value &
141
+ (R_V7M_AIRCR_SYSRESETREQS_MASK |
142
+ R_V7M_AIRCR_BFHFNMINS_MASK |
143
+ R_V7M_AIRCR_PRIS_MASK);
144
+ }
145
nvic_irq_update(s);
146
}
147
break;
148
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_nvic_security = {
149
.fields = (VMStateField[]) {
150
VMSTATE_STRUCT_ARRAY(sec_vectors, NVICState, NVIC_INTERNAL_VECTORS, 1,
151
vmstate_VecInfo, VecInfo),
152
+ VMSTATE_UINT32(prigroup[M_REG_S], NVICState),
153
VMSTATE_END_OF_LIST()
154
}
155
};
156
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_nvic = {
157
.fields = (VMStateField[]) {
158
VMSTATE_STRUCT_ARRAY(vectors, NVICState, NVIC_MAX_VECTORS, 1,
159
vmstate_VecInfo, VecInfo),
160
- VMSTATE_UINT32(prigroup, NVICState),
161
+ VMSTATE_UINT32(prigroup[M_REG_NS], NVICState),
162
VMSTATE_END_OF_LIST()
163
},
164
.subsections = (const VMStateDescription*[]) {
165
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
31
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
166
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
167
--- a/target/arm/cpu.c
33
--- a/target/arm/cpu.c
168
+++ b/target/arm/cpu.c
34
+++ b/target/arm/cpu.c
169
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s)
35
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
170
36
* feature registers as well.
171
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
37
*/
172
env->v7m.secure = true;
38
cpu->isar.id_pfr1 = FIELD_DP32(cpu->isar.id_pfr1, ID_PFR1, SECURITY, 0);
173
+ } else {
39
+ cpu->isar.id_dfr0 = FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, COPSDBG, 0);
174
+ /* This bit resets to 0 if security is supported, but 1 if
40
cpu->isar.id_aa64pfr0 = FIELD_DP64(cpu->isar.id_aa64pfr0,
175
+ * it is not. The bit is not present in v7M, but we set it
41
ID_AA64PFR0, EL3, 0);
176
+ * here so we can avoid having to make checks on it conditional
42
}
177
+ * on ARM_FEATURE_V8 (we don't let the guest see the bit).
43
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
178
+ */
44
index XXXXXXX..XXXXXXX 100644
179
+ env->v7m.aircr = R_V7M_AIRCR_BFHFNMINS_MASK;
45
--- a/target/arm/cpu64.c
180
}
46
+++ b/target/arm/cpu64.c
181
47
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
182
/* In v7M the reset value of this bit is IMPDEF, but ARM recommends
48
cpu->isar.id_aa64zfr0 = t;
49
50
t = cpu->isar.id_aa64dfr0;
51
+ t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 8); /* FEAT_Debugv8p2 */
52
t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */
53
cpu->isar.id_aa64dfr0 = t;
54
55
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/target/arm/cpu_tcg.c
58
+++ b/target/arm/cpu_tcg.c
59
@@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu)
60
cpu->isar.id_pfr2 = t;
61
62
t = cpu->isar.id_dfr0;
63
+ t = FIELD_DP32(t, ID_DFR0, COPDBG, 8); /* FEAT_Debugv8p2 */
64
+ t = FIELD_DP32(t, ID_DFR0, COPSDBG, 8); /* FEAT_Debugv8p2 */
65
t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* FEAT_PMUv3p4 */
66
cpu->isar.id_dfr0 = t;
67
}
183
--
68
--
184
2.7.4
69
2.25.1
185
186
diff view generated by jsdifflib
1
Update the static_ops functions to use new-style mmio
1
From: Richard Henderson <richard.henderson@linaro.org>
2
rather than the legacy old_mmio functions.
3
2
3
This extension concerns changes to the External Debug interface,
4
with Secure and Non-secure access to the debug registers, and all
5
of it is outside the scope of QEMU. Indicating support for this
6
is mandatory with FEAT_SEL2, which we do implement.
7
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20220506180242.216785-13-richard.henderson@linaro.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 1505580378-9044-2-git-send-email-peter.maydell@linaro.org
7
---
12
---
8
hw/arm/palm.c | 30 ++++++++++--------------------
13
docs/system/arm/emulation.rst | 1 +
9
1 file changed, 10 insertions(+), 20 deletions(-)
14
target/arm/cpu64.c | 2 +-
15
target/arm/cpu_tcg.c | 4 ++--
16
3 files changed, 4 insertions(+), 3 deletions(-)
10
17
11
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
18
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
12
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/arm/palm.c
20
--- a/docs/system/arm/emulation.rst
14
+++ b/hw/arm/palm.c
21
+++ b/docs/system/arm/emulation.rst
15
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
16
#include "exec/address-spaces.h"
23
- FEAT_DIT (Data Independent Timing instructions)
17
#include "cpu.h"
24
- FEAT_DPB (DC CVAP instruction)
18
25
- FEAT_Debugv8p2 (Debug changes for v8.2)
19
-static uint32_t static_readb(void *opaque, hwaddr offset)
26
+- FEAT_Debugv8p4 (Debug changes for v8.4)
20
+static uint64_t static_read(void *opaque, hwaddr offset, unsigned size)
27
- FEAT_DotProd (Advanced SIMD dot product instructions)
21
{
28
- FEAT_FCMA (Floating-point complex number instructions)
22
- uint32_t *val = (uint32_t *) opaque;
29
- FEAT_FHM (Floating-point half-precision multiplication instructions)
23
- return *val >> ((offset & 3) << 3);
30
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
24
-}
31
index XXXXXXX..XXXXXXX 100644
25
+ uint32_t *val = (uint32_t *)opaque;
32
--- a/target/arm/cpu64.c
26
+ uint32_t sizemask = 7 >> size;
33
+++ b/target/arm/cpu64.c
27
34
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
28
-static uint32_t static_readh(void *opaque, hwaddr offset)
35
cpu->isar.id_aa64zfr0 = t;
29
-{
36
30
- uint32_t *val = (uint32_t *) opaque;
37
t = cpu->isar.id_aa64dfr0;
31
- return *val >> ((offset & 1) << 3);
38
- t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 8); /* FEAT_Debugv8p2 */
32
-}
39
+ t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */
33
-
40
t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* FEAT_PMUv3p4 */
34
-static uint32_t static_readw(void *opaque, hwaddr offset)
41
cpu->isar.id_aa64dfr0 = t;
35
-{
42
36
- uint32_t *val = (uint32_t *) opaque;
43
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
37
- return *val >> ((offset & 0) << 3);
44
index XXXXXXX..XXXXXXX 100644
38
+ return *val >> ((offset & sizemask) << 3);
45
--- a/target/arm/cpu_tcg.c
46
+++ b/target/arm/cpu_tcg.c
47
@@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu)
48
cpu->isar.id_pfr2 = t;
49
50
t = cpu->isar.id_dfr0;
51
- t = FIELD_DP32(t, ID_DFR0, COPDBG, 8); /* FEAT_Debugv8p2 */
52
- t = FIELD_DP32(t, ID_DFR0, COPSDBG, 8); /* FEAT_Debugv8p2 */
53
+ t = FIELD_DP32(t, ID_DFR0, COPDBG, 9); /* FEAT_Debugv8p4 */
54
+ t = FIELD_DP32(t, ID_DFR0, COPSDBG, 9); /* FEAT_Debugv8p4 */
55
t = FIELD_DP32(t, ID_DFR0, PERFMON, 5); /* FEAT_PMUv3p4 */
56
cpu->isar.id_dfr0 = t;
39
}
57
}
40
41
-static void static_write(void *opaque, hwaddr offset,
42
- uint32_t value)
43
+static void static_write(void *opaque, hwaddr offset, uint64_t value,
44
+ unsigned size)
45
{
46
#ifdef SPY
47
printf("%s: value %08lx written at " PA_FMT "\n",
48
@@ -XXX,XX +XXX,XX @@ static void static_write(void *opaque, hwaddr offset,
49
}
50
51
static const MemoryRegionOps static_ops = {
52
- .old_mmio = {
53
- .read = { static_readb, static_readh, static_readw, },
54
- .write = { static_write, static_write, static_write, },
55
- },
56
+ .read = static_read,
57
+ .write = static_write,
58
+ .valid.min_access_size = 1,
59
+ .valid.max_access_size = 4,
60
.endianness = DEVICE_NATIVE_ENDIAN,
61
};
62
63
--
58
--
64
2.7.4
59
2.25.1
65
66
diff view generated by jsdifflib
1
Make the armv7m_nvic_set_pending() and armv7m_nvic_clear_pending()
1
From: Richard Henderson <richard.henderson@linaro.org>
2
functions take a bool indicating whether to pend the secure
3
or non-secure version of a banked interrupt, and update the
4
callsites accordingly.
5
2
6
In most callsites we can simply pass the correct security
3
Add only the system registers required to implement zero error
7
state in; in a couple of cases we use TODO comments to indicate
4
records. This means that all values for ERRSELR are out of range,
8
that we will return the code in a subsequent commit.
5
which means that it and all of the indexed error record registers
6
need not be implemented.
9
7
8
Add the EL2 registers required for injecting virtual SError.
9
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20220506180242.216785-14-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 1505240046-11454-10-git-send-email-peter.maydell@linaro.org
13
---
14
---
14
target/arm/cpu.h | 14 ++++++++++-
15
target/arm/cpu.h | 5 +++
15
hw/intc/armv7m_nvic.c | 64 ++++++++++++++++++++++++++++++++++++++-------------
16
target/arm/helper.c | 84 +++++++++++++++++++++++++++++++++++++++++++++
16
target/arm/helper.c | 24 +++++++++++--------
17
2 files changed, 89 insertions(+)
17
hw/intc/trace-events | 4 ++--
18
4 files changed, 77 insertions(+), 29 deletions(-)
19
18
20
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
19
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/cpu.h
21
--- a/target/arm/cpu.h
23
+++ b/target/arm/cpu.h
22
+++ b/target/arm/cpu.h
24
@@ -XXX,XX +XXX,XX @@ static inline bool armv7m_nvic_can_take_pending_exception(void *opaque)
23
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
25
return true;
24
uint64_t tfsr_el[4]; /* tfsre0_el1 is index 0. */
26
}
25
uint64_t gcr_el1;
27
#endif
26
uint64_t rgsr_el1;
28
-void armv7m_nvic_set_pending(void *opaque, int irq);
27
+
29
+/**
28
+ /* Minimal RAS registers */
30
+ * armv7m_nvic_set_pending: mark the specified exception as pending
29
+ uint64_t disr_el1;
31
+ * @opaque: the NVIC
30
+ uint64_t vdisr_el2;
32
+ * @irq: the exception number to mark pending
31
+ uint64_t vsesr_el2;
33
+ * @secure: false for non-banked exceptions or for the nonsecure
32
} cp15;
34
+ * version of a banked exception, true for the secure version of a banked
33
35
+ * exception.
34
struct {
36
+ *
37
+ * Marks the specified exception as pending. Note that we will assert()
38
+ * if @secure is true and @irq does not specify one of the fixed set
39
+ * of architecturally banked exceptions.
40
+ */
41
+void armv7m_nvic_set_pending(void *opaque, int irq, bool secure);
42
void armv7m_nvic_acknowledge_irq(void *opaque);
43
/**
44
* armv7m_nvic_complete_irq: complete specified interrupt or exception
45
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/intc/armv7m_nvic.c
48
+++ b/hw/intc/armv7m_nvic.c
49
@@ -XXX,XX +XXX,XX @@ static void nvic_irq_update(NVICState *s)
50
qemu_set_irq(s->excpout, lvl);
51
}
52
53
-static void armv7m_nvic_clear_pending(void *opaque, int irq)
54
+/**
55
+ * armv7m_nvic_clear_pending: mark the specified exception as not pending
56
+ * @opaque: the NVIC
57
+ * @irq: the exception number to mark as not pending
58
+ * @secure: false for non-banked exceptions or for the nonsecure
59
+ * version of a banked exception, true for the secure version of a banked
60
+ * exception.
61
+ *
62
+ * Marks the specified exception as not pending. Note that we will assert()
63
+ * if @secure is true and @irq does not specify one of the fixed set
64
+ * of architecturally banked exceptions.
65
+ */
66
+static void armv7m_nvic_clear_pending(void *opaque, int irq, bool secure)
67
{
68
NVICState *s = (NVICState *)opaque;
69
VecInfo *vec;
70
71
assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
72
73
- vec = &s->vectors[irq];
74
- trace_nvic_clear_pending(irq, vec->enabled, vec->prio);
75
+ if (secure) {
76
+ assert(exc_is_banked(irq));
77
+ vec = &s->sec_vectors[irq];
78
+ } else {
79
+ vec = &s->vectors[irq];
80
+ }
81
+ trace_nvic_clear_pending(irq, secure, vec->enabled, vec->prio);
82
if (vec->pending) {
83
vec->pending = 0;
84
nvic_irq_update(s);
85
}
86
}
87
88
-void armv7m_nvic_set_pending(void *opaque, int irq)
89
+void armv7m_nvic_set_pending(void *opaque, int irq, bool secure)
90
{
91
NVICState *s = (NVICState *)opaque;
92
+ bool banked = exc_is_banked(irq);
93
VecInfo *vec;
94
95
assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
96
+ assert(!secure || banked);
97
98
- vec = &s->vectors[irq];
99
- trace_nvic_set_pending(irq, vec->enabled, vec->prio);
100
+ vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq];
101
102
+ trace_nvic_set_pending(irq, secure, vec->enabled, vec->prio);
103
104
if (irq >= ARMV7M_EXCP_HARD && irq < ARMV7M_EXCP_PENDSV) {
105
/* If a synchronous exception is pending then it may be
106
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq)
107
"(current priority %d)\n", irq, running);
108
}
109
110
- /* We can do the escalation, so we take HardFault instead */
111
+ /* We can do the escalation, so we take HardFault instead.
112
+ * If BFHFNMINS is set then we escalate to the banked HF for
113
+ * the target security state of the original exception; otherwise
114
+ * we take a Secure HardFault.
115
+ */
116
irq = ARMV7M_EXCP_HARD;
117
- vec = &s->vectors[irq];
118
+ if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) &&
119
+ (secure ||
120
+ !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK))) {
121
+ vec = &s->sec_vectors[irq];
122
+ } else {
123
+ vec = &s->vectors[irq];
124
+ }
125
+ /* HF may be banked but there is only one shared HFSR */
126
s->cpu->env.v7m.hfsr |= R_V7M_HFSR_FORCED_MASK;
127
}
128
}
129
@@ -XXX,XX +XXX,XX @@ static void set_irq_level(void *opaque, int n, int level)
130
if (level != vec->level) {
131
vec->level = level;
132
if (level) {
133
- armv7m_nvic_set_pending(s, n);
134
+ armv7m_nvic_set_pending(s, n, false);
135
}
136
}
137
}
138
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
139
}
140
case 0xd04: /* Interrupt Control State. */
141
if (value & (1 << 31)) {
142
- armv7m_nvic_set_pending(s, ARMV7M_EXCP_NMI);
143
+ armv7m_nvic_set_pending(s, ARMV7M_EXCP_NMI, false);
144
}
145
if (value & (1 << 28)) {
146
- armv7m_nvic_set_pending(s, ARMV7M_EXCP_PENDSV);
147
+ armv7m_nvic_set_pending(s, ARMV7M_EXCP_PENDSV, attrs.secure);
148
} else if (value & (1 << 27)) {
149
- armv7m_nvic_clear_pending(s, ARMV7M_EXCP_PENDSV);
150
+ armv7m_nvic_clear_pending(s, ARMV7M_EXCP_PENDSV, attrs.secure);
151
}
152
if (value & (1 << 26)) {
153
- armv7m_nvic_set_pending(s, ARMV7M_EXCP_SYSTICK);
154
+ armv7m_nvic_set_pending(s, ARMV7M_EXCP_SYSTICK, attrs.secure);
155
} else if (value & (1 << 25)) {
156
- armv7m_nvic_clear_pending(s, ARMV7M_EXCP_SYSTICK);
157
+ armv7m_nvic_clear_pending(s, ARMV7M_EXCP_SYSTICK, attrs.secure);
158
}
159
break;
160
case 0xd08: /* Vector Table Offset. */
161
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
162
{
163
int excnum = (value & 0x1ff) + NVIC_FIRST_IRQ;
164
if (excnum < s->num_irq) {
165
- armv7m_nvic_set_pending(s, excnum);
166
+ armv7m_nvic_set_pending(s, excnum, false);
167
}
168
break;
169
}
170
@@ -XXX,XX +XXX,XX @@ static void nvic_systick_trigger(void *opaque, int n, int level)
171
/* SysTick just asked us to pend its exception.
172
* (This is different from an external interrupt line's
173
* behaviour.)
174
+ * TODO: when we implement the banked systicks we must make
175
+ * this pend the correct banked exception.
176
*/
177
- armv7m_nvic_set_pending(s, ARMV7M_EXCP_SYSTICK);
178
+ armv7m_nvic_set_pending(s, ARMV7M_EXCP_SYSTICK, false);
179
}
180
}
181
182
diff --git a/target/arm/helper.c b/target/arm/helper.c
35
diff --git a/target/arm/helper.c b/target/arm/helper.c
183
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
184
--- a/target/arm/helper.c
37
--- a/target/arm/helper.c
185
+++ b/target/arm/helper.c
38
+++ b/target/arm/helper.c
186
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
39
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = {
187
* stack, directly take a usage fault on the current stack.
40
.access = PL0_R, .type = ARM_CP_CONST|ARM_CP_64BIT, .resetvalue = 0 },
188
*/
41
};
189
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK;
42
190
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);
43
+/*
191
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
44
+ * Check for traps to RAS registers, which are controlled
192
v7m_exception_taken(cpu, excret);
45
+ * by HCR_EL2.TERR and SCR_EL3.TERR.
193
qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing "
46
+ */
194
"stackframe: failed exception return integrity check\n");
47
+static CPAccessResult access_terr(CPUARMState *env, const ARMCPRegInfo *ri,
195
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
48
+ bool isread)
196
* exception return excret specified then this is a UsageFault.
49
+{
197
*/
50
+ int el = arm_current_el(env);
198
if (return_to_handler != arm_v7m_is_handler_mode(env)) {
51
+
199
- /* Take an INVPC UsageFault by pushing the stack again. */
52
+ if (el < 2 && (arm_hcr_el2_eff(env) & HCR_TERR)) {
200
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);
53
+ return CP_ACCESS_TRAP_EL2;
201
+ /* Take an INVPC UsageFault by pushing the stack again.
54
+ }
202
+ * TODO: the v8M version of this code should target the
55
+ if (el < 3 && (env->cp15.scr_el3 & SCR_TERR)) {
203
+ * background state for this exception.
56
+ return CP_ACCESS_TRAP_EL3;
204
+ */
57
+ }
205
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, false);
58
+ return CP_ACCESS_OK;
206
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVPC_MASK;
59
+}
207
v7m_push_stack(cpu);
60
+
208
v7m_exception_taken(cpu, excret);
61
+static uint64_t disr_read(CPUARMState *env, const ARMCPRegInfo *ri)
209
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
62
+{
210
handle it. */
63
+ int el = arm_current_el(env);
211
switch (cs->exception_index) {
64
+
212
case EXCP_UDEF:
65
+ if (el < 2 && (arm_hcr_el2_eff(env) & HCR_AMO)) {
213
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);
66
+ return env->cp15.vdisr_el2;
214
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
67
+ }
215
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK;
68
+ if (el < 3 && (env->cp15.scr_el3 & SCR_EA)) {
216
break;
69
+ return 0; /* RAZ/WI */
217
case EXCP_NOCP:
70
+ }
218
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);
71
+ return env->cp15.disr_el1;
219
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
72
+}
220
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;
73
+
221
break;
74
+static void disr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t val)
222
case EXCP_INVSTATE:
75
+{
223
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE);
76
+ int el = arm_current_el(env);
224
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
77
+
225
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK;
78
+ if (el < 2 && (arm_hcr_el2_eff(env) & HCR_AMO)) {
226
break;
79
+ env->cp15.vdisr_el2 = val;
227
case EXCP_SWI:
80
+ return;
228
/* The PC already points to the next instruction. */
81
+ }
229
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC);
82
+ if (el < 3 && (env->cp15.scr_el3 & SCR_EA)) {
230
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure);
83
+ return; /* RAZ/WI */
231
break;
84
+ }
232
case EXCP_PREFETCH_ABORT:
85
+ env->cp15.disr_el1 = val;
233
case EXCP_DATA_ABORT:
86
+}
234
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
87
+
235
env->v7m.bfar);
88
+/*
236
break;
89
+ * Minimal RAS implementation with no Error Records.
237
}
90
+ * Which means that all of the Error Record registers:
238
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS);
91
+ * ERXADDR_EL1
239
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false);
92
+ * ERXCTLR_EL1
240
break;
93
+ * ERXFR_EL1
241
default:
94
+ * ERXMISC0_EL1
242
/* All other FSR values are either MPU faults or "can't happen
95
+ * ERXMISC1_EL1
243
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
96
+ * ERXMISC2_EL1
244
env->v7m.mmfar[env->v7m.secure]);
97
+ * ERXMISC3_EL1
245
break;
98
+ * ERXPFGCDN_EL1 (RASv1p1)
246
}
99
+ * ERXPFGCTL_EL1 (RASv1p1)
247
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM);
100
+ * ERXPFGF_EL1 (RASv1p1)
248
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM,
101
+ * ERXSTATUS_EL1
249
+ env->v7m.secure);
102
+ * and
250
break;
103
+ * ERRSELR_EL1
251
}
104
+ * may generate UNDEFINED, which is the effect we get by not
252
break;
105
+ * listing them at all.
253
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
106
+ */
254
return;
107
+static const ARMCPRegInfo minimal_ras_reginfo[] = {
255
}
108
+ { .name = "DISR_EL1", .state = ARM_CP_STATE_BOTH,
256
}
109
+ .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 1, .opc2 = 1,
257
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG);
110
+ .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.disr_el1),
258
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false);
111
+ .readfn = disr_read, .writefn = disr_write, .raw_writefn = raw_write },
259
break;
112
+ { .name = "ERRIDR_EL1", .state = ARM_CP_STATE_BOTH,
260
case EXCP_IRQ:
113
+ .opc0 = 3, .opc1 = 0, .crn = 5, .crm = 3, .opc2 = 0,
261
break;
114
+ .access = PL1_R, .accessfn = access_terr,
262
diff --git a/hw/intc/trace-events b/hw/intc/trace-events
115
+ .type = ARM_CP_CONST, .resetvalue = 0 },
263
index XXXXXXX..XXXXXXX 100644
116
+ { .name = "VDISR_EL2", .state = ARM_CP_STATE_BOTH,
264
--- a/hw/intc/trace-events
117
+ .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 1, .opc2 = 1,
265
+++ b/hw/intc/trace-events
118
+ .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.vdisr_el2) },
266
@@ -XXX,XX +XXX,XX @@ nvic_set_prio(int irq, uint8_t prio) "NVIC set irq %d priority %d"
119
+ { .name = "VSESR_EL2", .state = ARM_CP_STATE_BOTH,
267
nvic_irq_update(int vectpending, int pendprio, int exception_prio, int level) "NVIC vectpending %d pending prio %d exception_prio %d: setting irq line to %d"
120
+ .opc0 = 3, .opc1 = 4, .crn = 5, .crm = 2, .opc2 = 3,
268
nvic_escalate_prio(int irq, int irqprio, int runprio) "NVIC escalating irq %d to HardFault: insufficient priority %d >= %d"
121
+ .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.vsesr_el2) },
269
nvic_escalate_disabled(int irq) "NVIC escalating irq %d to HardFault: disabled"
122
+};
270
-nvic_set_pending(int irq, int en, int prio) "NVIC set pending irq %d (enabled: %d priority %d)"
123
+
271
-nvic_clear_pending(int irq, int en, int prio) "NVIC clear pending irq %d (enabled: %d priority %d)"
124
/* Return the exception level to which exceptions should be taken
272
+nvic_set_pending(int irq, bool secure, int en, int prio) "NVIC set pending irq %d secure-bank %d (enabled: %d priority %d)"
125
* via SVEAccessTrap. If an exception should be routed through
273
+nvic_clear_pending(int irq, bool secure, int en, int prio) "NVIC clear pending irq %d secure-bank %d (enabled: %d priority %d)"
126
* AArch64.AdvSIMDFPAccessTrap, return 0; fp_exception_el should
274
nvic_set_pending_level(int irq) "NVIC set pending: irq %d higher prio than vectpending: setting irq line to 1"
127
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
275
nvic_acknowledge_irq(int irq, int prio) "NVIC acknowledge IRQ: %d now active (prio %d)"
128
if (cpu_isar_feature(aa64_ssbs, cpu)) {
276
nvic_complete_irq(int irq) "NVIC complete IRQ %d"
129
define_one_arm_cp_reg(cpu, &ssbs_reginfo);
130
}
131
+ if (cpu_isar_feature(any_ras, cpu)) {
132
+ define_arm_cp_regs(cpu, minimal_ras_reginfo);
133
+ }
134
135
if (cpu_isar_feature(aa64_vh, cpu) ||
136
cpu_isar_feature(aa64_debugv8p2, cpu)) {
277
--
137
--
278
2.7.4
138
2.25.1
279
280
diff view generated by jsdifflib
1
In v8M the MSR and MRS instructions have extra register value
1
From: Richard Henderson <richard.henderson@linaro.org>
2
encodings to allow secure code to access the non-secure banked
3
version of various special registers.
4
2
5
(We don't implement the MSPLIM_NS or PSPLIM_NS aliases, because
3
Enable writes to the TERR and TEA bits when RAS is enabled.
6
we don't currently implement the stack limit registers at all.)
4
These bits are otherwise RES0.
7
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220506180242.216785-15-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: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 1505240046-11454-2-git-send-email-peter.maydell@linaro.org
11
---
10
---
12
target/arm/helper.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++
11
target/arm/helper.c | 9 +++++++++
13
1 file changed, 110 insertions(+)
12
1 file changed, 9 insertions(+)
14
13
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
16
--- a/target/arm/helper.c
18
+++ b/target/arm/helper.c
17
+++ b/target/arm/helper.c
19
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
18
@@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
20
break;
19
}
21
case 20: /* CONTROL */
20
valid_mask &= ~SCR_NET;
22
return env->v7m.control[env->v7m.secure];
21
23
+ case 0x94: /* CONTROL_NS */
22
+ if (cpu_isar_feature(aa64_ras, cpu)) {
24
+ /* We have to handle this here because unprivileged Secure code
23
+ valid_mask |= SCR_TERR;
25
+ * can read the NS CONTROL register.
26
+ */
27
+ if (!env->v7m.secure) {
28
+ return 0;
29
+ }
24
+ }
30
+ return env->v7m.control[M_REG_NS];
25
if (cpu_isar_feature(aa64_lor, cpu)) {
26
valid_mask |= SCR_TLOR;
27
}
28
@@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
29
}
30
} else {
31
valid_mask &= ~(SCR_RW | SCR_ST);
32
+ if (cpu_isar_feature(aa32_ras, cpu)) {
33
+ valid_mask |= SCR_TERR;
34
+ }
31
}
35
}
32
36
33
if (el == 0) {
37
if (!arm_feature(env, ARM_FEATURE_EL2)) {
34
return 0; /* unprivileged reads others as zero */
38
@@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
35
}
39
if (cpu_isar_feature(aa64_vh, cpu)) {
36
40
valid_mask |= HCR_E2H;
37
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
41
}
38
+ switch (reg) {
42
+ if (cpu_isar_feature(aa64_ras, cpu)) {
39
+ case 0x88: /* MSP_NS */
43
+ valid_mask |= HCR_TERR | HCR_TEA;
40
+ if (!env->v7m.secure) {
41
+ return 0;
42
+ }
43
+ return env->v7m.other_ss_msp;
44
+ case 0x89: /* PSP_NS */
45
+ if (!env->v7m.secure) {
46
+ return 0;
47
+ }
48
+ return env->v7m.other_ss_psp;
49
+ case 0x90: /* PRIMASK_NS */
50
+ if (!env->v7m.secure) {
51
+ return 0;
52
+ }
53
+ return env->v7m.primask[M_REG_NS];
54
+ case 0x91: /* BASEPRI_NS */
55
+ if (!env->v7m.secure) {
56
+ return 0;
57
+ }
58
+ return env->v7m.basepri[M_REG_NS];
59
+ case 0x93: /* FAULTMASK_NS */
60
+ if (!env->v7m.secure) {
61
+ return 0;
62
+ }
63
+ return env->v7m.faultmask[M_REG_NS];
64
+ case 0x98: /* SP_NS */
65
+ {
66
+ /* This gives the non-secure SP selected based on whether we're
67
+ * currently in handler mode or not, using the NS CONTROL.SPSEL.
68
+ */
69
+ bool spsel = env->v7m.control[M_REG_NS] & R_V7M_CONTROL_SPSEL_MASK;
70
+
71
+ if (!env->v7m.secure) {
72
+ return 0;
73
+ }
74
+ if (!arm_v7m_is_handler_mode(env) && spsel) {
75
+ return env->v7m.other_ss_psp;
76
+ } else {
77
+ return env->v7m.other_ss_msp;
78
+ }
79
+ }
44
+ }
80
+ default:
45
if (cpu_isar_feature(aa64_lor, cpu)) {
81
+ break;
46
valid_mask |= HCR_TLOR;
82
+ }
47
}
83
+ }
84
+
85
switch (reg) {
86
case 8: /* MSP */
87
return (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) ?
88
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
89
return;
90
}
91
92
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
93
+ switch (reg) {
94
+ case 0x88: /* MSP_NS */
95
+ if (!env->v7m.secure) {
96
+ return;
97
+ }
98
+ env->v7m.other_ss_msp = val;
99
+ return;
100
+ case 0x89: /* PSP_NS */
101
+ if (!env->v7m.secure) {
102
+ return;
103
+ }
104
+ env->v7m.other_ss_psp = val;
105
+ return;
106
+ case 0x90: /* PRIMASK_NS */
107
+ if (!env->v7m.secure) {
108
+ return;
109
+ }
110
+ env->v7m.primask[M_REG_NS] = val & 1;
111
+ return;
112
+ case 0x91: /* BASEPRI_NS */
113
+ if (!env->v7m.secure) {
114
+ return;
115
+ }
116
+ env->v7m.basepri[M_REG_NS] = val & 0xff;
117
+ return;
118
+ case 0x93: /* FAULTMASK_NS */
119
+ if (!env->v7m.secure) {
120
+ return;
121
+ }
122
+ env->v7m.faultmask[M_REG_NS] = val & 1;
123
+ return;
124
+ case 0x98: /* SP_NS */
125
+ {
126
+ /* This gives the non-secure SP selected based on whether we're
127
+ * currently in handler mode or not, using the NS CONTROL.SPSEL.
128
+ */
129
+ bool spsel = env->v7m.control[M_REG_NS] & R_V7M_CONTROL_SPSEL_MASK;
130
+
131
+ if (!env->v7m.secure) {
132
+ return;
133
+ }
134
+ if (!arm_v7m_is_handler_mode(env) && spsel) {
135
+ env->v7m.other_ss_psp = val;
136
+ } else {
137
+ env->v7m.other_ss_msp = val;
138
+ }
139
+ return;
140
+ }
141
+ default:
142
+ break;
143
+ }
144
+ }
145
+
146
switch (reg) {
147
case 0 ... 7: /* xPSR sub-fields */
148
/* only APSR is actually writable */
149
--
48
--
150
2.7.4
49
2.25.1
151
152
diff view generated by jsdifflib
1
Update armv7m_nvic_acknowledge_irq() and armv7m_nvic_complete_irq()
1
From: Richard Henderson <richard.henderson@linaro.org>
2
to handle banked exceptions:
3
* acknowledge needs to use the correct vector, which may be
4
in sec_vectors[]
5
* acknowledge needs to return to its caller whether the
6
exception should be taken to secure or non-secure state
7
* complete needs its caller to tell it whether the exception
8
being completed is a secure one or not
9
2
3
Virtual SError exceptions are raised by setting HCR_EL2.VSE,
4
and are routed to EL1 just like other virtual exceptions.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220506180242.216785-16-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
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 1505240046-11454-20-git-send-email-peter.maydell@linaro.org
13
---
10
---
14
target/arm/cpu.h | 15 +++++++++++++--
11
target/arm/cpu.h | 2 ++
15
hw/intc/armv7m_nvic.c | 26 ++++++++++++++++++++------
12
target/arm/internals.h | 8 ++++++++
16
target/arm/helper.c | 8 +++++---
13
target/arm/syndrome.h | 5 +++++
17
hw/intc/trace-events | 4 ++--
14
target/arm/cpu.c | 38 +++++++++++++++++++++++++++++++++++++-
18
4 files changed, 40 insertions(+), 13 deletions(-)
15
target/arm/helper.c | 40 +++++++++++++++++++++++++++++++++++++++-
16
5 files changed, 91 insertions(+), 2 deletions(-)
19
17
20
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
18
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/cpu.h
20
--- a/target/arm/cpu.h
23
+++ b/target/arm/cpu.h
21
+++ b/target/arm/cpu.h
24
@@ -XXX,XX +XXX,XX @@ static inline bool armv7m_nvic_can_take_pending_exception(void *opaque)
22
@@ -XXX,XX +XXX,XX @@
25
* of architecturally banked exceptions.
23
#define EXCP_LSERR 21 /* v8M LSERR SecureFault */
24
#define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */
25
#define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */
26
+#define EXCP_VSERR 24
27
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
28
29
#define ARMV7M_EXCP_RESET 1
30
@@ -XXX,XX +XXX,XX @@ enum {
31
#define CPU_INTERRUPT_FIQ CPU_INTERRUPT_TGT_EXT_1
32
#define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_EXT_2
33
#define CPU_INTERRUPT_VFIQ CPU_INTERRUPT_TGT_EXT_3
34
+#define CPU_INTERRUPT_VSERR CPU_INTERRUPT_TGT_INT_0
35
36
/* The usual mapping for an AArch64 system register to its AArch32
37
* counterpart is for the 32 bit world to have access to the lower
38
diff --git a/target/arm/internals.h b/target/arm/internals.h
39
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/internals.h
41
+++ b/target/arm/internals.h
42
@@ -XXX,XX +XXX,XX @@ void arm_cpu_update_virq(ARMCPU *cpu);
26
*/
43
*/
27
void armv7m_nvic_set_pending(void *opaque, int irq, bool secure);
44
void arm_cpu_update_vfiq(ARMCPU *cpu);
28
-void armv7m_nvic_acknowledge_irq(void *opaque);
45
29
+/**
46
+/**
30
+ * armv7m_nvic_acknowledge_irq: make highest priority pending exception active
47
+ * arm_cpu_update_vserr: Update CPU_INTERRUPT_VSERR bit
31
+ * @opaque: the NVIC
32
+ *
48
+ *
33
+ * Move the current highest priority pending exception from the pending
49
+ * Update the CPU_INTERRUPT_VSERR bit in cs->interrupt_request,
34
+ * state to the active state, and update v7m.exception to indicate that
50
+ * following a change to the HCR_EL2.VSE bit.
35
+ * it is the exception currently being handled.
36
+ *
37
+ * Returns: true if exception should be taken to Secure state, false for NS
38
+ */
51
+ */
39
+bool armv7m_nvic_acknowledge_irq(void *opaque);
52
+void arm_cpu_update_vserr(ARMCPU *cpu);
53
+
40
/**
54
/**
41
* armv7m_nvic_complete_irq: complete specified interrupt or exception
55
* arm_mmu_idx_el:
42
* @opaque: the NVIC
56
* @env: The cpu environment
43
* @irq: the exception number to complete
57
diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h
44
+ * @secure: true if this exception was secure
58
index XXXXXXX..XXXXXXX 100644
45
*
59
--- a/target/arm/syndrome.h
46
* Returns: -1 if the irq was not active
60
+++ b/target/arm/syndrome.h
47
* 1 if completing this irq brought us back to base (no active irqs)
61
@@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_pcalignment(void)
48
* 0 if there is still an irq active after this one was completed
62
return (EC_PCALIGNMENT << ARM_EL_EC_SHIFT) | ARM_EL_IL;
49
* (Ignoring -1, this is the same as the RETTOBASE value before completion.)
63
}
50
*/
64
51
-int armv7m_nvic_complete_irq(void *opaque, int irq);
65
+static inline uint32_t syn_serror(uint32_t extra)
52
+int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure);
66
+{
53
/**
67
+ return (EC_SERROR << ARM_EL_EC_SHIFT) | ARM_EL_IL | extra;
54
* armv7m_nvic_raw_execution_priority: return the raw execution priority
68
+}
55
* @opaque: the NVIC
69
+
56
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
70
#endif /* TARGET_ARM_SYNDROME_H */
57
index XXXXXXX..XXXXXXX 100644
71
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
58
--- a/hw/intc/armv7m_nvic.c
72
index XXXXXXX..XXXXXXX 100644
59
+++ b/hw/intc/armv7m_nvic.c
73
--- a/target/arm/cpu.c
60
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure)
74
+++ b/target/arm/cpu.c
61
}
75
@@ -XXX,XX +XXX,XX @@ static bool arm_cpu_has_work(CPUState *cs)
62
76
return (cpu->power_state != PSCI_OFF)
63
/* Make pending IRQ active. */
77
&& cs->interrupt_request &
64
-void armv7m_nvic_acknowledge_irq(void *opaque)
78
(CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD
65
+bool armv7m_nvic_acknowledge_irq(void *opaque)
79
- | CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ
80
+ | CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ | CPU_INTERRUPT_VSERR
81
| CPU_INTERRUPT_EXITTB);
82
}
83
84
@@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
85
return false;
86
}
87
return !(env->daif & PSTATE_I);
88
+ case EXCP_VSERR:
89
+ if (!(hcr_el2 & HCR_AMO) || (hcr_el2 & HCR_TGE)) {
90
+ /* VIRQs are only taken when hypervized. */
91
+ return false;
92
+ }
93
+ return !(env->daif & PSTATE_A);
94
default:
95
g_assert_not_reached();
96
}
97
@@ -XXX,XX +XXX,XX @@ static bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
98
goto found;
99
}
100
}
101
+ if (interrupt_request & CPU_INTERRUPT_VSERR) {
102
+ excp_idx = EXCP_VSERR;
103
+ target_el = 1;
104
+ if (arm_excp_unmasked(cs, excp_idx, target_el,
105
+ cur_el, secure, hcr_el2)) {
106
+ /* Taking a virtual abort clears HCR_EL2.VSE */
107
+ env->cp15.hcr_el2 &= ~HCR_VSE;
108
+ cpu_reset_interrupt(cs, CPU_INTERRUPT_VSERR);
109
+ goto found;
110
+ }
111
+ }
112
return false;
113
114
found:
115
@@ -XXX,XX +XXX,XX @@ void arm_cpu_update_vfiq(ARMCPU *cpu)
116
}
117
}
118
119
+void arm_cpu_update_vserr(ARMCPU *cpu)
120
+{
121
+ /*
122
+ * Update the interrupt level for VSERR, which is the HCR_EL2.VSE bit.
123
+ */
124
+ CPUARMState *env = &cpu->env;
125
+ CPUState *cs = CPU(cpu);
126
+
127
+ bool new_state = env->cp15.hcr_el2 & HCR_VSE;
128
+
129
+ if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VSERR) != 0)) {
130
+ if (new_state) {
131
+ cpu_interrupt(cs, CPU_INTERRUPT_VSERR);
132
+ } else {
133
+ cpu_reset_interrupt(cs, CPU_INTERRUPT_VSERR);
134
+ }
135
+ }
136
+}
137
+
138
#ifndef CONFIG_USER_ONLY
139
static void arm_cpu_set_irq(void *opaque, int irq, int level)
66
{
140
{
67
NVICState *s = (NVICState *)opaque;
68
CPUARMState *env = &s->cpu->env;
69
const int pending = s->vectpending;
70
const int running = nvic_exec_prio(s);
71
VecInfo *vec;
72
+ bool targets_secure;
73
74
assert(pending > ARMV7M_EXCP_RESET && pending < s->num_irq);
75
76
- vec = &s->vectors[pending];
77
+ if (s->vectpending_is_s_banked) {
78
+ vec = &s->sec_vectors[pending];
79
+ targets_secure = true;
80
+ } else {
81
+ vec = &s->vectors[pending];
82
+ targets_secure = !exc_is_banked(s->vectpending) &&
83
+ exc_targets_secure(s, s->vectpending);
84
+ }
85
86
assert(vec->enabled);
87
assert(vec->pending);
88
89
assert(s->vectpending_prio < running);
90
91
- trace_nvic_acknowledge_irq(pending, s->vectpending_prio);
92
+ trace_nvic_acknowledge_irq(pending, s->vectpending_prio, targets_secure);
93
94
vec->active = 1;
95
vec->pending = 0;
96
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque)
97
env->v7m.exception = s->vectpending;
98
99
nvic_irq_update(s);
100
+
101
+ return targets_secure;
102
}
103
104
-int armv7m_nvic_complete_irq(void *opaque, int irq)
105
+int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure)
106
{
107
NVICState *s = (NVICState *)opaque;
108
VecInfo *vec;
109
@@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq)
110
111
assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
112
113
- vec = &s->vectors[irq];
114
+ if (secure && exc_is_banked(irq)) {
115
+ vec = &s->sec_vectors[irq];
116
+ } else {
117
+ vec = &s->vectors[irq];
118
+ }
119
120
- trace_nvic_complete_irq(irq);
121
+ trace_nvic_complete_irq(irq, secure);
122
123
if (!vec->active) {
124
/* Tell the caller this was an illegal exception return */
125
diff --git a/target/arm/helper.c b/target/arm/helper.c
141
diff --git a/target/arm/helper.c b/target/arm/helper.c
126
index XXXXXXX..XXXXXXX 100644
142
index XXXXXXX..XXXXXXX 100644
127
--- a/target/arm/helper.c
143
--- a/target/arm/helper.c
128
+++ b/target/arm/helper.c
144
+++ b/target/arm/helper.c
129
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
145
@@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri)
130
bool return_to_sp_process = false;
131
bool return_to_handler = false;
132
bool rettobase = false;
133
+ bool exc_secure = false;
134
135
/* We can only get here from an EXCP_EXCEPTION_EXIT, and
136
* gen_bx_excret() enforces the architectural rule
137
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
138
* which security state's faultmask to clear. (v8M ARM ARM R_KBNF.)
139
*/
140
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
141
- int es = excret & R_V7M_EXCRET_ES_MASK;
142
+ exc_secure = excret & R_V7M_EXCRET_ES_MASK;
143
if (armv7m_nvic_raw_execution_priority(env->nvic) >= 0) {
144
- env->v7m.faultmask[es] = 0;
145
+ env->v7m.faultmask[exc_secure] = 0;
146
}
147
} else {
148
env->v7m.faultmask[M_REG_NS] = 0;
149
}
146
}
150
}
147
}
151
148
152
- switch (armv7m_nvic_complete_irq(env->nvic, env->v7m.exception)) {
149
- /* External aborts are not possible in QEMU so A bit is always clear */
153
+ switch (armv7m_nvic_complete_irq(env->nvic, env->v7m.exception,
150
+ if (hcr_el2 & HCR_AMO) {
154
+ exc_secure)) {
151
+ if (cs->interrupt_request & CPU_INTERRUPT_VSERR) {
155
case -1:
152
+ ret |= CPSR_A;
156
/* attempt to exit an exception that isn't active */
153
+ }
157
ufault = true;
154
+ }
158
diff --git a/hw/intc/trace-events b/hw/intc/trace-events
155
+
159
index XXXXXXX..XXXXXXX 100644
156
return ret;
160
--- a/hw/intc/trace-events
157
}
161
+++ b/hw/intc/trace-events
158
162
@@ -XXX,XX +XXX,XX @@ nvic_escalate_disabled(int irq) "NVIC escalating irq %d to HardFault: disabled"
159
@@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
163
nvic_set_pending(int irq, bool secure, int en, int prio) "NVIC set pending irq %d secure-bank %d (enabled: %d priority %d)"
160
g_assert(qemu_mutex_iothread_locked());
164
nvic_clear_pending(int irq, bool secure, int en, int prio) "NVIC clear pending irq %d secure-bank %d (enabled: %d priority %d)"
161
arm_cpu_update_virq(cpu);
165
nvic_set_pending_level(int irq) "NVIC set pending: irq %d higher prio than vectpending: setting irq line to 1"
162
arm_cpu_update_vfiq(cpu);
166
-nvic_acknowledge_irq(int irq, int prio) "NVIC acknowledge IRQ: %d now active (prio %d)"
163
+ arm_cpu_update_vserr(cpu);
167
-nvic_complete_irq(int irq) "NVIC complete IRQ %d"
164
}
168
+nvic_acknowledge_irq(int irq, int prio, bool targets_secure) "NVIC acknowledge IRQ: %d now active (prio %d targets_secure %d)"
165
169
+nvic_complete_irq(int irq, bool secure) "NVIC complete IRQ %d (secure %d)"
166
static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
170
nvic_set_irq_level(int irq, int level) "NVIC external irq %d level set to %d"
167
@@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs)
171
nvic_sysreg_read(uint64_t addr, uint32_t value, unsigned size) "NVIC sysreg read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
168
[EXCP_LSERR] = "v8M LSERR UsageFault",
172
nvic_sysreg_write(uint64_t addr, uint32_t value, unsigned size) "NVIC sysreg write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
169
[EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault",
170
[EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault",
171
+ [EXCP_VSERR] = "Virtual SERR",
172
};
173
174
if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
175
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
176
mask = CPSR_A | CPSR_I | CPSR_F;
177
offset = 4;
178
break;
179
+ case EXCP_VSERR:
180
+ {
181
+ /*
182
+ * Note that this is reported as a data abort, but the DFAR
183
+ * has an UNKNOWN value. Construct the SError syndrome from
184
+ * AET and ExT fields.
185
+ */
186
+ ARMMMUFaultInfo fi = { .type = ARMFault_AsyncExternal, };
187
+
188
+ if (extended_addresses_enabled(env)) {
189
+ env->exception.fsr = arm_fi_to_lfsc(&fi);
190
+ } else {
191
+ env->exception.fsr = arm_fi_to_sfsc(&fi);
192
+ }
193
+ env->exception.fsr |= env->cp15.vsesr_el2 & 0xd000;
194
+ A32_BANKED_CURRENT_REG_SET(env, dfsr, env->exception.fsr);
195
+ qemu_log_mask(CPU_LOG_INT, "...with IFSR 0x%x\n",
196
+ env->exception.fsr);
197
+
198
+ new_mode = ARM_CPU_MODE_ABT;
199
+ addr = 0x10;
200
+ mask = CPSR_A | CPSR_I;
201
+ offset = 8;
202
+ }
203
+ break;
204
case EXCP_SMC:
205
new_mode = ARM_CPU_MODE_MON;
206
addr = 0x08;
207
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
208
case EXCP_VFIQ:
209
addr += 0x100;
210
break;
211
+ case EXCP_VSERR:
212
+ addr += 0x180;
213
+ /* Construct the SError syndrome from IDS and ISS fields. */
214
+ env->exception.syndrome = syn_serror(env->cp15.vsesr_el2 & 0x1ffffff);
215
+ env->cp15.esr_el[new_el] = env->exception.syndrome;
216
+ break;
217
default:
218
cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
219
}
173
--
220
--
174
2.7.4
221
2.25.1
175
176
diff view generated by jsdifflib
1
From: Subbaraya Sundeep <sundeep.lkml@gmail.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Modelled Microsemi's Smartfusion2 SPI controller.
3
Check for and defer any pending virtual SError.
4
4
5
Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 20220506180242.216785-17-richard.henderson@linaro.org
8
Message-id: 20170920201737.25723-4-f4bug@amsat.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
9
---
11
hw/ssi/Makefile.objs | 1 +
10
target/arm/helper.h | 1 +
12
include/hw/ssi/mss-spi.h | 58 +++++++
11
target/arm/a32.decode | 16 ++++++++------
13
hw/ssi/mss-spi.c | 404 +++++++++++++++++++++++++++++++++++++++++++++++
12
target/arm/t32.decode | 18 ++++++++--------
14
3 files changed, 463 insertions(+)
13
target/arm/op_helper.c | 43 ++++++++++++++++++++++++++++++++++++++
15
create mode 100644 include/hw/ssi/mss-spi.h
14
target/arm/translate-a64.c | 17 +++++++++++++++
16
create mode 100644 hw/ssi/mss-spi.c
15
target/arm/translate.c | 23 ++++++++++++++++++++
16
6 files changed, 103 insertions(+), 15 deletions(-)
17
17
18
diff --git a/hw/ssi/Makefile.objs b/hw/ssi/Makefile.objs
18
diff --git a/target/arm/helper.h b/target/arm/helper.h
19
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/ssi/Makefile.objs
20
--- a/target/arm/helper.h
21
+++ b/hw/ssi/Makefile.objs
21
+++ b/target/arm/helper.h
22
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_XILINX_SPI) += xilinx_spi.o
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_1(wfe, void, env)
23
common-obj-$(CONFIG_XILINX_SPIPS) += xilinx_spips.o
23
DEF_HELPER_1(yield, void, env)
24
common-obj-$(CONFIG_ASPEED_SOC) += aspeed_smc.o
24
DEF_HELPER_1(pre_hvc, void, env)
25
common-obj-$(CONFIG_STM32F2XX_SPI) += stm32f2xx_spi.o
25
DEF_HELPER_2(pre_smc, void, env, i32)
26
+common-obj-$(CONFIG_MSF2) += mss-spi.o
26
+DEF_HELPER_1(vesb, void, env)
27
27
28
obj-$(CONFIG_OMAP) += omap_spi.o
28
DEF_HELPER_3(cpsr_write, void, env, i32, i32)
29
obj-$(CONFIG_IMX) += imx_spi.o
29
DEF_HELPER_2(cpsr_write_eret, void, env, i32)
30
diff --git a/include/hw/ssi/mss-spi.h b/include/hw/ssi/mss-spi.h
30
diff --git a/target/arm/a32.decode b/target/arm/a32.decode
31
new file mode 100644
31
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX
32
--- a/target/arm/a32.decode
33
--- /dev/null
33
+++ b/target/arm/a32.decode
34
+++ b/include/hw/ssi/mss-spi.h
34
@@ -XXX,XX +XXX,XX @@ SMULTT .... 0001 0110 .... 0000 .... 1110 .... @rd0mn
35
@@ -XXX,XX +XXX,XX @@
35
36
{
37
{
38
- YIELD ---- 0011 0010 0000 1111 ---- 0000 0001
39
- WFE ---- 0011 0010 0000 1111 ---- 0000 0010
40
- WFI ---- 0011 0010 0000 1111 ---- 0000 0011
41
+ [
42
+ YIELD ---- 0011 0010 0000 1111 ---- 0000 0001
43
+ WFE ---- 0011 0010 0000 1111 ---- 0000 0010
44
+ WFI ---- 0011 0010 0000 1111 ---- 0000 0011
45
46
- # TODO: Implement SEV, SEVL; may help SMP performance.
47
- # SEV ---- 0011 0010 0000 1111 ---- 0000 0100
48
- # SEVL ---- 0011 0010 0000 1111 ---- 0000 0101
49
+ # TODO: Implement SEV, SEVL; may help SMP performance.
50
+ # SEV ---- 0011 0010 0000 1111 ---- 0000 0100
51
+ # SEVL ---- 0011 0010 0000 1111 ---- 0000 0101
52
+
53
+ ESB ---- 0011 0010 0000 1111 ---- 0001 0000
54
+ ]
55
56
# The canonical nop ends in 00000000, but the whole of the
57
# rest of the space executes as nop if otherwise unsupported.
58
diff --git a/target/arm/t32.decode b/target/arm/t32.decode
59
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/t32.decode
61
+++ b/target/arm/t32.decode
62
@@ -XXX,XX +XXX,XX @@ CLZ 1111 1010 1011 ---- 1111 .... 1000 .... @rdm
63
[
64
# Hints, and CPS
65
{
66
- YIELD 1111 0011 1010 1111 1000 0000 0000 0001
67
- WFE 1111 0011 1010 1111 1000 0000 0000 0010
68
- WFI 1111 0011 1010 1111 1000 0000 0000 0011
69
+ [
70
+ YIELD 1111 0011 1010 1111 1000 0000 0000 0001
71
+ WFE 1111 0011 1010 1111 1000 0000 0000 0010
72
+ WFI 1111 0011 1010 1111 1000 0000 0000 0011
73
74
- # TODO: Implement SEV, SEVL; may help SMP performance.
75
- # SEV 1111 0011 1010 1111 1000 0000 0000 0100
76
- # SEVL 1111 0011 1010 1111 1000 0000 0000 0101
77
+ # TODO: Implement SEV, SEVL; may help SMP performance.
78
+ # SEV 1111 0011 1010 1111 1000 0000 0000 0100
79
+ # SEVL 1111 0011 1010 1111 1000 0000 0000 0101
80
81
- # For M-profile minimal-RAS ESB can be a NOP, which is the
82
- # default behaviour since it is in the hint space.
83
- # ESB 1111 0011 1010 1111 1000 0000 0001 0000
84
+ ESB 1111 0011 1010 1111 1000 0000 0001 0000
85
+ ]
86
87
# The canonical nop ends in 0000 0000, but the whole rest
88
# of the space is "reserved hint, behaves as nop".
89
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
90
index XXXXXXX..XXXXXXX 100644
91
--- a/target/arm/op_helper.c
92
+++ b/target/arm/op_helper.c
93
@@ -XXX,XX +XXX,XX @@ void HELPER(probe_access)(CPUARMState *env, target_ulong ptr,
94
access_type, mmu_idx, ra);
95
}
96
}
97
+
36
+/*
98
+/*
37
+ * Microsemi SmartFusion2 SPI
99
+ * This function corresponds to AArch64.vESBOperation().
38
+ *
100
+ * Note that the AArch32 version is not functionally different.
39
+ * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>
40
+ *
41
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
42
+ * of this software and associated documentation files (the "Software"), to deal
43
+ * in the Software without restriction, including without limitation the rights
44
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
45
+ * copies of the Software, and to permit persons to whom the Software is
46
+ * furnished to do so, subject to the following conditions:
47
+ *
48
+ * The above copyright notice and this permission notice shall be included in
49
+ * all copies or substantial portions of the Software.
50
+ *
51
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
53
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
54
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
55
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
56
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
57
+ * THE SOFTWARE.
58
+ */
101
+ */
59
+
102
+void HELPER(vesb)(CPUARMState *env)
60
+#ifndef HW_MSS_SPI_H
61
+#define HW_MSS_SPI_H
62
+
63
+#include "hw/sysbus.h"
64
+#include "hw/ssi/ssi.h"
65
+#include "qemu/fifo32.h"
66
+
67
+#define TYPE_MSS_SPI "mss-spi"
68
+#define MSS_SPI(obj) OBJECT_CHECK(MSSSpiState, (obj), TYPE_MSS_SPI)
69
+
70
+#define R_SPI_MAX 16
71
+
72
+typedef struct MSSSpiState {
73
+ SysBusDevice parent_obj;
74
+
75
+ MemoryRegion mmio;
76
+
77
+ qemu_irq irq;
78
+
79
+ qemu_irq cs_line;
80
+
81
+ SSIBus *spi;
82
+
83
+ Fifo32 rx_fifo;
84
+ Fifo32 tx_fifo;
85
+
86
+ int fifo_depth;
87
+ uint32_t frame_count;
88
+ bool enabled;
89
+
90
+ uint32_t regs[R_SPI_MAX];
91
+} MSSSpiState;
92
+
93
+#endif /* HW_MSS_SPI_H */
94
diff --git a/hw/ssi/mss-spi.c b/hw/ssi/mss-spi.c
95
new file mode 100644
96
index XXXXXXX..XXXXXXX
97
--- /dev/null
98
+++ b/hw/ssi/mss-spi.c
99
@@ -XXX,XX +XXX,XX @@
100
+/*
101
+ * Block model of SPI controller present in
102
+ * Microsemi's SmartFusion2 and SmartFusion SoCs.
103
+ *
104
+ * Copyright (C) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>
105
+ *
106
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
107
+ * of this software and associated documentation files (the "Software"), to deal
108
+ * in the Software without restriction, including without limitation the rights
109
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
110
+ * copies of the Software, and to permit persons to whom the Software is
111
+ * furnished to do so, subject to the following conditions:
112
+ *
113
+ * The above copyright notice and this permission notice shall be included in
114
+ * all copies or substantial portions of the Software.
115
+ *
116
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
117
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
118
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
119
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
120
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
121
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
122
+ * THE SOFTWARE.
123
+ */
124
+
125
+#include "qemu/osdep.h"
126
+#include "hw/ssi/mss-spi.h"
127
+#include "qemu/log.h"
128
+
129
+#ifndef MSS_SPI_ERR_DEBUG
130
+#define MSS_SPI_ERR_DEBUG 0
131
+#endif
132
+
133
+#define DB_PRINT_L(lvl, fmt, args...) do { \
134
+ if (MSS_SPI_ERR_DEBUG >= lvl) { \
135
+ qemu_log("%s: " fmt "\n", __func__, ## args); \
136
+ } \
137
+} while (0);
138
+
139
+#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args)
140
+
141
+#define FIFO_CAPACITY 32
142
+
143
+#define R_SPI_CONTROL 0
144
+#define R_SPI_DFSIZE 1
145
+#define R_SPI_STATUS 2
146
+#define R_SPI_INTCLR 3
147
+#define R_SPI_RX 4
148
+#define R_SPI_TX 5
149
+#define R_SPI_CLKGEN 6
150
+#define R_SPI_SS 7
151
+#define R_SPI_MIS 8
152
+#define R_SPI_RIS 9
153
+
154
+#define S_TXDONE (1 << 0)
155
+#define S_RXRDY (1 << 1)
156
+#define S_RXCHOVRF (1 << 2)
157
+#define S_RXFIFOFUL (1 << 4)
158
+#define S_RXFIFOFULNXT (1 << 5)
159
+#define S_RXFIFOEMP (1 << 6)
160
+#define S_RXFIFOEMPNXT (1 << 7)
161
+#define S_TXFIFOFUL (1 << 8)
162
+#define S_TXFIFOFULNXT (1 << 9)
163
+#define S_TXFIFOEMP (1 << 10)
164
+#define S_TXFIFOEMPNXT (1 << 11)
165
+#define S_FRAMESTART (1 << 12)
166
+#define S_SSEL (1 << 13)
167
+#define S_ACTIVE (1 << 14)
168
+
169
+#define C_ENABLE (1 << 0)
170
+#define C_MODE (1 << 1)
171
+#define C_INTRXDATA (1 << 4)
172
+#define C_INTTXDATA (1 << 5)
173
+#define C_INTRXOVRFLO (1 << 6)
174
+#define C_SPS (1 << 26)
175
+#define C_BIGFIFO (1 << 29)
176
+#define C_RESET (1 << 31)
177
+
178
+#define FRAMESZ_MASK 0x1F
179
+#define FMCOUNT_MASK 0x00FFFF00
180
+#define FMCOUNT_SHIFT 8
181
+
182
+static void txfifo_reset(MSSSpiState *s)
183
+{
103
+{
184
+ fifo32_reset(&s->tx_fifo);
104
+ /*
185
+
105
+ * The EL2Enabled() check is done inside arm_hcr_el2_eff,
186
+ s->regs[R_SPI_STATUS] &= ~S_TXFIFOFUL;
106
+ * and will return HCR_EL2.VSE == 0, so nothing happens.
187
+ s->regs[R_SPI_STATUS] |= S_TXFIFOEMP;
107
+ */
188
+}
108
+ uint64_t hcr = arm_hcr_el2_eff(env);
189
+
109
+ bool enabled = !(hcr & HCR_TGE) && (hcr & HCR_AMO);
190
+static void rxfifo_reset(MSSSpiState *s)
110
+ bool pending = enabled && (hcr & HCR_VSE);
191
+{
111
+ bool masked = (env->daif & PSTATE_A);
192
+ fifo32_reset(&s->rx_fifo);
112
+
193
+
113
+ /* If VSE pending and masked, defer the exception. */
194
+ s->regs[R_SPI_STATUS] &= ~S_RXFIFOFUL;
114
+ if (pending && masked) {
195
+ s->regs[R_SPI_STATUS] |= S_RXFIFOEMP;
115
+ uint32_t syndrome;
196
+}
116
+
197
+
117
+ if (arm_el_is_aa64(env, 1)) {
198
+static void set_fifodepth(MSSSpiState *s)
118
+ /* Copy across IDS and ISS from VSESR. */
199
+{
119
+ syndrome = env->cp15.vsesr_el2 & 0x1ffffff;
200
+ unsigned int size = s->regs[R_SPI_DFSIZE] & FRAMESZ_MASK;
120
+ } else {
201
+
121
+ ARMMMUFaultInfo fi = { .type = ARMFault_AsyncExternal };
202
+ if (size <= 8) {
122
+
203
+ s->fifo_depth = 32;
123
+ if (extended_addresses_enabled(env)) {
204
+ } else if (size <= 16) {
124
+ syndrome = arm_fi_to_lfsc(&fi);
205
+ s->fifo_depth = 16;
125
+ } else {
206
+ } else if (size <= 32) {
126
+ syndrome = arm_fi_to_sfsc(&fi);
207
+ s->fifo_depth = 8;
127
+ }
208
+ } else {
128
+ /* Copy across AET and ExT from VSESR. */
209
+ s->fifo_depth = 4;
129
+ syndrome |= env->cp15.vsesr_el2 & 0xd000;
130
+ }
131
+
132
+ /* Set VDISR_EL2.A along with the syndrome. */
133
+ env->cp15.vdisr_el2 = syndrome | (1u << 31);
134
+
135
+ /* Clear pending virtual SError */
136
+ env->cp15.hcr_el2 &= ~HCR_VSE;
137
+ cpu_reset_interrupt(env_cpu(env), CPU_INTERRUPT_VSERR);
210
+ }
138
+ }
211
+}
139
+}
212
+
140
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
213
+static void update_mis(MSSSpiState *s)
141
index XXXXXXX..XXXXXXX 100644
214
+{
142
--- a/target/arm/translate-a64.c
215
+ uint32_t reg = s->regs[R_SPI_CONTROL];
143
+++ b/target/arm/translate-a64.c
216
+ uint32_t tmp;
144
@@ -XXX,XX +XXX,XX @@ static void handle_hint(DisasContext *s, uint32_t insn,
217
+
145
gen_helper_autib(cpu_X[17], cpu_env, cpu_X[17], cpu_X[16]);
218
+ /*
146
}
219
+ * form the Control register interrupt enable bits
147
break;
220
+ * same as RIS, MIS and Interrupt clear registers for simplicity
148
+ case 0b10000: /* ESB */
221
+ */
149
+ /* Without RAS, we must implement this as NOP. */
222
+ tmp = ((reg & C_INTRXOVRFLO) >> 4) | ((reg & C_INTRXDATA) >> 3) |
150
+ if (dc_isar_feature(aa64_ras, s)) {
223
+ ((reg & C_INTTXDATA) >> 5);
151
+ /*
224
+ s->regs[R_SPI_MIS] |= tmp & s->regs[R_SPI_RIS];
152
+ * QEMU does not have a source of physical SErrors,
225
+}
153
+ * so we are only concerned with virtual SErrors.
226
+
154
+ * The pseudocode in the ARM for this case is
227
+static void spi_update_irq(MSSSpiState *s)
155
+ * if PSTATE.EL IN {EL0, EL1} && EL2Enabled() then
228
+{
156
+ * AArch64.vESBOperation();
229
+ int irq;
157
+ * Most of the condition can be evaluated at translation time.
230
+
158
+ * Test for EL2 present, and defer test for SEL2 to runtime.
231
+ update_mis(s);
159
+ */
232
+ irq = !!(s->regs[R_SPI_MIS]);
160
+ if (s->current_el <= 1 && arm_dc_feature(s, ARM_FEATURE_EL2)) {
233
+
161
+ gen_helper_vesb(cpu_env);
234
+ qemu_set_irq(s->irq, irq);
162
+ }
235
+}
236
+
237
+static void mss_spi_reset(DeviceState *d)
238
+{
239
+ MSSSpiState *s = MSS_SPI(d);
240
+
241
+ memset(s->regs, 0, sizeof s->regs);
242
+ s->regs[R_SPI_CONTROL] = 0x80000102;
243
+ s->regs[R_SPI_DFSIZE] = 0x4;
244
+ s->regs[R_SPI_STATUS] = S_SSEL | S_TXFIFOEMP | S_RXFIFOEMP;
245
+ s->regs[R_SPI_CLKGEN] = 0x7;
246
+ s->regs[R_SPI_RIS] = 0x0;
247
+
248
+ s->fifo_depth = 4;
249
+ s->frame_count = 1;
250
+ s->enabled = false;
251
+
252
+ rxfifo_reset(s);
253
+ txfifo_reset(s);
254
+}
255
+
256
+static uint64_t
257
+spi_read(void *opaque, hwaddr addr, unsigned int size)
258
+{
259
+ MSSSpiState *s = opaque;
260
+ uint32_t ret = 0;
261
+
262
+ addr >>= 2;
263
+ switch (addr) {
264
+ case R_SPI_RX:
265
+ s->regs[R_SPI_STATUS] &= ~S_RXFIFOFUL;
266
+ s->regs[R_SPI_STATUS] &= ~S_RXCHOVRF;
267
+ ret = fifo32_pop(&s->rx_fifo);
268
+ if (fifo32_is_empty(&s->rx_fifo)) {
269
+ s->regs[R_SPI_STATUS] |= S_RXFIFOEMP;
270
+ }
163
+ }
271
+ break;
164
+ break;
272
+
165
case 0b11000: /* PACIAZ */
273
+ case R_SPI_MIS:
166
if (s->pauth_active) {
274
+ update_mis(s);
167
gen_helper_pacia(cpu_X[30], cpu_env, cpu_X[30],
275
+ ret = s->regs[R_SPI_MIS];
168
diff --git a/target/arm/translate.c b/target/arm/translate.c
276
+ break;
169
index XXXXXXX..XXXXXXX 100644
277
+
170
--- a/target/arm/translate.c
278
+ default:
171
+++ b/target/arm/translate.c
279
+ if (addr < ARRAY_SIZE(s->regs)) {
172
@@ -XXX,XX +XXX,XX @@ static bool trans_WFI(DisasContext *s, arg_WFI *a)
280
+ ret = s->regs[addr];
173
return true;
281
+ } else {
174
}
282
+ qemu_log_mask(LOG_GUEST_ERROR,
175
283
+ "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__,
176
+static bool trans_ESB(DisasContext *s, arg_ESB *a)
284
+ addr * 4);
285
+ return ret;
286
+ }
287
+ break;
288
+ }
289
+
290
+ DB_PRINT("addr=0x%" HWADDR_PRIx " = 0x%" PRIx32, addr * 4, ret);
291
+ spi_update_irq(s);
292
+ return ret;
293
+}
294
+
295
+static void assert_cs(MSSSpiState *s)
296
+{
177
+{
297
+ qemu_set_irq(s->cs_line, 0);
298
+}
299
+
300
+static void deassert_cs(MSSSpiState *s)
301
+{
302
+ qemu_set_irq(s->cs_line, 1);
303
+}
304
+
305
+static void spi_flush_txfifo(MSSSpiState *s)
306
+{
307
+ uint32_t tx;
308
+ uint32_t rx;
309
+ bool sps = !!(s->regs[R_SPI_CONTROL] & C_SPS);
310
+
311
+ /*
178
+ /*
312
+ * Chip Select(CS) is automatically controlled by this controller.
179
+ * For M-profile, minimal-RAS ESB can be a NOP.
313
+ * If SPS bit is set in Control register then CS is asserted
180
+ * Without RAS, we must implement this as NOP.
314
+ * until all the frames set in frame count of Control register are
315
+ * transferred. If SPS is not set then CS pulses between frames.
316
+ * Note that Slave Select register specifies which of the CS line
317
+ * has to be controlled automatically by controller. Bits SS[7:1] are for
318
+ * masters in FPGA fabric since we model only Microcontroller subsystem
319
+ * of Smartfusion2 we control only one CS(SS[0]) line.
320
+ */
181
+ */
321
+ while (!fifo32_is_empty(&s->tx_fifo) && s->frame_count) {
182
+ if (!arm_dc_feature(s, ARM_FEATURE_M) && dc_isar_feature(aa32_ras, s)) {
322
+ assert_cs(s);
183
+ /*
323
+
184
+ * QEMU does not have a source of physical SErrors,
324
+ s->regs[R_SPI_STATUS] &= ~(S_TXDONE | S_RXRDY);
185
+ * so we are only concerned with virtual SErrors.
325
+
186
+ * The pseudocode in the ARM for this case is
326
+ tx = fifo32_pop(&s->tx_fifo);
187
+ * if PSTATE.EL IN {EL0, EL1} && EL2Enabled() then
327
+ DB_PRINT("data tx:0x%" PRIx32, tx);
188
+ * AArch32.vESBOperation();
328
+ rx = ssi_transfer(s->spi, tx);
189
+ * Most of the condition can be evaluated at translation time.
329
+ DB_PRINT("data rx:0x%" PRIx32, rx);
190
+ * Test for EL2 present, and defer test for SEL2 to runtime.
330
+
191
+ */
331
+ if (fifo32_num_used(&s->rx_fifo) == s->fifo_depth) {
192
+ if (s->current_el <= 1 && arm_dc_feature(s, ARM_FEATURE_EL2)) {
332
+ s->regs[R_SPI_STATUS] |= S_RXCHOVRF;
193
+ gen_helper_vesb(cpu_env);
333
+ s->regs[R_SPI_RIS] |= S_RXCHOVRF;
334
+ } else {
335
+ fifo32_push(&s->rx_fifo, rx);
336
+ s->regs[R_SPI_STATUS] &= ~S_RXFIFOEMP;
337
+ if (fifo32_num_used(&s->rx_fifo) == (s->fifo_depth - 1)) {
338
+ s->regs[R_SPI_STATUS] |= S_RXFIFOFULNXT;
339
+ } else if (fifo32_num_used(&s->rx_fifo) == s->fifo_depth) {
340
+ s->regs[R_SPI_STATUS] |= S_RXFIFOFUL;
341
+ }
342
+ }
343
+ s->frame_count--;
344
+ if (!sps) {
345
+ deassert_cs(s);
346
+ }
194
+ }
347
+ }
195
+ }
348
+
196
+ return true;
349
+ if (!s->frame_count) {
350
+ s->frame_count = (s->regs[R_SPI_CONTROL] & FMCOUNT_MASK) >>
351
+ FMCOUNT_SHIFT;
352
+ deassert_cs(s);
353
+ s->regs[R_SPI_RIS] |= S_TXDONE | S_RXRDY;
354
+ s->regs[R_SPI_STATUS] |= S_TXDONE | S_RXRDY;
355
+ }
356
+}
197
+}
357
+
198
+
358
+static void spi_write(void *opaque, hwaddr addr,
199
static bool trans_NOP(DisasContext *s, arg_NOP *a)
359
+ uint64_t val64, unsigned int size)
200
{
360
+{
201
return true;
361
+ MSSSpiState *s = opaque;
362
+ uint32_t value = val64;
363
+
364
+ DB_PRINT("addr=0x%" HWADDR_PRIx " =0x%" PRIx32, addr, value);
365
+ addr >>= 2;
366
+
367
+ switch (addr) {
368
+ case R_SPI_TX:
369
+ /* adding to already full FIFO */
370
+ if (fifo32_num_used(&s->tx_fifo) == s->fifo_depth) {
371
+ break;
372
+ }
373
+ s->regs[R_SPI_STATUS] &= ~S_TXFIFOEMP;
374
+ fifo32_push(&s->tx_fifo, value);
375
+ if (fifo32_num_used(&s->tx_fifo) == (s->fifo_depth - 1)) {
376
+ s->regs[R_SPI_STATUS] |= S_TXFIFOFULNXT;
377
+ } else if (fifo32_num_used(&s->tx_fifo) == s->fifo_depth) {
378
+ s->regs[R_SPI_STATUS] |= S_TXFIFOFUL;
379
+ }
380
+ if (s->enabled) {
381
+ spi_flush_txfifo(s);
382
+ }
383
+ break;
384
+
385
+ case R_SPI_CONTROL:
386
+ s->regs[R_SPI_CONTROL] = value;
387
+ if (value & C_BIGFIFO) {
388
+ set_fifodepth(s);
389
+ } else {
390
+ s->fifo_depth = 4;
391
+ }
392
+ s->enabled = value & C_ENABLE;
393
+ s->frame_count = (value & FMCOUNT_MASK) >> FMCOUNT_SHIFT;
394
+ if (value & C_RESET) {
395
+ mss_spi_reset(DEVICE(s));
396
+ }
397
+ break;
398
+
399
+ case R_SPI_DFSIZE:
400
+ if (s->enabled) {
401
+ break;
402
+ }
403
+ s->regs[R_SPI_DFSIZE] = value;
404
+ break;
405
+
406
+ case R_SPI_INTCLR:
407
+ s->regs[R_SPI_INTCLR] = value;
408
+ if (value & S_TXDONE) {
409
+ s->regs[R_SPI_RIS] &= ~S_TXDONE;
410
+ }
411
+ if (value & S_RXRDY) {
412
+ s->regs[R_SPI_RIS] &= ~S_RXRDY;
413
+ }
414
+ if (value & S_RXCHOVRF) {
415
+ s->regs[R_SPI_RIS] &= ~S_RXCHOVRF;
416
+ }
417
+ break;
418
+
419
+ case R_SPI_MIS:
420
+ case R_SPI_STATUS:
421
+ case R_SPI_RIS:
422
+ qemu_log_mask(LOG_GUEST_ERROR,
423
+ "%s: Write to read only register 0x%" HWADDR_PRIx "\n",
424
+ __func__, addr * 4);
425
+ break;
426
+
427
+ default:
428
+ if (addr < ARRAY_SIZE(s->regs)) {
429
+ s->regs[addr] = value;
430
+ } else {
431
+ qemu_log_mask(LOG_GUEST_ERROR,
432
+ "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__,
433
+ addr * 4);
434
+ }
435
+ break;
436
+ }
437
+
438
+ spi_update_irq(s);
439
+}
440
+
441
+static const MemoryRegionOps spi_ops = {
442
+ .read = spi_read,
443
+ .write = spi_write,
444
+ .endianness = DEVICE_NATIVE_ENDIAN,
445
+ .valid = {
446
+ .min_access_size = 1,
447
+ .max_access_size = 4
448
+ }
449
+};
450
+
451
+static void mss_spi_realize(DeviceState *dev, Error **errp)
452
+{
453
+ MSSSpiState *s = MSS_SPI(dev);
454
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
455
+
456
+ s->spi = ssi_create_bus(dev, "spi");
457
+
458
+ sysbus_init_irq(sbd, &s->irq);
459
+ ssi_auto_connect_slaves(dev, &s->cs_line, s->spi);
460
+ sysbus_init_irq(sbd, &s->cs_line);
461
+
462
+ memory_region_init_io(&s->mmio, OBJECT(s), &spi_ops, s,
463
+ TYPE_MSS_SPI, R_SPI_MAX * 4);
464
+ sysbus_init_mmio(sbd, &s->mmio);
465
+
466
+ fifo32_create(&s->tx_fifo, FIFO_CAPACITY);
467
+ fifo32_create(&s->rx_fifo, FIFO_CAPACITY);
468
+}
469
+
470
+static const VMStateDescription vmstate_mss_spi = {
471
+ .name = TYPE_MSS_SPI,
472
+ .version_id = 1,
473
+ .minimum_version_id = 1,
474
+ .fields = (VMStateField[]) {
475
+ VMSTATE_FIFO32(tx_fifo, MSSSpiState),
476
+ VMSTATE_FIFO32(rx_fifo, MSSSpiState),
477
+ VMSTATE_UINT32_ARRAY(regs, MSSSpiState, R_SPI_MAX),
478
+ VMSTATE_END_OF_LIST()
479
+ }
480
+};
481
+
482
+static void mss_spi_class_init(ObjectClass *klass, void *data)
483
+{
484
+ DeviceClass *dc = DEVICE_CLASS(klass);
485
+
486
+ dc->realize = mss_spi_realize;
487
+ dc->reset = mss_spi_reset;
488
+ dc->vmsd = &vmstate_mss_spi;
489
+}
490
+
491
+static const TypeInfo mss_spi_info = {
492
+ .name = TYPE_MSS_SPI,
493
+ .parent = TYPE_SYS_BUS_DEVICE,
494
+ .instance_size = sizeof(MSSSpiState),
495
+ .class_init = mss_spi_class_init,
496
+};
497
+
498
+static void mss_spi_register_types(void)
499
+{
500
+ type_register_static(&mss_spi_info);
501
+}
502
+
503
+type_init(mss_spi_register_types)
504
--
202
--
505
2.7.4
203
2.25.1
506
507
diff view generated by jsdifflib
1
Handle banking of SHCSR: some register bits are banked between
1
From: Richard Henderson <richard.henderson@linaro.org>
2
Secure and Non-Secure, and some are only accessible to Secure.
3
2
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220506180242.216785-18-richard.henderson@linaro.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 1505240046-11454-19-git-send-email-peter.maydell@linaro.org
7
---
7
---
8
hw/intc/armv7m_nvic.c | 221 ++++++++++++++++++++++++++++++++++++++------------
8
docs/system/arm/emulation.rst | 1 +
9
1 file changed, 169 insertions(+), 52 deletions(-)
9
target/arm/cpu64.c | 1 +
10
target/arm/cpu_tcg.c | 1 +
11
3 files changed, 3 insertions(+)
10
12
11
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
13
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
12
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/intc/armv7m_nvic.c
15
--- a/docs/system/arm/emulation.rst
14
+++ b/hw/intc/armv7m_nvic.c
16
+++ b/docs/system/arm/emulation.rst
15
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
17
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
16
val = cpu->env.v7m.ccr[attrs.secure];
18
- FEAT_PMULL (PMULL, PMULL2 instructions)
17
val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK;
19
- FEAT_PMUv3p1 (PMU Extensions v3.1)
18
return val;
20
- FEAT_PMUv3p4 (PMU Extensions v3.4)
19
- case 0xd24: /* System Handler Status. */
21
+- FEAT_RAS (Reliability, availability, and serviceability)
20
+ case 0xd24: /* System Handler Control and State (SHCSR) */
22
- FEAT_RDM (Advanced SIMD rounding double multiply accumulate instructions)
21
val = 0;
23
- FEAT_RNG (Random number generator)
22
- if (s->vectors[ARMV7M_EXCP_MEM].active) {
24
- FEAT_SB (Speculation Barrier)
23
- val |= (1 << 0);
25
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
24
- }
26
index XXXXXXX..XXXXXXX 100644
25
- if (s->vectors[ARMV7M_EXCP_BUS].active) {
27
--- a/target/arm/cpu64.c
26
- val |= (1 << 1);
28
+++ b/target/arm/cpu64.c
27
- }
29
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
28
- if (s->vectors[ARMV7M_EXCP_USAGE].active) {
30
t = cpu->isar.id_aa64pfr0;
29
- val |= (1 << 3);
31
t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */
30
+ if (attrs.secure) {
32
t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */
31
+ if (s->sec_vectors[ARMV7M_EXCP_MEM].active) {
33
+ t = FIELD_DP64(t, ID_AA64PFR0, RAS, 1); /* FEAT_RAS */
32
+ val |= (1 << 0);
34
t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
33
+ }
35
t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */
34
+ if (s->sec_vectors[ARMV7M_EXCP_HARD].active) {
36
t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */
35
+ val |= (1 << 2);
37
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
36
+ }
38
index XXXXXXX..XXXXXXX 100644
37
+ if (s->sec_vectors[ARMV7M_EXCP_USAGE].active) {
39
--- a/target/arm/cpu_tcg.c
38
+ val |= (1 << 3);
40
+++ b/target/arm/cpu_tcg.c
39
+ }
41
@@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu)
40
+ if (s->sec_vectors[ARMV7M_EXCP_SVC].active) {
42
41
+ val |= (1 << 7);
43
t = cpu->isar.id_pfr0;
42
+ }
44
t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */
43
+ if (s->sec_vectors[ARMV7M_EXCP_PENDSV].active) {
45
+ t = FIELD_DP32(t, ID_PFR0, RAS, 1); /* FEAT_RAS */
44
+ val |= (1 << 10);
46
cpu->isar.id_pfr0 = t;
45
+ }
47
46
+ if (s->sec_vectors[ARMV7M_EXCP_SYSTICK].active) {
48
t = cpu->isar.id_pfr2;
47
+ val |= (1 << 11);
48
+ }
49
+ if (s->sec_vectors[ARMV7M_EXCP_USAGE].pending) {
50
+ val |= (1 << 12);
51
+ }
52
+ if (s->sec_vectors[ARMV7M_EXCP_MEM].pending) {
53
+ val |= (1 << 13);
54
+ }
55
+ if (s->sec_vectors[ARMV7M_EXCP_SVC].pending) {
56
+ val |= (1 << 15);
57
+ }
58
+ if (s->sec_vectors[ARMV7M_EXCP_MEM].enabled) {
59
+ val |= (1 << 16);
60
+ }
61
+ if (s->sec_vectors[ARMV7M_EXCP_USAGE].enabled) {
62
+ val |= (1 << 18);
63
+ }
64
+ if (s->sec_vectors[ARMV7M_EXCP_HARD].pending) {
65
+ val |= (1 << 21);
66
+ }
67
+ /* SecureFault is not banked but is always RAZ/WI to NS */
68
+ if (s->vectors[ARMV7M_EXCP_SECURE].active) {
69
+ val |= (1 << 4);
70
+ }
71
+ if (s->vectors[ARMV7M_EXCP_SECURE].enabled) {
72
+ val |= (1 << 19);
73
+ }
74
+ if (s->vectors[ARMV7M_EXCP_SECURE].pending) {
75
+ val |= (1 << 20);
76
+ }
77
+ } else {
78
+ if (s->vectors[ARMV7M_EXCP_MEM].active) {
79
+ val |= (1 << 0);
80
+ }
81
+ if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
82
+ /* HARDFAULTACT, HARDFAULTPENDED not present in v7M */
83
+ if (s->vectors[ARMV7M_EXCP_HARD].active) {
84
+ val |= (1 << 2);
85
+ }
86
+ if (s->vectors[ARMV7M_EXCP_HARD].pending) {
87
+ val |= (1 << 21);
88
+ }
89
+ }
90
+ if (s->vectors[ARMV7M_EXCP_USAGE].active) {
91
+ val |= (1 << 3);
92
+ }
93
+ if (s->vectors[ARMV7M_EXCP_SVC].active) {
94
+ val |= (1 << 7);
95
+ }
96
+ if (s->vectors[ARMV7M_EXCP_PENDSV].active) {
97
+ val |= (1 << 10);
98
+ }
99
+ if (s->vectors[ARMV7M_EXCP_SYSTICK].active) {
100
+ val |= (1 << 11);
101
+ }
102
+ if (s->vectors[ARMV7M_EXCP_USAGE].pending) {
103
+ val |= (1 << 12);
104
+ }
105
+ if (s->vectors[ARMV7M_EXCP_MEM].pending) {
106
+ val |= (1 << 13);
107
+ }
108
+ if (s->vectors[ARMV7M_EXCP_SVC].pending) {
109
+ val |= (1 << 15);
110
+ }
111
+ if (s->vectors[ARMV7M_EXCP_MEM].enabled) {
112
+ val |= (1 << 16);
113
+ }
114
+ if (s->vectors[ARMV7M_EXCP_USAGE].enabled) {
115
+ val |= (1 << 18);
116
+ }
117
}
118
- if (s->vectors[ARMV7M_EXCP_SVC].active) {
119
- val |= (1 << 7);
120
+ if (attrs.secure || (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
121
+ if (s->vectors[ARMV7M_EXCP_BUS].active) {
122
+ val |= (1 << 1);
123
+ }
124
+ if (s->vectors[ARMV7M_EXCP_BUS].pending) {
125
+ val |= (1 << 14);
126
+ }
127
+ if (s->vectors[ARMV7M_EXCP_BUS].enabled) {
128
+ val |= (1 << 17);
129
+ }
130
+ if (arm_feature(&cpu->env, ARM_FEATURE_V8) &&
131
+ s->vectors[ARMV7M_EXCP_NMI].active) {
132
+ /* NMIACT is not present in v7M */
133
+ val |= (1 << 5);
134
+ }
135
}
136
+
137
+ /* TODO: this is RAZ/WI from NS if DEMCR.SDME is set */
138
if (s->vectors[ARMV7M_EXCP_DEBUG].active) {
139
val |= (1 << 8);
140
}
141
- if (s->vectors[ARMV7M_EXCP_PENDSV].active) {
142
- val |= (1 << 10);
143
- }
144
- if (s->vectors[ARMV7M_EXCP_SYSTICK].active) {
145
- val |= (1 << 11);
146
- }
147
- if (s->vectors[ARMV7M_EXCP_USAGE].pending) {
148
- val |= (1 << 12);
149
- }
150
- if (s->vectors[ARMV7M_EXCP_MEM].pending) {
151
- val |= (1 << 13);
152
- }
153
- if (s->vectors[ARMV7M_EXCP_BUS].pending) {
154
- val |= (1 << 14);
155
- }
156
- if (s->vectors[ARMV7M_EXCP_SVC].pending) {
157
- val |= (1 << 15);
158
- }
159
- if (s->vectors[ARMV7M_EXCP_MEM].enabled) {
160
- val |= (1 << 16);
161
- }
162
- if (s->vectors[ARMV7M_EXCP_BUS].enabled) {
163
- val |= (1 << 17);
164
- }
165
- if (s->vectors[ARMV7M_EXCP_USAGE].enabled) {
166
- val |= (1 << 18);
167
- }
168
return val;
169
case 0xd28: /* Configurable Fault Status. */
170
/* The BFSR bits [15:8] are shared between security states
171
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
172
173
cpu->env.v7m.ccr[attrs.secure] = value;
174
break;
175
- case 0xd24: /* System Handler Control. */
176
- s->vectors[ARMV7M_EXCP_MEM].active = (value & (1 << 0)) != 0;
177
- s->vectors[ARMV7M_EXCP_BUS].active = (value & (1 << 1)) != 0;
178
- s->vectors[ARMV7M_EXCP_USAGE].active = (value & (1 << 3)) != 0;
179
- s->vectors[ARMV7M_EXCP_SVC].active = (value & (1 << 7)) != 0;
180
+ case 0xd24: /* System Handler Control and State (SHCSR) */
181
+ if (attrs.secure) {
182
+ s->sec_vectors[ARMV7M_EXCP_MEM].active = (value & (1 << 0)) != 0;
183
+ /* Secure HardFault active bit cannot be written */
184
+ s->sec_vectors[ARMV7M_EXCP_USAGE].active = (value & (1 << 3)) != 0;
185
+ s->sec_vectors[ARMV7M_EXCP_SVC].active = (value & (1 << 7)) != 0;
186
+ s->sec_vectors[ARMV7M_EXCP_PENDSV].active =
187
+ (value & (1 << 10)) != 0;
188
+ s->sec_vectors[ARMV7M_EXCP_SYSTICK].active =
189
+ (value & (1 << 11)) != 0;
190
+ s->sec_vectors[ARMV7M_EXCP_USAGE].pending =
191
+ (value & (1 << 12)) != 0;
192
+ s->sec_vectors[ARMV7M_EXCP_MEM].pending = (value & (1 << 13)) != 0;
193
+ s->sec_vectors[ARMV7M_EXCP_SVC].pending = (value & (1 << 15)) != 0;
194
+ s->sec_vectors[ARMV7M_EXCP_MEM].enabled = (value & (1 << 16)) != 0;
195
+ s->sec_vectors[ARMV7M_EXCP_BUS].enabled = (value & (1 << 17)) != 0;
196
+ s->sec_vectors[ARMV7M_EXCP_USAGE].enabled =
197
+ (value & (1 << 18)) != 0;
198
+ /* SecureFault not banked, but RAZ/WI to NS */
199
+ s->vectors[ARMV7M_EXCP_SECURE].active = (value & (1 << 4)) != 0;
200
+ s->vectors[ARMV7M_EXCP_SECURE].enabled = (value & (1 << 19)) != 0;
201
+ s->vectors[ARMV7M_EXCP_SECURE].pending = (value & (1 << 20)) != 0;
202
+ } else {
203
+ s->vectors[ARMV7M_EXCP_MEM].active = (value & (1 << 0)) != 0;
204
+ if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
205
+ /* HARDFAULTPENDED is not present in v7M */
206
+ s->vectors[ARMV7M_EXCP_HARD].pending = (value & (1 << 21)) != 0;
207
+ }
208
+ s->vectors[ARMV7M_EXCP_USAGE].active = (value & (1 << 3)) != 0;
209
+ s->vectors[ARMV7M_EXCP_SVC].active = (value & (1 << 7)) != 0;
210
+ s->vectors[ARMV7M_EXCP_PENDSV].active = (value & (1 << 10)) != 0;
211
+ s->vectors[ARMV7M_EXCP_SYSTICK].active = (value & (1 << 11)) != 0;
212
+ s->vectors[ARMV7M_EXCP_USAGE].pending = (value & (1 << 12)) != 0;
213
+ s->vectors[ARMV7M_EXCP_MEM].pending = (value & (1 << 13)) != 0;
214
+ s->vectors[ARMV7M_EXCP_SVC].pending = (value & (1 << 15)) != 0;
215
+ s->vectors[ARMV7M_EXCP_MEM].enabled = (value & (1 << 16)) != 0;
216
+ s->vectors[ARMV7M_EXCP_USAGE].enabled = (value & (1 << 18)) != 0;
217
+ }
218
+ if (attrs.secure || (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
219
+ s->vectors[ARMV7M_EXCP_BUS].active = (value & (1 << 1)) != 0;
220
+ s->vectors[ARMV7M_EXCP_BUS].pending = (value & (1 << 14)) != 0;
221
+ s->vectors[ARMV7M_EXCP_BUS].enabled = (value & (1 << 17)) != 0;
222
+ }
223
+ /* NMIACT can only be written if the write is of a zero, with
224
+ * BFHFNMINS 1, and by the CPU in secure state via the NS alias.
225
+ */
226
+ if (!attrs.secure && cpu->env.v7m.secure &&
227
+ (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) &&
228
+ (value & (1 << 5)) == 0) {
229
+ s->vectors[ARMV7M_EXCP_NMI].active = 0;
230
+ }
231
+ /* HARDFAULTACT can only be written if the write is of a zero
232
+ * to the non-secure HardFault state by the CPU in secure state.
233
+ * The only case where we can be targeting the non-secure HF state
234
+ * when in secure state is if this is a write via the NS alias
235
+ * and BFHFNMINS is 1.
236
+ */
237
+ if (!attrs.secure && cpu->env.v7m.secure &&
238
+ (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) &&
239
+ (value & (1 << 2)) == 0) {
240
+ s->vectors[ARMV7M_EXCP_HARD].active = 0;
241
+ }
242
+
243
+ /* TODO: this is RAZ/WI from NS if DEMCR.SDME is set */
244
s->vectors[ARMV7M_EXCP_DEBUG].active = (value & (1 << 8)) != 0;
245
- s->vectors[ARMV7M_EXCP_PENDSV].active = (value & (1 << 10)) != 0;
246
- s->vectors[ARMV7M_EXCP_SYSTICK].active = (value & (1 << 11)) != 0;
247
- s->vectors[ARMV7M_EXCP_USAGE].pending = (value & (1 << 12)) != 0;
248
- s->vectors[ARMV7M_EXCP_MEM].pending = (value & (1 << 13)) != 0;
249
- s->vectors[ARMV7M_EXCP_BUS].pending = (value & (1 << 14)) != 0;
250
- s->vectors[ARMV7M_EXCP_SVC].pending = (value & (1 << 15)) != 0;
251
- s->vectors[ARMV7M_EXCP_MEM].enabled = (value & (1 << 16)) != 0;
252
- s->vectors[ARMV7M_EXCP_BUS].enabled = (value & (1 << 17)) != 0;
253
- s->vectors[ARMV7M_EXCP_USAGE].enabled = (value & (1 << 18)) != 0;
254
nvic_irq_update(s);
255
break;
256
case 0xd28: /* Configurable Fault Status. */
257
--
49
--
258
2.7.4
50
2.25.1
259
260
diff view generated by jsdifflib
1
The ICSR NVIC register is banked for v8M. This doesn't
1
From: Richard Henderson <richard.henderson@linaro.org>
2
require any new state, but it does mean that some bits
3
are controlled by BFHNFNMINS and some bits must work
4
with the correct banked exception. There is also a new
5
in v8M PENDNMICLR bit.
6
2
3
This feature is AArch64 only, and applies to physical SErrors,
4
which QEMU does not implement, thus the feature is a nop.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220506180242.216785-19-richard.henderson@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 1505240046-11454-18-git-send-email-peter.maydell@linaro.org
10
---
10
---
11
hw/intc/armv7m_nvic.c | 45 ++++++++++++++++++++++++++++++++-------------
11
docs/system/arm/emulation.rst | 1 +
12
1 file changed, 32 insertions(+), 13 deletions(-)
12
target/arm/cpu64.c | 1 +
13
2 files changed, 2 insertions(+)
13
14
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
15
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/armv7m_nvic.c
17
--- a/docs/system/arm/emulation.rst
17
+++ b/hw/intc/armv7m_nvic.c
18
+++ b/docs/system/arm/emulation.rst
18
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
19
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
19
}
20
- FEAT_FlagM2 (Enhancements to flag manipulation instructions)
20
case 0xd00: /* CPUID Base. */
21
- FEAT_HPDS (Hierarchical permission disables)
21
return cpu->midr;
22
- FEAT_I8MM (AArch64 Int8 matrix multiplication instructions)
22
- case 0xd04: /* Interrupt Control State. */
23
+- FEAT_IESB (Implicit error synchronization event)
23
+ case 0xd04: /* Interrupt Control State (ICSR) */
24
- FEAT_JSCVT (JavaScript conversion instructions)
24
/* VECTACTIVE */
25
- FEAT_LOR (Limited ordering regions)
25
val = cpu->env.v7m.exception;
26
- FEAT_LPA (Large Physical Address space)
26
/* VECTPENDING */
27
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
27
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
28
index XXXXXXX..XXXXXXX 100644
28
if (nvic_rettobase(s)) {
29
--- a/target/arm/cpu64.c
29
val |= (1 << 11);
30
+++ b/target/arm/cpu64.c
30
}
31
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
31
- /* PENDSTSET */
32
t = cpu->isar.id_aa64mmfr2;
32
- if (s->vectors[ARMV7M_EXCP_SYSTICK].pending) {
33
t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* FEAT_TTCNP */
33
- val |= (1 << 26);
34
t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); /* FEAT_UAO */
34
- }
35
+ t = FIELD_DP64(t, ID_AA64MMFR2, IESB, 1); /* FEAT_IESB */
35
- /* PENDSVSET */
36
t = FIELD_DP64(t, ID_AA64MMFR2, VARANGE, 1); /* FEAT_LVA */
36
- if (s->vectors[ARMV7M_EXCP_PENDSV].pending) {
37
t = FIELD_DP64(t, ID_AA64MMFR2, ST, 1); /* FEAT_TTST */
37
- val |= (1 << 28);
38
t = FIELD_DP64(t, ID_AA64MMFR2, TTL, 1); /* FEAT_TTL */
38
+ if (attrs.secure) {
39
+ /* PENDSTSET */
40
+ if (s->sec_vectors[ARMV7M_EXCP_SYSTICK].pending) {
41
+ val |= (1 << 26);
42
+ }
43
+ /* PENDSVSET */
44
+ if (s->sec_vectors[ARMV7M_EXCP_PENDSV].pending) {
45
+ val |= (1 << 28);
46
+ }
47
+ } else {
48
+ /* PENDSTSET */
49
+ if (s->vectors[ARMV7M_EXCP_SYSTICK].pending) {
50
+ val |= (1 << 26);
51
+ }
52
+ /* PENDSVSET */
53
+ if (s->vectors[ARMV7M_EXCP_PENDSV].pending) {
54
+ val |= (1 << 28);
55
+ }
56
}
57
/* NMIPENDSET */
58
- if (s->vectors[ARMV7M_EXCP_NMI].pending) {
59
+ if ((cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) &&
60
+ s->vectors[ARMV7M_EXCP_NMI].pending) {
61
val |= (1 << 31);
62
}
63
- /* ISRPREEMPT not implemented */
64
+ /* ISRPREEMPT: RES0 when halting debug not implemented */
65
+ /* STTNS: RES0 for the Main Extension */
66
return val;
67
case 0xd08: /* Vector Table Offset. */
68
return cpu->env.v7m.vecbase[attrs.secure];
69
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
70
nvic_irq_update(s);
71
break;
72
}
73
- case 0xd04: /* Interrupt Control State. */
74
- if (value & (1 << 31)) {
75
- armv7m_nvic_set_pending(s, ARMV7M_EXCP_NMI, false);
76
+ case 0xd04: /* Interrupt Control State (ICSR) */
77
+ if (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
78
+ if (value & (1 << 31)) {
79
+ armv7m_nvic_set_pending(s, ARMV7M_EXCP_NMI, false);
80
+ } else if (value & (1 << 30) &&
81
+ arm_feature(&cpu->env, ARM_FEATURE_V8)) {
82
+ /* PENDNMICLR didn't exist in v7M */
83
+ armv7m_nvic_clear_pending(s, ARMV7M_EXCP_NMI, false);
84
+ }
85
}
86
if (value & (1 << 28)) {
87
armv7m_nvic_set_pending(s, ARMV7M_EXCP_PENDSV, attrs.secure);
88
--
39
--
89
2.7.4
40
2.25.1
90
91
diff view generated by jsdifflib
1
When escalating to HardFault, we must go into Lockup if we
1
From: Richard Henderson <richard.henderson@linaro.org>
2
can't take the synchronous HardFault because the current
3
execution priority is already at or below the priority of
4
HardFault. In v7M HF is always priority -1 so a simple < 0
5
comparison sufficed; in v8M the priority of HardFault can
6
vary depending on whether it is a Secure or NonSecure
7
HardFault, so we must check against the priority of the
8
HardFault exception vector we're about to use.
9
2
3
This extension concerns branch speculation, which TCG does
4
not implement. Thus we can trivially enable this feature.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220506180242.216785-20-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
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 1505240046-11454-13-git-send-email-peter.maydell@linaro.org
13
---
10
---
14
hw/intc/armv7m_nvic.c | 23 ++++++++++++-----------
11
docs/system/arm/emulation.rst | 1 +
15
1 file changed, 12 insertions(+), 11 deletions(-)
12
target/arm/cpu64.c | 1 +
13
target/arm/cpu_tcg.c | 1 +
14
3 files changed, 3 insertions(+)
16
15
17
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.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/intc/armv7m_nvic.c
18
--- a/docs/system/arm/emulation.rst
20
+++ b/hw/intc/armv7m_nvic.c
19
+++ b/docs/system/arm/emulation.rst
21
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure)
20
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
22
}
21
- FEAT_BBM at level 2 (Translation table break-before-make levels)
23
22
- FEAT_BF16 (AArch64 BFloat16 instructions)
24
if (escalate) {
23
- FEAT_BTI (Branch Target Identification)
25
- if (running < 0) {
24
+- FEAT_CSV2 (Cache speculation variant 2)
26
- /* We want to escalate to HardFault but we can't take a
25
- FEAT_DIT (Data Independent Timing instructions)
27
- * synchronous HardFault at this point either. This is a
26
- FEAT_DPB (DC CVAP instruction)
28
- * Lockup condition due to a guest bug. We don't model
27
- FEAT_Debugv8p2 (Debug changes for v8.2)
29
- * Lockup, so report via cpu_abort() instead.
28
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
30
- */
29
index XXXXXXX..XXXXXXX 100644
31
- cpu_abort(&s->cpu->parent_obj,
30
--- a/target/arm/cpu64.c
32
- "Lockup: can't escalate %d to HardFault "
31
+++ b/target/arm/cpu64.c
33
- "(current priority %d)\n", irq, running);
32
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
34
- }
33
t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
35
34
t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */
36
- /* We can do the escalation, so we take HardFault instead.
35
t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */
37
+ /* We need to escalate this exception to a synchronous HardFault.
36
+ t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 1); /* FEAT_CSV2 */
38
* If BFHFNMINS is set then we escalate to the banked HF for
37
cpu->isar.id_aa64pfr0 = t;
39
* the target security state of the original exception; otherwise
38
40
* we take a Secure HardFault.
39
t = cpu->isar.id_aa64pfr1;
41
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure)
40
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
42
} else {
41
index XXXXXXX..XXXXXXX 100644
43
vec = &s->vectors[irq];
42
--- a/target/arm/cpu_tcg.c
44
}
43
+++ b/target/arm/cpu_tcg.c
45
+ if (running <= vec->prio) {
44
@@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu)
46
+ /* We want to escalate to HardFault but we can't take the
45
cpu->isar.id_mmfr4 = t;
47
+ * synchronous HardFault at this point either. This is a
46
48
+ * Lockup condition due to a guest bug. We don't model
47
t = cpu->isar.id_pfr0;
49
+ * Lockup, so report via cpu_abort() instead.
48
+ t = FIELD_DP32(t, ID_PFR0, CSV2, 2); /* FEAT_CVS2 */
50
+ */
49
t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */
51
+ cpu_abort(&s->cpu->parent_obj,
50
t = FIELD_DP32(t, ID_PFR0, RAS, 1); /* FEAT_RAS */
52
+ "Lockup: can't escalate %d to HardFault "
51
cpu->isar.id_pfr0 = t;
53
+ "(current priority %d)\n", irq, running);
54
+ }
55
+
56
/* HF may be banked but there is only one shared HFSR */
57
s->cpu->env.v7m.hfsr |= R_V7M_HFSR_FORCED_MASK;
58
}
59
--
52
--
60
2.7.4
53
2.25.1
61
62
diff view generated by jsdifflib
1
Now that we have a banked FAULTMASK register and banked exceptions,
1
From: Richard Henderson <richard.henderson@linaro.org>
2
we can implement the correct check in cpu_mmu_index() for whether
3
the MPU_CTRL.HFNMIENA bit's effect should apply. This bit causes
4
handlers which have requested a negative execution priority to run
5
with the MPU disabled. In v8M the test has to check this for the
6
current security state and so takes account of banking.
7
2
3
There is no branch prediction in TCG, therefore there is no
4
need to actually include the context number into the predictor.
5
Therefore all we need to do is add the state for SCXTNUM_ELx.
6
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220506180242.216785-21-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 1505240046-11454-17-git-send-email-peter.maydell@linaro.org
11
---
11
---
12
target/arm/cpu.h | 21 ++++++++++++++++-----
12
docs/system/arm/emulation.rst | 3 ++
13
hw/intc/armv7m_nvic.c | 29 +++++++++++++++++++++++++++++
13
target/arm/cpu.h | 16 +++++++++
14
2 files changed, 45 insertions(+), 5 deletions(-)
14
target/arm/cpu.c | 5 +++
15
target/arm/cpu64.c | 3 +-
16
target/arm/helper.c | 61 ++++++++++++++++++++++++++++++++++-
17
5 files changed, 86 insertions(+), 2 deletions(-)
15
18
19
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
20
index XXXXXXX..XXXXXXX 100644
21
--- a/docs/system/arm/emulation.rst
22
+++ b/docs/system/arm/emulation.rst
23
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
24
- FEAT_BF16 (AArch64 BFloat16 instructions)
25
- FEAT_BTI (Branch Target Identification)
26
- FEAT_CSV2 (Cache speculation variant 2)
27
+- FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
28
+- FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)
29
+- FEAT_CSV2_2 (Cache speculation variant 2, version 2)
30
- FEAT_DIT (Data Independent Timing instructions)
31
- FEAT_DPB (DC CVAP instruction)
32
- FEAT_Debugv8p2 (Debug changes for v8.2)
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
33
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
35
--- a/target/arm/cpu.h
19
+++ b/target/arm/cpu.h
36
+++ b/target/arm/cpu.h
20
@@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq);
37
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
21
* (v8M ARM ARM I_PKLD.)
38
ARMPACKey apdb;
22
*/
39
ARMPACKey apga;
23
int armv7m_nvic_raw_execution_priority(void *opaque);
40
} keys;
24
+/**
41
+
25
+ * armv7m_nvic_neg_prio_requested: return true if the requested execution
42
+ uint64_t scxtnum_el[4];
26
+ * priority is negative for the specified security state.
43
#endif
27
+ * @opaque: the NVIC
44
28
+ * @secure: the security state to test
45
#if defined(CONFIG_USER_ONLY)
29
+ * This corresponds to the pseudocode IsReqExecPriNeg().
46
@@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu);
30
+ */
47
#define SCTLR_WXN (1U << 19)
31
+#ifndef CONFIG_USER_ONLY
48
#define SCTLR_ST (1U << 20) /* up to ??, RAZ in v6 */
32
+bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure);
49
#define SCTLR_UWXN (1U << 20) /* v7 onward, AArch32 only */
33
+#else
50
+#define SCTLR_TSCXT (1U << 20) /* FEAT_CSV2_1p2, AArch64 only */
34
+static inline bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure)
51
#define SCTLR_FI (1U << 21) /* up to v7, v8 RES0 */
52
#define SCTLR_IESB (1U << 21) /* v8.2-IESB, AArch64 only */
53
#define SCTLR_U (1U << 22) /* up to v6, RAO in v7 */
54
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_dit(const ARMISARegisters *id)
55
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0;
56
}
57
58
+static inline bool isar_feature_aa64_scxtnum(const ARMISARegisters *id)
35
+{
59
+{
60
+ int key = FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, CSV2);
61
+ if (key >= 2) {
62
+ return true; /* FEAT_CSV2_2 */
63
+ }
64
+ if (key == 1) {
65
+ key = FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, CSV2_FRAC);
66
+ return key >= 2; /* FEAT_CSV2_1p2 */
67
+ }
36
+ return false;
68
+ return false;
37
+}
69
+}
38
+#endif
70
+
39
71
static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id)
40
/* Interface for defining coprocessor registers.
72
{
41
* Registers are defined in tables of arm_cp_reginfo structs
73
return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0;
42
@@ -XXX,XX +XXX,XX @@ static inline int cpu_mmu_index(CPUARMState *env, bool ifetch)
74
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
43
if (arm_feature(env, ARM_FEATURE_M)) {
75
index XXXXXXX..XXXXXXX 100644
44
ARMMMUIdx mmu_idx = el == 0 ? ARMMMUIdx_MUser : ARMMMUIdx_MPriv;
76
--- a/target/arm/cpu.c
45
77
+++ b/target/arm/cpu.c
46
- /* Execution priority is negative if FAULTMASK is set or
78
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev)
47
- * we're in a HardFault or NMI handler.
79
*/
48
- */
80
env->cp15.gcr_el1 = 0x1ffff;
49
- if ((env->v7m.exception > 0 && env->v7m.exception <= 3)
50
- || env->v7m.faultmask[env->v7m.secure]) {
51
+ if (armv7m_nvic_neg_prio_requested(env->nvic, env->v7m.secure)) {
52
mmu_idx = ARMMMUIdx_MNegPri;
53
}
81
}
54
82
+ /*
55
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
83
+ * Disable access to SCXTNUM_EL0 from CSV2_1p2.
56
index XXXXXXX..XXXXXXX 100644
84
+ * This is not yet exposed from the Linux kernel in any way.
57
--- a/hw/intc/armv7m_nvic.c
85
+ */
58
+++ b/hw/intc/armv7m_nvic.c
86
+ env->cp15.sctlr_el[1] |= SCTLR_TSCXT;
59
@@ -XXX,XX +XXX,XX @@ static inline int nvic_exec_prio(NVICState *s)
87
#else
60
return MIN(running, s->exception_prio);
88
/* Reset into the highest available EL */
61
}
89
if (arm_feature(env, ARM_FEATURE_EL3)) {
62
90
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
63
+bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure)
91
index XXXXXXX..XXXXXXX 100644
92
--- a/target/arm/cpu64.c
93
+++ b/target/arm/cpu64.c
94
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
95
t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
96
t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */
97
t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */
98
- t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 1); /* FEAT_CSV2 */
99
+ t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */
100
cpu->isar.id_aa64pfr0 = t;
101
102
t = cpu->isar.id_aa64pfr1;
103
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
104
* we do for EL2 with the virtualization=on property.
105
*/
106
t = FIELD_DP64(t, ID_AA64PFR1, MTE, 3); /* FEAT_MTE3 */
107
+ t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */
108
cpu->isar.id_aa64pfr1 = t;
109
110
t = cpu->isar.id_aa64mmfr0;
111
diff --git a/target/arm/helper.c b/target/arm/helper.c
112
index XXXXXXX..XXXXXXX 100644
113
--- a/target/arm/helper.c
114
+++ b/target/arm/helper.c
115
@@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
116
if (cpu_isar_feature(aa64_mte, cpu)) {
117
valid_mask |= SCR_ATA;
118
}
119
+ if (cpu_isar_feature(aa64_scxtnum, cpu)) {
120
+ valid_mask |= SCR_ENSCXT;
121
+ }
122
} else {
123
valid_mask &= ~(SCR_RW | SCR_ST);
124
if (cpu_isar_feature(aa32_ras, cpu)) {
125
@@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
126
if (cpu_isar_feature(aa64_mte, cpu)) {
127
valid_mask |= HCR_ATA | HCR_DCT | HCR_TID5;
128
}
129
+ if (cpu_isar_feature(aa64_scxtnum, cpu)) {
130
+ valid_mask |= HCR_ENSCXT;
131
+ }
132
}
133
134
/* Clear RES0 bits. */
135
@@ -XXX,XX +XXX,XX @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu)
136
{ K(3, 0, 5, 6, 0), K(3, 4, 5, 6, 0), K(3, 5, 5, 6, 0),
137
"TFSR_EL1", "TFSR_EL2", "TFSR_EL12", isar_feature_aa64_mte },
138
139
+ { K(3, 0, 13, 0, 7), K(3, 4, 13, 0, 7), K(3, 5, 13, 0, 7),
140
+ "SCXTNUM_EL1", "SCXTNUM_EL2", "SCXTNUM_EL12",
141
+ isar_feature_aa64_scxtnum },
142
+
143
/* TODO: ARMv8.2-SPE -- PMSCR_EL2 */
144
/* TODO: ARMv8.4-Trace -- TRFCR_EL2 */
145
};
146
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = {
147
},
148
};
149
150
-#endif
151
+static CPAccessResult access_scxtnum(CPUARMState *env, const ARMCPRegInfo *ri,
152
+ bool isread)
64
+{
153
+{
65
+ /* Return true if the requested execution priority is negative
154
+ uint64_t hcr = arm_hcr_el2_eff(env);
66
+ * for the specified security state, ie that security state
155
+ int el = arm_current_el(env);
67
+ * has an active NMI or HardFault or has set its FAULTMASK.
156
+
68
+ * Note that this is not the same as whether the execution
157
+ if (el == 0 && !((hcr & HCR_E2H) && (hcr & HCR_TGE))) {
69
+ * priority is actually negative (for instance AIRCR.PRIS may
158
+ if (env->cp15.sctlr_el[1] & SCTLR_TSCXT) {
70
+ * mean we don't allow FAULTMASK_NS to actually make the execution
159
+ if (hcr & HCR_TGE) {
71
+ * priority negative). Compare pseudocode IsReqExcPriNeg().
160
+ return CP_ACCESS_TRAP_EL2;
72
+ */
161
+ }
73
+ NVICState *s = opaque;
162
+ return CP_ACCESS_TRAP;
74
+
163
+ }
75
+ if (s->cpu->env.v7m.faultmask[secure]) {
164
+ } else if (el < 2 && (env->cp15.sctlr_el[2] & SCTLR_TSCXT)) {
76
+ return true;
165
+ return CP_ACCESS_TRAP_EL2;
77
+ }
166
+ }
78
+
167
+ if (el < 2 && arm_is_el2_enabled(env) && !(hcr & HCR_ENSCXT)) {
79
+ if (secure ? s->sec_vectors[ARMV7M_EXCP_HARD].active :
168
+ return CP_ACCESS_TRAP_EL2;
80
+ s->vectors[ARMV7M_EXCP_HARD].active) {
169
+ }
81
+ return true;
170
+ if (el < 3
82
+ }
171
+ && arm_feature(env, ARM_FEATURE_EL3)
83
+
172
+ && !(env->cp15.scr_el3 & SCR_ENSCXT)) {
84
+ if (s->vectors[ARMV7M_EXCP_NMI].active &&
173
+ return CP_ACCESS_TRAP_EL3;
85
+ exc_targets_secure(s, ARMV7M_EXCP_NMI) == secure) {
174
+ }
86
+ return true;
175
+ return CP_ACCESS_OK;
87
+ }
88
+
89
+ return false;
90
+}
176
+}
91
+
177
+
92
bool armv7m_nvic_can_take_pending_exception(void *opaque)
178
+static const ARMCPRegInfo scxtnum_reginfo[] = {
93
{
179
+ { .name = "SCXTNUM_EL0", .state = ARM_CP_STATE_AA64,
94
NVICState *s = opaque;
180
+ .opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 7,
181
+ .access = PL0_RW, .accessfn = access_scxtnum,
182
+ .fieldoffset = offsetof(CPUARMState, scxtnum_el[0]) },
183
+ { .name = "SCXTNUM_EL1", .state = ARM_CP_STATE_AA64,
184
+ .opc0 = 3, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 7,
185
+ .access = PL1_RW, .accessfn = access_scxtnum,
186
+ .fieldoffset = offsetof(CPUARMState, scxtnum_el[1]) },
187
+ { .name = "SCXTNUM_EL2", .state = ARM_CP_STATE_AA64,
188
+ .opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 7,
189
+ .access = PL2_RW, .accessfn = access_scxtnum,
190
+ .fieldoffset = offsetof(CPUARMState, scxtnum_el[2]) },
191
+ { .name = "SCXTNUM_EL3", .state = ARM_CP_STATE_AA64,
192
+ .opc0 = 3, .opc1 = 6, .crn = 13, .crm = 0, .opc2 = 7,
193
+ .access = PL3_RW,
194
+ .fieldoffset = offsetof(CPUARMState, scxtnum_el[3]) },
195
+};
196
+#endif /* TARGET_AARCH64 */
197
198
static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri,
199
bool isread)
200
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
201
define_arm_cp_regs(cpu, mte_tco_ro_reginfo);
202
define_arm_cp_regs(cpu, mte_el0_cacheop_reginfo);
203
}
204
+
205
+ if (cpu_isar_feature(aa64_scxtnum, cpu)) {
206
+ define_arm_cp_regs(cpu, scxtnum_reginfo);
207
+ }
208
#endif
209
210
if (cpu_isar_feature(any_predinv, cpu)) {
95
--
211
--
96
2.7.4
212
2.25.1
97
98
diff view generated by jsdifflib
1
In v7M, the fixed-priority exceptions are:
1
From: Richard Henderson <richard.henderson@linaro.org>
2
Reset: -3
3
NMI: -2
4
HardFault: -1
5
2
6
In v8M, this changes because Secure HardFault may need
3
This extension concerns cache speculation, which TCG does
7
to be prioritised above NMI:
4
not implement. Thus we can trivially enable this feature.
8
Reset: -4
9
Secure HardFault if AIRCR.BFHFNMINS == 1: -3
10
NMI: -2
11
Secure HardFault if AIRCR.BFHFNMINS == 0: -1
12
NonSecure HardFault: -1
13
5
14
Make these changes, including support for changing the
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
priority of Secure HardFault as AIRCR.BFHFNMINS changes.
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220506180242.216785-22-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
docs/system/arm/emulation.rst | 1 +
12
target/arm/cpu64.c | 1 +
13
target/arm/cpu_tcg.c | 1 +
14
3 files changed, 3 insertions(+)
16
15
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Message-id: 1505240046-11454-14-git-send-email-peter.maydell@linaro.org
20
---
21
hw/intc/armv7m_nvic.c | 22 +++++++++++++++++++---
22
1 file changed, 19 insertions(+), 3 deletions(-)
23
24
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
25
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/intc/armv7m_nvic.c
18
--- a/docs/system/arm/emulation.rst
27
+++ b/hw/intc/armv7m_nvic.c
19
+++ b/docs/system/arm/emulation.rst
28
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
20
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
29
(R_V7M_AIRCR_SYSRESETREQS_MASK |
21
- FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
30
R_V7M_AIRCR_BFHFNMINS_MASK |
22
- FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)
31
R_V7M_AIRCR_PRIS_MASK);
23
- FEAT_CSV2_2 (Cache speculation variant 2, version 2)
32
+ /* BFHFNMINS changes the priority of Secure HardFault */
24
+- FEAT_CSV3 (Cache speculation variant 3)
33
+ if (cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
25
- FEAT_DIT (Data Independent Timing instructions)
34
+ s->sec_vectors[ARMV7M_EXCP_HARD].prio = -3;
26
- FEAT_DPB (DC CVAP instruction)
35
+ } else {
27
- FEAT_Debugv8p2 (Debug changes for v8.2)
36
+ s->sec_vectors[ARMV7M_EXCP_HARD].prio = -1;
28
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
37
+ }
29
index XXXXXXX..XXXXXXX 100644
38
}
30
--- a/target/arm/cpu64.c
39
nvic_irq_update(s);
31
+++ b/target/arm/cpu64.c
40
}
32
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
41
@@ -XXX,XX +XXX,XX @@ static int nvic_post_load(void *opaque, int version_id)
33
t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1); /* FEAT_SEL2 */
42
{
34
t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */
43
NVICState *s = opaque;
35
t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */
44
unsigned i;
36
+ t = FIELD_DP64(t, ID_AA64PFR0, CSV3, 1); /* FEAT_CSV3 */
45
+ int resetprio;
37
cpu->isar.id_aa64pfr0 = t;
46
38
47
/* Check for out of range priority settings */
39
t = cpu->isar.id_aa64pfr1;
48
- if (s->vectors[ARMV7M_EXCP_RESET].prio != -3 ||
40
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
49
+ resetprio = arm_feature(&s->cpu->env, ARM_FEATURE_V8) ? -4 : -3;
41
index XXXXXXX..XXXXXXX 100644
50
+
42
--- a/target/arm/cpu_tcg.c
51
+ if (s->vectors[ARMV7M_EXCP_RESET].prio != resetprio ||
43
+++ b/target/arm/cpu_tcg.c
52
s->vectors[ARMV7M_EXCP_NMI].prio != -2 ||
44
@@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu)
53
s->vectors[ARMV7M_EXCP_HARD].prio != -1) {
45
cpu->isar.id_pfr0 = t;
54
return 1;
46
55
@@ -XXX,XX +XXX,XX @@ static int nvic_security_post_load(void *opaque, int version_id)
47
t = cpu->isar.id_pfr2;
56
int i;
48
+ t = FIELD_DP32(t, ID_PFR2, CSV3, 1); /* FEAT_CSV3 */
57
49
t = FIELD_DP32(t, ID_PFR2, SSBS, 1); /* FEAT_SSBS */
58
/* Check for out of range priority settings */
50
cpu->isar.id_pfr2 = t;
59
- if (s->sec_vectors[ARMV7M_EXCP_HARD].prio != -1) {
60
+ if (s->sec_vectors[ARMV7M_EXCP_HARD].prio != -1
61
+ && s->sec_vectors[ARMV7M_EXCP_HARD].prio != -3) {
62
+ /* We can't cross-check against AIRCR.BFHFNMINS as we don't know
63
+ * if the CPU state has been migrated yet; a mismatch won't
64
+ * cause the emulation to blow up, though.
65
+ */
66
return 1;
67
}
68
for (i = ARMV7M_EXCP_MEM; i < ARRAY_SIZE(s->sec_vectors); i++) {
69
@@ -XXX,XX +XXX,XX @@ static Property props_nvic[] = {
70
71
static void armv7m_nvic_reset(DeviceState *dev)
72
{
73
+ int resetprio;
74
NVICState *s = NVIC(dev);
75
76
s->vectors[ARMV7M_EXCP_NMI].enabled = 1;
77
@@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_reset(DeviceState *dev)
78
s->vectors[ARMV7M_EXCP_PENDSV].enabled = 1;
79
s->vectors[ARMV7M_EXCP_SYSTICK].enabled = 1;
80
81
- s->vectors[ARMV7M_EXCP_RESET].prio = -3;
82
+ resetprio = arm_feature(&s->cpu->env, ARM_FEATURE_V8) ? -4 : -3;
83
+ s->vectors[ARMV7M_EXCP_RESET].prio = resetprio;
84
s->vectors[ARMV7M_EXCP_NMI].prio = -2;
85
s->vectors[ARMV7M_EXCP_HARD].prio = -1;
86
51
87
--
52
--
88
2.7.4
53
2.25.1
89
90
diff view generated by jsdifflib
1
In the A64 decoder, we have a lot of references to section numbers
1
From: Richard Henderson <richard.henderson@linaro.org>
2
from version A.a of the v8A ARM ARM (DDI0487). This version of the
3
document is now long obsolete (we are currently on revision B.a),
4
and various intervening versions renumbered all the sections.
5
2
6
The most recent B.a version of the document doesn't assign
3
This extension concerns not merging memory access, which TCG does
7
section numbers at all to the individual instruction classes
4
not implement. Thus we can trivially enable this feature.
8
in the way that the various A.x versions did. The simplest thing
5
Add a comment to handle_hint for the DGH instruction, but no code.
9
to do is just to delete all the out of date C.x.x references.
10
6
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220506180242.216785-23-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
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
13
Message-id: 20170915150849.23557-1-peter.maydell@linaro.org
14
---
11
---
15
target/arm/translate-a64.c | 227 +++++++++++++++++++++++----------------------
12
docs/system/arm/emulation.rst | 1 +
16
1 file changed, 114 insertions(+), 113 deletions(-)
13
target/arm/cpu64.c | 1 +
14
target/arm/translate-a64.c | 1 +
15
3 files changed, 3 insertions(+)
17
16
17
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
18
index XXXXXXX..XXXXXXX 100644
19
--- a/docs/system/arm/emulation.rst
20
+++ b/docs/system/arm/emulation.rst
21
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
22
- FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)
23
- FEAT_CSV2_2 (Cache speculation variant 2, version 2)
24
- FEAT_CSV3 (Cache speculation variant 3)
25
+- FEAT_DGH (Data gathering hint)
26
- FEAT_DIT (Data Independent Timing instructions)
27
- FEAT_DPB (DC CVAP instruction)
28
- FEAT_Debugv8p2 (Debug changes for v8.2)
29
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/arm/cpu64.c
32
+++ b/target/arm/cpu64.c
33
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
34
t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1); /* FEAT_SB */
35
t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1); /* FEAT_SPECRES */
36
t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); /* FEAT_BF16 */
37
+ t = FIELD_DP64(t, ID_AA64ISAR1, DGH, 1); /* FEAT_DGH */
38
t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); /* FEAT_I8MM */
39
cpu->isar.id_aa64isar1 = t;
40
18
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
41
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
19
index XXXXXXX..XXXXXXX 100644
42
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/translate-a64.c
43
--- a/target/arm/translate-a64.c
21
+++ b/target/arm/translate-a64.c
44
+++ b/target/arm/translate-a64.c
22
@@ -XXX,XX +XXX,XX @@ static inline AArch64DecodeFn *lookup_disas_fn(const AArch64DecodeTable *table,
45
@@ -XXX,XX +XXX,XX @@ static void handle_hint(DisasContext *s, uint32_t insn,
23
}
46
break;
24
47
case 0b00100: /* SEV */
25
/*
48
case 0b00101: /* SEVL */
26
- * the instruction disassembly implemented here matches
49
+ case 0b00110: /* DGH */
27
- * the instruction encoding classifications in chapter 3 (C3)
50
/* we treat all as NOP at least for now */
28
- * of the ARM Architecture Reference Manual (DDI0487A_a)
51
break;
29
+ * The instruction disassembly implemented here matches
52
case 0b00111: /* XPACLRI */
30
+ * the instruction encoding classifications in chapter C4
31
+ * of the ARM Architecture Reference Manual (DDI0487B_a);
32
+ * classification names and decode diagrams here should generally
33
+ * match up with those in the manual.
34
*/
35
36
-/* C3.2.7 Unconditional branch (immediate)
37
+/* Unconditional branch (immediate)
38
* 31 30 26 25 0
39
* +----+-----------+-------------------------------------+
40
* | op | 0 0 1 0 1 | imm26 |
41
@@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_imm(DisasContext *s, uint32_t insn)
42
uint64_t addr = s->pc + sextract32(insn, 0, 26) * 4 - 4;
43
44
if (insn & (1U << 31)) {
45
- /* C5.6.26 BL Branch with link */
46
+ /* BL Branch with link */
47
tcg_gen_movi_i64(cpu_reg(s, 30), s->pc);
48
}
49
50
- /* C5.6.20 B Branch / C5.6.26 BL Branch with link */
51
+ /* B Branch / BL Branch with link */
52
gen_goto_tb(s, 0, addr);
53
}
54
55
-/* C3.2.1 Compare & branch (immediate)
56
+/* Compare and branch (immediate)
57
* 31 30 25 24 23 5 4 0
58
* +----+-------------+----+---------------------+--------+
59
* | sf | 0 1 1 0 1 0 | op | imm19 | Rt |
60
@@ -XXX,XX +XXX,XX @@ static void disas_comp_b_imm(DisasContext *s, uint32_t insn)
61
gen_goto_tb(s, 1, addr);
62
}
63
64
-/* C3.2.5 Test & branch (immediate)
65
+/* Test and branch (immediate)
66
* 31 30 25 24 23 19 18 5 4 0
67
* +----+-------------+----+-------+-------------+------+
68
* | b5 | 0 1 1 0 1 1 | op | b40 | imm14 | Rt |
69
@@ -XXX,XX +XXX,XX @@ static void disas_test_b_imm(DisasContext *s, uint32_t insn)
70
gen_goto_tb(s, 1, addr);
71
}
72
73
-/* C3.2.2 / C5.6.19 Conditional branch (immediate)
74
+/* Conditional branch (immediate)
75
* 31 25 24 23 5 4 3 0
76
* +---------------+----+---------------------+----+------+
77
* | 0 1 0 1 0 1 0 | o1 | imm19 | o0 | cond |
78
@@ -XXX,XX +XXX,XX @@ static void disas_cond_b_imm(DisasContext *s, uint32_t insn)
79
}
80
}
81
82
-/* C5.6.68 HINT */
83
+/* HINT instruction group, including various allocated HINTs */
84
static void handle_hint(DisasContext *s, uint32_t insn,
85
unsigned int op1, unsigned int op2, unsigned int crm)
86
{
87
@@ -XXX,XX +XXX,XX @@ static void handle_sync(DisasContext *s, uint32_t insn,
88
}
89
}
90
91
-/* C5.6.130 MSR (immediate) - move immediate to processor state field */
92
+/* MSR (immediate) - move immediate to processor state field */
93
static void handle_msr_i(DisasContext *s, uint32_t insn,
94
unsigned int op1, unsigned int op2, unsigned int crm)
95
{
96
@@ -XXX,XX +XXX,XX @@ static void gen_set_nzcv(TCGv_i64 tcg_rt)
97
tcg_temp_free_i32(nzcv);
98
}
99
100
-/* C5.6.129 MRS - move from system register
101
- * C5.6.131 MSR (register) - move to system register
102
- * C5.6.204 SYS
103
- * C5.6.205 SYSL
104
+/* MRS - move from system register
105
+ * MSR (register) - move to system register
106
+ * SYS
107
+ * SYSL
108
* These are all essentially the same insn in 'read' and 'write'
109
* versions, with varying op0 fields.
110
*/
111
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
112
}
113
}
114
115
-/* C3.2.4 System
116
+/* System
117
* 31 22 21 20 19 18 16 15 12 11 8 7 5 4 0
118
* +---------------------+---+-----+-----+-------+-------+-----+------+
119
* | 1 1 0 1 0 1 0 1 0 0 | L | op0 | op1 | CRn | CRm | op2 | Rt |
120
@@ -XXX,XX +XXX,XX @@ static void disas_system(DisasContext *s, uint32_t insn)
121
return;
122
}
123
switch (crn) {
124
- case 2: /* C5.6.68 HINT */
125
+ case 2: /* HINT (including allocated hints like NOP, YIELD, etc) */
126
handle_hint(s, insn, op1, op2, crm);
127
break;
128
case 3: /* CLREX, DSB, DMB, ISB */
129
handle_sync(s, insn, op1, op2, crm);
130
break;
131
- case 4: /* C5.6.130 MSR (immediate) */
132
+ case 4: /* MSR (immediate) */
133
handle_msr_i(s, insn, op1, op2, crm);
134
break;
135
default:
136
@@ -XXX,XX +XXX,XX @@ static void disas_system(DisasContext *s, uint32_t insn)
137
handle_sys(s, insn, l, op0, op1, op2, crn, crm, rt);
138
}
139
140
-/* C3.2.3 Exception generation
141
+/* Exception generation
142
*
143
* 31 24 23 21 20 5 4 2 1 0
144
* +-----------------+-----+------------------------+-----+----+
145
@@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn)
146
}
147
}
148
149
-/* C3.2.7 Unconditional branch (register)
150
+/* Unconditional branch (register)
151
* 31 25 24 21 20 16 15 10 9 5 4 0
152
* +---------------+-------+-------+-------+------+-------+
153
* | 1 1 0 1 0 1 1 | opc | op2 | op3 | Rn | op4 |
154
@@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)
155
s->base.is_jmp = DISAS_JUMP;
156
}
157
158
-/* C3.2 Branches, exception generating and system instructions */
159
+/* Branches, exception generating and system instructions */
160
static void disas_b_exc_sys(DisasContext *s, uint32_t insn)
161
{
162
switch (extract32(insn, 25, 7)) {
163
@@ -XXX,XX +XXX,XX @@ static bool disas_ldst_compute_iss_sf(int size, bool is_signed, int opc)
164
return regsize == 64;
165
}
166
167
-/* C3.3.6 Load/store exclusive
168
+/* Load/store exclusive
169
*
170
* 31 30 29 24 23 22 21 20 16 15 14 10 9 5 4 0
171
* +-----+-------------+----+---+----+------+----+-------+------+------+
172
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn)
173
}
174
175
/*
176
- * C3.3.5 Load register (literal)
177
+ * Load register (literal)
178
*
179
* 31 30 29 27 26 25 24 23 5 4 0
180
* +-----+-------+---+-----+-------------------+-------+
181
@@ -XXX,XX +XXX,XX @@ static void disas_ld_lit(DisasContext *s, uint32_t insn)
182
}
183
184
/*
185
- * C5.6.80 LDNP (Load Pair - non-temporal hint)
186
- * C5.6.81 LDP (Load Pair - non vector)
187
- * C5.6.82 LDPSW (Load Pair Signed Word - non vector)
188
- * C5.6.176 STNP (Store Pair - non-temporal hint)
189
- * C5.6.177 STP (Store Pair - non vector)
190
- * C6.3.165 LDNP (Load Pair of SIMD&FP - non-temporal hint)
191
- * C6.3.165 LDP (Load Pair of SIMD&FP)
192
- * C6.3.284 STNP (Store Pair of SIMD&FP - non-temporal hint)
193
- * C6.3.284 STP (Store Pair of SIMD&FP)
194
+ * LDNP (Load Pair - non-temporal hint)
195
+ * LDP (Load Pair - non vector)
196
+ * LDPSW (Load Pair Signed Word - non vector)
197
+ * STNP (Store Pair - non-temporal hint)
198
+ * STP (Store Pair - non vector)
199
+ * LDNP (Load Pair of SIMD&FP - non-temporal hint)
200
+ * LDP (Load Pair of SIMD&FP)
201
+ * STNP (Store Pair of SIMD&FP - non-temporal hint)
202
+ * STP (Store Pair of SIMD&FP)
203
*
204
* 31 30 29 27 26 25 24 23 22 21 15 14 10 9 5 4 0
205
* +-----+-------+---+---+-------+---+-----------------------------+
206
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_pair(DisasContext *s, uint32_t insn)
207
}
208
209
/*
210
- * C3.3.8 Load/store (immediate post-indexed)
211
- * C3.3.9 Load/store (immediate pre-indexed)
212
- * C3.3.12 Load/store (unscaled immediate)
213
+ * Load/store (immediate post-indexed)
214
+ * Load/store (immediate pre-indexed)
215
+ * Load/store (unscaled immediate)
216
*
217
* 31 30 29 27 26 25 24 23 22 21 20 12 11 10 9 5 4 0
218
* +----+-------+---+-----+-----+---+--------+-----+------+------+
219
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_imm9(DisasContext *s, uint32_t insn,
220
}
221
222
/*
223
- * C3.3.10 Load/store (register offset)
224
+ * Load/store (register offset)
225
*
226
* 31 30 29 27 26 25 24 23 22 21 20 16 15 13 12 11 10 9 5 4 0
227
* +----+-------+---+-----+-----+---+------+-----+--+-----+----+----+
228
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg_roffset(DisasContext *s, uint32_t insn,
229
}
230
231
/*
232
- * C3.3.13 Load/store (unsigned immediate)
233
+ * Load/store (unsigned immediate)
234
*
235
* 31 30 29 27 26 25 24 23 22 21 10 9 5
236
* +----+-------+---+-----+-----+------------+-------+------+
237
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_reg(DisasContext *s, uint32_t insn)
238
}
239
}
240
241
-/* C3.3.1 AdvSIMD load/store multiple structures
242
+/* AdvSIMD load/store multiple structures
243
*
244
* 31 30 29 23 22 21 16 15 12 11 10 9 5 4 0
245
* +---+---+---------------+---+-------------+--------+------+------+------+
246
* | 0 | Q | 0 0 1 1 0 0 0 | L | 0 0 0 0 0 0 | opcode | size | Rn | Rt |
247
* +---+---+---------------+---+-------------+--------+------+------+------+
248
*
249
- * C3.3.2 AdvSIMD load/store multiple structures (post-indexed)
250
+ * AdvSIMD load/store multiple structures (post-indexed)
251
*
252
* 31 30 29 23 22 21 20 16 15 12 11 10 9 5 4 0
253
* +---+---+---------------+---+---+---------+--------+------+------+------+
254
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_multiple_struct(DisasContext *s, uint32_t insn)
255
tcg_temp_free_i64(tcg_addr);
256
}
257
258
-/* C3.3.3 AdvSIMD load/store single structure
259
+/* AdvSIMD load/store single structure
260
*
261
* 31 30 29 23 22 21 20 16 15 13 12 11 10 9 5 4 0
262
* +---+---+---------------+-----+-----------+-----+---+------+------+------+
263
* | 0 | Q | 0 0 1 1 0 1 0 | L R | 0 0 0 0 0 | opc | S | size | Rn | Rt |
264
* +---+---+---------------+-----+-----------+-----+---+------+------+------+
265
*
266
- * C3.3.4 AdvSIMD load/store single structure (post-indexed)
267
+ * AdvSIMD load/store single structure (post-indexed)
268
*
269
* 31 30 29 23 22 21 20 16 15 13 12 11 10 9 5 4 0
270
* +---+---+---------------+-----+-----------+-----+---+------+------+------+
271
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_single_struct(DisasContext *s, uint32_t insn)
272
tcg_temp_free_i64(tcg_addr);
273
}
274
275
-/* C3.3 Loads and stores */
276
+/* Loads and stores */
277
static void disas_ldst(DisasContext *s, uint32_t insn)
278
{
279
switch (extract32(insn, 24, 6)) {
280
@@ -XXX,XX +XXX,XX @@ static void disas_ldst(DisasContext *s, uint32_t insn)
281
}
282
}
283
284
-/* C3.4.6 PC-rel. addressing
285
+/* PC-rel. addressing
286
* 31 30 29 28 24 23 5 4 0
287
* +----+-------+-----------+-------------------+------+
288
* | op | immlo | 1 0 0 0 0 | immhi | Rd |
289
@@ -XXX,XX +XXX,XX @@ static void disas_pc_rel_adr(DisasContext *s, uint32_t insn)
290
}
291
292
/*
293
- * C3.4.1 Add/subtract (immediate)
294
+ * Add/subtract (immediate)
295
*
296
* 31 30 29 28 24 23 22 21 10 9 5 4 0
297
* +--+--+--+-----------+-----+-------------+-----+-----+
298
@@ -XXX,XX +XXX,XX @@ static bool logic_imm_decode_wmask(uint64_t *result, unsigned int immn,
299
return true;
300
}
301
302
-/* C3.4.4 Logical (immediate)
303
+/* Logical (immediate)
304
* 31 30 29 28 23 22 21 16 15 10 9 5 4 0
305
* +----+-----+-------------+---+------+------+------+------+
306
* | sf | opc | 1 0 0 1 0 0 | N | immr | imms | Rn | Rd |
307
@@ -XXX,XX +XXX,XX @@ static void disas_logic_imm(DisasContext *s, uint32_t insn)
308
}
309
310
/*
311
- * C3.4.5 Move wide (immediate)
312
+ * Move wide (immediate)
313
*
314
* 31 30 29 28 23 22 21 20 5 4 0
315
* +--+-----+-------------+-----+----------------+------+
316
@@ -XXX,XX +XXX,XX @@ static void disas_movw_imm(DisasContext *s, uint32_t insn)
317
}
318
}
319
320
-/* C3.4.2 Bitfield
321
+/* Bitfield
322
* 31 30 29 28 23 22 21 16 15 10 9 5 4 0
323
* +----+-----+-------------+---+------+------+------+------+
324
* | sf | opc | 1 0 0 1 1 0 | N | immr | imms | Rn | Rd |
325
@@ -XXX,XX +XXX,XX @@ static void disas_bitfield(DisasContext *s, uint32_t insn)
326
}
327
}
328
329
-/* C3.4.3 Extract
330
+/* Extract
331
* 31 30 29 28 23 22 21 20 16 15 10 9 5 4 0
332
* +----+------+-------------+---+----+------+--------+------+------+
333
* | sf | op21 | 1 0 0 1 1 1 | N | o0 | Rm | imms | Rn | Rd |
334
@@ -XXX,XX +XXX,XX @@ static void disas_extract(DisasContext *s, uint32_t insn)
335
}
336
}
337
338
-/* C3.4 Data processing - immediate */
339
+/* Data processing - immediate */
340
static void disas_data_proc_imm(DisasContext *s, uint32_t insn)
341
{
342
switch (extract32(insn, 23, 6)) {
343
@@ -XXX,XX +XXX,XX @@ static void shift_reg_imm(TCGv_i64 dst, TCGv_i64 src, int sf,
344
}
345
}
346
347
-/* C3.5.10 Logical (shifted register)
348
+/* Logical (shifted register)
349
* 31 30 29 28 24 23 22 21 20 16 15 10 9 5 4 0
350
* +----+-----+-----------+-------+---+------+--------+------+------+
351
* | sf | opc | 0 1 0 1 0 | shift | N | Rm | imm6 | Rn | Rd |
352
@@ -XXX,XX +XXX,XX @@ static void disas_logic_reg(DisasContext *s, uint32_t insn)
353
}
354
355
/*
356
- * C3.5.1 Add/subtract (extended register)
357
+ * Add/subtract (extended register)
358
*
359
* 31|30|29|28 24|23 22|21|20 16|15 13|12 10|9 5|4 0|
360
* +--+--+--+-----------+-----+--+-------+------+------+----+----+
361
@@ -XXX,XX +XXX,XX @@ static void disas_add_sub_ext_reg(DisasContext *s, uint32_t insn)
362
}
363
364
/*
365
- * C3.5.2 Add/subtract (shifted register)
366
+ * Add/subtract (shifted register)
367
*
368
* 31 30 29 28 24 23 22 21 20 16 15 10 9 5 4 0
369
* +--+--+--+-----------+-----+--+-------+---------+------+------+
370
@@ -XXX,XX +XXX,XX @@ static void disas_add_sub_reg(DisasContext *s, uint32_t insn)
371
tcg_temp_free_i64(tcg_result);
372
}
373
374
-/* C3.5.9 Data-processing (3 source)
375
-
376
- 31 30 29 28 24 23 21 20 16 15 14 10 9 5 4 0
377
- +--+------+-----------+------+------+----+------+------+------+
378
- |sf| op54 | 1 1 0 1 1 | op31 | Rm | o0 | Ra | Rn | Rd |
379
- +--+------+-----------+------+------+----+------+------+------+
380
-
381
+/* Data-processing (3 source)
382
+ *
383
+ * 31 30 29 28 24 23 21 20 16 15 14 10 9 5 4 0
384
+ * +--+------+-----------+------+------+----+------+------+------+
385
+ * |sf| op54 | 1 1 0 1 1 | op31 | Rm | o0 | Ra | Rn | Rd |
386
+ * +--+------+-----------+------+------+----+------+------+------+
387
*/
388
static void disas_data_proc_3src(DisasContext *s, uint32_t insn)
389
{
390
@@ -XXX,XX +XXX,XX @@ static void disas_data_proc_3src(DisasContext *s, uint32_t insn)
391
tcg_temp_free_i64(tcg_tmp);
392
}
393
394
-/* C3.5.3 - Add/subtract (with carry)
395
+/* Add/subtract (with carry)
396
* 31 30 29 28 27 26 25 24 23 22 21 20 16 15 10 9 5 4 0
397
* +--+--+--+------------------------+------+---------+------+-----+
398
* |sf|op| S| 1 1 0 1 0 0 0 0 | rm | opcode2 | Rn | Rd |
399
@@ -XXX,XX +XXX,XX @@ static void disas_adc_sbc(DisasContext *s, uint32_t insn)
400
}
401
}
402
403
-/* C3.5.4 - C3.5.5 Conditional compare (immediate / register)
404
+/* Conditional compare (immediate / register)
405
* 31 30 29 28 27 26 25 24 23 22 21 20 16 15 12 11 10 9 5 4 3 0
406
* +--+--+--+------------------------+--------+------+----+--+------+--+-----+
407
* |sf|op| S| 1 1 0 1 0 0 1 0 |imm5/rm | cond |i/r |o2| Rn |o3|nzcv |
408
@@ -XXX,XX +XXX,XX @@ static void disas_cc(DisasContext *s, uint32_t insn)
409
tcg_temp_free_i32(tcg_t2);
410
}
411
412
-/* C3.5.6 Conditional select
413
+/* Conditional select
414
* 31 30 29 28 21 20 16 15 12 11 10 9 5 4 0
415
* +----+----+---+-----------------+------+------+-----+------+------+
416
* | sf | op | S | 1 1 0 1 0 1 0 0 | Rm | cond | op2 | Rn | Rd |
417
@@ -XXX,XX +XXX,XX @@ static void handle_rbit(DisasContext *s, unsigned int sf,
418
}
419
}
420
421
-/* C5.6.149 REV with sf==1, opcode==3 ("REV64") */
422
+/* REV with sf==1, opcode==3 ("REV64") */
423
static void handle_rev64(DisasContext *s, unsigned int sf,
424
unsigned int rn, unsigned int rd)
425
{
426
@@ -XXX,XX +XXX,XX @@ static void handle_rev64(DisasContext *s, unsigned int sf,
427
tcg_gen_bswap64_i64(cpu_reg(s, rd), cpu_reg(s, rn));
428
}
429
430
-/* C5.6.149 REV with sf==0, opcode==2
431
- * C5.6.151 REV32 (sf==1, opcode==2)
432
+/* REV with sf==0, opcode==2
433
+ * REV32 (sf==1, opcode==2)
434
*/
435
static void handle_rev32(DisasContext *s, unsigned int sf,
436
unsigned int rn, unsigned int rd)
437
@@ -XXX,XX +XXX,XX @@ static void handle_rev32(DisasContext *s, unsigned int sf,
438
}
439
}
440
441
-/* C5.6.150 REV16 (opcode==1) */
442
+/* REV16 (opcode==1) */
443
static void handle_rev16(DisasContext *s, unsigned int sf,
444
unsigned int rn, unsigned int rd)
445
{
446
@@ -XXX,XX +XXX,XX @@ static void handle_rev16(DisasContext *s, unsigned int sf,
447
tcg_temp_free_i64(tcg_tmp);
448
}
449
450
-/* C3.5.7 Data-processing (1 source)
451
+/* Data-processing (1 source)
452
* 31 30 29 28 21 20 16 15 10 9 5 4 0
453
* +----+---+---+-----------------+---------+--------+------+------+
454
* | sf | 1 | S | 1 1 0 1 0 1 1 0 | opcode2 | opcode | Rn | Rd |
455
@@ -XXX,XX +XXX,XX @@ static void handle_div(DisasContext *s, bool is_signed, unsigned int sf,
456
}
457
}
458
459
-/* C5.6.115 LSLV, C5.6.118 LSRV, C5.6.17 ASRV, C5.6.154 RORV */
460
+/* LSLV, LSRV, ASRV, RORV */
461
static void handle_shift_reg(DisasContext *s,
462
enum a64_shift_type shift_type, unsigned int sf,
463
unsigned int rm, unsigned int rn, unsigned int rd)
464
@@ -XXX,XX +XXX,XX @@ static void handle_crc32(DisasContext *s,
465
tcg_temp_free_i32(tcg_bytes);
466
}
467
468
-/* C3.5.8 Data-processing (2 source)
469
+/* Data-processing (2 source)
470
* 31 30 29 28 21 20 16 15 10 9 5 4 0
471
* +----+---+---+-----------------+------+--------+------+------+
472
* | sf | 0 | S | 1 1 0 1 0 1 1 0 | Rm | opcode | Rn | Rd |
473
@@ -XXX,XX +XXX,XX @@ static void disas_data_proc_2src(DisasContext *s, uint32_t insn)
474
}
475
}
476
477
-/* C3.5 Data processing - register */
478
+/* Data processing - register */
479
static void disas_data_proc_reg(DisasContext *s, uint32_t insn)
480
{
481
switch (extract32(insn, 24, 5)) {
482
@@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, bool is_double,
483
tcg_temp_free_i64(tcg_flags);
484
}
485
486
-/* C3.6.22 Floating point compare
487
+/* Floating point compare
488
* 31 30 29 28 24 23 22 21 20 16 15 14 13 10 9 5 4 0
489
* +---+---+---+-----------+------+---+------+-----+---------+------+-------+
490
* | M | 0 | S | 1 1 1 1 0 | type | 1 | Rm | op | 1 0 0 0 | Rn | op2 |
491
@@ -XXX,XX +XXX,XX @@ static void disas_fp_compare(DisasContext *s, uint32_t insn)
492
handle_fp_compare(s, type, rn, rm, opc & 1, opc & 2);
493
}
494
495
-/* C3.6.23 Floating point conditional compare
496
+/* Floating point conditional compare
497
* 31 30 29 28 24 23 22 21 20 16 15 12 11 10 9 5 4 3 0
498
* +---+---+---+-----------+------+---+------+------+-----+------+----+------+
499
* | M | 0 | S | 1 1 1 1 0 | type | 1 | Rm | cond | 0 1 | Rn | op | nzcv |
500
@@ -XXX,XX +XXX,XX @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn)
501
}
502
}
503
504
-/* C3.6.24 Floating point conditional select
505
+/* Floating point conditional select
506
* 31 30 29 28 24 23 22 21 20 16 15 12 11 10 9 5 4 0
507
* +---+---+---+-----------+------+---+------+------+-----+------+------+
508
* | M | 0 | S | 1 1 1 1 0 | type | 1 | Rm | cond | 1 1 | Rn | Rd |
509
@@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn)
510
tcg_temp_free_i64(t_true);
511
}
512
513
-/* C3.6.25 Floating-point data-processing (1 source) - single precision */
514
+/* Floating-point data-processing (1 source) - single precision */
515
static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn)
516
{
517
TCGv_ptr fpst;
518
@@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn)
519
tcg_temp_free_i32(tcg_res);
520
}
521
522
-/* C3.6.25 Floating-point data-processing (1 source) - double precision */
523
+/* Floating-point data-processing (1 source) - double precision */
524
static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn)
525
{
526
TCGv_ptr fpst;
527
@@ -XXX,XX +XXX,XX @@ static void handle_fp_fcvt(DisasContext *s, int opcode,
528
}
529
}
530
531
-/* C3.6.25 Floating point data-processing (1 source)
532
+/* Floating point data-processing (1 source)
533
* 31 30 29 28 24 23 22 21 20 15 14 10 9 5 4 0
534
* +---+---+---+-----------+------+---+--------+-----------+------+------+
535
* | M | 0 | S | 1 1 1 1 0 | type | 1 | opcode | 1 0 0 0 0 | Rn | Rd |
536
@@ -XXX,XX +XXX,XX @@ static void disas_fp_1src(DisasContext *s, uint32_t insn)
537
}
538
}
539
540
-/* C3.6.26 Floating-point data-processing (2 source) - single precision */
541
+/* Floating-point data-processing (2 source) - single precision */
542
static void handle_fp_2src_single(DisasContext *s, int opcode,
543
int rd, int rn, int rm)
544
{
545
@@ -XXX,XX +XXX,XX @@ static void handle_fp_2src_single(DisasContext *s, int opcode,
546
tcg_temp_free_i32(tcg_res);
547
}
548
549
-/* C3.6.26 Floating-point data-processing (2 source) - double precision */
550
+/* Floating-point data-processing (2 source) - double precision */
551
static void handle_fp_2src_double(DisasContext *s, int opcode,
552
int rd, int rn, int rm)
553
{
554
@@ -XXX,XX +XXX,XX @@ static void handle_fp_2src_double(DisasContext *s, int opcode,
555
tcg_temp_free_i64(tcg_res);
556
}
557
558
-/* C3.6.26 Floating point data-processing (2 source)
559
+/* Floating point data-processing (2 source)
560
* 31 30 29 28 24 23 22 21 20 16 15 12 11 10 9 5 4 0
561
* +---+---+---+-----------+------+---+------+--------+-----+------+------+
562
* | M | 0 | S | 1 1 1 1 0 | type | 1 | Rm | opcode | 1 0 | Rn | Rd |
563
@@ -XXX,XX +XXX,XX @@ static void disas_fp_2src(DisasContext *s, uint32_t insn)
564
}
565
}
566
567
-/* C3.6.27 Floating-point data-processing (3 source) - single precision */
568
+/* Floating-point data-processing (3 source) - single precision */
569
static void handle_fp_3src_single(DisasContext *s, bool o0, bool o1,
570
int rd, int rn, int rm, int ra)
571
{
572
@@ -XXX,XX +XXX,XX @@ static void handle_fp_3src_single(DisasContext *s, bool o0, bool o1,
573
tcg_temp_free_i32(tcg_res);
574
}
575
576
-/* C3.6.27 Floating-point data-processing (3 source) - double precision */
577
+/* Floating-point data-processing (3 source) - double precision */
578
static void handle_fp_3src_double(DisasContext *s, bool o0, bool o1,
579
int rd, int rn, int rm, int ra)
580
{
581
@@ -XXX,XX +XXX,XX @@ static void handle_fp_3src_double(DisasContext *s, bool o0, bool o1,
582
tcg_temp_free_i64(tcg_res);
583
}
584
585
-/* C3.6.27 Floating point data-processing (3 source)
586
+/* Floating point data-processing (3 source)
587
* 31 30 29 28 24 23 22 21 20 16 15 14 10 9 5 4 0
588
* +---+---+---+-----------+------+----+------+----+------+------+------+
589
* | M | 0 | S | 1 1 1 1 1 | type | o1 | Rm | o0 | Ra | Rn | Rd |
590
@@ -XXX,XX +XXX,XX @@ static void disas_fp_3src(DisasContext *s, uint32_t insn)
591
}
592
}
593
594
-/* C3.6.28 Floating point immediate
595
+/* Floating point immediate
596
* 31 30 29 28 24 23 22 21 20 13 12 10 9 5 4 0
597
* +---+---+---+-----------+------+---+------------+-------+------+------+
598
* | M | 0 | S | 1 1 1 1 0 | type | 1 | imm8 | 1 0 0 | imm5 | Rd |
599
@@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode,
600
tcg_temp_free_i32(tcg_shift);
601
}
602
603
-/* C3.6.29 Floating point <-> fixed point conversions
604
+/* Floating point <-> fixed point conversions
605
* 31 30 29 28 24 23 22 21 20 19 18 16 15 10 9 5 4 0
606
* +----+---+---+-----------+------+---+-------+--------+-------+------+------+
607
* | sf | 0 | S | 1 1 1 1 0 | type | 0 | rmode | opcode | scale | Rn | Rd |
608
@@ -XXX,XX +XXX,XX @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof)
609
}
610
}
611
612
-/* C3.6.30 Floating point <-> integer conversions
613
+/* Floating point <-> integer conversions
614
* 31 30 29 28 24 23 22 21 20 19 18 16 15 10 9 5 4 0
615
* +----+---+---+-----------+------+---+-------+-----+-------------+----+----+
616
* | sf | 0 | S | 1 1 1 1 0 | type | 1 | rmode | opc | 0 0 0 0 0 0 | Rn | Rd |
617
@@ -XXX,XX +XXX,XX @@ static void do_ext64(DisasContext *s, TCGv_i64 tcg_left, TCGv_i64 tcg_right,
618
tcg_temp_free_i64(tcg_tmp);
619
}
620
621
-/* C3.6.1 EXT
622
+/* EXT
623
* 31 30 29 24 23 22 21 20 16 15 14 11 10 9 5 4 0
624
* +---+---+-------------+-----+---+------+---+------+---+------+------+
625
* | 0 | Q | 1 0 1 1 1 0 | op2 | 0 | Rm | 0 | imm4 | 0 | Rn | Rd |
626
@@ -XXX,XX +XXX,XX @@ static void disas_simd_ext(DisasContext *s, uint32_t insn)
627
tcg_temp_free_i64(tcg_resh);
628
}
629
630
-/* C3.6.2 TBL/TBX
631
+/* TBL/TBX
632
* 31 30 29 24 23 22 21 20 16 15 14 13 12 11 10 9 5 4 0
633
* +---+---+-------------+-----+---+------+---+-----+----+-----+------+------+
634
* | 0 | Q | 0 0 1 1 1 0 | op2 | 0 | Rm | 0 | len | op | 0 0 | Rn | Rd |
635
@@ -XXX,XX +XXX,XX @@ static void disas_simd_tb(DisasContext *s, uint32_t insn)
636
tcg_temp_free_i64(tcg_resh);
637
}
638
639
-/* C3.6.3 ZIP/UZP/TRN
640
+/* ZIP/UZP/TRN
641
* 31 30 29 24 23 22 21 20 16 15 14 12 11 10 9 5 4 0
642
* +---+---+-------------+------+---+------+---+------------------+------+
643
* | 0 | Q | 0 0 1 1 1 0 | size | 0 | Rm | 0 | opc | 1 0 | Rn | Rd |
644
@@ -XXX,XX +XXX,XX @@ static void do_minmaxop(DisasContext *s, TCGv_i32 tcg_elt1, TCGv_i32 tcg_elt2,
645
}
646
}
647
648
-/* C3.6.4 AdvSIMD across lanes
649
+/* AdvSIMD across lanes
650
* 31 30 29 28 24 23 22 21 17 16 12 11 10 9 5 4 0
651
* +---+---+---+-----------+------+-----------+--------+-----+------+------+
652
* | 0 | Q | U | 0 1 1 1 0 | size | 1 1 0 0 0 | opcode | 1 0 | Rn | Rd |
653
@@ -XXX,XX +XXX,XX @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn)
654
tcg_temp_free_i64(tcg_res);
655
}
656
657
-/* C6.3.31 DUP (Element, Vector)
658
+/* DUP (Element, Vector)
659
*
660
* 31 30 29 21 20 16 15 10 9 5 4 0
661
* +---+---+-------------------+--------+-------------+------+------+
662
@@ -XXX,XX +XXX,XX @@ static void handle_simd_dupe(DisasContext *s, int is_q, int rd, int rn,
663
tcg_temp_free_i64(tmp);
664
}
665
666
-/* C6.3.31 DUP (element, scalar)
667
+/* DUP (element, scalar)
668
* 31 21 20 16 15 10 9 5 4 0
669
* +-----------------------+--------+-------------+------+------+
670
* | 0 1 0 1 1 1 1 0 0 0 0 | imm5 | 0 0 0 0 0 1 | Rn | Rd |
671
@@ -XXX,XX +XXX,XX @@ static void handle_simd_dupes(DisasContext *s, int rd, int rn,
672
tcg_temp_free_i64(tmp);
673
}
674
675
-/* C6.3.32 DUP (General)
676
+/* DUP (General)
677
*
678
* 31 30 29 21 20 16 15 10 9 5 4 0
679
* +---+---+-------------------+--------+-------------+------+------+
680
@@ -XXX,XX +XXX,XX @@ static void handle_simd_dupg(DisasContext *s, int is_q, int rd, int rn,
681
}
682
}
683
684
-/* C6.3.150 INS (Element)
685
+/* INS (Element)
686
*
687
* 31 21 20 16 15 14 11 10 9 5 4 0
688
* +-----------------------+--------+------------+---+------+------+
689
@@ -XXX,XX +XXX,XX @@ static void handle_simd_inse(DisasContext *s, int rd, int rn,
690
}
691
692
693
-/* C6.3.151 INS (General)
694
+/* INS (General)
695
*
696
* 31 21 20 16 15 10 9 5 4 0
697
* +-----------------------+--------+-------------+------+------+
698
@@ -XXX,XX +XXX,XX @@ static void handle_simd_insg(DisasContext *s, int rd, int rn, int imm5)
699
}
700
701
/*
702
- * C6.3.321 UMOV (General)
703
- * C6.3.237 SMOV (General)
704
+ * UMOV (General)
705
+ * SMOV (General)
706
*
707
* 31 30 29 21 20 16 15 12 10 9 5 4 0
708
* +---+---+-------------------+--------+-------------+------+------+
709
@@ -XXX,XX +XXX,XX @@ static void handle_simd_umov_smov(DisasContext *s, int is_q, int is_signed,
710
}
711
}
712
713
-/* C3.6.5 AdvSIMD copy
714
+/* AdvSIMD copy
715
* 31 30 29 28 21 20 16 15 14 11 10 9 5 4 0
716
* +---+---+----+-----------------+------+---+------+---+------+------+
717
* | 0 | Q | op | 0 1 1 1 0 0 0 0 | imm5 | 0 | imm4 | 1 | Rn | Rd |
718
@@ -XXX,XX +XXX,XX @@ static void disas_simd_copy(DisasContext *s, uint32_t insn)
719
}
720
}
721
722
-/* C3.6.6 AdvSIMD modified immediate
723
+/* AdvSIMD modified immediate
724
* 31 30 29 28 19 18 16 15 12 11 10 9 5 4 0
725
* +---+---+----+---------------------+-----+-------+----+---+-------+------+
726
* | 0 | Q | op | 0 1 1 1 1 0 0 0 0 0 | abc | cmode | o2 | 1 | defgh | Rd |
727
@@ -XXX,XX +XXX,XX @@ static void disas_simd_mod_imm(DisasContext *s, uint32_t insn)
728
tcg_temp_free_i64(tcg_imm);
729
}
730
731
-/* C3.6.7 AdvSIMD scalar copy
732
+/* AdvSIMD scalar copy
733
* 31 30 29 28 21 20 16 15 14 11 10 9 5 4 0
734
* +-----+----+-----------------+------+---+------+---+------+------+
735
* | 0 1 | op | 1 1 1 1 0 0 0 0 | imm5 | 0 | imm4 | 1 | Rn | Rd |
736
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_copy(DisasContext *s, uint32_t insn)
737
handle_simd_dupes(s, rd, rn, imm5);
738
}
739
740
-/* C3.6.8 AdvSIMD scalar pairwise
741
+/* AdvSIMD scalar pairwise
742
* 31 30 29 28 24 23 22 21 17 16 12 11 10 9 5 4 0
743
* +-----+---+-----------+------+-----------+--------+-----+------+------+
744
* | 0 1 | U | 1 1 1 1 0 | size | 1 1 0 0 0 | opcode | 1 0 | Rn | Rd |
745
@@ -XXX,XX +XXX,XX @@ static void handle_simd_shift_fpint_conv(DisasContext *s, bool is_scalar,
746
tcg_temp_free_i32(tcg_rmode);
747
}
748
749
-/* C3.6.9 AdvSIMD scalar shift by immediate
750
+/* AdvSIMD scalar shift by immediate
751
* 31 30 29 28 23 22 19 18 16 15 11 10 9 5 4 0
752
* +-----+---+-------------+------+------+--------+---+------+------+
753
* | 0 1 | U | 1 1 1 1 1 0 | immh | immb | opcode | 1 | Rn | Rd |
754
@@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_shift_imm(DisasContext *s, uint32_t insn)
755
}
756
}
757
758
-/* C3.6.10 AdvSIMD scalar three different
759
+/* AdvSIMD scalar three different
760
* 31 30 29 28 24 23 22 21 20 16 15 12 11 10 9 5 4 0
761
* +-----+---+-----------+------+---+------+--------+-----+------+------+
762
* | 0 1 | U | 1 1 1 1 0 | size | 1 | Rm | opcode | 0 0 | Rn | Rd |
763
@@ -XXX,XX +XXX,XX @@ static void handle_3same_float(DisasContext *s, int size, int elements,
764
}
765
}
766
767
-/* C3.6.11 AdvSIMD scalar three same
768
+/* AdvSIMD scalar three same
769
* 31 30 29 28 24 23 22 21 20 16 15 11 10 9 5 4 0
770
* +-----+---+-----------+------+---+------+--------+---+------+------+
771
* | 0 1 | U | 1 1 1 1 0 | size | 1 | Rm | opcode | 1 | Rn | Rd |
772
@@ -XXX,XX +XXX,XX @@ static void handle_2misc_satacc(DisasContext *s, bool is_scalar, bool is_u,
773
}
774
}
775
776
-/* C3.6.12 AdvSIMD scalar two reg misc
777
+/* AdvSIMD scalar two reg misc
778
* 31 30 29 28 24 23 22 21 17 16 12 11 10 9 5 4 0
779
* +-----+---+-----------+------+-----------+--------+-----+------+------+
780
* | 0 1 | U | 1 1 1 1 0 | size | 1 0 0 0 0 | opcode | 1 0 | Rn | Rd |
781
@@ -XXX,XX +XXX,XX @@ static void handle_vec_simd_shrn(DisasContext *s, bool is_q,
782
}
783
784
785
-/* C3.6.14 AdvSIMD shift by immediate
786
+/* AdvSIMD shift by immediate
787
* 31 30 29 28 23 22 19 18 16 15 11 10 9 5 4 0
788
* +---+---+---+-------------+------+------+--------+---+------+------+
789
* | 0 | Q | U | 0 1 1 1 1 0 | immh | immb | opcode | 1 | Rn | Rd |
790
@@ -XXX,XX +XXX,XX @@ static void handle_pmull_64(DisasContext *s, int is_q, int rd, int rn, int rm)
791
tcg_temp_free_i64(tcg_res);
792
}
793
794
-/* C3.6.15 AdvSIMD three different
795
+/* AdvSIMD three different
796
* 31 30 29 28 24 23 22 21 20 16 15 12 11 10 9 5 4 0
797
* +---+---+---+-----------+------+---+------+--------+-----+------+------+
798
* | 0 | Q | U | 0 1 1 1 0 | size | 1 | Rm | opcode | 0 0 | Rn | Rd |
799
@@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn)
800
}
801
}
802
803
-/* C3.6.16 AdvSIMD three same
804
+/* AdvSIMD three same
805
* 31 30 29 28 24 23 22 21 20 16 15 11 10 9 5 4 0
806
* +---+---+---+-----------+------+---+------+--------+---+------+------+
807
* | 0 | Q | U | 0 1 1 1 0 | size | 1 | Rm | opcode | 1 | Rn | Rd |
808
@@ -XXX,XX +XXX,XX @@ static void handle_shll(DisasContext *s, bool is_q, int size, int rn, int rd)
809
}
810
}
811
812
-/* C3.6.17 AdvSIMD two reg misc
813
+/* AdvSIMD two reg misc
814
* 31 30 29 28 24 23 22 21 17 16 12 11 10 9 5 4 0
815
* +---+---+---+-----------+------+-----------+--------+-----+------+------+
816
* | 0 | Q | U | 0 1 1 1 0 | size | 1 0 0 0 0 | opcode | 1 0 | Rn | Rd |
817
@@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc(DisasContext *s, uint32_t insn)
818
}
819
}
820
821
-/* C3.6.13 AdvSIMD scalar x indexed element
822
+/* AdvSIMD scalar x indexed element
823
* 31 30 29 28 24 23 22 21 20 19 16 15 12 11 10 9 5 4 0
824
* +-----+---+-----------+------+---+---+------+-----+---+---+------+------+
825
* | 0 1 | U | 1 1 1 1 1 | size | L | M | Rm | opc | H | 0 | Rn | Rd |
826
* +-----+---+-----------+------+---+---+------+-----+---+---+------+------+
827
- * C3.6.18 AdvSIMD vector x indexed element
828
+ * AdvSIMD vector x indexed element
829
* 31 30 29 28 24 23 22 21 20 19 16 15 12 11 10 9 5 4 0
830
* +---+---+---+-----------+------+---+---+------+-----+---+---+------+------+
831
* | 0 | Q | U | 0 1 1 1 1 | size | L | M | Rm | opc | H | 0 | Rn | Rd |
832
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
833
}
834
}
835
836
-/* C3.6.19 Crypto AES
837
+/* Crypto AES
838
* 31 24 23 22 21 17 16 12 11 10 9 5 4 0
839
* +-----------------+------+-----------+--------+-----+------+------+
840
* | 0 1 0 0 1 1 1 0 | size | 1 0 1 0 0 | opcode | 1 0 | Rn | Rd |
841
@@ -XXX,XX +XXX,XX @@ static void disas_crypto_aes(DisasContext *s, uint32_t insn)
842
tcg_temp_free_i32(tcg_decrypt);
843
}
844
845
-/* C3.6.20 Crypto three-reg SHA
846
+/* Crypto three-reg SHA
847
* 31 24 23 22 21 20 16 15 14 12 11 10 9 5 4 0
848
* +-----------------+------+---+------+---+--------+-----+------+------+
849
* | 0 1 0 1 1 1 1 0 | size | 0 | Rm | 0 | opcode | 0 0 | Rn | Rd |
850
@@ -XXX,XX +XXX,XX @@ static void disas_crypto_three_reg_sha(DisasContext *s, uint32_t insn)
851
tcg_temp_free_i32(tcg_rm_regno);
852
}
853
854
-/* C3.6.21 Crypto two-reg SHA
855
+/* Crypto two-reg SHA
856
* 31 24 23 22 21 17 16 12 11 10 9 5 4 0
857
* +-----------------+------+-----------+--------+-----+------+------+
858
* | 0 1 0 1 1 1 1 0 | size | 1 0 1 0 0 | opcode | 1 0 | Rn | Rd |
859
--
53
--
860
2.7.4
54
2.25.1
861
862
diff view generated by jsdifflib
1
Don't use the old_mmio struct in memory region ops.
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Enable the a76 for virt and sbsa board use.
4
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220506180242.216785-24-richard.henderson@linaro.org
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 1505580378-9044-5-git-send-email-peter.maydell@linaro.org
6
---
9
---
7
hw/timer/omap_gptimer.c | 49 +++++++++++++++++++++++++++++++++++++------------
10
docs/system/arm/virt.rst | 1 +
8
1 file changed, 37 insertions(+), 12 deletions(-)
11
hw/arm/sbsa-ref.c | 1 +
12
hw/arm/virt.c | 1 +
13
target/arm/cpu64.c | 66 ++++++++++++++++++++++++++++++++++++++++
14
4 files changed, 69 insertions(+)
9
15
10
diff --git a/hw/timer/omap_gptimer.c b/hw/timer/omap_gptimer.c
16
diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst
11
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
12
--- a/hw/timer/omap_gptimer.c
18
--- a/docs/system/arm/virt.rst
13
+++ b/hw/timer/omap_gptimer.c
19
+++ b/docs/system/arm/virt.rst
14
@@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_writeh(void *opaque, hwaddr addr,
20
@@ -XXX,XX +XXX,XX @@ Supported guest CPU types:
15
s->writeh = (uint16_t) value;
21
- ``cortex-a53`` (64-bit)
22
- ``cortex-a57`` (64-bit)
23
- ``cortex-a72`` (64-bit)
24
+- ``cortex-a76`` (64-bit)
25
- ``a64fx`` (64-bit)
26
- ``host`` (with KVM only)
27
- ``max`` (same as ``host`` for KVM; best possible emulation with TCG)
28
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/arm/sbsa-ref.c
31
+++ b/hw/arm/sbsa-ref.c
32
@@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = {
33
static const char * const valid_cpus[] = {
34
ARM_CPU_TYPE_NAME("cortex-a57"),
35
ARM_CPU_TYPE_NAME("cortex-a72"),
36
+ ARM_CPU_TYPE_NAME("cortex-a76"),
37
ARM_CPU_TYPE_NAME("max"),
38
};
39
40
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/arm/virt.c
43
+++ b/hw/arm/virt.c
44
@@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = {
45
ARM_CPU_TYPE_NAME("cortex-a53"),
46
ARM_CPU_TYPE_NAME("cortex-a57"),
47
ARM_CPU_TYPE_NAME("cortex-a72"),
48
+ ARM_CPU_TYPE_NAME("cortex-a76"),
49
ARM_CPU_TYPE_NAME("a64fx"),
50
ARM_CPU_TYPE_NAME("host"),
51
ARM_CPU_TYPE_NAME("max"),
52
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/target/arm/cpu64.c
55
+++ b/target/arm/cpu64.c
56
@@ -XXX,XX +XXX,XX @@ static void aarch64_a72_initfn(Object *obj)
57
define_cortex_a72_a57_a53_cp_reginfo(cpu);
16
}
58
}
17
59
18
+static uint64_t omap_gp_timer_readfn(void *opaque, hwaddr addr,
60
+static void aarch64_a76_initfn(Object *obj)
19
+ unsigned size)
20
+{
61
+{
21
+ switch (size) {
62
+ ARMCPU *cpu = ARM_CPU(obj);
22
+ case 1:
63
+
23
+ return omap_badwidth_read32(opaque, addr);
64
+ cpu->dtb_compatible = "arm,cortex-a76";
24
+ case 2:
65
+ set_feature(&cpu->env, ARM_FEATURE_V8);
25
+ return omap_gp_timer_readh(opaque, addr);
66
+ set_feature(&cpu->env, ARM_FEATURE_NEON);
26
+ case 4:
67
+ set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
27
+ return omap_gp_timer_readw(opaque, addr);
68
+ set_feature(&cpu->env, ARM_FEATURE_AARCH64);
28
+ default:
69
+ set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
29
+ g_assert_not_reached();
70
+ set_feature(&cpu->env, ARM_FEATURE_EL2);
30
+ }
71
+ set_feature(&cpu->env, ARM_FEATURE_EL3);
72
+ set_feature(&cpu->env, ARM_FEATURE_PMU);
73
+
74
+ /* Ordered by B2.4 AArch64 registers by functional group */
75
+ cpu->clidr = 0x82000023;
76
+ cpu->ctr = 0x8444C004;
77
+ cpu->dcz_blocksize = 4;
78
+ cpu->isar.id_aa64dfr0 = 0x0000000010305408ull;
79
+ cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
80
+ cpu->isar.id_aa64isar1 = 0x0000000000100001ull;
81
+ cpu->isar.id_aa64mmfr0 = 0x0000000000101122ull;
82
+ cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull;
83
+ cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull;
84
+ cpu->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */
85
+ cpu->isar.id_aa64pfr1 = 0x0000000000000010ull;
86
+ cpu->id_afr0 = 0x00000000;
87
+ cpu->isar.id_dfr0 = 0x04010088;
88
+ cpu->isar.id_isar0 = 0x02101110;
89
+ cpu->isar.id_isar1 = 0x13112111;
90
+ cpu->isar.id_isar2 = 0x21232042;
91
+ cpu->isar.id_isar3 = 0x01112131;
92
+ cpu->isar.id_isar4 = 0x00010142;
93
+ cpu->isar.id_isar5 = 0x01011121;
94
+ cpu->isar.id_isar6 = 0x00000010;
95
+ cpu->isar.id_mmfr0 = 0x10201105;
96
+ cpu->isar.id_mmfr1 = 0x40000000;
97
+ cpu->isar.id_mmfr2 = 0x01260000;
98
+ cpu->isar.id_mmfr3 = 0x02122211;
99
+ cpu->isar.id_mmfr4 = 0x00021110;
100
+ cpu->isar.id_pfr0 = 0x10010131;
101
+ cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */
102
+ cpu->isar.id_pfr2 = 0x00000011;
103
+ cpu->midr = 0x414fd0b1; /* r4p1 */
104
+ cpu->revidr = 0;
105
+
106
+ /* From B2.18 CCSIDR_EL1 */
107
+ cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */
108
+ cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */
109
+ cpu->ccsidr[2] = 0x707fe03a; /* 512KB L2 cache */
110
+
111
+ /* From B2.93 SCTLR_EL3 */
112
+ cpu->reset_sctlr = 0x30c50838;
113
+
114
+ /* From B4.23 ICH_VTR_EL2 */
115
+ cpu->gic_num_lrs = 4;
116
+ cpu->gic_vpribits = 5;
117
+ cpu->gic_vprebits = 5;
118
+
119
+ /* From B5.1 AdvSIMD AArch64 register summary */
120
+ cpu->isar.mvfr0 = 0x10110222;
121
+ cpu->isar.mvfr1 = 0x13211111;
122
+ cpu->isar.mvfr2 = 0x00000043;
31
+}
123
+}
32
+
124
+
33
+static void omap_gp_timer_writefn(void *opaque, hwaddr addr,
125
void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
34
+ uint64_t value, unsigned size)
126
{
35
+{
127
/*
36
+ switch (size) {
128
@@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = {
37
+ case 1:
129
{ .name = "cortex-a57", .initfn = aarch64_a57_initfn },
38
+ omap_badwidth_write32(opaque, addr, value);
130
{ .name = "cortex-a53", .initfn = aarch64_a53_initfn },
39
+ break;
131
{ .name = "cortex-a72", .initfn = aarch64_a72_initfn },
40
+ case 2:
132
+ { .name = "cortex-a76", .initfn = aarch64_a76_initfn },
41
+ omap_gp_timer_writeh(opaque, addr, value);
133
{ .name = "a64fx", .initfn = aarch64_a64fx_initfn },
42
+ break;
134
{ .name = "max", .initfn = aarch64_max_initfn },
43
+ case 4:
135
#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
44
+ omap_gp_timer_write(opaque, addr, value);
45
+ break;
46
+ default:
47
+ g_assert_not_reached();
48
+ }
49
+}
50
+
51
static const MemoryRegionOps omap_gp_timer_ops = {
52
- .old_mmio = {
53
- .read = {
54
- omap_badwidth_read32,
55
- omap_gp_timer_readh,
56
- omap_gp_timer_readw,
57
- },
58
- .write = {
59
- omap_badwidth_write32,
60
- omap_gp_timer_writeh,
61
- omap_gp_timer_write,
62
- },
63
- },
64
+ .read = omap_gp_timer_readfn,
65
+ .write = omap_gp_timer_writefn,
66
+ .valid.min_access_size = 1,
67
+ .valid.max_access_size = 4,
68
.endianness = DEVICE_NATIVE_ENDIAN,
69
};
70
71
--
136
--
72
2.7.4
137
2.25.1
73
74
diff view generated by jsdifflib
1
Make the set_prio() function take a bool indicating
1
From: Richard Henderson <richard.henderson@linaro.org>
2
whether to pend the secure or non-secure version of a banked
3
interrupt, and use this to implement the correct banking
4
semantics for the SHPR registers.
5
2
3
Enable the n1 for virt and sbsa board use.
4
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220506180242.216785-25-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 1505240046-11454-11-git-send-email-peter.maydell@linaro.org
9
---
9
---
10
hw/intc/armv7m_nvic.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++-----
10
docs/system/arm/virt.rst | 1 +
11
hw/intc/trace-events | 2 +-
11
hw/arm/sbsa-ref.c | 1 +
12
2 files changed, 88 insertions(+), 10 deletions(-)
12
hw/arm/virt.c | 1 +
13
target/arm/cpu64.c | 66 ++++++++++++++++++++++++++++++++++++++++
14
4 files changed, 69 insertions(+)
13
15
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
16
diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/armv7m_nvic.c
18
--- a/docs/system/arm/virt.rst
17
+++ b/hw/intc/armv7m_nvic.c
19
+++ b/docs/system/arm/virt.rst
18
@@ -XXX,XX +XXX,XX @@ int armv7m_nvic_raw_execution_priority(void *opaque)
20
@@ -XXX,XX +XXX,XX @@ Supported guest CPU types:
19
return s->exception_prio;
21
- ``cortex-a76`` (64-bit)
22
- ``a64fx`` (64-bit)
23
- ``host`` (with KVM only)
24
+- ``neoverse-n1`` (64-bit)
25
- ``max`` (same as ``host`` for KVM; best possible emulation with TCG)
26
27
Note that the default is ``cortex-a15``, so for an AArch64 guest you must
28
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/arm/sbsa-ref.c
31
+++ b/hw/arm/sbsa-ref.c
32
@@ -XXX,XX +XXX,XX @@ static const char * const valid_cpus[] = {
33
ARM_CPU_TYPE_NAME("cortex-a57"),
34
ARM_CPU_TYPE_NAME("cortex-a72"),
35
ARM_CPU_TYPE_NAME("cortex-a76"),
36
+ ARM_CPU_TYPE_NAME("neoverse-n1"),
37
ARM_CPU_TYPE_NAME("max"),
38
};
39
40
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/arm/virt.c
43
+++ b/hw/arm/virt.c
44
@@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = {
45
ARM_CPU_TYPE_NAME("cortex-a72"),
46
ARM_CPU_TYPE_NAME("cortex-a76"),
47
ARM_CPU_TYPE_NAME("a64fx"),
48
+ ARM_CPU_TYPE_NAME("neoverse-n1"),
49
ARM_CPU_TYPE_NAME("host"),
50
ARM_CPU_TYPE_NAME("max"),
51
};
52
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/target/arm/cpu64.c
55
+++ b/target/arm/cpu64.c
56
@@ -XXX,XX +XXX,XX @@ static void aarch64_a76_initfn(Object *obj)
57
cpu->isar.mvfr2 = 0x00000043;
20
}
58
}
21
59
22
-/* caller must call nvic_irq_update() after this */
60
+static void aarch64_neoverse_n1_initfn(Object *obj)
23
-static void set_prio(NVICState *s, unsigned irq, uint8_t prio)
61
+{
24
+/* caller must call nvic_irq_update() after this.
62
+ ARMCPU *cpu = ARM_CPU(obj);
25
+ * secure indicates the bank to use for banked exceptions (we assert if
26
+ * we are passed secure=true for a non-banked exception).
27
+ */
28
+static void set_prio(NVICState *s, unsigned irq, bool secure, uint8_t prio)
29
{
30
assert(irq > ARMV7M_EXCP_NMI); /* only use for configurable prios */
31
assert(irq < s->num_irq);
32
33
- s->vectors[irq].prio = prio;
34
+ if (secure) {
35
+ assert(exc_is_banked(irq));
36
+ s->sec_vectors[irq].prio = prio;
37
+ } else {
38
+ s->vectors[irq].prio = prio;
39
+ }
40
+
63
+
41
+ trace_nvic_set_prio(irq, secure, prio);
64
+ cpu->dtb_compatible = "arm,neoverse-n1";
65
+ set_feature(&cpu->env, ARM_FEATURE_V8);
66
+ set_feature(&cpu->env, ARM_FEATURE_NEON);
67
+ set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
68
+ set_feature(&cpu->env, ARM_FEATURE_AARCH64);
69
+ set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
70
+ set_feature(&cpu->env, ARM_FEATURE_EL2);
71
+ set_feature(&cpu->env, ARM_FEATURE_EL3);
72
+ set_feature(&cpu->env, ARM_FEATURE_PMU);
73
+
74
+ /* Ordered by B2.4 AArch64 registers by functional group */
75
+ cpu->clidr = 0x82000023;
76
+ cpu->ctr = 0x8444c004;
77
+ cpu->dcz_blocksize = 4;
78
+ cpu->isar.id_aa64dfr0 = 0x0000000110305408ull;
79
+ cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
80
+ cpu->isar.id_aa64isar1 = 0x0000000000100001ull;
81
+ cpu->isar.id_aa64mmfr0 = 0x0000000000101125ull;
82
+ cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull;
83
+ cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull;
84
+ cpu->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */
85
+ cpu->isar.id_aa64pfr1 = 0x0000000000000020ull;
86
+ cpu->id_afr0 = 0x00000000;
87
+ cpu->isar.id_dfr0 = 0x04010088;
88
+ cpu->isar.id_isar0 = 0x02101110;
89
+ cpu->isar.id_isar1 = 0x13112111;
90
+ cpu->isar.id_isar2 = 0x21232042;
91
+ cpu->isar.id_isar3 = 0x01112131;
92
+ cpu->isar.id_isar4 = 0x00010142;
93
+ cpu->isar.id_isar5 = 0x01011121;
94
+ cpu->isar.id_isar6 = 0x00000010;
95
+ cpu->isar.id_mmfr0 = 0x10201105;
96
+ cpu->isar.id_mmfr1 = 0x40000000;
97
+ cpu->isar.id_mmfr2 = 0x01260000;
98
+ cpu->isar.id_mmfr3 = 0x02122211;
99
+ cpu->isar.id_mmfr4 = 0x00021110;
100
+ cpu->isar.id_pfr0 = 0x10010131;
101
+ cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */
102
+ cpu->isar.id_pfr2 = 0x00000011;
103
+ cpu->midr = 0x414fd0c1; /* r4p1 */
104
+ cpu->revidr = 0;
105
+
106
+ /* From B2.23 CCSIDR_EL1 */
107
+ cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */
108
+ cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */
109
+ cpu->ccsidr[2] = 0x70ffe03a; /* 1MB L2 cache */
110
+
111
+ /* From B2.98 SCTLR_EL3 */
112
+ cpu->reset_sctlr = 0x30c50838;
113
+
114
+ /* From B4.23 ICH_VTR_EL2 */
115
+ cpu->gic_num_lrs = 4;
116
+ cpu->gic_vpribits = 5;
117
+ cpu->gic_vprebits = 5;
118
+
119
+ /* From B5.1 AdvSIMD AArch64 register summary */
120
+ cpu->isar.mvfr0 = 0x10110222;
121
+ cpu->isar.mvfr1 = 0x13211111;
122
+ cpu->isar.mvfr2 = 0x00000043;
42
+}
123
+}
43
+
124
+
44
+/* Return the current raw priority register value.
125
void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
45
+ * secure indicates the bank to use for banked exceptions (we assert if
126
{
46
+ * we are passed secure=true for a non-banked exception).
127
/*
47
+ */
128
@@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = {
48
+static int get_prio(NVICState *s, unsigned irq, bool secure)
129
{ .name = "cortex-a72", .initfn = aarch64_a72_initfn },
49
+{
130
{ .name = "cortex-a76", .initfn = aarch64_a76_initfn },
50
+ assert(irq > ARMV7M_EXCP_NMI); /* only use for configurable prios */
131
{ .name = "a64fx", .initfn = aarch64_a64fx_initfn },
51
+ assert(irq < s->num_irq);
132
+ { .name = "neoverse-n1", .initfn = aarch64_neoverse_n1_initfn },
52
133
{ .name = "max", .initfn = aarch64_max_initfn },
53
- trace_nvic_set_prio(irq, prio);
134
#if defined(CONFIG_KVM) || defined(CONFIG_HVF)
54
+ if (secure) {
135
{ .name = "host", .initfn = aarch64_host_initfn },
55
+ assert(exc_is_banked(irq));
56
+ return s->sec_vectors[irq].prio;
57
+ } else {
58
+ return s->vectors[irq].prio;
59
+ }
60
}
61
62
/* Recompute state and assert irq line accordingly.
63
@@ -XXX,XX +XXX,XX @@ static bool nvic_user_access_ok(NVICState *s, hwaddr offset, MemTxAttrs attrs)
64
}
65
}
66
67
+static int shpr_bank(NVICState *s, int exc, MemTxAttrs attrs)
68
+{
69
+ /* Behaviour for the SHPR register field for this exception:
70
+ * return M_REG_NS to use the nonsecure vector (including for
71
+ * non-banked exceptions), M_REG_S for the secure version of
72
+ * a banked exception, and -1 if this field should RAZ/WI.
73
+ */
74
+ switch (exc) {
75
+ case ARMV7M_EXCP_MEM:
76
+ case ARMV7M_EXCP_USAGE:
77
+ case ARMV7M_EXCP_SVC:
78
+ case ARMV7M_EXCP_PENDSV:
79
+ case ARMV7M_EXCP_SYSTICK:
80
+ /* Banked exceptions */
81
+ return attrs.secure;
82
+ case ARMV7M_EXCP_BUS:
83
+ /* Not banked, RAZ/WI from nonsecure if BFHFNMINS is zero */
84
+ if (!attrs.secure &&
85
+ !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
86
+ return -1;
87
+ }
88
+ return M_REG_NS;
89
+ case ARMV7M_EXCP_SECURE:
90
+ /* Not banked, RAZ/WI from nonsecure */
91
+ if (!attrs.secure) {
92
+ return -1;
93
+ }
94
+ return M_REG_NS;
95
+ case ARMV7M_EXCP_DEBUG:
96
+ /* Not banked. TODO should RAZ/WI if DEMCR.SDME is set */
97
+ return M_REG_NS;
98
+ case 8 ... 10:
99
+ case 13:
100
+ /* RES0 */
101
+ return -1;
102
+ default:
103
+ /* Not reachable due to decode of SHPR register addresses */
104
+ g_assert_not_reached();
105
+ }
106
+}
107
+
108
static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
109
uint64_t *data, unsigned size,
110
MemTxAttrs attrs)
111
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
112
}
113
}
114
break;
115
- case 0xd18 ... 0xd23: /* System Handler Priority. */
116
+ case 0xd18 ... 0xd23: /* System Handler Priority (SHPR1, SHPR2, SHPR3) */
117
val = 0;
118
for (i = 0; i < size; i++) {
119
- val |= s->vectors[(offset - 0xd14) + i].prio << (i * 8);
120
+ unsigned hdlidx = (offset - 0xd14) + i;
121
+ int sbank = shpr_bank(s, hdlidx, attrs);
122
+
123
+ if (sbank < 0) {
124
+ continue;
125
+ }
126
+ val = deposit32(val, i * 8, 8, get_prio(s, hdlidx, sbank));
127
}
128
break;
129
case 0xfe0 ... 0xfff: /* ID. */
130
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
131
132
for (i = 0; i < size && startvec + i < s->num_irq; i++) {
133
if (attrs.secure || s->itns[startvec + i]) {
134
- set_prio(s, startvec + i, (value >> (i * 8)) & 0xff);
135
+ set_prio(s, startvec + i, false, (value >> (i * 8)) & 0xff);
136
}
137
}
138
nvic_irq_update(s);
139
return MEMTX_OK;
140
- case 0xd18 ... 0xd23: /* System Handler Priority. */
141
+ case 0xd18 ... 0xd23: /* System Handler Priority (SHPR1, SHPR2, SHPR3) */
142
for (i = 0; i < size; i++) {
143
unsigned hdlidx = (offset - 0xd14) + i;
144
- set_prio(s, hdlidx, (value >> (i * 8)) & 0xff);
145
+ int newprio = extract32(value, i * 8, 8);
146
+ int sbank = shpr_bank(s, hdlidx, attrs);
147
+
148
+ if (sbank < 0) {
149
+ continue;
150
+ }
151
+ set_prio(s, hdlidx, sbank, newprio);
152
}
153
nvic_irq_update(s);
154
return MEMTX_OK;
155
diff --git a/hw/intc/trace-events b/hw/intc/trace-events
156
index XXXXXXX..XXXXXXX 100644
157
--- a/hw/intc/trace-events
158
+++ b/hw/intc/trace-events
159
@@ -XXX,XX +XXX,XX @@ gicv3_redist_send_sgi(uint32_t cpu, int irq) "GICv3 redistributor 0x%x pending S
160
# hw/intc/armv7m_nvic.c
161
nvic_recompute_state(int vectpending, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d vectpending_prio %d exception_prio %d"
162
nvic_recompute_state_secure(int vectpending, bool vectpending_is_s_banked, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d is_s_banked %d vectpending_prio %d exception_prio %d"
163
-nvic_set_prio(int irq, uint8_t prio) "NVIC set irq %d priority %d"
164
+nvic_set_prio(int irq, bool secure, uint8_t prio) "NVIC set irq %d secure-bank %d priority %d"
165
nvic_irq_update(int vectpending, int pendprio, int exception_prio, int level) "NVIC vectpending %d pending prio %d exception_prio %d: setting irq line to %d"
166
nvic_escalate_prio(int irq, int irqprio, int runprio) "NVIC escalating irq %d to HardFault: insufficient priority %d >= %d"
167
nvic_escalate_disabled(int irq) "NVIC escalating irq %d to HardFault: disabled"
168
--
136
--
169
2.7.4
137
2.25.1
170
171
diff view generated by jsdifflib
1
In armv7m_nvic_set_pending() we have to compare the
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
2
priority of an exception against the execution priority
3
to decide whether it needs to be escalated to HardFault.
4
In the specification this is a comparison against the
5
exception's group priority; for v7M we implemented it
6
as a comparison against the raw exception priority
7
because the two comparisons will always give the
8
same answer. For v8M the existence of AIRCR.PRIS and
9
the possibility of different PRIGROUP values for secure
10
and nonsecure exceptions means we need to explicitly
11
calculate the vector's group priority for this check.
12
2
3
The sbsa-ref machine is continuously evolving. Some of the changes we
4
want to make in the near future, to align with real components (e.g.
5
the GIC-700), will break compatibility for existing firmware.
6
7
Introduce two new properties to the DT generated on machine generation:
8
- machine-version-major
9
To be incremented when a platform change makes the machine
10
incompatible with existing firmware.
11
- machine-version-minor
12
To be incremented when functionality is added to the machine
13
without causing incompatibility with existing firmware.
14
to be reset to 0 when machine-version-major is incremented.
15
16
This versioning scheme is *neither*:
17
- A QEMU versioned machine type; a given version of QEMU will emulate
18
a given version of the platform.
19
- A reflection of level of SBSA (now SystemReady SR) support provided.
20
21
The version will increment on guest-visible functional changes only,
22
akin to a revision ID register found on a physical platform.
23
24
These properties are both introduced with the value 0.
25
(Hence, a machine where the DT is lacking these nodes is equivalent
26
to version 0.0.)
27
28
Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
29
Message-id: 20220505113947.75714-1-quic_llindhol@quicinc.com
30
Cc: Peter Maydell <peter.maydell@linaro.org>
31
Cc: Radoslaw Biernacki <rad@semihalf.com>
32
Cc: Cédric Le Goater <clg@kaod.org>
33
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
34
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 1505240046-11454-12-git-send-email-peter.maydell@linaro.org
16
---
35
---
17
hw/intc/armv7m_nvic.c | 2 +-
36
hw/arm/sbsa-ref.c | 14 ++++++++++++++
18
1 file changed, 1 insertion(+), 1 deletion(-)
37
1 file changed, 14 insertions(+)
19
38
20
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
39
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
21
index XXXXXXX..XXXXXXX 100644
40
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/intc/armv7m_nvic.c
41
--- a/hw/arm/sbsa-ref.c
23
+++ b/hw/intc/armv7m_nvic.c
42
+++ b/hw/arm/sbsa-ref.c
24
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure)
43
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms)
25
int running = nvic_exec_prio(s);
44
qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2);
26
bool escalate = false;
45
qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2);
27
46
28
- if (vec->prio >= running) {
47
+ /*
29
+ if (exc_group_prio(s, vec->prio, secure) >= running) {
48
+ * This versioning scheme is for informing platform fw only. It is neither:
30
trace_nvic_escalate_prio(irq, vec->prio, running);
49
+ * - A QEMU versioned machine type; a given version of QEMU will emulate
31
escalate = true;
50
+ * a given version of the platform.
32
} else if (!vec->enabled) {
51
+ * - A reflection of level of SBSA (now SystemReady SR) support provided.
52
+ *
53
+ * machine-version-major: updated when changes breaking fw compatibility
54
+ * are introduced.
55
+ * machine-version-minor: updated when features are added that don't break
56
+ * fw compatibility.
57
+ */
58
+ qemu_fdt_setprop_cell(fdt, "/", "machine-version-major", 0);
59
+ qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 0);
60
+
61
if (ms->numa_state->have_numa_distance) {
62
int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t);
63
uint32_t *matrix = g_malloc0(size);
33
--
64
--
34
2.7.4
65
2.25.1
35
66
36
67
diff view generated by jsdifflib
1
From: Subbaraya Sundeep <sundeep.lkml@gmail.com>
1
From: Gavin Shan <gshan@redhat.com>
2
2
3
Smartfusion2 SoC has hardened Microcontroller subsystem
3
This adds cluster-id in CPU instance properties, which will be used
4
and flash based FPGA fabric. This patch adds support for
4
by arm/virt machine. Besides, the cluster-id is also verified or
5
Microcontroller subsystem in the SoC.
5
dumped in various spots:
6
6
7
Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com>
7
* hw/core/machine.c::machine_set_cpu_numa_node() to associate
8
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
8
CPU with its NUMA node.
9
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
10
Message-id: 20170920201737.25723-5-f4bug@amsat.org
10
* hw/core/machine.c::machine_numa_finish_cpu_init() to record
11
[PMD: drop cpu_model to directly use cpu type, check m3clk non null]
11
CPU slots with no NUMA mapping set.
12
13
* hw/core/machine-hmp-cmds.c::hmp_hotpluggable_cpus() to dump
14
cluster-id.
15
16
Signed-off-by: Gavin Shan <gshan@redhat.com>
17
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
18
Acked-by: Igor Mammedov <imammedo@redhat.com>
19
Message-id: 20220503140304.855514-2-gshan@redhat.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
21
---
14
hw/arm/Makefile.objs | 1 +
22
qapi/machine.json | 6 ++++--
15
include/hw/arm/msf2-soc.h | 67 +++++++++++
23
hw/core/machine-hmp-cmds.c | 4 ++++
16
hw/arm/msf2-soc.c | 238 ++++++++++++++++++++++++++++++++++++++++
24
hw/core/machine.c | 16 ++++++++++++++++
17
default-configs/arm-softmmu.mak | 1 +
25
3 files changed, 24 insertions(+), 2 deletions(-)
18
4 files changed, 307 insertions(+)
19
create mode 100644 include/hw/arm/msf2-soc.h
20
create mode 100644 hw/arm/msf2-soc.c
21
26
22
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
27
diff --git a/qapi/machine.json b/qapi/machine.json
23
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
24
--- a/hw/arm/Makefile.objs
29
--- a/qapi/machine.json
25
+++ b/hw/arm/Makefile.objs
30
+++ b/qapi/machine.json
26
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
27
obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o
28
obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o
29
obj-$(CONFIG_MPS2) += mps2.o
30
+obj-$(CONFIG_MSF2) += msf2-soc.o
31
diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h
32
new file mode 100644
33
index XXXXXXX..XXXXXXX
34
--- /dev/null
35
+++ b/include/hw/arm/msf2-soc.h
36
@@ -XXX,XX +XXX,XX @@
31
@@ -XXX,XX +XXX,XX @@
37
+/*
32
# @node-id: NUMA node ID the CPU belongs to
38
+ * Microsemi Smartfusion2 SoC
33
# @socket-id: socket number within node/board the CPU belongs to
39
+ *
34
# @die-id: die number within socket the CPU belongs to (since 4.1)
40
+ * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>
35
-# @core-id: core number within die the CPU belongs to
41
+ *
36
+# @cluster-id: cluster number within die the CPU belongs to (since 7.1)
42
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
37
+# @core-id: core number within cluster the CPU belongs to
43
+ * of this software and associated documentation files (the "Software"), to deal
38
# @thread-id: thread number within core the CPU belongs to
44
+ * in the Software without restriction, including without limitation the rights
39
#
45
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
40
-# Note: currently there are 5 properties that could be present
46
+ * copies of the Software, and to permit persons to whom the Software is
41
+# Note: currently there are 6 properties that could be present
47
+ * furnished to do so, subject to the following conditions:
42
# but management should be prepared to pass through other
48
+ *
43
# properties with device_add command to allow for future
49
+ * The above copyright notice and this permission notice shall be included in
44
# interface extension. This also requires the filed names to be kept in
50
+ * all copies or substantial portions of the Software.
51
+ *
52
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
55
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
58
+ * THE SOFTWARE.
59
+ */
60
+
61
+#ifndef HW_ARM_MSF2_SOC_H
62
+#define HW_ARM_MSF2_SOC_H
63
+
64
+#include "hw/arm/armv7m.h"
65
+#include "hw/timer/mss-timer.h"
66
+#include "hw/misc/msf2-sysreg.h"
67
+#include "hw/ssi/mss-spi.h"
68
+
69
+#define TYPE_MSF2_SOC "msf2-soc"
70
+#define MSF2_SOC(obj) OBJECT_CHECK(MSF2State, (obj), TYPE_MSF2_SOC)
71
+
72
+#define MSF2_NUM_SPIS 2
73
+#define MSF2_NUM_UARTS 2
74
+
75
+/*
76
+ * System timer consists of two programmable 32-bit
77
+ * decrementing counters that generate individual interrupts to
78
+ * the Cortex-M3 processor
79
+ */
80
+#define MSF2_NUM_TIMERS 2
81
+
82
+typedef struct MSF2State {
83
+ /*< private >*/
84
+ SysBusDevice parent_obj;
85
+ /*< public >*/
86
+
87
+ ARMv7MState armv7m;
88
+
89
+ char *cpu_type;
90
+ char *part_name;
91
+ uint64_t envm_size;
92
+ uint64_t esram_size;
93
+
94
+ uint32_t m3clk;
95
+ uint8_t apb0div;
96
+ uint8_t apb1div;
97
+
98
+ MSF2SysregState sysreg;
99
+ MSSTimerState timer;
100
+ MSSSpiState spi[MSF2_NUM_SPIS];
101
+} MSF2State;
102
+
103
+#endif
104
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
105
new file mode 100644
106
index XXXXXXX..XXXXXXX
107
--- /dev/null
108
+++ b/hw/arm/msf2-soc.c
109
@@ -XXX,XX +XXX,XX @@
45
@@ -XXX,XX +XXX,XX @@
110
+/*
46
'data': { '*node-id': 'int',
111
+ * SmartFusion2 SoC emulation.
47
'*socket-id': 'int',
112
+ *
48
'*die-id': 'int',
113
+ * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>
49
+ '*cluster-id': 'int',
114
+ *
50
'*core-id': 'int',
115
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
51
'*thread-id': 'int'
116
+ * of this software and associated documentation files (the "Software"), to deal
52
}
117
+ * in the Software without restriction, including without limitation the rights
53
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
118
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
54
index XXXXXXX..XXXXXXX 100644
119
+ * copies of the Software, and to permit persons to whom the Software is
55
--- a/hw/core/machine-hmp-cmds.c
120
+ * furnished to do so, subject to the following conditions:
56
+++ b/hw/core/machine-hmp-cmds.c
121
+ *
57
@@ -XXX,XX +XXX,XX @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
122
+ * The above copyright notice and this permission notice shall be included in
58
if (c->has_die_id) {
123
+ * all copies or substantial portions of the Software.
59
monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id);
124
+ *
60
}
125
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
61
+ if (c->has_cluster_id) {
126
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
62
+ monitor_printf(mon, " cluster-id: \"%" PRIu64 "\"\n",
127
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
63
+ c->cluster_id);
128
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
129
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
130
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
131
+ * THE SOFTWARE.
132
+ */
133
+
134
+#include "qemu/osdep.h"
135
+#include "qapi/error.h"
136
+#include "qemu-common.h"
137
+#include "hw/arm/arm.h"
138
+#include "exec/address-spaces.h"
139
+#include "hw/char/serial.h"
140
+#include "hw/boards.h"
141
+#include "sysemu/block-backend.h"
142
+#include "qemu/cutils.h"
143
+#include "hw/arm/msf2-soc.h"
144
+#include "hw/misc/unimp.h"
145
+
146
+#define MSF2_TIMER_BASE 0x40004000
147
+#define MSF2_SYSREG_BASE 0x40038000
148
+
149
+#define ENVM_BASE_ADDRESS 0x60000000
150
+
151
+#define SRAM_BASE_ADDRESS 0x20000000
152
+
153
+#define MSF2_ENVM_MAX_SIZE (512 * K_BYTE)
154
+
155
+/*
156
+ * eSRAM max size is 80k without SECDED(Single error correction and
157
+ * dual error detection) feature and 64k with SECDED.
158
+ * We do not support SECDED now.
159
+ */
160
+#define MSF2_ESRAM_MAX_SIZE (80 * K_BYTE)
161
+
162
+static const uint32_t spi_addr[MSF2_NUM_SPIS] = { 0x40001000 , 0x40011000 };
163
+static const uint32_t uart_addr[MSF2_NUM_UARTS] = { 0x40000000 , 0x40010000 };
164
+
165
+static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 };
166
+static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 };
167
+static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 };
168
+
169
+static void m2sxxx_soc_initfn(Object *obj)
170
+{
171
+ MSF2State *s = MSF2_SOC(obj);
172
+ int i;
173
+
174
+ object_initialize(&s->armv7m, sizeof(s->armv7m), TYPE_ARMV7M);
175
+ qdev_set_parent_bus(DEVICE(&s->armv7m), sysbus_get_default());
176
+
177
+ object_initialize(&s->sysreg, sizeof(s->sysreg), TYPE_MSF2_SYSREG);
178
+ qdev_set_parent_bus(DEVICE(&s->sysreg), sysbus_get_default());
179
+
180
+ object_initialize(&s->timer, sizeof(s->timer), TYPE_MSS_TIMER);
181
+ qdev_set_parent_bus(DEVICE(&s->timer), sysbus_get_default());
182
+
183
+ for (i = 0; i < MSF2_NUM_SPIS; i++) {
184
+ object_initialize(&s->spi[i], sizeof(s->spi[i]),
185
+ TYPE_MSS_SPI);
186
+ qdev_set_parent_bus(DEVICE(&s->spi[i]), sysbus_get_default());
187
+ }
188
+}
189
+
190
+static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
191
+{
192
+ MSF2State *s = MSF2_SOC(dev_soc);
193
+ DeviceState *dev, *armv7m;
194
+ SysBusDevice *busdev;
195
+ Error *err = NULL;
196
+ int i;
197
+
198
+ MemoryRegion *system_memory = get_system_memory();
199
+ MemoryRegion *nvm = g_new(MemoryRegion, 1);
200
+ MemoryRegion *nvm_alias = g_new(MemoryRegion, 1);
201
+ MemoryRegion *sram = g_new(MemoryRegion, 1);
202
+
203
+ memory_region_init_rom(nvm, NULL, "MSF2.eNVM", s->envm_size,
204
+ &error_fatal);
205
+ /*
206
+ * On power-on, the eNVM region 0x60000000 is automatically
207
+ * remapped to the Cortex-M3 processor executable region
208
+ * start address (0x0). We do not support remapping other eNVM,
209
+ * eSRAM and DDR regions by guest(via Sysreg) currently.
210
+ */
211
+ memory_region_init_alias(nvm_alias, NULL, "MSF2.eNVM",
212
+ nvm, 0, s->envm_size);
213
+
214
+ memory_region_add_subregion(system_memory, ENVM_BASE_ADDRESS, nvm);
215
+ memory_region_add_subregion(system_memory, 0, nvm_alias);
216
+
217
+ memory_region_init_ram(sram, NULL, "MSF2.eSRAM", s->esram_size,
218
+ &error_fatal);
219
+ memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, sram);
220
+
221
+ armv7m = DEVICE(&s->armv7m);
222
+ qdev_prop_set_uint32(armv7m, "num-irq", 81);
223
+ qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type);
224
+ object_property_set_link(OBJECT(&s->armv7m), OBJECT(get_system_memory()),
225
+ "memory", &error_abort);
226
+ object_property_set_bool(OBJECT(&s->armv7m), true, "realized", &err);
227
+ if (err != NULL) {
228
+ error_propagate(errp, err);
229
+ return;
230
+ }
231
+
232
+ if (!s->m3clk) {
233
+ error_setg(errp, "Invalid m3clk value");
234
+ error_append_hint(errp, "m3clk can not be zero\n");
235
+ return;
236
+ }
237
+ system_clock_scale = NANOSECONDS_PER_SECOND / s->m3clk;
238
+
239
+ for (i = 0; i < MSF2_NUM_UARTS; i++) {
240
+ if (serial_hds[i]) {
241
+ serial_mm_init(get_system_memory(), uart_addr[i], 2,
242
+ qdev_get_gpio_in(armv7m, uart_irq[i]),
243
+ 115200, serial_hds[i], DEVICE_NATIVE_ENDIAN);
244
+ }
64
+ }
245
+ }
65
if (c->has_core_id) {
246
+
66
monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_id);
247
+ dev = DEVICE(&s->timer);
67
}
248
+ /* APB0 clock is the timer input clock */
68
diff --git a/hw/core/machine.c b/hw/core/machine.c
249
+ qdev_prop_set_uint32(dev, "clock-frequency", s->m3clk / s->apb0div);
69
index XXXXXXX..XXXXXXX 100644
250
+ object_property_set_bool(OBJECT(&s->timer), true, "realized", &err);
70
--- a/hw/core/machine.c
251
+ if (err != NULL) {
71
+++ b/hw/core/machine.c
252
+ error_propagate(errp, err);
72
@@ -XXX,XX +XXX,XX @@ void machine_set_cpu_numa_node(MachineState *machine,
253
+ return;
73
return;
254
+ }
74
}
255
+ busdev = SYS_BUS_DEVICE(dev);
75
256
+ sysbus_mmio_map(busdev, 0, MSF2_TIMER_BASE);
76
+ if (props->has_cluster_id && !slot->props.has_cluster_id) {
257
+ sysbus_connect_irq(busdev, 0,
77
+ error_setg(errp, "cluster-id is not supported");
258
+ qdev_get_gpio_in(armv7m, timer_irq[0]));
259
+ sysbus_connect_irq(busdev, 1,
260
+ qdev_get_gpio_in(armv7m, timer_irq[1]));
261
+
262
+ dev = DEVICE(&s->sysreg);
263
+ qdev_prop_set_uint32(dev, "apb0divisor", s->apb0div);
264
+ qdev_prop_set_uint32(dev, "apb1divisor", s->apb1div);
265
+ object_property_set_bool(OBJECT(&s->sysreg), true, "realized", &err);
266
+ if (err != NULL) {
267
+ error_propagate(errp, err);
268
+ return;
269
+ }
270
+ busdev = SYS_BUS_DEVICE(dev);
271
+ sysbus_mmio_map(busdev, 0, MSF2_SYSREG_BASE);
272
+
273
+ for (i = 0; i < MSF2_NUM_SPIS; i++) {
274
+ gchar *bus_name;
275
+
276
+ object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err);
277
+ if (err != NULL) {
278
+ error_propagate(errp, err);
279
+ return;
78
+ return;
280
+ }
79
+ }
281
+
80
+
282
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]);
81
if (props->has_socket_id && !slot->props.has_socket_id) {
283
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0,
82
error_setg(errp, "socket-id is not supported");
284
+ qdev_get_gpio_in(armv7m, spi_irq[i]));
83
return;
84
@@ -XXX,XX +XXX,XX @@ void machine_set_cpu_numa_node(MachineState *machine,
85
continue;
86
}
87
88
+ if (props->has_cluster_id &&
89
+ props->cluster_id != slot->props.cluster_id) {
90
+ continue;
91
+ }
285
+
92
+
286
+ /* Alias controller SPI bus to the SoC itself */
93
if (props->has_die_id && props->die_id != slot->props.die_id) {
287
+ bus_name = g_strdup_printf("spi%d", i);
94
continue;
288
+ object_property_add_alias(OBJECT(s), bus_name,
95
}
289
+ OBJECT(&s->spi[i]), "spi",
96
@@ -XXX,XX +XXX,XX @@ static char *cpu_slot_to_string(const CPUArchId *cpu)
290
+ &error_abort);
97
}
291
+ g_free(bus_name);
98
g_string_append_printf(s, "die-id: %"PRId64, cpu->props.die_id);
99
}
100
+ if (cpu->props.has_cluster_id) {
101
+ if (s->len) {
102
+ g_string_append_printf(s, ", ");
103
+ }
104
+ g_string_append_printf(s, "cluster-id: %"PRId64, cpu->props.cluster_id);
292
+ }
105
+ }
293
+
106
if (cpu->props.has_core_id) {
294
+ /* Below devices are not modelled yet. */
107
if (s->len) {
295
+ create_unimplemented_device("i2c_0", 0x40002000, 0x1000);
108
g_string_append_printf(s, ", ");
296
+ create_unimplemented_device("dma", 0x40003000, 0x1000);
297
+ create_unimplemented_device("watchdog", 0x40005000, 0x1000);
298
+ create_unimplemented_device("i2c_1", 0x40012000, 0x1000);
299
+ create_unimplemented_device("gpio", 0x40013000, 0x1000);
300
+ create_unimplemented_device("hs-dma", 0x40014000, 0x1000);
301
+ create_unimplemented_device("can", 0x40015000, 0x1000);
302
+ create_unimplemented_device("rtc", 0x40017000, 0x1000);
303
+ create_unimplemented_device("apb_config", 0x40020000, 0x10000);
304
+ create_unimplemented_device("emac", 0x40041000, 0x1000);
305
+ create_unimplemented_device("usb", 0x40043000, 0x1000);
306
+}
307
+
308
+static Property m2sxxx_soc_properties[] = {
309
+ /*
310
+ * part name specifies the type of SmartFusion2 device variant(this
311
+ * property is for information purpose only.
312
+ */
313
+ DEFINE_PROP_STRING("cpu-type", MSF2State, cpu_type),
314
+ DEFINE_PROP_STRING("part-name", MSF2State, part_name),
315
+ DEFINE_PROP_UINT64("eNVM-size", MSF2State, envm_size, MSF2_ENVM_MAX_SIZE),
316
+ DEFINE_PROP_UINT64("eSRAM-size", MSF2State, esram_size,
317
+ MSF2_ESRAM_MAX_SIZE),
318
+ /* Libero GUI shows 100Mhz as default for clocks */
319
+ DEFINE_PROP_UINT32("m3clk", MSF2State, m3clk, 100 * 1000000),
320
+ /* default divisors in Libero GUI */
321
+ DEFINE_PROP_UINT8("apb0div", MSF2State, apb0div, 2),
322
+ DEFINE_PROP_UINT8("apb1div", MSF2State, apb1div, 2),
323
+ DEFINE_PROP_END_OF_LIST(),
324
+};
325
+
326
+static void m2sxxx_soc_class_init(ObjectClass *klass, void *data)
327
+{
328
+ DeviceClass *dc = DEVICE_CLASS(klass);
329
+
330
+ dc->realize = m2sxxx_soc_realize;
331
+ dc->props = m2sxxx_soc_properties;
332
+}
333
+
334
+static const TypeInfo m2sxxx_soc_info = {
335
+ .name = TYPE_MSF2_SOC,
336
+ .parent = TYPE_SYS_BUS_DEVICE,
337
+ .instance_size = sizeof(MSF2State),
338
+ .instance_init = m2sxxx_soc_initfn,
339
+ .class_init = m2sxxx_soc_class_init,
340
+};
341
+
342
+static void m2sxxx_soc_types(void)
343
+{
344
+ type_register_static(&m2sxxx_soc_info);
345
+}
346
+
347
+type_init(m2sxxx_soc_types)
348
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
349
index XXXXXXX..XXXXXXX 100644
350
--- a/default-configs/arm-softmmu.mak
351
+++ b/default-configs/arm-softmmu.mak
352
@@ -XXX,XX +XXX,XX @@ CONFIG_ACPI=y
353
CONFIG_SMBIOS=y
354
CONFIG_ASPEED_SOC=y
355
CONFIG_GPIO_KEY=y
356
+CONFIG_MSF2=y
357
--
109
--
358
2.7.4
110
2.25.1
359
360
diff view generated by jsdifflib
1
For v8M, the NVIC has a new set of registers per interrupt,
1
From: Gavin Shan <gshan@redhat.com>
2
NVIC_ITNS<n>. These determine whether the interrupt targets Secure
3
or Non-secure state. Implement the register read/write code for
4
these, and make them cause NVIC_IABR, NVIC_ICER, NVIC_ISER,
5
NVIC_ICPR, NVIC_IPR and NVIC_ISPR to RAZ/WI for non-secure
6
accesses to fields corresponding to interrupts which are
7
configured to target secure state.
8
2
3
The CPU topology isn't enabled on arm/virt machine yet, but we're
4
going to do it in next patch. After the CPU topology is enabled by
5
next patch, "thread-id=1" becomes invalid because the CPU core is
6
preferred on arm/virt machine. It means these two CPUs have 0/1
7
as their core IDs, but their thread IDs are all 0. It will trigger
8
test failure as the following message indicates:
9
10
[14/21 qemu:qtest+qtest-aarch64 / qtest-aarch64/numa-test ERROR
11
1.48s killed by signal 6 SIGABRT
12
>>> G_TEST_DBUS_DAEMON=/home/gavin/sandbox/qemu.main/tests/dbus-vmstate-daemon.sh \
13
QTEST_QEMU_STORAGE_DAEMON_BINARY=./storage-daemon/qemu-storage-daemon \
14
QTEST_QEMU_BINARY=./qemu-system-aarch64 \
15
QTEST_QEMU_IMG=./qemu-img MALLOC_PERTURB_=83 \
16
/home/gavin/sandbox/qemu.main/build/tests/qtest/numa-test --tap -k
17
――――――――――――――――――――――――――――――――――――――――――――――
18
stderr:
19
qemu-system-aarch64: -numa cpu,node-id=0,thread-id=1: no match found
20
21
This fixes the issue by providing comprehensive SMP configurations
22
in aarch64_numa_cpu(). The SMP configurations aren't used before
23
the CPU topology is enabled in next patch.
24
25
Signed-off-by: Gavin Shan <gshan@redhat.com>
26
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
27
Message-id: 20220503140304.855514-3-gshan@redhat.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 1505240046-11454-8-git-send-email-peter.maydell@linaro.org
12
---
29
---
13
include/hw/intc/armv7m_nvic.h | 3 ++
30
tests/qtest/numa-test.c | 3 ++-
14
hw/intc/armv7m_nvic.c | 74 +++++++++++++++++++++++++++++++++++++++----
31
1 file changed, 2 insertions(+), 1 deletion(-)
15
2 files changed, 70 insertions(+), 7 deletions(-)
16
32
17
diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h
33
diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c
18
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/intc/armv7m_nvic.h
35
--- a/tests/qtest/numa-test.c
20
+++ b/include/hw/intc/armv7m_nvic.h
36
+++ b/tests/qtest/numa-test.c
21
@@ -XXX,XX +XXX,XX @@ typedef struct NVICState {
37
@@ -XXX,XX +XXX,XX @@ static void aarch64_numa_cpu(const void *data)
22
/* The PRIGROUP field in AIRCR is banked */
38
QTestState *qts;
23
uint32_t prigroup[M_REG_NUM_BANKS];
39
g_autofree char *cli = NULL;
24
40
25
+ /* v8M NVIC_ITNS state (stored as a bool per bit) */
41
- cli = make_cli(data, "-machine smp.cpus=2 "
26
+ bool itns[NVIC_MAX_VECTORS];
42
+ cli = make_cli(data, "-machine "
27
+
43
+ "smp.cpus=2,smp.sockets=1,smp.clusters=1,smp.cores=1,smp.threads=2 "
28
/* The following fields are all cached state that can be recalculated
44
"-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
29
* from the vectors[] and sec_vectors[] arrays and the prigroup field:
45
"-numa cpu,node-id=1,thread-id=0 "
30
* - vectpending
46
"-numa cpu,node-id=0,thread-id=1");
31
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/intc/armv7m_nvic.c
34
+++ b/hw/intc/armv7m_nvic.c
35
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
36
switch (offset) {
37
case 4: /* Interrupt Control Type. */
38
return ((s->num_irq - NVIC_FIRST_IRQ) / 32) - 1;
39
+ case 0x380 ... 0x3bf: /* NVIC_ITNS<n> */
40
+ {
41
+ int startvec = 32 * (offset - 0x380) + NVIC_FIRST_IRQ;
42
+ int i;
43
+
44
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
45
+ goto bad_offset;
46
+ }
47
+ if (!attrs.secure) {
48
+ return 0;
49
+ }
50
+ val = 0;
51
+ for (i = 0; i < 32 && startvec + i < s->num_irq; i++) {
52
+ if (s->itns[startvec + i]) {
53
+ val |= (1 << i);
54
+ }
55
+ }
56
+ return val;
57
+ }
58
case 0xd00: /* CPUID Base. */
59
return cpu->midr;
60
case 0xd04: /* Interrupt Control State. */
61
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
62
ARMCPU *cpu = s->cpu;
63
64
switch (offset) {
65
+ case 0x380 ... 0x3bf: /* NVIC_ITNS<n> */
66
+ {
67
+ int startvec = 32 * (offset - 0x380) + NVIC_FIRST_IRQ;
68
+ int i;
69
+
70
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
71
+ goto bad_offset;
72
+ }
73
+ if (!attrs.secure) {
74
+ break;
75
+ }
76
+ for (i = 0; i < 32 && startvec + i < s->num_irq; i++) {
77
+ s->itns[startvec + i] = (value >> i) & 1;
78
+ }
79
+ nvic_irq_update(s);
80
+ break;
81
+ }
82
case 0xd04: /* Interrupt Control State. */
83
if (value & (1 << 31)) {
84
armv7m_nvic_set_pending(s, ARMV7M_EXCP_NMI);
85
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
86
startvec = offset - 0x180 + NVIC_FIRST_IRQ; /* vector # */
87
88
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
89
- if (s->vectors[startvec + i].enabled) {
90
+ if (s->vectors[startvec + i].enabled &&
91
+ (attrs.secure || s->itns[startvec + i])) {
92
val |= (1 << i);
93
}
94
}
95
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
96
val = 0;
97
startvec = offset - 0x280 + NVIC_FIRST_IRQ; /* vector # */
98
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
99
- if (s->vectors[startvec + i].pending) {
100
+ if (s->vectors[startvec + i].pending &&
101
+ (attrs.secure || s->itns[startvec + i])) {
102
val |= (1 << i);
103
}
104
}
105
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
106
startvec = offset - 0x300 + NVIC_FIRST_IRQ; /* vector # */
107
108
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
109
- if (s->vectors[startvec + i].active) {
110
+ if (s->vectors[startvec + i].active &&
111
+ (attrs.secure || s->itns[startvec + i])) {
112
val |= (1 << i);
113
}
114
}
115
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
116
startvec = offset - 0x400 + NVIC_FIRST_IRQ; /* vector # */
117
118
for (i = 0; i < size && startvec + i < s->num_irq; i++) {
119
- val |= s->vectors[startvec + i].prio << (8 * i);
120
+ if (attrs.secure || s->itns[startvec + i]) {
121
+ val |= s->vectors[startvec + i].prio << (8 * i);
122
+ }
123
}
124
break;
125
case 0xd18 ... 0xd23: /* System Handler Priority. */
126
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
127
startvec = 8 * (offset - 0x180) + NVIC_FIRST_IRQ;
128
129
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
130
- if (value & (1 << i)) {
131
+ if (value & (1 << i) &&
132
+ (attrs.secure || s->itns[startvec + i])) {
133
s->vectors[startvec + i].enabled = setval;
134
}
135
}
136
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
137
startvec = 8 * (offset - 0x280) + NVIC_FIRST_IRQ; /* vector # */
138
139
for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
140
- if (value & (1 << i)) {
141
+ if (value & (1 << i) &&
142
+ (attrs.secure || s->itns[startvec + i])) {
143
s->vectors[startvec + i].pending = setval;
144
}
145
}
146
@@ -XXX,XX +XXX,XX @@ static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
147
startvec = 8 * (offset - 0x400) + NVIC_FIRST_IRQ; /* vector # */
148
149
for (i = 0; i < size && startvec + i < s->num_irq; i++) {
150
- set_prio(s, startvec + i, (value >> (i * 8)) & 0xff);
151
+ if (attrs.secure || s->itns[startvec + i]) {
152
+ set_prio(s, startvec + i, (value >> (i * 8)) & 0xff);
153
+ }
154
}
155
nvic_irq_update(s);
156
return MEMTX_OK;
157
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_nvic_security = {
158
VMSTATE_STRUCT_ARRAY(sec_vectors, NVICState, NVIC_INTERNAL_VECTORS, 1,
159
vmstate_VecInfo, VecInfo),
160
VMSTATE_UINT32(prigroup[M_REG_S], NVICState),
161
+ VMSTATE_BOOL_ARRAY(itns, NVICState, NVIC_MAX_VECTORS),
162
VMSTATE_END_OF_LIST()
163
}
164
};
165
@@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_reset(DeviceState *dev)
166
s->vectpending = 0;
167
s->vectpending_is_s_banked = false;
168
s->vectpending_prio = NVIC_NOEXC_PRIO;
169
+
170
+ if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY)) {
171
+ memset(s->itns, 0, sizeof(s->itns));
172
+ } else {
173
+ /* This state is constant and not guest accessible in a non-security
174
+ * NVIC; we set the bits to true to avoid having to do a feature
175
+ * bit check in the NVIC enable/pend/etc register accessors.
176
+ */
177
+ int i;
178
+
179
+ for (i = NVIC_FIRST_IRQ; i < ARRAY_SIZE(s->itns); i++) {
180
+ s->itns[i] = true;
181
+ }
182
+ }
183
}
184
185
static void nvic_systick_trigger(void *opaque, int n, int level)
186
--
47
--
187
2.7.4
48
2.25.1
188
49
189
50
diff view generated by jsdifflib
1
Update nvic_exec_prio() to support the v8M changes:
1
From: Gavin Shan <gshan@redhat.com>
2
* BASEPRI, FAULTMASK and PRIMASK are all banked
3
* AIRCR.PRIS can affect NS priorities
4
* AIRCR.BFHFNMINS affects FAULTMASK behaviour
5
2
6
These changes mean that it's no longer possible to
3
Currently, the SMP configuration isn't considered when the CPU
7
definitely say that if FAULTMASK is set it overrides
4
topology is populated. In this case, it's impossible to provide
8
PRIMASK, and if PRIMASK is set it overrides BASEPRI
5
the default CPU-to-NUMA mapping or association based on the socket
9
(since if PRIMASK_NS is set and AIRCR.PRIS is set then
6
ID of the given CPU.
10
whether that 0x80 priority should take effect or the
11
priority in BASEPRI_S depends on the value of BASEPRI_S,
12
for instance). So we switch to the same approach used
13
by the pseudocode of working through BASEPRI, PRIMASK
14
and FAULTMASK and overriding the previous values if
15
needed.
16
7
8
This takes account of SMP configuration when the CPU topology
9
is populated. The die ID for the given CPU isn't assigned since
10
it's not supported on arm/virt machine. Besides, the used SMP
11
configuration in qtest/numa-test/aarch64_numa_cpu() is corrcted
12
to avoid testing failure
13
14
Signed-off-by: Gavin Shan <gshan@redhat.com>
15
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
16
Acked-by: Igor Mammedov <imammedo@redhat.com>
17
Message-id: 20220503140304.855514-4-gshan@redhat.com
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Message-id: 1505240046-11454-16-git-send-email-peter.maydell@linaro.org
20
---
19
---
21
hw/intc/armv7m_nvic.c | 51 ++++++++++++++++++++++++++++++++++++++++++---------
20
hw/arm/virt.c | 15 ++++++++++++++-
22
1 file changed, 42 insertions(+), 9 deletions(-)
21
1 file changed, 14 insertions(+), 1 deletion(-)
23
22
24
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
23
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
25
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/intc/armv7m_nvic.c
25
--- a/hw/arm/virt.c
27
+++ b/hw/intc/armv7m_nvic.c
26
+++ b/hw/arm/virt.c
28
@@ -XXX,XX +XXX,XX @@ static void nvic_recompute_state(NVICState *s)
27
@@ -XXX,XX +XXX,XX @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms)
29
static inline int nvic_exec_prio(NVICState *s)
28
int n;
30
{
29
unsigned int max_cpus = ms->smp.max_cpus;
31
CPUARMState *env = &s->cpu->env;
30
VirtMachineState *vms = VIRT_MACHINE(ms);
32
- int running;
31
+ MachineClass *mc = MACHINE_GET_CLASS(vms);
33
+ int running = NVIC_NOEXC_PRIO;
32
34
33
if (ms->possible_cpus) {
35
- if (env->v7m.faultmask[env->v7m.secure]) {
34
assert(ms->possible_cpus->len == max_cpus);
36
- running = -1;
35
@@ -XXX,XX +XXX,XX @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms)
37
- } else if (env->v7m.primask[env->v7m.secure]) {
36
ms->possible_cpus->cpus[n].type = ms->cpu_type;
38
+ if (env->v7m.basepri[M_REG_NS] > 0) {
37
ms->possible_cpus->cpus[n].arch_id =
39
+ running = exc_group_prio(s, env->v7m.basepri[M_REG_NS], M_REG_NS);
38
virt_cpu_mp_affinity(vms, n);
40
+ }
41
+
39
+
42
+ if (env->v7m.basepri[M_REG_S] > 0) {
40
+ assert(!mc->smp_props.dies_supported);
43
+ int basepri = exc_group_prio(s, env->v7m.basepri[M_REG_S], M_REG_S);
41
+ ms->possible_cpus->cpus[n].props.has_socket_id = true;
44
+ if (running > basepri) {
42
+ ms->possible_cpus->cpus[n].props.socket_id =
45
+ running = basepri;
43
+ n / (ms->smp.clusters * ms->smp.cores * ms->smp.threads);
46
+ }
44
+ ms->possible_cpus->cpus[n].props.has_cluster_id = true;
47
+ }
45
+ ms->possible_cpus->cpus[n].props.cluster_id =
48
+
46
+ (n / (ms->smp.cores * ms->smp.threads)) % ms->smp.clusters;
49
+ if (env->v7m.primask[M_REG_NS]) {
47
+ ms->possible_cpus->cpus[n].props.has_core_id = true;
50
+ if (env->v7m.aircr & R_V7M_AIRCR_PRIS_MASK) {
48
+ ms->possible_cpus->cpus[n].props.core_id =
51
+ if (running > NVIC_NS_PRIO_LIMIT) {
49
+ (n / ms->smp.threads) % ms->smp.cores;
52
+ running = NVIC_NS_PRIO_LIMIT;
50
ms->possible_cpus->cpus[n].props.has_thread_id = true;
53
+ }
51
- ms->possible_cpus->cpus[n].props.thread_id = n;
54
+ } else {
52
+ ms->possible_cpus->cpus[n].props.thread_id =
55
+ running = 0;
53
+ n % ms->smp.threads;
56
+ }
57
+ }
58
+
59
+ if (env->v7m.primask[M_REG_S]) {
60
running = 0;
61
- } else if (env->v7m.basepri[env->v7m.secure] > 0) {
62
- running = env->v7m.basepri[env->v7m.secure] &
63
- nvic_gprio_mask(s, env->v7m.secure);
64
- } else {
65
- running = NVIC_NOEXC_PRIO; /* lower than any possible priority */
66
}
54
}
67
+
55
return ms->possible_cpus;
68
+ if (env->v7m.faultmask[M_REG_NS]) {
69
+ if (env->v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
70
+ running = -1;
71
+ } else {
72
+ if (env->v7m.aircr & R_V7M_AIRCR_PRIS_MASK) {
73
+ if (running > NVIC_NS_PRIO_LIMIT) {
74
+ running = NVIC_NS_PRIO_LIMIT;
75
+ }
76
+ } else {
77
+ running = 0;
78
+ }
79
+ }
80
+ }
81
+
82
+ if (env->v7m.faultmask[M_REG_S]) {
83
+ running = (env->v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) ? -3 : -1;
84
+ }
85
+
86
/* consider priority of active handler */
87
return MIN(running, s->exception_prio);
88
}
56
}
89
--
57
--
90
2.7.4
58
2.25.1
91
92
diff view generated by jsdifflib
1
Update the code in nvic_rettobase() so that it checks the
1
From: Gavin Shan <gshan@redhat.com>
2
sec_vectors[] array as well as the vectors[] array if needed.
3
2
3
In aarch64_numa_cpu(), the CPU and NUMA association is something
4
like below. Two threads in the same core/cluster/socket are
5
associated with two individual NUMA nodes, which is unreal as
6
Igor Mammedov mentioned. We don't expect the association to break
7
NUMA-to-socket boundary, which matches with the real world.
8
9
NUMA-node socket cluster core thread
10
------------------------------------------
11
0 0 0 0 0
12
1 0 0 0 1
13
14
This corrects the topology for CPUs and their association with
15
NUMA nodes. After this patch is applied, the CPU and NUMA
16
association becomes something like below, which looks real.
17
Besides, socket/cluster/core/thread IDs are all checked when
18
the NUMA node IDs are verified. It helps to check if the CPU
19
topology is properly populated or not.
20
21
NUMA-node socket cluster core thread
22
------------------------------------------
23
0 1 0 0 0
24
1 0 0 0 0
25
26
Suggested-by: Igor Mammedov <imammedo@redhat.com>
27
Signed-off-by: Gavin Shan <gshan@redhat.com>
28
Acked-by: Igor Mammedov <imammedo@redhat.com>
29
Message-id: 20220503140304.855514-5-gshan@redhat.com
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 1505240046-11454-7-git-send-email-peter.maydell@linaro.org
7
---
31
---
8
hw/intc/armv7m_nvic.c | 5 ++++-
32
tests/qtest/numa-test.c | 18 ++++++++++++------
9
1 file changed, 4 insertions(+), 1 deletion(-)
33
1 file changed, 12 insertions(+), 6 deletions(-)
10
34
11
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
35
diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c
12
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/intc/armv7m_nvic.c
37
--- a/tests/qtest/numa-test.c
14
+++ b/hw/intc/armv7m_nvic.c
38
+++ b/tests/qtest/numa-test.c
15
@@ -XXX,XX +XXX,XX @@ static int nvic_pending_prio(NVICState *s)
39
@@ -XXX,XX +XXX,XX @@ static void aarch64_numa_cpu(const void *data)
16
static bool nvic_rettobase(NVICState *s)
40
g_autofree char *cli = NULL;
17
{
41
18
int irq, nhand = 0;
42
cli = make_cli(data, "-machine "
19
+ bool check_sec = arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY);
43
- "smp.cpus=2,smp.sockets=1,smp.clusters=1,smp.cores=1,smp.threads=2 "
20
44
+ "smp.cpus=2,smp.sockets=2,smp.clusters=1,smp.cores=1,smp.threads=1 "
21
for (irq = ARMV7M_EXCP_RESET; irq < s->num_irq; irq++) {
45
"-numa node,nodeid=0,memdev=ram -numa node,nodeid=1 "
22
- if (s->vectors[irq].active) {
46
- "-numa cpu,node-id=1,thread-id=0 "
23
+ if (s->vectors[irq].active ||
47
- "-numa cpu,node-id=0,thread-id=1");
24
+ (check_sec && irq < NVIC_INTERNAL_VECTORS &&
48
+ "-numa cpu,node-id=0,socket-id=1,cluster-id=0,core-id=0,thread-id=0 "
25
+ s->sec_vectors[irq].active)) {
49
+ "-numa cpu,node-id=1,socket-id=0,cluster-id=0,core-id=0,thread-id=0");
26
nhand++;
50
qts = qtest_init(cli);
27
if (nhand == 2) {
51
cpus = get_cpus(qts, &resp);
28
return 0;
52
g_assert(cpus);
53
54
while ((e = qlist_pop(cpus))) {
55
QDict *cpu, *props;
56
- int64_t thread, node;
57
+ int64_t socket, cluster, core, thread, node;
58
59
cpu = qobject_to(QDict, e);
60
g_assert(qdict_haskey(cpu, "props"));
61
@@ -XXX,XX +XXX,XX @@ static void aarch64_numa_cpu(const void *data)
62
63
g_assert(qdict_haskey(props, "node-id"));
64
node = qdict_get_int(props, "node-id");
65
+ g_assert(qdict_haskey(props, "socket-id"));
66
+ socket = qdict_get_int(props, "socket-id");
67
+ g_assert(qdict_haskey(props, "cluster-id"));
68
+ cluster = qdict_get_int(props, "cluster-id");
69
+ g_assert(qdict_haskey(props, "core-id"));
70
+ core = qdict_get_int(props, "core-id");
71
g_assert(qdict_haskey(props, "thread-id"));
72
thread = qdict_get_int(props, "thread-id");
73
74
- if (thread == 0) {
75
+ if (socket == 0 && cluster == 0 && core == 0 && thread == 0) {
76
g_assert_cmpint(node, ==, 1);
77
- } else if (thread == 1) {
78
+ } else if (socket == 1 && cluster == 0 && core == 0 && thread == 0) {
79
g_assert_cmpint(node, ==, 0);
80
} else {
81
g_assert(false);
29
--
82
--
30
2.7.4
83
2.25.1
31
32
diff view generated by jsdifflib
1
Instead of looking up the pending priority
1
From: Gavin Shan <gshan@redhat.com>
2
in nvic_pending_prio(), cache it in a new state struct
3
field. The calculation of the pending priority given
4
the interrupt number is more complicated in v8M with
5
the security extension, so the caching will be worthwhile.
6
2
7
This changes nvic_pending_prio() from returning a full
3
When CPU-to-NUMA association isn't explicitly provided by users,
8
(group + subpriority) priority value to returning a group
4
the default one is given by mc->get_default_cpu_node_id(). However,
9
priority. This doesn't require changes to its callsites
5
the CPU topology isn't fully considered in the default association
10
because we use it only in comparisons of the form
6
and this causes CPU topology broken warnings on booting Linux guest.
11
execution_prio > nvic_pending_prio()
12
and execution priority is always a group priority, so
13
a test (exec prio > full prio) is true if and only if
14
(execprio > group_prio).
15
7
16
(Architecturally the expected comparison is with the
8
For example, the following warning messages are observed when the
17
group priority for this sort of "would we preempt" test;
9
Linux guest is booted with the following command lines.
18
we were only doing a test with a full priority as an
19
optimisation to avoid the mask, which is possible
20
precisely because the two comparisons always give the
21
same answer.)
22
10
11
/home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \
12
-accel kvm -machine virt,gic-version=host \
13
-cpu host \
14
-smp 6,sockets=2,cores=3,threads=1 \
15
-m 1024M,slots=16,maxmem=64G \
16
-object memory-backend-ram,id=mem0,size=128M \
17
-object memory-backend-ram,id=mem1,size=128M \
18
-object memory-backend-ram,id=mem2,size=128M \
19
-object memory-backend-ram,id=mem3,size=128M \
20
-object memory-backend-ram,id=mem4,size=128M \
21
-object memory-backend-ram,id=mem4,size=384M \
22
-numa node,nodeid=0,memdev=mem0 \
23
-numa node,nodeid=1,memdev=mem1 \
24
-numa node,nodeid=2,memdev=mem2 \
25
-numa node,nodeid=3,memdev=mem3 \
26
-numa node,nodeid=4,memdev=mem4 \
27
-numa node,nodeid=5,memdev=mem5
28
:
29
alternatives: patching kernel code
30
BUG: arch topology borken
31
the CLS domain not a subset of the MC domain
32
<the above error log repeats>
33
BUG: arch topology borken
34
the DIE domain not a subset of the NODE domain
35
36
With current implementation of mc->get_default_cpu_node_id(),
37
CPU#0 to CPU#5 are associated with NODE#0 to NODE#5 separately.
38
That's incorrect because CPU#0/1/2 should be associated with same
39
NUMA node because they're seated in same socket.
40
41
This fixes the issue by considering the socket ID when the default
42
CPU-to-NUMA association is provided in virt_possible_cpu_arch_ids().
43
With this applied, no more CPU topology broken warnings are seen
44
from the Linux guest. The 6 CPUs are associated with NODE#0/1, but
45
there are no CPUs associated with NODE#2/3/4/5.
46
47
Signed-off-by: Gavin Shan <gshan@redhat.com>
48
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
49
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
50
Message-id: 20220503140304.855514-6-gshan@redhat.com
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
51
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
25
Message-id: 1505240046-11454-5-git-send-email-peter.maydell@linaro.org
26
---
52
---
27
include/hw/intc/armv7m_nvic.h | 2 ++
53
hw/arm/virt.c | 4 +++-
28
hw/intc/armv7m_nvic.c | 23 +++++++++++++----------
54
1 file changed, 3 insertions(+), 1 deletion(-)
29
hw/intc/trace-events | 2 +-
30
3 files changed, 16 insertions(+), 11 deletions(-)
31
55
32
diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h
56
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
33
index XXXXXXX..XXXXXXX 100644
57
index XXXXXXX..XXXXXXX 100644
34
--- a/include/hw/intc/armv7m_nvic.h
58
--- a/hw/arm/virt.c
35
+++ b/include/hw/intc/armv7m_nvic.h
59
+++ b/hw/arm/virt.c
36
@@ -XXX,XX +XXX,XX @@ typedef struct NVICState {
60
@@ -XXX,XX +XXX,XX @@ virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index)
37
* - vectpending
61
38
* - vectpending_is_secure
62
static int64_t virt_get_default_cpu_node_id(const MachineState *ms, int idx)
39
* - exception_prio
40
+ * - vectpending_prio
41
*/
42
unsigned int vectpending; /* highest prio pending enabled exception */
43
/* true if vectpending is a banked secure exception, ie it is in
44
@@ -XXX,XX +XXX,XX @@ typedef struct NVICState {
45
*/
46
bool vectpending_is_s_banked;
47
int exception_prio; /* group prio of the highest prio active exception */
48
+ int vectpending_prio; /* group prio of the exeception in vectpending */
49
50
MemoryRegion sysregmem;
51
MemoryRegion sysreg_ns_mem;
52
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/hw/intc/armv7m_nvic.c
55
+++ b/hw/intc/armv7m_nvic.c
56
@@ -XXX,XX +XXX,XX @@ static const uint8_t nvic_id[] = {
57
58
static int nvic_pending_prio(NVICState *s)
59
{
63
{
60
- /* return the priority of the current pending interrupt,
64
- return idx % ms->numa_state->num_nodes;
61
+ /* return the group priority of the current pending interrupt,
65
+ int64_t socket_id = ms->possible_cpus->cpus[idx].props.socket_id;
62
* or NVIC_NOEXC_PRIO if no interrupt is pending
66
+
63
*/
67
+ return socket_id % ms->numa_state->num_nodes;
64
- return s->vectpending ? s->vectors[s->vectpending].prio : NVIC_NOEXC_PRIO;
65
+ return s->vectpending_prio;
66
}
68
}
67
69
68
/* Return the value of the ISCR RETTOBASE bit:
70
static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms)
69
@@ -XXX,XX +XXX,XX @@ static void nvic_recompute_state(NVICState *s)
70
active_prio &= nvic_gprio_mask(s);
71
}
72
73
+ if (pend_prio > 0) {
74
+ pend_prio &= nvic_gprio_mask(s);
75
+ }
76
+
77
s->vectpending = pend_irq;
78
+ s->vectpending_prio = pend_prio;
79
s->exception_prio = active_prio;
80
81
- trace_nvic_recompute_state(s->vectpending, s->exception_prio);
82
+ trace_nvic_recompute_state(s->vectpending,
83
+ s->vectpending_prio,
84
+ s->exception_prio);
85
}
86
87
/* Return the current execution priority of the CPU
88
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque)
89
CPUARMState *env = &s->cpu->env;
90
const int pending = s->vectpending;
91
const int running = nvic_exec_prio(s);
92
- int pendgroupprio;
93
VecInfo *vec;
94
95
assert(pending > ARMV7M_EXCP_RESET && pending < s->num_irq);
96
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque)
97
assert(vec->enabled);
98
assert(vec->pending);
99
100
- pendgroupprio = vec->prio;
101
- if (pendgroupprio > 0) {
102
- pendgroupprio &= nvic_gprio_mask(s);
103
- }
104
- assert(pendgroupprio < running);
105
+ assert(s->vectpending_prio < running);
106
107
- trace_nvic_acknowledge_irq(pending, vec->prio);
108
+ trace_nvic_acknowledge_irq(pending, s->vectpending_prio);
109
110
vec->active = 1;
111
vec->pending = 0;
112
@@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_reset(DeviceState *dev)
113
s->exception_prio = NVIC_NOEXC_PRIO;
114
s->vectpending = 0;
115
s->vectpending_is_s_banked = false;
116
+ s->vectpending_prio = NVIC_NOEXC_PRIO;
117
}
118
119
static void nvic_systick_trigger(void *opaque, int n, int level)
120
diff --git a/hw/intc/trace-events b/hw/intc/trace-events
121
index XXXXXXX..XXXXXXX 100644
122
--- a/hw/intc/trace-events
123
+++ b/hw/intc/trace-events
124
@@ -XXX,XX +XXX,XX @@ gicv3_redist_set_irq(uint32_t cpu, int irq, int level) "GICv3 redistributor 0x%x
125
gicv3_redist_send_sgi(uint32_t cpu, int irq) "GICv3 redistributor 0x%x pending SGI %d"
126
127
# hw/intc/armv7m_nvic.c
128
-nvic_recompute_state(int vectpending, int exception_prio) "NVIC state recomputed: vectpending %d exception_prio %d"
129
+nvic_recompute_state(int vectpending, int vectpending_prio, int exception_prio) "NVIC state recomputed: vectpending %d vectpending_prio %d exception_prio %d"
130
nvic_set_prio(int irq, uint8_t prio) "NVIC set irq %d priority %d"
131
nvic_irq_update(int vectpending, int pendprio, int exception_prio, int level) "NVIC vectpending %d pending prio %d exception_prio %d: setting irq line to %d"
132
nvic_escalate_prio(int irq, int irqprio, int runprio) "NVIC escalating irq %d to HardFault: insufficient priority %d >= %d"
133
--
71
--
134
2.7.4
72
2.25.1
135
136
diff view generated by jsdifflib
1
With banked exceptions, just the exception number in
1
From: Gavin Shan <gshan@redhat.com>
2
s->vectpending is no longer sufficient to uniquely identify
3
the pending exception. Add a vectpending_is_s_banked bool
4
which is true if the exception is using the sec_vectors[]
5
array.
6
2
3
When the PPTT table is built, the CPU topology is re-calculated, but
4
it's unecessary because the CPU topology has been populated in
5
virt_possible_cpu_arch_ids() on arm/virt machine.
6
7
This reworks build_pptt() to avoid by reusing the existing IDs in
8
ms->possible_cpus. Currently, the only user of build_pptt() is
9
arm/virt machine.
10
11
Signed-off-by: Gavin Shan <gshan@redhat.com>
12
Tested-by: Yanan Wang <wangyanan55@huawei.com>
13
Reviewed-by: Yanan Wang <wangyanan55@huawei.com>
14
Acked-by: Igor Mammedov <imammedo@redhat.com>
15
Acked-by: Michael S. Tsirkin <mst@redhat.com>
16
Message-id: 20220503140304.855514-7-gshan@redhat.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 1505240046-11454-4-git-send-email-peter.maydell@linaro.org
9
---
18
---
10
include/hw/intc/armv7m_nvic.h | 11 +++++++++--
19
hw/acpi/aml-build.c | 111 +++++++++++++++++++-------------------------
11
hw/intc/armv7m_nvic.c | 1 +
20
1 file changed, 48 insertions(+), 63 deletions(-)
12
2 files changed, 10 insertions(+), 2 deletions(-)
13
21
14
diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h
22
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
15
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
16
--- a/include/hw/intc/armv7m_nvic.h
24
--- a/hw/acpi/aml-build.c
17
+++ b/include/hw/intc/armv7m_nvic.h
25
+++ b/hw/acpi/aml-build.c
18
@@ -XXX,XX +XXX,XX @@ typedef struct NVICState {
26
@@ -XXX,XX +XXX,XX @@ void build_pptt(GArray *table_data, BIOSLinker *linker, MachineState *ms,
19
VecInfo sec_vectors[NVIC_INTERNAL_VECTORS];
27
const char *oem_id, const char *oem_table_id)
20
uint32_t prigroup;
28
{
21
29
MachineClass *mc = MACHINE_GET_CLASS(ms);
22
- /* vectpending and exception_prio are both cached state that can
30
- GQueue *list = g_queue_new();
23
- * be recalculated from the vectors[] array and the prigroup field.
31
- guint pptt_start = table_data->len;
24
+ /* The following fields are all cached state that can be recalculated
32
- guint parent_offset;
25
+ * from the vectors[] and sec_vectors[] arrays and the prigroup field:
33
- guint length, i;
26
+ * - vectpending
34
- int uid = 0;
27
+ * - vectpending_is_secure
35
- int socket;
28
+ * - exception_prio
36
+ CPUArchIdList *cpus = ms->possible_cpus;
29
*/
37
+ int64_t socket_id = -1, cluster_id = -1, core_id = -1;
30
unsigned int vectpending; /* highest prio pending enabled exception */
38
+ uint32_t socket_offset = 0, cluster_offset = 0, core_offset = 0;
31
+ /* true if vectpending is a banked secure exception, ie it is in
39
+ uint32_t pptt_start = table_data->len;
32
+ * sec_vectors[] rather than vectors[]
40
+ int n;
41
AcpiTable table = { .sig = "PPTT", .rev = 2,
42
.oem_id = oem_id, .oem_table_id = oem_table_id };
43
44
acpi_table_begin(&table, table_data);
45
46
- for (socket = 0; socket < ms->smp.sockets; socket++) {
47
- g_queue_push_tail(list,
48
- GUINT_TO_POINTER(table_data->len - pptt_start));
49
- build_processor_hierarchy_node(
50
- table_data,
51
- /*
52
- * Physical package - represents the boundary
53
- * of a physical package
54
- */
55
- (1 << 0),
56
- 0, socket, NULL, 0);
57
- }
58
-
59
- if (mc->smp_props.clusters_supported) {
60
- length = g_queue_get_length(list);
61
- for (i = 0; i < length; i++) {
62
- int cluster;
63
-
64
- parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
65
- for (cluster = 0; cluster < ms->smp.clusters; cluster++) {
66
- g_queue_push_tail(list,
67
- GUINT_TO_POINTER(table_data->len - pptt_start));
68
- build_processor_hierarchy_node(
69
- table_data,
70
- (0 << 0), /* not a physical package */
71
- parent_offset, cluster, NULL, 0);
72
- }
73
+ /*
74
+ * This works with the assumption that cpus[n].props.*_id has been
75
+ * sorted from top to down levels in mc->possible_cpu_arch_ids().
76
+ * Otherwise, the unexpected and duplicated containers will be
77
+ * created.
33
+ */
78
+ */
34
+ bool vectpending_is_s_banked;
79
+ for (n = 0; n < cpus->len; n++) {
35
int exception_prio; /* group prio of the highest prio active exception */
80
+ if (cpus->cpus[n].props.socket_id != socket_id) {
36
81
+ assert(cpus->cpus[n].props.socket_id > socket_id);
37
MemoryRegion sysregmem;
82
+ socket_id = cpus->cpus[n].props.socket_id;
38
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
83
+ cluster_id = -1;
39
index XXXXXXX..XXXXXXX 100644
84
+ core_id = -1;
40
--- a/hw/intc/armv7m_nvic.c
85
+ socket_offset = table_data->len - pptt_start;
41
+++ b/hw/intc/armv7m_nvic.c
86
+ build_processor_hierarchy_node(table_data,
42
@@ -XXX,XX +XXX,XX @@ static void armv7m_nvic_reset(DeviceState *dev)
87
+ (1 << 0), /* Physical package */
43
88
+ 0, socket_id, NULL, 0);
44
s->exception_prio = NVIC_NOEXC_PRIO;
89
}
45
s->vectpending = 0;
90
- }
46
+ s->vectpending_is_s_banked = false;
91
92
- length = g_queue_get_length(list);
93
- for (i = 0; i < length; i++) {
94
- int core;
95
-
96
- parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
97
- for (core = 0; core < ms->smp.cores; core++) {
98
- if (ms->smp.threads > 1) {
99
- g_queue_push_tail(list,
100
- GUINT_TO_POINTER(table_data->len - pptt_start));
101
- build_processor_hierarchy_node(
102
- table_data,
103
- (0 << 0), /* not a physical package */
104
- parent_offset, core, NULL, 0);
105
- } else {
106
- build_processor_hierarchy_node(
107
- table_data,
108
- (1 << 1) | /* ACPI Processor ID valid */
109
- (1 << 3), /* Node is a Leaf */
110
- parent_offset, uid++, NULL, 0);
111
+ if (mc->smp_props.clusters_supported) {
112
+ if (cpus->cpus[n].props.cluster_id != cluster_id) {
113
+ assert(cpus->cpus[n].props.cluster_id > cluster_id);
114
+ cluster_id = cpus->cpus[n].props.cluster_id;
115
+ core_id = -1;
116
+ cluster_offset = table_data->len - pptt_start;
117
+ build_processor_hierarchy_node(table_data,
118
+ (0 << 0), /* Not a physical package */
119
+ socket_offset, cluster_id, NULL, 0);
120
}
121
+ } else {
122
+ cluster_offset = socket_offset;
123
}
124
- }
125
126
- length = g_queue_get_length(list);
127
- for (i = 0; i < length; i++) {
128
- int thread;
129
+ if (ms->smp.threads == 1) {
130
+ build_processor_hierarchy_node(table_data,
131
+ (1 << 1) | /* ACPI Processor ID valid */
132
+ (1 << 3), /* Node is a Leaf */
133
+ cluster_offset, n, NULL, 0);
134
+ } else {
135
+ if (cpus->cpus[n].props.core_id != core_id) {
136
+ assert(cpus->cpus[n].props.core_id > core_id);
137
+ core_id = cpus->cpus[n].props.core_id;
138
+ core_offset = table_data->len - pptt_start;
139
+ build_processor_hierarchy_node(table_data,
140
+ (0 << 0), /* Not a physical package */
141
+ cluster_offset, core_id, NULL, 0);
142
+ }
143
144
- parent_offset = GPOINTER_TO_UINT(g_queue_pop_head(list));
145
- for (thread = 0; thread < ms->smp.threads; thread++) {
146
- build_processor_hierarchy_node(
147
- table_data,
148
+ build_processor_hierarchy_node(table_data,
149
(1 << 1) | /* ACPI Processor ID valid */
150
(1 << 2) | /* Processor is a Thread */
151
(1 << 3), /* Node is a Leaf */
152
- parent_offset, uid++, NULL, 0);
153
+ core_offset, n, NULL, 0);
154
}
155
}
156
157
- g_queue_free(list);
158
acpi_table_end(linker, &table);
47
}
159
}
48
160
49
static void nvic_systick_trigger(void *opaque, int n, int level)
50
--
161
--
51
2.7.4
162
2.25.1
52
53
diff view generated by jsdifflib