1 | Handful of bugfixes for rc2. None of these are particularly critical | 1 | The following changes since commit aa9e7fa4689d1becb2faf67f65aafcbcf664f1ce: |
---|---|---|---|
2 | or exciting. | ||
3 | 2 | ||
4 | -- PMM | 3 | Merge tag 'edk2-stable202302-20230320-pull-request' of https://gitlab.com/kraxel/qemu into staging (2023-03-20 13:43:35 +0000) |
5 | |||
6 | The following changes since commit 45a150aa2b3492acf6691c7bdbeb25a8545d8345: | ||
7 | |||
8 | Merge remote-tracking branch 'remotes/ericb/tags/pull-bitmaps-2020-08-03' into staging (2020-08-03 15:13:49 +0100) | ||
9 | 4 | ||
10 | are available in the Git repository at: | 5 | are available in the Git repository at: |
11 | 6 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200803 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230321 |
13 | 8 | ||
14 | for you to fetch changes up to 13557fd392890cbd985bceba7f717e01efd674b8: | 9 | for you to fetch changes up to 5787d17a42f7af4bd117e5d6bfa54b1fdf93c255: |
15 | 10 | ||
16 | hw/timer/imx_epit: Avoid assertion when CR.SWR is written (2020-08-03 17:56:11 +0100) | 11 | target/arm: Don't advertise aarch64-pauth.xml to gdb (2023-03-21 13:19:08 +0000) |
17 | 12 | ||
18 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
19 | target-arm queue: | 14 | target-arm queue: |
20 | * hw/timer/imx_epit: Avoid assertion when CR.SWR is written | 15 | * contrib/elf2dmp: Support Windows Server 2022 |
21 | * netduino2, netduinoplus2, microbit: set system_clock_scale so that | 16 | * hw/char/cadence_uart: Fix guards on invalid BRGR/BDIV settings |
22 | SysTick running on the CPU clock works | 17 | * target/arm: Add Neoverse-N1 IMPDEF registers |
23 | * target/arm: Avoid maybe-uninitialized warning with gcc 4.9 | 18 | * hw/usb/imx: Fix out of bounds access in imx_usbphy_read() |
24 | * target/arm: Fix AddPAC error indication | 19 | * docs/system/arm/cpu-features.rst: Fix formatting |
25 | * Make AIRCR.SYSRESETREQ actually reset the system for the | 20 | * target/arm: Don't advertise aarch64-pauth.xml to gdb |
26 | microbit, mps2-*, musca-*, netduino* boards | ||
27 | 21 | ||
28 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
29 | Kaige Li (1): | 23 | Chen Baozi (1): |
30 | target/arm: Avoid maybe-uninitialized warning with gcc 4.9 | 24 | target/arm: Add Neoverse-N1 registers |
31 | 25 | ||
32 | Peter Maydell (6): | 26 | Guenter Roeck (1): |
33 | hw/arm/netduino2, netduinoplus2: Set system_clock_scale | 27 | hw/usb/imx: Fix out of bounds access in imx_usbphy_read() |
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 | 28 | ||
40 | Richard Henderson (1): | 29 | Peter Maydell (3): |
41 | target/arm: Fix AddPAC error indication | 30 | hw/char/cadence_uart: Fix guards on invalid BRGR/BDIV settings |
31 | docs/system/arm/cpu-features.rst: Fix formatting | ||
32 | target/arm: Don't advertise aarch64-pauth.xml to gdb | ||
42 | 33 | ||
43 | include/hw/arm/armv7m.h | 4 +++- | 34 | Viktor Prutyanov (3): |
44 | include/hw/irq.h | 18 ++++++++++++++++++ | 35 | contrib/elf2dmp: fix code style |
45 | hw/arm/msf2-soc.c | 11 ----------- | 36 | contrib/elf2dmp: move PE dir search to pe_get_data_dir_entry |
46 | hw/arm/netduino2.c | 10 ++++++++++ | 37 | contrib/elf2dmp: add PE name check and Windows Server 2022 support |
47 | hw/arm/netduinoplus2.c | 10 ++++++++++ | ||
48 | hw/arm/nrf51_soc.c | 5 +++++ | ||
49 | hw/arm/stellaris.c | 12 ------------ | ||
50 | hw/intc/armv7m_nvic.c | 17 ++++++++++++++++- | ||
51 | hw/timer/imx_epit.c | 13 ++++++++++--- | ||
52 | target/arm/pauth_helper.c | 6 +++++- | ||
53 | target/arm/translate-a64.c | 2 +- | ||
54 | tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++++ | ||
55 | tests/tcg/aarch64/Makefile.target | 2 +- | ||
56 | 13 files changed, 112 insertions(+), 31 deletions(-) | ||
57 | create mode 100644 tests/tcg/aarch64/pauth-5.c | ||
58 | 38 | ||
39 | docs/system/arm/cpu-features.rst | 68 ++++++++++------------- | ||
40 | contrib/elf2dmp/pe.h | 115 ++++++++++++++++++++++----------------- | ||
41 | contrib/elf2dmp/addrspace.c | 1 + | ||
42 | contrib/elf2dmp/main.c | 108 ++++++++++++++++++++++++------------ | ||
43 | hw/char/cadence_uart.c | 6 +- | ||
44 | hw/usb/imx-usb-phy.c | 19 ++++++- | ||
45 | target/arm/cpu64.c | 69 +++++++++++++++++++++++ | ||
46 | target/arm/gdbstub.c | 7 +++ | ||
47 | 8 files changed, 267 insertions(+), 126 deletions(-) | diff view generated by jsdifflib |
1 | The MSF2 SoC model and the Stellaris board code both wire | 1 | From: Chen Baozi <chenbaozi@phytium.com.cn> |
---|---|---|---|
2 | SYSRESETREQ up to a function that just invokes | ||
3 | qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
4 | This is now the default action that the NVIC does if the line is | ||
5 | not connected, so we can delete the handling code. | ||
6 | 2 | ||
3 | Add implementation defined registers for neoverse-n1 which | ||
4 | would be accessed by TF-A. Since there is no DSU in Qemu, | ||
5 | CPUCFR_EL1.SCU bit is set to 1 to avoid DSU registers definition. | ||
6 | |||
7 | Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> | ||
10 | Message-id: 20230313033936.585669-1-chenbaozi@phytium.com.cn | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
9 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
10 | Message-id: 20200728103744.6909-4-peter.maydell@linaro.org | ||
11 | --- | 12 | --- |
12 | hw/arm/msf2-soc.c | 11 ----------- | 13 | target/arm/cpu64.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++ |
13 | hw/arm/stellaris.c | 12 ------------ | 14 | 1 file changed, 69 insertions(+) |
14 | 2 files changed, 23 deletions(-) | ||
15 | 15 | ||
16 | diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c | 16 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/msf2-soc.c | 18 | --- a/target/arm/cpu64.c |
19 | +++ b/hw/arm/msf2-soc.c | 19 | +++ b/target/arm/cpu64.c |
20 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
21 | #include "hw/irq.h" | 21 | #include "qemu/osdep.h" |
22 | #include "hw/arm/msf2-soc.h" | 22 | #include "qapi/error.h" |
23 | #include "hw/misc/unimp.h" | 23 | #include "cpu.h" |
24 | -#include "sysemu/runstate.h" | 24 | +#include "cpregs.h" |
25 | #include "sysemu/sysemu.h" | 25 | #include "qemu/module.h" |
26 | 26 | #include "sysemu/kvm.h" | |
27 | #define MSF2_TIMER_BASE 0x40004000 | 27 | #include "sysemu/hvf.h" |
28 | @@ -XXX,XX +XXX,XX @@ static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 }; | 28 | @@ -XXX,XX +XXX,XX @@ static void aarch64_a64fx_initfn(Object *obj) |
29 | static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 }; | 29 | /* TODO: Add A64FX specific HPC extension registers */ |
30 | static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 }; | 30 | } |
31 | 31 | ||
32 | -static void do_sys_reset(void *opaque, int n, int level) | 32 | +static const ARMCPRegInfo neoverse_n1_cp_reginfo[] = { |
33 | -{ | 33 | + { .name = "ATCR_EL1", .state = ARM_CP_STATE_AA64, |
34 | - if (level) { | 34 | + .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 7, .opc2 = 0, |
35 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | 35 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
36 | - } | 36 | + { .name = "ATCR_EL2", .state = ARM_CP_STATE_AA64, |
37 | -} | 37 | + .opc0 = 3, .opc1 = 4, .crn = 15, .crm = 7, .opc2 = 0, |
38 | - | 38 | + .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, |
39 | static void m2sxxx_soc_initfn(Object *obj) | 39 | + { .name = "ATCR_EL3", .state = ARM_CP_STATE_AA64, |
40 | + .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 7, .opc2 = 0, | ||
41 | + .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
42 | + { .name = "ATCR_EL12", .state = ARM_CP_STATE_AA64, | ||
43 | + .opc0 = 3, .opc1 = 5, .crn = 15, .crm = 7, .opc2 = 0, | ||
44 | + .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
45 | + { .name = "AVTCR_EL2", .state = ARM_CP_STATE_AA64, | ||
46 | + .opc0 = 3, .opc1 = 4, .crn = 15, .crm = 7, .opc2 = 1, | ||
47 | + .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
48 | + { .name = "CPUACTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
49 | + .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 0, | ||
50 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
51 | + { .name = "CPUACTLR2_EL1", .state = ARM_CP_STATE_AA64, | ||
52 | + .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 1, | ||
53 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
54 | + { .name = "CPUACTLR3_EL1", .state = ARM_CP_STATE_AA64, | ||
55 | + .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 2, | ||
56 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
57 | + /* | ||
58 | + * Report CPUCFR_EL1.SCU as 1, as we do not implement the DSU | ||
59 | + * (and in particular its system registers). | ||
60 | + */ | ||
61 | + { .name = "CPUCFR_EL1", .state = ARM_CP_STATE_AA64, | ||
62 | + .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 0, .opc2 = 0, | ||
63 | + .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 4 }, | ||
64 | + { .name = "CPUECTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
65 | + .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 1, .opc2 = 4, | ||
66 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0x961563010 }, | ||
67 | + { .name = "CPUPCR_EL3", .state = ARM_CP_STATE_AA64, | ||
68 | + .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 1, | ||
69 | + .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
70 | + { .name = "CPUPMR_EL3", .state = ARM_CP_STATE_AA64, | ||
71 | + .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 3, | ||
72 | + .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
73 | + { .name = "CPUPOR_EL3", .state = ARM_CP_STATE_AA64, | ||
74 | + .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 2, | ||
75 | + .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
76 | + { .name = "CPUPSELR_EL3", .state = ARM_CP_STATE_AA64, | ||
77 | + .opc0 = 3, .opc1 = 6, .crn = 15, .crm = 8, .opc2 = 0, | ||
78 | + .access = PL3_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
79 | + { .name = "CPUPWRCTLR_EL1", .state = ARM_CP_STATE_AA64, | ||
80 | + .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 7, | ||
81 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
82 | + { .name = "ERXPFGCDN_EL1", .state = ARM_CP_STATE_AA64, | ||
83 | + .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 2, | ||
84 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
85 | + { .name = "ERXPFGCTL_EL1", .state = ARM_CP_STATE_AA64, | ||
86 | + .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 1, | ||
87 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
88 | + { .name = "ERXPFGF_EL1", .state = ARM_CP_STATE_AA64, | ||
89 | + .opc0 = 3, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 0, | ||
90 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
91 | +}; | ||
92 | + | ||
93 | +static void define_neoverse_n1_cp_reginfo(ARMCPU *cpu) | ||
94 | +{ | ||
95 | + define_arm_cp_regs(cpu, neoverse_n1_cp_reginfo); | ||
96 | +} | ||
97 | + | ||
98 | static void aarch64_neoverse_n1_initfn(Object *obj) | ||
40 | { | 99 | { |
41 | MSF2State *s = MSF2_SOC(obj); | 100 | ARMCPU *cpu = ARM_CPU(obj); |
42 | @@ -XXX,XX +XXX,XX @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp) | 101 | @@ -XXX,XX +XXX,XX @@ static void aarch64_neoverse_n1_initfn(Object *obj) |
43 | return; | 102 | |
44 | } | 103 | /* From D5.1 AArch64 PMU register summary */ |
45 | 104 | cpu->isar.reset_pmcr_el0 = 0x410c3000; | |
46 | - qdev_connect_gpio_out_named(DEVICE(&s->armv7m.nvic), "SYSRESETREQ", 0, | 105 | + |
47 | - qemu_allocate_irq(&do_sys_reset, NULL, 0)); | 106 | + define_neoverse_n1_cp_reginfo(cpu); |
48 | - | ||
49 | system_clock_scale = NANOSECONDS_PER_SECOND / s->m3clk; | ||
50 | |||
51 | for (i = 0; i < MSF2_NUM_UARTS; i++) { | ||
52 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
53 | index XXXXXXX..XXXXXXX 100644 | ||
54 | --- a/hw/arm/stellaris.c | ||
55 | +++ b/hw/arm/stellaris.c | ||
56 | @@ -XXX,XX +XXX,XX @@ | ||
57 | #include "hw/boards.h" | ||
58 | #include "qemu/log.h" | ||
59 | #include "exec/address-spaces.h" | ||
60 | -#include "sysemu/runstate.h" | ||
61 | #include "sysemu/sysemu.h" | ||
62 | #include "hw/arm/armv7m.h" | ||
63 | #include "hw/char/pl011.h" | ||
64 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_init(Object *obj) | ||
65 | qdev_init_gpio_in(dev, stellaris_adc_trigger, 1); | ||
66 | } | 107 | } |
67 | 108 | ||
68 | -static | 109 | static void aarch64_host_initfn(Object *obj) |
69 | -void do_sys_reset(void *opaque, int n, int level) | ||
70 | -{ | ||
71 | - if (level) { | ||
72 | - qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
73 | - } | ||
74 | -} | ||
75 | - | ||
76 | /* Board init. */ | ||
77 | static stellaris_board_info stellaris_boards[] = { | ||
78 | { "LM3S811EVB", | ||
79 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
80 | /* This will exit with an error if the user passed us a bad cpu_type */ | ||
81 | sysbus_realize_and_unref(SYS_BUS_DEVICE(nvic), &error_fatal); | ||
82 | |||
83 | - qdev_connect_gpio_out_named(nvic, "SYSRESETREQ", 0, | ||
84 | - qemu_allocate_irq(&do_sys_reset, NULL, 0)); | ||
85 | - | ||
86 | if (board->dc1 & (1 << 16)) { | ||
87 | dev = sysbus_create_varargs(TYPE_STELLARIS_ADC, 0x40038000, | ||
88 | qdev_get_gpio_in(nvic, 14), | ||
89 | -- | 110 | -- |
90 | 2.20.1 | 111 | 2.34.1 |
91 | |||
92 | diff view generated by jsdifflib |
1 | The NVIC provides an outbound qemu_irq "SYSRESETREQ" which it signals | 1 | The cadence UART attempts to avoid allowing the guest to set invalid |
---|---|---|---|
2 | when the guest sets the SYSRESETREQ bit in the AIRCR register. This | 2 | baud rate register values in the uart_write() function. However it |
3 | matches the hardware design (where the CPU has a signal of this name | 3 | does the "mask to the size of the register field" and "check for |
4 | and it is up to the SoC to connect that up to an actual reset | 4 | invalid values" in the wrong order, which means that a malicious |
5 | mechanism), but in QEMU it mostly results in duplicated code in SoC | 5 | guest can get a bogus value into the register by setting also some |
6 | objects and bugs where SoC model implementors forget to wire up the | 6 | high bits in the value, and cause QEMU to crash by division-by-zero. |
7 | SYSRESETREQ line. | ||
8 | 7 | ||
9 | Provide a default behaviour for the case where SYSRESETREQ is not | 8 | Do the mask before the bounds check instead of afterwards. |
10 | actually connected to anything: use qemu_system_reset_request() to | ||
11 | perform a system reset. This will allow us to remove the | ||
12 | implementations of SYSRESETREQ handling from the boards where that's | ||
13 | exactly what it does, and also fixes the bugs in the board models | ||
14 | which forgot to wire up the signal: | ||
15 | 9 | ||
16 | * microbit | 10 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1493 |
17 | * mps2-an385 | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | * mps2-an505 | 12 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
19 | * mps2-an511 | 13 | Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com> |
20 | * mps2-an521 | 14 | Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com> |
21 | * musca-a | 15 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> |
22 | * musca-b1 | 16 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
23 | * netduino | 17 | Tested-by: Qiang Liu <cyruscyliu@gmail.com> |
24 | * netduinoplus2 | 18 | Message-id: 20230314170804.1196232-1-peter.maydell@linaro.org |
19 | --- | ||
20 | hw/char/cadence_uart.c | 6 ++++-- | ||
21 | 1 file changed, 4 insertions(+), 2 deletions(-) | ||
25 | 22 | ||
26 | We still allow the board to wire up the signal if it needs to, in case | 23 | diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.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 | 24 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/include/hw/arm/armv7m.h | 25 | --- a/hw/char/cadence_uart.c |
44 | +++ b/include/hw/arm/armv7m.h | 26 | +++ b/hw/char/cadence_uart.c |
45 | @@ -XXX,XX +XXX,XX @@ typedef struct { | 27 | @@ -XXX,XX +XXX,XX @@ static MemTxResult uart_write(void *opaque, hwaddr offset, |
46 | 28 | } | |
47 | /* ARMv7M container object. | 29 | break; |
48 | * + Unnamed GPIO input lines: external IRQ lines for the NVIC | 30 | case R_BRGR: /* Baud rate generator */ |
49 | - * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ | 31 | + value &= 0xffff; |
50 | + * + Named GPIO output SYSRESETREQ: signalled for guest AIRCR.SYSRESETREQ. | 32 | if (value >= 0x01) { |
51 | + * If this GPIO is not wired up then the NVIC will default to performing | 33 | - s->r[offset] = value & 0xFFFF; |
52 | + * a qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET). | 34 | + s->r[offset] = value; |
53 | * + Property "cpu-type": CPU type to instantiate | 35 | } |
54 | * + Property "num-irq": number of external IRQ lines | 36 | break; |
55 | * + Property "memory": MemoryRegion defining the physical address space | 37 | case R_BDIV: /* Baud rate divider */ |
56 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 38 | + value &= 0xff; |
57 | index XXXXXXX..XXXXXXX 100644 | 39 | if (value >= 0x04) { |
58 | --- a/hw/intc/armv7m_nvic.c | 40 | - s->r[offset] = value & 0xFF; |
59 | +++ b/hw/intc/armv7m_nvic.c | 41 | + s->r[offset] = value; |
60 | @@ -XXX,XX +XXX,XX @@ | 42 | } |
61 | #include "hw/intc/armv7m_nvic.h" | 43 | break; |
62 | #include "hw/irq.h" | 44 | default: |
63 | #include "hw/qdev-properties.h" | ||
64 | +#include "sysemu/runstate.h" | ||
65 | #include "target/arm/cpu.h" | ||
66 | #include "exec/exec-all.h" | ||
67 | #include "exec/memop.h" | ||
68 | @@ -XXX,XX +XXX,XX @@ static const uint8_t nvic_id[] = { | ||
69 | 0x00, 0xb0, 0x1b, 0x00, 0x0d, 0xe0, 0x05, 0xb1 | ||
70 | }; | ||
71 | |||
72 | +static void signal_sysresetreq(NVICState *s) | ||
73 | +{ | ||
74 | + if (qemu_irq_is_connected(s->sysresetreq)) { | ||
75 | + qemu_irq_pulse(s->sysresetreq); | ||
76 | + } else { | ||
77 | + /* | ||
78 | + * Default behaviour if the SoC doesn't need to wire up | ||
79 | + * SYSRESETREQ (eg to a system reset controller of some kind): | ||
80 | + * perform a system reset via the usual QEMU API. | ||
81 | + */ | ||
82 | + qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET); | ||
83 | + } | ||
84 | +} | ||
85 | + | ||
86 | static int nvic_pending_prio(NVICState *s) | ||
87 | { | ||
88 | /* return the group priority of the current pending interrupt, | ||
89 | @@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value, | ||
90 | if (value & R_V7M_AIRCR_SYSRESETREQ_MASK) { | ||
91 | if (attrs.secure || | ||
92 | !(cpu->env.v7m.aircr & R_V7M_AIRCR_SYSRESETREQS_MASK)) { | ||
93 | - qemu_irq_pulse(s->sysresetreq); | ||
94 | + signal_sysresetreq(s); | ||
95 | } | ||
96 | } | ||
97 | if (value & R_V7M_AIRCR_VECTCLRACTIVE_MASK) { | ||
98 | -- | 45 | -- |
99 | 2.20.1 | 46 | 2.34.1 |
100 | 47 | ||
101 | 48 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Viktor Prutyanov <viktor@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | The definition of top_bit used in this function is one higher | 3 | Originally elf2dmp were added with some code style issues, |
4 | than that used in the Arm ARM psuedo-code, which put the error | 4 | especially in pe.h header, and some were introduced by |
5 | indication at top_bit - 1 at the wrong place, which meant that | 5 | 2d0fc797faaa73fbc1d30f5f9e90407bf3dd93f0. Fix them now. |
6 | it wasn't visible to Auth. | ||
7 | 6 | ||
8 | Fixing the definition of top_bit requires more changes, because | 7 | Signed-off-by: Viktor Prutyanov <viktor@daynix.com> |
9 | its most common use is for the count of bits in top_bit:bot_bit, | 8 | Reviewed-by: Annie Li <annie.li@oracle.com> |
10 | which would then need to be computed as top_bit - bot_bit + 1. | 9 | Message-id: 20230222211246.883679-2-viktor@daynix.com |
11 | |||
12 | For now, prefer the minimal fix to the error indication alone. | ||
13 | |||
14 | Fixes: 63ff0ca94cb | ||
15 | Reported-by: Derrick McKee <derrick.mckee@gmail.com> | ||
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Message-id: 20200728195706.11087-1-richard.henderson@linaro.org | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | [PMM: added comment about the divergence from the pseudocode] | ||
20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
21 | --- | 11 | --- |
22 | target/arm/pauth_helper.c | 6 +++++- | 12 | contrib/elf2dmp/pe.h | 100 ++++++++++++++++++------------------ |
23 | tests/tcg/aarch64/pauth-5.c | 33 +++++++++++++++++++++++++++++++ | 13 | contrib/elf2dmp/addrspace.c | 1 + |
24 | tests/tcg/aarch64/Makefile.target | 2 +- | 14 | contrib/elf2dmp/main.c | 9 ++-- |
25 | 3 files changed, 39 insertions(+), 2 deletions(-) | 15 | 3 files changed, 57 insertions(+), 53 deletions(-) |
26 | create mode 100644 tests/tcg/aarch64/pauth-5.c | ||
27 | 16 | ||
28 | diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c | 17 | diff --git a/contrib/elf2dmp/pe.h b/contrib/elf2dmp/pe.h |
29 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/target/arm/pauth_helper.c | 19 | --- a/contrib/elf2dmp/pe.h |
31 | +++ b/target/arm/pauth_helper.c | 20 | +++ b/contrib/elf2dmp/pe.h |
32 | @@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, | 21 | @@ -XXX,XX +XXX,XX @@ typedef struct IMAGE_DOS_HEADER { |
33 | */ | 22 | } __attribute__ ((packed)) IMAGE_DOS_HEADER; |
34 | test = sextract64(ptr, bot_bit, top_bit - bot_bit); | 23 | |
35 | if (test != 0 && test != -1) { | 24 | typedef struct IMAGE_FILE_HEADER { |
36 | - pac ^= MAKE_64BIT_MASK(top_bit - 1, 1); | 25 | - uint16_t Machine; |
37 | + /* | 26 | - uint16_t NumberOfSections; |
38 | + * Note that our top_bit is one greater than the pseudocode's | 27 | - uint32_t TimeDateStamp; |
39 | + * version, hence "- 2" here. | 28 | - uint32_t PointerToSymbolTable; |
40 | + */ | 29 | - uint32_t NumberOfSymbols; |
41 | + pac ^= MAKE_64BIT_MASK(top_bit - 2, 1); | 30 | - uint16_t SizeOfOptionalHeader; |
31 | - uint16_t Characteristics; | ||
32 | + uint16_t Machine; | ||
33 | + uint16_t NumberOfSections; | ||
34 | + uint32_t TimeDateStamp; | ||
35 | + uint32_t PointerToSymbolTable; | ||
36 | + uint32_t NumberOfSymbols; | ||
37 | + uint16_t SizeOfOptionalHeader; | ||
38 | + uint16_t Characteristics; | ||
39 | } __attribute__ ((packed)) IMAGE_FILE_HEADER; | ||
40 | |||
41 | typedef struct IMAGE_DATA_DIRECTORY { | ||
42 | - uint32_t VirtualAddress; | ||
43 | - uint32_t Size; | ||
44 | + uint32_t VirtualAddress; | ||
45 | + uint32_t Size; | ||
46 | } __attribute__ ((packed)) IMAGE_DATA_DIRECTORY; | ||
47 | |||
48 | #define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16 | ||
49 | |||
50 | typedef struct IMAGE_OPTIONAL_HEADER64 { | ||
51 | - uint16_t Magic; /* 0x20b */ | ||
52 | - uint8_t MajorLinkerVersion; | ||
53 | - uint8_t MinorLinkerVersion; | ||
54 | - uint32_t SizeOfCode; | ||
55 | - uint32_t SizeOfInitializedData; | ||
56 | - uint32_t SizeOfUninitializedData; | ||
57 | - uint32_t AddressOfEntryPoint; | ||
58 | - uint32_t BaseOfCode; | ||
59 | - uint64_t ImageBase; | ||
60 | - uint32_t SectionAlignment; | ||
61 | - uint32_t FileAlignment; | ||
62 | - uint16_t MajorOperatingSystemVersion; | ||
63 | - uint16_t MinorOperatingSystemVersion; | ||
64 | - uint16_t MajorImageVersion; | ||
65 | - uint16_t MinorImageVersion; | ||
66 | - uint16_t MajorSubsystemVersion; | ||
67 | - uint16_t MinorSubsystemVersion; | ||
68 | - uint32_t Win32VersionValue; | ||
69 | - uint32_t SizeOfImage; | ||
70 | - uint32_t SizeOfHeaders; | ||
71 | - uint32_t CheckSum; | ||
72 | - uint16_t Subsystem; | ||
73 | - uint16_t DllCharacteristics; | ||
74 | - uint64_t SizeOfStackReserve; | ||
75 | - uint64_t SizeOfStackCommit; | ||
76 | - uint64_t SizeOfHeapReserve; | ||
77 | - uint64_t SizeOfHeapCommit; | ||
78 | - uint32_t LoaderFlags; | ||
79 | - uint32_t NumberOfRvaAndSizes; | ||
80 | - IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; | ||
81 | + uint16_t Magic; /* 0x20b */ | ||
82 | + uint8_t MajorLinkerVersion; | ||
83 | + uint8_t MinorLinkerVersion; | ||
84 | + uint32_t SizeOfCode; | ||
85 | + uint32_t SizeOfInitializedData; | ||
86 | + uint32_t SizeOfUninitializedData; | ||
87 | + uint32_t AddressOfEntryPoint; | ||
88 | + uint32_t BaseOfCode; | ||
89 | + uint64_t ImageBase; | ||
90 | + uint32_t SectionAlignment; | ||
91 | + uint32_t FileAlignment; | ||
92 | + uint16_t MajorOperatingSystemVersion; | ||
93 | + uint16_t MinorOperatingSystemVersion; | ||
94 | + uint16_t MajorImageVersion; | ||
95 | + uint16_t MinorImageVersion; | ||
96 | + uint16_t MajorSubsystemVersion; | ||
97 | + uint16_t MinorSubsystemVersion; | ||
98 | + uint32_t Win32VersionValue; | ||
99 | + uint32_t SizeOfImage; | ||
100 | + uint32_t SizeOfHeaders; | ||
101 | + uint32_t CheckSum; | ||
102 | + uint16_t Subsystem; | ||
103 | + uint16_t DllCharacteristics; | ||
104 | + uint64_t SizeOfStackReserve; | ||
105 | + uint64_t SizeOfStackCommit; | ||
106 | + uint64_t SizeOfHeapReserve; | ||
107 | + uint64_t SizeOfHeapCommit; | ||
108 | + uint32_t LoaderFlags; | ||
109 | + uint32_t NumberOfRvaAndSizes; | ||
110 | + IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; | ||
111 | } __attribute__ ((packed)) IMAGE_OPTIONAL_HEADER64; | ||
112 | |||
113 | typedef struct IMAGE_NT_HEADERS64 { | ||
114 | - uint32_t Signature; | ||
115 | - IMAGE_FILE_HEADER FileHeader; | ||
116 | - IMAGE_OPTIONAL_HEADER64 OptionalHeader; | ||
117 | + uint32_t Signature; | ||
118 | + IMAGE_FILE_HEADER FileHeader; | ||
119 | + IMAGE_OPTIONAL_HEADER64 OptionalHeader; | ||
120 | } __attribute__ ((packed)) IMAGE_NT_HEADERS64; | ||
121 | |||
122 | typedef struct IMAGE_DEBUG_DIRECTORY { | ||
123 | - uint32_t Characteristics; | ||
124 | - uint32_t TimeDateStamp; | ||
125 | - uint16_t MajorVersion; | ||
126 | - uint16_t MinorVersion; | ||
127 | - uint32_t Type; | ||
128 | - uint32_t SizeOfData; | ||
129 | - uint32_t AddressOfRawData; | ||
130 | - uint32_t PointerToRawData; | ||
131 | + uint32_t Characteristics; | ||
132 | + uint32_t TimeDateStamp; | ||
133 | + uint16_t MajorVersion; | ||
134 | + uint16_t MinorVersion; | ||
135 | + uint32_t Type; | ||
136 | + uint32_t SizeOfData; | ||
137 | + uint32_t AddressOfRawData; | ||
138 | + uint32_t PointerToRawData; | ||
139 | } __attribute__ ((packed)) IMAGE_DEBUG_DIRECTORY; | ||
140 | |||
141 | #define IMAGE_DEBUG_TYPE_CODEVIEW 2 | ||
142 | diff --git a/contrib/elf2dmp/addrspace.c b/contrib/elf2dmp/addrspace.c | ||
143 | index XXXXXXX..XXXXXXX 100644 | ||
144 | --- a/contrib/elf2dmp/addrspace.c | ||
145 | +++ b/contrib/elf2dmp/addrspace.c | ||
146 | @@ -XXX,XX +XXX,XX @@ | ||
147 | static struct pa_block *pa_space_find_block(struct pa_space *ps, uint64_t pa) | ||
148 | { | ||
149 | size_t i; | ||
150 | + | ||
151 | for (i = 0; i < ps->block_nr; i++) { | ||
152 | if (ps->block[i].paddr <= pa && | ||
153 | pa <= ps->block[i].paddr + ps->block[i].size) { | ||
154 | diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c | ||
155 | index XXXXXXX..XXXXXXX 100644 | ||
156 | --- a/contrib/elf2dmp/main.c | ||
157 | +++ b/contrib/elf2dmp/main.c | ||
158 | @@ -XXX,XX +XXX,XX @@ static int fill_header(WinDumpHeader64 *hdr, struct pa_space *ps, | ||
159 | }; | ||
160 | |||
161 | for (i = 0; i < ps->block_nr; i++) { | ||
162 | - h.PhysicalMemoryBlock.NumberOfPages += ps->block[i].size / ELF2DMP_PAGE_SIZE; | ||
163 | + h.PhysicalMemoryBlock.NumberOfPages += | ||
164 | + ps->block[i].size / ELF2DMP_PAGE_SIZE; | ||
165 | h.PhysicalMemoryBlock.Run[i] = (WinDumpPhyMemRun64) { | ||
166 | .BasePage = ps->block[i].paddr / ELF2DMP_PAGE_SIZE, | ||
167 | .PageCount = ps->block[i].size / ELF2DMP_PAGE_SIZE, | ||
168 | }; | ||
42 | } | 169 | } |
43 | 170 | ||
44 | /* | 171 | - h.RequiredDumpSpace += h.PhysicalMemoryBlock.NumberOfPages << ELF2DMP_PAGE_BITS; |
45 | diff --git a/tests/tcg/aarch64/pauth-5.c b/tests/tcg/aarch64/pauth-5.c | 172 | + h.RequiredDumpSpace += |
46 | new file mode 100644 | 173 | + h.PhysicalMemoryBlock.NumberOfPages << ELF2DMP_PAGE_BITS; |
47 | index XXXXXXX..XXXXXXX | 174 | |
48 | --- /dev/null | 175 | *hdr = h; |
49 | +++ b/tests/tcg/aarch64/pauth-5.c | 176 | |
50 | @@ -XXX,XX +XXX,XX @@ | 177 | @@ -XXX,XX +XXX,XX @@ static int fill_header(WinDumpHeader64 *hdr, struct pa_space *ps, |
51 | +#include <assert.h> | 178 | static int fill_context(KDDEBUGGER_DATA64 *kdbg, |
179 | struct va_space *vs, QEMU_Elf *qe) | ||
180 | { | ||
181 | - int i; | ||
182 | + int i; | ||
52 | + | 183 | + |
53 | +static int x; | 184 | for (i = 0; i < qe->state_nr; i++) { |
54 | + | 185 | uint64_t Prcb; |
55 | +int main() | 186 | uint64_t Context; |
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 | -- | 187 | -- |
98 | 2.20.1 | 188 | 2.34.1 |
99 | |||
100 | diff view generated by jsdifflib |
1 | The imx_epit device has a software-controllable reset triggered by | 1 | From: Viktor Prutyanov <viktor@daynix.com> |
---|---|---|---|
2 | setting the SWR bit in the CR register. An error in commit cc2722ec83ad9 | ||
3 | means that we will end up assert()ing if the guest does this, because | ||
4 | the code in imx_epit_write() starts ptimer transactions, and then | ||
5 | imx_epit_reset() also starts ptimer transactions, triggering | ||
6 | "ptimer_transaction_begin: Assertion `!s->in_transaction' failed". | ||
7 | 2 | ||
8 | The cleanest way to avoid this double-transaction is to move the | 3 | Move out PE directory search functionality to be reused not only |
9 | start-transaction for the CR write handling down below the check of | 4 | for Debug Directory processing but for arbitrary PE directory. |
10 | the SWR bit. | ||
11 | 5 | ||
12 | Fixes: https://bugs.launchpad.net/qemu/+bug/1880424 | 6 | Signed-off-by: Viktor Prutyanov <viktor@daynix.com> |
13 | Fixes: cc2722ec83ad944505fe | 7 | Reviewed-by: Annie Li <annie.li@oracle.com> |
8 | Message-id: 20230222211246.883679-3-viktor@daynix.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
16 | Message-id: 20200727154550.3409-1-peter.maydell@linaro.org | ||
17 | --- | 10 | --- |
18 | hw/timer/imx_epit.c | 13 ++++++++++--- | 11 | contrib/elf2dmp/main.c | 71 +++++++++++++++++++++++++----------------- |
19 | 1 file changed, 10 insertions(+), 3 deletions(-) | 12 | 1 file changed, 42 insertions(+), 29 deletions(-) |
20 | 13 | ||
21 | diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c | 14 | diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c |
22 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/hw/timer/imx_epit.c | 16 | --- a/contrib/elf2dmp/main.c |
24 | +++ b/hw/timer/imx_epit.c | 17 | +++ b/contrib/elf2dmp/main.c |
25 | @@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value, | 18 | @@ -XXX,XX +XXX,XX @@ static int fill_context(KDDEBUGGER_DATA64 *kdbg, |
26 | 19 | return 0; | |
27 | switch (offset >> 2) { | 20 | } |
28 | case 0: /* CR */ | 21 | |
29 | - ptimer_transaction_begin(s->timer_cmp); | 22 | +static int pe_get_data_dir_entry(uint64_t base, void *start_addr, int idx, |
30 | - ptimer_transaction_begin(s->timer_reload); | 23 | + void *entry, size_t size, struct va_space *vs) |
31 | 24 | +{ | |
32 | oldcr = s->cr; | 25 | + const char e_magic[2] = "MZ"; |
33 | s->cr = value & 0x03ffffff; | 26 | + const char Signature[4] = "PE\0\0"; |
34 | if (s->cr & CR_SWR) { | 27 | + IMAGE_DOS_HEADER *dos_hdr = start_addr; |
35 | /* handle the reset */ | 28 | + IMAGE_NT_HEADERS64 nt_hdrs; |
36 | imx_epit_reset(DEVICE(s)); | 29 | + IMAGE_FILE_HEADER *file_hdr = &nt_hdrs.FileHeader; |
37 | - } else { | 30 | + IMAGE_OPTIONAL_HEADER64 *opt_hdr = &nt_hdrs.OptionalHeader; |
38 | + /* | 31 | + IMAGE_DATA_DIRECTORY *data_dir = nt_hdrs.OptionalHeader.DataDirectory; |
39 | + * TODO: could we 'break' here? following operations appear | ||
40 | + * to duplicate the work imx_epit_reset() already did. | ||
41 | + */ | ||
42 | + } | ||
43 | + | 32 | + |
44 | + ptimer_transaction_begin(s->timer_cmp); | 33 | + QEMU_BUILD_BUG_ON(sizeof(*dos_hdr) >= ELF2DMP_PAGE_SIZE); |
45 | + ptimer_transaction_begin(s->timer_reload); | ||
46 | + | 34 | + |
47 | + if (!(s->cr & CR_SWR)) { | 35 | + if (memcmp(&dos_hdr->e_magic, e_magic, sizeof(e_magic))) { |
48 | imx_epit_set_freq(s); | 36 | + return 1; |
49 | } | 37 | + } |
38 | + | ||
39 | + if (va_space_rw(vs, base + dos_hdr->e_lfanew, | ||
40 | + &nt_hdrs, sizeof(nt_hdrs), 0)) { | ||
41 | + return 1; | ||
42 | + } | ||
43 | + | ||
44 | + if (memcmp(&nt_hdrs.Signature, Signature, sizeof(Signature)) || | ||
45 | + file_hdr->Machine != 0x8664 || opt_hdr->Magic != 0x020b) { | ||
46 | + return 1; | ||
47 | + } | ||
48 | + | ||
49 | + if (va_space_rw(vs, | ||
50 | + base + data_dir[idx].VirtualAddress, | ||
51 | + entry, size, 0)) { | ||
52 | + return 1; | ||
53 | + } | ||
54 | + | ||
55 | + printf("Data directory entry #%d: RVA = 0x%08"PRIx32"\n", idx, | ||
56 | + (uint32_t)data_dir[idx].VirtualAddress); | ||
57 | + | ||
58 | + return 0; | ||
59 | +} | ||
60 | + | ||
61 | static int write_dump(struct pa_space *ps, | ||
62 | WinDumpHeader64 *hdr, const char *name) | ||
63 | { | ||
64 | @@ -XXX,XX +XXX,XX @@ static int write_dump(struct pa_space *ps, | ||
65 | static int pe_get_pdb_symstore_hash(uint64_t base, void *start_addr, | ||
66 | char *hash, struct va_space *vs) | ||
67 | { | ||
68 | - const char e_magic[2] = "MZ"; | ||
69 | - const char Signature[4] = "PE\0\0"; | ||
70 | const char sign_rsds[4] = "RSDS"; | ||
71 | - IMAGE_DOS_HEADER *dos_hdr = start_addr; | ||
72 | - IMAGE_NT_HEADERS64 nt_hdrs; | ||
73 | - IMAGE_FILE_HEADER *file_hdr = &nt_hdrs.FileHeader; | ||
74 | - IMAGE_OPTIONAL_HEADER64 *opt_hdr = &nt_hdrs.OptionalHeader; | ||
75 | - IMAGE_DATA_DIRECTORY *data_dir = nt_hdrs.OptionalHeader.DataDirectory; | ||
76 | IMAGE_DEBUG_DIRECTORY debug_dir; | ||
77 | OMFSignatureRSDS rsds; | ||
78 | char *pdb_name; | ||
79 | size_t pdb_name_sz; | ||
80 | size_t i; | ||
81 | |||
82 | - QEMU_BUILD_BUG_ON(sizeof(*dos_hdr) >= ELF2DMP_PAGE_SIZE); | ||
83 | - | ||
84 | - if (memcmp(&dos_hdr->e_magic, e_magic, sizeof(e_magic))) { | ||
85 | - return 1; | ||
86 | - } | ||
87 | - | ||
88 | - if (va_space_rw(vs, base + dos_hdr->e_lfanew, | ||
89 | - &nt_hdrs, sizeof(nt_hdrs), 0)) { | ||
90 | - return 1; | ||
91 | - } | ||
92 | - | ||
93 | - if (memcmp(&nt_hdrs.Signature, Signature, sizeof(Signature)) || | ||
94 | - file_hdr->Machine != 0x8664 || opt_hdr->Magic != 0x020b) { | ||
95 | - return 1; | ||
96 | - } | ||
97 | - | ||
98 | - printf("Debug Directory RVA = 0x%08"PRIx32"\n", | ||
99 | - (uint32_t)data_dir[IMAGE_FILE_DEBUG_DIRECTORY].VirtualAddress); | ||
100 | - | ||
101 | - if (va_space_rw(vs, | ||
102 | - base + data_dir[IMAGE_FILE_DEBUG_DIRECTORY].VirtualAddress, | ||
103 | - &debug_dir, sizeof(debug_dir), 0)) { | ||
104 | + if (pe_get_data_dir_entry(base, start_addr, IMAGE_FILE_DEBUG_DIRECTORY, | ||
105 | + &debug_dir, sizeof(debug_dir), vs)) { | ||
106 | + eprintf("Failed to get Debug Directory\n"); | ||
107 | return 1; | ||
108 | } | ||
50 | 109 | ||
51 | -- | 110 | -- |
52 | 2.20.1 | 111 | 2.34.1 |
53 | |||
54 | diff view generated by jsdifflib |
1 | The nrf51 SoC model wasn't setting the system_clock_scale | 1 | From: Viktor Prutyanov <viktor@daynix.com> |
---|---|---|---|
2 | global.which meant that if guest code used the systick timer in "use | ||
3 | the processor clock" mode it would hang because time never advances. | ||
4 | 2 | ||
5 | Set the global to match the documented CPU clock speed for this SoC. | 3 | Since its inception elf2dmp has checked MZ signatures within an |
4 | address space above IDT[0] interrupt vector and took first PE image | ||
5 | found as Windows Kernel. | ||
6 | But in Windows Server 2022 memory dump this address space range is | ||
7 | full of invalid PE fragments and the tool must check that PE image | ||
8 | is 'ntoskrnl.exe' actually. | ||
9 | So, introduce additional validation by checking image name from | ||
10 | Export Directory against 'ntoskrnl.exe'. | ||
6 | 11 | ||
7 | This SoC in fact doesn't have a SysTick timer (which is the only thing | 12 | Signed-off-by: Viktor Prutyanov <viktor@daynix.com> |
8 | currently that cares about the system_clock_scale), because it's | 13 | Tested-by: Yuri Benditovich <yuri.benditovich@daynix.com> |
9 | a configurable option in the Cortex-M0. However our Cortex-M0 and | 14 | Reviewed-by: Annie Li <annie.li@oracle.com> |
10 | thus our nrf51 and our micro:bit board do provide a SysTick, so | 15 | Message-id: 20230222211246.883679-4-viktor@daynix.com |
11 | we ought to provide a functional one rather than a broken one. | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | --- | ||
18 | contrib/elf2dmp/pe.h | 15 +++++++++++++++ | ||
19 | contrib/elf2dmp/main.c | 28 ++++++++++++++++++++++++++-- | ||
20 | 2 files changed, 41 insertions(+), 2 deletions(-) | ||
12 | 21 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 22 | diff --git a/contrib/elf2dmp/pe.h b/contrib/elf2dmp/pe.h |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
15 | Message-id: 20200727193458.31250-1-peter.maydell@linaro.org | ||
16 | --- | ||
17 | hw/arm/nrf51_soc.c | 5 +++++ | ||
18 | 1 file changed, 5 insertions(+) | ||
19 | |||
20 | diff --git a/hw/arm/nrf51_soc.c b/hw/arm/nrf51_soc.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/nrf51_soc.c | 24 | --- a/contrib/elf2dmp/pe.h |
23 | +++ b/hw/arm/nrf51_soc.c | 25 | +++ b/contrib/elf2dmp/pe.h |
26 | @@ -XXX,XX +XXX,XX @@ typedef struct IMAGE_NT_HEADERS64 { | ||
27 | IMAGE_OPTIONAL_HEADER64 OptionalHeader; | ||
28 | } __attribute__ ((packed)) IMAGE_NT_HEADERS64; | ||
29 | |||
30 | +typedef struct IMAGE_EXPORT_DIRECTORY { | ||
31 | + uint32_t Characteristics; | ||
32 | + uint32_t TimeDateStamp; | ||
33 | + uint16_t MajorVersion; | ||
34 | + uint16_t MinorVersion; | ||
35 | + uint32_t Name; | ||
36 | + uint32_t Base; | ||
37 | + uint32_t NumberOfFunctions; | ||
38 | + uint32_t NumberOfNames; | ||
39 | + uint32_t AddressOfFunctions; | ||
40 | + uint32_t AddressOfNames; | ||
41 | + uint32_t AddressOfNameOrdinals; | ||
42 | +} __attribute__ ((packed)) IMAGE_EXPORT_DIRECTORY; | ||
43 | + | ||
44 | typedef struct IMAGE_DEBUG_DIRECTORY { | ||
45 | uint32_t Characteristics; | ||
46 | uint32_t TimeDateStamp; | ||
47 | @@ -XXX,XX +XXX,XX @@ typedef struct IMAGE_DEBUG_DIRECTORY { | ||
48 | #define IMAGE_DEBUG_TYPE_CODEVIEW 2 | ||
49 | #endif | ||
50 | |||
51 | +#define IMAGE_FILE_EXPORT_DIRECTORY 0 | ||
52 | #define IMAGE_FILE_DEBUG_DIRECTORY 6 | ||
53 | |||
54 | typedef struct guid_t { | ||
55 | diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c | ||
56 | index XXXXXXX..XXXXXXX 100644 | ||
57 | --- a/contrib/elf2dmp/main.c | ||
58 | +++ b/contrib/elf2dmp/main.c | ||
24 | @@ -XXX,XX +XXX,XX @@ | 59 | @@ -XXX,XX +XXX,XX @@ |
25 | 60 | ||
26 | #define BASE_TO_IRQ(base) ((base >> 12) & 0x1F) | 61 | #define SYM_URL_BASE "https://msdl.microsoft.com/download/symbols/" |
27 | 62 | #define PDB_NAME "ntkrnlmp.pdb" | |
28 | +/* HCLK (the main CPU clock) on this SoC is always 16MHz */ | 63 | +#define PE_NAME "ntoskrnl.exe" |
29 | +#define HCLK_FRQ 16000000 | 64 | |
65 | #define INITIAL_MXCSR 0x1f80 | ||
66 | |||
67 | @@ -XXX,XX +XXX,XX @@ static int write_dump(struct pa_space *ps, | ||
68 | return fclose(dmp_file); | ||
69 | } | ||
70 | |||
71 | +static bool pe_check_export_name(uint64_t base, void *start_addr, | ||
72 | + struct va_space *vs) | ||
73 | +{ | ||
74 | + IMAGE_EXPORT_DIRECTORY export_dir; | ||
75 | + const char *pe_name; | ||
30 | + | 76 | + |
31 | static uint64_t clock_read(void *opaque, hwaddr addr, unsigned int size) | 77 | + if (pe_get_data_dir_entry(base, start_addr, IMAGE_FILE_EXPORT_DIRECTORY, |
78 | + &export_dir, sizeof(export_dir), vs)) { | ||
79 | + return false; | ||
80 | + } | ||
81 | + | ||
82 | + pe_name = va_space_resolve(vs, base + export_dir.Name); | ||
83 | + if (!pe_name) { | ||
84 | + return false; | ||
85 | + } | ||
86 | + | ||
87 | + return !strcmp(pe_name, PE_NAME); | ||
88 | +} | ||
89 | + | ||
90 | static int pe_get_pdb_symstore_hash(uint64_t base, void *start_addr, | ||
91 | char *hash, struct va_space *vs) | ||
32 | { | 92 | { |
33 | qemu_log_mask(LOG_UNIMP, "%s: 0x%" HWADDR_PRIx " [%u]\n", | 93 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) |
34 | @@ -XXX,XX +XXX,XX @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp) | 94 | uint64_t KdDebuggerDataBlock; |
35 | return; | 95 | KDDEBUGGER_DATA64 *kdbg; |
96 | uint64_t KdVersionBlock; | ||
97 | + bool kernel_found = false; | ||
98 | |||
99 | if (argc != 3) { | ||
100 | eprintf("usage:\n\t%s elf_file dmp_file\n", argv[0]); | ||
101 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) | ||
102 | } | ||
103 | |||
104 | if (*(uint16_t *)nt_start_addr == 0x5a4d) { /* MZ */ | ||
105 | - break; | ||
106 | + if (pe_check_export_name(KernBase, nt_start_addr, &vs)) { | ||
107 | + kernel_found = true; | ||
108 | + break; | ||
109 | + } | ||
110 | } | ||
36 | } | 111 | } |
37 | 112 | ||
38 | + system_clock_scale = NANOSECONDS_PER_SECOND / HCLK_FRQ; | 113 | - if (!nt_start_addr) { |
39 | + | 114 | + if (!kernel_found) { |
40 | object_property_set_link(OBJECT(&s->cpu), "memory", OBJECT(&s->container), | 115 | eprintf("Failed to find NT kernel image\n"); |
41 | &error_abort); | 116 | err = 1; |
42 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->cpu), errp)) { | 117 | goto out_ps; |
43 | -- | 118 | -- |
44 | 2.20.1 | 119 | 2.34.1 |
45 | |||
46 | diff view generated by jsdifflib |
1 | From: Kaige Li <likaige@loongson.cn> | 1 | From: Guenter Roeck <linux@roeck-us.net> |
---|---|---|---|
2 | 2 | ||
3 | GCC version 4.9.4 isn't clever enough to figure out that all | 3 | The i.MX USB Phy driver does not check register ranges, resulting in out of |
4 | execution paths in disas_ldst() that use 'fn' will have initialized | 4 | bounds accesses if an attempt is made to access non-existing PHY registers. |
5 | it first, and so it warns: | 5 | Add range check and conditionally report bad accesses to fix the problem. |
6 | 6 | ||
7 | /home/LiKaige/qemu/target/arm/translate-a64.c: In function ‘disas_ldst’: | 7 | While at it, also conditionally log attempted writes to non-existing or |
8 | /home/LiKaige/qemu/target/arm/translate-a64.c:3392:5: error: ‘fn’ may be used uninitialized in this function [-Werror=maybe-uninitialized] | 8 | read-only registers. |
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 | 9 | ||
15 | Make it happy by initializing the variable to NULL. | 10 | Reported-by: Qiang Liu <cyruscyliu@gmail.com> |
16 | 11 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | |
17 | Signed-off-by: Kaige Li <likaige@loongson.cn> | 12 | Tested-by: Qiang Liu <cyruscyliu@gmail.com> |
18 | Message-id: 1596110248-7366-2-git-send-email-likaige@loongson.cn | 13 | Message-id: 20230316234926.208874-1-linux@roeck-us.net |
14 | Link: https://gitlab.com/qemu-project/qemu/-/issues/1408 | ||
15 | Fixes: 0701a5efa015 ("hw/usb: Add basic i.MX USB Phy support") | ||
16 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
19 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 17 | 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> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | --- | 19 | --- |
23 | target/arm/translate-a64.c | 2 +- | 20 | hw/usb/imx-usb-phy.c | 19 +++++++++++++++++-- |
24 | 1 file changed, 1 insertion(+), 1 deletion(-) | 21 | 1 file changed, 17 insertions(+), 2 deletions(-) |
25 | 22 | ||
26 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 23 | diff --git a/hw/usb/imx-usb-phy.c b/hw/usb/imx-usb-phy.c |
27 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/target/arm/translate-a64.c | 25 | --- a/hw/usb/imx-usb-phy.c |
29 | +++ b/target/arm/translate-a64.c | 26 | +++ b/hw/usb/imx-usb-phy.c |
30 | @@ -XXX,XX +XXX,XX @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, | 27 | @@ -XXX,XX +XXX,XX @@ |
31 | bool r = extract32(insn, 22, 1); | 28 | #include "qemu/osdep.h" |
32 | bool a = extract32(insn, 23, 1); | 29 | #include "hw/usb/imx-usb-phy.h" |
33 | TCGv_i64 tcg_rs, clean_addr; | 30 | #include "migration/vmstate.h" |
34 | - AtomicThreeOpFn *fn; | 31 | +#include "qemu/log.h" |
35 | + AtomicThreeOpFn *fn = NULL; | 32 | #include "qemu/module.h" |
36 | 33 | ||
37 | if (is_vector || !dc_isar_feature(aa64_atomics, s)) { | 34 | static const VMStateDescription vmstate_imx_usbphy = { |
38 | unallocated_encoding(s); | 35 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx_usbphy_read(void *opaque, hwaddr offset, unsigned size) |
36 | value = s->usbphy[index - 3]; | ||
37 | break; | ||
38 | default: | ||
39 | - value = s->usbphy[index]; | ||
40 | + if (index < USBPHY_MAX) { | ||
41 | + value = s->usbphy[index]; | ||
42 | + } else { | ||
43 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
44 | + "%s: Read from non-existing USB PHY register 0x%" | ||
45 | + HWADDR_PRIx "\n", | ||
46 | + __func__, offset); | ||
47 | + value = 0; | ||
48 | + } | ||
49 | break; | ||
50 | } | ||
51 | return (uint64_t)value; | ||
52 | @@ -XXX,XX +XXX,XX @@ static void imx_usbphy_write(void *opaque, hwaddr offset, uint64_t value, | ||
53 | s->usbphy[index - 3] ^= value; | ||
54 | break; | ||
55 | default: | ||
56 | - /* Other registers are read-only */ | ||
57 | + /* Other registers are read-only or do not exist */ | ||
58 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
59 | + "%s: Write to %s USB PHY register 0x%" | ||
60 | + HWADDR_PRIx "\n", | ||
61 | + __func__, | ||
62 | + index >= USBPHY_MAX ? "non-existing" : "read-only", | ||
63 | + offset); | ||
64 | break; | ||
65 | } | ||
66 | } | ||
39 | -- | 67 | -- |
40 | 2.20.1 | 68 | 2.34.1 |
41 | |||
42 | diff view generated by jsdifflib |
1 | The netduino2 and netduinoplus2 boards forgot to set the system_clock_scale | 1 | The markup for the Arm CPU feature documentation is incorrect, |
---|---|---|---|
2 | global, which meant that if guest code used the systick timer in "use | 2 | and results in the HTML not rendering correctly -- the first |
3 | the processor clock" mode it would hang because time never advances. | 3 | line of each description is rendered in boldface as if it |
4 | were part of the option name. | ||
4 | 5 | ||
5 | Set the global to match the documented CPU clock speed of these boards. | 6 | Reformat to match the styling used in cpu-models-x86.rst.inc. |
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 | 7 | ||
10 | Fixes: https://bugs.launchpad.net/qemu/+bug/1876187 | 8 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1479 |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 10 | Message-id: 20230316105808.1414003-1-peter.maydell@linaro.org |
13 | Message-id: 20200727162617.26227-1-peter.maydell@linaro.org | 11 | Reviewed-by: Cornelia Huck <cohuck@redhat.com> |
14 | --- | 12 | --- |
15 | hw/arm/netduino2.c | 10 ++++++++++ | 13 | docs/system/arm/cpu-features.rst | 68 ++++++++++++++------------------ |
16 | hw/arm/netduinoplus2.c | 10 ++++++++++ | 14 | 1 file changed, 30 insertions(+), 38 deletions(-) |
17 | 2 files changed, 20 insertions(+) | ||
18 | 15 | ||
19 | diff --git a/hw/arm/netduino2.c b/hw/arm/netduino2.c | 16 | diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst |
20 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/arm/netduino2.c | 18 | --- a/docs/system/arm/cpu-features.rst |
22 | +++ b/hw/arm/netduino2.c | 19 | +++ b/docs/system/arm/cpu-features.rst |
23 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ are named with the prefix "kvm-". KVM VCPU features may be probed, |
24 | #include "hw/arm/stm32f205_soc.h" | 21 | enabled, and disabled in the same way as other CPU features. Below is |
25 | #include "hw/arm/boot.h" | 22 | the list of KVM VCPU features and their descriptions. |
26 | 23 | ||
27 | +/* Main SYSCLK frequency in Hz (120MHz) */ | 24 | - kvm-no-adjvtime By default kvm-no-adjvtime is disabled. This |
28 | +#define SYSCLK_FRQ 120000000ULL | 25 | - means that by default the virtual time |
29 | + | 26 | - adjustment is enabled (vtime is not *not* |
30 | static void netduino2_init(MachineState *machine) | 27 | - adjusted). |
31 | { | 28 | +``kvm-no-adjvtime`` |
32 | DeviceState *dev; | 29 | + By default kvm-no-adjvtime is disabled. This means that by default |
33 | 30 | + the virtual time adjustment is enabled (vtime is not *not* adjusted). | |
34 | + /* | 31 | |
35 | + * TODO: ideally we would model the SoC RCC and let it handle | 32 | - When virtual time adjustment is enabled each |
36 | + * system_clock_scale, including its ability to define different | 33 | - time the VM transitions back to running state |
37 | + * possible SYSCLK sources. | 34 | - the VCPU's virtual counter is updated to ensure |
38 | + */ | 35 | - stopped time is not counted. This avoids time |
39 | + system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | 36 | - jumps surprising guest OSes and applications, |
40 | + | 37 | - as long as they use the virtual counter for |
41 | dev = qdev_new(TYPE_STM32F205_SOC); | 38 | - timekeeping. However it has the side effect of |
42 | qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m3")); | 39 | - the virtual and physical counters diverging. |
43 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | 40 | - All timekeeping based on the virtual counter |
44 | diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c | 41 | - will appear to lag behind any timekeeping that |
45 | index XXXXXXX..XXXXXXX 100644 | 42 | - does not subtract VM stopped time. The guest |
46 | --- a/hw/arm/netduinoplus2.c | 43 | - may resynchronize its virtual counter with |
47 | +++ b/hw/arm/netduinoplus2.c | 44 | - other time sources as needed. |
48 | @@ -XXX,XX +XXX,XX @@ | 45 | + When virtual time adjustment is enabled each time the VM transitions |
49 | #include "hw/arm/stm32f405_soc.h" | 46 | + back to running state the VCPU's virtual counter is updated to |
50 | #include "hw/arm/boot.h" | 47 | + ensure stopped time is not counted. This avoids time jumps |
51 | 48 | + surprising guest OSes and applications, as long as they use the | |
52 | +/* Main SYSCLK frequency in Hz (168MHz) */ | 49 | + virtual counter for timekeeping. However it has the side effect of |
53 | +#define SYSCLK_FRQ 168000000ULL | 50 | + the virtual and physical counters diverging. All timekeeping based |
54 | + | 51 | + on the virtual counter will appear to lag behind any timekeeping |
55 | static void netduinoplus2_init(MachineState *machine) | 52 | + that does not subtract VM stopped time. The guest may resynchronize |
56 | { | 53 | + its virtual counter with other time sources as needed. |
57 | DeviceState *dev; | 54 | |
58 | 55 | - Enable kvm-no-adjvtime to disable virtual time | |
59 | + /* | 56 | - adjustment, also restoring the legacy (pre-5.0) |
60 | + * TODO: ideally we would model the SoC RCC and let it handle | 57 | - behavior. |
61 | + * system_clock_scale, including its ability to define different | 58 | + Enable kvm-no-adjvtime to disable virtual time adjustment, also |
62 | + * possible SYSCLK sources. | 59 | + restoring the legacy (pre-5.0) behavior. |
63 | + */ | 60 | |
64 | + system_clock_scale = NANOSECONDS_PER_SECOND / SYSCLK_FRQ; | 61 | - kvm-steal-time Since v5.2, kvm-steal-time is enabled by |
65 | + | 62 | - default when KVM is enabled, the feature is |
66 | dev = qdev_new(TYPE_STM32F405_SOC); | 63 | - supported, and the guest is 64-bit. |
67 | qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4")); | 64 | +``kvm-steal-time`` |
68 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | 65 | + Since v5.2, kvm-steal-time is enabled by default when KVM is |
66 | + enabled, the feature is supported, and the guest is 64-bit. | ||
67 | |||
68 | - When kvm-steal-time is enabled a 64-bit guest | ||
69 | - can account for time its CPUs were not running | ||
70 | - due to the host not scheduling the corresponding | ||
71 | - VCPU threads. The accounting statistics may | ||
72 | - influence the guest scheduler behavior and/or be | ||
73 | - exposed to the guest userspace. | ||
74 | + When kvm-steal-time is enabled a 64-bit guest can account for time | ||
75 | + its CPUs were not running due to the host not scheduling the | ||
76 | + corresponding VCPU threads. The accounting statistics may influence | ||
77 | + the guest scheduler behavior and/or be exposed to the guest | ||
78 | + userspace. | ||
79 | |||
80 | TCG VCPU Features | ||
81 | ================= | ||
82 | @@ -XXX,XX +XXX,XX @@ TCG VCPU Features | ||
83 | TCG VCPU features are CPU features that are specific to TCG. | ||
84 | Below is the list of TCG VCPU features and their descriptions. | ||
85 | |||
86 | - pauth-impdef When ``FEAT_Pauth`` is enabled, either the | ||
87 | - *impdef* (Implementation Defined) algorithm | ||
88 | - is enabled or the *architected* QARMA algorithm | ||
89 | - is enabled. By default the impdef algorithm | ||
90 | - is disabled, and QARMA is enabled. | ||
91 | +``pauth-impdef`` | ||
92 | + When ``FEAT_Pauth`` is enabled, either the *impdef* (Implementation | ||
93 | + Defined) algorithm is enabled or the *architected* QARMA algorithm | ||
94 | + is enabled. By default the impdef algorithm is disabled, and QARMA | ||
95 | + is enabled. | ||
96 | |||
97 | - The architected QARMA algorithm has good | ||
98 | - cryptographic properties, but can be quite slow | ||
99 | - to emulate. The impdef algorithm used by QEMU | ||
100 | - is non-cryptographic but significantly faster. | ||
101 | + The architected QARMA algorithm has good cryptographic properties, | ||
102 | + but can be quite slow to emulate. The impdef algorithm used by QEMU | ||
103 | + is non-cryptographic but significantly faster. | ||
104 | |||
105 | SVE CPU Properties | ||
106 | ================== | ||
69 | -- | 107 | -- |
70 | 2.20.1 | 108 | 2.34.1 |
71 | |||
72 | diff view generated by jsdifflib |
1 | Mostly devices don't need to care whether one of their output | 1 | Unfortunately a bug in older versions of gdb means that they will |
---|---|---|---|
2 | qemu_irq lines is connected, because functions like qemu_set_irq() | 2 | crash if QEMU sends them the aarch64-pauth.xml. This bug is fixed in |
3 | silently do nothing if there is nothing on the other end. However | 3 | gdb commit 1ba3a3222039eb25, and there are plans to backport that to |
4 | sometimes a device might want to implement default behaviour for the | 4 | affected gdb release branches, but since the bug affects gdb 9 |
5 | case where the machine hasn't wired the line up to anywhere. | 5 | through 12 it is very widely deployed (for instance by distros). |
6 | 6 | ||
7 | Provide a function qemu_irq_is_connected() that devices can use for | 7 | It is not currently clear what the best way to deal with this is; it |
8 | this purpose. (The test is trivial but encapsulating it in a | 8 | has been proposed to define a new XML feature name that old gdb will |
9 | function makes it easier to see where we're doing it in case we need | 9 | ignore but newer gdb can handle. Since QEMU's 8.0 release is |
10 | to change the implementation later.) | 10 | imminent and at least one of our CI runners is now falling over this, |
11 | disable the pauth XML for the moment. We can follow up with a more | ||
12 | considered fix either in time for 8.0 or else for the 8.1 release. | ||
11 | 13 | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
14 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
15 | Message-id: 20200728103744.6909-2-peter.maydell@linaro.org | ||
16 | --- | 15 | --- |
17 | include/hw/irq.h | 18 ++++++++++++++++++ | 16 | target/arm/gdbstub.c | 7 +++++++ |
18 | 1 file changed, 18 insertions(+) | 17 | 1 file changed, 7 insertions(+) |
19 | 18 | ||
20 | diff --git a/include/hw/irq.h b/include/hw/irq.h | 19 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c |
21 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/irq.h | 21 | --- a/target/arm/gdbstub.c |
23 | +++ b/include/hw/irq.h | 22 | +++ b/target/arm/gdbstub.c |
24 | @@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); | 23 | @@ -XXX,XX +XXX,XX @@ void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu) |
25 | on an existing vector of qemu_irq. */ | 24 | aarch64_gdb_set_fpu_reg, |
26 | void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n); | 25 | 34, "aarch64-fpu.xml", 0); |
27 | 26 | } | |
28 | +/** | 27 | +#if 0 |
29 | + * qemu_irq_is_connected: Return true if IRQ line is wired up | 28 | + /* |
30 | + * | 29 | + * GDB versions 9 through 12 have a bug which means they will |
31 | + * If a qemu_irq has a device on the other (receiving) end of it, | 30 | + * crash if they see this XML from QEMU; disable it for the 8.0 |
32 | + * return true; otherwise return false. | 31 | + * release, pending a better solution. |
33 | + * | 32 | + */ |
34 | + * Usually device models don't need to care whether the machine model | 33 | if (isar_feature_aa64_pauth(&cpu->isar)) { |
35 | + * has wired up their outbound qemu_irq lines, because functions like | 34 | gdb_register_coprocessor(cs, aarch64_gdb_get_pauth_reg, |
36 | + * qemu_set_irq() silently do nothing if there is nothing on the other | 35 | aarch64_gdb_set_pauth_reg, |
37 | + * end of the line. However occasionally a device model will want to | 36 | 4, "aarch64-pauth.xml", 0); |
38 | + * provide default behaviour if its output is left floating, and | 37 | } |
39 | + * it can use this function to identify when that is the case. | 38 | +#endif |
40 | + */ | ||
41 | +static inline bool qemu_irq_is_connected(qemu_irq irq) | ||
42 | +{ | ||
43 | + return irq != NULL; | ||
44 | +} | ||
45 | + | ||
46 | #endif | 39 | #endif |
40 | } else { | ||
41 | if (arm_feature(env, ARM_FEATURE_NEON)) { | ||
47 | -- | 42 | -- |
48 | 2.20.1 | 43 | 2.34.1 |
49 | |||
50 | diff view generated by jsdifflib |