1 | arm pullreq for rc1. All minor bugfixes, except for the sve-default-vector-length | 1 | Hi; here's a queue of arm patches (plus a few elf2dmp changes); |
---|---|---|---|
2 | patches, which are somewhere between a bugfix and a new feature. | 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 c08ccd1b53f488ac86c1f65cf7623dc91acc249a: | 7 | The following changes since commit deaca3fd30d3a8829160f8d3705d65ad83176800: |
8 | 8 | ||
9 | Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210726' into staging (2021-07-27 08:35:01 +0100) | 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 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210727 | 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 e229a179a503f2aee43a76888cf12fbdfe8a3749: | 15 | for you to fetch changes up to 2a052b4ee01b3c413cef2ef49cb780cde17d4ba1: |
16 | 16 | ||
17 | hw: aspeed_gpio: Fix memory size (2021-07-27 11:00:00 +0100) | 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 | * hw/arm/smmuv3: Check 31st bit to see if CD is valid | 21 | * hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder |
22 | * qemu-options.hx: Fix formatting of -machine memory-backend option | 22 | * hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot' |
23 | * hw: aspeed_gpio: Fix memory size | 23 | * xlnx devices: remove deprecated device reset |
24 | * hw/arm/nseries: Display hexadecimal value with '0x' prefix | 24 | * xlnx-bbram: hw/nvram: Use dot in device type name |
25 | * Add sve-default-vector-length cpu property | 25 | * elf2dmp: fix coverity issues |
26 | * docs: Update path that mentions deprecated.rst | 26 | * elf2dmp: convert to g_malloc, g_new and g_free |
27 | * hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS | 27 | * target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0 |
28 | * hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING | 28 | * hw/arm: refactor virt PPI logic |
29 | * hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts | 29 | * arm/kvm: convert to kvm_set_one_reg, kvm_get_one_reg |
30 | * target/arm: Report M-profile alignment faults correctly to the guest | 30 | * target/arm: Permit T32 LDM with single register |
31 | * target/arm: Add missing 'return's after calling v7m_exception_taken() | 31 | * smmuv3: Advertise SMMUv3.1-XNX |
32 | * target/arm: Enforce that M-profile SP low 2 bits are always zero | 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 | ||
33 | 36 | ||
34 | ---------------------------------------------------------------- | 37 | ---------------------------------------------------------------- |
35 | Joe Komlodi (1): | 38 | Chris Rauer (1): |
36 | hw/arm/smmuv3: Check 31st bit to see if CD is valid | 39 | hw/timer/npcm7xx_timer: Prevent timer from counting down past zero |
37 | 40 | ||
38 | Joel Stanley (1): | 41 | Cornelia Huck (2): |
39 | hw: aspeed_gpio: Fix memory size | 42 | arm/kvm: convert to kvm_set_one_reg |
43 | arm/kvm: convert to kvm_get_one_reg | ||
40 | 44 | ||
41 | Mao Zhongyi (1): | 45 | Leif Lindholm (3): |
42 | docs: Update path that mentions deprecated.rst | 46 | {include/}hw/arm: refactor virt PPI logic |
47 | include/hw/arm: move BSA definitions to bsa.h | ||
48 | hw/arm/sbsa-ref: use bsa.h for PPI definitions | ||
43 | 49 | ||
44 | Peter Maydell (7): | 50 | Michal Orzel (1): |
45 | qemu-options.hx: Fix formatting of -machine memory-backend option | 51 | target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0 |
46 | target/arm: Enforce that M-profile SP low 2 bits are always zero | 52 | |
47 | target/arm: Add missing 'return's after calling v7m_exception_taken() | 53 | Peter Maydell (8): |
48 | target/arm: Report M-profile alignment faults correctly to the guest | 54 | target/arm: Permit T32 LDM with single register |
49 | hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts | 55 | hw/arm/smmuv3: Update ID register bit field definitions |
50 | hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING | 56 | hw/arm/smmuv3: Sort ID register setting into field order |
51 | hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS | 57 | hw/arm/smmuv3: Advertise SMMUv3.1-XNX feature |
58 | target/arm: Implement FEAT_HPMN0 | ||
59 | target/arm/kvm64.c: Remove unused include | ||
60 | target/arm/common-semi-target.h: Remove unnecessary boot.h include | ||
61 | target/arm/arm-powerctl: Correctly init CPUs when powered on to lower EL | ||
52 | 62 | ||
53 | Philippe Mathieu-Daudé (1): | 63 | Philippe Mathieu-Daudé (1): |
54 | hw/arm/nseries: Display hexadecimal value with '0x' prefix | 64 | hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot.h' |
55 | 65 | ||
56 | Richard Henderson (3): | 66 | Suraj Shirvankar (1): |
57 | target/arm: Correctly bound length in sve_zcr_get_valid_len | 67 | contrib/elf2dmp: Use g_malloc(), g_new() and g_free() |
58 | target/arm: Export aarch64_sve_zcr_get_valid_len | ||
59 | target/arm: Add sve-default-vector-length cpu property | ||
60 | 68 | ||
61 | docs/system/arm/cpu-features.rst | 15 ++++++++++ | 69 | Thomas Huth (1): |
62 | configure | 2 +- | 70 | hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder |
63 | hw/arm/smmuv3-internal.h | 2 +- | ||
64 | target/arm/cpu.h | 5 ++++ | ||
65 | target/arm/internals.h | 10 +++++++ | ||
66 | hw/arm/nseries.c | 2 +- | ||
67 | hw/gpio/aspeed_gpio.c | 3 +- | ||
68 | hw/intc/armv7m_nvic.c | 40 +++++++++++++++++++-------- | ||
69 | target/arm/cpu.c | 14 ++++++++-- | ||
70 | target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++++++++++ | ||
71 | target/arm/gdbstub.c | 4 +++ | ||
72 | target/arm/helper.c | 8 ++++-- | ||
73 | target/arm/m_helper.c | 24 ++++++++++++---- | ||
74 | target/arm/translate.c | 3 ++ | ||
75 | target/i386/cpu.c | 2 +- | ||
76 | MAINTAINERS | 2 +- | ||
77 | qemu-options.hx | 30 +++++++++++--------- | ||
78 | 17 files changed, 183 insertions(+), 43 deletions(-) | ||
79 | 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 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Missed in commit f3478392 "docs: Move deprecation, build | 3 | The file is obviously related to the raspberrypi machine, so |
4 | and license info out of system/" | 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. | ||
5 | 7 | ||
6 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 8 | Signed-off-by: Thomas Huth <thuth@redhat.com> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> |
8 | Message-id: 20210723065828.1336760-1-maozhongyi@cmss.chinamobile.com | 10 | Acked-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Message-id: 20231012073458.860187-1-thuth@redhat.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 13 | --- |
11 | configure | 2 +- | 14 | MAINTAINERS | 2 +- |
12 | target/i386/cpu.c | 2 +- | 15 | include/hw/{misc => arm}/raspberrypi-fw-defs.h | 0 |
13 | MAINTAINERS | 2 +- | 16 | hw/misc/bcm2835_property.c | 2 +- |
14 | 3 files changed, 3 insertions(+), 3 deletions(-) | 17 | 3 files changed, 2 insertions(+), 2 deletions(-) |
18 | rename include/hw/{misc => arm}/raspberrypi-fw-defs.h (100%) | ||
15 | 19 | ||
16 | diff --git a/configure b/configure | ||
17 | index XXXXXXX..XXXXXXX 100755 | ||
18 | --- a/configure | ||
19 | +++ b/configure | ||
20 | @@ -XXX,XX +XXX,XX @@ fi | ||
21 | |||
22 | if test -n "${deprecated_features}"; then | ||
23 | echo "Warning, deprecated features enabled." | ||
24 | - echo "Please see docs/system/deprecated.rst" | ||
25 | + echo "Please see docs/about/deprecated.rst" | ||
26 | echo " features: ${deprecated_features}" | ||
27 | fi | ||
28 | |||
29 | diff --git a/target/i386/cpu.c b/target/i386/cpu.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/target/i386/cpu.c | ||
32 | +++ b/target/i386/cpu.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static const X86CPUDefinition builtin_x86_defs[] = { | ||
34 | * none", but this is just for compatibility while libvirt isn't | ||
35 | * adapted to resolve CPU model versions before creating VMs. | ||
36 | * See "Runnability guarantee of CPU models" at | ||
37 | - * docs/system/deprecated.rst. | ||
38 | + * docs/about/deprecated.rst. | ||
39 | */ | ||
40 | X86CPUVersion default_cpu_version = 1; | ||
41 | |||
42 | diff --git a/MAINTAINERS b/MAINTAINERS | 20 | diff --git a/MAINTAINERS b/MAINTAINERS |
43 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/MAINTAINERS | 22 | --- a/MAINTAINERS |
45 | +++ b/MAINTAINERS | 23 | +++ b/MAINTAINERS |
46 | @@ -XXX,XX +XXX,XX @@ F: contrib/gitdm/* | 24 | @@ -XXX,XX +XXX,XX @@ S: Odd Fixes |
47 | 25 | F: hw/arm/raspi.c | |
48 | Incompatible changes | 26 | F: hw/arm/raspi_platform.h |
49 | R: libvir-list@redhat.com | 27 | F: hw/*/bcm283* |
50 | -F: docs/system/deprecated.rst | 28 | -F: include/hw/arm/raspi* |
51 | +F: docs/about/deprecated.rst | 29 | +F: include/hw/arm/rasp* |
52 | 30 | F: include/hw/*/bcm283* | |
53 | Build System | 31 | F: docs/system/arm/raspi.rst |
54 | ------------ | 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" | ||
55 | -- | 50 | -- |
56 | 2.20.1 | 51 | 2.34.1 |
57 | 52 | ||
58 | 53 | diff view generated by jsdifflib |
1 | In Arm v8.1M the VECTPENDING field in the ICSR has new behaviour: if | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | the register is accessed NonSecure and the highest priority pending | ||
3 | enabled exception (that would be returned in the VECTPENDING field) | ||
4 | targets Secure, then the VECTPENDING field must read 1 rather than | ||
5 | the exception number of the pending exception. Implement this. | ||
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 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210723162146.5167-7-peter.maydell@linaro.org | ||
10 | --- | 11 | --- |
11 | hw/intc/armv7m_nvic.c | 31 ++++++++++++++++++++++++------- | 12 | include/hw/arm/exynos4210.h | 2 +- |
12 | 1 file changed, 24 insertions(+), 7 deletions(-) | 13 | target/arm/cpu-qom.h | 2 -- |
14 | 2 files changed, 1 insertion(+), 3 deletions(-) | ||
13 | 15 | ||
14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 16 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
15 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/intc/armv7m_nvic.c | 18 | --- a/include/hw/arm/exynos4210.h |
17 | +++ b/hw/intc/armv7m_nvic.c | 19 | +++ b/include/hw/arm/exynos4210.h |
18 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque) | 20 | @@ -XXX,XX +XXX,XX @@ |
19 | nvic_irq_update(s); | 21 | #include "hw/intc/exynos4210_gic.h" |
20 | } | 22 | #include "hw/intc/exynos4210_combiner.h" |
21 | 23 | #include "hw/core/split-irq.h" | |
22 | +static bool vectpending_targets_secure(NVICState *s) | 24 | -#include "target/arm/cpu-qom.h" |
23 | +{ | 25 | +#include "hw/arm/boot.h" |
24 | + /* Return true if s->vectpending targets Secure state */ | 26 | #include "qom/object.h" |
25 | + if (s->vectpending_is_s_banked) { | 27 | |
26 | + return true; | 28 | #define EXYNOS4210_NCPUS 2 |
27 | + } | 29 | diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h |
28 | + return !exc_is_banked(s->vectpending) && | 30 | index XXXXXXX..XXXXXXX 100644 |
29 | + exc_targets_secure(s, s->vectpending); | 31 | --- a/target/arm/cpu-qom.h |
30 | +} | 32 | +++ b/target/arm/cpu-qom.h |
31 | + | 33 | @@ -XXX,XX +XXX,XX @@ |
32 | void armv7m_nvic_get_pending_irq_info(void *opaque, | 34 | #include "hw/core/cpu.h" |
33 | int *pirq, bool *ptargets_secure) | 35 | #include "qom/object.h" |
34 | { | 36 | |
35 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_get_pending_irq_info(void *opaque, | 37 | -struct arm_boot_info; |
36 | 38 | - | |
37 | assert(pending > ARMV7M_EXCP_RESET && pending < s->num_irq); | 39 | #define TYPE_ARM_CPU "arm-cpu" |
38 | 40 | ||
39 | - if (s->vectpending_is_s_banked) { | 41 | OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU) |
40 | - targets_secure = true; | ||
41 | - } else { | ||
42 | - targets_secure = !exc_is_banked(pending) && | ||
43 | - exc_targets_secure(s, pending); | ||
44 | - } | ||
45 | + targets_secure = vectpending_targets_secure(s); | ||
46 | |||
47 | trace_nvic_get_pending_irq_info(pending, targets_secure); | ||
48 | |||
49 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | ||
50 | /* VECTACTIVE */ | ||
51 | val = cpu->env.v7m.exception; | ||
52 | /* VECTPENDING */ | ||
53 | - val |= (s->vectpending & 0x1ff) << 12; | ||
54 | + if (s->vectpending) { | ||
55 | + /* | ||
56 | + * From v8.1M VECTPENDING must read as 1 if accessed as | ||
57 | + * NonSecure and the highest priority pending and enabled | ||
58 | + * exception targets Secure. | ||
59 | + */ | ||
60 | + int vp = s->vectpending; | ||
61 | + if (!attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_V8_1M) && | ||
62 | + vectpending_targets_secure(s)) { | ||
63 | + vp = 1; | ||
64 | + } | ||
65 | + val |= (vp & 0x1ff) << 12; | ||
66 | + } | ||
67 | /* ISRPENDING - set if any external IRQ is pending */ | ||
68 | if (nvic_isrpending(s)) { | ||
69 | val |= (1 << 22); | ||
70 | -- | 42 | -- |
71 | 2.20.1 | 43 | 2.34.1 |
72 | 44 | ||
73 | 45 | diff view generated by jsdifflib |
1 | The VECTPENDING field in the ICSR is 9 bits wide, in bits [20:12] of | 1 | From: Tong Ho <tong.ho@amd.com> |
---|---|---|---|
2 | the register. We were incorrectly masking it to 8 bits, so it would | ||
3 | report the wrong value if the pending exception was greater than 256. | ||
4 | Fix the bug. | ||
5 | 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 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210723162146.5167-6-peter.maydell@linaro.org | ||
9 | --- | 9 | --- |
10 | hw/intc/armv7m_nvic.c | 2 +- | 10 | hw/nvram/xlnx-bbram.c | 8 +++++--- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 5 insertions(+), 3 deletions(-) |
12 | 12 | ||
13 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.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/intc/armv7m_nvic.c | 15 | --- a/hw/nvram/xlnx-bbram.c |
16 | +++ b/hw/intc/armv7m_nvic.c | 16 | +++ b/hw/nvram/xlnx-bbram.c |
17 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 17 | @@ -XXX,XX +XXX,XX @@ |
18 | /* VECTACTIVE */ | 18 | * QEMU model of the Xilinx BBRAM Battery Backed RAM |
19 | val = cpu->env.v7m.exception; | 19 | * |
20 | /* VECTPENDING */ | 20 | * Copyright (c) 2014-2021 Xilinx Inc. |
21 | - val |= (s->vectpending & 0xff) << 12; | 21 | + * Copyright (c) 2023 Advanced Micro Devices, Inc. |
22 | + val |= (s->vectpending & 0x1ff) << 12; | 22 | * |
23 | /* ISRPENDING - set if any external IRQ is pending */ | 23 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
24 | if (nvic_isrpending(s)) { | 24 | * of this software and associated documentation files (the "Software"), to deal |
25 | val |= (1 << 22); | 25 | @@ -XXX,XX +XXX,XX @@ static RegisterAccessInfo bbram_ctrl_regs_info[] = { |
26 | } | ||
27 | }; | ||
28 | |||
29 | -static void bbram_ctrl_reset(DeviceState *dev) | ||
30 | +static void bbram_ctrl_reset_hold(Object *obj) | ||
31 | { | ||
32 | - XlnxBBRam *s = XLNX_BBRAM(dev); | ||
33 | + XlnxBBRam *s = XLNX_BBRAM(obj); | ||
34 | unsigned int i; | ||
35 | |||
36 | for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | ||
37 | @@ -XXX,XX +XXX,XX @@ static Property bbram_ctrl_props[] = { | ||
38 | static void bbram_ctrl_class_init(ObjectClass *klass, void *data) | ||
39 | { | ||
40 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
41 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
42 | |||
43 | - dc->reset = bbram_ctrl_reset; | ||
44 | + rc->phases.hold = bbram_ctrl_reset_hold; | ||
45 | dc->realize = bbram_ctrl_realize; | ||
46 | dc->vmsd = &vmstate_bbram_ctrl; | ||
47 | device_class_set_props(dc, bbram_ctrl_props); | ||
26 | -- | 48 | -- |
27 | 2.20.1 | 49 | 2.34.1 |
28 | 50 | ||
29 | 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 |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Viktor Prutyanov <viktor@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | String sign_rsds isn't terminated, so the print length must be limited. |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | |
5 | Message-id: 20210726150953.1218690-1-f4bug@amsat.org | 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 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | hw/arm/nseries.c | 2 +- | 11 | contrib/elf2dmp/main.c | 2 +- |
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 13 | ||
11 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | 14 | diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c |
12 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/arm/nseries.c | 16 | --- a/contrib/elf2dmp/main.c |
14 | +++ b/hw/arm/nseries.c | 17 | +++ b/contrib/elf2dmp/main.c |
15 | @@ -XXX,XX +XXX,XX @@ static uint32_t mipid_txrx(void *opaque, uint32_t cmd, int len) | 18 | @@ -XXX,XX +XXX,XX @@ static bool pe_check_pdb_name(uint64_t base, void *start_addr, |
16 | default: | ||
17 | bad_cmd: | ||
18 | qemu_log_mask(LOG_GUEST_ERROR, | ||
19 | - "%s: unknown command %02x\n", __func__, s->cmd); | ||
20 | + "%s: unknown command 0x%02x\n", __func__, s->cmd); | ||
21 | break; | ||
22 | } | 19 | } |
23 | 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 | } | ||
24 | -- | 27 | -- |
25 | 2.20.1 | 28 | 2.34.1 |
26 | |||
27 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Viktor Prutyanov <viktor@daynix.com> |
---|---|---|---|
2 | 2 | ||
3 | The macro used to calculate the maximum memory size of the MMIO region | 3 | Index in file_size array must be checked against num_files, because the |
4 | had a mistake, causing all GPIO models to create a mapping of 0x9D8. | 4 | entries we are looking for may be absent in the PDB. |
5 | The intent was to have it be 0x9D8 - 0x800. | ||
6 | 5 | ||
7 | This extra size doesn't matter on ast2400 and ast2500, which have a 4KB | 6 | Fixes: Coverity CID 1521597 |
8 | region set aside for the GPIO controller. | 7 | Signed-off-by: Viktor Prutyanov <viktor@daynix.com> |
9 | 8 | Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> | |
10 | On the ast2600 the 3.3V and 1.8V GPIO controllers are 2KB apart, so the | 9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | regions would overlap. Worse was the 1.8V controller would map over the | 10 | Message-id: 20230930235317.11469-3-viktor@daynix.com |
12 | top of the following peripheral, which happens to be the RTC. | ||
13 | |||
14 | The mmio region used by each device is a maximum of 2KB, so avoid the | ||
15 | calculations and hard code this as the maximum. | ||
16 | |||
17 | Fixes: 36d737ee82b2 ("hw/gpio: Add in AST2600 specific implementation") | ||
18 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
19 | Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com> | ||
20 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
21 | Message-id: 20210713065854.134634-2-joel@jms.id.au | ||
22 | [PMM: fix autocorrect error in commit message] | ||
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
24 | --- | 12 | --- |
25 | hw/gpio/aspeed_gpio.c | 3 +-- | 13 | contrib/elf2dmp/pdb.c | 13 +++++++++---- |
26 | 1 file changed, 1 insertion(+), 2 deletions(-) | 14 | 1 file changed, 9 insertions(+), 4 deletions(-) |
27 | 15 | ||
28 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c | 16 | diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c |
29 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/hw/gpio/aspeed_gpio.c | 18 | --- a/contrib/elf2dmp/pdb.c |
31 | +++ b/hw/gpio/aspeed_gpio.c | 19 | +++ b/contrib/elf2dmp/pdb.c |
32 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
33 | #define GPIO_1_8V_MEM_SIZE 0x9D8 | 21 | |
34 | #define GPIO_1_8V_REG_ARRAY_SIZE ((GPIO_1_8V_MEM_SIZE - \ | 22 | static uint32_t pdb_get_file_size(const struct pdb_reader *r, unsigned idx) |
35 | GPIO_1_8V_REG_OFFSET) >> 2) | ||
36 | -#define GPIO_MAX_MEM_SIZE MAX(GPIO_3_6V_MEM_SIZE, GPIO_1_8V_MEM_SIZE) | ||
37 | |||
38 | static int aspeed_evaluate_irq(GPIOSets *regs, int gpio_prev_high, int gpio) | ||
39 | { | 23 | { |
40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_realize(DeviceState *dev, Error **errp) | 24 | + if (idx >= r->ds.toc->num_files) { |
25 | + return 0; | ||
26 | + } | ||
27 | + | ||
28 | return r->ds.toc->file_size[idx]; | ||
29 | } | ||
30 | |||
31 | @@ -XXX,XX +XXX,XX @@ static void *pdb_ds_read_file(struct pdb_reader* r, uint32_t file_number) | ||
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; | ||
41 | } | 43 | } |
42 | 44 | ||
43 | memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_gpio_ops, s, | 45 | - r->segs = segs; |
44 | - TYPE_ASPEED_GPIO, GPIO_MAX_MEM_SIZE); | 46 | r->segs_size = pdb_get_file_size(r, stream_idx); |
45 | + TYPE_ASPEED_GPIO, 0x800); | 47 | + if (!r->segs_size) { |
46 | 48 | + return 1; | |
47 | sysbus_init_mmio(sbd, &s->iomem); | 49 | + } |
50 | |||
51 | return 0; | ||
48 | } | 52 | } |
49 | -- | 53 | -- |
50 | 2.20.1 | 54 | 2.34.1 |
51 | 55 | ||
52 | 56 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Michal Orzel <michal.orzel@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Currently, our only caller is sve_zcr_len_for_el, which has | 3 | On an attempt to access CNTPCT_EL0 from EL0 using a guest running on top |
4 | already masked the length extracted from ZCR_ELx, so the | 4 | of Xen, a trap from EL2 was observed which is something not reproducible |
5 | masking done here is a nop. But we will shortly have uses | 5 | on HW (also, Xen does not trap accesses to physical counter). |
6 | from other locations, where the length will be unmasked. | ||
7 | 6 | ||
8 | Saturate the length to ARM_MAX_VQ instead of truncating to | 7 | This is because gt_counter_access() checks for an incorrect bit (1 |
9 | the low 4 bits. | 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 | ||
10 | 13 | ||
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 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 | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 22 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Message-id: 20210723203344.968563-2-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 24 | --- |
16 | target/arm/helper.c | 4 +++- | 25 | target/arm/helper.c | 17 +---------------- |
17 | 1 file changed, 3 insertions(+), 1 deletion(-) | 26 | 1 file changed, 1 insertion(+), 16 deletions(-) |
18 | 27 | ||
19 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 28 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
20 | index XXXXXXX..XXXXXXX 100644 | 29 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.c | 30 | --- a/target/arm/helper.c |
22 | +++ b/target/arm/helper.c | 31 | +++ b/target/arm/helper.c |
23 | @@ -XXX,XX +XXX,XX @@ static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) | 32 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx, |
24 | { | 33 | if (!extract32(env->cp15.c14_cntkctl, timeridx, 1)) { |
25 | uint32_t end_len; | 34 | return CP_ACCESS_TRAP; |
26 | 35 | } | |
27 | - end_len = start_len &= 0xf; | 36 | - |
28 | + start_len = MIN(start_len, ARM_MAX_VQ - 1); | 37 | - /* If HCR_EL2.<E2H,TGE> == '10': check CNTHCTL_EL2.EL1PCTEN. */ |
29 | + end_len = start_len; | 38 | - if (hcr & HCR_E2H) { |
30 | + | 39 | - if (timeridx == GTIMER_PHYS && |
31 | if (!test_bit(start_len, cpu->sve_vq_map)) { | 40 | - !extract32(env->cp15.cnthctl_el2, 10, 1)) { |
32 | end_len = find_last_bit(cpu->sve_vq_map, start_len); | 41 | - return CP_ACCESS_TRAP_EL2; |
33 | assert(end_len < start_len); | 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 && | ||
34 | -- | 56 | -- |
35 | 2.20.1 | 57 | 2.34.1 |
36 | |||
37 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Leif Lindholm <quic_llindhol@quicinc.com> | ||
1 | 2 | ||
3 | GIC Private Peripheral Interrupts (PPI) are defined as GIC INTID 16-31. | ||
4 | As in, PPI0 is INTID16 .. PPI15 is INTID31. | ||
5 | Arm's Base System Architecture specification (BSA) lists the mandated and | ||
6 | recommended private interrupt IDs by INTID, not by PPI index. But current | ||
7 | definitions in virt define them by PPI index, complicating cross | ||
8 | referencing. | ||
9 | |||
10 | Meanwhile, the PPI(x) macro counterintuitively adds 16 to the input value, | ||
11 | converting a PPI index to an INTID. | ||
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> | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | --- | ||
21 | include/hw/arm/virt.h | 14 +++++++------- | ||
22 | hw/arm/virt-acpi-build.c | 12 ++++++------ | ||
23 | hw/arm/virt.c | 24 ++++++++++++++---------- | ||
24 | 3 files changed, 27 insertions(+), 23 deletions(-) | ||
25 | |||
26 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/include/hw/arm/virt.h | ||
29 | +++ b/include/hw/arm/virt.h | ||
30 | @@ -XXX,XX +XXX,XX @@ | ||
31 | #define NUM_VIRTIO_TRANSPORTS 32 | ||
32 | #define NUM_SMMU_IRQS 4 | ||
33 | |||
34 | -#define ARCH_GIC_MAINT_IRQ 9 | ||
35 | +#define ARCH_GIC_MAINT_IRQ 25 | ||
36 | |||
37 | -#define ARCH_TIMER_VIRT_IRQ 11 | ||
38 | -#define ARCH_TIMER_S_EL1_IRQ 13 | ||
39 | -#define ARCH_TIMER_NS_EL1_IRQ 14 | ||
40 | -#define ARCH_TIMER_NS_EL2_IRQ 10 | ||
41 | +#define ARCH_TIMER_VIRT_IRQ 27 | ||
42 | +#define ARCH_TIMER_S_EL1_IRQ 29 | ||
43 | +#define ARCH_TIMER_NS_EL1_IRQ 30 | ||
44 | +#define ARCH_TIMER_NS_EL2_IRQ 26 | ||
45 | |||
46 | -#define VIRTUAL_PMU_IRQ 7 | ||
47 | +#define VIRTUAL_PMU_IRQ 23 | ||
48 | |||
49 | -#define PPI(irq) ((irq) + 16) | ||
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); | ||
163 | } | ||
164 | -- | ||
165 | 2.34.1 | 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 |
New patch | |||
---|---|---|---|
1 | 1 | From: Cornelia Huck <cohuck@redhat.com> | |
2 | |||
3 | We can neaten the code by switching to the kvm_set_one_reg function. | ||
4 | |||
5 | Reviewed-by: Gavin Shan <gshan@redhat.com> | ||
6 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> | ||
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Message-id: 20231010142453.224369-2-cohuck@redhat.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/kvm.c | 13 +++------ | ||
13 | target/arm/kvm64.c | 66 +++++++++++++--------------------------------- | ||
14 | 2 files changed, 21 insertions(+), 58 deletions(-) | ||
15 | |||
16 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/target/arm/kvm.c | ||
19 | +++ b/target/arm/kvm.c | ||
20 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level) | ||
21 | bool ok = true; | ||
22 | |||
23 | for (i = 0; i < cpu->cpreg_array_len; i++) { | ||
24 | - struct kvm_one_reg r; | ||
25 | uint64_t regidx = cpu->cpreg_indexes[i]; | ||
26 | uint32_t v32; | ||
27 | int ret; | ||
28 | @@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level) | ||
29 | continue; | ||
30 | } | ||
31 | |||
32 | - r.id = regidx; | ||
33 | switch (regidx & KVM_REG_SIZE_MASK) { | ||
34 | case KVM_REG_SIZE_U32: | ||
35 | v32 = cpu->cpreg_values[i]; | ||
36 | - r.addr = (uintptr_t)&v32; | ||
37 | + ret = kvm_set_one_reg(cs, regidx, &v32); | ||
38 | break; | ||
39 | case KVM_REG_SIZE_U64: | ||
40 | - r.addr = (uintptr_t)(cpu->cpreg_values + i); | ||
41 | + ret = kvm_set_one_reg(cs, regidx, cpu->cpreg_values + i); | ||
42 | break; | ||
43 | default: | ||
44 | g_assert_not_reached(); | ||
45 | } | ||
46 | - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r); | ||
47 | if (ret) { | ||
48 | /* We might fail for "unknown register" and also for | ||
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]); | ||
86 | } | ||
87 | |||
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 | } | ||
249 | -- | ||
250 | 2.34.1 | ||
251 | |||
252 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Cornelia Huck <cohuck@redhat.com> | |
2 | |||
3 | We can neaten the code by switching the callers that work on a | ||
4 | CPUstate to the kvm_get_one_reg function. | ||
5 | |||
6 | Reviewed-by: Gavin Shan <gshan@redhat.com> | ||
7 | Signed-off-by: Cornelia Huck <cohuck@redhat.com> | ||
8 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Message-id: 20231010142453.224369-3-cohuck@redhat.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | target/arm/kvm.c | 15 +++--------- | ||
14 | target/arm/kvm64.c | 57 ++++++++++++---------------------------------- | ||
15 | 2 files changed, 18 insertions(+), 54 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/kvm.c b/target/arm/kvm.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/target/arm/kvm.c | ||
20 | +++ b/target/arm/kvm.c | ||
21 | @@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu) | ||
22 | bool ok = true; | ||
23 | |||
24 | for (i = 0; i < cpu->cpreg_array_len; i++) { | ||
25 | - struct kvm_one_reg r; | ||
26 | uint64_t regidx = cpu->cpreg_indexes[i]; | ||
27 | uint32_t v32; | ||
28 | int ret; | ||
29 | |||
30 | - r.id = regidx; | ||
31 | - | ||
32 | switch (regidx & KVM_REG_SIZE_MASK) { | ||
33 | case KVM_REG_SIZE_U32: | ||
34 | - r.addr = (uintptr_t)&v32; | ||
35 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r); | ||
36 | + ret = kvm_get_one_reg(cs, regidx, &v32); | ||
37 | if (!ret) { | ||
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 | ||
68 | index XXXXXXX..XXXXXXX 100644 | ||
69 | --- a/target/arm/kvm64.c | ||
70 | +++ b/target/arm/kvm64.c | ||
71 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level) | ||
72 | static int kvm_arch_get_fpsimd(CPUState *cs) | ||
73 | { | ||
74 | CPUARMState *env = &ARM_CPU(cs)->env; | ||
75 | - struct kvm_one_reg reg; | ||
76 | int i, ret; | ||
77 | |||
78 | for (i = 0; i < 32; i++) { | ||
79 | uint64_t *q = aa64_vfp_qreg(env, i); | ||
80 | - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); | ||
81 | - reg.addr = (uintptr_t)q; | ||
82 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
83 | + ret = kvm_get_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]), q); | ||
84 | if (ret) { | ||
85 | return ret; | ||
86 | } else { | ||
87 | @@ -XXX,XX +XXX,XX @@ static int kvm_arch_get_sve(CPUState *cs) | ||
88 | { | ||
89 | ARMCPU *cpu = ARM_CPU(cs); | ||
90 | CPUARMState *env = &cpu->env; | ||
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) | ||
172 | */ | ||
173 | aarch64_restore_sp(env, 1); | ||
174 | |||
175 | - reg.id = AARCH64_CORE_REG(regs.pc); | ||
176 | - reg.addr = (uintptr_t) &env->pc; | ||
177 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
178 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.pc), &env->pc); | ||
179 | if (ret) { | ||
180 | return ret; | ||
181 | } | ||
182 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
183 | aarch64_sync_64_to_32(env); | ||
184 | } | ||
185 | |||
186 | - reg.id = AARCH64_CORE_REG(elr_el1); | ||
187 | - reg.addr = (uintptr_t) &env->elr_el[1]; | ||
188 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
189 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(elr_el1), &env->elr_el[1]); | ||
190 | if (ret) { | ||
191 | return ret; | ||
192 | } | ||
193 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
194 | * KVM SPSRs 0-4 map to QEMU banks 1-5 | ||
195 | */ | ||
196 | for (i = 0; i < KVM_NR_SPSR; i++) { | ||
197 | - reg.id = AARCH64_CORE_REG(spsr[i]); | ||
198 | - reg.addr = (uintptr_t) &env->banked_spsr[i + 1]; | ||
199 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
200 | + ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(spsr[i]), | ||
201 | + &env->banked_spsr[i + 1]); | ||
202 | if (ret) { | ||
203 | return ret; | ||
204 | } | ||
205 | @@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs) | ||
206 | return ret; | ||
207 | } | ||
208 | |||
209 | - reg.addr = (uintptr_t)(&fpr); | ||
210 | - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); | ||
211 | - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); | ||
212 | + ret = kvm_get_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpsr), &fpr); | ||
213 | if (ret) { | ||
214 | return ret; | ||
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 | } | ||
225 | -- | ||
226 | 2.34.1 | ||
227 | |||
228 | diff view generated by jsdifflib |
1 | The ISCR.ISRPENDING bit is set when an external interrupt is pending. | 1 | For the Thumb T32 encoding of LDM, if only a single register is |
---|---|---|---|
2 | This is true whether that external interrupt is enabled or not. | 2 | specified in the register list this instruction is UNPREDICTABLE, |
3 | This means that we can't use 's->vectpending == 0' as a shortcut to | 3 | with the following choices: |
4 | "ISRPENDING is zero", because s->vectpending indicates only the | 4 | * instruction UNDEFs |
5 | highest priority pending enabled interrupt. | 5 | * instruction is a NOP |
6 | * instruction loads a single register | ||
7 | * instruction loads an unspecified set of registers | ||
6 | 8 | ||
7 | Remove the incorrect optimization so that if there is no pending | 9 | Currently we choose to UNDEF (a behaviour chosen in commit |
8 | enabled interrupt we fall through to scanning through the whole | 10 | 4b222545dbf30 in 2019; previously we treated it as "load the |
9 | interrupt array. | 11 | specified single register"). |
10 | 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 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
24 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Message-id: 20210723162146.5167-5-peter.maydell@linaro.org | 26 | Message-id: 20230927101853.39288-1-peter.maydell@linaro.org |
14 | --- | 27 | --- |
15 | hw/intc/armv7m_nvic.c | 9 ++++----- | 28 | target/arm/tcg/translate.c | 37 +++++++++++++++++++++++-------------- |
16 | 1 file changed, 4 insertions(+), 5 deletions(-) | 29 | 1 file changed, 23 insertions(+), 14 deletions(-) |
17 | 30 | ||
18 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 31 | diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c |
19 | index XXXXXXX..XXXXXXX 100644 | 32 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/intc/armv7m_nvic.c | 33 | --- a/target/arm/tcg/translate.c |
21 | +++ b/hw/intc/armv7m_nvic.c | 34 | +++ b/target/arm/tcg/translate.c |
22 | @@ -XXX,XX +XXX,XX @@ static bool nvic_isrpending(NVICState *s) | 35 | @@ -XXX,XX +XXX,XX @@ static void op_addr_block_post(DisasContext *s, arg_ldst_block *a, |
36 | } | ||
37 | } | ||
38 | |||
39 | -static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n) | ||
40 | +static bool op_stm(DisasContext *s, arg_ldst_block *a) | ||
23 | { | 41 | { |
24 | int irq; | 42 | int i, j, n, list, mem_idx; |
25 | 43 | bool user = a->u; | |
26 | - /* We can shortcut if the highest priority pending interrupt | 44 | @@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n) |
27 | - * happens to be external or if there is nothing pending. | 45 | |
46 | list = a->list; | ||
47 | n = ctpop16(list); | ||
48 | - if (n < min_n || a->rn == 15) { | ||
28 | + /* | 49 | + /* |
29 | + * We can shortcut if the highest priority pending interrupt | 50 | + * This is UNPREDICTABLE for n < 1 in all encodings, and we choose |
30 | + * happens to be external; if not we need to check the whole | 51 | + * to UNDEF. In the T32 STM encoding n == 1 is also UNPREDICTABLE, |
31 | + * vectors[] array. | 52 | + * but hardware treats it like the A32 version and implements the |
32 | */ | 53 | + * single-register-store, and some in-the-wild (buggy) software |
33 | if (s->vectpending > NVIC_FIRST_IRQ) { | 54 | + * assumes that, so we don't UNDEF on that case. |
55 | + */ | ||
56 | + if (n < 1 || a->rn == 15) { | ||
57 | unallocated_encoding(s); | ||
34 | return true; | 58 | return true; |
35 | } | 59 | } |
36 | - if (s->vectpending == 0) { | 60 | @@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n) |
37 | - return false; | 61 | |
38 | - } | 62 | static bool trans_STM(DisasContext *s, arg_ldst_block *a) |
39 | 63 | { | |
40 | for (irq = NVIC_FIRST_IRQ; irq < s->num_irq; irq++) { | 64 | - /* BitCount(list) < 1 is UNPREDICTABLE */ |
41 | if (s->vectors[irq].pending) { | 65 | - return op_stm(s, a, 1); |
66 | + return op_stm(s, a); | ||
67 | } | ||
68 | |||
69 | static bool trans_STM_t32(DisasContext *s, arg_ldst_block *a) | ||
70 | @@ -XXX,XX +XXX,XX @@ static bool trans_STM_t32(DisasContext *s, arg_ldst_block *a) | ||
71 | unallocated_encoding(s); | ||
72 | return true; | ||
73 | } | ||
74 | - /* BitCount(list) < 2 is UNPREDICTABLE */ | ||
75 | - return op_stm(s, a, 2); | ||
76 | + return op_stm(s, a); | ||
77 | } | ||
78 | |||
79 | -static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n) | ||
80 | +static bool do_ldm(DisasContext *s, arg_ldst_block *a) | ||
81 | { | ||
82 | int i, j, n, list, mem_idx; | ||
83 | bool loaded_base; | ||
84 | @@ -XXX,XX +XXX,XX @@ static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n) | ||
85 | |||
86 | list = a->list; | ||
87 | n = ctpop16(list); | ||
88 | - if (n < min_n || a->rn == 15) { | ||
89 | + /* | ||
90 | + * This is UNPREDICTABLE for n < 1 in all encodings, and we choose | ||
91 | + * to UNDEF. In the T32 LDM encoding n == 1 is also UNPREDICTABLE, | ||
92 | + * but hardware treats it like the A32 version and implements the | ||
93 | + * single-register-load, and some in-the-wild (buggy) software | ||
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); | ||
107 | } | ||
108 | |||
109 | static bool trans_LDM_t32(DisasContext *s, arg_ldst_block *a) | ||
110 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDM_t32(DisasContext *s, arg_ldst_block *a) | ||
111 | unallocated_encoding(s); | ||
112 | return true; | ||
113 | } | ||
114 | - /* BitCount(list) < 2 is UNPREDICTABLE */ | ||
115 | - return do_ldm(s, a, 2); | ||
116 | + return do_ldm(s, a); | ||
117 | } | ||
118 | |||
119 | static bool trans_LDM_t16(DisasContext *s, arg_ldst_block *a) | ||
120 | { | ||
121 | /* Writeback is conditional on the base register not being loaded. */ | ||
122 | a->w = !(a->list & (1 << a->rn)); | ||
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) | ||
42 | -- | 129 | -- |
43 | 2.20.1 | 130 | 2.34.1 |
44 | 131 | ||
45 | 132 | diff view generated by jsdifflib |
1 | From: Joe Komlodi <joe.komlodi@xilinx.com> | 1 | Update the SMMUv3 ID register bit field definitions to the |
---|---|---|---|
2 | set in the most recent specification (IHI0700 F.a). | ||
2 | 3 | ||
3 | The bit to see if a CD is valid is the last bit of the first word of the CD. | ||
4 | |||
5 | Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com> | ||
6 | Message-id: 1626728232-134665-2-git-send-email-joe.komlodi@xilinx.com | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 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 | --- | 9 | --- |
10 | hw/arm/smmuv3-internal.h | 2 +- | 10 | hw/arm/smmuv3-internal.h | 38 ++++++++++++++++++++++++++++++++++++++ |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 38 insertions(+) |
12 | 12 | ||
13 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h | 13 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/smmuv3-internal.h | 15 | --- a/hw/arm/smmuv3-internal.h |
16 | +++ b/hw/arm/smmuv3-internal.h | 16 | +++ b/hw/arm/smmuv3-internal.h |
17 | @@ -XXX,XX +XXX,XX @@ static inline int pa_range(STE *ste) | 17 | @@ -XXX,XX +XXX,XX @@ REG32(IDR0, 0x0) |
18 | 18 | FIELD(IDR0, S1P, 1 , 1) | |
19 | /* CD fields */ | 19 | FIELD(IDR0, TTF, 2 , 2) |
20 | 20 | FIELD(IDR0, COHACC, 4 , 1) | |
21 | -#define CD_VALID(x) extract32((x)->word[0], 30, 1) | 21 | + FIELD(IDR0, BTM, 5 , 1) |
22 | +#define CD_VALID(x) extract32((x)->word[0], 31, 1) | 22 | + FIELD(IDR0, HTTU, 6 , 2) |
23 | #define CD_ASID(x) extract32((x)->word[1], 16, 16) | 23 | + FIELD(IDR0, DORMHINT, 8 , 1) |
24 | #define CD_TTB(x, sel) \ | 24 | + FIELD(IDR0, HYP, 9 , 1) |
25 | ({ \ | 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 | |||
26 | -- | 89 | -- |
27 | 2.20.1 | 90 | 2.34.1 |
28 | |||
29 | diff view generated by jsdifflib |
1 | For M-profile, we weren't reporting alignment faults triggered by the | 1 | In smmuv3_init_regs() when we set the various bits in the ID |
---|---|---|---|
2 | generic TCG code correctly to the guest. These get passed into | 2 | registers, we do this almost in order of the fields in the |
3 | arm_v7m_cpu_do_interrupt() as an EXCP_DATA_ABORT with an A-profile | 3 | registers, but not quite. Move the initialization of |
4 | style exception.fsr value of 1. We didn't check for this, and so | 4 | SMMU_IDR3.RIL and SMMU_IDR5.OAS into their correct places. |
5 | they fell through into the default of "assume this is an MPU fault" | ||
6 | and were reported to the guest as a data access violation MPU fault. | ||
7 | |||
8 | Report these alignment faults as UsageFaults which set the UNALIGNED | ||
9 | bit in the UFSR. | ||
10 | 5 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Message-id: 20210723162146.5167-4-peter.maydell@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 | ||
14 | --- | 11 | --- |
15 | target/arm/m_helper.c | 8 ++++++++ | 12 | hw/arm/smmuv3.c | 4 ++-- |
16 | 1 file changed, 8 insertions(+) | 13 | 1 file changed, 2 insertions(+), 2 deletions(-) |
17 | 14 | ||
18 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 15 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
19 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/m_helper.c | 17 | --- a/hw/arm/smmuv3.c |
21 | +++ b/target/arm/m_helper.c | 18 | +++ b/hw/arm/smmuv3.c |
22 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 19 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s) |
23 | env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | 20 | s->idr[1] = FIELD_DP32(s->idr[1], IDR1, EVENTQS, SMMU_EVENTQS); |
24 | break; | 21 | s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS, SMMU_CMDQS); |
25 | case EXCP_UNALIGNED: | 22 | |
26 | + /* Unaligned faults reported by M-profile aware code */ | 23 | - s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1); |
27 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | 24 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1); |
28 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; | 25 | + s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1); |
29 | break; | 26 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2); |
30 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 27 | |
31 | } | 28 | + s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */ |
32 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); | 29 | /* 4K, 16K and 64K granule support */ |
33 | break; | 30 | s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN4K, 1); |
34 | + case 0x1: /* Alignment fault reported by generic code */ | 31 | s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN16K, 1); |
35 | + qemu_log_mask(CPU_LOG_INT, | 32 | s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN64K, 1); |
36 | + "...really UsageFault with UFSR.UNALIGNED\n"); | 33 | - s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */ |
37 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; | 34 | |
38 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | 35 | s->cmdq.base = deposit64(s->cmdq.base, 0, 5, SMMU_CMDQS); |
39 | + env->v7m.secure); | 36 | s->cmdq.prod = 0; |
40 | + break; | ||
41 | default: | ||
42 | /* | ||
43 | * All other FSR values are either MPU faults or "can't happen | ||
44 | -- | 37 | -- |
45 | 2.20.1 | 38 | 2.34.1 |
46 | |||
47 | diff view generated by jsdifflib |
1 | In do_v7m_exception_exit(), we perform various checks as part of | 1 | The SMMUv3.1-XNX feature is mandatory for an SMMUv3.1 if S2P is |
---|---|---|---|
2 | performing the exception return. If one of these checks fails, the | 2 | supported, so we should theoretically have implemented it as part of |
3 | architecture requires that we take an appropriate exception on the | 3 | the recent S2P work. Fortunately, for us the implementation is a |
4 | existing stackframe. We implement this by calling | 4 | no-op. |
5 | v7m_exception_taken() to set up to take the new exception, and then | ||
6 | immediately returning from do_v7m_exception_exit() without proceeding | ||
7 | any further with the unstack-and-exception-return process. | ||
8 | 5 | ||
9 | In a couple of checks that are new in v8.1M, we forgot the "return" | 6 | This feature is about interpretation of the stage 2 page table |
10 | statement, with the effect that if bad code in the guest tripped over | 7 | descriptor XN bits, which control execute permissions. |
11 | these checks we would set up to take a UsageFault exception but then | ||
12 | blunder on trying to also unstack and return from the original | ||
13 | exception, with the probable result that the guest would crash. | ||
14 | 8 | ||
15 | Add the missing return statements. | 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. | ||
16 | 27 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 29 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
19 | Message-id: 20210723162146.5167-3-peter.maydell@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 | ||
20 | --- | 33 | --- |
21 | target/arm/m_helper.c | 2 ++ | 34 | hw/arm/smmuv3.c | 4 ++++ |
22 | 1 file changed, 2 insertions(+) | 35 | 1 file changed, 4 insertions(+) |
23 | 36 | ||
24 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 37 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
25 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/m_helper.c | 39 | --- a/hw/arm/smmuv3.c |
27 | +++ b/target/arm/m_helper.c | 40 | +++ b/hw/arm/smmuv3.c |
28 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | 41 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s) |
29 | qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " | 42 | s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS, SMMU_CMDQS); |
30 | "stackframe: NSACR prevents clearing FPU registers\n"); | 43 | |
31 | v7m_exception_taken(cpu, excret, true, false); | 44 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1); |
32 | + return; | 45 | + if (FIELD_EX32(s->idr[0], IDR0, S2P)) { |
33 | } else if (!cpacr_pass) { | 46 | + /* XNX is a stage-2-specific feature */ |
34 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | 47 | + s->idr[3] = FIELD_DP32(s->idr[3], IDR3, XNX, 1); |
35 | exc_secure); | 48 | + } |
36 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | 49 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1); |
37 | qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " | 50 | s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2); |
38 | "stackframe: CPACR prevents clearing FPU registers\n"); | 51 | |
39 | v7m_exception_taken(cpu, excret, true, false); | ||
40 | + return; | ||
41 | } | ||
42 | } | ||
43 | /* Clear s0..s15, FPSCR and VPR */ | ||
44 | -- | 52 | -- |
45 | 2.20.1 | 53 | 2.34.1 |
46 | |||
47 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 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. | ||
2 | 7 | ||
3 | Rename from sve_zcr_get_valid_len and make accessible | 8 | (We don't need to make the behaviour conditional on feature |
4 | from outside of helper.c. | 9 | presence, because the FEAT_HPMN0 behaviour is within the range |
10 | of permitted UNPREDICTABLE behaviour for a non-FEAT_HPMN0 | ||
11 | implementation.) | ||
5 | 12 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Message-id: 20210723203344.968563-3-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 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 | ||
10 | --- | 16 | --- |
11 | target/arm/internals.h | 10 ++++++++++ | 17 | docs/system/arm/emulation.rst | 1 + |
12 | target/arm/helper.c | 4 ++-- | 18 | target/arm/helper.c | 2 +- |
13 | 2 files changed, 12 insertions(+), 2 deletions(-) | 19 | target/arm/tcg/cpu32.c | 4 ++++ |
20 | target/arm/tcg/cpu64.c | 1 + | ||
21 | 4 files changed, 7 insertions(+), 1 deletion(-) | ||
14 | 22 | ||
15 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 23 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
16 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/internals.h | 25 | --- a/docs/system/arm/emulation.rst |
18 | +++ b/target/arm/internals.h | 26 | +++ b/docs/system/arm/emulation.rst |
19 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void); | 27 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
20 | void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb); | 28 | - FEAT_HCX (Support for the HCRX_EL2 register) |
21 | #endif /* CONFIG_TCG */ | 29 | - FEAT_HPDS (Hierarchical permission disables) |
22 | 30 | - FEAT_HPDS2 (Translation table page-based hardware attributes) | |
23 | +/** | 31 | +- FEAT_HPMN0 (Setting of MDCR_EL2.HPMN to zero) |
24 | + * aarch64_sve_zcr_get_valid_len: | 32 | - FEAT_I8MM (AArch64 Int8 matrix multiplication instructions) |
25 | + * @cpu: cpu context | 33 | - FEAT_IDST (ID space trap handling) |
26 | + * @start_len: maximum len to consider | 34 | - FEAT_IESB (Implicit error synchronization event) |
27 | + * | ||
28 | + * Return the maximum supported sve vector length <= @start_len. | ||
29 | + * Note that both @start_len and the return value are in units | ||
30 | + * of ZCR_ELx.LEN, so the vector bit length is (x + 1) * 128. | ||
31 | + */ | ||
32 | +uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len); | ||
33 | |||
34 | enum arm_fprounding { | ||
35 | FPROUNDING_TIEEVEN, | ||
36 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 35 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
37 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/target/arm/helper.c | 37 | --- a/target/arm/helper.c |
39 | +++ b/target/arm/helper.c | 38 | +++ b/target/arm/helper.c |
40 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | 39 | @@ -XXX,XX +XXX,XX @@ static bool pmevcntr_is_64_bit(CPUARMState *env, int counter) |
41 | return 0; | 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; | ||
42 | } | 60 | } |
43 | 61 | ||
44 | -static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) | 62 | /* CPU models. These are not needed for the AArch64 linux-user build. */ |
45 | +uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) | 63 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
46 | { | 64 | index XXXXXXX..XXXXXXX 100644 |
47 | uint32_t end_len; | 65 | --- a/target/arm/tcg/cpu64.c |
48 | 66 | +++ b/target/arm/tcg/cpu64.c | |
49 | @@ -XXX,XX +XXX,XX @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) | 67 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
50 | zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); | 68 | t = cpu->isar.id_aa64dfr0; |
51 | } | 69 | t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */ |
52 | 70 | t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 6); /* FEAT_PMUv3p5 */ | |
53 | - return sve_zcr_get_valid_len(cpu, zcr_len); | 71 | + t = FIELD_DP64(t, ID_AA64DFR0, HPMN0, 1); /* FEAT_HPMN0 */ |
54 | + return aarch64_sve_zcr_get_valid_len(cpu, zcr_len); | 72 | cpu->isar.id_aa64dfr0 = t; |
55 | } | 73 | |
56 | 74 | t = cpu->isar.id_aa64smfr0; | |
57 | static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
58 | -- | 75 | -- |
59 | 2.20.1 | 76 | 2.34.1 |
60 | |||
61 | diff view generated by jsdifflib |
1 | The documentation of the -machine memory-backend has some minor | 1 | The include of hw/arm/virt.h in kvm64.c is unnecessary and also a |
---|---|---|---|
2 | formatting errors: | 2 | layering violation since the generic KVM code shouldn't need to know |
3 | * Misindentation of the initial line meant that the whole option | 3 | anything about board-specifics. The include line is an accidental |
4 | section is incorrectly indented in the HTML output compared to | 4 | leftover from commit 15613357ba53a4763, where we cleaned up the code |
5 | the other -machine options | 5 | to not depend on virt board internals but forgot to also remove the |
6 | * The examples weren't indented, which meant that they were formatted | 6 | now-redundant include line. |
7 | as plain run-on text including outputting the "::" as text. | ||
8 | * The a) b) list has no rst-format markup so it is rendered as | ||
9 | a single run-on paragraph | ||
10 | |||
11 | Fix the formatting. | ||
12 | 7 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | 9 | Reviewed-by: Gavin Shan <gshan@redhat.com> |
15 | Message-id: 20210719105257.3599-1-peter.maydell@linaro.org | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | Message-id: 20230925110429.3917202-1-peter.maydell@linaro.org | ||
16 | --- | 12 | --- |
17 | qemu-options.hx | 30 +++++++++++++++++------------- | 13 | target/arm/kvm64.c | 1 - |
18 | 1 file changed, 17 insertions(+), 13 deletions(-) | 14 | 1 file changed, 1 deletion(-) |
19 | 15 | ||
20 | diff --git a/qemu-options.hx b/qemu-options.hx | 16 | diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c |
21 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/qemu-options.hx | 18 | --- a/target/arm/kvm64.c |
23 | +++ b/qemu-options.hx | 19 | +++ b/target/arm/kvm64.c |
24 | @@ -XXX,XX +XXX,XX @@ SRST | 20 | @@ -XXX,XX +XXX,XX @@ |
25 | Enables or disables ACPI Heterogeneous Memory Attribute Table | 21 | #include "internals.h" |
26 | (HMAT) support. The default is off. | 22 | #include "hw/acpi/acpi.h" |
27 | 23 | #include "hw/acpi/ghes.h" | |
28 | - ``memory-backend='id'`` | 24 | -#include "hw/arm/virt.h" |
29 | + ``memory-backend='id'`` | 25 | |
30 | An alternative to legacy ``-mem-path`` and ``mem-prealloc`` options. | 26 | static bool have_guest_debug; |
31 | Allows to use a memory backend as main RAM. | 27 | |
32 | |||
33 | For example: | ||
34 | :: | ||
35 | - -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on | ||
36 | - -machine memory-backend=pc.ram | ||
37 | - -m 512M | ||
38 | + | ||
39 | + -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on | ||
40 | + -machine memory-backend=pc.ram | ||
41 | + -m 512M | ||
42 | |||
43 | Migration compatibility note: | ||
44 | - a) as backend id one shall use value of 'default-ram-id', advertised by | ||
45 | - machine type (available via ``query-machines`` QMP command), if migration | ||
46 | - to/from old QEMU (<5.0) is expected. | ||
47 | - b) for machine types 4.0 and older, user shall | ||
48 | - use ``x-use-canonical-path-for-ramblock-id=off`` backend option | ||
49 | - if migration to/from old QEMU (<5.0) is expected. | ||
50 | + | ||
51 | + * as backend id one shall use value of 'default-ram-id', advertised by | ||
52 | + machine type (available via ``query-machines`` QMP command), if migration | ||
53 | + to/from old QEMU (<5.0) is expected. | ||
54 | + * for machine types 4.0 and older, user shall | ||
55 | + use ``x-use-canonical-path-for-ramblock-id=off`` backend option | ||
56 | + if migration to/from old QEMU (<5.0) is expected. | ||
57 | + | ||
58 | For example: | ||
59 | :: | ||
60 | - -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off | ||
61 | - -machine memory-backend=pc.ram | ||
62 | - -m 512M | ||
63 | + | ||
64 | + -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off | ||
65 | + -machine memory-backend=pc.ram | ||
66 | + -m 512M | ||
67 | ERST | ||
68 | |||
69 | HXCOMM Deprecated by -machine | ||
70 | -- | 28 | -- |
71 | 2.20.1 | 29 | 2.34.1 |
72 | 30 | ||
73 | 31 | diff view generated by jsdifflib |
1 | For M-profile, unlike A-profile, the low 2 bits of SP are defined to be | 1 | The hw/arm/boot.h include in common-semi-target.h is not actually |
---|---|---|---|
2 | RES0H, which is to say that they must be hardwired to zero so that | 2 | needed, and it's a bit odd because it pulls a hw/arm header into a |
3 | guest attempts to write non-zero values to them are ignored. | 3 | target/arm file. |
4 | 4 | ||
5 | Implement this behaviour by masking out the low bits: | 5 | This include was originally needed because the semihosting code used |
6 | * for writes to r13 by the gdbstub | 6 | the arm_boot_info struct to get the base address of the RAM in system |
7 | * for writes to any of the various flavours of SP via MSR | 7 | emulation, to use in a (bad) heuristic for the return values for the |
8 | * for writes to r13 via store_reg() in generated code | 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. | ||
9 | 11 | ||
10 | Note that all the direct uses of cpu_R[] in translate.c are in places | 12 | Remove the now-redundant include line, and instead directly include |
11 | where the register is definitely not r13 (usually because that has | 13 | the cpu-qom.h header that we were previously getting via boot.h. |
12 | been checked for as an UNDEFINED or UNPREDICTABLE case and handled as | ||
13 | UNDEF). | ||
14 | |||
15 | All the other writes to regs[13] in C code are either: | ||
16 | * A-profile only code | ||
17 | * writes of values we can guarantee to be aligned, such as | ||
18 | - writes of previous-SP-value plus or minus a 4-aligned constant | ||
19 | - writes of the value in an SP limit register (which we already | ||
20 | enforce to be aligned) | ||
21 | 14 | ||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
24 | Message-id: 20210723162146.5167-2-peter.maydell@linaro.org | 17 | Message-id: 20230925112219.3919261-1-peter.maydell@linaro.org |
25 | --- | 18 | --- |
26 | target/arm/gdbstub.c | 4 ++++ | 19 | target/arm/common-semi-target.h | 4 +--- |
27 | target/arm/m_helper.c | 14 ++++++++------ | 20 | 1 file changed, 1 insertion(+), 3 deletions(-) |
28 | target/arm/translate.c | 3 +++ | ||
29 | 3 files changed, 15 insertions(+), 6 deletions(-) | ||
30 | 21 | ||
31 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | 22 | diff --git a/target/arm/common-semi-target.h b/target/arm/common-semi-target.h |
32 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/target/arm/gdbstub.c | 24 | --- a/target/arm/common-semi-target.h |
34 | +++ b/target/arm/gdbstub.c | 25 | +++ b/target/arm/common-semi-target.h |
35 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | 26 | @@ -XXX,XX +XXX,XX @@ |
36 | 27 | #ifndef TARGET_ARM_COMMON_SEMI_TARGET_H | |
37 | if (n < 16) { | 28 | #define TARGET_ARM_COMMON_SEMI_TARGET_H |
38 | /* Core integer register. */ | 29 | |
39 | + if (n == 13 && arm_feature(env, ARM_FEATURE_M)) { | 30 | -#ifndef CONFIG_USER_ONLY |
40 | + /* M profile SP low bits are always 0 */ | 31 | -#include "hw/arm/boot.h" |
41 | + tmp &= ~3; | 32 | -#endif |
42 | + } | 33 | +#include "target/arm/cpu-qom.h" |
43 | env->regs[n] = tmp; | 34 | |
44 | return 4; | 35 | static inline target_ulong common_semi_arg(CPUState *cs, int argno) |
45 | } | 36 | { |
46 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/target/arm/m_helper.c | ||
49 | +++ b/target/arm/m_helper.c | ||
50 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
51 | if (!env->v7m.secure) { | ||
52 | return; | ||
53 | } | ||
54 | - env->v7m.other_ss_msp = val; | ||
55 | + env->v7m.other_ss_msp = val & ~3; | ||
56 | return; | ||
57 | case 0x89: /* PSP_NS */ | ||
58 | if (!env->v7m.secure) { | ||
59 | return; | ||
60 | } | ||
61 | - env->v7m.other_ss_psp = val; | ||
62 | + env->v7m.other_ss_psp = val & ~3; | ||
63 | return; | ||
64 | case 0x8a: /* MSPLIM_NS */ | ||
65 | if (!env->v7m.secure) { | ||
66 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
67 | |||
68 | limit = is_psp ? env->v7m.psplim[false] : env->v7m.msplim[false]; | ||
69 | |||
70 | + val &= ~0x3; | ||
71 | + | ||
72 | if (val < limit) { | ||
73 | raise_exception_ra(env, EXCP_STKOF, 0, 1, GETPC()); | ||
74 | } | ||
75 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
76 | break; | ||
77 | case 8: /* MSP */ | ||
78 | if (v7m_using_psp(env)) { | ||
79 | - env->v7m.other_sp = val; | ||
80 | + env->v7m.other_sp = val & ~3; | ||
81 | } else { | ||
82 | - env->regs[13] = val; | ||
83 | + env->regs[13] = val & ~3; | ||
84 | } | ||
85 | break; | ||
86 | case 9: /* PSP */ | ||
87 | if (v7m_using_psp(env)) { | ||
88 | - env->regs[13] = val; | ||
89 | + env->regs[13] = val & ~3; | ||
90 | } else { | ||
91 | - env->v7m.other_sp = val; | ||
92 | + env->v7m.other_sp = val & ~3; | ||
93 | } | ||
94 | break; | ||
95 | case 10: /* MSPLIM */ | ||
96 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate.c | ||
99 | +++ b/target/arm/translate.c | ||
100 | @@ -XXX,XX +XXX,XX @@ void store_reg(DisasContext *s, int reg, TCGv_i32 var) | ||
101 | */ | ||
102 | tcg_gen_andi_i32(var, var, s->thumb ? ~1 : ~3); | ||
103 | s->base.is_jmp = DISAS_JUMP; | ||
104 | + } else if (reg == 13 && arm_dc_feature(s, ARM_FEATURE_M)) { | ||
105 | + /* For M-profile SP bits [1:0] are always zero */ | ||
106 | + tcg_gen_andi_i32(var, var, ~3); | ||
107 | } | ||
108 | tcg_gen_mov_i32(cpu_R[reg], var); | ||
109 | tcg_temp_free_i32(var); | ||
110 | -- | 37 | -- |
111 | 2.20.1 | 38 | 2.34.1 |
112 | |||
113 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | The code for powering on a CPU in arm-powerctl.c has two separate |
---|---|---|---|
2 | 2 | use cases: | |
3 | Mirror the behavour of /proc/sys/abi/sve_default_vector_length | 3 | * emulation of a real hardware power controller |
4 | under the real linux kernel. We have no way of passing along | 4 | * emulation of firmware interfaces (primarily PSCI) with |
5 | a real default across exec like the kernel can, but this is a | 5 | CPU on/off APIs |
6 | decent way of adjusting the startup vector length of a process. | 6 | |
7 | 7 | For the first case, we only need to reset the CPU and set its | |
8 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/482 | 8 | starting PC and X0. For the second case, because we're emulating the |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | firmware we need to ensure that it's in the state that the firmware |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | provides. In particular, when we reset to a lower EL than the |
11 | Message-id: 20210723203344.968563-4-richard.henderson@linaro.org | 11 | highest one we are emulating, we need to put the CPU into a state |
12 | [PMM: tweaked docs formatting, document -1 special-case, | 12 | that permits correct running at that lower EL. We already do a |
13 | added fixup patch from RTH mentioning QEMU's maximum veclen.] | 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 | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 65 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
66 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
67 | Message-id: 20230926155619.4028618-1-peter.maydell@linaro.org | ||
15 | --- | 68 | --- |
16 | docs/system/arm/cpu-features.rst | 15 ++++++++ | 69 | target/arm/cpu.h | 22 +++++++++ |
17 | target/arm/cpu.h | 5 +++ | 70 | hw/arm/boot.c | 95 ++++++++++----------------------------- |
18 | target/arm/cpu.c | 14 ++++++-- | 71 | target/arm/arm-powerctl.c | 53 +--------------------- |
19 | target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++ | 72 | target/arm/cpu.c | 95 +++++++++++++++++++++++++++++++++++++++ |
20 | 4 files changed, 92 insertions(+), 2 deletions(-) | 73 | 4 files changed, 141 insertions(+), 124 deletions(-) |
21 | 74 | ||
22 | diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/docs/system/arm/cpu-features.rst | ||
25 | +++ b/docs/system/arm/cpu-features.rst | ||
26 | @@ -XXX,XX +XXX,XX @@ verbose command lines. However, the recommended way to select vector | ||
27 | lengths is to explicitly enable each desired length. Therefore only | ||
28 | example's (1), (4), and (6) exhibit recommended uses of the properties. | ||
29 | |||
30 | +SVE User-mode Default Vector Length Property | ||
31 | +-------------------------------------------- | ||
32 | + | ||
33 | +For qemu-aarch64, the cpu property ``sve-default-vector-length=N`` is | ||
34 | +defined to mirror the Linux kernel parameter file | ||
35 | +``/proc/sys/abi/sve_default_vector_length``. The default length, ``N``, | ||
36 | +is in units of bytes and must be between 16 and 8192. | ||
37 | +If not specified, the default vector length is 64. | ||
38 | + | ||
39 | +If the default length is larger than the maximum vector length enabled, | ||
40 | +the actual vector length will be reduced. Note that the maximum vector | ||
41 | +length supported by QEMU is 256. | ||
42 | + | ||
43 | +If this property is set to ``-1`` then the default vector length | ||
44 | +is set to the maximum possible length. | ||
45 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | 75 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
46 | index XXXXXXX..XXXXXXX 100644 | 76 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/target/arm/cpu.h | 77 | --- a/target/arm/cpu.h |
48 | +++ b/target/arm/cpu.h | 78 | +++ b/target/arm/cpu.h |
49 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | 79 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, |
50 | /* Used to set the maximum vector length the cpu will support. */ | 80 | int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs, |
51 | uint32_t sve_max_vq; | 81 | int cpuid, DumpState *s); |
52 | 82 | ||
53 | +#ifdef CONFIG_USER_ONLY | 83 | +/** |
54 | + /* Used to set the default vector length at process start. */ | 84 | + * arm_emulate_firmware_reset: Emulate firmware CPU reset handling |
55 | + uint32_t sve_default_vq; | 85 | + * @cpu: CPU (which must have been freshly reset) |
56 | +#endif | 86 | + * @target_el: exception level to put the CPU into |
57 | + | 87 | + * @secure: whether to put the CPU in secure state |
58 | /* | 88 | + * |
59 | * In sve_vq_map each set bit is a supported vector length of | 89 | + * When QEMU is directly running a guest kernel at a lower level than |
60 | * (bit-number + 1) * 16 bytes, i.e. each bit number + 1 is the vector | 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); | ||
108 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | ||
109 | index XXXXXXX..XXXXXXX 100644 | ||
110 | --- a/hw/arm/boot.c | ||
111 | +++ b/hw/arm/boot.c | ||
112 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | ||
113 | |||
114 | cpu_set_pc(cs, entry); | ||
115 | } else { | ||
116 | - /* If we are booting Linux then we need to check whether we are | ||
117 | - * booting into secure or non-secure state and adjust the state | ||
118 | - * accordingly. Out of reset, ARM is defined to be in secure state | ||
119 | - * (SCR.NS = 0), we change that here if non-secure boot has been | ||
120 | - * requested. | ||
121 | + /* | ||
122 | + * If we are booting Linux then we might need to do so at: | ||
123 | + * - AArch64 NS EL2 or NS EL1 | ||
124 | + * - AArch32 Secure SVC (EL3) | ||
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 | |||
61 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 286 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
62 | index XXXXXXX..XXXXXXX 100644 | 287 | index XXXXXXX..XXXXXXX 100644 |
63 | --- a/target/arm/cpu.c | 288 | --- a/target/arm/cpu.c |
64 | +++ b/target/arm/cpu.c | 289 | +++ b/target/arm/cpu.c |
65 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) | 290 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj) |
66 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 16, 2, 3); | 291 | } |
67 | /* with reasonable vector length */ | 292 | } |
68 | if (cpu_isar_feature(aa64_sve, cpu)) { | 293 | |
69 | - env->vfp.zcr_el[1] = MIN(cpu->sve_max_vq - 1, 3); | 294 | +void arm_emulate_firmware_reset(CPUState *cpustate, int target_el) |
70 | + env->vfp.zcr_el[1] = | 295 | +{ |
71 | + aarch64_sve_zcr_get_valid_len(cpu, cpu->sve_default_vq - 1); | 296 | + ARMCPU *cpu = ARM_CPU(cpustate); |
72 | } | 297 | + CPUARMState *env = &cpu->env; |
73 | /* | 298 | + bool have_el3 = arm_feature(env, ARM_FEATURE_EL3); |
74 | * Enable TBI0 but not TBI1. | 299 | + bool have_el2 = arm_feature(env, ARM_FEATURE_EL2); |
75 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) | 300 | + |
76 | QLIST_INIT(&cpu->pre_el_change_hooks); | ||
77 | QLIST_INIT(&cpu->el_change_hooks); | ||
78 | |||
79 | -#ifndef CONFIG_USER_ONLY | ||
80 | +#ifdef CONFIG_USER_ONLY | ||
81 | +# ifdef TARGET_AARCH64 | ||
82 | + /* | 301 | + /* |
83 | + * The linux kernel defaults to 512-bit vectors, when sve is supported. | 302 | + * Check we have the EL we're aiming for. If that is the |
84 | + * See documentation for /proc/sys/abi/sve_default_vector_length, and | 303 | + * highest implemented EL, then cpu_reset has already done |
85 | + * our corresponding sve-default-vector-length cpu property. | 304 | + * all the work. |
86 | + */ | 305 | + */ |
87 | + cpu->sve_default_vq = 4; | 306 | + switch (target_el) { |
88 | +# endif | 307 | + case 3: |
89 | +#else | 308 | + assert(have_el3); |
90 | /* Our inbound IRQ and FIQ lines */ | ||
91 | if (kvm_enabled()) { | ||
92 | /* VIRQ and VFIQ are unused with KVM but we add them to maintain | ||
93 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/cpu64.c | ||
96 | +++ b/target/arm/cpu64.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, bool value, Error **errp) | ||
98 | cpu->isar.id_aa64pfr0 = t; | ||
99 | } | ||
100 | |||
101 | +#ifdef CONFIG_USER_ONLY | ||
102 | +/* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
103 | +static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v, | ||
104 | + const char *name, void *opaque, | ||
105 | + Error **errp) | ||
106 | +{ | ||
107 | + ARMCPU *cpu = ARM_CPU(obj); | ||
108 | + int32_t default_len, default_vq, remainder; | ||
109 | + | ||
110 | + if (!visit_type_int32(v, name, &default_len, errp)) { | ||
111 | + return; | 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(); | ||
112 | + } | 323 | + } |
113 | + | 324 | + |
114 | + /* Undocumented, but the kernel allows -1 to indicate "maximum". */ | 325 | + if (have_el3) { |
115 | + if (default_len == -1) { | 326 | + /* |
116 | + cpu->sve_default_vq = ARM_MAX_VQ; | 327 | + * Set the EL3 state so code can run at EL2. This should match |
117 | + return; | 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; | ||
118 | + } | 364 | + } |
119 | + | 365 | + |
120 | + default_vq = default_len / 16; | 366 | + if (have_el2 && target_el < 2) { |
121 | + remainder = default_len % 16; | 367 | + /* Set EL2 state so code can run at EL1. */ |
122 | + | 368 | + if (env->aarch64) { |
123 | + /* | 369 | + env->cp15.hcr_el2 |= HCR_RW; |
124 | + * Note that the 512 max comes from include/uapi/asm/sve_context.h | 370 | + } |
125 | + * and is the maximum architectural width of ZCR_ELx.LEN. | ||
126 | + */ | ||
127 | + if (remainder || default_vq < 1 || default_vq > 512) { | ||
128 | + error_setg(errp, "cannot set sve-default-vector-length"); | ||
129 | + if (remainder) { | ||
130 | + error_append_hint(errp, "Vector length not a multiple of 16\n"); | ||
131 | + } else if (default_vq < 1) { | ||
132 | + error_append_hint(errp, "Vector length smaller than 16\n"); | ||
133 | + } else { | ||
134 | + error_append_hint(errp, "Vector length larger than %d\n", | ||
135 | + 512 * 16); | ||
136 | + } | ||
137 | + return; | ||
138 | + } | 371 | + } |
139 | + | 372 | + |
140 | + cpu->sve_default_vq = default_vq; | 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 | + } | ||
141 | +} | 386 | +} |
142 | + | 387 | + |
143 | +static void cpu_arm_get_sve_default_vec_len(Object *obj, Visitor *v, | 388 | + |
144 | + const char *name, void *opaque, | 389 | #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) |
145 | + Error **errp) | 390 | |
146 | +{ | 391 | static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx, |
147 | + ARMCPU *cpu = ARM_CPU(obj); | ||
148 | + int32_t value = cpu->sve_default_vq * 16; | ||
149 | + | ||
150 | + visit_type_int32(v, name, &value, errp); | ||
151 | +} | ||
152 | +#endif | ||
153 | + | ||
154 | void aarch64_add_sve_properties(Object *obj) | ||
155 | { | ||
156 | uint32_t vq; | ||
157 | @@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj) | ||
158 | object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, | ||
159 | cpu_arm_set_sve_vq, NULL, NULL); | ||
160 | } | ||
161 | + | ||
162 | +#ifdef CONFIG_USER_ONLY | ||
163 | + /* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
164 | + object_property_add(obj, "sve-default-vector-length", "int32", | ||
165 | + cpu_arm_get_sve_default_vec_len, | ||
166 | + cpu_arm_set_sve_default_vec_len, NULL, NULL); | ||
167 | +#endif | ||
168 | } | ||
169 | |||
170 | void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) | ||
171 | -- | 392 | -- |
172 | 2.20.1 | 393 | 2.34.1 |
173 | |||
174 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Chris Rauer <crauer@google.com> | ||
1 | 2 | ||
3 | The counter register is only 24-bits and counts down. If the timer is | ||
4 | running but the qtimer to reset it hasn't fired off yet, there is a chance | ||
5 | the regster read can return an invalid result. | ||
6 | |||
7 | Signed-off-by: Chris Rauer <crauer@google.com> | ||
8 | Message-id: 20230922181411.2697135-1-crauer@google.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | hw/timer/npcm7xx_timer.c | 3 +++ | ||
13 | 1 file changed, 3 insertions(+) | ||
14 | |||
15 | diff --git a/hw/timer/npcm7xx_timer.c b/hw/timer/npcm7xx_timer.c | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/hw/timer/npcm7xx_timer.c | ||
18 | +++ b/hw/timer/npcm7xx_timer.c | ||
19 | @@ -XXX,XX +XXX,XX @@ static int64_t npcm7xx_timer_count_to_ns(NPCM7xxTimer *t, uint32_t count) | ||
20 | /* Convert a time interval in nanoseconds to a timer cycle count. */ | ||
21 | static uint32_t npcm7xx_timer_ns_to_count(NPCM7xxTimer *t, int64_t ns) | ||
22 | { | ||
23 | + if (ns < 0) { | ||
24 | + return 0; | ||
25 | + } | ||
26 | return clock_ns_to_ticks(t->ctrl->clock, ns) / | ||
27 | npcm7xx_tcsr_prescaler(t->tcsr); | ||
28 | } | ||
29 | -- | ||
30 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Suraj Shirvankar <surajshirvankar@gmail.com> | ||
1 | 2 | ||
3 | QEMU coding style uses the glib memory allocation APIs, not | ||
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). | ||
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> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | contrib/elf2dmp/addrspace.c | 7 ++----- | ||
16 | contrib/elf2dmp/main.c | 9 +++------ | ||
17 | contrib/elf2dmp/pdb.c | 19 ++++++++----------- | ||
18 | contrib/elf2dmp/qemu_elf.c | 7 ++----- | ||
19 | 4 files changed, 15 insertions(+), 27 deletions(-) | ||
20 | |||
21 | diff --git a/contrib/elf2dmp/addrspace.c b/contrib/elf2dmp/addrspace.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/contrib/elf2dmp/addrspace.c | ||
24 | +++ b/contrib/elf2dmp/addrspace.c | ||
25 | @@ -XXX,XX +XXX,XX @@ int pa_space_create(struct pa_space *ps, QEMU_Elf *qemu_elf) | ||
26 | } | ||
27 | } | ||
28 | |||
29 | - ps->block = malloc(sizeof(*ps->block) * ps->block_nr); | ||
30 | - if (!ps->block) { | ||
31 | - return 1; | ||
32 | - } | ||
33 | + ps->block = g_new(struct pa_block, ps->block_nr); | ||
34 | |||
35 | for (i = 0; i < phdr_nr; i++) { | ||
36 | if (phdr[i].p_type == PT_LOAD) { | ||
37 | @@ -XXX,XX +XXX,XX @@ int pa_space_create(struct pa_space *ps, QEMU_Elf *qemu_elf) | ||
38 | void pa_space_destroy(struct pa_space *ps) | ||
39 | { | ||
40 | ps->block_nr = 0; | ||
41 | - free(ps->block); | ||
42 | + g_free(ps->block); | ||
43 | } | ||
44 | |||
45 | void va_space_set_dtb(struct va_space *vs, uint64_t dtb) | ||
46 | diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/contrib/elf2dmp/main.c | ||
49 | +++ b/contrib/elf2dmp/main.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static KDDEBUGGER_DATA64 *get_kdbg(uint64_t KernBase, struct pdb_reader *pdb, | ||
51 | } | ||
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) | ||
83 | { | ||
84 | - free(r->ds.toc); | ||
85 | + g_free(r->ds.toc); | ||
86 | } | ||
87 | |||
88 | static void pdb_exit_symbols(struct pdb_reader *r) | ||
89 | { | ||
90 | - free(r->modimage); | ||
91 | - free(r->symbols); | ||
92 | + g_free(r->modimage); | ||
93 | + g_free(r->symbols); | ||
94 | } | ||
95 | |||
96 | static void pdb_exit_segments(struct pdb_reader *r) | ||
97 | { | ||
98 | - free(r->segs); | ||
99 | + g_free(r->segs); | ||
100 | } | ||
101 | |||
102 | static void *pdb_ds_read(const PDB_DS_HEADER *header, | ||
103 | @@ -XXX,XX +XXX,XX @@ static void *pdb_ds_read(const PDB_DS_HEADER *header, | ||
104 | |||
105 | nBlocks = (size + header->block_size - 1) / header->block_size; | ||
106 | |||
107 | - buffer = malloc(nBlocks * header->block_size); | ||
108 | - if (!buffer) { | ||
109 | - return NULL; | ||
110 | - } | ||
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 | ||
143 | index XXXXXXX..XXXXXXX 100644 | ||
144 | --- a/contrib/elf2dmp/qemu_elf.c | ||
145 | +++ b/contrib/elf2dmp/qemu_elf.c | ||
146 | @@ -XXX,XX +XXX,XX @@ static int init_states(QEMU_Elf *qe) | ||
147 | |||
148 | printf("%zu CPU states has been found\n", cpu_nr); | ||
149 | |||
150 | - qe->state = malloc(sizeof(*qe->state) * cpu_nr); | ||
151 | - if (!qe->state) { | ||
152 | - return 1; | ||
153 | - } | ||
154 | + qe->state = g_new(QEMUCPUState*, cpu_nr); | ||
155 | |||
156 | cpu_nr = 0; | ||
157 | |||
158 | @@ -XXX,XX +XXX,XX @@ static int init_states(QEMU_Elf *qe) | ||
159 | |||
160 | static void exit_states(QEMU_Elf *qe) | ||
161 | { | ||
162 | - free(qe->state); | ||
163 | + g_free(qe->state); | ||
164 | } | ||
165 | |||
166 | static bool check_ehdr(QEMU_Elf *qe) | ||
167 | -- | ||
168 | 2.34.1 | diff view generated by jsdifflib |