1
Nothing too exciting, but does include the last bits of v8.1M support work.
1
Hi; here's a queue of arm patches (plus a few elf2dmp changes);
2
mostly these are minor cleanups and bugfixes.
2
3
4
thanks
3
-- PMM
5
-- PMM
4
6
5
The following changes since commit e79de63ab1bd1f6550e7b915e433bec1ad1a870a:
7
The following changes since commit deaca3fd30d3a8829160f8d3705d65ad83176800:
6
8
7
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210107' into staging (2021-01-07 20:34:05 +0000)
9
Merge tag 'pull-vfio-20231018' of https://github.com/legoater/qemu into staging (2023-10-18 06:21:15 -0400)
8
10
9
are available in the Git repository at:
11
are available in the Git repository at:
10
12
11
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210108
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20231019
12
14
13
for you to fetch changes up to c9f8511ea8d2b80723af0fea1f716d752c1b5208:
15
for you to fetch changes up to 2a052b4ee01b3c413cef2ef49cb780cde17d4ba1:
14
16
15
docs/system: arm: Add sabrelite board description (2021-01-08 15:13:39 +0000)
17
contrib/elf2dmp: Use g_malloc(), g_new() and g_free() (2023-10-19 14:32:13 +0100)
16
18
17
----------------------------------------------------------------
19
----------------------------------------------------------------
18
target-arm queue:
20
target-arm queue:
19
* intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs
21
* hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder
20
* target/arm: Fix MTE0_ACTIVE
22
* hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot'
21
* target/arm: Implement v8.1M and Cortex-M55 model
23
* xlnx devices: remove deprecated device reset
22
* hw/arm/highbank: Drop dead KVM support code
24
* xlnx-bbram: hw/nvram: Use dot in device type name
23
* util/qemu-timer: Make timer_free() imply timer_del()
25
* elf2dmp: fix coverity issues
24
* various devices: Use ptimer_free() in finalize function
26
* elf2dmp: convert to g_malloc, g_new and g_free
25
* docs/system: arm: Add sabrelite board description
27
* target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0
26
* sabrelite: Minor fixes to allow booting U-Boot
28
* hw/arm: refactor virt PPI logic
29
* arm/kvm: convert to kvm_set_one_reg, kvm_get_one_reg
30
* target/arm: Permit T32 LDM with single register
31
* smmuv3: Advertise SMMUv3.1-XNX
32
* target/arm: Implement FEAT_HPMN0
33
* Remove some unnecessary include lines
34
* target/arm/arm-powerctl: Correctly init CPUs when powered on to lower EL
35
* hw/timer/npcm7xx_timer: Prevent timer from counting down past zero
27
36
28
----------------------------------------------------------------
37
----------------------------------------------------------------
29
Andrew Jones (1):
38
Chris Rauer (1):
30
hw/arm/virt: Remove virt machine state 'smp_cpus'
39
hw/timer/npcm7xx_timer: Prevent timer from counting down past zero
31
40
32
Bin Meng (4):
41
Cornelia Huck (2):
33
hw/misc: imx6_ccm: Update PMU_MISC0 reset value
42
arm/kvm: convert to kvm_set_one_reg
34
hw/msic: imx6_ccm: Correct register value for silicon type
43
arm/kvm: convert to kvm_get_one_reg
35
hw/arm: sabrelite: Connect the Ethernet PHY at address 6
36
docs/system: arm: Add sabrelite board description
37
44
38
Edgar E. Iglesias (1):
45
Leif Lindholm (3):
39
intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs
46
{include/}hw/arm: refactor virt PPI logic
47
include/hw/arm: move BSA definitions to bsa.h
48
hw/arm/sbsa-ref: use bsa.h for PPI definitions
40
49
41
Gan Qixin (7):
50
Michal Orzel (1):
42
digic-timer: Use ptimer_free() in the finalize function to avoid memleaks
51
target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0
43
allwinner-a10-pit: Use ptimer_free() in the finalize function to avoid memleaks
44
exynos4210_rtc: Use ptimer_free() in the finalize function to avoid memleaks
45
exynos4210_pwm: Use ptimer_free() in the finalize function to avoid memleaks
46
mss-timer: Use ptimer_free() in the finalize function to avoid memleaks
47
musicpal: Use ptimer_free() in the finalize function to avoid memleaks
48
exynos4210_mct: Use ptimer_free() in the finalize function to avoid memleaks
49
52
50
Peter Maydell (9):
53
Peter Maydell (8):
51
hw/intc/armv7m_nvic: Correct handling of CCR.BFHFNMIGN
54
target/arm: Permit T32 LDM with single register
52
target/arm: Correct store of FPSCR value via FPCXT_S
55
hw/arm/smmuv3: Update ID register bit field definitions
53
target/arm: Implement FPCXT_NS fp system register
56
hw/arm/smmuv3: Sort ID register setting into field order
54
target/arm: Implement Cortex-M55 model
57
hw/arm/smmuv3: Advertise SMMUv3.1-XNX feature
55
hw/arm/highbank: Drop dead KVM support code
58
target/arm: Implement FEAT_HPMN0
56
util/qemu-timer: Make timer_free() imply timer_del()
59
target/arm/kvm64.c: Remove unused include
57
scripts/coccinelle: New script to remove unnecessary timer_del() calls
60
target/arm/common-semi-target.h: Remove unnecessary boot.h include
58
Remove superfluous timer_del() calls
61
target/arm/arm-powerctl: Correctly init CPUs when powered on to lower EL
59
target/arm: Remove timer_del()/timer_deinit() before timer_free()
60
62
61
Richard Henderson (1):
63
Philippe Mathieu-Daudé (1):
62
target/arm: Fix MTE0_ACTIVE
64
hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot.h'
63
65
64
docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++
66
Suraj Shirvankar (1):
65
docs/system/target-arm.rst | 1 +
67
contrib/elf2dmp: Use g_malloc(), g_new() and g_free()
66
scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++
67
include/hw/arm/virt.h | 3 +-
68
include/qemu/timer.h | 24 +++---
69
block/iscsi.c | 2 -
70
block/nbd.c | 1 -
71
block/qcow2.c | 1 -
72
hw/arm/highbank.c | 14 +--
73
hw/arm/musicpal.c | 12 +++
74
hw/arm/sabrelite.c | 4 +
75
hw/arm/virt-acpi-build.c | 9 +-
76
hw/arm/virt.c | 21 +++--
77
hw/block/nvme.c | 2 -
78
hw/char/serial.c | 2 -
79
hw/char/virtio-serial-bus.c | 2 -
80
hw/ide/core.c | 1 -
81
hw/input/hid.c | 1 -
82
hw/intc/apic.c | 1 -
83
hw/intc/arm_gic.c | 4 +-
84
hw/intc/armv7m_nvic.c | 15 ++++
85
hw/intc/ioapic.c | 1 -
86
hw/ipmi/ipmi_bmc_extern.c | 1 -
87
hw/misc/imx6_ccm.c | 4 +-
88
hw/net/e1000.c | 3 -
89
hw/net/e1000e_core.c | 8 --
90
hw/net/pcnet-pci.c | 1 -
91
hw/net/rtl8139.c | 1 -
92
hw/net/spapr_llan.c | 1 -
93
hw/net/virtio-net.c | 2 -
94
hw/rtc/exynos4210_rtc.c | 9 ++
95
hw/s390x/s390-pci-inst.c | 1 -
96
hw/sd/sd.c | 1 -
97
hw/sd/sdhci.c | 2 -
98
hw/timer/allwinner-a10-pit.c | 11 +++
99
hw/timer/digic-timer.c | 8 ++
100
hw/timer/exynos4210_mct.c | 14 +++
101
hw/timer/exynos4210_pwm.c | 11 +++
102
hw/timer/mss-timer.c | 13 +++
103
hw/usb/dev-hub.c | 1 -
104
hw/usb/hcd-ehci.c | 1 -
105
hw/usb/hcd-ohci-pci.c | 1 -
106
hw/usb/hcd-uhci.c | 1 -
107
hw/usb/hcd-xhci.c | 1 -
108
hw/usb/redirect.c | 1 -
109
hw/vfio/display.c | 1 -
110
hw/virtio/vhost-vsock-common.c | 1 -
111
hw/virtio/virtio-balloon.c | 1 -
112
hw/virtio/virtio-rng.c | 1 -
113
hw/watchdog/wdt_diag288.c | 1 -
114
hw/watchdog/wdt_i6300esb.c | 1 -
115
migration/colo.c | 1 -
116
monitor/hmp-cmds.c | 1 -
117
net/announce.c | 1 -
118
net/colo-compare.c | 1 -
119
net/slirp.c | 1 -
120
replay/replay-debugging.c | 1 -
121
target/arm/cpu.c | 2 -
122
target/arm/cpu_tcg.c | 42 +++++++++
123
target/arm/helper.c | 2 +-
124
target/s390x/cpu.c | 2 -
125
ui/console.c | 1 -
126
ui/spice-core.c | 1 -
127
util/throttle.c | 1 -
128
target/arm/translate-vfp.c.inc | 114 ++++++++++++++++++++++--
129
65 files changed, 421 insertions(+), 111 deletions(-)
130
create mode 100644 docs/system/arm/sabrelite.rst
131
create mode 100644 scripts/coccinelle/timer-del-timer-free.cocci
132
68
69
Thomas Huth (1):
70
hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder
71
72
Tong Ho (4):
73
xlnx-bbram: hw/nvram: Remove deprecated device reset
74
xlnx-zynqmp-efuse: hw/nvram: Remove deprecated device reset
75
xlnx-versal-efuse: hw/nvram: Remove deprecated device reset
76
xlnx-bbram: hw/nvram: Use dot in device type name
77
78
Viktor Prutyanov (2):
79
elf2dmp: limit print length for sign_rsds
80
elf2dmp: check array bounds in pdb_get_file_size
81
82
MAINTAINERS | 2 +-
83
docs/system/arm/emulation.rst | 1 +
84
hw/arm/smmuv3-internal.h | 38 ++++++++
85
include/hw/arm/bsa.h | 35 +++++++
86
include/hw/arm/exynos4210.h | 2 +-
87
include/hw/{misc => arm}/raspberrypi-fw-defs.h | 0
88
include/hw/arm/virt.h | 12 +--
89
include/hw/nvram/xlnx-bbram.h | 2 +-
90
target/arm/common-semi-target.h | 4 +-
91
target/arm/cpu-qom.h | 2 -
92
target/arm/cpu.h | 22 +++++
93
contrib/elf2dmp/addrspace.c | 7 +-
94
contrib/elf2dmp/main.c | 11 +--
95
contrib/elf2dmp/pdb.c | 32 ++++---
96
contrib/elf2dmp/qemu_elf.c | 7 +-
97
hw/arm/boot.c | 95 +++++--------------
98
hw/arm/sbsa-ref.c | 21 ++---
99
hw/arm/smmuv3.c | 8 +-
100
hw/arm/virt-acpi-build.c | 12 +--
101
hw/arm/virt.c | 24 +++--
102
hw/misc/bcm2835_property.c | 2 +-
103
hw/nvram/xlnx-bbram.c | 8 +-
104
hw/nvram/xlnx-versal-efuse-ctrl.c | 8 +-
105
hw/nvram/xlnx-zynqmp-efuse.c | 8 +-
106
hw/timer/npcm7xx_timer.c | 3 +
107
target/arm/arm-powerctl.c | 53 +----------
108
target/arm/cpu.c | 95 +++++++++++++++++++
109
target/arm/helper.c | 19 +---
110
target/arm/kvm.c | 28 ++----
111
target/arm/kvm64.c | 124 +++++++------------------
112
target/arm/tcg/cpu32.c | 4 +
113
target/arm/tcg/cpu64.c | 1 +
114
target/arm/tcg/translate.c | 37 +++++---
115
33 files changed, 368 insertions(+), 359 deletions(-)
116
create mode 100644 include/hw/arm/bsa.h
117
rename include/hw/{misc => arm}/raspberrypi-fw-defs.h (100%)
118
diff view generated by jsdifflib
1
Now that timer_free() implicitly calls timer_del(), sequences
1
From: Thomas Huth <thuth@redhat.com>
2
timer_del(mytimer);
3
timer_free(mytimer);
4
2
5
can be simplified to just
3
The file is obviously related to the raspberrypi machine, so
6
timer_free(mytimer);
4
it should reside in hw/arm/ instead of hw/misc/. And while we're
5
at it, also adjust the wildcard in MAINTAINERS so that it covers
6
this file, too.
7
7
8
Add a Coccinelle script to do this transformation.
8
Signed-off-by: Thomas Huth <thuth@redhat.com>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
Acked-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Message-id: 20231012073458.860187-1-thuth@redhat.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
MAINTAINERS | 2 +-
15
include/hw/{misc => arm}/raspberrypi-fw-defs.h | 0
16
hw/misc/bcm2835_property.c | 2 +-
17
3 files changed, 2 insertions(+), 2 deletions(-)
18
rename include/hw/{misc => arm}/raspberrypi-fw-defs.h (100%)
9
19
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
diff --git a/MAINTAINERS b/MAINTAINERS
11
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
21
index XXXXXXX..XXXXXXX 100644
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22
--- a/MAINTAINERS
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
23
+++ b/MAINTAINERS
14
Message-id: 20201215154107.3255-3-peter.maydell@linaro.org
24
@@ -XXX,XX +XXX,XX @@ S: Odd Fixes
15
---
25
F: hw/arm/raspi.c
16
scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++++++++++++++++
26
F: hw/arm/raspi_platform.h
17
1 file changed, 18 insertions(+)
27
F: hw/*/bcm283*
18
create mode 100644 scripts/coccinelle/timer-del-timer-free.cocci
28
-F: include/hw/arm/raspi*
19
29
+F: include/hw/arm/rasp*
20
diff --git a/scripts/coccinelle/timer-del-timer-free.cocci b/scripts/coccinelle/timer-del-timer-free.cocci
30
F: include/hw/*/bcm283*
21
new file mode 100644
31
F: docs/system/arm/raspi.rst
22
index XXXXXXX..XXXXXXX
32
23
--- /dev/null
33
diff --git a/include/hw/misc/raspberrypi-fw-defs.h b/include/hw/arm/raspberrypi-fw-defs.h
24
+++ b/scripts/coccinelle/timer-del-timer-free.cocci
34
similarity index 100%
35
rename from include/hw/misc/raspberrypi-fw-defs.h
36
rename to include/hw/arm/raspberrypi-fw-defs.h
37
diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/hw/misc/bcm2835_property.c
40
+++ b/hw/misc/bcm2835_property.c
25
@@ -XXX,XX +XXX,XX @@
41
@@ -XXX,XX +XXX,XX @@
26
+// Remove superfluous timer_del() calls
42
#include "migration/vmstate.h"
27
+//
43
#include "hw/irq.h"
28
+// Copyright Linaro Limited 2020
44
#include "hw/misc/bcm2835_mbox_defs.h"
29
+// This work is licensed under the terms of the GNU GPLv2 or later.
45
-#include "hw/misc/raspberrypi-fw-defs.h"
30
+//
46
+#include "hw/arm/raspberrypi-fw-defs.h"
31
+// spatch --macro-file scripts/cocci-macro-file.h \
47
#include "sysemu/dma.h"
32
+// --sp-file scripts/coccinelle/timer-del-timer-free.cocci \
48
#include "qemu/log.h"
33
+// --in-place --dir .
49
#include "qemu/module.h"
34
+//
35
+// The timer_free() function now implicitly calls timer_del()
36
+// for you, so calls to timer_del() immediately before the
37
+// timer_free() of the same timer can be deleted.
38
+
39
+@@
40
+expression T;
41
+@@
42
+-timer_del(T);
43
+ timer_free(T);
44
--
50
--
45
2.20.1
51
2.34.1
46
52
47
53
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
At present, when booting U-Boot on QEMU sabrelite, we see:
3
struct arm_boot_info is declared in "hw/arm/boot.h".
4
By including the correct header we don't need to declare
5
it again in "target/arm/cpu-qom.h".
4
6
5
Net: Board Net Initialization Failed
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
No ethernet found.
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
9
Message-id: 20231013130214.95742-1-philmd@linaro.org
8
U-Boot scans PHY at address 4/5/6/7 (see board_eth_init() in the
9
U-Boot source: board/boundary/nitrogen6x/nitrogen6x.c). On the real
10
board, the Ethernet PHY is at address 6. Adjust this by updating the
11
"fec-phy-num" property of the fsl_imx6 SoC object.
12
13
With this change, U-Boot sees the PHY but complains MAC address:
14
15
Net: using phy at 6
16
FEC [PRIME]
17
Error: FEC address not set.
18
19
This is due to U-Boot tries to read the MAC address from the fuse,
20
which QEMU does not have any valid content filled in. However this
21
does not prevent the Ethernet from working in QEMU. We just need to
22
set up the MAC address later in the U-Boot command shell, by:
23
24
=> setenv ethaddr 00:11:22:33:44:55
25
26
Signed-off-by: Bin Meng <bin.meng@windriver.com>
27
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
28
Message-id: 20210106063504.10841-4-bmeng.cn@gmail.com
29
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
30
---
11
---
31
hw/arm/sabrelite.c | 4 ++++
12
include/hw/arm/exynos4210.h | 2 +-
32
1 file changed, 4 insertions(+)
13
target/arm/cpu-qom.h | 2 --
14
2 files changed, 1 insertion(+), 3 deletions(-)
33
15
34
diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c
16
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
35
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
36
--- a/hw/arm/sabrelite.c
18
--- a/include/hw/arm/exynos4210.h
37
+++ b/hw/arm/sabrelite.c
19
+++ b/include/hw/arm/exynos4210.h
38
@@ -XXX,XX +XXX,XX @@ static void sabrelite_init(MachineState *machine)
20
@@ -XXX,XX +XXX,XX @@
39
21
#include "hw/intc/exynos4210_gic.h"
40
s = FSL_IMX6(object_new(TYPE_FSL_IMX6));
22
#include "hw/intc/exynos4210_combiner.h"
41
object_property_add_child(OBJECT(machine), "soc", OBJECT(s));
23
#include "hw/core/split-irq.h"
42
+
24
-#include "target/arm/cpu-qom.h"
43
+ /* Ethernet PHY address is 6 */
25
+#include "hw/arm/boot.h"
44
+ object_property_set_int(OBJECT(s), "fec-phy-num", 6, &error_fatal);
26
#include "qom/object.h"
45
+
27
46
qdev_realize(DEVICE(s), NULL, &error_fatal);
28
#define EXYNOS4210_NCPUS 2
47
29
diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
48
memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR,
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/arm/cpu-qom.h
32
+++ b/target/arm/cpu-qom.h
33
@@ -XXX,XX +XXX,XX @@
34
#include "hw/core/cpu.h"
35
#include "qom/object.h"
36
37
-struct arm_boot_info;
38
-
39
#define TYPE_ARM_CPU "arm-cpu"
40
41
OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU)
49
--
42
--
50
2.20.1
43
2.34.1
51
44
52
45
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
When running device-introspect-test, a memory leak occurred in the
3
This change implements the ResettableClass interface for the device.
4
exynos4210_mct_init function, so use ptimer_free() in the finalize function to
5
avoid it.
6
4
7
ASAN shows memory leak stack:
5
Signed-off-by: Tong Ho <tong.ho@amd.com>
8
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Indirect leak of 96 byte(s) in 1 object(s) allocated from:
7
Message-id: 20231003052345.199725-1-tong.ho@amd.com
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432
13
#3 0xaaabf56b01a0 in exynos4210_mct_init /qemu/hw/timer/exynos4210_mct.c:1505
14
#4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
15
#5 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
16
#6 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
17
#7 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59
18
#8 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110
19
#9 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136
20
#10 0xaaabf6552708 in aio_bh_poll /qemu/util/async.c:164
21
#11 0xaaabf655f19c in aio_dispatch /qemu/util/aio-posix.c:381
22
#12 0xaaabf65523f4 in aio_ctx_dispatch /qemu/util/async.c:306
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
9
---
29
hw/timer/exynos4210_mct.c | 14 ++++++++++++++
10
hw/nvram/xlnx-bbram.c | 8 +++++---
30
1 file changed, 14 insertions(+)
11
1 file changed, 5 insertions(+), 3 deletions(-)
31
12
32
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
13
diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c
33
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/timer/exynos4210_mct.c
15
--- a/hw/nvram/xlnx-bbram.c
35
+++ b/hw/timer/exynos4210_mct.c
16
+++ b/hw/nvram/xlnx-bbram.c
36
@@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_init(Object *obj)
17
@@ -XXX,XX +XXX,XX @@
37
sysbus_init_mmio(dev, &s->iomem);
18
* QEMU model of the Xilinx BBRAM Battery Backed RAM
38
}
19
*
39
20
* Copyright (c) 2014-2021 Xilinx Inc.
40
+static void exynos4210_mct_finalize(Object *obj)
21
+ * Copyright (c) 2023 Advanced Micro Devices, Inc.
41
+{
22
*
42
+ int i;
23
* Permission is hereby granted, free of charge, to any person obtaining a copy
43
+ Exynos4210MCTState *s = EXYNOS4210_MCT(obj);
24
* of this software and associated documentation files (the "Software"), to deal
44
+
25
@@ -XXX,XX +XXX,XX @@ static RegisterAccessInfo bbram_ctrl_regs_info[] = {
45
+ ptimer_free(s->g_timer.ptimer_frc);
26
}
46
+
27
};
47
+ for (i = 0; i < 2; i++) {
28
48
+ ptimer_free(s->l_timer[i].tick_timer.ptimer_tick);
29
-static void bbram_ctrl_reset(DeviceState *dev)
49
+ ptimer_free(s->l_timer[i].ptimer_frc);
30
+static void bbram_ctrl_reset_hold(Object *obj)
50
+ }
31
{
51
+}
32
- XlnxBBRam *s = XLNX_BBRAM(dev);
52
+
33
+ XlnxBBRam *s = XLNX_BBRAM(obj);
53
static void exynos4210_mct_class_init(ObjectClass *klass, void *data)
34
unsigned int i;
35
36
for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
37
@@ -XXX,XX +XXX,XX @@ static Property bbram_ctrl_props[] = {
38
static void bbram_ctrl_class_init(ObjectClass *klass, void *data)
54
{
39
{
55
DeviceClass *dc = DEVICE_CLASS(klass);
40
DeviceClass *dc = DEVICE_CLASS(klass);
56
@@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_mct_info = {
41
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
57
.parent = TYPE_SYS_BUS_DEVICE,
42
58
.instance_size = sizeof(Exynos4210MCTState),
43
- dc->reset = bbram_ctrl_reset;
59
.instance_init = exynos4210_mct_init,
44
+ rc->phases.hold = bbram_ctrl_reset_hold;
60
+ .instance_finalize = exynos4210_mct_finalize,
45
dc->realize = bbram_ctrl_realize;
61
.class_init = exynos4210_mct_class_init,
46
dc->vmsd = &vmstate_bbram_ctrl;
62
};
47
device_class_set_props(dc, bbram_ctrl_props);
63
64
--
48
--
65
2.20.1
49
2.34.1
66
50
67
51
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
When running device-introspect-test, a memory leak occurred in the
3
This change implements the ResettableClass interface for the device.
4
exynos4210_pwm_init function, so use ptimer_free() in the finalize function to
5
avoid it.
6
4
7
ASAN shows memory leak stack:
5
Signed-off-by: Tong Ho <tong.ho@amd.com>
8
6
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
9
Indirect leak of 240 byte(s) in 5 object(s) allocated from:
7
Message-id: 20231004055713.324009-1-tong.ho@amd.com
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523
13
#3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544
14
#4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562
15
#5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433
16
#6 0xaaabf56a36cc in exynos4210_pwm_init /qemu/hw/timer/exynos4210_pwm.c:401
17
#7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
18
#8 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
19
#9 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
20
#10 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59
21
#11 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110
22
#12 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
9
---
29
hw/timer/exynos4210_pwm.c | 11 +++++++++++
10
hw/nvram/xlnx-zynqmp-efuse.c | 8 +++++---
30
1 file changed, 11 insertions(+)
11
1 file changed, 5 insertions(+), 3 deletions(-)
31
12
32
diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c
13
diff --git a/hw/nvram/xlnx-zynqmp-efuse.c b/hw/nvram/xlnx-zynqmp-efuse.c
33
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/timer/exynos4210_pwm.c
15
--- a/hw/nvram/xlnx-zynqmp-efuse.c
35
+++ b/hw/timer/exynos4210_pwm.c
16
+++ b/hw/nvram/xlnx-zynqmp-efuse.c
36
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_init(Object *obj)
17
@@ -XXX,XX +XXX,XX @@
37
sysbus_init_mmio(dev, &s->iomem);
18
* QEMU model of the ZynqMP eFuse
19
*
20
* Copyright (c) 2015 Xilinx Inc.
21
+ * Copyright (c) 2023 Advanced Micro Devices, Inc.
22
*
23
* Written by Edgar E. Iglesias <edgari@xilinx.com>
24
*
25
@@ -XXX,XX +XXX,XX @@ static void zynqmp_efuse_register_reset(RegisterInfo *reg)
26
register_reset(reg);
38
}
27
}
39
28
40
+static void exynos4210_pwm_finalize(Object *obj)
29
-static void zynqmp_efuse_reset(DeviceState *dev)
41
+{
30
+static void zynqmp_efuse_reset_hold(Object *obj)
42
+ Exynos4210PWMState *s = EXYNOS4210_PWM(obj);
31
{
43
+ int i;
32
- XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(dev);
44
+
33
+ XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(obj);
45
+ for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) {
34
unsigned int i;
46
+ ptimer_free(s->timer[i].ptimer);
35
47
+ }
36
for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
48
+}
37
@@ -XXX,XX +XXX,XX @@ static Property zynqmp_efuse_props[] = {
49
+
38
static void zynqmp_efuse_class_init(ObjectClass *klass, void *data)
50
static void exynos4210_pwm_class_init(ObjectClass *klass, void *data)
51
{
39
{
52
DeviceClass *dc = DEVICE_CLASS(klass);
40
DeviceClass *dc = DEVICE_CLASS(klass);
53
@@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_pwm_info = {
41
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
54
.parent = TYPE_SYS_BUS_DEVICE,
42
55
.instance_size = sizeof(Exynos4210PWMState),
43
- dc->reset = zynqmp_efuse_reset;
56
.instance_init = exynos4210_pwm_init,
44
+ rc->phases.hold = zynqmp_efuse_reset_hold;
57
+ .instance_finalize = exynos4210_pwm_finalize,
45
dc->realize = zynqmp_efuse_realize;
58
.class_init = exynos4210_pwm_class_init,
46
dc->vmsd = &vmstate_efuse;
59
};
47
device_class_set_props(dc, zynqmp_efuse_props);
60
61
--
48
--
62
2.20.1
49
2.34.1
63
64
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
When running device-introspect-test, a memory leak occurred in the
3
This change implements the ResettableClass interface for the device.
4
exynos4210_rtc_init function, so use ptimer_free() in the finalize function to
5
avoid it.
6
4
7
ASAN shows memory leak stack:
5
Signed-off-by: Tong Ho <tong.ho@amd.com>
8
6
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
9
Indirect leak of 96 byte(s) in 1 object(s) allocated from:
7
Message-id: 20231004055339.323833-1-tong.ho@amd.com
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432
13
#3 0xaaabf57b3934 in exynos4210_rtc_init /qemu/hw/rtc/exynos4210_rtc.c:567
14
#4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
15
#5 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
16
#6 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
17
#7 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59
18
#8 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110
19
#9 0xaaabf6552708 in aio_bh_call /qemu/util/async.c:136
20
#10 0xaaabf6552708 in aio_bh_poll /qemu/util/async.c:164
21
#11 0xaaabf655f19c in aio_dispatch /qemu/util/aio-posix.c:381
22
#12 0xaaabf65523f4 in aio_ctx_dispatch /qemu/util/async.c:306
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
9
---
29
hw/rtc/exynos4210_rtc.c | 9 +++++++++
10
hw/nvram/xlnx-versal-efuse-ctrl.c | 8 +++++---
30
1 file changed, 9 insertions(+)
11
1 file changed, 5 insertions(+), 3 deletions(-)
31
12
32
diff --git a/hw/rtc/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c
13
diff --git a/hw/nvram/xlnx-versal-efuse-ctrl.c b/hw/nvram/xlnx-versal-efuse-ctrl.c
33
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/rtc/exynos4210_rtc.c
15
--- a/hw/nvram/xlnx-versal-efuse-ctrl.c
35
+++ b/hw/rtc/exynos4210_rtc.c
16
+++ b/hw/nvram/xlnx-versal-efuse-ctrl.c
36
@@ -XXX,XX +XXX,XX @@ static void exynos4210_rtc_init(Object *obj)
17
@@ -XXX,XX +XXX,XX @@
37
sysbus_init_mmio(dev, &s->iomem);
18
* QEMU model of the Versal eFuse controller
19
*
20
* Copyright (c) 2020 Xilinx Inc.
21
+ * Copyright (c) 2023 Advanced Micro Devices, Inc.
22
*
23
* Permission is hereby granted, free of charge, to any person obtaining a copy
24
* of this software and associated documentation files (the "Software"), to deal
25
@@ -XXX,XX +XXX,XX @@ static void efuse_ctrl_register_reset(RegisterInfo *reg)
26
register_reset(reg);
38
}
27
}
39
28
40
+static void exynos4210_rtc_finalize(Object *obj)
29
-static void efuse_ctrl_reset(DeviceState *dev)
41
+{
30
+static void efuse_ctrl_reset_hold(Object *obj)
42
+ Exynos4210RTCState *s = EXYNOS4210_RTC(obj);
31
{
43
+
32
- XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(dev);
44
+ ptimer_free(s->ptimer);
33
+ XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(obj);
45
+ ptimer_free(s->ptimer_1Hz);
34
unsigned int i;
46
+}
35
47
+
36
for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
48
static void exynos4210_rtc_class_init(ObjectClass *klass, void *data)
37
@@ -XXX,XX +XXX,XX @@ static Property efuse_ctrl_props[] = {
38
static void efuse_ctrl_class_init(ObjectClass *klass, void *data)
49
{
39
{
50
DeviceClass *dc = DEVICE_CLASS(klass);
40
DeviceClass *dc = DEVICE_CLASS(klass);
51
@@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_rtc_info = {
41
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
52
.parent = TYPE_SYS_BUS_DEVICE,
42
53
.instance_size = sizeof(Exynos4210RTCState),
43
- dc->reset = efuse_ctrl_reset;
54
.instance_init = exynos4210_rtc_init,
44
+ rc->phases.hold = efuse_ctrl_reset_hold;
55
+ .instance_finalize = exynos4210_rtc_finalize,
45
dc->realize = efuse_ctrl_realize;
56
.class_init = exynos4210_rtc_class_init,
46
dc->vmsd = &vmstate_efuse_ctrl;
57
};
47
device_class_set_props(dc, efuse_ctrl_props);
58
59
--
48
--
60
2.20.1
49
2.34.1
61
62
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
Currently when U-Boot boots, it prints "??" for i.MX processor:
3
This replaces the comma (,) to dot (.) in the device type name
4
so the name can be used with the 'driver=' command line option.
4
5
5
CPU: Freescale i.MX?? rev1.0 at 792 MHz
6
Signed-off-by: Tong Ho <tong.ho@amd.com>
6
7
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
7
The register that was used to determine the silicon type is
8
Message-id: 20231003052139.199665-1-tong.ho@amd.com
8
undocumented in the latest IMX6DQRM (Rev. 6, 05/2020), but we
9
can refer to get_cpu_rev() in arch/arm/mach-imx/mx6/soc.c in
10
the U-Boot source codes that USB_ANALOG_DIGPROG is used.
11
12
Update its reset value to indicate i.MX6Q.
13
14
Signed-off-by: Bin Meng <bin.meng@windriver.com>
15
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
16
Message-id: 20210106063504.10841-3-bmeng.cn@gmail.com
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
10
---
19
hw/misc/imx6_ccm.c | 2 +-
11
include/hw/nvram/xlnx-bbram.h | 2 +-
20
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 1 insertion(+), 1 deletion(-)
21
13
22
diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c
14
diff --git a/include/hw/nvram/xlnx-bbram.h b/include/hw/nvram/xlnx-bbram.h
23
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
24
--- a/hw/misc/imx6_ccm.c
16
--- a/include/hw/nvram/xlnx-bbram.h
25
+++ b/hw/misc/imx6_ccm.c
17
+++ b/include/hw/nvram/xlnx-bbram.h
26
@@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev)
18
@@ -XXX,XX +XXX,XX @@
27
s->analog[USB_ANALOG_USB2_VBUS_DETECT] = 0x00000004;
19
28
s->analog[USB_ANALOG_USB2_CHRG_DETECT] = 0x00000000;
20
#define RMAX_XLNX_BBRAM ((0x4c / 4) + 1)
29
s->analog[USB_ANALOG_USB2_MISC] = 0x00000002;
21
30
- s->analog[USB_ANALOG_DIGPROG] = 0x00000000;
22
-#define TYPE_XLNX_BBRAM "xlnx,bbram-ctrl"
31
+ s->analog[USB_ANALOG_DIGPROG] = 0x00630000;
23
+#define TYPE_XLNX_BBRAM "xlnx.bbram-ctrl"
32
24
OBJECT_DECLARE_SIMPLE_TYPE(XlnxBBRam, XLNX_BBRAM);
33
/* all PLLs need to be locked */
25
34
s->analog[CCM_ANALOG_PLL_ARM] |= CCM_ANALOG_PLL_LOCK;
26
struct XlnxBBRam {
35
--
27
--
36
2.20.1
28
2.34.1
37
38
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Viktor Prutyanov <viktor@daynix.com>
2
2
3
U-Boot expects PMU_MISC0 register bit 7 is set (see init_bandgap()
3
String sign_rsds isn't terminated, so the print length must be limited.
4
in arch/arm/mach-imx/mx6/soc.c) during boot. This bit indicates the
5
bandgap has stabilized.
6
4
7
With this change, the latest upstream U-Boot (v2021.01-rc3) for imx6
5
Fixes: Coverity CID 1521598
8
sabrelite board (mx6qsabrelite_defconfig), with a slight change made
6
Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
9
by switching CONFIG_OF_SEPARATE to CONFIG_OF_EMBED, boots to U-Boot
7
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
10
shell on QEMU with the following command:
8
Message-id: 20230930235317.11469-2-viktor@daynix.com
11
12
$ qemu-system-arm -M sabrelite -smp 4 -m 1G -kernel u-boot \
13
-display none -serial null -serial stdio
14
15
Boot log below:
16
17
U-Boot 2021.01-rc3 (Dec 12 2020 - 17:40:02 +0800)
18
19
CPU: Freescale i.MX?? rev1.0 at 792 MHz
20
Reset cause: POR
21
Model: Freescale i.MX6 Quad SABRE Lite Board
22
Board: SABRE Lite
23
I2C: ready
24
DRAM: 1 GiB
25
force_idle_bus: sda=0 scl=0 sda.gp=0x5c scl.gp=0x55
26
force_idle_bus: failed to clear bus, sda=0 scl=0
27
force_idle_bus: sda=0 scl=0 sda.gp=0x6d scl.gp=0x6c
28
force_idle_bus: failed to clear bus, sda=0 scl=0
29
force_idle_bus: sda=0 scl=0 sda.gp=0xcb scl.gp=0x5
30
force_idle_bus: failed to clear bus, sda=0 scl=0
31
MMC: FSL_SDHC: 0, FSL_SDHC: 1
32
Loading Environment from MMC... *** Warning - No block device, using default environment
33
34
In: serial
35
Out: serial
36
Err: serial
37
Net: Board Net Initialization Failed
38
No ethernet found.
39
starting USB...
40
Bus usb@2184000: usb dr_mode not found
41
USB EHCI 1.00
42
Bus usb@2184200: USB EHCI 1.00
43
scanning bus usb@2184000 for devices... 1 USB Device(s) found
44
scanning bus usb@2184200 for devices... 1 USB Device(s) found
45
scanning usb for storage devices... 0 Storage Device(s) found
46
scanning usb for ethernet devices... 0 Ethernet Device(s) found
47
Hit any key to stop autoboot: 0
48
=>
49
50
Signed-off-by: Bin Meng <bin.meng@windriver.com>
51
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
52
Message-id: 20210106063504.10841-2-bmeng.cn@gmail.com
53
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
54
---
10
---
55
hw/misc/imx6_ccm.c | 2 +-
11
contrib/elf2dmp/main.c | 2 +-
56
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 1 insertion(+), 1 deletion(-)
57
13
58
diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c
14
diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c
59
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
60
--- a/hw/misc/imx6_ccm.c
16
--- a/contrib/elf2dmp/main.c
61
+++ b/hw/misc/imx6_ccm.c
17
+++ b/contrib/elf2dmp/main.c
62
@@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev)
18
@@ -XXX,XX +XXX,XX @@ static bool pe_check_pdb_name(uint64_t base, void *start_addr,
63
s->analog[PMU_REG_3P0] = 0x00000F74;
19
}
64
s->analog[PMU_REG_2P5] = 0x00005071;
20
65
s->analog[PMU_REG_CORE] = 0x00402010;
21
if (memcmp(&rsds->Signature, sign_rsds, sizeof(sign_rsds))) {
66
- s->analog[PMU_MISC0] = 0x04000000;
22
- eprintf("CodeView signature is \'%.4s\', \'%s\' expected\n",
67
+ s->analog[PMU_MISC0] = 0x04000080;
23
+ eprintf("CodeView signature is \'%.4s\', \'%.4s\' expected\n",
68
s->analog[PMU_MISC1] = 0x00000000;
24
rsds->Signature, sign_rsds);
69
s->analog[PMU_MISC2] = 0x00272727;
25
return false;
70
26
}
71
--
27
--
72
2.20.1
28
2.34.1
73
74
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Viktor Prutyanov <viktor@daynix.com>
2
2
3
When running device-introspect-test, a memory leak occurred in the
3
Index in file_size array must be checked against num_files, because the
4
mv88w8618_pit_init function, so use ptimer_free() in the finalize function to
4
entries we are looking for may be absent in the PDB.
5
avoid it.
6
5
7
ASAN shows memory leak stack:
6
Fixes: Coverity CID 1521597
8
7
Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
9
Indirect leak of 192 byte(s) in 4 object(s) allocated from:
8
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
10
Message-id: 20230930235317.11469-3-viktor@daynix.com
12
#2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523
13
#3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544
14
#4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562
15
#5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433
16
#6 0xaaabf5bb2290 in mv88w8618_timer_init /qemu/hw/arm/musicpal.c:862
17
#7 0xaaabf5bb2290 in mv88w8618_pit_init /qemu/hw/arm/musicpal.c:954
18
#8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
19
#9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
20
#10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
21
#11 0xaaabf5a95540 in qdev_device_help /qemu/softmmu/qdev-monitor.c:283
22
#12 0xaaabf5a96940 in qmp_device_add /qemu/softmmu/qdev-monitor.c:801
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
12
---
29
hw/arm/musicpal.c | 12 ++++++++++++
13
contrib/elf2dmp/pdb.c | 13 +++++++++----
30
1 file changed, 12 insertions(+)
14
1 file changed, 9 insertions(+), 4 deletions(-)
31
15
32
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
16
diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
33
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/musicpal.c
18
--- a/contrib/elf2dmp/pdb.c
35
+++ b/hw/arm/musicpal.c
19
+++ b/contrib/elf2dmp/pdb.c
36
@@ -XXX,XX +XXX,XX @@ static void mv88w8618_pit_init(Object *obj)
20
@@ -XXX,XX +XXX,XX @@
37
sysbus_init_mmio(dev, &s->iomem);
21
22
static uint32_t pdb_get_file_size(const struct pdb_reader *r, unsigned idx)
23
{
24
+ if (idx >= r->ds.toc->num_files) {
25
+ return 0;
26
+ }
27
+
28
return r->ds.toc->file_size[idx];
38
}
29
}
39
30
40
+static void mv88w8618_pit_finalize(Object *obj)
31
@@ -XXX,XX +XXX,XX @@ static void *pdb_ds_read_file(struct pdb_reader* r, uint32_t file_number)
41
+{
32
42
+ SysBusDevice *dev = SYS_BUS_DEVICE(obj);
33
static int pdb_init_segments(struct pdb_reader *r)
43
+ mv88w8618_pit_state *s = MV88W8618_PIT(dev);
34
{
44
+ int i;
35
- char *segs;
45
+
36
unsigned stream_idx = r->segments;
46
+ for (i = 0; i < 4; i++) {
37
47
+ ptimer_free(s->timer[i].ptimer);
38
- segs = pdb_ds_read_file(r, stream_idx);
39
- if (!segs) {
40
+ r->segs = pdb_ds_read_file(r, stream_idx);
41
+ if (!r->segs) {
42
return 1;
43
}
44
45
- r->segs = segs;
46
r->segs_size = pdb_get_file_size(r, stream_idx);
47
+ if (!r->segs_size) {
48
+ return 1;
48
+ }
49
+ }
49
+}
50
50
+
51
return 0;
51
static const VMStateDescription mv88w8618_timer_vmsd = {
52
}
52
.name = "timer",
53
.version_id = 1,
54
@@ -XXX,XX +XXX,XX @@ static const TypeInfo mv88w8618_pit_info = {
55
.parent = TYPE_SYS_BUS_DEVICE,
56
.instance_size = sizeof(mv88w8618_pit_state),
57
.instance_init = mv88w8618_pit_init,
58
+ .instance_finalize = mv88w8618_pit_finalize,
59
.class_init = mv88w8618_pit_class_init,
60
};
61
62
--
53
--
63
2.20.1
54
2.34.1
64
55
65
56
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Michal Orzel <michal.orzel@amd.com>
2
2
3
In 50244cc76abc we updated mte_check_fail to match the ARM
3
On an attempt to access CNTPCT_EL0 from EL0 using a guest running on top
4
pseudocode, using the correct EL to select the TCF field.
4
of Xen, a trap from EL2 was observed which is something not reproducible
5
But we failed to update MTE0_ACTIVE the same way, which led
5
on HW (also, Xen does not trap accesses to physical counter).
6
to g_assert_not_reached().
7
6
8
Cc: qemu-stable@nongnu.org
7
This is because gt_counter_access() checks for an incorrect bit (1
9
Buglink: https://bugs.launchpad.net/bugs/1907137
8
instead of 0) of CNTHCTL_EL2 if HCR_EL2.E2H is 0 and access is made to
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
physical counter. Refer ARM ARM DDI 0487J.a, D19.12.2:
11
Message-id: 20201221204426.88514-1-richard.henderson@linaro.org
10
When HCR_EL2.E2H is 0:
11
- EL1PCTEN, bit [0]: refers to physical counter
12
- EL1PCEN, bit [1]: refers to physical timer registers
13
14
Drop entire block "if (hcr & HCR_E2H) {...} else {...}" from EL0 case
15
and fall through to EL1 case, given that after fixing checking for the
16
correct bit, the handling is the same.
17
18
Fixes: 5bc8437136fb ("target/arm: Update timer access for VHE")
19
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
20
Tested-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
21
Message-id: 20230928094404.20802-1-michal.orzel@amd.com
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
22
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
24
---
15
target/arm/helper.c | 2 +-
25
target/arm/helper.c | 17 +----------------
16
1 file changed, 1 insertion(+), 1 deletion(-)
26
1 file changed, 1 insertion(+), 16 deletions(-)
17
27
18
diff --git a/target/arm/helper.c b/target/arm/helper.c
28
diff --git a/target/arm/helper.c b/target/arm/helper.c
19
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/helper.c
30
--- a/target/arm/helper.c
21
+++ b/target/arm/helper.c
31
+++ b/target/arm/helper.c
22
@@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
32
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx,
23
if (FIELD_EX32(flags, TBFLAG_A64, UNPRIV)
33
if (!extract32(env->cp15.c14_cntkctl, timeridx, 1)) {
24
&& tbid
34
return CP_ACCESS_TRAP;
25
&& !(env->pstate & PSTATE_TCO)
26
- && (sctlr & SCTLR_TCF0)
27
+ && (sctlr & SCTLR_TCF)
28
&& allocation_tag_access_enabled(env, 0, sctlr)) {
29
flags = FIELD_DP32(flags, TBFLAG_A64, MTE0_ACTIVE, 1);
30
}
35
}
36
-
37
- /* If HCR_EL2.<E2H,TGE> == '10': check CNTHCTL_EL2.EL1PCTEN. */
38
- if (hcr & HCR_E2H) {
39
- if (timeridx == GTIMER_PHYS &&
40
- !extract32(env->cp15.cnthctl_el2, 10, 1)) {
41
- return CP_ACCESS_TRAP_EL2;
42
- }
43
- } else {
44
- /* If HCR_EL2.<E2H> == 0: check CNTHCTL_EL2.EL1PCEN. */
45
- if (has_el2 && timeridx == GTIMER_PHYS &&
46
- !extract32(env->cp15.cnthctl_el2, 1, 1)) {
47
- return CP_ACCESS_TRAP_EL2;
48
- }
49
- }
50
- break;
51
-
52
+ /* fall through */
53
case 1:
54
/* Check CNTHCTL_EL2.EL1PCTEN, which changes location based on E2H. */
55
if (has_el2 && timeridx == GTIMER_PHYS &&
31
--
56
--
32
2.20.1
57
2.34.1
33
34
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
2
2
3
virt machine's 'smp_cpus' and machine->smp.cpus must always have the
3
GIC Private Peripheral Interrupts (PPI) are defined as GIC INTID 16-31.
4
same value. And, anywhere we have virt machine state we have machine
4
As in, PPI0 is INTID16 .. PPI15 is INTID31.
5
state. So let's remove the redundancy. Also, to make it easier to see
5
Arm's Base System Architecture specification (BSA) lists the mandated and
6
that machine->smp is the true source for "smp_cpus" and "max_cpus",
6
recommended private interrupt IDs by INTID, not by PPI index. But current
7
avoid passing them in function parameters, preferring instead to get
7
definitions in virt define them by PPI index, complicating cross
8
them from the state.
8
referencing.
9
9
10
No functional change intended.
10
Meanwhile, the PPI(x) macro counterintuitively adds 16 to the input value,
11
converting a PPI index to an INTID.
11
12
12
Signed-off-by: Andrew Jones <drjones@redhat.com>
13
Resolve this by redefining the BSA-allocated PPIs by their INTIDs,
13
Reviewed-by: David Edmondson <david.edmondson@oracle.com>
14
and replacing the PPI(x) macro with an INTID_TO_PPI(x) one where required.
14
Reviewed-by: Ying Fang <fangying1@huawei.com>
15
15
Message-id: 20201215174815.51520-1-drjones@redhat.com
16
Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
16
[PMM: minor formatting tweak to smp_cpus variable declaration]
17
Message-id: 20230919090229.188092-2-quic_llindhol@quicinc.com
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
20
---
19
include/hw/arm/virt.h | 3 +--
21
include/hw/arm/virt.h | 14 +++++++-------
20
hw/arm/virt-acpi-build.c | 9 +++++----
22
hw/arm/virt-acpi-build.c | 12 ++++++------
21
hw/arm/virt.c | 21 ++++++++++-----------
23
hw/arm/virt.c | 24 ++++++++++++++----------
22
3 files changed, 16 insertions(+), 17 deletions(-)
24
3 files changed, 27 insertions(+), 23 deletions(-)
23
25
24
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
26
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
25
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/arm/virt.h
28
--- a/include/hw/arm/virt.h
27
+++ b/include/hw/arm/virt.h
29
+++ b/include/hw/arm/virt.h
28
@@ -XXX,XX +XXX,XX @@ struct VirtMachineState {
30
@@ -XXX,XX +XXX,XX @@
29
MemMapEntry *memmap;
31
#define NUM_VIRTIO_TRANSPORTS 32
30
char *pciehb_nodename;
32
#define NUM_SMMU_IRQS 4
31
const int *irqmap;
33
32
- int smp_cpus;
34
-#define ARCH_GIC_MAINT_IRQ 9
33
void *fdt;
35
+#define ARCH_GIC_MAINT_IRQ 25
34
int fdt_size;
36
35
uint32_t clock_phandle;
37
-#define ARCH_TIMER_VIRT_IRQ 11
36
@@ -XXX,XX +XXX,XX @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)
38
-#define ARCH_TIMER_S_EL1_IRQ 13
37
39
-#define ARCH_TIMER_NS_EL1_IRQ 14
38
assert(vms->gic_version == VIRT_GIC_VERSION_3);
40
-#define ARCH_TIMER_NS_EL2_IRQ 10
39
41
+#define ARCH_TIMER_VIRT_IRQ 27
40
- return vms->smp_cpus > redist0_capacity ? 2 : 1;
42
+#define ARCH_TIMER_S_EL1_IRQ 29
41
+ return MACHINE(vms)->smp.cpus > redist0_capacity ? 2 : 1;
43
+#define ARCH_TIMER_NS_EL1_IRQ 30
42
}
44
+#define ARCH_TIMER_NS_EL2_IRQ 26
43
45
44
#endif /* QEMU_ARM_VIRT_H */
46
-#define VIRTUAL_PMU_IRQ 7
47
+#define VIRTUAL_PMU_IRQ 23
48
49
-#define PPI(irq) ((irq) + 16)
50
+#define INTID_TO_PPI(irq) ((irq) - 16)
51
52
/* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */
53
#define PVTIME_SIZE_PER_CPU 64
45
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
54
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
46
index XXXXXXX..XXXXXXX 100644
55
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/arm/virt-acpi-build.c
56
--- a/hw/arm/virt-acpi-build.c
48
+++ b/hw/arm/virt-acpi-build.c
57
+++ b/hw/arm/virt-acpi-build.c
49
@@ -XXX,XX +XXX,XX @@
58
@@ -XXX,XX +XXX,XX @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
50
59
* The interrupt values are the same with the device tree when adding 16
51
#define ACPI_BUILD_TABLE_SIZE 0x20000
60
*/
52
61
/* Secure EL1 timer GSIV */
53
-static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus)
62
- build_append_int_noprefix(table_data, ARCH_TIMER_S_EL1_IRQ + 16, 4);
54
+static void acpi_dsdt_add_cpus(Aml *scope, VirtMachineState *vms)
63
+ build_append_int_noprefix(table_data, ARCH_TIMER_S_EL1_IRQ, 4);
55
{
64
/* Secure EL1 timer Flags */
56
+ MachineState *ms = MACHINE(vms);
65
build_append_int_noprefix(table_data, irqflags, 4);
57
uint16_t i;
66
/* Non-Secure EL1 timer GSIV */
58
67
- build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL1_IRQ + 16, 4);
59
- for (i = 0; i < smp_cpus; i++) {
68
+ build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL1_IRQ, 4);
60
+ for (i = 0; i < ms->smp.cpus; i++) {
69
/* Non-Secure EL1 timer Flags */
61
Aml *dev = aml_device("C%.03X", i);
70
build_append_int_noprefix(table_data, irqflags |
62
aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007")));
71
1UL << 2, /* Always-on Capability */
63
aml_append(dev, aml_name_decl("_UID", aml_int(i)));
72
4);
73
/* Virtual timer GSIV */
74
- build_append_int_noprefix(table_data, ARCH_TIMER_VIRT_IRQ + 16, 4);
75
+ build_append_int_noprefix(table_data, ARCH_TIMER_VIRT_IRQ, 4);
76
/* Virtual Timer Flags */
77
build_append_int_noprefix(table_data, irqflags, 4);
78
/* Non-Secure EL2 timer GSIV */
79
- build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_IRQ + 16, 4);
80
+ build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_IRQ, 4);
81
/* Non-Secure EL2 timer Flags */
82
build_append_int_noprefix(table_data, irqflags, 4);
83
/* CntReadBase Physical address */
64
@@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
84
@@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
65
gicd->base_address = cpu_to_le64(memmap[VIRT_GIC_DIST].base);
85
for (i = 0; i < MACHINE(vms)->smp.cpus; i++) {
66
gicd->version = vms->gic_version;
67
68
- for (i = 0; i < vms->smp_cpus; i++) {
69
+ for (i = 0; i < MACHINE(vms)->smp.cpus; i++) {
70
AcpiMadtGenericCpuInterface *gicc = acpi_data_push(table_data,
71
sizeof(*gicc));
72
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
86
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
73
@@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
87
uint64_t physical_base_address = 0, gich = 0, gicv = 0;
74
* the RTC ACPI device at all when using UEFI.
88
- uint32_t vgic_interrupt = vms->virt ? PPI(ARCH_GIC_MAINT_IRQ) : 0;
75
*/
89
+ uint32_t vgic_interrupt = vms->virt ? ARCH_GIC_MAINT_IRQ : 0;
76
scope = aml_scope("\\_SB");
90
uint32_t pmu_interrupt = arm_feature(&armcpu->env, ARM_FEATURE_PMU) ?
77
- acpi_dsdt_add_cpus(scope, vms->smp_cpus);
91
- PPI(VIRTUAL_PMU_IRQ) : 0;
78
+ acpi_dsdt_add_cpus(scope, vms);
92
+ VIRTUAL_PMU_IRQ : 0;
79
acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
93
80
(irqmap[VIRT_UART] + ARM_SPI_BASE));
94
if (vms->gic_version == VIRT_GIC_VERSION_2) {
81
if (vmc->acpi_expose_flash) {
95
physical_base_address = memmap[VIRT_GIC_CPU].base;
82
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
96
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
83
index XXXXXXX..XXXXXXX 100644
97
index XXXXXXX..XXXXXXX 100644
84
--- a/hw/arm/virt.c
98
--- a/hw/arm/virt.c
85
+++ b/hw/arm/virt.c
99
+++ b/hw/arm/virt.c
86
@@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms)
100
@@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms)
87
if (vms->gic_version == VIRT_GIC_VERSION_2) {
88
irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,
89
GIC_FDT_IRQ_PPI_CPU_WIDTH,
90
- (1 << vms->smp_cpus) - 1);
91
+ (1 << MACHINE(vms)->smp.cpus) - 1);
92
}
101
}
93
102
qemu_fdt_setprop(ms->fdt, "/timer", "always-on", NULL, 0);
94
qemu_fdt_add_subnode(vms->fdt, "/timer");
103
qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts",
95
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
104
- GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_S_EL1_IRQ, irqflags,
96
int cpu;
105
- GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL1_IRQ, irqflags,
97
int addr_cells = 1;
106
- GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_VIRT_IRQ, irqflags,
98
const MachineState *ms = MACHINE(vms);
107
- GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL2_IRQ, irqflags);
99
+ int smp_cpus = ms->smp.cpus;
108
+ GIC_FDT_IRQ_TYPE_PPI,
100
109
+ INTID_TO_PPI(ARCH_TIMER_S_EL1_IRQ), irqflags,
101
/*
110
+ GIC_FDT_IRQ_TYPE_PPI,
102
* From Documentation/devicetree/bindings/arm/cpus.txt
111
+ INTID_TO_PPI(ARCH_TIMER_NS_EL1_IRQ), irqflags,
103
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
112
+ GIC_FDT_IRQ_TYPE_PPI,
104
* The simplest way to go is to examine affinity IDs of all our CPUs. If
113
+ INTID_TO_PPI(ARCH_TIMER_VIRT_IRQ), irqflags,
105
* at least one of them has Aff3 populated, we set #address-cells to 2.
114
+ GIC_FDT_IRQ_TYPE_PPI,
115
+ INTID_TO_PPI(ARCH_TIMER_NS_EL2_IRQ), irqflags);
116
}
117
118
static void fdt_add_cpu_nodes(const VirtMachineState *vms)
119
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
106
*/
120
*/
107
- for (cpu = 0; cpu < vms->smp_cpus; cpu++) {
121
for (i = 0; i < smp_cpus; i++) {
108
+ for (cpu = 0; cpu < smp_cpus; cpu++) {
122
DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
109
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
123
- int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS;
110
124
+ int intidbase = NUM_IRQS + i * GIC_INTERNAL;
111
if (armcpu->mp_affinity & ARM_AFF3_MASK) {
125
/* Mapping from the output timer irq lines from the CPU to the
112
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
126
* GIC PPI inputs we use for the virt board.
113
qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#address-cells", addr_cells);
127
*/
114
qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#size-cells", 0x0);
128
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
115
129
for (unsigned irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
116
- for (cpu = vms->smp_cpus - 1; cpu >= 0; cpu--) {
130
qdev_connect_gpio_out(cpudev, irq,
117
+ for (cpu = smp_cpus - 1; cpu >= 0; cpu--) {
131
qdev_get_gpio_in(vms->gic,
118
char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu);
132
- ppibase + timer_irq[irq]));
119
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
133
+ intidbase + timer_irq[irq]));
120
CPUState *cs = CPU(armcpu);
121
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
122
qemu_fdt_setprop_string(vms->fdt, nodename, "compatible",
123
armcpu->dtb_compatible);
124
125
- if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED
126
- && vms->smp_cpus > 1) {
127
+ if (vms->psci_conduit != QEMU_PSCI_CONDUIT_DISABLED && smp_cpus > 1) {
128
qemu_fdt_setprop_string(vms->fdt, nodename,
129
"enable-method", "psci");
130
}
134
}
131
@@ -XXX,XX +XXX,XX @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms)
135
132
if (vms->gic_version == VIRT_GIC_VERSION_2) {
136
if (vms->gic_version != VIRT_GIC_VERSION_2) {
133
irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,
137
qemu_irq irq = qdev_get_gpio_in(vms->gic,
134
GIC_FDT_IRQ_PPI_CPU_WIDTH,
138
- ppibase + ARCH_GIC_MAINT_IRQ);
135
- (1 << vms->smp_cpus) - 1);
139
+ intidbase + ARCH_GIC_MAINT_IRQ);
136
+ (1 << MACHINE(vms)->smp.cpus) - 1);
140
qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt",
137
}
141
0, irq);
138
142
} else if (vms->virt) {
139
qemu_fdt_add_subnode(vms->fdt, "/pmu");
143
qemu_irq irq = qdev_get_gpio_in(vms->gic,
140
@@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms)
144
- ppibase + ARCH_GIC_MAINT_IRQ);
141
* virt_cpu_post_init() must be called after the CPUs have
145
+ intidbase + ARCH_GIC_MAINT_IRQ);
142
* been realized and the GIC has been created.
146
sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus, irq);
143
*/
147
}
144
-static void virt_cpu_post_init(VirtMachineState *vms, int max_cpus,
148
145
- MemoryRegion *sysmem)
149
qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0,
146
+static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)
150
- qdev_get_gpio_in(vms->gic, ppibase
147
{
151
+ qdev_get_gpio_in(vms->gic, intidbase
148
+ int max_cpus = MACHINE(vms)->smp.max_cpus;
152
+ VIRTUAL_PMU_IRQ));
149
bool aarch64, pmu, steal_time;
153
150
CPUState *cpu;
154
sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
151
155
@@ -XXX,XX +XXX,XX @@ static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)
152
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
156
if (pmu) {
153
exit(1);
157
assert(arm_feature(&ARM_CPU(cpu)->env, ARM_FEATURE_PMU));
154
}
158
if (kvm_irqchip_in_kernel()) {
155
159
- kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ));
156
- vms->smp_cpus = smp_cpus;
160
+ kvm_arm_pmu_set_irq(cpu, VIRTUAL_PMU_IRQ);
157
-
161
}
158
if (vms->virt && kvm_enabled()) {
162
kvm_arm_pmu_init(cpu);
159
error_report("mach-virt: KVM does not support providing "
163
}
160
"Virtualization extensions to the guest CPU");
161
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
162
create_fdt(vms);
163
164
possible_cpus = mc->possible_cpu_arch_ids(machine);
165
+ assert(possible_cpus->len == max_cpus);
166
for (n = 0; n < possible_cpus->len; n++) {
167
Object *cpuobj;
168
CPUState *cs;
169
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
170
171
create_gic(vms);
172
173
- virt_cpu_post_init(vms, possible_cpus->len, sysmem);
174
+ virt_cpu_post_init(vms, sysmem);
175
176
fdt_add_pmu_nodes(vms);
177
178
--
164
--
179
2.20.1
165
2.34.1
180
181
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
2
2
3
This adds the target guide for SABRE Lite board, and documents how
3
virt.h defines a number of IRQs that are ultimately described by Arm's
4
to boot a Linux kernel and U-Boot bootloader.
4
Base System Architecture specification. Move these to a dedicated header
5
so that they can be reused by other platforms that do the same.
6
Include that header from virt.h to minimise churn.
5
7
6
Signed-off-by: Bin Meng <bin.meng@windriver.com>
8
While we're moving the definitions, sort them into numerical order,
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
9
and add the ARCH_TIMER_NS_EL2_VIRT_IRQ definition used by sbsa-ref
8
Message-id: 20210106063504.10841-5-bmeng.cn@gmail.com
10
and which will eventually be needed by virt also.
11
12
Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
13
Message-id: 20230919090229.188092-3-quic_llindhol@quicinc.com
14
[PMM: Remove unused PPI_TO_INTID macro; sort numerically;
15
add ARCH_TIMER_NS_EL2_VIRT_IRQ]
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
18
---
11
docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++++++++++
19
include/hw/arm/bsa.h | 35 +++++++++++++++++++++++++++++++++++
12
docs/system/target-arm.rst | 1 +
20
include/hw/arm/virt.h | 12 +-----------
13
2 files changed, 120 insertions(+)
21
2 files changed, 36 insertions(+), 11 deletions(-)
14
create mode 100644 docs/system/arm/sabrelite.rst
22
create mode 100644 include/hw/arm/bsa.h
15
23
16
diff --git a/docs/system/arm/sabrelite.rst b/docs/system/arm/sabrelite.rst
24
diff --git a/include/hw/arm/bsa.h b/include/hw/arm/bsa.h
17
new file mode 100644
25
new file mode 100644
18
index XXXXXXX..XXXXXXX
26
index XXXXXXX..XXXXXXX
19
--- /dev/null
27
--- /dev/null
20
+++ b/docs/system/arm/sabrelite.rst
28
+++ b/include/hw/arm/bsa.h
21
@@ -XXX,XX +XXX,XX @@
29
@@ -XXX,XX +XXX,XX @@
22
+Boundary Devices SABRE Lite (``sabrelite``)
30
+/*
23
+===========================================
31
+ * Common definitions for Arm Base System Architecture (BSA) platforms.
32
+ *
33
+ * Copyright (c) 2015 Linaro Limited
34
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
35
+ *
36
+ * This program is free software; you can redistribute it and/or modify it
37
+ * under the terms and conditions of the GNU General Public License,
38
+ * version 2 or later, as published by the Free Software Foundation.
39
+ *
40
+ * This program is distributed in the hope it will be useful, but WITHOUT
41
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
42
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
43
+ * more details.
44
+ *
45
+ * You should have received a copy of the GNU General Public License along with
46
+ * this program. If not, see <http://www.gnu.org/licenses/>.
47
+ *
48
+ */
24
+
49
+
25
+Boundary Devices SABRE Lite i.MX6 Development Board is a low-cost development
50
+#ifndef QEMU_ARM_BSA_H
26
+platform featuring the powerful Freescale / NXP Semiconductor's i.MX 6 Quad
51
+#define QEMU_ARM_BSA_H
27
+Applications Processor.
28
+
52
+
29
+Supported devices
53
+/* These are architectural INTID values */
30
+-----------------
54
+#define VIRTUAL_PMU_IRQ 23
55
+#define ARCH_GIC_MAINT_IRQ 25
56
+#define ARCH_TIMER_NS_EL2_IRQ 26
57
+#define ARCH_TIMER_VIRT_IRQ 27
58
+#define ARCH_TIMER_NS_EL2_VIRT_IRQ 28
59
+#define ARCH_TIMER_S_EL1_IRQ 29
60
+#define ARCH_TIMER_NS_EL1_IRQ 30
31
+
61
+
32
+The SABRE Lite machine supports the following devices:
62
+#define INTID_TO_PPI(irq) ((irq) - 16)
33
+
63
+
34
+ * Up to 4 Cortex A9 cores
64
+#endif /* QEMU_ARM_BSA_H */
35
+ * Generic Interrupt Controller
65
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
36
+ * 1 Clock Controller Module
37
+ * 1 System Reset Controller
38
+ * 5 UARTs
39
+ * 2 EPIC timers
40
+ * 1 GPT timer
41
+ * 2 Watchdog timers
42
+ * 1 FEC Ethernet controller
43
+ * 3 I2C controllers
44
+ * 7 GPIO controllers
45
+ * 4 SDHC storage controllers
46
+ * 4 USB 2.0 host controllers
47
+ * 5 ECSPI controllers
48
+ * 1 SST 25VF016B flash
49
+
50
+Please note above list is a complete superset the QEMU SABRE Lite machine can
51
+support. For a normal use case, a device tree blob that represents a real world
52
+SABRE Lite board, only exposes a subset of devices to the guest software.
53
+
54
+Boot options
55
+------------
56
+
57
+The SABRE Lite machine can start using the standard -kernel functionality
58
+for loading a Linux kernel, U-Boot bootloader or ELF executable.
59
+
60
+Running Linux kernel
61
+--------------------
62
+
63
+Linux mainline v5.10 release is tested at the time of writing. To build a Linux
64
+mainline kernel that can be booted by the SABRE Lite machine, simply configure
65
+the kernel using the imx_v6_v7_defconfig configuration:
66
+
67
+.. code-block:: bash
68
+
69
+ $ export ARCH=arm
70
+ $ export CROSS_COMPILE=arm-linux-gnueabihf-
71
+ $ make imx_v6_v7_defconfig
72
+ $ make
73
+
74
+To boot the newly built Linux kernel in QEMU with the SABRE Lite machine, use:
75
+
76
+.. code-block:: bash
77
+
78
+ $ qemu-system-arm -M sabrelite -smp 4 -m 1G \
79
+ -display none -serial null -serial stdio \
80
+ -kernel arch/arm/boot/zImage \
81
+ -dtb arch/arm/boot/dts/imx6q-sabrelite.dtb \
82
+ -initrd /path/to/rootfs.ext4 \
83
+ -append "root=/dev/ram"
84
+
85
+Running U-Boot
86
+--------------
87
+
88
+U-Boot mainline v2020.10 release is tested at the time of writing. To build a
89
+U-Boot mainline bootloader that can be booted by the SABRE Lite machine, use
90
+the mx6qsabrelite_defconfig with similar commands as described above for Linux:
91
+
92
+.. code-block:: bash
93
+
94
+ $ export CROSS_COMPILE=arm-linux-gnueabihf-
95
+ $ make mx6qsabrelite_defconfig
96
+
97
+Note we need to adjust settings by:
98
+
99
+.. code-block:: bash
100
+
101
+ $ make menuconfig
102
+
103
+then manually select the following configuration in U-Boot:
104
+
105
+ Device Tree Control > Provider of DTB for DT Control > Embedded DTB
106
+
107
+To start U-Boot using the SABRE Lite machine, provide the u-boot binary to
108
+the -kernel argument, along with an SD card image with rootfs:
109
+
110
+.. code-block:: bash
111
+
112
+ $ qemu-system-arm -M sabrelite -smp 4 -m 1G \
113
+ -display none -serial null -serial stdio \
114
+ -kernel u-boot
115
+
116
+The following example shows booting Linux kernel from dhcp, and uses the
117
+rootfs on an SD card. This requires some additional command line parameters
118
+for QEMU:
119
+
120
+.. code-block:: none
121
+
122
+ -nic user,tftp=/path/to/kernel/zImage \
123
+ -drive file=sdcard.img,id=rootfs -device sd-card,drive=rootfs
124
+
125
+The directory for the built-in TFTP server should also contain the device tree
126
+blob of the SABRE Lite board. The sample SD card image was populated with the
127
+root file system with one single partition. You may adjust the kernel "root="
128
+boot parameter accordingly.
129
+
130
+After U-Boot boots, type the following commands in the U-Boot command shell to
131
+boot the Linux kernel:
132
+
133
+.. code-block:: none
134
+
135
+ => setenv ethaddr 00:11:22:33:44:55
136
+ => setenv bootfile zImage
137
+ => dhcp
138
+ => tftpboot 14000000 imx6q-sabrelite.dtb
139
+ => setenv bootargs root=/dev/mmcblk3p1
140
+ => bootz 12000000 - 14000000
141
diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst
142
index XXXXXXX..XXXXXXX 100644
66
index XXXXXXX..XXXXXXX 100644
143
--- a/docs/system/target-arm.rst
67
--- a/include/hw/arm/virt.h
144
+++ b/docs/system/target-arm.rst
68
+++ b/include/hw/arm/virt.h
145
@@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running
69
@@ -XXX,XX +XXX,XX @@
146
arm/versatile
70
#include "qemu/notify.h"
147
arm/vexpress
71
#include "hw/boards.h"
148
arm/aspeed
72
#include "hw/arm/boot.h"
149
+ arm/sabrelite
73
+#include "hw/arm/bsa.h"
150
arm/digic
74
#include "hw/block/flash.h"
151
arm/musicpal
75
#include "sysemu/kvm.h"
152
arm/gumstix
76
#include "hw/intc/arm_gicv3_common.h"
77
@@ -XXX,XX +XXX,XX @@
78
#define NUM_VIRTIO_TRANSPORTS 32
79
#define NUM_SMMU_IRQS 4
80
81
-#define ARCH_GIC_MAINT_IRQ 25
82
-
83
-#define ARCH_TIMER_VIRT_IRQ 27
84
-#define ARCH_TIMER_S_EL1_IRQ 29
85
-#define ARCH_TIMER_NS_EL1_IRQ 30
86
-#define ARCH_TIMER_NS_EL2_IRQ 26
87
-
88
-#define VIRTUAL_PMU_IRQ 23
89
-
90
-#define INTID_TO_PPI(irq) ((irq) - 16)
91
-
92
/* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */
93
#define PVTIME_SIZE_PER_CPU 64
94
153
--
95
--
154
2.20.1
96
2.34.1
155
156
diff view generated by jsdifflib
New patch
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
1
2
3
Use the private peripheral interrupt definitions from bsa.h instead of
4
defining them locally. Refactor to use the INTIDs defined there instead
5
of the PPI# used previously.
6
7
Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
8
Message-id: 20230919090229.188092-4-quic_llindhol@quicinc.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/arm/sbsa-ref.c | 21 +++++++++------------
13
1 file changed, 9 insertions(+), 12 deletions(-)
14
15
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/sbsa-ref.c
18
+++ b/hw/arm/sbsa-ref.c
19
@@ -XXX,XX +XXX,XX @@
20
* ARM SBSA Reference Platform emulation
21
*
22
* Copyright (c) 2018 Linaro Limited
23
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
24
* Written by Hongbo Zhang <hongbo.zhang@linaro.org>
25
*
26
* This program is free software; you can redistribute it and/or modify it
27
@@ -XXX,XX +XXX,XX @@
28
#include "exec/hwaddr.h"
29
#include "kvm_arm.h"
30
#include "hw/arm/boot.h"
31
+#include "hw/arm/bsa.h"
32
#include "hw/arm/fdt.h"
33
#include "hw/arm/smmuv3.h"
34
#include "hw/block/flash.h"
35
@@ -XXX,XX +XXX,XX @@
36
#define NUM_SMMU_IRQS 4
37
#define NUM_SATA_PORTS 6
38
39
-#define VIRTUAL_PMU_IRQ 7
40
-#define ARCH_GIC_MAINT_IRQ 9
41
-#define ARCH_TIMER_VIRT_IRQ 11
42
-#define ARCH_TIMER_S_EL1_IRQ 13
43
-#define ARCH_TIMER_NS_EL1_IRQ 14
44
-#define ARCH_TIMER_NS_EL2_IRQ 10
45
-#define ARCH_TIMER_NS_EL2_VIRT_IRQ 12
46
-
47
enum {
48
SBSA_FLASH,
49
SBSA_MEM,
50
@@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem)
51
*/
52
for (i = 0; i < smp_cpus; i++) {
53
DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
54
- int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS;
55
+ int intidbase = NUM_IRQS + i * GIC_INTERNAL;
56
int irq;
57
/*
58
* Mapping from the output timer irq lines from the CPU to the
59
@@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem)
60
for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
61
qdev_connect_gpio_out(cpudev, irq,
62
qdev_get_gpio_in(sms->gic,
63
- ppibase + timer_irq[irq]));
64
+ intidbase + timer_irq[irq]));
65
}
66
67
qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0,
68
- qdev_get_gpio_in(sms->gic, ppibase
69
+ qdev_get_gpio_in(sms->gic,
70
+ intidbase
71
+ ARCH_GIC_MAINT_IRQ));
72
+
73
qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0,
74
- qdev_get_gpio_in(sms->gic, ppibase
75
+ qdev_get_gpio_in(sms->gic,
76
+ intidbase
77
+ VIRTUAL_PMU_IRQ));
78
79
sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ));
80
--
81
2.34.1
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Cornelia Huck <cohuck@redhat.com>
2
2
3
When running device-introspect-test, a memory leak occurred in the
3
We can neaten the code by switching to the kvm_set_one_reg function.
4
mss_timer_init function, so use ptimer_free() in the finalize function to avoid
4
5
it.
5
Reviewed-by: Gavin Shan <gshan@redhat.com>
6
6
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
7
ASAN shows memory leak stack:
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
8
Message-id: 20231010142453.224369-2-cohuck@redhat.com
9
Indirect leak of 192 byte(s) in 2 object(s) allocated from:
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432
13
#3 0xaaabf58a0010 in mss_timer_init /qemu/hw/timer/mss-timer.c:235
14
#4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
15
#5 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564
16
#6 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547
17
#7 0xaaabf5b8316c in m2sxxx_soc_initfn /qemu/hw/arm/msf2-soc.c:70
18
#8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
19
#9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
20
#10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
21
#11 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59
22
#12 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
11
---
29
hw/timer/mss-timer.c | 13 +++++++++++++
12
target/arm/kvm.c | 13 +++------
30
1 file changed, 13 insertions(+)
13
target/arm/kvm64.c | 66 +++++++++++++---------------------------------
31
14
2 files changed, 21 insertions(+), 58 deletions(-)
32
diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c
15
16
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
33
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/timer/mss-timer.c
18
--- a/target/arm/kvm.c
35
+++ b/hw/timer/mss-timer.c
19
+++ b/target/arm/kvm.c
36
@@ -XXX,XX +XXX,XX @@ static void mss_timer_init(Object *obj)
20
@@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level)
37
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &t->mmio);
21
bool ok = true;
22
23
for (i = 0; i < cpu->cpreg_array_len; i++) {
24
- struct kvm_one_reg r;
25
uint64_t regidx = cpu->cpreg_indexes[i];
26
uint32_t v32;
27
int ret;
28
@@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level)
29
continue;
30
}
31
32
- r.id = regidx;
33
switch (regidx & KVM_REG_SIZE_MASK) {
34
case KVM_REG_SIZE_U32:
35
v32 = cpu->cpreg_values[i];
36
- r.addr = (uintptr_t)&v32;
37
+ ret = kvm_set_one_reg(cs, regidx, &v32);
38
break;
39
case KVM_REG_SIZE_U64:
40
- r.addr = (uintptr_t)(cpu->cpreg_values + i);
41
+ ret = kvm_set_one_reg(cs, regidx, cpu->cpreg_values + i);
42
break;
43
default:
44
g_assert_not_reached();
45
}
46
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r);
47
if (ret) {
48
/* We might fail for "unknown register" and also for
49
* "you tried to set a register which is constant with
50
@@ -XXX,XX +XXX,XX @@ void kvm_arm_get_virtual_time(CPUState *cs)
51
void kvm_arm_put_virtual_time(CPUState *cs)
52
{
53
ARMCPU *cpu = ARM_CPU(cs);
54
- struct kvm_one_reg reg = {
55
- .id = KVM_REG_ARM_TIMER_CNT,
56
- .addr = (uintptr_t)&cpu->kvm_vtime,
57
- };
58
int ret;
59
60
if (!cpu->kvm_vtime_dirty) {
61
return;
62
}
63
64
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
65
+ ret = kvm_set_one_reg(cs, KVM_REG_ARM_TIMER_CNT, &cpu->kvm_vtime);
66
if (ret) {
67
error_report("Failed to set KVM_REG_ARM_TIMER_CNT");
68
abort();
69
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/target/arm/kvm64.c
72
+++ b/target/arm/kvm64.c
73
@@ -XXX,XX +XXX,XX @@ static int kvm_arm_sve_set_vls(CPUState *cs)
74
{
75
ARMCPU *cpu = ARM_CPU(cs);
76
uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq.map };
77
- struct kvm_one_reg reg = {
78
- .id = KVM_REG_ARM64_SVE_VLS,
79
- .addr = (uint64_t)&vls[0],
80
- };
81
82
assert(cpu->sve_max_vq <= KVM_ARM64_SVE_VQ_MAX);
83
84
- return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
85
+ return kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_VLS, &vls[0]);
38
}
86
}
39
87
40
+static void mss_timer_finalize(Object *obj)
88
#define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5
41
+{
89
@@ -XXX,XX +XXX,XX @@ static void kvm_inject_arm_sea(CPUState *c)
42
+ MSSTimerState *t = MSS_TIMER(obj);
90
static int kvm_arch_put_fpsimd(CPUState *cs)
43
+ int i;
91
{
44
+
92
CPUARMState *env = &ARM_CPU(cs)->env;
45
+ for (i = 0; i < NUM_TIMERS; i++) {
93
- struct kvm_one_reg reg;
46
+ struct Msf2Timer *st = &t->timers[i];
94
int i, ret;
47
+
95
48
+ ptimer_free(st->ptimer);
96
for (i = 0; i < 32; i++) {
49
+ }
97
uint64_t *q = aa64_vfp_qreg(env, i);
50
+}
98
#if HOST_BIG_ENDIAN
51
+
99
uint64_t fp_val[2] = { q[1], q[0] };
52
static const VMStateDescription vmstate_timers = {
100
- reg.addr = (uintptr_t)fp_val;
53
.name = "mss-timer-block",
101
+ ret = kvm_set_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]),
54
.version_id = 1,
102
+ fp_val);
55
@@ -XXX,XX +XXX,XX @@ static const TypeInfo mss_timer_info = {
103
#else
56
.parent = TYPE_SYS_BUS_DEVICE,
104
- reg.addr = (uintptr_t)q;
57
.instance_size = sizeof(MSSTimerState),
105
+ ret = kvm_set_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]), q);
58
.instance_init = mss_timer_init,
106
#endif
59
+ .instance_finalize = mss_timer_finalize,
107
- reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]);
60
.class_init = mss_timer_class_init,
108
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
61
};
109
if (ret) {
62
110
return ret;
111
}
112
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs)
113
CPUARMState *env = &cpu->env;
114
uint64_t tmp[ARM_MAX_VQ * 2];
115
uint64_t *r;
116
- struct kvm_one_reg reg;
117
int n, ret;
118
119
for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) {
120
r = sve_bswap64(tmp, &env->vfp.zregs[n].d[0], cpu->sve_max_vq * 2);
121
- reg.addr = (uintptr_t)r;
122
- reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0);
123
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
124
+ ret = kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_ZREG(n, 0), r);
125
if (ret) {
126
return ret;
127
}
128
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs)
129
for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) {
130
r = sve_bswap64(tmp, r = &env->vfp.pregs[n].p[0],
131
DIV_ROUND_UP(cpu->sve_max_vq * 2, 8));
132
- reg.addr = (uintptr_t)r;
133
- reg.id = KVM_REG_ARM64_SVE_PREG(n, 0);
134
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
135
+ ret = kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_PREG(n, 0), r);
136
if (ret) {
137
return ret;
138
}
139
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs)
140
141
r = sve_bswap64(tmp, &env->vfp.pregs[FFR_PRED_NUM].p[0],
142
DIV_ROUND_UP(cpu->sve_max_vq * 2, 8));
143
- reg.addr = (uintptr_t)r;
144
- reg.id = KVM_REG_ARM64_SVE_FFR(0);
145
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
146
+ ret = kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_FFR(0), r);
147
if (ret) {
148
return ret;
149
}
150
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs)
151
152
int kvm_arch_put_registers(CPUState *cs, int level)
153
{
154
- struct kvm_one_reg reg;
155
uint64_t val;
156
uint32_t fpr;
157
int i, ret;
158
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
159
}
160
161
for (i = 0; i < 31; i++) {
162
- reg.id = AARCH64_CORE_REG(regs.regs[i]);
163
- reg.addr = (uintptr_t) &env->xregs[i];
164
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
165
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.regs[i]),
166
+ &env->xregs[i]);
167
if (ret) {
168
return ret;
169
}
170
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
171
*/
172
aarch64_save_sp(env, 1);
173
174
- reg.id = AARCH64_CORE_REG(regs.sp);
175
- reg.addr = (uintptr_t) &env->sp_el[0];
176
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
177
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.sp), &env->sp_el[0]);
178
if (ret) {
179
return ret;
180
}
181
182
- reg.id = AARCH64_CORE_REG(sp_el1);
183
- reg.addr = (uintptr_t) &env->sp_el[1];
184
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
185
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(sp_el1), &env->sp_el[1]);
186
if (ret) {
187
return ret;
188
}
189
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
190
} else {
191
val = cpsr_read(env);
192
}
193
- reg.id = AARCH64_CORE_REG(regs.pstate);
194
- reg.addr = (uintptr_t) &val;
195
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
196
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.pstate), &val);
197
if (ret) {
198
return ret;
199
}
200
201
- reg.id = AARCH64_CORE_REG(regs.pc);
202
- reg.addr = (uintptr_t) &env->pc;
203
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
204
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.pc), &env->pc);
205
if (ret) {
206
return ret;
207
}
208
209
- reg.id = AARCH64_CORE_REG(elr_el1);
210
- reg.addr = (uintptr_t) &env->elr_el[1];
211
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
212
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(elr_el1), &env->elr_el[1]);
213
if (ret) {
214
return ret;
215
}
216
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
217
218
/* KVM 0-4 map to QEMU banks 1-5 */
219
for (i = 0; i < KVM_NR_SPSR; i++) {
220
- reg.id = AARCH64_CORE_REG(spsr[i]);
221
- reg.addr = (uintptr_t) &env->banked_spsr[i + 1];
222
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
223
+ ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(spsr[i]),
224
+ &env->banked_spsr[i + 1]);
225
if (ret) {
226
return ret;
227
}
228
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
229
return ret;
230
}
231
232
- reg.addr = (uintptr_t)(&fpr);
233
fpr = vfp_get_fpsr(env);
234
- reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr);
235
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
236
+ ret = kvm_set_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpsr), &fpr);
237
if (ret) {
238
return ret;
239
}
240
241
- reg.addr = (uintptr_t)(&fpr);
242
fpr = vfp_get_fpcr(env);
243
- reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr);
244
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
245
+ ret = kvm_set_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpcr), &fpr);
246
if (ret) {
247
return ret;
248
}
63
--
249
--
64
2.20.1
250
2.34.1
65
251
66
252
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Cornelia Huck <cohuck@redhat.com>
2
2
3
When running device-introspect-test, a memory leak occurred in the
3
We can neaten the code by switching the callers that work on a
4
digic_timer_init function, so use ptimer_free() in the finalize function to
4
CPUstate to the kvm_get_one_reg function.
5
avoid it.
5
6
6
Reviewed-by: Gavin Shan <gshan@redhat.com>
7
ASAN shows memory leak stack:
7
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
8
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Indirect leak of 288 byte(s) in 3 object(s) allocated from:
9
Message-id: 20231010142453.224369-3-cohuck@redhat.com
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
12
#2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432
13
#3 0xaaabf5b04084 in digic_timer_init /qemu/hw/timer/digic-timer.c:142
14
#4 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
15
#5 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564
16
#6 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547
17
#7 0xaaabf5b40e84 in digic_init /qemu/hw/arm/digic.c:46
18
#8 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
19
#9 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
20
#10 0xaaabf6375e40 in qmp_device_list_properties /qemu/qom/qom-qmp-cmds.c:153
21
#11 0xaaabf653d8ec in qmp_marshal_device_list_properties /qemu/qapi/qapi-commands-qdev.c:59
22
#12 0xaaabf6587d08 in do_qmp_dispatch_bh /qemu/qapi/qmp-dispatch.c:110
23
24
Reported-by: Euler Robot <euler.robot@huawei.com>
25
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
26
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
12
---
29
hw/timer/digic-timer.c | 8 ++++++++
13
target/arm/kvm.c | 15 +++---------
30
1 file changed, 8 insertions(+)
14
target/arm/kvm64.c | 57 ++++++++++++----------------------------------
31
15
2 files changed, 18 insertions(+), 54 deletions(-)
32
diff --git a/hw/timer/digic-timer.c b/hw/timer/digic-timer.c
16
17
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
33
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/timer/digic-timer.c
19
--- a/target/arm/kvm.c
35
+++ b/hw/timer/digic-timer.c
20
+++ b/target/arm/kvm.c
36
@@ -XXX,XX +XXX,XX @@ static void digic_timer_init(Object *obj)
21
@@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu)
37
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
22
bool ok = true;
38
}
23
39
24
for (i = 0; i < cpu->cpreg_array_len; i++) {
40
+static void digic_timer_finalize(Object *obj)
25
- struct kvm_one_reg r;
41
+{
26
uint64_t regidx = cpu->cpreg_indexes[i];
42
+ DigicTimerState *s = DIGIC_TIMER(obj);
27
uint32_t v32;
43
+
28
int ret;
44
+ ptimer_free(s->ptimer);
29
45
+}
30
- r.id = regidx;
46
+
31
-
47
static void digic_timer_class_init(ObjectClass *klass, void *class_data)
32
switch (regidx & KVM_REG_SIZE_MASK) {
48
{
33
case KVM_REG_SIZE_U32:
49
DeviceClass *dc = DEVICE_CLASS(klass);
34
- r.addr = (uintptr_t)&v32;
50
@@ -XXX,XX +XXX,XX @@ static const TypeInfo digic_timer_info = {
35
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r);
51
.parent = TYPE_SYS_BUS_DEVICE,
36
+ ret = kvm_get_one_reg(cs, regidx, &v32);
52
.instance_size = sizeof(DigicTimerState),
37
if (!ret) {
53
.instance_init = digic_timer_init,
38
cpu->cpreg_values[i] = v32;
54
+ .instance_finalize = digic_timer_finalize,
39
}
55
.class_init = digic_timer_class_init,
40
break;
56
};
41
case KVM_REG_SIZE_U64:
57
42
- r.addr = (uintptr_t)(cpu->cpreg_values + i);
43
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r);
44
+ ret = kvm_get_one_reg(cs, regidx, cpu->cpreg_values + i);
45
break;
46
default:
47
g_assert_not_reached();
48
@@ -XXX,XX +XXX,XX @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu)
49
void kvm_arm_get_virtual_time(CPUState *cs)
50
{
51
ARMCPU *cpu = ARM_CPU(cs);
52
- struct kvm_one_reg reg = {
53
- .id = KVM_REG_ARM_TIMER_CNT,
54
- .addr = (uintptr_t)&cpu->kvm_vtime,
55
- };
56
int ret;
57
58
if (cpu->kvm_vtime_dirty) {
59
return;
60
}
61
62
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
63
+ ret = kvm_get_one_reg(cs, KVM_REG_ARM_TIMER_CNT, &cpu->kvm_vtime);
64
if (ret) {
65
error_report("Failed to get KVM_REG_ARM_TIMER_CNT");
66
abort();
67
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/target/arm/kvm64.c
70
+++ b/target/arm/kvm64.c
71
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
72
static int kvm_arch_get_fpsimd(CPUState *cs)
73
{
74
CPUARMState *env = &ARM_CPU(cs)->env;
75
- struct kvm_one_reg reg;
76
int i, ret;
77
78
for (i = 0; i < 32; i++) {
79
uint64_t *q = aa64_vfp_qreg(env, i);
80
- reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]);
81
- reg.addr = (uintptr_t)q;
82
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
83
+ ret = kvm_get_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]), q);
84
if (ret) {
85
return ret;
86
} else {
87
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs)
88
{
89
ARMCPU *cpu = ARM_CPU(cs);
90
CPUARMState *env = &cpu->env;
91
- struct kvm_one_reg reg;
92
uint64_t *r;
93
int n, ret;
94
95
for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) {
96
r = &env->vfp.zregs[n].d[0];
97
- reg.addr = (uintptr_t)r;
98
- reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0);
99
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
100
+ ret = kvm_get_one_reg(cs, KVM_REG_ARM64_SVE_ZREG(n, 0), r);
101
if (ret) {
102
return ret;
103
}
104
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs)
105
106
for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) {
107
r = &env->vfp.pregs[n].p[0];
108
- reg.addr = (uintptr_t)r;
109
- reg.id = KVM_REG_ARM64_SVE_PREG(n, 0);
110
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
111
+ ret = kvm_get_one_reg(cs, KVM_REG_ARM64_SVE_PREG(n, 0), r);
112
if (ret) {
113
return ret;
114
}
115
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs)
116
}
117
118
r = &env->vfp.pregs[FFR_PRED_NUM].p[0];
119
- reg.addr = (uintptr_t)r;
120
- reg.id = KVM_REG_ARM64_SVE_FFR(0);
121
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
122
+ ret = kvm_get_one_reg(cs, KVM_REG_ARM64_SVE_FFR(0), r);
123
if (ret) {
124
return ret;
125
}
126
@@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs)
127
128
int kvm_arch_get_registers(CPUState *cs)
129
{
130
- struct kvm_one_reg reg;
131
uint64_t val;
132
unsigned int el;
133
uint32_t fpr;
134
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs)
135
CPUARMState *env = &cpu->env;
136
137
for (i = 0; i < 31; i++) {
138
- reg.id = AARCH64_CORE_REG(regs.regs[i]);
139
- reg.addr = (uintptr_t) &env->xregs[i];
140
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
141
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.regs[i]),
142
+ &env->xregs[i]);
143
if (ret) {
144
return ret;
145
}
146
}
147
148
- reg.id = AARCH64_CORE_REG(regs.sp);
149
- reg.addr = (uintptr_t) &env->sp_el[0];
150
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
151
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.sp), &env->sp_el[0]);
152
if (ret) {
153
return ret;
154
}
155
156
- reg.id = AARCH64_CORE_REG(sp_el1);
157
- reg.addr = (uintptr_t) &env->sp_el[1];
158
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
159
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(sp_el1), &env->sp_el[1]);
160
if (ret) {
161
return ret;
162
}
163
164
- reg.id = AARCH64_CORE_REG(regs.pstate);
165
- reg.addr = (uintptr_t) &val;
166
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
167
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.pstate), &val);
168
if (ret) {
169
return ret;
170
}
171
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs)
172
*/
173
aarch64_restore_sp(env, 1);
174
175
- reg.id = AARCH64_CORE_REG(regs.pc);
176
- reg.addr = (uintptr_t) &env->pc;
177
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
178
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.pc), &env->pc);
179
if (ret) {
180
return ret;
181
}
182
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs)
183
aarch64_sync_64_to_32(env);
184
}
185
186
- reg.id = AARCH64_CORE_REG(elr_el1);
187
- reg.addr = (uintptr_t) &env->elr_el[1];
188
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
189
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(elr_el1), &env->elr_el[1]);
190
if (ret) {
191
return ret;
192
}
193
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs)
194
* KVM SPSRs 0-4 map to QEMU banks 1-5
195
*/
196
for (i = 0; i < KVM_NR_SPSR; i++) {
197
- reg.id = AARCH64_CORE_REG(spsr[i]);
198
- reg.addr = (uintptr_t) &env->banked_spsr[i + 1];
199
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
200
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(spsr[i]),
201
+ &env->banked_spsr[i + 1]);
202
if (ret) {
203
return ret;
204
}
205
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs)
206
return ret;
207
}
208
209
- reg.addr = (uintptr_t)(&fpr);
210
- reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr);
211
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
212
+ ret = kvm_get_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpsr), &fpr);
213
if (ret) {
214
return ret;
215
}
216
vfp_set_fpsr(env, fpr);
217
218
- reg.addr = (uintptr_t)(&fpr);
219
- reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr);
220
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
221
+ ret = kvm_get_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpcr), &fpr);
222
if (ret) {
223
return ret;
224
}
58
--
225
--
59
2.20.1
226
2.34.1
60
227
61
228
diff view generated by jsdifflib
1
This commit is the result of running the timer-del-timer-free.cocci
1
For the Thumb T32 encoding of LDM, if only a single register is
2
script on the whole source tree.
2
specified in the register list this instruction is UNPREDICTABLE,
3
with the following choices:
4
* instruction UNDEFs
5
* instruction is a NOP
6
* instruction loads a single register
7
* instruction loads an unspecified set of registers
3
8
9
Currently we choose to UNDEF (a behaviour chosen in commit
10
4b222545dbf30 in 2019; previously we treated it as "load the
11
specified single register").
12
13
Unfortunately there is real world code out there (which shipped in at
14
least Android 11, 12 and 13) which incorrectly uses this
15
UNPREDICTABLE insn on the assumption that it does a single register
16
load, which is (presumably) what it happens to do on real hardware,
17
and is also what it does on the equivalent A32 encoding.
18
19
Revert to the pre-4b222545dbf30 behaviour of not UNDEFing
20
for this T32 encoding.
21
22
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1799
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Acked-by: Corey Minyard <cminyard@mvista.com>
24
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
6
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
25
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20201215154107.3255-4-peter.maydell@linaro.org
26
Message-id: 20230927101853.39288-1-peter.maydell@linaro.org
10
---
27
---
11
block/iscsi.c | 2 --
28
target/arm/tcg/translate.c | 37 +++++++++++++++++++++++--------------
12
block/nbd.c | 1 -
29
1 file changed, 23 insertions(+), 14 deletions(-)
13
block/qcow2.c | 1 -
14
hw/block/nvme.c | 2 --
15
hw/char/serial.c | 2 --
16
hw/char/virtio-serial-bus.c | 2 --
17
hw/ide/core.c | 1 -
18
hw/input/hid.c | 1 -
19
hw/intc/apic.c | 1 -
20
hw/intc/ioapic.c | 1 -
21
hw/ipmi/ipmi_bmc_extern.c | 1 -
22
hw/net/e1000.c | 3 ---
23
hw/net/e1000e_core.c | 8 --------
24
hw/net/pcnet-pci.c | 1 -
25
hw/net/rtl8139.c | 1 -
26
hw/net/spapr_llan.c | 1 -
27
hw/net/virtio-net.c | 2 --
28
hw/s390x/s390-pci-inst.c | 1 -
29
hw/sd/sd.c | 1 -
30
hw/sd/sdhci.c | 2 --
31
hw/usb/dev-hub.c | 1 -
32
hw/usb/hcd-ehci.c | 1 -
33
hw/usb/hcd-ohci-pci.c | 1 -
34
hw/usb/hcd-uhci.c | 1 -
35
hw/usb/hcd-xhci.c | 1 -
36
hw/usb/redirect.c | 1 -
37
hw/vfio/display.c | 1 -
38
hw/virtio/vhost-vsock-common.c | 1 -
39
hw/virtio/virtio-balloon.c | 1 -
40
hw/virtio/virtio-rng.c | 1 -
41
hw/watchdog/wdt_diag288.c | 1 -
42
hw/watchdog/wdt_i6300esb.c | 1 -
43
migration/colo.c | 1 -
44
monitor/hmp-cmds.c | 1 -
45
net/announce.c | 1 -
46
net/colo-compare.c | 1 -
47
net/slirp.c | 1 -
48
replay/replay-debugging.c | 1 -
49
target/s390x/cpu.c | 2 --
50
ui/console.c | 1 -
51
ui/spice-core.c | 1 -
52
util/throttle.c | 1 -
53
42 files changed, 58 deletions(-)
54
30
55
diff --git a/block/iscsi.c b/block/iscsi.c
31
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
56
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
57
--- a/block/iscsi.c
33
--- a/target/arm/tcg/translate.c
58
+++ b/block/iscsi.c
34
+++ b/target/arm/tcg/translate.c
59
@@ -XXX,XX +XXX,XX @@ static void iscsi_detach_aio_context(BlockDriverState *bs)
35
@@ -XXX,XX +XXX,XX @@ static void op_addr_block_post(DisasContext *s, arg_ldst_block *a,
60
iscsilun->events = 0;
61
62
if (iscsilun->nop_timer) {
63
- timer_del(iscsilun->nop_timer);
64
timer_free(iscsilun->nop_timer);
65
iscsilun->nop_timer = NULL;
66
}
67
if (iscsilun->event_timer) {
68
- timer_del(iscsilun->event_timer);
69
timer_free(iscsilun->event_timer);
70
iscsilun->event_timer = NULL;
71
}
72
diff --git a/block/nbd.c b/block/nbd.c
73
index XXXXXXX..XXXXXXX 100644
74
--- a/block/nbd.c
75
+++ b/block/nbd.c
76
@@ -XXX,XX +XXX,XX @@ static void nbd_recv_coroutines_wake_all(BDRVNBDState *s)
77
static void reconnect_delay_timer_del(BDRVNBDState *s)
78
{
79
if (s->reconnect_delay_timer) {
80
- timer_del(s->reconnect_delay_timer);
81
timer_free(s->reconnect_delay_timer);
82
s->reconnect_delay_timer = NULL;
83
}
84
diff --git a/block/qcow2.c b/block/qcow2.c
85
index XXXXXXX..XXXXXXX 100644
86
--- a/block/qcow2.c
87
+++ b/block/qcow2.c
88
@@ -XXX,XX +XXX,XX @@ static void cache_clean_timer_del(BlockDriverState *bs)
89
{
90
BDRVQcow2State *s = bs->opaque;
91
if (s->cache_clean_timer) {
92
- timer_del(s->cache_clean_timer);
93
timer_free(s->cache_clean_timer);
94
s->cache_clean_timer = NULL;
95
}
96
diff --git a/hw/block/nvme.c b/hw/block/nvme.c
97
index XXXXXXX..XXXXXXX 100644
98
--- a/hw/block/nvme.c
99
+++ b/hw/block/nvme.c
100
@@ -XXX,XX +XXX,XX @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeRequest *req)
101
static void nvme_free_sq(NvmeSQueue *sq, NvmeCtrl *n)
102
{
103
n->sq[sq->sqid] = NULL;
104
- timer_del(sq->timer);
105
timer_free(sq->timer);
106
g_free(sq->io_req);
107
if (sq->sqid) {
108
@@ -XXX,XX +XXX,XX @@ static uint16_t nvme_get_log(NvmeCtrl *n, NvmeRequest *req)
109
static void nvme_free_cq(NvmeCQueue *cq, NvmeCtrl *n)
110
{
111
n->cq[cq->cqid] = NULL;
112
- timer_del(cq->timer);
113
timer_free(cq->timer);
114
msix_vector_unuse(&n->parent_obj, cq->vector);
115
if (cq->cqid) {
116
diff --git a/hw/char/serial.c b/hw/char/serial.c
117
index XXXXXXX..XXXXXXX 100644
118
--- a/hw/char/serial.c
119
+++ b/hw/char/serial.c
120
@@ -XXX,XX +XXX,XX @@ static void serial_unrealize(DeviceState *dev)
121
122
qemu_chr_fe_deinit(&s->chr, false);
123
124
- timer_del(s->modem_status_poll);
125
timer_free(s->modem_status_poll);
126
127
- timer_del(s->fifo_timeout_timer);
128
timer_free(s->fifo_timeout_timer);
129
130
fifo8_destroy(&s->recv_fifo);
131
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
132
index XXXXXXX..XXXXXXX 100644
133
--- a/hw/char/virtio-serial-bus.c
134
+++ b/hw/char/virtio-serial-bus.c
135
@@ -XXX,XX +XXX,XX @@ static void virtio_serial_post_load_timer_cb(void *opaque)
136
}
137
}
138
g_free(s->post_load->connected);
139
- timer_del(s->post_load->timer);
140
timer_free(s->post_load->timer);
141
g_free(s->post_load);
142
s->post_load = NULL;
143
@@ -XXX,XX +XXX,XX @@ static void virtio_serial_device_unrealize(DeviceState *dev)
144
g_free(vser->ports_map);
145
if (vser->post_load) {
146
g_free(vser->post_load->connected);
147
- timer_del(vser->post_load->timer);
148
timer_free(vser->post_load->timer);
149
g_free(vser->post_load);
150
}
151
diff --git a/hw/ide/core.c b/hw/ide/core.c
152
index XXXXXXX..XXXXXXX 100644
153
--- a/hw/ide/core.c
154
+++ b/hw/ide/core.c
155
@@ -XXX,XX +XXX,XX @@ void ide_init2(IDEBus *bus, qemu_irq irq)
156
157
void ide_exit(IDEState *s)
158
{
159
- timer_del(s->sector_write_timer);
160
timer_free(s->sector_write_timer);
161
qemu_vfree(s->smart_selftest_data);
162
qemu_vfree(s->io_buffer);
163
diff --git a/hw/input/hid.c b/hw/input/hid.c
164
index XXXXXXX..XXXXXXX 100644
165
--- a/hw/input/hid.c
166
+++ b/hw/input/hid.c
167
@@ -XXX,XX +XXX,XX @@ static void hid_idle_timer(void *opaque)
168
static void hid_del_idle_timer(HIDState *hs)
169
{
170
if (hs->idle_timer) {
171
- timer_del(hs->idle_timer);
172
timer_free(hs->idle_timer);
173
hs->idle_timer = NULL;
174
}
175
diff --git a/hw/intc/apic.c b/hw/intc/apic.c
176
index XXXXXXX..XXXXXXX 100644
177
--- a/hw/intc/apic.c
178
+++ b/hw/intc/apic.c
179
@@ -XXX,XX +XXX,XX @@ static void apic_unrealize(DeviceState *dev)
180
{
181
APICCommonState *s = APIC(dev);
182
183
- timer_del(s->timer);
184
timer_free(s->timer);
185
local_apics[s->id] = NULL;
186
}
187
diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c
188
index XXXXXXX..XXXXXXX 100644
189
--- a/hw/intc/ioapic.c
190
+++ b/hw/intc/ioapic.c
191
@@ -XXX,XX +XXX,XX @@ static void ioapic_unrealize(DeviceState *dev)
192
{
193
IOAPICCommonState *s = IOAPIC_COMMON(dev);
194
195
- timer_del(s->delayed_ioapic_service_timer);
196
timer_free(s->delayed_ioapic_service_timer);
197
}
198
199
diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
200
index XXXXXXX..XXXXXXX 100644
201
--- a/hw/ipmi/ipmi_bmc_extern.c
202
+++ b/hw/ipmi/ipmi_bmc_extern.c
203
@@ -XXX,XX +XXX,XX @@ static void ipmi_bmc_extern_finalize(Object *obj)
204
{
205
IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj);
206
207
- timer_del(ibe->extern_timer);
208
timer_free(ibe->extern_timer);
209
}
210
211
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
212
index XXXXXXX..XXXXXXX 100644
213
--- a/hw/net/e1000.c
214
+++ b/hw/net/e1000.c
215
@@ -XXX,XX +XXX,XX @@ pci_e1000_uninit(PCIDevice *dev)
216
{
217
E1000State *d = E1000(dev);
218
219
- timer_del(d->autoneg_timer);
220
timer_free(d->autoneg_timer);
221
- timer_del(d->mit_timer);
222
timer_free(d->mit_timer);
223
- timer_del(d->flush_queue_timer);
224
timer_free(d->flush_queue_timer);
225
qemu_del_nic(d->nic);
226
}
227
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
228
index XXXXXXX..XXXXXXX 100644
229
--- a/hw/net/e1000e_core.c
230
+++ b/hw/net/e1000e_core.c
231
@@ -XXX,XX +XXX,XX @@ e1000e_intrmgr_pci_unint(E1000ECore *core)
232
{
233
int i;
234
235
- timer_del(core->radv.timer);
236
timer_free(core->radv.timer);
237
- timer_del(core->rdtr.timer);
238
timer_free(core->rdtr.timer);
239
- timer_del(core->raid.timer);
240
timer_free(core->raid.timer);
241
242
- timer_del(core->tadv.timer);
243
timer_free(core->tadv.timer);
244
- timer_del(core->tidv.timer);
245
timer_free(core->tidv.timer);
246
247
- timer_del(core->itr.timer);
248
timer_free(core->itr.timer);
249
250
for (i = 0; i < E1000E_MSIX_VEC_NUM; i++) {
251
- timer_del(core->eitr[i].timer);
252
timer_free(core->eitr[i].timer);
253
}
36
}
254
}
37
}
255
@@ -XXX,XX +XXX,XX @@ e1000e_core_pci_uninit(E1000ECore *core)
38
39
-static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n)
40
+static bool op_stm(DisasContext *s, arg_ldst_block *a)
256
{
41
{
257
int i;
42
int i, j, n, list, mem_idx;
258
43
bool user = a->u;
259
- timer_del(core->autoneg_timer);
44
@@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n)
260
timer_free(core->autoneg_timer);
45
261
46
list = a->list;
262
e1000e_intrmgr_pci_unint(core);
47
n = ctpop16(list);
263
diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
48
- if (n < min_n || a->rn == 15) {
264
index XXXXXXX..XXXXXXX 100644
49
+ /*
265
--- a/hw/net/pcnet-pci.c
50
+ * This is UNPREDICTABLE for n < 1 in all encodings, and we choose
266
+++ b/hw/net/pcnet-pci.c
51
+ * to UNDEF. In the T32 STM encoding n == 1 is also UNPREDICTABLE,
267
@@ -XXX,XX +XXX,XX @@ static void pci_pcnet_uninit(PCIDevice *dev)
52
+ * but hardware treats it like the A32 version and implements the
268
PCIPCNetState *d = PCI_PCNET(dev);
53
+ * single-register-store, and some in-the-wild (buggy) software
269
54
+ * assumes that, so we don't UNDEF on that case.
270
qemu_free_irq(d->state.irq);
55
+ */
271
- timer_del(d->state.poll_timer);
56
+ if (n < 1 || a->rn == 15) {
272
timer_free(d->state.poll_timer);
57
unallocated_encoding(s);
273
qemu_del_nic(d->state.nic);
58
return true;
59
}
60
@@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n)
61
62
static bool trans_STM(DisasContext *s, arg_ldst_block *a)
63
{
64
- /* BitCount(list) < 1 is UNPREDICTABLE */
65
- return op_stm(s, a, 1);
66
+ return op_stm(s, a);
274
}
67
}
275
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
68
276
index XXXXXXX..XXXXXXX 100644
69
static bool trans_STM_t32(DisasContext *s, arg_ldst_block *a)
277
--- a/hw/net/rtl8139.c
70
@@ -XXX,XX +XXX,XX @@ static bool trans_STM_t32(DisasContext *s, arg_ldst_block *a)
278
+++ b/hw/net/rtl8139.c
71
unallocated_encoding(s);
279
@@ -XXX,XX +XXX,XX @@ static void pci_rtl8139_uninit(PCIDevice *dev)
72
return true;
280
73
}
281
g_free(s->cplus_txbuffer);
74
- /* BitCount(list) < 2 is UNPREDICTABLE */
282
s->cplus_txbuffer = NULL;
75
- return op_stm(s, a, 2);
283
- timer_del(s->timer);
76
+ return op_stm(s, a);
284
timer_free(s->timer);
285
qemu_del_nic(s->nic);
286
}
77
}
287
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
78
288
index XXXXXXX..XXXXXXX 100644
79
-static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n)
289
--- a/hw/net/spapr_llan.c
80
+static bool do_ldm(DisasContext *s, arg_ldst_block *a)
290
+++ b/hw/net/spapr_llan.c
81
{
291
@@ -XXX,XX +XXX,XX @@ static void spapr_vlan_instance_finalize(Object *obj)
82
int i, j, n, list, mem_idx;
83
bool loaded_base;
84
@@ -XXX,XX +XXX,XX @@ static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n)
85
86
list = a->list;
87
n = ctpop16(list);
88
- if (n < min_n || a->rn == 15) {
89
+ /*
90
+ * This is UNPREDICTABLE for n < 1 in all encodings, and we choose
91
+ * to UNDEF. In the T32 LDM encoding n == 1 is also UNPREDICTABLE,
92
+ * but hardware treats it like the A32 version and implements the
93
+ * single-register-load, and some in-the-wild (buggy) software
94
+ * assumes that, so we don't UNDEF on that case.
95
+ */
96
+ if (n < 1 || a->rn == 15) {
97
unallocated_encoding(s);
98
return true;
292
}
99
}
293
100
@@ -XXX,XX +XXX,XX @@ static bool trans_LDM_a32(DisasContext *s, arg_ldst_block *a)
294
if (dev->rxp_timer) {
101
unallocated_encoding(s);
295
- timer_del(dev->rxp_timer);
102
return true;
296
timer_free(dev->rxp_timer);
297
}
103
}
104
- /* BitCount(list) < 1 is UNPREDICTABLE */
105
- return do_ldm(s, a, 1);
106
+ return do_ldm(s, a);
298
}
107
}
299
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
108
300
index XXXXXXX..XXXXXXX 100644
109
static bool trans_LDM_t32(DisasContext *s, arg_ldst_block *a)
301
--- a/hw/net/virtio-net.c
110
@@ -XXX,XX +XXX,XX @@ static bool trans_LDM_t32(DisasContext *s, arg_ldst_block *a)
302
+++ b/hw/net/virtio-net.c
111
unallocated_encoding(s);
303
@@ -XXX,XX +XXX,XX @@ static void virtio_net_rsc_cleanup(VirtIONet *n)
112
return true;
304
g_free(seg);
113
}
305
}
114
- /* BitCount(list) < 2 is UNPREDICTABLE */
306
115
- return do_ldm(s, a, 2);
307
- timer_del(chain->drain_timer);
116
+ return do_ldm(s, a);
308
timer_free(chain->drain_timer);
117
}
309
QTAILQ_REMOVE(&n->rsc_chains, chain, next);
118
310
g_free(chain);
119
static bool trans_LDM_t16(DisasContext *s, arg_ldst_block *a)
311
@@ -XXX,XX +XXX,XX @@ static void virtio_net_del_queue(VirtIONet *n, int index)
312
313
virtio_del_queue(vdev, index * 2);
314
if (q->tx_timer) {
315
- timer_del(q->tx_timer);
316
timer_free(q->tx_timer);
317
q->tx_timer = NULL;
318
} else {
319
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
320
index XXXXXXX..XXXXXXX 100644
321
--- a/hw/s390x/s390-pci-inst.c
322
+++ b/hw/s390x/s390-pci-inst.c
323
@@ -XXX,XX +XXX,XX @@ void pci_dereg_ioat(S390PCIIOMMU *iommu)
324
void fmb_timer_free(S390PCIBusDevice *pbdev)
325
{
120
{
326
if (pbdev->fmb_timer) {
121
/* Writeback is conditional on the base register not being loaded. */
327
- timer_del(pbdev->fmb_timer);
122
a->w = !(a->list & (1 << a->rn));
328
timer_free(pbdev->fmb_timer);
123
- /* BitCount(list) < 1 is UNPREDICTABLE */
329
pbdev->fmb_timer = NULL;
124
- return do_ldm(s, a, 1);
330
}
125
+ return do_ldm(s, a);
331
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
332
index XXXXXXX..XXXXXXX 100644
333
--- a/hw/sd/sd.c
334
+++ b/hw/sd/sd.c
335
@@ -XXX,XX +XXX,XX @@ static void sd_instance_finalize(Object *obj)
336
{
337
SDState *sd = SD_CARD(obj);
338
339
- timer_del(sd->ocr_power_timer);
340
timer_free(sd->ocr_power_timer);
341
}
126
}
342
127
343
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
128
static bool trans_CLRM(DisasContext *s, arg_CLRM *a)
344
index XXXXXXX..XXXXXXX 100644
345
--- a/hw/sd/sdhci.c
346
+++ b/hw/sd/sdhci.c
347
@@ -XXX,XX +XXX,XX @@ void sdhci_initfn(SDHCIState *s)
348
349
void sdhci_uninitfn(SDHCIState *s)
350
{
351
- timer_del(s->insert_timer);
352
timer_free(s->insert_timer);
353
- timer_del(s->transfer_timer);
354
timer_free(s->transfer_timer);
355
356
g_free(s->fifo_buffer);
357
diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c
358
index XXXXXXX..XXXXXXX 100644
359
--- a/hw/usb/dev-hub.c
360
+++ b/hw/usb/dev-hub.c
361
@@ -XXX,XX +XXX,XX @@ static void usb_hub_unrealize(USBDevice *dev)
362
&s->ports[i].port);
363
}
364
365
- timer_del(s->port_timer);
366
timer_free(s->port_timer);
367
}
368
369
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
370
index XXXXXXX..XXXXXXX 100644
371
--- a/hw/usb/hcd-ehci.c
372
+++ b/hw/usb/hcd-ehci.c
373
@@ -XXX,XX +XXX,XX @@ void usb_ehci_unrealize(EHCIState *s, DeviceState *dev)
374
trace_usb_ehci_unrealize();
375
376
if (s->frame_timer) {
377
- timer_del(s->frame_timer);
378
timer_free(s->frame_timer);
379
s->frame_timer = NULL;
380
}
381
diff --git a/hw/usb/hcd-ohci-pci.c b/hw/usb/hcd-ohci-pci.c
382
index XXXXXXX..XXXXXXX 100644
383
--- a/hw/usb/hcd-ohci-pci.c
384
+++ b/hw/usb/hcd-ohci-pci.c
385
@@ -XXX,XX +XXX,XX @@ static void usb_ohci_exit(PCIDevice *dev)
386
usb_bus_release(&s->bus);
387
}
388
389
- timer_del(s->eof_timer);
390
timer_free(s->eof_timer);
391
}
392
393
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
394
index XXXXXXX..XXXXXXX 100644
395
--- a/hw/usb/hcd-uhci.c
396
+++ b/hw/usb/hcd-uhci.c
397
@@ -XXX,XX +XXX,XX @@ static void usb_uhci_exit(PCIDevice *dev)
398
trace_usb_uhci_exit();
399
400
if (s->frame_timer) {
401
- timer_del(s->frame_timer);
402
timer_free(s->frame_timer);
403
s->frame_timer = NULL;
404
}
405
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
406
index XXXXXXX..XXXXXXX 100644
407
--- a/hw/usb/hcd-xhci.c
408
+++ b/hw/usb/hcd-xhci.c
409
@@ -XXX,XX +XXX,XX @@ static void usb_xhci_unrealize(DeviceState *dev)
410
}
411
412
if (xhci->mfwrap_timer) {
413
- timer_del(xhci->mfwrap_timer);
414
timer_free(xhci->mfwrap_timer);
415
xhci->mfwrap_timer = NULL;
416
}
417
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
418
index XXXXXXX..XXXXXXX 100644
419
--- a/hw/usb/redirect.c
420
+++ b/hw/usb/redirect.c
421
@@ -XXX,XX +XXX,XX @@ static void usbredir_unrealize(USBDevice *udev)
422
qemu_bh_delete(dev->chardev_close_bh);
423
qemu_bh_delete(dev->device_reject_bh);
424
425
- timer_del(dev->attach_timer);
426
timer_free(dev->attach_timer);
427
428
usbredir_cleanup_device_queues(dev);
429
diff --git a/hw/vfio/display.c b/hw/vfio/display.c
430
index XXXXXXX..XXXXXXX 100644
431
--- a/hw/vfio/display.c
432
+++ b/hw/vfio/display.c
433
@@ -XXX,XX +XXX,XX @@ static void vfio_display_edid_exit(VFIODisplay *dpy)
434
435
g_free(dpy->edid_regs);
436
g_free(dpy->edid_blob);
437
- timer_del(dpy->edid_link_timer);
438
timer_free(dpy->edid_link_timer);
439
}
440
441
diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c
442
index XXXXXXX..XXXXXXX 100644
443
--- a/hw/virtio/vhost-vsock-common.c
444
+++ b/hw/virtio/vhost-vsock-common.c
445
@@ -XXX,XX +XXX,XX @@ static void vhost_vsock_common_post_load_timer_cleanup(VHostVSockCommon *vvc)
446
return;
447
}
448
449
- timer_del(vvc->post_load_timer);
450
timer_free(vvc->post_load_timer);
451
vvc->post_load_timer = NULL;
452
}
453
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
454
index XXXXXXX..XXXXXXX 100644
455
--- a/hw/virtio/virtio-balloon.c
456
+++ b/hw/virtio/virtio-balloon.c
457
@@ -XXX,XX +XXX,XX @@ static bool balloon_stats_enabled(const VirtIOBalloon *s)
458
static void balloon_stats_destroy_timer(VirtIOBalloon *s)
459
{
460
if (balloon_stats_enabled(s)) {
461
- timer_del(s->stats_timer);
462
timer_free(s->stats_timer);
463
s->stats_timer = NULL;
464
s->stats_poll_interval = 0;
465
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
466
index XXXXXXX..XXXXXXX 100644
467
--- a/hw/virtio/virtio-rng.c
468
+++ b/hw/virtio/virtio-rng.c
469
@@ -XXX,XX +XXX,XX @@ static void virtio_rng_device_unrealize(DeviceState *dev)
470
VirtIORNG *vrng = VIRTIO_RNG(dev);
471
472
qemu_del_vm_change_state_handler(vrng->vmstate);
473
- timer_del(vrng->rate_limit_timer);
474
timer_free(vrng->rate_limit_timer);
475
virtio_del_queue(vdev, 0);
476
virtio_cleanup(vdev);
477
diff --git a/hw/watchdog/wdt_diag288.c b/hw/watchdog/wdt_diag288.c
478
index XXXXXXX..XXXXXXX 100644
479
--- a/hw/watchdog/wdt_diag288.c
480
+++ b/hw/watchdog/wdt_diag288.c
481
@@ -XXX,XX +XXX,XX @@ static void wdt_diag288_unrealize(DeviceState *dev)
482
{
483
DIAG288State *diag288 = DIAG288(dev);
484
485
- timer_del(diag288->timer);
486
timer_free(diag288->timer);
487
}
488
489
diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
490
index XXXXXXX..XXXXXXX 100644
491
--- a/hw/watchdog/wdt_i6300esb.c
492
+++ b/hw/watchdog/wdt_i6300esb.c
493
@@ -XXX,XX +XXX,XX @@ static void i6300esb_exit(PCIDevice *dev)
494
{
495
I6300State *d = WATCHDOG_I6300ESB_DEVICE(dev);
496
497
- timer_del(d->timer);
498
timer_free(d->timer);
499
}
500
501
diff --git a/migration/colo.c b/migration/colo.c
502
index XXXXXXX..XXXXXXX 100644
503
--- a/migration/colo.c
504
+++ b/migration/colo.c
505
@@ -XXX,XX +XXX,XX @@ out:
506
* error.
507
*/
508
colo_compare_unregister_notifier(&packets_compare_notifier);
509
- timer_del(s->colo_delay_timer);
510
timer_free(s->colo_delay_timer);
511
qemu_event_destroy(&s->colo_checkpoint_event);
512
513
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
514
index XXXXXXX..XXXXXXX 100644
515
--- a/monitor/hmp-cmds.c
516
+++ b/monitor/hmp-cmds.c
517
@@ -XXX,XX +XXX,XX @@ static void hmp_migrate_status_cb(void *opaque)
518
error_report("%s", info->error_desc);
519
}
520
monitor_resume(status->mon);
521
- timer_del(status->timer);
522
timer_free(status->timer);
523
g_free(status);
524
}
525
diff --git a/net/announce.c b/net/announce.c
526
index XXXXXXX..XXXXXXX 100644
527
--- a/net/announce.c
528
+++ b/net/announce.c
529
@@ -XXX,XX +XXX,XX @@ void qemu_announce_timer_del(AnnounceTimer *timer, bool free_named)
530
{
531
bool free_timer = false;
532
if (timer->tm) {
533
- timer_del(timer->tm);
534
timer_free(timer->tm);
535
timer->tm = NULL;
536
}
537
diff --git a/net/colo-compare.c b/net/colo-compare.c
538
index XXXXXXX..XXXXXXX 100644
539
--- a/net/colo-compare.c
540
+++ b/net/colo-compare.c
541
@@ -XXX,XX +XXX,XX @@ static void colo_compare_timer_init(CompareState *s)
542
static void colo_compare_timer_del(CompareState *s)
543
{
544
if (s->packet_check_timer) {
545
- timer_del(s->packet_check_timer);
546
timer_free(s->packet_check_timer);
547
s->packet_check_timer = NULL;
548
}
549
diff --git a/net/slirp.c b/net/slirp.c
550
index XXXXXXX..XXXXXXX 100644
551
--- a/net/slirp.c
552
+++ b/net/slirp.c
553
@@ -XXX,XX +XXX,XX @@ static void *net_slirp_timer_new(SlirpTimerCb cb,
554
555
static void net_slirp_timer_free(void *timer, void *opaque)
556
{
557
- timer_del(timer);
558
timer_free(timer);
559
}
560
561
diff --git a/replay/replay-debugging.c b/replay/replay-debugging.c
562
index XXXXXXX..XXXXXXX 100644
563
--- a/replay/replay-debugging.c
564
+++ b/replay/replay-debugging.c
565
@@ -XXX,XX +XXX,XX @@ static void replay_delete_break(void)
566
assert(replay_mutex_locked());
567
568
if (replay_break_timer) {
569
- timer_del(replay_break_timer);
570
timer_free(replay_break_timer);
571
replay_break_timer = NULL;
572
}
573
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
574
index XXXXXXX..XXXXXXX 100644
575
--- a/target/s390x/cpu.c
576
+++ b/target/s390x/cpu.c
577
@@ -XXX,XX +XXX,XX @@ static void s390_cpu_finalize(Object *obj)
578
#if !defined(CONFIG_USER_ONLY)
579
S390CPU *cpu = S390_CPU(obj);
580
581
- timer_del(cpu->env.tod_timer);
582
timer_free(cpu->env.tod_timer);
583
- timer_del(cpu->env.cpu_timer);
584
timer_free(cpu->env.cpu_timer);
585
586
qemu_unregister_reset(s390_cpu_machine_reset_cb, cpu);
587
diff --git a/ui/console.c b/ui/console.c
588
index XXXXXXX..XXXXXXX 100644
589
--- a/ui/console.c
590
+++ b/ui/console.c
591
@@ -XXX,XX +XXX,XX @@ static void gui_setup_refresh(DisplayState *ds)
592
timer_mod(ds->gui_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
593
}
594
if (!need_timer && ds->gui_timer != NULL) {
595
- timer_del(ds->gui_timer);
596
timer_free(ds->gui_timer);
597
ds->gui_timer = NULL;
598
}
599
diff --git a/ui/spice-core.c b/ui/spice-core.c
600
index XXXXXXX..XXXXXXX 100644
601
--- a/ui/spice-core.c
602
+++ b/ui/spice-core.c
603
@@ -XXX,XX +XXX,XX @@ static void timer_cancel(SpiceTimer *timer)
604
605
static void timer_remove(SpiceTimer *timer)
606
{
607
- timer_del(timer->timer);
608
timer_free(timer->timer);
609
g_free(timer);
610
}
611
diff --git a/util/throttle.c b/util/throttle.c
612
index XXXXXXX..XXXXXXX 100644
613
--- a/util/throttle.c
614
+++ b/util/throttle.c
615
@@ -XXX,XX +XXX,XX @@ static void throttle_timer_destroy(QEMUTimer **timer)
616
{
617
assert(*timer != NULL);
618
619
- timer_del(*timer);
620
timer_free(*timer);
621
*timer = NULL;
622
}
623
--
129
--
624
2.20.1
130
2.34.1
625
131
626
132
diff view generated by jsdifflib
1
Implement the v8.1M FPCXT_NS floating-point system register. This is
1
Update the SMMUv3 ID register bit field definitions to the
2
a little more complicated than FPCXT_S, because it has specific
2
set in the most recent specification (IHI0700 F.a).
3
handling for "current FP state is inactive", and it only wants to do
4
PreserveFPState(), not the full set of actions done by
5
ExecuteFPCheck() which vfp_access_check() implements.
6
3
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20201210201433.26262-4-peter.maydell@linaro.org
6
Reviewed-by: Mostafa Saleh <smostafa@google.com>
7
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
Message-id: 20230914145705.1648377-2-peter.maydell@linaro.org
10
---
9
---
11
target/arm/translate-vfp.c.inc | 102 ++++++++++++++++++++++++++++++++-
10
hw/arm/smmuv3-internal.h | 38 ++++++++++++++++++++++++++++++++++++++
12
1 file changed, 99 insertions(+), 3 deletions(-)
11
1 file changed, 38 insertions(+)
13
12
14
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
13
diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-vfp.c.inc
15
--- a/hw/arm/smmuv3-internal.h
17
+++ b/target/arm/translate-vfp.c.inc
16
+++ b/hw/arm/smmuv3-internal.h
18
@@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno)
17
@@ -XXX,XX +XXX,XX @@ REG32(IDR0, 0x0)
19
}
18
FIELD(IDR0, S1P, 1 , 1)
20
break;
19
FIELD(IDR0, TTF, 2 , 2)
21
case ARM_VFP_FPCXT_S:
20
FIELD(IDR0, COHACC, 4 , 1)
22
+ case ARM_VFP_FPCXT_NS:
21
+ FIELD(IDR0, BTM, 5 , 1)
23
if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
22
+ FIELD(IDR0, HTTU, 6 , 2)
24
return false;
23
+ FIELD(IDR0, DORMHINT, 8 , 1)
25
}
24
+ FIELD(IDR0, HYP, 9 , 1)
26
@@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno)
25
+ FIELD(IDR0, ATS, 10, 1)
27
return FPSysRegCheckFailed;
26
+ FIELD(IDR0, NS1ATS, 11, 1)
28
}
27
FIELD(IDR0, ASID16, 12, 1)
29
28
+ FIELD(IDR0, MSI, 13, 1)
30
- if (!vfp_access_check(s)) {
29
+ FIELD(IDR0, SEV, 14, 1)
31
+ /*
30
+ FIELD(IDR0, ATOS, 15, 1)
32
+ * FPCXT_NS is a special case: it has specific handling for
31
+ FIELD(IDR0, PRI, 16, 1)
33
+ * "current FP state is inactive", and must do the PreserveFPState()
32
+ FIELD(IDR0, VMW, 17, 1)
34
+ * but not the usual full set of actions done by ExecuteFPCheck().
33
FIELD(IDR0, VMID16, 18, 1)
35
+ * So we don't call vfp_access_check() and the callers must handle this.
34
+ FIELD(IDR0, CD2L, 19, 1)
36
+ */
35
+ FIELD(IDR0, VATOS, 20, 1)
37
+ if (regno != ARM_VFP_FPCXT_NS && !vfp_access_check(s)) {
36
FIELD(IDR0, TTENDIAN, 21, 2)
38
return FPSysRegCheckDone;
37
+ FIELD(IDR0, ATSRECERR, 23, 1)
39
}
38
FIELD(IDR0, STALL_MODEL, 24, 2)
40
-
39
FIELD(IDR0, TERM_MODEL, 26, 1)
41
return FPSysRegCheckContinue;
40
FIELD(IDR0, STLEVEL, 27, 2)
42
}
41
+ FIELD(IDR0, RME_IMPL, 30, 1)
43
42
44
+static void gen_branch_fpInactive(DisasContext *s, TCGCond cond,
43
REG32(IDR1, 0x4)
45
+ TCGLabel *label)
44
FIELD(IDR1, SIDSIZE, 0 , 6)
46
+{
45
+ FIELD(IDR1, SSIDSIZE, 6 , 5)
47
+ /*
46
+ FIELD(IDR1, PRIQS, 11, 5)
48
+ * FPCXT_NS is a special case: it has specific handling for
47
FIELD(IDR1, EVENTQS, 16, 5)
49
+ * "current FP state is inactive", and must do the PreserveFPState()
48
FIELD(IDR1, CMDQS, 21, 5)
50
+ * but not the usual full set of actions done by ExecuteFPCheck().
49
+ FIELD(IDR1, ATTR_PERMS_OVR, 26, 1)
51
+ * We don't have a TB flag that matches the fpInactive check, so we
50
+ FIELD(IDR1, ATTR_TYPES_OVR, 27, 1)
52
+ * do it at runtime as we don't expect FPCXT_NS accesses to be frequent.
51
+ FIELD(IDR1, REL, 28, 1)
53
+ *
52
+ FIELD(IDR1, QUEUES_PRESET, 29, 1)
54
+ * Emit code that checks fpInactive and does a conditional
53
+ FIELD(IDR1, TABLES_PRESET, 30, 1)
55
+ * branch to label based on it:
54
+ FIELD(IDR1, ECMDQ, 31, 1)
56
+ * if cond is TCG_COND_NE then branch if fpInactive != 0 (ie if inactive)
55
57
+ * if cond is TCG_COND_EQ then branch if fpInactive == 0 (ie if active)
56
#define SMMU_IDR1_SIDSIZE 16
58
+ */
57
#define SMMU_CMDQS 19
59
+ assert(cond == TCG_COND_EQ || cond == TCG_COND_NE);
58
#define SMMU_EVENTQS 19
59
60
REG32(IDR2, 0x8)
61
+ FIELD(IDR2, BA_VATOS, 0, 10)
60
+
62
+
61
+ /* fpInactive = FPCCR_NS.ASPEN == 1 && CONTROL.FPCA == 0 */
63
REG32(IDR3, 0xc)
62
+ TCGv_i32 aspen, fpca;
64
FIELD(IDR3, HAD, 2, 1);
63
+ aspen = load_cpu_field(v7m.fpccr[M_REG_NS]);
65
+ FIELD(IDR3, PBHA, 3, 1);
64
+ fpca = load_cpu_field(v7m.control[M_REG_S]);
66
+ FIELD(IDR3, XNX, 4, 1);
65
+ tcg_gen_andi_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK);
67
+ FIELD(IDR3, PPS, 5, 1);
66
+ tcg_gen_xori_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK);
68
+ FIELD(IDR3, MPAM, 7, 1);
67
+ tcg_gen_andi_i32(fpca, fpca, R_V7M_CONTROL_FPCA_MASK);
69
+ FIELD(IDR3, FWB, 8, 1);
68
+ tcg_gen_or_i32(fpca, fpca, aspen);
70
+ FIELD(IDR3, STT, 9, 1);
69
+ tcg_gen_brcondi_i32(tcg_invert_cond(cond), fpca, 0, label);
71
FIELD(IDR3, RIL, 10, 1);
70
+ tcg_temp_free_i32(aspen);
72
FIELD(IDR3, BBML, 11, 2);
71
+ tcg_temp_free_i32(fpca);
73
+ FIELD(IDR3, E0PD, 13, 1);
72
+}
74
+ FIELD(IDR3, PTWNNC, 14, 1);
75
+ FIELD(IDR3, DPT, 15, 1);
73
+
76
+
74
static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
77
REG32(IDR4, 0x10)
75
76
fp_sysreg_loadfn *loadfn,
77
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
78
{
79
/* Do a write to an M-profile floating point system register */
80
TCGv_i32 tmp;
81
+ TCGLabel *lab_end = NULL;
82
83
switch (fp_sysreg_checks(s, regno)) {
84
case FPSysRegCheckFailed:
85
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
86
tcg_temp_free_i32(tmp);
87
break;
88
}
89
+ case ARM_VFP_FPCXT_NS:
90
+ lab_end = gen_new_label();
91
+ /* fpInactive case: write is a NOP, so branch to end */
92
+ gen_branch_fpInactive(s, TCG_COND_NE, lab_end);
93
+ /* !fpInactive: PreserveFPState(), and reads same as FPCXT_S */
94
+ gen_preserve_fp_state(s);
95
+ /* fall through */
96
case ARM_VFP_FPCXT_S:
97
{
98
TCGv_i32 sfpa, control;
99
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
100
default:
101
g_assert_not_reached();
102
}
103
+ if (lab_end) {
104
+ gen_set_label(lab_end);
105
+ }
106
return true;
107
}
108
109
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno,
110
{
111
/* Do a read from an M-profile floating point system register */
112
TCGv_i32 tmp;
113
+ TCGLabel *lab_end = NULL;
114
+ bool lookup_tb = false;
115
116
switch (fp_sysreg_checks(s, regno)) {
117
case FPSysRegCheckFailed:
118
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno,
119
fpscr = load_cpu_field(v7m.fpdscr[M_REG_NS]);
120
gen_helper_vfp_set_fpscr(cpu_env, fpscr);
121
tcg_temp_free_i32(fpscr);
122
- gen_lookup_tb(s);
123
+ lookup_tb = true;
124
+ break;
125
+ }
126
+ case ARM_VFP_FPCXT_NS:
127
+ {
128
+ TCGv_i32 control, sfpa, fpscr, fpdscr, zero;
129
+ TCGLabel *lab_active = gen_new_label();
130
+
78
+
131
+ lookup_tb = true;
79
REG32(IDR5, 0x14)
132
+
80
FIELD(IDR5, OAS, 0, 3);
133
+ gen_branch_fpInactive(s, TCG_COND_EQ, lab_active);
81
FIELD(IDR5, GRAN4K, 4, 1);
134
+ /* fpInactive case: reads as FPDSCR_NS */
82
FIELD(IDR5, GRAN16K, 5, 1);
135
+ TCGv_i32 tmp = load_cpu_field(v7m.fpdscr[M_REG_NS]);
83
FIELD(IDR5, GRAN64K, 6, 1);
136
+ storefn(s, opaque, tmp);
84
+ FIELD(IDR5, VAX, 10, 2);
137
+ lab_end = gen_new_label();
85
+ FIELD(IDR5, STALL_MAX, 16, 16);
138
+ tcg_gen_br(lab_end);
86
139
+
87
#define SMMU_IDR5_OAS 4
140
+ gen_set_label(lab_active);
141
+ /* !fpInactive: Reads the same as FPCXT_S, but side effects differ */
142
+ gen_preserve_fp_state(s);
143
+ tmp = tcg_temp_new_i32();
144
+ sfpa = tcg_temp_new_i32();
145
+ fpscr = tcg_temp_new_i32();
146
+ gen_helper_vfp_get_fpscr(fpscr, cpu_env);
147
+ tcg_gen_andi_i32(tmp, fpscr, ~FPCR_NZCV_MASK);
148
+ control = load_cpu_field(v7m.control[M_REG_S]);
149
+ tcg_gen_andi_i32(sfpa, control, R_V7M_CONTROL_SFPA_MASK);
150
+ tcg_gen_shli_i32(sfpa, sfpa, 31 - R_V7M_CONTROL_SFPA_SHIFT);
151
+ tcg_gen_or_i32(tmp, tmp, sfpa);
152
+ tcg_temp_free_i32(control);
153
+ /* Store result before updating FPSCR, in case it faults */
154
+ storefn(s, opaque, tmp);
155
+ /* If SFPA is zero then set FPSCR from FPDSCR_NS */
156
+ fpdscr = load_cpu_field(v7m.fpdscr[M_REG_NS]);
157
+ zero = tcg_const_i32(0);
158
+ tcg_gen_movcond_i32(TCG_COND_EQ, fpscr, sfpa, zero, fpdscr, fpscr);
159
+ gen_helper_vfp_set_fpscr(cpu_env, fpscr);
160
+ tcg_temp_free_i32(zero);
161
+ tcg_temp_free_i32(sfpa);
162
+ tcg_temp_free_i32(fpdscr);
163
+ tcg_temp_free_i32(fpscr);
164
break;
165
}
166
default:
167
g_assert_not_reached();
168
}
169
+
170
+ if (lab_end) {
171
+ gen_set_label(lab_end);
172
+ }
173
+ if (lookup_tb) {
174
+ gen_lookup_tb(s);
175
+ }
176
return true;
177
}
178
88
179
--
89
--
180
2.20.1
90
2.34.1
181
182
diff view generated by jsdifflib
1
Support for running KVM on 32-bit Arm hosts was removed in commit
1
In smmuv3_init_regs() when we set the various bits in the ID
2
82bf7ae84ce739e. You can still run a 32-bit guest on a 64-bit Arm
2
registers, we do this almost in order of the fields in the
3
host CPU, but because Arm KVM requires the host and guest CPU types
3
registers, but not quite. Move the initialization of
4
to match, it is not possible to run a guest that requires a Cortex-A9
4
SMMU_IDR3.RIL and SMMU_IDR5.OAS into their correct places.
5
or Cortex-A15 CPU there. That means that the code in the
6
highbank/midway board models to support KVM is no longer used, and we
7
can delete it.
8
5
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Mostafa Saleh <smostafa@google.com>
12
Message-id: 20201215144215.28482-1-peter.maydell@linaro.org
9
Reviewed-by: Eric Auger <eric.auger@redhat.com>
10
Message-id: 20230914145705.1648377-3-peter.maydell@linaro.org
13
---
11
---
14
hw/arm/highbank.c | 14 ++++----------
12
hw/arm/smmuv3.c | 4 ++--
15
1 file changed, 4 insertions(+), 10 deletions(-)
13
1 file changed, 2 insertions(+), 2 deletions(-)
16
14
17
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
15
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/highbank.c
17
--- a/hw/arm/smmuv3.c
20
+++ b/hw/arm/highbank.c
18
+++ b/hw/arm/smmuv3.c
21
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s)
22
#include "hw/arm/boot.h"
20
s->idr[1] = FIELD_DP32(s->idr[1], IDR1, EVENTQS, SMMU_EVENTQS);
23
#include "hw/loader.h"
21
s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS, SMMU_CMDQS);
24
#include "net/net.h"
22
25
-#include "sysemu/kvm.h"
23
- s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1);
26
#include "sysemu/runstate.h"
24
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1);
27
#include "sysemu/sysemu.h"
25
+ s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1);
28
#include "hw/boards.h"
26
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2);
29
@@ -XXX,XX +XXX,XX @@
27
30
#include "hw/cpu/a15mpcore.h"
28
+ s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */
31
#include "qemu/log.h"
29
/* 4K, 16K and 64K granule support */
32
#include "qom/object.h"
30
s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN4K, 1);
33
+#include "cpu.h"
31
s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN16K, 1);
34
32
s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN64K, 1);
35
#define SMP_BOOT_ADDR 0x100
33
- s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */
36
#define SMP_BOOT_REG 0x40
34
37
@@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
35
s->cmdq.base = deposit64(s->cmdq.base, 0, 5, SMMU_CMDQS);
38
highbank_binfo.loader_start = 0;
36
s->cmdq.prod = 0;
39
highbank_binfo.write_secondary_boot = hb_write_secondary;
40
highbank_binfo.secondary_cpu_reset_hook = hb_reset_secondary;
41
- if (!kvm_enabled()) {
42
- highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR;
43
- highbank_binfo.write_board_setup = hb_write_board_setup;
44
- highbank_binfo.secure_board_setup = true;
45
- } else {
46
- warn_report("cannot load built-in Monitor support "
47
- "if KVM is enabled. Some guests (such as Linux) "
48
- "may not boot.");
49
- }
50
+ highbank_binfo.board_setup_addr = BOARD_SETUP_ADDR;
51
+ highbank_binfo.write_board_setup = hb_write_board_setup;
52
+ highbank_binfo.secure_board_setup = true;
53
54
arm_load_kernel(ARM_CPU(first_cpu), machine, &highbank_binfo);
55
}
56
--
37
--
57
2.20.1
38
2.34.1
58
59
diff view generated by jsdifflib
1
In commit 64f863baeedc8659 we implemented the v8.1M FPCXT_S register,
1
The SMMUv3.1-XNX feature is mandatory for an SMMUv3.1 if S2P is
2
but we got the write behaviour wrong. On read, this register reads
2
supported, so we should theoretically have implemented it as part of
3
bits [27:0] of FPSCR plus the CONTROL.SFPA bit. On write, it doesn't
3
the recent S2P work. Fortunately, for us the implementation is a
4
just write back those bits -- it writes a value to the whole FPSCR,
4
no-op.
5
whose upper 4 bits are zeroes.
6
5
7
We also incorrectly implemented the write-to-FPSCR as a simple store
6
This feature is about interpretation of the stage 2 page table
8
to vfp.xregs; this skips the "update the softfloat flags" part of
7
descriptor XN bits, which control execute permissions.
9
the vfp_set_fpscr helper so the value would read back correctly but
10
not actually take effect.
11
8
12
Fix both of these things by doing a complete write to the FPSCR
9
For QEMU, the permission bits passed to an IOMMU (via MemTxAttrs and
13
using the helper function.
10
IOMMUAccessFlags) only indicate read and write; we do not distinguish
11
data reads from instruction reads outside the CPU proper. In the
12
SMMU architecture's terms, our interconnect between the client device
13
and the SMMU doesn't have the ability to convey the INST attribute,
14
and we therefore use the default value of "data" for this attribute.
15
16
We also do not support the bits in the Stream Table Entry that can
17
override the on-the-bus transaction attribute permissions (we do not
18
set SMMU_IDR1.ATTR_PERMS_OVR=1).
19
20
These two things together mean that for our implementation, it never
21
has to deal with transactions with the INST attribute, and so it can
22
correctly ignore the XN bits entirely. So we already implement
23
FEAT_XNX's "XN field is now 2 bits, not 1" behaviour to the extent
24
that we need to.
25
26
Advertise the presence of the feature in SMMU_IDR3.XNX.
14
27
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
29
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20201210201433.26262-3-peter.maydell@linaro.org
30
Reviewed-by: Mostafa Saleh <smostafa@google.com>
31
Reviewed-by: Eric Auger <eric.auger@redhat.com>
32
Message-id: 20230914145705.1648377-4-peter.maydell@linaro.org
18
---
33
---
19
target/arm/translate-vfp.c.inc | 12 ++++++------
34
hw/arm/smmuv3.c | 4 ++++
20
1 file changed, 6 insertions(+), 6 deletions(-)
35
1 file changed, 4 insertions(+)
21
36
22
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
37
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
23
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/translate-vfp.c.inc
39
--- a/hw/arm/smmuv3.c
25
+++ b/target/arm/translate-vfp.c.inc
40
+++ b/hw/arm/smmuv3.c
26
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
41
@@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s)
27
}
42
s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS, SMMU_CMDQS);
28
case ARM_VFP_FPCXT_S:
43
29
{
44
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1);
30
- TCGv_i32 sfpa, control, fpscr;
45
+ if (FIELD_EX32(s->idr[0], IDR0, S2P)) {
31
- /* Set FPSCR[27:0] and CONTROL.SFPA from value */
46
+ /* XNX is a stage-2-specific feature */
32
+ TCGv_i32 sfpa, control;
47
+ s->idr[3] = FIELD_DP32(s->idr[3], IDR3, XNX, 1);
33
+ /*
48
+ }
34
+ * Set FPSCR and CONTROL.SFPA from value; the new FPSCR takes
49
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1);
35
+ * bits [27:0] from value and zeroes bits [31:28].
50
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2);
36
+ */
51
37
tmp = loadfn(s, opaque);
38
sfpa = tcg_temp_new_i32();
39
tcg_gen_shri_i32(sfpa, tmp, 31);
40
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
41
tcg_gen_deposit_i32(control, control, sfpa,
42
R_V7M_CONTROL_SFPA_SHIFT, 1);
43
store_cpu_field(control, v7m.control[M_REG_S]);
44
- fpscr = load_cpu_field(vfp.xregs[ARM_VFP_FPSCR]);
45
- tcg_gen_andi_i32(fpscr, fpscr, FPCR_NZCV_MASK);
46
tcg_gen_andi_i32(tmp, tmp, ~FPCR_NZCV_MASK);
47
- tcg_gen_or_i32(fpscr, fpscr, tmp);
48
- store_cpu_field(fpscr, vfp.xregs[ARM_VFP_FPSCR]);
49
+ gen_helper_vfp_set_fpscr(cpu_env, tmp);
50
tcg_temp_free_i32(tmp);
51
tcg_temp_free_i32(sfpa);
52
break;
53
--
52
--
54
2.20.1
53
2.34.1
55
56
diff view generated by jsdifflib
1
Now that we have implemented all the features needed by the v8.1M
1
FEAT_HPMN0 is a small feature which defines that it is valid for
2
architecture, we can add the model of the Cortex-M55. This is the
2
MDCR_EL2.HPMN to be set to 0, meaning "no PMU event counters provided
3
configuration without MVE support; we'll add MVE later.
3
to an EL1 guest" (previously this setting was reserved). QEMU's
4
implementation almost gets HPMN == 0 right, but we need to fix
5
one check in pmevcntr_is_64_bit(). That is enough for us to
6
advertise the feature in the 'max' CPU.
7
8
(We don't need to make the behaviour conditional on feature
9
presence, because the FEAT_HPMN0 behaviour is within the range
10
of permitted UNPREDICTABLE behaviour for a non-FEAT_HPMN0
11
implementation.)
4
12
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20201210201433.26262-5-peter.maydell@linaro.org
15
Message-id: 20230921185445.3339214-1-peter.maydell@linaro.org
8
---
16
---
9
target/arm/cpu_tcg.c | 42 ++++++++++++++++++++++++++++++++++++++++++
17
docs/system/arm/emulation.rst | 1 +
10
1 file changed, 42 insertions(+)
18
target/arm/helper.c | 2 +-
19
target/arm/tcg/cpu32.c | 4 ++++
20
target/arm/tcg/cpu64.c | 1 +
21
4 files changed, 7 insertions(+), 1 deletion(-)
11
22
12
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
23
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
13
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu_tcg.c
25
--- a/docs/system/arm/emulation.rst
15
+++ b/target/arm/cpu_tcg.c
26
+++ b/docs/system/arm/emulation.rst
16
@@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj)
27
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
17
cpu->ctr = 0x8000c000;
28
- FEAT_HCX (Support for the HCRX_EL2 register)
29
- FEAT_HPDS (Hierarchical permission disables)
30
- FEAT_HPDS2 (Translation table page-based hardware attributes)
31
+- FEAT_HPMN0 (Setting of MDCR_EL2.HPMN to zero)
32
- FEAT_I8MM (AArch64 Int8 matrix multiplication instructions)
33
- FEAT_IDST (ID space trap handling)
34
- FEAT_IESB (Implicit error synchronization event)
35
diff --git a/target/arm/helper.c b/target/arm/helper.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/helper.c
38
+++ b/target/arm/helper.c
39
@@ -XXX,XX +XXX,XX @@ static bool pmevcntr_is_64_bit(CPUARMState *env, int counter)
40
bool hlp = env->cp15.mdcr_el2 & MDCR_HLP;
41
int hpmn = env->cp15.mdcr_el2 & MDCR_HPMN;
42
43
- if (hpmn != 0 && counter >= hpmn) {
44
+ if (counter >= hpmn) {
45
return hlp;
46
}
47
}
48
diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/target/arm/tcg/cpu32.c
51
+++ b/target/arm/tcg/cpu32.c
52
@@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu)
53
t = FIELD_DP32(t, ID_DFR0, COPSDBG, 9); /* FEAT_Debugv8p4 */
54
t = FIELD_DP32(t, ID_DFR0, PERFMON, 6); /* FEAT_PMUv3p5 */
55
cpu->isar.id_dfr0 = t;
56
+
57
+ t = cpu->isar.id_dfr1;
58
+ t = FIELD_DP32(t, ID_DFR1, HPMN0, 1); /* FEAT_HPMN0 */
59
+ cpu->isar.id_dfr1 = t;
18
}
60
}
19
61
20
+static void cortex_m55_initfn(Object *obj)
62
/* CPU models. These are not needed for the AArch64 linux-user build. */
21
+{
63
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
22
+ ARMCPU *cpu = ARM_CPU(obj);
64
index XXXXXXX..XXXXXXX 100644
23
+
65
--- a/target/arm/tcg/cpu64.c
24
+ set_feature(&cpu->env, ARM_FEATURE_V8);
66
+++ b/target/arm/tcg/cpu64.c
25
+ set_feature(&cpu->env, ARM_FEATURE_V8_1M);
67
@@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj)
26
+ set_feature(&cpu->env, ARM_FEATURE_M);
68
t = cpu->isar.id_aa64dfr0;
27
+ set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
69
t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */
28
+ set_feature(&cpu->env, ARM_FEATURE_M_SECURITY);
70
t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 6); /* FEAT_PMUv3p5 */
29
+ set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
71
+ t = FIELD_DP64(t, ID_AA64DFR0, HPMN0, 1); /* FEAT_HPMN0 */
30
+ cpu->midr = 0x410fd221; /* r0p1 */
72
cpu->isar.id_aa64dfr0 = t;
31
+ cpu->revidr = 0;
73
32
+ cpu->pmsav7_dregion = 16;
74
t = cpu->isar.id_aa64smfr0;
33
+ cpu->sau_sregion = 8;
34
+ /*
35
+ * These are the MVFR* values for the FPU, no MVE configuration;
36
+ * we will update them later when we implement MVE
37
+ */
38
+ cpu->isar.mvfr0 = 0x10110221;
39
+ cpu->isar.mvfr1 = 0x12100011;
40
+ cpu->isar.mvfr2 = 0x00000040;
41
+ cpu->isar.id_pfr0 = 0x20000030;
42
+ cpu->isar.id_pfr1 = 0x00000230;
43
+ cpu->isar.id_dfr0 = 0x10200000;
44
+ cpu->id_afr0 = 0x00000000;
45
+ cpu->isar.id_mmfr0 = 0x00111040;
46
+ cpu->isar.id_mmfr1 = 0x00000000;
47
+ cpu->isar.id_mmfr2 = 0x01000000;
48
+ cpu->isar.id_mmfr3 = 0x00000011;
49
+ cpu->isar.id_isar0 = 0x01103110;
50
+ cpu->isar.id_isar1 = 0x02212000;
51
+ cpu->isar.id_isar2 = 0x20232232;
52
+ cpu->isar.id_isar3 = 0x01111131;
53
+ cpu->isar.id_isar4 = 0x01310132;
54
+ cpu->isar.id_isar5 = 0x00000000;
55
+ cpu->isar.id_isar6 = 0x00000000;
56
+ cpu->clidr = 0x00000000; /* caches not implemented */
57
+ cpu->ctr = 0x8303c003;
58
+}
59
+
60
static const ARMCPRegInfo cortexr5_cp_reginfo[] = {
61
/* Dummy the TCM region regs for the moment */
62
{ .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0,
63
@@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = {
64
.class_init = arm_v7m_class_init },
65
{ .name = "cortex-m33", .initfn = cortex_m33_initfn,
66
.class_init = arm_v7m_class_init },
67
+ { .name = "cortex-m55", .initfn = cortex_m55_initfn,
68
+ .class_init = arm_v7m_class_init },
69
{ .name = "cortex-r5", .initfn = cortex_r5_initfn },
70
{ .name = "cortex-r5f", .initfn = cortex_r5f_initfn },
71
{ .name = "ti925t", .initfn = ti925t_initfn },
72
--
75
--
73
2.20.1
76
2.34.1
74
75
diff view generated by jsdifflib
1
Currently timer_free() is a simple wrapper for g_free(). This means
1
The include of hw/arm/virt.h in kvm64.c is unnecessary and also a
2
that the timer being freed must not be currently active, as otherwise
2
layering violation since the generic KVM code shouldn't need to know
3
QEMU might crash later when the active list is processed and still
3
anything about board-specifics. The include line is an accidental
4
has a pointer to freed memory on it. As a result almost all calls to
4
leftover from commit 15613357ba53a4763, where we cleaned up the code
5
timer_free() are preceded by a timer_del() call, as can be seen in
5
to not depend on virt board internals but forgot to also remove the
6
the output of
6
now-redundant include line.
7
git grep -B1 '\<timer_free\>'
8
9
This is unfortunate API design as it makes it easy to accidentally
10
misuse (by forgetting the timer_del()), and the correct use is
11
annoyingly verbose.
12
13
Make timer_free() imply a timer_del().
14
7
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Reviewed-by: Gavin Shan <gshan@redhat.com>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
18
Message-id: 20201215154107.3255-2-peter.maydell@linaro.org
11
Message-id: 20230925110429.3917202-1-peter.maydell@linaro.org
19
---
12
---
20
include/qemu/timer.h | 24 +++++++++++++-----------
13
target/arm/kvm64.c | 1 -
21
1 file changed, 13 insertions(+), 11 deletions(-)
14
1 file changed, 1 deletion(-)
22
15
23
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
16
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
24
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
25
--- a/include/qemu/timer.h
18
--- a/target/arm/kvm64.c
26
+++ b/include/qemu/timer.h
19
+++ b/target/arm/kvm64.c
27
@@ -XXX,XX +XXX,XX @@ static inline QEMUTimer *timer_new_ms(QEMUClockType type, QEMUTimerCB *cb,
20
@@ -XXX,XX +XXX,XX @@
28
*/
21
#include "internals.h"
29
void timer_deinit(QEMUTimer *ts);
22
#include "hw/acpi/acpi.h"
30
23
#include "hw/acpi/ghes.h"
31
-/**
24
-#include "hw/arm/virt.h"
32
- * timer_free:
25
33
- * @ts: the timer
26
static bool have_guest_debug;
34
- *
27
35
- * Free a timer (it must not be on the active list)
36
- */
37
-static inline void timer_free(QEMUTimer *ts)
38
-{
39
- g_free(ts);
40
-}
41
-
42
/**
43
* timer_del:
44
* @ts: the timer
45
@@ -XXX,XX +XXX,XX @@ static inline void timer_free(QEMUTimer *ts)
46
*/
47
void timer_del(QEMUTimer *ts);
48
49
+/**
50
+ * timer_free:
51
+ * @ts: the timer
52
+ *
53
+ * Free a timer. This will call timer_del() for you to remove
54
+ * the timer from the active list if it was still active.
55
+ */
56
+static inline void timer_free(QEMUTimer *ts)
57
+{
58
+ timer_del(ts);
59
+ g_free(ts);
60
+}
61
+
62
/**
63
* timer_mod_ns:
64
* @ts: the timer
65
--
28
--
66
2.20.1
29
2.34.1
67
30
68
31
diff view generated by jsdifflib
1
The CCR is a register most of whose bits are banked between security
1
The hw/arm/boot.h include in common-semi-target.h is not actually
2
states but where BFHFNMIGN is not, and we keep it in the non-secure
2
needed, and it's a bit odd because it pulls a hw/arm header into a
3
entry of the v7m.ccr[] array. The logic which tries to handle this
3
target/arm file.
4
bit fails to implement the "RAZ/WI from Nonsecure if AIRCR.BFHFNMINS
4
5
is zero" requirement; correct the omission.
5
This include was originally needed because the semihosting code used
6
the arm_boot_info struct to get the base address of the RAM in system
7
emulation, to use in a (bad) heuristic for the return values for the
8
SYS_HEAPINFO semihosting call. We've since overhauled how we
9
calculate the HEAPINFO values in system emulation, and the code no
10
longer uses the arm_boot_info struct.
11
12
Remove the now-redundant include line, and instead directly include
13
the cpu-qom.h header that we were previously getting via boot.h.
6
14
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20201210201433.26262-2-peter.maydell@linaro.org
17
Message-id: 20230925112219.3919261-1-peter.maydell@linaro.org
10
---
18
---
11
hw/intc/armv7m_nvic.c | 15 +++++++++++++++
19
target/arm/common-semi-target.h | 4 +---
12
1 file changed, 15 insertions(+)
20
1 file changed, 1 insertion(+), 3 deletions(-)
13
21
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
22
diff --git a/target/arm/common-semi-target.h b/target/arm/common-semi-target.h
15
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/armv7m_nvic.c
24
--- a/target/arm/common-semi-target.h
17
+++ b/hw/intc/armv7m_nvic.c
25
+++ b/target/arm/common-semi-target.h
18
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
26
@@ -XXX,XX +XXX,XX @@
19
*/
27
#ifndef TARGET_ARM_COMMON_SEMI_TARGET_H
20
val = cpu->env.v7m.ccr[attrs.secure];
28
#define TARGET_ARM_COMMON_SEMI_TARGET_H
21
val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK;
29
22
+ /* BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0 */
30
-#ifndef CONFIG_USER_ONLY
23
+ if (!attrs.secure) {
31
-#include "hw/arm/boot.h"
24
+ if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
32
-#endif
25
+ val &= ~R_V7M_CCR_BFHFNMIGN_MASK;
33
+#include "target/arm/cpu-qom.h"
26
+ }
34
27
+ }
35
static inline target_ulong common_semi_arg(CPUState *cs, int argno)
28
return val;
36
{
29
case 0xd24: /* System Handler Control and State (SHCSR) */
30
if (!arm_feature(&cpu->env, ARM_FEATURE_V7)) {
31
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
32
(cpu->env.v7m.ccr[M_REG_NS] & ~R_V7M_CCR_BFHFNMIGN_MASK)
33
| (value & R_V7M_CCR_BFHFNMIGN_MASK);
34
value &= ~R_V7M_CCR_BFHFNMIGN_MASK;
35
+ } else {
36
+ /*
37
+ * BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0, so
38
+ * preserve the state currently in the NS element of the array
39
+ */
40
+ if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
41
+ value &= ~R_V7M_CCR_BFHFNMIGN_MASK;
42
+ value |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK;
43
+ }
44
}
45
46
cpu->env.v7m.ccr[attrs.secure] = value;
47
--
37
--
48
2.20.1
38
2.34.1
49
50
diff view generated by jsdifflib
1
The Arm CPU finalize function uses a sequence of timer_del(), timer_deinit(),
1
The code for powering on a CPU in arm-powerctl.c has two separate
2
timer_free() to free the timer. The timer_deinit() step in this was always
2
use cases:
3
unnecessary, and now the timer_del() is implied by timer_free(), so we can
3
* emulation of a real hardware power controller
4
collapse this down to simply calling timer_free().
4
* emulation of firmware interfaces (primarily PSCI) with
5
5
CPU on/off APIs
6
7
For the first case, we only need to reset the CPU and set its
8
starting PC and X0. For the second case, because we're emulating the
9
firmware we need to ensure that it's in the state that the firmware
10
provides. In particular, when we reset to a lower EL than the
11
highest one we are emulating, we need to put the CPU into a state
12
that permits correct running at that lower EL. We already do a
13
little of this in arm-powerctl.c (for instance we set SCR_HCE to
14
enable the HVC insn) but we don't do enough of it. This means that
15
in the case where we are emulating EL3 but also providing emulated
16
PSCI the guest will crash when a secondary core tries to use a
17
feature that needs an SCR_EL3 bit to be set, such as MTE or PAuth.
18
19
The hw/arm/boot.c code also has to support this "start guest code in
20
an EL that's lower than the highest emulated EL" case in order to do
21
direct guest kernel booting; it has all the necessary initialization
22
code to set the SCR_EL3 bits. Pull the relevant boot.c code out into
23
a separate function so we can share it between there and
24
arm-powerctl.c.
25
26
This refactoring has a few code changes that look like they
27
might be behaviour changes but aren't:
28
* if info->secure_boot is false and info->secure_board_setup is
29
true, then the old code would start the first CPU in Hyp
30
mode but without changing SCR.NS and NSACR.{CP11,CP10}.
31
This was wrong behaviour because there's no such thing
32
as Secure Hyp mode. The new code will leave the CPU in SVC.
33
(There is no board which sets secure_boot to false and
34
secure_board_setup to true, so this isn't a behaviour
35
change for any of our boards.)
36
* we don't explicitly clear SCR.NS when arm-powerctl.c
37
does a CPU-on to EL3. This was a no-op because CPU reset
38
will reset to NS == 0.
39
40
And some real behaviour changes:
41
* we no longer set HCR_EL2.RW when booting into EL2: the guest
42
can and should do that themselves before dropping into their
43
EL1 code. (arm-powerctl and boot did this differently; I
44
opted to use the logic from arm-powerctl, which only sets
45
HCR_EL2.RW when it's directly starting the guest in EL1,
46
because it's more correct, and I don't expect guests to be
47
accidentally depending on our having set the RW bit for them.)
48
* if we are booting a CPU into AArch32 Secure SVC then we won't
49
set SCR.HCE any more. This affects only the vexpress-a15 and
50
raspi2b machine types. Guests booting in this case will either:
51
- be able to set SCR.HCE themselves as part of moving from
52
Secure SVC into NS Hyp mode
53
- will move from Secure SVC to NS SVC, and won't care about
54
behaviour of the HVC insn
55
- will stay in Secure SVC, and won't care about HVC
56
* on an arm-powerctl CPU-on we will now set the SCR bits for
57
pauth/mte/sve/sme/hcx/fgt features
58
59
The first two of these are very minor and I don't expect guest
60
code to trip over them, so I didn't judge it worth convoluting
61
the code in an attempt to keep exactly the same boot.c behaviour.
62
The third change fixes issue 1899.
63
64
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1899
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
65
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
66
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20201215154107.3255-5-peter.maydell@linaro.org
67
Message-id: 20230926155619.4028618-1-peter.maydell@linaro.org
10
---
68
---
11
target/arm/cpu.c | 2 --
69
target/arm/cpu.h | 22 +++++++++
12
1 file changed, 2 deletions(-)
70
hw/arm/boot.c | 95 ++++++++++-----------------------------
13
71
target/arm/arm-powerctl.c | 53 +---------------------
72
target/arm/cpu.c | 95 +++++++++++++++++++++++++++++++++++++++
73
4 files changed, 141 insertions(+), 124 deletions(-)
74
75
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
76
index XXXXXXX..XXXXXXX 100644
77
--- a/target/arm/cpu.h
78
+++ b/target/arm/cpu.h
79
@@ -XXX,XX +XXX,XX @@ int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
80
int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,
81
int cpuid, DumpState *s);
82
83
+/**
84
+ * arm_emulate_firmware_reset: Emulate firmware CPU reset handling
85
+ * @cpu: CPU (which must have been freshly reset)
86
+ * @target_el: exception level to put the CPU into
87
+ * @secure: whether to put the CPU in secure state
88
+ *
89
+ * When QEMU is directly running a guest kernel at a lower level than
90
+ * EL3 it implicitly emulates some aspects of the guest firmware.
91
+ * This includes that on reset we need to configure the parts of the
92
+ * CPU corresponding to EL3 so that the real guest code can run at its
93
+ * lower exception level. This function does that post-reset CPU setup,
94
+ * for when we do direct boot of a guest kernel, and for when we
95
+ * emulate PSCI and similar firmware interfaces starting a CPU at a
96
+ * lower exception level.
97
+ *
98
+ * @target_el must be an EL implemented by the CPU between 1 and 3.
99
+ * We do not support dropping into a Secure EL other than 3.
100
+ *
101
+ * It is the responsibility of the caller to call arm_rebuild_hflags().
102
+ */
103
+void arm_emulate_firmware_reset(CPUState *cpustate, int target_el);
104
+
105
#ifdef TARGET_AARCH64
106
int aarch64_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
107
int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
108
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
109
index XXXXXXX..XXXXXXX 100644
110
--- a/hw/arm/boot.c
111
+++ b/hw/arm/boot.c
112
@@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque)
113
114
cpu_set_pc(cs, entry);
115
} else {
116
- /* If we are booting Linux then we need to check whether we are
117
- * booting into secure or non-secure state and adjust the state
118
- * accordingly. Out of reset, ARM is defined to be in secure state
119
- * (SCR.NS = 0), we change that here if non-secure boot has been
120
- * requested.
121
+ /*
122
+ * If we are booting Linux then we might need to do so at:
123
+ * - AArch64 NS EL2 or NS EL1
124
+ * - AArch32 Secure SVC (EL3)
125
+ * - AArch32 NS Hyp (EL2)
126
+ * - AArch32 NS SVC (EL1)
127
+ * Configure the CPU in the way boot firmware would do to
128
+ * drop us down to the appropriate level.
129
*/
130
- if (arm_feature(env, ARM_FEATURE_EL3)) {
131
- /* AArch64 is defined to come out of reset into EL3 if enabled.
132
- * If we are booting Linux then we need to adjust our EL as
133
- * Linux expects us to be in EL2 or EL1. AArch32 resets into
134
- * SVC, which Linux expects, so no privilege/exception level to
135
- * adjust.
136
- */
137
- if (env->aarch64) {
138
- env->cp15.scr_el3 |= SCR_RW;
139
- if (arm_feature(env, ARM_FEATURE_EL2)) {
140
- env->cp15.hcr_el2 |= HCR_RW;
141
- env->pstate = PSTATE_MODE_EL2h;
142
- } else {
143
- env->pstate = PSTATE_MODE_EL1h;
144
- }
145
- if (cpu_isar_feature(aa64_pauth, cpu)) {
146
- env->cp15.scr_el3 |= SCR_API | SCR_APK;
147
- }
148
- if (cpu_isar_feature(aa64_mte, cpu)) {
149
- env->cp15.scr_el3 |= SCR_ATA;
150
- }
151
- if (cpu_isar_feature(aa64_sve, cpu)) {
152
- env->cp15.cptr_el[3] |= R_CPTR_EL3_EZ_MASK;
153
- env->vfp.zcr_el[3] = 0xf;
154
- }
155
- if (cpu_isar_feature(aa64_sme, cpu)) {
156
- env->cp15.cptr_el[3] |= R_CPTR_EL3_ESM_MASK;
157
- env->cp15.scr_el3 |= SCR_ENTP2;
158
- env->vfp.smcr_el[3] = 0xf;
159
- }
160
- if (cpu_isar_feature(aa64_hcx, cpu)) {
161
- env->cp15.scr_el3 |= SCR_HXEN;
162
- }
163
- if (cpu_isar_feature(aa64_fgt, cpu)) {
164
- env->cp15.scr_el3 |= SCR_FGTEN;
165
- }
166
+ int target_el = arm_feature(env, ARM_FEATURE_EL2) ? 2 : 1;
167
168
- /* AArch64 kernels never boot in secure mode */
169
- assert(!info->secure_boot);
170
- /* This hook is only supported for AArch32 currently:
171
- * bootloader_aarch64[] will not call the hook, and
172
- * the code above has already dropped us into EL2 or EL1.
173
- */
174
- assert(!info->secure_board_setup);
175
- }
176
-
177
- if (arm_feature(env, ARM_FEATURE_EL2)) {
178
- /* If we have EL2 then Linux expects the HVC insn to work */
179
- env->cp15.scr_el3 |= SCR_HCE;
180
- }
181
-
182
- /* Set to non-secure if not a secure boot */
183
- if (!info->secure_boot &&
184
- (cs != first_cpu || !info->secure_board_setup)) {
185
- /* Linux expects non-secure state */
186
- env->cp15.scr_el3 |= SCR_NS;
187
- /* Set NSACR.{CP11,CP10} so NS can access the FPU */
188
- env->cp15.nsacr |= 3 << 10;
189
- }
190
- }
191
-
192
- if (!env->aarch64 && !info->secure_boot &&
193
- arm_feature(env, ARM_FEATURE_EL2)) {
194
+ if (env->aarch64) {
195
/*
196
- * This is an AArch32 boot not to Secure state, and
197
- * we have Hyp mode available, so boot the kernel into
198
- * Hyp mode. This is not how the CPU comes out of reset,
199
- * so we need to manually put it there.
200
+ * AArch64 kernels never boot in secure mode, and we don't
201
+ * support the secure_board_setup hook for AArch64.
202
*/
203
- cpsr_write(env, ARM_CPU_MODE_HYP, CPSR_M, CPSRWriteRaw);
204
+ assert(!info->secure_boot);
205
+ assert(!info->secure_board_setup);
206
+ } else {
207
+ if (arm_feature(env, ARM_FEATURE_EL3) &&
208
+ (info->secure_boot ||
209
+ (info->secure_board_setup && cs == first_cpu))) {
210
+ /* Start this CPU in Secure SVC */
211
+ target_el = 3;
212
+ }
213
}
214
215
+ arm_emulate_firmware_reset(cs, target_el);
216
+
217
if (cs == first_cpu) {
218
AddressSpace *as = arm_boot_address_space(cpu, info);
219
220
diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c
221
index XXXXXXX..XXXXXXX 100644
222
--- a/target/arm/arm-powerctl.c
223
+++ b/target/arm/arm-powerctl.c
224
@@ -XXX,XX +XXX,XX @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state,
225
226
/* Initialize the cpu we are turning on */
227
cpu_reset(target_cpu_state);
228
+ arm_emulate_firmware_reset(target_cpu_state, info->target_el);
229
target_cpu_state->halted = 0;
230
231
- if (info->target_aa64) {
232
- if ((info->target_el < 3) && arm_feature(&target_cpu->env,
233
- ARM_FEATURE_EL3)) {
234
- /*
235
- * As target mode is AArch64, we need to set lower
236
- * exception level (the requested level 2) to AArch64
237
- */
238
- target_cpu->env.cp15.scr_el3 |= SCR_RW;
239
- }
240
-
241
- if ((info->target_el < 2) && arm_feature(&target_cpu->env,
242
- ARM_FEATURE_EL2)) {
243
- /*
244
- * As target mode is AArch64, we need to set lower
245
- * exception level (the requested level 1) to AArch64
246
- */
247
- target_cpu->env.cp15.hcr_el2 |= HCR_RW;
248
- }
249
-
250
- target_cpu->env.pstate = aarch64_pstate_mode(info->target_el, true);
251
- } else {
252
- /* We are requested to boot in AArch32 mode */
253
- static const uint32_t mode_for_el[] = { 0,
254
- ARM_CPU_MODE_SVC,
255
- ARM_CPU_MODE_HYP,
256
- ARM_CPU_MODE_SVC };
257
-
258
- cpsr_write(&target_cpu->env, mode_for_el[info->target_el], CPSR_M,
259
- CPSRWriteRaw);
260
- }
261
-
262
- if (info->target_el == 3) {
263
- /* Processor is in secure mode */
264
- target_cpu->env.cp15.scr_el3 &= ~SCR_NS;
265
- } else {
266
- /* Processor is not in secure mode */
267
- target_cpu->env.cp15.scr_el3 |= SCR_NS;
268
-
269
- /* Set NSACR.{CP11,CP10} so NS can access the FPU */
270
- target_cpu->env.cp15.nsacr |= 3 << 10;
271
-
272
- /*
273
- * If QEMU is providing the equivalent of EL3 firmware, then we need
274
- * to make sure a CPU targeting EL2 comes out of reset with a
275
- * functional HVC insn.
276
- */
277
- if (arm_feature(&target_cpu->env, ARM_FEATURE_EL3)
278
- && info->target_el == 2) {
279
- target_cpu->env.cp15.scr_el3 |= SCR_HCE;
280
- }
281
- }
282
-
283
/* We check if the started CPU is now at the correct level */
284
assert(info->target_el == arm_current_el(&target_cpu->env));
285
14
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
286
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
15
index XXXXXXX..XXXXXXX 100644
287
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu.c
288
--- a/target/arm/cpu.c
17
+++ b/target/arm/cpu.c
289
+++ b/target/arm/cpu.c
18
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_finalizefn(Object *obj)
290
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj)
19
}
291
}
20
#ifndef CONFIG_USER_ONLY
292
}
21
if (cpu->pmu_timer) {
293
22
- timer_del(cpu->pmu_timer);
294
+void arm_emulate_firmware_reset(CPUState *cpustate, int target_el)
23
- timer_deinit(cpu->pmu_timer);
295
+{
24
timer_free(cpu->pmu_timer);
296
+ ARMCPU *cpu = ARM_CPU(cpustate);
25
}
297
+ CPUARMState *env = &cpu->env;
26
#endif
298
+ bool have_el3 = arm_feature(env, ARM_FEATURE_EL3);
299
+ bool have_el2 = arm_feature(env, ARM_FEATURE_EL2);
300
+
301
+ /*
302
+ * Check we have the EL we're aiming for. If that is the
303
+ * highest implemented EL, then cpu_reset has already done
304
+ * all the work.
305
+ */
306
+ switch (target_el) {
307
+ case 3:
308
+ assert(have_el3);
309
+ return;
310
+ case 2:
311
+ assert(have_el2);
312
+ if (!have_el3) {
313
+ return;
314
+ }
315
+ break;
316
+ case 1:
317
+ if (!have_el3 && !have_el2) {
318
+ return;
319
+ }
320
+ break;
321
+ default:
322
+ g_assert_not_reached();
323
+ }
324
+
325
+ if (have_el3) {
326
+ /*
327
+ * Set the EL3 state so code can run at EL2. This should match
328
+ * the requirements set by Linux in its booting spec.
329
+ */
330
+ if (env->aarch64) {
331
+ env->cp15.scr_el3 |= SCR_RW;
332
+ if (cpu_isar_feature(aa64_pauth, cpu)) {
333
+ env->cp15.scr_el3 |= SCR_API | SCR_APK;
334
+ }
335
+ if (cpu_isar_feature(aa64_mte, cpu)) {
336
+ env->cp15.scr_el3 |= SCR_ATA;
337
+ }
338
+ if (cpu_isar_feature(aa64_sve, cpu)) {
339
+ env->cp15.cptr_el[3] |= R_CPTR_EL3_EZ_MASK;
340
+ env->vfp.zcr_el[3] = 0xf;
341
+ }
342
+ if (cpu_isar_feature(aa64_sme, cpu)) {
343
+ env->cp15.cptr_el[3] |= R_CPTR_EL3_ESM_MASK;
344
+ env->cp15.scr_el3 |= SCR_ENTP2;
345
+ env->vfp.smcr_el[3] = 0xf;
346
+ }
347
+ if (cpu_isar_feature(aa64_hcx, cpu)) {
348
+ env->cp15.scr_el3 |= SCR_HXEN;
349
+ }
350
+ if (cpu_isar_feature(aa64_fgt, cpu)) {
351
+ env->cp15.scr_el3 |= SCR_FGTEN;
352
+ }
353
+ }
354
+
355
+ if (target_el == 2) {
356
+ /* If the guest is at EL2 then Linux expects the HVC insn to work */
357
+ env->cp15.scr_el3 |= SCR_HCE;
358
+ }
359
+
360
+ /* Put CPU into non-secure state */
361
+ env->cp15.scr_el3 |= SCR_NS;
362
+ /* Set NSACR.{CP11,CP10} so NS can access the FPU */
363
+ env->cp15.nsacr |= 3 << 10;
364
+ }
365
+
366
+ if (have_el2 && target_el < 2) {
367
+ /* Set EL2 state so code can run at EL1. */
368
+ if (env->aarch64) {
369
+ env->cp15.hcr_el2 |= HCR_RW;
370
+ }
371
+ }
372
+
373
+ /* Set the CPU to the desired state */
374
+ if (env->aarch64) {
375
+ env->pstate = aarch64_pstate_mode(target_el, true);
376
+ } else {
377
+ static const uint32_t mode_for_el[] = {
378
+ 0,
379
+ ARM_CPU_MODE_SVC,
380
+ ARM_CPU_MODE_HYP,
381
+ ARM_CPU_MODE_SVC,
382
+ };
383
+
384
+ cpsr_write(env, mode_for_el[target_el], CPSR_M, CPSRWriteRaw);
385
+ }
386
+}
387
+
388
+
389
#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
390
391
static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
27
--
392
--
28
2.20.1
393
2.34.1
29
30
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Chris Rauer <crauer@google.com>
2
2
3
When running device-introspect-test, a memory leak occurred in the a10_pit_init
3
The counter register is only 24-bits and counts down. If the timer is
4
function, so use ptimer_free() in the finalize function to avoid it.
4
running but the qtimer to reset it hasn't fired off yet, there is a chance
5
the regster read can return an invalid result.
5
6
6
ASAN shows memory leak stack:
7
Signed-off-by: Chris Rauer <crauer@google.com>
7
8
Message-id: 20230922181411.2697135-1-crauer@google.com
8
Indirect leak of 288 byte(s) in 6 object(s) allocated from:
9
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
10
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
11
#2 0xaaabf555db84 in timer_new_full /qemu/include/qemu/timer.h:523
12
#3 0xaaabf555db84 in timer_new /qemu/include/qemu/timer.h:544
13
#4 0xaaabf555db84 in timer_new_ns /qemu/include/qemu/timer.h:562
14
#5 0xaaabf555db84 in ptimer_init /qemu/hw/core/ptimer.c:433
15
#6 0xaaabf57415e8 in a10_pit_init /qemu/hw/timer/allwinner-a10-pit.c:278
16
#7 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
17
#8 0xaaabf633ca04 in object_initialize_child_with_propsv /qemu/qom/object.c:564
18
#9 0xaaabf633cc08 in object_initialize_child_with_props /qemu/qom/object.c:547
19
#10 0xaaabf5b94680 in aw_a10_init /qemu/hw/arm/allwinner-a10.c:49
20
#11 0xaaabf6339f6c in object_initialize_with_type /qemu/qom/object.c:515
21
#12 0xaaabf633a1e0 in object_new_with_type /qemu/qom/object.c:729
22
23
Reported-by: Euler Robot <euler.robot@huawei.com>
24
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
25
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
---
11
---
28
hw/timer/allwinner-a10-pit.c | 11 +++++++++++
12
hw/timer/npcm7xx_timer.c | 3 +++
29
1 file changed, 11 insertions(+)
13
1 file changed, 3 insertions(+)
30
14
31
diff --git a/hw/timer/allwinner-a10-pit.c b/hw/timer/allwinner-a10-pit.c
15
diff --git a/hw/timer/npcm7xx_timer.c b/hw/timer/npcm7xx_timer.c
32
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/timer/allwinner-a10-pit.c
17
--- a/hw/timer/npcm7xx_timer.c
34
+++ b/hw/timer/allwinner-a10-pit.c
18
+++ b/hw/timer/npcm7xx_timer.c
35
@@ -XXX,XX +XXX,XX @@ static void a10_pit_init(Object *obj)
19
@@ -XXX,XX +XXX,XX @@ static int64_t npcm7xx_timer_count_to_ns(NPCM7xxTimer *t, uint32_t count)
36
}
20
/* Convert a time interval in nanoseconds to a timer cycle count. */
21
static uint32_t npcm7xx_timer_ns_to_count(NPCM7xxTimer *t, int64_t ns)
22
{
23
+ if (ns < 0) {
24
+ return 0;
25
+ }
26
return clock_ns_to_ticks(t->ctrl->clock, ns) /
27
npcm7xx_tcsr_prescaler(t->tcsr);
37
}
28
}
38
39
+static void a10_pit_finalize(Object *obj)
40
+{
41
+ AwA10PITState *s = AW_A10_PIT(obj);
42
+ int i;
43
+
44
+ for (i = 0; i < AW_A10_PIT_TIMER_NR; i++) {
45
+ ptimer_free(s->timer[i]);
46
+ }
47
+}
48
+
49
static void a10_pit_class_init(ObjectClass *klass, void *data)
50
{
51
DeviceClass *dc = DEVICE_CLASS(klass);
52
@@ -XXX,XX +XXX,XX @@ static const TypeInfo a10_pit_info = {
53
.parent = TYPE_SYS_BUS_DEVICE,
54
.instance_size = sizeof(AwA10PITState),
55
.instance_init = a10_pit_init,
56
+ .instance_finalize = a10_pit_finalize,
57
.class_init = a10_pit_class_init,
58
};
59
60
--
29
--
61
2.20.1
30
2.34.1
62
63
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Suraj Shirvankar <surajshirvankar@gmail.com>
2
2
3
Correct the indexing into s->cpu_ctlr for vCPUs.
3
QEMU coding style uses the glib memory allocation APIs, not
4
the raw libc malloc/free. Switch the allocation and free
5
calls in elf2dmp to use these functions (dropping the now-unneeded
6
checks for failure).
4
7
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
8
Signed-off-by: Suraj Shirvankar <surajshirvankar@gmail.com>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 169753938460.23804.11418813007617535750-1@git.sr.ht
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
10
[PMM: also remove NULL checks from g_malloc() calls;
8
Message-id: 20201214222154.3480243-2-edgar.iglesias@gmail.com
11
beef up commit message]
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
14
---
11
hw/intc/arm_gic.c | 4 +++-
15
contrib/elf2dmp/addrspace.c | 7 ++-----
12
1 file changed, 3 insertions(+), 1 deletion(-)
16
contrib/elf2dmp/main.c | 9 +++------
17
contrib/elf2dmp/pdb.c | 19 ++++++++-----------
18
contrib/elf2dmp/qemu_elf.c | 7 ++-----
19
4 files changed, 15 insertions(+), 27 deletions(-)
13
20
14
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
21
diff --git a/contrib/elf2dmp/addrspace.c b/contrib/elf2dmp/addrspace.c
15
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/arm_gic.c
23
--- a/contrib/elf2dmp/addrspace.c
17
+++ b/hw/intc/arm_gic.c
24
+++ b/contrib/elf2dmp/addrspace.c
18
@@ -XXX,XX +XXX,XX @@ static inline void gic_get_best_virq(GICState *s, int cpu,
25
@@ -XXX,XX +XXX,XX @@ int pa_space_create(struct pa_space *ps, QEMU_Elf *qemu_elf)
19
static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt,
26
}
20
int group_mask)
27
}
28
29
- ps->block = malloc(sizeof(*ps->block) * ps->block_nr);
30
- if (!ps->block) {
31
- return 1;
32
- }
33
+ ps->block = g_new(struct pa_block, ps->block_nr);
34
35
for (i = 0; i < phdr_nr; i++) {
36
if (phdr[i].p_type == PT_LOAD) {
37
@@ -XXX,XX +XXX,XX @@ int pa_space_create(struct pa_space *ps, QEMU_Elf *qemu_elf)
38
void pa_space_destroy(struct pa_space *ps)
21
{
39
{
22
+ int cpu_iface = virt ? (cpu + GIC_NCPU) : cpu;
40
ps->block_nr = 0;
23
+
41
- free(ps->block);
24
if (!virt && !(s->ctlr & group_mask)) {
42
+ g_free(ps->block);
25
return false;
43
}
44
45
void va_space_set_dtb(struct va_space *vs, uint64_t dtb)
46
diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/contrib/elf2dmp/main.c
49
+++ b/contrib/elf2dmp/main.c
50
@@ -XXX,XX +XXX,XX @@ static KDDEBUGGER_DATA64 *get_kdbg(uint64_t KernBase, struct pdb_reader *pdb,
51
}
26
}
52
}
27
@@ -XXX,XX +XXX,XX @@ static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt,
53
28
return false;
54
- kdbg = malloc(kdbg_hdr.Size);
55
- if (!kdbg) {
56
- return NULL;
57
- }
58
+ kdbg = g_malloc(kdbg_hdr.Size);
59
60
if (va_space_rw(vs, KdDebuggerDataBlock, kdbg, kdbg_hdr.Size, 0)) {
61
eprintf("Failed to extract entire KDBG\n");
62
- free(kdbg);
63
+ g_free(kdbg);
64
return NULL;
29
}
65
}
30
66
31
- if (!(s->cpu_ctlr[cpu] & group_mask)) {
67
@@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[])
32
+ if (!(s->cpu_ctlr[cpu_iface] & group_mask)) {
33
return false;
34
}
68
}
35
69
70
out_kdbg:
71
- free(kdbg);
72
+ g_free(kdbg);
73
out_pdb:
74
pdb_exit(&pdb);
75
out_pdb_file:
76
diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
77
index XXXXXXX..XXXXXXX 100644
78
--- a/contrib/elf2dmp/pdb.c
79
+++ b/contrib/elf2dmp/pdb.c
80
@@ -XXX,XX +XXX,XX @@ uint64_t pdb_resolve(uint64_t img_base, struct pdb_reader *r, const char *name)
81
82
static void pdb_reader_ds_exit(struct pdb_reader *r)
83
{
84
- free(r->ds.toc);
85
+ g_free(r->ds.toc);
86
}
87
88
static void pdb_exit_symbols(struct pdb_reader *r)
89
{
90
- free(r->modimage);
91
- free(r->symbols);
92
+ g_free(r->modimage);
93
+ g_free(r->symbols);
94
}
95
96
static void pdb_exit_segments(struct pdb_reader *r)
97
{
98
- free(r->segs);
99
+ g_free(r->segs);
100
}
101
102
static void *pdb_ds_read(const PDB_DS_HEADER *header,
103
@@ -XXX,XX +XXX,XX @@ static void *pdb_ds_read(const PDB_DS_HEADER *header,
104
105
nBlocks = (size + header->block_size - 1) / header->block_size;
106
107
- buffer = malloc(nBlocks * header->block_size);
108
- if (!buffer) {
109
- return NULL;
110
- }
111
+ buffer = g_malloc(nBlocks * header->block_size);
112
113
for (i = 0; i < nBlocks; i++) {
114
memcpy(buffer + i * header->block_size, (const char *)header +
115
@@ -XXX,XX +XXX,XX @@ static int pdb_init_symbols(struct pdb_reader *r)
116
return 0;
117
118
out_symbols:
119
- free(symbols);
120
+ g_free(symbols);
121
122
return err;
123
}
124
@@ -XXX,XX +XXX,XX @@ static int pdb_reader_init(struct pdb_reader *r, void *data)
125
out_sym:
126
pdb_exit_symbols(r);
127
out_root:
128
- free(r->ds.root);
129
+ g_free(r->ds.root);
130
out_ds:
131
pdb_reader_ds_exit(r);
132
133
@@ -XXX,XX +XXX,XX @@ static void pdb_reader_exit(struct pdb_reader *r)
134
{
135
pdb_exit_segments(r);
136
pdb_exit_symbols(r);
137
- free(r->ds.root);
138
+ g_free(r->ds.root);
139
pdb_reader_ds_exit(r);
140
}
141
142
diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c
143
index XXXXXXX..XXXXXXX 100644
144
--- a/contrib/elf2dmp/qemu_elf.c
145
+++ b/contrib/elf2dmp/qemu_elf.c
146
@@ -XXX,XX +XXX,XX @@ static int init_states(QEMU_Elf *qe)
147
148
printf("%zu CPU states has been found\n", cpu_nr);
149
150
- qe->state = malloc(sizeof(*qe->state) * cpu_nr);
151
- if (!qe->state) {
152
- return 1;
153
- }
154
+ qe->state = g_new(QEMUCPUState*, cpu_nr);
155
156
cpu_nr = 0;
157
158
@@ -XXX,XX +XXX,XX @@ static int init_states(QEMU_Elf *qe)
159
160
static void exit_states(QEMU_Elf *qe)
161
{
162
- free(qe->state);
163
+ g_free(qe->state);
164
}
165
166
static bool check_ehdr(QEMU_Elf *qe)
36
--
167
--
37
2.20.1
168
2.34.1
38
39
diff view generated by jsdifflib