1
Just a collection of bug fixes this time around...
1
A last small test of bug fixes before rc1.
2
2
3
thanks
3
thanks
4
-- PMM
4
-- PMM
5
5
6
The following changes since commit 2a6ae69154542caa91dd17c40fd3f5ffbec300de:
6
The following changes since commit ed8ad9728a9c0eec34db9dff61dfa2f1dd625637:
7
7
8
Merge tag 'pull-maintainer-ominbus-030723-1' of https://gitlab.com/stsquad/qemu into staging (2023-07-04 08:36:44 +0200)
8
Merge tag 'pull-tpm-2023-07-14-1' of https://github.com/stefanberger/qemu-tpm into staging (2023-07-15 14:54:04 +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-20230704
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230717
13
13
14
for you to fetch changes up to 86a78272f094857b4eda79d721c116e93942aa9a:
14
for you to fetch changes up to c2c1c4a35c7c2b1a4140b0942b9797c857e476a4:
15
15
16
target/xtensa: Assert that interrupt level is within bounds (2023-07-04 14:27:08 +0100)
16
hw/nvram: Avoid unnecessary Xilinx eFuse backstore write (2023-07-17 11:05:52 +0100)
17
17
18
----------------------------------------------------------------
18
----------------------------------------------------------------
19
target-arm queue:
19
target-arm queue:
20
* Add raw_writes ops for register whose write induce TLB maintenance
20
* hw/arm/sbsa-ref: set 'slots' property of xhci
21
* hw/arm/sbsa-ref: use XHCI to replace EHCI
21
* linux-user: Remove pointless NULL check in clock_adjtime handling
22
* Avoid splitting Zregs across lines in dump
22
* ptw: Fix S1_ptw_translate() debug path
23
* Dump ZA[] when active
23
* ptw: Account for FEAT_RME when applying {N}SW, SA bits
24
* Fix SME full tile indexing
24
* accel/tcg: Zero-pad PC in TCG CPU exec trace lines
25
* Handle IC IVAU to improve compatibility with JITs
25
* hw/nvram: Avoid unnecessary Xilinx eFuse backstore write
26
* xlnx-canfd-test: Fix code coverity issues
27
* gdbstub: Guard M-profile code with CONFIG_TCG
28
* allwinner-sramc: Set class_size
29
* target/xtensa: Assert that interrupt level is within bounds
30
26
31
----------------------------------------------------------------
27
----------------------------------------------------------------
32
Akihiko Odaki (1):
28
Peter Maydell (5):
33
hw: arm: allwinner-sramc: Set class_size
29
linux-user: Remove pointless NULL check in clock_adjtime handling
30
target/arm/ptw.c: Add comments to S1Translate struct fields
31
target/arm: Fix S1_ptw_translate() debug path
32
target/arm/ptw.c: Account for FEAT_RME when applying {N}SW, SA bits
33
accel/tcg: Zero-pad PC in TCG CPU exec trace lines
34
34
35
Eric Auger (1):
35
Tong Ho (1):
36
target/arm: Add raw_writes ops for register whose write induce TLB maintenance
36
hw/nvram: Avoid unnecessary Xilinx eFuse backstore write
37
38
Fabiano Rosas (1):
39
target/arm: gdbstub: Guard M-profile code with CONFIG_TCG
40
41
John Högberg (2):
42
target/arm: Handle IC IVAU to improve compatibility with JITs
43
tests/tcg/aarch64: Add testcases for IC IVAU and dual-mapped code
44
45
Peter Maydell (1):
46
target/xtensa: Assert that interrupt level is within bounds
47
48
Richard Henderson (3):
49
target/arm: Avoid splitting Zregs across lines in dump
50
target/arm: Dump ZA[] when active
51
target/arm: Fix SME full tile indexing
52
53
Vikram Garhwal (1):
54
tests/qtest: xlnx-canfd-test: Fix code coverity issues
55
37
56
Yuquan Wang (1):
38
Yuquan Wang (1):
57
hw/arm/sbsa-ref: use XHCI to replace EHCI
39
hw/arm/sbsa-ref: set 'slots' property of xhci
58
40
59
docs/system/arm/sbsa.rst | 5 +-
41
accel/tcg/cpu-exec.c | 4 +--
60
hw/arm/sbsa-ref.c | 23 +++--
42
accel/tcg/translate-all.c | 2 +-
61
hw/misc/allwinner-sramc.c | 1 +
43
hw/arm/sbsa-ref.c | 1 +
62
target/arm/cpu.c | 65 ++++++++-----
44
hw/nvram/xlnx-efuse.c | 11 ++++--
63
target/arm/gdbstub.c | 4 +
45
linux-user/syscall.c | 12 +++----
64
target/arm/helper.c | 70 +++++++++++---
46
target/arm/ptw.c | 90 +++++++++++++++++++++++++++++++++++++++++------
65
target/arm/tcg/translate-sme.c | 24 +++--
47
6 files changed, 98 insertions(+), 22 deletions(-)
66
target/xtensa/exc_helper.c | 3 +
67
tests/qtest/xlnx-canfd-test.c | 33 +++----
68
tests/tcg/aarch64/icivau.c | 189 ++++++++++++++++++++++++++++++++++++++
69
tests/tcg/aarch64/sme-outprod1.c | 83 +++++++++++++++++
70
hw/arm/Kconfig | 2 +-
71
tests/tcg/aarch64/Makefile.target | 13 ++-
72
13 files changed, 436 insertions(+), 79 deletions(-)
73
create mode 100644 tests/tcg/aarch64/icivau.c
74
create mode 100644 tests/tcg/aarch64/sme-outprod1.c
75
diff view generated by jsdifflib
Deleted patch
1
From: Eric Auger <eric.auger@redhat.com>
2
1
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: Yuquan Wang <wangyuquan1236@phytium.com.cn>
1
From: Yuquan Wang <wangyuquan1236@phytium.com.cn>
2
2
3
The current sbsa-ref cannot use EHCI controller which is only
3
This extends the slots of xhci to 64, since the default xhci_sysbus
4
able to do 32-bit DMA, since sbsa-ref doesn't have RAM below 4GB.
4
just supports one slot.
5
Hence, this uses XHCI to provide a usb controller with 64-bit
6
DMA capablity instead of EHCI.
7
5
8
We bump the platform version to 0.3 with this change. Although the
6
Signed-off-by: Wang Yuquan <wangyuquan1236@phytium.com.cn>
9
hardware at the USB controller address changes, the firmware and
7
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
10
Linux can both cope with this -- on an older non-XHCI-aware
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
firmware/kernel setup the probe routine simply fails and the guest
9
Reviewed-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
12
proceeds without any USB. (This isn't a loss of functionality,
10
Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
13
because the old USB controller never worked in the first place.) So
11
Message-id: 20230710063750.473510-2-wangyuquan1236@phytium.com.cn
14
we can call this a backwards-compatible change and only bump the
15
minor version.
16
17
Signed-off-by: Yuquan Wang <wangyuquan1236@phytium.com.cn>
18
Message-id: 20230621103847.447508-2-wangyuquan1236@phytium.com.cn
19
[PMM: tweaked commit message; add line to docs about what
20
changes in platform version 0.3]
21
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
---
13
---
24
docs/system/arm/sbsa.rst | 5 ++++-
14
hw/arm/sbsa-ref.c | 1 +
25
hw/arm/sbsa-ref.c | 23 +++++++++++++----------
15
1 file changed, 1 insertion(+)
26
hw/arm/Kconfig | 2 +-
27
3 files changed, 18 insertions(+), 12 deletions(-)
28
16
29
diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst
30
index XXXXXXX..XXXXXXX 100644
31
--- a/docs/system/arm/sbsa.rst
32
+++ b/docs/system/arm/sbsa.rst
33
@@ -XXX,XX +XXX,XX @@ The ``sbsa-ref`` board supports:
34
- A configurable number of AArch64 CPUs
35
- GIC version 3
36
- System bus AHCI controller
37
- - System bus EHCI controller
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
17
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
50
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/arm/sbsa-ref.c
19
--- a/hw/arm/sbsa-ref.c
52
+++ b/hw/arm/sbsa-ref.c
20
+++ b/hw/arm/sbsa-ref.c
53
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ static void create_xhci(const SBSAMachineState *sms)
54
#include "hw/pci-host/gpex.h"
22
hwaddr base = sbsa_ref_memmap[SBSA_XHCI].base;
55
#include "hw/qdev-properties.h"
23
int irq = sbsa_ref_irqmap[SBSA_XHCI];
56
#include "hw/usb.h"
24
DeviceState *dev = qdev_new(TYPE_XHCI_SYSBUS);
57
+#include "hw/usb/xhci.h"
25
+ qdev_prop_set_uint32(dev, "slots", XHCI_MAXSLOTS);
58
#include "hw/char/pl011.h"
26
59
#include "hw/watchdog/sbsa_gwdt.h"
27
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
60
#include "net/net.h"
28
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
61
@@ -XXX,XX +XXX,XX @@ enum {
62
SBSA_SECURE_UART_MM,
63
SBSA_SECURE_MEM,
64
SBSA_AHCI,
65
- SBSA_EHCI,
66
+ SBSA_XHCI,
67
};
68
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
128
index XXXXXXX..XXXXXXX 100644
129
--- a/hw/arm/Kconfig
130
+++ b/hw/arm/Kconfig
131
@@ -XXX,XX +XXX,XX @@ config SBSA_REF
132
select PL011 # UART
133
select PL031 # RTC
134
select PL061 # GPIO
135
- select USB_EHCI_SYSBUS
136
+ select USB_XHCI_SYSBUS
137
select WDT_SBSA
138
select BOCHS_DISPLAY
139
140
--
29
--
141
2.34.1
30
2.34.1
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
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
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
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
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
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.
7
8
The test case relies only on assembler support for SME, since
9
no release of GCC recognizes -march=armv9-a+sme yet.
10
11
Cc: qemu-stable@nongnu.org
12
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1620
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20230622151201.1578522-5-richard.henderson@linaro.org
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
18
target/arm/tcg/translate-sme.c | 24 ++++++---
19
tests/tcg/aarch64/sme-outprod1.c | 83 +++++++++++++++++++++++++++++++
20
tests/tcg/aarch64/Makefile.target | 10 ++--
21
3 files changed, 108 insertions(+), 9 deletions(-)
22
create mode 100644 tests/tcg/aarch64/sme-outprod1.c
23
24
diff --git a/target/arm/tcg/translate-sme.c b/target/arm/tcg/translate-sme.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/tcg/translate-sme.c
27
+++ b/target/arm/tcg/translate-sme.c
28
@@ -XXX,XX +XXX,XX @@ static TCGv_ptr get_tile_rowcol(DisasContext *s, int esz, int rs,
29
return addr;
30
}
31
32
+/*
33
+ * Resolve tile.size[0] to a host pointer.
34
+ * Used by e.g. outer product insns where we require the entire tile.
35
+ */
36
+static TCGv_ptr get_tile(DisasContext *s, int esz, int tile)
37
+{
38
+ TCGv_ptr addr = tcg_temp_new_ptr();
39
+ int offset;
40
+
41
+ offset = tile * sizeof(ARMVectorReg) + offsetof(CPUARMState, zarray);
42
+
43
+ tcg_gen_addi_ptr(addr, cpu_env, offset);
44
+ return addr;
45
+}
46
+
47
static bool trans_ZERO(DisasContext *s, arg_ZERO *a)
48
{
49
if (!dc_isar_feature(aa64_sme, s)) {
50
@@ -XXX,XX +XXX,XX @@ static bool do_adda(DisasContext *s, arg_adda *a, MemOp esz,
51
return true;
52
}
53
54
- /* Sum XZR+zad to find ZAd. */
55
- za = get_tile_rowcol(s, esz, 31, a->zad, false);
56
+ za = get_tile(s, esz, a->zad);
57
zn = vec_full_reg_ptr(s, a->zn);
58
pn = pred_full_reg_ptr(s, a->pn);
59
pm = pred_full_reg_ptr(s, a->pm);
60
@@ -XXX,XX +XXX,XX @@ static bool do_outprod(DisasContext *s, arg_op *a, MemOp esz,
61
return true;
62
}
63
64
- /* Sum XZR+zad to find ZAd. */
65
- za = get_tile_rowcol(s, esz, 31, a->zad, false);
66
+ za = get_tile(s, esz, a->zad);
67
zn = vec_full_reg_ptr(s, a->zn);
68
zm = vec_full_reg_ptr(s, a->zm);
69
pn = pred_full_reg_ptr(s, a->pn);
70
@@ -XXX,XX +XXX,XX @@ static bool do_outprod_fpst(DisasContext *s, arg_op *a, MemOp esz,
71
return true;
72
}
73
74
- /* Sum XZR+zad to find ZAd. */
75
- za = get_tile_rowcol(s, esz, 31, a->zad, false);
76
+ za = get_tile(s, esz, a->zad);
77
zn = vec_full_reg_ptr(s, a->zn);
78
zm = vec_full_reg_ptr(s, a->zm);
79
pn = pred_full_reg_ptr(s, a->pn);
80
diff --git a/tests/tcg/aarch64/sme-outprod1.c b/tests/tcg/aarch64/sme-outprod1.c
81
new file mode 100644
82
index XXXXXXX..XXXXXXX
83
--- /dev/null
84
+++ b/tests/tcg/aarch64/sme-outprod1.c
85
@@ -XXX,XX +XXX,XX @@
86
+/*
87
+ * SME outer product, 1 x 1.
88
+ * SPDX-License-Identifier: GPL-2.0-or-later
89
+ */
90
+
91
+#include <stdio.h>
92
+
93
+extern void foo(float *dst);
94
+
95
+asm(
96
+"    .arch_extension sme\n"
97
+"    .type foo, @function\n"
98
+"foo:\n"
99
+"    stp x29, x30, [sp, -80]!\n"
100
+"    mov x29, sp\n"
101
+"    stp d8, d9, [sp, 16]\n"
102
+"    stp d10, d11, [sp, 32]\n"
103
+"    stp d12, d13, [sp, 48]\n"
104
+"    stp d14, d15, [sp, 64]\n"
105
+"    smstart\n"
106
+"    ptrue p0.s, vl4\n"
107
+"    fmov z0.s, #1.0\n"
108
+/*
109
+ * An outer product of a vector of 1.0 by itself should be a matrix of 1.0.
110
+ * Note that we are using tile 1 here (za1.s) rather than tile 0.
111
+ */
112
+"    zero {za}\n"
113
+"    fmopa za1.s, p0/m, p0/m, z0.s, z0.s\n"
114
+/*
115
+ * Read the first 4x4 sub-matrix of elements from tile 1:
116
+ * Note that za1h should be interchangable here.
117
+ */
118
+"    mov w12, #0\n"
119
+"    mova z0.s, p0/m, za1v.s[w12, #0]\n"
120
+"    mova z1.s, p0/m, za1v.s[w12, #1]\n"
121
+"    mova z2.s, p0/m, za1v.s[w12, #2]\n"
122
+"    mova z3.s, p0/m, za1v.s[w12, #3]\n"
123
+/*
124
+ * And store them to the input pointer (dst in the C code):
125
+ */
126
+"    st1w {z0.s}, p0, [x0]\n"
127
+"    add x0, x0, #16\n"
128
+"    st1w {z1.s}, p0, [x0]\n"
129
+"    add x0, x0, #16\n"
130
+"    st1w {z2.s}, p0, [x0]\n"
131
+"    add x0, x0, #16\n"
132
+"    st1w {z3.s}, p0, [x0]\n"
133
+"    smstop\n"
134
+"    ldp d8, d9, [sp, 16]\n"
135
+"    ldp d10, d11, [sp, 32]\n"
136
+"    ldp d12, d13, [sp, 48]\n"
137
+"    ldp d14, d15, [sp, 64]\n"
138
+"    ldp x29, x30, [sp], 80\n"
139
+"    ret\n"
140
+"    .size foo, . - foo"
141
+);
142
+
143
+int main()
144
+{
145
+ float dst[16];
146
+ int i, j;
147
+
148
+ foo(dst);
149
+
150
+ for (i = 0; i < 16; i++) {
151
+ if (dst[i] != 1.0f) {
152
+ break;
153
+ }
154
+ }
155
+
156
+ if (i == 16) {
157
+ return 0; /* success */
158
+ }
159
+
160
+ /* failure */
161
+ for (i = 0; i < 4; ++i) {
162
+ for (j = 0; j < 4; ++j) {
163
+ printf("%f ", (double)dst[i * 4 + j]);
164
+ }
165
+ printf("\n");
166
+ }
167
+ return 1;
168
+}
169
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
170
index XXXXXXX..XXXXXXX 100644
171
--- a/tests/tcg/aarch64/Makefile.target
172
+++ b/tests/tcg/aarch64/Makefile.target
173
@@ -XXX,XX +XXX,XX @@ config-cc.mak: Makefile
174
     $(call cc-option,-march=armv8.5-a, CROSS_CC_HAS_ARMV8_5); \
175
     $(call cc-option,-mbranch-protection=standard, CROSS_CC_HAS_ARMV8_BTI); \
176
     $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE); \
177
-     $(call cc-option,-march=armv9-a+sme, CROSS_CC_HAS_ARMV9_SME)) 3> config-cc.mak
178
+     $(call cc-option,-Wa$(COMMA)-march=armv9-a+sme, CROSS_AS_HAS_ARMV9_SME)) 3> config-cc.mak
179
-include config-cc.mak
180
181
ifneq ($(CROSS_CC_HAS_ARMV8_2),)
182
@@ -XXX,XX +XXX,XX @@ AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-5 mte-6 mte-7
183
mte-%: CFLAGS += -march=armv8.5-a+memtag
184
endif
185
186
+ifneq ($(CROSS_AS_HAS_ARMV9_SME),)
187
+AARCH64_TESTS += sme-outprod1
188
+endif
189
+
190
ifneq ($(CROSS_CC_HAS_SVE),)
191
# System Registers Tests
192
AARCH64_TESTS += sysregs
193
-ifneq ($(CROSS_CC_HAS_ARMV9_SME),)
194
-sysregs: CFLAGS+=-march=armv9-a+sme -DHAS_ARMV9_SME
195
+ifneq ($(CROSS_AS_HAS_ARMV9_SME),)
196
+sysregs: CFLAGS+=-Wa,-march=armv9-a+sme -DHAS_ARMV9_SME
197
else
198
sysregs: CFLAGS+=-march=armv8.1-a+sve
199
endif
200
--
201
2.34.1
diff view generated by jsdifflib
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
1
In the code for TARGET_NR_clock_adjtime, we set the pointer phtx to
2
the address of the local variable htx. This means it can never be
3
NULL, but later in the code we check it for NULL anyway. Coverity
4
complains about this (CID 1507683) because the NULL check comes after
5
a call to clock_adjtime() that assumes it is non-NULL.
2
6
3
AwSRAMCClass is larger than SysBusDeviceClass so the class size must be
7
Since phtx is always &htx, and is used only in three places, it's not
4
advertised accordingly.
8
really necessary. Remove it, bringing the code structure in to line
9
with that for TARGET_NR_clock_adjtime64, which already uses a simple
10
'&htx' when it wants a pointer to 'htx'.
5
11
6
Fixes: 05def917e1 ("hw: arm: allwinner-sramc: Add SRAM Controller support for R40")
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20230628110905.38125-1-akihiko.odaki@daynix.com
15
Message-id: 20230623144410.1837261-1-peter.maydell@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
16
---
13
hw/misc/allwinner-sramc.c | 1 +
17
linux-user/syscall.c | 12 +++++-------
14
1 file changed, 1 insertion(+)
18
1 file changed, 5 insertions(+), 7 deletions(-)
15
19
16
diff --git a/hw/misc/allwinner-sramc.c b/hw/misc/allwinner-sramc.c
20
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
17
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/misc/allwinner-sramc.c
22
--- a/linux-user/syscall.c
19
+++ b/hw/misc/allwinner-sramc.c
23
+++ b/linux-user/syscall.c
20
@@ -XXX,XX +XXX,XX @@ static const TypeInfo allwinner_sramc_info = {
24
@@ -XXX,XX +XXX,XX @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
21
.parent = TYPE_SYS_BUS_DEVICE,
25
#if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME)
22
.instance_init = allwinner_sramc_init,
26
case TARGET_NR_clock_adjtime:
23
.instance_size = sizeof(AwSRAMCState),
27
{
24
+ .class_size = sizeof(AwSRAMCClass),
28
- struct timex htx, *phtx = &htx;
25
.class_init = allwinner_sramc_class_init,
29
+ struct timex htx;
26
};
30
27
31
- if (target_to_host_timex(phtx, arg2) != 0) {
32
+ if (target_to_host_timex(&htx, arg2) != 0) {
33
return -TARGET_EFAULT;
34
}
35
- ret = get_errno(clock_adjtime(arg1, phtx));
36
- if (!is_error(ret) && phtx) {
37
- if (host_to_target_timex(arg2, phtx) != 0) {
38
- return -TARGET_EFAULT;
39
- }
40
+ ret = get_errno(clock_adjtime(arg1, &htx));
41
+ if (!is_error(ret) && host_to_target_timex(arg2, &htx)) {
42
+ return -TARGET_EFAULT;
43
}
44
}
45
return ret;
28
--
46
--
29
2.34.1
47
2.34.1
30
48
31
49
diff view generated by jsdifflib
1
In handle_interrupt() we use level as an index into the interrupt_vector[]
1
Add comments to the in_* fields in the S1Translate struct
2
array. This is safe because we have checked it against env->config->nlevel,
2
that explain what they're doing.
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)
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
3
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20230623154135.1930261-1-peter.maydell@linaro.org
6
Message-id: 20230710152130.3928330-2-peter.maydell@linaro.org
13
---
7
---
14
target/xtensa/exc_helper.c | 3 +++
8
target/arm/ptw.c | 40 ++++++++++++++++++++++++++++++++++++++++
15
1 file changed, 3 insertions(+)
9
1 file changed, 40 insertions(+)
16
10
17
diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c
11
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
18
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
19
--- a/target/xtensa/exc_helper.c
13
--- a/target/arm/ptw.c
20
+++ b/target/xtensa/exc_helper.c
14
+++ b/target/arm/ptw.c
21
@@ -XXX,XX +XXX,XX @@ static void handle_interrupt(CPUXtensaState *env)
15
@@ -XXX,XX +XXX,XX @@
22
CPUState *cs = env_cpu(env);
16
#endif
23
17
24
if (level > 1) {
18
typedef struct S1Translate {
25
+ /* env->config->nlevel check should have ensured this */
19
+ /*
26
+ assert(level < sizeof(env->config->interrupt_vector));
20
+ * in_mmu_idx : specifies which TTBR, TCR, etc to use for the walk.
27
+
21
+ * Together with in_space, specifies the architectural translation regime.
28
env->sregs[EPC1 + level - 1] = env->pc;
22
+ */
29
env->sregs[EPS2 + level - 2] = env->sregs[PS];
23
ARMMMUIdx in_mmu_idx;
30
env->sregs[PS] =
24
+ /*
25
+ * in_ptw_idx: specifies which mmuidx to use for the actual
26
+ * page table descriptor load operations. This will be one of the
27
+ * ARMMMUIdx_Stage2* or one of the ARMMMUIdx_Phys_* indexes.
28
+ * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit,
29
+ * this field is updated accordingly.
30
+ */
31
ARMMMUIdx in_ptw_idx;
32
+ /*
33
+ * in_space: the security space for this walk. This plus
34
+ * the in_mmu_idx specify the architectural translation regime.
35
+ * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit,
36
+ * this field is updated accordingly.
37
+ *
38
+ * Note that the security space for the in_ptw_idx may be different
39
+ * from that for the in_mmu_idx. We do not need to explicitly track
40
+ * the in_ptw_idx security space because:
41
+ * - if the in_ptw_idx is an ARMMMUIdx_Phys_* then the mmuidx
42
+ * itself specifies the security space
43
+ * - if the in_ptw_idx is an ARMMMUIdx_Stage2* then the security
44
+ * space used for ptw reads is the same as that of the security
45
+ * space of the stage 1 translation for all cases except where
46
+ * stage 1 is Secure; in that case the only possibilities for
47
+ * the ptw read are Secure and NonSecure, and the in_ptw_idx
48
+ * value being Stage2 vs Stage2_S distinguishes those.
49
+ */
50
ARMSecuritySpace in_space;
51
+ /*
52
+ * in_secure: whether the translation regime is a Secure one.
53
+ * This is always equal to arm_space_is_secure(in_space).
54
+ * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit,
55
+ * this field is updated accordingly.
56
+ */
57
bool in_secure;
58
+ /*
59
+ * in_debug: is this a QEMU debug access (gdbstub, etc)? Debug
60
+ * accesses will not update the guest page table access flags
61
+ * and will not change the state of the softmmu TLBs.
62
+ */
63
bool in_debug;
64
/*
65
* If this is stage 2 of a stage 1+2 page table walk, then this must
31
--
66
--
32
2.34.1
67
2.34.1
diff view generated by jsdifflib
1
From: Vikram Garhwal <vikram.garhwal@amd.com>
1
In commit fe4a5472ccd6 we rearranged the logic in S1_ptw_translate()
2
so that the debug-access "call get_phys_addr_*" codepath is used both
3
when S1 is doing ptw reads from stage 2 and when it is doing ptw
4
reads from physical memory. However, we didn't update the
5
calculation of s2ptw->in_space and s2ptw->in_secure to account for
6
the "ptw reads from physical memory" case. This meant that debug
7
accesses when in Secure state broke.
2
8
3
Following are done to fix the coverity issues:
9
Create a new function S2_security_space() which returns the
4
1. Change read_data to fix the CID 1512899: Out-of-bounds access (OVERRUN)
10
correct security space to use for the ptw load, and use it to
5
2. Fix match_rx_tx_data to fix CID 1512900: Logically dead code (DEADCODE)
11
determine the correct .in_secure and .in_space fields for the
6
3. Replace rand() in generate_random_data() with g_rand_int()
12
stage 2 lookup for the ptw load.
7
13
8
Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
14
Reported-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
9
Message-id: 20230628202758.16398-1-vikram.garhwal@amd.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Message-id: 20230710152130.3928330-3-peter.maydell@linaro.org
19
Fixes: fe4a5472ccd6 ("target/arm: Use get_phys_addr_with_struct in S1_ptw_translate")
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
21
---
13
tests/qtest/xlnx-canfd-test.c | 33 +++++++++++----------------------
22
target/arm/ptw.c | 37 ++++++++++++++++++++++++++++++++-----
14
1 file changed, 11 insertions(+), 22 deletions(-)
23
1 file changed, 32 insertions(+), 5 deletions(-)
15
24
16
diff --git a/tests/qtest/xlnx-canfd-test.c b/tests/qtest/xlnx-canfd-test.c
25
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
17
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
18
--- a/tests/qtest/xlnx-canfd-test.c
27
--- a/target/arm/ptw.c
19
+++ b/tests/qtest/xlnx-canfd-test.c
28
+++ b/target/arm/ptw.c
20
@@ -XXX,XX +XXX,XX @@ static void generate_random_data(uint32_t *buf_tx, bool is_canfd_frame)
29
@@ -XXX,XX +XXX,XX @@ static bool S2_attrs_are_device(uint64_t hcr, uint8_t attrs)
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
}
30
}
34
}
31
}
35
32
36
-static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx)
33
+static ARMSecuritySpace S2_security_space(ARMSecuritySpace s1_space,
37
+static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx,
34
+ ARMMMUIdx s2_mmu_idx)
38
+ uint32_t frame_size)
35
+{
36
+ /*
37
+ * Return the security space to use for stage 2 when doing
38
+ * the S1 page table descriptor load.
39
+ */
40
+ if (regime_is_stage2(s2_mmu_idx)) {
41
+ /*
42
+ * The security space for ptw reads is almost always the same
43
+ * as that of the security space of the stage 1 translation.
44
+ * The only exception is when stage 1 is Secure; in that case
45
+ * the ptw read might be to the Secure or the NonSecure space
46
+ * (but never Realm or Root), and the s2_mmu_idx tells us which.
47
+ * Root translations are always single-stage.
48
+ */
49
+ if (s1_space == ARMSS_Secure) {
50
+ return arm_secure_to_space(s2_mmu_idx == ARMMMUIdx_Stage2_S);
51
+ } else {
52
+ assert(s2_mmu_idx != ARMMMUIdx_Stage2_S);
53
+ assert(s1_space != ARMSS_Root);
54
+ return s1_space;
55
+ }
56
+ } else {
57
+ /* ptw loads are from phys: the mmu idx itself says which space */
58
+ return arm_phys_to_space(s2_mmu_idx);
59
+ }
60
+}
61
+
62
/* Translate a S1 pagetable walk through S2 if needed. */
63
static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
64
hwaddr addr, ARMMMUFaultInfo *fi)
39
{
65
{
40
uint32_t int_status;
66
- ARMSecuritySpace space = ptw->in_space;
41
uint32_t fifo_status_reg_value;
67
bool is_secure = ptw->in_secure;
42
/* At which RX FIFO the received data is stored. */
68
ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
43
uint8_t store_ind = 0;
69
ARMMMUIdx s2_mmu_idx = ptw->in_ptw_idx;
44
- bool is_canfd_frame = false;
70
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
45
71
* From gdbstub, do not use softmmu so that we don't modify the
46
/* Read the interrupt on CANFD rx. */
72
* state of the cpu at all, including softmmu tlb contents.
47
int_status = qtest_readl(qts, can_base_addr + R_ISR_OFFSET) & ISR_RXOK;
73
*/
48
@@ -XXX,XX +XXX,XX @@ static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx)
74
+ ARMSecuritySpace s2_space = S2_security_space(ptw->in_space, s2_mmu_idx);
49
buf_rx[0] = qtest_readl(qts, can_base_addr + R_RX0_ID_OFFSET);
75
S1Translate s2ptw = {
50
buf_rx[1] = qtest_readl(qts, can_base_addr + R_RX0_DLC_OFFSET);
76
.in_mmu_idx = s2_mmu_idx,
51
77
.in_ptw_idx = ptw_idx_for_stage_2(env, s2_mmu_idx),
52
- is_canfd_frame = (buf_rx[1] >> DLC_FD_BIT_SHIFT) & 1;
78
- .in_secure = s2_mmu_idx == ARMMMUIdx_Stage2_S,
53
-
79
- .in_space = (s2_mmu_idx == ARMMMUIdx_Stage2_S ? ARMSS_Secure
54
- if (is_canfd_frame) {
80
- : space == ARMSS_Realm ? ARMSS_Realm
55
- for (int i = 0; i < CANFD_FRAME_SIZE - 2; i++) {
81
- : ARMSS_NonSecure),
56
- buf_rx[i + 2] = qtest_readl(qts,
82
+ .in_secure = arm_space_is_secure(s2_space),
57
- can_base_addr + R_RX0_DATA1_OFFSET + 4 * i);
83
+ .in_space = s2_space,
58
- }
84
.in_debug = true,
59
- } else {
85
};
60
- buf_rx[2] = qtest_readl(qts, can_base_addr + R_RX0_DATA1_OFFSET);
86
GetPhysAddrResult s2 = { };
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
--
87
--
116
2.34.1
88
2.34.1
diff view generated by jsdifflib
1
From: Fabiano Rosas <farosas@suse.de>
1
In get_phys_addr_twostage() the code that applies the effects of
2
VSTCR.{SA,SW} and VTCR.{NSA,NSW} only updates result->f.attrs.secure.
3
Now we also have f.attrs.space for FEAT_RME, we need to keep the two
4
in sync.
2
5
3
This code is only relevant when TCG is present in the build. Building
6
These bits only have an effect for Secure space translations, not
4
with --disable-tcg --enable-xen on an x86 host we get:
7
for Root, so use the input in_space field to determine whether to
8
apply them rather than the input is_secure. This doesn't actually
9
make a difference because Root translations are never two-stage,
10
but it's a little clearer.
5
11
6
$ ../configure --target-list=x86_64-softmmu,aarch64-softmmu --disable-tcg --enable-xen
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
$ make -j$(nproc)
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
...
14
Message-id: 20230710152130.3928330-4-peter.maydell@linaro.org
9
libqemu-aarch64-softmmu.fa.p/target_arm_gdbstub.c.o: in function `m_sysreg_ptr':
15
---
10
../target/arm/gdbstub.c:358: undefined reference to `arm_v7m_get_sp_ptr'
16
target/arm/ptw.c | 13 ++++++++-----
11
../target/arm/gdbstub.c:361: undefined reference to `arm_v7m_get_sp_ptr'
17
1 file changed, 8 insertions(+), 5 deletions(-)
12
18
13
libqemu-aarch64-softmmu.fa.p/target_arm_gdbstub.c.o: in function `arm_gdb_get_m_systemreg':
19
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
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
20
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/gdbstub.c
21
--- a/target/arm/ptw.c
27
+++ b/target/arm/gdbstub.c
22
+++ b/target/arm/ptw.c
28
@@ -XXX,XX +XXX,XX @@ static int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg)
23
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
29
return cpu->dyn_sysreg_xml.num;
24
hwaddr ipa;
30
}
25
int s1_prot, s1_lgpgsz;
31
26
bool is_secure = ptw->in_secure;
32
+#ifdef CONFIG_TCG
27
+ ARMSecuritySpace in_space = ptw->in_space;
33
typedef enum {
28
bool ret, ipa_secure;
34
M_SYSREG_MSP,
29
ARMCacheAttrs cacheattrs1;
35
M_SYSREG_PSP,
30
ARMSecuritySpace ipa_space;
36
@@ -XXX,XX +XXX,XX @@ static int arm_gen_dynamic_m_secextreg_xml(CPUState *cs, int orig_base_reg)
31
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
37
return cpu->dyn_m_secextreg_xml.num;
32
* Check if IPA translates to secure or non-secure PA space.
38
}
33
* Note that VSTCR overrides VTCR and {N}SW overrides {N}SA.
39
#endif
34
*/
40
+#endif /* CONFIG_TCG */
35
- result->f.attrs.secure =
41
36
- (is_secure
42
const char *arm_gdb_get_dynamic_xml(CPUState *cs, const char *xmlname)
37
- && !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW))
43
{
38
- && (ipa_secure
44
@@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
39
- || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW))));
45
arm_gen_dynamic_sysreg_xml(cs, cs->gdb_num_regs),
40
+ if (in_space == ARMSS_Secure) {
46
"system-registers.xml", 0);
41
+ result->f.attrs.secure =
47
42
+ !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW))
48
+#ifdef CONFIG_TCG
43
+ && (ipa_secure
49
if (arm_feature(env, ARM_FEATURE_M) && tcg_enabled()) {
44
+ || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW)));
50
gdb_register_coprocessor(cs,
45
+ result->f.attrs.space = arm_secure_to_space(result->f.attrs.secure);
51
arm_gdb_get_m_systemreg, arm_gdb_set_m_systemreg,
46
+ }
52
@@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu)
47
53
}
48
return false;
54
#endif
55
}
56
+#endif /* CONFIG_TCG */
57
}
49
}
58
--
50
--
59
2.34.1
51
2.34.1
diff view generated by jsdifflib
1
From: John Högberg <john.hogberg@ericsson.com>
1
In commit f0a08b0913befbd we changed the type of the PC from
2
target_ulong to vaddr. In doing so we inadvertently dropped the
3
zero-padding on the PC in trace lines (the second item inside the []
4
in these lines). They used to look like this on AArch64, for
5
instance:
2
6
3
https://gitlab.com/qemu-project/qemu/-/issues/1034
7
Trace 0: 0x7f2260000100 [00000000/0000000040000000/00000061/ff200000]
4
8
5
Signed-off-by: John Högberg <john.hogberg@ericsson.com>
9
and now they look like this:
6
Message-id: 168778890374.24232.3402138851538068785-2@git.sr.ht
10
Trace 0: 0x7f4f50000100 [00000000/40000000/00000061/ff200000]
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
8
[PMM: fixed typo in comment]
12
and if the PC happens to be somewhere low like 0x5000
13
then the field is shown as /5000/.
14
15
This is because TARGET_FMT_lx is a "%08x" or "%016x" specifier,
16
depending on TARGET_LONG_SIZE, whereas VADDR_PRIx is just PRIx64
17
with no width specifier.
18
19
Restore the zero-padding by adding an 016 width specifier to
20
this tracing and a couple of others that were similarly recently
21
changed to use VADDR_PRIx without a width specifier.
22
23
We can't unfortunately restore the "32-bit guests are padded to
24
8 hex digits and 64-bit guests to 16 hex digits" behaviour so
25
easily.
26
27
Fixes: f0a08b0913befbd ("accel/tcg/cpu-exec.c: Widen pc to vaddr")
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
29
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
30
Reviewed-by: Anton Johansson <anjo@rev.ng>
31
Message-id: 20230711165434.4123674-1-peter.maydell@linaro.org
10
---
32
---
11
tests/tcg/aarch64/icivau.c | 189 ++++++++++++++++++++++++++++++
33
accel/tcg/cpu-exec.c | 4 ++--
12
tests/tcg/aarch64/Makefile.target | 3 +-
34
accel/tcg/translate-all.c | 2 +-
13
2 files changed, 191 insertions(+), 1 deletion(-)
35
2 files changed, 3 insertions(+), 3 deletions(-)
14
create mode 100644 tests/tcg/aarch64/icivau.c
15
36
16
diff --git a/tests/tcg/aarch64/icivau.c b/tests/tcg/aarch64/icivau.c
37
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
17
new file mode 100644
18
index XXXXXXX..XXXXXXX
19
--- /dev/null
20
+++ b/tests/tcg/aarch64/icivau.c
21
@@ -XXX,XX +XXX,XX @@
22
+/*
23
+ * Tests the IC IVAU-driven workaround for catching changes made to dual-mapped
24
+ * code that would otherwise go unnoticed in user mode.
25
+ *
26
+ * Copyright (c) 2023 Ericsson AB
27
+ * SPDX-License-Identifier: GPL-2.0-or-later
28
+ */
29
+
30
+#include <sys/mman.h>
31
+#include <sys/stat.h>
32
+#include <string.h>
33
+#include <stdint.h>
34
+#include <stdlib.h>
35
+#include <unistd.h>
36
+#include <fcntl.h>
37
+
38
+#define MAX_CODE_SIZE 128
39
+
40
+typedef int (SelfModTest)(uint32_t, uint32_t*);
41
+typedef int (BasicTest)(int);
42
+
43
+static void mark_code_modified(const uint32_t *exec_data, size_t length)
44
+{
45
+ int dc_required, ic_required;
46
+ unsigned long ctr_el0;
47
+
48
+ /*
49
+ * Clear the data/instruction cache, as indicated by the CTR_ELO.{DIC,IDC}
50
+ * flags.
51
+ *
52
+ * For completeness we might be tempted to assert that we should fail when
53
+ * the whole code update sequence is omitted, but that would make the test
54
+ * flaky as it can succeed by coincidence on actual hardware.
55
+ */
56
+ asm ("mrs %0, ctr_el0\n" : "=r"(ctr_el0));
57
+
58
+ /* CTR_EL0.IDC */
59
+ dc_required = !((ctr_el0 >> 28) & 1);
60
+
61
+ /* CTR_EL0.DIC */
62
+ ic_required = !((ctr_el0 >> 29) & 1);
63
+
64
+ if (dc_required) {
65
+ size_t dcache_stride, i;
66
+
67
+ /*
68
+ * Step according to the minimum cache size, as the cache maintenance
69
+ * instructions operate on the cache line of the given address.
70
+ *
71
+ * We assume that exec_data is properly aligned.
72
+ */
73
+ dcache_stride = (4 << ((ctr_el0 >> 16) & 0xF));
74
+
75
+ for (i = 0; i < length; i += dcache_stride) {
76
+ const char *dc_addr = &((const char *)exec_data)[i];
77
+ asm volatile ("dc cvau, %x[dc_addr]\n"
78
+ : /* no outputs */
79
+ : [dc_addr] "r"(dc_addr)
80
+ : "memory");
81
+ }
82
+
83
+ asm volatile ("dmb ish\n");
84
+ }
85
+
86
+ if (ic_required) {
87
+ size_t icache_stride, i;
88
+
89
+ icache_stride = (4 << (ctr_el0 & 0xF));
90
+
91
+ for (i = 0; i < length; i += icache_stride) {
92
+ const char *ic_addr = &((const char *)exec_data)[i];
93
+ asm volatile ("ic ivau, %x[ic_addr]\n"
94
+ : /* no outputs */
95
+ : [ic_addr] "r"(ic_addr)
96
+ : "memory");
97
+ }
98
+
99
+ asm volatile ("dmb ish\n");
100
+ }
101
+
102
+ asm volatile ("isb sy\n");
103
+}
104
+
105
+static int basic_test(uint32_t *rw_data, const uint32_t *exec_data)
106
+{
107
+ /*
108
+ * As user mode only misbehaved for dual-mapped code when previously
109
+ * translated code had been changed, we'll start off with this basic test
110
+ * function to ensure that there's already some translated code at
111
+ * exec_data before the next test. This should cause the next test to fail
112
+ * if `mark_code_modified` fails to invalidate the code.
113
+ *
114
+ * Note that the payload is in binary form instead of inline assembler
115
+ * because we cannot use __attribute__((naked)) on this platform and the
116
+ * workarounds are at least as ugly as this is.
117
+ */
118
+ static const uint32_t basic_payload[] = {
119
+ 0xD65F03C0 /* 0x00: RET */
120
+ };
121
+
122
+ BasicTest *copied_ptr = (BasicTest *)exec_data;
123
+
124
+ memcpy(rw_data, basic_payload, sizeof(basic_payload));
125
+ mark_code_modified(exec_data, sizeof(basic_payload));
126
+
127
+ return copied_ptr(1234) == 1234;
128
+}
129
+
130
+static int self_modification_test(uint32_t *rw_data, const uint32_t *exec_data)
131
+{
132
+ /*
133
+ * This test is self-modifying in an attempt to cover an edge case where
134
+ * the IC IVAU instruction invalidates itself.
135
+ *
136
+ * Note that the IC IVAU instruction is 16 bytes into the function, in what
137
+ * will be the same cache line as the modified instruction on machines with
138
+ * a cache line size >= 16 bytes.
139
+ */
140
+ static const uint32_t self_mod_payload[] = {
141
+ /* Overwrite the placeholder instruction with the new one. */
142
+ 0xB9001C20, /* 0x00: STR w0, [x1, 0x1C] */
143
+
144
+ /* Get the executable address of the modified instruction. */
145
+ 0x100000A8, /* 0x04: ADR x8, <0x1C> */
146
+
147
+ /* Mark the modified instruction as updated. */
148
+ 0xD50B7B28, /* 0x08: DC CVAU x8 */
149
+ 0xD5033BBF, /* 0x0C: DMB ISH */
150
+ 0xD50B7528, /* 0x10: IC IVAU x8 */
151
+ 0xD5033BBF, /* 0x14: DMB ISH */
152
+ 0xD5033FDF, /* 0x18: ISB */
153
+
154
+ /* Placeholder instruction, overwritten above. */
155
+ 0x52800000, /* 0x1C: MOV w0, 0 */
156
+
157
+ 0xD65F03C0 /* 0x20: RET */
158
+ };
159
+
160
+ SelfModTest *copied_ptr = (SelfModTest *)exec_data;
161
+ int i;
162
+
163
+ memcpy(rw_data, self_mod_payload, sizeof(self_mod_payload));
164
+ mark_code_modified(exec_data, sizeof(self_mod_payload));
165
+
166
+ for (i = 1; i < 10; i++) {
167
+ /* Replace the placeholder instruction with `MOV w0, i` */
168
+ uint32_t new_instr = 0x52800000 | (i << 5);
169
+
170
+ if (copied_ptr(new_instr, rw_data) != i) {
171
+ return 0;
172
+ }
173
+ }
174
+
175
+ return 1;
176
+}
177
+
178
+int main(int argc, char **argv)
179
+{
180
+ const char *shm_name = "qemu-test-tcg-aarch64-icivau";
181
+ int fd;
182
+
183
+ fd = shm_open(shm_name, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
184
+
185
+ if (fd < 0) {
186
+ return EXIT_FAILURE;
187
+ }
188
+
189
+ /* Unlink early to avoid leaving garbage in case the test crashes. */
190
+ shm_unlink(shm_name);
191
+
192
+ if (ftruncate(fd, MAX_CODE_SIZE) == 0) {
193
+ const uint32_t *exec_data;
194
+ uint32_t *rw_data;
195
+
196
+ rw_data = mmap(0, MAX_CODE_SIZE, PROT_READ | PROT_WRITE,
197
+ MAP_SHARED, fd, 0);
198
+ exec_data = mmap(0, MAX_CODE_SIZE, PROT_READ | PROT_EXEC,
199
+ MAP_SHARED, fd, 0);
200
+
201
+ if (rw_data && exec_data) {
202
+ if (basic_test(rw_data, exec_data) &&
203
+ self_modification_test(rw_data, exec_data)) {
204
+ return EXIT_SUCCESS;
205
+ }
206
+ }
207
+ }
208
+
209
+ return EXIT_FAILURE;
210
+}
211
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
212
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
213
--- a/tests/tcg/aarch64/Makefile.target
39
--- a/accel/tcg/cpu-exec.c
214
+++ b/tests/tcg/aarch64/Makefile.target
40
+++ b/accel/tcg/cpu-exec.c
215
@@ -XXX,XX +XXX,XX @@ AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64
41
@@ -XXX,XX +XXX,XX @@ static void log_cpu_exec(vaddr pc, CPUState *cpu,
216
VPATH         += $(AARCH64_SRC)
42
if (qemu_log_in_addr_range(pc)) {
217
43
qemu_log_mask(CPU_LOG_EXEC,
218
# Base architecture tests
44
"Trace %d: %p [%08" PRIx64
219
-AARCH64_TESTS=fcvt pcalign-a64
45
- "/%" VADDR_PRIx "/%08x/%08x] %s\n",
220
+AARCH64_TESTS=fcvt pcalign-a64 icivau
46
+ "/%016" VADDR_PRIx "/%08x/%08x] %s\n",
221
47
cpu->cpu_index, tb->tc.ptr, tb->cs_base, pc,
222
fcvt: LDFLAGS+=-lm
48
tb->flags, tb->cflags, lookup_symbol(pc));
223
+icivau: LDFLAGS+=-lrt
49
224
50
@@ -XXX,XX +XXX,XX @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit)
225
run-fcvt: fcvt
51
if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
226
    $(call run-test,$<,$(QEMU) $<, "$< on $(TARGET_NAME)")
52
vaddr pc = log_pc(cpu, last_tb);
53
if (qemu_log_in_addr_range(pc)) {
54
- qemu_log("Stopped execution of TB chain before %p [%"
55
+ qemu_log("Stopped execution of TB chain before %p [%016"
56
VADDR_PRIx "] %s\n",
57
last_tb->tc.ptr, pc, lookup_symbol(pc));
58
}
59
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
60
index XXXXXXX..XXXXXXX 100644
61
--- a/accel/tcg/translate-all.c
62
+++ b/accel/tcg/translate-all.c
63
@@ -XXX,XX +XXX,XX @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr)
64
if (qemu_loglevel_mask(CPU_LOG_EXEC)) {
65
vaddr pc = log_pc(cpu, tb);
66
if (qemu_log_in_addr_range(pc)) {
67
- qemu_log("cpu_io_recompile: rewound execution of TB to %"
68
+ qemu_log("cpu_io_recompile: rewound execution of TB to %016"
69
VADDR_PRIx "\n", pc);
70
}
71
}
227
--
72
--
228
2.34.1
73
2.34.1
229
74
230
75
diff view generated by jsdifflib
1
From: John Högberg <john.hogberg@ericsson.com>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
Unlike architectures with precise self-modifying code semantics
3
Add a check in the bit-set operation to write the backstore
4
(e.g. x86) ARM processors do not maintain coherency for instruction
4
only if the affected bit is 0 before.
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
5
9
While this is required to make JITs work on actual hardware, QEMU
6
With this in place, there will be no need for callers to
10
has gotten away with not handling this since it does not emulate
7
do the checking in order to avoid unnecessary writes.
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
8
15
Unfortunately the latter does not work in the face of dual-mapped
9
Signed-off-by: Tong Ho <tong.ho@amd.com>
16
code (a common W^X workaround), where one page is executable and
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
17
the other is writable: user-mode has no way to connect one with the
11
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
18
other as that is only known to the kernel and the emulated
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
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]
35
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
36
---
14
---
37
target/arm/cpu.c | 11 +++++++++++
15
hw/nvram/xlnx-efuse.c | 11 +++++++++--
38
target/arm/helper.c | 47 ++++++++++++++++++++++++++++++++++++++++++---
16
1 file changed, 9 insertions(+), 2 deletions(-)
39
2 files changed, 55 insertions(+), 3 deletions(-)
40
17
41
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
18
diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c
42
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
43
--- a/target/arm/cpu.c
20
--- a/hw/nvram/xlnx-efuse.c
44
+++ b/target/arm/cpu.c
21
+++ b/hw/nvram/xlnx-efuse.c
45
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
22
@@ -XXX,XX +XXX,XX @@ static bool efuse_ro_bits_find(XlnxEFuse *s, uint32_t k)
46
return;
23
24
bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit)
25
{
26
+ uint32_t set, *row;
27
+
28
if (efuse_ro_bits_find(s, bit)) {
29
g_autofree char *path = object_get_canonical_path(OBJECT(s));
30
31
@@ -XXX,XX +XXX,XX @@ bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit)
32
return false;
47
}
33
}
48
34
49
+#ifdef CONFIG_USER_ONLY
35
- s->fuse32[bit / 32] |= 1 << (bit % 32);
50
+ /*
36
- efuse_bdrv_sync(s, bit);
51
+ * User mode relies on IC IVAU instructions to catch modification of
37
+ /* Avoid back-end write unless there is a real update */
52
+ * dual-mapped code.
38
+ row = &s->fuse32[bit / 32];
53
+ *
39
+ set = 1 << (bit % 32);
54
+ * Clear CTR_EL0.DIC to ensure that software that honors these flags uses
40
+ if (!(set & *row)) {
55
+ * IC IVAU even if the emulated processor does not normally require it.
41
+ *row |= set;
56
+ */
42
+ efuse_bdrv_sync(s, bit);
57
+ cpu->ctr = FIELD_DP64(cpu->ctr, CTR_EL0, DIC, 0);
43
+ }
58
+#endif
44
return true;
59
+
60
if (arm_feature(env, ARM_FEATURE_AARCH64) &&
61
cpu->has_vfp != cpu->has_neon) {
62
/*
63
diff --git a/target/arm/helper.c b/target/arm/helper.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/target/arm/helper.c
66
+++ b/target/arm/helper.c
67
@@ -XXX,XX +XXX,XX @@ static void mdcr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri,
68
}
69
}
45
}
70
46
71
+#ifdef CONFIG_USER_ONLY
72
+/*
73
+ * `IC IVAU` is handled to improve compatibility with JITs that dual-map their
74
+ * code to get around W^X restrictions, where one region is writable and the
75
+ * other is executable.
76
+ *
77
+ * Since the executable region is never written to we cannot detect code
78
+ * changes when running in user mode, and rely on the emulated JIT telling us
79
+ * that the code has changed by executing this instruction.
80
+ */
81
+static void ic_ivau_write(CPUARMState *env, const ARMCPRegInfo *ri,
82
+ uint64_t value)
83
+{
84
+ uint64_t icache_line_mask, start_address, end_address;
85
+ const ARMCPU *cpu;
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,
136
--
47
--
137
2.34.1
48
2.34.1
138
49
139
50
diff view generated by jsdifflib