1
Small pullreq with some bug fixes to go into rc1.
1
Changes v1->v2 (fixing CI failures in v1, added a couple of
2
extra patches in an attempt to avoid having to do a last
3
minute arm pullreq next week):
4
* new patch to hopefully fix the build issue with the SVE/SME sysregs test
5
* dropped the IC IVAU test case patch
6
* new patch: fix over-length shift
7
* new patches: define neoverse-v1
2
8
9
thanks
3
-- PMM
10
-- PMM
4
11
5
The following changes since commit 5ca634afcf83215a9a54ca6e66032325b5ffb5f6:
12
The following changes since commit 2a6ae69154542caa91dd17c40fd3f5ffbec300de:
6
13
7
Merge remote-tracking branch 'remotes/philmd/tags/sdmmc-20210322' into staging (2021-03-22 18:50:25 +0000)
14
Merge tag 'pull-maintainer-ominbus-030723-1' of https://gitlab.com/stsquad/qemu into staging (2023-07-04 08:36:44 +0200)
8
15
9
are available in the Git repository at:
16
are available in the Git repository at:
10
17
11
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210323
18
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230706
12
19
13
for you to fetch changes up to dad90de78e9e9d47cefcbcd30115706b98e6ec87:
20
for you to fetch changes up to c41077235168140cdd4a34fce9bd95c3d30efe9c:
14
21
15
target/arm: Set ARMMMUFaultInfo.level in user-only arm_cpu_tlb_fill (2021-03-23 14:07:55 +0000)
22
target/arm: Avoid over-length shift in arm_cpu_sve_finalize() error case (2023-07-06 13:36:51 +0100)
16
23
17
----------------------------------------------------------------
24
----------------------------------------------------------------
18
target-arm queue:
25
target-arm queue:
19
* hw/arm/virt: Disable pl011 clock migration if needed
26
* Add raw_writes ops for register whose write induce TLB maintenance
20
* target/arm: Make M-profile VTOR loads on reset handle memory aliasing
27
* hw/arm/sbsa-ref: use XHCI to replace EHCI
21
* target/arm: Set ARMMMUFaultInfo.level in user-only arm_cpu_tlb_fill
28
* Avoid splitting Zregs across lines in dump
29
* Dump ZA[] when active
30
* Fix SME full tile indexing
31
* Handle IC IVAU to improve compatibility with JITs
32
* xlnx-canfd-test: Fix code coverity issues
33
* gdbstub: Guard M-profile code with CONFIG_TCG
34
* allwinner-sramc: Set class_size
35
* target/xtensa: Assert that interrupt level is within bounds
36
* Avoid over-length shift in arm_cpu_sve_finalize() error case
37
* Define new 'neoverse-v1' CPU type
22
38
23
----------------------------------------------------------------
39
----------------------------------------------------------------
24
Gavin Shan (1):
40
Akihiko Odaki (1):
25
hw/arm/virt: Disable pl011 clock migration if needed
41
hw: arm: allwinner-sramc: Set class_size
42
43
Eric Auger (1):
44
target/arm: Add raw_writes ops for register whose write induce TLB maintenance
45
46
Fabiano Rosas (1):
47
target/arm: gdbstub: Guard M-profile code with CONFIG_TCG
48
49
John Högberg (1):
50
target/arm: Handle IC IVAU to improve compatibility with JITs
26
51
27
Peter Maydell (5):
52
Peter Maydell (5):
28
memory: Make flatview_cb return bool, not int
53
tests/tcg/aarch64/sysregs.c: Use S syntax for id_aa64zfr0_el1 and id_aa64smfr0_el1
29
memory: Document flatview_for_each_range()
54
target/xtensa: Assert that interrupt level is within bounds
30
memory: Add offset_in_region to flatview_cb arguments
55
target/arm: Suppress more TCG unimplemented features in ID registers
31
hw/core/loader: Add new function rom_ptr_for_as()
56
target/arm: Define neoverse-v1
32
target/arm: Make M-profile VTOR loads on reset handle memory aliasing
57
target/arm: Avoid over-length shift in arm_cpu_sve_finalize() error case
33
58
34
Richard Henderson (1):
59
Richard Henderson (3):
35
target/arm: Set ARMMMUFaultInfo.level in user-only arm_cpu_tlb_fill
60
target/arm: Avoid splitting Zregs across lines in dump
61
target/arm: Dump ZA[] when active
62
target/arm: Fix SME full tile indexing
36
63
37
include/exec/memory.h | 32 +++++++++++++++---
64
Vikram Garhwal (1):
38
include/hw/char/pl011.h | 1 +
65
tests/qtest: xlnx-canfd-test: Fix code coverity issues
39
include/hw/loader.h | 31 +++++++++++++++++
40
hw/char/pl011.c | 9 +++++
41
hw/core/loader.c | 75 +++++++++++++++++++++++++++++++++++++++++
42
hw/core/machine.c | 1 +
43
softmmu/memory.c | 4 ++-
44
target/arm/cpu.c | 2 +-
45
target/arm/tlb_helper.c | 1 +
46
tests/qtest/fuzz/generic_fuzz.c | 11 +++---
47
10 files changed, 157 insertions(+), 10 deletions(-)
48
66
67
Yuquan Wang (1):
68
hw/arm/sbsa-ref: use XHCI to replace EHCI
69
70
docs/system/arm/sbsa.rst | 5 +-
71
docs/system/arm/virt.rst | 1 +
72
hw/arm/sbsa-ref.c | 24 ++++---
73
hw/arm/virt.c | 1 +
74
hw/misc/allwinner-sramc.c | 1 +
75
target/arm/cpu.c | 98 +++++++++++++++++++++--------
76
target/arm/cpu64.c | 4 +-
77
target/arm/gdbstub.c | 4 ++
78
target/arm/helper.c | 70 +++++++++++++++++----
79
target/arm/tcg/cpu64.c | 128 ++++++++++++++++++++++++++++++++++++++
80
target/arm/tcg/translate-sme.c | 24 +++++--
81
target/xtensa/exc_helper.c | 3 +
82
tests/qtest/xlnx-canfd-test.c | 33 ++++------
83
tests/tcg/aarch64/sme-outprod1.c | 83 ++++++++++++++++++++++++
84
tests/tcg/aarch64/sysregs.c | 11 ++--
85
hw/arm/Kconfig | 2 +-
86
tests/tcg/aarch64/Makefile.target | 16 ++---
87
17 files changed, 415 insertions(+), 93 deletions(-)
88
create mode 100644 tests/tcg/aarch64/sme-outprod1.c
89
diff view generated by jsdifflib
New patch
1
From: Eric Auger <eric.auger@redhat.com>
1
2
3
Some registers whose 'cooked' writefns induce TLB maintenance do
4
not have raw_writefn ops defined. If only the writefn ops is set
5
(ie. no raw_writefn is provided), it is assumed the cooked also
6
work as the raw one. For those registers it is not obvious the
7
tlb_flush works on KVM mode so better/safer setting the raw write.
8
9
Signed-off-by: Eric Auger <eric.auger@redhat.com>
10
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/helper.c | 23 +++++++++++++----------
15
1 file changed, 13 insertions(+), 10 deletions(-)
16
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
20
+++ b/target/arm/helper.c
21
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = {
22
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 0,
23
.access = PL1_RW, .accessfn = access_tvm_trvm,
24
.fgt = FGT_TTBR0_EL1,
25
- .writefn = vmsa_ttbr_write, .resetvalue = 0,
26
+ .writefn = vmsa_ttbr_write, .resetvalue = 0, .raw_writefn = raw_write,
27
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s),
28
offsetof(CPUARMState, cp15.ttbr0_ns) } },
29
{ .name = "TTBR1_EL1", .state = ARM_CP_STATE_BOTH,
30
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 1,
31
.access = PL1_RW, .accessfn = access_tvm_trvm,
32
.fgt = FGT_TTBR1_EL1,
33
- .writefn = vmsa_ttbr_write, .resetvalue = 0,
34
+ .writefn = vmsa_ttbr_write, .resetvalue = 0, .raw_writefn = raw_write,
35
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s),
36
offsetof(CPUARMState, cp15.ttbr1_ns) } },
37
{ .name = "TCR_EL1", .state = ARM_CP_STATE_AA64,
38
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lpae_cp_reginfo[] = {
39
.type = ARM_CP_64BIT | ARM_CP_ALIAS,
40
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s),
41
offsetof(CPUARMState, cp15.ttbr0_ns) },
42
- .writefn = vmsa_ttbr_write, },
43
+ .writefn = vmsa_ttbr_write, .raw_writefn = raw_write },
44
{ .name = "TTBR1", .cp = 15, .crm = 2, .opc1 = 1,
45
.access = PL1_RW, .accessfn = access_tvm_trvm,
46
.type = ARM_CP_64BIT | ARM_CP_ALIAS,
47
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s),
48
offsetof(CPUARMState, cp15.ttbr1_ns) },
49
- .writefn = vmsa_ttbr_write, },
50
+ .writefn = vmsa_ttbr_write, .raw_writefn = raw_write },
51
};
52
53
static uint64_t aa64_fpcr_read(CPUARMState *env, const ARMCPRegInfo *ri)
54
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
55
.type = ARM_CP_IO,
56
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
57
.access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2),
58
- .writefn = hcr_write },
59
+ .writefn = hcr_write, .raw_writefn = raw_write },
60
{ .name = "HCR", .state = ARM_CP_STATE_AA32,
61
.type = ARM_CP_ALIAS | ARM_CP_IO,
62
.cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
63
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
64
{ .name = "TCR_EL2", .state = ARM_CP_STATE_BOTH,
65
.opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 2,
66
.access = PL2_RW, .writefn = vmsa_tcr_el12_write,
67
+ .raw_writefn = raw_write,
68
.fieldoffset = offsetof(CPUARMState, cp15.tcr_el[2]) },
69
{ .name = "VTCR", .state = ARM_CP_STATE_AA32,
70
.cp = 15, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 2,
71
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
72
.type = ARM_CP_64BIT | ARM_CP_ALIAS,
73
.access = PL2_RW, .accessfn = access_el3_aa32ns,
74
.fieldoffset = offsetof(CPUARMState, cp15.vttbr_el2),
75
- .writefn = vttbr_write },
76
+ .writefn = vttbr_write, .raw_writefn = raw_write },
77
{ .name = "VTTBR_EL2", .state = ARM_CP_STATE_AA64,
78
.opc0 = 3, .opc1 = 4, .crn = 2, .crm = 1, .opc2 = 0,
79
- .access = PL2_RW, .writefn = vttbr_write,
80
+ .access = PL2_RW, .writefn = vttbr_write, .raw_writefn = raw_write,
81
.fieldoffset = offsetof(CPUARMState, cp15.vttbr_el2) },
82
{ .name = "SCTLR_EL2", .state = ARM_CP_STATE_BOTH,
83
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 0, .opc2 = 0,
84
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
85
.fieldoffset = offsetof(CPUARMState, cp15.tpidr_el[2]) },
86
{ .name = "TTBR0_EL2", .state = ARM_CP_STATE_AA64,
87
.opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 0,
88
- .access = PL2_RW, .resetvalue = 0, .writefn = vmsa_tcr_ttbr_el2_write,
89
+ .access = PL2_RW, .resetvalue = 0,
90
+ .writefn = vmsa_tcr_ttbr_el2_write, .raw_writefn = raw_write,
91
.fieldoffset = offsetof(CPUARMState, cp15.ttbr0_el[2]) },
92
{ .name = "HTTBR", .cp = 15, .opc1 = 4, .crm = 2,
93
.access = PL2_RW, .type = ARM_CP_64BIT | ARM_CP_ALIAS,
94
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_cp_reginfo[] = {
95
{ .name = "SCR_EL3", .state = ARM_CP_STATE_AA64,
96
.opc0 = 3, .opc1 = 6, .crn = 1, .crm = 1, .opc2 = 0,
97
.access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.scr_el3),
98
- .resetfn = scr_reset, .writefn = scr_write },
99
+ .resetfn = scr_reset, .writefn = scr_write, .raw_writefn = raw_write },
100
{ .name = "SCR", .type = ARM_CP_ALIAS | ARM_CP_NEWEL,
101
.cp = 15, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 0,
102
.access = PL1_RW, .accessfn = access_trap_aa32s_el1,
103
.fieldoffset = offsetoflow32(CPUARMState, cp15.scr_el3),
104
- .writefn = scr_write },
105
+ .writefn = scr_write, .raw_writefn = raw_write },
106
{ .name = "SDER32_EL3", .state = ARM_CP_STATE_AA64,
107
.opc0 = 3, .opc1 = 6, .crn = 1, .crm = 1, .opc2 = 1,
108
.access = PL3_RW, .resetvalue = 0,
109
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = {
110
{ .name = "TTBR1_EL2", .state = ARM_CP_STATE_AA64,
111
.opc0 = 3, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 1,
112
.access = PL2_RW, .writefn = vmsa_tcr_ttbr_el2_write,
113
+ .raw_writefn = raw_write,
114
.fieldoffset = offsetof(CPUARMState, cp15.ttbr1_el[2]) },
115
#ifndef CONFIG_USER_ONLY
116
{ .name = "CNTHV_CVAL_EL2", .state = ARM_CP_STATE_AA64,
117
--
118
2.34.1
diff view generated by jsdifflib
1
From: Gavin Shan <gshan@redhat.com>
1
From: Yuquan Wang <wangyuquan1236@phytium.com.cn>
2
2
3
A clock is added by commit aac63e0e6ea3 ("hw/char/pl011: add a clock
3
The current sbsa-ref cannot use EHCI controller which is only
4
input") since v5.2.0 which corresponds to virt-5.2 machine type. It
4
able to do 32-bit DMA, since sbsa-ref doesn't have RAM below 4GB.
5
causes backwards migration failure from upstream to downstream (v5.1.0)
5
Hence, this uses XHCI to provide a usb controller with 64-bit
6
when the machine type is specified with virt-5.1.
6
DMA capablity instead of EHCI.
7
7
8
This fixes the issue by following instructions from section "Connecting
8
We bump the platform version to 0.3 with this change. Although the
9
subsections to properties" in docs/devel/migration.rst. With this applied,
9
hardware at the USB controller address changes, the firmware and
10
the PL011 clock is migrated based on the machine type.
10
Linux can both cope with this -- on an older non-XHCI-aware
11
firmware/kernel setup the probe routine simply fails and the guest
12
proceeds without any USB. (This isn't a loss of functionality,
13
because the old USB controller never worked in the first place.) So
14
we can call this a backwards-compatible change and only bump the
15
minor version.
11
16
12
virt-5.2 or newer: migration
17
Signed-off-by: Yuquan Wang <wangyuquan1236@phytium.com.cn>
13
virt-5.1 or older: non-migration
18
Message-id: 20230621103847.447508-2-wangyuquan1236@phytium.com.cn
14
19
[PMM: tweaked commit message; add line to docs about what
15
Cc: qemu-stable@nongnu.org # v5.2.0+
20
changes in platform version 0.3]
16
Fixes: aac63e0e6ea3 ("hw/char/pl011: add a clock input")
21
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Suggested-by: Andrew Jones <drjones@redhat.com>
18
Signed-off-by: Gavin Shan <gshan@redhat.com>
19
Reviewed-by: Andrew Jones <drjones@redhat.com>
20
Message-id: 20210318023801.18287-1-gshan@redhat.com
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
23
---
23
include/hw/char/pl011.h | 1 +
24
docs/system/arm/sbsa.rst | 5 ++++-
24
hw/char/pl011.c | 9 +++++++++
25
hw/arm/sbsa-ref.c | 23 +++++++++++++----------
25
hw/core/machine.c | 1 +
26
hw/arm/Kconfig | 2 +-
26
3 files changed, 11 insertions(+)
27
3 files changed, 18 insertions(+), 12 deletions(-)
27
28
28
diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h
29
diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst
29
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
30
--- a/include/hw/char/pl011.h
31
--- a/docs/system/arm/sbsa.rst
31
+++ b/include/hw/char/pl011.h
32
+++ b/docs/system/arm/sbsa.rst
32
@@ -XXX,XX +XXX,XX @@ struct PL011State {
33
@@ -XXX,XX +XXX,XX @@ The ``sbsa-ref`` board supports:
33
CharBackend chr;
34
- A configurable number of AArch64 CPUs
34
qemu_irq irq[6];
35
- GIC version 3
35
Clock *clk;
36
- System bus AHCI controller
36
+ bool migrate_clk;
37
- - System bus EHCI controller
37
const unsigned char *id;
38
+ - System bus XHCI controller
39
- CDROM and hard disc on AHCI bus
40
- E1000E ethernet card on PCIe bus
41
- Bochs display adapter on PCIe bus
42
@@ -XXX,XX +XXX,XX @@ Platform version changes:
43
44
0.2
45
GIC ITS information is present in devicetree.
46
+
47
+0.3
48
+ The USB controller is an XHCI device, not EHCI
49
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/arm/sbsa-ref.c
52
+++ b/hw/arm/sbsa-ref.c
53
@@ -XXX,XX +XXX,XX @@
54
#include "hw/pci-host/gpex.h"
55
#include "hw/qdev-properties.h"
56
#include "hw/usb.h"
57
+#include "hw/usb/xhci.h"
58
#include "hw/char/pl011.h"
59
#include "hw/watchdog/sbsa_gwdt.h"
60
#include "net/net.h"
61
@@ -XXX,XX +XXX,XX @@ enum {
62
SBSA_SECURE_UART_MM,
63
SBSA_SECURE_MEM,
64
SBSA_AHCI,
65
- SBSA_EHCI,
66
+ SBSA_XHCI,
38
};
67
};
39
68
40
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
69
struct SBSAMachineState {
70
@@ -XXX,XX +XXX,XX @@ static const MemMapEntry sbsa_ref_memmap[] = {
71
[SBSA_SMMU] = { 0x60050000, 0x00020000 },
72
/* Space here reserved for more SMMUs */
73
[SBSA_AHCI] = { 0x60100000, 0x00010000 },
74
- [SBSA_EHCI] = { 0x60110000, 0x00010000 },
75
+ [SBSA_XHCI] = { 0x60110000, 0x00010000 },
76
/* Space here reserved for other devices */
77
[SBSA_PCIE_PIO] = { 0x7fff0000, 0x00010000 },
78
/* 32-bit address PCIE MMIO space */
79
@@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = {
80
[SBSA_SECURE_UART] = 8,
81
[SBSA_SECURE_UART_MM] = 9,
82
[SBSA_AHCI] = 10,
83
- [SBSA_EHCI] = 11,
84
+ [SBSA_XHCI] = 11,
85
[SBSA_SMMU] = 12, /* ... to 15 */
86
[SBSA_GWDT_WS0] = 16,
87
};
88
@@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms)
89
* fw compatibility.
90
*/
91
qemu_fdt_setprop_cell(fdt, "/", "machine-version-major", 0);
92
- qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 2);
93
+ qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 3);
94
95
if (ms->numa_state->have_numa_distance) {
96
int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t);
97
@@ -XXX,XX +XXX,XX @@ static void create_ahci(const SBSAMachineState *sms)
98
}
99
}
100
101
-static void create_ehci(const SBSAMachineState *sms)
102
+static void create_xhci(const SBSAMachineState *sms)
103
{
104
- hwaddr base = sbsa_ref_memmap[SBSA_EHCI].base;
105
- int irq = sbsa_ref_irqmap[SBSA_EHCI];
106
+ hwaddr base = sbsa_ref_memmap[SBSA_XHCI].base;
107
+ int irq = sbsa_ref_irqmap[SBSA_XHCI];
108
+ DeviceState *dev = qdev_new(TYPE_XHCI_SYSBUS);
109
110
- sysbus_create_simple("platform-ehci-usb", base,
111
- qdev_get_gpio_in(sms->gic, irq));
112
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
113
+ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
114
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(sms->gic, irq));
115
}
116
117
static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
118
@@ -XXX,XX +XXX,XX @@ static void sbsa_ref_init(MachineState *machine)
119
120
create_ahci(sms);
121
122
- create_ehci(sms);
123
+ create_xhci(sms);
124
125
create_pcie(sms);
126
127
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
41
index XXXXXXX..XXXXXXX 100644
128
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/char/pl011.c
129
--- a/hw/arm/Kconfig
43
+++ b/hw/char/pl011.c
130
+++ b/hw/arm/Kconfig
44
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps pl011_ops = {
131
@@ -XXX,XX +XXX,XX @@ config SBSA_REF
45
.endianness = DEVICE_NATIVE_ENDIAN,
132
select PL011 # UART
46
};
133
select PL031 # RTC
47
134
select PL061 # GPIO
48
+static bool pl011_clock_needed(void *opaque)
135
- select USB_EHCI_SYSBUS
49
+{
136
+ select USB_XHCI_SYSBUS
50
+ PL011State *s = PL011(opaque);
137
select WDT_SBSA
51
+
138
select BOCHS_DISPLAY
52
+ return s->migrate_clk;
53
+}
54
+
55
static const VMStateDescription vmstate_pl011_clock = {
56
.name = "pl011/clock",
57
.version_id = 1,
58
.minimum_version_id = 1,
59
+ .needed = pl011_clock_needed,
60
.fields = (VMStateField[]) {
61
VMSTATE_CLOCK(clk, PL011State),
62
VMSTATE_END_OF_LIST()
63
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pl011 = {
64
65
static Property pl011_properties[] = {
66
DEFINE_PROP_CHR("chardev", PL011State, chr),
67
+ DEFINE_PROP_BOOL("migrate-clk", PL011State, migrate_clk, true),
68
DEFINE_PROP_END_OF_LIST(),
69
};
70
71
diff --git a/hw/core/machine.c b/hw/core/machine.c
72
index XXXXXXX..XXXXXXX 100644
73
--- a/hw/core/machine.c
74
+++ b/hw/core/machine.c
75
@@ -XXX,XX +XXX,XX @@ GlobalProperty hw_compat_5_1[] = {
76
{ "virtio-scsi-device", "num_queues", "1"},
77
{ "nvme", "use-intel-id", "on"},
78
{ "pvpanic", "events", "1"}, /* PVPANIC_PANICKED */
79
+ { "pl011", "migrate-clk", "off" },
80
};
81
const size_t hw_compat_5_1_len = G_N_ELEMENTS(hw_compat_5_1);
82
139
83
--
140
--
84
2.20.1
141
2.34.1
85
86
diff view generated by jsdifflib
New patch
1
Some assemblers will complain about attempts to access
2
id_aa64zfr0_el1 and id_aa64smfr0_el1 by name if the test
3
binary isn't built for the right processor type:
1
4
5
/tmp/ccASXpLo.s:782: Error: selected processor does not support system register name 'id_aa64zfr0_el1'
6
/tmp/ccASXpLo.s:829: Error: selected processor does not support system register name 'id_aa64smfr0_el1'
7
8
However, these registers are in the ID space and are guaranteed to
9
read-as-zero on older CPUs, so the access is both safe and sensible.
10
Switch to using the S syntax, as we already do for ID_AA64ISAR2_EL1
11
and ID_AA64MMFR2_EL1. This allows us to drop the HAS_ARMV9_SME check
12
and the makefile machinery to adjust the CFLAGS for this test, so we
13
don't rely on having a sufficiently new compiler to be able to check
14
these registers.
15
16
This means we're actually testing the SME ID register: no released
17
GCC yet recognizes -march=armv9-a+sme, so that was always skipped.
18
It also avoids a future problem if we try to switch the "do we have
19
SME support in the toolchain" check from "in the compiler" to "in the
20
assembler" (at which point we would otherwise run into the above
21
errors).
22
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
---
25
tests/tcg/aarch64/sysregs.c | 11 +++++++----
26
tests/tcg/aarch64/Makefile.target | 7 +------
27
2 files changed, 8 insertions(+), 10 deletions(-)
28
29
diff --git a/tests/tcg/aarch64/sysregs.c b/tests/tcg/aarch64/sysregs.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/tests/tcg/aarch64/sysregs.c
32
+++ b/tests/tcg/aarch64/sysregs.c
33
@@ -XXX,XX +XXX,XX @@
34
/*
35
* Older assemblers don't recognize newer system register names,
36
* but we can still access them by the Sn_n_Cn_Cn_n syntax.
37
+ * This also means we don't need to specifically request that the
38
+ * assembler enables whatever architectural features the ID registers
39
+ * syntax might be gated behind.
40
*/
41
#define SYS_ID_AA64ISAR2_EL1 S3_0_C0_C6_2
42
#define SYS_ID_AA64MMFR2_EL1 S3_0_C0_C7_2
43
+#define SYS_ID_AA64ZFR0_EL1 S3_0_C0_C4_4
44
+#define SYS_ID_AA64SMFR0_EL1 S3_0_C0_C4_5
45
46
int failed_bit_count;
47
48
@@ -XXX,XX +XXX,XX @@ int main(void)
49
/* all hidden, DebugVer fixed to 0x6 (ARMv8 debug architecture) */
50
get_cpu_reg_check_mask(id_aa64dfr0_el1, _m(0000,0000,0000,0006));
51
get_cpu_reg_check_zero(id_aa64dfr1_el1);
52
- get_cpu_reg_check_mask(id_aa64zfr0_el1, _m(0ff0,ff0f,00ff,00ff));
53
-#ifdef HAS_ARMV9_SME
54
- get_cpu_reg_check_mask(id_aa64smfr0_el1, _m(80f1,00fd,0000,0000));
55
-#endif
56
+ get_cpu_reg_check_mask(SYS_ID_AA64ZFR0_EL1, _m(0ff0,ff0f,00ff,00ff));
57
+ get_cpu_reg_check_mask(SYS_ID_AA64SMFR0_EL1, _m(80f1,00fd,0000,0000));
58
59
get_cpu_reg_check_zero(id_aa64afr0_el1);
60
get_cpu_reg_check_zero(id_aa64afr1_el1);
61
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
62
index XXXXXXX..XXXXXXX 100644
63
--- a/tests/tcg/aarch64/Makefile.target
64
+++ b/tests/tcg/aarch64/Makefile.target
65
@@ -XXX,XX +XXX,XX @@ AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-5 mte-6 mte-7
66
mte-%: CFLAGS += -march=armv8.5-a+memtag
67
endif
68
69
-ifneq ($(CROSS_CC_HAS_SVE),)
70
# System Registers Tests
71
AARCH64_TESTS += sysregs
72
-ifneq ($(CROSS_CC_HAS_ARMV9_SME),)
73
-sysregs: CFLAGS+=-march=armv9-a+sme -DHAS_ARMV9_SME
74
-else
75
-sysregs: CFLAGS+=-march=armv8.1-a+sve
76
-endif
77
78
+ifneq ($(CROSS_CC_HAS_SVE),)
79
# SVE ioctl test
80
AARCH64_TESTS += sve-ioctls
81
sve-ioctls: CFLAGS+=-march=armv8.1-a+sve
82
--
83
2.34.1
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Allow the line length to extend to 548 columns. While annoyingly wide,
4
it's still less confusing than the continuations we print. Also, the
5
default VL used by Linux (and max for A64FX) uses only 140 columns.
6
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230622151201.1578522-2-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/cpu.c | 36 ++++++++++++++----------------------
13
1 file changed, 14 insertions(+), 22 deletions(-)
14
15
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu.c
18
+++ b/target/arm/cpu.c
19
@@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
20
ARMCPU *cpu = ARM_CPU(cs);
21
CPUARMState *env = &cpu->env;
22
uint32_t psr = pstate_read(env);
23
- int i;
24
+ int i, j;
25
int el = arm_current_el(env);
26
const char *ns_status;
27
bool sve;
28
@@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
29
}
30
31
if (sve) {
32
- int j, zcr_len = sve_vqm1_for_el(env, el);
33
+ int zcr_len = sve_vqm1_for_el(env, el);
34
35
for (i = 0; i <= FFR_PRED_NUM; i++) {
36
bool eol;
37
@@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
38
}
39
}
40
41
- for (i = 0; i < 32; i++) {
42
- if (zcr_len == 0) {
43
+ if (zcr_len == 0) {
44
+ /*
45
+ * With vl=16, there are only 37 columns per register,
46
+ * so output two registers per line.
47
+ */
48
+ for (i = 0; i < 32; i++) {
49
qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64 "%s",
50
i, env->vfp.zregs[i].d[1],
51
env->vfp.zregs[i].d[0], i & 1 ? "\n" : " ");
52
- } else if (zcr_len == 1) {
53
- qemu_fprintf(f, "Z%02d=%016" PRIx64 ":%016" PRIx64
54
- ":%016" PRIx64 ":%016" PRIx64 "\n",
55
- i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].d[2],
56
- env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0]);
57
- } else {
58
+ }
59
+ } else {
60
+ for (i = 0; i < 32; i++) {
61
+ qemu_fprintf(f, "Z%02d=", i);
62
for (j = zcr_len; j >= 0; j--) {
63
- bool odd = (zcr_len - j) % 2 != 0;
64
- if (j == zcr_len) {
65
- qemu_fprintf(f, "Z%02d[%x-%x]=", i, j, j - 1);
66
- } else if (!odd) {
67
- if (j > 0) {
68
- qemu_fprintf(f, " [%x-%x]=", j, j - 1);
69
- } else {
70
- qemu_fprintf(f, " [%x]=", j);
71
- }
72
- }
73
qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s",
74
env->vfp.zregs[i].d[j * 2 + 1],
75
- env->vfp.zregs[i].d[j * 2],
76
- odd || j == 0 ? "\n" : ":");
77
+ env->vfp.zregs[i].d[j * 2 + 0],
78
+ j ? ":" : "\n");
79
}
80
}
81
}
82
--
83
2.34.1
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Always print each matrix row whole, one per line, so that we
4
get the entire matrix in the proper shape.
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20230622151201.1578522-3-richard.henderson@linaro.org
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/cpu.c | 18 ++++++++++++++++++
12
1 file changed, 18 insertions(+)
13
14
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu.c
17
+++ b/target/arm/cpu.c
18
@@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
19
i, q[1], q[0], (i & 1 ? "\n" : " "));
20
}
21
}
22
+
23
+ if (cpu_isar_feature(aa64_sme, cpu) &&
24
+ FIELD_EX64(env->svcr, SVCR, ZA) &&
25
+ sme_exception_el(env, el) == 0) {
26
+ int zcr_len = sve_vqm1_for_el_sm(env, el, true);
27
+ int svl = (zcr_len + 1) * 16;
28
+ int svl_lg10 = svl < 100 ? 2 : 3;
29
+
30
+ for (i = 0; i < svl; i++) {
31
+ qemu_fprintf(f, "ZA[%0*d]=", svl_lg10, i);
32
+ for (j = zcr_len; j >= 0; --j) {
33
+ qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%c",
34
+ env->zarray[i].d[2 * j + 1],
35
+ env->zarray[i].d[2 * j],
36
+ j ? ':' : '\n');
37
+ }
38
+ }
39
+ }
40
}
41
42
#else
43
--
44
2.34.1
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Pretend the fault always happens at page table level 3.
3
For the outer product set of insns, which take an entire matrix
4
tile as output, the argument is not a combined tile+column.
5
Therefore using get_tile_rowcol was incorrect, as we extracted
6
the tile number from itself.
4
7
5
Failure to set this leaves level = 0, which is impossible for
8
The test case relies only on assembler support for SME, since
6
ARMFault_Permission, and produces an invalid syndrome, which
9
no release of GCC recognizes -march=armv9-a+sme yet.
7
reaches g_assert_not_reached in cpu_loop.
8
10
9
Fixes: 8db94ab4e5db ("linux-user/aarch64: Pass syndrome to EXC_*_ABORT")
11
Cc: qemu-stable@nongnu.org
10
Reported-by: Laurent Vivier <laurent@vivier.eu>
12
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1620
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20230622151201.1578522-5-richard.henderson@linaro.org
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Message-id: 20210320000606.1788699-1-richard.henderson@linaro.org
16
[PMM: dropped now-unneeded changes to sysregs CFLAGS]
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
18
---
16
target/arm/tlb_helper.c | 1 +
19
target/arm/tcg/translate-sme.c | 24 ++++++---
17
1 file changed, 1 insertion(+)
20
tests/tcg/aarch64/sme-outprod1.c | 83 +++++++++++++++++++++++++++++++
21
tests/tcg/aarch64/Makefile.target | 7 ++-
22
3 files changed, 107 insertions(+), 7 deletions(-)
23
create mode 100644 tests/tcg/aarch64/sme-outprod1.c
18
24
19
diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c
25
diff --git a/target/arm/tcg/translate-sme.c b/target/arm/tcg/translate-sme.c
20
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/tlb_helper.c
27
--- a/target/arm/tcg/translate-sme.c
22
+++ b/target/arm/tlb_helper.c
28
+++ b/target/arm/tcg/translate-sme.c
23
@@ -XXX,XX +XXX,XX @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
29
@@ -XXX,XX +XXX,XX @@ static TCGv_ptr get_tile_rowcol(DisasContext *s, int esz, int rs,
24
} else {
30
return addr;
25
fi.type = ARMFault_Translation;
31
}
32
33
+/*
34
+ * Resolve tile.size[0] to a host pointer.
35
+ * Used by e.g. outer product insns where we require the entire tile.
36
+ */
37
+static TCGv_ptr get_tile(DisasContext *s, int esz, int tile)
38
+{
39
+ TCGv_ptr addr = tcg_temp_new_ptr();
40
+ int offset;
41
+
42
+ offset = tile * sizeof(ARMVectorReg) + offsetof(CPUARMState, zarray);
43
+
44
+ tcg_gen_addi_ptr(addr, cpu_env, offset);
45
+ return addr;
46
+}
47
+
48
static bool trans_ZERO(DisasContext *s, arg_ZERO *a)
49
{
50
if (!dc_isar_feature(aa64_sme, s)) {
51
@@ -XXX,XX +XXX,XX @@ static bool do_adda(DisasContext *s, arg_adda *a, MemOp esz,
52
return true;
26
}
53
}
27
+ fi.level = 3;
54
28
55
- /* Sum XZR+zad to find ZAd. */
29
/* now we have a real cpu fault */
56
- za = get_tile_rowcol(s, esz, 31, a->zad, false);
30
cpu_restore_state(cs, retaddr, true);
57
+ za = get_tile(s, esz, a->zad);
58
zn = vec_full_reg_ptr(s, a->zn);
59
pn = pred_full_reg_ptr(s, a->pn);
60
pm = pred_full_reg_ptr(s, a->pm);
61
@@ -XXX,XX +XXX,XX @@ static bool do_outprod(DisasContext *s, arg_op *a, MemOp esz,
62
return true;
63
}
64
65
- /* Sum XZR+zad to find ZAd. */
66
- za = get_tile_rowcol(s, esz, 31, a->zad, false);
67
+ za = get_tile(s, esz, a->zad);
68
zn = vec_full_reg_ptr(s, a->zn);
69
zm = vec_full_reg_ptr(s, a->zm);
70
pn = pred_full_reg_ptr(s, a->pn);
71
@@ -XXX,XX +XXX,XX @@ static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz,
72
return true;
73
}
74
75
- /* Sum XZR+zad to find ZAd. */
76
- za = get_tile_rowcol(s, esz, 31, a->zad, false);
77
+ za = get_tile(s, esz, a->zad);
78
zn = vec_full_reg_ptr(s, a->zn);
79
zm = vec_full_reg_ptr(s, a->zm);
80
pn = pred_full_reg_ptr(s, a->pn);
81
diff --git a/tests/tcg/aarch64/sme-outprod1.c b/tests/tcg/aarch64/sme-outprod1.c
82
new file mode 100644
83
index XXXXXXX..XXXXXXX
84
--- /dev/null
85
+++ b/tests/tcg/aarch64/sme-outprod1.c
86
@@ -XXX,XX +XXX,XX @@
87
+/*
88
+ * SME outer product, 1 x 1.
89
+ * SPDX-License-Identifier: GPL-2.0-or-later
90
+ */
91
+
92
+#include <stdio.h>
93
+
94
+extern void foo(float *dst);
95
+
96
+asm(
97
+"    .arch_extension sme\n"
98
+"    .type foo, @function\n"
99
+"foo:\n"
100
+"    stp x29, x30, [sp, -80]!\n"
101
+"    mov x29, sp\n"
102
+"    stp d8, d9, [sp, 16]\n"
103
+"    stp d10, d11, [sp, 32]\n"
104
+"    stp d12, d13, [sp, 48]\n"
105
+"    stp d14, d15, [sp, 64]\n"
106
+"    smstart\n"
107
+"    ptrue p0.s, vl4\n"
108
+"    fmov z0.s, #1.0\n"
109
+/*
110
+ * An outer product of a vector of 1.0 by itself should be a matrix of 1.0.
111
+ * Note that we are using tile 1 here (za1.s) rather than tile 0.
112
+ */
113
+"    zero {za}\n"
114
+"    fmopa za1.s, p0/m, p0/m, z0.s, z0.s\n"
115
+/*
116
+ * Read the first 4x4 sub-matrix of elements from tile 1:
117
+ * Note that za1h should be interchangable here.
118
+ */
119
+"    mov w12, #0\n"
120
+"    mova z0.s, p0/m, za1v.s[w12, #0]\n"
121
+"    mova z1.s, p0/m, za1v.s[w12, #1]\n"
122
+"    mova z2.s, p0/m, za1v.s[w12, #2]\n"
123
+"    mova z3.s, p0/m, za1v.s[w12, #3]\n"
124
+/*
125
+ * And store them to the input pointer (dst in the C code):
126
+ */
127
+"    st1w {z0.s}, p0, [x0]\n"
128
+"    add x0, x0, #16\n"
129
+"    st1w {z1.s}, p0, [x0]\n"
130
+"    add x0, x0, #16\n"
131
+"    st1w {z2.s}, p0, [x0]\n"
132
+"    add x0, x0, #16\n"
133
+"    st1w {z3.s}, p0, [x0]\n"
134
+"    smstop\n"
135
+"    ldp d8, d9, [sp, 16]\n"
136
+"    ldp d10, d11, [sp, 32]\n"
137
+"    ldp d12, d13, [sp, 48]\n"
138
+"    ldp d14, d15, [sp, 64]\n"
139
+"    ldp x29, x30, [sp], 80\n"
140
+"    ret\n"
141
+"    .size foo, . - foo"
142
+);
143
+
144
+int main()
145
+{
146
+ float dst[16];
147
+ int i, j;
148
+
149
+ foo(dst);
150
+
151
+ for (i = 0; i < 16; i++) {
152
+ if (dst[i] != 1.0f) {
153
+ break;
154
+ }
155
+ }
156
+
157
+ if (i == 16) {
158
+ return 0; /* success */
159
+ }
160
+
161
+ /* failure */
162
+ for (i = 0; i < 4; ++i) {
163
+ for (j = 0; j < 4; ++j) {
164
+ printf("%f ", (double)dst[i * 4 + j]);
165
+ }
166
+ printf("\n");
167
+ }
168
+ return 1;
169
+}
170
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
171
index XXXXXXX..XXXXXXX 100644
172
--- a/tests/tcg/aarch64/Makefile.target
173
+++ b/tests/tcg/aarch64/Makefile.target
174
@@ -XXX,XX +XXX,XX @@ config-cc.mak: Makefile
175
     $(call cc-option,-march=armv8.5-a, CROSS_CC_HAS_ARMV8_5); \
