1
The following changes since commit 003ba52a8b327180e284630b289c6ece5a3e08b9:
1
Hi; here's a queue of arm patches (plus a few elf2dmp changes);
2
mostly these are minor cleanups and bugfixes.
2
3
3
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-02-16 11:16:39 +0000)
4
thanks
5
-- PMM
6
7
The following changes since commit deaca3fd30d3a8829160f8d3705d65ad83176800:
8
9
Merge tag 'pull-vfio-20231018' of https://github.com/legoater/qemu into staging (2023-10-18 06:21:15 -0400)
4
10
5
are available in the Git repository at:
11
are available in the Git repository at:
6
12
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230216
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20231019
8
14
9
for you to fetch changes up to caf01d6a435d9f4a95aeae2f9fc6cb8b889b1fb8:
15
for you to fetch changes up to 2a052b4ee01b3c413cef2ef49cb780cde17d4ba1:
10
16
11
tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG (2023-02-16 16:28:53 +0000)
17
contrib/elf2dmp: Use g_malloc(), g_new() and g_free() (2023-10-19 14:32:13 +0100)
12
18
13
----------------------------------------------------------------
19
----------------------------------------------------------------
14
target-arm queue:
20
target-arm queue:
15
* Some mostly M-profile-related code cleanups
21
* hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder
16
* avocado: Retire the boot_linux.py AArch64 TCG tests
22
* hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot'
17
* hw/arm/smmuv3: Add GBPA register
23
* xlnx devices: remove deprecated device reset
18
* arm/virt: don't try to spell out the accelerator
24
* xlnx-bbram: hw/nvram: Use dot in device type name
19
* hw/arm: Attach PSPI module to NPCM7XX SoC
25
* elf2dmp: fix coverity issues
20
* Some cleanup/refactoring patches aiming towards
26
* elf2dmp: convert to g_malloc, g_new and g_free
21
allowing building Arm targets without CONFIG_TCG
27
* target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0
28
* hw/arm: refactor virt PPI logic
29
* arm/kvm: convert to kvm_set_one_reg, kvm_get_one_reg
30
* target/arm: Permit T32 LDM with single register
31
* smmuv3: Advertise SMMUv3.1-XNX
32
* target/arm: Implement FEAT_HPMN0
33
* Remove some unnecessary include lines
34
* target/arm/arm-powerctl: Correctly init CPUs when powered on to lower EL
35
* hw/timer/npcm7xx_timer: Prevent timer from counting down past zero
22
36
23
----------------------------------------------------------------
37
----------------------------------------------------------------
24
Alex Bennée (1):
38
Chris Rauer (1):
25
tests/avocado: retire the Aarch64 TCG tests from boot_linux.py
39
hw/timer/npcm7xx_timer: Prevent timer from counting down past zero
26
40
27
Claudio Fontana (3):
41
Cornelia Huck (2):
28
target/arm: rename handle_semihosting to tcg_handle_semihosting
42
arm/kvm: convert to kvm_set_one_reg
29
target/arm: wrap psci call with tcg_enabled
43
arm/kvm: convert to kvm_get_one_reg
30
target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()
31
44
32
Cornelia Huck (1):
45
Leif Lindholm (3):
33
arm/virt: don't try to spell out the accelerator
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
34
49
35
Fabiano Rosas (7):
50
Michal Orzel (1):
36
target/arm: Move PC alignment check
51
target/arm: Fix CNTPCT_EL0 trapping from EL0 when HCR_EL2.E2H is 0
37
target/arm: Move cpregs code out of cpu.h
38
tests/avocado: Skip tests that require a missing accelerator
39
tests/avocado: Tag TCG tests with accel:tcg
40
target/arm: Use "max" as default cpu for the virt machine with KVM
41
tests/qtest: arm-cpu-features: Match tests to required accelerators
42
tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG
43
52
44
Hao Wu (3):
53
Peter Maydell (8):
45
MAINTAINERS: Add myself to maintainers and remove Havard
54
target/arm: Permit T32 LDM with single register
46
hw/ssi: Add Nuvoton PSPI Module
55
hw/arm/smmuv3: Update ID register bit field definitions
47
hw/arm: Attach PSPI module to NPCM7XX SoC
56
hw/arm/smmuv3: Sort ID register setting into field order
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
48
62
49
Jean-Philippe Brucker (2):
63
Philippe Mathieu-Daudé (1):
50
hw/arm/smmu-common: Support 64-bit addresses
64
hw/arm/exynos4210: Get arm_boot_info declaration from 'hw/arm/boot.h'
51
hw/arm/smmu-common: Fix TTB1 handling
52
65
53
Mostafa Saleh (1):
66
Suraj Shirvankar (1):
54
hw/arm/smmuv3: Add GBPA register
67
contrib/elf2dmp: Use g_malloc(), g_new() and g_free()
55
68
56
Philippe Mathieu-Daudé (12):
69
Thomas Huth (1):
57
hw/intc/armv7m_nvic: Use OBJECT_DECLARE_SIMPLE_TYPE() macro
70
hw/arm: Move raspberrypi-fw-defs.h to the include/hw/arm/ folder
58
target/arm: Simplify arm_v7m_mmu_idx_for_secstate() for user emulation
59
target/arm: Reduce arm_v7m_mmu_idx_[all/for_secstate_and_priv]() scope
60
target/arm: Constify ID_PFR1 on user emulation
61
target/arm: Convert CPUARMState::eabi to boolean
62
target/arm: Avoid resetting CPUARMState::eabi field
63
target/arm: Restrict CPUARMState::gicv3state to sysemu
64
target/arm: Restrict CPUARMState::arm_boot_info to sysemu
65
target/arm: Restrict CPUARMState::nvic to sysemu
66
target/arm: Store CPUARMState::nvic as NVICState*
67
target/arm: Declare CPU <-> NVIC helpers in 'hw/intc/armv7m_nvic.h'
68
hw/arm: Add missing XLNX_ZYNQMP_ARM -> USB_DWC3 Kconfig dependency
69
71
70
MAINTAINERS | 8 +-
72
Tong Ho (4):
71
docs/system/arm/nuvoton.rst | 2 +-
73
xlnx-bbram: hw/nvram: Remove deprecated device reset
72
hw/arm/smmuv3-internal.h | 7 +
74
xlnx-zynqmp-efuse: hw/nvram: Remove deprecated device reset
73
include/hw/arm/npcm7xx.h | 2 +
75
xlnx-versal-efuse: hw/nvram: Remove deprecated device reset
74
include/hw/arm/smmu-common.h | 2 -
76
xlnx-bbram: hw/nvram: Use dot in device type name
75
include/hw/arm/smmuv3.h | 1 +
76
include/hw/intc/armv7m_nvic.h | 128 +++++++++++++++++-
77
include/hw/ssi/npcm_pspi.h | 53 ++++++++
78
linux-user/user-internals.h | 2 +-
79
target/arm/cpregs.h | 98 ++++++++++++++
80
target/arm/cpu.h | 228 ++-------------------------------
81
target/arm/internals.h | 14 --
82
hw/arm/npcm7xx.c | 25 +++-
83
hw/arm/smmu-common.c | 4 +-
84
hw/arm/smmuv3.c | 43 ++++++-
85
hw/arm/virt.c | 10 +-
86
hw/intc/armv7m_nvic.c | 38 ++----
87
hw/ssi/npcm_pspi.c | 221 ++++++++++++++++++++++++++++++++
88
linux-user/arm/cpu_loop.c | 4 +-
89
target/arm/cpu.c | 5 +-
90
target/arm/cpu_tcg.c | 3 +
91
target/arm/helper.c | 31 +++--
92
target/arm/m_helper.c | 86 +++++++------
93
target/arm/machine.c | 18 +--
94
tests/qtest/arm-cpu-features.c | 28 ++--
95
hw/arm/Kconfig | 1 +
96
hw/ssi/meson.build | 2 +-
97
hw/ssi/trace-events | 5 +
98
tests/avocado/avocado_qemu/__init__.py | 4 +
99
tests/avocado/boot_linux.py | 48 ++-----
100
tests/avocado/boot_linux_console.py | 1 +
101
tests/avocado/machine_aarch64_virt.py | 63 ++++++++-
102
tests/avocado/reverse_debugging.py | 8 ++
103
tests/qtest/meson.build | 4 +-
104
34 files changed, 798 insertions(+), 399 deletions(-)
105
create mode 100644 include/hw/ssi/npcm_pspi.h
106
create mode 100644 hw/ssi/npcm_pspi.c
107
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: Fabiano Rosas <farosas@suse.de>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
This allows the test to be skipped when TCG is not present in the QEMU
3
The file is obviously related to the raspberrypi machine, so
4
binary.
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: Fabiano Rosas <farosas@suse.de>
8
Signed-off-by: Thomas Huth <thuth@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
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
tests/avocado/boot_linux_console.py | 1 +
14
MAINTAINERS | 2 +-
12
tests/avocado/reverse_debugging.py | 8 ++++++++
15
include/hw/{misc => arm}/raspberrypi-fw-defs.h | 0
13
2 files changed, 9 insertions(+)
16
hw/misc/bcm2835_property.c | 2 +-
17
3 files changed, 2 insertions(+), 2 deletions(-)
18
rename include/hw/{misc => arm}/raspberrypi-fw-defs.h (100%)
14
19
15
diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
20
diff --git a/MAINTAINERS b/MAINTAINERS
16
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
17
--- a/tests/avocado/boot_linux_console.py
22
--- a/MAINTAINERS
18
+++ b/tests/avocado/boot_linux_console.py
23
+++ b/MAINTAINERS
19
@@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_uboot_netbsd9(self):
24
@@ -XXX,XX +XXX,XX @@ S: Odd Fixes
20
25
F: hw/arm/raspi.c
21
def test_aarch64_raspi3_atf(self):
26
F: hw/arm/raspi_platform.h
22
"""
27
F: hw/*/bcm283*
23
+ :avocado: tags=accel:tcg
28
-F: include/hw/arm/raspi*
24
:avocado: tags=arch:aarch64
29
+F: include/hw/arm/rasp*
25
:avocado: tags=machine:raspi3b
30
F: include/hw/*/bcm283*
26
:avocado: tags=cpu:cortex-a53
31
F: docs/system/arm/raspi.rst
27
diff --git a/tests/avocado/reverse_debugging.py b/tests/avocado/reverse_debugging.py
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
28
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
29
--- a/tests/avocado/reverse_debugging.py
39
--- a/hw/misc/bcm2835_property.c
30
+++ b/tests/avocado/reverse_debugging.py
40
+++ b/hw/misc/bcm2835_property.c
31
@@ -XXX,XX +XXX,XX @@ def reverse_debugging(self, shift=7, args=None):
41
@@ -XXX,XX +XXX,XX @@
32
vm.shutdown()
42
#include "migration/vmstate.h"
33
43
#include "hw/irq.h"
34
class ReverseDebugging_X86_64(ReverseDebugging):
44
#include "hw/misc/bcm2835_mbox_defs.h"
35
+ """
45
-#include "hw/misc/raspberrypi-fw-defs.h"
36
+ :avocado: tags=accel:tcg
46
+#include "hw/arm/raspberrypi-fw-defs.h"
37
+ """
47
#include "sysemu/dma.h"
38
+
48
#include "qemu/log.h"
39
REG_PC = 0x10
49
#include "qemu/module.h"
40
REG_CS = 0x12
41
def get_pc(self, g):
42
@@ -XXX,XX +XXX,XX @@ def test_x86_64_pc(self):
43
self.reverse_debugging()
44
45
class ReverseDebugging_AArch64(ReverseDebugging):
46
+ """
47
+ :avocado: tags=accel:tcg
48
+ """
49
+
50
REG_PC = 32
51
52
# unidentified gitlab timeout problem
53
--
50
--
54
2.34.1
51
2.34.1
55
52
56
53
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Manually convert to OBJECT_DECLARE_SIMPLE_TYPE() macro,
3
struct arm_boot_info is declared in "hw/arm/boot.h".
4
similarly to automatic conversion from commit 8063396bf3
4
By including the correct header we don't need to declare
5
("Use OBJECT_DECLARE_SIMPLE_TYPE when possible").
5
it again in "target/arm/cpu-qom.h".
6
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230206223502.25122-2-philmd@linaro.org
9
Message-id: 20231013130214.95742-1-philmd@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
include/hw/intc/armv7m_nvic.h | 5 +----
12
include/hw/arm/exynos4210.h | 2 +-
13
1 file changed, 1 insertion(+), 4 deletions(-)
13
target/arm/cpu-qom.h | 2 --
14
2 files changed, 1 insertion(+), 3 deletions(-)
14
15
15
diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h
16
diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/intc/armv7m_nvic.h
18
--- a/include/hw/arm/exynos4210.h
18
+++ b/include/hw/intc/armv7m_nvic.h
19
+++ b/include/hw/arm/exynos4210.h
19
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@
21
#include "hw/intc/exynos4210_gic.h"
22
#include "hw/intc/exynos4210_combiner.h"
23
#include "hw/core/split-irq.h"
24
-#include "target/arm/cpu-qom.h"
25
+#include "hw/arm/boot.h"
20
#include "qom/object.h"
26
#include "qom/object.h"
21
27
22
#define TYPE_NVIC "armv7m_nvic"
28
#define EXYNOS4210_NCPUS 2
29
diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
30
index XXXXXXX..XXXXXXX 100644
31
--- a/target/arm/cpu-qom.h
32
+++ b/target/arm/cpu-qom.h
33
@@ -XXX,XX +XXX,XX @@
34
#include "hw/core/cpu.h"
35
#include "qom/object.h"
36
37
-struct arm_boot_info;
23
-
38
-
24
-typedef struct NVICState NVICState;
39
#define TYPE_ARM_CPU "arm-cpu"
25
-DECLARE_INSTANCE_CHECKER(NVICState, NVIC,
40
26
- TYPE_NVIC)
41
OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU)
27
+OBJECT_DECLARE_SIMPLE_TYPE(NVICState, NVIC)
28
29
/* Highest permitted number of exceptions (architectural limit) */
30
#define NVIC_MAX_VECTORS 512
31
--
42
--
32
2.34.1
43
2.34.1
33
44
34
45
diff view generated by jsdifflib
1
From: Claudio Fontana <cfontana@suse.de>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
Signed-off-by: Claudio Fontana <cfontana@suse.de>
3
This change implements the ResettableClass interface for the device.
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
5
Signed-off-by: Fabiano Rosas <farosas@suse.de>
5
Signed-off-by: Tong Ho <tong.ho@amd.com>
6
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Message-id: 20231003052345.199725-1-tong.ho@amd.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
---
9
target/arm/helper.c | 12 +++++++-----
10
hw/nvram/xlnx-bbram.c | 8 +++++---
10
1 file changed, 7 insertions(+), 5 deletions(-)
11
1 file changed, 5 insertions(+), 3 deletions(-)
11
12
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c
13
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.c
15
--- a/hw/nvram/xlnx-bbram.c
15
+++ b/target/arm/helper.c
16
+++ b/hw/nvram/xlnx-bbram.c
16
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
17
@@ -XXX,XX +XXX,XX @@
17
unsigned int cur_el = arm_current_el(env);
18
* QEMU model of the Xilinx BBRAM Battery Backed RAM
18
int rt;
19
*
19
20
* Copyright (c) 2014-2021 Xilinx Inc.
20
- /*
21
+ * Copyright (c) 2023 Advanced Micro Devices, Inc.
21
- * Note that new_el can never be 0. If cur_el is 0, then
22
*
22
- * el0_a64 is is_a64(), else el0_a64 is ignored.
23
* Permission is hereby granted, free of charge, to any person obtaining a copy
23
- */
24
* of this software and associated documentation files (the "Software"), to deal
24
- aarch64_sve_change_el(env, cur_el, new_el, is_a64(env));
25
@@ -XXX,XX +XXX,XX @@ static RegisterAccessInfo bbram_ctrl_regs_info[] = {
25
+ if (tcg_enabled()) {
26
}
26
+ /*
27
};
27
+ * Note that new_el can never be 0. If cur_el is 0, then
28
28
+ * el0_a64 is is_a64(), else el0_a64 is ignored.
29
-static void bbram_ctrl_reset(DeviceState *dev)
29
+ */
30
+static void bbram_ctrl_reset_hold(Object *obj)
30
+ aarch64_sve_change_el(env, cur_el, new_el, is_a64(env));
31
{
31
+ }
32
- XlnxBBRam *s = XLNX_BBRAM(dev);
32
33
+ XlnxBBRam *s = XLNX_BBRAM(obj);
33
if (cur_el < new_el) {
34
unsigned int i;
34
/*
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);
35
--
48
--
36
2.34.1
49
2.34.1
37
50
38
51
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
arm_v7m_mmu_idx_all() and arm_v7m_mmu_idx_for_secstate_and_priv()
3
This change implements the ResettableClass interface for the device.
4
are only used for system emulation in m_helper.c.
5
Move the definitions to avoid prototype forward declarations.
6
4
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Signed-off-by: Tong Ho <tong.ho@amd.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
9
Message-id: 20230206223502.25122-4-philmd@linaro.org
7
Message-id: 20231004055713.324009-1-tong.ho@amd.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
9
---
12
target/arm/internals.h | 14 --------
10
hw/nvram/xlnx-zynqmp-efuse.c | 8 +++++---
13
target/arm/m_helper.c | 74 +++++++++++++++++++++---------------------
11
1 file changed, 5 insertions(+), 3 deletions(-)
14
2 files changed, 37 insertions(+), 51 deletions(-)
15
12
16
diff --git a/target/arm/internals.h b/target/arm/internals.h
13
diff --git a/hw/nvram/xlnx-zynqmp-efuse.c b/hw/nvram/xlnx-zynqmp-efuse.c
17
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/internals.h
15
--- a/hw/nvram/xlnx-zynqmp-efuse.c
19
+++ b/target/arm/internals.h
16
+++ b/hw/nvram/xlnx-zynqmp-efuse.c
20
@@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx core_to_aa64_mmu_idx(int mmu_idx)
17
@@ -XXX,XX +XXX,XX @@
21
18
* QEMU model of the ZynqMP eFuse
22
int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx);
19
*
23
20
* Copyright (c) 2015 Xilinx Inc.
24
-/*
21
+ * Copyright (c) 2023 Advanced Micro Devices, Inc.
25
- * Return the MMU index for a v7M CPU with all relevant information
22
*
26
- * manually specified.
23
* Written by Edgar E. Iglesias <edgari@xilinx.com>
27
- */
24
*
28
-ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
25
@@ -XXX,XX +XXX,XX @@ static void zynqmp_efuse_register_reset(RegisterInfo *reg)
29
- bool secstate, bool priv, bool negpri);
26
register_reset(reg);
30
-
31
-/*
32
- * Return the MMU index for a v7M CPU in the specified security and
33
- * privilege state.
34
- */
35
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
36
- bool secstate, bool priv);
37
-
38
/* Return the MMU index for a v7M CPU in the specified security state */
39
ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate);
40
41
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/target/arm/m_helper.c
44
+++ b/target/arm/m_helper.c
45
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
46
47
#else /* !CONFIG_USER_ONLY */
48
49
+static ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
50
+ bool secstate, bool priv, bool negpri)
51
+{
52
+ ARMMMUIdx mmu_idx = ARM_MMU_IDX_M;
53
+
54
+ if (priv) {
55
+ mmu_idx |= ARM_MMU_IDX_M_PRIV;
56
+ }
57
+
58
+ if (negpri) {
59
+ mmu_idx |= ARM_MMU_IDX_M_NEGPRI;
60
+ }
61
+
62
+ if (secstate) {
63
+ mmu_idx |= ARM_MMU_IDX_M_S;
64
+ }
65
+
66
+ return mmu_idx;
67
+}
68
+
69
+static ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
70
+ bool secstate, bool priv)
71
+{
72
+ bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate);
73
+
74
+ return arm_v7m_mmu_idx_all(env, secstate, priv, negpri);
75
+}
76
+
77
+/* Return the MMU index for a v7M CPU in the specified security state */
78
+ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
79
+{
80
+ bool priv = arm_v7m_is_handler_mode(env) ||
81
+ !(env->v7m.control[secstate] & 1);
82
+
83
+ return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv);
84
+}
85
+
86
/*
87
* What kind of stack write are we doing? This affects how exceptions
88
* generated during the stacking are treated.
89
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
90
return tt_resp;
91
}
27
}
92
28
93
-ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
29
-static void zynqmp_efuse_reset(DeviceState *dev)
94
- bool secstate, bool priv, bool negpri)
30
+static void zynqmp_efuse_reset_hold(Object *obj)
95
-{
31
{
96
- ARMMMUIdx mmu_idx = ARM_MMU_IDX_M;
32
- XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(dev);
97
-
33
+ XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(obj);
98
- if (priv) {
34
unsigned int i;
99
- mmu_idx |= ARM_MMU_IDX_M_PRIV;
35
100
- }
36
for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
101
-
37
@@ -XXX,XX +XXX,XX @@ static Property zynqmp_efuse_props[] = {
102
- if (negpri) {
38
static void zynqmp_efuse_class_init(ObjectClass *klass, void *data)
103
- mmu_idx |= ARM_MMU_IDX_M_NEGPRI;
39
{
104
- }
40
DeviceClass *dc = DEVICE_CLASS(klass);
105
-
41
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
106
- if (secstate) {
42
107
- mmu_idx |= ARM_MMU_IDX_M_S;
43
- dc->reset = zynqmp_efuse_reset;
108
- }
44
+ rc->phases.hold = zynqmp_efuse_reset_hold;
109
-
45
dc->realize = zynqmp_efuse_realize;
110
- return mmu_idx;
46
dc->vmsd = &vmstate_efuse;
111
-}
47
device_class_set_props(dc, zynqmp_efuse_props);
112
-
113
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
114
- bool secstate, bool priv)
115
-{
116
- bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate);
117
-
118
- return arm_v7m_mmu_idx_all(env, secstate, priv, negpri);
119
-}
120
-
121
-/* Return the MMU index for a v7M CPU in the specified security state */
122
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
123
-{
124
- bool priv = arm_v7m_is_handler_mode(env) ||
125
- !(env->v7m.control[secstate] & 1);
126
-
127
- return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv);
128
-}
129
-
130
#endif /* !CONFIG_USER_ONLY */
131
--
48
--
132
2.34.1
49
2.34.1
133
134
diff view generated by jsdifflib
1
From: Hao Wu <wuhaotsh@google.com>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
Signed-off-by: Hao Wu <wuhaotsh@google.com>
3
This change implements the ResettableClass interface for the device.
4
Reviewed-by: Titus Rwantare <titusr@google.com>
4
5
Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org>
5
Signed-off-by: Tong Ho <tong.ho@amd.com>
6
Message-id: 20230208235433.3989937-4-wuhaotsh@google.com
6
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
7
Message-id: 20231004055339.323833-1-tong.ho@amd.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
---
9
docs/system/arm/nuvoton.rst | 2 +-
10
hw/nvram/xlnx-versal-efuse-ctrl.c | 8 +++++---
10
include/hw/arm/npcm7xx.h | 2 ++
11
1 file changed, 5 insertions(+), 3 deletions(-)
11
hw/arm/npcm7xx.c | 25 +++++++++++++++++++++++--
12
3 files changed, 26 insertions(+), 3 deletions(-)
13
12
14
diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst
13
diff --git a/hw/nvram/xlnx-versal-efuse-ctrl.c b/hw/nvram/xlnx-versal-efuse-ctrl.c
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/docs/system/arm/nuvoton.rst
15
--- a/hw/nvram/xlnx-versal-efuse-ctrl.c
17
+++ b/docs/system/arm/nuvoton.rst
16
+++ b/hw/nvram/xlnx-versal-efuse-ctrl.c
18
@@ -XXX,XX +XXX,XX @@ Supported devices
19
* SMBus controller (SMBF)
20
* Ethernet controller (EMC)
21
* Tachometer
22
+ * Peripheral SPI controller (PSPI)
23
24
Missing devices
25
---------------
26
@@ -XXX,XX +XXX,XX @@ Missing devices
27
28
* Ethernet controller (GMAC)
29
* USB device (USBD)
30
- * Peripheral SPI controller (PSPI)
31
* SD/MMC host
32
* PECI interface
33
* PCI and PCIe root complex and bridges
34
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
35
index XXXXXXX..XXXXXXX 100644
36
--- a/include/hw/arm/npcm7xx.h
37
+++ b/include/hw/arm/npcm7xx.h
38
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@
39
#include "hw/nvram/npcm7xx_otp.h"
18
* QEMU model of the Versal eFuse controller
40
#include "hw/timer/npcm7xx_timer.h"
19
*
41
#include "hw/ssi/npcm7xx_fiu.h"
20
* Copyright (c) 2020 Xilinx Inc.
42
+#include "hw/ssi/npcm_pspi.h"
21
+ * Copyright (c) 2023 Advanced Micro Devices, Inc.
43
#include "hw/usb/hcd-ehci.h"
22
*
44
#include "hw/usb/hcd-ohci.h"
23
* Permission is hereby granted, free of charge, to any person obtaining a copy
45
#include "target/arm/cpu.h"
24
* of this software and associated documentation files (the "Software"), to deal
46
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxState {
25
@@ -XXX,XX +XXX,XX @@ static void efuse_ctrl_register_reset(RegisterInfo *reg)
47
NPCM7xxFIUState fiu[2];
26
register_reset(reg);
48
NPCM7xxEMCState emc[2];
49
NPCM7xxSDHCIState mmc;
50
+ NPCMPSPIState pspi[2];
51
};
52
53
#define TYPE_NPCM7XX "npcm7xx"
54
diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/hw/arm/npcm7xx.c
57
+++ b/hw/arm/npcm7xx.c
58
@@ -XXX,XX +XXX,XX @@ enum NPCM7xxInterrupt {
59
NPCM7XX_EMC1RX_IRQ = 15,
60
NPCM7XX_EMC1TX_IRQ,
61
NPCM7XX_MMC_IRQ = 26,
62
+ NPCM7XX_PSPI2_IRQ = 28,
63
+ NPCM7XX_PSPI1_IRQ = 31,
64
NPCM7XX_TIMER0_IRQ = 32, /* Timer Module 0 */
65
NPCM7XX_TIMER1_IRQ,
66
NPCM7XX_TIMER2_IRQ,
67
@@ -XXX,XX +XXX,XX @@ static const hwaddr npcm7xx_emc_addr[] = {
68
0xf0826000,
69
};
70
71
+/* Register base address for each PSPI Module */
72
+static const hwaddr npcm7xx_pspi_addr[] = {
73
+ 0xf0200000,
74
+ 0xf0201000,
75
+};
76
+
77
static const struct {
78
hwaddr regs_addr;
79
uint32_t unconnected_pins;
80
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_init(Object *obj)
81
object_initialize_child(obj, "emc[*]", &s->emc[i], TYPE_NPCM7XX_EMC);
82
}
83
84
+ for (i = 0; i < ARRAY_SIZE(s->pspi); i++) {
85
+ object_initialize_child(obj, "pspi[*]", &s->pspi[i], TYPE_NPCM_PSPI);
86
+ }
87
+
88
object_initialize_child(obj, "mmc", &s->mmc, TYPE_NPCM7XX_SDHCI);
89
}
27
}
90
28
91
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
29
-static void efuse_ctrl_reset(DeviceState *dev)
92
sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc), 0,
30
+static void efuse_ctrl_reset_hold(Object *obj)
93
npcm7xx_irq(s, NPCM7XX_MMC_IRQ));
31
{
94
32
- XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(dev);
95
+ /* PSPI */
33
+ XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(obj);
96
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_pspi_addr) != ARRAY_SIZE(s->pspi));
34
unsigned int i;
97
+ for (i = 0; i < ARRAY_SIZE(s->pspi); i++) {
35
98
+ SysBusDevice *sbd = SYS_BUS_DEVICE(&s->pspi[i]);
36
for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
99
+ int irq = (i == 0) ? NPCM7XX_PSPI1_IRQ : NPCM7XX_PSPI2_IRQ;
37
@@ -XXX,XX +XXX,XX @@ static Property efuse_ctrl_props[] = {
100
+
38
static void efuse_ctrl_class_init(ObjectClass *klass, void *data)
101
+ sysbus_realize(sbd, &error_abort);
39
{
102
+ sysbus_mmio_map(sbd, 0, npcm7xx_pspi_addr[i]);
40
DeviceClass *dc = DEVICE_CLASS(klass);
103
+ sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, irq));
41
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
104
+ }
42
105
+
43
- dc->reset = efuse_ctrl_reset;
106
create_unimplemented_device("npcm7xx.shm", 0xc0001000, 4 * KiB);
44
+ rc->phases.hold = efuse_ctrl_reset_hold;
107
create_unimplemented_device("npcm7xx.vdmx", 0xe0800000, 4 * KiB);
45
dc->realize = efuse_ctrl_realize;
108
create_unimplemented_device("npcm7xx.pcierc", 0xe1000000, 64 * KiB);
46
dc->vmsd = &vmstate_efuse_ctrl;
109
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
47
device_class_set_props(dc, efuse_ctrl_props);
110
create_unimplemented_device("npcm7xx.peci", 0xf0100000, 4 * KiB);
111
create_unimplemented_device("npcm7xx.siox[1]", 0xf0101000, 4 * KiB);
112
create_unimplemented_device("npcm7xx.siox[2]", 0xf0102000, 4 * KiB);
113
- create_unimplemented_device("npcm7xx.pspi1", 0xf0200000, 4 * KiB);
114
- create_unimplemented_device("npcm7xx.pspi2", 0xf0201000, 4 * KiB);
115
create_unimplemented_device("npcm7xx.ahbpci", 0xf0400000, 1 * MiB);
116
create_unimplemented_device("npcm7xx.mcphy", 0xf05f0000, 64 * KiB);
117
create_unimplemented_device("npcm7xx.gmac1", 0xf0802000, 8 * KiB);
118
--
48
--
119
2.34.1
49
2.34.1
diff view generated by jsdifflib
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
1
From: Tong Ho <tong.ho@amd.com>
2
2
3
Addresses targeting the second translation table (TTB1) in the SMMU have
3
This replaces the comma (,) to dot (.) in the device type name
4
all upper bits set (except for the top byte when TBI is enabled). Fix
4
so the name can be used with the 'driver=' command line option.
5
the TTB1 check.
6
5
7
Reported-by: Ola Hugosson <ola.hugosson@arm.com>
6
Signed-off-by: Tong Ho <tong.ho@amd.com>
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20231003052139.199665-1-tong.ho@amd.com
10
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
11
Message-id: 20230214171921.1917916-3-jean-philippe@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
10
---
14
hw/arm/smmu-common.c | 2 +-
11
include/hw/nvram/xlnx-bbram.h | 2 +-
15
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 1 insertion(+), 1 deletion(-)
16
13
17
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
14
diff --git a/include/hw/nvram/xlnx-bbram.h b/include/hw/nvram/xlnx-bbram.h
18
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/smmu-common.c
16
--- a/include/hw/nvram/xlnx-bbram.h
20
+++ b/hw/arm/smmu-common.c
17
+++ b/include/hw/nvram/xlnx-bbram.h
21
@@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova)
18
@@ -XXX,XX +XXX,XX @@
22
/* there is a ttbr0 region and we are in it (high bits all zero) */
19
23
return &cfg->tt[0];
20
#define RMAX_XLNX_BBRAM ((0x4c / 4) + 1)
24
} else if (cfg->tt[1].tsz &&
21
25
- !extract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte)) {
22
-#define TYPE_XLNX_BBRAM "xlnx,bbram-ctrl"
26
+ sextract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte) == -1) {
23
+#define TYPE_XLNX_BBRAM "xlnx.bbram-ctrl"
27
/* there is a ttbr1 region and we are in it (high bits all one) */
24
OBJECT_DECLARE_SIMPLE_TYPE(XlnxBBRam, XLNX_BBRAM);
28
return &cfg->tt[1];
25
29
} else if (!cfg->tt[0].tsz) {
26
struct XlnxBBRam {
30
--
27
--
31
2.34.1
28
2.34.1
diff view generated by jsdifflib
1
From: Hao Wu <wuhaotsh@google.com>
1
From: Viktor Prutyanov <viktor@daynix.com>
2
2
3
Havard is no longer working on the Nuvoton systems for a while
3
String sign_rsds isn't terminated, so the print length must be limited.
4
and won't be able to do any work on it in the future. So I'll
5
take over maintaining the Nuvoton system from him.
6
4
7
Signed-off-by: Hao Wu <wuhaotsh@google.com>
5
Fixes: Coverity CID 1521598
8
Acked-by: Havard Skinnemoen <hskinnemoen@google.com>
6
Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
9
Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org>
7
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
10
Message-id: 20230208235433.3989937-2-wuhaotsh@google.com
8
Message-id: 20230930235317.11469-2-viktor@daynix.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
10
---
13
MAINTAINERS | 2 +-
11
contrib/elf2dmp/main.c | 2 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 1 insertion(+), 1 deletion(-)
15
13
16
diff --git a/MAINTAINERS b/MAINTAINERS
14
diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/MAINTAINERS
16
--- a/contrib/elf2dmp/main.c
19
+++ b/MAINTAINERS
17
+++ b/contrib/elf2dmp/main.c
20
@@ -XXX,XX +XXX,XX @@ F: include/hw/net/mv88w8618_eth.h
18
@@ -XXX,XX +XXX,XX @@ static bool pe_check_pdb_name(uint64_t base, void *start_addr,
21
F: docs/system/arm/musicpal.rst
19
}
22
20
23
Nuvoton NPCM7xx
21
if (memcmp(&rsds->Signature, sign_rsds, sizeof(sign_rsds))) {
24
-M: Havard Skinnemoen <hskinnemoen@google.com>
22
- eprintf("CodeView signature is \'%.4s\', \'%s\' expected\n",
25
M: Tyrone Ting <kfting@nuvoton.com>
23
+ eprintf("CodeView signature is \'%.4s\', \'%.4s\' expected\n",
26
+M: Hao Wu <wuhaotsh@google.com>
24
rsds->Signature, sign_rsds);
27
L: qemu-arm@nongnu.org
25
return false;
28
S: Supported
26
}
29
F: hw/*/npcm7xx*
30
--
27
--
31
2.34.1
28
2.34.1
diff view generated by jsdifflib
1
From: Fabiano Rosas <farosas@suse.de>
1
From: Viktor Prutyanov <viktor@daynix.com>
2
2
3
Move this earlier to make the next patch diff cleaner. While here
3
Index in file_size array must be checked against num_files, because the
4
update the comment slightly to not give the impression that the
4
entries we are looking for may be absent in the PDB.
5
misalignment affects only TCG.
6
5
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Fixes: Coverity CID 1521597
7
Signed-off-by: Viktor Prutyanov <viktor@daynix.com>
8
Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Signed-off-by: Fabiano Rosas <farosas@suse.de>
10
Message-id: 20230930235317.11469-3-viktor@daynix.com
10
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
12
---
13
target/arm/machine.c | 18 +++++++++---------
13
contrib/elf2dmp/pdb.c | 13 +++++++++----
14
1 file changed, 9 insertions(+), 9 deletions(-)
14
1 file changed, 9 insertions(+), 4 deletions(-)
15
15
16
diff --git a/target/arm/machine.c b/target/arm/machine.c
16
diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
17
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/machine.c
18
--- a/contrib/elf2dmp/pdb.c
19
+++ b/target/arm/machine.c
19
+++ b/contrib/elf2dmp/pdb.c
20
@@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id)
20
@@ -XXX,XX +XXX,XX @@
21
}
21
22
}
22
static uint32_t pdb_get_file_size(const struct pdb_reader *r, unsigned idx)
23
23
{
24
+ /*
24
+ if (idx >= r->ds.toc->num_files) {
25
+ * Misaligned thumb pc is architecturally impossible. Fail the
25
+ return 0;
26
+ * incoming migration. For TCG it would trigger the assert in
27
+ * thumb_tr_translate_insn().
28
+ */
29
+ if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) {
30
+ return -1;
31
+ }
26
+ }
32
+
27
+
33
hw_breakpoint_update_all(cpu);
28
return r->ds.toc->file_size[idx];
34
hw_watchpoint_update_all(cpu);
29
}
35
30
36
@@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id)
31
@@ -XXX,XX +XXX,XX @@ static void *pdb_ds_read_file(struct pdb_reader* r, uint32_t file_number)
37
}
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;
38
}
43
}
39
44
40
- /*
45
- r->segs = segs;
41
- * Misaligned thumb pc is architecturally impossible.
46
r->segs_size = pdb_get_file_size(r, stream_idx);
42
- * We have an assert in thumb_tr_translate_insn to verify this.
47
+ if (!r->segs_size) {
43
- * Fail an incoming migrate to avoid this assert.
48
+ return 1;
44
- */
49
+ }
45
- if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) {
50
46
- return -1;
51
return 0;
47
- }
52
}
48
-
49
if (!kvm_enabled()) {
50
pmu_op_finish(&cpu->env);
51
}
52
--
53
--
53
2.34.1
54
2.34.1
54
55
55
56
diff view generated by jsdifflib
1
From: Claudio Fontana <cfontana@suse.de>
1
From: Michal Orzel <michal.orzel@amd.com>
2
2
3
for "all" builds (tcg + kvm), we want to avoid doing
3
On an attempt to access CNTPCT_EL0 from EL0 using a guest running on top
4
the psci check if tcg is built-in, but not enabled.
4
of Xen, a trap from EL2 was observed which is something not reproducible
5
on HW (also, Xen does not trap accesses to physical counter).
5
6
6
Signed-off-by: Claudio Fontana <cfontana@suse.de>
7
This is because gt_counter_access() checks for an incorrect bit (1
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
instead of 0) of CNTHCTL_EL2 if HCR_EL2.E2H is 0 and access is made to
8
Signed-off-by: Fabiano Rosas <farosas@suse.de>
9
physical counter. Refer ARM ARM DDI 0487J.a, D19.12.2:
9
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
When HCR_EL2.E2H is 0:
11
- EL1PCTEN, bit [0]: refers to physical counter
12
- EL1PCEN, bit [1]: refers to physical timer registers
13
14
Drop entire block "if (hcr & HCR_E2H) {...} else {...}" from EL0 case
15
and fall through to EL1 case, given that after fixing checking for the
16
correct bit, the handling is the same.
17
18
Fixes: 5bc8437136fb ("target/arm: Update timer access for VHE")
19
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
20
Tested-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
21
Message-id: 20230928094404.20802-1-michal.orzel@amd.com
22
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
24
---
12
target/arm/helper.c | 3 ++-
25
target/arm/helper.c | 17 +----------------
13
1 file changed, 2 insertions(+), 1 deletion(-)
26
1 file changed, 1 insertion(+), 16 deletions(-)
14
27
15
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
16
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
30
--- a/target/arm/helper.c
18
+++ b/target/arm/helper.c
31
+++ b/target/arm/helper.c
19
@@ -XXX,XX +XXX,XX @@
32
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx,
20
#include "hw/irq.h"
33
if (!extract32(env->cp15.c14_cntkctl, timeridx, 1)) {
21
#include "sysemu/cpu-timers.h"
34
return CP_ACCESS_TRAP;
22
#include "sysemu/kvm.h"
35
}
23
+#include "sysemu/tcg.h"
36
-
24
#include "qapi/qapi-commands-machine-target.h"
37
- /* If HCR_EL2.<E2H,TGE> == '10': check CNTHCTL_EL2.EL1PCTEN. */
25
#include "qapi/error.h"
38
- if (hcr & HCR_E2H) {
26
#include "qemu/guest-random.h"
39
- if (timeridx == GTIMER_PHYS &&
27
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs)
40
- !extract32(env->cp15.cnthctl_el2, 10, 1)) {
28
env->exception.syndrome);
41
- return CP_ACCESS_TRAP_EL2;
29
}
42
- }
30
43
- } else {
31
- if (arm_is_psci_call(cpu, cs->exception_index)) {
44
- /* If HCR_EL2.<E2H> == 0: check CNTHCTL_EL2.EL1PCEN. */
32
+ if (tcg_enabled() && arm_is_psci_call(cpu, cs->exception_index)) {
45
- if (has_el2 && timeridx == GTIMER_PHYS &&
33
arm_handle_psci_call(cpu);
46
- !extract32(env->cp15.cnthctl_el2, 1, 1)) {
34
qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n");
47
- return CP_ACCESS_TRAP_EL2;
35
return;
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 &&
36
--
56
--
37
2.34.1
57
2.34.1
38
39
diff view generated by jsdifflib
1
From: Fabiano Rosas <farosas@suse.de>
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
2
2
3
Now that the cortex-a15 is under CONFIG_TCG, use as default CPU for a
3
GIC Private Peripheral Interrupts (PPI) are defined as GIC INTID 16-31.
4
KVM-only build the 'max' cpu.
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.
5
9
6
Note that we cannot use 'host' here because the qtests can run without
10
Meanwhile, the PPI(x) macro counterintuitively adds 16 to the input value,
7
any other accelerator (than qtest) and 'host' depends on KVM being
11
converting a PPI index to an INTID.
8
enabled.
9
12
10
Signed-off-by: Fabiano Rosas <farosas@suse.de>
13
Resolve this by redefining the BSA-allocated PPIs by their INTIDs,
11
Acked-by: Richard Henderson <richard.henderson@linaro.org>
14
and replacing the PPI(x) macro with an INTID_TO_PPI(x) one where required.
12
Reviewed-by: Thomas Huth <thuth@redhat.com>
15
16
Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
17
Message-id: 20230919090229.188092-2-quic_llindhol@quicinc.com
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
20
---
15
hw/arm/virt.c | 4 ++++
21
include/hw/arm/virt.h | 14 +++++++-------
16
1 file changed, 4 insertions(+)
22
hw/arm/virt-acpi-build.c | 12 ++++++------
23
hw/arm/virt.c | 24 ++++++++++++++----------
24
3 files changed, 27 insertions(+), 23 deletions(-)
17
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;
18
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
96
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
19
index XXXXXXX..XXXXXXX 100644
97
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/virt.c
98
--- a/hw/arm/virt.c
21
+++ b/hw/arm/virt.c
99
+++ b/hw/arm/virt.c
22
@@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
100
@@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms)
23
mc->minimum_page_bits = 12;
101
}
24
mc->possible_cpu_arch_ids = virt_possible_cpu_arch_ids;
102
qemu_fdt_setprop(ms->fdt, "/timer", "always-on", NULL, 0);
25
mc->cpu_index_to_instance_props = virt_cpu_index_to_props;
103
qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts",
26
+#ifdef CONFIG_TCG
104
- GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_S_EL1_IRQ, irqflags,
27
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
105
- GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL1_IRQ, irqflags,
28
+#else
106
- GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_VIRT_IRQ, irqflags,
29
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("max");
107
- GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL2_IRQ, irqflags);
30
+#endif
108
+ GIC_FDT_IRQ_TYPE_PPI,
31
mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
109
+ INTID_TO_PPI(ARCH_TIMER_S_EL1_IRQ), irqflags,
32
mc->kvm_type = virt_kvm_type;
110
+ GIC_FDT_IRQ_TYPE_PPI,
33
assert(!mc->get_hotplug_handler);
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
}
34
--
164
--
35
2.34.1
165
2.34.1
diff view generated by jsdifflib
1
From: Hao Wu <wuhaotsh@google.com>
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
2
2
3
Nuvoton's PSPI is a general purpose SPI module which enables
3
virt.h defines a number of IRQs that are ultimately described by Arm's
4
connections to SPI-based peripheral devices.
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.
5
7
6
Signed-off-by: Hao Wu <wuhaotsh@google.com>
8
While we're moving the definitions, sort them into numerical order,
7
Reviewed-by: Chris Rauer <crauer@google.com>
9
and add the ARCH_TIMER_NS_EL2_VIRT_IRQ definition used by sbsa-ref
8
Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org>
10
and which will eventually be needed by virt also.
9
Message-id: 20230208235433.3989937-3-wuhaotsh@google.com
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>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
18
---
12
MAINTAINERS | 6 +-
19
include/hw/arm/bsa.h | 35 +++++++++++++++++++++++++++++++++++
13
include/hw/ssi/npcm_pspi.h | 53 +++++++++
20
include/hw/arm/virt.h | 12 +-----------
14
hw/ssi/npcm_pspi.c | 221 +++++++++++++++++++++++++++++++++++++
21
2 files changed, 36 insertions(+), 11 deletions(-)
15
hw/ssi/meson.build | 2 +-
22
create mode 100644 include/hw/arm/bsa.h
16
hw/ssi/trace-events | 5 +
17
5 files changed, 283 insertions(+), 4 deletions(-)
18
create mode 100644 include/hw/ssi/npcm_pspi.h
19
create mode 100644 hw/ssi/npcm_pspi.c
20
23
21
diff --git a/MAINTAINERS b/MAINTAINERS
24
diff --git a/include/hw/arm/bsa.h b/include/hw/arm/bsa.h
22
index XXXXXXX..XXXXXXX 100644
23
--- a/MAINTAINERS
24
+++ b/MAINTAINERS
25
@@ -XXX,XX +XXX,XX @@ M: Tyrone Ting <kfting@nuvoton.com>
26
M: Hao Wu <wuhaotsh@google.com>
27
L: qemu-arm@nongnu.org
28
S: Supported
29
-F: hw/*/npcm7xx*
30
-F: include/hw/*/npcm7xx*
31
-F: tests/qtest/npcm7xx*
32
+F: hw/*/npcm*
33
+F: include/hw/*/npcm*
34
+F: tests/qtest/npcm*
35
F: pc-bios/npcm7xx_bootrom.bin
36
F: roms/vbootrom
37
F: docs/system/arm/nuvoton.rst
38
diff --git a/include/hw/ssi/npcm_pspi.h b/include/hw/ssi/npcm_pspi.h
39
new file mode 100644
25
new file mode 100644
40
index XXXXXXX..XXXXXXX
26
index XXXXXXX..XXXXXXX
41
--- /dev/null
27
--- /dev/null
42
+++ b/include/hw/ssi/npcm_pspi.h
28
+++ b/include/hw/arm/bsa.h
43
@@ -XXX,XX +XXX,XX @@
29
@@ -XXX,XX +XXX,XX @@
44
+/*
30
+/*
45
+ * Nuvoton Peripheral SPI Module
31
+ * Common definitions for Arm Base System Architecture (BSA) platforms.
46
+ *
32
+ *
47
+ * Copyright 2023 Google LLC
33
+ * Copyright (c) 2015 Linaro Limited
34
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
48
+ *
35
+ *
49
+ * This program is free software; you can redistribute it and/or modify it
36
+ * This program is free software; you can redistribute it and/or modify it
50
+ * under the terms of the GNU General Public License as published by the
37
+ * under the terms and conditions of the GNU General Public License,
51
+ * Free Software Foundation; either version 2 of the License, or
38
+ * version 2 or later, as published by the Free Software Foundation.
52
+ * (at your option) any later version.
53
+ *
39
+ *
54
+ * This program is distributed in the hope that it will be useful, but WITHOUT
40
+ * This program is distributed in the hope it will be useful, but WITHOUT
55
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
41
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
56
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
42
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
57
+ * for more details.
43
+ * more details.
58
+ */
59
+#ifndef NPCM_PSPI_H
60
+#define NPCM_PSPI_H
61
+
62
+#include "hw/ssi/ssi.h"
63
+#include "hw/sysbus.h"
64
+
65
+/*
66
+ * Number of registers in our device state structure. Don't change this without
67
+ * incrementing the version_id in the vmstate.
68
+ */
69
+#define NPCM_PSPI_NR_REGS 3
70
+
71
+/**
72
+ * NPCMPSPIState - Device state for one Flash Interface Unit.
73
+ * @parent: System bus device.
74
+ * @mmio: Memory region for register access.
75
+ * @spi: The SPI bus mastered by this controller.
76
+ * @regs: Register contents.
77
+ * @irq: The interrupt request queue for this module.
78
+ *
44
+ *
79
+ * Each PSPI has a shared bank of registers, and controls up to four chip
45
+ * You should have received a copy of the GNU General Public License along with
80
+ * selects. Each chip select has a dedicated memory region which may be used to
46
+ * this program. If not, see <http://www.gnu.org/licenses/>.
81
+ * read and write the flash connected to that chip select as if it were memory.
82
+ */
83
+typedef struct NPCMPSPIState {
84
+ SysBusDevice parent;
85
+
86
+ MemoryRegion mmio;
87
+
88
+ SSIBus *spi;
89
+ uint16_t regs[NPCM_PSPI_NR_REGS];
90
+ qemu_irq irq;
91
+} NPCMPSPIState;
92
+
93
+#define TYPE_NPCM_PSPI "npcm-pspi"
94
+OBJECT_DECLARE_SIMPLE_TYPE(NPCMPSPIState, NPCM_PSPI)
95
+
96
+#endif /* NPCM_PSPI_H */
97
diff --git a/hw/ssi/npcm_pspi.c b/hw/ssi/npcm_pspi.c
98
new file mode 100644
99
index XXXXXXX..XXXXXXX
100
--- /dev/null
101
+++ b/hw/ssi/npcm_pspi.c
102
@@ -XXX,XX +XXX,XX @@
103
+/*
104
+ * Nuvoton NPCM Peripheral SPI Module (PSPI)
105
+ *
47
+ *
106
+ * Copyright 2023 Google LLC
107
+ *
108
+ * This program is free software; you can redistribute it and/or modify it
109
+ * under the terms of the GNU General Public License as published by the
110
+ * Free Software Foundation; either version 2 of the License, or
111
+ * (at your option) any later version.
112
+ *
113
+ * This program is distributed in the hope that it will be useful, but WITHOUT
114
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
115
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
116
+ * for more details.
117
+ */
48
+ */
118
+
49
+
119
+#include "qemu/osdep.h"
50
+#ifndef QEMU_ARM_BSA_H
51
+#define QEMU_ARM_BSA_H
120
+
52
+
121
+#include "hw/irq.h"
53
+/* These are architectural INTID values */
122
+#include "hw/registerfields.h"
54
+#define VIRTUAL_PMU_IRQ 23
123
+#include "hw/ssi/npcm_pspi.h"
55
+#define ARCH_GIC_MAINT_IRQ 25
124
+#include "migration/vmstate.h"
56
+#define ARCH_TIMER_NS_EL2_IRQ 26
125
+#include "qapi/error.h"
57
+#define ARCH_TIMER_VIRT_IRQ 27
126
+#include "qemu/error-report.h"
58
+#define ARCH_TIMER_NS_EL2_VIRT_IRQ 28
127
+#include "qemu/log.h"
59
+#define ARCH_TIMER_S_EL1_IRQ 29
128
+#include "qemu/module.h"
60
+#define ARCH_TIMER_NS_EL1_IRQ 30
129
+#include "qemu/units.h"
130
+
61
+
131
+#include "trace.h"
62
+#define INTID_TO_PPI(irq) ((irq) - 16)
132
+
63
+
133
+REG16(PSPI_DATA, 0x0)
64
+#endif /* QEMU_ARM_BSA_H */
134
+REG16(PSPI_CTL1, 0x2)
65
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
135
+ FIELD(PSPI_CTL1, SPIEN, 0, 1)
136
+ FIELD(PSPI_CTL1, MOD, 2, 1)
137
+ FIELD(PSPI_CTL1, EIR, 5, 1)
138
+ FIELD(PSPI_CTL1, EIW, 6, 1)
139
+ FIELD(PSPI_CTL1, SCM, 7, 1)
140
+ FIELD(PSPI_CTL1, SCIDL, 8, 1)
141
+ FIELD(PSPI_CTL1, SCDV, 9, 7)
142
+REG16(PSPI_STAT, 0x4)
143
+ FIELD(PSPI_STAT, BSY, 0, 1)
144
+ FIELD(PSPI_STAT, RBF, 1, 1)
145
+
146
+static void npcm_pspi_update_irq(NPCMPSPIState *s)
147
+{
148
+ int level = 0;
149
+
150
+ /* Only fire IRQ when the module is enabled. */
151
+ if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, SPIEN)) {
152
+ /* Update interrupt as BSY is cleared. */
153
+ if ((!FIELD_EX16(s->regs[R_PSPI_STAT], PSPI_STAT, BSY)) &&
154
+ FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, EIW)) {
155
+ level = 1;
156
+ }
157
+
158
+ /* Update interrupt as RBF is set. */
159
+ if (FIELD_EX16(s->regs[R_PSPI_STAT], PSPI_STAT, RBF) &&
160
+ FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, EIR)) {
161
+ level = 1;
162
+ }
163
+ }
164
+ qemu_set_irq(s->irq, level);
165
+}
166
+
167
+static uint16_t npcm_pspi_read_data(NPCMPSPIState *s)
168
+{
169
+ uint16_t value = s->regs[R_PSPI_DATA];
170
+
171
+ /* Clear stat bits as the value are read out. */
172
+ s->regs[R_PSPI_STAT] = 0;
173
+
174
+ return value;
175
+}
176
+
177
+static void npcm_pspi_write_data(NPCMPSPIState *s, uint16_t data)
178
+{
179
+ uint16_t value = 0;
180
+
181
+ if (FIELD_EX16(s->regs[R_PSPI_CTL1], PSPI_CTL1, MOD)) {
182
+ value = ssi_transfer(s->spi, extract16(data, 8, 8)) << 8;
183
+ }
184
+ value |= ssi_transfer(s->spi, extract16(data, 0, 8));
185
+ s->regs[R_PSPI_DATA] = value;
186
+
187
+ /* Mark data as available */
188
+ s->regs[R_PSPI_STAT] = R_PSPI_STAT_BSY_MASK | R_PSPI_STAT_RBF_MASK;
189
+}
190
+
191
+/* Control register read handler. */
192
+static uint64_t npcm_pspi_ctrl_read(void *opaque, hwaddr addr,
193
+ unsigned int size)
194
+{
195
+ NPCMPSPIState *s = opaque;
196
+ uint16_t value;
197
+
198
+ switch (addr) {
199
+ case A_PSPI_DATA:
200
+ value = npcm_pspi_read_data(s);
201
+ break;
202
+
203
+ case A_PSPI_CTL1:
204
+ value = s->regs[R_PSPI_CTL1];
205
+ break;
206
+
207
+ case A_PSPI_STAT:
208
+ value = s->regs[R_PSPI_STAT];
209
+ break;
210
+
211
+ default:
212
+ qemu_log_mask(LOG_GUEST_ERROR,
213
+ "%s: write to invalid offset 0x%" PRIx64 "\n",
214
+ DEVICE(s)->canonical_path, addr);
215
+ return 0;
216
+ }
217
+ trace_npcm_pspi_ctrl_read(DEVICE(s)->canonical_path, addr, value);
218
+ npcm_pspi_update_irq(s);
219
+
220
+ return value;
221
+}
222
+
223
+/* Control register write handler. */
224
+static void npcm_pspi_ctrl_write(void *opaque, hwaddr addr, uint64_t v,
225
+ unsigned int size)
226
+{
227
+ NPCMPSPIState *s = opaque;
228
+ uint16_t value = v;
229
+
230
+ trace_npcm_pspi_ctrl_write(DEVICE(s)->canonical_path, addr, value);
231
+
232
+ switch (addr) {
233
+ case A_PSPI_DATA:
234
+ npcm_pspi_write_data(s, value);
235
+ break;
236
+
237
+ case A_PSPI_CTL1:
238
+ s->regs[R_PSPI_CTL1] = value;
239
+ break;
240
+
241
+ case A_PSPI_STAT:
242
+ qemu_log_mask(LOG_GUEST_ERROR,
243
+ "%s: write to read-only register PSPI_STAT: 0x%08"
244
+ PRIx64 "\n", DEVICE(s)->canonical_path, v);
245
+ break;
246
+
247
+ default:
248
+ qemu_log_mask(LOG_GUEST_ERROR,
249
+ "%s: write to invalid offset 0x%" PRIx64 "\n",
250
+ DEVICE(s)->canonical_path, addr);
251
+ return;
252
+ }
253
+ npcm_pspi_update_irq(s);
254
+}
255
+
256
+static const MemoryRegionOps npcm_pspi_ctrl_ops = {
257
+ .read = npcm_pspi_ctrl_read,
258
+ .write = npcm_pspi_ctrl_write,
259
+ .endianness = DEVICE_LITTLE_ENDIAN,
260
+ .valid = {
261
+ .min_access_size = 1,
262
+ .max_access_size = 2,
263
+ .unaligned = false,
264
+ },
265
+ .impl = {
266
+ .min_access_size = 2,
267
+ .max_access_size = 2,
268
+ .unaligned = false,
269
+ },
270
+};
271
+
272
+static void npcm_pspi_enter_reset(Object *obj, ResetType type)
273
+{
274
+ NPCMPSPIState *s = NPCM_PSPI(obj);
275
+
276
+ trace_npcm_pspi_enter_reset(DEVICE(obj)->canonical_path, type);
277
+ memset(s->regs, 0, sizeof(s->regs));
278
+}
279
+
280
+static void npcm_pspi_realize(DeviceState *dev, Error **errp)
281
+{
282
+ NPCMPSPIState *s = NPCM_PSPI(dev);
283
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
284
+ Object *obj = OBJECT(dev);
285
+
286
+ s->spi = ssi_create_bus(dev, "pspi");
287
+ memory_region_init_io(&s->mmio, obj, &npcm_pspi_ctrl_ops, s,
288
+ "mmio", 4 * KiB);
289
+ sysbus_init_mmio(sbd, &s->mmio);
290
+ sysbus_init_irq(sbd, &s->irq);
291
+}
292
+
293
+static const VMStateDescription vmstate_npcm_pspi = {
294
+ .name = "npcm-pspi",
295
+ .version_id = 0,
296
+ .minimum_version_id = 0,
297
+ .fields = (VMStateField[]) {
298
+ VMSTATE_UINT16_ARRAY(regs, NPCMPSPIState, NPCM_PSPI_NR_REGS),
299
+ VMSTATE_END_OF_LIST(),
300
+ },
301
+};
302
+
303
+
304
+static void npcm_pspi_class_init(ObjectClass *klass, void *data)
305
+{
306
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
307
+ DeviceClass *dc = DEVICE_CLASS(klass);
308
+
309
+ dc->desc = "NPCM Peripheral SPI Module";
310
+ dc->realize = npcm_pspi_realize;
311
+ dc->vmsd = &vmstate_npcm_pspi;
312
+ rc->phases.enter = npcm_pspi_enter_reset;
313
+}
314
+
315
+static const TypeInfo npcm_pspi_types[] = {
316
+ {
317
+ .name = TYPE_NPCM_PSPI,
318
+ .parent = TYPE_SYS_BUS_DEVICE,
319
+ .instance_size = sizeof(NPCMPSPIState),
320
+ .class_init = npcm_pspi_class_init,
321
+ },
322
+};
323
+DEFINE_TYPES(npcm_pspi_types);
324
diff --git a/hw/ssi/meson.build b/hw/ssi/meson.build
325
index XXXXXXX..XXXXXXX 100644
66
index XXXXXXX..XXXXXXX 100644
326
--- a/hw/ssi/meson.build
67
--- a/include/hw/arm/virt.h
327
+++ b/hw/ssi/meson.build
68
+++ b/include/hw/arm/virt.h
328
@@ -XXX,XX +XXX,XX @@
69
@@ -XXX,XX +XXX,XX @@
329
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_smc.c'))
70
#include "qemu/notify.h"
330
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-spi.c'))
71
#include "hw/boards.h"
331
-softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c'))
72
#include "hw/arm/boot.h"
332
+softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c', 'npcm_pspi.c'))
73
+#include "hw/arm/bsa.h"
333
softmmu_ss.add(when: 'CONFIG_PL022', if_true: files('pl022.c'))
74
#include "hw/block/flash.h"
334
softmmu_ss.add(when: 'CONFIG_SIFIVE_SPI', if_true: files('sifive_spi.c'))
75
#include "sysemu/kvm.h"
335
softmmu_ss.add(when: 'CONFIG_SSI', if_true: files('ssi.c'))
76
#include "hw/intc/arm_gicv3_common.h"
336
diff --git a/hw/ssi/trace-events b/hw/ssi/trace-events
77
@@ -XXX,XX +XXX,XX @@
337
index XXXXXXX..XXXXXXX 100644
78
#define NUM_VIRTIO_TRANSPORTS 32
338
--- a/hw/ssi/trace-events
79
#define NUM_SMMU_IRQS 4
339
+++ b/hw/ssi/trace-events
80
340
@@ -XXX,XX +XXX,XX @@ npcm7xx_fiu_ctrl_write(const char *id, uint64_t addr, uint32_t data) "%s offset:
81
-#define ARCH_GIC_MAINT_IRQ 25
341
npcm7xx_fiu_flash_read(const char *id, int cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64
82
-
342
npcm7xx_fiu_flash_write(const char *id, unsigned cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64
83
-#define ARCH_TIMER_VIRT_IRQ 27
343
84
-#define ARCH_TIMER_S_EL1_IRQ 29
344
+# npcm_pspi.c
85
-#define ARCH_TIMER_NS_EL1_IRQ 30
345
+npcm_pspi_enter_reset(const char *id, int reset_type) "%s reset type: %d"
86
-#define ARCH_TIMER_NS_EL2_IRQ 26
346
+npcm_pspi_ctrl_read(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16
87
-
347
+npcm_pspi_ctrl_write(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16
88
-#define VIRTUAL_PMU_IRQ 23
348
+
89
-
349
# ibex_spi_host.c
90
-#define INTID_TO_PPI(irq) ((irq) - 16)
350
91
-
351
ibex_spi_host_reset(const char *msg) "%s"
92
/* See Linux kernel arch/arm64/include/asm/pvclock-abi.h */
93
#define PVTIME_SIZE_PER_CPU 64
94
352
--
95
--
353
2.34.1
96
2.34.1
diff view generated by jsdifflib
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
2
2
3
Addresses targeting the second translation table (TTB1) in the SMMU have
3
Use the private peripheral interrupt definitions from bsa.h instead of
4
all upper bits set. Ensure the IOMMU region covers all 64 bits.
4
defining them locally. Refactor to use the INTIDs defined there instead
5
of the PPI# used previously.
5
6
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
7
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
8
Message-id: 20230919090229.188092-4-quic_llindhol@quicinc.com
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20230214171921.1917916-2-jean-philippe@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
include/hw/arm/smmu-common.h | 2 --
12
hw/arm/sbsa-ref.c | 21 +++++++++------------
13
hw/arm/smmu-common.c | 2 +-
13
1 file changed, 9 insertions(+), 12 deletions(-)
14
2 files changed, 1 insertion(+), 3 deletions(-)
15
14
16
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
15
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/smmu-common.h
17
--- a/hw/arm/sbsa-ref.c
19
+++ b/include/hw/arm/smmu-common.h
18
+++ b/hw/arm/sbsa-ref.c
20
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
21
#define SMMU_PCI_DEVFN_MAX 256
20
* ARM SBSA Reference Platform emulation
22
#define SMMU_PCI_DEVFN(sid) (sid & 0xFF)
21
*
23
22
* Copyright (c) 2018 Linaro Limited
24
-#define SMMU_MAX_VA_BITS 48
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
25
-
46
-
26
/*
47
enum {
27
* Page table walk error types
48
SBSA_FLASH,
28
*/
49
SBSA_MEM,
29
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
50
@@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem)
30
index XXXXXXX..XXXXXXX 100644
51
*/
31
--- a/hw/arm/smmu-common.c
52
for (i = 0; i < smp_cpus; i++) {
32
+++ b/hw/arm/smmu-common.c
53
DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
33
@@ -XXX,XX +XXX,XX @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)
54
- int ppibase = NUM_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS;
34
55
+ int intidbase = NUM_IRQS + i * GIC_INTERNAL;
35
memory_region_init_iommu(&sdev->iommu, sizeof(sdev->iommu),
56
int irq;
36
s->mrtypename,
57
/*
37
- OBJECT(s), name, 1ULL << SMMU_MAX_VA_BITS);
58
* Mapping from the output timer irq lines from the CPU to the
38
+ OBJECT(s), name, UINT64_MAX);
59
@@ -XXX,XX +XXX,XX @@ static void create_gic(SBSAMachineState *sms, MemoryRegion *mem)
39
address_space_init(&sdev->as,
60
for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) {
40
MEMORY_REGION(&sdev->iommu), name);
61
qdev_connect_gpio_out(cpudev, irq,
41
trace_smmu_add_mr(name);
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));
42
--
80
--
43
2.34.1
81
2.34.1
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Cornelia Huck <cohuck@redhat.com>
2
2
3
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
3
We can neaten the code by switching to the kvm_set_one_reg function.
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Gavin Shan <gshan@redhat.com>
6
Message-id: 20230206223502.25122-3-philmd@linaro.org
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>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
11
---
9
target/arm/m_helper.c | 11 ++++++++---
12
target/arm/kvm.c | 13 +++------
10
1 file changed, 8 insertions(+), 3 deletions(-)
13
target/arm/kvm64.c | 66 +++++++++++++---------------------------------
11
14
2 files changed, 21 insertions(+), 58 deletions(-)
12
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
15
16
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
13
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/m_helper.c
18
--- a/target/arm/kvm.c
15
+++ b/target/arm/m_helper.c
19
+++ b/target/arm/kvm.c
16
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
20
@@ -XXX,XX +XXX,XX @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level)
17
return 0;
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, &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, &reg);
85
+ return kvm_set_one_reg(cs, KVM_REG_ARM64_SVE_VLS, &vls[0]);
18
}
86
}
19
87
20
-#else
88
#define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5
21
+ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
89
@@ -XXX,XX +XXX,XX @@ static void kvm_inject_arm_sea(CPUState *c)
22
+{
90
static int kvm_arch_put_fpsimd(CPUState *cs)
23
+ return ARMMMUIdx_MUser;
91
{
24
+}
92
CPUARMState *env = &ARM_CPU(cs)->env;
25
+
93
- struct kvm_one_reg reg;
26
+#else /* !CONFIG_USER_ONLY */
94
int i, ret;
27
95
28
/*
96
for (i = 0; i < 32; i++) {
29
* What kind of stack write are we doing? This affects how exceptions
97
uint64_t *q = aa64_vfp_qreg(env, i);
30
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
98
#if HOST_BIG_ENDIAN
31
return tt_resp;
99
uint64_t fp_val[2] = { q[1], q[0] };
32
}
100
- reg.addr = (uintptr_t)fp_val;
33
101
+ ret = kvm_set_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]),
34
-#endif /* !CONFIG_USER_ONLY */
102
+ fp_val);
35
-
103
#else
36
ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
104
- reg.addr = (uintptr_t)q;
37
bool secstate, bool priv, bool negpri)
105
+ ret = kvm_set_one_reg(cs, AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]), q);
38
{
106
#endif
39
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
107
- reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]);
40
108
- ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &reg);
41
return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv);
109
if (ret) {
42
}
110
return ret;
43
+
111
}
44
+#endif /* !CONFIG_USER_ONLY */
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, &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, &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, &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, &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, &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, &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, &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, &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, &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, &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, &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, &reg);
245
+ ret = kvm_set_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpcr), &fpr);
246
if (ret) {
247
return ret;
248
}
45
--
249
--
46
2.34.1
250
2.34.1
47
251
48
252
diff view generated by jsdifflib
1
From: Claudio Fontana <cfontana@suse.de>
1
From: Cornelia Huck <cohuck@redhat.com>
2
2
3
make it clearer from the name that this is a tcg-only function.
3
We can neaten the code by switching the callers that work on a
4
4
CPUstate to the kvm_get_one_reg function.
5
Signed-off-by: Claudio Fontana <cfontana@suse.de>
5
6
Signed-off-by: Fabiano Rosas <farosas@suse.de>
6
Reviewed-by: Gavin Shan <gshan@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Tested-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>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
---
12
target/arm/helper.c | 4 ++--
13
target/arm/kvm.c | 15 +++---------
13
1 file changed, 2 insertions(+), 2 deletions(-)
14
target/arm/kvm64.c | 57 ++++++++++++----------------------------------
14
15
2 files changed, 18 insertions(+), 54 deletions(-)
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
17
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
16
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
19
--- a/target/arm/kvm.c
18
+++ b/target/arm/helper.c
20
+++ b/target/arm/kvm.c
19
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
21
@@ -XXX,XX +XXX,XX @@ bool write_kvmstate_to_list(ARMCPU *cpu)
20
* trapped to the hypervisor in KVM.
22
bool ok = true;
21
*/
23
22
#ifdef CONFIG_TCG
24
for (i = 0; i < cpu->cpreg_array_len; i++) {
23
-static void handle_semihosting(CPUState *cs)
25
- struct kvm_one_reg r;
24
+static void tcg_handle_semihosting(CPUState *cs)
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, &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, &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)
25
{
88
{
26
ARMCPU *cpu = ARM_CPU(cs);
89
ARMCPU *cpu = ARM_CPU(cs);
27
CPUARMState *env = &cpu->env;
90
CPUARMState *env = &cpu->env;
28
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs)
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, &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, &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, &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, &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, &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, &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, &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)
29
*/
172
*/
30
#ifdef CONFIG_TCG
173
aarch64_restore_sp(env, 1);
31
if (cs->exception_index == EXCP_SEMIHOST) {
174
32
- handle_semihosting(cs);
175
- reg.id = AARCH64_CORE_REG(regs.pc);
33
+ tcg_handle_semihosting(cs);
176
- reg.addr = (uintptr_t) &env->pc;
34
return;
177
- ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &reg);
35
}
178
+ ret = kvm_get_one_reg(cs, AARCH64_CORE_REG(regs.pc), &env->pc);
36
#endif
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, &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, &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, &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, &reg);
221
+ ret = kvm_get_one_reg(cs, AARCH64_SIMD_CTRL_REG(fp_regs.fpcr), &fpr);
222
if (ret) {
223
return ret;
224
}
37
--
225
--
38
2.34.1
226
2.34.1
39
227
40
228
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
For the Thumb T32 encoding of LDM, if only a single register is
2
specified in the register list this instruction is UNPREDICTABLE,
3
with the following choices:
4
* instruction UNDEFs
5
* instruction is a NOP
6
* instruction loads a single register
7
* instruction loads an unspecified set of registers
2
8
3
There is no point in using a void pointer to access the NVIC.
9
Currently we choose to UNDEF (a behaviour chosen in commit
4
Use the real type to avoid casting it while debugging.
10
4b222545dbf30 in 2019; previously we treated it as "load the
11
specified single register").
5
12
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
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
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
25
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230206223502.25122-11-philmd@linaro.org
26
Message-id: 20230927101853.39288-1-peter.maydell@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
27
---
11
target/arm/cpu.h | 46 ++++++++++++++++++++++---------------------
28
target/arm/tcg/translate.c | 37 +++++++++++++++++++++++--------------
12
hw/intc/armv7m_nvic.c | 38 ++++++++++++-----------------------
29
1 file changed, 23 insertions(+), 14 deletions(-)
13
target/arm/cpu.c | 1 +
14
target/arm/m_helper.c | 2 +-
15
4 files changed, 39 insertions(+), 48 deletions(-)
16
30
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
31
diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c
18
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
33
--- a/target/arm/tcg/translate.c
20
+++ b/target/arm/cpu.h
34
+++ b/target/arm/tcg/translate.c
21
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMTBFlags {
35
@@ -XXX,XX +XXX,XX @@ static void op_addr_block_post(DisasContext *s, arg_ldst_block *a,
22
36
}
23
typedef struct ARMMMUFaultInfo ARMMMUFaultInfo;
37
}
24
38
25
+typedef struct NVICState NVICState;
39
-static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n)
26
+
40
+static bool op_stm(DisasContext *s, arg_ldst_block *a)
27
typedef struct CPUArchState {
28
/* Regs for current mode. */
29
uint32_t regs[16];
30
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
31
} sau;
32
33
#if !defined(CONFIG_USER_ONLY)
34
- void *nvic;
35
+ NVICState *nvic;
36
const struct arm_boot_info *boot_info;
37
/* Store GICv3CPUState to access from this struct */
38
void *gicv3state;
39
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
40
41
/* Interface between CPU and Interrupt controller. */
42
#ifndef CONFIG_USER_ONLY
43
-bool armv7m_nvic_can_take_pending_exception(void *opaque);
44
+bool armv7m_nvic_can_take_pending_exception(NVICState *s);
45
#else
46
-static inline bool armv7m_nvic_can_take_pending_exception(void *opaque)
47
+static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s)
48
{
41
{
49
return true;
42
int i, j, n, list, mem_idx;
50
}
43
bool user = a->u;
51
#endif
44
@@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n)
52
/**
45
53
* armv7m_nvic_set_pending: mark the specified exception as pending
46
list = a->list;
54
- * @opaque: the NVIC
47
n = ctpop16(list);
55
+ * @s: the NVIC
48
- if (n < min_n || a->rn == 15) {
56
* @irq: the exception number to mark pending
49
+ /*
57
* @secure: false for non-banked exceptions or for the nonsecure
50
+ * This is UNPREDICTABLE for n < 1 in all encodings, and we choose
58
* version of a banked exception, true for the secure version of a banked
51
+ * to UNDEF. In the T32 STM encoding n == 1 is also UNPREDICTABLE,
59
@@ -XXX,XX +XXX,XX @@ static inline bool armv7m_nvic_can_take_pending_exception(void *opaque)
52
+ * but hardware treats it like the A32 version and implements the
60
* if @secure is true and @irq does not specify one of the fixed set
53
+ * single-register-store, and some in-the-wild (buggy) software
61
* of architecturally banked exceptions.
54
+ * assumes that, so we don't UNDEF on that case.
62
*/
55
+ */
63
-void armv7m_nvic_set_pending(void *opaque, int irq, bool secure);
56
+ if (n < 1 || a->rn == 15) {
64
+void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure);
57
unallocated_encoding(s);
65
/**
66
* armv7m_nvic_set_pending_derived: mark this derived exception as pending
67
- * @opaque: the NVIC
68
+ * @s: the NVIC
69
* @irq: the exception number to mark pending
70
* @secure: false for non-banked exceptions or for the nonsecure
71
* version of a banked exception, true for the secure version of a banked
72
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure);
73
* exceptions (exceptions generated in the course of trying to take
74
* a different exception).
75
*/
76
-void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure);
77
+void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure);
78
/**
79
* armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending
80
- * @opaque: the NVIC
81
+ * @s: the NVIC
82
* @irq: the exception number to mark pending
83
* @secure: false for non-banked exceptions or for the nonsecure
84
* version of a banked exception, true for the secure version of a banked
85
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure);
86
* Similar to armv7m_nvic_set_pending(), but specifically for exceptions
87
* generated in the course of lazy stacking of FP registers.
88
*/
89
-void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure);
90
+void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure);
91
/**
92
* armv7m_nvic_get_pending_irq_info: return highest priority pending
93
* exception, and whether it targets Secure state
94
- * @opaque: the NVIC
95
+ * @s: the NVIC
96
* @pirq: set to pending exception number
97
* @ptargets_secure: set to whether pending exception targets Secure
98
*
99
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure);
100
* to true if the current highest priority pending exception should
101
* be taken to Secure state, false for NS.
102
*/
103
-void armv7m_nvic_get_pending_irq_info(void *opaque, int *pirq,
104
+void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq,
105
bool *ptargets_secure);
106
/**
107
* armv7m_nvic_acknowledge_irq: make highest priority pending exception active
108
- * @opaque: the NVIC
109
+ * @s: the NVIC
110
*
111
* Move the current highest priority pending exception from the pending
112
* state to the active state, and update v7m.exception to indicate that
113
* it is the exception currently being handled.
114
*/
115
-void armv7m_nvic_acknowledge_irq(void *opaque);
116
+void armv7m_nvic_acknowledge_irq(NVICState *s);
117
/**
118
* armv7m_nvic_complete_irq: complete specified interrupt or exception
119
- * @opaque: the NVIC
120
+ * @s: the NVIC
121
* @irq: the exception number to complete
122
* @secure: true if this exception was secure
123
*
124
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque);
125
* 0 if there is still an irq active after this one was completed
126
* (Ignoring -1, this is the same as the RETTOBASE value before completion.)
127
*/
128
-int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure);
129
+int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure);
130
/**
131
* armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
132
- * @opaque: the NVIC
133
+ * @s: the NVIC
134
* @irq: the exception number to mark pending
135
* @secure: false for non-banked exceptions or for the nonsecure
136
* version of a banked exception, true for the secure version of a banked
137
@@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure);
138
* interrupt the current execution priority. This controls whether the
139
* RDY bit for it in the FPCCR is set.
140
*/
141
-bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure);
142
+bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure);
143
/**
144
* armv7m_nvic_raw_execution_priority: return the raw execution priority
145
- * @opaque: the NVIC
146
+ * @s: the NVIC
147
*
148
* Returns: the raw execution priority as defined by the v8M architecture.
149
* This is the execution priority minus the effects of AIRCR.PRIS,
150
* and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting.
151
* (v8M ARM ARM I_PKLD.)
152
*/
153
-int armv7m_nvic_raw_execution_priority(void *opaque);
154
+int armv7m_nvic_raw_execution_priority(NVICState *s);
155
/**
156
* armv7m_nvic_neg_prio_requested: return true if the requested execution
157
* priority is negative for the specified security state.
158
- * @opaque: the NVIC
159
+ * @s: the NVIC
160
* @secure: the security state to test
161
* This corresponds to the pseudocode IsReqExecPriNeg().
162
*/
163
#ifndef CONFIG_USER_ONLY
164
-bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure);
165
+bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure);
166
#else
167
-static inline bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure)
168
+static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure)
169
{
170
return false;
171
}
172
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
173
index XXXXXXX..XXXXXXX 100644
174
--- a/hw/intc/armv7m_nvic.c
175
+++ b/hw/intc/armv7m_nvic.c
176
@@ -XXX,XX +XXX,XX @@ static inline int nvic_exec_prio(NVICState *s)
177
return MIN(running, s->exception_prio);
178
}
179
180
-bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure)
181
+bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure)
182
{
183
/* Return true if the requested execution priority is negative
184
* for the specified security state, ie that security state
185
@@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure)
186
* mean we don't allow FAULTMASK_NS to actually make the execution
187
* priority negative). Compare pseudocode IsReqExcPriNeg().
188
*/
189
- NVICState *s = opaque;
190
-
191
if (s->cpu->env.v7m.faultmask[secure]) {
192
return true;
58
return true;
193
}
59
}
194
@@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure)
60
@@ -XXX,XX +XXX,XX @@ static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n)
195
return false;
61
62
static bool trans_STM(DisasContext *s, arg_ldst_block *a)
63
{
64
- /* BitCount(list) < 1 is UNPREDICTABLE */
65
- return op_stm(s, a, 1);
66
+ return op_stm(s, a);
196
}
67
}
197
68
198
-bool armv7m_nvic_can_take_pending_exception(void *opaque)
69
static bool trans_STM_t32(DisasContext *s, arg_ldst_block *a)
199
+bool armv7m_nvic_can_take_pending_exception(NVICState *s)
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)
200
{
81
{
201
- NVICState *s = opaque;
82
int i, j, n, list, mem_idx;
202
-
83
bool loaded_base;
203
return nvic_exec_prio(s) > nvic_pending_prio(s);
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);
204
}
107
}
205
108
206
-int armv7m_nvic_raw_execution_priority(void *opaque)
109
static bool trans_LDM_t32(DisasContext *s, arg_ldst_block *a)
207
+int armv7m_nvic_raw_execution_priority(NVICState *s)
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)
208
{
120
{
209
- NVICState *s = opaque;
121
/* Writeback is conditional on the base register not being loaded. */
210
-
122
a->w = !(a->list & (1 << a->rn));
211
return s->exception_prio;
123
- /* BitCount(list) < 1 is UNPREDICTABLE */
124
- return do_ldm(s, a, 1);
125
+ return do_ldm(s, a);
212
}
126
}
213
127
214
@@ -XXX,XX +XXX,XX @@ static void nvic_irq_update(NVICState *s)
128
static bool trans_CLRM(DisasContext *s, arg_CLRM *a)
215
* if @secure is true and @irq does not specify one of the fixed set
216
* of architecturally banked exceptions.
217
*/
218
-static void armv7m_nvic_clear_pending(void *opaque, int irq, bool secure)
219
+static void armv7m_nvic_clear_pending(NVICState *s, int irq, bool secure)
220
{
221
- NVICState *s = (NVICState *)opaque;
222
VecInfo *vec;
223
224
assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
225
@@ -XXX,XX +XXX,XX @@ static void do_armv7m_nvic_set_pending(void *opaque, int irq, bool secure,
226
}
227
}
228
229
-void armv7m_nvic_set_pending(void *opaque, int irq, bool secure)
230
+void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure)
231
{
232
- do_armv7m_nvic_set_pending(opaque, irq, secure, false);
233
+ do_armv7m_nvic_set_pending(s, irq, secure, false);
234
}
235
236
-void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure)
237
+void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure)
238
{
239
- do_armv7m_nvic_set_pending(opaque, irq, secure, true);
240
+ do_armv7m_nvic_set_pending(s, irq, secure, true);
241
}
242
243
-void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure)
244
+void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure)
245
{
246
/*
247
* Pend an exception during lazy FP stacking. This differs
248
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure)
249
* whether we should escalate depends on the saved context
250
* in the FPCCR register, not on the current state of the CPU/NVIC.
251
*/
252
- NVICState *s = (NVICState *)opaque;
253
bool banked = exc_is_banked(irq);
254
VecInfo *vec;
255
bool targets_secure;
256
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure)
257
}
258
259
/* Make pending IRQ active. */
260
-void armv7m_nvic_acknowledge_irq(void *opaque)
261
+void armv7m_nvic_acknowledge_irq(NVICState *s)
262
{
263
- NVICState *s = (NVICState *)opaque;
264
CPUARMState *env = &s->cpu->env;
265
const int pending = s->vectpending;
266
const int running = nvic_exec_prio(s);
267
@@ -XXX,XX +XXX,XX @@ static bool vectpending_targets_secure(NVICState *s)
268
exc_targets_secure(s, s->vectpending);
269
}
270
271
-void armv7m_nvic_get_pending_irq_info(void *opaque,
272
+void armv7m_nvic_get_pending_irq_info(NVICState *s,
273
int *pirq, bool *ptargets_secure)
274
{
275
- NVICState *s = (NVICState *)opaque;
276
const int pending = s->vectpending;
277
bool targets_secure;
278
279
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_get_pending_irq_info(void *opaque,
280
*pirq = pending;
281
}
282
283
-int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure)
284
+int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure)
285
{
286
- NVICState *s = (NVICState *)opaque;
287
VecInfo *vec = NULL;
288
int ret = 0;
289
290
@@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure)
291
return ret;
292
}
293
294
-bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
295
+bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure)
296
{
297
/*
298
* Return whether an exception is "ready", i.e. it is enabled and is
299
@@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
300
* for non-banked exceptions secure is always false; for banked exceptions
301
* it indicates which of the exceptions is required.
302
*/
303
- NVICState *s = (NVICState *)opaque;
304
bool banked = exc_is_banked(irq);
305
VecInfo *vec;
306
int running = nvic_exec_prio(s);
307
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
308
index XXXXXXX..XXXXXXX 100644
309
--- a/target/arm/cpu.c
310
+++ b/target/arm/cpu.c
311
@@ -XXX,XX +XXX,XX @@
312
#if !defined(CONFIG_USER_ONLY)
313
#include "hw/loader.h"
314
#include "hw/boards.h"
315
+#include "hw/intc/armv7m_nvic.h"
316
#endif
317
#include "sysemu/tcg.h"
318
#include "sysemu/qtest.h"
319
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
320
index XXXXXXX..XXXXXXX 100644
321
--- a/target/arm/m_helper.c
322
+++ b/target/arm/m_helper.c
323
@@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr,
324
* that we will need later in order to do lazy FP reg stacking.
325
*/
326
bool is_secure = env->v7m.secure;
327
- void *nvic = env->nvic;
328
+ NVICState *nvic = env->nvic;
329
/*
330
* Some bits are unbanked and live always in fpccr[M_REG_S]; some bits
331
* are banked and we want to update the bit in the bank for the
332
--
129
--
333
2.34.1
130
2.34.1
334
131
335
132
diff view generated by jsdifflib
1
From: Mostafa Saleh <smostafa@google.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
GBPA register can be used to globally abort all
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
transactions.
5
6
It is described in the SMMU manual in "6.3.14 SMMU_GBPA".
7
ABORT reset value is IMPLEMENTATION DEFINED, it is chosen to
8
be zero(Do not abort incoming transactions).
9
10
Other fields have default values of Use Incoming.
11
12
If UPDATE is not set, the write is ignored. This is the only permitted
13
behavior in SMMUv3.2 and later.(6.3.14.1 Update procedure)
14
15
As this patch adds a new state to the SMMU (GBPA), it is added
16
in a new subsection for forward migration compatibility.
17
GBPA is only migrated if its value is different from the reset value.
18
It does this to be backward migration compatible if SW didn't write
19
the register.
20
21
Signed-off-by: Mostafa Saleh <smostafa@google.com>
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Mostafa Saleh <smostafa@google.com>
23
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Eric Auger <eric.auger@redhat.com>
24
Message-id: 20230214094009.2445653-1-smostafa@google.com
8
Message-id: 20230914145705.1648377-2-peter.maydell@linaro.org
25
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
---
9
---
28
hw/arm/smmuv3-internal.h | 7 +++++++
10
hw/arm/smmuv3-internal.h | 38 ++++++++++++++++++++++++++++++++++++++
29
include/hw/arm/smmuv3.h | 1 +
11
1 file changed, 38 insertions(+)
30
hw/arm/smmuv3.c | 43 +++++++++++++++++++++++++++++++++++++++-
31
3 files changed, 50 insertions(+), 1 deletion(-)
32
12
33
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
34
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/arm/smmuv3-internal.h
15
--- a/hw/arm/smmuv3-internal.h
36
+++ b/hw/arm/smmuv3-internal.h
16
+++ b/hw/arm/smmuv3-internal.h
37
@@ -XXX,XX +XXX,XX @@ REG32(CR0ACK, 0x24)
17
@@ -XXX,XX +XXX,XX @@ REG32(IDR0, 0x0)
38
REG32(CR1, 0x28)
18
FIELD(IDR0, S1P, 1 , 1)
39
REG32(CR2, 0x2c)
19
FIELD(IDR0, TTF, 2 , 2)
40
REG32(STATUSR, 0x40)
20
FIELD(IDR0, COHACC, 4 , 1)
41
+REG32(GBPA, 0x44)
21
+ FIELD(IDR0, BTM, 5 , 1)
42
+ FIELD(GBPA, ABORT, 20, 1)
22
+ FIELD(IDR0, HTTU, 6 , 2)
43
+ FIELD(GBPA, UPDATE, 31, 1)
23
+ FIELD(IDR0, DORMHINT, 8 , 1)
24
+ FIELD(IDR0, HYP, 9 , 1)
25
+ FIELD(IDR0, ATS, 10, 1)
26
+ FIELD(IDR0, NS1ATS, 11, 1)
27
FIELD(IDR0, ASID16, 12, 1)
28
+ FIELD(IDR0, MSI, 13, 1)
29
+ FIELD(IDR0, SEV, 14, 1)
30
+ FIELD(IDR0, ATOS, 15, 1)
31
+ FIELD(IDR0, PRI, 16, 1)
32
+ FIELD(IDR0, VMW, 17, 1)
33
FIELD(IDR0, VMID16, 18, 1)
34
+ FIELD(IDR0, CD2L, 19, 1)
35
+ FIELD(IDR0, VATOS, 20, 1)
36
FIELD(IDR0, TTENDIAN, 21, 2)
37
+ FIELD(IDR0, ATSRECERR, 23, 1)
38
FIELD(IDR0, STALL_MODEL, 24, 2)
39
FIELD(IDR0, TERM_MODEL, 26, 1)
40
FIELD(IDR0, STLEVEL, 27, 2)
41
+ FIELD(IDR0, RME_IMPL, 30, 1)
42
43
REG32(IDR1, 0x4)
44
FIELD(IDR1, SIDSIZE, 0 , 6)
45
+ FIELD(IDR1, SSIDSIZE, 6 , 5)
46
+ FIELD(IDR1, PRIQS, 11, 5)
47
FIELD(IDR1, EVENTQS, 16, 5)
48
FIELD(IDR1, CMDQS, 21, 5)
49
+ FIELD(IDR1, ATTR_PERMS_OVR, 26, 1)
50
+ FIELD(IDR1, ATTR_TYPES_OVR, 27, 1)
51
+ FIELD(IDR1, REL, 28, 1)
52
+ FIELD(IDR1, QUEUES_PRESET, 29, 1)
53
+ FIELD(IDR1, TABLES_PRESET, 30, 1)
54
+ FIELD(IDR1, ECMDQ, 31, 1)
55
56
#define SMMU_IDR1_SIDSIZE 16
57
#define SMMU_CMDQS 19
58
#define SMMU_EVENTQS 19
59
60
REG32(IDR2, 0x8)
61
+ FIELD(IDR2, BA_VATOS, 0, 10)
44
+
62
+
45
+/* Use incoming. */
63
REG32(IDR3, 0xc)
46
+#define SMMU_GBPA_RESET_VAL 0x1000
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);
47
+
76
+
48
REG32(IRQ_CTRL, 0x50)
77
REG32(IDR4, 0x10)
49
FIELD(IRQ_CTRL, GERROR_IRQEN, 0, 1)
50
FIELD(IRQ_CTRL, PRI_IRQEN, 1, 1)
51
diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h
52
index XXXXXXX..XXXXXXX 100644
53
--- a/include/hw/arm/smmuv3.h
54
+++ b/include/hw/arm/smmuv3.h
55
@@ -XXX,XX +XXX,XX @@ struct SMMUv3State {
56
uint32_t cr[3];
57
uint32_t cr0ack;
58
uint32_t statusr;
59
+ uint32_t gbpa;
60
uint32_t irq_ctrl;
61
uint32_t gerror;
62
uint32_t gerrorn;
63
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/hw/arm/smmuv3.c
66
+++ b/hw/arm/smmuv3.c
67
@@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s)
68
s->gerror = 0;
69
s->gerrorn = 0;
70
s->statusr = 0;
71
+ s->gbpa = SMMU_GBPA_RESET_VAL;
72
}
73
74
static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr, STE *buf,
75
@@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
76
qemu_mutex_lock(&s->mutex);
77
78
if (!smmu_enabled(s)) {
79
- status = SMMU_TRANS_DISABLE;
80
+ if (FIELD_EX32(s->gbpa, GBPA, ABORT)) {
81
+ status = SMMU_TRANS_ABORT;
82
+ } else {
83
+ status = SMMU_TRANS_DISABLE;
84
+ }
85
goto epilogue;
86
}
87
88
@@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_writel(SMMUv3State *s, hwaddr offset,
89
case A_GERROR_IRQ_CFG2:
90
s->gerror_irq_cfg2 = data;
91
return MEMTX_OK;
92
+ case A_GBPA:
93
+ /*
94
+ * If UPDATE is not set, the write is ignored. This is the only
95
+ * permitted behavior in SMMUv3.2 and later.
96
+ */
97
+ if (data & R_GBPA_UPDATE_MASK) {
98
+ /* Ignore update bit as write is synchronous. */
99
+ s->gbpa = data & ~R_GBPA_UPDATE_MASK;
100
+ }
101
+ return MEMTX_OK;
102
case A_STRTAB_BASE: /* 64b */
103
s->strtab_base = deposit64(s->strtab_base, 0, 32, data);
104
return MEMTX_OK;
105
@@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_readl(SMMUv3State *s, hwaddr offset,
106
case A_STATUSR:
107
*data = s->statusr;
108
return MEMTX_OK;
109
+ case A_GBPA:
110
+ *data = s->gbpa;
111
+ return MEMTX_OK;
112
case A_IRQ_CTRL:
113
case A_IRQ_CTRL_ACK:
114
*data = s->irq_ctrl;
115
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3_queue = {
116
},
117
};
118
119
+static bool smmuv3_gbpa_needed(void *opaque)
120
+{
121
+ SMMUv3State *s = opaque;
122
+
78
+
123
+ /* Only migrate GBPA if it has different reset value. */
79
REG32(IDR5, 0x14)
124
+ return s->gbpa != SMMU_GBPA_RESET_VAL;
80
FIELD(IDR5, OAS, 0, 3);
125
+}
81
FIELD(IDR5, GRAN4K, 4, 1);
126
+
82
FIELD(IDR5, GRAN16K, 5, 1);
127
+static const VMStateDescription vmstate_gbpa = {
83
FIELD(IDR5, GRAN64K, 6, 1);
128
+ .name = "smmuv3/gbpa",
84
+ FIELD(IDR5, VAX, 10, 2);
129
+ .version_id = 1,
85
+ FIELD(IDR5, STALL_MAX, 16, 16);
130
+ .minimum_version_id = 1,
86
131
+ .needed = smmuv3_gbpa_needed,
87
#define SMMU_IDR5_OAS 4
132
+ .fields = (VMStateField[]) {
88
133
+ VMSTATE_UINT32(gbpa, SMMUv3State),
134
+ VMSTATE_END_OF_LIST()
135
+ }
136
+};
137
+
138
static const VMStateDescription vmstate_smmuv3 = {
139
.name = "smmuv3",
140
.version_id = 1,
141
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3 = {
142
143
VMSTATE_END_OF_LIST(),
144
},
145
+ .subsections = (const VMStateDescription * []) {
146
+ &vmstate_gbpa,
147
+ NULL
148
+ }
149
};
150
151
static void smmuv3_instance_init(Object *obj)
152
--
89
--
153
2.34.1
90
2.34.1
diff view generated by jsdifflib
1
From: Fabiano Rosas <farosas@suse.de>
1
In smmuv3_init_regs() when we set the various bits in the ID
2
registers, we do this almost in order of the fields in the
3
registers, but not quite. Move the initialization of
4
SMMU_IDR3.RIL and SMMU_IDR5.OAS into their correct places.
2
5
3
These tests set -accel tcg, so restrict them to when TCG is present.
4
5
Signed-off-by: Fabiano Rosas <farosas@suse.de>
6
Acked-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Thomas Huth <thuth@redhat.com>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Mostafa Saleh <smostafa@google.com>
9
Reviewed-by: Eric Auger <eric.auger@redhat.com>
10
Message-id: 20230914145705.1648377-3-peter.maydell@linaro.org
9
---
11
---
10
tests/qtest/meson.build | 4 ++--
12
hw/arm/smmuv3.c | 4 ++--
11
1 file changed, 2 insertions(+), 2 deletions(-)
13
1 file changed, 2 insertions(+), 2 deletions(-)
12
14
13
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
15
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/tests/qtest/meson.build
17
--- a/hw/arm/smmuv3.c
16
+++ b/tests/qtest/meson.build
18
+++ b/hw/arm/smmuv3.c
17
@@ -XXX,XX +XXX,XX @@ qtests_arm = \
19
@@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s)
18
# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
20
s->idr[1] = FIELD_DP32(s->idr[1], IDR1, EVENTQS, SMMU_EVENTQS);
19
qtests_aarch64 = \
21
s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS, SMMU_CMDQS);
20
(cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) + \
22
21
- (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \
23
- s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1);
22
- (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \
24
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1);
23
+ (config_all.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? \
25
+ s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1);
24
+ ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + \
26
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2);
25
(config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \
27
26
(config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \
28
+ s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */
27
['arm-cpu-features',
29
/* 4K, 16K and 64K granule support */
30
s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN4K, 1);
31
s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN16K, 1);
32
s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN64K, 1);
33
- s->idr[5] = FIELD_DP32(s->idr[5], IDR5, OAS, SMMU_IDR5_OAS); /* 44 bits */
34
35
s->cmdq.base = deposit64(s->cmdq.base, 0, 5, SMMU_CMDQS);
36
s->cmdq.prod = 0;
28
--
37
--
29
2.34.1
38
2.34.1
diff view generated by jsdifflib
1
From: Fabiano Rosas <farosas@suse.de>
1
The SMMUv3.1-XNX feature is mandatory for an SMMUv3.1 if S2P is
2
supported, so we should theoretically have implemented it as part of
3
the recent S2P work. Fortunately, for us the implementation is a
4
no-op.
2
5
3
If a test was tagged with the "accel" tag and the specified
6
This feature is about interpretation of the stage 2 page table
4
accelerator it not present in the qemu binary, cancel the test.
7
descriptor XN bits, which control execute permissions.
5
8
6
We can now write tests without explicit calls to require_accelerator,
9
For QEMU, the permission bits passed to an IOMMU (via MemTxAttrs and
7
just the tag is enough.
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.
8
15
9
Signed-off-by: Fabiano Rosas <farosas@suse.de>
16
We also do not support the bits in the Stream Table Entry that can
17
override the on-the-bus transaction attribute permissions (we do not
18
set SMMU_IDR1.ATTR_PERMS_OVR=1).
19
20
These two things together mean that for our implementation, it never
21
has to deal with transactions with the INST attribute, and so it can
22
correctly ignore the XN bits entirely. So we already implement
23
FEAT_XNX's "XN field is now 2 bits, not 1" behaviour to the extent
24
that we need to.
25
26
Advertise the presence of the feature in SMMU_IDR3.XNX.
27
28
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
29
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
30
Reviewed-by: Mostafa Saleh <smostafa@google.com>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
31
Reviewed-by: Eric Auger <eric.auger@redhat.com>
32
Message-id: 20230914145705.1648377-4-peter.maydell@linaro.org
13
---
33
---
14
tests/avocado/avocado_qemu/__init__.py | 4 ++++
34
hw/arm/smmuv3.c | 4 ++++
15
1 file changed, 4 insertions(+)
35
1 file changed, 4 insertions(+)
16
36
17
diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py
37
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
18
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
19
--- a/tests/avocado/avocado_qemu/__init__.py
39
--- a/hw/arm/smmuv3.c
20
+++ b/tests/avocado/avocado_qemu/__init__.py
40
+++ b/hw/arm/smmuv3.c
21
@@ -XXX,XX +XXX,XX @@ def setUp(self):
41
@@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s)
22
42
s->idr[1] = FIELD_DP32(s->idr[1], IDR1, CMDQS, SMMU_CMDQS);
23
super().setUp('qemu-system-')
43
24
44
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, HAD, 1);
25
+ accel_required = self._get_unique_tag_val('accel')
45
+ if (FIELD_EX32(s->idr[0], IDR0, S2P)) {
26
+ if accel_required:
46
+ /* XNX is a stage-2-specific feature */
27
+ self.require_accelerator(accel_required)
47
+ s->idr[3] = FIELD_DP32(s->idr[3], IDR3, XNX, 1);
28
+
48
+ }
29
self.machine = self.params.get('machine',
49
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, RIL, 1);
30
default=self._get_unique_tag_val('machine'))
50
s->idr[3] = FIELD_DP32(s->idr[3], IDR3, BBML, 2);
31
51
32
--
52
--
33
2.34.1
53
2.34.1
34
35
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@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
8
(We don't need to make the behaviour conditional on feature
9
presence, because the FEAT_HPMN0 behaviour is within the range
10
of permitted UNPREDICTABLE behaviour for a non-FEAT_HPMN0
11
implementation.)
12
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
15
Message-id: 20230921185445.3339214-1-peter.maydell@linaro.org
5
Message-id: 20230206223502.25122-5-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
16
---
8
target/arm/helper.c | 12 ++++++++++--
17
docs/system/arm/emulation.rst | 1 +
9
1 file changed, 10 insertions(+), 2 deletions(-)
18
target/arm/helper.c | 2 +-
19
target/arm/tcg/cpu32.c | 4 ++++
20
target/arm/tcg/cpu64.c | 1 +
21
4 files changed, 7 insertions(+), 1 deletion(-)
10
22
23
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
24
index XXXXXXX..XXXXXXX 100644
25
--- a/docs/system/arm/emulation.rst
26
+++ b/docs/system/arm/emulation.rst
27
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
28
- FEAT_HCX (Support for the HCRX_EL2 register)
29
- FEAT_HPDS (Hierarchical permission disables)
30
- FEAT_HPDS2 (Translation table page-based hardware attributes)
31
+- FEAT_HPMN0 (Setting of MDCR_EL2.HPMN to zero)
32
- FEAT_I8MM (AArch64 Int8 matrix multiplication instructions)
33
- FEAT_IDST (ID space trap handling)
34
- FEAT_IESB (Implicit error synchronization event)
11
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
12
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
37
--- a/target/arm/helper.c
14
+++ b/target/arm/helper.c
38
+++ b/target/arm/helper.c
15
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
39
@@ -XXX,XX +XXX,XX @@ static bool pmevcntr_is_64_bit(CPUARMState *env, int counter)
40
bool hlp = env->cp15.mdcr_el2 & MDCR_HLP;
41
int hpmn = env->cp15.mdcr_el2 & MDCR_HPMN;
42
43
- if (hpmn != 0 && counter >= hpmn) {
44
+ if (counter >= hpmn) {
45
return hlp;
46
}
16
}
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;
17
}
60
}
18
61
19
+#ifndef CONFIG_USER_ONLY
62
/* CPU models. These are not needed for the AArch64 linux-user build. */
20
/*
63
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
21
* We don't know until after realize whether there's a GICv3
64
index XXXXXXX..XXXXXXX 100644
22
* attached, and that is what registers the gicv3 sysregs.
65
--- a/target/arm/tcg/cpu64.c
23
@@ -XXX,XX +XXX,XX @@ static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri)
66
+++ b/target/arm/tcg/cpu64.c
24
return pfr1;
67
@@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj)
25
}
68
t = cpu->isar.id_aa64dfr0;
26
69
t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */
27
-#ifndef CONFIG_USER_ONLY
70
t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 6); /* FEAT_PMUv3p5 */
28
static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri)
71
+ t = FIELD_DP64(t, ID_AA64DFR0, HPMN0, 1); /* FEAT_HPMN0 */
29
{
72
cpu->isar.id_aa64dfr0 = t;
30
ARMCPU *cpu = env_archcpu(env);
73
31
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
74
t = cpu->isar.id_aa64smfr0;
32
.opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 1,
33
.access = PL1_R, .type = ARM_CP_NO_RAW,
34
.accessfn = access_aa32_tid3,
35
+#ifdef CONFIG_USER_ONLY
36
+ .type = ARM_CP_CONST,
37
+ .resetvalue = cpu->isar.id_pfr1,
38
+#else
39
+ .type = ARM_CP_NO_RAW,
40
+ .accessfn = access_aa32_tid3,
41
.readfn = id_pfr1_read,
42
- .writefn = arm_cp_write_ignore },
43
+ .writefn = arm_cp_write_ignore
44
+#endif
45
+ },
46
{ .name = "ID_DFR0", .state = ARM_CP_STATE_BOTH,
47
.opc0 = 3, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 2,
48
.access = PL1_R, .type = ARM_CP_CONST,
49
--
75
--
50
2.34.1
76
2.34.1
51
52
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
The include of hw/arm/virt.h in kvm64.c is unnecessary and also a
2
layering violation since the generic KVM code shouldn't need to know
3
anything about board-specifics. The include line is an accidental
4
leftover from commit 15613357ba53a4763, where we cleaned up the code
5
to not depend on virt board internals but forgot to also remove the
6
now-redundant include line.
2
7
3
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20230206223502.25122-6-philmd@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Gavin Shan <gshan@redhat.com>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Message-id: 20230925110429.3917202-1-peter.maydell@linaro.org
8
---
12
---
9
linux-user/user-internals.h | 2 +-
13
target/arm/kvm64.c | 1 -
10
target/arm/cpu.h | 2 +-
14
1 file changed, 1 deletion(-)
11
linux-user/arm/cpu_loop.c | 4 ++--
12
3 files changed, 4 insertions(+), 4 deletions(-)
13
15
14
diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h
16
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/linux-user/user-internals.h
18
--- a/target/arm/kvm64.c
17
+++ b/linux-user/user-internals.h
19
+++ b/target/arm/kvm64.c
18
@@ -XXX,XX +XXX,XX @@ void print_termios(void *arg);
20
@@ -XXX,XX +XXX,XX @@
19
#ifdef TARGET_ARM
21
#include "internals.h"
20
static inline int regpairs_aligned(CPUArchState *cpu_env, int num)
22
#include "hw/acpi/acpi.h"
21
{
23
#include "hw/acpi/ghes.h"
22
- return cpu_env->eabi == 1;
24
-#include "hw/arm/virt.h"
23
+ return cpu_env->eabi;
25
24
}
26
static bool have_guest_debug;
25
#elif defined(TARGET_MIPS) && defined(TARGET_ABI_MIPSO32)
26
static inline int regpairs_aligned(CPUArchState *cpu_env, int num) { return 1; }
27
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
28
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/cpu.h
30
+++ b/target/arm/cpu.h
31
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
32
33
#if defined(CONFIG_USER_ONLY)
34
/* For usermode syscall translation. */
35
- int eabi;
36
+ bool eabi;
37
#endif
38
39
struct CPUBreakpoint *cpu_breakpoint[16];
40
diff --git a/linux-user/arm/cpu_loop.c b/linux-user/arm/cpu_loop.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/linux-user/arm/cpu_loop.c
43
+++ b/linux-user/arm/cpu_loop.c
44
@@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env)
45
break;
46
case EXCP_SWI:
47
{
48
- env->eabi = 1;
49
+ env->eabi = true;
50
/* system call */
51
if (env->thumb) {
52
/* Thumb is always EABI style with syscall number in r7 */
53
@@ -XXX,XX +XXX,XX @@ void cpu_loop(CPUARMState *env)
54
* > 0xfffff and are handled below as out-of-range.
55
*/
56
n ^= ARM_SYSCALL_BASE;
57
- env->eabi = 0;
58
+ env->eabi = false;
59
}
60
}
61
27
62
--
28
--
63
2.34.1
29
2.34.1
64
30
65
31
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
Although the 'eabi' field is only used in user emulation where
4
CPU reset doesn't occur, it doesn't belong to the area to reset.
5
Move it after the 'end_reset_fields' for consistency.
6
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Message-id: 20230206223502.25122-7-philmd@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/cpu.h | 9 ++++-----
13
1 file changed, 4 insertions(+), 5 deletions(-)
14
15
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu.h
18
+++ b/target/arm/cpu.h
19
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
20
ARMVectorReg zarray[ARM_MAX_VQ * 16];
21
#endif
22
23
-#if defined(CONFIG_USER_ONLY)
24
- /* For usermode syscall translation. */
25
- bool eabi;
26
-#endif
27
-
28
struct CPUBreakpoint *cpu_breakpoint[16];
29
struct CPUWatchpoint *cpu_watchpoint[16];
30
31
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
32
const struct arm_boot_info *boot_info;
33
/* Store GICv3CPUState to access from this struct */
34
void *gicv3state;
35
+#if defined(CONFIG_USER_ONLY)
36
+ /* For usermode syscall translation. */
37
+ bool eabi;
38
+#endif /* CONFIG_USER_ONLY */
39
40
#ifdef TARGET_TAGGED_ADDRESSES
41
/* Linux syscall tagged address support */
42
--
43
2.34.1
44
45
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Message-id: 20230206223502.25122-8-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/cpu.h | 3 ++-
9
1 file changed, 2 insertions(+), 1 deletion(-)
10
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/cpu.h
14
+++ b/target/arm/cpu.h
15
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
16
17
void *nvic;
18
const struct arm_boot_info *boot_info;
19
+#if !defined(CONFIG_USER_ONLY)
20
/* Store GICv3CPUState to access from this struct */
21
void *gicv3state;
22
-#if defined(CONFIG_USER_ONLY)
23
+#else /* CONFIG_USER_ONLY */
24
/* For usermode syscall translation. */
25
bool eabi;
26
#endif /* CONFIG_USER_ONLY */
27
--
28
2.34.1
29
30
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Message-id: 20230206223502.25122-9-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/cpu.h | 2 +-
9
1 file changed, 1 insertion(+), 1 deletion(-)
10
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/cpu.h
14
+++ b/target/arm/cpu.h
15
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
16
} sau;
17
18
void *nvic;
19
- const struct arm_boot_info *boot_info;
20
#if !defined(CONFIG_USER_ONLY)
21
+ const struct arm_boot_info *boot_info;
22
/* Store GICv3CPUState to access from this struct */
23
void *gicv3state;
24
#else /* CONFIG_USER_ONLY */
25
--
26
2.34.1
27
28
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20230206223502.25122-10-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/cpu.h | 2 +-
9
1 file changed, 1 insertion(+), 1 deletion(-)
10
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/cpu.h
14
+++ b/target/arm/cpu.h
15
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
16
uint32_t ctrl;
17
} sau;
18
19
- void *nvic;
20
#if !defined(CONFIG_USER_ONLY)
21
+ void *nvic;
22
const struct arm_boot_info *boot_info;
23
/* Store GICv3CPUState to access from this struct */
24
void *gicv3state;
25
--
26
2.34.1
27
28
diff view generated by jsdifflib
1
From: Fabiano Rosas <farosas@suse.de>
1
The hw/arm/boot.h include in common-semi-target.h is not actually
2
needed, and it's a bit odd because it pulls a hw/arm header into a
3
target/arm file.
2
4
3
Since commit cf7c6d1004 ("target/arm: Split out cpregs.h") we now have
5
This include was originally needed because the semihosting code used
4
a cpregs.h header which is more suitable for this code.
6
the arm_boot_info struct to get the base address of the RAM in system
7
emulation, to use in a (bad) heuristic for the return values for the
8
SYS_HEAPINFO semihosting call. We've since overhauled how we
9
calculate the HEAPINFO values in system emulation, and the code no
10
longer uses the arm_boot_info struct.
5
11
6
Code moved verbatim.
12
Remove the now-redundant include line, and instead directly include
13
the cpu-qom.h header that we were previously getting via boot.h.
7
14
8
Signed-off-by: Fabiano Rosas <farosas@suse.de>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
17
Message-id: 20230925112219.3919261-1-peter.maydell@linaro.org
11
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
18
---
14
target/arm/cpregs.h | 98 +++++++++++++++++++++++++++++++++++++++++++++
19
target/arm/common-semi-target.h | 4 +---
15
target/arm/cpu.h | 91 -----------------------------------------
20
1 file changed, 1 insertion(+), 3 deletions(-)
16
2 files changed, 98 insertions(+), 91 deletions(-)
17
21
18
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
22
diff --git a/target/arm/common-semi-target.h b/target/arm/common-semi-target.h
19
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/cpregs.h
24
--- a/target/arm/common-semi-target.h
21
+++ b/target/arm/cpregs.h
25
+++ b/target/arm/common-semi-target.h
22
@@ -XXX,XX +XXX,XX @@ enum {
26
@@ -XXX,XX +XXX,XX @@
23
ARM_CP_SME = 1 << 19,
27
#ifndef TARGET_ARM_COMMON_SEMI_TARGET_H
24
};
28
#define TARGET_ARM_COMMON_SEMI_TARGET_H
25
29
26
+/*
30
-#ifndef CONFIG_USER_ONLY
27
+ * Interface for defining coprocessor registers.
31
-#include "hw/arm/boot.h"
28
+ * Registers are defined in tables of arm_cp_reginfo structs
32
-#endif
29
+ * which are passed to define_arm_cp_regs().
33
+#include "target/arm/cpu-qom.h"
30
+ */
34
31
+
35
static inline target_ulong common_semi_arg(CPUState *cs, int argno)
32
+/*
33
+ * When looking up a coprocessor register we look for it
34
+ * via an integer which encodes all of:
35
+ * coprocessor number
36
+ * Crn, Crm, opc1, opc2 fields
37
+ * 32 or 64 bit register (ie is it accessed via MRC/MCR
38
+ * or via MRRC/MCRR?)
39
+ * non-secure/secure bank (AArch32 only)
40
+ * We allow 4 bits for opc1 because MRRC/MCRR have a 4 bit field.
41
+ * (In this case crn and opc2 should be zero.)
42
+ * For AArch64, there is no 32/64 bit size distinction;
43
+ * instead all registers have a 2 bit op0, 3 bit op1 and op2,
44
+ * and 4 bit CRn and CRm. The encoding patterns are chosen
45
+ * to be easy to convert to and from the KVM encodings, and also
46
+ * so that the hashtable can contain both AArch32 and AArch64
47
+ * registers (to allow for interprocessing where we might run
48
+ * 32 bit code on a 64 bit core).
49
+ */
50
+/*
51
+ * This bit is private to our hashtable cpreg; in KVM register
52
+ * IDs the AArch64/32 distinction is the KVM_REG_ARM/ARM64
53
+ * in the upper bits of the 64 bit ID.
54
+ */
55
+#define CP_REG_AA64_SHIFT 28
56
+#define CP_REG_AA64_MASK (1 << CP_REG_AA64_SHIFT)
57
+
58
+/*
59
+ * To enable banking of coprocessor registers depending on ns-bit we
60
+ * add a bit to distinguish between secure and non-secure cpregs in the
61
+ * hashtable.
62
+ */
63
+#define CP_REG_NS_SHIFT 29
64
+#define CP_REG_NS_MASK (1 << CP_REG_NS_SHIFT)
65
+
66
+#define ENCODE_CP_REG(cp, is64, ns, crn, crm, opc1, opc2) \
67
+ ((ns) << CP_REG_NS_SHIFT | ((cp) << 16) | ((is64) << 15) | \
68
+ ((crn) << 11) | ((crm) << 7) | ((opc1) << 3) | (opc2))
69
+
70
+#define ENCODE_AA64_CP_REG(cp, crn, crm, op0, op1, op2) \
71
+ (CP_REG_AA64_MASK | \
72
+ ((cp) << CP_REG_ARM_COPROC_SHIFT) | \
73
+ ((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \
74
+ ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \
75
+ ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \
76
+ ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \
77
+ ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT))
78
+
79
+/*
80
+ * Convert a full 64 bit KVM register ID to the truncated 32 bit
81
+ * version used as a key for the coprocessor register hashtable
82
+ */
83
+static inline uint32_t kvm_to_cpreg_id(uint64_t kvmid)
84
+{
85
+ uint32_t cpregid = kvmid;
86
+ if ((kvmid & CP_REG_ARCH_MASK) == CP_REG_ARM64) {
87
+ cpregid |= CP_REG_AA64_MASK;
88
+ } else {
89
+ if ((kvmid & CP_REG_SIZE_MASK) == CP_REG_SIZE_U64) {
90
+ cpregid |= (1 << 15);
91
+ }
92
+
93
+ /*
94
+ * KVM is always non-secure so add the NS flag on AArch32 register
95
+ * entries.
96
+ */
97
+ cpregid |= 1 << CP_REG_NS_SHIFT;
98
+ }
99
+ return cpregid;
100
+}
101
+
102
+/*
103
+ * Convert a truncated 32 bit hashtable key into the full
104
+ * 64 bit KVM register ID.
105
+ */
106
+static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)
107
+{
108
+ uint64_t kvmid;
109
+
110
+ if (cpregid & CP_REG_AA64_MASK) {
111
+ kvmid = cpregid & ~CP_REG_AA64_MASK;
112
+ kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM64;
113
+ } else {
114
+ kvmid = cpregid & ~(1 << 15);
115
+ if (cpregid & (1 << 15)) {
116
+ kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM;
117
+ } else {
118
+ kvmid |= CP_REG_SIZE_U32 | CP_REG_ARM;
119
+ }
120
+ }
121
+ return kvmid;
122
+}
123
+
124
/*
125
* Valid values for ARMCPRegInfo state field, indicating which of
126
* the AArch32 and AArch64 execution states this register is visible in.
127
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
128
index XXXXXXX..XXXXXXX 100644
129
--- a/target/arm/cpu.h
130
+++ b/target/arm/cpu.h
131
@@ -XXX,XX +XXX,XX @@ void arm_cpu_list(void);
132
uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
133
uint32_t cur_el, bool secure);
134
135
-/* Interface for defining coprocessor registers.
136
- * Registers are defined in tables of arm_cp_reginfo structs
137
- * which are passed to define_arm_cp_regs().
138
- */
139
-
140
-/* When looking up a coprocessor register we look for it
141
- * via an integer which encodes all of:
142
- * coprocessor number
143
- * Crn, Crm, opc1, opc2 fields
144
- * 32 or 64 bit register (ie is it accessed via MRC/MCR
145
- * or via MRRC/MCRR?)
146
- * non-secure/secure bank (AArch32 only)
147
- * We allow 4 bits for opc1 because MRRC/MCRR have a 4 bit field.
148
- * (In this case crn and opc2 should be zero.)
149
- * For AArch64, there is no 32/64 bit size distinction;
150
- * instead all registers have a 2 bit op0, 3 bit op1 and op2,
151
- * and 4 bit CRn and CRm. The encoding patterns are chosen
152
- * to be easy to convert to and from the KVM encodings, and also
153
- * so that the hashtable can contain both AArch32 and AArch64
154
- * registers (to allow for interprocessing where we might run
155
- * 32 bit code on a 64 bit core).
156
- */
157
-/* This bit is private to our hashtable cpreg; in KVM register
158
- * IDs the AArch64/32 distinction is the KVM_REG_ARM/ARM64
159
- * in the upper bits of the 64 bit ID.
160
- */
161
-#define CP_REG_AA64_SHIFT 28
162
-#define CP_REG_AA64_MASK (1 << CP_REG_AA64_SHIFT)
163
-
164
-/* To enable banking of coprocessor registers depending on ns-bit we
165
- * add a bit to distinguish between secure and non-secure cpregs in the
166
- * hashtable.
167
- */
168
-#define CP_REG_NS_SHIFT 29
169
-#define CP_REG_NS_MASK (1 << CP_REG_NS_SHIFT)
170
-
171
-#define ENCODE_CP_REG(cp, is64, ns, crn, crm, opc1, opc2) \
172
- ((ns) << CP_REG_NS_SHIFT | ((cp) << 16) | ((is64) << 15) | \
173
- ((crn) << 11) | ((crm) << 7) | ((opc1) << 3) | (opc2))
174
-
175
-#define ENCODE_AA64_CP_REG(cp, crn, crm, op0, op1, op2) \
176
- (CP_REG_AA64_MASK | \
177
- ((cp) << CP_REG_ARM_COPROC_SHIFT) | \
178
- ((op0) << CP_REG_ARM64_SYSREG_OP0_SHIFT) | \
179
- ((op1) << CP_REG_ARM64_SYSREG_OP1_SHIFT) | \
180
- ((crn) << CP_REG_ARM64_SYSREG_CRN_SHIFT) | \
181
- ((crm) << CP_REG_ARM64_SYSREG_CRM_SHIFT) | \
182
- ((op2) << CP_REG_ARM64_SYSREG_OP2_SHIFT))
183
-
184
-/* Convert a full 64 bit KVM register ID to the truncated 32 bit
185
- * version used as a key for the coprocessor register hashtable
186
- */
187
-static inline uint32_t kvm_to_cpreg_id(uint64_t kvmid)
188
-{
189
- uint32_t cpregid = kvmid;
190
- if ((kvmid & CP_REG_ARCH_MASK) == CP_REG_ARM64) {
191
- cpregid |= CP_REG_AA64_MASK;
192
- } else {
193
- if ((kvmid & CP_REG_SIZE_MASK) == CP_REG_SIZE_U64) {
194
- cpregid |= (1 << 15);
195
- }
196
-
197
- /* KVM is always non-secure so add the NS flag on AArch32 register
198
- * entries.
199
- */
200
- cpregid |= 1 << CP_REG_NS_SHIFT;
201
- }
202
- return cpregid;
203
-}
204
-
205
-/* Convert a truncated 32 bit hashtable key into the full
206
- * 64 bit KVM register ID.
207
- */
208
-static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)
209
-{
210
- uint64_t kvmid;
211
-
212
- if (cpregid & CP_REG_AA64_MASK) {
213
- kvmid = cpregid & ~CP_REG_AA64_MASK;
214
- kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM64;
215
- } else {
216
- kvmid = cpregid & ~(1 << 15);
217
- if (cpregid & (1 << 15)) {
218
- kvmid |= CP_REG_SIZE_U64 | CP_REG_ARM;
219
- } else {
220
- kvmid |= CP_REG_SIZE_U32 | CP_REG_ARM;
221
- }
222
- }
223
- return kvmid;
224
-}
225
-
226
/* Return the highest implemented Exception Level */
227
static inline int arm_highest_el(CPUARMState *env)
228
{
36
{
229
--
37
--
230
2.34.1
38
2.34.1
231
232
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
The code for powering on a CPU in arm-powerctl.c has two separate
2
2
use cases:
3
While dozens of files include "cpu.h", only 3 files require
3
* emulation of a real hardware power controller
4
these NVIC helper declarations.
4
* emulation of firmware interfaces (primarily PSCI) with
5
5
CPU on/off APIs
6
7
For the first case, we only need to reset the CPU and set its
8
starting PC and X0. For the second case, because we're emulating the
9
firmware we need to ensure that it's in the state that the firmware
10
provides. In particular, when we reset to a lower EL than the
11
highest one we are emulating, we need to put the CPU into a state
12
that permits correct running at that lower EL. We already do a
13
little of this in arm-powerctl.c (for instance we set SCR_HCE to
14
enable the HVC insn) but we don't do enough of it. This means that
15
in the case where we are emulating EL3 but also providing emulated
16
PSCI the guest will crash when a secondary core tries to use a
17
feature that needs an SCR_EL3 bit to be set, such as MTE or PAuth.
18
19
The hw/arm/boot.c code also has to support this "start guest code in
20
an EL that's lower than the highest emulated EL" case in order to do
21
direct guest kernel booting; it has all the necessary initialization
22
code to set the SCR_EL3 bits. Pull the relevant boot.c code out into
23
a separate function so we can share it between there and
24
arm-powerctl.c.
25
26
This refactoring has a few code changes that look like they
27
might be behaviour changes but aren't:
28
* if info->secure_boot is false and info->secure_board_setup is
29
true, then the old code would start the first CPU in Hyp
30
mode but without changing SCR.NS and NSACR.{CP11,CP10}.
31
This was wrong behaviour because there's no such thing
32
as Secure Hyp mode. The new code will leave the CPU in SVC.
33
(There is no board which sets secure_boot to false and
34
secure_board_setup to true, so this isn't a behaviour
35
change for any of our boards.)
36
* we don't explicitly clear SCR.NS when arm-powerctl.c
37
does a CPU-on to EL3. This was a no-op because CPU reset
38
will reset to NS == 0.
39
40
And some real behaviour changes:
41
* we no longer set HCR_EL2.RW when booting into EL2: the guest
42
can and should do that themselves before dropping into their
43
EL1 code. (arm-powerctl and boot did this differently; I
44
opted to use the logic from arm-powerctl, which only sets
45
HCR_EL2.RW when it's directly starting the guest in EL1,
46
because it's more correct, and I don't expect guests to be
47
accidentally depending on our having set the RW bit for them.)
48
* if we are booting a CPU into AArch32 Secure SVC then we won't
49
set SCR.HCE any more. This affects only the vexpress-a15 and
50
raspi2b machine types. Guests booting in this case will either:
51
- be able to set SCR.HCE themselves as part of moving from
52
Secure SVC into NS Hyp mode
53
- will move from Secure SVC to NS SVC, and won't care about
54
behaviour of the HVC insn
55
- will stay in Secure SVC, and won't care about HVC
56
* on an arm-powerctl CPU-on we will now set the SCR bits for
57
pauth/mte/sve/sme/hcx/fgt features
58
59
The first two of these are very minor and I don't expect guest
60
code to trip over them, so I didn't judge it worth convoluting
61
the code in an attempt to keep exactly the same boot.c behaviour.
62
The third change fixes issue 1899.
63
64
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1899
65
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
66
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
67
Message-id: 20230926155619.4028618-1-peter.maydell@linaro.org
8
Message-id: 20230206223502.25122-12-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
68
---
11
include/hw/intc/armv7m_nvic.h | 123 ++++++++++++++++++++++++++++++++++
69
target/arm/cpu.h | 22 +++++++++
12
target/arm/cpu.h | 123 ----------------------------------
70
hw/arm/boot.c | 95 ++++++++++-----------------------------
13
target/arm/cpu.c | 4 +-
71
target/arm/arm-powerctl.c | 53 +---------------------
14
target/arm/cpu_tcg.c | 3 +
72
target/arm/cpu.c | 95 +++++++++++++++++++++++++++++++++++++++
15
target/arm/m_helper.c | 3 +
73
4 files changed, 141 insertions(+), 124 deletions(-)
16
5 files changed, 132 insertions(+), 124 deletions(-)
74
17
18
diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/intc/armv7m_nvic.h
21
+++ b/include/hw/intc/armv7m_nvic.h
22
@@ -XXX,XX +XXX,XX @@ struct NVICState {
23
qemu_irq sysresetreq;
24
};
25
26
+/* Interface between CPU and Interrupt controller. */
27
+/**
28
+ * armv7m_nvic_set_pending: mark the specified exception as pending
29
+ * @s: the NVIC
30
+ * @irq: the exception number to mark pending
31
+ * @secure: false for non-banked exceptions or for the nonsecure
32
+ * version of a banked exception, true for the secure version of a banked
33
+ * exception.
34
+ *
35
+ * Marks the specified exception as pending. Note that we will assert()
36
+ * if @secure is true and @irq does not specify one of the fixed set
37
+ * of architecturally banked exceptions.
38
+ */
39
+void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure);
40
+/**
41
+ * armv7m_nvic_set_pending_derived: mark this derived exception as pending
42
+ * @s: the NVIC
43
+ * @irq: the exception number to mark pending
44
+ * @secure: false for non-banked exceptions or for the nonsecure
45
+ * version of a banked exception, true for the secure version of a banked
46
+ * exception.
47
+ *
48
+ * Similar to armv7m_nvic_set_pending(), but specifically for derived
49
+ * exceptions (exceptions generated in the course of trying to take
50
+ * a different exception).
51
+ */
52
+void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure);
53
+/**
54
+ * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending
55
+ * @s: the NVIC
56
+ * @irq: the exception number to mark pending
57
+ * @secure: false for non-banked exceptions or for the nonsecure
58
+ * version of a banked exception, true for the secure version of a banked
59
+ * exception.
60
+ *
61
+ * Similar to armv7m_nvic_set_pending(), but specifically for exceptions
62
+ * generated in the course of lazy stacking of FP registers.
63
+ */
64
+void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure);
65
+/**
66
+ * armv7m_nvic_get_pending_irq_info: return highest priority pending
67
+ * exception, and whether it targets Secure state
68
+ * @s: the NVIC
69
+ * @pirq: set to pending exception number
70
+ * @ptargets_secure: set to whether pending exception targets Secure
71
+ *
72
+ * This function writes the number of the highest priority pending
73
+ * exception (the one which would be made active by
74
+ * armv7m_nvic_acknowledge_irq()) to @pirq, and sets @ptargets_secure
75
+ * to true if the current highest priority pending exception should
76
+ * be taken to Secure state, false for NS.
77
+ */
78
+void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq,
79
+ bool *ptargets_secure);
80
+/**
81
+ * armv7m_nvic_acknowledge_irq: make highest priority pending exception active
82
+ * @s: the NVIC
83
+ *
84
+ * Move the current highest priority pending exception from the pending
85
+ * state to the active state, and update v7m.exception to indicate that
86
+ * it is the exception currently being handled.
87
+ */
88
+void armv7m_nvic_acknowledge_irq(NVICState *s);
89
+/**
90
+ * armv7m_nvic_complete_irq: complete specified interrupt or exception
91
+ * @s: the NVIC
92
+ * @irq: the exception number to complete
93
+ * @secure: true if this exception was secure
94
+ *
95
+ * Returns: -1 if the irq was not active
96
+ * 1 if completing this irq brought us back to base (no active irqs)
97
+ * 0 if there is still an irq active after this one was completed
98
+ * (Ignoring -1, this is the same as the RETTOBASE value before completion.)
99
+ */
100
+int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure);
101
+/**
102
+ * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
103
+ * @s: the NVIC
104
+ * @irq: the exception number to mark pending
105
+ * @secure: false for non-banked exceptions or for the nonsecure
106
+ * version of a banked exception, true for the secure version of a banked
107
+ * exception.
108
+ *
109
+ * Return whether an exception is "ready", i.e. whether the exception is
110
+ * enabled and is configured at a priority which would allow it to
111
+ * interrupt the current execution priority. This controls whether the
112
+ * RDY bit for it in the FPCCR is set.
113
+ */
114
+bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure);
115
+/**
116
+ * armv7m_nvic_raw_execution_priority: return the raw execution priority
117
+ * @s: the NVIC
118
+ *
119
+ * Returns: the raw execution priority as defined by the v8M architecture.
120
+ * This is the execution priority minus the effects of AIRCR.PRIS,
121
+ * and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting.
122
+ * (v8M ARM ARM I_PKLD.)
123
+ */
124
+int armv7m_nvic_raw_execution_priority(NVICState *s);
125
+/**
126
+ * armv7m_nvic_neg_prio_requested: return true if the requested execution
127
+ * priority is negative for the specified security state.
128
+ * @s: the NVIC
129
+ * @secure: the security state to test
130
+ * This corresponds to the pseudocode IsReqExecPriNeg().
131
+ */
132
+#ifndef CONFIG_USER_ONLY
133
+bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure);
134
+#else
135
+static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure)
136
+{
137
+ return false;
138
+}
139
+#endif
140
+#ifndef CONFIG_USER_ONLY
141
+bool armv7m_nvic_can_take_pending_exception(NVICState *s);
142
+#else
143
+static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s)
144
+{
145
+ return true;
146
+}
147
+#endif
148
+
149
#endif
150
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
151
index XXXXXXX..XXXXXXX 100644
76
index XXXXXXX..XXXXXXX 100644
152
--- a/target/arm/cpu.h
77
--- a/target/arm/cpu.h
153
+++ b/target/arm/cpu.h
78
+++ b/target/arm/cpu.h
154
@@ -XXX,XX +XXX,XX @@ void arm_cpu_list(void);
79
@@ -XXX,XX +XXX,XX @@ int arm_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
155
uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
80
int arm_cpu_write_elf32_note(WriteCoreDumpFunction f, CPUState *cs,
156
uint32_t cur_el, bool secure);
81
int cpuid, DumpState *s);
157
82
158
-/* Interface between CPU and Interrupt controller. */
83
+/**
159
-#ifndef CONFIG_USER_ONLY
84
+ * arm_emulate_firmware_reset: Emulate firmware CPU reset handling
160
-bool armv7m_nvic_can_take_pending_exception(NVICState *s);
85
+ * @cpu: CPU (which must have been freshly reset)
161
-#else
86
+ * @target_el: exception level to put the CPU into
162
-static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s)
87
+ * @secure: whether to put the CPU in secure state
163
-{
88
+ *
164
- return true;
89
+ * When QEMU is directly running a guest kernel at a lower level than
165
-}
90
+ * EL3 it implicitly emulates some aspects of the guest firmware.
166
-#endif
91
+ * This includes that on reset we need to configure the parts of the
167
-/**
92
+ * CPU corresponding to EL3 so that the real guest code can run at its
168
- * armv7m_nvic_set_pending: mark the specified exception as pending
93
+ * lower exception level. This function does that post-reset CPU setup,
169
- * @s: the NVIC
94
+ * for when we do direct boot of a guest kernel, and for when we
170
- * @irq: the exception number to mark pending
95
+ * emulate PSCI and similar firmware interfaces starting a CPU at a
171
- * @secure: false for non-banked exceptions or for the nonsecure
96
+ * lower exception level.
172
- * version of a banked exception, true for the secure version of a banked
97
+ *
173
- * exception.
98
+ * @target_el must be an EL implemented by the CPU between 1 and 3.
174
- *
99
+ * We do not support dropping into a Secure EL other than 3.
175
- * Marks the specified exception as pending. Note that we will assert()
100
+ *
176
- * if @secure is true and @irq does not specify one of the fixed set
101
+ * It is the responsibility of the caller to call arm_rebuild_hflags().
177
- * of architecturally banked exceptions.
102
+ */
178
- */
103
+void arm_emulate_firmware_reset(CPUState *cpustate, int target_el);
179
-void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure);
104
+
180
-/**
105
#ifdef TARGET_AARCH64
181
- * armv7m_nvic_set_pending_derived: mark this derived exception as pending
106
int aarch64_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
182
- * @s: the NVIC
107
int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
183
- * @irq: the exception number to mark pending
108
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
184
- * @secure: false for non-banked exceptions or for the nonsecure
109
index XXXXXXX..XXXXXXX 100644
185
- * version of a banked exception, true for the secure version of a banked
110
--- a/hw/arm/boot.c
186
- * exception.
111
+++ b/hw/arm/boot.c
187
- *
112
@@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque)
188
- * Similar to armv7m_nvic_set_pending(), but specifically for derived
113
189
- * exceptions (exceptions generated in the course of trying to take
114
cpu_set_pc(cs, entry);
190
- * a different exception).
115
} else {
191
- */
116
- /* If we are booting Linux then we need to check whether we are
192
-void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure);
117
- * booting into secure or non-secure state and adjust the state
193
-/**
118
- * accordingly. Out of reset, ARM is defined to be in secure state
194
- * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending
119
- * (SCR.NS = 0), we change that here if non-secure boot has been
195
- * @s: the NVIC
120
- * requested.
196
- * @irq: the exception number to mark pending
121
+ /*
197
- * @secure: false for non-banked exceptions or for the nonsecure
122
+ * If we are booting Linux then we might need to do so at:
198
- * version of a banked exception, true for the secure version of a banked
123
+ * - AArch64 NS EL2 or NS EL1
199
- * exception.
124
+ * - AArch32 Secure SVC (EL3)
200
- *
125
+ * - AArch32 NS Hyp (EL2)
201
- * Similar to armv7m_nvic_set_pending(), but specifically for exceptions
126
+ * - AArch32 NS SVC (EL1)
202
- * generated in the course of lazy stacking of FP registers.
127
+ * Configure the CPU in the way boot firmware would do to
203
- */
128
+ * drop us down to the appropriate level.
204
-void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure);
129
*/
205
-/**
130
- if (arm_feature(env, ARM_FEATURE_EL3)) {
206
- * armv7m_nvic_get_pending_irq_info: return highest priority pending
131
- /* AArch64 is defined to come out of reset into EL3 if enabled.
207
- * exception, and whether it targets Secure state
132
- * If we are booting Linux then we need to adjust our EL as
208
- * @s: the NVIC
133
- * Linux expects us to be in EL2 or EL1. AArch32 resets into
209
- * @pirq: set to pending exception number
134
- * SVC, which Linux expects, so no privilege/exception level to
210
- * @ptargets_secure: set to whether pending exception targets Secure
135
- * adjust.
211
- *
136
- */
212
- * This function writes the number of the highest priority pending
137
- if (env->aarch64) {
213
- * exception (the one which would be made active by
138
- env->cp15.scr_el3 |= SCR_RW;
214
- * armv7m_nvic_acknowledge_irq()) to @pirq, and sets @ptargets_secure
139
- if (arm_feature(env, ARM_FEATURE_EL2)) {
215
- * to true if the current highest priority pending exception should
140
- env->cp15.hcr_el2 |= HCR_RW;
216
- * be taken to Secure state, false for NS.
141
- env->pstate = PSTATE_MODE_EL2h;
217
- */
142
- } else {
218
-void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq,
143
- env->pstate = PSTATE_MODE_EL1h;
219
- bool *ptargets_secure);
144
- }
220
-/**
145
- if (cpu_isar_feature(aa64_pauth, cpu)) {
221
- * armv7m_nvic_acknowledge_irq: make highest priority pending exception active
146
- env->cp15.scr_el3 |= SCR_API | SCR_APK;
222
- * @s: the NVIC
147
- }
223
- *
148
- if (cpu_isar_feature(aa64_mte, cpu)) {
224
- * Move the current highest priority pending exception from the pending
149
- env->cp15.scr_el3 |= SCR_ATA;
225
- * state to the active state, and update v7m.exception to indicate that
150
- }
226
- * it is the exception currently being handled.
151
- if (cpu_isar_feature(aa64_sve, cpu)) {
227
- */
152
- env->cp15.cptr_el[3] |= R_CPTR_EL3_EZ_MASK;
228
-void armv7m_nvic_acknowledge_irq(NVICState *s);
153
- env->vfp.zcr_el[3] = 0xf;
229
-/**
154
- }
230
- * armv7m_nvic_complete_irq: complete specified interrupt or exception
155
- if (cpu_isar_feature(aa64_sme, cpu)) {
231
- * @s: the NVIC
156
- env->cp15.cptr_el[3] |= R_CPTR_EL3_ESM_MASK;
232
- * @irq: the exception number to complete
157
- env->cp15.scr_el3 |= SCR_ENTP2;
233
- * @secure: true if this exception was secure
158
- env->vfp.smcr_el[3] = 0xf;
234
- *
159
- }
235
- * Returns: -1 if the irq was not active
160
- if (cpu_isar_feature(aa64_hcx, cpu)) {
236
- * 1 if completing this irq brought us back to base (no active irqs)
161
- env->cp15.scr_el3 |= SCR_HXEN;
237
- * 0 if there is still an irq active after this one was completed
162
- }
238
- * (Ignoring -1, this is the same as the RETTOBASE value before completion.)
163
- if (cpu_isar_feature(aa64_fgt, cpu)) {
239
- */
164
- env->cp15.scr_el3 |= SCR_FGTEN;
240
-int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure);
165
- }
241
-/**
166
+ int target_el = arm_feature(env, ARM_FEATURE_EL2) ? 2 : 1;
242
- * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
167
243
- * @s: the NVIC
168
- /* AArch64 kernels never boot in secure mode */
244
- * @irq: the exception number to mark pending
169
- assert(!info->secure_boot);
245
- * @secure: false for non-banked exceptions or for the nonsecure
170
- /* This hook is only supported for AArch32 currently:
246
- * version of a banked exception, true for the secure version of a banked
171
- * bootloader_aarch64[] will not call the hook, and
247
- * exception.
172
- * the code above has already dropped us into EL2 or EL1.
248
- *
173
- */
249
- * Return whether an exception is "ready", i.e. whether the exception is
174
- assert(!info->secure_board_setup);
250
- * enabled and is configured at a priority which would allow it to
175
- }
251
- * interrupt the current execution priority. This controls whether the
176
-
252
- * RDY bit for it in the FPCCR is set.
177
- if (arm_feature(env, ARM_FEATURE_EL2)) {
253
- */
178
- /* If we have EL2 then Linux expects the HVC insn to work */
254
-bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure);
179
- env->cp15.scr_el3 |= SCR_HCE;
255
-/**
180
- }
256
- * armv7m_nvic_raw_execution_priority: return the raw execution priority
181
-
257
- * @s: the NVIC
182
- /* Set to non-secure if not a secure boot */
258
- *
183
- if (!info->secure_boot &&
259
- * Returns: the raw execution priority as defined by the v8M architecture.
184
- (cs != first_cpu || !info->secure_board_setup)) {
260
- * This is the execution priority minus the effects of AIRCR.PRIS,
185
- /* Linux expects non-secure state */
261
- * and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting.
186
- env->cp15.scr_el3 |= SCR_NS;
262
- * (v8M ARM ARM I_PKLD.)
187
- /* Set NSACR.{CP11,CP10} so NS can access the FPU */
263
- */
188
- env->cp15.nsacr |= 3 << 10;
264
-int armv7m_nvic_raw_execution_priority(NVICState *s);
189
- }
265
-/**
190
- }
266
- * armv7m_nvic_neg_prio_requested: return true if the requested execution
191
-
267
- * priority is negative for the specified security state.
192
- if (!env->aarch64 && !info->secure_boot &&
268
- * @s: the NVIC
193
- arm_feature(env, ARM_FEATURE_EL2)) {
269
- * @secure: the security state to test
194
+ if (env->aarch64) {
270
- * This corresponds to the pseudocode IsReqExecPriNeg().
195
/*
271
- */
196
- * This is an AArch32 boot not to Secure state, and
272
-#ifndef CONFIG_USER_ONLY
197
- * we have Hyp mode available, so boot the kernel into
273
-bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure);
198
- * Hyp mode. This is not how the CPU comes out of reset,
274
-#else
199
- * so we need to manually put it there.
275
-static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure)
200
+ * AArch64 kernels never boot in secure mode, and we don't
276
-{
201
+ * support the secure_board_setup hook for AArch64.
277
- return false;
202
*/
278
-}
203
- cpsr_write(env, ARM_CPU_MODE_HYP, CPSR_M, CPSRWriteRaw);
279
-#endif
204
+ assert(!info->secure_boot);
280
-
205
+ assert(!info->secure_board_setup);
281
/* Interface for defining coprocessor registers.
206
+ } else {
282
* Registers are defined in tables of arm_cp_reginfo structs
207
+ if (arm_feature(env, ARM_FEATURE_EL3) &&
283
* which are passed to define_arm_cp_regs().
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
284
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
285
index XXXXXXX..XXXXXXX 100644
287
index XXXXXXX..XXXXXXX 100644
286
--- a/target/arm/cpu.c
288
--- a/target/arm/cpu.c
287
+++ b/target/arm/cpu.c
289
+++ b/target/arm/cpu.c
288
@@ -XXX,XX +XXX,XX @@
290
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj)
289
#if !defined(CONFIG_USER_ONLY)
291
}
290
#include "hw/loader.h"
292
}
291
#include "hw/boards.h"
293
292
+#ifdef CONFIG_TCG
294
+void arm_emulate_firmware_reset(CPUState *cpustate, int target_el)
293
#include "hw/intc/armv7m_nvic.h"
295
+{
294
-#endif
296
+ ARMCPU *cpu = ARM_CPU(cpustate);
295
+#endif /* CONFIG_TCG */
297
+ CPUARMState *env = &cpu->env;
296
+#endif /* !CONFIG_USER_ONLY */
298
+ bool have_el3 = arm_feature(env, ARM_FEATURE_EL3);
297
#include "sysemu/tcg.h"
299
+ bool have_el2 = arm_feature(env, ARM_FEATURE_EL2);
298
#include "sysemu/qtest.h"
300
+
299
#include "sysemu/hw_accel.h"
301
+ /*
300
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
302
+ * Check we have the EL we're aiming for. If that is the
301
index XXXXXXX..XXXXXXX 100644
303
+ * highest implemented EL, then cpu_reset has already done
302
--- a/target/arm/cpu_tcg.c
304
+ * all the work.
303
+++ b/target/arm/cpu_tcg.c
305
+ */
304
@@ -XXX,XX +XXX,XX @@
306
+ switch (target_el) {
305
#include "hw/boards.h"
307
+ case 3:
306
#endif
308
+ assert(have_el3);
307
#include "cpregs.h"
309
+ return;
308
+#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
310
+ case 2:
309
+#include "hw/intc/armv7m_nvic.h"
311
+ assert(have_el2);
310
+#endif
312
+ if (!have_el3) {
311
313
+ return;
312
314
+ }
313
/* Share AArch32 -cpu max features with AArch64. */
315
+ break;
314
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
316
+ case 1:
315
index XXXXXXX..XXXXXXX 100644
317
+ if (!have_el3 && !have_el2) {
316
--- a/target/arm/m_helper.c
318
+ return;
317
+++ b/target/arm/m_helper.c
319
+ }
318
@@ -XXX,XX +XXX,XX @@
320
+ break;
319
#include "exec/cpu_ldst.h"
321
+ default:
320
#include "semihosting/common-semi.h"
322
+ g_assert_not_reached();
321
#endif
323
+ }
322
+#if !defined(CONFIG_USER_ONLY)
324
+
323
+#include "hw/intc/armv7m_nvic.h"
325
+ if (have_el3) {
324
+#endif
326
+ /*
325
327
+ * Set the EL3 state so code can run at EL2. This should match
326
static void v7m_msr_xpsr(CPUARMState *env, uint32_t mask,
328
+ * the requirements set by Linux in its booting spec.
327
uint32_t reg, uint32_t val)
329
+ */
330
+ if (env->aarch64) {
331
+ env->cp15.scr_el3 |= SCR_RW;
332
+ if (cpu_isar_feature(aa64_pauth, cpu)) {
333
+ env->cp15.scr_el3 |= SCR_API | SCR_APK;
334
+ }
335
+ if (cpu_isar_feature(aa64_mte, cpu)) {
336
+ env->cp15.scr_el3 |= SCR_ATA;
337
+ }
338
+ if (cpu_isar_feature(aa64_sve, cpu)) {
339
+ env->cp15.cptr_el[3] |= R_CPTR_EL3_EZ_MASK;
340
+ env->vfp.zcr_el[3] = 0xf;
341
+ }
342
+ if (cpu_isar_feature(aa64_sme, cpu)) {
343
+ env->cp15.cptr_el[3] |= R_CPTR_EL3_ESM_MASK;
344
+ env->cp15.scr_el3 |= SCR_ENTP2;
345
+ env->vfp.smcr_el[3] = 0xf;
346
+ }
347
+ if (cpu_isar_feature(aa64_hcx, cpu)) {
348
+ env->cp15.scr_el3 |= SCR_HXEN;
349
+ }
350
+ if (cpu_isar_feature(aa64_fgt, cpu)) {
351
+ env->cp15.scr_el3 |= SCR_FGTEN;
352
+ }
353
+ }
354
+
355
+ if (target_el == 2) {
356
+ /* If the guest is at EL2 then Linux expects the HVC insn to work */
357
+ env->cp15.scr_el3 |= SCR_HCE;
358
+ }
359
+
360
+ /* Put CPU into non-secure state */
361
+ env->cp15.scr_el3 |= SCR_NS;
362
+ /* Set NSACR.{CP11,CP10} so NS can access the FPU */
363
+ env->cp15.nsacr |= 3 << 10;
364
+ }
365
+
366
+ if (have_el2 && target_el < 2) {
367
+ /* Set EL2 state so code can run at EL1. */
368
+ if (env->aarch64) {
369
+ env->cp15.hcr_el2 |= HCR_RW;
370
+ }
371
+ }
372
+
373
+ /* Set the CPU to the desired state */
374
+ if (env->aarch64) {
375
+ env->pstate = aarch64_pstate_mode(target_el, true);
376
+ } else {
377
+ static const uint32_t mode_for_el[] = {
378
+ 0,
379
+ ARM_CPU_MODE_SVC,
380
+ ARM_CPU_MODE_HYP,
381
+ ARM_CPU_MODE_SVC,
382
+ };
383
+
384
+ cpsr_write(env, mode_for_el[target_el], CPSR_M, CPSRWriteRaw);
385
+ }
386
+}
387
+
388
+
389
#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY)
390
391
static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
328
--
392
--
329
2.34.1
393
2.34.1
330
331
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
The two TCG tests for GICv2 and GICv3 are very heavy weight distros
4
that take a long time to boot up, especially for an --enable-debug
5
build. The total code coverage they give is:
6
7
Overall coverage rate:
8
lines......: 11.2% (59584 of 530123 lines)
9
functions..: 15.0% (7436 of 49443 functions)
10
branches...: 6.3% (19273 of 303933 branches)
11
12
We already get pretty close to that with the machine_aarch64_virt
13
tests which only does one full boot (~120s vs ~600s) of alpine. We
14
expand the kernel+initrd boot (~8s) to test both GICs and also add an
15
RNG device and a block device to generate a few IRQs and exercise the
16
storage layer. With that we get to a coverage of:
17
18
Overall coverage rate:
19
lines......: 11.0% (58121 of 530123 lines)
20
functions..: 14.9% (7343 of 49443 functions)
21
branches...: 6.0% (18269 of 303933 branches)
22
23
which I feel is close enough given the massive time saving. If we want
24
to target any more sub-systems we can use lighter weight more directed
25
tests.
26
27
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
28
Reviewed-by: Fabiano Rosas <farosas@suse.de>
29
Acked-by: Richard Henderson <richard.henderson@linaro.org>
30
Message-id: 20230203181632.2919715-1-alex.bennee@linaro.org
31
Cc: Peter Maydell <peter.maydell@linaro.org>
32
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
33
---
34
tests/avocado/boot_linux.py | 48 ++++----------------
35
tests/avocado/machine_aarch64_virt.py | 63 ++++++++++++++++++++++++---
36
2 files changed, 65 insertions(+), 46 deletions(-)
37
38
diff --git a/tests/avocado/boot_linux.py b/tests/avocado/boot_linux.py
39
index XXXXXXX..XXXXXXX 100644
40
--- a/tests/avocado/boot_linux.py
41
+++ b/tests/avocado/boot_linux.py
42
@@ -XXX,XX +XXX,XX @@ def test_pc_q35_kvm(self):
43
self.launch_and_wait(set_up_ssh_connection=False)
44
45
46
-# For Aarch64 we only boot KVM tests in CI as the TCG tests are very
47
-# heavyweight. There are lighter weight distros which we use in the
48
-# machine_aarch64_virt.py tests.
49
+# For Aarch64 we only boot KVM tests in CI as booting the current
50
+# Fedora OS in TCG tests is very heavyweight. There are lighter weight
51
+# distros which we use in the machine_aarch64_virt.py tests.
52
class BootLinuxAarch64(LinuxTest):
53
"""
54
:avocado: tags=arch:aarch64
55
:avocado: tags=machine:virt
56
- :avocado: tags=machine:gic-version=2
57
"""
58
timeout = 720
59
60
- def add_common_args(self):
61
- self.vm.add_args('-bios',
62
- os.path.join(BUILD_DIR, 'pc-bios',
63
- 'edk2-aarch64-code.fd'))
64
- self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
65
- self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom')
66
-
67
- @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
68
- def test_fedora_cloud_tcg_gicv2(self):
69
- """
70
- :avocado: tags=accel:tcg
71
- :avocado: tags=cpu:max
72
- :avocado: tags=device:gicv2
73
- """
74
- self.require_accelerator("tcg")
75
- self.vm.add_args("-accel", "tcg")
76
- self.vm.add_args("-cpu", "max,lpa2=off")
77
- self.vm.add_args("-machine", "virt,gic-version=2")
78
- self.add_common_args()
79
- self.launch_and_wait(set_up_ssh_connection=False)
80
-
81
- @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
82
- def test_fedora_cloud_tcg_gicv3(self):
83
- """
84
- :avocado: tags=accel:tcg
85
- :avocado: tags=cpu:max
86
- :avocado: tags=device:gicv3
87
- """
88
- self.require_accelerator("tcg")
89
- self.vm.add_args("-accel", "tcg")
90
- self.vm.add_args("-cpu", "max,lpa2=off")
91
- self.vm.add_args("-machine", "virt,gic-version=3")
92
- self.add_common_args()
93
- self.launch_and_wait(set_up_ssh_connection=False)
94
-
95
def test_virt_kvm(self):
96
"""
97
:avocado: tags=accel:kvm
98
@@ -XXX,XX +XXX,XX @@ def test_virt_kvm(self):
99
self.require_accelerator("kvm")
100
self.vm.add_args("-accel", "kvm")
101
self.vm.add_args("-machine", "virt,gic-version=host")
102
- self.add_common_args()
103
+ self.vm.add_args('-bios',
104
+ os.path.join(BUILD_DIR, 'pc-bios',
105
+ 'edk2-aarch64-code.fd'))
106
+ self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
107
+ self.vm.add_args('-object', 'rng-random,id=rng0,filename=/dev/urandom')
108
self.launch_and_wait(set_up_ssh_connection=False)
109
110
111
diff --git a/tests/avocado/machine_aarch64_virt.py b/tests/avocado/machine_aarch64_virt.py
112
index XXXXXXX..XXXXXXX 100644
113
--- a/tests/avocado/machine_aarch64_virt.py
114
+++ b/tests/avocado/machine_aarch64_virt.py
115
@@ -XXX,XX +XXX,XX @@
116
117
import time
118
import os
119
+import logging
120
121
from avocado_qemu import QemuSystemTest
122
from avocado_qemu import wait_for_console_pattern
123
from avocado_qemu import exec_command
124
from avocado_qemu import BUILD_DIR
125
+from avocado.utils import process
126
+from avocado.utils.path import find_command
127
128
class Aarch64VirtMachine(QemuSystemTest):
129
KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 '
130
@@ -XXX,XX +XXX,XX @@ def test_alpine_virt_tcg_gic_max(self):
131
self.wait_for_console_pattern('Welcome to Alpine Linux 3.16')
132
133
134
- def test_aarch64_virt(self):
135
+ def common_aarch64_virt(self, machine):
136
"""
137
- :avocado: tags=arch:aarch64
138
- :avocado: tags=machine:virt
139
- :avocado: tags=accel:tcg
140
- :avocado: tags=cpu:max
141
+ Common code to launch basic virt machine with kernel+initrd
142
+ and a scratch disk.
143
"""
144
+ logger = logging.getLogger('aarch64_virt')
145
+
146
kernel_url = ('https://fileserver.linaro.org/s/'
147
'z6B2ARM7DQT3HWN/download')
148
-
149
kernel_hash = 'ed11daab50c151dde0e1e9c9cb8b2d9bd3215347'
150
kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
151
152
@@ -XXX,XX +XXX,XX @@ def test_aarch64_virt(self):
153
'console=ttyAMA0')
154
self.require_accelerator("tcg")
155
self.vm.add_args('-cpu', 'max,pauth-impdef=on',
156
+ '-machine', machine,
157
'-accel', 'tcg',
158
'-kernel', kernel_path,
159
'-append', kernel_command_line)
160
+
161
+ # A RNG offers an easy way to generate a few IRQs
162
+ self.vm.add_args('-device', 'virtio-rng-pci,rng=rng0')
163
+ self.vm.add_args('-object',
164
+ 'rng-random,id=rng0,filename=/dev/urandom')
165
+
166
+ # Also add a scratch block device
167
+ logger.info('creating scratch qcow2 image')
168
+ image_path = os.path.join(self.workdir, 'scratch.qcow2')
169
+ qemu_img = os.path.join(BUILD_DIR, 'qemu-img')
170
+ if not os.path.exists(qemu_img):
171
+ qemu_img = find_command('qemu-img', False)
172
+ if qemu_img is False:
173
+ self.cancel('Could not find "qemu-img", which is required to '
174
+ 'create the temporary qcow2 image')
175
+ cmd = '%s create -f qcow2 %s 8M' % (qemu_img, image_path)
176
+ process.run(cmd)
177
+
178
+ # Add the device
179
+ self.vm.add_args('-blockdev',
180
+ f"driver=qcow2,file.driver=file,file.filename={image_path},node-name=scratch")
181
+ self.vm.add_args('-device',
182
+ 'virtio-blk-device,drive=scratch')
183
+
184
self.vm.launch()
185
self.wait_for_console_pattern('Welcome to Buildroot')
186
time.sleep(0.1)
187
exec_command(self, 'root')
188
time.sleep(0.1)
189
+ exec_command(self, 'dd if=/dev/hwrng of=/dev/vda bs=512 count=4')
190
+ time.sleep(0.1)
191
+ exec_command(self, 'md5sum /dev/vda')
192
+ time.sleep(0.1)
193
+ exec_command(self, 'cat /proc/interrupts')
194
+ time.sleep(0.1)
195
exec_command(self, 'cat /proc/self/maps')
196
time.sleep(0.1)
197
+
198
+ def test_aarch64_virt_gicv3(self):
199
+ """
200
+ :avocado: tags=arch:aarch64
201
+ :avocado: tags=machine:virt
202
+ :avocado: tags=accel:tcg
203
+ :avocado: tags=cpu:max
204
+ """
205
+ self.common_aarch64_virt("virt,gic_version=3")
206
+
207
+ def test_aarch64_virt_gicv2(self):
208
+ """
209
+ :avocado: tags=arch:aarch64
210
+ :avocado: tags=machine:virt
211
+ :avocado: tags=accel:tcg
212
+ :avocado: tags=cpu:max
213
+ """
214
+ self.common_aarch64_virt("virt,gic-version=2")
215
--
216
2.34.1
217
218
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
1
3
Since commit acc0b8b05a when running the ZynqMP ZCU102 board with
4
a QEMU configured using --without-default-devices, we get:
5
6
$ qemu-system-aarch64 -M xlnx-zcu102
7
qemu-system-aarch64: missing object type 'usb_dwc3'
8
Abort trap: 6
9
10
Fix by adding the missing Kconfig dependency.
11
12
Fixes: acc0b8b05a ("hw/arm/xlnx-zynqmp: Connect ZynqMP's USB controllers")
13
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
Message-id: 20230216092327.2203-1-philmd@linaro.org
15
Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
18
hw/arm/Kconfig | 1 +
19
1 file changed, 1 insertion(+)
20
21
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
22
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/arm/Kconfig
24
+++ b/hw/arm/Kconfig
25
@@ -XXX,XX +XXX,XX @@ config XLNX_ZYNQMP_ARM
26
select XLNX_CSU_DMA
27
select XLNX_ZYNQMP
28
select XLNX_ZDMA
29
+ select USB_DWC3
30
31
config XLNX_VERSAL
32
bool
33
--
34
2.34.1
35
36
diff view generated by jsdifflib
1
From: Fabiano Rosas <farosas@suse.de>
1
From: Chris Rauer <crauer@google.com>
2
2
3
Signed-off-by: Fabiano Rosas <farosas@suse.de>
3
The counter register is only 24-bits and counts down. If the timer is
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
running but the qtimer to reset it hasn't fired off yet, there is a chance
5
Acked-by: Thomas Huth <thuth@redhat.com>
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>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
tests/qtest/arm-cpu-features.c | 28 ++++++++++++++++++----------
12
hw/timer/npcm7xx_timer.c | 3 +++
9
1 file changed, 18 insertions(+), 10 deletions(-)
13
1 file changed, 3 insertions(+)
10
14
11
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
15
diff --git a/hw/timer/npcm7xx_timer.c b/hw/timer/npcm7xx_timer.c
12
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
13
--- a/tests/qtest/arm-cpu-features.c
17
--- a/hw/timer/npcm7xx_timer.c
14
+++ b/tests/qtest/arm-cpu-features.c
18
+++ b/hw/timer/npcm7xx_timer.c
15
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static int64_t npcm7xx_timer_count_to_ns(NPCM7xxTimer *t, uint32_t count)
16
#define SVE_MAX_VQ 16
20
/* Convert a time interval in nanoseconds to a timer cycle count. */
17
21
static uint32_t npcm7xx_timer_ns_to_count(NPCM7xxTimer *t, int64_t ns)
18
#define MACHINE "-machine virt,gic-version=max -accel tcg "
19
-#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm -accel tcg "
20
+#define MACHINE_KVM "-machine virt,gic-version=max -accel kvm "
21
#define QUERY_HEAD "{ 'execute': 'query-cpu-model-expansion', " \
22
" 'arguments': { 'type': 'full', "
23
#define QUERY_TAIL "}}"
24
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
25
{
22
{
26
g_test_init(&argc, &argv, NULL);
23
+ if (ns < 0) {
27
24
+ return 0;
28
- qtest_add_data_func("/arm/query-cpu-model-expansion",
29
- NULL, test_query_cpu_model_expansion);
30
+ if (qtest_has_accel("tcg")) {
31
+ qtest_add_data_func("/arm/query-cpu-model-expansion",
32
+ NULL, test_query_cpu_model_expansion);
33
+ }
25
+ }
34
+
26
return clock_ns_to_ticks(t->ctrl->clock, ns) /
35
+ if (!g_str_equal(qtest_get_arch(), "aarch64")) {
27
npcm7xx_tcsr_prescaler(t->tcsr);
36
+ goto out;
37
+ }
38
39
/*
40
* For now we only run KVM specific tests with AArch64 QEMU in
41
* order avoid attempting to run an AArch32 QEMU with KVM on
42
* AArch64 hosts. That won't work and isn't easy to detect.
43
*/
44
- if (g_str_equal(qtest_get_arch(), "aarch64") && qtest_has_accel("kvm")) {
45
+ if (qtest_has_accel("kvm")) {
46
/*
47
* This tests target the 'host' CPU type, so register it only if
48
* KVM is available.
49
*/
50
qtest_add_data_func("/arm/kvm/query-cpu-model-expansion",
51
NULL, test_query_cpu_model_expansion_kvm);
52
- }
53
54
- if (g_str_equal(qtest_get_arch(), "aarch64")) {
55
- qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8",
56
- NULL, sve_tests_sve_max_vq_8);
57
- qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off",
58
- NULL, sve_tests_sve_off);
59
qtest_add_data_func("/arm/kvm/query-cpu-model-expansion/sve-off",
60
NULL, sve_tests_sve_off_kvm);
61
}
62
63
+ if (qtest_has_accel("tcg")) {
64
+ qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-max-vq-8",
65
+ NULL, sve_tests_sve_max_vq_8);
66
+ qtest_add_data_func("/arm/max/query-cpu-model-expansion/sve-off",
67
+ NULL, sve_tests_sve_off);
68
+ }
69
+
70
+out:
71
return g_test_run();
72
}
28
}
73
--
29
--
74
2.34.1
30
2.34.1
diff view generated by jsdifflib
1
From: Cornelia Huck <cohuck@redhat.com>
1
From: Suraj Shirvankar <surajshirvankar@gmail.com>
2
2
3
Just use current_accel_name() directly.
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).
4
7
5
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
8
Signed-off-by: Suraj Shirvankar <surajshirvankar@gmail.com>
6
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Message-id: 169753938460.23804.11418813007617535750-1@git.sr.ht
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
[PMM: also remove NULL checks from g_malloc() calls;
11
beef up commit message]
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
14
---
10
hw/arm/virt.c | 6 +++---
15
contrib/elf2dmp/addrspace.c | 7 ++-----
11
1 file changed, 3 insertions(+), 3 deletions(-)
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(-)
12
20
13
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
21
diff --git a/contrib/elf2dmp/addrspace.c b/contrib/elf2dmp/addrspace.c
14
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/virt.c
23
--- a/contrib/elf2dmp/addrspace.c
16
+++ b/hw/arm/virt.c
24
+++ b/contrib/elf2dmp/addrspace.c
17
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
25
@@ -XXX,XX +XXX,XX @@ int pa_space_create(struct pa_space *ps, QEMU_Elf *qemu_elf)
18
if (vms->secure && (kvm_enabled() || hvf_enabled())) {
26
}
19
error_report("mach-virt: %s does not support providing "
20
"Security extensions (TrustZone) to the guest CPU",
21
- kvm_enabled() ? "KVM" : "HVF");
22
+ current_accel_name());
23
exit(1);
24
}
27
}
25
28
26
if (vms->virt && (kvm_enabled() || hvf_enabled())) {
29
- ps->block = malloc(sizeof(*ps->block) * ps->block_nr);
27
error_report("mach-virt: %s does not support providing "
30
- if (!ps->block) {
28
"Virtualization extensions to the guest CPU",
31
- return 1;
29
- kvm_enabled() ? "KVM" : "HVF");
32
- }
30
+ current_accel_name());
33
+ ps->block = g_new(struct pa_block, ps->block_nr);
31
exit(1);
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
}
32
}
52
}
33
53
34
if (vms->mte && (kvm_enabled() || hvf_enabled())) {
54
- kdbg = malloc(kdbg_hdr.Size);
35
error_report("mach-virt: %s does not support providing "
55
- if (!kdbg) {
36
"MTE to the guest CPU",
56
- return NULL;
37
- kvm_enabled() ? "KVM" : "HVF");
57
- }
38
+ current_accel_name());
58
+ kdbg = g_malloc(kdbg_hdr.Size);
39
exit(1);
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;
40
}
65
}
41
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)
42
--
167
--
43
2.34.1
168
2.34.1
diff view generated by jsdifflib