1
Arm queue; bugfixes only.
1
Just a collection of bug fixes this time around...
2
2
3
thanks
3
thanks
4
-- PMM
4
-- PMM
5
5
6
The following changes since commit 48aa8f0ac536db3550a35c295ff7de94e4c33739:
6
The following changes since commit 2a6ae69154542caa91dd17c40fd3f5ffbec300de:
7
7
8
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2020-11-16' into staging (2020-11-17 11:07:00 +0000)
8
Merge tag 'pull-maintainer-ominbus-030723-1' of https://gitlab.com/stsquad/qemu into staging (2023-07-04 08:36:44 +0200)
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-20201117
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230704
13
13
14
for you to fetch changes up to ab135622cf478585bdfcb68b85e4a817d74a0c42:
14
for you to fetch changes up to 86a78272f094857b4eda79d721c116e93942aa9a:
15
15
16
tmp105: Correct handling of temperature limit checks (2020-11-17 12:56:33 +0000)
16
target/xtensa: Assert that interrupt level is within bounds (2023-07-04 14:27:08 +0100)
17
17
18
----------------------------------------------------------------
18
----------------------------------------------------------------
19
target-arm queue:
19
target-arm queue:
20
* hw/arm/virt: ARM_VIRT must select ARM_GIC
20
* Add raw_writes ops for register whose write induce TLB maintenance
21
* exynos: Fix bad printf format specifiers
21
* hw/arm/sbsa-ref: use XHCI to replace EHCI
22
* hw/input/ps2.c: Remove remnants of printf debug
22
* Avoid splitting Zregs across lines in dump
23
* target/openrisc: Remove dead code attempting to check "is timer disabled"
23
* Dump ZA[] when active
24
* register: Remove unnecessary NULL check
24
* Fix SME full tile indexing
25
* util/cutils: Fix Coverity array overrun in freq_to_str()
25
* Handle IC IVAU to improve compatibility with JITs
26
* configure: Make "does libgio work" test pull in some actual functions
26
* xlnx-canfd-test: Fix code coverity issues
27
* tmp105: reset the T_low and T_High registers
27
* gdbstub: Guard M-profile code with CONFIG_TCG
28
* tmp105: Correct handling of temperature limit checks
28
* allwinner-sramc: Set class_size
29
* target/xtensa: Assert that interrupt level is within bounds
29
30
30
----------------------------------------------------------------
31
----------------------------------------------------------------
31
Alex Chen (1):
32
Akihiko Odaki (1):
32
exynos: Fix bad printf format specifiers
33
hw: arm: allwinner-sramc: Set class_size
33
34
34
Alistair Francis (1):
35
Eric Auger (1):
35
register: Remove unnecessary NULL check
36
target/arm: Add raw_writes ops for register whose write induce TLB maintenance
36
37
37
Andrew Jones (1):
38
Fabiano Rosas (1):
38
hw/arm/virt: ARM_VIRT must select ARM_GIC
39
target/arm: gdbstub: Guard M-profile code with CONFIG_TCG
39
40
40
Peter Maydell (5):
41
John Högberg (2):
41
hw/input/ps2.c: Remove remnants of printf debug
42
target/arm: Handle IC IVAU to improve compatibility with JITs
42
target/openrisc: Remove dead code attempting to check "is timer disabled"
43
tests/tcg/aarch64: Add testcases for IC IVAU and dual-mapped code
43
configure: Make "does libgio work" test pull in some actual functions
44
hw/misc/tmp105: reset the T_low and T_High registers
45
tmp105: Correct handling of temperature limit checks
46
44
47
Philippe Mathieu-Daudé (1):
45
Peter Maydell (1):
48
util/cutils: Fix Coverity array overrun in freq_to_str()
46
target/xtensa: Assert that interrupt level is within bounds
49
47
50
configure | 11 +++++--
48
Richard Henderson (3):
51
hw/misc/tmp105.h | 7 +++++
49
target/arm: Avoid splitting Zregs across lines in dump
52
hw/core/register.c | 4 ---
50
target/arm: Dump ZA[] when active
53
hw/input/ps2.c | 9 ------
51
target/arm: Fix SME full tile indexing
54
hw/misc/tmp105.c | 73 ++++++++++++++++++++++++++++++++++++++------
55
hw/timer/exynos4210_mct.c | 4 +--
56
hw/timer/exynos4210_pwm.c | 8 ++---
57
target/openrisc/sys_helper.c | 3 --
58
util/cutils.c | 3 +-
59
hw/arm/Kconfig | 1 +
60
10 files changed, 89 insertions(+), 34 deletions(-)
61
52
53
Vikram Garhwal (1):
54
tests/qtest: xlnx-canfd-test: Fix code coverity issues
55
56
Yuquan Wang (1):
57
hw/arm/sbsa-ref: use XHCI to replace EHCI
58
59
docs/system/arm/sbsa.rst | 5 +-
60
hw/arm/sbsa-ref.c | 23 +++--
61
hw/misc/allwinner-sramc.c | 1 +
62
target/arm/cpu.c | 65 ++++++++-----
63
target/arm/gdbstub.c | 4 +
64
target/arm/helper.c | 70 +++++++++++---
65
target/arm/tcg/translate-sme.c | 24 +++--
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
1
In commit 76346b6264a9b01979 we tried to add a configure check that
1
From: Eric Auger <eric.auger@redhat.com>
2
the libgio pkg-config data was correct, which builds an executable
3
linked against it. Unfortunately this doesn't catch the problem
4
(missing static library dependency info), because a "do nothing" test
5
source file doesn't have any symbol references that cause the linker
6
to pull in .o files from libgio.a, and so we don't see the "missing
7
symbols from libmount" error that a full QEMU link triggers.
8
2
9
(The ineffective test went unnoticed because of a typo that
3
Some registers whose 'cooked' writefns induce TLB maintenance do
10
effectively disabled libgio unconditionally, but after commit
4
not have raw_writefn ops defined. If only the writefn ops is set
11
3569a5dfc11f2 fixed that, a static link of the system emulator on
5
(ie. no raw_writefn is provided), it is assumed the cooked also
12
Ubuntu stopped working again.)
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.
13
8
14
Improve the gio test by having the test source fragment reference a
9
Signed-off-by: Eric Auger <eric.auger@redhat.com>
15
g_dbus function (which is what is indirectly causing us to end up
10
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
16
wanting functions from libmount).
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(-)
17
16
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
19
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
18
index XXXXXXX..XXXXXXX 100644
20
Message-id: 20201116104617.18333-1-peter.maydell@linaro.org
19
--- a/target/arm/helper.c
21
---
20
+++ b/target/arm/helper.c
22
configure | 11 +++++++++--
21
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = {
23
1 file changed, 9 insertions(+), 2 deletions(-)
22
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 0,
24
23
.access = PL1_RW, .accessfn = access_tvm_trvm,
25
diff --git a/configure b/configure
24
.fgt = FGT_TTBR0_EL1,
26
index XXXXXXX..XXXXXXX 100755
25
- .writefn = vmsa_ttbr_write, .resetvalue = 0,
27
--- a/configure
26
+ .writefn = vmsa_ttbr_write, .resetvalue = 0, .raw_writefn = raw_write,
28
+++ b/configure
27
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s),
29
@@ -XXX,XX +XXX,XX @@ if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
28
offsetof(CPUARMState, cp15.ttbr0_ns) } },
30
# Check that the libraries actually work -- Ubuntu 18.04 ships
29
{ .name = "TTBR1_EL1", .state = ARM_CP_STATE_BOTH,
31
# with pkg-config --static --libs data for gio-2.0 that is missing
30
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 1,
32
# -lblkid and will give a link error.
31
.access = PL1_RW, .accessfn = access_tvm_trvm,
33
- write_c_skeleton
32
.fgt = FGT_TTBR1_EL1,
34
- if compile_prog "" "$gio_libs" ; then
33
- .writefn = vmsa_ttbr_write, .resetvalue = 0,
35
+ cat > $TMPC <<EOF
34
+ .writefn = vmsa_ttbr_write, .resetvalue = 0, .raw_writefn = raw_write,
36
+#include <gio/gio.h>
35
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s),
37
+int main(void)
36
offsetof(CPUARMState, cp15.ttbr1_ns) } },
38
+{
37
{ .name = "TCR_EL1", .state = ARM_CP_STATE_AA64,
39
+ g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
38
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lpae_cp_reginfo[] = {
40
+ return 0;
39
.type = ARM_CP_64BIT | ARM_CP_ALIAS,
41
+}
40
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s),
42
+EOF
41
offsetof(CPUARMState, cp15.ttbr0_ns) },
43
+ if compile_prog "$gio_cflags" "$gio_libs" ; then
42
- .writefn = vmsa_ttbr_write, },
44
gio=yes
43
+ .writefn = vmsa_ttbr_write, .raw_writefn = raw_write },
45
else
44
{ .name = "TTBR1", .cp = 15, .crm = 2, .opc1 = 1,
46
gio=no
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,
47
--
117
--
48
2.20.1
118
2.34.1
49
50
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Yuquan Wang <wangyuquan1236@phytium.com.cn>
2
2
3
The removal of the selection of A15MPCORE from ARM_VIRT also
3
The current sbsa-ref cannot use EHCI controller which is only
4
removed what A15MPCORE selects, ARM_GIC. We still need ARM_GIC.
4
able to do 32-bit DMA, since sbsa-ref doesn't have RAM below 4GB.
5
Hence, this uses XHCI to provide a usb controller with 64-bit
6
DMA capablity instead of EHCI.
5
7
6
Fixes: bec3c97e0cf9 ("hw/arm/virt: Remove dependency on Cortex-A15 MPCore peripherals")
8
We bump the platform version to 0.3 with this change. Although the
7
Reported-by: Miroslav Rezanina <mrezanin@redhat.com>
9
hardware at the USB controller address changes, the firmware and
8
Signed-off-by: Andrew Jones <drjones@redhat.com>
10
Linux can both cope with this -- on an older non-XHCI-aware
9
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
11
firmware/kernel setup the probe routine simply fails and the guest
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
proceeds without any USB. (This isn't a loss of functionality,
11
Message-id: 20201111143440.112763-1-drjones@redhat.com
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.
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>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
23
---
14
hw/arm/Kconfig | 1 +
24
docs/system/arm/sbsa.rst | 5 ++++-
15
1 file changed, 1 insertion(+)
25
hw/arm/sbsa-ref.c | 23 +++++++++++++----------
26
hw/arm/Kconfig | 2 +-
27
3 files changed, 18 insertions(+), 12 deletions(-)
16
28
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
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,
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
17
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
127
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
18
index XXXXXXX..XXXXXXX 100644
128
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/Kconfig
129
--- a/hw/arm/Kconfig
20
+++ b/hw/arm/Kconfig
130
+++ b/hw/arm/Kconfig
21
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
131
@@ -XXX,XX +XXX,XX @@ config SBSA_REF
22
imply VFIO_PLATFORM
132
select PL011 # UART
23
imply VFIO_XGMAC
133
select PL031 # RTC
24
imply TPM_TIS_SYSBUS
134
select PL061 # GPIO
25
+ select ARM_GIC
135
- select USB_EHCI_SYSBUS
26
select ACPI
136
+ select USB_XHCI_SYSBUS
27
select ARM_SMMUV3
137
select WDT_SBSA
28
select GPIO_KEY
138
select BOCHS_DISPLAY
139
29
--
140
--
30
2.20.1
141
2.34.1
31
32
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
1
The TMP105 datasheet says that in Interrupt Mode (when TM==1) the device
1
From: Richard Henderson <richard.henderson@linaro.org>
2
signals an alert when the temperature equals or exceeds the T_high value and
3
then remains high until a device register is read or the device responds to
4
the SMBUS Alert Response address, or the device is put into Shutdown Mode.
5
Thereafter the Alert pin will only be re-signalled when temperature falls
6
below T_low; alert can then be cleared in the same set of ways, and the
7
device returns to its initial "alert when temperature goes above T_high"
8
mode. (If this textual description is confusing, see figure 3 in the
9
TI datasheet at https://www.ti.com/lit/gpn/tmp105 .)
10
2
11
We were misimplementing this as a simple "always alert if temperature is
3
Always print each matrix row whole, one per line, so that we
12
above T_high or below T_low" condition, which gives a spurious alert on
4
get the entire matrix in the proper shape.
13
startup if using the "T_high = 80 degrees C, T_low = 75 degrees C" reset
14
limit values.
15
5
16
Implement the correct (hysteresis) behaviour by tracking whether we
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
17
are currently looking for the temperature to rise over T_high or
7
Message-id: 20230622151201.1578522-3-richard.henderson@linaro.org
18
for it to fall below T_low. Our implementation of the comparator
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
mode (TM==0) wasn't wrong, but rephrase it to match the way that
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
interrupt mode is now handled for clarity.
10
---
11
target/arm/cpu.c | 18 ++++++++++++++++++
12
1 file changed, 18 insertions(+)
21
13
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
23
Reviewed-by: Cédric Le Goater <clg@kaod.org>
24
Message-id: 20201110150023.25533-3-peter.maydell@linaro.org
25
---
26
hw/misc/tmp105.h | 7 +++++
27
hw/misc/tmp105.c | 70 +++++++++++++++++++++++++++++++++++++++++-------
28
2 files changed, 68 insertions(+), 9 deletions(-)
29
30
diff --git a/hw/misc/tmp105.h b/hw/misc/tmp105.h
31
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/misc/tmp105.h
16
--- a/target/arm/cpu.c
33
+++ b/hw/misc/tmp105.h
17
+++ b/target/arm/cpu.c
34
@@ -XXX,XX +XXX,XX @@ struct TMP105State {
18
@@ -XXX,XX +XXX,XX @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags)
35
int16_t limit[2];
19
i, q[1], q[0], (i & 1 ? "\n" : " "));
36
int faults;
20
}
37
uint8_t alarm;
38
+ /*
39
+ * The TMP105 initially looks for a temperature rising above T_high;
40
+ * once this is detected, the condition it looks for next is the
41
+ * temperature falling below T_low. This flag is false when initially
42
+ * looking for T_high, true when looking for T_low.
43
+ */
44
+ bool detect_falling;
45
};
46
47
#endif
48
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/misc/tmp105.c
51
+++ b/hw/misc/tmp105.c
52
@@ -XXX,XX +XXX,XX @@ static void tmp105_alarm_update(TMP105State *s)
53
return;
54
}
21
}
55
22
+
56
- if ((s->config >> 1) & 1) {                    /* TM */
23
+ if (cpu_isar_feature(aa64_sme, cpu) &&
57
- if (s->temperature >= s->limit[1])
24
+ FIELD_EX64(env->svcr, SVCR, ZA) &&
58
- s->alarm = 1;
25
+ sme_exception_el(env, el) == 0) {
59
- else if (s->temperature < s->limit[0])
26
+ int zcr_len = sve_vqm1_for_el_sm(env, el, true);
60
- s->alarm = 1;
27
+ int svl = (zcr_len + 1) * 16;
61
+ if (s->config >> 1 & 1) {
28
+ int svl_lg10 = svl < 100 ? 2 : 3;
62
+ /*
29
+
63
+ * TM == 1 : Interrupt mode. We signal Alert when the
30
+ for (i = 0; i < svl; i++) {
64
+ * temperature rises above T_high, and expect the guest to clear
31
+ qemu_fprintf(f, "ZA[%0*d]=", svl_lg10, i);
65
+ * it (eg by reading a device register).
32
+ for (j = zcr_len; j >= 0; --j) {
66
+ */
33
+ qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%c",
67
+ if (s->detect_falling) {
34
+ env->zarray[i].d[2 * j + 1],
68
+ if (s->temperature < s->limit[0]) {
35
+ env->zarray[i].d[2 * j],
69
+ s->alarm = 1;
36
+ j ? ':' : '\n');
70
+ s->detect_falling = false;
71
+ }
72
+ } else {
73
+ if (s->temperature >= s->limit[1]) {
74
+ s->alarm = 1;
75
+ s->detect_falling = true;
76
+ }
37
+ }
77
+ }
38
+ }
78
} else {
39
+ }
79
- if (s->temperature >= s->limit[1])
80
- s->alarm = 1;
81
- else if (s->temperature < s->limit[0])
82
- s->alarm = 0;
83
+ /*
84
+ * TM == 0 : Comparator mode. We signal Alert when the temperature
85
+ * rises above T_high, and stop signalling it when the temperature
86
+ * falls below T_low.
87
+ */
88
+ if (s->detect_falling) {
89
+ if (s->temperature < s->limit[0]) {
90
+ s->alarm = 0;
91
+ s->detect_falling = false;
92
+ }
93
+ } else {
94
+ if (s->temperature >= s->limit[1]) {
95
+ s->alarm = 1;
96
+ s->detect_falling = true;
97
+ }
98
+ }
99
}
100
101
tmp105_interrupt_update(s);
102
@@ -XXX,XX +XXX,XX @@ static int tmp105_post_load(void *opaque, int version_id)
103
return 0;
104
}
40
}
105
41
106
+static bool detect_falling_needed(void *opaque)
42
#else
107
+{
108
+ TMP105State *s = opaque;
109
+
110
+ /*
111
+ * We only need to migrate the detect_falling bool if it's set;
112
+ * for migration from older machines we assume that it is false
113
+ * (ie temperature is not out of range).
114
+ */
115
+ return s->detect_falling;
116
+}
117
+
118
+static const VMStateDescription vmstate_tmp105_detect_falling = {
119
+ .name = "TMP105/detect-falling",
120
+ .version_id = 1,
121
+ .minimum_version_id = 1,
122
+ .needed = detect_falling_needed,
123
+ .fields = (VMStateField[]) {
124
+ VMSTATE_BOOL(detect_falling, TMP105State),
125
+ VMSTATE_END_OF_LIST()
126
+ }
127
+};
128
+
129
static const VMStateDescription vmstate_tmp105 = {
130
.name = "TMP105",
131
.version_id = 0,
132
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_tmp105 = {
133
VMSTATE_UINT8(alarm, TMP105State),
134
VMSTATE_I2C_SLAVE(i2c, TMP105State),
135
VMSTATE_END_OF_LIST()
136
+ },
137
+ .subsections = (const VMStateDescription*[]) {
138
+ &vmstate_tmp105_detect_falling,
139
+ NULL
140
}
141
};
142
143
@@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c)
144
s->config = 0;
145
s->faults = tmp105_faultq[(s->config >> 3) & 3];
146
s->alarm = 0;
147
+ s->detect_falling = false;
148
149
s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */
150
s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */
151
--
43
--
152
2.20.1
44
2.34.1
153
154
diff view generated by jsdifflib
New patch
1
1
From: Richard Henderson <richard.henderson@linaro.org>
2
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
The TMP105 datasheet (https://www.ti.com/lit/gpn/tmp105) says that the
1
From: John Högberg <john.hogberg@ericsson.com>
2
power-up reset values for the T_low and T_high registers are 80 degrees C
3
and 75 degrees C, which are 0x500 and 0x4B0 hex according to table 5. These
4
values are then shifted right by four bits to give the register reset
5
values, since both registers store the 12 bits of temperature data in bits
6
[15..4] of a 16 bit register.
7
2
8
We were resetting these registers to zero, which is problematic for Linux
3
Unlike architectures with precise self-modifying code semantics
9
guests which enable the alert interrupt and then immediately take an
4
(e.g. x86) ARM processors do not maintain coherency for instruction
10
unexpected overtemperature alert because the current temperature is above
5
execution and memory, requiring an instruction synchronization
11
freezing...
6
barrier on every core that will execute the new code, and on many
7
models also the explicit use of cache management instructions.
12
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]
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
35
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
15
Message-id: 20201110150023.25533-2-peter.maydell@linaro.org
16
---
36
---
17
hw/misc/tmp105.c | 3 +++
37
target/arm/cpu.c | 11 +++++++++++
18
1 file changed, 3 insertions(+)
38
target/arm/helper.c | 47 ++++++++++++++++++++++++++++++++++++++++++---
39
2 files changed, 55 insertions(+), 3 deletions(-)
19
40
20
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
41
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
21
index XXXXXXX..XXXXXXX 100644
42
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/misc/tmp105.c
43
--- a/target/arm/cpu.c
23
+++ b/hw/misc/tmp105.c
44
+++ b/target/arm/cpu.c
24
@@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c)
45
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
25
s->faults = tmp105_faultq[(s->config >> 3) & 3];
46
return;
26
s->alarm = 0;
47
}
27
48
28
+ s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */
49
+#ifdef CONFIG_USER_ONLY
29
+ s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */
50
+ /*
51
+ * User mode relies on IC IVAU instructions to catch modification of
52
+ * dual-mapped code.
53
+ *
54
+ * Clear CTR_EL0.DIC to ensure that software that honors these flags uses
55
+ * IC IVAU even if the emulated processor does not normally require it.
56
+ */
57
+ cpu->ctr = FIELD_DP64(cpu->ctr, CTR_EL0, DIC, 0);
58
+#endif
30
+
59
+
31
tmp105_interrupt_update(s);
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
}
32
}
69
}
33
70
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,
34
--
136
--
35
2.20.1
137
2.34.1
36
138
37
139
diff view generated by jsdifflib
1
In the mtspr helper we attempt to check for "is the timer disabled"
1
From: John Högberg <john.hogberg@ericsson.com>
2
with "if (env->ttmr & TIMER_NONE)". This is wrong because TIMER_NONE
2
3
is zero and the condition is always false (Coverity complains about
3
https://gitlab.com/qemu-project/qemu/-/issues/1034
4
the dead code.)
4
5
5
Signed-off-by: John Högberg <john.hogberg@ericsson.com>
6
The correct check would be to test whether the TTMR_M field in the
6
Message-id: 168778890374.24232.3402138851538068785-2@git.sr.ht
7
register is equal to TIMER_NONE instead. However, the
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
cpu_openrisc_timer_update() function checks whether the timer is
8
[PMM: fixed typo in comment]
9
enabled (it looks at cpu->env.is_counting, which is set to 0 via
10
cpu_openrisc_count_stop() when the TTMR_M field is set to
11
TIMER_NONE), so there's no need to check for "timer disabled" in the
12
target/openrisc code. Instead, simply remove the dead code.
13
14
Fixes: Coverity CID 1005812
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Acked-by: Stafford Horne <shorne@gmail.com>
17
Message-id: 20201103114654.18540-1-peter.maydell@linaro.org
18
---
10
---
19
target/openrisc/sys_helper.c | 3 ---
11
tests/tcg/aarch64/icivau.c | 189 ++++++++++++++++++++++++++++++
20
1 file changed, 3 deletions(-)
12
tests/tcg/aarch64/Makefile.target | 3 +-
21
13
2 files changed, 191 insertions(+), 1 deletion(-)
22
diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c
14
create mode 100644 tests/tcg/aarch64/icivau.c
15
16
diff --git a/tests/tcg/aarch64/icivau.c b/tests/tcg/aarch64/icivau.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
23
index XXXXXXX..XXXXXXX 100644
212
index XXXXXXX..XXXXXXX 100644
24
--- a/target/openrisc/sys_helper.c
213
--- a/tests/tcg/aarch64/Makefile.target
25
+++ b/target/openrisc/sys_helper.c
214
+++ b/tests/tcg/aarch64/Makefile.target
26
@@ -XXX,XX +XXX,XX @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)
215
@@ -XXX,XX +XXX,XX @@ AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64
27
216
VPATH         += $(AARCH64_SRC)
28
case TO_SPR(10, 1): /* TTCR */
217
29
cpu_openrisc_count_set(cpu, rb);
218
# Base architecture tests
30
- if (env->ttmr & TIMER_NONE) {
219
-AARCH64_TESTS=fcvt pcalign-a64
31
- return;
220
+AARCH64_TESTS=fcvt pcalign-a64 icivau
32
- }
221
33
cpu_openrisc_timer_update(cpu);
222
fcvt: LDFLAGS+=-lm
34
break;
223
+icivau: LDFLAGS+=-lrt
35
#endif
224
225
run-fcvt: fcvt
226
    $(call run-test,$<,$(QEMU) $<, "$< on $(TARGET_NAME)")
