1
The following changes since commit adf2e451f357e993f173ba9b4176dbf3e65fee7e:
1
The following changes since commit 003ba52a8b327180e284630b289c6ece5a3e08b9:
2
2
3
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2019-02-26 19:04:47 +0000)
3
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-02-16 11:16:39 +0000)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190228-1
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230216
8
8
9
for you to fetch changes up to 1c9af3a9e05c1607a36df4943f8f5393d7621a91:
9
for you to fetch changes up to caf01d6a435d9f4a95aeae2f9fc6cb8b889b1fb8:
10
10
11
linux-user: Enable HWCAP_ASIMDFHM, HWCAP_JSCVT (2019-02-28 11:03:05 +0000)
11
tests/qtest: Restrict tpm-tis-devices-{swtpm}-test to CONFIG_TCG (2023-02-16 16:28:53 +0000)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
target-arm queue:
14
target-arm queue:
15
* add MHU and dual-core support to Musca boards
15
* Some mostly M-profile-related code cleanups
16
* refactor some VFP insns to be gated by ID registers
16
* avocado: Retire the boot_linux.py AArch64 TCG tests
17
* Revert "arm: Allow system registers for KVM guests to be changed by QEMU code"
17
* hw/arm/smmuv3: Add GBPA register
18
* Implement ARMv8.2-FHM extension
18
* arm/virt: don't try to spell out the accelerator
19
* Advertise JSCVT via HWCAP for linux-user
19
* hw/arm: Attach PSPI module to NPCM7XX SoC
20
* Some cleanup/refactoring patches aiming towards
21
allowing building Arm targets without CONFIG_TCG
20
22
21
----------------------------------------------------------------
23
----------------------------------------------------------------
22
Peter Maydell (11):
24
Alex Bennée (1):
23
hw/misc/armsse-mhu.c: Model the SSE-200 Message Handling Unit
25
tests/avocado: retire the Aarch64 TCG tests from boot_linux.py
24
hw/arm/armsse: Wire up the MHUs
25
target/arm/cpu: Allow init-svtor property to be set after realize
26
target/arm/arm-powerctl: Add new arm_set_cpu_on_and_reset()
27
hw/misc/iotkit-sysctl: Correct typo in INITSVTOR0 register name
28
hw/arm/iotkit-sysctl: Add SSE-200 registers
29
hw/arm/iotkit-sysctl: Implement CPUWAIT and INITSVTOR*
30
hw/arm/armsse: Unify init-svtor and cpuwait handling
31
target/arm: Use MVFR1 feature bits to gate A32/T32 FP16 instructions
32
target/arm: Gate "miscellaneous FP" insns by ID register field
33
Revert "arm: Allow system registers for KVM guests to be changed by QEMU code"
34
26
35
Richard Henderson (5):
27
Claudio Fontana (3):
36
target/arm: Add helpers for FMLAL
28
target/arm: rename handle_semihosting to tcg_handle_semihosting
37
target/arm: Implement FMLAL and FMLSL for aarch64
29
target/arm: wrap psci call with tcg_enabled
38
target/arm: Implement VFMAL and VFMSL for aarch32
30
target/arm: wrap call to aarch64_sve_change_el in tcg_enabled()
39
target/arm: Enable ARMv8.2-FHM for -cpu max
40
linux-user: Enable HWCAP_ASIMDFHM, HWCAP_JSCVT
41
31
42
hw/misc/Makefile.objs | 1 +
32
Cornelia Huck (1):
43
include/hw/arm/armsse.h | 3 +-
33
arm/virt: don't try to spell out the accelerator
44
include/hw/misc/armsse-mhu.h | 44 ++++++
45
include/hw/misc/iotkit-sysctl.h | 25 +++-
46
target/arm/arm-powerctl.h | 16 +++
47
target/arm/cpu.h | 76 +++++++++--
48
target/arm/helper.h | 9 ++
49
hw/arm/armsse.c | 91 +++++++++----
50
hw/misc/armsse-mhu.c | 198 +++++++++++++++++++++++++++
51
hw/misc/iotkit-sysctl.c | 294 ++++++++++++++++++++++++++++++++++++++--
52
linux-user/elfload.c | 2 +
53
target/arm/arm-powerctl.c | 56 ++++++++
54
target/arm/cpu.c | 32 ++++-
55
target/arm/cpu64.c | 2 +
56
target/arm/helper.c | 27 +---
57
target/arm/kvm32.c | 23 +++-
58
target/arm/kvm64.c | 2 -
59
target/arm/machine.c | 2 +-
60
target/arm/translate-a64.c | 49 ++++++-
61
target/arm/translate.c | 180 ++++++++++++++++--------
62
target/arm/vec_helper.c | 148 ++++++++++++++++++++
63
MAINTAINERS | 2 +
64
default-configs/arm-softmmu.mak | 1 +
65
hw/misc/trace-events | 4 +
66
24 files changed, 1139 insertions(+), 148 deletions(-)
67
create mode 100644 include/hw/misc/armsse-mhu.h
68
create mode 100644 hw/misc/armsse-mhu.c
69
34
35
Fabiano Rosas (7):
36
target/arm: Move PC alignment check
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
44
Hao Wu (3):
45
MAINTAINERS: Add myself to maintainers and remove Havard
46
hw/ssi: Add Nuvoton PSPI Module
47
hw/arm: Attach PSPI module to NPCM7XX SoC
48
49
Jean-Philippe Brucker (2):
50
hw/arm/smmu-common: Support 64-bit addresses
51
hw/arm/smmu-common: Fix TTB1 handling
52
53
Mostafa Saleh (1):
54
hw/arm/smmuv3: Add GBPA register
55
56
Philippe Mathieu-Daudé (12):
57
hw/intc/armv7m_nvic: Use OBJECT_DECLARE_SIMPLE_TYPE() macro
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
70
MAINTAINERS | 8 +-
71
docs/system/arm/nuvoton.rst | 2 +-
72
hw/arm/smmuv3-internal.h | 7 +
73
include/hw/arm/npcm7xx.h | 2 +
74
include/hw/arm/smmu-common.h | 2 -
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
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
2
3
Manually convert to OBJECT_DECLARE_SIMPLE_TYPE() macro,
4
similarly to automatic conversion from commit 8063396bf3
5
("Use OBJECT_DECLARE_SIMPLE_TYPE when possible").
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230206223502.25122-2-philmd@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
include/hw/intc/armv7m_nvic.h | 5 +----
13
1 file changed, 1 insertion(+), 4 deletions(-)
14
15
diff --git a/include/hw/intc/armv7m_nvic.h b/include/hw/intc/armv7m_nvic.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/intc/armv7m_nvic.h
18
+++ b/include/hw/intc/armv7m_nvic.h
19
@@ -XXX,XX +XXX,XX @@
20
#include "qom/object.h"
21
22
#define TYPE_NVIC "armv7m_nvic"
23
-
24
-typedef struct NVICState NVICState;
25
-DECLARE_INSTANCE_CHECKER(NVICState, NVIC,
26
- TYPE_NVIC)
27
+OBJECT_DECLARE_SIMPLE_TYPE(NVICState, NVIC)
28
29
/* Highest permitted number of exceptions (architectural limit) */
30
#define NVIC_MAX_VECTORS 512
31
--
32
2.34.1
33
34
diff view generated by jsdifflib
1
Currently the Arm arm-powerctl.h APIs allow:
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
* arm_set_cpu_on(), which powers on a CPU and sets its
3
initial PC and other startup state
4
* arm_reset_cpu(), which resets a CPU which is already on
5
(and fails if the CPU is powered off)
6
2
7
but there is no way to say "power on a CPU as if it had
3
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
8
just come out of reset and don't do anything else to it".
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20230206223502.25122-3-philmd@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
target/arm/m_helper.c | 11 ++++++++---
10
1 file changed, 8 insertions(+), 3 deletions(-)
9
11
10
Add a new function arm_set_cpu_on_and_reset(), which does this.
12
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
11
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20190219125808.25174-5-peter.maydell@linaro.org
15
---
16
target/arm/arm-powerctl.h | 16 +++++++++++
17
target/arm/arm-powerctl.c | 56 +++++++++++++++++++++++++++++++++++++++
18
2 files changed, 72 insertions(+)
19
20
diff --git a/target/arm/arm-powerctl.h b/target/arm/arm-powerctl.h
21
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/arm-powerctl.h
14
--- a/target/arm/m_helper.c
23
+++ b/target/arm/arm-powerctl.h
15
+++ b/target/arm/m_helper.c
24
@@ -XXX,XX +XXX,XX @@ int arm_set_cpu_off(uint64_t cpuid);
16
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
25
*/
17
return 0;
26
int arm_reset_cpu(uint64_t cpuid);
27
28
+/*
29
+ * arm_set_cpu_on_and_reset:
30
+ * @cpuid: the id of the CPU we want to star
31
+ *
32
+ * Start the cpu designated by @cpuid and put it through its normal
33
+ * CPU reset process. The CPU will start in the way it is architected
34
+ * to start after a power-on reset.
35
+ *
36
+ * Returns: QEMU_ARM_POWERCTL_RET_SUCCESS on success.
37
+ * QEMU_ARM_POWERCTL_INVALID_PARAM if there is no CPU with that ID.
38
+ * QEMU_ARM_POWERCTL_ALREADY_ON if the CPU is already on.
39
+ * QEMU_ARM_POWERCTL_ON_PENDING if the CPU is already partway through
40
+ * powering on.
41
+ */
42
+int arm_set_cpu_on_and_reset(uint64_t cpuid);
43
+
44
#endif
45
diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/target/arm/arm-powerctl.c
48
+++ b/target/arm/arm-powerctl.c
49
@@ -XXX,XX +XXX,XX @@ int arm_set_cpu_on(uint64_t cpuid, uint64_t entry, uint64_t context_id,
50
return QEMU_ARM_POWERCTL_RET_SUCCESS;
51
}
18
}
52
19
53
+static void arm_set_cpu_on_and_reset_async_work(CPUState *target_cpu_state,
20
-#else
54
+ run_on_cpu_data data)
21
+ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
55
+{
22
+{
56
+ ARMCPU *target_cpu = ARM_CPU(target_cpu_state);
23
+ return ARMMMUIdx_MUser;
57
+
58
+ /* Initialize the cpu we are turning on */
59
+ cpu_reset(target_cpu_state);
60
+ target_cpu_state->halted = 0;
61
+
62
+ /* Finally set the power status */
63
+ assert(qemu_mutex_iothread_locked());
64
+ target_cpu->power_state = PSCI_ON;
65
+}
24
+}
66
+
25
+
67
+int arm_set_cpu_on_and_reset(uint64_t cpuid)
26
+#else /* !CONFIG_USER_ONLY */
68
+{
27
69
+ CPUState *target_cpu_state;
28
/*
70
+ ARMCPU *target_cpu;
29
* What kind of stack write are we doing? This affects how exceptions
30
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
31
return tt_resp;
32
}
33
34
-#endif /* !CONFIG_USER_ONLY */
35
-
36
ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
37
bool secstate, bool priv, bool negpri)
38
{
39
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
40
41
return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv);
42
}
71
+
43
+
72
+ assert(qemu_mutex_iothread_locked());
44
+#endif /* !CONFIG_USER_ONLY */
73
+
74
+ /* Retrieve the cpu we are powering up */
75
+ target_cpu_state = arm_get_cpu_by_id(cpuid);
76
+ if (!target_cpu_state) {
77
+ /* The cpu was not found */
78
+ return QEMU_ARM_POWERCTL_INVALID_PARAM;
79
+ }
80
+
81
+ target_cpu = ARM_CPU(target_cpu_state);
82
+ if (target_cpu->power_state == PSCI_ON) {
83
+ qemu_log_mask(LOG_GUEST_ERROR,
84
+ "[ARM]%s: CPU %" PRId64 " is already on\n",
85
+ __func__, cpuid);
86
+ return QEMU_ARM_POWERCTL_ALREADY_ON;
87
+ }
88
+
89
+ /*
90
+ * If another CPU has powered the target on we are in the state
91
+ * ON_PENDING and additional attempts to power on the CPU should
92
+ * fail (see 6.6 Implementation CPU_ON/CPU_OFF races in the PSCI
93
+ * spec)
94
+ */
95
+ if (target_cpu->power_state == PSCI_ON_PENDING) {
96
+ qemu_log_mask(LOG_GUEST_ERROR,
97
+ "[ARM]%s: CPU %" PRId64 " is already powering on\n",
98
+ __func__, cpuid);
99
+ return QEMU_ARM_POWERCTL_ON_PENDING;
100
+ }
101
+
102
+ async_run_on_cpu(target_cpu_state, arm_set_cpu_on_and_reset_async_work,
103
+ RUN_ON_CPU_NULL);
104
+
105
+ /* We are good to go */
106
+ return QEMU_ARM_POWERCTL_RET_SUCCESS;
107
+}
108
+
109
static void arm_set_cpu_off_async_work(CPUState *target_cpu_state,
110
run_on_cpu_data data)
111
{
112
--
45
--
113
2.20.1
46
2.34.1
114
47
115
48
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Note that float16_to_float32 rightly squashes SNaN to QNaN.
3
arm_v7m_mmu_idx_all() and arm_v7m_mmu_idx_for_secstate_and_priv()
4
But of course pickNaNMulAdd, for ARM, selects SNaNs first.
4
are only used for system emulation in m_helper.c.
5
So we have to preserve SNaN long enough for the correct NaN
5
Move the definitions to avoid prototype forward declarations.
6
to be selected. Thus float16_to_float32_by_bits.
7
6
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Message-id: 20190219222952.22183-2-richard.henderson@linaro.org
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20230206223502.25122-4-philmd@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
target/arm/helper.h | 9 +++
12
target/arm/internals.h | 14 --------
14
target/arm/vec_helper.c | 148 ++++++++++++++++++++++++++++++++++++++++
13
target/arm/m_helper.c | 74 +++++++++++++++++++++---------------------
15
2 files changed, 157 insertions(+)
14
2 files changed, 37 insertions(+), 51 deletions(-)
16
15
17
diff --git a/target/arm/helper.h b/target/arm/helper.h
16
diff --git a/target/arm/internals.h b/target/arm/internals.h
18
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.h
18
--- a/target/arm/internals.h
20
+++ b/target/arm/helper.h
19
+++ b/target/arm/internals.h
21
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_sqsub_s, TCG_CALL_NO_RWG,
20
@@ -XXX,XX +XXX,XX @@ static inline ARMMMUIdx core_to_aa64_mmu_idx(int mmu_idx)
22
DEF_HELPER_FLAGS_5(gvec_sqsub_d, TCG_CALL_NO_RWG,
21
23
void, ptr, ptr, ptr, ptr, i32)
22
int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx);
24
23
25
+DEF_HELPER_FLAGS_5(gvec_fmlal_a32, TCG_CALL_NO_RWG,
24
-/*
26
+ void, ptr, ptr, ptr, ptr, i32)
25
- * Return the MMU index for a v7M CPU with all relevant information
27
+DEF_HELPER_FLAGS_5(gvec_fmlal_a64, TCG_CALL_NO_RWG,
26
- * manually specified.
28
+ void, ptr, ptr, ptr, ptr, i32)
27
- */
29
+DEF_HELPER_FLAGS_5(gvec_fmlal_idx_a32, TCG_CALL_NO_RWG,
28
-ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
30
+ void, ptr, ptr, ptr, ptr, i32)
29
- bool secstate, bool priv, bool negpri);
31
+DEF_HELPER_FLAGS_5(gvec_fmlal_idx_a64, TCG_CALL_NO_RWG,
30
-
32
+ void, ptr, ptr, ptr, ptr, i32)
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;
33
+
53
+
34
#ifdef TARGET_AARCH64
54
+ if (priv) {
35
#include "helper-a64.h"
55
+ mmu_idx |= ARM_MMU_IDX_M_PRIV;
36
#include "helper-sve.h"
56
+ }
37
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/target/arm/vec_helper.c
40
+++ b/target/arm/vec_helper.c
41
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_sqsub_d)(void *vd, void *vq, void *vn,
42
}
43
clear_tail(d, oprsz, simd_maxsz(desc));
44
}
45
+
57
+
46
+/*
58
+ if (negpri) {
47
+ * Convert float16 to float32, raising no exceptions and
59
+ mmu_idx |= ARM_MMU_IDX_M_NEGPRI;
48
+ * preserving exceptional values, including SNaN.
60
+ }
49
+ * This is effectively an unpack+repack operation.
50
+ */
51
+static float32 float16_to_float32_by_bits(uint32_t f16, bool fz16)
52
+{
53
+ const int f16_bias = 15;
54
+ const int f32_bias = 127;
55
+ uint32_t sign = extract32(f16, 15, 1);
56
+ uint32_t exp = extract32(f16, 10, 5);
57
+ uint32_t frac = extract32(f16, 0, 10);
58
+
61
+
59
+ if (exp == 0x1f) {
62
+ if (secstate) {
60
+ /* Inf or NaN */
63
+ mmu_idx |= ARM_MMU_IDX_M_S;
61
+ exp = 0xff;
62
+ } else if (exp == 0) {
63
+ /* Zero or denormal. */
64
+ if (frac != 0) {
65
+ if (fz16) {
66
+ frac = 0;
67
+ } else {
68
+ /*
69
+ * Denormal; these are all normal float32.
70
+ * Shift the fraction so that the msb is at bit 11,
71
+ * then remove bit 11 as the implicit bit of the
72
+ * normalized float32. Note that we still go through
73
+ * the shift for normal numbers below, to put the
74
+ * float32 fraction at the right place.
75
+ */
76
+ int shift = clz32(frac) - 21;
77
+ frac = (frac << shift) & 0x3ff;
78
+ exp = f32_bias - f16_bias - shift + 1;
79
+ }
80
+ }
81
+ } else {
82
+ /* Normal number; adjust the bias. */
83
+ exp += f32_bias - f16_bias;
84
+ }
64
+ }
85
+ sign <<= 31;
86
+ exp <<= 23;
87
+ frac <<= 23 - 10;
88
+
65
+
89
+ return sign | exp | frac;
66
+ return mmu_idx;
90
+}
67
+}
91
+
68
+
92
+static uint64_t load4_f16(uint64_t *ptr, int is_q, int is_2)
69
+static ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
70
+ bool secstate, bool priv)
93
+{
71
+{
94
+ /*
72
+ bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate);
95
+ * Branchless load of u32[0], u64[0], u32[1], or u64[1].
73
+
96
+ * Load the 2nd qword iff is_q & is_2.
74
+ return arm_v7m_mmu_idx_all(env, secstate, priv, negpri);
97
+ * Shift to the 2nd dword iff !is_q & is_2.
98
+ * For !is_q & !is_2, the upper bits of the result are garbage.
99
+ */
100
+ return ptr[is_q & is_2] >> ((is_2 & ~is_q) << 5);
101
+}
75
+}
102
+
76
+
103
+/*
77
+/* Return the MMU index for a v7M CPU in the specified security state */
104
+ * Note that FMLAL requires oprsz == 8 or oprsz == 16,
78
+ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
105
+ * as there is not yet SVE versions that might use blocking.
79
+{
106
+ */
80
+ bool priv = arm_v7m_is_handler_mode(env) ||
81
+ !(env->v7m.control[secstate] & 1);
107
+
82
+
108
+static void do_fmlal(float32 *d, void *vn, void *vm, float_status *fpst,
83
+ return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv);
109
+ uint32_t desc, bool fz16)
110
+{
111
+ intptr_t i, oprsz = simd_oprsz(desc);
112
+ int is_s = extract32(desc, SIMD_DATA_SHIFT, 1);
113
+ int is_2 = extract32(desc, SIMD_DATA_SHIFT + 1, 1);
114
+ int is_q = oprsz == 16;
115
+ uint64_t n_4, m_4;
116
+
117
+ /* Pre-load all of the f16 data, avoiding overlap issues. */
118
+ n_4 = load4_f16(vn, is_q, is_2);
119
+ m_4 = load4_f16(vm, is_q, is_2);
120
+
121
+ /* Negate all inputs for FMLSL at once. */
122
+ if (is_s) {
123
+ n_4 ^= 0x8000800080008000ull;
124
+ }
125
+
126
+ for (i = 0; i < oprsz / 4; i++) {
127
+ float32 n_1 = float16_to_float32_by_bits(n_4 >> (i * 16), fz16);
128
+ float32 m_1 = float16_to_float32_by_bits(m_4 >> (i * 16), fz16);
129
+ d[H4(i)] = float32_muladd(n_1, m_1, d[H4(i)], 0, fpst);
130
+ }
131
+ clear_tail(d, oprsz, simd_maxsz(desc));
132
+}
84
+}
133
+
85
+
134
+void HELPER(gvec_fmlal_a32)(void *vd, void *vn, void *vm,
86
/*
135
+ void *venv, uint32_t desc)
87
* What kind of stack write are we doing? This affects how exceptions
136
+{
88
* generated during the stacking are treated.
137
+ CPUARMState *env = venv;
89
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
138
+ do_fmlal(vd, vn, vm, &env->vfp.standard_fp_status, desc,
90
return tt_resp;
139
+ get_flush_inputs_to_zero(&env->vfp.fp_status_f16));
91
}
140
+}
92
141
+
93
-ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
142
+void HELPER(gvec_fmlal_a64)(void *vd, void *vn, void *vm,
94
- bool secstate, bool priv, bool negpri)
143
+ void *venv, uint32_t desc)
95
-{
144
+{
96
- ARMMMUIdx mmu_idx = ARM_MMU_IDX_M;
145
+ CPUARMState *env = venv;
97
-
146
+ do_fmlal(vd, vn, vm, &env->vfp.fp_status, desc,
98
- if (priv) {
147
+ get_flush_inputs_to_zero(&env->vfp.fp_status_f16));
99
- mmu_idx |= ARM_MMU_IDX_M_PRIV;
148
+}
100
- }
149
+
101
-
150
+static void do_fmlal_idx(float32 *d, void *vn, void *vm, float_status *fpst,
102
- if (negpri) {
151
+ uint32_t desc, bool fz16)
103
- mmu_idx |= ARM_MMU_IDX_M_NEGPRI;
152
+{
104
- }
153
+ intptr_t i, oprsz = simd_oprsz(desc);
105
-
154
+ int is_s = extract32(desc, SIMD_DATA_SHIFT, 1);
106
- if (secstate) {
155
+ int is_2 = extract32(desc, SIMD_DATA_SHIFT + 1, 1);
107
- mmu_idx |= ARM_MMU_IDX_M_S;
156
+ int index = extract32(desc, SIMD_DATA_SHIFT + 2, 3);
108
- }
157
+ int is_q = oprsz == 16;
109
-
158
+ uint64_t n_4;
110
- return mmu_idx;
159
+ float32 m_1;
111
-}
160
+
112
-
161
+ /* Pre-load all of the f16 data, avoiding overlap issues. */
113
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
162
+ n_4 = load4_f16(vn, is_q, is_2);
114
- bool secstate, bool priv)
163
+
115
-{
164
+ /* Negate all inputs for FMLSL at once. */
116
- bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate);
165
+ if (is_s) {
117
-
166
+ n_4 ^= 0x8000800080008000ull;
118
- return arm_v7m_mmu_idx_all(env, secstate, priv, negpri);
167
+ }
119
-}
168
+
120
-
169
+ m_1 = float16_to_float32_by_bits(((float16 *)vm)[H2(index)], fz16);
121
-/* Return the MMU index for a v7M CPU in the specified security state */
170
+
122
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
171
+ for (i = 0; i < oprsz / 4; i++) {
123
-{
172
+ float32 n_1 = float16_to_float32_by_bits(n_4 >> (i * 16), fz16);
124
- bool priv = arm_v7m_is_handler_mode(env) ||
173
+ d[H4(i)] = float32_muladd(n_1, m_1, d[H4(i)], 0, fpst);
125
- !(env->v7m.control[secstate] & 1);
174
+ }
126
-
175
+ clear_tail(d, oprsz, simd_maxsz(desc));
127
- return arm_v7m_mmu_idx_for_secstate_and_priv(env, secstate, priv);
176
+}
128
-}
177
+
129
-
178
+void HELPER(gvec_fmlal_idx_a32)(void *vd, void *vn, void *vm,
130
#endif /* !CONFIG_USER_ONLY */
179
+ void *venv, uint32_t desc)
180
+{
181
+ CPUARMState *env = venv;
182
+ do_fmlal_idx(vd, vn, vm, &env->vfp.standard_fp_status, desc,
183
+ get_flush_inputs_to_zero(&env->vfp.fp_status_f16));
184
+}
185
+
186
+void HELPER(gvec_fmlal_idx_a64)(void *vd, void *vn, void *vm,
187
+ void *venv, uint32_t desc)
188
+{
189
+ CPUARMState *env = venv;
190
+ do_fmlal_idx(vd, vn, vm, &env->vfp.fp_status, desc,
191
+ get_flush_inputs_to_zero(&env->vfp.fp_status_f16));
192
+}
193
--
131
--
194
2.20.1
132
2.34.1
195
133
196
134
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
2
3
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Message-id: 20230206223502.25122-5-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
target/arm/helper.c | 12 ++++++++++--
9
1 file changed, 10 insertions(+), 2 deletions(-)
10
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
14
+++ b/target/arm/helper.c
15
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
16
}
17
}
18
19
+#ifndef CONFIG_USER_ONLY
20
/*
21
* We don't know until after realize whether there's a GICv3
22
* attached, and that is what registers the gicv3 sysregs.
23
@@ -XXX,XX +XXX,XX @@ static uint64_t id_pfr1_read(CPUARMState *env, const ARMCPRegInfo *ri)
24
return pfr1;
25
}
26
27
-#ifndef CONFIG_USER_ONLY
28
static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri)
29
{
30
ARMCPU *cpu = env_archcpu(env);
31
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
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
--
50
2.34.1
51
52
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
4
Message-id: 20190219222952.22183-6-richard.henderson@linaro.org
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20230206223502.25122-6-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
---
8
linux-user/elfload.c | 2 ++
9
linux-user/user-internals.h | 2 +-
9
1 file changed, 2 insertions(+)
10
target/arm/cpu.h | 2 +-
11
linux-user/arm/cpu_loop.c | 4 ++--
12
3 files changed, 4 insertions(+), 4 deletions(-)
10
13
11
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
14
diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h
12
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
13
--- a/linux-user/elfload.c
16
--- a/linux-user/user-internals.h
14
+++ b/linux-user/elfload.c
17
+++ b/linux-user/user-internals.h
15
@@ -XXX,XX +XXX,XX @@ static uint32_t get_elf_hwcap(void)
18
@@ -XXX,XX +XXX,XX @@ void print_termios(void *arg);
16
GET_FEATURE_ID(aa64_fcma, ARM_HWCAP_A64_FCMA);
19
#ifdef TARGET_ARM
17
GET_FEATURE_ID(aa64_sve, ARM_HWCAP_A64_SVE);
20
static inline int regpairs_aligned(CPUArchState *cpu_env, int num)
18
GET_FEATURE_ID(aa64_pauth, ARM_HWCAP_A64_PACA | ARM_HWCAP_A64_PACG);
21
{
19
+ GET_FEATURE_ID(aa64_fhm, ARM_HWCAP_A64_ASIMDFHM);
22
- return cpu_env->eabi == 1;
20
+ GET_FEATURE_ID(aa64_jscvt, ARM_HWCAP_A64_JSCVT);
23
+ return cpu_env->eabi;
21
24
}
22
#undef GET_FEATURE_ID
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
}
23
61
24
--
62
--
25
2.20.1
63
2.34.1
26
64
27
65
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
Although the 'eabi' field is only used in user emulation where
4
Message-id: 20190219222952.22183-4-richard.henderson@linaro.org
4
CPU reset doesn't occur, it doesn't belong to the area to reset.
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
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
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
target/arm/cpu.h | 5 ++
12
target/arm/cpu.h | 9 ++++-----
9
target/arm/translate.c | 129 ++++++++++++++++++++++++++++++-----------
13
1 file changed, 4 insertions(+), 5 deletions(-)
10
2 files changed, 101 insertions(+), 33 deletions(-)
11
14
12
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
15
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
13
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu.h
17
--- a/target/arm/cpu.h
15
+++ b/target/arm/cpu.h
18
+++ b/target/arm/cpu.h
16
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_dp(const ARMISARegisters *id)
19
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
17
return FIELD_EX32(id->id_isar6, ID_ISAR6, DP) != 0;
20
ARMVectorReg zarray[ARM_MAX_VQ * 16];
18
}
21
#endif
19
22
20
+static inline bool isar_feature_aa32_fhm(const ARMISARegisters *id)
23
-#if defined(CONFIG_USER_ONLY)
21
+{
24
- /* For usermode syscall translation. */
22
+ return FIELD_EX32(id->id_isar6, ID_ISAR6, FHM) != 0;
25
- bool eabi;
23
+}
26
-#endif
24
+
25
static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id)
26
{
27
/*
28
diff --git a/target/arm/translate.c b/target/arm/translate.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/translate.c
31
+++ b/target/arm/translate.c
32
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
33
gen_helper_gvec_3_ptr *fn_gvec_ptr = NULL;
34
int rd, rn, rm, opr_sz;
35
int data = 0;
36
- bool q;
37
-
27
-
38
- q = extract32(insn, 6, 1);
28
struct CPUBreakpoint *cpu_breakpoint[16];
39
- VFP_DREG_D(rd, insn);
29
struct CPUWatchpoint *cpu_watchpoint[16];
40
- VFP_DREG_N(rn, insn);
30
41
- VFP_DREG_M(rm, insn);
31
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
42
- if ((rd | rn | rm) & q) {
32
const struct arm_boot_info *boot_info;
43
- return 1;
33
/* Store GICv3CPUState to access from this struct */
44
- }
34
void *gicv3state;
45
+ int off_rn, off_rm;
35
+#if defined(CONFIG_USER_ONLY)
46
+ bool is_long = false, q = extract32(insn, 6, 1);
36
+ /* For usermode syscall translation. */
47
+ bool ptr_is_env = false;
37
+ bool eabi;
48
38
+#endif /* CONFIG_USER_ONLY */
49
if ((insn & 0xfe200f10) == 0xfc200800) {
39
50
/* VCMLA -- 1111 110R R.1S .... .... 1000 ...0 .... */
40
#ifdef TARGET_TAGGED_ADDRESSES
51
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
41
/* Linux syscall tagged address support */
52
return 1;
53
}
54
fn_gvec = u ? gen_helper_gvec_udot_b : gen_helper_gvec_sdot_b;
55
+ } else if ((insn & 0xff300f10) == 0xfc200810) {
56
+ /* VFM[AS]L -- 1111 1100 S.10 .... .... 1000 .Q.1 .... */
57
+ int is_s = extract32(insn, 23, 1);
58
+ if (!dc_isar_feature(aa32_fhm, s)) {
59
+ return 1;
60
+ }
61
+ is_long = true;
62
+ data = is_s; /* is_2 == 0 */
63
+ fn_gvec_ptr = gen_helper_gvec_fmlal_a32;
64
+ ptr_is_env = true;
65
} else {
66
return 1;
67
}
68
69
+ VFP_DREG_D(rd, insn);
70
+ if (rd & q) {
71
+ return 1;
72
+ }
73
+ if (q || !is_long) {
74
+ VFP_DREG_N(rn, insn);
75
+ VFP_DREG_M(rm, insn);
76
+ if ((rn | rm) & q & !is_long) {
77
+ return 1;
78
+ }
79
+ off_rn = vfp_reg_offset(1, rn);
80
+ off_rm = vfp_reg_offset(1, rm);
81
+ } else {
82
+ rn = VFP_SREG_N(insn);
83
+ rm = VFP_SREG_M(insn);
84
+ off_rn = vfp_reg_offset(0, rn);
85
+ off_rm = vfp_reg_offset(0, rm);
86
+ }
87
+
88
if (s->fp_excp_el) {
89
gen_exception_insn(s, 4, EXCP_UDEF,
90
syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
91
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
92
93
opr_sz = (1 + q) * 8;
94
if (fn_gvec_ptr) {
95
- TCGv_ptr fpst = get_fpstatus_ptr(1);
96
- tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd),
97
- vfp_reg_offset(1, rn),
98
- vfp_reg_offset(1, rm), fpst,
99
+ TCGv_ptr ptr;
100
+ if (ptr_is_env) {
101
+ ptr = cpu_env;
102
+ } else {
103
+ ptr = get_fpstatus_ptr(1);
104
+ }
105
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), off_rn, off_rm, ptr,
106
opr_sz, opr_sz, data, fn_gvec_ptr);
107
- tcg_temp_free_ptr(fpst);
108
+ if (!ptr_is_env) {
109
+ tcg_temp_free_ptr(ptr);
110
+ }
111
} else {
112
- tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd),
113
- vfp_reg_offset(1, rn),
114
- vfp_reg_offset(1, rm),
115
+ tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd), off_rn, off_rm,
116
opr_sz, opr_sz, data, fn_gvec);
117
}
118
return 0;
119
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
120
gen_helper_gvec_3 *fn_gvec = NULL;
121
gen_helper_gvec_3_ptr *fn_gvec_ptr = NULL;
122
int rd, rn, rm, opr_sz, data;
123
- bool q;
124
-
125
- q = extract32(insn, 6, 1);
126
- VFP_DREG_D(rd, insn);
127
- VFP_DREG_N(rn, insn);
128
- if ((rd | rn) & q) {
129
- return 1;
130
- }
131
+ int off_rn, off_rm;
132
+ bool is_long = false, q = extract32(insn, 6, 1);
133
+ bool ptr_is_env = false;
134
135
if ((insn & 0xff000f10) == 0xfe000800) {
136
/* VCMLA (indexed) -- 1111 1110 S.RR .... .... 1000 ...0 .... */
137
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
138
} else if ((insn & 0xffb00f00) == 0xfe200d00) {
139
/* V[US]DOT -- 1111 1110 0.10 .... .... 1101 .Q.U .... */
140
int u = extract32(insn, 4, 1);
141
+
142
if (!dc_isar_feature(aa32_dp, s)) {
143
return 1;
144
}
145
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
146
/* rm is just Vm, and index is M. */
147
data = extract32(insn, 5, 1); /* index */
148
rm = extract32(insn, 0, 4);
149
+ } else if ((insn & 0xffa00f10) == 0xfe000810) {
150
+ /* VFM[AS]L -- 1111 1110 0.0S .... .... 1000 .Q.1 .... */
151
+ int is_s = extract32(insn, 20, 1);
152
+ int vm20 = extract32(insn, 0, 3);
153
+ int vm3 = extract32(insn, 3, 1);
154
+ int m = extract32(insn, 5, 1);
155
+ int index;
156
+
157
+ if (!dc_isar_feature(aa32_fhm, s)) {
158
+ return 1;
159
+ }
160
+ if (q) {
161
+ rm = vm20;
162
+ index = m * 2 + vm3;
163
+ } else {
164
+ rm = vm20 * 2 + m;
165
+ index = vm3;
166
+ }
167
+ is_long = true;
168
+ data = (index << 2) | is_s; /* is_2 == 0 */
169
+ fn_gvec_ptr = gen_helper_gvec_fmlal_idx_a32;
170
+ ptr_is_env = true;
171
} else {
172
return 1;
173
}
174
175
+ VFP_DREG_D(rd, insn);
176
+ if (rd & q) {
177
+ return 1;
178
+ }
179
+ if (q || !is_long) {
180
+ VFP_DREG_N(rn, insn);
181
+ if (rn & q & !is_long) {
182
+ return 1;
183
+ }
184
+ off_rn = vfp_reg_offset(1, rn);
185
+ off_rm = vfp_reg_offset(1, rm);
186
+ } else {
187
+ rn = VFP_SREG_N(insn);
188
+ off_rn = vfp_reg_offset(0, rn);
189
+ off_rm = vfp_reg_offset(0, rm);
190
+ }
191
if (s->fp_excp_el) {
192
gen_exception_insn(s, 4, EXCP_UDEF,
193
syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
194
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
195
196
opr_sz = (1 + q) * 8;
197
if (fn_gvec_ptr) {
198
- TCGv_ptr fpst = get_fpstatus_ptr(1);
199
- tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd),
200
- vfp_reg_offset(1, rn),
201
- vfp_reg_offset(1, rm), fpst,
202
+ TCGv_ptr ptr;
203
+ if (ptr_is_env) {
204
+ ptr = cpu_env;
205
+ } else {
206
+ ptr = get_fpstatus_ptr(1);
207
+ }
208
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), off_rn, off_rm, ptr,
209
opr_sz, opr_sz, data, fn_gvec_ptr);
210
- tcg_temp_free_ptr(fpst);
211
+ if (!ptr_is_env) {
212
+ tcg_temp_free_ptr(ptr);
213
+ }
214
} else {
215
- tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd),
216
- vfp_reg_offset(1, rn),
217
- vfp_reg_offset(1, rm),
218
+ tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd), off_rn, off_rm,
219
opr_sz, opr_sz, data, fn_gvec);
220
}
221
return 0;
222
--
42
--
223
2.20.1
43
2.34.1
224
44
225
45
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
3
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
Message-id: 20190219222952.22183-3-richard.henderson@linaro.org
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20230206223502.25122-8-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
7
---
8
target/arm/cpu.h | 5 ++++
8
target/arm/cpu.h | 3 ++-
9
target/arm/translate-a64.c | 49 +++++++++++++++++++++++++++++++++++++-
9
1 file changed, 2 insertions(+), 1 deletion(-)
10
2 files changed, 53 insertions(+), 1 deletion(-)
11
10
12
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
13
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu.h
13
--- a/target/arm/cpu.h
15
+++ b/target/arm/cpu.h
14
+++ b/target/arm/cpu.h
16
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_dp(const ARMISARegisters *id)
15
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
17
return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, DP) != 0;
16
18
}
17
void *nvic;
19
18
const struct arm_boot_info *boot_info;
20
+static inline bool isar_feature_aa64_fhm(const ARMISARegisters *id)
19
+#if !defined(CONFIG_USER_ONLY)
21
+{
20
/* Store GICv3CPUState to access from this struct */
22
+ return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, FHM) != 0;
21
void *gicv3state;
23
+}
22
-#if defined(CONFIG_USER_ONLY)
24
+
23
+#else /* CONFIG_USER_ONLY */
25
static inline bool isar_feature_aa64_jscvt(const ARMISARegisters *id)
24
/* For usermode syscall translation. */
26
{
25
bool eabi;
27
return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, JSCVT) != 0;
26
#endif /* CONFIG_USER_ONLY */
28
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/target/arm/translate-a64.c
31
+++ b/target/arm/translate-a64.c
32
@@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_float(DisasContext *s, uint32_t insn)
33
if (!fp_access_check(s)) {
34
return;
35
}
36
-
37
handle_3same_float(s, size, elements, fpopcode, rd, rn, rm);
38
return;
39
+
40
+ case 0x1d: /* FMLAL */
41
+ case 0x3d: /* FMLSL */
42
+ case 0x59: /* FMLAL2 */
43
+ case 0x79: /* FMLSL2 */
44
+ if (size & 1 || !dc_isar_feature(aa64_fhm, s)) {
45
+ unallocated_encoding(s);
46
+ return;
47
+ }
48
+ if (fp_access_check(s)) {
49
+ int is_s = extract32(insn, 23, 1);
50
+ int is_2 = extract32(insn, 29, 1);
51
+ int data = (is_2 << 1) | is_s;
52
+ tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd),
53
+ vec_full_reg_offset(s, rn),
54
+ vec_full_reg_offset(s, rm), cpu_env,
55
+ is_q ? 16 : 8, vec_full_reg_size(s),
56
+ data, gen_helper_gvec_fmlal_a64);
57
+ }
58
+ return;
59
+
60
default:
61
unallocated_encoding(s);
62
return;
63
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
64
}
65
is_fp = 2;
66
break;
67
+ case 0x00: /* FMLAL */
68
+ case 0x04: /* FMLSL */
69
+ case 0x18: /* FMLAL2 */
70
+ case 0x1c: /* FMLSL2 */
71
+ if (is_scalar || size != MO_32 || !dc_isar_feature(aa64_fhm, s)) {
72
+ unallocated_encoding(s);
73
+ return;
74
+ }
75
+ size = MO_16;
76
+ /* is_fp, but we pass cpu_env not fp_status. */
77
+ break;
78
default:
79
unallocated_encoding(s);
80
return;
81
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
82
tcg_temp_free_ptr(fpst);
83
}
84
return;
85
+
86
+ case 0x00: /* FMLAL */
87
+ case 0x04: /* FMLSL */
88
+ case 0x18: /* FMLAL2 */
89
+ case 0x1c: /* FMLSL2 */
90
+ {
91
+ int is_s = extract32(opcode, 2, 1);
92
+ int is_2 = u;
93
+ int data = (index << 2) | (is_2 << 1) | is_s;
94
+ tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd),
95
+ vec_full_reg_offset(s, rn),
96
+ vec_full_reg_offset(s, rm), cpu_env,
97
+ is_q ? 16 : 8, vec_full_reg_size(s),
98
+ data, gen_helper_gvec_fmlal_idx_a64);
99
+ }
100
+ return;
101
}
102
103
if (size == 3) {
104
--
27
--
105
2.20.1
28
2.34.1
106
29
107
30
diff view generated by jsdifflib
1
This reverts commit 823e1b3818f9b10b824ddcd756983b6e2fa68730,
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
which introduces a regression running EDK2 guest firmware
3
under KVM:
4
2
5
error: kvm run failed Function not implemented
3
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
PC=000000013f5a6208 X00=00000000404003c4 X01=000000000000003a
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
X02=0000000000000000 X03=00000000404003c4 X04=0000000000000000
5
Message-id: 20230206223502.25122-9-philmd@linaro.org
8
X05=0000000096000046 X06=000000013d2ef270 X07=000000013e3d1710
9
X08=09010755ffaf8ba8 X09=ffaf8b9cfeeb5468 X10=feeb546409010756
10
X11=09010757ffaf8b90 X12=feeb50680903068b X13=090306a1ffaf8bc0
11
X14=0000000000000000 X15=0000000000000000 X16=000000013f872da0
12
X17=00000000ffffa6ab X18=0000000000000000 X19=000000013f5a92d0
13
X20=000000013f5a7a78 X21=000000000000003a X22=000000013f5a7ab2
14
X23=000000013f5a92e8 X24=000000013f631090 X25=0000000000000010
15
X26=0000000000000100 X27=000000013f89501b X28=000000013e3d14e0
16
X29=000000013e3d12a0 X30=000000013f5a2518 SP=000000013b7be0b0
17
PSTATE=404003c4 -Z-- EL1t
18
19
with
20
[ 3507.926571] kvm [35042]: load/store instruction decoding not implemented
21
in the host dmesg.
22
23
Revert the change for the moment until we can investigate the
24
cause of the regression.
25
26
Reported-by: Eric Auger <eric.auger@redhat.com>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
7
---
29
target/arm/cpu.h | 9 +--------
8
target/arm/cpu.h | 2 +-
30
target/arm/helper.c | 27 ++-------------------------
9
1 file changed, 1 insertion(+), 1 deletion(-)
31
target/arm/kvm32.c | 20 ++++++++++++++++++--
32
target/arm/kvm64.c | 2 --
33
target/arm/machine.c | 2 +-
34
5 files changed, 22 insertions(+), 38 deletions(-)
35
10
36
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
37
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/cpu.h
13
--- a/target/arm/cpu.h
39
+++ b/target/arm/cpu.h
14
+++ b/target/arm/cpu.h
40
@@ -XXX,XX +XXX,XX @@ bool write_list_to_cpustate(ARMCPU *cpu);
15
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
41
/**
16
} sau;
42
* write_cpustate_to_list:
17
43
* @cpu: ARMCPU
18
void *nvic;
44
- * @kvm_sync: true if this is for syncing back to KVM
19
- const struct arm_boot_info *boot_info;
45
*
20
#if !defined(CONFIG_USER_ONLY)
46
* For each register listed in the ARMCPU cpreg_indexes list, write
21
+ const struct arm_boot_info *boot_info;
47
* its value from the ARMCPUState structure into the cpreg_values list.
22
/* Store GICv3CPUState to access from this struct */
48
* This is used to copy info from TCG's working data structures into
23
void *gicv3state;
49
* KVM or for outbound migration.
24
#else /* CONFIG_USER_ONLY */
50
*
51
- * @kvm_sync is true if we are doing this in order to sync the
52
- * register state back to KVM. In this case we will only update
53
- * values in the list if the previous list->cpustate sync actually
54
- * successfully wrote the CPU state. Otherwise we will keep the value
55
- * that is in the list.
56
- *
57
* Returns: true if all register values were read correctly,
58
* false if some register was unknown or could not be read.
59
* Note that we do not stop early on failure -- we will attempt
60
* reading all registers in the list.
61
*/
62
-bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
63
+bool write_cpustate_to_list(ARMCPU *cpu);
64
65
#define ARM_CPUID_TI915T 0x54029152
66
#define ARM_CPUID_TI925T 0x54029252
67
diff --git a/target/arm/helper.c b/target/arm/helper.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/target/arm/helper.c
70
+++ b/target/arm/helper.c
71
@@ -XXX,XX +XXX,XX @@ static bool raw_accessors_invalid(const ARMCPRegInfo *ri)
72
return true;
73
}
74
75
-bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync)
76
+bool write_cpustate_to_list(ARMCPU *cpu)
77
{
78
/* Write the coprocessor state from cpu->env to the (index,value) list. */
79
int i;
80
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync)
81
for (i = 0; i < cpu->cpreg_array_len; i++) {
82
uint32_t regidx = kvm_to_cpreg_id(cpu->cpreg_indexes[i]);
83
const ARMCPRegInfo *ri;
84
- uint64_t newval;
85
86
ri = get_arm_cp_reginfo(cpu->cp_regs, regidx);
87
if (!ri) {
88
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync)
89
if (ri->type & ARM_CP_NO_RAW) {
90
continue;
91
}
92
-
93
- newval = read_raw_cp_reg(&cpu->env, ri);
94
- if (kvm_sync) {
95
- /*
96
- * Only sync if the previous list->cpustate sync succeeded.
97
- * Rather than tracking the success/failure state for every
98
- * item in the list, we just recheck "does the raw write we must
99
- * have made in write_list_to_cpustate() read back OK" here.
100
- */
101
- uint64_t oldval = cpu->cpreg_values[i];
102
-
103
- if (oldval == newval) {
104
- continue;
105
- }
106
-
107
- write_raw_cp_reg(&cpu->env, ri, oldval);
108
- if (read_raw_cp_reg(&cpu->env, ri) != oldval) {
109
- continue;
110
- }
111
-
112
- write_raw_cp_reg(&cpu->env, ri, newval);
113
- }
114
- cpu->cpreg_values[i] = newval;
115
+ cpu->cpreg_values[i] = read_raw_cp_reg(&cpu->env, ri);
116
}
117
return ok;
118
}
119
diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c
120
index XXXXXXX..XXXXXXX 100644
121
--- a/target/arm/kvm32.c
122
+++ b/target/arm/kvm32.c
123
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
124
return ret;
125
}
126
127
- write_cpustate_to_list(cpu, true);
128
-
129
+ /* Note that we do not call write_cpustate_to_list()
130
+ * here, so we are only writing the tuple list back to
131
+ * KVM. This is safe because nothing can change the
132
+ * CPUARMState cp15 fields (in particular gdb accesses cannot)
133
+ * and so there are no changes to sync. In fact syncing would
134
+ * be wrong at this point: for a constant register where TCG and
135
+ * KVM disagree about its value, the preceding write_list_to_cpustate()
136
+ * would not have had any effect on the CPUARMState value (since the
137
+ * register is read-only), and a write_cpustate_to_list() here would
138
+ * then try to write the TCG value back into KVM -- this would either
139
+ * fail or incorrectly change the value the guest sees.
140
+ *
141
+ * If we ever want to allow the user to modify cp15 registers via
142
+ * the gdb stub, we would need to be more clever here (for instance
143
+ * tracking the set of registers kvm_arch_get_registers() successfully
144
+ * managed to update the CPUARMState with, and only allowing those
145
+ * to be written back up into the kernel).
146
+ */
147
if (!write_list_to_kvmstate(cpu, level)) {
148
return EINVAL;
149
}
150
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
151
index XXXXXXX..XXXXXXX 100644
152
--- a/target/arm/kvm64.c
153
+++ b/target/arm/kvm64.c
154
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
155
return ret;
156
}
157
158
- write_cpustate_to_list(cpu, true);
159
-
160
if (!write_list_to_kvmstate(cpu, level)) {
161
return EINVAL;
162
}
163
diff --git a/target/arm/machine.c b/target/arm/machine.c
164
index XXXXXXX..XXXXXXX 100644
165
--- a/target/arm/machine.c
166
+++ b/target/arm/machine.c
167
@@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque)
168
abort();
169
}
170
} else {
171
- if (!write_cpustate_to_list(cpu, false)) {
172
+ if (!write_cpustate_to_list(cpu)) {
173
/* This should never fail. */
174
abort();
175
}
176
--
25
--
177
2.20.1
26
2.34.1
178
27
179
28
diff view generated by jsdifflib
1
There is a set of VFP instructions which we implement in
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
disas_vfp_v8_insn() and gate on the ARM_FEATURE_V8 bit.
3
These were all first introduced in v8 for A-profile, but in
4
M-profile they appeared in v7M. Gate them on the MVFR2
5
FPMisc field instead, and rename the function appropriately.
6
2
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
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190222170936.13268-3-peter.maydell@linaro.org
10
---
7
---
11
target/arm/cpu.h | 20 ++++++++++++++++++++
8
target/arm/cpu.h | 2 +-
12
target/arm/translate.c | 25 +++++++++++++------------
9
1 file changed, 1 insertion(+), 1 deletion(-)
13
2 files changed, 33 insertions(+), 12 deletions(-)
14
10
15
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
11
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
16
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu.h
13
--- a/target/arm/cpu.h
18
+++ b/target/arm/cpu.h
14
+++ b/target/arm/cpu.h
19
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_fp16_dpconv(const ARMISARegisters *id)
15
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
20
return FIELD_EX64(id->mvfr1, MVFR1, FPHP) > 1;
16
uint32_t ctrl;
21
}
17
} sau;
22
18
23
+static inline bool isar_feature_aa32_vsel(const ARMISARegisters *id)
19
- void *nvic;
24
+{
20
#if !defined(CONFIG_USER_ONLY)
25
+ return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 1;
21
+ void *nvic;
26
+}
22
const struct arm_boot_info *boot_info;
27
+
23
/* Store GICv3CPUState to access from this struct */
28
+static inline bool isar_feature_aa32_vcvt_dr(const ARMISARegisters *id)
24
void *gicv3state;
29
+{
30
+ return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 2;
31
+}
32
+
33
+static inline bool isar_feature_aa32_vrint(const ARMISARegisters *id)
34
+{
35
+ return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 3;
36
+}
37
+
38
+static inline bool isar_feature_aa32_vminmaxnm(const ARMISARegisters *id)
39
+{
40
+ return FIELD_EX64(id->mvfr2, MVFR2, FPMISC) >= 4;
41
+}
42
+
43
/*
44
* 64-bit feature tests via id registers.
45
*/
46
diff --git a/target/arm/translate.c b/target/arm/translate.c
47
index XXXXXXX..XXXXXXX 100644
48
--- a/target/arm/translate.c
49
+++ b/target/arm/translate.c
50
@@ -XXX,XX +XXX,XX @@ static const uint8_t fp_decode_rm[] = {
51
FPROUNDING_NEGINF,
52
};
53
54
-static int disas_vfp_v8_insn(DisasContext *s, uint32_t insn)
55
+static int disas_vfp_misc_insn(DisasContext *s, uint32_t insn)
56
{
57
uint32_t rd, rn, rm, dp = extract32(insn, 8, 1);
58
59
- if (!arm_dc_feature(s, ARM_FEATURE_V8)) {
60
- return 1;
61
- }
62
-
63
if (dp) {
64
VFP_DREG_D(rd, insn);
65
VFP_DREG_N(rn, insn);
66
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_v8_insn(DisasContext *s, uint32_t insn)
67
rm = VFP_SREG_M(insn);
68
}
69
70
- if ((insn & 0x0f800e50) == 0x0e000a00) {
71
+ if ((insn & 0x0f800e50) == 0x0e000a00 && dc_isar_feature(aa32_vsel, s)) {
72
return handle_vsel(insn, rd, rn, rm, dp);
73
- } else if ((insn & 0x0fb00e10) == 0x0e800a00) {
74
+ } else if ((insn & 0x0fb00e10) == 0x0e800a00 &&
75
+ dc_isar_feature(aa32_vminmaxnm, s)) {
76
return handle_vminmaxnm(insn, rd, rn, rm, dp);
77
- } else if ((insn & 0x0fbc0ed0) == 0x0eb80a40) {
78
+ } else if ((insn & 0x0fbc0ed0) == 0x0eb80a40 &&
79
+ dc_isar_feature(aa32_vrint, s)) {
80
/* VRINTA, VRINTN, VRINTP, VRINTM */
81
int rounding = fp_decode_rm[extract32(insn, 16, 2)];
82
return handle_vrint(insn, rd, rm, dp, rounding);
83
- } else if ((insn & 0x0fbc0e50) == 0x0ebc0a40) {
84
+ } else if ((insn & 0x0fbc0e50) == 0x0ebc0a40 &&
85
+ dc_isar_feature(aa32_vcvt_dr, s)) {
86
/* VCVTA, VCVTN, VCVTP, VCVTM */
87
int rounding = fp_decode_rm[extract32(insn, 16, 2)];
88
return handle_vcvt(insn, rd, rm, dp, rounding);
89
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
90
}
91
92
if (extract32(insn, 28, 4) == 0xf) {
93
- /* Encodings with T=1 (Thumb) or unconditional (ARM):
94
- * only used in v8 and above.
95
+ /*
96
+ * Encodings with T=1 (Thumb) or unconditional (ARM):
97
+ * only used for the "miscellaneous VFP features" added in v8A
98
+ * and v7M (and gated on the MVFR2.FPMisc field).
99
*/
100
- return disas_vfp_v8_insn(s, insn);
101
+ return disas_vfp_misc_insn(s, insn);
102
}
103
104
dp = ((insn & 0xf00) == 0xb00);
105
--
25
--
106
2.20.1
26
2.34.1
107
27
108
28
diff view generated by jsdifflib
1
Instead of gating the A32/T32 FP16 conversion instructions on
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
the ARM_FEATURE_VFP_FP16 flag, switch to our new approach of
2
3
looking at ID register bits. In this case MVFR1 fields FPHP
3
There is no point in using a void pointer to access the NVIC.
4
and SIMDHP indicate the presence of these insns.
4
Use the real type to avoid casting it while debugging.
5
5
6
This change doesn't alter behaviour for any of our CPUs.
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230206223502.25122-11-philmd@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20190222170936.13268-2-peter.maydell@linaro.org
11
---
10
---
12
target/arm/cpu.h | 37 ++++++++++++++++++++++++++++++++++++-
11
target/arm/cpu.h | 46 ++++++++++++++++++++++---------------------
13
target/arm/cpu.c | 2 --
12
hw/intc/armv7m_nvic.c | 38 ++++++++++++-----------------------
14
target/arm/kvm32.c | 3 ---
13
target/arm/cpu.c | 1 +
15
target/arm/translate.c | 26 ++++++++++++++++++--------
14
target/arm/m_helper.c | 2 +-
16
4 files changed, 54 insertions(+), 14 deletions(-)
15
4 files changed, 39 insertions(+), 48 deletions(-)
17
16
18
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
19
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/cpu.h
19
--- a/target/arm/cpu.h
21
+++ b/target/arm/cpu.h
20
+++ b/target/arm/cpu.h
22
@@ -XXX,XX +XXX,XX @@ FIELD(ID_DFR0, MPROFDBG, 20, 4)
21
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMTBFlags {
23
FIELD(ID_DFR0, PERFMON, 24, 4)
22
24
FIELD(ID_DFR0, TRACEFILT, 28, 4)
23
typedef struct ARMMMUFaultInfo ARMMMUFaultInfo;
25
24
26
+FIELD(MVFR0, SIMDREG, 0, 4)
25
+typedef struct NVICState NVICState;
27
+FIELD(MVFR0, FPSP, 4, 4)
28
+FIELD(MVFR0, FPDP, 8, 4)
29
+FIELD(MVFR0, FPTRAP, 12, 4)
30
+FIELD(MVFR0, FPDIVIDE, 16, 4)
31
+FIELD(MVFR0, FPSQRT, 20, 4)
32
+FIELD(MVFR0, FPSHVEC, 24, 4)
33
+FIELD(MVFR0, FPROUND, 28, 4)
34
+
26
+
35
+FIELD(MVFR1, FPFTZ, 0, 4)
27
typedef struct CPUArchState {
36
+FIELD(MVFR1, FPDNAN, 4, 4)
28
/* Regs for current mode. */
37
+FIELD(MVFR1, SIMDLS, 8, 4)
29
uint32_t regs[16];
38
+FIELD(MVFR1, SIMDINT, 12, 4)
30
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
39
+FIELD(MVFR1, SIMDSP, 16, 4)
31
} sau;
40
+FIELD(MVFR1, SIMDHP, 20, 4)
32
41
+FIELD(MVFR1, FPHP, 24, 4)
33
#if !defined(CONFIG_USER_ONLY)
42
+FIELD(MVFR1, SIMDFMAC, 28, 4)
34
- void *nvic;
43
+
35
+ NVICState *nvic;
44
+FIELD(MVFR2, SIMDMISC, 0, 4)
36
const struct arm_boot_info *boot_info;
45
+FIELD(MVFR2, FPMISC, 4, 4)
37
/* Store GICv3CPUState to access from this struct */
46
+
38
void *gicv3state;
47
QEMU_BUILD_BUG_ON(ARRAY_SIZE(((ARMCPU *)0)->ccsidr) <= R_V7M_CSSELR_INDEX_MASK);
39
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
48
40
49
/* If adding a feature bit which corresponds to a Linux ELF
41
/* Interface between CPU and Interrupt controller. */
50
@@ -XXX,XX +XXX,XX @@ enum arm_features {
42
#ifndef CONFIG_USER_ONLY
51
ARM_FEATURE_THUMB2,
43
-bool armv7m_nvic_can_take_pending_exception(void *opaque);
52
ARM_FEATURE_PMSA, /* no MMU; may have Memory Protection Unit */
44
+bool armv7m_nvic_can_take_pending_exception(NVICState *s);
53
ARM_FEATURE_VFP3,
45
#else
54
- ARM_FEATURE_VFP_FP16,
46
-static inline bool armv7m_nvic_can_take_pending_exception(void *opaque)
55
ARM_FEATURE_NEON,
47
+static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s)
56
ARM_FEATURE_M, /* Microcontroller profile. */
48
{
57
ARM_FEATURE_OMAPCP, /* OMAP specific CP15 ops handling. */
49
return true;
58
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa32_fp16_arith(const ARMISARegisters *id)
50
}
59
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1;
51
#endif
60
}
52
/**
61
53
* armv7m_nvic_set_pending: mark the specified exception as pending
62
+/*
54
- * @opaque: the NVIC
63
+ * We always set the FP and SIMD FP16 fields to indicate identical
55
+ * @s: the NVIC
64
+ * levels of support (assuming SIMD is implemented at all), so
56
* @irq: the exception number to mark pending
65
+ * we only need one set of accessors.
57
* @secure: false for non-banked exceptions or for the nonsecure
66
+ */
58
* version of a banked exception, true for the secure version of a banked
67
+static inline bool isar_feature_aa32_fp16_spconv(const ARMISARegisters *id)
59
@@ -XXX,XX +XXX,XX @@ static inline bool armv7m_nvic_can_take_pending_exception(void *opaque)
68
+{
60
* if @secure is true and @irq does not specify one of the fixed set
69
+ return FIELD_EX64(id->mvfr1, MVFR1, FPHP) > 0;
61
* of architecturally banked exceptions.
70
+}
62
*/
71
+
63
-void armv7m_nvic_set_pending(void *opaque, int irq, bool secure);
72
+static inline bool isar_feature_aa32_fp16_dpconv(const ARMISARegisters *id)
64
+void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure);
73
+{
65
/**
74
+ return FIELD_EX64(id->mvfr1, MVFR1, FPHP) > 1;
66
* armv7m_nvic_set_pending_derived: mark this derived exception as pending
75
+}
67
- * @opaque: the NVIC
76
+
68
+ * @s: the NVIC
77
/*
69
* @irq: the exception number to mark pending
78
* 64-bit feature tests via id registers.
70
* @secure: false for non-banked exceptions or for the nonsecure
79
*/
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;
193
}
194
@@ -XXX,XX +XXX,XX @@ bool armv7m_nvic_neg_prio_requested(void *opaque, bool secure)
195
return false;
196
}
197
198
-bool armv7m_nvic_can_take_pending_exception(void *opaque)
199
+bool armv7m_nvic_can_take_pending_exception(NVICState *s)
200
{
201
- NVICState *s = opaque;
202
-
203
return nvic_exec_prio(s) > nvic_pending_prio(s);
204
}
205
206
-int armv7m_nvic_raw_execution_priority(void *opaque)
207
+int armv7m_nvic_raw_execution_priority(NVICState *s)
208
{
209
- NVICState *s = opaque;
210
-
211
return s->exception_prio;
212
}
213
214
@@ -XXX,XX +XXX,XX @@ static void nvic_irq_update(NVICState *s)
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);
80
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
307
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
81
index XXXXXXX..XXXXXXX 100644
308
index XXXXXXX..XXXXXXX 100644
82
--- a/target/arm/cpu.c
309
--- a/target/arm/cpu.c
83
+++ b/target/arm/cpu.c
310
+++ b/target/arm/cpu.c
84
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
311
@@ -XXX,XX +XXX,XX @@
85
}
312
#if !defined(CONFIG_USER_ONLY)
86
if (arm_feature(env, ARM_FEATURE_VFP4)) {
313
#include "hw/loader.h"
87
set_feature(env, ARM_FEATURE_VFP3);
314
#include "hw/boards.h"
88
- set_feature(env, ARM_FEATURE_VFP_FP16);
315
+#include "hw/intc/armv7m_nvic.h"
89
}
316
#endif
90
if (arm_feature(env, ARM_FEATURE_VFP3)) {
317
#include "sysemu/tcg.h"
91
set_feature(env, ARM_FEATURE_VFP);
318
#include "sysemu/qtest.h"
92
@@ -XXX,XX +XXX,XX @@ static void cortex_a9_initfn(Object *obj)
319
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
93
cpu->dtb_compatible = "arm,cortex-a9";
94
set_feature(&cpu->env, ARM_FEATURE_V7);
95
set_feature(&cpu->env, ARM_FEATURE_VFP3);
96
- set_feature(&cpu->env, ARM_FEATURE_VFP_FP16);
97
set_feature(&cpu->env, ARM_FEATURE_NEON);
98
set_feature(&cpu->env, ARM_FEATURE_THUMB2EE);
99
set_feature(&cpu->env, ARM_FEATURE_EL3);
100
diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c
101
index XXXXXXX..XXXXXXX 100644
320
index XXXXXXX..XXXXXXX 100644
102
--- a/target/arm/kvm32.c
321
--- a/target/arm/m_helper.c
103
+++ b/target/arm/kvm32.c
322
+++ b/target/arm/m_helper.c
104
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)
323
@@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr,
105
if (extract32(id_pfr0, 12, 4) == 1) {
324
* that we will need later in order to do lazy FP reg stacking.
106
set_feature(&features, ARM_FEATURE_THUMB2EE);
325
*/
107
}
326
bool is_secure = env->v7m.secure;
108
- if (extract32(ahcf->isar.mvfr1, 20, 4) == 1) {
327
- void *nvic = env->nvic;
109
- set_feature(&features, ARM_FEATURE_VFP_FP16);
328
+ NVICState *nvic = env->nvic;
110
- }
329
/*
111
if (extract32(ahcf->isar.mvfr1, 12, 4) == 1) {
330
* Some bits are unbanked and live always in fpccr[M_REG_S]; some bits
112
set_feature(&features, ARM_FEATURE_NEON);
331
* are banked and we want to update the bit in the bank for the
113
}
114
diff --git a/target/arm/translate.c b/target/arm/translate.c
115
index XXXXXXX..XXXXXXX 100644
116
--- a/target/arm/translate.c
117
+++ b/target/arm/translate.c
118
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
119
* UNPREDICTABLE if bit 8 is set prior to ARMv8
120
* (we choose to UNDEF)
121
*/
122
- if ((dp && !arm_dc_feature(s, ARM_FEATURE_V8)) ||
123
- !arm_dc_feature(s, ARM_FEATURE_VFP_FP16)) {
124
- return 1;
125
+ if (dp) {
126
+ if (!dc_isar_feature(aa32_fp16_dpconv, s)) {
127
+ return 1;
128
+ }
129
+ } else {
130
+ if (!dc_isar_feature(aa32_fp16_spconv, s)) {
131
+ return 1;
132
+ }
133
}
134
rm_is_dp = false;
135
break;
136
case 0x06: /* vcvtb.f16.f32, vcvtb.f16.f64 */
137
case 0x07: /* vcvtt.f16.f32, vcvtt.f16.f64 */
138
- if ((dp && !arm_dc_feature(s, ARM_FEATURE_V8)) ||
139
- !arm_dc_feature(s, ARM_FEATURE_VFP_FP16)) {
140
- return 1;
141
+ if (dp) {
142
+ if (!dc_isar_feature(aa32_fp16_dpconv, s)) {
143
+ return 1;
144
+ }
145
+ } else {
146
+ if (!dc_isar_feature(aa32_fp16_spconv, s)) {
147
+ return 1;
148
+ }
149
}
150
rd_is_dp = false;
151
break;
152
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
153
TCGv_ptr fpst;
154
TCGv_i32 ahp;
155
156
- if (!arm_dc_feature(s, ARM_FEATURE_VFP_FP16) ||
157
+ if (!dc_isar_feature(aa32_fp16_spconv, s) ||
158
q || (rm & 1)) {
159
return 1;
160
}
161
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
162
{
163
TCGv_ptr fpst;
164
TCGv_i32 ahp;
165
- if (!arm_dc_feature(s, ARM_FEATURE_VFP_FP16) ||
166
+ if (!dc_isar_feature(aa32_fp16_spconv, s) ||
167
q || (rd & 1)) {
168
return 1;
169
}
170
--
332
--
171
2.20.1
333
2.34.1
172
334
173
335
diff view generated by jsdifflib
1
Make the M-profile "init-svtor" property be settable after realize.
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
This matches the hardware, where this is a config signal which
2
3
is sampled on CPU reset and can thus be changed between one
3
While dozens of files include "cpu.h", only 3 files require
4
reset and another. To do this we have to change the API we
4
these NVIC helper declarations.
5
use to add the property.
5
6
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
(We will need this capability for the SSE-200.)
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
8
Message-id: 20230206223502.25122-12-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20190219125808.25174-4-peter.maydell@linaro.org
12
---
10
---
13
target/arm/cpu.c | 29 ++++++++++++++++++++++++-----
11
include/hw/intc/armv7m_nvic.h | 123 ++++++++++++++++++++++++++++++++++
14
1 file changed, 24 insertions(+), 5 deletions(-)
12
target/arm/cpu.h | 123 ----------------------------------
15
13
target/arm/cpu.c | 4 +-
14
target/arm/cpu_tcg.c | 3 +
15
target/arm/m_helper.c | 3 +
16
5 files changed, 132 insertions(+), 124 deletions(-)
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
151
index XXXXXXX..XXXXXXX 100644
152
--- a/target/arm/cpu.h
153
+++ b/target/arm/cpu.h
154
@@ -XXX,XX +XXX,XX @@ void arm_cpu_list(void);
155
uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
156
uint32_t cur_el, bool secure);
157
158
-/* Interface between CPU and Interrupt controller. */
159
-#ifndef CONFIG_USER_ONLY
160
-bool armv7m_nvic_can_take_pending_exception(NVICState *s);
161
-#else
162
-static inline bool armv7m_nvic_can_take_pending_exception(NVICState *s)
163
-{
164
- return true;
165
-}
166
-#endif
167
-/**
168
- * armv7m_nvic_set_pending: mark the specified exception as pending
169
- * @s: the NVIC
170
- * @irq: the exception number to mark pending
171
- * @secure: false for non-banked exceptions or for the nonsecure
172
- * version of a banked exception, true for the secure version of a banked
173
- * exception.
174
- *
175
- * Marks the specified exception as pending. Note that we will assert()
176
- * if @secure is true and @irq does not specify one of the fixed set
177
- * of architecturally banked exceptions.
178
- */
179
-void armv7m_nvic_set_pending(NVICState *s, int irq, bool secure);
180
-/**
181
- * armv7m_nvic_set_pending_derived: mark this derived exception as pending
182
- * @s: the NVIC
183
- * @irq: the exception number to mark pending
184
- * @secure: false for non-banked exceptions or for the nonsecure
185
- * version of a banked exception, true for the secure version of a banked
186
- * exception.
187
- *
188
- * Similar to armv7m_nvic_set_pending(), but specifically for derived
189
- * exceptions (exceptions generated in the course of trying to take
190
- * a different exception).
191
- */
192
-void armv7m_nvic_set_pending_derived(NVICState *s, int irq, bool secure);
193
-/**
194
- * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending
195
- * @s: the NVIC
196
- * @irq: the exception number to mark pending
197
- * @secure: false for non-banked exceptions or for the nonsecure
198
- * version of a banked exception, true for the secure version of a banked
199
- * exception.
200
- *
201
- * Similar to armv7m_nvic_set_pending(), but specifically for exceptions
202
- * generated in the course of lazy stacking of FP registers.
203
- */
204
-void armv7m_nvic_set_pending_lazyfp(NVICState *s, int irq, bool secure);
205
-/**
206
- * armv7m_nvic_get_pending_irq_info: return highest priority pending
207
- * exception, and whether it targets Secure state
208
- * @s: the NVIC
209
- * @pirq: set to pending exception number
210
- * @ptargets_secure: set to whether pending exception targets Secure
211
- *
212
- * This function writes the number of the highest priority pending
213
- * exception (the one which would be made active by
214
- * armv7m_nvic_acknowledge_irq()) to @pirq, and sets @ptargets_secure
215
- * to true if the current highest priority pending exception should
216
- * be taken to Secure state, false for NS.
217
- */
218
-void armv7m_nvic_get_pending_irq_info(NVICState *s, int *pirq,
219
- bool *ptargets_secure);
220
-/**
221
- * armv7m_nvic_acknowledge_irq: make highest priority pending exception active
222
- * @s: the NVIC
223
- *
224
- * Move the current highest priority pending exception from the pending
225
- * state to the active state, and update v7m.exception to indicate that
226
- * it is the exception currently being handled.
227
- */
228
-void armv7m_nvic_acknowledge_irq(NVICState *s);
229
-/**
230
- * armv7m_nvic_complete_irq: complete specified interrupt or exception
231
- * @s: the NVIC
232
- * @irq: the exception number to complete
233
- * @secure: true if this exception was secure
234
- *
235
- * Returns: -1 if the irq was not active
236
- * 1 if completing this irq brought us back to base (no active irqs)
237
- * 0 if there is still an irq active after this one was completed
238
- * (Ignoring -1, this is the same as the RETTOBASE value before completion.)
239
- */
240
-int armv7m_nvic_complete_irq(NVICState *s, int irq, bool secure);
241
-/**
242
- * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
243
- * @s: the NVIC
244
- * @irq: the exception number to mark pending
245
- * @secure: false for non-banked exceptions or for the nonsecure
246
- * version of a banked exception, true for the secure version of a banked
247
- * exception.
248
- *
249
- * Return whether an exception is "ready", i.e. whether the exception is
250
- * enabled and is configured at a priority which would allow it to
251
- * interrupt the current execution priority. This controls whether the
252
- * RDY bit for it in the FPCCR is set.
253
- */
254
-bool armv7m_nvic_get_ready_status(NVICState *s, int irq, bool secure);
255
-/**
256
- * armv7m_nvic_raw_execution_priority: return the raw execution priority
257
- * @s: the NVIC
258
- *
259
- * Returns: the raw execution priority as defined by the v8M architecture.
260
- * This is the execution priority minus the effects of AIRCR.PRIS,
261
- * and minus any PRIMASK/FAULTMASK/BASEPRI priority boosting.
262
- * (v8M ARM ARM I_PKLD.)
263
- */
264
-int armv7m_nvic_raw_execution_priority(NVICState *s);
265
-/**
266
- * armv7m_nvic_neg_prio_requested: return true if the requested execution
267
- * priority is negative for the specified security state.
268
- * @s: the NVIC
269
- * @secure: the security state to test
270
- * This corresponds to the pseudocode IsReqExecPriNeg().
271
- */
272
-#ifndef CONFIG_USER_ONLY
273
-bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure);
274
-#else
275
-static inline bool armv7m_nvic_neg_prio_requested(NVICState *s, bool secure)
276
-{
277
- return false;
278
-}
279
-#endif
280
-
281
/* Interface for defining coprocessor registers.
282
* Registers are defined in tables of arm_cp_reginfo structs
283
* which are passed to define_arm_cp_regs().
16
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
284
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
17
index XXXXXXX..XXXXXXX 100644
285
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/cpu.c
286
--- a/target/arm/cpu.c
19
+++ b/target/arm/cpu.c
287
+++ b/target/arm/cpu.c
20
@@ -XXX,XX +XXX,XX @@
288
@@ -XXX,XX +XXX,XX @@
21
#include "target/arm/idau.h"
289
#if !defined(CONFIG_USER_ONLY)
22
#include "qemu/error-report.h"
290
#include "hw/loader.h"
23
#include "qapi/error.h"
291
#include "hw/boards.h"
24
+#include "qapi/visitor.h"
292
+#ifdef CONFIG_TCG
25
#include "cpu.h"
293
#include "hw/intc/armv7m_nvic.h"
26
#include "internals.h"
294
-#endif
27
#include "qemu-common.h"
295
+#endif /* CONFIG_TCG */
28
@@ -XXX,XX +XXX,XX @@ static Property arm_cpu_pmsav7_dregion_property =
296
+#endif /* !CONFIG_USER_ONLY */
29
pmsav7_dregion,
297
#include "sysemu/tcg.h"
30
qdev_prop_uint32, uint32_t);
298
#include "sysemu/qtest.h"
31
299
#include "sysemu/hw_accel.h"
32
-/* M profile: initial value of the Secure VTOR */
300
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
33
-static Property arm_cpu_initsvtor_property =
301
index XXXXXXX..XXXXXXX 100644
34
- DEFINE_PROP_UINT32("init-svtor", ARMCPU, init_svtor, 0);
302
--- a/target/arm/cpu_tcg.c
35
+static void arm_get_init_svtor(Object *obj, Visitor *v, const char *name,
303
+++ b/target/arm/cpu_tcg.c
36
+ void *opaque, Error **errp)
304
@@ -XXX,XX +XXX,XX @@
37
+{
305
#include "hw/boards.h"
38
+ ARMCPU *cpu = ARM_CPU(obj);
306
#endif
39
+
307
#include "cpregs.h"
40
+ visit_type_uint32(v, name, &cpu->init_svtor, errp);
308
+#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
41
+}
309
+#include "hw/intc/armv7m_nvic.h"
42
+
310
+#endif
43
+static void arm_set_init_svtor(Object *obj, Visitor *v, const char *name,
311
44
+ void *opaque, Error **errp)
312
45
+{
313
/* Share AArch32 -cpu max features with AArch64. */
46
+ ARMCPU *cpu = ARM_CPU(obj);
314
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
47
+
315
index XXXXXXX..XXXXXXX 100644
48
+ visit_type_uint32(v, name, &cpu->init_svtor, errp);
316
--- a/target/arm/m_helper.c
49
+}
317
+++ b/target/arm/m_helper.c
50
318
@@ -XXX,XX +XXX,XX @@
51
void arm_cpu_post_init(Object *obj)
319
#include "exec/cpu_ldst.h"
52
{
320
#include "semihosting/common-semi.h"
53
@@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj)
321
#endif
54
qdev_prop_allow_set_link_before_realize,
322
+#if !defined(CONFIG_USER_ONLY)
55
OBJ_PROP_LINK_STRONG,
323
+#include "hw/intc/armv7m_nvic.h"
56
&error_abort);
324
+#endif
57
- qdev_property_add_static(DEVICE(obj), &arm_cpu_initsvtor_property,
325
58
- &error_abort);
326
static void v7m_msr_xpsr(CPUARMState *env, uint32_t mask,
59
+ /*
327
uint32_t reg, uint32_t val)
60
+ * M profile: initial value of the Secure VTOR. We can't just use
61
+ * a simple DEFINE_PROP_UINT32 for this because we want to permit
62
+ * the property to be set after realize.
63
+ */
64
+ object_property_add(obj, "init-svtor", "uint32",
65
+ arm_get_init_svtor, arm_set_init_svtor,
66
+ NULL, NULL, &error_abort);
67
}
68
69
qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property,
70
--
328
--
71
2.20.1
329
2.34.1
72
330
73
331
diff view generated by jsdifflib
New patch
1
1
From: Alex Bennée <alex.bennee@linaro.org>
2
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
1
The SYSCTL block in the SSE-200 has some extra registers that
1
From: Mostafa Saleh <smostafa@google.com>
2
are not present in the IoTKit version. Add these registers
3
(as reads-as-written stubs), enabled by a new QOM property.
4
2
3
GBPA register can be used to globally abort all
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>
23
Reviewed-by: Eric Auger <eric.auger@redhat.com>
24
Message-id: 20230214094009.2445653-1-smostafa@google.com
25
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20190219125808.25174-7-peter.maydell@linaro.org
8
---
27
---
9
include/hw/misc/iotkit-sysctl.h | 20 +++
28
hw/arm/smmuv3-internal.h | 7 +++++++
10
hw/arm/armsse.c | 2 +
29
include/hw/arm/smmuv3.h | 1 +
11
hw/misc/iotkit-sysctl.c | 245 +++++++++++++++++++++++++++++++-
30
hw/arm/smmuv3.c | 43 +++++++++++++++++++++++++++++++++++++++-
12
3 files changed, 262 insertions(+), 5 deletions(-)
31
3 files changed, 50 insertions(+), 1 deletion(-)
13
32
14
diff --git a/include/hw/misc/iotkit-sysctl.h b/include/hw/misc/iotkit-sysctl.h
33
diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h
15
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
16
--- a/include/hw/misc/iotkit-sysctl.h
35
--- a/hw/arm/smmuv3-internal.h
17
+++ b/include/hw/misc/iotkit-sysctl.h
36
+++ b/hw/arm/smmuv3-internal.h
18
@@ -XXX,XX +XXX,XX @@
37
@@ -XXX,XX +XXX,XX @@ REG32(CR0ACK, 0x24)
19
* "system control register" blocks.
38
REG32(CR1, 0x28)
20
*
39
REG32(CR2, 0x2c)
21
* QEMU interface:
40
REG32(STATUSR, 0x40)
22
+ * + QOM property "SYS_VERSION": value of the SYS_VERSION register of the
41
+REG32(GBPA, 0x44)
23
+ * system information block of the SSE
42
+ FIELD(GBPA, ABORT, 20, 1)
24
+ * (used to identify whether to provide SSE-200-only registers)
43
+ FIELD(GBPA, UPDATE, 31, 1)
25
* + sysbus MMIO region 0: the system information register bank
26
* + sysbus MMIO region 1: the system control register bank
27
*/
28
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKitSysCtl {
29
uint32_t initsvtor0;
30
uint32_t cpuwait;
31
uint32_t wicctrl;
32
+ uint32_t scsecctrl;
33
+ uint32_t fclk_div;
34
+ uint32_t sysclk_div;
35
+ uint32_t clock_force;
36
+ uint32_t initsvtor1;
37
+ uint32_t nmi_enable;
38
+ uint32_t ewctrl;
39
+ uint32_t pdcm_pd_sys_sense;
40
+ uint32_t pdcm_pd_sram0_sense;
41
+ uint32_t pdcm_pd_sram1_sense;
42
+ uint32_t pdcm_pd_sram2_sense;
43
+ uint32_t pdcm_pd_sram3_sense;
44
+
44
+
45
+ /* Properties */
45
+/* Use incoming. */
46
+ uint32_t sys_version;
46
+#define SMMU_GBPA_RESET_VAL 0x1000
47
+
47
+
48
+ bool is_sse200;
48
REG32(IRQ_CTRL, 0x50)
49
} IoTKitSysCtl;
49
FIELD(IRQ_CTRL, GERROR_IRQEN, 0, 1)
50
50
FIELD(IRQ_CTRL, PRI_IRQEN, 1, 1)
51
#endif
51
diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h
52
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
53
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
54
--- a/hw/arm/armsse.c
53
--- a/include/hw/arm/smmuv3.h
55
+++ b/hw/arm/armsse.c
54
+++ b/include/hw/arm/smmuv3.h
56
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
55
@@ -XXX,XX +XXX,XX @@ struct SMMUv3State {
57
/* System information registers */
56
uint32_t cr[3];
58
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sysinfo), 0, 0x40020000);
57
uint32_t cr0ack;
59
/* System control registers */
58
uint32_t statusr;
60
+ object_property_set_int(OBJECT(&s->sysctl), info->sys_version,
59
+ uint32_t gbpa;
61
+ "SYS_VERSION", &err);
60
uint32_t irq_ctrl;
62
object_property_set_bool(OBJECT(&s->sysctl), true, "realized", &err);
61
uint32_t gerror;
63
if (err) {
62
uint32_t gerrorn;
64
error_propagate(errp, err);
63
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
65
diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c
66
index XXXXXXX..XXXXXXX 100644
64
index XXXXXXX..XXXXXXX 100644
67
--- a/hw/misc/iotkit-sysctl.c
65
--- a/hw/arm/smmuv3.c
68
+++ b/hw/misc/iotkit-sysctl.c
66
+++ b/hw/arm/smmuv3.c
69
@@ -XXX,XX +XXX,XX @@
67
@@ -XXX,XX +XXX,XX @@ static void smmuv3_init_regs(SMMUv3State *s)
70
*/
68
s->gerror = 0;
71
69
s->gerrorn = 0;
72
#include "qemu/osdep.h"
70
s->statusr = 0;
73
+#include "qemu/bitops.h"
71
+ s->gbpa = SMMU_GBPA_RESET_VAL;
74
#include "qemu/log.h"
72
}
75
#include "trace.h"
73
76
#include "qapi/error.h"
74
static int smmu_get_ste(SMMUv3State *s, dma_addr_t addr, STE *buf,
77
@@ -XXX,XX +XXX,XX @@
75
@@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
78
REG32(SECDBGSTAT, 0x0)
76
qemu_mutex_lock(&s->mutex);
79
REG32(SECDBGSET, 0x4)
77
80
REG32(SECDBGCLR, 0x8)
78
if (!smmu_enabled(s)) {
81
+REG32(SCSECCTRL, 0xc)
79
- status = SMMU_TRANS_DISABLE;
82
+REG32(FCLK_DIV, 0x10)
80
+ if (FIELD_EX32(s->gbpa, GBPA, ABORT)) {
83
+REG32(SYSCLK_DIV, 0x14)
81
+ status = SMMU_TRANS_ABORT;
84
+REG32(CLOCK_FORCE, 0x18)
82
+ } else {
85
REG32(RESET_SYNDROME, 0x100)
83
+ status = SMMU_TRANS_DISABLE;
86
REG32(RESET_MASK, 0x104)
87
REG32(SWRESET, 0x108)
88
FIELD(SWRESET, SWRESETREQ, 9, 1)
89
REG32(GRETREG, 0x10c)
90
REG32(INITSVTOR0, 0x110)
91
+REG32(INITSVTOR1, 0x114)
92
REG32(CPUWAIT, 0x118)
93
-REG32(BUSWAIT, 0x11c)
94
+REG32(NMI_ENABLE, 0x11c) /* BUSWAIT in IoTKit */
95
REG32(WICCTRL, 0x120)
96
+REG32(EWCTRL, 0x124)
97
+REG32(PDCM_PD_SYS_SENSE, 0x200)
98
+REG32(PDCM_PD_SRAM0_SENSE, 0x20c)
99
+REG32(PDCM_PD_SRAM1_SENSE, 0x210)
100
+REG32(PDCM_PD_SRAM2_SENSE, 0x214)
101
+REG32(PDCM_PD_SRAM3_SENSE, 0x218)
102
REG32(PID4, 0xfd0)
103
REG32(PID5, 0xfd4)
104
REG32(PID6, 0xfd8)
105
@@ -XXX,XX +XXX,XX @@ static uint64_t iotkit_sysctl_read(void *opaque, hwaddr offset,
106
case A_SECDBGSTAT:
107
r = s->secure_debug;
108
break;
109
+ case A_SCSECCTRL:
110
+ if (!s->is_sse200) {
111
+ goto bad_offset;
112
+ }
84
+ }
113
+ r = s->scsecctrl;
85
goto epilogue;
114
+ break;
86
}
115
+ case A_FCLK_DIV:
87
116
+ if (!s->is_sse200) {
88
@@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_writel(SMMUv3State *s, hwaddr offset,
117
+ goto bad_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;
118
+ }
100
+ }
119
+ r = s->fclk_div;
101
+ return MEMTX_OK;
120
+ break;
102
case A_STRTAB_BASE: /* 64b */
121
+ case A_SYSCLK_DIV:
103
s->strtab_base = deposit64(s->strtab_base, 0, 32, data);
122
+ if (!s->is_sse200) {
104
return MEMTX_OK;
123
+ goto bad_offset;
105
@@ -XXX,XX +XXX,XX @@ static MemTxResult smmu_readl(SMMUv3State *s, hwaddr offset,
124
+ }
106
case A_STATUSR:
125
+ r = s->sysclk_div;
107
*data = s->statusr;
126
+ break;
108
return MEMTX_OK;
127
+ case A_CLOCK_FORCE:
109
+ case A_GBPA:
128
+ if (!s->is_sse200) {
110
+ *data = s->gbpa;
129
+ goto bad_offset;
111
+ return MEMTX_OK;
130
+ }
112
case A_IRQ_CTRL:
131
+ r = s->clock_force;
113
case A_IRQ_CTRL_ACK:
132
+ break;
114
*data = s->irq_ctrl;
133
case A_RESET_SYNDROME:
115
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3_queue = {
134
r = s->reset_syndrome;
116
},
135
break;
117
};
136
@@ -XXX,XX +XXX,XX @@ static uint64_t iotkit_sysctl_read(void *opaque, hwaddr offset,
118
137
case A_INITSVTOR0:
119
+static bool smmuv3_gbpa_needed(void *opaque)
138
r = s->initsvtor0;
139
break;
140
+ case A_INITSVTOR1:
141
+ if (!s->is_sse200) {
142
+ goto bad_offset;
143
+ }
144
+ r = s->initsvtor1;
145
+ break;
146
case A_CPUWAIT:
147
r = s->cpuwait;
148
break;
149
- case A_BUSWAIT:
150
- /* In IoTKit BUSWAIT is reserved, R/O, zero */
151
- r = 0;
152
+ case A_NMI_ENABLE:
153
+ /* In IoTKit this is named BUSWAIT but is marked reserved, R/O, zero */
154
+ if (!s->is_sse200) {
155
+ r = 0;
156
+ break;
157
+ }
158
+ r = s->nmi_enable;
159
break;
160
case A_WICCTRL:
161
r = s->wicctrl;
162
break;
163
+ case A_EWCTRL:
164
+ if (!s->is_sse200) {
165
+ goto bad_offset;
166
+ }
167
+ r = s->ewctrl;
168
+ break;
169
+ case A_PDCM_PD_SYS_SENSE:
170
+ if (!s->is_sse200) {
171
+ goto bad_offset;
172
+ }
173
+ r = s->pdcm_pd_sys_sense;
174
+ break;
175
+ case A_PDCM_PD_SRAM0_SENSE:
176
+ if (!s->is_sse200) {
177
+ goto bad_offset;
178
+ }
179
+ r = s->pdcm_pd_sram0_sense;
180
+ break;
181
+ case A_PDCM_PD_SRAM1_SENSE:
182
+ if (!s->is_sse200) {
183
+ goto bad_offset;
184
+ }
185
+ r = s->pdcm_pd_sram1_sense;
186
+ break;
187
+ case A_PDCM_PD_SRAM2_SENSE:
188
+ if (!s->is_sse200) {
189
+ goto bad_offset;
190
+ }
191
+ r = s->pdcm_pd_sram2_sense;
192
+ break;
193
+ case A_PDCM_PD_SRAM3_SENSE:
194
+ if (!s->is_sse200) {
195
+ goto bad_offset;
196
+ }
197
+ r = s->pdcm_pd_sram3_sense;
198
+ break;
199
case A_PID4 ... A_CID3:
200
r = sysctl_id[(offset - A_PID4) / 4];
201
break;
202
@@ -XXX,XX +XXX,XX @@ static uint64_t iotkit_sysctl_read(void *opaque, hwaddr offset,
203
r = 0;
204
break;
205
default:
206
+ bad_offset:
207
qemu_log_mask(LOG_GUEST_ERROR,
208
"IoTKit SysCtl read: bad offset %x\n", (int)offset);
209
r = 0;
210
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_write(void *opaque, hwaddr offset,
211
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
212
}
213
break;
214
- case A_BUSWAIT: /* In IoTKit BUSWAIT is reserved, R/O, zero */
215
+ case A_SCSECCTRL:
216
+ if (!s->is_sse200) {
217
+ goto bad_offset;
218
+ }
219
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl SCSECCTRL unimplemented\n");
220
+ s->scsecctrl = value;
221
+ break;
222
+ case A_FCLK_DIV:
223
+ if (!s->is_sse200) {
224
+ goto bad_offset;
225
+ }
226
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl FCLK_DIV unimplemented\n");
227
+ s->fclk_div = value;
228
+ break;
229
+ case A_SYSCLK_DIV:
230
+ if (!s->is_sse200) {
231
+ goto bad_offset;
232
+ }
233
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl SYSCLK_DIV unimplemented\n");
234
+ s->sysclk_div = value;
235
+ break;
236
+ case A_CLOCK_FORCE:
237
+ if (!s->is_sse200) {
238
+ goto bad_offset;
239
+ }
240
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl CLOCK_FORCE unimplemented\n");
241
+ s->clock_force = value;
242
+ break;
243
+ case A_INITSVTOR1:
244
+ if (!s->is_sse200) {
245
+ goto bad_offset;
246
+ }
247
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl INITSVTOR1 unimplemented\n");
248
+ s->initsvtor1 = value;
249
+ break;
250
+ case A_EWCTRL:
251
+ if (!s->is_sse200) {
252
+ goto bad_offset;
253
+ }
254
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl EWCTRL unimplemented\n");
255
+ s->ewctrl = value;
256
+ break;
257
+ case A_PDCM_PD_SYS_SENSE:
258
+ if (!s->is_sse200) {
259
+ goto bad_offset;
260
+ }
261
+ qemu_log_mask(LOG_UNIMP,
262
+ "IoTKit SysCtl PDCM_PD_SYS_SENSE unimplemented\n");
263
+ s->pdcm_pd_sys_sense = value;
264
+ break;
265
+ case A_PDCM_PD_SRAM0_SENSE:
266
+ if (!s->is_sse200) {
267
+ goto bad_offset;
268
+ }
269
+ qemu_log_mask(LOG_UNIMP,
270
+ "IoTKit SysCtl PDCM_PD_SRAM0_SENSE unimplemented\n");
271
+ s->pdcm_pd_sram0_sense = value;
272
+ break;
273
+ case A_PDCM_PD_SRAM1_SENSE:
274
+ if (!s->is_sse200) {
275
+ goto bad_offset;
276
+ }
277
+ qemu_log_mask(LOG_UNIMP,
278
+ "IoTKit SysCtl PDCM_PD_SRAM1_SENSE unimplemented\n");
279
+ s->pdcm_pd_sram1_sense = value;
280
+ break;
281
+ case A_PDCM_PD_SRAM2_SENSE:
282
+ if (!s->is_sse200) {
283
+ goto bad_offset;
284
+ }
285
+ qemu_log_mask(LOG_UNIMP,
286
+ "IoTKit SysCtl PDCM_PD_SRAM2_SENSE unimplemented\n");
287
+ s->pdcm_pd_sram2_sense = value;
288
+ break;
289
+ case A_PDCM_PD_SRAM3_SENSE:
290
+ if (!s->is_sse200) {
291
+ goto bad_offset;
292
+ }
293
+ qemu_log_mask(LOG_UNIMP,
294
+ "IoTKit SysCtl PDCM_PD_SRAM3_SENSE unimplemented\n");
295
+ s->pdcm_pd_sram3_sense = value;
296
+ break;
297
+ case A_NMI_ENABLE:
298
+ /* In IoTKit this is BUSWAIT: reserved, R/O, zero */
299
+ if (!s->is_sse200) {
300
+ goto ro_offset;
301
+ }
302
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl NMI_ENABLE unimplemented\n");
303
+ s->nmi_enable = value;
304
+ break;
305
case A_SECDBGSTAT:
306
case A_PID4 ... A_CID3:
307
+ ro_offset:
308
qemu_log_mask(LOG_GUEST_ERROR,
309
"IoTKit SysCtl write: write of RO offset %x\n",
310
(int)offset);
311
break;
312
default:
313
+ bad_offset:
314
qemu_log_mask(LOG_GUEST_ERROR,
315
"IoTKit SysCtl write: bad offset %x\n", (int)offset);
316
break;
317
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_reset(DeviceState *dev)
318
s->reset_mask = 0;
319
s->gretreg = 0;
320
s->initsvtor0 = 0x10000000;
321
+ s->initsvtor1 = 0x10000000;
322
s->cpuwait = 0;
323
s->wicctrl = 0;
324
+ s->scsecctrl = 0;
325
+ s->fclk_div = 0;
326
+ s->sysclk_div = 0;
327
+ s->clock_force = 0;
328
+ s->nmi_enable = 0;
329
+ s->ewctrl = 0;
330
+ s->pdcm_pd_sys_sense = 0x7f;
331
+ s->pdcm_pd_sram0_sense = 0;
332
+ s->pdcm_pd_sram1_sense = 0;
333
+ s->pdcm_pd_sram2_sense = 0;
334
+ s->pdcm_pd_sram3_sense = 0;
335
}
336
337
static void iotkit_sysctl_init(Object *obj)
338
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_init(Object *obj)
339
sysbus_init_mmio(sbd, &s->iomem);
340
}
341
342
+static void iotkit_sysctl_realize(DeviceState *dev, Error **errp)
343
+{
120
+{
344
+ IoTKitSysCtl *s = IOTKIT_SYSCTL(dev);
121
+ SMMUv3State *s = opaque;
345
+
122
+
346
+ /* The top 4 bits of the SYS_VERSION register tell us if we're an SSE-200 */
123
+ /* Only migrate GBPA if it has different reset value. */
347
+ if (extract32(s->sys_version, 28, 4) == 2) {
124
+ return s->gbpa != SMMU_GBPA_RESET_VAL;
348
+ s->is_sse200 = true;
349
+ }
350
+}
125
+}
351
+
126
+
352
+static bool sse200_needed(void *opaque)
127
+static const VMStateDescription vmstate_gbpa = {
353
+{
128
+ .name = "smmuv3/gbpa",
354
+ IoTKitSysCtl *s = IOTKIT_SYSCTL(opaque);
355
+
356
+ return s->is_sse200;
357
+}
358
+
359
+static const VMStateDescription iotkit_sysctl_sse200_vmstate = {
360
+ .name = "iotkit-sysctl/sse-200",
361
+ .version_id = 1,
129
+ .version_id = 1,
362
+ .minimum_version_id = 1,
130
+ .minimum_version_id = 1,
363
+ .needed = sse200_needed,
131
+ .needed = smmuv3_gbpa_needed,
364
+ .fields = (VMStateField[]) {
132
+ .fields = (VMStateField[]) {
365
+ VMSTATE_UINT32(scsecctrl, IoTKitSysCtl),
133
+ VMSTATE_UINT32(gbpa, SMMUv3State),
366
+ VMSTATE_UINT32(fclk_div, IoTKitSysCtl),
367
+ VMSTATE_UINT32(sysclk_div, IoTKitSysCtl),
368
+ VMSTATE_UINT32(clock_force, IoTKitSysCtl),
369
+ VMSTATE_UINT32(initsvtor1, IoTKitSysCtl),
370
+ VMSTATE_UINT32(nmi_enable, IoTKitSysCtl),
371
+ VMSTATE_UINT32(pdcm_pd_sys_sense, IoTKitSysCtl),
372
+ VMSTATE_UINT32(pdcm_pd_sram0_sense, IoTKitSysCtl),
373
+ VMSTATE_UINT32(pdcm_pd_sram1_sense, IoTKitSysCtl),
374
+ VMSTATE_UINT32(pdcm_pd_sram2_sense, IoTKitSysCtl),
375
+ VMSTATE_UINT32(pdcm_pd_sram3_sense, IoTKitSysCtl),
376
+ VMSTATE_END_OF_LIST()
134
+ VMSTATE_END_OF_LIST()
377
+ }
135
+ }
378
+};
136
+};
379
+
137
+
380
static const VMStateDescription iotkit_sysctl_vmstate = {
138
static const VMStateDescription vmstate_smmuv3 = {
381
.name = "iotkit-sysctl",
139
.name = "smmuv3",
382
.version_id = 1,
140
.version_id = 1,
383
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription iotkit_sysctl_vmstate = {
141
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3 = {
384
VMSTATE_UINT32(cpuwait, IoTKitSysCtl),
142
385
VMSTATE_UINT32(wicctrl, IoTKitSysCtl),
143
VMSTATE_END_OF_LIST(),
386
VMSTATE_END_OF_LIST()
144
},
387
+ },
145
+ .subsections = (const VMStateDescription * []) {
388
+ .subsections = (const VMStateDescription*[]) {
146
+ &vmstate_gbpa,
389
+ &iotkit_sysctl_sse200_vmstate,
390
+ NULL
147
+ NULL
391
}
148
+ }
392
};
149
};
393
150
394
+static Property iotkit_sysctl_props[] = {
151
static void smmuv3_instance_init(Object *obj)
395
+ DEFINE_PROP_UINT32("SYS_VERSION", IoTKitSysCtl, sys_version, 0),
396
+ DEFINE_PROP_END_OF_LIST()
397
+};
398
+
399
static void iotkit_sysctl_class_init(ObjectClass *klass, void *data)
400
{
401
DeviceClass *dc = DEVICE_CLASS(klass);
402
403
dc->vmsd = &iotkit_sysctl_vmstate;
404
dc->reset = iotkit_sysctl_reset;
405
+ dc->props = iotkit_sysctl_props;
406
+ dc->realize = iotkit_sysctl_realize;
407
}
408
409
static const TypeInfo iotkit_sysctl_info = {
410
--
152
--
411
2.20.1
153
2.34.1
412
413
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
2
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
New patch
1
From: Cornelia Huck <cohuck@redhat.com>
1
2
3
Just use current_accel_name() directly.
4
5
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
6
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
hw/arm/virt.c | 6 +++---
11
1 file changed, 3 insertions(+), 3 deletions(-)
12
13
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/virt.c
16
+++ b/hw/arm/virt.c
17
@@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine)
18
if (vms->secure && (kvm_enabled() || hvf_enabled())) {
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
}
25
26
if (vms->virt && (kvm_enabled() || hvf_enabled())) {
27
error_report("mach-virt: %s does not support providing "
28
"Virtualization extensions to the guest CPU",
29
- kvm_enabled() ? "KVM" : "HVF");
30
+ current_accel_name());
31
exit(1);
32
}
33
34
if (vms->mte && (kvm_enabled() || hvf_enabled())) {
35
error_report("mach-virt: %s does not support providing "
36
"MTE to the guest CPU",
37
- kvm_enabled() ? "KVM" : "HVF");
38
+ current_accel_name());
39
exit(1);
40
}
41
42
--
43
2.34.1
diff view generated by jsdifflib
New patch
1
From: Hao Wu <wuhaotsh@google.com>
1
2
3
Havard is no longer working on the Nuvoton systems for a while
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
7
Signed-off-by: Hao Wu <wuhaotsh@google.com>
8
Acked-by: Havard Skinnemoen <hskinnemoen@google.com>
9
Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org>
10
Message-id: 20230208235433.3989937-2-wuhaotsh@google.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
MAINTAINERS | 2 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
15
16
diff --git a/MAINTAINERS b/MAINTAINERS
17
index XXXXXXX..XXXXXXX 100644
18
--- a/MAINTAINERS
19
+++ b/MAINTAINERS
20
@@ -XXX,XX +XXX,XX @@ F: include/hw/net/mv88w8618_eth.h
21
F: docs/system/arm/musicpal.rst
22
23
Nuvoton NPCM7xx
24
-M: Havard Skinnemoen <hskinnemoen@google.com>
25
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
--
31
2.34.1
diff view generated by jsdifflib
1
Implement a model of the Message Handling Unit (MHU) found in
1
From: Hao Wu <wuhaotsh@google.com>
2
the Arm SSE-200. This is a simple device which just contains
3
some registers which allow the two cores of the SSE-200
4
to raise interrupts on each other.
5
2
3
Nuvoton's PSPI is a general purpose SPI module which enables
4
connections to SPI-based peripheral devices.
5
6
Signed-off-by: Hao Wu <wuhaotsh@google.com>
7
Reviewed-by: Chris Rauer <crauer@google.com>
8
Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org>
9
Message-id: 20230208235433.3989937-3-wuhaotsh@google.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190219125808.25174-2-peter.maydell@linaro.org
9
---
11
---
10
hw/misc/Makefile.objs | 1 +
12
MAINTAINERS | 6 +-
11
include/hw/misc/armsse-mhu.h | 44 +++++++
13
include/hw/ssi/npcm_pspi.h | 53 +++++++++
12
hw/misc/armsse-mhu.c | 198 ++++++++++++++++++++++++++++++++
14
hw/ssi/npcm_pspi.c | 221 +++++++++++++++++++++++++++++++++++++
13
MAINTAINERS | 2 +
15
hw/ssi/meson.build | 2 +-
14
default-configs/arm-softmmu.mak | 1 +
16
hw/ssi/trace-events | 5 +
15
hw/misc/trace-events | 4 +
17
5 files changed, 283 insertions(+), 4 deletions(-)
16
6 files changed, 250 insertions(+)
18
create mode 100644 include/hw/ssi/npcm_pspi.h
17
create mode 100644 include/hw/misc/armsse-mhu.h
19
create mode 100644 hw/ssi/npcm_pspi.c
18
create mode 100644 hw/misc/armsse-mhu.c
19
20
20
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
21
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/misc/Makefile.objs
23
+++ b/hw/misc/Makefile.objs
24
@@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_IOTKIT_SECCTL) += iotkit-secctl.o
25
obj-$(CONFIG_IOTKIT_SYSCTL) += iotkit-sysctl.o
26
obj-$(CONFIG_IOTKIT_SYSINFO) += iotkit-sysinfo.o
27
obj-$(CONFIG_ARMSSE_CPUID) += armsse-cpuid.o
28
+obj-$(CONFIG_ARMSSE_MHU) += armsse-mhu.o
29
30
obj-$(CONFIG_PVPANIC) += pvpanic.o
31
obj-$(CONFIG_AUX) += auxbus.o
32
diff --git a/include/hw/misc/armsse-mhu.h b/include/hw/misc/armsse-mhu.h
33
new file mode 100644
34
index XXXXXXX..XXXXXXX
35
--- /dev/null
36
+++ b/include/hw/misc/armsse-mhu.h
37
@@ -XXX,XX +XXX,XX @@
38
+/*
39
+ * ARM SSE-200 Message Handling Unit (MHU)
40
+ *
41
+ * Copyright (c) 2019 Linaro Limited
42
+ * Written by Peter Maydell
43
+ *
44
+ * This program is free software; you can redistribute it and/or modify
45
+ * it under the terms of the GNU General Public License version 2 or
46
+ * (at your option) any later version.
47
+ */
48
+
49
+/*
50
+ * This is a model of the Message Handling Unit (MHU) which is part of the
51
+ * Arm SSE-200 and documented in
52
+ * http://infocenter.arm.com/help/topic/com.arm.doc.101104_0100_00_en/corelink_sse200_subsystem_for_embedded_technical_reference_manual_101104_0100_00_en.pdf
53
+ *
54
+ * QEMU interface:
55
+ * + sysbus MMIO region 0: the system information register bank
56
+ * + sysbus IRQ 0: interrupt for CPU 0
57
+ * + sysbus IRQ 1: interrupt for CPU 1
58
+ */
59
+
60
+#ifndef HW_MISC_SSE_MHU_H
61
+#define HW_MISC_SSE_MHU_H
62
+
63
+#include "hw/sysbus.h"
64
+
65
+#define TYPE_ARMSSE_MHU "armsse-mhu"
66
+#define ARMSSE_MHU(obj) OBJECT_CHECK(ARMSSEMHU, (obj), TYPE_ARMSSE_MHU)
67
+
68
+typedef struct ARMSSEMHU {
69
+ /*< private >*/
70
+ SysBusDevice parent_obj;
71
+
72
+ /*< public >*/
73
+ MemoryRegion iomem;
74
+ qemu_irq cpu0irq;
75
+ qemu_irq cpu1irq;
76
+
77
+ uint32_t cpu0intr;
78
+ uint32_t cpu1intr;
79
+} ARMSSEMHU;
80
+
81
+#endif
82
diff --git a/hw/misc/armsse-mhu.c b/hw/misc/armsse-mhu.c
83
new file mode 100644
84
index XXXXXXX..XXXXXXX
85
--- /dev/null
86
+++ b/hw/misc/armsse-mhu.c
87
@@ -XXX,XX +XXX,XX @@
88
+/*
89
+ * ARM SSE-200 Message Handling Unit (MHU)
90
+ *
91
+ * Copyright (c) 2019 Linaro Limited
92
+ * Written by Peter Maydell
93
+ *
94
+ * This program is free software; you can redistribute it and/or modify
95
+ * it under the terms of the GNU General Public License version 2 or
96
+ * (at your option) any later version.
97
+ */
98
+
99
+/*
100
+ * This is a model of the Message Handling Unit (MHU) which is part of the
101
+ * Arm SSE-200 and documented in
102
+ * http://infocenter.arm.com/help/topic/com.arm.doc.101104_0100_00_en/corelink_sse200_subsystem_for_embedded_technical_reference_manual_101104_0100_00_en.pdf
103
+ */
104
+
105
+#include "qemu/osdep.h"
106
+#include "qemu/log.h"
107
+#include "trace.h"
108
+#include "qapi/error.h"
109
+#include "sysemu/sysemu.h"
110
+#include "hw/sysbus.h"
111
+#include "hw/registerfields.h"
112
+#include "hw/misc/armsse-mhu.h"
113
+
114
+REG32(CPU0INTR_STAT, 0x0)
115
+REG32(CPU0INTR_SET, 0x4)
116
+REG32(CPU0INTR_CLR, 0x8)
117
+REG32(CPU1INTR_STAT, 0x10)
118
+REG32(CPU1INTR_SET, 0x14)
119
+REG32(CPU1INTR_CLR, 0x18)
120
+REG32(PID4, 0xfd0)
121
+REG32(PID5, 0xfd4)
122
+REG32(PID6, 0xfd8)
123
+REG32(PID7, 0xfdc)
124
+REG32(PID0, 0xfe0)
125
+REG32(PID1, 0xfe4)
126
+REG32(PID2, 0xfe8)
127
+REG32(PID3, 0xfec)
128
+REG32(CID0, 0xff0)
129
+REG32(CID1, 0xff4)
130
+REG32(CID2, 0xff8)
131
+REG32(CID3, 0xffc)
132
+
133
+/* Valid bits in the interrupt registers. If any are set the IRQ is raised */
134
+#define INTR_MASK 0xf
135
+
136
+/* PID/CID values */
137
+static const int armsse_mhu_id[] = {
138
+ 0x04, 0x00, 0x00, 0x00, /* PID4..PID7 */
139
+ 0x56, 0xb8, 0x0b, 0x00, /* PID0..PID3 */
140
+ 0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
141
+};
142
+
143
+static void armsse_mhu_update(ARMSSEMHU *s)
144
+{
145
+ qemu_set_irq(s->cpu0irq, s->cpu0intr != 0);
146
+ qemu_set_irq(s->cpu1irq, s->cpu1intr != 0);
147
+}
148
+
149
+static uint64_t armsse_mhu_read(void *opaque, hwaddr offset, unsigned size)
150
+{
151
+ ARMSSEMHU *s = ARMSSE_MHU(opaque);
152
+ uint64_t r;
153
+
154
+ switch (offset) {
155
+ case A_CPU0INTR_STAT:
156
+ r = s->cpu0intr;
157
+ break;
158
+
159
+ case A_CPU1INTR_STAT:
160
+ r = s->cpu1intr;
161
+ break;
162
+
163
+ case A_PID4 ... A_CID3:
164
+ r = armsse_mhu_id[(offset - A_PID4) / 4];
165
+ break;
166
+
167
+ case A_CPU0INTR_SET:
168
+ case A_CPU0INTR_CLR:
169
+ case A_CPU1INTR_SET:
170
+ case A_CPU1INTR_CLR:
171
+ qemu_log_mask(LOG_GUEST_ERROR,
172
+ "SSE MHU: read of write-only register at offset 0x%x\n",
173
+ (int)offset);
174
+ r = 0;
175
+ break;
176
+
177
+ default:
178
+ qemu_log_mask(LOG_GUEST_ERROR,
179
+ "SSE MHU read: bad offset 0x%x\n", (int)offset);
180
+ r = 0;
181
+ break;
182
+ }
183
+ trace_armsse_mhu_read(offset, r, size);
184
+ return r;
185
+}
186
+
187
+static void armsse_mhu_write(void *opaque, hwaddr offset,
188
+ uint64_t value, unsigned size)
189
+{
190
+ ARMSSEMHU *s = ARMSSE_MHU(opaque);
191
+
192
+ trace_armsse_mhu_write(offset, value, size);
193
+
194
+ switch (offset) {
195
+ case A_CPU0INTR_SET:
196
+ s->cpu0intr |= (value & INTR_MASK);
197
+ break;
198
+ case A_CPU0INTR_CLR:
199
+ s->cpu0intr &= ~(value & INTR_MASK);
200
+ break;
201
+ case A_CPU1INTR_SET:
202
+ s->cpu1intr |= (value & INTR_MASK);
203
+ break;
204
+ case A_CPU1INTR_CLR:
205
+ s->cpu1intr &= ~(value & INTR_MASK);
206
+ break;
207
+
208
+ case A_CPU0INTR_STAT:
209
+ case A_CPU1INTR_STAT:
210
+ case A_PID4 ... A_CID3:
211
+ qemu_log_mask(LOG_GUEST_ERROR,
212
+ "SSE MHU: write to read-only register at offset 0x%x\n",
213
+ (int)offset);
214
+ break;
215
+
216
+ default:
217
+ qemu_log_mask(LOG_GUEST_ERROR,
218
+ "SSE MHU write: bad offset 0x%x\n", (int)offset);
219
+ break;
220
+ }
221
+
222
+ armsse_mhu_update(s);
223
+}
224
+
225
+static const MemoryRegionOps armsse_mhu_ops = {
226
+ .read = armsse_mhu_read,
227
+ .write = armsse_mhu_write,
228
+ .endianness = DEVICE_LITTLE_ENDIAN,
229
+ .valid.min_access_size = 4,
230
+ .valid.max_access_size = 4,
231
+};
232
+
233
+static void armsse_mhu_reset(DeviceState *dev)
234
+{
235
+ ARMSSEMHU *s = ARMSSE_MHU(dev);
236
+
237
+ s->cpu0intr = 0;
238
+ s->cpu1intr = 0;
239
+}
240
+
241
+static const VMStateDescription armsse_mhu_vmstate = {
242
+ .name = "armsse-mhu",
243
+ .version_id = 1,
244
+ .minimum_version_id = 1,
245
+ .fields = (VMStateField[]) {
246
+ VMSTATE_UINT32(cpu0intr, ARMSSEMHU),
247
+ VMSTATE_UINT32(cpu1intr, ARMSSEMHU),
248
+ VMSTATE_END_OF_LIST()
249
+ },
250
+};
251
+
252
+static void armsse_mhu_init(Object *obj)
253
+{
254
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
255
+ ARMSSEMHU *s = ARMSSE_MHU(obj);
256
+
257
+ memory_region_init_io(&s->iomem, obj, &armsse_mhu_ops,
258
+ s, "armsse-mhu", 0x1000);
259
+ sysbus_init_mmio(sbd, &s->iomem);
260
+ sysbus_init_irq(sbd, &s->cpu0irq);
261
+ sysbus_init_irq(sbd, &s->cpu1irq);
262
+}
263
+
264
+static void armsse_mhu_class_init(ObjectClass *klass, void *data)
265
+{
266
+ DeviceClass *dc = DEVICE_CLASS(klass);
267
+
268
+ dc->reset = armsse_mhu_reset;
269
+ dc->vmsd = &armsse_mhu_vmstate;
270
+}
271
+
272
+static const TypeInfo armsse_mhu_info = {
273
+ .name = TYPE_ARMSSE_MHU,
274
+ .parent = TYPE_SYS_BUS_DEVICE,
275
+ .instance_size = sizeof(ARMSSEMHU),
276
+ .instance_init = armsse_mhu_init,
277
+ .class_init = armsse_mhu_class_init,
278
+};
279
+
280
+static void armsse_mhu_register_types(void)
281
+{
282
+ type_register_static(&armsse_mhu_info);
283
+}
284
+
285
+type_init(armsse_mhu_register_types);
286
diff --git a/MAINTAINERS b/MAINTAINERS
21
diff --git a/MAINTAINERS b/MAINTAINERS
287
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
288
--- a/MAINTAINERS
23
--- a/MAINTAINERS
289
+++ b/MAINTAINERS
24
+++ b/MAINTAINERS
290
@@ -XXX,XX +XXX,XX @@ F: hw/misc/iotkit-sysinfo.c
25
@@ -XXX,XX +XXX,XX @@ M: Tyrone Ting <kfting@nuvoton.com>
291
F: include/hw/misc/iotkit-sysinfo.h
26
M: Hao Wu <wuhaotsh@google.com>
292
F: hw/misc/armsse-cpuid.c
27
L: qemu-arm@nongnu.org
293
F: include/hw/misc/armsse-cpuid.h
28
S: Supported
294
+F: hw/misc/armsse-mhu.c
29
-F: hw/*/npcm7xx*
295
+F: include/hw/misc/armsse-mhu.h
30
-F: include/hw/*/npcm7xx*
296
31
-F: tests/qtest/npcm7xx*
297
Musca
32
+F: hw/*/npcm*
298
M: Peter Maydell <peter.maydell@linaro.org>
33
+F: include/hw/*/npcm*
299
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
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
40
index XXXXXXX..XXXXXXX
41
--- /dev/null
42
+++ b/include/hw/ssi/npcm_pspi.h
43
@@ -XXX,XX +XXX,XX @@
44
+/*
45
+ * Nuvoton Peripheral SPI Module
46
+ *
47
+ * Copyright 2023 Google LLC
48
+ *
49
+ * 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
51
+ * Free Software Foundation; either version 2 of the License, or
52
+ * (at your option) any later version.
53
+ *
54
+ * This program is distributed in the hope that it will be useful, but WITHOUT
55
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
56
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
57
+ * for 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
+ *
79
+ * Each PSPI has a shared bank of registers, and controls up to four chip
80
+ * selects. Each chip select has a dedicated memory region which may be used to
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
+ *
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
+ */
118
+
119
+#include "qemu/osdep.h"
120
+
121
+#include "hw/irq.h"
122
+#include "hw/registerfields.h"
123
+#include "hw/ssi/npcm_pspi.h"
124
+#include "migration/vmstate.h"
125
+#include "qapi/error.h"
126
+#include "qemu/error-report.h"
127
+#include "qemu/log.h"
128
+#include "qemu/module.h"
129
+#include "qemu/units.h"
130
+
131
+#include "trace.h"
132
+
133
+REG16(PSPI_DATA, 0x0)
134
+REG16(PSPI_CTL1, 0x2)
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
300
index XXXXXXX..XXXXXXX 100644
325
index XXXXXXX..XXXXXXX 100644
301
--- a/default-configs/arm-softmmu.mak
326
--- a/hw/ssi/meson.build
302
+++ b/default-configs/arm-softmmu.mak
327
+++ b/hw/ssi/meson.build
303
@@ -XXX,XX +XXX,XX @@ CONFIG_IOTKIT_SECCTL=y
328
@@ -XXX,XX +XXX,XX @@
304
CONFIG_IOTKIT_SYSCTL=y
329
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_smc.c'))
305
CONFIG_IOTKIT_SYSINFO=y
330
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-spi.c'))
306
CONFIG_ARMSSE_CPUID=y
331
-softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c'))
307
+CONFIG_ARMSSE_MHU=y
332
+softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c', 'npcm_pspi.c'))
308
333
softmmu_ss.add(when: 'CONFIG_PL022', if_true: files('pl022.c'))
309
CONFIG_VERSATILE=y
334
softmmu_ss.add(when: 'CONFIG_SIFIVE_SPI', if_true: files('sifive_spi.c'))
310
CONFIG_VERSATILE_PCI=y
335
softmmu_ss.add(when: 'CONFIG_SSI', if_true: files('ssi.c'))
311
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
336
diff --git a/hw/ssi/trace-events b/hw/ssi/trace-events
312
index XXXXXXX..XXXXXXX 100644
337
index XXXXXXX..XXXXXXX 100644
313
--- a/hw/misc/trace-events
338
--- a/hw/ssi/trace-events
314
+++ b/hw/misc/trace-events
339
+++ b/hw/ssi/trace-events
315
@@ -XXX,XX +XXX,XX @@ iotkit_sysctl_reset(void) "IoTKit SysCtl: reset"
340
@@ -XXX,XX +XXX,XX @@ npcm7xx_fiu_ctrl_write(const char *id, uint64_t addr, uint32_t data) "%s offset:
316
# hw/misc/armsse-cpuid.c
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
317
armsse_cpuid_read(uint64_t offset, uint64_t data, unsigned size) "SSE-200 CPU_IDENTITY read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
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
318
armsse_cpuid_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 CPU_IDENTITY write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
343
319
+
344
+# npcm_pspi.c
320
+# hw/misc/armsse-mhu.c
345
+npcm_pspi_enter_reset(const char *id, int reset_type) "%s reset type: %d"
321
+armsse_mhu_read(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
346
+npcm_pspi_ctrl_read(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16
322
+armsse_mhu_write(uint64_t offset, uint64_t data, unsigned size) "SSE-200 MHU write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
347
+npcm_pspi_ctrl_write(const char *id, uint64_t addr, uint16_t data) "%s offset: 0x%03" PRIx64 " value: 0x%04" PRIx16
348
+
349
# ibex_spi_host.c
350
351
ibex_spi_host_reset(const char *msg) "%s"
323
--
352
--
324
2.20.1
353
2.34.1
325
326
diff view generated by jsdifflib
New patch
1
From: Hao Wu <wuhaotsh@google.com>
1
2
3
Signed-off-by: Hao Wu <wuhaotsh@google.com>
4
Reviewed-by: Titus Rwantare <titusr@google.com>
5
Reviewed-by: Philippe Mathieu-Daude <philmd@linaro.org>
6
Message-id: 20230208235433.3989937-4-wuhaotsh@google.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
docs/system/arm/nuvoton.rst | 2 +-
10
include/hw/arm/npcm7xx.h | 2 ++
11
hw/arm/npcm7xx.c | 25 +++++++++++++++++++++++--
12
3 files changed, 26 insertions(+), 3 deletions(-)
13
14
diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst
15
index XXXXXXX..XXXXXXX 100644
16
--- a/docs/system/arm/nuvoton.rst
17
+++ b/docs/system/arm/nuvoton.rst
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 @@
39
#include "hw/nvram/npcm7xx_otp.h"
40
#include "hw/timer/npcm7xx_timer.h"
41
#include "hw/ssi/npcm7xx_fiu.h"
42
+#include "hw/ssi/npcm_pspi.h"
43
#include "hw/usb/hcd-ehci.h"
44
#include "hw/usb/hcd-ohci.h"
45
#include "target/arm/cpu.h"
46
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxState {
47
NPCM7xxFIUState fiu[2];
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
}
90
91
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
92
sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc), 0,
93
npcm7xx_irq(s, NPCM7XX_MMC_IRQ));
94
95
+ /* PSPI */
96
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_pspi_addr) != ARRAY_SIZE(s->pspi));
97
+ for (i = 0; i < ARRAY_SIZE(s->pspi); i++) {
98
+ SysBusDevice *sbd = SYS_BUS_DEVICE(&s->pspi[i]);
99
+ int irq = (i == 0) ? NPCM7XX_PSPI1_IRQ : NPCM7XX_PSPI2_IRQ;
100
+
101
+ sysbus_realize(sbd, &error_abort);
102
+ sysbus_mmio_map(sbd, 0, npcm7xx_pspi_addr[i]);
103
+ sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, irq));
104
+ }
105
+
106
create_unimplemented_device("npcm7xx.shm", 0xc0001000, 4 * KiB);
107
create_unimplemented_device("npcm7xx.vdmx", 0xe0800000, 4 * KiB);
108
create_unimplemented_device("npcm7xx.pcierc", 0xe1000000, 64 * KiB);
109
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
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
--
119
2.34.1
diff view generated by jsdifflib
New patch
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
1
2
3
Addresses targeting the second translation table (TTB1) in the SMMU have
4
all upper bits set. Ensure the IOMMU region covers all 64 bits.
5
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Message-id: 20230214171921.1917916-2-jean-philippe@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
include/hw/arm/smmu-common.h | 2 --
13
hw/arm/smmu-common.c | 2 +-
14
2 files changed, 1 insertion(+), 3 deletions(-)
15
16
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/smmu-common.h
19
+++ b/include/hw/arm/smmu-common.h
20
@@ -XXX,XX +XXX,XX @@
21
#define SMMU_PCI_DEVFN_MAX 256
22
#define SMMU_PCI_DEVFN(sid) (sid & 0xFF)
23
24
-#define SMMU_MAX_VA_BITS 48
25
-
26
/*
27
* Page table walk error types
28
*/
29
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/arm/smmu-common.c
32
+++ b/hw/arm/smmu-common.c
33
@@ -XXX,XX +XXX,XX @@ static AddressSpace *smmu_find_add_as(PCIBus *bus, void *opaque, int devfn)
34
35
memory_region_init_iommu(&sdev->iommu, sizeof(sdev->iommu),
36
s->mrtypename,
37
- OBJECT(s), name, 1ULL << SMMU_MAX_VA_BITS);
38
+ OBJECT(s), name, UINT64_MAX);
39
address_space_init(&sdev->as,
40
MEMORY_REGION(&sdev->iommu), name);
41
trace_smmu_add_mr(name);
42
--
43
2.34.1
diff view generated by jsdifflib
New patch
1
From: Jean-Philippe Brucker <jean-philippe@linaro.org>
1
2
3
Addresses targeting the second translation table (TTB1) in the SMMU have
4
all upper bits set (except for the top byte when TBI is enabled). Fix
5
the TTB1 check.
6
7
Reported-by: Ola Hugosson <ola.hugosson@arm.com>
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
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>
13
---
14
hw/arm/smmu-common.c | 2 +-
15
1 file changed, 1 insertion(+), 1 deletion(-)
16
17
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/smmu-common.c
20
+++ b/hw/arm/smmu-common.c
21
@@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova)
22
/* there is a ttbr0 region and we are in it (high bits all zero) */
23
return &cfg->tt[0];
24
} else if (cfg->tt[1].tsz &&
25
- !extract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte)) {
26
+ sextract64(iova, 64 - cfg->tt[1].tsz, cfg->tt[1].tsz - tbi_byte) == -1) {
27
/* there is a ttbr1 region and we are in it (high bits all one) */
28
return &cfg->tt[1];
29
} else if (!cfg->tt[0].tsz) {
30
--
31
2.34.1
diff view generated by jsdifflib
New patch
1
From: Claudio Fontana <cfontana@suse.de>
1
2
3
make it clearer from the name that this is a tcg-only function.
4
5
Signed-off-by: Claudio Fontana <cfontana@suse.de>
6
Signed-off-by: Fabiano Rosas <farosas@suse.de>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/helper.c | 4 ++--
13
1 file changed, 2 insertions(+), 2 deletions(-)
14
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
18
+++ b/target/arm/helper.c
19
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
20
* trapped to the hypervisor in KVM.
21
*/
22
#ifdef CONFIG_TCG
23
-static void handle_semihosting(CPUState *cs)
24
+static void tcg_handle_semihosting(CPUState *cs)
25
{
26
ARMCPU *cpu = ARM_CPU(cs);
27
CPUARMState *env = &cpu->env;
28
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs)
29
*/
30
#ifdef CONFIG_TCG
31
if (cs->exception_index == EXCP_SEMIHOST) {
32
- handle_semihosting(cs);
33
+ tcg_handle_semihosting(cs);
34
return;
35
}
36
#endif
37
--
38
2.34.1
39
40
diff view generated by jsdifflib
New patch
1
From: Claudio Fontana <cfontana@suse.de>
1
2
3
for "all" builds (tcg + kvm), we want to avoid doing
4
the psci check if tcg is built-in, but not enabled.
5
6
Signed-off-by: Claudio Fontana <cfontana@suse.de>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Fabiano Rosas <farosas@suse.de>
9
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/helper.c | 3 ++-
13
1 file changed, 2 insertions(+), 1 deletion(-)
14
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
18
+++ b/target/arm/helper.c
19
@@ -XXX,XX +XXX,XX @@
20
#include "hw/irq.h"
21
#include "sysemu/cpu-timers.h"
22
#include "sysemu/kvm.h"
23
+#include "sysemu/tcg.h"
24
#include "qapi/qapi-commands-machine-target.h"
25
#include "qapi/error.h"
26
#include "qemu/guest-random.h"
27
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs)
28
env->exception.syndrome);
29
}
30
31
- if (arm_is_psci_call(cpu, cs->exception_index)) {
32
+ if (tcg_enabled() && arm_is_psci_call(cpu, cs->exception_index)) {
33
arm_handle_psci_call(cpu);
34
qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n");
35
return;
36
--
37
2.34.1
38
39
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Claudio Fontana <cfontana@suse.de>
2
2
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
3
Signed-off-by: Claudio Fontana <cfontana@suse.de>
4
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190219222952.22183-5-richard.henderson@linaro.org
5
Signed-off-by: Fabiano Rosas <farosas@suse.de>
6
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
---
8
target/arm/cpu.c | 1 +
9
target/arm/helper.c | 12 +++++++-----
9
target/arm/cpu64.c | 2 ++
10
1 file changed, 7 insertions(+), 5 deletions(-)
10
2 files changed, 3 insertions(+)
11
11
12
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu.c
14
--- a/target/arm/helper.c
15
+++ b/target/arm/cpu.c
15
+++ b/target/arm/helper.c
16
@@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj)
16
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
17
t = cpu->isar.id_isar6;
17
unsigned int cur_el = arm_current_el(env);
18
t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1);
18
int rt;
19
t = FIELD_DP32(t, ID_ISAR6, DP, 1);
19
20
+ t = FIELD_DP32(t, ID_ISAR6, FHM, 1);
20
- /*
21
cpu->isar.id_isar6 = t;
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
t = cpu->id_mmfr4;
23
- */
24
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
24
- aarch64_sve_change_el(env, cur_el, new_el, is_a64(env));
25
index XXXXXXX..XXXXXXX 100644
25
+ if (tcg_enabled()) {
26
--- a/target/arm/cpu64.c
26
+ /*
27
+++ b/target/arm/cpu64.c
27
+ * Note that new_el can never be 0. If cur_el is 0, then
28
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
28
+ * el0_a64 is is_a64(), else el0_a64 is ignored.
29
t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 1);
29
+ */
30
t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 1);
30
+ aarch64_sve_change_el(env, cur_el, new_el, is_a64(env));
31
t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);
31
+ }
32
+ t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 1);
32
33
cpu->isar.id_aa64isar0 = t;
33
if (cur_el < new_el) {
34
35
t = cpu->isar.id_aa64isar1;
36
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
37
u = cpu->isar.id_isar6;
38
u = FIELD_DP32(u, ID_ISAR6, JSCVT, 1);
39
u = FIELD_DP32(u, ID_ISAR6, DP, 1);
40
+ u = FIELD_DP32(u, ID_ISAR6, FHM, 1);
41
cpu->isar.id_isar6 = u;
42
43
/*
34
/*
44
--
35
--
45
2.20.1
36
2.34.1
46
37
47
38
diff view generated by jsdifflib
1
Create and connect the MHUs in the SSE-200.
1
From: Fabiano Rosas <farosas@suse.de>
2
2
3
Move this earlier to make the next patch diff cleaner. While here
4
update the comment slightly to not give the impression that the
5
misalignment affects only TCG.
6
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Signed-off-by: Fabiano Rosas <farosas@suse.de>
10
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190219125808.25174-3-peter.maydell@linaro.org
6
---
12
---
7
include/hw/arm/armsse.h | 3 ++-
13
target/arm/machine.c | 18 +++++++++---------
8
hw/arm/armsse.c | 40 ++++++++++++++++++++++++++++++----------
14
1 file changed, 9 insertions(+), 9 deletions(-)
9
2 files changed, 32 insertions(+), 11 deletions(-)
10
15
11
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
16
diff --git a/target/arm/machine.c b/target/arm/machine.c
12
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
13
--- a/include/hw/arm/armsse.h
18
--- a/target/arm/machine.c
14
+++ b/include/hw/arm/armsse.h
19
+++ b/target/arm/machine.c
15
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id)
16
#include "hw/misc/iotkit-sysctl.h"
17
#include "hw/misc/iotkit-sysinfo.h"
18
#include "hw/misc/armsse-cpuid.h"
19
+#include "hw/misc/armsse-mhu.h"
20
#include "hw/misc/unimp.h"
21
#include "hw/or-irq.h"
22
#include "hw/core/split-irq.h"
23
@@ -XXX,XX +XXX,XX @@ typedef struct ARMSSE {
24
IoTKitSysCtl sysctl;
25
IoTKitSysCtl sysinfo;
26
27
- UnimplementedDeviceState mhu[2];
28
+ ARMSSEMHU mhu[2];
29
UnimplementedDeviceState ppu[NUM_PPUS];
30
UnimplementedDeviceState cachectrl[SSE_MAX_CPUS];
31
UnimplementedDeviceState cpusecctrl[SSE_MAX_CPUS];
32
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/armsse.c
35
+++ b/hw/arm/armsse.c
36
@@ -XXX,XX +XXX,XX @@ static void armsse_init(Object *obj)
37
sizeof(s->sysinfo), TYPE_IOTKIT_SYSINFO);
38
if (info->has_mhus) {
39
sysbus_init_child_obj(obj, "mhu0", &s->mhu[0], sizeof(s->mhu[0]),
40
- TYPE_UNIMPLEMENTED_DEVICE);
41
+ TYPE_ARMSSE_MHU);
42
sysbus_init_child_obj(obj, "mhu1", &s->mhu[1], sizeof(s->mhu[1]),
43
- TYPE_UNIMPLEMENTED_DEVICE);
44
+ TYPE_ARMSSE_MHU);
45
}
46
if (info->has_ppus) {
47
for (i = 0; i < info->num_cpus; i++) {
48
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
49
}
50
51
if (info->has_mhus) {
52
- for (i = 0; i < ARRAY_SIZE(s->mhu); i++) {
53
- char *name;
54
- char *port;
55
+ /*
56
+ * An SSE-200 with only one CPU should have only one MHU created,
57
+ * with the region where the second MHU usually is being RAZ/WI.
58
+ * We don't implement that SSE-200 config; if we want to support
59
+ * it then this code needs to be enhanced to handle creating the
60
+ * RAZ/WI region instead of the second MHU.
61
+ */
62
+ assert(info->num_cpus == ARRAY_SIZE(s->mhu));
63
+
64
+ for (i = 0; i < ARRAY_SIZE(s->mhu); i++) {
65
+ char *port;
66
+ int cpunum;
67
+ SysBusDevice *mhu_sbd = SYS_BUS_DEVICE(&s->mhu[i]);
68
69
- name = g_strdup_printf("MHU%d", i);
70
- qdev_prop_set_string(DEVICE(&s->mhu[i]), "name", name);
71
- qdev_prop_set_uint64(DEVICE(&s->mhu[i]), "size", 0x1000);
72
object_property_set_bool(OBJECT(&s->mhu[i]), true,
73
"realized", &err);
74
- g_free(name);
75
if (err) {
76
error_propagate(errp, err);
77
return;
78
}
79
port = g_strdup_printf("port[%d]", i + 3);
80
- mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->mhu[i]), 0);
81
+ mr = sysbus_mmio_get_region(mhu_sbd, 0);
82
object_property_set_link(OBJECT(&s->apb_ppc0), OBJECT(mr),
83
port, &err);
84
g_free(port);
85
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
86
error_propagate(errp, err);
87
return;
88
}
89
+
90
+ /*
91
+ * Each MHU has an irq line for each CPU:
92
+ * MHU 0 irq line 0 -> CPU 0 IRQ 6
93
+ * MHU 0 irq line 1 -> CPU 1 IRQ 6
94
+ * MHU 1 irq line 0 -> CPU 0 IRQ 7
95
+ * MHU 1 irq line 1 -> CPU 1 IRQ 7
96
+ */
97
+ for (cpunum = 0; cpunum < info->num_cpus; cpunum++) {
98
+ DeviceState *cpudev = DEVICE(&s->armv7m[cpunum]);
99
+
100
+ sysbus_connect_irq(mhu_sbd, cpunum,
101
+ qdev_get_gpio_in(cpudev, 6 + i));
102
+ }
103
}
21
}
104
}
22
}
105
23
24
+ /*
25
+ * Misaligned thumb pc is architecturally impossible. Fail the
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
+ }
32
+
33
hw_breakpoint_update_all(cpu);
34
hw_watchpoint_update_all(cpu);
35
36
@@ -XXX,XX +XXX,XX @@ static int cpu_post_load(void *opaque, int version_id)
37
}
38
}
39
40
- /*
41
- * Misaligned thumb pc is architecturally impossible.
42
- * We have an assert in thumb_tr_translate_insn to verify this.
43
- * Fail an incoming migrate to avoid this assert.
44
- */
45
- if (!is_a64(env) && env->thumb && (env->regs[15] & 1)) {
46
- return -1;
47
- }
48
-
49
if (!kvm_enabled()) {
50
pmu_op_finish(&cpu->env);
51
}
106
--
52
--
107
2.20.1
53
2.34.1
108
54
109
55
diff view generated by jsdifflib
1
The CPUWAIT register acts as a sort of power-control: if a bit
1
From: Fabiano Rosas <farosas@suse.de>
2
in it is 1 then the CPU will have been forced into waiting
2
3
when the system was reset (which in QEMU we model as the
3
Since commit cf7c6d1004 ("target/arm: Split out cpregs.h") we now have
4
CPU starting powered off). Writing a 0 to the register will
4
a cpregs.h header which is more suitable for this code.
5
allow the CPU to boot (for QEMU, we model this as powering
5
6
it on). Note that writing 0 to the register does not power
6
Code moved verbatim.
7
off a CPU.
7
8
8
Signed-off-by: Fabiano Rosas <farosas@suse.de>
9
For this to work correctly we need to also honour the
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
INITSVTOR* registers, which let the guest control where the
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
CPU will load its SP and PC from when it comes out of reset.
11
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20190219125808.25174-8-peter.maydell@linaro.org
16
---
13
---
17
hw/misc/iotkit-sysctl.c | 41 +++++++++++++++++++++++++++++++++++++----
14
target/arm/cpregs.h | 98 +++++++++++++++++++++++++++++++++++++++++++++
18
1 file changed, 37 insertions(+), 4 deletions(-)
15
target/arm/cpu.h | 91 -----------------------------------------
19
16
2 files changed, 98 insertions(+), 91 deletions(-)
20
diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c
17
18
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
21
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/misc/iotkit-sysctl.c
20
--- a/target/arm/cpregs.h
23
+++ b/hw/misc/iotkit-sysctl.c
21
+++ b/target/arm/cpregs.h
24
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ enum {
25
#include "hw/sysbus.h"
23
ARM_CP_SME = 1 << 19,
26
#include "hw/registerfields.h"
27
#include "hw/misc/iotkit-sysctl.h"
28
+#include "target/arm/arm-powerctl.h"
29
+#include "target/arm/cpu.h"
30
31
REG32(SECDBGSTAT, 0x0)
32
REG32(SECDBGSET, 0x4)
33
@@ -XXX,XX +XXX,XX @@ static const int sysctl_id[] = {
34
0x0d, 0xf0, 0x05, 0xb1, /* CID0..CID3 */
35
};
24
};
36
25
37
+/*
26
+/*
38
+ * Set the initial secure vector table offset address for the core.
27
+ * Interface for defining coprocessor registers.
39
+ * This will take effect when the CPU next resets.
28
+ * Registers are defined in tables of arm_cp_reginfo structs
40
+ */
29
+ * which are passed to define_arm_cp_regs().
41
+static void set_init_vtor(uint64_t cpuid, uint32_t vtor)
30
+ */
31
+
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)
42
+{
84
+{
43
+ Object *cpuobj = OBJECT(arm_get_cpu_by_id(cpuid));
85
+ uint32_t cpregid = kvmid;
44
+
86
+ if ((kvmid & CP_REG_ARCH_MASK) == CP_REG_ARM64) {
45
+ if (cpuobj) {
87
+ cpregid |= CP_REG_AA64_MASK;
46
+ if (object_property_find(cpuobj, "init-svtor", NULL)) {
88
+ } else {
47
+ object_property_set_uint(cpuobj, vtor, "init-svtor", &error_abort);
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;
48
+ }
119
+ }
49
+ }
120
+ }
121
+ return kvmid;
50
+}
122
+}
51
+
123
+
52
static uint64_t iotkit_sysctl_read(void *opaque, hwaddr offset,
124
/*
53
unsigned size)
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)
54
{
228
{
55
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_write(void *opaque, hwaddr offset,
56
s->gretreg = value;
57
break;
58
case A_INITSVTOR0:
59
- qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl INITSVTOR0 unimplemented\n");
60
s->initsvtor0 = value;
61
+ set_init_vtor(0, s->initsvtor0);
62
break;
63
case A_CPUWAIT:
64
- qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl CPUWAIT unimplemented\n");
65
+ if ((s->cpuwait & 1) && !(value & 1)) {
66
+ /* Powering up CPU 0 */
67
+ arm_set_cpu_on_and_reset(0);
68
+ }
69
+ if ((s->cpuwait & 2) && !(value & 2)) {
70
+ /* Powering up CPU 1 */
71
+ arm_set_cpu_on_and_reset(1);
72
+ }
73
s->cpuwait = value;
74
break;
75
case A_WICCTRL:
76
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_write(void *opaque, hwaddr offset,
77
if (!s->is_sse200) {
78
goto bad_offset;
79
}
80
- qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl INITSVTOR1 unimplemented\n");
81
s->initsvtor1 = value;
82
+ set_init_vtor(1, s->initsvtor1);
83
break;
84
case A_EWCTRL:
85
if (!s->is_sse200) {
86
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_reset(DeviceState *dev)
87
s->gretreg = 0;
88
s->initsvtor0 = 0x10000000;
89
s->initsvtor1 = 0x10000000;
90
- s->cpuwait = 0;
91
+ if (s->is_sse200) {
92
+ /*
93
+ * CPU 0 starts on, CPU 1 starts off. In real hardware this is
94
+ * configurable by the SoC integrator as a verilog parameter.
95
+ */
96
+ s->cpuwait = 2;
97
+ } else {
98
+ /* CPU 0 starts on */
99
+ s->cpuwait = 0;
100
+ }
101
s->wicctrl = 0;
102
s->scsecctrl = 0;
103
s->fclk_div = 0;
104
--
229
--
105
2.20.1
230
2.34.1
106
231
107
232
diff view generated by jsdifflib
1
At the moment the handling of init-svtor and cpuwait initial
1
From: Fabiano Rosas <farosas@suse.de>
2
values is split between armsse.c and iotkit-sysctl.c:
3
the code in armsse.c sets the initial state of the CPU
4
object by setting the init-svtor and start-powered-off
5
properties, but the iotkit-sysctl.c code has its own
6
code setting the reset values of its registers (which are
7
then used when updating the CPU when the guest makes
8
runtime changes).
9
2
10
Clean this up by making the armsse.c code set properties on the
3
If a test was tagged with the "accel" tag and the specified
11
iotkit-sysctl object to define the initial values of the
4
accelerator it not present in the qemu binary, cancel the test.
12
registers, so they always match the initial CPU state,
13
and update the comments in armsse.c accordingly.
14
5
6
We can now write tests without explicit calls to require_accelerator,
7
just the tag is enough.
8
9
Signed-off-by: Fabiano Rosas <farosas@suse.de>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20190219125808.25174-9-peter.maydell@linaro.org
18
---
13
---
19
include/hw/misc/iotkit-sysctl.h | 3 ++
14
tests/avocado/avocado_qemu/__init__.py | 4 ++++
20
hw/arm/armsse.c | 49 +++++++++++++++++++++------------
15
1 file changed, 4 insertions(+)
21
hw/misc/iotkit-sysctl.c | 20 ++++++--------
22
3 files changed, 42 insertions(+), 30 deletions(-)
23
16
24
diff --git a/include/hw/misc/iotkit-sysctl.h b/include/hw/misc/iotkit-sysctl.h
17
diff --git a/tests/avocado/avocado_qemu/__init__.py b/tests/avocado/avocado_qemu/__init__.py
25
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/misc/iotkit-sysctl.h
19
--- a/tests/avocado/avocado_qemu/__init__.py
27
+++ b/include/hw/misc/iotkit-sysctl.h
20
+++ b/tests/avocado/avocado_qemu/__init__.py
28
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKitSysCtl {
21
@@ -XXX,XX +XXX,XX @@ def setUp(self):
29
22
30
/* Properties */
23
super().setUp('qemu-system-')
31
uint32_t sys_version;
24
32
+ uint32_t cpuwait_rst;
25
+ accel_required = self._get_unique_tag_val('accel')
33
+ uint32_t initsvtor0_rst;
26
+ if accel_required:
34
+ uint32_t initsvtor1_rst;
27
+ self.require_accelerator(accel_required)
35
28
+
36
bool is_sse200;
29
self.machine = self.params.get('machine',
37
} IoTKitSysCtl;
30
default=self._get_unique_tag_val('machine'))
38
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/hw/arm/armsse.c
41
+++ b/hw/arm/armsse.c
42
@@ -XXX,XX +XXX,XX @@
43
44
#include "qemu/osdep.h"
45
#include "qemu/log.h"
46
+#include "qemu/bitops.h"
47
#include "qapi/error.h"
48
#include "trace.h"
49
#include "hw/sysbus.h"
50
@@ -XXX,XX +XXX,XX @@ struct ARMSSEInfo {
51
int sram_banks;
52
int num_cpus;
53
uint32_t sys_version;
54
+ uint32_t cpuwait_rst;
55
SysConfigFormat sys_config_format;
56
bool has_mhus;
57
bool has_ppus;
58
@@ -XXX,XX +XXX,XX @@ static const ARMSSEInfo armsse_variants[] = {
59
.sram_banks = 1,
60
.num_cpus = 1,
61
.sys_version = 0x41743,
62
+ .cpuwait_rst = 0,
63
.sys_config_format = IoTKitFormat,
64
.has_mhus = false,
65
.has_ppus = false,
66
@@ -XXX,XX +XXX,XX @@ static const ARMSSEInfo armsse_variants[] = {
67
.sram_banks = 4,
68
.num_cpus = 2,
69
.sys_version = 0x22041743,
70
+ .cpuwait_rst = 2,
71
.sys_config_format = SSE200Format,
72
.has_mhus = true,
73
.has_ppus = true,
74
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
75
76
qdev_prop_set_uint32(cpudev, "num-irq", s->exp_numirq + 32);
77
/*
78
- * In real hardware the initial Secure VTOR is set from the INITSVTOR0
79
- * register in the IoT Kit System Control Register block, and the
80
- * initial value of that is in turn specifiable by the FPGA that
81
- * instantiates the IoT Kit. In QEMU we don't implement this wrinkle,
82
- * and simply set the CPU's init-svtor to the IoT Kit default value.
83
- * In SSE-200 the situation is similar, except that the default value
84
- * is a reset-time signal input. Typically a board using the SSE-200
85
- * will have a system control processor whose boot firmware initializes
86
- * the INITSVTOR* registers before powering up the CPUs in any case,
87
- * so the hardware's default value doesn't matter. QEMU doesn't emulate
88
+ * In real hardware the initial Secure VTOR is set from the INITSVTOR*
89
+ * registers in the IoT Kit System Control Register block. In QEMU
90
+ * we set the initial value here, and also the reset value of the
91
+ * sysctl register, from this object's QOM init-svtor property.
92
+ * If the guest changes the INITSVTOR* registers at runtime then the
93
+ * code in iotkit-sysctl.c will update the CPU init-svtor property
94
+ * (which will then take effect on the next CPU warm-reset).
95
+ *
96
+ * Note that typically a board using the SSE-200 will have a system
97
+ * control processor whose boot firmware initializes the INITSVTOR*
98
+ * registers before powering up the CPUs. QEMU doesn't emulate
99
* the control processor, so instead we behave in the way that the
100
- * firmware does. The initial value is configurable by the board code
101
- * to match whatever its firmware does.
102
+ * firmware does: the initial value should be set by the board code
103
+ * (using the init-svtor property on the ARMSSE object) to match
104
+ * whatever its firmware does.
105
*/
106
qdev_prop_set_uint32(cpudev, "init-svtor", s->init_svtor);
107
/*
108
- * Start all CPUs except CPU0 powered down. In real hardware it is
109
- * a configurable property of the SSE-200 which CPUs start powered up
110
- * (via the CPUWAIT0_RST and CPUWAIT1_RST parameters), but since all
111
- * the boards we care about start CPU0 and leave CPU1 powered off,
112
- * we hard-code that for now. We can add QOM properties for this
113
+ * CPUs start powered down if the corresponding bit in the CPUWAIT
114
+ * register is 1. In real hardware the CPUWAIT register reset value is
115
+ * a configurable property of the SSE-200 (via the CPUWAIT0_RST and
116
+ * CPUWAIT1_RST parameters), but since all the boards we care about
117
+ * start CPU0 and leave CPU1 powered off, we hard-code that in
118
+ * info->cpuwait_rst for now. We can add QOM properties for this
119
* later if necessary.
120
*/
121
- if (i > 0) {
122
+ if (extract32(info->cpuwait_rst, i, 1)) {
123
object_property_set_bool(cpuobj, true, "start-powered-off", &err);
124
if (err) {
125
error_propagate(errp, err);
126
@@ -XXX,XX +XXX,XX @@ static void armsse_realize(DeviceState *dev, Error **errp)
127
/* System control registers */
128
object_property_set_int(OBJECT(&s->sysctl), info->sys_version,
129
"SYS_VERSION", &err);
130
+ object_property_set_int(OBJECT(&s->sysctl), info->cpuwait_rst,
131
+ "CPUWAIT_RST", &err);
132
+ object_property_set_int(OBJECT(&s->sysctl), s->init_svtor,
133
+ "INITSVTOR0_RST", &err);
134
+ object_property_set_int(OBJECT(&s->sysctl), s->init_svtor,
135
+ "INITSVTOR1_RST", &err);
136
object_property_set_bool(OBJECT(&s->sysctl), true, "realized", &err);
137
if (err) {
138
error_propagate(errp, err);
139
diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c
140
index XXXXXXX..XXXXXXX 100644
141
--- a/hw/misc/iotkit-sysctl.c
142
+++ b/hw/misc/iotkit-sysctl.c
143
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_reset(DeviceState *dev)
144
s->reset_syndrome = 1;
145
s->reset_mask = 0;
146
s->gretreg = 0;
147
- s->initsvtor0 = 0x10000000;
148
- s->initsvtor1 = 0x10000000;
149
- if (s->is_sse200) {
150
- /*
151
- * CPU 0 starts on, CPU 1 starts off. In real hardware this is
152
- * configurable by the SoC integrator as a verilog parameter.
153
- */
154
- s->cpuwait = 2;
155
- } else {
156
- /* CPU 0 starts on */
157
- s->cpuwait = 0;
158
- }
159
+ s->initsvtor0 = s->initsvtor0_rst;
160
+ s->initsvtor1 = s->initsvtor1_rst;
161
+ s->cpuwait = s->cpuwait_rst;
162
s->wicctrl = 0;
163
s->scsecctrl = 0;
164
s->fclk_div = 0;
165
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription iotkit_sysctl_vmstate = {
166
167
static Property iotkit_sysctl_props[] = {
168
DEFINE_PROP_UINT32("SYS_VERSION", IoTKitSysCtl, sys_version, 0),
169
+ DEFINE_PROP_UINT32("CPUWAIT_RST", IoTKitSysCtl, cpuwait_rst, 0),
170
+ DEFINE_PROP_UINT32("INITSVTOR0_RST", IoTKitSysCtl, initsvtor0_rst,
171
+ 0x10000000),
172
+ DEFINE_PROP_UINT32("INITSVTOR1_RST", IoTKitSysCtl, initsvtor1_rst,
173
+ 0x10000000),
174
DEFINE_PROP_END_OF_LIST()
175
};
176
31
177
--
32
--
178
2.20.1
33
2.34.1
179
34
180
35
diff view generated by jsdifflib
1
The iotkit-sysctl device has a register it names INITSVRTOR0.
1
From: Fabiano Rosas <farosas@suse.de>
2
This is actually a typo present in the IoTKit documentation
3
and also in part of the SSE-200 documentation: it should be
4
INITSVTOR0 because it is specifying the initial value of the
5
Secure VTOR register in the CPU. Correct the typo.
6
2
3
This allows the test to be skipped when TCG is not present in the QEMU
4
binary.
5
6
Signed-off-by: Fabiano Rosas <farosas@suse.de>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190219125808.25174-6-peter.maydell@linaro.org
10
---
10
---
11
include/hw/misc/iotkit-sysctl.h | 2 +-
11
tests/avocado/boot_linux_console.py | 1 +
12
hw/misc/iotkit-sysctl.c | 16 ++++++++--------
12
tests/avocado/reverse_debugging.py | 8 ++++++++
13
2 files changed, 9 insertions(+), 9 deletions(-)
13
2 files changed, 9 insertions(+)
14
14
15
diff --git a/include/hw/misc/iotkit-sysctl.h b/include/hw/misc/iotkit-sysctl.h
15
diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
16
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/misc/iotkit-sysctl.h
17
--- a/tests/avocado/boot_linux_console.py
18
+++ b/include/hw/misc/iotkit-sysctl.h
18
+++ b/tests/avocado/boot_linux_console.py
19
@@ -XXX,XX +XXX,XX @@ typedef struct IoTKitSysCtl {
19
@@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_uboot_netbsd9(self):
20
uint32_t reset_syndrome;
20
21
uint32_t reset_mask;
21
def test_aarch64_raspi3_atf(self):
22
uint32_t gretreg;
22
"""
23
- uint32_t initsvrtor0;
23
+ :avocado: tags=accel:tcg
24
+ uint32_t initsvtor0;
24
:avocado: tags=arch:aarch64
25
uint32_t cpuwait;
25
:avocado: tags=machine:raspi3b
26
uint32_t wicctrl;
26
:avocado: tags=cpu:cortex-a53
27
} IoTKitSysCtl;
27
diff --git a/tests/avocado/reverse_debugging.py b/tests/avocado/reverse_debugging.py
28
diff --git a/hw/misc/iotkit-sysctl.c b/hw/misc/iotkit-sysctl.c
29
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/misc/iotkit-sysctl.c
29
--- a/tests/avocado/reverse_debugging.py
31
+++ b/hw/misc/iotkit-sysctl.c
30
+++ b/tests/avocado/reverse_debugging.py
32
@@ -XXX,XX +XXX,XX @@ REG32(RESET_MASK, 0x104)
31
@@ -XXX,XX +XXX,XX @@ def reverse_debugging(self, shift=7, args=None):
33
REG32(SWRESET, 0x108)
32
vm.shutdown()
34
FIELD(SWRESET, SWRESETREQ, 9, 1)
33
35
REG32(GRETREG, 0x10c)
34
class ReverseDebugging_X86_64(ReverseDebugging):
36
-REG32(INITSVRTOR0, 0x110)
35
+ """
37
+REG32(INITSVTOR0, 0x110)
36
+ :avocado: tags=accel:tcg
38
REG32(CPUWAIT, 0x118)
37
+ """
39
REG32(BUSWAIT, 0x11c)
38
+
40
REG32(WICCTRL, 0x120)
39
REG_PC = 0x10
41
@@ -XXX,XX +XXX,XX @@ static uint64_t iotkit_sysctl_read(void *opaque, hwaddr offset,
40
REG_CS = 0x12
42
case A_GRETREG:
41
def get_pc(self, g):
43
r = s->gretreg;
42
@@ -XXX,XX +XXX,XX @@ def test_x86_64_pc(self):
44
break;
43
self.reverse_debugging()
45
- case A_INITSVRTOR0:
44
46
- r = s->initsvrtor0;
45
class ReverseDebugging_AArch64(ReverseDebugging):
47
+ case A_INITSVTOR0:
46
+ """
48
+ r = s->initsvtor0;
47
+ :avocado: tags=accel:tcg
49
break;
48
+ """
50
case A_CPUWAIT:
49
+
51
r = s->cpuwait;
50
REG_PC = 32
52
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_write(void *opaque, hwaddr offset,
51
53
*/
52
# unidentified gitlab timeout problem
54
s->gretreg = value;
55
break;
56
- case A_INITSVRTOR0:
57
- qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl INITSVRTOR0 unimplemented\n");
58
- s->initsvrtor0 = value;
59
+ case A_INITSVTOR0:
60
+ qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl INITSVTOR0 unimplemented\n");
61
+ s->initsvtor0 = value;
62
break;
63
case A_CPUWAIT:
64
qemu_log_mask(LOG_UNIMP, "IoTKit SysCtl CPUWAIT unimplemented\n");
65
@@ -XXX,XX +XXX,XX @@ static void iotkit_sysctl_reset(DeviceState *dev)
66
s->reset_syndrome = 1;
67
s->reset_mask = 0;
68
s->gretreg = 0;
69
- s->initsvrtor0 = 0x10000000;
70
+ s->initsvtor0 = 0x10000000;
71
s->cpuwait = 0;
72
s->wicctrl = 0;
73
}
74
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription iotkit_sysctl_vmstate = {
75
VMSTATE_UINT32(reset_syndrome, IoTKitSysCtl),
76
VMSTATE_UINT32(reset_mask, IoTKitSysCtl),
77
VMSTATE_UINT32(gretreg, IoTKitSysCtl),
78
- VMSTATE_UINT32(initsvrtor0, IoTKitSysCtl),
79
+ VMSTATE_UINT32(initsvtor0, IoTKitSysCtl),
80
VMSTATE_UINT32(cpuwait, IoTKitSysCtl),
81
VMSTATE_UINT32(wicctrl, IoTKitSysCtl),
82
VMSTATE_END_OF_LIST()
83
--
53
--
84
2.20.1
54
2.34.1
85
55
86
56
diff view generated by jsdifflib
New patch
1
From: Fabiano Rosas <farosas@suse.de>
1
2
3
Now that the cortex-a15 is under CONFIG_TCG, use as default CPU for a
4
KVM-only build the 'max' cpu.
5
6
Note that we cannot use 'host' here because the qtests can run without
7
any other accelerator (than qtest) and 'host' depends on KVM being
8
enabled.
9
10
Signed-off-by: Fabiano Rosas <farosas@suse.de>
11
Acked-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Thomas Huth <thuth@redhat.com>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
hw/arm/virt.c | 4 ++++
16
1 file changed, 4 insertions(+)
17
18
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/virt.c
21
+++ b/hw/arm/virt.c
22
@@ -XXX,XX +XXX,XX @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
23
mc->minimum_page_bits = 12;
24
mc->possible_cpu_arch_ids = virt_possible_cpu_arch_ids;
25
mc->cpu_index_to_instance_props = virt_cpu_index_to_props;
26
+#ifdef CONFIG_TCG
27
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15");
28
+#else
29
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("max");
30
+#endif
31
mc->get_default_cpu_node_id = virt_get_default_cpu_node_id;
32
mc->kvm_type = virt_kvm_type;
33
assert(!mc->get_hotplug_handler);
34
--
35
2.34.1
diff view generated by jsdifflib
New patch
1
From: Fabiano Rosas <farosas@suse.de>
1
2
3
Signed-off-by: Fabiano Rosas <farosas@suse.de>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Acked-by: Thomas Huth <thuth@redhat.com>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
tests/qtest/arm-cpu-features.c | 28 ++++++++++++++++++----------
9
1 file changed, 18 insertions(+), 10 deletions(-)
10
11
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/tests/qtest/arm-cpu-features.c
14
+++ b/tests/qtest/arm-cpu-features.c
15
@@ -XXX,XX +XXX,XX @@
16
#define SVE_MAX_VQ 16
17
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
{
26
g_test_init(&argc, &argv, NULL);
27
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
+ }
34
+
35
+ if (!g_str_equal(qtest_get_arch(), "aarch64")) {
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
}
73
--
74
2.34.1
diff view generated by jsdifflib
New patch
1
From: Fabiano Rosas <farosas@suse.de>
1
2
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>
9
---
10
tests/qtest/meson.build | 4 ++--
11
1 file changed, 2 insertions(+), 2 deletions(-)
12
13
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
14
index XXXXXXX..XXXXXXX 100644
15
--- a/tests/qtest/meson.build
16
+++ b/tests/qtest/meson.build
17
@@ -XXX,XX +XXX,XX @@ qtests_arm = \
18
# TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional
19
qtests_aarch64 = \
20
(cpu != 'arm' and unpack_edk2_blobs ? ['bios-tables-test'] : []) + \
21
- (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-test'] : []) + \
22
- (config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? ['tpm-tis-device-swtpm-test'] : []) + \
23
+ (config_all.has_key('CONFIG_TCG') and config_all_devices.has_key('CONFIG_TPM_TIS_SYSBUS') ? \
24
+ ['tpm-tis-device-test', 'tpm-tis-device-swtpm-test'] : []) + \
25
(config_all_devices.has_key('CONFIG_XLNX_ZYNQMP_ARM') ? ['xlnx-can-test', 'fuzz-xlnx-dp-test'] : []) + \
26
(config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \
27
['arm-cpu-features',
28
--
29
2.34.1
diff view generated by jsdifflib