1
Arm patch queue -- these are all bug fix patches but we might
1
The following changes since commit adf2e451f357e993f173ba9b4176dbf3e65fee7e:
2
as well put them in to rc0...
3
2
4
thanks
3
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-02-26 19:04:47 +0000)
5
-- PMM
6
7
The following changes since commit 2c8cfc0b52b5a4d123c26c0b5fdf941be24805be:
8
9
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2018-03-19 11:44:26 +0000)
10
4
11
are available in the Git repository at:
5
are available in the Git repository at:
12
6
13
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180319
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190228-1
14
8
15
for you to fetch changes up to ff72cb6b46b95bb530787add5277c211af3d31c6:
9
for you to fetch changes up to 1c9af3a9e05c1607a36df4943f8f5393d7621a91:
16
10
17
hw/arm/raspi: Provide spin-loop code for AArch64 CPUs (2018-03-19 18:23:24 +0000)
11
linux-user: Enable HWCAP_ASIMDFHM, HWCAP_JSCVT (2019-02-28 11:03:05 +0000)
18
12
19
----------------------------------------------------------------
13
----------------------------------------------------------------
20
target-arm queue:
14
target-arm queue:
21
* fsl-imx6: Fix incorrect Ethernet interrupt defines
15
* add MHU and dual-core support to Musca boards
22
* dump: Update correct kdump phys_base field for AArch64
16
* refactor some VFP insns to be gated by ID registers
23
* char: i.MX: Add support for "TX complete" interrupt
17
* Revert "arm: Allow system registers for KVM guests to be changed by QEMU code"
24
* bcm2836/raspi: Fix various bugs resulting in panics trying
18
* Implement ARMv8.2-FHM extension
25
to boot a Debian Linux kernel on raspi3
19
* Advertise JSCVT via HWCAP for linux-user
26
20
27
----------------------------------------------------------------
21
----------------------------------------------------------------
28
Andrey Smirnov (2):
22
Peter Maydell (11):
29
char: i.MX: Simplify imx_update()
23
hw/misc/armsse-mhu.c: Model the SSE-200 Message Handling Unit
30
char: i.MX: Add support for "TX complete" interrupt
24
hw/arm/armsse: Wire up the MHUs
25
target/arm/cpu: Allow init-svtor property to be set after realize
26
target/arm/arm-powerctl: Add new arm_set_cpu_on_and_reset()
27
hw/misc/iotkit-sysctl: Correct typo in INITSVTOR0 register name
28
hw/arm/iotkit-sysctl: Add SSE-200 registers
29
hw/arm/iotkit-sysctl: Implement CPUWAIT and INITSVTOR*
30
hw/arm/armsse: Unify init-svtor and cpuwait handling
31
target/arm: Use MVFR1 feature bits to gate A32/T32 FP16 instructions
32
target/arm: Gate "miscellaneous FP" insns by ID register field
33
Revert "arm: Allow system registers for KVM guests to be changed by QEMU code"
31
34
32
Guenter Roeck (1):
35
Richard Henderson (5):
33
fsl-imx6: Swap Ethernet interrupt defines
36
target/arm: Add helpers for FMLAL
37
target/arm: Implement FMLAL and FMLSL for aarch64
38
target/arm: Implement VFMAL and VFMSL for aarch32
39
target/arm: Enable ARMv8.2-FHM for -cpu max
40
linux-user: Enable HWCAP_ASIMDFHM, HWCAP_JSCVT
34
41
35
Peter Maydell (9):
42
hw/misc/Makefile.objs | 1 +
36
hw/arm/raspi: Don't do board-setup or secure-boot for raspi3
43
include/hw/arm/armsse.h | 3 +-
37
hw/arm/boot: assert that secure_boot and secure_board_setup are false for AArch64
44
include/hw/misc/armsse-mhu.h | 44 ++++++
38
hw/arm/boot: If booting a kernel in EL2, set SCR_EL3.HCE
45
include/hw/misc/iotkit-sysctl.h | 25 +++-
39
hw/arm/bcm2386: Fix parent type of bcm2386
46
target/arm/arm-powerctl.h | 16 +++
40
hw/arm/bcm2836: Rename bcm2836 type/struct to bcm283x
47
target/arm/cpu.h | 76 +++++++++--
41
hw/arm/bcm2836: Create proper bcm2837 device
48
target/arm/helper.h | 9 ++
42
hw/arm/bcm2836: Use correct affinity values for BCM2837
49
hw/arm/armsse.c | 91 +++++++++----
43
hw/arm/bcm2836: Hardcode correct CPU type
50
hw/misc/armsse-mhu.c | 198 +++++++++++++++++++++++++++
44
hw/arm/raspi: Provide spin-loop code for AArch64 CPUs
51
hw/misc/iotkit-sysctl.c | 294 ++++++++++++++++++++++++++++++++++++++--
52
linux-user/elfload.c | 2 +
53
target/arm/arm-powerctl.c | 56 ++++++++
54
target/arm/cpu.c | 32 ++++-
55
target/arm/cpu64.c | 2 +
56
target/arm/helper.c | 27 +---
57
target/arm/kvm32.c | 23 +++-
58
target/arm/kvm64.c | 2 -
59
target/arm/machine.c | 2 +-
60
target/arm/translate-a64.c | 49 ++++++-
61
target/arm/translate.c | 180 ++++++++++++++++--------
62
target/arm/vec_helper.c | 148 ++++++++++++++++++++
63
MAINTAINERS | 2 +
64
default-configs/arm-softmmu.mak | 1 +
65
hw/misc/trace-events | 4 +
66
24 files changed, 1139 insertions(+), 148 deletions(-)
67
create mode 100644 include/hw/misc/armsse-mhu.h
68
create mode 100644 hw/misc/armsse-mhu.c
45
69
46
Wei Huang (1):
47
dump: Update correct kdump phys_base field for AArch64
48
49
include/hw/arm/bcm2836.h | 31 +++++++++++++---
50
include/hw/arm/fsl-imx6.h | 4 +-
51
include/hw/char/imx_serial.h | 3 ++
52
dump.c | 14 +++++--
53
hw/arm/bcm2836.c | 87 +++++++++++++++++++++++++++++++-------------
54
hw/arm/boot.c | 12 ++++++
55
hw/arm/raspi.c | 77 +++++++++++++++++++++++++++++++--------
56
hw/char/imx_serial.c | 44 ++++++++++++++++------
57
hw/net/imx_fec.c | 28 +++++++++++++-
58
9 files changed, 237 insertions(+), 63 deletions(-)
59
diff view generated by jsdifflib
1
The bcm2837 is pretty similar to the bcm2836, but it does have
1
Implement a model of the Message Handling Unit (MHU) found in
2
some differences. Notably, the MPIDR affinity aff1 values it
2
the Arm SSE-200. This is a simple device which just contains
3
sets for the CPUs are 0x0, rather than the 0xf that the bcm2836
3
some registers which allow the two cores of the SSE-200
4
uses, and if this is wrong Linux will not boot.
4
to raise interrupts on each other.
5
6
Rather than trying to have one device with properties that
7
configure it differently for the two cases, create two
8
separate QOM devices for the two SoCs. We use the same approach
9
as hw/arm/aspeed_soc.c and share code and have a data table
10
that might differ per-SoC. For the moment the two types don't
11
actually have different behaviour.
12
5
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20180313153458.26822-7-peter.maydell@linaro.org
8
Message-id: 20190219125808.25174-2-peter.maydell@linaro.org
16
---
9
---
17
include/hw/arm/bcm2836.h | 19 +++++++++++++++++++
10
hw/misc/Makefile.objs | 1 +
18
hw/arm/bcm2836.c | 37 ++++++++++++++++++++++++++++++++-----
11
include/hw/misc/armsse-mhu.h | 44 +++++++
19
hw/arm/raspi.c | 3 ++-
12
hw/misc/armsse-mhu.c | 198 ++++++++++++++++++++++++++++++++
20
3 files changed, 53 insertions(+), 6 deletions(-)
13
MAINTAINERS | 2 +
14
default-configs/arm-softmmu.mak | 1 +
15
hw/misc/trace-events | 4 +
16
6 files changed, 250 insertions(+)
17
create mode 100644 include/hw/misc/armsse-mhu.h
18
create mode 100644 hw/misc/armsse-mhu.c
21
19
22
diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h
20
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
23
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
24
--- a/include/hw/arm/bcm2836.h
22
--- a/hw/misc/Makefile.objs
25
+++ b/include/hw/arm/bcm2836.h
23
+++ b/hw/misc/Makefile.objs
24
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_IOTKIT_SECCTL) += iotkit-secctl.o
25
obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
26
obj-$(CONFIG_IOTKIT_SYSINFO) += iotkit-sysinfo.o
27
obj-$(CONFIG_ARMSSE_CPUID) += armsse-cpuid.o
28
+obj-$(CONFIG_ARMSSE_MHU) += armsse-mhu.o
29
30
obj-$(CONFIG_PVPANIC) += pvpanic.o
31
obj-$(CONFIG_AUX) += auxbus.o
32
diff --git a/include/hw/misc/armsse-mhu.h b/include/hw/misc/armsse-mhu.h
33
new file mode 100644
34
index XXXXXXX..XXXXXXX
35
--- /dev/null
36
+++ b/include/hw/misc/armsse-mhu.h
26
@@ -XXX,XX +XXX,XX @@
37
@@ -XXX,XX +XXX,XX @@
27
38
+/*
28
#define BCM283X_NCPUS 4
39
+ * ARM SSE-200 Message Handling Unit (MHU)
29
40
+ *
30
+/* These type names are for specific SoCs; other than instantiating
41
+ * Copyright (c) 2019 Linaro Limited
31
+ * them, code using these devices should always handle them via the
42
+ * Written by Peter Maydell
32
+ * BCM283x base class, so they have no BCM2836(obj) etc macros.
43
+ *
44
+ * This program is free software; you can redistribute it and/or modify
45
+ * it under the terms of the GNU General Public License version 2 or
46
+ * (at your option) any later version.
33
+ */
47
+ */
34
+#define TYPE_BCM2836 "bcm2836"
48
+
35
+#define TYPE_BCM2837 "bcm2837"
49
+/*
36
+
50
+ * This is a model of the Message Handling Unit (MHU) which is part of the
37
typedef struct BCM283XState {
51
+ * Arm SSE-200 and documented in
38
/*< private >*/
52
+ * http://infocenter.arm.com/help/topic/com.arm.doc.101104_0100_00_en/corelink_sse200_subsystem_for_embedded_technical_reference_manual_101104_0100_00_en.pdf
39
DeviceState parent_obj;
53
+ *
40
@@ -XXX,XX +XXX,XX @@ typedef struct BCM283XState {
54
+ * QEMU interface:
41
BCM2835PeripheralState peripherals;
55
+ * + sysbus MMIO region 0: the system information register bank
42
} BCM283XState;
56
+ * + sysbus IRQ 0: interrupt for CPU 0
43
57
+ * + sysbus IRQ 1: interrupt for CPU 1
44
+typedef struct BCM283XInfo BCM283XInfo;
58
+ */
45
+
59
+
46
+typedef struct BCM283XClass {
60
+#ifndef HW_MISC_SSE_MHU_H
47
+ DeviceClass parent_class;
61
+#define HW_MISC_SSE_MHU_H
48
+ const BCM283XInfo *info;
62
+
49
+} BCM283XClass;
63
+#include "hw/sysbus.h"
50
+
64
+
51
+#define BCM283X_CLASS(klass) \
65
+#define TYPE_ARMSSE_MHU "armsse-mhu"
52
+ OBJECT_CLASS_CHECK(BCM283XClass, (klass), TYPE_BCM283X)
66
+#define ARMSSE_MHU(obj) OBJECT_CHECK(ARMSSEMHU, (obj), TYPE_ARMSSE_MHU)
53
+#define BCM283X_GET_CLASS(obj) \
67
+
54
+ OBJECT_GET_CLASS(BCM283XClass, (obj), TYPE_BCM283X)
68
+typedef struct ARMSSEMHU {
55
+
69
+ /*< private >*/
56
#endif /* BCM2836_H */
70
+ SysBusDevice parent_obj;
57
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
71
+
58
index XXXXXXX..XXXXXXX 100644
72
+ /*< public >*/
59
--- a/hw/arm/bcm2836.c
73
+ MemoryRegion iomem;
60
+++ b/hw/arm/bcm2836.c
74
+ qemu_irq cpu0irq;
75
+ qemu_irq cpu1irq;
76
+
77
+ uint32_t cpu0intr;
78
+ uint32_t cpu1intr;
79
+} ARMSSEMHU;
80
+
81
+#endif
82
diff --git a/hw/misc/armsse-mhu.c b/hw/misc/armsse-mhu.c
83
new file mode 100644
84
index XXXXXXX..XXXXXXX
85
--- /dev/null
86
+++ b/hw/misc/armsse-mhu.c
61
@@ -XXX,XX +XXX,XX @@
87
@@ -XXX,XX +XXX,XX @@
62
/* "QA7" (Pi2) interrupt controller and mailboxes etc. */
88
+/*
63
#define BCM2836_CONTROL_BASE 0x40000000
89
+ * ARM SSE-200 Message Handling Unit (MHU)
64
90
+ *
65
+struct BCM283XInfo {
91
+ * Copyright (c) 2019 Linaro Limited
66
+ const char *name;
92
+ * Written by Peter Maydell
93
+ *
94
+ * This program is free software; you can redistribute it and/or modify
95
+ * it under the terms of the GNU General Public License version 2 or
96
+ * (at your option) any later version.
97
+ */
98
+
99
+/*
100
+ * This is a model of the Message Handling Unit (MHU) which is part of the
101
+ * Arm SSE-200 and documented in
102
+ * http://infocenter.arm.com/help/topic/com.arm.doc.101104_0100_00_en/corelink_sse200_subsystem_for_embedded_technical_reference_manual_101104_0100_00_en.pdf
103
+ */
104
+
105
+#include "qemu/osdep.h"
106
+#include "qemu/log.h"
107
+#include "trace.h"
108
+#include "qapi/error.h"
109
+#include "sysemu/sysemu.h"
110
+#include "hw/sysbus.h"
111
+#include "hw/registerfields.h"
112
+#include "hw/misc/armsse-mhu.h"
113
+
114
+REG32(CPU0INTR_STAT, 0x0)
115
+REG32(CPU0INTR_SET, 0x4)
116
+REG32(CPU0INTR_CLR, 0x8)
117
+REG32(CPU1INTR_STAT, 0x10)
118
+REG32(CPU1INTR_SET, 0x14)
119
+REG32(CPU1INTR_CLR, 0x18)
120
+REG32(PID4, 0xfd0)
121
+REG32(PID5, 0xfd4)
122
+REG32(PID6, 0xfd8)
123
+REG32(PID7, 0xfdc)
124
+REG32(PID0, 0xfe0)
125
+REG32(PID1, 0xfe4)
126
+REG32(PID2, 0xfe8)
127
+REG32(PID3, 0xfec)
128
+REG32(CID0, 0xff0)
129
+REG32(CID1, 0xff4)
130
+REG32(CID2, 0xff8)
131
+REG32(CID3, 0xffc)
132
+
133
+/* Valid bits in the interrupt registers. If any are set the IRQ is raised */
134
+#define INTR_MASK 0xf
135
+
136
+/* PID/CID values */
137
+static const int armsse_mhu_id[] = {
138
+ 0x04, 0x00, 0x00, 0x00, /* PID4..PID7 */
139
+ 0x56, 0xb8, 0x0b, 0x00, /* PID0..PID3 */
140
+ 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
67
+};
141
+};
68
+
142
+
69
+static const BCM283XInfo bcm283x_socs[] = {
143
+static void armsse_mhu_update(ARMSSEMHU *s)
70
+ {
144
+{
71
+ .name = TYPE_BCM2836,
145
+ qemu_set_irq(s->cpu0irq, s->cpu0intr != 0);
72
+ },
146
+ qemu_set_irq(s->cpu1irq, s->cpu1intr != 0);
73
+ {
147
+}
74
+ .name = TYPE_BCM2837,
148
+
149
+static uint64_t armsse_mhu_read(void *opaque, hwaddr offset, unsigned size)
150
+{
151
+ ARMSSEMHU *s = ARMSSE_MHU(opaque);
152
+ uint64_t r;
153
+
154
+ switch (offset) {
155
+ case A_CPU0INTR_STAT:
156
+ r = s->cpu0intr;
157
+ break;
158
+
159
+ case A_CPU1INTR_STAT:
160
+ r = s->cpu1intr;
161
+ break;
162
+
163
+ case A_PID4 ... A_CID3:
164
+ r = armsse_mhu_id[(offset - A_PID4) / 4];
165
+ break;
166
+
167
+ case A_CPU0INTR_SET:
168
+ case A_CPU0INTR_CLR:
169
+ case A_CPU1INTR_SET:
170
+ case A_CPU1INTR_CLR:
171
+ qemu_log_mask(LOG_GUEST_ERROR,
172
+ "SSE MHU: read of write-only register at offset 0x%x\n",
173
+ (int)offset);
174
+ r = 0;
175
+ break;
176
+
177
+ default:
178
+ qemu_log_mask(LOG_GUEST_ERROR,
179
+ "SSE MHU read: bad offset 0x%x\n", (int)offset);
180
+ r = 0;
181
+ break;
182
+ }
183
+ trace_armsse_mhu_read(offset, r, size);
184
+ return r;
185
+}
186
+
187
+static void armsse_mhu_write(void *opaque, hwaddr offset,
188
+ uint64_t value, unsigned size)
189
+{
190
+ ARMSSEMHU *s = ARMSSE_MHU(opaque);
191
+
192
+ trace_armsse_mhu_write(offset, value, size);
193
+
194
+ switch (offset) {
195
+ case A_CPU0INTR_SET:
196
+ s->cpu0intr |= (value & INTR_MASK);
197
+ break;
198
+ case A_CPU0INTR_CLR:
199
+ s->cpu0intr &= ~(value & INTR_MASK);
200
+ break;
201
+ case A_CPU1INTR_SET:
202
+ s->cpu1intr |= (value & INTR_MASK);
203
+ break;
204
+ case A_CPU1INTR_CLR:
205
+ s->cpu1intr &= ~(value & INTR_MASK);
206
+ break;
207
+
208
+ case A_CPU0INTR_STAT:
209
+ case A_CPU1INTR_STAT:
210
+ case A_PID4 ... A_CID3:
211
+ qemu_log_mask(LOG_GUEST_ERROR,
212
+ "SSE MHU: write to read-only register at offset 0x%x\n",
213
+ (int)offset);
214
+ break;
215
+
216
+ default:
217
+ qemu_log_mask(LOG_GUEST_ERROR,
218
+ "SSE MHU write: bad offset 0x%x\n", (int)offset);
219
+ break;
220
+ }
221
+
222
+ armsse_mhu_update(s);
223
+}
224
+
225
+static const MemoryRegionOps armsse_mhu_ops = {
226
+ .read = armsse_mhu_read,
227
+ .write = armsse_mhu_write,
228
+ .endianness = DEVICE_LITTLE_ENDIAN,
229
+ .valid.min_access_size = 4,
230
+ .valid.max_access_size = 4,
231
+};
232
+
233
+static void armsse_mhu_reset(DeviceState *dev)
234
+{
235
+ ARMSSEMHU *s = ARMSSE_MHU(dev);
236
+
237
+ s->cpu0intr = 0;
238
+ s->cpu1intr = 0;
239
+}
240
+
241
+static const VMStateDescription armsse_mhu_vmstate = {
242
+ .name = "armsse-mhu",
243
+ .version_id = 1,
244
+ .minimum_version_id = 1,
245
+ .fields = (VMStateField[]) {
246
+ VMSTATE_UINT32(cpu0intr, ARMSSEMHU),
247
+ VMSTATE_UINT32(cpu1intr, ARMSSEMHU),
248
+ VMSTATE_END_OF_LIST()
75
+ },
249
+ },
76
+};
250
+};
77
+
251
+
78
static void bcm2836_init(Object *obj)
252
+static void armsse_mhu_init(Object *obj)
79
{
253
+{
80
BCM283XState *s = BCM283X(obj);
254
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
81
@@ -XXX,XX +XXX,XX @@ static Property bcm2836_props[] = {
255
+ ARMSSEMHU *s = ARMSSE_MHU(obj);
82
DEFINE_PROP_END_OF_LIST()
256
+
83
};
257
+ memory_region_init_io(&s->iomem, obj, &armsse_mhu_ops,
84
258
+ s, "armsse-mhu", 0x1000);
85
-static void bcm2836_class_init(ObjectClass *oc, void *data)
259
+ sysbus_init_mmio(sbd, &s->iomem);
86
+static void bcm283x_class_init(ObjectClass *oc, void *data)
260
+ sysbus_init_irq(sbd, &s->cpu0irq);
87
{
261
+ sysbus_init_irq(sbd, &s->cpu1irq);
88
DeviceClass *dc = DEVICE_CLASS(oc);
262
+}
89
+ BCM283XClass *bc = BCM283X_CLASS(oc);
263
+
90
264
+static void armsse_mhu_class_init(ObjectClass *klass, void *data)
91
- dc->props = bcm2836_props;
265
+{
92
+ bc->info = data;
266
+ DeviceClass *dc = DEVICE_CLASS(klass);
93
dc->realize = bcm2836_realize;
267
+
94
+ dc->props = bcm2836_props;
268
+ dc->reset = armsse_mhu_reset;
95
}
269
+ dc->vmsd = &armsse_mhu_vmstate;
96
270
+}
97
-static const TypeInfo bcm2836_type_info = {
271
+
98
+static const TypeInfo bcm283x_type_info = {
272
+static const TypeInfo armsse_mhu_info = {
99
.name = TYPE_BCM283X,
273
+ .name = TYPE_ARMSSE_MHU,
100
.parent = TYPE_DEVICE,
274
+ .parent = TYPE_SYS_BUS_DEVICE,
101
.instance_size = sizeof(BCM283XState),
275
+ .instance_size = sizeof(ARMSSEMHU),
102
.instance_init = bcm2836_init,
276
+ .instance_init = armsse_mhu_init,
103
- .class_init = bcm2836_class_init,
277
+ .class_init = armsse_mhu_class_init,
104
+ .class_size = sizeof(BCM283XClass),
278
+};
105
+ .abstract = true,
279
+
106
};
280
+static void armsse_mhu_register_types(void)
107
281
+{
108
static void bcm2836_register_types(void)
282
+ type_register_static(&armsse_mhu_info);
109
{
283
+}
110
- type_register_static(&bcm2836_type_info);
284
+
111
+ int i;
285
+type_init(armsse_mhu_register_types);
112
+
286
diff --git a/MAINTAINERS b/MAINTAINERS
113
+ type_register_static(&bcm283x_type_info);
114
+ for (i = 0; i < ARRAY_SIZE(bcm283x_socs); i++) {
115
+ TypeInfo ti = {
116
+ .name = bcm283x_socs[i].name,
117
+ .parent = TYPE_BCM283X,
118
+ .class_init = bcm283x_class_init,
119
+ .class_data = (void *) &bcm283x_socs[i],
120
+ };
121
+ type_register(&ti);
122
+ }
123
}
124
125
type_init(bcm2836_register_types)
126
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
127
index XXXXXXX..XXXXXXX 100644
287
index XXXXXXX..XXXXXXX 100644
128
--- a/hw/arm/raspi.c
288
--- a/MAINTAINERS
129
+++ b/hw/arm/raspi.c
289
+++ b/MAINTAINERS
130
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
290
@@ -XXX,XX +XXX,XX @@ F: hw/misc/iotkit-sysinfo.c
131
BusState *bus;
291
F: include/hw/misc/iotkit-sysinfo.h
132
DeviceState *carddev;
292
F: hw/misc/armsse-cpuid.c
133
293
F: include/hw/misc/armsse-cpuid.h
134
- object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X);
294
+F: hw/misc/armsse-mhu.c
135
+ object_initialize(&s->soc, sizeof(s->soc),
295
+F: include/hw/misc/armsse-mhu.h
136
+ version == 3 ? TYPE_BCM2837 : TYPE_BCM2836);
296
137
object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
297
Musca
138
&error_abort);
298
M: Peter Maydell <peter.maydell@linaro.org>
139
299
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
300
index XXXXXXX..XXXXXXX 100644
301
--- a/default-configs/arm-softmmu.mak
302
+++ b/default-configs/arm-softmmu.mak
303
@@ -XXX,XX +XXX,XX @@ CONFIG_IOTKIT_SECCTL=y
304
CONFIG_IOTKIT_SYSCTL=y
305
CONFIG_IOTKIT_SYSINFO=y
306
CONFIG_ARMSSE_CPUID=y
307
+CONFIG_ARMSSE_MHU=y
308
309
CONFIG_VERSATILE=y
310
CONFIG_VERSATILE_PCI=y
311
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
312
index XXXXXXX..XXXXXXX 100644
313
--- a/hw/misc/trace-events
314
+++ b/hw/misc/trace-events
315
@@ -XXX,XX +XXX,XX @@ iotkit_sysctl_reset(void) "IoTKit SysCtl: reset"
316
# hw/misc/armsse-cpuid.c
317
armsse_cpuid_read(uint64_t offset, uint64_t data, unsigned size) "SSE-200 CPU_IDENTITY read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
318
armsse_cpuid_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 CPU_IDENTITY write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
319
+
320
+# hw/misc/armsse-mhu.c
321
+armsse_mhu_read(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
322
+armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
140
--
323
--
141
2.16.2
324
2.20.1
142
325
143
326
diff view generated by jsdifflib
New patch
1
Create and connect the MHUs in the SSE-200.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190219125808.25174-3-peter.maydell@linaro.org
6
---
7
include/hw/arm/armsse.h | 3 ++-
8
hw/arm/armsse.c | 40 ++++++++++++++++++++++++++++++----------
9
2 files changed, 32 insertions(+), 11 deletions(-)
10
11
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
12
index XXXXXXX..XXXXXXX 100644
13
--- a/include/hw/arm/armsse.h
14
+++ b/include/hw/arm/armsse.h
15
@@ -XXX,XX +XXX,XX @@
16
#include "hw/misc/iotkit-sysctl.h"
17
#include "hw/misc/iotkit-sysinfo.h"
18
#include "hw/misc/armsse-cpuid.h"
19
+#include "hw/misc/armsse-mhu.h"
20
#include "hw/misc/unimp.h"
21
#include "hw/or-irq.h"
22
#include "hw/core/split-irq.h"
23
@@ -XXX,XX +XXX,XX @@ typedef struct ARMSSE {
24
IoTKitSysCtl sysctl;
25
IoTKitSysCtl sysinfo;
26
27
- UnimplementedDeviceState mhu[2];
28
+ ARMSSEMHU mhu[2];
29
UnimplementedDeviceState ppu[NUM_PPUS];
30
UnimplementedDeviceState cachectrl[SSE_MAX_CPUS];
31
UnimplementedDeviceState cpusecctrl[SSE_MAX_CPUS];
32
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/armsse.c
35
+++ b/hw/arm/armsse.c
36
@@ -XXX,XX +XXX,XX @@ static void armsse_init(Object *obj)
37
sizeof(s->sysinfo), TYPE_IOTKIT_SYSINFO);
38
if (info->has_mhus) {
39
sysbus_init_child_obj(obj, "mhu0", &s->mhu[0], sizeof(s->mhu[0]),
40
- TYPE_UNIMPLEMENTED_DEVICE);
41
+ TYPE_ARMSSE_MHU);
42
sysbus_init_child_obj(obj, "mhu1", &s->mhu[1], sizeof(s->mhu[1]),
43
- TYPE_UNIMPLEMENTED_DEVICE);
44
+ TYPE_ARMSSE_MHU);
45
}
46
if (info->has_ppus) {
47
for (i = 0; i < info->num_cpus; i++) {
48
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
49
}
50
51
if (info->has_mhus) {
52
- for (i = 0; i < ARRAY_SIZE(s->mhu); i++) {
53
- char *name;
54
- char *port;
55
+ /*
56
+ * An SSE-200 with only one CPU should have only one MHU created,
57
+ * with the region where the second MHU usually is being RAZ/WI.
58
+ * We don't implement that SSE-200 config; if we want to support
59
+ * it then this code needs to be enhanced to handle creating the
60
+ * RAZ/WI region instead of the second MHU.
61
+ */
62
+ assert(info->num_cpus == ARRAY_SIZE(s->mhu));
63
+
64
+ for (i = 0; i < ARRAY_SIZE(s->mhu); i++) {
65
+ char *port;
66
+ int cpunum;
67
+ SysBusDevice *mhu_sbd = SYS_BUS_DEVICE(&s->mhu[i]);
68
69
- name = g_strdup_printf("MHU%d", i);
70
- qdev_prop_set_string(DEVICE(&s->mhu[i]), "name", name);
71
- qdev_prop_set_uint64(DEVICE(&s->mhu[i]), "size", 0x1000);
72
object_property_set_bool(OBJECT(&s->mhu[i]), true,
73
"realized", &err);
74
- g_free(name);
75
if (err) {
76
error_propagate(errp, err);
77
return;
78
}
79
port = g_strdup_printf("port[%d]", i + 3);
80
- mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mhu[i]), 0);
81
+ mr = sysbus_mmio_get_region(mhu_sbd, 0);
82
object_property_set_link(OBJECT(&s->apb_ppc0), OBJECT(mr),
83
port, &err);
84
g_free(port);
85
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
86
error_propagate(errp, err);
87
return;
88
}
89
+
90
+ /*
91
+ * Each MHU has an irq line for each CPU:
92
+ * MHU 0 irq line 0 -> CPU 0 IRQ 6
93
+ * MHU 0 irq line 1 -> CPU 1 IRQ 6
94
+ * MHU 1 irq line 0 -> CPU 0 IRQ 7
95
+ * MHU 1 irq line 1 -> CPU 1 IRQ 7
96
+ */
97
+ for (cpunum = 0; cpunum < info->num_cpus; cpunum++) {
98
+ DeviceState *cpudev = DEVICE(&s->armv7m[cpunum]);
99
+
100
+ sysbus_connect_irq(mhu_sbd, cpunum,
101
+ qdev_get_gpio_in(cpudev, 6 + i));
102
+ }
103
}
104
}
105
106
--
107
2.20.1
108
109
diff view generated by jsdifflib
1
The TypeInfo and state struct for bcm2386 disagree about what the
1
Make the M-profile "init-svtor" property be settable after realize.
2
parent class is -- the TypeInfo says it's TYPE_SYS_BUS_DEVICE,
2
This matches the hardware, where this is a config signal which
3
but the BCM2386State struct only defines the parent_obj field
3
is sampled on CPU reset and can thus be changed between one
4
as DeviceState. This would have caused problems if anything
4
reset and another. To do this we have to change the API we
5
actually tried to treat the object as a TYPE_SYS_BUS_DEVICE.
5
use to add the property.
6
Fix the TypeInfo to use TYPE_DEVICE as the parent, since we don't
6
7
need any of the additional functionality TYPE_SYS_BUS_DEVICE
7
(We will need this capability for the SSE-200.)
8
provides.
9
8
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20190219125808.25174-4-peter.maydell@linaro.org
13
Message-id: 20180313153458.26822-5-peter.maydell@linaro.org
14
---
12
---
15
hw/arm/bcm2836.c | 2 +-
13
target/arm/cpu.c | 29 ++++++++++++++++++++++++-----
16
1 file changed, 1 insertion(+), 1 deletion(-)
14
1 file changed, 24 insertions(+), 5 deletions(-)
17
15
18
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
16
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
19
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/bcm2836.c
18
--- a/target/arm/cpu.c
21
+++ b/hw/arm/bcm2836.c
19
+++ b/target/arm/cpu.c
22
@@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data)
20
@@ -XXX,XX +XXX,XX @@
23
21
#include "target/arm/idau.h"
24
static const TypeInfo bcm2836_type_info = {
22
#include "qemu/error-report.h"
25
.name = TYPE_BCM2836,
23
#include "qapi/error.h"
26
- .parent = TYPE_SYS_BUS_DEVICE,
24
+#include "qapi/visitor.h"
27
+ .parent = TYPE_DEVICE,
25
#include "cpu.h"
28
.instance_size = sizeof(BCM2836State),
26
#include "internals.h"
29
.instance_init = bcm2836_init,
27
#include "qemu-common.h"
30
.class_init = bcm2836_class_init,
28
@@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pmsav7_dregion_property =
29
pmsav7_dregion,
30
qdev_prop_uint32, uint32_t);
31
32
-/* M profile: initial value of the Secure VTOR */
33
-static Property arm_cpu_initsvtor_property =
34
- DEFINE_PROP_UINT32("init-svtor", ARMCPU, init_svtor, 0);
35
+static void arm_get_init_svtor(Object *obj, Visitor *v, const char *name,
36
+ void *opaque, Error **errp)
37
+{
38
+ ARMCPU *cpu = ARM_CPU(obj);
39
+
40
+ visit_type_uint32(v, name, &cpu->init_svtor, errp);
41
+}
42
+
43
+static void arm_set_init_svtor(Object *obj, Visitor *v, const char *name,
44
+ void *opaque, Error **errp)
45
+{
46
+ ARMCPU *cpu = ARM_CPU(obj);
47
+
48
+ visit_type_uint32(v, name, &cpu->init_svtor, errp);
49
+}
50
51
void arm_cpu_post_init(Object *obj)
52
{
53
@@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj)
54
qdev_prop_allow_set_link_before_realize,
55
OBJ_PROP_LINK_STRONG,
56
&error_abort);
57
- qdev_property_add_static(DEVICE(obj), &arm_cpu_initsvtor_property,
58
- &error_abort);
59
+ /*
60
+ * M profile: initial value of the Secure VTOR. We can't just use
61
+ * a simple DEFINE_PROP_UINT32 for this because we want to permit
62
+ * the property to be set after realize.
63
+ */
64
+ object_property_add(obj, "init-svtor", "uint32",
65
+ arm_get_init_svtor, arm_set_init_svtor,
66
+ NULL, NULL, &error_abort);
67
}
68
69
qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property,
31
--
70
--
32
2.16.2
71
2.20.1
33
72
34
73
diff view generated by jsdifflib
1
If we're directly booting a Linux kernel and the CPU supports both
1
Currently the Arm arm-powerctl.h APIs allow:
2
EL3 and EL2, we start the kernel in EL2, as it expects. We must also
2
* arm_set_cpu_on(), which powers on a CPU and sets its
3
set the SCR_EL3.HCE bit in this situation, so that the HVC
3
initial PC and other startup state
4
instruction is enabled rather than UNDEFing. Otherwise at least some
4
* arm_reset_cpu(), which resets a CPU which is already on
5
kernels will panic when trying to initialize KVM in the guest.
5
(and fails if the CPU is powered off)
6
7
but there is no way to say "power on a CPU as if it had
8
just come out of reset and don't do anything else to it".
9
10
Add a new function arm_set_cpu_on_and_reset(), which does this.
6
11
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20180313153458.26822-4-peter.maydell@linaro.org
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20190219125808.25174-5-peter.maydell@linaro.org
9
---
15
---
10
hw/arm/boot.c | 5 +++++
16
target/arm/arm-powerctl.h | 16 +++++++++++
11
1 file changed, 5 insertions(+)
17
target/arm/arm-powerctl.c | 56 +++++++++++++++++++++++++++++++++++++++
18
2 files changed, 72 insertions(+)
12
19
13
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
20
diff --git a/target/arm/arm-powerctl.h b/target/arm/arm-powerctl.h
14
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/boot.c
22
--- a/target/arm/arm-powerctl.h
16
+++ b/hw/arm/boot.c
23
+++ b/target/arm/arm-powerctl.h
17
@@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque)
24
@@ -XXX,XX +XXX,XX @@ int arm_set_cpu_off(uint64_t cpuid);
18
assert(!info->secure_board_setup);
25
*/
19
}
26
int arm_reset_cpu(uint64_t cpuid);
20
27
21
+ if (arm_feature(env, ARM_FEATURE_EL2)) {
28
+/*
22
+ /* If we have EL2 then Linux expects the HVC insn to work */
29
+ * arm_set_cpu_on_and_reset:
23
+ env->cp15.scr_el3 |= SCR_HCE;
30
+ * @cpuid: the id of the CPU we want to star
24
+ }
31
+ *
32
+ * Start the cpu designated by @cpuid and put it through its normal
33
+ * CPU reset process. The CPU will start in the way it is architected
34
+ * to start after a power-on reset.
35
+ *
36
+ * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
37
+ * QEMU_ARM_POWERCTL_INVALID_PARAM if there is no CPU with that ID.
38
+ * QEMU_ARM_POWERCTL_ALREADY_ON if the CPU is already on.
39
+ * QEMU_ARM_POWERCTL_ON_PENDING if the CPU is already partway through
40
+ * powering on.
41
+ */
42
+int arm_set_cpu_on_and_reset(uint64_t cpuid);
25
+
43
+
26
/* Set to non-secure if not a secure boot */
44
#endif
27
if (!info->secure_boot &&
45
diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c
28
(cs != first_cpu || !info->secure_board_setup)) {
46
index XXXXXXX..XXXXXXX 100644
47
--- a/target/arm/arm-powerctl.c
48
+++ b/target/arm/arm-powerctl.c
49
@@ -XXX,XX +XXX,XX @@ int arm_set_cpu_on(uint64_t cpuid, uint64_t entry, uint64_t context_id,
50
return QEMU_ARM_POWERCTL_RET_SUCCESS;
51
}
52
53
+static void arm_set_cpu_on_and_reset_async_work(CPUState *target_cpu_state,
54
+ run_on_cpu_data data)
55
+{
56
+ ARMCPU *target_cpu = ARM_CPU(target_cpu_state);
57
+
58
+ /* Initialize the cpu we are turning on */
59
+ cpu_reset(target_cpu_state);
60
+ target_cpu_state->halted = 0;
61
+
62
+ /* Finally set the power status */
63
+ assert(qemu_mutex_iothread_locked());
64
+ target_cpu->power_state = PSCI_ON;
65
+}
66
+
67
+int arm_set_cpu_on_and_reset(uint64_t cpuid)
68
+{
69
+ CPUState *target_cpu_state;
70
+ ARMCPU *target_cpu;
71
+
72
+ assert(qemu_mutex_iothread_locked());
73
+
74
+ /* Retrieve the cpu we are powering up */
75
+ target_cpu_state = arm_get_cpu_by_id(cpuid);
76
+ if (!target_cpu_state) {
77
+ /* The cpu was not found */
78
+ return QEMU_ARM_POWERCTL_INVALID_PARAM;
79
+ }
80
+
81
+ target_cpu = ARM_CPU(target_cpu_state);
82
+ if (target_cpu->power_state == PSCI_ON) {
83
+ qemu_log_mask(LOG_GUEST_ERROR,
84
+ "[ARM]%s: CPU %" PRId64 " is already on\n",
85
+ __func__, cpuid);
86
+ return QEMU_ARM_POWERCTL_ALREADY_ON;
87
+ }
88
+
89
+ /*
90
+ * If another CPU has powered the target on we are in the state
91
+ * ON_PENDING and additional attempts to power on the CPU should
92
+ * fail (see 6.6 Implementation CPU_ON/CPU_OFF races in the PSCI
93
+ * spec)
94
+ */
95
+ if (target_cpu->power_state == PSCI_ON_PENDING) {
96
+ qemu_log_mask(LOG_GUEST_ERROR,
97
+ "[ARM]%s: CPU %" PRId64 " is already powering on\n",
98
+ __func__, cpuid);
99
+ return QEMU_ARM_POWERCTL_ON_PENDING;
100
+ }
101
+
102
+ async_run_on_cpu(target_cpu_state, arm_set_cpu_on_and_reset_async_work,
103
+ RUN_ON_CPU_NULL);
104
+
105
+ /* We are good to go */
106
+ return QEMU_ARM_POWERCTL_RET_SUCCESS;
107
+}
108
+
109
static void arm_set_cpu_off_async_work(CPUState *target_cpu_state,
110
run_on_cpu_data data)
111
{
29
--
112
--
30
2.16.2
113
2.20.1
31
114
32
115
diff view generated by jsdifflib
1
Add some assertions that if we're about to boot an AArch64 kernel,
1
The iotkit-sysctl device has a register it names INITSVRTOR0.
2
the board code has not mistakenly set either secure_boot or
2
This is actually a typo present in the IoTKit documentation
3
secure_board_setup. It doesn't make sense to set secure_boot,
3
and also in part of the SSE-200 documentation: it should be
4
because all AArch64 kernels must be booted in non-secure mode.
4
INITSVTOR0 because it is specifying the initial value of the
5
5
Secure VTOR register in the CPU. Correct the typo.
6
It might in theory make sense to set secure_board_setup, but
7
we don't currently support that, because only the AArch32
8
bootloader[] code calls this hook; bootloader_aarch64[] does not.
9
Since we don't have a current need for this functionality, just
10
assert that we don't try to use it. If it's needed we'll add
11
it later.
12
6
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20180313153458.26822-3-peter.maydell@linaro.org
9
Message-id: 20190219125808.25174-6-peter.maydell@linaro.org
16
---
10
---
17
hw/arm/boot.c | 7 +++++++
11
include/hw/misc/iotkit-sysctl.h | 2 +-
18
1 file changed, 7 insertions(+)
12
hw/misc/iotkit-sysctl.c | 16 ++++++++--------
13
2 files changed, 9 insertions(+), 9 deletions(-)
19
14
20
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
15
diff --git a/include/hw/misc/iotkit-sysctl.h b/include/hw/misc/iotkit-sysctl.h
21
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/boot.c
17
--- a/include/hw/misc/iotkit-sysctl.h
23
+++ b/hw/arm/boot.c
18
+++ b/include/hw/misc/iotkit-sysctl.h
24
@@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque)
19
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKitSysCtl {
25
} else {
20
uint32_t reset_syndrome;
26
env->pstate = PSTATE_MODE_EL1h;
21
uint32_t reset_mask;
27
}
22
uint32_t gretreg;
28
+ /* AArch64 kernels never boot in secure mode */
23
- uint32_t initsvrtor0;
29
+ assert(!info->secure_boot);
24
+ uint32_t initsvtor0;
30
+ /* This hook is only supported for AArch32 currently:
25
uint32_t cpuwait;
31
+ * bootloader_aarch64[] will not call the hook, and
26
uint32_t wicctrl;
32
+ * the code above has already dropped us into EL2 or EL1.
27
} IoTKitSysCtl;
33
+ */
28
diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c
34
+ assert(!info->secure_board_setup);
29
index XXXXXXX..XXXXXXX 100644
35
}
30
--- a/hw/misc/iotkit-sysctl.c
36
31
+++ b/hw/misc/iotkit-sysctl.c
37
/* Set to non-secure if not a secure boot */
32
@@ -XXX,XX +XXX,XX @@ REG32(RESET_MASK, 0x104)
33
REG32(SWRESET, 0x108)
34
FIELD(SWRESET, SWRESETREQ, 9, 1)
35
REG32(GRETREG, 0x10c)
36
-REG32(INITSVRTOR0, 0x110)
37
+REG32(INITSVTOR0, 0x110)
38
REG32(CPUWAIT, 0x118)
39
REG32(BUSWAIT, 0x11c)
40
REG32(WICCTRL, 0x120)
41
@@ -XXX,XX +XXX,XX @@ static uint64_t iotkit_sysctl_read(void *opaque, hwaddr offset,
42
case A_GRETREG:
43
r = s->gretreg;
44
break;
45
- case A_INITSVRTOR0:
46
- r = s->initsvrtor0;
47
+ case A_INITSVTOR0:
48
+ r = s->initsvtor0;
49
break;
50
case A_CPUWAIT:
51
r = s->cpuwait;
52
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_write(void *opaque, hwaddr offset,
53
*/
54
s->gretreg = value;
55
break;
56
- case A_INITSVRTOR0:
57
- qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl INITSVRTOR0 unimplemented\n");
58
- s->initsvrtor0 = value;
59
+ case A_INITSVTOR0:
60
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl INITSVTOR0 unimplemented\n");
61
+ s->initsvtor0 = value;
62
break;
63
case A_CPUWAIT:
64
qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl CPUWAIT unimplemented\n");
65
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_reset(DeviceState *dev)
66
s->reset_syndrome = 1;
67
s->reset_mask = 0;
68
s->gretreg = 0;
69
- s->initsvrtor0 = 0x10000000;
70
+ s->initsvtor0 = 0x10000000;
71
s->cpuwait = 0;
72
s->wicctrl = 0;
73
}
74
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription iotkit_sysctl_vmstate = {
75
VMSTATE_UINT32(reset_syndrome, IoTKitSysCtl),
76
VMSTATE_UINT32(reset_mask, IoTKitSysCtl),
77
VMSTATE_UINT32(gretreg, IoTKitSysCtl),
78
- VMSTATE_UINT32(initsvrtor0, IoTKitSysCtl),
79
+ VMSTATE_UINT32(initsvtor0, IoTKitSysCtl),
80
VMSTATE_UINT32(cpuwait, IoTKitSysCtl),
81
VMSTATE_UINT32(wicctrl, IoTKitSysCtl),
82
VMSTATE_END_OF_LIST()
38
--
83
--
39
2.16.2
84
2.20.1
40
85
41
86
diff view generated by jsdifflib
1
Now we have separate types for BCM2386 and BCM2387, we might as well
1
The SYSCTL block in the SSE-200 has some extra registers that
2
just hard-code the CPU type they use rather than having it passed
2
are not present in the IoTKit version. Add these registers
3
through as an object property. This then lets us put the initialization
3
(as reads-as-written stubs), enabled by a new QOM property.
4
of the CPU object in init rather than realize.
5
6
Note that this change means that it's no longer possible on
7
the command line to use -cpu to ask for a different kind of
8
CPU than the SoC supports. This was never a supported thing to
9
do anyway; we were just not sanity-checking the command line.
10
11
This does require us to only build the bcm2837 object on
12
TARGET_AARCH64 configs, since otherwise it won't instantiate
13
due to the missing cortex-a53 device and "make check" will fail.
14
4
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 20190219125808.25174-7-peter.maydell@linaro.org
18
Message-id: 20180313153458.26822-9-peter.maydell@linaro.org
19
---
8
---
20
hw/arm/bcm2836.c | 24 +++++++++++++++---------
9
include/hw/misc/iotkit-sysctl.h | 20 +++
21
hw/arm/raspi.c | 2 --
10
hw/arm/armsse.c | 2 +
22
2 files changed, 15 insertions(+), 11 deletions(-)
11
hw/misc/iotkit-sysctl.c | 245 +++++++++++++++++++++++++++++++-
12
3 files changed, 262 insertions(+), 5 deletions(-)
23
13
24
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
14
diff --git a/include/hw/misc/iotkit-sysctl.h b/include/hw/misc/iotkit-sysctl.h
25
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/arm/bcm2836.c
16
--- a/include/hw/misc/iotkit-sysctl.h
27
+++ b/hw/arm/bcm2836.c
17
+++ b/include/hw/misc/iotkit-sysctl.h
28
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@
29
19
* "system control register" blocks.
30
struct BCM283XInfo {
20
*
31
const char *name;
21
* QEMU interface:
32
+ const char *cpu_type;
22
+ * + QOM property "SYS_VERSION": value of the SYS_VERSION register of the
33
int clusterid;
23
+ * system information block of the SSE
24
+ * (used to identify whether to provide SSE-200-only registers)
25
* + sysbus MMIO region 0: the system information register bank
26
* + sysbus MMIO region 1: the system control register bank
27
*/
28
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKitSysCtl {
29
uint32_t initsvtor0;
30
uint32_t cpuwait;
31
uint32_t wicctrl;
32
+ uint32_t scsecctrl;
33
+ uint32_t fclk_div;
34
+ uint32_t sysclk_div;
35
+ uint32_t clock_force;
36
+ uint32_t initsvtor1;
37
+ uint32_t nmi_enable;
38
+ uint32_t ewctrl;
39
+ uint32_t pdcm_pd_sys_sense;
40
+ uint32_t pdcm_pd_sram0_sense;
41
+ uint32_t pdcm_pd_sram1_sense;
42
+ uint32_t pdcm_pd_sram2_sense;
43
+ uint32_t pdcm_pd_sram3_sense;
44
+
45
+ /* Properties */
46
+ uint32_t sys_version;
47
+
48
+ bool is_sse200;
49
} IoTKitSysCtl;
50
51
#endif
52
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/hw/arm/armsse.c
55
+++ b/hw/arm/armsse.c
56
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
57
/* System information registers */
58
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sysinfo), 0, 0x40020000);
59
/* System control registers */
60
+ object_property_set_int(OBJECT(&s->sysctl), info->sys_version,
61
+ "SYS_VERSION", &err);
62
object_property_set_bool(OBJECT(&s->sysctl), true, "realized", &err);
63
if (err) {
64
error_propagate(errp, err);
65
diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c
66
index XXXXXXX..XXXXXXX 100644
67
--- a/hw/misc/iotkit-sysctl.c
68
+++ b/hw/misc/iotkit-sysctl.c
69
@@ -XXX,XX +XXX,XX @@
70
*/
71
72
#include "qemu/osdep.h"
73
+#include "qemu/bitops.h"
74
#include "qemu/log.h"
75
#include "trace.h"
76
#include "qapi/error.h"
77
@@ -XXX,XX +XXX,XX @@
78
REG32(SECDBGSTAT, 0x0)
79
REG32(SECDBGSET, 0x4)
80
REG32(SECDBGCLR, 0x8)
81
+REG32(SCSECCTRL, 0xc)
82
+REG32(FCLK_DIV, 0x10)
83
+REG32(SYSCLK_DIV, 0x14)
84
+REG32(CLOCK_FORCE, 0x18)
85
REG32(RESET_SYNDROME, 0x100)
86
REG32(RESET_MASK, 0x104)
87
REG32(SWRESET, 0x108)
88
FIELD(SWRESET, SWRESETREQ, 9, 1)
89
REG32(GRETREG, 0x10c)
90
REG32(INITSVTOR0, 0x110)
91
+REG32(INITSVTOR1, 0x114)
92
REG32(CPUWAIT, 0x118)
93
-REG32(BUSWAIT, 0x11c)
94
+REG32(NMI_ENABLE, 0x11c) /* BUSWAIT in IoTKit */
95
REG32(WICCTRL, 0x120)
96
+REG32(EWCTRL, 0x124)
97
+REG32(PDCM_PD_SYS_SENSE, 0x200)
98
+REG32(PDCM_PD_SRAM0_SENSE, 0x20c)
99
+REG32(PDCM_PD_SRAM1_SENSE, 0x210)
100
+REG32(PDCM_PD_SRAM2_SENSE, 0x214)
101
+REG32(PDCM_PD_SRAM3_SENSE, 0x218)
102
REG32(PID4, 0xfd0)
103
REG32(PID5, 0xfd4)
104
REG32(PID6, 0xfd8)
105
@@ -XXX,XX +XXX,XX @@ static uint64_t iotkit_sysctl_read(void *opaque, hwaddr offset,
106
case A_SECDBGSTAT:
107
r = s->secure_debug;
108
break;
109
+ case A_SCSECCTRL:
110
+ if (!s->is_sse200) {
111
+ goto bad_offset;
112
+ }
113
+ r = s->scsecctrl;
114
+ break;
115
+ case A_FCLK_DIV:
116
+ if (!s->is_sse200) {
117
+ goto bad_offset;
118
+ }
119
+ r = s->fclk_div;
120
+ break;
121
+ case A_SYSCLK_DIV:
122
+ if (!s->is_sse200) {
123
+ goto bad_offset;
124
+ }
125
+ r = s->sysclk_div;
126
+ break;
127
+ case A_CLOCK_FORCE:
128
+ if (!s->is_sse200) {
129
+ goto bad_offset;
130
+ }
131
+ r = s->clock_force;
132
+ break;
133
case A_RESET_SYNDROME:
134
r = s->reset_syndrome;
135
break;
136
@@ -XXX,XX +XXX,XX @@ static uint64_t iotkit_sysctl_read(void *opaque, hwaddr offset,
137
case A_INITSVTOR0:
138
r = s->initsvtor0;
139
break;
140
+ case A_INITSVTOR1:
141
+ if (!s->is_sse200) {
142
+ goto bad_offset;
143
+ }
144
+ r = s->initsvtor1;
145
+ break;
146
case A_CPUWAIT:
147
r = s->cpuwait;
148
break;
149
- case A_BUSWAIT:
150
- /* In IoTKit BUSWAIT is reserved, R/O, zero */
151
- r = 0;
152
+ case A_NMI_ENABLE:
153
+ /* In IoTKit this is named BUSWAIT but is marked reserved, R/O, zero */
154
+ if (!s->is_sse200) {
155
+ r = 0;
156
+ break;
157
+ }
158
+ r = s->nmi_enable;
159
break;
160
case A_WICCTRL:
161
r = s->wicctrl;
162
break;
163
+ case A_EWCTRL:
164
+ if (!s->is_sse200) {
165
+ goto bad_offset;
166
+ }
167
+ r = s->ewctrl;
168
+ break;
169
+ case A_PDCM_PD_SYS_SENSE:
170
+ if (!s->is_sse200) {
171
+ goto bad_offset;
172
+ }
173
+ r = s->pdcm_pd_sys_sense;
174
+ break;
175
+ case A_PDCM_PD_SRAM0_SENSE:
176
+ if (!s->is_sse200) {
177
+ goto bad_offset;
178
+ }
179
+ r = s->pdcm_pd_sram0_sense;
180
+ break;
181
+ case A_PDCM_PD_SRAM1_SENSE:
182
+ if (!s->is_sse200) {
183
+ goto bad_offset;
184
+ }
185
+ r = s->pdcm_pd_sram1_sense;
186
+ break;
187
+ case A_PDCM_PD_SRAM2_SENSE:
188
+ if (!s->is_sse200) {
189
+ goto bad_offset;
190
+ }
191
+ r = s->pdcm_pd_sram2_sense;
192
+ break;
193
+ case A_PDCM_PD_SRAM3_SENSE:
194
+ if (!s->is_sse200) {
195
+ goto bad_offset;
196
+ }
197
+ r = s->pdcm_pd_sram3_sense;
198
+ break;
199
case A_PID4 ... A_CID3:
200
r = sysctl_id[(offset - A_PID4) / 4];
201
break;
202
@@ -XXX,XX +XXX,XX @@ static uint64_t iotkit_sysctl_read(void *opaque, hwaddr offset,
203
r = 0;
204
break;
205
default:
206
+ bad_offset:
207
qemu_log_mask(LOG_GUEST_ERROR,
208
"IoTKit SysCtl read: bad offset %x\n", (int)offset);
209
r = 0;
210
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_write(void *opaque, hwaddr offset,
211
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
212
}
213
break;
214
- case A_BUSWAIT: /* In IoTKit BUSWAIT is reserved, R/O, zero */
215
+ case A_SCSECCTRL:
216
+ if (!s->is_sse200) {
217
+ goto bad_offset;
218
+ }
219
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl SCSECCTRL unimplemented\n");
220
+ s->scsecctrl = value;
221
+ break;
222
+ case A_FCLK_DIV:
223
+ if (!s->is_sse200) {
224
+ goto bad_offset;
225
+ }
226
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl FCLK_DIV unimplemented\n");
227
+ s->fclk_div = value;
228
+ break;
229
+ case A_SYSCLK_DIV:
230
+ if (!s->is_sse200) {
231
+ goto bad_offset;
232
+ }
233
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl SYSCLK_DIV unimplemented\n");
234
+ s->sysclk_div = value;
235
+ break;
236
+ case A_CLOCK_FORCE:
237
+ if (!s->is_sse200) {
238
+ goto bad_offset;
239
+ }
240
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl CLOCK_FORCE unimplemented\n");
241
+ s->clock_force = value;
242
+ break;
243
+ case A_INITSVTOR1:
244
+ if (!s->is_sse200) {
245
+ goto bad_offset;
246
+ }
247
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl INITSVTOR1 unimplemented\n");
248
+ s->initsvtor1 = value;
249
+ break;
250
+ case A_EWCTRL:
251
+ if (!s->is_sse200) {
252
+ goto bad_offset;
253
+ }
254
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl EWCTRL unimplemented\n");
255
+ s->ewctrl = value;
256
+ break;
257
+ case A_PDCM_PD_SYS_SENSE:
258
+ if (!s->is_sse200) {
259
+ goto bad_offset;
260
+ }
261
+ qemu_log_mask(LOG_UNIMP,
262
+ "IoTKit SysCtl PDCM_PD_SYS_SENSE unimplemented\n");
263
+ s->pdcm_pd_sys_sense = value;
264
+ break;
265
+ case A_PDCM_PD_SRAM0_SENSE:
266
+ if (!s->is_sse200) {
267
+ goto bad_offset;
268
+ }
269
+ qemu_log_mask(LOG_UNIMP,
270
+ "IoTKit SysCtl PDCM_PD_SRAM0_SENSE unimplemented\n");
271
+ s->pdcm_pd_sram0_sense = value;
272
+ break;
273
+ case A_PDCM_PD_SRAM1_SENSE:
274
+ if (!s->is_sse200) {
275
+ goto bad_offset;
276
+ }
277
+ qemu_log_mask(LOG_UNIMP,
278
+ "IoTKit SysCtl PDCM_PD_SRAM1_SENSE unimplemented\n");
279
+ s->pdcm_pd_sram1_sense = value;
280
+ break;
281
+ case A_PDCM_PD_SRAM2_SENSE:
282
+ if (!s->is_sse200) {
283
+ goto bad_offset;
284
+ }
285
+ qemu_log_mask(LOG_UNIMP,
286
+ "IoTKit SysCtl PDCM_PD_SRAM2_SENSE unimplemented\n");
287
+ s->pdcm_pd_sram2_sense = value;
288
+ break;
289
+ case A_PDCM_PD_SRAM3_SENSE:
290
+ if (!s->is_sse200) {
291
+ goto bad_offset;
292
+ }
293
+ qemu_log_mask(LOG_UNIMP,
294
+ "IoTKit SysCtl PDCM_PD_SRAM3_SENSE unimplemented\n");
295
+ s->pdcm_pd_sram3_sense = value;
296
+ break;
297
+ case A_NMI_ENABLE:
298
+ /* In IoTKit this is BUSWAIT: reserved, R/O, zero */
299
+ if (!s->is_sse200) {
300
+ goto ro_offset;
301
+ }
302
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl NMI_ENABLE unimplemented\n");
303
+ s->nmi_enable = value;
304
+ break;
305
case A_SECDBGSTAT:
306
case A_PID4 ... A_CID3:
307
+ ro_offset:
308
qemu_log_mask(LOG_GUEST_ERROR,
309
"IoTKit SysCtl write: write of RO offset %x\n",
310
(int)offset);
311
break;
312
default:
313
+ bad_offset:
314
qemu_log_mask(LOG_GUEST_ERROR,
315
"IoTKit SysCtl write: bad offset %x\n", (int)offset);
316
break;
317
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_reset(DeviceState *dev)
318
s->reset_mask = 0;
319
s->gretreg = 0;
320
s->initsvtor0 = 0x10000000;
321
+ s->initsvtor1 = 0x10000000;
322
s->cpuwait = 0;
323
s->wicctrl = 0;
324
+ s->scsecctrl = 0;
325
+ s->fclk_div = 0;
326
+ s->sysclk_div = 0;
327
+ s->clock_force = 0;
328
+ s->nmi_enable = 0;
329
+ s->ewctrl = 0;
330
+ s->pdcm_pd_sys_sense = 0x7f;
331
+ s->pdcm_pd_sram0_sense = 0;
332
+ s->pdcm_pd_sram1_sense = 0;
333
+ s->pdcm_pd_sram2_sense = 0;
334
+ s->pdcm_pd_sram3_sense = 0;
335
}
336
337
static void iotkit_sysctl_init(Object *obj)
338
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_init(Object *obj)
339
sysbus_init_mmio(sbd, &s->iomem);
340
}
341
342
+static void iotkit_sysctl_realize(DeviceState *dev, Error **errp)
343
+{
344
+ IoTKitSysCtl *s = IOTKIT_SYSCTL(dev);
345
+
346
+ /* The top 4 bits of the SYS_VERSION register tell us if we're an SSE-200 */
347
+ if (extract32(s->sys_version, 28, 4) == 2) {
348
+ s->is_sse200 = true;
349
+ }
350
+}
351
+
352
+static bool sse200_needed(void *opaque)
353
+{
354
+ IoTKitSysCtl *s = IOTKIT_SYSCTL(opaque);
355
+
356
+ return s->is_sse200;
357
+}
358
+
359
+static const VMStateDescription iotkit_sysctl_sse200_vmstate = {
360
+ .name = "iotkit-sysctl/sse-200",
361
+ .version_id = 1,
362
+ .minimum_version_id = 1,
363
+ .needed = sse200_needed,
364
+ .fields = (VMStateField[]) {
365
+ VMSTATE_UINT32(scsecctrl, IoTKitSysCtl),
366
+ VMSTATE_UINT32(fclk_div, IoTKitSysCtl),
367
+ VMSTATE_UINT32(sysclk_div, IoTKitSysCtl),
368
+ VMSTATE_UINT32(clock_force, IoTKitSysCtl),
369
+ VMSTATE_UINT32(initsvtor1, IoTKitSysCtl),
370
+ VMSTATE_UINT32(nmi_enable, IoTKitSysCtl),
371
+ VMSTATE_UINT32(pdcm_pd_sys_sense, IoTKitSysCtl),
372
+ VMSTATE_UINT32(pdcm_pd_sram0_sense, IoTKitSysCtl),
373
+ VMSTATE_UINT32(pdcm_pd_sram1_sense, IoTKitSysCtl),
374
+ VMSTATE_UINT32(pdcm_pd_sram2_sense, IoTKitSysCtl),
375
+ VMSTATE_UINT32(pdcm_pd_sram3_sense, IoTKitSysCtl),
376
+ VMSTATE_END_OF_LIST()
377
+ }
378
+};
379
+
380
static const VMStateDescription iotkit_sysctl_vmstate = {
381
.name = "iotkit-sysctl",
382
.version_id = 1,
383
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription iotkit_sysctl_vmstate = {
384
VMSTATE_UINT32(cpuwait, IoTKitSysCtl),
385
VMSTATE_UINT32(wicctrl, IoTKitSysCtl),
386
VMSTATE_END_OF_LIST()
387
+ },
388
+ .subsections = (const VMStateDescription*[]) {
389
+ &iotkit_sysctl_sse200_vmstate,
390
+ NULL
391
}
34
};
392
};
35
393
36
static const BCM283XInfo bcm283x_socs[] = {
394
+static Property iotkit_sysctl_props[] = {
37
{
395
+ DEFINE_PROP_UINT32("SYS_VERSION", IoTKitSysCtl, sys_version, 0),
38
.name = TYPE_BCM2836,
396
+ DEFINE_PROP_END_OF_LIST()
39
+ .cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"),
397
+};
40
.clusterid = 0xf,
398
+
41
},
399
static void iotkit_sysctl_class_init(ObjectClass *klass, void *data)
42
+#ifdef TARGET_AARCH64
43
{
44
.name = TYPE_BCM2837,
45
+ .cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"),
46
.clusterid = 0x0,
47
},
48
+#endif
49
};
50
51
static void bcm2836_init(Object *obj)
52
{
400
{
53
BCM283XState *s = BCM283X(obj);
401
DeviceClass *dc = DEVICE_CLASS(klass);
54
+ BCM283XClass *bc = BCM283X_GET_CLASS(obj);
402
55
+ const BCM283XInfo *info = bc->info;
403
dc->vmsd = &iotkit_sysctl_vmstate;
56
+ int n;
404
dc->reset = iotkit_sysctl_reset;
57
+
405
+ dc->props = iotkit_sysctl_props;
58
+ for (n = 0; n < BCM283X_NCPUS; n++) {
406
+ dc->realize = iotkit_sysctl_realize;
59
+ object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
60
+ info->cpu_type);
61
+ object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
62
+ &error_abort);
63
+ }
64
65
object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL);
66
object_property_add_child(obj, "control", OBJECT(&s->control), NULL);
67
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
68
69
/* common peripherals from bcm2835 */
70
71
- obj = OBJECT(dev);
72
- for (n = 0; n < BCM283X_NCPUS; n++) {
73
- object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
74
- s->cpu_type);
75
- object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
76
- &error_abort);
77
- }
78
-
79
obj = object_property_get_link(OBJECT(dev), "ram", &err);
80
if (obj == NULL) {
81
error_setg(errp, "%s: required ram link not found: %s",
82
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
83
}
407
}
84
408
85
static Property bcm2836_props[] = {
409
static const TypeInfo iotkit_sysctl_info = {
86
- DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type),
87
DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus,
88
BCM283X_NCPUS),
89
DEFINE_PROP_END_OF_LIST()
90
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
91
index XXXXXXX..XXXXXXX 100644
92
--- a/hw/arm/raspi.c
93
+++ b/hw/arm/raspi.c
94
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
95
/* Setup the SOC */
96
object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram),
97
&error_abort);
98
- object_property_set_str(OBJECT(&s->soc), machine->cpu_type, "cpu-type",
99
- &error_abort);
100
object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus",
101
&error_abort);
102
int board_rev = version == 3 ? 0xa02082 : 0xa21041;
103
--
410
--
104
2.16.2
411
2.20.1
105
412
106
413
diff view generated by jsdifflib
1
The BCM2837 sets the Aff1 field of the MPIDR affinity values for the
1
The CPUWAIT register acts as a sort of power-control: if a bit
2
CPUs to 0, whereas the BCM2836 uses 0xf. Set this correctly, as it
2
in it is 1 then the CPU will have been forced into waiting
3
is required for Linux to boot.
3
when the system was reset (which in QEMU we model as the
4
CPU starting powered off). Writing a 0 to the register will
5
allow the CPU to boot (for QEMU, we model this as powering
6
it on). Note that writing 0 to the register does not power
7
off a CPU.
8
9
For this to work correctly we need to also honour the
10
INITSVTOR* registers, which let the guest control where the
11
CPU will load its SP and PC from when it comes out of reset.
4
12
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20190219125808.25174-8-peter.maydell@linaro.org
8
Message-id: 20180313153458.26822-8-peter.maydell@linaro.org
9
---
16
---
10
hw/arm/bcm2836.c | 11 +++++++----
17
hw/misc/iotkit-sysctl.c | 41 +++++++++++++++++++++++++++++++++++++----
11
1 file changed, 7 insertions(+), 4 deletions(-)
18
1 file changed, 37 insertions(+), 4 deletions(-)
12
19
13
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
20
diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c
14
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/bcm2836.c
22
--- a/hw/misc/iotkit-sysctl.c
16
+++ b/hw/arm/bcm2836.c
23
+++ b/hw/misc/iotkit-sysctl.c
17
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@
18
25
#include "hw/sysbus.h"
19
struct BCM283XInfo {
26
#include "hw/registerfields.h"
20
const char *name;
27
#include "hw/misc/iotkit-sysctl.h"
21
+ int clusterid;
28
+#include "target/arm/arm-powerctl.h"
29
+#include "target/arm/cpu.h"
30
31
REG32(SECDBGSTAT, 0x0)
32
REG32(SECDBGSET, 0x4)
33
@@ -XXX,XX +XXX,XX @@ static const int sysctl_id[] = {
34
0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
22
};
35
};
23
36
24
static const BCM283XInfo bcm283x_socs[] = {
37
+/*
25
{
38
+ * Set the initial secure vector table offset address for the core.
26
.name = TYPE_BCM2836,
39
+ * This will take effect when the CPU next resets.
27
+ .clusterid = 0xf,
40
+ */
28
},
41
+static void set_init_vtor(uint64_t cpuid, uint32_t vtor)
29
{
42
+{
30
.name = TYPE_BCM2837,
43
+ Object *cpuobj = OBJECT(arm_get_cpu_by_id(cpuid));
31
+ .clusterid = 0x0,
44
+
32
},
45
+ if (cpuobj) {
33
};
46
+ if (object_property_find(cpuobj, "init-svtor", NULL)) {
34
47
+ object_property_set_uint(cpuobj, vtor, "init-svtor", &error_abort);
35
@@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj)
48
+ }
36
static void bcm2836_realize(DeviceState *dev, Error **errp)
49
+ }
50
+}
51
+
52
static uint64_t iotkit_sysctl_read(void *opaque, hwaddr offset,
53
unsigned size)
37
{
54
{
38
BCM283XState *s = BCM283X(dev);
55
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_write(void *opaque, hwaddr offset,
39
+ BCM283XClass *bc = BCM283X_GET_CLASS(dev);
56
s->gretreg = value;
40
+ const BCM283XInfo *info = bc->info;
57
break;
41
Object *obj;
58
case A_INITSVTOR0:
42
Error *err = NULL;
59
- qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl INITSVTOR0 unimplemented\n");
43
int n;
60
s->initsvtor0 = value;
44
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
61
+ set_init_vtor(0, s->initsvtor0);
45
qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0));
62
break;
46
63
case A_CPUWAIT:
47
for (n = 0; n < BCM283X_NCPUS; n++) {
64
- qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl CPUWAIT unimplemented\n");
48
- /* Mirror bcm2836, which has clusterid set to 0xf
65
+ if ((s->cpuwait & 1) && !(value & 1)) {
49
- * TODO: this should be converted to a property of ARM_CPU
66
+ /* Powering up CPU 0 */
50
- */
67
+ arm_set_cpu_on_and_reset(0);
51
- s->cpus[n].mp_affinity = 0xF00 | n;
68
+ }
52
+ /* TODO: this should be converted to a property of ARM_CPU */
69
+ if ((s->cpuwait & 2) && !(value & 2)) {
53
+ s->cpus[n].mp_affinity = (info->clusterid << 8) | n;
70
+ /* Powering up CPU 1 */
54
71
+ arm_set_cpu_on_and_reset(1);
55
/* set periphbase/CBAR value for CPU-local registers */
72
+ }
56
object_property_set_int(OBJECT(&s->cpus[n]),
73
s->cpuwait = value;
74
break;
75
case A_WICCTRL:
76
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_write(void *opaque, hwaddr offset,
77
if (!s->is_sse200) {
78
goto bad_offset;
79
}
80
- qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl INITSVTOR1 unimplemented\n");
81
s->initsvtor1 = value;
82
+ set_init_vtor(1, s->initsvtor1);
83
break;
84
case A_EWCTRL:
85
if (!s->is_sse200) {
86
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_reset(DeviceState *dev)
87
s->gretreg = 0;
88
s->initsvtor0 = 0x10000000;
89
s->initsvtor1 = 0x10000000;
90
- s->cpuwait = 0;
91
+ if (s->is_sse200) {
92
+ /*
93
+ * CPU 0 starts on, CPU 1 starts off. In real hardware this is
94
+ * configurable by the SoC integrator as a verilog parameter.
95
+ */
96
+ s->cpuwait = 2;
97
+ } else {
98
+ /* CPU 0 starts on */
99
+ s->cpuwait = 0;
100
+ }
101
s->wicctrl = 0;
102
s->scsecctrl = 0;
103
s->fclk_div = 0;
57
--
104
--
58
2.16.2
105
2.20.1
59
106
60
107
diff view generated by jsdifflib
1
Our BCM2836 type is really a generic one that can be any of
1
At the moment the handling of init-svtor and cpuwait initial
2
the bcm283x family. Rename it accordingly. We change only
2
values is split between armsse.c and iotkit-sysctl.c:
3
the names which are visible via the header file to the
3
the code in armsse.c sets the initial state of the CPU
4
rest of the QEMU code, leaving private function names
4
object by setting the init-svtor and start-powered-off
5
in bcm2836.c as they are.
5
properties, but the iotkit-sysctl.c code has its own
6
code setting the reset values of its registers (which are
7
then used when updating the CPU when the guest makes
8
runtime changes).
6
9
7
This is a preliminary to making bcm283x be an abstract
10
Clean this up by making the armsse.c code set properties on the
8
parent class to specific types for the bcm2836 and bcm2837.
11
iotkit-sysctl object to define the initial values of the
12
registers, so they always match the initial CPU state,
13
and update the comments in armsse.c accordingly.
9
14
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Message-id: 20190219125808.25174-9-peter.maydell@linaro.org
13
Message-id: 20180313153458.26822-6-peter.maydell@linaro.org
14
---
18
---
15
include/hw/arm/bcm2836.h | 12 ++++++------
19
include/hw/misc/iotkit-sysctl.h | 3 ++
16
hw/arm/bcm2836.c | 17 +++++++++--------
20
hw/arm/armsse.c | 49 +++++++++++++++++++++------------
17
hw/arm/raspi.c | 16 ++++++++--------
21
hw/misc/iotkit-sysctl.c | 20 ++++++--------
18
3 files changed, 23 insertions(+), 22 deletions(-)
22
3 files changed, 42 insertions(+), 30 deletions(-)
19
23
20
diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h
24
diff --git a/include/hw/misc/iotkit-sysctl.h b/include/hw/misc/iotkit-sysctl.h
21
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/arm/bcm2836.h
26
--- a/include/hw/misc/iotkit-sysctl.h
23
+++ b/include/hw/arm/bcm2836.h
27
+++ b/include/hw/misc/iotkit-sysctl.h
28
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKitSysCtl {
29
30
/* Properties */
31
uint32_t sys_version;
32
+ uint32_t cpuwait_rst;
33
+ uint32_t initsvtor0_rst;
34
+ uint32_t initsvtor1_rst;
35
36
bool is_sse200;
37
} IoTKitSysCtl;
38
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/hw/arm/armsse.c
41
+++ b/hw/arm/armsse.c
24
@@ -XXX,XX +XXX,XX @@
42
@@ -XXX,XX +XXX,XX @@
25
#include "hw/arm/bcm2835_peripherals.h"
43
26
#include "hw/intc/bcm2836_control.h"
44
#include "qemu/osdep.h"
27
45
#include "qemu/log.h"
28
-#define TYPE_BCM2836 "bcm2836"
46
+#include "qemu/bitops.h"
29
-#define BCM2836(obj) OBJECT_CHECK(BCM2836State, (obj), TYPE_BCM2836)
47
#include "qapi/error.h"
30
+#define TYPE_BCM283X "bcm283x"
48
#include "trace.h"
31
+#define BCM283X(obj) OBJECT_CHECK(BCM283XState, (obj), TYPE_BCM283X)
49
#include "hw/sysbus.h"
32
50
@@ -XXX,XX +XXX,XX @@ struct ARMSSEInfo {
33
-#define BCM2836_NCPUS 4
51
int sram_banks;
34
+#define BCM283X_NCPUS 4
52
int num_cpus;
35
53
uint32_t sys_version;
36
-typedef struct BCM2836State {
54
+ uint32_t cpuwait_rst;
37
+typedef struct BCM283XState {
55
SysConfigFormat sys_config_format;
38
/*< private >*/
56
bool has_mhus;
39
DeviceState parent_obj;
57
bool has_ppus;
40
/*< public >*/
58
@@ -XXX,XX +XXX,XX @@ static const ARMSSEInfo armsse_variants[] = {
41
@@ -XXX,XX +XXX,XX @@ typedef struct BCM2836State {
59
.sram_banks = 1,
42
char *cpu_type;
60
.num_cpus = 1,
43
uint32_t enabled_cpus;
61
.sys_version = 0x41743,
44
62
+ .cpuwait_rst = 0,
45
- ARMCPU cpus[BCM2836_NCPUS];
63
.sys_config_format = IoTKitFormat,
46
+ ARMCPU cpus[BCM283X_NCPUS];
64
.has_mhus = false,
47
BCM2836ControlState control;
65
.has_ppus = false,
48
BCM2835PeripheralState peripherals;
66
@@ -XXX,XX +XXX,XX @@ static const ARMSSEInfo armsse_variants[] = {
49
-} BCM2836State;
67
.sram_banks = 4,
50
+} BCM283XState;
68
.num_cpus = 2,
51
69
.sys_version = 0x22041743,
52
#endif /* BCM2836_H */
70
+ .cpuwait_rst = 2,
53
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
71
.sys_config_format = SSE200Format,
72
.has_mhus = true,
73
.has_ppus = true,
74
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
75
76
qdev_prop_set_uint32(cpudev, "num-irq", s->exp_numirq + 32);
77
/*
78
- * In real hardware the initial Secure VTOR is set from the INITSVTOR0
79
- * register in the IoT Kit System Control Register block, and the
80
- * initial value of that is in turn specifiable by the FPGA that
81
- * instantiates the IoT Kit. In QEMU we don't implement this wrinkle,
82
- * and simply set the CPU's init-svtor to the IoT Kit default value.
83
- * In SSE-200 the situation is similar, except that the default value
84
- * is a reset-time signal input. Typically a board using the SSE-200
85
- * will have a system control processor whose boot firmware initializes
86
- * the INITSVTOR* registers before powering up the CPUs in any case,
87
- * so the hardware's default value doesn't matter. QEMU doesn't emulate
88
+ * In real hardware the initial Secure VTOR is set from the INITSVTOR*
89
+ * registers in the IoT Kit System Control Register block. In QEMU
90
+ * we set the initial value here, and also the reset value of the
91
+ * sysctl register, from this object's QOM init-svtor property.
92
+ * If the guest changes the INITSVTOR* registers at runtime then the
93
+ * code in iotkit-sysctl.c will update the CPU init-svtor property
94
+ * (which will then take effect on the next CPU warm-reset).
95
+ *
96
+ * Note that typically a board using the SSE-200 will have a system
97
+ * control processor whose boot firmware initializes the INITSVTOR*
98
+ * registers before powering up the CPUs. QEMU doesn't emulate
99
* the control processor, so instead we behave in the way that the
100
- * firmware does. The initial value is configurable by the board code
101
- * to match whatever its firmware does.
102
+ * firmware does: the initial value should be set by the board code
103
+ * (using the init-svtor property on the ARMSSE object) to match
104
+ * whatever its firmware does.
105
*/
106
qdev_prop_set_uint32(cpudev, "init-svtor", s->init_svtor);
107
/*
108
- * Start all CPUs except CPU0 powered down. In real hardware it is
109
- * a configurable property of the SSE-200 which CPUs start powered up
110
- * (via the CPUWAIT0_RST and CPUWAIT1_RST parameters), but since all
111
- * the boards we care about start CPU0 and leave CPU1 powered off,
112
- * we hard-code that for now. We can add QOM properties for this
113
+ * CPUs start powered down if the corresponding bit in the CPUWAIT
114
+ * register is 1. In real hardware the CPUWAIT register reset value is
115
+ * a configurable property of the SSE-200 (via the CPUWAIT0_RST and
116
+ * CPUWAIT1_RST parameters), but since all the boards we care about
117
+ * start CPU0 and leave CPU1 powered off, we hard-code that in
118
+ * info->cpuwait_rst for now. We can add QOM properties for this
119
* later if necessary.
120
*/
121
- if (i > 0) {
122
+ if (extract32(info->cpuwait_rst, i, 1)) {
123
object_property_set_bool(cpuobj, true, "start-powered-off", &err);
124
if (err) {
125
error_propagate(errp, err);
126
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
127
/* System control registers */
128
object_property_set_int(OBJECT(&s->sysctl), info->sys_version,
129
"SYS_VERSION", &err);
130
+ object_property_set_int(OBJECT(&s->sysctl), info->cpuwait_rst,
131
+ "CPUWAIT_RST", &err);
132
+ object_property_set_int(OBJECT(&s->sysctl), s->init_svtor,
133
+ "INITSVTOR0_RST", &err);
134
+ object_property_set_int(OBJECT(&s->sysctl), s->init_svtor,
135
+ "INITSVTOR1_RST", &err);
136
object_property_set_bool(OBJECT(&s->sysctl), true, "realized", &err);
137
if (err) {
138
error_propagate(errp, err);
139
diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c
54
index XXXXXXX..XXXXXXX 100644
140
index XXXXXXX..XXXXXXX 100644
55
--- a/hw/arm/bcm2836.c
141
--- a/hw/misc/iotkit-sysctl.c
56
+++ b/hw/arm/bcm2836.c
142
+++ b/hw/misc/iotkit-sysctl.c
57
@@ -XXX,XX +XXX,XX @@
143
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_reset(DeviceState *dev)
58
144
s->reset_syndrome = 1;
59
static void bcm2836_init(Object *obj)
145
s->reset_mask = 0;
60
{
146
s->gretreg = 0;
61
- BCM2836State *s = BCM2836(obj);
147
- s->initsvtor0 = 0x10000000;
62
+ BCM283XState *s = BCM283X(obj);
148
- s->initsvtor1 = 0x10000000;
63
149
- if (s->is_sse200) {
64
object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL);
150
- /*
65
object_property_add_child(obj, "control", OBJECT(&s->control), NULL);
151
- * CPU 0 starts on, CPU 1 starts off. In real hardware this is
66
@@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj)
152
- * configurable by the SoC integrator as a verilog parameter.
67
153
- */
68
static void bcm2836_realize(DeviceState *dev, Error **errp)
154
- s->cpuwait = 2;
69
{
155
- } else {
70
- BCM2836State *s = BCM2836(dev);
156
- /* CPU 0 starts on */
71
+ BCM283XState *s = BCM283X(dev);
157
- s->cpuwait = 0;
72
Object *obj;
158
- }
73
Error *err = NULL;
159
+ s->initsvtor0 = s->initsvtor0_rst;
74
int n;
160
+ s->initsvtor1 = s->initsvtor1_rst;
75
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
161
+ s->cpuwait = s->cpuwait_rst;
76
/* common peripherals from bcm2835 */
162
s->wicctrl = 0;
77
163
s->scsecctrl = 0;
78
obj = OBJECT(dev);
164
s->fclk_div = 0;
79
- for (n = 0; n < BCM2836_NCPUS; n++) {
165
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription iotkit_sysctl_vmstate = {
80
+ for (n = 0; n < BCM283X_NCPUS; n++) {
166
81
object_initialize(&s->cpus[n], sizeof(s->cpus[n]),
167
static Property iotkit_sysctl_props[] = {
82
s->cpu_type);
168
DEFINE_PROP_UINT32("SYS_VERSION", IoTKitSysCtl, sys_version, 0),
83
object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]),
169
+ DEFINE_PROP_UINT32("CPUWAIT_RST", IoTKitSysCtl, cpuwait_rst, 0),
84
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
170
+ DEFINE_PROP_UINT32("INITSVTOR0_RST", IoTKitSysCtl, initsvtor0_rst,
85
sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1,
171
+ 0x10000000),
86
qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0));
172
+ DEFINE_PROP_UINT32("INITSVTOR1_RST", IoTKitSysCtl, initsvtor1_rst,
87
173
+ 0x10000000),
88
- for (n = 0; n < BCM2836_NCPUS; n++) {
89
+ for (n = 0; n < BCM283X_NCPUS; n++) {
90
/* Mirror bcm2836, which has clusterid set to 0xf
91
* TODO: this should be converted to a property of ARM_CPU
92
*/
93
@@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp)
94
}
95
96
static Property bcm2836_props[] = {
97
- DEFINE_PROP_STRING("cpu-type", BCM2836State, cpu_type),
98
- DEFINE_PROP_UINT32("enabled-cpus", BCM2836State, enabled_cpus, BCM2836_NCPUS),
99
+ DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type),
100
+ DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus,
101
+ BCM283X_NCPUS),
102
DEFINE_PROP_END_OF_LIST()
174
DEFINE_PROP_END_OF_LIST()
103
};
175
};
104
176
105
@@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data)
106
}
107
108
static const TypeInfo bcm2836_type_info = {
109
- .name = TYPE_BCM2836,
110
+ .name = TYPE_BCM283X,
111
.parent = TYPE_DEVICE,
112
- .instance_size = sizeof(BCM2836State),
113
+ .instance_size = sizeof(BCM283XState),
114
.instance_init = bcm2836_init,
115
.class_init = bcm2836_class_init,
116
};
117
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
118
index XXXXXXX..XXXXXXX 100644
119
--- a/hw/arm/raspi.c
120
+++ b/hw/arm/raspi.c
121
@@ -XXX,XX +XXX,XX @@
122
static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44};
123
124
typedef struct RasPiState {
125
- BCM2836State soc;
126
+ BCM283XState soc;
127
MemoryRegion ram;
128
} RasPiState;
129
130
@@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version)
131
BusState *bus;
132
DeviceState *carddev;
133
134
- object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM2836);
135
+ object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X);
136
object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
137
&error_abort);
138
139
@@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc)
140
mc->no_floppy = 1;
141
mc->no_cdrom = 1;
142
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
143
- mc->max_cpus = BCM2836_NCPUS;
144
- mc->min_cpus = BCM2836_NCPUS;
145
- mc->default_cpus = BCM2836_NCPUS;
146
+ mc->max_cpus = BCM283X_NCPUS;
147
+ mc->min_cpus = BCM283X_NCPUS;
148
+ mc->default_cpus = BCM283X_NCPUS;
149
mc->default_ram_size = 1024 * 1024 * 1024;
150
mc->ignore_memory_transaction_failures = true;
151
};
152
@@ -XXX,XX +XXX,XX @@ static void raspi3_machine_init(MachineClass *mc)
153
mc->no_floppy = 1;
154
mc->no_cdrom = 1;
155
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a53");
156
- mc->max_cpus = BCM2836_NCPUS;
157
- mc->min_cpus = BCM2836_NCPUS;
158
- mc->default_cpus = BCM2836_NCPUS;
159
+ mc->max_cpus = BCM283X_NCPUS;
160
+ mc->min_cpus = BCM283X_NCPUS;
161
+ mc->default_cpus = BCM283X_NCPUS;
162
mc->default_ram_size = 1024 * 1024 * 1024;
163
}
164
DEFINE_MACHINE("raspi3", raspi3_machine_init)
165
--
177
--
166
2.16.2
178
2.20.1
167
179
168
180
diff view generated by jsdifflib
1
For the rpi1 and 2 we want to boot the Linux kernel via some
1
Instead of gating the A32/T32 FP16 conversion instructions on
2
custom setup code that makes sure that the SMC instruction
2
the ARM_FEATURE_VFP_FP16 flag, switch to our new approach of
3
acts as a no-op, because it's used for cache maintenance.
3
looking at ID register bits. In this case MVFR1 fields FPHP
4
The rpi3 boots AArch64 kernels, which don't need SMC for
4
and SIMDHP indicate the presence of these insns.
5
cache maintenance and always expect to be booted non-secure.
5
6
Don't fill in the aarch32-specific parts of the binfo struct.
6
This change doesn't alter behaviour for any of our CPUs.
7
7
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Message-id: 20190222170936.13268-2-peter.maydell@linaro.org
11
Message-id: 20180313153458.26822-2-peter.maydell@linaro.org
12
---
11
---
13
hw/arm/raspi.c | 17 +++++++++++++----
12
target/arm/cpu.h | 37 ++++++++++++++++++++++++++++++++++++-
14
1 file changed, 13 insertions(+), 4 deletions(-)
13
target/arm/cpu.c | 2 --
14
target/arm/kvm32.c | 3 ---
15
target/arm/translate.c | 26 ++++++++++++++++++--------
16
4 files changed, 54 insertions(+), 14 deletions(-)
15
17
16
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
18
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/raspi.c
20
--- a/target/arm/cpu.h
19
+++ b/hw/arm/raspi.c
21
+++ b/target/arm/cpu.h
20
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
22
@@ -XXX,XX +XXX,XX @@ FIELD(ID_DFR0, MPROFDBG, 20, 4)
21
binfo.board_id = raspi_boardid[version];
23
FIELD(ID_DFR0, PERFMON, 24, 4)
22
binfo.ram_size = ram_size;
24
FIELD(ID_DFR0, TRACEFILT, 28, 4)
23
binfo.nb_cpus = smp_cpus;
25
24
- binfo.board_setup_addr = BOARDSETUP_ADDR;
26
+FIELD(MVFR0, SIMDREG, 0, 4)
25
- binfo.write_board_setup = write_board_setup;
27
+FIELD(MVFR0, FPSP, 4, 4)
26
- binfo.secure_board_setup = true;
28
+FIELD(MVFR0, FPDP, 8, 4)
27
- binfo.secure_boot = true;
29
+FIELD(MVFR0, FPTRAP, 12, 4)
30
+FIELD(MVFR0, FPDIVIDE, 16, 4)
31
+FIELD(MVFR0, FPSQRT, 20, 4)
32
+FIELD(MVFR0, FPSHVEC, 24, 4)
33
+FIELD(MVFR0, FPROUND, 28, 4)
28
+
34
+
29
+ if (version <= 2) {
35
+FIELD(MVFR1, FPFTZ, 0, 4)
30
+ /* The rpi1 and 2 require some custom setup code to run in Secure
36
+FIELD(MVFR1, FPDNAN, 4, 4)
31
+ * mode before booting a kernel (to set up the SMC vectors so
37
+FIELD(MVFR1, SIMDLS, 8, 4)
32
+ * that we get a no-op SMC; this is used by Linux to call the
38
+FIELD(MVFR1, SIMDINT, 12, 4)
33
+ * firmware for some cache maintenance operations.
39
+FIELD(MVFR1, SIMDSP, 16, 4)
34
+ * The rpi3 doesn't need this.
40
+FIELD(MVFR1, SIMDHP, 20, 4)
35
+ */
41
+FIELD(MVFR1, FPHP, 24, 4)
36
+ binfo.board_setup_addr = BOARDSETUP_ADDR;
42
+FIELD(MVFR1, SIMDFMAC, 28, 4)
37
+ binfo.write_board_setup = write_board_setup;
43
+
38
+ binfo.secure_board_setup = true;
44
+FIELD(MVFR2, SIMDMISC, 0, 4)
39
+ binfo.secure_boot = true;
45
+FIELD(MVFR2, FPMISC, 4, 4)
40
+ }
46
+
41
47
QEMU_BUILD_BUG_ON(ARRAY_SIZE(((ARMCPU *)0)->ccsidr) <= R_V7M_CSSELR_INDEX_MASK);
42
/* Pi2 and Pi3 requires SMP setup */
48
43
if (version >= 2) {
49
/* If adding a feature bit which corresponds to a Linux ELF
50
@@ -XXX,XX +XXX,XX @@ enum arm_features {
51
ARM_FEATURE_THUMB2,
52
ARM_FEATURE_PMSA, /* no MMU; may have Memory Protection Unit */
53
ARM_FEATURE_VFP3,
54
- ARM_FEATURE_VFP_FP16,
55
ARM_FEATURE_NEON,
56
ARM_FEATURE_M, /* Microcontroller profile. */
57
ARM_FEATURE_OMAPCP, /* OMAP specific CP15 ops handling. */
58
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id)
59
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1;
60
}
61
62
+/*
63
+ * We always set the FP and SIMD FP16 fields to indicate identical
64
+ * levels of support (assuming SIMD is implemented at all), so
65
+ * we only need one set of accessors.
66
+ */
67
+static inline bool isar_feature_aa32_fp16_spconv(const ARMISARegisters *id)
68
+{
69
+ return FIELD_EX64(id->mvfr1, MVFR1, FPHP) > 0;
70
+}
71
+
72
+static inline bool isar_feature_aa32_fp16_dpconv(const ARMISARegisters *id)
73
+{
74
+ return FIELD_EX64(id->mvfr1, MVFR1, FPHP) > 1;
75
+}
76
+
77
/*
78
* 64-bit feature tests via id registers.
79
*/
80
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
81
index XXXXXXX..XXXXXXX 100644
82
--- a/target/arm/cpu.c
83
+++ b/target/arm/cpu.c
84
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
85
}
86
if (arm_feature(env, ARM_FEATURE_VFP4)) {
87
set_feature(env, ARM_FEATURE_VFP3);
88
- set_feature(env, ARM_FEATURE_VFP_FP16);
89
}
90
if (arm_feature(env, ARM_FEATURE_VFP3)) {
91
set_feature(env, ARM_FEATURE_VFP);
92
@@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj)
93
cpu->dtb_compatible = "arm,cortex-a9";
94
set_feature(&cpu->env, ARM_FEATURE_V7);
95
set_feature(&cpu->env, ARM_FEATURE_VFP3);
96
- set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
97
set_feature(&cpu->env, ARM_FEATURE_NEON);
98
set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
99
set_feature(&cpu->env, ARM_FEATURE_EL3);
100
diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c
101
index XXXXXXX..XXXXXXX 100644
102
--- a/target/arm/kvm32.c
103
+++ b/target/arm/kvm32.c
104
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
105
if (extract32(id_pfr0, 12, 4) == 1) {
106
set_feature(&features, ARM_FEATURE_THUMB2EE);
107
}
108
- if (extract32(ahcf->isar.mvfr1, 20, 4) == 1) {
109
- set_feature(&features, ARM_FEATURE_VFP_FP16);
110
- }
111
if (extract32(ahcf->isar.mvfr1, 12, 4) == 1) {
112
set_feature(&features, ARM_FEATURE_NEON);
113
}
114
diff --git a/target/arm/translate.c b/target/arm/translate.c
115
index XXXXXXX..XXXXXXX 100644
116
--- a/target/arm/translate.c
117
+++ b/target/arm/translate.c
118
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
119
* UNPREDICTABLE if bit 8 is set prior to ARMv8
120
* (we choose to UNDEF)
121
*/
122
- if ((dp && !arm_dc_feature(s, ARM_FEATURE_V8)) ||
123
- !arm_dc_feature(s, ARM_FEATURE_VFP_FP16)) {
124
- return 1;
125
+ if (dp) {
126
+ if (!dc_isar_feature(aa32_fp16_dpconv, s)) {
127
+ return 1;
128
+ }
129
+ } else {
130
+ if (!dc_isar_feature(aa32_fp16_spconv, s)) {
131
+ return 1;
132
+ }
133
}
134
rm_is_dp = false;
135
break;
136
case 0x06: /* vcvtb.f16.f32, vcvtb.f16.f64 */
137
case 0x07: /* vcvtt.f16.f32, vcvtt.f16.f64 */
138
- if ((dp && !arm_dc_feature(s, ARM_FEATURE_V8)) ||
139
- !arm_dc_feature(s, ARM_FEATURE_VFP_FP16)) {
140
- return 1;
141
+ if (dp) {
142
+ if (!dc_isar_feature(aa32_fp16_dpconv, s)) {
143
+ return 1;
144
+ }
145
+ } else {
146
+ if (!dc_isar_feature(aa32_fp16_spconv, s)) {
147
+ return 1;
148
+ }
149
}
150
rd_is_dp = false;
151
break;
152
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
153
TCGv_ptr fpst;
154
TCGv_i32 ahp;
155
156
- if (!arm_dc_feature(s, ARM_FEATURE_VFP_FP16) ||
157
+ if (!dc_isar_feature(aa32_fp16_spconv, s) ||
158
q || (rm & 1)) {
159
return 1;
160
}
161
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
162
{
163
TCGv_ptr fpst;
164
TCGv_i32 ahp;
165
- if (!arm_dc_feature(s, ARM_FEATURE_VFP_FP16) ||
166
+ if (!dc_isar_feature(aa32_fp16_spconv, s) ||
167
q || (rd & 1)) {
168
return 1;
169
}
44
--
170
--
45
2.16.2
171
2.20.1
46
172
47
173
diff view generated by jsdifflib
1
The raspi3 has AArch64 CPUs, which means that our smpboot
1
There is a set of VFP instructions which we implement in
2
code for keeping the secondary CPUs in a pen needs to have
2
disas_vfp_v8_insn() and gate on the ARM_FEATURE_V8 bit.
3
a version for A64 as well as A32. Without this, the
3
These were all first introduced in v8 for A-profile, but in
4
secondary CPUs go into an infinite loop of taking undefined
4
M-profile they appeared in v7M. Gate them on the MVFR2
5
instruction exceptions.
5
FPMisc field instead, and rename the function appropriately.
6
6
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20180313153458.26822-10-peter.maydell@linaro.org
9
Message-id: 20190222170936.13268-3-peter.maydell@linaro.org
10
---
10
---
11
hw/arm/raspi.c | 41 ++++++++++++++++++++++++++++++++++++++++-
11
target/arm/cpu.h | 20 ++++++++++++++++++++
12
1 file changed, 40 insertions(+), 1 deletion(-)
12
target/arm/translate.c | 25 +++++++++++++------------
13
2 files changed, 33 insertions(+), 12 deletions(-)
13
14
14
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
15
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/raspi.c
17
--- a/target/arm/cpu.h
17
+++ b/hw/arm/raspi.c
18
+++ b/target/arm/cpu.h
18
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_fp16_dpconv(const ARMISARegisters *id)
19
#define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */
20
return FIELD_EX64(id->mvfr1, MVFR1, FPHP) > 1;
20
#define FIRMWARE_ADDR_2 0x8000 /* Pi 2 loads kernel.img here by default */
21
#define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */
22
+#define SPINTABLE_ADDR 0xd8 /* Pi 3 bootloader spintable */
23
24
/* Table of Linux board IDs for different Pi versions */
25
static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44};
26
@@ -XXX,XX +XXX,XX @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
27
info->smp_loader_start);
28
}
21
}
29
22
30
+static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info)
23
+static inline bool isar_feature_aa32_vsel(const ARMISARegisters *id)
31
+{
24
+{
32
+ /* Unlike the AArch32 version we don't need to call the board setup hook.
25
+ return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 1;
33
+ * The mechanism for doing the spin-table is also entirely different.
34
+ * We must have four 64-bit fields at absolute addresses
35
+ * 0xd8, 0xe0, 0xe8, 0xf0 in RAM, which are the flag variables for
36
+ * our CPUs, and which we must ensure are zero initialized before
37
+ * the primary CPU goes into the kernel. We put these variables inside
38
+ * a rom blob, so that the reset for ROM contents zeroes them for us.
39
+ */
40
+ static const uint32_t smpboot[] = {
41
+ 0xd2801b05, /* mov x5, 0xd8 */
42
+ 0xd53800a6, /* mrs x6, mpidr_el1 */
43
+ 0x924004c6, /* and x6, x6, #0x3 */
44
+ 0xd503205f, /* spin: wfe */
45
+ 0xf86678a4, /* ldr x4, [x5,x6,lsl #3] */
46
+ 0xb4ffffc4, /* cbz x4, spin */
47
+ 0xd2800000, /* mov x0, #0x0 */
48
+ 0xd2800001, /* mov x1, #0x0 */
49
+ 0xd2800002, /* mov x2, #0x0 */
50
+ 0xd2800003, /* mov x3, #0x0 */
51
+ 0xd61f0080, /* br x4 */
52
+ };
53
+
54
+ static const uint64_t spintables[] = {
55
+ 0, 0, 0, 0
56
+ };
57
+
58
+ rom_add_blob_fixed("raspi_smpboot", smpboot, sizeof(smpboot),
59
+ info->smp_loader_start);
60
+ rom_add_blob_fixed("raspi_spintables", spintables, sizeof(spintables),
61
+ SPINTABLE_ADDR);
62
+}
26
+}
63
+
27
+
64
static void write_board_setup(ARMCPU *cpu, const struct arm_boot_info *info)
28
+static inline bool isar_feature_aa32_vcvt_dr(const ARMISARegisters *id)
29
+{
30
+ return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 2;
31
+}
32
+
33
+static inline bool isar_feature_aa32_vrint(const ARMISARegisters *id)
34
+{
35
+ return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 3;
36
+}
37
+
38
+static inline bool isar_feature_aa32_vminmaxnm(const ARMISARegisters *id)
39
+{
40
+ return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 4;
41
+}
42
+
43
/*
44
* 64-bit feature tests via id registers.
45
*/
46
diff --git a/target/arm/translate.c b/target/arm/translate.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/arm/translate.c
49
+++ b/target/arm/translate.c
50
@@ -XXX,XX +XXX,XX @@ static const uint8_t fp_decode_rm[] = {
51
FPROUNDING_NEGINF,
52
};
53
54
-static int disas_vfp_v8_insn(DisasContext *s, uint32_t insn)
55
+static int disas_vfp_misc_insn(DisasContext *s, uint32_t insn)
65
{
56
{
66
arm_write_secure_board_setup_dummy_smc(cpu, info, MVBAR_ADDR);
57
uint32_t rd, rn, rm, dp = extract32(insn, 8, 1);
67
@@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
58
68
/* Pi2 and Pi3 requires SMP setup */
59
- if (!arm_dc_feature(s, ARM_FEATURE_V8)) {
69
if (version >= 2) {
60
- return 1;
70
binfo.smp_loader_start = SMPBOOT_ADDR;
61
- }
71
- binfo.write_secondary_boot = write_smpboot;
62
-
72
+ if (version == 2) {
63
if (dp) {
73
+ binfo.write_secondary_boot = write_smpboot;
64
VFP_DREG_D(rd, insn);
74
+ } else {
65
VFP_DREG_N(rn, insn);
75
+ binfo.write_secondary_boot = write_smpboot64;
66
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_v8_insn(DisasContext *s, uint32_t insn)
76
+ }
67
rm = VFP_SREG_M(insn);
77
binfo.secondary_cpu_reset_hook = reset_secondary;
78
}
68
}
79
69
70
- if ((insn & 0x0f800e50) == 0x0e000a00) {
71
+ if ((insn & 0x0f800e50) == 0x0e000a00 && dc_isar_feature(aa32_vsel, s)) {
72
return handle_vsel(insn, rd, rn, rm, dp);
73
- } else if ((insn & 0x0fb00e10) == 0x0e800a00) {
74
+ } else if ((insn & 0x0fb00e10) == 0x0e800a00 &&
75
+ dc_isar_feature(aa32_vminmaxnm, s)) {
76
return handle_vminmaxnm(insn, rd, rn, rm, dp);
77
- } else if ((insn & 0x0fbc0ed0) == 0x0eb80a40) {
78
+ } else if ((insn & 0x0fbc0ed0) == 0x0eb80a40 &&
79
+ dc_isar_feature(aa32_vrint, s)) {
80
/* VRINTA, VRINTN, VRINTP, VRINTM */
81
int rounding = fp_decode_rm[extract32(insn, 16, 2)];
82
return handle_vrint(insn, rd, rm, dp, rounding);
83
- } else if ((insn & 0x0fbc0e50) == 0x0ebc0a40) {
84
+ } else if ((insn & 0x0fbc0e50) == 0x0ebc0a40 &&
85
+ dc_isar_feature(aa32_vcvt_dr, s)) {
86
/* VCVTA, VCVTN, VCVTP, VCVTM */
87
int rounding = fp_decode_rm[extract32(insn, 16, 2)];
88
return handle_vcvt(insn, rd, rm, dp, rounding);
89
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
90
}
91
92
if (extract32(insn, 28, 4) == 0xf) {
93
- /* Encodings with T=1 (Thumb) or unconditional (ARM):
94
- * only used in v8 and above.
95
+ /*
96
+ * Encodings with T=1 (Thumb) or unconditional (ARM):
97
+ * only used for the "miscellaneous VFP features" added in v8A
98
+ * and v7M (and gated on the MVFR2.FPMisc field).
99
*/
100
- return disas_vfp_v8_insn(s, insn);
101
+ return disas_vfp_misc_insn(s, insn);
102
}
103
104
dp = ((insn & 0xf00) == 0xb00);
80
--
105
--
81
2.16.2
106
2.20.1
82
107
83
108
diff view generated by jsdifflib
New patch
1
This reverts commit 823e1b3818f9b10b824ddcd756983b6e2fa68730,
2
which introduces a regression running EDK2 guest firmware
3
under KVM:
1
4
5
error: kvm run failed Function not implemented
6
PC=000000013f5a6208 X00=00000000404003c4 X01=000000000000003a
7
X02=0000000000000000 X03=00000000404003c4 X04=0000000000000000
8
X05=0000000096000046 X06=000000013d2ef270 X07=000000013e3d1710
9
X08=09010755ffaf8ba8 X09=ffaf8b9cfeeb5468 X10=feeb546409010756
10
X11=09010757ffaf8b90 X12=feeb50680903068b X13=090306a1ffaf8bc0
11
X14=0000000000000000 X15=0000000000000000 X16=000000013f872da0
12
X17=00000000ffffa6ab X18=0000000000000000 X19=000000013f5a92d0
13
X20=000000013f5a7a78 X21=000000000000003a X22=000000013f5a7ab2
14
X23=000000013f5a92e8 X24=000000013f631090 X25=0000000000000010
15
X26=0000000000000100 X27=000000013f89501b X28=000000013e3d14e0
16
X29=000000013e3d12a0 X30=000000013f5a2518 SP=000000013b7be0b0
17
PSTATE=404003c4 -Z-- EL1t
18
19
with
20
[ 3507.926571] kvm [35042]: load/store instruction decoding not implemented
21
in the host dmesg.
22
23
Revert the change for the moment until we can investigate the
24
cause of the regression.
25
26
Reported-by: Eric Auger <eric.auger@redhat.com>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
29
target/arm/cpu.h | 9 +--------
30
target/arm/helper.c | 27 ++-------------------------
31
target/arm/kvm32.c | 20 ++++++++++++++++++--
32
target/arm/kvm64.c | 2 --
33
target/arm/machine.c | 2 +-
34
5 files changed, 22 insertions(+), 38 deletions(-)
35
36
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
37
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/cpu.h
39
+++ b/target/arm/cpu.h
40
@@ -XXX,XX +XXX,XX @@ bool write_list_to_cpustate(ARMCPU *cpu);
41
/**
42
* write_cpustate_to_list:
43
* @cpu: ARMCPU
44
- * @kvm_sync: true if this is for syncing back to KVM
45
*
46
* For each register listed in the ARMCPU cpreg_indexes list, write
47
* its value from the ARMCPUState structure into the cpreg_values list.
48
* This is used to copy info from TCG's working data structures into
49
* KVM or for outbound migration.
50
*
51
- * @kvm_sync is true if we are doing this in order to sync the
52
- * register state back to KVM. In this case we will only update
53
- * values in the list if the previous list->cpustate sync actually
54
- * successfully wrote the CPU state. Otherwise we will keep the value
55
- * that is in the list.
56
- *
57
* Returns: true if all register values were read correctly,
58
* false if some register was unknown or could not be read.
59
* Note that we do not stop early on failure -- we will attempt
60
* reading all registers in the list.
61
*/
62
-bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
63
+bool write_cpustate_to_list(ARMCPU *cpu);
64
65
#define ARM_CPUID_TI915T 0x54029152
66
#define ARM_CPUID_TI925T 0x54029252
67
diff --git a/target/arm/helper.c b/target/arm/helper.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/target/arm/helper.c
70
+++ b/target/arm/helper.c
71
@@ -XXX,XX +XXX,XX @@ static bool raw_accessors_invalid(const ARMCPRegInfo *ri)
72
return true;
73
}
74
75
-bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync)
76
+bool write_cpustate_to_list(ARMCPU *cpu)
77
{
78
/* Write the coprocessor state from cpu->env to the (index,value) list. */
79
int i;
80
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync)
81
for (i = 0; i < cpu->cpreg_array_len; i++) {
82
uint32_t regidx = kvm_to_cpreg_id(cpu->cpreg_indexes[i]);
83
const ARMCPRegInfo *ri;
84
- uint64_t newval;
85
86
ri = get_arm_cp_reginfo(cpu->cp_regs, regidx);
87
if (!ri) {
88
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync)
89
if (ri->type & ARM_CP_NO_RAW) {
90
continue;
91
}
92
-
93
- newval = read_raw_cp_reg(&cpu->env, ri);
94
- if (kvm_sync) {
95
- /*
96
- * Only sync if the previous list->cpustate sync succeeded.
97
- * Rather than tracking the success/failure state for every
98
- * item in the list, we just recheck "does the raw write we must
99
- * have made in write_list_to_cpustate() read back OK" here.
100
- */
101
- uint64_t oldval = cpu->cpreg_values[i];
102
-
103
- if (oldval == newval) {
104
- continue;
105
- }
106
-
107
- write_raw_cp_reg(&cpu->env, ri, oldval);
108
- if (read_raw_cp_reg(&cpu->env, ri) != oldval) {
109
- continue;
110
- }
111
-
112
- write_raw_cp_reg(&cpu->env, ri, newval);
113
- }
114
- cpu->cpreg_values[i] = newval;
115
+ cpu->cpreg_values[i] = read_raw_cp_reg(&cpu->env, ri);
116
}
117
return ok;
118
}
119
diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c
120
index XXXXXXX..XXXXXXX 100644
121
--- a/target/arm/kvm32.c
122
+++ b/target/arm/kvm32.c
123
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
124
return ret;
125
}
126
127
- write_cpustate_to_list(cpu, true);
128
-
129
+ /* Note that we do not call write_cpustate_to_list()
130
+ * here, so we are only writing the tuple list back to
131
+ * KVM. This is safe because nothing can change the
132
+ * CPUARMState cp15 fields (in particular gdb accesses cannot)
133
+ * and so there are no changes to sync. In fact syncing would
134
+ * be wrong at this point: for a constant register where TCG and
135
+ * KVM disagree about its value, the preceding write_list_to_cpustate()
136
+ * would not have had any effect on the CPUARMState value (since the
137
+ * register is read-only), and a write_cpustate_to_list() here would
138
+ * then try to write the TCG value back into KVM -- this would either
139
+ * fail or incorrectly change the value the guest sees.
140
+ *
141
+ * If we ever want to allow the user to modify cp15 registers via
142
+ * the gdb stub, we would need to be more clever here (for instance
143
+ * tracking the set of registers kvm_arch_get_registers() successfully
144
+ * managed to update the CPUARMState with, and only allowing those
145
+ * to be written back up into the kernel).
146
+ */
147
if (!write_list_to_kvmstate(cpu, level)) {
148
return EINVAL;
149
}
150
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
151
index XXXXXXX..XXXXXXX 100644
152
--- a/target/arm/kvm64.c
153
+++ b/target/arm/kvm64.c
154
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
155
return ret;
156
}
157
158
- write_cpustate_to_list(cpu, true);
159
-
160
if (!write_list_to_kvmstate(cpu, level)) {
161
return EINVAL;
162
}
163
diff --git a/target/arm/machine.c b/target/arm/machine.c
164
index XXXXXXX..XXXXXXX 100644
165
--- a/target/arm/machine.c
166
+++ b/target/arm/machine.c
167
@@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque)
168
abort();
169
}
170
} else {
171
- if (!write_cpustate_to_list(cpu, false)) {
172
+ if (!write_cpustate_to_list(cpu)) {
173
/* This should never fail. */
174
abort();
175
}
176
--
177
2.20.1
178
179
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Add support for "TX complete"/TXDC interrupt generate by real HW since
3
Note that float16_to_float32 rightly squashes SNaN to QNaN.
4
it is needed to support guests other than Linux.
4
But of course pickNaNMulAdd, for ARM, selects SNaNs first.
5
So we have to preserve SNaN long enough for the correct NaN
6
to be selected. Thus float16_to_float32_by_bits.
5
7
6
Based on the patch by Bill Paul as found here:
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
https://bugs.launchpad.net/qemu/+bug/1753314
9
Message-id: 20190219222952.22183-2-richard.henderson@linaro.org
8
9
Cc: qemu-devel@nongnu.org
10
Cc: qemu-arm@nongnu.org
11
Cc: Bill Paul <wpaul@windriver.com>
12
Cc: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Bill Paul <wpaul@windriver.com>
14
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
15
Message-id: 20180315191141.6789-2-andrew.smirnov@gmail.com
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
12
---
19
include/hw/char/imx_serial.h | 3 +++
13
target/arm/helper.h | 9 +++
20
hw/char/imx_serial.c | 20 +++++++++++++++++---
14
target/arm/vec_helper.c | 148 ++++++++++++++++++++++++++++++++++++++++
21
2 files changed, 20 insertions(+), 3 deletions(-)
15
2 files changed, 157 insertions(+)
22
16
23
diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h
17
diff --git a/target/arm/helper.h b/target/arm/helper.h
24
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/char/imx_serial.h
19
--- a/target/arm/helper.h
26
+++ b/include/hw/char/imx_serial.h
20
+++ b/target/arm/helper.h
27
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_sqsub_s, TCG_CALL_NO_RWG,
28
#define UCR2_RXEN (1<<1) /* Receiver enable */
22
DEF_HELPER_FLAGS_5(gvec_sqsub_d, TCG_CALL_NO_RWG,
29
#define UCR2_SRST (1<<0) /* Reset complete */
23
void, ptr, ptr, ptr, ptr, i32)
30
24
31
+#define UCR4_TCEN BIT(3) /* TX complete interrupt enable */
25
+DEF_HELPER_FLAGS_5(gvec_fmlal_a32, TCG_CALL_NO_RWG,
26
+ void, ptr, ptr, ptr, ptr, i32)
27
+DEF_HELPER_FLAGS_5(gvec_fmlal_a64, TCG_CALL_NO_RWG,
28
+ void, ptr, ptr, ptr, ptr, i32)
29
+DEF_HELPER_FLAGS_5(gvec_fmlal_idx_a32, TCG_CALL_NO_RWG,
30
+ void, ptr, ptr, ptr, ptr, i32)
31
+DEF_HELPER_FLAGS_5(gvec_fmlal_idx_a64, TCG_CALL_NO_RWG,
32
+ void, ptr, ptr, ptr, ptr, i32)
32
+
33
+
33
#define UTS1_TXEMPTY (1<<6)
34
#ifdef TARGET_AARCH64
34
#define UTS1_RXEMPTY (1<<5)
35
#include "helper-a64.h"
35
#define UTS1_TXFULL (1<<4)
36
#include "helper-sve.h"
36
@@ -XXX,XX +XXX,XX @@ typedef struct IMXSerialState {
37
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
37
uint32_t ubmr;
38
uint32_t ubrc;
39
uint32_t ucr3;
40
+ uint32_t ucr4;
41
42
qemu_irq irq;
43
CharBackend chr;
44
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
45
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/char/imx_serial.c
39
--- a/target/arm/vec_helper.c
47
+++ b/hw/char/imx_serial.c
40
+++ b/target/arm/vec_helper.c
48
@@ -XXX,XX +XXX,XX @@
41
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_sqsub_d)(void *vd, void *vq, void *vn,
49
42
}
50
static const VMStateDescription vmstate_imx_serial = {
43
clear_tail(d, oprsz, simd_maxsz(desc));
51
.name = TYPE_IMX_SERIAL,
44
}
52
- .version_id = 1,
45
+
53
- .minimum_version_id = 1,
46
+/*
54
+ .version_id = 2,
47
+ * Convert float16 to float32, raising no exceptions and
55
+ .minimum_version_id = 2,
48
+ * preserving exceptional values, including SNaN.
56
.fields = (VMStateField[]) {
49
+ * This is effectively an unpack+repack operation.
57
VMSTATE_INT32(readbuff, IMXSerialState),
50
+ */
58
VMSTATE_UINT32(usr1, IMXSerialState),
51
+static float32 float16_to_float32_by_bits(uint32_t f16, bool fz16)
59
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = {
52
+{
60
VMSTATE_UINT32(ubmr, IMXSerialState),
53
+ const int f16_bias = 15;
61
VMSTATE_UINT32(ubrc, IMXSerialState),
54
+ const int f32_bias = 127;
62
VMSTATE_UINT32(ucr3, IMXSerialState),
55
+ uint32_t sign = extract32(f16, 15, 1);
63
+ VMSTATE_UINT32(ucr4, IMXSerialState),
56
+ uint32_t exp = extract32(f16, 10, 5);
64
VMSTATE_END_OF_LIST()
57
+ uint32_t frac = extract32(f16, 0, 10);
65
},
58
+
66
};
59
+ if (exp == 0x1f) {
67
@@ -XXX,XX +XXX,XX @@ static void imx_update(IMXSerialState *s)
60
+ /* Inf or NaN */
68
* unfortunately.
61
+ exp = 0xff;
69
*/
62
+ } else if (exp == 0) {
70
mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0;
63
+ /* Zero or denormal. */
64
+ if (frac != 0) {
65
+ if (fz16) {
66
+ frac = 0;
67
+ } else {
68
+ /*
69
+ * Denormal; these are all normal float32.
70
+ * Shift the fraction so that the msb is at bit 11,
71
+ * then remove bit 11 as the implicit bit of the
72
+ * normalized float32. Note that we still go through
73
+ * the shift for normal numbers below, to put the
74
+ * float32 fraction at the right place.
75
+ */
76
+ int shift = clz32(frac) - 21;
77
+ frac = (frac << shift) & 0x3ff;
78
+ exp = f32_bias - f16_bias - shift + 1;
79
+ }
80
+ }
81
+ } else {
82
+ /* Normal number; adjust the bias. */
83
+ exp += f32_bias - f16_bias;
84
+ }
85
+ sign <<= 31;
86
+ exp <<= 23;
87
+ frac <<= 23 - 10;
88
+
89
+ return sign | exp | frac;
90
+}
91
+
92
+static uint64_t load4_f16(uint64_t *ptr, int is_q, int is_2)
93
+{
71
+ /*
94
+ /*
72
+ * TCEN and TXDC are both bit 3
95
+ * Branchless load of u32[0], u64[0], u32[1], or u64[1].
96
+ * Load the 2nd qword iff is_q & is_2.
97
+ * Shift to the 2nd dword iff !is_q & is_2.
98
+ * For !is_q & !is_2, the upper bits of the result are garbage.
73
+ */
99
+ */
74
+ mask |= s->ucr4 & UCR4_TCEN;
100
+ return ptr[is_q & is_2] >> ((is_2 & ~is_q) << 5);
101
+}
75
+
102
+
76
usr2 = s->usr2 & mask;
103
+/*
77
104
+ * Note that FMLAL requires oprsz == 8 or oprsz == 16,
78
qemu_set_irq(s->irq, usr1 || usr2);
105
+ * as there is not yet SVE versions that might use blocking.
79
@@ -XXX,XX +XXX,XX @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset,
106
+ */
80
return s->ucr3;
81
82
case 0x23: /* UCR4 */
83
+ return s->ucr4;
84
+
107
+
85
case 0x29: /* BRM Incremental */
108
+static void do_fmlal(float32 *d, void *vn, void *vm, float_status *fpst,
86
return 0x0; /* TODO */
109
+ uint32_t desc, bool fz16)
87
110
+{
88
@@ -XXX,XX +XXX,XX @@ static void imx_serial_write(void *opaque, hwaddr offset,
111
+ intptr_t i, oprsz = simd_oprsz(desc);
89
* qemu_chr_fe_write and background I/O callbacks */
112
+ int is_s = extract32(desc, SIMD_DATA_SHIFT, 1);
90
qemu_chr_fe_write_all(&s->chr, &ch, 1);
113
+ int is_2 = extract32(desc, SIMD_DATA_SHIFT + 1, 1);
91
s->usr1 &= ~USR1_TRDY;
114
+ int is_q = oprsz == 16;
92
+ s->usr2 &= ~USR2_TXDC;
115
+ uint64_t n_4, m_4;
93
imx_update(s);
94
s->usr1 |= USR1_TRDY;
95
+ s->usr2 |= USR2_TXDC;
96
imx_update(s);
97
}
98
break;
99
@@ -XXX,XX +XXX,XX @@ static void imx_serial_write(void *opaque, hwaddr offset,
100
s->ucr3 = value & 0xffff;
101
break;
102
103
- case 0x2d: /* UTS1 */
104
case 0x23: /* UCR4 */
105
+ s->ucr4 = value & 0xffff;
106
+ imx_update(s);
107
+ break;
108
+
116
+
109
+ case 0x2d: /* UTS1 */
117
+ /* Pre-load all of the f16 data, avoiding overlap issues. */
110
qemu_log_mask(LOG_UNIMP, "[%s]%s: Unimplemented reg 0x%"
118
+ n_4 = load4_f16(vn, is_q, is_2);
111
HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset);
119
+ m_4 = load4_f16(vm, is_q, is_2);
112
/* TODO */
120
+
121
+ /* Negate all inputs for FMLSL at once. */
122
+ if (is_s) {
123
+ n_4 ^= 0x8000800080008000ull;
124
+ }
125
+
126
+ for (i = 0; i < oprsz / 4; i++) {
127
+ float32 n_1 = float16_to_float32_by_bits(n_4 >> (i * 16), fz16);
128
+ float32 m_1 = float16_to_float32_by_bits(m_4 >> (i * 16), fz16);
129
+ d[H4(i)] = float32_muladd(n_1, m_1, d[H4(i)], 0, fpst);
130
+ }
131
+ clear_tail(d, oprsz, simd_maxsz(desc));
132
+}
133
+
134
+void HELPER(gvec_fmlal_a32)(void *vd, void *vn, void *vm,
135
+ void *venv, uint32_t desc)
136
+{
137
+ CPUARMState *env = venv;
138
+ do_fmlal(vd, vn, vm, &env->vfp.standard_fp_status, desc,
139
+ get_flush_inputs_to_zero(&env->vfp.fp_status_f16));
140
+}
141
+
142
+void HELPER(gvec_fmlal_a64)(void *vd, void *vn, void *vm,
143
+ void *venv, uint32_t desc)
144
+{
145
+ CPUARMState *env = venv;
146
+ do_fmlal(vd, vn, vm, &env->vfp.fp_status, desc,
147
+ get_flush_inputs_to_zero(&env->vfp.fp_status_f16));
148
+}
149
+
150
+static void do_fmlal_idx(float32 *d, void *vn, void *vm, float_status *fpst,
151
+ uint32_t desc, bool fz16)
152
+{
153
+ intptr_t i, oprsz = simd_oprsz(desc);
154
+ int is_s = extract32(desc, SIMD_DATA_SHIFT, 1);
155
+ int is_2 = extract32(desc, SIMD_DATA_SHIFT + 1, 1);
156
+ int index = extract32(desc, SIMD_DATA_SHIFT + 2, 3);
157
+ int is_q = oprsz == 16;
158
+ uint64_t n_4;
159
+ float32 m_1;
160
+
161
+ /* Pre-load all of the f16 data, avoiding overlap issues. */
162
+ n_4 = load4_f16(vn, is_q, is_2);
163
+
164
+ /* Negate all inputs for FMLSL at once. */
165
+ if (is_s) {
166
+ n_4 ^= 0x8000800080008000ull;
167
+ }
168
+
169
+ m_1 = float16_to_float32_by_bits(((float16 *)vm)[H2(index)], fz16);
170
+
171
+ for (i = 0; i < oprsz / 4; i++) {
172
+ float32 n_1 = float16_to_float32_by_bits(n_4 >> (i * 16), fz16);
173
+ d[H4(i)] = float32_muladd(n_1, m_1, d[H4(i)], 0, fpst);
174
+ }
175
+ clear_tail(d, oprsz, simd_maxsz(desc));
176
+}
177
+
178
+void HELPER(gvec_fmlal_idx_a32)(void *vd, void *vn, void *vm,
179
+ void *venv, uint32_t desc)
180
+{
181
+ CPUARMState *env = venv;
182
+ do_fmlal_idx(vd, vn, vm, &env->vfp.standard_fp_status, desc,
183
+ get_flush_inputs_to_zero(&env->vfp.fp_status_f16));
184
+}
185
+
186
+void HELPER(gvec_fmlal_idx_a64)(void *vd, void *vn, void *vm,
187
+ void *venv, uint32_t desc)
188
+{
189
+ CPUARMState *env = venv;
190
+ do_fmlal_idx(vd, vn, vm, &env->vfp.fp_status, desc,
191
+ get_flush_inputs_to_zero(&env->vfp.fp_status_f16));
192
+}
113
--
193
--
114
2.16.2
194
2.20.1
115
195
116
196
diff view generated by jsdifflib
1
From: Andrey Smirnov <andrew.smirnov@gmail.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Code of imx_update() is slightly confusing since the "flags" variable
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
doesn't really corespond to anything in real hardware and server as a
4
Message-id: 20190219222952.22183-3-richard.henderson@linaro.org
5
kitchensink accumulating events normally reported via USR1 and USR2
6
registers.
7
8
Change the code to explicitly evaluate state of interrupts reported
9
via USR1 and USR2 against corresponding masking bits and use the to
10
detemine if IRQ line should be asserted or not.
11
12
NOTE: Check for UTS1_TXEMPTY being set has been dropped for two
13
reasons:
14
15
1. Emulation code implements a single character FIFO, so this flag
16
will always be set since characters are trasmitted as a part of
17
the code emulating "push" into the FIFO
18
19
2. imx_update() is really just a function doing ORing and maksing
20
of reported events, so checking for UTS1_TXEMPTY should happen,
21
if it's ever really needed should probably happen outside of
22
it.
23
24
Cc: qemu-devel@nongnu.org
25
Cc: qemu-arm@nongnu.org
26
Cc: Bill Paul <wpaul@windriver.com>
27
Cc: Peter Maydell <peter.maydell@linaro.org>
28
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
29
Message-id: 20180315191141.6789-1-andrew.smirnov@gmail.com
30
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
31
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
32
---
7
---
33
hw/char/imx_serial.c | 24 ++++++++++++++++--------
8
target/arm/cpu.h | 5 ++++
34
1 file changed, 16 insertions(+), 8 deletions(-)
9
target/arm/translate-a64.c | 49 +++++++++++++++++++++++++++++++++++++-
10
2 files changed, 53 insertions(+), 1 deletion(-)
35
11
36
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
12
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
37
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
38
--- a/hw/char/imx_serial.c
14
--- a/target/arm/cpu.h
39
+++ b/hw/char/imx_serial.c
15
+++ b/target/arm/cpu.h
40
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = {
16
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_dp(const ARMISARegisters *id)
41
17
return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, DP) != 0;
42
static void imx_update(IMXSerialState *s)
18
}
19
20
+static inline bool isar_feature_aa64_fhm(const ARMISARegisters *id)
21
+{
22
+ return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, FHM) != 0;
23
+}
24
+
25
static inline bool isar_feature_aa64_jscvt(const ARMISARegisters *id)
43
{
26
{
44
- uint32_t flags;
27
return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, JSCVT) != 0;
45
+ uint32_t usr1;
28
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
46
+ uint32_t usr2;
29
index XXXXXXX..XXXXXXX 100644
47
+ uint32_t mask;
30
--- a/target/arm/translate-a64.c
48
31
+++ b/target/arm/translate-a64.c
49
- flags = (s->usr1 & s->ucr1) & (USR1_TRDY|USR1_RRDY);
32
@@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_float(DisasContext *s, uint32_t insn)
50
- if (s->ucr1 & UCR1_TXMPTYEN) {
33
if (!fp_access_check(s)) {
51
- flags |= (s->uts1 & UTS1_TXEMPTY);
34
return;
52
- } else {
35
}
53
- flags &= ~USR1_TRDY;
36
-
54
- }
37
handle_3same_float(s, size, elements, fpopcode, rd, rn, rm);
55
+ /*
38
return;
56
+ * Lucky for us TRDY and RRDY has the same offset in both USR1 and
39
+
57
+ * UCR1, so we can get away with something as simple as the
40
+ case 0x1d: /* FMLAL */
58
+ * following:
41
+ case 0x3d: /* FMLSL */
59
+ */
42
+ case 0x59: /* FMLAL2 */
60
+ usr1 = s->usr1 & s->ucr1 & (USR1_TRDY | USR1_RRDY);
43
+ case 0x79: /* FMLSL2 */
61
+ /*
44
+ if (size & 1 || !dc_isar_feature(aa64_fhm, s)) {
62
+ * Bits that we want in USR2 are not as conveniently laid out,
45
+ unallocated_encoding(s);
63
+ * unfortunately.
46
+ return;
64
+ */
47
+ }
65
+ mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0;
48
+ if (fp_access_check(s)) {
66
+ usr2 = s->usr2 & mask;
49
+ int is_s = extract32(insn, 23, 1);
67
50
+ int is_2 = extract32(insn, 29, 1);
68
- qemu_set_irq(s->irq, !!flags);
51
+ int data = (is_2 << 1) | is_s;
69
+ qemu_set_irq(s->irq, usr1 || usr2);
52
+ tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd),
70
}
53
+ vec_full_reg_offset(s, rn),
71
54
+ vec_full_reg_offset(s, rm), cpu_env,
72
static void imx_serial_reset(IMXSerialState *s)
55
+ is_q ? 16 : 8, vec_full_reg_size(s),
56
+ data, gen_helper_gvec_fmlal_a64);
57
+ }
58
+ return;
59
+
60
default:
61
unallocated_encoding(s);
62
return;
63
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
64
}
65
is_fp = 2;
66
break;
67
+ case 0x00: /* FMLAL */
68
+ case 0x04: /* FMLSL */
69
+ case 0x18: /* FMLAL2 */
70
+ case 0x1c: /* FMLSL2 */
71
+ if (is_scalar || size != MO_32 || !dc_isar_feature(aa64_fhm, s)) {
72
+ unallocated_encoding(s);
73
+ return;
74
+ }
75
+ size = MO_16;
76
+ /* is_fp, but we pass cpu_env not fp_status. */
77
+ break;
78
default:
79
unallocated_encoding(s);
80
return;
81
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
82
tcg_temp_free_ptr(fpst);
83
}
84
return;
85
+
86
+ case 0x00: /* FMLAL */
87
+ case 0x04: /* FMLSL */
88
+ case 0x18: /* FMLAL2 */
89
+ case 0x1c: /* FMLSL2 */
90
+ {
91
+ int is_s = extract32(opcode, 2, 1);
92
+ int is_2 = u;
93
+ int data = (index << 2) | (is_2 << 1) | is_s;
94
+ tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd),
95
+ vec_full_reg_offset(s, rn),
96
+ vec_full_reg_offset(s, rm), cpu_env,
97
+ is_q ? 16 : 8, vec_full_reg_size(s),
98
+ data, gen_helper_gvec_fmlal_idx_a64);
99
+ }
100
+ return;
101
}
102
103
if (size == 3) {
73
--
104
--
74
2.16.2
105
2.20.1
75
106
76
107
diff view generated by jsdifflib
New patch
1
1
From: Richard Henderson <richard.henderson@linaro.org>
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Message-id: 20190219222952.22183-4-richard.henderson@linaro.org
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/cpu.h | 5 ++
9
target/arm/translate.c | 129 ++++++++++++++++++++++++++++++-----------
10
2 files changed, 101 insertions(+), 33 deletions(-)
11
12
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu.h
15
+++ b/target/arm/cpu.h
16
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_dp(const ARMISARegisters *id)
17
return FIELD_EX32(id->id_isar6, ID_ISAR6, DP) != 0;
18
}
19
20
+static inline bool isar_feature_aa32_fhm(const ARMISARegisters *id)
21
+{
22
+ return FIELD_EX32(id->id_isar6, ID_ISAR6, FHM) != 0;
23
+}
24
+
25
static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id)
26
{
27
/*
28
diff --git a/target/arm/translate.c b/target/arm/translate.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/translate.c
31
+++ b/target/arm/translate.c
32
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
33
gen_helper_gvec_3_ptr *fn_gvec_ptr = NULL;
34
int rd, rn, rm, opr_sz;
35
int data = 0;
36
- bool q;
37
-
38
- q = extract32(insn, 6, 1);
39
- VFP_DREG_D(rd, insn);
40
- VFP_DREG_N(rn, insn);
41
- VFP_DREG_M(rm, insn);
42
- if ((rd | rn | rm) & q) {
43
- return 1;
44
- }
45
+ int off_rn, off_rm;
46
+ bool is_long = false, q = extract32(insn, 6, 1);
47
+ bool ptr_is_env = false;
48
49
if ((insn & 0xfe200f10) == 0xfc200800) {
50
/* VCMLA -- 1111 110R R.1S .... .... 1000 ...0 .... */
51
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
52
return 1;
53
}
54
fn_gvec = u ? gen_helper_gvec_udot_b : gen_helper_gvec_sdot_b;
55
+ } else if ((insn & 0xff300f10) == 0xfc200810) {
56
+ /* VFM[AS]L -- 1111 1100 S.10 .... .... 1000 .Q.1 .... */
57
+ int is_s = extract32(insn, 23, 1);
58
+ if (!dc_isar_feature(aa32_fhm, s)) {
59
+ return 1;
60
+ }
61
+ is_long = true;
62
+ data = is_s; /* is_2 == 0 */
63
+ fn_gvec_ptr = gen_helper_gvec_fmlal_a32;
64
+ ptr_is_env = true;
65
} else {
66
return 1;
67
}
68
69
+ VFP_DREG_D(rd, insn);
70
+ if (rd & q) {
71
+ return 1;
72
+ }
73
+ if (q || !is_long) {
74
+ VFP_DREG_N(rn, insn);
75
+ VFP_DREG_M(rm, insn);
76
+ if ((rn | rm) & q & !is_long) {
77
+ return 1;
78
+ }
79
+ off_rn = vfp_reg_offset(1, rn);
80
+ off_rm = vfp_reg_offset(1, rm);
81
+ } else {
82
+ rn = VFP_SREG_N(insn);
83
+ rm = VFP_SREG_M(insn);
84
+ off_rn = vfp_reg_offset(0, rn);
85
+ off_rm = vfp_reg_offset(0, rm);
86
+ }
87
+
88
if (s->fp_excp_el) {
89
gen_exception_insn(s, 4, EXCP_UDEF,
90
syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
91
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
92
93
opr_sz = (1 + q) * 8;
94
if (fn_gvec_ptr) {
95
- TCGv_ptr fpst = get_fpstatus_ptr(1);
96
- tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd),
97
- vfp_reg_offset(1, rn),
98
- vfp_reg_offset(1, rm), fpst,
99
+ TCGv_ptr ptr;
100
+ if (ptr_is_env) {
101
+ ptr = cpu_env;
102
+ } else {
103
+ ptr = get_fpstatus_ptr(1);
104
+ }
105
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), off_rn, off_rm, ptr,
106
opr_sz, opr_sz, data, fn_gvec_ptr);
107
- tcg_temp_free_ptr(fpst);
108
+ if (!ptr_is_env) {
109
+ tcg_temp_free_ptr(ptr);
110
+ }
111
} else {
112
- tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd),
113
- vfp_reg_offset(1, rn),
114
- vfp_reg_offset(1, rm),
115
+ tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd), off_rn, off_rm,
116
opr_sz, opr_sz, data, fn_gvec);
117
}
118
return 0;
119
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
120
gen_helper_gvec_3 *fn_gvec = NULL;
121
gen_helper_gvec_3_ptr *fn_gvec_ptr = NULL;
122
int rd, rn, rm, opr_sz, data;
123
- bool q;
124
-
125
- q = extract32(insn, 6, 1);
126
- VFP_DREG_D(rd, insn);
127
- VFP_DREG_N(rn, insn);
128
- if ((rd | rn) & q) {
129
- return 1;
130
- }
131
+ int off_rn, off_rm;
132
+ bool is_long = false, q = extract32(insn, 6, 1);
133
+ bool ptr_is_env = false;
134
135
if ((insn & 0xff000f10) == 0xfe000800) {
136
/* VCMLA (indexed) -- 1111 1110 S.RR .... .... 1000 ...0 .... */
137
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
138
} else if ((insn & 0xffb00f00) == 0xfe200d00) {
139
/* V[US]DOT -- 1111 1110 0.10 .... .... 1101 .Q.U .... */
140
int u = extract32(insn, 4, 1);
141
+
142
if (!dc_isar_feature(aa32_dp, s)) {
143
return 1;
144
}
145
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
146
/* rm is just Vm, and index is M. */
147
data = extract32(insn, 5, 1); /* index */
148
rm = extract32(insn, 0, 4);
149
+ } else if ((insn & 0xffa00f10) == 0xfe000810) {
150
+ /* VFM[AS]L -- 1111 1110 0.0S .... .... 1000 .Q.1 .... */
151
+ int is_s = extract32(insn, 20, 1);
152
+ int vm20 = extract32(insn, 0, 3);
153
+ int vm3 = extract32(insn, 3, 1);
154
+ int m = extract32(insn, 5, 1);
155
+ int index;
156
+
157
+ if (!dc_isar_feature(aa32_fhm, s)) {
158
+ return 1;
159
+ }
160
+ if (q) {
161
+ rm = vm20;
162
+ index = m * 2 + vm3;
163
+ } else {
164
+ rm = vm20 * 2 + m;
165
+ index = vm3;
166
+ }
167
+ is_long = true;
168
+ data = (index << 2) | is_s; /* is_2 == 0 */
169
+ fn_gvec_ptr = gen_helper_gvec_fmlal_idx_a32;
170
+ ptr_is_env = true;
171
} else {
172
return 1;
173
}
174
175
+ VFP_DREG_D(rd, insn);
176
+ if (rd & q) {
177
+ return 1;
178
+ }
179
+ if (q || !is_long) {
180
+ VFP_DREG_N(rn, insn);
181
+ if (rn & q & !is_long) {
182
+ return 1;
183
+ }
184
+ off_rn = vfp_reg_offset(1, rn);
185
+ off_rm = vfp_reg_offset(1, rm);
186
+ } else {
187
+ rn = VFP_SREG_N(insn);
188
+ off_rn = vfp_reg_offset(0, rn);
189
+ off_rm = vfp_reg_offset(0, rm);
190
+ }
191
if (s->fp_excp_el) {
192
gen_exception_insn(s, 4, EXCP_UDEF,
193
syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
194
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
195
196
opr_sz = (1 + q) * 8;
197
if (fn_gvec_ptr) {
198
- TCGv_ptr fpst = get_fpstatus_ptr(1);
199
- tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd),
200
- vfp_reg_offset(1, rn),
201
- vfp_reg_offset(1, rm), fpst,
202
+ TCGv_ptr ptr;
203
+ if (ptr_is_env) {
204
+ ptr = cpu_env;
205
+ } else {
206
+ ptr = get_fpstatus_ptr(1);
207
+ }
208
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), off_rn, off_rm, ptr,
209
opr_sz, opr_sz, data, fn_gvec_ptr);
210
- tcg_temp_free_ptr(fpst);
211
+ if (!ptr_is_env) {
212
+ tcg_temp_free_ptr(ptr);
213
+ }
214
} else {
215
- tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd),
216
- vfp_reg_offset(1, rn),
217
- vfp_reg_offset(1, rm),
218
+ tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd), off_rn, off_rm,
219
opr_sz, opr_sz, data, fn_gvec);
220
}
221
return 0;
222
--
223
2.20.1
224
225
diff view generated by jsdifflib
1
From: Wei Huang <wei@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
For guest kernel that supports KASLR, the load address can change every
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
time when guest VM runs. To find the physical base address correctly,
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
current QEMU dump searches VMCOREINFO for the string "NUMBER(phys_base)=".
5
Message-id: 20190219222952.22183-5-richard.henderson@linaro.org
6
However this string pattern is only available on x86_64. AArch64 uses a
7
different field, called "NUMBER(PHYS_OFFSET)=". This patch makes sure
8
QEMU dump uses the correct string on AArch64.
9
10
Signed-off-by: Wei Huang <wei@redhat.com>
11
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
12
Message-id: 1520615003-20869-1-git-send-email-wei@redhat.com
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
7
---
15
dump.c | 14 +++++++++++---
8
target/arm/cpu.c | 1 +
16
1 file changed, 11 insertions(+), 3 deletions(-)
9
target/arm/cpu64.c | 2 ++
10
2 files changed, 3 insertions(+)
17
11
18
diff --git a/dump.c b/dump.c
12
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
19
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
20
--- a/dump.c
14
--- a/target/arm/cpu.c
21
+++ b/dump.c
15
+++ b/target/arm/cpu.c
22
@@ -XXX,XX +XXX,XX @@ static void vmcoreinfo_update_phys_base(DumpState *s)
16
@@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj)
23
17
t = cpu->isar.id_isar6;
24
lines = g_strsplit((char *)vmci, "\n", -1);
18
t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1);
25
for (i = 0; lines[i]; i++) {
19
t = FIELD_DP32(t, ID_ISAR6, DP, 1);
26
- if (g_str_has_prefix(lines[i], "NUMBER(phys_base)=")) {
20
+ t = FIELD_DP32(t, ID_ISAR6, FHM, 1);
27
- if (qemu_strtou64(lines[i] + 18, NULL, 16,
21
cpu->isar.id_isar6 = t;
28
+ const char *prefix = NULL;
22
29
+
23
t = cpu->id_mmfr4;
30
+ if (s->dump_info.d_machine == EM_X86_64) {
24
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
31
+ prefix = "NUMBER(phys_base)=";
25
index XXXXXXX..XXXXXXX 100644
32
+ } else if (s->dump_info.d_machine == EM_AARCH64) {
26
--- a/target/arm/cpu64.c
33
+ prefix = "NUMBER(PHYS_OFFSET)=";
27
+++ b/target/arm/cpu64.c
34
+ }
28
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
35
+
29
t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1);
36
+ if (prefix && g_str_has_prefix(lines[i], prefix)) {
30
t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1);
37
+ if (qemu_strtou64(lines[i] + strlen(prefix), NULL, 16,
31
t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);
38
&phys_base) < 0) {
32
+ t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1);
39
- warn_report("Failed to read NUMBER(phys_base)=");
33
cpu->isar.id_aa64isar0 = t;
40
+ warn_report("Failed to read %s", prefix);
34
41
} else {
35
t = cpu->isar.id_aa64isar1;
42
s->dump_info.phys_base = phys_base;
36
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
43
}
37
u = cpu->isar.id_isar6;
38
u = FIELD_DP32(u, ID_ISAR6, JSCVT, 1);
39
u = FIELD_DP32(u, ID_ISAR6, DP, 1);
40
+ u = FIELD_DP32(u, ID_ISAR6, FHM, 1);
41
cpu->isar.id_isar6 = u;
42
43
/*
44
--
44
--
45
2.16.2
45
2.20.1
46
46
47
47
diff view generated by jsdifflib
1
From: Guenter Roeck <linux@roeck-us.net>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
The sabrelite machine model used by qemu-system-arm is based on the
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Freescale/NXP i.MX6Q processor. This SoC has an on-board ethernet
4
Message-id: 20190219222952.22183-6-richard.henderson@linaro.org
5
controller which is supported in QEMU using the imx_fec.c module
6
(actually called imx.enet for this model.)
7
8
The include/hw/arm/fsm-imx6.h file defines the interrupt vectors for the
9
imx.enet device like this:
10
11
#define FSL_IMX6_ENET_MAC_1588_IRQ 118
12
#define FSL_IMX6_ENET_MAC_IRQ 119
13
14
According to https://www.nxp.com/docs/en/reference-manual/IMX6DQRM.pdf,
15
page 225, in Table 3-1. ARM Cortex A9 domain interrupt summary,
16
interrupts are as follows.
17
18
150 ENET MAC 0 IRQ
19
151 ENET MAC 0 1588 Timer interrupt
20
21
where
22
23
150 - 32 == 118
24
151 - 32 == 119
25
26
In other words, the vector definitions in the fsl-imx6.h file are reversed.
27
28
Fixing the interrupts alone causes problems with older Linux kernels:
29
The Ethernet interface will fail to probe with Linux v4.9 and earlier.
30
Linux v4.1 and earlier will crash due to a bug in Ethernet driver probe
31
error handling. This is a Linux kernel problem, not a qemu problem:
32
the Linux kernel only worked by accident since it requested both interrupts.
33
34
For backward compatibility, generate the Ethernet interrupt on both interrupt
35
lines. This was shown to work from all Linux kernel releases starting with
36
v3.16.
37
38
Link: https://bugs.launchpad.net/qemu/+bug/1753309
39
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
40
Message-id: 1520723090-22130-1-git-send-email-linux@roeck-us.net
41
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
42
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
43
---
7
---
44
include/hw/arm/fsl-imx6.h | 4 ++--
8
linux-user/elfload.c | 2 ++
45
hw/net/imx_fec.c | 28 +++++++++++++++++++++++++++-
9
1 file changed, 2 insertions(+)
46
2 files changed, 29 insertions(+), 3 deletions(-)
47
10
48
diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h
11
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
49
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
50
--- a/include/hw/arm/fsl-imx6.h
13
--- a/linux-user/elfload.c
51
+++ b/include/hw/arm/fsl-imx6.h
14
+++ b/linux-user/elfload.c
52
@@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6State {
15
@@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void)
53
#define FSL_IMX6_HDMI_MASTER_IRQ 115
16
GET_FEATURE_ID(aa64_fcma, ARM_HWCAP_A64_FCMA);
54
#define FSL_IMX6_HDMI_CEC_IRQ 116
17
GET_FEATURE_ID(aa64_sve, ARM_HWCAP_A64_SVE);
55
#define FSL_IMX6_MLB150_LOW_IRQ 117
18
GET_FEATURE_ID(aa64_pauth, ARM_HWCAP_A64_PACA | ARM_HWCAP_A64_PACG);
56
-#define FSL_IMX6_ENET_MAC_1588_IRQ 118
19
+ GET_FEATURE_ID(aa64_fhm, ARM_HWCAP_A64_ASIMDFHM);
57
-#define FSL_IMX6_ENET_MAC_IRQ 119
20
+ GET_FEATURE_ID(aa64_jscvt, ARM_HWCAP_A64_JSCVT);
58
+#define FSL_IMX6_ENET_MAC_IRQ 118
21
59
+#define FSL_IMX6_ENET_MAC_1588_IRQ 119
22
#undef GET_FEATURE_ID
60
#define FSL_IMX6_PCIE1_IRQ 120
23
61
#define FSL_IMX6_PCIE2_IRQ 121
62
#define FSL_IMX6_PCIE3_IRQ 122
63
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/hw/net/imx_fec.c
66
+++ b/hw/net/imx_fec.c
67
@@ -XXX,XX +XXX,XX @@ static void imx_enet_write_bd(IMXENETBufDesc *bd, dma_addr_t addr)
68
69
static void imx_eth_update(IMXFECState *s)
70
{
71
- if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & ENET_INT_TS_TIMER) {
72
+ /*
73
+ * Previous versions of qemu had the ENET_INT_MAC and ENET_INT_TS_TIMER
74
+ * interrupts swapped. This worked with older versions of Linux (4.14
75
+ * and older) since Linux associated both interrupt lines with Ethernet
76
+ * MAC interrupts. Specifically,
77
+ * - Linux 4.15 and later have separate interrupt handlers for the MAC and
78
+ * timer interrupts. Those versions of Linux fail with versions of QEMU
79
+ * with swapped interrupt assignments.
80
+ * - In linux 4.14, both interrupt lines were registered with the Ethernet
81
+ * MAC interrupt handler. As a result, all versions of qemu happen to
82
+ * work, though that is accidental.
83
+ * - In Linux 4.9 and older, the timer interrupt was registered directly
84
+ * with the Ethernet MAC interrupt handler. The MAC interrupt was
85
+ * redirected to a GPIO interrupt to work around erratum ERR006687.
86
+ * This was implemented using the SOC's IOMUX block. In qemu, this GPIO
87
+ * interrupt never fired since IOMUX is currently not supported in qemu.
88
+ * Linux instead received MAC interrupts on the timer interrupt.
89
+ * As a result, qemu versions with the swapped interrupt assignment work,
90
+ * albeit accidentally, but qemu versions with the correct interrupt
91
+ * assignment fail.
92
+ *
93
+ * To ensure that all versions of Linux work, generate ENET_INT_MAC
94
+ * interrrupts on both interrupt lines. This should be changed if and when
95
+ * qemu supports IOMUX.
96
+ */
97
+ if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] &
98
+ (ENET_INT_MAC | ENET_INT_TS_TIMER)) {
99
qemu_set_irq(s->irq[1], 1);
100
} else {
101
qemu_set_irq(s->irq[1], 0);
102
--
24
--
103
2.16.2
25
2.20.1
104
26
105
27
diff view generated by jsdifflib