1
target-arm queue for rc1 -- these are all bug fixes.
1
Not much here, mostly documentation, but a few bug fixes.
2
2
3
thanks
3
thanks
4
-- PMM
4
-- PMM
5
5
6
The following changes since commit b9404bf592e7ba74180e1a54ed7a266ec6ee67f2:
6
The following changes since commit 873ec69aeb12e24eec7fb317fd0cd8494e8489dd:
7
7
8
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-hmp-20190715' into staging (2019-07-15 12:22:07 +0100)
8
Merge remote-tracking branch 'remotes/cminyard/tags/for-qemu-i2c-5' into staging (2020-07-20 11:03:09 +0100)
9
9
10
are available in the Git repository at:
10
are available in the Git repository at:
11
11
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190715
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200720
13
13
14
for you to fetch changes up to 51c9122e92b776a3f16af0b9282f1dc5012e2a19:
14
for you to fetch changes up to 6a0b7505f1fd6769c3f1558fda76464d51e4118a:
15
15
16
target/arm: NS BusFault on vector table fetch escalates to NS HardFault (2019-07-15 14:17:04 +0100)
16
docs/system: Document the arm virt board (2020-07-20 11:35:17 +0100)
17
17
18
----------------------------------------------------------------
18
----------------------------------------------------------------
19
target-arm queue:
19
target-arm queue:
20
* report ARMv8-A FP support for AArch32 -cpu max
20
* virt: Don't enable MTE emulation by default
21
* hw/ssi/xilinx_spips: Avoid AXI writes to the LQSPI linear memory
21
* virt: Diagnose attempts to use MTE with memory-hotplug or KVM
22
* hw/ssi/xilinx_spips: Avoid out-of-bound access to lqspi_buf[]
22
(rather than silently not working correctly)
23
* hw/ssi/mss-spi: Avoid crash when reading empty RX FIFO
23
* util: Implement qemu_get_thread_id() for OpenBSD
24
* hw/display/xlnx_dp: Avoid crash when reading empty RX FIFO
24
* qdev: Add doc comments for qdev_unrealize and GPIO functions,
25
* hw/arm/virt: Fix non-secure flash mode
25
and standardize on doc-comments-in-header-file
26
* pl031: Correctly migrate state when using -rtc clock=host
26
* hw/arm/armsse: Assert info->num_cpus is in-bounds in armsse_realize()
27
* fix regression that meant arm926 and arm1026 lost VFP
27
* docs/system: Document canon-a1100, collie, gumstix, virt boards
28
double-precision support
29
* v8M: NS BusFault on vector table fetch escalates to NS HardFault
30
28
31
----------------------------------------------------------------
29
----------------------------------------------------------------
32
Alex Bennée (1):
30
David CARLIER (1):
33
target/arm: report ARMv8-A FP support for AArch32 -cpu max
31
util: Implement qemu_get_thread_id() for OpenBSD
34
32
35
David Engraf (1):
33
Peter Maydell (8):
36
hw/arm/virt: Fix non-secure flash mode
34
qdev: Move doc comments from qdev.c to qdev-core.h
35
qdev: Document qdev_unrealize()
36
qdev: Document GPIO related functions
37
hw/arm/armsse: Assert info->num_cpus is in-bounds in armsse_realize()
38
docs/system: Briefly document canon-a1100 board
39
docs/system: Briefly document collie board
40
docs/system: Briefly document gumstix boards
41
docs/system: Document the arm virt board
37
42
38
Peter Maydell (3):
43
Richard Henderson (3):
39
pl031: Correctly migrate state when using -rtc clock=host
44
hw/arm/virt: Enable MTE via a machine property
40
target/arm: Set VFP-related MVFR0 fields for arm926 and arm1026
45
hw/arm/virt: Error for MTE enabled with KVM
41
target/arm: NS BusFault on vector table fetch escalates to NS HardFault
46
hw/arm/virt: Disable memory hotplug when MTE is enabled
42
47
43
Philippe Mathieu-Daudé (5):
48
docs/system/arm/collie.rst | 16 +++
44
hw/ssi/xilinx_spips: Convert lqspi_read() to read_with_attrs
49
docs/system/arm/digic.rst | 11 ++
45
hw/ssi/xilinx_spips: Avoid AXI writes to the LQSPI linear memory
50
docs/system/arm/gumstix.rst | 21 ++++
46
hw/ssi/xilinx_spips: Avoid out-of-bound access to lqspi_buf[]
51
docs/system/arm/virt.rst | 161 ++++++++++++++++++++++++++
47
hw/ssi/mss-spi: Avoid crash when reading empty RX FIFO
52
docs/system/target-arm.rst | 4 +
48
hw/display/xlnx_dp: Avoid crash when reading empty RX FIFO
53
include/hw/arm/virt.h | 1 +
54
include/hw/qdev-core.h | 267 ++++++++++++++++++++++++++++++++++++++++++-
55
include/hw/qdev-properties.h | 13 +++
56
hw/arm/armsse.c | 2 +
57
hw/arm/virt.c | 50 +++++++-
58
hw/core/qdev.c | 33 ------
59
target/arm/cpu.c | 19 +--
60
target/arm/cpu64.c | 5 +-
61
util/oslib-posix.c | 2 +
62
MAINTAINERS | 4 +
63
15 files changed, 559 insertions(+), 50 deletions(-)
64
create mode 100644 docs/system/arm/collie.rst
65
create mode 100644 docs/system/arm/digic.rst
66
create mode 100644 docs/system/arm/gumstix.rst
67
create mode 100644 docs/system/arm/virt.rst
49
68
50
include/hw/timer/pl031.h | 2 ++
51
hw/arm/virt.c | 2 +-
52
hw/core/machine.c | 1 +
53
hw/display/xlnx_dp.c | 15 +++++---
54
hw/ssi/mss-spi.c | 8 ++++-
55
hw/ssi/xilinx_spips.c | 43 +++++++++++++++-------
56
hw/timer/pl031.c | 92 +++++++++++++++++++++++++++++++++++++++++++++---
57
target/arm/cpu.c | 16 +++++++++
58
target/arm/m_helper.c | 21 ++++++++---
59
9 files changed, 174 insertions(+), 26 deletions(-)
60
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
When we converted to using feature bits in 602f6e42cfbf we missed out
3
Control this cpu feature via a machine property, much as we do
4
the fact (dp && arm_dc_feature(s, ARM_FEATURE_V8)) was supported for
4
with secure=on, since both require specialized support in the
5
-cpu max configurations. This caused a regression in the GCC test
5
machine setup to be functional.
6
suite. Fix this by setting the appropriate bits in mvfr1.FPHP to
7
report ARMv8-A with FP support (but not ARMv8.2-FP16).
8
6
9
Fixes: https://bugs.launchpad.net/qemu/+bug/1836078
7
Default MTE to off, since this feature implies extra overhead.
10
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20190711103737.10017-1-alex.bennee@linaro.org
10
Message-id: 20200713213341.590275-2-richard.henderson@linaro.org
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
13
---
15
target/arm/cpu.c | 4 ++++
14
include/hw/arm/virt.h | 1 +
16
1 file changed, 4 insertions(+)
15
hw/arm/virt.c | 39 ++++++++++++++++++++++++++++++++++-----
16
target/arm/cpu.c | 19 +++++++++++--------
17
target/arm/cpu64.c | 5 +++--
18
4 files changed, 49 insertions(+), 15 deletions(-)
17
19
20
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/arm/virt.h
23
+++ b/include/hw/arm/virt.h
24
@@ -XXX,XX +XXX,XX @@ typedef struct {
25
bool its;
26
bool virt;
27
bool ras;
28
+ bool mte;
29
OnOffAuto acpi;
30
VirtGICType gic_version;
31
VirtIOMMUType iommu;
32
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/virt.c
35
+++ b/hw/arm/virt.c
36
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
37
OBJECT(secure_sysmem), &error_abort);
38
}
39
40
- /*
41
- * The cpu adds the property if and only if MemTag is supported.
42
- * If it is, we must allocate the ram to back that up.
43
- */
44
- if (object_property_find(cpuobj, "tag-memory", NULL)) {
45
+ if (vms->mte) {
46
+ /* Create the memory region only once, but link to all cpus. */
47
if (!tag_sysmem) {
48
+ /*
49
+ * The property exists only if MemTag is supported.
50
+ * If it is, we must allocate the ram to back that up.
51
+ */
52
+ if (!object_property_find(cpuobj, "tag-memory", NULL)) {
53
+ error_report("MTE requested, but not supported "
54
+ "by the guest CPU");
55
+ exit(1);
56
+ }
57
+
58
tag_sysmem = g_new(MemoryRegion, 1);
59
memory_region_init(tag_sysmem, OBJECT(machine),
60
"tag-memory", UINT64_MAX / 32);
61
@@ -XXX,XX +XXX,XX @@ static void virt_set_ras(Object *obj, bool value, Error **errp)
62
vms->ras = value;
63
}
64
65
+static bool virt_get_mte(Object *obj, Error **errp)
66
+{
67
+ VirtMachineState *vms = VIRT_MACHINE(obj);
68
+
69
+ return vms->mte;
70
+}
71
+
72
+static void virt_set_mte(Object *obj, bool value, Error **errp)
73
+{
74
+ VirtMachineState *vms = VIRT_MACHINE(obj);
75
+
76
+ vms->mte = value;
77
+}
78
+
79
static char *virt_get_gic_version(Object *obj, Error **errp)
80
{
81
VirtMachineState *vms = VIRT_MACHINE(obj);
82
@@ -XXX,XX +XXX,XX @@ static void virt_instance_init(Object *obj)
83
"Set on/off to enable/disable reporting host memory errors "
84
"to a KVM guest using ACPI and guest external abort exceptions");
85
86
+ /* MTE is disabled by default. */
87
+ vms->mte = false;
88
+ object_property_add_bool(obj, "mte", virt_get_mte, virt_set_mte);
89
+ object_property_set_description(obj, "mte",
90
+ "Set on/off to enable/disable emulating a "
91
+ "guest CPU which implements the ARM "
92
+ "Memory Tagging Extension");
93
+
94
vms->irqmap = a15irqmap;
95
96
virt_flash_create(vms);
18
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
97
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
19
index XXXXXXX..XXXXXXX 100644
98
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/cpu.c
99
--- a/target/arm/cpu.c
21
+++ b/target/arm/cpu.c
100
+++ b/target/arm/cpu.c
22
@@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj)
101
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
23
t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1);
102
cpu->id_pfr1 &= ~0xf000;
24
cpu->isar.id_isar6 = t;
103
}
25
104
26
+ t = cpu->isar.mvfr1;
105
+#ifndef CONFIG_USER_ONLY
27
+ t = FIELD_DP32(t, MVFR1, FPHP, 2); /* v8.0 FP support */
106
+ if (cpu->tag_memory == NULL && cpu_isar_feature(aa64_mte, cpu)) {
28
+ cpu->isar.mvfr1 = t;
107
+ /*
108
+ * Disable the MTE feature bits if we do not have tag-memory
109
+ * provided by the machine.
110
+ */
111
+ cpu->isar.id_aa64pfr1 =
112
+ FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 0);
113
+ }
114
+#endif
29
+
115
+
30
t = cpu->isar.mvfr2;
116
/* MPU can be configured out of a PMSA CPU either by setting has-mpu
31
t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */
117
* to false or by setting pmsav7-dregion to 0.
32
t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */
118
*/
119
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
120
cpu_address_space_init(cs, ARMASIdx_TagS, "cpu-tag-memory",
121
cpu->secure_tag_memory);
122
}
123
- } else if (cpu_isar_feature(aa64_mte, cpu)) {
124
- /*
125
- * Since there is no tag memory, we can't meaningfully support MTE
126
- * to its fullest. To avoid problems later, when we would come to
127
- * use the tag memory, downgrade support to insns only.
128
- */
129
- cpu->isar.id_aa64pfr1 =
130
- FIELD_DP64(cpu->isar.id_aa64pfr1, ID_AA64PFR1, MTE, 1);
131
}
132
133
cpu_address_space_init(cs, ARMASIdx_NS, "cpu-memory", cs->memory);
134
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
135
index XXXXXXX..XXXXXXX 100644
136
--- a/target/arm/cpu64.c
137
+++ b/target/arm/cpu64.c
138
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
139
t = cpu->isar.id_aa64pfr1;
140
t = FIELD_DP64(t, ID_AA64PFR1, BT, 1);
141
/*
142
- * Begin with full support for MTE; will be downgraded to MTE=1
143
- * during realize if the board provides no tag memory.
144
+ * Begin with full support for MTE. This will be downgraded to MTE=0
145
+ * during realize if the board provides no tag memory, much like
146
+ * we do for EL2 with the virtualization=on property.
147
*/
148
t = FIELD_DP64(t, ID_AA64PFR1, MTE, 2);
149
cpu->isar.id_aa64pfr1 = t;
33
--
150
--
34
2.20.1
151
2.20.1
35
152
36
153
diff view generated by jsdifflib
1
From: David Engraf <david.engraf@sysgo.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Using the whole 128 MiB flash in non-secure mode is not working because
3
While we expect KVM to support MTE at some future point,
4
virt_flash_fdt() expects the same address for secure_sysmem and sysmem.
4
it certainly won't be ready in time for qemu 5.1.
5
This is not correctly handled by caller because it forwards NULL for
6
secure_sysmem in non-secure flash mode.
7
5
8
Fixed by using sysmem when secure_sysmem is NULL.
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
7
Message-id: 20200713213341.590275-3-richard.henderson@linaro.org
10
Signed-off-by: David Engraf <david.engraf@sysgo.com>
11
Message-id: 20190712075002.14326-1-david.engraf@sysgo.com
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
10
---
15
hw/arm/virt.c | 2 +-
11
hw/arm/virt.c | 6 ++++++
16
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 6 insertions(+)
17
13
18
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
14
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
19
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/virt.c
16
--- a/hw/arm/virt.c
21
+++ b/hw/arm/virt.c
17
+++ b/hw/arm/virt.c
22
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
18
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
23
&machine->device_memory->mr);
19
exit(1);
24
}
20
}
25
21
26
- virt_flash_fdt(vms, sysmem, secure_sysmem);
22
+ if (vms->mte && kvm_enabled()) {
27
+ virt_flash_fdt(vms, sysmem, secure_sysmem ?: sysmem);
23
+ error_report("mach-virt: KVM does not support providing "
28
24
+ "MTE to the guest CPU");
29
create_gic(vms, pic);
25
+ exit(1);
30
26
+ }
27
+
28
create_fdt(vms);
29
30
possible_cpus = mc->possible_cpu_arch_ids(machine);
31
--
31
--
32
2.20.1
32
2.20.1
33
33
34
34
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
In the previous commit we fixed a crash when the guest read a
3
When MTE is enabled, tag memory must exist for all RAM.
4
register that pop from an empty FIFO.
5
By auditing the repository, we found another similar use with
6
an easy way to reproduce:
7
4
8
$ qemu-system-aarch64 -M xlnx-zcu102 -monitor stdio -S
5
It might be possible to simultaneously hot plug tag memory
9
QEMU 4.0.50 monitor - type 'help' for more information
6
alongside the corresponding normal memory, but for now just
10
(qemu) xp/b 0xfd4a0134
7
disable hotplug.
11
Aborted (core dumped)
12
8
13
(gdb) bt
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
#0 0x00007f6936dea57f in raise () at /lib64/libc.so.6
10
Message-id: 20200713213341.590275-4-richard.henderson@linaro.org
15
#1 0x00007f6936dd4895 in abort () at /lib64/libc.so.6
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
#2 0x0000561ad32975ec in xlnx_dp_aux_pop_rx_fifo (s=0x7f692babee70) at hw/display/xlnx_dp.c:431
17
#3 0x0000561ad3297dc0 in xlnx_dp_read (opaque=0x7f692babee70, offset=77, size=4) at hw/display/xlnx_dp.c:667
18
#4 0x0000561ad321b896 in memory_region_read_accessor (mr=0x7f692babf620, addr=308, value=0x7ffe05c1db88, size=4, shift=0, mask=4294967295, attrs=...) at memory.c:439
19
#5 0x0000561ad321bd70 in access_with_adjusted_size (addr=308, value=0x7ffe05c1db88, size=1, access_size_min=4, access_size_max=4, access_fn=0x561ad321b858 <memory_region_read_accessor>, mr=0x7f692babf620, attrs=...) at memory.c:569
20
#6 0x0000561ad321e9d5 in memory_region_dispatch_read1 (mr=0x7f692babf620, addr=308, pval=0x7ffe05c1db88, size=1, attrs=...) at memory.c:1420
21
#7 0x0000561ad321ea9d in memory_region_dispatch_read (mr=0x7f692babf620, addr=308, pval=0x7ffe05c1db88, size=1, attrs=...) at memory.c:1447
22
#8 0x0000561ad31bd742 in flatview_read_continue (fv=0x561ad69c04f0, addr=4249485620, attrs=..., buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", len=1, addr1=308, l=1, mr=0x7f692babf620) at exec.c:3385
23
#9 0x0000561ad31bd895 in flatview_read (fv=0x561ad69c04f0, addr=4249485620, attrs=..., buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", len=1) at exec.c:3423
24
#10 0x0000561ad31bd90b in address_space_read_full (as=0x561ad5bb3020, addr=4249485620, attrs=..., buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", len=1) at exec.c:3436
25
#11 0x0000561ad33b1c42 in address_space_read (len=1, buf=0x7ffe05c1dcf0 "\020\335\301\005\376\177", attrs=..., addr=4249485620, as=0x561ad5bb3020) at include/exec/memory.h:2131
26
#12 0x0000561ad33b1c42 in memory_dump (mon=0x561ad59c4530, count=1, format=120, wsize=1, addr=4249485620, is_physical=1) at monitor/misc.c:723
27
#13 0x0000561ad33b1fc1 in hmp_physical_memory_dump (mon=0x561ad59c4530, qdict=0x561ad6c6fd00) at monitor/misc.c:795
28
#14 0x0000561ad37b4a9f in handle_hmp_command (mon=0x561ad59c4530, cmdline=0x561ad59d0f22 "/b 0x00000000fd4a0134") at monitor/hmp.c:1082
29
30
Fix by checking the FIFO is not empty before popping from it.
31
32
The datasheet is not clear about the reset value of this register,
33
we choose to return '0'.
34
35
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
36
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
37
Message-id: 20190709113715.7761-4-philmd@redhat.com
38
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
39
---
13
---
40
hw/display/xlnx_dp.c | 15 +++++++++++----
14
hw/arm/virt.c | 5 +++++
41
1 file changed, 11 insertions(+), 4 deletions(-)
15
1 file changed, 5 insertions(+)
42
16
43
diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c
17
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
44
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/display/xlnx_dp.c
19
--- a/hw/arm/virt.c
46
+++ b/hw/display/xlnx_dp.c
20
+++ b/hw/arm/virt.c
47
@@ -XXX,XX +XXX,XX @@ static uint8_t xlnx_dp_aux_pop_rx_fifo(XlnxDPState *s)
21
@@ -XXX,XX +XXX,XX @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
48
uint8_t ret;
22
return;
49
50
if (fifo8_is_empty(&s->rx_fifo)) {
51
- DPRINTF("rx_fifo underflow..\n");
52
- abort();
53
+ qemu_log_mask(LOG_GUEST_ERROR,
54
+ "%s: Reading empty RX_FIFO\n",
55
+ __func__);
56
+ /*
57
+ * The datasheet is not clear about the reset value, it seems
58
+ * to be unspecified. We choose to return '0'.
59
+ */
60
+ ret = 0;
61
+ } else {
62
+ ret = fifo8_pop(&s->rx_fifo);
63
+ DPRINTF("pop 0x%" PRIX8 " from rx_fifo.\n", ret);
64
}
23
}
65
- ret = fifo8_pop(&s->rx_fifo);
24
66
- DPRINTF("pop 0x%" PRIX8 " from rx_fifo.\n", ret);
25
+ if (vms->mte) {
67
return ret;
26
+ error_setg(errp, "memory hotplug is not enabled: MTE is enabled");
68
}
27
+ return;
69
28
+ }
29
+
30
if (is_nvdimm && !ms->nvdimms_state->is_enabled) {
31
error_setg(errp, "nvdimm is not enabled: add 'nvdimm=on' to '-M'");
32
return;
70
--
33
--
71
2.20.1
34
2.20.1
72
35
73
36
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: David CARLIER <devnexen@gmail.com>
2
2
3
Reading the RX_DATA register when the RX_FIFO is empty triggers
3
Implement qemu_get_thread_id() for OpenBSD hosts, using
4
an abort. This can be easily reproduced:
4
getthrid().
5
5
6
$ qemu-system-arm -M emcraft-sf2 -monitor stdio -S
6
Signed-off-by: David Carlier <devnexen@gmail.com>
7
QEMU 4.0.50 monitor - type 'help' for more information
7
Reviewed-by: Brad Smith <brad@comstyle.com>
8
(qemu) x 0x40001010
8
Message-id: CA+XhMqxD6gQDBaj8tX0CMEj3si7qYKsM8u1km47e_-U7MC37Pg@mail.gmail.com
9
Aborted (core dumped)
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
10
[PMM: tidied up commit message]
11
(gdb) bt
12
#1 0x00007f035874f895 in abort () at /lib64/libc.so.6
13
#2 0x00005628686591ff in fifo8_pop (fifo=0x56286a9a4c68) at util/fifo8.c:66
14
#3 0x00005628683e0b8e in fifo32_pop (fifo=0x56286a9a4c68) at include/qemu/fifo32.h:137
15
#4 0x00005628683e0efb in spi_read (opaque=0x56286a9a4850, addr=4, size=4) at hw/ssi/mss-spi.c:168
16
#5 0x0000562867f96801 in memory_region_read_accessor (mr=0x56286a9a4b60, addr=16, value=0x7ffeecb0c5c8, size=4, shift=0, mask=4294967295, attrs=...) at memory.c:439
17
#6 0x0000562867f96cdb in access_with_adjusted_size (addr=16, value=0x7ffeecb0c5c8, size=4, access_size_min=1, access_size_max=4, access_fn=0x562867f967c3 <memory_region_read_accessor>, mr=0x56286a9a4b60, attrs=...) at memory.c:569
18
#7 0x0000562867f99940 in memory_region_dispatch_read1 (mr=0x56286a9a4b60, addr=16, pval=0x7ffeecb0c5c8, size=4, attrs=...) at memory.c:1420
19
#8 0x0000562867f99a08 in memory_region_dispatch_read (mr=0x56286a9a4b60, addr=16, pval=0x7ffeecb0c5c8, size=4, attrs=...) at memory.c:1447
20
#9 0x0000562867f38721 in flatview_read_continue (fv=0x56286aec6360, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4, addr1=16, l=4, mr=0x56286a9a4b60) at exec.c:3385
21
#10 0x0000562867f38874 in flatview_read (fv=0x56286aec6360, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4) at exec.c:3423
22
#11 0x0000562867f388ea in address_space_read_full (as=0x56286aa3e890, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4) at exec.c:3436
23
#12 0x0000562867f389c5 in address_space_rw (as=0x56286aa3e890, addr=1073745936, attrs=..., buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4, is_write=false) at exec.c:3466
24
#13 0x0000562867f3bdd7 in cpu_memory_rw_debug (cpu=0x56286aa19d00, addr=1073745936, buf=0x7ffeecb0c7c0 "\340ǰ\354\376\177", len=4, is_write=0) at exec.c:3976
25
#14 0x000056286811ed51 in memory_dump (mon=0x56286a8c32d0, count=1, format=120, wsize=4, addr=1073745936, is_physical=0) at monitor/misc.c:730
26
#15 0x000056286811eff1 in hmp_memory_dump (mon=0x56286a8c32d0, qdict=0x56286b15c400) at monitor/misc.c:785
27
#16 0x00005628684740ee in handle_hmp_command (mon=0x56286a8c32d0, cmdline=0x56286a8caeb2 "0x40001010") at monitor/hmp.c:1082
28
29
From the datasheet "Actel SmartFusion Microcontroller Subsystem
30
User's Guide" Rev.1, Table 13-3 "SPI Register Summary", this
31
register has a reset value of 0.
32
33
Check the FIFO is not empty before accessing it, else log an
34
error message.
35
36
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
37
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
38
Message-id: 20190709113715.7761-3-philmd@redhat.com
39
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
40
---
12
---
41
hw/ssi/mss-spi.c | 8 +++++++-
13
util/oslib-posix.c | 2 ++
42
1 file changed, 7 insertions(+), 1 deletion(-)
14
1 file changed, 2 insertions(+)
43
15
44
diff --git a/hw/ssi/mss-spi.c b/hw/ssi/mss-spi.c
16
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
45
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/ssi/mss-spi.c
18
--- a/util/oslib-posix.c
47
+++ b/hw/ssi/mss-spi.c
19
+++ b/util/oslib-posix.c
48
@@ -XXX,XX +XXX,XX @@ spi_read(void *opaque, hwaddr addr, unsigned int size)
20
@@ -XXX,XX +XXX,XX @@ int qemu_get_thread_id(void)
49
case R_SPI_RX:
21
return (int)tid;
50
s->regs[R_SPI_STATUS] &= ~S_RXFIFOFUL;
22
#elif defined(__NetBSD__)
51
s->regs[R_SPI_STATUS] &= ~S_RXCHOVRF;
23
return _lwp_self();
52
- ret = fifo32_pop(&s->rx_fifo);
24
+#elif defined(__OpenBSD__)
53
+ if (fifo32_is_empty(&s->rx_fifo)) {
25
+ return getthrid();
54
+ qemu_log_mask(LOG_GUEST_ERROR,
26
#else
55
+ "%s: Reading empty RX_FIFO\n",
27
return getpid();
56
+ __func__);
28
#endif
57
+ } else {
58
+ ret = fifo32_pop(&s->rx_fifo);
59
+ }
60
if (fifo32_is_empty(&s->rx_fifo)) {
61
s->regs[R_SPI_STATUS] |= S_RXFIFOEMP;
62
}
63
--
29
--
64
2.20.1
30
2.20.1
65
31
66
32
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
The doc-comments which document the qdev API are split between the
2
header file and the C source files, because as a project we haven't
3
been consistent about where we put them.
2
4
3
In the next commit we will implement the write_with_attrs()
5
Move all the doc-comments in qdev.c to the header files, so that
4
handler. To avoid using different APIs, convert the read()
6
users of the APIs don't have to look at the implementation files for
5
handler first.
7
this information.
6
8
7
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
9
In the process, unify them into our doc-comment format and expand on
8
Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com>
10
them in some cases to clarify expected use cases.
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20200711142425.16283-2-peter.maydell@linaro.org
11
---
15
---
12
hw/ssi/xilinx_spips.c | 23 +++++++++++------------
16
include/hw/qdev-core.h | 57 ++++++++++++++++++++++++++++++++++++
13
1 file changed, 11 insertions(+), 12 deletions(-)
17
include/hw/qdev-properties.h | 13 ++++++++
18
hw/core/qdev.c | 33 ---------------------
19
3 files changed, 70 insertions(+), 33 deletions(-)
14
20
15
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
21
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
16
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/ssi/xilinx_spips.c
23
--- a/include/hw/qdev-core.h
18
+++ b/hw/ssi/xilinx_spips.c
24
+++ b/include/hw/qdev-core.h
19
@@ -XXX,XX +XXX,XX @@ static void lqspi_load_cache(void *opaque, hwaddr addr)
25
@@ -XXX,XX +XXX,XX @@ compat_props_add(GPtrArray *arr,
26
27
/*** Board API. This should go away once we have a machine config file. ***/
28
29
+/**
30
+ * qdev_new: Create a device on the heap
31
+ * @name: device type to create (we assert() that this type exists)
32
+ *
33
+ * This only allocates the memory and initializes the device state
34
+ * structure, ready for the caller to set properties if they wish.
35
+ * The device still needs to be realized.
36
+ * The returned object has a reference count of 1.
37
+ */
38
DeviceState *qdev_new(const char *name);
39
+/**
40
+ * qdev_try_new: Try to create a device on the heap
41
+ * @name: device type to create
42
+ *
43
+ * This is like qdev_new(), except it returns %NULL when type @name
44
+ * does not exist, rather than asserting.
45
+ */
46
DeviceState *qdev_try_new(const char *name);
47
+/**
48
+ * qdev_realize: Realize @dev.
49
+ * @dev: device to realize
50
+ * @bus: bus to plug it into (may be NULL)
51
+ * @errp: pointer to error object
52
+ *
53
+ * "Realize" the device, i.e. perform the second phase of device
54
+ * initialization.
55
+ * @dev must not be plugged into a bus already.
56
+ * If @bus, plug @dev into @bus. This takes a reference to @dev.
57
+ * If @dev has no QOM parent, make one up, taking another reference.
58
+ * On success, return true.
59
+ * On failure, store an error through @errp and return false.
60
+ *
61
+ * If you created @dev using qdev_new(), you probably want to use
62
+ * qdev_realize_and_unref() instead.
63
+ */
64
bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp);
65
+/**
66
+ * qdev_realize_and_unref: Realize @dev and drop a reference
67
+ * @dev: device to realize
68
+ * @bus: bus to plug it into (may be NULL)
69
+ * @errp: pointer to error object
70
+ *
71
+ * Realize @dev and drop a reference.
72
+ * This is like qdev_realize(), except the caller must hold a
73
+ * (private) reference, which is dropped on return regardless of
74
+ * success or failure. Intended use::
75
+ *
76
+ * dev = qdev_new();
77
+ * [...]
78
+ * qdev_realize_and_unref(dev, bus, errp);
79
+ *
80
+ * Now @dev can go away without further ado.
81
+ *
82
+ * If you are embedding the device into some other QOM device and
83
+ * initialized it via some variant on object_initialize_child() then
84
+ * do not use this function, because that family of functions arrange
85
+ * for the only reference to the child device to be held by the parent
86
+ * via the child<> property, and so the reference-count-drop done here
87
+ * would be incorrect. For that use case you want qdev_realize().
88
+ */
89
bool qdev_realize_and_unref(DeviceState *dev, BusState *bus, Error **errp);
90
void qdev_unrealize(DeviceState *dev);
91
void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
92
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
93
index XXXXXXX..XXXXXXX 100644
94
--- a/include/hw/qdev-properties.h
95
+++ b/include/hw/qdev-properties.h
96
@@ -XXX,XX +XXX,XX @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
97
*/
98
void qdev_property_add_static(DeviceState *dev, Property *prop);
99
100
+/**
101
+ * qdev_alias_all_properties: Create aliases on source for all target properties
102
+ * @target: Device which has properties to be aliased
103
+ * @source: Object to add alias properties to
104
+ *
105
+ * Add alias properties to the @source object for all qdev properties on
106
+ * the @target DeviceState.
107
+ *
108
+ * This is useful when @target is an internal implementation object
109
+ * owned by @source, and you want to expose all the properties of that
110
+ * implementation object as properties on the @source object so that users
111
+ * of @source can set them.
112
+ */
113
void qdev_alias_all_properties(DeviceState *target, Object *source);
114
115
/**
116
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
117
index XXXXXXX..XXXXXXX 100644
118
--- a/hw/core/qdev.c
119
+++ b/hw/core/qdev.c
120
@@ -XXX,XX +XXX,XX @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus)
20
}
121
}
21
}
122
}
22
123
23
-static uint64_t
124
-/*
24
-lqspi_read(void *opaque, hwaddr addr, unsigned int size)
125
- * Create a device on the heap.
25
+static MemTxResult lqspi_read(void *opaque, hwaddr addr, uint64_t *value,
126
- * A type @name must exist.
26
+ unsigned size, MemTxAttrs attrs)
127
- * This only initializes the device state structure and allows
128
- * properties to be set. The device still needs to be realized. See
129
- * qdev-core.h.
130
- */
131
DeviceState *qdev_new(const char *name)
27
{
132
{
28
- XilinxQSPIPS *q = opaque;
133
if (!object_class_by_name(name)) {
29
- uint32_t ret;
134
@@ -XXX,XX +XXX,XX @@ DeviceState *qdev_new(const char *name)
30
+ XilinxQSPIPS *q = XILINX_QSPIPS(opaque);
135
return DEVICE(object_new(name));
31
32
if (addr >= q->lqspi_cached_addr &&
33
addr <= q->lqspi_cached_addr + LQSPI_CACHE_SIZE - 4) {
34
uint8_t *retp = &q->lqspi_buf[addr - q->lqspi_cached_addr];
35
- ret = cpu_to_le32(*(uint32_t *)retp);
36
- DB_PRINT_L(1, "addr: %08x, data: %08x\n", (unsigned)addr,
37
- (unsigned)ret);
38
- return ret;
39
- } else {
40
- lqspi_load_cache(opaque, addr);
41
- return lqspi_read(opaque, addr, size);
42
+ *value = cpu_to_le32(*(uint32_t *)retp);
43
+ DB_PRINT_L(1, "addr: %08" HWADDR_PRIx ", data: %08" PRIx64 "\n",
44
+ addr, *value);
45
+ return MEMTX_OK;
46
}
47
+
48
+ lqspi_load_cache(opaque, addr);
49
+ return lqspi_read(opaque, addr, value, size, attrs);
50
}
136
}
51
137
52
static const MemoryRegionOps lqspi_ops = {
138
-/*
53
- .read = lqspi_read,
139
- * Try to create a device on the heap.
54
+ .read_with_attrs = lqspi_read,
140
- * This is like qdev_new(), except it returns %NULL when type @name
55
.endianness = DEVICE_NATIVE_ENDIAN,
141
- * does not exist.
56
.valid = {
142
- */
57
.min_access_size = 1,
143
DeviceState *qdev_try_new(const char *name)
144
{
145
if (!module_object_class_by_name(name)) {
146
@@ -XXX,XX +XXX,XX @@ void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
147
qdev_unrealize(dev);
148
}
149
150
-/*
151
- * Realize @dev.
152
- * @dev must not be plugged into a bus.
153
- * If @bus, plug @dev into @bus. This takes a reference to @dev.
154
- * If @dev has no QOM parent, make one up, taking another reference.
155
- * On success, return true.
156
- * On failure, store an error through @errp and return false.
157
- */
158
bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
159
{
160
assert(!dev->realized && !dev->parent_bus);
161
@@ -XXX,XX +XXX,XX @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
162
return object_property_set_bool(OBJECT(dev), "realized", true, errp);
163
}
164
165
-/*
166
- * Realize @dev and drop a reference.
167
- * This is like qdev_realize(), except the caller must hold a
168
- * (private) reference, which is dropped on return regardless of
169
- * success or failure. Intended use:
170
- * dev = qdev_new();
171
- * [...]
172
- * qdev_realize_and_unref(dev, bus, errp);
173
- * Now @dev can go away without further ado.
174
- */
175
bool qdev_realize_and_unref(DeviceState *dev, BusState *bus, Error **errp)
176
{
177
bool ret;
178
@@ -XXX,XX +XXX,XX @@ static void qdev_class_add_property(DeviceClass *klass, Property *prop)
179
prop->info->description);
180
}
181
182
-/* @qdev_alias_all_properties - Add alias properties to the source object for
183
- * all qdev properties on the target DeviceState.
184
- */
185
void qdev_alias_all_properties(DeviceState *target, Object *source)
186
{
187
ObjectClass *class;
58
--
188
--
59
2.20.1
189
2.20.1
60
190
61
191
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Add a doc comment for qdev_unrealize(), to go with the new
2
documentation for the realize part of the qdev lifecycle.
2
3
3
Both lqspi_read() and lqspi_load_cache() expect a 32-bit
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
aligned address.
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20200711142425.16283-3-peter.maydell@linaro.org
7
---
8
include/hw/qdev-core.h | 19 +++++++++++++++++++
9
1 file changed, 19 insertions(+)
5
10
6
>From UG1085 datasheet [*] chapter on 'Quad-SPI Controller':
11
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
7
8
Transfer Size Limitations
9
10
Because of the 32-bit wide TX, RX, and generic FIFO, all
11
APB/AXI transfers must be an integer multiple of 4-bytes.
12
Shorter transfers are not possible.
13
14
Set MemoryRegionOps.impl values to force 32-bit accesses,
15
this way we are sure we do not access the lqspi_buf[] array
16
out of bound.
17
18
[*] https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ultrascale-trm.pdf
19
20
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
21
Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com>
22
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
---
25
hw/ssi/xilinx_spips.c | 4 ++++
26
1 file changed, 4 insertions(+)
27
28
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
29
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/ssi/xilinx_spips.c
13
--- a/include/hw/qdev-core.h
31
+++ b/hw/ssi/xilinx_spips.c
14
+++ b/include/hw/qdev-core.h
32
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps lqspi_ops = {
15
@@ -XXX,XX +XXX,XX @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp);
33
.read_with_attrs = lqspi_read,
16
* would be incorrect. For that use case you want qdev_realize().
34
.write_with_attrs = lqspi_write,
17
*/
35
.endianness = DEVICE_NATIVE_ENDIAN,
18
bool qdev_realize_and_unref(DeviceState *dev, BusState *bus, Error **errp);
36
+ .impl = {
19
+/**
37
+ .min_access_size = 4,
20
+ * qdev_unrealize: Unrealize a device
38
+ .max_access_size = 4,
21
+ * @dev: device to unrealize
39
+ },
22
+ *
40
.valid = {
23
+ * This function will "unrealize" a device, which is the first phase
41
.min_access_size = 1,
24
+ * of correctly destroying a device that has been realized. It will:
42
.max_access_size = 4
25
+ *
26
+ * - unrealize any child buses by calling qbus_unrealize()
27
+ * (this will recursively unrealize any devices on those buses)
28
+ * - call the the unrealize method of @dev
29
+ *
30
+ * The device can then be freed by causing its reference count to go
31
+ * to zero.
32
+ *
33
+ * Warning: most devices in QEMU do not expect to be unrealized. Only
34
+ * devices which are hot-unpluggable should be unrealized (as part of
35
+ * the unplugging process); all other devices are expected to last for
36
+ * the life of the simulation and should not be unrealized and freed.
37
+ */
38
void qdev_unrealize(DeviceState *dev);
39
void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
40
int required_for_version);
43
--
41
--
44
2.20.1
42
2.20.1
45
43
46
44
diff view generated by jsdifflib
1
The ARMv5 architecture didn't specify detailed per-feature ID
1
Add documentation comments for the various qdev functions
2
registers. Now that we're using the MVFR0 register fields to
2
related to creating and connecting GPIO lines.
3
gate the existence of VFP instructions, we need to set up
3
4
the correct values in the cpu->isar structure so that we still
5
provide an FPU to the guest.
6
7
This fixes a regression in the arm926 and arm1026 CPUs, which
8
are the only ones that both have VFP and are ARMv5 or earlier.
9
This regression was introduced by the VFP refactoring, and more
10
specifically by commits 1120827fa182f0e76 and 266bd25c485597c,
11
which accidentally disabled VFP short-vector support and
12
double-precision support on these CPUs.
13
14
Fixes: 1120827fa182f0e
15
Fixes: 266bd25c485597c
16
Fixes: https://bugs.launchpad.net/qemu/+bug/1836192
17
Reported-by: Christophe Lyon <christophe.lyon@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Message-id: 20200711142425.16283-4-peter.maydell@linaro.org
21
Tested-by: Christophe Lyon <christophe.lyon@linaro.org>
22
Message-id: 20190711131241.22231-1-peter.maydell@linaro.org
23
---
7
---
24
target/arm/cpu.c | 12 ++++++++++++
8
include/hw/qdev-core.h | 191 ++++++++++++++++++++++++++++++++++++++++-
25
1 file changed, 12 insertions(+)
9
1 file changed, 189 insertions(+), 2 deletions(-)
26
10
27
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
11
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
28
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/cpu.c
13
--- a/include/hw/qdev-core.h
30
+++ b/target/arm/cpu.c
14
+++ b/include/hw/qdev-core.h
31
@@ -XXX,XX +XXX,XX @@ static void arm926_initfn(Object *obj)
15
@@ -XXX,XX +XXX,XX @@ void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev,
32
* set the field to indicate Jazelle support within QEMU.
16
void qdev_machine_creation_done(void);
33
*/
17
bool qdev_machine_modified(void);
34
cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1);
18
35
+ /*
19
+/**
36
+ * Similarly, we need to set MVFR0 fields to enable double precision
20
+ * qdev_get_gpio_in: Get one of a device's anonymous input GPIO lines
37
+ * and short vector support even though ARMv5 doesn't have this register.
21
+ * @dev: Device whose GPIO we want
38
+ */
22
+ * @n: Number of the anonymous GPIO line (which must be in range)
39
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
23
+ *
40
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1);
24
+ * Returns the qemu_irq corresponding to an anonymous input GPIO line
25
+ * (which the device has set up with qdev_init_gpio_in()). The index
26
+ * @n of the GPIO line must be valid (i.e. be at least 0 and less than
27
+ * the total number of anonymous input GPIOs the device has); this
28
+ * function will assert() if passed an invalid index.
29
+ *
30
+ * This function is intended to be used by board code or SoC "container"
31
+ * device models to wire up the GPIO lines; usually the return value
32
+ * will be passed to qdev_connect_gpio_out() or a similar function to
33
+ * connect another device's output GPIO line to this input.
34
+ *
35
+ * For named input GPIO lines, use qdev_get_gpio_in_named().
36
+ */
37
qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
38
+/**
39
+ * qdev_get_gpio_in_named: Get one of a device's named input GPIO lines
40
+ * @dev: Device whose GPIO we want
41
+ * @name: Name of the input GPIO array
42
+ * @n: Number of the GPIO line in that array (which must be in range)
43
+ *
44
+ * Returns the qemu_irq corresponding to a named input GPIO line
45
+ * (which the device has set up with qdev_init_gpio_in_named()).
46
+ * The @name string must correspond to an input GPIO array which exists on
47
+ * the device, and the index @n of the GPIO line must be valid (i.e.
48
+ * be at least 0 and less than the total number of input GPIOs in that
49
+ * array); this function will assert() if passed an invalid name or index.
50
+ *
51
+ * For anonymous input GPIO lines, use qdev_get_gpio_in().
52
+ */
53
qemu_irq qdev_get_gpio_in_named(DeviceState *dev, const char *name, int n);
54
55
+/**
56
+ * qdev_connect_gpio_out: Connect one of a device's anonymous output GPIO lines
57
+ * @dev: Device whose GPIO to connect
58
+ * @n: Number of the anonymous output GPIO line (which must be in range)
59
+ * @pin: qemu_irq to connect the output line to
60
+ *
61
+ * This function connects an anonymous output GPIO line on a device
62
+ * up to an arbitrary qemu_irq, so that when the device asserts that
63
+ * output GPIO line, the qemu_irq's callback is invoked.
64
+ * The index @n of the GPIO line must be valid (i.e. be at least 0 and
65
+ * less than the total number of anonymous output GPIOs the device has
66
+ * created with qdev_init_gpio_out()); otherwise this function will assert().
67
+ *
68
+ * Outbound GPIO lines can be connected to any qemu_irq, but the common
69
+ * case is connecting them to another device's inbound GPIO line, using
70
+ * the qemu_irq returned by qdev_get_gpio_in() or qdev_get_gpio_in_named().
71
+ *
72
+ * It is not valid to try to connect one outbound GPIO to multiple
73
+ * qemu_irqs at once, or to connect multiple outbound GPIOs to the
74
+ * same qemu_irq. (Warning: there is no assertion or other guard to
75
+ * catch this error: the model will just not do the right thing.)
76
+ * Instead, for fan-out you can use the TYPE_IRQ_SPLIT device: connect
77
+ * a device's outbound GPIO to the splitter's input, and connect each
78
+ * of the splitter's outputs to a different device. For fan-in you
79
+ * can use the TYPE_OR_IRQ device, which is a model of a logical OR
80
+ * gate with multiple inputs and one output.
81
+ *
82
+ * For named output GPIO lines, use qdev_connect_gpio_out_named().
83
+ */
84
void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);
85
+/**
86
+ * qdev_connect_gpio_out: Connect one of a device's anonymous output GPIO lines
87
+ * @dev: Device whose GPIO to connect
88
+ * @name: Name of the output GPIO array
89
+ * @n: Number of the anonymous output GPIO line (which must be in range)
90
+ * @pin: qemu_irq to connect the output line to
91
+ *
92
+ * This function connects an anonymous output GPIO line on a device
93
+ * up to an arbitrary qemu_irq, so that when the device asserts that
94
+ * output GPIO line, the qemu_irq's callback is invoked.
95
+ * The @name string must correspond to an output GPIO array which exists on
96
+ * the device, and the index @n of the GPIO line must be valid (i.e.
97
+ * be at least 0 and less than the total number of input GPIOs in that
98
+ * array); this function will assert() if passed an invalid name or index.
99
+ *
100
+ * Outbound GPIO lines can be connected to any qemu_irq, but the common
101
+ * case is connecting them to another device's inbound GPIO line, using
102
+ * the qemu_irq returned by qdev_get_gpio_in() or qdev_get_gpio_in_named().
103
+ *
104
+ * It is not valid to try to connect one outbound GPIO to multiple
105
+ * qemu_irqs at once, or to connect multiple outbound GPIOs to the
106
+ * same qemu_irq; see qdev_connect_gpio_out() for details.
107
+ *
108
+ * For named output GPIO lines, use qdev_connect_gpio_out_named().
109
+ */
110
void qdev_connect_gpio_out_named(DeviceState *dev, const char *name, int n,
111
qemu_irq pin);
112
+/**
113
+ * qdev_get_gpio_out_connector: Get the qemu_irq connected to an output GPIO
114
+ * @dev: Device whose output GPIO we are interested in
115
+ * @name: Name of the output GPIO array
116
+ * @n: Number of the output GPIO line within that array
117
+ *
118
+ * Returns whatever qemu_irq is currently connected to the specified
119
+ * output GPIO line of @dev. This will be NULL if the output GPIO line
120
+ * has never been wired up to the anything. Note that the qemu_irq
121
+ * returned does not belong to @dev -- it will be the input GPIO or
122
+ * IRQ of whichever device the board code has connected up to @dev's
123
+ * output GPIO.
124
+ *
125
+ * You probably don't need to use this function -- it is used only
126
+ * by the platform-bus subsystem.
127
+ */
128
qemu_irq qdev_get_gpio_out_connector(DeviceState *dev, const char *name, int n);
129
+/**
130
+ * qdev_intercept_gpio_out: Intercept an existing GPIO connection
131
+ * @dev: Device to intercept the outbound GPIO line from
132
+ * @icpt: New qemu_irq to connect instead
133
+ * @name: Name of the output GPIO array
134
+ * @n: Number of the GPIO line in the array
135
+ *
136
+ * This function is provided only for use by the qtest testing framework
137
+ * and is not suitable for use in non-testing parts of QEMU.
138
+ *
139
+ * This function breaks an existing connection of an outbound GPIO
140
+ * line from @dev, and replaces it with the new qemu_irq @icpt, as if
141
+ * ``qdev_connect_gpio_out_named(dev, icpt, name, n)`` had been called.
142
+ * The previously connected qemu_irq is returned, so it can be restored
143
+ * by a second call to qdev_intercept_gpio_out() if desired.
144
+ */
145
qemu_irq qdev_intercept_gpio_out(DeviceState *dev, qemu_irq icpt,
146
const char *name, int n);
147
148
@@ -XXX,XX +XXX,XX @@ BusState *qdev_get_child_bus(DeviceState *dev, const char *name);
149
150
/*** Device API. ***/
151
152
-/* Register device properties. */
153
-/* GPIO inputs also double as IRQ sinks. */
154
+/**
155
+ * qdev_init_gpio_in: create an array of anonymous input GPIO lines
156
+ * @dev: Device to create input GPIOs for
157
+ * @handler: Function to call when GPIO line value is set
158
+ * @n: Number of GPIO lines to create
159
+ *
160
+ * Devices should use functions in the qdev_init_gpio_in* family in
161
+ * their instance_init or realize methods to create any input GPIO
162
+ * lines they need. There is no functional difference between
163
+ * anonymous and named GPIO lines. Stylistically, named GPIOs are
164
+ * preferable (easier to understand at callsites) unless a device
165
+ * has exactly one uniform kind of GPIO input whose purpose is obvious.
166
+ * Note that input GPIO lines can serve as 'sinks' for IRQ lines.
167
+ *
168
+ * See qdev_get_gpio_in() for how code that uses such a device can get
169
+ * hold of an input GPIO line to manipulate it.
170
+ */
171
void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
172
+/**
173
+ * qdev_init_gpio_out: create an array of anonymous output GPIO lines
174
+ * @dev: Device to create output GPIOs for
175
+ * @pins: Pointer to qemu_irq or qemu_irq array for the GPIO lines
176
+ * @n: Number of GPIO lines to create
177
+ *
178
+ * Devices should use functions in the qdev_init_gpio_out* family
179
+ * in their instance_init or realize methods to create any output
180
+ * GPIO lines they need. There is no functional difference between
181
+ * anonymous and named GPIO lines. Stylistically, named GPIOs are
182
+ * preferable (easier to understand at callsites) unless a device
183
+ * has exactly one uniform kind of GPIO output whose purpose is obvious.
184
+ *
185
+ * The @pins argument should be a pointer to either a "qemu_irq"
186
+ * (if @n == 1) or a "qemu_irq []" array (if @n > 1) in the device's
187
+ * state structure. The device implementation can then raise and
188
+ * lower the GPIO line by calling qemu_set_irq(). (If anything is
189
+ * connected to the other end of the GPIO this will cause the handler
190
+ * function for that input GPIO to be called.)
191
+ *
192
+ * See qdev_connect_gpio_out() for how code that uses such a device
193
+ * can connect to one of its output GPIO lines.
194
+ */
195
void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
196
+/**
197
+ * qdev_init_gpio_out: create an array of named output GPIO lines
198
+ * @dev: Device to create output GPIOs for
199
+ * @pins: Pointer to qemu_irq or qemu_irq array for the GPIO lines
200
+ * @name: Name to give this array of GPIO lines
201
+ * @n: Number of GPIO lines to create
202
+ *
203
+ * Like qdev_init_gpio_out(), but creates an array of GPIO output lines
204
+ * with a name. Code using the device can then connect these GPIO lines
205
+ * using qdev_connect_gpio_out_named().
206
+ */
207
void qdev_init_gpio_out_named(DeviceState *dev, qemu_irq *pins,
208
const char *name, int n);
209
/**
210
@@ -XXX,XX +XXX,XX @@ static inline void qdev_init_gpio_in_named(DeviceState *dev,
211
qdev_init_gpio_in_named_with_opaque(dev, handler, dev, name, n);
41
}
212
}
42
213
43
static void arm946_initfn(Object *obj)
214
+/**
44
@@ -XXX,XX +XXX,XX @@ static void arm1026_initfn(Object *obj)
215
+ * qdev_pass_gpios: create GPIO lines on container which pass through to device
45
* set the field to indicate Jazelle support within QEMU.
216
+ * @dev: Device which has GPIO lines
46
*/
217
+ * @container: Container device which needs to expose them
47
cpu->isar.id_isar1 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1);
218
+ * @name: Name of GPIO array to pass through (NULL for the anonymous GPIO array)
48
+ /*
219
+ *
49
+ * Similarly, we need to set MVFR0 fields to enable double precision
220
+ * In QEMU, complicated devices like SoCs are often modelled with a
50
+ * and short vector support even though ARMv5 doesn't have this register.
221
+ * "container" QOM device which itself contains other QOM devices and
51
+ */
222
+ * which wires them up appropriately. This function allows the container
52
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1);
223
+ * to create GPIO arrays on itself which simply pass through to a GPIO
53
+ cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1);
224
+ * array of one of its internal devices.
54
225
+ *
55
{
226
+ * If @dev has both input and output GPIOs named @name then both will
56
/* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */
227
+ * be passed through. It is not possible to pass a subset of the array
228
+ * with this function.
229
+ *
230
+ * To users of the container device, the GPIO array created on @container
231
+ * behaves exactly like any other.
232
+ */
233
void qdev_pass_gpios(DeviceState *dev, DeviceState *container,
234
const char *name);
235
57
--
236
--
58
2.20.1
237
2.20.1
59
238
60
239
diff view generated by jsdifflib
New patch
1
In armsse_realize() we have a loop over [0, info->num_cpus), which
2
indexes into various fixed-size arrays in the ARMSSE struct. This
3
confuses Coverity, which warns that we might overrun those arrays
4
(CID 1430326, 1430337, 1430371, 1430414, 1430430). This can't
5
actually happen, because the info struct is always one of the entries
6
in the armsse_variants[] array and num_cpus is either 1 or 2; we also
7
already assert in armsse_init() that num_cpus is not too large.
8
However, adding an assert to armsse_realize() like the one in
9
armsse_init() should help Coverity figure out that these code paths
10
aren't possible.
1
11
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Message-id: 20200713143716.9881-1-peter.maydell@linaro.org
15
---
16
hw/arm/armsse.c | 2 ++
17
1 file changed, 2 insertions(+)
18
19
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/arm/armsse.c
22
+++ b/hw/arm/armsse.c
23
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
24
return;
25
}
26
27
+ assert(info->num_cpus <= SSE_MAX_CPUS);
28
+
29
/* max SRAM_ADDR_WIDTH: 24 - log2(SRAM_NUM_BANK) */
30
assert(is_power_of_2(info->sram_banks));
31
addr_width_max = 24 - ctz32(info->sram_banks);
32
--
33
2.20.1
34
35
diff view generated by jsdifflib
New patch
1
Add skeletal documentation of the canon-a1100 board.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Message-id: 20200713175746.5936-2-peter.maydell@linaro.org
7
---
8
docs/system/arm/digic.rst | 11 +++++++++++
9
docs/system/target-arm.rst | 1 +
10
MAINTAINERS | 1 +
11
3 files changed, 13 insertions(+)
12
create mode 100644 docs/system/arm/digic.rst
13
14
diff --git a/docs/system/arm/digic.rst b/docs/system/arm/digic.rst
15
new file mode 100644
16
index XXXXXXX..XXXXXXX
17
--- /dev/null
18
+++ b/docs/system/arm/digic.rst
19
@@ -XXX,XX +XXX,XX @@
20
+Canon A1100 (``canon-a1100``)
21
+=============================
22
+
23
+This machine is a model of the Canon PowerShot A1100 camera, which
24
+uses the DIGIC SoC. This model is based on reverse engineering efforts
25
+by the contributors to the `CHDK <http://chdk.wikia.com/>`_ and
26
+`Magic Lantern <http://www.magiclantern.fm/>`_ projects.
27
+
28
+The emulation is incomplete. In particular it can't be used
29
+to run the original camera firmware, but it can successfully run
30
+an experimental version of the `barebox bootloader <http://www.barebox.org/>`_.
31
diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst
32
index XXXXXXX..XXXXXXX 100644
33
--- a/docs/system/target-arm.rst
34
+++ b/docs/system/target-arm.rst
35
@@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running
36
arm/versatile
37
arm/vexpress
38
arm/aspeed
39
+ arm/digic
40
arm/musicpal
41
arm/nseries
42
arm/orangepi
43
diff --git a/MAINTAINERS b/MAINTAINERS
44
index XXXXXXX..XXXXXXX 100644
45
--- a/MAINTAINERS
46
+++ b/MAINTAINERS
47
@@ -XXX,XX +XXX,XX @@ F: include/hw/arm/digic.h
48
F: hw/*/digic*
49
F: include/hw/*/digic*
50
F: tests/acceptance/machine_arm_canona1100.py
51
+F: docs/system/arm/digic.rst
52
53
Goldfish RTC
54
M: Anup Patel <anup.patel@wdc.com>
55
--
56
2.20.1
57
58
diff view generated by jsdifflib
1
In the M-profile architecture, when we do a vector table fetch and it
1
Add skeletal documentation of the collie board.
2
fails, we need to report a HardFault. Whether this is a Secure HF or
3
a NonSecure HF depends on several things. If AIRCR.BFHFNMINS is 0
4
then HF is always Secure, because there is no NonSecure HardFault.
5
Otherwise, the answer depends on whether the 'underlying exception'
6
(MemManage, BusFault, SecureFault) targets Secure or NonSecure. (In
7
the pseudocode, this is handled in the Vector() function: the final
8
exc.isSecure is calculated by looking at the exc.isSecure from the
9
exception returned from the memory access, not the isSecure input
10
argument.)
11
12
We weren't doing this correctly, because we were looking at
13
the target security domain of the exception we were trying to
14
load the vector table entry for. This produces errors of two kinds:
15
* a load from the NS vector table which hits the "NS access
16
to S memory" SecureFault should end up as a Secure HardFault,
17
but we were raising an NS HardFault
18
* a load from the S vector table which causes a BusFault
19
should raise an NS HardFault if BFHFNMINS == 1 (because
20
in that case all BusFaults are NonSecure), but we were raising
21
a Secure HardFault
22
23
Correct the logic.
24
25
We also fix a comment error where we claimed that we might
26
be escalating MemManage to HardFault, and forgot about SecureFault.
27
(Vector loads can never hit MPU access faults, because they're
28
always aligned and always use the default address map.)
29
2
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
31
Message-id: 20190705094823.28905-1-peter.maydell@linaro.org
4
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
5
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Message-id: 20200713175746.5936-3-peter.maydell@linaro.org
32
---
7
---
33
target/arm/m_helper.c | 21 +++++++++++++++++----
8
docs/system/arm/collie.rst | 16 ++++++++++++++++
34
1 file changed, 17 insertions(+), 4 deletions(-)
9
docs/system/target-arm.rst | 1 +
10
MAINTAINERS | 1 +
11
3 files changed, 18 insertions(+)
12
create mode 100644 docs/system/arm/collie.rst
35
13
36
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
14
diff --git a/docs/system/arm/collie.rst b/docs/system/arm/collie.rst
15
new file mode 100644
16
index XXXXXXX..XXXXXXX
17
--- /dev/null
18
+++ b/docs/system/arm/collie.rst
19
@@ -XXX,XX +XXX,XX @@
20
+Sharp Zaurus SL-5500 (``collie``)
21
+=================================
22
+
23
+This machine is a model of the Sharp Zaurus SL-5500, which was
24
+a 1990s PDA based on the StrongARM SA1110.
25
+
26
+Implemented devices:
27
+
28
+ * NOR flash
29
+ * Interrupt controller
30
+ * Timer
31
+ * RTC
32
+ * GPIO
33
+ * Peripheral Pin Controller (PPC)
34
+ * UARTs
35
+ * Synchronous Serial Ports (SSP)
36
diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst
37
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/m_helper.c
38
--- a/docs/system/target-arm.rst
39
+++ b/target/arm/m_helper.c
39
+++ b/docs/system/target-arm.rst
40
@@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure,
40
@@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running
41
if (sattrs.ns) {
41
arm/orangepi
42
attrs.secure = false;
42
arm/palm
43
} else if (!targets_secure) {
43
arm/xscale
44
- /* NS access to S memory */
44
+ arm/collie
45
+ /*
45
arm/sx1
46
+ * NS access to S memory: the underlying exception which we escalate
46
arm/stellaris
47
+ * to HardFault is SecureFault, which always targets Secure.
47
48
+ */
48
diff --git a/MAINTAINERS b/MAINTAINERS
49
+ exc_secure = true;
49
index XXXXXXX..XXXXXXX 100644
50
goto load_fail;
50
--- a/MAINTAINERS
51
}
51
+++ b/MAINTAINERS
52
}
52
@@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org
53
@@ -XXX,XX +XXX,XX @@ static bool arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure,
53
S: Odd Fixes
54
vector_entry = address_space_ldl(arm_addressspace(cs, attrs), addr,
54
F: hw/arm/collie.c
55
attrs, &result);
55
F: hw/arm/strongarm*
56
if (result != MEMTX_OK) {
56
+F: docs/system/arm/collie.rst
57
+ /*
57
58
+ * Underlying exception is BusFault: its target security state
58
Stellaris
59
+ * depends on BFHFNMINS.
59
M: Peter Maydell <peter.maydell@linaro.org>
60
+ */
61
+ exc_secure = !(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK);
62
goto load_fail;
63
}
64
*pvec = vector_entry;
65
@@ -XXX,XX +XXX,XX @@ load_fail:
66
/*
67
* All vector table fetch fails are reported as HardFault, with
68
* HFSR.VECTTBL and .FORCED set. (FORCED is set because
69
- * technically the underlying exception is a MemManage or BusFault
70
+ * technically the underlying exception is a SecureFault or BusFault
71
* that is escalated to HardFault.) This is a terminal exception,
72
* so we will either take the HardFault immediately or else enter
73
* lockup (the latter case is handled in armv7m_nvic_set_pending_derived()).
74
+ * The HardFault is Secure if BFHFNMINS is 0 (meaning that all HFs are
75
+ * secure); otherwise it targets the same security state as the
76
+ * underlying exception.
77
*/
78
- exc_secure = targets_secure ||
79
- !(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK);
80
+ if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
81
+ exc_secure = true;
82
+ }
83
env->v7m.hfsr |= R_V7M_HFSR_VECTTBL_MASK | R_V7M_HFSR_FORCED_MASK;
84
armv7m_nvic_set_pending_derived(env->nvic, ARMV7M_EXCP_HARD, exc_secure);
85
return false;
86
--
60
--
87
2.20.1
61
2.20.1
88
62
89
63
diff view generated by jsdifflib
1
The PL031 RTC tracks the difference between the guest RTC
1
Add skeletal documentation of the gumstix boards
2
and the host RTC using a tick_offset field. For migration,
2
('connex' and 'verdex').
3
however, we currently always migrate the offset between
4
the guest and the vm_clock, even if the RTC clock is not
5
the same as the vm_clock; this was an attempt to retain
6
migration backwards compatibility.
7
3
8
Unfortunately this results in the RTC behaving oddly across
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
a VM state save and restore -- since the VM clock stands still
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
across save-then-restore, regardless of how much real world
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
11
time has elapsed, the guest RTC ends up out of sync with the
7
Message-id: 20200713175746.5936-4-peter.maydell@linaro.org
12
host RTC in the restored VM.
8
---
9
docs/system/arm/gumstix.rst | 21 +++++++++++++++++++++
10
docs/system/target-arm.rst | 1 +
11
MAINTAINERS | 1 +
12
3 files changed, 23 insertions(+)
13
create mode 100644 docs/system/arm/gumstix.rst
13
14
14
Fix this by migrating the raw tick_offset. To retain migration
15
diff --git a/docs/system/arm/gumstix.rst b/docs/system/arm/gumstix.rst
15
compatibility as far as possible, we have a new property
16
new file mode 100644
16
migrate-tick-offset; by default this is 'true' and we will
17
index XXXXXXX..XXXXXXX
17
migrate the true tick offset in a new subsection; if the
18
--- /dev/null
18
incoming data has no subsection we fall back to the old
19
+++ b/docs/system/arm/gumstix.rst
19
vm_clock-based offset information, so old->new migration
20
@@ -XXX,XX +XXX,XX @@
20
compatibility is preserved. For complete new->old migration
21
+Gumstix Connex and Verdex (``connex``, ``verdex``)
21
compatibility, the property is set to 'false' for 4.0 and
22
+==================================================
22
earlier machine types (this will only affect 'virt-4.0'
23
+
23
and below, as none of the other pl031-using machines are
24
+These machines model the Gumstix Connex and Verdex boards.
24
versioned).
25
+The Connex has a PXA255 CPU and the Verdex has a PXA270.
25
26
+
26
Reported-by: Russell King <rmk@armlinux.org.uk>
27
+Implemented devices:
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
+
28
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
29
+ * NOR flash
29
Message-id: 20190709143912.28905-1-peter.maydell@linaro.org
30
+ * SMC91C111 ethernet
30
---
31
+ * Interrupt controller
31
include/hw/timer/pl031.h | 2 +
32
+ * DMA
32
hw/core/machine.c | 1 +
33
+ * Timer
33
hw/timer/pl031.c | 92 ++++++++++++++++++++++++++++++++++++++--
34
+ * GPIO
34
3 files changed, 91 insertions(+), 4 deletions(-)
35
+ * MMC/SD card
35
36
+ * Fast infra-red communications port (FIR)
36
diff --git a/include/hw/timer/pl031.h b/include/hw/timer/pl031.h
37
+ * LCD controller
38
+ * Synchronous serial ports (SPI)
39
+ * PCMCIA interface
40
+ * I2C
41
+ * I2S
42
diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst
37
index XXXXXXX..XXXXXXX 100644
43
index XXXXXXX..XXXXXXX 100644
38
--- a/include/hw/timer/pl031.h
44
--- a/docs/system/target-arm.rst
39
+++ b/include/hw/timer/pl031.h
45
+++ b/docs/system/target-arm.rst
40
@@ -XXX,XX +XXX,XX @@ typedef struct PL031State {
46
@@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running
41
*/
47
arm/aspeed
42
uint32_t tick_offset_vmstate;
48
arm/digic
43
uint32_t tick_offset;
49
arm/musicpal
44
+ bool tick_offset_migrated;
50
+ arm/gumstix
45
+ bool migrate_tick_offset;
51
arm/nseries
46
52
arm/orangepi
47
uint32_t mr;
53
arm/palm
48
uint32_t lr;
54
diff --git a/MAINTAINERS b/MAINTAINERS
49
diff --git a/hw/core/machine.c b/hw/core/machine.c
50
index XXXXXXX..XXXXXXX 100644
55
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/core/machine.c
56
--- a/MAINTAINERS
52
+++ b/hw/core/machine.c
57
+++ b/MAINTAINERS
53
@@ -XXX,XX +XXX,XX @@ GlobalProperty hw_compat_4_0[] = {
58
@@ -XXX,XX +XXX,XX @@ R: Philippe Mathieu-Daudé <f4bug@amsat.org>
54
{ "virtio-gpu-pci", "edid", "false" },
59
L: qemu-arm@nongnu.org
55
{ "virtio-device", "use-started", "false" },
60
S: Odd Fixes
56
{ "virtio-balloon-device", "qemu-4-0-config-size", "true" },
61
F: hw/arm/gumstix.c
57
+ { "pl031", "migrate-tick-offset", "false" },
62
+F: docs/system/arm/gumstix.rst
58
};
63
59
const size_t hw_compat_4_0_len = G_N_ELEMENTS(hw_compat_4_0);
64
i.MX25 PDK
60
65
M: Peter Maydell <peter.maydell@linaro.org>
61
diff --git a/hw/timer/pl031.c b/hw/timer/pl031.c
62
index XXXXXXX..XXXXXXX 100644
63
--- a/hw/timer/pl031.c
64
+++ b/hw/timer/pl031.c
65
@@ -XXX,XX +XXX,XX @@ static int pl031_pre_save(void *opaque)
66
{
67
PL031State *s = opaque;
68
69
- /* tick_offset is base_time - rtc_clock base time. Instead, we want to
70
- * store the base time relative to the QEMU_CLOCK_VIRTUAL for backwards-compatibility. */
71
+ /*
72
+ * The PL031 device model code uses the tick_offset field, which is
73
+ * the offset between what the guest RTC should read and what the
74
+ * QEMU rtc_clock reads:
75
+ * guest_rtc = rtc_clock + tick_offset
76
+ * and so
77
+ * tick_offset = guest_rtc - rtc_clock
78
+ *
79
+ * We want to migrate this offset, which sounds straightforward.
80
+ * Unfortunately older versions of QEMU migrated a conversion of this
81
+ * offset into an offset from the vm_clock. (This was in turn an
82
+ * attempt to be compatible with even older QEMU versions, but it
83
+ * has incorrect behaviour if the rtc_clock is not the same as the
84
+ * vm_clock.) So we put the actual tick_offset into a migration
85
+ * subsection, and the backwards-compatible time-relative-to-vm_clock
86
+ * in the main migration state.
87
+ *
88
+ * Calculate base time relative to QEMU_CLOCK_VIRTUAL:
89
+ */
90
int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
91
s->tick_offset_vmstate = s->tick_offset + delta / NANOSECONDS_PER_SECOND;
92
93
return 0;
94
}
95
96
+static int pl031_pre_load(void *opaque)
97
+{
98
+ PL031State *s = opaque;
99
+
100
+ s->tick_offset_migrated = false;
101
+ return 0;
102
+}
103
+
104
static int pl031_post_load(void *opaque, int version_id)
105
{
106
PL031State *s = opaque;
107
108
- int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
109
- s->tick_offset = s->tick_offset_vmstate - delta / NANOSECONDS_PER_SECOND;
110
+ /*
111
+ * If we got the tick_offset subsection, then we can just use
112
+ * the value in that. Otherwise the source is an older QEMU and
113
+ * has given us the offset from the vm_clock; convert it back to
114
+ * an offset from the rtc_clock. This will cause time to incorrectly
115
+ * go backwards compared to the host RTC, but this is unavoidable.
116
+ */
117
+
118
+ if (!s->tick_offset_migrated) {
119
+ int64_t delta = qemu_clock_get_ns(rtc_clock) -
120
+ qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
121
+ s->tick_offset = s->tick_offset_vmstate -
122
+ delta / NANOSECONDS_PER_SECOND;
123
+ }
124
pl031_set_alarm(s);
125
return 0;
126
}
127
128
+static int pl031_tick_offset_post_load(void *opaque, int version_id)
129
+{
130
+ PL031State *s = opaque;
131
+
132
+ s->tick_offset_migrated = true;
133
+ return 0;
134
+}
135
+
136
+static bool pl031_tick_offset_needed(void *opaque)
137
+{
138
+ PL031State *s = opaque;
139
+
140
+ return s->migrate_tick_offset;
141
+}
142
+
143
+static const VMStateDescription vmstate_pl031_tick_offset = {
144
+ .name = "pl031/tick-offset",
145
+ .version_id = 1,
146
+ .minimum_version_id = 1,
147
+ .needed = pl031_tick_offset_needed,
148
+ .post_load = pl031_tick_offset_post_load,
149
+ .fields = (VMStateField[]) {
150
+ VMSTATE_UINT32(tick_offset, PL031State),
151
+ VMSTATE_END_OF_LIST()
152
+ }
153
+};
154
+
155
static const VMStateDescription vmstate_pl031 = {
156
.name = "pl031",
157
.version_id = 1,
158
.minimum_version_id = 1,
159
.pre_save = pl031_pre_save,
160
+ .pre_load = pl031_pre_load,
161
.post_load = pl031_post_load,
162
.fields = (VMStateField[]) {
163
VMSTATE_UINT32(tick_offset_vmstate, PL031State),
164
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pl031 = {
165
VMSTATE_UINT32(im, PL031State),
166
VMSTATE_UINT32(is, PL031State),
167
VMSTATE_END_OF_LIST()
168
+ },
169
+ .subsections = (const VMStateDescription*[]) {
170
+ &vmstate_pl031_tick_offset,
171
+ NULL
172
}
173
};
174
175
+static Property pl031_properties[] = {
176
+ /*
177
+ * True to correctly migrate the tick offset of the RTC. False to
178
+ * obtain backward migration compatibility with older QEMU versions,
179
+ * at the expense of the guest RTC going backwards compared with the
180
+ * host RTC when the VM is saved/restored if using -rtc host.
181
+ * (Even if set to 'true' older QEMU can migrate forward to newer QEMU;
182
+ * 'false' also permits newer QEMU to migrate to older QEMU.)
183
+ */
184
+ DEFINE_PROP_BOOL("migrate-tick-offset",
185
+ PL031State, migrate_tick_offset, true),
186
+ DEFINE_PROP_END_OF_LIST()
187
+};
188
+
189
static void pl031_class_init(ObjectClass *klass, void *data)
190
{
191
DeviceClass *dc = DEVICE_CLASS(klass);
192
193
dc->vmsd = &vmstate_pl031;
194
+ dc->props = pl031_properties;
195
}
196
197
static const TypeInfo pl031_info = {
198
--
66
--
199
2.20.1
67
2.20.1
200
68
201
69
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
Document the arm 'virt' board, which has been undocumented
2
2
for far too long given that it is the main recommended board
3
Lei Sun found while auditing the code that a CPU write would
3
type for arm guests.
4
trigger a NULL pointer dereference.
4
5
6
>From UG1085 datasheet [*] AXI writes in this region are ignored
7
and generates an AXI Slave Error (SLVERR).
8
9
Fix by implementing the write_with_attrs() handler.
10
Return MEMTX_ERROR when the region is accessed (this error maps
11
to an AXI slave error).
12
13
[*] https://www.xilinx.com/support/documentation/user_guides/ug1085-zynq-ultrascale-trm.pdf
14
15
Reported-by: Lei Sun <slei.casper@gmail.com>
16
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
17
Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com>
18
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Message-id: 20200713175746.5936-5-peter.maydell@linaro.org
20
---
8
---
21
hw/ssi/xilinx_spips.c | 16 ++++++++++++++++
9
docs/system/arm/virt.rst | 161 +++++++++++++++++++++++++++++++++++++
22
1 file changed, 16 insertions(+)
10
docs/system/target-arm.rst | 1 +
23
11
MAINTAINERS | 1 +
24
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
12
3 files changed, 163 insertions(+)
13
create mode 100644 docs/system/arm/virt.rst
14
15
diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst
16
new file mode 100644
17
index XXXXXXX..XXXXXXX
18
--- /dev/null
19
+++ b/docs/system/arm/virt.rst
20
@@ -XXX,XX +XXX,XX @@
21
+'virt' generic virtual platform (``virt``)
22
+==========================================
23
+
24
+The `virt` board is a platform which does not correspond to any
25
+real hardware; it is designed for use in virtual machines.
26
+It is the recommended board type if you simply want to run
27
+a guest such as Linux and do not care about reproducing the
28
+idiosyncrasies and limitations of a particular bit of real-world
29
+hardware.
30
+
31
+This is a "versioned" board model, so as well as the ``virt`` machine
32
+type itself (which may have improvements, bugfixes and other minor
33
+changes between QEMU versions) a version is provided that guarantees
34
+to have the same behaviour as that of previous QEMU releases, so
35
+that VM migration will work between QEMU versions. For instance the
36
+``virt-5.0`` machine type will behave like the ``virt`` machine from
37
+the QEMU 5.0 release, and migration should work between ``virt-5.0``
38
+of the 5.0 release and ``virt-5.0`` of the 5.1 release. Migration
39
+is not guaranteed to work between different QEMU releases for
40
+the non-versioned ``virt`` machine type.
41
+
42
+Supported devices
43
+"""""""""""""""""
44
+
45
+The virt board supports:
46
+
47
+- PCI/PCIe devices
48
+- Flash memory
49
+- One PL011 UART
50
+- An RTC
51
+- The fw_cfg device that allows a guest to obtain data from QEMU
52
+- A PL061 GPIO controller
53
+- An optional SMMUv3 IOMMU
54
+- hotpluggable DIMMs
55
+- hotpluggable NVDIMMs
56
+- An MSI controller (GICv2M or ITS). GICv2M is selected by default along
57
+ with GICv2. ITS is selected by default with GICv3 (>= virt-2.7). Note
58
+ that ITS is not modeled in TCG mode.
59
+- 32 virtio-mmio transport devices
60
+- running guests using the KVM accelerator on aarch64 hardware
61
+- large amounts of RAM (at least 255GB, and more if using highmem)
62
+- many CPUs (up to 512 if using a GICv3 and highmem)
63
+- Secure-World-only devices if the CPU has TrustZone:
64
+
65
+ - A second PL011 UART
66
+ - A secure flash memory
67
+ - 16MB of secure RAM
68
+
69
+Supported guest CPU types:
70
+
71
+- ``cortex-a7`` (32-bit)
72
+- ``cortex-a15`` (32-bit; the default)
73
+- ``cortex-a53`` (64-bit)
74
+- ``cortex-a57`` (64-bit)
75
+- ``cortex-a72`` (64-bit)
76
+- ``host`` (with KVM only)
77
+- ``max`` (same as ``host`` for KVM; best possible emulation with TCG)
78
+
79
+Note that the default is ``cortex-a15``, so for an AArch64 guest you must
80
+specify a CPU type.
81
+
82
+Graphics output is available, but unlike the x86 PC machine types
83
+there is no default display device enabled: you should select one from
84
+the Display devices section of "-device help". The recommended option
85
+is ``virtio-gpu-pci``; this is the only one which will work correctly
86
+with KVM. You may also need to ensure your guest kernel is configured
87
+with support for this; see below.
88
+
89
+Machine-specific options
90
+""""""""""""""""""""""""
91
+
92
+The following machine-specific options are supported:
93
+
94
+secure
95
+ Set ``on``/``off`` to enable/disable emulating a guest CPU which implements the
96
+ Arm Security Extensions (TrustZone). The default is ``off``.
97
+
98
+virtualization
99
+ Set ``on``/``off`` to enable/disable emulating a guest CPU which implements the
100
+ Arm Virtualization Extensions. The default is ``off``.
101
+
102
+highmem
103
+ Set ``on``/``off`` to enable/disable placing devices and RAM in physical
104
+ address space above 32 bits. The default is ``on`` for machine types
105
+ later than ``virt-2.12``.
106
+
107
+gic-version
108
+ Specify the version of the Generic Interrupt Controller (GIC) to provide.
109
+ Valid values are:
110
+
111
+ ``2``
112
+ GICv2
113
+ ``3``
114
+ GICv3
115
+ ``host``
116
+ Use the same GIC version the host provides, when using KVM
117
+ ``max``
118
+ Use the best GIC version possible (same as host when using KVM;
119
+ currently same as ``3``` for TCG, but this may change in future)
120
+
121
+its
122
+ Set ``on``/``off`` to enable/disable ITS instantiation. The default is ``on``
123
+ for machine types later than ``virt-2.7``.
124
+
125
+iommu
126
+ Set the IOMMU type to create for the guest. Valid values are:
127
+
128
+ ``none``
129
+ Don't create an IOMMU (the default)
130
+ ``smmuv3``
131
+ Create an SMMUv3
132
+
133
+ras
134
+ Set ``on``/``off`` to enable/disable reporting host memory errors to a guest
135
+ using ACPI and guest external abort exceptions. The default is off.
136
+
137
+Linux guest kernel configuration
138
+""""""""""""""""""""""""""""""""
139
+
140
+The 'defconfig' for Linux arm and arm64 kernels should include the
141
+right device drivers for virtio and the PCI controller; however some older
142
+kernel versions, especially for 32-bit Arm, did not have everything
143
+enabled by default. If you're not seeing PCI devices that you expect,
144
+then check that your guest config has::
145
+
146
+ CONFIG_PCI=y
147
+ CONFIG_VIRTIO_PCI=y
148
+ CONFIG_PCI_HOST_GENERIC=y
149
+
150
+If you want to use the ``virtio-gpu-pci`` graphics device you will also
151
+need::
152
+
153
+ CONFIG_DRM=y
154
+ CONFIG_DRM_VIRTIO_GPU=y
155
+
156
+Hardware configuration information for bare-metal programming
157
+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
158
+
159
+The ``virt`` board automatically generates a device tree blob ("dtb")
160
+which it passes to the guest. This provides information about the
161
+addresses, interrupt lines and other configuration of the various devices
162
+in the system. Guest code can rely on and hard-code the following
163
+addresses:
164
+
165
+- Flash memory starts at address 0x0000_0000
166
+
167
+- RAM starts at 0x4000_0000
168
+
169
+All other information about device locations may change between
170
+QEMU versions, so guest code must look in the DTB.
171
+
172
+QEMU supports two types of guest image boot for ``virt``, and
173
+the way for the guest code to locate the dtb binary differs:
174
+
175
+- For guests using the Linux kernel boot protocol (this means any
176
+ non-ELF file passed to the QEMU ``-kernel`` option) the address
177
+ of the DTB is passed in a register (``r2`` for 32-bit guests,
178
+ or ``x0`` for 64-bit guests)
179
+
180
+- For guests booting as "bare-metal" (any other kind of boot),
181
+ the DTB is at the start of RAM (0x4000_0000)
182
diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst
25
index XXXXXXX..XXXXXXX 100644
183
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/ssi/xilinx_spips.c
184
--- a/docs/system/target-arm.rst
27
+++ b/hw/ssi/xilinx_spips.c
185
+++ b/docs/system/target-arm.rst
28
@@ -XXX,XX +XXX,XX @@ static MemTxResult lqspi_read(void *opaque, hwaddr addr, uint64_t *value,
186
@@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running
29
return lqspi_read(opaque, addr, value, size, attrs);
187
arm/collie
30
}
188
arm/sx1
31
189
arm/stellaris
32
+static MemTxResult lqspi_write(void *opaque, hwaddr offset, uint64_t value,
190
+ arm/virt
33
+ unsigned size, MemTxAttrs attrs)
191
34
+{
192
Arm CPU features
35
+ /*
193
================
36
+ * From UG1085, Chapter 24 (Quad-SPI controllers):
194
diff --git a/MAINTAINERS b/MAINTAINERS
37
+ * - Writes are ignored
195
index XXXXXXX..XXXXXXX 100644
38
+ * - AXI writes generate an external AXI slave error (SLVERR)
196
--- a/MAINTAINERS
39
+ */
197
+++ b/MAINTAINERS
40
+ qemu_log_mask(LOG_GUEST_ERROR, "%s Unexpected %u-bit access to 0x%" PRIx64
198
@@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org
41
+ " (value: 0x%" PRIx64 "\n",
199
S: Maintained
42
+ __func__, size << 3, offset, value);
200
F: hw/arm/virt*
43
+
201
F: include/hw/arm/virt.h
44
+ return MEMTX_ERROR;
202
+F: docs/system/arm/virt.rst
45
+}
203
46
+
204
Xilinx Zynq
47
static const MemoryRegionOps lqspi_ops = {
205
M: Edgar E. Iglesias <edgar.iglesias@gmail.com>
48
.read_with_attrs = lqspi_read,
49
+ .write_with_attrs = lqspi_write,
50
.endianness = DEVICE_NATIVE_ENDIAN,
51
.valid = {
52
.min_access_size = 1,
53
--
206
--
54
2.20.1
207
2.20.1
55
208
56
209
diff view generated by jsdifflib