1
Handful of bugfixes for rc2. None of these are particularly critical
1
The following changes since commit efcd0ec14b0fe9ee0ee70277763b2d538d19238d:
2
or exciting.
3
2
4
-- PMM
3
Merge tag 'misc-fixes-20230330' of https://github.com/philmd/qemu into staging (2023-03-30 14:22:29 +0100)
5
6
The following changes since commit 45a150aa2b3492acf6691c7bdbeb25a8545d8345:
7
8
Merge remote-tracking branch 'remotes/ericb/tags/pull-bitmaps-2020-08-03' into staging (2020-08-03 15:13:49 +0100)
9
4
10
are available in the Git repository at:
5
are available in the Git repository at:
11
6
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200803
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230403
13
8
14
for you to fetch changes up to 13557fd392890cbd985bceba7f717e01efd674b8:
9
for you to fetch changes up to a0eaa126af3c5a43937a22c58cfb9bb36e4a5001:
15
10
16
hw/timer/imx_epit: Avoid assertion when CR.SWR is written (2020-08-03 17:56:11 +0100)
11
hw/ssi: Fix Linux driver init issue with xilinx_spi (2023-04-03 16:12:30 +0100)
17
12
18
----------------------------------------------------------------
13
----------------------------------------------------------------
19
target-arm queue:
14
* target/arm: Fix non-TCG build failure by inlining pauth_ptr_mask()
20
* hw/timer/imx_epit: Avoid assertion when CR.SWR is written
15
* hw/arm: do not free machine->fdt in arm_load_dtb()
21
* netduino2, netduinoplus2, microbit: set system_clock_scale so that
16
* target/arm: Fix generated code for cpreg reads when HSTR is active
22
SysTick running on the CPU clock works
17
* hw/ssi: Fix Linux driver init issue with xilinx_spi
23
* target/arm: Avoid maybe-uninitialized warning with gcc 4.9
24
* target/arm: Fix AddPAC error indication
25
* Make AIRCR.SYSRESETREQ actually reset the system for the
26
microbit, mps2-*, musca-*, netduino* boards
27
18
28
----------------------------------------------------------------
19
----------------------------------------------------------------
29
Kaige Li (1):
20
Chris Rauer (1):
30
target/arm: Avoid maybe-uninitialized warning with gcc 4.9
21
hw/ssi: Fix Linux driver init issue with xilinx_spi
31
22
32
Peter Maydell (6):
23
Markus Armbruster (1):
33
hw/arm/netduino2, netduinoplus2: Set system_clock_scale
24
hw/arm: do not free machine->fdt in arm_load_dtb()
34
include/hw/irq.h: New function qemu_irq_is_connected()
35
hw/intc/armv7m_nvic: Provide default "reset the system" behaviour for SYSRESETREQ
36
msf2-soc, stellaris: Don't wire up SYSRESETREQ
37
hw/arm/nrf51_soc: Set system_clock_scale
38
hw/timer/imx_epit: Avoid assertion when CR.SWR is written
39
25
40
Richard Henderson (1):
26
Peter Maydell (1):
41
target/arm: Fix AddPAC error indication
27
target/arm: Fix generated code for cpreg reads when HSTR is active
42
28
43
include/hw/arm/armv7m.h | 4 +++-
29
Philippe Mathieu-Daudé (1):
44
include/hw/irq.h | 18 ++++++++++++++++++
30
target/arm: Fix non-TCG build failure by inlining pauth_ptr_mask()
45
hw/arm/msf2-soc.c | 11 -----------
46
hw/arm/netduino2.c | 10 ++++++++++
47
hw/arm/netduinoplus2.c | 10 ++++++++++
48
hw/arm/nrf51_soc.c | 5 +++++
49
hw/arm/stellaris.c | 12 ------------
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
31
32
target/arm/internals.h | 15 ++++++++++-----
33
hw/arm/boot.c | 5 ++++-
34
hw/ssi/xilinx_spi.c | 1 +
35
target/arm/gdbstub64.c | 7 +++++--
36
target/arm/tcg/pauth_helper.c | 18 +-----------------
37
target/arm/tcg/translate.c | 6 ++++++
38
6 files changed, 27 insertions(+), 25 deletions(-)
39
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
Deleted patch
1
Mostly devices don't need to care whether one of their output
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
1
7
Provide a function qemu_irq_is_connected() that devices can use for
8
this purpose. (The test is trivial but encapsulating it in a
9
function makes it easier to see where we're doing it in case we need
10
to change the implementation later.)
11
12
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
---
17
include/hw/irq.h | 18 ++++++++++++++++++
18
1 file changed, 18 insertions(+)
19
20
diff --git a/include/hw/irq.h b/include/hw/irq.h
21
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/irq.h
23
+++ b/include/hw/irq.h
24
@@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2);
25
on an existing vector of qemu_irq. */
26
void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n);
27
28
+/**
29
+ * qemu_irq_is_connected: Return true if IRQ line is wired up
30
+ *
31
+ * If a qemu_irq has a device on the other (receiving) end of it,
32
+ * return true; otherwise return false.
33
+ *
34
+ * Usually device models don't need to care whether the machine model
35
+ * has wired up their outbound qemu_irq lines, because functions like
36
+ * qemu_set_irq() silently do nothing if there is nothing on the other
37
+ * end of the line. However occasionally a device model will want to
38
+ * provide default behaviour if its output is left floating, and
39
+ * it can use this function to identify when that is the case.
40
+ */
41
+static inline bool qemu_irq_is_connected(qemu_irq irq)
42
+{
43
+ return irq != NULL;
44
+}
45
+
46
#endif
47
--
48
2.20.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
1
The MSF2 SoC model and the Stellaris board code both wire
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
SYSRESETREQ up to a function that just invokes
3
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
4
This is now the default action that the NVIC does if the line is
5
not connected, so we can delete the handling code.
6
2
3
aarch64_gdb_get_pauth_reg() -- although disabled since commit
4
5787d17a42 ("target/arm: Don't advertise aarch64-pauth.xml to
5
gdb") is still compiled in. It calls pauth_ptr_mask() which is
6
located in target/arm/tcg/pauth_helper.c, a TCG specific helper.
7
8
To avoid a linking error when TCG is not enabled:
9
10
Undefined symbols for architecture arm64:
11
"_pauth_ptr_mask", referenced from:
12
_aarch64_gdb_get_pauth_reg in target_arm_gdbstub64.c.o
13
ld: symbol(s) not found for architecture arm64
14
clang: error: linker command failed with exit code 1 (use -v to see invocation)
15
16
- Inline pauth_ptr_mask() in aarch64_gdb_get_pauth_reg()
17
(this is the single user),
18
- Rename pauth_ptr_mask_internal() as pauth_ptr_mask() and
19
inline it in "internals.h",
20
21
Fixes: e995d5cce4 ("target/arm: Implement gdbstub pauth extension")
22
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
23
Reviewed-by: Fabiano Rosas <farosas@suse.de>
24
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
25
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
26
Message-id: 20230328212516.29592-1-philmd@linaro.org
27
[PMM: reinstated doc comment]
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Message-id: 20200728103744.6909-4-peter.maydell@linaro.org
11
---
29
---
12
hw/arm/msf2-soc.c | 11 -----------
30
target/arm/internals.h | 15 ++++++++++-----
13
hw/arm/stellaris.c | 12 ------------
31
target/arm/gdbstub64.c | 7 +++++--
14
2 files changed, 23 deletions(-)
32
target/arm/tcg/pauth_helper.c | 18 +-----------------
33
3 files changed, 16 insertions(+), 24 deletions(-)
15
34
16
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
35
diff --git a/target/arm/internals.h b/target/arm/internals.h
17
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/msf2-soc.c
37
--- a/target/arm/internals.h
19
+++ b/hw/arm/msf2-soc.c
38
+++ b/target/arm/internals.h
20
@@ -XXX,XX +XXX,XX @@
39
@@ -XXX,XX +XXX,XX @@ bool arm_generate_debug_exceptions(CPUARMState *env);
21
#include "hw/irq.h"
40
22
#include "hw/arm/msf2-soc.h"
41
/**
23
#include "hw/misc/unimp.h"
42
* pauth_ptr_mask:
24
-#include "sysemu/runstate.h"
43
- * @env: cpu context
25
#include "sysemu/sysemu.h"
44
- * @ptr: selects between TTBR0 and TTBR1
26
45
- * @data: selects between TBI and TBID
27
#define MSF2_TIMER_BASE 0x40004000
46
+ * @param: parameters defining the MMU setup
28
@@ -XXX,XX +XXX,XX @@ static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 };
47
*
29
static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 };
48
- * Return a mask of the bits of @ptr that contain the authentication code.
30
static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 };
49
+ * Return a mask of the address bits that contain the authentication code,
31
50
+ * given the MMU config defined by @param.
32
-static void do_sys_reset(void *opaque, int n, int level)
51
*/
52
-uint64_t pauth_ptr_mask(CPUARMState *env, uint64_t ptr, bool data);
53
+static inline uint64_t pauth_ptr_mask(ARMVAParameters param)
54
+{
55
+ int bot_pac_bit = 64 - param.tsz;
56
+ int top_pac_bit = 64 - 8 * param.tbi;
57
+
58
+ return MAKE_64BIT_MASK(bot_pac_bit, top_pac_bit - bot_pac_bit);
59
+}
60
61
/* Add the cpreg definitions for debug related system registers */
62
void define_debug_regs(ARMCPU *cpu);
63
diff --git a/target/arm/gdbstub64.c b/target/arm/gdbstub64.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/target/arm/gdbstub64.c
66
+++ b/target/arm/gdbstub64.c
67
@@ -XXX,XX +XXX,XX @@ int aarch64_gdb_get_pauth_reg(CPUARMState *env, GByteArray *buf, int reg)
68
{
69
bool is_data = !(reg & 1);
70
bool is_high = reg & 2;
71
- uint64_t mask = pauth_ptr_mask(env, -is_high, is_data);
72
- return gdb_get_reg64(buf, mask);
73
+ ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env);
74
+ ARMVAParameters param;
75
+
76
+ param = aa64_va_parameters(env, -is_high, mmu_idx, is_data);
77
+ return gdb_get_reg64(buf, pauth_ptr_mask(param));
78
}
79
default:
80
return 0;
81
diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c
82
index XXXXXXX..XXXXXXX 100644
83
--- a/target/arm/tcg/pauth_helper.c
84
+++ b/target/arm/tcg/pauth_helper.c
85
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,
86
return pac | ext | ptr;
87
}
88
89
-static uint64_t pauth_ptr_mask_internal(ARMVAParameters param)
33
-{
90
-{
34
- if (level) {
91
- int bot_pac_bit = 64 - param.tsz;
35
- qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
92
- int top_pac_bit = 64 - 8 * param.tbi;
36
- }
93
-
94
- return MAKE_64BIT_MASK(bot_pac_bit, top_pac_bit - bot_pac_bit);
37
-}
95
-}
38
-
96
-
39
static void m2sxxx_soc_initfn(Object *obj)
97
static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param)
40
{
98
{
41
MSF2State *s = MSF2_SOC(obj);
99
- uint64_t mask = pauth_ptr_mask_internal(param);
42
@@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
100
+ uint64_t mask = pauth_ptr_mask(param);
43
return;
101
102
/* Note that bit 55 is used whether or not the regime has 2 ranges. */
103
if (extract64(ptr, 55, 1)) {
104
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param)
44
}
105
}
45
106
}
46
- qdev_connect_gpio_out_named(DEVICE(&s->armv7m.nvic), "SYSRESETREQ", 0,
107
47
- qemu_allocate_irq(&do_sys_reset, NULL, 0));
108
-uint64_t pauth_ptr_mask(CPUARMState *env, uint64_t ptr, bool data)
109
-{
110
- ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env);
111
- ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data);
48
-
112
-
49
system_clock_scale = NANOSECONDS_PER_SECOND / s->m3clk;
113
- return pauth_ptr_mask_internal(param);
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
-}
114
-}
75
-
115
-
76
/* Board init. */
116
static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier,
77
static stellaris_board_info stellaris_boards[] = {
117
ARMPACKey *key, bool data, int keynumber)
78
{ "LM3S811EVB",
118
{
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
--
119
--
90
2.20.1
120
2.34.1
91
121
92
122
diff view generated by jsdifflib
Deleted patch
1
From: Richard Henderson <richard.henderson@linaro.org>
2
1
3
The definition of top_bit used in this function is one higher
4
than that used in the Arm ARM psuedo-code, which put the error
5
indication at top_bit - 1 at the wrong place, which meant that
6
it wasn't visible to Auth.
7
8
Fixing the definition of top_bit requires more changes, because
9
its most common use is for the count of bits in top_bit:bot_bit,
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>
17
Message-id: 20200728195706.11087-1-richard.henderson@linaro.org
18
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>
21
---
22
target/arm/pauth_helper.c | 6 +++++-
23
tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++
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
28
diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/pauth_helper.c
31
+++ b/target/arm/pauth_helper.c
32
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,
33
*/
34
test = sextract64(ptr, bot_bit, top_bit - bot_bit);
35
if (test != 0 && test != -1) {
36
- pac ^= MAKE_64BIT_MASK(top_bit - 1, 1);
37
+ /*
38
+ * Note that our top_bit is one greater than the pseudocode's
39
+ * version, hence "- 2" here.
40
+ */
41
+ pac ^= MAKE_64BIT_MASK(top_bit - 2, 1);
42
}
43
44
/*
45
diff --git a/tests/tcg/aarch64/pauth-5.c b/tests/tcg/aarch64/pauth-5.c
46
new file mode 100644
47
index XXXXXXX..XXXXXXX
48
--- /dev/null
49
+++ b/tests/tcg/aarch64/pauth-5.c
50
@@ -XXX,XX +XXX,XX @@
51
+#include <assert.h>
52
+
53
+static int x;
54
+
55
+int main()
56
+{
57
+ int *p0 = &x, *p1, *p2, *p3;
58
+ unsigned long salt = 0;
59
+
60
+ /*
61
+ * With TBI enabled and a 48-bit VA, there are 7 bits of auth, and so
62
+ * a 1/128 chance of auth = pac(ptr,key,salt) producing zero.
63
+ * Find a salt that creates auth != 0.
64
+ */
65
+ do {
66
+ salt++;
67
+ asm("pacda %0, %1" : "=r"(p1) : "r"(salt), "0"(p0));
68
+ } while (p0 == p1);
69
+
70
+ /*
71
+ * This pac must fail, because the input pointer bears an encryption,
72
+ * and so is not properly extended within bits [55:47]. This will
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
--
98
2.20.1
99
100
diff view generated by jsdifflib
1
The imx_epit device has a software-controllable reset triggered by
1
From: Markus Armbruster <armbru@redhat.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
At this moment, arm_load_dtb() can free machine->fdt when
9
start-transaction for the CR write handling down below the check of
4
binfo->dtb_filename is NULL. If there's no 'dtb_filename', 'fdt' will be
10
the SWR bit.
5
retrieved by binfo->get_dtb(). If get_dtb() returns machine->fdt, as is
6
the case of machvirt_dtb() from hw/arm/virt.c, fdt now has a pointer to
7
machine->fdt. And, in that case, the existing g_free(fdt) at the end of
8
arm_load_dtb() will make machine->fdt point to an invalid memory region.
11
9
12
Fixes: https://bugs.launchpad.net/qemu/+bug/1880424
10
Since monitor command 'dumpdtb' was introduced a couple of releases
13
Fixes: cc2722ec83ad944505fe
11
ago, running it with any ARM machine that uses arm_load_dtb() will
12
crash QEMU.
13
14
Let's enable all arm_load_dtb() callers to use dumpdtb properly. Instead
15
of freeing 'fdt', assign it back to ms->fdt.
16
17
Cc: Peter Maydell <peter.maydell@linaro.org>
18
Cc: qemu-arm@nongnu.org
19
Fixes: bf353ad55590f ("qmp/hmp, device_tree.c: introduce dumpdtb")
20
Reported-by: Markus Armbruster <armbru@redhat.com>
21
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
22
Signed-off-by: Markus Armbruster <armbru@redhat.com>
23
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
24
Message-id: 20230328165935.1512846-1-armbru@redhat.com
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
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
---
26
---
18
hw/timer/imx_epit.c | 13 ++++++++++---
27
hw/arm/boot.c | 5 ++++-
19
1 file changed, 10 insertions(+), 3 deletions(-)
28
1 file changed, 4 insertions(+), 1 deletion(-)
20
29
21
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
30
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
22
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/timer/imx_epit.c
32
--- a/hw/arm/boot.c
24
+++ b/hw/timer/imx_epit.c
33
+++ b/hw/arm/boot.c
25
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
34
@@ -XXX,XX +XXX,XX @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
26
35
qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds,
27
switch (offset >> 2) {
36
rom_ptr_for_as(as, addr, size));
28
case 0: /* CR */
37
29
- ptimer_transaction_begin(s->timer_cmp);
38
- g_free(fdt);
30
- ptimer_transaction_begin(s->timer_reload);
39
+ if (fdt != ms->fdt) {
31
40
+ g_free(ms->fdt);
32
oldcr = s->cr;
41
+ ms->fdt = fdt;
33
s->cr = value & 0x03ffffff;
42
+ }
34
if (s->cr & CR_SWR) {
43
35
/* handle the reset */
44
return size;
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
+ }
43
+
44
+ ptimer_transaction_begin(s->timer_cmp);
45
+ ptimer_transaction_begin(s->timer_reload);
46
+
47
+ if (!(s->cr & CR_SWR)) {
48
imx_epit_set_freq(s);
49
}
50
45
51
--
46
--
52
2.20.1
47
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 049edada we added some code to handle HSTR_EL2 traps, which
2
global.which meant that if guest code used the systick timer in "use
2
we did as an inline "conditionally branch over a
3
the processor clock" mode it would hang because time never advances.
3
gen_exception_insn()". Unfortunately this fails to take account of
4
the fact that gen_exception_insn() will set s->base.is_jmp to
5
DISAS_NORETURN. That means that at the end of the TB we won't
6
generate the necessary code to handle the "branched over the trap and
7
continued normal execution" codepath. The result is that the TCG
8
main loop thinks that we stopped execution of the TB due to a
9
situation that only happens when icount is enabled, and hits an
10
assertion. Explicitly set is_jmp back to DISAS_NEXT so we generate
11
the correct code for when execution continues past this insn.
4
12
5
Set the global to match the documented CPU clock speed for this SoC.
13
Note that this only happens for cpreg reads; writes will call
14
gen_lookup_tb() which generates a valid end-of-TB.
6
15
7
This SoC in fact doesn't have a SysTick timer (which is the only thing
16
Fixes: 049edada ("target/arm: Make HSTR_EL2 traps take priority over UNDEF-at-EL1")
8
currently that cares about the system_clock_scale), because it's
17
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1551
9
a configurable option in the Cortex-M0. However our Cortex-M0 and
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
thus our nrf51 and our micro:bit board do provide a SysTick, so
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
we ought to provide a functional one rather than a broken one.
20
Message-id: 20230330101900.2320380-1-peter.maydell@linaro.org
21
---
22
target/arm/tcg/translate.c | 6 ++++++
23
1 file changed, 6 insertions(+)
12
24
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20200727193458.31250-1-peter.maydell@linaro.org
16
---
17
hw/arm/nrf51_soc.c | 5 +++++
18
1 file changed, 5 insertions(+)
19
20
diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c
21
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/nrf51_soc.c
27
--- a/target/arm/tcg/translate.c
23
+++ b/hw/arm/nrf51_soc.c
28
+++ b/target/arm/tcg/translate.c
24
@@ -XXX,XX +XXX,XX @@
29
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
25
30
tcg_gen_brcondi_i32(TCG_COND_EQ, t, 0, over.label);
26
#define BASE_TO_IRQ(base) ((base >> 12) & 0x1F)
31
27
32
gen_exception_insn(s, 0, EXCP_UDEF, syndrome);
28
+/* HCLK (the main CPU clock) on this SoC is always 16MHz */
33
+ /*
29
+#define HCLK_FRQ 16000000
34
+ * gen_exception_insn() will set is_jmp to DISAS_NORETURN,
30
+
35
+ * but since we're conditionally branching over it, we want
31
static uint64_t clock_read(void *opaque, hwaddr addr, unsigned int size)
36
+ * to assume continue-to-next-instruction.
32
{
37
+ */
33
qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n",
38
+ s->base.is_jmp = DISAS_NEXT;
34
@@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
39
set_disas_label(s, over);
35
return;
40
}
36
}
41
}
37
38
+ system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ;
39
+
40
object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container),
41
&error_abort);
42
if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) {
43
--
42
--
44
2.20.1
43
2.34.1
45
46
diff view generated by jsdifflib
1
From: Kaige Li <likaige@loongson.cn>
1
From: Chris Rauer <crauer@google.com>
2
2
3
GCC version 4.9.4 isn't clever enough to figure out that all
3
The problem is that the Linux driver expects the master transaction inhibit
4
execution paths in disas_ldst() that use 'fn' will have initialized
4
bit(R_SPICR_MTI) to be set during driver initialization so that it can
5
it first, and so it warns:
5
detect the fifo size but QEMU defaults it to zero out of reset. The
6
datasheet indicates this bit is active on reset.
6
7
7
/home/LiKaige/qemu/target/arm/translate-a64.c: In function ‘disas_ldst’:
8
See page 25, SPI Control Register section:
8
/home/LiKaige/qemu/target/arm/translate-a64.c:3392:5: error: ‘fn’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
9
https://www.xilinx.com/content/dam/xilinx/support/documents/ip_documentation/axi_quad_spi/v3_2/pg153-axi-quad-spi.pdf
9
fn(cpu_reg(s, rt), clean_addr, tcg_rs, get_mem_index(s),
10
^
11
/home/LiKaige/qemu/target/arm/translate-a64.c:3318:22: note: ‘fn’ was declared here
12
AtomicThreeOpFn *fn;
13
^
14
10
15
Make it happy by initializing the variable to NULL.
11
Signed-off-by: Chris Rauer <crauer@google.com>
16
12
Message-id: 20230323182811.2641044-1-crauer@google.com
17
Signed-off-by: Kaige Li <likaige@loongson.cn>
13
Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com>
18
Message-id: 1596110248-7366-2-git-send-email-likaige@loongson.cn
19
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
20
[PMM: Clean up commit message and note which gcc version this was]
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
15
---
23
target/arm/translate-a64.c | 2 +-
16
hw/ssi/xilinx_spi.c | 1 +
24
1 file changed, 1 insertion(+), 1 deletion(-)
17
1 file changed, 1 insertion(+)
25
18
26
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
19
diff --git a/hw/ssi/xilinx_spi.c b/hw/ssi/xilinx_spi.c
27
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/translate-a64.c
21
--- a/hw/ssi/xilinx_spi.c
29
+++ b/target/arm/translate-a64.c
22
+++ b/hw/ssi/xilinx_spi.c
30
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn,
23
@@ -XXX,XX +XXX,XX @@ static void xlx_spi_do_reset(XilinxSPI *s)
31
bool r = extract32(insn, 22, 1);
24
txfifo_reset(s);
32
bool a = extract32(insn, 23, 1);
25
33
TCGv_i64 tcg_rs, clean_addr;
26
s->regs[R_SPISSR] = ~0;
34
- AtomicThreeOpFn *fn;
27
+ s->regs[R_SPICR] = R_SPICR_MTI;
35
+ AtomicThreeOpFn *fn = NULL;
28
xlx_spi_update_irq(s);
36
29
xlx_spi_update_cs(s);
37
if (is_vector || !dc_isar_feature(aa64_atomics, s)) {
30
}
38
unallocated_encoding(s);
39
--
31
--
40
2.20.1
32
2.34.1
41
42
diff view generated by jsdifflib