176
     $(call cc-option,-mbranch-protection=standard, CROSS_CC_HAS_ARMV8_BTI); \
177
     $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE); \
178
-     $(call cc-option,-march=armv9-a+sme, CROSS_CC_HAS_ARMV9_SME)) 3> config-cc.mak
179
+     $(call cc-option,-Wa$(COMMA)-march=armv9-a+sme, CROSS_AS_HAS_ARMV9_SME)) 3> config-cc.mak
180
-include config-cc.mak
181
182
ifneq ($(CROSS_CC_HAS_ARMV8_2),)
183
@@ -XXX,XX +XXX,XX @@ AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-5 mte-6 mte-7
184
mte-%: CFLAGS += -march=armv8.5-a+memtag
185
endif
186
187
+# SME Tests
188
+ifneq ($(CROSS_AS_HAS_ARMV9_SME),)
189
+AARCH64_TESTS += sme-outprod1
190
+endif
191
+
192
# System Registers Tests
193
AARCH64_TESTS += sysregs
194
31
--
195
--
32
2.20.1
196
2.34.1
33
34
diff view generated by jsdifflib
1
The function flatview_for_each_range() calls a callback for each
1
From: John Högberg <john.hogberg@ericsson.com>
2
range in a FlatView. Currently the callback gets the start and
3
length of the range and the MemoryRegion involved, but not the offset
4
within the MemoryRegion. Add this to the callback's arguments; we're
5
going to want it for a new use in the next commit.
6
2
3
Unlike architectures with precise self-modifying code semantics
4
(e.g. x86) ARM processors do not maintain coherency for instruction
5
execution and memory, requiring an instruction synchronization
6
barrier on every core that will execute the new code, and on many
7
models also the explicit use of cache management instructions.
8
9
While this is required to make JITs work on actual hardware, QEMU
10
has gotten away with not handling this since it does not emulate
11
caches, and unconditionally invalidates code whenever the softmmu
12
or the user-mode page protection logic detects that code has been
13
modified.
14
15
Unfortunately the latter does not work in the face of dual-mapped
16
code (a common W^X workaround), where one page is executable and
17
the other is writable: user-mode has no way to connect one with the
18
other as that is only known to the kernel and the emulated
19
application.
20
21
This commit works around the issue by telling software that
22
instruction cache invalidation is required by clearing the
23
CPR_EL0.DIC flag (regardless of whether the emulated processor
24
needs it), and then invalidating code in IC IVAU instructions.
25
26
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1034
27
28
Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
29
Signed-off-by: John Högberg <john.hogberg@ericsson.com>
30
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
31
Message-id: 168778890374.24232.3402138851538068785-1@git.sr.ht
32
[PMM: removed unnecessary AArch64 feature check; moved
33
"clear CTR_EL1.DIC" code up a bit so it's not in the middle
34
of the vfp/neon related tests]
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
35
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Message-id: 20210318174823.18066-4-peter.maydell@linaro.org
11
---
36
---
12
include/exec/memory.h | 2 ++
37
target/arm/cpu.c | 11 +++++++++++
13
softmmu/memory.c | 4 +++-
38
target/arm/helper.c | 47 ++++++++++++++++++++++++++++++++++++++++++---
14
tests/qtest/fuzz/generic_fuzz.c | 5 ++++-
39
2 files changed, 55 insertions(+), 3 deletions(-)
15
3 files changed, 9 insertions(+), 2 deletions(-)
16
40
17
diff --git a/include/exec/memory.h b/include/exec/memory.h
41
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
18
index XXXXXXX..XXXXXXX 100644
42
index XXXXXXX..XXXXXXX 100644
19
--- a/include/exec/memory.h
43
--- a/target/arm/cpu.c
20
+++ b/include/exec/memory.h
44
+++ b/target/arm/cpu.c
21
@@ -XXX,XX +XXX,XX @@ static inline FlatView *address_space_to_flatview(AddressSpace *as)
45
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
22
* @start: start address of the range within the FlatView
46
return;
23
* @len: length of the range in bytes
47
}
24
* @mr: MemoryRegion covering this range
48
25
+ * @offset_in_region: offset of the first byte of the range within @mr
49
+#ifdef CONFIG_USER_ONLY
26
* @opaque: data pointer passed to flatview_for_each_range()
50
+ /*
27
*
51
+ * User mode relies on IC IVAU instructions to catch modification of
28
* Returns: true to stop the iteration, false to keep going.
52
+ * dual-mapped code.
29
@@ -XXX,XX +XXX,XX @@ static inline FlatView *address_space_to_flatview(AddressSpace *as)
53
+ *
30
typedef bool (*flatview_cb)(Int128 start,
54
+ * Clear CTR_EL0.DIC to ensure that software that honors these flags uses
31
Int128 len,
55
+ * IC IVAU even if the emulated processor does not normally require it.
32
const MemoryRegion *mr,
56
+ */
33
+ hwaddr offset_in_region,
57
+ cpu->ctr = FIELD_DP64(cpu->ctr, CTR_EL0, DIC, 0);
34
void *opaque);
58
+#endif
35
59
+
36
/**
60
if (arm_feature(env, ARM_FEATURE_AARCH64) &&
37
diff --git a/softmmu/memory.c b/softmmu/memory.c
61
cpu->has_vfp != cpu->has_neon) {
62
/*
63
diff --git a/target/arm/helper.c b/target/arm/helper.c
38
index XXXXXXX..XXXXXXX 100644
64
index XXXXXXX..XXXXXXX 100644
39
--- a/softmmu/memory.c
65
--- a/target/arm/helper.c
40
+++ b/softmmu/memory.c
66
+++ b/target/arm/helper.c
41
@@ -XXX,XX +XXX,XX @@ void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque)
67
@@ -XXX,XX +XXX,XX @@ static void mdcr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri,
42
assert(cb);
43
44
FOR_EACH_FLAT_RANGE(fr, fv) {
45
- if (cb(fr->addr.start, fr->addr.size, fr->mr, opaque))
46
+ if (cb(fr->addr.start, fr->addr.size, fr->mr,
47
+ fr->offset_in_region, opaque)) {
48
break;
49
+ }
50
}
68
}
51
}
69
}
52
70
53
diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c
71
+#ifdef CONFIG_USER_ONLY
54
index XXXXXXX..XXXXXXX 100644
72
+/*
55
--- a/tests/qtest/fuzz/generic_fuzz.c
73
+ * `IC IVAU` is handled to improve compatibility with JITs that dual-map their
56
+++ b/tests/qtest/fuzz/generic_fuzz.c
74
+ * code to get around W^X restrictions, where one region is writable and the
57
@@ -XXX,XX +XXX,XX @@ struct get_io_cb_info {
75
+ * other is executable.
58
};
76
+ *
59
77
+ * Since the executable region is never written to we cannot detect code
60
static bool get_io_address_cb(Int128 start, Int128 size,
78
+ * changes when running in user mode, and rely on the emulated JIT telling us
61
- const MemoryRegion *mr, void *opaque) {
79
+ * that the code has changed by executing this instruction.
62
+ const MemoryRegion *mr,
80
+ */
63
+ hwaddr offset_in_region,
81
+static void ic_ivau_write(CPUARMState *env, const ARMCPRegInfo *ri,
64
+ void *opaque)
82
+ uint64_t value)
65
+{
83
+{
66
struct get_io_cb_info *info = opaque;
84
+ uint64_t icache_line_mask, start_address, end_address;
67
if (g_hash_table_lookup(fuzzable_memoryregions, mr)) {
85
+ const ARMCPU *cpu;
68
if (info->index == 0) {
86
+
87
+ cpu = env_archcpu(env);
88
+
89
+ icache_line_mask = (4 << extract32(cpu->ctr, 0, 4)) - 1;
90
+ start_address = value & ~icache_line_mask;
91
+ end_address = value | icache_line_mask;
92
+
93
+ mmap_lock();
94
+
95
+ tb_invalidate_phys_range(start_address, end_address);
96
+
97
+ mmap_unlock();
98
+}
99
+#endif
100
+
101
static const ARMCPRegInfo v8_cp_reginfo[] = {
102
/*
103
* Minimal set of EL0-visible registers. This will need to be expanded
104
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
105
{ .name = "CURRENTEL", .state = ARM_CP_STATE_AA64,
106
.opc0 = 3, .opc1 = 0, .opc2 = 2, .crn = 4, .crm = 2,
107
.access = PL1_R, .type = ARM_CP_CURRENTEL },
108
- /* Cache ops: all NOPs since we don't emulate caches */
109
+ /*
110
+ * Instruction cache ops. All of these except `IC IVAU` NOP because we
111
+ * don't emulate caches.
112
+ */
113
{ .name = "IC_IALLUIS", .state = ARM_CP_STATE_AA64,
114
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0,
115
.access = PL1_W, .type = ARM_CP_NOP,
116
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
117
.accessfn = access_tocu },
118
{ .name = "IC_IVAU", .state = ARM_CP_STATE_AA64,
119
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 5, .opc2 = 1,
120
- .access = PL0_W, .type = ARM_CP_NOP,
121
+ .access = PL0_W,
122
.fgt = FGT_ICIVAU,
123
- .accessfn = access_tocu },
124
+ .accessfn = access_tocu,
125
+#ifdef CONFIG_USER_ONLY
126
+ .type = ARM_CP_NO_RAW,
127
+ .writefn = ic_ivau_write
128
+#else
129
+ .type = ARM_CP_NOP
130
+#endif
131
+ },
132
+ /* Cache ops: all NOPs since we don't emulate caches */
133
{ .name = "DC_IVAC", .state = ARM_CP_STATE_AA64,
134
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1,
135
.access = PL1_W, .accessfn = aa64_cacheop_poc_access,
69
--
136
--
70
2.20.1
137
2.34.1
71
138
72
139
diff view generated by jsdifflib
New patch
1
From: Vikram Garhwal <vikram.garhwal@amd.com>
1
2
3
Following are done to fix the coverity issues:
4
1. Change read_data to fix the CID 1512899: Out-of-bounds access (OVERRUN)
5
2. Fix match_rx_tx_data to fix CID 1512900: Logically dead code (DEADCODE)
6
3. Replace rand() in generate_random_data() with g_rand_int()
7
8
Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
9
Message-id: 20230628202758.16398-1-vikram.garhwal@amd.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
tests/qtest/xlnx-canfd-test.c | 33 +++++++++++----------------------
14
1 file changed, 11 insertions(+), 22 deletions(-)
15
16
diff --git a/tests/qtest/xlnx-canfd-test.c b/tests/qtest/xlnx-canfd-test.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qtest/xlnx-canfd-test.c
19
+++ b/tests/qtest/xlnx-canfd-test.c
20
@@ -XXX,XX +XXX,XX @@ static void generate_random_data(uint32_t *buf_tx, bool is_canfd_frame)
21
/* Generate random TX data for CANFD frame. */
22
if (is_canfd_frame) {
23
for (int i = 0; i < CANFD_FRAME_SIZE - 2; i++) {
24
- buf_tx[2 + i] = rand();
25
+ buf_tx[2 + i] = g_random_int();
26
}
27
} else {
28
/* Generate random TX data for CAN frame. */
29
for (int i = 0; i < CAN_FRAME_SIZE - 2; i++) {
30
- buf_tx[2 + i] = rand();
31
+ buf_tx[2 + i] = g_random_int();
32
}
33
}
34
}
35
36
-static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx)
37
+static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx,
38
+ uint32_t frame_size)
39
{
40
uint32_t int_status;
41
uint32_t fifo_status_reg_value;
42
/* At which RX FIFO the received data is stored. */
43
uint8_t store_ind = 0;
44
- bool is_canfd_frame = false;
45
46
/* Read the interrupt on CANFD rx. */
47
int_status = qtest_readl(qts, can_base_addr + R_ISR_OFFSET) & ISR_RXOK;
48
@@ -XXX,XX +XXX,XX @@ static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx)
49
buf_rx[0] = qtest_readl(qts, can_base_addr + R_RX0_ID_OFFSET);
50
buf_rx[1] = qtest_readl(qts, can_base_addr + R_RX0_DLC_OFFSET);
51
52
- is_canfd_frame = (buf_rx[1] >> DLC_FD_BIT_SHIFT) & 1;
53
-
54
- if (is_canfd_frame) {
55
- for (int i = 0; i < CANFD_FRAME_SIZE - 2; i++) {
56
- buf_rx[i + 2] = qtest_readl(qts,
57
- can_base_addr + R_RX0_DATA1_OFFSET + 4 * i);
58
- }
59
- } else {
60
- buf_rx[2] = qtest_readl(qts, can_base_addr + R_RX0_DATA1_OFFSET);
61
- buf_rx[3] = qtest_readl(qts, can_base_addr + R_RX0_DATA2_OFFSET);
62
+ for (int i = 0; i < frame_size - 2; i++) {
63
+ buf_rx[i + 2] = qtest_readl(qts,
64
+ can_base_addr + R_RX0_DATA1_OFFSET + 4 * i);
65
}
66
67
/* Clear the RX interrupt. */
68
@@ -XXX,XX +XXX,XX @@ static void match_rx_tx_data(const uint32_t *buf_tx, const uint32_t *buf_rx,
69
g_assert_cmpint((buf_rx[size] & DLC_FD_BIT_MASK), ==,
70
(buf_tx[size] & DLC_FD_BIT_MASK));
71
} else {
72
- if (!is_canfd_frame && size == 4) {
73
- break;
74
- }
75
-
76
g_assert_cmpint(buf_rx[size], ==, buf_tx[size]);
77
}
78
79
@@ -XXX,XX +XXX,XX @@ static void test_can_data_transfer(void)
80
write_data(qts, CANFD0_BASE_ADDR, buf_tx, false);
81
82
send_data(qts, CANFD0_BASE_ADDR);
83
- read_data(qts, CANFD1_BASE_ADDR, buf_rx);
84
+ read_data(qts, CANFD1_BASE_ADDR, buf_rx, CAN_FRAME_SIZE);
85
match_rx_tx_data(buf_tx, buf_rx, false);
86
87
qtest_quit(qts);
88
@@ -XXX,XX +XXX,XX @@ static void test_canfd_data_transfer(void)
89
write_data(qts, CANFD0_BASE_ADDR, buf_tx, true);
90
91
send_data(qts, CANFD0_BASE_ADDR);
92
- read_data(qts, CANFD1_BASE_ADDR, buf_rx);
93
+ read_data(qts, CANFD1_BASE_ADDR, buf_rx, CANFD_FRAME_SIZE);
94
match_rx_tx_data(buf_tx, buf_rx, true);
95
96
qtest_quit(qts);
97
@@ -XXX,XX +XXX,XX @@ static void test_can_loopback(void)
98
write_data(qts, CANFD0_BASE_ADDR, buf_tx, true);
99
100
send_data(qts, CANFD0_BASE_ADDR);
101
- read_data(qts, CANFD0_BASE_ADDR, buf_rx);
102
+ read_data(qts, CANFD0_BASE_ADDR, buf_rx, CANFD_FRAME_SIZE);
103
match_rx_tx_data(buf_tx, buf_rx, true);
104
105
generate_random_data(buf_tx, true);
106
@@ -XXX,XX +XXX,XX @@ static void test_can_loopback(void)
107
write_data(qts, CANFD1_BASE_ADDR, buf_tx, true);
108
109
send_data(qts, CANFD1_BASE_ADDR);
110
- read_data(qts, CANFD1_BASE_ADDR, buf_rx);
111
+ read_data(qts, CANFD1_BASE_ADDR, buf_rx, CANFD_FRAME_SIZE);
112
match_rx_tx_data(buf_tx, buf_rx, true);
113
114
qtest_quit(qts);
115
--
116
2.34.1
diff view generated by jsdifflib
New patch
1
From: Fabiano Rosas <farosas@suse.de>
1
2
3
This code is only relevant when TCG is present in the build. Building
4
with --disable-tcg --enable-xen on an x86 host we get:
5
6
$ ../configure --target-list=x86_64-softmmu,aarch64-softmmu --disable-tcg --enable-xen
7
$ make -j$(nproc)
8
...
9
libqemu-aarch64-softmmu.fa.p/target_arm_gdbstub.c.o: in function `m_sysreg_ptr':
10
../target/arm/gdbstub.c:358: undefined reference to `arm_v7m_get_sp_ptr'
11
../target/arm/gdbstub.c:361: undefined reference to `arm_v7m_get_sp_ptr'
12
13
libqemu-aarch64-softmmu.fa.p/target_arm_gdbstub.c.o: in function `arm_gdb_get_m_systemreg':
14
../target/arm/gdbstub.c:405: undefined reference to `arm_v7m_mrs_control'
15
16
Signed-off-by: Fabiano Rosas <farosas@suse.de>
17
Message-id: 20230628164821.16771-1-farosas@suse.de
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
21
target/arm/gdbstub.c | 4 ++++
22
1 file changed, 4 insertions(+)
23
24
diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/gdbstub.c
27
+++ b/target/arm/gdbstub.c
28
@@ -XXX,XX +XXX,XX @@ static int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg)
29
return cpu->dyn_sysreg_xml.num;
30
}
31
32
+#ifdef CONFIG_TCG
33
typedef enum {
34
M_SYSREG_MSP,
35
M_SYSREG_PSP,
36
@@ -XXX,XX +XXX,XX @@ static int arm_gen_dynamic_m_secextreg_xml(CPUState *cs, int orig_base_reg)
37
return cpu->dyn_m_secextreg_xml.num;
38
}
39
#endif
40
+#endif /* CONFIG_TCG */
41
42
const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname)
43
{
44
@@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
45
arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_regs),
46
"system-registers.xml", 0);
47
48
+#ifdef CONFIG_TCG
49
if (arm_feature(env, ARM_FEATURE_M) && tcg_enabled()) {
50
gdb_register_coprocessor(cs,
51
arm_gdb_get_m_systemreg, arm_gdb_set_m_systemreg,
52
@@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
53
}
54
#endif
55
}
56
+#endif /* CONFIG_TCG */
57
}
58
--
59
2.34.1
diff view generated by jsdifflib
1
The return value of the flatview_cb callback passed to the
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
flatview_for_each_range() function is zero if the iteration through
3
the ranges should continue, or non-zero to break out of it. Use a
4
bool for this rather than int.
5
2
3
AwSRAMCClass is larger than SysBusDeviceClass so the class size must be
4
advertised accordingly.
5
6
Fixes: 05def917e1 ("hw: arm: allwinner-sramc: Add SRAM Controller support for R40")
7
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20230628110905.38125-1-akihiko.odaki@daynix.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20210318174823.18066-2-peter.maydell@linaro.org
10
---
12
---
11
include/exec/memory.h | 6 +++---
13
hw/misc/allwinner-sramc.c | 1 +
12
tests/qtest/fuzz/generic_fuzz.c | 8 ++++----
14
1 file changed, 1 insertion(+)
13
2 files changed, 7 insertions(+), 7 deletions(-)
14
15
15
diff --git a/include/exec/memory.h b/include/exec/memory.h
16
diff --git a/hw/misc/allwinner-sramc.c b/hw/misc/allwinner-sramc.c
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/include/exec/memory.h
18
--- a/hw/misc/allwinner-sramc.c
18
+++ b/include/exec/memory.h
19
+++ b/hw/misc/allwinner-sramc.c
19
@@ -XXX,XX +XXX,XX @@ static inline FlatView *address_space_to_flatview(AddressSpace *as)
20
@@ -XXX,XX +XXX,XX @@ static const TypeInfo allwinner_sramc_info = {
20
return qatomic_rcu_read(&as->current_map);
21
.parent = TYPE_SYS_BUS_DEVICE,
21
}
22
.instance_init = allwinner_sramc_init,
22
23
.instance_size = sizeof(AwSRAMCState),
23
-typedef int (*flatview_cb)(Int128 start,
24
+ .class_size = sizeof(AwSRAMCClass),
24
- Int128 len,
25
.class_init = allwinner_sramc_class_init,
25
- const MemoryRegion*, void*);
26
+typedef bool (*flatview_cb)(Int128 start,
27
+ Int128 len,
28
+ const MemoryRegion*, void*);
29
30
void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque);
31
32
diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/tests/qtest/fuzz/generic_fuzz.c
35
+++ b/tests/qtest/fuzz/generic_fuzz.c
36
@@ -XXX,XX +XXX,XX @@ struct get_io_cb_info {
37
address_range result;
38
};
26
};
39
27
40
-static int get_io_address_cb(Int128 start, Int128 size,
41
- const MemoryRegion *mr, void *opaque) {
42
+static bool get_io_address_cb(Int128 start, Int128 size,
43
+ const MemoryRegion *mr, void *opaque) {
44
struct get_io_cb_info *info = opaque;
45
if (g_hash_table_lookup(fuzzable_memoryregions, mr)) {
46
if (info->index == 0) {
47
info->result.addr = (ram_addr_t)start;
48
info->result.size = (ram_addr_t)size;
49
info->found = 1;
50
- return 1;
51
+ return true;
52
}
53
info->index--;
54
}
55
- return 0;
56
+ return false;
57
}
58
59
/*
60
--
28
--
61
2.20.1
29
2.34.1
62
30
63
31
diff view generated by jsdifflib
New patch
1
In handle_interrupt() we use level as an index into the interrupt_vector[]
2
array. This is safe because we have checked it against env->config->nlevel,
3
but Coverity can't see that (and it is only true because each CPU config
4
sets its XCHAL_NUM_INTLEVELS to something less than MAX_NLEVELS), so it
5
complains about a possible array overrun (CID 1507131)
1
6
7
Add an assert() which will make Coverity happy and catch the unlikely
8
case of a mis-set XCHAL_NUM_INTLEVELS in future.
9
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
12
Message-id: 20230623154135.1930261-1-peter.maydell@linaro.org
13
---
14
target/xtensa/exc_helper.c | 3 +++
15
1 file changed, 3 insertions(+)
16
17
diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/xtensa/exc_helper.c
20
+++ b/target/xtensa/exc_helper.c
21
@@ -XXX,XX +XXX,XX @@ static void handle_interrupt(CPUXtensaState *env)
22
CPUState *cs = env_cpu(env);
23
24
if (level > 1) {
25
+ /* env->config->nlevel check should have ensured this */
26
+ assert(level < sizeof(env->config->interrupt_vector));
27
+
28
env->sregs[EPC1 + level - 1] = env->pc;
29
env->sregs[EPS2 + level - 2] = env->sregs[PS];
30
env->sregs[PS] =
31
--
32
2.34.1
diff view generated by jsdifflib
1
For Arm M-profile CPUs, on reset the CPU must load its initial PC and
1
We already squash the ID register field for FEAT_SPE (the Statistical
2
SP from a vector table in guest memory. Because we can't guarantee
2
Profiling Extension) because TCG does not implement it and if we
3
reset ordering, we have to handle the possibility that the ROM blob
3
advertise it to the guest the guest will crash trying to look at
4
loader's reset function has not yet run when the CPU resets, in which
4
non-existent system registers. Do the same for some other features
5
case the data in an ELF file specified by the user won't be in guest
5
which a real hardware Neoverse-V1 implements but which TCG doesn't:
6
memory to be read yet.
6
* FEAT_TRF (Self-hosted Trace Extension)
7
* Trace Macrocell system register access
8
* Memory mapped trace
9
* FEAT_AMU (Activity Monitors Extension)
10
* FEAT_MPAM (Memory Partitioning and Monitoring Extension)
11
* FEAT_NV (Nested Virtualization)
7
12
8
We work around the reset ordering problem by checking whether the ROM
13
Most of these, like FEAT_SPE, are "introspection/trace" type features
9
blob loader has any data for the address where the vector table is,
14
which QEMU is unlikely to ever implement. The odd-one-out here is
10
using rom_ptr(). Unfortunately this does not handle the possibility
15
FEAT_NV -- we could implement that and at some point we probably
11
of memory aliasing. For many M-profile boards, memory can be
16
will.
12
accessed via multiple possible physical addresses; if the board has
13
the vector table at address X but the user's ELF file loads data via
14
a different address Y which is an alias to the same underlying guest
15
RAM then rom_ptr() will not find it.
16
17
Use the new rom_ptr_for_as() function, which deals with memory
18
aliasing when locating a relevant ROM blob.
19
17
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Message-id: 20230704130647.2842917-2-peter.maydell@linaro.org
20
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
22
Message-id: 20210318174823.18066-6-peter.maydell@linaro.org
23
---
22
---
24
target/arm/cpu.c | 2 +-
23
target/arm/cpu.c | 33 +++++++++++++++++++++++++++++----
25
1 file changed, 1 insertion(+), 1 deletion(-)
24
1 file changed, 29 insertions(+), 4 deletions(-)
26
25
27
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
26
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
28
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/cpu.c
28
--- a/target/arm/cpu.c
30
+++ b/target/arm/cpu.c
29
+++ b/target/arm/cpu.c
31
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev)
30
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
32
31
33
/* Load the initial SP and PC from offset 0 and 4 in the vector table */
32
if (tcg_enabled()) {
34
vecbase = env->v7m.vecbase[env->v7m.secure];
33
/*
35
- rom = rom_ptr(vecbase, 8);
34
- * Don't report the Statistical Profiling Extension in the ID
36
+ rom = rom_ptr_for_as(s->as, vecbase, 8);
35
- * registers, because TCG doesn't implement it yet (not even a
37
if (rom) {
36
- * minimal stub version) and guests will fall over when they
38
/* Address zero is covered by ROM which hasn't yet been
37
- * try to access the non-existent system registers for it.
39
* copied into physical memory.
38
+ * Don't report some architectural features in the ID registers
39
+ * where TCG does not yet implement it (not even a minimal
40
+ * stub version). This avoids guests falling over when they
41
+ * try to access the non-existent system registers for them.
42
*/
43
+ /* FEAT_SPE (Statistical Profiling Extension) */
44
cpu->isar.id_aa64dfr0 =
45
FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, PMSVER, 0);
46
+ /* FEAT_TRF (Self-hosted Trace Extension) */
47
+ cpu->isar.id_aa64dfr0 =
48
+ FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEFILT, 0);
49
+ cpu->isar.id_dfr0 =
50
+ FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, TRACEFILT, 0);
51
+ /* Trace Macrocell system register access */
52
+ cpu->isar.id_aa64dfr0 =
53
+ FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, TRACEVER, 0);
54
+ cpu->isar.id_dfr0 =
55
+ FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, COPTRC, 0);
56
+ /* Memory mapped trace */
57
+ cpu->isar.id_dfr0 =
58
+ FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, MMAPTRC, 0);
59
+ /* FEAT_AMU (Activity Monitors Extension) */
60
+ cpu->isar.id_aa64pfr0 =
61
+ FIELD_DP64(cpu->isar.id_aa64pfr0, ID_AA64PFR0, AMU, 0);
62
+ cpu->isar.id_pfr0 =
63
+ FIELD_DP32(cpu->isar.id_pfr0, ID_PFR0, AMU, 0);
64
+ /* FEAT_MPAM (Memory Partitioning and Monitoring Extension) */
65
+ cpu->isar.id_aa64pfr0 =
66
+ FIELD_DP64(cpu->isar.id_aa64pfr0, ID_AA64PFR0, MPAM, 0);
67
+ /* FEAT_NV (Nested Virtualization) */
68
+ cpu->isar.id_aa64mmfr2 =
69
+ FIELD_DP64(cpu->isar.id_aa64mmfr2, ID_AA64MMFR2, NV, 0);
70
}
71
72
/* MPU can be configured out of a PMSA CPU either by setting has-mpu
40
--
73
--
41
2.20.1
74
2.34.1
42
75
43
76
diff view generated by jsdifflib
1
For accesses to rom blob data before or during reset, we have a
1
Now that we have implemented support for FEAT_LSE2, we can define
2
function rom_ptr() which looks for a rom blob that would be loaded to
2
a CPU model for the Neoverse-V1, and enable it for the virt and
3
the specified address, and returns a pointer into the rom blob data
3
sbsa-ref boards.
4
corresponding to that address. This allows board or CPU code to say
5
"what is the data that is going to be loaded to this address?".
6
7
However, this function does not take account of memory region
8
aliases. If for instance a machine model has RAM at address
9
0x0000_0000 which is aliased to also appear at 0x1000_0000, a
10
rom_ptr() query for address 0x0000_0000 will only return a match if
11
the guest image provided by the user was loaded at 0x0000_0000 and
12
not if it was loaded at 0x1000_0000, even though they are the same
13
RAM and a run-time guest CPU read of 0x0000_0000 will read the data
14
loaded to 0x1000_0000.
15
16
Provide a new function rom_ptr_for_as() which takes an AddressSpace
17
argument, so that it can check whether the MemoryRegion corresponding
18
to the address is also mapped anywhere else in the AddressSpace and
19
look for rom blobs that loaded to that alias.
20
4
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Message-id: 20230704130647.2842917-3-peter.maydell@linaro.org
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
23
Message-id: 20210318174823.18066-5-peter.maydell@linaro.org
24
---
9
---
25
include/hw/loader.h | 31 +++++++++++++++++++
10
docs/system/arm/virt.rst | 1 +
26
hw/core/loader.c | 75 +++++++++++++++++++++++++++++++++++++++++++++
11
hw/arm/sbsa-ref.c | 1 +
27
2 files changed, 106 insertions(+)
12
hw/arm/virt.c | 1 +
28
13
target/arm/tcg/cpu64.c | 128 +++++++++++++++++++++++++++++++++++++++
29
diff --git a/include/hw/loader.h b/include/hw/loader.h
14
4 files changed, 131 insertions(+)
30
index XXXXXXX..XXXXXXX 100644
15
31
--- a/include/hw/loader.h
16
diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst
32
+++ b/include/hw/loader.h
17
index XXXXXXX..XXXXXXX 100644
33
@@ -XXX,XX +XXX,XX @@ void rom_transaction_end(bool commit);
18
--- a/docs/system/arm/virt.rst
34
19
+++ b/docs/system/arm/virt.rst
35
int rom_copy(uint8_t *dest, hwaddr addr, size_t size);
20
@@ -XXX,XX +XXX,XX @@ Supported guest CPU types:
36
void *rom_ptr(hwaddr addr, size_t size);
21
- ``a64fx`` (64-bit)
37
+/**
22
- ``host`` (with KVM only)
38
+ * rom_ptr_for_as: Return a pointer to ROM blob data for the address
23
- ``neoverse-n1`` (64-bit)
39
+ * @as: AddressSpace to look for the ROM blob in
24
+- ``neoverse-v1`` (64-bit)
40
+ * @addr: Address within @as
25
- ``max`` (same as ``host`` for KVM; best possible emulation with TCG)
41
+ * @size: size of data required in bytes
26
42
+ *
27
Note that the default is ``cortex-a15``, so for an AArch64 guest you must
43
+ * Returns: pointer into the data which backs the matching ROM blob,
28
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
44
+ * or NULL if no blob covers the address range.
29
index XXXXXXX..XXXXXXX 100644
45
+ *
30
--- a/hw/arm/sbsa-ref.c
46
+ * This function looks for a ROM blob which covers the specified range
31
+++ b/hw/arm/sbsa-ref.c
47
+ * of bytes of length @size starting at @addr within the address space
32
@@ -XXX,XX +XXX,XX @@ static const char * const valid_cpus[] = {
48
+ * @as. This is useful for code which runs as part of board
33
ARM_CPU_TYPE_NAME("cortex-a57"),
49
+ * initialization or CPU reset which wants to read data that is part
34
ARM_CPU_TYPE_NAME("cortex-a72"),
50
+ * of a user-supplied guest image or other guest memory contents, but
35
ARM_CPU_TYPE_NAME("neoverse-n1"),
51
+ * which runs before the ROM loader's reset function has copied the
36
+ ARM_CPU_TYPE_NAME("neoverse-v1"),
52
+ * blobs into guest memory.
37
ARM_CPU_TYPE_NAME("max"),
53
+ *
38
};
54
+ * rom_ptr_for_as() will look not just for blobs loaded directly to
39
55
+ * the specified address, but also for blobs which were loaded to an
40
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
56
+ * alias of the region at a different location in the AddressSpace.
41
index XXXXXXX..XXXXXXX 100644
57
+ * In other words, if a machine model has RAM at address 0x0000_0000
42
--- a/hw/arm/virt.c
58
+ * which is aliased to also appear at 0x1000_0000, rom_ptr_for_as()
43
+++ b/hw/arm/virt.c
59
+ * will return the correct data whether the guest image was linked and
44
@@ -XXX,XX +XXX,XX @@ static const char *valid_cpus[] = {
60
+ * loaded at 0x0000_0000 or 0x1000_0000. Contrast rom_ptr(), which
45
ARM_CPU_TYPE_NAME("cortex-a76"),
61
+ * will only return data if the image load address is an exact match
46
ARM_CPU_TYPE_NAME("a64fx"),
62
+ * with the queried address.
47
ARM_CPU_TYPE_NAME("neoverse-n1"),
63
+ *
48
+ ARM_CPU_TYPE_NAME("neoverse-v1"),
64
+ * New code should prefer to use rom_ptr_for_as() instead of
49
#endif
65
+ * rom_ptr().
50
ARM_CPU_TYPE_NAME("cortex-a53"),
66
+ */
51
ARM_CPU_TYPE_NAME("cortex-a57"),
67
+void *rom_ptr_for_as(AddressSpace *as, hwaddr addr, size_t size);
52
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
68
void hmp_info_roms(Monitor *mon, const QDict *qdict);
53
index XXXXXXX..XXXXXXX 100644
69
54
--- a/target/arm/tcg/cpu64.c
70
#define rom_add_file_fixed(_f, _a, _i) \
55
+++ b/target/arm/tcg/cpu64.c
71
diff --git a/hw/core/loader.c b/hw/core/loader.c
56
@@ -XXX,XX +XXX,XX @@ static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu)
72
index XXXXXXX..XXXXXXX 100644
57
define_arm_cp_regs(cpu, neoverse_n1_cp_reginfo);
73
--- a/hw/core/loader.c
74
+++ b/hw/core/loader.c
75
@@ -XXX,XX +XXX,XX @@ void *rom_ptr(hwaddr addr, size_t size)
76
return rom->data + (addr - rom->addr);
77
}
58
}
78
59
79
+typedef struct FindRomCBData {
60
+static const ARMCPRegInfo neoverse_v1_cp_reginfo[] = {
80
+ size_t size; /* Amount of data we want from ROM, in bytes */
61
+ { .name = "CPUECTLR2_EL1", .state = ARM_CP_STATE_AA64,
81
+ MemoryRegion *mr; /* MR at the unaliased guest addr */
62
+ .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 5,
82
+ hwaddr xlat; /* Offset of addr within mr */
63
+ .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
83
+ void *rom; /* Output: rom data pointer, if found */
64
+ { .name = "CPUPPMCR_EL3", .state = ARM_CP_STATE_AA64,
84
+} FindRomCBData;
65
+ .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 2, .opc2 = 0,
85
+
66
+ .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
86
+static bool find_rom_cb(Int128 start, Int128 len, const MemoryRegion *mr,
67
+ { .name = "CPUPPMCR2_EL3", .state = ARM_CP_STATE_AA64,
87
+ hwaddr offset_in_region, void *opaque)
68
+ .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 2, .opc2 = 1,
88
+{
69
+ .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
89
+ FindRomCBData *cbdata = opaque;
70
+ { .name = "CPUPPMCR3_EL3", .state = ARM_CP_STATE_AA64,
90
+ hwaddr alias_addr;
71
+ .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 2, .opc2 = 6,
91
+
72
+ .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
92
+ if (mr != cbdata->mr) {
73
+};
93
+ return false;
74
+
94
+ }
75
+static void define_neoverse_v1_cp_reginfo(ARMCPU *cpu)
95
+
96
+ alias_addr = int128_get64(start) + cbdata->xlat - offset_in_region;
97
+ cbdata->rom = rom_ptr(alias_addr, cbdata->size);
98
+ if (!cbdata->rom) {
99
+ return false;
100
+ }
101
+ /* Found a match, stop iterating */
102
+ return true;
103
+}
104
+
105
+void *rom_ptr_for_as(AddressSpace *as, hwaddr addr, size_t size)
106
+{
76
+{
107
+ /*
77
+ /*
108
+ * Find any ROM data for the given guest address range. If there
78
+ * The Neoverse V1 has all of the Neoverse N1's IMPDEF
109
+ * is a ROM blob then return a pointer to the host memory
79
+ * registers and a few more of its own.
110
+ * corresponding to 'addr'; otherwise return NULL.
111
+ *
112
+ * We look not only for ROM blobs that were loaded directly to
113
+ * addr, but also for ROM blobs that were loaded to aliases of
114
+ * that memory at other addresses within the AddressSpace.
115
+ *
116
+ * Note that we do not check @as against the 'as' member in the
117
+ * 'struct Rom' returned by rom_ptr(). The Rom::as is the
118
+ * AddressSpace which the rom blob should be written to, whereas
119
+ * our @as argument is the AddressSpace which we are (effectively)
120
+ * reading from, and the same underlying RAM will often be visible
121
+ * in multiple AddressSpaces. (A common example is a ROM blob
122
+ * written to the 'system' address space but then read back via a
123
+ * CPU's cpu->as pointer.) This does mean we might potentially
124
+ * return a false-positive match if a ROM blob was loaded into an
125
+ * AS which is entirely separate and distinct from the one we're
126
+ * querying, but this issue exists also for rom_ptr() and hasn't
127
+ * caused any problems in practice.
128
+ */
80
+ */
129
+ FlatView *fv;
81
+ define_arm_cp_regs(cpu, neoverse_n1_cp_reginfo);
130
+ void *rom;
82
+ define_arm_cp_regs(cpu, neoverse_v1_cp_reginfo);
131
+ hwaddr len_unused;
132
+ FindRomCBData cbdata = {};
133
+
134
+ /* Easy case: there's data at the actual address */
135
+ rom = rom_ptr(addr, size);
136
+ if (rom) {
137
+ return rom;
138
+ }
139
+
140
+ RCU_READ_LOCK_GUARD();
141
+
142
+ fv = address_space_to_flatview(as);
143
+ cbdata.mr = flatview_translate(fv, addr, &cbdata.xlat, &len_unused,
144
+ false, MEMTXATTRS_UNSPECIFIED);
145
+ if (!cbdata.mr) {
146
+ /* Nothing at this address, so there can't be any aliasing */
147
+ return NULL;
148
+ }
149
+ cbdata.size = size;
150
+ flatview_for_each_range(fv, find_rom_cb, &cbdata);
151
+ return cbdata.rom;
152
+}
83
+}
153
+
84
+
154
void hmp_info_roms(Monitor *mon, const QDict *qdict)
85
static void aarch64_neoverse_n1_initfn(Object *obj)
155
{
86
{
156
Rom *rom;
87
ARMCPU *cpu = ARM_CPU(obj);
88
@@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_n1_initfn(Object *obj)
89
define_neoverse_n1_cp_reginfo(cpu);
90
}
91
92
+static void aarch64_neoverse_v1_initfn(Object *obj)
93
+{
94
+ ARMCPU *cpu = ARM_CPU(obj);
95
+
96
+ cpu->dtb_compatible = "arm,neoverse-v1";
97
+ set_feature(&cpu->env, ARM_FEATURE_V8);
98
+ set_feature(&cpu->env, ARM_FEATURE_NEON);
99
+ set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
100
+ set_feature(&cpu->env, ARM_FEATURE_AARCH64);
101
+ set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
102
+ set_feature(&cpu->env, ARM_FEATURE_EL2);
103
+ set_feature(&cpu->env, ARM_FEATURE_EL3);
104
+ set_feature(&cpu->env, ARM_FEATURE_PMU);
105
+
106
+ /* Ordered by 3.2.4 AArch64 registers by functional group */
107
+ cpu->clidr = 0x82000023;
108
+ cpu->ctr = 0xb444c004; /* With DIC and IDC set */
109
+ cpu->dcz_blocksize = 4;
110
+ cpu->id_aa64afr0 = 0x00000000;
111
+ cpu->id_aa64afr1 = 0x00000000;
112
+ cpu->isar.id_aa64dfr0 = 0x000001f210305519ull;
113
+ cpu->isar.id_aa64dfr1 = 0x00000000;
114
+ cpu->isar.id_aa64isar0 = 0x1011111110212120ull; /* with FEAT_RNG */
115
+ cpu->isar.id_aa64isar1 = 0x0111000001211032ull;
116
+ cpu->isar.id_aa64mmfr0 = 0x0000000000101125ull;
117
+ cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull;
118
+ cpu->isar.id_aa64mmfr2 = 0x0220011102101011ull;
119
+ cpu->isar.id_aa64pfr0 = 0x1101110120111112ull; /* GIC filled in later */
120
+ cpu->isar.id_aa64pfr1 = 0x0000000000000020ull;
121
+ cpu->id_afr0 = 0x00000000;
122
+ cpu->isar.id_dfr0 = 0x15011099;
123
+ cpu->isar.id_isar0 = 0x02101110;
124
+ cpu->isar.id_isar1 = 0x13112111;
125
+ cpu->isar.id_isar2 = 0x21232042;
126
+ cpu->isar.id_isar3 = 0x01112131;
127
+ cpu->isar.id_isar4 = 0x00010142;
128
+ cpu->isar.id_isar5 = 0x11011121;
129
+ cpu->isar.id_isar6 = 0x01100111;
130
+ cpu->isar.id_mmfr0 = 0x10201105;
131
+ cpu->isar.id_mmfr1 = 0x40000000;
132
+ cpu->isar.id_mmfr2 = 0x01260000;
133
+ cpu->isar.id_mmfr3 = 0x02122211;
134
+ cpu->isar.id_mmfr4 = 0x01021110;
135
+ cpu->isar.id_pfr0 = 0x21110131;
136
+ cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */
137
+ cpu->isar.id_pfr2 = 0x00000011;
138
+ cpu->midr = 0x411FD402; /* r1p2 */
139
+ cpu->revidr = 0;
140
+
141
+ /*
142
+ * The Neoverse-V1 r1p2 TRM lists 32-bit format CCSIDR_EL1 values,
143
+ * but also says it implements CCIDX, which means they should be
144
+ * 64-bit format. So we here use values which are based on the textual
145
+ * information in chapter 2 of the TRM (and on the fact that
146
+ * sets * associativity * linesize == cachesize).
147
+ *
148
+ * The 64-bit CCSIDR_EL1 format is:
149
+ * [55:32] number of sets - 1
150
+ * [23:3] associativity - 1
151
+ * [2:0] log2(linesize) - 4
152
+ * so 0 == 16 bytes, 1 == 32 bytes, 2 == 64 bytes, etc
153
+ *
154
+ * L1: 4-way set associative 64-byte line size, total size 64K,
155
+ * so sets is 256.
156
+ *
157
+ * L2: 8-way set associative, 64 byte line size, either 512K or 1MB.
158
+ * We pick 1MB, so this has 2048 sets.
159
+ *
160
+ * L3: No L3 (this matches the CLIDR_EL1 value).
161
+ */
162
+ cpu->ccsidr[0] = 0x000000ff0000001aull; /* 64KB L1 dcache */
163
+ cpu->ccsidr[1] = 0x000000ff0000001aull; /* 64KB L1 icache */
164
+ cpu->ccsidr[2] = 0x000007ff0000003aull; /* 1MB L2 cache */
165
+
166
+ /* From 3.2.115 SCTLR_EL3 */
167
+ cpu->reset_sctlr = 0x30c50838;
168
+
169
+ /* From 3.4.8 ICC_CTLR_EL3 and 3.4.23 ICH_VTR_EL2 */
170
+ cpu->gic_num_lrs = 4;
171
+ cpu->gic_vpribits = 5;
172
+ cpu->gic_vprebits = 5;
173
+ cpu->gic_pribits = 5;
174
+
175
+ /* From 3.5.1 AdvSIMD AArch64 register summary */
176
+ cpu->isar.mvfr0 = 0x10110222;
177
+ cpu->isar.mvfr1 = 0x13211111;
178
+ cpu->isar.mvfr2 = 0x00000043;
179
+
180
+ /* From 3.7.5 ID_AA64ZFR0_EL1 */
181
+ cpu->isar.id_aa64zfr0 = 0x0000100000100000;
182
+ cpu->sve_vq.supported = (1 << 0) /* 128bit */
183
+ | (1 << 1); /* 256bit */
184
+
185
+ /* From 5.5.1 AArch64 PMU register summary */
186
+ cpu->isar.reset_pmcr_el0 = 0x41213000;
187
+
188
+ define_neoverse_v1_cp_reginfo(cpu);
189
+
190
+ aarch64_add_pauth_properties(obj);
191
+ aarch64_add_sve_properties(obj);
192
+}
193
+
194
/*
195
* -cpu max: a CPU with as many features enabled as our emulation supports.
196
* The version of '-cpu max' for qemu-system-arm is defined in cpu32.c;
197
@@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo aarch64_cpus[] = {
198
{ .name = "cortex-a76", .initfn = aarch64_a76_initfn },
199
{ .name = "a64fx", .initfn = aarch64_a64fx_initfn },
200
{ .name = "neoverse-n1", .initfn = aarch64_neoverse_n1_initfn },
201
+ { .name = "neoverse-v1", .initfn = aarch64_neoverse_v1_initfn },
202
};
203
204
static void aarch64_cpu_register_types(void)
157
--
205
--
158
2.20.1
206
2.34.1
159
207
160
208
diff view generated by jsdifflib
1
Add a documentation comment describing flatview_for_each_range().
1
If you build QEMU with the clang sanitizer enabled, you can see it
2
fire when running the arm-cpu-features test:
3
4
$ QTEST_QEMU_BINARY=./build/arm-clang/qemu-system-aarch64 ./build/arm-clang/tests/qtest/arm-cpu-features
5
[...]
6
../../target/arm/cpu64.c:125:19: runtime error: shift exponent 64 is too large for 64-bit type 'unsigned long long'
7
[...]
8
9
This happens because the user can specify some incorrect SVE
10
properties that result in our calculating a max_vq of 0. We catch
11
this and error out, but before we do that we calculate
12
13
vq_mask = MAKE_64BIT_MASK(0, max_vq);$
14
15
and the MAKE_64BIT_MASK() call is only valid for lengths that are
16
greater than zero, so we hit the undefined behaviour.
17
18
Change the logic so that if max_vq is 0 we specifically set vq_mask
19
to 0 without going via MAKE_64BIT_MASK(). This lets us drop the
20
max_vq check from the error-exit logic, because if max_vq is 0 then
21
vq_map must now be 0.
22
23
The UB only happens in the case where the user passed us an incorrect
24
set of SVE properties, so it's not a big problem in practice.
2
25
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
28
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
29
Message-id: 20230704154332.3014896-1-peter.maydell@linaro.org
6
Message-id: 20210318174823.18066-3-peter.maydell@linaro.org
7
---
30
---
8
include/exec/memory.h | 26 ++++++++++++++++++++++++--
31
target/arm/cpu64.c | 4 ++--
9
1 file changed, 24 insertions(+), 2 deletions(-)
32
1 file changed, 2 insertions(+), 2 deletions(-)
10
33
11
diff --git a/include/exec/memory.h b/include/exec/memory.h
34
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
12
index XXXXXXX..XXXXXXX 100644
35
index XXXXXXX..XXXXXXX 100644
13
--- a/include/exec/memory.h
36
--- a/target/arm/cpu64.c
14
+++ b/include/exec/memory.h
37
+++ b/target/arm/cpu64.c
15
@@ -XXX,XX +XXX,XX @@ static inline FlatView *address_space_to_flatview(AddressSpace *as)
38
@@ -XXX,XX +XXX,XX @@ void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
16
return qatomic_rcu_read(&as->current_map);
39
vq = ctz32(tmp) + 1;
17
}
40
18
41
max_vq = vq <= ARM_MAX_VQ ? vq - 1 : ARM_MAX_VQ;
19
+/**
42
- vq_mask = MAKE_64BIT_MASK(0, max_vq);
20
+ * typedef flatview_cb: callback for flatview_for_each_range()
43
+ vq_mask = max_vq > 0 ? MAKE_64BIT_MASK(0, max_vq) : 0;
21
+ *
44
vq_map = vq_supported & ~vq_init & vq_mask;
22
+ * @start: start address of the range within the FlatView
45
23
+ * @len: length of the range in bytes
46
- if (max_vq == 0 || vq_map == 0) {
24
+ * @mr: MemoryRegion covering this range
47
+ if (vq_map == 0) {
25
+ * @opaque: data pointer passed to flatview_for_each_range()
48
error_setg(errp, "cannot disable sve%d", vq * 128);
26
+ *
49
error_append_hint(errp, "Disabling sve%d results in all "
27
+ * Returns: true to stop the iteration, false to keep going.
50
"vector lengths being disabled.\n",
28
+ */
29
typedef bool (*flatview_cb)(Int128 start,
30
Int128 len,
31
- const MemoryRegion*, void*);
32
+ const MemoryRegion *mr,
33
+ void *opaque);
34
35
-void flatview_for_each_range(FlatView *fv, flatview_cb cb , void *opaque);
36
+/**
37
+ * flatview_for_each_range: Iterate through a FlatView
38
+ * @fv: the FlatView to iterate through
39
+ * @cb: function to call for each range
40
+ * @opaque: opaque data pointer to pass to @cb
41
+ *
42
+ * A FlatView is made up of a list of non-overlapping ranges, each of
43
+ * which is a slice of a MemoryRegion. This function iterates through
44
+ * each range in @fv, calling @cb. The callback function can terminate
45
+ * iteration early by returning 'true'.
46
+ */
47
+void flatview_for_each_range(FlatView *fv, flatview_cb cb, void *opaque);
48
49
/**
50
* struct MemoryRegionSection: describes a fragment of a #MemoryRegion
51
--
51
--
52
2.20.1
52
2.34.1
53
53
54
54
diff view generated by jsdifflib