1 | Arm patch queue -- these are all bug fix patches but we might | 1 | Hi; here's a queue of arm patches (plus a few elf2dmp changes); |
---|---|---|---|
2 | as well put them in to rc0... | 2 | mostly these are minor cleanups and bugfixes. |
3 | 3 | ||
4 | thanks | 4 | thanks |
5 | -- PMM | 5 | -- PMM |
6 | 6 | ||
7 | The following changes since commit 2c8cfc0b52b5a4d123c26c0b5fdf941be24805be: | 7 | The following changes since commit deaca3fd30d3a8829160f8d3705d65ad83176800: |
8 | 8 | ||
9 | Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2018-03-19 11:44:26 +0000) | 9 | Merge tag 'pull-vfio-20231018' of https://github.com/legoater/qemu into staging (2023-10-18 06:21:15 -0400) |
10 | 10 | ||
11 | are available in the Git repository at: | 11 | are available in the Git repository at: |
12 | 12 | ||
13 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180319 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20231019 |
14 | 14 | ||
15 | for you to fetch changes up to ff72cb6b46b95bb530787add5277c211af3d31c6: | 15 | for you to fetch changes up to 2a052b4ee01b3c413cef2ef49cb780cde17d4ba1: |
16 | 16 | ||
17 | hw/arm/raspi: Provide spin-loop code for AArch64 CPUs (2018-03-19 18:23:24 +0000) | 17 | contrib/elf2dmp: Use g_malloc(), g_new() and g_free() (2023-10-19 14:32:13 +0100) |
18 | 18 | ||
19 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
20 | target-arm queue: | 20 | target-arm queue: |
21 | * fsl-imx6: Fix incorrect Ethernet interrupt defines | 21 | * hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder |
22 | * dump: Update correct kdump phys_base field for AArch64 | 22 | * hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot' |
23 | * char: i.MX: Add support for "TX complete" interrupt | 23 | * xlnx devices: remove deprecated device reset |
24 | * bcm2836/raspi: Fix various bugs resulting in panics trying | 24 | * xlnx-bbram: hw/nvram: Use dot in device type name |
25 | to boot a Debian Linux kernel on raspi3 | 25 | * elf2dmp: fix coverity issues |
26 | * elf2dmp: convert to g_malloc, g_new and g_free | ||
27 | * target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0 | ||
28 | * hw/arm: refactor virt PPI logic | ||
29 | * arm/kvm: convert to kvm_set_one_reg, kvm_get_one_reg | ||
30 | * target/arm: Permit T32 LDM with single register | ||
31 | * smmuv3: Advertise SMMUv3.1-XNX | ||
32 | * target/arm: Implement FEAT_HPMN0 | ||
33 | * Remove some unnecessary include lines | ||
34 | * target/arm/arm-powerctl: Correctly init CPUs when powered on to lower EL | ||
35 | * hw/timer/npcm7xx_timer: Prevent timer from counting down past zero | ||
26 | 36 | ||
27 | ---------------------------------------------------------------- | 37 | ---------------------------------------------------------------- |
28 | Andrey Smirnov (2): | 38 | Chris Rauer (1): |
29 | char: i.MX: Simplify imx_update() | 39 | hw/timer/npcm7xx_timer: Prevent timer from counting down past zero |
30 | char: i.MX: Add support for "TX complete" interrupt | ||
31 | 40 | ||
32 | Guenter Roeck (1): | 41 | Cornelia Huck (2): |
33 | fsl-imx6: Swap Ethernet interrupt defines | 42 | arm/kvm: convert to kvm_set_one_reg |
43 | arm/kvm: convert to kvm_get_one_reg | ||
34 | 44 | ||
35 | Peter Maydell (9): | 45 | Leif Lindholm (3): |
36 | hw/arm/raspi: Don't do board-setup or secure-boot for raspi3 | 46 | {include/}hw/arm: refactor virt PPI logic |
37 | hw/arm/boot: assert that secure_boot and secure_board_setup are false for AArch64 | 47 | include/hw/arm: move BSA definitions to bsa.h |
38 | hw/arm/boot: If booting a kernel in EL2, set SCR_EL3.HCE | 48 | hw/arm/sbsa-ref: use bsa.h for PPI definitions |
39 | hw/arm/bcm2386: Fix parent type of bcm2386 | ||
40 | hw/arm/bcm2836: Rename bcm2836 type/struct to bcm283x | ||
41 | hw/arm/bcm2836: Create proper bcm2837 device | ||
42 | hw/arm/bcm2836: Use correct affinity values for BCM2837 | ||
43 | hw/arm/bcm2836: Hardcode correct CPU type | ||
44 | hw/arm/raspi: Provide spin-loop code for AArch64 CPUs | ||
45 | 49 | ||
46 | Wei Huang (1): | 50 | Michal Orzel (1): |
47 | dump: Update correct kdump phys_base field for AArch64 | 51 | target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0 |
48 | 52 | ||
49 | include/hw/arm/bcm2836.h | 31 +++++++++++++--- | 53 | Peter Maydell (8): |
50 | include/hw/arm/fsl-imx6.h | 4 +- | 54 | target/arm: Permit T32 LDM with single register |
51 | include/hw/char/imx_serial.h | 3 ++ | 55 | hw/arm/smmuv3: Update ID register bit field definitions |
52 | dump.c | 14 +++++-- | 56 | hw/arm/smmuv3: Sort ID register setting into field order |
53 | hw/arm/bcm2836.c | 87 +++++++++++++++++++++++++++++++------------- | 57 | hw/arm/smmuv3: Advertise SMMUv3.1-XNX feature |
54 | hw/arm/boot.c | 12 ++++++ | 58 | target/arm: Implement FEAT_HPMN0 |
55 | hw/arm/raspi.c | 77 +++++++++++++++++++++++++++++++-------- | 59 | target/arm/kvm64.c: Remove unused include |
56 | hw/char/imx_serial.c | 44 ++++++++++++++++------ | 60 | target/arm/common-semi-target.h: Remove unnecessary boot.h include |
57 | hw/net/imx_fec.c | 28 +++++++++++++- | 61 | target/arm/arm-powerctl: Correctly init CPUs when powered on to lower EL |
58 | 9 files changed, 237 insertions(+), 63 deletions(-) | ||
59 | 62 | ||
63 | Philippe Mathieu-Daudé (1): | ||
64 | hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot.h' | ||
65 | |||
66 | Suraj Shirvankar (1): | ||
67 | contrib/elf2dmp: Use g_malloc(), g_new() and g_free() | ||
68 | |||
69 | Thomas Huth (1): | ||
70 | hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder | ||
71 | |||
72 | Tong Ho (4): | ||
73 | xlnx-bbram: hw/nvram: Remove deprecated device reset | ||
74 | xlnx-zynqmp-efuse: hw/nvram: Remove deprecated device reset | ||
75 | xlnx-versal-efuse: hw/nvram: Remove deprecated device reset | ||
76 | xlnx-bbram: hw/nvram: Use dot in device type name | ||
77 | |||
78 | Viktor Prutyanov (2): | ||
79 | elf2dmp: limit print length for sign_rsds | ||
80 | elf2dmp: check array bounds in pdb_get_file_size | ||
81 | |||
82 | MAINTAINERS | 2 +- | ||
83 | docs/system/arm/emulation.rst | 1 + | ||
84 | hw/arm/smmuv3-internal.h | 38 ++++++++ | ||
85 | include/hw/arm/bsa.h | 35 +++++++ | ||
86 | include/hw/arm/exynos4210.h | 2 +- | ||
87 | include/hw/{misc => arm}/raspberrypi-fw-defs.h | 0 | ||
88 | include/hw/arm/virt.h | 12 +-- | ||
89 | include/hw/nvram/xlnx-bbram.h | 2 +- | ||
90 | target/arm/common-semi-target.h | 4 +- | ||
91 | target/arm/cpu-qom.h | 2 - | ||
92 | target/arm/cpu.h | 22 +++++ | ||
93 | contrib/elf2dmp/addrspace.c | 7 +- | ||
94 | contrib/elf2dmp/main.c | 11 +-- | ||
95 | contrib/elf2dmp/pdb.c | 32 ++++--- | ||
96 | contrib/elf2dmp/qemu_elf.c | 7 +- | ||
97 | hw/arm/boot.c | 95 +++++-------------- | ||
98 | hw/arm/sbsa-ref.c | 21 ++--- | ||
99 | hw/arm/smmuv3.c | 8 +- | ||
100 | hw/arm/virt-acpi-build.c | 12 +-- | ||
101 | hw/arm/virt.c | 24 +++-- | ||
102 | hw/misc/bcm2835_property.c | 2 +- | ||
103 | hw/nvram/xlnx-bbram.c | 8 +- | ||
104 | hw/nvram/xlnx-versal-efuse-ctrl.c | 8 +- | ||
105 | hw/nvram/xlnx-zynqmp-efuse.c | 8 +- | ||
106 | hw/timer/npcm7xx_timer.c | 3 + | ||
107 | target/arm/arm-powerctl.c | 53 +---------- | ||
108 | target/arm/cpu.c | 95 +++++++++++++++++++ | ||
109 | target/arm/helper.c | 19 +--- | ||
110 | target/arm/kvm.c | 28 ++---- | ||
111 | target/arm/kvm64.c | 124 +++++++------------------ | ||
112 | target/arm/tcg/cpu32.c | 4 + | ||
113 | target/arm/tcg/cpu64.c | 1 + | ||
114 | target/arm/tcg/translate.c | 37 +++++--- | ||
115 | 33 files changed, 368 insertions(+), 359 deletions(-) | ||
116 | create mode 100644 include/hw/arm/bsa.h | ||
117 | rename include/hw/{misc => arm}/raspberrypi-fw-defs.h (100%) | ||
118 | diff view generated by jsdifflib |
1 | The TypeInfo and state struct for bcm2386 disagree about what the | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | parent class is -- the TypeInfo says it's TYPE_SYS_BUS_DEVICE, | ||
3 | but the BCM2386State struct only defines the parent_obj field | ||
4 | as DeviceState. This would have caused problems if anything | ||
5 | actually tried to treat the object as a TYPE_SYS_BUS_DEVICE. | ||
6 | Fix the TypeInfo to use TYPE_DEVICE as the parent, since we don't | ||
7 | need any of the additional functionality TYPE_SYS_BUS_DEVICE | ||
8 | provides. | ||
9 | 2 | ||
3 | The file is obviously related to the raspberrypi machine, so | ||
4 | it should reside in hw/arm/ instead of hw/misc/. And while we're | ||
5 | at it, also adjust the wildcard in MAINTAINERS so that it covers | ||
6 | this file, too. | ||
7 | |||
8 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Acked-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Message-id: 20231012073458.860187-1-thuth@redhat.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 20180313153458.26822-5-peter.maydell@linaro.org | ||
14 | --- | 13 | --- |
15 | hw/arm/bcm2836.c | 2 +- | 14 | MAINTAINERS | 2 +- |
16 | 1 file changed, 1 insertion(+), 1 deletion(-) | 15 | include/hw/{misc => arm}/raspberrypi-fw-defs.h | 0 |
16 | hw/misc/bcm2835_property.c | 2 +- | ||
17 | 3 files changed, 2 insertions(+), 2 deletions(-) | ||
18 | rename include/hw/{misc => arm}/raspberrypi-fw-defs.h (100%) | ||
17 | 19 | ||
18 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | 20 | diff --git a/MAINTAINERS b/MAINTAINERS |
19 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/arm/bcm2836.c | 22 | --- a/MAINTAINERS |
21 | +++ b/hw/arm/bcm2836.c | 23 | +++ b/MAINTAINERS |
22 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data) | 24 | @@ -XXX,XX +XXX,XX @@ S: Odd Fixes |
23 | 25 | F: hw/arm/raspi.c | |
24 | static const TypeInfo bcm2836_type_info = { | 26 | F: hw/arm/raspi_platform.h |
25 | .name = TYPE_BCM2836, | 27 | F: hw/*/bcm283* |
26 | - .parent = TYPE_SYS_BUS_DEVICE, | 28 | -F: include/hw/arm/raspi* |
27 | + .parent = TYPE_DEVICE, | 29 | +F: include/hw/arm/rasp* |
28 | .instance_size = sizeof(BCM2836State), | 30 | F: include/hw/*/bcm283* |
29 | .instance_init = bcm2836_init, | 31 | F: docs/system/arm/raspi.rst |
30 | .class_init = bcm2836_class_init, | 32 | |
33 | diff --git a/include/hw/misc/raspberrypi-fw-defs.h b/include/hw/arm/raspberrypi-fw-defs.h | ||
34 | similarity index 100% | ||
35 | rename from include/hw/misc/raspberrypi-fw-defs.h | ||
36 | rename to include/hw/arm/raspberrypi-fw-defs.h | ||
37 | diff --git a/hw/misc/bcm2835_property.c b/hw/misc/bcm2835_property.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/hw/misc/bcm2835_property.c | ||
40 | +++ b/hw/misc/bcm2835_property.c | ||
41 | @@ -XXX,XX +XXX,XX @@ | ||
42 | #include "migration/vmstate.h" | ||
43 | #include "hw/irq.h" | ||
44 | #include "hw/misc/bcm2835_mbox_defs.h" | ||
45 | -#include "hw/misc/raspberrypi-fw-defs.h" | ||
46 | +#include "hw/arm/raspberrypi-fw-defs.h" | ||
47 | #include "sysemu/dma.h" | ||
48 | #include "qemu/log.h" | ||
49 | #include "qemu/module.h" | ||
31 | -- | 50 | -- |
32 | 2.16.2 | 51 | 2.34.1 |
33 | 52 | ||
34 | 53 | diff view generated by jsdifflib |
1 | If we're directly booting a Linux kernel and the CPU supports both | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | EL3 and EL2, we start the kernel in EL2, as it expects. We must also | ||
3 | set the SCR_EL3.HCE bit in this situation, so that the HVC | ||
4 | instruction is enabled rather than UNDEFing. Otherwise at least some | ||
5 | kernels will panic when trying to initialize KVM in the guest. | ||
6 | 2 | ||
3 | struct arm_boot_info is declared in "hw/arm/boot.h". | ||
4 | By including the correct header we don't need to declare | ||
5 | it again in "target/arm/cpu-qom.h". | ||
6 | |||
7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20231013130214.95742-1-philmd@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20180313153458.26822-4-peter.maydell@linaro.org | ||
9 | --- | 11 | --- |
10 | hw/arm/boot.c | 5 +++++ | 12 | include/hw/arm/exynos4210.h | 2 +- |
11 | 1 file changed, 5 insertions(+) | 13 | target/arm/cpu-qom.h | 2 -- |
14 | 2 files changed, 1 insertion(+), 3 deletions(-) | ||
12 | 15 | ||
13 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 16 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/boot.c | 18 | --- a/include/hw/arm/exynos4210.h |
16 | +++ b/hw/arm/boot.c | 19 | +++ b/include/hw/arm/exynos4210.h |
17 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | 20 | @@ -XXX,XX +XXX,XX @@ |
18 | assert(!info->secure_board_setup); | 21 | #include "hw/intc/exynos4210_gic.h" |
19 | } | 22 | #include "hw/intc/exynos4210_combiner.h" |
20 | 23 | #include "hw/core/split-irq.h" | |
21 | + if (arm_feature(env, ARM_FEATURE_EL2)) { | 24 | -#include "target/arm/cpu-qom.h" |
22 | + /* If we have EL2 then Linux expects the HVC insn to work */ | 25 | +#include "hw/arm/boot.h" |
23 | + env->cp15.scr_el3 |= SCR_HCE; | 26 | #include "qom/object.h" |
24 | + } | 27 | |
25 | + | 28 | #define EXYNOS4210_NCPUS 2 |
26 | /* Set to non-secure if not a secure boot */ | 29 | diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h |
27 | if (!info->secure_boot && | 30 | index XXXXXXX..XXXXXXX 100644 |
28 | (cs != first_cpu || !info->secure_board_setup)) { | 31 | --- a/target/arm/cpu-qom.h |
32 | +++ b/target/arm/cpu-qom.h | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | #include "hw/core/cpu.h" | ||
35 | #include "qom/object.h" | ||
36 | |||
37 | -struct arm_boot_info; | ||
38 | - | ||
39 | #define TYPE_ARM_CPU "arm-cpu" | ||
40 | |||
41 | OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU) | ||
29 | -- | 42 | -- |
30 | 2.16.2 | 43 | 2.34.1 |
31 | 44 | ||
32 | 45 | diff view generated by jsdifflib |
1 | The BCM2837 sets the Aff1 field of the MPIDR affinity values for the | 1 | From: Tong Ho <tong.ho@amd.com> |
---|---|---|---|
2 | CPUs to 0, whereas the BCM2836 uses 0xf. Set this correctly, as it | ||
3 | is required for Linux to boot. | ||
4 | 2 | ||
3 | This change implements the ResettableClass interface for the device. | ||
4 | |||
5 | Signed-off-by: Tong Ho <tong.ho@amd.com> | ||
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Message-id: 20231003052345.199725-1-tong.ho@amd.com | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
8 | Message-id: 20180313153458.26822-8-peter.maydell@linaro.org | ||
9 | --- | 9 | --- |
10 | hw/arm/bcm2836.c | 11 +++++++---- | 10 | hw/nvram/xlnx-bbram.c | 8 +++++--- |
11 | 1 file changed, 7 insertions(+), 4 deletions(-) | 11 | 1 file changed, 5 insertions(+), 3 deletions(-) |
12 | 12 | ||
13 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | 13 | diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/bcm2836.c | 15 | --- a/hw/nvram/xlnx-bbram.c |
16 | +++ b/hw/arm/bcm2836.c | 16 | +++ b/hw/nvram/xlnx-bbram.c |
17 | @@ -XXX,XX +XXX,XX @@ | 17 | @@ -XXX,XX +XXX,XX @@ |
18 | 18 | * QEMU model of the Xilinx BBRAM Battery Backed RAM | |
19 | struct BCM283XInfo { | 19 | * |
20 | const char *name; | 20 | * Copyright (c) 2014-2021 Xilinx Inc. |
21 | + int clusterid; | 21 | + * Copyright (c) 2023 Advanced Micro Devices, Inc. |
22 | * | ||
23 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
24 | * of this software and associated documentation files (the "Software"), to deal | ||
25 | @@ -XXX,XX +XXX,XX @@ static RegisterAccessInfo bbram_ctrl_regs_info[] = { | ||
26 | } | ||
22 | }; | 27 | }; |
23 | 28 | ||
24 | static const BCM283XInfo bcm283x_socs[] = { | 29 | -static void bbram_ctrl_reset(DeviceState *dev) |
25 | { | 30 | +static void bbram_ctrl_reset_hold(Object *obj) |
26 | .name = TYPE_BCM2836, | ||
27 | + .clusterid = 0xf, | ||
28 | }, | ||
29 | { | ||
30 | .name = TYPE_BCM2837, | ||
31 | + .clusterid = 0x0, | ||
32 | }, | ||
33 | }; | ||
34 | |||
35 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj) | ||
36 | static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
37 | { | 31 | { |
38 | BCM283XState *s = BCM283X(dev); | 32 | - XlnxBBRam *s = XLNX_BBRAM(dev); |
39 | + BCM283XClass *bc = BCM283X_GET_CLASS(dev); | 33 | + XlnxBBRam *s = XLNX_BBRAM(obj); |
40 | + const BCM283XInfo *info = bc->info; | 34 | unsigned int i; |
41 | Object *obj; | 35 | |
42 | Error *err = NULL; | 36 | for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { |
43 | int n; | 37 | @@ -XXX,XX +XXX,XX @@ static Property bbram_ctrl_props[] = { |
44 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | 38 | static void bbram_ctrl_class_init(ObjectClass *klass, void *data) |
45 | qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); | 39 | { |
46 | 40 | DeviceClass *dc = DEVICE_CLASS(klass); | |
47 | for (n = 0; n < BCM283X_NCPUS; n++) { | 41 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
48 | - /* Mirror bcm2836, which has clusterid set to 0xf | 42 | |
49 | - * TODO: this should be converted to a property of ARM_CPU | 43 | - dc->reset = bbram_ctrl_reset; |
50 | - */ | 44 | + rc->phases.hold = bbram_ctrl_reset_hold; |
51 | - s->cpus[n].mp_affinity = 0xF00 | n; | 45 | dc->realize = bbram_ctrl_realize; |
52 | + /* TODO: this should be converted to a property of ARM_CPU */ | 46 | dc->vmsd = &vmstate_bbram_ctrl; |
53 | + s->cpus[n].mp_affinity = (info->clusterid << 8) | n; | 47 | device_class_set_props(dc, bbram_ctrl_props); |
54 | |||
55 | /* set periphbase/CBAR value for CPU-local registers */ | ||
56 | object_property_set_int(OBJECT(&s->cpus[n]), | ||
57 | -- | 48 | -- |
58 | 2.16.2 | 49 | 2.34.1 |
59 | 50 | ||
60 | 51 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Tong Ho <tong.ho@amd.com> | ||
1 | 2 | ||
3 | This change implements the ResettableClass interface for the device. | ||
4 | |||
5 | Signed-off-by: Tong Ho <tong.ho@amd.com> | ||
6 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
7 | Message-id: 20231004055713.324009-1-tong.ho@amd.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/nvram/xlnx-zynqmp-efuse.c | 8 +++++--- | ||
11 | 1 file changed, 5 insertions(+), 3 deletions(-) | ||
12 | |||
13 | diff --git a/hw/nvram/xlnx-zynqmp-efuse.c b/hw/nvram/xlnx-zynqmp-efuse.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/nvram/xlnx-zynqmp-efuse.c | ||
16 | +++ b/hw/nvram/xlnx-zynqmp-efuse.c | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | * QEMU model of the ZynqMP eFuse | ||
19 | * | ||
20 | * Copyright (c) 2015 Xilinx Inc. | ||
21 | + * Copyright (c) 2023 Advanced Micro Devices, Inc. | ||
22 | * | ||
23 | * Written by Edgar E. Iglesias <edgari@xilinx.com> | ||
24 | * | ||
25 | @@ -XXX,XX +XXX,XX @@ static void zynqmp_efuse_register_reset(RegisterInfo *reg) | ||
26 | register_reset(reg); | ||
27 | } | ||
28 | |||
29 | -static void zynqmp_efuse_reset(DeviceState *dev) | ||
30 | +static void zynqmp_efuse_reset_hold(Object *obj) | ||
31 | { | ||
32 | - XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(dev); | ||
33 | + XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(obj); | ||
34 | unsigned int i; | ||
35 | |||
36 | for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | ||
37 | @@ -XXX,XX +XXX,XX @@ static Property zynqmp_efuse_props[] = { | ||
38 | static void zynqmp_efuse_class_init(ObjectClass *klass, void *data) | ||
39 | { | ||
40 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
41 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
42 | |||
43 | - dc->reset = zynqmp_efuse_reset; | ||
44 | + rc->phases.hold = zynqmp_efuse_reset_hold; | ||
45 | dc->realize = zynqmp_efuse_realize; | ||
46 | dc->vmsd = &vmstate_efuse; | ||
47 | device_class_set_props(dc, zynqmp_efuse_props); | ||
48 | -- | ||
49 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Tong Ho <tong.ho@amd.com> | ||
1 | 2 | ||
3 | This change implements the ResettableClass interface for the device. | ||
4 | |||
5 | Signed-off-by: Tong Ho <tong.ho@amd.com> | ||
6 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
7 | Message-id: 20231004055339.323833-1-tong.ho@amd.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | hw/nvram/xlnx-versal-efuse-ctrl.c | 8 +++++--- | ||
11 | 1 file changed, 5 insertions(+), 3 deletions(-) | ||
12 | |||
13 | diff --git a/hw/nvram/xlnx-versal-efuse-ctrl.c b/hw/nvram/xlnx-versal-efuse-ctrl.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/nvram/xlnx-versal-efuse-ctrl.c | ||
16 | +++ b/hw/nvram/xlnx-versal-efuse-ctrl.c | ||
17 | @@ -XXX,XX +XXX,XX @@ | ||
18 | * QEMU model of the Versal eFuse controller | ||
19 | * | ||
20 | * Copyright (c) 2020 Xilinx Inc. | ||
21 | + * Copyright (c) 2023 Advanced Micro Devices, Inc. | ||
22 | * | ||
23 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
24 | * of this software and associated documentation files (the "Software"), to deal | ||
25 | @@ -XXX,XX +XXX,XX @@ static void efuse_ctrl_register_reset(RegisterInfo *reg) | ||
26 | register_reset(reg); | ||
27 | } | ||
28 | |||
29 | -static void efuse_ctrl_reset(DeviceState *dev) | ||
30 | +static void efuse_ctrl_reset_hold(Object *obj) | ||
31 | { | ||
32 | - XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(dev); | ||
33 | + XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(obj); | ||
34 | unsigned int i; | ||
35 | |||
36 | for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | ||
37 | @@ -XXX,XX +XXX,XX @@ static Property efuse_ctrl_props[] = { | ||
38 | static void efuse_ctrl_class_init(ObjectClass *klass, void *data) | ||
39 | { | ||
40 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
41 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
42 | |||
43 | - dc->reset = efuse_ctrl_reset; | ||
44 | + rc->phases.hold = efuse_ctrl_reset_hold; | ||
45 | dc->realize = efuse_ctrl_realize; | ||
46 | dc->vmsd = &vmstate_efuse_ctrl; | ||
47 | device_class_set_props(dc, efuse_ctrl_props); | ||
48 | -- | ||
49 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Tong Ho <tong.ho@amd.com> | ||
1 | 2 | ||
3 | This replaces the comma (,) to dot (.) in the device type name | ||
4 | so the name can be used with the 'driver=' command line option. | ||
5 | |||
6 | Signed-off-by: Tong Ho <tong.ho@amd.com> | ||
7 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
8 | Message-id: 20231003052139.199665-1-tong.ho@amd.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/nvram/xlnx-bbram.h | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/include/hw/nvram/xlnx-bbram.h b/include/hw/nvram/xlnx-bbram.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/nvram/xlnx-bbram.h | ||
17 | +++ b/include/hw/nvram/xlnx-bbram.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | |||
20 | #define RMAX_XLNX_BBRAM ((0x4c / 4) + 1) | ||
21 | |||
22 | -#define TYPE_XLNX_BBRAM "xlnx,bbram-ctrl" | ||
23 | +#define TYPE_XLNX_BBRAM "xlnx.bbram-ctrl" | ||
24 | OBJECT_DECLARE_SIMPLE_TYPE(XlnxBBRam, XLNX_BBRAM); | ||
25 | |||
26 | struct XlnxBBRam { | ||
27 | -- | ||
28 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Viktor Prutyanov <viktor@daynix.com> | ||
1 | 2 | ||
3 | String sign_rsds isn't terminated, so the print length must be limited. | ||
4 | |||
5 | Fixes: Coverity CID 1521598 | ||
6 | Signed-off-by: Viktor Prutyanov <viktor@daynix.com> | ||
7 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | ||
8 | Message-id: 20230930235317.11469-2-viktor@daynix.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | contrib/elf2dmp/main.c | 2 +- | ||
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/contrib/elf2dmp/main.c | ||
17 | +++ b/contrib/elf2dmp/main.c | ||
18 | @@ -XXX,XX +XXX,XX @@ static bool pe_check_pdb_name(uint64_t base, void *start_addr, | ||
19 | } | ||
20 | |||
21 | if (memcmp(&rsds->Signature, sign_rsds, sizeof(sign_rsds))) { | ||
22 | - eprintf("CodeView signature is \'%.4s\', \'%s\' expected\n", | ||
23 | + eprintf("CodeView signature is \'%.4s\', \'%.4s\' expected\n", | ||
24 | rsds->Signature, sign_rsds); | ||
25 | return false; | ||
26 | } | ||
27 | -- | ||
28 | 2.34.1 | diff view generated by jsdifflib |
1 | Now we have separate types for BCM2386 and BCM2387, we might as well | 1 | From: Viktor Prutyanov <viktor@daynix.com> |
---|---|---|---|
2 | just hard-code the CPU type they use rather than having it passed | ||
3 | through as an object property. This then lets us put the initialization | ||
4 | of the CPU object in init rather than realize. | ||
5 | 2 | ||
6 | Note that this change means that it's no longer possible on | 3 | Index in file_size array must be checked against num_files, because the |
7 | the command line to use -cpu to ask for a different kind of | 4 | entries we are looking for may be absent in the PDB. |
8 | CPU than the SoC supports. This was never a supported thing to | ||
9 | do anyway; we were just not sanity-checking the command line. | ||
10 | 5 | ||
11 | This does require us to only build the bcm2837 object on | 6 | Fixes: Coverity CID 1521597 |
12 | TARGET_AARCH64 configs, since otherwise it won't instantiate | 7 | Signed-off-by: Viktor Prutyanov <viktor@daynix.com> |
13 | due to the missing cortex-a53 device and "make check" will fail. | 8 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Message-id: 20230930235317.11469-3-viktor@daynix.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | contrib/elf2dmp/pdb.c | 13 +++++++++---- | ||
14 | 1 file changed, 9 insertions(+), 4 deletions(-) | ||
14 | 15 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c |
16 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
17 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
18 | Message-id: 20180313153458.26822-9-peter.maydell@linaro.org | ||
19 | --- | ||
20 | hw/arm/bcm2836.c | 24 +++++++++++++++--------- | ||
21 | hw/arm/raspi.c | 2 -- | ||
22 | 2 files changed, 15 insertions(+), 11 deletions(-) | ||
23 | |||
24 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/arm/bcm2836.c | 18 | --- a/contrib/elf2dmp/pdb.c |
27 | +++ b/hw/arm/bcm2836.c | 19 | +++ b/contrib/elf2dmp/pdb.c |
28 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
29 | 21 | ||
30 | struct BCM283XInfo { | 22 | static uint32_t pdb_get_file_size(const struct pdb_reader *r, unsigned idx) |
31 | const char *name; | ||
32 | + const char *cpu_type; | ||
33 | int clusterid; | ||
34 | }; | ||
35 | |||
36 | static const BCM283XInfo bcm283x_socs[] = { | ||
37 | { | ||
38 | .name = TYPE_BCM2836, | ||
39 | + .cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"), | ||
40 | .clusterid = 0xf, | ||
41 | }, | ||
42 | +#ifdef TARGET_AARCH64 | ||
43 | { | ||
44 | .name = TYPE_BCM2837, | ||
45 | + .cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"), | ||
46 | .clusterid = 0x0, | ||
47 | }, | ||
48 | +#endif | ||
49 | }; | ||
50 | |||
51 | static void bcm2836_init(Object *obj) | ||
52 | { | 23 | { |
53 | BCM283XState *s = BCM283X(obj); | 24 | + if (idx >= r->ds.toc->num_files) { |
54 | + BCM283XClass *bc = BCM283X_GET_CLASS(obj); | 25 | + return 0; |
55 | + const BCM283XInfo *info = bc->info; | 26 | + } |
56 | + int n; | ||
57 | + | 27 | + |
58 | + for (n = 0; n < BCM283X_NCPUS; n++) { | 28 | return r->ds.toc->file_size[idx]; |
59 | + object_initialize(&s->cpus[n], sizeof(s->cpus[n]), | 29 | } |
60 | + info->cpu_type); | 30 | |
61 | + object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), | 31 | @@ -XXX,XX +XXX,XX @@ static void *pdb_ds_read_file(struct pdb_reader* r, uint32_t file_number) |
62 | + &error_abort); | 32 | |
33 | static int pdb_init_segments(struct pdb_reader *r) | ||
34 | { | ||
35 | - char *segs; | ||
36 | unsigned stream_idx = r->segments; | ||
37 | |||
38 | - segs = pdb_ds_read_file(r, stream_idx); | ||
39 | - if (!segs) { | ||
40 | + r->segs = pdb_ds_read_file(r, stream_idx); | ||
41 | + if (!r->segs) { | ||
42 | return 1; | ||
43 | } | ||
44 | |||
45 | - r->segs = segs; | ||
46 | r->segs_size = pdb_get_file_size(r, stream_idx); | ||
47 | + if (!r->segs_size) { | ||
48 | + return 1; | ||
63 | + } | 49 | + } |
64 | 50 | ||
65 | object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL); | 51 | return 0; |
66 | object_property_add_child(obj, "control", OBJECT(&s->control), NULL); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
68 | |||
69 | /* common peripherals from bcm2835 */ | ||
70 | |||
71 | - obj = OBJECT(dev); | ||
72 | - for (n = 0; n < BCM283X_NCPUS; n++) { | ||
73 | - object_initialize(&s->cpus[n], sizeof(s->cpus[n]), | ||
74 | - s->cpu_type); | ||
75 | - object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), | ||
76 | - &error_abort); | ||
77 | - } | ||
78 | - | ||
79 | obj = object_property_get_link(OBJECT(dev), "ram", &err); | ||
80 | if (obj == NULL) { | ||
81 | error_setg(errp, "%s: required ram link not found: %s", | ||
82 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
83 | } | 52 | } |
84 | |||
85 | static Property bcm2836_props[] = { | ||
86 | - DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type), | ||
87 | DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, | ||
88 | BCM283X_NCPUS), | ||
89 | DEFINE_PROP_END_OF_LIST() | ||
90 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/hw/arm/raspi.c | ||
93 | +++ b/hw/arm/raspi.c | ||
94 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) | ||
95 | /* Setup the SOC */ | ||
96 | object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram), | ||
97 | &error_abort); | ||
98 | - object_property_set_str(OBJECT(&s->soc), machine->cpu_type, "cpu-type", | ||
99 | - &error_abort); | ||
100 | object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus", | ||
101 | &error_abort); | ||
102 | int board_rev = version == 3 ? 0xa02082 : 0xa21041; | ||
103 | -- | 53 | -- |
104 | 2.16.2 | 54 | 2.34.1 |
105 | 55 | ||
106 | 56 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Michal Orzel <michal.orzel@amd.com> | ||
1 | 2 | ||
3 | On an attempt to access CNTPCT_EL0 from EL0 using a guest running on top | ||
4 | of Xen, a trap from EL2 was observed which is something not reproducible | ||
5 | on HW (also, Xen does not trap accesses to physical counter). | ||
6 | |||
7 | This is because gt_counter_access() checks for an incorrect bit (1 | ||
8 | instead of 0) of CNTHCTL_EL2 if HCR_EL2.E2H is 0 and access is made to | ||
9 | physical counter. Refer ARM ARM DDI 0487J.a, D19.12.2: | ||
10 | When HCR_EL2.E2H is 0: | ||
11 | - EL1PCTEN, bit [0]: refers to physical counter | ||
12 | - EL1PCEN, bit [1]: refers to physical timer registers | ||
13 | |||
14 | Drop entire block "if (hcr & HCR_E2H) {...} else {...}" from EL0 case | ||
15 | and fall through to EL1 case, given that after fixing checking for the | ||
16 | correct bit, the handling is the same. | ||
17 | |||
18 | Fixes: 5bc8437136fb ("target/arm: Update timer access for VHE") | ||
19 | Signed-off-by: Michal Orzel <michal.orzel@amd.com> | ||
20 | Tested-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> | ||
21 | Message-id: 20230928094404.20802-1-michal.orzel@amd.com | ||
22 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
24 | --- | ||
25 | target/arm/helper.c | 17 +---------------- | ||
26 | 1 file changed, 1 insertion(+), 16 deletions(-) | ||
27 | |||
28 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/target/arm/helper.c | ||
31 | +++ b/target/arm/helper.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx, | ||
33 | if (!extract32(env->cp15.c14_cntkctl, timeridx, 1)) { | ||
34 | return CP_ACCESS_TRAP; | ||
35 | } | ||
36 | - | ||
37 | - /* If HCR_EL2.<E2H,TGE> == '10': check CNTHCTL_EL2.EL1PCTEN. */ | ||
38 | - if (hcr & HCR_E2H) { | ||
39 | - if (timeridx == GTIMER_PHYS && | ||
40 | - !extract32(env->cp15.cnthctl_el2, 10, 1)) { | ||
41 | - return CP_ACCESS_TRAP_EL2; | ||
42 | - } | ||
43 | - } else { | ||
44 | - /* If HCR_EL2.<E2H> == 0: check CNTHCTL_EL2.EL1PCEN. */ | ||
45 | - if (has_el2 && timeridx == GTIMER_PHYS && | ||
46 | - !extract32(env->cp15.cnthctl_el2, 1, 1)) { | ||
47 | - return CP_ACCESS_TRAP_EL2; | ||
48 | - } | ||
49 | - } | ||
50 | - break; | ||
51 | - | ||
52 | + /* fall through */ | ||
53 | case 1: | ||
54 | /* Check CNTHCTL_EL2.EL1PCTEN, which changes location based on E2H. */ | ||
55 | if (has_el2 && timeridx == GTIMER_PHYS && | ||
56 | -- | ||
57 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Wei Huang <wei@redhat.com> | 1 | From: Leif Lindholm <quic_llindhol@quicinc.com> |
---|---|---|---|
2 | 2 | ||
3 | For guest kernel that supports KASLR, the load address can change every | 3 | GIC Private Peripheral Interrupts (PPI) are defined as GIC INTID 16-31. |
4 | time when guest VM runs. To find the physical base address correctly, | 4 | As in, PPI0 is INTID16 .. PPI15 is INTID31. |
5 | current QEMU dump searches VMCOREINFO for the string "NUMBER(phys_base)=". | 5 | Arm's Base System Architecture specification (BSA) lists the mandated and |
6 | However this string pattern is only available on x86_64. AArch64 uses a | 6 | recommended private interrupt IDs by INTID, not by PPI index. But current |
7 | different field, called "NUMBER(PHYS_OFFSET)=". This patch makes sure | 7 | definitions in virt define them by PPI index, complicating cross |
8 | QEMU dump uses the correct string on AArch64. | 8 | referencing. |
9 | 9 | ||
10 | Signed-off-by: Wei Huang <wei@redhat.com> | 10 | Meanwhile, the PPI(x) macro counterintuitively adds 16 to the input value, |
11 | Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> | 11 | converting a PPI index to an INTID. |
12 | Message-id: 1520615003-20869-1-git-send-email-wei@redhat.com | 12 | |
13 | Resolve this by redefining the BSA-allocated PPIs by their INTIDs, | ||
14 | and replacing the PPI(x) macro with an INTID_TO_PPI(x) one where required. | ||
15 | |||
16 | Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com> | ||
17 | Message-id: 20230919090229.188092-2-quic_llindhol@quicinc.com | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 20 | --- |
15 | dump.c | 14 +++++++++++--- | 21 | include/hw/arm/virt.h | 14 +++++++------- |
16 | 1 file changed, 11 insertions(+), 3 deletions(-) | 22 | hw/arm/virt-acpi-build.c | 12 ++++++------ |
23 | hw/arm/virt.c | 24 ++++++++++++++---------- | ||
24 | 3 files changed, 27 insertions(+), 23 deletions(-) | ||
17 | 25 | ||
18 | diff --git a/dump.c b/dump.c | 26 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h |
19 | index XXXXXXX..XXXXXXX 100644 | 27 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/dump.c | 28 | --- a/include/hw/arm/virt.h |
21 | +++ b/dump.c | 29 | +++ b/include/hw/arm/virt.h |
22 | @@ -XXX,XX +XXX,XX @@ static void vmcoreinfo_update_phys_base(DumpState *s) | 30 | @@ -XXX,XX +XXX,XX @@ |
23 | 31 | #define NUM_VIRTIO_TRANSPORTS 32 | |
24 | lines = g_strsplit((char *)vmci, "\n", -1); | 32 | #define NUM_SMMU_IRQS 4 |
25 | for (i = 0; lines[i]; i++) { | 33 | |
26 | - if (g_str_has_prefix(lines[i], "NUMBER(phys_base)=")) { | 34 | -#define ARCH_GIC_MAINT_IRQ 9 |
27 | - if (qemu_strtou64(lines[i] + 18, NULL, 16, | 35 | +#define ARCH_GIC_MAINT_IRQ 25 |
28 | + const char *prefix = NULL; | 36 | |
29 | + | 37 | -#define ARCH_TIMER_VIRT_IRQ 11 |
30 | + if (s->dump_info.d_machine == EM_X86_64) { | 38 | -#define ARCH_TIMER_S_EL1_IRQ 13 |
31 | + prefix = "NUMBER(phys_base)="; | 39 | -#define ARCH_TIMER_NS_EL1_IRQ 14 |
32 | + } else if (s->dump_info.d_machine == EM_AARCH64) { | 40 | -#define ARCH_TIMER_NS_EL2_IRQ 10 |
33 | + prefix = "NUMBER(PHYS_OFFSET)="; | 41 | +#define ARCH_TIMER_VIRT_IRQ 27 |
34 | + } | 42 | +#define ARCH_TIMER_S_EL1_IRQ 29 |
35 | + | 43 | +#define ARCH_TIMER_NS_EL1_IRQ 30 |
36 | + if (prefix && g_str_has_prefix(lines[i], prefix)) { | 44 | +#define ARCH_TIMER_NS_EL2_IRQ 26 |
37 | + if (qemu_strtou64(lines[i] + strlen(prefix), NULL, 16, | 45 | |
38 | &phys_base) < 0) { | 46 | -#define VIRTUAL_PMU_IRQ 7 |
39 | - warn_report("Failed to read NUMBER(phys_base)="); | 47 | +#define VIRTUAL_PMU_IRQ 23 |
40 | + warn_report("Failed to read %s", prefix); | 48 | |
41 | } else { | 49 | -#define PPI(irq) ((irq) + 16) |
42 | s->dump_info.phys_base = phys_base; | 50 | +#define INTID_TO_PPI(irq) ((irq) - 16) |
51 | |||
52 | /* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */ | ||
53 | #define PVTIME_SIZE_PER_CPU 64 | ||
54 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
55 | index XXXXXXX..XXXXXXX 100644 | ||
56 | --- a/hw/arm/virt-acpi-build.c | ||
57 | +++ b/hw/arm/virt-acpi-build.c | ||
58 | @@ -XXX,XX +XXX,XX @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
59 | * The interrupt values are the same with the device tree when adding 16 | ||
60 | */ | ||
61 | /* Secure EL1 timer GSIV */ | ||
62 | - build_append_int_noprefix(table_data, ARCH_TIMER_S_EL1_IRQ + 16, 4); | ||
63 | + build_append_int_noprefix(table_data, ARCH_TIMER_S_EL1_IRQ, 4); | ||
64 | /* Secure EL1 timer Flags */ | ||
65 | build_append_int_noprefix(table_data, irqflags, 4); | ||
66 | /* Non-Secure EL1 timer GSIV */ | ||
67 | - build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL1_IRQ + 16, 4); | ||
68 | + build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL1_IRQ, 4); | ||
69 | /* Non-Secure EL1 timer Flags */ | ||
70 | build_append_int_noprefix(table_data, irqflags | | ||
71 | 1UL << 2, /* Always-on Capability */ | ||
72 | 4); | ||
73 | /* Virtual timer GSIV */ | ||
74 | - build_append_int_noprefix(table_data, ARCH_TIMER_VIRT_IRQ + 16, 4); | ||
75 | + build_append_int_noprefix(table_data, ARCH_TIMER_VIRT_IRQ, 4); | ||
76 | /* Virtual Timer Flags */ | ||
77 | build_append_int_noprefix(table_data, irqflags, 4); | ||
78 | /* Non-Secure EL2 timer GSIV */ | ||
79 | - build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_IRQ + 16, 4); | ||
80 | + build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_IRQ, 4); | ||
81 | /* Non-Secure EL2 timer Flags */ | ||
82 | build_append_int_noprefix(table_data, irqflags, 4); | ||
83 | /* CntReadBase Physical address */ | ||
84 | @@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
85 | for (i = 0; i < MACHINE(vms)->smp.cpus; i++) { | ||
86 | ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i)); | ||
87 | uint64_t physical_base_address = 0, gich = 0, gicv = 0; | ||
88 | - uint32_t vgic_interrupt = vms->virt ? PPI(ARCH_GIC_MAINT_IRQ) : 0; | ||
89 | + uint32_t vgic_interrupt = vms->virt ? ARCH_GIC_MAINT_IRQ : 0; | ||
90 | uint32_t pmu_interrupt = arm_feature(&armcpu->env, ARM_FEATURE_PMU) ? | ||
91 | - PPI(VIRTUAL_PMU_IRQ) : 0; | ||
92 | + VIRTUAL_PMU_IRQ : 0; | ||
93 | |||
94 | if (vms->gic_version == VIRT_GIC_VERSION_2) { | ||
95 | physical_base_address = memmap[VIRT_GIC_CPU].base; | ||
96 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/hw/arm/virt.c | ||
99 | +++ b/hw/arm/virt.c | ||
100 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms) | ||
101 | } | ||
102 | qemu_fdt_setprop(ms->fdt, "/timer", "always-on", NULL, 0); | ||
103 | qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts", | ||
104 | - GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_S_EL1_IRQ, irqflags, | ||
105 | - GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL1_IRQ, irqflags, | ||
106 | - GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_VIRT_IRQ, irqflags, | ||
107 | - GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL2_IRQ, irqflags); | ||
108 | + GIC_FDT_IRQ_TYPE_PPI, | ||
109 | + INTID_TO_PPI(ARCH_TIMER_S_EL1_IRQ), irqflags, | ||
110 | + GIC_FDT_IRQ_TYPE_PPI, | ||
111 | + INTID_TO_PPI(ARCH_TIMER_NS_EL1_IRQ), irqflags, | ||
112 | + GIC_FDT_IRQ_TYPE_PPI, | ||
113 | + INTID_TO_PPI(ARCH_TIMER_VIRT_IRQ), irqflags, | ||
114 | + GIC_FDT_IRQ_TYPE_PPI, | ||
115 | + INTID_TO_PPI(ARCH_TIMER_NS_EL2_IRQ), irqflags); | ||
116 | } | ||
117 | |||
118 | static void fdt_add_cpu_nodes(const VirtMachineState *vms) | ||
119 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
120 | */ | ||
121 | for (i = 0; i < smp_cpus; i++) { | ||
122 | DeviceState *cpudev = DEVICE(qemu_get_cpu(i)); | ||
123 | - int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS; | ||
124 | + int intidbase = NUM_IRQS + i * GIC_INTERNAL; | ||
125 | /* Mapping from the output timer irq lines from the CPU to the | ||
126 | * GIC PPI inputs we use for the virt board. | ||
127 | */ | ||
128 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
129 | for (unsigned irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { | ||
130 | qdev_connect_gpio_out(cpudev, irq, | ||
131 | qdev_get_gpio_in(vms->gic, | ||
132 | - ppibase + timer_irq[irq])); | ||
133 | + intidbase + timer_irq[irq])); | ||
134 | } | ||
135 | |||
136 | if (vms->gic_version != VIRT_GIC_VERSION_2) { | ||
137 | qemu_irq irq = qdev_get_gpio_in(vms->gic, | ||
138 | - ppibase + ARCH_GIC_MAINT_IRQ); | ||
139 | + intidbase + ARCH_GIC_MAINT_IRQ); | ||
140 | qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", | ||
141 | 0, irq); | ||
142 | } else if (vms->virt) { | ||
143 | qemu_irq irq = qdev_get_gpio_in(vms->gic, | ||
144 | - ppibase + ARCH_GIC_MAINT_IRQ); | ||
145 | + intidbase + ARCH_GIC_MAINT_IRQ); | ||
146 | sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus, irq); | ||
147 | } | ||
148 | |||
149 | qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, | ||
150 | - qdev_get_gpio_in(vms->gic, ppibase | ||
151 | + qdev_get_gpio_in(vms->gic, intidbase | ||
152 | + VIRTUAL_PMU_IRQ)); | ||
153 | |||
154 | sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); | ||
155 | @@ -XXX,XX +XXX,XX @@ static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem) | ||
156 | if (pmu) { | ||
157 | assert(arm_feature(&ARM_CPU(cpu)->env, ARM_FEATURE_PMU)); | ||
158 | if (kvm_irqchip_in_kernel()) { | ||
159 | - kvm_arm_pmu_set_irq(cpu, PPI(VIRTUAL_PMU_IRQ)); | ||
160 | + kvm_arm_pmu_set_irq(cpu, VIRTUAL_PMU_IRQ); | ||
161 | } | ||
162 | kvm_arm_pmu_init(cpu); | ||
43 | } | 163 | } |
44 | -- | 164 | -- |
45 | 2.16.2 | 165 | 2.34.1 |
46 | |||
47 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Leif Lindholm <quic_llindhol@quicinc.com> | ||
1 | 2 | ||
3 | virt.h defines a number of IRQs that are ultimately described by Arm's | ||
4 | Base System Architecture specification. Move these to a dedicated header | ||
5 | so that they can be reused by other platforms that do the same. | ||
6 | Include that header from virt.h to minimise churn. | ||
7 | |||
8 | While we're moving the definitions, sort them into numerical order, | ||
9 | and add the ARCH_TIMER_NS_EL2_VIRT_IRQ definition used by sbsa-ref | ||
10 | and which will eventually be needed by virt also. | ||
11 | |||
12 | Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com> | ||
13 | Message-id: 20230919090229.188092-3-quic_llindhol@quicinc.com | ||
14 | [PMM: Remove unused PPI_TO_INTID macro; sort numerically; | ||
15 | add ARCH_TIMER_NS_EL2_VIRT_IRQ] | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | --- | ||
19 | include/hw/arm/bsa.h | 35 +++++++++++++++++++++++++++++++++++ | ||
20 | include/hw/arm/virt.h | 12 +----------- | ||
21 | 2 files changed, 36 insertions(+), 11 deletions(-) | ||
22 | create mode 100644 include/hw/arm/bsa.h | ||
23 | |||
24 | diff --git a/include/hw/arm/bsa.h b/include/hw/arm/bsa.h | ||
25 | new file mode 100644 | ||
26 | index XXXXXXX..XXXXXXX | ||
27 | --- /dev/null | ||
28 | +++ b/include/hw/arm/bsa.h | ||
29 | @@ -XXX,XX +XXX,XX @@ | ||
30 | +/* | ||
31 | + * Common definitions for Arm Base System Architecture (BSA) platforms. | ||
32 | + * | ||
33 | + * Copyright (c) 2015 Linaro Limited | ||
34 | + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. | ||
35 | + * | ||
36 | + * This program is free software; you can redistribute it and/or modify it | ||
37 | + * under the terms and conditions of the GNU General Public License, | ||
38 | + * version 2 or later, as published by the Free Software Foundation. | ||
39 | + * | ||
40 | + * This program is distributed in the hope it will be useful, but WITHOUT | ||
41 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
42 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
43 | + * more details. | ||
44 | + * | ||
45 | + * You should have received a copy of the GNU General Public License along with | ||
46 | + * this program. If not, see <http://www.gnu.org/licenses/>. | ||
47 | + * | ||
48 | + */ | ||
49 | + | ||
50 | +#ifndef QEMU_ARM_BSA_H | ||
51 | +#define QEMU_ARM_BSA_H | ||
52 | + | ||
53 | +/* These are architectural INTID values */ | ||
54 | +#define VIRTUAL_PMU_IRQ 23 | ||
55 | +#define ARCH_GIC_MAINT_IRQ 25 | ||
56 | +#define ARCH_TIMER_NS_EL2_IRQ 26 | ||
57 | +#define ARCH_TIMER_VIRT_IRQ 27 | ||
58 | +#define ARCH_TIMER_NS_EL2_VIRT_IRQ 28 | ||
59 | +#define ARCH_TIMER_S_EL1_IRQ 29 | ||
60 | +#define ARCH_TIMER_NS_EL1_IRQ 30 | ||
61 | + | ||
62 | +#define INTID_TO_PPI(irq) ((irq) - 16) | ||
63 | + | ||
64 | +#endif /* QEMU_ARM_BSA_H */ | ||
65 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/include/hw/arm/virt.h | ||
68 | +++ b/include/hw/arm/virt.h | ||
69 | @@ -XXX,XX +XXX,XX @@ | ||
70 | #include "qemu/notify.h" | ||
71 | #include "hw/boards.h" | ||
72 | #include "hw/arm/boot.h" | ||
73 | +#include "hw/arm/bsa.h" | ||
74 | #include "hw/block/flash.h" | ||
75 | #include "sysemu/kvm.h" | ||
76 | #include "hw/intc/arm_gicv3_common.h" | ||
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | #define NUM_VIRTIO_TRANSPORTS 32 | ||
79 | #define NUM_SMMU_IRQS 4 | ||
80 | |||
81 | -#define ARCH_GIC_MAINT_IRQ 25 | ||
82 | - | ||
83 | -#define ARCH_TIMER_VIRT_IRQ 27 | ||
84 | -#define ARCH_TIMER_S_EL1_IRQ 29 | ||
85 | -#define ARCH_TIMER_NS_EL1_IRQ 30 | ||
86 | -#define ARCH_TIMER_NS_EL2_IRQ 26 | ||
87 | - | ||
88 | -#define VIRTUAL_PMU_IRQ 23 | ||
89 | - | ||
90 | -#define INTID_TO_PPI(irq) ((irq) - 16) | ||
91 | - | ||
92 | /* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */ | ||
93 | #define PVTIME_SIZE_PER_CPU 64 | ||
94 | |||
95 | -- | ||
96 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Leif Lindholm <quic_llindhol@quicinc.com> | ||
1 | 2 | ||
3 | Use the private peripheral interrupt definitions from bsa.h instead of | ||
4 | defining them locally. Refactor to use the INTIDs defined there instead | ||
5 | of the PPI# used previously. | ||
6 | |||
7 | Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com> | ||
8 | Message-id: 20230919090229.188092-4-quic_llindhol@quicinc.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/arm/sbsa-ref.c | 21 +++++++++------------ | ||
13 | 1 file changed, 9 insertions(+), 12 deletions(-) | ||
14 | |||
15 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/arm/sbsa-ref.c | ||
18 | +++ b/hw/arm/sbsa-ref.c | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | * ARM SBSA Reference Platform emulation | ||
21 | * | ||
22 | * Copyright (c) 2018 Linaro Limited | ||
23 | + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. | ||
24 | * Written by Hongbo Zhang <hongbo.zhang@linaro.org> | ||
25 | * | ||
26 | * This program is free software; you can redistribute it and/or modify it | ||
27 | @@ -XXX,XX +XXX,XX @@ | ||
28 | #include "exec/hwaddr.h" | ||
29 | #include "kvm_arm.h" | ||
30 | #include "hw/arm/boot.h" | ||
31 | +#include "hw/arm/bsa.h" | ||
32 | #include "hw/arm/fdt.h" | ||
33 | #include "hw/arm/smmuv3.h" | ||
34 | #include "hw/block/flash.h" | ||
35 | @@ -XXX,XX +XXX,XX @@ | ||
36 | #define NUM_SMMU_IRQS 4 | ||
37 | #define NUM_SATA_PORTS 6 | ||
38 | |||
39 | -#define VIRTUAL_PMU_IRQ 7 | ||
40 | -#define ARCH_GIC_MAINT_IRQ 9 | ||
41 | -#define ARCH_TIMER_VIRT_IRQ 11 | ||
42 | -#define ARCH_TIMER_S_EL1_IRQ 13 | ||
43 | -#define ARCH_TIMER_NS_EL1_IRQ 14 | ||
44 | -#define ARCH_TIMER_NS_EL2_IRQ 10 | ||
45 | -#define ARCH_TIMER_NS_EL2_VIRT_IRQ 12 | ||
46 | - | ||
47 | enum { | ||
48 | SBSA_FLASH, | ||
49 | SBSA_MEM, | ||
50 | @@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem) | ||
51 | */ | ||
52 | for (i = 0; i < smp_cpus; i++) { | ||
53 | DeviceState *cpudev = DEVICE(qemu_get_cpu(i)); | ||
54 | - int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS; | ||
55 | + int intidbase = NUM_IRQS + i * GIC_INTERNAL; | ||
56 | int irq; | ||
57 | /* | ||
58 | * Mapping from the output timer irq lines from the CPU to the | ||
59 | @@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem) | ||
60 | for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { | ||
61 | qdev_connect_gpio_out(cpudev, irq, | ||
62 | qdev_get_gpio_in(sms->gic, | ||
63 | - ppibase + timer_irq[irq])); | ||
64 | + intidbase + timer_irq[irq])); | ||
65 | } | ||
66 | |||
67 | qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0, | ||
68 | - qdev_get_gpio_in(sms->gic, ppibase | ||
69 | + qdev_get_gpio_in(sms->gic, | ||
70 | + intidbase | ||
71 | + ARCH_GIC_MAINT_IRQ)); | ||
72 | + | ||
73 | qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, | ||
74 | - qdev_get_gpio_in(sms->gic, ppibase | ||
75 | + qdev_get_gpio_in(sms->gic, | ||
76 | + intidbase | ||
77 | + VIRTUAL_PMU_IRQ)); | ||
78 | |||
79 | sysbus_connect_irq(gicbusdev, i, qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); | ||
80 | -- | ||
81 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Cornelia Huck <cohuck@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Code of imx_update() is slightly confusing since the "flags" variable | 3 | We can neaten the code by switching to the kvm_set_one_reg function. |
4 | doesn't really corespond to anything in real hardware and server as a | 4 | |
5 | kitchensink accumulating events normally reported via USR1 and USR2 | 5 | Reviewed-by: Gavin Shan <gshan@redhat.com> |
6 | registers. | 6 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> |
7 | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
8 | Change the code to explicitly evaluate state of interrupts reported | 8 | Message-id: 20231010142453.224369-2-cohuck@redhat.com |
9 | via USR1 and USR2 against corresponding masking bits and use the to | ||
10 | detemine if IRQ line should be asserted or not. | ||
11 | |||
12 | NOTE: Check for UTS1_TXEMPTY being set has been dropped for two | ||
13 | reasons: | ||
14 | |||
15 | 1. Emulation code implements a single character FIFO, so this flag | ||
16 | will always be set since characters are trasmitted as a part of | ||
17 | the code emulating "push" into the FIFO | ||
18 | |||
19 | 2. imx_update() is really just a function doing ORing and maksing | ||
20 | of reported events, so checking for UTS1_TXEMPTY should happen, | ||
21 | if it's ever really needed should probably happen outside of | ||
22 | it. | ||
23 | |||
24 | Cc: qemu-devel@nongnu.org | ||
25 | Cc: qemu-arm@nongnu.org | ||
26 | Cc: Bill Paul <wpaul@windriver.com> | ||
27 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
28 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
29 | Message-id: 20180315191141.6789-1-andrew.smirnov@gmail.com | ||
30 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
32 | --- | 11 | --- |
33 | hw/char/imx_serial.c | 24 ++++++++++++++++-------- | 12 | target/arm/kvm.c | 13 +++------ |
34 | 1 file changed, 16 insertions(+), 8 deletions(-) | 13 | target/arm/kvm64.c | 66 +++++++++++++--------------------------------- |
35 | 14 | 2 files changed, 21 insertions(+), 58 deletions(-) | |
36 | diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c | 15 | |
16 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/hw/char/imx_serial.c | 18 | --- a/target/arm/kvm.c |
39 | +++ b/hw/char/imx_serial.c | 19 | +++ b/target/arm/kvm.c |
40 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = { | 20 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level) |
41 | 21 | bool ok = true; | |
42 | static void imx_update(IMXSerialState *s) | 22 | |
43 | { | 23 | for (i = 0; i < cpu->cpreg_array_len; i++) { |
44 | - uint32_t flags; | 24 | - struct kvm_one_reg r; |
45 | + uint32_t usr1; | 25 | uint64_t regidx = cpu->cpreg_indexes[i]; |
46 | + uint32_t usr2; | 26 | uint32_t v32; |
47 | + uint32_t mask; | 27 | int ret; |
48 | 28 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level) | |
49 | - flags = (s->usr1 & s->ucr1) & (USR1_TRDY|USR1_RRDY); | 29 | continue; |
50 | - if (s->ucr1 & UCR1_TXMPTYEN) { | 30 | } |
51 | - flags |= (s->uts1 & UTS1_TXEMPTY); | 31 | |
52 | - } else { | 32 | - r.id = regidx; |
53 | - flags &= ~USR1_TRDY; | 33 | switch (regidx & KVM_REG_SIZE_MASK) { |
54 | - } | 34 | case KVM_REG_SIZE_U32: |
55 | + /* | 35 | v32 = cpu->cpreg_values[i]; |
56 | + * Lucky for us TRDY and RRDY has the same offset in both USR1 and | 36 | - r.addr = (uintptr_t)&v32; |
57 | + * UCR1, so we can get away with something as simple as the | 37 | + ret = kvm_set_one_reg(cs, regidx, &v32); |
58 | + * following: | 38 | break; |
59 | + */ | 39 | case KVM_REG_SIZE_U64: |
60 | + usr1 = s->usr1 & s->ucr1 & (USR1_TRDY | USR1_RRDY); | 40 | - r.addr = (uintptr_t)(cpu->cpreg_values + i); |
61 | + /* | 41 | + ret = kvm_set_one_reg(cs, regidx, cpu->cpreg_values + i); |
62 | + * Bits that we want in USR2 are not as conveniently laid out, | 42 | break; |
63 | + * unfortunately. | 43 | default: |
64 | + */ | 44 | g_assert_not_reached(); |
65 | + mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0; | 45 | } |
66 | + usr2 = s->usr2 & mask; | 46 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r); |
67 | 47 | if (ret) { | |
68 | - qemu_set_irq(s->irq, !!flags); | 48 | /* We might fail for "unknown register" and also for |
69 | + qemu_set_irq(s->irq, usr1 || usr2); | 49 | * "you tried to set a register which is constant with |
50 | @@ -XXX,XX +XXX,XX @@ void kvm_arm_get_virtual_time(CPUState *cs) | ||
51 | void kvm_arm_put_virtual_time(CPUState *cs) | ||
52 | { | ||
53 | ARMCPU *cpu = ARM_CPU(cs); | ||
54 | - struct kvm_one_reg reg = { | ||
55 | - .id = KVM_REG_ARM_TIMER_CNT, | ||
56 | - .addr = (uintptr_t)&cpu->kvm_vtime, | ||
57 | - }; | ||
58 | int ret; | ||
59 | |||
60 | if (!cpu->kvm_vtime_dirty) { | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
65 | + ret = kvm_set_one_reg(cs, KVM_REG_ARM_TIMER_CNT, &cpu->kvm_vtime); | ||
66 | if (ret) { | ||
67 | error_report("Failed to set KVM_REG_ARM_TIMER_CNT"); | ||
68 | abort(); | ||
69 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
70 | index XXXXXXX..XXXXXXX 100644 | ||
71 | --- a/target/arm/kvm64.c | ||
72 | +++ b/target/arm/kvm64.c | ||
73 | @@ -XXX,XX +XXX,XX @@ static int kvm_arm_sve_set_vls(CPUState *cs) | ||
74 | { | ||
75 | ARMCPU *cpu = ARM_CPU(cs); | ||
76 | uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq.map }; | ||
77 | - struct kvm_one_reg reg = { | ||
78 | - .id = KVM_REG_ARM64_SVE_VLS, | ||
79 | - .addr = (uint64_t)&vls[0], | ||
80 | - }; | ||
81 | |||
82 | assert(cpu->sve_max_vq <= KVM_ARM64_SVE_VQ_MAX); | ||
83 | |||
84 | - return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
85 | + return kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_VLS, &vls[0]); | ||
70 | } | 86 | } |
71 | 87 | ||
72 | static void imx_serial_reset(IMXSerialState *s) | 88 | #define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 |
89 | @@ -XXX,XX +XXX,XX @@ static void kvm_inject_arm_sea(CPUState *c) | ||
90 | static int kvm_arch_put_fpsimd(CPUState *cs) | ||
91 | { | ||
92 | CPUARMState *env = &ARM_CPU(cs)->env; | ||
93 | - struct kvm_one_reg reg; | ||
94 | int i, ret; | ||
95 | |||
96 | for (i = 0; i < 32; i++) { | ||
97 | uint64_t *q = aa64_vfp_qreg(env, i); | ||
98 | #if HOST_BIG_ENDIAN | ||
99 | uint64_t fp_val[2] = { q[1], q[0] }; | ||
100 | - reg.addr = (uintptr_t)fp_val; | ||
101 | + ret = kvm_set_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]), | ||
102 | + fp_val); | ||
103 | #else | ||
104 | - reg.addr = (uintptr_t)q; | ||
105 | + ret = kvm_set_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]), q); | ||
106 | #endif | ||
107 | - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
108 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
109 | if (ret) { | ||
110 | return ret; | ||
111 | } | ||
112 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs) | ||
113 | CPUARMState *env = &cpu->env; | ||
114 | uint64_t tmp[ARM_MAX_VQ * 2]; | ||
115 | uint64_t *r; | ||
116 | - struct kvm_one_reg reg; | ||
117 | int n, ret; | ||
118 | |||
119 | for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { | ||
120 | r = sve_bswap64(tmp, &env->vfp.zregs[n].d[0], cpu->sve_max_vq * 2); | ||
121 | - reg.addr = (uintptr_t)r; | ||
122 | - reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0); | ||
123 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
124 | + ret = kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_ZREG(n, 0), r); | ||
125 | if (ret) { | ||
126 | return ret; | ||
127 | } | ||
128 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs) | ||
129 | for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { | ||
130 | r = sve_bswap64(tmp, r = &env->vfp.pregs[n].p[0], | ||
131 | DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); | ||
132 | - reg.addr = (uintptr_t)r; | ||
133 | - reg.id = KVM_REG_ARM64_SVE_PREG(n, 0); | ||
134 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
135 | + ret = kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_PREG(n, 0), r); | ||
136 | if (ret) { | ||
137 | return ret; | ||
138 | } | ||
139 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs) | ||
140 | |||
141 | r = sve_bswap64(tmp, &env->vfp.pregs[FFR_PRED_NUM].p[0], | ||
142 | DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); | ||
143 | - reg.addr = (uintptr_t)r; | ||
144 | - reg.id = KVM_REG_ARM64_SVE_FFR(0); | ||
145 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
146 | + ret = kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_FFR(0), r); | ||
147 | if (ret) { | ||
148 | return ret; | ||
149 | } | ||
150 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_put_sve(CPUState *cs) | ||
151 | |||
152 | int kvm_arch_put_registers(CPUState *cs, int level) | ||
153 | { | ||
154 | - struct kvm_one_reg reg; | ||
155 | uint64_t val; | ||
156 | uint32_t fpr; | ||
157 | int i, ret; | ||
158 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
159 | } | ||
160 | |||
161 | for (i = 0; i < 31; i++) { | ||
162 | - reg.id = AARCH64_CORE_REG(regs.regs[i]); | ||
163 | - reg.addr = (uintptr_t) &env->xregs[i]; | ||
164 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
165 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.regs[i]), | ||
166 | + &env->xregs[i]); | ||
167 | if (ret) { | ||
168 | return ret; | ||
169 | } | ||
170 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
171 | */ | ||
172 | aarch64_save_sp(env, 1); | ||
173 | |||
174 | - reg.id = AARCH64_CORE_REG(regs.sp); | ||
175 | - reg.addr = (uintptr_t) &env->sp_el[0]; | ||
176 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
177 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.sp), &env->sp_el[0]); | ||
178 | if (ret) { | ||
179 | return ret; | ||
180 | } | ||
181 | |||
182 | - reg.id = AARCH64_CORE_REG(sp_el1); | ||
183 | - reg.addr = (uintptr_t) &env->sp_el[1]; | ||
184 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
185 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(sp_el1), &env->sp_el[1]); | ||
186 | if (ret) { | ||
187 | return ret; | ||
188 | } | ||
189 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
190 | } else { | ||
191 | val = cpsr_read(env); | ||
192 | } | ||
193 | - reg.id = AARCH64_CORE_REG(regs.pstate); | ||
194 | - reg.addr = (uintptr_t) &val; | ||
195 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
196 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.pstate), &val); | ||
197 | if (ret) { | ||
198 | return ret; | ||
199 | } | ||
200 | |||
201 | - reg.id = AARCH64_CORE_REG(regs.pc); | ||
202 | - reg.addr = (uintptr_t) &env->pc; | ||
203 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
204 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(regs.pc), &env->pc); | ||
205 | if (ret) { | ||
206 | return ret; | ||
207 | } | ||
208 | |||
209 | - reg.id = AARCH64_CORE_REG(elr_el1); | ||
210 | - reg.addr = (uintptr_t) &env->elr_el[1]; | ||
211 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
212 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(elr_el1), &env->elr_el[1]); | ||
213 | if (ret) { | ||
214 | return ret; | ||
215 | } | ||
216 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
217 | |||
218 | /* KVM 0-4 map to QEMU banks 1-5 */ | ||
219 | for (i = 0; i < KVM_NR_SPSR; i++) { | ||
220 | - reg.id = AARCH64_CORE_REG(spsr[i]); | ||
221 | - reg.addr = (uintptr_t) &env->banked_spsr[i + 1]; | ||
222 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
223 | + ret = kvm_set_one_reg(cs, AARCH64_CORE_REG(spsr[i]), | ||
224 | + &env->banked_spsr[i + 1]); | ||
225 | if (ret) { | ||
226 | return ret; | ||
227 | } | ||
228 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
229 | return ret; | ||
230 | } | ||
231 | |||
232 | - reg.addr = (uintptr_t)(&fpr); | ||
233 | fpr = vfp_get_fpsr(env); | ||
234 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
235 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
236 | + ret = kvm_set_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpsr), &fpr); | ||
237 | if (ret) { | ||
238 | return ret; | ||
239 | } | ||
240 | |||
241 | - reg.addr = (uintptr_t)(&fpr); | ||
242 | fpr = vfp_get_fpcr(env); | ||
243 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
244 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); | ||
245 | + ret = kvm_set_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpcr), &fpr); | ||
246 | if (ret) { | ||
247 | return ret; | ||
248 | } | ||
73 | -- | 249 | -- |
74 | 2.16.2 | 250 | 2.34.1 |
75 | 251 | ||
76 | 252 | diff view generated by jsdifflib |
1 | From: Andrey Smirnov <andrew.smirnov@gmail.com> | 1 | From: Cornelia Huck <cohuck@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Add support for "TX complete"/TXDC interrupt generate by real HW since | 3 | We can neaten the code by switching the callers that work on a |
4 | it is needed to support guests other than Linux. | 4 | CPUstate to the kvm_get_one_reg function. |
5 | 5 | ||
6 | Based on the patch by Bill Paul as found here: | 6 | Reviewed-by: Gavin Shan <gshan@redhat.com> |
7 | https://bugs.launchpad.net/qemu/+bug/1753314 | 7 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> |
8 | 8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
9 | Cc: qemu-devel@nongnu.org | 9 | Message-id: 20231010142453.224369-3-cohuck@redhat.com |
10 | Cc: qemu-arm@nongnu.org | ||
11 | Cc: Bill Paul <wpaul@windriver.com> | ||
12 | Cc: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Bill Paul <wpaul@windriver.com> | ||
14 | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> | ||
15 | Message-id: 20180315191141.6789-2-andrew.smirnov@gmail.com | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | --- | 12 | --- |
19 | include/hw/char/imx_serial.h | 3 +++ | 13 | target/arm/kvm.c | 15 +++--------- |
20 | hw/char/imx_serial.c | 20 +++++++++++++++++--- | 14 | target/arm/kvm64.c | 57 ++++++++++++---------------------------------- |
21 | 2 files changed, 20 insertions(+), 3 deletions(-) | 15 | 2 files changed, 18 insertions(+), 54 deletions(-) |
22 | 16 | ||
23 | diff --git a/include/hw/char/imx_serial.h b/include/hw/char/imx_serial.h | 17 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c |
24 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/include/hw/char/imx_serial.h | 19 | --- a/target/arm/kvm.c |
26 | +++ b/include/hw/char/imx_serial.h | 20 | +++ b/target/arm/kvm.c |
27 | @@ -XXX,XX +XXX,XX @@ | 21 | @@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu) |
28 | #define UCR2_RXEN (1<<1) /* Receiver enable */ | 22 | bool ok = true; |
29 | #define UCR2_SRST (1<<0) /* Reset complete */ | 23 | |
30 | 24 | for (i = 0; i < cpu->cpreg_array_len; i++) { | |
31 | +#define UCR4_TCEN BIT(3) /* TX complete interrupt enable */ | 25 | - struct kvm_one_reg r; |
32 | + | 26 | uint64_t regidx = cpu->cpreg_indexes[i]; |
33 | #define UTS1_TXEMPTY (1<<6) | 27 | uint32_t v32; |
34 | #define UTS1_RXEMPTY (1<<5) | 28 | int ret; |
35 | #define UTS1_TXFULL (1<<4) | 29 | |
36 | @@ -XXX,XX +XXX,XX @@ typedef struct IMXSerialState { | 30 | - r.id = regidx; |
37 | uint32_t ubmr; | 31 | - |
38 | uint32_t ubrc; | 32 | switch (regidx & KVM_REG_SIZE_MASK) { |
39 | uint32_t ucr3; | 33 | case KVM_REG_SIZE_U32: |
40 | + uint32_t ucr4; | 34 | - r.addr = (uintptr_t)&v32; |
41 | 35 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r); | |
42 | qemu_irq irq; | 36 | + ret = kvm_get_one_reg(cs, regidx, &v32); |
43 | CharBackend chr; | 37 | if (!ret) { |
44 | diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c | 38 | cpu->cpreg_values[i] = v32; |
39 | } | ||
40 | break; | ||
41 | case KVM_REG_SIZE_U64: | ||
42 | - r.addr = (uintptr_t)(cpu->cpreg_values + i); | ||
43 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r); | ||
44 | + ret = kvm_get_one_reg(cs, regidx, cpu->cpreg_values + i); | ||
45 | break; | ||
46 | default: | ||
47 | g_assert_not_reached(); | ||
48 | @@ -XXX,XX +XXX,XX @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu) | ||
49 | void kvm_arm_get_virtual_time(CPUState *cs) | ||
50 | { | ||
51 | ARMCPU *cpu = ARM_CPU(cs); | ||
52 | - struct kvm_one_reg reg = { | ||
53 | - .id = KVM_REG_ARM_TIMER_CNT, | ||
54 | - .addr = (uintptr_t)&cpu->kvm_vtime, | ||
55 | - }; | ||
56 | int ret; | ||
57 | |||
58 | if (cpu->kvm_vtime_dirty) { | ||
59 | return; | ||
60 | } | ||
61 | |||
62 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
63 | + ret = kvm_get_one_reg(cs, KVM_REG_ARM_TIMER_CNT, &cpu->kvm_vtime); | ||
64 | if (ret) { | ||
65 | error_report("Failed to get KVM_REG_ARM_TIMER_CNT"); | ||
66 | abort(); | ||
67 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | 68 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/hw/char/imx_serial.c | 69 | --- a/target/arm/kvm64.c |
47 | +++ b/hw/char/imx_serial.c | 70 | +++ b/target/arm/kvm64.c |
48 | @@ -XXX,XX +XXX,XX @@ | 71 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) |
49 | 72 | static int kvm_arch_get_fpsimd(CPUState *cs) | |
50 | static const VMStateDescription vmstate_imx_serial = { | 73 | { |
51 | .name = TYPE_IMX_SERIAL, | 74 | CPUARMState *env = &ARM_CPU(cs)->env; |
52 | - .version_id = 1, | 75 | - struct kvm_one_reg reg; |
53 | - .minimum_version_id = 1, | 76 | int i, ret; |
54 | + .version_id = 2, | 77 | |
55 | + .minimum_version_id = 2, | 78 | for (i = 0; i < 32; i++) { |
56 | .fields = (VMStateField[]) { | 79 | uint64_t *q = aa64_vfp_qreg(env, i); |
57 | VMSTATE_INT32(readbuff, IMXSerialState), | 80 | - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); |
58 | VMSTATE_UINT32(usr1, IMXSerialState), | 81 | - reg.addr = (uintptr_t)q; |
59 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_serial = { | 82 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); |
60 | VMSTATE_UINT32(ubmr, IMXSerialState), | 83 | + ret = kvm_get_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]), q); |
61 | VMSTATE_UINT32(ubrc, IMXSerialState), | 84 | if (ret) { |
62 | VMSTATE_UINT32(ucr3, IMXSerialState), | 85 | return ret; |
63 | + VMSTATE_UINT32(ucr4, IMXSerialState), | 86 | } else { |
64 | VMSTATE_END_OF_LIST() | 87 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs) |
65 | }, | 88 | { |
66 | }; | 89 | ARMCPU *cpu = ARM_CPU(cs); |
67 | @@ -XXX,XX +XXX,XX @@ static void imx_update(IMXSerialState *s) | 90 | CPUARMState *env = &cpu->env; |
68 | * unfortunately. | 91 | - struct kvm_one_reg reg; |
92 | uint64_t *r; | ||
93 | int n, ret; | ||
94 | |||
95 | for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { | ||
96 | r = &env->vfp.zregs[n].d[0]; | ||
97 | - reg.addr = (uintptr_t)r; | ||
98 | - reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0); | ||
99 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
100 | + ret = kvm_get_one_reg(cs, KVM_REG_ARM64_SVE_ZREG(n, 0), r); | ||
101 | if (ret) { | ||
102 | return ret; | ||
103 | } | ||
104 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs) | ||
105 | |||
106 | for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { | ||
107 | r = &env->vfp.pregs[n].p[0]; | ||
108 | - reg.addr = (uintptr_t)r; | ||
109 | - reg.id = KVM_REG_ARM64_SVE_PREG(n, 0); | ||
110 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
111 | + ret = kvm_get_one_reg(cs, KVM_REG_ARM64_SVE_PREG(n, 0), r); | ||
112 | if (ret) { | ||
113 | return ret; | ||
114 | } | ||
115 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs) | ||
116 | } | ||
117 | |||
118 | r = &env->vfp.pregs[FFR_PRED_NUM].p[0]; | ||
119 | - reg.addr = (uintptr_t)r; | ||
120 | - reg.id = KVM_REG_ARM64_SVE_FFR(0); | ||
121 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
122 | + ret = kvm_get_one_reg(cs, KVM_REG_ARM64_SVE_FFR(0), r); | ||
123 | if (ret) { | ||
124 | return ret; | ||
125 | } | ||
126 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs) | ||
127 | |||
128 | int kvm_arch_get_registers(CPUState *cs) | ||
129 | { | ||
130 | - struct kvm_one_reg reg; | ||
131 | uint64_t val; | ||
132 | unsigned int el; | ||
133 | uint32_t fpr; | ||
134 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
135 | CPUARMState *env = &cpu->env; | ||
136 | |||
137 | for (i = 0; i < 31; i++) { | ||
138 | - reg.id = AARCH64_CORE_REG(regs.regs[i]); | ||
139 | - reg.addr = (uintptr_t) &env->xregs[i]; | ||
140 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
141 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.regs[i]), | ||
142 | + &env->xregs[i]); | ||
143 | if (ret) { | ||
144 | return ret; | ||
145 | } | ||
146 | } | ||
147 | |||
148 | - reg.id = AARCH64_CORE_REG(regs.sp); | ||
149 | - reg.addr = (uintptr_t) &env->sp_el[0]; | ||
150 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
151 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.sp), &env->sp_el[0]); | ||
152 | if (ret) { | ||
153 | return ret; | ||
154 | } | ||
155 | |||
156 | - reg.id = AARCH64_CORE_REG(sp_el1); | ||
157 | - reg.addr = (uintptr_t) &env->sp_el[1]; | ||
158 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
159 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(sp_el1), &env->sp_el[1]); | ||
160 | if (ret) { | ||
161 | return ret; | ||
162 | } | ||
163 | |||
164 | - reg.id = AARCH64_CORE_REG(regs.pstate); | ||
165 | - reg.addr = (uintptr_t) &val; | ||
166 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
167 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.pstate), &val); | ||
168 | if (ret) { | ||
169 | return ret; | ||
170 | } | ||
171 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
69 | */ | 172 | */ |
70 | mask = (s->ucr1 & UCR1_TXMPTYEN) ? USR2_TXFE : 0; | 173 | aarch64_restore_sp(env, 1); |
71 | + /* | 174 | |
72 | + * TCEN and TXDC are both bit 3 | 175 | - reg.id = AARCH64_CORE_REG(regs.pc); |
73 | + */ | 176 | - reg.addr = (uintptr_t) &env->pc; |
74 | + mask |= s->ucr4 & UCR4_TCEN; | 177 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); |
75 | + | 178 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.pc), &env->pc); |
76 | usr2 = s->usr2 & mask; | 179 | if (ret) { |
77 | 180 | return ret; | |
78 | qemu_set_irq(s->irq, usr1 || usr2); | 181 | } |
79 | @@ -XXX,XX +XXX,XX @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset, | 182 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) |
80 | return s->ucr3; | 183 | aarch64_sync_64_to_32(env); |
81 | 184 | } | |
82 | case 0x23: /* UCR4 */ | 185 | |
83 | + return s->ucr4; | 186 | - reg.id = AARCH64_CORE_REG(elr_el1); |
84 | + | 187 | - reg.addr = (uintptr_t) &env->elr_el[1]; |
85 | case 0x29: /* BRM Incremental */ | 188 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); |
86 | return 0x0; /* TODO */ | 189 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(elr_el1), &env->elr_el[1]); |
87 | 190 | if (ret) { | |
88 | @@ -XXX,XX +XXX,XX @@ static void imx_serial_write(void *opaque, hwaddr offset, | 191 | return ret; |
89 | * qemu_chr_fe_write and background I/O callbacks */ | 192 | } |
90 | qemu_chr_fe_write_all(&s->chr, &ch, 1); | 193 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) |
91 | s->usr1 &= ~USR1_TRDY; | 194 | * KVM SPSRs 0-4 map to QEMU banks 1-5 |
92 | + s->usr2 &= ~USR2_TXDC; | 195 | */ |
93 | imx_update(s); | 196 | for (i = 0; i < KVM_NR_SPSR; i++) { |
94 | s->usr1 |= USR1_TRDY; | 197 | - reg.id = AARCH64_CORE_REG(spsr[i]); |
95 | + s->usr2 |= USR2_TXDC; | 198 | - reg.addr = (uintptr_t) &env->banked_spsr[i + 1]; |
96 | imx_update(s); | 199 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); |
97 | } | 200 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(spsr[i]), |
98 | break; | 201 | + &env->banked_spsr[i + 1]); |
99 | @@ -XXX,XX +XXX,XX @@ static void imx_serial_write(void *opaque, hwaddr offset, | 202 | if (ret) { |
100 | s->ucr3 = value & 0xffff; | 203 | return ret; |
101 | break; | 204 | } |
102 | 205 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | |
103 | - case 0x2d: /* UTS1 */ | 206 | return ret; |
104 | case 0x23: /* UCR4 */ | 207 | } |
105 | + s->ucr4 = value & 0xffff; | 208 | |
106 | + imx_update(s); | 209 | - reg.addr = (uintptr_t)(&fpr); |
107 | + break; | 210 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); |
108 | + | 211 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); |
109 | + case 0x2d: /* UTS1 */ | 212 | + ret = kvm_get_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpsr), &fpr); |
110 | qemu_log_mask(LOG_UNIMP, "[%s]%s: Unimplemented reg 0x%" | 213 | if (ret) { |
111 | HWADDR_PRIx "\n", TYPE_IMX_SERIAL, __func__, offset); | 214 | return ret; |
112 | /* TODO */ | 215 | } |
216 | vfp_set_fpsr(env, fpr); | ||
217 | |||
218 | - reg.addr = (uintptr_t)(&fpr); | ||
219 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); | ||
220 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
221 | + ret = kvm_get_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpcr), &fpr); | ||
222 | if (ret) { | ||
223 | return ret; | ||
224 | } | ||
113 | -- | 225 | -- |
114 | 2.16.2 | 226 | 2.34.1 |
115 | 227 | ||
116 | 228 | diff view generated by jsdifflib |
1 | The bcm2837 is pretty similar to the bcm2836, but it does have | 1 | For the Thumb T32 encoding of LDM, if only a single register is |
---|---|---|---|
2 | some differences. Notably, the MPIDR affinity aff1 values it | 2 | specified in the register list this instruction is UNPREDICTABLE, |
3 | sets for the CPUs are 0x0, rather than the 0xf that the bcm2836 | 3 | with the following choices: |
4 | uses, and if this is wrong Linux will not boot. | 4 | * instruction UNDEFs |
5 | * instruction is a NOP | ||
6 | * instruction loads a single register | ||
7 | * instruction loads an unspecified set of registers | ||
5 | 8 | ||
6 | Rather than trying to have one device with properties that | 9 | Currently we choose to UNDEF (a behaviour chosen in commit |
7 | configure it differently for the two cases, create two | 10 | 4b222545dbf30 in 2019; previously we treated it as "load the |
8 | separate QOM devices for the two SoCs. We use the same approach | 11 | specified single register"). |
9 | as hw/arm/aspeed_soc.c and share code and have a data table | ||
10 | that might differ per-SoC. For the moment the two types don't | ||
11 | actually have different behaviour. | ||
12 | 12 | ||
13 | Unfortunately there is real world code out there (which shipped in at | ||
14 | least Android 11, 12 and 13) which incorrectly uses this | ||
15 | UNPREDICTABLE insn on the assumption that it does a single register | ||
16 | load, which is (presumably) what it happens to do on real hardware, | ||
17 | and is also what it does on the equivalent A32 encoding. | ||
18 | |||
19 | Revert to the pre-4b222545dbf30 behaviour of not UNDEFing | ||
20 | for this T32 encoding. | ||
21 | |||
22 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1799 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 24 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
15 | Message-id: 20180313153458.26822-7-peter.maydell@linaro.org | 25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
26 | Message-id: 20230927101853.39288-1-peter.maydell@linaro.org | ||
16 | --- | 27 | --- |
17 | include/hw/arm/bcm2836.h | 19 +++++++++++++++++++ | 28 | target/arm/tcg/translate.c | 37 +++++++++++++++++++++++-------------- |
18 | hw/arm/bcm2836.c | 37 ++++++++++++++++++++++++++++++++----- | 29 | 1 file changed, 23 insertions(+), 14 deletions(-) |
19 | hw/arm/raspi.c | 3 ++- | ||
20 | 3 files changed, 53 insertions(+), 6 deletions(-) | ||
21 | 30 | ||
22 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h | 31 | diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c |
23 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/include/hw/arm/bcm2836.h | 33 | --- a/target/arm/tcg/translate.c |
25 | +++ b/include/hw/arm/bcm2836.h | 34 | +++ b/target/arm/tcg/translate.c |
26 | @@ -XXX,XX +XXX,XX @@ | 35 | @@ -XXX,XX +XXX,XX @@ static void op_addr_block_post(DisasContext *s, arg_ldst_block *a, |
27 | 36 | } | |
28 | #define BCM283X_NCPUS 4 | 37 | } |
29 | 38 | ||
30 | +/* These type names are for specific SoCs; other than instantiating | 39 | -static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n) |
31 | + * them, code using these devices should always handle them via the | 40 | +static bool op_stm(DisasContext *s, arg_ldst_block *a) |
32 | + * BCM283x base class, so they have no BCM2836(obj) etc macros. | ||
33 | + */ | ||
34 | +#define TYPE_BCM2836 "bcm2836" | ||
35 | +#define TYPE_BCM2837 "bcm2837" | ||
36 | + | ||
37 | typedef struct BCM283XState { | ||
38 | /*< private >*/ | ||
39 | DeviceState parent_obj; | ||
40 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM283XState { | ||
41 | BCM2835PeripheralState peripherals; | ||
42 | } BCM283XState; | ||
43 | |||
44 | +typedef struct BCM283XInfo BCM283XInfo; | ||
45 | + | ||
46 | +typedef struct BCM283XClass { | ||
47 | + DeviceClass parent_class; | ||
48 | + const BCM283XInfo *info; | ||
49 | +} BCM283XClass; | ||
50 | + | ||
51 | +#define BCM283X_CLASS(klass) \ | ||
52 | + OBJECT_CLASS_CHECK(BCM283XClass, (klass), TYPE_BCM283X) | ||
53 | +#define BCM283X_GET_CLASS(obj) \ | ||
54 | + OBJECT_GET_CLASS(BCM283XClass, (obj), TYPE_BCM283X) | ||
55 | + | ||
56 | #endif /* BCM2836_H */ | ||
57 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/hw/arm/bcm2836.c | ||
60 | +++ b/hw/arm/bcm2836.c | ||
61 | @@ -XXX,XX +XXX,XX @@ | ||
62 | /* "QA7" (Pi2) interrupt controller and mailboxes etc. */ | ||
63 | #define BCM2836_CONTROL_BASE 0x40000000 | ||
64 | |||
65 | +struct BCM283XInfo { | ||
66 | + const char *name; | ||
67 | +}; | ||
68 | + | ||
69 | +static const BCM283XInfo bcm283x_socs[] = { | ||
70 | + { | ||
71 | + .name = TYPE_BCM2836, | ||
72 | + }, | ||
73 | + { | ||
74 | + .name = TYPE_BCM2837, | ||
75 | + }, | ||
76 | +}; | ||
77 | + | ||
78 | static void bcm2836_init(Object *obj) | ||
79 | { | 41 | { |
80 | BCM283XState *s = BCM283X(obj); | 42 | int i, j, n, list, mem_idx; |
81 | @@ -XXX,XX +XXX,XX @@ static Property bcm2836_props[] = { | 43 | bool user = a->u; |
82 | DEFINE_PROP_END_OF_LIST() | 44 | @@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n) |
83 | }; | 45 | |
84 | 46 | list = a->list; | |
85 | -static void bcm2836_class_init(ObjectClass *oc, void *data) | 47 | n = ctpop16(list); |
86 | +static void bcm283x_class_init(ObjectClass *oc, void *data) | 48 | - if (n < min_n || a->rn == 15) { |
49 | + /* | ||
50 | + * This is UNPREDICTABLE for n < 1 in all encodings, and we choose | ||
51 | + * to UNDEF. In the T32 STM encoding n == 1 is also UNPREDICTABLE, | ||
52 | + * but hardware treats it like the A32 version and implements the | ||
53 | + * single-register-store, and some in-the-wild (buggy) software | ||
54 | + * assumes that, so we don't UNDEF on that case. | ||
55 | + */ | ||
56 | + if (n < 1 || a->rn == 15) { | ||
57 | unallocated_encoding(s); | ||
58 | return true; | ||
59 | } | ||
60 | @@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n) | ||
61 | |||
62 | static bool trans_STM(DisasContext *s, arg_ldst_block *a) | ||
87 | { | 63 | { |
88 | DeviceClass *dc = DEVICE_CLASS(oc); | 64 | - /* BitCount(list) < 1 is UNPREDICTABLE */ |
89 | + BCM283XClass *bc = BCM283X_CLASS(oc); | 65 | - return op_stm(s, a, 1); |
90 | 66 | + return op_stm(s, a); | |
91 | - dc->props = bcm2836_props; | ||
92 | + bc->info = data; | ||
93 | dc->realize = bcm2836_realize; | ||
94 | + dc->props = bcm2836_props; | ||
95 | } | 67 | } |
96 | 68 | ||
97 | -static const TypeInfo bcm2836_type_info = { | 69 | static bool trans_STM_t32(DisasContext *s, arg_ldst_block *a) |
98 | +static const TypeInfo bcm283x_type_info = { | 70 | @@ -XXX,XX +XXX,XX @@ static bool trans_STM_t32(DisasContext *s, arg_ldst_block *a) |
99 | .name = TYPE_BCM283X, | 71 | unallocated_encoding(s); |
100 | .parent = TYPE_DEVICE, | 72 | return true; |
101 | .instance_size = sizeof(BCM283XState), | 73 | } |
102 | .instance_init = bcm2836_init, | 74 | - /* BitCount(list) < 2 is UNPREDICTABLE */ |
103 | - .class_init = bcm2836_class_init, | 75 | - return op_stm(s, a, 2); |
104 | + .class_size = sizeof(BCM283XClass), | 76 | + return op_stm(s, a); |
105 | + .abstract = true, | 77 | } |
106 | }; | 78 | |
107 | 79 | -static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n) | |
108 | static void bcm2836_register_types(void) | 80 | +static bool do_ldm(DisasContext *s, arg_ldst_block *a) |
109 | { | 81 | { |
110 | - type_register_static(&bcm2836_type_info); | 82 | int i, j, n, list, mem_idx; |
111 | + int i; | 83 | bool loaded_base; |
112 | + | 84 | @@ -XXX,XX +XXX,XX @@ static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n) |
113 | + type_register_static(&bcm283x_type_info); | 85 | |
114 | + for (i = 0; i < ARRAY_SIZE(bcm283x_socs); i++) { | 86 | list = a->list; |
115 | + TypeInfo ti = { | 87 | n = ctpop16(list); |
116 | + .name = bcm283x_socs[i].name, | 88 | - if (n < min_n || a->rn == 15) { |
117 | + .parent = TYPE_BCM283X, | 89 | + /* |
118 | + .class_init = bcm283x_class_init, | 90 | + * This is UNPREDICTABLE for n < 1 in all encodings, and we choose |
119 | + .class_data = (void *) &bcm283x_socs[i], | 91 | + * to UNDEF. In the T32 LDM encoding n == 1 is also UNPREDICTABLE, |
120 | + }; | 92 | + * but hardware treats it like the A32 version and implements the |
121 | + type_register(&ti); | 93 | + * single-register-load, and some in-the-wild (buggy) software |
122 | + } | 94 | + * assumes that, so we don't UNDEF on that case. |
95 | + */ | ||
96 | + if (n < 1 || a->rn == 15) { | ||
97 | unallocated_encoding(s); | ||
98 | return true; | ||
99 | } | ||
100 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDM_a32(DisasContext *s, arg_ldst_block *a) | ||
101 | unallocated_encoding(s); | ||
102 | return true; | ||
103 | } | ||
104 | - /* BitCount(list) < 1 is UNPREDICTABLE */ | ||
105 | - return do_ldm(s, a, 1); | ||
106 | + return do_ldm(s, a); | ||
123 | } | 107 | } |
124 | 108 | ||
125 | type_init(bcm2836_register_types) | 109 | static bool trans_LDM_t32(DisasContext *s, arg_ldst_block *a) |
126 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 110 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDM_t32(DisasContext *s, arg_ldst_block *a) |
127 | index XXXXXXX..XXXXXXX 100644 | 111 | unallocated_encoding(s); |
128 | --- a/hw/arm/raspi.c | 112 | return true; |
129 | +++ b/hw/arm/raspi.c | 113 | } |
130 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) | 114 | - /* BitCount(list) < 2 is UNPREDICTABLE */ |
131 | BusState *bus; | 115 | - return do_ldm(s, a, 2); |
132 | DeviceState *carddev; | 116 | + return do_ldm(s, a); |
133 | 117 | } | |
134 | - object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X); | 118 | |
135 | + object_initialize(&s->soc, sizeof(s->soc), | 119 | static bool trans_LDM_t16(DisasContext *s, arg_ldst_block *a) |
136 | + version == 3 ? TYPE_BCM2837 : TYPE_BCM2836); | 120 | { |
137 | object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc), | 121 | /* Writeback is conditional on the base register not being loaded. */ |
138 | &error_abort); | 122 | a->w = !(a->list & (1 << a->rn)); |
139 | 123 | - /* BitCount(list) < 1 is UNPREDICTABLE */ | |
124 | - return do_ldm(s, a, 1); | ||
125 | + return do_ldm(s, a); | ||
126 | } | ||
127 | |||
128 | static bool trans_CLRM(DisasContext *s, arg_CLRM *a) | ||
140 | -- | 129 | -- |
141 | 2.16.2 | 130 | 2.34.1 |
142 | 131 | ||
143 | 132 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Update the SMMUv3 ID register bit field definitions to the | ||
2 | set in the most recent specification (IHI0700 F.a). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Reviewed-by: Mostafa Saleh <smostafa@google.com> | ||
7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
8 | Message-id: 20230914145705.1648377-2-peter.maydell@linaro.org | ||
9 | --- | ||
10 | hw/arm/smmuv3-internal.h | 38 ++++++++++++++++++++++++++++++++++++++ | ||
11 | 1 file changed, 38 insertions(+) | ||
12 | |||
13 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/arm/smmuv3-internal.h | ||
16 | +++ b/hw/arm/smmuv3-internal.h | ||
17 | @@ -XXX,XX +XXX,XX @@ REG32(IDR0, 0x0) | ||
18 | FIELD(IDR0, S1P, 1 , 1) | ||
19 | FIELD(IDR0, TTF, 2 , 2) | ||
20 | FIELD(IDR0, COHACC, 4 , 1) | ||
21 | + FIELD(IDR0, BTM, 5 , 1) | ||
22 | + FIELD(IDR0, HTTU, 6 , 2) | ||
23 | + FIELD(IDR0, DORMHINT, 8 , 1) | ||
24 | + FIELD(IDR0, HYP, 9 , 1) | ||
25 | + FIELD(IDR0, ATS, 10, 1) | ||
26 | + FIELD(IDR0, NS1ATS, 11, 1) | ||
27 | FIELD(IDR0, ASID16, 12, 1) | ||
28 | + FIELD(IDR0, MSI, 13, 1) | ||
29 | + FIELD(IDR0, SEV, 14, 1) | ||
30 | + FIELD(IDR0, ATOS, 15, 1) | ||
31 | + FIELD(IDR0, PRI, 16, 1) | ||
32 | + FIELD(IDR0, VMW, 17, 1) | ||
33 | FIELD(IDR0, VMID16, 18, 1) | ||
34 | + FIELD(IDR0, CD2L, 19, 1) | ||
35 | + FIELD(IDR0, VATOS, 20, 1) | ||
36 | FIELD(IDR0, TTENDIAN, 21, 2) | ||
37 | + FIELD(IDR0, ATSRECERR, 23, 1) | ||
38 | FIELD(IDR0, STALL_MODEL, 24, 2) | ||
39 | FIELD(IDR0, TERM_MODEL, 26, 1) | ||
40 | FIELD(IDR0, STLEVEL, 27, 2) | ||
41 | + FIELD(IDR0, RME_IMPL, 30, 1) | ||
42 | |||
43 | REG32(IDR1, 0x4) | ||
44 | FIELD(IDR1, SIDSIZE, 0 , 6) | ||
45 | + FIELD(IDR1, SSIDSIZE, 6 , 5) | ||
46 | + FIELD(IDR1, PRIQS, 11, 5) | ||
47 | FIELD(IDR1, EVENTQS, 16, 5) | ||
48 | FIELD(IDR1, CMDQS, 21, 5) | ||
49 | + FIELD(IDR1, ATTR_PERMS_OVR, 26, 1) | ||
50 | + FIELD(IDR1, ATTR_TYPES_OVR, 27, 1) | ||
51 | + FIELD(IDR1, REL, 28, 1) | ||
52 | + FIELD(IDR1, QUEUES_PRESET, 29, 1) | ||
53 | + FIELD(IDR1, TABLES_PRESET, 30, 1) | ||
54 | + FIELD(IDR1, ECMDQ, 31, 1) | ||
55 | |||
56 | #define SMMU_IDR1_SIDSIZE 16 | ||
57 | #define SMMU_CMDQS 19 | ||
58 | #define SMMU_EVENTQS 19 | ||
59 | |||
60 | REG32(IDR2, 0x8) | ||
61 | + FIELD(IDR2, BA_VATOS, 0, 10) | ||
62 | + | ||
63 | REG32(IDR3, 0xc) | ||
64 | FIELD(IDR3, HAD, 2, 1); | ||
65 | + FIELD(IDR3, PBHA, 3, 1); | ||
66 | + FIELD(IDR3, XNX, 4, 1); | ||
67 | + FIELD(IDR3, PPS, 5, 1); | ||
68 | + FIELD(IDR3, MPAM, 7, 1); | ||
69 | + FIELD(IDR3, FWB, 8, 1); | ||
70 | + FIELD(IDR3, STT, 9, 1); | ||
71 | FIELD(IDR3, RIL, 10, 1); | ||
72 | FIELD(IDR3, BBML, 11, 2); | ||
73 | + FIELD(IDR3, E0PD, 13, 1); | ||
74 | + FIELD(IDR3, PTWNNC, 14, 1); | ||
75 | + FIELD(IDR3, DPT, 15, 1); | ||
76 | + | ||
77 | REG32(IDR4, 0x10) | ||
78 | + | ||
79 | REG32(IDR5, 0x14) | ||
80 | FIELD(IDR5, OAS, 0, 3); | ||
81 | FIELD(IDR5, GRAN4K, 4, 1); | ||
82 | FIELD(IDR5, GRAN16K, 5, 1); | ||
83 | FIELD(IDR5, GRAN64K, 6, 1); | ||
84 | + FIELD(IDR5, VAX, 10, 2); | ||
85 | + FIELD(IDR5, STALL_MAX, 16, 16); | ||
86 | |||
87 | #define SMMU_IDR5_OAS 4 | ||
88 | |||
89 | -- | ||
90 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | In smmuv3_init_regs() when we set the various bits in the ID | ||
2 | registers, we do this almost in order of the fields in the | ||
3 | registers, but not quite. Move the initialization of | ||
4 | SMMU_IDR3.RIL and SMMU_IDR5.OAS into their correct places. | ||
1 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Mostafa Saleh <smostafa@google.com> | ||
9 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
10 | Message-id: 20230914145705.1648377-3-peter.maydell@linaro.org | ||
11 | --- | ||
12 | hw/arm/smmuv3.c | 4 ++-- | ||
13 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/arm/smmuv3.c | ||
18 | +++ b/hw/arm/smmuv3.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s) | ||
20 | s->idr[1] = FIELD_DP32(s->idr[1], IDR1, EVENTQS, SMMU_EVENTQS); | ||
21 | s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS, SMMU_CMDQS); | ||
22 | |||
23 | - s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1); | ||
24 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1); | ||
25 | + s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1); | ||
26 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2); | ||
27 | |||
28 | + s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */ | ||
29 | /* 4K, 16K and 64K granule support */ | ||
30 | s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN4K, 1); | ||
31 | s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN16K, 1); | ||
32 | s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN64K, 1); | ||
33 | - s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */ | ||
34 | |||
35 | s->cmdq.base = deposit64(s->cmdq.base, 0, 5, SMMU_CMDQS); | ||
36 | s->cmdq.prod = 0; | ||
37 | -- | ||
38 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The SMMUv3.1-XNX feature is mandatory for an SMMUv3.1 if S2P is | ||
2 | supported, so we should theoretically have implemented it as part of | ||
3 | the recent S2P work. Fortunately, for us the implementation is a | ||
4 | no-op. | ||
1 | 5 | ||
6 | This feature is about interpretation of the stage 2 page table | ||
7 | descriptor XN bits, which control execute permissions. | ||
8 | |||
9 | For QEMU, the permission bits passed to an IOMMU (via MemTxAttrs and | ||
10 | IOMMUAccessFlags) only indicate read and write; we do not distinguish | ||
11 | data reads from instruction reads outside the CPU proper. In the | ||
12 | SMMU architecture's terms, our interconnect between the client device | ||
13 | and the SMMU doesn't have the ability to convey the INST attribute, | ||
14 | and we therefore use the default value of "data" for this attribute. | ||
15 | |||
16 | We also do not support the bits in the Stream Table Entry that can | ||
17 | override the on-the-bus transaction attribute permissions (we do not | ||
18 | set SMMU_IDR1.ATTR_PERMS_OVR=1). | ||
19 | |||
20 | These two things together mean that for our implementation, it never | ||
21 | has to deal with transactions with the INST attribute, and so it can | ||
22 | correctly ignore the XN bits entirely. So we already implement | ||
23 | FEAT_XNX's "XN field is now 2 bits, not 1" behaviour to the extent | ||
24 | that we need to. | ||
25 | |||
26 | Advertise the presence of the feature in SMMU_IDR3.XNX. | ||
27 | |||
28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
29 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
30 | Reviewed-by: Mostafa Saleh <smostafa@google.com> | ||
31 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
32 | Message-id: 20230914145705.1648377-4-peter.maydell@linaro.org | ||
33 | --- | ||
34 | hw/arm/smmuv3.c | 4 ++++ | ||
35 | 1 file changed, 4 insertions(+) | ||
36 | |||
37 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/hw/arm/smmuv3.c | ||
40 | +++ b/hw/arm/smmuv3.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s) | ||
42 | s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS, SMMU_CMDQS); | ||
43 | |||
44 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1); | ||
45 | + if (FIELD_EX32(s->idr[0], IDR0, S2P)) { | ||
46 | + /* XNX is a stage-2-specific feature */ | ||
47 | + s->idr[3] = FIELD_DP32(s->idr[3], IDR3, XNX, 1); | ||
48 | + } | ||
49 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1); | ||
50 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2); | ||
51 | |||
52 | -- | ||
53 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | FEAT_HPMN0 is a small feature which defines that it is valid for | ||
2 | MDCR_EL2.HPMN to be set to 0, meaning "no PMU event counters provided | ||
3 | to an EL1 guest" (previously this setting was reserved). QEMU's | ||
4 | implementation almost gets HPMN == 0 right, but we need to fix | ||
5 | one check in pmevcntr_is_64_bit(). That is enough for us to | ||
6 | advertise the feature in the 'max' CPU. | ||
1 | 7 | ||
8 | (We don't need to make the behaviour conditional on feature | ||
9 | presence, because the FEAT_HPMN0 behaviour is within the range | ||
10 | of permitted UNPREDICTABLE behaviour for a non-FEAT_HPMN0 | ||
11 | implementation.) | ||
12 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20230921185445.3339214-1-peter.maydell@linaro.org | ||
16 | --- | ||
17 | docs/system/arm/emulation.rst | 1 + | ||
18 | target/arm/helper.c | 2 +- | ||
19 | target/arm/tcg/cpu32.c | 4 ++++ | ||
20 | target/arm/tcg/cpu64.c | 1 + | ||
21 | 4 files changed, 7 insertions(+), 1 deletion(-) | ||
22 | |||
23 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst | ||
24 | index XXXXXXX..XXXXXXX 100644 | ||
25 | --- a/docs/system/arm/emulation.rst | ||
26 | +++ b/docs/system/arm/emulation.rst | ||
27 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: | ||
28 | - FEAT_HCX (Support for the HCRX_EL2 register) | ||
29 | - FEAT_HPDS (Hierarchical permission disables) | ||
30 | - FEAT_HPDS2 (Translation table page-based hardware attributes) | ||
31 | +- FEAT_HPMN0 (Setting of MDCR_EL2.HPMN to zero) | ||
32 | - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) | ||
33 | - FEAT_IDST (ID space trap handling) | ||
34 | - FEAT_IESB (Implicit error synchronization event) | ||
35 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/target/arm/helper.c | ||
38 | +++ b/target/arm/helper.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static bool pmevcntr_is_64_bit(CPUARMState *env, int counter) | ||
40 | bool hlp = env->cp15.mdcr_el2 & MDCR_HLP; | ||
41 | int hpmn = env->cp15.mdcr_el2 & MDCR_HPMN; | ||
42 | |||
43 | - if (hpmn != 0 && counter >= hpmn) { | ||
44 | + if (counter >= hpmn) { | ||
45 | return hlp; | ||
46 | } | ||
47 | } | ||
48 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/target/arm/tcg/cpu32.c | ||
51 | +++ b/target/arm/tcg/cpu32.c | ||
52 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) | ||
53 | t = FIELD_DP32(t, ID_DFR0, COPSDBG, 9); /* FEAT_Debugv8p4 */ | ||
54 | t = FIELD_DP32(t, ID_DFR0, PERFMON, 6); /* FEAT_PMUv3p5 */ | ||
55 | cpu->isar.id_dfr0 = t; | ||
56 | + | ||
57 | + t = cpu->isar.id_dfr1; | ||
58 | + t = FIELD_DP32(t, ID_DFR1, HPMN0, 1); /* FEAT_HPMN0 */ | ||
59 | + cpu->isar.id_dfr1 = t; | ||
60 | } | ||
61 | |||
62 | /* CPU models. These are not needed for the AArch64 linux-user build. */ | ||
63 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/target/arm/tcg/cpu64.c | ||
66 | +++ b/target/arm/tcg/cpu64.c | ||
67 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) | ||
68 | t = cpu->isar.id_aa64dfr0; | ||
69 | t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */ | ||
70 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 6); /* FEAT_PMUv3p5 */ | ||
71 | + t = FIELD_DP64(t, ID_AA64DFR0, HPMN0, 1); /* FEAT_HPMN0 */ | ||
72 | cpu->isar.id_aa64dfr0 = t; | ||
73 | |||
74 | t = cpu->isar.id_aa64smfr0; | ||
75 | -- | ||
76 | 2.34.1 | diff view generated by jsdifflib |
1 | The raspi3 has AArch64 CPUs, which means that our smpboot | 1 | The include of hw/arm/virt.h in kvm64.c is unnecessary and also a |
---|---|---|---|
2 | code for keeping the secondary CPUs in a pen needs to have | 2 | layering violation since the generic KVM code shouldn't need to know |
3 | a version for A64 as well as A32. Without this, the | 3 | anything about board-specifics. The include line is an accidental |
4 | secondary CPUs go into an infinite loop of taking undefined | 4 | leftover from commit 15613357ba53a4763, where we cleaned up the code |
5 | instruction exceptions. | 5 | to not depend on virt board internals but forgot to also remove the |
6 | now-redundant include line. | ||
6 | 7 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 9 | Reviewed-by: Gavin Shan <gshan@redhat.com> |
9 | Message-id: 20180313153458.26822-10-peter.maydell@linaro.org | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Message-id: 20230925110429.3917202-1-peter.maydell@linaro.org | ||
10 | --- | 12 | --- |
11 | hw/arm/raspi.c | 41 ++++++++++++++++++++++++++++++++++++++++- | 13 | target/arm/kvm64.c | 1 - |
12 | 1 file changed, 40 insertions(+), 1 deletion(-) | 14 | 1 file changed, 1 deletion(-) |
13 | 15 | ||
14 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 16 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/raspi.c | 18 | --- a/target/arm/kvm64.c |
17 | +++ b/hw/arm/raspi.c | 19 | +++ b/target/arm/kvm64.c |
18 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
19 | #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */ | 21 | #include "internals.h" |
20 | #define FIRMWARE_ADDR_2 0x8000 /* Pi 2 loads kernel.img here by default */ | 22 | #include "hw/acpi/acpi.h" |
21 | #define FIRMWARE_ADDR_3 0x80000 /* Pi 3 loads kernel.img here by default */ | 23 | #include "hw/acpi/ghes.h" |
22 | +#define SPINTABLE_ADDR 0xd8 /* Pi 3 bootloader spintable */ | 24 | -#include "hw/arm/virt.h" |
23 | 25 | ||
24 | /* Table of Linux board IDs for different Pi versions */ | 26 | static bool have_guest_debug; |
25 | static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44}; | ||
26 | @@ -XXX,XX +XXX,XX @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) | ||
27 | info->smp_loader_start); | ||
28 | } | ||
29 | |||
30 | +static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info) | ||
31 | +{ | ||
32 | + /* Unlike the AArch32 version we don't need to call the board setup hook. | ||
33 | + * The mechanism for doing the spin-table is also entirely different. | ||
34 | + * We must have four 64-bit fields at absolute addresses | ||
35 | + * 0xd8, 0xe0, 0xe8, 0xf0 in RAM, which are the flag variables for | ||
36 | + * our CPUs, and which we must ensure are zero initialized before | ||
37 | + * the primary CPU goes into the kernel. We put these variables inside | ||
38 | + * a rom blob, so that the reset for ROM contents zeroes them for us. | ||
39 | + */ | ||
40 | + static const uint32_t smpboot[] = { | ||
41 | + 0xd2801b05, /* mov x5, 0xd8 */ | ||
42 | + 0xd53800a6, /* mrs x6, mpidr_el1 */ | ||
43 | + 0x924004c6, /* and x6, x6, #0x3 */ | ||
44 | + 0xd503205f, /* spin: wfe */ | ||
45 | + 0xf86678a4, /* ldr x4, [x5,x6,lsl #3] */ | ||
46 | + 0xb4ffffc4, /* cbz x4, spin */ | ||
47 | + 0xd2800000, /* mov x0, #0x0 */ | ||
48 | + 0xd2800001, /* mov x1, #0x0 */ | ||
49 | + 0xd2800002, /* mov x2, #0x0 */ | ||
50 | + 0xd2800003, /* mov x3, #0x0 */ | ||
51 | + 0xd61f0080, /* br x4 */ | ||
52 | + }; | ||
53 | + | ||
54 | + static const uint64_t spintables[] = { | ||
55 | + 0, 0, 0, 0 | ||
56 | + }; | ||
57 | + | ||
58 | + rom_add_blob_fixed("raspi_smpboot", smpboot, sizeof(smpboot), | ||
59 | + info->smp_loader_start); | ||
60 | + rom_add_blob_fixed("raspi_spintables", spintables, sizeof(spintables), | ||
61 | + SPINTABLE_ADDR); | ||
62 | +} | ||
63 | + | ||
64 | static void write_board_setup(ARMCPU *cpu, const struct arm_boot_info *info) | ||
65 | { | ||
66 | arm_write_secure_board_setup_dummy_smc(cpu, info, MVBAR_ADDR); | ||
67 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | ||
68 | /* Pi2 and Pi3 requires SMP setup */ | ||
69 | if (version >= 2) { | ||
70 | binfo.smp_loader_start = SMPBOOT_ADDR; | ||
71 | - binfo.write_secondary_boot = write_smpboot; | ||
72 | + if (version == 2) { | ||
73 | + binfo.write_secondary_boot = write_smpboot; | ||
74 | + } else { | ||
75 | + binfo.write_secondary_boot = write_smpboot64; | ||
76 | + } | ||
77 | binfo.secondary_cpu_reset_hook = reset_secondary; | ||
78 | } | ||
79 | 27 | ||
80 | -- | 28 | -- |
81 | 2.16.2 | 29 | 2.34.1 |
82 | 30 | ||
83 | 31 | diff view generated by jsdifflib |
1 | For the rpi1 and 2 we want to boot the Linux kernel via some | 1 | The hw/arm/boot.h include in common-semi-target.h is not actually |
---|---|---|---|
2 | custom setup code that makes sure that the SMC instruction | 2 | needed, and it's a bit odd because it pulls a hw/arm header into a |
3 | acts as a no-op, because it's used for cache maintenance. | 3 | target/arm file. |
4 | The rpi3 boots AArch64 kernels, which don't need SMC for | 4 | |
5 | cache maintenance and always expect to be booted non-secure. | 5 | This include was originally needed because the semihosting code used |
6 | Don't fill in the aarch32-specific parts of the binfo struct. | 6 | the arm_boot_info struct to get the base address of the RAM in system |
7 | emulation, to use in a (bad) heuristic for the return values for the | ||
8 | SYS_HEAPINFO semihosting call. We've since overhauled how we | ||
9 | calculate the HEAPINFO values in system emulation, and the code no | ||
10 | longer uses the arm_boot_info struct. | ||
11 | |||
12 | Remove the now-redundant include line, and instead directly include | ||
13 | the cpu-qom.h header that we were previously getting via boot.h. | ||
7 | 14 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 17 | Message-id: 20230925112219.3919261-1-peter.maydell@linaro.org |
11 | Message-id: 20180313153458.26822-2-peter.maydell@linaro.org | ||
12 | --- | 18 | --- |
13 | hw/arm/raspi.c | 17 +++++++++++++---- | 19 | target/arm/common-semi-target.h | 4 +--- |
14 | 1 file changed, 13 insertions(+), 4 deletions(-) | 20 | 1 file changed, 1 insertion(+), 3 deletions(-) |
15 | 21 | ||
16 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 22 | diff --git a/target/arm/common-semi-target.h b/target/arm/common-semi-target.h |
17 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/raspi.c | 24 | --- a/target/arm/common-semi-target.h |
19 | +++ b/hw/arm/raspi.c | 25 | +++ b/target/arm/common-semi-target.h |
20 | @@ -XXX,XX +XXX,XX @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) | 26 | @@ -XXX,XX +XXX,XX @@ |
21 | binfo.board_id = raspi_boardid[version]; | 27 | #ifndef TARGET_ARM_COMMON_SEMI_TARGET_H |
22 | binfo.ram_size = ram_size; | 28 | #define TARGET_ARM_COMMON_SEMI_TARGET_H |
23 | binfo.nb_cpus = smp_cpus; | 29 | |
24 | - binfo.board_setup_addr = BOARDSETUP_ADDR; | 30 | -#ifndef CONFIG_USER_ONLY |
25 | - binfo.write_board_setup = write_board_setup; | 31 | -#include "hw/arm/boot.h" |
26 | - binfo.secure_board_setup = true; | 32 | -#endif |
27 | - binfo.secure_boot = true; | 33 | +#include "target/arm/cpu-qom.h" |
28 | + | 34 | |
29 | + if (version <= 2) { | 35 | static inline target_ulong common_semi_arg(CPUState *cs, int argno) |
30 | + /* The rpi1 and 2 require some custom setup code to run in Secure | 36 | { |
31 | + * mode before booting a kernel (to set up the SMC vectors so | ||
32 | + * that we get a no-op SMC; this is used by Linux to call the | ||
33 | + * firmware for some cache maintenance operations. | ||
34 | + * The rpi3 doesn't need this. | ||
35 | + */ | ||
36 | + binfo.board_setup_addr = BOARDSETUP_ADDR; | ||
37 | + binfo.write_board_setup = write_board_setup; | ||
38 | + binfo.secure_board_setup = true; | ||
39 | + binfo.secure_boot = true; | ||
40 | + } | ||
41 | |||
42 | /* Pi2 and Pi3 requires SMP setup */ | ||
43 | if (version >= 2) { | ||
44 | -- | 37 | -- |
45 | 2.16.2 | 38 | 2.34.1 |
46 | |||
47 | diff view generated by jsdifflib |
1 | Add some assertions that if we're about to boot an AArch64 kernel, | 1 | The code for powering on a CPU in arm-powerctl.c has two separate |
---|---|---|---|
2 | the board code has not mistakenly set either secure_boot or | 2 | use cases: |
3 | secure_board_setup. It doesn't make sense to set secure_boot, | 3 | * emulation of a real hardware power controller |
4 | because all AArch64 kernels must be booted in non-secure mode. | 4 | * emulation of firmware interfaces (primarily PSCI) with |
5 | 5 | CPU on/off APIs | |
6 | It might in theory make sense to set secure_board_setup, but | 6 | |
7 | we don't currently support that, because only the AArch32 | 7 | For the first case, we only need to reset the CPU and set its |
8 | bootloader[] code calls this hook; bootloader_aarch64[] does not. | 8 | starting PC and X0. For the second case, because we're emulating the |
9 | Since we don't have a current need for this functionality, just | 9 | firmware we need to ensure that it's in the state that the firmware |
10 | assert that we don't try to use it. If it's needed we'll add | 10 | provides. In particular, when we reset to a lower EL than the |
11 | it later. | 11 | highest one we are emulating, we need to put the CPU into a state |
12 | 12 | that permits correct running at that lower EL. We already do a | |
13 | little of this in arm-powerctl.c (for instance we set SCR_HCE to | ||
14 | enable the HVC insn) but we don't do enough of it. This means that | ||
15 | in the case where we are emulating EL3 but also providing emulated | ||
16 | PSCI the guest will crash when a secondary core tries to use a | ||
17 | feature that needs an SCR_EL3 bit to be set, such as MTE or PAuth. | ||
18 | |||
19 | The hw/arm/boot.c code also has to support this "start guest code in | ||
20 | an EL that's lower than the highest emulated EL" case in order to do | ||
21 | direct guest kernel booting; it has all the necessary initialization | ||
22 | code to set the SCR_EL3 bits. Pull the relevant boot.c code out into | ||
23 | a separate function so we can share it between there and | ||
24 | arm-powerctl.c. | ||
25 | |||
26 | This refactoring has a few code changes that look like they | ||
27 | might be behaviour changes but aren't: | ||
28 | * if info->secure_boot is false and info->secure_board_setup is | ||
29 | true, then the old code would start the first CPU in Hyp | ||
30 | mode but without changing SCR.NS and NSACR.{CP11,CP10}. | ||
31 | This was wrong behaviour because there's no such thing | ||
32 | as Secure Hyp mode. The new code will leave the CPU in SVC. | ||
33 | (There is no board which sets secure_boot to false and | ||
34 | secure_board_setup to true, so this isn't a behaviour | ||
35 | change for any of our boards.) | ||
36 | * we don't explicitly clear SCR.NS when arm-powerctl.c | ||
37 | does a CPU-on to EL3. This was a no-op because CPU reset | ||
38 | will reset to NS == 0. | ||
39 | |||
40 | And some real behaviour changes: | ||
41 | * we no longer set HCR_EL2.RW when booting into EL2: the guest | ||
42 | can and should do that themselves before dropping into their | ||
43 | EL1 code. (arm-powerctl and boot did this differently; I | ||
44 | opted to use the logic from arm-powerctl, which only sets | ||
45 | HCR_EL2.RW when it's directly starting the guest in EL1, | ||
46 | because it's more correct, and I don't expect guests to be | ||
47 | accidentally depending on our having set the RW bit for them.) | ||
48 | * if we are booting a CPU into AArch32 Secure SVC then we won't | ||
49 | set SCR.HCE any more. This affects only the vexpress-a15 and | ||
50 | raspi2b machine types. Guests booting in this case will either: | ||
51 | - be able to set SCR.HCE themselves as part of moving from | ||
52 | Secure SVC into NS Hyp mode | ||
53 | - will move from Secure SVC to NS SVC, and won't care about | ||
54 | behaviour of the HVC insn | ||
55 | - will stay in Secure SVC, and won't care about HVC | ||
56 | * on an arm-powerctl CPU-on we will now set the SCR bits for | ||
57 | pauth/mte/sve/sme/hcx/fgt features | ||
58 | |||
59 | The first two of these are very minor and I don't expect guest | ||
60 | code to trip over them, so I didn't judge it worth convoluting | ||
61 | the code in an attempt to keep exactly the same boot.c behaviour. | ||
62 | The third change fixes issue 1899. | ||
63 | |||
64 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1899 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 65 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 66 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20180313153458.26822-3-peter.maydell@linaro.org | 67 | Message-id: 20230926155619.4028618-1-peter.maydell@linaro.org |
16 | --- | 68 | --- |
17 | hw/arm/boot.c | 7 +++++++ | 69 | target/arm/cpu.h | 22 +++++++++ |
18 | 1 file changed, 7 insertions(+) | 70 | hw/arm/boot.c | 95 ++++++++++----------------------------- |
19 | 71 | target/arm/arm-powerctl.c | 53 +--------------------- | |
72 | target/arm/cpu.c | 95 +++++++++++++++++++++++++++++++++++++++ | ||
73 | 4 files changed, 141 insertions(+), 124 deletions(-) | ||
74 | |||
75 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
76 | index XXXXXXX..XXXXXXX 100644 | ||
77 | --- a/target/arm/cpu.h | ||
78 | +++ b/target/arm/cpu.h | ||
79 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, | ||
80 | int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, | ||
81 | int cpuid, DumpState *s); | ||
82 | |||
83 | +/** | ||
84 | + * arm_emulate_firmware_reset: Emulate firmware CPU reset handling | ||
85 | + * @cpu: CPU (which must have been freshly reset) | ||
86 | + * @target_el: exception level to put the CPU into | ||
87 | + * @secure: whether to put the CPU in secure state | ||
88 | + * | ||
89 | + * When QEMU is directly running a guest kernel at a lower level than | ||
90 | + * EL3 it implicitly emulates some aspects of the guest firmware. | ||
91 | + * This includes that on reset we need to configure the parts of the | ||
92 | + * CPU corresponding to EL3 so that the real guest code can run at its | ||
93 | + * lower exception level. This function does that post-reset CPU setup, | ||
94 | + * for when we do direct boot of a guest kernel, and for when we | ||
95 | + * emulate PSCI and similar firmware interfaces starting a CPU at a | ||
96 | + * lower exception level. | ||
97 | + * | ||
98 | + * @target_el must be an EL implemented by the CPU between 1 and 3. | ||
99 | + * We do not support dropping into a Secure EL other than 3. | ||
100 | + * | ||
101 | + * It is the responsibility of the caller to call arm_rebuild_hflags(). | ||
102 | + */ | ||
103 | +void arm_emulate_firmware_reset(CPUState *cpustate, int target_el); | ||
104 | + | ||
105 | #ifdef TARGET_AARCH64 | ||
106 | int aarch64_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); | ||
107 | int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); | ||
20 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 108 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c |
21 | index XXXXXXX..XXXXXXX 100644 | 109 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/hw/arm/boot.c | 110 | --- a/hw/arm/boot.c |
23 | +++ b/hw/arm/boot.c | 111 | +++ b/hw/arm/boot.c |
24 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | 112 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) |
25 | } else { | 113 | |
26 | env->pstate = PSTATE_MODE_EL1h; | 114 | cpu_set_pc(cs, entry); |
27 | } | 115 | } else { |
28 | + /* AArch64 kernels never boot in secure mode */ | 116 | - /* If we are booting Linux then we need to check whether we are |
29 | + assert(!info->secure_boot); | 117 | - * booting into secure or non-secure state and adjust the state |
30 | + /* This hook is only supported for AArch32 currently: | 118 | - * accordingly. Out of reset, ARM is defined to be in secure state |
31 | + * bootloader_aarch64[] will not call the hook, and | 119 | - * (SCR.NS = 0), we change that here if non-secure boot has been |
32 | + * the code above has already dropped us into EL2 or EL1. | 120 | - * requested. |
33 | + */ | 121 | + /* |
34 | + assert(!info->secure_board_setup); | 122 | + * If we are booting Linux then we might need to do so at: |
35 | } | 123 | + * - AArch64 NS EL2 or NS EL1 |
36 | 124 | + * - AArch32 Secure SVC (EL3) | |
37 | /* Set to non-secure if not a secure boot */ | 125 | + * - AArch32 NS Hyp (EL2) |
126 | + * - AArch32 NS SVC (EL1) | ||
127 | + * Configure the CPU in the way boot firmware would do to | ||
128 | + * drop us down to the appropriate level. | ||
129 | */ | ||
130 | - if (arm_feature(env, ARM_FEATURE_EL3)) { | ||
131 | - /* AArch64 is defined to come out of reset into EL3 if enabled. | ||
132 | - * If we are booting Linux then we need to adjust our EL as | ||
133 | - * Linux expects us to be in EL2 or EL1. AArch32 resets into | ||
134 | - * SVC, which Linux expects, so no privilege/exception level to | ||
135 | - * adjust. | ||
136 | - */ | ||
137 | - if (env->aarch64) { | ||
138 | - env->cp15.scr_el3 |= SCR_RW; | ||
139 | - if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
140 | - env->cp15.hcr_el2 |= HCR_RW; | ||
141 | - env->pstate = PSTATE_MODE_EL2h; | ||
142 | - } else { | ||
143 | - env->pstate = PSTATE_MODE_EL1h; | ||
144 | - } | ||
145 | - if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
146 | - env->cp15.scr_el3 |= SCR_API | SCR_APK; | ||
147 | - } | ||
148 | - if (cpu_isar_feature(aa64_mte, cpu)) { | ||
149 | - env->cp15.scr_el3 |= SCR_ATA; | ||
150 | - } | ||
151 | - if (cpu_isar_feature(aa64_sve, cpu)) { | ||
152 | - env->cp15.cptr_el[3] |= R_CPTR_EL3_EZ_MASK; | ||
153 | - env->vfp.zcr_el[3] = 0xf; | ||
154 | - } | ||
155 | - if (cpu_isar_feature(aa64_sme, cpu)) { | ||
156 | - env->cp15.cptr_el[3] |= R_CPTR_EL3_ESM_MASK; | ||
157 | - env->cp15.scr_el3 |= SCR_ENTP2; | ||
158 | - env->vfp.smcr_el[3] = 0xf; | ||
159 | - } | ||
160 | - if (cpu_isar_feature(aa64_hcx, cpu)) { | ||
161 | - env->cp15.scr_el3 |= SCR_HXEN; | ||
162 | - } | ||
163 | - if (cpu_isar_feature(aa64_fgt, cpu)) { | ||
164 | - env->cp15.scr_el3 |= SCR_FGTEN; | ||
165 | - } | ||
166 | + int target_el = arm_feature(env, ARM_FEATURE_EL2) ? 2 : 1; | ||
167 | |||
168 | - /* AArch64 kernels never boot in secure mode */ | ||
169 | - assert(!info->secure_boot); | ||
170 | - /* This hook is only supported for AArch32 currently: | ||
171 | - * bootloader_aarch64[] will not call the hook, and | ||
172 | - * the code above has already dropped us into EL2 or EL1. | ||
173 | - */ | ||
174 | - assert(!info->secure_board_setup); | ||
175 | - } | ||
176 | - | ||
177 | - if (arm_feature(env, ARM_FEATURE_EL2)) { | ||
178 | - /* If we have EL2 then Linux expects the HVC insn to work */ | ||
179 | - env->cp15.scr_el3 |= SCR_HCE; | ||
180 | - } | ||
181 | - | ||
182 | - /* Set to non-secure if not a secure boot */ | ||
183 | - if (!info->secure_boot && | ||
184 | - (cs != first_cpu || !info->secure_board_setup)) { | ||
185 | - /* Linux expects non-secure state */ | ||
186 | - env->cp15.scr_el3 |= SCR_NS; | ||
187 | - /* Set NSACR.{CP11,CP10} so NS can access the FPU */ | ||
188 | - env->cp15.nsacr |= 3 << 10; | ||
189 | - } | ||
190 | - } | ||
191 | - | ||
192 | - if (!env->aarch64 && !info->secure_boot && | ||
193 | - arm_feature(env, ARM_FEATURE_EL2)) { | ||
194 | + if (env->aarch64) { | ||
195 | /* | ||
196 | - * This is an AArch32 boot not to Secure state, and | ||
197 | - * we have Hyp mode available, so boot the kernel into | ||
198 | - * Hyp mode. This is not how the CPU comes out of reset, | ||
199 | - * so we need to manually put it there. | ||
200 | + * AArch64 kernels never boot in secure mode, and we don't | ||
201 | + * support the secure_board_setup hook for AArch64. | ||
202 | */ | ||
203 | - cpsr_write(env, ARM_CPU_MODE_HYP, CPSR_M, CPSRWriteRaw); | ||
204 | + assert(!info->secure_boot); | ||
205 | + assert(!info->secure_board_setup); | ||
206 | + } else { | ||
207 | + if (arm_feature(env, ARM_FEATURE_EL3) && | ||
208 | + (info->secure_boot || | ||
209 | + (info->secure_board_setup && cs == first_cpu))) { | ||
210 | + /* Start this CPU in Secure SVC */ | ||
211 | + target_el = 3; | ||
212 | + } | ||
213 | } | ||
214 | |||
215 | + arm_emulate_firmware_reset(cs, target_el); | ||
216 | + | ||
217 | if (cs == first_cpu) { | ||
218 | AddressSpace *as = arm_boot_address_space(cpu, info); | ||
219 | |||
220 | diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c | ||
221 | index XXXXXXX..XXXXXXX 100644 | ||
222 | --- a/target/arm/arm-powerctl.c | ||
223 | +++ b/target/arm/arm-powerctl.c | ||
224 | @@ -XXX,XX +XXX,XX @@ static void arm_set_cpu_on_async_work(CPUState *target_cpu_state, | ||
225 | |||
226 | /* Initialize the cpu we are turning on */ | ||
227 | cpu_reset(target_cpu_state); | ||
228 | + arm_emulate_firmware_reset(target_cpu_state, info->target_el); | ||
229 | target_cpu_state->halted = 0; | ||
230 | |||
231 | - if (info->target_aa64) { | ||
232 | - if ((info->target_el < 3) && arm_feature(&target_cpu->env, | ||
233 | - ARM_FEATURE_EL3)) { | ||
234 | - /* | ||
235 | - * As target mode is AArch64, we need to set lower | ||
236 | - * exception level (the requested level 2) to AArch64 | ||
237 | - */ | ||
238 | - target_cpu->env.cp15.scr_el3 |= SCR_RW; | ||
239 | - } | ||
240 | - | ||
241 | - if ((info->target_el < 2) && arm_feature(&target_cpu->env, | ||
242 | - ARM_FEATURE_EL2)) { | ||
243 | - /* | ||
244 | - * As target mode is AArch64, we need to set lower | ||
245 | - * exception level (the requested level 1) to AArch64 | ||
246 | - */ | ||
247 | - target_cpu->env.cp15.hcr_el2 |= HCR_RW; | ||
248 | - } | ||
249 | - | ||
250 | - target_cpu->env.pstate = aarch64_pstate_mode(info->target_el, true); | ||
251 | - } else { | ||
252 | - /* We are requested to boot in AArch32 mode */ | ||
253 | - static const uint32_t mode_for_el[] = { 0, | ||
254 | - ARM_CPU_MODE_SVC, | ||
255 | - ARM_CPU_MODE_HYP, | ||
256 | - ARM_CPU_MODE_SVC }; | ||
257 | - | ||
258 | - cpsr_write(&target_cpu->env, mode_for_el[info->target_el], CPSR_M, | ||
259 | - CPSRWriteRaw); | ||
260 | - } | ||
261 | - | ||
262 | - if (info->target_el == 3) { | ||
263 | - /* Processor is in secure mode */ | ||
264 | - target_cpu->env.cp15.scr_el3 &= ~SCR_NS; | ||
265 | - } else { | ||
266 | - /* Processor is not in secure mode */ | ||
267 | - target_cpu->env.cp15.scr_el3 |= SCR_NS; | ||
268 | - | ||
269 | - /* Set NSACR.{CP11,CP10} so NS can access the FPU */ | ||
270 | - target_cpu->env.cp15.nsacr |= 3 << 10; | ||
271 | - | ||
272 | - /* | ||
273 | - * If QEMU is providing the equivalent of EL3 firmware, then we need | ||
274 | - * to make sure a CPU targeting EL2 comes out of reset with a | ||
275 | - * functional HVC insn. | ||
276 | - */ | ||
277 | - if (arm_feature(&target_cpu->env, ARM_FEATURE_EL3) | ||
278 | - && info->target_el == 2) { | ||
279 | - target_cpu->env.cp15.scr_el3 |= SCR_HCE; | ||
280 | - } | ||
281 | - } | ||
282 | - | ||
283 | /* We check if the started CPU is now at the correct level */ | ||
284 | assert(info->target_el == arm_current_el(&target_cpu->env)); | ||
285 | |||
286 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
287 | index XXXXXXX..XXXXXXX 100644 | ||
288 | --- a/target/arm/cpu.c | ||
289 | +++ b/target/arm/cpu.c | ||
290 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj) | ||
291 | } | ||
292 | } | ||
293 | |||
294 | +void arm_emulate_firmware_reset(CPUState *cpustate, int target_el) | ||
295 | +{ | ||
296 | + ARMCPU *cpu = ARM_CPU(cpustate); | ||
297 | + CPUARMState *env = &cpu->env; | ||
298 | + bool have_el3 = arm_feature(env, ARM_FEATURE_EL3); | ||
299 | + bool have_el2 = arm_feature(env, ARM_FEATURE_EL2); | ||
300 | + | ||
301 | + /* | ||
302 | + * Check we have the EL we're aiming for. If that is the | ||
303 | + * highest implemented EL, then cpu_reset has already done | ||
304 | + * all the work. | ||
305 | + */ | ||
306 | + switch (target_el) { | ||
307 | + case 3: | ||
308 | + assert(have_el3); | ||
309 | + return; | ||
310 | + case 2: | ||
311 | + assert(have_el2); | ||
312 | + if (!have_el3) { | ||
313 | + return; | ||
314 | + } | ||
315 | + break; | ||
316 | + case 1: | ||
317 | + if (!have_el3 && !have_el2) { | ||
318 | + return; | ||
319 | + } | ||
320 | + break; | ||
321 | + default: | ||
322 | + g_assert_not_reached(); | ||
323 | + } | ||
324 | + | ||
325 | + if (have_el3) { | ||
326 | + /* | ||
327 | + * Set the EL3 state so code can run at EL2. This should match | ||
328 | + * the requirements set by Linux in its booting spec. | ||
329 | + */ | ||
330 | + if (env->aarch64) { | ||
331 | + env->cp15.scr_el3 |= SCR_RW; | ||
332 | + if (cpu_isar_feature(aa64_pauth, cpu)) { | ||
333 | + env->cp15.scr_el3 |= SCR_API | SCR_APK; | ||
334 | + } | ||
335 | + if (cpu_isar_feature(aa64_mte, cpu)) { | ||
336 | + env->cp15.scr_el3 |= SCR_ATA; | ||
337 | + } | ||
338 | + if (cpu_isar_feature(aa64_sve, cpu)) { | ||
339 | + env->cp15.cptr_el[3] |= R_CPTR_EL3_EZ_MASK; | ||
340 | + env->vfp.zcr_el[3] = 0xf; | ||
341 | + } | ||
342 | + if (cpu_isar_feature(aa64_sme, cpu)) { | ||
343 | + env->cp15.cptr_el[3] |= R_CPTR_EL3_ESM_MASK; | ||
344 | + env->cp15.scr_el3 |= SCR_ENTP2; | ||
345 | + env->vfp.smcr_el[3] = 0xf; | ||
346 | + } | ||
347 | + if (cpu_isar_feature(aa64_hcx, cpu)) { | ||
348 | + env->cp15.scr_el3 |= SCR_HXEN; | ||
349 | + } | ||
350 | + if (cpu_isar_feature(aa64_fgt, cpu)) { | ||
351 | + env->cp15.scr_el3 |= SCR_FGTEN; | ||
352 | + } | ||
353 | + } | ||
354 | + | ||
355 | + if (target_el == 2) { | ||
356 | + /* If the guest is at EL2 then Linux expects the HVC insn to work */ | ||
357 | + env->cp15.scr_el3 |= SCR_HCE; | ||
358 | + } | ||
359 | + | ||
360 | + /* Put CPU into non-secure state */ | ||
361 | + env->cp15.scr_el3 |= SCR_NS; | ||
362 | + /* Set NSACR.{CP11,CP10} so NS can access the FPU */ | ||
363 | + env->cp15.nsacr |= 3 << 10; | ||
364 | + } | ||
365 | + | ||
366 | + if (have_el2 && target_el < 2) { | ||
367 | + /* Set EL2 state so code can run at EL1. */ | ||
368 | + if (env->aarch64) { | ||
369 | + env->cp15.hcr_el2 |= HCR_RW; | ||
370 | + } | ||
371 | + } | ||
372 | + | ||
373 | + /* Set the CPU to the desired state */ | ||
374 | + if (env->aarch64) { | ||
375 | + env->pstate = aarch64_pstate_mode(target_el, true); | ||
376 | + } else { | ||
377 | + static const uint32_t mode_for_el[] = { | ||
378 | + 0, | ||
379 | + ARM_CPU_MODE_SVC, | ||
380 | + ARM_CPU_MODE_HYP, | ||
381 | + ARM_CPU_MODE_SVC, | ||
382 | + }; | ||
383 | + | ||
384 | + cpsr_write(env, mode_for_el[target_el], CPSR_M, CPSRWriteRaw); | ||
385 | + } | ||
386 | +} | ||
387 | + | ||
388 | + | ||
389 | #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) | ||
390 | |||
391 | static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, | ||
38 | -- | 392 | -- |
39 | 2.16.2 | 393 | 2.34.1 |
40 | |||
41 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Chris Rauer <crauer@google.com> |
---|---|---|---|
2 | 2 | ||
3 | The sabrelite machine model used by qemu-system-arm is based on the | 3 | The counter register is only 24-bits and counts down. If the timer is |
4 | Freescale/NXP i.MX6Q processor. This SoC has an on-board ethernet | 4 | running but the qtimer to reset it hasn't fired off yet, there is a chance |
5 | controller which is supported in QEMU using the imx_fec.c module | 5 | the regster read can return an invalid result. |
6 | (actually called imx.enet for this model.) | ||
7 | 6 | ||
8 | The include/hw/arm/fsm-imx6.h file defines the interrupt vectors for the | 7 | Signed-off-by: Chris Rauer <crauer@google.com> |
9 | imx.enet device like this: | 8 | Message-id: 20230922181411.2697135-1-crauer@google.com |
10 | |||
11 | #define FSL_IMX6_ENET_MAC_1588_IRQ 118 | ||
12 | #define FSL_IMX6_ENET_MAC_IRQ 119 | ||
13 | |||
14 | According to https://www.nxp.com/docs/en/reference-manual/IMX6DQRM.pdf, | ||
15 | page 225, in Table 3-1. ARM Cortex A9 domain interrupt summary, | ||
16 | interrupts are as follows. | ||
17 | |||
18 | 150 ENET MAC 0 IRQ | ||
19 | 151 ENET MAC 0 1588 Timer interrupt | ||
20 | |||
21 | where | ||
22 | |||
23 | 150 - 32 == 118 | ||
24 | 151 - 32 == 119 | ||
25 | |||
26 | In other words, the vector definitions in the fsl-imx6.h file are reversed. | ||
27 | |||
28 | Fixing the interrupts alone causes problems with older Linux kernels: | ||
29 | The Ethernet interface will fail to probe with Linux v4.9 and earlier. | ||
30 | Linux v4.1 and earlier will crash due to a bug in Ethernet driver probe | ||
31 | error handling. This is a Linux kernel problem, not a qemu problem: | ||
32 | the Linux kernel only worked by accident since it requested both interrupts. | ||
33 | |||
34 | For backward compatibility, generate the Ethernet interrupt on both interrupt | ||
35 | lines. This was shown to work from all Linux kernel releases starting with | ||
36 | v3.16. | ||
37 | |||
38 | Link: https://bugs.launchpad.net/qemu/+bug/1753309 | ||
39 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
40 | Message-id: 1520723090-22130-1-git-send-email-linux@roeck-us.net | ||
41 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
42 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
43 | --- | 11 | --- |
44 | include/hw/arm/fsl-imx6.h | 4 ++-- | 12 | hw/timer/npcm7xx_timer.c | 3 +++ |
45 | hw/net/imx_fec.c | 28 +++++++++++++++++++++++++++- | 13 | 1 file changed, 3 insertions(+) |
46 | 2 files changed, 29 insertions(+), 3 deletions(-) | ||
47 | 14 | ||
48 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h | 15 | diff --git a/hw/timer/npcm7xx_timer.c b/hw/timer/npcm7xx_timer.c |
49 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
50 | --- a/include/hw/arm/fsl-imx6.h | 17 | --- a/hw/timer/npcm7xx_timer.c |
51 | +++ b/include/hw/arm/fsl-imx6.h | 18 | +++ b/hw/timer/npcm7xx_timer.c |
52 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX6State { | 19 | @@ -XXX,XX +XXX,XX @@ static int64_t npcm7xx_timer_count_to_ns(NPCM7xxTimer *t, uint32_t count) |
53 | #define FSL_IMX6_HDMI_MASTER_IRQ 115 | 20 | /* Convert a time interval in nanoseconds to a timer cycle count. */ |
54 | #define FSL_IMX6_HDMI_CEC_IRQ 116 | 21 | static uint32_t npcm7xx_timer_ns_to_count(NPCM7xxTimer *t, int64_t ns) |
55 | #define FSL_IMX6_MLB150_LOW_IRQ 117 | ||
56 | -#define FSL_IMX6_ENET_MAC_1588_IRQ 118 | ||
57 | -#define FSL_IMX6_ENET_MAC_IRQ 119 | ||
58 | +#define FSL_IMX6_ENET_MAC_IRQ 118 | ||
59 | +#define FSL_IMX6_ENET_MAC_1588_IRQ 119 | ||
60 | #define FSL_IMX6_PCIE1_IRQ 120 | ||
61 | #define FSL_IMX6_PCIE2_IRQ 121 | ||
62 | #define FSL_IMX6_PCIE3_IRQ 122 | ||
63 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/hw/net/imx_fec.c | ||
66 | +++ b/hw/net/imx_fec.c | ||
67 | @@ -XXX,XX +XXX,XX @@ static void imx_enet_write_bd(IMXENETBufDesc *bd, dma_addr_t addr) | ||
68 | |||
69 | static void imx_eth_update(IMXFECState *s) | ||
70 | { | 22 | { |
71 | - if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & ENET_INT_TS_TIMER) { | 23 | + if (ns < 0) { |
72 | + /* | 24 | + return 0; |
73 | + * Previous versions of qemu had the ENET_INT_MAC and ENET_INT_TS_TIMER | 25 | + } |
74 | + * interrupts swapped. This worked with older versions of Linux (4.14 | 26 | return clock_ns_to_ticks(t->ctrl->clock, ns) / |
75 | + * and older) since Linux associated both interrupt lines with Ethernet | 27 | npcm7xx_tcsr_prescaler(t->tcsr); |
76 | + * MAC interrupts. Specifically, | 28 | } |
77 | + * - Linux 4.15 and later have separate interrupt handlers for the MAC and | ||
78 | + * timer interrupts. Those versions of Linux fail with versions of QEMU | ||
79 | + * with swapped interrupt assignments. | ||
80 | + * - In linux 4.14, both interrupt lines were registered with the Ethernet | ||
81 | + * MAC interrupt handler. As a result, all versions of qemu happen to | ||
82 | + * work, though that is accidental. | ||
83 | + * - In Linux 4.9 and older, the timer interrupt was registered directly | ||
84 | + * with the Ethernet MAC interrupt handler. The MAC interrupt was | ||
85 | + * redirected to a GPIO interrupt to work around erratum ERR006687. | ||
86 | + * This was implemented using the SOC's IOMUX block. In qemu, this GPIO | ||
87 | + * interrupt never fired since IOMUX is currently not supported in qemu. | ||
88 | + * Linux instead received MAC interrupts on the timer interrupt. | ||
89 | + * As a result, qemu versions with the swapped interrupt assignment work, | ||
90 | + * albeit accidentally, but qemu versions with the correct interrupt | ||
91 | + * assignment fail. | ||
92 | + * | ||
93 | + * To ensure that all versions of Linux work, generate ENET_INT_MAC | ||
94 | + * interrrupts on both interrupt lines. This should be changed if and when | ||
95 | + * qemu supports IOMUX. | ||
96 | + */ | ||
97 | + if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & | ||
98 | + (ENET_INT_MAC | ENET_INT_TS_TIMER)) { | ||
99 | qemu_set_irq(s->irq[1], 1); | ||
100 | } else { | ||
101 | qemu_set_irq(s->irq[1], 0); | ||
102 | -- | 29 | -- |
103 | 2.16.2 | 30 | 2.34.1 |
104 | |||
105 | diff view generated by jsdifflib |
1 | Our BCM2836 type is really a generic one that can be any of | 1 | From: Suraj Shirvankar <surajshirvankar@gmail.com> |
---|---|---|---|
2 | the bcm283x family. Rename it accordingly. We change only | ||
3 | the names which are visible via the header file to the | ||
4 | rest of the QEMU code, leaving private function names | ||
5 | in bcm2836.c as they are. | ||
6 | 2 | ||
7 | This is a preliminary to making bcm283x be an abstract | 3 | QEMU coding style uses the glib memory allocation APIs, not |
8 | parent class to specific types for the bcm2836 and bcm2837. | 4 | the raw libc malloc/free. Switch the allocation and free |
5 | calls in elf2dmp to use these functions (dropping the now-unneeded | ||
6 | checks for failure). | ||
9 | 7 | ||
8 | Signed-off-by: Suraj Shirvankar <surajshirvankar@gmail.com> | ||
9 | Message-id: 169753938460.23804.11418813007617535750-1@git.sr.ht | ||
10 | [PMM: also remove NULL checks from g_malloc() calls; | ||
11 | beef up commit message] | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Andrew Baumann <Andrew.Baumann@microsoft.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-id: 20180313153458.26822-6-peter.maydell@linaro.org | ||
14 | --- | 14 | --- |
15 | include/hw/arm/bcm2836.h | 12 ++++++------ | 15 | contrib/elf2dmp/addrspace.c | 7 ++----- |
16 | hw/arm/bcm2836.c | 17 +++++++++-------- | 16 | contrib/elf2dmp/main.c | 9 +++------ |
17 | hw/arm/raspi.c | 16 ++++++++-------- | 17 | contrib/elf2dmp/pdb.c | 19 ++++++++----------- |
18 | 3 files changed, 23 insertions(+), 22 deletions(-) | 18 | contrib/elf2dmp/qemu_elf.c | 7 ++----- |
19 | 4 files changed, 15 insertions(+), 27 deletions(-) | ||
19 | 20 | ||
20 | diff --git a/include/hw/arm/bcm2836.h b/include/hw/arm/bcm2836.h | 21 | diff --git a/contrib/elf2dmp/addrspace.c b/contrib/elf2dmp/addrspace.c |
21 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/include/hw/arm/bcm2836.h | 23 | --- a/contrib/elf2dmp/addrspace.c |
23 | +++ b/include/hw/arm/bcm2836.h | 24 | +++ b/contrib/elf2dmp/addrspace.c |
24 | @@ -XXX,XX +XXX,XX @@ | 25 | @@ -XXX,XX +XXX,XX @@ int pa_space_create(struct pa_space *ps, QEMU_Elf *qemu_elf) |
25 | #include "hw/arm/bcm2835_peripherals.h" | 26 | } |
26 | #include "hw/intc/bcm2836_control.h" | 27 | } |
27 | 28 | ||
28 | -#define TYPE_BCM2836 "bcm2836" | 29 | - ps->block = malloc(sizeof(*ps->block) * ps->block_nr); |
29 | -#define BCM2836(obj) OBJECT_CHECK(BCM2836State, (obj), TYPE_BCM2836) | 30 | - if (!ps->block) { |
30 | +#define TYPE_BCM283X "bcm283x" | 31 | - return 1; |
31 | +#define BCM283X(obj) OBJECT_CHECK(BCM283XState, (obj), TYPE_BCM283X) | 32 | - } |
32 | 33 | + ps->block = g_new(struct pa_block, ps->block_nr); | |
33 | -#define BCM2836_NCPUS 4 | 34 | |
34 | +#define BCM283X_NCPUS 4 | 35 | for (i = 0; i < phdr_nr; i++) { |
35 | 36 | if (phdr[i].p_type == PT_LOAD) { | |
36 | -typedef struct BCM2836State { | 37 | @@ -XXX,XX +XXX,XX @@ int pa_space_create(struct pa_space *ps, QEMU_Elf *qemu_elf) |
37 | +typedef struct BCM283XState { | 38 | void pa_space_destroy(struct pa_space *ps) |
38 | /*< private >*/ | 39 | { |
39 | DeviceState parent_obj; | 40 | ps->block_nr = 0; |
40 | /*< public >*/ | 41 | - free(ps->block); |
41 | @@ -XXX,XX +XXX,XX @@ typedef struct BCM2836State { | 42 | + g_free(ps->block); |
42 | char *cpu_type; | 43 | } |
43 | uint32_t enabled_cpus; | 44 | |
44 | 45 | void va_space_set_dtb(struct va_space *vs, uint64_t dtb) | |
45 | - ARMCPU cpus[BCM2836_NCPUS]; | 46 | diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c |
46 | + ARMCPU cpus[BCM283X_NCPUS]; | ||
47 | BCM2836ControlState control; | ||
48 | BCM2835PeripheralState peripherals; | ||
49 | -} BCM2836State; | ||
50 | +} BCM283XState; | ||
51 | |||
52 | #endif /* BCM2836_H */ | ||
53 | diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c | ||
54 | index XXXXXXX..XXXXXXX 100644 | 47 | index XXXXXXX..XXXXXXX 100644 |
55 | --- a/hw/arm/bcm2836.c | 48 | --- a/contrib/elf2dmp/main.c |
56 | +++ b/hw/arm/bcm2836.c | 49 | +++ b/contrib/elf2dmp/main.c |
57 | @@ -XXX,XX +XXX,XX @@ | 50 | @@ -XXX,XX +XXX,XX @@ static KDDEBUGGER_DATA64 *get_kdbg(uint64_t KernBase, struct pdb_reader *pdb, |
58 | 51 | } | |
59 | static void bcm2836_init(Object *obj) | 52 | } |
53 | |||
54 | - kdbg = malloc(kdbg_hdr.Size); | ||
55 | - if (!kdbg) { | ||
56 | - return NULL; | ||
57 | - } | ||
58 | + kdbg = g_malloc(kdbg_hdr.Size); | ||
59 | |||
60 | if (va_space_rw(vs, KdDebuggerDataBlock, kdbg, kdbg_hdr.Size, 0)) { | ||
61 | eprintf("Failed to extract entire KDBG\n"); | ||
62 | - free(kdbg); | ||
63 | + g_free(kdbg); | ||
64 | return NULL; | ||
65 | } | ||
66 | |||
67 | @@ -XXX,XX +XXX,XX @@ int main(int argc, char *argv[]) | ||
68 | } | ||
69 | |||
70 | out_kdbg: | ||
71 | - free(kdbg); | ||
72 | + g_free(kdbg); | ||
73 | out_pdb: | ||
74 | pdb_exit(&pdb); | ||
75 | out_pdb_file: | ||
76 | diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c | ||
77 | index XXXXXXX..XXXXXXX 100644 | ||
78 | --- a/contrib/elf2dmp/pdb.c | ||
79 | +++ b/contrib/elf2dmp/pdb.c | ||
80 | @@ -XXX,XX +XXX,XX @@ uint64_t pdb_resolve(uint64_t img_base, struct pdb_reader *r, const char *name) | ||
81 | |||
82 | static void pdb_reader_ds_exit(struct pdb_reader *r) | ||
60 | { | 83 | { |
61 | - BCM2836State *s = BCM2836(obj); | 84 | - free(r->ds.toc); |
62 | + BCM283XState *s = BCM283X(obj); | 85 | + g_free(r->ds.toc); |
63 | 86 | } | |
64 | object_initialize(&s->control, sizeof(s->control), TYPE_BCM2836_CONTROL); | 87 | |
65 | object_property_add_child(obj, "control", OBJECT(&s->control), NULL); | 88 | static void pdb_exit_symbols(struct pdb_reader *r) |
66 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_init(Object *obj) | ||
67 | |||
68 | static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
69 | { | 89 | { |
70 | - BCM2836State *s = BCM2836(dev); | 90 | - free(r->modimage); |
71 | + BCM283XState *s = BCM283X(dev); | 91 | - free(r->symbols); |
72 | Object *obj; | 92 | + g_free(r->modimage); |
73 | Error *err = NULL; | 93 | + g_free(r->symbols); |
74 | int n; | ||
75 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
76 | /* common peripherals from bcm2835 */ | ||
77 | |||
78 | obj = OBJECT(dev); | ||
79 | - for (n = 0; n < BCM2836_NCPUS; n++) { | ||
80 | + for (n = 0; n < BCM283X_NCPUS; n++) { | ||
81 | object_initialize(&s->cpus[n], sizeof(s->cpus[n]), | ||
82 | s->cpu_type); | ||
83 | object_property_add_child(obj, "cpu[*]", OBJECT(&s->cpus[n]), | ||
84 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
85 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->peripherals), 1, | ||
86 | qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); | ||
87 | |||
88 | - for (n = 0; n < BCM2836_NCPUS; n++) { | ||
89 | + for (n = 0; n < BCM283X_NCPUS; n++) { | ||
90 | /* Mirror bcm2836, which has clusterid set to 0xf | ||
91 | * TODO: this should be converted to a property of ARM_CPU | ||
92 | */ | ||
93 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_realize(DeviceState *dev, Error **errp) | ||
94 | } | 94 | } |
95 | 95 | ||
96 | static Property bcm2836_props[] = { | 96 | static void pdb_exit_segments(struct pdb_reader *r) |
97 | - DEFINE_PROP_STRING("cpu-type", BCM2836State, cpu_type), | 97 | { |
98 | - DEFINE_PROP_UINT32("enabled-cpus", BCM2836State, enabled_cpus, BCM2836_NCPUS), | 98 | - free(r->segs); |
99 | + DEFINE_PROP_STRING("cpu-type", BCM283XState, cpu_type), | 99 | + g_free(r->segs); |
100 | + DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, | ||
101 | + BCM283X_NCPUS), | ||
102 | DEFINE_PROP_END_OF_LIST() | ||
103 | }; | ||
104 | |||
105 | @@ -XXX,XX +XXX,XX @@ static void bcm2836_class_init(ObjectClass *oc, void *data) | ||
106 | } | 100 | } |
107 | 101 | ||
108 | static const TypeInfo bcm2836_type_info = { | 102 | static void *pdb_ds_read(const PDB_DS_HEADER *header, |
109 | - .name = TYPE_BCM2836, | 103 | @@ -XXX,XX +XXX,XX @@ static void *pdb_ds_read(const PDB_DS_HEADER *header, |
110 | + .name = TYPE_BCM283X, | 104 | |
111 | .parent = TYPE_DEVICE, | 105 | nBlocks = (size + header->block_size - 1) / header->block_size; |
112 | - .instance_size = sizeof(BCM2836State), | 106 | |
113 | + .instance_size = sizeof(BCM283XState), | 107 | - buffer = malloc(nBlocks * header->block_size); |
114 | .instance_init = bcm2836_init, | 108 | - if (!buffer) { |
115 | .class_init = bcm2836_class_init, | 109 | - return NULL; |
116 | }; | 110 | - } |
117 | diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c | 111 | + buffer = g_malloc(nBlocks * header->block_size); |
112 | |||
113 | for (i = 0; i < nBlocks; i++) { | ||
114 | memcpy(buffer + i * header->block_size, (const char *)header + | ||
115 | @@ -XXX,XX +XXX,XX @@ static int pdb_init_symbols(struct pdb_reader *r) | ||
116 | return 0; | ||
117 | |||
118 | out_symbols: | ||
119 | - free(symbols); | ||
120 | + g_free(symbols); | ||
121 | |||
122 | return err; | ||
123 | } | ||
124 | @@ -XXX,XX +XXX,XX @@ static int pdb_reader_init(struct pdb_reader *r, void *data) | ||
125 | out_sym: | ||
126 | pdb_exit_symbols(r); | ||
127 | out_root: | ||
128 | - free(r->ds.root); | ||
129 | + g_free(r->ds.root); | ||
130 | out_ds: | ||
131 | pdb_reader_ds_exit(r); | ||
132 | |||
133 | @@ -XXX,XX +XXX,XX @@ static void pdb_reader_exit(struct pdb_reader *r) | ||
134 | { | ||
135 | pdb_exit_segments(r); | ||
136 | pdb_exit_symbols(r); | ||
137 | - free(r->ds.root); | ||
138 | + g_free(r->ds.root); | ||
139 | pdb_reader_ds_exit(r); | ||
140 | } | ||
141 | |||
142 | diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c | ||
118 | index XXXXXXX..XXXXXXX 100644 | 143 | index XXXXXXX..XXXXXXX 100644 |
119 | --- a/hw/arm/raspi.c | 144 | --- a/contrib/elf2dmp/qemu_elf.c |
120 | +++ b/hw/arm/raspi.c | 145 | +++ b/contrib/elf2dmp/qemu_elf.c |
121 | @@ -XXX,XX +XXX,XX @@ | 146 | @@ -XXX,XX +XXX,XX @@ static int init_states(QEMU_Elf *qe) |
122 | static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44}; | 147 | |
123 | 148 | printf("%zu CPU states has been found\n", cpu_nr); | |
124 | typedef struct RasPiState { | 149 | |
125 | - BCM2836State soc; | 150 | - qe->state = malloc(sizeof(*qe->state) * cpu_nr); |
126 | + BCM283XState soc; | 151 | - if (!qe->state) { |
127 | MemoryRegion ram; | 152 | - return 1; |
128 | } RasPiState; | 153 | - } |
129 | 154 | + qe->state = g_new(QEMUCPUState*, cpu_nr); | |
130 | @@ -XXX,XX +XXX,XX @@ static void raspi_init(MachineState *machine, int version) | 155 | |
131 | BusState *bus; | 156 | cpu_nr = 0; |
132 | DeviceState *carddev; | 157 | |
133 | 158 | @@ -XXX,XX +XXX,XX @@ static int init_states(QEMU_Elf *qe) | |
134 | - object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM2836); | 159 | |
135 | + object_initialize(&s->soc, sizeof(s->soc), TYPE_BCM283X); | 160 | static void exit_states(QEMU_Elf *qe) |
136 | object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc), | 161 | { |
137 | &error_abort); | 162 | - free(qe->state); |
138 | 163 | + g_free(qe->state); | |
139 | @@ -XXX,XX +XXX,XX @@ static void raspi2_machine_init(MachineClass *mc) | ||
140 | mc->no_floppy = 1; | ||
141 | mc->no_cdrom = 1; | ||
142 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); | ||
143 | - mc->max_cpus = BCM2836_NCPUS; | ||
144 | - mc->min_cpus = BCM2836_NCPUS; | ||
145 | - mc->default_cpus = BCM2836_NCPUS; | ||
146 | + mc->max_cpus = BCM283X_NCPUS; | ||
147 | + mc->min_cpus = BCM283X_NCPUS; | ||
148 | + mc->default_cpus = BCM283X_NCPUS; | ||
149 | mc->default_ram_size = 1024 * 1024 * 1024; | ||
150 | mc->ignore_memory_transaction_failures = true; | ||
151 | }; | ||
152 | @@ -XXX,XX +XXX,XX @@ static void raspi3_machine_init(MachineClass *mc) | ||
153 | mc->no_floppy = 1; | ||
154 | mc->no_cdrom = 1; | ||
155 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"); | ||
156 | - mc->max_cpus = BCM2836_NCPUS; | ||
157 | - mc->min_cpus = BCM2836_NCPUS; | ||
158 | - mc->default_cpus = BCM2836_NCPUS; | ||
159 | + mc->max_cpus = BCM283X_NCPUS; | ||
160 | + mc->min_cpus = BCM283X_NCPUS; | ||
161 | + mc->default_cpus = BCM283X_NCPUS; | ||
162 | mc->default_ram_size = 1024 * 1024 * 1024; | ||
163 | } | 164 | } |
164 | DEFINE_MACHINE("raspi3", raspi3_machine_init) | 165 | |
166 | static bool check_ehdr(QEMU_Elf *qe) | ||
165 | -- | 167 | -- |
166 | 2.16.2 | 168 | 2.34.1 |
167 | |||
168 | diff view generated by jsdifflib |