1 | Handful of bugfixes for rc2. None of these are particularly critical | 1 | A last small test of bug fixes before rc1. |
---|---|---|---|
2 | or exciting. | ||
3 | 2 | ||
3 | thanks | ||
4 | -- PMM | 4 | -- PMM |
5 | 5 | ||
6 | The following changes since commit 45a150aa2b3492acf6691c7bdbeb25a8545d8345: | 6 | The following changes since commit ed8ad9728a9c0eec34db9dff61dfa2f1dd625637: |
7 | 7 | ||
8 | Merge remote-tracking branch 'remotes/ericb/tags/pull-bitmaps-2020-08-03' into staging (2020-08-03 15:13:49 +0100) | 8 | Merge tag 'pull-tpm-2023-07-14-1' of https://github.com/stefanberger/qemu-tpm into staging (2023-07-15 14:54:04 +0100) |
9 | 9 | ||
10 | are available in the Git repository at: | 10 | are available in the Git repository at: |
11 | 11 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200803 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230717 |
13 | 13 | ||
14 | for you to fetch changes up to 13557fd392890cbd985bceba7f717e01efd674b8: | 14 | for you to fetch changes up to c2c1c4a35c7c2b1a4140b0942b9797c857e476a4: |
15 | 15 | ||
16 | hw/timer/imx_epit: Avoid assertion when CR.SWR is written (2020-08-03 17:56:11 +0100) | 16 | hw/nvram: Avoid unnecessary Xilinx eFuse backstore write (2023-07-17 11:05:52 +0100) |
17 | 17 | ||
18 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
19 | target-arm queue: | 19 | target-arm queue: |
20 | * hw/timer/imx_epit: Avoid assertion when CR.SWR is written | 20 | * hw/arm/sbsa-ref: set 'slots' property of xhci |
21 | * netduino2, netduinoplus2, microbit: set system_clock_scale so that | 21 | * linux-user: Remove pointless NULL check in clock_adjtime handling |
22 | SysTick running on the CPU clock works | 22 | * ptw: Fix S1_ptw_translate() debug path |
23 | * target/arm: Avoid maybe-uninitialized warning with gcc 4.9 | 23 | * ptw: Account for FEAT_RME when applying {N}SW, SA bits |
24 | * target/arm: Fix AddPAC error indication | 24 | * accel/tcg: Zero-pad PC in TCG CPU exec trace lines |
25 | * Make AIRCR.SYSRESETREQ actually reset the system for the | 25 | * hw/nvram: Avoid unnecessary Xilinx eFuse backstore write |
26 | microbit, mps2-*, musca-*, netduino* boards | ||
27 | 26 | ||
28 | ---------------------------------------------------------------- | 27 | ---------------------------------------------------------------- |
29 | Kaige Li (1): | 28 | Peter Maydell (5): |
30 | target/arm: Avoid maybe-uninitialized warning with gcc 4.9 | 29 | linux-user: Remove pointless NULL check in clock_adjtime handling |
30 | target/arm/ptw.c: Add comments to S1Translate struct fields | ||
31 | target/arm: Fix S1_ptw_translate() debug path | ||
32 | target/arm/ptw.c: Account for FEAT_RME when applying {N}SW, SA bits | ||
33 | accel/tcg: Zero-pad PC in TCG CPU exec trace lines | ||
31 | 34 | ||
32 | Peter Maydell (6): | 35 | Tong Ho (1): |
33 | hw/arm/netduino2, netduinoplus2: Set system_clock_scale | 36 | hw/nvram: Avoid unnecessary Xilinx eFuse backstore write |
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 | 37 | ||
40 | Richard Henderson (1): | 38 | Yuquan Wang (1): |
41 | target/arm: Fix AddPAC error indication | 39 | hw/arm/sbsa-ref: set 'slots' property of xhci |
42 | 40 | ||
43 | include/hw/arm/armv7m.h | 4 +++- | 41 | accel/tcg/cpu-exec.c | 4 +-- |
44 | include/hw/irq.h | 18 ++++++++++++++++++ | 42 | accel/tcg/translate-all.c | 2 +- |
45 | hw/arm/msf2-soc.c | 11 ----------- | 43 | hw/arm/sbsa-ref.c | 1 + |
46 | hw/arm/netduino2.c | 10 ++++++++++ | 44 | hw/nvram/xlnx-efuse.c | 11 ++++-- |
47 | hw/arm/netduinoplus2.c | 10 ++++++++++ | 45 | linux-user/syscall.c | 12 +++---- |
48 | hw/arm/nrf51_soc.c | 5 +++++ | 46 | target/arm/ptw.c | 90 +++++++++++++++++++++++++++++++++++++++++------ |
49 | hw/arm/stellaris.c | 12 ------------ | 47 | 6 files changed, 98 insertions(+), 22 deletions(-) |
50 | hw/intc/armv7m_nvic.c | 17 ++++++++++++++++- | ||
51 | hw/timer/imx_epit.c | 13 ++++++++++--- | ||
52 | target/arm/pauth_helper.c | 6 +++++- | ||
53 | target/arm/translate-a64.c | 2 +- | ||
54 | tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++++ | ||
55 | tests/tcg/aarch64/Makefile.target | 2 +- | ||
56 | 13 files changed, 112 insertions(+), 31 deletions(-) | ||
57 | create mode 100644 tests/tcg/aarch64/pauth-5.c | ||
58 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The netduino2 and netduinoplus2 boards forgot to set the system_clock_scale | ||
2 | global, which meant that if guest code used the systick timer in "use | ||
3 | the processor clock" mode it would hang because time never advances. | ||
4 | 1 | ||
5 | Set the global to match the documented CPU clock speed of these boards. | ||
6 | Judging by the data sheet this is slightly simplistic because the | ||
7 | SoC allows configuration of the SYSCLK source and frequency via the | ||
8 | RCC (reset and clock control) module, but we don't model that. | ||
9 | |||
10 | Fixes: https://bugs.launchpad.net/qemu/+bug/1876187 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
13 | Message-id: 20200727162617.26227-1-peter.maydell@linaro.org | ||
14 | --- | ||
15 | hw/arm/netduino2.c | 10 ++++++++++ | ||
16 | hw/arm/netduinoplus2.c | 10 ++++++++++ | ||
17 | 2 files changed, 20 insertions(+) | ||
18 | |||
19 | diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/arm/netduino2.c | ||
22 | +++ b/hw/arm/netduino2.c | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | #include "hw/arm/stm32f205_soc.h" | ||
25 | #include "hw/arm/boot.h" | ||
26 | |||
27 | +/* Main SYSCLK frequency in Hz (120MHz) */ | ||
28 | +#define SYSCLK_FRQ 120000000ULL | ||
29 | + | ||
30 | static void netduino2_init(MachineState *machine) | ||
31 | { | ||
32 | DeviceState *dev; | ||
33 | |||
34 | + /* | ||
35 | + * TODO: ideally we would model the SoC RCC and let it handle | ||
36 | + * system_clock_scale, including its ability to define different | ||
37 | + * possible SYSCLK sources. | ||
38 | + */ | ||
39 | + system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | ||
40 | + | ||
41 | dev = qdev_new(TYPE_STM32F205_SOC); | ||
42 | qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3")); | ||
43 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
44 | diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/arm/netduinoplus2.c | ||
47 | +++ b/hw/arm/netduinoplus2.c | ||
48 | @@ -XXX,XX +XXX,XX @@ | ||
49 | #include "hw/arm/stm32f405_soc.h" | ||
50 | #include "hw/arm/boot.h" | ||
51 | |||
52 | +/* Main SYSCLK frequency in Hz (168MHz) */ | ||
53 | +#define SYSCLK_FRQ 168000000ULL | ||
54 | + | ||
55 | static void netduinoplus2_init(MachineState *machine) | ||
56 | { | ||
57 | DeviceState *dev; | ||
58 | |||
59 | + /* | ||
60 | + * TODO: ideally we would model the SoC RCC and let it handle | ||
61 | + * system_clock_scale, including its ability to define different | ||
62 | + * possible SYSCLK sources. | ||
63 | + */ | ||
64 | + system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | ||
65 | + | ||
66 | dev = qdev_new(TYPE_STM32F405_SOC); | ||
67 | qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4")); | ||
68 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
69 | -- | ||
70 | 2.20.1 | ||
71 | |||
72 | diff view generated by jsdifflib |
1 | From: Kaige Li <likaige@loongson.cn> | 1 | From: Yuquan Wang <wangyuquan1236@phytium.com.cn> |
---|---|---|---|
2 | 2 | ||
3 | GCC version 4.9.4 isn't clever enough to figure out that all | 3 | This extends the slots of xhci to 64, since the default xhci_sysbus |
4 | execution paths in disas_ldst() that use 'fn' will have initialized | 4 | just supports one slot. |
5 | it first, and so it warns: | ||
6 | 5 | ||
7 | /home/LiKaige/qemu/target/arm/translate-a64.c: In function ‘disas_ldst’: | 6 | Signed-off-by: Wang Yuquan <wangyuquan1236@phytium.com.cn> |
8 | /home/LiKaige/qemu/target/arm/translate-a64.c:3392:5: error: ‘fn’ may be used uninitialized in this function [-Werror=maybe-uninitialized] | 7 | Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn> |
9 | fn(cpu_reg(s, rt), clean_addr, tcg_rs, get_mem_index(s), | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | ^ | 9 | Reviewed-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
11 | /home/LiKaige/qemu/target/arm/translate-a64.c:3318:22: note: ‘fn’ was declared here | 10 | Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
12 | AtomicThreeOpFn *fn; | 11 | Message-id: 20230710063750.473510-2-wangyuquan1236@phytium.com.cn |
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 | ||
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> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 13 | --- |
23 | target/arm/translate-a64.c | 2 +- | 14 | hw/arm/sbsa-ref.c | 1 + |
24 | 1 file changed, 1 insertion(+), 1 deletion(-) | 15 | 1 file changed, 1 insertion(+) |
25 | 16 | ||
26 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 17 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
27 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/translate-a64.c | 19 | --- a/hw/arm/sbsa-ref.c |
29 | +++ b/target/arm/translate-a64.c | 20 | +++ b/hw/arm/sbsa-ref.c |
30 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | 21 | @@ -XXX,XX +XXX,XX @@ static void create_xhci(const SBSAMachineState *sms) |
31 | bool r = extract32(insn, 22, 1); | 22 | hwaddr base = sbsa_ref_memmap[SBSA_XHCI].base; |
32 | bool a = extract32(insn, 23, 1); | 23 | int irq = sbsa_ref_irqmap[SBSA_XHCI]; |
33 | TCGv_i64 tcg_rs, clean_addr; | 24 | DeviceState *dev = qdev_new(TYPE_XHCI_SYSBUS); |
34 | - AtomicThreeOpFn *fn; | 25 | + qdev_prop_set_uint32(dev, "slots", XHCI_MAXSLOTS); |
35 | + AtomicThreeOpFn *fn = NULL; | 26 | |
36 | 27 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | |
37 | if (is_vector || !dc_isar_feature(aa64_atomics, s)) { | 28 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); |
38 | unallocated_encoding(s); | ||
39 | -- | 29 | -- |
40 | 2.20.1 | 30 | 2.34.1 |
41 | |||
42 | diff view generated by jsdifflib |
1 | The nrf51 SoC model wasn't setting the system_clock_scale | 1 | In the code for TARGET_NR_clock_adjtime, we set the pointer phtx to |
---|---|---|---|
2 | global.which meant that if guest code used the systick timer in "use | 2 | the address of the local variable htx. This means it can never be |
3 | the processor clock" mode it would hang because time never advances. | 3 | NULL, but later in the code we check it for NULL anyway. Coverity |
4 | complains about this (CID 1507683) because the NULL check comes after | ||
5 | a call to clock_adjtime() that assumes it is non-NULL. | ||
4 | 6 | ||
5 | Set the global to match the documented CPU clock speed for this SoC. | 7 | Since phtx is always &htx, and is used only in three places, it's not |
6 | 8 | really necessary. Remove it, bringing the code structure in to line | |
7 | This SoC in fact doesn't have a SysTick timer (which is the only thing | 9 | with that for TARGET_NR_clock_adjtime64, which already uses a simple |
8 | currently that cares about the system_clock_scale), because it's | 10 | '&htx' when it wants a pointer to 'htx'. |
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 | 11 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
15 | Message-id: 20200727193458.31250-1-peter.maydell@linaro.org | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20230623144410.1837261-1-peter.maydell@linaro.org | ||
16 | --- | 16 | --- |
17 | hw/arm/nrf51_soc.c | 5 +++++ | 17 | linux-user/syscall.c | 12 +++++------- |
18 | 1 file changed, 5 insertions(+) | 18 | 1 file changed, 5 insertions(+), 7 deletions(-) |
19 | 19 | ||
20 | diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c | 20 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c |
21 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/nrf51_soc.c | 22 | --- a/linux-user/syscall.c |
23 | +++ b/hw/arm/nrf51_soc.c | 23 | +++ b/linux-user/syscall.c |
24 | @@ -XXX,XX +XXX,XX @@ | 24 | @@ -XXX,XX +XXX,XX @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, |
25 | 25 | #if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME) | |
26 | #define BASE_TO_IRQ(base) ((base >> 12) & 0x1F) | 26 | case TARGET_NR_clock_adjtime: |
27 | 27 | { | |
28 | +/* HCLK (the main CPU clock) on this SoC is always 16MHz */ | 28 | - struct timex htx, *phtx = &htx; |
29 | +#define HCLK_FRQ 16000000 | 29 | + struct timex htx; |
30 | + | 30 | |
31 | static uint64_t clock_read(void *opaque, hwaddr addr, unsigned int size) | 31 | - if (target_to_host_timex(phtx, arg2) != 0) { |
32 | { | 32 | + if (target_to_host_timex(&htx, arg2) != 0) { |
33 | qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n", | 33 | return -TARGET_EFAULT; |
34 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | 34 | } |
35 | return; | 35 | - ret = get_errno(clock_adjtime(arg1, phtx)); |
36 | } | 36 | - if (!is_error(ret) && phtx) { |
37 | 37 | - if (host_to_target_timex(arg2, phtx) != 0) { | |
38 | + system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ; | 38 | - return -TARGET_EFAULT; |
39 | + | 39 | - } |
40 | object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container), | 40 | + ret = get_errno(clock_adjtime(arg1, &htx)); |
41 | &error_abort); | 41 | + if (!is_error(ret) && host_to_target_timex(arg2, &htx)) { |
42 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) { | 42 | + return -TARGET_EFAULT; |
43 | } | ||
44 | } | ||
45 | return ret; | ||
43 | -- | 46 | -- |
44 | 2.20.1 | 47 | 2.34.1 |
45 | 48 | ||
46 | 49 | diff view generated by jsdifflib |
1 | The MSF2 SoC model and the Stellaris board code both wire | 1 | Add comments to the in_* fields in the S1Translate struct |
---|---|---|---|
2 | SYSRESETREQ up to a function that just invokes | 2 | that explain what they're doing. |
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 | 3 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 6 | Message-id: 20230710152130.3928330-2-peter.maydell@linaro.org |
10 | Message-id: 20200728103744.6909-4-peter.maydell@linaro.org | ||
11 | --- | 7 | --- |
12 | hw/arm/msf2-soc.c | 11 ----------- | 8 | target/arm/ptw.c | 40 ++++++++++++++++++++++++++++++++++++++++ |
13 | hw/arm/stellaris.c | 12 ------------ | 9 | 1 file changed, 40 insertions(+) |
14 | 2 files changed, 23 deletions(-) | ||
15 | 10 | ||
16 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c | 11 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
17 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/msf2-soc.c | 13 | --- a/target/arm/ptw.c |
19 | +++ b/hw/arm/msf2-soc.c | 14 | +++ b/target/arm/ptw.c |
20 | @@ -XXX,XX +XXX,XX @@ | 15 | @@ -XXX,XX +XXX,XX @@ |
21 | #include "hw/irq.h" | 16 | #endif |
22 | #include "hw/arm/msf2-soc.h" | 17 | |
23 | #include "hw/misc/unimp.h" | 18 | typedef struct S1Translate { |
24 | -#include "sysemu/runstate.h" | 19 | + /* |
25 | #include "sysemu/sysemu.h" | 20 | + * in_mmu_idx : specifies which TTBR, TCR, etc to use for the walk. |
26 | 21 | + * Together with in_space, specifies the architectural translation regime. | |
27 | #define MSF2_TIMER_BASE 0x40004000 | 22 | + */ |
28 | @@ -XXX,XX +XXX,XX @@ static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 }; | 23 | ARMMMUIdx in_mmu_idx; |
29 | static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 }; | 24 | + /* |
30 | static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 }; | 25 | + * in_ptw_idx: specifies which mmuidx to use for the actual |
31 | 26 | + * page table descriptor load operations. This will be one of the | |
32 | -static void do_sys_reset(void *opaque, int n, int level) | 27 | + * ARMMMUIdx_Stage2* or one of the ARMMMUIdx_Phys_* indexes. |
33 | -{ | 28 | + * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit, |
34 | - if (level) { | 29 | + * this field is updated accordingly. |
35 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | 30 | + */ |
36 | - } | 31 | ARMMMUIdx in_ptw_idx; |
37 | -} | 32 | + /* |
38 | - | 33 | + * in_space: the security space for this walk. This plus |
39 | static void m2sxxx_soc_initfn(Object *obj) | 34 | + * the in_mmu_idx specify the architectural translation regime. |
40 | { | 35 | + * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit, |
41 | MSF2State *s = MSF2_SOC(obj); | 36 | + * this field is updated accordingly. |
42 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | 37 | + * |
43 | return; | 38 | + * Note that the security space for the in_ptw_idx may be different |
44 | } | 39 | + * from that for the in_mmu_idx. We do not need to explicitly track |
45 | 40 | + * the in_ptw_idx security space because: | |
46 | - qdev_connect_gpio_out_named(DEVICE(&s->armv7m.nvic), "SYSRESETREQ", 0, | 41 | + * - if the in_ptw_idx is an ARMMMUIdx_Phys_* then the mmuidx |
47 | - qemu_allocate_irq(&do_sys_reset, NULL, 0)); | 42 | + * itself specifies the security space |
48 | - | 43 | + * - if the in_ptw_idx is an ARMMMUIdx_Stage2* then the security |
49 | system_clock_scale = NANOSECONDS_PER_SECOND / s->m3clk; | 44 | + * space used for ptw reads is the same as that of the security |
50 | 45 | + * space of the stage 1 translation for all cases except where | |
51 | for (i = 0; i < MSF2_NUM_UARTS; i++) { | 46 | + * stage 1 is Secure; in that case the only possibilities for |
52 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | 47 | + * the ptw read are Secure and NonSecure, and the in_ptw_idx |
53 | index XXXXXXX..XXXXXXX 100644 | 48 | + * value being Stage2 vs Stage2_S distinguishes those. |
54 | --- a/hw/arm/stellaris.c | 49 | + */ |
55 | +++ b/hw/arm/stellaris.c | 50 | ARMSecuritySpace in_space; |
56 | @@ -XXX,XX +XXX,XX @@ | 51 | + /* |
57 | #include "hw/boards.h" | 52 | + * in_secure: whether the translation regime is a Secure one. |
58 | #include "qemu/log.h" | 53 | + * This is always equal to arm_space_is_secure(in_space). |
59 | #include "exec/address-spaces.h" | 54 | + * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit, |
60 | -#include "sysemu/runstate.h" | 55 | + * this field is updated accordingly. |
61 | #include "sysemu/sysemu.h" | 56 | + */ |
62 | #include "hw/arm/armv7m.h" | 57 | bool in_secure; |
63 | #include "hw/char/pl011.h" | 58 | + /* |
64 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_init(Object *obj) | 59 | + * in_debug: is this a QEMU debug access (gdbstub, etc)? Debug |
65 | qdev_init_gpio_in(dev, stellaris_adc_trigger, 1); | 60 | + * accesses will not update the guest page table access flags |
66 | } | 61 | + * and will not change the state of the softmmu TLBs. |
67 | 62 | + */ | |
68 | -static | 63 | bool in_debug; |
69 | -void do_sys_reset(void *opaque, int n, int level) | 64 | /* |
70 | -{ | 65 | * If this is stage 2 of a stage 1+2 page table walk, then this must |
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 | -- | 66 | -- |
90 | 2.20.1 | 67 | 2.34.1 |
91 | |||
92 | diff view generated by jsdifflib |
1 | The NVIC provides an outbound qemu_irq "SYSRESETREQ" which it signals | 1 | In commit fe4a5472ccd6 we rearranged the logic in S1_ptw_translate() |
---|---|---|---|
2 | when the guest sets the SYSRESETREQ bit in the AIRCR register. This | 2 | so that the debug-access "call get_phys_addr_*" codepath is used both |
3 | matches the hardware design (where the CPU has a signal of this name | 3 | when S1 is doing ptw reads from stage 2 and when it is doing ptw |
4 | and it is up to the SoC to connect that up to an actual reset | 4 | reads from physical memory. However, we didn't update the |
5 | mechanism), but in QEMU it mostly results in duplicated code in SoC | 5 | calculation of s2ptw->in_space and s2ptw->in_secure to account for |
6 | objects and bugs where SoC model implementors forget to wire up the | 6 | the "ptw reads from physical memory" case. This meant that debug |
7 | SYSRESETREQ line. | 7 | accesses when in Secure state broke. |
8 | 8 | ||
9 | Provide a default behaviour for the case where SYSRESETREQ is not | 9 | Create a new function S2_security_space() which returns the |
10 | actually connected to anything: use qemu_system_reset_request() to | 10 | correct security space to use for the ptw load, and use it to |
11 | perform a system reset. This will allow us to remove the | 11 | determine the correct .in_secure and .in_space fields for the |
12 | implementations of SYSRESETREQ handling from the boards where that's | 12 | stage 2 lookup for the ptw load. |
13 | exactly what it does, and also fixes the bugs in the board models | ||
14 | which forgot to wire up the signal: | ||
15 | 13 | ||
16 | * microbit | 14 | Reported-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
17 | * mps2-an385 | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | * mps2-an505 | 16 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
19 | * mps2-an511 | 17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
20 | * mps2-an521 | 18 | Message-id: 20230710152130.3928330-3-peter.maydell@linaro.org |
21 | * musca-a | 19 | Fixes: fe4a5472ccd6 ("target/arm: Use get_phys_addr_with_struct in S1_ptw_translate") |
22 | * musca-b1 | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | * netduino | 21 | --- |
24 | * netduinoplus2 | 22 | target/arm/ptw.c | 37 ++++++++++++++++++++++++++++++++----- |
23 | 1 file changed, 32 insertions(+), 5 deletions(-) | ||
25 | 24 | ||
26 | We still allow the board to wire up the signal if it needs to, in case | 25 | diff --git a/target/arm/ptw.c b/target/arm/ptw.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 | 26 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/include/hw/arm/armv7m.h | 27 | --- a/target/arm/ptw.c |
44 | +++ b/include/hw/arm/armv7m.h | 28 | +++ b/target/arm/ptw.c |
45 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 29 | @@ -XXX,XX +XXX,XX @@ static bool S2_attrs_are_device(uint64_t hcr, uint8_t attrs) |
46 | 30 | } | |
47 | /* ARMv7M container object. | 31 | } |
48 | * + Unnamed GPIO input lines: external IRQ lines for the NVIC | 32 | |
49 | - * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ | 33 | +static ARMSecuritySpace S2_security_space(ARMSecuritySpace s1_space, |
50 | + * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ. | 34 | + ARMMMUIdx s2_mmu_idx) |
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 | +{ | 35 | +{ |
74 | + if (qemu_irq_is_connected(s->sysresetreq)) { | 36 | + /* |
75 | + qemu_irq_pulse(s->sysresetreq); | 37 | + * Return the security space to use for stage 2 when doing |
38 | + * the S1 page table descriptor load. | ||
39 | + */ | ||
40 | + if (regime_is_stage2(s2_mmu_idx)) { | ||
41 | + /* | ||
42 | + * The security space for ptw reads is almost always the same | ||
43 | + * as that of the security space of the stage 1 translation. | ||
44 | + * The only exception is when stage 1 is Secure; in that case | ||
45 | + * the ptw read might be to the Secure or the NonSecure space | ||
46 | + * (but never Realm or Root), and the s2_mmu_idx tells us which. | ||
47 | + * Root translations are always single-stage. | ||
48 | + */ | ||
49 | + if (s1_space == ARMSS_Secure) { | ||
50 | + return arm_secure_to_space(s2_mmu_idx == ARMMMUIdx_Stage2_S); | ||
51 | + } else { | ||
52 | + assert(s2_mmu_idx != ARMMMUIdx_Stage2_S); | ||
53 | + assert(s1_space != ARMSS_Root); | ||
54 | + return s1_space; | ||
55 | + } | ||
76 | + } else { | 56 | + } else { |
77 | + /* | 57 | + /* ptw loads are from phys: the mmu idx itself says which space */ |
78 | + * Default behaviour if the SoC doesn't need to wire up | 58 | + return arm_phys_to_space(s2_mmu_idx); |
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 | + } | 59 | + } |
84 | +} | 60 | +} |
85 | + | 61 | + |
86 | static int nvic_pending_prio(NVICState *s) | 62 | /* Translate a S1 pagetable walk through S2 if needed. */ |
63 | static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, | ||
64 | hwaddr addr, ARMMMUFaultInfo *fi) | ||
87 | { | 65 | { |
88 | /* return the group priority of the current pending interrupt, | 66 | - ARMSecuritySpace space = ptw->in_space; |
89 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | 67 | bool is_secure = ptw->in_secure; |
90 | if (value & R_V7M_AIRCR_SYSRESETREQ_MASK) { | 68 | ARMMMUIdx mmu_idx = ptw->in_mmu_idx; |
91 | if (attrs.secure || | 69 | ARMMMUIdx s2_mmu_idx = ptw->in_ptw_idx; |
92 | !(cpu->env.v7m.aircr & R_V7M_AIRCR_SYSRESETREQS_MASK)) { | 70 | @@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, |
93 | - qemu_irq_pulse(s->sysresetreq); | 71 | * From gdbstub, do not use softmmu so that we don't modify the |
94 | + signal_sysresetreq(s); | 72 | * state of the cpu at all, including softmmu tlb contents. |
95 | } | 73 | */ |
96 | } | 74 | + ARMSecuritySpace s2_space = S2_security_space(ptw->in_space, s2_mmu_idx); |
97 | if (value & R_V7M_AIRCR_VECTCLRACTIVE_MASK) { | 75 | S1Translate s2ptw = { |
76 | .in_mmu_idx = s2_mmu_idx, | ||
77 | .in_ptw_idx = ptw_idx_for_stage_2(env, s2_mmu_idx), | ||
78 | - .in_secure = s2_mmu_idx == ARMMMUIdx_Stage2_S, | ||
79 | - .in_space = (s2_mmu_idx == ARMMMUIdx_Stage2_S ? ARMSS_Secure | ||
80 | - : space == ARMSS_Realm ? ARMSS_Realm | ||
81 | - : ARMSS_NonSecure), | ||
82 | + .in_secure = arm_space_is_secure(s2_space), | ||
83 | + .in_space = s2_space, | ||
84 | .in_debug = true, | ||
85 | }; | ||
86 | GetPhysAddrResult s2 = { }; | ||
98 | -- | 87 | -- |
99 | 2.20.1 | 88 | 2.34.1 |
100 | |||
101 | diff view generated by jsdifflib |
1 | Mostly devices don't need to care whether one of their output | 1 | In get_phys_addr_twostage() the code that applies the effects of |
---|---|---|---|
2 | qemu_irq lines is connected, because functions like qemu_set_irq() | 2 | VSTCR.{SA,SW} and VTCR.{NSA,NSW} only updates result->f.attrs.secure. |
3 | silently do nothing if there is nothing on the other end. However | 3 | Now we also have f.attrs.space for FEAT_RME, we need to keep the two |
4 | sometimes a device might want to implement default behaviour for the | 4 | in sync. |
5 | case where the machine hasn't wired the line up to anywhere. | ||
6 | 5 | ||
7 | Provide a function qemu_irq_is_connected() that devices can use for | 6 | These bits only have an effect for Secure space translations, not |
8 | this purpose. (The test is trivial but encapsulating it in a | 7 | for Root, so use the input in_space field to determine whether to |
9 | function makes it easier to see where we're doing it in case we need | 8 | apply them rather than the input is_secure. This doesn't actually |
10 | to change the implementation later.) | 9 | make a difference because Root translations are never two-stage, |
10 | but it's a little clearer. | ||
11 | 11 | ||
12 | 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> | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 14 | Message-id: 20230710152130.3928330-4-peter.maydell@linaro.org |
15 | Message-id: 20200728103744.6909-2-peter.maydell@linaro.org | ||
16 | --- | 15 | --- |
17 | include/hw/irq.h | 18 ++++++++++++++++++ | 16 | target/arm/ptw.c | 13 ++++++++----- |
18 | 1 file changed, 18 insertions(+) | 17 | 1 file changed, 8 insertions(+), 5 deletions(-) |
19 | 18 | ||
20 | diff --git a/include/hw/irq.h b/include/hw/irq.h | 19 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
21 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/irq.h | 21 | --- a/target/arm/ptw.c |
23 | +++ b/include/hw/irq.h | 22 | +++ b/target/arm/ptw.c |
24 | @@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); | 23 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, |
25 | on an existing vector of qemu_irq. */ | 24 | hwaddr ipa; |
26 | void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n); | 25 | int s1_prot, s1_lgpgsz; |
27 | 26 | bool is_secure = ptw->in_secure; | |
28 | +/** | 27 | + ARMSecuritySpace in_space = ptw->in_space; |
29 | + * qemu_irq_is_connected: Return true if IRQ line is wired up | 28 | bool ret, ipa_secure; |
30 | + * | 29 | ARMCacheAttrs cacheattrs1; |
31 | + * If a qemu_irq has a device on the other (receiving) end of it, | 30 | ARMSecuritySpace ipa_space; |
32 | + * return true; otherwise return false. | 31 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, |
33 | + * | 32 | * Check if IPA translates to secure or non-secure PA space. |
34 | + * Usually device models don't need to care whether the machine model | 33 | * Note that VSTCR overrides VTCR and {N}SW overrides {N}SA. |
35 | + * has wired up their outbound qemu_irq lines, because functions like | 34 | */ |
36 | + * qemu_set_irq() silently do nothing if there is nothing on the other | 35 | - result->f.attrs.secure = |
37 | + * end of the line. However occasionally a device model will want to | 36 | - (is_secure |
38 | + * provide default behaviour if its output is left floating, and | 37 | - && !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)) |
39 | + * it can use this function to identify when that is the case. | 38 | - && (ipa_secure |
40 | + */ | 39 | - || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW)))); |
41 | +static inline bool qemu_irq_is_connected(qemu_irq irq) | 40 | + if (in_space == ARMSS_Secure) { |
42 | +{ | 41 | + result->f.attrs.secure = |
43 | + return irq != NULL; | 42 | + !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)) |
44 | +} | 43 | + && (ipa_secure |
45 | + | 44 | + || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW))); |
46 | #endif | 45 | + result->f.attrs.space = arm_secure_to_space(result->f.attrs.secure); |
46 | + } | ||
47 | |||
48 | return false; | ||
49 | } | ||
47 | -- | 50 | -- |
48 | 2.20.1 | 51 | 2.34.1 |
49 | |||
50 | diff view generated by jsdifflib |
1 | The imx_epit device has a software-controllable reset triggered by | 1 | In commit f0a08b0913befbd we changed the type of the PC from |
---|---|---|---|
2 | setting the SWR bit in the CR register. An error in commit cc2722ec83ad9 | 2 | target_ulong to vaddr. In doing so we inadvertently dropped the |
3 | means that we will end up assert()ing if the guest does this, because | 3 | zero-padding on the PC in trace lines (the second item inside the [] |
4 | the code in imx_epit_write() starts ptimer transactions, and then | 4 | in these lines). They used to look like this on AArch64, for |
5 | imx_epit_reset() also starts ptimer transactions, triggering | 5 | instance: |
6 | "ptimer_transaction_begin: Assertion `!s->in_transaction' failed". | ||
7 | 6 | ||
8 | The cleanest way to avoid this double-transaction is to move the | 7 | Trace 0: 0x7f2260000100 [00000000/0000000040000000/00000061/ff200000] |
9 | start-transaction for the CR write handling down below the check of | ||
10 | the SWR bit. | ||
11 | 8 | ||
12 | Fixes: https://bugs.launchpad.net/qemu/+bug/1880424 | 9 | and now they look like this: |
13 | Fixes: cc2722ec83ad944505fe | 10 | Trace 0: 0x7f4f50000100 [00000000/40000000/00000061/ff200000] |
11 | |||
12 | and if the PC happens to be somewhere low like 0x5000 | ||
13 | then the field is shown as /5000/. | ||
14 | |||
15 | This is because TARGET_FMT_lx is a "%08x" or "%016x" specifier, | ||
16 | depending on TARGET_LONG_SIZE, whereas VADDR_PRIx is just PRIx64 | ||
17 | with no width specifier. | ||
18 | |||
19 | Restore the zero-padding by adding an 016 width specifier to | ||
20 | this tracing and a couple of others that were similarly recently | ||
21 | changed to use VADDR_PRIx without a width specifier. | ||
22 | |||
23 | We can't unfortunately restore the "32-bit guests are padded to | ||
24 | 8 hex digits and 64-bit guests to 16 hex digits" behaviour so | ||
25 | easily. | ||
26 | |||
27 | Fixes: f0a08b0913befbd ("accel/tcg/cpu-exec.c: Widen pc to vaddr") | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 29 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
16 | Message-id: 20200727154550.3409-1-peter.maydell@linaro.org | 30 | Reviewed-by: Anton Johansson <anjo@rev.ng> |
31 | Message-id: 20230711165434.4123674-1-peter.maydell@linaro.org | ||
17 | --- | 32 | --- |
18 | hw/timer/imx_epit.c | 13 ++++++++++--- | 33 | accel/tcg/cpu-exec.c | 4 ++-- |
19 | 1 file changed, 10 insertions(+), 3 deletions(-) | 34 | accel/tcg/translate-all.c | 2 +- |
35 | 2 files changed, 3 insertions(+), 3 deletions(-) | ||
20 | 36 | ||
21 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c | 37 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c |
22 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/timer/imx_epit.c | 39 | --- a/accel/tcg/cpu-exec.c |
24 | +++ b/hw/timer/imx_epit.c | 40 | +++ b/accel/tcg/cpu-exec.c |
25 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | 41 | @@ -XXX,XX +XXX,XX @@ static void log_cpu_exec(vaddr pc, CPUState *cpu, |
26 | 42 | if (qemu_log_in_addr_range(pc)) { | |
27 | switch (offset >> 2) { | 43 | qemu_log_mask(CPU_LOG_EXEC, |
28 | case 0: /* CR */ | 44 | "Trace %d: %p [%08" PRIx64 |
29 | - ptimer_transaction_begin(s->timer_cmp); | 45 | - "/%" VADDR_PRIx "/%08x/%08x] %s\n", |
30 | - ptimer_transaction_begin(s->timer_reload); | 46 | + "/%016" VADDR_PRIx "/%08x/%08x] %s\n", |
31 | 47 | cpu->cpu_index, tb->tc.ptr, tb->cs_base, pc, | |
32 | oldcr = s->cr; | 48 | tb->flags, tb->cflags, lookup_symbol(pc)); |
33 | s->cr = value & 0x03ffffff; | 49 | |
34 | if (s->cr & CR_SWR) { | 50 | @@ -XXX,XX +XXX,XX @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit) |
35 | /* handle the reset */ | 51 | if (qemu_loglevel_mask(CPU_LOG_EXEC)) { |
36 | imx_epit_reset(DEVICE(s)); | 52 | vaddr pc = log_pc(cpu, last_tb); |
37 | - } else { | 53 | if (qemu_log_in_addr_range(pc)) { |
38 | + /* | 54 | - qemu_log("Stopped execution of TB chain before %p [%" |
39 | + * TODO: could we 'break' here? following operations appear | 55 | + qemu_log("Stopped execution of TB chain before %p [%016" |
40 | + * to duplicate the work imx_epit_reset() already did. | 56 | VADDR_PRIx "] %s\n", |
41 | + */ | 57 | last_tb->tc.ptr, pc, lookup_symbol(pc)); |
42 | + } | 58 | } |
43 | + | 59 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c |
44 | + ptimer_transaction_begin(s->timer_cmp); | 60 | index XXXXXXX..XXXXXXX 100644 |
45 | + ptimer_transaction_begin(s->timer_reload); | 61 | --- a/accel/tcg/translate-all.c |
46 | + | 62 | +++ b/accel/tcg/translate-all.c |
47 | + if (!(s->cr & CR_SWR)) { | 63 | @@ -XXX,XX +XXX,XX @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) |
48 | imx_epit_set_freq(s); | 64 | if (qemu_loglevel_mask(CPU_LOG_EXEC)) { |
65 | vaddr pc = log_pc(cpu, tb); | ||
66 | if (qemu_log_in_addr_range(pc)) { | ||
67 | - qemu_log("cpu_io_recompile: rewound execution of TB to %" | ||
68 | + qemu_log("cpu_io_recompile: rewound execution of TB to %016" | ||
69 | VADDR_PRIx "\n", pc); | ||
49 | } | 70 | } |
50 | 71 | } | |
51 | -- | 72 | -- |
52 | 2.20.1 | 73 | 2.34.1 |
53 | 74 | ||
54 | 75 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Tong Ho <tong.ho@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | The definition of top_bit used in this function is one higher | 3 | Add a check in the bit-set operation to write the backstore |
4 | than that used in the Arm ARM psuedo-code, which put the error | 4 | only if the affected bit is 0 before. |
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 | With this in place, there will be no need for callers to |
9 | its most common use is for the count of bits in top_bit:bot_bit, | 7 | do the checking in order to avoid unnecessary writes. |
10 | which would then need to be computed as top_bit - bot_bit + 1. | ||
11 | 8 | ||
12 | For now, prefer the minimal fix to the error indication alone. | 9 | Signed-off-by: Tong Ho <tong.ho@amd.com> |
13 | 10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | |
14 | Fixes: 63ff0ca94cb | 11 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> |
15 | Reported-by: Derrick McKee <derrick.mckee@gmail.com> | 12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
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> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | --- | 14 | --- |
22 | target/arm/pauth_helper.c | 6 +++++- | 15 | hw/nvram/xlnx-efuse.c | 11 +++++++++-- |
23 | tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++ | 16 | 1 file changed, 9 insertions(+), 2 deletions(-) |
24 | tests/tcg/aarch64/Makefile.target | 2 +- | ||
25 | 3 files changed, 39 insertions(+), 2 deletions(-) | ||
26 | create mode 100644 tests/tcg/aarch64/pauth-5.c | ||
27 | 17 | ||
28 | diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c | 18 | diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c |
29 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/pauth_helper.c | 20 | --- a/hw/nvram/xlnx-efuse.c |
31 | +++ b/target/arm/pauth_helper.c | 21 | +++ b/hw/nvram/xlnx-efuse.c |
32 | @@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, | 22 | @@ -XXX,XX +XXX,XX @@ static bool efuse_ro_bits_find(XlnxEFuse *s, uint32_t k) |
33 | */ | 23 | |
34 | test = sextract64(ptr, bot_bit, top_bit - bot_bit); | 24 | bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit) |
35 | if (test != 0 && test != -1) { | 25 | { |
36 | - pac ^= MAKE_64BIT_MASK(top_bit - 1, 1); | 26 | + uint32_t set, *row; |
37 | + /* | 27 | + |
38 | + * Note that our top_bit is one greater than the pseudocode's | 28 | if (efuse_ro_bits_find(s, bit)) { |
39 | + * version, hence "- 2" here. | 29 | g_autofree char *path = object_get_canonical_path(OBJECT(s)); |
40 | + */ | 30 | |
41 | + pac ^= MAKE_64BIT_MASK(top_bit - 2, 1); | 31 | @@ -XXX,XX +XXX,XX @@ bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit) |
32 | return false; | ||
42 | } | 33 | } |
43 | 34 | ||
44 | /* | 35 | - s->fuse32[bit / 32] |= 1 << (bit % 32); |
45 | diff --git a/tests/tcg/aarch64/pauth-5.c b/tests/tcg/aarch64/pauth-5.c | 36 | - efuse_bdrv_sync(s, bit); |
46 | new file mode 100644 | 37 | + /* Avoid back-end write unless there is a real update */ |
47 | index XXXXXXX..XXXXXXX | 38 | + row = &s->fuse32[bit / 32]; |
48 | --- /dev/null | 39 | + set = 1 << (bit % 32); |
49 | +++ b/tests/tcg/aarch64/pauth-5.c | 40 | + if (!(set & *row)) { |
50 | @@ -XXX,XX +XXX,XX @@ | 41 | + *row |= set; |
51 | +#include <assert.h> | 42 | + efuse_bdrv_sync(s, bit); |
52 | + | 43 | + } |
53 | +static int x; | 44 | return true; |
54 | + | 45 | } |
55 | +int main() | 46 | |
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 | -- | 47 | -- |
98 | 2.20.1 | 48 | 2.34.1 |
99 | 49 | ||
100 | 50 | diff view generated by jsdifflib |