1
Handful of bugfixes for rc2. None of these are particularly critical
1
Hi; here's a target-arm pull for rc2. Four arm-related fixes,
2
or exciting.
2
and a couple of bug fixes for other areas of the codebase
3
that seemed like they'd fallen through the cracks.
3
4
5
thanks
4
-- PMM
6
-- PMM
5
7
6
The following changes since commit 45a150aa2b3492acf6691c7bdbeb25a8545d8345:
8
The following changes since commit ccb86f079a9e4d94918086a9df18c1844347aff8:
7
9
8
Merge remote-tracking branch 'remotes/ericb/tags/pull-bitmaps-2020-08-03' into staging (2020-08-03 15:13:49 +0100)
10
Merge tag 'pull-nbd-2023-07-28' of https://repo.or.cz/qemu/ericb into staging (2023-07-28 09:56:57 -0700)
9
11
10
are available in the Git repository at:
12
are available in the Git repository at:
11
13
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200803
14
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230731
13
15
14
for you to fetch changes up to 13557fd392890cbd985bceba7f717e01efd674b8:
16
for you to fetch changes up to 108e8180c6b0c315711aa54e914030a313505c17:
15
17
16
hw/timer/imx_epit: Avoid assertion when CR.SWR is written (2020-08-03 17:56:11 +0100)
18
gdbstub: Fix client Ctrl-C handling (2023-07-31 14:57:32 +0100)
17
19
18
----------------------------------------------------------------
20
----------------------------------------------------------------
19
target-arm queue:
21
target-arm queue:
20
* hw/timer/imx_epit: Avoid assertion when CR.SWR is written
22
* Don't build AArch64 decodetree files for qemu-system-arm
21
* netduino2, netduinoplus2, microbit: set system_clock_scale so that
23
* Fix TCG assert in v8.1M CSEL etc
22
SysTick running on the CPU clock works
24
* Fix MemOp for STGP
23
* target/arm: Avoid maybe-uninitialized warning with gcc 4.9
25
* gdbstub: Fix client Ctrl-C handling
24
* target/arm: Fix AddPAC error indication
26
* kvm: Fix crash due to access uninitialized kvm_state
25
* Make AIRCR.SYSRESETREQ actually reset the system for the
27
* elf2dmp: Don't abandon when Prcb is set to 0
26
microbit, mps2-*, musca-*, netduino* boards
27
28
28
----------------------------------------------------------------
29
----------------------------------------------------------------
29
Kaige Li (1):
30
Akihiko Odaki (1):
30
target/arm: Avoid maybe-uninitialized warning with gcc 4.9
31
elf2dmp: Don't abandon when Prcb is set to 0
31
32
32
Peter Maydell (6):
33
Gavin Shan (1):
33
hw/arm/netduino2, netduinoplus2: Set system_clock_scale
34
kvm: Fix crash due to access uninitialized kvm_state
34
include/hw/irq.h: New function qemu_irq_is_connected()
35
35
hw/intc/armv7m_nvic: Provide default "reset the system" behaviour for SYSRESETREQ
36
Nicholas Piggin (1):
36
msf2-soc, stellaris: Don't wire up SYSRESETREQ
37
gdbstub: Fix client Ctrl-C handling
37
hw/arm/nrf51_soc: Set system_clock_scale
38
38
hw/timer/imx_epit: Avoid assertion when CR.SWR is written
39
Peter Maydell (2):
40
target/arm: Avoid writing to constant TCGv in trans_CSEL()
41
target/arm/tcg: Don't build AArch64 decodetree files for qemu-system-arm
39
42
40
Richard Henderson (1):
43
Richard Henderson (1):
41
target/arm: Fix AddPAC error indication
44
target/arm: Fix MemOp for STGP
42
45
43
include/hw/arm/armv7m.h | 4 +++-
46
accel/kvm/kvm-all.c | 2 +-
44
include/hw/irq.h | 18 ++++++++++++++++++
47
contrib/elf2dmp/main.c | 5 +++++
45
hw/arm/msf2-soc.c | 11 -----------
48
gdbstub/gdbstub.c | 13 +++++++++++--
46
hw/arm/netduino2.c | 10 ++++++++++
49
target/arm/tcg/translate-a64.c | 21 ++++++++++++++++++---
47
hw/arm/netduinoplus2.c | 10 ++++++++++
50
target/arm/tcg/translate.c | 15 ++++++++-------
48
hw/arm/nrf51_soc.c | 5 +++++
51
target/arm/tcg/meson.build | 10 +++++++---
49
hw/arm/stellaris.c | 12 ------------
52
6 files changed, 50 insertions(+), 16 deletions(-)
50
hw/intc/armv7m_nvic.c | 17 ++++++++++++++++-
51
hw/timer/imx_epit.c | 13 ++++++++++---
52
target/arm/pauth_helper.c | 6 +++++-
53
target/arm/translate-a64.c | 2 +-
54
tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++++
55
tests/tcg/aarch64/Makefile.target | 2 +-
56
13 files changed, 112 insertions(+), 31 deletions(-)
57
create mode 100644 tests/tcg/aarch64/pauth-5.c
58
diff view generated by jsdifflib
Deleted patch
1
The netduino2 and netduinoplus2 boards forgot to set the system_clock_scale
2
global, which meant that if guest code used the systick timer in "use
3
the processor clock" mode it would hang because time never advances.
4
1
5
Set the global to match the documented CPU clock speed of these boards.
6
Judging by the data sheet this is slightly simplistic because the
7
SoC allows configuration of the SYSCLK source and frequency via the
8
RCC (reset and clock control) module, but we don't model that.
9
10
Fixes: https://bugs.launchpad.net/qemu/+bug/1876187
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
13
Message-id: 20200727162617.26227-1-peter.maydell@linaro.org
14
---
15
hw/arm/netduino2.c | 10 ++++++++++
16
hw/arm/netduinoplus2.c | 10 ++++++++++
17
2 files changed, 20 insertions(+)
18
19
diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/arm/netduino2.c
22
+++ b/hw/arm/netduino2.c
23
@@ -XXX,XX +XXX,XX @@
24
#include "hw/arm/stm32f205_soc.h"
25
#include "hw/arm/boot.h"
26
27
+/* Main SYSCLK frequency in Hz (120MHz) */
28
+#define SYSCLK_FRQ 120000000ULL
29
+
30
static void netduino2_init(MachineState *machine)
31
{
32
DeviceState *dev;
33
34
+ /*
35
+ * TODO: ideally we would model the SoC RCC and let it handle
36
+ * system_clock_scale, including its ability to define different
37
+ * possible SYSCLK sources.
38
+ */
39
+ system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
40
+
41
dev = qdev_new(TYPE_STM32F205_SOC);
42
qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3"));
43
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
44
diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/arm/netduinoplus2.c
47
+++ b/hw/arm/netduinoplus2.c
48
@@ -XXX,XX +XXX,XX @@
49
#include "hw/arm/stm32f405_soc.h"
50
#include "hw/arm/boot.h"
51
52
+/* Main SYSCLK frequency in Hz (168MHz) */
53
+#define SYSCLK_FRQ 168000000ULL
54
+
55
static void netduinoplus2_init(MachineState *machine)
56
{
57
DeviceState *dev;
58
59
+ /*
60
+ * TODO: ideally we would model the SoC RCC and let it handle
61
+ * system_clock_scale, including its ability to define different
62
+ * possible SYSCLK sources.
63
+ */
64
+ system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ;
65
+
66
dev = qdev_new(TYPE_STM32F405_SOC);
67
qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4"));
68
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
69
--
70
2.20.1
71
72
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
The definition of top_bit used in this function is one higher
3
When converting to decodetree, the code to rebuild mop for the pair
4
than that used in the Arm ARM psuedo-code, which put the error
4
only made it into trans_STP and not into trans_STGP.
5
indication at top_bit - 1 at the wrong place, which meant that
6
it wasn't visible to Auth.
7
5
8
Fixing the definition of top_bit requires more changes, because
6
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1790
9
its most common use is for the count of bits in top_bit:bot_bit,
7
Fixes: 8c212eb6594 ("target/arm: Convert load/store-pair to decodetree")
10
which would then need to be computed as top_bit - bot_bit + 1.
11
12
For now, prefer the minimal fix to the error indication alone.
13
14
Fixes: 63ff0ca94cb
15
Reported-by: Derrick McKee <derrick.mckee@gmail.com>
16
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20200728195706.11087-1-richard.henderson@linaro.org
9
Message-id: 20230726165416.309624-1-richard.henderson@linaro.org
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
[PMM: added comment about the divergence from the pseudocode]
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
---
12
---
22
target/arm/pauth_helper.c | 6 +++++-
13
target/arm/tcg/translate-a64.c | 21 ++++++++++++++++++---
23
tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++
14
1 file changed, 18 insertions(+), 3 deletions(-)
24
tests/tcg/aarch64/Makefile.target | 2 +-
25
3 files changed, 39 insertions(+), 2 deletions(-)
26
create mode 100644 tests/tcg/aarch64/pauth-5.c
27
15
28
diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c
16
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
29
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/pauth_helper.c
18
--- a/target/arm/tcg/translate-a64.c
31
+++ b/target/arm/pauth_helper.c
19
+++ b/target/arm/tcg/translate-a64.c
32
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,
20
@@ -XXX,XX +XXX,XX @@ static bool trans_STGP(DisasContext *s, arg_ldstpair *a)
33
*/
21
MemOp mop;
34
test = sextract64(ptr, bot_bit, top_bit - bot_bit);
22
TCGv_i128 tmp;
35
if (test != 0 && test != -1) {
23
36
- pac ^= MAKE_64BIT_MASK(top_bit - 1, 1);
24
+ /* STGP only comes in one size. */
37
+ /*
25
+ tcg_debug_assert(a->sz == MO_64);
38
+ * Note that our top_bit is one greater than the pseudocode's
26
+
39
+ * version, hence "- 2" here.
27
if (!dc_isar_feature(aa64_mte_insn_reg, s)) {
40
+ */
28
return false;
41
+ pac ^= MAKE_64BIT_MASK(top_bit - 2, 1);
42
}
29
}
43
30
@@ -XXX,XX +XXX,XX @@ static bool trans_STGP(DisasContext *s, arg_ldstpair *a)
44
/*
31
gen_helper_stg(cpu_env, dirty_addr, dirty_addr);
45
diff --git a/tests/tcg/aarch64/pauth-5.c b/tests/tcg/aarch64/pauth-5.c
32
}
46
new file mode 100644
33
47
index XXXXXXX..XXXXXXX
34
- mop = finalize_memop(s, a->sz);
48
--- /dev/null
35
- clean_addr = gen_mte_checkN(s, dirty_addr, true, false, 2 << a->sz, mop);
49
+++ b/tests/tcg/aarch64/pauth-5.c
36
+ mop = finalize_memop(s, MO_64);
50
@@ -XXX,XX +XXX,XX @@
37
+ clean_addr = gen_mte_checkN(s, dirty_addr, true, false, 2 << MO_64, mop);
51
+#include <assert.h>
38
52
+
39
tcg_rt = cpu_reg(s, a->rt);
53
+static int x;
40
tcg_rt2 = cpu_reg(s, a->rt2);
54
+
41
55
+int main()
42
- assert(a->sz == 3);
56
+{
57
+ int *p0 = &x, *p1, *p2, *p3;
58
+ unsigned long salt = 0;
59
+
60
+ /*
43
+ /*
61
+ * With TBI enabled and a 48-bit VA, there are 7 bits of auth, and so
44
+ * STGP is defined as two 8-byte memory operations and one tag operation.
62
+ * a 1/128 chance of auth = pac(ptr,key,salt) producing zero.
45
+ * We implement it as one single 16-byte memory operation for convenience.
63
+ * Find a salt that creates auth != 0.
46
+ * Rebuild mop as for STP.
47
+ * TODO: The atomicity with LSE2 is stronger than required.
48
+ * Need a form of MO_ATOM_WITHIN16_PAIR that never requires
49
+ * 16-byte atomicity.
64
+ */
50
+ */
65
+ do {
51
+ mop = MO_128;
66
+ salt++;
52
+ if (s->align_mem) {
67
+ asm("pacda %0, %1" : "=r"(p1) : "r"(salt), "0"(p0));
53
+ mop |= MO_ALIGN_8;
68
+ } while (p0 == p1);
54
+ }
69
+
55
+ mop = finalize_memop_pair(s, mop);
70
+ /*
56
71
+ * This pac must fail, because the input pointer bears an encryption,
57
tmp = tcg_temp_new_i128();
72
+ * and so is not properly extended within bits [55:47]. This will
58
if (s->be_data == MO_LE) {
73
+ * toggle bit 54 in the output...
74
+ */
75
+ asm("pacda %0, %1" : "=r"(p2) : "r"(salt), "0"(p1));
76
+
77
+ /* ... so that the aut must fail, setting bit 53 in the output ... */
78
+ asm("autda %0, %1" : "=r"(p3) : "r"(salt), "0"(p2));
79
+
80
+ /* ... which means this equality must not hold. */
81
+ assert(p3 != p0);
82
+ return 0;
83
+}
84
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
85
index XXXXXXX..XXXXXXX 100644
86
--- a/tests/tcg/aarch64/Makefile.target
87
+++ b/tests/tcg/aarch64/Makefile.target
88
@@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt
89
90
# Pauth Tests
91
ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_ARMV8_3),)
92
-AARCH64_TESTS += pauth-1 pauth-2 pauth-4
93
+AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5
94
pauth-%: CFLAGS += -march=armv8.3-a
95
run-pauth-%: QEMU_OPTS += -cpu max
96
run-plugin-pauth-%: QEMU_OPTS += -cpu max
97
--
59
--
98
2.20.1
60
2.34.1
99
100
diff view generated by jsdifflib
1
The imx_epit device has a software-controllable reset triggered by
1
From: Akihiko Odaki <akihiko.odaki@daynix.com>
2
setting the SWR bit in the CR register. An error in commit cc2722ec83ad9
3
means that we will end up assert()ing if the guest does this, because
4
the code in imx_epit_write() starts ptimer transactions, and then
5
imx_epit_reset() also starts ptimer transactions, triggering
6
"ptimer_transaction_begin: Assertion `!s->in_transaction' failed".
7
2
8
The cleanest way to avoid this double-transaction is to move the
3
Prcb may be set to 0 for some CPUs if the dump was taken before they
9
start-transaction for the CR write handling down below the check of
4
start. The dump may still contain valuable information for started CPUs
10
the SWR bit.
5
so don't abandon conversion in such a case.
11
6
12
Fixes: https://bugs.launchpad.net/qemu/+bug/1880424
7
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
13
Fixes: cc2722ec83ad944505fe
8
Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
9
Message-id: 20230611033434.14659-1-akihiko.odaki@daynix.com
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Message-id: 20200727154550.3409-1-peter.maydell@linaro.org
17
---
11
---
18
hw/timer/imx_epit.c | 13 ++++++++++---
12
contrib/elf2dmp/main.c | 5 +++++
19
1 file changed, 10 insertions(+), 3 deletions(-)
13
1 file changed, 5 insertions(+)
20
14
21
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
15
diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c
22
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/timer/imx_epit.c
17
--- a/contrib/elf2dmp/main.c
24
+++ b/hw/timer/imx_epit.c
18
+++ b/contrib/elf2dmp/main.c
25
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
19
@@ -XXX,XX +XXX,XX @@ static int fill_context(KDDEBUGGER_DATA64 *kdbg,
26
20
return 1;
27
switch (offset >> 2) {
21
}
28
case 0: /* CR */
22
29
- ptimer_transaction_begin(s->timer_cmp);
23
+ if (!Prcb) {
30
- ptimer_transaction_begin(s->timer_reload);
24
+ eprintf("Context for CPU #%d is missing\n", i);
31
25
+ continue;
32
oldcr = s->cr;
33
s->cr = value & 0x03ffffff;
34
if (s->cr & CR_SWR) {
35
/* handle the reset */
36
imx_epit_reset(DEVICE(s));
37
- } else {
38
+ /*
39
+ * TODO: could we 'break' here? following operations appear
40
+ * to duplicate the work imx_epit_reset() already did.
41
+ */
42
+ }
26
+ }
43
+
27
+
44
+ ptimer_transaction_begin(s->timer_cmp);
28
if (va_space_rw(vs, Prcb + kdbg->OffsetPrcbContext,
45
+ ptimer_transaction_begin(s->timer_reload);
29
&Context, sizeof(Context), 0)) {
46
+
30
eprintf("Failed to read CPU #%d ContextFrame location\n", i);
47
+ if (!(s->cr & CR_SWR)) {
48
imx_epit_set_freq(s);
49
}
50
51
--
31
--
52
2.20.1
32
2.34.1
53
54
diff view generated by jsdifflib
1
The nrf51 SoC model wasn't setting the system_clock_scale
1
In commit 0b188ea05acb5 we changed the implementation of
2
global.which meant that if guest code used the systick timer in "use
2
trans_CSEL() to use tcg_constant_i32(). However, this change
3
the processor clock" mode it would hang because time never advances.
3
was incorrect, because the implementation of the function
4
sets up the TCGv_i32 rn and rm to be either zero or else
5
a TCG temp created in load_reg(), and these TCG temps are
6
then in both cases written to by the emitted TCG ops.
7
The result is that we hit a TCG assertion:
4
8
5
Set the global to match the documented CPU clock speed for this SoC.
9
qemu-system-arm: ../../tcg/tcg.c:4455: tcg_reg_alloc_mov: Assertion `!temp_readonly(ots)' failed.
6
10
7
This SoC in fact doesn't have a SysTick timer (which is the only thing
11
(or on a non-debug build, just produce a garbage result)
8
currently that cares about the system_clock_scale), because it's
9
a configurable option in the Cortex-M0. However our Cortex-M0 and
10
thus our nrf51 and our micro:bit board do provide a SysTick, so
11
we ought to provide a functional one rather than a broken one.
12
12
13
Adjust the code so that rn and rm are always writeable
14
temporaries whether the instruction is using the special
15
case "0" or a normal register as input.
16
17
Cc: qemu-stable@nongnu.org
18
Fixes: 0b188ea05acb5 ("target/arm: Use tcg_constant in trans_CSEL")
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20200727193458.31250-1-peter.maydell@linaro.org
21
Message-id: 20230727103906.2641264-1-peter.maydell@linaro.org
16
---
22
---
17
hw/arm/nrf51_soc.c | 5 +++++
23
target/arm/tcg/translate.c | 15 ++++++++-------
18
1 file changed, 5 insertions(+)
24
1 file changed, 8 insertions(+), 7 deletions(-)
19
25
20
diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c
26
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
21
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/nrf51_soc.c
28
--- a/target/arm/tcg/translate.c
23
+++ b/hw/arm/nrf51_soc.c
29
+++ b/target/arm/tcg/translate.c
24
@@ -XXX,XX +XXX,XX @@
30
@@ -XXX,XX +XXX,XX @@ static bool trans_IT(DisasContext *s, arg_IT *a)
25
31
/* v8.1M CSEL/CSINC/CSNEG/CSINV */
26
#define BASE_TO_IRQ(base) ((base >> 12) & 0x1F)
32
static bool trans_CSEL(DisasContext *s, arg_CSEL *a)
27
28
+/* HCLK (the main CPU clock) on this SoC is always 16MHz */
29
+#define HCLK_FRQ 16000000
30
+
31
static uint64_t clock_read(void *opaque, hwaddr addr, unsigned int size)
32
{
33
{
33
qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n",
34
- TCGv_i32 rn, rm, zero;
34
@@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
35
+ TCGv_i32 rn, rm;
35
return;
36
DisasCompare c;
37
38
if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) {
39
@@ -XXX,XX +XXX,XX @@ static bool trans_CSEL(DisasContext *s, arg_CSEL *a)
36
}
40
}
37
41
38
+ system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ;
42
/* In this insn input reg fields of 0b1111 mean "zero", not "PC" */
39
+
43
- zero = tcg_constant_i32(0);
40
object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container),
44
+ rn = tcg_temp_new_i32();
41
&error_abort);
45
+ rm = tcg_temp_new_i32();
42
if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) {
46
if (a->rn == 15) {
47
- rn = zero;
48
+ tcg_gen_movi_i32(rn, 0);
49
} else {
50
- rn = load_reg(s, a->rn);
51
+ load_reg_var(s, rn, a->rn);
52
}
53
if (a->rm == 15) {
54
- rm = zero;
55
+ tcg_gen_movi_i32(rm, 0);
56
} else {
57
- rm = load_reg(s, a->rm);
58
+ load_reg_var(s, rm, a->rm);
59
}
60
61
switch (a->op) {
62
@@ -XXX,XX +XXX,XX @@ static bool trans_CSEL(DisasContext *s, arg_CSEL *a)
63
}
64
65
arm_test_cc(&c, a->fcond);
66
- tcg_gen_movcond_i32(c.cond, rn, c.value, zero, rn, rm);
67
+ tcg_gen_movcond_i32(c.cond, rn, c.value, tcg_constant_i32(0), rn, rm);
68
69
store_reg(s, a->rd, rn);
70
return true;
43
--
71
--
44
2.20.1
72
2.34.1
45
46
diff view generated by jsdifflib
1
The MSF2 SoC model and the Stellaris board code both wire
1
Currently we list all the Arm decodetree files together and add them
2
SYSRESETREQ up to a function that just invokes
2
unconditionally to arm_ss. This means we build them for both
3
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
3
qemu-system-aarch64 and qemu-system-arm. However, some of them are
4
This is now the default action that the NVIC does if the line is
4
AArch64-specific, so there is no need to build them for
5
not connected, so we can delete the handling code.
5
qemu-system-arm. (Meson is smart enough to notice that the generated
6
.c.inc file is not used by any objects that go into qemu-system-arm,
7
so we only unnecessarily run decodetree, not anything more
8
heavyweight like a recompile or relink, but it's still unnecessary
9
work.)
10
11
Split gen into gen_a32 and gen_a64, and only add gen_a64 for
12
TARGET_AARCH64 compiles.
6
13
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
16
Message-id: 20230718104628.1137734-1-peter.maydell@linaro.org
10
Message-id: 20200728103744.6909-4-peter.maydell@linaro.org
11
---
17
---
12
hw/arm/msf2-soc.c | 11 -----------
18
target/arm/tcg/meson.build | 10 +++++++---
13
hw/arm/stellaris.c | 12 ------------
19
1 file changed, 7 insertions(+), 3 deletions(-)
14
2 files changed, 23 deletions(-)
15
20
16
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
21
diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build
17
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/msf2-soc.c
23
--- a/target/arm/tcg/meson.build
19
+++ b/hw/arm/msf2-soc.c
24
+++ b/target/arm/tcg/meson.build
20
@@ -XXX,XX +XXX,XX @@
25
@@ -XXX,XX +XXX,XX @@
21
#include "hw/irq.h"
26
-gen = [
22
#include "hw/arm/msf2-soc.h"
27
+gen_a64 = [
23
#include "hw/misc/unimp.h"
28
+ decodetree.process('a64.decode', extra_args: ['--static-decode=disas_a64']),
24
-#include "sysemu/runstate.h"
29
decodetree.process('sve.decode', extra_args: '--decode=disas_sve'),
25
#include "sysemu/sysemu.h"
30
decodetree.process('sme.decode', extra_args: '--decode=disas_sme'),
26
31
decodetree.process('sme-fa64.decode', extra_args: '--static-decode=disas_sme_fa64'),
27
#define MSF2_TIMER_BASE 0x40004000
32
+]
28
@@ -XXX,XX +XXX,XX @@ static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 };
33
+
29
static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 };
34
+gen_a32 = [
30
static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 };
35
decodetree.process('neon-shared.decode', extra_args: '--decode=disas_neon_shared'),
31
36
decodetree.process('neon-dp.decode', extra_args: '--decode=disas_neon_dp'),
32
-static void do_sys_reset(void *opaque, int n, int level)
37
decodetree.process('neon-ls.decode', extra_args: '--decode=disas_neon_ls'),
33
-{
38
@@ -XXX,XX +XXX,XX @@ gen = [
34
- if (level) {
39
decodetree.process('a32-uncond.decode', extra_args: '--static-decode=disas_a32_uncond'),
35
- qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
40
decodetree.process('t32.decode', extra_args: '--static-decode=disas_t32'),
36
- }
41
decodetree.process('t16.decode', extra_args: ['-w', '16', '--static-decode=disas_t16']),
37
-}
42
- decodetree.process('a64.decode', extra_args: ['--static-decode=disas_a64']),
38
-
43
]
39
static void m2sxxx_soc_initfn(Object *obj)
44
40
{
45
-arm_ss.add(gen)
41
MSF2State *s = MSF2_SOC(obj);
46
+arm_ss.add(gen_a32)
42
@@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
47
+arm_ss.add(when: 'TARGET_AARCH64', if_true: gen_a64)
43
return;
48
44
}
49
arm_ss.add(files(
45
50
'cpu32.c',
46
- qdev_connect_gpio_out_named(DEVICE(&s->armv7m.nvic), "SYSRESETREQ", 0,
47
- qemu_allocate_irq(&do_sys_reset, NULL, 0));
48
-
49
system_clock_scale = NANOSECONDS_PER_SECOND / s->m3clk;
50
51
for (i = 0; i < MSF2_NUM_UARTS; i++) {
52
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
53
index XXXXXXX..XXXXXXX 100644
54
--- a/hw/arm/stellaris.c
55
+++ b/hw/arm/stellaris.c
56
@@ -XXX,XX +XXX,XX @@
57
#include "hw/boards.h"
58
#include "qemu/log.h"
59
#include "exec/address-spaces.h"
60
-#include "sysemu/runstate.h"
61
#include "sysemu/sysemu.h"
62
#include "hw/arm/armv7m.h"
63
#include "hw/char/pl011.h"
64
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_init(Object *obj)
65
qdev_init_gpio_in(dev, stellaris_adc_trigger, 1);
66
}
67
68
-static
69
-void do_sys_reset(void *opaque, int n, int level)
70
-{
71
- if (level) {
72
- qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
73
- }
74
-}
75
-
76
/* Board init. */
77
static stellaris_board_info stellaris_boards[] = {
78
{ "LM3S811EVB",
79
@@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
80
/* This will exit with an error if the user passed us a bad cpu_type */
81
sysbus_realize_and_unref(SYS_BUS_DEVICE(nvic), &error_fatal);
82
83
- qdev_connect_gpio_out_named(nvic, "SYSRESETREQ", 0,
84
- qemu_allocate_irq(&do_sys_reset, NULL, 0));
85
-
86
if (board->dc1 & (1 << 16)) {
87
dev = sysbus_create_varargs(TYPE_STELLARIS_ADC, 0x40038000,
88
qdev_get_gpio_in(nvic, 14),
89
--
51
--
90
2.20.1
52
2.34.1
91
53
92
54
diff view generated by jsdifflib
1
From: Kaige Li <likaige@loongson.cn>
1
From: Gavin Shan <gshan@redhat.com>
2
2
3
GCC version 4.9.4 isn't clever enough to figure out that all
3
Runs into core dump on arm64 and the backtrace extracted from the
4
execution paths in disas_ldst() that use 'fn' will have initialized
4
core dump is shown as below. It's caused by accessing uninitialized
5
it first, and so it warns:
5
@kvm_state in kvm_flush_coalesced_mmio_buffer() due to commit 176d073029
6
("hw/arm/virt: Use machine_memory_devices_init()"), where the machine's
7
memory region is added earlier than before.
6
8
7
/home/LiKaige/qemu/target/arm/translate-a64.c: In function ‘disas_ldst’:
9
main
8
/home/LiKaige/qemu/target/arm/translate-a64.c:3392:5: error: ‘fn’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
10
qemu_init
9
fn(cpu_reg(s, rt), clean_addr, tcg_rs, get_mem_index(s),
11
configure_accelerators
10
^
12
qemu_opts_foreach
11
/home/LiKaige/qemu/target/arm/translate-a64.c:3318:22: note: ‘fn’ was declared here
13
do_configure_accelerator
12
AtomicThreeOpFn *fn;
14
accel_init_machine
13
^
15
kvm_init
16
virt_kvm_type
17
virt_set_memmap
18
machine_memory_devices_init
19
memory_region_add_subregion
20
memory_region_add_subregion_common
21
memory_region_update_container_subregions
22
memory_region_transaction_begin
23
qemu_flush_coalesced_mmio_buffer
24
kvm_flush_coalesced_mmio_buffer
14
25
15
Make it happy by initializing the variable to NULL.
26
Fix it by bailing early in kvm_flush_coalesced_mmio_buffer() on the
27
uninitialized @kvm_state. With this applied, no crash is observed on
28
arm64.
16
29
17
Signed-off-by: Kaige Li <likaige@loongson.cn>
30
Fixes: 176d073029 ("hw/arm/virt: Use machine_memory_devices_init()")
18
Message-id: 1596110248-7366-2-git-send-email-likaige@loongson.cn
31
Signed-off-by: Gavin Shan <gshan@redhat.com>
19
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
32
Reviewed-by: David Hildenbrand <david@redhat.com>
20
[PMM: Clean up commit message and note which gcc version this was]
33
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
34
Message-id: 20230731125946.2038742-1-gshan@redhat.com
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
35
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
36
---
23
target/arm/translate-a64.c | 2 +-
37
accel/kvm/kvm-all.c | 2 +-
24
1 file changed, 1 insertion(+), 1 deletion(-)
38
1 file changed, 1 insertion(+), 1 deletion(-)
25
39
26
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
40
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
27
index XXXXXXX..XXXXXXX 100644
41
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/translate-a64.c
42
--- a/accel/kvm/kvm-all.c
29
+++ b/target/arm/translate-a64.c
43
+++ b/accel/kvm/kvm-all.c
30
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn,
44
@@ -XXX,XX +XXX,XX @@ void kvm_flush_coalesced_mmio_buffer(void)
31
bool r = extract32(insn, 22, 1);
45
{
32
bool a = extract32(insn, 23, 1);
46
KVMState *s = kvm_state;
33
TCGv_i64 tcg_rs, clean_addr;
47
34
- AtomicThreeOpFn *fn;
48
- if (s->coalesced_flush_in_progress) {
35
+ AtomicThreeOpFn *fn = NULL;
49
+ if (!s || s->coalesced_flush_in_progress) {
36
50
return;
37
if (is_vector || !dc_isar_feature(aa64_atomics, s)) {
51
}
38
unallocated_encoding(s);
52
39
--
53
--
40
2.20.1
54
2.34.1
41
55
42
56
diff view generated by jsdifflib
1
Mostly devices don't need to care whether one of their output
1
From: Nicholas Piggin <npiggin@gmail.com>
2
qemu_irq lines is connected, because functions like qemu_set_irq()
3
silently do nothing if there is nothing on the other end. However
4
sometimes a device might want to implement default behaviour for the
5
case where the machine hasn't wired the line up to anywhere.
6
2
7
Provide a function qemu_irq_is_connected() that devices can use for
3
The gdb remote protocol has a special interrupt character (0x03) that is
8
this purpose. (The test is trivial but encapsulating it in a
4
transmitted outside the regular packet processing, and represents a
9
function makes it easier to see where we're doing it in case we need
5
Ctrl-C pressed in the client. Despite not being a regular packet, it
10
to change the implementation later.)
6
does expect a regular stop response if the stub successfully stops the
7
running program.
11
8
9
See: https://sourceware.org/gdb/onlinedocs/gdb/Interrupts.html
10
11
Inhibiting the stop reply packet can lead to gdb client hang. So permit
12
a stop response when receiving a character from gdb that stops the vm.
13
Additionally, add a warning if that was not a 0x03 character, because
14
the gdb session is likely to end up getting confused if this happens.
15
16
Cc: qemu-stable@nongnu.org
17
Fixes: 758370052fb ("gdbstub: only send stop-reply packets when allowed to")
18
Reported-by: Frederic Barrat <fbarrat@linux.ibm.com>
19
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
20
Tested-by: Joel Stanley <joel@jms.id.au>
21
Message-id: 20230711085903.304496-1-npiggin@gmail.com
22
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
15
Message-id: 20200728103744.6909-2-peter.maydell@linaro.org
16
---
24
---
17
include/hw/irq.h | 18 ++++++++++++++++++
25
gdbstub/gdbstub.c | 13 +++++++++++--
18
1 file changed, 18 insertions(+)
26
1 file changed, 11 insertions(+), 2 deletions(-)
19
27
20
diff --git a/include/hw/irq.h b/include/hw/irq.h
28
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
21
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/irq.h
30
--- a/gdbstub/gdbstub.c
23
+++ b/include/hw/irq.h
31
+++ b/gdbstub/gdbstub.c
24
@@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2);
32
@@ -XXX,XX +XXX,XX @@ void gdb_read_byte(uint8_t ch)
25
on an existing vector of qemu_irq. */
33
return;
26
void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n);
34
}
27
35
if (runstate_is_running()) {
28
+/**
36
- /* when the CPU is running, we cannot do anything except stop
29
+ * qemu_irq_is_connected: Return true if IRQ line is wired up
37
- it when receiving a char */
30
+ *
38
+ /*
31
+ * If a qemu_irq has a device on the other (receiving) end of it,
39
+ * When the CPU is running, we cannot do anything except stop
32
+ * return true; otherwise return false.
40
+ * it when receiving a char. This is expected on a Ctrl-C in the
33
+ *
41
+ * gdb client. Because we are in all-stop mode, gdb sends a
34
+ * Usually device models don't need to care whether the machine model
42
+ * 0x03 byte which is not a usual packet, so we handle it specially
35
+ * has wired up their outbound qemu_irq lines, because functions like
43
+ * here, but it does expect a stop reply.
36
+ * qemu_set_irq() silently do nothing if there is nothing on the other
44
+ */
37
+ * end of the line. However occasionally a device model will want to
45
+ if (ch != 0x03) {
38
+ * provide default behaviour if its output is left floating, and
46
+ warn_report("gdbstub: client sent packet while target running\n");
39
+ * it can use this function to identify when that is the case.
47
+ }
40
+ */
48
+ gdbserver_state.allow_stop_reply = true;
41
+static inline bool qemu_irq_is_connected(qemu_irq irq)
49
vm_stop(RUN_STATE_PAUSED);
42
+{
50
} else
43
+ return irq != NULL;
44
+}
45
+
46
#endif
51
#endif
47
--
52
--
48
2.20.1
53
2.34.1
49
50
diff view generated by jsdifflib
Deleted patch
1
The NVIC provides an outbound qemu_irq "SYSRESETREQ" which it signals
2
when the guest sets the SYSRESETREQ bit in the AIRCR register. This
3
matches the hardware design (where the CPU has a signal of this name
4
and it is up to the SoC to connect that up to an actual reset
5
mechanism), but in QEMU it mostly results in duplicated code in SoC
6
objects and bugs where SoC model implementors forget to wire up the
7
SYSRESETREQ line.
8
1
9
Provide a default behaviour for the case where SYSRESETREQ is not
10
actually connected to anything: use qemu_system_reset_request() to
11
perform a system reset. This will allow us to remove the
12
implementations of SYSRESETREQ handling from the boards where that's
13
exactly what it does, and also fixes the bugs in the board models
14
which forgot to wire up the signal:
15
16
* microbit
17
* mps2-an385
18
* mps2-an505
19
* mps2-an511
20
* mps2-an521
21
* musca-a
22
* musca-b1
23
* netduino
24
* netduinoplus2
25
26
We still allow the board to wire up the signal if it needs to, in case
27
we need to model more complicated reset controller logic or to model
28
buggy SoC hardware which forgot to wire up the line itself. But
29
defaulting to "reset the system" is more often going to be correct
30
than defaulting to "do nothing".
31
32
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
33
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
34
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
35
Message-id: 20200728103744.6909-3-peter.maydell@linaro.org
36
---
37
include/hw/arm/armv7m.h | 4 +++-
38
hw/intc/armv7m_nvic.c | 17 ++++++++++++++++-
39
2 files changed, 19 insertions(+), 2 deletions(-)
40
41
diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h
42
index XXXXXXX..XXXXXXX 100644
43
--- a/include/hw/arm/armv7m.h
44
+++ b/include/hw/arm/armv7m.h
45
@@ -XXX,XX +XXX,XX @@ typedef struct {
46
47
/* ARMv7M container object.
48
* + Unnamed GPIO input lines: external IRQ lines for the NVIC
49
- * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ
50
+ * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ.
51
+ * If this GPIO is not wired up then the NVIC will default to performing
52
+ * a qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET).
53
* + Property "cpu-type": CPU type to instantiate
54
* + Property "num-irq": number of external IRQ lines
55
* + Property "memory": MemoryRegion defining the physical address space
56
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
57
index XXXXXXX..XXXXXXX 100644
58
--- a/hw/intc/armv7m_nvic.c
59
+++ b/hw/intc/armv7m_nvic.c
60
@@ -XXX,XX +XXX,XX @@
61
#include "hw/intc/armv7m_nvic.h"
62
#include "hw/irq.h"
63
#include "hw/qdev-properties.h"
64
+#include "sysemu/runstate.h"
65
#include "target/arm/cpu.h"
66
#include "exec/exec-all.h"
67
#include "exec/memop.h"
68
@@ -XXX,XX +XXX,XX @@ static const uint8_t nvic_id[] = {
69
0x00, 0xb0, 0x1b, 0x00, 0x0d, 0xe0, 0x05, 0xb1
70
};
71
72
+static void signal_sysresetreq(NVICState *s)
73
+{
74
+ if (qemu_irq_is_connected(s->sysresetreq)) {
75
+ qemu_irq_pulse(s->sysresetreq);
76
+ } else {
77
+ /*
78
+ * Default behaviour if the SoC doesn't need to wire up
79
+ * SYSRESETREQ (eg to a system reset controller of some kind):
80
+ * perform a system reset via the usual QEMU API.
81
+ */
82
+ qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
83
+ }
84
+}
85
+
86
static int nvic_pending_prio(NVICState *s)
87
{
88
/* return the group priority of the current pending interrupt,
89
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
90
if (value & R_V7M_AIRCR_SYSRESETREQ_MASK) {
91
if (attrs.secure ||
92
!(cpu->env.v7m.aircr & R_V7M_AIRCR_SYSRESETREQS_MASK)) {
93
- qemu_irq_pulse(s->sysresetreq);
94
+ signal_sysresetreq(s);
95
}
96
}
97
if (value & R_V7M_AIRCR_VECTCLRACTIVE_MASK) {
98
--
99
2.20.1
100
101
diff view generated by jsdifflib