1 | target-arm queue: nothing major here, but no point | 1 | Handful of bugfixes for rc2. None of these are particularly critical |
---|---|---|---|
2 | sitting on them waiting for more stuff to come along. | 2 | or exciting. |
3 | 3 | ||
4 | thanks | ||
5 | -- PMM | 4 | -- PMM |
6 | 5 | ||
7 | The following changes since commit 1329132d28bf14b9508f7a1f04a2c63422bc3f99: | 6 | The following changes since commit 45a150aa2b3492acf6691c7bdbeb25a8545d8345: |
8 | 7 | ||
9 | Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2019-09-26 16:14:03 +0100) | 8 | Merge remote-tracking branch 'remotes/ericb/tags/pull-bitmaps-2020-08-03' into staging (2020-08-03 15:13:49 +0100) |
10 | 9 | ||
11 | are available in the Git repository at: | 10 | are available in the Git repository at: |
12 | 11 | ||
13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190927 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200803 |
14 | 13 | ||
15 | for you to fetch changes up to e4e34855e658b78ecac50a651cc847662ff02cfd: | 14 | for you to fetch changes up to 13557fd392890cbd985bceba7f717e01efd674b8: |
16 | 15 | ||
17 | hw/arm/boot: Use the IEC binary prefix definitions (2019-09-27 11:44:39 +0100) | 16 | hw/timer/imx_epit: Avoid assertion when CR.SWR is written (2020-08-03 17:56:11 +0100) |
18 | 17 | ||
19 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
20 | target-arm queue: | 19 | target-arm queue: |
21 | * Fix the CBAR register implementation for Cortex-A53, | 20 | * hw/timer/imx_epit: Avoid assertion when CR.SWR is written |
22 | Cortex-A57, Cortex-A72 | 21 | * netduino2, netduinoplus2, microbit: set system_clock_scale so that |
23 | * Fix direct booting of Linux kernels on emulated CPUs | 22 | SysTick running on the CPU clock works |
24 | which have an AArch32 EL3 (incorrect NSACR settings | 23 | * target/arm: Avoid maybe-uninitialized warning with gcc 4.9 |
25 | meant they could not access the FPU) | 24 | * target/arm: Fix AddPAC error indication |
26 | * semihosting cleanup: do more work at translate time | 25 | * Make AIRCR.SYSRESETREQ actually reset the system for the |
27 | and less work at runtime | 26 | microbit, mps2-*, musca-*, netduino* boards |
28 | 27 | ||
29 | ---------------------------------------------------------------- | 28 | ---------------------------------------------------------------- |
30 | Alex Bennée (6): | 29 | Kaige Li (1): |
31 | tests/tcg: clean-up some comments after the de-tangling | 30 | target/arm: Avoid maybe-uninitialized warning with gcc 4.9 |
32 | target/arm: handle M-profile semihosting at translate time | ||
33 | target/arm: handle A-profile semihosting at translate time | ||
34 | target/arm: remove run time semihosting checks | ||
35 | target/arm: remove run-time semihosting checks for linux-user | ||
36 | tests/tcg: add linux-user semihosting smoke test for ARM | ||
37 | 31 | ||
38 | Luc Michel (1): | 32 | Peter Maydell (6): |
39 | target/arm: fix CBAR register for AArch64 CPUs | 33 | hw/arm/netduino2, netduinoplus2: Set system_clock_scale |
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 | ||
40 | 39 | ||
41 | Peter Maydell (1): | 40 | Richard Henderson (1): |
42 | hw/arm/boot.c: Set NSACR.{CP11,CP10} for NS kernel boots | 41 | target/arm: Fix AddPAC error indication |
43 | 42 | ||
44 | Philippe Mathieu-Daudé (1): | 43 | include/hw/arm/armv7m.h | 4 +++- |
45 | hw/arm/boot: Use the IEC binary prefix definitions | 44 | include/hw/irq.h | 18 ++++++++++++++++++ |
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 | ||
46 | 58 | ||
47 | tests/tcg/Makefile.target | 7 ++- | ||
48 | tests/tcg/aarch64/Makefile.target | 8 ++- | ||
49 | tests/tcg/arm/Makefile.target | 20 ++++--- | ||
50 | linux-user/arm/target_syscall.h | 3 - | ||
51 | hw/arm/boot.c | 12 ++-- | ||
52 | linux-user/arm/cpu_loop.c | 3 - | ||
53 | target/arm/helper.c | 115 +++++++++++++------------------------- | ||
54 | target/arm/m_helper.c | 18 ++---- | ||
55 | target/arm/translate.c | 30 ++++++++-- | ||
56 | tests/tcg/arm/semihosting.c | 45 +++++++++++++++ | ||
57 | 10 files changed, 146 insertions(+), 115 deletions(-) | ||
58 | create mode 100644 tests/tcg/arm/semihosting.c | ||
59 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Luc Michel <luc.michel@greensocs.com> | ||
2 | 1 | ||
3 | For AArch64 CPUs with a CBAR register, we have two views for it: | ||
4 | - in AArch64 state, the CBAR_EL1 register (S3_1_C15_C3_0), returns the | ||
5 | full 64 bits CBAR value | ||
6 | - in AArch32 state, the CBAR register (cp15, opc1=1, CRn=15, CRm=3, opc2=0) | ||
7 | returns a 32 bits view such that: | ||
8 | CBAR = CBAR_EL1[31:18] 0..0 CBAR_EL1[43:32] | ||
9 | |||
10 | This commit fixes the current implementation where: | ||
11 | - CBAR_EL1 was returning the 32 bits view instead of the full 64 bits | ||
12 | value, | ||
13 | - CBAR was returning a truncated 32 bits version of the full 64 bits | ||
14 | one, instead of the 32 bits view | ||
15 | - CBAR was declared as cp15, opc1=4, CRn=15, CRm=0, opc2=0, which is | ||
16 | the CBAR register found in the ARMv7 Cortex-Ax CPUs, but not in | ||
17 | ARMv8 CPUs. | ||
18 | |||
19 | Signed-off-by: Luc Michel <luc.michel@greensocs.com> | ||
20 | Message-id: 20190912110103.1417887-1-luc.michel@greensocs.com | ||
21 | [PMM: Added a comment about the two different kinds of CBAR] | ||
22 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
24 | --- | ||
25 | target/arm/helper.c | 19 ++++++++++++++++--- | ||
26 | 1 file changed, 16 insertions(+), 3 deletions(-) | ||
27 | |||
28 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/helper.c | ||
31 | +++ b/target/arm/helper.c | ||
32 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
33 | } | ||
34 | |||
35 | if (arm_feature(env, ARM_FEATURE_CBAR)) { | ||
36 | + /* | ||
37 | + * CBAR is IMPDEF, but common on Arm Cortex-A implementations. | ||
38 | + * There are two flavours: | ||
39 | + * (1) older 32-bit only cores have a simple 32-bit CBAR | ||
40 | + * (2) 64-bit cores have a 64-bit CBAR visible to AArch64, plus a | ||
41 | + * 32-bit register visible to AArch32 at a different encoding | ||
42 | + * to the "flavour 1" register and with the bits rearranged to | ||
43 | + * be able to squash a 64-bit address into the 32-bit view. | ||
44 | + * We distinguish the two via the ARM_FEATURE_AARCH64 flag, but | ||
45 | + * in future if we support AArch32-only configs of some of the | ||
46 | + * AArch64 cores we might need to add a specific feature flag | ||
47 | + * to indicate cores with "flavour 2" CBAR. | ||
48 | + */ | ||
49 | if (arm_feature(env, ARM_FEATURE_AARCH64)) { | ||
50 | /* 32 bit view is [31:18] 0...0 [43:32]. */ | ||
51 | uint32_t cbar32 = (extract64(cpu->reset_cbar, 18, 14) << 18) | ||
52 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
53 | ARMCPRegInfo cbar_reginfo[] = { | ||
54 | { .name = "CBAR", | ||
55 | .type = ARM_CP_CONST, | ||
56 | - .cp = 15, .crn = 15, .crm = 0, .opc1 = 4, .opc2 = 0, | ||
57 | - .access = PL1_R, .resetvalue = cpu->reset_cbar }, | ||
58 | + .cp = 15, .crn = 15, .crm = 3, .opc1 = 1, .opc2 = 0, | ||
59 | + .access = PL1_R, .resetvalue = cbar32 }, | ||
60 | { .name = "CBAR_EL1", .state = ARM_CP_STATE_AA64, | ||
61 | .type = ARM_CP_CONST, | ||
62 | .opc0 = 3, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 0, | ||
63 | - .access = PL1_R, .resetvalue = cbar32 }, | ||
64 | + .access = PL1_R, .resetvalue = cpu->reset_cbar }, | ||
65 | REGINFO_SENTINEL | ||
66 | }; | ||
67 | /* We don't implement a r/w 64 bit CBAR currently */ | ||
68 | -- | ||
69 | 2.20.1 | ||
70 | |||
71 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@redhat.com> | 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. | ||
2 | 4 | ||
3 | IEC binary prefixes ease code review: the unit is explicit. | 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. | ||
4 | 9 | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Fixes: https://bugs.launchpad.net/qemu/+bug/1876187 |
6 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> | ||
7 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 20190923131108.21459-1-philmd@redhat.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 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 | ||
11 | --- | 14 | --- |
12 | hw/arm/boot.c | 10 +++++----- | 15 | hw/arm/netduino2.c | 10 ++++++++++ |
13 | 1 file changed, 5 insertions(+), 5 deletions(-) | 16 | hw/arm/netduinoplus2.c | 10 ++++++++++ |
17 | 2 files changed, 20 insertions(+) | ||
14 | 18 | ||
15 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 19 | diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c |
16 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/boot.c | 21 | --- a/hw/arm/netduino2.c |
18 | +++ b/hw/arm/boot.c | 22 | +++ b/hw/arm/netduino2.c |
19 | @@ -XXX,XX +XXX,XX @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, | 23 | @@ -XXX,XX +XXX,XX @@ |
20 | goto fail; | 24 | #include "hw/arm/stm32f205_soc.h" |
21 | } | 25 | #include "hw/arm/boot.h" |
22 | 26 | ||
23 | - if (scells < 2 && binfo->ram_size >= (1ULL << 32)) { | 27 | +/* Main SYSCLK frequency in Hz (120MHz) */ |
24 | + if (scells < 2 && binfo->ram_size >= 4 * GiB) { | 28 | +#define SYSCLK_FRQ 120000000ULL |
25 | /* This is user error so deserves a friendlier error message | 29 | + |
26 | * than the failure of setprop_sized_cells would provide | 30 | static void netduino2_init(MachineState *machine) |
27 | */ | 31 | { |
28 | @@ -XXX,XX +XXX,XX @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, | 32 | DeviceState *dev; |
29 | * we might still make a bad choice here. | 33 | |
30 | */ | 34 | + /* |
31 | info->initrd_start = info->loader_start + | 35 | + * TODO: ideally we would model the SoC RCC and let it handle |
32 | - MIN(info->ram_size / 2, 128 * 1024 * 1024); | 36 | + * system_clock_scale, including its ability to define different |
33 | + MIN(info->ram_size / 2, 128 * MiB); | 37 | + * possible SYSCLK sources. |
34 | if (image_high_addr) { | 38 | + */ |
35 | info->initrd_start = MAX(info->initrd_start, image_high_addr); | 39 | + system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; |
36 | } | 40 | + |
37 | @@ -XXX,XX +XXX,XX @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, | 41 | dev = qdev_new(TYPE_STM32F205_SOC); |
38 | * | 42 | qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3")); |
39 | * Let's play safe and prealign it to 2MB to give us some space. | 43 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); |
40 | */ | 44 | diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c |
41 | - align = 2 * 1024 * 1024; | 45 | index XXXXXXX..XXXXXXX 100644 |
42 | + align = 2 * MiB; | 46 | --- a/hw/arm/netduinoplus2.c |
43 | } else { | 47 | +++ b/hw/arm/netduinoplus2.c |
44 | /* | 48 | @@ -XXX,XX +XXX,XX @@ |
45 | * Some 32bit kernels will trash anything in the 4K page the | 49 | #include "hw/arm/stm32f405_soc.h" |
46 | * initrd ends in, so make sure the DTB isn't caught up in that. | 50 | #include "hw/arm/boot.h" |
47 | */ | 51 | |
48 | - align = 4096; | 52 | +/* Main SYSCLK frequency in Hz (168MHz) */ |
49 | + align = 4 * KiB; | 53 | +#define SYSCLK_FRQ 168000000ULL |
50 | } | 54 | + |
51 | 55 | static void netduinoplus2_init(MachineState *machine) | |
52 | /* Place the DTB after the initrd in memory with alignment. */ | 56 | { |
53 | @@ -XXX,XX +XXX,XX @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, | 57 | DeviceState *dev; |
54 | info->loader_start + KERNEL_ARGS_ADDR; | 58 | |
55 | fixupcontext[FIXUP_ARGPTR_HI] = | 59 | + /* |
56 | (info->loader_start + KERNEL_ARGS_ADDR) >> 32; | 60 | + * TODO: ideally we would model the SoC RCC and let it handle |
57 | - if (info->ram_size >= (1ULL << 32)) { | 61 | + * system_clock_scale, including its ability to define different |
58 | + if (info->ram_size >= 4 * GiB) { | 62 | + * possible SYSCLK sources. |
59 | error_report("RAM size must be less than 4GB to boot" | 63 | + */ |
60 | " Linux kernel using ATAGS (try passing a device tree" | 64 | + system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; |
61 | " using -dtb)"); | 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); | ||
62 | -- | 69 | -- |
63 | 2.20.1 | 70 | 2.20.1 |
64 | 71 | ||
65 | 72 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 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. | ||
2 | 6 | ||
3 | Now we do all our checking at translate time we can make cpu_loop a | 7 | Provide a function qemu_irq_is_connected() that devices can use for |
4 | little bit simpler. We also introduce a simple linux-user semihosting | 8 | this purpose. (The test is trivial but encapsulating it in a |
5 | test case to defend the functionality. The out-of-tree softmmu based | 9 | function makes it easier to see where we're doing it in case we need |
6 | semihosting tests are still more comprehensive. | 10 | to change the implementation later.) |
7 | 11 | ||
8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Message-id: 20190913151845.12582-6-alex.bennee@linaro.org | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 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 | ||
12 | --- | 16 | --- |
13 | linux-user/arm/target_syscall.h | 3 --- | 17 | include/hw/irq.h | 18 ++++++++++++++++++ |
14 | linux-user/arm/cpu_loop.c | 3 --- | 18 | 1 file changed, 18 insertions(+) |
15 | 2 files changed, 6 deletions(-) | ||
16 | 19 | ||
17 | diff --git a/linux-user/arm/target_syscall.h b/linux-user/arm/target_syscall.h | 20 | diff --git a/include/hw/irq.h b/include/hw/irq.h |
18 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/linux-user/arm/target_syscall.h | 22 | --- a/include/hw/irq.h |
20 | +++ b/linux-user/arm/target_syscall.h | 23 | +++ b/include/hw/irq.h |
21 | @@ -XXX,XX +XXX,XX @@ struct target_pt_regs { | 24 | @@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); |
22 | #define ARM_NR_set_tls (ARM_NR_BASE + 5) | 25 | on an existing vector of qemu_irq. */ |
23 | #define ARM_NR_get_tls (ARM_NR_BASE + 6) | 26 | void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n); |
24 | 27 | ||
25 | -#define ARM_NR_semihosting 0x123456 | 28 | +/** |
26 | -#define ARM_NR_thumb_semihosting 0xAB | 29 | + * qemu_irq_is_connected: Return true if IRQ line is wired up |
27 | - | 30 | + * |
28 | #if defined(TARGET_WORDS_BIGENDIAN) | 31 | + * If a qemu_irq has a device on the other (receiving) end of it, |
29 | #define UNAME_MACHINE "armv5teb" | 32 | + * return true; otherwise return false. |
30 | #else | 33 | + * |
31 | diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c | 34 | + * Usually device models don't need to care whether the machine model |
32 | index XXXXXXX..XXXXXXX 100644 | 35 | + * has wired up their outbound qemu_irq lines, because functions like |
33 | --- a/linux-user/arm/cpu_loop.c | 36 | + * qemu_set_irq() silently do nothing if there is nothing on the other |
34 | +++ b/linux-user/arm/cpu_loop.c | 37 | + * end of the line. However occasionally a device model will want to |
35 | @@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env) | 38 | + * provide default behaviour if its output is left floating, and |
36 | 39 | + * it can use this function to identify when that is the case. | |
37 | if (n == ARM_NR_cacheflush) { | 40 | + */ |
38 | /* nop */ | 41 | +static inline bool qemu_irq_is_connected(qemu_irq irq) |
39 | - } else if (n == ARM_NR_semihosting | 42 | +{ |
40 | - || n == ARM_NR_thumb_semihosting) { | 43 | + return irq != NULL; |
41 | - env->regs[0] = do_arm_semihosting (env); | 44 | +} |
42 | } else if (n == 0 || n >= ARM_SYSCALL_BASE || env->thumb) { | 45 | + |
43 | /* linux syscall */ | 46 | #endif |
44 | if (env->thumb || n == 0) { | ||
45 | -- | 47 | -- |
46 | 2.20.1 | 48 | 2.20.1 |
47 | 49 | ||
48 | 50 | diff view generated by jsdifflib |
1 | If we're booting a Linux kernel directly into Non-Secure | 1 | The NVIC provides an outbound qemu_irq "SYSRESETREQ" which it signals |
---|---|---|---|
2 | state on a CPU which has Secure state, then make sure we | 2 | when the guest sets the SYSRESETREQ bit in the AIRCR register. This |
3 | set the NSACR CP11 and CP10 bits, so that Non-Secure is allowed | 3 | matches the hardware design (where the CPU has a signal of this name |
4 | to access the FPU. Otherwise an AArch32 kernel will UNDEF as | 4 | and it is up to the SoC to connect that up to an actual reset |
5 | soon as it tries to use the FPU. | 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. | ||
6 | 8 | ||
7 | It used to not matter that we didn't do this until commit | 9 | Provide a default behaviour for the case where SYSRESETREQ is not |
8 | fc1120a7f5f2d4b6, where we implemented actually honouring | 10 | actually connected to anything: use qemu_system_reset_request() to |
9 | these NSACR bits. | 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: | ||
10 | 15 | ||
11 | The problem only exists for CPUs where EL3 is AArch32; the | 16 | * microbit |
12 | equivalent AArch64 trap bits are in CPTR_EL3 and are "0 to | 17 | * mps2-an385 |
13 | not trap, 1 to trap", so the reset value of the register | 18 | * mps2-an505 |
14 | permits NS access, unlike NSACR. | 19 | * mps2-an511 |
20 | * mps2-an521 | ||
21 | * musca-a | ||
22 | * musca-b1 | ||
23 | * netduino | ||
24 | * netduinoplus2 | ||
15 | 25 | ||
16 | Fixes: fc1120a7f5 | 26 | We still allow the board to wire up the signal if it needs to, in case |
17 | Fixes: https://bugs.launchpad.net/qemu/+bug/1844597 | 27 | we need to model more complicated reset controller logic or to model |
18 | Cc: qemu-stable@nongnu.org | 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 | |||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 33 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
21 | Message-id: 20190920174039.3916-1-peter.maydell@linaro.org | 34 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
35 | Message-id: 20200728103744.6909-3-peter.maydell@linaro.org | ||
22 | --- | 36 | --- |
23 | hw/arm/boot.c | 2 ++ | 37 | include/hw/arm/armv7m.h | 4 +++- |
24 | 1 file changed, 2 insertions(+) | 38 | hw/intc/armv7m_nvic.c | 17 ++++++++++++++++- |
39 | 2 files changed, 19 insertions(+), 2 deletions(-) | ||
25 | 40 | ||
26 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 41 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h |
27 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/arm/boot.c | 43 | --- a/include/hw/arm/armv7m.h |
29 | +++ b/hw/arm/boot.c | 44 | +++ b/include/hw/arm/armv7m.h |
30 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | 45 | @@ -XXX,XX +XXX,XX @@ typedef struct { |
31 | (cs != first_cpu || !info->secure_board_setup)) { | 46 | |
32 | /* Linux expects non-secure state */ | 47 | /* ARMv7M container object. |
33 | env->cp15.scr_el3 |= SCR_NS; | 48 | * + Unnamed GPIO input lines: external IRQ lines for the NVIC |
34 | + /* Set NSACR.{CP11,CP10} so NS can access the FPU */ | 49 | - * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ |
35 | + env->cp15.nsacr |= 3 << 10; | 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); | ||
36 | } | 95 | } |
37 | } | 96 | } |
38 | 97 | if (value & R_V7M_AIRCR_VECTCLRACTIVE_MASK) { | |
39 | -- | 98 | -- |
40 | 2.20.1 | 99 | 2.20.1 |
41 | 100 | ||
42 | 101 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | The MSF2 SoC model and the Stellaris board code both wire |
---|---|---|---|
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. | ||
2 | 6 | ||
3 | As for the other semihosting calls we can resolve this at translate | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | time. | 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 | --- | ||
12 | hw/arm/msf2-soc.c | 11 ----------- | ||
13 | hw/arm/stellaris.c | 12 ------------ | ||
14 | 2 files changed, 23 deletions(-) | ||
5 | 15 | ||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 16 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20190913151845.12582-4-alex.bennee@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/translate.c | 19 +++++++++++++++---- | ||
12 | 1 file changed, 15 insertions(+), 4 deletions(-) | ||
13 | |||
14 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate.c | 18 | --- a/hw/arm/msf2-soc.c |
17 | +++ b/target/arm/translate.c | 19 | +++ b/hw/arm/msf2-soc.c |
18 | @@ -XXX,XX +XXX,XX @@ static bool trans_CBZ(DisasContext *s, arg_CBZ *a) | 20 | @@ -XXX,XX +XXX,XX @@ |
21 | #include "hw/irq.h" | ||
22 | #include "hw/arm/msf2-soc.h" | ||
23 | #include "hw/misc/unimp.h" | ||
24 | -#include "sysemu/runstate.h" | ||
25 | #include "sysemu/sysemu.h" | ||
26 | |||
27 | #define MSF2_TIMER_BASE 0x40004000 | ||
28 | @@ -XXX,XX +XXX,XX @@ static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 }; | ||
29 | static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 }; | ||
30 | static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 }; | ||
31 | |||
32 | -static void do_sys_reset(void *opaque, int n, int level) | ||
33 | -{ | ||
34 | - if (level) { | ||
35 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
36 | - } | ||
37 | -} | ||
38 | - | ||
39 | static void m2sxxx_soc_initfn(Object *obj) | ||
40 | { | ||
41 | MSF2State *s = MSF2_SOC(obj); | ||
42 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | ||
43 | return; | ||
44 | } | ||
45 | |||
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); | ||
19 | } | 66 | } |
20 | 67 | ||
21 | /* | 68 | -static |
22 | - * Supervisor call | 69 | -void do_sys_reset(void *opaque, int n, int level) |
23 | + * Supervisor call - both T32 & A32 come here so we need to check | 70 | -{ |
24 | + * which mode we are in when checking for semihosting. | 71 | - if (level) { |
25 | */ | 72 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); |
26 | 73 | - } | |
27 | static bool trans_SVC(DisasContext *s, arg_SVC *a) | 74 | -} |
28 | { | 75 | - |
29 | - gen_set_pc_im(s, s->base.pc_next); | 76 | /* Board init. */ |
30 | - s->svc_imm = a->imm; | 77 | static stellaris_board_info stellaris_boards[] = { |
31 | - s->base.is_jmp = DISAS_SWI; | 78 | { "LM3S811EVB", |
32 | + const uint32_t semihost_imm = s->thumb ? 0xab : 0x123456; | 79 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
33 | + | 80 | /* This will exit with an error if the user passed us a bad cpu_type */ |
34 | + if (!arm_dc_feature(s, ARM_FEATURE_M) && semihosting_enabled() && | 81 | sysbus_realize_and_unref(SYS_BUS_DEVICE(nvic), &error_fatal); |
35 | +#ifndef CONFIG_USER_ONLY | 82 | |
36 | + !IS_USER(s) && | 83 | - qdev_connect_gpio_out_named(nvic, "SYSRESETREQ", 0, |
37 | +#endif | 84 | - qemu_allocate_irq(&do_sys_reset, NULL, 0)); |
38 | + (a->imm == semihost_imm)) { | 85 | - |
39 | + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); | 86 | if (board->dc1 & (1 << 16)) { |
40 | + } else { | 87 | dev = sysbus_create_varargs(TYPE_STELLARIS_ADC, 0x40038000, |
41 | + gen_set_pc_im(s, s->base.pc_next); | 88 | qdev_get_gpio_in(nvic, 14), |
42 | + s->svc_imm = a->imm; | ||
43 | + s->base.is_jmp = DISAS_SWI; | ||
44 | + } | ||
45 | return true; | ||
46 | } | ||
47 | |||
48 | -- | 89 | -- |
49 | 2.20.1 | 90 | 2.20.1 |
50 | 91 | ||
51 | 92 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | We already use semihosting for the system stuff so this is a simple | 3 | The definition of top_bit used in this function is one higher |
4 | smoke test to ensure we are working OK on linux-user. | 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. | ||
5 | 7 | ||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Fixing the definition of top_bit requires more changes, because |
7 | Message-id: 20190913151845.12582-7-alex.bennee@linaro.org | 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 | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
19 | [PMM: added comment about the divergence from the pseudocode] | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 21 | --- |
11 | tests/tcg/aarch64/Makefile.target | 5 ++++ | 22 | target/arm/pauth_helper.c | 6 +++++- |
12 | tests/tcg/arm/Makefile.target | 5 ++++ | 23 | tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++ |
13 | tests/tcg/arm/semihosting.c | 45 +++++++++++++++++++++++++++++++ | 24 | tests/tcg/aarch64/Makefile.target | 2 +- |
14 | 3 files changed, 55 insertions(+) | 25 | 3 files changed, 39 insertions(+), 2 deletions(-) |
15 | create mode 100644 tests/tcg/arm/semihosting.c | 26 | create mode 100644 tests/tcg/aarch64/pauth-5.c |
16 | 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 | +} | ||
17 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | 84 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target |
18 | index XXXXXXX..XXXXXXX 100644 | 85 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/tests/tcg/aarch64/Makefile.target | 86 | --- a/tests/tcg/aarch64/Makefile.target |
20 | +++ b/tests/tcg/aarch64/Makefile.target | 87 | +++ b/tests/tcg/aarch64/Makefile.target |
21 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt | 88 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt |
22 | AARCH64_TESTS += pauth-1 pauth-2 | 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 | ||
23 | run-pauth-%: QEMU_OPTS += -cpu max | 95 | run-pauth-%: QEMU_OPTS += -cpu max |
24 | 96 | run-plugin-pauth-%: QEMU_OPTS += -cpu max | |
25 | +# Semihosting smoke test for linux-user | ||
26 | +AARCH64_TESTS += semihosting | ||
27 | +run-semihosting: semihosting | ||
28 | + $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") | ||
29 | + | ||
30 | TESTS += $(AARCH64_TESTS) | ||
31 | diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/tests/tcg/arm/Makefile.target | ||
34 | +++ b/tests/tcg/arm/Makefile.target | ||
35 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt | ||
36 | $(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") | ||
37 | $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) | ||
38 | |||
39 | +# Semihosting smoke test for linux-user | ||
40 | +ARM_TESTS += semihosting | ||
41 | +run-semihosting: semihosting | ||
42 | + $(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)") | ||
43 | + | ||
44 | TESTS += $(ARM_TESTS) | ||
45 | |||
46 | # On ARM Linux only supports 4k pages | ||
47 | diff --git a/tests/tcg/arm/semihosting.c b/tests/tcg/arm/semihosting.c | ||
48 | new file mode 100644 | ||
49 | index XXXXXXX..XXXXXXX | ||
50 | --- /dev/null | ||
51 | +++ b/tests/tcg/arm/semihosting.c | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | +/* | ||
54 | + * linux-user semihosting checks | ||
55 | + * | ||
56 | + * Copyright (c) 2019 | ||
57 | + * Written by Alex Bennée <alex.bennee@linaro.org> | ||
58 | + * | ||
59 | + * SPDX-License-Identifier: GPL-3.0-or-later | ||
60 | + */ | ||
61 | + | ||
62 | +#include <stdint.h> | ||
63 | + | ||
64 | +#define SYS_WRITE0 0x04 | ||
65 | +#define SYS_REPORTEXC 0x18 | ||
66 | + | ||
67 | +void __semi_call(uintptr_t type, uintptr_t arg0) | ||
68 | +{ | ||
69 | +#if defined(__arm__) | ||
70 | + register uintptr_t t asm("r0") = type; | ||
71 | + register uintptr_t a0 asm("r1") = arg0; | ||
72 | + asm("svc 0xab" | ||
73 | + : /* no return */ | ||
74 | + : "r" (t), "r" (a0)); | ||
75 | +#else | ||
76 | + register uintptr_t t asm("x0") = type; | ||
77 | + register uintptr_t a0 asm("x1") = arg0; | ||
78 | + asm("hlt 0xf000" | ||
79 | + : /* no return */ | ||
80 | + : "r" (t), "r" (a0)); | ||
81 | +#endif | ||
82 | +} | ||
83 | + | ||
84 | +int main(int argc, char *argv[argc]) | ||
85 | +{ | ||
86 | +#if defined(__arm__) | ||
87 | + uintptr_t exit_code = 0x20026; | ||
88 | +#else | ||
89 | + uintptr_t exit_block[2] = {0x20026, 0}; | ||
90 | + uintptr_t exit_code = (uintptr_t) &exit_block; | ||
91 | +#endif | ||
92 | + | ||
93 | + __semi_call(SYS_WRITE0, (uintptr_t) "Hello World"); | ||
94 | + __semi_call(SYS_REPORTEXC, exit_code); | ||
95 | + /* if we get here we failed */ | ||
96 | + return -1; | ||
97 | +} | ||
98 | -- | 97 | -- |
99 | 2.20.1 | 98 | 2.20.1 |
100 | 99 | ||
101 | 100 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Kaige Li <likaige@loongson.cn> |
---|---|---|---|
2 | 2 | ||
3 | These were missed in the recent de-tangling so have been updated to be | 3 | GCC version 4.9.4 isn't clever enough to figure out that all |
4 | more actuate. I've also built up ARM_TESTS in a manner similar to | 4 | execution paths in disas_ldst() that use 'fn' will have initialized |
5 | AARCH64_TESTS for better consistency. | 5 | it first, and so it warns: |
6 | 6 | ||
7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 7 | /home/LiKaige/qemu/target/arm/translate-a64.c: In function ‘disas_ldst’: |
8 | /home/LiKaige/qemu/target/arm/translate-a64.c:3392:5: error: ‘fn’ may be used uninitialized in this function [-Werror=maybe-uninitialized] | ||
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 | |||
15 | Make it happy by initializing the variable to NULL. | ||
16 | |||
17 | Signed-off-by: Kaige Li <likaige@loongson.cn> | ||
18 | Message-id: 1596110248-7366-2-git-send-email-likaige@loongson.cn | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Message-id: 20190913151845.12582-2-alex.bennee@linaro.org | 20 | [PMM: Clean up commit message and note which gcc version this was] |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 22 | --- |
12 | tests/tcg/Makefile.target | 7 +++++-- | 23 | target/arm/translate-a64.c | 2 +- |
13 | tests/tcg/aarch64/Makefile.target | 3 ++- | 24 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | tests/tcg/arm/Makefile.target | 15 ++++++++------- | ||
15 | 3 files changed, 15 insertions(+), 10 deletions(-) | ||
16 | 25 | ||
17 | diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target | 26 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
18 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/tests/tcg/Makefile.target | 28 | --- a/target/arm/translate-a64.c |
20 | +++ b/tests/tcg/Makefile.target | 29 | +++ b/target/arm/translate-a64.c |
21 | @@ -XXX,XX +XXX,XX @@ TIMEOUT=15 | 30 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, |
22 | endif | 31 | bool r = extract32(insn, 22, 1); |
23 | 32 | bool a = extract32(insn, 23, 1); | |
24 | ifdef CONFIG_USER_ONLY | 33 | TCGv_i64 tcg_rs, clean_addr; |
25 | -# The order we include is important. We include multiarch, base arch | 34 | - AtomicThreeOpFn *fn; |
26 | -# and finally arch if it's not the same as base arch. | 35 | + AtomicThreeOpFn *fn = NULL; |
27 | +# The order we include is important. We include multiarch first and | 36 | |
28 | +# then the target. If there are common tests shared between | 37 | if (is_vector || !dc_isar_feature(aa64_atomics, s)) { |
29 | +# sub-targets (e.g. ARM & AArch64) then it is up to | 38 | unallocated_encoding(s); |
30 | +# $(TARGET_NAME)/Makefile.target to include the common parent | ||
31 | +# architecture in its VPATH. | ||
32 | -include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target | ||
33 | -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target | ||
34 | |||
35 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/tests/tcg/aarch64/Makefile.target | ||
38 | +++ b/tests/tcg/aarch64/Makefile.target | ||
39 | @@ -XXX,XX +XXX,XX @@ VPATH += $(ARM_SRC) | ||
40 | AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64 | ||
41 | VPATH += $(AARCH64_SRC) | ||
42 | |||
43 | -# we don't build any other ARM test | ||
44 | +# Float-convert Tests | ||
45 | AARCH64_TESTS=fcvt | ||
46 | |||
47 | fcvt: LDFLAGS+=-lm | ||
48 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt | ||
49 | $(call run-test,$<,$(QEMU) $<, "$< on $(TARGET_NAME)") | ||
50 | $(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref) | ||
51 | |||
52 | +# Pauth Tests | ||
53 | AARCH64_TESTS += pauth-1 pauth-2 | ||
54 | run-pauth-%: QEMU_OPTS += -cpu max | ||
55 | |||
56 | diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/tests/tcg/arm/Makefile.target | ||
59 | +++ b/tests/tcg/arm/Makefile.target | ||
60 | @@ -XXX,XX +XXX,XX @@ ARM_SRC=$(SRC_PATH)/tests/tcg/arm | ||
61 | # Set search path for all sources | ||
62 | VPATH += $(ARM_SRC) | ||
63 | |||
64 | -ARM_TESTS=hello-arm test-arm-iwmmxt | ||
65 | - | ||
66 | -TESTS += $(ARM_TESTS) fcvt | ||
67 | - | ||
68 | +# Basic Hello World | ||
69 | +ARM_TESTS = hello-arm | ||
70 | hello-arm: CFLAGS+=-marm -ffreestanding | ||
71 | hello-arm: LDFLAGS+=-nostdlib | ||
72 | |||
73 | +# IWMXT floating point extensions | ||
74 | +ARM_TESTS += test-arm-iwmmxt | ||
75 | test-arm-iwmmxt: CFLAGS+=-marm -march=iwmmxt -mabi=aapcs -mfpu=fpv4-sp-d16 | ||
76 | test-arm-iwmmxt: test-arm-iwmmxt.S | ||
77 | $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) | ||
78 | |||
79 | -ifeq ($(TARGET_NAME), arm) | ||
80 | +# Float-convert Tests | ||
81 | +ARM_TESTS += fcvt | ||
82 | fcvt: LDFLAGS+=-lm | ||
83 | # fcvt: CFLAGS+=-march=armv8.2-a+fp16 -mfpu=neon-fp-armv8 | ||
84 | - | ||
85 | run-fcvt: fcvt | ||
86 | $(call run-test,fcvt,$(QEMU) $<,"$< on $(TARGET_NAME)") | ||
87 | $(call diff-out,fcvt,$(ARM_SRC)/fcvt.ref) | ||
88 | -endif | ||
89 | + | ||
90 | +TESTS += $(ARM_TESTS) | ||
91 | |||
92 | # On ARM Linux only supports 4k pages | ||
93 | EXTRA_RUNS+=run-test-mmap-4096 | ||
94 | -- | 39 | -- |
95 | 2.20.1 | 40 | 2.20.1 |
96 | 41 | ||
97 | 42 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | The nrf51 SoC model wasn't setting 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. | ||
2 | 4 | ||
3 | Now we do all our checking and use a common EXCP_SEMIHOST for | 5 | Set the global to match the documented CPU clock speed for this SoC. |
4 | semihosting operations we can make helper code a lot simpler. | ||
5 | 6 | ||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 7 | This SoC in fact doesn't have a SysTick timer (which is the only thing |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | currently that cares about the system_clock_scale), because it's |
8 | Message-id: 20190913151845.12582-5-alex.bennee@linaro.org | 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 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Message-id: 20200727193458.31250-1-peter.maydell@linaro.org | ||
10 | --- | 16 | --- |
11 | target/arm/helper.c | 96 +++++++++++---------------------------------- | 17 | hw/arm/nrf51_soc.c | 5 +++++ |
12 | 1 file changed, 22 insertions(+), 74 deletions(-) | 18 | 1 file changed, 5 insertions(+) |
13 | 19 | ||
14 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 20 | diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c |
15 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/helper.c | 22 | --- a/hw/arm/nrf51_soc.c |
17 | +++ b/target/arm/helper.c | 23 | +++ b/hw/arm/nrf51_soc.c |
18 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs) | 24 | @@ -XXX,XX +XXX,XX @@ |
19 | new_el, env->pc, pstate_read(env)); | 25 | |
20 | } | 26 | #define BASE_TO_IRQ(base) ((base >> 12) & 0x1F) |
21 | 27 | ||
22 | -static inline bool check_for_semihosting(CPUState *cs) | 28 | +/* HCLK (the main CPU clock) on this SoC is always 16MHz */ |
23 | -{ | 29 | +#define HCLK_FRQ 16000000 |
24 | +/* | 30 | + |
25 | + * Do semihosting call and set the appropriate return value. All the | 31 | static uint64_t clock_read(void *opaque, hwaddr addr, unsigned int size) |
26 | + * permission and validity checks have been done at translate time. | 32 | { |
27 | + * | 33 | qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n", |
28 | + * We only see semihosting exceptions in TCG only as they are not | 34 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) |
29 | + * trapped to the hypervisor in KVM. | ||
30 | + */ | ||
31 | #ifdef CONFIG_TCG | ||
32 | - /* Check whether this exception is a semihosting call; if so | ||
33 | - * then handle it and return true; otherwise return false. | ||
34 | - */ | ||
35 | +static void handle_semihosting(CPUState *cs) | ||
36 | +{ | ||
37 | ARMCPU *cpu = ARM_CPU(cs); | ||
38 | CPUARMState *env = &cpu->env; | ||
39 | |||
40 | if (is_a64(env)) { | ||
41 | - if (cs->exception_index == EXCP_SEMIHOST) { | ||
42 | - /* This is always the 64-bit semihosting exception. | ||
43 | - * The "is this usermode" and "is semihosting enabled" | ||
44 | - * checks have been done at translate time. | ||
45 | - */ | ||
46 | - qemu_log_mask(CPU_LOG_INT, | ||
47 | - "...handling as semihosting call 0x%" PRIx64 "\n", | ||
48 | - env->xregs[0]); | ||
49 | - env->xregs[0] = do_arm_semihosting(env); | ||
50 | - return true; | ||
51 | - } | ||
52 | - return false; | ||
53 | + qemu_log_mask(CPU_LOG_INT, | ||
54 | + "...handling as semihosting call 0x%" PRIx64 "\n", | ||
55 | + env->xregs[0]); | ||
56 | + env->xregs[0] = do_arm_semihosting(env); | ||
57 | } else { | ||
58 | - uint32_t imm; | ||
59 | - | ||
60 | - /* Only intercept calls from privileged modes, to provide some | ||
61 | - * semblance of security. | ||
62 | - */ | ||
63 | - if (cs->exception_index != EXCP_SEMIHOST && | ||
64 | - (!semihosting_enabled() || | ||
65 | - ((env->uncached_cpsr & CPSR_M) == ARM_CPU_MODE_USR))) { | ||
66 | - return false; | ||
67 | - } | ||
68 | - | ||
69 | - switch (cs->exception_index) { | ||
70 | - case EXCP_SEMIHOST: | ||
71 | - /* This is always a semihosting call; the "is this usermode" | ||
72 | - * and "is semihosting enabled" checks have been done at | ||
73 | - * translate time. | ||
74 | - */ | ||
75 | - break; | ||
76 | - case EXCP_SWI: | ||
77 | - /* Check for semihosting interrupt. */ | ||
78 | - if (env->thumb) { | ||
79 | - imm = arm_lduw_code(env, env->regs[15] - 2, arm_sctlr_b(env)) | ||
80 | - & 0xff; | ||
81 | - if (imm == 0xab) { | ||
82 | - break; | ||
83 | - } | ||
84 | - } else { | ||
85 | - imm = arm_ldl_code(env, env->regs[15] - 4, arm_sctlr_b(env)) | ||
86 | - & 0xffffff; | ||
87 | - if (imm == 0x123456) { | ||
88 | - break; | ||
89 | - } | ||
90 | - } | ||
91 | - return false; | ||
92 | - case EXCP_BKPT: | ||
93 | - /* See if this is a semihosting syscall. */ | ||
94 | - if (env->thumb) { | ||
95 | - imm = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) | ||
96 | - & 0xff; | ||
97 | - if (imm == 0xab) { | ||
98 | - env->regs[15] += 2; | ||
99 | - break; | ||
100 | - } | ||
101 | - } | ||
102 | - return false; | ||
103 | - default: | ||
104 | - return false; | ||
105 | - } | ||
106 | - | ||
107 | qemu_log_mask(CPU_LOG_INT, | ||
108 | "...handling as semihosting call 0x%x\n", | ||
109 | env->regs[0]); | ||
110 | env->regs[0] = do_arm_semihosting(env); | ||
111 | - return true; | ||
112 | } | ||
113 | -#else | ||
114 | - return false; | ||
115 | -#endif | ||
116 | } | ||
117 | +#endif | ||
118 | |||
119 | /* Handle a CPU exception for A and R profile CPUs. | ||
120 | * Do any appropriate logging, handle PSCI calls, and then hand off | ||
121 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs) | ||
122 | return; | 35 | return; |
123 | } | 36 | } |
124 | 37 | ||
125 | - /* Semihosting semantics depend on the register width of the | 38 | + system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ; |
126 | - * code that caused the exception, not the target exception level, | 39 | + |
127 | - * so must be handled here. | 40 | object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container), |
128 | + /* | 41 | &error_abort); |
129 | + * Semihosting semantics depend on the register width of the code | 42 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) { |
130 | + * that caused the exception, not the target exception level, so | ||
131 | + * must be handled here. | ||
132 | */ | ||
133 | - if (check_for_semihosting(cs)) { | ||
134 | +#ifdef CONFIG_TCG | ||
135 | + if (cs->exception_index == EXCP_SEMIHOST) { | ||
136 | + handle_semihosting(cs); | ||
137 | return; | ||
138 | } | ||
139 | +#endif | ||
140 | |||
141 | /* Hooks may change global state so BQL should be held, also the | ||
142 | * BQL needs to be held for any modification of | ||
143 | -- | 43 | -- |
144 | 2.20.1 | 44 | 2.20.1 |
145 | 45 | ||
146 | 46 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | The imx_epit device has a software-controllable reset triggered by |
---|---|---|---|
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". | ||
2 | 7 | ||
3 | We do this for other semihosting calls so we might as well do it for | 8 | The cleanest way to avoid this double-transaction is to move the |
4 | M-profile as well. | 9 | start-transaction for the CR write handling down below the check of |
10 | the SWR bit. | ||
5 | 11 | ||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 12 | Fixes: https://bugs.launchpad.net/qemu/+bug/1880424 |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Fixes: cc2722ec83ad944505fe |
8 | Message-id: 20190913151845.12582-3-alex.bennee@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | 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 | ||
11 | --- | 17 | --- |
12 | target/arm/m_helper.c | 18 ++++++------------ | 18 | hw/timer/imx_epit.c | 13 ++++++++++--- |
13 | target/arm/translate.c | 11 ++++++++++- | 19 | 1 file changed, 10 insertions(+), 3 deletions(-) |
14 | 2 files changed, 16 insertions(+), 13 deletions(-) | ||
15 | 20 | ||
16 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 21 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
17 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/m_helper.c | 23 | --- a/hw/timer/imx_epit.c |
19 | +++ b/target/arm/m_helper.c | 24 | +++ b/hw/timer/imx_epit.c |
20 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 25 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, |
21 | break; | 26 | |
27 | switch (offset >> 2) { | ||
28 | case 0: /* CR */ | ||
29 | - ptimer_transaction_begin(s->timer_cmp); | ||
30 | - ptimer_transaction_begin(s->timer_reload); | ||
31 | |||
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 | + } | ||
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); | ||
22 | } | 49 | } |
23 | break; | ||
24 | + case EXCP_SEMIHOST: | ||
25 | + qemu_log_mask(CPU_LOG_INT, | ||
26 | + "...handling as semihosting call 0x%x\n", | ||
27 | + env->regs[0]); | ||
28 | + env->regs[0] = do_arm_semihosting(env); | ||
29 | + return; | ||
30 | case EXCP_BKPT: | ||
31 | - if (semihosting_enabled()) { | ||
32 | - int nr; | ||
33 | - nr = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0xff; | ||
34 | - if (nr == 0xab) { | ||
35 | - env->regs[15] += 2; | ||
36 | - qemu_log_mask(CPU_LOG_INT, | ||
37 | - "...handling as semihosting call 0x%x\n", | ||
38 | - env->regs[0]); | ||
39 | - env->regs[0] = do_arm_semihosting(env); | ||
40 | - return; | ||
41 | - } | ||
42 | - } | ||
43 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false); | ||
44 | break; | ||
45 | case EXCP_IRQ: | ||
46 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/translate.c | ||
49 | +++ b/target/arm/translate.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static bool trans_BKPT(DisasContext *s, arg_BKPT *a) | ||
51 | if (!ENABLE_ARCH_5) { | ||
52 | return false; | ||
53 | } | ||
54 | - gen_exception_bkpt_insn(s, syn_aa32_bkpt(a->imm, false)); | ||
55 | + if (arm_dc_feature(s, ARM_FEATURE_M) && | ||
56 | + semihosting_enabled() && | ||
57 | +#ifndef CONFIG_USER_ONLY | ||
58 | + !IS_USER(s) && | ||
59 | +#endif | ||
60 | + (a->imm == 0xab)) { | ||
61 | + gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST); | ||
62 | + } else { | ||
63 | + gen_exception_bkpt_insn(s, syn_aa32_bkpt(a->imm, false)); | ||
64 | + } | ||
65 | return true; | ||
66 | } | ||
67 | 50 | ||
68 | -- | 51 | -- |
69 | 2.20.1 | 52 | 2.20.1 |
70 | 53 | ||
71 | 54 | diff view generated by jsdifflib |