36
--
227
--
37
2.20.1
228
2.34.1
38
229
39
230
diff view generated by jsdifflib
1
From: Alex Chen <alex.chen@huawei.com>
1
From: Vikram Garhwal <vikram.garhwal@amd.com>
2
2
3
We should use printf format specifier "%u" instead of "%d" for
3
Following are done to fix the coverity issues:
4
argument of type "unsigned int".
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()
5
7
6
Reported-by: Euler Robot <euler.robot@huawei.com>
8
Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
7
Signed-off-by: Alex Chen <alex.chen@huawei.com>
9
Message-id: 20230628202758.16398-1-vikram.garhwal@amd.com
8
Message-id: 20201111073651.72804-1-alex.chen@huawei.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
---
12
hw/timer/exynos4210_mct.c | 4 ++--
13
tests/qtest/xlnx-canfd-test.c | 33 +++++++++++----------------------
13
hw/timer/exynos4210_pwm.c | 8 ++++----
14
1 file changed, 11 insertions(+), 22 deletions(-)
14
2 files changed, 6 insertions(+), 6 deletions(-)
15
15
16
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
16
diff --git a/tests/qtest/xlnx-canfd-test.c b/tests/qtest/xlnx-canfd-test.c
17
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/timer/exynos4210_mct.c
18
--- a/tests/qtest/xlnx-canfd-test.c
19
+++ b/hw/timer/exynos4210_mct.c
19
+++ b/tests/qtest/xlnx-canfd-test.c
20
@@ -XXX,XX +XXX,XX @@ static void exynos4210_gcomp_raise_irq(void *opaque, uint32_t id)
20
@@ -XXX,XX +XXX,XX @@ static void generate_random_data(uint32_t *buf_tx, bool is_canfd_frame)
21
/* If CSTAT is pending and IRQ is enabled */
21
/* Generate random TX data for CANFD frame. */
22
if ((s->reg.int_cstat & G_INT_CSTAT_COMP(id)) &&
22
if (is_canfd_frame) {
23
(s->reg.int_enb & G_INT_ENABLE(id))) {
23
for (int i = 0; i < CANFD_FRAME_SIZE - 2; i++) {
24
- DPRINTF("gcmp timer[%d] IRQ\n", id);
24
- buf_tx[2 + i] = rand();
25
+ DPRINTF("gcmp timer[%u] IRQ\n", id);
25
+ buf_tx[2 + i] = g_random_int();
26
qemu_irq_raise(s->irq[id]);
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
}
27
}
33
}
28
}
34
}
29
@@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_update_freq(Exynos4210MCTState *s)
35
30
MCT_CFG_GET_DIVIDER(s->reg_mct_cfg));
36
-static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx)
31
37
+static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx,
32
if (freq != s->freq) {
38
+ uint32_t frame_size)
33
- DPRINTF("freq=%dHz\n", s->freq);
39
{
34
+ DPRINTF("freq=%uHz\n", s->freq);
40
uint32_t int_status;
35
41
uint32_t fifo_status_reg_value;
36
/* global timer */
42
/* At which RX FIFO the received data is stored. */
37
tx_ptimer_set_freq(s->g_timer.ptimer_frc, s->freq);
43
uint8_t store_ind = 0;
38
diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c
44
- bool is_canfd_frame = false;
39
index XXXXXXX..XXXXXXX 100644
45
40
--- a/hw/timer/exynos4210_pwm.c
46
/* Read the interrupt on CANFD rx. */
41
+++ b/hw/timer/exynos4210_pwm.c
47
int_status = qtest_readl(qts, can_base_addr + R_ISR_OFFSET) & ISR_RXOK;
42
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_update_freq(Exynos4210PWMState *s, uint32_t id)
48
@@ -XXX,XX +XXX,XX @@ static void read_data(QTestState *qts, uint64_t can_base_addr, uint32_t *buf_rx)
43
49
buf_rx[0] = qtest_readl(qts, can_base_addr + R_RX0_ID_OFFSET);
44
if (freq != s->timer[id].freq) {
50
buf_rx[1] = qtest_readl(qts, can_base_addr + R_RX0_DLC_OFFSET);
45
ptimer_set_freq(s->timer[id].ptimer, s->timer[id].freq);
51
46
- DPRINTF("freq=%dHz\n", s->timer[id].freq);
52
- is_canfd_frame = (buf_rx[1] >> DLC_FD_BIT_SHIFT) & 1;
47
+ DPRINTF("freq=%uHz\n", s->timer[id].freq);
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);
48
}
65
}
49
}
66
50
67
/* Clear the RX interrupt. */
51
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque)
68
@@ -XXX,XX +XXX,XX @@ static void match_rx_tx_data(const uint32_t *buf_tx, const uint32_t *buf_rx,
52
uint32_t id = s->id;
69
g_assert_cmpint((buf_rx[size] & DLC_FD_BIT_MASK), ==,
53
bool cmp;
70
(buf_tx[size] & DLC_FD_BIT_MASK));
54
71
} else {
55
- DPRINTF("timer %d tick\n", id);
72
- if (!is_canfd_frame && size == 4) {
56
+ DPRINTF("timer %u tick\n", id);
73
- break;
57
74
- }
58
/* set irq status */
75
-
59
p->reg_tint_cstat |= TINT_CSTAT_STATUS(id);
76
g_assert_cmpint(buf_rx[size], ==, buf_tx[size]);
60
77
}
61
/* raise IRQ */
78
62
if (p->reg_tint_cstat & TINT_CSTAT_ENABLE(id)) {
79
@@ -XXX,XX +XXX,XX @@ static void test_can_data_transfer(void)
63
- DPRINTF("timer %d IRQ\n", id);
80
write_data(qts, CANFD0_BASE_ADDR, buf_tx, false);
64
+ DPRINTF("timer %u IRQ\n", id);
81
65
qemu_irq_raise(p->timer[id].irq);
82
send_data(qts, CANFD0_BASE_ADDR);
66
}
83
- read_data(qts, CANFD1_BASE_ADDR, buf_rx);
67
84
+ read_data(qts, CANFD1_BASE_ADDR, buf_rx, CAN_FRAME_SIZE);
68
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque)
85
match_rx_tx_data(buf_tx, buf_rx, false);
69
}
86
70
87
qtest_quit(qts);
71
if (cmp) {
88
@@ -XXX,XX +XXX,XX @@ static void test_canfd_data_transfer(void)
72
- DPRINTF("auto reload timer %d count to %x\n", id,
89
write_data(qts, CANFD0_BASE_ADDR, buf_tx, true);
73
+ DPRINTF("auto reload timer %u count to %x\n", id,
90
74
p->timer[id].reg_tcntb);
91
send_data(qts, CANFD0_BASE_ADDR);
75
ptimer_set_count(p->timer[id].ptimer, p->timer[id].reg_tcntb);
92
- read_data(qts, CANFD1_BASE_ADDR, buf_rx);
76
ptimer_run(p->timer[id].ptimer, 1);
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);
77
--
115
--
78
2.20.1
116
2.34.1
79
80
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
Fix Coverity CID 1435957: Memory - illegal accesses (OVERRUN):
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:
4
5
5
>>> Overrunning array "suffixes" of 7 8-byte elements at element
6
$ ../configure --target-list=x86_64-softmmu,aarch64-softmmu --disable-tcg --enable-xen
6
index 7 (byte offset 63) using index "idx" (which evaluates to 7).
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'
7
12
8
Note, the biggest input value freq_to_str() can accept is UINT64_MAX,
13
libqemu-aarch64-softmmu.fa.p/target_arm_gdbstub.c.o: in function `arm_gdb_get_m_systemreg':
9
which is ~18.446 EHz, less than 1000 EHz.
14
../target/arm/gdbstub.c:405: undefined reference to `arm_v7m_mrs_control'
10
15
11
Reported-by: Eduardo Habkost <ehabkost@redhat.com>
16
Signed-off-by: Fabiano Rosas <farosas@suse.de>
12
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Message-id: 20230628164821.16771-1-farosas@suse.de
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
15
Reviewed-by: Luc Michel <luc@lmichel.fr>
16
Message-id: 20201101215755.2021421-1-f4bug@amsat.org
17
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
20
---
21
util/cutils.c | 3 ++-
21
target/arm/gdbstub.c | 4 ++++
22
1 file changed, 2 insertions(+), 1 deletion(-)
22
1 file changed, 4 insertions(+)
23
23
24
diff --git a/util/cutils.c b/util/cutils.c
24
diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c
25
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
26
--- a/util/cutils.c
26
--- a/target/arm/gdbstub.c
27
+++ b/util/cutils.c
27
+++ b/target/arm/gdbstub.c
28
@@ -XXX,XX +XXX,XX @@ char *freq_to_str(uint64_t freq_hz)
28
@@ -XXX,XX +XXX,XX @@ static int arm_gen_dynamic_sysreg_xml(CPUState *cs, int base_reg)
29
double freq = freq_hz;
29
return cpu->dyn_sysreg_xml.num;
30
size_t idx = 0;
30
}
31
31
32
- while (freq >= 1000.0 && idx < ARRAY_SIZE(suffixes)) {
32
+#ifdef CONFIG_TCG
33
+ while (freq >= 1000.0) {
33
typedef enum {
34
freq /= 1000.0;
34
M_SYSREG_MSP,
35
idx++;
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
36
}
55
}
37
+ assert(idx < ARRAY_SIZE(suffixes));
56
+#endif /* CONFIG_TCG */
38
39
return g_strdup_printf("%0.3g %sHz", freq, suffixes[idx]);
40
}
57
}
41
--
58
--
42
2.20.1
59
2.34.1
43
44
diff view generated by jsdifflib
1
From: Alistair Francis <alistair.francis@wdc.com>
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
2
3
This patch fixes CID 1432800 by removing an unnecessary check.
3
AwSRAMCClass is larger than SysBusDeviceClass so the class size must be
4
advertised accordingly.
4
5
5
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
6
Fixes: 05def917e1 ("hw: arm: allwinner-sramc: Add SRAM Controller support for R40")
6
Reviewed-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>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20230628110905.38125-1-akihiko.odaki@daynix.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
12
---
9
hw/core/register.c | 4 ----
13
hw/misc/allwinner-sramc.c | 1 +
10
1 file changed, 4 deletions(-)
14
1 file changed, 1 insertion(+)
11
15
12
diff --git a/hw/core/register.c b/hw/core/register.c
16
diff --git a/hw/misc/allwinner-sramc.c b/hw/misc/allwinner-sramc.c
13
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/core/register.c
18
--- a/hw/misc/allwinner-sramc.c
15
+++ b/hw/core/register.c
19
+++ b/hw/misc/allwinner-sramc.c
16
@@ -XXX,XX +XXX,XX @@ static RegisterInfoArray *register_init_block(DeviceState *owner,
20
@@ -XXX,XX +XXX,XX @@ static const TypeInfo allwinner_sramc_info = {
17
int index = rae[i].addr / data_size;
21
.parent = TYPE_SYS_BUS_DEVICE,
18
RegisterInfo *r = &ri[index];
22
.instance_init = allwinner_sramc_init,
19
23
.instance_size = sizeof(AwSRAMCState),
20
- if (data + data_size * index == 0 || !&rae[i]) {
24
+ .class_size = sizeof(AwSRAMCClass),
21
- continue;
25
.class_init = allwinner_sramc_class_init,
22
- }
26
};
23
-
24
/* Init the register, this will zero it. */
25
object_initialize((void *)r, sizeof(*r), TYPE_REGISTER);
26
27
27
--
28
--
28
2.20.1
29
2.34.1
29
30
30
31
diff view generated by jsdifflib
1
In commit 5edab03d4040 we added tracepoints to the ps2 keyboard
1
In handle_interrupt() we use level as an index into the interrupt_vector[]
2
and mouse emulation. However we didn't remove all the debug-by-printf
2
array. This is safe because we have checked it against env->config->nlevel,
3
support. In fact there is only one printf() remaining, and it is
3
but Coverity can't see that (and it is only true because each CPU config
4
redundant with the trace_ps2_write_mouse() event next to it.
4
sets its XCHAL_NUM_INTLEVELS to something less than MAX_NLEVELS), so it
5
Remove the printf() and the now-unused DEBUG* macros.
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.
6
9
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Acked-by: Max Filippov <jcmvbkbc@gmail.com>
9
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
12
Message-id: 20230623154135.1930261-1-peter.maydell@linaro.org
10
Message-id: 20201101133258.4240-1-peter.maydell@linaro.org
11
---
13
---
12
hw/input/ps2.c | 9 ---------
14
target/xtensa/exc_helper.c | 3 +++
13
1 file changed, 9 deletions(-)
15
1 file changed, 3 insertions(+)
14
16
15
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
17
diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c
16
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/input/ps2.c
19
--- a/target/xtensa/exc_helper.c
18
+++ b/hw/input/ps2.c
20
+++ b/target/xtensa/exc_helper.c
19
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ static void handle_interrupt(CPUXtensaState *env)
20
22
CPUState *cs = env_cpu(env);
21
#include "trace.h"
23
22
24
if (level > 1) {
23
-/* debug PC keyboard */
25
+ /* env->config->nlevel check should have ensured this */
24
-//#define DEBUG_KBD
26
+ assert(level < sizeof(env->config->interrupt_vector));
25
-
27
+
26
-/* debug PC keyboard : only mouse */
28
env->sregs[EPC1 + level - 1] = env->pc;
27
-//#define DEBUG_MOUSE
29
env->sregs[EPS2 + level - 2] = env->sregs[PS];
28
-
30
env->sregs[PS] =
29
/* Keyboard Commands */
30
#define KBD_CMD_SET_LEDS    0xED    /* Set keyboard leds */
31
#define KBD_CMD_ECHO     0xEE
32
@@ -XXX,XX +XXX,XX @@ void ps2_write_mouse(void *opaque, int val)
33
PS2MouseState *s = (PS2MouseState *)opaque;
34
35
trace_ps2_write_mouse(opaque, val);
36
-#ifdef DEBUG_MOUSE
37
- printf("kbd: write mouse 0x%02x\n", val);
38
-#endif
39
switch(s->common.write_cmd) {
40
default:
41
case -1:
42
--
31
--
43
2.20.1
32
2.34.1
44
45
diff view generated by jsdifflib