1
Nothing too exciting, but does include the last bits of v8.1M support work.
1
Just flushing my target-arm queue since I won't be working next week :-)
2
2
3
-- PMM
3
-- PMM
4
4
5
The following changes since commit e79de63ab1bd1f6550e7b915e433bec1ad1a870a:
5
The following changes since commit b3cd3b5a66f0dddfe3d5ba2bef13cd4f5b89cde9:
6
6
7
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210107' into staging (2021-01-07 20:34:05 +0000)
7
Merge tag 'pull-riscv-to-apply-20220610' of github.com:alistair23/qemu into staging (2022-06-09 22:08:27 -0700)
8
8
9
are available in the Git repository at:
9
are available in the Git repository at:
10
10
11
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210108
11
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220610
12
12
13
for you to fetch changes up to c9f8511ea8d2b80723af0fea1f716d752c1b5208:
13
for you to fetch changes up to 90c072e063737e9e8f431489bbd334452f89056e:
14
14
15
docs/system: arm: Add sabrelite board description (2021-01-08 15:13:39 +0000)
15
semihosting/config: Merge --semihosting-config option groups (2022-06-10 14:32:36 +0100)
16
16
17
----------------------------------------------------------------
17
----------------------------------------------------------------
18
target-arm queue:
18
* refactor exception routing code
19
* intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs
19
* fix SCR_EL3 RAO/RAZ bits
20
* target/arm: Fix MTE0_ACTIVE
20
* gdbstub: Don't use GDB syscalls if no GDB is attached
21
* target/arm: Implement v8.1M and Cortex-M55 model
21
* semihosting/config: Merge --semihosting-config option groups
22
* hw/arm/highbank: Drop dead KVM support code
22
* tests/qtest: Reduce npcm7xx_sdhci test image size
23
* util/qemu-timer: Make timer_free() imply timer_del()
24
* various devices: Use ptimer_free() in finalize function
25
* docs/system: arm: Add sabrelite board description
26
* sabrelite: Minor fixes to allow booting U-Boot
27
23
28
----------------------------------------------------------------
24
----------------------------------------------------------------
29
Andrew Jones (1):
25
Hao Wu (1):
30
hw/arm/virt: Remove virt machine state 'smp_cpus'
26
tests/qtest: Reduce npcm7xx_sdhci test image size
31
27
32
Bin Meng (4):
28
Peter Maydell (2):
33
hw/misc: imx6_ccm: Update PMU_MISC0 reset value
29
gdbstub: Don't use GDB syscalls if no GDB is attached
34
hw/msic: imx6_ccm: Correct register value for silicon type
30
semihosting/config: Merge --semihosting-config option groups
35
hw/arm: sabrelite: Connect the Ethernet PHY at address 6
36
docs/system: arm: Add sabrelite board description
37
31
38
Edgar E. Iglesias (1):
32
Richard Henderson (25):
39
intc/arm_gic: Fix gic_irq_signaling_enabled() for vCPUs
33
target/arm: Mark exception helpers as noreturn
34
target/arm: Add coproc parameter to syn_fp_access_trap
35
target/arm: Move exception_target_el out of line
36
target/arm: Move arm_singlestep_active out of line
37
target/arm: Move arm_generate_debug_exceptions out of line
38
target/arm: Use is_a64 in arm_generate_debug_exceptions
39
target/arm: Move exception_bkpt_insn to debug_helper.c
40
target/arm: Move arm_debug_exception_fsr to debug_helper.c
41
target/arm: Rename helper_exception_with_syndrome
42
target/arm: Introduce gen_exception_insn_el_v
43
target/arm: Rename gen_exception_insn to gen_exception_insn_el
44
target/arm: Introduce gen_exception_insn
45
target/arm: Create helper_exception_swstep
46
target/arm: Remove TBFLAG_ANY.DEBUG_TARGET_EL
47
target/arm: Move gen_exception to translate.c
48
target/arm: Rename gen_exception to gen_exception_el
49
target/arm: Introduce gen_exception
50
target/arm: Introduce gen_exception_el_v
51
target/arm: Introduce helper_exception_with_syndrome
52
target/arm: Remove default_exception_el
53
target/arm: Create raise_exception_debug
54
target/arm: Move arm_debug_target_el to debug_helper.c
55
target/arm: Fix Secure PL1 tests in fp_exception_el
56
target/arm: Adjust format test in scr_write
57
target/arm: SCR_EL3.RW is RAO/WI without AArch32 EL[12]
40
58
41
Gan Qixin (7):
59
target/arm/cpu.h | 133 ++---------------------
42
digic-timer: Use ptimer_free() in the finalize function to avoid memleaks
60
target/arm/helper.h | 8 +-
43
allwinner-a10-pit: Use ptimer_free() in the finalize function to avoid memleaks
61
target/arm/internals.h | 43 +-------
44
exynos4210_rtc: Use ptimer_free() in the finalize function to avoid memleaks
62
target/arm/syndrome.h | 7 +-
45
exynos4210_pwm: Use ptimer_free() in the finalize function to avoid memleaks
63
target/arm/translate.h | 43 ++------
46
mss-timer: Use ptimer_free() in the finalize function to avoid memleaks
64
gdbstub.c | 14 ++-
47
musicpal: Use ptimer_free() in the finalize function to avoid memleaks
65
semihosting/config.c | 1 +
48
exynos4210_mct: Use ptimer_free() in the finalize function to avoid memleaks
66
target/arm/debug_helper.c | 220 +++++++++++++++++++++++++++++++++++++--
49
67
target/arm/helper.c | 53 ++++------
50
Peter Maydell (9):
68
target/arm/op_helper.c | 52 +++++----
51
hw/intc/armv7m_nvic: Correct handling of CCR.BFHFNMIGN
69
target/arm/translate-a64.c | 34 +++---
52
target/arm: Correct store of FPSCR value via FPCXT_S
70
target/arm/translate-m-nocp.c | 15 ++-
53
target/arm: Implement FPCXT_NS fp system register
71
target/arm/translate-mve.c | 3 +-
54
target/arm: Implement Cortex-M55 model
72
target/arm/translate-vfp.c | 18 +++-
55
hw/arm/highbank: Drop dead KVM support code
73
target/arm/translate.c | 106 ++++++++++---------
56
util/qemu-timer: Make timer_free() imply timer_del()
74
tests/qtest/npcm7xx_sdhci-test.c | 2 +-
57
scripts/coccinelle: New script to remove unnecessary timer_del() calls
75
16 files changed, 390 insertions(+), 362 deletions(-)
58
Remove superfluous timer_del() calls
59
target/arm: Remove timer_del()/timer_deinit() before timer_free()
60
61
Richard Henderson (1):
62
target/arm: Fix MTE0_ACTIVE
63
64
docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++
65
docs/system/target-arm.rst | 1 +
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
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220609202901.1177572-2-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/helper.h | 6 +++---
9
1 file changed, 3 insertions(+), 3 deletions(-)
10
11
diff --git a/target/arm/helper.h b/target/arm/helper.h
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.h
14
+++ b/target/arm/helper.h
15
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(usad8, TCG_CALL_NO_RWG_SE, i32, i32, i32)
16
17
DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE,
18
i32, i32, i32, i32)
19
-DEF_HELPER_2(exception_internal, void, env, i32)
20
-DEF_HELPER_4(exception_with_syndrome, void, env, i32, i32, i32)
21
-DEF_HELPER_2(exception_bkpt_insn, void, env, i32)
22
+DEF_HELPER_2(exception_internal, noreturn, env, i32)
23
+DEF_HELPER_4(exception_with_syndrome, noreturn, env, i32, i32, i32)
24
+DEF_HELPER_2(exception_bkpt_insn, noreturn, env, i32)
25
DEF_HELPER_2(exception_pc_alignment, noreturn, env, tl)
26
DEF_HELPER_1(setend, void, env)
27
DEF_HELPER_2(wfi, void, env, i32)
28
--
29
2.25.1
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Correct the indexing into s->cpu_ctlr for vCPUs.
3
With ARMv8, this field is always RES0.
4
With ARMv7, targeting EL2 and TA=0, it is always 0xA.
4
5
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
Message-id: 20220609202901.1177572-3-richard.henderson@linaro.org
8
Message-id: 20201214222154.3480243-2-edgar.iglesias@gmail.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
10
---
11
hw/intc/arm_gic.c | 4 +++-
11
target/arm/syndrome.h | 7 ++++---
12
1 file changed, 3 insertions(+), 1 deletion(-)
12
target/arm/translate-a64.c | 3 ++-
13
target/arm/translate-vfp.c | 14 ++++++++++++--
14
3 files changed, 18 insertions(+), 6 deletions(-)
13
15
14
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
16
diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/arm_gic.c
18
--- a/target/arm/syndrome.h
17
+++ b/hw/intc/arm_gic.c
19
+++ b/target/arm/syndrome.h
18
@@ -XXX,XX +XXX,XX @@ static inline void gic_get_best_virq(GICState *s, int cpu,
20
@@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_cp15_rrt_trap(int cv, int cond, int opc1, int crm,
19
static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt,
21
| (rt2 << 10) | (rt << 5) | (crm << 1) | isread;
20
int group_mask)
22
}
23
24
-static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit)
25
+static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit,
26
+ int coproc)
21
{
27
{
22
+ int cpu_iface = virt ? (cpu + GIC_NCPU) : cpu;
28
- /* AArch32 FP trap or any AArch64 FP/SIMD trap: TA == 0 coproc == 0xa */
23
+
29
+ /* AArch32 FP trap or any AArch64 FP/SIMD trap: TA == 0 */
24
if (!virt && !(s->ctlr & group_mask)) {
30
return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT)
31
| (is_16bit ? 0 : ARM_EL_IL)
32
- | (cv << 24) | (cond << 20) | 0xa;
33
+ | (cv << 24) | (cond << 20) | coproc;
34
}
35
36
static inline uint32_t syn_simd_access_trap(int cv, int cond, bool is_16bit)
37
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/target/arm/translate-a64.c
40
+++ b/target/arm/translate-a64.c
41
@@ -XXX,XX +XXX,XX @@ static bool fp_access_check(DisasContext *s)
42
s->fp_access_checked = true;
43
44
gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
45
- syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
46
+ syn_fp_access_trap(1, 0xe, false, 0),
47
+ s->fp_excp_el);
25
return false;
48
return false;
26
}
49
}
27
@@ -XXX,XX +XXX,XX @@ static inline bool gic_irq_signaling_enabled(GICState *s, int cpu, bool virt,
50
s->fp_access_checked = true;
51
diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/target/arm/translate-vfp.c
54
+++ b/target/arm/translate-vfp.c
55
@@ -XXX,XX +XXX,XX @@ static void gen_update_fp_context(DisasContext *s)
56
static bool vfp_access_check_a(DisasContext *s, bool ignore_vfp_enabled)
57
{
58
if (s->fp_excp_el) {
59
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
60
- syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
61
+ /*
62
+ * The full syndrome is only used for HSR when HCPTR traps:
63
+ * For v8, when TA==0, coproc is RES0.
64
+ * For v7, any use of a Floating-point instruction or access
65
+ * to a Floating-point Extension register that is trapped to
66
+ * Hyp mode because of a trap configured in the HCPTR sets
67
+ * this field to 0xA.
68
+ */
69
+ int coproc = arm_dc_feature(s, ARM_FEATURE_V8) ? 0 : 0xa;
70
+ uint32_t syn = syn_fp_access_trap(1, 0xe, false, coproc);
71
+
72
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn, s->fp_excp_el);
28
return false;
73
return false;
29
}
74
}
30
75
31
- if (!(s->cpu_ctlr[cpu] & group_mask)) {
32
+ if (!(s->cpu_ctlr[cpu_iface] & group_mask)) {
33
return false;
34
}
35
36
--
76
--
37
2.20.1
77
2.25.1
38
39
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Move the function to op_helper.c, near raise_exception.
4
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220609202901.1177572-4-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/internals.h | 16 +---------------
11
target/arm/op_helper.c | 15 +++++++++++++++
12
2 files changed, 16 insertions(+), 15 deletions(-)
13
14
diff --git a/target/arm/internals.h b/target/arm/internals.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/internals.h
17
+++ b/target/arm/internals.h
18
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
19
int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx);
20
int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx);
21
22
-static inline int exception_target_el(CPUARMState *env)
23
-{
24
- int target_el = MAX(1, arm_current_el(env));
25
-
26
- /*
27
- * No such thing as secure EL1 if EL3 is aarch32,
28
- * so update the target EL to EL3 in this case.
29
- */
30
- if (arm_is_secure(env) && !arm_el_is_aa64(env, 3) && target_el == 1) {
31
- target_el = 3;
32
- }
33
-
34
- return target_el;
35
-}
36
-
37
/* Determine if allocation tags are available. */
38
static inline bool allocation_tag_access_enabled(CPUARMState *env, int el,
39
uint64_t sctlr)
40
@@ -XXX,XX +XXX,XX @@ void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu);
41
bool el_is_in_host(CPUARMState *env, int el);
42
43
void aa32_max_features(ARMCPU *cpu);
44
+int exception_target_el(CPUARMState *env);
45
46
/* Powers of 2 for sve_vq_map et al. */
47
#define SVE_VQ_POW2_MAP \
48
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/target/arm/op_helper.c
51
+++ b/target/arm/op_helper.c
52
@@ -XXX,XX +XXX,XX @@
53
#define SIGNBIT (uint32_t)0x80000000
54
#define SIGNBIT64 ((uint64_t)1 << 63)
55
56
+int exception_target_el(CPUARMState *env)
57
+{
58
+ int target_el = MAX(1, arm_current_el(env));
59
+
60
+ /*
61
+ * No such thing as secure EL1 if EL3 is aarch32,
62
+ * so update the target EL to EL3 in this case.
63
+ */
64
+ if (arm_is_secure(env) && !arm_el_is_aa64(env, 3) && target_el == 1) {
65
+ target_el = 3;
66
+ }
67
+
68
+ return target_el;
69
+}
70
+
71
void raise_exception(CPUARMState *env, uint32_t excp,
72
uint32_t syndrome, uint32_t target_el)
73
{
74
--
75
2.25.1
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Move the function to debug_helper.c, and the
4
declaration to internals.h.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220609202901.1177572-5-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/cpu.h | 10 ----------
12
target/arm/internals.h | 1 +
13
target/arm/debug_helper.c | 12 ++++++++++++
14
3 files changed, 13 insertions(+), 10 deletions(-)
15
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.h
19
+++ b/target/arm/cpu.h
20
@@ -XXX,XX +XXX,XX @@ static inline bool arm_generate_debug_exceptions(CPUARMState *env)
21
}
22
}
23
24
-/* Is single-stepping active? (Note that the "is EL_D AArch64?" check
25
- * implicitly means this always returns false in pre-v8 CPUs.)
26
- */
27
-static inline bool arm_singlestep_active(CPUARMState *env)
28
-{
29
- return extract32(env->cp15.mdscr_el1, 0, 1)
30
- && arm_el_is_aa64(env, arm_debug_target_el(env))
31
- && arm_generate_debug_exceptions(env);
32
-}
33
-
34
static inline bool arm_sctlr_b(CPUARMState *env)
35
{
36
return
37
diff --git a/target/arm/internals.h b/target/arm/internals.h
38
index XXXXXXX..XXXXXXX 100644
39
--- a/target/arm/internals.h
40
+++ b/target/arm/internals.h
41
@@ -XXX,XX +XXX,XX @@ bool el_is_in_host(CPUARMState *env, int el);
42
43
void aa32_max_features(ARMCPU *cpu);
44
int exception_target_el(CPUARMState *env);
45
+bool arm_singlestep_active(CPUARMState *env);
46
47
/* Powers of 2 for sve_vq_map et al. */
48
#define SVE_VQ_POW2_MAP \
49
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/target/arm/debug_helper.c
52
+++ b/target/arm/debug_helper.c
53
@@ -XXX,XX +XXX,XX @@
54
#include "exec/exec-all.h"
55
#include "exec/helper-proto.h"
56
57
+
58
+/*
59
+ * Is single-stepping active? (Note that the "is EL_D AArch64?" check
60
+ * implicitly means this always returns false in pre-v8 CPUs.)
61
+ */
62
+bool arm_singlestep_active(CPUARMState *env)
63
+{
64
+ return extract32(env->cp15.mdscr_el1, 0, 1)
65
+ && arm_el_is_aa64(env, arm_debug_target_el(env))
66
+ && arm_generate_debug_exceptions(env);
67
+}
68
+
69
/* Return true if the linked breakpoint entry lbn passes its checks */
70
static bool linked_bp_matches(ARMCPU *cpu, int lbn)
71
{
72
--
73
2.25.1
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Move arm_generate_debug_exceptions and its two subroutines,
4
{aa32,aa64}_generate_debug_exceptions into debug_helper.c,
5
and the one interface declaration to internals.h.
6
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20220609202901.1177572-6-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/cpu.h | 91 -------------------------------------
13
target/arm/internals.h | 1 +
14
target/arm/debug_helper.c | 94 +++++++++++++++++++++++++++++++++++++++
15
3 files changed, 95 insertions(+), 91 deletions(-)
16
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
20
+++ b/target/arm/cpu.h
21
@@ -XXX,XX +XXX,XX @@ static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu)
22
return (cpu->clidr & R_V7M_CLIDR_CTYPE_ALL_MASK) != 0;
23
}
24
25
-/* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */
26
-static inline bool aa64_generate_debug_exceptions(CPUARMState *env)
27
-{
28
- int cur_el = arm_current_el(env);
29
- int debug_el;
30
-
31
- if (cur_el == 3) {
32
- return false;
33
- }
34
-
35
- /* MDCR_EL3.SDD disables debug events from Secure state */
36
- if (arm_is_secure_below_el3(env)
37
- && extract32(env->cp15.mdcr_el3, 16, 1)) {
38
- return false;
39
- }
40
-
41
- /*
42
- * Same EL to same EL debug exceptions need MDSCR_KDE enabled
43
- * while not masking the (D)ebug bit in DAIF.
44
- */
45
- debug_el = arm_debug_target_el(env);
46
-
47
- if (cur_el == debug_el) {
48
- return extract32(env->cp15.mdscr_el1, 13, 1)
49
- && !(env->daif & PSTATE_D);
50
- }
51
-
52
- /* Otherwise the debug target needs to be a higher EL */
53
- return debug_el > cur_el;
54
-}
55
-
56
-static inline bool aa32_generate_debug_exceptions(CPUARMState *env)
57
-{
58
- int el = arm_current_el(env);
59
-
60
- if (el == 0 && arm_el_is_aa64(env, 1)) {
61
- return aa64_generate_debug_exceptions(env);
62
- }
63
-
64
- if (arm_is_secure(env)) {
65
- int spd;
66
-
67
- if (el == 0 && (env->cp15.sder & 1)) {
68
- /* SDER.SUIDEN means debug exceptions from Secure EL0
69
- * are always enabled. Otherwise they are controlled by
70
- * SDCR.SPD like those from other Secure ELs.
71
- */
72
- return true;
73
- }
74
-
75
- spd = extract32(env->cp15.mdcr_el3, 14, 2);
76
- switch (spd) {
77
- case 1:
78
- /* SPD == 0b01 is reserved, but behaves as 0b00. */
79
- case 0:
80
- /* For 0b00 we return true if external secure invasive debug
81
- * is enabled. On real hardware this is controlled by external
82
- * signals to the core. QEMU always permits debug, and behaves
83
- * as if DBGEN, SPIDEN, NIDEN and SPNIDEN are all tied high.
84
- */
85
- return true;
86
- case 2:
87
- return false;
88
- case 3:
89
- return true;
90
- }
91
- }
92
-
93
- return el != 2;
94
-}
95
-
96
-/* Return true if debugging exceptions are currently enabled.
97
- * This corresponds to what in ARM ARM pseudocode would be
98
- * if UsingAArch32() then
99
- * return AArch32.GenerateDebugExceptions()
100
- * else
101
- * return AArch64.GenerateDebugExceptions()
102
- * We choose to push the if() down into this function for clarity,
103
- * since the pseudocode has it at all callsites except for the one in
104
- * CheckSoftwareStep(), where it is elided because both branches would
105
- * always return the same value.
106
- */
107
-static inline bool arm_generate_debug_exceptions(CPUARMState *env)
108
-{
109
- if (env->aarch64) {
110
- return aa64_generate_debug_exceptions(env);
111
- } else {
112
- return aa32_generate_debug_exceptions(env);
113
- }
114
-}
115
-
116
static inline bool arm_sctlr_b(CPUARMState *env)
117
{
118
return
119
diff --git a/target/arm/internals.h b/target/arm/internals.h
120
index XXXXXXX..XXXXXXX 100644
121
--- a/target/arm/internals.h
122
+++ b/target/arm/internals.h
123
@@ -XXX,XX +XXX,XX @@ bool el_is_in_host(CPUARMState *env, int el);
124
void aa32_max_features(ARMCPU *cpu);
125
int exception_target_el(CPUARMState *env);
126
bool arm_singlestep_active(CPUARMState *env);
127
+bool arm_generate_debug_exceptions(CPUARMState *env);
128
129
/* Powers of 2 for sve_vq_map et al. */
130
#define SVE_VQ_POW2_MAP \
131
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
132
index XXXXXXX..XXXXXXX 100644
133
--- a/target/arm/debug_helper.c
134
+++ b/target/arm/debug_helper.c
135
@@ -XXX,XX +XXX,XX @@
136
#include "exec/helper-proto.h"
137
138
139
+/* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */
140
+static bool aa64_generate_debug_exceptions(CPUARMState *env)
141
+{
142
+ int cur_el = arm_current_el(env);
143
+ int debug_el;
144
+
145
+ if (cur_el == 3) {
146
+ return false;
147
+ }
148
+
149
+ /* MDCR_EL3.SDD disables debug events from Secure state */
150
+ if (arm_is_secure_below_el3(env)
151
+ && extract32(env->cp15.mdcr_el3, 16, 1)) {
152
+ return false;
153
+ }
154
+
155
+ /*
156
+ * Same EL to same EL debug exceptions need MDSCR_KDE enabled
157
+ * while not masking the (D)ebug bit in DAIF.
158
+ */
159
+ debug_el = arm_debug_target_el(env);
160
+
161
+ if (cur_el == debug_el) {
162
+ return extract32(env->cp15.mdscr_el1, 13, 1)
163
+ && !(env->daif & PSTATE_D);
164
+ }
165
+
166
+ /* Otherwise the debug target needs to be a higher EL */
167
+ return debug_el > cur_el;
168
+}
169
+
170
+static bool aa32_generate_debug_exceptions(CPUARMState *env)
171
+{
172
+ int el = arm_current_el(env);
173
+
174
+ if (el == 0 && arm_el_is_aa64(env, 1)) {
175
+ return aa64_generate_debug_exceptions(env);
176
+ }
177
+
178
+ if (arm_is_secure(env)) {
179
+ int spd;
180
+
181
+ if (el == 0 && (env->cp15.sder & 1)) {
182
+ /*
183
+ * SDER.SUIDEN means debug exceptions from Secure EL0
184
+ * are always enabled. Otherwise they are controlled by
185
+ * SDCR.SPD like those from other Secure ELs.
186
+ */
187
+ return true;
188
+ }
189
+
190
+ spd = extract32(env->cp15.mdcr_el3, 14, 2);
191
+ switch (spd) {
192
+ case 1:
193
+ /* SPD == 0b01 is reserved, but behaves as 0b00. */
194
+ case 0:
195
+ /*
196
+ * For 0b00 we return true if external secure invasive debug
197
+ * is enabled. On real hardware this is controlled by external
198
+ * signals to the core. QEMU always permits debug, and behaves
199
+ * as if DBGEN, SPIDEN, NIDEN and SPNIDEN are all tied high.
200
+ */
201
+ return true;
202
+ case 2:
203
+ return false;
204
+ case 3:
205
+ return true;
206
+ }
207
+ }
208
+
209
+ return el != 2;
210
+}
211
+
212
+/*
213
+ * Return true if debugging exceptions are currently enabled.
214
+ * This corresponds to what in ARM ARM pseudocode would be
215
+ * if UsingAArch32() then
216
+ * return AArch32.GenerateDebugExceptions()
217
+ * else
218
+ * return AArch64.GenerateDebugExceptions()
219
+ * We choose to push the if() down into this function for clarity,
220
+ * since the pseudocode has it at all callsites except for the one in
221
+ * CheckSoftwareStep(), where it is elided because both branches would
222
+ * always return the same value.
223
+ */
224
+bool arm_generate_debug_exceptions(CPUARMState *env)
225
+{
226
+ if (env->aarch64) {
227
+ return aa64_generate_debug_exceptions(env);
228
+ } else {
229
+ return aa32_generate_debug_exceptions(env);
230
+ }
231
+}
232
+
233
/*
234
* Is single-stepping active? (Note that the "is EL_D AArch64?" check
235
* implicitly means this always returns false in pre-v8 CPUs.)
236
--
237
2.25.1
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Currently when U-Boot boots, it prints "??" for i.MX processor:
3
Use the accessor rather than the raw structure member.
4
4
5
CPU: Freescale i.MX?? rev1.0 at 792 MHz
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
The register that was used to determine the silicon type is
7
Message-id: 20220609202901.1177572-7-richard.henderson@linaro.org
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>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
9
---
19
hw/misc/imx6_ccm.c | 2 +-
10
target/arm/debug_helper.c | 2 +-
20
1 file changed, 1 insertion(+), 1 deletion(-)
11
1 file changed, 1 insertion(+), 1 deletion(-)
21
12
22
diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c
13
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
23
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
24
--- a/hw/misc/imx6_ccm.c
15
--- a/target/arm/debug_helper.c
25
+++ b/hw/misc/imx6_ccm.c
16
+++ b/target/arm/debug_helper.c
26
@@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev)
17
@@ -XXX,XX +XXX,XX @@ static bool aa32_generate_debug_exceptions(CPUARMState *env)
27
s->analog[USB_ANALOG_USB2_VBUS_DETECT] = 0x00000004;
18
*/
28
s->analog[USB_ANALOG_USB2_CHRG_DETECT] = 0x00000000;
19
bool arm_generate_debug_exceptions(CPUARMState *env)
29
s->analog[USB_ANALOG_USB2_MISC] = 0x00000002;
20
{
30
- s->analog[USB_ANALOG_DIGPROG] = 0x00000000;
21
- if (env->aarch64) {
31
+ s->analog[USB_ANALOG_DIGPROG] = 0x00630000;
22
+ if (is_a64(env)) {
32
23
return aa64_generate_debug_exceptions(env);
33
/* all PLLs need to be locked */
24
} else {
34
s->analog[CCM_ANALOG_PLL_ARM] |= CCM_ANALOG_PLL_LOCK;
25
return aa32_generate_debug_exceptions(env);
35
--
26
--
36
2.20.1
27
2.25.1
37
38
diff view generated by jsdifflib
New patch
1
From: Richard Henderson <richard.henderson@linaro.org>
1
2
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220609202901.1177572-8-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/debug_helper.c | 31 +++++++++++++++++++++++++++++++
9
target/arm/op_helper.c | 29 -----------------------------
10
2 files changed, 31 insertions(+), 29 deletions(-)
11
12
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/debug_helper.c
15
+++ b/target/arm/debug_helper.c
16
@@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs)
17
}
18
}
19
20
+/*
21
+ * Raise an EXCP_BKPT with the specified syndrome register value,
22
+ * targeting the correct exception level for debug exceptions.
23
+ */
24
+void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome)
25
+{
26
+ int debug_el = arm_debug_target_el(env);
27
+ int cur_el = arm_current_el(env);
28
+
29
+ /* FSR will only be used if the debug target EL is AArch32. */
30
+ env->exception.fsr = arm_debug_exception_fsr(env);
31
+ /*
32
+ * FAR is UNKNOWN: clear vaddress to avoid potentially exposing
33
+ * values to the guest that it shouldn't be able to see at its
34
+ * exception/security level.
35
+ */
36
+ env->exception.vaddress = 0;
37
+ /*
38
+ * Other kinds of architectural debug exception are ignored if
39
+ * they target an exception level below the current one (in QEMU
40
+ * this is checked by arm_generate_debug_exceptions()). Breakpoint
41
+ * instructions are special because they always generate an exception
42
+ * to somewhere: if they can't go to the configured debug exception
43
+ * level they are taken to the current exception level.
44
+ */
45
+ if (debug_el < cur_el) {
46
+ debug_el = cur_el;
47
+ }
48
+ raise_exception(env, EXCP_BKPT, syndrome, debug_el);
49
+}
50
+
51
#if !defined(CONFIG_USER_ONLY)
52
53
vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len)
54
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/target/arm/op_helper.c
57
+++ b/target/arm/op_helper.c
58
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_with_syndrome)(CPUARMState *env, uint32_t excp,
59
raise_exception(env, excp, syndrome, target_el);
60
}
61
62
-/* Raise an EXCP_BKPT with the specified syndrome register value,
63
- * targeting the correct exception level for debug exceptions.
64
- */
65
-void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome)
66
-{
67
- int debug_el = arm_debug_target_el(env);
68
- int cur_el = arm_current_el(env);
69
-
70
- /* FSR will only be used if the debug target EL is AArch32. */
71
- env->exception.fsr = arm_debug_exception_fsr(env);
72
- /* FAR is UNKNOWN: clear vaddress to avoid potentially exposing
73
- * values to the guest that it shouldn't be able to see at its
74
- * exception/security level.
75
- */
76
- env->exception.vaddress = 0;
77
- /*
78
- * Other kinds of architectural debug exception are ignored if
79
- * they target an exception level below the current one (in QEMU
80
- * this is checked by arm_generate_debug_exceptions()). Breakpoint
81
- * instructions are special because they always generate an exception
82
- * to somewhere: if they can't go to the configured debug exception
83
- * level they are taken to the current exception level.
84
- */
85
- if (debug_el < cur_el) {
86
- debug_el = cur_el;
87
- }
88
- raise_exception(env, EXCP_BKPT, syndrome, debug_el);
89
-}
90
-
91
uint32_t HELPER(cpsr_read)(CPUARMState *env)
92
{
93
return cpsr_read(env) & ~CPSR_EXEC;
94
--
95
2.25.1
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
When running device-introspect-test, a memory leak occurred in the
3
This function now now only used in debug_helper.c, so there is
4
exynos4210_mct_init function, so use ptimer_free() in the finalize function to
4
no reason to have a declaration in a header.
5
avoid it.
6
5
7
ASAN shows memory leak stack:
8
9
Indirect leak of 96 byte(s) in 1 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 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>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220609202901.1177572-9-richard.henderson@linaro.org
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
10
---
29
hw/timer/exynos4210_mct.c | 14 ++++++++++++++
11
target/arm/internals.h | 25 -------------------------
30
1 file changed, 14 insertions(+)
12
target/arm/debug_helper.c | 26 ++++++++++++++++++++++++++
13
2 files changed, 26 insertions(+), 25 deletions(-)
31
14
32
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
15
diff --git a/target/arm/internals.h b/target/arm/internals.h
33
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/timer/exynos4210_mct.c
17
--- a/target/arm/internals.h
35
+++ b/hw/timer/exynos4210_mct.c
18
+++ b/target/arm/internals.h
36
@@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_init(Object *obj)
19
@@ -XXX,XX +XXX,XX @@ static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx)
37
sysbus_init_mmio(dev, &s->iomem);
20
return &env->cp15.tcr_el[regime_el(env, mmu_idx)];
38
}
21
}
39
22
40
+static void exynos4210_mct_finalize(Object *obj)
23
-/* Return the FSR value for a debug exception (watchpoint, hardware
24
- * breakpoint or BKPT insn) targeting the specified exception level.
25
- */
26
-static inline uint32_t arm_debug_exception_fsr(CPUARMState *env)
27
-{
28
- ARMMMUFaultInfo fi = { .type = ARMFault_Debug };
29
- int target_el = arm_debug_target_el(env);
30
- bool using_lpae = false;
31
-
32
- if (target_el == 2 || arm_el_is_aa64(env, target_el)) {
33
- using_lpae = true;
34
- } else {
35
- if (arm_feature(env, ARM_FEATURE_LPAE) &&
36
- (env->cp15.tcr_el[target_el].raw_tcr & TTBCR_EAE)) {
37
- using_lpae = true;
38
- }
39
- }
40
-
41
- if (using_lpae) {
42
- return arm_fi_to_lfsc(&fi);
43
- } else {
44
- return arm_fi_to_sfsc(&fi);
45
- }
46
-}
47
-
48
/**
49
* arm_num_brps: Return number of implemented breakpoints.
50
* Note that the ID register BRPS field is "number of bps - 1",
51
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/target/arm/debug_helper.c
54
+++ b/target/arm/debug_helper.c
55
@@ -XXX,XX +XXX,XX @@ bool arm_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp)
56
return check_watchpoints(cpu);
57
}
58
59
+/*
60
+ * Return the FSR value for a debug exception (watchpoint, hardware
61
+ * breakpoint or BKPT insn) targeting the specified exception level.
62
+ */
63
+static uint32_t arm_debug_exception_fsr(CPUARMState *env)
41
+{
64
+{
42
+ int i;
65
+ ARMMMUFaultInfo fi = { .type = ARMFault_Debug };
43
+ Exynos4210MCTState *s = EXYNOS4210_MCT(obj);
66
+ int target_el = arm_debug_target_el(env);
67
+ bool using_lpae = false;
44
+
68
+
45
+ ptimer_free(s->g_timer.ptimer_frc);
69
+ if (target_el == 2 || arm_el_is_aa64(env, target_el)) {
70
+ using_lpae = true;
71
+ } else {
72
+ if (arm_feature(env, ARM_FEATURE_LPAE) &&
73
+ (env->cp15.tcr_el[target_el].raw_tcr & TTBCR_EAE)) {
74
+ using_lpae = true;
75
+ }
76
+ }
46
+
77
+
47
+ for (i = 0; i < 2; i++) {
78
+ if (using_lpae) {
48
+ ptimer_free(s->l_timer[i].tick_timer.ptimer_tick);
79
+ return arm_fi_to_lfsc(&fi);
49
+ ptimer_free(s->l_timer[i].ptimer_frc);
80
+ } else {
81
+ return arm_fi_to_sfsc(&fi);
50
+ }
82
+ }
51
+}
83
+}
52
+
84
+
53
static void exynos4210_mct_class_init(ObjectClass *klass, void *data)
85
void arm_debug_excp_handler(CPUState *cs)
54
{
86
{
55
DeviceClass *dc = DEVICE_CLASS(klass);
87
/*
56
@@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_mct_info = {
57
.parent = TYPE_SYS_BUS_DEVICE,
58
.instance_size = sizeof(Exynos4210MCTState),
59
.instance_init = exynos4210_mct_init,
60
+ .instance_finalize = exynos4210_mct_finalize,
61
.class_init = exynos4210_mct_class_init,
62
};
63
64
--
88
--
65
2.20.1
89
2.25.1
66
67
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
virt machine's 'smp_cpus' and machine->smp.cpus must always have the
3
Rename to helper_exception_with_syndrome_el, to emphasize
4
same value. And, anywhere we have virt machine state we have machine
4
that the target el is a parameter.
5
state. So let's remove the redundancy. Also, to make it easier to see
6
that machine->smp is the true source for "smp_cpus" and "max_cpus",
7
avoid passing them in function parameters, preferring instead to get
8
them from the state.
9
5
10
No functional change intended.
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
Signed-off-by: Andrew Jones <drjones@redhat.com>
8
Message-id: 20220609202901.1177572-10-richard.henderson@linaro.org
13
Reviewed-by: David Edmondson <david.edmondson@oracle.com>
14
Reviewed-by: Ying Fang <fangying1@huawei.com>
15
Message-id: 20201215174815.51520-1-drjones@redhat.com
16
[PMM: minor formatting tweak to smp_cpus variable declaration]
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
10
---
19
include/hw/arm/virt.h | 3 +--
11
target/arm/helper.h | 2 +-
20
hw/arm/virt-acpi-build.c | 9 +++++----
12
target/arm/translate.h | 6 +++---
21
hw/arm/virt.c | 21 ++++++++++-----------
13
target/arm/op_helper.c | 6 +++---
22
3 files changed, 16 insertions(+), 17 deletions(-)
14
target/arm/translate.c | 6 +++---
15
4 files changed, 10 insertions(+), 10 deletions(-)
23
16
24
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
17
diff --git a/target/arm/helper.h b/target/arm/helper.h
25
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/arm/virt.h
19
--- a/target/arm/helper.h
27
+++ b/include/hw/arm/virt.h
20
+++ b/target/arm/helper.h
28
@@ -XXX,XX +XXX,XX @@ struct VirtMachineState {
21
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(usad8, TCG_CALL_NO_RWG_SE, i32, i32, i32)
29
MemMapEntry *memmap;
22
DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE,
30
char *pciehb_nodename;
23
i32, i32, i32, i32)
31
const int *irqmap;
24
DEF_HELPER_2(exception_internal, noreturn, env, i32)
32
- int smp_cpus;
25
-DEF_HELPER_4(exception_with_syndrome, noreturn, env, i32, i32, i32)
33
void *fdt;
26
+DEF_HELPER_4(exception_with_syndrome_el, noreturn, env, i32, i32, i32)
34
int fdt_size;
27
DEF_HELPER_2(exception_bkpt_insn, noreturn, env, i32)
35
uint32_t clock_phandle;
28
DEF_HELPER_2(exception_pc_alignment, noreturn, env, tl)
36
@@ -XXX,XX +XXX,XX @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)
29
DEF_HELPER_1(setend, void, env)
37
30
diff --git a/target/arm/translate.h b/target/arm/translate.h
38
assert(vms->gic_version == VIRT_GIC_VERSION_3);
31
index XXXXXXX..XXXXXXX 100644
39
32
--- a/target/arm/translate.h
40
- return vms->smp_cpus > redist0_capacity ? 2 : 1;
33
+++ b/target/arm/translate.h
41
+ return MACHINE(vms)->smp.cpus > redist0_capacity ? 2 : 1;
34
@@ -XXX,XX +XXX,XX @@ static inline void gen_ss_advance(DisasContext *s)
35
static inline void gen_exception(int excp, uint32_t syndrome,
36
uint32_t target_el)
37
{
38
- gen_helper_exception_with_syndrome(cpu_env, tcg_constant_i32(excp),
39
- tcg_constant_i32(syndrome),
40
- tcg_constant_i32(target_el));
41
+ gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp),
42
+ tcg_constant_i32(syndrome),
43
+ tcg_constant_i32(target_el));
42
}
44
}
43
45
44
#endif /* QEMU_ARM_VIRT_H */
46
/* Generate an architectural singlestep exception */
45
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
47
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
46
index XXXXXXX..XXXXXXX 100644
48
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/arm/virt-acpi-build.c
49
--- a/target/arm/op_helper.c
48
+++ b/hw/arm/virt-acpi-build.c
50
+++ b/target/arm/op_helper.c
49
@@ -XXX,XX +XXX,XX @@
51
@@ -XXX,XX +XXX,XX @@ void HELPER(yield)(CPUARMState *env)
50
52
* those EXCP values which are special cases for QEMU to interrupt
51
#define ACPI_BUILD_TABLE_SIZE 0x20000
53
* execution and not to be used for exceptions which are passed to
52
54
* the guest (those must all have syndrome information and thus should
53
-static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus)
55
- * use exception_with_syndrome).
54
+static void acpi_dsdt_add_cpus(Aml *scope, VirtMachineState *vms)
56
+ * use exception_with_syndrome*).
57
*/
58
void HELPER(exception_internal)(CPUARMState *env, uint32_t excp)
55
{
59
{
56
+ MachineState *ms = MACHINE(vms);
60
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_internal)(CPUARMState *env, uint32_t excp)
57
uint16_t i;
61
}
58
62
59
- for (i = 0; i < smp_cpus; i++) {
63
/* Raise an exception with the specified syndrome register value */
60
+ for (i = 0; i < ms->smp.cpus; i++) {
64
-void HELPER(exception_with_syndrome)(CPUARMState *env, uint32_t excp,
61
Aml *dev = aml_device("C%.03X", i);
65
- uint32_t syndrome, uint32_t target_el)
62
aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007")));
66
+void HELPER(exception_with_syndrome_el)(CPUARMState *env, uint32_t excp,
63
aml_append(dev, aml_name_decl("_UID", aml_int(i)));
67
+ uint32_t syndrome, uint32_t target_el)
64
@@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
68
{
65
gicd->base_address = cpu_to_le64(memmap[VIRT_GIC_DIST].base);
69
raise_exception(env, excp, syndrome, target_el);
66
gicd->version = vms->gic_version;
70
}
67
71
diff --git a/target/arm/translate.c b/target/arm/translate.c
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));
73
@@ -XXX,XX +XXX,XX @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
74
* the RTC ACPI device at all when using UEFI.
75
*/
76
scope = aml_scope("\\_SB");
77
- acpi_dsdt_add_cpus(scope, vms->smp_cpus);
78
+ acpi_dsdt_add_cpus(scope, vms);
79
acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
80
(irqmap[VIRT_UART] + ARM_SPI_BASE));
81
if (vmc->acpi_expose_flash) {
82
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
83
index XXXXXXX..XXXXXXX 100644
72
index XXXXXXX..XXXXXXX 100644
84
--- a/hw/arm/virt.c
73
--- a/target/arm/translate.c
85
+++ b/hw/arm/virt.c
74
+++ b/target/arm/translate.c
86
@@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms)
75
@@ -XXX,XX +XXX,XX @@ static void gen_exception_el(DisasContext *s, int excp, uint32_t syn,
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
}
93
94
qemu_fdt_add_subnode(vms->fdt, "/timer");
95
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
96
int cpu;
97
int addr_cells = 1;
98
const MachineState *ms = MACHINE(vms);
99
+ int smp_cpus = ms->smp.cpus;
100
101
/*
102
* From Documentation/devicetree/bindings/arm/cpus.txt
103
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
104
* The simplest way to go is to examine affinity IDs of all our CPUs. If
105
* at least one of them has Aff3 populated, we set #address-cells to 2.
106
*/
107
- for (cpu = 0; cpu < vms->smp_cpus; cpu++) {
108
+ for (cpu = 0; cpu < smp_cpus; cpu++) {
109
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
110
111
if (armcpu->mp_affinity & ARM_AFF3_MASK) {
112
@@ -XXX,XX +XXX,XX @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)
113
qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#address-cells", addr_cells);
114
qemu_fdt_setprop_cell(vms->fdt, "/cpus", "#size-cells", 0x0);
115
116
- for (cpu = vms->smp_cpus - 1; cpu >= 0; cpu--) {
117
+ for (cpu = smp_cpus - 1; cpu >= 0; cpu--) {
118
char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu);
119
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
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
}
131
@@ -XXX,XX +XXX,XX @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms)
132
if (vms->gic_version == VIRT_GIC_VERSION_2) {
133
irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,
134
GIC_FDT_IRQ_PPI_CPU_WIDTH,
135
- (1 << vms->smp_cpus) - 1);
136
+ (1 << MACHINE(vms)->smp.cpus) - 1);
137
}
138
139
qemu_fdt_add_subnode(vms->fdt, "/pmu");
140
@@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms)
141
* virt_cpu_post_init() must be called after the CPUs have
142
* been realized and the GIC has been created.
143
*/
144
-static void virt_cpu_post_init(VirtMachineState *vms, int max_cpus,
145
- MemoryRegion *sysmem)
146
+static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)
147
{
76
{
148
+ int max_cpus = MACHINE(vms)->smp.max_cpus;
77
gen_set_condexec(s);
149
bool aarch64, pmu, steal_time;
78
gen_set_pc_im(s, s->pc_curr);
150
CPUState *cpu;
79
- gen_helper_exception_with_syndrome(cpu_env,
151
80
- tcg_constant_i32(excp),
152
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
81
- tcg_constant_i32(syn), tcg_el);
153
exit(1);
82
+ gen_helper_exception_with_syndrome_el(cpu_env,
154
}
83
+ tcg_constant_i32(excp),
155
84
+ tcg_constant_i32(syn), tcg_el);
156
- vms->smp_cpus = smp_cpus;
85
s->base.is_jmp = DISAS_NORETURN;
157
-
86
}
158
if (vms->virt && kvm_enabled()) {
159
error_report("mach-virt: KVM does not support providing "
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
87
178
--
88
--
179
2.20.1
89
2.25.1
180
181
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
When running device-introspect-test, a memory leak occurred in the
3
Create a function below gen_exception_insn that takes
4
mv88w8618_pit_init function, so use ptimer_free() in the finalize function to
4
the target_el as a TCGv_i32, replacing gen_exception_el.
5
avoid it.
6
5
7
ASAN shows memory leak stack:
8
9
Indirect leak of 192 byte(s) in 4 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 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>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220609202901.1177572-11-richard.henderson@linaro.org
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
10
---
29
hw/arm/musicpal.c | 12 ++++++++++++
11
target/arm/translate.c | 27 ++++++++++++---------------
30
1 file changed, 12 insertions(+)
12
1 file changed, 12 insertions(+), 15 deletions(-)
31
13
32
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
14
diff --git a/target/arm/translate.c b/target/arm/translate.c
33
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/musicpal.c
16
--- a/target/arm/translate.c
35
+++ b/hw/arm/musicpal.c
17
+++ b/target/arm/translate.c
36
@@ -XXX,XX +XXX,XX @@ static void mv88w8618_pit_init(Object *obj)
18
@@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, uint32_t pc, int excp)
37
sysbus_init_mmio(dev, &s->iomem);
19
s->base.is_jmp = DISAS_NORETURN;
38
}
20
}
39
21
40
+static void mv88w8618_pit_finalize(Object *obj)
22
-void gen_exception_insn(DisasContext *s, uint64_t pc, int excp,
23
- uint32_t syn, uint32_t target_el)
24
+static void gen_exception_insn_el_v(DisasContext *s, uint64_t pc, int excp,
25
+ uint32_t syn, TCGv_i32 tcg_el)
26
{
27
if (s->aarch64) {
28
gen_a64_set_pc_im(pc);
29
@@ -XXX,XX +XXX,XX @@ void gen_exception_insn(DisasContext *s, uint64_t pc, int excp,
30
gen_set_condexec(s);
31
gen_set_pc_im(s, pc);
32
}
33
- gen_exception(excp, syn, target_el);
34
+ gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp),
35
+ tcg_constant_i32(syn), tcg_el);
36
s->base.is_jmp = DISAS_NORETURN;
37
}
38
39
+void gen_exception_insn(DisasContext *s, uint64_t pc, int excp,
40
+ uint32_t syn, uint32_t target_el)
41
+{
41
+{
42
+ SysBusDevice *dev = SYS_BUS_DEVICE(obj);
42
+ gen_exception_insn_el_v(s, pc, excp, syn, tcg_constant_i32(target_el));
43
+ mv88w8618_pit_state *s = MV88W8618_PIT(dev);
44
+ int i;
45
+
46
+ for (i = 0; i < 4; i++) {
47
+ ptimer_free(s->timer[i].ptimer);
48
+ }
49
+}
43
+}
50
+
44
+
51
static const VMStateDescription mv88w8618_timer_vmsd = {
45
static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn)
52
.name = "timer",
46
{
53
.version_id = 1,
47
gen_set_condexec(s);
54
@@ -XXX,XX +XXX,XX @@ static const TypeInfo mv88w8618_pit_info = {
48
@@ -XXX,XX +XXX,XX @@ void unallocated_encoding(DisasContext *s)
55
.parent = TYPE_SYS_BUS_DEVICE,
49
default_exception_el(s));
56
.instance_size = sizeof(mv88w8618_pit_state),
50
}
57
.instance_init = mv88w8618_pit_init,
51
58
+ .instance_finalize = mv88w8618_pit_finalize,
52
-static void gen_exception_el(DisasContext *s, int excp, uint32_t syn,
59
.class_init = mv88w8618_pit_class_init,
53
- TCGv_i32 tcg_el)
60
};
54
-{
61
55
- gen_set_condexec(s);
56
- gen_set_pc_im(s, s->pc_curr);
57
- gen_helper_exception_with_syndrome_el(cpu_env,
58
- tcg_constant_i32(excp),
59
- tcg_constant_i32(syn), tcg_el);
60
- s->base.is_jmp = DISAS_NORETURN;
61
-}
62
-
63
/* Force a TB lookup after an instruction that changes the CPU state. */
64
void gen_lookup_tb(DisasContext *s)
65
{
66
@@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn,
67
tcg_el = tcg_constant_i32(3);
68
}
69
70
- gen_exception_el(s, EXCP_UDEF, syn_uncategorized(), tcg_el);
71
+ gen_exception_insn_el_v(s, s->pc_curr, EXCP_UDEF,
72
+ syn_uncategorized(), tcg_el);
73
tcg_temp_free_i32(tcg_el);
74
return false;
75
}
62
--
76
--
63
2.20.1
77
2.25.1
64
65
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This adds the target guide for SABRE Lite board, and documents how
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
to boot a Linux kernel and U-Boot bootloader.
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
5
Message-id: 20220609202901.1177572-12-richard.henderson@linaro.org
6
Signed-off-by: Bin Meng <bin.meng@windriver.com>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Message-id: 20210106063504.10841-5-bmeng.cn@gmail.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
7
---
11
docs/system/arm/sabrelite.rst | 119 ++++++++++++++++++++++++++++++++++
8
target/arm/translate.h | 4 ++--
12
docs/system/target-arm.rst | 1 +
9
target/arm/translate-a64.c | 36 ++++++++++++++++----------------
13
2 files changed, 120 insertions(+)
10
target/arm/translate-m-nocp.c | 16 +++++++-------
14
create mode 100644 docs/system/arm/sabrelite.rst
11
target/arm/translate-mve.c | 4 ++--
12
target/arm/translate-vfp.c | 6 +++---
13
target/arm/translate.c | 39 ++++++++++++++++++-----------------
14
6 files changed, 53 insertions(+), 52 deletions(-)
15
15
16
diff --git a/docs/system/arm/sabrelite.rst b/docs/system/arm/sabrelite.rst
16
diff --git a/target/arm/translate.h b/target/arm/translate.h
17
new file mode 100644
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX
18
--- a/target/arm/translate.h
19
--- /dev/null
19
+++ b/target/arm/translate.h
20
+++ b/docs/system/arm/sabrelite.rst
20
@@ -XXX,XX +XXX,XX @@ void arm_jump_cc(DisasCompare *cmp, TCGLabel *label);
21
@@ -XXX,XX +XXX,XX @@
21
void arm_gen_test_cc(int cc, TCGLabel *label);
22
+Boundary Devices SABRE Lite (``sabrelite``)
22
MemOp pow2_align(unsigned i);
23
+===========================================
23
void unallocated_encoding(DisasContext *s);
24
+
24
-void gen_exception_insn(DisasContext *s, uint64_t pc, int excp,
25
+Boundary Devices SABRE Lite i.MX6 Development Board is a low-cost development
25
- uint32_t syn, uint32_t target_el);
26
+platform featuring the powerful Freescale / NXP Semiconductor's i.MX 6 Quad
26
+void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp,
27
+Applications Processor.
27
+ uint32_t syn, uint32_t target_el);
28
+
28
29
+Supported devices
29
/* Return state of Alternate Half-precision flag, caller frees result */
30
+-----------------
30
static inline TCGv_i32 get_ahp_flag(void)
31
+
31
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
32
+The SABRE Lite machine supports the following devices:
32
index XXXXXXX..XXXXXXX 100644
33
+
33
--- a/target/arm/translate-a64.c
34
+ * Up to 4 Cortex A9 cores
34
+++ b/target/arm/translate-a64.c
35
+ * Generic Interrupt Controller
35
@@ -XXX,XX +XXX,XX @@ static bool fp_access_check(DisasContext *s)
36
+ * 1 Clock Controller Module
36
assert(!s->fp_access_checked);
37
+ * 1 System Reset Controller
37
s->fp_access_checked = true;
38
+ * 5 UARTs
38
39
+ * 2 EPIC timers
39
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
40
+ * 1 GPT timer
40
- syn_fp_access_trap(1, 0xe, false, 0),
41
+ * 2 Watchdog timers
41
- s->fp_excp_el);
42
+ * 1 FEC Ethernet controller
42
+ gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
43
+ * 3 I2C controllers
43
+ syn_fp_access_trap(1, 0xe, false, 0),
44
+ * 7 GPIO controllers
44
+ s->fp_excp_el);
45
+ * 4 SDHC storage controllers
45
return false;
46
+ * 4 USB 2.0 host controllers
46
}
47
+ * 5 ECSPI controllers
47
s->fp_access_checked = true;
48
+ * 1 SST 25VF016B flash
48
@@ -XXX,XX +XXX,XX @@ bool sve_access_check(DisasContext *s)
49
+
49
assert(!s->sve_access_checked);
50
+Please note above list is a complete superset the QEMU SABRE Lite machine can
50
s->sve_access_checked = true;
51
+support. For a normal use case, a device tree blob that represents a real world
51
52
+SABRE Lite board, only exposes a subset of devices to the guest software.
52
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
53
+
53
- syn_sve_access_trap(), s->sve_excp_el);
54
+Boot options
54
+ gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
55
+------------
55
+ syn_sve_access_trap(), s->sve_excp_el);
56
+
56
return false;
57
+The SABRE Lite machine can start using the standard -kernel functionality
57
}
58
+for loading a Linux kernel, U-Boot bootloader or ELF executable.
58
s->sve_access_checked = true;
59
+
59
@@ -XXX,XX +XXX,XX @@ static void gen_sysreg_undef(DisasContext *s, bool isread,
60
+Running Linux kernel
60
} else {
61
+--------------------
61
syndrome = syn_uncategorized();
62
+
62
}
63
+Linux mainline v5.10 release is tested at the time of writing. To build a Linux
63
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syndrome,
64
+mainline kernel that can be booted by the SABRE Lite machine, simply configure
64
- default_exception_el(s));
65
+the kernel using the imx_v6_v7_defconfig configuration:
65
+ gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, syndrome,
66
+
66
+ default_exception_el(s));
67
+.. code-block:: bash
67
}
68
+
68
69
+ $ export ARCH=arm
69
/* MRS - move from system register
70
+ $ export CROSS_COMPILE=arm-linux-gnueabihf-
70
@@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn)
71
+ $ make imx_v6_v7_defconfig
71
switch (op2_ll) {
72
+ $ make
72
case 1: /* SVC */
73
+
73
gen_ss_advance(s);
74
+To boot the newly built Linux kernel in QEMU with the SABRE Lite machine, use:
74
- gen_exception_insn(s, s->base.pc_next, EXCP_SWI,
75
+
75
- syn_aa64_svc(imm16), default_exception_el(s));
76
+.. code-block:: bash
76
+ gen_exception_insn_el(s, s->base.pc_next, EXCP_SWI,
77
+
77
+ syn_aa64_svc(imm16), default_exception_el(s));
78
+ $ qemu-system-arm -M sabrelite -smp 4 -m 1G \
78
break;
79
+ -display none -serial null -serial stdio \
79
case 2: /* HVC */
80
+ -kernel arch/arm/boot/zImage \
80
if (s->current_el == 0) {
81
+ -dtb arch/arm/boot/dts/imx6q-sabrelite.dtb \
81
@@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn)
82
+ -initrd /path/to/rootfs.ext4 \
82
gen_a64_set_pc_im(s->pc_curr);
83
+ -append "root=/dev/ram"
83
gen_helper_pre_hvc(cpu_env);
84
+
84
gen_ss_advance(s);
85
+Running U-Boot
85
- gen_exception_insn(s, s->base.pc_next, EXCP_HVC,
86
+--------------
86
- syn_aa64_hvc(imm16), 2);
87
+
87
+ gen_exception_insn_el(s, s->base.pc_next, EXCP_HVC,
88
+U-Boot mainline v2020.10 release is tested at the time of writing. To build a
88
+ syn_aa64_hvc(imm16), 2);
89
+U-Boot mainline bootloader that can be booted by the SABRE Lite machine, use
89
break;
90
+the mx6qsabrelite_defconfig with similar commands as described above for Linux:
90
case 3: /* SMC */
91
+
91
if (s->current_el == 0) {
92
+.. code-block:: bash
92
@@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn)
93
+
93
gen_a64_set_pc_im(s->pc_curr);
94
+ $ export CROSS_COMPILE=arm-linux-gnueabihf-
94
gen_helper_pre_smc(cpu_env, tcg_constant_i32(syn_aa64_smc(imm16)));
95
+ $ make mx6qsabrelite_defconfig
95
gen_ss_advance(s);
96
+
96
- gen_exception_insn(s, s->base.pc_next, EXCP_SMC,
97
+Note we need to adjust settings by:
97
- syn_aa64_smc(imm16), 3);
98
+
98
+ gen_exception_insn_el(s, s->base.pc_next, EXCP_SMC,
99
+.. code-block:: bash
99
+ syn_aa64_smc(imm16), 3);
100
+
100
break;
101
+ $ make menuconfig
101
default:
102
+
102
unallocated_encoding(s);
103
+then manually select the following configuration in U-Boot:
103
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
104
+
104
* Illegal execution state. This has priority over BTI
105
+ Device Tree Control > Provider of DTB for DT Control > Embedded DTB
105
* exceptions, but comes after instruction abort exceptions.
106
+
106
*/
107
+To start U-Boot using the SABRE Lite machine, provide the u-boot binary to
107
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
108
+the -kernel argument, along with an SD card image with rootfs:
108
- syn_illegalstate(), default_exception_el(s));
109
+
109
+ gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
110
+.. code-block:: bash
110
+ syn_illegalstate(), default_exception_el(s));
111
+
111
return;
112
+ $ qemu-system-arm -M sabrelite -smp 4 -m 1G \
112
}
113
+ -display none -serial null -serial stdio \
113
114
+ -kernel u-boot
114
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
115
+
115
if (s->btype != 0
116
+The following example shows booting Linux kernel from dhcp, and uses the
116
&& s->guarded_page
117
+rootfs on an SD card. This requires some additional command line parameters
117
&& !btype_destination_ok(insn, s->bt, s->btype)) {
118
+for QEMU:
118
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
119
+
119
- syn_btitrap(s->btype),
120
+.. code-block:: none
120
- default_exception_el(s));
121
+
121
+ gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
122
+ -nic user,tftp=/path/to/kernel/zImage \
122
+ syn_btitrap(s->btype),
123
+ -drive file=sdcard.img,id=rootfs -device sd-card,drive=rootfs
123
+ default_exception_el(s));
124
+
124
return;
125
+The directory for the built-in TFTP server should also contain the device tree
125
}
126
+blob of the SABRE Lite board. The sample SD card image was populated with the
126
} else {
127
+root file system with one single partition. You may adjust the kernel "root="
127
diff --git a/target/arm/translate-m-nocp.c b/target/arm/translate-m-nocp.c
128
+boot parameter accordingly.
128
index XXXXXXX..XXXXXXX 100644
129
+
129
--- a/target/arm/translate-m-nocp.c
130
+After U-Boot boots, type the following commands in the U-Boot command shell to
130
+++ b/target/arm/translate-m-nocp.c
131
+boot the Linux kernel:
131
@@ -XXX,XX +XXX,XX @@ static bool trans_VSCCLRM(DisasContext *s, arg_VSCCLRM *a)
132
+
132
tcg_gen_brcondi_i32(TCG_COND_EQ, sfpa, 0, s->condlabel);
133
+.. code-block:: none
133
134
+
134
if (s->fp_excp_el != 0) {
135
+ => setenv ethaddr 00:11:22:33:44:55
135
- gen_exception_insn(s, s->pc_curr, EXCP_NOCP,
136
+ => setenv bootfile zImage
136
- syn_uncategorized(), s->fp_excp_el);
137
+ => dhcp
137
+ gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP,
138
+ => tftpboot 14000000 imx6q-sabrelite.dtb
138
+ syn_uncategorized(), s->fp_excp_el);
139
+ => setenv bootargs root=/dev/mmcblk3p1
139
return true;
140
+ => bootz 12000000 - 14000000
140
}
141
diff --git a/docs/system/target-arm.rst b/docs/system/target-arm.rst
141
142
index XXXXXXX..XXXXXXX 100644
142
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
143
--- a/docs/system/target-arm.rst
143
if (!vfp_access_check_m(s, true)) {
144
+++ b/docs/system/target-arm.rst
144
/*
145
@@ -XXX,XX +XXX,XX @@ undocumented; you can get a complete list by running
145
* This was only a conditional exception, so override
146
arm/versatile
146
- * gen_exception_insn()'s default to DISAS_NORETURN
147
arm/vexpress
147
+ * gen_exception_insn_el()'s default to DISAS_NORETURN
148
arm/aspeed
148
*/
149
+ arm/sabrelite
149
s->base.is_jmp = DISAS_NEXT;
150
arm/digic
150
break;
151
arm/musicpal
151
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno,
152
arm/gumstix
152
if (!vfp_access_check_m(s, true)) {
153
/*
154
* This was only a conditional exception, so override
155
- * gen_exception_insn()'s default to DISAS_NORETURN
156
+ * gen_exception_insn_el()'s default to DISAS_NORETURN
157
*/
158
s->base.is_jmp = DISAS_NEXT;
159
break;
160
@@ -XXX,XX +XXX,XX @@ static bool trans_NOCP(DisasContext *s, arg_nocp *a)
161
}
162
163
if (a->cp != 10) {
164
- gen_exception_insn(s, s->pc_curr, EXCP_NOCP,
165
- syn_uncategorized(), default_exception_el(s));
166
+ gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP,
167
+ syn_uncategorized(), default_exception_el(s));
168
return true;
169
}
170
171
if (s->fp_excp_el != 0) {
172
- gen_exception_insn(s, s->pc_curr, EXCP_NOCP,
173
- syn_uncategorized(), s->fp_excp_el);
174
+ gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP,
175
+ syn_uncategorized(), s->fp_excp_el);
176
return true;
177
}
178
179
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
180
index XXXXXXX..XXXXXXX 100644
181
--- a/target/arm/translate-mve.c
182
+++ b/target/arm/translate-mve.c
183
@@ -XXX,XX +XXX,XX @@ bool mve_eci_check(DisasContext *s)
184
return true;
185
default:
186
/* Reserved value: INVSTATE UsageFault */
187
- gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
188
- default_exception_el(s));
189
+ gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
190
+ default_exception_el(s));
191
return false;
192
}
193
}
194
diff --git a/target/arm/translate-vfp.c b/target/arm/translate-vfp.c
195
index XXXXXXX..XXXXXXX 100644
196
--- a/target/arm/translate-vfp.c
197
+++ b/target/arm/translate-vfp.c
198
@@ -XXX,XX +XXX,XX @@ static bool vfp_access_check_a(DisasContext *s, bool ignore_vfp_enabled)
199
int coproc = arm_dc_feature(s, ARM_FEATURE_V8) ? 0 : 0xa;
200
uint32_t syn = syn_fp_access_trap(1, 0xe, false, coproc);
201
202
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn, s->fp_excp_el);
203
+ gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, syn, s->fp_excp_el);
204
return false;
205
}
206
207
@@ -XXX,XX +XXX,XX @@ bool vfp_access_check_m(DisasContext *s, bool skip_context_update)
208
* the encoding space handled by the patterns in m-nocp.decode,
209
* and for them we may need to raise NOCP here.
210
*/
211
- gen_exception_insn(s, s->pc_curr, EXCP_NOCP,
212
- syn_uncategorized(), s->fp_excp_el);
213
+ gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP,
214
+ syn_uncategorized(), s->fp_excp_el);
215
return false;
216
}
217
218
diff --git a/target/arm/translate.c b/target/arm/translate.c
219
index XXXXXXX..XXXXXXX 100644
220
--- a/target/arm/translate.c
221
+++ b/target/arm/translate.c
222
@@ -XXX,XX +XXX,XX @@ static void gen_exception_insn_el_v(DisasContext *s, uint64_t pc, int excp,
223
s->base.is_jmp = DISAS_NORETURN;
224
}
225
226
-void gen_exception_insn(DisasContext *s, uint64_t pc, int excp,
227
- uint32_t syn, uint32_t target_el)
228
+void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp,
229
+ uint32_t syn, uint32_t target_el)
230
{
231
gen_exception_insn_el_v(s, pc, excp, syn, tcg_constant_i32(target_el));
232
}
233
@@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn)
234
void unallocated_encoding(DisasContext *s)
235
{
236
/* Unallocated and reserved encodings are uncategorized */
237
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(),
238
- default_exception_el(s));
239
+ gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(),
240
+ default_exception_el(s));
241
}
242
243
/* Force a TB lookup after an instruction that changes the CPU state. */
244
@@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn,
245
246
undef:
247
/* If we get here then some access check did not pass */
248
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
249
- syn_uncategorized(), exc_target);
250
+ gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
251
+ syn_uncategorized(), exc_target);
252
return false;
253
}
254
255
@@ -XXX,XX +XXX,XX @@ static void gen_srs(DisasContext *s,
256
* For the UNPREDICTABLE cases we choose to UNDEF.
257
*/
258
if (s->current_el == 1 && !s->ns && mode == ARM_CPU_MODE_MON) {
259
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), 3);
260
+ gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
261
+ syn_uncategorized(), 3);
262
return;
263
}
264
265
@@ -XXX,XX +XXX,XX @@ static bool trans_WLS(DisasContext *s, arg_WLS *a)
266
* Do the check-and-raise-exception by hand.
267
*/
268
if (s->fp_excp_el) {
269
- gen_exception_insn(s, s->pc_curr, EXCP_NOCP,
270
- syn_uncategorized(), s->fp_excp_el);
271
+ gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP,
272
+ syn_uncategorized(), s->fp_excp_el);
273
return true;
274
}
275
}
276
@@ -XXX,XX +XXX,XX @@ static bool trans_LE(DisasContext *s, arg_LE *a)
277
tmp = load_cpu_field(v7m.ltpsize);
278
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 4, skipexc);
279
tcg_temp_free_i32(tmp);
280
- gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
281
- default_exception_el(s));
282
+ gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
283
+ default_exception_el(s));
284
gen_set_label(skipexc);
285
}
286
287
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
288
* UsageFault exception.
289
*/
290
if (arm_dc_feature(s, ARM_FEATURE_M)) {
291
- gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
292
- default_exception_el(s));
293
+ gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
294
+ default_exception_el(s));
295
return;
296
}
297
298
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
299
* Illegal execution state. This has priority over BTI
300
* exceptions, but comes after instruction abort exceptions.
301
*/
302
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
303
- syn_illegalstate(), default_exception_el(s));
304
+ gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
305
+ syn_illegalstate(), default_exception_el(s));
306
return;
307
}
308
309
@@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
310
* Illegal execution state. This has priority over BTI
311
* exceptions, but comes after instruction abort exceptions.
312
*/
313
- gen_exception_insn(dc, dc->pc_curr, EXCP_UDEF,
314
- syn_illegalstate(), default_exception_el(dc));
315
+ gen_exception_insn_el(dc, dc->pc_curr, EXCP_UDEF,
316
+ syn_illegalstate(), default_exception_el(dc));
317
return;
318
}
319
320
@@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
321
*/
322
tcg_remove_ops_after(dc->insn_eci_rewind);
323
dc->condjmp = 0;
324
- gen_exception_insn(dc, dc->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
325
- default_exception_el(dc));
326
+ gen_exception_insn_el(dc, dc->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
327
+ default_exception_el(dc));
328
}
329
330
arm_post_translate_insn(dc);
153
--
331
--
154
2.20.1
332
2.25.1
155
156
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
At present, when booting U-Boot on QEMU sabrelite, we see:
3
Create a new wrapper function that passes the default
4
exception target to gen_exception_insn_el.
4
5
5
Net: Board Net Initialization Failed
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
No ethernet found.
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
8
Message-id: 20220609202901.1177572-13-richard.henderson@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>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
30
---
10
---
31
hw/arm/sabrelite.c | 4 ++++
11
target/arm/translate.h | 1 +
32
1 file changed, 4 insertions(+)
12
target/arm/translate-a64.c | 15 ++++++---------
13
target/arm/translate-m-nocp.c | 3 +--
14
target/arm/translate-mve.c | 3 +--
15
target/arm/translate.c | 29 +++++++++++++----------------
16
5 files changed, 22 insertions(+), 29 deletions(-)
33
17
34
diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c
18
diff --git a/target/arm/translate.h b/target/arm/translate.h
35
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
36
--- a/hw/arm/sabrelite.c
20
--- a/target/arm/translate.h
37
+++ b/hw/arm/sabrelite.c
21
+++ b/target/arm/translate.h
38
@@ -XXX,XX +XXX,XX @@ static void sabrelite_init(MachineState *machine)
22
@@ -XXX,XX +XXX,XX @@ MemOp pow2_align(unsigned i);
39
23
void unallocated_encoding(DisasContext *s);
40
s = FSL_IMX6(object_new(TYPE_FSL_IMX6));
24
void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp,
41
object_property_add_child(OBJECT(machine), "soc", OBJECT(s));
25
uint32_t syn, uint32_t target_el);
26
+void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, uint32_t syn);
27
28
/* Return state of Alternate Half-precision flag, caller frees result */
29
static inline TCGv_i32 get_ahp_flag(void)
30
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/translate-a64.c
33
+++ b/target/arm/translate-a64.c
34
@@ -XXX,XX +XXX,XX @@ static void gen_sysreg_undef(DisasContext *s, bool isread,
35
} else {
36
syndrome = syn_uncategorized();
37
}
38
- gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, syndrome,
39
- default_exception_el(s));
40
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syndrome);
41
}
42
43
/* MRS - move from system register
44
@@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn)
45
switch (op2_ll) {
46
case 1: /* SVC */
47
gen_ss_advance(s);
48
- gen_exception_insn_el(s, s->base.pc_next, EXCP_SWI,
49
- syn_aa64_svc(imm16), default_exception_el(s));
50
+ gen_exception_insn(s, s->base.pc_next, EXCP_SWI,
51
+ syn_aa64_svc(imm16));
52
break;
53
case 2: /* HVC */
54
if (s->current_el == 0) {
55
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
56
* Illegal execution state. This has priority over BTI
57
* exceptions, but comes after instruction abort exceptions.
58
*/
59
- gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
60
- syn_illegalstate(), default_exception_el(s));
61
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_illegalstate());
62
return;
63
}
64
65
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
66
if (s->btype != 0
67
&& s->guarded_page
68
&& !btype_destination_ok(insn, s->bt, s->btype)) {
69
- gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
70
- syn_btitrap(s->btype),
71
- default_exception_el(s));
72
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
73
+ syn_btitrap(s->btype));
74
return;
75
}
76
} else {
77
diff --git a/target/arm/translate-m-nocp.c b/target/arm/translate-m-nocp.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/target/arm/translate-m-nocp.c
80
+++ b/target/arm/translate-m-nocp.c
81
@@ -XXX,XX +XXX,XX @@ static bool trans_NOCP(DisasContext *s, arg_nocp *a)
82
}
83
84
if (a->cp != 10) {
85
- gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP,
86
- syn_uncategorized(), default_exception_el(s));
87
+ gen_exception_insn(s, s->pc_curr, EXCP_NOCP, syn_uncategorized());
88
return true;
89
}
90
91
diff --git a/target/arm/translate-mve.c b/target/arm/translate-mve.c
92
index XXXXXXX..XXXXXXX 100644
93
--- a/target/arm/translate-mve.c
94
+++ b/target/arm/translate-mve.c
95
@@ -XXX,XX +XXX,XX @@ bool mve_eci_check(DisasContext *s)
96
return true;
97
default:
98
/* Reserved value: INVSTATE UsageFault */
99
- gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
100
- default_exception_el(s));
101
+ gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized());
102
return false;
103
}
104
}
105
diff --git a/target/arm/translate.c b/target/arm/translate.c
106
index XXXXXXX..XXXXXXX 100644
107
--- a/target/arm/translate.c
108
+++ b/target/arm/translate.c
109
@@ -XXX,XX +XXX,XX @@ void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp,
110
gen_exception_insn_el_v(s, pc, excp, syn, tcg_constant_i32(target_el));
111
}
112
113
+void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, uint32_t syn)
114
+{
115
+ gen_exception_insn_el(s, pc, excp, syn, default_exception_el(s));
116
+}
42
+
117
+
43
+ /* Ethernet PHY address is 6 */
118
static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn)
44
+ object_property_set_int(OBJECT(s), "fec-phy-num", 6, &error_fatal);
119
{
45
+
120
gen_set_condexec(s);
46
qdev_realize(DEVICE(s), NULL, &error_fatal);
121
@@ -XXX,XX +XXX,XX @@ static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn)
47
122
void unallocated_encoding(DisasContext *s)
48
memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR,
123
{
124
/* Unallocated and reserved encodings are uncategorized */
125
- gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(),
126
- default_exception_el(s));
127
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized());
128
}
129
130
/* Force a TB lookup after an instruction that changes the CPU state. */
131
@@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn,
132
* an exception and return false. Otherwise it will return true,
133
* and set *tgtmode and *regno appropriately.
134
*/
135
- int exc_target = default_exception_el(s);
136
-
137
/* These instructions are present only in ARMv8, or in ARMv7 with the
138
* Virtualization Extensions.
139
*/
140
@@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn,
141
142
undef:
143
/* If we get here then some access check did not pass */
144
- gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
145
- syn_uncategorized(), exc_target);
146
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized());
147
return false;
148
}
149
150
@@ -XXX,XX +XXX,XX @@ static bool trans_LE(DisasContext *s, arg_LE *a)
151
tmp = load_cpu_field(v7m.ltpsize);
152
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 4, skipexc);
153
tcg_temp_free_i32(tmp);
154
- gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
155
- default_exception_el(s));
156
+ gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized());
157
gen_set_label(skipexc);
158
}
159
160
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
161
* UsageFault exception.
162
*/
163
if (arm_dc_feature(s, ARM_FEATURE_M)) {
164
- gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
165
- default_exception_el(s));
166
+ gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized());
167
return;
168
}
169
170
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
171
* Illegal execution state. This has priority over BTI
172
* exceptions, but comes after instruction abort exceptions.
173
*/
174
- gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
175
- syn_illegalstate(), default_exception_el(s));
176
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_illegalstate());
177
return;
178
}
179
180
@@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
181
* Illegal execution state. This has priority over BTI
182
* exceptions, but comes after instruction abort exceptions.
183
*/
184
- gen_exception_insn_el(dc, dc->pc_curr, EXCP_UDEF,
185
- syn_illegalstate(), default_exception_el(dc));
186
+ gen_exception_insn(dc, dc->pc_curr, EXCP_UDEF, syn_illegalstate());
187
return;
188
}
189
190
@@ -XXX,XX +XXX,XX @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
191
*/
192
tcg_remove_ops_after(dc->insn_eci_rewind);
193
dc->condjmp = 0;
194
- gen_exception_insn_el(dc, dc->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
195
- default_exception_el(dc));
196
+ gen_exception_insn(dc, dc->pc_curr, EXCP_INVSTATE,
197
+ syn_uncategorized());
198
}
199
200
arm_post_translate_insn(dc);
49
--
201
--
50
2.20.1
202
2.25.1
51
52
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
When running device-introspect-test, a memory leak occurred in the
3
Move the computation from gen_swstep_exception into a helper.
4
mss_timer_init function, so use ptimer_free() in the finalize function to avoid
5
it.
6
4
7
ASAN shows memory leak stack:
5
This fixes a bug when:
6
- MDSCR_EL1.KDE == 1 to enable debug exceptions within EL_D itself
7
- we singlestep an ERET from EL_D to some lower EL
8
8
9
Indirect leak of 192 byte(s) in 2 object(s) allocated from:
9
Previously we were computing 'same el' based on the EL which
10
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
10
executed the ERET instruction, whereas it ought to be computed
11
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
11
based on the EL to which ERET returned. This happens naturally
12
#2 0xaaabf555db78 in ptimer_init /qemu/hw/core/ptimer.c:432
12
with the new helper, which runs after EL has been changed.
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
13
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>
14
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
16
Message-id: 20220609202901.1177572-14-richard.henderson@linaro.org
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
18
---
29
hw/timer/mss-timer.c | 13 +++++++++++++
19
target/arm/helper.h | 1 +
30
1 file changed, 13 insertions(+)
20
target/arm/translate.h | 12 +++---------
21
target/arm/debug_helper.c | 16 ++++++++++++++++
22
3 files changed, 20 insertions(+), 9 deletions(-)
31
23
32
diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c
24
diff --git a/target/arm/helper.h b/target/arm/helper.h
33
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/timer/mss-timer.c
26
--- a/target/arm/helper.h
35
+++ b/hw/timer/mss-timer.c
27
+++ b/target/arm/helper.h
36
@@ -XXX,XX +XXX,XX @@ static void mss_timer_init(Object *obj)
28
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE,
37
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &t->mmio);
29
DEF_HELPER_2(exception_internal, noreturn, env, i32)
30
DEF_HELPER_4(exception_with_syndrome_el, noreturn, env, i32, i32, i32)
31
DEF_HELPER_2(exception_bkpt_insn, noreturn, env, i32)
32
+DEF_HELPER_2(exception_swstep, noreturn, env, i32)
33
DEF_HELPER_2(exception_pc_alignment, noreturn, env, tl)
34
DEF_HELPER_1(setend, void, env)
35
DEF_HELPER_2(wfi, void, env, i32)
36
diff --git a/target/arm/translate.h b/target/arm/translate.h
37
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/translate.h
39
+++ b/target/arm/translate.h
40
@@ -XXX,XX +XXX,XX @@ static inline void gen_exception(int excp, uint32_t syndrome,
41
/* Generate an architectural singlestep exception */
42
static inline void gen_swstep_exception(DisasContext *s, int isv, int ex)
43
{
44
- bool same_el = (s->debug_target_el == s->current_el);
45
-
46
- /*
47
- * If singlestep is targeting a lower EL than the current one,
48
- * then s->ss_active must be false and we can never get here.
49
- */
50
- assert(s->debug_target_el >= s->current_el);
51
-
52
- gen_exception(EXCP_UDEF, syn_swstep(same_el, isv, ex), s->debug_target_el);
53
+ /* Fill in the same_el field of the syndrome in the helper. */
54
+ uint32_t syn = syn_swstep(false, isv, ex);
55
+ gen_helper_exception_swstep(cpu_env, tcg_constant_i32(syn));
38
}
56
}
39
57
40
+static void mss_timer_finalize(Object *obj)
58
/*
59
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
60
index XXXXXXX..XXXXXXX 100644
61
--- a/target/arm/debug_helper.c
62
+++ b/target/arm/debug_helper.c
63
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome)
64
raise_exception(env, EXCP_BKPT, syndrome, debug_el);
65
}
66
67
+void HELPER(exception_swstep)(CPUARMState *env, uint32_t syndrome)
41
+{
68
+{
42
+ MSSTimerState *t = MSS_TIMER(obj);
69
+ int debug_el = arm_debug_target_el(env);
43
+ int i;
70
+ int cur_el = arm_current_el(env);
44
+
71
+
45
+ for (i = 0; i < NUM_TIMERS; i++) {
72
+ /*
46
+ struct Msf2Timer *st = &t->timers[i];
73
+ * If singlestep is targeting a lower EL than the current one, then
47
+
74
+ * DisasContext.ss_active must be false and we can never get here.
48
+ ptimer_free(st->ptimer);
75
+ */
76
+ assert(debug_el >= cur_el);
77
+ if (debug_el == cur_el) {
78
+ syndrome |= 1 << ARM_EL_EC_SHIFT;
49
+ }
79
+ }
80
+ raise_exception(env, EXCP_UDEF, syndrome, debug_el);
50
+}
81
+}
51
+
82
+
52
static const VMStateDescription vmstate_timers = {
83
#if !defined(CONFIG_USER_ONLY)
53
.name = "mss-timer-block",
84
54
.version_id = 1,
85
vaddr arm_adjust_watchpoint_address(CPUState *cs, vaddr addr, int len)
55
@@ -XXX,XX +XXX,XX @@ static const TypeInfo mss_timer_info = {
56
.parent = TYPE_SYS_BUS_DEVICE,
57
.instance_size = sizeof(MSSTimerState),
58
.instance_init = mss_timer_init,
59
+ .instance_finalize = mss_timer_finalize,
60
.class_init = mss_timer_class_init,
61
};
62
63
--
86
--
64
2.20.1
87
2.25.1
65
66
diff view generated by jsdifflib
1
Now that timer_free() implicitly calls timer_del(), sequences
1
From: Richard Henderson <richard.henderson@linaro.org>
2
timer_del(mytimer);
3
timer_free(mytimer);
4
2
5
can be simplified to just
3
We no longer need this value during translation,
6
timer_free(mytimer);
4
as it is now handled within the helpers.
7
5
8
Add a Coccinelle script to do this transformation.
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220609202901.1177572-15-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/cpu.h | 6 ++----
12
target/arm/translate.h | 2 --
13
target/arm/helper.c | 12 ++----------
14
target/arm/translate-a64.c | 1 -
15
target/arm/translate.c | 1 -
16
5 files changed, 4 insertions(+), 18 deletions(-)
9
17
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
11
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
19
index XXXXXXX..XXXXXXX 100644
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
20
--- a/target/arm/cpu.h
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
+++ b/target/arm/cpu.h
14
Message-id: 20201215154107.3255-3-peter.maydell@linaro.org
22
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 3, 1)
15
---
23
FIELD(TBFLAG_ANY, MMUIDX, 4, 4)
16
scripts/coccinelle/timer-del-timer-free.cocci | 18 ++++++++++++++++++
24
/* Target EL if we take a floating-point-disabled exception */
17
1 file changed, 18 insertions(+)
25
FIELD(TBFLAG_ANY, FPEXC_EL, 8, 2)
18
create mode 100644 scripts/coccinelle/timer-del-timer-free.cocci
26
-/* For A-profile only, target EL for debug exceptions. */
19
27
-FIELD(TBFLAG_ANY, DEBUG_TARGET_EL, 10, 2)
20
diff --git a/scripts/coccinelle/timer-del-timer-free.cocci b/scripts/coccinelle/timer-del-timer-free.cocci
28
/* Memory operations require alignment: SCTLR_ELx.A or CCR.UNALIGN_TRP */
21
new file mode 100644
29
-FIELD(TBFLAG_ANY, ALIGN_MEM, 12, 1)
22
index XXXXXXX..XXXXXXX
30
-FIELD(TBFLAG_ANY, PSTATE__IL, 13, 1)
23
--- /dev/null
31
+FIELD(TBFLAG_ANY, ALIGN_MEM, 10, 1)
24
+++ b/scripts/coccinelle/timer-del-timer-free.cocci
32
+FIELD(TBFLAG_ANY, PSTATE__IL, 11, 1)
25
@@ -XXX,XX +XXX,XX @@
33
26
+// Remove superfluous timer_del() calls
34
/*
27
+//
35
* Bit usage when in AArch32 state, both A- and M-profile.
28
+// Copyright Linaro Limited 2020
36
diff --git a/target/arm/translate.h b/target/arm/translate.h
29
+// This work is licensed under the terms of the GNU GPLv2 or later.
37
index XXXXXXX..XXXXXXX 100644
30
+//
38
--- a/target/arm/translate.h
31
+// spatch --macro-file scripts/cocci-macro-file.h \
39
+++ b/target/arm/translate.h
32
+// --sp-file scripts/coccinelle/timer-del-timer-free.cocci \
40
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
33
+// --in-place --dir .
41
*/
34
+//
42
uint32_t svc_imm;
35
+// The timer_free() function now implicitly calls timer_del()
43
int current_el;
36
+// for you, so calls to timer_del() immediately before the
44
- /* Debug target exception level for single-step exceptions */
37
+// timer_free() of the same timer can be deleted.
45
- int debug_target_el;
38
+
46
GHashTable *cp_regs;
39
+@@
47
uint64_t features; /* CPU features bits */
40
+expression T;
48
bool aarch64;
41
+@@
49
diff --git a/target/arm/helper.c b/target/arm/helper.c
42
+-timer_del(T);
50
index XXXXXXX..XXXXXXX 100644
43
+ timer_free(T);
51
--- a/target/arm/helper.c
52
+++ b/target/arm/helper.c
53
@@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_m32(CPUARMState *env, int fp_el,
54
return rebuild_hflags_common_32(env, fp_el, mmu_idx, flags);
55
}
56
57
-static CPUARMTBFlags rebuild_hflags_aprofile(CPUARMState *env)
58
-{
59
- CPUARMTBFlags flags = {};
60
-
61
- DP_TBFLAG_ANY(flags, DEBUG_TARGET_EL, arm_debug_target_el(env));
62
- return flags;
63
-}
64
-
65
static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el,
66
ARMMMUIdx mmu_idx)
67
{
68
- CPUARMTBFlags flags = rebuild_hflags_aprofile(env);
69
+ CPUARMTBFlags flags = {};
70
int el = arm_current_el(env);
71
72
if (arm_sctlr(env, el) & SCTLR_A) {
73
@@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el,
74
static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
75
ARMMMUIdx mmu_idx)
76
{
77
- CPUARMTBFlags flags = rebuild_hflags_aprofile(env);
78
+ CPUARMTBFlags flags = {};
79
ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx);
80
uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr;
81
uint64_t sctlr;
82
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
83
index XXXXXXX..XXXXXXX 100644
84
--- a/target/arm/translate-a64.c
85
+++ b/target/arm/translate-a64.c
86
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase,
87
dc->ss_active = EX_TBFLAG_ANY(tb_flags, SS_ACTIVE);
88
dc->pstate_ss = EX_TBFLAG_ANY(tb_flags, PSTATE__SS);
89
dc->is_ldex = false;
90
- dc->debug_target_el = EX_TBFLAG_ANY(tb_flags, DEBUG_TARGET_EL);
91
92
/* Bound the number of insns to execute to those left on the page. */
93
bound = -(dc->base.pc_first | TARGET_PAGE_MASK) / 4;
94
diff --git a/target/arm/translate.c b/target/arm/translate.c
95
index XXXXXXX..XXXXXXX 100644
96
--- a/target/arm/translate.c
97
+++ b/target/arm/translate.c
98
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
99
dc->v7m_lspact = EX_TBFLAG_M32(tb_flags, LSPACT);
100
dc->mve_no_pred = EX_TBFLAG_M32(tb_flags, MVE_NO_PRED);
101
} else {
102
- dc->debug_target_el = EX_TBFLAG_ANY(tb_flags, DEBUG_TARGET_EL);
103
dc->sctlr_b = EX_TBFLAG_A32(tb_flags, SCTLR__B);
104
dc->hstr_active = EX_TBFLAG_A32(tb_flags, HSTR_ACTIVE);
105
dc->ns = EX_TBFLAG_A32(tb_flags, NS);
44
--
106
--
45
2.20.1
107
2.25.1
46
47
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
When running device-introspect-test, a memory leak occurred in the a10_pit_init
3
This function is not required by any other translation file.
4
function, so use ptimer_free() in the finalize function to avoid it.
5
4
6
ASAN shows memory leak stack:
7
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>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220609202901.1177572-16-richard.henderson@linaro.org
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
---
9
---
28
hw/timer/allwinner-a10-pit.c | 11 +++++++++++
10
target/arm/translate.h | 8 --------
29
1 file changed, 11 insertions(+)
11
target/arm/translate.c | 7 +++++++
12
2 files changed, 7 insertions(+), 8 deletions(-)
30
13
31
diff --git a/hw/timer/allwinner-a10-pit.c b/hw/timer/allwinner-a10-pit.c
14
diff --git a/target/arm/translate.h b/target/arm/translate.h
32
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
33
--- a/hw/timer/allwinner-a10-pit.c
16
--- a/target/arm/translate.h
34
+++ b/hw/timer/allwinner-a10-pit.c
17
+++ b/target/arm/translate.h
35
@@ -XXX,XX +XXX,XX @@ static void a10_pit_init(Object *obj)
18
@@ -XXX,XX +XXX,XX @@ static inline void gen_ss_advance(DisasContext *s)
36
}
19
}
37
}
20
}
38
21
39
+static void a10_pit_finalize(Object *obj)
22
-static inline void gen_exception(int excp, uint32_t syndrome,
23
- uint32_t target_el)
24
-{
25
- gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp),
26
- tcg_constant_i32(syndrome),
27
- tcg_constant_i32(target_el));
28
-}
29
-
30
/* Generate an architectural singlestep exception */
31
static inline void gen_swstep_exception(DisasContext *s, int isv, int ex)
32
{
33
diff --git a/target/arm/translate.c b/target/arm/translate.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/translate.c
36
+++ b/target/arm/translate.c
37
@@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, uint32_t pc, int excp)
38
s->base.is_jmp = DISAS_NORETURN;
39
}
40
41
+static void gen_exception(int excp, uint32_t syndrome, uint32_t target_el)
40
+{
42
+{
41
+ AwA10PITState *s = AW_A10_PIT(obj);
43
+ gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp),
42
+ int i;
44
+ tcg_constant_i32(syndrome),
43
+
45
+ tcg_constant_i32(target_el));
44
+ for (i = 0; i < AW_A10_PIT_TIMER_NR; i++) {
45
+ ptimer_free(s->timer[i]);
46
+ }
47
+}
46
+}
48
+
47
+
49
static void a10_pit_class_init(ObjectClass *klass, void *data)
48
static void gen_exception_insn_el_v(DisasContext *s, uint64_t pc, int excp,
49
uint32_t syn, TCGv_i32 tcg_el)
50
{
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
--
51
--
61
2.20.1
52
2.25.1
62
63
diff view generated by jsdifflib
1
The Arm CPU finalize function uses a sequence of timer_del(), timer_deinit(),
1
From: Richard Henderson <richard.henderson@linaro.org>
2
timer_free() to free the timer. The timer_deinit() step in this was always
3
unnecessary, and now the timer_del() is implied by timer_free(), so we can
4
collapse this down to simply calling timer_free().
5
2
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20220609202901.1177572-17-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
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>
9
Message-id: 20201215154107.3255-5-peter.maydell@linaro.org
10
---
7
---
11
target/arm/cpu.c | 2 --
8
target/arm/translate.c | 18 +++++++++---------
12
1 file changed, 2 deletions(-)
9
1 file changed, 9 insertions(+), 9 deletions(-)
13
10
14
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
11
diff --git a/target/arm/translate.c b/target/arm/translate.c
15
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu.c
13
--- a/target/arm/translate.c
17
+++ b/target/arm/cpu.c
14
+++ b/target/arm/translate.c
18
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_finalizefn(Object *obj)
15
@@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, uint32_t pc, int excp)
16
s->base.is_jmp = DISAS_NORETURN;
17
}
18
19
-static void gen_exception(int excp, uint32_t syndrome, uint32_t target_el)
20
+static void gen_exception_el(int excp, uint32_t syndrome, uint32_t target_el)
21
{
22
gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp),
23
tcg_constant_i32(syndrome),
24
@@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
25
switch (dc->base.is_jmp) {
26
case DISAS_SWI:
27
gen_ss_advance(dc);
28
- gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb),
29
- default_exception_el(dc));
30
+ gen_exception_el(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb),
31
+ default_exception_el(dc));
32
break;
33
case DISAS_HVC:
34
gen_ss_advance(dc);
35
- gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2);
36
+ gen_exception_el(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2);
37
break;
38
case DISAS_SMC:
39
gen_ss_advance(dc);
40
- gen_exception(EXCP_SMC, syn_aa32_smc(), 3);
41
+ gen_exception_el(EXCP_SMC, syn_aa32_smc(), 3);
42
break;
43
case DISAS_NEXT:
44
case DISAS_TOO_MANY:
45
@@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
46
gen_helper_yield(cpu_env);
47
break;
48
case DISAS_SWI:
49
- gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb),
50
- default_exception_el(dc));
51
+ gen_exception_el(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb),
52
+ default_exception_el(dc));
53
break;
54
case DISAS_HVC:
55
- gen_exception(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2);
56
+ gen_exception_el(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2);
57
break;
58
case DISAS_SMC:
59
- gen_exception(EXCP_SMC, syn_aa32_smc(), 3);
60
+ gen_exception_el(EXCP_SMC, syn_aa32_smc(), 3);
61
break;
62
}
19
}
63
}
20
#ifndef CONFIG_USER_ONLY
21
if (cpu->pmu_timer) {
22
- timer_del(cpu->pmu_timer);
23
- timer_deinit(cpu->pmu_timer);
24
timer_free(cpu->pmu_timer);
25
}
26
#endif
27
--
64
--
28
2.20.1
65
2.25.1
29
30
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
When running device-introspect-test, a memory leak occurred in the
3
Create a new wrapper function that passes the default
4
exynos4210_pwm_init function, so use ptimer_free() in the finalize function to
4
exception target to gen_exception_el.
5
avoid it.
6
5
7
ASAN shows memory leak stack:
8
9
Indirect leak of 240 byte(s) in 5 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 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>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220609202901.1177572-18-richard.henderson@linaro.org
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
10
---
29
hw/timer/exynos4210_pwm.c | 11 +++++++++++
11
target/arm/translate.c | 11 +++++++----
30
1 file changed, 11 insertions(+)
12
1 file changed, 7 insertions(+), 4 deletions(-)
31
13
32
diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c
14
diff --git a/target/arm/translate.c b/target/arm/translate.c
33
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/timer/exynos4210_pwm.c
16
--- a/target/arm/translate.c
35
+++ b/hw/timer/exynos4210_pwm.c
17
+++ b/target/arm/translate.c
36
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_init(Object *obj)
18
@@ -XXX,XX +XXX,XX @@ static void gen_exception_el(int excp, uint32_t syndrome, uint32_t target_el)
37
sysbus_init_mmio(dev, &s->iomem);
19
tcg_constant_i32(target_el));
38
}
20
}
39
21
40
+static void exynos4210_pwm_finalize(Object *obj)
22
+static void gen_exception(DisasContext *s, int excp, uint32_t syndrome)
41
+{
23
+{
42
+ Exynos4210PWMState *s = EXYNOS4210_PWM(obj);
24
+ gen_exception_el(excp, syndrome, default_exception_el(s));
43
+ int i;
44
+
45
+ for (i = 0; i < EXYNOS4210_PWM_TIMERS_NUM; i++) {
46
+ ptimer_free(s->timer[i].ptimer);
47
+ }
48
+}
25
+}
49
+
26
+
50
static void exynos4210_pwm_class_init(ObjectClass *klass, void *data)
27
static void gen_exception_insn_el_v(DisasContext *s, uint64_t pc, int excp,
28
uint32_t syn, TCGv_i32 tcg_el)
51
{
29
{
52
DeviceClass *dc = DEVICE_CLASS(klass);
30
@@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
53
@@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_pwm_info = {
31
switch (dc->base.is_jmp) {
54
.parent = TYPE_SYS_BUS_DEVICE,
32
case DISAS_SWI:
55
.instance_size = sizeof(Exynos4210PWMState),
33
gen_ss_advance(dc);
56
.instance_init = exynos4210_pwm_init,
34
- gen_exception_el(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb),
57
+ .instance_finalize = exynos4210_pwm_finalize,
35
- default_exception_el(dc));
58
.class_init = exynos4210_pwm_class_init,
36
+ gen_exception(dc, EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb));
59
};
37
break;
60
38
case DISAS_HVC:
39
gen_ss_advance(dc);
40
@@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
41
gen_helper_yield(cpu_env);
42
break;
43
case DISAS_SWI:
44
- gen_exception_el(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb),
45
- default_exception_el(dc));
46
+ gen_exception(dc, EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb));
47
break;
48
case DISAS_HVC:
49
gen_exception_el(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2);
61
--
50
--
62
2.20.1
51
2.25.1
63
64
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
When running device-introspect-test, a memory leak occurred in the
3
Split out a common helper function for gen_exception_el
4
exynos4210_rtc_init function, so use ptimer_free() in the finalize function to
4
and gen_exception_insn_el_v.
5
avoid it.
6
5
7
ASAN shows memory leak stack:
8
9
Indirect leak of 96 byte(s) in 1 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 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>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220609202901.1177572-19-richard.henderson@linaro.org
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
10
---
29
hw/rtc/exynos4210_rtc.c | 9 +++++++++
11
target/arm/translate.c | 13 ++++++++-----
30
1 file changed, 9 insertions(+)
12
1 file changed, 8 insertions(+), 5 deletions(-)
31
13
32
diff --git a/hw/rtc/exynos4210_rtc.c b/hw/rtc/exynos4210_rtc.c
14
diff --git a/target/arm/translate.c b/target/arm/translate.c
33
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/rtc/exynos4210_rtc.c
16
--- a/target/arm/translate.c
35
+++ b/hw/rtc/exynos4210_rtc.c
17
+++ b/target/arm/translate.c
36
@@ -XXX,XX +XXX,XX @@ static void exynos4210_rtc_init(Object *obj)
18
@@ -XXX,XX +XXX,XX @@ static void gen_exception_internal_insn(DisasContext *s, uint32_t pc, int excp)
37
sysbus_init_mmio(dev, &s->iomem);
19
s->base.is_jmp = DISAS_NORETURN;
38
}
20
}
39
21
40
+static void exynos4210_rtc_finalize(Object *obj)
22
-static void gen_exception_el(int excp, uint32_t syndrome, uint32_t target_el)
41
+{
23
+static void gen_exception_el_v(int excp, uint32_t syndrome, TCGv_i32 tcg_el)
42
+ Exynos4210RTCState *s = EXYNOS4210_RTC(obj);
24
{
43
+
25
gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp),
44
+ ptimer_free(s->ptimer);
26
- tcg_constant_i32(syndrome),
45
+ ptimer_free(s->ptimer_1Hz);
27
- tcg_constant_i32(target_el));
28
+ tcg_constant_i32(syndrome), tcg_el);
46
+}
29
+}
47
+
30
+
48
static void exynos4210_rtc_class_init(ObjectClass *klass, void *data)
31
+static void gen_exception_el(int excp, uint32_t syndrome, uint32_t target_el)
49
{
32
+{
50
DeviceClass *dc = DEVICE_CLASS(klass);
33
+ gen_exception_el_v(excp, syndrome, tcg_constant_i32(target_el));
51
@@ -XXX,XX +XXX,XX @@ static const TypeInfo exynos4210_rtc_info = {
34
}
52
.parent = TYPE_SYS_BUS_DEVICE,
35
53
.instance_size = sizeof(Exynos4210RTCState),
36
static void gen_exception(DisasContext *s, int excp, uint32_t syndrome)
54
.instance_init = exynos4210_rtc_init,
37
@@ -XXX,XX +XXX,XX @@ static void gen_exception_insn_el_v(DisasContext *s, uint64_t pc, int excp,
55
+ .instance_finalize = exynos4210_rtc_finalize,
38
gen_set_condexec(s);
56
.class_init = exynos4210_rtc_class_init,
39
gen_set_pc_im(s, pc);
57
};
40
}
41
- gen_helper_exception_with_syndrome_el(cpu_env, tcg_constant_i32(excp),
42
- tcg_constant_i32(syn), tcg_el);
43
+ gen_exception_el_v(excp, syn, tcg_el);
44
s->base.is_jmp = DISAS_NORETURN;
45
}
58
46
59
--
47
--
60
2.20.1
48
2.25.1
61
62
diff view generated by jsdifflib
1
Now that we have implemented all the features needed by the v8.1M
1
From: Richard Henderson <richard.henderson@linaro.org>
2
architecture, we can add the model of the Cortex-M55. This is the
3
configuration without MVE support; we'll add MVE later.
4
2
3
With the helper we can use exception_target_el at runtime,
4
instead of default_exception_el at translate time.
5
While we're at it, remove the DisasContext parameter from
6
gen_exception, as it is no longer used.
7
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20220609202901.1177572-20-richard.henderson@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20201210201433.26262-5-peter.maydell@linaro.org
8
---
12
---
9
target/arm/cpu_tcg.c | 42 ++++++++++++++++++++++++++++++++++++++++++
13
target/arm/helper.h | 1 +
10
1 file changed, 42 insertions(+)
14
target/arm/op_helper.c | 10 ++++++++++
15
target/arm/translate.c | 18 +++++++++++++-----
16
3 files changed, 24 insertions(+), 5 deletions(-)
11
17
12
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
18
diff --git a/target/arm/helper.h b/target/arm/helper.h
13
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu_tcg.c
20
--- a/target/arm/helper.h
15
+++ b/target/arm/cpu_tcg.c
21
+++ b/target/arm/helper.h
16
@@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj)
22
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_2(usad8, TCG_CALL_NO_RWG_SE, i32, i32, i32)
17
cpu->ctr = 0x8000c000;
23
DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE,
24
i32, i32, i32, i32)
25
DEF_HELPER_2(exception_internal, noreturn, env, i32)
26
+DEF_HELPER_3(exception_with_syndrome, noreturn, env, i32, i32)
27
DEF_HELPER_4(exception_with_syndrome_el, noreturn, env, i32, i32, i32)
28
DEF_HELPER_2(exception_bkpt_insn, noreturn, env, i32)
29
DEF_HELPER_2(exception_swstep, noreturn, env, i32)
30
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/op_helper.c
33
+++ b/target/arm/op_helper.c
34
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_with_syndrome_el)(CPUARMState *env, uint32_t excp,
35
raise_exception(env, excp, syndrome, target_el);
18
}
36
}
19
37
20
+static void cortex_m55_initfn(Object *obj)
38
+/*
39
+ * Raise an exception with the specified syndrome register value
40
+ * to the default target el.
41
+ */
42
+void HELPER(exception_with_syndrome)(CPUARMState *env, uint32_t excp,
43
+ uint32_t syndrome)
21
+{
44
+{
22
+ ARMCPU *cpu = ARM_CPU(obj);
45
+ raise_exception(env, excp, syndrome, exception_target_el(env));
23
+
24
+ set_feature(&cpu->env, ARM_FEATURE_V8);
25
+ set_feature(&cpu->env, ARM_FEATURE_V8_1M);
26
+ set_feature(&cpu->env, ARM_FEATURE_M);
27
+ set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
28
+ set_feature(&cpu->env, ARM_FEATURE_M_SECURITY);
29
+ set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
30
+ cpu->midr = 0x410fd221; /* r0p1 */
31
+ cpu->revidr = 0;
32
+ cpu->pmsav7_dregion = 16;
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
+}
46
+}
59
+
47
+
60
static const ARMCPRegInfo cortexr5_cp_reginfo[] = {
48
uint32_t HELPER(cpsr_read)(CPUARMState *env)
61
/* Dummy the TCM region regs for the moment */
49
{
62
{ .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0,
50
return cpsr_read(env) & ~CPSR_EXEC;
63
@@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = {
51
diff --git a/target/arm/translate.c b/target/arm/translate.c
64
.class_init = arm_v7m_class_init },
52
index XXXXXXX..XXXXXXX 100644
65
{ .name = "cortex-m33", .initfn = cortex_m33_initfn,
53
--- a/target/arm/translate.c
66
.class_init = arm_v7m_class_init },
54
+++ b/target/arm/translate.c
67
+ { .name = "cortex-m55", .initfn = cortex_m55_initfn,
55
@@ -XXX,XX +XXX,XX @@ static void gen_exception_el(int excp, uint32_t syndrome, uint32_t target_el)
68
+ .class_init = arm_v7m_class_init },
56
gen_exception_el_v(excp, syndrome, tcg_constant_i32(target_el));
69
{ .name = "cortex-r5", .initfn = cortex_r5_initfn },
57
}
70
{ .name = "cortex-r5f", .initfn = cortex_r5f_initfn },
58
71
{ .name = "ti925t", .initfn = ti925t_initfn },
59
-static void gen_exception(DisasContext *s, int excp, uint32_t syndrome)
60
+static void gen_exception(int excp, uint32_t syndrome)
61
{
62
- gen_exception_el(excp, syndrome, default_exception_el(s));
63
+ gen_helper_exception_with_syndrome(cpu_env, tcg_constant_i32(excp),
64
+ tcg_constant_i32(syndrome));
65
}
66
67
static void gen_exception_insn_el_v(DisasContext *s, uint64_t pc, int excp,
68
@@ -XXX,XX +XXX,XX @@ void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp,
69
70
void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, uint32_t syn)
71
{
72
- gen_exception_insn_el(s, pc, excp, syn, default_exception_el(s));
73
+ if (s->aarch64) {
74
+ gen_a64_set_pc_im(pc);
75
+ } else {
76
+ gen_set_condexec(s);
77
+ gen_set_pc_im(s, pc);
78
+ }
79
+ gen_exception(excp, syn);
80
+ s->base.is_jmp = DISAS_NORETURN;
81
}
82
83
static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn)
84
@@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
85
switch (dc->base.is_jmp) {
86
case DISAS_SWI:
87
gen_ss_advance(dc);
88
- gen_exception(dc, EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb));
89
+ gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb));
90
break;
91
case DISAS_HVC:
92
gen_ss_advance(dc);
93
@@ -XXX,XX +XXX,XX @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
94
gen_helper_yield(cpu_env);
95
break;
96
case DISAS_SWI:
97
- gen_exception(dc, EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb));
98
+ gen_exception(EXCP_SWI, syn_aa32_svc(dc->svc_imm, dc->thumb));
99
break;
100
case DISAS_HVC:
101
gen_exception_el(EXCP_HVC, syn_aa32_hvc(dc->svc_imm), 2);
72
--
102
--
73
2.20.1
103
2.25.1
74
75
diff view generated by jsdifflib
1
Support for running KVM on 32-bit Arm hosts was removed in commit
1
From: Richard Henderson <richard.henderson@linaro.org>
2
82bf7ae84ce739e. You can still run a 32-bit guest on a 64-bit Arm
3
host CPU, but because Arm KVM requires the host and guest CPU types
4
to match, it is not possible to run a guest that requires a Cortex-A9
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
2
3
This function is no longer used. At the same time, remove
4
DisasContext.secure_routed_to_el3, as it in turn becomes unused.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220609202901.1177572-21-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Message-id: 20201215144215.28482-1-peter.maydell@linaro.org
13
---
10
---
14
hw/arm/highbank.c | 14 ++++----------
11
target/arm/translate.h | 16 ----------------
15
1 file changed, 4 insertions(+), 10 deletions(-)
12
target/arm/translate-a64.c | 5 -----
13
target/arm/translate.c | 5 -----
14
3 files changed, 26 deletions(-)
16
15
17
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
16
diff --git a/target/arm/translate.h b/target/arm/translate.h
18
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/highbank.c
18
--- a/target/arm/translate.h
20
+++ b/hw/arm/highbank.c
19
+++ b/target/arm/translate.h
21
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
22
#include "hw/arm/boot.h"
21
int fp_excp_el; /* FP exception EL or 0 if enabled */
23
#include "hw/loader.h"
22
int sve_excp_el; /* SVE exception EL or 0 if enabled */
24
#include "net/net.h"
23
int vl; /* current vector length in bytes */
25
-#include "sysemu/kvm.h"
24
- /* Flag indicating that exceptions from secure mode are routed to EL3. */
26
#include "sysemu/runstate.h"
25
- bool secure_routed_to_el3;
27
#include "sysemu/sysemu.h"
26
bool vfp_enabled; /* FP enabled via FPSCR.EN */
28
#include "hw/boards.h"
27
int vec_len;
29
@@ -XXX,XX +XXX,XX @@
28
int vec_stride;
30
#include "hw/cpu/a15mpcore.h"
29
@@ -XXX,XX +XXX,XX @@ static inline int get_mem_index(DisasContext *s)
31
#include "qemu/log.h"
30
return arm_to_core_mmu_idx(s->mmu_idx);
32
#include "qom/object.h"
33
+#include "cpu.h"
34
35
#define SMP_BOOT_ADDR 0x100
36
#define SMP_BOOT_REG 0x40
37
@@ -XXX,XX +XXX,XX @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
38
highbank_binfo.loader_start = 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
}
31
}
32
33
-/* Function used to determine the target exception EL when otherwise not known
34
- * or default.
35
- */
36
-static inline int default_exception_el(DisasContext *s)
37
-{
38
- /* If we are coming from secure EL0 in a system with a 32-bit EL3, then
39
- * there is no secure EL1, so we route exceptions to EL3. Otherwise,
40
- * exceptions can only be routed to ELs above 1, so we target the higher of
41
- * 1 or the current EL.
42
- */
43
- return (s->mmu_idx == ARMMMUIdx_SE10_0 && s->secure_routed_to_el3)
44
- ? 3 : MAX(1, s->current_el);
45
-}
46
-
47
static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)
48
{
49
/* We don't need to save all of the syndrome so we mask and shift
50
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
51
index XXXXXXX..XXXXXXX 100644
52
--- a/target/arm/translate-a64.c
53
+++ b/target/arm/translate-a64.c
54
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase,
55
dc->condjmp = 0;
56
57
dc->aarch64 = true;
58
- /* If we are coming from secure EL0 in a system with a 32-bit EL3, then
59
- * there is no secure EL1, so we route exceptions to EL3.
60
- */
61
- dc->secure_routed_to_el3 = arm_feature(env, ARM_FEATURE_EL3) &&
62
- !arm_el_is_aa64(env, 3);
63
dc->thumb = false;
64
dc->sctlr_b = 0;
65
dc->be_data = EX_TBFLAG_ANY(tb_flags, BE_DATA) ? MO_BE : MO_LE;
66
diff --git a/target/arm/translate.c b/target/arm/translate.c
67
index XXXXXXX..XXXXXXX 100644
68
--- a/target/arm/translate.c
69
+++ b/target/arm/translate.c
70
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
71
dc->condjmp = 0;
72
73
dc->aarch64 = false;
74
- /* If we are coming from secure EL0 in a system with a 32-bit EL3, then
75
- * there is no secure EL1, so we route exceptions to EL3.
76
- */
77
- dc->secure_routed_to_el3 = arm_feature(env, ARM_FEATURE_EL3) &&
78
- !arm_el_is_aa64(env, 3);
79
dc->thumb = EX_TBFLAG_AM32(tb_flags, THUMB);
80
dc->be_data = EX_TBFLAG_ANY(tb_flags, BE_DATA) ? MO_BE : MO_LE;
81
condexec = EX_TBFLAG_AM32(tb_flags, CONDEXEC);
56
--
82
--
57
2.20.1
83
2.25.1
58
59
diff view generated by jsdifflib
1
Implement the v8.1M FPCXT_NS floating-point system register. This is
1
From: Richard Henderson <richard.henderson@linaro.org>
2
a little more complicated than FPCXT_S, because it has specific
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
2
3
Handle the debug vs current el exception test in one place.
4
Leave EXCP_BKPT alone, since that treats debug < current differently.
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20220609202901.1177572-22-richard.henderson@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20201210201433.26262-4-peter.maydell@linaro.org
10
---
10
---
11
target/arm/translate-vfp.c.inc | 102 ++++++++++++++++++++++++++++++++-
11
target/arm/debug_helper.c | 44 +++++++++++++++++++++------------------
12
1 file changed, 99 insertions(+), 3 deletions(-)
12
1 file changed, 24 insertions(+), 20 deletions(-)
13
13
14
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
14
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate-vfp.c.inc
16
--- a/target/arm/debug_helper.c
17
+++ b/target/arm/translate-vfp.c.inc
17
+++ b/target/arm/debug_helper.c
18
@@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno)
18
@@ -XXX,XX +XXX,XX @@
19
}
19
#include "exec/helper-proto.h"
20
break;
20
21
case ARM_VFP_FPCXT_S:
21
22
+ case ARM_VFP_FPCXT_NS:
22
+/*
23
if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
23
+ * Raise an exception to the debug target el.
24
return false;
24
+ * Modify syndrome to indicate when origin and target EL are the same.
25
}
25
+ */
26
@@ -XXX,XX +XXX,XX @@ static FPSysRegCheckResult fp_sysreg_checks(DisasContext *s, int regno)
26
+G_NORETURN static void
27
return FPSysRegCheckFailed;
27
+raise_exception_debug(CPUARMState *env, uint32_t excp, uint32_t syndrome)
28
}
28
+{
29
29
+ int debug_el = arm_debug_target_el(env);
30
- if (!vfp_access_check(s)) {
30
+ int cur_el = arm_current_el(env);
31
+
31
+ /*
32
+ /*
32
+ * FPCXT_NS is a special case: it has specific handling for
33
+ * If singlestep is targeting a lower EL than the current one, then
33
+ * "current FP state is inactive", and must do the PreserveFPState()
34
+ * DisasContext.ss_active must be false and we can never get here.
34
+ * but not the usual full set of actions done by ExecuteFPCheck().
35
+ * Similarly for watchpoint and breakpoint matches.
35
+ * So we don't call vfp_access_check() and the callers must handle this.
36
+ */
36
+ */
37
+ if (regno != ARM_VFP_FPCXT_NS && !vfp_access_check(s)) {
37
+ assert(debug_el >= cur_el);
38
return FPSysRegCheckDone;
38
+ syndrome |= (debug_el == cur_el) << ARM_EL_EC_SHIFT;
39
}
39
+ raise_exception(env, excp, syndrome, debug_el);
40
-
41
return FPSysRegCheckContinue;
42
}
43
44
+static void gen_branch_fpInactive(DisasContext *s, TCGCond cond,
45
+ TCGLabel *label)
46
+{
47
+ /*
48
+ * FPCXT_NS is a special case: it has specific handling for
49
+ * "current FP state is inactive", and must do the PreserveFPState()
50
+ * but not the usual full set of actions done by ExecuteFPCheck().
51
+ * We don't have a TB flag that matches the fpInactive check, so we
52
+ * do it at runtime as we don't expect FPCXT_NS accesses to be frequent.
53
+ *
54
+ * Emit code that checks fpInactive and does a conditional
55
+ * branch to label based on it:
56
+ * if cond is TCG_COND_NE then branch if fpInactive != 0 (ie if inactive)
57
+ * if cond is TCG_COND_EQ then branch if fpInactive == 0 (ie if active)
58
+ */
59
+ assert(cond == TCG_COND_EQ || cond == TCG_COND_NE);
60
+
61
+ /* fpInactive = FPCCR_NS.ASPEN == 1 && CONTROL.FPCA == 0 */
62
+ TCGv_i32 aspen, fpca;
63
+ aspen = load_cpu_field(v7m.fpccr[M_REG_NS]);
64
+ fpca = load_cpu_field(v7m.control[M_REG_S]);
65
+ tcg_gen_andi_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK);
66
+ tcg_gen_xori_i32(aspen, aspen, R_V7M_FPCCR_ASPEN_MASK);
67
+ tcg_gen_andi_i32(fpca, fpca, R_V7M_CONTROL_FPCA_MASK);
68
+ tcg_gen_or_i32(fpca, fpca, aspen);
69
+ tcg_gen_brcondi_i32(tcg_invert_cond(cond), fpca, 0, label);
70
+ tcg_temp_free_i32(aspen);
71
+ tcg_temp_free_i32(fpca);
72
+}
40
+}
73
+
41
+
74
static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
42
/* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */
75
43
static bool aa64_generate_debug_exceptions(CPUARMState *env)
76
fp_sysreg_loadfn *loadfn,
77
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
78
{
44
{
79
/* Do a write to an M-profile floating point system register */
45
@@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs)
80
TCGv_i32 tmp;
46
if (wp_hit) {
81
+ TCGLabel *lab_end = NULL;
47
if (wp_hit->flags & BP_CPU) {
82
48
bool wnr = (wp_hit->flags & BP_WATCHPOINT_HIT_WRITE) != 0;
83
switch (fp_sysreg_checks(s, regno)) {
49
- bool same_el = arm_debug_target_el(env) == arm_current_el(env);
84
case FPSysRegCheckFailed:
50
85
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
51
cs->watchpoint_hit = NULL;
86
tcg_temp_free_i32(tmp);
52
87
break;
53
env->exception.fsr = arm_debug_exception_fsr(env);
54
env->exception.vaddress = wp_hit->hitaddr;
55
- raise_exception(env, EXCP_DATA_ABORT,
56
- syn_watchpoint(same_el, 0, wnr),
57
- arm_debug_target_el(env));
58
+ raise_exception_debug(env, EXCP_DATA_ABORT,
59
+ syn_watchpoint(0, 0, wnr));
60
}
61
} else {
62
uint64_t pc = is_a64(env) ? env->pc : env->regs[15];
63
- bool same_el = (arm_debug_target_el(env) == arm_current_el(env));
64
65
/*
66
* (1) GDB breakpoints should be handled first.
67
@@ -XXX,XX +XXX,XX @@ void arm_debug_excp_handler(CPUState *cs)
68
* exception/security level.
69
*/
70
env->exception.vaddress = 0;
71
- raise_exception(env, EXCP_PREFETCH_ABORT,
72
- syn_breakpoint(same_el),
73
- arm_debug_target_el(env));
74
+ raise_exception_debug(env, EXCP_PREFETCH_ABORT, syn_breakpoint(0));
88
}
75
}
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
}
76
}
108
77
109
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno,
78
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_bkpt_insn)(CPUARMState *env, uint32_t syndrome)
79
80
void HELPER(exception_swstep)(CPUARMState *env, uint32_t syndrome)
110
{
81
{
111
/* Do a read from an M-profile floating point system register */
82
- int debug_el = arm_debug_target_el(env);
112
TCGv_i32 tmp;
83
- int cur_el = arm_current_el(env);
113
+ TCGLabel *lab_end = NULL;
84
-
114
+ bool lookup_tb = false;
85
- /*
115
86
- * If singlestep is targeting a lower EL than the current one, then
116
switch (fp_sysreg_checks(s, regno)) {
87
- * DisasContext.ss_active must be false and we can never get here.
117
case FPSysRegCheckFailed:
88
- */
118
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_read(DisasContext *s, int regno,
89
- assert(debug_el >= cur_el);
119
fpscr = load_cpu_field(v7m.fpdscr[M_REG_NS]);
90
- if (debug_el == cur_el) {
120
gen_helper_vfp_set_fpscr(cpu_env, fpscr);
91
- syndrome |= 1 << ARM_EL_EC_SHIFT;
121
tcg_temp_free_i32(fpscr);
92
- }
122
- gen_lookup_tb(s);
93
- raise_exception(env, EXCP_UDEF, syndrome, debug_el);
123
+ lookup_tb = true;
94
+ raise_exception_debug(env, EXCP_UDEF, syndrome);
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
+
131
+ lookup_tb = true;
132
+
133
+ gen_branch_fpInactive(s, TCG_COND_EQ, lab_active);
134
+ /* fpInactive case: reads as FPDSCR_NS */
135
+ TCGv_i32 tmp = load_cpu_field(v7m.fpdscr[M_REG_NS]);
136
+ storefn(s, opaque, tmp);
137
+ lab_end = gen_new_label();
138
+ tcg_gen_br(lab_end);
139
+
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
}
95
}
178
96
97
#if !defined(CONFIG_USER_ONLY)
179
--
98
--
180
2.20.1
99
2.25.1
181
182
diff view generated by jsdifflib
1
Currently timer_free() is a simple wrapper for g_free(). This means
1
From: Richard Henderson <richard.henderson@linaro.org>
2
that the timer being freed must not be currently active, as otherwise
3
QEMU might crash later when the active list is processed and still
4
has a pointer to freed memory on it. As a result almost all calls to
5
timer_free() are preceded by a timer_del() call, as can be seen in
6
the output of
7
git grep -B1 '\<timer_free\>'
8
2
9
This is unfortunate API design as it makes it easy to accidentally
3
This function is no longer used outside debug_helper.c.
10
misuse (by forgetting the timer_del()), and the correct use is
11
annoyingly verbose.
12
4
13
Make timer_free() imply a timer_del().
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20220609202901.1177572-23-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/cpu.h | 21 ---------------------
11
target/arm/debug_helper.c | 21 +++++++++++++++++++++
12
2 files changed, 21 insertions(+), 21 deletions(-)
14
13
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
16
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Message-id: 20201215154107.3255-2-peter.maydell@linaro.org
19
---
20
include/qemu/timer.h | 24 +++++++++++++-----------
21
1 file changed, 13 insertions(+), 11 deletions(-)
22
23
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
24
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
25
--- a/include/qemu/timer.h
16
--- a/target/arm/cpu.h
26
+++ b/include/qemu/timer.h
17
+++ b/target/arm/cpu.h
27
@@ -XXX,XX +XXX,XX @@ static inline QEMUTimer *timer_new_ms(QEMUClockType type, QEMUTimerCB *cb,
18
@@ -XXX,XX +XXX,XX @@ typedef enum ARMASIdx {
28
*/
19
ARMASIdx_TagS = 3,
29
void timer_deinit(QEMUTimer *ts);
20
} ARMASIdx;
30
21
31
-/**
22
-/* Return the Exception Level targeted by debug exceptions. */
32
- * timer_free:
23
-static inline int arm_debug_target_el(CPUARMState *env)
33
- * @ts: the timer
34
- *
35
- * Free a timer (it must not be on the active list)
36
- */
37
-static inline void timer_free(QEMUTimer *ts)
38
-{
24
-{
39
- g_free(ts);
25
- bool secure = arm_is_secure(env);
26
- bool route_to_el2 = false;
27
-
28
- if (arm_is_el2_enabled(env)) {
29
- route_to_el2 = env->cp15.hcr_el2 & HCR_TGE ||
30
- env->cp15.mdcr_el2 & MDCR_TDE;
31
- }
32
-
33
- if (route_to_el2) {
34
- return 2;
35
- } else if (arm_feature(env, ARM_FEATURE_EL3) &&
36
- !arm_el_is_aa64(env, 3) && secure) {
37
- return 3;
38
- } else {
39
- return 1;
40
- }
40
-}
41
-}
41
-
42
-
42
/**
43
static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu)
43
* timer_del:
44
{
44
* @ts: the timer
45
/* If all the CLIDR.Ctypem bits are 0 there are no caches, and
45
@@ -XXX,XX +XXX,XX @@ static inline void timer_free(QEMUTimer *ts)
46
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
46
*/
47
index XXXXXXX..XXXXXXX 100644
47
void timer_del(QEMUTimer *ts);
48
--- a/target/arm/debug_helper.c
48
49
+++ b/target/arm/debug_helper.c
49
+/**
50
@@ -XXX,XX +XXX,XX @@
50
+ * timer_free:
51
#include "exec/helper-proto.h"
51
+ * @ts: the timer
52
52
+ *
53
53
+ * Free a timer. This will call timer_del() for you to remove
54
+/* Return the Exception Level targeted by debug exceptions. */
54
+ * the timer from the active list if it was still active.
55
+static int arm_debug_target_el(CPUARMState *env)
55
+ */
56
+static inline void timer_free(QEMUTimer *ts)
57
+{
56
+{
58
+ timer_del(ts);
57
+ bool secure = arm_is_secure(env);
59
+ g_free(ts);
58
+ bool route_to_el2 = false;
59
+
60
+ if (arm_is_el2_enabled(env)) {
61
+ route_to_el2 = env->cp15.hcr_el2 & HCR_TGE ||
62
+ env->cp15.mdcr_el2 & MDCR_TDE;
63
+ }
64
+
65
+ if (route_to_el2) {
66
+ return 2;
67
+ } else if (arm_feature(env, ARM_FEATURE_EL3) &&
68
+ !arm_el_is_aa64(env, 3) && secure) {
69
+ return 3;
70
+ } else {
71
+ return 1;
72
+ }
60
+}
73
+}
61
+
74
+
62
/**
75
/*
63
* timer_mod_ns:
76
* Raise an exception to the debug target el.
64
* @ts: the timer
77
* Modify syndrome to indicate when origin and target EL are the same.
65
--
78
--
66
2.20.1
79
2.25.1
67
68
diff view generated by jsdifflib
1
In commit 64f863baeedc8659 we implemented the v8.1M FPCXT_S register,
1
From: Richard Henderson <richard.henderson@linaro.org>
2
but we got the write behaviour wrong. On read, this register reads
3
bits [27:0] of FPSCR plus the CONTROL.SFPA bit. On write, it doesn't
4
just write back those bits -- it writes a value to the whole FPSCR,
5
whose upper 4 bits are zeroes.
6
2
7
We also incorrectly implemented the write-to-FPSCR as a simple store
3
We were using arm_is_secure and is_a64, which are
8
to vfp.xregs; this skips the "update the softfloat flags" part of
4
tests against the current EL, as opposed to
9
the vfp_set_fpscr helper so the value would read back correctly but
5
arm_el_is_aa64 and arm_is_secure_below_el3, which
10
not actually take effect.
6
can be applied to a different EL than current.
7
Consolidate the two tests.
11
8
12
Fix both of these things by doing a complete write to the FPSCR
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
using the helper function.
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20220609202901.1177572-24-richard.henderson@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
target/arm/helper.c | 23 +++++++++--------------
15
1 file changed, 9 insertions(+), 14 deletions(-)
14
16
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20201210201433.26262-3-peter.maydell@linaro.org
18
---
19
target/arm/translate-vfp.c.inc | 12 ++++++------
20
1 file changed, 6 insertions(+), 6 deletions(-)
21
22
diff --git a/target/arm/translate-vfp.c.inc b/target/arm/translate-vfp.c.inc
23
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/translate-vfp.c.inc
19
--- a/target/arm/helper.c
25
+++ b/target/arm/translate-vfp.c.inc
20
+++ b/target/arm/helper.c
26
@@ -XXX,XX +XXX,XX @@ static bool gen_M_fp_sysreg_write(DisasContext *s, int regno,
21
@@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el)
22
int fpen = FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, FPEN);
23
24
switch (fpen) {
25
+ case 1:
26
+ if (cur_el != 0) {
27
+ break;
28
+ }
29
+ /* fall through */
30
case 0:
31
case 2:
32
- if (cur_el == 0 || cur_el == 1) {
33
- /* Trap to PL1, which might be EL1 or EL3 */
34
- if (arm_is_secure(env) && !arm_el_is_aa64(env, 3)) {
35
- return 3;
36
- }
37
- return 1;
38
- }
39
- if (cur_el == 3 && !is_a64(env)) {
40
- /* Secure PL1 running at EL3 */
41
+ /* Trap from Secure PL0 or PL1 to Secure PL1. */
42
+ if (!arm_el_is_aa64(env, 3)
43
+ && (cur_el == 3 || arm_is_secure_below_el3(env))) {
44
return 3;
45
}
46
- break;
47
- case 1:
48
- if (cur_el == 0) {
49
+ if (cur_el <= 1) {
50
return 1;
51
}
52
break;
53
- case 3:
54
- break;
55
}
27
}
56
}
28
case ARM_VFP_FPCXT_S:
57
29
{
30
- TCGv_i32 sfpa, control, fpscr;
31
- /* Set FPSCR[27:0] and CONTROL.SFPA from value */
32
+ TCGv_i32 sfpa, control;
33
+ /*
34
+ * Set FPSCR and CONTROL.SFPA from value; the new FPSCR takes
35
+ * bits [27:0] from value and zeroes bits [31:28].
36
+ */
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
--
58
--
54
2.20.1
59
2.25.1
55
56
diff view generated by jsdifflib
1
From: Bin Meng <bin.meng@windriver.com>
1
From: Hao Wu <wuhaotsh@google.com>
2
2
3
U-Boot expects PMU_MISC0 register bit 7 is set (see init_bandgap()
3
Creating 1GB image for a simple qtest is unnecessary
4
in arch/arm/mach-imx/mx6/soc.c) during boot. This bit indicates the
4
and could lead to failures. We reduce the image size
5
bandgap has stabilized.
5
to 1MB to reduce the test overhead.
6
6
7
With this change, the latest upstream U-Boot (v2021.01-rc3) for imx6
7
Signed-off-by: Hao Wu <wuhaotsh@google.com>
8
sabrelite board (mx6qsabrelite_defconfig), with a slight change made
8
Message-id: 20220609214125.4192212-1-wuhaotsh@google.com
9
by switching CONFIG_OF_SEPARATE to CONFIG_OF_EMBED, boots to U-Boot
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
shell on QEMU with the following command:
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>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
54
---
11
---
55
hw/misc/imx6_ccm.c | 2 +-
12
tests/qtest/npcm7xx_sdhci-test.c | 2 +-
56
1 file changed, 1 insertion(+), 1 deletion(-)
13
1 file changed, 1 insertion(+), 1 deletion(-)
57
14
58
diff --git a/hw/misc/imx6_ccm.c b/hw/misc/imx6_ccm.c
15
diff --git a/tests/qtest/npcm7xx_sdhci-test.c b/tests/qtest/npcm7xx_sdhci-test.c
59
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
60
--- a/hw/misc/imx6_ccm.c
17
--- a/tests/qtest/npcm7xx_sdhci-test.c
61
+++ b/hw/misc/imx6_ccm.c
18
+++ b/tests/qtest/npcm7xx_sdhci-test.c
62
@@ -XXX,XX +XXX,XX @@ static void imx6_ccm_reset(DeviceState *dev)
19
@@ -XXX,XX +XXX,XX @@
63
s->analog[PMU_REG_3P0] = 0x00000F74;
20
#define NPCM7XX_REG_SIZE 0x100
64
s->analog[PMU_REG_2P5] = 0x00005071;
21
#define NPCM7XX_MMC_BA 0xF0842000
65
s->analog[PMU_REG_CORE] = 0x00402010;
22
#define NPCM7XX_BLK_SIZE 512
66
- s->analog[PMU_MISC0] = 0x04000000;
23
-#define NPCM7XX_TEST_IMAGE_SIZE (1 << 30)
67
+ s->analog[PMU_MISC0] = 0x04000080;
24
+#define NPCM7XX_TEST_IMAGE_SIZE (1 << 20)
68
s->analog[PMU_MISC1] = 0x00000000;
25
69
s->analog[PMU_MISC2] = 0x00272727;
26
char *sd_path;
70
27
71
--
28
--
72
2.20.1
29
2.25.1
73
74
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
In 50244cc76abc we updated mte_check_fail to match the ARM
3
Because reset always initializes the AA64 version, SCR_EL3,
4
pseudocode, using the correct EL to select the TCF field.
4
test the mode of EL3 instead of the type of the cpreg.
5
But we failed to update MTE0_ACTIVE the same way, which led
6
to g_assert_not_reached().
7
5
8
Cc: qemu-stable@nongnu.org
9
Buglink: https://bugs.launchpad.net/bugs/1907137
10
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20201221204426.88514-1-richard.henderson@linaro.org
7
Message-id: 20220609214657.1217913-2-richard.henderson@linaro.org
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
10
---
15
target/arm/helper.c | 2 +-
11
target/arm/helper.c | 14 ++++++++------
16
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 8 insertions(+), 6 deletions(-)
17
13
18
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
19
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/helper.c
16
--- a/target/arm/helper.c
21
+++ b/target/arm/helper.c
17
+++ b/target/arm/helper.c
22
@@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
18
@@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
23
if (FIELD_EX32(flags, TBFLAG_A64, UNPRIV)
19
uint32_t valid_mask = 0x3fff;
24
&& tbid
20
ARMCPU *cpu = env_archcpu(env);
25
&& !(env->pstate & PSTATE_TCO)
21
26
- && (sctlr & SCTLR_TCF0)
22
- if (ri->state == ARM_CP_STATE_AA64) {
27
+ && (sctlr & SCTLR_TCF)
23
- if (arm_feature(env, ARM_FEATURE_AARCH64) &&
28
&& allocation_tag_access_enabled(env, 0, sctlr)) {
24
- !cpu_isar_feature(aa64_aa32_el1, cpu)) {
29
flags = FIELD_DP32(flags, TBFLAG_A64, MTE0_ACTIVE, 1);
25
- value |= SCR_FW | SCR_AW; /* these two bits are RES1. */
30
}
26
- }
27
- valid_mask &= ~SCR_NET;
28
+ /*
29
+ * Because SCR_EL3 is the "real" cpreg and SCR is the alias, reset always
30
+ * passes the reginfo for SCR_EL3, which has type ARM_CP_STATE_AA64.
31
+ * Instead, choose the format based on the mode of EL3.
32
+ */
33
+ if (arm_el_is_aa64(env, 3)) {
34
+ value |= SCR_FW | SCR_AW; /* RES1 */
35
+ valid_mask &= ~SCR_NET; /* RES0 */
36
37
if (cpu_isar_feature(aa64_ras, cpu)) {
38
valid_mask |= SCR_TERR;
31
--
39
--
32
2.20.1
40
2.25.1
33
34
diff view generated by jsdifflib
1
From: Gan Qixin <ganqixin@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
When running device-introspect-test, a memory leak occurred in the
3
Since DDI0487F.a, the RW bit is RAO/WI. When specifically
4
digic_timer_init function, so use ptimer_free() in the finalize function to
4
targeting such a cpu, e.g. cortex-a76, it is legitimate to
5
avoid it.
5
ignore the bit within the secure monitor.
6
6
7
ASAN shows memory leak stack:
7
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1062
8
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Indirect leak of 288 byte(s) in 3 object(s) allocated from:
9
Message-id: 20220609214657.1217913-3-richard.henderson@linaro.org
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/cpu.h | 5 +++++
30
1 file changed, 8 insertions(+)
14
target/arm/helper.c | 4 ++++
15
2 files changed, 9 insertions(+)
31
16
32
diff --git a/hw/timer/digic-timer.c b/hw/timer/digic-timer.c
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
33
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/timer/digic-timer.c
19
--- a/target/arm/cpu.h
35
+++ b/hw/timer/digic-timer.c
20
+++ b/target/arm/cpu.h
36
@@ -XXX,XX +XXX,XX @@ static void digic_timer_init(Object *obj)
21
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_aa32_el1(const ARMISARegisters *id)
37
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
22
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL1) >= 2;
38
}
23
}
39
24
40
+static void digic_timer_finalize(Object *obj)
25
+static inline bool isar_feature_aa64_aa32_el2(const ARMISARegisters *id)
41
+{
26
+{
42
+ DigicTimerState *s = DIGIC_TIMER(obj);
27
+ return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL2) >= 2;
43
+
44
+ ptimer_free(s->ptimer);
45
+}
28
+}
46
+
29
+
47
static void digic_timer_class_init(ObjectClass *klass, void *class_data)
30
static inline bool isar_feature_aa64_ras(const ARMISARegisters *id)
48
{
31
{
49
DeviceClass *dc = DEVICE_CLASS(klass);
32
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, RAS) != 0;
50
@@ -XXX,XX +XXX,XX @@ static const TypeInfo digic_timer_info = {
33
diff --git a/target/arm/helper.c b/target/arm/helper.c
51
.parent = TYPE_SYS_BUS_DEVICE,
34
index XXXXXXX..XXXXXXX 100644
52
.instance_size = sizeof(DigicTimerState),
35
--- a/target/arm/helper.c
53
.instance_init = digic_timer_init,
36
+++ b/target/arm/helper.c
54
+ .instance_finalize = digic_timer_finalize,
37
@@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
55
.class_init = digic_timer_class_init,
38
value |= SCR_FW | SCR_AW; /* RES1 */
56
};
39
valid_mask &= ~SCR_NET; /* RES0 */
57
40
41
+ if (!cpu_isar_feature(aa64_aa32_el1, cpu) &&
42
+ !cpu_isar_feature(aa64_aa32_el2, cpu)) {
43
+ value |= SCR_RW; /* RAO/WI */
44
+ }
45
if (cpu_isar_feature(aa64_ras, cpu)) {
46
valid_mask |= SCR_TERR;
47
}
58
--
48
--
59
2.20.1
49
2.25.1
60
61
diff view generated by jsdifflib
1
This commit is the result of running the timer-del-timer-free.cocci
1
In two places in gdbstub.c we look at gdbserver_state.init to decide
2
script on the whole source tree.
2
whether we're going to do a semihosting syscall via the gdb remote
3
protocol:
4
* when setting up, if the user didn't explicitly select either
5
native semihosting or gdb semihosting, we autoselect, with the
6
intended behaviour "use gdb if gdb is connected"
7
* when the semihosting layer attempts to do a syscall via gdb, we
8
silently ignore it if the gdbstub wasn't actually set up
3
9
10
However, if the user's commandline sets up the gdbstub but tells QEMU
11
to start rather than waiting for a GDB to connect (eg using '-s' but
12
not '-S'), then we will have gdbserver_state.init true but no actual
13
connection; an attempt to use gdb syscalls will then crash because we
14
try to use gdbserver_state.c_cpu when it hasn't been set up:
15
16
#0 0x00007ffff6803ba8 in qemu_cpu_kick (cpu=0x0) at ../../softmmu/cpus.c:457
17
#1 0x00007ffff6c03913 in gdb_do_syscallv (cb=0x7ffff6c19944 <common_semi_cb>,
18
fmt=0x7ffff7573b7e "", va=0x7ffff56294c0) at ../../gdbstub.c:2946
19
#2 0x00007ffff6c19c3a in common_semi_gdb_syscall (cs=0x7ffff83fe060,
20
cb=0x7ffff6c19944 <common_semi_cb>, fmt=0x7ffff7573b75 "isatty,%x")
21
at ../../semihosting/arm-compat-semi.c:494
22
#3 0x00007ffff6c1a064 in gdb_isattyfn (cs=0x7ffff83fe060, gf=0x7ffff86a3690)
23
at ../../semihosting/arm-compat-semi.c:636
24
#4 0x00007ffff6c1b20f in do_common_semihosting (cs=0x7ffff83fe060)
25
at ../../semihosting/arm-compat-semi.c:967
26
#5 0x00007ffff693a037 in handle_semihosting (cs=0x7ffff83fe060)
27
at ../../target/arm/helper.c:10316
28
29
You can probably also get into this state via some odd
30
corner cases involving connecting a GDB and then telling it
31
to detach from all the vCPUs.
32
33
Abstract out the test into a new gdb_attached() function
34
which returns true only if there's actually a GDB connected
35
to the debug stub and attached to at least one vCPU.
36
37
Reported-by: Liviu Ionescu <ilg@livius.net>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
38
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Acked-by: Corey Minyard <cminyard@mvista.com>
39
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
40
Reviewed-by: Luc Michel <luc@lmichel.fr>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
41
Message-id: 20220526190053.521505-2-peter.maydell@linaro.org
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20201215154107.3255-4-peter.maydell@linaro.org
10
---
42
---
11
block/iscsi.c | 2 --
43
gdbstub.c | 14 +++++++++++---
12
block/nbd.c | 1 -
44
1 file changed, 11 insertions(+), 3 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
45
55
diff --git a/block/iscsi.c b/block/iscsi.c
46
diff --git a/gdbstub.c b/gdbstub.c
56
index XXXXXXX..XXXXXXX 100644
47
index XXXXXXX..XXXXXXX 100644
57
--- a/block/iscsi.c
48
--- a/gdbstub.c
58
+++ b/block/iscsi.c
49
+++ b/gdbstub.c
59
@@ -XXX,XX +XXX,XX @@ static void iscsi_detach_aio_context(BlockDriverState *bs)
50
@@ -XXX,XX +XXX,XX @@ static int get_char(void)
60
iscsilun->events = 0;
51
}
61
52
#endif
62
if (iscsilun->nop_timer) {
53
63
- timer_del(iscsilun->nop_timer);
54
+/*
64
timer_free(iscsilun->nop_timer);
55
+ * Return true if there is a GDB currently connected to the stub
65
iscsilun->nop_timer = NULL;
56
+ * and attached to a CPU
57
+ */
58
+static bool gdb_attached(void)
59
+{
60
+ return gdbserver_state.init && gdbserver_state.c_cpu;
61
+}
62
+
63
static enum {
64
GDB_SYS_UNKNOWN,
65
GDB_SYS_ENABLED,
66
@@ -XXX,XX +XXX,XX @@ int use_gdb_syscalls(void)
67
/* -semihosting-config target=auto */
68
/* On the first call check if gdb is connected and remember. */
69
if (gdb_syscall_mode == GDB_SYS_UNKNOWN) {
70
- gdb_syscall_mode = gdbserver_state.init ?
71
- GDB_SYS_ENABLED : GDB_SYS_DISABLED;
72
+ gdb_syscall_mode = gdb_attached() ? GDB_SYS_ENABLED : GDB_SYS_DISABLED;
66
}
73
}
67
if (iscsilun->event_timer) {
74
return gdb_syscall_mode == GDB_SYS_ENABLED;
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
}
75
}
187
diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c
76
@@ -XXX,XX +XXX,XX @@ void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va)
188
index XXXXXXX..XXXXXXX 100644
77
target_ulong addr;
189
--- a/hw/intc/ioapic.c
78
uint64_t i64;
190
+++ b/hw/intc/ioapic.c
79
191
@@ -XXX,XX +XXX,XX @@ static void ioapic_unrealize(DeviceState *dev)
80
- if (!gdbserver_state.init) {
192
{
81
+ if (!gdb_attached()) {
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
}
254
}
255
@@ -XXX,XX +XXX,XX @@ e1000e_core_pci_uninit(E1000ECore *core)
256
{
257
int i;
258
259
- timer_del(core->autoneg_timer);
260
timer_free(core->autoneg_timer);
261
262
e1000e_intrmgr_pci_unint(core);
263
diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
264
index XXXXXXX..XXXXXXX 100644
265
--- a/hw/net/pcnet-pci.c
266
+++ b/hw/net/pcnet-pci.c
267
@@ -XXX,XX +XXX,XX @@ static void pci_pcnet_uninit(PCIDevice *dev)
268
PCIPCNetState *d = PCI_PCNET(dev);
269
270
qemu_free_irq(d->state.irq);
271
- timer_del(d->state.poll_timer);
272
timer_free(d->state.poll_timer);
273
qemu_del_nic(d->state.nic);
274
}
275
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
276
index XXXXXXX..XXXXXXX 100644
277
--- a/hw/net/rtl8139.c
278
+++ b/hw/net/rtl8139.c
279
@@ -XXX,XX +XXX,XX @@ static void pci_rtl8139_uninit(PCIDevice *dev)
280
281
g_free(s->cplus_txbuffer);
282
s->cplus_txbuffer = NULL;
283
- timer_del(s->timer);
284
timer_free(s->timer);
285
qemu_del_nic(s->nic);
286
}
287
diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
288
index XXXXXXX..XXXXXXX 100644
289
--- a/hw/net/spapr_llan.c
290
+++ b/hw/net/spapr_llan.c
291
@@ -XXX,XX +XXX,XX @@ static void spapr_vlan_instance_finalize(Object *obj)
292
}
293
294
if (dev->rxp_timer) {
295
- timer_del(dev->rxp_timer);
296
timer_free(dev->rxp_timer);
297
}
298
}
299
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
300
index XXXXXXX..XXXXXXX 100644
301
--- a/hw/net/virtio-net.c
302
+++ b/hw/net/virtio-net.c
303
@@ -XXX,XX +XXX,XX @@ static void virtio_net_rsc_cleanup(VirtIONet *n)
304
g_free(seg);
305
}
306
307
- timer_del(chain->drain_timer);
308
timer_free(chain->drain_timer);
309
QTAILQ_REMOVE(&n->rsc_chains, chain, next);
310
g_free(chain);
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
{
326
if (pbdev->fmb_timer) {
327
- timer_del(pbdev->fmb_timer);
328
timer_free(pbdev->fmb_timer);
329
pbdev->fmb_timer = NULL;
330
}
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
}
342
343
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
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;
82
return;
447
}
83
}
448
84
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
--
85
--
624
2.20.1
86
2.25.1
625
87
626
88
diff view generated by jsdifflib
1
The CCR is a register most of whose bits are banked between security
1
Currently we mishandle the --semihosting-config option if the
2
states but where BFHFNMIGN is not, and we keep it in the non-secure
2
user specifies it on the command line more than once. For
3
entry of the v7m.ccr[] array. The logic which tries to handle this
3
example with:
4
bit fails to implement the "RAZ/WI from Nonsecure if AIRCR.BFHFNMINS
4
--semihosting-config target=gdb --semihosting-config arg=foo,arg=bar
5
is zero" requirement; correct the omission.
5
6
the function qemu_semihosting_config_options() is called twice, once
7
for each argument. But that function expects to be called only once,
8
and it always unconditionally sets the semihosting.enabled,
9
semihost_chardev and semihosting.target variables. This means that
10
if any of those options were set anywhere except the last
11
--semihosting-config option on the command line, those settings are
12
ignored. In the example above, 'target=gdb' in the first option is
13
overridden by an implied default 'target=auto' in the second.
14
15
The QemuOptsList machinery has a flag for handling this kind of
16
"option group is setting global state": by setting
17
.merge_lists = true;
18
we make the machinery merge all the --semihosting-config arguments
19
the user passes into a single set of options and call our
20
qemu_semihosting_config_options() just once.
6
21
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
23
Reviewed-by: Luc Michel <luc@lmichel.fr>
9
Message-id: 20201210201433.26262-2-peter.maydell@linaro.org
24
Message-id: 20220526190053.521505-3-peter.maydell@linaro.org
10
---
25
---
11
hw/intc/armv7m_nvic.c | 15 +++++++++++++++
26
semihosting/config.c | 1 +
12
1 file changed, 15 insertions(+)
27
1 file changed, 1 insertion(+)
13
28
14
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
29
diff --git a/semihosting/config.c b/semihosting/config.c
15
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/armv7m_nvic.c
31
--- a/semihosting/config.c
17
+++ b/hw/intc/armv7m_nvic.c
32
+++ b/semihosting/config.c
18
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
33
@@ -XXX,XX +XXX,XX @@
19
*/
34
20
val = cpu->env.v7m.ccr[attrs.secure];
35
QemuOptsList qemu_semihosting_config_opts = {
21
val |= cpu->env.v7m.ccr[M_REG_NS] & R_V7M_CCR_BFHFNMIGN_MASK;
36
.name = "semihosting-config",
22
+ /* BFHFNMIGN is RAZ/WI from NS if AIRCR.BFHFNMINS is 0 */
37
+ .merge_lists = true,
23
+ if (!attrs.secure) {
38
.implied_opt_name = "enable",
24
+ if (!(cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
39
.head = QTAILQ_HEAD_INITIALIZER(qemu_semihosting_config_opts.head),
25
+ val &= ~R_V7M_CCR_BFHFNMIGN_MASK;
40
.desc = {
26
+ }
27
+ }
28
return val;
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
--
41
--
48
2.20.1
42
2.25.1
49
50
diff view generated by jsdifflib