1
First pullreq for arm of the 4.1 series, since I'm back from
1
Hi; here's the first arm pullreq for 9.1.
2
holiday now. This is mostly my M-profile FPU series and Philippe's
2
3
devices.h cleanup. I have a pile of other patchsets to work through
3
This includes the reset method function signature change, so it has
4
in my to-review folder, but 42 patches is definitely quite
4
some chance of compile failures due to merge conflicts if some other
5
big enough to send now...
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.
6
10
7
thanks
11
thanks
8
-- PMM
12
-- PMM
9
13
10
The following changes since commit 413a99a92c13ec408dcf2adaa87918dc81e890c8:
14
The following changes since commit 5da72194df36535d773c8bdc951529ecd5e31707:
11
15
12
Add Nios II semihosting support. (2019-04-29 16:09:51 +0100)
16
Merge tag 'pull-tcg-20240424' of https://gitlab.com/rth7680/qemu into staging (2024-04-24 15:51:49 -0700)
13
17
14
are available in the Git repository at:
18
are available in the Git repository at:
15
19
16
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190429
20
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240425
17
21
18
for you to fetch changes up to 437cc27ddfded3bbab6afd5ac1761e0e195edba7:
22
for you to fetch changes up to 214652da123e3821657a64691ee556281e9f6238:
19
23
20
hw/devices: Move SMSC 91C111 declaration into a new header (2019-04-29 17:57:21 +0100)
24
tests/qtest: Add tests for the STM32L4x5 USART (2024-04-25 10:21:59 +0100)
21
25
22
----------------------------------------------------------------
26
----------------------------------------------------------------
23
target-arm queue:
27
target-arm queue:
24
* remove "bag of random stuff" hw/devices.h header
28
* Implement FEAT_NMI and NMI support in the GICv3
25
* implement FPU for Cortex-M and enable it for Cortex-M4 and -M33
29
* hw/dma: avoid apparent overflow in soc_dma_set_request
26
* hw/dma: Compile the bcm2835_dma device as common object
30
* linux-user/flatload.c: Remove unused bFLT shared-library and ZFLAT code
27
* configure: Remove --source-path option
31
* Add ResetType argument to Resettable hold and exit phase methods
28
* hw/ssi/xilinx_spips: Avoid variable length array
32
* Add RESET_TYPE_SNAPSHOT_LOAD ResetType
29
* hw/arm/smmuv3: Remove SMMUNotifierNode
33
* Implement STM32L4x5 USART
30
34
31
----------------------------------------------------------------
35
----------------------------------------------------------------
32
Eric Auger (1):
36
Anastasia Belova (1):
33
hw/arm/smmuv3: Remove SMMUNotifierNode
37
hw/dma: avoid apparent overflow in soc_dma_set_request
34
38
35
Peter Maydell (28):
39
Arnaud Minier (5):
36
hw/ssi/xilinx_spips: Avoid variable length array
40
hw/char: Implement STM32L4x5 USART skeleton
37
configure: Remove --source-path option
41
hw/char/stm32l4x5_usart: Enable serial read and write
38
target/arm: Make sure M-profile FPSCR RES0 bits are not settable
42
hw/char/stm32l4x5_usart: Add options for serial parameters setting
39
hw/intc/armv7m_nvic: Allow reading of M-profile MVFR* registers
43
hw/arm: Add the USART to the stm32l4x5 SoC
40
target/arm: Implement dummy versions of M-profile FP-related registers
44
tests/qtest: Add tests for the STM32L4x5 USART
41
target/arm: Disable most VFP sysregs for M-profile
45
42
target/arm: Honour M-profile FP enable bits
46
Jinjie Ruan (22):
43
target/arm: Decode FP instructions for M profile
47
target/arm: Handle HCR_EL2 accesses for bits introduced with FEAT_NMI
44
target/arm: Clear CONTROL_S.SFPA in SG insn if FPU present
48
target/arm: Add PSTATE.ALLINT
45
target/arm: Handle SFPA and FPCA bits in reads and writes of CONTROL
49
target/arm: Add support for FEAT_NMI, Non-maskable Interrupt
46
target/arm/helper: don't return early for STKOF faults during stacking
50
target/arm: Implement ALLINT MSR (immediate)
47
target/arm: Handle floating point registers in exception entry
51
target/arm: Support MSR access to ALLINT
48
target/arm: Implement v7m_update_fpccr()
52
target/arm: Add support for Non-maskable Interrupt
49
target/arm: Clear CONTROL.SFPA in BXNS and BLXNS
53
target/arm: Add support for NMI in arm_phys_excp_target_el()
50
target/arm: Clean excReturn bits when tail chaining
54
target/arm: Handle IS/FS in ISR_EL1 for NMI, VINMI and VFNMI
51
target/arm: Allow for floating point in callee stack integrity check
55
target/arm: Handle PSTATE.ALLINT on taking an exception
52
target/arm: Handle floating point registers in exception return
56
hw/intc/arm_gicv3: Add external IRQ lines for NMI
53
target/arm: Move NS TBFLAG from bit 19 to bit 6
57
hw/arm/virt: Wire NMI and VINMI irq lines from GIC to CPU
54
target/arm: Overlap VECSTRIDE and XSCALE_CPAR TB flags
58
target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64()
55
target/arm: Set FPCCR.S when executing M-profile floating point insns
59
hw/intc/arm_gicv3: Add has-nmi property to GICv3 device
56
target/arm: Activate M-profile floating point context when FPCCR.ASPEN is set
60
hw/intc/arm_gicv3_kvm: Not set has-nmi=true for the KVM GICv3
57
target/arm: New helper function arm_v7m_mmu_idx_all()
61
hw/intc/arm_gicv3: Add irq non-maskable property
58
target/arm: New function armv7m_nvic_set_pending_lazyfp()
62
hw/intc/arm_gicv3_redist: Implement GICR_INMIR0
59
target/arm: Add lazy-FP-stacking support to v7m_stack_write()
63
hw/intc/arm_gicv3: Implement GICD_INMIR
60
target/arm: Implement M-profile lazy FP state preservation
64
hw/intc/arm_gicv3: Implement NMI interrupt priority
61
target/arm: Implement VLSTM for v7M CPUs with an FPU
65
hw/intc/arm_gicv3: Report the NMI interrupt in gicv3_cpuif_update()
62
target/arm: Implement VLLDM for v7M CPUs with an FPU
66
hw/intc/arm_gicv3: Report the VINMI interrupt
63
target/arm: Enable FPU for Cortex-M4 and Cortex-M33
67
target/arm: Add FEAT_NMI to max
64
68
hw/arm/virt: Enable NMI support in the GIC if the CPU has FEAT_NMI
65
Philippe Mathieu-Daudé (13):
69
66
hw/dma: Compile the bcm2835_dma device as common object
70
Peter Maydell (9):
67
hw/arm/aspeed: Use TYPE_TMP105/TYPE_PCA9552 instead of hardcoded string
71
hw/intc/arm_gicv3: Add NMI handling CPU interface registers
68
hw/arm/nseries: Use TYPE_TMP105 instead of hardcoded string
72
hw/intc/arm_gicv3: Handle icv_nmiar1_read() for icc_nmiar1_read()
69
hw/display/tc6393xb: Remove unused functions
73
linux-user/flatload.c: Remove unused bFLT shared-library and ZFLAT code
70
hw/devices: Move TC6393XB declarations into a new header
74
hw/misc: Don't special case RESET_TYPE_COLD in npcm7xx_clk, gcr
71
hw/devices: Move Blizzard declarations into a new header
75
allwinner-i2c, adm1272: Use device_cold_reset() for software-triggered reset
72
hw/devices: Move CBus declarations into a new header
76
scripts/coccinelle: New script to add ResetType to hold and exit phases
73
hw/devices: Move Gamepad declarations into a new header
77
hw, target: Add ResetType argument to hold and exit phase methods
74
hw/devices: Move TI touchscreen declarations into a new header
78
docs/devel/reset: Update to new API for hold and exit phase methods
75
hw/devices: Move LAN9118 declarations into a new header
79
reset: Add RESET_TYPE_SNAPSHOT_LOAD
76
hw/net/ne2000-isa: Add guards to the header
80
77
hw/net/lan9118: Export TYPE_LAN9118 and use it instead of hardcoded string
81
MAINTAINERS | 1 +
78
hw/devices: Move SMSC 91C111 declaration into a new header
82
docs/devel/reset.rst | 25 +-
79
83
docs/system/arm/b-l475e-iot01a.rst | 2 +-
80
configure | 10 +-
84
docs/system/arm/emulation.rst | 1 +
81
hw/dma/Makefile.objs | 2 +-
85
scripts/coccinelle/reset-type.cocci | 133 ++++++++
82
include/hw/arm/omap.h | 6 +-
86
hw/intc/gicv3_internal.h | 13 +
83
include/hw/arm/smmu-common.h | 8 +-
87
include/hw/arm/stm32l4x5_soc.h | 7 +
84
include/hw/devices.h | 62 ---
88
include/hw/char/stm32l4x5_usart.h | 67 ++++
85
include/hw/display/blizzard.h | 22 ++
89
include/hw/intc/arm_gic_common.h | 2 +
86
include/hw/display/tc6393xb.h | 24 ++
90
include/hw/intc/arm_gicv3_common.h | 14 +
87
include/hw/input/gamepad.h | 19 +
91
include/hw/resettable.h | 5 +-
88
include/hw/input/tsc2xxx.h | 36 ++
92
linux-user/flat.h | 5 +-
89
include/hw/misc/cbus.h | 32 ++
93
target/arm/cpu-features.h | 5 +
90
include/hw/net/lan9118.h | 21 +
94
target/arm/cpu-qom.h | 5 +-
91
include/hw/net/ne2000-isa.h | 6 +
95
target/arm/cpu.h | 9 +
92
include/hw/net/smc91c111.h | 19 +
96
target/arm/internals.h | 21 ++
93
include/qemu/typedefs.h | 1 -
97
target/arm/tcg/helper-a64.h | 1 +
94
target/arm/cpu.h | 95 ++++-
98
target/arm/tcg/a64.decode | 1 +
95
target/arm/helper.h | 5 +
99
hw/adc/npcm7xx_adc.c | 2 +-
96
target/arm/translate.h | 3 +
100
hw/arm/pxa2xx_pic.c | 2 +-
97
hw/arm/aspeed.c | 13 +-
101
hw/arm/smmu-common.c | 2 +-
98
hw/arm/exynos4_boards.c | 3 +-
102
hw/arm/smmuv3.c | 4 +-
99
hw/arm/gumstix.c | 2 +-
103
hw/arm/stellaris.c | 10 +-
100
hw/arm/integratorcp.c | 2 +-
104
hw/arm/stm32l4x5_soc.c | 83 ++++-
101
hw/arm/kzm.c | 2 +-
105
hw/arm/virt.c | 29 +-
102
hw/arm/mainstone.c | 2 +-
106
hw/audio/asc.c | 2 +-
103
hw/arm/mps2-tz.c | 3 +-
107
hw/char/cadence_uart.c | 2 +-
104
hw/arm/mps2.c | 2 +-
108
hw/char/sifive_uart.c | 2 +-
105
hw/arm/nseries.c | 7 +-
109
hw/char/stm32l4x5_usart.c | 637 ++++++++++++++++++++++++++++++++++++
106
hw/arm/palm.c | 2 +-
110
hw/core/cpu-common.c | 2 +-
107
hw/arm/realview.c | 3 +-
111
hw/core/qdev.c | 4 +-
108
hw/arm/smmu-common.c | 6 +-
112
hw/core/reset.c | 17 +-
109
hw/arm/smmuv3.c | 28 +-
113
hw/core/resettable.c | 8 +-
110
hw/arm/stellaris.c | 2 +-
114
hw/display/virtio-vga.c | 4 +-
111
hw/arm/tosa.c | 2 +-
115
hw/dma/soc_dma.c | 4 +-
112
hw/arm/versatilepb.c | 2 +-
116
hw/gpio/npcm7xx_gpio.c | 2 +-
113
hw/arm/vexpress.c | 2 +-
117
hw/gpio/pl061.c | 2 +-
114
hw/display/blizzard.c | 2 +-
118
hw/gpio/stm32l4x5_gpio.c | 2 +-
115
hw/display/tc6393xb.c | 18 +-
119
hw/hyperv/vmbus.c | 2 +-
116
hw/input/stellaris_input.c | 2 +-
120
hw/i2c/allwinner-i2c.c | 5 +-
117
hw/input/tsc2005.c | 2 +-
121
hw/i2c/npcm7xx_smbus.c | 2 +-
118
hw/input/tsc210x.c | 4 +-
122
hw/input/adb.c | 2 +-
119
hw/intc/armv7m_nvic.c | 261 +++++++++++++
123
hw/input/ps2.c | 12 +-
120
hw/misc/cbus.c | 2 +-
124
hw/intc/arm_gic_common.c | 2 +-
121
hw/net/lan9118.c | 3 +-
125
hw/intc/arm_gic_kvm.c | 4 +-
122
hw/net/smc91c111.c | 2 +-
126
hw/intc/arm_gicv3.c | 67 +++-
123
hw/ssi/xilinx_spips.c | 6 +-
127
hw/intc/arm_gicv3_common.c | 50 ++-
124
target/arm/cpu.c | 20 +
128
hw/intc/arm_gicv3_cpuif.c | 268 ++++++++++++++-
125
target/arm/helper.c | 873 +++++++++++++++++++++++++++++++++++++++---
129
hw/intc/arm_gicv3_dist.c | 36 ++
126
target/arm/machine.c | 16 +
130
hw/intc/arm_gicv3_its.c | 4 +-
127
target/arm/translate.c | 150 +++++++-
131
hw/intc/arm_gicv3_its_common.c | 2 +-
128
target/arm/vfp_helper.c | 8 +
132
hw/intc/arm_gicv3_its_kvm.c | 4 +-
129
MAINTAINERS | 7 +
133
hw/intc/arm_gicv3_kvm.c | 9 +-
130
50 files changed, 1595 insertions(+), 235 deletions(-)
134
hw/intc/arm_gicv3_redist.c | 22 ++
131
delete mode 100644 include/hw/devices.h
135
hw/intc/xics.c | 2 +-
132
create mode 100644 include/hw/display/blizzard.h
136
hw/m68k/q800-glue.c | 2 +-
133
create mode 100644 include/hw/display/tc6393xb.h
137
hw/misc/djmemc.c | 2 +-
134
create mode 100644 include/hw/input/gamepad.h
138
hw/misc/iosb.c | 2 +-
135
create mode 100644 include/hw/input/tsc2xxx.h
139
hw/misc/mac_via.c | 8 +-
136
create mode 100644 include/hw/misc/cbus.h
140
hw/misc/macio/cuda.c | 4 +-
137
create mode 100644 include/hw/net/lan9118.h
141
hw/misc/macio/pmu.c | 4 +-
138
create mode 100644 include/hw/net/smc91c111.h
142
hw/misc/mos6522.c | 2 +-
139
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
Handle floating point registers in exception return.
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
This corresponds to pseudocode functions ValidateExceptionReturn(),
3
ExceptionReturn(), PopStack() and ConsumeExcStackFrame().
4
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
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20190416125744.27770-16-peter.maydell@linaro.org
8
---
12
---
9
target/arm/helper.c | 142 +++++++++++++++++++++++++++++++++++++++++++-
13
target/arm/cpu-features.h | 5 +++++
10
1 file changed, 141 insertions(+), 1 deletion(-)
14
target/arm/helper.c | 8 +++++++-
15
2 files changed, 12 insertions(+), 1 deletion(-)
11
16
17
diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu-features.h
20
+++ b/target/arm/cpu-features.h
21
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_sme(const ARMISARegisters *id)
22
return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SME) != 0;
23
}
24
25
+static inline bool isar_feature_aa64_nmi(const ARMISARegisters *id)
26
+{
27
+ return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, NMI) != 0;
28
+}
29
+
30
static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id)
31
{
32
return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 1;
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
33
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.c
35
--- a/target/arm/helper.c
15
+++ b/target/arm/helper.c
36
+++ b/target/arm/helper.c
16
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
37
@@ -XXX,XX +XXX,XX @@ bool el_is_in_host(CPUARMState *env, int el)
17
bool rettobase = false;
38
static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri,
18
bool exc_secure = false;
39
uint64_t value)
19
bool return_to_secure;
40
{
20
+ bool ftype;
41
+ ARMCPU *cpu = env_archcpu(env);
21
+ bool restore_s16_s31;
42
uint64_t valid_mask = 0;
22
43
23
/* If we're not in Handler mode then jumps to magic exception-exit
44
/* FEAT_MOPS adds MSCEn and MCE2 */
24
* addresses don't have magic behaviour. However for the v8M
45
- if (cpu_isar_feature(aa64_mops, env_archcpu(env))) {
25
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
46
+ if (cpu_isar_feature(aa64_mops, cpu)) {
26
excret);
47
valid_mask |= HCRX_MSCEN | HCRX_MCE2;
27
}
48
}
28
49
29
+ ftype = excret & R_V7M_EXCRET_FTYPE_MASK;
50
+ /* FEAT_NMI adds TALLINT, VINMI and VFNMI */
30
+
51
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
31
+ if (!arm_feature(env, ARM_FEATURE_VFP) && !ftype) {
52
+ valid_mask |= HCRX_TALLINT | HCRX_VINMI | HCRX_VFNMI;
32
+ qemu_log_mask(LOG_GUEST_ERROR, "M profile: zero FTYPE in exception "
33
+ "exit PC value 0x%" PRIx32 " is UNPREDICTABLE "
34
+ "if FPU not present\n",
35
+ excret);
36
+ ftype = true;
37
+ }
53
+ }
38
+
54
+
39
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
55
/* Clear RES0 bits. */
40
/* EXC_RETURN.ES validation check (R_SMFL). We must do this before
56
env->cp15.hcrx_el2 = value & valid_mask;
41
* we pick which FAULTMASK to clear.
57
}
42
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
43
*/
44
write_v7m_control_spsel_for_secstate(env, return_to_sp_process, exc_secure);
45
46
+ /*
47
+ * Clear scratch FP values left in caller saved registers; this
48
+ * must happen before any kind of tail chaining.
49
+ */
50
+ if ((env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_CLRONRET_MASK) &&
51
+ (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) {
52
+ if (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK) {
53
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
54
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
55
+ qemu_log_mask(CPU_LOG_INT, "...taking SecureFault on existing "
56
+ "stackframe: error during lazy state deactivation\n");
57
+ v7m_exception_taken(cpu, excret, true, false);
58
+ return;
59
+ } else {
60
+ /* Clear s0..s15 and FPSCR */
61
+ int i;
62
+
63
+ for (i = 0; i < 16; i += 2) {
64
+ *aa32_vfp_dreg(env, i / 2) = 0;
65
+ }
66
+ vfp_set_fpscr(env, 0);
67
+ }
68
+ }
69
+
70
if (sfault) {
71
env->v7m.sfsr |= R_V7M_SFSR_INVER_MASK;
72
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
73
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
74
}
75
}
76
77
+ if (!ftype) {
78
+ /* FP present and we need to handle it */
79
+ if (!return_to_secure &&
80
+ (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK)) {
81
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
82
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
83
+ qemu_log_mask(CPU_LOG_INT,
84
+ "...taking SecureFault on existing stackframe: "
85
+ "Secure LSPACT set but exception return is "
86
+ "not to secure state\n");
87
+ v7m_exception_taken(cpu, excret, true, false);
88
+ return;
89
+ }
90
+
91
+ restore_s16_s31 = return_to_secure &&
92
+ (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK);
93
+
94
+ if (env->v7m.fpccr[return_to_secure] & R_V7M_FPCCR_LSPACT_MASK) {
95
+ /* State in FPU is still valid, just clear LSPACT */
96
+ env->v7m.fpccr[return_to_secure] &= ~R_V7M_FPCCR_LSPACT_MASK;
97
+ } else {
98
+ int i;
99
+ uint32_t fpscr;
100
+ bool cpacr_pass, nsacr_pass;
101
+
102
+ cpacr_pass = v7m_cpacr_pass(env, return_to_secure,
103
+ return_to_priv);
104
+ nsacr_pass = return_to_secure ||
105
+ extract32(env->v7m.nsacr, 10, 1);
106
+
107
+ if (!cpacr_pass) {
108
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
109
+ return_to_secure);
110
+ env->v7m.cfsr[return_to_secure] |= R_V7M_CFSR_NOCP_MASK;
111
+ qemu_log_mask(CPU_LOG_INT,
112
+ "...taking UsageFault on existing "
113
+ "stackframe: CPACR.CP10 prevents unstacking "
114
+ "FP regs\n");
115
+ v7m_exception_taken(cpu, excret, true, false);
116
+ return;
117
+ } else if (!nsacr_pass) {
118
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, true);
119
+ env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_INVPC_MASK;
120
+ qemu_log_mask(CPU_LOG_INT,
121
+ "...taking Secure UsageFault on existing "
122
+ "stackframe: NSACR.CP10 prevents unstacking "
123
+ "FP regs\n");
124
+ v7m_exception_taken(cpu, excret, true, false);
125
+ return;
126
+ }
127
+
128
+ for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) {
129
+ uint32_t slo, shi;
130
+ uint64_t dn;
131
+ uint32_t faddr = frameptr + 0x20 + 4 * i;
132
+
133
+ if (i >= 16) {
134
+ faddr += 8; /* Skip the slot for the FPSCR */
135
+ }
136
+
137
+ pop_ok = pop_ok &&
138
+ v7m_stack_read(cpu, &slo, faddr, mmu_idx) &&
139
+ v7m_stack_read(cpu, &shi, faddr + 4, mmu_idx);
140
+
141
+ if (!pop_ok) {
142
+ break;
143
+ }
144
+
145
+ dn = (uint64_t)shi << 32 | slo;
146
+ *aa32_vfp_dreg(env, i / 2) = dn;
147
+ }
148
+ pop_ok = pop_ok &&
149
+ v7m_stack_read(cpu, &fpscr, frameptr + 0x60, mmu_idx);
150
+ if (pop_ok) {
151
+ vfp_set_fpscr(env, fpscr);
152
+ }
153
+ if (!pop_ok) {
154
+ /*
155
+ * These regs are 0 if security extension present;
156
+ * otherwise merely UNKNOWN. We zero always.
157
+ */
158
+ for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) {
159
+ *aa32_vfp_dreg(env, i / 2) = 0;
160
+ }
161
+ vfp_set_fpscr(env, 0);
162
+ }
163
+ }
164
+ }
165
+ env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S],
166
+ V7M_CONTROL, FPCA, !ftype);
167
+
168
/* Commit to consuming the stack frame */
169
frameptr += 0x20;
170
+ if (!ftype) {
171
+ frameptr += 0x48;
172
+ if (restore_s16_s31) {
173
+ frameptr += 0x40;
174
+ }
175
+ }
176
/* Undo stack alignment (the SPREALIGN bit indicates that the original
177
* pre-exception SP was not 8-aligned and we added a padding word to
178
* align it, so we undo this by ORing in the bit that increases it
179
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
180
*frame_sp_p = frameptr;
181
}
182
/* This xpsr_write() will invalidate frame_sp_p as it may switch stack */
183
- xpsr_write(env, xpsr, ~XPSR_SPREALIGN);
184
+ xpsr_write(env, xpsr, ~(XPSR_SPREALIGN | XPSR_SFPA));
185
+
186
+ if (env->v7m.secure) {
187
+ bool sfpa = xpsr & XPSR_SFPA;
188
+
189
+ env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S],
190
+ V7M_CONTROL, SFPA, sfpa);
191
+ }
192
193
/* The restored xPSR exception field will be zero if we're
194
* resuming in Thread mode. If that doesn't match what the
195
--
58
--
196
2.20.1
59
2.34.1
197
198
diff view generated by jsdifflib
1
Move the NS TBFLAG down from bit 19 to bit 6, which has not
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
been used since commit c1e3781090b9d36c60 in 2015, when we
3
started passing the entire MMU index in the TB flags rather
4
than just a 'privilege level' bit.
5
2
6
This rearrangement is not strictly necessary, but means that
3
When PSTATE.ALLINT is set, an IRQ or FIQ interrupt that is targeted to
7
we can put M-profile-only bits next to each other rather
4
ELx, with or without superpriority is masked. As Richard suggested, place
8
than scattered across the flag word.
5
ALLINT bit in PSTATE in env->pstate.
9
6
7
In the pseudocode, AArch64.ExceptionReturn() calls SetPSTATEFromPSR(), which
8
treats PSTATE.ALLINT as one of the bits which are reinstated from SPSR to
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.
13
14
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
15
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Message-id: 20240407081733.3231820-3-ruanjinjie@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20190416125744.27770-17-peter.maydell@linaro.org
13
---
19
---
14
target/arm/cpu.h | 11 ++++++-----
20
target/arm/cpu.h | 1 +
15
1 file changed, 6 insertions(+), 5 deletions(-)
21
target/arm/tcg/helper-a64.c | 4 ++--
22
2 files changed, 3 insertions(+), 2 deletions(-)
16
23
17
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
18
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
26
--- a/target/arm/cpu.h
20
+++ b/target/arm/cpu.h
27
+++ b/target/arm/cpu.h
21
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1)
28
@@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu);
22
FIELD(TBFLAG_A32, THUMB, 0, 1)
29
#define PSTATE_D (1U << 9)
23
FIELD(TBFLAG_A32, VECLEN, 1, 3)
30
#define PSTATE_BTYPE (3U << 10)
24
FIELD(TBFLAG_A32, VECSTRIDE, 4, 2)
31
#define PSTATE_SSBS (1U << 12)
25
+/*
32
+#define PSTATE_ALLINT (1U << 13)
26
+ * Indicates whether cp register reads and writes by guest code should access
33
#define PSTATE_IL (1U << 20)
27
+ * the secure or nonsecure bank of banked registers; note that this is not
34
#define PSTATE_SS (1U << 21)
28
+ * the same thing as the current security state of the processor!
35
#define PSTATE_PAN (1U << 22)
29
+ */
36
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
30
+FIELD(TBFLAG_A32, NS, 6, 1)
37
index XXXXXXX..XXXXXXX 100644
31
FIELD(TBFLAG_A32, VFPEN, 7, 1)
38
--- a/target/arm/tcg/helper-a64.c
32
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
39
+++ b/target/arm/tcg/helper-a64.c
33
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
40
@@ -XXX,XX +XXX,XX @@ illegal_return:
34
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
41
*/
35
* checks on the other bits at runtime
42
env->pstate |= PSTATE_IL;
36
*/
43
env->pc = new_pc;
37
FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2)
44
- spsr &= PSTATE_NZCV | PSTATE_DAIF;
38
-/* Indicates whether cp register reads and writes by guest code should access
45
- spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF);
39
- * the secure or nonsecure bank of banked registers; note that this is not
46
+ spsr &= PSTATE_NZCV | PSTATE_DAIF | PSTATE_ALLINT;
40
- * the same thing as the current security state of the processor!
47
+ spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF | PSTATE_ALLINT);
41
- */
48
pstate_write(env, spsr);
42
-FIELD(TBFLAG_A32, NS, 19, 1)
49
if (!arm_singlestep_active(env)) {
43
/* For M profile only, Handler (ie not Thread) mode */
50
env->pstate &= ~PSTATE_SS;
44
FIELD(TBFLAG_A32, HANDLER, 21, 1)
45
/* For M profile only, whether we should generate stack-limit checks */
46
--
51
--
47
2.20.1
52
2.34.1
48
49
diff view generated by jsdifflib
1
Currently the code in v7m_push_stack() which detects a violation
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
of the v8M stack limit simply returns early if it does so. This
3
is OK for the current integer-only code, but won't work for the
4
floating point handling we're about to add. We need to continue
5
executing the rest of the function so that we check for other
6
exceptions like not having permission to use the FPU and so
7
that we correctly set the FPCCR state if we are doing lazy
8
stacking. Refactor to avoid the early return.
9
2
3
Add support for FEAT_NMI. NMI (FEAT_NMI) is an mandatory feature in
4
ARMv8.8-A and ARM v9.3-A.
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-4-ruanjinjie@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20190416125744.27770-10-peter.maydell@linaro.org
13
---
11
---
14
target/arm/helper.c | 23 ++++++++++++++++++-----
12
target/arm/internals.h | 3 +++
15
1 file changed, 18 insertions(+), 5 deletions(-)
13
1 file changed, 3 insertions(+)
16
14
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
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/target/arm/helper.c
17
--- a/target/arm/internals.h
20
+++ b/target/arm/helper.c
18
+++ b/target/arm/internals.h
21
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
19
@@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id)
22
* should ignore further stack faults trying to process
20
if (isar_feature_aa64_mte(id)) {
23
* that derived exception.)
21
valid |= PSTATE_TCO;
24
*/
25
- bool stacked_ok;
26
+ bool stacked_ok = true, limitviol = false;
27
CPUARMState *env = &cpu->env;
28
uint32_t xpsr = xpsr_read(env);
29
uint32_t frameptr = env->regs[13];
30
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
31
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
32
env->v7m.secure);
33
env->regs[13] = limit;
34
- return true;
35
+ /*
36
+ * We won't try to perform any further memory accesses but
37
+ * we must continue through the following code to check for
38
+ * permission faults during FPU state preservation, and we
39
+ * must update FPCCR if lazy stacking is enabled.
40
+ */
41
+ limitviol = true;
42
+ stacked_ok = false;
43
}
44
}
22
}
45
23
+ if (isar_feature_aa64_nmi(id)) {
46
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
24
+ valid |= PSTATE_ALLINT;
47
* (which may be taken in preference to the one we started with
48
* if it has higher priority).
49
*/
50
- stacked_ok =
51
+ stacked_ok = stacked_ok &&
52
v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) &&
53
v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) &&
54
v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) &&
55
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
56
v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) &&
57
v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false);
58
59
- /* Update SP regardless of whether any of the stack accesses failed. */
60
- env->regs[13] = frameptr;
61
+ /*
62
+ * If we broke a stack limit then SP was already updated earlier;
63
+ * otherwise we update SP regardless of whether any of the stack
64
+ * accesses failed or we took some other kind of fault.
65
+ */
66
+ if (!limitviol) {
67
+ env->regs[13] = frameptr;
68
+ }
25
+ }
69
26
70
return !stacked_ok;
27
return valid;
71
}
28
}
72
--
29
--
73
2.20.1
30
2.34.1
74
75
diff view generated by jsdifflib
1
Implement the VLLDM instruction for v7M for the FPU present cas.
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Add ALLINT MSR (immediate) to decodetree, in which the CRm is 0b000x. The
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.
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
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190416125744.27770-26-peter.maydell@linaro.org
6
---
13
---
7
target/arm/helper.h | 1 +
14
target/arm/tcg/helper-a64.h | 1 +
8
target/arm/helper.c | 54 ++++++++++++++++++++++++++++++++++++++++++
15
target/arm/tcg/a64.decode | 1 +
9
target/arm/translate.c | 2 +-
16
target/arm/tcg/helper-a64.c | 12 ++++++++++++
10
3 files changed, 56 insertions(+), 1 deletion(-)
17
target/arm/tcg/translate-a64.c | 19 +++++++++++++++++++
18
4 files changed, 33 insertions(+)
11
19
12
diff --git a/target/arm/helper.h b/target/arm/helper.h
20
diff --git a/target/arm/tcg/helper-a64.h b/target/arm/tcg/helper-a64.h
13
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.h
22
--- a/target/arm/tcg/helper-a64.h
15
+++ b/target/arm/helper.h
23
+++ b/target/arm/tcg/helper-a64.h
16
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32)
24
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64)
17
DEF_HELPER_1(v7m_preserve_fp_state, void, env)
25
DEF_HELPER_2(msr_i_spsel, void, env, i32)
18
26
DEF_HELPER_2(msr_i_daifset, void, env, i32)
19
DEF_HELPER_2(v7m_vlstm, void, env, i32)
27
DEF_HELPER_2(msr_i_daifclear, void, env, i32)
20
+DEF_HELPER_2(v7m_vlldm, void, env, i32)
28
+DEF_HELPER_1(msr_set_allint_el1, void, env)
21
29
DEF_HELPER_3(vfp_cmph_a64, i64, f16, f16, ptr)
22
DEF_HELPER_2(v8m_stackcheck, void, env, i32)
30
DEF_HELPER_3(vfp_cmpeh_a64, i64, f16, f16, ptr)
23
31
DEF_HELPER_3(vfp_cmps_a64, i64, f32, f32, ptr)
24
diff --git a/target/arm/helper.c b/target/arm/helper.c
32
diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode
25
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/helper.c
34
--- a/target/arm/tcg/a64.decode
27
+++ b/target/arm/helper.c
35
+++ b/target/arm/tcg/a64.decode
28
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
36
@@ -XXX,XX +XXX,XX @@ MSR_i_DIT 1101 0101 0000 0 011 0100 .... 010 11111 @msr_i
29
g_assert_not_reached();
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);
30
}
50
}
31
51
32
+void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
52
+void HELPER(msr_set_allint_el1)(CPUARMState *env)
33
+{
53
+{
34
+ /* translate.c should never generate calls here in user-only mode */
54
+ /* ALLINT update to PSTATE. */
35
+ g_assert_not_reached();
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
+ }
60
+
61
+ env->pstate |= PSTATE_ALLINT;
36
+}
62
+}
37
+
63
+
38
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
64
static void daif_check(CPUARMState *env, uint32_t op,
65
uint32_t imm, uintptr_t ra)
39
{
66
{
40
/* The TT instructions can be used by unprivileged code, but in
67
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
41
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
68
index XXXXXXX..XXXXXXX 100644
42
env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
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)
72
return true;
43
}
73
}
44
74
45
+void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
75
+static bool trans_MSR_i_ALLINT(DisasContext *s, arg_i *a)
46
+{
76
+{
47
+ /* fptr is the value of Rn, the frame pointer we load the FP regs from */
77
+ if (!dc_isar_feature(aa64_nmi, s) || s->current_el == 0) {
48
+ assert(env->v7m.secure);
78
+ return false;
49
+
50
+ if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) {
51
+ return;
52
+ }
79
+ }
53
+
80
+
54
+ /* Check access to the coprocessor is permitted */
81
+ if (a->imm == 0) {
55
+ if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) {
82
+ clear_pstate_bits(PSTATE_ALLINT);
56
+ raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC());
83
+ } else if (s->current_el > 1) {
84
+ set_pstate_bits(PSTATE_ALLINT);
85
+ } else {
86
+ gen_helper_msr_set_allint_el1(tcg_env);
57
+ }
87
+ }
58
+
88
+
59
+ if (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK) {
89
+ /* Exit the cpu loop to re-evaluate pending IRQs. */
60
+ /* State in FP is still valid */
90
+ s->base.is_jmp = DISAS_UPDATE_EXIT;
61
+ env->v7m.fpccr[M_REG_S] &= ~R_V7M_FPCCR_LSPACT_MASK;
91
+ return true;
62
+ } else {
63
+ bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK;
64
+ int i;
65
+ uint32_t fpscr;
66
+
67
+ if (fptr & 7) {
68
+ raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC());
69
+ }
70
+
71
+ for (i = 0; i < (ts ? 32 : 16); i += 2) {
72
+ uint32_t slo, shi;
73
+ uint64_t dn;
74
+ uint32_t faddr = fptr + 4 * i;
75
+
76
+ if (i >= 16) {
77
+ faddr += 8; /* skip the slot for the FPSCR */
78
+ }
79
+
80
+ slo = cpu_ldl_data(env, faddr);
81
+ shi = cpu_ldl_data(env, faddr + 4);
82
+
83
+ dn = (uint64_t) shi << 32 | slo;
84
+ *aa32_vfp_dreg(env, i / 2) = dn;
85
+ }
86
+ fpscr = cpu_ldl_data(env, fptr + 0x40);
87
+ vfp_set_fpscr(env, fpscr);
88
+ }
89
+
90
+ env->v7m.control[M_REG_S] |= R_V7M_CONTROL_FPCA_MASK;
91
+}
92
+}
92
+
93
+
93
static bool v7m_push_stack(ARMCPU *cpu)
94
static bool trans_MSR_i_SVCR(DisasContext *s, arg_MSR_i_SVCR *a)
94
{
95
{
95
/* Do the "set up stack frame" part of exception entry,
96
if (!dc_isar_feature(aa64_sme, s) || a->mask == 0) {
96
diff --git a/target/arm/translate.c b/target/arm/translate.c
97
index XXXXXXX..XXXXXXX 100644
98
--- a/target/arm/translate.c
99
+++ b/target/arm/translate.c
100
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
101
TCGv_i32 fptr = load_reg(s, rn);
102
103
if (extract32(insn, 20, 1)) {
104
- /* VLLDM */
105
+ gen_helper_v7m_vlldm(cpu_env, fptr);
106
} else {
107
gen_helper_v7m_vlstm(cpu_env, fptr);
108
}
109
--
97
--
110
2.20.1
98
2.34.1
111
112
diff view generated by jsdifflib
1
Pushing registers to the stack for v7M needs to handle three cases:
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
* the "normal" case where we pend exceptions
3
* an "ignore faults" case where we set FSR bits but
4
do not pend exceptions (this is used when we are
5
handling some kinds of derived exception on exception entry)
6
* a "lazy FP stacking" case, where different FSR bits
7
are set and the exception is pended differently
8
2
9
Implement this by changing the existing flag argument that
3
Support ALLINT msr access as follow:
10
tells us whether to ignore faults or not into an enum that
4
    mrs <xt>, ALLINT    // read allint
11
specifies which of the 3 modes we should handle.
5
    msr ALLINT, <xt>    // write allint with imm
12
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
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20190416125744.27770-23-peter.maydell@linaro.org
16
---
12
---
17
target/arm/helper.c | 118 +++++++++++++++++++++++++++++---------------
13
target/arm/helper.c | 35 +++++++++++++++++++++++++++++++++++
18
1 file changed, 79 insertions(+), 39 deletions(-)
14
1 file changed, 35 insertions(+)
19
15
20
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
21
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/helper.c
18
--- a/target/arm/helper.c
23
+++ b/target/arm/helper.c
19
+++ b/target/arm/helper.c
24
@@ -XXX,XX +XXX,XX @@ static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv)
20
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo rme_mte_reginfo[] = {
21
.opc0 = 1, .opc1 = 6, .crn = 7, .crm = 14, .opc2 = 5,
22
.access = PL3_W, .type = ARM_CP_NOP },
23
};
24
+
25
+static void aa64_allint_write(CPUARMState *env, const ARMCPRegInfo *ri,
26
+ uint64_t value)
27
+{
28
+ env->pstate = (env->pstate & ~PSTATE_ALLINT) | (value & PSTATE_ALLINT);
29
+}
30
+
31
+static uint64_t aa64_allint_read(CPUARMState *env, const ARMCPRegInfo *ri)
32
+{
33
+ return env->pstate & PSTATE_ALLINT;
34
+}
35
+
36
+static CPAccessResult aa64_allint_access(CPUARMState *env,
37
+ const ARMCPRegInfo *ri, bool isread)
38
+{
39
+ if (!isread && arm_current_el(env) == 1 &&
40
+ (arm_hcrx_el2_eff(env) & HCRX_TALLINT)) {
41
+ return CP_ACCESS_TRAP_EL2;
42
+ }
43
+ return CP_ACCESS_OK;
44
+}
45
+
46
+static const ARMCPRegInfo nmi_reginfo[] = {
47
+ { .name = "ALLINT", .state = ARM_CP_STATE_AA64,
48
+ .opc0 = 3, .opc1 = 0, .opc2 = 0, .crn = 4, .crm = 3,
49
+ .type = ARM_CP_NO_RAW,
50
+ .access = PL1_RW, .accessfn = aa64_allint_access,
51
+ .fieldoffset = offsetof(CPUARMState, pstate),
52
+ .writefn = aa64_allint_write, .readfn = aa64_allint_read,
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);
25
}
61
}
26
}
27
28
+/*
29
+ * What kind of stack write are we doing? This affects how exceptions
30
+ * generated during the stacking are treated.
31
+ */
32
+typedef enum StackingMode {
33
+ STACK_NORMAL,
34
+ STACK_IGNFAULTS,
35
+ STACK_LAZYFP,
36
+} StackingMode;
37
+
62
+
38
static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
63
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
39
- ARMMMUIdx mmu_idx, bool ignfault)
64
+ define_arm_cp_regs(cpu, nmi_reginfo);
40
+ ARMMMUIdx mmu_idx, StackingMode mode)
65
+ }
41
{
66
#endif
42
CPUState *cs = CPU(cpu);
67
43
CPUARMState *env = &cpu->env;
68
if (cpu_isar_feature(any_predinv, cpu)) {
44
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
45
&attrs, &prot, &page_size, &fi, NULL)) {
46
/* MPU/SAU lookup failed */
47
if (fi.type == ARMFault_QEMU_SFault) {
48
- qemu_log_mask(CPU_LOG_INT,
49
- "...SecureFault with SFSR.AUVIOL during stacking\n");
50
- env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK | R_V7M_SFSR_SFARVALID_MASK;
51
+ if (mode == STACK_LAZYFP) {
52
+ qemu_log_mask(CPU_LOG_INT,
53
+ "...SecureFault with SFSR.LSPERR "
54
+ "during lazy stacking\n");
55
+ env->v7m.sfsr |= R_V7M_SFSR_LSPERR_MASK;
56
+ } else {
57
+ qemu_log_mask(CPU_LOG_INT,
58
+ "...SecureFault with SFSR.AUVIOL "
59
+ "during stacking\n");
60
+ env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK;
61
+ }
62
+ env->v7m.sfsr |= R_V7M_SFSR_SFARVALID_MASK;
63
env->v7m.sfar = addr;
64
exc = ARMV7M_EXCP_SECURE;
65
exc_secure = false;
66
} else {
67
- qemu_log_mask(CPU_LOG_INT, "...MemManageFault with CFSR.MSTKERR\n");
68
- env->v7m.cfsr[secure] |= R_V7M_CFSR_MSTKERR_MASK;
69
+ if (mode == STACK_LAZYFP) {
70
+ qemu_log_mask(CPU_LOG_INT,
71
+ "...MemManageFault with CFSR.MLSPERR\n");
72
+ env->v7m.cfsr[secure] |= R_V7M_CFSR_MLSPERR_MASK;
73
+ } else {
74
+ qemu_log_mask(CPU_LOG_INT,
75
+ "...MemManageFault with CFSR.MSTKERR\n");
76
+ env->v7m.cfsr[secure] |= R_V7M_CFSR_MSTKERR_MASK;
77
+ }
78
exc = ARMV7M_EXCP_MEM;
79
exc_secure = secure;
80
}
81
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
82
attrs, &txres);
83
if (txres != MEMTX_OK) {
84
/* BusFault trying to write the data */
85
- qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.STKERR\n");
86
- env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_STKERR_MASK;
87
+ if (mode == STACK_LAZYFP) {
88
+ qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.LSPERR\n");
89
+ env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_LSPERR_MASK;
90
+ } else {
91
+ qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.STKERR\n");
92
+ env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_STKERR_MASK;
93
+ }
94
exc = ARMV7M_EXCP_BUS;
95
exc_secure = false;
96
goto pend_fault;
97
@@ -XXX,XX +XXX,XX @@ pend_fault:
98
* later if we have two derived exceptions.
99
* The only case when we must not pend the exception but instead
100
* throw it away is if we are doing the push of the callee registers
101
- * and we've already generated a derived exception. Even in this
102
- * case we will still update the fault status registers.
103
+ * and we've already generated a derived exception (this is indicated
104
+ * by the caller passing STACK_IGNFAULTS). Even in this case we will
105
+ * still update the fault status registers.
106
*/
107
- if (!ignfault) {
108
+ switch (mode) {
109
+ case STACK_NORMAL:
110
armv7m_nvic_set_pending_derived(env->nvic, exc, exc_secure);
111
+ break;
112
+ case STACK_LAZYFP:
113
+ armv7m_nvic_set_pending_lazyfp(env->nvic, exc, exc_secure);
114
+ break;
115
+ case STACK_IGNFAULTS:
116
+ break;
117
}
118
return false;
119
}
120
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
121
uint32_t limit;
122
bool want_psp;
123
uint32_t sig;
124
+ StackingMode smode = ignore_faults ? STACK_IGNFAULTS : STACK_NORMAL;
125
126
if (dotailchain) {
127
bool mode = lr & R_V7M_EXCRET_MODE_MASK;
128
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
129
*/
130
sig = v7m_integrity_sig(env, lr);
131
stacked_ok =
132
- v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) &&
133
- v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx,
134
- ignore_faults) &&
135
- v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx,
136
- ignore_faults) &&
137
- v7m_stack_write(cpu, frameptr + 0x10, env->regs[6], mmu_idx,
138
- ignore_faults) &&
139
- v7m_stack_write(cpu, frameptr + 0x14, env->regs[7], mmu_idx,
140
- ignore_faults) &&
141
- v7m_stack_write(cpu, frameptr + 0x18, env->regs[8], mmu_idx,
142
- ignore_faults) &&
143
- v7m_stack_write(cpu, frameptr + 0x1c, env->regs[9], mmu_idx,
144
- ignore_faults) &&
145
- v7m_stack_write(cpu, frameptr + 0x20, env->regs[10], mmu_idx,
146
- ignore_faults) &&
147
- v7m_stack_write(cpu, frameptr + 0x24, env->regs[11], mmu_idx,
148
- ignore_faults);
149
+ v7m_stack_write(cpu, frameptr, sig, mmu_idx, smode) &&
150
+ v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, smode) &&
151
+ v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, smode) &&
152
+ v7m_stack_write(cpu, frameptr + 0x10, env->regs[6], mmu_idx, smode) &&
153
+ v7m_stack_write(cpu, frameptr + 0x14, env->regs[7], mmu_idx, smode) &&
154
+ v7m_stack_write(cpu, frameptr + 0x18, env->regs[8], mmu_idx, smode) &&
155
+ v7m_stack_write(cpu, frameptr + 0x1c, env->regs[9], mmu_idx, smode) &&
156
+ v7m_stack_write(cpu, frameptr + 0x20, env->regs[10], mmu_idx, smode) &&
157
+ v7m_stack_write(cpu, frameptr + 0x24, env->regs[11], mmu_idx, smode);
158
159
/* Update SP regardless of whether any of the stack accesses failed. */
160
*frame_sp_p = frameptr;
161
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
162
* if it has higher priority).
163
*/
164
stacked_ok = stacked_ok &&
165
- v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) &&
166
- v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) &&
167
- v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) &&
168
- v7m_stack_write(cpu, frameptr + 12, env->regs[3], mmu_idx, false) &&
169
- v7m_stack_write(cpu, frameptr + 16, env->regs[12], mmu_idx, false) &&
170
- v7m_stack_write(cpu, frameptr + 20, env->regs[14], mmu_idx, false) &&
171
- v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) &&
172
- v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false);
173
+ v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, STACK_NORMAL) &&
174
+ v7m_stack_write(cpu, frameptr + 4, env->regs[1],
175
+ mmu_idx, STACK_NORMAL) &&
176
+ v7m_stack_write(cpu, frameptr + 8, env->regs[2],
177
+ mmu_idx, STACK_NORMAL) &&
178
+ v7m_stack_write(cpu, frameptr + 12, env->regs[3],
179
+ mmu_idx, STACK_NORMAL) &&
180
+ v7m_stack_write(cpu, frameptr + 16, env->regs[12],
181
+ mmu_idx, STACK_NORMAL) &&
182
+ v7m_stack_write(cpu, frameptr + 20, env->regs[14],
183
+ mmu_idx, STACK_NORMAL) &&
184
+ v7m_stack_write(cpu, frameptr + 24, env->regs[15],
185
+ mmu_idx, STACK_NORMAL) &&
186
+ v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, STACK_NORMAL);
187
188
if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) {
189
/* FPU is active, try to save its registers */
190
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
191
faddr += 8; /* skip the slot for the FPSCR */
192
}
193
stacked_ok = stacked_ok &&
194
- v7m_stack_write(cpu, faddr, slo, mmu_idx, false) &&
195
- v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, false);
196
+ v7m_stack_write(cpu, faddr, slo,
197
+ mmu_idx, STACK_NORMAL) &&
198
+ v7m_stack_write(cpu, faddr + 4, shi,
199
+ mmu_idx, STACK_NORMAL);
200
}
201
stacked_ok = stacked_ok &&
202
v7m_stack_write(cpu, frameptr + 0x60,
203
- vfp_get_fpscr(env), mmu_idx, false);
204
+ vfp_get_fpscr(env), mmu_idx, STACK_NORMAL);
205
if (cpacr_pass) {
206
for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) {
207
*aa32_vfp_dreg(env, i / 2) = 0;
208
--
69
--
209
2.20.1
70
2.34.1
210
211
diff view generated by jsdifflib
1
The M-profile architecture floating point system supports
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
lazy FP state preservation, where FP registers are not
3
pushed to the stack when an exception occurs but are instead
4
only saved if and when the first FP instruction in the exception
5
handler is executed. Implement this in QEMU, corresponding
6
to the check of LSPACT in the pseudocode ExecuteFPCheck().
7
2
3
This only implements the external delivery method via the GICv3.
4
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20240407081733.3231820-7-ruanjinjie@huawei.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20190416125744.27770-24-peter.maydell@linaro.org
11
---
10
---
12
target/arm/cpu.h | 3 ++
11
target/arm/cpu-qom.h | 5 +-
13
target/arm/helper.h | 2 +
12
target/arm/cpu.h | 6 ++
14
target/arm/translate.h | 1 +
13
target/arm/internals.h | 18 +++++
15
target/arm/helper.c | 112 +++++++++++++++++++++++++++++++++++++++++
14
target/arm/cpu.c | 147 ++++++++++++++++++++++++++++++++++++++---
16
target/arm/translate.c | 22 ++++++++
15
target/arm/helper.c | 33 +++++++--
17
5 files changed, 140 insertions(+)
16
5 files changed, 193 insertions(+), 16 deletions(-)
18
17
18
diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/cpu-qom.h
21
+++ b/target/arm/cpu-qom.h
22
@@ -XXX,XX +XXX,XX @@ DECLARE_CLASS_CHECKERS(AArch64CPUClass, AARCH64_CPU,
23
#define ARM_CPU_TYPE_SUFFIX "-" TYPE_ARM_CPU
24
#define ARM_CPU_TYPE_NAME(name) (name ARM_CPU_TYPE_SUFFIX)
25
26
-/* Meanings of the ARMCPU object's four inbound GPIO lines */
27
+/* Meanings of the ARMCPU object's seven inbound GPIO lines */
28
#define ARM_CPU_IRQ 0
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
19
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
20
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/cpu.h
40
--- a/target/arm/cpu.h
22
+++ b/target/arm/cpu.h
41
+++ b/target/arm/cpu.h
23
@@ -XXX,XX +XXX,XX @@
42
@@ -XXX,XX +XXX,XX @@
24
#define EXCP_NOCP 17 /* v7M NOCP UsageFault */
43
#define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */
25
#define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */
44
#define EXCP_VSERR 24
26
#define EXCP_STKOF 19 /* v8M STKOF UsageFault */
45
#define EXCP_GPC 25 /* v9 Granule Protection Check Fault */
27
+#define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */
46
+#define EXCP_NMI 26
47
+#define EXCP_VINMI 27
48
+#define EXCP_VFNMI 28
28
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
49
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
29
50
30
#define ARMV7M_EXCP_RESET 1
51
#define ARMV7M_EXCP_RESET 1
31
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
52
@@ -XXX,XX +XXX,XX @@
32
FIELD(TBFLAG_A32, VFPEN, 7, 1)
53
#define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_EXT_2
33
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
54
#define CPU_INTERRUPT_VFIQ CPU_INTERRUPT_TGT_EXT_3
34
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
55
#define CPU_INTERRUPT_VSERR CPU_INTERRUPT_TGT_INT_0
35
+/* For M profile only, set if FPCCR.LSPACT is set */
56
+#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_4
36
+FIELD(TBFLAG_A32, LSPACT, 18, 1)
57
+#define CPU_INTERRUPT_VINMI CPU_INTERRUPT_TGT_EXT_0
37
/* For M profile only, set if we must create a new FP context */
58
+#define CPU_INTERRUPT_VFNMI CPU_INTERRUPT_TGT_INT_1
38
FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1)
59
39
/* For M profile only, set if FPCCR.S does not match current security state */
60
/* The usual mapping for an AArch64 system register to its AArch32
40
diff --git a/target/arm/helper.h b/target/arm/helper.h
61
* counterpart is for the 32 bit world to have access to the lower
62
diff --git a/target/arm/internals.h b/target/arm/internals.h
41
index XXXXXXX..XXXXXXX 100644
63
index XXXXXXX..XXXXXXX 100644
42
--- a/target/arm/helper.h
64
--- a/target/arm/internals.h
43
+++ b/target/arm/helper.h
65
+++ b/target/arm/internals.h
44
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(v7m_blxns, void, env, i32)
66
@@ -XXX,XX +XXX,XX @@ void arm_cpu_update_virq(ARMCPU *cpu);
45
67
*/
46
DEF_HELPER_3(v7m_tt, i32, env, i32, i32)
68
void arm_cpu_update_vfiq(ARMCPU *cpu);
47
69
48
+DEF_HELPER_1(v7m_preserve_fp_state, void, env)
70
+/**
49
+
71
+ * arm_cpu_update_vinmi: Update CPU_INTERRUPT_VINMI bit in cs->interrupt_request
50
DEF_HELPER_2(v8m_stackcheck, void, env, i32)
72
+ *
51
73
+ * Update the CPU_INTERRUPT_VINMI bit in cs->interrupt_request, following
52
DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32)
74
+ * a change to either the input VNMI line from the GIC or the HCRX_EL2.VINMI.
53
diff --git a/target/arm/translate.h b/target/arm/translate.h
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
90
*
91
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
54
index XXXXXXX..XXXXXXX 100644
92
index XXXXXXX..XXXXXXX 100644
55
--- a/target/arm/translate.h
93
--- a/target/arm/cpu.c
56
+++ b/target/arm/translate.h
94
+++ b/target/arm/cpu.c
57
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
95
@@ -XXX,XX +XXX,XX @@ void arm_restore_state_to_opc(CPUState *cs,
58
bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */
96
}
59
bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */
97
#endif /* CONFIG_TCG */
60
bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */
98
61
+ bool v7m_lspact; /* FPCCR.LSPACT set */
99
+/*
62
/* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI
100
+ * With SCTLR_ELx.NMI == 0, IRQ with Superpriority is masked identically with
63
* so that top level loop can generate correct syndrome information.
101
+ * IRQ without Superpriority. Moreover, if the GIC is configured so that
64
*/
102
+ * FEAT_GICv3_NMI is only set if FEAT_NMI is set, then we won't ever see
103
+ * CPU_INTERRUPT_*NMI anyway. So we might as well accept NMI here
104
+ * unconditionally.
105
+ */
106
static bool arm_cpu_has_work(CPUState *cs)
107
{
108
ARMCPU *cpu = ARM_CPU(cs);
109
@@ -XXX,XX +XXX,XX @@ static bool arm_cpu_has_work(CPUState *cs)
110
return (cpu->power_state != PSCI_OFF)
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
123
/*
124
* Don't take exceptions if they target a lower EL.
125
@@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
126
return false;
127
}
128
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
+{
255
+ /*
256
+ * Update the interrupt level for VINMI, which is the logical OR of
257
+ * the HCRX_EL2.VINMI bit and the input line level from the GIC.
258
+ */
259
+ CPUARMState *env = &cpu->env;
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
{
297
/*
298
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level)
299
[ARM_CPU_IRQ] = CPU_INTERRUPT_HARD,
300
[ARM_CPU_FIQ] = CPU_INTERRUPT_FIQ,
301
[ARM_CPU_VIRQ] = CPU_INTERRUPT_VIRQ,
302
- [ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ
303
+ [ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ,
304
+ [ARM_CPU_NMI] = CPU_INTERRUPT_NMI,
305
+ [ARM_CPU_VINMI] = CPU_INTERRUPT_VINMI,
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,
65
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
66
index XXXXXXX..XXXXXXX 100644
341
index XXXXXXX..XXXXXXX 100644
67
--- a/target/arm/helper.c
342
--- a/target/arm/helper.c
68
+++ b/target/arm/helper.c
343
+++ b/target/arm/helper.c
69
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
344
@@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
70
g_assert_not_reached();
345
* and the state of the input lines from the GIC. (This requires
346
* that we have the BQL, which is done by marking the
347
* reginfo structs as ARM_CP_IO.)
348
- * Note that if a write to HCR pends a VIRQ or VFIQ it is never
349
- * possible for it to be taken immediately, because VIRQ and
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
+ }
71
}
365
}
72
366
73
+void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
367
static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
74
+{
368
@@ -XXX,XX +XXX,XX @@ static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri,
75
+ /* translate.c should never generate calls here in user-only mode */
369
76
+ g_assert_not_reached();
370
/* Clear RES0 bits. */
77
+}
371
env->cp15.hcrx_el2 = value & valid_mask;
78
+
372
+
79
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
373
+ /*
80
{
374
+ * Updates to VINMI and VFNMI require us to update the status of
81
/* The TT instructions can be used by unprivileged code, but in
375
+ * virtual NMI, which are the logical OR of these bits
82
@@ -XXX,XX +XXX,XX @@ pend_fault:
376
+ * and the state of the input lines from the GIC. (This requires
83
return false;
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
+ }
84
}
389
}
85
390
86
+void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
391
static CPAccessResult access_hxen(CPUARMState *env, const ARMCPRegInfo *ri,
87
+{
392
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_hxen(CPUARMState *env, const ARMCPRegInfo *ri,
88
+ /*
393
89
+ * Preserve FP state (because LSPACT was set and we are about
394
static const ARMCPRegInfo hcrx_el2_reginfo = {
90
+ * to execute an FP instruction). This corresponds to the
395
.name = "HCRX_EL2", .state = ARM_CP_STATE_AA64,
91
+ * PreserveFPState() pseudocode.
396
+ .type = ARM_CP_IO,
92
+ * We may throw an exception if the stacking fails.
397
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 2,
93
+ */
398
.access = PL2_RW, .writefn = hcrx_write, .accessfn = access_hxen,
94
+ ARMCPU *cpu = arm_env_get_cpu(env);
399
.nv2_redirect_offset = 0xa0,
95
+ bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
400
@@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs)
96
+ bool negpri = !(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_HFRDY_MASK);
401
[EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault",
97
+ bool is_priv = !(env->v7m.fpccr[is_secure] & R_V7M_FPCCR_USER_MASK);
402
[EXCP_VSERR] = "Virtual SERR",
98
+ bool splimviol = env->v7m.fpccr[is_secure] & R_V7M_FPCCR_SPLIMVIOL_MASK;
403
[EXCP_GPC] = "Granule Protection Check",
99
+ uint32_t fpcar = env->v7m.fpcar[is_secure];
404
+ [EXCP_NMI] = "NMI",
100
+ bool stacked_ok = true;
405
+ [EXCP_VINMI] = "Virtual IRQ NMI",
101
+ bool ts = is_secure && (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK);
406
+ [EXCP_VFNMI] = "Virtual FIQ NMI",
102
+ bool take_exception;
103
+
104
+ /* Take the iothread lock as we are going to touch the NVIC */
105
+ qemu_mutex_lock_iothread();
106
+
107
+ /* Check the background context had access to the FPU */
108
+ if (!v7m_cpacr_pass(env, is_secure, is_priv)) {
109
+ armv7m_nvic_set_pending_lazyfp(env->nvic, ARMV7M_EXCP_USAGE, is_secure);
110
+ env->v7m.cfsr[is_secure] |= R_V7M_CFSR_NOCP_MASK;
111
+ stacked_ok = false;
112
+ } else if (!is_secure && !extract32(env->v7m.nsacr, 10, 1)) {
113
+ armv7m_nvic_set_pending_lazyfp(env->nvic, ARMV7M_EXCP_USAGE, M_REG_S);
114
+ env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK;
115
+ stacked_ok = false;
116
+ }
117
+
118
+ if (!splimviol && stacked_ok) {
119
+ /* We only stack if the stack limit wasn't violated */
120
+ int i;
121
+ ARMMMUIdx mmu_idx;
122
+
123
+ mmu_idx = arm_v7m_mmu_idx_all(env, is_secure, is_priv, negpri);
124
+ for (i = 0; i < (ts ? 32 : 16); i += 2) {
125
+ uint64_t dn = *aa32_vfp_dreg(env, i / 2);
126
+ uint32_t faddr = fpcar + 4 * i;
127
+ uint32_t slo = extract64(dn, 0, 32);
128
+ uint32_t shi = extract64(dn, 32, 32);
129
+
130
+ if (i >= 16) {
131
+ faddr += 8; /* skip the slot for the FPSCR */
132
+ }
133
+ stacked_ok = stacked_ok &&
134
+ v7m_stack_write(cpu, faddr, slo, mmu_idx, STACK_LAZYFP) &&
135
+ v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, STACK_LAZYFP);
136
+ }
137
+
138
+ stacked_ok = stacked_ok &&
139
+ v7m_stack_write(cpu, fpcar + 0x40,
140
+ vfp_get_fpscr(env), mmu_idx, STACK_LAZYFP);
141
+ }
142
+
143
+ /*
144
+ * We definitely pended an exception, but it's possible that it
145
+ * might not be able to be taken now. If its priority permits us
146
+ * to take it now, then we must not update the LSPACT or FP regs,
147
+ * but instead jump out to take the exception immediately.
148
+ * If it's just pending and won't be taken until the current
149
+ * handler exits, then we do update LSPACT and the FP regs.
150
+ */
151
+ take_exception = !stacked_ok &&
152
+ armv7m_nvic_can_take_pending_exception(env->nvic);
153
+
154
+ qemu_mutex_unlock_iothread();
155
+
156
+ if (take_exception) {
157
+ raise_exception_ra(env, EXCP_LAZYFP, 0, 1, GETPC());
158
+ }
159
+
160
+ env->v7m.fpccr[is_secure] &= ~R_V7M_FPCCR_LSPACT_MASK;
161
+
162
+ if (ts) {
163
+ /* Clear s0 to s31 and the FPSCR */
164
+ int i;
165
+
166
+ for (i = 0; i < 32; i += 2) {
167
+ *aa32_vfp_dreg(env, i / 2) = 0;
168
+ }
169
+ vfp_set_fpscr(env, 0);
170
+ }
171
+ /*
172
+ * Otherwise s0 to s15 and FPSCR are UNKNOWN; we choose to leave them
173
+ * unchanged.
174
+ */
175
+}
176
+
177
/* Write to v7M CONTROL.SPSEL bit for the specified security bank.
178
* This may change the current stack pointer between Main and Process
179
* stack pointers if it is done for the CONTROL register for the current
180
@@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx)
181
[EXCP_NOCP] = "v7M NOCP UsageFault",
182
[EXCP_INVSTATE] = "v7M INVSTATE UsageFault",
183
[EXCP_STKOF] = "v8M STKOF UsageFault",
184
+ [EXCP_LAZYFP] = "v7M exception during lazy FP stacking",
185
};
407
};
186
408
187
if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
409
if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
188
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
189
return;
190
}
191
break;
192
+ case EXCP_LAZYFP:
193
+ /*
194
+ * We already pended the specific exception in the NVIC in the
195
+ * v7m_preserve_fp_state() helper function.
196
+ */
197
+ break;
198
default:
199
cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
200
return; /* Never happens. Keep compiler happy. */
201
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
202
flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1);
203
}
204
205
+ if (arm_feature(env, ARM_FEATURE_M)) {
206
+ bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
207
+
208
+ if (env->v7m.fpccr[is_secure] & R_V7M_FPCCR_LSPACT_MASK) {
209
+ flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1);
210
+ }
211
+ }
212
+
213
*pflags = flags;
214
*cs_base = 0;
215
}
216
diff --git a/target/arm/translate.c b/target/arm/translate.c
217
index XXXXXXX..XXXXXXX 100644
218
--- a/target/arm/translate.c
219
+++ b/target/arm/translate.c
220
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
221
if (arm_dc_feature(s, ARM_FEATURE_M)) {
222
/* Handle M-profile lazy FP state mechanics */
223
224
+ /* Trigger lazy-state preservation if necessary */
225
+ if (s->v7m_lspact) {
226
+ /*
227
+ * Lazy state saving affects external memory and also the NVIC,
228
+ * so we must mark it as an IO operation for icount.
229
+ */
230
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
231
+ gen_io_start();
232
+ }
233
+ gen_helper_v7m_preserve_fp_state(cpu_env);
234
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
235
+ gen_io_end();
236
+ }
237
+ /*
238
+ * If the preserve_fp_state helper doesn't throw an exception
239
+ * then it will clear LSPACT; we don't need to repeat this for
240
+ * any further FP insns in this TB.
241
+ */
242
+ s->v7m_lspact = false;
243
+ }
244
+
245
/* Update ownership of FP context: set FPCCR.S to match current state */
246
if (s->v8m_fpccr_s_wrong) {
247
TCGv_i32 tmp;
248
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
249
dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG);
250
dc->v7m_new_fp_ctxt_needed =
251
FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED);
252
+ dc->v7m_lspact = FIELD_EX32(tb_flags, TBFLAG_A32, LSPACT);
253
dc->cp_regs = cpu->cp_regs;
254
dc->features = env->features;
255
256
--
410
--
257
2.20.1
411
2.34.1
258
259
diff view generated by jsdifflib
1
If the floating point extension is present, then the SG instruction
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
must clear the CONTROL_S.SFPA bit. Implement this.
3
2
4
(On a no-FPU system the bit will always be zero, so we don't need
3
According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt
5
to make the clearing of the bit conditional on ARM_FEATURE_VFP.)
4
with superpriority is always IRQ, never FIQ, so handle NMI same as IRQ in
5
arm_phys_excp_target_el().
6
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
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-8-peter.maydell@linaro.org
10
---
12
---
11
target/arm/helper.c | 1 +
13
target/arm/helper.c | 1 +
12
1 file changed, 1 insertion(+)
14
1 file changed, 1 insertion(+)
13
15
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
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/helper.c
18
--- a/target/arm/helper.c
17
+++ b/target/arm/helper.c
19
+++ b/target/arm/helper.c
18
@@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu)
20
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
19
qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32
21
hcr_el2 = arm_hcr_el2_eff(env);
20
", executing it\n", env->regs[15]);
22
switch (excp_idx) {
21
env->regs[14] &= ~1;
23
case EXCP_IRQ:
22
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
24
+ case EXCP_NMI:
23
switch_v7m_security_state(env, true);
25
scr = ((env->cp15.scr_el3 & SCR_IRQ) == SCR_IRQ);
24
xpsr_write(env, 0, XPSR_IT);
26
hcr = hcr_el2 & HCR_IMO;
25
env->regs[15] += 4;
27
break;
26
--
28
--
27
2.20.1
29
2.34.1
28
29
diff view generated by jsdifflib
1
The M-profile FPCCR.ASPEN bit indicates that automatic floating-point
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
context preservation is enabled. Before executing any floating-point
3
instruction, if FPCCR.ASPEN is set and the CONTROL FPCA/SFPA bits
4
indicate that there is no active floating point context then we
5
must create a new context (by initializing FPSCR and setting
6
FPCA/SFPA to indicate that the context is now active). In the
7
pseudocode this is handled by ExecuteFPCheck().
8
2
9
Implement this with a new TB flag which tracks whether we
3
Add IS and FS bit in ISR_EL1 and handle the read. With CPU_INTERRUPT_NMI or
10
need to create a new FP context.
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.
11
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
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20190416125744.27770-20-peter.maydell@linaro.org
15
---
12
---
16
target/arm/cpu.h | 2 ++
13
target/arm/cpu.h | 2 ++
17
target/arm/translate.h | 1 +
14
target/arm/helper.c | 13 +++++++++++++
18
target/arm/helper.c | 13 +++++++++++++
15
2 files changed, 15 insertions(+)
19
target/arm/translate.c | 29 +++++++++++++++++++++++++++++
20
4 files changed, 45 insertions(+)
21
16
22
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
23
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/cpu.h
19
--- a/target/arm/cpu.h
25
+++ b/target/arm/cpu.h
20
+++ b/target/arm/cpu.h
26
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
21
@@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu);
27
FIELD(TBFLAG_A32, VFPEN, 7, 1)
22
#define CPSR_N (1U << 31)
28
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
23
#define CPSR_NZCV (CPSR_N | CPSR_Z | CPSR_C | CPSR_V)
29
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
24
#define CPSR_AIF (CPSR_A | CPSR_I | CPSR_F)
30
+/* For M profile only, set if we must create a new FP context */
25
+#define ISR_FS (1U << 9)
31
+FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1)
26
+#define ISR_IS (1U << 10)
32
/* For M profile only, set if FPCCR.S does not match current security state */
27
33
FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1)
28
#define CPSR_IT (CPSR_IT_0_1 | CPSR_IT_2_7)
34
/* For M profile only, Handler (ie not Thread) mode */
29
#define CACHED_CPSR_BITS (CPSR_T | CPSR_AIF | CPSR_GE | CPSR_IT | CPSR_Q \
35
diff --git a/target/arm/translate.h b/target/arm/translate.h
36
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/translate.h
38
+++ b/target/arm/translate.h
39
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
40
bool v8m_secure; /* true if v8M and we're in Secure mode */
41
bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */
42
bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */
43
+ bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */
44
/* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI
45
* so that top level loop can generate correct syndrome information.
46
*/
47
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
48
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/helper.c
32
--- a/target/arm/helper.c
50
+++ b/target/arm/helper.c
33
+++ b/target/arm/helper.c
51
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
34
@@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri)
52
flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1);
35
if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) {
53
}
36
ret |= CPSR_I;
54
37
}
55
+ if (arm_feature(env, ARM_FEATURE_M) &&
38
+ if (cs->interrupt_request & CPU_INTERRUPT_VINMI) {
56
+ (env->v7m.fpccr[env->v7m.secure] & R_V7M_FPCCR_ASPEN_MASK) &&
39
+ ret |= ISR_IS;
57
+ (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) ||
40
+ ret |= CPSR_I;
58
+ (env->v7m.secure &&
41
+ }
59
+ !(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)))) {
42
} else {
60
+ /*
43
if (cs->interrupt_request & CPU_INTERRUPT_HARD) {
61
+ * ASPEN is set, but FPCA/SFPA indicate that there is no active
44
ret |= CPSR_I;
62
+ * FP context; we must create a new FP context before executing
63
+ * any FP insn.
64
+ */
65
+ flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1);
66
+ }
67
+
68
*pflags = flags;
69
*cs_base = 0;
70
}
71
diff --git a/target/arm/translate.c b/target/arm/translate.c
72
index XXXXXXX..XXXXXXX 100644
73
--- a/target/arm/translate.c
74
+++ b/target/arm/translate.c
75
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
76
/* Don't need to do this for any further FP insns in this TB */
77
s->v8m_fpccr_s_wrong = false;
78
}
45
}
79
+
46
+
80
+ if (s->v7m_new_fp_ctxt_needed) {
47
+ if (cs->interrupt_request & CPU_INTERRUPT_NMI) {
81
+ /*
48
+ ret |= ISR_IS;
82
+ * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA
49
+ ret |= CPSR_I;
83
+ * and the FPSCR.
84
+ */
85
+ TCGv_i32 control, fpscr;
86
+ uint32_t bits = R_V7M_CONTROL_FPCA_MASK;
87
+
88
+ fpscr = load_cpu_field(v7m.fpdscr[s->v8m_secure]);
89
+ gen_helper_vfp_set_fpscr(cpu_env, fpscr);
90
+ tcg_temp_free_i32(fpscr);
91
+ /*
92
+ * We don't need to arrange to end the TB, because the only
93
+ * parts of FPSCR which we cache in the TB flags are the VECLEN
94
+ * and VECSTRIDE, and those don't exist for M-profile.
95
+ */
96
+
97
+ if (s->v8m_secure) {
98
+ bits |= R_V7M_CONTROL_SFPA_MASK;
99
+ }
100
+ control = load_cpu_field(v7m.control[M_REG_S]);
101
+ tcg_gen_ori_i32(control, control, bits);
102
+ store_cpu_field(control, v7m.control[M_REG_S]);
103
+ /* Don't need to do this for any further FP insns in this TB */
104
+ s->v7m_new_fp_ctxt_needed = false;
105
+ }
50
+ }
106
}
51
}
107
52
108
if (extract32(insn, 28, 4) == 0xf) {
53
if (hcr_el2 & HCR_FMO) {
109
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
54
if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) {
110
regime_is_secure(env, dc->mmu_idx);
55
ret |= CPSR_F;
111
dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK);
56
}
112
dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG);
57
+ if (cs->interrupt_request & CPU_INTERRUPT_VFNMI) {
113
+ dc->v7m_new_fp_ctxt_needed =
58
+ ret |= ISR_FS;
114
+ FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED);
59
+ ret |= CPSR_F;
115
dc->cp_regs = cpu->cp_regs;
60
+ }
116
dc->features = env->features;
61
} else {
117
62
if (cs->interrupt_request & CPU_INTERRUPT_FIQ) {
63
ret |= CPSR_F;
118
--
64
--
119
2.20.1
65
2.34.1
120
121
diff view generated by jsdifflib
1
The TailChain() pseudocode specifies that a tail chaining
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
exception should sanitize the excReturn all-ones bits and
3
(if there is no FPU) the excReturn FType bits; we weren't
4
doing this.
5
2
3
Set or clear PSTATE.ALLINT on taking an exception to ELx according to the
4
SCTLR_ELx.SPINTMASK bit.
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
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-14-peter.maydell@linaro.org
9
---
11
---
10
target/arm/helper.c | 8 ++++++++
12
target/arm/helper.c | 8 ++++++++
11
1 file changed, 8 insertions(+)
13
1 file changed, 8 insertions(+)
12
14
13
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
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
17
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
18
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
19
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
18
qemu_log_mask(CPU_LOG_INT, "...taking pending %s exception %d\n",
20
}
19
targets_secure ? "secure" : "nonsecure", exc);
21
}
20
22
21
+ if (dotailchain) {
23
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
22
+ /* Sanitize LR FType and PREFIX bits */
24
+ if (!(env->cp15.sctlr_el[new_el] & SCTLR_SPINTMASK)) {
23
+ if (!arm_feature(env, ARM_FEATURE_VFP)) {
25
+ new_mode |= PSTATE_ALLINT;
24
+ lr |= R_V7M_EXCRET_FTYPE_MASK;
26
+ } else {
27
+ new_mode &= ~PSTATE_ALLINT;
25
+ }
28
+ }
26
+ lr = deposit32(lr, 24, 8, 0xff);
27
+ }
29
+ }
28
+
30
+
29
if (arm_feature(env, ARM_FEATURE_V8)) {
31
pstate_write(env, PSTATE_DAIF | new_mode);
30
if (arm_feature(env, ARM_FEATURE_M_SECURITY) &&
32
env->aarch64 = true;
31
(lr & R_V7M_EXCRET_S_MASK)) {
33
aarch64_restore_sp(env, new_el);
32
--
34
--
33
2.20.1
35
2.34.1
34
35
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
This commit finally deletes "hw/devices.h".
3
Augment the GICv3's QOM device interface by adding one
4
new set of sysbus IRQ line, to signal NMI to each CPU.
4
5
5
Reviewed-by: Markus Armbruster <armbru@redhat.com>
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20190412165416.7977-13-philmd@redhat.com
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20240407081733.3231820-11-ruanjinjie@huawei.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
11
---
10
include/hw/devices.h | 11 -----------
12
include/hw/intc/arm_gic_common.h | 2 ++
11
include/hw/net/smc91c111.h | 19 +++++++++++++++++++
13
include/hw/intc/arm_gicv3_common.h | 2 ++
12
hw/arm/gumstix.c | 2 +-
14
hw/intc/arm_gicv3_common.c | 6 ++++++
13
hw/arm/integratorcp.c | 2 +-
15
3 files changed, 10 insertions(+)
14
hw/arm/mainstone.c | 2 +-
15
hw/arm/realview.c | 2 +-
16
hw/arm/versatilepb.c | 2 +-
17
hw/net/smc91c111.c | 2 +-
18
8 files changed, 25 insertions(+), 17 deletions(-)
19
delete mode 100644 include/hw/devices.h
20
create mode 100644 include/hw/net/smc91c111.h
21
16
22
diff --git a/include/hw/devices.h b/include/hw/devices.h
17
diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_common.h
23
deleted file mode 100644
24
index XXXXXXX..XXXXXXX
25
--- a/include/hw/devices.h
26
+++ /dev/null
27
@@ -XXX,XX +XXX,XX @@
28
-#ifndef QEMU_DEVICES_H
29
-#define QEMU_DEVICES_H
30
-
31
-/* Devices that have nowhere better to go. */
32
-
33
-#include "hw/hw.h"
34
-
35
-/* smc91c111.c */
36
-void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
37
-
38
-#endif
39
diff --git a/include/hw/net/smc91c111.h b/include/hw/net/smc91c111.h
40
new file mode 100644
41
index XXXXXXX..XXXXXXX
42
--- /dev/null
43
+++ b/include/hw/net/smc91c111.h
44
@@ -XXX,XX +XXX,XX @@
45
+/*
46
+ * SMSC 91C111 Ethernet interface emulation
47
+ *
48
+ * Copyright (c) 2005 CodeSourcery, LLC.
49
+ * Written by Paul Brook
50
+ *
51
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
52
+ * See the COPYING file in the top-level directory.
53
+ */
54
+
55
+#ifndef HW_NET_SMC91C111_H
56
+#define HW_NET_SMC91C111_H
57
+
58
+#include "hw/irq.h"
59
+#include "net/net.h"
60
+
61
+void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
62
+
63
+#endif
64
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
65
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
66
--- a/hw/arm/gumstix.c
19
--- a/include/hw/intc/arm_gic_common.h
67
+++ b/hw/arm/gumstix.c
20
+++ b/include/hw/intc/arm_gic_common.h
68
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ struct GICState {
69
#include "hw/arm/pxa.h"
22
qemu_irq parent_fiq[GIC_NCPU];
70
#include "net/net.h"
23
qemu_irq parent_virq[GIC_NCPU];
71
#include "hw/block/flash.h"
24
qemu_irq parent_vfiq[GIC_NCPU];
72
-#include "hw/devices.h"
25
+ qemu_irq parent_nmi[GIC_NCPU];
73
+#include "hw/net/smc91c111.h"
26
+ qemu_irq parent_vnmi[GIC_NCPU];
74
#include "hw/boards.h"
27
qemu_irq maintenance_irq[GIC_NCPU];
75
#include "exec/address-spaces.h"
28
76
#include "sysemu/qtest.h"
29
/* GICD_CTLR; for a GIC with the security extensions the NS banked version
77
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
30
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
78
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
79
--- a/hw/arm/integratorcp.c
32
--- a/include/hw/intc/arm_gicv3_common.h
80
+++ b/hw/arm/integratorcp.c
33
+++ b/include/hw/intc/arm_gicv3_common.h
81
@@ -XXX,XX +XXX,XX @@
34
@@ -XXX,XX +XXX,XX @@ struct GICv3CPUState {
82
#include "qemu-common.h"
35
qemu_irq parent_fiq;
83
#include "cpu.h"
36
qemu_irq parent_virq;
84
#include "hw/sysbus.h"
37
qemu_irq parent_vfiq;
85
-#include "hw/devices.h"
38
+ qemu_irq parent_nmi;
86
#include "hw/boards.h"
39
+ qemu_irq parent_vnmi;
87
#include "hw/arm/arm.h"
40
88
#include "hw/misc/arm_integrator_debug.h"
41
/* Redistributor */
89
+#include "hw/net/smc91c111.h"
42
uint32_t level; /* Current IRQ level */
90
#include "net/net.h"
43
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
91
#include "exec/address-spaces.h"
92
#include "sysemu/sysemu.h"
93
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
94
index XXXXXXX..XXXXXXX 100644
44
index XXXXXXX..XXXXXXX 100644
95
--- a/hw/arm/mainstone.c
45
--- a/hw/intc/arm_gicv3_common.c
96
+++ b/hw/arm/mainstone.c
46
+++ b/hw/intc/arm_gicv3_common.c
97
@@ -XXX,XX +XXX,XX @@
47
@@ -XXX,XX +XXX,XX @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler,
98
#include "hw/arm/pxa.h"
48
for (i = 0; i < s->num_cpu; i++) {
99
#include "hw/arm/arm.h"
49
sysbus_init_irq(sbd, &s->cpu[i].parent_vfiq);
100
#include "net/net.h"
50
}
101
-#include "hw/devices.h"
51
+ for (i = 0; i < s->num_cpu; i++) {
102
+#include "hw/net/smc91c111.h"
52
+ sysbus_init_irq(sbd, &s->cpu[i].parent_nmi);
103
#include "hw/boards.h"
53
+ }
104
#include "hw/block/flash.h"
54
+ for (i = 0; i < s->num_cpu; i++) {
105
#include "hw/sysbus.h"
55
+ sysbus_init_irq(sbd, &s->cpu[i].parent_vnmi);
106
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
56
+ }
107
index XXXXXXX..XXXXXXX 100644
57
108
--- a/hw/arm/realview.c
58
memory_region_init_io(&s->iomem_dist, OBJECT(s), ops, s,
109
+++ b/hw/arm/realview.c
59
"gicv3_dist", 0x10000);
110
@@ -XXX,XX +XXX,XX @@
111
#include "hw/sysbus.h"
112
#include "hw/arm/arm.h"
113
#include "hw/arm/primecell.h"
114
-#include "hw/devices.h"
115
#include "hw/net/lan9118.h"
116
+#include "hw/net/smc91c111.h"
117
#include "hw/pci/pci.h"
118
#include "net/net.h"
119
#include "sysemu/sysemu.h"
120
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
121
index XXXXXXX..XXXXXXX 100644
122
--- a/hw/arm/versatilepb.c
123
+++ b/hw/arm/versatilepb.c
124
@@ -XXX,XX +XXX,XX @@
125
#include "cpu.h"
126
#include "hw/sysbus.h"
127
#include "hw/arm/arm.h"
128
-#include "hw/devices.h"
129
+#include "hw/net/smc91c111.h"
130
#include "net/net.h"
131
#include "sysemu/sysemu.h"
132
#include "hw/pci/pci.h"
133
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
134
index XXXXXXX..XXXXXXX 100644
135
--- a/hw/net/smc91c111.c
136
+++ b/hw/net/smc91c111.c
137
@@ -XXX,XX +XXX,XX @@
138
#include "qemu/osdep.h"
139
#include "hw/sysbus.h"
140
#include "net/net.h"
141
-#include "hw/devices.h"
142
+#include "hw/net/smc91c111.h"
143
#include "qemu/log.h"
144
/* For crc32 */
145
#include <zlib.h>
146
--
60
--
147
2.20.1
61
2.34.1
148
149
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
Wire the new NMI and VINMI interrupt line from the GIC to each CPU if it
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
is not GICv2.
5
Message-id: 20190412165416.7977-12-philmd@redhat.com
5
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20240407081733.3231820-12-ruanjinjie@huawei.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
10
---
8
include/hw/net/lan9118.h | 2 ++
11
hw/arm/virt.c | 10 +++++++++-
9
hw/arm/exynos4_boards.c | 3 ++-
12
1 file changed, 9 insertions(+), 1 deletion(-)
10
hw/arm/mps2-tz.c | 3 ++-
11
hw/net/lan9118.c | 1 -
12
4 files changed, 6 insertions(+), 3 deletions(-)
13
13
14
diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h
14
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/include/hw/net/lan9118.h
16
--- a/hw/arm/virt.c
17
+++ b/include/hw/net/lan9118.h
17
+++ b/hw/arm/virt.c
18
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
19
#include "hw/irq.h"
19
20
#include "net/net.h"
20
/* Wire the outputs from each CPU's generic timer and the GICv3
21
21
* maintenance interrupt signal to the appropriate GIC PPI inputs,
22
+#define TYPE_LAN9118 "lan9118"
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));
23
+
32
+
24
void lan9118_init(NICInfo *, uint32_t, qemu_irq);
33
+ if (vms->gic_version != VIRT_GIC_VERSION_2) {
25
34
+ sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus,
26
#endif
35
+ qdev_get_gpio_in(cpudev, ARM_CPU_NMI));
27
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
36
+ sysbus_connect_irq(gicbusdev, i + 5 * smp_cpus,
28
index XXXXXXX..XXXXXXX 100644
37
+ qdev_get_gpio_in(cpudev, ARM_CPU_VINMI));
29
--- a/hw/arm/exynos4_boards.c
38
+ }
30
+++ b/hw/arm/exynos4_boards.c
31
@@ -XXX,XX +XXX,XX @@
32
#include "hw/arm/arm.h"
33
#include "exec/address-spaces.h"
34
#include "hw/arm/exynos4210.h"
35
+#include "hw/net/lan9118.h"
36
#include "hw/boards.h"
37
38
#undef DEBUG
39
@@ -XXX,XX +XXX,XX @@ static void lan9215_init(uint32_t base, qemu_irq irq)
40
/* This should be a 9215 but the 9118 is close enough */
41
if (nd_table[0].used) {
42
qemu_check_nic_model(&nd_table[0], "lan9118");
43
- dev = qdev_create(NULL, "lan9118");
44
+ dev = qdev_create(NULL, TYPE_LAN9118);
45
qdev_set_nic_properties(dev, &nd_table[0]);
46
qdev_prop_set_uint32(dev, "mode_16bit", 1);
47
qdev_init_nofail(dev);
48
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/arm/mps2-tz.c
51
+++ b/hw/arm/mps2-tz.c
52
@@ -XXX,XX +XXX,XX @@
53
#include "hw/arm/armsse.h"
54
#include "hw/dma/pl080.h"
55
#include "hw/ssi/pl022.h"
56
+#include "hw/net/lan9118.h"
57
#include "net/net.h"
58
#include "hw/core/split-irq.h"
59
60
@@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque,
61
* except that it doesn't support the checksum-offload feature.
62
*/
63
qemu_check_nic_model(nd, "lan9118");
64
- mms->lan9118 = qdev_create(NULL, "lan9118");
65
+ mms->lan9118 = qdev_create(NULL, TYPE_LAN9118);
66
qdev_set_nic_properties(mms->lan9118, nd);
67
qdev_init_nofail(mms->lan9118);
68
69
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/hw/net/lan9118.c
72
+++ b/hw/net/lan9118.c
73
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_lan9118_packet = {
74
}
39
}
75
};
40
76
41
fdt_add_gic_node(vms);
77
-#define TYPE_LAN9118 "lan9118"
78
#define LAN9118(obj) OBJECT_CHECK(lan9118_state, (obj), TYPE_LAN9118)
79
80
typedef struct {
81
--
42
--
82
2.20.1
43
2.34.1
83
84
diff view generated by jsdifflib
1
For v8M floating point support, transitions from Secure
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
to Non-secure state via BLNS and BLXNS must clear the
3
CONTROL.SFPA bit. (This corresponds to the pseudocode
4
BranchToNS() function.)
5
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
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-13-peter.maydell@linaro.org
9
---
14
---
10
target/arm/helper.c | 4 ++++
15
target/arm/helper.c | 3 +++
11
1 file changed, 4 insertions(+)
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 @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest)
22
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
18
/* translate.c should have made BXNS UNDEF unless we're secure */
23
break;
19
assert(env->v7m.secure);
24
case EXCP_IRQ:
20
25
case EXCP_VIRQ:
21
+ if (!(dest & 1)) {
26
+ case EXCP_NMI:
22
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
27
+ case EXCP_VINMI:
23
+ }
28
addr += 0x80;
24
switch_v7m_security_state(env, dest & 1);
29
break;
25
env->thumb = 1;
30
case EXCP_FIQ:
26
env->regs[15] = dest & ~1;
31
case EXCP_VFIQ:
27
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
32
+ case EXCP_VFNMI:
28
*/
33
addr += 0x100;
29
write_v7m_exception(env, 1);
34
break;
30
}
35
case EXCP_VSERR:
31
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
32
switch_v7m_security_state(env, 0);
33
env->thumb = 1;
34
env->regs[15] = dest;
35
--
36
--
36
2.20.1
37
2.34.1
37
38
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Reviewed-by: Thomas Huth <thuth@redhat.com>
3
Add a property has-nmi to the GICv3 device, and use this to set
4
Reviewed-by: Markus Armbruster <armbru@redhat.com>
4
the NMI bit in the GICD_TYPER register. This isn't visible to
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
guests yet because the property defaults to false and we won't
6
Message-id: 20190412165416.7977-11-philmd@redhat.com
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
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
14
---
9
include/hw/net/ne2000-isa.h | 6 ++++++
15
hw/intc/gicv3_internal.h | 1 +
10
1 file changed, 6 insertions(+)
16
include/hw/intc/arm_gicv3_common.h | 1 +
17
hw/intc/arm_gicv3_common.c | 1 +
18
hw/intc/arm_gicv3_dist.c | 2 ++
19
4 files changed, 5 insertions(+)
11
20
12
diff --git a/include/hw/net/ne2000-isa.h b/include/hw/net/ne2000-isa.h
21
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
13
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
14
--- a/include/hw/net/ne2000-isa.h
23
--- a/hw/intc/gicv3_internal.h
15
+++ b/include/hw/net/ne2000-isa.h
24
+++ b/hw/intc/gicv3_internal.h
16
@@ -XXX,XX +XXX,XX @@
25
@@ -XXX,XX +XXX,XX @@
17
* This work is licensed under the terms of the GNU GPL, version 2 or later.
26
#define GICD_CTLR_E1NWF (1U << 7)
18
* See the COPYING file in the top-level directory.
27
#define GICD_CTLR_RWP (1U << 31)
19
*/
28
20
+
29
+#define GICD_TYPER_NMI_SHIFT 9
21
+#ifndef HW_NET_NE2K_ISA_H
30
#define GICD_TYPER_LPIS_SHIFT 17
22
+#define HW_NET_NE2K_ISA_H
31
23
+
32
/* 16 bits EventId */
24
#include "hw/hw.h"
33
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
25
#include "hw/qdev.h"
34
index XXXXXXX..XXXXXXX 100644
26
#include "hw/isa/isa.h"
35
--- a/include/hw/intc/arm_gicv3_common.h
27
@@ -XXX,XX +XXX,XX @@ static inline ISADevice *isa_ne2000_init(ISABus *bus, int base, int irq,
36
+++ b/include/hw/intc/arm_gicv3_common.h
28
}
37
@@ -XXX,XX +XXX,XX @@ struct GICv3State {
29
return d;
38
uint32_t num_irq;
30
}
39
uint32_t revision;
31
+
40
bool lpi_enable;
32
+#endif
41
+ bool nmi_support;
42
bool security_extn;
43
bool force_8bit_prio;
44
bool irq_reset_nonsecure;
45
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/hw/intc/arm_gicv3_common.c
48
+++ b/hw/intc/arm_gicv3_common.c
49
@@ -XXX,XX +XXX,XX @@ static Property arm_gicv3_common_properties[] = {
50
DEFINE_PROP_UINT32("num-irq", GICv3State, num_irq, 32),
51
DEFINE_PROP_UINT32("revision", GICv3State, revision, 3),
52
DEFINE_PROP_BOOL("has-lpi", GICv3State, lpi_enable, 0),
53
+ DEFINE_PROP_BOOL("has-nmi", GICv3State, nmi_support, 0),
54
DEFINE_PROP_BOOL("has-security-extensions", GICv3State, security_extn, 0),
55
/*
56
* Compatibility property: force 8 bits of physical priority, even
57
diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c
58
index XXXXXXX..XXXXXXX 100644
59
--- a/hw/intc/arm_gicv3_dist.c
60
+++ b/hw/intc/arm_gicv3_dist.c
61
@@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset,
62
* by GICD_TYPER.IDbits)
63
* MBIS == 0 (message-based SPIs not supported)
64
* SecurityExtn == 1 if security extns supported
65
+ * NMI = 1 if Non-maskable interrupt property is supported
66
* CPUNumber == 0 since for us ARE is always 1
67
* ITLinesNumber == (((max SPI IntID + 1) / 32) - 1)
68
*/
69
@@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset,
70
bool dvis = s->revision >= 4;
71
72
*data = (1 << 25) | (1 << 24) | (dvis << 18) | (sec_extn << 10) |
73
+ (s->nmi_support << GICD_TYPER_NMI_SHIFT) |
74
(s->lpi_enable << GICD_TYPER_LPIS_SHIFT) |
75
(0xf << 19) | itlinesnumber;
76
return true;
33
--
77
--
34
2.20.1
78
2.34.1
35
36
diff view generated by jsdifflib
1
Enforce that for M-profile various FPSCR bits which are RES0 there
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
but have defined meanings on A-profile are never settable. This
3
ensures that M-profile code can't enable the A-profile behaviour
4
(notably vector length/stride handling) by accident.
5
2
3
So far, there is no FEAT_GICv3_NMI support in the in-kernel GIC, so make it
4
an error to try to set has-nmi=true for the KVM GICv3.
5
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
Message-id: 20240407081733.3231820-15-ruanjinjie@huawei.com
8
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-2-peter.maydell@linaro.org
9
---
10
---
10
target/arm/vfp_helper.c | 8 ++++++++
11
hw/intc/arm_gicv3_kvm.c | 5 +++++
11
1 file changed, 8 insertions(+)
12
1 file changed, 5 insertions(+)
12
13
13
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
14
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/vfp_helper.c
16
--- a/hw/intc/arm_gicv3_kvm.c
16
+++ b/target/arm/vfp_helper.c
17
+++ b/hw/intc/arm_gicv3_kvm.c
17
@@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
18
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
18
val &= ~FPCR_FZ16;
19
return;
19
}
20
}
20
21
21
+ if (arm_feature(env, ARM_FEATURE_M)) {
22
+ if (s->nmi_support) {
22
+ /*
23
+ error_setg(errp, "NMI is not supported with the in-kernel GIC");
23
+ * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits
24
+ return;
24
+ * and also for the trapped-exception-handling bits IxE.
25
+ */
26
+ val &= 0xf7c0009f;
27
+ }
25
+ }
28
+
26
+
29
/*
27
gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);
30
* We don't implement trapped exception handling, so the
28
31
* trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!)
29
for (i = 0; i < s->num_cpu; i++) {
32
--
30
--
33
2.20.1
31
2.34.1
34
35
diff view generated by jsdifflib
1
The M-profile floating point support has three associated config
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
registers: FPCAR, FPCCR and FPDSCR. It also makes the registers
3
CPACR and NSACR have behaviour other than reads-as-zero.
4
Add support for all of these as simple reads-as-written registers.
5
We will hook up actual functionality later.
6
2
7
The main complexity here is handling the FPCCR register, which
3
A SPI, PPI or SGI interrupt can have non-maskable property. So maintain
8
has a mix of banked and unbanked bits.
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.
9
7
10
Note that we don't share storage with the A-profile
8
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
11
cpu->cp15.nsacr and cpu->cp15.cpacr_el1, though the behaviour
9
Acked-by: Richard Henderson <richard.henderson@linaro.org>
12
is quite similar, for two reasons:
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
* the M profile CPACR is banked between security states
11
Message-id: 20240407081733.3231820-16-ruanjinjie@huawei.com
14
* it preserves the invariant that M profile uses no state
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
inside the cp15 substruct
13
---
14
include/hw/intc/arm_gicv3_common.h | 4 ++++
15
hw/intc/arm_gicv3_common.c | 38 ++++++++++++++++++++++++++++++
16
2 files changed, 42 insertions(+)
16
17
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Message-id: 20190416125744.27770-4-peter.maydell@linaro.org
20
---
21
target/arm/cpu.h | 34 ++++++++++++
22
hw/intc/armv7m_nvic.c | 125 ++++++++++++++++++++++++++++++++++++++++++
23
target/arm/cpu.c | 5 ++
24
target/arm/machine.c | 16 ++++++
25
4 files changed, 180 insertions(+)
26
27
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
28
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/cpu.h
20
--- a/include/hw/intc/arm_gicv3_common.h
30
+++ b/target/arm/cpu.h
21
+++ b/include/hw/intc/arm_gicv3_common.h
31
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
22
@@ -XXX,XX +XXX,XX @@ typedef struct {
32
uint32_t scr[M_REG_NUM_BANKS];
23
int irq;
33
uint32_t msplim[M_REG_NUM_BANKS];
24
uint8_t prio;
34
uint32_t psplim[M_REG_NUM_BANKS];
25
int grp;
35
+ uint32_t fpcar[M_REG_NUM_BANKS];
26
+ bool nmi;
36
+ uint32_t fpccr[M_REG_NUM_BANKS];
27
} PendingIrq;
37
+ uint32_t fpdscr[M_REG_NUM_BANKS];
28
38
+ uint32_t cpacr[M_REG_NUM_BANKS];
29
struct GICv3CPUState {
39
+ uint32_t nsacr;
30
@@ -XXX,XX +XXX,XX @@ struct GICv3CPUState {
40
} v7m;
31
uint32_t gicr_ienabler0;
41
32
uint32_t gicr_ipendr0;
42
/* Information associated with an exception about to be taken:
33
uint32_t gicr_iactiver0;
43
@@ -XXX,XX +XXX,XX @@ FIELD(V7M_CSSELR, LEVEL, 1, 3)
34
+ uint32_t gicr_inmir0;
44
*/
35
uint32_t edge_trigger; /* ICFGR0 and ICFGR1 even bits */
45
FIELD(V7M_CSSELR, INDEX, 0, 4)
36
uint32_t gicr_igrpmodr0;
46
37
uint32_t gicr_nsacr;
47
+/* v7M FPCCR bits */
38
@@ -XXX,XX +XXX,XX @@ struct GICv3State {
48
+FIELD(V7M_FPCCR, LSPACT, 0, 1)
39
GIC_DECLARE_BITMAP(active); /* GICD_ISACTIVER */
49
+FIELD(V7M_FPCCR, USER, 1, 1)
40
GIC_DECLARE_BITMAP(level); /* Current level */
50
+FIELD(V7M_FPCCR, S, 2, 1)
41
GIC_DECLARE_BITMAP(edge_trigger); /* GICD_ICFGR even bits */
51
+FIELD(V7M_FPCCR, THREAD, 3, 1)
42
+ GIC_DECLARE_BITMAP(nmi); /* GICD_INMIR */
52
+FIELD(V7M_FPCCR, HFRDY, 4, 1)
43
uint8_t gicd_ipriority[GICV3_MAXIRQ];
53
+FIELD(V7M_FPCCR, MMRDY, 5, 1)
44
uint64_t gicd_irouter[GICV3_MAXIRQ];
54
+FIELD(V7M_FPCCR, BFRDY, 6, 1)
45
/* Cached information: pointer to the cpu i/f for the CPUs specified
55
+FIELD(V7M_FPCCR, SFRDY, 7, 1)
46
@@ -XXX,XX +XXX,XX @@ GICV3_BITMAP_ACCESSORS(pending)
56
+FIELD(V7M_FPCCR, MONRDY, 8, 1)
47
GICV3_BITMAP_ACCESSORS(active)
57
+FIELD(V7M_FPCCR, SPLIMVIOL, 9, 1)
48
GICV3_BITMAP_ACCESSORS(level)
58
+FIELD(V7M_FPCCR, UFRDY, 10, 1)
49
GICV3_BITMAP_ACCESSORS(edge_trigger)
59
+FIELD(V7M_FPCCR, RES0, 11, 15)
50
+GICV3_BITMAP_ACCESSORS(nmi)
60
+FIELD(V7M_FPCCR, TS, 26, 1)
51
61
+FIELD(V7M_FPCCR, CLRONRETS, 27, 1)
52
#define TYPE_ARM_GICV3_COMMON "arm-gicv3-common"
62
+FIELD(V7M_FPCCR, CLRONRET, 28, 1)
53
typedef struct ARMGICv3CommonClass ARMGICv3CommonClass;
63
+FIELD(V7M_FPCCR, LSPENS, 29, 1)
54
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
64
+FIELD(V7M_FPCCR, LSPEN, 30, 1)
65
+FIELD(V7M_FPCCR, ASPEN, 31, 1)
66
+/* These bits are banked. Others are non-banked and live in the M_REG_S bank */
67
+#define R_V7M_FPCCR_BANKED_MASK \
68
+ (R_V7M_FPCCR_LSPACT_MASK | \
69
+ R_V7M_FPCCR_USER_MASK | \
70
+ R_V7M_FPCCR_THREAD_MASK | \
71
+ R_V7M_FPCCR_MMRDY_MASK | \
72
+ R_V7M_FPCCR_SPLIMVIOL_MASK | \
73
+ R_V7M_FPCCR_UFRDY_MASK | \
74
+ R_V7M_FPCCR_ASPEN_MASK)
75
+
76
/*
77
* System register ID fields.
78
*/
79
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
80
index XXXXXXX..XXXXXXX 100644
55
index XXXXXXX..XXXXXXX 100644
81
--- a/hw/intc/armv7m_nvic.c
56
--- a/hw/intc/arm_gicv3_common.c
82
+++ b/hw/intc/armv7m_nvic.c
57
+++ b/hw/intc/arm_gicv3_common.c
83
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
58
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_gicv3_gicv4 = {
84
}
85
case 0xd84: /* CSSELR */
86
return cpu->env.v7m.csselr[attrs.secure];
87
+ case 0xd88: /* CPACR */
88
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
89
+ return 0;
90
+ }
91
+ return cpu->env.v7m.cpacr[attrs.secure];
92
+ case 0xd8c: /* NSACR */
93
+ if (!attrs.secure || !arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
94
+ return 0;
95
+ }
96
+ return cpu->env.v7m.nsacr;
97
/* TODO: Implement debug registers. */
98
case 0xd90: /* MPU_TYPE */
99
/* Unified MPU; if the MPU is not present this value is zero */
100
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
101
return 0;
102
}
103
return cpu->env.v7m.sfar;
104
+ case 0xf34: /* FPCCR */
105
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
106
+ return 0;
107
+ }
108
+ if (attrs.secure) {
109
+ return cpu->env.v7m.fpccr[M_REG_S];
110
+ } else {
111
+ /*
112
+ * NS can read LSPEN, CLRONRET and MONRDY. It can read
113
+ * BFRDY and HFRDY if AIRCR.BFHFNMINS != 0;
114
+ * other non-banked bits RAZ.
115
+ * TODO: MONRDY should RAZ/WI if DEMCR.SDME is set.
116
+ */
117
+ uint32_t value = cpu->env.v7m.fpccr[M_REG_S];
118
+ uint32_t mask = R_V7M_FPCCR_LSPEN_MASK |
119
+ R_V7M_FPCCR_CLRONRET_MASK |
120
+ R_V7M_FPCCR_MONRDY_MASK;
121
+
122
+ if (s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
123
+ mask |= R_V7M_FPCCR_BFRDY_MASK | R_V7M_FPCCR_HFRDY_MASK;
124
+ }
125
+
126
+ value &= mask;
127
+
128
+ value |= cpu->env.v7m.fpccr[M_REG_NS];
129
+ return value;
130
+ }
131
+ case 0xf38: /* FPCAR */
132
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
133
+ return 0;
134
+ }
135
+ return cpu->env.v7m.fpcar[attrs.secure];
136
+ case 0xf3c: /* FPDSCR */
137
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
138
+ return 0;
139
+ }
140
+ return cpu->env.v7m.fpdscr[attrs.secure];
141
case 0xf40: /* MVFR0 */
142
return cpu->isar.mvfr0;
143
case 0xf44: /* MVFR1 */
144
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
145
cpu->env.v7m.csselr[attrs.secure] = value & R_V7M_CSSELR_INDEX_MASK;
146
}
147
break;
148
+ case 0xd88: /* CPACR */
149
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
150
+ /* We implement only the Floating Point extension's CP10/CP11 */
151
+ cpu->env.v7m.cpacr[attrs.secure] = value & (0xf << 20);
152
+ }
153
+ break;
154
+ case 0xd8c: /* NSACR */
155
+ if (attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
156
+ /* We implement only the Floating Point extension's CP10/CP11 */
157
+ cpu->env.v7m.nsacr = value & (3 << 10);
158
+ }
159
+ break;
160
case 0xd90: /* MPU_TYPE */
161
return; /* RO */
162
case 0xd94: /* MPU_CTRL */
163
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
164
}
165
break;
166
}
167
+ case 0xf34: /* FPCCR */
168
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
169
+ /* Not all bits here are banked. */
170
+ uint32_t fpccr_s;
171
+
172
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
173
+ /* Don't allow setting of bits not present in v7M */
174
+ value &= (R_V7M_FPCCR_LSPACT_MASK |
175
+ R_V7M_FPCCR_USER_MASK |
176
+ R_V7M_FPCCR_THREAD_MASK |
177
+ R_V7M_FPCCR_HFRDY_MASK |
178
+ R_V7M_FPCCR_MMRDY_MASK |
179
+ R_V7M_FPCCR_BFRDY_MASK |
180
+ R_V7M_FPCCR_MONRDY_MASK |
181
+ R_V7M_FPCCR_LSPEN_MASK |
182
+ R_V7M_FPCCR_ASPEN_MASK);
183
+ }
184
+ value &= ~R_V7M_FPCCR_RES0_MASK;
185
+
186
+ if (!attrs.secure) {
187
+ /* Some non-banked bits are configurably writable by NS */
188
+ fpccr_s = cpu->env.v7m.fpccr[M_REG_S];
189
+ if (!(fpccr_s & R_V7M_FPCCR_LSPENS_MASK)) {
190
+ uint32_t lspen = FIELD_EX32(value, V7M_FPCCR, LSPEN);
191
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, LSPEN, lspen);
192
+ }
193
+ if (!(fpccr_s & R_V7M_FPCCR_CLRONRETS_MASK)) {
194
+ uint32_t cor = FIELD_EX32(value, V7M_FPCCR, CLRONRET);
195
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, CLRONRET, cor);
196
+ }
197
+ if ((s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
198
+ uint32_t hfrdy = FIELD_EX32(value, V7M_FPCCR, HFRDY);
199
+ uint32_t bfrdy = FIELD_EX32(value, V7M_FPCCR, BFRDY);
200
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, HFRDY, hfrdy);
201
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, BFRDY, bfrdy);
202
+ }
203
+ /* TODO MONRDY should RAZ/WI if DEMCR.SDME is set */
204
+ {
205
+ uint32_t monrdy = FIELD_EX32(value, V7M_FPCCR, MONRDY);
206
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, MONRDY, monrdy);
207
+ }
208
+
209
+ /*
210
+ * All other non-banked bits are RAZ/WI from NS; write
211
+ * just the banked bits to fpccr[M_REG_NS].
212
+ */
213
+ value &= R_V7M_FPCCR_BANKED_MASK;
214
+ cpu->env.v7m.fpccr[M_REG_NS] = value;
215
+ } else {
216
+ fpccr_s = value;
217
+ }
218
+ cpu->env.v7m.fpccr[M_REG_S] = fpccr_s;
219
+ }
220
+ break;
221
+ case 0xf38: /* FPCAR */
222
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
223
+ value &= ~7;
224
+ cpu->env.v7m.fpcar[attrs.secure] = value;
225
+ }
226
+ break;
227
+ case 0xf3c: /* FPDSCR */
228
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
229
+ value &= 0x07c00000;
230
+ cpu->env.v7m.fpdscr[attrs.secure] = value;
231
+ }
232
+ break;
233
case 0xf50: /* ICIALLU */
234
case 0xf58: /* ICIMVAU */
235
case 0xf5c: /* DCIMVAC */
236
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
237
index XXXXXXX..XXXXXXX 100644
238
--- a/target/arm/cpu.c
239
+++ b/target/arm/cpu.c
240
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s)
241
env->v7m.ccr[M_REG_S] |= R_V7M_CCR_UNALIGN_TRP_MASK;
242
}
243
244
+ if (arm_feature(env, ARM_FEATURE_VFP)) {
245
+ env->v7m.fpccr[M_REG_NS] = R_V7M_FPCCR_ASPEN_MASK;
246
+ env->v7m.fpccr[M_REG_S] = R_V7M_FPCCR_ASPEN_MASK |
247
+ R_V7M_FPCCR_LSPEN_MASK | R_V7M_FPCCR_S_MASK;
248
+ }
249
/* Unlike A/R profile, M profile defines the reset LR value */
250
env->regs[14] = 0xffffffff;
251
252
diff --git a/target/arm/machine.c b/target/arm/machine.c
253
index XXXXXXX..XXXXXXX 100644
254
--- a/target/arm/machine.c
255
+++ b/target/arm/machine.c
256
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_v8m = {
257
}
59
}
258
};
60
};
259
61
260
+static const VMStateDescription vmstate_m_fp = {
62
+static bool gicv3_cpu_nmi_needed(void *opaque)
261
+ .name = "cpu/m/fp",
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",
262
+ .version_id = 1,
71
+ .version_id = 1,
263
+ .minimum_version_id = 1,
72
+ .minimum_version_id = 1,
264
+ .needed = vfp_needed,
73
+ .needed = gicv3_cpu_nmi_needed,
265
+ .fields = (VMStateField[]) {
74
+ .fields = (const VMStateField[]) {
266
+ VMSTATE_UINT32_ARRAY(env.v7m.fpcar, ARMCPU, M_REG_NUM_BANKS),
75
+ VMSTATE_UINT32(gicr_inmir0, GICv3CPUState),
267
+ VMSTATE_UINT32_ARRAY(env.v7m.fpccr, ARMCPU, M_REG_NUM_BANKS),
268
+ VMSTATE_UINT32_ARRAY(env.v7m.fpdscr, ARMCPU, M_REG_NUM_BANKS),
269
+ VMSTATE_UINT32_ARRAY(env.v7m.cpacr, ARMCPU, M_REG_NUM_BANKS),
270
+ VMSTATE_UINT32(env.v7m.nsacr, ARMCPU),
271
+ VMSTATE_END_OF_LIST()
76
+ VMSTATE_END_OF_LIST()
272
+ }
77
+ }
273
+};
78
+};
274
+
79
+
275
static const VMStateDescription vmstate_m = {
80
static const VMStateDescription vmstate_gicv3_cpu = {
276
.name = "cpu/m",
81
.name = "arm_gicv3_cpu",
277
.version_id = 4,
82
.version_id = 1,
278
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = {
83
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3_cpu = {
279
&vmstate_m_scr,
84
&vmstate_gicv3_cpu_virt,
280
&vmstate_m_other_sp,
85
&vmstate_gicv3_cpu_sre_el1,
281
&vmstate_m_v8m,
86
&vmstate_gicv3_gicv4,
282
+ &vmstate_m_fp,
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,
283
NULL
121
NULL
284
}
122
}
285
};
123
};
286
--
124
--
287
2.20.1
125
2.34.1
288
289
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Since uWireSlave is only used in this new header, there is no
3
Add GICR_INMIR0 register and support access GICR_INMIR0.
4
need to expose it via "qemu/typedefs.h".
5
4
6
Reviewed-by: Markus Armbruster <armbru@redhat.com>
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190412165416.7977-9-philmd@redhat.com
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20240407081733.3231820-17-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
include/hw/arm/omap.h | 6 +-----
11
hw/intc/gicv3_internal.h | 1 +
12
include/hw/devices.h | 15 ---------------
12
hw/intc/arm_gicv3_redist.c | 19 +++++++++++++++++++
13
include/hw/input/tsc2xxx.h | 36 ++++++++++++++++++++++++++++++++++++
13
2 files changed, 20 insertions(+)
14
include/qemu/typedefs.h | 1 -
15
hw/arm/nseries.c | 2 +-
16
hw/arm/palm.c | 2 +-
17
hw/input/tsc2005.c | 2 +-
18
hw/input/tsc210x.c | 4 ++--
19
MAINTAINERS | 2 ++
20
9 files changed, 44 insertions(+), 26 deletions(-)
21
create mode 100644 include/hw/input/tsc2xxx.h
22
14
23
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
15
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
24
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/arm/omap.h
17
--- a/hw/intc/gicv3_internal.h
26
+++ b/include/hw/arm/omap.h
18
+++ b/hw/intc/gicv3_internal.h
27
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
28
#include "exec/memory.h"
20
#define GICR_ICFGR1 (GICR_SGI_OFFSET + 0x0C04)
29
# define hw_omap_h        "omap.h"
21
#define GICR_IGRPMODR0 (GICR_SGI_OFFSET + 0x0D00)
30
#include "hw/irq.h"
22
#define GICR_NSACR (GICR_SGI_OFFSET + 0x0E00)
31
+#include "hw/input/tsc2xxx.h"
23
+#define GICR_INMIR0 (GICR_SGI_OFFSET + 0x0F80)
32
#include "target/arm/cpu-qom.h"
24
33
#include "qemu/log.h"
25
/* VLPI redistributor registers, offsets from VLPI_base */
34
26
#define GICR_VPROPBASER (GICR_VLPI_OFFSET + 0x70)
35
@@ -XXX,XX +XXX,XX @@ qemu_irq *omap_mpuio_in_get(struct omap_mpuio_s *s);
27
diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c
36
void omap_mpuio_out_set(struct omap_mpuio_s *s, int line, qemu_irq handler);
37
void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down);
38
39
-struct uWireSlave {
40
- uint16_t (*receive)(void *opaque);
41
- void (*send)(void *opaque, uint16_t data);
42
- void *opaque;
43
-};
44
struct omap_uwire_s;
45
void omap_uwire_attach(struct omap_uwire_s *s,
46
uWireSlave *slave, int chipselect);
47
diff --git a/include/hw/devices.h b/include/hw/devices.h
48
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
49
--- a/include/hw/devices.h
29
--- a/hw/intc/arm_gicv3_redist.c
50
+++ b/include/hw/devices.h
30
+++ b/hw/intc/arm_gicv3_redist.c
51
@@ -XXX,XX +XXX,XX @@
31
@@ -XXX,XX +XXX,XX @@ static int gicr_ns_access(GICv3CPUState *cs, int irq)
52
/* Devices that have nowhere better to go. */
32
return extract32(cs->gicr_nsacr, irq * 2, 2);
53
33
}
54
#include "hw/hw.h"
34
55
-#include "ui/console.h"
35
+static void gicr_write_bitmap_reg(GICv3CPUState *cs, MemTxAttrs attrs,
56
36
+ uint32_t *reg, uint32_t val)
57
/* smc91c111.c */
37
+{
58
void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
38
+ /* Helper routine to implement writing to a "set" register */
59
@@ -XXX,XX +XXX,XX @@ void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
39
+ val &= mask_group(cs, attrs);
60
/* lan9118.c */
40
+ *reg = val;
61
void lan9118_init(NICInfo *, uint32_t, qemu_irq);
41
+ gicv3_redist_update(cs);
62
42
+}
63
-/* tsc210x.c */
64
-uWireSlave *tsc2102_init(qemu_irq pint);
65
-uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav);
66
-I2SCodec *tsc210x_codec(uWireSlave *chip);
67
-uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len);
68
-void tsc210x_set_transform(uWireSlave *chip,
69
- MouseTransformInfo *info);
70
-void tsc210x_key_event(uWireSlave *chip, int key, int down);
71
-
72
-/* tsc2005.c */
73
-void *tsc2005_init(qemu_irq pintdav);
74
-uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
75
-void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
76
-
77
#endif
78
diff --git a/include/hw/input/tsc2xxx.h b/include/hw/input/tsc2xxx.h
79
new file mode 100644
80
index XXXXXXX..XXXXXXX
81
--- /dev/null
82
+++ b/include/hw/input/tsc2xxx.h
83
@@ -XXX,XX +XXX,XX @@
84
+/*
85
+ * TI touchscreen controller
86
+ *
87
+ * Copyright (c) 2006 Andrzej Zaborowski
88
+ * Copyright (C) 2008 Nokia Corporation
89
+ *
90
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
91
+ * See the COPYING file in the top-level directory.
92
+ */
93
+
43
+
94
+#ifndef HW_INPUT_TSC2XXX_H
44
static void gicr_write_set_bitmap_reg(GICv3CPUState *cs, MemTxAttrs attrs,
95
+#define HW_INPUT_TSC2XXX_H
45
uint32_t *reg, uint32_t val)
46
{
47
@@ -XXX,XX +XXX,XX @@ static MemTxResult gicr_readl(GICv3CPUState *cs, hwaddr offset,
48
*data = value;
49
return MEMTX_OK;
50
}
51
+ case GICR_INMIR0:
52
+ *data = cs->gic->nmi_support ?
53
+ gicr_read_bitmap_reg(cs, attrs, cs->gicr_inmir0) : 0;
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;
96
+
67
+
97
+#include "hw/irq.h"
68
case GICR_ICFGR0:
98
+#include "ui/console.h"
69
/* Register is all RAZ/WI or RAO/WI bits */
99
+
70
return MEMTX_OK;
100
+typedef struct uWireSlave {
101
+ uint16_t (*receive)(void *opaque);
102
+ void (*send)(void *opaque, uint16_t data);
103
+ void *opaque;
104
+} uWireSlave;
105
+
106
+/* tsc210x.c */
107
+uWireSlave *tsc2102_init(qemu_irq pint);
108
+uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav);
109
+I2SCodec *tsc210x_codec(uWireSlave *chip);
110
+uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len);
111
+void tsc210x_set_transform(uWireSlave *chip, MouseTransformInfo *info);
112
+void tsc210x_key_event(uWireSlave *chip, int key, int down);
113
+
114
+/* tsc2005.c */
115
+void *tsc2005_init(qemu_irq pintdav);
116
+uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
117
+void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
118
+
119
+#endif
120
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
121
index XXXXXXX..XXXXXXX 100644
122
--- a/include/qemu/typedefs.h
123
+++ b/include/qemu/typedefs.h
124
@@ -XXX,XX +XXX,XX @@ typedef struct RAMBlock RAMBlock;
125
typedef struct Range Range;
126
typedef struct SHPCDevice SHPCDevice;
127
typedef struct SSIBus SSIBus;
128
-typedef struct uWireSlave uWireSlave;
129
typedef struct VirtIODevice VirtIODevice;
130
typedef struct Visitor Visitor;
131
typedef void SaveStateHandler(QEMUFile *f, void *opaque);
132
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
133
index XXXXXXX..XXXXXXX 100644
134
--- a/hw/arm/nseries.c
135
+++ b/hw/arm/nseries.c
136
@@ -XXX,XX +XXX,XX @@
137
#include "ui/console.h"
138
#include "hw/boards.h"
139
#include "hw/i2c/i2c.h"
140
-#include "hw/devices.h"
141
#include "hw/display/blizzard.h"
142
+#include "hw/input/tsc2xxx.h"
143
#include "hw/misc/cbus.h"
144
#include "hw/misc/tmp105.h"
145
#include "hw/block/flash.h"
146
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
147
index XXXXXXX..XXXXXXX 100644
148
--- a/hw/arm/palm.c
149
+++ b/hw/arm/palm.c
150
@@ -XXX,XX +XXX,XX @@
151
#include "hw/arm/omap.h"
152
#include "hw/boards.h"
153
#include "hw/arm/arm.h"
154
-#include "hw/devices.h"
155
+#include "hw/input/tsc2xxx.h"
156
#include "hw/loader.h"
157
#include "exec/address-spaces.h"
158
#include "cpu.h"
159
diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c
160
index XXXXXXX..XXXXXXX 100644
161
--- a/hw/input/tsc2005.c
162
+++ b/hw/input/tsc2005.c
163
@@ -XXX,XX +XXX,XX @@
164
#include "hw/hw.h"
165
#include "qemu/timer.h"
166
#include "ui/console.h"
167
-#include "hw/devices.h"
168
+#include "hw/input/tsc2xxx.h"
169
#include "trace.h"
170
171
#define TSC_CUT_RESOLUTION(value, p)    ((value) >> (16 - (p ? 12 : 10)))
172
diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
173
index XXXXXXX..XXXXXXX 100644
174
--- a/hw/input/tsc210x.c
175
+++ b/hw/input/tsc210x.c
176
@@ -XXX,XX +XXX,XX @@
177
#include "audio/audio.h"
178
#include "qemu/timer.h"
179
#include "ui/console.h"
180
-#include "hw/arm/omap.h"    /* For I2SCodec and uWireSlave */
181
-#include "hw/devices.h"
182
+#include "hw/arm/omap.h" /* For I2SCodec */
183
+#include "hw/input/tsc2xxx.h"
184
185
#define TSC_DATA_REGISTERS_PAGE        0x0
186
#define TSC_CONTROL_REGISTERS_PAGE    0x1
187
diff --git a/MAINTAINERS b/MAINTAINERS
188
index XXXXXXX..XXXXXXX 100644
189
--- a/MAINTAINERS
190
+++ b/MAINTAINERS
191
@@ -XXX,XX +XXX,XX @@ F: hw/input/tsc2005.c
192
F: hw/misc/cbus.c
193
F: hw/timer/twl92230.c
194
F: include/hw/display/blizzard.h
195
+F: include/hw/input/tsc2xxx.h
196
F: include/hw/misc/cbus.h
197
198
Palm
199
@@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org
200
S: Odd Fixes
201
F: hw/arm/palm.c
202
F: hw/input/tsc210x.c
203
+F: include/hw/input/tsc2xxx.h
204
205
Raspberry Pi
206
M: Peter Maydell <peter.maydell@linaro.org>
207
--
71
--
208
2.20.1
72
2.34.1
209
210
diff view generated by jsdifflib
1
In the v7M architecture, if an exception is generated in the process
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
of doing the lazy stacking of FP registers, the handling of
3
possible escalation to HardFault is treated differently to the normal
4
approach: it works based on the saved information about exception
5
readiness that was stored in the FPCCR when the stack frame was
6
created. Provide a new function armv7m_nvic_set_pending_lazyfp()
7
which pends exceptions during lazy stacking, and implements
8
this logic.
9
2
10
This corresponds to the pseudocode TakePreserveFPException().
3
Add GICD_INMIR, GICD_INMIRnE register and support access GICD_INMIR0.
11
4
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20240407081733.3231820-18-ruanjinjie@huawei.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20190416125744.27770-22-peter.maydell@linaro.org
15
---
10
---
16
target/arm/cpu.h | 12 ++++++
11
hw/intc/gicv3_internal.h | 2 ++
17
hw/intc/armv7m_nvic.c | 96 +++++++++++++++++++++++++++++++++++++++++++
12
hw/intc/arm_gicv3_dist.c | 34 ++++++++++++++++++++++++++++++++++
18
2 files changed, 108 insertions(+)
13
2 files changed, 36 insertions(+)
19
14
20
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
15
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
21
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/cpu.h
17
--- a/hw/intc/gicv3_internal.h
23
+++ b/target/arm/cpu.h
18
+++ b/hw/intc/gicv3_internal.h
24
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure);
19
@@ -XXX,XX +XXX,XX @@
25
* a different exception).
20
#define GICD_SGIR 0x0F00
26
*/
21
#define GICD_CPENDSGIR 0x0F10
27
void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure);
22
#define GICD_SPENDSGIR 0x0F20
28
+/**
23
+#define GICD_INMIR 0x0F80
29
+ * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending
24
+#define GICD_INMIRnE 0x3B00
30
+ * @opaque: the NVIC
25
#define GICD_IROUTER 0x6000
31
+ * @irq: the exception number to mark pending
26
#define GICD_IDREGS 0xFFD0
32
+ * @secure: false for non-banked exceptions or for the nonsecure
27
33
+ * version of a banked exception, true for the secure version of a banked
28
diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c
34
+ * exception.
35
+ *
36
+ * Similar to armv7m_nvic_set_pending(), but specifically for exceptions
37
+ * generated in the course of lazy stacking of FP registers.
38
+ */
39
+void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure);
40
/**
41
* armv7m_nvic_get_pending_irq_info: return highest priority pending
42
* exception, and whether it targets Secure state
43
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
44
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/intc/armv7m_nvic.c
30
--- a/hw/intc/arm_gicv3_dist.c
46
+++ b/hw/intc/armv7m_nvic.c
31
+++ b/hw/intc/arm_gicv3_dist.c
47
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure)
32
@@ -XXX,XX +XXX,XX @@ static int gicd_ns_access(GICv3State *s, int irq)
48
do_armv7m_nvic_set_pending(opaque, irq, secure, true);
33
return extract32(s->gicd_nsacr[irq / 16], (irq % 16) * 2, 2);
49
}
34
}
50
35
51
+void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure)
36
+static void gicd_write_bitmap_reg(GICv3State *s, MemTxAttrs attrs,
37
+ uint32_t *bmp, maskfn *maskfn,
38
+ int offset, uint32_t val)
52
+{
39
+{
53
+ /*
40
+ /*
54
+ * Pend an exception during lazy FP stacking. This differs
41
+ * Helper routine to implement writing to a "set" register
55
+ * from the usual exception pending because the logic for
42
+ * (GICD_INMIR, etc).
56
+ * whether we should escalate depends on the saved context
43
+ * Semantics implemented here:
57
+ * in the FPCCR register, not on the current state of the CPU/NVIC.
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.
58
+ */
48
+ */
59
+ NVICState *s = (NVICState *)opaque;
49
+ int irq = offset * 8;
60
+ bool banked = exc_is_banked(irq);
61
+ VecInfo *vec;
62
+ bool targets_secure;
63
+ bool escalate = false;
64
+ /*
65
+ * We will only look at bits in fpccr if this is a banked exception
66
+ * (in which case 'secure' tells us whether it is the S or NS version).
67
+ * All the bits for the non-banked exceptions are in fpccr_s.
68
+ */
69
+ uint32_t fpccr_s = s->cpu->env.v7m.fpccr[M_REG_S];
70
+ uint32_t fpccr = s->cpu->env.v7m.fpccr[secure];
71
+
50
+
72
+ assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
51
+ if (irq < GIC_INTERNAL || irq >= s->num_irq) {
73
+ assert(!secure || banked);
52
+ return;
74
+
75
+ vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq];
76
+
77
+ targets_secure = banked ? secure : exc_targets_secure(s, irq);
78
+
79
+ switch (irq) {
80
+ case ARMV7M_EXCP_DEBUG:
81
+ if (!(fpccr_s & R_V7M_FPCCR_MONRDY_MASK)) {
82
+ /* Ignore DebugMonitor exception */
83
+ return;
84
+ }
85
+ break;
86
+ case ARMV7M_EXCP_MEM:
87
+ escalate = !(fpccr & R_V7M_FPCCR_MMRDY_MASK);
88
+ break;
89
+ case ARMV7M_EXCP_USAGE:
90
+ escalate = !(fpccr & R_V7M_FPCCR_UFRDY_MASK);
91
+ break;
92
+ case ARMV7M_EXCP_BUS:
93
+ escalate = !(fpccr_s & R_V7M_FPCCR_BFRDY_MASK);
94
+ break;
95
+ case ARMV7M_EXCP_SECURE:
96
+ escalate = !(fpccr_s & R_V7M_FPCCR_SFRDY_MASK);
97
+ break;
98
+ default:
99
+ g_assert_not_reached();
100
+ }
53
+ }
101
+
54
+ val &= mask_group_and_nsacr(s, attrs, maskfn, irq);
102
+ if (escalate) {
55
+ *gic_bmp_ptr32(bmp, irq) = val;
103
+ /*
56
+ gicv3_update(s, irq, 32);
104
+ * Escalate to HardFault: faults that initially targeted Secure
105
+ * continue to do so, even if HF normally targets NonSecure.
106
+ */
107
+ irq = ARMV7M_EXCP_HARD;
108
+ if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) &&
109
+ (targets_secure ||
110
+ !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK))) {
111
+ vec = &s->sec_vectors[irq];
112
+ } else {
113
+ vec = &s->vectors[irq];
114
+ }
115
+ }
116
+
117
+ if (!vec->enabled ||
118
+ nvic_exec_prio(s) <= exc_group_prio(s, vec->prio, secure)) {
119
+ if (!(fpccr_s & R_V7M_FPCCR_HFRDY_MASK)) {
120
+ /*
121
+ * We want to escalate to HardFault but the context the
122
+ * FP state belongs to prevents the exception pre-empting.
123
+ */
124
+ cpu_abort(&s->cpu->parent_obj,
125
+ "Lockup: can't escalate to HardFault during "
126
+ "lazy FP register stacking\n");
127
+ }
128
+ }
129
+
130
+ if (escalate) {
131
+ s->cpu->env.v7m.hfsr |= R_V7M_HFSR_FORCED_MASK;
132
+ }
133
+ if (!vec->pending) {
134
+ vec->pending = 1;
135
+ /*
136
+ * We do not call nvic_irq_update(), because we know our caller
137
+ * is going to handle causing us to take the exception by
138
+ * raising EXCP_LAZYFP, so raising the IRQ line would be
139
+ * pointless extra work. We just need to recompute the
140
+ * priorities so that armv7m_nvic_can_take_pending_exception()
141
+ * returns the right answer.
142
+ */
143
+ nvic_recompute_state(s);
144
+ }
145
+}
57
+}
146
+
58
+
147
/* Make pending IRQ active. */
59
static void gicd_write_set_bitmap_reg(GICv3State *s, MemTxAttrs attrs,
148
void armv7m_nvic_acknowledge_irq(void *opaque)
60
uint32_t *bmp,
149
{
61
maskfn *maskfn,
62
@@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset,
63
/* RAZ/WI since affinity routing is always enabled */
64
*data = 0;
65
return true;
66
+ case GICD_INMIR ... GICD_INMIR + 0x7f:
67
+ *data = (!s->nmi_support) ? 0 :
68
+ gicd_read_bitmap_reg(s, attrs, s->nmi, NULL,
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;
150
--
87
--
151
2.20.1
88
2.34.1
152
153
diff view generated by jsdifflib
1
The magic value pushed onto the callee stack as an integrity
1
Add the NMIAR CPU interface registers which deal with acknowledging NMI.
2
check is different if floating point is present.
3
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
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20190416125744.27770-15-peter.maydell@linaro.org
7
---
19
---
8
target/arm/helper.c | 22 +++++++++++++++++++---
20
hw/intc/gicv3_internal.h | 5 +
9
1 file changed, 19 insertions(+), 3 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(-)
10
25
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
26
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
12
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
28
--- a/hw/intc/gicv3_internal.h
14
+++ b/target/arm/helper.c
29
+++ b/hw/intc/gicv3_internal.h
15
@@ -XXX,XX +XXX,XX @@ load_fail:
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)) {
125
return false;
126
}
127
128
- if (cs->hppi.prio >= cs->icc_pmr_el1) {
129
+ if (cs->hppi.nmi) {
130
+ if (!(cs->gic->gicd_ctlr & GICD_CTLR_DS) &&
131
+ cs->hppi.grp == GICV3_G1NS) {
132
+ if (cs->icc_pmr_el1 < 0x80) {
133
+ return false;
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)
144
return true;
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
+
16
return false;
153
return false;
17
}
154
}
18
155
19
+static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr)
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)
20
+{
196
+{
21
+ /*
197
+ GICv3CPUState *cs = icc_cs_from_env(env);
22
+ * Return the integrity signature value for the callee-saves
198
+ uint64_t intid;
23
+ * stack frame section. @lr is the exception return payload/LR value
199
+
24
+ * whose FType bit forms bit 0 of the signature if FP is present.
200
+ if (icv_access(env, HCR_IMO)) {
25
+ */
201
+ return icv_nmiar1_read(env, ri);
26
+ uint32_t sig = 0xfefa125a;
202
+ }
27
+
203
+
28
+ if (!arm_feature(env, ARM_FEATURE_VFP) || (lr & R_V7M_EXCRET_FTYPE_MASK)) {
204
+ if (!icc_hppi_can_preempt(cs)) {
29
+ sig |= 1;
205
+ intid = INTID_SPURIOUS;
30
+ }
206
+ } else {
31
+ return sig;
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;
32
+}
220
+}
33
+
221
+
34
static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
222
static void icc_drop_prio(GICv3CPUState *cs, int grp)
35
bool ignore_faults)
223
{
36
{
224
/* Drop the priority of the currently active interrupt in
37
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
225
@@ -XXX,XX +XXX,XX @@ static void icc_drop_prio(GICv3CPUState *cs, int grp)
38
bool stacked_ok;
226
if (!*papr) {
39
uint32_t limit;
227
continue;
40
bool want_psp;
228
}
41
+ uint32_t sig;
229
+
42
230
+ if (i == 0 && cs->nmi_support && (*papr & ICC_AP1R_EL1_NMI)) {
43
if (dotailchain) {
231
+ *papr &= (~ICC_AP1R_EL1_NMI);
44
bool mode = lr & R_V7M_EXCRET_MODE_MASK;
232
+ break;
45
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
233
+ }
46
/* Write as much of the stack frame as we can. A write failure may
234
+
47
* cause us to pend a derived exception.
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)
48
*/
239
*/
49
+ sig = v7m_integrity_sig(env, lr);
240
int i;
50
stacked_ok =
241
51
- v7m_stack_write(cpu, frameptr, 0xfefa125b, mmu_idx, ignore_faults) &&
242
+ if (cs->nmi_support) {
52
+ v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) &&
243
+ if (cs->icc_apr[GICV3_G1][0] & ICC_AP1R_EL1_NMI) {
53
v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx,
244
+ return GICV3_G1;
54
ignore_faults) &&
245
+ }
55
v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx,
246
+ if (cs->icc_apr[GICV3_G1NS][0] & ICC_AP1R_EL1_NMI) {
56
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
247
+ return GICV3_G1NS;
57
if (return_to_secure &&
248
+ }
58
((excret & R_V7M_EXCRET_ES_MASK) == 0 ||
249
+ }
59
(excret & R_V7M_EXCRET_DCRS_MASK) == 0)) {
250
+
60
- uint32_t expected_sig = 0xfefa125b;
251
for (i = 0; i < ARRAY_SIZE(cs->icc_apr[0]); i++) {
61
uint32_t actual_sig;
252
int g0ctz = ctz32(cs->icc_apr[GICV3_G0][i]);
62
253
int g1ctz = ctz32(cs->icc_apr[GICV3_G1][i]);
63
pop_ok = v7m_stack_read(cpu, &actual_sig, frameptr, mmu_idx);
254
@@ -XXX,XX +XXX,XX @@ static void icc_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
64
255
return;
65
- if (pop_ok && expected_sig != actual_sig) {
256
}
66
+ if (pop_ok && v7m_integrity_sig(env, excret) != actual_sig) {
257
67
/* Take a SecureFault on the current stack */
258
- cs->icc_apr[grp][regno] = value & 0xFFFFFFFFU;
68
env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK;
259
+ if (cs->nmi_support) {
69
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
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
70
--
347
--
71
2.20.1
348
2.34.1
72
73
diff view generated by jsdifflib
1
Handle floating point registers in exception entry.
1
Implement icv_nmiar1_read() for icc_nmiar1_read(), so add definition for
2
This corresponds to the FP-specific parts of the pseudocode
2
ICH_LR_EL2.NMI and ICH_AP1R_EL2.NMI bit.
3
functions ActivateException() and PushStack().
3
4
4
If FEAT_GICv3_NMI is supported, ich_ap_write() should consider ICV_AP1R_EL1.NMI
5
We defer the code corresponding to UpdateFPCCR() to a later patch.
5
bit. In icv_activate_irq() and icv_eoir_write(), the ICV_AP1R_EL1.NMI bit
6
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
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-11-peter.maydell@linaro.org
10
---
20
---
11
target/arm/helper.c | 98 +++++++++++++++++++++++++++++++++++++++++++--
21
hw/intc/gicv3_internal.h | 4 ++
12
1 file changed, 95 insertions(+), 3 deletions(-)
22
hw/intc/arm_gicv3_cpuif.c | 105 +++++++++++++++++++++++++++++++++-----
13
23
hw/intc/trace-events | 1 +
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
24
3 files changed, 98 insertions(+), 12 deletions(-)
25
26
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
15
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
28
--- a/hw/intc/gicv3_internal.h
17
+++ b/target/arm/helper.c
29
+++ b/hw/intc/gicv3_internal.h
18
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
30
@@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1)
19
switch_v7m_security_state(env, targets_secure);
31
#define ICH_LR_EL2_PRIORITY_SHIFT 48
20
write_v7m_control_spsel(env, 0);
32
#define ICH_LR_EL2_PRIORITY_LENGTH 8
21
arm_clear_exclusive(env);
33
#define ICH_LR_EL2_PRIORITY_MASK (0xffULL << ICH_LR_EL2_PRIORITY_SHIFT)
22
+ /* Clear SFPA and FPCA (has no effect if no FPU) */
34
+#define ICH_LR_EL2_NMI (1ULL << 59)
23
+ env->v7m.control[M_REG_S] &=
35
#define ICH_LR_EL2_GROUP (1ULL << 60)
24
+ ~(R_V7M_CONTROL_FPCA_MASK | R_V7M_CONTROL_SFPA_MASK);
36
#define ICH_LR_EL2_HW (1ULL << 61)
25
/* Clear IT bits */
37
#define ICH_LR_EL2_STATE_SHIFT 62
26
env->condexec_bits = 0;
38
@@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1)
27
env->regs[14] = lr;
39
#define ICH_VTR_EL2_PREBITS_SHIFT 26
28
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
40
#define ICH_VTR_EL2_PRIBITS_SHIFT 29
29
uint32_t xpsr = xpsr_read(env);
41
30
uint32_t frameptr = env->regs[13];
42
+#define ICV_AP1R_EL1_NMI (1ULL << 63)
31
ARMMMUIdx mmu_idx = arm_mmu_idx(env);
43
+#define ICV_RPR_EL1_NMI (1ULL << 63)
32
+ uint32_t framesize;
44
+
33
+ bool nsacr_cp10 = extract32(env->v7m.nsacr, 10, 1);
45
/* ITS Registers */
34
+
46
35
+ if ((env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) &&
47
FIELD(GITS_BASER, SIZE, 0, 8)
36
+ (env->v7m.secure || nsacr_cp10)) {
48
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
37
+ if (env->v7m.secure &&
49
index XXXXXXX..XXXXXXX 100644
38
+ env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK) {
50
--- a/hw/intc/arm_gicv3_cpuif.c
39
+ framesize = 0xa8;
51
+++ b/hw/intc/arm_gicv3_cpuif.c
40
+ } else {
52
@@ -XXX,XX +XXX,XX @@ static int ich_highest_active_virt_prio(GICv3CPUState *cs)
41
+ framesize = 0x68;
53
int i;
42
+ }
54
int aprmax = ich_num_aprs(cs);
55
56
+ if (cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI) {
57
+ return 0x0;
58
+ }
59
+
60
for (i = 0; i < aprmax; i++) {
61
uint32_t apr = cs->ich_apr[GICV3_G0][i] |
62
cs->ich_apr[GICV3_G1NS][i];
63
@@ -XXX,XX +XXX,XX @@ static int hppvi_index(GICv3CPUState *cs)
64
* correct behaviour.
65
*/
66
int prio = 0xff;
67
+ bool nmi = false;
68
69
if (!(cs->ich_vmcr_el2 & (ICH_VMCR_EL2_VENG0 | ICH_VMCR_EL2_VENG1))) {
70
/* Both groups disabled, definitely nothing to do */
71
@@ -XXX,XX +XXX,XX @@ static int hppvi_index(GICv3CPUState *cs)
72
73
for (i = 0; i < cs->num_list_regs; i++) {
74
uint64_t lr = cs->ich_lr_el2[i];
75
+ bool thisnmi;
76
int thisprio;
77
78
if (ich_lr_state(lr) != ICH_LR_EL2_STATE_PENDING) {
79
@@ -XXX,XX +XXX,XX @@ static int hppvi_index(GICv3CPUState *cs)
80
}
81
}
82
83
+ thisnmi = lr & ICH_LR_EL2_NMI;
84
thisprio = ich_lr_prio(lr);
85
86
- if (thisprio < prio) {
87
+ if ((thisprio < prio) || ((thisprio == prio) && (thisnmi & (!nmi)))) {
88
prio = thisprio;
89
+ nmi = thisnmi;
90
idx = i;
91
}
92
}
93
@@ -XXX,XX +XXX,XX @@ static bool icv_hppi_can_preempt(GICv3CPUState *cs, uint64_t lr)
94
* equivalent of these checks.
95
*/
96
int grp;
97
+ bool is_nmi;
98
uint32_t mask, prio, rprio, vpmr;
99
100
if (!(cs->ich_hcr_el2 & ICH_HCR_EL2_EN)) {
101
@@ -XXX,XX +XXX,XX @@ static bool icv_hppi_can_preempt(GICv3CPUState *cs, uint64_t lr)
102
*/
103
104
prio = ich_lr_prio(lr);
105
+ is_nmi = lr & ICH_LR_EL2_NMI;
106
vpmr = extract64(cs->ich_vmcr_el2, ICH_VMCR_EL2_VPMR_SHIFT,
107
ICH_VMCR_EL2_VPMR_LENGTH);
108
109
- if (prio >= vpmr) {
110
+ if (!is_nmi && prio >= vpmr) {
111
/* Priority mask masks this interrupt */
112
return false;
113
}
114
@@ -XXX,XX +XXX,XX @@ static bool icv_hppi_can_preempt(GICv3CPUState *cs, uint64_t lr)
115
return true;
116
}
117
118
+ if ((prio & mask) == (rprio & mask) && is_nmi &&
119
+ !(cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI)) {
120
+ return true;
121
+ }
122
+
123
return false;
124
}
125
126
@@ -XXX,XX +XXX,XX @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
127
128
trace_gicv3_icv_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value);
129
130
- cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU;
131
+ if (cs->nmi_support) {
132
+ cs->ich_apr[grp][regno] = value & (0xFFFFFFFFU | ICV_AP1R_EL1_NMI);
43
+ } else {
133
+ } else {
44
+ framesize = 0x20;
134
+ cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU;
45
+ }
135
+ }
46
136
47
/* Align stack pointer if the guest wants that */
137
gicv3_cpuif_virt_irq_fiq_update(cs);
48
if ((frameptr & 4) &&
138
return;
49
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
139
@@ -XXX,XX +XXX,XX @@ static void icv_ctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
50
xpsr |= XPSR_SPREALIGN;
140
static uint64_t icv_rpr_read(CPUARMState *env, const ARMCPRegInfo *ri)
51
}
141
{
52
142
GICv3CPUState *cs = icc_cs_from_env(env);
53
- frameptr -= 0x20;
143
- int prio = ich_highest_active_virt_prio(cs);
54
+ xpsr &= ~XPSR_SFPA;
144
+ uint64_t prio = ich_highest_active_virt_prio(cs);
55
+ if (env->v7m.secure &&
145
+
56
+ (env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) {
146
+ if (cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI) {
57
+ xpsr |= XPSR_SFPA;
147
+ prio |= ICV_RPR_EL1_NMI;
58
+ }
148
+ }
59
+
149
60
+ frameptr -= framesize;
150
trace_gicv3_icv_rpr_read(gicv3_redist_affid(cs), prio);
61
151
return prio;
62
if (arm_feature(env, ARM_FEATURE_V8)) {
152
@@ -XXX,XX +XXX,XX @@ static void icv_activate_irq(GICv3CPUState *cs, int idx, int grp)
63
uint32_t limit = v7m_sp_limit(env);
153
*/
64
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
154
uint32_t mask = icv_gprio_mask(cs, grp);
65
v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) &&
155
int prio = ich_lr_prio(cs->ich_lr_el2[idx]) & mask;
66
v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false);
156
+ bool nmi = cs->ich_lr_el2[idx] & ICH_LR_EL2_NMI;
67
157
int aprbit = prio >> (8 - cs->vprebits);
68
+ if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) {
158
int regno = aprbit / 32;
69
+ /* FPU is active, try to save its registers */
159
int regbit = aprbit % 32;
70
+ bool fpccr_s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
160
71
+ bool lspact = env->v7m.fpccr[fpccr_s] & R_V7M_FPCCR_LSPACT_MASK;
161
cs->ich_lr_el2[idx] &= ~ICH_LR_EL2_STATE_PENDING_BIT;
72
+
162
cs->ich_lr_el2[idx] |= ICH_LR_EL2_STATE_ACTIVE_BIT;
73
+ if (lspact && arm_feature(env, ARM_FEATURE_M_SECURITY)) {
163
- cs->ich_apr[grp][regno] |= (1 << regbit);
74
+ qemu_log_mask(CPU_LOG_INT,
164
+
75
+ "...SecureFault because LSPACT and FPCA both set\n");
165
+ if (nmi) {
76
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
166
+ cs->ich_apr[grp][regno] |= ICV_AP1R_EL1_NMI;
77
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
167
+ } else {
78
+ } else if (!env->v7m.secure && !nsacr_cp10) {
168
+ cs->ich_apr[grp][regno] |= (1 << regbit);
79
+ qemu_log_mask(CPU_LOG_INT,
169
+ }
80
+ "...Secure UsageFault with CFSR.NOCP because "
170
}
81
+ "NSACR.CP10 prevents stacking FP regs\n");
171
82
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, M_REG_S);
172
static void icv_activate_vlpi(GICv3CPUState *cs)
83
+ env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK;
173
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri)
84
+ } else {
174
int grp = ri->crm == 8 ? GICV3_G0 : GICV3_G1NS;
85
+ if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) {
175
int idx = hppvi_index(cs);
86
+ /* Lazy stacking disabled, save registers now */
176
uint64_t intid = INTID_SPURIOUS;
87
+ int i;
177
+ int el = arm_current_el(env);
88
+ bool cpacr_pass = v7m_cpacr_pass(env, env->v7m.secure,
178
89
+ arm_current_el(env) != 0);
179
if (idx == HPPVI_INDEX_VLPI) {
90
+
180
if (cs->hppvlpi.grp == grp && icv_hppvlpi_can_preempt(cs)) {
91
+ if (stacked_ok && !cpacr_pass) {
181
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri)
92
+ /*
182
} else if (idx >= 0) {
93
+ * Take UsageFault if CPACR forbids access. The pseudocode
183
uint64_t lr = cs->ich_lr_el2[idx];
94
+ * here does a full CheckCPEnabled() but we know the NSACR
184
int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0;
95
+ * check can never fail as we have already handled that.
185
+ bool nmi = env->cp15.sctlr_el[el] & SCTLR_NMI && lr & ICH_LR_EL2_NMI;
96
+ */
186
97
+ qemu_log_mask(CPU_LOG_INT,
187
if (thisgrp == grp && icv_hppi_can_preempt(cs, lr)) {
98
+ "...UsageFault with CFSR.NOCP because "
188
intid = ich_lr_vintid(lr);
99
+ "CPACR.CP10 prevents stacking FP regs\n");
189
if (!gicv3_intid_is_special(intid)) {
100
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
190
- icv_activate_irq(cs, idx, grp);
101
+ env->v7m.secure);
191
+ if (!nmi) {
102
+ env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;
192
+ icv_activate_irq(cs, idx, grp);
103
+ stacked_ok = false;
193
+ } else {
194
+ intid = INTID_NMI;
104
+ }
195
+ }
105
+
196
} else {
106
+ for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) {
197
/* Interrupt goes from Pending to Invalid */
107
+ uint64_t dn = *aa32_vfp_dreg(env, i / 2);
198
cs->ich_lr_el2[idx] &= ~ICH_LR_EL2_STATE_PENDING_BIT;
108
+ uint32_t faddr = frameptr + 0x20 + 4 * i;
199
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri)
109
+ uint32_t slo = extract64(dn, 0, 32);
200
110
+ uint32_t shi = extract64(dn, 32, 32);
201
static uint64_t icv_nmiar1_read(CPUARMState *env, const ARMCPRegInfo *ri)
111
+
202
{
112
+ if (i >= 16) {
203
- /* todo */
113
+ faddr += 8; /* skip the slot for the FPSCR */
204
+ GICv3CPUState *cs = icc_cs_from_env(env);
114
+ }
205
+ int idx = hppvi_index(cs);
115
+ stacked_ok = stacked_ok &&
206
uint64_t intid = INTID_SPURIOUS;
116
+ v7m_stack_write(cpu, faddr, slo, mmu_idx, false) &&
207
+
117
+ v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, false);
208
+ if (idx >= 0 && idx != HPPVI_INDEX_VLPI) {
118
+ }
209
+ uint64_t lr = cs->ich_lr_el2[idx];
119
+ stacked_ok = stacked_ok &&
210
+ int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0;
120
+ v7m_stack_write(cpu, frameptr + 0x60,
211
+
121
+ vfp_get_fpscr(env), mmu_idx, false);
212
+ if ((thisgrp == GICV3_G1NS) && icv_hppi_can_preempt(cs, lr)) {
122
+ if (cpacr_pass) {
213
+ intid = ich_lr_vintid(lr);
123
+ for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) {
214
+ if (!gicv3_intid_is_special(intid)) {
124
+ *aa32_vfp_dreg(env, i / 2) = 0;
215
+ if (lr & ICH_LR_EL2_NMI) {
125
+ }
216
+ icv_activate_irq(cs, idx, GICV3_G1NS);
126
+ vfp_set_fpscr(env, 0);
217
+ } else {
218
+ intid = INTID_SPURIOUS;
127
+ }
219
+ }
128
+ } else {
220
+ } else {
129
+ /* Lazy stacking enabled, save necessary info to stack later */
221
+ /* Interrupt goes from Pending to Invalid */
130
+ /* TODO : equivalent of UpdateFPCCR() pseudocode */
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
+ */
131
+ }
227
+ }
132
+ }
228
+ }
133
+ }
229
+ }
134
+
230
+
135
/*
231
+ trace_gicv3_icv_nmiar1_read(gicv3_redist_affid(cs), intid);
136
* If we broke a stack limit then SP was already updated earlier;
232
+
137
* otherwise we update SP regardless of whether any of the stack
233
+ gicv3_cpuif_virt_update(cs);
138
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
234
+
139
235
return intid;
140
if (arm_feature(env, ARM_FEATURE_V8)) {
236
}
141
lr = R_V7M_EXCRET_RES1_MASK |
237
142
- R_V7M_EXCRET_DCRS_MASK |
238
@@ -XXX,XX +XXX,XX @@ static void icv_increment_eoicount(GICv3CPUState *cs)
143
- R_V7M_EXCRET_FTYPE_MASK;
239
ICH_HCR_EL2_EOICOUNT_LENGTH, eoicount + 1);
144
+ R_V7M_EXCRET_DCRS_MASK;
240
}
145
/* The S bit indicates whether we should return to Secure
241
146
* or NonSecure (ie our current state).
242
-static int icv_drop_prio(GICv3CPUState *cs)
147
* The ES bit indicates whether we're taking this exception
243
+static int icv_drop_prio(GICv3CPUState *cs, bool *nmi)
148
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
244
{
149
if (env->v7m.secure) {
245
/* Drop the priority of the currently active virtual interrupt
150
lr |= R_V7M_EXCRET_S_MASK;
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;
151
}
249
}
152
+ if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) {
250
153
+ lr |= R_V7M_EXCRET_FTYPE_MASK;
251
+ if (i == 0 && cs->nmi_support && (*papr1 & ICV_AP1R_EL1_NMI)) {
252
+ *papr1 &= (~ICV_AP1R_EL1_NMI);
253
+ *nmi = true;
254
+ return 0xff;
154
+ }
255
+ }
155
} else {
256
+
156
lr = R_V7M_EXCRET_RES1_MASK |
257
/* We can't just use the bit-twiddling hack icc_drop_prio() does
157
R_V7M_EXCRET_S_MASK |
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
316
index XXXXXXX..XXXXXXX 100644
317
--- a/hw/intc/trace-events
318
+++ b/hw/intc/trace-events
319
@@ -XXX,XX +XXX,XX @@ gicv3_icv_rpr_read(uint32_t cpu, uint64_t val) "GICv3 ICV_RPR read cpu 0x%x valu
320
gicv3_icv_hppir_read(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_HPPIR%d read cpu 0x%x value 0x%" PRIx64
321
gicv3_icv_dir_write(uint32_t cpu, uint64_t val) "GICv3 ICV_DIR write cpu 0x%x value 0x%" PRIx64
322
gicv3_icv_iar_read(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_IAR%d read cpu 0x%x value 0x%" PRIx64
323
+gicv3_icv_nmiar1_read(uint32_t cpu, uint64_t val) "GICv3 ICV_NMIAR1 read cpu 0x%x value 0x%" PRIx64
324
gicv3_icv_eoir_write(int grp, uint32_t cpu, uint64_t val) "GICv3 ICV_EOIR%d write cpu 0x%x value 0x%" PRIx64
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"
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"
158
--
327
--
159
2.20.1
328
2.34.1
160
161
diff view generated by jsdifflib
1
The M-profile CONTROL register has two bits -- SFPA and FPCA --
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
which relate to floating-point support, and should be RES0 otherwise.
3
Handle them correctly in the MSR/MRS register access code.
4
Neither is banked between security states, so they are stored
5
in v7m.control[M_REG_S] regardless of current security state.
6
2
3
If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI priority is
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.
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-21-ruanjinjie@huawei.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-9-peter.maydell@linaro.org
10
---
14
---
11
target/arm/helper.c | 57 ++++++++++++++++++++++++++++++++++++++-------
15
hw/intc/arm_gicv3.c | 67 +++++++++++++++++++++++++++++++++-----
12
1 file changed, 49 insertions(+), 8 deletions(-)
16
hw/intc/arm_gicv3_common.c | 3 ++
17
hw/intc/arm_gicv3_redist.c | 3 ++
18
3 files changed, 64 insertions(+), 9 deletions(-)
13
19
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
20
diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c
15
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
22
--- a/hw/intc/arm_gicv3.c
17
+++ b/target/arm/helper.c
23
+++ b/hw/intc/arm_gicv3.c
18
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
24
@@ -XXX,XX +XXX,XX @@
19
return xpsr_read(env) & mask;
25
#include "hw/intc/arm_gicv3.h"
20
break;
26
#include "gicv3_internal.h"
21
case 20: /* CONTROL */
27
22
- return env->v7m.control[env->v7m.secure];
28
-static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio)
23
+ {
29
+static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio, bool nmi)
24
+ uint32_t value = env->v7m.control[env->v7m.secure];
30
{
25
+ if (!env->v7m.secure) {
31
/* Return true if this IRQ at this priority should take
26
+ /* SFPA is RAZ/WI from NS; FPCA is stored in the M_REG_S bank */
32
* precedence over the current recorded highest priority
27
+ value |= env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK;
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;
28
+ }
84
+ }
29
+ return value;
85
+
30
+ }
86
+ return true;
31
case 0x94: /* CONTROL_NS */
87
+ }
32
/* We have to handle this here because unprivileged Secure code
88
+
33
* can read the NS CONTROL register.
89
+ if (is_redist) {
34
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
90
+ *prio = cs->gicr_ipriorityr[irq];
35
if (!env->v7m.secure) {
91
+ } else {
36
return 0;
92
+ *prio = cs->gic->gicd_ipriority[irq];
37
}
93
+ }
38
- return env->v7m.control[M_REG_NS];
94
+
39
+ return env->v7m.control[M_REG_NS] |
95
+ return false;
40
+ (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK);
96
+}
41
}
97
+
42
98
/* Update the interrupt status after state in a redistributor
43
if (el == 0) {
99
* or CPU interface has changed, but don't tell the CPU i/f.
44
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
100
*/
45
*/
101
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs)
46
uint32_t mask = extract32(maskreg, 8, 4);
102
uint8_t prio;
47
uint32_t reg = extract32(maskreg, 0, 8);
103
int i;
48
+ int cur_el = arm_current_el(env);
104
uint32_t pend;
49
105
+ bool nmi = false;
50
- if (arm_current_el(env) == 0 && reg > 7) {
106
51
- /* only xPSR sub-fields may be written by unprivileged */
107
/* Find out which redistributor interrupts are eligible to be
52
+ if (cur_el == 0 && reg > 7 && reg != 20) {
108
* signaled to the CPU interface.
53
+ /*
109
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs)
54
+ * only xPSR sub-fields and CONTROL.SFPA may be written by
110
if (!(pend & (1 << i))) {
55
+ * unprivileged code
111
continue;
56
+ */
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;
57
return;
206
return;
58
}
207
}
59
208
60
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
61
env->v7m.control[M_REG_NS] &= ~R_V7M_CONTROL_NPRIV_MASK;
62
env->v7m.control[M_REG_NS] |= val & R_V7M_CONTROL_NPRIV_MASK;
63
}
64
+ /*
65
+ * SFPA is RAZ/WI from NS. FPCA is RO if NSACR.CP10 == 0,
66
+ * RES0 if the FPU is not present, and is stored in the S bank
67
+ */
68
+ if (arm_feature(env, ARM_FEATURE_VFP) &&
69
+ extract32(env->v7m.nsacr, 10, 1)) {
70
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
71
+ env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK;
72
+ }
73
return;
74
case 0x98: /* SP_NS */
75
{
76
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
77
env->v7m.faultmask[env->v7m.secure] = val & 1;
78
break;
79
case 20: /* CONTROL */
80
- /* Writing to the SPSEL bit only has an effect if we are in
81
+ /*
82
+ * Writing to the SPSEL bit only has an effect if we are in
83
* thread mode; other bits can be updated by any privileged code.
84
* write_v7m_control_spsel() deals with updating the SPSEL bit in
85
* env->v7m.control, so we only need update the others.
86
* For v7M, we must just ignore explicit writes to SPSEL in handler
87
* mode; for v8M the write is permitted but will have no effect.
88
+ * All these bits are writes-ignored from non-privileged code,
89
+ * except for SFPA.
90
*/
91
- if (arm_feature(env, ARM_FEATURE_V8) ||
92
- !arm_v7m_is_handler_mode(env)) {
93
+ if (cur_el > 0 && (arm_feature(env, ARM_FEATURE_V8) ||
94
+ !arm_v7m_is_handler_mode(env))) {
95
write_v7m_control_spsel(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0);
96
}
97
- if (arm_feature(env, ARM_FEATURE_M_MAIN)) {
98
+ if (cur_el > 0 && arm_feature(env, ARM_FEATURE_M_MAIN)) {
99
env->v7m.control[env->v7m.secure] &= ~R_V7M_CONTROL_NPRIV_MASK;
100
env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK;
101
}
102
+ if (arm_feature(env, ARM_FEATURE_VFP)) {
103
+ /*
104
+ * SFPA is RAZ/WI from NS or if no FPU.
105
+ * FPCA is RO if NSACR.CP10 == 0, RES0 if the FPU is not present.
106
+ * Both are stored in the S bank.
107
+ */
108
+ if (env->v7m.secure) {
109
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
110
+ env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_SFPA_MASK;
111
+ }
112
+ if (cur_el > 0 &&
113
+ (env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_SECURITY) ||
114
+ extract32(env->v7m.nsacr, 10, 1))) {
115
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
116
+ env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK;
117
+ }
118
+ }
119
break;
120
default:
121
bad_reg:
122
--
209
--
123
2.20.1
210
2.34.1
124
125
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
In CPU Interface, if the IRQ has the non-maskable property, report NMI to
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
the corresponding PE.
5
Message-id: 20190412165416.7977-8-philmd@redhat.com
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-22-ruanjinjie@huawei.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
include/hw/devices.h | 3 ---
12
hw/intc/arm_gicv3_cpuif.c | 4 ++++
9
include/hw/input/gamepad.h | 19 +++++++++++++++++++
13
1 file changed, 4 insertions(+)
10
hw/arm/stellaris.c | 2 +-
11
hw/input/stellaris_input.c | 2 +-
12
MAINTAINERS | 1 +
13
5 files changed, 22 insertions(+), 5 deletions(-)
14
create mode 100644 include/hw/input/gamepad.h
15
14
16
diff --git a/include/hw/devices.h b/include/hw/devices.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/devices.h
17
--- a/hw/intc/arm_gicv3_cpuif.c
19
+++ b/include/hw/devices.h
18
+++ b/hw/intc/arm_gicv3_cpuif.c
20
@@ -XXX,XX +XXX,XX @@ void *tsc2005_init(qemu_irq pintdav);
19
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs)
21
uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
20
/* Tell the CPU about its highest priority pending interrupt */
22
void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
21
int irqlevel = 0;
23
22
int fiqlevel = 0;
24
-/* stellaris_input.c */
23
+ int nmilevel = 0;
25
-void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
24
ARMCPU *cpu = ARM_CPU(cs->cpu);
26
-
25
CPUARMState *env = &cpu->env;
27
#endif
26
28
diff --git a/include/hw/input/gamepad.h b/include/hw/input/gamepad.h
27
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs)
29
new file mode 100644
28
30
index XXXXXXX..XXXXXXX
29
if (isfiq) {
31
--- /dev/null
30
fiqlevel = 1;
32
+++ b/include/hw/input/gamepad.h
31
+ } else if (cs->hppi.nmi) {
33
@@ -XXX,XX +XXX,XX @@
32
+ nmilevel = 1;
34
+/*
33
} else {
35
+ * Gamepad style buttons connected to IRQ/GPIO lines
34
irqlevel = 1;
36
+ *
35
}
37
+ * Copyright (c) 2007 CodeSourcery.
36
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs)
38
+ * Written by Paul Brook
37
39
+ *
38
qemu_set_irq(cs->parent_fiq, fiqlevel);
40
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
39
qemu_set_irq(cs->parent_irq, irqlevel);
41
+ * See the COPYING file in the top-level directory.
40
+ qemu_set_irq(cs->parent_nmi, nmilevel);
42
+ */
41
}
43
+
42
44
+#ifndef HW_INPUT_GAMEPAD_H
43
static uint64_t icc_pmr_read(CPUARMState *env, const ARMCPRegInfo *ri)
45
+#define HW_INPUT_GAMEPAD_H
46
+
47
+#include "hw/irq.h"
48
+
49
+/* stellaris_input.c */
50
+void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
51
+
52
+#endif
53
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
54
index XXXXXXX..XXXXXXX 100644
55
--- a/hw/arm/stellaris.c
56
+++ b/hw/arm/stellaris.c
57
@@ -XXX,XX +XXX,XX @@
58
#include "hw/sysbus.h"
59
#include "hw/ssi/ssi.h"
60
#include "hw/arm/arm.h"
61
-#include "hw/devices.h"
62
#include "qemu/timer.h"
63
#include "hw/i2c/i2c.h"
64
#include "net/net.h"
65
@@ -XXX,XX +XXX,XX @@
66
#include "sysemu/sysemu.h"
67
#include "hw/arm/armv7m.h"
68
#include "hw/char/pl011.h"
69
+#include "hw/input/gamepad.h"
70
#include "hw/watchdog/cmsdk-apb-watchdog.h"
71
#include "hw/misc/unimp.h"
72
#include "cpu.h"
73
diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/hw/input/stellaris_input.c
76
+++ b/hw/input/stellaris_input.c
77
@@ -XXX,XX +XXX,XX @@
78
*/
79
#include "qemu/osdep.h"
80
#include "hw/hw.h"
81
-#include "hw/devices.h"
82
+#include "hw/input/gamepad.h"
83
#include "ui/console.h"
84
85
typedef struct {
86
diff --git a/MAINTAINERS b/MAINTAINERS
87
index XXXXXXX..XXXXXXX 100644
88
--- a/MAINTAINERS
89
+++ b/MAINTAINERS
90
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
91
L: qemu-arm@nongnu.org
92
S: Maintained
93
F: hw/*/stellaris*
94
+F: include/hw/input/gamepad.h
95
96
Versatile Express
97
M: Peter Maydell <peter.maydell@linaro.org>
98
--
44
--
99
2.20.1
45
2.34.1
100
101
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Suggested-by: Markus Armbruster <armbru@redhat.com>
3
In vCPU Interface, if the vIRQ has the non-maskable property, report
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
vINMI to the corresponding vPE.
5
Message-id: 20190412165416.7977-3-philmd@redhat.com
5
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20240407081733.3231820-23-ruanjinjie@huawei.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
11
---
9
hw/arm/nseries.c | 3 ++-
12
hw/intc/arm_gicv3_cpuif.c | 14 ++++++++++++--
10
1 file changed, 2 insertions(+), 1 deletion(-)
13
1 file changed, 12 insertions(+), 2 deletions(-)
11
14
12
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
15
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
13
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/arm/nseries.c
17
--- a/hw/intc/arm_gicv3_cpuif.c
15
+++ b/hw/arm/nseries.c
18
+++ b/hw/intc/arm_gicv3_cpuif.c
16
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs)
17
#include "hw/boards.h"
20
int idx;
18
#include "hw/i2c/i2c.h"
21
int irqlevel = 0;
19
#include "hw/devices.h"
22
int fiqlevel = 0;
20
+#include "hw/misc/tmp105.h"
23
+ int nmilevel = 0;
21
#include "hw/block/flash.h"
24
22
#include "hw/hw.h"
25
idx = hppvi_index(cs);
23
#include "hw/bt.h"
26
trace_gicv3_cpuif_virt_update(gicv3_redist_affid(cs), idx,
24
@@ -XXX,XX +XXX,XX @@ static void n8x0_i2c_setup(struct n800_s *s)
27
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs)
25
qemu_register_powerdown_notifier(&n8x0_system_powerdown_notifier);
28
uint64_t lr = cs->ich_lr_el2[idx];
26
29
27
/* Attach a TMP105 PM chip (A0 wired to ground) */
30
if (icv_hppi_can_preempt(cs, lr)) {
28
- dev = i2c_create_slave(i2c, "tmp105", N8X0_TMP105_ADDR);
31
- /* Virtual interrupts are simple: G0 are always FIQ, and G1 IRQ */
29
+ dev = i2c_create_slave(i2c, TYPE_TMP105, N8X0_TMP105_ADDR);
32
+ /*
30
qdev_connect_gpio_out(dev, 0, tmp_irq);
33
+ * Virtual interrupts are simple: G0 are always FIQ, and G1 are
34
+ * IRQ or NMI which depends on the ICH_LR<n>_EL2.NMI to have
35
+ * non-maskable property.
36
+ */
37
if (lr & ICH_LR_EL2_GROUP) {
38
- irqlevel = 1;
39
+ if (lr & ICH_LR_EL2_NMI) {
40
+ nmilevel = 1;
41
+ } else {
42
+ irqlevel = 1;
43
+ }
44
} else {
45
fiqlevel = 1;
46
}
47
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs)
48
trace_gicv3_cpuif_virt_set_irqs(gicv3_redist_affid(cs), fiqlevel, irqlevel);
49
qemu_set_irq(cs->parent_vfiq, fiqlevel);
50
qemu_set_irq(cs->parent_virq, irqlevel);
51
+ qemu_set_irq(cs->parent_vnmi, nmilevel);
31
}
52
}
32
53
54
static void gicv3_cpuif_virt_update(GICv3CPUState *cs)
33
--
55
--
34
2.20.1
56
2.34.1
35
36
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
2
3
Reviewed-by: Thomas Huth <thuth@redhat.com>
3
Enable FEAT_NMI on the 'max' CPU.
4
Reviewed-by: Markus Armbruster <armbru@redhat.com>
4
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Message-id: 20190412165416.7977-7-philmd@redhat.com
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20240407081733.3231820-24-ruanjinjie@huawei.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
10
---
9
include/hw/devices.h | 14 --------------
11
docs/system/arm/emulation.rst | 1 +
10
include/hw/misc/cbus.h | 32 ++++++++++++++++++++++++++++++++
12
target/arm/tcg/cpu64.c | 1 +
11
hw/arm/nseries.c | 1 +
13
2 files changed, 2 insertions(+)
12
hw/misc/cbus.c | 2 +-
13
MAINTAINERS | 1 +
14
5 files changed, 35 insertions(+), 15 deletions(-)
15
create mode 100644 include/hw/misc/cbus.h
16
14
17
diff --git a/include/hw/devices.h b/include/hw/devices.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/devices.h
17
--- a/docs/system/arm/emulation.rst
20
+++ b/include/hw/devices.h
18
+++ b/docs/system/arm/emulation.rst
21
@@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
19
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
22
/* stellaris_input.c */
20
- FEAT_MTE (Memory Tagging Extension)
23
void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
21
- FEAT_MTE2 (Memory Tagging Extension)
24
22
- FEAT_MTE3 (MTE Asymmetric Fault Handling)
25
-/* cbus.c */
23
+- FEAT_NMI (Non-maskable Interrupt)
26
-typedef struct {
24
- FEAT_NV (Nested Virtualization)
27
- qemu_irq clk;
25
- FEAT_NV2 (Enhanced nested virtualization support)
28
- qemu_irq dat;
26
- FEAT_PACIMP (Pointer authentication - IMPLEMENTATION DEFINED algorithm)
29
- qemu_irq sel;
27
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
30
-} CBus;
31
-CBus *cbus_init(qemu_irq dat_out);
32
-void cbus_attach(CBus *bus, void *slave_opaque);
33
-
34
-void *retu_init(qemu_irq irq, int vilma);
35
-void *tahvo_init(qemu_irq irq, int betty);
36
-
37
-void retu_key_event(void *retu, int state);
38
-
39
#endif
40
diff --git a/include/hw/misc/cbus.h b/include/hw/misc/cbus.h
41
new file mode 100644
42
index XXXXXXX..XXXXXXX
43
--- /dev/null
44
+++ b/include/hw/misc/cbus.h
45
@@ -XXX,XX +XXX,XX @@
46
+/*
47
+ * CBUS three-pin bus and the Retu / Betty / Tahvo / Vilma / Avilma /
48
+ * Hinku / Vinku / Ahne / Pihi chips used in various Nokia platforms.
49
+ * Based on reverse-engineering of a linux driver.
50
+ *
51
+ * Copyright (C) 2008 Nokia Corporation
52
+ * Written by Andrzej Zaborowski
53
+ *
54
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
55
+ * See the COPYING file in the top-level directory.
56
+ */
57
+
58
+#ifndef HW_MISC_CBUS_H
59
+#define HW_MISC_CBUS_H
60
+
61
+#include "hw/irq.h"
62
+
63
+typedef struct {
64
+ qemu_irq clk;
65
+ qemu_irq dat;
66
+ qemu_irq sel;
67
+} CBus;
68
+
69
+CBus *cbus_init(qemu_irq dat_out);
70
+void cbus_attach(CBus *bus, void *slave_opaque);
71
+
72
+void *retu_init(qemu_irq irq, int vilma);
73
+void *tahvo_init(qemu_irq irq, int betty);
74
+
75
+void retu_key_event(void *retu, int state);
76
+
77
+#endif
78
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
79
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
80
--- a/hw/arm/nseries.c
29
--- a/target/arm/tcg/cpu64.c
81
+++ b/hw/arm/nseries.c
30
+++ b/target/arm/tcg/cpu64.c
82
@@ -XXX,XX +XXX,XX @@
31
@@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj)
83
#include "hw/i2c/i2c.h"
32
t = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT_DoubleFault */
84
#include "hw/devices.h"
33
t = FIELD_DP64(t, ID_AA64PFR1, SME, 1); /* FEAT_SME */
85
#include "hw/display/blizzard.h"
34
t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */
86
+#include "hw/misc/cbus.h"
35
+ t = FIELD_DP64(t, ID_AA64PFR1, NMI, 1); /* FEAT_NMI */
87
#include "hw/misc/tmp105.h"
36
cpu->isar.id_aa64pfr1 = t;
88
#include "hw/block/flash.h"
37
89
#include "hw/hw.h"
38
t = cpu->isar.id_aa64mmfr0;
90
diff --git a/hw/misc/cbus.c b/hw/misc/cbus.c
91
index XXXXXXX..XXXXXXX 100644
92
--- a/hw/misc/cbus.c
93
+++ b/hw/misc/cbus.c
94
@@ -XXX,XX +XXX,XX @@
95
#include "qemu/osdep.h"
96
#include "hw/hw.h"
97
#include "hw/irq.h"
98
-#include "hw/devices.h"
99
+#include "hw/misc/cbus.h"
100
#include "sysemu/sysemu.h"
101
102
//#define DEBUG
103
diff --git a/MAINTAINERS b/MAINTAINERS
104
index XXXXXXX..XXXXXXX 100644
105
--- a/MAINTAINERS
106
+++ b/MAINTAINERS
107
@@ -XXX,XX +XXX,XX @@ F: hw/input/tsc2005.c
108
F: hw/misc/cbus.c
109
F: hw/timer/twl92230.c
110
F: include/hw/display/blizzard.h
111
+F: include/hw/misc/cbus.h
112
113
Palm
114
M: Andrzej Zaborowski <balrogg@gmail.com>
115
--
39
--
116
2.20.1
40
2.34.1
117
118
diff view generated by jsdifflib
1
Like AArch64, M-profile floating point has no FPEXC enable
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
2
bit to gate floating point; so always set the VFPEN TB flag.
3
2
4
M-profile also has CPACR and NSACR similar to A-profile;
3
If the CPU implements FEAT_NMI, then turn on the NMI support in the
5
they behave slightly differently:
4
GICv3 too. It's permitted to have a configuration with FEAT_NMI in
6
* the CPACR is banked between Secure and Non-Secure
5
the CPU (and thus NMI support in the CPU interfaces too) but no NMI
7
* if the NSACR forces a trap then this is taken to
6
support in the distributor and redistributor, but this isn't a very
8
the Secure state, not the Non-Secure state
7
useful setup as it's close to having no NMI support at all.
9
8
10
Honour the CPACR and NSACR settings. The NSACR handling
9
We don't need to gate the enabling of NMI in the GIC behind a
11
requires us to borrow the exception.target_el field
10
machine version property, because none of our current CPUs
12
(usually meaningless for M profile) to distinguish the
11
implement FEAT_NMI, and '-cpu max' is not something we maintain
13
NOCP UsageFault taken to Secure state from the more
12
migration compatibility across versions for. So we can always
14
usual fault taken to the current security state.
13
enable the GIC NMI support when the CPU has it.
15
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>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Message-id: 20190416125744.27770-6-peter.maydell@linaro.org
19
---
24
---
20
target/arm/helper.c | 55 +++++++++++++++++++++++++++++++++++++++---
25
hw/arm/virt.c | 19 +++++++++++++++++++
21
target/arm/translate.c | 10 ++++++--
26
1 file changed, 19 insertions(+)
22
2 files changed, 60 insertions(+), 5 deletions(-)
23
27
24
diff --git a/target/arm/helper.c b/target/arm/helper.c
28
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
25
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/helper.c
30
--- a/hw/arm/virt.c
27
+++ b/target/arm/helper.c
31
+++ b/hw/arm/virt.c
28
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
32
@@ -XXX,XX +XXX,XX @@ static void create_v2m(VirtMachineState *vms)
29
return target_el;
33
vms->msi_controller = VIRT_MSI_CTRL_GICV2M;
30
}
34
}
31
35
32
+/*
36
+/*
33
+ * Return true if the v7M CPACR permits access to the FPU for the specified
37
+ * If the CPU has FEAT_NMI, then turn on the NMI support in the GICv3 too.
34
+ * security state and privilege level.
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.
35
+ */
41
+ */
36
+static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv)
42
+static bool gicv3_nmi_present(VirtMachineState *vms)
37
+{
43
+{
38
+ switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) {
44
+ ARMCPU *cpu = ARM_CPU(qemu_get_cpu(0));
39
+ case 0:
45
+
40
+ case 2: /* UNPREDICTABLE: we treat like 0 */
46
+ return tcg_enabled() && cpu_isar_feature(aa64_nmi, cpu) &&
41
+ return false;
47
+ (vms->gic_version != VIRT_GIC_VERSION_2);
42
+ case 1:
43
+ return is_priv;
44
+ case 3:
45
+ return true;
46
+ default:
47
+ g_assert_not_reached();
48
+ }
49
+}
48
+}
50
+
49
+
51
static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
50
static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
52
ARMMMUIdx mmu_idx, bool ignfault)
53
{
51
{
54
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
52
MachineState *ms = MACHINE(vms);
55
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK;
53
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
56
break;
54
vms->virt);
57
case EXCP_NOCP:
55
}
58
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
56
}
59
- env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;
60
+ {
61
+ /*
62
+ * NOCP might be directed to something other than the current
63
+ * security state if this fault is because of NSACR; we indicate
64
+ * the target security state using exception.target_el.
65
+ */
66
+ int target_secstate;
67
+
57
+
68
+ if (env->exception.target_el == 3) {
58
+ if (gicv3_nmi_present(vms)) {
69
+ target_secstate = M_REG_S;
59
+ qdev_prop_set_bit(vms->gic, "has-nmi", true);
70
+ } else {
71
+ target_secstate = env->v7m.secure;
72
+ }
73
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, target_secstate);
74
+ env->v7m.cfsr[target_secstate] |= R_V7M_CFSR_NOCP_MASK;
75
break;
76
+ }
77
case EXCP_INVSTATE:
78
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
79
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK;
80
@@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el)
81
return 0;
82
}
83
84
+ if (arm_feature(env, ARM_FEATURE_M)) {
85
+ /* CPACR can cause a NOCP UsageFault taken to current security state */
86
+ if (!v7m_cpacr_pass(env, env->v7m.secure, cur_el != 0)) {
87
+ return 1;
88
+ }
89
+
90
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY) && !env->v7m.secure) {
91
+ if (!extract32(env->v7m.nsacr, 10, 1)) {
92
+ /* FP insns cause a NOCP UsageFault taken to Secure */
93
+ return 3;
94
+ }
95
+ }
96
+
97
+ return 0;
98
+ }
60
+ }
99
+
61
+
100
/* The CPACR controls traps to EL1, or PL1 if we're 32 bit:
62
gicbusdev = SYS_BUS_DEVICE(vms->gic);
101
* 0, 2 : trap EL0 and EL1/PL1 accesses
63
sysbus_realize_and_unref(gicbusdev, &error_fatal);
102
* 1 : trap only EL0 accesses
64
sysbus_mmio_map(gicbusdev, 0, vms->memmap[VIRT_GIC_DIST].base);
103
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
104
flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, arm_sctlr_b(env));
105
flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env));
106
if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30)
107
- || arm_el_is_aa64(env, 1)) {
108
+ || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) {
109
flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1);
110
}
111
flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar);
112
diff --git a/target/arm/translate.c b/target/arm/translate.c
113
index XXXXXXX..XXXXXXX 100644
114
--- a/target/arm/translate.c
115
+++ b/target/arm/translate.c
116
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
117
* for attempts to execute invalid vfp/neon encodings with FP disabled.
118
*/
119
if (s->fp_excp_el) {
120
- gen_exception_insn(s, 4, EXCP_UDEF,
121
- syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
122
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
123
+ gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(),
124
+ s->fp_excp_el);
125
+ } else {
126
+ gen_exception_insn(s, 4, EXCP_UDEF,
127
+ syn_fp_access_trap(1, 0xe, false),
128
+ s->fp_excp_el);
129
+ }
130
return 0;
131
}
132
133
--
65
--
134
2.20.1
66
2.34.1
135
136
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Anastasia Belova <abelova@astralinux.ru>
2
2
3
This device is used by both ARM (BCM2836, for raspi2) and AArch64
3
In soc_dma_set_request() we try to set a bit in a uint64_t, but we
4
(BCM2837, for raspi3) targets, and is not CPU-specific.
4
do it with "1 << ch->num", which can't set any bits past 31;
5
Move it to common object, so we build it once for all targets.
5
any use for a channel number of 32 or more would fail due to
6
integer overflow.
6
7
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
This doesn't happen in practice for our current use of this code,
8
Message-id: 20190427133028.12874-1-philmd@redhat.com
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.]
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
26
---
12
hw/dma/Makefile.objs | 2 +-
27
hw/dma/soc_dma.c | 4 ++--
13
1 file changed, 1 insertion(+), 1 deletion(-)
28
1 file changed, 2 insertions(+), 2 deletions(-)
14
29
15
diff --git a/hw/dma/Makefile.objs b/hw/dma/Makefile.objs
30
diff --git a/hw/dma/soc_dma.c b/hw/dma/soc_dma.c
16
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/dma/Makefile.objs
32
--- a/hw/dma/soc_dma.c
18
+++ b/hw/dma/Makefile.objs
33
+++ b/hw/dma/soc_dma.c
19
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx-zdma.o
34
@@ -XXX,XX +XXX,XX @@ void soc_dma_set_request(struct soc_dma_ch_s *ch, int level)
20
35
dma->enabled_count += level - ch->enable;
21
obj-$(CONFIG_OMAP) += omap_dma.o soc_dma.o
36
22
obj-$(CONFIG_PXA2XX) += pxa2xx_dma.o
37
if (level)
23
-obj-$(CONFIG_RASPI) += bcm2835_dma.o
38
- dma->ch_enable_mask |= 1 << ch->num;
24
+common-obj-$(CONFIG_RASPI) += bcm2835_dma.o
39
+ dma->ch_enable_mask |= (uint64_t)1 << ch->num;
40
else
41
- dma->ch_enable_mask &= ~(1 << ch->num);
42
+ dma->ch_enable_mask &= ~((uint64_t)1 << ch->num);
43
44
if (level != ch->enable) {
45
soc_dma_ch_freq_update(dma);
25
--
46
--
26
2.20.1
47
2.34.1
27
28
diff view generated by jsdifflib
1
Implement the code which updates the FPCCR register on an
1
Ever since the bFLT format support was added in 2006, there has been
2
exception entry where we are going to use lazy FP stacking.
2
a chunk of code in the file guarded by CONFIG_BINFMT_SHARED_FLAT
3
We have to defer to the NVIC to determine whether the
3
which is supposedly for shared library support. This is not enabled
4
various exceptions are currently ready or not.
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.
5
16
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20190416125744.27770-12-peter.maydell@linaro.org
18
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
19
Message-id: 20240411115313.680433-1-peter.maydell@linaro.org
8
---
20
---
9
target/arm/cpu.h | 14 +++++++++
21
linux-user/flat.h | 5 +-
10
hw/intc/armv7m_nvic.c | 34 ++++++++++++++++++++++
22
linux-user/flatload.c | 293 ++----------------------------------------
11
target/arm/helper.c | 67 ++++++++++++++++++++++++++++++++++++++++++-
23
2 files changed, 11 insertions(+), 287 deletions(-)
12
3 files changed, 114 insertions(+), 1 deletion(-)
24
13
25
diff --git a/linux-user/flat.h b/linux-user/flat.h
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
15
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu.h
27
--- a/linux-user/flat.h
17
+++ b/target/arm/cpu.h
28
+++ b/linux-user/flat.h
18
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque);
29
@@ -XXX,XX +XXX,XX @@
19
* (Ignoring -1, this is the same as the RETTOBASE value before completion.)
30
31
#define    FLAT_VERSION            0x00000004L
32
33
-#ifdef CONFIG_BINFMT_SHARED_FLAT
34
-#define    MAX_SHARED_LIBS            (4)
35
-#else
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
43
index XXXXXXX..XXXXXXX 100644
44
--- a/linux-user/flatload.c
45
+++ b/linux-user/flatload.c
46
@@ -XXX,XX +XXX,XX @@
47
*    JAN/99 -- coded full program relocation (gerg@snapgear.com)
20
*/
48
*/
21
int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure);
49
22
+/**
50
-/* ??? ZFLAT and shared library support is currently disabled. */
23
+ * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
51
-
24
+ * @opaque: the NVIC
52
/****************************************************************************/
25
+ * @irq: the exception number to mark pending
53
26
+ * @secure: false for non-banked exceptions or for the nonsecure
54
#include "qemu/osdep.h"
27
+ * version of a banked exception, true for the secure version of a banked
55
@@ -XXX,XX +XXX,XX @@ struct lib_info {
28
+ * exception.
56
short loaded;        /* Has this library been loaded? */
29
+ *
57
};
30
+ * Return whether an exception is "ready", i.e. whether the exception is
58
31
+ * enabled and is configured at a priority which would allow it to
59
-#ifdef CONFIG_BINFMT_SHARED_FLAT
32
+ * interrupt the current execution priority. This controls whether the
60
-static int load_flat_shared_library(int id, struct lib_info *p);
33
+ * RDY bit for it in the FPCCR is set.
61
-#endif
34
+ */
62
-
35
+bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure);
63
struct linux_binprm;
36
/**
64
37
* armv7m_nvic_raw_execution_priority: return the raw execution priority
65
/****************************************************************************/
38
* @opaque: the NVIC
66
@@ -XXX,XX +XXX,XX @@ static int target_pread(int fd, abi_ulong ptr, abi_ulong len,
39
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
67
unlock_user(buf, ptr, len);
40
index XXXXXXX..XXXXXXX 100644
41
--- a/hw/intc/armv7m_nvic.c
42
+++ b/hw/intc/armv7m_nvic.c
43
@@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure)
44
return ret;
68
return ret;
45
}
69
}
46
70
-/****************************************************************************/
47
+bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
71
-
48
+{
72
-#ifdef CONFIG_BINFMT_ZFLAT
49
+ /*
73
-
50
+ * Return whether an exception is "ready", i.e. it is enabled and is
74
-#include <linux/zlib.h>
51
+ * configured at a priority which would allow it to interrupt the
75
-
52
+ * current execution priority.
76
-#define LBUFSIZE    4000
53
+ *
77
-
54
+ * irq and secure have the same semantics as for armv7m_nvic_set_pending():
78
-/* gzip flag byte */
55
+ * for non-banked exceptions secure is always false; for banked exceptions
79
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
56
+ * it indicates which of the exceptions is required.
80
-#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
57
+ */
81
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
58
+ NVICState *s = (NVICState *)opaque;
82
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
59
+ bool banked = exc_is_banked(irq);
83
-#define COMMENT 0x10 /* bit 4 set: file comment present */
60
+ VecInfo *vec;
84
-#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
61
+ int running = nvic_exec_prio(s);
85
-#define RESERVED 0xC0 /* bit 6,7: reserved */
62
+
86
-
63
+ assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
87
-static int decompress_exec(
64
+ assert(!secure || banked);
88
-    struct linux_binprm *bprm,
65
+
89
-    unsigned long offset,
66
+ /*
90
-    char *dst,
67
+ * HardFault is an odd special case: we always check against -1,
91
-    long len,
68
+ * even if we're secure and HardFault has priority -3; we never
92
-    int fd)
69
+ * need to check for enabled state.
93
-{
70
+ */
94
-    unsigned char *buf;
71
+ if (irq == ARMV7M_EXCP_HARD) {
95
-    z_stream strm;
72
+ return running > -1;
96
-    loff_t fpos;
73
+ }
97
-    int ret, retval;
74
+
98
-
75
+ vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq];
99
-    DBG_FLT("decompress_exec(offset=%x,buf=%x,len=%x)\n",(int)offset, (int)dst, (int)len);
76
+
100
-
77
+ return vec->enabled &&
101
-    memset(&strm, 0, sizeof(strm));
78
+ exc_group_prio(s, vec->prio, secure) < running;
102
-    strm.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
79
+}
103
-    if (strm.workspace == NULL) {
80
+
104
-        DBG_FLT("binfmt_flat: no memory for decompress workspace\n");
81
/* callback when external interrupt line is changed */
105
-        return -ENOMEM;
82
static void set_irq_level(void *opaque, int n, int level)
106
-    }
107
-    buf = kmalloc(LBUFSIZE, GFP_KERNEL);
108
-    if (buf == NULL) {
109
-        DBG_FLT("binfmt_flat: no memory for read buffer\n");
110
-        retval = -ENOMEM;
111
-        goto out_free;
112
-    }
113
-
114
-    /* Read in first chunk of data and parse gzip header. */
115
-    fpos = offset;
116
-    ret = bprm->file->f_op->read(bprm->file, buf, LBUFSIZE, &fpos);
117
-
118
-    strm.next_in = buf;
119
-    strm.avail_in = ret;
120
-    strm.total_in = 0;
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;
246
- }
247
- /* Check versioning information (i.e. time stamps) */
248
- if (p[id].build_date && p[curid].build_date
249
- && p[curid].build_date < p[id].build_date) {
250
- fprintf(stderr, "BINFMT_FLAT: library %d is younger than %d\n",
251
- id, curid);
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)
83
{
384
{
84
diff --git a/target/arm/helper.c b/target/arm/helper.c
385
struct lib_info libinfo[MAX_SHARED_LIBS];
85
index XXXXXXX..XXXXXXX 100644
386
@@ -XXX,XX +XXX,XX @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info)
86
--- a/target/arm/helper.c
387
*/
87
+++ b/target/arm/helper.c
388
start_addr = libinfo[0].entry;
88
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
389
89
env->thumb = addr & 1;
390
-#ifdef CONFIG_BINFMT_SHARED_FLAT
90
}
391
-#error here
91
392
- for (i = MAX_SHARED_LIBS-1; i>0; i--) {
92
+static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr,
393
- if (libinfo[i].loaded) {
93
+ bool apply_splim)
394
- /* Push previous first to call address */
94
+{
395
- --sp;
95
+ /*
396
- if (put_user_ual(start_addr, sp))
96
+ * Like the pseudocode UpdateFPCCR: save state in FPCAR and FPCCR
397
- return -EFAULT;
97
+ * that we will need later in order to do lazy FP reg stacking.
398
- start_addr = libinfo[i].entry;
98
+ */
399
- }
99
+ bool is_secure = env->v7m.secure;
400
- }
100
+ void *nvic = env->nvic;
401
-#endif
101
+ /*
402
-
102
+ * Some bits are unbanked and live always in fpccr[M_REG_S]; some bits
403
/* Stash our initial stack pointer into the mm structure */
103
+ * are banked and we want to update the bit in the bank for the
404
info->start_code = libinfo[0].start_code;
104
+ * current security state; and in one case we want to specifically
405
info->end_code = libinfo[0].start_code + libinfo[0].text_len;
105
+ * update the NS banked version of a bit even if we are secure.
106
+ */
107
+ uint32_t *fpccr_s = &env->v7m.fpccr[M_REG_S];
108
+ uint32_t *fpccr_ns = &env->v7m.fpccr[M_REG_NS];
109
+ uint32_t *fpccr = &env->v7m.fpccr[is_secure];
110
+ bool hfrdy, bfrdy, mmrdy, ns_ufrdy, s_ufrdy, sfrdy, monrdy;
111
+
112
+ env->v7m.fpcar[is_secure] = frameptr & ~0x7;
113
+
114
+ if (apply_splim && arm_feature(env, ARM_FEATURE_V8)) {
115
+ bool splimviol;
116
+ uint32_t splim = v7m_sp_limit(env);
117
+ bool ign = armv7m_nvic_neg_prio_requested(nvic, is_secure) &&
118
+ (env->v7m.ccr[is_secure] & R_V7M_CCR_STKOFHFNMIGN_MASK);
119
+
120
+ splimviol = !ign && frameptr < splim;
121
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, SPLIMVIOL, splimviol);
122
+ }
123
+
124
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, LSPACT, 1);
125
+
126
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, S, is_secure);
127
+
128
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, USER, arm_current_el(env) == 0);
129
+
130
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, THREAD,
131
+ !arm_v7m_is_handler_mode(env));
132
+
133
+ hfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_HARD, false);
134
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, HFRDY, hfrdy);
135
+
136
+ bfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_BUS, false);
137
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, BFRDY, bfrdy);
138
+
139
+ mmrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_MEM, is_secure);
140
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, MMRDY, mmrdy);
141
+
142
+ ns_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, false);
143
+ *fpccr_ns = FIELD_DP32(*fpccr_ns, V7M_FPCCR, UFRDY, ns_ufrdy);
144
+
145
+ monrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_DEBUG, false);
146
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, MONRDY, monrdy);
147
+
148
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
149
+ s_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, true);
150
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, UFRDY, s_ufrdy);
151
+
152
+ sfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_SECURE, false);
153
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, SFRDY, sfrdy);
154
+ }
155
+}
156
+
157
static bool v7m_push_stack(ARMCPU *cpu)
158
{
159
/* Do the "set up stack frame" part of exception entry,
160
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
161
}
162
} else {
163
/* Lazy stacking enabled, save necessary info to stack later */
164
- /* TODO : equivalent of UpdateFPCCR() pseudocode */
165
+ v7m_update_fpccr(env, frameptr + 0x20, true);
166
}
167
}
168
}
169
--
406
--
170
2.20.1
407
2.34.1
171
408
172
409
diff view generated by jsdifflib
1
Add a new helper function which returns the MMU index to use
1
The npcm7xx_clk and npcm7xx_gcr device reset methods look at
2
for v7M, where the caller specifies all of the security
2
the ResetType argument and only handle RESET_TYPE_COLD,
3
state, privilege level and whether the execution priority
3
producing a warning if another reset type is passed. This
4
is negative, and reimplement the existing
4
is different from how every other three-phase-reset method
5
arm_v7m_mmu_idx_for_secstate_and_priv() in terms of it.
5
we have works, and makes it difficult to add new reset types.
6
6
7
We are going to need this for the lazy-FP-stacking code.
7
A better pattern is "assume that any reset type you don't know
8
about should be handled like RESET_TYPE_COLD"; switch these
9
devices to do that. Then adding a new reset type will only
10
need to touch those devices where its behaviour really needs
11
to be different from the standard cold reset.
8
12
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20190416125744.27770-21-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
12
---
18
---
13
target/arm/cpu.h | 7 +++++++
19
hw/misc/npcm7xx_clk.c | 13 +++----------
14
target/arm/helper.c | 14 +++++++++++---
20
hw/misc/npcm7xx_gcr.c | 12 ++++--------
15
2 files changed, 18 insertions(+), 3 deletions(-)
21
2 files changed, 7 insertions(+), 18 deletions(-)
16
22
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
23
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
18
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
25
--- a/hw/misc/npcm7xx_clk.c
20
+++ b/target/arm/cpu.h
26
+++ b/hw/misc/npcm7xx_clk.c
21
@@ -XXX,XX +XXX,XX @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
27
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_clk_enter_reset(Object *obj, ResetType type)
22
}
28
29
QEMU_BUILD_BUG_ON(sizeof(s->regs) != sizeof(cold_reset_values));
30
31
- switch (type) {
32
- case RESET_TYPE_COLD:
33
- memcpy(s->regs, cold_reset_values, sizeof(cold_reset_values));
34
- s->ref_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
35
- npcm7xx_clk_update_all_clocks(s);
36
- return;
37
- }
38
-
39
+ memcpy(s->regs, cold_reset_values, sizeof(cold_reset_values));
40
+ s->ref_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
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);
23
}
48
}
24
49
25
+/*
50
static void npcm7xx_clk_init_clock_hierarchy(NPCM7xxCLKState *s)
26
+ * Return the MMU index for a v7M CPU with all relevant information
51
diff --git a/hw/misc/npcm7xx_gcr.c b/hw/misc/npcm7xx_gcr.c
27
+ * manually specified.
28
+ */
29
+ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
30
+ bool secstate, bool priv, bool negpri);
31
+
32
/* Return the MMU index for a v7M CPU in the specified security and
33
* privilege state.
34
*/
35
diff --git a/target/arm/helper.c b/target/arm/helper.c
36
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/helper.c
53
--- a/hw/misc/npcm7xx_gcr.c
38
+++ b/target/arm/helper.c
54
+++ b/hw/misc/npcm7xx_gcr.c
39
@@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el)
55
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_gcr_enter_reset(Object *obj, ResetType type)
40
return 0;
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;
66
- }
67
+ memcpy(s->regs, cold_reset_values, sizeof(s->regs));
68
+ s->regs[NPCM7XX_GCR_PWRON] = s->reset_pwron;
69
+ s->regs[NPCM7XX_GCR_MDLR] = s->reset_mdlr;
70
+ s->regs[NPCM7XX_GCR_INTCR3] = s->reset_intcr3;
41
}
71
}
42
72
43
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
73
static void npcm7xx_gcr_realize(DeviceState *dev, Error **errp)
44
- bool secstate, bool priv)
45
+ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
46
+ bool secstate, bool priv, bool negpri)
47
{
48
ARMMMUIdx mmu_idx = ARM_MMU_IDX_M;
49
50
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
51
mmu_idx |= ARM_MMU_IDX_M_PRIV;
52
}
53
54
- if (armv7m_nvic_neg_prio_requested(env->nvic, secstate)) {
55
+ if (negpri) {
56
mmu_idx |= ARM_MMU_IDX_M_NEGPRI;
57
}
58
59
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
60
return mmu_idx;
61
}
62
63
+ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
64
+ bool secstate, bool priv)
65
+{
66
+ bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate);
67
+
68
+ return arm_v7m_mmu_idx_all(env, secstate, priv, negpri);
69
+}
70
+
71
/* Return the MMU index for a v7M CPU in the specified security state */
72
ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
73
{
74
--
74
--
75
2.20.1
75
2.34.1
76
76
77
77
diff view generated by jsdifflib
1
Enable the FPU by default for the Cortex-M4 and Cortex-M33.
1
Rather than directly calling the device's implementation of its 'hold'
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.
2
5
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190416125744.27770-27-peter.maydell@linaro.org
8
Reviewed-by: Luc Michel <luc.michel@amd.com>
9
Message-id: 20240412160809.1260625-3-peter.maydell@linaro.org
6
---
10
---
7
target/arm/cpu.c | 8 ++++++++
11
hw/i2c/allwinner-i2c.c | 3 +--
8
1 file changed, 8 insertions(+)
12
hw/sensor/adm1272.c | 2 +-
13
2 files changed, 2 insertions(+), 3 deletions(-)
9
14
10
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
15
diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c
11
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
12
--- a/target/arm/cpu.c
17
--- a/hw/i2c/allwinner-i2c.c
13
+++ b/target/arm/cpu.c
18
+++ b/hw/i2c/allwinner-i2c.c
14
@@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj)
19
@@ -XXX,XX +XXX,XX @@ static void allwinner_i2c_write(void *opaque, hwaddr offset,
15
set_feature(&cpu->env, ARM_FEATURE_M);
20
break;
16
set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
21
case TWI_SRST_REG:
17
set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
22
if (((value & TWI_SRST_MASK) == 0) && (s->srst & TWI_SRST_MASK)) {
18
+ set_feature(&cpu->env, ARM_FEATURE_VFP4);
23
- /* Perform reset */
19
cpu->midr = 0x410fc240; /* r0p0 */
24
- allwinner_i2c_reset_hold(OBJECT(s));
20
cpu->pmsav7_dregion = 8;
25
+ device_cold_reset(DEVICE(s));
21
+ cpu->isar.mvfr0 = 0x10110021;
26
}
22
+ cpu->isar.mvfr1 = 0x11000011;
27
s->srst = value & TWI_SRST_MASK;
23
+ cpu->isar.mvfr2 = 0x00000000;
28
break;
24
cpu->id_pfr0 = 0x00000030;
29
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
25
cpu->id_pfr1 = 0x00000200;
30
index XXXXXXX..XXXXXXX 100644
26
cpu->id_dfr0 = 0x00100000;
31
--- a/hw/sensor/adm1272.c
27
@@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj)
32
+++ b/hw/sensor/adm1272.c
28
set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
33
@@ -XXX,XX +XXX,XX @@ static int adm1272_write_data(PMBusDevice *pmdev, const uint8_t *buf,
29
set_feature(&cpu->env, ARM_FEATURE_M_SECURITY);
34
break;
30
set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
35
31
+ set_feature(&cpu->env, ARM_FEATURE_VFP4);
36
case ADM1272_MFR_POWER_CYCLE:
32
cpu->midr = 0x410fd213; /* r0p3 */
37
- adm1272_exit_reset((Object *)s);
33
cpu->pmsav7_dregion = 16;
38
+ device_cold_reset(DEVICE(s));
34
cpu->sau_sregion = 8;
39
break;
35
+ cpu->isar.mvfr0 = 0x10110021;
40
36
+ cpu->isar.mvfr1 = 0x11000011;
41
case ADM1272_HYSTERESIS_LOW:
37
+ cpu->isar.mvfr2 = 0x00000040;
38
cpu->id_pfr0 = 0x00000030;
39
cpu->id_pfr1 = 0x00000210;
40
cpu->id_dfr0 = 0x00200000;
41
--
42
--
42
2.20.1
43
2.34.1
43
44
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
We pass a ResetType argument to the Resettable class enter phase
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.
2
7
3
Add an entries the Blizzard device in MAINTAINERS.
8
This coccinelle script adds the ResetType argument to the hold and
9
exit phases of the Resettable interface.
4
10
5
Reviewed-by: Thomas Huth <thuth@redhat.com>
11
The first part of the script (rules holdfn_assigned, holdfn_defined,
6
Reviewed-by: Markus Armbruster <armbru@redhat.com>
12
exitfn_assigned, exitfn_defined) update implementations of the
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
interface within device models, both to change the signature of their
8
Message-id: 20190412165416.7977-6-philmd@redhat.com
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
23
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Luc Michel <luc.michel@amd.com>
26
Message-id: 20240412160809.1260625-4-peter.maydell@linaro.org
10
---
27
---
11
include/hw/devices.h | 7 -------
28
scripts/coccinelle/reset-type.cocci | 133 ++++++++++++++++++++++++++++
12
include/hw/display/blizzard.h | 22 ++++++++++++++++++++++
29
1 file changed, 133 insertions(+)
13
hw/arm/nseries.c | 1 +
30
create mode 100644 scripts/coccinelle/reset-type.cocci
14
hw/display/blizzard.c | 2 +-
15
MAINTAINERS | 2 ++
16
5 files changed, 26 insertions(+), 8 deletions(-)
17
create mode 100644 include/hw/display/blizzard.h
18
31
19
diff --git a/include/hw/devices.h b/include/hw/devices.h
32
diff --git a/scripts/coccinelle/reset-type.cocci b/scripts/coccinelle/reset-type.cocci
20
index XXXXXXX..XXXXXXX 100644
21
--- a/include/hw/devices.h
22
+++ b/include/hw/devices.h
23
@@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
24
/* stellaris_input.c */
25
void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
26
27
-/* blizzard.c */
28
-void *s1d13745_init(qemu_irq gpio_int);
29
-void s1d13745_write(void *opaque, int dc, uint16_t value);
30
-void s1d13745_write_block(void *opaque, int dc,
31
- void *buf, size_t len, int pitch);
32
-uint16_t s1d13745_read(void *opaque, int dc);
33
-
34
/* cbus.c */
35
typedef struct {
36
qemu_irq clk;
37
diff --git a/include/hw/display/blizzard.h b/include/hw/display/blizzard.h
38
new file mode 100644
33
new file mode 100644
39
index XXXXXXX..XXXXXXX
34
index XXXXXXX..XXXXXXX
40
--- /dev/null
35
--- /dev/null
41
+++ b/include/hw/display/blizzard.h
36
+++ b/scripts/coccinelle/reset-type.cocci
42
@@ -XXX,XX +XXX,XX @@
37
@@ -XXX,XX +XXX,XX @@
43
+/*
38
+// Convert device code using three-phase reset to add a ResetType
44
+ * Epson S1D13744/S1D13745 (Blizzard/Hailstorm/Tornado) LCD/TV controller.
39
+// argument to implementations of ResettableHoldPhase and
45
+ *
40
+// ResettableEnterPhase methods.
46
+ * Copyright (C) 2008 Nokia Corporation
41
+//
47
+ * Written by Andrzej Zaborowski
42
+// Copyright Linaro Ltd 2024
48
+ *
43
+// SPDX-License-Identifier: GPL-2.0-or-later
49
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
44
+//
50
+ * See the COPYING file in the top-level directory.
45
+// for dir in include hw target; do \
51
+ */
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.
52
+
57
+
53
+#ifndef HW_DISPLAY_BLIZZARD_H
58
+// Look for where we use a function as a ResettableHoldPhase method,
54
+#define HW_DISPLAY_BLIZZARD_H
59
+// either by directly assigning it to phases.hold or by calling
60
+// resettable_class_set_parent_phases, and remember the function name.
61
+@ holdfn_assigned @
62
+identifier enterfn, holdfn, exitfn;
63
+identifier rc;
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
+)
55
+
73
+
56
+#include "hw/irq.h"
74
+// Look for the definition of the function we found in holdfn_assigned,
75
+// and add the new argument. If the function calls a hold function
76
+// itself (probably chaining to the parent class reset) then add the
77
+// new argument there too.
78
+@ holdfn_defined @
79
+identifier holdfn_assigned.holdfn;
80
+typedef Object;
81
+identifier obj;
82
+expression parent;
83
+@@
84
+-holdfn(Object *obj)
85
++holdfn(Object *obj, ResetType type)
86
+{
87
+ <...
88
+- parent.hold(obj)
89
++ parent.hold(obj, type)
90
+ ...>
91
+}
57
+
92
+
58
+void *s1d13745_init(qemu_irq gpio_int);
93
+// Similarly for ResettableExitPhase.
59
+void s1d13745_write(void *opaque, int dc, uint16_t value);
94
+@ exitfn_assigned @
60
+void s1d13745_write_block(void *opaque, int dc,
95
+identifier enterfn, holdfn, exitfn;
61
+ void *buf, size_t len, int pitch);
96
+identifier rc;
62
+uint16_t s1d13745_read(void *opaque, int dc);
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)
114
+{
115
+ <...
116
+- parent.exit(obj)
117
++ parent.exit(obj, type)
118
+ ...>
119
+}
63
+
120
+
64
+#endif
121
+// SPECIAL CASES ONLY BELOW HERE
65
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
122
+// We use a python scripted constraint on the position of the match
66
index XXXXXXX..XXXXXXX 100644
123
+// to ensure that they only match in a particular function. See
67
--- a/hw/arm/nseries.c
124
+// https://public-inbox.org/git/alpine.DEB.2.21.1808240652370.2344@hadrien/
68
+++ b/hw/arm/nseries.c
125
+// which recommends this as the way to do "match only in this function".
69
@@ -XXX,XX +XXX,XX @@
126
+
70
#include "hw/boards.h"
127
+// Special case: isl_pmbus_vr.c has some reset methods calling others directly
71
#include "hw/i2c/i2c.h"
128
+@ isl_pmbus_vr @
72
#include "hw/devices.h"
129
+identifier obj;
73
+#include "hw/display/blizzard.h"
130
+@@
74
#include "hw/misc/tmp105.h"
131
+- isl_pmbus_vr_exit_reset(obj);
75
#include "hw/block/flash.h"
132
++ isl_pmbus_vr_exit_reset(obj, type);
76
#include "hw/hw.h"
133
+
77
diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c
134
+// Special case: device_phases_reset() needs to pass RESET_TYPE_COLD
78
index XXXXXXX..XXXXXXX 100644
135
+@ device_phases_reset_hold @
79
--- a/hw/display/blizzard.c
136
+expression obj;
80
+++ b/hw/display/blizzard.c
137
+identifier rc;
81
@@ -XXX,XX +XXX,XX @@
138
+identifier phase;
82
#include "qemu/osdep.h"
139
+position p : script:python() { p[0].current_element == "device_phases_reset" };
83
#include "qemu-common.h"
140
+@@
84
#include "ui/console.h"
141
+- rc->phases.phase(obj)@p
85
-#include "hw/devices.h"
142
++ rc->phases.phase(obj, RESET_TYPE_COLD)
86
+#include "hw/display/blizzard.h"
143
+
87
#include "ui/pixel_ops.h"
144
+// Special case: in resettable_phase_hold() and resettable_phase_exit()
88
145
+// we need to pass through the ResetType argument to the method being called
89
typedef void (*blizzard_fn_t)(uint8_t *, const uint8_t *, unsigned int);
146
+@ resettable_phase_hold @
90
diff --git a/MAINTAINERS b/MAINTAINERS
147
+expression obj;
91
index XXXXXXX..XXXXXXX 100644
148
+identifier rc;
92
--- a/MAINTAINERS
149
+position p : script:python() { p[0].current_element == "resettable_phase_hold" };
93
+++ b/MAINTAINERS
150
+@@
94
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
151
+- rc->phases.hold(obj)@p
95
L: qemu-arm@nongnu.org
152
++ rc->phases.hold(obj, type)
96
S: Odd Fixes
153
+@ resettable_phase_exit @
97
F: hw/arm/nseries.c
154
+expression obj;
98
+F: hw/display/blizzard.c
155
+identifier rc;
99
F: hw/input/lm832x.c
156
+position p : script:python() { p[0].current_element == "resettable_phase_exit" };
100
F: hw/input/tsc2005.c
157
+@@
101
F: hw/misc/cbus.c
158
+- rc->phases.exit(obj)@p
102
F: hw/timer/twl92230.c
159
++ rc->phases.exit(obj, type)
103
+F: include/hw/display/blizzard.h
160
+// Special case: the typedefs for the methods need to declare the new argument
104
161
+@ phase_typedef_hold @
105
Palm
162
+identifier obj;
106
M: Andrzej Zaborowski <balrogg@gmail.com>
163
+@@
164
+- typedef void (*ResettableHoldPhase)(Object *obj);
165
++ typedef void (*ResettableHoldPhase)(Object *obj, ResetType type);
166
+@ phase_typedef_exit @
167
+identifier obj;
168
+@@
169
+- typedef void (*ResettableExitPhase)(Object *obj);
170
++ typedef void (*ResettableExitPhase)(Object *obj, ResetType type);
107
--
171
--
108
2.20.1
172
2.34.1
109
110
diff view generated by jsdifflib
1
From: Eric Auger <eric.auger@redhat.com>
1
We pass a ResetType argument to the Resettable class enter
2
phase method, but we don't pass it to hold and exit, even though
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.
2
7
3
The SMMUNotifierNode struct is not necessary and brings extra
8
Commit created with
4
complexity so let's remove it. We now directly track the SMMUDevices
5
which have registered IOMMU MR notifiers.
6
9
7
This is inspired from the same transformation on intel-iommu
10
for dir in hw target include; do \
8
done in commit b4a4ba0d68f50f218ee3957b6638dbee32a5eeef
11
spatch --macro-file scripts/cocci-macro-file.h \
9
("intel-iommu: remove IntelIOMMUNotifierNode")
12
--sp-file scripts/coccinelle/reset-type.cocci \
13
--keep-comments --smpl-spacing --in-place \
14
--include-headers --dir $dir; done
10
15
11
Signed-off-by: Eric Auger <eric.auger@redhat.com>
16
and no manual edits.
12
Reviewed-by: Peter Xu <peterx@redhat.com>
17
13
Message-id: 20190409160219.19026-1-eric.auger@redhat.com
14
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>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Reviewed-by: Luc Michel <luc.michel@amd.com>
22
Message-id: 20240412160809.1260625-5-peter.maydell@linaro.org
15
---
23
---
16
include/hw/arm/smmu-common.h | 8 ++------
24
include/hw/resettable.h | 4 ++--
17
hw/arm/smmu-common.c | 6 +++---
25
hw/adc/npcm7xx_adc.c | 2 +-
18
hw/arm/smmuv3.c | 28 +++++++---------------------
26
hw/arm/pxa2xx_pic.c | 2 +-
19
3 files changed, 12 insertions(+), 30 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(-)
20
119
21
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
120
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
22
index XXXXXXX..XXXXXXX 100644
121
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/arm/smmu-common.h
122
--- a/include/hw/resettable.h
24
+++ b/include/hw/arm/smmu-common.h
123
+++ b/include/hw/resettable.h
25
@@ -XXX,XX +XXX,XX @@ typedef struct SMMUDevice {
124
@@ -XXX,XX +XXX,XX @@ typedef enum ResetType {
26
AddressSpace as;
125
* the callback.
27
uint32_t cfg_cache_hits;
126
*/
28
uint32_t cfg_cache_misses;
127
typedef void (*ResettableEnterPhase)(Object *obj, ResetType type);
29
+ QLIST_ENTRY(SMMUDevice) next;
128
-typedef void (*ResettableHoldPhase)(Object *obj);
30
} SMMUDevice;
129
-typedef void (*ResettableExitPhase)(Object *obj);
31
130
+typedef void (*ResettableHoldPhase)(Object *obj, ResetType type);
32
-typedef struct SMMUNotifierNode {
131
+typedef void (*ResettableExitPhase)(Object *obj, ResetType type);
33
- SMMUDevice *sdev;
132
typedef ResettableState * (*ResettableGetState)(Object *obj);
34
- QLIST_ENTRY(SMMUNotifierNode) next;
133
typedef void (*ResettableTrFunction)(Object *obj);
35
-} SMMUNotifierNode;
134
typedef ResettableTrFunction (*ResettableGetTrFunction)(Object *obj);
36
-
135
diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c
37
typedef struct SMMUPciBus {
136
index XXXXXXX..XXXXXXX 100644
38
PCIBus *bus;
137
--- a/hw/adc/npcm7xx_adc.c
39
SMMUDevice *pbdev[0]; /* Parent array is sparse, so dynamically alloc */
138
+++ b/hw/adc/npcm7xx_adc.c
40
@@ -XXX,XX +XXX,XX @@ typedef struct SMMUState {
139
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_adc_enter_reset(Object *obj, ResetType type)
41
GHashTable *iotlb;
140
npcm7xx_adc_reset(s);
42
SMMUPciBus *smmu_pcibus_by_bus_num[SMMU_PCI_BUS_MAX];
141
}
43
PCIBus *pci_bus;
142
44
- QLIST_HEAD(, SMMUNotifierNode) notifiers_list;
143
-static void npcm7xx_adc_hold_reset(Object *obj)
45
+ QLIST_HEAD(, SMMUDevice) devices_with_notifiers;
144
+static void npcm7xx_adc_hold_reset(Object *obj, ResetType type)
46
uint8_t bus_num;
145
{
47
PCIBus *primary_bus;
146
NPCM7xxADCState *s = NPCM7XX_ADC(obj);
48
} SMMUState;
147
148
diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c
149
index XXXXXXX..XXXXXXX 100644
150
--- a/hw/arm/pxa2xx_pic.c
151
+++ b/hw/arm/pxa2xx_pic.c
152
@@ -XXX,XX +XXX,XX @@ static int pxa2xx_pic_post_load(void *opaque, int version_id)
153
return 0;
154
}
155
156
-static void pxa2xx_pic_reset_hold(Object *obj)
157
+static void pxa2xx_pic_reset_hold(Object *obj, ResetType type)
158
{
159
PXA2xxPICState *s = PXA2XX_PIC(obj);
160
49
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
161
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
50
index XXXXXXX..XXXXXXX 100644
162
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/arm/smmu-common.c
163
--- a/hw/arm/smmu-common.c
52
+++ b/hw/arm/smmu-common.c
164
+++ b/hw/arm/smmu-common.c
53
@@ -XXX,XX +XXX,XX @@ inline void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr)
165
@@ -XXX,XX +XXX,XX @@ static void smmu_base_realize(DeviceState *dev, Error **errp)
54
/* Unmap all notifiers of all mr's */
166
}
55
void smmu_inv_notifiers_all(SMMUState *s)
167
}
56
{
168
57
- SMMUNotifierNode *node;
169
-static void smmu_base_reset_hold(Object *obj)
58
+ SMMUDevice *sdev;
170
+static void smmu_base_reset_hold(Object *obj, ResetType type)
59
171
{
60
- QLIST_FOREACH(node, &s->notifiers_list, next) {
172
SMMUState *s = ARM_SMMU(obj);
61
- smmu_inv_notifiers_mr(&node->sdev->iommu);
62
+ QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
63
+ smmu_inv_notifiers_mr(&sdev->iommu);
64
}
65
}
66
173
67
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
174
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
68
index XXXXXXX..XXXXXXX 100644
175
index XXXXXXX..XXXXXXX 100644
69
--- a/hw/arm/smmuv3.c
176
--- a/hw/arm/smmuv3.c
70
+++ b/hw/arm/smmuv3.c
177
+++ b/hw/arm/smmuv3.c
71
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
178
@@ -XXX,XX +XXX,XX @@ static void smmu_init_irq(SMMUv3State *s, SysBusDevice *dev)
72
/* invalidate an asid/iova tuple in all mr's */
179
}
73
static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova)
180
}
74
{
181
75
- SMMUNotifierNode *node;
182
-static void smmu_reset_hold(Object *obj)
76
+ SMMUDevice *sdev;
183
+static void smmu_reset_hold(Object *obj, ResetType type)
77
184
{
78
- QLIST_FOREACH(node, &s->notifiers_list, next) {
185
SMMUv3State *s = ARM_SMMUV3(obj);
79
- IOMMUMemoryRegion *mr = &node->sdev->iommu;
186
SMMUv3Class *c = ARM_SMMUV3_GET_CLASS(s);
80
+ QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
187
81
+ IOMMUMemoryRegion *mr = &sdev->iommu;
188
if (c->parent_phases.hold) {
82
IOMMUNotifier *n;
189
- c->parent_phases.hold(obj);
83
190
+ c->parent_phases.hold(obj, type);
84
trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, iova);
191
}
85
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
192
86
SMMUDevice *sdev = container_of(iommu, SMMUDevice, iommu);
193
smmuv3_init_regs(s);
87
SMMUv3State *s3 = sdev->smmu;
194
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
88
SMMUState *s = &(s3->smmu_state);
195
index XXXXXXX..XXXXXXX 100644
89
- SMMUNotifierNode *node = NULL;
196
--- a/hw/arm/stellaris.c
90
- SMMUNotifierNode *next_node = NULL;
197
+++ b/hw/arm/stellaris.c
91
198
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_enter(Object *obj, ResetType type)
92
if (new & IOMMU_NOTIFIER_MAP) {
199
s->dcgc[0] = 1;
93
int bus_num = pci_bus_num(sdev->bus);
200
}
94
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
201
95
202
-static void stellaris_sys_reset_hold(Object *obj)
96
if (old == IOMMU_NOTIFIER_NONE) {
203
+static void stellaris_sys_reset_hold(Object *obj, ResetType type)
97
trace_smmuv3_notify_flag_add(iommu->parent_obj.name);
204
{
98
- node = g_malloc0(sizeof(*node));
205
ssys_state *s = STELLARIS_SYS(obj);
99
- node->sdev = sdev;
206
100
- QLIST_INSERT_HEAD(&s->notifiers_list, node, next);
207
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_hold(Object *obj)
101
- return;
208
ssys_calculate_system_clock(s, true);
102
- }
209
}
103
-
210
104
- /* update notifier node with new flags */
211
-static void stellaris_sys_reset_exit(Object *obj)
105
- QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) {
212
+static void stellaris_sys_reset_exit(Object *obj, ResetType type)
106
- if (node->sdev == sdev) {
213
{
107
- if (new == IOMMU_NOTIFIER_NONE) {
214
}
108
- trace_smmuv3_notify_flag_del(iommu->parent_obj.name);
215
109
- QLIST_REMOVE(node, next);
216
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_reset_enter(Object *obj, ResetType type)
110
- g_free(node);
217
i2c_end_transfer(s->bus);
111
- }
218
}
112
- return;
219
113
- }
220
-static void stellaris_i2c_reset_hold(Object *obj)
114
+ QLIST_INSERT_HEAD(&s->devices_with_notifiers, sdev, next);
221
+static void stellaris_i2c_reset_hold(Object *obj, ResetType type)
115
+ } else if (new == IOMMU_NOTIFIER_NONE) {
222
{
116
+ trace_smmuv3_notify_flag_del(iommu->parent_obj.name);
223
stellaris_i2c_state *s = STELLARIS_I2C(obj);
117
+ QLIST_REMOVE(sdev, next);
224
118
}
225
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_reset_hold(Object *obj)
119
}
226
s->mcr = 0;
120
227
}
228
229
-static void stellaris_i2c_reset_exit(Object *obj)
230
+static void stellaris_i2c_reset_exit(Object *obj, ResetType type)
231
{
232
stellaris_i2c_state *s = STELLARIS_I2C(obj);
233
234
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_trigger(void *opaque, int irq, int level)
235
}
236
}
237
238
-static void stellaris_adc_reset_hold(Object *obj)
239
+static void stellaris_adc_reset_hold(Object *obj, ResetType type)
240
{
241
StellarisADCState *s = STELLARIS_ADC(obj);
242
int n;
243
diff --git a/hw/audio/asc.c b/hw/audio/asc.c
244
index XXXXXXX..XXXXXXX 100644
245
--- a/hw/audio/asc.c
246
+++ b/hw/audio/asc.c
247
@@ -XXX,XX +XXX,XX @@ static void asc_fifo_init(ASCFIFOState *fs, int index)
248
g_free(name);
249
}
250
251
-static void asc_reset_hold(Object *obj)
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);
335
}
336
}
337
trace_resettable_phase_hold_end(obj, obj_typename, s->count);
338
@@ -XXX,XX +XXX,XX @@ static void resettable_phase_exit(Object *obj, void *opaque, ResetType type)
339
if (--s->count == 0) {
340
trace_resettable_phase_exit_exec(obj, obj_typename, !!rc->phases.exit);
341
if (rc->phases.exit && !resettable_get_tr_func(rc, obj)) {
342
- rc->phases.exit(obj);
343
+ rc->phases.exit(obj, type);
344
}
345
}
346
s->exit_phase_in_progress = false;
347
diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
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];
121
--
1799
--
122
2.20.1
1800
2.34.1
123
124
diff view generated by jsdifflib
Deleted patch
1
In the stripe8() function we use a variable length array; however
2
we know that the maximum length required is MAX_NUM_BUSSES. Use
3
a fixed-length array and an assert instead.
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
10
Message-id: 20190328152635.2794-1-peter.maydell@linaro.org
11
---
12
hw/ssi/xilinx_spips.c | 6 ++++--
13
1 file changed, 4 insertions(+), 2 deletions(-)
14
15
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/ssi/xilinx_spips.c
18
+++ b/hw/ssi/xilinx_spips.c
19
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_qspips_reset(DeviceState *d)
20
21
static inline void stripe8(uint8_t *x, int num, bool dir)
22
{
23
- uint8_t r[num];
24
- memset(r, 0, sizeof(uint8_t) * num);
25
+ uint8_t r[MAX_NUM_BUSSES];
26
int idx[2] = {0, 0};
27
int bit[2] = {0, 7};
28
int d = dir;
29
30
+ assert(num <= MAX_NUM_BUSSES);
31
+ memset(r, 0, sizeof(uint8_t) * num);
32
+
33
for (idx[0] = 0; idx[0] < num; ++idx[0]) {
34
for (bit[0] = 7; bit[0] >= 0; bit[0]--) {
35
r[idx[!d]] |= x[idx[d]] & 1 << bit[d] ? 1 << bit[!d] : 0;
36
--
37
2.20.1
38
39
diff view generated by jsdifflib
Deleted patch
1
Normally configure identifies the source path by looking
2
at the location where the configure script itself exists.
3
We also provide a --source-path option which lets the user
4
manually override this.
5
1
6
There isn't really an obvious use case for the --source-path
7
option, and in commit 927128222b0a91f56c13a in 2017 we
8
accidentally added some logic that looks at $source_path
9
before the command line option that overrides it has been
10
processed.
11
12
The fact that nobody complained suggests that there isn't
13
any use of this option and we aren't testing it either;
14
remove it. This allows us to move the "make $source_path
15
absolute" logic up so that there is no window in the script
16
where $source_path is set but not yet absolute.
17
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
20
Message-id: 20190318134019.23729-1-peter.maydell@linaro.org
21
---
22
configure | 10 ++--------
23
1 file changed, 2 insertions(+), 8 deletions(-)
24
25
diff --git a/configure b/configure
26
index XXXXXXX..XXXXXXX 100755
27
--- a/configure
28
+++ b/configure
29
@@ -XXX,XX +XXX,XX @@ ld_has() {
30
31
# default parameters
32
source_path=$(dirname "$0")
33
+# make source path absolute
34
+source_path=$(cd "$source_path"; pwd)
35
cpu=""
36
iasl="iasl"
37
interp_prefix="/usr/gnemul/qemu-%M"
38
@@ -XXX,XX +XXX,XX @@ for opt do
39
;;
40
--cxx=*) CXX="$optarg"
41
;;
42
- --source-path=*) source_path="$optarg"
43
- ;;
44
--cpu=*) cpu="$optarg"
45
;;
46
--extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
47
@@ -XXX,XX +XXX,XX @@ if test "$debug_info" = "yes"; then
48
LDFLAGS="-g $LDFLAGS"
49
fi
50
51
-# make source path absolute
52
-source_path=$(cd "$source_path"; pwd)
53
-
54
# running configure in the source tree?
55
# we know that's the case if configure is there.
56
if test -f "./configure"; then
57
@@ -XXX,XX +XXX,XX @@ for opt do
58
;;
59
--interp-prefix=*) interp_prefix="$optarg"
60
;;
61
- --source-path=*)
62
- ;;
63
--cross-prefix=*)
64
;;
65
--cc=*)
66
@@ -XXX,XX +XXX,XX @@ $(echo Available targets: $default_target_list | \
67
--target-list-exclude=LIST exclude a set of targets from the default target-list
68
69
Advanced options (experts only):
70
- --source-path=PATH path of source code [$source_path]
71
--cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
72
--cc=CC use C compiler CC [$cc]
73
--iasl=IASL use ACPI compiler IASL [$iasl]
74
--
75
2.20.1
76
77
diff view generated by jsdifflib
Deleted patch
1
For M-profile the MVFR* ID registers are memory mapped, in the
2
range we implement via the NVIC. Allow them to be read.
3
(If the CPU has no FPU, these registers are defined to be RAZ.)
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20190416125744.27770-3-peter.maydell@linaro.org
8
---
9
hw/intc/armv7m_nvic.c | 6 ++++++
10
1 file changed, 6 insertions(+)
11
12
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/intc/armv7m_nvic.c
15
+++ b/hw/intc/armv7m_nvic.c
16
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
17
return 0;
18
}
19
return cpu->env.v7m.sfar;
20
+ case 0xf40: /* MVFR0 */
21
+ return cpu->isar.mvfr0;
22
+ case 0xf44: /* MVFR1 */
23
+ return cpu->isar.mvfr1;
24
+ case 0xf48: /* MVFR2 */
25
+ return cpu->isar.mvfr2;
26
default:
27
bad_offset:
28
qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset);
29
--
30
2.20.1
31
32
diff view generated by jsdifflib
Deleted patch
1
The only "system register" that M-profile floating point exposes
2
via the VMRS/VMRS instructions is FPSCR, and it does not have
3
the odd special case for rd==15. Add a check to ensure we only
4
expose FPSCR.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-5-peter.maydell@linaro.org
9
---
10
target/arm/translate.c | 19 +++++++++++++++++--
11
1 file changed, 17 insertions(+), 2 deletions(-)
12
13
diff --git a/target/arm/translate.c b/target/arm/translate.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate.c
16
+++ b/target/arm/translate.c
17
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
18
}
19
}
20
} else { /* !dp */
21
+ bool is_sysreg;
22
+
23
if ((insn & 0x6f) != 0x00)
24
return 1;
25
rn = VFP_SREG_N(insn);
26
+
27
+ is_sysreg = extract32(insn, 21, 1);
28
+
29
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
30
+ /*
31
+ * The only M-profile VFP vmrs/vmsr sysreg is FPSCR.
32
+ * Writes to R15 are UNPREDICTABLE; we choose to undef.
33
+ */
34
+ if (is_sysreg && (rd == 15 || (rn >> 1) != ARM_VFP_FPSCR)) {
35
+ return 1;
36
+ }
37
+ }
38
+
39
if (insn & ARM_CP_RW_BIT) {
40
/* vfp->arm */
41
- if (insn & (1 << 21)) {
42
+ if (is_sysreg) {
43
/* system register */
44
rn >>= 1;
45
46
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
47
}
48
} else {
49
/* arm->vfp */
50
- if (insn & (1 << 21)) {
51
+ if (is_sysreg) {
52
rn >>= 1;
53
/* system register */
54
switch (rn) {
55
--
56
2.20.1
57
58
diff view generated by jsdifflib
Deleted patch
1
Correct the decode of the M-profile "coprocessor and
2
floating-point instructions" space:
3
* op0 == 0b11 is always unallocated
4
* if the CPU has an FPU then all insns with op1 == 0b101
5
are floating point and go to disas_vfp_insn()
6
1
7
For the moment we leave VLLDM and VLSTM as NOPs; in
8
a later commit we will fill in the proper implementation
9
for the case where an FPU is present.
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20190416125744.27770-7-peter.maydell@linaro.org
14
---
15
target/arm/translate.c | 26 ++++++++++++++++++++++----
16
1 file changed, 22 insertions(+), 4 deletions(-)
17
18
diff --git a/target/arm/translate.c b/target/arm/translate.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/translate.c
21
+++ b/target/arm/translate.c
22
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
23
case 6: case 7: case 14: case 15:
24
/* Coprocessor. */
25
if (arm_dc_feature(s, ARM_FEATURE_M)) {
26
- /* We don't currently implement M profile FP support,
27
- * so this entire space should give a NOCP fault, with
28
- * the exception of the v8M VLLDM and VLSTM insns, which
29
- * must be NOPs in Secure state and UNDEF in Nonsecure state.
30
+ /* 0b111x_11xx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx */
31
+ if (extract32(insn, 24, 2) == 3) {
32
+ goto illegal_op; /* op0 = 0b11 : unallocated */
33
+ }
34
+
35
+ /*
36
+ * Decode VLLDM and VLSTM first: these are nonstandard because:
37
+ * * if there is no FPU then these insns must NOP in
38
+ * Secure state and UNDEF in Nonsecure state
39
+ * * if there is an FPU then these insns do not have
40
+ * the usual behaviour that disas_vfp_insn() provides of
41
+ * being controlled by CPACR/NSACR enable bits or the
42
+ * lazy-stacking logic.
43
*/
44
if (arm_dc_feature(s, ARM_FEATURE_V8) &&
45
(insn & 0xffa00f00) == 0xec200a00) {
46
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
47
/* Just NOP since FP support is not implemented */
48
break;
49
}
50
+ if (arm_dc_feature(s, ARM_FEATURE_VFP) &&
51
+ ((insn >> 8) & 0xe) == 10) {
52
+ /* FP, and the CPU supports it */
53
+ if (disas_vfp_insn(s, insn)) {
54
+ goto illegal_op;
55
+ }
56
+ break;
57
+ }
58
+
59
/* All other insns: NOCP */
60
gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(),
61
default_exception_el(s));
62
--
63
2.20.1
64
65
diff view generated by jsdifflib
1
We are close to running out of TB flags for AArch32; we could
1
Update the reset documentation's example code to match the new API
2
start using the cs_base word, but before we do that we can
2
for the hold and exit phase method APIs where they take a ResetType
3
economise on our usage by sharing the same bits for the VFP
3
argument.
4
VECSTRIDE field and the XScale XSCALE_CPAR field. This
5
works because no XScale CPU ever had VFP.
6
4
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-18-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
10
---
10
---
11
target/arm/cpu.h | 10 ++++++----
11
docs/devel/reset.rst | 8 ++++----
12
target/arm/cpu.c | 7 +++++++
12
1 file changed, 4 insertions(+), 4 deletions(-)
13
target/arm/helper.c | 6 +++++-
14
target/arm/translate.c | 9 +++++++--
15
4 files changed, 25 insertions(+), 7 deletions(-)
16
13
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
18
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
16
--- a/docs/devel/reset.rst
20
+++ b/target/arm/cpu.h
17
+++ b/docs/devel/reset.rst
21
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1)
18
@@ -XXX,XX +XXX,XX @@ in reset.
22
FIELD(TBFLAG_A32, THUMB, 0, 1)
19
mydev->var = 0;
23
FIELD(TBFLAG_A32, VECLEN, 1, 3)
24
FIELD(TBFLAG_A32, VECSTRIDE, 4, 2)
25
+/*
26
+ * We store the bottom two bits of the CPAR as TB flags and handle
27
+ * checks on the other bits at runtime. This shares the same bits as
28
+ * VECSTRIDE, which is OK as no XScale CPU has VFP.
29
+ */
30
+FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2)
31
/*
32
* Indicates whether cp register reads and writes by guest code should access
33
* the secure or nonsecure bank of banked registers; note that this is not
34
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
35
FIELD(TBFLAG_A32, VFPEN, 7, 1)
36
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
37
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
38
-/* We store the bottom two bits of the CPAR as TB flags and handle
39
- * checks on the other bits at runtime
40
- */
41
-FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2)
42
/* For M profile only, Handler (ie not Thread) mode */
43
FIELD(TBFLAG_A32, HANDLER, 21, 1)
44
/* For M profile only, whether we should generate stack-limit checks */
45
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/target/arm/cpu.c
48
+++ b/target/arm/cpu.c
49
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
50
set_feature(env, ARM_FEATURE_THUMB_DSP);
51
}
20
}
52
21
53
+ /*
22
- static void mydev_reset_hold(Object *obj)
54
+ * We rely on no XScale CPU having VFP so we can use the same bits in the
23
+ static void mydev_reset_hold(Object *obj, ResetType type)
55
+ * TB flags field for VECSTRIDE and XSCALE_CPAR.
24
{
56
+ */
25
MyDevClass *myclass = MYDEV_GET_CLASS(obj);
57
+ assert(!(arm_feature(env, ARM_FEATURE_VFP) &&
26
MyDevState *mydev = MYDEV(obj);
58
+ arm_feature(env, ARM_FEATURE_XSCALE)));
27
/* call parent class hold phase */
59
+
28
if (myclass->parent_phases.hold) {
60
if (arm_feature(env, ARM_FEATURE_V7) &&
29
- myclass->parent_phases.hold(obj);
61
!arm_feature(env, ARM_FEATURE_M) &&
30
+ myclass->parent_phases.hold(obj, type);
62
!arm_feature(env, ARM_FEATURE_PMSA)) {
63
diff --git a/target/arm/helper.c b/target/arm/helper.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/target/arm/helper.c
66
+++ b/target/arm/helper.c
67
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
68
|| arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) {
69
flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1);
70
}
31
}
71
- flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar);
32
/* set an IO */
72
+ /* Note that XSCALE_CPAR shares bits with VECSTRIDE */
33
qemu_set_irq(mydev->irq, 1);
73
+ if (arm_feature(env, ARM_FEATURE_XSCALE)) {
74
+ flags = FIELD_DP32(flags, TBFLAG_A32,
75
+ XSCALE_CPAR, env->cp15.c15_cpar);
76
+ }
77
}
34
}
78
35
79
flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx));
36
- static void mydev_reset_exit(Object *obj)
80
diff --git a/target/arm/translate.c b/target/arm/translate.c
37
+ static void mydev_reset_exit(Object *obj, ResetType type)
81
index XXXXXXX..XXXXXXX 100644
38
{
82
--- a/target/arm/translate.c
39
MyDevClass *myclass = MYDEV_GET_CLASS(obj);
83
+++ b/target/arm/translate.c
40
MyDevState *mydev = MYDEV(obj);
84
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
41
/* call parent class exit phase */
85
dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL);
42
if (myclass->parent_phases.exit) {
86
dc->vfp_enabled = FIELD_EX32(tb_flags, TBFLAG_A32, VFPEN);
43
- myclass->parent_phases.exit(obj);
87
dc->vec_len = FIELD_EX32(tb_flags, TBFLAG_A32, VECLEN);
44
+ myclass->parent_phases.exit(obj, type);
88
- dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE);
45
}
89
- dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR);
46
/* clear an IO */
90
+ if (arm_feature(env, ARM_FEATURE_XSCALE)) {
47
qemu_set_irq(mydev->irq, 0);
91
+ dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR);
92
+ dc->vec_stride = 0;
93
+ } else {
94
+ dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE);
95
+ dc->c15_cpar = 0;
96
+ }
97
dc->v7m_handler_mode = FIELD_EX32(tb_flags, TBFLAG_A32, HANDLER);
98
dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) &&
99
regime_is_secure(env, dc->mmu_idx);
100
--
48
--
101
2.20.1
49
2.34.1
102
50
103
51
diff view generated by jsdifflib
1
The M-profile FPCCR.S bit indicates the security status of
1
Some devices and machines need to handle the reset before a vmsave
2
the floating point context. In the pseudocode ExecuteFPCheck()
2
snapshot is loaded differently -- the main user is the handling of
3
function it is unconditionally set to match the current
3
RNG seed information, which does not want to put a new RNG seed into
4
security state whenever a floating point instruction is
4
a ROM blob when we are doing a snapshot load.
5
executed.
6
5
7
Implement this by adding a new TB flag which tracks whether
6
Currently this kind of reset handling is supported only for:
8
FPCCR.S is different from the current security state, so
7
* TYPE_MACHINE reset methods, which take a ShutdownCause argument
9
that we only need to emit the code to update it in the
8
* reset functions registered with qemu_register_reset_nosnapshotload
10
less-common case when it is not already set correctly.
11
9
12
Note that we will add the handling for the other work done
10
To allow a three-phase-reset device to also distinguish "snapshot
13
by ExecuteFPCheck() in later commits.
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().
14
19
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20190416125744.27770-19-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
18
---
25
---
19
target/arm/cpu.h | 2 ++
26
docs/devel/reset.rst | 17 ++++++++++++++---
20
target/arm/translate.h | 1 +
27
include/hw/resettable.h | 1 +
21
target/arm/helper.c | 5 +++++
28
hw/core/reset.c | 15 ++++-----------
22
target/arm/translate.c | 20 ++++++++++++++++++++
29
hw/core/resettable.c | 4 ----
23
4 files changed, 28 insertions(+)
30
4 files changed, 19 insertions(+), 18 deletions(-)
24
31
25
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
32
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
26
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
27
--- a/target/arm/cpu.h
34
--- a/docs/devel/reset.rst
28
+++ b/target/arm/cpu.h
35
+++ b/docs/devel/reset.rst
29
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
36
@@ -XXX,XX +XXX,XX @@ instantly reset an object, without keeping it in reset state, just call
30
FIELD(TBFLAG_A32, VFPEN, 7, 1)
37
``resettable_reset()``. These functions take two parameters: a pointer to the
31
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
38
object to reset and a reset type.
32
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
39
33
+/* For M profile only, set if FPCCR.S does not match current security state */
40
-Several types of reset will be supported. For now only cold reset is defined;
34
+FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1)
41
-others may be added later. The Resettable interface handles reset types with an
35
/* For M profile only, Handler (ie not Thread) mode */
42
-enum:
36
FIELD(TBFLAG_A32, HANDLER, 21, 1)
43
+The Resettable interface handles reset types with an enum ``ResetType``:
37
/* For M profile only, whether we should generate stack-limit checks */
44
38
diff --git a/target/arm/translate.h b/target/arm/translate.h
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.
59
+
60
+Devices which implement reset methods must treat any unknown ``ResetType``
61
+as equivalent to ``RESET_TYPE_COLD``; this will reduce the amount of
62
+existing code we need to change if we add more types in future.
63
+
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
39
index XXXXXXX..XXXXXXX 100644
68
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/translate.h
69
--- a/include/hw/resettable.h
41
+++ b/target/arm/translate.h
70
+++ b/include/hw/resettable.h
42
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
71
@@ -XXX,XX +XXX,XX @@ typedef struct ResettableState ResettableState;
43
bool v7m_handler_mode;
72
*/
44
bool v8m_secure; /* true if v8M and we're in Secure mode */
73
typedef enum ResetType {
45
bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */
74
RESET_TYPE_COLD,
46
+ bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */
75
+ RESET_TYPE_SNAPSHOT_LOAD,
47
/* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI
76
} ResetType;
48
* so that top level loop can generate correct syndrome information.
77
49
*/
78
/*
50
diff --git a/target/arm/helper.c b/target/arm/helper.c
79
diff --git a/hw/core/reset.c b/hw/core/reset.c
51
index XXXXXXX..XXXXXXX 100644
80
index XXXXXXX..XXXXXXX 100644
52
--- a/target/arm/helper.c
81
--- a/hw/core/reset.c
53
+++ b/target/arm/helper.c
82
+++ b/hw/core/reset.c
54
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
83
@@ -XXX,XX +XXX,XX @@ static ResettableContainer *get_root_reset_container(void)
55
flags = FIELD_DP32(flags, TBFLAG_A32, STACKCHECK, 1);
84
return root_reset_container;
85
}
86
87
-/*
88
- * Reason why the currently in-progress qemu_devices_reset() was called.
89
- * If we made at least SHUTDOWN_CAUSE_SNAPSHOT_LOAD have a corresponding
90
- * ResetType we could perhaps avoid the need for this global.
91
- */
92
-static ShutdownCause device_reset_reason;
93
-
94
/*
95
* This is an Object which implements Resettable simply to call the
96
* callback function in the hold phase.
97
@@ -XXX,XX +XXX,XX @@ static void legacy_reset_hold(Object *obj, ResetType type)
98
{
99
LegacyReset *lr = LEGACY_RESET(obj);
100
101
- if (device_reset_reason == SHUTDOWN_CAUSE_SNAPSHOT_LOAD &&
102
- lr->skip_on_snapshot_load) {
103
+ if (type == RESET_TYPE_SNAPSHOT_LOAD && lr->skip_on_snapshot_load) {
104
return;
56
}
105
}
57
106
lr->func(lr->opaque);
58
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY) &&
107
@@ -XXX,XX +XXX,XX @@ void qemu_unregister_resettable(Object *obj)
59
+ FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) {
108
60
+ flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1);
109
void qemu_devices_reset(ShutdownCause reason)
61
+ }
110
{
62
+
111
- device_reset_reason = reason;
63
*pflags = flags;
112
+ ResetType type = (reason == SHUTDOWN_CAUSE_SNAPSHOT_LOAD) ?
64
*cs_base = 0;
113
+ RESET_TYPE_SNAPSHOT_LOAD : RESET_TYPE_COLD;
114
115
/* Reset the simulation */
116
- resettable_reset(OBJECT(get_root_reset_container()), RESET_TYPE_COLD);
117
+ resettable_reset(OBJECT(get_root_reset_container()), type);
65
}
118
}
66
diff --git a/target/arm/translate.c b/target/arm/translate.c
119
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
67
index XXXXXXX..XXXXXXX 100644
120
index XXXXXXX..XXXXXXX 100644
68
--- a/target/arm/translate.c
121
--- a/hw/core/resettable.c
69
+++ b/target/arm/translate.c
122
+++ b/hw/core/resettable.c
70
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
123
@@ -XXX,XX +XXX,XX @@ void resettable_reset(Object *obj, ResetType type)
71
}
124
72
}
125
void resettable_assert_reset(Object *obj, ResetType type)
73
126
{
74
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
127
- /* TODO: change this assert when adding support for other reset types */
75
+ /* Handle M-profile lazy FP state mechanics */
128
- assert(type == RESET_TYPE_COLD);
76
+
129
trace_resettable_reset_assert_begin(obj, type);
77
+ /* Update ownership of FP context: set FPCCR.S to match current state */
130
assert(!enter_phase_in_progress);
78
+ if (s->v8m_fpccr_s_wrong) {
131
79
+ TCGv_i32 tmp;
132
@@ -XXX,XX +XXX,XX @@ void resettable_assert_reset(Object *obj, ResetType type)
80
+
133
81
+ tmp = load_cpu_field(v7m.fpccr[M_REG_S]);
134
void resettable_release_reset(Object *obj, ResetType type)
82
+ if (s->v8m_secure) {
135
{
83
+ tcg_gen_ori_i32(tmp, tmp, R_V7M_FPCCR_S_MASK);
136
- /* TODO: change this assert when adding support for other reset types */
84
+ } else {
137
- assert(type == RESET_TYPE_COLD);
85
+ tcg_gen_andi_i32(tmp, tmp, ~R_V7M_FPCCR_S_MASK);
138
trace_resettable_reset_release_begin(obj, type);
86
+ }
139
assert(!enter_phase_in_progress);
87
+ store_cpu_field(tmp, v7m.fpccr[M_REG_S]);
88
+ /* Don't need to do this for any further FP insns in this TB */
89
+ s->v8m_fpccr_s_wrong = false;
90
+ }
91
+ }
92
+
93
if (extract32(insn, 28, 4) == 0xf) {
94
/*
95
* Encodings with T=1 (Thumb) or unconditional (ARM):
96
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
97
dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) &&
98
regime_is_secure(env, dc->mmu_idx);
99
dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK);
100
+ dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG);
101
dc->cp_regs = cpu->cp_regs;
102
dc->features = env->features;
103
140
104
--
141
--
105
2.20.1
142
2.34.1
106
143
107
144
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
Add the basic infrastructure (register read/write, type...)
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
to implement the STM32L4x5 USART.
5
Message-id: 20190412165416.7977-10-philmd@redhat.com
5
6
Also create different types for the USART, UART and LPUART
7
of the STM32L4x5 to deduplicate code and enable the
8
implementation of different behaviors depending on the type.
9
10
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
11
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
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]
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
17
---
8
include/hw/devices.h | 3 ---
18
MAINTAINERS | 1 +
9
include/hw/net/lan9118.h | 19 +++++++++++++++++++
19
include/hw/char/stm32l4x5_usart.h | 66 +++++
10
hw/arm/kzm.c | 2 +-
20
hw/char/stm32l4x5_usart.c | 396 ++++++++++++++++++++++++++++++
11
hw/arm/mps2.c | 2 +-
21
hw/char/Kconfig | 3 +
12
hw/arm/realview.c | 1 +
22
hw/char/meson.build | 1 +
13
hw/arm/vexpress.c | 2 +-
23
hw/char/trace-events | 4 +
14
hw/net/lan9118.c | 2 +-
24
6 files changed, 471 insertions(+)
15
7 files changed, 24 insertions(+), 7 deletions(-)
25
create mode 100644 include/hw/char/stm32l4x5_usart.h
16
create mode 100644 include/hw/net/lan9118.h
26
create mode 100644 hw/char/stm32l4x5_usart.c
17
27
18
diff --git a/include/hw/devices.h b/include/hw/devices.h
28
diff --git a/MAINTAINERS b/MAINTAINERS
19
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/devices.h
30
--- a/MAINTAINERS
21
+++ b/include/hw/devices.h
31
+++ b/MAINTAINERS
22
@@ -XXX,XX +XXX,XX @@
32
@@ -XXX,XX +XXX,XX @@ M: Inès Varhol <ines.varhol@telecom-paris.fr>
23
/* smc91c111.c */
33
L: qemu-arm@nongnu.org
24
void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
34
S: Maintained
25
35
F: hw/arm/stm32l4x5_soc.c
26
-/* lan9118.c */
36
+F: hw/char/stm32l4x5_usart.c
27
-void lan9118_init(NICInfo *, uint32_t, qemu_irq);
37
F: hw/misc/stm32l4x5_exti.c
28
-
38
F: hw/misc/stm32l4x5_syscfg.c
29
#endif
39
F: hw/misc/stm32l4x5_rcc.c
30
diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h
40
diff --git a/include/hw/char/stm32l4x5_usart.h b/include/hw/char/stm32l4x5_usart.h
31
new file mode 100644
41
new file mode 100644
32
index XXXXXXX..XXXXXXX
42
index XXXXXXX..XXXXXXX
33
--- /dev/null
43
--- /dev/null
34
+++ b/include/hw/net/lan9118.h
44
+++ b/include/hw/char/stm32l4x5_usart.h
35
@@ -XXX,XX +XXX,XX @@
45
@@ -XXX,XX +XXX,XX @@
36
+/*
46
+/*
37
+ * SMSC LAN9118 Ethernet interface emulation
47
+ * STM32L4X5 USART (Universal Synchronous Asynchronous Receiver Transmitter)
38
+ *
48
+ *
39
+ * Copyright (c) 2009 CodeSourcery, LLC.
49
+ * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
40
+ * Written by Paul Brook
50
+ * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
51
+ *
52
+ * SPDX-License-Identifier: GPL-2.0-or-later
41
+ *
53
+ *
42
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
54
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
43
+ * See the COPYING file in the top-level directory.
55
+ * See the COPYING file in the top-level directory.
56
+ *
57
+ * The STM32L4X5 USART is heavily inspired by the stm32f2xx_usart
58
+ * by Alistair Francis.
59
+ * The reference used is the STMicroElectronics RM0351 Reference manual
60
+ * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs.
44
+ */
61
+ */
45
+
62
+
46
+#ifndef HW_NET_LAN9118_H
63
+#ifndef HW_STM32L4X5_USART_H
47
+#define HW_NET_LAN9118_H
64
+#define HW_STM32L4X5_USART_H
48
+
65
+
66
+#include "hw/sysbus.h"
67
+#include "chardev/char-fe.h"
68
+#include "qom/object.h"
69
+
70
+#define TYPE_STM32L4X5_USART_BASE "stm32l4x5-usart-base"
71
+#define TYPE_STM32L4X5_USART "stm32l4x5-usart"
72
+#define TYPE_STM32L4X5_UART "stm32l4x5-uart"
73
+#define TYPE_STM32L4X5_LPUART "stm32l4x5-lpuart"
74
+OBJECT_DECLARE_TYPE(Stm32l4x5UsartBaseState, Stm32l4x5UsartBaseClass,
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
113
new file mode 100644
114
index XXXXXXX..XXXXXXX
115
--- /dev/null
116
+++ b/hw/char/stm32l4x5_usart.c
117
@@ -XXX,XX +XXX,XX @@
118
+/*
119
+ * STM32L4X5 USART (Universal Synchronous Asynchronous Receiver Transmitter)
120
+ *
121
+ * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
122
+ * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
123
+ *
124
+ * SPDX-License-Identifier: GPL-2.0-or-later
125
+ *
126
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
127
+ * See the COPYING file in the top-level directory.
128
+ *
129
+ * The STM32L4X5 USART is heavily inspired by the stm32f2xx_usart
130
+ * by Alistair Francis.
131
+ * The reference used is the STMicroElectronics RM0351 Reference manual
132
+ * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs.
133
+ */
134
+
135
+#include "qemu/osdep.h"
136
+#include "qemu/log.h"
137
+#include "qemu/module.h"
138
+#include "qapi/error.h"
139
+#include "chardev/char-fe.h"
140
+#include "chardev/char-serial.h"
141
+#include "migration/vmstate.h"
142
+#include "hw/char/stm32l4x5_usart.h"
143
+#include "hw/clock.h"
49
+#include "hw/irq.h"
144
+#include "hw/irq.h"
50
+#include "net/net.h"
145
+#include "hw/qdev-clock.h"
51
+
146
+#include "hw/qdev-properties.h"
52
+void lan9118_init(NICInfo *, uint32_t, qemu_irq);
147
+#include "hw/qdev-properties-system.h"
53
+
148
+#include "hw/registerfields.h"
54
+#endif
149
+#include "trace.h"
55
diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c
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
56
index XXXXXXX..XXXXXXX 100644
515
index XXXXXXX..XXXXXXX 100644
57
--- a/hw/arm/kzm.c
516
--- a/hw/char/Kconfig
58
+++ b/hw/arm/kzm.c
517
+++ b/hw/char/Kconfig
59
@@ -XXX,XX +XXX,XX @@
518
@@ -XXX,XX +XXX,XX @@ config VIRTIO_SERIAL
60
#include "qemu/error-report.h"
519
config STM32F2XX_USART
61
#include "exec/address-spaces.h"
520
bool
62
#include "net/net.h"
521
63
-#include "hw/devices.h"
522
+config STM32L4X5_USART
64
+#include "hw/net/lan9118.h"
523
+ bool
65
#include "hw/char/serial.h"
524
+
66
#include "sysemu/qtest.h"
525
config CMSDK_APB_UART
67
526
bool
68
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
527
528
diff --git a/hw/char/meson.build b/hw/char/meson.build
69
index XXXXXXX..XXXXXXX 100644
529
index XXXXXXX..XXXXXXX 100644
70
--- a/hw/arm/mps2.c
530
--- a/hw/char/meson.build
71
+++ b/hw/arm/mps2.c
531
+++ b/hw/char/meson.build
72
@@ -XXX,XX +XXX,XX @@
532
@@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_RENESAS_SCI', if_true: files('renesas_sci.c'))
73
#include "hw/timer/cmsdk-apb-timer.h"
533
system_ss.add(when: 'CONFIG_SIFIVE_UART', if_true: files('sifive_uart.c'))
74
#include "hw/timer/cmsdk-apb-dualtimer.h"
534
system_ss.add(when: 'CONFIG_SH_SCI', if_true: files('sh_serial.c'))
75
#include "hw/misc/mps2-scc.h"
535
system_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: files('stm32f2xx_usart.c'))
76
-#include "hw/devices.h"
536
+system_ss.add(when: 'CONFIG_STM32L4X5_USART', if_true: files('stm32l4x5_usart.c'))
77
+#include "hw/net/lan9118.h"
537
system_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: files('mchp_pfsoc_mmuart.c'))
78
#include "net/net.h"
538
system_ss.add(when: 'CONFIG_HTIF', if_true: files('riscv_htif.c'))
79
539
system_ss.add(when: 'CONFIG_GOLDFISH_TTY', if_true: files('goldfish_tty.c'))
80
typedef enum MPS2FPGAType {
540
diff --git a/hw/char/trace-events b/hw/char/trace-events
81
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
82
index XXXXXXX..XXXXXXX 100644
541
index XXXXXXX..XXXXXXX 100644
83
--- a/hw/arm/realview.c
542
--- a/hw/char/trace-events
84
+++ b/hw/arm/realview.c
543
+++ b/hw/char/trace-events
85
@@ -XXX,XX +XXX,XX @@
544
@@ -XXX,XX +XXX,XX @@ cadence_uart_baudrate(unsigned baudrate) "baudrate %u"
86
#include "hw/arm/arm.h"
545
sh_serial_read(char *id, unsigned size, uint64_t offs, uint64_t val) " %s size %d offs 0x%02" PRIx64 " -> 0x%02" PRIx64
87
#include "hw/arm/primecell.h"
546
sh_serial_write(char *id, unsigned size, uint64_t offs, uint64_t val) "%s size %d offs 0x%02" PRIx64 " <- 0x%02" PRIx64
88
#include "hw/devices.h"
547
89
+#include "hw/net/lan9118.h"
548
+# stm32l4x5_usart.c
90
#include "hw/pci/pci.h"
549
+stm32l4x5_usart_read(uint64_t addr, uint32_t data) "USART: Read <0x%" PRIx64 "> -> 0x%" PRIx32 ""
91
#include "net/net.h"
550
+stm32l4x5_usart_write(uint64_t addr, uint32_t data) "USART: Write <0x%" PRIx64 "> <- 0x%" PRIx32 ""
92
#include "sysemu/sysemu.h"
551
+
93
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
552
# xen_console.c
94
index XXXXXXX..XXXXXXX 100644
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"
95
--- a/hw/arm/vexpress.c
554
xen_console_disconnect(unsigned int idx) "idx %u"
96
+++ b/hw/arm/vexpress.c
97
@@ -XXX,XX +XXX,XX @@
98
#include "hw/sysbus.h"
99
#include "hw/arm/arm.h"
100
#include "hw/arm/primecell.h"
101
-#include "hw/devices.h"
102
+#include "hw/net/lan9118.h"
103
#include "hw/i2c/i2c.h"
104
#include "net/net.h"
105
#include "sysemu/sysemu.h"
106
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
107
index XXXXXXX..XXXXXXX 100644
108
--- a/hw/net/lan9118.c
109
+++ b/hw/net/lan9118.c
110
@@ -XXX,XX +XXX,XX @@
111
#include "hw/sysbus.h"
112
#include "net/net.h"
113
#include "net/eth.h"
114
-#include "hw/devices.h"
115
+#include "hw/net/lan9118.h"
116
#include "sysemu/sysemu.h"
117
#include "hw/ptimer.h"
118
#include "qemu/log.h"
119
--
555
--
120
2.20.1
556
2.34.1
121
557
122
558
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
2
3
Reviewed-by: Thomas Huth <thuth@redhat.com>
3
Implement the ability to read and write characters to the
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
4
usart using the serial port.
5
Reviewed-by: Markus Armbruster <armbru@redhat.com>
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
The character transmission is based on the
7
Message-id: 20190412165416.7977-2-philmd@redhat.com
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
---
15
---
10
hw/arm/aspeed.c | 13 +++++++++----
16
include/hw/char/stm32l4x5_usart.h | 1 +
11
1 file changed, 9 insertions(+), 4 deletions(-)
17
hw/char/stm32l4x5_usart.c | 143 ++++++++++++++++++++++++++++++
12
18
hw/char/trace-events | 7 ++
13
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.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
14
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/aspeed.c
23
--- a/include/hw/char/stm32l4x5_usart.h
16
+++ b/hw/arm/aspeed.c
24
+++ b/include/hw/char/stm32l4x5_usart.h
17
@@ -XXX,XX +XXX,XX @@
25
@@ -XXX,XX +XXX,XX @@ struct Stm32l4x5UsartBaseState {
18
#include "hw/arm/aspeed_soc.h"
26
Clock *clk;
19
#include "hw/boards.h"
27
CharBackend chr;
20
#include "hw/i2c/smbus_eeprom.h"
28
qemu_irq irq;
21
+#include "hw/misc/pca9552.h"
29
+ guint watch_tag;
22
+#include "hw/misc/tmp105.h"
30
};
23
#include "qemu/log.h"
31
24
#include "sysemu/block-backend.h"
32
struct Stm32l4x5UsartBaseClass {
25
#include "hw/loader.h"
33
diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c
26
@@ -XXX,XX +XXX,XX @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
34
index XXXXXXX..XXXXXXX 100644
27
eeprom_buf);
35
--- a/hw/char/stm32l4x5_usart.c
28
36
+++ b/hw/char/stm32l4x5_usart.c
29
/* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
37
@@ -XXX,XX +XXX,XX @@ REG32(RDR, 0x24)
30
- i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d);
38
REG32(TDR, 0x28)
31
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7),
39
FIELD(TDR, TDR, 0, 9)
32
+ TYPE_TMP105, 0x4d);
40
33
41
+static void stm32l4x5_update_irq(Stm32l4x5UsartBaseState *s)
34
/* The AST2500 EVB does not have an RTC. Let's pretend that one is
42
+{
35
* plugged on the I2C bus header */
43
+ if (((s->isr & R_ISR_WUF_MASK) && (s->cr3 & R_CR3_WUFIE_MASK)) ||
36
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
44
+ ((s->isr & R_ISR_CMF_MASK) && (s->cr1 & R_CR1_CMIE_MASK)) ||
37
AspeedSoCState *soc = &bmc->soc;
45
+ ((s->isr & R_ISR_ABRF_MASK) && (s->cr1 & R_CR1_RXNEIE_MASK)) ||
38
uint8_t *eeprom_buf = g_malloc0(8 * 1024);
46
+ ((s->isr & R_ISR_EOBF_MASK) && (s->cr1 & R_CR1_EOBIE_MASK)) ||
39
47
+ ((s->isr & R_ISR_RTOF_MASK) && (s->cr1 & R_CR1_RTOIE_MASK)) ||
40
- i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60);
48
+ ((s->isr & R_ISR_CTSIF_MASK) && (s->cr3 & R_CR3_CTSIE_MASK)) ||
41
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), TYPE_PCA9552,
49
+ ((s->isr & R_ISR_LBDF_MASK) && (s->cr2 & R_CR2_LBDIE_MASK)) ||
42
+ 0x60);
50
+ ((s->isr & R_ISR_TXE_MASK) && (s->cr1 & R_CR1_TXEIE_MASK)) ||
43
51
+ ((s->isr & R_ISR_TC_MASK) && (s->cr1 & R_CR1_TCIE_MASK)) ||
44
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
52
+ ((s->isr & R_ISR_RXNE_MASK) && (s->cr1 & R_CR1_RXNEIE_MASK)) ||
45
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
53
+ ((s->isr & R_ISR_IDLE_MASK) && (s->cr1 & R_CR1_IDLEIE_MASK)) ||
46
54
+ ((s->isr & R_ISR_ORE_MASK) &&
47
/* The Witherspoon expects a TMP275 but a TMP105 is compatible */
55
+ ((s->cr1 & R_CR1_RXNEIE_MASK) || (s->cr3 & R_CR3_EIE_MASK))) ||
48
- i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);
56
+ /* TODO: Handle NF ? */
49
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), TYPE_TMP105,
57
+ ((s->isr & R_ISR_FE_MASK) && (s->cr3 & R_CR3_EIE_MASK)) ||
50
+ 0x4a);
58
+ ((s->isr & R_ISR_PE_MASK) && (s->cr1 & R_CR1_PEIE_MASK))) {
51
59
+ qemu_irq_raise(s->irq);
52
/* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
60
+ trace_stm32l4x5_usart_irq_raised(s->isr);
53
* good enough */
61
+ } else {
54
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
62
+ qemu_irq_lower(s->irq);
55
63
+ trace_stm32l4x5_usart_irq_lowered();
56
smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,
64
+ }
57
eeprom_buf);
65
+}
58
- i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "pca9552",
66
+
59
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), TYPE_PCA9552,
67
+static int stm32l4x5_usart_base_can_receive(void *opaque)
60
0x60);
68
+{
69
+ Stm32l4x5UsartBaseState *s = opaque;
70
+
71
+ if (!(s->isr & R_ISR_RXNE_MASK)) {
72
+ return 1;
73
+ }
74
+
75
+ return 0;
76
+}
77
+
78
+static void stm32l4x5_usart_base_receive(void *opaque, const uint8_t *buf,
79
+ int size)
80
+{
81
+ Stm32l4x5UsartBaseState *s = opaque;
82
+
83
+ if (!((s->cr1 & R_CR1_UE_MASK) && (s->cr1 & R_CR1_RE_MASK))) {
84
+ trace_stm32l4x5_usart_receiver_not_enabled(
85
+ FIELD_EX32(s->cr1, CR1, UE), FIELD_EX32(s->cr1, CR1, RE));
86
+ return;
87
+ }
88
+
89
+ /* Check if overrun detection is enabled and if there is an overrun */
90
+ if (!(s->cr3 & R_CR3_OVRDIS_MASK) && (s->isr & R_ISR_RXNE_MASK)) {
91
+ /*
92
+ * A character has been received while
93
+ * the previous has not been read = Overrun.
94
+ */
95
+ s->isr |= R_ISR_ORE_MASK;
96
+ trace_stm32l4x5_usart_overrun_detected(s->rdr, *buf);
97
+ } else {
98
+ /* No overrun */
99
+ s->rdr = *buf;
100
+ s->isr |= R_ISR_RXNE_MASK;
101
+ trace_stm32l4x5_usart_rx(s->rdr);
102
+ }
103
+
104
+ stm32l4x5_update_irq(s);
105
+}
106
+
107
+/*
108
+ * Try to send tx data, and arrange to be called back later if
109
+ * we can't (ie the char backend is busy/blocking).
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);
61
}
181
}
62
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"
63
--
254
--
64
2.20.1
255
2.34.1
65
256
66
257
diff view generated by jsdifflib
1
Implement the VLSTM instruction for v7M for the FPU present case.
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
2
3
Add a function to change the settings of the
4
serial connection.
5
6
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
7
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20240329174402.60382-4-arnaud.minier@telecom-paris.fr
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190416125744.27770-25-peter.maydell@linaro.org
6
---
11
---
7
target/arm/cpu.h | 2 +
12
hw/char/stm32l4x5_usart.c | 98 +++++++++++++++++++++++++++++++++++++++
8
target/arm/helper.h | 2 +
13
hw/char/trace-events | 1 +
9
target/arm/helper.c | 84 ++++++++++++++++++++++++++++++++++++++++++
14
2 files changed, 99 insertions(+)
10
target/arm/translate.c | 15 +++++++-
11
4 files changed, 102 insertions(+), 1 deletion(-)
12
15
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
16
diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
18
--- a/hw/char/stm32l4x5_usart.c
16
+++ b/target/arm/cpu.h
19
+++ b/hw/char/stm32l4x5_usart.c
17
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@ static void usart_cancel_transmit(Stm32l4x5UsartBaseState *s)
18
#define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */
19
#define EXCP_STKOF 19 /* v8M STKOF UsageFault */
20
#define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */
21
+#define EXCP_LSERR 21 /* v8M LSERR SecureFault */
22
+#define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */
23
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
24
25
#define ARMV7M_EXCP_RESET 1
26
diff --git a/target/arm/helper.h b/target/arm/helper.h
27
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/helper.h
29
+++ b/target/arm/helper.h
30
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32)
31
32
DEF_HELPER_1(v7m_preserve_fp_state, void, env)
33
34
+DEF_HELPER_2(v7m_vlstm, void, env, i32)
35
+
36
DEF_HELPER_2(v8m_stackcheck, void, env, i32)
37
38
DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32)
39
diff --git a/target/arm/helper.c b/target/arm/helper.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/helper.c
42
+++ b/target/arm/helper.c
43
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
44
g_assert_not_reached();
45
}
46
47
+void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
48
+{
49
+ /* translate.c should never generate calls here in user-only mode */
50
+ g_assert_not_reached();
51
+}
52
+
53
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
54
{
55
/* The TT instructions can be used by unprivileged code, but in
56
@@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr,
57
}
21
}
58
}
22
}
59
23
60
+void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
24
+static void stm32l4x5_update_params(Stm32l4x5UsartBaseState *s)
61
+{
25
+{
62
+ /* fptr is the value of Rn, the frame pointer we store the FP regs to */
26
+ int speed, parity, data_bits, stop_bits;
63
+ bool s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
27
+ uint32_t value, usart_div;
64
+ bool lspact = env->v7m.fpccr[s] & R_V7M_FPCCR_LSPACT_MASK;
28
+ QEMUSerialSetParams ssp;
65
+
29
+
66
+ assert(env->v7m.secure);
30
+ /* Select the parity type */
31
+ if (s->cr1 & R_CR1_PCE_MASK) {
32
+ if (s->cr1 & R_CR1_PS_MASK) {
33
+ parity = 'O';
34
+ } else {
35
+ parity = 'E';
36
+ }
37
+ } else {
38
+ parity = 'N';
39
+ }
67
+
40
+
68
+ if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) {
41
+ /* Select the number of stop bits */
42
+ switch (FIELD_EX32(s->cr2, CR2, STOP)) {
43
+ case 0:
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));
69
+ return;
53
+ return;
70
+ }
54
+ }
71
+
55
+
72
+ /* Check access to the coprocessor is permitted */
56
+ /* Select the length of the word */
73
+ if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) {
57
+ switch ((FIELD_EX32(s->cr1, CR1, M1) << 1) | FIELD_EX32(s->cr1, CR1, M0)) {
74
+ raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC());
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;
75
+ }
71
+ }
76
+
72
+
77
+ if (lspact) {
73
+ /* Select the baud rate */
78
+ /* LSPACT should not be active when there is active FP state */
74
+ value = FIELD_EX32(s->brr, BRR, BRR);
79
+ raise_exception_ra(env, EXCP_LSERR, 0, 1, GETPC());
75
+ if (value < 16) {
76
+ qemu_log_mask(LOG_GUEST_ERROR,
77
+ "UNDEFINED: BRR less than 16: %u", value);
78
+ return;
80
+ }
79
+ }
81
+
80
+
82
+ if (fptr & 7) {
81
+ if (FIELD_EX32(s->cr1, CR1, OVER8) == 0) {
83
+ raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC());
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;
84
+ }
96
+ }
85
+
97
+
86
+ /*
98
+ speed = clock_get_hz(s->clk) / usart_div;
87
+ * Note that we do not use v7m_stack_write() here, because the
88
+ * accesses should not set the FSR bits for stacking errors if they
89
+ * fail. (In pseudocode terms, they are AccType_NORMAL, not AccType_STACK
90
+ * or AccType_LAZYFP). Faults in cpu_stl_data() will throw exceptions
91
+ * and longjmp out.
92
+ */
93
+ if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) {
94
+ bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK;
95
+ int i;
96
+
99
+
97
+ for (i = 0; i < (ts ? 32 : 16); i += 2) {
100
+ ssp.speed = speed;
98
+ uint64_t dn = *aa32_vfp_dreg(env, i / 2);
101
+ ssp.parity = parity;
99
+ uint32_t faddr = fptr + 4 * i;
102
+ ssp.data_bits = data_bits;
100
+ uint32_t slo = extract64(dn, 0, 32);
103
+ ssp.stop_bits = stop_bits;
101
+ uint32_t shi = extract64(dn, 32, 32);
102
+
104
+
103
+ if (i >= 16) {
105
+ qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp);
104
+ faddr += 8; /* skip the slot for the FPSCR */
105
+ }
106
+ cpu_stl_data(env, faddr, slo);
107
+ cpu_stl_data(env, faddr + 4, shi);
108
+ }
109
+ cpu_stl_data(env, fptr + 0x40, vfp_get_fpscr(env));
110
+
106
+
111
+ /*
107
+ trace_stm32l4x5_usart_update_params(speed, parity, data_bits, stop_bits);
112
+ * If TS is 0 then s0 to s15 and FPSCR are UNKNOWN; we choose to
113
+ * leave them unchanged, matching our choice in v7m_preserve_fp_state.
114
+ */
115
+ if (ts) {
116
+ for (i = 0; i < 32; i += 2) {
117
+ *aa32_vfp_dreg(env, i / 2) = 0;
118
+ }
119
+ vfp_set_fpscr(env, 0);
120
+ }
121
+ } else {
122
+ v7m_update_fpccr(env, fptr, false);
123
+ }
124
+
125
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
126
+}
108
+}
127
+
109
+
128
static bool v7m_push_stack(ARMCPU *cpu)
110
static void stm32l4x5_usart_base_reset_hold(Object *obj, ResetType type)
129
{
111
{
130
/* Do the "set up stack frame" part of exception entry,
112
Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj);
131
@@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx)
113
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
132
[EXCP_INVSTATE] = "v7M INVSTATE UsageFault",
114
switch (addr) {
133
[EXCP_STKOF] = "v8M STKOF UsageFault",
115
case A_CR1:
134
[EXCP_LAZYFP] = "v7M exception during lazy FP stacking",
116
s->cr1 = value;
135
+ [EXCP_LSERR] = "v8M LSERR UsageFault",
117
+ stm32l4x5_update_params(s);
136
+ [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault",
118
stm32l4x5_update_irq(s);
137
};
119
return;
138
120
case A_CR2:
139
if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
121
s->cr2 = value;
140
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
122
+ stm32l4x5_update_params(s);
141
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
123
return;
142
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_STKOF_MASK;
124
case A_CR3:
143
break;
125
s->cr3 = value;
144
+ case EXCP_LSERR:
126
return;
145
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
127
case A_BRR:
146
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
128
s->brr = value;
147
+ break;
129
+ stm32l4x5_update_params(s);
148
+ case EXCP_UNALIGNED:
130
return;
149
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
131
case A_GTPR:
150
+ env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK;
132
s->gtpr = value;
151
+ break;
133
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_init(Object *obj)
152
case EXCP_SWI:
134
s->clk = qdev_init_clock_in(DEVICE(s), "clk", NULL, s, 0);
153
/* The PC already points to the next instruction. */
135
}
154
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure);
136
155
diff --git a/target/arm/translate.c b/target/arm/translate.c
137
+static int stm32l4x5_usart_base_post_load(void *opaque, int version_id)
138
+{
139
+ Stm32l4x5UsartBaseState *s = (Stm32l4x5UsartBaseState *)opaque;
140
+
141
+ stm32l4x5_update_params(s);
142
+ return 0;
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
156
index XXXXXXX..XXXXXXX 100644
154
index XXXXXXX..XXXXXXX 100644
157
--- a/target/arm/translate.c
155
--- a/hw/char/trace-events
158
+++ b/target/arm/translate.c
156
+++ b/hw/char/trace-events
159
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
157
@@ -XXX,XX +XXX,XX @@ stm32l4x5_usart_irq_raised(uint32_t reg) "USART: IRQ raised: 0x%08"PRIx32
160
if (!s->v8m_secure || (insn & 0x0040f0ff)) {
158
stm32l4x5_usart_irq_lowered(void) "USART: IRQ lowered"
161
goto illegal_op;
159
stm32l4x5_usart_overrun_detected(uint8_t current, uint8_t received) "USART: Overrun detected, RDR='0x%x', received 0x%x"
162
}
160
stm32l4x5_usart_receiver_not_enabled(uint8_t ue_bit, uint8_t re_bit) "USART: Receiver not enabled, UE=0x%x, RE=0x%x"
163
- /* Just NOP since FP support is not implemented */
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"
164
+
162
165
+ if (arm_dc_feature(s, ARM_FEATURE_VFP)) {
163
# xen_console.c
166
+ TCGv_i32 fptr = load_reg(s, rn);
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"
167
+
168
+ if (extract32(insn, 20, 1)) {
169
+ /* VLLDM */
170
+ } else {
171
+ gen_helper_v7m_vlstm(cpu_env, fptr);
172
+ }
173
+ tcg_temp_free_i32(fptr);
174
+
175
+ /* End the TB, because we have updated FP control bits */
176
+ s->base.is_jmp = DISAS_UPDATE;
177
+ }
178
break;
179
}
180
if (arm_dc_feature(s, ARM_FEATURE_VFP) &&
181
--
165
--
182
2.20.1
166
2.34.1
183
167
184
168
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
2
3
No code used the tc6393xb_gpio_in_get() and tc6393xb_gpio_out_set()
3
Add the USART to the SoC and connect it to the other implemented devices.
4
functions since their introduction in commit 88d2c950b002. Time to
4
5
remove them.
5
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
6
6
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
7
Suggested-by: Markus Armbruster <armbru@redhat.com>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Message-id: 20190412165416.7977-4-philmd@redhat.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
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]
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/devices.h | 3 ---
12
docs/system/arm/b-l475e-iot01a.rst | 2 +-
14
hw/display/tc6393xb.c | 16 ----------------
13
include/hw/arm/stm32l4x5_soc.h | 7 +++
15
2 files changed, 19 deletions(-)
14
hw/arm/stm32l4x5_soc.c | 83 +++++++++++++++++++++++++++---
16
15
hw/arm/Kconfig | 1 +
17
diff --git a/include/hw/devices.h b/include/hw/devices.h
16
4 files changed, 86 insertions(+), 7 deletions(-)
18
index XXXXXXX..XXXXXXX 100644
17
19
--- a/include/hw/devices.h
18
diff --git a/docs/system/arm/b-l475e-iot01a.rst b/docs/system/arm/b-l475e-iot01a.rst
20
+++ b/include/hw/devices.h
19
index XXXXXXX..XXXXXXX 100644
21
@@ -XXX,XX +XXX,XX @@ void retu_key_event(void *retu, int state);
20
--- a/docs/system/arm/b-l475e-iot01a.rst
22
typedef struct TC6393xbState TC6393xbState;
21
+++ b/docs/system/arm/b-l475e-iot01a.rst
23
TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
22
@@ -XXX,XX +XXX,XX @@ Currently B-L475E-IOT01A machine's only supports the following devices:
24
uint32_t base, qemu_irq irq);
23
- STM32L4x5 SYSCFG (System configuration controller)
25
-void tc6393xb_gpio_out_set(TC6393xbState *s, int line,
24
- STM32L4x5 RCC (Reset and clock control)
26
- qemu_irq handler);
25
- STM32L4x5 GPIOs (General-purpose I/Os)
27
-qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s);
26
+- STM32L4x5 USARTs, UARTs and LPUART (Serial ports)
28
qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
27
29
28
Missing devices
30
#endif
29
"""""""""""""""
31
diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
30
32
index XXXXXXX..XXXXXXX 100644
31
The B-L475E-IOT01A does *not* support the following devices:
33
--- a/hw/display/tc6393xb.c
32
34
+++ b/hw/display/tc6393xb.c
33
-- Serial ports (UART)
35
@@ -XXX,XX +XXX,XX @@ struct TC6393xbState {
34
- Analog to Digital Converter (ADC)
36
blanked : 1;
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
41
@@ -XXX,XX +XXX,XX @@
42
#include "hw/misc/stm32l4x5_exti.h"
43
#include "hw/misc/stm32l4x5_rcc.h"
44
#include "hw/gpio/stm32l4x5_gpio.h"
45
+#include "hw/char/stm32l4x5_usart.h"
46
#include "qom/object.h"
47
48
#define TYPE_STM32L4X5_SOC "stm32l4x5-soc"
49
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(Stm32l4x5SocState, Stm32l4x5SocClass, STM32L4X5_SOC)
50
51
#define NUM_EXTI_OR_GATES 4
52
53
+#define STM_NUM_USARTS 3
54
+#define STM_NUM_UARTS 2
55
+
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 },
37
};
83
};
38
84
39
-qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s)
85
+static const hwaddr usart_addr[] = {
40
-{
86
+ 0x40013800, /* "USART1", 0x400 */
41
- return s->gpio_in;
87
+ 0x40004400, /* "USART2", 0x400 */
42
-}
88
+ 0x40004800, /* "USART3", 0x400 */
43
-
89
+};
44
static void tc6393xb_gpio_set(void *opaque, int line, int level)
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)
45
{
102
{
46
// TC6393xbState *s = opaque;
103
Stm32l4x5SocState *s = STM32L4X5_SOC(obj);
47
@@ -XXX,XX +XXX,XX @@ static void tc6393xb_gpio_set(void *opaque, int line, int level)
104
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_initfn(Object *obj)
48
// FIXME: how does the chip reflect the GPIO input level change?
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);
49
}
120
}
50
121
51
-void tc6393xb_gpio_out_set(TC6393xbState *s, int line,
122
static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
52
- qemu_irq handler)
123
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
53
-{
124
sysbus_mmio_map(busdev, 0, RCC_BASE_ADDRESS);
54
- if (line >= TC6393XB_GPIOS) {
125
sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, RCC_IRQ));
55
- fprintf(stderr, "TC6393xb: no GPIO pin %d\n", line);
126
56
- return;
127
+ /* USART devices */
57
- }
128
+ for (int i = 0; i < STM_NUM_USARTS; i++) {
58
-
129
+ g_autofree char *name = g_strdup_printf("usart%d-out", i + 1);
59
- s->handler[line] = handler;
130
+ dev = DEVICE(&(s->usart[i]));
60
-}
131
+ qdev_prop_set_chr(dev, "chardev", serial_hd(i));
61
-
132
+ qdev_connect_clock_in(dev, "clk",
62
static void tc6393xb_gpio_handler_update(TC6393xbState *s)
133
+ qdev_get_clock_out(DEVICE(&(s->rcc)), name));
63
{
134
+ busdev = SYS_BUS_DEVICE(dev);
64
uint32_t level, diff;
135
+ if (!sysbus_realize(busdev, errp)) {
136
+ return;
137
+ }
138
+ sysbus_mmio_map(busdev, 0, usart_addr[i]);
139
+ sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, usart_irq[i]));
140
+ }
141
+
142
+ /*
143
+ * TODO: Connect the USARTs, UARTs and LPUART to the EXTI once the EXTI
144
+ * can handle other gpio-in than the gpios. (e.g. Direct Lines for the
145
+ * usarts)
146
+ */
147
+
148
+ /* UART devices */
149
+ for (int i = 0; i < STM_NUM_UARTS; i++) {
150
+ g_autofree char *name = g_strdup_printf("uart%d-out", STM_NUM_USARTS + i + 1);
151
+ dev = DEVICE(&(s->uart[i]));
152
+ qdev_prop_set_chr(dev, "chardev", serial_hd(STM_NUM_USARTS + i));
153
+ qdev_connect_clock_in(dev, "clk",
154
+ qdev_get_clock_out(DEVICE(&(s->rcc)), name));
155
+ busdev = SYS_BUS_DEVICE(dev);
156
+ if (!sysbus_realize(busdev, errp)) {
157
+ return;
158
+ }
159
+ sysbus_mmio_map(busdev, 0, uart_addr[i]);
160
+ sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, uart_irq[i]));
161
+ }
162
+
163
+ /* LPUART device*/
164
+ dev = DEVICE(&(s->lpuart));
165
+ qdev_prop_set_chr(dev, "chardev", serial_hd(STM_NUM_USARTS + STM_NUM_UARTS));
166
+ qdev_connect_clock_in(dev, "clk",
167
+ qdev_get_clock_out(DEVICE(&(s->rcc)), "lpuart1-out"));
168
+ busdev = SYS_BUS_DEVICE(dev);
169
+ if (!sysbus_realize(busdev, errp)) {
170
+ return;
171
+ }
172
+ sysbus_mmio_map(busdev, 0, LPUART_BASE_ADDRESS);
173
+ sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, LPUART_IRQ));
174
+
175
/* APB1 BUS */
176
create_unimplemented_device("TIM2", 0x40000000, 0x400);
177
create_unimplemented_device("TIM3", 0x40000400, 0x400);
178
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
179
create_unimplemented_device("SPI2", 0x40003800, 0x400);
180
create_unimplemented_device("SPI3", 0x40003C00, 0x400);
181
/* RESERVED: 0x40004000, 0x400 */
182
- create_unimplemented_device("USART2", 0x40004400, 0x400);
183
- create_unimplemented_device("USART3", 0x40004800, 0x400);
184
- create_unimplemented_device("UART4", 0x40004C00, 0x400);
185
- create_unimplemented_device("UART5", 0x40005000, 0x400);
186
create_unimplemented_device("I2C1", 0x40005400, 0x400);
187
create_unimplemented_device("I2C2", 0x40005800, 0x400);
188
create_unimplemented_device("I2C3", 0x40005C00, 0x400);
189
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
190
create_unimplemented_device("DAC1", 0x40007400, 0x400);
191
create_unimplemented_device("OPAMP", 0x40007800, 0x400);
192
create_unimplemented_device("LPTIM1", 0x40007C00, 0x400);
193
- create_unimplemented_device("LPUART1", 0x40008000, 0x400);
194
/* RESERVED: 0x40008400, 0x400 */
195
create_unimplemented_device("SWPMI1", 0x40008800, 0x400);
196
/* RESERVED: 0x40008C00, 0x800 */
197
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
198
create_unimplemented_device("TIM1", 0x40012C00, 0x400);
199
create_unimplemented_device("SPI1", 0x40013000, 0x400);
200
create_unimplemented_device("TIM8", 0x40013400, 0x400);
201
- create_unimplemented_device("USART1", 0x40013800, 0x400);
202
/* RESERVED: 0x40013C00, 0x400 */
203
create_unimplemented_device("TIM15", 0x40014000, 0x400);
204
create_unimplemented_device("TIM16", 0x40014400, 0x400);
205
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
206
index XXXXXXX..XXXXXXX 100644
207
--- a/hw/arm/Kconfig
208
+++ b/hw/arm/Kconfig
209
@@ -XXX,XX +XXX,XX @@ config STM32L4X5_SOC
210
select STM32L4X5_SYSCFG
211
select STM32L4X5_RCC
212
select STM32L4X5_GPIO
213
+ select STM32L4X5_USART
214
215
config XLNX_ZYNQMP_ARM
216
bool
65
--
217
--
66
2.20.1
218
2.34.1
67
219
68
220
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
Test:
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
- read/write from/to the usart registers
5
Message-id: 20190412165416.7977-5-philmd@redhat.com
5
- send/receive a character/string over the serial port
6
7
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
8
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
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]
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
13
---
8
include/hw/devices.h | 6 ------
14
tests/qtest/stm32l4x5_usart-test.c | 315 +++++++++++++++++++++++++++++
9
include/hw/display/tc6393xb.h | 24 ++++++++++++++++++++++++
15
tests/qtest/meson.build | 4 +-
10
hw/arm/tosa.c | 2 +-
16
2 files changed, 318 insertions(+), 1 deletion(-)
11
hw/display/tc6393xb.c | 2 +-
17
create mode 100644 tests/qtest/stm32l4x5_usart-test.c
12
MAINTAINERS | 1 +
18
13
5 files changed, 27 insertions(+), 8 deletions(-)
19
diff --git a/tests/qtest/stm32l4x5_usart-test.c b/tests/qtest/stm32l4x5_usart-test.c
14
create mode 100644 include/hw/display/tc6393xb.h
15
16
diff --git a/include/hw/devices.h b/include/hw/devices.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/devices.h
19
+++ b/include/hw/devices.h
20
@@ -XXX,XX +XXX,XX @@ void *tahvo_init(qemu_irq irq, int betty);
21
22
void retu_key_event(void *retu, int state);
23
24
-/* tc6393xb.c */
25
-typedef struct TC6393xbState TC6393xbState;
26
-TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
27
- uint32_t base, qemu_irq irq);
28
-qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
29
-
30
#endif
31
diff --git a/include/hw/display/tc6393xb.h b/include/hw/display/tc6393xb.h
32
new file mode 100644
20
new file mode 100644
33
index XXXXXXX..XXXXXXX
21
index XXXXXXX..XXXXXXX
34
--- /dev/null
22
--- /dev/null
35
+++ b/include/hw/display/tc6393xb.h
23
+++ b/tests/qtest/stm32l4x5_usart-test.c
36
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@
37
+/*
25
+/*
38
+ * Toshiba TC6393XB I/O Controller.
26
+ * QTest testcase for STML4X5_USART
39
+ * Found in Sharp Zaurus SL-6000 (tosa) or some
40
+ * Toshiba e-Series PDAs.
41
+ *
27
+ *
42
+ * Copyright (c) 2007 Hervé Poussineau
28
+ * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
29
+ * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
43
+ *
30
+ *
44
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
31
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
45
+ * See the COPYING file in the top-level directory.
32
+ * See the COPYING file in the top-level directory.
46
+ */
33
+ */
47
+
34
+
48
+#ifndef HW_DISPLAY_TC6393XB_H
35
+#include "qemu/osdep.h"
49
+#define HW_DISPLAY_TC6393XB_H
36
+#include "libqtest.h"
50
+
37
+#include "hw/misc/stm32l4x5_rcc_internals.h"
51
+#include "exec/memory.h"
38
+#include "hw/registerfields.h"
52
+#include "hw/irq.h"
39
+
53
+
40
+#define RCC_BASE_ADDR 0x40021000
54
+typedef struct TC6393xbState TC6393xbState;
41
+/* Use USART 1 ADDR, assume the others work the same */
55
+
42
+#define USART1_BASE_ADDR 0x40013800
56
+TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
43
+
57
+ uint32_t base, qemu_irq irq);
44
+/* See stm32l4x5_usart for definitions */
58
+qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
45
+REG32(CR1, 0x00)
59
+
46
+ FIELD(CR1, M1, 28, 1)
60
+#endif
47
+ FIELD(CR1, OVER8, 15, 1)
61
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
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
62
index XXXXXXX..XXXXXXX 100644
341
index XXXXXXX..XXXXXXX 100644
63
--- a/hw/arm/tosa.c
342
--- a/tests/qtest/meson.build
64
+++ b/hw/arm/tosa.c
343
+++ b/tests/qtest/meson.build
65
@@ -XXX,XX +XXX,XX @@
344
@@ -XXX,XX +XXX,XX @@ slow_qtests = {
66
#include "hw/hw.h"
345
'npcm7xx_pwm-test': 300,
67
#include "hw/arm/pxa.h"
346
'npcm7xx_watchdog_timer-test': 120,
68
#include "hw/arm/arm.h"
347
'qom-test' : 900,
69
-#include "hw/devices.h"
348
+ 'stm32l4x5_usart-test' : 600,
70
#include "hw/arm/sharpsl.h"
349
'test-hmp' : 240,
71
#include "hw/pcmcia.h"
350
'pxe-test': 610,
72
#include "hw/boards.h"
351
'prom-env-test': 360,
73
+#include "hw/display/tc6393xb.h"
352
@@ -XXX,XX +XXX,XX @@ qtests_stm32l4x5 = \
74
#include "hw/i2c/i2c.h"
353
['stm32l4x5_exti-test',
75
#include "hw/ssi/ssi.h"
354
'stm32l4x5_syscfg-test',
76
#include "hw/sysbus.h"
355
'stm32l4x5_rcc-test',
77
diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
356
- 'stm32l4x5_gpio-test']
78
index XXXXXXX..XXXXXXX 100644
357
+ 'stm32l4x5_gpio-test',
79
--- a/hw/display/tc6393xb.c
358
+ 'stm32l4x5_usart-test']
80
+++ b/hw/display/tc6393xb.c
359
81
@@ -XXX,XX +XXX,XX @@
360
qtests_arm = \
82
#include "qapi/error.h"
361
(config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \
83
#include "qemu/host-utils.h"
84
#include "hw/hw.h"
85
-#include "hw/devices.h"
86
+#include "hw/display/tc6393xb.h"
87
#include "hw/block/flash.h"
88
#include "ui/console.h"
89
#include "ui/pixel_ops.h"
90
diff --git a/MAINTAINERS b/MAINTAINERS
91
index XXXXXXX..XXXXXXX 100644
92
--- a/MAINTAINERS
93
+++ b/MAINTAINERS
94
@@ -XXX,XX +XXX,XX @@ F: hw/misc/mst_fpga.c
95
F: hw/misc/max111x.c
96
F: include/hw/arm/pxa.h
97
F: include/hw/arm/sharpsl.h
98
+F: include/hw/display/tc6393xb.h
99
100
SABRELITE / i.MX6
101
M: Peter Maydell <peter.maydell@linaro.org>
102
--
362
--
103
2.20.1
363
2.34.1
104
364
105
365
diff view generated by jsdifflib