1 | target-arm queue for 3.1: mostly bug fixes, but the "turn on | 1 | Handful of bugfixes for rc2. None of these are particularly critical |
---|---|---|---|
2 | EL2 support for Cortex-A7 and -A15" is technically enabling | 2 | or exciting. |
3 | of a new feature... I think this is OK since we're only at rc1, | ||
4 | and it's easy to revert that feature bit flip if necessary. | ||
5 | 3 | ||
6 | thanks | ||
7 | -- PMM | 4 | -- PMM |
8 | 5 | ||
6 | The following changes since commit 45a150aa2b3492acf6691c7bdbeb25a8545d8345: | ||
9 | 7 | ||
10 | The following changes since commit 5704c36d25ee84e7129722cb0db53df9faefe943: | 8 | Merge remote-tracking branch 'remotes/ericb/tags/pull-bitmaps-2020-08-03' into staging (2020-08-03 15:13:49 +0100) |
11 | |||
12 | Merge remote-tracking branch 'remotes/kraxel/tags/fixes-31-20181112-pull-request' into staging (2018-11-12 15:55:40 +0000) | ||
13 | 9 | ||
14 | are available in the Git repository at: | 10 | are available in the Git repository at: |
15 | 11 | ||
16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20181112 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200803 |
17 | 13 | ||
18 | for you to fetch changes up to 1a4c1a6dbf60aebddd07753f1013ea896c06ad29: | 14 | for you to fetch changes up to 13557fd392890cbd985bceba7f717e01efd674b8: |
19 | 15 | ||
20 | target/arm/cpu: Give Cortex-A15 and -A7 the EL2 feature (2018-11-12 16:52:29 +0000) | 16 | hw/timer/imx_epit: Avoid assertion when CR.SWR is written (2020-08-03 17:56:11 +0100) |
21 | 17 | ||
22 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
23 | target/arm queue: | 19 | target-arm queue: |
24 | * Remove no-longer-needed workaround for small SAU regions for v8M | 20 | * hw/timer/imx_epit: Avoid assertion when CR.SWR is written |
25 | * Remove antique TODO comment | 21 | * netduino2, netduinoplus2, microbit: set system_clock_scale so that |
26 | * MAINTAINERS: Add an entry for the 'collie' machine | 22 | SysTick running on the CPU clock works |
27 | * hw/arm/sysbus-fdt: Only call match_fn callback if the type matches | 23 | * target/arm: Avoid maybe-uninitialized warning with gcc 4.9 |
28 | * Fix infinite recursion in tlbi_aa64_vmalle1_write() | 24 | * target/arm: Fix AddPAC error indication |
29 | * ARM KVM: fix various bugs in handling of guest debugging | 25 | * Make AIRCR.SYSRESETREQ actually reset the system for the |
30 | * Correctly implement handling of HCR_EL2.{VI, VF} | 26 | microbit, mps2-*, musca-*, netduino* boards |
31 | * Hyp mode R14 is shared with User and System | ||
32 | * Give Cortex-A15 and -A7 the EL2 feature | ||
33 | 27 | ||
34 | ---------------------------------------------------------------- | 28 | ---------------------------------------------------------------- |
35 | Alex Bennée (6): | 29 | Kaige Li (1): |
36 | target/arm64: properly handle DBGVR RESS bits | 30 | target/arm: Avoid maybe-uninitialized warning with gcc 4.9 |
37 | target/arm64: hold BQL when calling do_interrupt() | ||
38 | target/arm64: kvm debug set target_el when passing exception to guest | ||
39 | tests/guest-debug: fix scoping of failcount | ||
40 | arm: use symbolic MDCR_TDE in arm_debug_target_el | ||
41 | arm: fix aa64_generate_debug_exceptions to work with EL2 | ||
42 | 31 | ||
43 | Eric Auger (1): | 32 | Peter Maydell (6): |
44 | hw/arm/sysbus-fdt: Only call match_fn callback if the type matches | 33 | hw/arm/netduino2, netduinoplus2: Set system_clock_scale |
45 | 34 | include/hw/irq.h: New function qemu_irq_is_connected() | |
46 | Peter Maydell (7): | 35 | hw/intc/armv7m_nvic: Provide default "reset the system" behaviour for SYSRESETREQ |
47 | target/arm: Remove workaround for small SAU regions | 36 | msf2-soc, stellaris: Don't wire up SYSRESETREQ |
48 | target/arm: Remove antique TODO comment | 37 | hw/arm/nrf51_soc: Set system_clock_scale |
49 | Revert "target/arm: Implement HCR.VI and VF" | 38 | hw/timer/imx_epit: Avoid assertion when CR.SWR is written |
50 | target/arm: Track the state of our irq lines from the GIC explicitly | ||
51 | target/arm: Correctly implement handling of HCR_EL2.{VI, VF} | ||
52 | target/arm: Hyp mode R14 is shared with User and System | ||
53 | target/arm/cpu: Give Cortex-A15 and -A7 the EL2 feature | ||
54 | 39 | ||
55 | Richard Henderson (1): | 40 | Richard Henderson (1): |
56 | target/arm: Fix typo in tlbi_aa64_vmalle1_write | 41 | target/arm: Fix AddPAC error indication |
57 | 42 | ||
58 | Thomas Huth (1): | 43 | include/hw/arm/armv7m.h | 4 +++- |
59 | MAINTAINERS: Add an entry for the 'collie' machine | 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 | ||
60 | 58 | ||
61 | target/arm/cpu.h | 44 +++++++++++------ | ||
62 | target/arm/internals.h | 34 +++++++++++++ | ||
63 | hw/arm/sysbus-fdt.c | 12 +++-- | ||
64 | target/arm/cpu.c | 66 ++++++++++++++++++++++++- | ||
65 | target/arm/helper.c | 101 +++++++++++++------------------------- | ||
66 | target/arm/kvm32.c | 4 +- | ||
67 | target/arm/kvm64.c | 20 +++++++- | ||
68 | target/arm/machine.c | 51 +++++++++++++++++++ | ||
69 | target/arm/op_helper.c | 4 +- | ||
70 | MAINTAINERS | 7 +++ | ||
71 | tests/guest-debug/test-gdbstub.py | 1 + | ||
72 | 11 files changed, 248 insertions(+), 96 deletions(-) | ||
73 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Before we supported direct execution from MMIO regions, we | ||
2 | implemented workarounds in commit 720424359917887c926a33d2 | ||
3 | which let us avoid doing so, even if the SAU or MPU region | ||
4 | was less than page-sized. | ||
5 | 1 | ||
6 | Once we implemented execute-from-MMIO, we removed part | ||
7 | of those workarounds in commit d4b6275df320cee76; but | ||
8 | we forgot the one in get_phys_addr_pmsav8() which | ||
9 | suppressed use of small SAU regions in executable regions. | ||
10 | Remove that workaround now. | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20181106163801.14474-1-peter.maydell@linaro.org | ||
16 | --- | ||
17 | target/arm/helper.c | 12 ------------ | ||
18 | 1 file changed, 12 deletions(-) | ||
19 | |||
20 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/target/arm/helper.c | ||
23 | +++ b/target/arm/helper.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address, | ||
25 | |||
26 | ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, phys_ptr, | ||
27 | txattrs, prot, &mpu_is_subpage, fi, NULL); | ||
28 | - /* | ||
29 | - * TODO: this is a temporary hack to ignore the fact that the SAU region | ||
30 | - * is smaller than a page if this is an executable region. We never | ||
31 | - * supported small MPU regions, but we did (accidentally) allow small | ||
32 | - * SAU regions, and if we now made small SAU regions not be executable | ||
33 | - * then this would break previously working guest code. We can't | ||
34 | - * remove this until/unless we implement support for execution from | ||
35 | - * small regions. | ||
36 | - */ | ||
37 | - if (*prot & PAGE_EXEC) { | ||
38 | - sattrs.subpage = false; | ||
39 | - } | ||
40 | *page_size = sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE; | ||
41 | return ret; | ||
42 | } | ||
43 | -- | ||
44 | 2.19.1 | ||
45 | |||
46 | diff view generated by jsdifflib |
1 | The Cortex-A15 and Cortex-A7 both have EL2; now we've implemented | 1 | The netduino2 and netduinoplus2 boards forgot to set the system_clock_scale |
---|---|---|---|
2 | it properly we can enable the feature bit. | 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. | ||
3 | 4 | ||
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 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
6 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 13 | Message-id: 20200727162617.26227-1-peter.maydell@linaro.org |
7 | Message-id: 20181109173553.22341-3-peter.maydell@linaro.org | ||
8 | --- | 14 | --- |
9 | target/arm/cpu.c | 2 ++ | 15 | hw/arm/netduino2.c | 10 ++++++++++ |
10 | 1 file changed, 2 insertions(+) | 16 | hw/arm/netduinoplus2.c | 10 ++++++++++ |
17 | 2 files changed, 20 insertions(+) | ||
11 | 18 | ||
12 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 19 | diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c |
13 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/target/arm/cpu.c | 21 | --- a/hw/arm/netduino2.c |
15 | +++ b/target/arm/cpu.c | 22 | +++ b/hw/arm/netduino2.c |
16 | @@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj) | 23 | @@ -XXX,XX +XXX,XX @@ |
17 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | 24 | #include "hw/arm/stm32f205_soc.h" |
18 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | 25 | #include "hw/arm/boot.h" |
19 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | 26 | |
20 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | 27 | +/* Main SYSCLK frequency in Hz (120MHz) */ |
21 | set_feature(&cpu->env, ARM_FEATURE_EL3); | 28 | +#define SYSCLK_FRQ 120000000ULL |
22 | cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A7; | 29 | + |
23 | cpu->midr = 0x410fc075; | 30 | static void netduino2_init(MachineState *machine) |
24 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | 31 | { |
25 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | 32 | DeviceState *dev; |
26 | set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); | 33 | |
27 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | 34 | + /* |
28 | + set_feature(&cpu->env, ARM_FEATURE_EL2); | 35 | + * TODO: ideally we would model the SoC RCC and let it handle |
29 | set_feature(&cpu->env, ARM_FEATURE_EL3); | 36 | + * system_clock_scale, including its ability to define different |
30 | cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A15; | 37 | + * possible SYSCLK sources. |
31 | cpu->midr = 0x412fc0f1; | 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); | ||
32 | -- | 69 | -- |
33 | 2.19.1 | 70 | 2.20.1 |
34 | 71 | ||
35 | 72 | diff view generated by jsdifflib |
1 | Hyp mode is an exception to the general rule that each AArch32 | 1 | Mostly devices don't need to care whether one of their output |
---|---|---|---|
2 | mode has its own r13, r14 and SPSR -- it has a banked r13 and | 2 | qemu_irq lines is connected, because functions like qemu_set_irq() |
3 | SPSR but shares its r14 with User and System mode. We were | 3 | silently do nothing if there is nothing on the other end. However |
4 | incorrectly implementing it as banked, which meant that on | 4 | sometimes a device might want to implement default behaviour for the |
5 | entry to Hyp mode r14 was 0 rather than the USR/SYS r14. | 5 | case where the machine hasn't wired the line up to anywhere. |
6 | 6 | ||
7 | We provide a new function r14_bank_number() which is like | 7 | Provide a function qemu_irq_is_connected() that devices can use for |
8 | the existing bank_number() but provides the index into | 8 | this purpose. (The test is trivial but encapsulating it in a |
9 | env->banked_r14[]; bank_number() provides the index to use | 9 | function makes it easier to see where we're doing it in case we need |
10 | for env->banked_r13[] and env->banked_cpsr[]. | 10 | to change the implementation later.) |
11 | |||
12 | All the points in the code that were using bank_number() | ||
13 | to index into env->banked_r14[] are updated for consintency: | ||
14 | * switch_mode() -- this is the only place where we fix | ||
15 | an actual bug | ||
16 | * aarch64_sync_32_to_64() and aarch64_sync_64_to_32(): | ||
17 | no behavioural change as we already special-cased Hyp R14 | ||
18 | * kvm32.c: no behavioural change since the guest can't ever | ||
19 | be in Hyp mode, but conceptually the right thing to do | ||
20 | * msr_banked()/mrs_banked(): we can never get to the case | ||
21 | that accesses banked_r14[] with tgtmode == ARM_CPU_MODE_HYP, | ||
22 | so no behavioural change | ||
23 | 11 | ||
24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
25 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 13 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
26 | Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 14 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
27 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 15 | Message-id: 20200728103744.6909-2-peter.maydell@linaro.org |
28 | Message-id: 20181109173553.22341-2-peter.maydell@linaro.org | ||
29 | --- | 16 | --- |
30 | target/arm/internals.h | 16 ++++++++++++++++ | 17 | include/hw/irq.h | 18 ++++++++++++++++++ |
31 | target/arm/helper.c | 29 +++++++++++++++-------------- | 18 | 1 file changed, 18 insertions(+) |
32 | target/arm/kvm32.c | 4 ++-- | ||
33 | target/arm/op_helper.c | 4 ++-- | ||
34 | 4 files changed, 35 insertions(+), 18 deletions(-) | ||
35 | 19 | ||
36 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 20 | diff --git a/include/hw/irq.h b/include/hw/irq.h |
37 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/target/arm/internals.h | 22 | --- a/include/hw/irq.h |
39 | +++ b/target/arm/internals.h | 23 | +++ b/include/hw/irq.h |
40 | @@ -XXX,XX +XXX,XX @@ static inline int bank_number(int mode) | 24 | @@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); |
41 | g_assert_not_reached(); | 25 | on an existing vector of qemu_irq. */ |
42 | } | 26 | void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n); |
43 | 27 | ||
44 | +/** | 28 | +/** |
45 | + * r14_bank_number: Map CPU mode onto register bank for r14 | 29 | + * qemu_irq_is_connected: Return true if IRQ line is wired up |
46 | + * | 30 | + * |
47 | + * Given an AArch32 CPU mode, return the index into the saved register | 31 | + * If a qemu_irq has a device on the other (receiving) end of it, |
48 | + * banks to use for the R14 (LR) in that mode. This is the same as | 32 | + * return true; otherwise return false. |
49 | + * bank_number(), except for the special case of Hyp mode, where | 33 | + * |
50 | + * R14 is shared with USR and SYS, unlike its R13 and SPSR. | 34 | + * Usually device models don't need to care whether the machine model |
51 | + * This should be used as the index into env->banked_r14[], and | 35 | + * has wired up their outbound qemu_irq lines, because functions like |
52 | + * bank_number() used for the index into env->banked_r13[] and | 36 | + * qemu_set_irq() silently do nothing if there is nothing on the other |
53 | + * env->banked_spsr[]. | 37 | + * end of the line. However occasionally a device model will want to |
38 | + * provide default behaviour if its output is left floating, and | ||
39 | + * it can use this function to identify when that is the case. | ||
54 | + */ | 40 | + */ |
55 | +static inline int r14_bank_number(int mode) | 41 | +static inline bool qemu_irq_is_connected(qemu_irq irq) |
56 | +{ | 42 | +{ |
57 | + return (mode == ARM_CPU_MODE_HYP) ? BANK_USRSYS : bank_number(mode); | 43 | + return irq != NULL; |
58 | +} | 44 | +} |
59 | + | 45 | + |
60 | void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu); | 46 | #endif |
61 | void arm_translate_init(void); | ||
62 | |||
63 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/helper.c | ||
66 | +++ b/target/arm/helper.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static void switch_mode(CPUARMState *env, int mode) | ||
68 | |||
69 | i = bank_number(old_mode); | ||
70 | env->banked_r13[i] = env->regs[13]; | ||
71 | - env->banked_r14[i] = env->regs[14]; | ||
72 | env->banked_spsr[i] = env->spsr; | ||
73 | |||
74 | i = bank_number(mode); | ||
75 | env->regs[13] = env->banked_r13[i]; | ||
76 | - env->regs[14] = env->banked_r14[i]; | ||
77 | env->spsr = env->banked_spsr[i]; | ||
78 | + | ||
79 | + env->banked_r14[r14_bank_number(old_mode)] = env->regs[14]; | ||
80 | + env->regs[14] = env->banked_r14[r14_bank_number(mode)]; | ||
81 | } | ||
82 | |||
83 | /* Physical Interrupt Target EL Lookup Table | ||
84 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
85 | if (mode == ARM_CPU_MODE_HYP) { | ||
86 | env->xregs[14] = env->regs[14]; | ||
87 | } else { | ||
88 | - env->xregs[14] = env->banked_r14[bank_number(ARM_CPU_MODE_USR)]; | ||
89 | + env->xregs[14] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_USR)]; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
94 | env->xregs[16] = env->regs[14]; | ||
95 | env->xregs[17] = env->regs[13]; | ||
96 | } else { | ||
97 | - env->xregs[16] = env->banked_r14[bank_number(ARM_CPU_MODE_IRQ)]; | ||
98 | + env->xregs[16] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_IRQ)]; | ||
99 | env->xregs[17] = env->banked_r13[bank_number(ARM_CPU_MODE_IRQ)]; | ||
100 | } | ||
101 | |||
102 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
103 | env->xregs[18] = env->regs[14]; | ||
104 | env->xregs[19] = env->regs[13]; | ||
105 | } else { | ||
106 | - env->xregs[18] = env->banked_r14[bank_number(ARM_CPU_MODE_SVC)]; | ||
107 | + env->xregs[18] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_SVC)]; | ||
108 | env->xregs[19] = env->banked_r13[bank_number(ARM_CPU_MODE_SVC)]; | ||
109 | } | ||
110 | |||
111 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
112 | env->xregs[20] = env->regs[14]; | ||
113 | env->xregs[21] = env->regs[13]; | ||
114 | } else { | ||
115 | - env->xregs[20] = env->banked_r14[bank_number(ARM_CPU_MODE_ABT)]; | ||
116 | + env->xregs[20] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_ABT)]; | ||
117 | env->xregs[21] = env->banked_r13[bank_number(ARM_CPU_MODE_ABT)]; | ||
118 | } | ||
119 | |||
120 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
121 | env->xregs[22] = env->regs[14]; | ||
122 | env->xregs[23] = env->regs[13]; | ||
123 | } else { | ||
124 | - env->xregs[22] = env->banked_r14[bank_number(ARM_CPU_MODE_UND)]; | ||
125 | + env->xregs[22] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_UND)]; | ||
126 | env->xregs[23] = env->banked_r13[bank_number(ARM_CPU_MODE_UND)]; | ||
127 | } | ||
128 | |||
129 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env) | ||
130 | env->xregs[i] = env->fiq_regs[i - 24]; | ||
131 | } | ||
132 | env->xregs[29] = env->banked_r13[bank_number(ARM_CPU_MODE_FIQ)]; | ||
133 | - env->xregs[30] = env->banked_r14[bank_number(ARM_CPU_MODE_FIQ)]; | ||
134 | + env->xregs[30] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_FIQ)]; | ||
135 | } | ||
136 | |||
137 | env->pc = env->regs[15]; | ||
138 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
139 | if (mode == ARM_CPU_MODE_HYP) { | ||
140 | env->regs[14] = env->xregs[14]; | ||
141 | } else { | ||
142 | - env->banked_r14[bank_number(ARM_CPU_MODE_USR)] = env->xregs[14]; | ||
143 | + env->banked_r14[r14_bank_number(ARM_CPU_MODE_USR)] = env->xregs[14]; | ||
144 | } | ||
145 | } | ||
146 | |||
147 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
148 | env->regs[14] = env->xregs[16]; | ||
149 | env->regs[13] = env->xregs[17]; | ||
150 | } else { | ||
151 | - env->banked_r14[bank_number(ARM_CPU_MODE_IRQ)] = env->xregs[16]; | ||
152 | + env->banked_r14[r14_bank_number(ARM_CPU_MODE_IRQ)] = env->xregs[16]; | ||
153 | env->banked_r13[bank_number(ARM_CPU_MODE_IRQ)] = env->xregs[17]; | ||
154 | } | ||
155 | |||
156 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
157 | env->regs[14] = env->xregs[18]; | ||
158 | env->regs[13] = env->xregs[19]; | ||
159 | } else { | ||
160 | - env->banked_r14[bank_number(ARM_CPU_MODE_SVC)] = env->xregs[18]; | ||
161 | + env->banked_r14[r14_bank_number(ARM_CPU_MODE_SVC)] = env->xregs[18]; | ||
162 | env->banked_r13[bank_number(ARM_CPU_MODE_SVC)] = env->xregs[19]; | ||
163 | } | ||
164 | |||
165 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
166 | env->regs[14] = env->xregs[20]; | ||
167 | env->regs[13] = env->xregs[21]; | ||
168 | } else { | ||
169 | - env->banked_r14[bank_number(ARM_CPU_MODE_ABT)] = env->xregs[20]; | ||
170 | + env->banked_r14[r14_bank_number(ARM_CPU_MODE_ABT)] = env->xregs[20]; | ||
171 | env->banked_r13[bank_number(ARM_CPU_MODE_ABT)] = env->xregs[21]; | ||
172 | } | ||
173 | |||
174 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
175 | env->regs[14] = env->xregs[22]; | ||
176 | env->regs[13] = env->xregs[23]; | ||
177 | } else { | ||
178 | - env->banked_r14[bank_number(ARM_CPU_MODE_UND)] = env->xregs[22]; | ||
179 | + env->banked_r14[r14_bank_number(ARM_CPU_MODE_UND)] = env->xregs[22]; | ||
180 | env->banked_r13[bank_number(ARM_CPU_MODE_UND)] = env->xregs[23]; | ||
181 | } | ||
182 | |||
183 | @@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env) | ||
184 | env->fiq_regs[i - 24] = env->xregs[i]; | ||
185 | } | ||
186 | env->banked_r13[bank_number(ARM_CPU_MODE_FIQ)] = env->xregs[29]; | ||
187 | - env->banked_r14[bank_number(ARM_CPU_MODE_FIQ)] = env->xregs[30]; | ||
188 | + env->banked_r14[r14_bank_number(ARM_CPU_MODE_FIQ)] = env->xregs[30]; | ||
189 | } | ||
190 | |||
191 | env->regs[15] = env->pc; | ||
192 | diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c | ||
193 | index XXXXXXX..XXXXXXX 100644 | ||
194 | --- a/target/arm/kvm32.c | ||
195 | +++ b/target/arm/kvm32.c | ||
196 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
197 | memcpy(env->usr_regs, env->regs + 8, 5 * sizeof(uint32_t)); | ||
198 | } | ||
199 | env->banked_r13[bn] = env->regs[13]; | ||
200 | - env->banked_r14[bn] = env->regs[14]; | ||
201 | env->banked_spsr[bn] = env->spsr; | ||
202 | + env->banked_r14[r14_bank_number(mode)] = env->regs[14]; | ||
203 | |||
204 | /* Now we can safely copy stuff down to the kernel */ | ||
205 | for (i = 0; i < ARRAY_SIZE(regs); i++) { | ||
206 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
207 | memcpy(env->regs + 8, env->usr_regs, 5 * sizeof(uint32_t)); | ||
208 | } | ||
209 | env->regs[13] = env->banked_r13[bn]; | ||
210 | - env->regs[14] = env->banked_r14[bn]; | ||
211 | env->spsr = env->banked_spsr[bn]; | ||
212 | + env->regs[14] = env->banked_r14[r14_bank_number(mode)]; | ||
213 | |||
214 | /* VFP registers */ | ||
215 | r.id = KVM_REG_ARM | KVM_REG_SIZE_U64 | KVM_REG_ARM_VFP; | ||
216 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | ||
217 | index XXXXXXX..XXXXXXX 100644 | ||
218 | --- a/target/arm/op_helper.c | ||
219 | +++ b/target/arm/op_helper.c | ||
220 | @@ -XXX,XX +XXX,XX @@ void HELPER(msr_banked)(CPUARMState *env, uint32_t value, uint32_t tgtmode, | ||
221 | env->banked_r13[bank_number(tgtmode)] = value; | ||
222 | break; | ||
223 | case 14: | ||
224 | - env->banked_r14[bank_number(tgtmode)] = value; | ||
225 | + env->banked_r14[r14_bank_number(tgtmode)] = value; | ||
226 | break; | ||
227 | case 8 ... 12: | ||
228 | switch (tgtmode) { | ||
229 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mrs_banked)(CPUARMState *env, uint32_t tgtmode, uint32_t regno) | ||
230 | case 13: | ||
231 | return env->banked_r13[bank_number(tgtmode)]; | ||
232 | case 14: | ||
233 | - return env->banked_r14[bank_number(tgtmode)]; | ||
234 | + return env->banked_r14[r14_bank_number(tgtmode)]; | ||
235 | case 8 ... 12: | ||
236 | switch (tgtmode) { | ||
237 | case ARM_CPU_MODE_USR: | ||
238 | -- | 47 | -- |
239 | 2.19.1 | 48 | 2.20.1 |
240 | 49 | ||
241 | 50 | diff view generated by jsdifflib |
1 | In commit 8a0fc3a29fc2315325400 we tried to implement HCR_EL2.{VI,VF}, | 1 | The NVIC provides an outbound qemu_irq "SYSRESETREQ" which it signals |
---|---|---|---|
2 | but we got it wrong and had to revert it. | 2 | when the guest sets the SYSRESETREQ bit in the AIRCR register. This |
3 | matches the hardware design (where the CPU has a signal of this name | ||
4 | and it is up to the SoC to connect that up to an actual reset | ||
5 | mechanism), but in QEMU it mostly results in duplicated code in SoC | ||
6 | objects and bugs where SoC model implementors forget to wire up the | ||
7 | SYSRESETREQ line. | ||
3 | 8 | ||
4 | In that commit we implemented them as simply tracking whether there | 9 | Provide a default behaviour for the case where SYSRESETREQ is not |
5 | is a pending virtual IRQ or virtual FIQ. This is not correct -- these | 10 | actually connected to anything: use qemu_system_reset_request() to |
6 | bits cause a software-generated VIRQ/VFIQ, which is distinct from | 11 | perform a system reset. This will allow us to remove the |
7 | whether there is a hardware-generated VIRQ/VFIQ caused by the | 12 | implementations of SYSRESETREQ handling from the boards where that's |
8 | external interrupt controller. So we need to track separately | 13 | exactly what it does, and also fixes the bugs in the board models |
9 | the HCR_EL2 bit state and the external virq/vfiq line state, and | 14 | which forgot to wire up the signal: |
10 | OR the two together to get the actual pending VIRQ/VFIQ state. | ||
11 | 15 | ||
12 | Fixes: 8a0fc3a29fc2315325400c738f807d0d4ae0ab7f | 16 | * microbit |
17 | * mps2-an385 | ||
18 | * mps2-an505 | ||
19 | * mps2-an511 | ||
20 | * mps2-an521 | ||
21 | * musca-a | ||
22 | * musca-b1 | ||
23 | * netduino | ||
24 | * netduinoplus2 | ||
25 | |||
26 | We still allow the board to wire up the signal if it needs to, in case | ||
27 | we need to model more complicated reset controller logic or to model | ||
28 | buggy SoC hardware which forgot to wire up the line itself. But | ||
29 | defaulting to "reset the system" is more often going to be correct | ||
30 | than defaulting to "do nothing". | ||
31 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 33 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
15 | Message-id: 20181109134731.11605-4-peter.maydell@linaro.org | 34 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
35 | Message-id: 20200728103744.6909-3-peter.maydell@linaro.org | ||
16 | --- | 36 | --- |
17 | target/arm/internals.h | 18 ++++++++++++++++ | 37 | include/hw/arm/armv7m.h | 4 +++- |
18 | target/arm/cpu.c | 48 +++++++++++++++++++++++++++++++++++++++++- | 38 | hw/intc/armv7m_nvic.c | 17 ++++++++++++++++- |
19 | target/arm/helper.c | 20 ++++++++++++++++-- | 39 | 2 files changed, 19 insertions(+), 2 deletions(-) |
20 | 3 files changed, 83 insertions(+), 3 deletions(-) | ||
21 | 40 | ||
22 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 41 | diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h |
23 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/target/arm/internals.h | 43 | --- a/include/hw/arm/armv7m.h |
25 | +++ b/target/arm/internals.h | 44 | +++ b/include/hw/arm/armv7m.h |
26 | @@ -XXX,XX +XXX,XX @@ static inline const char *aarch32_mode_name(uint32_t psr) | 45 | @@ -XXX,XX +XXX,XX @@ typedef struct { |
27 | return cpu_mode_names[psr & 0xf]; | 46 | |
28 | } | 47 | /* ARMv7M container object. |
29 | 48 | * + Unnamed GPIO input lines: external IRQ lines for the NVIC | |
30 | +/** | 49 | - * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ |
31 | + * arm_cpu_update_virq: Update CPU_INTERRUPT_VIRQ bit in cs->interrupt_request | 50 | + * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ. |
32 | + * | 51 | + * If this GPIO is not wired up then the NVIC will default to performing |
33 | + * Update the CPU_INTERRUPT_VIRQ bit in cs->interrupt_request, following | 52 | + * a qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET). |
34 | + * a change to either the input VIRQ line from the GIC or the HCR_EL2.VI bit. | 53 | * + Property "cpu-type": CPU type to instantiate |
35 | + * Must be called with the iothread lock held. | 54 | * + Property "num-irq": number of external IRQ lines |
36 | + */ | 55 | * + Property "memory": MemoryRegion defining the physical address space |
37 | +void arm_cpu_update_virq(ARMCPU *cpu); | 56 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c |
38 | + | ||
39 | +/** | ||
40 | + * arm_cpu_update_vfiq: Update CPU_INTERRUPT_VFIQ bit in cs->interrupt_request | ||
41 | + * | ||
42 | + * Update the CPU_INTERRUPT_VFIQ bit in cs->interrupt_request, following | ||
43 | + * a change to either the input VFIQ line from the GIC or the HCR_EL2.VF bit. | ||
44 | + * Must be called with the iothread lock held. | ||
45 | + */ | ||
46 | +void arm_cpu_update_vfiq(ARMCPU *cpu); | ||
47 | + | ||
48 | #endif | ||
49 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | 57 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/target/arm/cpu.c | 58 | --- a/hw/intc/armv7m_nvic.c |
52 | +++ b/target/arm/cpu.c | 59 | +++ b/hw/intc/armv7m_nvic.c |
53 | @@ -XXX,XX +XXX,XX @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) | 60 | @@ -XXX,XX +XXX,XX @@ |
54 | } | 61 | #include "hw/intc/armv7m_nvic.h" |
55 | #endif | 62 | #include "hw/irq.h" |
56 | 63 | #include "hw/qdev-properties.h" | |
57 | +void arm_cpu_update_virq(ARMCPU *cpu) | 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) | ||
58 | +{ | 73 | +{ |
59 | + /* | 74 | + if (qemu_irq_is_connected(s->sysresetreq)) { |
60 | + * Update the interrupt level for VIRQ, which is the logical OR of | 75 | + qemu_irq_pulse(s->sysresetreq); |
61 | + * the HCR_EL2.VI bit and the input line level from the GIC. | 76 | + } else { |
62 | + */ | 77 | + /* |
63 | + CPUARMState *env = &cpu->env; | 78 | + * Default behaviour if the SoC doesn't need to wire up |
64 | + CPUState *cs = CPU(cpu); | 79 | + * SYSRESETREQ (eg to a system reset controller of some kind): |
65 | + | 80 | + * perform a system reset via the usual QEMU API. |
66 | + bool new_state = (env->cp15.hcr_el2 & HCR_VI) || | 81 | + */ |
67 | + (env->irq_line_state & CPU_INTERRUPT_VIRQ); | 82 | + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); |
68 | + | ||
69 | + if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VIRQ) != 0)) { | ||
70 | + if (new_state) { | ||
71 | + cpu_interrupt(cs, CPU_INTERRUPT_VIRQ); | ||
72 | + } else { | ||
73 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_VIRQ); | ||
74 | + } | ||
75 | + } | 83 | + } |
76 | +} | 84 | +} |
77 | + | 85 | + |
78 | +void arm_cpu_update_vfiq(ARMCPU *cpu) | 86 | static int nvic_pending_prio(NVICState *s) |
79 | +{ | ||
80 | + /* | ||
81 | + * Update the interrupt level for VFIQ, which is the logical OR of | ||
82 | + * the HCR_EL2.VF bit and the input line level from the GIC. | ||
83 | + */ | ||
84 | + CPUARMState *env = &cpu->env; | ||
85 | + CPUState *cs = CPU(cpu); | ||
86 | + | ||
87 | + bool new_state = (env->cp15.hcr_el2 & HCR_VF) || | ||
88 | + (env->irq_line_state & CPU_INTERRUPT_VFIQ); | ||
89 | + | ||
90 | + if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VFIQ) != 0)) { | ||
91 | + if (new_state) { | ||
92 | + cpu_interrupt(cs, CPU_INTERRUPT_VFIQ); | ||
93 | + } else { | ||
94 | + cpu_reset_interrupt(cs, CPU_INTERRUPT_VFIQ); | ||
95 | + } | ||
96 | + } | ||
97 | +} | ||
98 | + | ||
99 | #ifndef CONFIG_USER_ONLY | ||
100 | static void arm_cpu_set_irq(void *opaque, int irq, int level) | ||
101 | { | 87 | { |
102 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level) | 88 | /* return the group priority of the current pending interrupt, |
103 | 89 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | |
104 | switch (irq) { | 90 | if (value & R_V7M_AIRCR_SYSRESETREQ_MASK) { |
105 | case ARM_CPU_VIRQ: | 91 | if (attrs.secure || |
106 | + assert(arm_feature(env, ARM_FEATURE_EL2)); | 92 | !(cpu->env.v7m.aircr & R_V7M_AIRCR_SYSRESETREQS_MASK)) { |
107 | + arm_cpu_update_virq(cpu); | 93 | - qemu_irq_pulse(s->sysresetreq); |
108 | + break; | 94 | + signal_sysresetreq(s); |
109 | case ARM_CPU_VFIQ: | 95 | } |
110 | assert(arm_feature(env, ARM_FEATURE_EL2)); | 96 | } |
111 | - /* fall through */ | 97 | if (value & R_V7M_AIRCR_VECTCLRACTIVE_MASK) { |
112 | + arm_cpu_update_vfiq(cpu); | ||
113 | + break; | ||
114 | case ARM_CPU_IRQ: | ||
115 | case ARM_CPU_FIQ: | ||
116 | if (level) { | ||
117 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
118 | index XXXXXXX..XXXXXXX 100644 | ||
119 | --- a/target/arm/helper.c | ||
120 | +++ b/target/arm/helper.c | ||
121 | @@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
122 | tlb_flush(CPU(cpu)); | ||
123 | } | ||
124 | env->cp15.hcr_el2 = value; | ||
125 | + | ||
126 | + /* | ||
127 | + * Updates to VI and VF require us to update the status of | ||
128 | + * virtual interrupts, which are the logical OR of these bits | ||
129 | + * and the state of the input lines from the GIC. (This requires | ||
130 | + * that we have the iothread lock, which is done by marking the | ||
131 | + * reginfo structs as ARM_CP_IO.) | ||
132 | + * Note that if a write to HCR pends a VIRQ or VFIQ it is never | ||
133 | + * possible for it to be taken immediately, because VIRQ and | ||
134 | + * VFIQ are masked unless running at EL0 or EL1, and HCR | ||
135 | + * can only be written at EL2. | ||
136 | + */ | ||
137 | + g_assert(qemu_mutex_iothread_locked()); | ||
138 | + arm_cpu_update_virq(cpu); | ||
139 | + arm_cpu_update_vfiq(cpu); | ||
140 | } | ||
141 | |||
142 | static void hcr_writehigh(CPUARMState *env, const ARMCPRegInfo *ri, | ||
143 | @@ -XXX,XX +XXX,XX @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri, | ||
144 | |||
145 | static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
146 | { .name = "HCR_EL2", .state = ARM_CP_STATE_AA64, | ||
147 | + .type = ARM_CP_IO, | ||
148 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, | ||
149 | .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2), | ||
150 | .writefn = hcr_write }, | ||
151 | { .name = "HCR", .state = ARM_CP_STATE_AA32, | ||
152 | - .type = ARM_CP_ALIAS, | ||
153 | + .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
154 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, | ||
155 | .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2), | ||
156 | .writefn = hcr_writelow }, | ||
157 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
158 | |||
159 | static const ARMCPRegInfo el2_v8_cp_reginfo[] = { | ||
160 | { .name = "HCR2", .state = ARM_CP_STATE_AA32, | ||
161 | - .type = ARM_CP_ALIAS, | ||
162 | + .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
163 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, | ||
164 | .access = PL2_RW, | ||
165 | .fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2), | ||
166 | -- | 98 | -- |
167 | 2.19.1 | 99 | 2.20.1 |
168 | 100 | ||
169 | 101 | diff view generated by jsdifflib |
1 | Currently we track the state of the four irq lines from the GIC | 1 | The MSF2 SoC model and the Stellaris board code both wire |
---|---|---|---|
2 | only via the cs->interrupt_request or KVM irq state. That means | 2 | SYSRESETREQ up to a function that just invokes |
3 | that we assume that an interrupt is asserted if and only if the | 3 | qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); |
4 | external line is set. This assumption is incorrect for VIRQ | 4 | This is now the default action that the NVIC does if the line is |
5 | and VFIQ, because the HCR_EL2.{VI,VF} bits allow assertion | 5 | not connected, so we can delete the handling code. |
6 | of VIRQ and VFIQ separately from the state of the external line. | ||
7 | |||
8 | To handle this, start tracking the state of the external lines | ||
9 | explicitly in a CPU state struct field, as is common practice | ||
10 | for devices. | ||
11 | |||
12 | The complicated part of this is dealing with inbound migration | ||
13 | from an older QEMU which didn't have this state. We assume in | ||
14 | that case that the older QEMU did not implement the HCR_EL2.{VI,VF} | ||
15 | bits as generating interrupts, and so the line state matches | ||
16 | the current state in cs->interrupt_request. (This is not quite | ||
17 | true between commit 8a0fc3a29fc2315325400c7 and its revert, but | ||
18 | that commit is broken and never made it into any released QEMU | ||
19 | version.) | ||
20 | 6 | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
23 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
24 | Message-id: 20181109134731.11605-3-peter.maydell@linaro.org | 10 | Message-id: 20200728103744.6909-4-peter.maydell@linaro.org |
25 | --- | 11 | --- |
26 | target/arm/cpu.h | 3 +++ | 12 | hw/arm/msf2-soc.c | 11 ----------- |
27 | target/arm/cpu.c | 16 ++++++++++++++ | 13 | hw/arm/stellaris.c | 12 ------------ |
28 | target/arm/machine.c | 51 ++++++++++++++++++++++++++++++++++++++++++++ | 14 | 2 files changed, 23 deletions(-) |
29 | 3 files changed, 70 insertions(+) | ||
30 | 15 | ||
31 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 16 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c |
32 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/target/arm/cpu.h | 18 | --- a/hw/arm/msf2-soc.c |
34 | +++ b/target/arm/cpu.h | 19 | +++ b/hw/arm/msf2-soc.c |
35 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState { | 20 | @@ -XXX,XX +XXX,XX @@ |
36 | uint64_t esr; | 21 | #include "hw/irq.h" |
37 | } serror; | 22 | #include "hw/arm/msf2-soc.h" |
38 | 23 | #include "hw/misc/unimp.h" | |
39 | + /* State of our input IRQ/FIQ/VIRQ/VFIQ lines */ | 24 | -#include "sysemu/runstate.h" |
40 | + uint32_t irq_line_state; | 25 | #include "sysemu/sysemu.h" |
41 | + | 26 | |
42 | /* Thumb-2 EE state. */ | 27 | #define MSF2_TIMER_BASE 0x40004000 |
43 | uint32_t teecr; | 28 | @@ -XXX,XX +XXX,XX @@ static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 }; |
44 | uint32_t teehbr; | 29 | static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 }; |
45 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 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 | ||
46 | index XXXXXXX..XXXXXXX 100644 | 53 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/target/arm/cpu.c | 54 | --- a/hw/arm/stellaris.c |
48 | +++ b/target/arm/cpu.c | 55 | +++ b/hw/arm/stellaris.c |
49 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level) | 56 | @@ -XXX,XX +XXX,XX @@ |
50 | [ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ | 57 | #include "hw/boards.h" |
51 | }; | 58 | #include "qemu/log.h" |
52 | 59 | #include "exec/address-spaces.h" | |
53 | + if (level) { | 60 | -#include "sysemu/runstate.h" |
54 | + env->irq_line_state |= mask[irq]; | 61 | #include "sysemu/sysemu.h" |
55 | + } else { | 62 | #include "hw/arm/armv7m.h" |
56 | + env->irq_line_state &= ~mask[irq]; | 63 | #include "hw/char/pl011.h" |
57 | + } | 64 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_init(Object *obj) |
58 | + | 65 | qdev_init_gpio_in(dev, stellaris_adc_trigger, 1); |
59 | switch (irq) { | ||
60 | case ARM_CPU_VIRQ: | ||
61 | case ARM_CPU_VFIQ: | ||
62 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_kvm_set_irq(void *opaque, int irq, int level) | ||
63 | ARMCPU *cpu = opaque; | ||
64 | CPUState *cs = CPU(cpu); | ||
65 | int kvm_irq = KVM_ARM_IRQ_TYPE_CPU << KVM_ARM_IRQ_TYPE_SHIFT; | ||
66 | + uint32_t linestate_bit; | ||
67 | |||
68 | switch (irq) { | ||
69 | case ARM_CPU_IRQ: | ||
70 | kvm_irq |= KVM_ARM_IRQ_CPU_IRQ; | ||
71 | + linestate_bit = CPU_INTERRUPT_HARD; | ||
72 | break; | ||
73 | case ARM_CPU_FIQ: | ||
74 | kvm_irq |= KVM_ARM_IRQ_CPU_FIQ; | ||
75 | + linestate_bit = CPU_INTERRUPT_FIQ; | ||
76 | break; | ||
77 | default: | ||
78 | g_assert_not_reached(); | ||
79 | } | ||
80 | + | ||
81 | + if (level) { | ||
82 | + env->irq_line_state |= linestate_bit; | ||
83 | + } else { | ||
84 | + env->irq_line_state &= ~linestate_bit; | ||
85 | + } | ||
86 | + | ||
87 | kvm_irq |= cs->cpu_index << KVM_ARM_IRQ_VCPU_SHIFT; | ||
88 | kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0); | ||
89 | #endif | ||
90 | diff --git a/target/arm/machine.c b/target/arm/machine.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/target/arm/machine.c | ||
93 | +++ b/target/arm/machine.c | ||
94 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_serror = { | ||
95 | } | ||
96 | }; | ||
97 | |||
98 | +static bool irq_line_state_needed(void *opaque) | ||
99 | +{ | ||
100 | + return true; | ||
101 | +} | ||
102 | + | ||
103 | +static const VMStateDescription vmstate_irq_line_state = { | ||
104 | + .name = "cpu/irq-line-state", | ||
105 | + .version_id = 1, | ||
106 | + .minimum_version_id = 1, | ||
107 | + .needed = irq_line_state_needed, | ||
108 | + .fields = (VMStateField[]) { | ||
109 | + VMSTATE_UINT32(env.irq_line_state, ARMCPU), | ||
110 | + VMSTATE_END_OF_LIST() | ||
111 | + } | ||
112 | +}; | ||
113 | + | ||
114 | static bool m_needed(void *opaque) | ||
115 | { | ||
116 | ARMCPU *cpu = opaque; | ||
117 | @@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque) | ||
118 | return 0; | ||
119 | } | 66 | } |
120 | 67 | ||
121 | +static int cpu_pre_load(void *opaque) | 68 | -static |
122 | +{ | 69 | -void do_sys_reset(void *opaque, int n, int level) |
123 | + ARMCPU *cpu = opaque; | 70 | -{ |
124 | + CPUARMState *env = &cpu->env; | 71 | - if (level) { |
125 | + | 72 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); |
126 | + /* | 73 | - } |
127 | + * Pre-initialize irq_line_state to a value that's never valid as | 74 | -} |
128 | + * real data, so cpu_post_load() can tell whether we've seen the | 75 | - |
129 | + * irq-line-state subsection in the incoming migration state. | 76 | /* Board init. */ |
130 | + */ | 77 | static stellaris_board_info stellaris_boards[] = { |
131 | + env->irq_line_state = UINT32_MAX; | 78 | { "LM3S811EVB", |
132 | + | 79 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
133 | + return 0; | 80 | /* This will exit with an error if the user passed us a bad cpu_type */ |
134 | +} | 81 | sysbus_realize_and_unref(SYS_BUS_DEVICE(nvic), &error_fatal); |
135 | + | 82 | |
136 | static int cpu_post_load(void *opaque, int version_id) | 83 | - qdev_connect_gpio_out_named(nvic, "SYSRESETREQ", 0, |
137 | { | 84 | - qemu_allocate_irq(&do_sys_reset, NULL, 0)); |
138 | ARMCPU *cpu = opaque; | 85 | - |
139 | + CPUARMState *env = &cpu->env; | 86 | if (board->dc1 & (1 << 16)) { |
140 | int i, v; | 87 | dev = sysbus_create_varargs(TYPE_STELLARIS_ADC, 0x40038000, |
141 | 88 | qdev_get_gpio_in(nvic, 14), | |
142 | + /* | ||
143 | + * Handle migration compatibility from old QEMU which didn't | ||
144 | + * send the irq-line-state subsection. A QEMU without it did not | ||
145 | + * implement the HCR_EL2.{VI,VF} bits as generating interrupts, | ||
146 | + * so for TCG the line state matches the bits set in cs->interrupt_request. | ||
147 | + * For KVM the line state is not stored in cs->interrupt_request | ||
148 | + * and so this will leave irq_line_state as 0, but this is OK because | ||
149 | + * we only need to care about it for TCG. | ||
150 | + */ | ||
151 | + if (env->irq_line_state == UINT32_MAX) { | ||
152 | + CPUState *cs = CPU(cpu); | ||
153 | + | ||
154 | + env->irq_line_state = cs->interrupt_request & | ||
155 | + (CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIQ | | ||
156 | + CPU_INTERRUPT_VIRQ | CPU_INTERRUPT_VFIQ); | ||
157 | + } | ||
158 | + | ||
159 | /* Update the values list from the incoming migration data. | ||
160 | * Anything in the incoming data which we don't know about is | ||
161 | * a migration failure; anything we know about but the incoming | ||
162 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_arm_cpu = { | ||
163 | .version_id = 22, | ||
164 | .minimum_version_id = 22, | ||
165 | .pre_save = cpu_pre_save, | ||
166 | + .pre_load = cpu_pre_load, | ||
167 | .post_load = cpu_post_load, | ||
168 | .fields = (VMStateField[]) { | ||
169 | VMSTATE_UINT32_ARRAY(env.regs, ARMCPU, 16), | ||
170 | @@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_arm_cpu = { | ||
171 | &vmstate_sve, | ||
172 | #endif | ||
173 | &vmstate_serror, | ||
174 | + &vmstate_irq_line_state, | ||
175 | NULL | ||
176 | } | ||
177 | }; | ||
178 | -- | 89 | -- |
179 | 2.19.1 | 90 | 2.20.1 |
180 | 91 | ||
181 | 92 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This would cause an infinite recursion or loop. | 3 | The definition of top_bit used in this function is one higher |
4 | than that used in the Arm ARM psuedo-code, which put the error | ||
5 | indication at top_bit - 1 at the wrong place, which meant that | ||
6 | it wasn't visible to Auth. | ||
4 | 7 | ||
8 | Fixing the definition of top_bit requires more changes, because | ||
9 | its most common use is for the count of bits in top_bit:bot_bit, | ||
10 | which would then need to be computed as top_bit - bot_bit + 1. | ||
11 | |||
12 | For now, prefer the minimal fix to the error indication alone. | ||
13 | |||
14 | Fixes: 63ff0ca94cb | ||
15 | Reported-by: Derrick McKee <derrick.mckee@gmail.com> | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 17 | Message-id: 20200728195706.11087-1-richard.henderson@linaro.org |
7 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Message-id: 20181110121711.15257-1-richard.henderson@linaro.org | ||
9 | 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] | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 21 | --- |
12 | target/arm/helper.c | 2 +- | 22 | target/arm/pauth_helper.c | 6 +++++- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 23 | tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++ |
24 | tests/tcg/aarch64/Makefile.target | 2 +- | ||
25 | 3 files changed, 39 insertions(+), 2 deletions(-) | ||
26 | create mode 100644 tests/tcg/aarch64/pauth-5.c | ||
14 | 27 | ||
15 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 28 | diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c |
16 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper.c | 30 | --- a/target/arm/pauth_helper.c |
18 | +++ b/target/arm/helper.c | 31 | +++ b/target/arm/pauth_helper.c |
19 | @@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vmalle1_write(CPUARMState *env, const ARMCPRegInfo *ri, | 32 | @@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, |
20 | CPUState *cs = ENV_GET_CPU(env); | 33 | */ |
21 | 34 | test = sextract64(ptr, bot_bit, top_bit - bot_bit); | |
22 | if (tlb_force_broadcast(env)) { | 35 | if (test != 0 && test != -1) { |
23 | - tlbi_aa64_vmalle1_write(env, NULL, value); | 36 | - pac ^= MAKE_64BIT_MASK(top_bit - 1, 1); |
24 | + tlbi_aa64_vmalle1is_write(env, NULL, value); | 37 | + /* |
25 | return; | 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); | ||
26 | } | 42 | } |
27 | 43 | ||
44 | /* | ||
45 | diff --git a/tests/tcg/aarch64/pauth-5.c b/tests/tcg/aarch64/pauth-5.c | ||
46 | new file mode 100644 | ||
47 | index XXXXXXX..XXXXXXX | ||
48 | --- /dev/null | ||
49 | +++ b/tests/tcg/aarch64/pauth-5.c | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | +#include <assert.h> | ||
52 | + | ||
53 | +static int x; | ||
54 | + | ||
55 | +int main() | ||
56 | +{ | ||
57 | + int *p0 = &x, *p1, *p2, *p3; | ||
58 | + unsigned long salt = 0; | ||
59 | + | ||
60 | + /* | ||
61 | + * With TBI enabled and a 48-bit VA, there are 7 bits of auth, and so | ||
62 | + * a 1/128 chance of auth = pac(ptr,key,salt) producing zero. | ||
63 | + * Find a salt that creates auth != 0. | ||
64 | + */ | ||
65 | + do { | ||
66 | + salt++; | ||
67 | + asm("pacda %0, %1" : "=r"(p1) : "r"(salt), "0"(p0)); | ||
68 | + } while (p0 == p1); | ||
69 | + | ||
70 | + /* | ||
71 | + * This pac must fail, because the input pointer bears an encryption, | ||
72 | + * and so is not properly extended within bits [55:47]. This will | ||
73 | + * toggle bit 54 in the output... | ||
74 | + */ | ||
75 | + asm("pacda %0, %1" : "=r"(p2) : "r"(salt), "0"(p1)); | ||
76 | + | ||
77 | + /* ... so that the aut must fail, setting bit 53 in the output ... */ | ||
78 | + asm("autda %0, %1" : "=r"(p3) : "r"(salt), "0"(p2)); | ||
79 | + | ||
80 | + /* ... which means this equality must not hold. */ | ||
81 | + assert(p3 != p0); | ||
82 | + return 0; | ||
83 | +} | ||
84 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
85 | index XXXXXXX..XXXXXXX 100644 | ||
86 | --- a/tests/tcg/aarch64/Makefile.target | ||
87 | +++ b/tests/tcg/aarch64/Makefile.target | ||
88 | @@ -XXX,XX +XXX,XX @@ run-fcvt: fcvt | ||
89 | |||
90 | # Pauth Tests | ||
91 | ifneq ($(DOCKER_IMAGE)$(CROSS_CC_HAS_ARMV8_3),) | ||
92 | -AARCH64_TESTS += pauth-1 pauth-2 pauth-4 | ||
93 | +AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5 | ||
94 | pauth-%: CFLAGS += -march=armv8.3-a | ||
95 | run-pauth-%: QEMU_OPTS += -cpu max | ||
96 | run-plugin-pauth-%: QEMU_OPTS += -cpu max | ||
28 | -- | 97 | -- |
29 | 2.19.1 | 98 | 2.20.1 |
30 | 99 | ||
31 | 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 | We already have this symbol defined so lets use it. | 3 | GCC version 4.9.4 isn't clever enough to figure out that all |
4 | execution paths in disas_ldst() that use 'fn' will have initialized | ||
5 | it first, and so it warns: | ||
4 | 6 | ||
5 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 7 | /home/LiKaige/qemu/target/arm/translate-a64.c: In function ‘disas_ldst’: |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | /home/LiKaige/qemu/target/arm/translate-a64.c:3392:5: error: ‘fn’ may be used uninitialized in this function [-Werror=maybe-uninitialized] |
7 | Message-id: 20181109152119.9242-7-alex.bennee@linaro.org | 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 | ||
19 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | [PMM: Clean up commit message and note which gcc version this was] | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 22 | --- |
10 | target/arm/cpu.h | 2 +- | 23 | target/arm/translate-a64.c | 2 +- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 24 | 1 file changed, 1 insertion(+), 1 deletion(-) |
12 | 25 | ||
13 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 26 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c |
14 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/cpu.h | 28 | --- a/target/arm/translate-a64.c |
16 | +++ b/target/arm/cpu.h | 29 | +++ b/target/arm/translate-a64.c |
17 | @@ -XXX,XX +XXX,XX @@ static inline int arm_debug_target_el(CPUARMState *env) | 30 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, |
18 | 31 | bool r = extract32(insn, 22, 1); | |
19 | if (arm_feature(env, ARM_FEATURE_EL2) && !secure) { | 32 | bool a = extract32(insn, 23, 1); |
20 | route_to_el2 = env->cp15.hcr_el2 & HCR_TGE || | 33 | TCGv_i64 tcg_rs, clean_addr; |
21 | - env->cp15.mdcr_el2 & (1 << 8); | 34 | - AtomicThreeOpFn *fn; |
22 | + env->cp15.mdcr_el2 & MDCR_TDE; | 35 | + AtomicThreeOpFn *fn = NULL; |
23 | } | 36 | |
24 | 37 | if (is_vector || !dc_isar_feature(aa64_atomics, s)) { | |
25 | if (route_to_el2) { | 38 | unallocated_encoding(s); |
26 | -- | 39 | -- |
27 | 2.19.1 | 40 | 2.20.1 |
28 | 41 | ||
29 | 42 | diff view generated by jsdifflib |
1 | Remove a TODO comment about implementing the vectored interrupt | 1 | The nrf51 SoC model wasn't setting the system_clock_scale |
---|---|---|---|
2 | controller. We have had an implementation of that for a decade; | 2 | global.which meant that if guest code used the systick timer in "use |
3 | it's in hw/intc/pl190.c. | 3 | the processor clock" mode it would hang because time never advances. |
4 | |||
5 | Set the global to match the documented CPU clock speed for this SoC. | ||
6 | |||
7 | This SoC in fact doesn't have a SysTick timer (which is the only thing | ||
8 | currently that cares about the system_clock_scale), because it's | ||
9 | a configurable option in the Cortex-M0. However our Cortex-M0 and | ||
10 | thus our nrf51 and our micro:bit board do provide a SysTick, so | ||
11 | we ought to provide a functional one rather than a broken one. | ||
4 | 12 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20181106164118.16184-1-peter.maydell@linaro.org | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 15 | Message-id: 20200727193458.31250-1-peter.maydell@linaro.org |
10 | --- | 16 | --- |
11 | target/arm/helper.c | 1 - | 17 | hw/arm/nrf51_soc.c | 5 +++++ |
12 | 1 file changed, 1 deletion(-) | 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_aarch32(CPUState *cs) | 24 | @@ -XXX,XX +XXX,XX @@ |
25 | |||
26 | #define BASE_TO_IRQ(base) ((base >> 12) & 0x1F) | ||
27 | |||
28 | +/* HCLK (the main CPU clock) on this SoC is always 16MHz */ | ||
29 | +#define HCLK_FRQ 16000000 | ||
30 | + | ||
31 | static uint64_t clock_read(void *opaque, hwaddr addr, unsigned int size) | ||
32 | { | ||
33 | qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n", | ||
34 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | ||
19 | return; | 35 | return; |
20 | } | 36 | } |
21 | 37 | ||
22 | - /* TODO: Vectored interrupt controller. */ | 38 | + system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ; |
23 | switch (cs->exception_index) { | 39 | + |
24 | case EXCP_UDEF: | 40 | object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container), |
25 | new_mode = ARM_CPU_MODE_UND; | 41 | &error_abort); |
42 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) { | ||
26 | -- | 43 | -- |
27 | 2.19.1 | 44 | 2.20.1 |
28 | 45 | ||
29 | 46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Thomas Huth <thuth@redhat.com> | ||
2 | 1 | ||
3 | There is no active maintainer, but since Peter is picking up | ||
4 | patches via qemu-arm@nongnu.org, I think we could at least use | ||
5 | "Odd Fixes" as status here. | ||
6 | |||
7 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
9 | Message-id: 1541528230-31817-1-git-send-email-thuth@redhat.com | ||
10 | [PMM: Also add myself as an M: contact] | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | MAINTAINERS | 7 +++++++ | ||
14 | 1 file changed, 7 insertions(+) | ||
15 | |||
16 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/MAINTAINERS | ||
19 | +++ b/MAINTAINERS | ||
20 | @@ -XXX,XX +XXX,XX @@ F: hw/*/pxa2xx* | ||
21 | F: hw/misc/mst_fpga.c | ||
22 | F: include/hw/arm/pxa.h | ||
23 | |||
24 | +Sharp SL-5500 (Collie) PDA | ||
25 | +M: Peter Maydell <peter.maydell@linaro.org> | ||
26 | +L: qemu-arm@nongnu.org | ||
27 | +S: Odd Fixes | ||
28 | +F: hw/arm/collie.c | ||
29 | +F: hw/arm/strongarm* | ||
30 | + | ||
31 | Stellaris | ||
32 | M: Peter Maydell <peter.maydell@linaro.org> | ||
33 | L: qemu-arm@nongnu.org | ||
34 | -- | ||
35 | 2.19.1 | ||
36 | |||
37 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Eric Auger <eric.auger@redhat.com> | ||
2 | 1 | ||
3 | Commit af7d64ede0b9 (hw/arm/sysbus-fdt: Allow device matching with DT | ||
4 | compatible value) introduced a match_fn callback which gets called | ||
5 | for each registered combo to check whether a sysbus device can be | ||
6 | dynamically instantiated. However the callback gets called even if | ||
7 | the device type does not match the binding combo typename field. | ||
8 | This causes an assert when passing "-device ramfb" to the qemu | ||
9 | command line as vfio_platform_match() gets called on a non | ||
10 | vfio-platform device. | ||
11 | |||
12 | To fix this regression, let's change the add_fdt_node() logic so | ||
13 | that we first check the type and if the match_fn callback is defined, | ||
14 | then we also call it. | ||
15 | |||
16 | Binding combos only requesting a type check do not define the | ||
17 | match_fn callback. | ||
18 | |||
19 | Fixes: af7d64ede0b9 (hw/arm/sysbus-fdt: Allow device matching with | ||
20 | DT compatible value) | ||
21 | |||
22 | Signed-off-by: Eric Auger <eric.auger@redhat.com> | ||
23 | Reported-by: Thomas Huth <thuth@redhat.com> | ||
24 | Reviewed-by: Alex Williamson <alex.williamson@redhat.com> | ||
25 | Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> | ||
26 | Message-id: 20181106184212.29377-1-eric.auger@redhat.com | ||
27 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
28 | --- | ||
29 | hw/arm/sysbus-fdt.c | 12 +++++++----- | ||
30 | 1 file changed, 7 insertions(+), 5 deletions(-) | ||
31 | |||
32 | diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c | ||
33 | index XXXXXXX..XXXXXXX 100644 | ||
34 | --- a/hw/arm/sysbus-fdt.c | ||
35 | +++ b/hw/arm/sysbus-fdt.c | ||
36 | @@ -XXX,XX +XXX,XX @@ static bool type_match(SysBusDevice *sbdev, const BindingEntry *entry) | ||
37 | return !strcmp(object_get_typename(OBJECT(sbdev)), entry->typename); | ||
38 | } | ||
39 | |||
40 | -#define TYPE_BINDING(type, add_fn) {(type), NULL, (add_fn), type_match} | ||
41 | +#define TYPE_BINDING(type, add_fn) {(type), NULL, (add_fn), NULL} | ||
42 | |||
43 | /* list of supported dynamic sysbus bindings */ | ||
44 | static const BindingEntry bindings[] = { | ||
45 | @@ -XXX,XX +XXX,XX @@ static void add_fdt_node(SysBusDevice *sbdev, void *opaque) | ||
46 | for (i = 0; i < ARRAY_SIZE(bindings); i++) { | ||
47 | const BindingEntry *iter = &bindings[i]; | ||
48 | |||
49 | - if (iter->match_fn(sbdev, iter)) { | ||
50 | - ret = iter->add_fn(sbdev, opaque); | ||
51 | - assert(!ret); | ||
52 | - return; | ||
53 | + if (type_match(sbdev, iter)) { | ||
54 | + if (!iter->match_fn || iter->match_fn(sbdev, iter)) { | ||
55 | + ret = iter->add_fn(sbdev, opaque); | ||
56 | + assert(!ret); | ||
57 | + return; | ||
58 | + } | ||
59 | } | ||
60 | } | ||
61 | error_report("Device %s can not be dynamically instantiated", | ||
62 | -- | ||
63 | 2.19.1 | ||
64 | |||
65 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alex Bennée <alex.bennee@linaro.org> | ||
2 | 1 | ||
3 | This only fails with some (broken) versions of gdb but we should | ||
4 | treat the top bits of DBGBVR as RESS. Properly sign extend QEMU's | ||
5 | reference copy of dbgbvr and also update the register descriptions in | ||
6 | the comment. | ||
7 | |||
8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20181109152119.9242-2-alex.bennee@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/kvm64.c | 17 +++++++++++++++-- | ||
14 | 1 file changed, 15 insertions(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/kvm64.c | ||
19 | +++ b/target/arm/kvm64.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_init_debug(CPUState *cs) | ||
21 | * capable of fancier matching but that will require exposing that | ||
22 | * fanciness to GDB's interface | ||
23 | * | ||
24 | - * D7.3.2 DBGBCR<n>_EL1, Debug Breakpoint Control Registers | ||
25 | + * DBGBCR<n>_EL1, Debug Breakpoint Control Registers | ||
26 | * | ||
27 | * 31 24 23 20 19 16 15 14 13 12 9 8 5 4 3 2 1 0 | ||
28 | * +------+------+-------+-----+----+------+-----+------+-----+---+ | ||
29 | @@ -XXX,XX +XXX,XX @@ static void kvm_arm_init_debug(CPUState *cs) | ||
30 | * SSC/HMC/PMC: Security, Higher and Priv access control (Table D-12) | ||
31 | * BAS: Byte Address Select (RES1 for AArch64) | ||
32 | * E: Enable bit | ||
33 | + * | ||
34 | + * DBGBVR<n>_EL1, Debug Breakpoint Value Registers | ||
35 | + * | ||
36 | + * 63 53 52 49 48 2 1 0 | ||
37 | + * +------+-----------+----------+-----+ | ||
38 | + * | RESS | VA[52:49] | VA[48:2] | 0 0 | | ||
39 | + * +------+-----------+----------+-----+ | ||
40 | + * | ||
41 | + * Depending on the addressing mode bits the top bits of the register | ||
42 | + * are a sign extension of the highest applicable VA bit. Some | ||
43 | + * versions of GDB don't do it correctly so we ensure they are correct | ||
44 | + * here so future PC comparisons will work properly. | ||
45 | */ | ||
46 | + | ||
47 | static int insert_hw_breakpoint(target_ulong addr) | ||
48 | { | ||
49 | HWBreakpoint brk = { | ||
50 | .bcr = 0x1, /* BCR E=1, enable */ | ||
51 | - .bvr = addr | ||
52 | + .bvr = sextract64(addr, 0, 53) | ||
53 | }; | ||
54 | |||
55 | if (cur_hw_bps >= max_hw_bps) { | ||
56 | -- | ||
57 | 2.19.1 | ||
58 | |||
59 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alex Bennée <alex.bennee@linaro.org> | ||
2 | 1 | ||
3 | Fix the assertion failure when running interrupts. | ||
4 | |||
5 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20181109152119.9242-3-alex.bennee@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | target/arm/kvm64.c | 2 ++ | ||
12 | 1 file changed, 2 insertions(+) | ||
13 | |||
14 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/target/arm/kvm64.c | ||
17 | +++ b/target/arm/kvm64.c | ||
18 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit) | ||
19 | cs->exception_index = EXCP_BKPT; | ||
20 | env->exception.syndrome = debug_exit->hsr; | ||
21 | env->exception.vaddress = debug_exit->far; | ||
22 | + qemu_mutex_lock_iothread(); | ||
23 | cc->do_interrupt(cs); | ||
24 | + qemu_mutex_unlock_iothread(); | ||
25 | |||
26 | return false; | ||
27 | } | ||
28 | -- | ||
29 | 2.19.1 | ||
30 | |||
31 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alex Bennée <alex.bennee@linaro.org> | ||
2 | 1 | ||
3 | When we are debugging the guest all exceptions come our way but might | ||
4 | be for the guest's own debug exceptions. We use the ->do_interrupt() | ||
5 | infrastructure to inject the exception into the guest. However, we are | ||
6 | missing a full setup of the exception structure, causing an assert | ||
7 | later down the line. | ||
8 | |||
9 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20181109152119.9242-4-alex.bennee@linaro.org | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | target/arm/kvm64.c | 1 + | ||
16 | 1 file changed, 1 insertion(+) | ||
17 | |||
18 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/target/arm/kvm64.c | ||
21 | +++ b/target/arm/kvm64.c | ||
22 | @@ -XXX,XX +XXX,XX @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit) | ||
23 | cs->exception_index = EXCP_BKPT; | ||
24 | env->exception.syndrome = debug_exit->hsr; | ||
25 | env->exception.vaddress = debug_exit->far; | ||
26 | + env->exception.target_el = 1; | ||
27 | qemu_mutex_lock_iothread(); | ||
28 | cc->do_interrupt(cs); | ||
29 | qemu_mutex_unlock_iothread(); | ||
30 | -- | ||
31 | 2.19.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alex Bennée <alex.bennee@linaro.org> | ||
2 | 1 | ||
3 | You should declare you are using a global version of a variable before | ||
4 | you attempt to modify it in a function. | ||
5 | |||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20181109152119.9242-5-alex.bennee@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | tests/guest-debug/test-gdbstub.py | 1 + | ||
13 | 1 file changed, 1 insertion(+) | ||
14 | |||
15 | diff --git a/tests/guest-debug/test-gdbstub.py b/tests/guest-debug/test-gdbstub.py | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/tests/guest-debug/test-gdbstub.py | ||
18 | +++ b/tests/guest-debug/test-gdbstub.py | ||
19 | @@ -XXX,XX +XXX,XX @@ def report(cond, msg): | ||
20 | print ("PASS: %s" % (msg)) | ||
21 | else: | ||
22 | print ("FAIL: %s" % (msg)) | ||
23 | + global failcount | ||
24 | failcount += 1 | ||
25 | |||
26 | |||
27 | -- | ||
28 | 2.19.1 | ||
29 | |||
30 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Alex Bennée <alex.bennee@linaro.org> | ||
2 | 1 | ||
3 | The test was incomplete and incorrectly caused debug exceptions to be | ||
4 | generated when returning to EL2 after a failed attempt to single-step | ||
5 | an EL1 instruction. Fix this while cleaning up the function a little. | ||
6 | |||
7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20181109152119.9242-8-alex.bennee@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/cpu.h | 39 ++++++++++++++++++++++++--------------- | ||
13 | 1 file changed, 24 insertions(+), 15 deletions(-) | ||
14 | |||
15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/target/arm/cpu.h | ||
18 | +++ b/target/arm/cpu.h | ||
19 | @@ -XXX,XX +XXX,XX @@ static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu) | ||
20 | return (cpu->clidr & R_V7M_CLIDR_CTYPE_ALL_MASK) != 0; | ||
21 | } | ||
22 | |||
23 | +/* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */ | ||
24 | static inline bool aa64_generate_debug_exceptions(CPUARMState *env) | ||
25 | { | ||
26 | - if (arm_is_secure(env)) { | ||
27 | - /* MDCR_EL3.SDD disables debug events from Secure state */ | ||
28 | - if (extract32(env->cp15.mdcr_el3, 16, 1) != 0 | ||
29 | - || arm_current_el(env) == 3) { | ||
30 | - return false; | ||
31 | - } | ||
32 | + int cur_el = arm_current_el(env); | ||
33 | + int debug_el; | ||
34 | + | ||
35 | + if (cur_el == 3) { | ||
36 | + return false; | ||
37 | } | ||
38 | |||
39 | - if (arm_current_el(env) == arm_debug_target_el(env)) { | ||
40 | - if ((extract32(env->cp15.mdscr_el1, 13, 1) == 0) | ||
41 | - || (env->daif & PSTATE_D)) { | ||
42 | - return false; | ||
43 | - } | ||
44 | + /* MDCR_EL3.SDD disables debug events from Secure state */ | ||
45 | + if (arm_is_secure_below_el3(env) | ||
46 | + && extract32(env->cp15.mdcr_el3, 16, 1)) { | ||
47 | + return false; | ||
48 | } | ||
49 | - return true; | ||
50 | + | ||
51 | + /* | ||
52 | + * Same EL to same EL debug exceptions need MDSCR_KDE enabled | ||
53 | + * while not masking the (D)ebug bit in DAIF. | ||
54 | + */ | ||
55 | + debug_el = arm_debug_target_el(env); | ||
56 | + | ||
57 | + if (cur_el == debug_el) { | ||
58 | + return extract32(env->cp15.mdscr_el1, 13, 1) | ||
59 | + && !(env->daif & PSTATE_D); | ||
60 | + } | ||
61 | + | ||
62 | + /* Otherwise the debug target needs to be a higher EL */ | ||
63 | + return debug_el > cur_el; | ||
64 | } | ||
65 | |||
66 | static inline bool aa32_generate_debug_exceptions(CPUARMState *env) | ||
67 | @@ -XXX,XX +XXX,XX @@ static inline bool aa32_generate_debug_exceptions(CPUARMState *env) | ||
68 | * since the pseudocode has it at all callsites except for the one in | ||
69 | * CheckSoftwareStep(), where it is elided because both branches would | ||
70 | * always return the same value. | ||
71 | - * | ||
72 | - * Parts of the pseudocode relating to EL2 and EL3 are omitted because we | ||
73 | - * don't yet implement those exception levels or their associated trap bits. | ||
74 | */ | ||
75 | static inline bool arm_generate_debug_exceptions(CPUARMState *env) | ||
76 | { | ||
77 | -- | ||
78 | 2.19.1 | ||
79 | |||
80 | diff view generated by jsdifflib |
1 | This reverts commit 8a0fc3a29fc2315325400c738f807d0d4ae0ab7f. | 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 | The implementation of HCR.VI and VF in that commit is not | 8 | The cleanest way to avoid this double-transaction is to move the |
4 | correct -- they do not track the overall "is there a pending | 9 | start-transaction for the CR write handling down below the check of |
5 | VIRQ or VFIQ" status, but whether there is a pending interrupt | 10 | the SWR bit. |
6 | due to "this mechanism", ie the hypervisor having set the VI/VF | ||
7 | bits. The overall pending state for VIRQ and VFIQ is effectively | ||
8 | the logical OR of the inbound lines from the GIC with the | ||
9 | VI and VF bits. Commit 8a0fc3a29fc231 would result in pending | ||
10 | VIRQ/VFIQ possibly being lost when the hypervisor wrote to HCR. | ||
11 | 11 | ||
12 | As a preliminary to implementing the HCR.VI/VF feature properly, | 12 | Fixes: https://bugs.launchpad.net/qemu/+bug/1880424 |
13 | revert the broken one entirely. | 13 | Fixes: cc2722ec83ad944505fe |
14 | |||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 15 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> |
17 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 16 | Message-id: 20200727154550.3409-1-peter.maydell@linaro.org |
18 | Message-id: 20181109134731.11605-2-peter.maydell@linaro.org | ||
19 | --- | 17 | --- |
20 | target/arm/helper.c | 47 ++++----------------------------------------- | 18 | hw/timer/imx_epit.c | 13 ++++++++++--- |
21 | 1 file changed, 4 insertions(+), 43 deletions(-) | 19 | 1 file changed, 10 insertions(+), 3 deletions(-) |
22 | 20 | ||
23 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 21 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c |
24 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/arm/helper.c | 23 | --- a/hw/timer/imx_epit.c |
26 | +++ b/target/arm/helper.c | 24 | +++ b/hw/timer/imx_epit.c |
27 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = { | 25 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, |
28 | static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 26 | |
29 | { | 27 | switch (offset >> 2) { |
30 | ARMCPU *cpu = arm_env_get_cpu(env); | 28 | case 0: /* CR */ |
31 | - CPUState *cs = ENV_GET_CPU(env); | 29 | - ptimer_transaction_begin(s->timer_cmp); |
32 | uint64_t valid_mask = HCR_MASK; | 30 | - ptimer_transaction_begin(s->timer_reload); |
33 | 31 | ||
34 | if (arm_feature(env, ARM_FEATURE_EL3)) { | 32 | oldcr = s->cr; |
35 | @@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | 33 | s->cr = value & 0x03ffffff; |
36 | /* Clear RES0 bits. */ | 34 | if (s->cr & CR_SWR) { |
37 | value &= valid_mask; | 35 | /* handle the reset */ |
38 | 36 | imx_epit_reset(DEVICE(s)); | |
39 | - /* | 37 | - } else { |
40 | - * VI and VF are kept in cs->interrupt_request. Modifying that | 38 | + /* |
41 | - * requires that we have the iothread lock, which is done by | 39 | + * TODO: could we 'break' here? following operations appear |
42 | - * marking the reginfo structs as ARM_CP_IO. | 40 | + * to duplicate the work imx_epit_reset() already did. |
43 | - * Note that if a write to HCR pends a VIRQ or VFIQ it is never | 41 | + */ |
44 | - * possible for it to be taken immediately, because VIRQ and | 42 | + } |
45 | - * VFIQ are masked unless running at EL0 or EL1, and HCR | 43 | + |
46 | - * can only be written at EL2. | 44 | + ptimer_transaction_begin(s->timer_cmp); |
47 | - */ | 45 | + ptimer_transaction_begin(s->timer_reload); |
48 | - g_assert(qemu_mutex_iothread_locked()); | 46 | + |
49 | - if (value & HCR_VI) { | 47 | + if (!(s->cr & CR_SWR)) { |
50 | - cs->interrupt_request |= CPU_INTERRUPT_VIRQ; | 48 | imx_epit_set_freq(s); |
51 | - } else { | 49 | } |
52 | - cs->interrupt_request &= ~CPU_INTERRUPT_VIRQ; | 50 | |
53 | - } | ||
54 | - if (value & HCR_VF) { | ||
55 | - cs->interrupt_request |= CPU_INTERRUPT_VFIQ; | ||
56 | - } else { | ||
57 | - cs->interrupt_request &= ~CPU_INTERRUPT_VFIQ; | ||
58 | - } | ||
59 | - value &= ~(HCR_VI | HCR_VF); | ||
60 | - | ||
61 | /* These bits change the MMU setup: | ||
62 | * HCR_VM enables stage 2 translation | ||
63 | * HCR_PTW forbids certain page-table setups | ||
64 | @@ -XXX,XX +XXX,XX @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri, | ||
65 | hcr_write(env, NULL, value); | ||
66 | } | ||
67 | |||
68 | -static uint64_t hcr_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
69 | -{ | ||
70 | - /* The VI and VF bits live in cs->interrupt_request */ | ||
71 | - uint64_t ret = env->cp15.hcr_el2 & ~(HCR_VI | HCR_VF); | ||
72 | - CPUState *cs = ENV_GET_CPU(env); | ||
73 | - | ||
74 | - if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) { | ||
75 | - ret |= HCR_VI; | ||
76 | - } | ||
77 | - if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) { | ||
78 | - ret |= HCR_VF; | ||
79 | - } | ||
80 | - return ret; | ||
81 | -} | ||
82 | - | ||
83 | static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
84 | { .name = "HCR_EL2", .state = ARM_CP_STATE_AA64, | ||
85 | - .type = ARM_CP_IO, | ||
86 | .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, | ||
87 | .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2), | ||
88 | - .writefn = hcr_write, .readfn = hcr_read }, | ||
89 | + .writefn = hcr_write }, | ||
90 | { .name = "HCR", .state = ARM_CP_STATE_AA32, | ||
91 | - .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
92 | + .type = ARM_CP_ALIAS, | ||
93 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, | ||
94 | .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2), | ||
95 | - .writefn = hcr_writelow, .readfn = hcr_read }, | ||
96 | + .writefn = hcr_writelow }, | ||
97 | { .name = "ELR_EL2", .state = ARM_CP_STATE_AA64, | ||
98 | .type = ARM_CP_ALIAS, | ||
99 | .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 0, .opc2 = 1, | ||
100 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = { | ||
101 | |||
102 | static const ARMCPRegInfo el2_v8_cp_reginfo[] = { | ||
103 | { .name = "HCR2", .state = ARM_CP_STATE_AA32, | ||
104 | - .type = ARM_CP_ALIAS | ARM_CP_IO, | ||
105 | + .type = ARM_CP_ALIAS, | ||
106 | .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4, | ||
107 | .access = PL2_RW, | ||
108 | .fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2), | ||
109 | -- | 51 | -- |
110 | 2.19.1 | 52 | 2.20.1 |
111 | 53 | ||
112 | 54 | diff view generated by jsdifflib |