1
Most of this is the Neon decodetree patches, followed by Edgar's versal cleanups.
1
Hi; here's the first arm pullreq for 9.1.
2
3
This includes the reset method function signature change, so it has
4
some chance of compile failures due to merge conflicts if some other
5
pullreq added a device reset method and that pullreq got applied
6
before this one. If so, the changes needed to fix those up can be
7
created by running the spatch rune described in the commit message of
8
the "hw, target: Add ResetType argument to hold and exit phase
9
methods" commit.
2
10
3
thanks
11
thanks
4
-- PMM
12
-- PMM
5
13
6
14
The following changes since commit 5da72194df36535d773c8bdc951529ecd5e31707:
7
The following changes since commit 2ef486e76d64436be90f7359a3071fb2a56ce835:
15
8
16
Merge tag 'pull-tcg-20240424' of https://gitlab.com/rth7680/qemu into staging (2024-04-24 15:51:49 -0700)
9
Merge remote-tracking branch 'remotes/marcel/tags/rdma-pull-request' into staging (2020-05-03 14:12:56 +0100)
10
17
11
are available in the Git repository at:
18
are available in the Git repository at:
12
19
13
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200504
20
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240425
14
21
15
for you to fetch changes up to 9aefc6cf9b73f66062d2f914a0136756e7a28211:
22
for you to fetch changes up to 214652da123e3821657a64691ee556281e9f6238:
16
23
17
target/arm: Move gen_ function typedefs to translate.h (2020-05-04 12:59:26 +0100)
24
tests/qtest: Add tests for the STM32L4x5 USART (2024-04-25 10:21:59 +0100)
18
25
19
----------------------------------------------------------------
26
----------------------------------------------------------------
20
target-arm queue:
27
target-arm queue:
21
* Start of conversion of Neon insns to decodetree
28
* Implement FEAT_NMI and NMI support in the GICv3
22
* versal board: support SD and RTC
29
* hw/dma: avoid apparent overflow in soc_dma_set_request
23
* Implement ARMv8.2-TTS2UXN
30
* linux-user/flatload.c: Remove unused bFLT shared-library and ZFLAT code
24
* Make VQDMULL undefined when U=1
31
* Add ResetType argument to Resettable hold and exit phase methods
25
* Some minor code cleanups
32
* Add RESET_TYPE_SNAPSHOT_LOAD ResetType
33
* Implement STM32L4x5 USART
26
34
27
----------------------------------------------------------------
35
----------------------------------------------------------------
28
Edgar E. Iglesias (11):
36
Anastasia Belova (1):
29
hw/arm: versal: Remove inclusion of arm_gicv3_common.h
37
hw/dma: avoid apparent overflow in soc_dma_set_request
30
hw/arm: versal: Move misplaced comment
38
31
hw/arm: versal-virt: Fix typo xlnx-ve -> xlnx-versal
39
Arnaud Minier (5):
32
hw/arm: versal: Embed the UARTs into the SoC type
40
hw/char: Implement STM32L4x5 USART skeleton
33
hw/arm: versal: Embed the GEMs into the SoC type
41
hw/char/stm32l4x5_usart: Enable serial read and write
34
hw/arm: versal: Embed the ADMAs into the SoC type
42
hw/char/stm32l4x5_usart: Add options for serial parameters setting
35
hw/arm: versal: Embed the APUs into the SoC type
43
hw/arm: Add the USART to the stm32l4x5 SoC
36
hw/arm: versal: Add support for SD
44
tests/qtest: Add tests for the STM32L4x5 USART
37
hw/arm: versal: Add support for the RTC
45
38
hw/arm: versal-virt: Add support for SD
46
Jinjie Ruan (22):
39
hw/arm: versal-virt: Add support for the RTC
47
target/arm: Handle HCR_EL2 accesses for bits introduced with FEAT_NMI
40
48
target/arm: Add PSTATE.ALLINT
41
Fredrik Strupe (1):
49
target/arm: Add support for FEAT_NMI, Non-maskable Interrupt
42
target/arm: Make VQDMULL undefined when U=1
50
target/arm: Implement ALLINT MSR (immediate)
43
51
target/arm: Support MSR access to ALLINT
44
Peter Maydell (25):
52
target/arm: Add support for Non-maskable Interrupt
45
target/arm: Don't use a TLB for ARMMMUIdx_Stage2
53
target/arm: Add support for NMI in arm_phys_excp_target_el()
46
target/arm: Use enum constant in get_phys_addr_lpae() call
54
target/arm: Handle IS/FS in ISR_EL1 for NMI, VINMI and VFNMI
47
target/arm: Add new 's1_is_el0' argument to get_phys_addr_lpae()
55
target/arm: Handle PSTATE.ALLINT on taking an exception
48
target/arm: Implement ARMv8.2-TTS2UXN
56
hw/intc/arm_gicv3: Add external IRQ lines for NMI
49
target/arm: Use correct variable for setting 'max' cpu's ID_AA64DFR0
57
hw/arm/virt: Wire NMI and VINMI irq lines from GIC to CPU
50
target/arm/translate-vfp.inc.c: Remove duplicate simd_r32 check
58
target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64()
51
target/arm: Don't allow Thumb Neon insns without FEATURE_NEON
59
hw/intc/arm_gicv3: Add has-nmi property to GICv3 device
52
target/arm: Add stubs for AArch32 Neon decodetree
60
hw/intc/arm_gicv3_kvm: Not set has-nmi=true for the KVM GICv3
53
target/arm: Convert VCMLA (vector) to decodetree
61
hw/intc/arm_gicv3: Add irq non-maskable property
54
target/arm: Convert VCADD (vector) to decodetree
62
hw/intc/arm_gicv3_redist: Implement GICR_INMIR0
55
target/arm: Convert V[US]DOT (vector) to decodetree
63
hw/intc/arm_gicv3: Implement GICD_INMIR
56
target/arm: Convert VFM[AS]L (vector) to decodetree
64
hw/intc/arm_gicv3: Implement NMI interrupt priority
57
target/arm: Convert VCMLA (scalar) to decodetree
65
hw/intc/arm_gicv3: Report the NMI interrupt in gicv3_cpuif_update()
58
target/arm: Convert V[US]DOT (scalar) to decodetree
66
hw/intc/arm_gicv3: Report the VINMI interrupt
59
target/arm: Convert VFM[AS]L (scalar) to decodetree
67
target/arm: Add FEAT_NMI to max
60
target/arm: Convert Neon load/store multiple structures to decodetree
68
hw/arm/virt: Enable NMI support in the GIC if the CPU has FEAT_NMI
61
target/arm: Convert Neon 'load single structure to all lanes' to decodetree
69
62
target/arm: Convert Neon 'load/store single structure' to decodetree
70
Peter Maydell (9):
63
target/arm: Convert Neon 3-reg-same VADD/VSUB to decodetree
71
hw/intc/arm_gicv3: Add NMI handling CPU interface registers
64
target/arm: Convert Neon 3-reg-same logic ops to decodetree
72
hw/intc/arm_gicv3: Handle icv_nmiar1_read() for icc_nmiar1_read()
65
target/arm: Convert Neon 3-reg-same VMAX/VMIN to decodetree
73
linux-user/flatload.c: Remove unused bFLT shared-library and ZFLAT code
66
target/arm: Convert Neon 3-reg-same comparisons to decodetree
74
hw/misc: Don't special case RESET_TYPE_COLD in npcm7xx_clk, gcr
67
target/arm: Convert Neon 3-reg-same VQADD/VQSUB to decodetree
75
allwinner-i2c, adm1272: Use device_cold_reset() for software-triggered reset
68
target/arm: Convert Neon 3-reg-same VMUL, VMLA, VMLS, VSHL to decodetree
76
scripts/coccinelle: New script to add ResetType to hold and exit phases
69
target/arm: Move gen_ function typedefs to translate.h
77
hw, target: Add ResetType argument to hold and exit phase methods
70
78
docs/devel/reset: Update to new API for hold and exit phase methods
71
Philippe Mathieu-Daudé (2):
79
reset: Add RESET_TYPE_SNAPSHOT_LOAD
72
hw/arm/mps2-tz: Use TYPE_IOTKIT instead of hardcoded string
80
73
target/arm: Use uint64_t for midr field in CPU state struct
81
MAINTAINERS | 1 +
74
82
docs/devel/reset.rst | 25 +-
75
include/hw/arm/xlnx-versal.h | 31 +-
83
docs/system/arm/b-l475e-iot01a.rst | 2 +-
76
target/arm/cpu-param.h | 2 +-
84
docs/system/arm/emulation.rst | 1 +
77
target/arm/cpu.h | 38 ++-
85
scripts/coccinelle/reset-type.cocci | 133 ++++++++
78
target/arm/translate-a64.h | 9 -
86
hw/intc/gicv3_internal.h | 13 +
79
target/arm/translate.h | 26 ++
87
include/hw/arm/stm32l4x5_soc.h | 7 +
80
target/arm/neon-dp.decode | 86 +++++
88
include/hw/char/stm32l4x5_usart.h | 67 ++++
81
target/arm/neon-ls.decode | 52 +++
89
include/hw/intc/arm_gic_common.h | 2 +
82
target/arm/neon-shared.decode | 66 ++++
90
include/hw/intc/arm_gicv3_common.h | 14 +
83
hw/arm/mps2-tz.c | 2 +-
91
include/hw/resettable.h | 5 +-
84
hw/arm/xlnx-versal-virt.c | 74 ++++-
92
linux-user/flat.h | 5 +-
85
hw/arm/xlnx-versal.c | 115 +++++--
93
target/arm/cpu-features.h | 5 +
86
target/arm/cpu.c | 3 +-
94
target/arm/cpu-qom.h | 5 +-
87
target/arm/cpu64.c | 8 +-
95
target/arm/cpu.h | 9 +
88
target/arm/helper.c | 183 ++++------
96
target/arm/internals.h | 21 ++
89
target/arm/translate-a64.c | 17 -
97
target/arm/tcg/helper-a64.h | 1 +
90
target/arm/translate-neon.inc.c | 714 +++++++++++++++++++++++++++++++++++++++
98
target/arm/tcg/a64.decode | 1 +
91
target/arm/translate-vfp.inc.c | 6 -
99
hw/adc/npcm7xx_adc.c | 2 +-
92
target/arm/translate.c | 716 +++-------------------------------------
100
hw/arm/pxa2xx_pic.c | 2 +-
93
target/arm/Makefile.objs | 18 +
101
hw/arm/smmu-common.c | 2 +-
94
19 files changed, 1302 insertions(+), 864 deletions(-)
102
hw/arm/smmuv3.c | 4 +-
95
create mode 100644 target/arm/neon-dp.decode
103
hw/arm/stellaris.c | 10 +-
96
create mode 100644 target/arm/neon-ls.decode
104
hw/arm/stm32l4x5_soc.c | 83 ++++-
97
create mode 100644 target/arm/neon-shared.decode
105
hw/arm/virt.c | 29 +-
98
create mode 100644 target/arm/translate-neon.inc.c
106
hw/audio/asc.c | 2 +-
99
107
hw/char/cadence_uart.c | 2 +-
108
hw/char/sifive_uart.c | 2 +-
109
hw/char/stm32l4x5_usart.c | 637 ++++++++++++++++++++++++++++++++++++
110
hw/core/cpu-common.c | 2 +-
111
hw/core/qdev.c | 4 +-
112
hw/core/reset.c | 17 +-
113
hw/core/resettable.c | 8 +-
114
hw/display/virtio-vga.c | 4 +-
115
hw/dma/soc_dma.c | 4 +-
116
hw/gpio/npcm7xx_gpio.c | 2 +-
117
hw/gpio/pl061.c | 2 +-
118
hw/gpio/stm32l4x5_gpio.c | 2 +-
119
hw/hyperv/vmbus.c | 2 +-
120
hw/i2c/allwinner-i2c.c | 5 +-
121
hw/i2c/npcm7xx_smbus.c | 2 +-
122
hw/input/adb.c | 2 +-
123
hw/input/ps2.c | 12 +-
124
hw/intc/arm_gic_common.c | 2 +-
125
hw/intc/arm_gic_kvm.c | 4 +-
126
hw/intc/arm_gicv3.c | 67 +++-
127
hw/intc/arm_gicv3_common.c | 50 ++-
128
hw/intc/arm_gicv3_cpuif.c | 268 ++++++++++++++-
129
hw/intc/arm_gicv3_dist.c | 36 ++
130
hw/intc/arm_gicv3_its.c | 4 +-
131
hw/intc/arm_gicv3_its_common.c | 2 +-
132
hw/intc/arm_gicv3_its_kvm.c | 4 +-
133
hw/intc/arm_gicv3_kvm.c | 9 +-
134
hw/intc/arm_gicv3_redist.c | 22 ++
135
hw/intc/xics.c | 2 +-
136
hw/m68k/q800-glue.c | 2 +-
137
hw/misc/djmemc.c | 2 +-
138
hw/misc/iosb.c | 2 +-
139
hw/misc/mac_via.c | 8 +-
140
hw/misc/macio/cuda.c | 4 +-
141
hw/misc/macio/pmu.c | 4 +-
142
hw/misc/mos6522.c | 2 +-
143
hw/misc/npcm7xx_clk.c | 13 +-
144
hw/misc/npcm7xx_gcr.c | 12 +-
145
hw/misc/npcm7xx_mft.c | 2 +-
146
hw/misc/npcm7xx_pwm.c | 2 +-
147
hw/misc/stm32l4x5_exti.c | 2 +-
148
hw/misc/stm32l4x5_rcc.c | 10 +-
149
hw/misc/stm32l4x5_syscfg.c | 2 +-
150
hw/misc/xlnx-versal-cframe-reg.c | 2 +-
151
hw/misc/xlnx-versal-crl.c | 2 +-
152
hw/misc/xlnx-versal-pmc-iou-slcr.c | 2 +-
153
hw/misc/xlnx-versal-trng.c | 2 +-
154
hw/misc/xlnx-versal-xramc.c | 2 +-
155
hw/misc/xlnx-zynqmp-apu-ctrl.c | 2 +-
156
hw/misc/xlnx-zynqmp-crf.c | 2 +-
157
hw/misc/zynq_slcr.c | 4 +-
158
hw/net/can/xlnx-zynqmp-can.c | 2 +-
159
hw/net/e1000.c | 2 +-
160
hw/net/e1000e.c | 2 +-
161
hw/net/igb.c | 2 +-
162
hw/net/igbvf.c | 2 +-
163
hw/nvram/xlnx-bbram.c | 2 +-
164
hw/nvram/xlnx-versal-efuse-ctrl.c | 2 +-
165
hw/nvram/xlnx-zynqmp-efuse.c | 2 +-
166
hw/pci-bridge/cxl_root_port.c | 4 +-
167
hw/pci-bridge/pcie_root_port.c | 2 +-
168
hw/pci-host/bonito.c | 2 +-
169
hw/pci-host/pnv_phb.c | 4 +-
170
hw/pci-host/pnv_phb3_msi.c | 4 +-
171
hw/pci/pci.c | 4 +-
172
hw/rtc/mc146818rtc.c | 2 +-
173
hw/s390x/css-bridge.c | 2 +-
174
hw/sensor/adm1266.c | 2 +-
175
hw/sensor/adm1272.c | 4 +-
176
hw/sensor/isl_pmbus_vr.c | 10 +-
177
hw/sensor/max31785.c | 2 +-
178
hw/sensor/max34451.c | 2 +-
179
hw/ssi/npcm7xx_fiu.c | 2 +-
180
hw/timer/etraxfs_timer.c | 2 +-
181
hw/timer/npcm7xx_timer.c | 2 +-
182
hw/usb/hcd-dwc2.c | 8 +-
183
hw/usb/xlnx-versal-usb2-ctrl-regs.c | 2 +-
184
hw/virtio/virtio-pci.c | 2 +-
185
linux-user/flatload.c | 293 +----------------
186
target/arm/cpu.c | 151 ++++++++-
187
target/arm/helper.c | 101 +++++-
188
target/arm/tcg/cpu64.c | 1 +
189
target/arm/tcg/helper-a64.c | 16 +-
190
target/arm/tcg/translate-a64.c | 19 ++
191
target/avr/cpu.c | 4 +-
192
target/cris/cpu.c | 4 +-
193
target/hexagon/cpu.c | 4 +-
194
target/i386/cpu.c | 4 +-
195
target/loongarch/cpu.c | 4 +-
196
target/m68k/cpu.c | 4 +-
197
target/microblaze/cpu.c | 4 +-
198
target/mips/cpu.c | 4 +-
199
target/openrisc/cpu.c | 4 +-
200
target/ppc/cpu_init.c | 4 +-
201
target/riscv/cpu.c | 4 +-
202
target/rx/cpu.c | 4 +-
203
target/sh4/cpu.c | 4 +-
204
target/sparc/cpu.c | 4 +-
205
target/tricore/cpu.c | 4 +-
206
target/xtensa/cpu.c | 4 +-
207
tests/qtest/stm32l4x5_usart-test.c | 315 ++++++++++++++++++
208
hw/arm/Kconfig | 1 +
209
hw/char/Kconfig | 3 +
210
hw/char/meson.build | 1 +
211
hw/char/trace-events | 12 +
212
hw/intc/trace-events | 2 +
213
tests/qtest/meson.build | 4 +-
214
133 files changed, 2239 insertions(+), 537 deletions(-)
215
create mode 100644 scripts/coccinelle/reset-type.cocci
216
create mode 100644 include/hw/char/stm32l4x5_usart.h
217
create mode 100644 hw/char/stm32l4x5_usart.c
218
create mode 100644 tests/qtest/stm32l4x5_usart-test.c
diff view generated by jsdifflib
1
Convert the Neon 3-reg-same VMAX and VMIN insns to decodetree.
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
FEAT_NMI defines another three new bits in HCRX_EL2: TALLINT, HCRX_VINMI and
4
HCRX_VFNMI. When the feature is enabled, allow these bits to be written in
5
HCRX_EL2.
6
7
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20240407081733.3231820-2-ruanjinjie@huawei.com
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: 20200430181003.21682-17-peter.maydell@linaro.org
6
---
12
---
7
target/arm/neon-dp.decode | 5 +++++
13
target/arm/cpu-features.h | 5 +++++
8
target/arm/translate-neon.inc.c | 14 ++++++++++++++
14
target/arm/helper.c | 8 +++++++-
9
target/arm/translate.c | 21 ++-------------------
15
2 files changed, 12 insertions(+), 1 deletion(-)
10
3 files changed, 21 insertions(+), 19 deletions(-)
11
16
12
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
17
diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h
13
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/neon-dp.decode
19
--- a/target/arm/cpu-features.h
15
+++ b/target/arm/neon-dp.decode
20
+++ b/target/arm/cpu-features.h
16
@@ -XXX,XX +XXX,XX @@ VBSL_3s 1111 001 1 0 . 01 .... .... 0001 ... 1 .... @3same_logic
21
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_sme(const ARMISARegisters *id)
17
VBIT_3s 1111 001 1 0 . 10 .... .... 0001 ... 1 .... @3same_logic
22
return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SME) != 0;
18
VBIF_3s 1111 001 1 0 . 11 .... .... 0001 ... 1 .... @3same_logic
23
}
19
24
20
+VMAX_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 0 .... @3same
25
+static inline bool isar_feature_aa64_nmi(const ARMISARegisters *id)
21
+VMAX_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 0 .... @3same
26
+{
22
+VMIN_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 1 .... @3same
27
+ return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, NMI) != 0;
23
+VMIN_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 1 .... @3same
28
+}
24
+
29
+
25
VADD_3s 1111 001 0 0 . .. .... .... 1000 . . . 0 .... @3same
30
static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id)
26
VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same
31
{
27
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
32
return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 1;
33
diff --git a/target/arm/helper.c b/target/arm/helper.c
28
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/translate-neon.inc.c
35
--- a/target/arm/helper.c
30
+++ b/target/arm/translate-neon.inc.c
36
+++ b/target/arm/helper.c
31
@@ -XXX,XX +XXX,XX @@ DO_3SAME(VEOR, tcg_gen_gvec_xor)
37
@@ -XXX,XX +XXX,XX @@ bool el_is_in_host(CPUARMState *env, int el)
32
DO_3SAME_BITSEL(VBSL, rd_ofs, rn_ofs, rm_ofs)
38
static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri,
33
DO_3SAME_BITSEL(VBIT, rm_ofs, rn_ofs, rd_ofs)
39
uint64_t value)
34
DO_3SAME_BITSEL(VBIF, rm_ofs, rd_ofs, rn_ofs)
40
{
35
+
41
+ ARMCPU *cpu = env_archcpu(env);
36
+#define DO_3SAME_NO_SZ_3(INSN, FUNC) \
42
uint64_t valid_mask = 0;
37
+ static bool trans_##INSN##_3s(DisasContext *s, arg_3same *a) \
43
38
+ { \
44
/* FEAT_MOPS adds MSCEn and MCE2 */
39
+ if (a->size == 3) { \
45
- if (cpu_isar_feature(aa64_mops, env_archcpu(env))) {
40
+ return false; \
46
+ if (cpu_isar_feature(aa64_mops, cpu)) {
41
+ } \
47
valid_mask |= HCRX_MSCEN | HCRX_MCE2;
42
+ return do_3same(s, a, FUNC); \
48
}
49
50
+ /* FEAT_NMI adds TALLINT, VINMI and VFNMI */
51
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
52
+ valid_mask |= HCRX_TALLINT | HCRX_VINMI | HCRX_VFNMI;
43
+ }
53
+ }
44
+
54
+
45
+DO_3SAME_NO_SZ_3(VMAX_S, tcg_gen_gvec_smax)
55
/* Clear RES0 bits. */
46
+DO_3SAME_NO_SZ_3(VMAX_U, tcg_gen_gvec_umax)
56
env->cp15.hcrx_el2 = value & valid_mask;
47
+DO_3SAME_NO_SZ_3(VMIN_S, tcg_gen_gvec_smin)
57
}
48
+DO_3SAME_NO_SZ_3(VMIN_U, tcg_gen_gvec_umin)
49
diff --git a/target/arm/translate.c b/target/arm/translate.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/target/arm/translate.c
52
+++ b/target/arm/translate.c
53
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
54
rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size);
55
return 0;
56
57
- case NEON_3R_VMAX:
58
- if (u) {
59
- tcg_gen_gvec_umax(size, rd_ofs, rn_ofs, rm_ofs,
60
- vec_size, vec_size);
61
- } else {
62
- tcg_gen_gvec_smax(size, rd_ofs, rn_ofs, rm_ofs,
63
- vec_size, vec_size);
64
- }
65
- return 0;
66
- case NEON_3R_VMIN:
67
- if (u) {
68
- tcg_gen_gvec_umin(size, rd_ofs, rn_ofs, rm_ofs,
69
- vec_size, vec_size);
70
- } else {
71
- tcg_gen_gvec_smin(size, rd_ofs, rn_ofs, rm_ofs,
72
- vec_size, vec_size);
73
- }
74
- return 0;
75
-
76
case NEON_3R_VSHL:
77
/* Note the operation is vshl vd,vm,vn */
78
tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size,
79
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
80
81
case NEON_3R_VADD_VSUB:
82
case NEON_3R_LOGIC:
83
+ case NEON_3R_VMAX:
84
+ case NEON_3R_VMIN:
85
/* Already handled by decodetree */
86
return 1;
87
}
88
--
58
--
89
2.20.1
59
2.34.1
90
91
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
MIDR_EL1 is a 64-bit system register with the top 32-bit being RES0.
3
When PSTATE.ALLINT is set, an IRQ or FIQ interrupt that is targeted to
4
Represent it in QEMU's ARMCPU struct with a uint64_t, not a
4
ELx, with or without superpriority is masked. As Richard suggested, place
5
uint32_t.
5
ALLINT bit in PSTATE in env->pstate.
6
6
7
This fixes an error when compiling with -Werror=conversion
7
In the pseudocode, AArch64.ExceptionReturn() calls SetPSTATEFromPSR(), which
8
because we were manipulating the register value using a
8
treats PSTATE.ALLINT as one of the bits which are reinstated from SPSR to
9
local uint64_t variable:
9
PSTATE regardless of whether this is an illegal exception return or not. So
10
handle PSTATE.ALLINT the same way as PSTATE.DAIF in the illegal_return exit
11
path of the exception_return helper. With the change, exception entry and
12
return are automatically handled.
10
13
11
target/arm/cpu64.c: In function ‘aarch64_max_initfn’:
14
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
12
target/arm/cpu64.c:628:21: error: conversion from ‘uint64_t’ {aka ‘long unsigned int’} to ‘uint32_t’ {aka ‘unsigned int’} may change value [-Werror=conversion]
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
628 | cpu->midr = t;
14
| ^
15
16
and future-proofs us against a possible future architecture
17
change using some of the top 32 bits.
18
19
Suggested-by: Laurent Desnogues <laurent.desnogues@gmail.com>
20
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
22
Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com>
23
Message-id: 20200428172634.29707-1-f4bug@amsat.org
24
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Message-id: 20240407081733.3231820-3-ruanjinjie@huawei.com
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
---
19
---
27
target/arm/cpu.h | 2 +-
20
target/arm/cpu.h | 1 +
28
target/arm/cpu.c | 2 +-
21
target/arm/tcg/helper-a64.c | 4 ++--
29
2 files changed, 2 insertions(+), 2 deletions(-)
22
2 files changed, 3 insertions(+), 2 deletions(-)
30
23
31
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
24
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
32
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
33
--- a/target/arm/cpu.h
26
--- a/target/arm/cpu.h
34
+++ b/target/arm/cpu.h
27
+++ b/target/arm/cpu.h
35
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
28
@@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu);
36
uint64_t id_aa64dfr0;
29
#define PSTATE_D (1U << 9)
37
uint64_t id_aa64dfr1;
30
#define PSTATE_BTYPE (3U << 10)
38
} isar;
31
#define PSTATE_SSBS (1U << 12)
39
- uint32_t midr;
32
+#define PSTATE_ALLINT (1U << 13)
40
+ uint64_t midr;
33
#define PSTATE_IL (1U << 20)
41
uint32_t revidr;
34
#define PSTATE_SS (1U << 21)
42
uint32_t reset_fpsid;
35
#define PSTATE_PAN (1U << 22)
43
uint32_t ctr;
36
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
44
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
45
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
46
--- a/target/arm/cpu.c
38
--- a/target/arm/tcg/helper-a64.c
47
+++ b/target/arm/cpu.c
39
+++ b/target/arm/tcg/helper-a64.c
48
@@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_cpus[] = {
40
@@ -XXX,XX +XXX,XX @@ illegal_return:
49
static Property arm_cpu_properties[] = {
41
*/
50
DEFINE_PROP_BOOL("start-powered-off", ARMCPU, start_powered_off, false),
42
env->pstate |= PSTATE_IL;
51
DEFINE_PROP_UINT32("psci-conduit", ARMCPU, psci_conduit, 0),
43
env->pc = new_pc;
52
- DEFINE_PROP_UINT32("midr", ARMCPU, midr, 0),
44
- spsr &= PSTATE_NZCV | PSTATE_DAIF;
53
+ DEFINE_PROP_UINT64("midr", ARMCPU, midr, 0),
45
- spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF);
54
DEFINE_PROP_UINT64("mp-affinity", ARMCPU,
46
+ spsr &= PSTATE_NZCV | PSTATE_DAIF | PSTATE_ALLINT;
55
mp_affinity, ARM64_AFFINITY_INVALID),
47
+ spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF | PSTATE_ALLINT);
56
DEFINE_PROP_INT32("node-id", ARMCPU, node_id, CPU_UNSET_NUMA_NODE_ID),
48
pstate_write(env, spsr);
49
if (!arm_singlestep_active(env)) {
50
env->pstate &= ~PSTATE_SS;
57
--
51
--
58
2.20.1
52
2.34.1
59
60
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Embed the ADMAs into the SoC type.
3
Add support for FEAT_NMI. NMI (FEAT_NMI) is an mandatory feature in
4
ARMv8.8-A and ARM v9.3-A.
4
5
5
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20240407081733.3231820-4-ruanjinjie@huawei.com
9
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
10
Message-id: 20200427181649.26851-7-edgar.iglesias@gmail.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
include/hw/arm/xlnx-versal.h | 3 ++-
12
target/arm/internals.h | 3 +++
14
hw/arm/xlnx-versal.c | 14 +++++++-------
13
1 file changed, 3 insertions(+)
15
2 files changed, 9 insertions(+), 8 deletions(-)
16
14
17
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
15
diff --git a/target/arm/internals.h b/target/arm/internals.h
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/xlnx-versal.h
17
--- a/target/arm/internals.h
20
+++ b/include/hw/arm/xlnx-versal.h
18
+++ b/target/arm/internals.h
21
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id)
22
#include "hw/arm/boot.h"
20
if (isar_feature_aa64_mte(id)) {
23
#include "hw/intc/arm_gicv3.h"
21
valid |= PSTATE_TCO;
24
#include "hw/char/pl011.h"
25
+#include "hw/dma/xlnx-zdma.h"
26
#include "hw/net/cadence_gem.h"
27
28
#define TYPE_XLNX_VERSAL "xlnx-versal"
29
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
30
struct {
31
PL011State uart[XLNX_VERSAL_NR_UARTS];
32
CadenceGEMState gem[XLNX_VERSAL_NR_GEMS];
33
- SysBusDevice *adma[XLNX_VERSAL_NR_ADMAS];
34
+ XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS];
35
} iou;
36
} lpd;
37
38
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/hw/arm/xlnx-versal.c
41
+++ b/hw/arm/xlnx-versal.c
42
@@ -XXX,XX +XXX,XX @@ static void versal_create_admas(Versal *s, qemu_irq *pic)
43
DeviceState *dev;
44
MemoryRegion *mr;
45
46
- dev = qdev_create(NULL, "xlnx.zdma");
47
- s->lpd.iou.adma[i] = SYS_BUS_DEVICE(dev);
48
- object_property_set_int(OBJECT(s->lpd.iou.adma[i]), 128, "bus-width",
49
- &error_abort);
50
- object_property_add_child(OBJECT(s), name, OBJECT(dev), &error_fatal);
51
+ sysbus_init_child_obj(OBJECT(s), name,
52
+ &s->lpd.iou.adma[i], sizeof(s->lpd.iou.adma[i]),
53
+ TYPE_XLNX_ZDMA);
54
+ dev = DEVICE(&s->lpd.iou.adma[i]);
55
+ object_property_set_int(OBJECT(dev), 128, "bus-width", &error_abort);
56
qdev_init_nofail(dev);
57
58
- mr = sysbus_mmio_get_region(s->lpd.iou.adma[i], 0);
59
+ mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
60
memory_region_add_subregion(&s->mr_ps,
61
MM_ADMA_CH0 + i * MM_ADMA_CH0_SIZE, mr);
62
63
- sysbus_connect_irq(s->lpd.iou.adma[i], 0, pic[VERSAL_ADMA_IRQ_0 + i]);
64
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[VERSAL_ADMA_IRQ_0 + i]);
65
g_free(name);
66
}
22
}
23
+ if (isar_feature_aa64_nmi(id)) {
24
+ valid |= PSTATE_ALLINT;
25
+ }
26
27
return valid;
67
}
28
}
68
--
29
--
69
2.20.1
30
2.34.1
70
71
diff view generated by jsdifflib
1
Convert the Neon "load/store single structure to one lane" insns to
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
decodetree.
3
2
4
As this is the last set of insns in the neon load/store group,
3
Add ALLINT MSR (immediate) to decodetree, in which the CRm is 0b000x. The
5
we can remove the whole disas_neon_ls_insn() function.
4
EL0 check is necessary to ALLINT, and the EL1 check is necessary when
5
imm == 1. So implement it inline for EL2/3, or EL1 with imm==0. Avoid the
6
unconditional write to pc and use raise_exception_ra to unwind.
6
7
8
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20240407081733.3231820-5-ruanjinjie@huawei.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20200430181003.21682-14-peter.maydell@linaro.org
10
---
13
---
11
target/arm/neon-ls.decode | 11 +++
14
target/arm/tcg/helper-a64.h | 1 +
12
target/arm/translate-neon.inc.c | 89 +++++++++++++++++++
15
target/arm/tcg/a64.decode | 1 +
13
target/arm/translate.c | 147 --------------------------------
16
target/arm/tcg/helper-a64.c | 12 ++++++++++++
14
3 files changed, 100 insertions(+), 147 deletions(-)
17
target/arm/tcg/translate-a64.c | 19 +++++++++++++++++++
18
4 files changed, 33 insertions(+)
15
19
16
diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode
20
diff --git a/target/arm/tcg/helper-a64.h b/target/arm/tcg/helper-a64.h
17
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/neon-ls.decode
22
--- a/target/arm/tcg/helper-a64.h
19
+++ b/target/arm/neon-ls.decode
23
+++ b/target/arm/tcg/helper-a64.h
20
@@ -XXX,XX +XXX,XX @@ VLDST_multiple 1111 0100 0 . l:1 0 rn:4 .... itype:4 size:2 align:2 rm:4 \
24
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64)
21
25
DEF_HELPER_2(msr_i_spsel, void, env, i32)
22
VLD_all_lanes 1111 0100 1 . 1 0 rn:4 .... 11 n:2 size:2 t:1 a:1 rm:4 \
26
DEF_HELPER_2(msr_i_daifset, void, env, i32)
23
vd=%vd_dp
27
DEF_HELPER_2(msr_i_daifclear, void, env, i32)
28
+DEF_HELPER_1(msr_set_allint_el1, void, env)
29
DEF_HELPER_3(vfp_cmph_a64, i64, f16, f16, ptr)
30
DEF_HELPER_3(vfp_cmpeh_a64, i64, f16, f16, ptr)
31
DEF_HELPER_3(vfp_cmps_a64, i64, f32, f32, ptr)
32
diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/arm/tcg/a64.decode
35
+++ b/target/arm/tcg/a64.decode
36
@@ -XXX,XX +XXX,XX @@ MSR_i_DIT 1101 0101 0000 0 011 0100 .... 010 11111 @msr_i
37
MSR_i_TCO 1101 0101 0000 0 011 0100 .... 100 11111 @msr_i
38
MSR_i_DAIFSET 1101 0101 0000 0 011 0100 .... 110 11111 @msr_i
39
MSR_i_DAIFCLEAR 1101 0101 0000 0 011 0100 .... 111 11111 @msr_i
40
+MSR_i_ALLINT 1101 0101 0000 0 001 0100 000 imm:1 000 11111
41
MSR_i_SVCR 1101 0101 0000 0 011 0100 0 mask:2 imm:1 011 11111
42
43
# MRS, MSR (register), SYS, SYSL. These are all essentially the
44
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/target/arm/tcg/helper-a64.c
47
+++ b/target/arm/tcg/helper-a64.c
48
@@ -XXX,XX +XXX,XX @@ void HELPER(msr_i_spsel)(CPUARMState *env, uint32_t imm)
49
update_spsel(env, imm);
50
}
51
52
+void HELPER(msr_set_allint_el1)(CPUARMState *env)
53
+{
54
+ /* ALLINT update to PSTATE. */
55
+ if (arm_hcrx_el2_eff(env) & HCRX_TALLINT) {
56
+ raise_exception_ra(env, EXCP_UDEF,
57
+ syn_aa64_sysregtrap(0, 1, 0, 4, 1, 0x1f, 0), 2,
58
+ GETPC());
59
+ }
24
+
60
+
25
+# Neon load/store single structure to one lane
61
+ env->pstate |= PSTATE_ALLINT;
26
+%imm1_5_p1 5:1 !function=plus1
27
+%imm1_6_p1 6:1 !function=plus1
28
+
29
+VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 00 n:2 reg_idx:3 align:1 rm:4 \
30
+ vd=%vd_dp size=0 stride=1
31
+VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 01 n:2 reg_idx:2 align:2 rm:4 \
32
+ vd=%vd_dp size=1 stride=%imm1_5_p1
33
+VLDST_single 1111 0100 1 . l:1 0 rn:4 .... 10 n:2 reg_idx:1 align:3 rm:4 \
34
+ vd=%vd_dp size=2 stride=%imm1_6_p1
35
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/translate-neon.inc.c
38
+++ b/target/arm/translate-neon.inc.c
39
@@ -XXX,XX +XXX,XX @@
40
* It might be possible to convert it to a standalone .c file eventually.
41
*/
42
43
+static inline int plus1(DisasContext *s, int x)
44
+{
45
+ return x + 1;
46
+}
62
+}
47
+
63
+
48
/* Include the generated Neon decoder */
64
static void daif_check(CPUARMState *env, uint32_t op,
49
#include "decode-neon-dp.inc.c"
65
uint32_t imm, uintptr_t ra)
50
#include "decode-neon-ls.inc.c"
66
{
51
@@ -XXX,XX +XXX,XX @@ static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a)
67
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
52
68
index XXXXXXX..XXXXXXX 100644
69
--- a/target/arm/tcg/translate-a64.c
70
+++ b/target/arm/tcg/translate-a64.c
71
@@ -XXX,XX +XXX,XX @@ static bool trans_MSR_i_DAIFCLEAR(DisasContext *s, arg_i *a)
53
return true;
72
return true;
54
}
73
}
55
+
74
56
+static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a)
75
+static bool trans_MSR_i_ALLINT(DisasContext *s, arg_i *a)
57
+{
76
+{
58
+ /* Neon load/store single structure to one lane */
77
+ if (!dc_isar_feature(aa64_nmi, s) || s->current_el == 0) {
59
+ int reg;
60
+ int nregs = a->n + 1;
61
+ int vd = a->vd;
62
+ TCGv_i32 addr, tmp;
63
+
64
+ if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
65
+ return false;
78
+ return false;
66
+ }
79
+ }
67
+
80
+
68
+ /* UNDEF accesses to D16-D31 if they don't exist */
81
+ if (a->imm == 0) {
69
+ if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) {
82
+ clear_pstate_bits(PSTATE_ALLINT);
70
+ return false;
83
+ } else if (s->current_el > 1) {
84
+ set_pstate_bits(PSTATE_ALLINT);
85
+ } else {
86
+ gen_helper_msr_set_allint_el1(tcg_env);
71
+ }
87
+ }
72
+
88
+
73
+ /* Catch the UNDEF cases. This is unavoidably a bit messy. */
89
+ /* Exit the cpu loop to re-evaluate pending IRQs. */
74
+ switch (nregs) {
90
+ s->base.is_jmp = DISAS_UPDATE_EXIT;
75
+ case 1:
76
+ if (((a->align & (1 << a->size)) != 0) ||
77
+ (a->size == 2 && ((a->align & 3) == 1 || (a->align & 3) == 2))) {
78
+ return false;
79
+ }
80
+ break;
81
+ case 3:
82
+ if ((a->align & 1) != 0) {
83
+ return false;
84
+ }
85
+ /* fall through */
86
+ case 2:
87
+ if (a->size == 2 && (a->align & 2) != 0) {
88
+ return false;
89
+ }
90
+ break;
91
+ case 4:
92
+ if ((a->size == 2) && ((a->align & 3) == 3)) {
93
+ return false;
94
+ }
95
+ break;
96
+ default:
97
+ abort();
98
+ }
99
+ if ((vd + a->stride * (nregs - 1)) > 31) {
100
+ /*
101
+ * Attempts to write off the end of the register file are
102
+ * UNPREDICTABLE; we choose to UNDEF because otherwise we would
103
+ * access off the end of the array that holds the register data.
104
+ */
105
+ return false;
106
+ }
107
+
108
+ if (!vfp_access_check(s)) {
109
+ return true;
110
+ }
111
+
112
+ tmp = tcg_temp_new_i32();
113
+ addr = tcg_temp_new_i32();
114
+ load_reg_var(s, addr, a->rn);
115
+ /*
116
+ * TODO: if we implemented alignment exceptions, we should check
117
+ * addr against the alignment encoded in a->align here.
118
+ */
119
+ for (reg = 0; reg < nregs; reg++) {
120
+ if (a->l) {
121
+ gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s),
122
+ s->be_data | a->size);
123
+ neon_store_element(vd, a->reg_idx, a->size, tmp);
124
+ } else { /* Store */
125
+ neon_load_element(tmp, vd, a->reg_idx, a->size);
126
+ gen_aa32_st_i32(s, tmp, addr, get_mem_index(s),
127
+ s->be_data | a->size);
128
+ }
129
+ vd += a->stride;
130
+ tcg_gen_addi_i32(addr, addr, 1 << a->size);
131
+ }
132
+ tcg_temp_free_i32(addr);
133
+ tcg_temp_free_i32(tmp);
134
+
135
+ gen_neon_ldst_base_update(s, a->rm, a->rn, (1 << a->size) * nregs);
136
+
137
+ return true;
91
+ return true;
138
+}
92
+}
139
diff --git a/target/arm/translate.c b/target/arm/translate.c
93
+
140
index XXXXXXX..XXXXXXX 100644
94
static bool trans_MSR_i_SVCR(DisasContext *s, arg_MSR_i_SVCR *a)
141
--- a/target/arm/translate.c
142
+++ b/target/arm/translate.c
143
@@ -XXX,XX +XXX,XX @@ static void gen_neon_trn_u16(TCGv_i32 t0, TCGv_i32 t1)
144
tcg_temp_free_i32(rd);
145
}
146
147
-
148
-/* Translate a NEON load/store element instruction. Return nonzero if the
149
- instruction is invalid. */
150
-static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
151
-{
152
- int rd, rn, rm;
153
- int nregs;
154
- int stride;
155
- int size;
156
- int reg;
157
- int load;
158
- TCGv_i32 addr;
159
- TCGv_i32 tmp;
160
-
161
- if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
162
- return 1;
163
- }
164
-
165
- /* FIXME: this access check should not take precedence over UNDEF
166
- * for invalid encodings; we will generate incorrect syndrome information
167
- * for attempts to execute invalid vfp/neon encodings with FP disabled.
168
- */
169
- if (s->fp_excp_el) {
170
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
171
- syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
172
- return 0;
173
- }
174
-
175
- if (!s->vfp_enabled)
176
- return 1;
177
- VFP_DREG_D(rd, insn);
178
- rn = (insn >> 16) & 0xf;
179
- rm = insn & 0xf;
180
- load = (insn & (1 << 21)) != 0;
181
- if ((insn & (1 << 23)) == 0) {
182
- /* Load store all elements -- handled already by decodetree */
183
- return 1;
184
- } else {
185
- size = (insn >> 10) & 3;
186
- if (size == 3) {
187
- /* Load single element to all lanes -- handled by decodetree */
188
- return 1;
189
- } else {
190
- /* Single element. */
191
- int idx = (insn >> 4) & 0xf;
192
- int reg_idx;
193
- switch (size) {
194
- case 0:
195
- reg_idx = (insn >> 5) & 7;
196
- stride = 1;
197
- break;
198
- case 1:
199
- reg_idx = (insn >> 6) & 3;
200
- stride = (insn & (1 << 5)) ? 2 : 1;
201
- break;
202
- case 2:
203
- reg_idx = (insn >> 7) & 1;
204
- stride = (insn & (1 << 6)) ? 2 : 1;
205
- break;
206
- default:
207
- abort();
208
- }
209
- nregs = ((insn >> 8) & 3) + 1;
210
- /* Catch the UNDEF cases. This is unavoidably a bit messy. */
211
- switch (nregs) {
212
- case 1:
213
- if (((idx & (1 << size)) != 0) ||
214
- (size == 2 && ((idx & 3) == 1 || (idx & 3) == 2))) {
215
- return 1;
216
- }
217
- break;
218
- case 3:
219
- if ((idx & 1) != 0) {
220
- return 1;
221
- }
222
- /* fall through */
223
- case 2:
224
- if (size == 2 && (idx & 2) != 0) {
225
- return 1;
226
- }
227
- break;
228
- case 4:
229
- if ((size == 2) && ((idx & 3) == 3)) {
230
- return 1;
231
- }
232
- break;
233
- default:
234
- abort();
235
- }
236
- if ((rd + stride * (nregs - 1)) > 31) {
237
- /* Attempts to write off the end of the register file
238
- * are UNPREDICTABLE; we choose to UNDEF because otherwise
239
- * the neon_load_reg() would write off the end of the array.
240
- */
241
- return 1;
242
- }
243
- tmp = tcg_temp_new_i32();
244
- addr = tcg_temp_new_i32();
245
- load_reg_var(s, addr, rn);
246
- for (reg = 0; reg < nregs; reg++) {
247
- if (load) {
248
- gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s),
249
- s->be_data | size);
250
- neon_store_element(rd, reg_idx, size, tmp);
251
- } else { /* Store */
252
- neon_load_element(tmp, rd, reg_idx, size);
253
- gen_aa32_st_i32(s, tmp, addr, get_mem_index(s),
254
- s->be_data | size);
255
- }
256
- rd += stride;
257
- tcg_gen_addi_i32(addr, addr, 1 << size);
258
- }
259
- tcg_temp_free_i32(addr);
260
- tcg_temp_free_i32(tmp);
261
- stride = nregs * (1 << size);
262
- }
263
- }
264
- if (rm != 15) {
265
- TCGv_i32 base;
266
-
267
- base = load_reg(s, rn);
268
- if (rm == 13) {
269
- tcg_gen_addi_i32(base, base, stride);
270
- } else {
271
- TCGv_i32 index;
272
- index = load_reg(s, rm);
273
- tcg_gen_add_i32(base, base, index);
274
- tcg_temp_free_i32(index);
275
- }
276
- store_reg(s, rn, base);
277
- }
278
- return 0;
279
-}
280
-
281
static inline void gen_neon_narrow(int size, TCGv_i32 dest, TCGv_i64 src)
282
{
95
{
283
switch (size) {
96
if (!dc_isar_feature(aa64_sme, s) || a->mask == 0) {
284
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
285
}
286
return;
287
}
288
- if ((insn & 0x0f100000) == 0x04000000) {
289
- /* NEON load/store. */
290
- if (disas_neon_ls_insn(s, insn)) {
291
- goto illegal_op;
292
- }
293
- return;
294
- }
295
if ((insn & 0x0e000f00) == 0x0c000100) {
296
if (arm_dc_feature(s, ARM_FEATURE_IWMMXT)) {
297
/* iWMMXt register transfer. */
298
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
299
}
300
break;
301
case 12:
302
- if ((insn & 0x01100000) == 0x01000000) {
303
- if (disas_neon_ls_insn(s, insn)) {
304
- goto illegal_op;
305
- }
306
- break;
307
- }
308
goto illegal_op;
309
default:
310
illegal_op:
311
--
97
--
312
2.20.1
98
2.34.1
313
314
diff view generated by jsdifflib
1
We're going to want at least some of the NeonGen* typedefs
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
for the refactored 32-bit Neon decoder, so move them all
3
to translate.h since it makes more sense to keep them in
4
one group.
5
2
3
Support ALLINT msr access as follow:
4
    mrs <xt>, ALLINT    // read allint
5
    msr ALLINT, <xt>    // write allint with imm
6
7
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20240407081733.3231820-6-ruanjinjie@huawei.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20200430181003.21682-23-peter.maydell@linaro.org
9
---
12
---
10
target/arm/translate.h | 17 +++++++++++++++++
13
target/arm/helper.c | 35 +++++++++++++++++++++++++++++++++++
11
target/arm/translate-a64.c | 17 -----------------
14
1 file changed, 35 insertions(+)
12
2 files changed, 17 insertions(+), 17 deletions(-)
13
15
14
diff --git a/target/arm/translate.h b/target/arm/translate.h
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate.h
18
--- a/target/arm/helper.c
17
+++ b/target/arm/translate.h
19
+++ b/target/arm/helper.c
18
@@ -XXX,XX +XXX,XX @@ typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t,
20
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo rme_mte_reginfo[] = {
19
typedef void GVecGen4Fn(unsigned, uint32_t, uint32_t, uint32_t,
21
.opc0 = 1, .opc1 = 6, .crn = 7, .crm = 14, .opc2 = 5,
20
uint32_t, uint32_t, uint32_t);
22
.access = PL3_W, .type = ARM_CP_NOP },
21
23
};
22
+/* Function prototype for gen_ functions for calling Neon helpers */
23
+typedef void NeonGenOneOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32);
24
+typedef void NeonGenTwoOpFn(TCGv_i32, TCGv_i32, TCGv_i32);
25
+typedef void NeonGenTwoOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32);
26
+typedef void NeonGenTwo64OpFn(TCGv_i64, TCGv_i64, TCGv_i64);
27
+typedef void NeonGenTwo64OpEnvFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i64);
28
+typedef void NeonGenNarrowFn(TCGv_i32, TCGv_i64);
29
+typedef void NeonGenNarrowEnvFn(TCGv_i32, TCGv_ptr, TCGv_i64);
30
+typedef void NeonGenWidenFn(TCGv_i64, TCGv_i32);
31
+typedef void NeonGenTwoSingleOPFn(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr);
32
+typedef void NeonGenTwoDoubleOPFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_ptr);
33
+typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64);
34
+typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr);
35
+typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32);
36
+typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr);
37
+typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp);
38
+
24
+
39
#endif /* TARGET_ARM_TRANSLATE_H */
25
+static void aa64_allint_write(CPUARMState *env, const ARMCPRegInfo *ri,
40
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
26
+ uint64_t value)
41
index XXXXXXX..XXXXXXX 100644
27
+{
42
--- a/target/arm/translate-a64.c
28
+ env->pstate = (env->pstate & ~PSTATE_ALLINT) | (value & PSTATE_ALLINT);
43
+++ b/target/arm/translate-a64.c
29
+}
44
@@ -XXX,XX +XXX,XX @@ typedef struct AArch64DecodeTable {
30
+
45
AArch64DecodeFn *disas_fn;
31
+static uint64_t aa64_allint_read(CPUARMState *env, const ARMCPRegInfo *ri)
46
} AArch64DecodeTable;
32
+{
47
33
+ return env->pstate & PSTATE_ALLINT;
48
-/* Function prototype for gen_ functions for calling Neon helpers */
34
+}
49
-typedef void NeonGenOneOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32);
35
+
50
-typedef void NeonGenTwoOpFn(TCGv_i32, TCGv_i32, TCGv_i32);
36
+static CPAccessResult aa64_allint_access(CPUARMState *env,
51
-typedef void NeonGenTwoOpEnvFn(TCGv_i32, TCGv_ptr, TCGv_i32, TCGv_i32);
37
+ const ARMCPRegInfo *ri, bool isread)
52
-typedef void NeonGenTwo64OpFn(TCGv_i64, TCGv_i64, TCGv_i64);
38
+{
53
-typedef void NeonGenTwo64OpEnvFn(TCGv_i64, TCGv_ptr, TCGv_i64, TCGv_i64);
39
+ if (!isread && arm_current_el(env) == 1 &&
54
-typedef void NeonGenNarrowFn(TCGv_i32, TCGv_i64);
40
+ (arm_hcrx_el2_eff(env) & HCRX_TALLINT)) {
55
-typedef void NeonGenNarrowEnvFn(TCGv_i32, TCGv_ptr, TCGv_i64);
41
+ return CP_ACCESS_TRAP_EL2;
56
-typedef void NeonGenWidenFn(TCGv_i64, TCGv_i32);
42
+ }
57
-typedef void NeonGenTwoSingleOPFn(TCGv_i32, TCGv_i32, TCGv_i32, TCGv_ptr);
43
+ return CP_ACCESS_OK;
58
-typedef void NeonGenTwoDoubleOPFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGv_ptr);
44
+}
59
-typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64);
45
+
60
-typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr);
46
+static const ARMCPRegInfo nmi_reginfo[] = {
61
-typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32);
47
+ { .name = "ALLINT", .state = ARM_CP_STATE_AA64,
62
-typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr);
48
+ .opc0 = 3, .opc1 = 0, .opc2 = 0, .crn = 4, .crm = 3,
63
-typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, MemOp);
49
+ .type = ARM_CP_NO_RAW,
64
-
50
+ .access = PL1_RW, .accessfn = aa64_allint_access,
65
/* initialize TCG globals. */
51
+ .fieldoffset = offsetof(CPUARMState, pstate),
66
void a64_translate_init(void)
52
+ .writefn = aa64_allint_write, .readfn = aa64_allint_read,
67
{
53
+ .resetfn = arm_cp_reset_ignore },
54
+};
55
#endif /* TARGET_AARCH64 */
56
57
static void define_pmu_regs(ARMCPU *cpu)
58
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
59
if (cpu_isar_feature(aa64_nv2, cpu)) {
60
define_arm_cp_regs(cpu, nv2_reginfo);
61
}
62
+
63
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
64
+ define_arm_cp_regs(cpu, nmi_reginfo);
65
+ }
66
#endif
67
68
if (cpu_isar_feature(any_predinv, cpu)) {
68
--
69
--
69
2.20.1
70
2.34.1
70
71
diff view generated by jsdifflib
1
We define ARMMMUIdx_Stage2 as being an MMU index which uses a QEMU
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
TLB. However we never actually use the TLB -- all stage 2 lookups
3
are done by direct calls to get_phys_addr_lpae() followed by a
4
physical address load via address_space_ld*().
5
2
6
Remove Stage2 from the list of ARM MMU indexes which correspond to
3
This only implements the external delivery method via the GICv3.
7
real core MMU indexes, and instead put it in the set of "NOTLB" ARM
8
MMU indexes.
9
4
10
This allows us to drop NB_MMU_MODES to 11. It also means we can
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
11
safely add support for the ARMv8.3-TTS2UXN extension, which adds
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
permission bits to the stage 2 descriptors which define execute
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
permission separatel for EL0 and EL1; supporting that while keeping
8
Message-id: 20240407081733.3231820-7-ruanjinjie@huawei.com
14
Stage2 in a QEMU TLB would require us to use separate TLBs for
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
"Stage2 for an EL0 access" and "Stage2 for an EL1 access", which is a
10
---
16
lot of extra complication given we aren't even using the QEMU TLB.
11
target/arm/cpu-qom.h | 5 +-
12
target/arm/cpu.h | 6 ++
13
target/arm/internals.h | 18 +++++
14
target/arm/cpu.c | 147 ++++++++++++++++++++++++++++++++++++++---
15
target/arm/helper.c | 33 +++++++--
16
5 files changed, 193 insertions(+), 16 deletions(-)
17
17
18
In the process of updating the comment on our MMU index use,
18
diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
19
fix a couple of other minor errors:
20
* NS EL2 EL2&0 was missing from the list in the comment
21
* some text hadn't been updated from when we bumped NB_MMU_MODES
22
above 8
23
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
26
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
27
Message-id: 20200330210400.11724-2-peter.maydell@linaro.org
28
---
29
target/arm/cpu-param.h | 2 +-
30
target/arm/cpu.h | 21 +++++---
31
target/arm/helper.c | 112 ++++-------------------------------------
32
3 files changed, 27 insertions(+), 108 deletions(-)
33
34
diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h
35
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
36
--- a/target/arm/cpu-param.h
20
--- a/target/arm/cpu-qom.h
37
+++ b/target/arm/cpu-param.h
21
+++ b/target/arm/cpu-qom.h
38
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ DECLARE_CLASS_CHECKERS(AArch64CPUClass, AARCH64_CPU,
39
# define TARGET_PAGE_BITS_MIN 10
23
#define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU
40
#endif
24
#define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX)
41
25
42
-#define NB_MMU_MODES 12
26
-/* Meanings of the ARMCPU object's four inbound GPIO lines */
43
+#define NB_MMU_MODES 11
27
+/* Meanings of the ARMCPU object's seven inbound GPIO lines */
44
28
#define ARM_CPU_IRQ 0
45
#endif
29
#define ARM_CPU_FIQ 1
30
#define ARM_CPU_VIRQ 2
31
#define ARM_CPU_VFIQ 3
32
+#define ARM_CPU_NMI 4
33
+#define ARM_CPU_VINMI 5
34
+#define ARM_CPU_VFNMI 6
35
36
/* For M profile, some registers are banked secure vs non-secure;
37
* these are represented as a 2-element array where the first element
46
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
38
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
47
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
48
--- a/target/arm/cpu.h
40
--- a/target/arm/cpu.h
49
+++ b/target/arm/cpu.h
41
+++ b/target/arm/cpu.h
50
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
42
@@ -XXX,XX +XXX,XX @@
51
* handling via the TLB. The only way to do a stage 1 translation without
43
#define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */
52
* the immediate stage 2 translation is via the ATS or AT system insns,
44
#define EXCP_VSERR 24
53
* which can be slow-pathed and always do a page table walk.
45
#define EXCP_GPC 25 /* v9 Granule Protection Check Fault */
54
+ * The only use of stage 2 translations is either as part of an s1+2
46
+#define EXCP_NMI 26
55
+ * lookup or when loading the descriptors during a stage 1 page table walk,
47
+#define EXCP_VINMI 27
56
+ * and in both those cases we don't use the TLB.
48
+#define EXCP_VFNMI 28
57
* 4. we can also safely fold together the "32 bit EL3" and "64 bit EL3"
49
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
58
* translation regimes, because they map reasonably well to each other
50
59
* and they can't both be active at the same time.
51
#define ARMV7M_EXCP_RESET 1
60
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
52
@@ -XXX,XX +XXX,XX @@
61
* NS EL1 EL1&0 stage 1+2 (aka NS PL1)
53
#define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_EXT_2
62
* NS EL1 EL1&0 stage 1+2 +PAN
54
#define CPU_INTERRUPT_VFIQ CPU_INTERRUPT_TGT_EXT_3
63
* NS EL0 EL2&0
55
#define CPU_INTERRUPT_VSERR CPU_INTERRUPT_TGT_INT_0
64
+ * NS EL2 EL2&0
56
+#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_4
65
* NS EL2 EL2&0 +PAN
57
+#define CPU_INTERRUPT_VINMI CPU_INTERRUPT_TGT_EXT_0
66
* NS EL2 (aka NS PL2)
58
+#define CPU_INTERRUPT_VFNMI CPU_INTERRUPT_TGT_INT_1
67
* S EL0 EL1&0 (aka S PL0)
59
68
* S EL1 EL1&0 (not used if EL3 is 32 bit)
60
/* The usual mapping for an AArch64 system register to its AArch32
69
* S EL1 EL1&0 +PAN
61
* counterpart is for the 32 bit world to have access to the lower
70
* S EL3 (aka S PL1)
62
diff --git a/target/arm/internals.h b/target/arm/internals.h
71
- * NS EL1&0 stage 2
63
index XXXXXXX..XXXXXXX 100644
64
--- a/target/arm/internals.h
65
+++ b/target/arm/internals.h
66
@@ -XXX,XX +XXX,XX @@ void arm_cpu_update_virq(ARMCPU *cpu);
67
*/
68
void arm_cpu_update_vfiq(ARMCPU *cpu);
69
70
+/**
71
+ * arm_cpu_update_vinmi: Update CPU_INTERRUPT_VINMI bit in cs->interrupt_request
72
+ *
73
+ * Update the CPU_INTERRUPT_VINMI bit in cs->interrupt_request, following
74
+ * a change to either the input VNMI line from the GIC or the HCRX_EL2.VINMI.
75
+ * Must be called with the BQL held.
76
+ */
77
+void arm_cpu_update_vinmi(ARMCPU *cpu);
78
+
79
+/**
80
+ * arm_cpu_update_vfnmi: Update CPU_INTERRUPT_VFNMI bit in cs->interrupt_request
81
+ *
82
+ * Update the CPU_INTERRUPT_VFNMI bit in cs->interrupt_request, following
83
+ * a change to the HCRX_EL2.VFNMI.
84
+ * Must be called with the BQL held.
85
+ */
86
+void arm_cpu_update_vfnmi(ARMCPU *cpu);
87
+
88
/**
89
* arm_cpu_update_vserr: Update CPU_INTERRUPT_VSERR bit
72
*
90
*
73
- * for a total of 12 different mmu_idx.
91
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
74
+ * for a total of 11 different mmu_idx.
92
index XXXXXXX..XXXXXXX 100644
75
*
93
--- a/target/arm/cpu.c
76
* R profile CPUs have an MPU, but can use the same set of MMU indexes
94
+++ b/target/arm/cpu.c
77
* as A profile. They only need to distinguish NS EL0 and NS EL1 (and
95
@@ -XXX,XX +XXX,XX @@ void arm_restore_state_to_opc(CPUState *cs,
78
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
96
}
79
* are not quite the same -- different CPU types (most notably M profile
97
#endif /* CONFIG_TCG */
80
* vs A/R profile) would like to use MMU indexes with different semantics,
98
81
* but since we don't ever need to use all of those in a single CPU we
99
+/*
82
- * can avoid setting NB_MMU_MODES to more than 8. The lower bits of
100
+ * With SCTLR_ELx.NMI == 0, IRQ with Superpriority is masked identically with
83
+ * can avoid having to set NB_MMU_MODES to "total number of A profile MMU
101
+ * IRQ without Superpriority. Moreover, if the GIC is configured so that
84
+ * modes + total number of M profile MMU modes". The lower bits of
102
+ * FEAT_GICv3_NMI is only set if FEAT_NMI is set, then we won't ever see
85
* ARMMMUIdx are the core TLB mmu index, and the higher bits are always
103
+ * CPU_INTERRUPT_*NMI anyway. So we might as well accept NMI here
86
* the same for any particular CPU.
104
+ * unconditionally.
87
* Variables of type ARMMUIdx are always full values, and the core
105
+ */
88
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx {
106
static bool arm_cpu_has_work(CPUState *cs)
89
ARMMMUIdx_SE10_1_PAN = 9 | ARM_MMU_IDX_A,
107
{
90
ARMMMUIdx_SE3 = 10 | ARM_MMU_IDX_A,
108
ARMCPU *cpu = ARM_CPU(cs);
91
109
@@ -XXX,XX +XXX,XX @@ static bool arm_cpu_has_work(CPUState *cs)
92
- ARMMMUIdx_Stage2 = 11 | ARM_MMU_IDX_A,
110
return (cpu->power_state != PSCI_OFF)
93
-
111
&& cs->interrupt_request &
112
(CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD
113
+ | CPU_INTERRUPT_NMI | CPU_INTERRUPT_VINMI | CPU_INTERRUPT_VFNMI
114
| CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ | CPU_INTERRUPT_VSERR
115
| CPU_INTERRUPT_EXITTB);
116
}
117
@@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
118
CPUARMState *env = cpu_env(cs);
119
bool pstate_unmasked;
120
bool unmasked = false;
121
+ bool allIntMask = false;
122
94
/*
123
/*
95
* These are not allocated TLBs and are used only for AT system
124
* Don't take exceptions if they target a lower EL.
96
* instructions or for the first stage of an S12 page table walk.
125
@@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
97
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx {
126
return false;
98
ARMMMUIdx_Stage1_E0 = 0 | ARM_MMU_IDX_NOTLB,
127
}
99
ARMMMUIdx_Stage1_E1 = 1 | ARM_MMU_IDX_NOTLB,
128
100
ARMMMUIdx_Stage1_E1_PAN = 2 | ARM_MMU_IDX_NOTLB,
129
+ if (cpu_isar_feature(aa64_nmi, env_archcpu(env)) &&
130
+ env->cp15.sctlr_el[target_el] & SCTLR_NMI && cur_el == target_el) {
131
+ allIntMask = env->pstate & PSTATE_ALLINT ||
132
+ ((env->cp15.sctlr_el[target_el] & SCTLR_SPINTMASK) &&
133
+ (env->pstate & PSTATE_SP));
134
+ }
135
+
136
switch (excp_idx) {
137
+ case EXCP_NMI:
138
+ pstate_unmasked = !allIntMask;
139
+ break;
140
+
141
+ case EXCP_VINMI:
142
+ if (!(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) {
143
+ /* VINMIs are only taken when hypervized. */
144
+ return false;
145
+ }
146
+ return !allIntMask;
147
+ case EXCP_VFNMI:
148
+ if (!(hcr_el2 & HCR_FMO) || (hcr_el2 & HCR_TGE)) {
149
+ /* VFNMIs are only taken when hypervized. */
150
+ return false;
151
+ }
152
+ return !allIntMask;
153
case EXCP_FIQ:
154
- pstate_unmasked = !(env->daif & PSTATE_F);
155
+ pstate_unmasked = (!(env->daif & PSTATE_F)) && (!allIntMask);
156
break;
157
158
case EXCP_IRQ:
159
- pstate_unmasked = !(env->daif & PSTATE_I);
160
+ pstate_unmasked = (!(env->daif & PSTATE_I)) && (!allIntMask);
161
break;
162
163
case EXCP_VFIQ:
164
@@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
165
/* VFIQs are only taken when hypervized. */
166
return false;
167
}
168
- return !(env->daif & PSTATE_F);
169
+ return !(env->daif & PSTATE_F) && (!allIntMask);
170
case EXCP_VIRQ:
171
if (!(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) {
172
/* VIRQs are only taken when hypervized. */
173
return false;
174
}
175
- return !(env->daif & PSTATE_I);
176
+ return !(env->daif & PSTATE_I) && (!allIntMask);
177
case EXCP_VSERR:
178
if (!(hcr_el2 & HCR_AMO) || (hcr_el2 & HCR_TGE)) {
179
/* VIRQs are only taken when hypervized. */
180
@@ -XXX,XX +XXX,XX @@ static bool arm_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
181
182
/* The prioritization of interrupts is IMPLEMENTATION DEFINED. */
183
184
+ if (cpu_isar_feature(aa64_nmi, env_archcpu(env)) &&
185
+ (arm_sctlr(env, cur_el) & SCTLR_NMI)) {
186
+ if (interrupt_request & CPU_INTERRUPT_NMI) {
187
+ excp_idx = EXCP_NMI;
188
+ target_el = arm_phys_excp_target_el(cs, excp_idx, cur_el, secure);
189
+ if (arm_excp_unmasked(cs, excp_idx, target_el,
190
+ cur_el, secure, hcr_el2)) {
191
+ goto found;
192
+ }
193
+ }
194
+ if (interrupt_request & CPU_INTERRUPT_VINMI) {
195
+ excp_idx = EXCP_VINMI;
196
+ target_el = 1;
197
+ if (arm_excp_unmasked(cs, excp_idx, target_el,
198
+ cur_el, secure, hcr_el2)) {
199
+ goto found;
200
+ }
201
+ }
202
+ if (interrupt_request & CPU_INTERRUPT_VFNMI) {
203
+ excp_idx = EXCP_VFNMI;
204
+ target_el = 1;
205
+ if (arm_excp_unmasked(cs, excp_idx, target_el,
206
+ cur_el, secure, hcr_el2)) {
207
+ goto found;
208
+ }
209
+ }
210
+ } else {
211
+ /*
212
+ * NMI disabled: interrupts with superpriority are handled
213
+ * as if they didn't have it
214
+ */
215
+ if (interrupt_request & CPU_INTERRUPT_NMI) {
216
+ interrupt_request |= CPU_INTERRUPT_HARD;
217
+ }
218
+ if (interrupt_request & CPU_INTERRUPT_VINMI) {
219
+ interrupt_request |= CPU_INTERRUPT_VIRQ;
220
+ }
221
+ if (interrupt_request & CPU_INTERRUPT_VFNMI) {
222
+ interrupt_request |= CPU_INTERRUPT_VFIQ;
223
+ }
224
+ }
225
+
226
if (interrupt_request & CPU_INTERRUPT_FIQ) {
227
excp_idx = EXCP_FIQ;
228
target_el = arm_phys_excp_target_el(cs, excp_idx, cur_el, secure);
229
@@ -XXX,XX +XXX,XX @@ void arm_cpu_update_virq(ARMCPU *cpu)
230
CPUARMState *env = &cpu->env;
231
CPUState *cs = CPU(cpu);
232
233
- bool new_state = (env->cp15.hcr_el2 & HCR_VI) ||
234
+ bool new_state = ((arm_hcr_el2_eff(env) & HCR_VI) &&
235
+ !(arm_hcrx_el2_eff(env) & HCRX_VINMI)) ||
236
(env->irq_line_state & CPU_INTERRUPT_VIRQ);
237
238
if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VIRQ) != 0)) {
239
@@ -XXX,XX +XXX,XX @@ void arm_cpu_update_vfiq(ARMCPU *cpu)
240
CPUARMState *env = &cpu->env;
241
CPUState *cs = CPU(cpu);
242
243
- bool new_state = (env->cp15.hcr_el2 & HCR_VF) ||
244
+ bool new_state = ((arm_hcr_el2_eff(env) & HCR_VF) &&
245
+ !(arm_hcrx_el2_eff(env) & HCRX_VFNMI)) ||
246
(env->irq_line_state & CPU_INTERRUPT_VFIQ);
247
248
if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VFIQ) != 0)) {
249
@@ -XXX,XX +XXX,XX @@ void arm_cpu_update_vfiq(ARMCPU *cpu)
250
}
251
}
252
253
+void arm_cpu_update_vinmi(ARMCPU *cpu)
254
+{
101
+ /*
255
+ /*
102
+ * Not allocated a TLB: used only for second stage of an S12 page
256
+ * Update the interrupt level for VINMI, which is the logical OR of
103
+ * table walk, or for descriptor loads during first stage of an S1
257
+ * the HCRX_EL2.VINMI bit and the input line level from the GIC.
104
+ * page table walk. Note that if we ever want to have a TLB for this
105
+ * then various TLB flush insns which currently are no-ops or flush
106
+ * only stage 1 MMU indexes will need to change to flush stage 2.
107
+ */
258
+ */
108
+ ARMMMUIdx_Stage2 = 3 | ARM_MMU_IDX_NOTLB,
259
+ CPUARMState *env = &cpu->env;
109
260
+ CPUState *cs = CPU(cpu);
261
+
262
+ bool new_state = ((arm_hcr_el2_eff(env) & HCR_VI) &&
263
+ (arm_hcrx_el2_eff(env) & HCRX_VINMI)) ||
264
+ (env->irq_line_state & CPU_INTERRUPT_VINMI);
265
+
266
+ if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VINMI) != 0)) {
267
+ if (new_state) {
268
+ cpu_interrupt(cs, CPU_INTERRUPT_VINMI);
269
+ } else {
270
+ cpu_reset_interrupt(cs, CPU_INTERRUPT_VINMI);
271
+ }
272
+ }
273
+}
274
+
275
+void arm_cpu_update_vfnmi(ARMCPU *cpu)
276
+{
277
+ /*
278
+ * Update the interrupt level for VFNMI, which is the HCRX_EL2.VFNMI bit.
279
+ */
280
+ CPUARMState *env = &cpu->env;
281
+ CPUState *cs = CPU(cpu);
282
+
283
+ bool new_state = (arm_hcr_el2_eff(env) & HCR_VF) &&
284
+ (arm_hcrx_el2_eff(env) & HCRX_VFNMI);
285
+
286
+ if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VFNMI) != 0)) {
287
+ if (new_state) {
288
+ cpu_interrupt(cs, CPU_INTERRUPT_VFNMI);
289
+ } else {
290
+ cpu_reset_interrupt(cs, CPU_INTERRUPT_VFNMI);
291
+ }
292
+ }
293
+}
294
+
295
void arm_cpu_update_vserr(ARMCPU *cpu)
296
{
110
/*
297
/*
111
* M-profile.
298
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level)
112
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdxBit {
299
[ARM_CPU_IRQ] = CPU_INTERRUPT_HARD,
113
TO_CORE_BIT(SE10_1),
300
[ARM_CPU_FIQ] = CPU_INTERRUPT_FIQ,
114
TO_CORE_BIT(SE10_1_PAN),
301
[ARM_CPU_VIRQ] = CPU_INTERRUPT_VIRQ,
115
TO_CORE_BIT(SE3),
302
- [ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ
116
- TO_CORE_BIT(Stage2),
303
+ [ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ,
117
304
+ [ARM_CPU_NMI] = CPU_INTERRUPT_NMI,
118
TO_CORE_BIT(MUser),
305
+ [ARM_CPU_VINMI] = CPU_INTERRUPT_VINMI,
119
TO_CORE_BIT(MPriv),
306
};
307
308
if (!arm_feature(env, ARM_FEATURE_EL2) &&
309
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level)
310
case ARM_CPU_VFIQ:
311
arm_cpu_update_vfiq(cpu);
312
break;
313
+ case ARM_CPU_VINMI:
314
+ arm_cpu_update_vinmi(cpu);
315
+ break;
316
case ARM_CPU_IRQ:
317
case ARM_CPU_FIQ:
318
+ case ARM_CPU_NMI:
319
if (level) {
320
cpu_interrupt(cs, mask[irq]);
321
} else {
322
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj)
323
#else
324
/* Our inbound IRQ and FIQ lines */
325
if (kvm_enabled()) {
326
- /* VIRQ and VFIQ are unused with KVM but we add them to maintain
327
- * the same interface as non-KVM CPUs.
328
+ /*
329
+ * VIRQ, VFIQ, NMI, VINMI are unused with KVM but we add
330
+ * them to maintain the same interface as non-KVM CPUs.
331
*/
332
- qdev_init_gpio_in(DEVICE(cpu), arm_cpu_kvm_set_irq, 4);
333
+ qdev_init_gpio_in(DEVICE(cpu), arm_cpu_kvm_set_irq, 6);
334
} else {
335
- qdev_init_gpio_in(DEVICE(cpu), arm_cpu_set_irq, 4);
336
+ qdev_init_gpio_in(DEVICE(cpu), arm_cpu_set_irq, 6);
337
}
338
339
qdev_init_gpio_out(DEVICE(cpu), cpu->gt_timer_outputs,
120
diff --git a/target/arm/helper.c b/target/arm/helper.c
340
diff --git a/target/arm/helper.c b/target/arm/helper.c
121
index XXXXXXX..XXXXXXX 100644
341
index XXXXXXX..XXXXXXX 100644
122
--- a/target/arm/helper.c
342
--- a/target/arm/helper.c
123
+++ b/target/arm/helper.c
343
+++ b/target/arm/helper.c
124
@@ -XXX,XX +XXX,XX @@ static void tlbiall_nsnh_write(CPUARMState *env, const ARMCPRegInfo *ri,
344
@@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
125
tlb_flush_by_mmuidx(cs,
345
* and the state of the input lines from the GIC. (This requires
126
ARMMMUIdxBit_E10_1 |
346
* that we have the BQL, which is done by marking the
127
ARMMMUIdxBit_E10_1_PAN |
347
* reginfo structs as ARM_CP_IO.)
128
- ARMMMUIdxBit_E10_0 |
348
- * Note that if a write to HCR pends a VIRQ or VFIQ it is never
129
- ARMMMUIdxBit_Stage2);
349
- * possible for it to be taken immediately, because VIRQ and
130
+ ARMMMUIdxBit_E10_0);
350
- * VFIQ are masked unless running at EL0 or EL1, and HCR
351
- * can only be written at EL2.
352
+ * Note that if a write to HCR pends a VIRQ or VFIQ or VINMI or
353
+ * VFNMI, it is never possible for it to be taken immediately
354
+ * because VIRQ, VFIQ, VINMI and VFNMI are masked unless running
355
+ * at EL0 or EL1, and HCR can only be written at EL2.
356
*/
357
g_assert(bql_locked());
358
arm_cpu_update_virq(cpu);
359
arm_cpu_update_vfiq(cpu);
360
arm_cpu_update_vserr(cpu);
361
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
362
+ arm_cpu_update_vinmi(cpu);
363
+ arm_cpu_update_vfnmi(cpu);
364
+ }
131
}
365
}
132
366
133
static void tlbiall_nsnh_is_write(CPUARMState *env, const ARMCPRegInfo *ri,
367
static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
134
@@ -XXX,XX +XXX,XX @@ static void tlbiall_nsnh_is_write(CPUARMState *env, const ARMCPRegInfo *ri,
368
@@ -XXX,XX +XXX,XX @@ static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri,
135
tlb_flush_by_mmuidx_all_cpus_synced(cs,
369
136
ARMMMUIdxBit_E10_1 |
370
/* Clear RES0 bits. */
137
ARMMMUIdxBit_E10_1_PAN |
371
env->cp15.hcrx_el2 = value & valid_mask;
138
- ARMMMUIdxBit_E10_0 |
372
+
139
- ARMMMUIdxBit_Stage2);
373
+ /*
140
+ ARMMMUIdxBit_E10_0);
374
+ * Updates to VINMI and VFNMI require us to update the status of
375
+ * virtual NMI, which are the logical OR of these bits
376
+ * and the state of the input lines from the GIC. (This requires
377
+ * that we have the BQL, which is done by marking the
378
+ * reginfo structs as ARM_CP_IO.)
379
+ * Note that if a write to HCRX pends a VINMI or VFNMI it is never
380
+ * possible for it to be taken immediately, because VINMI and
381
+ * VFNMI are masked unless running at EL0 or EL1, and HCRX
382
+ * can only be written at EL2.
383
+ */
384
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
385
+ g_assert(bql_locked());
386
+ arm_cpu_update_vinmi(cpu);
387
+ arm_cpu_update_vfnmi(cpu);
388
+ }
141
}
389
}
142
390
143
-static void tlbiipas2_write(CPUARMState *env, const ARMCPRegInfo *ri,
391
static CPAccessResult access_hxen(CPUARMState *env, const ARMCPRegInfo *ri,
144
- uint64_t value)
392
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_hxen(CPUARMState *env, const ARMCPRegInfo *ri,
145
-{
393
146
- /* Invalidate by IPA. This has to invalidate any structures that
394
static const ARMCPRegInfo hcrx_el2_reginfo = {
147
- * contain only stage 2 translation information, but does not need
395
.name = "HCRX_EL2", .state = ARM_CP_STATE_AA64,
148
- * to apply to structures that contain combined stage 1 and stage 2
396
+ .type = ARM_CP_IO,
149
- * translation information.
397
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 2,
150
- * This must NOP if EL2 isn't implemented or SCR_EL3.NS is zero.
398
.access = PL2_RW, .writefn = hcrx_write, .accessfn = access_hxen,
151
- */
399
.nv2_redirect_offset = 0xa0,
152
- CPUState *cs = env_cpu(env);
400
@@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs)
153
- uint64_t pageaddr;
401
[EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault",
154
-
402
[EXCP_VSERR] = "Virtual SERR",
155
- if (!arm_feature(env, ARM_FEATURE_EL2) || !(env->cp15.scr_el3 & SCR_NS)) {
403
[EXCP_GPC] = "Granule Protection Check",
156
- return;
404
+ [EXCP_NMI] = "NMI",
157
- }
405
+ [EXCP_VINMI] = "Virtual IRQ NMI",
158
-
406
+ [EXCP_VFNMI] = "Virtual FIQ NMI",
159
- pageaddr = sextract64(value << 12, 0, 40);
407
};
160
-
408
161
- tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_Stage2);
409
if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
162
-}
163
-
164
-static void tlbiipas2_is_write(CPUARMState *env, const ARMCPRegInfo *ri,
165
- uint64_t value)
166
-{
167
- CPUState *cs = env_cpu(env);
168
- uint64_t pageaddr;
169
-
170
- if (!arm_feature(env, ARM_FEATURE_EL2) || !(env->cp15.scr_el3 & SCR_NS)) {
171
- return;
172
- }
173
-
174
- pageaddr = sextract64(value << 12, 0, 40);
175
-
176
- tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr,
177
- ARMMMUIdxBit_Stage2);
178
-}
179
180
static void tlbiall_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri,
181
uint64_t value)
182
@@ -XXX,XX +XXX,XX @@ static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri,
183
tlb_flush_by_mmuidx(cs,
184
ARMMMUIdxBit_E10_1 |
185
ARMMMUIdxBit_E10_1_PAN |
186
- ARMMMUIdxBit_E10_0 |
187
- ARMMMUIdxBit_Stage2);
188
+ ARMMMUIdxBit_E10_0);
189
raw_write(env, ri, value);
190
}
191
}
192
@@ -XXX,XX +XXX,XX @@ static int alle1_tlbmask(CPUARMState *env)
193
return ARMMMUIdxBit_SE10_1 |
194
ARMMMUIdxBit_SE10_1_PAN |
195
ARMMMUIdxBit_SE10_0;
196
- } else if (arm_feature(env, ARM_FEATURE_EL2)) {
197
- return ARMMMUIdxBit_E10_1 |
198
- ARMMMUIdxBit_E10_1_PAN |
199
- ARMMMUIdxBit_E10_0 |
200
- ARMMMUIdxBit_Stage2;
201
} else {
202
return ARMMMUIdxBit_E10_1 |
203
ARMMMUIdxBit_E10_1_PAN |
204
@@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae3is_write(CPUARMState *env, const ARMCPRegInfo *ri,
205
ARMMMUIdxBit_SE3);
206
}
207
208
-static void tlbi_aa64_ipas2e1_write(CPUARMState *env, const ARMCPRegInfo *ri,
209
- uint64_t value)
210
-{
211
- /* Invalidate by IPA. This has to invalidate any structures that
212
- * contain only stage 2 translation information, but does not need
213
- * to apply to structures that contain combined stage 1 and stage 2
214
- * translation information.
215
- * This must NOP if EL2 isn't implemented or SCR_EL3.NS is zero.
216
- */
217
- ARMCPU *cpu = env_archcpu(env);
218
- CPUState *cs = CPU(cpu);
219
- uint64_t pageaddr;
220
-
221
- if (!arm_feature(env, ARM_FEATURE_EL2) || !(env->cp15.scr_el3 & SCR_NS)) {
222
- return;
223
- }
224
-
225
- pageaddr = sextract64(value << 12, 0, 48);
226
-
227
- tlb_flush_page_by_mmuidx(cs, pageaddr, ARMMMUIdxBit_Stage2);
228
-}
229
-
230
-static void tlbi_aa64_ipas2e1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
231
- uint64_t value)
232
-{
233
- CPUState *cs = env_cpu(env);
234
- uint64_t pageaddr;
235
-
236
- if (!arm_feature(env, ARM_FEATURE_EL2) || !(env->cp15.scr_el3 & SCR_NS)) {
237
- return;
238
- }
239
-
240
- pageaddr = sextract64(value << 12, 0, 48);
241
-
242
- tlb_flush_page_by_mmuidx_all_cpus_synced(cs, pageaddr,
243
- ARMMMUIdxBit_Stage2);
244
-}
245
-
246
static CPAccessResult aa64_zva_access(CPUARMState *env, const ARMCPRegInfo *ri,
247
bool isread)
248
{
249
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
250
.writefn = tlbi_aa64_vae1_write },
251
{ .name = "TLBI_IPAS2E1IS", .state = ARM_CP_STATE_AA64,
252
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 1,
253
- .access = PL2_W, .type = ARM_CP_NO_RAW,
254
- .writefn = tlbi_aa64_ipas2e1is_write },
255
+ .access = PL2_W, .type = ARM_CP_NOP },
256
{ .name = "TLBI_IPAS2LE1IS", .state = ARM_CP_STATE_AA64,
257
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 5,
258
- .access = PL2_W, .type = ARM_CP_NO_RAW,
259
- .writefn = tlbi_aa64_ipas2e1is_write },
260
+ .access = PL2_W, .type = ARM_CP_NOP },
261
{ .name = "TLBI_ALLE1IS", .state = ARM_CP_STATE_AA64,
262
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 3, .opc2 = 4,
263
.access = PL2_W, .type = ARM_CP_NO_RAW,
264
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
265
.writefn = tlbi_aa64_alle1is_write },
266
{ .name = "TLBI_IPAS2E1", .state = ARM_CP_STATE_AA64,
267
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 1,
268
- .access = PL2_W, .type = ARM_CP_NO_RAW,
269
- .writefn = tlbi_aa64_ipas2e1_write },
270
+ .access = PL2_W, .type = ARM_CP_NOP },
271
{ .name = "TLBI_IPAS2LE1", .state = ARM_CP_STATE_AA64,
272
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 5,
273
- .access = PL2_W, .type = ARM_CP_NO_RAW,
274
- .writefn = tlbi_aa64_ipas2e1_write },
275
+ .access = PL2_W, .type = ARM_CP_NOP },
276
{ .name = "TLBI_ALLE1", .state = ARM_CP_STATE_AA64,
277
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 7, .opc2 = 4,
278
.access = PL2_W, .type = ARM_CP_NO_RAW,
279
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
280
.writefn = tlbimva_hyp_is_write },
281
{ .name = "TLBIIPAS2",
282
.cp = 15, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 1,
283
- .type = ARM_CP_NO_RAW, .access = PL2_W,
284
- .writefn = tlbiipas2_write },
285
+ .type = ARM_CP_NOP, .access = PL2_W },
286
{ .name = "TLBIIPAS2IS",
287
.cp = 15, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 1,
288
- .type = ARM_CP_NO_RAW, .access = PL2_W,
289
- .writefn = tlbiipas2_is_write },
290
+ .type = ARM_CP_NOP, .access = PL2_W },
291
{ .name = "TLBIIPAS2L",
292
.cp = 15, .opc1 = 4, .crn = 8, .crm = 4, .opc2 = 5,
293
- .type = ARM_CP_NO_RAW, .access = PL2_W,
294
- .writefn = tlbiipas2_write },
295
+ .type = ARM_CP_NOP, .access = PL2_W },
296
{ .name = "TLBIIPAS2LIS",
297
.cp = 15, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 5,
298
- .type = ARM_CP_NO_RAW, .access = PL2_W,
299
- .writefn = tlbiipas2_is_write },
300
+ .type = ARM_CP_NOP, .access = PL2_W },
301
/* 32 bit cache operations */
302
{ .name = "ICIALLUIS", .cp = 15, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0,
303
.type = ARM_CP_NOP, .access = PL1_W, .accessfn = aa64_cacheop_pou_access },
304
--
410
--
305
2.20.1
411
2.34.1
306
307
diff view generated by jsdifflib
1
Convert the Neon VQADD/VQSUB insns in the 3-reg-same grouping
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
to decodetree.
3
2
3
According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt
4
with superpriority is always IRQ, never FIQ, so handle NMI same as IRQ in
5
arm_phys_excp_target_el().
6
7
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20240407081733.3231820-8-ruanjinjie@huawei.com
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20200430181003.21682-19-peter.maydell@linaro.org
7
---
12
---
8
target/arm/neon-dp.decode | 6 ++++++
13
target/arm/helper.c | 1 +
9
target/arm/translate-neon.inc.c | 15 +++++++++++++++
14
1 file changed, 1 insertion(+)
10
target/arm/translate.c | 14 ++------------
11
3 files changed, 23 insertions(+), 12 deletions(-)
12
15
13
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/neon-dp.decode
18
--- a/target/arm/helper.c
16
+++ b/target/arm/neon-dp.decode
19
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
18
@3same .... ... . . . size:2 .... .... .... . q:1 . . .... \
21
hcr_el2 = arm_hcr_el2_eff(env);
19
&3same vm=%vm_dp vn=%vn_dp vd=%vd_dp
22
switch (excp_idx) {
20
23
case EXCP_IRQ:
21
+VQADD_S_3s 1111 001 0 0 . .. .... .... 0000 . . . 1 .... @3same
24
+ case EXCP_NMI:
22
+VQADD_U_3s 1111 001 1 0 . .. .... .... 0000 . . . 1 .... @3same
25
scr = ((env->cp15.scr_el3 & SCR_IRQ) == SCR_IRQ);
23
+
26
hcr = hcr_el2 & HCR_IMO;
24
@3same_logic .... ... . . . .. .... .... .... . q:1 .. .... \
27
break;
25
&3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0
26
27
@@ -XXX,XX +XXX,XX @@ VBSL_3s 1111 001 1 0 . 01 .... .... 0001 ... 1 .... @3same_logic
28
VBIT_3s 1111 001 1 0 . 10 .... .... 0001 ... 1 .... @3same_logic
29
VBIF_3s 1111 001 1 0 . 11 .... .... 0001 ... 1 .... @3same_logic
30
31
+VQSUB_S_3s 1111 001 0 0 . .. .... .... 0010 . . . 1 .... @3same
32
+VQSUB_U_3s 1111 001 1 0 . .. .... .... 0010 . . . 1 .... @3same
33
+
34
VCGT_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 0 .... @3same
35
VCGT_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 0 .... @3same
36
VCGE_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 1 .... @3same
37
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/target/arm/translate-neon.inc.c
40
+++ b/target/arm/translate-neon.inc.c
41
@@ -XXX,XX +XXX,XX @@ static void gen_VTST_3s(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
42
tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, &cmtst_op[vece]);
43
}
44
DO_3SAME_NO_SZ_3(VTST, gen_VTST_3s)
45
+
46
+#define DO_3SAME_GVEC4(INSN, OPARRAY) \
47
+ static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \
48
+ uint32_t rn_ofs, uint32_t rm_ofs, \
49
+ uint32_t oprsz, uint32_t maxsz) \
50
+ { \
51
+ tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc), \
52
+ rn_ofs, rm_ofs, oprsz, maxsz, &OPARRAY[vece]); \
53
+ } \
54
+ DO_3SAME(INSN, gen_##INSN##_3s)
55
+
56
+DO_3SAME_GVEC4(VQADD_S, sqadd_op)
57
+DO_3SAME_GVEC4(VQADD_U, uqadd_op)
58
+DO_3SAME_GVEC4(VQSUB_S, sqsub_op)
59
+DO_3SAME_GVEC4(VQSUB_U, uqsub_op)
60
diff --git a/target/arm/translate.c b/target/arm/translate.c
61
index XXXXXXX..XXXXXXX 100644
62
--- a/target/arm/translate.c
63
+++ b/target/arm/translate.c
64
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
65
}
66
return 1;
67
68
- case NEON_3R_VQADD:
69
- tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc),
70
- rn_ofs, rm_ofs, vec_size, vec_size,
71
- (u ? uqadd_op : sqadd_op) + size);
72
- return 0;
73
-
74
- case NEON_3R_VQSUB:
75
- tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc),
76
- rn_ofs, rm_ofs, vec_size, vec_size,
77
- (u ? uqsub_op : sqsub_op) + size);
78
- return 0;
79
-
80
case NEON_3R_VMUL: /* VMUL */
81
if (u) {
82
/* Polynomial case allows only P8. */
83
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
84
case NEON_3R_VTST_VCEQ:
85
case NEON_3R_VCGT:
86
case NEON_3R_VCGE:
87
+ case NEON_3R_VQADD:
88
+ case NEON_3R_VQSUB:
89
/* Already handled by decodetree */
90
return 1;
91
}
92
--
28
--
93
2.20.1
29
2.34.1
94
95
diff view generated by jsdifflib
1
The ARMv8.2-TTS2UXN feature extends the XN field in stage 2
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
translation table descriptors from just bit [54] to bits [54:53],
3
allowing stage 2 to control execution permissions separately for EL0
4
and EL1. Implement the new semantics of the XN field and enable
5
the feature for our 'max' CPU.
6
2
3
Add IS and FS bit in ISR_EL1 and handle the read. With CPU_INTERRUPT_NMI or
4
CPU_INTERRUPT_VINMI, both CPSR_I and ISR_IS must be set. With
5
CPU_INTERRUPT_VFNMI, both CPSR_F and ISR_FS must be set.
6
7
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20240407081733.3231820-9-ruanjinjie@huawei.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20200330210400.11724-5-peter.maydell@linaro.org
11
---
12
---
12
target/arm/cpu.h | 15 +++++++++++++++
13
target/arm/cpu.h | 2 ++
13
target/arm/cpu.c | 1 +
14
target/arm/helper.c | 13 +++++++++++++
14
target/arm/cpu64.c | 2 ++
15
2 files changed, 15 insertions(+)
15
target/arm/helper.c | 37 +++++++++++++++++++++++++++++++------
16
4 files changed, 49 insertions(+), 6 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 @@ static inline bool isar_feature_aa32_ccidx(const ARMISARegisters *id)
21
@@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu);
23
return FIELD_EX32(id->id_mmfr4, ID_MMFR4, CCIDX) != 0;
22
#define CPSR_N (1U << 31)
24
}
23
#define CPSR_NZCV (CPSR_N | CPSR_Z | CPSR_C | CPSR_V)
25
24
#define CPSR_AIF (CPSR_A | CPSR_I | CPSR_F)
26
+static inline bool isar_feature_aa32_tts2uxn(const ARMISARegisters *id)
25
+#define ISR_FS (1U << 9)
27
+{
26
+#define ISR_IS (1U << 10)
28
+ return FIELD_EX32(id->id_mmfr4, ID_MMFR4, XNX) != 0;
27
29
+}
28
#define CPSR_IT (CPSR_IT_0_1 | CPSR_IT_2_7)
30
+
29
#define CACHED_CPSR_BITS (CPSR_T | CPSR_AIF | CPSR_GE | CPSR_IT | CPSR_Q \
31
/*
32
* 64-bit feature tests via id registers.
33
*/
34
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ccidx(const ARMISARegisters *id)
35
return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, CCIDX) != 0;
36
}
37
38
+static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id)
39
+{
40
+ return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) != 0;
41
+}
42
+
43
/*
44
* Feature tests for "does this exist in either 32-bit or 64-bit?"
45
*/
46
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_any_ccidx(const ARMISARegisters *id)
47
return isar_feature_aa64_ccidx(id) || isar_feature_aa32_ccidx(id);
48
}
49
50
+static inline bool isar_feature_any_tts2uxn(const ARMISARegisters *id)
51
+{
52
+ return isar_feature_aa64_tts2uxn(id) || isar_feature_aa32_tts2uxn(id);
53
+}
54
+
55
/*
56
* Forward to the above feature tests given an ARMCPU pointer.
57
*/
58
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/cpu.c
61
+++ b/target/arm/cpu.c
62
@@ -XXX,XX +XXX,XX @@ static void arm_max_initfn(Object *obj)
63
t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* AA32HPD */
64
t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
65
t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* TTCNP */
66
+ t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* TTS2UXN */
67
cpu->isar.id_mmfr4 = t;
68
}
69
#endif
70
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
71
index XXXXXXX..XXXXXXX 100644
72
--- a/target/arm/cpu64.c
73
+++ b/target/arm/cpu64.c
74
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
75
t = FIELD_DP64(t, ID_AA64MMFR1, VH, 1);
76
t = FIELD_DP64(t, ID_AA64MMFR1, PAN, 2); /* ATS1E1 */
77
t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* VMID16 */
78
+ t = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* TTS2UXN */
79
cpu->isar.id_aa64mmfr1 = t;
80
81
t = cpu->isar.id_aa64mmfr2;
82
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
83
u = FIELD_DP32(u, ID_MMFR4, HPDS, 1); /* AA32HPD */
84
u = FIELD_DP32(u, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */
85
u = FIELD_DP32(u, ID_MMFR4, CNP, 1); /* TTCNP */
86
+ u = FIELD_DP32(u, ID_MMFR4, XNX, 1); /* TTS2UXN */
87
cpu->isar.id_mmfr4 = u;
88
89
u = cpu->isar.id_aa64dfr0;
90
diff --git a/target/arm/helper.c b/target/arm/helper.c
30
diff --git a/target/arm/helper.c b/target/arm/helper.c
91
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
92
--- a/target/arm/helper.c
32
--- a/target/arm/helper.c
93
+++ b/target/arm/helper.c
33
+++ b/target/arm/helper.c
94
@@ -XXX,XX +XXX,XX @@ simple_ap_to_rw_prot(CPUARMState *env, ARMMMUIdx mmu_idx, int ap)
34
@@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri)
95
*
35
if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) {
96
* @env: CPUARMState
36
ret |= CPSR_I;
97
* @s2ap: The 2-bit stage2 access permissions (S2AP)
37
}
98
- * @xn: XN (execute-never) bit
38
+ if (cs->interrupt_request & CPU_INTERRUPT_VINMI) {
99
+ * @xn: XN (execute-never) bits
39
+ ret |= ISR_IS;
100
+ * @s1_is_el0: true if this is S2 of an S1+2 walk for EL0
40
+ ret |= CPSR_I;
101
*/
41
+ }
102
-static int get_S2prot(CPUARMState *env, int s2ap, int xn)
42
} else {
103
+static int get_S2prot(CPUARMState *env, int s2ap, int xn, bool s1_is_el0)
43
if (cs->interrupt_request & CPU_INTERRUPT_HARD) {
104
{
44
ret |= CPSR_I;
105
int prot = 0;
45
}
106
46
+
107
@@ -XXX,XX +XXX,XX @@ static int get_S2prot(CPUARMState *env, int s2ap, int xn)
47
+ if (cs->interrupt_request & CPU_INTERRUPT_NMI) {
108
if (s2ap & 2) {
48
+ ret |= ISR_IS;
109
prot |= PAGE_WRITE;
49
+ ret |= CPSR_I;
50
+ }
110
}
51
}
111
- if (!xn) {
52
112
- if (arm_el_is_aa64(env, 2) || prot & PAGE_READ) {
53
if (hcr_el2 & HCR_FMO) {
113
+
54
if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) {
114
+ if (cpu_isar_feature(any_tts2uxn, env_archcpu(env))) {
55
ret |= CPSR_F;
115
+ switch (xn) {
56
}
116
+ case 0:
57
+ if (cs->interrupt_request & CPU_INTERRUPT_VFNMI) {
117
prot |= PAGE_EXEC;
58
+ ret |= ISR_FS;
118
+ break;
59
+ ret |= CPSR_F;
119
+ case 1:
120
+ if (s1_is_el0) {
121
+ prot |= PAGE_EXEC;
122
+ }
123
+ break;
124
+ case 2:
125
+ break;
126
+ case 3:
127
+ if (!s1_is_el0) {
128
+ prot |= PAGE_EXEC;
129
+ }
130
+ break;
131
+ default:
132
+ g_assert_not_reached();
133
+ }
60
+ }
134
+ } else {
135
+ if (!extract32(xn, 1, 1)) {
136
+ if (arm_el_is_aa64(env, 2) || prot & PAGE_READ) {
137
+ prot |= PAGE_EXEC;
138
+ }
139
}
140
}
141
return prot;
142
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
143
}
144
145
ap = extract32(attrs, 4, 2);
146
- xn = extract32(attrs, 12, 1);
147
148
if (mmu_idx == ARMMMUIdx_Stage2) {
149
ns = true;
150
- *prot = get_S2prot(env, ap, xn);
151
+ xn = extract32(attrs, 11, 2);
152
+ *prot = get_S2prot(env, ap, xn, s1_is_el0);
153
} else {
61
} else {
154
ns = extract32(attrs, 3, 1);
62
if (cs->interrupt_request & CPU_INTERRUPT_FIQ) {
155
+ xn = extract32(attrs, 12, 1);
63
ret |= CPSR_F;
156
pxn = extract32(attrs, 11, 1);
157
*prot = get_S1prot(env, mmu_idx, aarch64, ap, ns, xn, pxn);
158
}
159
--
64
--
160
2.20.1
65
2.34.1
161
162
diff view generated by jsdifflib
1
For ARMv8.2-TTS2UXN, the stage 2 page table walk wants to know
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
whether the stage 1 access is for EL0 or not, because whether
3
exec permission is given can depend on whether this is an EL0
4
or EL1 access. Add a new argument to get_phys_addr_lpae() so
5
the call sites can pass this information in.
6
2
7
Since get_phys_addr_lpae() doesn't already have a doc comment,
3
Set or clear PSTATE.ALLINT on taking an exception to ELx according to the
8
add one so we have a place to put the documentation of the
4
SCTLR_ELx.SPINTMASK bit.
9
semantics of the new s1_is_el0 argument.
10
5
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20240407081733.3231820-10-ruanjinjie@huawei.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20200330210400.11724-4-peter.maydell@linaro.org
15
---
11
---
16
target/arm/helper.c | 29 ++++++++++++++++++++++++++++-
12
target/arm/helper.c | 8 ++++++++
17
1 file changed, 28 insertions(+), 1 deletion(-)
13
1 file changed, 8 insertions(+)
18
14
19
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
20
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/helper.c
17
--- a/target/arm/helper.c
22
+++ b/target/arm/helper.c
18
+++ b/target/arm/helper.c
23
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
24
25
static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
26
MMUAccessType access_type, ARMMMUIdx mmu_idx,
27
+ bool s1_is_el0,
28
hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,
29
target_ulong *page_size_ptr,
30
ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs);
31
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
32
}
20
}
33
34
ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, ARMMMUIdx_Stage2,
35
+ false,
36
&s2pa, &txattrs, &s2prot, &s2size, fi,
37
pcacheattrs);
38
if (ret) {
39
@@ -XXX,XX +XXX,XX @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va,
40
};
41
}
42
43
+/**
44
+ * get_phys_addr_lpae: perform one stage of page table walk, LPAE format
45
+ *
46
+ * Returns false if the translation was successful. Otherwise, phys_ptr, attrs,
47
+ * prot and page_size may not be filled in, and the populated fsr value provides
48
+ * information on why the translation aborted, in the format of a long-format
49
+ * DFSR/IFSR fault register, with the following caveats:
50
+ * * the WnR bit is never set (the caller must do this).
51
+ *
52
+ * @env: CPUARMState
53
+ * @address: virtual address to get physical address for
54
+ * @access_type: MMU_DATA_LOAD, MMU_DATA_STORE or MMU_INST_FETCH
55
+ * @mmu_idx: MMU index indicating required translation regime
56
+ * @s1_is_el0: if @mmu_idx is ARMMMUIdx_Stage2 (so this is a stage 2 page table
57
+ * walk), must be true if this is stage 2 of a stage 1+2 walk for an
58
+ * EL0 access). If @mmu_idx is anything else, @s1_is_el0 is ignored.
59
+ * @phys_ptr: set to the physical address corresponding to the virtual address
60
+ * @attrs: set to the memory transaction attributes to use
61
+ * @prot: set to the permissions for the page containing phys_ptr
62
+ * @page_size_ptr: set to the size of the page containing phys_ptr
63
+ * @fi: set to fault info if the translation fails
64
+ * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes
65
+ */
66
static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
67
MMUAccessType access_type, ARMMMUIdx mmu_idx,
68
+ bool s1_is_el0,
69
hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,
70
target_ulong *page_size_ptr,
71
ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
72
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
73
74
/* S1 is done. Now do S2 translation. */
75
ret = get_phys_addr_lpae(env, ipa, access_type, ARMMMUIdx_Stage2,
76
+ mmu_idx == ARMMMUIdx_E10_0,
77
phys_ptr, attrs, &s2_prot,
78
page_size, fi,
79
cacheattrs != NULL ? &cacheattrs2 : NULL);
80
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
81
}
21
}
82
22
83
if (regime_using_lpae_format(env, mmu_idx)) {
23
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
84
- return get_phys_addr_lpae(env, address, access_type, mmu_idx,
24
+ if (!(env->cp15.sctlr_el[new_el] & SCTLR_SPINTMASK)) {
85
+ return get_phys_addr_lpae(env, address, access_type, mmu_idx, false,
25
+ new_mode |= PSTATE_ALLINT;
86
phys_ptr, attrs, prot, page_size,
26
+ } else {
87
fi, cacheattrs);
27
+ new_mode &= ~PSTATE_ALLINT;
88
} else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) {
28
+ }
29
+ }
30
+
31
pstate_write(env, PSTATE_DAIF | new_mode);
32
env->aarch64 = true;
33
aarch64_restore_sp(env, new_el);
89
--
34
--
90
2.20.1
35
2.34.1
91
92
diff view generated by jsdifflib
1
Convert the Neon comparison ops in the 3-reg-same grouping
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
to decodetree.
3
2
3
Augment the GICv3's QOM device interface by adding one
4
new set of sysbus IRQ line, to signal NMI to each CPU.
5
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20240407081733.3231820-11-ruanjinjie@huawei.com
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20200430181003.21682-18-peter.maydell@linaro.org
7
---
11
---
8
target/arm/neon-dp.decode | 8 ++++++++
12
include/hw/intc/arm_gic_common.h | 2 ++
9
target/arm/translate-neon.inc.c | 22 ++++++++++++++++++++++
13
include/hw/intc/arm_gicv3_common.h | 2 ++
10
target/arm/translate.c | 23 +++--------------------
14
hw/intc/arm_gicv3_common.c | 6 ++++++
11
3 files changed, 33 insertions(+), 20 deletions(-)
15
3 files changed, 10 insertions(+)
12
16
13
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
17
diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_common.h
14
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/neon-dp.decode
19
--- a/include/hw/intc/arm_gic_common.h
16
+++ b/target/arm/neon-dp.decode
20
+++ b/include/hw/intc/arm_gic_common.h
17
@@ -XXX,XX +XXX,XX @@ VBSL_3s 1111 001 1 0 . 01 .... .... 0001 ... 1 .... @3same_logic
21
@@ -XXX,XX +XXX,XX @@ struct GICState {
18
VBIT_3s 1111 001 1 0 . 10 .... .... 0001 ... 1 .... @3same_logic
22
qemu_irq parent_fiq[GIC_NCPU];
19
VBIF_3s 1111 001 1 0 . 11 .... .... 0001 ... 1 .... @3same_logic
23
qemu_irq parent_virq[GIC_NCPU];
20
24
qemu_irq parent_vfiq[GIC_NCPU];
21
+VCGT_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 0 .... @3same
25
+ qemu_irq parent_nmi[GIC_NCPU];
22
+VCGT_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 0 .... @3same
26
+ qemu_irq parent_vnmi[GIC_NCPU];
23
+VCGE_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 1 .... @3same
27
qemu_irq maintenance_irq[GIC_NCPU];
24
+VCGE_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 1 .... @3same
28
25
+
29
/* GICD_CTLR; for a GIC with the security extensions the NS banked version
26
VMAX_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 0 .... @3same
30
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
27
VMAX_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 0 .... @3same
28
VMIN_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 1 .... @3same
29
@@ -XXX,XX +XXX,XX @@ VMIN_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 1 .... @3same
30
31
VADD_3s 1111 001 0 0 . .. .... .... 1000 . . . 0 .... @3same
32
VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same
33
+
34
+VTST_3s 1111 001 0 0 . .. .... .... 1000 . . . 1 .... @3same
35
+VCEQ_3s 1111 001 1 0 . .. .... .... 1000 . . . 1 .... @3same
36
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
37
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/translate-neon.inc.c
32
--- a/include/hw/intc/arm_gicv3_common.h
39
+++ b/target/arm/translate-neon.inc.c
33
+++ b/include/hw/intc/arm_gicv3_common.h
40
@@ -XXX,XX +XXX,XX @@ DO_3SAME_NO_SZ_3(VMAX_S, tcg_gen_gvec_smax)
34
@@ -XXX,XX +XXX,XX @@ struct GICv3CPUState {
41
DO_3SAME_NO_SZ_3(VMAX_U, tcg_gen_gvec_umax)
35
qemu_irq parent_fiq;
42
DO_3SAME_NO_SZ_3(VMIN_S, tcg_gen_gvec_smin)
36
qemu_irq parent_virq;
43
DO_3SAME_NO_SZ_3(VMIN_U, tcg_gen_gvec_umin)
37
qemu_irq parent_vfiq;
44
+
38
+ qemu_irq parent_nmi;
45
+#define DO_3SAME_CMP(INSN, COND) \
39
+ qemu_irq parent_vnmi;
46
+ static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \
40
47
+ uint32_t rn_ofs, uint32_t rm_ofs, \
41
/* Redistributor */
48
+ uint32_t oprsz, uint32_t maxsz) \
42
uint32_t level; /* Current IRQ level */
49
+ { \
43
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
50
+ tcg_gen_gvec_cmp(COND, vece, rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz); \
51
+ } \
52
+ DO_3SAME_NO_SZ_3(INSN, gen_##INSN##_3s)
53
+
54
+DO_3SAME_CMP(VCGT_S, TCG_COND_GT)
55
+DO_3SAME_CMP(VCGT_U, TCG_COND_GTU)
56
+DO_3SAME_CMP(VCGE_S, TCG_COND_GE)
57
+DO_3SAME_CMP(VCGE_U, TCG_COND_GEU)
58
+DO_3SAME_CMP(VCEQ, TCG_COND_EQ)
59
+
60
+static void gen_VTST_3s(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
61
+ uint32_t rm_ofs, uint32_t oprsz, uint32_t maxsz)
62
+{
63
+ tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz, &cmtst_op[vece]);
64
+}
65
+DO_3SAME_NO_SZ_3(VTST, gen_VTST_3s)
66
diff --git a/target/arm/translate.c b/target/arm/translate.c
67
index XXXXXXX..XXXXXXX 100644
44
index XXXXXXX..XXXXXXX 100644
68
--- a/target/arm/translate.c
45
--- a/hw/intc/arm_gicv3_common.c
69
+++ b/target/arm/translate.c
46
+++ b/hw/intc/arm_gicv3_common.c
70
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
47
@@ -XXX,XX +XXX,XX @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler,
71
u ? &mls_op[size] : &mla_op[size]);
48
for (i = 0; i < s->num_cpu; i++) {
72
return 0;
49
sysbus_init_irq(sbd, &s->cpu[i].parent_vfiq);
73
50
}
74
- case NEON_3R_VTST_VCEQ:
51
+ for (i = 0; i < s->num_cpu; i++) {
75
- if (u) { /* VCEQ */
52
+ sysbus_init_irq(sbd, &s->cpu[i].parent_nmi);
76
- tcg_gen_gvec_cmp(TCG_COND_EQ, size, rd_ofs, rn_ofs, rm_ofs,
53
+ }
77
- vec_size, vec_size);
54
+ for (i = 0; i < s->num_cpu; i++) {
78
- } else { /* VTST */
55
+ sysbus_init_irq(sbd, &s->cpu[i].parent_vnmi);
79
- tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs,
56
+ }
80
- vec_size, vec_size, &cmtst_op[size]);
57
81
- }
58
memory_region_init_io(&s->iomem_dist, OBJECT(s), ops, s,
82
- return 0;
59
"gicv3_dist", 0x10000);
83
-
84
- case NEON_3R_VCGT:
85
- tcg_gen_gvec_cmp(u ? TCG_COND_GTU : TCG_COND_GT, size,
86
- rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size);
87
- return 0;
88
-
89
- case NEON_3R_VCGE:
90
- tcg_gen_gvec_cmp(u ? TCG_COND_GEU : TCG_COND_GE, size,
91
- rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size);
92
- return 0;
93
-
94
case NEON_3R_VSHL:
95
/* Note the operation is vshl vd,vm,vn */
96
tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size,
97
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
98
case NEON_3R_LOGIC:
99
case NEON_3R_VMAX:
100
case NEON_3R_VMIN:
101
+ case NEON_3R_VTST_VCEQ:
102
+ case NEON_3R_VCGT:
103
+ case NEON_3R_VCGE:
104
/* Already handled by decodetree */
105
return 1;
106
}
107
--
60
--
108
2.20.1
61
2.34.1
109
110
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Fix typo xlnx-ve -> xlnx-versal.
3
Wire the new NMI and VINMI interrupt line from the GIC to each CPU if it
4
is not GICv2.
4
5
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20240407081733.3231820-12-ruanjinjie@huawei.com
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
9
Message-id: 20200427181649.26851-4-edgar.iglesias@gmail.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
hw/arm/xlnx-versal-virt.c | 2 +-
11
hw/arm/virt.c | 10 +++++++++-
13
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 9 insertions(+), 1 deletion(-)
14
13
15
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
14
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/xlnx-versal-virt.c
16
--- a/hw/arm/virt.c
18
+++ b/hw/arm/xlnx-versal-virt.c
17
+++ b/hw/arm/virt.c
19
@@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine)
18
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
20
psci_conduit = QEMU_PSCI_CONDUIT_SMC;
19
20
/* Wire the outputs from each CPU's generic timer and the GICv3
21
* maintenance interrupt signal to the appropriate GIC PPI inputs,
22
- * and the GIC's IRQ/FIQ/VIRQ/VFIQ interrupt outputs to the CPU's inputs.
23
+ * and the GIC's IRQ/FIQ/VIRQ/VFIQ/NMI/VINMI interrupt outputs to the
24
+ * CPU's inputs.
25
*/
26
for (i = 0; i < smp_cpus; i++) {
27
DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
28
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
29
qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ));
30
sysbus_connect_irq(gicbusdev, i + 3 * smp_cpus,
31
qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ));
32
+
33
+ if (vms->gic_version != VIRT_GIC_VERSION_2) {
34
+ sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus,
35
+ qdev_get_gpio_in(cpudev, ARM_CPU_NMI));
36
+ sysbus_connect_irq(gicbusdev, i + 5 * smp_cpus,
37
+ qdev_get_gpio_in(cpudev, ARM_CPU_VINMI));
38
+ }
21
}
39
}
22
40
23
- sysbus_init_child_obj(OBJECT(machine), "xlnx-ve", &s->soc,
41
fdt_add_gic_node(vms);
24
+ sysbus_init_child_obj(OBJECT(machine), "xlnx-versal", &s->soc,
25
sizeof(s->soc), TYPE_XLNX_VERSAL);
26
object_property_set_link(OBJECT(&s->soc), OBJECT(machine->ram),
27
"ddr", &error_abort);
28
--
42
--
29
2.20.1
43
2.34.1
30
31
diff view generated by jsdifflib
1
The access_type argument to get_phys_addr_lpae() is an MMUAccessType;
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
use the enum constant MMU_DATA_LOAD rather than a literal 0 when we
3
call it in S1_ptw_translate().
4
2
3
According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt
4
with superpriority is always IRQ, never FIQ, so the NMI exception trap entry
5
behave like IRQ. And VINMI(vIRQ with Superpriority) can be raised from the
6
GIC or come from the hcrx_el2.HCRX_VINMI bit, VFNMI(vFIQ with Superpriority)
7
come from the hcrx_el2.HCRX_VFNMI bit.
8
9
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20240407081733.3231820-13-ruanjinjie@huawei.com
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20200330210400.11724-3-peter.maydell@linaro.org
9
---
14
---
10
target/arm/helper.c | 5 +++--
15
target/arm/helper.c | 3 +++
11
1 file changed, 3 insertions(+), 2 deletions(-)
16
1 file changed, 3 insertions(+)
12
17
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
20
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
21
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
22
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
18
pcacheattrs = &cacheattrs;
23
break;
19
}
24
case EXCP_IRQ:
20
25
case EXCP_VIRQ:
21
- ret = get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_Stage2, &s2pa,
26
+ case EXCP_NMI:
22
- &txattrs, &s2prot, &s2size, fi, pcacheattrs);
27
+ case EXCP_VINMI:
23
+ ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, ARMMMUIdx_Stage2,
28
addr += 0x80;
24
+ &s2pa, &txattrs, &s2prot, &s2size, fi,
29
break;
25
+ pcacheattrs);
30
case EXCP_FIQ:
26
if (ret) {
31
case EXCP_VFIQ:
27
assert(fi->type != ARMFault_None);
32
+ case EXCP_VFNMI:
28
fi->s2addr = addr;
33
addr += 0x100;
34
break;
35
case EXCP_VSERR:
29
--
36
--
30
2.20.1
37
2.34.1
31
32
diff view generated by jsdifflib
1
Convert the Neon logic ops in the 3-reg-same grouping to decodetree.
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
Note that for the logic ops the 'size' field forms part of their
3
decode and the actual operations are always bitwise.
4
2
3
Add a property has-nmi to the GICv3 device, and use this to set
4
the NMI bit in the GICD_TYPER register. This isn't visible to
5
guests yet because the property defaults to false and we won't
6
set it in the board code until we've landed all of the changes
7
needed to implement FEAT_GICV3_NMI.
8
9
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20240407081733.3231820-14-ruanjinjie@huawei.com
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20200430181003.21682-16-peter.maydell@linaro.org
8
---
14
---
9
target/arm/neon-dp.decode | 12 +++++++++++
15
hw/intc/gicv3_internal.h | 1 +
10
target/arm/translate-neon.inc.c | 19 +++++++++++++++++
16
include/hw/intc/arm_gicv3_common.h | 1 +
11
target/arm/translate.c | 38 +--------------------------------
17
hw/intc/arm_gicv3_common.c | 1 +
12
3 files changed, 32 insertions(+), 37 deletions(-)
18
hw/intc/arm_gicv3_dist.c | 2 ++
19
4 files changed, 5 insertions(+)
13
20
14
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
21
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
15
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/neon-dp.decode
23
--- a/hw/intc/gicv3_internal.h
17
+++ b/target/arm/neon-dp.decode
24
+++ b/hw/intc/gicv3_internal.h
18
@@ -XXX,XX +XXX,XX @@
25
@@ -XXX,XX +XXX,XX @@
19
@3same .... ... . . . size:2 .... .... .... . q:1 . . .... \
26
#define GICD_CTLR_E1NWF (1U << 7)
20
&3same vm=%vm_dp vn=%vn_dp vd=%vd_dp
27
#define GICD_CTLR_RWP (1U << 31)
21
28
22
+@3same_logic .... ... . . . .. .... .... .... . q:1 .. .... \
29
+#define GICD_TYPER_NMI_SHIFT 9
23
+ &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp size=0
30
#define GICD_TYPER_LPIS_SHIFT 17
24
+
31
25
+VAND_3s 1111 001 0 0 . 00 .... .... 0001 ... 1 .... @3same_logic
32
/* 16 bits EventId */
26
+VBIC_3s 1111 001 0 0 . 01 .... .... 0001 ... 1 .... @3same_logic
33
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
27
+VORR_3s 1111 001 0 0 . 10 .... .... 0001 ... 1 .... @3same_logic
28
+VORN_3s 1111 001 0 0 . 11 .... .... 0001 ... 1 .... @3same_logic
29
+VEOR_3s 1111 001 1 0 . 00 .... .... 0001 ... 1 .... @3same_logic
30
+VBSL_3s 1111 001 1 0 . 01 .... .... 0001 ... 1 .... @3same_logic
31
+VBIT_3s 1111 001 1 0 . 10 .... .... 0001 ... 1 .... @3same_logic
32
+VBIF_3s 1111 001 1 0 . 11 .... .... 0001 ... 1 .... @3same_logic
33
+
34
VADD_3s 1111 001 0 0 . .. .... .... 1000 . . . 0 .... @3same
35
VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same
36
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
37
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/translate-neon.inc.c
35
--- a/include/hw/intc/arm_gicv3_common.h
39
+++ b/target/arm/translate-neon.inc.c
36
+++ b/include/hw/intc/arm_gicv3_common.h
40
@@ -XXX,XX +XXX,XX @@ static bool do_3same(DisasContext *s, arg_3same *a, GVecGen3Fn fn)
37
@@ -XXX,XX +XXX,XX @@ struct GICv3State {
41
38
uint32_t num_irq;
42
DO_3SAME(VADD, tcg_gen_gvec_add)
39
uint32_t revision;
43
DO_3SAME(VSUB, tcg_gen_gvec_sub)
40
bool lpi_enable;
44
+DO_3SAME(VAND, tcg_gen_gvec_and)
41
+ bool nmi_support;
45
+DO_3SAME(VBIC, tcg_gen_gvec_andc)
42
bool security_extn;
46
+DO_3SAME(VORR, tcg_gen_gvec_or)
43
bool force_8bit_prio;
47
+DO_3SAME(VORN, tcg_gen_gvec_orc)
44
bool irq_reset_nonsecure;
48
+DO_3SAME(VEOR, tcg_gen_gvec_xor)
45
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
49
+
50
+/* These insns are all gvec_bitsel but with the inputs in various orders. */
51
+#define DO_3SAME_BITSEL(INSN, O1, O2, O3) \
52
+ static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \
53
+ uint32_t rn_ofs, uint32_t rm_ofs, \
54
+ uint32_t oprsz, uint32_t maxsz) \
55
+ { \
56
+ tcg_gen_gvec_bitsel(vece, rd_ofs, O1, O2, O3, oprsz, maxsz); \
57
+ } \
58
+ DO_3SAME(INSN, gen_##INSN##_3s)
59
+
60
+DO_3SAME_BITSEL(VBSL, rd_ofs, rn_ofs, rm_ofs)
61
+DO_3SAME_BITSEL(VBIT, rm_ofs, rn_ofs, rd_ofs)
62
+DO_3SAME_BITSEL(VBIF, rm_ofs, rd_ofs, rn_ofs)
63
diff --git a/target/arm/translate.c b/target/arm/translate.c
64
index XXXXXXX..XXXXXXX 100644
46
index XXXXXXX..XXXXXXX 100644
65
--- a/target/arm/translate.c
47
--- a/hw/intc/arm_gicv3_common.c
66
+++ b/target/arm/translate.c
48
+++ b/hw/intc/arm_gicv3_common.c
67
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
49
@@ -XXX,XX +XXX,XX @@ static Property arm_gicv3_common_properties[] = {
68
}
50
DEFINE_PROP_UINT32("num-irq", GICv3State, num_irq, 32),
69
return 1;
51
DEFINE_PROP_UINT32("revision", GICv3State, revision, 3),
70
52
DEFINE_PROP_BOOL("has-lpi", GICv3State, lpi_enable, 0),
71
- case NEON_3R_LOGIC: /* Logic ops. */
53
+ DEFINE_PROP_BOOL("has-nmi", GICv3State, nmi_support, 0),
72
- switch ((u << 2) | size) {
54
DEFINE_PROP_BOOL("has-security-extensions", GICv3State, security_extn, 0),
73
- case 0: /* VAND */
55
/*
74
- tcg_gen_gvec_and(0, rd_ofs, rn_ofs, rm_ofs,
56
* Compatibility property: force 8 bits of physical priority, even
75
- vec_size, vec_size);
57
diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c
76
- break;
58
index XXXXXXX..XXXXXXX 100644
77
- case 1: /* VBIC */
59
--- a/hw/intc/arm_gicv3_dist.c
78
- tcg_gen_gvec_andc(0, rd_ofs, rn_ofs, rm_ofs,
60
+++ b/hw/intc/arm_gicv3_dist.c
79
- vec_size, vec_size);
61
@@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset,
80
- break;
62
* by GICD_TYPER.IDbits)
81
- case 2: /* VORR */
63
* MBIS == 0 (message-based SPIs not supported)
82
- tcg_gen_gvec_or(0, rd_ofs, rn_ofs, rm_ofs,
64
* SecurityExtn == 1 if security extns supported
83
- vec_size, vec_size);
65
+ * NMI = 1 if Non-maskable interrupt property is supported
84
- break;
66
* CPUNumber == 0 since for us ARE is always 1
85
- case 3: /* VORN */
67
* ITLinesNumber == (((max SPI IntID + 1) / 32) - 1)
86
- tcg_gen_gvec_orc(0, rd_ofs, rn_ofs, rm_ofs,
68
*/
87
- vec_size, vec_size);
69
@@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset,
88
- break;
70
bool dvis = s->revision >= 4;
89
- case 4: /* VEOR */
71
90
- tcg_gen_gvec_xor(0, rd_ofs, rn_ofs, rm_ofs,
72
*data = (1 << 25) | (1 << 24) | (dvis << 18) | (sec_extn << 10) |
91
- vec_size, vec_size);
73
+ (s->nmi_support << GICD_TYPER_NMI_SHIFT) |
92
- break;
74
(s->lpi_enable << GICD_TYPER_LPIS_SHIFT) |
93
- case 5: /* VBSL */
75
(0xf << 19) | itlinesnumber;
94
- tcg_gen_gvec_bitsel(MO_8, rd_ofs, rd_ofs, rn_ofs, rm_ofs,
76
return true;
95
- vec_size, vec_size);
96
- break;
97
- case 6: /* VBIT */
98
- tcg_gen_gvec_bitsel(MO_8, rd_ofs, rm_ofs, rn_ofs, rd_ofs,
99
- vec_size, vec_size);
100
- break;
101
- case 7: /* VBIF */
102
- tcg_gen_gvec_bitsel(MO_8, rd_ofs, rm_ofs, rd_ofs, rn_ofs,
103
- vec_size, vec_size);
104
- break;
105
- }
106
- return 0;
107
-
108
case NEON_3R_VQADD:
109
tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc),
110
rn_ofs, rm_ofs, vec_size, vec_size,
111
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
112
return 0;
113
114
case NEON_3R_VADD_VSUB:
115
+ case NEON_3R_LOGIC:
116
/* Already handled by decodetree */
117
return 1;
118
}
119
--
77
--
120
2.20.1
78
2.34.1
121
122
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
By using the TYPE_* definitions for devices, we can:
3
So far, there is no FEAT_GICv3_NMI support in the in-kernel GIC, so make it
4
- quickly find where devices are used with 'git-grep'
4
an error to try to set has-nmi=true for the KVM GICv3.
5
- easily rename a device (one-line change).
6
5
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
8
Message-id: 20200428154650.21991-1-f4bug@amsat.org
7
Message-id: 20240407081733.3231820-15-ruanjinjie@huawei.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
hw/arm/mps2-tz.c | 2 +-
11
hw/intc/arm_gicv3_kvm.c | 5 +++++
13
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 5 insertions(+)
14
13
15
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
14
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/mps2-tz.c
16
--- a/hw/intc/arm_gicv3_kvm.c
18
+++ b/hw/arm/mps2-tz.c
17
+++ b/hw/intc/arm_gicv3_kvm.c
19
@@ -XXX,XX +XXX,XX @@ static void mps2tz_common_init(MachineState *machine)
18
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
20
exit(EXIT_FAILURE);
19
return;
21
}
20
}
22
21
23
- sysbus_init_child_obj(OBJECT(machine), "iotkit", &mms->iotkit,
22
+ if (s->nmi_support) {
24
+ sysbus_init_child_obj(OBJECT(machine), TYPE_IOTKIT, &mms->iotkit,
23
+ error_setg(errp, "NMI is not supported with the in-kernel GIC");
25
sizeof(mms->iotkit), mmc->armsse_type);
24
+ return;
26
iotkitdev = DEVICE(&mms->iotkit);
25
+ }
27
object_property_set_link(OBJECT(&mms->iotkit), OBJECT(system_memory),
26
+
27
gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);
28
29
for (i = 0; i < s->num_cpu; i++) {
28
--
30
--
29
2.20.1
31
2.34.1
30
31
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Embed the GEMs into the SoC type.
3
A SPI, PPI or SGI interrupt can have non-maskable property. So maintain
4
non-maskable property in PendingIrq and GICR/GICD. Since add new device
5
state, it also needs to be migrated, so also save NMI info in
6
vmstate_gicv3_cpu and vmstate_gicv3.
4
7
5
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9
Acked-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20240407081733.3231820-16-ruanjinjie@huawei.com
9
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
10
Message-id: 20200427181649.26851-6-edgar.iglesias@gmail.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
---
13
include/hw/arm/xlnx-versal.h | 3 ++-
14
include/hw/intc/arm_gicv3_common.h | 4 ++++
14
hw/arm/xlnx-versal.c | 15 ++++++++-------
15
hw/intc/arm_gicv3_common.c | 38 ++++++++++++++++++++++++++++++
15
2 files changed, 10 insertions(+), 8 deletions(-)
16
2 files changed, 42 insertions(+)
16
17
17
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
18
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
18
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/xlnx-versal.h
20
--- a/include/hw/intc/arm_gicv3_common.h
20
+++ b/include/hw/arm/xlnx-versal.h
21
+++ b/include/hw/intc/arm_gicv3_common.h
21
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ typedef struct {
22
#include "hw/arm/boot.h"
23
int irq;
23
#include "hw/intc/arm_gicv3.h"
24
uint8_t prio;
24
#include "hw/char/pl011.h"
25
int grp;
25
+#include "hw/net/cadence_gem.h"
26
+ bool nmi;
26
27
} PendingIrq;
27
#define TYPE_XLNX_VERSAL "xlnx-versal"
28
28
#define XLNX_VERSAL(obj) OBJECT_CHECK(Versal, (obj), TYPE_XLNX_VERSAL)
29
struct GICv3CPUState {
29
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
30
@@ -XXX,XX +XXX,XX @@ struct GICv3CPUState {
30
31
uint32_t gicr_ienabler0;
31
struct {
32
uint32_t gicr_ipendr0;
32
PL011State uart[XLNX_VERSAL_NR_UARTS];
33
uint32_t gicr_iactiver0;
33
- SysBusDevice *gem[XLNX_VERSAL_NR_GEMS];
34
+ uint32_t gicr_inmir0;
34
+ CadenceGEMState gem[XLNX_VERSAL_NR_GEMS];
35
uint32_t edge_trigger; /* ICFGR0 and ICFGR1 even bits */
35
SysBusDevice *adma[XLNX_VERSAL_NR_ADMAS];
36
uint32_t gicr_igrpmodr0;
36
} iou;
37
uint32_t gicr_nsacr;
37
} lpd;
38
@@ -XXX,XX +XXX,XX @@ struct GICv3State {
38
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
39
GIC_DECLARE_BITMAP(active); /* GICD_ISACTIVER */
40
GIC_DECLARE_BITMAP(level); /* Current level */
41
GIC_DECLARE_BITMAP(edge_trigger); /* GICD_ICFGR even bits */
42
+ GIC_DECLARE_BITMAP(nmi); /* GICD_INMIR */
43
uint8_t gicd_ipriority[GICV3_MAXIRQ];
44
uint64_t gicd_irouter[GICV3_MAXIRQ];
45
/* Cached information: pointer to the cpu i/f for the CPUs specified
46
@@ -XXX,XX +XXX,XX @@ GICV3_BITMAP_ACCESSORS(pending)
47
GICV3_BITMAP_ACCESSORS(active)
48
GICV3_BITMAP_ACCESSORS(level)
49
GICV3_BITMAP_ACCESSORS(edge_trigger)
50
+GICV3_BITMAP_ACCESSORS(nmi)
51
52
#define TYPE_ARM_GICV3_COMMON "arm-gicv3-common"
53
typedef struct ARMGICv3CommonClass ARMGICv3CommonClass;
54
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
39
index XXXXXXX..XXXXXXX 100644
55
index XXXXXXX..XXXXXXX 100644
40
--- a/hw/arm/xlnx-versal.c
56
--- a/hw/intc/arm_gicv3_common.c
41
+++ b/hw/arm/xlnx-versal.c
57
+++ b/hw/intc/arm_gicv3_common.c
42
@@ -XXX,XX +XXX,XX @@ static void versal_create_gems(Versal *s, qemu_irq *pic)
58
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_gicv3_gicv4 = {
43
DeviceState *dev;
44
MemoryRegion *mr;
45
46
- dev = qdev_create(NULL, "cadence_gem");
47
- s->lpd.iou.gem[i] = SYS_BUS_DEVICE(dev);
48
- object_property_add_child(OBJECT(s), name, OBJECT(dev), &error_fatal);
49
+ sysbus_init_child_obj(OBJECT(s), name,
50
+ &s->lpd.iou.gem[i], sizeof(s->lpd.iou.gem[i]),
51
+ TYPE_CADENCE_GEM);
52
+ dev = DEVICE(&s->lpd.iou.gem[i]);
53
if (nd->used) {
54
qemu_check_nic_model(nd, "cadence_gem");
55
qdev_set_nic_properties(dev, nd);
56
}
57
- object_property_set_int(OBJECT(s->lpd.iou.gem[i]),
58
+ object_property_set_int(OBJECT(dev),
59
2, "num-priority-queues",
60
&error_abort);
61
- object_property_set_link(OBJECT(s->lpd.iou.gem[i]),
62
+ object_property_set_link(OBJECT(dev),
63
OBJECT(&s->mr_ps), "dma",
64
&error_abort);
65
qdev_init_nofail(dev);
66
67
- mr = sysbus_mmio_get_region(s->lpd.iou.gem[i], 0);
68
+ mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
69
memory_region_add_subregion(&s->mr_ps, addrs[i], mr);
70
71
- sysbus_connect_irq(s->lpd.iou.gem[i], 0, pic[irqs[i]]);
72
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irqs[i]]);
73
g_free(name);
74
}
59
}
75
}
60
};
61
62
+static bool gicv3_cpu_nmi_needed(void *opaque)
63
+{
64
+ GICv3CPUState *cs = opaque;
65
+
66
+ return cs->gic->nmi_support;
67
+}
68
+
69
+static const VMStateDescription vmstate_gicv3_cpu_nmi = {
70
+ .name = "arm_gicv3_cpu/nmi",
71
+ .version_id = 1,
72
+ .minimum_version_id = 1,
73
+ .needed = gicv3_cpu_nmi_needed,
74
+ .fields = (const VMStateField[]) {
75
+ VMSTATE_UINT32(gicr_inmir0, GICv3CPUState),
76
+ VMSTATE_END_OF_LIST()
77
+ }
78
+};
79
+
80
static const VMStateDescription vmstate_gicv3_cpu = {
81
.name = "arm_gicv3_cpu",
82
.version_id = 1,
83
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3_cpu = {
84
&vmstate_gicv3_cpu_virt,
85
&vmstate_gicv3_cpu_sre_el1,
86
&vmstate_gicv3_gicv4,
87
+ &vmstate_gicv3_cpu_nmi,
88
NULL
89
}
90
};
91
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = {
92
}
93
};
94
95
+static bool gicv3_nmi_needed(void *opaque)
96
+{
97
+ GICv3State *cs = opaque;
98
+
99
+ return cs->nmi_support;
100
+}
101
+
102
+const VMStateDescription vmstate_gicv3_gicd_nmi = {
103
+ .name = "arm_gicv3/gicd_nmi",
104
+ .version_id = 1,
105
+ .minimum_version_id = 1,
106
+ .needed = gicv3_nmi_needed,
107
+ .fields = (const VMStateField[]) {
108
+ VMSTATE_UINT32_ARRAY(nmi, GICv3State, GICV3_BMP_SIZE),
109
+ VMSTATE_END_OF_LIST()
110
+ }
111
+};
112
+
113
static const VMStateDescription vmstate_gicv3 = {
114
.name = "arm_gicv3",
115
.version_id = 1,
116
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3 = {
117
},
118
.subsections = (const VMStateDescription * const []) {
119
&vmstate_gicv3_gicd_no_migration_shift_bug,
120
+ &vmstate_gicv3_gicd_nmi,
121
NULL
122
}
123
};
76
--
124
--
77
2.20.1
125
2.34.1
78
79
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
hw/arm: versal: Add support for the RTC.
3
Add GICR_INMIR0 register and support access GICR_INMIR0.
4
4
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
Message-id: 20240407081733.3231820-17-ruanjinjie@huawei.com
9
Message-id: 20200427181649.26851-10-edgar.iglesias@gmail.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
include/hw/arm/xlnx-versal.h | 8 ++++++++
11
hw/intc/gicv3_internal.h | 1 +
13
hw/arm/xlnx-versal.c | 21 +++++++++++++++++++++
12
hw/intc/arm_gicv3_redist.c | 19 +++++++++++++++++++
14
2 files changed, 29 insertions(+)
13
2 files changed, 20 insertions(+)
15
14
16
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
15
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/xlnx-versal.h
17
--- a/hw/intc/gicv3_internal.h
19
+++ b/include/hw/arm/xlnx-versal.h
18
+++ b/hw/intc/gicv3_internal.h
20
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
21
#include "hw/char/pl011.h"
20
#define GICR_ICFGR1 (GICR_SGI_OFFSET + 0x0C04)
22
#include "hw/dma/xlnx-zdma.h"
21
#define GICR_IGRPMODR0 (GICR_SGI_OFFSET + 0x0D00)
23
#include "hw/net/cadence_gem.h"
22
#define GICR_NSACR (GICR_SGI_OFFSET + 0x0E00)
24
+#include "hw/rtc/xlnx-zynqmp-rtc.h"
23
+#define GICR_INMIR0 (GICR_SGI_OFFSET + 0x0F80)
25
24
26
#define TYPE_XLNX_VERSAL "xlnx-versal"
25
/* VLPI redistributor registers, offsets from VLPI_base */
27
#define XLNX_VERSAL(obj) OBJECT_CHECK(Versal, (obj), TYPE_XLNX_VERSAL)
26
#define GICR_VPROPBASER (GICR_VLPI_OFFSET + 0x70)
28
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
27
diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c
29
struct {
30
SDHCIState sd[XLNX_VERSAL_NR_SDS];
31
} iou;
32
+
33
+ XlnxZynqMPRTC rtc;
34
} pmc;
35
36
struct {
37
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
38
#define VERSAL_GEM1_IRQ_0 58
39
#define VERSAL_GEM1_WAKE_IRQ_0 59
40
#define VERSAL_ADMA_IRQ_0 60
41
+#define VERSAL_RTC_APB_ERR_IRQ 121
42
#define VERSAL_SD0_IRQ_0 126
43
+#define VERSAL_RTC_ALARM_IRQ 142
44
+#define VERSAL_RTC_SECONDS_IRQ 143
45
46
/* Architecturally reserved IRQs suitable for virtualization. */
47
#define VERSAL_RSVD_IRQ_FIRST 111
48
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
49
#define MM_PMC_SD0_SIZE 0x10000
50
#define MM_PMC_CRP 0xf1260000U
51
#define MM_PMC_CRP_SIZE 0x10000
52
+#define MM_PMC_RTC 0xf12a0000
53
+#define MM_PMC_RTC_SIZE 0x10000
54
#endif
55
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
56
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
57
--- a/hw/arm/xlnx-versal.c
29
--- a/hw/intc/arm_gicv3_redist.c
58
+++ b/hw/arm/xlnx-versal.c
30
+++ b/hw/intc/arm_gicv3_redist.c
59
@@ -XXX,XX +XXX,XX @@ static void versal_create_sds(Versal *s, qemu_irq *pic)
31
@@ -XXX,XX +XXX,XX @@ static int gicr_ns_access(GICv3CPUState *cs, int irq)
60
}
32
return extract32(cs->gicr_nsacr, irq * 2, 2);
61
}
33
}
62
34
63
+static void versal_create_rtc(Versal *s, qemu_irq *pic)
35
+static void gicr_write_bitmap_reg(GICv3CPUState *cs, MemTxAttrs attrs,
36
+ uint32_t *reg, uint32_t val)
64
+{
37
+{
65
+ SysBusDevice *sbd;
38
+ /* Helper routine to implement writing to a "set" register */
66
+ MemoryRegion *mr;
39
+ val &= mask_group(cs, attrs);
67
+
40
+ *reg = val;
68
+ sysbus_init_child_obj(OBJECT(s), "rtc", &s->pmc.rtc, sizeof(s->pmc.rtc),
41
+ gicv3_redist_update(cs);
69
+ TYPE_XLNX_ZYNQMP_RTC);
70
+ sbd = SYS_BUS_DEVICE(&s->pmc.rtc);
71
+ qdev_init_nofail(DEVICE(sbd));
72
+
73
+ mr = sysbus_mmio_get_region(sbd, 0);
74
+ memory_region_add_subregion(&s->mr_ps, MM_PMC_RTC, mr);
75
+
76
+ /*
77
+ * TODO: Connect the ALARM and SECONDS interrupts once our RTC model
78
+ * supports them.
79
+ */
80
+ sysbus_connect_irq(sbd, 1, pic[VERSAL_RTC_APB_ERR_IRQ]);
81
+}
42
+}
82
+
43
+
83
/* This takes the board allocated linear DDR memory and creates aliases
44
static void gicr_write_set_bitmap_reg(GICv3CPUState *cs, MemTxAttrs attrs,
84
* for each split DDR range/aperture on the Versal address map.
45
uint32_t *reg, uint32_t val)
85
*/
46
{
86
@@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp)
47
@@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr offset,
87
versal_create_gems(s, pic);
48
*data = value;
88
versal_create_admas(s, pic);
49
return MEMTX_OK;
89
versal_create_sds(s, pic);
50
}
90
+ versal_create_rtc(s, pic);
51
+ case GICR_INMIR0:
91
versal_map_ddr(s);
52
+ *data = cs->gic->nmi_support ?
92
versal_unimp(s);
53
+ gicr_read_bitmap_reg(cs, attrs, cs->gicr_inmir0) : 0;
93
54
+ return MEMTX_OK;
55
case GICR_ICFGR0:
56
case GICR_ICFGR1:
57
{
58
@@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_writel(GICv3CPUState *cs, hwaddr offset,
59
gicv3_redist_update(cs);
60
return MEMTX_OK;
61
}
62
+ case GICR_INMIR0:
63
+ if (cs->gic->nmi_support) {
64
+ gicr_write_bitmap_reg(cs, attrs, &cs->gicr_inmir0, value);
65
+ }
66
+ return MEMTX_OK;
67
+
68
case GICR_ICFGR0:
69
/* Register is all RAZ/WI or RAO/WI bits */
70
return MEMTX_OK;
94
--
71
--
95
2.20.1
72
2.34.1
96
97
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Add support for the RTC.
3
Add GICD_INMIR, GICD_INMIRnE register and support access GICD_INMIR0.
4
4
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20200427181649.26851-12-edgar.iglesias@gmail.com
8
Message-id: 20240407081733.3231820-18-ruanjinjie@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
10
---
11
hw/arm/xlnx-versal-virt.c | 22 ++++++++++++++++++++++
11
hw/intc/gicv3_internal.h | 2 ++
12
1 file changed, 22 insertions(+)
12
hw/intc/arm_gicv3_dist.c | 34 ++++++++++++++++++++++++++++++++++
13
2 files changed, 36 insertions(+)
13
14
14
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
15
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/xlnx-versal-virt.c
17
--- a/hw/intc/gicv3_internal.h
17
+++ b/hw/arm/xlnx-versal-virt.c
18
+++ b/hw/intc/gicv3_internal.h
18
@@ -XXX,XX +XXX,XX @@ static void fdt_add_sd_nodes(VersalVirt *s)
19
@@ -XXX,XX +XXX,XX @@
19
}
20
#define GICD_SGIR 0x0F00
21
#define GICD_CPENDSGIR 0x0F10
22
#define GICD_SPENDSGIR 0x0F20
23
+#define GICD_INMIR 0x0F80
24
+#define GICD_INMIRnE 0x3B00
25
#define GICD_IROUTER 0x6000
26
#define GICD_IDREGS 0xFFD0
27
28
diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/intc/arm_gicv3_dist.c
31
+++ b/hw/intc/arm_gicv3_dist.c
32
@@ -XXX,XX +XXX,XX @@ static int gicd_ns_access(GICv3State *s, int irq)
33
return extract32(s->gicd_nsacr[irq / 16], (irq % 16) * 2, 2);
20
}
34
}
21
35
22
+static void fdt_add_rtc_node(VersalVirt *s)
36
+static void gicd_write_bitmap_reg(GICv3State *s, MemTxAttrs attrs,
37
+ uint32_t *bmp, maskfn *maskfn,
38
+ int offset, uint32_t val)
23
+{
39
+{
24
+ const char compat[] = "xlnx,zynqmp-rtc";
40
+ /*
25
+ const char interrupt_names[] = "alarm\0sec";
41
+ * Helper routine to implement writing to a "set" register
26
+ char *name = g_strdup_printf("/rtc@%x", MM_PMC_RTC);
42
+ * (GICD_INMIR, etc).
43
+ * Semantics implemented here:
44
+ * RAZ/WI for SGIs, PPIs, unimplemented IRQs
45
+ * Bits corresponding to Group 0 or Secure Group 1 interrupts RAZ/WI.
46
+ * offset should be the offset in bytes of the register from the start
47
+ * of its group.
48
+ */
49
+ int irq = offset * 8;
27
+
50
+
28
+ qemu_fdt_add_subnode(s->fdt, name);
51
+ if (irq < GIC_INTERNAL || irq >= s->num_irq) {
29
+
52
+ return;
30
+ qemu_fdt_setprop_cells(s->fdt, name, "interrupts",
53
+ }
31
+ GIC_FDT_IRQ_TYPE_SPI, VERSAL_RTC_ALARM_IRQ,
54
+ val &= mask_group_and_nsacr(s, attrs, maskfn, irq);
32
+ GIC_FDT_IRQ_FLAGS_LEVEL_HI,
55
+ *gic_bmp_ptr32(bmp, irq) = val;
33
+ GIC_FDT_IRQ_TYPE_SPI, VERSAL_RTC_SECONDS_IRQ,
56
+ gicv3_update(s, irq, 32);
34
+ GIC_FDT_IRQ_FLAGS_LEVEL_HI);
35
+ qemu_fdt_setprop(s->fdt, name, "interrupt-names",
36
+ interrupt_names, sizeof(interrupt_names));
37
+ qemu_fdt_setprop_sized_cells(s->fdt, name, "reg",
38
+ 2, MM_PMC_RTC, 2, MM_PMC_RTC_SIZE);
39
+ qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat));
40
+ g_free(name);
41
+}
57
+}
42
+
58
+
43
static void fdt_nop_memory_nodes(void *fdt, Error **errp)
59
static void gicd_write_set_bitmap_reg(GICv3State *s, MemTxAttrs attrs,
44
{
60
uint32_t *bmp,
45
Error *err = NULL;
61
maskfn *maskfn,
46
@@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine)
62
@@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset,
47
fdt_add_timer_nodes(s);
63
/* RAZ/WI since affinity routing is always enabled */
48
fdt_add_zdma_nodes(s);
64
*data = 0;
49
fdt_add_sd_nodes(s);
65
return true;
50
+ fdt_add_rtc_node(s);
66
+ case GICD_INMIR ... GICD_INMIR + 0x7f:
51
fdt_add_cpu_nodes(s, psci_conduit);
67
+ *data = (!s->nmi_support) ? 0 :
52
fdt_add_clk_node(s, "/clk125", 125000000, s->phandle.clk_125Mhz);
68
+ gicd_read_bitmap_reg(s, attrs, s->nmi, NULL,
53
fdt_add_clk_node(s, "/clk25", 25000000, s->phandle.clk_25Mhz);
69
+ offset - GICD_INMIR);
70
+ return true;
71
case GICD_IROUTER ... GICD_IROUTER + 0x1fdf:
72
{
73
uint64_t r;
74
@@ -XXX,XX +XXX,XX @@ static bool gicd_writel(GICv3State *s, hwaddr offset,
75
case GICD_SPENDSGIR ... GICD_SPENDSGIR + 0xf:
76
/* RAZ/WI since affinity routing is always enabled */
77
return true;
78
+ case GICD_INMIR ... GICD_INMIR + 0x7f:
79
+ if (s->nmi_support) {
80
+ gicd_write_bitmap_reg(s, attrs, s->nmi, NULL,
81
+ offset - GICD_INMIR, value);
82
+ }
83
+ return true;
84
case GICD_IROUTER ... GICD_IROUTER + 0x1fdf:
85
{
86
uint64_t r;
54
--
87
--
55
2.20.1
88
2.34.1
56
57
diff view generated by jsdifflib
1
Somewhere along theline we accidentally added a duplicate
1
Add the NMIAR CPU interface registers which deal with acknowledging NMI.
2
"using D16-D31 when they don't exist" check to do_vfm_dp()
3
(probably an artifact of a patchseries rebase). Remove it.
4
2
3
When introduce NMI interrupt, there are some updates to the semantics for the
4
register ICC_IAR1_EL1 and ICC_HPPIR1_EL1. For ICC_IAR1_EL1 register, it
5
should return 1022 if the intid has non-maskable property. And for
6
ICC_NMIAR1_EL1 register, it should return 1023 if the intid do not have
7
non-maskable property. Howerever, these are not necessary for ICC_HPPIR1_EL1
8
register.
9
10
And the APR and RPR has NMI bits which should be handled correctly.
11
12
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
[PMM: Separate out whether cpuif supports NMI from whether the
15
GIC proper (IRI) supports NMI]
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Message-id: 20240407081733.3231820-19-ruanjinjie@huawei.com
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20200430181003.21682-2-peter.maydell@linaro.org
9
---
19
---
10
target/arm/translate-vfp.inc.c | 6 ------
20
hw/intc/gicv3_internal.h | 5 +
11
1 file changed, 6 deletions(-)
21
include/hw/intc/arm_gicv3_common.h | 7 ++
22
hw/intc/arm_gicv3_cpuif.c | 147 ++++++++++++++++++++++++++++-
23
hw/intc/trace-events | 1 +
24
4 files changed, 155 insertions(+), 5 deletions(-)
12
25
13
diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c
26
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
14
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate-vfp.inc.c
28
--- a/hw/intc/gicv3_internal.h
16
+++ b/target/arm/translate-vfp.inc.c
29
+++ b/hw/intc/gicv3_internal.h
17
@@ -XXX,XX +XXX,XX @@ static bool do_vfm_dp(DisasContext *s, arg_VFMA_dp *a, bool neg_n, bool neg_d)
30
@@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1)
31
#define ICC_CTLR_EL3_A3V (1U << 15)
32
#define ICC_CTLR_EL3_NDS (1U << 17)
33
34
+#define ICC_AP1R_EL1_NMI (1ULL << 63)
35
+#define ICC_RPR_EL1_NSNMI (1ULL << 62)
36
+#define ICC_RPR_EL1_NMI (1ULL << 63)
37
+
38
#define ICH_VMCR_EL2_VENG0_SHIFT 0
39
#define ICH_VMCR_EL2_VENG0 (1U << ICH_VMCR_EL2_VENG0_SHIFT)
40
#define ICH_VMCR_EL2_VENG1_SHIFT 1
41
@@ -XXX,XX +XXX,XX @@ FIELD(VTE, RDBASE, 42, RDBASE_PROCNUM_LENGTH)
42
/* Special interrupt IDs */
43
#define INTID_SECURE 1020
44
#define INTID_NONSECURE 1021
45
+#define INTID_NMI 1022
46
#define INTID_SPURIOUS 1023
47
48
/* Functions internal to the emulated GICv3 */
49
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
50
index XXXXXXX..XXXXXXX 100644
51
--- a/include/hw/intc/arm_gicv3_common.h
52
+++ b/include/hw/intc/arm_gicv3_common.h
53
@@ -XXX,XX +XXX,XX @@ struct GICv3CPUState {
54
55
/* This is temporary working state, to avoid a malloc in gicv3_update() */
56
bool seenbetter;
57
+
58
+ /*
59
+ * Whether the CPU interface has NMI support (FEAT_GICv3_NMI). The
60
+ * CPU interface may support NMIs even when the GIC proper (what the
61
+ * spec calls the IRI; the redistributors and distributor) does not.
62
+ */
63
+ bool nmi_support;
64
};
65
66
/*
67
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/hw/intc/arm_gicv3_cpuif.c
70
+++ b/hw/intc/arm_gicv3_cpuif.c
71
@@ -XXX,XX +XXX,XX @@
72
#include "hw/irq.h"
73
#include "cpu.h"
74
#include "target/arm/cpregs.h"
75
+#include "target/arm/cpu-features.h"
76
#include "sysemu/tcg.h"
77
#include "sysemu/qtest.h"
78
79
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri)
80
return intid;
81
}
82
83
+static uint64_t icv_nmiar1_read(CPUARMState *env, const ARMCPRegInfo *ri)
84
+{
85
+ /* todo */
86
+ uint64_t intid = INTID_SPURIOUS;
87
+ return intid;
88
+}
89
+
90
static uint32_t icc_fullprio_mask(GICv3CPUState *cs)
91
{
92
/*
93
@@ -XXX,XX +XXX,XX @@ static int icc_highest_active_prio(GICv3CPUState *cs)
94
*/
95
int i;
96
97
+ if (cs->nmi_support) {
98
+ /*
99
+ * If an NMI is active this takes precedence over anything else
100
+ * for priority purposes; the NMI bit is only in the AP1R0 bit.
101
+ * We return here the effective priority of the NMI, which is
102
+ * either 0x0 or 0x80. Callers will need to check NMI again for
103
+ * purposes of either setting the RPR register bits or for
104
+ * prioritization of NMI vs non-NMI.
105
+ */
106
+ if (cs->icc_apr[GICV3_G1][0] & ICC_AP1R_EL1_NMI) {
107
+ return 0;
108
+ }
109
+ if (cs->icc_apr[GICV3_G1NS][0] & ICC_AP1R_EL1_NMI) {
110
+ return (cs->gic->gicd_ctlr & GICD_CTLR_DS) ? 0 : 0x80;
111
+ }
112
+ }
113
+
114
for (i = 0; i < icc_num_aprs(cs); i++) {
115
uint32_t apr = cs->icc_apr[GICV3_G0][i] |
116
cs->icc_apr[GICV3_G1][i] | cs->icc_apr[GICV3_G1NS][i];
117
@@ -XXX,XX +XXX,XX @@ static bool icc_hppi_can_preempt(GICv3CPUState *cs)
118
*/
119
int rprio;
120
uint32_t mask;
121
+ ARMCPU *cpu = ARM_CPU(cs->cpu);
122
+ CPUARMState *env = &cpu->env;
123
124
if (icc_no_enabled_hppi(cs)) {
18
return false;
125
return false;
19
}
126
}
20
127
21
- /* UNDEF accesses to D16-D31 if they don't exist. */
128
- if (cs->hppi.prio >= cs->icc_pmr_el1) {
22
- if (!dc_isar_feature(aa32_simd_r32, s) &&
129
+ if (cs->hppi.nmi) {
23
- ((a->vd | a->vn | a->vm) & 0x10)) {
130
+ if (!(cs->gic->gicd_ctlr & GICD_CTLR_DS) &&
24
- return false;
131
+ cs->hppi.grp == GICV3_G1NS) {
25
- }
132
+ if (cs->icc_pmr_el1 < 0x80) {
26
-
133
+ return false;
27
if (!vfp_access_check(s)) {
134
+ }
135
+ if (arm_is_secure(env) && cs->icc_pmr_el1 == 0x80) {
136
+ return false;
137
+ }
138
+ }
139
+ } else if (cs->hppi.prio >= cs->icc_pmr_el1) {
140
/* Priority mask masks this interrupt */
141
return false;
142
}
143
@@ -XXX,XX +XXX,XX @@ static bool icc_hppi_can_preempt(GICv3CPUState *cs)
28
return true;
144
return true;
29
}
145
}
146
147
+ if (cs->hppi.nmi && (cs->hppi.prio & mask) == (rprio & mask)) {
148
+ if (!(cs->icc_apr[cs->hppi.grp][0] & ICC_AP1R_EL1_NMI)) {
149
+ return true;
150
+ }
151
+ }
152
+
153
return false;
154
}
155
156
@@ -XXX,XX +XXX,XX @@ static void icc_activate_irq(GICv3CPUState *cs, int irq)
157
int aprbit = prio >> (8 - cs->prebits);
158
int regno = aprbit / 32;
159
int regbit = aprbit % 32;
160
+ bool nmi = cs->hppi.nmi;
161
162
- cs->icc_apr[cs->hppi.grp][regno] |= (1 << regbit);
163
+ if (nmi) {
164
+ cs->icc_apr[cs->hppi.grp][regno] |= ICC_AP1R_EL1_NMI;
165
+ } else {
166
+ cs->icc_apr[cs->hppi.grp][regno] |= (1 << regbit);
167
+ }
168
169
if (irq < GIC_INTERNAL) {
170
cs->gicr_iactiver0 = deposit32(cs->gicr_iactiver0, irq, 1, 1);
171
@@ -XXX,XX +XXX,XX @@ static uint64_t icc_iar0_read(CPUARMState *env, const ARMCPRegInfo *ri)
172
static uint64_t icc_iar1_read(CPUARMState *env, const ARMCPRegInfo *ri)
173
{
174
GICv3CPUState *cs = icc_cs_from_env(env);
175
+ int el = arm_current_el(env);
176
uint64_t intid;
177
178
if (icv_access(env, HCR_IMO)) {
179
@@ -XXX,XX +XXX,XX @@ static uint64_t icc_iar1_read(CPUARMState *env, const ARMCPRegInfo *ri)
180
}
181
182
if (!gicv3_intid_is_special(intid)) {
183
- icc_activate_irq(cs, intid);
184
+ if (cs->hppi.nmi && env->cp15.sctlr_el[el] & SCTLR_NMI) {
185
+ intid = INTID_NMI;
186
+ } else {
187
+ icc_activate_irq(cs, intid);
188
+ }
189
}
190
191
trace_gicv3_icc_iar1_read(gicv3_redist_affid(cs), intid);
192
return intid;
193
}
194
195
+static uint64_t icc_nmiar1_read(CPUARMState *env, const ARMCPRegInfo *ri)
196
+{
197
+ GICv3CPUState *cs = icc_cs_from_env(env);
198
+ uint64_t intid;
199
+
200
+ if (icv_access(env, HCR_IMO)) {
201
+ return icv_nmiar1_read(env, ri);
202
+ }
203
+
204
+ if (!icc_hppi_can_preempt(cs)) {
205
+ intid = INTID_SPURIOUS;
206
+ } else {
207
+ intid = icc_hppir1_value(cs, env);
208
+ }
209
+
210
+ if (!gicv3_intid_is_special(intid)) {
211
+ if (!cs->hppi.nmi) {
212
+ intid = INTID_SPURIOUS;
213
+ } else {
214
+ icc_activate_irq(cs, intid);
215
+ }
216
+ }
217
+
218
+ trace_gicv3_icc_nmiar1_read(gicv3_redist_affid(cs), intid);
219
+ return intid;
220
+}
221
+
222
static void icc_drop_prio(GICv3CPUState *cs, int grp)
223
{
224
/* Drop the priority of the currently active interrupt in
225
@@ -XXX,XX +XXX,XX @@ static void icc_drop_prio(GICv3CPUState *cs, int grp)
226
if (!*papr) {
227
continue;
228
}
229
+
230
+ if (i == 0 && cs->nmi_support && (*papr & ICC_AP1R_EL1_NMI)) {
231
+ *papr &= (~ICC_AP1R_EL1_NMI);
232
+ break;
233
+ }
234
+
235
/* Clear the lowest set bit */
236
*papr &= *papr - 1;
237
break;
238
@@ -XXX,XX +XXX,XX @@ static int icc_highest_active_group(GICv3CPUState *cs)
239
*/
240
int i;
241
242
+ if (cs->nmi_support) {
243
+ if (cs->icc_apr[GICV3_G1][0] & ICC_AP1R_EL1_NMI) {
244
+ return GICV3_G1;
245
+ }
246
+ if (cs->icc_apr[GICV3_G1NS][0] & ICC_AP1R_EL1_NMI) {
247
+ return GICV3_G1NS;
248
+ }
249
+ }
250
+
251
for (i = 0; i < ARRAY_SIZE(cs->icc_apr[0]); i++) {
252
int g0ctz = ctz32(cs->icc_apr[GICV3_G0][i]);
253
int g1ctz = ctz32(cs->icc_apr[GICV3_G1][i]);
254
@@ -XXX,XX +XXX,XX @@ static void icc_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
255
return;
256
}
257
258
- cs->icc_apr[grp][regno] = value & 0xFFFFFFFFU;
259
+ if (cs->nmi_support) {
260
+ cs->icc_apr[grp][regno] = value & (0xFFFFFFFFU | ICC_AP1R_EL1_NMI);
261
+ } else {
262
+ cs->icc_apr[grp][regno] = value & 0xFFFFFFFFU;
263
+ }
264
gicv3_cpuif_update(cs);
265
}
266
267
@@ -XXX,XX +XXX,XX @@ static void icc_dir_write(CPUARMState *env, const ARMCPRegInfo *ri,
268
static uint64_t icc_rpr_read(CPUARMState *env, const ARMCPRegInfo *ri)
269
{
270
GICv3CPUState *cs = icc_cs_from_env(env);
271
- int prio;
272
+ uint64_t prio;
273
274
if (icv_access(env, HCR_FMO | HCR_IMO)) {
275
return icv_rpr_read(env, ri);
276
@@ -XXX,XX +XXX,XX @@ static uint64_t icc_rpr_read(CPUARMState *env, const ARMCPRegInfo *ri)
277
}
278
}
279
280
+ if (cs->nmi_support) {
281
+ /* NMI info is reported in the high bits of RPR */
282
+ if (arm_feature(env, ARM_FEATURE_EL3) && !arm_is_secure(env)) {
283
+ if (cs->icc_apr[GICV3_G1NS][0] & ICC_AP1R_EL1_NMI) {
284
+ prio |= ICC_RPR_EL1_NMI;
285
+ }
286
+ } else {
287
+ if (cs->icc_apr[GICV3_G1NS][0] & ICC_AP1R_EL1_NMI) {
288
+ prio |= ICC_RPR_EL1_NSNMI;
289
+ }
290
+ if (cs->icc_apr[GICV3_G1][0] & ICC_AP1R_EL1_NMI) {
291
+ prio |= ICC_RPR_EL1_NMI;
292
+ }
293
+ }
294
+ }
295
+
296
trace_gicv3_icc_rpr_read(gicv3_redist_affid(cs), prio);
297
return prio;
298
}
299
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_icc_apxr23_reginfo[] = {
300
},
301
};
302
303
+static const ARMCPRegInfo gicv3_cpuif_gicv3_nmi_reginfo[] = {
304
+ { .name = "ICC_NMIAR1_EL1", .state = ARM_CP_STATE_BOTH,
305
+ .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 9, .opc2 = 5,
306
+ .type = ARM_CP_IO | ARM_CP_NO_RAW,
307
+ .access = PL1_R, .accessfn = gicv3_irq_access,
308
+ .readfn = icc_nmiar1_read,
309
+ },
310
+};
311
+
312
static uint64_t ich_ap_read(CPUARMState *env, const ARMCPRegInfo *ri)
313
{
314
GICv3CPUState *cs = icc_cs_from_env(env);
315
@@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s)
316
*/
317
define_arm_cp_regs(cpu, gicv3_cpuif_reginfo);
318
319
+ /*
320
+ * If the CPU implements FEAT_NMI and FEAT_GICv3 it must also
321
+ * implement FEAT_GICv3_NMI, which is the CPU interface part
322
+ * of NMI support. This is distinct from whether the GIC proper
323
+ * (redistributors and distributor) have NMI support. In QEMU
324
+ * that is a property of the GIC device in s->nmi_support;
325
+ * cs->nmi_support indicates the CPU interface's support.
326
+ */
327
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
328
+ cs->nmi_support = true;
329
+ define_arm_cp_regs(cpu, gicv3_cpuif_gicv3_nmi_reginfo);
330
+ }
331
+
332
/*
333
* The CPU implementation specifies the number of supported
334
* bits of physical priority. For backwards compatibility
335
diff --git a/hw/intc/trace-events b/hw/intc/trace-events
336
index XXXXXXX..XXXXXXX 100644
337
--- a/hw/intc/trace-events
338
+++ b/hw/intc/trace-events
339
@@ -XXX,XX +XXX,XX @@ gicv3_cpuif_set_irqs(uint32_t cpuid, int fiqlevel, int irqlevel) "GICv3 CPU i/f
340
gicv3_icc_generate_sgi(uint32_t cpuid, int irq, int irm, uint32_t aff, uint32_t targetlist) "GICv3 CPU i/f 0x%x generating SGI %d IRM %d target affinity 0x%xxx targetlist 0x%x"
341
gicv3_icc_iar0_read(uint32_t cpu, uint64_t val) "GICv3 ICC_IAR0 read cpu 0x%x value 0x%" PRIx64
342
gicv3_icc_iar1_read(uint32_t cpu, uint64_t val) "GICv3 ICC_IAR1 read cpu 0x%x value 0x%" PRIx64
343
+gicv3_icc_nmiar1_read(uint32_t cpu, uint64_t val) "GICv3 ICC_NMIAR1 read cpu 0x%x value 0x%" PRIx64
344
gicv3_icc_eoir_write(int grp, uint32_t cpu, uint64_t val) "GICv3 ICC_EOIR%d write cpu 0x%x value 0x%" PRIx64
345
gicv3_icc_hppir0_read(uint32_t cpu, uint64_t val) "GICv3 ICC_HPPIR0 read cpu 0x%x value 0x%" PRIx64
346
gicv3_icc_hppir1_read(uint32_t cpu, uint64_t val) "GICv3 ICC_HPPIR1 read cpu 0x%x value 0x%" PRIx64
30
--
347
--
31
2.20.1
348
2.34.1
32
33
diff view generated by jsdifflib
1
Convert the Neon "load/store multiple structures" insns to decodetree.
1
Implement icv_nmiar1_read() for icc_nmiar1_read(), so add definition for
2
2
ICH_LR_EL2.NMI and ICH_AP1R_EL2.NMI bit.
3
4
If FEAT_GICv3_NMI is supported, ich_ap_write() should consider ICV_AP1R_EL1.NMI
5
bit. In icv_activate_irq() and icv_eoir_write(), the ICV_AP1R_EL1.NMI bit
6
should be set or clear according to the Non-maskable property. And the RPR
7
priority should also update the NMI bit according to the APR priority NMI bit.
8
9
By the way, add gicv3_icv_nmiar1_read trace event.
10
11
If the hpp irq is a NMI, the icv iar read should return 1022 and trap for
12
NMI again
13
14
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
[PMM: use cs->nmi_support instead of cs->gic->nmi_support]
17
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
18
Message-id: 20240407081733.3231820-20-ruanjinjie@huawei.com
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20200430181003.21682-12-peter.maydell@linaro.org
6
---
20
---
7
target/arm/neon-ls.decode | 7 ++
21
hw/intc/gicv3_internal.h | 4 ++
8
target/arm/translate-neon.inc.c | 124 ++++++++++++++++++++++++++++++++
22
hw/intc/arm_gicv3_cpuif.c | 105 +++++++++++++++++++++++++++++++++-----
9
target/arm/translate.c | 91 +----------------------
23
hw/intc/trace-events | 1 +
10
3 files changed, 133 insertions(+), 89 deletions(-)
24
3 files changed, 98 insertions(+), 12 deletions(-)
11
25
12
diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode
26
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
13
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/neon-ls.decode
28
--- a/hw/intc/gicv3_internal.h
15
+++ b/target/arm/neon-ls.decode
29
+++ b/hw/intc/gicv3_internal.h
16
@@ -XXX,XX +XXX,XX @@
30
@@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1)
17
# 0b1111_1001_xxx0_xxxx_xxxx_xxxx_xxxx_xxxx
31
#define ICH_LR_EL2_PRIORITY_SHIFT 48
18
# This file works on the A32 encoding only; calling code for T32 has to
32
#define ICH_LR_EL2_PRIORITY_LENGTH 8
19
# transform the insn into the A32 version first.
33
#define ICH_LR_EL2_PRIORITY_MASK (0xffULL << ICH_LR_EL2_PRIORITY_SHIFT)
20
+
34
+#define ICH_LR_EL2_NMI (1ULL << 59)
21
+%vd_dp 22:1 12:4
35
#define ICH_LR_EL2_GROUP (1ULL << 60)
22
+
36
#define ICH_LR_EL2_HW (1ULL << 61)
23
+# Neon load/store multiple structures
37
#define ICH_LR_EL2_STATE_SHIFT 62
24
+
38
@@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1)
25
+VLDST_multiple 1111 0100 0 . l:1 0 rn:4 .... itype:4 size:2 align:2 rm:4 \
39
#define ICH_VTR_EL2_PREBITS_SHIFT 26
26
+ vd=%vd_dp
40
#define ICH_VTR_EL2_PRIBITS_SHIFT 29
27
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
41
42
+#define ICV_AP1R_EL1_NMI (1ULL << 63)
43
+#define ICV_RPR_EL1_NMI (1ULL << 63)
44
+
45
/* ITS Registers */
46
47
FIELD(GITS_BASER, SIZE, 0, 8)
48
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
28
index XXXXXXX..XXXXXXX 100644
49
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/translate-neon.inc.c
50
--- a/hw/intc/arm_gicv3_cpuif.c
30
+++ b/target/arm/translate-neon.inc.c
51
+++ b/hw/intc/arm_gicv3_cpuif.c
31
@@ -XXX,XX +XXX,XX @@ static bool trans_VFML_scalar(DisasContext *s, arg_VFML_scalar *a)
52
@@ -XXX,XX +XXX,XX @@ static int ich_highest_active_virt_prio(GICv3CPUState *cs)
32
gen_helper_gvec_fmlal_idx_a32);
53
int i;
33
return true;
54
int aprmax = ich_num_aprs(cs);
34
}
55
35
+
56
+ if (cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI) {
36
+static struct {
57
+ return 0x0;
37
+ int nregs;
58
+ }
38
+ int interleave;
59
+
39
+ int spacing;
60
for (i = 0; i < aprmax; i++) {
40
+} const neon_ls_element_type[11] = {
61
uint32_t apr = cs->ich_apr[GICV3_G0][i] |
41
+ {1, 4, 1},
62
cs->ich_apr[GICV3_G1NS][i];
42
+ {1, 4, 2},
63
@@ -XXX,XX +XXX,XX @@ static int hppvi_index(GICv3CPUState *cs)
43
+ {4, 1, 1},
64
* correct behaviour.
44
+ {2, 2, 2},
65
*/
45
+ {1, 3, 1},
66
int prio = 0xff;
46
+ {1, 3, 2},
67
+ bool nmi = false;
47
+ {3, 1, 1},
68
48
+ {1, 1, 1},
69
if (!(cs->ich_vmcr_el2 & (ICH_VMCR_EL2_VENG0 | ICH_VMCR_EL2_VENG1))) {
49
+ {1, 2, 1},
70
/* Both groups disabled, definitely nothing to do */
50
+ {1, 2, 2},
71
@@ -XXX,XX +XXX,XX @@ static int hppvi_index(GICv3CPUState *cs)
51
+ {2, 1, 1}
72
52
+};
73
for (i = 0; i < cs->num_list_regs; i++) {
53
+
74
uint64_t lr = cs->ich_lr_el2[i];
54
+static void gen_neon_ldst_base_update(DisasContext *s, int rm, int rn,
75
+ bool thisnmi;
55
+ int stride)
76
int thisprio;
56
+{
77
57
+ if (rm != 15) {
78
if (ich_lr_state(lr) != ICH_LR_EL2_STATE_PENDING) {
58
+ TCGv_i32 base;
79
@@ -XXX,XX +XXX,XX @@ static int hppvi_index(GICv3CPUState *cs)
59
+
80
}
60
+ base = load_reg(s, rn);
81
}
61
+ if (rm == 13) {
82
62
+ tcg_gen_addi_i32(base, base, stride);
83
+ thisnmi = lr & ICH_LR_EL2_NMI;
63
+ } else {
84
thisprio = ich_lr_prio(lr);
64
+ TCGv_i32 index;
85
65
+ index = load_reg(s, rm);
86
- if (thisprio < prio) {
66
+ tcg_gen_add_i32(base, base, index);
87
+ if ((thisprio < prio) || ((thisprio == prio) && (thisnmi & (!nmi)))) {
67
+ tcg_temp_free_i32(index);
88
prio = thisprio;
68
+ }
89
+ nmi = thisnmi;
69
+ store_reg(s, rn, base);
90
idx = i;
70
+ }
91
}
71
+}
92
}
72
+
93
@@ -XXX,XX +XXX,XX @@ static bool icv_hppi_can_preempt(GICv3CPUState *cs, uint64_t lr)
73
+static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a)
94
* equivalent of these checks.
74
+{
95
*/
75
+ /* Neon load/store multiple structures */
96
int grp;
76
+ int nregs, interleave, spacing, reg, n;
97
+ bool is_nmi;
77
+ MemOp endian = s->be_data;
98
uint32_t mask, prio, rprio, vpmr;
78
+ int mmu_idx = get_mem_index(s);
99
79
+ int size = a->size;
100
if (!(cs->ich_hcr_el2 & ICH_HCR_EL2_EN)) {
80
+ TCGv_i64 tmp64;
101
@@ -XXX,XX +XXX,XX @@ static bool icv_hppi_can_preempt(GICv3CPUState *cs, uint64_t lr)
81
+ TCGv_i32 addr, tmp;
102
*/
82
+
103
83
+ if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
104
prio = ich_lr_prio(lr);
84
+ return false;
105
+ is_nmi = lr & ICH_LR_EL2_NMI;
85
+ }
106
vpmr = extract64(cs->ich_vmcr_el2, ICH_VMCR_EL2_VPMR_SHIFT,
86
+
107
ICH_VMCR_EL2_VPMR_LENGTH);
87
+ /* UNDEF accesses to D16-D31 if they don't exist */
108
88
+ if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) {
109
- if (prio >= vpmr) {
89
+ return false;
110
+ if (!is_nmi && prio >= vpmr) {
90
+ }
111
/* Priority mask masks this interrupt */
91
+ if (a->itype > 10) {
112
return false;
92
+ return false;
113
}
93
+ }
114
@@ -XXX,XX +XXX,XX @@ static bool icv_hppi_can_preempt(GICv3CPUState *cs, uint64_t lr)
94
+ /* Catch UNDEF cases for bad values of align field */
115
return true;
95
+ switch (a->itype & 0xc) {
116
}
96
+ case 4:
117
97
+ if (a->align >= 2) {
118
+ if ((prio & mask) == (rprio & mask) && is_nmi &&
98
+ return false;
119
+ !(cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI)) {
99
+ }
100
+ break;
101
+ case 8:
102
+ if (a->align == 3) {
103
+ return false;
104
+ }
105
+ break;
106
+ default:
107
+ break;
108
+ }
109
+ nregs = neon_ls_element_type[a->itype].nregs;
110
+ interleave = neon_ls_element_type[a->itype].interleave;
111
+ spacing = neon_ls_element_type[a->itype].spacing;
112
+ if (size == 3 && (interleave | spacing) != 1) {
113
+ return false;
114
+ }
115
+
116
+ if (!vfp_access_check(s)) {
117
+ return true;
120
+ return true;
118
+ }
121
+ }
119
+
122
+
120
+ /* For our purposes, bytes are always little-endian. */
123
return false;
121
+ if (size == 0) {
124
}
122
+ endian = MO_LE;
125
123
+ }
126
@@ -XXX,XX +XXX,XX @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
124
+ /*
127
125
+ * Consecutive little-endian elements from a single register
128
trace_gicv3_icv_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value);
126
+ * can be promoted to a larger little-endian operation.
129
127
+ */
130
- cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU;
128
+ if (interleave == 1 && endian == MO_LE) {
131
+ if (cs->nmi_support) {
129
+ size = 3;
132
+ cs->ich_apr[grp][regno] = value & (0xFFFFFFFFU | ICV_AP1R_EL1_NMI);
130
+ }
133
+ } else {
131
+ tmp64 = tcg_temp_new_i64();
134
+ cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU;
132
+ addr = tcg_temp_new_i32();
135
+ }
133
+ tmp = tcg_const_i32(1 << size);
136
134
+ load_reg_var(s, addr, a->rn);
137
gicv3_cpuif_virt_irq_fiq_update(cs);
135
+ for (reg = 0; reg < nregs; reg++) {
138
return;
136
+ for (n = 0; n < 8 >> size; n++) {
139
@@ -XXX,XX +XXX,XX @@ static void icv_ctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
137
+ int xs;
140
static uint64_t icv_rpr_read(CPUARMState *env, const ARMCPRegInfo *ri)
138
+ for (xs = 0; xs < interleave; xs++) {
141
{
139
+ int tt = a->vd + reg + spacing * xs;
142
GICv3CPUState *cs = icc_cs_from_env(env);
140
+
143
- int prio = ich_highest_active_virt_prio(cs);
141
+ if (a->l) {
144
+ uint64_t prio = ich_highest_active_virt_prio(cs);
142
+ gen_aa32_ld_i64(s, tmp64, addr, mmu_idx, endian | size);
145
+
143
+ neon_store_element64(tt, n, size, tmp64);
146
+ if (cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI) {
147
+ prio |= ICV_RPR_EL1_NMI;
148
+ }
149
150
trace_gicv3_icv_rpr_read(gicv3_redist_affid(cs), prio);
151
return prio;
152
@@ -XXX,XX +XXX,XX @@ static void icv_activate_irq(GICv3CPUState *cs, int idx, int grp)
153
*/
154
uint32_t mask = icv_gprio_mask(cs, grp);
155
int prio = ich_lr_prio(cs->ich_lr_el2[idx]) & mask;
156
+ bool nmi = cs->ich_lr_el2[idx] & ICH_LR_EL2_NMI;
157
int aprbit = prio >> (8 - cs->vprebits);
158
int regno = aprbit / 32;
159
int regbit = aprbit % 32;
160
161
cs->ich_lr_el2[idx] &= ~ICH_LR_EL2_STATE_PENDING_BIT;
162
cs->ich_lr_el2[idx] |= ICH_LR_EL2_STATE_ACTIVE_BIT;
163
- cs->ich_apr[grp][regno] |= (1 << regbit);
164
+
165
+ if (nmi) {
166
+ cs->ich_apr[grp][regno] |= ICV_AP1R_EL1_NMI;
167
+ } else {
168
+ cs->ich_apr[grp][regno] |= (1 << regbit);
169
+ }
170
}
171
172
static void icv_activate_vlpi(GICv3CPUState *cs)
173
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri)
174
int grp = ri->crm == 8 ? GICV3_G0 : GICV3_G1NS;
175
int idx = hppvi_index(cs);
176
uint64_t intid = INTID_SPURIOUS;
177
+ int el = arm_current_el(env);
178
179
if (idx == HPPVI_INDEX_VLPI) {
180
if (cs->hppvlpi.grp == grp && icv_hppvlpi_can_preempt(cs)) {
181
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri)
182
} else if (idx >= 0) {
183
uint64_t lr = cs->ich_lr_el2[idx];
184
int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0;
185
+ bool nmi = env->cp15.sctlr_el[el] & SCTLR_NMI && lr & ICH_LR_EL2_NMI;
186
187
if (thisgrp == grp && icv_hppi_can_preempt(cs, lr)) {
188
intid = ich_lr_vintid(lr);
189
if (!gicv3_intid_is_special(intid)) {
190
- icv_activate_irq(cs, idx, grp);
191
+ if (!nmi) {
192
+ icv_activate_irq(cs, idx, grp);
144
+ } else {
193
+ } else {
145
+ neon_load_element64(tmp64, tt, n, size);
194
+ intid = INTID_NMI;
146
+ gen_aa32_st_i64(s, tmp64, addr, mmu_idx, endian | size);
147
+ }
195
+ }
148
+ tcg_gen_add_i32(addr, addr, tmp);
196
} else {
197
/* Interrupt goes from Pending to Invalid */
198
cs->ich_lr_el2[idx] &= ~ICH_LR_EL2_STATE_PENDING_BIT;
199
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri)
200
201
static uint64_t icv_nmiar1_read(CPUARMState *env, const ARMCPRegInfo *ri)
202
{
203
- /* todo */
204
+ GICv3CPUState *cs = icc_cs_from_env(env);
205
+ int idx = hppvi_index(cs);
206
uint64_t intid = INTID_SPURIOUS;
207
+
208
+ if (idx >= 0 && idx != HPPVI_INDEX_VLPI) {
209
+ uint64_t lr = cs->ich_lr_el2[idx];
210
+ int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0;
211
+
212
+ if ((thisgrp == GICV3_G1NS) && icv_hppi_can_preempt(cs, lr)) {
213
+ intid = ich_lr_vintid(lr);
214
+ if (!gicv3_intid_is_special(intid)) {
215
+ if (lr & ICH_LR_EL2_NMI) {
216
+ icv_activate_irq(cs, idx, GICV3_G1NS);
217
+ } else {
218
+ intid = INTID_SPURIOUS;
219
+ }
220
+ } else {
221
+ /* Interrupt goes from Pending to Invalid */
222
+ cs->ich_lr_el2[idx] &= ~ICH_LR_EL2_STATE_PENDING_BIT;
223
+ /*
224
+ * We will now return the (bogus) ID from the list register,
225
+ * as per the pseudocode.
226
+ */
149
+ }
227
+ }
150
+ }
228
+ }
151
+ }
229
+ }
152
+ tcg_temp_free_i32(addr);
230
+
153
+ tcg_temp_free_i32(tmp);
231
+ trace_gicv3_icv_nmiar1_read(gicv3_redist_affid(cs), intid);
154
+ tcg_temp_free_i64(tmp64);
232
+
155
+
233
+ gicv3_cpuif_virt_update(cs);
156
+ gen_neon_ldst_base_update(s, a->rm, a->rn, nregs * interleave * 8);
234
+
157
+ return true;
235
return intid;
158
+}
236
}
159
diff --git a/target/arm/translate.c b/target/arm/translate.c
237
238
@@ -XXX,XX +XXX,XX @@ static void icv_increment_eoicount(GICv3CPUState *cs)
239
ICH_HCR_EL2_EOICOUNT_LENGTH, eoicount + 1);
240
}
241
242
-static int icv_drop_prio(GICv3CPUState *cs)
243
+static int icv_drop_prio(GICv3CPUState *cs, bool *nmi)
244
{
245
/* Drop the priority of the currently active virtual interrupt
246
* (favouring group 0 if there is a set active bit at
247
@@ -XXX,XX +XXX,XX @@ static int icv_drop_prio(GICv3CPUState *cs)
248
continue;
249
}
250
251
+ if (i == 0 && cs->nmi_support && (*papr1 & ICV_AP1R_EL1_NMI)) {
252
+ *papr1 &= (~ICV_AP1R_EL1_NMI);
253
+ *nmi = true;
254
+ return 0xff;
255
+ }
256
+
257
/* We can't just use the bit-twiddling hack icc_drop_prio() does
258
* because we need to return the bit number we cleared so
259
* it can be compared against the list register's priority field.
260
@@ -XXX,XX +XXX,XX @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri,
261
int irq = value & 0xffffff;
262
int grp = ri->crm == 8 ? GICV3_G0 : GICV3_G1NS;
263
int idx, dropprio;
264
+ bool nmi = false;
265
266
trace_gicv3_icv_eoir_write(ri->crm == 8 ? 0 : 1,
267
gicv3_redist_affid(cs), value);
268
@@ -XXX,XX +XXX,XX @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri,
269
* error checks" (because that lets us avoid scanning the AP
270
* registers twice).
271
*/
272
- dropprio = icv_drop_prio(cs);
273
- if (dropprio == 0xff) {
274
+ dropprio = icv_drop_prio(cs, &nmi);
275
+ if (dropprio == 0xff && !nmi) {
276
/* No active interrupt. It is CONSTRAINED UNPREDICTABLE
277
* whether the list registers are checked in this
278
* situation; we choose not to.
279
@@ -XXX,XX +XXX,XX @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri,
280
uint64_t lr = cs->ich_lr_el2[idx];
281
int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0;
282
int lr_gprio = ich_lr_prio(lr) & icv_gprio_mask(cs, grp);
283
+ bool thisnmi = lr & ICH_LR_EL2_NMI;
284
285
- if (thisgrp == grp && lr_gprio == dropprio) {
286
+ if (thisgrp == grp && (lr_gprio == dropprio || (thisnmi & nmi))) {
287
if (!icv_eoi_split(env, cs) || irq >= GICV3_LPI_INTID_START) {
288
/*
289
* Priority drop and deactivate not split: deactivate irq now.
290
@@ -XXX,XX +XXX,XX @@ static void ich_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
291
292
trace_gicv3_ich_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value);
293
294
- cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU;
295
+ if (cs->nmi_support) {
296
+ cs->ich_apr[grp][regno] = value & (0xFFFFFFFFU | ICV_AP1R_EL1_NMI);
297
+ } else {
298
+ cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU;
299
+ }
300
gicv3_cpuif_virt_irq_fiq_update(cs);
301
}
302
303
@@ -XXX,XX +XXX,XX @@ static void ich_lr_write(CPUARMState *env, const ARMCPRegInfo *ri,
304
8 - cs->vpribits, 0);
305
}
306
307
+ /* Enforce RES0 bit in NMI field when FEAT_GICv3_NMI is not implemented */
308
+ if (!cs->nmi_support) {
309
+ value &= ~ICH_LR_EL2_NMI;
310
+ }
311
+
312
cs->ich_lr_el2[regno] = value;
313
gicv3_cpuif_virt_update(cs);
314
}
315
diff --git a/hw/intc/trace-events b/hw/intc/trace-events
160
index XXXXXXX..XXXXXXX 100644
316
index XXXXXXX..XXXXXXX 100644
161
--- a/target/arm/translate.c
317
--- a/hw/intc/trace-events
162
+++ b/target/arm/translate.c
318
+++ b/hw/intc/trace-events
163
@@ -XXX,XX +XXX,XX @@ static void gen_neon_trn_u16(TCGv_i32 t0, TCGv_i32 t1)
319
@@ -XXX,XX +XXX,XX @@ gicv3_icv_rpr_read(uint32_t cpu, uint64_t val) "GICv3 ICV_RPR read cpu 0x%x valu
164
}
320
gicv3_icv_hppir_read(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_HPPIR%d read cpu 0x%x value 0x%" PRIx64
165
321
gicv3_icv_dir_write(uint32_t cpu, uint64_t val) "GICv3 ICV_DIR write cpu 0x%x value 0x%" PRIx64
166
322
gicv3_icv_iar_read(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_IAR%d read cpu 0x%x value 0x%" PRIx64
167
-static struct {
323
+gicv3_icv_nmiar1_read(uint32_t cpu, uint64_t val) "GICv3 ICV_NMIAR1 read cpu 0x%x value 0x%" PRIx64
168
- int nregs;
324
gicv3_icv_eoir_write(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_EOIR%d write cpu 0x%x value 0x%" PRIx64
169
- int interleave;
325
gicv3_cpuif_virt_update(uint32_t cpuid, int idx, int hppvlpi, int grp, int prio) "GICv3 CPU i/f 0x%x virt HPPI update LR index %d HPPVLPI %d grp %d prio %d"
170
- int spacing;
326
gicv3_cpuif_virt_set_irqs(uint32_t cpuid, int fiqlevel, int irqlevel) "GICv3 CPU i/f 0x%x virt HPPI update: setting FIQ %d IRQ %d"
171
-} const neon_ls_element_type[11] = {
172
- {1, 4, 1},
173
- {1, 4, 2},
174
- {4, 1, 1},
175
- {2, 2, 2},
176
- {1, 3, 1},
177
- {1, 3, 2},
178
- {3, 1, 1},
179
- {1, 1, 1},
180
- {1, 2, 1},
181
- {1, 2, 2},
182
- {2, 1, 1}
183
-};
184
-
185
/* Translate a NEON load/store element instruction. Return nonzero if the
186
instruction is invalid. */
187
static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
188
{
189
int rd, rn, rm;
190
- int op;
191
int nregs;
192
- int interleave;
193
- int spacing;
194
int stride;
195
int size;
196
int reg;
197
int load;
198
- int n;
199
int vec_size;
200
- int mmu_idx;
201
- MemOp endian;
202
TCGv_i32 addr;
203
TCGv_i32 tmp;
204
- TCGv_i32 tmp2;
205
- TCGv_i64 tmp64;
206
207
if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
208
return 1;
209
@@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
210
rn = (insn >> 16) & 0xf;
211
rm = insn & 0xf;
212
load = (insn & (1 << 21)) != 0;
213
- endian = s->be_data;
214
- mmu_idx = get_mem_index(s);
215
if ((insn & (1 << 23)) == 0) {
216
- /* Load store all elements. */
217
- op = (insn >> 8) & 0xf;
218
- size = (insn >> 6) & 3;
219
- if (op > 10)
220
- return 1;
221
- /* Catch UNDEF cases for bad values of align field */
222
- switch (op & 0xc) {
223
- case 4:
224
- if (((insn >> 5) & 1) == 1) {
225
- return 1;
226
- }
227
- break;
228
- case 8:
229
- if (((insn >> 4) & 3) == 3) {
230
- return 1;
231
- }
232
- break;
233
- default:
234
- break;
235
- }
236
- nregs = neon_ls_element_type[op].nregs;
237
- interleave = neon_ls_element_type[op].interleave;
238
- spacing = neon_ls_element_type[op].spacing;
239
- if (size == 3 && (interleave | spacing) != 1) {
240
- return 1;
241
- }
242
- /* For our purposes, bytes are always little-endian. */
243
- if (size == 0) {
244
- endian = MO_LE;
245
- }
246
- /* Consecutive little-endian elements from a single register
247
- * can be promoted to a larger little-endian operation.
248
- */
249
- if (interleave == 1 && endian == MO_LE) {
250
- size = 3;
251
- }
252
- tmp64 = tcg_temp_new_i64();
253
- addr = tcg_temp_new_i32();
254
- tmp2 = tcg_const_i32(1 << size);
255
- load_reg_var(s, addr, rn);
256
- for (reg = 0; reg < nregs; reg++) {
257
- for (n = 0; n < 8 >> size; n++) {
258
- int xs;
259
- for (xs = 0; xs < interleave; xs++) {
260
- int tt = rd + reg + spacing * xs;
261
-
262
- if (load) {
263
- gen_aa32_ld_i64(s, tmp64, addr, mmu_idx, endian | size);
264
- neon_store_element64(tt, n, size, tmp64);
265
- } else {
266
- neon_load_element64(tmp64, tt, n, size);
267
- gen_aa32_st_i64(s, tmp64, addr, mmu_idx, endian | size);
268
- }
269
- tcg_gen_add_i32(addr, addr, tmp2);
270
- }
271
- }
272
- }
273
- tcg_temp_free_i32(addr);
274
- tcg_temp_free_i32(tmp2);
275
- tcg_temp_free_i64(tmp64);
276
- stride = nregs * interleave * 8;
277
+ /* Load store all elements -- handled already by decodetree */
278
+ return 1;
279
} else {
280
size = (insn >> 10) & 3;
281
if (size == 3) {
282
--
327
--
283
2.20.1
328
2.34.1
284
285
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Remove inclusion of arm_gicv3_common.h, this already gets
3
If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI priority is
4
included via xlnx-versal.h.
4
higher than 0x80, otherwise it is higher than 0x0. And save the interrupt
5
non-maskable property in hppi.nmi to deliver NMI exception. Since both GICR
6
and GICD can deliver NMI, it is both necessary to check whether the pending
7
irq is NMI in gicv3_redist_update_noirqset and gicv3_update_noirqset.
5
8
6
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20200427181649.26851-2-edgar.iglesias@gmail.com
12
Message-id: 20240407081733.3231820-21-ruanjinjie@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
14
---
12
hw/arm/xlnx-versal.c | 1 -
15
hw/intc/arm_gicv3.c | 67 +++++++++++++++++++++++++++++++++-----
13
1 file changed, 1 deletion(-)
16
hw/intc/arm_gicv3_common.c | 3 ++
17
hw/intc/arm_gicv3_redist.c | 3 ++
18
3 files changed, 64 insertions(+), 9 deletions(-)
14
19
15
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
20
diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c
16
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/xlnx-versal.c
22
--- a/hw/intc/arm_gicv3.c
18
+++ b/hw/arm/xlnx-versal.c
23
+++ b/hw/intc/arm_gicv3.c
19
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@
20
#include "hw/arm/boot.h"
25
#include "hw/intc/arm_gicv3.h"
21
#include "kvm_arm.h"
26
#include "gicv3_internal.h"
22
#include "hw/misc/unimp.h"
27
23
-#include "hw/intc/arm_gicv3_common.h"
28
-static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio)
24
#include "hw/arm/xlnx-versal.h"
29
+static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio, bool nmi)
25
#include "hw/char/pl011.h"
30
{
31
/* Return true if this IRQ at this priority should take
32
* precedence over the current recorded highest priority
33
@@ -XXX,XX +XXX,XX @@ static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio)
34
* is the same as this one (a property which the calling code
35
* relies on).
36
*/
37
- if (prio < cs->hppi.prio) {
38
- return true;
39
+ if (prio != cs->hppi.prio) {
40
+ return prio < cs->hppi.prio;
41
}
42
+
43
+ /*
44
+ * The same priority IRQ with non-maskable property should signal to
45
+ * the CPU as it have the priority higher than the labelled 0x80 or 0x00.
46
+ */
47
+ if (nmi != cs->hppi.nmi) {
48
+ return nmi;
49
+ }
50
+
51
/* If multiple pending interrupts have the same priority then it is an
52
* IMPDEF choice which of them to signal to the CPU. We choose to
53
* signal the one with the lowest interrupt number.
54
*/
55
- if (prio == cs->hppi.prio && irq <= cs->hppi.irq) {
56
+ if (irq <= cs->hppi.irq) {
57
return true;
58
}
59
return false;
60
@@ -XXX,XX +XXX,XX @@ static uint32_t gicr_int_pending(GICv3CPUState *cs)
61
return pend;
62
}
63
64
+static bool gicv3_get_priority(GICv3CPUState *cs, bool is_redist, int irq,
65
+ uint8_t *prio)
66
+{
67
+ uint32_t nmi = 0x0;
68
+
69
+ if (is_redist) {
70
+ nmi = extract32(cs->gicr_inmir0, irq, 1);
71
+ } else {
72
+ nmi = *gic_bmp_ptr32(cs->gic->nmi, irq);
73
+ nmi = nmi & (1 << (irq & 0x1f));
74
+ }
75
+
76
+ if (nmi) {
77
+ /* DS = 0 & Non-secure NMI */
78
+ if (!(cs->gic->gicd_ctlr & GICD_CTLR_DS) &&
79
+ ((is_redist && extract32(cs->gicr_igroupr0, irq, 1)) ||
80
+ (!is_redist && gicv3_gicd_group_test(cs->gic, irq)))) {
81
+ *prio = 0x80;
82
+ } else {
83
+ *prio = 0x0;
84
+ }
85
+
86
+ return true;
87
+ }
88
+
89
+ if (is_redist) {
90
+ *prio = cs->gicr_ipriorityr[irq];
91
+ } else {
92
+ *prio = cs->gic->gicd_ipriority[irq];
93
+ }
94
+
95
+ return false;
96
+}
97
+
98
/* Update the interrupt status after state in a redistributor
99
* or CPU interface has changed, but don't tell the CPU i/f.
100
*/
101
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs)
102
uint8_t prio;
103
int i;
104
uint32_t pend;
105
+ bool nmi = false;
106
107
/* Find out which redistributor interrupts are eligible to be
108
* signaled to the CPU interface.
109
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs)
110
if (!(pend & (1 << i))) {
111
continue;
112
}
113
- prio = cs->gicr_ipriorityr[i];
114
- if (irqbetter(cs, i, prio)) {
115
+ nmi = gicv3_get_priority(cs, true, i, &prio);
116
+ if (irqbetter(cs, i, prio, nmi)) {
117
cs->hppi.irq = i;
118
cs->hppi.prio = prio;
119
+ cs->hppi.nmi = nmi;
120
seenbetter = true;
121
}
122
}
123
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs)
124
if ((cs->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) && cs->gic->lpi_enable &&
125
(cs->gic->gicd_ctlr & GICD_CTLR_EN_GRP1NS) &&
126
(cs->hpplpi.prio != 0xff)) {
127
- if (irqbetter(cs, cs->hpplpi.irq, cs->hpplpi.prio)) {
128
+ if (irqbetter(cs, cs->hpplpi.irq, cs->hpplpi.prio, cs->hpplpi.nmi)) {
129
cs->hppi.irq = cs->hpplpi.irq;
130
cs->hppi.prio = cs->hpplpi.prio;
131
+ cs->hppi.nmi = cs->hpplpi.nmi;
132
cs->hppi.grp = cs->hpplpi.grp;
133
seenbetter = true;
134
}
135
@@ -XXX,XX +XXX,XX @@ static void gicv3_update_noirqset(GICv3State *s, int start, int len)
136
int i;
137
uint8_t prio;
138
uint32_t pend = 0;
139
+ bool nmi = false;
140
141
assert(start >= GIC_INTERNAL);
142
assert(len > 0);
143
@@ -XXX,XX +XXX,XX @@ static void gicv3_update_noirqset(GICv3State *s, int start, int len)
144
*/
145
continue;
146
}
147
- prio = s->gicd_ipriority[i];
148
- if (irqbetter(cs, i, prio)) {
149
+ nmi = gicv3_get_priority(cs, false, i, &prio);
150
+ if (irqbetter(cs, i, prio, nmi)) {
151
cs->hppi.irq = i;
152
cs->hppi.prio = prio;
153
+ cs->hppi.nmi = nmi;
154
cs->seenbetter = true;
155
}
156
}
157
@@ -XXX,XX +XXX,XX @@ void gicv3_full_update_noirqset(GICv3State *s)
158
159
for (i = 0; i < s->num_cpu; i++) {
160
s->cpu[i].hppi.prio = 0xff;
161
+ s->cpu[i].hppi.nmi = false;
162
}
163
164
/* Note that we can guarantee that these functions will not
165
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
166
index XXXXXXX..XXXXXXX 100644
167
--- a/hw/intc/arm_gicv3_common.c
168
+++ b/hw/intc/arm_gicv3_common.c
169
@@ -XXX,XX +XXX,XX @@ static void arm_gicv3_common_reset_hold(Object *obj)
170
memset(cs->gicr_ipriorityr, 0, sizeof(cs->gicr_ipriorityr));
171
172
cs->hppi.prio = 0xff;
173
+ cs->hppi.nmi = false;
174
cs->hpplpi.prio = 0xff;
175
+ cs->hpplpi.nmi = false;
176
cs->hppvlpi.prio = 0xff;
177
+ cs->hppvlpi.nmi = false;
178
179
/* State in the CPU interface must *not* be reset here, because it
180
* is part of the CPU's reset domain, not the GIC device's.
181
diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c
182
index XXXXXXX..XXXXXXX 100644
183
--- a/hw/intc/arm_gicv3_redist.c
184
+++ b/hw/intc/arm_gicv3_redist.c
185
@@ -XXX,XX +XXX,XX @@ static void update_for_one_lpi(GICv3CPUState *cs, int irq,
186
((prio == hpp->prio) && (irq <= hpp->irq))) {
187
hpp->irq = irq;
188
hpp->prio = prio;
189
+ hpp->nmi = false;
190
/* LPIs and vLPIs are always non-secure Grp1 interrupts */
191
hpp->grp = GICV3_G1NS;
192
}
193
@@ -XXX,XX +XXX,XX @@ static void update_for_all_lpis(GICv3CPUState *cs, uint64_t ptbase,
194
int i, bit;
195
196
hpp->prio = 0xff;
197
+ hpp->nmi = false;
198
199
for (i = GICV3_LPI_INTID_START / 8; i < pendt_size / 8; i++) {
200
address_space_read(as, ptbase + i, MEMTXATTRS_UNSPECIFIED, &pend, 1);
201
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_vlpi_only(GICv3CPUState *cs)
202
203
if (!FIELD_EX64(cs->gicr_vpendbaser, GICR_VPENDBASER, VALID)) {
204
cs->hppvlpi.prio = 0xff;
205
+ cs->hppvlpi.nmi = false;
206
return;
207
}
26
208
27
--
209
--
28
2.20.1
210
2.34.1
29
30
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Add support for SD.
3
In CPU Interface, if the IRQ has the non-maskable property, report NMI to
4
the corresponding PE.
4
5
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
9
Message-id: 20240407081733.3231820-22-ruanjinjie@huawei.com
9
Message-id: 20200427181649.26851-9-edgar.iglesias@gmail.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
11
---
12
include/hw/arm/xlnx-versal.h | 12 ++++++++++++
12
hw/intc/arm_gicv3_cpuif.c | 4 ++++
13
hw/arm/xlnx-versal.c | 31 +++++++++++++++++++++++++++++++
13
1 file changed, 4 insertions(+)
14
2 files changed, 43 insertions(+)
15
14
16
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
15
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/xlnx-versal.h
17
--- a/hw/intc/arm_gicv3_cpuif.c
19
+++ b/include/hw/arm/xlnx-versal.h
18
+++ b/hw/intc/arm_gicv3_cpuif.c
20
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs)
21
20
/* Tell the CPU about its highest priority pending interrupt */
22
#include "hw/sysbus.h"
21
int irqlevel = 0;
23
#include "hw/arm/boot.h"
22
int fiqlevel = 0;
24
+#include "hw/sd/sdhci.h"
23
+ int nmilevel = 0;
25
#include "hw/intc/arm_gicv3.h"
24
ARMCPU *cpu = ARM_CPU(cs->cpu);
26
#include "hw/char/pl011.h"
25
CPUARMState *env = &cpu->env;
27
#include "hw/dma/xlnx-zdma.h"
26
28
@@ -XXX,XX +XXX,XX @@
27
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs)
29
#define XLNX_VERSAL_NR_UARTS 2
28
30
#define XLNX_VERSAL_NR_GEMS 2
29
if (isfiq) {
31
#define XLNX_VERSAL_NR_ADMAS 8
30
fiqlevel = 1;
32
+#define XLNX_VERSAL_NR_SDS 2
31
+ } else if (cs->hppi.nmi) {
33
#define XLNX_VERSAL_NR_IRQS 192
32
+ nmilevel = 1;
34
33
} else {
35
typedef struct Versal {
34
irqlevel = 1;
36
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
35
}
37
} iou;
36
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs)
38
} lpd;
37
39
38
qemu_set_irq(cs->parent_fiq, fiqlevel);
40
+ /* The Platform Management Controller subsystem. */
39
qemu_set_irq(cs->parent_irq, irqlevel);
41
+ struct {
40
+ qemu_set_irq(cs->parent_nmi, nmilevel);
42
+ struct {
43
+ SDHCIState sd[XLNX_VERSAL_NR_SDS];
44
+ } iou;
45
+ } pmc;
46
+
47
struct {
48
MemoryRegion *mr_ddr;
49
uint32_t psci_conduit;
50
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
51
#define VERSAL_GEM1_IRQ_0 58
52
#define VERSAL_GEM1_WAKE_IRQ_0 59
53
#define VERSAL_ADMA_IRQ_0 60
54
+#define VERSAL_SD0_IRQ_0 126
55
56
/* Architecturally reserved IRQs suitable for virtualization. */
57
#define VERSAL_RSVD_IRQ_FIRST 111
58
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
59
#define MM_FPD_CRF 0xfd1a0000U
60
#define MM_FPD_CRF_SIZE 0x140000
61
62
+#define MM_PMC_SD0 0xf1040000U
63
+#define MM_PMC_SD0_SIZE 0x10000
64
#define MM_PMC_CRP 0xf1260000U
65
#define MM_PMC_CRP_SIZE 0x10000
66
#endif
67
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/hw/arm/xlnx-versal.c
70
+++ b/hw/arm/xlnx-versal.c
71
@@ -XXX,XX +XXX,XX @@ static void versal_create_admas(Versal *s, qemu_irq *pic)
72
}
73
}
41
}
74
42
75
+#define SDHCI_CAPABILITIES 0x280737ec6481 /* Same as on ZynqMP. */
43
static uint64_t icc_pmr_read(CPUARMState *env, const ARMCPRegInfo *ri)
76
+static void versal_create_sds(Versal *s, qemu_irq *pic)
77
+{
78
+ int i;
79
+
80
+ for (i = 0; i < ARRAY_SIZE(s->pmc.iou.sd); i++) {
81
+ DeviceState *dev;
82
+ MemoryRegion *mr;
83
+
84
+ sysbus_init_child_obj(OBJECT(s), "sd[*]",
85
+ &s->pmc.iou.sd[i], sizeof(s->pmc.iou.sd[i]),
86
+ TYPE_SYSBUS_SDHCI);
87
+ dev = DEVICE(&s->pmc.iou.sd[i]);
88
+
89
+ object_property_set_uint(OBJECT(dev),
90
+ 3, "sd-spec-version", &error_fatal);
91
+ object_property_set_uint(OBJECT(dev), SDHCI_CAPABILITIES, "capareg",
92
+ &error_fatal);
93
+ object_property_set_uint(OBJECT(dev), UHS_I, "uhs", &error_fatal);
94
+ qdev_init_nofail(dev);
95
+
96
+ mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
97
+ memory_region_add_subregion(&s->mr_ps,
98
+ MM_PMC_SD0 + i * MM_PMC_SD0_SIZE, mr);
99
+
100
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
101
+ pic[VERSAL_SD0_IRQ_0 + i * 2]);
102
+ }
103
+}
104
+
105
/* This takes the board allocated linear DDR memory and creates aliases
106
* for each split DDR range/aperture on the Versal address map.
107
*/
108
@@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp)
109
versal_create_uarts(s, pic);
110
versal_create_gems(s, pic);
111
versal_create_admas(s, pic);
112
+ versal_create_sds(s, pic);
113
versal_map_ddr(s);
114
versal_unimp(s);
115
116
--
44
--
117
2.20.1
45
2.34.1
118
119
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Embed the APUs into the SoC type.
3
In vCPU Interface, if the vIRQ has the non-maskable property, report
4
vINMI to the corresponding vPE.
4
5
5
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20240407081733.3231820-23-ruanjinjie@huawei.com
9
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
10
Message-id: 20200427181649.26851-8-edgar.iglesias@gmail.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
include/hw/arm/xlnx-versal.h | 2 +-
12
hw/intc/arm_gicv3_cpuif.c | 14 ++++++++++++--
14
hw/arm/xlnx-versal-virt.c | 4 ++--
13
1 file changed, 12 insertions(+), 2 deletions(-)
15
hw/arm/xlnx-versal.c | 19 +++++--------------
16
3 files changed, 8 insertions(+), 17 deletions(-)
17
14
18
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
15
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/arm/xlnx-versal.h
17
--- a/hw/intc/arm_gicv3_cpuif.c
21
+++ b/include/hw/arm/xlnx-versal.h
18
+++ b/hw/intc/arm_gicv3_cpuif.c
22
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
19
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs)
23
struct {
20
int idx;
24
struct {
21
int irqlevel = 0;
25
MemoryRegion mr;
22
int fiqlevel = 0;
26
- ARMCPU *cpu[XLNX_VERSAL_NR_ACPUS];
23
+ int nmilevel = 0;
27
+ ARMCPU cpu[XLNX_VERSAL_NR_ACPUS];
24
28
GICv3State gic;
25
idx = hppvi_index(cs);
29
} apu;
26
trace_gicv3_cpuif_virt_update(gicv3_redist_affid(cs), idx,
30
} fpd;
27
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs)
31
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
28
uint64_t lr = cs->ich_lr_el2[idx];
32
index XXXXXXX..XXXXXXX 100644
29
33
--- a/hw/arm/xlnx-versal-virt.c
30
if (icv_hppi_can_preempt(cs, lr)) {
34
+++ b/hw/arm/xlnx-versal-virt.c
31
- /* Virtual interrupts are simple: G0 are always FIQ, and G1 IRQ */
35
@@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine)
32
+ /*
36
s->binfo.get_dtb = versal_virt_get_dtb;
33
+ * Virtual interrupts are simple: G0 are always FIQ, and G1 are
37
s->binfo.modify_dtb = versal_virt_modify_dtb;
34
+ * IRQ or NMI which depends on the ICH_LR<n>_EL2.NMI to have
38
if (machine->kernel_filename) {
35
+ * non-maskable property.
39
- arm_load_kernel(s->soc.fpd.apu.cpu[0], machine, &s->binfo);
36
+ */
40
+ arm_load_kernel(&s->soc.fpd.apu.cpu[0], machine, &s->binfo);
37
if (lr & ICH_LR_EL2_GROUP) {
41
} else {
38
- irqlevel = 1;
42
- AddressSpace *as = arm_boot_address_space(s->soc.fpd.apu.cpu[0],
39
+ if (lr & ICH_LR_EL2_NMI) {
43
+ AddressSpace *as = arm_boot_address_space(&s->soc.fpd.apu.cpu[0],
40
+ nmilevel = 1;
44
&s->binfo);
41
+ } else {
45
/* Some boot-loaders (e.g u-boot) don't like blobs at address 0 (NULL).
42
+ irqlevel = 1;
46
* Offset things by 4K. */
43
+ }
47
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
44
} else {
48
index XXXXXXX..XXXXXXX 100644
45
fiqlevel = 1;
49
--- a/hw/arm/xlnx-versal.c
46
}
50
+++ b/hw/arm/xlnx-versal.c
47
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs)
51
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s)
48
trace_gicv3_cpuif_virt_set_irqs(gicv3_redist_affid(cs), fiqlevel, irqlevel);
52
49
qemu_set_irq(cs->parent_vfiq, fiqlevel);
53
for (i = 0; i < ARRAY_SIZE(s->fpd.apu.cpu); i++) {
50
qemu_set_irq(cs->parent_virq, irqlevel);
54
Object *obj;
51
+ qemu_set_irq(cs->parent_vnmi, nmilevel);
55
- char *name;
56
-
57
- obj = object_new(XLNX_VERSAL_ACPU_TYPE);
58
- if (!obj) {
59
- error_report("Unable to create apu.cpu[%d] of type %s",
60
- i, XLNX_VERSAL_ACPU_TYPE);
61
- exit(EXIT_FAILURE);
62
- }
63
-
64
- name = g_strdup_printf("apu-cpu[%d]", i);
65
- object_property_add_child(OBJECT(s), name, obj, &error_fatal);
66
- g_free(name);
67
68
+ object_initialize_child(OBJECT(s), "apu-cpu[*]",
69
+ &s->fpd.apu.cpu[i], sizeof(s->fpd.apu.cpu[i]),
70
+ XLNX_VERSAL_ACPU_TYPE, &error_abort, NULL);
71
+ obj = OBJECT(&s->fpd.apu.cpu[i]);
72
object_property_set_int(obj, s->cfg.psci_conduit,
73
"psci-conduit", &error_abort);
74
if (i) {
75
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s)
76
object_property_set_link(obj, OBJECT(&s->fpd.apu.mr), "memory",
77
&error_abort);
78
object_property_set_bool(obj, true, "realized", &error_fatal);
79
- s->fpd.apu.cpu[i] = ARM_CPU(obj);
80
}
81
}
52
}
82
53
83
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pic)
54
static void gicv3_cpuif_virt_update(GICv3CPUState *cs)
84
}
85
86
for (i = 0; i < nr_apu_cpus; i++) {
87
- DeviceState *cpudev = DEVICE(s->fpd.apu.cpu[i]);
88
+ DeviceState *cpudev = DEVICE(&s->fpd.apu.cpu[i]);
89
int ppibase = XLNX_VERSAL_NR_IRQS + i * GIC_INTERNAL + GIC_NR_SGIS;
90
qemu_irq maint_irq;
91
int ti;
92
--
55
--
93
2.20.1
56
2.34.1
94
95
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Embed the UARTs into the SoC type.
3
Enable FEAT_NMI on the 'max' CPU.
4
4
5
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20240407081733.3231820-24-ruanjinjie@huawei.com
9
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
10
Message-id: 20200427181649.26851-5-edgar.iglesias@gmail.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
10
---
13
include/hw/arm/xlnx-versal.h | 3 ++-
11
docs/system/arm/emulation.rst | 1 +
14
hw/arm/xlnx-versal.c | 12 ++++++------
12
target/arm/tcg/cpu64.c | 1 +
15
2 files changed, 8 insertions(+), 7 deletions(-)
13
2 files changed, 2 insertions(+)
16
14
17
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
15
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/arm/xlnx-versal.h
17
--- a/docs/system/arm/emulation.rst
20
+++ b/include/hw/arm/xlnx-versal.h
18
+++ b/docs/system/arm/emulation.rst
21
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
22
#include "hw/sysbus.h"
20
- FEAT_MTE (Memory Tagging Extension)
23
#include "hw/arm/boot.h"
21
- FEAT_MTE2 (Memory Tagging Extension)
24
#include "hw/intc/arm_gicv3.h"
22
- FEAT_MTE3 (MTE Asymmetric Fault Handling)
25
+#include "hw/char/pl011.h"
23
+- FEAT_NMI (Non-maskable Interrupt)
26
24
- FEAT_NV (Nested Virtualization)
27
#define TYPE_XLNX_VERSAL "xlnx-versal"
25
- FEAT_NV2 (Enhanced nested virtualization support)
28
#define XLNX_VERSAL(obj) OBJECT_CHECK(Versal, (obj), TYPE_XLNX_VERSAL)
26
- FEAT_PACIMP (Pointer authentication - IMPLEMENTATION DEFINED algorithm)
29
@@ -XXX,XX +XXX,XX @@ typedef struct Versal {
27
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
30
MemoryRegion mr_ocm;
31
32
struct {
33
- SysBusDevice *uart[XLNX_VERSAL_NR_UARTS];
34
+ PL011State uart[XLNX_VERSAL_NR_UARTS];
35
SysBusDevice *gem[XLNX_VERSAL_NR_GEMS];
36
SysBusDevice *adma[XLNX_VERSAL_NR_ADMAS];
37
} iou;
38
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
39
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
40
--- a/hw/arm/xlnx-versal.c
29
--- a/target/arm/tcg/cpu64.c
41
+++ b/hw/arm/xlnx-versal.c
30
+++ b/target/arm/tcg/cpu64.c
42
@@ -XXX,XX +XXX,XX @@
31
@@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj)
43
#include "kvm_arm.h"
32
t = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT_DoubleFault */
44
#include "hw/misc/unimp.h"
33
t = FIELD_DP64(t, ID_AA64PFR1, SME, 1); /* FEAT_SME */
45
#include "hw/arm/xlnx-versal.h"
34
t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */
46
-#include "hw/char/pl011.h"
35
+ t = FIELD_DP64(t, ID_AA64PFR1, NMI, 1); /* FEAT_NMI */
47
36
cpu->isar.id_aa64pfr1 = t;
48
#define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72")
37
49
#define GEM_REVISION 0x40070106
38
t = cpu->isar.id_aa64mmfr0;
50
@@ -XXX,XX +XXX,XX @@ static void versal_create_uarts(Versal *s, qemu_irq *pic)
51
DeviceState *dev;
52
MemoryRegion *mr;
53
54
- dev = qdev_create(NULL, TYPE_PL011);
55
- s->lpd.iou.uart[i] = SYS_BUS_DEVICE(dev);
56
+ sysbus_init_child_obj(OBJECT(s), name,
57
+ &s->lpd.iou.uart[i], sizeof(s->lpd.iou.uart[i]),
58
+ TYPE_PL011);
59
+ dev = DEVICE(&s->lpd.iou.uart[i]);
60
qdev_prop_set_chr(dev, "chardev", serial_hd(i));
61
- object_property_add_child(OBJECT(s), name, OBJECT(dev), &error_fatal);
62
qdev_init_nofail(dev);
63
64
- mr = sysbus_mmio_get_region(s->lpd.iou.uart[i], 0);
65
+ mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
66
memory_region_add_subregion(&s->mr_ps, addrs[i], mr);
67
68
- sysbus_connect_irq(s->lpd.iou.uart[i], 0, pic[irqs[i]]);
69
+ sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irqs[i]]);
70
g_free(name);
71
}
72
}
73
--
39
--
74
2.20.1
40
2.34.1
75
76
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Add support for SD.
3
If the CPU implements FEAT_NMI, then turn on the NMI support in the
4
GICv3 too. It's permitted to have a configuration with FEAT_NMI in
5
the CPU (and thus NMI support in the CPU interfaces too) but no NMI
6
support in the distributor and redistributor, but this isn't a very
7
useful setup as it's close to having no NMI support at all.
4
8
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9
We don't need to gate the enabling of NMI in the GIC behind a
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
10
machine version property, because none of our current CPUs
7
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
11
implement FEAT_NMI, and '-cpu max' is not something we maintain
8
Message-id: 20200427181649.26851-11-edgar.iglesias@gmail.com
12
migration compatibility across versions for. So we can always
13
enable the GIC NMI support when the CPU has it.
14
15
Neither hvf nor KVM support NMI in the GIC yet, so we don't enable
16
it unless we're using TCG.
17
18
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Message-id: 20240407081733.3231820-25-ruanjinjie@huawei.com
21
[PMM: Update comment and commit message]
22
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
24
---
11
hw/arm/xlnx-versal-virt.c | 46 +++++++++++++++++++++++++++++++++++++++
25
hw/arm/virt.c | 19 +++++++++++++++++++
12
1 file changed, 46 insertions(+)
26
1 file changed, 19 insertions(+)
13
27
14
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
28
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
15
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/xlnx-versal-virt.c
30
--- a/hw/arm/virt.c
17
+++ b/hw/arm/xlnx-versal-virt.c
31
+++ b/hw/arm/virt.c
18
@@ -XXX,XX +XXX,XX @@
32
@@ -XXX,XX +XXX,XX @@ static void create_v2m(VirtMachineState *vms)
19
#include "hw/arm/sysbus-fdt.h"
33
vms->msi_controller = VIRT_MSI_CTRL_GICV2M;
20
#include "hw/arm/fdt.h"
21
#include "cpu.h"
22
+#include "hw/qdev-properties.h"
23
#include "hw/arm/xlnx-versal.h"
24
25
#define TYPE_XLNX_VERSAL_VIRT_MACHINE MACHINE_TYPE_NAME("xlnx-versal-virt")
26
@@ -XXX,XX +XXX,XX @@ static void fdt_add_zdma_nodes(VersalVirt *s)
27
}
28
}
34
}
29
35
30
+static void fdt_add_sd_nodes(VersalVirt *s)
36
+/*
37
+ * If the CPU has FEAT_NMI, then turn on the NMI support in the GICv3 too.
38
+ * It's permitted to have a configuration with NMI in the CPU (and thus the
39
+ * GICv3 CPU interface) but not in the distributor/redistributors, but it's
40
+ * not very useful.
41
+ */
42
+static bool gicv3_nmi_present(VirtMachineState *vms)
31
+{
43
+{
32
+ const char clocknames[] = "clk_xin\0clk_ahb";
44
+ ARMCPU *cpu = ARM_CPU(qemu_get_cpu(0));
33
+ const char compat[] = "arasan,sdhci-8.9a";
34
+ int i;
35
+
45
+
36
+ for (i = ARRAY_SIZE(s->soc.pmc.iou.sd) - 1; i >= 0; i--) {
46
+ return tcg_enabled() && cpu_isar_feature(aa64_nmi, cpu) &&
37
+ uint64_t addr = MM_PMC_SD0 + MM_PMC_SD0_SIZE * i;
47
+ (vms->gic_version != VIRT_GIC_VERSION_2);
38
+ char *name = g_strdup_printf("/sdhci@%" PRIx64, addr);
39
+
40
+ qemu_fdt_add_subnode(s->fdt, name);
41
+
42
+ qemu_fdt_setprop_cells(s->fdt, name, "clocks",
43
+ s->phandle.clk_25Mhz, s->phandle.clk_25Mhz);
44
+ qemu_fdt_setprop(s->fdt, name, "clock-names",
45
+ clocknames, sizeof(clocknames));
46
+ qemu_fdt_setprop_cells(s->fdt, name, "interrupts",
47
+ GIC_FDT_IRQ_TYPE_SPI, VERSAL_SD0_IRQ_0 + i * 2,
48
+ GIC_FDT_IRQ_FLAGS_LEVEL_HI);
49
+ qemu_fdt_setprop_sized_cells(s->fdt, name, "reg",
50
+ 2, addr, 2, MM_PMC_SD0_SIZE);
51
+ qemu_fdt_setprop(s->fdt, name, "compatible", compat, sizeof(compat));
52
+ g_free(name);
53
+ }
54
+}
48
+}
55
+
49
+
56
static void fdt_nop_memory_nodes(void *fdt, Error **errp)
50
static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
57
{
51
{
58
Error *err = NULL;
52
MachineState *ms = MACHINE(vms);
59
@@ -XXX,XX +XXX,XX @@ static void create_virtio_regions(VersalVirt *s)
53
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
54
vms->virt);
55
}
60
}
56
}
61
}
62
63
+static void sd_plugin_card(SDHCIState *sd, DriveInfo *di)
64
+{
65
+ BlockBackend *blk = di ? blk_by_legacy_dinfo(di) : NULL;
66
+ DeviceState *card;
67
+
57
+
68
+ card = qdev_create(qdev_get_child_bus(DEVICE(sd), "sd-bus"), TYPE_SD_CARD);
58
+ if (gicv3_nmi_present(vms)) {
69
+ object_property_add_child(OBJECT(sd), "card[*]", OBJECT(card),
59
+ qdev_prop_set_bit(vms->gic, "has-nmi", true);
70
+ &error_fatal);
71
+ qdev_prop_set_drive(card, "drive", blk, &error_fatal);
72
+ object_property_set_bool(OBJECT(card), true, "realized", &error_fatal);
73
+}
74
+
75
static void versal_virt_init(MachineState *machine)
76
{
77
VersalVirt *s = XLNX_VERSAL_VIRT_MACHINE(machine);
78
int psci_conduit = QEMU_PSCI_CONDUIT_DISABLED;
79
+ int i;
80
81
/*
82
* If the user provides an Operating System to be loaded, we expect them
83
@@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine)
84
fdt_add_gic_nodes(s);
85
fdt_add_timer_nodes(s);
86
fdt_add_zdma_nodes(s);
87
+ fdt_add_sd_nodes(s);
88
fdt_add_cpu_nodes(s, psci_conduit);
89
fdt_add_clk_node(s, "/clk125", 125000000, s->phandle.clk_125Mhz);
90
fdt_add_clk_node(s, "/clk25", 25000000, s->phandle.clk_25Mhz);
91
@@ -XXX,XX +XXX,XX @@ static void versal_virt_init(MachineState *machine)
92
memory_region_add_subregion_overlap(get_system_memory(),
93
0, &s->soc.fpd.apu.mr, 0);
94
95
+ /* Plugin SD cards. */
96
+ for (i = 0; i < ARRAY_SIZE(s->soc.pmc.iou.sd); i++) {
97
+ sd_plugin_card(&s->soc.pmc.iou.sd[i], drive_get_next(IF_SD));
98
+ }
60
+ }
99
+
61
+
100
s->binfo.ram_size = machine->ram_size;
62
gicbusdev = SYS_BUS_DEVICE(vms->gic);
101
s->binfo.loader_start = 0x0;
63
sysbus_realize_and_unref(gicbusdev, &error_fatal);
102
s->binfo.get_dtb = versal_virt_get_dtb;
64
sysbus_mmio_map(gicbusdev, 0, vms->memmap[VIRT_GIC_DIST].base);
103
--
65
--
104
2.20.1
66
2.34.1
105
106
diff view generated by jsdifflib
1
From: Fredrik Strupe <fredrik@strupe.net>
1
From: Anastasia Belova <abelova@astralinux.ru>
2
2
3
According to Arm ARM, VQDMULL is only valid when U=0, while having
3
In soc_dma_set_request() we try to set a bit in a uint64_t, but we
4
U=1 is unallocated.
4
do it with "1 << ch->num", which can't set any bits past 31;
5
any use for a channel number of 32 or more would fail due to
6
integer overflow.
5
7
6
Signed-off-by: Fredrik Strupe <fredrik@strupe.net>
8
This doesn't happen in practice for our current use of this code,
7
Fixes: 695272dcb976 ("target-arm: Handle UNDEF cases for Neon 3-regs-different-widths")
9
because the worst case is when we call soc_dma_init() with an
10
argument of 32 for the number of channels, and QEMU builds with
11
-fwrapv so the shift into the sign bit is well-defined. However,
12
it's obviously not the intended behaviour of the code.
13
14
Add casts to force the shift to be done as 64-bit arithmetic,
15
allowing up to 64 channels.
16
17
Found by Linux Verification Center (linuxtesting.org) with SVACE.
18
19
Fixes: afbb5194d4 ("Handle on-chip DMA controllers in one place, convert OMAP DMA to use it.")
20
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
21
Message-id: 20240409115301.21829-1-abelova@astralinux.ru
22
[PMM: Edit commit message to clarify that this doesn't actually
23
bite us in our current usage of this code.]
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
26
---
11
target/arm/translate.c | 2 +-
27
hw/dma/soc_dma.c | 4 ++--
12
1 file changed, 1 insertion(+), 1 deletion(-)
28
1 file changed, 2 insertions(+), 2 deletions(-)
13
29
14
diff --git a/target/arm/translate.c b/target/arm/translate.c
30
diff --git a/hw/dma/soc_dma.c b/hw/dma/soc_dma.c
15
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/translate.c
32
--- a/hw/dma/soc_dma.c
17
+++ b/target/arm/translate.c
33
+++ b/hw/dma/soc_dma.c
18
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
34
@@ -XXX,XX +XXX,XX @@ void soc_dma_set_request(struct soc_dma_ch_s *ch, int level)
19
{0, 0, 0, 0}, /* VMLSL */
35
dma->enabled_count += level - ch->enable;
20
{0, 0, 0, 9}, /* VQDMLSL */
36
21
{0, 0, 0, 0}, /* Integer VMULL */
37
if (level)
22
- {0, 0, 0, 1}, /* VQDMULL */
38
- dma->ch_enable_mask |= 1 << ch->num;
23
+ {0, 0, 0, 9}, /* VQDMULL */
39
+ dma->ch_enable_mask |= (uint64_t)1 << ch->num;
24
{0, 0, 0, 0xa}, /* Polynomial VMULL */
40
else
25
{0, 0, 0, 7}, /* Reserved: always UNDEF */
41
- dma->ch_enable_mask &= ~(1 << ch->num);
26
};
42
+ dma->ch_enable_mask &= ~((uint64_t)1 << ch->num);
43
44
if (level != ch->enable) {
45
soc_dma_ch_freq_update(dma);
27
--
46
--
28
2.20.1
47
2.34.1
29
30
diff view generated by jsdifflib
Deleted patch
1
In aarch64_max_initfn() we update both 32-bit and 64-bit ID
2
registers. The intended pattern is that for 64-bit ID registers we
3
use FIELD_DP64 and the uint64_t 't' register, while 32-bit ID
4
registers use FIELD_DP32 and the uint32_t 'u' register. For
5
ID_AA64DFR0 we accidentally used 'u', meaning that the top 32 bits of
6
this 64-bit ID register would end up always zero. Luckily at the
7
moment that's what they should be anyway, so this bug has no visible
8
effects.
9
1
10
Use the right-sized variable.
11
12
Fixes: 3bec78447a958d481991
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com>
15
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Message-id: 20200423110915.10527-1-peter.maydell@linaro.org
17
---
18
target/arm/cpu64.c | 6 +++---
19
1 file changed, 3 insertions(+), 3 deletions(-)
20
21
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/cpu64.c
24
+++ b/target/arm/cpu64.c
25
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
26
u = FIELD_DP32(u, ID_MMFR4, XNX, 1); /* TTS2UXN */
27
cpu->isar.id_mmfr4 = u;
28
29
- u = cpu->isar.id_aa64dfr0;
30
- u = FIELD_DP64(u, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */
31
- cpu->isar.id_aa64dfr0 = u;
32
+ t = cpu->isar.id_aa64dfr0;
33
+ t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 5); /* v8.4-PMU */
34
+ cpu->isar.id_aa64dfr0 = t;
35
36
u = cpu->isar.id_dfr0;
37
u = FIELD_DP32(u, ID_DFR0, PERFMON, 5); /* v8.4-PMU */
38
--
39
2.20.1
40
41
diff view generated by jsdifflib
1
Convert the VCADD (vector) insns to decodetree.
1
Ever since the bFLT format support was added in 2006, there has been
2
a chunk of code in the file guarded by CONFIG_BINFMT_SHARED_FLAT
3
which is supposedly for shared library support. This is not enabled
4
and it's not possible to enable it, because if you do you'll run into
5
the "#error needs checking" in the calc_reloc() function.
6
7
Similarly, CONFIG_BINFMT_ZFLAT exists but can't be enabled because of
8
an "#error code needs checking" in load_flat_file().
9
10
This code is obviously unfinished and has never been used; nobody in
11
the intervening 18 years has complained about this or fixed it, so
12
just delete the dead code. If anybody ever wants the feature they
13
can always pull it out of git, or (perhaps better) write it from
14
scratch based on the current Linux bFLT loader rather than the one of
15
18 years ago.
2
16
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Message-id: 20200430181003.21682-6-peter.maydell@linaro.org
19
Message-id: 20240411115313.680433-1-peter.maydell@linaro.org
6
---
20
---
7
target/arm/neon-shared.decode | 3 +++
21
linux-user/flat.h | 5 +-
8
target/arm/translate-neon.inc.c | 37 +++++++++++++++++++++++++++++++++
22
linux-user/flatload.c | 293 ++----------------------------------------
9
target/arm/translate.c | 11 +---------
23
2 files changed, 11 insertions(+), 287 deletions(-)
10
3 files changed, 41 insertions(+), 10 deletions(-)
24
11
25
diff --git a/linux-user/flat.h b/linux-user/flat.h
12
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
13
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/neon-shared.decode
27
--- a/linux-user/flat.h
15
+++ b/target/arm/neon-shared.decode
28
+++ b/linux-user/flat.h
16
@@ -XXX,XX +XXX,XX @@
29
@@ -XXX,XX +XXX,XX @@
17
30
18
VCMLA 1111 110 rot:2 . 1 size:1 .... .... 1000 . q:1 . 0 .... \
31
#define    FLAT_VERSION            0x00000004L
19
vm=%vm_dp vn=%vn_dp vd=%vd_dp
32
20
+
33
-#ifdef CONFIG_BINFMT_SHARED_FLAT
21
+VCADD 1111 110 rot:1 1 . 0 size:1 .... .... 1000 . q:1 . 0 .... \
34
-#define    MAX_SHARED_LIBS            (4)
22
+ vm=%vm_dp vn=%vn_dp vd=%vd_dp
35
-#else
23
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
36
+/* QEMU doesn't support bflt shared libraries */
37
#define    MAX_SHARED_LIBS            (1)
38
-#endif
39
40
/*
41
* To make everything easier to port and manage cross platform
42
diff --git a/linux-user/flatload.c b/linux-user/flatload.c
24
index XXXXXXX..XXXXXXX 100644
43
index XXXXXXX..XXXXXXX 100644
25
--- a/target/arm/translate-neon.inc.c
44
--- a/linux-user/flatload.c
26
+++ b/target/arm/translate-neon.inc.c
45
+++ b/linux-user/flatload.c
27
@@ -XXX,XX +XXX,XX @@ static bool trans_VCMLA(DisasContext *s, arg_VCMLA *a)
46
@@ -XXX,XX +XXX,XX @@
28
tcg_temp_free_ptr(fpst);
47
*    JAN/99 -- coded full program relocation (gerg@snapgear.com)
29
return true;
48
*/
49
50
-/* ??? ZFLAT and shared library support is currently disabled. */
51
-
52
/****************************************************************************/
53
54
#include "qemu/osdep.h"
55
@@ -XXX,XX +XXX,XX @@ struct lib_info {
56
short loaded;        /* Has this library been loaded? */
57
};
58
59
-#ifdef CONFIG_BINFMT_SHARED_FLAT
60
-static int load_flat_shared_library(int id, struct lib_info *p);
61
-#endif
62
-
63
struct linux_binprm;
64
65
/****************************************************************************/
66
@@ -XXX,XX +XXX,XX @@ static int target_pread(int fd, abi_ulong ptr, abi_ulong len,
67
unlock_user(buf, ptr, len);
68
return ret;
30
}
69
}
31
+
70
-/****************************************************************************/
32
+static bool trans_VCADD(DisasContext *s, arg_VCADD *a)
71
-
33
+{
72
-#ifdef CONFIG_BINFMT_ZFLAT
34
+ int opr_sz;
73
-
35
+ TCGv_ptr fpst;
74
-#include <linux/zlib.h>
36
+ gen_helper_gvec_3_ptr *fn_gvec_ptr;
75
-
37
+
76
-#define LBUFSIZE    4000
38
+ if (!dc_isar_feature(aa32_vcma, s)
77
-
39
+ || (!a->size && !dc_isar_feature(aa32_fp16_arith, s))) {
78
-/* gzip flag byte */
40
+ return false;
79
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
41
+ }
80
-#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
42
+
81
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
43
+ /* UNDEF accesses to D16-D31 if they don't exist. */
82
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
44
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
83
-#define COMMENT 0x10 /* bit 4 set: file comment present */
45
+ ((a->vd | a->vn | a->vm) & 0x10)) {
84
-#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
46
+ return false;
85
-#define RESERVED 0xC0 /* bit 6,7: reserved */
47
+ }
86
-
48
+
87
-static int decompress_exec(
49
+ if ((a->vn | a->vm | a->vd) & a->q) {
88
-    struct linux_binprm *bprm,
50
+ return false;
89
-    unsigned long offset,
51
+ }
90
-    char *dst,
52
+
91
-    long len,
53
+ if (!vfp_access_check(s)) {
92
-    int fd)
54
+ return true;
93
-{
55
+ }
94
-    unsigned char *buf;
56
+
95
-    z_stream strm;
57
+ opr_sz = (1 + a->q) * 8;
96
-    loff_t fpos;
58
+ fpst = get_fpstatus_ptr(1);
97
-    int ret, retval;
59
+ fn_gvec_ptr = a->size ? gen_helper_gvec_fcadds : gen_helper_gvec_fcaddh;
98
-
60
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd),
99
-    DBG_FLT("decompress_exec(offset=%x,buf=%x,len=%x)\n",(int)offset, (int)dst, (int)len);
61
+ vfp_reg_offset(1, a->vn),
100
-
62
+ vfp_reg_offset(1, a->vm),
101
-    memset(&strm, 0, sizeof(strm));
63
+ fpst, opr_sz, opr_sz, a->rot,
102
-    strm.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
64
+ fn_gvec_ptr);
103
-    if (strm.workspace == NULL) {
65
+ tcg_temp_free_ptr(fpst);
104
-        DBG_FLT("binfmt_flat: no memory for decompress workspace\n");
66
+ return true;
105
-        return -ENOMEM;
67
+}
106
-    }
68
diff --git a/target/arm/translate.c b/target/arm/translate.c
107
-    buf = kmalloc(LBUFSIZE, GFP_KERNEL);
69
index XXXXXXX..XXXXXXX 100644
108
-    if (buf == NULL) {
70
--- a/target/arm/translate.c
109
-        DBG_FLT("binfmt_flat: no memory for read buffer\n");
71
+++ b/target/arm/translate.c
110
-        retval = -ENOMEM;
72
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
111
-        goto out_free;
73
bool is_long = false, q = extract32(insn, 6, 1);
112
-    }
74
bool ptr_is_env = false;
113
-
75
114
-    /* Read in first chunk of data and parse gzip header. */
76
- if ((insn & 0xfea00f10) == 0xfc800800) {
115
-    fpos = offset;
77
- /* VCADD -- 1111 110R 1.0S .... .... 1000 ...0 .... */
116
-    ret = bprm->file->f_op->read(bprm->file, buf, LBUFSIZE, &fpos);
78
- int size = extract32(insn, 20, 1);
117
-
79
- data = extract32(insn, 24, 1); /* rot */
118
-    strm.next_in = buf;
80
- if (!dc_isar_feature(aa32_vcma, s)
119
-    strm.avail_in = ret;
81
- || (!size && !dc_isar_feature(aa32_fp16_arith, s))) {
120
-    strm.total_in = 0;
82
- return 1;
121
-
122
-    retval = -ENOEXEC;
123
-
124
-    /* Check minimum size -- gzip header */
125
-    if (ret < 10) {
126
-        DBG_FLT("binfmt_flat: file too small?\n");
127
-        goto out_free_buf;
128
-    }
129
-
130
-    /* Check gzip magic number */
131
-    if ((buf[0] != 037) || ((buf[1] != 0213) && (buf[1] != 0236))) {
132
-        DBG_FLT("binfmt_flat: unknown compression magic?\n");
133
-        goto out_free_buf;
134
-    }
135
-
136
-    /* Check gzip method */
137
-    if (buf[2] != 8) {
138
-        DBG_FLT("binfmt_flat: unknown compression method?\n");
139
-        goto out_free_buf;
140
-    }
141
-    /* Check gzip flags */
142
-    if ((buf[3] & ENCRYPTED) || (buf[3] & CONTINUATION) ||
143
-     (buf[3] & RESERVED)) {
144
-        DBG_FLT("binfmt_flat: unknown flags?\n");
145
-        goto out_free_buf;
146
-    }
147
-
148
-    ret = 10;
149
-    if (buf[3] & EXTRA_FIELD) {
150
-        ret += 2 + buf[10] + (buf[11] << 8);
151
-        if (unlikely(LBUFSIZE == ret)) {
152
-            DBG_FLT("binfmt_flat: buffer overflow (EXTRA)?\n");
153
-            goto out_free_buf;
154
-        }
155
-    }
156
-    if (buf[3] & ORIG_NAME) {
157
-        for (; ret < LBUFSIZE && (buf[ret] != 0); ret++)
158
-            ;
159
-        if (unlikely(LBUFSIZE == ret)) {
160
-            DBG_FLT("binfmt_flat: buffer overflow (ORIG_NAME)?\n");
161
-            goto out_free_buf;
162
-        }
163
-    }
164
-    if (buf[3] & COMMENT) {
165
-        for (; ret < LBUFSIZE && (buf[ret] != 0); ret++)
166
-            ;
167
-        if (unlikely(LBUFSIZE == ret)) {
168
-            DBG_FLT("binfmt_flat: buffer overflow (COMMENT)?\n");
169
-            goto out_free_buf;
170
-        }
171
-    }
172
-
173
-    strm.next_in += ret;
174
-    strm.avail_in -= ret;
175
-
176
-    strm.next_out = dst;
177
-    strm.avail_out = len;
178
-    strm.total_out = 0;
179
-
180
-    if (zlib_inflateInit2(&strm, -MAX_WBITS) != Z_OK) {
181
-        DBG_FLT("binfmt_flat: zlib init failed?\n");
182
-        goto out_free_buf;
183
-    }
184
-
185
-    while ((ret = zlib_inflate(&strm, Z_NO_FLUSH)) == Z_OK) {
186
-        ret = bprm->file->f_op->read(bprm->file, buf, LBUFSIZE, &fpos);
187
-        if (ret <= 0)
188
-            break;
189
- if (is_error(ret)) {
190
-            break;
191
- }
192
-        len -= ret;
193
-
194
-        strm.next_in = buf;
195
-        strm.avail_in = ret;
196
-        strm.total_in = 0;
197
-    }
198
-
199
-    if (ret < 0) {
200
-        DBG_FLT("binfmt_flat: decompression failed (%d), %s\n",
201
-            ret, strm.msg);
202
-        goto out_zlib;
203
-    }
204
-
205
-    retval = 0;
206
-out_zlib:
207
-    zlib_inflateEnd(&strm);
208
-out_free_buf:
209
-    kfree(buf);
210
-out_free:
211
-    kfree(strm.workspace);
212
-out:
213
-    return retval;
214
-}
215
-
216
-#endif /* CONFIG_BINFMT_ZFLAT */
217
218
/****************************************************************************/
219
220
@@ -XXX,XX +XXX,XX @@ calc_reloc(abi_ulong r, struct lib_info *p, int curid, int internalp)
221
abi_ulong text_len;
222
abi_ulong start_code;
223
224
-#ifdef CONFIG_BINFMT_SHARED_FLAT
225
-#error needs checking
226
- if (r == 0)
227
- id = curid;    /* Relocs of 0 are always self referring */
228
- else {
229
- id = (r >> 24) & 0xff;    /* Find ID for this reloc */
230
- r &= 0x00ffffff;    /* Trim ID off here */
231
- }
232
- if (id >= MAX_SHARED_LIBS) {
233
- fprintf(stderr, "BINFMT_FLAT: reference 0x%x to shared library %d\n",
234
- (unsigned) r, id);
235
- goto failed;
236
- }
237
- if (curid != id) {
238
- if (internalp) {
239
- fprintf(stderr, "BINFMT_FLAT: reloc address 0x%x not "
240
- "in same module (%d != %d)\n",
241
- (unsigned) r, curid, id);
242
- goto failed;
243
- } else if (!p[id].loaded && is_error(load_flat_shared_library(id, p))) {
244
- fprintf(stderr, "BINFMT_FLAT: failed to load library %d\n", id);
245
- goto failed;
83
- }
246
- }
84
- fn_gvec_ptr = size ? gen_helper_gvec_fcadds : gen_helper_gvec_fcaddh;
247
- /* Check versioning information (i.e. time stamps) */
85
- } else if ((insn & 0xfeb00f00) == 0xfc200d00) {
248
- if (p[id].build_date && p[curid].build_date
86
+ if ((insn & 0xfeb00f00) == 0xfc200d00) {
249
- && p[curid].build_date < p[id].build_date) {
87
/* V[US]DOT -- 1111 1100 0.10 .... .... 1101 .Q.U .... */
250
- fprintf(stderr, "BINFMT_FLAT: library %d is younger than %d\n",
88
bool u = extract32(insn, 4, 1);
251
- id, curid);
89
if (!dc_isar_feature(aa32_dp, s)) {
252
- goto failed;
253
- }
254
- }
255
-#else
256
id = 0;
257
-#endif
258
259
start_brk = p[id].start_brk;
260
start_data = p[id].start_data;
261
@@ -XXX,XX +XXX,XX @@ static int load_flat_file(struct linux_binprm * bprm,
262
if (rev == OLD_FLAT_VERSION && flat_old_ram_flag(flags))
263
flags = FLAT_FLAG_RAM;
264
265
-#ifndef CONFIG_BINFMT_ZFLAT
266
if (flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) {
267
- fprintf(stderr, "Support for ZFLAT executables is not enabled\n");
268
+ fprintf(stderr, "ZFLAT executables are not supported\n");
269
return -ENOEXEC;
270
}
271
-#endif
272
273
/*
274
* calculate the extra space we need to map in
275
@@ -XXX,XX +XXX,XX @@ static int load_flat_file(struct linux_binprm * bprm,
276
(int)(data_len + bss_len + stack_len), (int)datapos);
277
278
fpos = ntohl(hdr->data_start);
279
-#ifdef CONFIG_BINFMT_ZFLAT
280
- if (flags & FLAT_FLAG_GZDATA) {
281
- result = decompress_exec(bprm, fpos, (char *) datapos,
282
- data_len + (relocs * sizeof(abi_ulong)))
283
- } else
284
-#endif
285
- {
286
- result = target_pread(bprm->src.fd, datapos,
287
- data_len + (relocs * sizeof(abi_ulong)),
288
- fpos);
289
- }
290
+ result = target_pread(bprm->src.fd, datapos,
291
+ data_len + (relocs * sizeof(abi_ulong)),
292
+ fpos);
293
if (result < 0) {
294
fprintf(stderr, "Unable to read data+bss\n");
295
return result;
296
@@ -XXX,XX +XXX,XX @@ static int load_flat_file(struct linux_binprm * bprm,
297
datapos = realdatastart + indx_len;
298
reloc = (textpos + ntohl(hdr->reloc_start) + indx_len);
299
300
-#ifdef CONFIG_BINFMT_ZFLAT
301
-#error code needs checking
302
- /*
303
- * load it all in and treat it like a RAM load from now on
304
- */
305
- if (flags & FLAT_FLAG_GZIP) {
306
- result = decompress_exec(bprm, sizeof (struct flat_hdr),
307
- (((char *) textpos) + sizeof (struct flat_hdr)),
308
- (text_len + data_len + (relocs * sizeof(unsigned long))
309
- - sizeof (struct flat_hdr)),
310
- 0);
311
- memmove((void *) datapos, (void *) realdatastart,
312
- data_len + (relocs * sizeof(unsigned long)));
313
- } else if (flags & FLAT_FLAG_GZDATA) {
314
- fpos = 0;
315
- result = bprm->file->f_op->read(bprm->file,
316
- (char *) textpos, text_len, &fpos);
317
- if (!is_error(result)) {
318
- result = decompress_exec(bprm, text_len, (char *) datapos,
319
- data_len + (relocs * sizeof(unsigned long)), 0);
320
- }
321
- }
322
- else
323
-#endif
324
- {
325
- result = target_pread(bprm->src.fd, textpos,
326
- text_len, 0);
327
- if (result >= 0) {
328
- result = target_pread(bprm->src.fd, datapos,
329
- data_len + (relocs * sizeof(abi_ulong)),
330
- ntohl(hdr->data_start));
331
- }
332
+ result = target_pread(bprm->src.fd, textpos,
333
+ text_len, 0);
334
+ if (result >= 0) {
335
+ result = target_pread(bprm->src.fd, datapos,
336
+ data_len + (relocs * sizeof(abi_ulong)),
337
+ ntohl(hdr->data_start));
338
}
339
if (result < 0) {
340
fprintf(stderr, "Unable to read code+data+bss\n");
341
@@ -XXX,XX +XXX,XX @@ static int load_flat_file(struct linux_binprm * bprm,
342
343
344
/****************************************************************************/
345
-#ifdef CONFIG_BINFMT_SHARED_FLAT
346
-
347
-/*
348
- * Load a shared library into memory. The library gets its own data
349
- * segment (including bss) but not argv/argc/environ.
350
- */
351
-
352
-static int load_flat_shared_library(int id, struct lib_info *libs)
353
-{
354
-    struct linux_binprm bprm;
355
-    int res;
356
-    char buf[16];
357
-
358
-    /* Create the file name */
359
-    sprintf(buf, "/lib/lib%d.so", id);
360
-
361
-    /* Open the file up */
362
-    bprm.filename = buf;
363
-    bprm.file = open_exec(bprm.filename);
364
-    res = PTR_ERR(bprm.file);
365
-    if (IS_ERR(bprm.file))
366
-        return res;
367
-
368
-    res = prepare_binprm(&bprm);
369
-
370
- if (!is_error(res)) {
371
-        res = load_flat_file(&bprm, libs, id, NULL);
372
- }
373
-    if (bprm.file) {
374
-        allow_write_access(bprm.file);
375
-        fput(bprm.file);
376
-        bprm.file = NULL;
377
-    }
378
-    return(res);
379
-}
380
-
381
-#endif /* CONFIG_BINFMT_SHARED_FLAT */
382
-
383
int load_flt_binary(struct linux_binprm *bprm, struct image_info *info)
384
{
385
struct lib_info libinfo[MAX_SHARED_LIBS];
386
@@ -XXX,XX +XXX,XX @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info)
387
*/
388
start_addr = libinfo[0].entry;
389
390
-#ifdef CONFIG_BINFMT_SHARED_FLAT
391
-#error here
392
- for (i = MAX_SHARED_LIBS-1; i>0; i--) {
393
- if (libinfo[i].loaded) {
394
- /* Push previous first to call address */
395
- --sp;
396
- if (put_user_ual(start_addr, sp))
397
- return -EFAULT;
398
- start_addr = libinfo[i].entry;
399
- }
400
- }
401
-#endif
402
-
403
/* Stash our initial stack pointer into the mm structure */
404
info->start_code = libinfo[0].start_code;
405
info->end_code = libinfo[0].start_code + libinfo[0].text_len;
90
--
406
--
91
2.20.1
407
2.34.1
92
408
93
409
diff view generated by jsdifflib
1
Convert the VFM[AS]L (scalar) insns in the 2reg-scalar-ext group
1
The npcm7xx_clk and npcm7xx_gcr device reset methods look at
2
to decodetree. These are the last ones in the group so we can remove
2
the ResetType argument and only handle RESET_TYPE_COLD,
3
all the legacy decode for the group.
3
producing a warning if another reset type is passed. This
4
is different from how every other three-phase-reset method
5
we have works, and makes it difficult to add new reset types.
4
6
5
Note that in disas_thumb2_insn() the parts of this encoding space
7
A better pattern is "assume that any reset type you don't know
6
where the decodetree decoder returns false will correctly be directed
8
about should be handled like RESET_TYPE_COLD"; switch these
7
to illegal_op by the "(insn & (1 << 28))" check so they won't fall
9
devices to do that. Then adding a new reset type will only
8
into disas_coproc_insn() by mistake.
10
need to touch those devices where its behaviour really needs
11
to be different from the standard cold reset.
9
12
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20200430181003.21682-11-peter.maydell@linaro.org
15
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
16
Reviewed-by: Luc Michel <luc.michel@amd.com>
17
Message-id: 20240412160809.1260625-2-peter.maydell@linaro.org
13
---
18
---
14
target/arm/neon-shared.decode | 7 +++
19
hw/misc/npcm7xx_clk.c | 13 +++----------
15
target/arm/translate-neon.inc.c | 32 ++++++++++
20
hw/misc/npcm7xx_gcr.c | 12 ++++--------
16
target/arm/translate.c | 107 +-------------------------------
21
2 files changed, 7 insertions(+), 18 deletions(-)
17
3 files changed, 40 insertions(+), 106 deletions(-)
18
22
19
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
23
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
20
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/neon-shared.decode
25
--- a/hw/misc/npcm7xx_clk.c
22
+++ b/target/arm/neon-shared.decode
26
+++ b/hw/misc/npcm7xx_clk.c
23
@@ -XXX,XX +XXX,XX @@ VCMLA_scalar 1111 1110 1 . rot:2 .... .... 1000 . q:1 . 0 .... \
27
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_clk_enter_reset(Object *obj, ResetType type)
24
28
25
VDOT_scalar 1111 1110 0 . 10 .... .... 1101 . q:1 index:1 u:1 rm:4 \
29
QEMU_BUILD_BUG_ON(sizeof(s->regs) != sizeof(cold_reset_values));
26
vm=%vm_dp vn=%vn_dp vd=%vd_dp
30
27
+
31
- switch (type) {
28
+%vfml_scalar_q0_rm 0:3 5:1
32
- case RESET_TYPE_COLD:
29
+%vfml_scalar_q1_index 5:1 3:1
33
- memcpy(s->regs, cold_reset_values, sizeof(cold_reset_values));
30
+VFML_scalar 1111 1110 0 . 0 s:1 .... .... 1000 . 0 . 1 index:1 ... \
34
- s->ref_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
31
+ rm=%vfml_scalar_q0_rm vn=%vn_sp vd=%vd_dp q=0
35
- npcm7xx_clk_update_all_clocks(s);
32
+VFML_scalar 1111 1110 0 . 0 s:1 .... .... 1000 . 1 . 1 . rm:3 \
36
- return;
33
+ index=%vfml_scalar_q1_index vn=%vn_dp vd=%vd_dp q=1
34
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/target/arm/translate-neon.inc.c
37
+++ b/target/arm/translate-neon.inc.c
38
@@ -XXX,XX +XXX,XX @@ static bool trans_VDOT_scalar(DisasContext *s, arg_VDOT_scalar *a)
39
tcg_temp_free_ptr(fpst);
40
return true;
41
}
42
+
43
+static bool trans_VFML_scalar(DisasContext *s, arg_VFML_scalar *a)
44
+{
45
+ int opr_sz;
46
+
47
+ if (!dc_isar_feature(aa32_fhm, s)) {
48
+ return false;
49
+ }
50
+
51
+ /* UNDEF accesses to D16-D31 if they don't exist. */
52
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
53
+ ((a->vd & 0x10) || (a->q && (a->vn & 0x10)))) {
54
+ return false;
55
+ }
56
+
57
+ if (a->vd & a->q) {
58
+ return false;
59
+ }
60
+
61
+ if (!vfp_access_check(s)) {
62
+ return true;
63
+ }
64
+
65
+ opr_sz = (1 + a->q) * 8;
66
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd),
67
+ vfp_reg_offset(a->q, a->vn),
68
+ vfp_reg_offset(a->q, a->rm),
69
+ cpu_env, opr_sz, opr_sz,
70
+ (a->index << 2) | a->s, /* is_2 == 0 */
71
+ gen_helper_gvec_fmlal_idx_a32);
72
+ return true;
73
+}
74
diff --git a/target/arm/translate.c b/target/arm/translate.c
75
index XXXXXXX..XXXXXXX 100644
76
--- a/target/arm/translate.c
77
+++ b/target/arm/translate.c
78
@@ -XXX,XX +XXX,XX @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn)
79
}
80
81
#define VFP_REG_SHR(x, n) (((n) > 0) ? (x) >> (n) : (x) << -(n))
82
-#define VFP_SREG(insn, bigbit, smallbit) \
83
- ((VFP_REG_SHR(insn, bigbit - 1) & 0x1e) | (((insn) >> (smallbit)) & 1))
84
#define VFP_DREG(reg, insn, bigbit, smallbit) do { \
85
if (dc_isar_feature(aa32_simd_r32, s)) { \
86
reg = (((insn) >> (bigbit)) & 0x0f) \
87
@@ -XXX,XX +XXX,XX @@ static int disas_dsp_insn(DisasContext *s, uint32_t insn)
88
reg = ((insn) >> (bigbit)) & 0x0f; \
89
}} while (0)
90
91
-#define VFP_SREG_D(insn) VFP_SREG(insn, 12, 22)
92
#define VFP_DREG_D(reg, insn) VFP_DREG(reg, insn, 12, 22)
93
-#define VFP_SREG_N(insn) VFP_SREG(insn, 16, 7)
94
#define VFP_DREG_N(reg, insn) VFP_DREG(reg, insn, 16, 7)
95
-#define VFP_SREG_M(insn) VFP_SREG(insn, 0, 5)
96
#define VFP_DREG_M(reg, insn) VFP_DREG(reg, insn, 0, 5)
97
98
static void gen_neon_dup_low16(TCGv_i32 var)
99
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
100
return 0;
101
}
102
103
-/* Advanced SIMD two registers and a scalar extension.
104
- * 31 24 23 22 20 16 12 11 10 9 8 3 0
105
- * +-----------------+----+---+----+----+----+---+----+---+----+---------+----+
106
- * | 1 1 1 1 1 1 1 0 | o1 | D | o2 | Vn | Vd | 1 | o3 | 0 | o4 | N Q M U | Vm |
107
- * +-----------------+----+---+----+----+----+---+----+---+----+---------+----+
108
- *
109
- */
110
-
111
-static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
112
-{
113
- gen_helper_gvec_3 *fn_gvec = NULL;
114
- gen_helper_gvec_3_ptr *fn_gvec_ptr = NULL;
115
- int rd, rn, rm, opr_sz, data;
116
- int off_rn, off_rm;
117
- bool is_long = false, q = extract32(insn, 6, 1);
118
- bool ptr_is_env = false;
119
-
120
- if ((insn & 0xffa00f10) == 0xfe000810) {
121
- /* VFM[AS]L -- 1111 1110 0.0S .... .... 1000 .Q.1 .... */
122
- int is_s = extract32(insn, 20, 1);
123
- int vm20 = extract32(insn, 0, 3);
124
- int vm3 = extract32(insn, 3, 1);
125
- int m = extract32(insn, 5, 1);
126
- int index;
127
-
128
- if (!dc_isar_feature(aa32_fhm, s)) {
129
- return 1;
130
- }
131
- if (q) {
132
- rm = vm20;
133
- index = m * 2 + vm3;
134
- } else {
135
- rm = vm20 * 2 + m;
136
- index = vm3;
137
- }
138
- is_long = true;
139
- data = (index << 2) | is_s; /* is_2 == 0 */
140
- fn_gvec_ptr = gen_helper_gvec_fmlal_idx_a32;
141
- ptr_is_env = true;
142
- } else {
143
- return 1;
144
- }
37
- }
145
-
38
-
146
- VFP_DREG_D(rd, insn);
39
+ memcpy(s->regs, cold_reset_values, sizeof(cold_reset_values));
147
- if (rd & q) {
40
+ s->ref_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
148
- return 1;
41
+ npcm7xx_clk_update_all_clocks(s);
42
/*
43
* A small number of registers need to be reset on a core domain reset,
44
* but no such reset type exists yet.
45
*/
46
- qemu_log_mask(LOG_UNIMP, "%s: reset type %d not implemented.",
47
- __func__, type);
48
}
49
50
static void npcm7xx_clk_init_clock_hierarchy(NPCM7xxCLKState *s)
51
diff --git a/hw/misc/npcm7xx_gcr.c b/hw/misc/npcm7xx_gcr.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/misc/npcm7xx_gcr.c
54
+++ b/hw/misc/npcm7xx_gcr.c
55
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_gcr_enter_reset(Object *obj, ResetType type)
56
57
QEMU_BUILD_BUG_ON(sizeof(s->regs) != sizeof(cold_reset_values));
58
59
- switch (type) {
60
- case RESET_TYPE_COLD:
61
- memcpy(s->regs, cold_reset_values, sizeof(s->regs));
62
- s->regs[NPCM7XX_GCR_PWRON] = s->reset_pwron;
63
- s->regs[NPCM7XX_GCR_MDLR] = s->reset_mdlr;
64
- s->regs[NPCM7XX_GCR_INTCR3] = s->reset_intcr3;
65
- break;
149
- }
66
- }
150
- if (q || !is_long) {
67
+ memcpy(s->regs, cold_reset_values, sizeof(s->regs));
151
- VFP_DREG_N(rn, insn);
68
+ s->regs[NPCM7XX_GCR_PWRON] = s->reset_pwron;
152
- if (rn & q & !is_long) {
69
+ s->regs[NPCM7XX_GCR_MDLR] = s->reset_mdlr;
153
- return 1;
70
+ s->regs[NPCM7XX_GCR_INTCR3] = s->reset_intcr3;
154
- }
71
}
155
- off_rn = vfp_reg_offset(1, rn);
72
156
- off_rm = vfp_reg_offset(1, rm);
73
static void npcm7xx_gcr_realize(DeviceState *dev, Error **errp)
157
- } else {
158
- rn = VFP_SREG_N(insn);
159
- off_rn = vfp_reg_offset(0, rn);
160
- off_rm = vfp_reg_offset(0, rm);
161
- }
162
- if (s->fp_excp_el) {
163
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
164
- syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
165
- return 0;
166
- }
167
- if (!s->vfp_enabled) {
168
- return 1;
169
- }
170
-
171
- opr_sz = (1 + q) * 8;
172
- if (fn_gvec_ptr) {
173
- TCGv_ptr ptr;
174
- if (ptr_is_env) {
175
- ptr = cpu_env;
176
- } else {
177
- ptr = get_fpstatus_ptr(1);
178
- }
179
- tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), off_rn, off_rm, ptr,
180
- opr_sz, opr_sz, data, fn_gvec_ptr);
181
- if (!ptr_is_env) {
182
- tcg_temp_free_ptr(ptr);
183
- }
184
- } else {
185
- tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd), off_rn, off_rm,
186
- opr_sz, opr_sz, data, fn_gvec);
187
- }
188
- return 0;
189
-}
190
-
191
static int disas_coproc_insn(DisasContext *s, uint32_t insn)
192
{
193
int cpnum, is64, crn, crm, opc1, opc2, isread, rt, rt2;
194
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
195
}
196
}
197
}
198
- } else if ((insn & 0x0f000a00) == 0x0e000800
199
- && arm_dc_feature(s, ARM_FEATURE_V8)) {
200
- if (disas_neon_insn_2reg_scalar_ext(s, insn)) {
201
- goto illegal_op;
202
- }
203
- return;
204
}
205
goto illegal_op;
206
}
207
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
208
}
209
break;
210
}
211
- if ((insn & 0xff000a00) == 0xfe000800
212
- && arm_dc_feature(s, ARM_FEATURE_V8)) {
213
- /* The Thumb2 and ARM encodings are identical. */
214
- if (disas_neon_insn_2reg_scalar_ext(s, insn)) {
215
- goto illegal_op;
216
- }
217
- } else if (((insn >> 24) & 3) == 3) {
218
+ if (((insn >> 24) & 3) == 3) {
219
/* Translate into the equivalent ARM encoding. */
220
insn = (insn & 0xe2ffffff) | ((insn & (1 << 28)) >> 4) | (1 << 28);
221
if (disas_neon_data_insn(s, insn)) {
222
--
74
--
223
2.20.1
75
2.34.1
224
76
225
77
diff view generated by jsdifflib
1
Convert the V[US]DOT (scalar) insns in the 2reg-scalar-ext group
1
Rather than directly calling the device's implementation of its 'hold'
2
to decodetree.
2
reset phase, call device_cold_reset(). This means we don't have to
3
adjust this callsite when we add another argument to the function
4
signature for the hold and exit reset methods.
3
5
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20200430181003.21682-10-peter.maydell@linaro.org
8
Reviewed-by: Luc Michel <luc.michel@amd.com>
9
Message-id: 20240412160809.1260625-3-peter.maydell@linaro.org
7
---
10
---
8
target/arm/neon-shared.decode | 3 +++
11
hw/i2c/allwinner-i2c.c | 3 +--
9
target/arm/translate-neon.inc.c | 35 +++++++++++++++++++++++++++++++++
12
hw/sensor/adm1272.c | 2 +-
10
target/arm/translate.c | 13 +-----------
13
2 files changed, 2 insertions(+), 3 deletions(-)
11
3 files changed, 39 insertions(+), 12 deletions(-)
12
14
13
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
15
diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/neon-shared.decode
17
--- a/hw/i2c/allwinner-i2c.c
16
+++ b/target/arm/neon-shared.decode
18
+++ b/hw/i2c/allwinner-i2c.c
17
@@ -XXX,XX +XXX,XX @@ VCMLA_scalar 1111 1110 0 . rot:2 .... .... 1000 . q:1 index:1 0 vm:4 \
19
@@ -XXX,XX +XXX,XX @@ static void allwinner_i2c_write(void *opaque, hwaddr offset,
18
vn=%vn_dp vd=%vd_dp size=0
20
break;
19
VCMLA_scalar 1111 1110 1 . rot:2 .... .... 1000 . q:1 . 0 .... \
21
case TWI_SRST_REG:
20
vm=%vm_dp vn=%vn_dp vd=%vd_dp size=1 index=0
22
if (((value & TWI_SRST_MASK) == 0) && (s->srst & TWI_SRST_MASK)) {
21
+
23
- /* Perform reset */
22
+VDOT_scalar 1111 1110 0 . 10 .... .... 1101 . q:1 index:1 u:1 rm:4 \
24
- allwinner_i2c_reset_hold(OBJECT(s));
23
+ vm=%vm_dp vn=%vn_dp vd=%vd_dp
25
+ device_cold_reset(DEVICE(s));
24
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
26
}
27
s->srst = value & TWI_SRST_MASK;
28
break;
29
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
25
index XXXXXXX..XXXXXXX 100644
30
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/translate-neon.inc.c
31
--- a/hw/sensor/adm1272.c
27
+++ b/target/arm/translate-neon.inc.c
32
+++ b/hw/sensor/adm1272.c
28
@@ -XXX,XX +XXX,XX @@ static bool trans_VCMLA_scalar(DisasContext *s, arg_VCMLA_scalar *a)
33
@@ -XXX,XX +XXX,XX @@ static int adm1272_write_data(PMBusDevice *pmdev, const uint8_t *buf,
29
tcg_temp_free_ptr(fpst);
34
break;
30
return true;
35
31
}
36
case ADM1272_MFR_POWER_CYCLE:
32
+
37
- adm1272_exit_reset((Object *)s);
33
+static bool trans_VDOT_scalar(DisasContext *s, arg_VDOT_scalar *a)
38
+ device_cold_reset(DEVICE(s));
34
+{
39
break;
35
+ gen_helper_gvec_3 *fn_gvec;
40
36
+ int opr_sz;
41
case ADM1272_HYSTERESIS_LOW:
37
+ TCGv_ptr fpst;
38
+
39
+ if (!dc_isar_feature(aa32_dp, s)) {
40
+ return false;
41
+ }
42
+
43
+ /* UNDEF accesses to D16-D31 if they don't exist. */
44
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
45
+ ((a->vd | a->vn) & 0x10)) {
46
+ return false;
47
+ }
48
+
49
+ if ((a->vd | a->vn) & a->q) {
50
+ return false;
51
+ }
52
+
53
+ if (!vfp_access_check(s)) {
54
+ return true;
55
+ }
56
+
57
+ fn_gvec = a->u ? gen_helper_gvec_udot_idx_b : gen_helper_gvec_sdot_idx_b;
58
+ opr_sz = (1 + a->q) * 8;
59
+ fpst = get_fpstatus_ptr(1);
60
+ tcg_gen_gvec_3_ool(vfp_reg_offset(1, a->vd),
61
+ vfp_reg_offset(1, a->vn),
62
+ vfp_reg_offset(1, a->rm),
63
+ opr_sz, opr_sz, a->index, fn_gvec);
64
+ tcg_temp_free_ptr(fpst);
65
+ return true;
66
+}
67
diff --git a/target/arm/translate.c b/target/arm/translate.c
68
index XXXXXXX..XXXXXXX 100644
69
--- a/target/arm/translate.c
70
+++ b/target/arm/translate.c
71
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
72
bool is_long = false, q = extract32(insn, 6, 1);
73
bool ptr_is_env = false;
74
75
- if ((insn & 0xffb00f00) == 0xfe200d00) {
76
- /* V[US]DOT -- 1111 1110 0.10 .... .... 1101 .Q.U .... */
77
- int u = extract32(insn, 4, 1);
78
-
79
- if (!dc_isar_feature(aa32_dp, s)) {
80
- return 1;
81
- }
82
- fn_gvec = u ? gen_helper_gvec_udot_idx_b : gen_helper_gvec_sdot_idx_b;
83
- /* rm is just Vm, and index is M. */
84
- data = extract32(insn, 5, 1); /* index */
85
- rm = extract32(insn, 0, 4);
86
- } else if ((insn & 0xffa00f10) == 0xfe000810) {
87
+ if ((insn & 0xffa00f10) == 0xfe000810) {
88
/* VFM[AS]L -- 1111 1110 0.0S .... .... 1000 .Q.1 .... */
89
int is_s = extract32(insn, 20, 1);
90
int vm20 = extract32(insn, 0, 3);
91
--
42
--
92
2.20.1
43
2.34.1
93
94
diff view generated by jsdifflib
1
Convert the Neon VMUL, VMLA, VMLS and VSHL insns in the
1
We pass a ResetType argument to the Resettable class enter phase
2
3-reg-same grouping to decodetree.
2
method, but we don't pass it to hold and exit, even though the
3
callsites have it readily available. This means that if a device
4
cared about the ResetType it would need to record it in the enter
5
phase method to use later on. We should pass the type to all three
6
of the phase methods to avoid having to do that.
7
8
This coccinelle script adds the ResetType argument to the hold and
9
exit phases of the Resettable interface.
10
11
The first part of the script (rules holdfn_assigned, holdfn_defined,
12
exitfn_assigned, exitfn_defined) update implementations of the
13
interface within device models, both to change the signature of their
14
method implementations and to pass on the reset type when they invoke
15
reset on some other device.
16
17
The second part of the script is various special cases:
18
* method callsites in resettable_phase_hold(), resettable_phase_exit()
19
and device_phases_reset()
20
* updating the typedefs for the methods
21
* isl_pmbus_vr.c has some code where one device's reset method directly
22
calls the implementation of a different device's method
3
23
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
25
Reviewed-by: Luc Michel <luc.michel@amd.com>
6
Message-id: 20200430181003.21682-20-peter.maydell@linaro.org
26
Message-id: 20240412160809.1260625-4-peter.maydell@linaro.org
7
---
27
---
8
target/arm/neon-dp.decode | 9 +++++++
28
scripts/coccinelle/reset-type.cocci | 133 ++++++++++++++++++++++++++++
9
target/arm/translate-neon.inc.c | 44 +++++++++++++++++++++++++++++++++
29
1 file changed, 133 insertions(+)
10
target/arm/translate.c | 28 +++------------------
30
create mode 100644 scripts/coccinelle/reset-type.cocci
11
3 files changed, 56 insertions(+), 25 deletions(-)
12
31
13
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
32
diff --git a/scripts/coccinelle/reset-type.cocci b/scripts/coccinelle/reset-type.cocci
14
index XXXXXXX..XXXXXXX 100644
33
new file mode 100644
15
--- a/target/arm/neon-dp.decode
34
index XXXXXXX..XXXXXXX
16
+++ b/target/arm/neon-dp.decode
35
--- /dev/null
17
@@ -XXX,XX +XXX,XX @@ VCGT_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 0 .... @3same
36
+++ b/scripts/coccinelle/reset-type.cocci
18
VCGE_S_3s 1111 001 0 0 . .. .... .... 0011 . . . 1 .... @3same
37
@@ -XXX,XX +XXX,XX @@
19
VCGE_U_3s 1111 001 1 0 . .. .... .... 0011 . . . 1 .... @3same
38
+// Convert device code using three-phase reset to add a ResetType
20
39
+// argument to implementations of ResettableHoldPhase and
21
+VSHL_S_3s 1111 001 0 0 . .. .... .... 0100 . . . 0 .... @3same
40
+// ResettableEnterPhase methods.
22
+VSHL_U_3s 1111 001 1 0 . .. .... .... 0100 . . . 0 .... @3same
41
+//
42
+// Copyright Linaro Ltd 2024
43
+// SPDX-License-Identifier: GPL-2.0-or-later
44
+//
45
+// for dir in include hw target; do \
46
+// spatch --macro-file scripts/cocci-macro-file.h \
47
+// --sp-file scripts/coccinelle/reset-type.cocci \
48
+// --keep-comments --smpl-spacing --in-place --include-headers \
49
+// --dir $dir; done
50
+//
51
+// This coccinelle script aims to produce a complete change that needs
52
+// no human interaction, so as well as the generic "update device
53
+// implementations of the hold and exit phase methods" it includes
54
+// the special-case transformations needed for the core code and for
55
+// one device model that does something a bit nonstandard. Those
56
+// special cases are at the end of the file.
23
+
57
+
24
VMAX_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 0 .... @3same
58
+// Look for where we use a function as a ResettableHoldPhase method,
25
VMAX_U_3s 1111 001 1 0 . .. .... .... 0110 . . . 0 .... @3same
59
+// either by directly assigning it to phases.hold or by calling
26
VMIN_S_3s 1111 001 0 0 . .. .... .... 0110 . . . 1 .... @3same
60
+// resettable_class_set_parent_phases, and remember the function name.
27
@@ -XXX,XX +XXX,XX @@ VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same
61
+@ holdfn_assigned @
28
62
+identifier enterfn, holdfn, exitfn;
29
VTST_3s 1111 001 0 0 . .. .... .... 1000 . . . 1 .... @3same
63
+identifier rc;
30
VCEQ_3s 1111 001 1 0 . .. .... .... 1000 . . . 1 .... @3same
64
+expression e;
65
+@@
66
+ResettableClass *rc;
67
+...
68
+(
69
+ rc->phases.hold = holdfn;
70
+|
71
+ resettable_class_set_parent_phases(rc, enterfn, holdfn, exitfn, e);
72
+)
31
+
73
+
32
+VMLA_3s 1111 001 0 0 . .. .... .... 1001 . . . 0 .... @3same
74
+// Look for the definition of the function we found in holdfn_assigned,
33
+VMLS_3s 1111 001 1 0 . .. .... .... 1001 . . . 0 .... @3same
75
+// and add the new argument. If the function calls a hold function
34
+
76
+// itself (probably chaining to the parent class reset) then add the
35
+VMUL_3s 1111 001 0 0 . .. .... .... 1001 . . . 1 .... @3same
77
+// new argument there too.
36
+VMUL_p_3s 1111 001 1 0 . .. .... .... 1001 . . . 1 .... @3same
78
+@ holdfn_defined @
37
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
79
+identifier holdfn_assigned.holdfn;
38
index XXXXXXX..XXXXXXX 100644
80
+typedef Object;
39
--- a/target/arm/translate-neon.inc.c
81
+identifier obj;
40
+++ b/target/arm/translate-neon.inc.c
82
+expression parent;
41
@@ -XXX,XX +XXX,XX @@ DO_3SAME_NO_SZ_3(VMAX_S, tcg_gen_gvec_smax)
83
+@@
42
DO_3SAME_NO_SZ_3(VMAX_U, tcg_gen_gvec_umax)
84
+-holdfn(Object *obj)
43
DO_3SAME_NO_SZ_3(VMIN_S, tcg_gen_gvec_smin)
85
++holdfn(Object *obj, ResetType type)
44
DO_3SAME_NO_SZ_3(VMIN_U, tcg_gen_gvec_umin)
45
+DO_3SAME_NO_SZ_3(VMUL, tcg_gen_gvec_mul)
46
47
#define DO_3SAME_CMP(INSN, COND) \
48
static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \
49
@@ -XXX,XX +XXX,XX @@ DO_3SAME_GVEC4(VQADD_S, sqadd_op)
50
DO_3SAME_GVEC4(VQADD_U, uqadd_op)
51
DO_3SAME_GVEC4(VQSUB_S, sqsub_op)
52
DO_3SAME_GVEC4(VQSUB_U, uqsub_op)
53
+
54
+static void gen_VMUL_p_3s(unsigned vece, uint32_t rd_ofs, uint32_t rn_ofs,
55
+ uint32_t rm_ofs, uint32_t oprsz, uint32_t maxsz)
56
+{
86
+{
57
+ tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, oprsz, maxsz,
87
+ <...
58
+ 0, gen_helper_gvec_pmul_b);
88
+- parent.hold(obj)
89
++ parent.hold(obj, type)
90
+ ...>
59
+}
91
+}
60
+
92
+
61
+static bool trans_VMUL_p_3s(DisasContext *s, arg_3same *a)
93
+// Similarly for ResettableExitPhase.
94
+@ exitfn_assigned @
95
+identifier enterfn, holdfn, exitfn;
96
+identifier rc;
97
+expression e;
98
+@@
99
+ResettableClass *rc;
100
+...
101
+(
102
+ rc->phases.exit = exitfn;
103
+|
104
+ resettable_class_set_parent_phases(rc, enterfn, holdfn, exitfn, e);
105
+)
106
+@ exitfn_defined @
107
+identifier exitfn_assigned.exitfn;
108
+typedef Object;
109
+identifier obj;
110
+expression parent;
111
+@@
112
+-exitfn(Object *obj)
113
++exitfn(Object *obj, ResetType type)
62
+{
114
+{
63
+ if (a->size != 0) {
115
+ <...
64
+ return false;
116
+- parent.exit(obj)
65
+ }
117
++ parent.exit(obj, type)
66
+ return do_3same(s, a, gen_VMUL_p_3s);
118
+ ...>
67
+}
119
+}
68
+
120
+
69
+#define DO_3SAME_GVEC3_NO_SZ_3(INSN, OPARRAY) \
121
+// SPECIAL CASES ONLY BELOW HERE
70
+ static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \
122
+// We use a python scripted constraint on the position of the match
71
+ uint32_t rn_ofs, uint32_t rm_ofs, \
123
+// to ensure that they only match in a particular function. See
72
+ uint32_t oprsz, uint32_t maxsz) \
124
+// https://public-inbox.org/git/alpine.DEB.2.21.1808240652370.2344@hadrien/
73
+ { \
125
+// which recommends this as the way to do "match only in this function".
74
+ tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, \
75
+ oprsz, maxsz, &OPARRAY[vece]); \
76
+ } \
77
+ DO_3SAME_NO_SZ_3(INSN, gen_##INSN##_3s)
78
+
126
+
127
+// Special case: isl_pmbus_vr.c has some reset methods calling others directly
128
+@ isl_pmbus_vr @
129
+identifier obj;
130
+@@
131
+- isl_pmbus_vr_exit_reset(obj);
132
++ isl_pmbus_vr_exit_reset(obj, type);
79
+
133
+
80
+DO_3SAME_GVEC3_NO_SZ_3(VMLA, mla_op)
134
+// Special case: device_phases_reset() needs to pass RESET_TYPE_COLD
81
+DO_3SAME_GVEC3_NO_SZ_3(VMLS, mls_op)
135
+@ device_phases_reset_hold @
136
+expression obj;
137
+identifier rc;
138
+identifier phase;
139
+position p : script:python() { p[0].current_element == "device_phases_reset" };
140
+@@
141
+- rc->phases.phase(obj)@p
142
++ rc->phases.phase(obj, RESET_TYPE_COLD)
82
+
143
+
83
+#define DO_3SAME_GVEC3_SHIFT(INSN, OPARRAY) \
144
+// Special case: in resettable_phase_hold() and resettable_phase_exit()
84
+ static void gen_##INSN##_3s(unsigned vece, uint32_t rd_ofs, \
145
+// we need to pass through the ResetType argument to the method being called
85
+ uint32_t rn_ofs, uint32_t rm_ofs, \
146
+@ resettable_phase_hold @
86
+ uint32_t oprsz, uint32_t maxsz) \
147
+expression obj;
87
+ { \
148
+identifier rc;
88
+ /* Note the operation is vshl vd,vm,vn */ \
149
+position p : script:python() { p[0].current_element == "resettable_phase_hold" };
89
+ tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, \
150
+@@
90
+ oprsz, maxsz, &OPARRAY[vece]); \
151
+- rc->phases.hold(obj)@p
91
+ } \
152
++ rc->phases.hold(obj, type)
92
+ DO_3SAME(INSN, gen_##INSN##_3s)
153
+@ resettable_phase_exit @
93
+
154
+expression obj;
94
+DO_3SAME_GVEC3_SHIFT(VSHL_S, sshl_op)
155
+identifier rc;
95
+DO_3SAME_GVEC3_SHIFT(VSHL_U, ushl_op)
156
+position p : script:python() { p[0].current_element == "resettable_phase_exit" };
96
diff --git a/target/arm/translate.c b/target/arm/translate.c
157
+@@
97
index XXXXXXX..XXXXXXX 100644
158
+- rc->phases.exit(obj)@p
98
--- a/target/arm/translate.c
159
++ rc->phases.exit(obj, type)
99
+++ b/target/arm/translate.c
160
+// Special case: the typedefs for the methods need to declare the new argument
100
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
161
+@ phase_typedef_hold @
101
}
162
+identifier obj;
102
return 1;
163
+@@
103
164
+- typedef void (*ResettableHoldPhase)(Object *obj);
104
- case NEON_3R_VMUL: /* VMUL */
165
++ typedef void (*ResettableHoldPhase)(Object *obj, ResetType type);
105
- if (u) {
166
+@ phase_typedef_exit @
106
- /* Polynomial case allows only P8. */
167
+identifier obj;
107
- if (size != 0) {
168
+@@
108
- return 1;
169
+- typedef void (*ResettableExitPhase)(Object *obj);
109
- }
170
++ typedef void (*ResettableExitPhase)(Object *obj, ResetType type);
110
- tcg_gen_gvec_3_ool(rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size,
111
- 0, gen_helper_gvec_pmul_b);
112
- } else {
113
- tcg_gen_gvec_mul(size, rd_ofs, rn_ofs, rm_ofs,
114
- vec_size, vec_size);
115
- }
116
- return 0;
117
-
118
- case NEON_3R_VML: /* VMLA, VMLS */
119
- tcg_gen_gvec_3(rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size,
120
- u ? &mls_op[size] : &mla_op[size]);
121
- return 0;
122
-
123
- case NEON_3R_VSHL:
124
- /* Note the operation is vshl vd,vm,vn */
125
- tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size,
126
- u ? &ushl_op[size] : &sshl_op[size]);
127
- return 0;
128
-
129
case NEON_3R_VADD_VSUB:
130
case NEON_3R_LOGIC:
131
case NEON_3R_VMAX:
132
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
133
case NEON_3R_VCGE:
134
case NEON_3R_VQADD:
135
case NEON_3R_VQSUB:
136
+ case NEON_3R_VMUL:
137
+ case NEON_3R_VML:
138
+ case NEON_3R_VSHL:
139
/* Already handled by decodetree */
140
return 1;
141
}
142
--
171
--
143
2.20.1
172
2.34.1
144
145
diff view generated by jsdifflib
1
Convert the VFM[AS]L (vector) insns to decodetree. This is the last
1
We pass a ResetType argument to the Resettable class enter
2
insn in the legacy decoder for the 3same_ext group, so we can
2
phase method, but we don't pass it to hold and exit, even though
3
delete the legacy decoder function for the group entirely.
3
the callsites have it readily available. This means that if
4
a device cared about the ResetType it would need to record it
5
in the enter phase method to use later on. Pass the type to
6
all three of the phase methods to avoid having to do that.
4
7
5
Note that in disas_thumb2_insn() the parts of this encoding space
8
Commit created with
6
where the decodetree decoder returns false will correctly be directed
9
7
to illegal_op by the "(insn & (1 << 28))" check so they won't fall
10
for dir in hw target include; do \
8
into disas_coproc_insn() by mistake.
11
spatch --macro-file scripts/cocci-macro-file.h \
12
--sp-file scripts/coccinelle/reset-type.cocci \
13
--keep-comments --smpl-spacing --in-place \
14
--include-headers --dir $dir; done
15
16
and no manual edits.
9
17
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20200430181003.21682-8-peter.maydell@linaro.org
21
Reviewed-by: Luc Michel <luc.michel@amd.com>
22
Message-id: 20240412160809.1260625-5-peter.maydell@linaro.org
13
---
23
---
14
target/arm/neon-shared.decode | 6 +++
24
include/hw/resettable.h | 4 ++--
15
target/arm/translate-neon.inc.c | 31 +++++++++++
25
hw/adc/npcm7xx_adc.c | 2 +-
16
target/arm/translate.c | 92 +--------------------------------
26
hw/arm/pxa2xx_pic.c | 2 +-
17
3 files changed, 38 insertions(+), 91 deletions(-)
27
hw/arm/smmu-common.c | 2 +-
28
hw/arm/smmuv3.c | 4 ++--
29
hw/arm/stellaris.c | 10 +++++-----
30
hw/audio/asc.c | 2 +-
31
hw/char/cadence_uart.c | 2 +-
32
hw/char/sifive_uart.c | 2 +-
33
hw/core/cpu-common.c | 2 +-
34
hw/core/qdev.c | 4 ++--
35
hw/core/reset.c | 2 +-
36
hw/core/resettable.c | 4 ++--
37
hw/display/virtio-vga.c | 4 ++--
38
hw/gpio/npcm7xx_gpio.c | 2 +-
39
hw/gpio/pl061.c | 2 +-
40
hw/gpio/stm32l4x5_gpio.c | 2 +-
41
hw/hyperv/vmbus.c | 2 +-
42
hw/i2c/allwinner-i2c.c | 2 +-
43
hw/i2c/npcm7xx_smbus.c | 2 +-
44
hw/input/adb.c | 2 +-
45
hw/input/ps2.c | 12 ++++++------
46
hw/intc/arm_gic_common.c | 2 +-
47
hw/intc/arm_gic_kvm.c | 4 ++--
48
hw/intc/arm_gicv3_common.c | 2 +-
49
hw/intc/arm_gicv3_its.c | 4 ++--
50
hw/intc/arm_gicv3_its_common.c | 2 +-
51
hw/intc/arm_gicv3_its_kvm.c | 4 ++--
52
hw/intc/arm_gicv3_kvm.c | 4 ++--
53
hw/intc/xics.c | 2 +-
54
hw/m68k/q800-glue.c | 2 +-
55
hw/misc/djmemc.c | 2 +-
56
hw/misc/iosb.c | 2 +-
57
hw/misc/mac_via.c | 8 ++++----
58
hw/misc/macio/cuda.c | 4 ++--
59
hw/misc/macio/pmu.c | 4 ++--
60
hw/misc/mos6522.c | 2 +-
61
hw/misc/npcm7xx_mft.c | 2 +-
62
hw/misc/npcm7xx_pwm.c | 2 +-
63
hw/misc/stm32l4x5_exti.c | 2 +-
64
hw/misc/stm32l4x5_rcc.c | 10 +++++-----
65
hw/misc/stm32l4x5_syscfg.c | 2 +-
66
hw/misc/xlnx-versal-cframe-reg.c | 2 +-
67
hw/misc/xlnx-versal-crl.c | 2 +-
68
hw/misc/xlnx-versal-pmc-iou-slcr.c | 2 +-
69
hw/misc/xlnx-versal-trng.c | 2 +-
70
hw/misc/xlnx-versal-xramc.c | 2 +-
71
hw/misc/xlnx-zynqmp-apu-ctrl.c | 2 +-
72
hw/misc/xlnx-zynqmp-crf.c | 2 +-
73
hw/misc/zynq_slcr.c | 4 ++--
74
hw/net/can/xlnx-zynqmp-can.c | 2 +-
75
hw/net/e1000.c | 2 +-
76
hw/net/e1000e.c | 2 +-
77
hw/net/igb.c | 2 +-
78
hw/net/igbvf.c | 2 +-
79
hw/nvram/xlnx-bbram.c | 2 +-
80
hw/nvram/xlnx-versal-efuse-ctrl.c | 2 +-
81
hw/nvram/xlnx-zynqmp-efuse.c | 2 +-
82
hw/pci-bridge/cxl_root_port.c | 4 ++--
83
hw/pci-bridge/pcie_root_port.c | 2 +-
84
hw/pci-host/bonito.c | 2 +-
85
hw/pci-host/pnv_phb.c | 4 ++--
86
hw/pci-host/pnv_phb3_msi.c | 4 ++--
87
hw/pci/pci.c | 4 ++--
88
hw/rtc/mc146818rtc.c | 2 +-
89
hw/s390x/css-bridge.c | 2 +-
90
hw/sensor/adm1266.c | 2 +-
91
hw/sensor/adm1272.c | 2 +-
92
hw/sensor/isl_pmbus_vr.c | 10 +++++-----
93
hw/sensor/max31785.c | 2 +-
94
hw/sensor/max34451.c | 2 +-
95
hw/ssi/npcm7xx_fiu.c | 2 +-
96
hw/timer/etraxfs_timer.c | 2 +-
97
hw/timer/npcm7xx_timer.c | 2 +-
98
hw/usb/hcd-dwc2.c | 8 ++++----
99
hw/usb/xlnx-versal-usb2-ctrl-regs.c | 2 +-
100
hw/virtio/virtio-pci.c | 2 +-
101
target/arm/cpu.c | 4 ++--
102
target/avr/cpu.c | 4 ++--
103
target/cris/cpu.c | 4 ++--
104
target/hexagon/cpu.c | 4 ++--
105
target/i386/cpu.c | 4 ++--
106
target/loongarch/cpu.c | 4 ++--
107
target/m68k/cpu.c | 4 ++--
108
target/microblaze/cpu.c | 4 ++--
109
target/mips/cpu.c | 4 ++--
110
target/openrisc/cpu.c | 4 ++--
111
target/ppc/cpu_init.c | 4 ++--
112
target/riscv/cpu.c | 4 ++--
113
target/rx/cpu.c | 4 ++--
114
target/sh4/cpu.c | 4 ++--
115
target/sparc/cpu.c | 4 ++--
116
target/tricore/cpu.c | 4 ++--
117
target/xtensa/cpu.c | 4 ++--
118
94 files changed, 150 insertions(+), 150 deletions(-)
18
119
19
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
120
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
20
index XXXXXXX..XXXXXXX 100644
121
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/neon-shared.decode
122
--- a/include/hw/resettable.h
22
+++ b/target/arm/neon-shared.decode
123
+++ b/include/hw/resettable.h
23
@@ -XXX,XX +XXX,XX @@ VCADD 1111 110 rot:1 1 . 0 size:1 .... .... 1000 . q:1 . 0 .... \
124
@@ -XXX,XX +XXX,XX @@ typedef enum ResetType {
24
# VUDOT and VSDOT
125
* the callback.
25
VDOT 1111 110 00 . 10 .... .... 1101 . q:1 . u:1 .... \
126
*/
26
vm=%vm_dp vn=%vn_dp vd=%vd_dp
127
typedef void (*ResettableEnterPhase)(Object *obj, ResetType type);
27
+
128
-typedef void (*ResettableHoldPhase)(Object *obj);
28
+# VFM[AS]L
129
-typedef void (*ResettableExitPhase)(Object *obj);
29
+VFML 1111 110 0 s:1 . 10 .... .... 1000 . 0 . 1 .... \
130
+typedef void (*ResettableHoldPhase)(Object *obj, ResetType type);
30
+ vm=%vm_sp vn=%vn_sp vd=%vd_dp q=0
131
+typedef void (*ResettableExitPhase)(Object *obj, ResetType type);
31
+VFML 1111 110 0 s:1 . 10 .... .... 1000 . 1 . 1 .... \
132
typedef ResettableState * (*ResettableGetState)(Object *obj);
32
+ vm=%vm_dp vn=%vn_dp vd=%vd_dp q=1
133
typedef void (*ResettableTrFunction)(Object *obj);
33
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
134
typedef ResettableTrFunction (*ResettableGetTrFunction)(Object *obj);
34
index XXXXXXX..XXXXXXX 100644
135
diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c
35
--- a/target/arm/translate-neon.inc.c
136
index XXXXXXX..XXXXXXX 100644
36
+++ b/target/arm/translate-neon.inc.c
137
--- a/hw/adc/npcm7xx_adc.c
37
@@ -XXX,XX +XXX,XX @@ static bool trans_VDOT(DisasContext *s, arg_VDOT *a)
138
+++ b/hw/adc/npcm7xx_adc.c
38
opr_sz, opr_sz, 0, fn_gvec);
139
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_adc_enter_reset(Object *obj, ResetType type)
39
return true;
140
npcm7xx_adc_reset(s);
40
}
141
}
41
+
142
42
+static bool trans_VFML(DisasContext *s, arg_VFML *a)
143
-static void npcm7xx_adc_hold_reset(Object *obj)
43
+{
144
+static void npcm7xx_adc_hold_reset(Object *obj, ResetType type)
44
+ int opr_sz;
145
{
45
+
146
NPCM7xxADCState *s = NPCM7XX_ADC(obj);
46
+ if (!dc_isar_feature(aa32_fhm, s)) {
147
47
+ return false;
148
diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c
48
+ }
149
index XXXXXXX..XXXXXXX 100644
49
+
150
--- a/hw/arm/pxa2xx_pic.c
50
+ /* UNDEF accesses to D16-D31 if they don't exist. */
151
+++ b/hw/arm/pxa2xx_pic.c
51
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
152
@@ -XXX,XX +XXX,XX @@ static int pxa2xx_pic_post_load(void *opaque, int version_id)
52
+ (a->vd & 0x10)) {
53
+ return false;
54
+ }
55
+
56
+ if (a->vd & a->q) {
57
+ return false;
58
+ }
59
+
60
+ if (!vfp_access_check(s)) {
61
+ return true;
62
+ }
63
+
64
+ opr_sz = (1 + a->q) * 8;
65
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd),
66
+ vfp_reg_offset(a->q, a->vn),
67
+ vfp_reg_offset(a->q, a->vm),
68
+ cpu_env, opr_sz, opr_sz, a->s, /* is_2 == 0 */
69
+ gen_helper_gvec_fmlal_a32);
70
+ return true;
71
+}
72
diff --git a/target/arm/translate.c b/target/arm/translate.c
73
index XXXXXXX..XXXXXXX 100644
74
--- a/target/arm/translate.c
75
+++ b/target/arm/translate.c
76
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
77
return 0;
153
return 0;
78
}
154
}
79
155
80
-/* Advanced SIMD three registers of the same length extension.
156
-static void pxa2xx_pic_reset_hold(Object *obj)
81
- * 31 25 23 22 20 16 12 11 10 9 8 3 0
157
+static void pxa2xx_pic_reset_hold(Object *obj, ResetType type)
82
- * +---------------+-----+---+-----+----+----+---+----+---+----+---------+----+
158
{
83
- * | 1 1 1 1 1 1 0 | op1 | D | op2 | Vn | Vd | 1 | o3 | 0 | o4 | N Q M U | Vm |
159
PXA2xxPICState *s = PXA2XX_PIC(obj);
84
- * +---------------+-----+---+-----+----+----+---+----+---+----+---------+----+
160
85
- */
161
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
86
-static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
162
index XXXXXXX..XXXXXXX 100644
87
-{
163
--- a/hw/arm/smmu-common.c
88
- gen_helper_gvec_3 *fn_gvec = NULL;
164
+++ b/hw/arm/smmu-common.c
89
- gen_helper_gvec_3_ptr *fn_gvec_ptr = NULL;
165
@@ -XXX,XX +XXX,XX @@ static void smmu_base_realize(DeviceState *dev, Error **errp)
90
- int rd, rn, rm, opr_sz;
166
}
91
- int data = 0;
167
}
92
- int off_rn, off_rm;
168
93
- bool is_long = false, q = extract32(insn, 6, 1);
169
-static void smmu_base_reset_hold(Object *obj)
94
- bool ptr_is_env = false;
170
+static void smmu_base_reset_hold(Object *obj, ResetType type)
95
-
171
{
96
- if ((insn & 0xff300f10) == 0xfc200810) {
172
SMMUState *s = ARM_SMMU(obj);
97
- /* VFM[AS]L -- 1111 1100 S.10 .... .... 1000 .Q.1 .... */
173
98
- int is_s = extract32(insn, 23, 1);
174
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
99
- if (!dc_isar_feature(aa32_fhm, s)) {
175
index XXXXXXX..XXXXXXX 100644
100
- return 1;
176
--- a/hw/arm/smmuv3.c
101
- }
177
+++ b/hw/arm/smmuv3.c
102
- is_long = true;
178
@@ -XXX,XX +XXX,XX @@ static void smmu_init_irq(SMMUv3State *s, SysBusDevice *dev)
103
- data = is_s; /* is_2 == 0 */
179
}
104
- fn_gvec_ptr = gen_helper_gvec_fmlal_a32;
180
}
105
- ptr_is_env = true;
181
106
- } else {
182
-static void smmu_reset_hold(Object *obj)
107
- return 1;
183
+static void smmu_reset_hold(Object *obj, ResetType type)
108
- }
184
{
109
-
185
SMMUv3State *s = ARM_SMMUV3(obj);
110
- VFP_DREG_D(rd, insn);
186
SMMUv3Class *c = ARM_SMMUV3_GET_CLASS(s);
111
- if (rd & q) {
187
112
- return 1;
188
if (c->parent_phases.hold) {
113
- }
189
- c->parent_phases.hold(obj);
114
- if (q || !is_long) {
190
+ c->parent_phases.hold(obj, type);
115
- VFP_DREG_N(rn, insn);
191
}
116
- VFP_DREG_M(rm, insn);
192
117
- if ((rn | rm) & q & !is_long) {
193
smmuv3_init_regs(s);
118
- return 1;
194
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
119
- }
195
index XXXXXXX..XXXXXXX 100644
120
- off_rn = vfp_reg_offset(1, rn);
196
--- a/hw/arm/stellaris.c
121
- off_rm = vfp_reg_offset(1, rm);
197
+++ b/hw/arm/stellaris.c
122
- } else {
198
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_enter(Object *obj, ResetType type)
123
- rn = VFP_SREG_N(insn);
199
s->dcgc[0] = 1;
124
- rm = VFP_SREG_M(insn);
200
}
125
- off_rn = vfp_reg_offset(0, rn);
201
126
- off_rm = vfp_reg_offset(0, rm);
202
-static void stellaris_sys_reset_hold(Object *obj)
127
- }
203
+static void stellaris_sys_reset_hold(Object *obj, ResetType type)
128
-
204
{
129
- if (s->fp_excp_el) {
205
ssys_state *s = STELLARIS_SYS(obj);
130
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
206
131
- syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
207
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_hold(Object *obj)
132
- return 0;
208
ssys_calculate_system_clock(s, true);
133
- }
209
}
134
- if (!s->vfp_enabled) {
210
135
- return 1;
211
-static void stellaris_sys_reset_exit(Object *obj)
136
- }
212
+static void stellaris_sys_reset_exit(Object *obj, ResetType type)
137
-
213
{
138
- opr_sz = (1 + q) * 8;
214
}
139
- if (fn_gvec_ptr) {
215
140
- TCGv_ptr ptr;
216
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_reset_enter(Object *obj, ResetType type)
141
- if (ptr_is_env) {
217
i2c_end_transfer(s->bus);
142
- ptr = cpu_env;
218
}
143
- } else {
219
144
- ptr = get_fpstatus_ptr(1);
220
-static void stellaris_i2c_reset_hold(Object *obj)
145
- }
221
+static void stellaris_i2c_reset_hold(Object *obj, ResetType type)
146
- tcg_gen_gvec_3_ptr(vfp_reg_offset(1, rd), off_rn, off_rm, ptr,
222
{
147
- opr_sz, opr_sz, data, fn_gvec_ptr);
223
stellaris_i2c_state *s = STELLARIS_I2C(obj);
148
- if (!ptr_is_env) {
224
149
- tcg_temp_free_ptr(ptr);
225
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_reset_hold(Object *obj)
150
- }
226
s->mcr = 0;
151
- } else {
227
}
152
- tcg_gen_gvec_3_ool(vfp_reg_offset(1, rd), off_rn, off_rm,
228
153
- opr_sz, opr_sz, data, fn_gvec);
229
-static void stellaris_i2c_reset_exit(Object *obj)
154
- }
230
+static void stellaris_i2c_reset_exit(Object *obj, ResetType type)
155
- return 0;
231
{
156
-}
232
stellaris_i2c_state *s = STELLARIS_I2C(obj);
157
-
233
158
/* Advanced SIMD two registers and a scalar extension.
234
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_trigger(void *opaque, int irq, int level)
159
* 31 24 23 22 20 16 12 11 10 9 8 3 0
235
}
160
* +-----------------+----+---+----+----+----+---+----+---+----+---------+----+
236
}
161
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
237
162
}
238
-static void stellaris_adc_reset_hold(Object *obj)
163
}
239
+static void stellaris_adc_reset_hold(Object *obj, ResetType type)
164
}
240
{
165
- } else if ((insn & 0x0e000a00) == 0x0c000800
241
StellarisADCState *s = STELLARIS_ADC(obj);
166
- && arm_dc_feature(s, ARM_FEATURE_V8)) {
242
int n;
167
- if (disas_neon_insn_3same_ext(s, insn)) {
243
diff --git a/hw/audio/asc.c b/hw/audio/asc.c
168
- goto illegal_op;
244
index XXXXXXX..XXXXXXX 100644
169
- }
245
--- a/hw/audio/asc.c
170
- return;
246
+++ b/hw/audio/asc.c
171
} else if ((insn & 0x0f000a00) == 0x0e000800
247
@@ -XXX,XX +XXX,XX @@ static void asc_fifo_init(ASCFIFOState *fs, int index)
172
&& arm_dc_feature(s, ARM_FEATURE_V8)) {
248
g_free(name);
173
if (disas_neon_insn_2reg_scalar_ext(s, insn)) {
249
}
174
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
250
175
}
251
-static void asc_reset_hold(Object *obj)
176
break;
252
+static void asc_reset_hold(Object *obj, ResetType type)
253
{
254
ASCState *s = ASC(obj);
255
256
diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
257
index XXXXXXX..XXXXXXX 100644
258
--- a/hw/char/cadence_uart.c
259
+++ b/hw/char/cadence_uart.c
260
@@ -XXX,XX +XXX,XX @@ static void cadence_uart_reset_init(Object *obj, ResetType type)
261
s->r[R_TTRIG] = 0x00000020;
262
}
263
264
-static void cadence_uart_reset_hold(Object *obj)
265
+static void cadence_uart_reset_hold(Object *obj, ResetType type)
266
{
267
CadenceUARTState *s = CADENCE_UART(obj);
268
269
diff --git a/hw/char/sifive_uart.c b/hw/char/sifive_uart.c
270
index XXXXXXX..XXXXXXX 100644
271
--- a/hw/char/sifive_uart.c
272
+++ b/hw/char/sifive_uart.c
273
@@ -XXX,XX +XXX,XX @@ static void sifive_uart_reset_enter(Object *obj, ResetType type)
274
s->rx_fifo_len = 0;
275
}
276
277
-static void sifive_uart_reset_hold(Object *obj)
278
+static void sifive_uart_reset_hold(Object *obj, ResetType type)
279
{
280
SiFiveUARTState *s = SIFIVE_UART(obj);
281
qemu_irq_lower(s->irq);
282
diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c
283
index XXXXXXX..XXXXXXX 100644
284
--- a/hw/core/cpu-common.c
285
+++ b/hw/core/cpu-common.c
286
@@ -XXX,XX +XXX,XX @@ void cpu_reset(CPUState *cpu)
287
trace_cpu_reset(cpu->cpu_index);
288
}
289
290
-static void cpu_common_reset_hold(Object *obj)
291
+static void cpu_common_reset_hold(Object *obj, ResetType type)
292
{
293
CPUState *cpu = CPU(obj);
294
CPUClass *cc = CPU_GET_CLASS(cpu);
295
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
296
index XXXXXXX..XXXXXXX 100644
297
--- a/hw/core/qdev.c
298
+++ b/hw/core/qdev.c
299
@@ -XXX,XX +XXX,XX @@ static void device_phases_reset(DeviceState *dev)
300
rc->phases.enter(OBJECT(dev), RESET_TYPE_COLD);
301
}
302
if (rc->phases.hold) {
303
- rc->phases.hold(OBJECT(dev));
304
+ rc->phases.hold(OBJECT(dev), RESET_TYPE_COLD);
305
}
306
if (rc->phases.exit) {
307
- rc->phases.exit(OBJECT(dev));
308
+ rc->phases.exit(OBJECT(dev), RESET_TYPE_COLD);
309
}
310
}
311
312
diff --git a/hw/core/reset.c b/hw/core/reset.c
313
index XXXXXXX..XXXXXXX 100644
314
--- a/hw/core/reset.c
315
+++ b/hw/core/reset.c
316
@@ -XXX,XX +XXX,XX @@ static ResettableState *legacy_reset_get_state(Object *obj)
317
return &lr->reset_state;
318
}
319
320
-static void legacy_reset_hold(Object *obj)
321
+static void legacy_reset_hold(Object *obj, ResetType type)
322
{
323
LegacyReset *lr = LEGACY_RESET(obj);
324
325
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
326
index XXXXXXX..XXXXXXX 100644
327
--- a/hw/core/resettable.c
328
+++ b/hw/core/resettable.c
329
@@ -XXX,XX +XXX,XX @@ static void resettable_phase_hold(Object *obj, void *opaque, ResetType type)
330
trace_resettable_transitional_function(obj, obj_typename);
331
tr_func(obj);
332
} else if (rc->phases.hold) {
333
- rc->phases.hold(obj);
334
+ rc->phases.hold(obj, type);
177
}
335
}
178
- if ((insn & 0xfe000a00) == 0xfc000800
336
}
179
+ if ((insn & 0xff000a00) == 0xfe000800
337
trace_resettable_phase_hold_end(obj, obj_typename, s->count);
180
&& arm_dc_feature(s, ARM_FEATURE_V8)) {
338
@@ -XXX,XX +XXX,XX @@ static void resettable_phase_exit(Object *obj, void *opaque, ResetType type)
181
/* The Thumb2 and ARM encodings are identical. */
339
if (--s->count == 0) {
182
- if (disas_neon_insn_3same_ext(s, insn)) {
340
trace_resettable_phase_exit_exec(obj, obj_typename, !!rc->phases.exit);
183
- goto illegal_op;
341
if (rc->phases.exit && !resettable_get_tr_func(rc, obj)) {
184
- }
342
- rc->phases.exit(obj);
185
- } else if ((insn & 0xff000a00) == 0xfe000800
343
+ rc->phases.exit(obj, type);
186
- && arm_dc_feature(s, ARM_FEATURE_V8)) {
344
}
187
- /* The Thumb2 and ARM encodings are identical. */
345
}
188
if (disas_neon_insn_2reg_scalar_ext(s, insn)) {
346
s->exit_phase_in_progress = false;
189
goto illegal_op;
347
diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
190
}
348
index XXXXXXX..XXXXXXX 100644
349
--- a/hw/display/virtio-vga.c
350
+++ b/hw/display/virtio-vga.c
351
@@ -XXX,XX +XXX,XX @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
352
}
353
}
354
355
-static void virtio_vga_base_reset_hold(Object *obj)
356
+static void virtio_vga_base_reset_hold(Object *obj, ResetType type)
357
{
358
VirtIOVGABaseClass *klass = VIRTIO_VGA_BASE_GET_CLASS(obj);
359
VirtIOVGABase *vvga = VIRTIO_VGA_BASE(obj);
360
361
/* reset virtio-gpu */
362
if (klass->parent_phases.hold) {
363
- klass->parent_phases.hold(obj);
364
+ klass->parent_phases.hold(obj, type);
365
}
366
367
/* reset vga */
368
diff --git a/hw/gpio/npcm7xx_gpio.c b/hw/gpio/npcm7xx_gpio.c
369
index XXXXXXX..XXXXXXX 100644
370
--- a/hw/gpio/npcm7xx_gpio.c
371
+++ b/hw/gpio/npcm7xx_gpio.c
372
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_gpio_enter_reset(Object *obj, ResetType type)
373
s->regs[NPCM7XX_GPIO_ODSC] = s->reset_odsc;
374
}
375
376
-static void npcm7xx_gpio_hold_reset(Object *obj)
377
+static void npcm7xx_gpio_hold_reset(Object *obj, ResetType type)
378
{
379
NPCM7xxGPIOState *s = NPCM7XX_GPIO(obj);
380
381
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
382
index XXXXXXX..XXXXXXX 100644
383
--- a/hw/gpio/pl061.c
384
+++ b/hw/gpio/pl061.c
385
@@ -XXX,XX +XXX,XX @@ static void pl061_enter_reset(Object *obj, ResetType type)
386
s->amsel = 0;
387
}
388
389
-static void pl061_hold_reset(Object *obj)
390
+static void pl061_hold_reset(Object *obj, ResetType type)
391
{
392
PL061State *s = PL061(obj);
393
int i, level;
394
diff --git a/hw/gpio/stm32l4x5_gpio.c b/hw/gpio/stm32l4x5_gpio.c
395
index XXXXXXX..XXXXXXX 100644
396
--- a/hw/gpio/stm32l4x5_gpio.c
397
+++ b/hw/gpio/stm32l4x5_gpio.c
398
@@ -XXX,XX +XXX,XX @@ static bool is_push_pull(Stm32l4x5GpioState *s, unsigned pin)
399
return extract32(s->otyper, pin, 1) == 0;
400
}
401
402
-static void stm32l4x5_gpio_reset_hold(Object *obj)
403
+static void stm32l4x5_gpio_reset_hold(Object *obj, ResetType type)
404
{
405
Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj);
406
407
diff --git a/hw/hyperv/vmbus.c b/hw/hyperv/vmbus.c
408
index XXXXXXX..XXXXXXX 100644
409
--- a/hw/hyperv/vmbus.c
410
+++ b/hw/hyperv/vmbus.c
411
@@ -XXX,XX +XXX,XX @@ static void vmbus_unrealize(BusState *bus)
412
qemu_mutex_destroy(&vmbus->rx_queue_lock);
413
}
414
415
-static void vmbus_reset_hold(Object *obj)
416
+static void vmbus_reset_hold(Object *obj, ResetType type)
417
{
418
vmbus_deinit(VMBUS(obj));
419
}
420
diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c
421
index XXXXXXX..XXXXXXX 100644
422
--- a/hw/i2c/allwinner-i2c.c
423
+++ b/hw/i2c/allwinner-i2c.c
424
@@ -XXX,XX +XXX,XX @@ static inline bool allwinner_i2c_interrupt_is_enabled(AWI2CState *s)
425
return s->cntr & TWI_CNTR_INT_EN;
426
}
427
428
-static void allwinner_i2c_reset_hold(Object *obj)
429
+static void allwinner_i2c_reset_hold(Object *obj, ResetType type)
430
{
431
AWI2CState *s = AW_I2C(obj);
432
433
diff --git a/hw/i2c/npcm7xx_smbus.c b/hw/i2c/npcm7xx_smbus.c
434
index XXXXXXX..XXXXXXX 100644
435
--- a/hw/i2c/npcm7xx_smbus.c
436
+++ b/hw/i2c/npcm7xx_smbus.c
437
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_smbus_enter_reset(Object *obj, ResetType type)
438
s->rx_cur = 0;
439
}
440
441
-static void npcm7xx_smbus_hold_reset(Object *obj)
442
+static void npcm7xx_smbus_hold_reset(Object *obj, ResetType type)
443
{
444
NPCM7xxSMBusState *s = NPCM7XX_SMBUS(obj);
445
446
diff --git a/hw/input/adb.c b/hw/input/adb.c
447
index XXXXXXX..XXXXXXX 100644
448
--- a/hw/input/adb.c
449
+++ b/hw/input/adb.c
450
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_adb_bus = {
451
}
452
};
453
454
-static void adb_bus_reset_hold(Object *obj)
455
+static void adb_bus_reset_hold(Object *obj, ResetType type)
456
{
457
ADBBusState *adb_bus = ADB_BUS(obj);
458
459
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
460
index XXXXXXX..XXXXXXX 100644
461
--- a/hw/input/ps2.c
462
+++ b/hw/input/ps2.c
463
@@ -XXX,XX +XXX,XX @@ void ps2_write_mouse(PS2MouseState *s, int val)
464
}
465
}
466
467
-static void ps2_reset_hold(Object *obj)
468
+static void ps2_reset_hold(Object *obj, ResetType type)
469
{
470
PS2State *s = PS2_DEVICE(obj);
471
472
@@ -XXX,XX +XXX,XX @@ static void ps2_reset_hold(Object *obj)
473
ps2_reset_queue(s);
474
}
475
476
-static void ps2_reset_exit(Object *obj)
477
+static void ps2_reset_exit(Object *obj, ResetType type)
478
{
479
PS2State *s = PS2_DEVICE(obj);
480
481
@@ -XXX,XX +XXX,XX @@ static void ps2_common_post_load(PS2State *s)
482
q->cwptr = ccount ? (q->rptr + ccount) & (PS2_BUFFER_SIZE - 1) : -1;
483
}
484
485
-static void ps2_kbd_reset_hold(Object *obj)
486
+static void ps2_kbd_reset_hold(Object *obj, ResetType type)
487
{
488
PS2DeviceClass *ps2dc = PS2_DEVICE_GET_CLASS(obj);
489
PS2KbdState *s = PS2_KBD_DEVICE(obj);
490
@@ -XXX,XX +XXX,XX @@ static void ps2_kbd_reset_hold(Object *obj)
491
trace_ps2_kbd_reset(s);
492
493
if (ps2dc->parent_phases.hold) {
494
- ps2dc->parent_phases.hold(obj);
495
+ ps2dc->parent_phases.hold(obj, type);
496
}
497
498
s->scan_enabled = 1;
499
@@ -XXX,XX +XXX,XX @@ static void ps2_kbd_reset_hold(Object *obj)
500
s->modifiers = 0;
501
}
502
503
-static void ps2_mouse_reset_hold(Object *obj)
504
+static void ps2_mouse_reset_hold(Object *obj, ResetType type)
505
{
506
PS2DeviceClass *ps2dc = PS2_DEVICE_GET_CLASS(obj);
507
PS2MouseState *s = PS2_MOUSE_DEVICE(obj);
508
@@ -XXX,XX +XXX,XX @@ static void ps2_mouse_reset_hold(Object *obj)
509
trace_ps2_mouse_reset(s);
510
511
if (ps2dc->parent_phases.hold) {
512
- ps2dc->parent_phases.hold(obj);
513
+ ps2dc->parent_phases.hold(obj, type);
514
}
515
516
s->mouse_status = 0;
517
diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c
518
index XXXXXXX..XXXXXXX 100644
519
--- a/hw/intc/arm_gic_common.c
520
+++ b/hw/intc/arm_gic_common.c
521
@@ -XXX,XX +XXX,XX @@ static inline void arm_gic_common_reset_irq_state(GICState *s, int cidx,
522
}
523
}
524
525
-static void arm_gic_common_reset_hold(Object *obj)
526
+static void arm_gic_common_reset_hold(Object *obj, ResetType type)
527
{
528
GICState *s = ARM_GIC_COMMON(obj);
529
int i, j;
530
diff --git a/hw/intc/arm_gic_kvm.c b/hw/intc/arm_gic_kvm.c
531
index XXXXXXX..XXXXXXX 100644
532
--- a/hw/intc/arm_gic_kvm.c
533
+++ b/hw/intc/arm_gic_kvm.c
534
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gic_get(GICState *s)
535
}
536
}
537
538
-static void kvm_arm_gic_reset_hold(Object *obj)
539
+static void kvm_arm_gic_reset_hold(Object *obj, ResetType type)
540
{
541
GICState *s = ARM_GIC_COMMON(obj);
542
KVMARMGICClass *kgc = KVM_ARM_GIC_GET_CLASS(s);
543
544
if (kgc->parent_phases.hold) {
545
- kgc->parent_phases.hold(obj);
546
+ kgc->parent_phases.hold(obj, type);
547
}
548
549
if (kvm_arm_gic_can_save_restore(s)) {
550
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
551
index XXXXXXX..XXXXXXX 100644
552
--- a/hw/intc/arm_gicv3_common.c
553
+++ b/hw/intc/arm_gicv3_common.c
554
@@ -XXX,XX +XXX,XX @@ static void arm_gicv3_finalize(Object *obj)
555
g_free(s->redist_region_count);
556
}
557
558
-static void arm_gicv3_common_reset_hold(Object *obj)
559
+static void arm_gicv3_common_reset_hold(Object *obj, ResetType type)
560
{
561
GICv3State *s = ARM_GICV3_COMMON(obj);
562
int i;
563
diff --git a/hw/intc/arm_gicv3_its.c b/hw/intc/arm_gicv3_its.c
564
index XXXXXXX..XXXXXXX 100644
565
--- a/hw/intc/arm_gicv3_its.c
566
+++ b/hw/intc/arm_gicv3_its.c
567
@@ -XXX,XX +XXX,XX @@ static void gicv3_arm_its_realize(DeviceState *dev, Error **errp)
568
}
569
}
570
571
-static void gicv3_its_reset_hold(Object *obj)
572
+static void gicv3_its_reset_hold(Object *obj, ResetType type)
573
{
574
GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj);
575
GICv3ITSClass *c = ARM_GICV3_ITS_GET_CLASS(s);
576
577
if (c->parent_phases.hold) {
578
- c->parent_phases.hold(obj);
579
+ c->parent_phases.hold(obj, type);
580
}
581
582
/* Quiescent bit reset to 1 */
583
diff --git a/hw/intc/arm_gicv3_its_common.c b/hw/intc/arm_gicv3_its_common.c
584
index XXXXXXX..XXXXXXX 100644
585
--- a/hw/intc/arm_gicv3_its_common.c
586
+++ b/hw/intc/arm_gicv3_its_common.c
587
@@ -XXX,XX +XXX,XX @@ void gicv3_its_init_mmio(GICv3ITSState *s, const MemoryRegionOps *ops,
588
msi_nonbroken = true;
589
}
590
591
-static void gicv3_its_common_reset_hold(Object *obj)
592
+static void gicv3_its_common_reset_hold(Object *obj, ResetType type)
593
{
594
GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj);
595
596
diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c
597
index XXXXXXX..XXXXXXX 100644
598
--- a/hw/intc/arm_gicv3_its_kvm.c
599
+++ b/hw/intc/arm_gicv3_its_kvm.c
600
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_post_load(GICv3ITSState *s)
601
GITS_CTLR, &s->ctlr, true, &error_abort);
602
}
603
604
-static void kvm_arm_its_reset_hold(Object *obj)
605
+static void kvm_arm_its_reset_hold(Object *obj, ResetType type)
606
{
607
GICv3ITSState *s = ARM_GICV3_ITS_COMMON(obj);
608
KVMARMITSClass *c = KVM_ARM_ITS_GET_CLASS(s);
609
int i;
610
611
if (c->parent_phases.hold) {
612
- c->parent_phases.hold(obj);
613
+ c->parent_phases.hold(obj, type);
614
}
615
616
if (kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
617
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
618
index XXXXXXX..XXXXXXX 100644
619
--- a/hw/intc/arm_gicv3_kvm.c
620
+++ b/hw/intc/arm_gicv3_kvm.c
621
@@ -XXX,XX +XXX,XX @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri)
622
c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS];
623
}
624
625
-static void kvm_arm_gicv3_reset_hold(Object *obj)
626
+static void kvm_arm_gicv3_reset_hold(Object *obj, ResetType type)
627
{
628
GICv3State *s = ARM_GICV3_COMMON(obj);
629
KVMARMGICv3Class *kgc = KVM_ARM_GICV3_GET_CLASS(s);
630
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_reset_hold(Object *obj)
631
DPRINTF("Reset\n");
632
633
if (kgc->parent_phases.hold) {
634
- kgc->parent_phases.hold(obj);
635
+ kgc->parent_phases.hold(obj, type);
636
}
637
638
if (s->migration_blocker) {
639
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
640
index XXXXXXX..XXXXXXX 100644
641
--- a/hw/intc/xics.c
642
+++ b/hw/intc/xics.c
643
@@ -XXX,XX +XXX,XX @@ static void ics_reset_irq(ICSIRQState *irq)
644
irq->saved_priority = 0xff;
645
}
646
647
-static void ics_reset_hold(Object *obj)
648
+static void ics_reset_hold(Object *obj, ResetType type)
649
{
650
ICSState *ics = ICS(obj);
651
g_autofree uint8_t *flags = g_malloc(ics->nr_irqs);
652
diff --git a/hw/m68k/q800-glue.c b/hw/m68k/q800-glue.c
653
index XXXXXXX..XXXXXXX 100644
654
--- a/hw/m68k/q800-glue.c
655
+++ b/hw/m68k/q800-glue.c
656
@@ -XXX,XX +XXX,XX @@ static void glue_nmi_release(void *opaque)
657
GLUE_set_irq(s, GLUE_IRQ_IN_NMI, 0);
658
}
659
660
-static void glue_reset_hold(Object *obj)
661
+static void glue_reset_hold(Object *obj, ResetType type)
662
{
663
GLUEState *s = GLUE(obj);
664
665
diff --git a/hw/misc/djmemc.c b/hw/misc/djmemc.c
666
index XXXXXXX..XXXXXXX 100644
667
--- a/hw/misc/djmemc.c
668
+++ b/hw/misc/djmemc.c
669
@@ -XXX,XX +XXX,XX @@ static void djmemc_init(Object *obj)
670
sysbus_init_mmio(sbd, &s->mem_regs);
671
}
672
673
-static void djmemc_reset_hold(Object *obj)
674
+static void djmemc_reset_hold(Object *obj, ResetType type)
675
{
676
DJMEMCState *s = DJMEMC(obj);
677
678
diff --git a/hw/misc/iosb.c b/hw/misc/iosb.c
679
index XXXXXXX..XXXXXXX 100644
680
--- a/hw/misc/iosb.c
681
+++ b/hw/misc/iosb.c
682
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps iosb_mmio_ops = {
683
.endianness = DEVICE_BIG_ENDIAN,
684
};
685
686
-static void iosb_reset_hold(Object *obj)
687
+static void iosb_reset_hold(Object *obj, ResetType type)
688
{
689
IOSBState *s = IOSB(obj);
690
691
diff --git a/hw/misc/mac_via.c b/hw/misc/mac_via.c
692
index XXXXXXX..XXXXXXX 100644
693
--- a/hw/misc/mac_via.c
694
+++ b/hw/misc/mac_via.c
695
@@ -XXX,XX +XXX,XX @@ static int via1_post_load(void *opaque, int version_id)
696
}
697
698
/* VIA 1 */
699
-static void mos6522_q800_via1_reset_hold(Object *obj)
700
+static void mos6522_q800_via1_reset_hold(Object *obj, ResetType type)
701
{
702
MOS6522Q800VIA1State *v1s = MOS6522_Q800_VIA1(obj);
703
MOS6522State *ms = MOS6522(v1s);
704
@@ -XXX,XX +XXX,XX @@ static void mos6522_q800_via1_reset_hold(Object *obj)
705
ADBBusState *adb_bus = &v1s->adb_bus;
706
707
if (mdc->parent_phases.hold) {
708
- mdc->parent_phases.hold(obj);
709
+ mdc->parent_phases.hold(obj, type);
710
}
711
712
ms->timers[0].frequency = VIA_TIMER_FREQ;
713
@@ -XXX,XX +XXX,XX @@ static void mos6522_q800_via2_portB_write(MOS6522State *s)
714
}
715
}
716
717
-static void mos6522_q800_via2_reset_hold(Object *obj)
718
+static void mos6522_q800_via2_reset_hold(Object *obj, ResetType type)
719
{
720
MOS6522State *ms = MOS6522(obj);
721
MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms);
722
723
if (mdc->parent_phases.hold) {
724
- mdc->parent_phases.hold(obj);
725
+ mdc->parent_phases.hold(obj, type);
726
}
727
728
ms->timers[0].frequency = VIA_TIMER_FREQ;
729
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
730
index XXXXXXX..XXXXXXX 100644
731
--- a/hw/misc/macio/cuda.c
732
+++ b/hw/misc/macio/cuda.c
733
@@ -XXX,XX +XXX,XX @@ static void mos6522_cuda_portB_write(MOS6522State *s)
734
cuda_update(cs);
735
}
736
737
-static void mos6522_cuda_reset_hold(Object *obj)
738
+static void mos6522_cuda_reset_hold(Object *obj, ResetType type)
739
{
740
MOS6522State *ms = MOS6522(obj);
741
MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms);
742
743
if (mdc->parent_phases.hold) {
744
- mdc->parent_phases.hold(obj);
745
+ mdc->parent_phases.hold(obj, type);
746
}
747
748
ms->timers[0].frequency = CUDA_TIMER_FREQ;
749
diff --git a/hw/misc/macio/pmu.c b/hw/misc/macio/pmu.c
750
index XXXXXXX..XXXXXXX 100644
751
--- a/hw/misc/macio/pmu.c
752
+++ b/hw/misc/macio/pmu.c
753
@@ -XXX,XX +XXX,XX @@ static void mos6522_pmu_portB_write(MOS6522State *s)
754
pmu_update(ps);
755
}
756
757
-static void mos6522_pmu_reset_hold(Object *obj)
758
+static void mos6522_pmu_reset_hold(Object *obj, ResetType type)
759
{
760
MOS6522State *ms = MOS6522(obj);
761
MOS6522PMUState *mps = container_of(ms, MOS6522PMUState, parent_obj);
762
@@ -XXX,XX +XXX,XX @@ static void mos6522_pmu_reset_hold(Object *obj)
763
MOS6522DeviceClass *mdc = MOS6522_GET_CLASS(ms);
764
765
if (mdc->parent_phases.hold) {
766
- mdc->parent_phases.hold(obj);
767
+ mdc->parent_phases.hold(obj, type);
768
}
769
770
ms->timers[0].frequency = VIA_TIMER_FREQ;
771
diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c
772
index XXXXXXX..XXXXXXX 100644
773
--- a/hw/misc/mos6522.c
774
+++ b/hw/misc/mos6522.c
775
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_mos6522 = {
776
}
777
};
778
779
-static void mos6522_reset_hold(Object *obj)
780
+static void mos6522_reset_hold(Object *obj, ResetType type)
781
{
782
MOS6522State *s = MOS6522(obj);
783
784
diff --git a/hw/misc/npcm7xx_mft.c b/hw/misc/npcm7xx_mft.c
785
index XXXXXXX..XXXXXXX 100644
786
--- a/hw/misc/npcm7xx_mft.c
787
+++ b/hw/misc/npcm7xx_mft.c
788
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_mft_enter_reset(Object *obj, ResetType type)
789
npcm7xx_mft_reset(s);
790
}
791
792
-static void npcm7xx_mft_hold_reset(Object *obj)
793
+static void npcm7xx_mft_hold_reset(Object *obj, ResetType type)
794
{
795
NPCM7xxMFTState *s = NPCM7XX_MFT(obj);
796
797
diff --git a/hw/misc/npcm7xx_pwm.c b/hw/misc/npcm7xx_pwm.c
798
index XXXXXXX..XXXXXXX 100644
799
--- a/hw/misc/npcm7xx_pwm.c
800
+++ b/hw/misc/npcm7xx_pwm.c
801
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_enter_reset(Object *obj, ResetType type)
802
s->piir = 0x00000000;
803
}
804
805
-static void npcm7xx_pwm_hold_reset(Object *obj)
806
+static void npcm7xx_pwm_hold_reset(Object *obj, ResetType type)
807
{
808
NPCM7xxPWMState *s = NPCM7XX_PWM(obj);
809
int i;
810
diff --git a/hw/misc/stm32l4x5_exti.c b/hw/misc/stm32l4x5_exti.c
811
index XXXXXXX..XXXXXXX 100644
812
--- a/hw/misc/stm32l4x5_exti.c
813
+++ b/hw/misc/stm32l4x5_exti.c
814
@@ -XXX,XX +XXX,XX @@ static unsigned configurable_mask(unsigned bank)
815
return valid_mask(bank) & ~exti_romask[bank];
816
}
817
818
-static void stm32l4x5_exti_reset_hold(Object *obj)
819
+static void stm32l4x5_exti_reset_hold(Object *obj, ResetType type)
820
{
821
Stm32l4x5ExtiState *s = STM32L4X5_EXTI(obj);
822
823
diff --git a/hw/misc/stm32l4x5_rcc.c b/hw/misc/stm32l4x5_rcc.c
824
index XXXXXXX..XXXXXXX 100644
825
--- a/hw/misc/stm32l4x5_rcc.c
826
+++ b/hw/misc/stm32l4x5_rcc.c
827
@@ -XXX,XX +XXX,XX @@ static void clock_mux_reset_enter(Object *obj, ResetType type)
828
set_clock_mux_init_info(s, s->id);
829
}
830
831
-static void clock_mux_reset_hold(Object *obj)
832
+static void clock_mux_reset_hold(Object *obj, ResetType type)
833
{
834
RccClockMuxState *s = RCC_CLOCK_MUX(obj);
835
clock_mux_update(s, true);
836
}
837
838
-static void clock_mux_reset_exit(Object *obj)
839
+static void clock_mux_reset_exit(Object *obj, ResetType type)
840
{
841
RccClockMuxState *s = RCC_CLOCK_MUX(obj);
842
clock_mux_update(s, false);
843
@@ -XXX,XX +XXX,XX @@ static void pll_reset_enter(Object *obj, ResetType type)
844
set_pll_init_info(s, s->id);
845
}
846
847
-static void pll_reset_hold(Object *obj)
848
+static void pll_reset_hold(Object *obj, ResetType type)
849
{
850
RccPllState *s = RCC_PLL(obj);
851
pll_update(s, true);
852
}
853
854
-static void pll_reset_exit(Object *obj)
855
+static void pll_reset_exit(Object *obj, ResetType type)
856
{
857
RccPllState *s = RCC_PLL(obj);
858
pll_update(s, false);
859
@@ -XXX,XX +XXX,XX @@ static void rcc_update_csr(Stm32l4x5RccState *s)
860
rcc_update_irq(s);
861
}
862
863
-static void stm32l4x5_rcc_reset_hold(Object *obj)
864
+static void stm32l4x5_rcc_reset_hold(Object *obj, ResetType type)
865
{
866
Stm32l4x5RccState *s = STM32L4X5_RCC(obj);
867
s->cr = 0x00000063;
868
diff --git a/hw/misc/stm32l4x5_syscfg.c b/hw/misc/stm32l4x5_syscfg.c
869
index XXXXXXX..XXXXXXX 100644
870
--- a/hw/misc/stm32l4x5_syscfg.c
871
+++ b/hw/misc/stm32l4x5_syscfg.c
872
@@ -XXX,XX +XXX,XX @@
873
874
#define NUM_LINES_PER_EXTICR_REG 4
875
876
-static void stm32l4x5_syscfg_hold_reset(Object *obj)
877
+static void stm32l4x5_syscfg_hold_reset(Object *obj, ResetType type)
878
{
879
Stm32l4x5SyscfgState *s = STM32L4X5_SYSCFG(obj);
880
881
diff --git a/hw/misc/xlnx-versal-cframe-reg.c b/hw/misc/xlnx-versal-cframe-reg.c
882
index XXXXXXX..XXXXXXX 100644
883
--- a/hw/misc/xlnx-versal-cframe-reg.c
884
+++ b/hw/misc/xlnx-versal-cframe-reg.c
885
@@ -XXX,XX +XXX,XX @@ static void cframe_reg_reset_enter(Object *obj, ResetType type)
886
}
887
}
888
889
-static void cframe_reg_reset_hold(Object *obj)
890
+static void cframe_reg_reset_hold(Object *obj, ResetType type)
891
{
892
XlnxVersalCFrameReg *s = XLNX_VERSAL_CFRAME_REG(obj);
893
894
diff --git a/hw/misc/xlnx-versal-crl.c b/hw/misc/xlnx-versal-crl.c
895
index XXXXXXX..XXXXXXX 100644
896
--- a/hw/misc/xlnx-versal-crl.c
897
+++ b/hw/misc/xlnx-versal-crl.c
898
@@ -XXX,XX +XXX,XX @@ static void crl_reset_enter(Object *obj, ResetType type)
899
}
900
}
901
902
-static void crl_reset_hold(Object *obj)
903
+static void crl_reset_hold(Object *obj, ResetType type)
904
{
905
XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj);
906
907
diff --git a/hw/misc/xlnx-versal-pmc-iou-slcr.c b/hw/misc/xlnx-versal-pmc-iou-slcr.c
908
index XXXXXXX..XXXXXXX 100644
909
--- a/hw/misc/xlnx-versal-pmc-iou-slcr.c
910
+++ b/hw/misc/xlnx-versal-pmc-iou-slcr.c
911
@@ -XXX,XX +XXX,XX @@ static void xlnx_versal_pmc_iou_slcr_reset_init(Object *obj, ResetType type)
912
}
913
}
914
915
-static void xlnx_versal_pmc_iou_slcr_reset_hold(Object *obj)
916
+static void xlnx_versal_pmc_iou_slcr_reset_hold(Object *obj, ResetType type)
917
{
918
XlnxVersalPmcIouSlcr *s = XILINX_VERSAL_PMC_IOU_SLCR(obj);
919
920
diff --git a/hw/misc/xlnx-versal-trng.c b/hw/misc/xlnx-versal-trng.c
921
index XXXXXXX..XXXXXXX 100644
922
--- a/hw/misc/xlnx-versal-trng.c
923
+++ b/hw/misc/xlnx-versal-trng.c
924
@@ -XXX,XX +XXX,XX @@ static void trng_unrealize(DeviceState *dev)
925
s->prng = NULL;
926
}
927
928
-static void trng_reset_hold(Object *obj)
929
+static void trng_reset_hold(Object *obj, ResetType type)
930
{
931
trng_reset(XLNX_VERSAL_TRNG(obj));
932
}
933
diff --git a/hw/misc/xlnx-versal-xramc.c b/hw/misc/xlnx-versal-xramc.c
934
index XXXXXXX..XXXXXXX 100644
935
--- a/hw/misc/xlnx-versal-xramc.c
936
+++ b/hw/misc/xlnx-versal-xramc.c
937
@@ -XXX,XX +XXX,XX @@ static void xram_ctrl_reset_enter(Object *obj, ResetType type)
938
ARRAY_FIELD_DP32(s->regs, XRAM_IMP, SIZE, s->cfg.encoded_size);
939
}
940
941
-static void xram_ctrl_reset_hold(Object *obj)
942
+static void xram_ctrl_reset_hold(Object *obj, ResetType type)
943
{
944
XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj);
945
946
diff --git a/hw/misc/xlnx-zynqmp-apu-ctrl.c b/hw/misc/xlnx-zynqmp-apu-ctrl.c
947
index XXXXXXX..XXXXXXX 100644
948
--- a/hw/misc/xlnx-zynqmp-apu-ctrl.c
949
+++ b/hw/misc/xlnx-zynqmp-apu-ctrl.c
950
@@ -XXX,XX +XXX,XX @@ static void zynqmp_apu_reset_enter(Object *obj, ResetType type)
951
s->cpu_in_wfi = 0;
952
}
953
954
-static void zynqmp_apu_reset_hold(Object *obj)
955
+static void zynqmp_apu_reset_hold(Object *obj, ResetType type)
956
{
957
XlnxZynqMPAPUCtrl *s = XLNX_ZYNQMP_APU_CTRL(obj);
958
959
diff --git a/hw/misc/xlnx-zynqmp-crf.c b/hw/misc/xlnx-zynqmp-crf.c
960
index XXXXXXX..XXXXXXX 100644
961
--- a/hw/misc/xlnx-zynqmp-crf.c
962
+++ b/hw/misc/xlnx-zynqmp-crf.c
963
@@ -XXX,XX +XXX,XX @@ static void crf_reset_enter(Object *obj, ResetType type)
964
}
965
}
966
967
-static void crf_reset_hold(Object *obj)
968
+static void crf_reset_hold(Object *obj, ResetType type)
969
{
970
XlnxZynqMPCRF *s = XLNX_ZYNQMP_CRF(obj);
971
ir_update_irq(s);
972
diff --git a/hw/misc/zynq_slcr.c b/hw/misc/zynq_slcr.c
973
index XXXXXXX..XXXXXXX 100644
974
--- a/hw/misc/zynq_slcr.c
975
+++ b/hw/misc/zynq_slcr.c
976
@@ -XXX,XX +XXX,XX @@ static void zynq_slcr_reset_init(Object *obj, ResetType type)
977
s->regs[R_DDRIOB + 12] = 0x00000021;
978
}
979
980
-static void zynq_slcr_reset_hold(Object *obj)
981
+static void zynq_slcr_reset_hold(Object *obj, ResetType type)
982
{
983
ZynqSLCRState *s = ZYNQ_SLCR(obj);
984
985
@@ -XXX,XX +XXX,XX @@ static void zynq_slcr_reset_hold(Object *obj)
986
zynq_slcr_propagate_clocks(s);
987
}
988
989
-static void zynq_slcr_reset_exit(Object *obj)
990
+static void zynq_slcr_reset_exit(Object *obj, ResetType type)
991
{
992
ZynqSLCRState *s = ZYNQ_SLCR(obj);
993
994
diff --git a/hw/net/can/xlnx-zynqmp-can.c b/hw/net/can/xlnx-zynqmp-can.c
995
index XXXXXXX..XXXXXXX 100644
996
--- a/hw/net/can/xlnx-zynqmp-can.c
997
+++ b/hw/net/can/xlnx-zynqmp-can.c
998
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_can_reset_init(Object *obj, ResetType type)
999
ptimer_transaction_commit(s->can_timer);
1000
}
1001
1002
-static void xlnx_zynqmp_can_reset_hold(Object *obj)
1003
+static void xlnx_zynqmp_can_reset_hold(Object *obj, ResetType type)
1004
{
1005
XlnxZynqMPCANState *s = XLNX_ZYNQMP_CAN(obj);
1006
unsigned int i;
1007
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
1008
index XXXXXXX..XXXXXXX 100644
1009
--- a/hw/net/e1000.c
1010
+++ b/hw/net/e1000.c
1011
@@ -XXX,XX +XXX,XX @@ static bool e1000_vet_init_need(void *opaque)
1012
return chkflag(VET);
1013
}
1014
1015
-static void e1000_reset_hold(Object *obj)
1016
+static void e1000_reset_hold(Object *obj, ResetType type)
1017
{
1018
E1000State *d = E1000(obj);
1019
E1000BaseClass *edc = E1000_GET_CLASS(d);
1020
diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
1021
index XXXXXXX..XXXXXXX 100644
1022
--- a/hw/net/e1000e.c
1023
+++ b/hw/net/e1000e.c
1024
@@ -XXX,XX +XXX,XX @@ static void e1000e_pci_uninit(PCIDevice *pci_dev)
1025
msi_uninit(pci_dev);
1026
}
1027
1028
-static void e1000e_qdev_reset_hold(Object *obj)
1029
+static void e1000e_qdev_reset_hold(Object *obj, ResetType type)
1030
{
1031
E1000EState *s = E1000E(obj);
1032
1033
diff --git a/hw/net/igb.c b/hw/net/igb.c
1034
index XXXXXXX..XXXXXXX 100644
1035
--- a/hw/net/igb.c
1036
+++ b/hw/net/igb.c
1037
@@ -XXX,XX +XXX,XX @@ static void igb_pci_uninit(PCIDevice *pci_dev)
1038
msi_uninit(pci_dev);
1039
}
1040
1041
-static void igb_qdev_reset_hold(Object *obj)
1042
+static void igb_qdev_reset_hold(Object *obj, ResetType type)
1043
{
1044
IGBState *s = IGB(obj);
1045
1046
diff --git a/hw/net/igbvf.c b/hw/net/igbvf.c
1047
index XXXXXXX..XXXXXXX 100644
1048
--- a/hw/net/igbvf.c
1049
+++ b/hw/net/igbvf.c
1050
@@ -XXX,XX +XXX,XX @@ static void igbvf_pci_realize(PCIDevice *dev, Error **errp)
1051
pcie_ari_init(dev, 0x150);
1052
}
1053
1054
-static void igbvf_qdev_reset_hold(Object *obj)
1055
+static void igbvf_qdev_reset_hold(Object *obj, ResetType type)
1056
{
1057
PCIDevice *vf = PCI_DEVICE(obj);
1058
1059
diff --git a/hw/nvram/xlnx-bbram.c b/hw/nvram/xlnx-bbram.c
1060
index XXXXXXX..XXXXXXX 100644
1061
--- a/hw/nvram/xlnx-bbram.c
1062
+++ b/hw/nvram/xlnx-bbram.c
1063
@@ -XXX,XX +XXX,XX @@ static RegisterAccessInfo bbram_ctrl_regs_info[] = {
1064
}
1065
};
1066
1067
-static void bbram_ctrl_reset_hold(Object *obj)
1068
+static void bbram_ctrl_reset_hold(Object *obj, ResetType type)
1069
{
1070
XlnxBBRam *s = XLNX_BBRAM(obj);
1071
unsigned int i;
1072
diff --git a/hw/nvram/xlnx-versal-efuse-ctrl.c b/hw/nvram/xlnx-versal-efuse-ctrl.c
1073
index XXXXXXX..XXXXXXX 100644
1074
--- a/hw/nvram/xlnx-versal-efuse-ctrl.c
1075
+++ b/hw/nvram/xlnx-versal-efuse-ctrl.c
1076
@@ -XXX,XX +XXX,XX @@ static void efuse_ctrl_register_reset(RegisterInfo *reg)
1077
register_reset(reg);
1078
}
1079
1080
-static void efuse_ctrl_reset_hold(Object *obj)
1081
+static void efuse_ctrl_reset_hold(Object *obj, ResetType type)
1082
{
1083
XlnxVersalEFuseCtrl *s = XLNX_VERSAL_EFUSE_CTRL(obj);
1084
unsigned int i;
1085
diff --git a/hw/nvram/xlnx-zynqmp-efuse.c b/hw/nvram/xlnx-zynqmp-efuse.c
1086
index XXXXXXX..XXXXXXX 100644
1087
--- a/hw/nvram/xlnx-zynqmp-efuse.c
1088
+++ b/hw/nvram/xlnx-zynqmp-efuse.c
1089
@@ -XXX,XX +XXX,XX @@ static void zynqmp_efuse_register_reset(RegisterInfo *reg)
1090
register_reset(reg);
1091
}
1092
1093
-static void zynqmp_efuse_reset_hold(Object *obj)
1094
+static void zynqmp_efuse_reset_hold(Object *obj, ResetType type)
1095
{
1096
XlnxZynqMPEFuse *s = XLNX_ZYNQMP_EFUSE(obj);
1097
unsigned int i;
1098
diff --git a/hw/pci-bridge/cxl_root_port.c b/hw/pci-bridge/cxl_root_port.c
1099
index XXXXXXX..XXXXXXX 100644
1100
--- a/hw/pci-bridge/cxl_root_port.c
1101
+++ b/hw/pci-bridge/cxl_root_port.c
1102
@@ -XXX,XX +XXX,XX @@ static void cxl_rp_realize(DeviceState *dev, Error **errp)
1103
component_bar);
1104
}
1105
1106
-static void cxl_rp_reset_hold(Object *obj)
1107
+static void cxl_rp_reset_hold(Object *obj, ResetType type)
1108
{
1109
PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(obj);
1110
CXLRootPort *crp = CXL_ROOT_PORT(obj);
1111
1112
if (rpc->parent_phases.hold) {
1113
- rpc->parent_phases.hold(obj);
1114
+ rpc->parent_phases.hold(obj, type);
1115
}
1116
1117
latch_registers(crp);
1118
diff --git a/hw/pci-bridge/pcie_root_port.c b/hw/pci-bridge/pcie_root_port.c
1119
index XXXXXXX..XXXXXXX 100644
1120
--- a/hw/pci-bridge/pcie_root_port.c
1121
+++ b/hw/pci-bridge/pcie_root_port.c
1122
@@ -XXX,XX +XXX,XX @@ static void rp_write_config(PCIDevice *d, uint32_t address,
1123
pcie_aer_root_write_config(d, address, val, len, root_cmd);
1124
}
1125
1126
-static void rp_reset_hold(Object *obj)
1127
+static void rp_reset_hold(Object *obj, ResetType type)
1128
{
1129
PCIDevice *d = PCI_DEVICE(obj);
1130
DeviceState *qdev = DEVICE(obj);
1131
diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
1132
index XXXXXXX..XXXXXXX 100644
1133
--- a/hw/pci-host/bonito.c
1134
+++ b/hw/pci-host/bonito.c
1135
@@ -XXX,XX +XXX,XX @@ static int pci_bonito_map_irq(PCIDevice *pci_dev, int irq_num)
1136
}
1137
}
1138
1139
-static void bonito_reset_hold(Object *obj)
1140
+static void bonito_reset_hold(Object *obj, ResetType type)
1141
{
1142
PCIBonitoState *s = PCI_BONITO(obj);
1143
uint32_t val = 0;
1144
diff --git a/hw/pci-host/pnv_phb.c b/hw/pci-host/pnv_phb.c
1145
index XXXXXXX..XXXXXXX 100644
1146
--- a/hw/pci-host/pnv_phb.c
1147
+++ b/hw/pci-host/pnv_phb.c
1148
@@ -XXX,XX +XXX,XX @@ static void pnv_phb_class_init(ObjectClass *klass, void *data)
1149
dc->user_creatable = true;
1150
}
1151
1152
-static void pnv_phb_root_port_reset_hold(Object *obj)
1153
+static void pnv_phb_root_port_reset_hold(Object *obj, ResetType type)
1154
{
1155
PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(obj);
1156
PnvPHBRootPort *phb_rp = PNV_PHB_ROOT_PORT(obj);
1157
@@ -XXX,XX +XXX,XX @@ static void pnv_phb_root_port_reset_hold(Object *obj)
1158
uint8_t *conf = d->config;
1159
1160
if (rpc->parent_phases.hold) {
1161
- rpc->parent_phases.hold(obj);
1162
+ rpc->parent_phases.hold(obj, type);
1163
}
1164
1165
if (phb_rp->version == 3) {
1166
diff --git a/hw/pci-host/pnv_phb3_msi.c b/hw/pci-host/pnv_phb3_msi.c
1167
index XXXXXXX..XXXXXXX 100644
1168
--- a/hw/pci-host/pnv_phb3_msi.c
1169
+++ b/hw/pci-host/pnv_phb3_msi.c
1170
@@ -XXX,XX +XXX,XX @@ static void phb3_msi_resend(ICSState *ics)
1171
}
1172
}
1173
1174
-static void phb3_msi_reset_hold(Object *obj)
1175
+static void phb3_msi_reset_hold(Object *obj, ResetType type)
1176
{
1177
Phb3MsiState *msi = PHB3_MSI(obj);
1178
ICSStateClass *icsc = ICS_GET_CLASS(obj);
1179
1180
if (icsc->parent_phases.hold) {
1181
- icsc->parent_phases.hold(obj);
1182
+ icsc->parent_phases.hold(obj, type);
1183
}
1184
1185
memset(msi->rba, 0, sizeof(msi->rba));
1186
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
1187
index XXXXXXX..XXXXXXX 100644
1188
--- a/hw/pci/pci.c
1189
+++ b/hw/pci/pci.c
1190
@@ -XXX,XX +XXX,XX @@ bool pci_available = true;
1191
1192
static char *pcibus_get_dev_path(DeviceState *dev);
1193
static char *pcibus_get_fw_dev_path(DeviceState *dev);
1194
-static void pcibus_reset_hold(Object *obj);
1195
+static void pcibus_reset_hold(Object *obj, ResetType type);
1196
static bool pcie_has_upstream_port(PCIDevice *dev);
1197
1198
static Property pci_props[] = {
1199
@@ -XXX,XX +XXX,XX @@ void pci_device_reset(PCIDevice *dev)
1200
* Called via bus_cold_reset on RST# assert, after the devices
1201
* have been reset device_cold_reset-ed already.
1202
*/
1203
-static void pcibus_reset_hold(Object *obj)
1204
+static void pcibus_reset_hold(Object *obj, ResetType type)
1205
{
1206
PCIBus *bus = PCI_BUS(obj);
1207
int i;
1208
diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
1209
index XXXXXXX..XXXXXXX 100644
1210
--- a/hw/rtc/mc146818rtc.c
1211
+++ b/hw/rtc/mc146818rtc.c
1212
@@ -XXX,XX +XXX,XX @@ static void rtc_reset_enter(Object *obj, ResetType type)
1213
}
1214
}
1215
1216
-static void rtc_reset_hold(Object *obj)
1217
+static void rtc_reset_hold(Object *obj, ResetType type)
1218
{
1219
MC146818RtcState *s = MC146818_RTC(obj);
1220
1221
diff --git a/hw/s390x/css-bridge.c b/hw/s390x/css-bridge.c
1222
index XXXXXXX..XXXXXXX 100644
1223
--- a/hw/s390x/css-bridge.c
1224
+++ b/hw/s390x/css-bridge.c
1225
@@ -XXX,XX +XXX,XX @@ static void ccw_device_unplug(HotplugHandler *hotplug_dev,
1226
qdev_unrealize(dev);
1227
}
1228
1229
-static void virtual_css_bus_reset_hold(Object *obj)
1230
+static void virtual_css_bus_reset_hold(Object *obj, ResetType type)
1231
{
1232
/* This should actually be modelled via the generic css */
1233
css_reset();
1234
diff --git a/hw/sensor/adm1266.c b/hw/sensor/adm1266.c
1235
index XXXXXXX..XXXXXXX 100644
1236
--- a/hw/sensor/adm1266.c
1237
+++ b/hw/sensor/adm1266.c
1238
@@ -XXX,XX +XXX,XX @@ static const uint8_t adm1266_ic_device_id[] = {0x03, 0x41, 0x12, 0x66};
1239
static const uint8_t adm1266_ic_device_rev[] = {0x08, 0x01, 0x08, 0x07, 0x0,
1240
0x0, 0x07, 0x41, 0x30};
1241
1242
-static void adm1266_exit_reset(Object *obj)
1243
+static void adm1266_exit_reset(Object *obj, ResetType type)
1244
{
1245
ADM1266State *s = ADM1266(obj);
1246
PMBusDevice *pmdev = PMBUS_DEVICE(obj);
1247
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
1248
index XXXXXXX..XXXXXXX 100644
1249
--- a/hw/sensor/adm1272.c
1250
+++ b/hw/sensor/adm1272.c
1251
@@ -XXX,XX +XXX,XX @@ static uint32_t adm1272_direct_to_watts(uint16_t value)
1252
return pmbus_direct_mode2data(c, value);
1253
}
1254
1255
-static void adm1272_exit_reset(Object *obj)
1256
+static void adm1272_exit_reset(Object *obj, ResetType type)
1257
{
1258
ADM1272State *s = ADM1272(obj);
1259
PMBusDevice *pmdev = PMBUS_DEVICE(obj);
1260
diff --git a/hw/sensor/isl_pmbus_vr.c b/hw/sensor/isl_pmbus_vr.c
1261
index XXXXXXX..XXXXXXX 100644
1262
--- a/hw/sensor/isl_pmbus_vr.c
1263
+++ b/hw/sensor/isl_pmbus_vr.c
1264
@@ -XXX,XX +XXX,XX @@ static void isl_pmbus_vr_set(Object *obj, Visitor *v, const char *name,
1265
pmbus_check_limits(pmdev);
1266
}
1267
1268
-static void isl_pmbus_vr_exit_reset(Object *obj)
1269
+static void isl_pmbus_vr_exit_reset(Object *obj, ResetType type)
1270
{
1271
PMBusDevice *pmdev = PMBUS_DEVICE(obj);
1272
1273
@@ -XXX,XX +XXX,XX @@ static void isl_pmbus_vr_exit_reset(Object *obj)
1274
}
1275
1276
/* The raa228000 uses different direct mode coefficients from most isl devices */
1277
-static void raa228000_exit_reset(Object *obj)
1278
+static void raa228000_exit_reset(Object *obj, ResetType type)
1279
{
1280
PMBusDevice *pmdev = PMBUS_DEVICE(obj);
1281
1282
- isl_pmbus_vr_exit_reset(obj);
1283
+ isl_pmbus_vr_exit_reset(obj, type);
1284
1285
pmdev->pages[0].read_iout = 0;
1286
pmdev->pages[0].read_pout = 0;
1287
@@ -XXX,XX +XXX,XX @@ static void raa228000_exit_reset(Object *obj)
1288
pmdev->pages[0].read_temperature_3 = 0;
1289
}
1290
1291
-static void isl69259_exit_reset(Object *obj)
1292
+static void isl69259_exit_reset(Object *obj, ResetType type)
1293
{
1294
ISLState *s = ISL69260(obj);
1295
static const uint8_t ic_device_id[] = {0x04, 0x00, 0x81, 0xD2, 0x49, 0x3c};
1296
g_assert(sizeof(ic_device_id) <= sizeof(s->ic_device_id));
1297
1298
- isl_pmbus_vr_exit_reset(obj);
1299
+ isl_pmbus_vr_exit_reset(obj, type);
1300
1301
s->ic_device_id_len = sizeof(ic_device_id);
1302
memcpy(s->ic_device_id, ic_device_id, sizeof(ic_device_id));
1303
diff --git a/hw/sensor/max31785.c b/hw/sensor/max31785.c
1304
index XXXXXXX..XXXXXXX 100644
1305
--- a/hw/sensor/max31785.c
1306
+++ b/hw/sensor/max31785.c
1307
@@ -XXX,XX +XXX,XX @@ static int max31785_write_data(PMBusDevice *pmdev, const uint8_t *buf,
1308
return 0;
1309
}
1310
1311
-static void max31785_exit_reset(Object *obj)
1312
+static void max31785_exit_reset(Object *obj, ResetType type)
1313
{
1314
PMBusDevice *pmdev = PMBUS_DEVICE(obj);
1315
MAX31785State *s = MAX31785(obj);
1316
diff --git a/hw/sensor/max34451.c b/hw/sensor/max34451.c
1317
index XXXXXXX..XXXXXXX 100644
1318
--- a/hw/sensor/max34451.c
1319
+++ b/hw/sensor/max34451.c
1320
@@ -XXX,XX +XXX,XX @@ static inline void *memset_word(void *s, uint16_t c, size_t n)
1321
return s;
1322
}
1323
1324
-static void max34451_exit_reset(Object *obj)
1325
+static void max34451_exit_reset(Object *obj, ResetType type)
1326
{
1327
PMBusDevice *pmdev = PMBUS_DEVICE(obj);
1328
MAX34451State *s = MAX34451(obj);
1329
diff --git a/hw/ssi/npcm7xx_fiu.c b/hw/ssi/npcm7xx_fiu.c
1330
index XXXXXXX..XXXXXXX 100644
1331
--- a/hw/ssi/npcm7xx_fiu.c
1332
+++ b/hw/ssi/npcm7xx_fiu.c
1333
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_fiu_enter_reset(Object *obj, ResetType type)
1334
s->regs[NPCM7XX_FIU_CFG] = 0x0000000b;
1335
}
1336
1337
-static void npcm7xx_fiu_hold_reset(Object *obj)
1338
+static void npcm7xx_fiu_hold_reset(Object *obj, ResetType type)
1339
{
1340
NPCM7xxFIUState *s = NPCM7XX_FIU(obj);
1341
int i;
1342
diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
1343
index XXXXXXX..XXXXXXX 100644
1344
--- a/hw/timer/etraxfs_timer.c
1345
+++ b/hw/timer/etraxfs_timer.c
1346
@@ -XXX,XX +XXX,XX @@ static void etraxfs_timer_reset_enter(Object *obj, ResetType type)
1347
t->rw_intr_mask = 0;
1348
}
1349
1350
-static void etraxfs_timer_reset_hold(Object *obj)
1351
+static void etraxfs_timer_reset_hold(Object *obj, ResetType type)
1352
{
1353
ETRAXTimerState *t = ETRAX_TIMER(obj);
1354
1355
diff --git a/hw/timer/npcm7xx_timer.c b/hw/timer/npcm7xx_timer.c
1356
index XXXXXXX..XXXXXXX 100644
1357
--- a/hw/timer/npcm7xx_timer.c
1358
+++ b/hw/timer/npcm7xx_timer.c
1359
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_watchdog_timer_expired(void *opaque)
1360
}
1361
}
1362
1363
-static void npcm7xx_timer_hold_reset(Object *obj)
1364
+static void npcm7xx_timer_hold_reset(Object *obj, ResetType type)
1365
{
1366
NPCM7xxTimerCtrlState *s = NPCM7XX_TIMER(obj);
1367
int i;
1368
diff --git a/hw/usb/hcd-dwc2.c b/hw/usb/hcd-dwc2.c
1369
index XXXXXXX..XXXXXXX 100644
1370
--- a/hw/usb/hcd-dwc2.c
1371
+++ b/hw/usb/hcd-dwc2.c
1372
@@ -XXX,XX +XXX,XX @@ static void dwc2_reset_enter(Object *obj, ResetType type)
1373
}
1374
}
1375
1376
-static void dwc2_reset_hold(Object *obj)
1377
+static void dwc2_reset_hold(Object *obj, ResetType type)
1378
{
1379
DWC2Class *c = DWC2_USB_GET_CLASS(obj);
1380
DWC2State *s = DWC2_USB(obj);
1381
@@ -XXX,XX +XXX,XX @@ static void dwc2_reset_hold(Object *obj)
1382
trace_usb_dwc2_reset_hold();
1383
1384
if (c->parent_phases.hold) {
1385
- c->parent_phases.hold(obj);
1386
+ c->parent_phases.hold(obj, type);
1387
}
1388
1389
dwc2_update_irq(s);
1390
}
1391
1392
-static void dwc2_reset_exit(Object *obj)
1393
+static void dwc2_reset_exit(Object *obj, ResetType type)
1394
{
1395
DWC2Class *c = DWC2_USB_GET_CLASS(obj);
1396
DWC2State *s = DWC2_USB(obj);
1397
@@ -XXX,XX +XXX,XX @@ static void dwc2_reset_exit(Object *obj)
1398
trace_usb_dwc2_reset_exit();
1399
1400
if (c->parent_phases.exit) {
1401
- c->parent_phases.exit(obj);
1402
+ c->parent_phases.exit(obj, type);
1403
}
1404
1405
s->hprt0 = HPRT0_PWR;
1406
diff --git a/hw/usb/xlnx-versal-usb2-ctrl-regs.c b/hw/usb/xlnx-versal-usb2-ctrl-regs.c
1407
index XXXXXXX..XXXXXXX 100644
1408
--- a/hw/usb/xlnx-versal-usb2-ctrl-regs.c
1409
+++ b/hw/usb/xlnx-versal-usb2-ctrl-regs.c
1410
@@ -XXX,XX +XXX,XX @@ static void usb2_ctrl_regs_reset_init(Object *obj, ResetType type)
1411
}
1412
}
1413
1414
-static void usb2_ctrl_regs_reset_hold(Object *obj)
1415
+static void usb2_ctrl_regs_reset_hold(Object *obj, ResetType type)
1416
{
1417
VersalUsb2CtrlRegs *s = XILINX_VERSAL_USB2_CTRL_REGS(obj);
1418
1419
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
1420
index XXXXXXX..XXXXXXX 100644
1421
--- a/hw/virtio/virtio-pci.c
1422
+++ b/hw/virtio/virtio-pci.c
1423
@@ -XXX,XX +XXX,XX @@ static void virtio_pci_reset(DeviceState *qdev)
1424
}
1425
}
1426
1427
-static void virtio_pci_bus_reset_hold(Object *obj)
1428
+static void virtio_pci_bus_reset_hold(Object *obj, ResetType type)
1429
{
1430
PCIDevice *dev = PCI_DEVICE(obj);
1431
DeviceState *qdev = DEVICE(obj);
1432
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
1433
index XXXXXXX..XXXXXXX 100644
1434
--- a/target/arm/cpu.c
1435
+++ b/target/arm/cpu.c
1436
@@ -XXX,XX +XXX,XX @@ static void cp_reg_check_reset(gpointer key, gpointer value, gpointer opaque)
1437
assert(oldvalue == newvalue);
1438
}
1439
1440
-static void arm_cpu_reset_hold(Object *obj)
1441
+static void arm_cpu_reset_hold(Object *obj, ResetType type)
1442
{
1443
CPUState *cs = CPU(obj);
1444
ARMCPU *cpu = ARM_CPU(cs);
1445
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj)
1446
CPUARMState *env = &cpu->env;
1447
1448
if (acc->parent_phases.hold) {
1449
- acc->parent_phases.hold(obj);
1450
+ acc->parent_phases.hold(obj, type);
1451
}
1452
1453
memset(env, 0, offsetof(CPUARMState, end_reset_fields));
1454
diff --git a/target/avr/cpu.c b/target/avr/cpu.c
1455
index XXXXXXX..XXXXXXX 100644
1456
--- a/target/avr/cpu.c
1457
+++ b/target/avr/cpu.c
1458
@@ -XXX,XX +XXX,XX @@ static void avr_restore_state_to_opc(CPUState *cs,
1459
cpu_env(cs)->pc_w = data[0];
1460
}
1461
1462
-static void avr_cpu_reset_hold(Object *obj)
1463
+static void avr_cpu_reset_hold(Object *obj, ResetType type)
1464
{
1465
CPUState *cs = CPU(obj);
1466
AVRCPU *cpu = AVR_CPU(cs);
1467
@@ -XXX,XX +XXX,XX @@ static void avr_cpu_reset_hold(Object *obj)
1468
CPUAVRState *env = &cpu->env;
1469
1470
if (mcc->parent_phases.hold) {
1471
- mcc->parent_phases.hold(obj);
1472
+ mcc->parent_phases.hold(obj, type);
1473
}
1474
1475
env->pc_w = 0;
1476
diff --git a/target/cris/cpu.c b/target/cris/cpu.c
1477
index XXXXXXX..XXXXXXX 100644
1478
--- a/target/cris/cpu.c
1479
+++ b/target/cris/cpu.c
1480
@@ -XXX,XX +XXX,XX @@ static int cris_cpu_mmu_index(CPUState *cs, bool ifetch)
1481
return !!(cpu_env(cs)->pregs[PR_CCS] & U_FLAG);
1482
}
1483
1484
-static void cris_cpu_reset_hold(Object *obj)
1485
+static void cris_cpu_reset_hold(Object *obj, ResetType type)
1486
{
1487
CPUState *cs = CPU(obj);
1488
CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(obj);
1489
@@ -XXX,XX +XXX,XX @@ static void cris_cpu_reset_hold(Object *obj)
1490
uint32_t vr;
1491
1492
if (ccc->parent_phases.hold) {
1493
- ccc->parent_phases.hold(obj);
1494
+ ccc->parent_phases.hold(obj, type);
1495
}
1496
1497
vr = env->pregs[PR_VR];
1498
diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c
1499
index XXXXXXX..XXXXXXX 100644
1500
--- a/target/hexagon/cpu.c
1501
+++ b/target/hexagon/cpu.c
1502
@@ -XXX,XX +XXX,XX @@ static void hexagon_restore_state_to_opc(CPUState *cs,
1503
cpu_env(cs)->gpr[HEX_REG_PC] = data[0];
1504
}
1505
1506
-static void hexagon_cpu_reset_hold(Object *obj)
1507
+static void hexagon_cpu_reset_hold(Object *obj, ResetType type)
1508
{
1509
CPUState *cs = CPU(obj);
1510
HexagonCPUClass *mcc = HEXAGON_CPU_GET_CLASS(obj);
1511
CPUHexagonState *env = cpu_env(cs);
1512
1513
if (mcc->parent_phases.hold) {
1514
- mcc->parent_phases.hold(obj);
1515
+ mcc->parent_phases.hold(obj, type);
1516
}
1517
1518
set_default_nan_mode(1, &env->fp_status);
1519
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
1520
index XXXXXXX..XXXXXXX 100644
1521
--- a/target/i386/cpu.c
1522
+++ b/target/i386/cpu.c
1523
@@ -XXX,XX +XXX,XX @@ static void x86_cpu_set_sgxlepubkeyhash(CPUX86State *env)
1524
#endif
1525
}
1526
1527
-static void x86_cpu_reset_hold(Object *obj)
1528
+static void x86_cpu_reset_hold(Object *obj, ResetType type)
1529
{
1530
CPUState *cs = CPU(obj);
1531
X86CPU *cpu = X86_CPU(cs);
1532
@@ -XXX,XX +XXX,XX @@ static void x86_cpu_reset_hold(Object *obj)
1533
int i;
1534
1535
if (xcc->parent_phases.hold) {
1536
- xcc->parent_phases.hold(obj);
1537
+ xcc->parent_phases.hold(obj, type);
1538
}
1539
1540
memset(env, 0, offsetof(CPUX86State, end_reset_fields));
1541
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
1542
index XXXXXXX..XXXXXXX 100644
1543
--- a/target/loongarch/cpu.c
1544
+++ b/target/loongarch/cpu.c
1545
@@ -XXX,XX +XXX,XX @@ static void loongarch_max_initfn(Object *obj)
1546
loongarch_la464_initfn(obj);
1547
}
1548
1549
-static void loongarch_cpu_reset_hold(Object *obj)
1550
+static void loongarch_cpu_reset_hold(Object *obj, ResetType type)
1551
{
1552
CPUState *cs = CPU(obj);
1553
LoongArchCPUClass *lacc = LOONGARCH_CPU_GET_CLASS(obj);
1554
CPULoongArchState *env = cpu_env(cs);
1555
1556
if (lacc->parent_phases.hold) {
1557
- lacc->parent_phases.hold(obj);
1558
+ lacc->parent_phases.hold(obj, type);
1559
}
1560
1561
env->fcsr0_mask = FCSR0_M1 | FCSR0_M2 | FCSR0_M3;
1562
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
1563
index XXXXXXX..XXXXXXX 100644
1564
--- a/target/m68k/cpu.c
1565
+++ b/target/m68k/cpu.c
1566
@@ -XXX,XX +XXX,XX @@ static void m68k_unset_feature(CPUM68KState *env, int feature)
1567
env->features &= ~BIT_ULL(feature);
1568
}
1569
1570
-static void m68k_cpu_reset_hold(Object *obj)
1571
+static void m68k_cpu_reset_hold(Object *obj, ResetType type)
1572
{
1573
CPUState *cs = CPU(obj);
1574
M68kCPUClass *mcc = M68K_CPU_GET_CLASS(obj);
1575
@@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj)
1576
int i;
1577
1578
if (mcc->parent_phases.hold) {
1579
- mcc->parent_phases.hold(obj);
1580
+ mcc->parent_phases.hold(obj, type);
1581
}
1582
1583
memset(env, 0, offsetof(CPUM68KState, end_reset_fields));
1584
diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
1585
index XXXXXXX..XXXXXXX 100644
1586
--- a/target/microblaze/cpu.c
1587
+++ b/target/microblaze/cpu.c
1588
@@ -XXX,XX +XXX,XX @@ static void microblaze_cpu_set_irq(void *opaque, int irq, int level)
1589
}
1590
#endif
1591
1592
-static void mb_cpu_reset_hold(Object *obj)
1593
+static void mb_cpu_reset_hold(Object *obj, ResetType type)
1594
{
1595
CPUState *cs = CPU(obj);
1596
MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
1597
@@ -XXX,XX +XXX,XX @@ static void mb_cpu_reset_hold(Object *obj)
1598
CPUMBState *env = &cpu->env;
1599
1600
if (mcc->parent_phases.hold) {
1601
- mcc->parent_phases.hold(obj);
1602
+ mcc->parent_phases.hold(obj, type);
1603
}
1604
1605
memset(env, 0, offsetof(CPUMBState, end_reset_fields));
1606
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
1607
index XXXXXXX..XXXXXXX 100644
1608
--- a/target/mips/cpu.c
1609
+++ b/target/mips/cpu.c
1610
@@ -XXX,XX +XXX,XX @@ static int mips_cpu_mmu_index(CPUState *cs, bool ifunc)
1611
1612
#include "cpu-defs.c.inc"
1613
1614
-static void mips_cpu_reset_hold(Object *obj)
1615
+static void mips_cpu_reset_hold(Object *obj, ResetType type)
1616
{
1617
CPUState *cs = CPU(obj);
1618
MIPSCPU *cpu = MIPS_CPU(cs);
1619
@@ -XXX,XX +XXX,XX @@ static void mips_cpu_reset_hold(Object *obj)
1620
CPUMIPSState *env = &cpu->env;
1621
1622
if (mcc->parent_phases.hold) {
1623
- mcc->parent_phases.hold(obj);
1624
+ mcc->parent_phases.hold(obj, type);
1625
}
1626
1627
memset(env, 0, offsetof(CPUMIPSState, end_reset_fields));
1628
diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c
1629
index XXXXXXX..XXXXXXX 100644
1630
--- a/target/openrisc/cpu.c
1631
+++ b/target/openrisc/cpu.c
1632
@@ -XXX,XX +XXX,XX @@ static void openrisc_disas_set_info(CPUState *cpu, disassemble_info *info)
1633
info->print_insn = print_insn_or1k;
1634
}
1635
1636
-static void openrisc_cpu_reset_hold(Object *obj)
1637
+static void openrisc_cpu_reset_hold(Object *obj, ResetType type)
1638
{
1639
CPUState *cs = CPU(obj);
1640
OpenRISCCPU *cpu = OPENRISC_CPU(cs);
1641
OpenRISCCPUClass *occ = OPENRISC_CPU_GET_CLASS(obj);
1642
1643
if (occ->parent_phases.hold) {
1644
- occ->parent_phases.hold(obj);
1645
+ occ->parent_phases.hold(obj, type);
1646
}
1647
1648
memset(&cpu->env, 0, offsetof(CPUOpenRISCState, end_reset_fields));
1649
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
1650
index XXXXXXX..XXXXXXX 100644
1651
--- a/target/ppc/cpu_init.c
1652
+++ b/target/ppc/cpu_init.c
1653
@@ -XXX,XX +XXX,XX @@ static int ppc_cpu_mmu_index(CPUState *cs, bool ifetch)
1654
return ppc_env_mmu_index(cpu_env(cs), ifetch);
1655
}
1656
1657
-static void ppc_cpu_reset_hold(Object *obj)
1658
+static void ppc_cpu_reset_hold(Object *obj, ResetType type)
1659
{
1660
CPUState *cs = CPU(obj);
1661
PowerPCCPU *cpu = POWERPC_CPU(cs);
1662
@@ -XXX,XX +XXX,XX @@ static void ppc_cpu_reset_hold(Object *obj)
1663
int i;
1664
1665
if (pcc->parent_phases.hold) {
1666
- pcc->parent_phases.hold(obj);
1667
+ pcc->parent_phases.hold(obj, type);
1668
}
1669
1670
msr = (target_ulong)0;
1671
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
1672
index XXXXXXX..XXXXXXX 100644
1673
--- a/target/riscv/cpu.c
1674
+++ b/target/riscv/cpu.c
1675
@@ -XXX,XX +XXX,XX @@ static int riscv_cpu_mmu_index(CPUState *cs, bool ifetch)
1676
return riscv_env_mmu_index(cpu_env(cs), ifetch);
1677
}
1678
1679
-static void riscv_cpu_reset_hold(Object *obj)
1680
+static void riscv_cpu_reset_hold(Object *obj, ResetType type)
1681
{
1682
#ifndef CONFIG_USER_ONLY
1683
uint8_t iprio;
1684
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset_hold(Object *obj)
1685
CPURISCVState *env = &cpu->env;
1686
1687
if (mcc->parent_phases.hold) {
1688
- mcc->parent_phases.hold(obj);
1689
+ mcc->parent_phases.hold(obj, type);
1690
}
1691
#ifndef CONFIG_USER_ONLY
1692
env->misa_mxl = mcc->misa_mxl_max;
1693
diff --git a/target/rx/cpu.c b/target/rx/cpu.c
1694
index XXXXXXX..XXXXXXX 100644
1695
--- a/target/rx/cpu.c
1696
+++ b/target/rx/cpu.c
1697
@@ -XXX,XX +XXX,XX @@ static int riscv_cpu_mmu_index(CPUState *cs, bool ifunc)
1698
return 0;
1699
}
1700
1701
-static void rx_cpu_reset_hold(Object *obj)
1702
+static void rx_cpu_reset_hold(Object *obj, ResetType type)
1703
{
1704
CPUState *cs = CPU(obj);
1705
RXCPUClass *rcc = RX_CPU_GET_CLASS(obj);
1706
@@ -XXX,XX +XXX,XX @@ static void rx_cpu_reset_hold(Object *obj)
1707
uint32_t *resetvec;
1708
1709
if (rcc->parent_phases.hold) {
1710
- rcc->parent_phases.hold(obj);
1711
+ rcc->parent_phases.hold(obj, type);
1712
}
1713
1714
memset(env, 0, offsetof(CPURXState, end_reset_fields));
1715
diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
1716
index XXXXXXX..XXXXXXX 100644
1717
--- a/target/sh4/cpu.c
1718
+++ b/target/sh4/cpu.c
1719
@@ -XXX,XX +XXX,XX @@ static int sh4_cpu_mmu_index(CPUState *cs, bool ifetch)
1720
}
1721
}
1722
1723
-static void superh_cpu_reset_hold(Object *obj)
1724
+static void superh_cpu_reset_hold(Object *obj, ResetType type)
1725
{
1726
CPUState *cs = CPU(obj);
1727
SuperHCPUClass *scc = SUPERH_CPU_GET_CLASS(obj);
1728
CPUSH4State *env = cpu_env(cs);
1729
1730
if (scc->parent_phases.hold) {
1731
- scc->parent_phases.hold(obj);
1732
+ scc->parent_phases.hold(obj, type);
1733
}
1734
1735
memset(env, 0, offsetof(CPUSH4State, end_reset_fields));
1736
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
1737
index XXXXXXX..XXXXXXX 100644
1738
--- a/target/sparc/cpu.c
1739
+++ b/target/sparc/cpu.c
1740
@@ -XXX,XX +XXX,XX @@
1741
1742
//#define DEBUG_FEATURES
1743
1744
-static void sparc_cpu_reset_hold(Object *obj)
1745
+static void sparc_cpu_reset_hold(Object *obj, ResetType type)
1746
{
1747
CPUState *cs = CPU(obj);
1748
SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(obj);
1749
CPUSPARCState *env = cpu_env(cs);
1750
1751
if (scc->parent_phases.hold) {
1752
- scc->parent_phases.hold(obj);
1753
+ scc->parent_phases.hold(obj, type);
1754
}
1755
1756
memset(env, 0, offsetof(CPUSPARCState, end_reset_fields));
1757
diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c
1758
index XXXXXXX..XXXXXXX 100644
1759
--- a/target/tricore/cpu.c
1760
+++ b/target/tricore/cpu.c
1761
@@ -XXX,XX +XXX,XX @@ static void tricore_restore_state_to_opc(CPUState *cs,
1762
cpu_env(cs)->PC = data[0];
1763
}
1764
1765
-static void tricore_cpu_reset_hold(Object *obj)
1766
+static void tricore_cpu_reset_hold(Object *obj, ResetType type)
1767
{
1768
CPUState *cs = CPU(obj);
1769
TriCoreCPUClass *tcc = TRICORE_CPU_GET_CLASS(obj);
1770
1771
if (tcc->parent_phases.hold) {
1772
- tcc->parent_phases.hold(obj);
1773
+ tcc->parent_phases.hold(obj, type);
1774
}
1775
1776
cpu_state_reset(cpu_env(cs));
1777
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
1778
index XXXXXXX..XXXXXXX 100644
1779
--- a/target/xtensa/cpu.c
1780
+++ b/target/xtensa/cpu.c
1781
@@ -XXX,XX +XXX,XX @@ bool xtensa_abi_call0(void)
1782
}
1783
#endif
1784
1785
-static void xtensa_cpu_reset_hold(Object *obj)
1786
+static void xtensa_cpu_reset_hold(Object *obj, ResetType type)
1787
{
1788
CPUState *cs = CPU(obj);
1789
XtensaCPUClass *xcc = XTENSA_CPU_GET_CLASS(obj);
1790
@@ -XXX,XX +XXX,XX @@ static void xtensa_cpu_reset_hold(Object *obj)
1791
XTENSA_OPTION_DFP_COPROCESSOR);
1792
1793
if (xcc->parent_phases.hold) {
1794
- xcc->parent_phases.hold(obj);
1795
+ xcc->parent_phases.hold(obj, type);
1796
}
1797
1798
env->pc = env->config->exception_vector[EXC_RESET0 + env->static_vectors];
191
--
1799
--
192
2.20.1
1800
2.34.1
193
194
diff view generated by jsdifflib
1
Convert the V[US]DOT (vector) insns to decodetree.
1
Update the reset documentation's example code to match the new API
2
for the hold and exit phase method APIs where they take a ResetType
3
argument.
2
4
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20200430181003.21682-7-peter.maydell@linaro.org
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Luc Michel <luc.michel@amd.com>
9
Message-id: 20240412160809.1260625-6-peter.maydell@linaro.org
6
---
10
---
7
target/arm/neon-shared.decode | 4 ++++
11
docs/devel/reset.rst | 8 ++++----
8
target/arm/translate-neon.inc.c | 32 ++++++++++++++++++++++++++++++++
12
1 file changed, 4 insertions(+), 4 deletions(-)
9
target/arm/translate.c | 9 +--------
10
3 files changed, 37 insertions(+), 8 deletions(-)
11
13
12
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
14
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
13
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/neon-shared.decode
16
--- a/docs/devel/reset.rst
15
+++ b/target/arm/neon-shared.decode
17
+++ b/docs/devel/reset.rst
16
@@ -XXX,XX +XXX,XX @@ VCMLA 1111 110 rot:2 . 1 size:1 .... .... 1000 . q:1 . 0 .... \
18
@@ -XXX,XX +XXX,XX @@ in reset.
17
19
mydev->var = 0;
18
VCADD 1111 110 rot:1 1 . 0 size:1 .... .... 1000 . q:1 . 0 .... \
20
}
19
vm=%vm_dp vn=%vn_dp vd=%vd_dp
21
20
+
22
- static void mydev_reset_hold(Object *obj)
21
+# VUDOT and VSDOT
23
+ static void mydev_reset_hold(Object *obj, ResetType type)
22
+VDOT 1111 110 00 . 10 .... .... 1101 . q:1 . u:1 .... \
24
{
23
+ vm=%vm_dp vn=%vn_dp vd=%vd_dp
25
MyDevClass *myclass = MYDEV_GET_CLASS(obj);
24
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
26
MyDevState *mydev = MYDEV(obj);
25
index XXXXXXX..XXXXXXX 100644
27
/* call parent class hold phase */
26
--- a/target/arm/translate-neon.inc.c
28
if (myclass->parent_phases.hold) {
27
+++ b/target/arm/translate-neon.inc.c
29
- myclass->parent_phases.hold(obj);
28
@@ -XXX,XX +XXX,XX @@ static bool trans_VCADD(DisasContext *s, arg_VCADD *a)
30
+ myclass->parent_phases.hold(obj, type);
29
tcg_temp_free_ptr(fpst);
31
}
30
return true;
32
/* set an IO */
31
}
33
qemu_set_irq(mydev->irq, 1);
32
+
34
}
33
+static bool trans_VDOT(DisasContext *s, arg_VDOT *a)
35
34
+{
36
- static void mydev_reset_exit(Object *obj)
35
+ int opr_sz;
37
+ static void mydev_reset_exit(Object *obj, ResetType type)
36
+ gen_helper_gvec_3 *fn_gvec;
38
{
37
+
39
MyDevClass *myclass = MYDEV_GET_CLASS(obj);
38
+ if (!dc_isar_feature(aa32_dp, s)) {
40
MyDevState *mydev = MYDEV(obj);
39
+ return false;
41
/* call parent class exit phase */
40
+ }
42
if (myclass->parent_phases.exit) {
41
+
43
- myclass->parent_phases.exit(obj);
42
+ /* UNDEF accesses to D16-D31 if they don't exist. */
44
+ myclass->parent_phases.exit(obj, type);
43
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
45
}
44
+ ((a->vd | a->vn | a->vm) & 0x10)) {
46
/* clear an IO */
45
+ return false;
47
qemu_set_irq(mydev->irq, 0);
46
+ }
47
+
48
+ if ((a->vn | a->vm | a->vd) & a->q) {
49
+ return false;
50
+ }
51
+
52
+ if (!vfp_access_check(s)) {
53
+ return true;
54
+ }
55
+
56
+ opr_sz = (1 + a->q) * 8;
57
+ fn_gvec = a->u ? gen_helper_gvec_udot_b : gen_helper_gvec_sdot_b;
58
+ tcg_gen_gvec_3_ool(vfp_reg_offset(1, a->vd),
59
+ vfp_reg_offset(1, a->vn),
60
+ vfp_reg_offset(1, a->vm),
61
+ opr_sz, opr_sz, 0, fn_gvec);
62
+ return true;
63
+}
64
diff --git a/target/arm/translate.c b/target/arm/translate.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/target/arm/translate.c
67
+++ b/target/arm/translate.c
68
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
69
bool is_long = false, q = extract32(insn, 6, 1);
70
bool ptr_is_env = false;
71
72
- if ((insn & 0xfeb00f00) == 0xfc200d00) {
73
- /* V[US]DOT -- 1111 1100 0.10 .... .... 1101 .Q.U .... */
74
- bool u = extract32(insn, 4, 1);
75
- if (!dc_isar_feature(aa32_dp, s)) {
76
- return 1;
77
- }
78
- fn_gvec = u ? gen_helper_gvec_udot_b : gen_helper_gvec_sdot_b;
79
- } else if ((insn & 0xff300f10) == 0xfc200810) {
80
+ if ((insn & 0xff300f10) == 0xfc200810) {
81
/* VFM[AS]L -- 1111 1100 S.10 .... .... 1000 .Q.1 .... */
82
int is_s = extract32(insn, 23, 1);
83
if (!dc_isar_feature(aa32_fhm, s)) {
84
--
48
--
85
2.20.1
49
2.34.1
86
50
87
51
diff view generated by jsdifflib
1
Convert VCMLA (scalar) in the 2reg-scalar-ext group to decodetree.
1
Some devices and machines need to handle the reset before a vmsave
2
snapshot is loaded differently -- the main user is the handling of
3
RNG seed information, which does not want to put a new RNG seed into
4
a ROM blob when we are doing a snapshot load.
5
6
Currently this kind of reset handling is supported only for:
7
* TYPE_MACHINE reset methods, which take a ShutdownCause argument
8
* reset functions registered with qemu_register_reset_nosnapshotload
9
10
To allow a three-phase-reset device to also distinguish "snapshot
11
load" reset from the normal kind, add a new ResetType
12
RESET_TYPE_SNAPSHOT_LOAD. All our existing reset methods ignore
13
the reset type, so we don't need to update any device code.
14
15
Add the enum type, and make qemu_devices_reset() use the
16
right reset type for the ShutdownCause it is passed. This
17
allows us to get rid of the device_reset_reason global we
18
were using to implement qemu_register_reset_nosnapshotload().
2
19
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20200430181003.21682-9-peter.maydell@linaro.org
22
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
23
Reviewed-by: Luc Michel <luc.michel@amd.com>
24
Message-id: 20240412160809.1260625-7-peter.maydell@linaro.org
6
---
25
---
7
target/arm/neon-shared.decode | 5 +++++
26
docs/devel/reset.rst | 17 ++++++++++++++---
8
target/arm/translate-neon.inc.c | 40 +++++++++++++++++++++++++++++++++
27
include/hw/resettable.h | 1 +
9
target/arm/translate.c | 26 +--------------------
28
hw/core/reset.c | 15 ++++-----------
10
3 files changed, 46 insertions(+), 25 deletions(-)
29
hw/core/resettable.c | 4 ----
30
4 files changed, 19 insertions(+), 18 deletions(-)
11
31
12
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
32
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
13
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/neon-shared.decode
34
--- a/docs/devel/reset.rst
15
+++ b/target/arm/neon-shared.decode
35
+++ b/docs/devel/reset.rst
16
@@ -XXX,XX +XXX,XX @@ VFML 1111 110 0 s:1 . 10 .... .... 1000 . 0 . 1 .... \
36
@@ -XXX,XX +XXX,XX @@ instantly reset an object, without keeping it in reset state, just call
17
vm=%vm_sp vn=%vn_sp vd=%vd_dp q=0
37
``resettable_reset()``. These functions take two parameters: a pointer to the
18
VFML 1111 110 0 s:1 . 10 .... .... 1000 . 1 . 1 .... \
38
object to reset and a reset type.
19
vm=%vm_dp vn=%vn_dp vd=%vd_dp q=1
39
40
-Several types of reset will be supported. For now only cold reset is defined;
41
-others may be added later. The Resettable interface handles reset types with an
42
-enum:
43
+The Resettable interface handles reset types with an enum ``ResetType``:
44
45
``RESET_TYPE_COLD``
46
Cold reset is supported by every resettable object. In QEMU, it means we reset
47
@@ -XXX,XX +XXX,XX @@ enum:
48
from what is a real hardware cold reset. It differs from other resets (like
49
warm or bus resets) which may keep certain parts untouched.
50
51
+``RESET_TYPE_SNAPSHOT_LOAD``
52
+ This is called for a reset which is being done to put the system into a
53
+ clean state prior to loading a snapshot. (This corresponds to a reset
54
+ with ``SHUTDOWN_CAUSE_SNAPSHOT_LOAD``.) Almost all devices should treat
55
+ this the same as ``RESET_TYPE_COLD``. The main exception is devices which
56
+ have some non-deterministic state they want to reinitialize to a different
57
+ value on each cold reset, such as RNG seed information, and which they
58
+ must not reinitialize on a snapshot-load reset.
20
+
59
+
21
+VCMLA_scalar 1111 1110 0 . rot:2 .... .... 1000 . q:1 index:1 0 vm:4 \
60
+Devices which implement reset methods must treat any unknown ``ResetType``
22
+ vn=%vn_dp vd=%vd_dp size=0
61
+as equivalent to ``RESET_TYPE_COLD``; this will reduce the amount of
23
+VCMLA_scalar 1111 1110 1 . rot:2 .... .... 1000 . q:1 . 0 .... \
62
+existing code we need to change if we add more types in future.
24
+ vm=%vm_dp vn=%vn_dp vd=%vd_dp size=1 index=0
63
+
25
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
64
Calling ``resettable_reset()`` is equivalent to calling
65
``resettable_assert_reset()`` then ``resettable_release_reset()``. It is
66
possible to interleave multiple calls to these three functions. There may
67
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
26
index XXXXXXX..XXXXXXX 100644
68
index XXXXXXX..XXXXXXX 100644
27
--- a/target/arm/translate-neon.inc.c
69
--- a/include/hw/resettable.h
28
+++ b/target/arm/translate-neon.inc.c
70
+++ b/include/hw/resettable.h
29
@@ -XXX,XX +XXX,XX @@ static bool trans_VFML(DisasContext *s, arg_VFML *a)
71
@@ -XXX,XX +XXX,XX @@ typedef struct ResettableState ResettableState;
30
gen_helper_gvec_fmlal_a32);
72
*/
31
return true;
73
typedef enum ResetType {
74
RESET_TYPE_COLD,
75
+ RESET_TYPE_SNAPSHOT_LOAD,
76
} ResetType;
77
78
/*
79
diff --git a/hw/core/reset.c b/hw/core/reset.c
80
index XXXXXXX..XXXXXXX 100644
81
--- a/hw/core/reset.c
82
+++ b/hw/core/reset.c
83
@@ -XXX,XX +XXX,XX @@ static ResettableContainer *get_root_reset_container(void)
84
return root_reset_container;
32
}
85
}
33
+
86
34
+static bool trans_VCMLA_scalar(DisasContext *s, arg_VCMLA_scalar *a)
87
-/*
35
+{
88
- * Reason why the currently in-progress qemu_devices_reset() was called.
36
+ gen_helper_gvec_3_ptr *fn_gvec_ptr;
89
- * If we made at least SHUTDOWN_CAUSE_SNAPSHOT_LOAD have a corresponding
37
+ int opr_sz;
90
- * ResetType we could perhaps avoid the need for this global.
38
+ TCGv_ptr fpst;
91
- */
39
+
92
-static ShutdownCause device_reset_reason;
40
+ if (!dc_isar_feature(aa32_vcma, s)) {
93
-
41
+ return false;
94
/*
42
+ }
95
* This is an Object which implements Resettable simply to call the
43
+ if (a->size == 0 && !dc_isar_feature(aa32_fp16_arith, s)) {
96
* callback function in the hold phase.
44
+ return false;
97
@@ -XXX,XX +XXX,XX @@ static void legacy_reset_hold(Object *obj, ResetType type)
45
+ }
98
{
46
+
99
LegacyReset *lr = LEGACY_RESET(obj);
47
+ /* UNDEF accesses to D16-D31 if they don't exist. */
100
48
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
101
- if (device_reset_reason == SHUTDOWN_CAUSE_SNAPSHOT_LOAD &&
49
+ ((a->vd | a->vn | a->vm) & 0x10)) {
102
- lr->skip_on_snapshot_load) {
50
+ return false;
103
+ if (type == RESET_TYPE_SNAPSHOT_LOAD && lr->skip_on_snapshot_load) {
51
+ }
104
return;
52
+
105
}
53
+ if ((a->vd | a->vn) & a->q) {
106
lr->func(lr->opaque);
54
+ return false;
107
@@ -XXX,XX +XXX,XX @@ void qemu_unregister_resettable(Object *obj)
55
+ }
108
56
+
109
void qemu_devices_reset(ShutdownCause reason)
57
+ if (!vfp_access_check(s)) {
110
{
58
+ return true;
111
- device_reset_reason = reason;
59
+ }
112
+ ResetType type = (reason == SHUTDOWN_CAUSE_SNAPSHOT_LOAD) ?
60
+
113
+ RESET_TYPE_SNAPSHOT_LOAD : RESET_TYPE_COLD;
61
+ fn_gvec_ptr = (a->size ? gen_helper_gvec_fcmlas_idx
114
62
+ : gen_helper_gvec_fcmlah_idx);
115
/* Reset the simulation */
63
+ opr_sz = (1 + a->q) * 8;
116
- resettable_reset(OBJECT(get_root_reset_container()), RESET_TYPE_COLD);
64
+ fpst = get_fpstatus_ptr(1);
117
+ resettable_reset(OBJECT(get_root_reset_container()), type);
65
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd),
118
}
66
+ vfp_reg_offset(1, a->vn),
119
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
67
+ vfp_reg_offset(1, a->vm),
68
+ fpst, opr_sz, opr_sz,
69
+ (a->index << 2) | a->rot, fn_gvec_ptr);
70
+ tcg_temp_free_ptr(fpst);
71
+ return true;
72
+}
73
diff --git a/target/arm/translate.c b/target/arm/translate.c
74
index XXXXXXX..XXXXXXX 100644
120
index XXXXXXX..XXXXXXX 100644
75
--- a/target/arm/translate.c
121
--- a/hw/core/resettable.c
76
+++ b/target/arm/translate.c
122
+++ b/hw/core/resettable.c
77
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
123
@@ -XXX,XX +XXX,XX @@ void resettable_reset(Object *obj, ResetType type)
78
bool is_long = false, q = extract32(insn, 6, 1);
124
79
bool ptr_is_env = false;
125
void resettable_assert_reset(Object *obj, ResetType type)
80
126
{
81
- if ((insn & 0xff000f10) == 0xfe000800) {
127
- /* TODO: change this assert when adding support for other reset types */
82
- /* VCMLA (indexed) -- 1111 1110 S.RR .... .... 1000 ...0 .... */
128
- assert(type == RESET_TYPE_COLD);
83
- int rot = extract32(insn, 20, 2);
129
trace_resettable_reset_assert_begin(obj, type);
84
- int size = extract32(insn, 23, 1);
130
assert(!enter_phase_in_progress);
85
- int index;
131
86
-
132
@@ -XXX,XX +XXX,XX @@ void resettable_assert_reset(Object *obj, ResetType type)
87
- if (!dc_isar_feature(aa32_vcma, s)) {
133
88
- return 1;
134
void resettable_release_reset(Object *obj, ResetType type)
89
- }
135
{
90
- if (size == 0) {
136
- /* TODO: change this assert when adding support for other reset types */
91
- if (!dc_isar_feature(aa32_fp16_arith, s)) {
137
- assert(type == RESET_TYPE_COLD);
92
- return 1;
138
trace_resettable_reset_release_begin(obj, type);
93
- }
139
assert(!enter_phase_in_progress);
94
- /* For fp16, rm is just Vm, and index is M. */
95
- rm = extract32(insn, 0, 4);
96
- index = extract32(insn, 5, 1);
97
- } else {
98
- /* For fp32, rm is the usual M:Vm, and index is 0. */
99
- VFP_DREG_M(rm, insn);
100
- index = 0;
101
- }
102
- data = (index << 2) | rot;
103
- fn_gvec_ptr = (size ? gen_helper_gvec_fcmlas_idx
104
- : gen_helper_gvec_fcmlah_idx);
105
- } else if ((insn & 0xffb00f00) == 0xfe200d00) {
106
+ if ((insn & 0xffb00f00) == 0xfe200d00) {
107
/* V[US]DOT -- 1111 1110 0.10 .... .... 1101 .Q.U .... */
108
int u = extract32(insn, 4, 1);
109
140
110
--
141
--
111
2.20.1
142
2.34.1
112
143
113
144
diff view generated by jsdifflib
1
Add the infrastructure for building and invoking a decodetree decoder
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
for the AArch32 Neon encodings. At the moment the new decoder covers
3
nothing, so we always fall back to the existing hand-written decode.
4
2
5
We follow the same pattern we did for the VFP decodetree conversion
3
Add the basic infrastructure (register read/write, type...)
6
(commit 78e138bc1f672c145ef6ace74617d and following): code that deals
4
to implement the STM32L4x5 USART.
7
with Neon will be moving gradually out to translate-neon.vfp.inc,
8
which we #include into translate.c.
9
5
10
In order to share the decode files between A32 and T32, we
6
Also create different types for the USART, UART and LPUART
11
split Neon into 3 parts:
7
of the STM32L4x5 to deduplicate code and enable the
12
* data-processing
8
implementation of different behaviors depending on the type.
13
* load-store
14
* 'shared' encodings
15
9
16
The first two groups of instructions have similar but not identical
10
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
17
A32 and T32 encodings, so we need to manually transform the T32
11
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
18
encoding into the A32 one before calling the decoder; the third group
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
covers the Neon instructions which are identical in A32 and T32.
13
Message-id: 20240329174402.60382-2-arnaud.minier@telecom-paris.fr
14
[PMM: update to new reset hold method signature;
15
fixed a few checkpatch nits]
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
18
MAINTAINERS | 1 +
19
include/hw/char/stm32l4x5_usart.h | 66 +++++
20
hw/char/stm32l4x5_usart.c | 396 ++++++++++++++++++++++++++++++
21
hw/char/Kconfig | 3 +
22
hw/char/meson.build | 1 +
23
hw/char/trace-events | 4 +
24
6 files changed, 471 insertions(+)
25
create mode 100644 include/hw/char/stm32l4x5_usart.h
26
create mode 100644 hw/char/stm32l4x5_usart.c
20
27
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
diff --git a/MAINTAINERS b/MAINTAINERS
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
29
index XXXXXXX..XXXXXXX 100644
23
Message-id: 20200430181003.21682-4-peter.maydell@linaro.org
30
--- a/MAINTAINERS
24
---
31
+++ b/MAINTAINERS
25
target/arm/neon-dp.decode | 29 ++++++++++++++++++++++++++
32
@@ -XXX,XX +XXX,XX @@ M: Inès Varhol <ines.varhol@telecom-paris.fr>
26
target/arm/neon-ls.decode | 29 ++++++++++++++++++++++++++
33
L: qemu-arm@nongnu.org
27
target/arm/neon-shared.decode | 27 +++++++++++++++++++++++++
34
S: Maintained
28
target/arm/translate-neon.inc.c | 32 +++++++++++++++++++++++++++++
35
F: hw/arm/stm32l4x5_soc.c
29
target/arm/translate.c | 36 +++++++++++++++++++++++++++++++--
36
+F: hw/char/stm32l4x5_usart.c
30
target/arm/Makefile.objs | 18 +++++++++++++++++
37
F: hw/misc/stm32l4x5_exti.c
31
6 files changed, 169 insertions(+), 2 deletions(-)
38
F: hw/misc/stm32l4x5_syscfg.c
32
create mode 100644 target/arm/neon-dp.decode
39
F: hw/misc/stm32l4x5_rcc.c
33
create mode 100644 target/arm/neon-ls.decode
40
diff --git a/include/hw/char/stm32l4x5_usart.h b/include/hw/char/stm32l4x5_usart.h
34
create mode 100644 target/arm/neon-shared.decode
35
create mode 100644 target/arm/translate-neon.inc.c
36
37
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
38
new file mode 100644
41
new file mode 100644
39
index XXXXXXX..XXXXXXX
42
index XXXXXXX..XXXXXXX
40
--- /dev/null
43
--- /dev/null
41
+++ b/target/arm/neon-dp.decode
44
+++ b/include/hw/char/stm32l4x5_usart.h
42
@@ -XXX,XX +XXX,XX @@
45
@@ -XXX,XX +XXX,XX @@
43
+# AArch32 Neon data-processing instruction descriptions
46
+/*
44
+#
47
+ * STM32L4X5 USART (Universal Synchronous Asynchronous Receiver Transmitter)
45
+# Copyright (c) 2020 Linaro, Ltd
48
+ *
46
+#
49
+ * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
47
+# This library is free software; you can redistribute it and/or
50
+ * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
48
+# modify it under the terms of the GNU Lesser General Public
51
+ *
49
+# License as published by the Free Software Foundation; either
52
+ * SPDX-License-Identifier: GPL-2.0-or-later
50
+# version 2 of the License, or (at your option) any later version.
53
+ *
51
+#
54
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
52
+# This library is distributed in the hope that it will be useful,
55
+ * See the COPYING file in the top-level directory.
53
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
56
+ *
54
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
57
+ * The STM32L4X5 USART is heavily inspired by the stm32f2xx_usart
55
+# Lesser General Public License for more details.
58
+ * by Alistair Francis.
56
+#
59
+ * The reference used is the STMicroElectronics RM0351 Reference manual
57
+# You should have received a copy of the GNU Lesser General Public
60
+ * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs.
58
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
61
+ */
59
+
62
+
60
+#
63
+#ifndef HW_STM32L4X5_USART_H
61
+# This file is processed by scripts/decodetree.py
64
+#define HW_STM32L4X5_USART_H
62
+#
65
+
63
+
66
+#include "hw/sysbus.h"
64
+# Encodings for Neon data processing instructions where the T32 encoding
67
+#include "chardev/char-fe.h"
65
+# is a simple transformation of the A32 encoding.
68
+#include "qom/object.h"
66
+# More specifically, this file covers instructions where the A32 encoding is
69
+
67
+# 0b1111_001p_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq
70
+#define TYPE_STM32L4X5_USART_BASE "stm32l4x5-usart-base"
68
+# and the T32 encoding is
71
+#define TYPE_STM32L4X5_USART "stm32l4x5-usart"
69
+# 0b111p_1111_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq
72
+#define TYPE_STM32L4X5_UART "stm32l4x5-uart"
70
+# This file works on the A32 encoding only; calling code for T32 has to
73
+#define TYPE_STM32L4X5_LPUART "stm32l4x5-lpuart"
71
+# transform the insn into the A32 version first.
74
+OBJECT_DECLARE_TYPE(Stm32l4x5UsartBaseState, Stm32l4x5UsartBaseClass,
72
diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode
75
+ STM32L4X5_USART_BASE)
76
+
77
+typedef enum {
78
+ STM32L4x5_USART,
79
+ STM32L4x5_UART,
80
+ STM32L4x5_LPUART,
81
+} Stm32l4x5UsartType;
82
+
83
+struct Stm32l4x5UsartBaseState {
84
+ SysBusDevice parent_obj;
85
+
86
+ MemoryRegion mmio;
87
+
88
+ uint32_t cr1;
89
+ uint32_t cr2;
90
+ uint32_t cr3;
91
+ uint32_t brr;
92
+ uint32_t gtpr;
93
+ uint32_t rtor;
94
+ /* rqr is write-only */
95
+ uint32_t isr;
96
+ /* icr is a clear register */
97
+ uint32_t rdr;
98
+ uint32_t tdr;
99
+
100
+ Clock *clk;
101
+ CharBackend chr;
102
+ qemu_irq irq;
103
+};
104
+
105
+struct Stm32l4x5UsartBaseClass {
106
+ SysBusDeviceClass parent_class;
107
+
108
+ Stm32l4x5UsartType type;
109
+};
110
+
111
+#endif /* HW_STM32L4X5_USART_H */
112
diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c
73
new file mode 100644
113
new file mode 100644
74
index XXXXXXX..XXXXXXX
114
index XXXXXXX..XXXXXXX
75
--- /dev/null
115
--- /dev/null
76
+++ b/target/arm/neon-ls.decode
116
+++ b/hw/char/stm32l4x5_usart.c
77
@@ -XXX,XX +XXX,XX @@
78
+# AArch32 Neon load/store instruction descriptions
79
+#
80
+# Copyright (c) 2020 Linaro, Ltd
81
+#
82
+# This library is free software; you can redistribute it and/or
83
+# modify it under the terms of the GNU Lesser General Public
84
+# License as published by the Free Software Foundation; either
85
+# version 2 of the License, or (at your option) any later version.
86
+#
87
+# This library is distributed in the hope that it will be useful,
88
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
89
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
90
+# Lesser General Public License for more details.
91
+#
92
+# You should have received a copy of the GNU Lesser General Public
93
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
94
+
95
+#
96
+# This file is processed by scripts/decodetree.py
97
+#
98
+
99
+# Encodings for Neon load/store instructions where the T32 encoding
100
+# is a simple transformation of the A32 encoding.
101
+# More specifically, this file covers instructions where the A32 encoding is
102
+# 0b1111_0100_xxx0_xxxx_xxxx_xxxx_xxxx_xxxx
103
+# and the T32 encoding is
104
+# 0b1111_1001_xxx0_xxxx_xxxx_xxxx_xxxx_xxxx
105
+# This file works on the A32 encoding only; calling code for T32 has to
106
+# transform the insn into the A32 version first.
107
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
108
new file mode 100644
109
index XXXXXXX..XXXXXXX
110
--- /dev/null
111
+++ b/target/arm/neon-shared.decode
112
@@ -XXX,XX +XXX,XX @@
113
+# AArch32 Neon instruction descriptions
114
+#
115
+# Copyright (c) 2020 Linaro, Ltd
116
+#
117
+# This library is free software; you can redistribute it and/or
118
+# modify it under the terms of the GNU Lesser General Public
119
+# License as published by the Free Software Foundation; either
120
+# version 2 of the License, or (at your option) any later version.
121
+#
122
+# This library is distributed in the hope that it will be useful,
123
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
124
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
125
+# Lesser General Public License for more details.
126
+#
127
+# You should have received a copy of the GNU Lesser General Public
128
+# License along with this library; if not, see <http://www.gnu.org/licenses/>.
129
+
130
+#
131
+# This file is processed by scripts/decodetree.py
132
+#
133
+
134
+# Encodings for Neon instructions whose encoding is the same for
135
+# both A32 and T32.
136
+
137
+# More specifically, this covers:
138
+# 2reg scalar ext: 0b1111_1110_xxxx_xxxx_xxxx_1x0x_xxxx_xxxx
139
+# 3same ext: 0b1111_110x_xxxx_xxxx_xxxx_1x0x_xxxx_xxxx
140
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
141
new file mode 100644
142
index XXXXXXX..XXXXXXX
143
--- /dev/null
144
+++ b/target/arm/translate-neon.inc.c
145
@@ -XXX,XX +XXX,XX @@
117
@@ -XXX,XX +XXX,XX @@
146
+/*
118
+/*
147
+ * ARM translation: AArch32 Neon instructions
119
+ * STM32L4X5 USART (Universal Synchronous Asynchronous Receiver Transmitter)
148
+ *
120
+ *
149
+ * Copyright (c) 2003 Fabrice Bellard
121
+ * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
150
+ * Copyright (c) 2005-2007 CodeSourcery
122
+ * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
151
+ * Copyright (c) 2007 OpenedHand, Ltd.
123
+ *
152
+ * Copyright (c) 2020 Linaro, Ltd.
124
+ * SPDX-License-Identifier: GPL-2.0-or-later
153
+ *
125
+ *
154
+ * This library is free software; you can redistribute it and/or
126
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
155
+ * modify it under the terms of the GNU Lesser General Public
127
+ * See the COPYING file in the top-level directory.
156
+ * License as published by the Free Software Foundation; either
128
+ *
157
+ * version 2 of the License, or (at your option) any later version.
129
+ * The STM32L4X5 USART is heavily inspired by the stm32f2xx_usart
158
+ *
130
+ * by Alistair Francis.
159
+ * This library is distributed in the hope that it will be useful,
131
+ * The reference used is the STMicroElectronics RM0351 Reference manual
160
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
132
+ * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs.
161
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
162
+ * Lesser General Public License for more details.
163
+ *
164
+ * You should have received a copy of the GNU Lesser General Public
165
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
166
+ */
133
+ */
167
+
134
+
168
+/*
135
+#include "qemu/osdep.h"
169
+ * This file is intended to be included from translate.c; it uses
136
+#include "qemu/log.h"
170
+ * some macros and definitions provided by that file.
137
+#include "qemu/module.h"
171
+ * It might be possible to convert it to a standalone .c file eventually.
138
+#include "qapi/error.h"
172
+ */
139
+#include "chardev/char-fe.h"
173
+
140
+#include "chardev/char-serial.h"
174
+/* Include the generated Neon decoder */
141
+#include "migration/vmstate.h"
175
+#include "decode-neon-dp.inc.c"
142
+#include "hw/char/stm32l4x5_usart.h"
176
+#include "decode-neon-ls.inc.c"
143
+#include "hw/clock.h"
177
+#include "decode-neon-shared.inc.c"
144
+#include "hw/irq.h"
178
diff --git a/target/arm/translate.c b/target/arm/translate.c
145
+#include "hw/qdev-clock.h"
146
+#include "hw/qdev-properties.h"
147
+#include "hw/qdev-properties-system.h"
148
+#include "hw/registerfields.h"
149
+#include "trace.h"
150
+
151
+
152
+REG32(CR1, 0x00)
153
+ FIELD(CR1, M1, 28, 1) /* Word length (part 2, see M0) */
154
+ FIELD(CR1, EOBIE, 27, 1) /* End of Block interrupt enable */
155
+ FIELD(CR1, RTOIE, 26, 1) /* Receiver timeout interrupt enable */
156
+ FIELD(CR1, DEAT, 21, 5) /* Driver Enable assertion time */
157
+ FIELD(CR1, DEDT, 16, 5) /* Driver Enable de-assertion time */
158
+ FIELD(CR1, OVER8, 15, 1) /* Oversampling mode */
159
+ FIELD(CR1, CMIE, 14, 1) /* Character match interrupt enable */
160
+ FIELD(CR1, MME, 13, 1) /* Mute mode enable */
161
+ FIELD(CR1, M0, 12, 1) /* Word length (part 1, see M1) */
162
+ FIELD(CR1, WAKE, 11, 1) /* Receiver wakeup method */
163
+ FIELD(CR1, PCE, 10, 1) /* Parity control enable */
164
+ FIELD(CR1, PS, 9, 1) /* Parity selection */
165
+ FIELD(CR1, PEIE, 8, 1) /* PE interrupt enable */
166
+ FIELD(CR1, TXEIE, 7, 1) /* TXE interrupt enable */
167
+ FIELD(CR1, TCIE, 6, 1) /* Transmission complete interrupt enable */
168
+ FIELD(CR1, RXNEIE, 5, 1) /* RXNE interrupt enable */
169
+ FIELD(CR1, IDLEIE, 4, 1) /* IDLE interrupt enable */
170
+ FIELD(CR1, TE, 3, 1) /* Transmitter enable */
171
+ FIELD(CR1, RE, 2, 1) /* Receiver enable */
172
+ FIELD(CR1, UESM, 1, 1) /* USART enable in Stop mode */
173
+ FIELD(CR1, UE, 0, 1) /* USART enable */
174
+REG32(CR2, 0x04)
175
+ FIELD(CR2, ADD_1, 28, 4) /* ADD[7:4] */
176
+ FIELD(CR2, ADD_0, 24, 1) /* ADD[3:0] */
177
+ FIELD(CR2, RTOEN, 23, 1) /* Receiver timeout enable */
178
+ FIELD(CR2, ABRMOD, 21, 2) /* Auto baud rate mode */
179
+ FIELD(CR2, ABREN, 20, 1) /* Auto baud rate enable */
180
+ FIELD(CR2, MSBFIRST, 19, 1) /* Most significant bit first */
181
+ FIELD(CR2, DATAINV, 18, 1) /* Binary data inversion */
182
+ FIELD(CR2, TXINV, 17, 1) /* TX pin active level inversion */
183
+ FIELD(CR2, RXINV, 16, 1) /* RX pin active level inversion */
184
+ FIELD(CR2, SWAP, 15, 1) /* Swap RX/TX pins */
185
+ FIELD(CR2, LINEN, 14, 1) /* LIN mode enable */
186
+ FIELD(CR2, STOP, 12, 2) /* STOP bits */
187
+ FIELD(CR2, CLKEN, 11, 1) /* Clock enable */
188
+ FIELD(CR2, CPOL, 10, 1) /* Clock polarity */
189
+ FIELD(CR2, CPHA, 9, 1) /* Clock phase */
190
+ FIELD(CR2, LBCL, 8, 1) /* Last bit clock pulse */
191
+ FIELD(CR2, LBDIE, 6, 1) /* LIN break detection interrupt enable */
192
+ FIELD(CR2, LBDL, 5, 1) /* LIN break detection length */
193
+ FIELD(CR2, ADDM7, 4, 1) /* 7-bit / 4-bit Address Detection */
194
+
195
+REG32(CR3, 0x08)
196
+ /* TCBGTIE only on STM32L496xx/4A6xx devices */
197
+ FIELD(CR3, UCESM, 23, 1) /* USART Clock Enable in Stop Mode */
198
+ FIELD(CR3, WUFIE, 22, 1) /* Wakeup from Stop mode interrupt enable */
199
+ FIELD(CR3, WUS, 20, 2) /* Wakeup from Stop mode interrupt flag selection */
200
+ FIELD(CR3, SCARCNT, 17, 3) /* Smartcard auto-retry count */
201
+ FIELD(CR3, DEP, 15, 1) /* Driver enable polarity selection */
202
+ FIELD(CR3, DEM, 14, 1) /* Driver enable mode */
203
+ FIELD(CR3, DDRE, 13, 1) /* DMA Disable on Reception Error */
204
+ FIELD(CR3, OVRDIS, 12, 1) /* Overrun Disable */
205
+ FIELD(CR3, ONEBIT, 11, 1) /* One sample bit method enable */
206
+ FIELD(CR3, CTSIE, 10, 1) /* CTS interrupt enable */
207
+ FIELD(CR3, CTSE, 9, 1) /* CTS enable */
208
+ FIELD(CR3, RTSE, 8, 1) /* RTS enable */
209
+ FIELD(CR3, DMAT, 7, 1) /* DMA enable transmitter */
210
+ FIELD(CR3, DMAR, 6, 1) /* DMA enable receiver */
211
+ FIELD(CR3, SCEN, 5, 1) /* Smartcard mode enable */
212
+ FIELD(CR3, NACK, 4, 1) /* Smartcard NACK enable */
213
+ FIELD(CR3, HDSEL, 3, 1) /* Half-duplex selection */
214
+ FIELD(CR3, IRLP, 2, 1) /* IrDA low-power */
215
+ FIELD(CR3, IREN, 1, 1) /* IrDA mode enable */
216
+ FIELD(CR3, EIE, 0, 1) /* Error interrupt enable */
217
+REG32(BRR, 0x0C)
218
+ FIELD(BRR, BRR, 0, 16)
219
+REG32(GTPR, 0x10)
220
+ FIELD(GTPR, GT, 8, 8) /* Guard time value */
221
+ FIELD(GTPR, PSC, 0, 8) /* Prescaler value */
222
+REG32(RTOR, 0x14)
223
+ FIELD(RTOR, BLEN, 24, 8) /* Block Length */
224
+ FIELD(RTOR, RTO, 0, 24) /* Receiver timeout value */
225
+REG32(RQR, 0x18)
226
+ FIELD(RQR, TXFRQ, 4, 1) /* Transmit data flush request */
227
+ FIELD(RQR, RXFRQ, 3, 1) /* Receive data flush request */
228
+ FIELD(RQR, MMRQ, 2, 1) /* Mute mode request */
229
+ FIELD(RQR, SBKRQ, 1, 1) /* Send break request */
230
+ FIELD(RQR, ABBRRQ, 0, 1) /* Auto baud rate request */
231
+REG32(ISR, 0x1C)
232
+ /* TCBGT only for STM32L475xx/476xx/486xx devices */
233
+ FIELD(ISR, REACK, 22, 1) /* Receive enable acknowledge flag */
234
+ FIELD(ISR, TEACK, 21, 1) /* Transmit enable acknowledge flag */
235
+ FIELD(ISR, WUF, 20, 1) /* Wakeup from Stop mode flag */
236
+ FIELD(ISR, RWU, 19, 1) /* Receiver wakeup from Mute mode */
237
+ FIELD(ISR, SBKF, 18, 1) /* Send break flag */
238
+ FIELD(ISR, CMF, 17, 1) /* Character match flag */
239
+ FIELD(ISR, BUSY, 16, 1) /* Busy flag */
240
+ FIELD(ISR, ABRF, 15, 1) /* Auto Baud rate flag */
241
+ FIELD(ISR, ABRE, 14, 1) /* Auto Baud rate error */
242
+ FIELD(ISR, EOBF, 12, 1) /* End of block flag */
243
+ FIELD(ISR, RTOF, 11, 1) /* Receiver timeout */
244
+ FIELD(ISR, CTS, 10, 1) /* CTS flag */
245
+ FIELD(ISR, CTSIF, 9, 1) /* CTS interrupt flag */
246
+ FIELD(ISR, LBDF, 8, 1) /* LIN break detection flag */
247
+ FIELD(ISR, TXE, 7, 1) /* Transmit data register empty */
248
+ FIELD(ISR, TC, 6, 1) /* Transmission complete */
249
+ FIELD(ISR, RXNE, 5, 1) /* Read data register not empty */
250
+ FIELD(ISR, IDLE, 4, 1) /* Idle line detected */
251
+ FIELD(ISR, ORE, 3, 1) /* Overrun error */
252
+ FIELD(ISR, NF, 2, 1) /* START bit Noise detection flag */
253
+ FIELD(ISR, FE, 1, 1) /* Framing Error */
254
+ FIELD(ISR, PE, 0, 1) /* Parity Error */
255
+REG32(ICR, 0x20)
256
+ FIELD(ICR, WUCF, 20, 1) /* Wakeup from Stop mode clear flag */
257
+ FIELD(ICR, CMCF, 17, 1) /* Character match clear flag */
258
+ FIELD(ICR, EOBCF, 12, 1) /* End of block clear flag */
259
+ FIELD(ICR, RTOCF, 11, 1) /* Receiver timeout clear flag */
260
+ FIELD(ICR, CTSCF, 9, 1) /* CTS clear flag */
261
+ FIELD(ICR, LBDCF, 8, 1) /* LIN break detection clear flag */
262
+ /* TCBGTCF only on STM32L496xx/4A6xx devices */
263
+ FIELD(ICR, TCCF, 6, 1) /* Transmission complete clear flag */
264
+ FIELD(ICR, IDLECF, 4, 1) /* Idle line detected clear flag */
265
+ FIELD(ICR, ORECF, 3, 1) /* Overrun error clear flag */
266
+ FIELD(ICR, NCF, 2, 1) /* Noise detected clear flag */
267
+ FIELD(ICR, FECF, 1, 1) /* Framing error clear flag */
268
+ FIELD(ICR, PECF, 0, 1) /* Parity error clear flag */
269
+REG32(RDR, 0x24)
270
+ FIELD(RDR, RDR, 0, 9)
271
+REG32(TDR, 0x28)
272
+ FIELD(TDR, TDR, 0, 9)
273
+
274
+static void stm32l4x5_usart_base_reset_hold(Object *obj, ResetType type)
275
+{
276
+ Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj);
277
+
278
+ s->cr1 = 0x00000000;
279
+ s->cr2 = 0x00000000;
280
+ s->cr3 = 0x00000000;
281
+ s->brr = 0x00000000;
282
+ s->gtpr = 0x00000000;
283
+ s->rtor = 0x00000000;
284
+ s->isr = 0x020000C0;
285
+ s->rdr = 0x00000000;
286
+ s->tdr = 0x00000000;
287
+}
288
+
289
+static uint64_t stm32l4x5_usart_base_read(void *opaque, hwaddr addr,
290
+ unsigned int size)
291
+{
292
+ Stm32l4x5UsartBaseState *s = opaque;
293
+ uint64_t retvalue = 0;
294
+
295
+ switch (addr) {
296
+ case A_CR1:
297
+ retvalue = s->cr1;
298
+ break;
299
+ case A_CR2:
300
+ retvalue = s->cr2;
301
+ break;
302
+ case A_CR3:
303
+ retvalue = s->cr3;
304
+ break;
305
+ case A_BRR:
306
+ retvalue = FIELD_EX32(s->brr, BRR, BRR);
307
+ break;
308
+ case A_GTPR:
309
+ retvalue = s->gtpr;
310
+ break;
311
+ case A_RTOR:
312
+ retvalue = s->rtor;
313
+ break;
314
+ case A_RQR:
315
+ /* RQR is a write only register */
316
+ retvalue = 0x00000000;
317
+ break;
318
+ case A_ISR:
319
+ retvalue = s->isr;
320
+ break;
321
+ case A_ICR:
322
+ /* ICR is a clear register */
323
+ retvalue = 0x00000000;
324
+ break;
325
+ case A_RDR:
326
+ retvalue = FIELD_EX32(s->rdr, RDR, RDR);
327
+ /* Reset RXNE flag */
328
+ s->isr &= ~R_ISR_RXNE_MASK;
329
+ break;
330
+ case A_TDR:
331
+ retvalue = FIELD_EX32(s->tdr, TDR, TDR);
332
+ break;
333
+ default:
334
+ qemu_log_mask(LOG_GUEST_ERROR,
335
+ "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr);
336
+ break;
337
+ }
338
+
339
+ trace_stm32l4x5_usart_read(addr, retvalue);
340
+
341
+ return retvalue;
342
+}
343
+
344
+static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
345
+ uint64_t val64, unsigned int size)
346
+{
347
+ Stm32l4x5UsartBaseState *s = opaque;
348
+ const uint32_t value = val64;
349
+
350
+ trace_stm32l4x5_usart_write(addr, value);
351
+
352
+ switch (addr) {
353
+ case A_CR1:
354
+ s->cr1 = value;
355
+ return;
356
+ case A_CR2:
357
+ s->cr2 = value;
358
+ return;
359
+ case A_CR3:
360
+ s->cr3 = value;
361
+ return;
362
+ case A_BRR:
363
+ s->brr = value;
364
+ return;
365
+ case A_GTPR:
366
+ s->gtpr = value;
367
+ return;
368
+ case A_RTOR:
369
+ s->rtor = value;
370
+ return;
371
+ case A_RQR:
372
+ return;
373
+ case A_ISR:
374
+ qemu_log_mask(LOG_GUEST_ERROR,
375
+ "%s: ISR is read only !\n", __func__);
376
+ return;
377
+ case A_ICR:
378
+ /* Clear the status flags */
379
+ s->isr &= ~value;
380
+ return;
381
+ case A_RDR:
382
+ qemu_log_mask(LOG_GUEST_ERROR,
383
+ "%s: RDR is read only !\n", __func__);
384
+ return;
385
+ case A_TDR:
386
+ s->tdr = value;
387
+ return;
388
+ default:
389
+ qemu_log_mask(LOG_GUEST_ERROR,
390
+ "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr);
391
+ }
392
+}
393
+
394
+static const MemoryRegionOps stm32l4x5_usart_base_ops = {
395
+ .read = stm32l4x5_usart_base_read,
396
+ .write = stm32l4x5_usart_base_write,
397
+ .endianness = DEVICE_NATIVE_ENDIAN,
398
+ .valid = {
399
+ .max_access_size = 4,
400
+ .min_access_size = 4,
401
+ .unaligned = false
402
+ },
403
+ .impl = {
404
+ .max_access_size = 4,
405
+ .min_access_size = 4,
406
+ .unaligned = false
407
+ },
408
+};
409
+
410
+static Property stm32l4x5_usart_base_properties[] = {
411
+ DEFINE_PROP_CHR("chardev", Stm32l4x5UsartBaseState, chr),
412
+ DEFINE_PROP_END_OF_LIST(),
413
+};
414
+
415
+static void stm32l4x5_usart_base_init(Object *obj)
416
+{
417
+ Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj);
418
+
419
+ sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq);
420
+
421
+ memory_region_init_io(&s->mmio, obj, &stm32l4x5_usart_base_ops, s,
422
+ TYPE_STM32L4X5_USART_BASE, 0x400);
423
+ sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio);
424
+
425
+ s->clk = qdev_init_clock_in(DEVICE(s), "clk", NULL, s, 0);
426
+}
427
+
428
+static const VMStateDescription vmstate_stm32l4x5_usart_base = {
429
+ .name = TYPE_STM32L4X5_USART_BASE,
430
+ .version_id = 1,
431
+ .minimum_version_id = 1,
432
+ .fields = (VMStateField[]) {
433
+ VMSTATE_UINT32(cr1, Stm32l4x5UsartBaseState),
434
+ VMSTATE_UINT32(cr2, Stm32l4x5UsartBaseState),
435
+ VMSTATE_UINT32(cr3, Stm32l4x5UsartBaseState),
436
+ VMSTATE_UINT32(brr, Stm32l4x5UsartBaseState),
437
+ VMSTATE_UINT32(gtpr, Stm32l4x5UsartBaseState),
438
+ VMSTATE_UINT32(rtor, Stm32l4x5UsartBaseState),
439
+ VMSTATE_UINT32(isr, Stm32l4x5UsartBaseState),
440
+ VMSTATE_UINT32(rdr, Stm32l4x5UsartBaseState),
441
+ VMSTATE_UINT32(tdr, Stm32l4x5UsartBaseState),
442
+ VMSTATE_CLOCK(clk, Stm32l4x5UsartBaseState),
443
+ VMSTATE_END_OF_LIST()
444
+ }
445
+};
446
+
447
+
448
+static void stm32l4x5_usart_base_realize(DeviceState *dev, Error **errp)
449
+{
450
+ ERRP_GUARD();
451
+ Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(dev);
452
+ if (!clock_has_source(s->clk)) {
453
+ error_setg(errp, "USART clock must be wired up by SoC code");
454
+ return;
455
+ }
456
+}
457
+
458
+static void stm32l4x5_usart_base_class_init(ObjectClass *klass, void *data)
459
+{
460
+ DeviceClass *dc = DEVICE_CLASS(klass);
461
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
462
+
463
+ rc->phases.hold = stm32l4x5_usart_base_reset_hold;
464
+ device_class_set_props(dc, stm32l4x5_usart_base_properties);
465
+ dc->realize = stm32l4x5_usart_base_realize;
466
+ dc->vmsd = &vmstate_stm32l4x5_usart_base;
467
+}
468
+
469
+static void stm32l4x5_usart_class_init(ObjectClass *oc, void *data)
470
+{
471
+ Stm32l4x5UsartBaseClass *subc = STM32L4X5_USART_BASE_CLASS(oc);
472
+
473
+ subc->type = STM32L4x5_USART;
474
+}
475
+
476
+static void stm32l4x5_uart_class_init(ObjectClass *oc, void *data)
477
+{
478
+ Stm32l4x5UsartBaseClass *subc = STM32L4X5_USART_BASE_CLASS(oc);
479
+
480
+ subc->type = STM32L4x5_UART;
481
+}
482
+
483
+static void stm32l4x5_lpuart_class_init(ObjectClass *oc, void *data)
484
+{
485
+ Stm32l4x5UsartBaseClass *subc = STM32L4X5_USART_BASE_CLASS(oc);
486
+
487
+ subc->type = STM32L4x5_LPUART;
488
+}
489
+
490
+static const TypeInfo stm32l4x5_usart_types[] = {
491
+ {
492
+ .name = TYPE_STM32L4X5_USART_BASE,
493
+ .parent = TYPE_SYS_BUS_DEVICE,
494
+ .instance_size = sizeof(Stm32l4x5UsartBaseState),
495
+ .instance_init = stm32l4x5_usart_base_init,
496
+ .class_init = stm32l4x5_usart_base_class_init,
497
+ .abstract = true,
498
+ }, {
499
+ .name = TYPE_STM32L4X5_USART,
500
+ .parent = TYPE_STM32L4X5_USART_BASE,
501
+ .class_init = stm32l4x5_usart_class_init,
502
+ }, {
503
+ .name = TYPE_STM32L4X5_UART,
504
+ .parent = TYPE_STM32L4X5_USART_BASE,
505
+ .class_init = stm32l4x5_uart_class_init,
506
+ }, {
507
+ .name = TYPE_STM32L4X5_LPUART,
508
+ .parent = TYPE_STM32L4X5_USART_BASE,
509
+ .class_init = stm32l4x5_lpuart_class_init,
510
+ }
511
+};
512
+
513
+DEFINE_TYPES(stm32l4x5_usart_types)
514
diff --git a/hw/char/Kconfig b/hw/char/Kconfig
179
index XXXXXXX..XXXXXXX 100644
515
index XXXXXXX..XXXXXXX 100644
180
--- a/target/arm/translate.c
516
--- a/hw/char/Kconfig
181
+++ b/target/arm/translate.c
517
+++ b/hw/char/Kconfig
182
@@ -XXX,XX +XXX,XX @@ static TCGv_ptr vfp_reg_ptr(bool dp, int reg)
518
@@ -XXX,XX +XXX,XX @@ config VIRTIO_SERIAL
183
519
config STM32F2XX_USART
184
#define ARM_CP_RW_BIT (1 << 20)
520
bool
185
521
186
-/* Include the VFP decoder */
522
+config STM32L4X5_USART
187
+/* Include the VFP and Neon decoders */
523
+ bool
188
#include "translate-vfp.inc.c"
524
+
189
+#include "translate-neon.inc.c"
525
config CMSDK_APB_UART
190
526
bool
191
static inline void iwmmxt_load_reg(TCGv_i64 var, int reg)
527
192
{
528
diff --git a/hw/char/meson.build b/hw/char/meson.build
193
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
194
/* Unconditional instructions. */
195
/* TODO: Perhaps merge these into one decodetree output file. */
196
if (disas_a32_uncond(s, insn) ||
197
- disas_vfp_uncond(s, insn)) {
198
+ disas_vfp_uncond(s, insn) ||
199
+ disas_neon_dp(s, insn) ||
200
+ disas_neon_ls(s, insn) ||
201
+ disas_neon_shared(s, insn)) {
202
return;
203
}
204
/* fall back to legacy decoder */
205
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
206
ARCH(6T2);
207
}
208
209
+ if ((insn & 0xef000000) == 0xef000000) {
210
+ /*
211
+ * T32 encodings 0b111p_1111_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq
212
+ * transform into
213
+ * A32 encodings 0b1111_001p_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq
214
+ */
215
+ uint32_t a32_insn = (insn & 0xe2ffffff) |
216
+ ((insn & (1 << 28)) >> 4) | (1 << 28);
217
+
218
+ if (disas_neon_dp(s, a32_insn)) {
219
+ return;
220
+ }
221
+ }
222
+
223
+ if ((insn & 0xff100000) == 0xf9000000) {
224
+ /*
225
+ * T32 encodings 0b1111_1001_ppp0_qqqq_qqqq_qqqq_qqqq_qqqq
226
+ * transform into
227
+ * A32 encodings 0b1111_0100_ppp0_qqqq_qqqq_qqqq_qqqq_qqqq
228
+ */
229
+ uint32_t a32_insn = (insn & 0x00ffffff) | 0xf4000000;
230
+
231
+ if (disas_neon_ls(s, a32_insn)) {
232
+ return;
233
+ }
234
+ }
235
+
236
/*
237
* TODO: Perhaps merge these into one decodetree output file.
238
* Note disas_vfp is written for a32 with cond field in the
239
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
240
*/
241
if (disas_t32(s, insn) ||
242
disas_vfp_uncond(s, insn) ||
243
+ disas_neon_shared(s, insn) ||
244
((insn >> 28) == 0xe && disas_vfp(s, insn))) {
245
return;
246
}
247
diff --git a/target/arm/Makefile.objs b/target/arm/Makefile.objs
248
index XXXXXXX..XXXXXXX 100644
529
index XXXXXXX..XXXXXXX 100644
249
--- a/target/arm/Makefile.objs
530
--- a/hw/char/meson.build
250
+++ b/target/arm/Makefile.objs
531
+++ b/hw/char/meson.build
251
@@ -XXX,XX +XXX,XX @@ target/arm/decode-sve.inc.c: $(SRC_PATH)/target/arm/sve.decode $(DECODETREE)
532
@@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_RENESAS_SCI', if_true: files('renesas_sci.c'))
252
     $(PYTHON) $(DECODETREE) --decode disas_sve -o $@ $<,\
533
system_ss.add(when: 'CONFIG_SIFIVE_UART', if_true: files('sifive_uart.c'))
253
     "GEN", $(TARGET_DIR)$@)
534
system_ss.add(when: 'CONFIG_SH_SCI', if_true: files('sh_serial.c'))
254
535
system_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: files('stm32f2xx_usart.c'))
255
+target/arm/decode-neon-shared.inc.c: $(SRC_PATH)/target/arm/neon-shared.decode $(DECODETREE)
536
+system_ss.add(when: 'CONFIG_STM32L4X5_USART', if_true: files('stm32l4x5_usart.c'))
256
+    $(call quiet-command,\
537
system_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: files('mchp_pfsoc_mmuart.c'))
257
+     $(PYTHON) $(DECODETREE) --static-decode disas_neon_shared -o $@ $<,\
538
system_ss.add(when: 'CONFIG_HTIF', if_true: files('riscv_htif.c'))
258
+     "GEN", $(TARGET_DIR)$@)
539
system_ss.add(when: 'CONFIG_GOLDFISH_TTY', if_true: files('goldfish_tty.c'))
259
+
540
diff --git a/hw/char/trace-events b/hw/char/trace-events
260
+target/arm/decode-neon-dp.inc.c: $(SRC_PATH)/target/arm/neon-dp.decode $(DECODETREE)
541
index XXXXXXX..XXXXXXX 100644
261
+    $(call quiet-command,\
542
--- a/hw/char/trace-events
262
+     $(PYTHON) $(DECODETREE) --static-decode disas_neon_dp -o $@ $<,\
543
+++ b/hw/char/trace-events
263
+     "GEN", $(TARGET_DIR)$@)
544
@@ -XXX,XX +XXX,XX @@ cadence_uart_baudrate(unsigned baudrate) "baudrate %u"
264
+
545
sh_serial_read(char *id, unsigned size, uint64_t offs, uint64_t val) " %s size %d offs 0x%02" PRIx64 " -> 0x%02" PRIx64
265
+target/arm/decode-neon-ls.inc.c: $(SRC_PATH)/target/arm/neon-ls.decode $(DECODETREE)
546
sh_serial_write(char *id, unsigned size, uint64_t offs, uint64_t val) "%s size %d offs 0x%02" PRIx64 " <- 0x%02" PRIx64
266
+    $(call quiet-command,\
547
267
+     $(PYTHON) $(DECODETREE) --static-decode disas_neon_ls -o $@ $<,\
548
+# stm32l4x5_usart.c
268
+     "GEN", $(TARGET_DIR)$@)
549
+stm32l4x5_usart_read(uint64_t addr, uint32_t data) "USART: Read <0x%" PRIx64 "> -> 0x%" PRIx32 ""
269
+
550
+stm32l4x5_usart_write(uint64_t addr, uint32_t data) "USART: Write <0x%" PRIx64 "> <- 0x%" PRIx32 ""
270
target/arm/decode-vfp.inc.c: $(SRC_PATH)/target/arm/vfp.decode $(DECODETREE)
551
+
271
    $(call quiet-command,\
552
# xen_console.c
272
     $(PYTHON) $(DECODETREE) --static-decode disas_vfp -o $@ $<,\
553
xen_console_connect(unsigned int idx, unsigned int ring_ref, unsigned int port, unsigned int limit) "idx %u ring_ref %u port %u limit %u"
273
@@ -XXX,XX +XXX,XX @@ target/arm/decode-t16.inc.c: $(SRC_PATH)/target/arm/t16.decode $(DECODETREE)
554
xen_console_disconnect(unsigned int idx) "idx %u"
274
     "GEN", $(TARGET_DIR)$@)
275
276
target/arm/translate-sve.o: target/arm/decode-sve.inc.c
277
+target/arm/translate.o: target/arm/decode-neon-shared.inc.c
278
+target/arm/translate.o: target/arm/decode-neon-dp.inc.c
279
+target/arm/translate.o: target/arm/decode-neon-ls.inc.c
280
target/arm/translate.o: target/arm/decode-vfp.inc.c
281
target/arm/translate.o: target/arm/decode-vfp-uncond.inc.c
282
target/arm/translate.o: target/arm/decode-a32.inc.c
283
--
555
--
284
2.20.1
556
2.34.1
285
557
286
558
diff view generated by jsdifflib
1
We were accidentally permitting decode of Thumb Neon insns even if
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
the CPU didn't have the FEATURE_NEON bit set, because the feature
2
3
check was being done before the call to disas_neon_data_insn() and
3
Implement the ability to read and write characters to the
4
disas_neon_ls_insn() in the Arm decoder but was omitted from the
4
usart using the serial port.
5
Thumb decoder. Push the feature bit check down into the called
5
6
functions so it is done for both Arm and Thumb encodings.
6
The character transmission is based on the
7
7
cmsdk-apb-uart implementation.
8
9
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
10
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20240329174402.60382-3-arnaud.minier@telecom-paris.fr
13
[PMM: fixed a few checkpatch nits]
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20200430181003.21682-3-peter.maydell@linaro.org
12
---
15
---
13
target/arm/translate.c | 16 ++++++++--------
16
include/hw/char/stm32l4x5_usart.h | 1 +
14
1 file changed, 8 insertions(+), 8 deletions(-)
17
hw/char/stm32l4x5_usart.c | 143 ++++++++++++++++++++++++++++++
15
18
hw/char/trace-events | 7 ++
16
diff --git a/target/arm/translate.c b/target/arm/translate.c
19
3 files changed, 151 insertions(+)
20
21
diff --git a/include/hw/char/stm32l4x5_usart.h b/include/hw/char/stm32l4x5_usart.h
17
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/translate.c
23
--- a/include/hw/char/stm32l4x5_usart.h
19
+++ b/target/arm/translate.c
24
+++ b/include/hw/char/stm32l4x5_usart.h
20
@@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
25
@@ -XXX,XX +XXX,XX @@ struct Stm32l4x5UsartBaseState {
21
TCGv_i32 tmp2;
26
Clock *clk;
22
TCGv_i64 tmp64;
27
CharBackend chr;
23
28
qemu_irq irq;
24
+ if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
29
+ guint watch_tag;
30
};
31
32
struct Stm32l4x5UsartBaseClass {
33
diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/char/stm32l4x5_usart.c
36
+++ b/hw/char/stm32l4x5_usart.c
37
@@ -XXX,XX +XXX,XX @@ REG32(RDR, 0x24)
38
REG32(TDR, 0x28)
39
FIELD(TDR, TDR, 0, 9)
40
41
+static void stm32l4x5_update_irq(Stm32l4x5UsartBaseState *s)
42
+{
43
+ if (((s->isr & R_ISR_WUF_MASK) && (s->cr3 & R_CR3_WUFIE_MASK)) ||
44
+ ((s->isr & R_ISR_CMF_MASK) && (s->cr1 & R_CR1_CMIE_MASK)) ||
45
+ ((s->isr & R_ISR_ABRF_MASK) && (s->cr1 & R_CR1_RXNEIE_MASK)) ||
46
+ ((s->isr & R_ISR_EOBF_MASK) && (s->cr1 & R_CR1_EOBIE_MASK)) ||
47
+ ((s->isr & R_ISR_RTOF_MASK) && (s->cr1 & R_CR1_RTOIE_MASK)) ||
48
+ ((s->isr & R_ISR_CTSIF_MASK) && (s->cr3 & R_CR3_CTSIE_MASK)) ||
49
+ ((s->isr & R_ISR_LBDF_MASK) && (s->cr2 & R_CR2_LBDIE_MASK)) ||
50
+ ((s->isr & R_ISR_TXE_MASK) && (s->cr1 & R_CR1_TXEIE_MASK)) ||
51
+ ((s->isr & R_ISR_TC_MASK) && (s->cr1 & R_CR1_TCIE_MASK)) ||
52
+ ((s->isr & R_ISR_RXNE_MASK) && (s->cr1 & R_CR1_RXNEIE_MASK)) ||
53
+ ((s->isr & R_ISR_IDLE_MASK) && (s->cr1 & R_CR1_IDLEIE_MASK)) ||
54
+ ((s->isr & R_ISR_ORE_MASK) &&
55
+ ((s->cr1 & R_CR1_RXNEIE_MASK) || (s->cr3 & R_CR3_EIE_MASK))) ||
56
+ /* TODO: Handle NF ? */
57
+ ((s->isr & R_ISR_FE_MASK) && (s->cr3 & R_CR3_EIE_MASK)) ||
58
+ ((s->isr & R_ISR_PE_MASK) && (s->cr1 & R_CR1_PEIE_MASK))) {
59
+ qemu_irq_raise(s->irq);
60
+ trace_stm32l4x5_usart_irq_raised(s->isr);
61
+ } else {
62
+ qemu_irq_lower(s->irq);
63
+ trace_stm32l4x5_usart_irq_lowered();
64
+ }
65
+}
66
+
67
+static int stm32l4x5_usart_base_can_receive(void *opaque)
68
+{
69
+ Stm32l4x5UsartBaseState *s = opaque;
70
+
71
+ if (!(s->isr & R_ISR_RXNE_MASK)) {
25
+ return 1;
72
+ return 1;
26
+ }
73
+ }
27
+
74
+
28
/* FIXME: this access check should not take precedence over UNDEF
75
+ return 0;
29
* for invalid encodings; we will generate incorrect syndrome information
76
+}
30
* for attempts to execute invalid vfp/neon encodings with FP disabled.
77
+
31
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
78
+static void stm32l4x5_usart_base_receive(void *opaque, const uint8_t *buf,
32
TCGv_ptr ptr1, ptr2, ptr3;
79
+ int size)
33
TCGv_i64 tmp64;
80
+{
34
81
+ Stm32l4x5UsartBaseState *s = opaque;
35
+ if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
82
+
36
+ return 1;
83
+ if (!((s->cr1 & R_CR1_UE_MASK) && (s->cr1 & R_CR1_RE_MASK))) {
37
+ }
84
+ trace_stm32l4x5_usart_receiver_not_enabled(
38
+
85
+ FIELD_EX32(s->cr1, CR1, UE), FIELD_EX32(s->cr1, CR1, RE));
39
/* FIXME: this access check should not take precedence over UNDEF
86
+ return;
40
* for invalid encodings; we will generate incorrect syndrome information
87
+ }
41
* for attempts to execute invalid vfp/neon encodings with FP disabled.
88
+
42
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
89
+ /* Check if overrun detection is enabled and if there is an overrun */
43
90
+ if (!(s->cr3 & R_CR3_OVRDIS_MASK) && (s->isr & R_ISR_RXNE_MASK)) {
44
if (((insn >> 25) & 7) == 1) {
91
+ /*
45
/* NEON Data processing. */
92
+ * A character has been received while
46
- if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
93
+ * the previous has not been read = Overrun.
47
- goto illegal_op;
94
+ */
48
- }
95
+ s->isr |= R_ISR_ORE_MASK;
49
-
96
+ trace_stm32l4x5_usart_overrun_detected(s->rdr, *buf);
50
if (disas_neon_data_insn(s, insn)) {
97
+ } else {
51
goto illegal_op;
98
+ /* No overrun */
52
}
99
+ s->rdr = *buf;
53
@@ -XXX,XX +XXX,XX @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
100
+ s->isr |= R_ISR_RXNE_MASK;
54
}
101
+ trace_stm32l4x5_usart_rx(s->rdr);
55
if ((insn & 0x0f100000) == 0x04000000) {
102
+ }
56
/* NEON load/store. */
103
+
57
- if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
104
+ stm32l4x5_update_irq(s);
58
- goto illegal_op;
105
+}
59
- }
106
+
60
-
107
+/*
61
if (disas_neon_ls_insn(s, insn)) {
108
+ * Try to send tx data, and arrange to be called back later if
62
goto illegal_op;
109
+ * we can't (ie the char backend is busy/blocking).
63
}
110
+ */
111
+static gboolean usart_transmit(void *do_not_use, GIOCondition cond,
112
+ void *opaque)
113
+{
114
+ Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(opaque);
115
+ int ret;
116
+ /* TODO: Handle 9 bits transmission */
117
+ uint8_t ch = s->tdr;
118
+
119
+ s->watch_tag = 0;
120
+
121
+ if (!(s->cr1 & R_CR1_TE_MASK) || (s->isr & R_ISR_TXE_MASK)) {
122
+ return G_SOURCE_REMOVE;
123
+ }
124
+
125
+ ret = qemu_chr_fe_write(&s->chr, &ch, 1);
126
+ if (ret <= 0) {
127
+ s->watch_tag = qemu_chr_fe_add_watch(&s->chr, G_IO_OUT | G_IO_HUP,
128
+ usart_transmit, s);
129
+ if (!s->watch_tag) {
130
+ /*
131
+ * Most common reason to be here is "no chardev backend":
132
+ * just insta-drain the buffer, so the serial output
133
+ * goes into a void, rather than blocking the guest.
134
+ */
135
+ goto buffer_drained;
136
+ }
137
+ /* Transmit pending */
138
+ trace_stm32l4x5_usart_tx_pending();
139
+ return G_SOURCE_REMOVE;
140
+ }
141
+
142
+buffer_drained:
143
+ /* Character successfully sent */
144
+ trace_stm32l4x5_usart_tx(ch);
145
+ s->isr |= R_ISR_TC_MASK | R_ISR_TXE_MASK;
146
+ stm32l4x5_update_irq(s);
147
+ return G_SOURCE_REMOVE;
148
+}
149
+
150
+static void usart_cancel_transmit(Stm32l4x5UsartBaseState *s)
151
+{
152
+ if (s->watch_tag) {
153
+ g_source_remove(s->watch_tag);
154
+ s->watch_tag = 0;
155
+ }
156
+}
157
+
158
static void stm32l4x5_usart_base_reset_hold(Object *obj, ResetType type)
159
{
160
Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj);
161
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_reset_hold(Object *obj, ResetType type)
162
s->isr = 0x020000C0;
163
s->rdr = 0x00000000;
164
s->tdr = 0x00000000;
165
+
166
+ usart_cancel_transmit(s);
167
+ stm32l4x5_update_irq(s);
168
+}
169
+
170
+static void usart_update_rqr(Stm32l4x5UsartBaseState *s, uint32_t value)
171
+{
172
+ /* TXFRQ */
173
+ /* Reset RXNE flag */
174
+ if (value & R_RQR_RXFRQ_MASK) {
175
+ s->isr &= ~R_ISR_RXNE_MASK;
176
+ }
177
+ /* MMRQ */
178
+ /* SBKRQ */
179
+ /* ABRRQ */
180
+ stm32l4x5_update_irq(s);
181
}
182
183
static uint64_t stm32l4x5_usart_base_read(void *opaque, hwaddr addr,
184
@@ -XXX,XX +XXX,XX @@ static uint64_t stm32l4x5_usart_base_read(void *opaque, hwaddr addr,
185
retvalue = FIELD_EX32(s->rdr, RDR, RDR);
186
/* Reset RXNE flag */
187
s->isr &= ~R_ISR_RXNE_MASK;
188
+ stm32l4x5_update_irq(s);
189
break;
190
case A_TDR:
191
retvalue = FIELD_EX32(s->tdr, TDR, TDR);
192
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
193
switch (addr) {
194
case A_CR1:
195
s->cr1 = value;
196
+ stm32l4x5_update_irq(s);
197
return;
198
case A_CR2:
199
s->cr2 = value;
200
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
201
s->rtor = value;
202
return;
203
case A_RQR:
204
+ usart_update_rqr(s, value);
205
return;
206
case A_ISR:
207
qemu_log_mask(LOG_GUEST_ERROR,
208
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
209
case A_ICR:
210
/* Clear the status flags */
211
s->isr &= ~value;
212
+ stm32l4x5_update_irq(s);
213
return;
214
case A_RDR:
215
qemu_log_mask(LOG_GUEST_ERROR,
216
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
217
return;
218
case A_TDR:
219
s->tdr = value;
220
+ s->isr &= ~R_ISR_TXE_MASK;
221
+ usart_transmit(NULL, G_IO_OUT, s);
222
return;
223
default:
224
qemu_log_mask(LOG_GUEST_ERROR,
225
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_realize(DeviceState *dev, Error **errp)
226
error_setg(errp, "USART clock must be wired up by SoC code");
227
return;
228
}
229
+
230
+ qemu_chr_fe_set_handlers(&s->chr, stm32l4x5_usart_base_can_receive,
231
+ stm32l4x5_usart_base_receive, NULL, NULL,
232
+ s, NULL, true);
233
}
234
235
static void stm32l4x5_usart_base_class_init(ObjectClass *klass, void *data)
236
diff --git a/hw/char/trace-events b/hw/char/trace-events
237
index XXXXXXX..XXXXXXX 100644
238
--- a/hw/char/trace-events
239
+++ b/hw/char/trace-events
240
@@ -XXX,XX +XXX,XX @@ sh_serial_write(char *id, unsigned size, uint64_t offs, uint64_t val) "%s size %
241
# stm32l4x5_usart.c
242
stm32l4x5_usart_read(uint64_t addr, uint32_t data) "USART: Read <0x%" PRIx64 "> -> 0x%" PRIx32 ""
243
stm32l4x5_usart_write(uint64_t addr, uint32_t data) "USART: Write <0x%" PRIx64 "> <- 0x%" PRIx32 ""
244
+stm32l4x5_usart_rx(uint8_t c) "USART: got character 0x%x from backend"
245
+stm32l4x5_usart_tx(uint8_t c) "USART: character 0x%x sent to backend"
246
+stm32l4x5_usart_tx_pending(void) "USART: character send to backend pending"
247
+stm32l4x5_usart_irq_raised(uint32_t reg) "USART: IRQ raised: 0x%08"PRIx32
248
+stm32l4x5_usart_irq_lowered(void) "USART: IRQ lowered"
249
+stm32l4x5_usart_overrun_detected(uint8_t current, uint8_t received) "USART: Overrun detected, RDR='0x%x', received 0x%x"
250
+stm32l4x5_usart_receiver_not_enabled(uint8_t ue_bit, uint8_t re_bit) "USART: Receiver not enabled, UE=0x%x, RE=0x%x"
251
252
# xen_console.c
253
xen_console_connect(unsigned int idx, unsigned int ring_ref, unsigned int port, unsigned int limit) "idx %u ring_ref %u port %u limit %u"
64
--
254
--
65
2.20.1
255
2.34.1
66
256
67
257
diff view generated by jsdifflib
1
Convert the Neon 3-reg-same VADD and VSUB insns to decodetree.
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
2
3
Note that we don't need the neon_3r_sizes[op] check here because all
3
Add a function to change the settings of the
4
size values are OK for VADD and VSUB; we'll add this when we convert
4
serial connection.
5
the first insn that has size restrictions.
6
5
7
For this we need one of the GVecGen*Fn typedefs currently in
6
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
8
translate-a64.h; move them all to translate.h as a block so they
7
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
9
are visible to the 32-bit decoder.
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20240329174402.60382-4-arnaud.minier@telecom-paris.fr
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/char/stm32l4x5_usart.c | 98 +++++++++++++++++++++++++++++++++++++++
13
hw/char/trace-events | 1 +
14
2 files changed, 99 insertions(+)
10
15
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20200430181003.21682-15-peter.maydell@linaro.org
14
---
15
target/arm/translate-a64.h | 9 --------
16
target/arm/translate.h | 9 ++++++++
17
target/arm/neon-dp.decode | 17 +++++++++++++++
18
target/arm/translate-neon.inc.c | 38 +++++++++++++++++++++++++++++++++
19
target/arm/translate.c | 14 ++++--------
20
5 files changed, 68 insertions(+), 19 deletions(-)
21
22
diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h
23
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/translate-a64.h
18
--- a/hw/char/stm32l4x5_usart.c
25
+++ b/target/arm/translate-a64.h
19
+++ b/hw/char/stm32l4x5_usart.c
26
@@ -XXX,XX +XXX,XX @@ static inline int vec_full_reg_size(DisasContext *s)
20
@@ -XXX,XX +XXX,XX @@ static void usart_cancel_transmit(Stm32l4x5UsartBaseState *s)
27
21
}
28
bool disas_sve(DisasContext *, uint32_t);
22
}
29
23
30
-/* Note that the gvec expanders operate on offsets + sizes. */
24
+static void stm32l4x5_update_params(Stm32l4x5UsartBaseState *s)
31
-typedef void GVecGen2Fn(unsigned, uint32_t, uint32_t, uint32_t, uint32_t);
25
+{
32
-typedef void GVecGen2iFn(unsigned, uint32_t, uint32_t, int64_t,
26
+ int speed, parity, data_bits, stop_bits;
33
- uint32_t, uint32_t);
27
+ uint32_t value, usart_div;
34
-typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t,
28
+ QEMUSerialSetParams ssp;
35
- uint32_t, uint32_t, uint32_t);
36
-typedef void GVecGen4Fn(unsigned, uint32_t, uint32_t, uint32_t,
37
- uint32_t, uint32_t, uint32_t);
38
-
39
#endif /* TARGET_ARM_TRANSLATE_A64_H */
40
diff --git a/target/arm/translate.h b/target/arm/translate.h
41
index XXXXXXX..XXXXXXX 100644
42
--- a/target/arm/translate.h
43
+++ b/target/arm/translate.h
44
@@ -XXX,XX +XXX,XX @@ void gen_sshl_i64(TCGv_i64 d, TCGv_i64 a, TCGv_i64 b);
45
#define dc_isar_feature(name, ctx) \
46
({ DisasContext *ctx_ = (ctx); isar_feature_##name(ctx_->isar); })
47
48
+/* Note that the gvec expanders operate on offsets + sizes. */
49
+typedef void GVecGen2Fn(unsigned, uint32_t, uint32_t, uint32_t, uint32_t);
50
+typedef void GVecGen2iFn(unsigned, uint32_t, uint32_t, int64_t,
51
+ uint32_t, uint32_t);
52
+typedef void GVecGen3Fn(unsigned, uint32_t, uint32_t,
53
+ uint32_t, uint32_t, uint32_t);
54
+typedef void GVecGen4Fn(unsigned, uint32_t, uint32_t, uint32_t,
55
+ uint32_t, uint32_t, uint32_t);
56
+
29
+
57
#endif /* TARGET_ARM_TRANSLATE_H */
30
+ /* Select the parity type */
58
diff --git a/target/arm/neon-dp.decode b/target/arm/neon-dp.decode
31
+ if (s->cr1 & R_CR1_PCE_MASK) {
59
index XXXXXXX..XXXXXXX 100644
32
+ if (s->cr1 & R_CR1_PS_MASK) {
60
--- a/target/arm/neon-dp.decode
33
+ parity = 'O';
61
+++ b/target/arm/neon-dp.decode
34
+ } else {
62
@@ -XXX,XX +XXX,XX @@
35
+ parity = 'E';
63
#
36
+ }
64
# This file is processed by scripts/decodetree.py
37
+ } else {
65
#
38
+ parity = 'N';
66
+# VFP/Neon register fields; same as vfp.decode
67
+%vm_dp 5:1 0:4
68
+%vn_dp 7:1 16:4
69
+%vd_dp 22:1 12:4
70
71
# Encodings for Neon data processing instructions where the T32 encoding
72
# is a simple transformation of the A32 encoding.
73
@@ -XXX,XX +XXX,XX @@
74
# 0b111p_1111_qqqq_qqqq_qqqq_qqqq_qqqq_qqqq
75
# This file works on the A32 encoding only; calling code for T32 has to
76
# transform the insn into the A32 version first.
77
+
78
+######################################################################
79
+# 3-reg-same grouping:
80
+# 1111 001 U 0 D sz:2 Vn:4 Vd:4 opc:4 N Q M op Vm:4
81
+######################################################################
82
+
83
+&3same vm vn vd q size
84
+
85
+@3same .... ... . . . size:2 .... .... .... . q:1 . . .... \
86
+ &3same vm=%vm_dp vn=%vn_dp vd=%vd_dp
87
+
88
+VADD_3s 1111 001 0 0 . .. .... .... 1000 . . . 0 .... @3same
89
+VSUB_3s 1111 001 1 0 . .. .... .... 1000 . . . 0 .... @3same
90
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
91
index XXXXXXX..XXXXXXX 100644
92
--- a/target/arm/translate-neon.inc.c
93
+++ b/target/arm/translate-neon.inc.c
94
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_single(DisasContext *s, arg_VLDST_single *a)
95
96
return true;
97
}
98
+
99
+static bool do_3same(DisasContext *s, arg_3same *a, GVecGen3Fn fn)
100
+{
101
+ int vec_size = a->q ? 16 : 8;
102
+ int rd_ofs = neon_reg_offset(a->vd, 0);
103
+ int rn_ofs = neon_reg_offset(a->vn, 0);
104
+ int rm_ofs = neon_reg_offset(a->vm, 0);
105
+
106
+ if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
107
+ return false;
108
+ }
39
+ }
109
+
40
+
110
+ /* UNDEF accesses to D16-D31 if they don't exist. */
41
+ /* Select the number of stop bits */
111
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
42
+ switch (FIELD_EX32(s->cr2, CR2, STOP)) {
112
+ ((a->vd | a->vn | a->vm) & 0x10)) {
43
+ case 0:
113
+ return false;
44
+ stop_bits = 1;
45
+ break;
46
+ case 2:
47
+ stop_bits = 2;
48
+ break;
49
+ default:
50
+ qemu_log_mask(LOG_UNIMP,
51
+ "UNIMPLEMENTED: fractionnal stop bits; CR2[13:12] = %u",
52
+ FIELD_EX32(s->cr2, CR2, STOP));
53
+ return;
114
+ }
54
+ }
115
+
55
+
116
+ if ((a->vn | a->vm | a->vd) & a->q) {
56
+ /* Select the length of the word */
117
+ return false;
57
+ switch ((FIELD_EX32(s->cr1, CR1, M1) << 1) | FIELD_EX32(s->cr1, CR1, M0)) {
58
+ case 0:
59
+ data_bits = 8;
60
+ break;
61
+ case 1:
62
+ data_bits = 9;
63
+ break;
64
+ case 2:
65
+ data_bits = 7;
66
+ break;
67
+ default:
68
+ qemu_log_mask(LOG_GUEST_ERROR,
69
+ "UNDEFINED: invalid word length, CR1.M = 0b11");
70
+ return;
118
+ }
71
+ }
119
+
72
+
120
+ if (!vfp_access_check(s)) {
73
+ /* Select the baud rate */
121
+ return true;
74
+ value = FIELD_EX32(s->brr, BRR, BRR);
75
+ if (value < 16) {
76
+ qemu_log_mask(LOG_GUEST_ERROR,
77
+ "UNDEFINED: BRR less than 16: %u", value);
78
+ return;
122
+ }
79
+ }
123
+
80
+
124
+ fn(a->size, rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size);
81
+ if (FIELD_EX32(s->cr1, CR1, OVER8) == 0) {
125
+ return true;
82
+ /*
83
+ * Oversampling by 16
84
+ * BRR = USARTDIV
85
+ */
86
+ usart_div = value;
87
+ } else {
88
+ /*
89
+ * Oversampling by 8
90
+ * - BRR[2:0] = USARTDIV[3:0] shifted 1 bit to the right.
91
+ * - BRR[3] must be kept cleared.
92
+ * - BRR[15:4] = USARTDIV[15:4]
93
+ * - The frequency is multiplied by 2
94
+ */
95
+ usart_div = ((value & 0xFFF0) | ((value & 0x0007) << 1)) / 2;
96
+ }
97
+
98
+ speed = clock_get_hz(s->clk) / usart_div;
99
+
100
+ ssp.speed = speed;
101
+ ssp.parity = parity;
102
+ ssp.data_bits = data_bits;
103
+ ssp.stop_bits = stop_bits;
104
+
105
+ qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp);
106
+
107
+ trace_stm32l4x5_usart_update_params(speed, parity, data_bits, stop_bits);
126
+}
108
+}
127
+
109
+
128
+#define DO_3SAME(INSN, FUNC) \
110
static void stm32l4x5_usart_base_reset_hold(Object *obj, ResetType type)
129
+ static bool trans_##INSN##_3s(DisasContext *s, arg_3same *a) \
111
{
130
+ { \
112
Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj);
131
+ return do_3same(s, a, FUNC); \
113
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
132
+ }
114
switch (addr) {
115
case A_CR1:
116
s->cr1 = value;
117
+ stm32l4x5_update_params(s);
118
stm32l4x5_update_irq(s);
119
return;
120
case A_CR2:
121
s->cr2 = value;
122
+ stm32l4x5_update_params(s);
123
return;
124
case A_CR3:
125
s->cr3 = value;
126
return;
127
case A_BRR:
128
s->brr = value;
129
+ stm32l4x5_update_params(s);
130
return;
131
case A_GTPR:
132
s->gtpr = value;
133
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_init(Object *obj)
134
s->clk = qdev_init_clock_in(DEVICE(s), "clk", NULL, s, 0);
135
}
136
137
+static int stm32l4x5_usart_base_post_load(void *opaque, int version_id)
138
+{
139
+ Stm32l4x5UsartBaseState *s = (Stm32l4x5UsartBaseState *)opaque;
133
+
140
+
134
+DO_3SAME(VADD, tcg_gen_gvec_add)
141
+ stm32l4x5_update_params(s);
135
+DO_3SAME(VSUB, tcg_gen_gvec_sub)
142
+ return 0;
136
diff --git a/target/arm/translate.c b/target/arm/translate.c
143
+}
144
+
145
static const VMStateDescription vmstate_stm32l4x5_usart_base = {
146
.name = TYPE_STM32L4X5_USART_BASE,
147
.version_id = 1,
148
.minimum_version_id = 1,
149
+ .post_load = stm32l4x5_usart_base_post_load,
150
.fields = (VMStateField[]) {
151
VMSTATE_UINT32(cr1, Stm32l4x5UsartBaseState),
152
VMSTATE_UINT32(cr2, Stm32l4x5UsartBaseState),
153
diff --git a/hw/char/trace-events b/hw/char/trace-events
137
index XXXXXXX..XXXXXXX 100644
154
index XXXXXXX..XXXXXXX 100644
138
--- a/target/arm/translate.c
155
--- a/hw/char/trace-events
139
+++ b/target/arm/translate.c
156
+++ b/hw/char/trace-events
140
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
157
@@ -XXX,XX +XXX,XX @@ stm32l4x5_usart_irq_raised(uint32_t reg) "USART: IRQ raised: 0x%08"PRIx32
141
}
158
stm32l4x5_usart_irq_lowered(void) "USART: IRQ lowered"
142
return 0;
159
stm32l4x5_usart_overrun_detected(uint8_t current, uint8_t received) "USART: Overrun detected, RDR='0x%x', received 0x%x"
143
160
stm32l4x5_usart_receiver_not_enabled(uint8_t ue_bit, uint8_t re_bit) "USART: Receiver not enabled, UE=0x%x, RE=0x%x"
144
- case NEON_3R_VADD_VSUB:
161
+stm32l4x5_usart_update_params(int speed, uint8_t parity, int data, int stop) "USART: speed: %d, parity: %c, data bits: %d, stop bits: %d"
145
- if (u) {
162
146
- tcg_gen_gvec_sub(size, rd_ofs, rn_ofs, rm_ofs,
163
# xen_console.c
147
- vec_size, vec_size);
164
xen_console_connect(unsigned int idx, unsigned int ring_ref, unsigned int port, unsigned int limit) "idx %u ring_ref %u port %u limit %u"
148
- } else {
149
- tcg_gen_gvec_add(size, rd_ofs, rn_ofs, rm_ofs,
150
- vec_size, vec_size);
151
- }
152
- return 0;
153
-
154
case NEON_3R_VQADD:
155
tcg_gen_gvec_4(rd_ofs, offsetof(CPUARMState, vfp.qc),
156
rn_ofs, rm_ofs, vec_size, vec_size,
157
@@ -XXX,XX +XXX,XX @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
158
tcg_gen_gvec_3(rd_ofs, rm_ofs, rn_ofs, vec_size, vec_size,
159
u ? &ushl_op[size] : &sshl_op[size]);
160
return 0;
161
+
162
+ case NEON_3R_VADD_VSUB:
163
+ /* Already handled by decodetree */
164
+ return 1;
165
}
166
167
if (size == 3) {
168
--
165
--
169
2.20.1
166
2.34.1
170
167
171
168
diff view generated by jsdifflib
1
Convert the Neon "load single structure to all lanes" insns to
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
decodetree.
2
3
3
Add the USART to the SoC and connect it to the other implemented devices.
4
5
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
6
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20240329174402.60382-5-arnaud.minier@telecom-paris.fr
9
[PMM: fixed a few checkpatch nits]
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20200430181003.21682-13-peter.maydell@linaro.org
7
---
11
---
8
target/arm/neon-ls.decode | 5 +++
12
docs/system/arm/b-l475e-iot01a.rst | 2 +-
9
target/arm/translate-neon.inc.c | 73 +++++++++++++++++++++++++++++++++
13
include/hw/arm/stm32l4x5_soc.h | 7 +++
10
target/arm/translate.c | 55 +------------------------
14
hw/arm/stm32l4x5_soc.c | 83 +++++++++++++++++++++++++++---
11
3 files changed, 80 insertions(+), 53 deletions(-)
15
hw/arm/Kconfig | 1 +
12
16
4 files changed, 86 insertions(+), 7 deletions(-)
13
diff --git a/target/arm/neon-ls.decode b/target/arm/neon-ls.decode
17
14
index XXXXXXX..XXXXXXX 100644
18
diff --git a/docs/system/arm/b-l475e-iot01a.rst b/docs/system/arm/b-l475e-iot01a.rst
15
--- a/target/arm/neon-ls.decode
19
index XXXXXXX..XXXXXXX 100644
16
+++ b/target/arm/neon-ls.decode
20
--- a/docs/system/arm/b-l475e-iot01a.rst
21
+++ b/docs/system/arm/b-l475e-iot01a.rst
22
@@ -XXX,XX +XXX,XX @@ Currently B-L475E-IOT01A machine's only supports the following devices:
23
- STM32L4x5 SYSCFG (System configuration controller)
24
- STM32L4x5 RCC (Reset and clock control)
25
- STM32L4x5 GPIOs (General-purpose I/Os)
26
+- STM32L4x5 USARTs, UARTs and LPUART (Serial ports)
27
28
Missing devices
29
"""""""""""""""
30
31
The B-L475E-IOT01A does *not* support the following devices:
32
33
-- Serial ports (UART)
34
- Analog to Digital Converter (ADC)
35
- SPI controller
36
- Timer controller (TIMER)
37
diff --git a/include/hw/arm/stm32l4x5_soc.h b/include/hw/arm/stm32l4x5_soc.h
38
index XXXXXXX..XXXXXXX 100644
39
--- a/include/hw/arm/stm32l4x5_soc.h
40
+++ b/include/hw/arm/stm32l4x5_soc.h
17
@@ -XXX,XX +XXX,XX @@
41
@@ -XXX,XX +XXX,XX @@
18
42
#include "hw/misc/stm32l4x5_exti.h"
19
VLDST_multiple 1111 0100 0 . l:1 0 rn:4 .... itype:4 size:2 align:2 rm:4 \
43
#include "hw/misc/stm32l4x5_rcc.h"
20
vd=%vd_dp
44
#include "hw/gpio/stm32l4x5_gpio.h"
21
+
45
+#include "hw/char/stm32l4x5_usart.h"
22
+# Neon load single element to all lanes
46
#include "qom/object.h"
23
+
47
24
+VLD_all_lanes 1111 0100 1 . 1 0 rn:4 .... 11 n:2 size:2 t:1 a:1 rm:4 \
48
#define TYPE_STM32L4X5_SOC "stm32l4x5-soc"
25
+ vd=%vd_dp
49
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(Stm32l4x5SocState, Stm32l4x5SocClass, STM32L4X5_SOC)
26
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
50
27
index XXXXXXX..XXXXXXX 100644
51
#define NUM_EXTI_OR_GATES 4
28
--- a/target/arm/translate-neon.inc.c
52
29
+++ b/target/arm/translate-neon.inc.c
53
+#define STM_NUM_USARTS 3
30
@@ -XXX,XX +XXX,XX @@ static bool trans_VLDST_multiple(DisasContext *s, arg_VLDST_multiple *a)
54
+#define STM_NUM_UARTS 2
31
gen_neon_ldst_base_update(s, a->rm, a->rn, nregs * interleave * 8);
55
+
32
return true;
56
struct Stm32l4x5SocState {
57
SysBusDevice parent_obj;
58
59
@@ -XXX,XX +XXX,XX @@ struct Stm32l4x5SocState {
60
Stm32l4x5SyscfgState syscfg;
61
Stm32l4x5RccState rcc;
62
Stm32l4x5GpioState gpio[NUM_GPIOS];
63
+ Stm32l4x5UsartBaseState usart[STM_NUM_USARTS];
64
+ Stm32l4x5UsartBaseState uart[STM_NUM_UARTS];
65
+ Stm32l4x5UsartBaseState lpuart;
66
67
MemoryRegion sram1;
68
MemoryRegion sram2;
69
diff --git a/hw/arm/stm32l4x5_soc.c b/hw/arm/stm32l4x5_soc.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/hw/arm/stm32l4x5_soc.c
72
+++ b/hw/arm/stm32l4x5_soc.c
73
@@ -XXX,XX +XXX,XX @@
74
#include "sysemu/sysemu.h"
75
#include "hw/or-irq.h"
76
#include "hw/arm/stm32l4x5_soc.h"
77
+#include "hw/char/stm32l4x5_usart.h"
78
#include "hw/gpio/stm32l4x5_gpio.h"
79
#include "hw/qdev-clock.h"
80
#include "hw/misc/unimp.h"
81
@@ -XXX,XX +XXX,XX @@ static const struct {
82
{ 0x48001C00, 0x0000000F, 0x00000000, 0x00000000 },
83
};
84
85
+static const hwaddr usart_addr[] = {
86
+ 0x40013800, /* "USART1", 0x400 */
87
+ 0x40004400, /* "USART2", 0x400 */
88
+ 0x40004800, /* "USART3", 0x400 */
89
+};
90
+static const hwaddr uart_addr[] = {
91
+ 0x40004C00, /* "UART4" , 0x400 */
92
+ 0x40005000 /* "UART5" , 0x400 */
93
+};
94
+
95
+#define LPUART_BASE_ADDRESS 0x40008000
96
+
97
+static const int usart_irq[] = { 37, 38, 39 };
98
+static const int uart_irq[] = { 52, 53 };
99
+#define LPUART_IRQ 70
100
+
101
static void stm32l4x5_soc_initfn(Object *obj)
102
{
103
Stm32l4x5SocState *s = STM32L4X5_SOC(obj);
104
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_initfn(Object *obj)
105
g_autofree char *name = g_strdup_printf("gpio%c", 'a' + i);
106
object_initialize_child(obj, name, &s->gpio[i], TYPE_STM32L4X5_GPIO);
107
}
108
+
109
+ for (int i = 0; i < STM_NUM_USARTS; i++) {
110
+ object_initialize_child(obj, "usart[*]", &s->usart[i],
111
+ TYPE_STM32L4X5_USART);
112
+ }
113
+
114
+ for (int i = 0; i < STM_NUM_UARTS; i++) {
115
+ object_initialize_child(obj, "uart[*]", &s->uart[i],
116
+ TYPE_STM32L4X5_UART);
117
+ }
118
+ object_initialize_child(obj, "lpuart1", &s->lpuart,
119
+ TYPE_STM32L4X5_LPUART);
33
}
120
}
34
+
121
35
+static bool trans_VLD_all_lanes(DisasContext *s, arg_VLD_all_lanes *a)
122
static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
36
+{
123
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
37
+ /* Neon load single structure to all lanes */
124
sysbus_mmio_map(busdev, 0, RCC_BASE_ADDRESS);
38
+ int reg, stride, vec_size;
125
sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, RCC_IRQ));
39
+ int vd = a->vd;
126
40
+ int size = a->size;
127
+ /* USART devices */
41
+ int nregs = a->n + 1;
128
+ for (int i = 0; i < STM_NUM_USARTS; i++) {
42
+ TCGv_i32 addr, tmp;
129
+ g_autofree char *name = g_strdup_printf("usart%d-out", i + 1);
43
+
130
+ dev = DEVICE(&(s->usart[i]));
44
+ if (!arm_dc_feature(s, ARM_FEATURE_NEON)) {
131
+ qdev_prop_set_chr(dev, "chardev", serial_hd(i));
45
+ return false;
132
+ qdev_connect_clock_in(dev, "clk",
46
+ }
133
+ qdev_get_clock_out(DEVICE(&(s->rcc)), name));
47
+
134
+ busdev = SYS_BUS_DEVICE(dev);
48
+ /* UNDEF accesses to D16-D31 if they don't exist */
135
+ if (!sysbus_realize(busdev, errp)) {
49
+ if (!dc_isar_feature(aa32_simd_r32, s) && (a->vd & 0x10)) {
136
+ return;
50
+ return false;
51
+ }
52
+
53
+ if (size == 3) {
54
+ if (nregs != 4 || a->a == 0) {
55
+ return false;
56
+ }
137
+ }
57
+ /* For VLD4 size == 3 a == 1 means 32 bits at 16 byte alignment */
138
+ sysbus_mmio_map(busdev, 0, usart_addr[i]);
58
+ size = 2;
139
+ sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, usart_irq[i]));
59
+ }
60
+ if (nregs == 1 && a->a == 1 && size == 0) {
61
+ return false;
62
+ }
63
+ if (nregs == 3 && a->a == 1) {
64
+ return false;
65
+ }
66
+
67
+ if (!vfp_access_check(s)) {
68
+ return true;
69
+ }
140
+ }
70
+
141
+
71
+ /*
142
+ /*
72
+ * VLD1 to all lanes: T bit indicates how many Dregs to write.
143
+ * TODO: Connect the USARTs, UARTs and LPUART to the EXTI once the EXTI
73
+ * VLD2/3/4 to all lanes: T bit indicates register stride.
144
+ * can handle other gpio-in than the gpios. (e.g. Direct Lines for the
145
+ * usarts)
74
+ */
146
+ */
75
+ stride = a->t ? 2 : 1;
147
+
76
+ vec_size = nregs == 1 ? stride * 8 : 8;
148
+ /* UART devices */
77
+
149
+ for (int i = 0; i < STM_NUM_UARTS; i++) {
78
+ tmp = tcg_temp_new_i32();
150
+ g_autofree char *name = g_strdup_printf("uart%d-out", STM_NUM_USARTS + i + 1);
79
+ addr = tcg_temp_new_i32();
151
+ dev = DEVICE(&(s->uart[i]));
80
+ load_reg_var(s, addr, a->rn);
152
+ qdev_prop_set_chr(dev, "chardev", serial_hd(STM_NUM_USARTS + i));
81
+ for (reg = 0; reg < nregs; reg++) {
153
+ qdev_connect_clock_in(dev, "clk",
82
+ gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s),
154
+ qdev_get_clock_out(DEVICE(&(s->rcc)), name));
83
+ s->be_data | size);
155
+ busdev = SYS_BUS_DEVICE(dev);
84
+ if ((vd & 1) && vec_size == 16) {
156
+ if (!sysbus_realize(busdev, errp)) {
85
+ /*
157
+ return;
86
+ * We cannot write 16 bytes at once because the
87
+ * destination is unaligned.
88
+ */
89
+ tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0),
90
+ 8, 8, tmp);
91
+ tcg_gen_gvec_mov(0, neon_reg_offset(vd + 1, 0),
92
+ neon_reg_offset(vd, 0), 8, 8);
93
+ } else {
94
+ tcg_gen_gvec_dup_i32(size, neon_reg_offset(vd, 0),
95
+ vec_size, vec_size, tmp);
96
+ }
158
+ }
97
+ tcg_gen_addi_i32(addr, addr, 1 << size);
159
+ sysbus_mmio_map(busdev, 0, uart_addr[i]);
98
+ vd += stride;
160
+ sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, uart_irq[i]));
99
+ }
161
+ }
100
+ tcg_temp_free_i32(tmp);
162
+
101
+ tcg_temp_free_i32(addr);
163
+ /* LPUART device*/
102
+
164
+ dev = DEVICE(&(s->lpuart));
103
+ gen_neon_ldst_base_update(s, a->rm, a->rn, (1 << size) * nregs);
165
+ qdev_prop_set_chr(dev, "chardev", serial_hd(STM_NUM_USARTS + STM_NUM_UARTS));
104
+
166
+ qdev_connect_clock_in(dev, "clk",
105
+ return true;
167
+ qdev_get_clock_out(DEVICE(&(s->rcc)), "lpuart1-out"));
106
+}
168
+ busdev = SYS_BUS_DEVICE(dev);
107
diff --git a/target/arm/translate.c b/target/arm/translate.c
169
+ if (!sysbus_realize(busdev, errp)) {
108
index XXXXXXX..XXXXXXX 100644
170
+ return;
109
--- a/target/arm/translate.c
171
+ }
110
+++ b/target/arm/translate.c
172
+ sysbus_mmio_map(busdev, 0, LPUART_BASE_ADDRESS);
111
@@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
173
+ sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, LPUART_IRQ));
112
int size;
174
+
113
int reg;
175
/* APB1 BUS */
114
int load;
176
create_unimplemented_device("TIM2", 0x40000000, 0x400);
115
- int vec_size;
177
create_unimplemented_device("TIM3", 0x40000400, 0x400);
116
TCGv_i32 addr;
178
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
117
TCGv_i32 tmp;
179
create_unimplemented_device("SPI2", 0x40003800, 0x400);
118
180
create_unimplemented_device("SPI3", 0x40003C00, 0x400);
119
@@ -XXX,XX +XXX,XX @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
181
/* RESERVED: 0x40004000, 0x400 */
120
} else {
182
- create_unimplemented_device("USART2", 0x40004400, 0x400);
121
size = (insn >> 10) & 3;
183
- create_unimplemented_device("USART3", 0x40004800, 0x400);
122
if (size == 3) {
184
- create_unimplemented_device("UART4", 0x40004C00, 0x400);
123
- /* Load single element to all lanes. */
185
- create_unimplemented_device("UART5", 0x40005000, 0x400);
124
- int a = (insn >> 4) & 1;
186
create_unimplemented_device("I2C1", 0x40005400, 0x400);
125
- if (!load) {
187
create_unimplemented_device("I2C2", 0x40005800, 0x400);
126
- return 1;
188
create_unimplemented_device("I2C3", 0x40005C00, 0x400);
127
- }
189
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
128
- size = (insn >> 6) & 3;
190
create_unimplemented_device("DAC1", 0x40007400, 0x400);
129
- nregs = ((insn >> 8) & 3) + 1;
191
create_unimplemented_device("OPAMP", 0x40007800, 0x400);
130
-
192
create_unimplemented_device("LPTIM1", 0x40007C00, 0x400);
131
- if (size == 3) {
193
- create_unimplemented_device("LPUART1", 0x40008000, 0x400);
132
- if (nregs != 4 || a == 0) {
194
/* RESERVED: 0x40008400, 0x400 */
133
- return 1;
195
create_unimplemented_device("SWPMI1", 0x40008800, 0x400);
134
- }
196
/* RESERVED: 0x40008C00, 0x800 */
135
- /* For VLD4 size==3 a == 1 means 32 bits at 16 byte alignment */
197
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
136
- size = 2;
198
create_unimplemented_device("TIM1", 0x40012C00, 0x400);
137
- }
199
create_unimplemented_device("SPI1", 0x40013000, 0x400);
138
- if (nregs == 1 && a == 1 && size == 0) {
200
create_unimplemented_device("TIM8", 0x40013400, 0x400);
139
- return 1;
201
- create_unimplemented_device("USART1", 0x40013800, 0x400);
140
- }
202
/* RESERVED: 0x40013C00, 0x400 */
141
- if (nregs == 3 && a == 1) {
203
create_unimplemented_device("TIM15", 0x40014000, 0x400);
142
- return 1;
204
create_unimplemented_device("TIM16", 0x40014400, 0x400);
143
- }
205
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
144
- addr = tcg_temp_new_i32();
206
index XXXXXXX..XXXXXXX 100644
145
- load_reg_var(s, addr, rn);
207
--- a/hw/arm/Kconfig
146
-
208
+++ b/hw/arm/Kconfig
147
- /* VLD1 to all lanes: bit 5 indicates how many Dregs to write.
209
@@ -XXX,XX +XXX,XX @@ config STM32L4X5_SOC
148
- * VLD2/3/4 to all lanes: bit 5 indicates register stride.
210
select STM32L4X5_SYSCFG
149
- */
211
select STM32L4X5_RCC
150
- stride = (insn & (1 << 5)) ? 2 : 1;
212
select STM32L4X5_GPIO
151
- vec_size = nregs == 1 ? stride * 8 : 8;
213
+ select STM32L4X5_USART
152
-
214
153
- tmp = tcg_temp_new_i32();
215
config XLNX_ZYNQMP_ARM
154
- for (reg = 0; reg < nregs; reg++) {
216
bool
155
- gen_aa32_ld_i32(s, tmp, addr, get_mem_index(s),
156
- s->be_data | size);
157
- if ((rd & 1) && vec_size == 16) {
158
- /* We cannot write 16 bytes at once because the
159
- * destination is unaligned.
160
- */
161
- tcg_gen_gvec_dup_i32(size, neon_reg_offset(rd, 0),
162
- 8, 8, tmp);
163
- tcg_gen_gvec_mov(0, neon_reg_offset(rd + 1, 0),
164
- neon_reg_offset(rd, 0), 8, 8);
165
- } else {
166
- tcg_gen_gvec_dup_i32(size, neon_reg_offset(rd, 0),
167
- vec_size, vec_size, tmp);
168
- }
169
- tcg_gen_addi_i32(addr, addr, 1 << size);
170
- rd += stride;
171
- }
172
- tcg_temp_free_i32(tmp);
173
- tcg_temp_free_i32(addr);
174
- stride = (1 << size) * nregs;
175
+ /* Load single element to all lanes -- handled by decodetree */
176
+ return 1;
177
} else {
178
/* Single element. */
179
int idx = (insn >> 4) & 0xf;
180
--
217
--
181
2.20.1
218
2.34.1
182
219
183
220
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
2
3
Move misplaced comment.
3
Test:
4
4
- read/write from/to the usart registers
5
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
5
- send/receive a character/string over the serial port
6
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
6
7
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
8
Reviewed-by: Luc Michel <luc.michel@greensocs.com>
8
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
9
Message-id: 20200427181649.26851-3-edgar.iglesias@gmail.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20240329174402.60382-6-arnaud.minier@telecom-paris.fr
11
[PMM: fix checkpatch nits, remove commented out code]
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
13
---
12
hw/arm/xlnx-versal.c | 2 +-
14
tests/qtest/stm32l4x5_usart-test.c | 315 +++++++++++++++++++++++++++++
13
1 file changed, 1 insertion(+), 1 deletion(-)
15
tests/qtest/meson.build | 4 +-
14
16
2 files changed, 318 insertions(+), 1 deletion(-)
15
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
17
create mode 100644 tests/qtest/stm32l4x5_usart-test.c
18
19
diff --git a/tests/qtest/stm32l4x5_usart-test.c b/tests/qtest/stm32l4x5_usart-test.c
20
new file mode 100644
21
index XXXXXXX..XXXXXXX
22
--- /dev/null
23
+++ b/tests/qtest/stm32l4x5_usart-test.c
24
@@ -XXX,XX +XXX,XX @@
25
+/*
26
+ * QTest testcase for STML4X5_USART
27
+ *
28
+ * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
29
+ * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
30
+ *
31
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
32
+ * See the COPYING file in the top-level directory.
33
+ */
34
+
35
+#include "qemu/osdep.h"
36
+#include "libqtest.h"
37
+#include "hw/misc/stm32l4x5_rcc_internals.h"
38
+#include "hw/registerfields.h"
39
+
40
+#define RCC_BASE_ADDR 0x40021000
41
+/* Use USART 1 ADDR, assume the others work the same */
42
+#define USART1_BASE_ADDR 0x40013800
43
+
44
+/* See stm32l4x5_usart for definitions */
45
+REG32(CR1, 0x00)
46
+ FIELD(CR1, M1, 28, 1)
47
+ FIELD(CR1, OVER8, 15, 1)
48
+ FIELD(CR1, M0, 12, 1)
49
+ FIELD(CR1, PCE, 10, 1)
50
+ FIELD(CR1, TXEIE, 7, 1)
51
+ FIELD(CR1, RXNEIE, 5, 1)
52
+ FIELD(CR1, TE, 3, 1)
53
+ FIELD(CR1, RE, 2, 1)
54
+ FIELD(CR1, UE, 0, 1)
55
+REG32(CR2, 0x04)
56
+REG32(CR3, 0x08)
57
+ FIELD(CR3, OVRDIS, 12, 1)
58
+REG32(BRR, 0x0C)
59
+REG32(GTPR, 0x10)
60
+REG32(RTOR, 0x14)
61
+REG32(RQR, 0x18)
62
+REG32(ISR, 0x1C)
63
+ FIELD(ISR, TXE, 7, 1)
64
+ FIELD(ISR, RXNE, 5, 1)
65
+ FIELD(ISR, ORE, 3, 1)
66
+REG32(ICR, 0x20)
67
+REG32(RDR, 0x24)
68
+REG32(TDR, 0x28)
69
+
70
+#define NVIC_ISPR1 0XE000E204
71
+#define NVIC_ICPR1 0xE000E284
72
+#define USART1_IRQ 37
73
+
74
+static bool check_nvic_pending(QTestState *qts, unsigned int n)
75
+{
76
+ /* No USART interrupts are less than 32 */
77
+ assert(n > 32);
78
+ n -= 32;
79
+ return qtest_readl(qts, NVIC_ISPR1) & (1 << n);
80
+}
81
+
82
+static bool clear_nvic_pending(QTestState *qts, unsigned int n)
83
+{
84
+ /* No USART interrupts are less than 32 */
85
+ assert(n > 32);
86
+ n -= 32;
87
+ qtest_writel(qts, NVIC_ICPR1, (1 << n));
88
+ return true;
89
+}
90
+
91
+/*
92
+ * Wait indefinitely for the flag to be updated.
93
+ * If this is run on a slow CI runner,
94
+ * the meson harness will timeout after 10 minutes for us.
95
+ */
96
+static bool usart_wait_for_flag(QTestState *qts, uint32_t event_addr,
97
+ uint32_t flag)
98
+{
99
+ while (true) {
100
+ if ((qtest_readl(qts, event_addr) & flag)) {
101
+ return true;
102
+ }
103
+ g_usleep(1000);
104
+ }
105
+
106
+ return false;
107
+}
108
+
109
+static void usart_receive_string(QTestState *qts, int sock_fd, const char *in,
110
+ char *out)
111
+{
112
+ int i, in_len = strlen(in);
113
+
114
+ g_assert_true(send(sock_fd, in, in_len, 0) == in_len);
115
+ for (i = 0; i < in_len; i++) {
116
+ g_assert_true(usart_wait_for_flag(qts,
117
+ USART1_BASE_ADDR + A_ISR, R_ISR_RXNE_MASK));
118
+ out[i] = qtest_readl(qts, USART1_BASE_ADDR + A_RDR);
119
+ }
120
+ out[i] = '\0';
121
+}
122
+
123
+static void usart_send_string(QTestState *qts, const char *in)
124
+{
125
+ int i, in_len = strlen(in);
126
+
127
+ for (i = 0; i < in_len; i++) {
128
+ qtest_writel(qts, USART1_BASE_ADDR + A_TDR, in[i]);
129
+ g_assert_true(usart_wait_for_flag(qts,
130
+ USART1_BASE_ADDR + A_ISR, R_ISR_TXE_MASK));
131
+ }
132
+}
133
+
134
+/* Init the RCC clocks to run at 80 MHz */
135
+static void init_clocks(QTestState *qts)
136
+{
137
+ uint32_t value;
138
+
139
+ /* MSIRANGE can be set only when MSI is OFF or READY */
140
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CR), R_CR_MSION_MASK);
141
+
142
+ /* Clocking from MSI, in case MSI was not the default source */
143
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CFGR), 0);
144
+
145
+ /*
146
+ * Update PLL and set MSI as the source clock.
147
+ * PLLM = 1 --> 000
148
+ * PLLN = 40 --> 40
149
+ * PPLLR = 2 --> 00
150
+ * PLLDIV = unused, PLLP = unused (SAI3), PLLQ = unused (48M1)
151
+ * SRC = MSI --> 01
152
+ */
153
+ qtest_writel(qts, (RCC_BASE_ADDR + A_PLLCFGR), R_PLLCFGR_PLLREN_MASK |
154
+ (40 << R_PLLCFGR_PLLN_SHIFT) |
155
+ (0b01 << R_PLLCFGR_PLLSRC_SHIFT));
156
+
157
+ /* PLL activation */
158
+
159
+ value = qtest_readl(qts, (RCC_BASE_ADDR + A_CR));
160
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CR), value | R_CR_PLLON_MASK);
161
+
162
+ /* RCC_CFGR is OK by defaut */
163
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CFGR), 0);
164
+
165
+ /* CCIPR : no periph clock by default */
166
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CCIPR), 0);
167
+
168
+ /* Switches on the PLL clock source */
169
+ value = qtest_readl(qts, (RCC_BASE_ADDR + A_CFGR));
170
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CFGR), (value & ~R_CFGR_SW_MASK) |
171
+ (0b11 << R_CFGR_SW_SHIFT));
172
+
173
+ /* Enable SYSCFG clock enabled */
174
+ qtest_writel(qts, (RCC_BASE_ADDR + A_APB2ENR), R_APB2ENR_SYSCFGEN_MASK);
175
+
176
+ /* Enable the IO port B clock (See p.252) */
177
+ qtest_writel(qts, (RCC_BASE_ADDR + A_AHB2ENR), R_AHB2ENR_GPIOBEN_MASK);
178
+
179
+ /* Enable the clock for USART1 (cf p.259) */
180
+ /* We rewrite SYSCFGEN to not disable it */
181
+ qtest_writel(qts, (RCC_BASE_ADDR + A_APB2ENR),
182
+ R_APB2ENR_SYSCFGEN_MASK | R_APB2ENR_USART1EN_MASK);
183
+
184
+ /* TODO: Enable usart via gpio */
185
+
186
+ /* Set PCLK as the clock for USART1(cf p.272) i.e. reset both bits */
187
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CCIPR), 0);
188
+
189
+ /* Reset USART1 (see p.249) */
190
+ qtest_writel(qts, (RCC_BASE_ADDR + A_APB2RSTR), 1 << 14);
191
+ qtest_writel(qts, (RCC_BASE_ADDR + A_APB2RSTR), 0);
192
+}
193
+
194
+static void init_uart(QTestState *qts)
195
+{
196
+ uint32_t cr1;
197
+
198
+ init_clocks(qts);
199
+
200
+ /*
201
+ * For 115200 bauds, see p.1349.
202
+ * The clock has a frequency of 80Mhz,
203
+ * for 115200, we have to put a divider of 695 = 0x2B7.
204
+ */
205
+ qtest_writel(qts, (USART1_BASE_ADDR + A_BRR), 0x2B7);
206
+
207
+ /*
208
+ * Set the oversampling by 16,
209
+ * disable the parity control and
210
+ * set the word length to 8. (cf p.1377)
211
+ */
212
+ cr1 = qtest_readl(qts, (USART1_BASE_ADDR + A_CR1));
213
+ cr1 &= ~(R_CR1_M1_MASK | R_CR1_M0_MASK | R_CR1_OVER8_MASK | R_CR1_PCE_MASK);
214
+ qtest_writel(qts, (USART1_BASE_ADDR + A_CR1), cr1);
215
+
216
+ /* Enable the transmitter, the receiver and the USART. */
217
+ qtest_writel(qts, (USART1_BASE_ADDR + A_CR1),
218
+ R_CR1_UE_MASK | R_CR1_RE_MASK | R_CR1_TE_MASK);
219
+}
220
+
221
+static void test_write_read(void)
222
+{
223
+ QTestState *qts = qtest_init("-M b-l475e-iot01a");
224
+
225
+ /* Test that we can write and retrieve a value from the device */
226
+ qtest_writel(qts, USART1_BASE_ADDR + A_TDR, 0xFFFFFFFF);
227
+ const uint32_t tdr = qtest_readl(qts, USART1_BASE_ADDR + A_TDR);
228
+ g_assert_cmpuint(tdr, ==, 0x000001FF);
229
+}
230
+
231
+static void test_receive_char(void)
232
+{
233
+ int sock_fd;
234
+ uint32_t cr1;
235
+ QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd);
236
+
237
+ init_uart(qts);
238
+
239
+ /* Try without initializing IRQ */
240
+ g_assert_true(send(sock_fd, "a", 1, 0) == 1);
241
+ usart_wait_for_flag(qts, USART1_BASE_ADDR + A_ISR, R_ISR_RXNE_MASK);
242
+ g_assert_cmphex(qtest_readl(qts, USART1_BASE_ADDR + A_RDR), ==, 'a');
243
+ g_assert_false(check_nvic_pending(qts, USART1_IRQ));
244
+
245
+ /* Now with the IRQ */
246
+ cr1 = qtest_readl(qts, (USART1_BASE_ADDR + A_CR1));
247
+ cr1 |= R_CR1_RXNEIE_MASK;
248
+ qtest_writel(qts, USART1_BASE_ADDR + A_CR1, cr1);
249
+ g_assert_true(send(sock_fd, "b", 1, 0) == 1);
250
+ usart_wait_for_flag(qts, USART1_BASE_ADDR + A_ISR, R_ISR_RXNE_MASK);
251
+ g_assert_cmphex(qtest_readl(qts, USART1_BASE_ADDR + A_RDR), ==, 'b');
252
+ g_assert_true(check_nvic_pending(qts, USART1_IRQ));
253
+ clear_nvic_pending(qts, USART1_IRQ);
254
+
255
+ close(sock_fd);
256
+
257
+ qtest_quit(qts);
258
+}
259
+
260
+static void test_send_char(void)
261
+{
262
+ int sock_fd;
263
+ char s[1];
264
+ uint32_t cr1;
265
+ QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd);
266
+
267
+ init_uart(qts);
268
+
269
+ /* Try without initializing IRQ */
270
+ qtest_writel(qts, USART1_BASE_ADDR + A_TDR, 'c');
271
+ g_assert_true(recv(sock_fd, s, 1, 0) == 1);
272
+ g_assert_cmphex(s[0], ==, 'c');
273
+ g_assert_false(check_nvic_pending(qts, USART1_IRQ));
274
+
275
+ /* Now with the IRQ */
276
+ cr1 = qtest_readl(qts, (USART1_BASE_ADDR + A_CR1));
277
+ cr1 |= R_CR1_TXEIE_MASK;
278
+ qtest_writel(qts, USART1_BASE_ADDR + A_CR1, cr1);
279
+ qtest_writel(qts, USART1_BASE_ADDR + A_TDR, 'd');
280
+ g_assert_true(recv(sock_fd, s, 1, 0) == 1);
281
+ g_assert_cmphex(s[0], ==, 'd');
282
+ g_assert_true(check_nvic_pending(qts, USART1_IRQ));
283
+ clear_nvic_pending(qts, USART1_IRQ);
284
+
285
+ close(sock_fd);
286
+
287
+ qtest_quit(qts);
288
+}
289
+
290
+static void test_receive_str(void)
291
+{
292
+ int sock_fd;
293
+ char s[10];
294
+ QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd);
295
+
296
+ init_uart(qts);
297
+
298
+ usart_receive_string(qts, sock_fd, "hello", s);
299
+ g_assert_true(memcmp(s, "hello", 5) == 0);
300
+
301
+ close(sock_fd);
302
+
303
+ qtest_quit(qts);
304
+}
305
+
306
+static void test_send_str(void)
307
+{
308
+ int sock_fd;
309
+ char s[10];
310
+ QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd);
311
+
312
+ init_uart(qts);
313
+
314
+ usart_send_string(qts, "world");
315
+ g_assert_true(recv(sock_fd, s, 10, 0) == 5);
316
+ g_assert_true(memcmp(s, "world", 5) == 0);
317
+
318
+ close(sock_fd);
319
+
320
+ qtest_quit(qts);
321
+}
322
+
323
+int main(int argc, char **argv)
324
+{
325
+ int ret;
326
+
327
+ g_test_init(&argc, &argv, NULL);
328
+ g_test_set_nonfatal_assertions();
329
+
330
+ qtest_add_func("stm32l4x5/usart/write_read", test_write_read);
331
+ qtest_add_func("stm32l4x5/usart/receive_char", test_receive_char);
332
+ qtest_add_func("stm32l4x5/usart/send_char", test_send_char);
333
+ qtest_add_func("stm32l4x5/usart/receive_str", test_receive_str);
334
+ qtest_add_func("stm32l4x5/usart/send_str", test_send_str);
335
+ ret = g_test_run();
336
+
337
+ return ret;
338
+}
339
+
340
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
16
index XXXXXXX..XXXXXXX 100644
341
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/xlnx-versal.c
342
--- a/tests/qtest/meson.build
18
+++ b/hw/arm/xlnx-versal.c
343
+++ b/tests/qtest/meson.build
19
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s)
344
@@ -XXX,XX +XXX,XX @@ slow_qtests = {
20
345
'npcm7xx_pwm-test': 300,
21
obj = object_new(XLNX_VERSAL_ACPU_TYPE);
346
'npcm7xx_watchdog_timer-test': 120,
22
if (!obj) {
347
'qom-test' : 900,
23
- /* Secondary CPUs start in PSCI powered-down state */
348
+ 'stm32l4x5_usart-test' : 600,
24
error_report("Unable to create apu.cpu[%d] of type %s",
349
'test-hmp' : 240,
25
i, XLNX_VERSAL_ACPU_TYPE);
350
'pxe-test': 610,
26
exit(EXIT_FAILURE);
351
'prom-env-test': 360,
27
@@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s)
352
@@ -XXX,XX +XXX,XX @@ qtests_stm32l4x5 = \
28
object_property_set_int(obj, s->cfg.psci_conduit,
353
['stm32l4x5_exti-test',
29
"psci-conduit", &error_abort);
354
'stm32l4x5_syscfg-test',
30
if (i) {
355
'stm32l4x5_rcc-test',
31
+ /* Secondary CPUs start in PSCI powered-down state */
356
- 'stm32l4x5_gpio-test']
32
object_property_set_bool(obj, true,
357
+ 'stm32l4x5_gpio-test',
33
"start-powered-off", &error_abort);
358
+ 'stm32l4x5_usart-test']
34
}
359
360
qtests_arm = \
361
(config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \
35
--
362
--
36
2.20.1
363
2.34.1
37
364
38
365
diff view generated by jsdifflib
Deleted patch
1
Convert the VCMLA (vector) insns in the 3same extension group to
2
decodetree.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20200430181003.21682-5-peter.maydell@linaro.org
7
---
8
target/arm/neon-shared.decode | 11 ++++++++++
9
target/arm/translate-neon.inc.c | 37 +++++++++++++++++++++++++++++++++
10
target/arm/translate.c | 11 +---------
11
3 files changed, 49 insertions(+), 10 deletions(-)
12
13
diff --git a/target/arm/neon-shared.decode b/target/arm/neon-shared.decode
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/neon-shared.decode
16
+++ b/target/arm/neon-shared.decode
17
@@ -XXX,XX +XXX,XX @@
18
# More specifically, this covers:
19
# 2reg scalar ext: 0b1111_1110_xxxx_xxxx_xxxx_1x0x_xxxx_xxxx
20
# 3same ext: 0b1111_110x_xxxx_xxxx_xxxx_1x0x_xxxx_xxxx
21
+
22
+# VFP/Neon register fields; same as vfp.decode
23
+%vm_dp 5:1 0:4
24
+%vm_sp 0:4 5:1
25
+%vn_dp 7:1 16:4
26
+%vn_sp 16:4 7:1
27
+%vd_dp 22:1 12:4
28
+%vd_sp 12:4 22:1
29
+
30
+VCMLA 1111 110 rot:2 . 1 size:1 .... .... 1000 . q:1 . 0 .... \
31
+ vm=%vm_dp vn=%vn_dp vd=%vd_dp
32
diff --git a/target/arm/translate-neon.inc.c b/target/arm/translate-neon.inc.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/arm/translate-neon.inc.c
35
+++ b/target/arm/translate-neon.inc.c
36
@@ -XXX,XX +XXX,XX @@
37
#include "decode-neon-dp.inc.c"
38
#include "decode-neon-ls.inc.c"
39
#include "decode-neon-shared.inc.c"
40
+
41
+static bool trans_VCMLA(DisasContext *s, arg_VCMLA *a)
42
+{
43
+ int opr_sz;
44
+ TCGv_ptr fpst;
45
+ gen_helper_gvec_3_ptr *fn_gvec_ptr;
46
+
47
+ if (!dc_isar_feature(aa32_vcma, s)
48
+ || (!a->size && !dc_isar_feature(aa32_fp16_arith, s))) {
49
+ return false;
50
+ }
51
+
52
+ /* UNDEF accesses to D16-D31 if they don't exist. */
53
+ if (!dc_isar_feature(aa32_simd_r32, s) &&
54
+ ((a->vd | a->vn | a->vm) & 0x10)) {
55
+ return false;
56
+ }
57
+
58
+ if ((a->vn | a->vm | a->vd) & a->q) {
59
+ return false;
60
+ }
61
+
62
+ if (!vfp_access_check(s)) {
63
+ return true;
64
+ }
65
+
66
+ opr_sz = (1 + a->q) * 8;
67
+ fpst = get_fpstatus_ptr(1);
68
+ fn_gvec_ptr = a->size ? gen_helper_gvec_fcmlas : gen_helper_gvec_fcmlah;
69
+ tcg_gen_gvec_3_ptr(vfp_reg_offset(1, a->vd),
70
+ vfp_reg_offset(1, a->vn),
71
+ vfp_reg_offset(1, a->vm),
72
+ fpst, opr_sz, opr_sz, a->rot,
73
+ fn_gvec_ptr);
74
+ tcg_temp_free_ptr(fpst);
75
+ return true;
76
+}
77
diff --git a/target/arm/translate.c b/target/arm/translate.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/target/arm/translate.c
80
+++ b/target/arm/translate.c
81
@@ -XXX,XX +XXX,XX @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
82
bool is_long = false, q = extract32(insn, 6, 1);
83
bool ptr_is_env = false;
84
85
- if ((insn & 0xfe200f10) == 0xfc200800) {
86
- /* VCMLA -- 1111 110R R.1S .... .... 1000 ...0 .... */
87
- int size = extract32(insn, 20, 1);
88
- data = extract32(insn, 23, 2); /* rot */
89
- if (!dc_isar_feature(aa32_vcma, s)
90
- || (!size && !dc_isar_feature(aa32_fp16_arith, s))) {
91
- return 1;
92
- }
93
- fn_gvec_ptr = size ? gen_helper_gvec_fcmlas : gen_helper_gvec_fcmlah;
94
- } else if ((insn & 0xfea00f10) == 0xfc800800) {
95
+ if ((insn & 0xfea00f10) == 0xfc800800) {
96
/* VCADD -- 1111 110R 1.0S .... .... 1000 ...0 .... */
97
int size = extract32(insn, 20, 1);
98
data = extract32(insn, 24, 1); /* rot */
99
--
100
2.20.1
101
102
diff view generated by jsdifflib