1
Handful of bugfixes for rc2. None of these are particularly critical
1
Some small arm bug fixes for rc3.
2
or exciting.
3
2
4
-- PMM
3
-- PMM
5
4
6
The following changes since commit 45a150aa2b3492acf6691c7bdbeb25a8545d8345:
5
The following changes since commit 9b617b1bb4056e60b39be4c33be20c10928a6a5c:
7
6
8
Merge remote-tracking branch 'remotes/ericb/tags/pull-bitmaps-2020-08-03' into staging (2020-08-03 15:13:49 +0100)
7
Merge tag 'trivial-branch-for-7.0-pull-request' of https://gitlab.com/laurent_vivier/qemu into staging (2022-04-01 10:23:27 +0100)
9
8
10
are available in the Git repository at:
9
are available in the Git repository at:
11
10
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200803
11
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220401
13
12
14
for you to fetch changes up to 13557fd392890cbd985bceba7f717e01efd674b8:
13
for you to fetch changes up to a5b1e1ab662aa6dc42d5a913080fccbb8bf82e9b:
15
14
16
hw/timer/imx_epit: Avoid assertion when CR.SWR is written (2020-08-03 17:56:11 +0100)
15
target/arm: Don't use DISAS_NORETURN in STXP !HAVE_CMPXCHG128 codegen (2022-04-01 15:35:49 +0100)
17
16
18
----------------------------------------------------------------
17
----------------------------------------------------------------
19
target-arm queue:
18
target-arm queue:
20
* hw/timer/imx_epit: Avoid assertion when CR.SWR is written
19
* target/arm: Fix some bugs in secure EL2 handling
21
* netduino2, netduinoplus2, microbit: set system_clock_scale so that
20
* target/arm: Fix assert when !HAVE_CMPXCHG128
22
SysTick running on the CPU clock works
21
* MAINTAINERS: change Fred Konrad's email address
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
22
28
----------------------------------------------------------------
23
----------------------------------------------------------------
29
Kaige Li (1):
24
Frederic Konrad (1):
30
target/arm: Avoid maybe-uninitialized warning with gcc 4.9
25
MAINTAINERS: change Fred Konrad's email address
31
26
32
Peter Maydell (6):
27
Idan Horowitz (4):
33
hw/arm/netduino2, netduinoplus2: Set system_clock_scale
28
target/arm: Fix MTE access checks for disabled SEL2
34
include/hw/irq.h: New function qemu_irq_is_connected()
29
target/arm: Check VSTCR.SW when assigning the stage 2 output PA space
35
hw/intc/armv7m_nvic: Provide default "reset the system" behaviour for SYSRESETREQ
30
target/arm: Take VSTCR.SW, VTCR.NSW into account in final stage 2 walk
36
msf2-soc, stellaris: Don't wire up SYSRESETREQ
31
target/arm: Determine final stage 2 output PA space based on original IPA
37
hw/arm/nrf51_soc: Set system_clock_scale
38
hw/timer/imx_epit: Avoid assertion when CR.SWR is written
39
32
40
Richard Henderson (1):
33
Peter Maydell (1):
41
target/arm: Fix AddPAC error indication
34
target/arm: Don't use DISAS_NORETURN in STXP !HAVE_CMPXCHG128 codegen
42
35
43
include/hw/arm/armv7m.h | 4 +++-
36
target/arm/internals.h | 2 +-
44
include/hw/irq.h | 18 ++++++++++++++++++
37
target/arm/helper.c | 18 +++++++++++++++---
45
hw/arm/msf2-soc.c | 11 -----------
38
target/arm/translate-a64.c | 7 ++++++-
46
hw/arm/netduino2.c | 10 ++++++++++
39
.mailmap | 3 ++-
47
hw/arm/netduinoplus2.c | 10 ++++++++++
40
MAINTAINERS | 2 +-
48
hw/arm/nrf51_soc.c | 5 +++++
41
5 files changed, 25 insertions(+), 7 deletions(-)
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
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
1
The nrf51 SoC model wasn't setting the system_clock_scale
1
From: Idan Horowitz <idan.horowitz@gmail.com>
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
2
5
Set the global to match the documented CPU clock speed for this SoC.
3
While not mentioned anywhere in the actual specification text, the
4
HCR_EL2.ATA bit is treated as '1' when EL2 is disabled at the current
5
security state. This can be observed in the psuedo-code implementation
6
of AArch64.AllocationTagAccessIsEnabled().
6
7
7
This SoC in fact doesn't have a SysTick timer (which is the only thing
8
Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com>
8
currently that cares about the system_clock_scale), because it's
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
a configurable option in the Cortex-M0. However our Cortex-M0 and
10
Message-id: 20220328173107.311267-1-idan.horowitz@gmail.com
10
thus our nrf51 and our micro:bit board do provide a SysTick, so
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
we ought to provide a functional one rather than a broken one.
12
---
13
target/arm/internals.h | 2 +-
14
target/arm/helper.c | 2 +-
15
2 files changed, 2 insertions(+), 2 deletions(-)
12
16
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
diff --git a/target/arm/internals.h b/target/arm/internals.h
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
18
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/arm/nrf51_soc.c
19
--- a/target/arm/internals.h
23
+++ b/hw/arm/nrf51_soc.c
20
+++ b/target/arm/internals.h
24
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ static inline bool allocation_tag_access_enabled(CPUARMState *env, int el,
25
22
&& !(env->cp15.scr_el3 & SCR_ATA)) {
26
#define BASE_TO_IRQ(base) ((base >> 12) & 0x1F)
23
return false;
27
24
}
28
+/* HCLK (the main CPU clock) on this SoC is always 16MHz */
25
- if (el < 2 && arm_feature(env, ARM_FEATURE_EL2)) {
29
+#define HCLK_FRQ 16000000
26
+ if (el < 2 && arm_is_el2_enabled(env)) {
30
+
27
uint64_t hcr = arm_hcr_el2_eff(env);
31
static uint64_t clock_read(void *opaque, hwaddr addr, unsigned int size)
28
if (!(hcr & HCR_ATA) && (!(hcr & HCR_E2H) || !(hcr & HCR_TGE))) {
29
return false;
30
diff --git a/target/arm/helper.c b/target/arm/helper.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/helper.c
33
+++ b/target/arm/helper.c
34
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_mte(CPUARMState *env, const ARMCPRegInfo *ri,
32
{
35
{
33
qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n",
36
int el = arm_current_el(env);
34
@@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
37
35
return;
38
- if (el < 2 && arm_feature(env, ARM_FEATURE_EL2)) {
36
}
39
+ if (el < 2 && arm_is_el2_enabled(env)) {
37
40
uint64_t hcr = arm_hcr_el2_eff(env);
38
+ system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ;
41
if (!(hcr & HCR_ATA) && (!(hcr & HCR_E2H) || !(hcr & HCR_TGE))) {
39
+
42
return CP_ACCESS_TRAP_EL2;
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
--
43
--
44
2.20.1
44
2.25.1
45
46
diff view generated by jsdifflib
1
The NVIC provides an outbound qemu_irq "SYSRESETREQ" which it signals
1
From: Idan Horowitz <idan.horowitz@gmail.com>
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
2
9
Provide a default behaviour for the case where SYSRESETREQ is not
3
As per the AArch64.SS2OutputPASpace() psuedo-code in the ARMv8 ARM when the
10
actually connected to anything: use qemu_system_reset_request() to
4
PA space of the IPA is non secure, the output PA space is secure if and only
11
perform a system reset. This will allow us to remove the
5
if all of the bits VTCR.<NSW, NSA>, VSTCR.<SW, SA> are not set.
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
6
16
* microbit
7
Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com>
17
* mps2-an385
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
* mps2-an505
9
Message-id: 20220327093427.1548629-2-idan.horowitz@gmail.com
19
* mps2-an511
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
* mps2-an521
11
---
21
* musca-a
12
target/arm/helper.c | 2 +-
22
* musca-b1
13
1 file changed, 1 insertion(+), 1 deletion(-)
23
* netduino
24
* netduinoplus2
25
14
26
We still allow the board to wire up the signal if it needs to, in case
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
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
16
index XXXXXXX..XXXXXXX 100644
43
--- a/include/hw/arm/armv7m.h
17
--- a/target/arm/helper.c
44
+++ b/include/hw/arm/armv7m.h
18
+++ b/target/arm/helper.c
45
@@ -XXX,XX +XXX,XX @@ typedef struct {
19
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
46
20
} else {
47
/* ARMv7M container object.
21
attrs->secure =
48
* + Unnamed GPIO input lines: external IRQ lines for the NVIC
22
!((env->cp15.vtcr_el2.raw_tcr & (VTCR_NSA | VTCR_NSW))
49
- * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ
23
- || (env->cp15.vstcr_el2.raw_tcr & VSTCR_SA));
50
+ * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ.
24
+ || (env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_SW)));
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
}
25
}
96
}
26
}
97
if (value & R_V7M_AIRCR_VECTCLRACTIVE_MASK) {
27
return 0;
98
--
28
--
99
2.20.1
29
2.25.1
100
101
diff view generated by jsdifflib
1
The imx_epit device has a software-controllable reset triggered by
1
From: Idan Horowitz <idan.horowitz@gmail.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
As per the AArch64.SS2InitialTTWState() psuedo-code in the ARMv8 ARM the
9
start-transaction for the CR write handling down below the check of
4
initial PA space used for stage 2 table walks is assigned based on the SW
10
the SWR bit.
5
and NSW bits of the VSTCR and VTCR registers.
6
This was already implemented for the recursive stage 2 page table walks
7
in S1_ptw_translate(), but was missing for the final stage 2 walk.
11
8
12
Fixes: https://bugs.launchpad.net/qemu/+bug/1880424
9
Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com>
13
Fixes: cc2722ec83ad944505fe
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20220327093427.1548629-3-idan.horowitz@gmail.com
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
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
---
13
---
18
hw/timer/imx_epit.c | 13 ++++++++++---
14
target/arm/helper.c | 10 ++++++++++
19
1 file changed, 10 insertions(+), 3 deletions(-)
15
1 file changed, 10 insertions(+)
20
16
21
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
22
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/timer/imx_epit.c
19
--- a/target/arm/helper.c
24
+++ b/hw/timer/imx_epit.c
20
+++ b/target/arm/helper.c
25
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
21
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
26
22
return ret;
27
switch (offset >> 2) {
23
}
28
case 0: /* CR */
24
29
- ptimer_transaction_begin(s->timer_cmp);
25
+ if (arm_is_secure_below_el3(env)) {
30
- ptimer_transaction_begin(s->timer_reload);
26
+ if (attrs->secure) {
31
27
+ attrs->secure = !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW);
32
oldcr = s->cr;
28
+ } else {
33
s->cr = value & 0x03ffffff;
29
+ attrs->secure = !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW);
34
if (s->cr & CR_SWR) {
30
+ }
35
/* handle the reset */
31
+ } else {
36
imx_epit_reset(DEVICE(s));
32
+ assert(!attrs->secure);
37
- } else {
33
+ }
38
+ /*
39
+ * TODO: could we 'break' here? following operations appear
40
+ * to duplicate the work imx_epit_reset() already did.
41
+ */
42
+ }
43
+
34
+
44
+ ptimer_transaction_begin(s->timer_cmp);
35
s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
45
+ ptimer_transaction_begin(s->timer_reload);
36
is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0;
46
+
47
+ if (!(s->cr & CR_SWR)) {
48
imx_epit_set_freq(s);
49
}
50
37
51
--
38
--
52
2.20.1
39
2.25.1
53
54
diff view generated by jsdifflib
1
The MSF2 SoC model and the Stellaris board code both wire
1
From: Idan Horowitz <idan.horowitz@gmail.com>
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
As per the AArch64.S2Walk() pseudo-code in the ARMv8 ARM, the final
4
decision as to the output address's PA space based on the SA/SW/NSA/NSW
5
bits needs to take the input IPA's PA space into account, and not the
6
PA space of the result of the stage 2 walk itself.
7
8
Signed-off-by: Idan Horowitz <idan.horowitz@gmail.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20220327093427.1548629-4-idan.horowitz@gmail.com
11
[PMM: fixed commit message typo]
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
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
---
13
---
12
hw/arm/msf2-soc.c | 11 -----------
14
target/arm/helper.c | 8 +++++---
13
hw/arm/stellaris.c | 12 ------------
15
1 file changed, 5 insertions(+), 3 deletions(-)
14
2 files changed, 23 deletions(-)
15
16
16
diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/msf2-soc.c
19
--- a/target/arm/helper.c
19
+++ b/hw/arm/msf2-soc.c
20
+++ b/target/arm/helper.c
20
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
21
#include "hw/irq.h"
22
hwaddr ipa;
22
#include "hw/arm/msf2-soc.h"
23
int s2_prot;
23
#include "hw/misc/unimp.h"
24
int ret;
24
-#include "sysemu/runstate.h"
25
+ bool ipa_secure;
25
#include "sysemu/sysemu.h"
26
ARMCacheAttrs cacheattrs2 = {};
26
27
ARMMMUIdx s2_mmu_idx;
27
#define MSF2_TIMER_BASE 0x40004000
28
bool is_el0;
28
@@ -XXX,XX +XXX,XX @@ static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 };
29
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
29
static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 };
30
return ret;
30
static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 };
31
}
31
32
32
-static void do_sys_reset(void *opaque, int n, int level)
33
+ ipa_secure = attrs->secure;
33
-{
34
if (arm_is_secure_below_el3(env)) {
34
- if (level) {
35
- if (attrs->secure) {
35
- qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
36
+ if (ipa_secure) {
36
- }
37
attrs->secure = !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW);
37
-}
38
} else {
38
-
39
attrs->secure = !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW);
39
static void m2sxxx_soc_initfn(Object *obj)
40
}
40
{
41
} else {
41
MSF2State *s = MSF2_SOC(obj);
42
- assert(!attrs->secure);
42
@@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
43
+ assert(!ipa_secure);
43
return;
44
}
44
}
45
45
46
s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
46
- qdev_connect_gpio_out_named(DEVICE(&s->armv7m.nvic), "SYSRESETREQ", 0,
47
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
47
- qemu_allocate_irq(&do_sys_reset, NULL, 0));
48
48
-
49
/* Check if IPA translates to secure or non-secure PA space. */
49
system_clock_scale = NANOSECONDS_PER_SECOND / s->m3clk;
50
if (arm_is_secure_below_el3(env)) {
50
51
- if (attrs->secure) {
51
for (i = 0; i < MSF2_NUM_UARTS; i++) {
52
+ if (ipa_secure) {
52
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
53
attrs->secure =
53
index XXXXXXX..XXXXXXX 100644
54
!(env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_SW));
54
--- a/hw/arm/stellaris.c
55
} else {
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
--
56
--
90
2.20.1
57
2.25.1
91
92
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Frederic Konrad <konrad@adacore.com>
2
2
3
The definition of top_bit used in this function is one higher
3
frederic.konrad@adacore.com and konrad@adacore.com will stop working starting
4
than that used in the Arm ARM psuedo-code, which put the error
4
2022-04-01.
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
Use my personal email instead.
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
7
12
For now, prefer the minimal fix to the error indication alone.
8
Signed-off-by: Frederic Konrad <frederic.konrad@adacore.com>
13
9
Reviewed-by: Fabien Chouteau <chouteau@adacore.com <clg@kaod.org>>
14
Fixes: 63ff0ca94cb
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Reported-by: Derrick McKee <derrick.mckee@gmail.com>
11
Message-id: 1648643217-15811-1-git-send-email-frederic.konrad@adacore.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>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
---
13
---
22
target/arm/pauth_helper.c | 6 +++++-
14
.mailmap | 3 ++-
23
tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++
15
MAINTAINERS | 2 +-
24
tests/tcg/aarch64/Makefile.target | 2 +-
16
2 files changed, 3 insertions(+), 2 deletions(-)
25
3 files changed, 39 insertions(+), 2 deletions(-)
26
create mode 100644 tests/tcg/aarch64/pauth-5.c
27
17
28
diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c
18
diff --git a/.mailmap b/.mailmap
29
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/pauth_helper.c
20
--- a/.mailmap
31
+++ b/target/arm/pauth_helper.c
21
+++ b/.mailmap
32
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,
22
@@ -XXX,XX +XXX,XX @@ Alexander Graf <agraf@csgraf.de> <agraf@suse.de>
33
*/
23
Anthony Liguori <anthony@codemonkey.ws> Anthony Liguori <aliguori@us.ibm.com>
34
test = sextract64(ptr, bot_bit, top_bit - bot_bit);
24
Christian Borntraeger <borntraeger@linux.ibm.com> <borntraeger@de.ibm.com>
35
if (test != 0 && test != -1) {
25
Filip Bozuta <filip.bozuta@syrmia.com> <filip.bozuta@rt-rk.com.com>
36
- pac ^= MAKE_64BIT_MASK(top_bit - 1, 1);
26
-Frederic Konrad <konrad@adacore.com> <fred.konrad@greensocs.com>
37
+ /*
27
+Frederic Konrad <konrad.frederic@yahoo.fr> <fred.konrad@greensocs.com>
38
+ * Note that our top_bit is one greater than the pseudocode's
28
+Frederic Konrad <konrad.frederic@yahoo.fr> <konrad@adacore.com>
39
+ * version, hence "- 2" here.
29
Greg Kurz <groug@kaod.org> <gkurz@linux.vnet.ibm.com>
40
+ */
30
Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com>
41
+ pac ^= MAKE_64BIT_MASK(top_bit - 2, 1);
31
Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn>
42
}
32
diff --git a/MAINTAINERS b/MAINTAINERS
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
33
index XXXXXXX..XXXXXXX 100644
86
--- a/tests/tcg/aarch64/Makefile.target
34
--- a/MAINTAINERS
87
+++ b/tests/tcg/aarch64/Makefile.target
35
+++ b/MAINTAINERS
88
@@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt
36
@@ -XXX,XX +XXX,XX @@ F: include/hw/rtc/sun4v-rtc.h
89
37
90
# Pauth Tests
38
Leon3
91
ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_ARMV8_3),)
39
M: Fabien Chouteau <chouteau@adacore.com>
92
-AARCH64_TESTS += pauth-1 pauth-2 pauth-4
40
-M: KONRAD Frederic <frederic.konrad@adacore.com>
93
+AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5
41
+M: Frederic Konrad <konrad.frederic@yahoo.fr>
94
pauth-%: CFLAGS += -march=armv8.3-a
42
S: Maintained
95
run-pauth-%: QEMU_OPTS += -cpu max
43
F: hw/sparc/leon3.c
96
run-plugin-pauth-%: QEMU_OPTS += -cpu max
44
F: hw/*/grlib*
97
--
45
--
98
2.20.1
46
2.25.1
99
47
100
48
diff view generated by jsdifflib
1
From: Kaige Li <likaige@loongson.cn>
1
In gen_store_exclusive(), if the host does not have a cmpxchg128
2
primitive then we generate bad code for STXP for storing two 64-bit
3
values. We generate a call to the exit_atomic helper, which never
4
returns, and set is_jmp to DISAS_NORETURN. However, this is
5
forgetting that we have already emitted a brcond that jumps over this
6
call for the case where we don't hold the exclusive. The effect is
7
that we don't generate any code to end the TB for the
8
exclusive-not-held execution path, which falls into the "exit with
9
TB_EXIT_REQUESTED" code that gen_tb_end() emits. This then causes an
10
assert at runtime when cpu_loop_exec_tb() sees an EXIT_REQUESTED TB
11
return that wasn't for an interrupt or icount.
2
12
3
GCC version 4.9.4 isn't clever enough to figure out that all
13
In particular, you can hit this case when using the clang sanitizers
4
execution paths in disas_ldst() that use 'fn' will have initialized
14
and trying to run the xlnx-versal-virt acceptance test in 'make
5
it first, and so it warns:
15
check-acceptance'. This bug was masked until commit 848126d11e93ff
16
("meson: move int128 checks from configure") because we used to set
17
CONFIG_CMPXCHG128=1 and avoid the buggy codepath, but after that we
18
do not.
6
19
7
/home/LiKaige/qemu/target/arm/translate-a64.c: In function ‘disas_ldst’:
20
Fix the bug by not setting is_jmp. The code after the exit_atomic
8
/home/LiKaige/qemu/target/arm/translate-a64.c:3392:5: error: ‘fn’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
21
call up to the fail_label is dead, but TCG is smart enough to
9
fn(cpu_reg(s, rt), clean_addr, tcg_rs, get_mem_index(s),
22
eliminate it. We do need to set 'tmp' to some valid value, though
10
^
23
(in the same way the exit_atomic-using code in tcg/tcg-op.c does).
11
/home/LiKaige/qemu/target/arm/translate-a64.c:3318:22: note: ‘fn’ was declared here
12
AtomicThreeOpFn *fn;
13
^
14
24
15
Make it happy by initializing the variable to NULL.
25
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/953
16
17
Signed-off-by: Kaige Li <likaige@loongson.cn>
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>
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
28
Message-id: 20220331150858.96348-1-peter.maydell@linaro.org
22
---
29
---
23
target/arm/translate-a64.c | 2 +-
30
target/arm/translate-a64.c | 7 ++++++-
24
1 file changed, 1 insertion(+), 1 deletion(-)
31
1 file changed, 6 insertions(+), 1 deletion(-)
25
32
26
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
33
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
27
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/translate-a64.c
35
--- a/target/arm/translate-a64.c
29
+++ b/target/arm/translate-a64.c
36
+++ b/target/arm/translate-a64.c
30
@@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn,
37
@@ -XXX,XX +XXX,XX @@ static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2,
31
bool r = extract32(insn, 22, 1);
38
} else if (tb_cflags(s->base.tb) & CF_PARALLEL) {
32
bool a = extract32(insn, 23, 1);
39
if (!HAVE_CMPXCHG128) {
33
TCGv_i64 tcg_rs, clean_addr;
40
gen_helper_exit_atomic(cpu_env);
34
- AtomicThreeOpFn *fn;
41
- s->base.is_jmp = DISAS_NORETURN;
35
+ AtomicThreeOpFn *fn = NULL;
42
+ /*
36
43
+ * Produce a result so we have a well-formed opcode
37
if (is_vector || !dc_isar_feature(aa64_atomics, s)) {
44
+ * stream when the following (dead) code uses 'tmp'.
38
unallocated_encoding(s);
45
+ * TCG will remove the dead ops for us.
46
+ */
47
+ tcg_gen_movi_i64(tmp, 0);
48
} else if (s->be_data == MO_LE) {
49
gen_helper_paired_cmpxchg64_le_parallel(tmp, cpu_env,
50
cpu_exclusive_addr,
39
--
51
--
40
2.20.1
52
2.25.1
41
42
diff view generated by jsdifflib