1
Hi; here's the first arm pullreq for 9.1.
1
First arm pullreq of the cycle; this is mostly my softfloat NaN
2
2
handling series. (Lots more in my to-review queue, but I don't
3
This includes the reset method function signature change, so it has
3
like pullreqs growing too close to a hundred patches at a time :-))
4
some chance of compile failures due to merge conflicts if some other
5
pullreq added a device reset method and that pullreq got applied
6
before this one. If so, the changes needed to fix those up can be
7
created by running the spatch rune described in the commit message of
8
the "hw, target: Add ResetType argument to hold and exit phase
9
methods" commit.
10
4
11
thanks
5
thanks
12
-- PMM
6
-- PMM
13
7
14
The following changes since commit 5da72194df36535d773c8bdc951529ecd5e31707:
8
The following changes since commit 97f2796a3736ed37a1b85dc1c76a6c45b829dd17:
15
9
16
Merge tag 'pull-tcg-20240424' of https://gitlab.com/rth7680/qemu into staging (2024-04-24 15:51:49 -0700)
10
Open 10.0 development tree (2024-12-10 17:41:17 +0000)
17
11
18
are available in the Git repository at:
12
are available in the Git repository at:
19
13
20
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240425
14
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20241211
21
15
22
for you to fetch changes up to 214652da123e3821657a64691ee556281e9f6238:
16
for you to fetch changes up to 1abe28d519239eea5cf9620bb13149423e5665f8:
23
17
24
tests/qtest: Add tests for the STM32L4x5 USART (2024-04-25 10:21:59 +0100)
18
MAINTAINERS: Add correct email address for Vikram Garhwal (2024-12-11 15:31:09 +0000)
25
19
26
----------------------------------------------------------------
20
----------------------------------------------------------------
27
target-arm queue:
21
target-arm queue:
28
* Implement FEAT_NMI and NMI support in the GICv3
22
* hw/net/lan9118: Extract PHY model, reuse with imx_fec, fix bugs
29
* hw/dma: avoid apparent overflow in soc_dma_set_request
23
* fpu: Make muladd NaN handling runtime-selected, not compile-time
30
* linux-user/flatload.c: Remove unused bFLT shared-library and ZFLAT code
24
* fpu: Make default NaN pattern runtime-selected, not compile-time
31
* Add ResetType argument to Resettable hold and exit phase methods
25
* fpu: Minor NaN-related cleanups
32
* Add RESET_TYPE_SNAPSHOT_LOAD ResetType
26
* MAINTAINERS: email address updates
33
* Implement STM32L4x5 USART
34
27
35
----------------------------------------------------------------
28
----------------------------------------------------------------
36
Anastasia Belova (1):
29
Bernhard Beschow (5):
37
hw/dma: avoid apparent overflow in soc_dma_set_request
30
hw/net/lan9118: Extract lan9118_phy
31
hw/net/lan9118_phy: Reuse in imx_fec and consolidate implementations
32
hw/net/lan9118_phy: Fix off-by-one error in MII_ANLPAR register
33
hw/net/lan9118_phy: Reuse MII constants
34
hw/net/lan9118_phy: Add missing 100 mbps full duplex advertisement
38
35
39
Arnaud Minier (5):
36
Leif Lindholm (1):
40
hw/char: Implement STM32L4x5 USART skeleton
37
MAINTAINERS: update email address for Leif Lindholm
41
hw/char/stm32l4x5_usart: Enable serial read and write
42
hw/char/stm32l4x5_usart: Add options for serial parameters setting
43
hw/arm: Add the USART to the stm32l4x5 SoC
44
tests/qtest: Add tests for the STM32L4x5 USART
45
38
46
Jinjie Ruan (22):
39
Peter Maydell (54):
47
target/arm: Handle HCR_EL2 accesses for bits introduced with FEAT_NMI
40
fpu: handle raising Invalid for infzero in pick_nan_muladd
48
target/arm: Add PSTATE.ALLINT
41
fpu: Check for default_nan_mode before calling pickNaNMulAdd
49
target/arm: Add support for FEAT_NMI, Non-maskable Interrupt
42
softfloat: Allow runtime choice of inf * 0 + NaN result
50
target/arm: Implement ALLINT MSR (immediate)
43
tests/fp: Explicitly set inf-zero-nan rule
51
target/arm: Support MSR access to ALLINT
44
target/arm: Set FloatInfZeroNaNRule explicitly
52
target/arm: Add support for Non-maskable Interrupt
45
target/s390: Set FloatInfZeroNaNRule explicitly
53
target/arm: Add support for NMI in arm_phys_excp_target_el()
46
target/ppc: Set FloatInfZeroNaNRule explicitly
54
target/arm: Handle IS/FS in ISR_EL1 for NMI, VINMI and VFNMI
47
target/mips: Set FloatInfZeroNaNRule explicitly
55
target/arm: Handle PSTATE.ALLINT on taking an exception
48
target/sparc: Set FloatInfZeroNaNRule explicitly
56
hw/intc/arm_gicv3: Add external IRQ lines for NMI
49
target/xtensa: Set FloatInfZeroNaNRule explicitly
57
hw/arm/virt: Wire NMI and VINMI irq lines from GIC to CPU
50
target/x86: Set FloatInfZeroNaNRule explicitly
58
target/arm: Handle NMI in arm_cpu_do_interrupt_aarch64()
51
target/loongarch: Set FloatInfZeroNaNRule explicitly
59
hw/intc/arm_gicv3: Add has-nmi property to GICv3 device
52
target/hppa: Set FloatInfZeroNaNRule explicitly
60
hw/intc/arm_gicv3_kvm: Not set has-nmi=true for the KVM GICv3
53
softfloat: Pass have_snan to pickNaNMulAdd
61
hw/intc/arm_gicv3: Add irq non-maskable property
54
softfloat: Allow runtime choice of NaN propagation for muladd
62
hw/intc/arm_gicv3_redist: Implement GICR_INMIR0
55
tests/fp: Explicitly set 3-NaN propagation rule
63
hw/intc/arm_gicv3: Implement GICD_INMIR
56
target/arm: Set Float3NaNPropRule explicitly
64
hw/intc/arm_gicv3: Implement NMI interrupt priority
57
target/loongarch: Set Float3NaNPropRule explicitly
65
hw/intc/arm_gicv3: Report the NMI interrupt in gicv3_cpuif_update()
58
target/ppc: Set Float3NaNPropRule explicitly
66
hw/intc/arm_gicv3: Report the VINMI interrupt
59
target/s390x: Set Float3NaNPropRule explicitly
67
target/arm: Add FEAT_NMI to max
60
target/sparc: Set Float3NaNPropRule explicitly
68
hw/arm/virt: Enable NMI support in the GIC if the CPU has FEAT_NMI
61
target/mips: Set Float3NaNPropRule explicitly
62
target/xtensa: Set Float3NaNPropRule explicitly
63
target/i386: Set Float3NaNPropRule explicitly
64
target/hppa: Set Float3NaNPropRule explicitly
65
fpu: Remove use_first_nan field from float_status
66
target/m68k: Don't pass NULL float_status to floatx80_default_nan()
67
softfloat: Create floatx80 default NaN from parts64_default_nan
68
target/loongarch: Use normal float_status in fclass_s and fclass_d helpers
69
target/m68k: In frem helper, initialize local float_status from env->fp_status
70
target/m68k: Init local float_status from env fp_status in gdb get/set reg
71
target/sparc: Initialize local scratch float_status from env->fp_status
72
target/ppc: Use env->fp_status in helper_compute_fprf functions
73
fpu: Allow runtime choice of default NaN value
74
tests/fp: Set default NaN pattern explicitly
75
target/microblaze: Set default NaN pattern explicitly
76
target/i386: Set default NaN pattern explicitly
77
target/hppa: Set default NaN pattern explicitly
78
target/alpha: Set default NaN pattern explicitly
79
target/arm: Set default NaN pattern explicitly
80
target/loongarch: Set default NaN pattern explicitly
81
target/m68k: Set default NaN pattern explicitly
82
target/mips: Set default NaN pattern explicitly
83
target/openrisc: Set default NaN pattern explicitly
84
target/ppc: Set default NaN pattern explicitly
85
target/sh4: Set default NaN pattern explicitly
86
target/rx: Set default NaN pattern explicitly
87
target/s390x: Set default NaN pattern explicitly
88
target/sparc: Set default NaN pattern explicitly
89
target/xtensa: Set default NaN pattern explicitly
90
target/hexagon: Set default NaN pattern explicitly
91
target/riscv: Set default NaN pattern explicitly
92
target/tricore: Set default NaN pattern explicitly
93
fpu: Remove default handling for dnan_pattern
69
94
70
Peter Maydell (9):
95
Richard Henderson (11):
71
hw/intc/arm_gicv3: Add NMI handling CPU interface registers
96
target/arm: Copy entire float_status in is_ebf
72
hw/intc/arm_gicv3: Handle icv_nmiar1_read() for icc_nmiar1_read()
97
softfloat: Inline pickNaNMulAdd
73
linux-user/flatload.c: Remove unused bFLT shared-library and ZFLAT code
98
softfloat: Use goto for default nan case in pick_nan_muladd
74
hw/misc: Don't special case RESET_TYPE_COLD in npcm7xx_clk, gcr
99
softfloat: Remove which from parts_pick_nan_muladd
75
allwinner-i2c, adm1272: Use device_cold_reset() for software-triggered reset
100
softfloat: Pad array size in pick_nan_muladd
76
scripts/coccinelle: New script to add ResetType to hold and exit phases
101
softfloat: Move propagateFloatx80NaN to softfloat.c
77
hw, target: Add ResetType argument to hold and exit phase methods
102
softfloat: Use parts_pick_nan in propagateFloatx80NaN
78
docs/devel/reset: Update to new API for hold and exit phase methods
103
softfloat: Inline pickNaN
79
reset: Add RESET_TYPE_SNAPSHOT_LOAD
104
softfloat: Share code between parts_pick_nan cases
105
softfloat: Sink frac_cmp in parts_pick_nan until needed
106
softfloat: Replace WHICH with RET in parts_pick_nan
80
107
81
MAINTAINERS | 1 +
108
Vikram Garhwal (1):
82
docs/devel/reset.rst | 25 +-
109
MAINTAINERS: Add correct email address for Vikram Garhwal
83
docs/system/arm/b-l475e-iot01a.rst | 2 +-
110
84
docs/system/arm/emulation.rst | 1 +
111
MAINTAINERS | 4 +-
85
scripts/coccinelle/reset-type.cocci | 133 ++++++++
112
include/fpu/softfloat-helpers.h | 38 +++-
86
hw/intc/gicv3_internal.h | 13 +
113
include/fpu/softfloat-types.h | 89 +++++++-
87
include/hw/arm/stm32l4x5_soc.h | 7 +
114
include/hw/net/imx_fec.h | 9 +-
88
include/hw/char/stm32l4x5_usart.h | 67 ++++
115
include/hw/net/lan9118_phy.h | 37 ++++
89
include/hw/intc/arm_gic_common.h | 2 +
116
include/hw/net/mii.h | 6 +
90
include/hw/intc/arm_gicv3_common.h | 14 +
117
target/mips/fpu_helper.h | 20 ++
91
include/hw/resettable.h | 5 +-
118
target/sparc/helper.h | 4 +-
92
linux-user/flat.h | 5 +-
119
fpu/softfloat.c | 19 ++
93
target/arm/cpu-features.h | 5 +
120
hw/net/imx_fec.c | 146 ++------------
94
target/arm/cpu-qom.h | 5 +-
121
hw/net/lan9118.c | 137 ++-----------
95
target/arm/cpu.h | 9 +
122
hw/net/lan9118_phy.c | 222 ++++++++++++++++++++
96
target/arm/internals.h | 21 ++
123
linux-user/arm/nwfpe/fpa11.c | 5 +
97
target/arm/tcg/helper-a64.h | 1 +
124
target/alpha/cpu.c | 2 +
98
target/arm/tcg/a64.decode | 1 +
125
target/arm/cpu.c | 10 +
99
hw/adc/npcm7xx_adc.c | 2 +-
126
target/arm/tcg/vec_helper.c | 20 +-
100
hw/arm/pxa2xx_pic.c | 2 +-
127
target/hexagon/cpu.c | 2 +
101
hw/arm/smmu-common.c | 2 +-
128
target/hppa/fpu_helper.c | 12 ++
102
hw/arm/smmuv3.c | 4 +-
129
target/i386/tcg/fpu_helper.c | 12 ++
103
hw/arm/stellaris.c | 10 +-
130
target/loongarch/tcg/fpu_helper.c | 14 +-
104
hw/arm/stm32l4x5_soc.c | 83 ++++-
131
target/m68k/cpu.c | 14 +-
105
hw/arm/virt.c | 29 +-
132
target/m68k/fpu_helper.c | 6 +-
106
hw/audio/asc.c | 2 +-
133
target/m68k/helper.c | 6 +-
107
hw/char/cadence_uart.c | 2 +-
134
target/microblaze/cpu.c | 2 +
108
hw/char/sifive_uart.c | 2 +-
135
target/mips/msa.c | 10 +
109
hw/char/stm32l4x5_usart.c | 637 ++++++++++++++++++++++++++++++++++++
136
target/openrisc/cpu.c | 2 +
110
hw/core/cpu-common.c | 2 +-
137
target/ppc/cpu_init.c | 19 ++
111
hw/core/qdev.c | 4 +-
138
target/ppc/fpu_helper.c | 3 +-
112
hw/core/reset.c | 17 +-
139
target/riscv/cpu.c | 2 +
113
hw/core/resettable.c | 8 +-
140
target/rx/cpu.c | 2 +
114
hw/display/virtio-vga.c | 4 +-
141
target/s390x/cpu.c | 5 +
115
hw/dma/soc_dma.c | 4 +-
142
target/sh4/cpu.c | 2 +
116
hw/gpio/npcm7xx_gpio.c | 2 +-
143
target/sparc/cpu.c | 6 +
117
hw/gpio/pl061.c | 2 +-
144
target/sparc/fop_helper.c | 8 +-
118
hw/gpio/stm32l4x5_gpio.c | 2 +-
145
target/sparc/translate.c | 4 +-
119
hw/hyperv/vmbus.c | 2 +-
146
target/tricore/helper.c | 2 +
120
hw/i2c/allwinner-i2c.c | 5 +-
147
target/xtensa/cpu.c | 4 +
121
hw/i2c/npcm7xx_smbus.c | 2 +-
148
target/xtensa/fpu_helper.c | 3 +-
122
hw/input/adb.c | 2 +-
149
tests/fp/fp-bench.c | 7 +
123
hw/input/ps2.c | 12 +-
150
tests/fp/fp-test-log2.c | 1 +
124
hw/intc/arm_gic_common.c | 2 +-
151
tests/fp/fp-test.c | 7 +
125
hw/intc/arm_gic_kvm.c | 4 +-
152
fpu/softfloat-parts.c.inc | 152 +++++++++++---
126
hw/intc/arm_gicv3.c | 67 +++-
153
fpu/softfloat-specialize.c.inc | 412 ++------------------------------------
127
hw/intc/arm_gicv3_common.c | 50 ++-
154
.mailmap | 5 +-
128
hw/intc/arm_gicv3_cpuif.c | 268 ++++++++++++++-
155
hw/net/Kconfig | 5 +
129
hw/intc/arm_gicv3_dist.c | 36 ++
156
hw/net/meson.build | 1 +
130
hw/intc/arm_gicv3_its.c | 4 +-
157
hw/net/trace-events | 10 +-
131
hw/intc/arm_gicv3_its_common.c | 2 +-
158
47 files changed, 778 insertions(+), 730 deletions(-)
132
hw/intc/arm_gicv3_its_kvm.c | 4 +-
159
create mode 100644 include/hw/net/lan9118_phy.h
133
hw/intc/arm_gicv3_kvm.c | 9 +-
160
create mode 100644 hw/net/lan9118_phy.c
134
hw/intc/arm_gicv3_redist.c | 22 ++
135
hw/intc/xics.c | 2 +-
136
hw/m68k/q800-glue.c | 2 +-
137
hw/misc/djmemc.c | 2 +-
138
hw/misc/iosb.c | 2 +-
139
hw/misc/mac_via.c | 8 +-
140
hw/misc/macio/cuda.c | 4 +-
141
hw/misc/macio/pmu.c | 4 +-
142
hw/misc/mos6522.c | 2 +-
143
hw/misc/npcm7xx_clk.c | 13 +-
144
hw/misc/npcm7xx_gcr.c | 12 +-
145
hw/misc/npcm7xx_mft.c | 2 +-
146
hw/misc/npcm7xx_pwm.c | 2 +-
147
hw/misc/stm32l4x5_exti.c | 2 +-
148
hw/misc/stm32l4x5_rcc.c | 10 +-
149
hw/misc/stm32l4x5_syscfg.c | 2 +-
150
hw/misc/xlnx-versal-cframe-reg.c | 2 +-
151
hw/misc/xlnx-versal-crl.c | 2 +-
152
hw/misc/xlnx-versal-pmc-iou-slcr.c | 2 +-
153
hw/misc/xlnx-versal-trng.c | 2 +-
154
hw/misc/xlnx-versal-xramc.c | 2 +-
155
hw/misc/xlnx-zynqmp-apu-ctrl.c | 2 +-
156
hw/misc/xlnx-zynqmp-crf.c | 2 +-
157
hw/misc/zynq_slcr.c | 4 +-
158
hw/net/can/xlnx-zynqmp-can.c | 2 +-
159
hw/net/e1000.c | 2 +-
160
hw/net/e1000e.c | 2 +-
161
hw/net/igb.c | 2 +-
162
hw/net/igbvf.c | 2 +-
163
hw/nvram/xlnx-bbram.c | 2 +-
164
hw/nvram/xlnx-versal-efuse-ctrl.c | 2 +-
165
hw/nvram/xlnx-zynqmp-efuse.c | 2 +-
166
hw/pci-bridge/cxl_root_port.c | 4 +-
167
hw/pci-bridge/pcie_root_port.c | 2 +-
168
hw/pci-host/bonito.c | 2 +-
169
hw/pci-host/pnv_phb.c | 4 +-
170
hw/pci-host/pnv_phb3_msi.c | 4 +-
171
hw/pci/pci.c | 4 +-
172
hw/rtc/mc146818rtc.c | 2 +-
173
hw/s390x/css-bridge.c | 2 +-
174
hw/sensor/adm1266.c | 2 +-
175
hw/sensor/adm1272.c | 4 +-
176
hw/sensor/isl_pmbus_vr.c | 10 +-
177
hw/sensor/max31785.c | 2 +-
178
hw/sensor/max34451.c | 2 +-
179
hw/ssi/npcm7xx_fiu.c | 2 +-
180
hw/timer/etraxfs_timer.c | 2 +-
181
hw/timer/npcm7xx_timer.c | 2 +-
182
hw/usb/hcd-dwc2.c | 8 +-
183
hw/usb/xlnx-versal-usb2-ctrl-regs.c | 2 +-
184
hw/virtio/virtio-pci.c | 2 +-
185
linux-user/flatload.c | 293 +----------------
186
target/arm/cpu.c | 151 ++++++++-
187
target/arm/helper.c | 101 +++++-
188
target/arm/tcg/cpu64.c | 1 +
189
target/arm/tcg/helper-a64.c | 16 +-
190
target/arm/tcg/translate-a64.c | 19 ++
191
target/avr/cpu.c | 4 +-
192
target/cris/cpu.c | 4 +-
193
target/hexagon/cpu.c | 4 +-
194
target/i386/cpu.c | 4 +-
195
target/loongarch/cpu.c | 4 +-
196
target/m68k/cpu.c | 4 +-
197
target/microblaze/cpu.c | 4 +-
198
target/mips/cpu.c | 4 +-
199
target/openrisc/cpu.c | 4 +-
200
target/ppc/cpu_init.c | 4 +-
201
target/riscv/cpu.c | 4 +-
202
target/rx/cpu.c | 4 +-
203
target/sh4/cpu.c | 4 +-
204
target/sparc/cpu.c | 4 +-
205
target/tricore/cpu.c | 4 +-
206
target/xtensa/cpu.c | 4 +-
207
tests/qtest/stm32l4x5_usart-test.c | 315 ++++++++++++++++++
208
hw/arm/Kconfig | 1 +
209
hw/char/Kconfig | 3 +
210
hw/char/meson.build | 1 +
211
hw/char/trace-events | 12 +
212
hw/intc/trace-events | 2 +
213
tests/qtest/meson.build | 4 +-
214
133 files changed, 2239 insertions(+), 537 deletions(-)
215
create mode 100644 scripts/coccinelle/reset-type.cocci
216
create mode 100644 include/hw/char/stm32l4x5_usart.h
217
create mode 100644 hw/char/stm32l4x5_usart.c
218
create mode 100644 tests/qtest/stm32l4x5_usart-test.c
diff view generated by jsdifflib
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
1
From: Bernhard Beschow <shentey@gmail.com>
2
2
3
Add the basic infrastructure (register read/write, type...)
3
A very similar implementation of the same device exists in imx_fec. Prepare for
4
to implement the STM32L4x5 USART.
4
a common implementation by extracting a device model into its own files.
5
5
6
Also create different types for the USART, UART and LPUART
6
Some migration state has been moved into the new device model which breaks
7
of the STM32L4x5 to deduplicate code and enable the
7
migration compatibility for the following machines:
8
implementation of different behaviors depending on the type.
8
* smdkc210
9
* realview-*
10
* vexpress-*
11
* kzm
12
* mps2-*
9
13
10
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
14
While breaking migration ABI, fix the size of the MII registers to be 16 bit,
11
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
15
as defined by IEEE 802.3u.
16
17
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
18
Tested-by: Guenter Roeck <linux@roeck-us.net>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Message-id: 20240329174402.60382-2-arnaud.minier@telecom-paris.fr
20
Message-id: 20241102125724.532843-2-shentey@gmail.com
14
[PMM: update to new reset hold method signature;
15
fixed a few checkpatch nits]
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
22
---
18
MAINTAINERS | 1 +
23
include/hw/net/lan9118_phy.h | 37 ++++++++
19
include/hw/char/stm32l4x5_usart.h | 66 +++++
24
hw/net/lan9118.c | 137 +++++-----------------------
20
hw/char/stm32l4x5_usart.c | 396 ++++++++++++++++++++++++++++++
25
hw/net/lan9118_phy.c | 169 +++++++++++++++++++++++++++++++++++
21
hw/char/Kconfig | 3 +
26
hw/net/Kconfig | 4 +
22
hw/char/meson.build | 1 +
27
hw/net/meson.build | 1 +
23
hw/char/trace-events | 4 +
28
5 files changed, 233 insertions(+), 115 deletions(-)
24
6 files changed, 471 insertions(+)
29
create mode 100644 include/hw/net/lan9118_phy.h
25
create mode 100644 include/hw/char/stm32l4x5_usart.h
30
create mode 100644 hw/net/lan9118_phy.c
26
create mode 100644 hw/char/stm32l4x5_usart.c
27
31
28
diff --git a/MAINTAINERS b/MAINTAINERS
32
diff --git a/include/hw/net/lan9118_phy.h b/include/hw/net/lan9118_phy.h
29
index XXXXXXX..XXXXXXX 100644
30
--- a/MAINTAINERS
31
+++ b/MAINTAINERS
32
@@ -XXX,XX +XXX,XX @@ M: Inès Varhol <ines.varhol@telecom-paris.fr>
33
L: qemu-arm@nongnu.org
34
S: Maintained
35
F: hw/arm/stm32l4x5_soc.c
36
+F: hw/char/stm32l4x5_usart.c
37
F: hw/misc/stm32l4x5_exti.c
38
F: hw/misc/stm32l4x5_syscfg.c
39
F: hw/misc/stm32l4x5_rcc.c
40
diff --git a/include/hw/char/stm32l4x5_usart.h b/include/hw/char/stm32l4x5_usart.h
41
new file mode 100644
33
new file mode 100644
42
index XXXXXXX..XXXXXXX
34
index XXXXXXX..XXXXXXX
43
--- /dev/null
35
--- /dev/null
44
+++ b/include/hw/char/stm32l4x5_usart.h
36
+++ b/include/hw/net/lan9118_phy.h
45
@@ -XXX,XX +XXX,XX @@
37
@@ -XXX,XX +XXX,XX @@
46
+/*
38
+/*
47
+ * STM32L4X5 USART (Universal Synchronous Asynchronous Receiver Transmitter)
39
+ * SMSC LAN9118 PHY emulation
48
+ *
40
+ *
49
+ * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
41
+ * Copyright (c) 2009 CodeSourcery, LLC.
50
+ * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
42
+ * Written by Paul Brook
51
+ *
52
+ * SPDX-License-Identifier: GPL-2.0-or-later
53
+ *
43
+ *
54
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
44
+ * 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.
45
+ * 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.
61
+ */
46
+ */
62
+
47
+
63
+#ifndef HW_STM32L4X5_USART_H
48
+#ifndef HW_NET_LAN9118_PHY_H
64
+#define HW_STM32L4X5_USART_H
49
+#define HW_NET_LAN9118_PHY_H
65
+
50
+
51
+#include "qom/object.h"
66
+#include "hw/sysbus.h"
52
+#include "hw/sysbus.h"
67
+#include "chardev/char-fe.h"
53
+
68
+#include "qom/object.h"
54
+#define TYPE_LAN9118_PHY "lan9118-phy"
69
+
55
+OBJECT_DECLARE_SIMPLE_TYPE(Lan9118PhyState, LAN9118_PHY)
70
+#define TYPE_STM32L4X5_USART_BASE "stm32l4x5-usart-base"
56
+
71
+#define TYPE_STM32L4X5_USART "stm32l4x5-usart"
57
+typedef struct Lan9118PhyState {
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;
58
+ SysBusDevice parent_obj;
85
+
59
+
86
+ MemoryRegion mmio;
60
+ uint16_t status;
87
+
61
+ uint16_t control;
88
+ uint32_t cr1;
62
+ uint16_t advertise;
89
+ uint32_t cr2;
63
+ uint16_t ints;
90
+ uint32_t cr3;
64
+ uint16_t int_mask;
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;
65
+ qemu_irq irq;
103
+};
66
+ bool link_down;
104
+
67
+} Lan9118PhyState;
105
+struct Stm32l4x5UsartBaseClass {
68
+
106
+ SysBusDeviceClass parent_class;
69
+void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down);
107
+
70
+void lan9118_phy_reset(Lan9118PhyState *s);
108
+ Stm32l4x5UsartType type;
71
+uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg);
109
+};
72
+void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val);
110
+
73
+
111
+#endif /* HW_STM32L4X5_USART_H */
74
+#endif
112
diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c
75
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
76
index XXXXXXX..XXXXXXX 100644
77
--- a/hw/net/lan9118.c
78
+++ b/hw/net/lan9118.c
79
@@ -XXX,XX +XXX,XX @@
80
#include "net/net.h"
81
#include "net/eth.h"
82
#include "hw/irq.h"
83
+#include "hw/net/lan9118_phy.h"
84
#include "hw/net/lan9118.h"
85
#include "hw/ptimer.h"
86
#include "hw/qdev-properties.h"
87
@@ -XXX,XX +XXX,XX @@ do { printf("lan9118: " fmt , ## __VA_ARGS__); } while (0)
88
#define MAC_CR_RXEN 0x00000004
89
#define MAC_CR_RESERVED 0x7f404213
90
91
-#define PHY_INT_ENERGYON 0x80
92
-#define PHY_INT_AUTONEG_COMPLETE 0x40
93
-#define PHY_INT_FAULT 0x20
94
-#define PHY_INT_DOWN 0x10
95
-#define PHY_INT_AUTONEG_LP 0x08
96
-#define PHY_INT_PARFAULT 0x04
97
-#define PHY_INT_AUTONEG_PAGE 0x02
98
-
99
#define GPT_TIMER_EN 0x20000000
100
101
/*
102
@@ -XXX,XX +XXX,XX @@ struct lan9118_state {
103
uint32_t mac_mii_data;
104
uint32_t mac_flow;
105
106
- uint32_t phy_status;
107
- uint32_t phy_control;
108
- uint32_t phy_advertise;
109
- uint32_t phy_int;
110
- uint32_t phy_int_mask;
111
+ Lan9118PhyState mii;
112
+ IRQState mii_irq;
113
114
int32_t eeprom_writable;
115
uint8_t eeprom[128];
116
@@ -XXX,XX +XXX,XX @@ struct lan9118_state {
117
118
static const VMStateDescription vmstate_lan9118 = {
119
.name = "lan9118",
120
- .version_id = 2,
121
- .minimum_version_id = 1,
122
+ .version_id = 3,
123
+ .minimum_version_id = 3,
124
.fields = (const VMStateField[]) {
125
VMSTATE_PTIMER(timer, lan9118_state),
126
VMSTATE_UINT32(irq_cfg, lan9118_state),
127
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_lan9118 = {
128
VMSTATE_UINT32(mac_mii_acc, lan9118_state),
129
VMSTATE_UINT32(mac_mii_data, lan9118_state),
130
VMSTATE_UINT32(mac_flow, lan9118_state),
131
- VMSTATE_UINT32(phy_status, lan9118_state),
132
- VMSTATE_UINT32(phy_control, lan9118_state),
133
- VMSTATE_UINT32(phy_advertise, lan9118_state),
134
- VMSTATE_UINT32(phy_int, lan9118_state),
135
- VMSTATE_UINT32(phy_int_mask, lan9118_state),
136
VMSTATE_INT32(eeprom_writable, lan9118_state),
137
VMSTATE_UINT8_ARRAY(eeprom, lan9118_state, 128),
138
VMSTATE_INT32(tx_fifo_size, lan9118_state),
139
@@ -XXX,XX +XXX,XX @@ static void lan9118_reload_eeprom(lan9118_state *s)
140
lan9118_mac_changed(s);
141
}
142
143
-static void phy_update_irq(lan9118_state *s)
144
+static void lan9118_update_irq(void *opaque, int n, int level)
145
{
146
- if (s->phy_int & s->phy_int_mask) {
147
+ lan9118_state *s = opaque;
148
+
149
+ if (level) {
150
s->int_sts |= PHY_INT;
151
} else {
152
s->int_sts &= ~PHY_INT;
153
@@ -XXX,XX +XXX,XX @@ static void phy_update_irq(lan9118_state *s)
154
lan9118_update(s);
155
}
156
157
-static void phy_update_link(lan9118_state *s)
158
-{
159
- /* Autonegotiation status mirrors link status. */
160
- if (qemu_get_queue(s->nic)->link_down) {
161
- s->phy_status &= ~0x0024;
162
- s->phy_int |= PHY_INT_DOWN;
163
- } else {
164
- s->phy_status |= 0x0024;
165
- s->phy_int |= PHY_INT_ENERGYON;
166
- s->phy_int |= PHY_INT_AUTONEG_COMPLETE;
167
- }
168
- phy_update_irq(s);
169
-}
170
-
171
static void lan9118_set_link(NetClientState *nc)
172
{
173
- phy_update_link(qemu_get_nic_opaque(nc));
174
-}
175
-
176
-static void phy_reset(lan9118_state *s)
177
-{
178
- s->phy_status = 0x7809;
179
- s->phy_control = 0x3000;
180
- s->phy_advertise = 0x01e1;
181
- s->phy_int_mask = 0;
182
- s->phy_int = 0;
183
- phy_update_link(s);
184
+ lan9118_phy_update_link(&LAN9118(qemu_get_nic_opaque(nc))->mii,
185
+ nc->link_down);
186
}
187
188
static void lan9118_reset(DeviceState *d)
189
@@ -XXX,XX +XXX,XX @@ static void lan9118_reset(DeviceState *d)
190
s->read_word_n = 0;
191
s->write_word_n = 0;
192
193
- phy_reset(s);
194
-
195
s->eeprom_writable = 0;
196
lan9118_reload_eeprom(s);
197
}
198
@@ -XXX,XX +XXX,XX @@ static void do_tx_packet(lan9118_state *s)
199
uint32_t status;
200
201
/* FIXME: Honor TX disable, and allow queueing of packets. */
202
- if (s->phy_control & 0x4000) {
203
+ if (s->mii.control & 0x4000) {
204
/* This assumes the receive routine doesn't touch the VLANClient. */
205
qemu_receive_packet(qemu_get_queue(s->nic), s->txp->data, s->txp->len);
206
} else {
207
@@ -XXX,XX +XXX,XX @@ static void tx_fifo_push(lan9118_state *s, uint32_t val)
208
}
209
}
210
211
-static uint32_t do_phy_read(lan9118_state *s, int reg)
212
-{
213
- uint32_t val;
214
-
215
- switch (reg) {
216
- case 0: /* Basic Control */
217
- return s->phy_control;
218
- case 1: /* Basic Status */
219
- return s->phy_status;
220
- case 2: /* ID1 */
221
- return 0x0007;
222
- case 3: /* ID2 */
223
- return 0xc0d1;
224
- case 4: /* Auto-neg advertisement */
225
- return s->phy_advertise;
226
- case 5: /* Auto-neg Link Partner Ability */
227
- return 0x0f71;
228
- case 6: /* Auto-neg Expansion */
229
- return 1;
230
- /* TODO 17, 18, 27, 29, 30, 31 */
231
- case 29: /* Interrupt source. */
232
- val = s->phy_int;
233
- s->phy_int = 0;
234
- phy_update_irq(s);
235
- return val;
236
- case 30: /* Interrupt mask */
237
- return s->phy_int_mask;
238
- default:
239
- qemu_log_mask(LOG_GUEST_ERROR,
240
- "do_phy_read: PHY read reg %d\n", reg);
241
- return 0;
242
- }
243
-}
244
-
245
-static void do_phy_write(lan9118_state *s, int reg, uint32_t val)
246
-{
247
- switch (reg) {
248
- case 0: /* Basic Control */
249
- if (val & 0x8000) {
250
- phy_reset(s);
251
- break;
252
- }
253
- s->phy_control = val & 0x7980;
254
- /* Complete autonegotiation immediately. */
255
- if (val & 0x1000) {
256
- s->phy_status |= 0x0020;
257
- }
258
- break;
259
- case 4: /* Auto-neg advertisement */
260
- s->phy_advertise = (val & 0x2d7f) | 0x80;
261
- break;
262
- /* TODO 17, 18, 27, 31 */
263
- case 30: /* Interrupt mask */
264
- s->phy_int_mask = val & 0xff;
265
- phy_update_irq(s);
266
- break;
267
- default:
268
- qemu_log_mask(LOG_GUEST_ERROR,
269
- "do_phy_write: PHY write reg %d = 0x%04x\n", reg, val);
270
- }
271
-}
272
-
273
static void do_mac_write(lan9118_state *s, int reg, uint32_t val)
274
{
275
switch (reg) {
276
@@ -XXX,XX +XXX,XX @@ static void do_mac_write(lan9118_state *s, int reg, uint32_t val)
277
if (val & 2) {
278
DPRINTF("PHY write %d = 0x%04x\n",
279
(val >> 6) & 0x1f, s->mac_mii_data);
280
- do_phy_write(s, (val >> 6) & 0x1f, s->mac_mii_data);
281
+ lan9118_phy_write(&s->mii, (val >> 6) & 0x1f, s->mac_mii_data);
282
} else {
283
- s->mac_mii_data = do_phy_read(s, (val >> 6) & 0x1f);
284
+ s->mac_mii_data = lan9118_phy_read(&s->mii, (val >> 6) & 0x1f);
285
DPRINTF("PHY read %d = 0x%04x\n",
286
(val >> 6) & 0x1f, s->mac_mii_data);
287
}
288
@@ -XXX,XX +XXX,XX @@ static void lan9118_writel(void *opaque, hwaddr offset,
289
break;
290
case CSR_PMT_CTRL:
291
if (val & 0x400) {
292
- phy_reset(s);
293
+ lan9118_phy_reset(&s->mii);
294
}
295
s->pmt_ctrl &= ~0x34e;
296
s->pmt_ctrl |= (val & 0x34e);
297
@@ -XXX,XX +XXX,XX @@ static void lan9118_realize(DeviceState *dev, Error **errp)
298
const MemoryRegionOps *mem_ops =
299
s->mode_16bit ? &lan9118_16bit_mem_ops : &lan9118_mem_ops;
300
301
+ qemu_init_irq(&s->mii_irq, lan9118_update_irq, s, 0);
302
+ object_initialize_child(OBJECT(s), "mii", &s->mii, TYPE_LAN9118_PHY);
303
+ if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(&s->mii), errp)) {
304
+ return;
305
+ }
306
+ qdev_connect_gpio_out(DEVICE(&s->mii), 0, &s->mii_irq);
307
+
308
memory_region_init_io(&s->mmio, OBJECT(dev), mem_ops, s,
309
"lan9118-mmio", 0x100);
310
sysbus_init_mmio(sbd, &s->mmio);
311
diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c
113
new file mode 100644
312
new file mode 100644
114
index XXXXXXX..XXXXXXX
313
index XXXXXXX..XXXXXXX
115
--- /dev/null
314
--- /dev/null
116
+++ b/hw/char/stm32l4x5_usart.c
315
+++ b/hw/net/lan9118_phy.c
117
@@ -XXX,XX +XXX,XX @@
316
@@ -XXX,XX +XXX,XX @@
118
+/*
317
+/*
119
+ * STM32L4X5 USART (Universal Synchronous Asynchronous Receiver Transmitter)
318
+ * SMSC LAN9118 PHY emulation
120
+ *
319
+ *
121
+ * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
320
+ * Copyright (c) 2009 CodeSourcery, LLC.
122
+ * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
321
+ * Written by Paul Brook
123
+ *
322
+ *
124
+ * SPDX-License-Identifier: GPL-2.0-or-later
323
+ * This code is licensed under the GNU GPL v2
125
+ *
324
+ *
126
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
325
+ * Contributions after 2012-01-13 are licensed under the terms of the
127
+ * See the COPYING file in the top-level directory.
326
+ * GNU GPL, version 2 or (at your option) any later version.
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
+ */
327
+ */
134
+
328
+
135
+#include "qemu/osdep.h"
329
+#include "qemu/osdep.h"
330
+#include "hw/net/lan9118_phy.h"
331
+#include "hw/irq.h"
332
+#include "hw/resettable.h"
333
+#include "migration/vmstate.h"
136
+#include "qemu/log.h"
334
+#include "qemu/log.h"
137
+#include "qemu/module.h"
335
+
138
+#include "qapi/error.h"
336
+#define PHY_INT_ENERGYON (1 << 7)
139
+#include "chardev/char-fe.h"
337
+#define PHY_INT_AUTONEG_COMPLETE (1 << 6)
140
+#include "chardev/char-serial.h"
338
+#define PHY_INT_FAULT (1 << 5)
141
+#include "migration/vmstate.h"
339
+#define PHY_INT_DOWN (1 << 4)
142
+#include "hw/char/stm32l4x5_usart.h"
340
+#define PHY_INT_AUTONEG_LP (1 << 3)
143
+#include "hw/clock.h"
341
+#define PHY_INT_PARFAULT (1 << 2)
144
+#include "hw/irq.h"
342
+#define PHY_INT_AUTONEG_PAGE (1 << 1)
145
+#include "hw/qdev-clock.h"
343
+
146
+#include "hw/qdev-properties.h"
344
+static void lan9118_phy_update_irq(Lan9118PhyState *s)
147
+#include "hw/qdev-properties-system.h"
345
+{
148
+#include "hw/registerfields.h"
346
+ qemu_set_irq(s->irq, !!(s->ints & s->int_mask));
149
+#include "trace.h"
347
+}
150
+
348
+
151
+
349
+uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg)
152
+REG32(CR1, 0x00)
350
+{
153
+ FIELD(CR1, M1, 28, 1) /* Word length (part 2, see M0) */
351
+ uint16_t val;
154
+ FIELD(CR1, EOBIE, 27, 1) /* End of Block interrupt enable */
352
+
155
+ FIELD(CR1, RTOIE, 26, 1) /* Receiver timeout interrupt enable */
353
+ switch (reg) {
156
+ FIELD(CR1, DEAT, 21, 5) /* Driver Enable assertion time */
354
+ case 0: /* Basic Control */
157
+ FIELD(CR1, DEDT, 16, 5) /* Driver Enable de-assertion time */
355
+ return s->control;
158
+ FIELD(CR1, OVER8, 15, 1) /* Oversampling mode */
356
+ case 1: /* Basic Status */
159
+ FIELD(CR1, CMIE, 14, 1) /* Character match interrupt enable */
357
+ return s->status;
160
+ FIELD(CR1, MME, 13, 1) /* Mute mode enable */
358
+ case 2: /* ID1 */
161
+ FIELD(CR1, M0, 12, 1) /* Word length (part 1, see M1) */
359
+ return 0x0007;
162
+ FIELD(CR1, WAKE, 11, 1) /* Receiver wakeup method */
360
+ case 3: /* ID2 */
163
+ FIELD(CR1, PCE, 10, 1) /* Parity control enable */
361
+ return 0xc0d1;
164
+ FIELD(CR1, PS, 9, 1) /* Parity selection */
362
+ case 4: /* Auto-neg advertisement */
165
+ FIELD(CR1, PEIE, 8, 1) /* PE interrupt enable */
363
+ return s->advertise;
166
+ FIELD(CR1, TXEIE, 7, 1) /* TXE interrupt enable */
364
+ case 5: /* Auto-neg Link Partner Ability */
167
+ FIELD(CR1, TCIE, 6, 1) /* Transmission complete interrupt enable */
365
+ return 0x0f71;
168
+ FIELD(CR1, RXNEIE, 5, 1) /* RXNE interrupt enable */
366
+ case 6: /* Auto-neg Expansion */
169
+ FIELD(CR1, IDLEIE, 4, 1) /* IDLE interrupt enable */
367
+ return 1;
170
+ FIELD(CR1, TE, 3, 1) /* Transmitter enable */
368
+ /* TODO 17, 18, 27, 29, 30, 31 */
171
+ FIELD(CR1, RE, 2, 1) /* Receiver enable */
369
+ case 29: /* Interrupt source. */
172
+ FIELD(CR1, UESM, 1, 1) /* USART enable in Stop mode */
370
+ val = s->ints;
173
+ FIELD(CR1, UE, 0, 1) /* USART enable */
371
+ s->ints = 0;
174
+REG32(CR2, 0x04)
372
+ lan9118_phy_update_irq(s);
175
+ FIELD(CR2, ADD_1, 28, 4) /* ADD[7:4] */
373
+ return val;
176
+ FIELD(CR2, ADD_0, 24, 1) /* ADD[3:0] */
374
+ case 30: /* Interrupt mask */
177
+ FIELD(CR2, RTOEN, 23, 1) /* Receiver timeout enable */
375
+ return s->int_mask;
178
+ FIELD(CR2, ABRMOD, 21, 2) /* Auto baud rate mode */
376
+ default:
179
+ FIELD(CR2, ABREN, 20, 1) /* Auto baud rate enable */
377
+ qemu_log_mask(LOG_GUEST_ERROR,
180
+ FIELD(CR2, MSBFIRST, 19, 1) /* Most significant bit first */
378
+ "lan9118_phy_read: PHY read reg %d\n", reg);
181
+ FIELD(CR2, DATAINV, 18, 1) /* Binary data inversion */
379
+ return 0;
182
+ FIELD(CR2, TXINV, 17, 1) /* TX pin active level inversion */
380
+ }
183
+ FIELD(CR2, RXINV, 16, 1) /* RX pin active level inversion */
381
+}
184
+ FIELD(CR2, SWAP, 15, 1) /* Swap RX/TX pins */
382
+
185
+ FIELD(CR2, LINEN, 14, 1) /* LIN mode enable */
383
+void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val)
186
+ FIELD(CR2, STOP, 12, 2) /* STOP bits */
384
+{
187
+ FIELD(CR2, CLKEN, 11, 1) /* Clock enable */
385
+ switch (reg) {
188
+ FIELD(CR2, CPOL, 10, 1) /* Clock polarity */
386
+ case 0: /* Basic Control */
189
+ FIELD(CR2, CPHA, 9, 1) /* Clock phase */
387
+ if (val & 0x8000) {
190
+ FIELD(CR2, LBCL, 8, 1) /* Last bit clock pulse */
388
+ lan9118_phy_reset(s);
191
+ FIELD(CR2, LBDIE, 6, 1) /* LIN break detection interrupt enable */
389
+ break;
192
+ FIELD(CR2, LBDL, 5, 1) /* LIN break detection length */
390
+ }
193
+ FIELD(CR2, ADDM7, 4, 1) /* 7-bit / 4-bit Address Detection */
391
+ s->control = val & 0x7980;
194
+
392
+ /* Complete autonegotiation immediately. */
195
+REG32(CR3, 0x08)
393
+ if (val & 0x1000) {
196
+ /* TCBGTIE only on STM32L496xx/4A6xx devices */
394
+ s->status |= 0x0020;
197
+ FIELD(CR3, UCESM, 23, 1) /* USART Clock Enable in Stop Mode */
395
+ }
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;
396
+ break;
299
+ case A_CR2:
397
+ case 4: /* Auto-neg advertisement */
300
+ retvalue = s->cr2;
398
+ s->advertise = (val & 0x2d7f) | 0x80;
301
+ break;
399
+ break;
302
+ case A_CR3:
400
+ /* TODO 17, 18, 27, 31 */
303
+ retvalue = s->cr3;
401
+ case 30: /* Interrupt mask */
304
+ break;
402
+ s->int_mask = val & 0xff;
305
+ case A_BRR:
403
+ lan9118_phy_update_irq(s);
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;
404
+ break;
333
+ default:
405
+ default:
334
+ qemu_log_mask(LOG_GUEST_ERROR,
406
+ qemu_log_mask(LOG_GUEST_ERROR,
335
+ "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr);
407
+ "lan9118_phy_write: PHY write reg %d = 0x%04x\n", reg, val);
336
+ break;
337
+ }
408
+ }
338
+
409
+}
339
+ trace_stm32l4x5_usart_read(addr, retvalue);
410
+
340
+
411
+void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down)
341
+ return retvalue;
412
+{
342
+}
413
+ s->link_down = link_down;
343
+
414
+
344
+static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
415
+ /* Autonegotiation status mirrors link status. */
345
+ uint64_t val64, unsigned int size)
416
+ if (link_down) {
346
+{
417
+ s->status &= ~0x0024;
347
+ Stm32l4x5UsartBaseState *s = opaque;
418
+ s->ints |= PHY_INT_DOWN;
348
+ const uint32_t value = val64;
419
+ } else {
349
+
420
+ s->status |= 0x0024;
350
+ trace_stm32l4x5_usart_write(addr, value);
421
+ s->ints |= PHY_INT_ENERGYON;
351
+
422
+ s->ints |= PHY_INT_AUTONEG_COMPLETE;
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
+ }
423
+ }
392
+}
424
+ lan9118_phy_update_irq(s);
393
+
425
+}
394
+static const MemoryRegionOps stm32l4x5_usart_base_ops = {
426
+
395
+ .read = stm32l4x5_usart_base_read,
427
+void lan9118_phy_reset(Lan9118PhyState *s)
396
+ .write = stm32l4x5_usart_base_write,
428
+{
397
+ .endianness = DEVICE_NATIVE_ENDIAN,
429
+ s->control = 0x3000;
398
+ .valid = {
430
+ s->status = 0x7809;
399
+ .max_access_size = 4,
431
+ s->advertise = 0x01e1;
400
+ .min_access_size = 4,
432
+ s->int_mask = 0;
401
+ .unaligned = false
433
+ s->ints = 0;
402
+ },
434
+ lan9118_phy_update_link(s, s->link_down);
403
+ .impl = {
435
+}
404
+ .max_access_size = 4,
436
+
405
+ .min_access_size = 4,
437
+static void lan9118_phy_reset_hold(Object *obj, ResetType type)
406
+ .unaligned = false
438
+{
407
+ },
439
+ Lan9118PhyState *s = LAN9118_PHY(obj);
408
+};
440
+
409
+
441
+ lan9118_phy_reset(s);
410
+static Property stm32l4x5_usart_base_properties[] = {
442
+}
411
+ DEFINE_PROP_CHR("chardev", Stm32l4x5UsartBaseState, chr),
443
+
412
+ DEFINE_PROP_END_OF_LIST(),
444
+static void lan9118_phy_init(Object *obj)
413
+};
445
+{
414
+
446
+ Lan9118PhyState *s = LAN9118_PHY(obj);
415
+static void stm32l4x5_usart_base_init(Object *obj)
447
+
416
+{
448
+ qdev_init_gpio_out(DEVICE(s), &s->irq, 1);
417
+ Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj);
449
+}
418
+
450
+
419
+ sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq);
451
+static const VMStateDescription vmstate_lan9118_phy = {
420
+
452
+ .name = "lan9118-phy",
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,
453
+ .version_id = 1,
431
+ .minimum_version_id = 1,
454
+ .minimum_version_id = 1,
432
+ .fields = (VMStateField[]) {
455
+ .fields = (const VMStateField[]) {
433
+ VMSTATE_UINT32(cr1, Stm32l4x5UsartBaseState),
456
+ VMSTATE_UINT16(control, Lan9118PhyState),
434
+ VMSTATE_UINT32(cr2, Stm32l4x5UsartBaseState),
457
+ VMSTATE_UINT16(status, Lan9118PhyState),
435
+ VMSTATE_UINT32(cr3, Stm32l4x5UsartBaseState),
458
+ VMSTATE_UINT16(advertise, Lan9118PhyState),
436
+ VMSTATE_UINT32(brr, Stm32l4x5UsartBaseState),
459
+ VMSTATE_UINT16(ints, Lan9118PhyState),
437
+ VMSTATE_UINT32(gtpr, Stm32l4x5UsartBaseState),
460
+ VMSTATE_UINT16(int_mask, Lan9118PhyState),
438
+ VMSTATE_UINT32(rtor, Stm32l4x5UsartBaseState),
461
+ VMSTATE_BOOL(link_down, Lan9118PhyState),
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()
462
+ VMSTATE_END_OF_LIST()
444
+ }
463
+ }
445
+};
464
+};
446
+
465
+
447
+
466
+static void lan9118_phy_class_init(ObjectClass *klass, void *data)
448
+static void stm32l4x5_usart_base_realize(DeviceState *dev, Error **errp)
467
+{
449
+{
468
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
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);
469
+ DeviceClass *dc = DEVICE_CLASS(klass);
461
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
470
+
462
+
471
+ rc->phases.hold = lan9118_phy_reset_hold;
463
+ rc->phases.hold = stm32l4x5_usart_base_reset_hold;
472
+ dc->vmsd = &vmstate_lan9118_phy;
464
+ device_class_set_props(dc, stm32l4x5_usart_base_properties);
473
+}
465
+ dc->realize = stm32l4x5_usart_base_realize;
474
+
466
+ dc->vmsd = &vmstate_stm32l4x5_usart_base;
475
+static const TypeInfo types[] = {
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
+ {
476
+ {
492
+ .name = TYPE_STM32L4X5_USART_BASE,
477
+ .name = TYPE_LAN9118_PHY,
493
+ .parent = TYPE_SYS_BUS_DEVICE,
478
+ .parent = TYPE_SYS_BUS_DEVICE,
494
+ .instance_size = sizeof(Stm32l4x5UsartBaseState),
479
+ .instance_size = sizeof(Lan9118PhyState),
495
+ .instance_init = stm32l4x5_usart_base_init,
480
+ .instance_init = lan9118_phy_init,
496
+ .class_init = stm32l4x5_usart_base_class_init,
481
+ .class_init = lan9118_phy_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
+ }
482
+ }
511
+};
483
+};
512
+
484
+
513
+DEFINE_TYPES(stm32l4x5_usart_types)
485
+DEFINE_TYPES(types)
514
diff --git a/hw/char/Kconfig b/hw/char/Kconfig
486
diff --git a/hw/net/Kconfig b/hw/net/Kconfig
515
index XXXXXXX..XXXXXXX 100644
487
index XXXXXXX..XXXXXXX 100644
516
--- a/hw/char/Kconfig
488
--- a/hw/net/Kconfig
517
+++ b/hw/char/Kconfig
489
+++ b/hw/net/Kconfig
518
@@ -XXX,XX +XXX,XX @@ config VIRTIO_SERIAL
490
@@ -XXX,XX +XXX,XX @@ config VMXNET3_PCI
519
config STM32F2XX_USART
491
config SMC91C111
520
bool
492
bool
521
493
522
+config STM32L4X5_USART
494
+config LAN9118_PHY
523
+ bool
495
+ bool
524
+
496
+
525
config CMSDK_APB_UART
497
config LAN9118
526
bool
498
bool
527
499
+ select LAN9118_PHY
528
diff --git a/hw/char/meson.build b/hw/char/meson.build
500
select PTIMER
501
502
config NE2000_ISA
503
diff --git a/hw/net/meson.build b/hw/net/meson.build
529
index XXXXXXX..XXXXXXX 100644
504
index XXXXXXX..XXXXXXX 100644
530
--- a/hw/char/meson.build
505
--- a/hw/net/meson.build
531
+++ b/hw/char/meson.build
506
+++ b/hw/net/meson.build
532
@@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_RENESAS_SCI', if_true: files('renesas_sci.c'))
507
@@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_VMXNET3_PCI', if_true: files('vmxnet3.c'))
533
system_ss.add(when: 'CONFIG_SIFIVE_UART', if_true: files('sifive_uart.c'))
508
534
system_ss.add(when: 'CONFIG_SH_SCI', if_true: files('sh_serial.c'))
509
system_ss.add(when: 'CONFIG_SMC91C111', if_true: files('smc91c111.c'))
535
system_ss.add(when: 'CONFIG_STM32F2XX_USART', if_true: files('stm32f2xx_usart.c'))
510
system_ss.add(when: 'CONFIG_LAN9118', if_true: files('lan9118.c'))
536
+system_ss.add(when: 'CONFIG_STM32L4X5_USART', if_true: files('stm32l4x5_usart.c'))
511
+system_ss.add(when: 'CONFIG_LAN9118_PHY', if_true: files('lan9118_phy.c'))
537
system_ss.add(when: 'CONFIG_MCHP_PFSOC_MMUART', if_true: files('mchp_pfsoc_mmuart.c'))
512
system_ss.add(when: 'CONFIG_NE2000_ISA', if_true: files('ne2000-isa.c'))
538
system_ss.add(when: 'CONFIG_HTIF', if_true: files('riscv_htif.c'))
513
system_ss.add(when: 'CONFIG_OPENCORES_ETH', if_true: files('opencores_eth.c'))
539
system_ss.add(when: 'CONFIG_GOLDFISH_TTY', if_true: files('goldfish_tty.c'))
514
system_ss.add(when: 'CONFIG_XGMAC', if_true: files('xgmac.c'))
540
diff --git a/hw/char/trace-events b/hw/char/trace-events
541
index XXXXXXX..XXXXXXX 100644
542
--- a/hw/char/trace-events
543
+++ b/hw/char/trace-events
544
@@ -XXX,XX +XXX,XX @@ cadence_uart_baudrate(unsigned baudrate) "baudrate %u"
545
sh_serial_read(char *id, unsigned size, uint64_t offs, uint64_t val) " %s size %d offs 0x%02" PRIx64 " -> 0x%02" PRIx64
546
sh_serial_write(char *id, unsigned size, uint64_t offs, uint64_t val) "%s size %d offs 0x%02" PRIx64 " <- 0x%02" PRIx64
547
548
+# stm32l4x5_usart.c
549
+stm32l4x5_usart_read(uint64_t addr, uint32_t data) "USART: Read <0x%" PRIx64 "> -> 0x%" PRIx32 ""
550
+stm32l4x5_usart_write(uint64_t addr, uint32_t data) "USART: Write <0x%" PRIx64 "> <- 0x%" PRIx32 ""
551
+
552
# xen_console.c
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"
554
xen_console_disconnect(unsigned int idx) "idx %u"
555
--
515
--
556
2.34.1
516
2.34.1
557
558
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
From: Bernhard Beschow <shentey@gmail.com>
2
2
3
Support ALLINT msr access as follow:
3
imx_fec models the same PHY as lan9118_phy. The code is almost the same with
4
    mrs <xt>, ALLINT    // read allint
4
imx_fec having more logging and tracing. Merge these improvements into
5
    msr ALLINT, <xt>    // write allint with imm
5
lan9118_phy and reuse in imx_fec to fix the code duplication.
6
6
7
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
Some migration state how resides in the new device model which breaks migration
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
compatibility for the following machines:
9
* imx25-pdk
10
* sabrelite
11
* mcimx7d-sabre
12
* mcimx6ul-evk
13
14
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
15
Tested-by: Guenter Roeck <linux@roeck-us.net>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20240407081733.3231820-6-ruanjinjie@huawei.com
17
Message-id: 20241102125724.532843-3-shentey@gmail.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
19
---
13
target/arm/helper.c | 35 +++++++++++++++++++++++++++++++++++
20
include/hw/net/imx_fec.h | 9 ++-
14
1 file changed, 35 insertions(+)
21
hw/net/imx_fec.c | 146 ++++-----------------------------------
22
hw/net/lan9118_phy.c | 82 ++++++++++++++++------
23
hw/net/Kconfig | 1 +
24
hw/net/trace-events | 10 +--
25
5 files changed, 85 insertions(+), 163 deletions(-)
15
26
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
27
diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h
17
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper.c
29
--- a/include/hw/net/imx_fec.h
19
+++ b/target/arm/helper.c
30
+++ b/include/hw/net/imx_fec.h
20
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo rme_mte_reginfo[] = {
31
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(IMXFECState, IMX_FEC)
21
.opc0 = 1, .opc1 = 6, .crn = 7, .crm = 14, .opc2 = 5,
32
#define TYPE_IMX_ENET "imx.enet"
22
.access = PL3_W, .type = ARM_CP_NOP },
33
34
#include "hw/sysbus.h"
35
+#include "hw/net/lan9118_phy.h"
36
+#include "hw/irq.h"
37
#include "net/net.h"
38
39
#define ENET_EIR 1
40
@@ -XXX,XX +XXX,XX @@ struct IMXFECState {
41
uint32_t tx_descriptor[ENET_TX_RING_NUM];
42
uint32_t tx_ring_num;
43
44
- uint32_t phy_status;
45
- uint32_t phy_control;
46
- uint32_t phy_advertise;
47
- uint32_t phy_int;
48
- uint32_t phy_int_mask;
49
+ Lan9118PhyState mii;
50
+ IRQState mii_irq;
51
uint32_t phy_num;
52
bool phy_connected;
53
struct IMXFECState *phy_consumer;
54
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/hw/net/imx_fec.c
57
+++ b/hw/net/imx_fec.c
58
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_eth_txdescs = {
59
60
static const VMStateDescription vmstate_imx_eth = {
61
.name = TYPE_IMX_FEC,
62
- .version_id = 2,
63
- .minimum_version_id = 2,
64
+ .version_id = 3,
65
+ .minimum_version_id = 3,
66
.fields = (const VMStateField[]) {
67
VMSTATE_UINT32_ARRAY(regs, IMXFECState, ENET_MAX),
68
VMSTATE_UINT32(rx_descriptor, IMXFECState),
69
VMSTATE_UINT32(tx_descriptor[0], IMXFECState),
70
- VMSTATE_UINT32(phy_status, IMXFECState),
71
- VMSTATE_UINT32(phy_control, IMXFECState),
72
- VMSTATE_UINT32(phy_advertise, IMXFECState),
73
- VMSTATE_UINT32(phy_int, IMXFECState),
74
- VMSTATE_UINT32(phy_int_mask, IMXFECState),
75
VMSTATE_END_OF_LIST()
76
},
77
.subsections = (const VMStateDescription * const []) {
78
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_eth = {
79
},
23
};
80
};
24
+
81
25
+static void aa64_allint_write(CPUARMState *env, const ARMCPRegInfo *ri,
82
-#define PHY_INT_ENERGYON (1 << 7)
26
+ uint64_t value)
83
-#define PHY_INT_AUTONEG_COMPLETE (1 << 6)
27
+{
84
-#define PHY_INT_FAULT (1 << 5)
28
+ env->pstate = (env->pstate & ~PSTATE_ALLINT) | (value & PSTATE_ALLINT);
85
-#define PHY_INT_DOWN (1 << 4)
29
+}
86
-#define PHY_INT_AUTONEG_LP (1 << 3)
30
+
87
-#define PHY_INT_PARFAULT (1 << 2)
31
+static uint64_t aa64_allint_read(CPUARMState *env, const ARMCPRegInfo *ri)
88
-#define PHY_INT_AUTONEG_PAGE (1 << 1)
32
+{
89
-
33
+ return env->pstate & PSTATE_ALLINT;
90
static void imx_eth_update(IMXFECState *s);
34
+}
91
35
+
92
/*
36
+static CPAccessResult aa64_allint_access(CPUARMState *env,
93
@@ -XXX,XX +XXX,XX @@ static void imx_eth_update(IMXFECState *s);
37
+ const ARMCPRegInfo *ri, bool isread)
94
* For now we don't handle any GPIO/interrupt line, so the OS will
38
+{
95
* have to poll for the PHY status.
39
+ if (!isread && arm_current_el(env) == 1 &&
96
*/
40
+ (arm_hcrx_el2_eff(env) & HCRX_TALLINT)) {
97
-static void imx_phy_update_irq(IMXFECState *s)
41
+ return CP_ACCESS_TRAP_EL2;
98
+static void imx_phy_update_irq(void *opaque, int n, int level)
99
{
100
- imx_eth_update(s);
101
-}
102
-
103
-static void imx_phy_update_link(IMXFECState *s)
104
-{
105
- /* Autonegotiation status mirrors link status. */
106
- if (qemu_get_queue(s->nic)->link_down) {
107
- trace_imx_phy_update_link("down");
108
- s->phy_status &= ~0x0024;
109
- s->phy_int |= PHY_INT_DOWN;
110
- } else {
111
- trace_imx_phy_update_link("up");
112
- s->phy_status |= 0x0024;
113
- s->phy_int |= PHY_INT_ENERGYON;
114
- s->phy_int |= PHY_INT_AUTONEG_COMPLETE;
115
- }
116
- imx_phy_update_irq(s);
117
+ imx_eth_update(opaque);
118
}
119
120
static void imx_eth_set_link(NetClientState *nc)
121
{
122
- imx_phy_update_link(IMX_FEC(qemu_get_nic_opaque(nc)));
123
-}
124
-
125
-static void imx_phy_reset(IMXFECState *s)
126
-{
127
- trace_imx_phy_reset();
128
-
129
- s->phy_status = 0x7809;
130
- s->phy_control = 0x3000;
131
- s->phy_advertise = 0x01e1;
132
- s->phy_int_mask = 0;
133
- s->phy_int = 0;
134
- imx_phy_update_link(s);
135
+ lan9118_phy_update_link(&IMX_FEC(qemu_get_nic_opaque(nc))->mii,
136
+ nc->link_down);
137
}
138
139
static uint32_t imx_phy_read(IMXFECState *s, int reg)
140
{
141
- uint32_t val;
142
uint32_t phy = reg / 32;
143
144
if (!s->phy_connected) {
145
@@ -XXX,XX +XXX,XX @@ static uint32_t imx_phy_read(IMXFECState *s, int reg)
146
147
reg %= 32;
148
149
- switch (reg) {
150
- case 0: /* Basic Control */
151
- val = s->phy_control;
152
- break;
153
- case 1: /* Basic Status */
154
- val = s->phy_status;
155
- break;
156
- case 2: /* ID1 */
157
- val = 0x0007;
158
- break;
159
- case 3: /* ID2 */
160
- val = 0xc0d1;
161
- break;
162
- case 4: /* Auto-neg advertisement */
163
- val = s->phy_advertise;
164
- break;
165
- case 5: /* Auto-neg Link Partner Ability */
166
- val = 0x0f71;
167
- break;
168
- case 6: /* Auto-neg Expansion */
169
- val = 1;
170
- break;
171
- case 29: /* Interrupt source. */
172
- val = s->phy_int;
173
- s->phy_int = 0;
174
- imx_phy_update_irq(s);
175
- break;
176
- case 30: /* Interrupt mask */
177
- val = s->phy_int_mask;
178
- break;
179
- case 17:
180
- case 18:
181
- case 27:
182
- case 31:
183
- qemu_log_mask(LOG_UNIMP, "[%s.phy]%s: reg %d not implemented\n",
184
- TYPE_IMX_FEC, __func__, reg);
185
- val = 0;
186
- break;
187
- default:
188
- qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad address at offset %d\n",
189
- TYPE_IMX_FEC, __func__, reg);
190
- val = 0;
191
- break;
192
- }
193
-
194
- trace_imx_phy_read(val, phy, reg);
195
-
196
- return val;
197
+ return lan9118_phy_read(&s->mii, reg);
198
}
199
200
static void imx_phy_write(IMXFECState *s, int reg, uint32_t val)
201
@@ -XXX,XX +XXX,XX @@ static void imx_phy_write(IMXFECState *s, int reg, uint32_t val)
202
203
reg %= 32;
204
205
- trace_imx_phy_write(val, phy, reg);
206
-
207
- switch (reg) {
208
- case 0: /* Basic Control */
209
- if (val & 0x8000) {
210
- imx_phy_reset(s);
211
- } else {
212
- s->phy_control = val & 0x7980;
213
- /* Complete autonegotiation immediately. */
214
- if (val & 0x1000) {
215
- s->phy_status |= 0x0020;
216
- }
217
- }
218
- break;
219
- case 4: /* Auto-neg advertisement */
220
- s->phy_advertise = (val & 0x2d7f) | 0x80;
221
- break;
222
- case 30: /* Interrupt mask */
223
- s->phy_int_mask = val & 0xff;
224
- imx_phy_update_irq(s);
225
- break;
226
- case 17:
227
- case 18:
228
- case 27:
229
- case 31:
230
- qemu_log_mask(LOG_UNIMP, "[%s.phy)%s: reg %d not implemented\n",
231
- TYPE_IMX_FEC, __func__, reg);
232
- break;
233
- default:
234
- qemu_log_mask(LOG_GUEST_ERROR, "[%s.phy]%s: Bad address at offset %d\n",
235
- TYPE_IMX_FEC, __func__, reg);
236
- break;
237
- }
238
+ lan9118_phy_write(&s->mii, reg, val);
239
}
240
241
static void imx_fec_read_bd(IMXFECBufDesc *bd, dma_addr_t addr)
242
@@ -XXX,XX +XXX,XX @@ static void imx_eth_reset(DeviceState *d)
243
244
s->rx_descriptor = 0;
245
memset(s->tx_descriptor, 0, sizeof(s->tx_descriptor));
246
-
247
- /* We also reset the PHY */
248
- imx_phy_reset(s);
249
}
250
251
static uint32_t imx_default_read(IMXFECState *s, uint32_t index)
252
@@ -XXX,XX +XXX,XX @@ static void imx_eth_realize(DeviceState *dev, Error **errp)
253
sysbus_init_irq(sbd, &s->irq[0]);
254
sysbus_init_irq(sbd, &s->irq[1]);
255
256
+ qemu_init_irq(&s->mii_irq, imx_phy_update_irq, s, 0);
257
+ object_initialize_child(OBJECT(s), "mii", &s->mii, TYPE_LAN9118_PHY);
258
+ if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(&s->mii), errp)) {
259
+ return;
42
+ }
260
+ }
43
+ return CP_ACCESS_OK;
261
+ qdev_connect_gpio_out(DEVICE(&s->mii), 0, &s->mii_irq);
44
+}
262
+
45
+
263
qemu_macaddr_default_if_unset(&s->conf.macaddr);
46
+static const ARMCPRegInfo nmi_reginfo[] = {
264
47
+ { .name = "ALLINT", .state = ARM_CP_STATE_AA64,
265
s->nic = qemu_new_nic(&imx_eth_net_info, &s->conf,
48
+ .opc0 = 3, .opc1 = 0, .opc2 = 0, .crn = 4, .crm = 3,
266
diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c
49
+ .type = ARM_CP_NO_RAW,
267
index XXXXXXX..XXXXXXX 100644
50
+ .access = PL1_RW, .accessfn = aa64_allint_access,
268
--- a/hw/net/lan9118_phy.c
51
+ .fieldoffset = offsetof(CPUARMState, pstate),
269
+++ b/hw/net/lan9118_phy.c
52
+ .writefn = aa64_allint_write, .readfn = aa64_allint_read,
270
@@ -XXX,XX +XXX,XX @@
53
+ .resetfn = arm_cp_reset_ignore },
271
* Copyright (c) 2009 CodeSourcery, LLC.
54
+};
272
* Written by Paul Brook
55
#endif /* TARGET_AARCH64 */
273
*
56
274
+ * Copyright (c) 2013 Jean-Christophe Dubois. <jcd@tribudubois.net>
57
static void define_pmu_regs(ARMCPU *cpu)
275
+ *
58
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
276
* This code is licensed under the GNU GPL v2
59
if (cpu_isar_feature(aa64_nv2, cpu)) {
277
*
60
define_arm_cp_regs(cpu, nv2_reginfo);
278
* Contributions after 2012-01-13 are licensed under the terms of the
279
@@ -XXX,XX +XXX,XX @@
280
#include "hw/resettable.h"
281
#include "migration/vmstate.h"
282
#include "qemu/log.h"
283
+#include "trace.h"
284
285
#define PHY_INT_ENERGYON (1 << 7)
286
#define PHY_INT_AUTONEG_COMPLETE (1 << 6)
287
@@ -XXX,XX +XXX,XX @@ uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg)
288
289
switch (reg) {
290
case 0: /* Basic Control */
291
- return s->control;
292
+ val = s->control;
293
+ break;
294
case 1: /* Basic Status */
295
- return s->status;
296
+ val = s->status;
297
+ break;
298
case 2: /* ID1 */
299
- return 0x0007;
300
+ val = 0x0007;
301
+ break;
302
case 3: /* ID2 */
303
- return 0xc0d1;
304
+ val = 0xc0d1;
305
+ break;
306
case 4: /* Auto-neg advertisement */
307
- return s->advertise;
308
+ val = s->advertise;
309
+ break;
310
case 5: /* Auto-neg Link Partner Ability */
311
- return 0x0f71;
312
+ val = 0x0f71;
313
+ break;
314
case 6: /* Auto-neg Expansion */
315
- return 1;
316
- /* TODO 17, 18, 27, 29, 30, 31 */
317
+ val = 1;
318
+ break;
319
case 29: /* Interrupt source. */
320
val = s->ints;
321
s->ints = 0;
322
lan9118_phy_update_irq(s);
323
- return val;
324
+ break;
325
case 30: /* Interrupt mask */
326
- return s->int_mask;
327
+ val = s->int_mask;
328
+ break;
329
+ case 17:
330
+ case 18:
331
+ case 27:
332
+ case 31:
333
+ qemu_log_mask(LOG_UNIMP, "%s: reg %d not implemented\n",
334
+ __func__, reg);
335
+ val = 0;
336
+ break;
337
default:
338
- qemu_log_mask(LOG_GUEST_ERROR,
339
- "lan9118_phy_read: PHY read reg %d\n", reg);
340
- return 0;
341
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address at offset %d\n",
342
+ __func__, reg);
343
+ val = 0;
344
+ break;
61
}
345
}
62
+
346
+
63
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
347
+ trace_lan9118_phy_read(val, reg);
64
+ define_arm_cp_regs(cpu, nmi_reginfo);
348
+
65
+ }
349
+ return val;
66
#endif
350
}
67
351
68
if (cpu_isar_feature(any_predinv, cpu)) {
352
void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val)
353
{
354
+ trace_lan9118_phy_write(val, reg);
355
+
356
switch (reg) {
357
case 0: /* Basic Control */
358
if (val & 0x8000) {
359
lan9118_phy_reset(s);
360
- break;
361
- }
362
- s->control = val & 0x7980;
363
- /* Complete autonegotiation immediately. */
364
- if (val & 0x1000) {
365
- s->status |= 0x0020;
366
+ } else {
367
+ s->control = val & 0x7980;
368
+ /* Complete autonegotiation immediately. */
369
+ if (val & 0x1000) {
370
+ s->status |= 0x0020;
371
+ }
372
}
373
break;
374
case 4: /* Auto-neg advertisement */
375
s->advertise = (val & 0x2d7f) | 0x80;
376
break;
377
- /* TODO 17, 18, 27, 31 */
378
case 30: /* Interrupt mask */
379
s->int_mask = val & 0xff;
380
lan9118_phy_update_irq(s);
381
break;
382
+ case 17:
383
+ case 18:
384
+ case 27:
385
+ case 31:
386
+ qemu_log_mask(LOG_UNIMP, "%s: reg %d not implemented\n",
387
+ __func__, reg);
388
+ break;
389
default:
390
- qemu_log_mask(LOG_GUEST_ERROR,
391
- "lan9118_phy_write: PHY write reg %d = 0x%04x\n", reg, val);
392
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad address at offset %d\n",
393
+ __func__, reg);
394
+ break;
395
}
396
}
397
398
@@ -XXX,XX +XXX,XX @@ void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down)
399
400
/* Autonegotiation status mirrors link status. */
401
if (link_down) {
402
+ trace_lan9118_phy_update_link("down");
403
s->status &= ~0x0024;
404
s->ints |= PHY_INT_DOWN;
405
} else {
406
+ trace_lan9118_phy_update_link("up");
407
s->status |= 0x0024;
408
s->ints |= PHY_INT_ENERGYON;
409
s->ints |= PHY_INT_AUTONEG_COMPLETE;
410
@@ -XXX,XX +XXX,XX @@ void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down)
411
412
void lan9118_phy_reset(Lan9118PhyState *s)
413
{
414
+ trace_lan9118_phy_reset();
415
+
416
s->control = 0x3000;
417
s->status = 0x7809;
418
s->advertise = 0x01e1;
419
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_lan9118_phy = {
420
.version_id = 1,
421
.minimum_version_id = 1,
422
.fields = (const VMStateField[]) {
423
- VMSTATE_UINT16(control, Lan9118PhyState),
424
VMSTATE_UINT16(status, Lan9118PhyState),
425
+ VMSTATE_UINT16(control, Lan9118PhyState),
426
VMSTATE_UINT16(advertise, Lan9118PhyState),
427
VMSTATE_UINT16(ints, Lan9118PhyState),
428
VMSTATE_UINT16(int_mask, Lan9118PhyState),
429
diff --git a/hw/net/Kconfig b/hw/net/Kconfig
430
index XXXXXXX..XXXXXXX 100644
431
--- a/hw/net/Kconfig
432
+++ b/hw/net/Kconfig
433
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_SUN8I_EMAC
434
435
config IMX_FEC
436
bool
437
+ select LAN9118_PHY
438
439
config CADENCE
440
bool
441
diff --git a/hw/net/trace-events b/hw/net/trace-events
442
index XXXXXXX..XXXXXXX 100644
443
--- a/hw/net/trace-events
444
+++ b/hw/net/trace-events
445
@@ -XXX,XX +XXX,XX @@ allwinner_sun8i_emac_set_link(bool active) "Set link: active=%u"
446
allwinner_sun8i_emac_read(uint64_t offset, uint64_t val) "MMIO read: offset=0x%" PRIx64 " value=0x%" PRIx64
447
allwinner_sun8i_emac_write(uint64_t offset, uint64_t val) "MMIO write: offset=0x%" PRIx64 " value=0x%" PRIx64
448
449
+# lan9118_phy.c
450
+lan9118_phy_read(uint16_t val, int reg) "[0x%02x] -> 0x%04" PRIx16
451
+lan9118_phy_write(uint16_t val, int reg) "[0x%02x] <- 0x%04" PRIx16
452
+lan9118_phy_update_link(const char *s) "%s"
453
+lan9118_phy_reset(void) ""
454
+
455
# lance.c
456
lance_mem_readw(uint64_t addr, uint32_t ret) "addr=0x%"PRIx64"val=0x%04x"
457
lance_mem_writew(uint64_t addr, uint32_t val) "addr=0x%"PRIx64"val=0x%04x"
458
@@ -XXX,XX +XXX,XX @@ i82596_set_multicast(uint16_t count) "Added %d multicast entries"
459
i82596_channel_attention(void *s) "%p: Received CHANNEL ATTENTION"
460
461
# imx_fec.c
462
-imx_phy_read(uint32_t val, int phy, int reg) "0x%04"PRIx32" <= phy[%d].reg[%d]"
463
imx_phy_read_num(int phy, int configured) "read request from unconfigured phy %d (configured %d)"
464
-imx_phy_write(uint32_t val, int phy, int reg) "0x%04"PRIx32" => phy[%d].reg[%d]"
465
imx_phy_write_num(int phy, int configured) "write request to unconfigured phy %d (configured %d)"
466
-imx_phy_update_link(const char *s) "%s"
467
-imx_phy_reset(void) ""
468
imx_fec_read_bd(uint64_t addr, int flags, int len, int data) "tx_bd 0x%"PRIx64" flags 0x%04x len %d data 0x%08x"
469
imx_enet_read_bd(uint64_t addr, int flags, int len, int data, int options, int status) "tx_bd 0x%"PRIx64" flags 0x%04x len %d data 0x%08x option 0x%04x status 0x%04x"
470
imx_eth_tx_bd_busy(void) "tx_bd ran out of descriptors to transmit"
69
--
471
--
70
2.34.1
472
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
From: Bernhard Beschow <shentey@gmail.com>
2
2
3
A SPI, PPI or SGI interrupt can have non-maskable property. So maintain
3
Turns 0x70 into 0xe0 (== 0x70 << 1) which adds the missing MII_ANLPAR_TX and
4
non-maskable property in PendingIrq and GICR/GICD. Since add new device
4
fixes the MSB of selector field to be zero, as specified in the datasheet.
5
state, it also needs to be migrated, so also save NMI info in
6
vmstate_gicv3_cpu and vmstate_gicv3.
7
5
8
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Fixes: 2a424990170b "LAN9118 emulation"
9
Acked-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
8
Tested-by: Guenter Roeck <linux@roeck-us.net>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20240407081733.3231820-16-ruanjinjie@huawei.com
10
Message-id: 20241102125724.532843-4-shentey@gmail.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
12
---
14
include/hw/intc/arm_gicv3_common.h | 4 ++++
13
hw/net/lan9118_phy.c | 2 +-
15
hw/intc/arm_gicv3_common.c | 38 ++++++++++++++++++++++++++++++
14
1 file changed, 1 insertion(+), 1 deletion(-)
16
2 files changed, 42 insertions(+)
17
15
18
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
16
diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c
19
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/intc/arm_gicv3_common.h
18
--- a/hw/net/lan9118_phy.c
21
+++ b/include/hw/intc/arm_gicv3_common.h
19
+++ b/hw/net/lan9118_phy.c
22
@@ -XXX,XX +XXX,XX @@ typedef struct {
20
@@ -XXX,XX +XXX,XX @@ uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg)
23
int irq;
21
val = s->advertise;
24
uint8_t prio;
22
break;
25
int grp;
23
case 5: /* Auto-neg Link Partner Ability */
26
+ bool nmi;
24
- val = 0x0f71;
27
} PendingIrq;
25
+ val = 0x0fe1;
28
26
break;
29
struct GICv3CPUState {
27
case 6: /* Auto-neg Expansion */
30
@@ -XXX,XX +XXX,XX @@ struct GICv3CPUState {
28
val = 1;
31
uint32_t gicr_ienabler0;
32
uint32_t gicr_ipendr0;
33
uint32_t gicr_iactiver0;
34
+ uint32_t gicr_inmir0;
35
uint32_t edge_trigger; /* ICFGR0 and ICFGR1 even bits */
36
uint32_t gicr_igrpmodr0;
37
uint32_t gicr_nsacr;
38
@@ -XXX,XX +XXX,XX @@ struct GICv3State {
39
GIC_DECLARE_BITMAP(active); /* GICD_ISACTIVER */
40
GIC_DECLARE_BITMAP(level); /* Current level */
41
GIC_DECLARE_BITMAP(edge_trigger); /* GICD_ICFGR even bits */
42
+ GIC_DECLARE_BITMAP(nmi); /* GICD_INMIR */
43
uint8_t gicd_ipriority[GICV3_MAXIRQ];
44
uint64_t gicd_irouter[GICV3_MAXIRQ];
45
/* Cached information: pointer to the cpu i/f for the CPUs specified
46
@@ -XXX,XX +XXX,XX @@ GICV3_BITMAP_ACCESSORS(pending)
47
GICV3_BITMAP_ACCESSORS(active)
48
GICV3_BITMAP_ACCESSORS(level)
49
GICV3_BITMAP_ACCESSORS(edge_trigger)
50
+GICV3_BITMAP_ACCESSORS(nmi)
51
52
#define TYPE_ARM_GICV3_COMMON "arm-gicv3-common"
53
typedef struct ARMGICv3CommonClass ARMGICv3CommonClass;
54
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/hw/intc/arm_gicv3_common.c
57
+++ b/hw/intc/arm_gicv3_common.c
58
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_gicv3_gicv4 = {
59
}
60
};
61
62
+static bool gicv3_cpu_nmi_needed(void *opaque)
63
+{
64
+ GICv3CPUState *cs = opaque;
65
+
66
+ return cs->gic->nmi_support;
67
+}
68
+
69
+static const VMStateDescription vmstate_gicv3_cpu_nmi = {
70
+ .name = "arm_gicv3_cpu/nmi",
71
+ .version_id = 1,
72
+ .minimum_version_id = 1,
73
+ .needed = gicv3_cpu_nmi_needed,
74
+ .fields = (const VMStateField[]) {
75
+ VMSTATE_UINT32(gicr_inmir0, GICv3CPUState),
76
+ VMSTATE_END_OF_LIST()
77
+ }
78
+};
79
+
80
static const VMStateDescription vmstate_gicv3_cpu = {
81
.name = "arm_gicv3_cpu",
82
.version_id = 1,
83
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3_cpu = {
84
&vmstate_gicv3_cpu_virt,
85
&vmstate_gicv3_cpu_sre_el1,
86
&vmstate_gicv3_gicv4,
87
+ &vmstate_gicv3_cpu_nmi,
88
NULL
89
}
90
};
91
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = {
92
}
93
};
94
95
+static bool gicv3_nmi_needed(void *opaque)
96
+{
97
+ GICv3State *cs = opaque;
98
+
99
+ return cs->nmi_support;
100
+}
101
+
102
+const VMStateDescription vmstate_gicv3_gicd_nmi = {
103
+ .name = "arm_gicv3/gicd_nmi",
104
+ .version_id = 1,
105
+ .minimum_version_id = 1,
106
+ .needed = gicv3_nmi_needed,
107
+ .fields = (const VMStateField[]) {
108
+ VMSTATE_UINT32_ARRAY(nmi, GICv3State, GICV3_BMP_SIZE),
109
+ VMSTATE_END_OF_LIST()
110
+ }
111
+};
112
+
113
static const VMStateDescription vmstate_gicv3 = {
114
.name = "arm_gicv3",
115
.version_id = 1,
116
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_gicv3 = {
117
},
118
.subsections = (const VMStateDescription * const []) {
119
&vmstate_gicv3_gicd_no_migration_shift_bug,
120
+ &vmstate_gicv3_gicd_nmi,
121
NULL
122
}
123
};
124
--
29
--
125
2.34.1
30
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
From: Bernhard Beschow <shentey@gmail.com>
2
2
3
Add a property has-nmi to the GICv3 device, and use this to set
3
Prefer named constants over magic values for better readability.
4
the NMI bit in the GICD_TYPER register. This isn't visible to
5
guests yet because the property defaults to false and we won't
6
set it in the board code until we've landed all of the changes
7
needed to implement FEAT_GICV3_NMI.
8
4
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>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20240407081733.3231820-14-ruanjinjie@huawei.com
6
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
7
Tested-by: Guenter Roeck <linux@roeck-us.net>
8
Message-id: 20241102125724.532843-5-shentey@gmail.com
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
10
---
15
hw/intc/gicv3_internal.h | 1 +
11
include/hw/net/mii.h | 6 +++++
16
include/hw/intc/arm_gicv3_common.h | 1 +
12
hw/net/lan9118_phy.c | 63 ++++++++++++++++++++++++++++----------------
17
hw/intc/arm_gicv3_common.c | 1 +
13
2 files changed, 46 insertions(+), 23 deletions(-)
18
hw/intc/arm_gicv3_dist.c | 2 ++
19
4 files changed, 5 insertions(+)
20
14
21
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
15
diff --git a/include/hw/net/mii.h b/include/hw/net/mii.h
22
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/intc/gicv3_internal.h
17
--- a/include/hw/net/mii.h
24
+++ b/hw/intc/gicv3_internal.h
18
+++ b/include/hw/net/mii.h
25
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
26
#define GICD_CTLR_E1NWF (1U << 7)
20
#define MII_BMSR_JABBER (1 << 1) /* Jabber detected */
27
#define GICD_CTLR_RWP (1U << 31)
21
#define MII_BMSR_EXTCAP (1 << 0) /* Ext-reg capability */
28
22
29
+#define GICD_TYPER_NMI_SHIFT 9
23
+#define MII_ANAR_RFAULT (1 << 13) /* Say we can detect faults */
30
#define GICD_TYPER_LPIS_SHIFT 17
24
#define MII_ANAR_PAUSE_ASYM (1 << 11) /* Try for asymmetric pause */
31
25
#define MII_ANAR_PAUSE (1 << 10) /* Try for pause */
32
/* 16 bits EventId */
26
#define MII_ANAR_TXFD (1 << 8)
33
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
27
@@ -XXX,XX +XXX,XX @@
28
#define MII_ANAR_10FD (1 << 6)
29
#define MII_ANAR_10 (1 << 5)
30
#define MII_ANAR_CSMACD (1 << 0)
31
+#define MII_ANAR_SELECT (0x001f) /* Selector bits */
32
33
#define MII_ANLPAR_ACK (1 << 14)
34
#define MII_ANLPAR_PAUSEASY (1 << 11) /* can pause asymmetrically */
35
@@ -XXX,XX +XXX,XX @@
36
#define RTL8201CP_PHYID1 0x0000
37
#define RTL8201CP_PHYID2 0x8201
38
39
+/* SMSC LAN9118 */
40
+#define SMSCLAN9118_PHYID1 0x0007
41
+#define SMSCLAN9118_PHYID2 0xc0d1
42
+
43
/* RealTek 8211E */
44
#define RTL8211E_PHYID1 0x001c
45
#define RTL8211E_PHYID2 0xc915
46
diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c
34
index XXXXXXX..XXXXXXX 100644
47
index XXXXXXX..XXXXXXX 100644
35
--- a/include/hw/intc/arm_gicv3_common.h
48
--- a/hw/net/lan9118_phy.c
36
+++ b/include/hw/intc/arm_gicv3_common.h
49
+++ b/hw/net/lan9118_phy.c
37
@@ -XXX,XX +XXX,XX @@ struct GICv3State {
50
@@ -XXX,XX +XXX,XX @@
38
uint32_t num_irq;
51
39
uint32_t revision;
52
#include "qemu/osdep.h"
40
bool lpi_enable;
53
#include "hw/net/lan9118_phy.h"
41
+ bool nmi_support;
54
+#include "hw/net/mii.h"
42
bool security_extn;
55
#include "hw/irq.h"
43
bool force_8bit_prio;
56
#include "hw/resettable.h"
44
bool irq_reset_nonsecure;
57
#include "migration/vmstate.h"
45
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
58
@@ -XXX,XX +XXX,XX @@ uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg)
46
index XXXXXXX..XXXXXXX 100644
59
uint16_t val;
47
--- a/hw/intc/arm_gicv3_common.c
60
48
+++ b/hw/intc/arm_gicv3_common.c
61
switch (reg) {
49
@@ -XXX,XX +XXX,XX @@ static Property arm_gicv3_common_properties[] = {
62
- case 0: /* Basic Control */
50
DEFINE_PROP_UINT32("num-irq", GICv3State, num_irq, 32),
63
+ case MII_BMCR:
51
DEFINE_PROP_UINT32("revision", GICv3State, revision, 3),
64
val = s->control;
52
DEFINE_PROP_BOOL("has-lpi", GICv3State, lpi_enable, 0),
65
break;
53
+ DEFINE_PROP_BOOL("has-nmi", GICv3State, nmi_support, 0),
66
- case 1: /* Basic Status */
54
DEFINE_PROP_BOOL("has-security-extensions", GICv3State, security_extn, 0),
67
+ case MII_BMSR:
55
/*
68
val = s->status;
56
* Compatibility property: force 8 bits of physical priority, even
69
break;
57
diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c
70
- case 2: /* ID1 */
58
index XXXXXXX..XXXXXXX 100644
71
- val = 0x0007;
59
--- a/hw/intc/arm_gicv3_dist.c
72
+ case MII_PHYID1:
60
+++ b/hw/intc/arm_gicv3_dist.c
73
+ val = SMSCLAN9118_PHYID1;
61
@@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset,
74
break;
62
* by GICD_TYPER.IDbits)
75
- case 3: /* ID2 */
63
* MBIS == 0 (message-based SPIs not supported)
76
- val = 0xc0d1;
64
* SecurityExtn == 1 if security extns supported
77
+ case MII_PHYID2:
65
+ * NMI = 1 if Non-maskable interrupt property is supported
78
+ val = SMSCLAN9118_PHYID2;
66
* CPUNumber == 0 since for us ARE is always 1
79
break;
67
* ITLinesNumber == (((max SPI IntID + 1) / 32) - 1)
80
- case 4: /* Auto-neg advertisement */
68
*/
81
+ case MII_ANAR:
69
@@ -XXX,XX +XXX,XX @@ static bool gicd_readl(GICv3State *s, hwaddr offset,
82
val = s->advertise;
70
bool dvis = s->revision >= 4;
83
break;
71
84
- case 5: /* Auto-neg Link Partner Ability */
72
*data = (1 << 25) | (1 << 24) | (dvis << 18) | (sec_extn << 10) |
85
- val = 0x0fe1;
73
+ (s->nmi_support << GICD_TYPER_NMI_SHIFT) |
86
+ case MII_ANLPAR:
74
(s->lpi_enable << GICD_TYPER_LPIS_SHIFT) |
87
+ val = MII_ANLPAR_PAUSEASY | MII_ANLPAR_PAUSE | MII_ANLPAR_T4 |
75
(0xf << 19) | itlinesnumber;
88
+ MII_ANLPAR_TXFD | MII_ANLPAR_TX | MII_ANLPAR_10FD |
76
return true;
89
+ MII_ANLPAR_10 | MII_ANLPAR_CSMACD;
90
break;
91
- case 6: /* Auto-neg Expansion */
92
- val = 1;
93
+ case MII_ANER:
94
+ val = MII_ANER_NWAY;
95
break;
96
case 29: /* Interrupt source. */
97
val = s->ints;
98
@@ -XXX,XX +XXX,XX @@ void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val)
99
trace_lan9118_phy_write(val, reg);
100
101
switch (reg) {
102
- case 0: /* Basic Control */
103
- if (val & 0x8000) {
104
+ case MII_BMCR:
105
+ if (val & MII_BMCR_RESET) {
106
lan9118_phy_reset(s);
107
} else {
108
- s->control = val & 0x7980;
109
+ s->control = val & (MII_BMCR_LOOPBACK | MII_BMCR_SPEED100 |
110
+ MII_BMCR_AUTOEN | MII_BMCR_PDOWN | MII_BMCR_FD |
111
+ MII_BMCR_CTST);
112
/* Complete autonegotiation immediately. */
113
- if (val & 0x1000) {
114
- s->status |= 0x0020;
115
+ if (val & MII_BMCR_AUTOEN) {
116
+ s->status |= MII_BMSR_AN_COMP;
117
}
118
}
119
break;
120
- case 4: /* Auto-neg advertisement */
121
- s->advertise = (val & 0x2d7f) | 0x80;
122
+ case MII_ANAR:
123
+ s->advertise = (val & (MII_ANAR_RFAULT | MII_ANAR_PAUSE_ASYM |
124
+ MII_ANAR_PAUSE | MII_ANAR_10FD | MII_ANAR_10 |
125
+ MII_ANAR_SELECT))
126
+ | MII_ANAR_TX;
127
break;
128
case 30: /* Interrupt mask */
129
s->int_mask = val & 0xff;
130
@@ -XXX,XX +XXX,XX @@ void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down)
131
/* Autonegotiation status mirrors link status. */
132
if (link_down) {
133
trace_lan9118_phy_update_link("down");
134
- s->status &= ~0x0024;
135
+ s->status &= ~(MII_BMSR_AN_COMP | MII_BMSR_LINK_ST);
136
s->ints |= PHY_INT_DOWN;
137
} else {
138
trace_lan9118_phy_update_link("up");
139
- s->status |= 0x0024;
140
+ s->status |= MII_BMSR_AN_COMP | MII_BMSR_LINK_ST;
141
s->ints |= PHY_INT_ENERGYON;
142
s->ints |= PHY_INT_AUTONEG_COMPLETE;
143
}
144
@@ -XXX,XX +XXX,XX @@ void lan9118_phy_reset(Lan9118PhyState *s)
145
{
146
trace_lan9118_phy_reset();
147
148
- s->control = 0x3000;
149
- s->status = 0x7809;
150
- s->advertise = 0x01e1;
151
+ s->control = MII_BMCR_AUTOEN | MII_BMCR_SPEED100;
152
+ s->status = MII_BMSR_100TX_FD
153
+ | MII_BMSR_100TX_HD
154
+ | MII_BMSR_10T_FD
155
+ | MII_BMSR_10T_HD
156
+ | MII_BMSR_AUTONEG
157
+ | MII_BMSR_EXTCAP;
158
+ s->advertise = MII_ANAR_TXFD
159
+ | MII_ANAR_TX
160
+ | MII_ANAR_10FD
161
+ | MII_ANAR_10
162
+ | MII_ANAR_CSMACD;
163
s->int_mask = 0;
164
s->ints = 0;
165
lan9118_phy_update_link(s, s->link_down);
77
--
166
--
78
2.34.1
167
2.34.1
diff view generated by jsdifflib
1
From: Anastasia Belova <abelova@astralinux.ru>
1
From: Bernhard Beschow <shentey@gmail.com>
2
2
3
In soc_dma_set_request() we try to set a bit in a uint64_t, but we
3
The real device advertises this mode and the device model already advertises
4
do it with "1 << ch->num", which can't set any bits past 31;
4
100 mbps half duplex and 10 mbps full+half duplex. So advertise this mode to
5
any use for a channel number of 32 or more would fail due to
5
make the model more realistic.
6
integer overflow.
7
6
8
This doesn't happen in practice for our current use of this code,
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.]
24
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
9
Tested-by: Guenter Roeck <linux@roeck-us.net>
10
Message-id: 20241102125724.532843-6-shentey@gmail.com
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
26
---
12
---
27
hw/dma/soc_dma.c | 4 ++--
13
hw/net/lan9118_phy.c | 4 ++--
28
1 file changed, 2 insertions(+), 2 deletions(-)
14
1 file changed, 2 insertions(+), 2 deletions(-)
29
15
30
diff --git a/hw/dma/soc_dma.c b/hw/dma/soc_dma.c
16
diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c
31
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/dma/soc_dma.c
18
--- a/hw/net/lan9118_phy.c
33
+++ b/hw/dma/soc_dma.c
19
+++ b/hw/net/lan9118_phy.c
34
@@ -XXX,XX +XXX,XX @@ void soc_dma_set_request(struct soc_dma_ch_s *ch, int level)
20
@@ -XXX,XX +XXX,XX @@ void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val)
35
dma->enabled_count += level - ch->enable;
21
break;
36
22
case MII_ANAR:
37
if (level)
23
s->advertise = (val & (MII_ANAR_RFAULT | MII_ANAR_PAUSE_ASYM |
38
- dma->ch_enable_mask |= 1 << ch->num;
24
- MII_ANAR_PAUSE | MII_ANAR_10FD | MII_ANAR_10 |
39
+ dma->ch_enable_mask |= (uint64_t)1 << ch->num;
25
- MII_ANAR_SELECT))
40
else
26
+ MII_ANAR_PAUSE | MII_ANAR_TXFD | MII_ANAR_10FD |
41
- dma->ch_enable_mask &= ~(1 << ch->num);
27
+ MII_ANAR_10 | MII_ANAR_SELECT))
42
+ dma->ch_enable_mask &= ~((uint64_t)1 << ch->num);
28
| MII_ANAR_TX;
43
29
break;
44
if (level != ch->enable) {
30
case 30: /* Interrupt mask */
45
soc_dma_ch_freq_update(dma);
46
--
31
--
47
2.34.1
32
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
For IEEE fused multiply-add, the (0 * inf) + NaN case should raise
2
Invalid for the multiplication of 0 by infinity. Currently we handle
3
this in the per-architecture ifdef ladder in pickNaNMulAdd().
4
However, since this isn't really architecture specific we can hoist
5
it up to the generic code.
2
6
3
If GICD_CTLR_DS bit is zero and the NMI is non-secure, the NMI priority is
7
For the cases where the infzero test in pickNaNMulAdd was
4
higher than 0x80, otherwise it is higher than 0x0. And save the interrupt
8
returning 2, we can delete the check entirely and allow the
5
non-maskable property in hppi.nmi to deliver NMI exception. Since both GICR
9
code to fall into the normal pick-a-NaN handling, because this
6
and GICD can deliver NMI, it is both necessary to check whether the pending
10
will return 2 anyway (input 'c' being the only NaN in this case).
7
irq is NMI in gicv3_redist_update_noirqset and gicv3_update_noirqset.
11
For the cases where infzero was returning 3 to indicate "return
12
the default NaN", we must retain that "return 3".
8
13
9
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
14
For Arm, this looks like it might be a behaviour change because we
15
used to set float_flag_invalid | float_flag_invalid_imz only if C is
16
a quiet NaN. However, it is not, because Arm target code never looks
17
at float_flag_invalid_imz, and for the (0 * inf) + SNaN case we
18
already raised float_flag_invalid via the "abc_mask &
19
float_cmask_snan" check in pick_nan_muladd.
20
21
For any target architecture using the "default implementation" at the
22
bottom of the ifdef, this is a behaviour change but will be fixing a
23
bug (where we failed to raise the Invalid exception for (0 * inf +
24
QNaN). The architectures using the default case are:
25
* hppa
26
* i386
27
* sh4
28
* tricore
29
30
The x86, Tricore and SH4 CPU architecture manuals are clear that this
31
should have raised Invalid; HPPA is a bit vaguer but still seems
32
clear enough.
33
34
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
35
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
36
Message-id: 20241202131347.498124-2-peter.maydell@linaro.org
12
Message-id: 20240407081733.3231820-21-ruanjinjie@huawei.com
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
37
---
15
hw/intc/arm_gicv3.c | 67 +++++++++++++++++++++++++++++++++-----
38
fpu/softfloat-parts.c.inc | 13 +++++++------
16
hw/intc/arm_gicv3_common.c | 3 ++
39
fpu/softfloat-specialize.c.inc | 29 +----------------------------
17
hw/intc/arm_gicv3_redist.c | 3 ++
40
2 files changed, 8 insertions(+), 34 deletions(-)
18
3 files changed, 64 insertions(+), 9 deletions(-)
19
41
20
diff --git a/hw/intc/arm_gicv3.c b/hw/intc/arm_gicv3.c
42
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
21
index XXXXXXX..XXXXXXX 100644
43
index XXXXXXX..XXXXXXX 100644
22
--- a/hw/intc/arm_gicv3.c
44
--- a/fpu/softfloat-parts.c.inc
23
+++ b/hw/intc/arm_gicv3.c
45
+++ b/fpu/softfloat-parts.c.inc
24
@@ -XXX,XX +XXX,XX @@
46
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
25
#include "hw/intc/arm_gicv3.h"
47
int ab_mask, int abc_mask)
26
#include "gicv3_internal.h"
27
28
-static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio)
29
+static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio, bool nmi)
30
{
48
{
31
/* Return true if this IRQ at this priority should take
49
int which;
32
* precedence over the current recorded highest priority
50
+ bool infzero = (ab_mask == float_cmask_infzero);
33
@@ -XXX,XX +XXX,XX @@ static bool irqbetter(GICv3CPUState *cs, int irq, uint8_t prio)
51
34
* is the same as this one (a property which the calling code
52
if (unlikely(abc_mask & float_cmask_snan)) {
35
* relies on).
53
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
36
*/
37
- if (prio < cs->hppi.prio) {
38
- return true;
39
+ if (prio != cs->hppi.prio) {
40
+ return prio < cs->hppi.prio;
41
}
54
}
42
+
55
43
+ /*
56
- which = pickNaNMulAdd(a->cls, b->cls, c->cls,
44
+ * The same priority IRQ with non-maskable property should signal to
57
- ab_mask == float_cmask_infzero, s);
45
+ * the CPU as it have the priority higher than the labelled 0x80 or 0x00.
58
+ if (infzero) {
46
+ */
59
+ /* This is (0 * inf) + NaN or (inf * 0) + NaN */
47
+ if (nmi != cs->hppi.nmi) {
60
+ float_raise(float_flag_invalid | float_flag_invalid_imz, s);
48
+ return nmi;
49
+ }
61
+ }
50
+
62
+
51
/* If multiple pending interrupts have the same priority then it is an
63
+ which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s);
52
* IMPDEF choice which of them to signal to the CPU. We choose to
64
53
* signal the one with the lowest interrupt number.
65
if (s->default_nan_mode || which == 3) {
66
- /*
67
- * Note that this check is after pickNaNMulAdd so that function
68
- * has an opportunity to set the Invalid flag for infzero.
69
- */
70
parts_default_nan(a, s);
71
return a;
72
}
73
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
74
index XXXXXXX..XXXXXXX 100644
75
--- a/fpu/softfloat-specialize.c.inc
76
+++ b/fpu/softfloat-specialize.c.inc
77
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
78
* the default NaN
54
*/
79
*/
55
- if (prio == cs->hppi.prio && irq <= cs->hppi.irq) {
80
if (infzero && is_qnan(c_cls)) {
56
+ if (irq <= cs->hppi.irq) {
81
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
57
return true;
82
return 3;
58
}
83
}
59
return false;
84
60
@@ -XXX,XX +XXX,XX @@ static uint32_t gicr_int_pending(GICv3CPUState *cs)
85
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
61
return pend;
86
* case sets InvalidOp and returns the default NaN
62
}
87
*/
63
88
if (infzero) {
64
+static bool gicv3_get_priority(GICv3CPUState *cs, bool is_redist, int irq,
89
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
65
+ uint8_t *prio)
90
return 3;
66
+{
91
}
67
+ uint32_t nmi = 0x0;
92
/* Prefer sNaN over qNaN, in the a, b, c order. */
93
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
94
* For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
95
* case sets InvalidOp and returns the input value 'c'
96
*/
97
- if (infzero) {
98
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
99
- return 2;
100
- }
101
/* Prefer sNaN over qNaN, in the c, a, b order. */
102
if (is_snan(c_cls)) {
103
return 2;
104
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
105
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
106
* case sets InvalidOp and returns the input value 'c'
107
*/
108
- if (infzero) {
109
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
110
- return 2;
111
- }
68
+
112
+
69
+ if (is_redist) {
113
/* Prefer sNaN over qNaN, in the c, a, b order. */
70
+ nmi = extract32(cs->gicr_inmir0, irq, 1);
114
if (is_snan(c_cls)) {
71
+ } else {
115
return 2;
72
+ nmi = *gic_bmp_ptr32(cs->gic->nmi, irq);
116
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
73
+ nmi = nmi & (1 << (irq & 0x1f));
117
* to return an input NaN if we have one (ie c) rather than generating
74
+ }
118
* a default NaN
75
+
119
*/
76
+ if (nmi) {
120
- if (infzero) {
77
+ /* DS = 0 & Non-secure NMI */
121
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
78
+ if (!(cs->gic->gicd_ctlr & GICD_CTLR_DS) &&
122
- return 2;
79
+ ((is_redist && extract32(cs->gicr_igroupr0, irq, 1)) ||
123
- }
80
+ (!is_redist && gicv3_gicd_group_test(cs->gic, irq)))) {
124
81
+ *prio = 0x80;
125
/* If fRA is a NaN return it; otherwise if fRB is a NaN return it;
82
+ } else {
126
* otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
83
+ *prio = 0x0;
127
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
84
+ }
128
return 1;
85
+
86
+ return true;
87
+ }
88
+
89
+ if (is_redist) {
90
+ *prio = cs->gicr_ipriorityr[irq];
91
+ } else {
92
+ *prio = cs->gic->gicd_ipriority[irq];
93
+ }
94
+
95
+ return false;
96
+}
97
+
98
/* Update the interrupt status after state in a redistributor
99
* or CPU interface has changed, but don't tell the CPU i/f.
100
*/
101
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs)
102
uint8_t prio;
103
int i;
104
uint32_t pend;
105
+ bool nmi = false;
106
107
/* Find out which redistributor interrupts are eligible to be
108
* signaled to the CPU interface.
109
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs)
110
if (!(pend & (1 << i))) {
111
continue;
112
}
113
- prio = cs->gicr_ipriorityr[i];
114
- if (irqbetter(cs, i, prio)) {
115
+ nmi = gicv3_get_priority(cs, true, i, &prio);
116
+ if (irqbetter(cs, i, prio, nmi)) {
117
cs->hppi.irq = i;
118
cs->hppi.prio = prio;
119
+ cs->hppi.nmi = nmi;
120
seenbetter = true;
121
}
122
}
123
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_noirqset(GICv3CPUState *cs)
124
if ((cs->gicr_ctlr & GICR_CTLR_ENABLE_LPIS) && cs->gic->lpi_enable &&
125
(cs->gic->gicd_ctlr & GICD_CTLR_EN_GRP1NS) &&
126
(cs->hpplpi.prio != 0xff)) {
127
- if (irqbetter(cs, cs->hpplpi.irq, cs->hpplpi.prio)) {
128
+ if (irqbetter(cs, cs->hpplpi.irq, cs->hpplpi.prio, cs->hpplpi.nmi)) {
129
cs->hppi.irq = cs->hpplpi.irq;
130
cs->hppi.prio = cs->hpplpi.prio;
131
+ cs->hppi.nmi = cs->hpplpi.nmi;
132
cs->hppi.grp = cs->hpplpi.grp;
133
seenbetter = true;
134
}
135
@@ -XXX,XX +XXX,XX @@ static void gicv3_update_noirqset(GICv3State *s, int start, int len)
136
int i;
137
uint8_t prio;
138
uint32_t pend = 0;
139
+ bool nmi = false;
140
141
assert(start >= GIC_INTERNAL);
142
assert(len > 0);
143
@@ -XXX,XX +XXX,XX @@ static void gicv3_update_noirqset(GICv3State *s, int start, int len)
144
*/
145
continue;
146
}
147
- prio = s->gicd_ipriority[i];
148
- if (irqbetter(cs, i, prio)) {
149
+ nmi = gicv3_get_priority(cs, false, i, &prio);
150
+ if (irqbetter(cs, i, prio, nmi)) {
151
cs->hppi.irq = i;
152
cs->hppi.prio = prio;
153
+ cs->hppi.nmi = nmi;
154
cs->seenbetter = true;
155
}
156
}
129
}
157
@@ -XXX,XX +XXX,XX @@ void gicv3_full_update_noirqset(GICv3State *s)
130
#elif defined(TARGET_RISCV)
158
131
- /* For RISC-V, InvalidOp is set when multiplicands are Inf and zero */
159
for (i = 0; i < s->num_cpu; i++) {
132
- if (infzero) {
160
s->cpu[i].hppi.prio = 0xff;
133
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
161
+ s->cpu[i].hppi.nmi = false;
134
- }
135
return 3; /* default NaN */
136
#elif defined(TARGET_S390X)
137
if (infzero) {
138
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
139
return 3;
162
}
140
}
163
141
164
/* Note that we can guarantee that these functions will not
142
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
165
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
143
return 2;
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
}
144
}
193
@@ -XXX,XX +XXX,XX @@ static void update_for_all_lpis(GICv3CPUState *cs, uint64_t ptbase,
145
#elif defined(TARGET_SPARC)
194
int i, bit;
146
- /* For (inf,0,nan) return c. */
195
147
- if (infzero) {
196
hpp->prio = 0xff;
148
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
197
+ hpp->nmi = false;
149
- return 2;
198
150
- }
199
for (i = GICV3_LPI_INTID_START / 8; i < pendt_size / 8; i++) {
151
/* Prefer SNaN over QNaN, order C, B, A. */
200
address_space_read(as, ptbase + i, MEMTXATTRS_UNSPECIFIED, &pend, 1);
152
if (is_snan(c_cls)) {
201
@@ -XXX,XX +XXX,XX @@ static void gicv3_redist_update_vlpi_only(GICv3CPUState *cs)
153
return 2;
202
154
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
203
if (!FIELD_EX64(cs->gicr_vpendbaser, GICR_VPENDBASER, VALID)) {
155
* For Xtensa, the (inf,zero,nan) case sets InvalidOp and returns
204
cs->hppvlpi.prio = 0xff;
156
* an input NaN if we have one (ie c).
205
+ cs->hppvlpi.nmi = false;
157
*/
206
return;
158
- if (infzero) {
207
}
159
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
208
160
- return 2;
161
- }
162
if (status->use_first_nan) {
163
if (is_nan(a_cls)) {
164
return 0;
209
--
165
--
210
2.34.1
166
2.34.1
diff view generated by jsdifflib
New patch
1
If the target sets default_nan_mode then we're always going to return
2
the default NaN, and pickNaNMulAdd() no longer has any side effects.
3
For consistency with pickNaN(), check for default_nan_mode before
4
calling pickNaNMulAdd().
1
5
6
When we convert pickNaNMulAdd() to allow runtime selection of the NaN
7
propagation rule, this means we won't have to make the targets which
8
use default_nan_mode also set a propagation rule.
9
10
Since RiscV always uses default_nan_mode, this allows us to remove
11
its ifdef case from pickNaNMulAdd().
12
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20241202131347.498124-3-peter.maydell@linaro.org
16
---
17
fpu/softfloat-parts.c.inc | 8 ++++++--
18
fpu/softfloat-specialize.c.inc | 9 +++++++--
19
2 files changed, 13 insertions(+), 4 deletions(-)
20
21
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
22
index XXXXXXX..XXXXXXX 100644
23
--- a/fpu/softfloat-parts.c.inc
24
+++ b/fpu/softfloat-parts.c.inc
25
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
26
float_raise(float_flag_invalid | float_flag_invalid_imz, s);
27
}
28
29
- which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s);
30
+ if (s->default_nan_mode) {
31
+ which = 3;
32
+ } else {
33
+ which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s);
34
+ }
35
36
- if (s->default_nan_mode || which == 3) {
37
+ if (which == 3) {
38
parts_default_nan(a, s);
39
return a;
40
}
41
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
42
index XXXXXXX..XXXXXXX 100644
43
--- a/fpu/softfloat-specialize.c.inc
44
+++ b/fpu/softfloat-specialize.c.inc
45
@@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
46
static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
47
bool infzero, float_status *status)
48
{
49
+ /*
50
+ * We guarantee not to require the target to tell us how to
51
+ * pick a NaN if we're always returning the default NaN.
52
+ * But if we're not in default-NaN mode then the target must
53
+ * specify.
54
+ */
55
+ assert(!status->default_nan_mode);
56
#if defined(TARGET_ARM)
57
/* For ARM, the (inf,zero,qnan) case sets InvalidOp and returns
58
* the default NaN
59
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
60
} else {
61
return 1;
62
}
63
-#elif defined(TARGET_RISCV)
64
- return 3; /* default NaN */
65
#elif defined(TARGET_S390X)
66
if (infzero) {
67
return 3;
68
--
69
2.34.1
diff view generated by jsdifflib
1
We pass a ResetType argument to the Resettable class enter phase
1
IEEE 758 does not define a fixed rule for what NaN to return in
2
method, but we don't pass it to hold and exit, even though the
2
the case of a fused multiply-add of inf * 0 + NaN. Different
3
callsites have it readily available. This means that if a device
3
architectures thus do different things:
4
cared about the ResetType it would need to record it in the enter
4
* some return the default NaN
5
phase method to use later on. We should pass the type to all three
5
* some return the input NaN
6
of the phase methods to avoid having to do that.
6
* Arm returns the default NaN if the input NaN is quiet,
7
7
and the input NaN if it is signalling
8
This coccinelle script adds the ResetType argument to the hold and
8
9
exit phases of the Resettable interface.
9
We want to make this logic be runtime selected rather than
10
10
hardcoded into the binary, because:
11
The first part of the script (rules holdfn_assigned, holdfn_defined,
11
* this will let us have multiple targets in one QEMU binary
12
exitfn_assigned, exitfn_defined) update implementations of the
12
* the Arm FEAT_AFP architectural feature includes letting
13
interface within device models, both to change the signature of their
13
the guest select a NaN propagation rule at runtime
14
method implementations and to pass on the reset type when they invoke
14
15
reset on some other device.
15
In this commit we add an enum for the propagation rule, the field in
16
16
float_status, and the corresponding getters and setters. We change
17
The second part of the script is various special cases:
17
pickNaNMulAdd to honour this, but because all targets still leave
18
* method callsites in resettable_phase_hold(), resettable_phase_exit()
18
this field at its default 0 value, the fallback logic will pick the
19
and device_phases_reset()
19
rule type with the old ifdef ladder.
20
* updating the typedefs for the methods
20
21
* isl_pmbus_vr.c has some code where one device's reset method directly
21
Note that four architectures both use the muladd softfloat functions
22
calls the implementation of a different device's method
22
and did not have a branch of the ifdef ladder to specify their
23
behaviour (and so were ending up with the "default" case, probably
24
wrongly): i386, HPPA, SH4 and Tricore. SH4 and Tricore both set
25
default_nan_mode, and so will never get into pickNaNMulAdd(). For
26
HPPA and i386 we retain the same behaviour as the old default-case,
27
which is to not ever return the default NaN. This might not be
28
correct but it is not a behaviour change.
23
29
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Reviewed-by: Luc Michel <luc.michel@amd.com>
31
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
26
Message-id: 20240412160809.1260625-4-peter.maydell@linaro.org
32
Message-id: 20241202131347.498124-4-peter.maydell@linaro.org
27
---
33
---
28
scripts/coccinelle/reset-type.cocci | 133 ++++++++++++++++++++++++++++
34
include/fpu/softfloat-helpers.h | 11 ++++
29
1 file changed, 133 insertions(+)
35
include/fpu/softfloat-types.h | 23 +++++++++
30
create mode 100644 scripts/coccinelle/reset-type.cocci
36
fpu/softfloat-specialize.c.inc | 91 ++++++++++++++++++++++-----------
31
37
3 files changed, 95 insertions(+), 30 deletions(-)
32
diff --git a/scripts/coccinelle/reset-type.cocci b/scripts/coccinelle/reset-type.cocci
38
33
new file mode 100644
39
diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h
34
index XXXXXXX..XXXXXXX
40
index XXXXXXX..XXXXXXX 100644
35
--- /dev/null
41
--- a/include/fpu/softfloat-helpers.h
36
+++ b/scripts/coccinelle/reset-type.cocci
42
+++ b/include/fpu/softfloat-helpers.h
37
@@ -XXX,XX +XXX,XX @@
43
@@ -XXX,XX +XXX,XX @@ static inline void set_float_2nan_prop_rule(Float2NaNPropRule rule,
38
+// Convert device code using three-phase reset to add a ResetType
44
status->float_2nan_prop_rule = rule;
39
+// argument to implementations of ResettableHoldPhase and
45
}
40
+// ResettableEnterPhase methods.
46
41
+//
47
+static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule,
42
+// Copyright Linaro Ltd 2024
48
+ float_status *status)
43
+// SPDX-License-Identifier: GPL-2.0-or-later
44
+//
45
+// for dir in include hw target; do \
46
+// spatch --macro-file scripts/cocci-macro-file.h \
47
+// --sp-file scripts/coccinelle/reset-type.cocci \
48
+// --keep-comments --smpl-spacing --in-place --include-headers \
49
+// --dir $dir; done
50
+//
51
+// This coccinelle script aims to produce a complete change that needs
52
+// no human interaction, so as well as the generic "update device
53
+// implementations of the hold and exit phase methods" it includes
54
+// the special-case transformations needed for the core code and for
55
+// one device model that does something a bit nonstandard. Those
56
+// special cases are at the end of the file.
57
+
58
+// Look for where we use a function as a ResettableHoldPhase method,
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
+)
73
+
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
+{
49
+{
87
+ <...
50
+ status->float_infzeronan_rule = rule;
88
+- parent.hold(obj)
89
++ parent.hold(obj, type)
90
+ ...>
91
+}
51
+}
92
+
52
+
93
+// Similarly for ResettableExitPhase.
53
static inline void set_flush_to_zero(bool val, float_status *status)
94
+@ exitfn_assigned @
54
{
95
+identifier enterfn, holdfn, exitfn;
55
status->flush_to_zero = val;
96
+identifier rc;
56
@@ -XXX,XX +XXX,XX @@ static inline Float2NaNPropRule get_float_2nan_prop_rule(float_status *status)
97
+expression e;
57
return status->float_2nan_prop_rule;
98
+@@
58
}
99
+ResettableClass *rc;
59
100
+...
60
+static inline FloatInfZeroNaNRule get_float_infzeronan_rule(float_status *status)
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
+{
61
+{
115
+ <...
62
+ return status->float_infzeronan_rule;
116
+- parent.exit(obj)
117
++ parent.exit(obj, type)
118
+ ...>
119
+}
63
+}
120
+
64
+
121
+// SPECIAL CASES ONLY BELOW HERE
65
static inline bool get_flush_to_zero(float_status *status)
122
+// We use a python scripted constraint on the position of the match
66
{
123
+// to ensure that they only match in a particular function. See
67
return status->flush_to_zero;
124
+// https://public-inbox.org/git/alpine.DEB.2.21.1808240652370.2344@hadrien/
68
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
125
+// which recommends this as the way to do "match only in this function".
69
index XXXXXXX..XXXXXXX 100644
126
+
70
--- a/include/fpu/softfloat-types.h
127
+// Special case: isl_pmbus_vr.c has some reset methods calling others directly
71
+++ b/include/fpu/softfloat-types.h
128
+@ isl_pmbus_vr @
72
@@ -XXX,XX +XXX,XX @@ typedef enum __attribute__((__packed__)) {
129
+identifier obj;
73
float_2nan_prop_x87,
130
+@@
74
} Float2NaNPropRule;
131
+- isl_pmbus_vr_exit_reset(obj);
75
132
++ isl_pmbus_vr_exit_reset(obj, type);
76
+/*
133
+
77
+ * Rule for result of fused multiply-add 0 * Inf + NaN.
134
+// Special case: device_phases_reset() needs to pass RESET_TYPE_COLD
78
+ * This must be a NaN, but implementations differ on whether this
135
+@ device_phases_reset_hold @
79
+ * is the input NaN or the default NaN.
136
+expression obj;
80
+ *
137
+identifier rc;
81
+ * You don't need to set this if default_nan_mode is enabled.
138
+identifier phase;
82
+ * When not in default-NaN mode, it is an error for the target
139
+position p : script:python() { p[0].current_element == "device_phases_reset" };
83
+ * not to set the rule in float_status if it uses muladd, and we
140
+@@
84
+ * will assert if we need to handle an input NaN and no rule was
141
+- rc->phases.phase(obj)@p
85
+ * selected.
142
++ rc->phases.phase(obj, RESET_TYPE_COLD)
86
+ */
143
+
87
+typedef enum __attribute__((__packed__)) {
144
+// Special case: in resettable_phase_hold() and resettable_phase_exit()
88
+ /* No propagation rule specified */
145
+// we need to pass through the ResetType argument to the method being called
89
+ float_infzeronan_none = 0,
146
+@ resettable_phase_hold @
90
+ /* Result is never the default NaN (so always the input NaN) */
147
+expression obj;
91
+ float_infzeronan_dnan_never,
148
+identifier rc;
92
+ /* Result is always the default NaN */
149
+position p : script:python() { p[0].current_element == "resettable_phase_hold" };
93
+ float_infzeronan_dnan_always,
150
+@@
94
+ /* Result is the default NaN if the input NaN is quiet */
151
+- rc->phases.hold(obj)@p
95
+ float_infzeronan_dnan_if_qnan,
152
++ rc->phases.hold(obj, type)
96
+} FloatInfZeroNaNRule;
153
+@ resettable_phase_exit @
97
+
154
+expression obj;
98
/*
155
+identifier rc;
99
* Floating Point Status. Individual architectures may maintain
156
+position p : script:python() { p[0].current_element == "resettable_phase_exit" };
100
* several versions of float_status for different functions. The
157
+@@
101
@@ -XXX,XX +XXX,XX @@ typedef struct float_status {
158
+- rc->phases.exit(obj)@p
102
FloatRoundMode float_rounding_mode;
159
++ rc->phases.exit(obj, type)
103
FloatX80RoundPrec floatx80_rounding_precision;
160
+// Special case: the typedefs for the methods need to declare the new argument
104
Float2NaNPropRule float_2nan_prop_rule;
161
+@ phase_typedef_hold @
105
+ FloatInfZeroNaNRule float_infzeronan_rule;
162
+identifier obj;
106
bool tininess_before_rounding;
163
+@@
107
/* should denormalised results go to zero and set the inexact flag? */
164
+- typedef void (*ResettableHoldPhase)(Object *obj);
108
bool flush_to_zero;
165
++ typedef void (*ResettableHoldPhase)(Object *obj, ResetType type);
109
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
166
+@ phase_typedef_exit @
110
index XXXXXXX..XXXXXXX 100644
167
+identifier obj;
111
--- a/fpu/softfloat-specialize.c.inc
168
+@@
112
+++ b/fpu/softfloat-specialize.c.inc
169
+- typedef void (*ResettableExitPhase)(Object *obj);
113
@@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
170
++ typedef void (*ResettableExitPhase)(Object *obj, ResetType type);
114
static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
115
bool infzero, float_status *status)
116
{
117
+ FloatInfZeroNaNRule rule = status->float_infzeronan_rule;
118
+
119
/*
120
* We guarantee not to require the target to tell us how to
121
* pick a NaN if we're always returning the default NaN.
122
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
123
* specify.
124
*/
125
assert(!status->default_nan_mode);
126
+
127
+ if (rule == float_infzeronan_none) {
128
+ /*
129
+ * Temporarily fall back to ifdef ladder
130
+ */
131
#if defined(TARGET_ARM)
132
- /* For ARM, the (inf,zero,qnan) case sets InvalidOp and returns
133
- * the default NaN
134
- */
135
- if (infzero && is_qnan(c_cls)) {
136
- return 3;
137
+ /*
138
+ * For ARM, the (inf,zero,qnan) case returns the default NaN,
139
+ * but (inf,zero,snan) returns the input NaN.
140
+ */
141
+ rule = float_infzeronan_dnan_if_qnan;
142
+#elif defined(TARGET_MIPS)
143
+ if (snan_bit_is_one(status)) {
144
+ /*
145
+ * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
146
+ * case sets InvalidOp and returns the default NaN
147
+ */
148
+ rule = float_infzeronan_dnan_always;
149
+ } else {
150
+ /*
151
+ * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
152
+ * case sets InvalidOp and returns the input value 'c'
153
+ */
154
+ rule = float_infzeronan_dnan_never;
155
+ }
156
+#elif defined(TARGET_PPC) || defined(TARGET_SPARC) || \
157
+ defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
158
+ defined(TARGET_I386) || defined(TARGET_LOONGARCH)
159
+ /*
160
+ * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
161
+ * case sets InvalidOp and returns the input value 'c'
162
+ */
163
+ /*
164
+ * For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
165
+ * to return an input NaN if we have one (ie c) rather than generating
166
+ * a default NaN
167
+ */
168
+ rule = float_infzeronan_dnan_never;
169
+#elif defined(TARGET_S390X)
170
+ rule = float_infzeronan_dnan_always;
171
+#endif
172
}
173
174
+ if (infzero) {
175
+ /*
176
+ * Inf * 0 + NaN -- some implementations return the default NaN here,
177
+ * and some return the input NaN.
178
+ */
179
+ switch (rule) {
180
+ case float_infzeronan_dnan_never:
181
+ return 2;
182
+ case float_infzeronan_dnan_always:
183
+ return 3;
184
+ case float_infzeronan_dnan_if_qnan:
185
+ return is_qnan(c_cls) ? 3 : 2;
186
+ default:
187
+ g_assert_not_reached();
188
+ }
189
+ }
190
+
191
+#if defined(TARGET_ARM)
192
+
193
/* This looks different from the ARM ARM pseudocode, because the ARM ARM
194
* puts the operands to a fused mac operation (a*b)+c in the order c,a,b.
195
*/
196
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
197
}
198
#elif defined(TARGET_MIPS)
199
if (snan_bit_is_one(status)) {
200
- /*
201
- * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
202
- * case sets InvalidOp and returns the default NaN
203
- */
204
- if (infzero) {
205
- return 3;
206
- }
207
/* Prefer sNaN over qNaN, in the a, b, c order. */
208
if (is_snan(a_cls)) {
209
return 0;
210
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
211
return 2;
212
}
213
} else {
214
- /*
215
- * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
216
- * case sets InvalidOp and returns the input value 'c'
217
- */
218
/* Prefer sNaN over qNaN, in the c, a, b order. */
219
if (is_snan(c_cls)) {
220
return 2;
221
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
222
}
223
}
224
#elif defined(TARGET_LOONGARCH64)
225
- /*
226
- * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
227
- * case sets InvalidOp and returns the input value 'c'
228
- */
229
-
230
/* Prefer sNaN over qNaN, in the c, a, b order. */
231
if (is_snan(c_cls)) {
232
return 2;
233
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
234
return 1;
235
}
236
#elif defined(TARGET_PPC)
237
- /* For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
238
- * to return an input NaN if we have one (ie c) rather than generating
239
- * a default NaN
240
- */
241
-
242
/* If fRA is a NaN return it; otherwise if fRB is a NaN return it;
243
* otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
244
*/
245
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
246
return 1;
247
}
248
#elif defined(TARGET_S390X)
249
- if (infzero) {
250
- return 3;
251
- }
252
-
253
if (is_snan(a_cls)) {
254
return 0;
255
} else if (is_snan(b_cls)) {
171
--
256
--
172
2.34.1
257
2.34.1
diff view generated by jsdifflib
New patch
1
Explicitly set a rule in the softfloat tests for the inf-zero-nan
2
muladd special case. In meson.build we put -DTARGET_ARM in fpcflags,
3
and so we should select here the Arm rule of
4
float_infzeronan_dnan_if_qnan.
1
5
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20241202131347.498124-5-peter.maydell@linaro.org
9
---
10
tests/fp/fp-bench.c | 5 +++++
11
tests/fp/fp-test.c | 5 +++++
12
2 files changed, 10 insertions(+)
13
14
diff --git a/tests/fp/fp-bench.c b/tests/fp/fp-bench.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/fp/fp-bench.c
17
+++ b/tests/fp/fp-bench.c
18
@@ -XXX,XX +XXX,XX @@ static void run_bench(void)
19
{
20
bench_func_t f;
21
22
+ /*
23
+ * These implementation-defined choices for various things IEEE
24
+ * doesn't specify match those used by the Arm architecture.
25
+ */
26
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &soft_status);
27
+ set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &soft_status);
28
29
f = bench_funcs[operation][precision];
30
g_assert(f);
31
diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/tests/fp/fp-test.c
34
+++ b/tests/fp/fp-test.c
35
@@ -XXX,XX +XXX,XX @@ void run_test(void)
36
{
37
unsigned int i;
38
39
+ /*
40
+ * These implementation-defined choices for various things IEEE
41
+ * doesn't specify match those used by the Arm architecture.
42
+ */
43
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf);
44
+ set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &qsf);
45
46
genCases_setLevel(test_level);
47
verCases_maxErrorCount = n_max_errors;
48
--
49
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the Arm target,
2
so we can remove the ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-6-peter.maydell@linaro.org
7
---
8
target/arm/cpu.c | 3 +++
9
fpu/softfloat-specialize.c.inc | 8 +-------
10
2 files changed, 4 insertions(+), 7 deletions(-)
11
12
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu.c
15
+++ b/target/arm/cpu.c
16
@@ -XXX,XX +XXX,XX @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
17
* * tininess-before-rounding
18
* * 2-input NaN propagation prefers SNaN over QNaN, and then
19
* operand A over operand B (see FPProcessNaNs() pseudocode)
20
+ * * 0 * Inf + NaN returns the default NaN if the input NaN is quiet,
21
+ * and the input NaN if it is signalling
22
*/
23
static void arm_set_default_fp_behaviours(float_status *s)
24
{
25
set_float_detect_tininess(float_tininess_before_rounding, s);
26
set_float_2nan_prop_rule(float_2nan_prop_s_ab, s);
27
+ set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, s);
28
}
29
30
static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)
31
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
32
index XXXXXXX..XXXXXXX 100644
33
--- a/fpu/softfloat-specialize.c.inc
34
+++ b/fpu/softfloat-specialize.c.inc
35
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
36
/*
37
* Temporarily fall back to ifdef ladder
38
*/
39
-#if defined(TARGET_ARM)
40
- /*
41
- * For ARM, the (inf,zero,qnan) case returns the default NaN,
42
- * but (inf,zero,snan) returns the input NaN.
43
- */
44
- rule = float_infzeronan_dnan_if_qnan;
45
-#elif defined(TARGET_MIPS)
46
+#if defined(TARGET_MIPS)
47
if (snan_bit_is_one(status)) {
48
/*
49
* For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
50
--
51
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for s390, so we
2
can remove the ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-7-peter.maydell@linaro.org
7
---
8
target/s390x/cpu.c | 2 ++
9
fpu/softfloat-specialize.c.inc | 2 --
10
2 files changed, 2 insertions(+), 2 deletions(-)
11
12
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/s390x/cpu.c
15
+++ b/target/s390x/cpu.c
16
@@ -XXX,XX +XXX,XX @@ static void s390_cpu_reset_hold(Object *obj, ResetType type)
17
set_float_detect_tininess(float_tininess_before_rounding,
18
&env->fpu_status);
19
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fpu_status);
20
+ set_float_infzeronan_rule(float_infzeronan_dnan_always,
21
+ &env->fpu_status);
22
/* fall through */
23
case RESET_TYPE_S390_CPU_NORMAL:
24
env->psw.mask &= ~PSW_MASK_RI;
25
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
26
index XXXXXXX..XXXXXXX 100644
27
--- a/fpu/softfloat-specialize.c.inc
28
+++ b/fpu/softfloat-specialize.c.inc
29
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
30
* a default NaN
31
*/
32
rule = float_infzeronan_dnan_never;
33
-#elif defined(TARGET_S390X)
34
- rule = float_infzeronan_dnan_always;
35
#endif
36
}
37
38
--
39
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the PPC target,
2
so we can remove the ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-8-peter.maydell@linaro.org
7
---
8
target/ppc/cpu_init.c | 7 +++++++
9
fpu/softfloat-specialize.c.inc | 7 +------
10
2 files changed, 8 insertions(+), 6 deletions(-)
11
12
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/ppc/cpu_init.c
15
+++ b/target/ppc/cpu_init.c
16
@@ -XXX,XX +XXX,XX @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type)
17
*/
18
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status);
19
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->vec_status);
20
+ /*
21
+ * For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
22
+ * to return an input NaN if we have one (ie c) rather than generating
23
+ * a default NaN
24
+ */
25
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
26
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->vec_status);
27
28
for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) {
29
ppc_spr_t *spr = &env->spr_cb[i];
30
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
31
index XXXXXXX..XXXXXXX 100644
32
--- a/fpu/softfloat-specialize.c.inc
33
+++ b/fpu/softfloat-specialize.c.inc
34
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
35
*/
36
rule = float_infzeronan_dnan_never;
37
}
38
-#elif defined(TARGET_PPC) || defined(TARGET_SPARC) || \
39
+#elif defined(TARGET_SPARC) || \
40
defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
41
defined(TARGET_I386) || defined(TARGET_LOONGARCH)
42
/*
43
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
44
* case sets InvalidOp and returns the input value 'c'
45
*/
46
- /*
47
- * For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
48
- * to return an input NaN if we have one (ie c) rather than generating
49
- * a default NaN
50
- */
51
rule = float_infzeronan_dnan_never;
52
#endif
53
}
54
--
55
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the MIPS target,
2
so we can remove the ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-9-peter.maydell@linaro.org
7
---
8
target/mips/fpu_helper.h | 9 +++++++++
9
target/mips/msa.c | 4 ++++
10
fpu/softfloat-specialize.c.inc | 16 +---------------
11
3 files changed, 14 insertions(+), 15 deletions(-)
12
13
diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/mips/fpu_helper.h
16
+++ b/target/mips/fpu_helper.h
17
@@ -XXX,XX +XXX,XX @@ static inline void restore_flush_mode(CPUMIPSState *env)
18
static inline void restore_snan_bit_mode(CPUMIPSState *env)
19
{
20
bool nan2008 = env->active_fpu.fcr31 & (1 << FCR31_NAN2008);
21
+ FloatInfZeroNaNRule izn_rule;
22
23
/*
24
* With nan2008, SNaNs are silenced in the usual way.
25
@@ -XXX,XX +XXX,XX @@ static inline void restore_snan_bit_mode(CPUMIPSState *env)
26
*/
27
set_snan_bit_is_one(!nan2008, &env->active_fpu.fp_status);
28
set_default_nan_mode(!nan2008, &env->active_fpu.fp_status);
29
+ /*
30
+ * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
31
+ * case sets InvalidOp and returns the default NaN.
32
+ * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
33
+ * case sets InvalidOp and returns the input value 'c'.
34
+ */
35
+ izn_rule = nan2008 ? float_infzeronan_dnan_never : float_infzeronan_dnan_always;
36
+ set_float_infzeronan_rule(izn_rule, &env->active_fpu.fp_status);
37
}
38
39
static inline void restore_fp_status(CPUMIPSState *env)
40
diff --git a/target/mips/msa.c b/target/mips/msa.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/target/mips/msa.c
43
+++ b/target/mips/msa.c
44
@@ -XXX,XX +XXX,XX @@ void msa_reset(CPUMIPSState *env)
45
46
/* set proper signanling bit meaning ("1" means "quiet") */
47
set_snan_bit_is_one(0, &env->active_tc.msa_fp_status);
48
+
49
+ /* Inf * 0 + NaN returns the input NaN */
50
+ set_float_infzeronan_rule(float_infzeronan_dnan_never,
51
+ &env->active_tc.msa_fp_status);
52
}
53
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
54
index XXXXXXX..XXXXXXX 100644
55
--- a/fpu/softfloat-specialize.c.inc
56
+++ b/fpu/softfloat-specialize.c.inc
57
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
58
/*
59
* Temporarily fall back to ifdef ladder
60
*/
61
-#if defined(TARGET_MIPS)
62
- if (snan_bit_is_one(status)) {
63
- /*
64
- * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
65
- * case sets InvalidOp and returns the default NaN
66
- */
67
- rule = float_infzeronan_dnan_always;
68
- } else {
69
- /*
70
- * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
71
- * case sets InvalidOp and returns the input value 'c'
72
- */
73
- rule = float_infzeronan_dnan_never;
74
- }
75
-#elif defined(TARGET_SPARC) || \
76
+#if defined(TARGET_SPARC) || \
77
defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
78
defined(TARGET_I386) || defined(TARGET_LOONGARCH)
79
/*
80
--
81
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the SPARC target,
2
so we can remove the ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-10-peter.maydell@linaro.org
7
---
8
target/sparc/cpu.c | 2 ++
9
fpu/softfloat-specialize.c.inc | 3 +--
10
2 files changed, 3 insertions(+), 2 deletions(-)
11
12
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/sparc/cpu.c
15
+++ b/target/sparc/cpu.c
16
@@ -XXX,XX +XXX,XX @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
17
* the CPU state struct so it won't get zeroed on reset.
18
*/
19
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &env->fp_status);
20
+ /* For inf * 0 + NaN, return the input NaN */
21
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
22
23
cpu_exec_realizefn(cs, &local_err);
24
if (local_err != NULL) {
25
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
26
index XXXXXXX..XXXXXXX 100644
27
--- a/fpu/softfloat-specialize.c.inc
28
+++ b/fpu/softfloat-specialize.c.inc
29
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
30
/*
31
* Temporarily fall back to ifdef ladder
32
*/
33
-#if defined(TARGET_SPARC) || \
34
- defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
35
+#if defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
36
defined(TARGET_I386) || defined(TARGET_LOONGARCH)
37
/*
38
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
39
--
40
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the xtensa target,
2
so we can remove the ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-11-peter.maydell@linaro.org
7
---
8
target/xtensa/cpu.c | 2 ++
9
fpu/softfloat-specialize.c.inc | 2 +-
10
2 files changed, 3 insertions(+), 1 deletion(-)
11
12
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/xtensa/cpu.c
15
+++ b/target/xtensa/cpu.c
16
@@ -XXX,XX +XXX,XX @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type)
17
reset_mmu(env);
18
cs->halted = env->runstall;
19
#endif
20
+ /* For inf * 0 + NaN, return the input NaN */
21
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
22
set_no_signaling_nans(!dfpu, &env->fp_status);
23
xtensa_use_first_nan(env, !dfpu);
24
}
25
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
26
index XXXXXXX..XXXXXXX 100644
27
--- a/fpu/softfloat-specialize.c.inc
28
+++ b/fpu/softfloat-specialize.c.inc
29
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
30
/*
31
* Temporarily fall back to ifdef ladder
32
*/
33
-#if defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
34
+#if defined(TARGET_HPPA) || \
35
defined(TARGET_I386) || defined(TARGET_LOONGARCH)
36
/*
37
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
38
--
39
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the x86 target.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-12-peter.maydell@linaro.org
6
---
7
target/i386/tcg/fpu_helper.c | 7 +++++++
8
fpu/softfloat-specialize.c.inc | 2 +-
9
2 files changed, 8 insertions(+), 1 deletion(-)
10
11
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/i386/tcg/fpu_helper.c
14
+++ b/target/i386/tcg/fpu_helper.c
15
@@ -XXX,XX +XXX,XX @@ void cpu_init_fp_statuses(CPUX86State *env)
16
*/
17
set_float_2nan_prop_rule(float_2nan_prop_x87, &env->mmx_status);
18
set_float_2nan_prop_rule(float_2nan_prop_x87, &env->sse_status);
19
+ /*
20
+ * Only SSE has multiply-add instructions. In the SDM Section 14.5.2
21
+ * "Fused-Multiply-ADD (FMA) Numeric Behavior" the NaN handling is
22
+ * specified -- for 0 * inf + NaN the input NaN is selected, and if
23
+ * there are multiple input NaNs they are selected in the order a, b, c.
24
+ */
25
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status);
26
}
27
28
static inline uint8_t save_exception_flags(CPUX86State *env)
29
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
30
index XXXXXXX..XXXXXXX 100644
31
--- a/fpu/softfloat-specialize.c.inc
32
+++ b/fpu/softfloat-specialize.c.inc
33
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
34
* Temporarily fall back to ifdef ladder
35
*/
36
#if defined(TARGET_HPPA) || \
37
- defined(TARGET_I386) || defined(TARGET_LOONGARCH)
38
+ defined(TARGET_LOONGARCH)
39
/*
40
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
41
* case sets InvalidOp and returns the input value 'c'
42
--
43
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the loongarch target.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-13-peter.maydell@linaro.org
6
---
7
target/loongarch/tcg/fpu_helper.c | 5 +++++
8
fpu/softfloat-specialize.c.inc | 7 +------
9
2 files changed, 6 insertions(+), 6 deletions(-)
10
11
diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/loongarch/tcg/fpu_helper.c
14
+++ b/target/loongarch/tcg/fpu_helper.c
15
@@ -XXX,XX +XXX,XX @@ void restore_fp_status(CPULoongArchState *env)
16
&env->fp_status);
17
set_flush_to_zero(0, &env->fp_status);
18
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status);
19
+ /*
20
+ * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
21
+ * case sets InvalidOp and returns the input value 'c'
22
+ */
23
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
24
}
25
26
int ieee_ex_to_loongarch(int xcpt)
27
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
28
index XXXXXXX..XXXXXXX 100644
29
--- a/fpu/softfloat-specialize.c.inc
30
+++ b/fpu/softfloat-specialize.c.inc
31
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
32
/*
33
* Temporarily fall back to ifdef ladder
34
*/
35
-#if defined(TARGET_HPPA) || \
36
- defined(TARGET_LOONGARCH)
37
- /*
38
- * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
39
- * case sets InvalidOp and returns the input value 'c'
40
- */
41
+#if defined(TARGET_HPPA)
42
rule = float_infzeronan_dnan_never;
43
#endif
44
}
45
--
46
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the HPPA target,
2
so we can remove the ifdef from pickNaNMulAdd().
1
3
4
As this is the last target to be converted to explicitly setting
5
the rule, we can remove the fallback code in pickNaNMulAdd()
6
entirely.
7
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20241202131347.498124-14-peter.maydell@linaro.org
11
---
12
target/hppa/fpu_helper.c | 2 ++
13
fpu/softfloat-specialize.c.inc | 13 +------------
14
2 files changed, 3 insertions(+), 12 deletions(-)
15
16
diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/hppa/fpu_helper.c
19
+++ b/target/hppa/fpu_helper.c
20
@@ -XXX,XX +XXX,XX @@ void HELPER(loaded_fr0)(CPUHPPAState *env)
21
* HPPA does note implement a CPU reset method at all...
22
*/
23
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status);
24
+ /* For inf * 0 + NaN, return the input NaN */
25
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
26
}
27
28
void cpu_hppa_loaded_fr0(CPUHPPAState *env)
29
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
30
index XXXXXXX..XXXXXXX 100644
31
--- a/fpu/softfloat-specialize.c.inc
32
+++ b/fpu/softfloat-specialize.c.inc
33
@@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
34
static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
35
bool infzero, float_status *status)
36
{
37
- FloatInfZeroNaNRule rule = status->float_infzeronan_rule;
38
-
39
/*
40
* We guarantee not to require the target to tell us how to
41
* pick a NaN if we're always returning the default NaN.
42
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
43
*/
44
assert(!status->default_nan_mode);
45
46
- if (rule == float_infzeronan_none) {
47
- /*
48
- * Temporarily fall back to ifdef ladder
49
- */
50
-#if defined(TARGET_HPPA)
51
- rule = float_infzeronan_dnan_never;
52
-#endif
53
- }
54
-
55
if (infzero) {
56
/*
57
* Inf * 0 + NaN -- some implementations return the default NaN here,
58
* and some return the input NaN.
59
*/
60
- switch (rule) {
61
+ switch (status->float_infzeronan_rule) {
62
case float_infzeronan_dnan_never:
63
return 2;
64
case float_infzeronan_dnan_always:
65
--
66
2.34.1
diff view generated by jsdifflib
New patch
1
The new implementation of pickNaNMulAdd() will find it convenient
2
to know whether at least one of the three arguments to the muladd
3
was a signaling NaN. We already calculate that in the caller,
4
so pass it in as a new bool have_snan.
1
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20241202131347.498124-15-peter.maydell@linaro.org
9
---
10
fpu/softfloat-parts.c.inc | 5 +++--
11
fpu/softfloat-specialize.c.inc | 2 +-
12
2 files changed, 4 insertions(+), 3 deletions(-)
13
14
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
15
index XXXXXXX..XXXXXXX 100644
16
--- a/fpu/softfloat-parts.c.inc
17
+++ b/fpu/softfloat-parts.c.inc
18
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
19
{
20
int which;
21
bool infzero = (ab_mask == float_cmask_infzero);
22
+ bool have_snan = (abc_mask & float_cmask_snan);
23
24
- if (unlikely(abc_mask & float_cmask_snan)) {
25
+ if (unlikely(have_snan)) {
26
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
27
}
28
29
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
30
if (s->default_nan_mode) {
31
which = 3;
32
} else {
33
- which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s);
34
+ which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, have_snan, s);
35
}
36
37
if (which == 3) {
38
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
39
index XXXXXXX..XXXXXXX 100644
40
--- a/fpu/softfloat-specialize.c.inc
41
+++ b/fpu/softfloat-specialize.c.inc
42
@@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
43
| Return values : 0 : a; 1 : b; 2 : c; 3 : default-NaN
44
*----------------------------------------------------------------------------*/
45
static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
46
- bool infzero, float_status *status)
47
+ bool infzero, bool have_snan, float_status *status)
48
{
49
/*
50
* We guarantee not to require the target to tell us how to
51
--
52
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
IEEE 758 does not define a fixed rule for which NaN to pick as the
2
2
result if both operands of a 3-operand fused multiply-add operation
3
FEAT_NMI defines another three new bits in HCRX_EL2: TALLINT, HCRX_VINMI and
3
are NaNs. As a result different architectures have ended up with
4
HCRX_VFNMI. When the feature is enabled, allow these bits to be written in
4
different rules for propagating NaNs.
5
HCRX_EL2.
5
6
6
QEMU currently hardcodes the NaN propagation logic into the binary
7
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
because pickNaNMulAdd() has an ifdef ladder for different targets.
8
We want to make the propagation rule instead be selectable at
9
runtime, because:
10
* this will let us have multiple targets in one QEMU binary
11
* the Arm FEAT_AFP architectural feature includes letting
12
the guest select a NaN propagation rule at runtime
13
14
In this commit we add an enum for the propagation rule, the field in
15
float_status, and the corresponding getters and setters. We change
16
pickNaNMulAdd to honour this, but because all targets still leave
17
this field at its default 0 value, the fallback logic will pick the
18
rule type with the old ifdef ladder.
19
20
It's valid not to set a propagation rule if default_nan_mode is
21
enabled, because in that case there's no need to pick a NaN; all the
22
callers of pickNaNMulAdd() catch this case and skip calling it.
23
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
25
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
26
Message-id: 20241202131347.498124-16-peter.maydell@linaro.org
10
Message-id: 20240407081733.3231820-2-ruanjinjie@huawei.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
27
---
13
target/arm/cpu-features.h | 5 +++++
28
include/fpu/softfloat-helpers.h | 11 +++
14
target/arm/helper.c | 8 +++++++-
29
include/fpu/softfloat-types.h | 55 +++++++++++
15
2 files changed, 12 insertions(+), 1 deletion(-)
30
fpu/softfloat-specialize.c.inc | 167 ++++++++------------------------
16
31
3 files changed, 107 insertions(+), 126 deletions(-)
17
diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h
32
33
diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h
18
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu-features.h
35
--- a/include/fpu/softfloat-helpers.h
20
+++ b/target/arm/cpu-features.h
36
+++ b/include/fpu/softfloat-helpers.h
21
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_sme(const ARMISARegisters *id)
37
@@ -XXX,XX +XXX,XX @@ static inline void set_float_2nan_prop_rule(Float2NaNPropRule rule,
22
return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SME) != 0;
38
status->float_2nan_prop_rule = rule;
23
}
39
}
24
40
25
+static inline bool isar_feature_aa64_nmi(const ARMISARegisters *id)
41
+static inline void set_float_3nan_prop_rule(Float3NaNPropRule rule,
42
+ float_status *status)
26
+{
43
+{
27
+ return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, NMI) != 0;
44
+ status->float_3nan_prop_rule = rule;
28
+}
45
+}
29
+
46
+
30
static inline bool isar_feature_aa64_tgran4_lpa2(const ARMISARegisters *id)
47
static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule,
48
float_status *status)
31
{
49
{
32
return FIELD_SEX64(id->id_aa64mmfr0, ID_AA64MMFR0, TGRAN4) >= 1;
50
@@ -XXX,XX +XXX,XX @@ static inline Float2NaNPropRule get_float_2nan_prop_rule(float_status *status)
33
diff --git a/target/arm/helper.c b/target/arm/helper.c
51
return status->float_2nan_prop_rule;
52
}
53
54
+static inline Float3NaNPropRule get_float_3nan_prop_rule(float_status *status)
55
+{
56
+ return status->float_3nan_prop_rule;
57
+}
58
+
59
static inline FloatInfZeroNaNRule get_float_infzeronan_rule(float_status *status)
60
{
61
return status->float_infzeronan_rule;
62
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
34
index XXXXXXX..XXXXXXX 100644
63
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/helper.c
64
--- a/include/fpu/softfloat-types.h
36
+++ b/target/arm/helper.c
65
+++ b/include/fpu/softfloat-types.h
37
@@ -XXX,XX +XXX,XX @@ bool el_is_in_host(CPUARMState *env, int el)
66
@@ -XXX,XX +XXX,XX @@ this code that are retained.
38
static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri,
67
#ifndef SOFTFLOAT_TYPES_H
39
uint64_t value)
68
#define SOFTFLOAT_TYPES_H
69
70
+#include "hw/registerfields.h"
71
+
72
/*
73
* Software IEC/IEEE floating-point types.
74
*/
75
@@ -XXX,XX +XXX,XX @@ typedef enum __attribute__((__packed__)) {
76
float_2nan_prop_x87,
77
} Float2NaNPropRule;
78
79
+/*
80
+ * 3-input NaN propagation rule, for fused multiply-add. Individual
81
+ * architectures have different rules for which input NaN is
82
+ * propagated to the output when there is more than one NaN on the
83
+ * input.
84
+ *
85
+ * If default_nan_mode is enabled then it is valid not to set a NaN
86
+ * propagation rule, because the softfloat code guarantees not to try
87
+ * to pick a NaN to propagate in default NaN mode. When not in
88
+ * default-NaN mode, it is an error for the target not to set the rule
89
+ * in float_status if it uses a muladd, and we will assert if we need
90
+ * to handle an input NaN and no rule was selected.
91
+ *
92
+ * The naming scheme for Float3NaNPropRule values is:
93
+ * float_3nan_prop_s_abc:
94
+ * = "Prefer SNaN over QNaN, then operand A over B over C"
95
+ * float_3nan_prop_abc:
96
+ * = "Prefer A over B over C regardless of SNaN vs QNAN"
97
+ *
98
+ * For QEMU, the multiply-add operation is A * B + C.
99
+ */
100
+
101
+/*
102
+ * We set the Float3NaNPropRule enum values up so we can select the
103
+ * right value in pickNaNMulAdd in a data driven way.
104
+ */
105
+FIELD(3NAN, 1ST, 0, 2) /* which operand is most preferred ? */
106
+FIELD(3NAN, 2ND, 2, 2) /* which operand is next most preferred ? */
107
+FIELD(3NAN, 3RD, 4, 2) /* which operand is least preferred ? */
108
+FIELD(3NAN, SNAN, 6, 1) /* do we prefer SNaN over QNaN ? */
109
+
110
+#define PROPRULE(X, Y, Z) \
111
+ ((X << R_3NAN_1ST_SHIFT) | (Y << R_3NAN_2ND_SHIFT) | (Z << R_3NAN_3RD_SHIFT))
112
+
113
+typedef enum __attribute__((__packed__)) {
114
+ float_3nan_prop_none = 0, /* No propagation rule specified */
115
+ float_3nan_prop_abc = PROPRULE(0, 1, 2),
116
+ float_3nan_prop_acb = PROPRULE(0, 2, 1),
117
+ float_3nan_prop_bac = PROPRULE(1, 0, 2),
118
+ float_3nan_prop_bca = PROPRULE(1, 2, 0),
119
+ float_3nan_prop_cab = PROPRULE(2, 0, 1),
120
+ float_3nan_prop_cba = PROPRULE(2, 1, 0),
121
+ float_3nan_prop_s_abc = float_3nan_prop_abc | R_3NAN_SNAN_MASK,
122
+ float_3nan_prop_s_acb = float_3nan_prop_acb | R_3NAN_SNAN_MASK,
123
+ float_3nan_prop_s_bac = float_3nan_prop_bac | R_3NAN_SNAN_MASK,
124
+ float_3nan_prop_s_bca = float_3nan_prop_bca | R_3NAN_SNAN_MASK,
125
+ float_3nan_prop_s_cab = float_3nan_prop_cab | R_3NAN_SNAN_MASK,
126
+ float_3nan_prop_s_cba = float_3nan_prop_cba | R_3NAN_SNAN_MASK,
127
+} Float3NaNPropRule;
128
+
129
+#undef PROPRULE
130
+
131
/*
132
* Rule for result of fused multiply-add 0 * Inf + NaN.
133
* This must be a NaN, but implementations differ on whether this
134
@@ -XXX,XX +XXX,XX @@ typedef struct float_status {
135
FloatRoundMode float_rounding_mode;
136
FloatX80RoundPrec floatx80_rounding_precision;
137
Float2NaNPropRule float_2nan_prop_rule;
138
+ Float3NaNPropRule float_3nan_prop_rule;
139
FloatInfZeroNaNRule float_infzeronan_rule;
140
bool tininess_before_rounding;
141
/* should denormalised results go to zero and set the inexact flag? */
142
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
143
index XXXXXXX..XXXXXXX 100644
144
--- a/fpu/softfloat-specialize.c.inc
145
+++ b/fpu/softfloat-specialize.c.inc
146
@@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
147
static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
148
bool infzero, bool have_snan, float_status *status)
40
{
149
{
41
+ ARMCPU *cpu = env_archcpu(env);
150
+ FloatClass cls[3] = { a_cls, b_cls, c_cls };
42
uint64_t valid_mask = 0;
151
+ Float3NaNPropRule rule = status->float_3nan_prop_rule;
43
152
+ int which;
44
/* FEAT_MOPS adds MSCEn and MCE2 */
153
+
45
- if (cpu_isar_feature(aa64_mops, env_archcpu(env))) {
154
/*
46
+ if (cpu_isar_feature(aa64_mops, cpu)) {
155
* We guarantee not to require the target to tell us how to
47
valid_mask |= HCRX_MSCEN | HCRX_MCE2;
156
* pick a NaN if we're always returning the default NaN.
157
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
158
}
48
}
159
}
49
160
50
+ /* FEAT_NMI adds TALLINT, VINMI and VFNMI */
161
+ if (rule == float_3nan_prop_none) {
51
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
162
#if defined(TARGET_ARM)
52
+ valid_mask |= HCRX_TALLINT | HCRX_VINMI | HCRX_VFNMI;
163
-
164
- /* This looks different from the ARM ARM pseudocode, because the ARM ARM
165
- * puts the operands to a fused mac operation (a*b)+c in the order c,a,b.
166
- */
167
- if (is_snan(c_cls)) {
168
- return 2;
169
- } else if (is_snan(a_cls)) {
170
- return 0;
171
- } else if (is_snan(b_cls)) {
172
- return 1;
173
- } else if (is_qnan(c_cls)) {
174
- return 2;
175
- } else if (is_qnan(a_cls)) {
176
- return 0;
177
- } else {
178
- return 1;
179
- }
180
+ /*
181
+ * This looks different from the ARM ARM pseudocode, because the ARM ARM
182
+ * puts the operands to a fused mac operation (a*b)+c in the order c,a,b
183
+ */
184
+ rule = float_3nan_prop_s_cab;
185
#elif defined(TARGET_MIPS)
186
- if (snan_bit_is_one(status)) {
187
- /* Prefer sNaN over qNaN, in the a, b, c order. */
188
- if (is_snan(a_cls)) {
189
- return 0;
190
- } else if (is_snan(b_cls)) {
191
- return 1;
192
- } else if (is_snan(c_cls)) {
193
- return 2;
194
- } else if (is_qnan(a_cls)) {
195
- return 0;
196
- } else if (is_qnan(b_cls)) {
197
- return 1;
198
+ if (snan_bit_is_one(status)) {
199
+ rule = float_3nan_prop_s_abc;
200
} else {
201
- return 2;
202
+ rule = float_3nan_prop_s_cab;
203
}
204
- } else {
205
- /* Prefer sNaN over qNaN, in the c, a, b order. */
206
- if (is_snan(c_cls)) {
207
- return 2;
208
- } else if (is_snan(a_cls)) {
209
- return 0;
210
- } else if (is_snan(b_cls)) {
211
- return 1;
212
- } else if (is_qnan(c_cls)) {
213
- return 2;
214
- } else if (is_qnan(a_cls)) {
215
- return 0;
216
- } else {
217
- return 1;
218
- }
219
- }
220
#elif defined(TARGET_LOONGARCH64)
221
- /* Prefer sNaN over qNaN, in the c, a, b order. */
222
- if (is_snan(c_cls)) {
223
- return 2;
224
- } else if (is_snan(a_cls)) {
225
- return 0;
226
- } else if (is_snan(b_cls)) {
227
- return 1;
228
- } else if (is_qnan(c_cls)) {
229
- return 2;
230
- } else if (is_qnan(a_cls)) {
231
- return 0;
232
- } else {
233
- return 1;
234
- }
235
+ rule = float_3nan_prop_s_cab;
236
#elif defined(TARGET_PPC)
237
- /* If fRA is a NaN return it; otherwise if fRB is a NaN return it;
238
- * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
239
- */
240
- if (is_nan(a_cls)) {
241
- return 0;
242
- } else if (is_nan(c_cls)) {
243
- return 2;
244
- } else {
245
- return 1;
246
- }
247
+ /*
248
+ * If fRA is a NaN return it; otherwise if fRB is a NaN return it;
249
+ * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
250
+ */
251
+ rule = float_3nan_prop_acb;
252
#elif defined(TARGET_S390X)
253
- if (is_snan(a_cls)) {
254
- return 0;
255
- } else if (is_snan(b_cls)) {
256
- return 1;
257
- } else if (is_snan(c_cls)) {
258
- return 2;
259
- } else if (is_qnan(a_cls)) {
260
- return 0;
261
- } else if (is_qnan(b_cls)) {
262
- return 1;
263
- } else {
264
- return 2;
265
- }
266
+ rule = float_3nan_prop_s_abc;
267
#elif defined(TARGET_SPARC)
268
- /* Prefer SNaN over QNaN, order C, B, A. */
269
- if (is_snan(c_cls)) {
270
- return 2;
271
- } else if (is_snan(b_cls)) {
272
- return 1;
273
- } else if (is_snan(a_cls)) {
274
- return 0;
275
- } else if (is_qnan(c_cls)) {
276
- return 2;
277
- } else if (is_qnan(b_cls)) {
278
- return 1;
279
- } else {
280
- return 0;
281
- }
282
+ rule = float_3nan_prop_s_cba;
283
#elif defined(TARGET_XTENSA)
284
- /*
285
- * For Xtensa, the (inf,zero,nan) case sets InvalidOp and returns
286
- * an input NaN if we have one (ie c).
287
- */
288
- if (status->use_first_nan) {
289
- if (is_nan(a_cls)) {
290
- return 0;
291
- } else if (is_nan(b_cls)) {
292
- return 1;
293
+ if (status->use_first_nan) {
294
+ rule = float_3nan_prop_abc;
295
} else {
296
- return 2;
297
+ rule = float_3nan_prop_cba;
298
}
299
- } else {
300
- if (is_nan(c_cls)) {
301
- return 2;
302
- } else if (is_nan(b_cls)) {
303
- return 1;
304
- } else {
305
- return 0;
306
- }
307
- }
308
#else
309
- /* A default implementation: prefer a to b to c.
310
- * This is unlikely to actually match any real implementation.
311
- */
312
- if (is_nan(a_cls)) {
313
- return 0;
314
- } else if (is_nan(b_cls)) {
315
- return 1;
316
- } else {
317
- return 2;
318
- }
319
+ rule = float_3nan_prop_abc;
320
#endif
53
+ }
321
+ }
54
+
322
+
55
/* Clear RES0 bits. */
323
+ assert(rule != float_3nan_prop_none);
56
env->cp15.hcrx_el2 = value & valid_mask;
324
+ if (have_snan && (rule & R_3NAN_SNAN_MASK)) {
325
+ /* We have at least one SNaN input and should prefer it */
326
+ do {
327
+ which = rule & R_3NAN_1ST_MASK;
328
+ rule >>= R_3NAN_1ST_LENGTH;
329
+ } while (!is_snan(cls[which]));
330
+ } else {
331
+ do {
332
+ which = rule & R_3NAN_1ST_MASK;
333
+ rule >>= R_3NAN_1ST_LENGTH;
334
+ } while (!is_nan(cls[which]));
335
+ }
336
+ return which;
57
}
337
}
338
339
/*----------------------------------------------------------------------------
58
--
340
--
59
2.34.1
341
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
Explicitly set a rule in the softfloat tests for propagating NaNs in
2
the muladd case. In meson.build we put -DTARGET_ARM in fpcflags, and
3
so we should select here the Arm rule of float_3nan_prop_s_cab.
2
4
3
Enable FEAT_NMI on the 'max' CPU.
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20241202131347.498124-17-peter.maydell@linaro.org
8
Message-id: 20240407081733.3231820-24-ruanjinjie@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
8
---
11
docs/system/arm/emulation.rst | 1 +
9
tests/fp/fp-bench.c | 1 +
12
target/arm/tcg/cpu64.c | 1 +
10
tests/fp/fp-test.c | 1 +
13
2 files changed, 2 insertions(+)
11
2 files changed, 2 insertions(+)
14
12
15
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
13
diff --git a/tests/fp/fp-bench.c b/tests/fp/fp-bench.c
16
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
17
--- a/docs/system/arm/emulation.rst
15
--- a/tests/fp/fp-bench.c
18
+++ b/docs/system/arm/emulation.rst
16
+++ b/tests/fp/fp-bench.c
19
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
17
@@ -XXX,XX +XXX,XX @@ static void run_bench(void)
20
- FEAT_MTE (Memory Tagging Extension)
18
* doesn't specify match those used by the Arm architecture.
21
- FEAT_MTE2 (Memory Tagging Extension)
19
*/
22
- FEAT_MTE3 (MTE Asymmetric Fault Handling)
20
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &soft_status);
23
+- FEAT_NMI (Non-maskable Interrupt)
21
+ set_float_3nan_prop_rule(float_3nan_prop_s_cab, &soft_status);
24
- FEAT_NV (Nested Virtualization)
22
set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &soft_status);
25
- FEAT_NV2 (Enhanced nested virtualization support)
23
26
- FEAT_PACIMP (Pointer authentication - IMPLEMENTATION DEFINED algorithm)
24
f = bench_funcs[operation][precision];
27
diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c
25
diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c
28
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/tcg/cpu64.c
27
--- a/tests/fp/fp-test.c
30
+++ b/target/arm/tcg/cpu64.c
28
+++ b/tests/fp/fp-test.c
31
@@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj)
29
@@ -XXX,XX +XXX,XX @@ void run_test(void)
32
t = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT_DoubleFault */
30
* doesn't specify match those used by the Arm architecture.
33
t = FIELD_DP64(t, ID_AA64PFR1, SME, 1); /* FEAT_SME */
31
*/
34
t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */
32
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf);
35
+ t = FIELD_DP64(t, ID_AA64PFR1, NMI, 1); /* FEAT_NMI */
33
+ set_float_3nan_prop_rule(float_3nan_prop_s_cab, &qsf);
36
cpu->isar.id_aa64pfr1 = t;
34
set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &qsf);
37
35
38
t = cpu->isar.id_aa64mmfr0;
36
genCases_setLevel(test_level);
39
--
37
--
40
2.34.1
38
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
Set the Float3NaNPropRule explicitly for Arm, and remove the
2
ifdef from pickNaNMulAdd().
2
3
3
This only implements the external delivery method via the GICv3.
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-18-peter.maydell@linaro.org
7
---
8
target/arm/cpu.c | 5 +++++
9
fpu/softfloat-specialize.c.inc | 8 +-------
10
2 files changed, 6 insertions(+), 7 deletions(-)
4
11
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
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/cpu-qom.h | 5 +-
12
target/arm/cpu.h | 6 ++
13
target/arm/internals.h | 18 +++++
14
target/arm/cpu.c | 147 ++++++++++++++++++++++++++++++++++++++---
15
target/arm/helper.c | 33 +++++++--
16
5 files changed, 193 insertions(+), 16 deletions(-)
17
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
38
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
39
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/cpu.h
41
+++ b/target/arm/cpu.h
42
@@ -XXX,XX +XXX,XX @@
43
#define EXCP_DIVBYZERO 23 /* v7M DIVBYZERO UsageFault */
44
#define EXCP_VSERR 24
45
#define EXCP_GPC 25 /* v9 Granule Protection Check Fault */
46
+#define EXCP_NMI 26
47
+#define EXCP_VINMI 27
48
+#define EXCP_VFNMI 28
49
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
50
51
#define ARMV7M_EXCP_RESET 1
52
@@ -XXX,XX +XXX,XX @@
53
#define CPU_INTERRUPT_VIRQ CPU_INTERRUPT_TGT_EXT_2
54
#define CPU_INTERRUPT_VFIQ CPU_INTERRUPT_TGT_EXT_3
55
#define CPU_INTERRUPT_VSERR CPU_INTERRUPT_TGT_INT_0
56
+#define CPU_INTERRUPT_NMI CPU_INTERRUPT_TGT_EXT_4
57
+#define CPU_INTERRUPT_VINMI CPU_INTERRUPT_TGT_EXT_0
58
+#define CPU_INTERRUPT_VFNMI CPU_INTERRUPT_TGT_INT_1
59
60
/* The usual mapping for an AArch64 system register to its AArch32
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
63
index XXXXXXX..XXXXXXX 100644
64
--- a/target/arm/internals.h
65
+++ b/target/arm/internals.h
66
@@ -XXX,XX +XXX,XX @@ void arm_cpu_update_virq(ARMCPU *cpu);
67
*/
68
void arm_cpu_update_vfiq(ARMCPU *cpu);
69
70
+/**
71
+ * arm_cpu_update_vinmi: Update CPU_INTERRUPT_VINMI bit in cs->interrupt_request
72
+ *
73
+ * Update the CPU_INTERRUPT_VINMI bit in cs->interrupt_request, following
74
+ * a change to either the input VNMI line from the GIC or the HCRX_EL2.VINMI.
75
+ * Must be called with the BQL held.
76
+ */
77
+void arm_cpu_update_vinmi(ARMCPU *cpu);
78
+
79
+/**
80
+ * arm_cpu_update_vfnmi: Update CPU_INTERRUPT_VFNMI bit in cs->interrupt_request
81
+ *
82
+ * Update the CPU_INTERRUPT_VFNMI bit in cs->interrupt_request, following
83
+ * a change to the HCRX_EL2.VFNMI.
84
+ * Must be called with the BQL held.
85
+ */
86
+void arm_cpu_update_vfnmi(ARMCPU *cpu);
87
+
88
/**
89
* arm_cpu_update_vserr: Update CPU_INTERRUPT_VSERR bit
90
*
91
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
12
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
92
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
93
--- a/target/arm/cpu.c
14
--- a/target/arm/cpu.c
94
+++ b/target/arm/cpu.c
15
+++ b/target/arm/cpu.c
95
@@ -XXX,XX +XXX,XX @@ void arm_restore_state_to_opc(CPUState *cs,
16
@@ -XXX,XX +XXX,XX @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
17
* * tininess-before-rounding
18
* * 2-input NaN propagation prefers SNaN over QNaN, and then
19
* operand A over operand B (see FPProcessNaNs() pseudocode)
20
+ * * 3-input NaN propagation prefers SNaN over QNaN, and then
21
+ * operand C over A over B (see FPProcessNaNs3() pseudocode,
22
+ * but note that for QEMU muladd is a * b + c, whereas for
23
+ * the pseudocode function the arguments are in the order c, a, b.
24
* * 0 * Inf + NaN returns the default NaN if the input NaN is quiet,
25
* and the input NaN if it is signalling
26
*/
27
@@ -XXX,XX +XXX,XX @@ static void arm_set_default_fp_behaviours(float_status *s)
28
{
29
set_float_detect_tininess(float_tininess_before_rounding, s);
30
set_float_2nan_prop_rule(float_2nan_prop_s_ab, s);
31
+ set_float_3nan_prop_rule(float_3nan_prop_s_cab, s);
32
set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, s);
96
}
33
}
97
#endif /* CONFIG_TCG */
34
98
35
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
99
+/*
36
index XXXXXXX..XXXXXXX 100644
100
+ * With SCTLR_ELx.NMI == 0, IRQ with Superpriority is masked identically with
37
--- a/fpu/softfloat-specialize.c.inc
101
+ * IRQ without Superpriority. Moreover, if the GIC is configured so that
38
+++ b/fpu/softfloat-specialize.c.inc
102
+ * FEAT_GICv3_NMI is only set if FEAT_NMI is set, then we won't ever see
39
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
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
}
40
}
128
41
129
+ if (cpu_isar_feature(aa64_nmi, env_archcpu(env)) &&
42
if (rule == float_3nan_prop_none) {
130
+ env->cp15.sctlr_el[target_el] & SCTLR_NMI && cur_el == target_el) {
43
-#if defined(TARGET_ARM)
131
+ allIntMask = env->pstate & PSTATE_ALLINT ||
44
- /*
132
+ ((env->cp15.sctlr_el[target_el] & SCTLR_SPINTMASK) &&
45
- * This looks different from the ARM ARM pseudocode, because the ARM ARM
133
+ (env->pstate & PSTATE_SP));
46
- * puts the operands to a fused mac operation (a*b)+c in the order c,a,b
134
+ }
47
- */
135
+
48
- rule = float_3nan_prop_s_cab;
136
switch (excp_idx) {
49
-#elif defined(TARGET_MIPS)
137
+ case EXCP_NMI:
50
+#if defined(TARGET_MIPS)
138
+ pstate_unmasked = !allIntMask;
51
if (snan_bit_is_one(status)) {
139
+ break;
52
rule = float_3nan_prop_s_abc;
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 {
53
} 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,
340
diff --git a/target/arm/helper.c b/target/arm/helper.c
341
index XXXXXXX..XXXXXXX 100644
342
--- a/target/arm/helper.c
343
+++ b/target/arm/helper.c
344
@@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
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
+ }
365
}
366
367
static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
368
@@ -XXX,XX +XXX,XX @@ static void hcrx_write(CPUARMState *env, const ARMCPRegInfo *ri,
369
370
/* Clear RES0 bits. */
371
env->cp15.hcrx_el2 = value & valid_mask;
372
+
373
+ /*
374
+ * Updates to VINMI and VFNMI require us to update the status of
375
+ * virtual NMI, which are the logical OR of these bits
376
+ * and the state of the input lines from the GIC. (This requires
377
+ * that we have the BQL, which is done by marking the
378
+ * reginfo structs as ARM_CP_IO.)
379
+ * Note that if a write to HCRX pends a VINMI or VFNMI it is never
380
+ * possible for it to be taken immediately, because VINMI and
381
+ * VFNMI are masked unless running at EL0 or EL1, and HCRX
382
+ * can only be written at EL2.
383
+ */
384
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
385
+ g_assert(bql_locked());
386
+ arm_cpu_update_vinmi(cpu);
387
+ arm_cpu_update_vfnmi(cpu);
388
+ }
389
}
390
391
static CPAccessResult access_hxen(CPUARMState *env, const ARMCPRegInfo *ri,
392
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_hxen(CPUARMState *env, const ARMCPRegInfo *ri,
393
394
static const ARMCPRegInfo hcrx_el2_reginfo = {
395
.name = "HCRX_EL2", .state = ARM_CP_STATE_AA64,
396
+ .type = ARM_CP_IO,
397
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 2,
398
.access = PL2_RW, .writefn = hcrx_write, .accessfn = access_hxen,
399
.nv2_redirect_offset = 0xa0,
400
@@ -XXX,XX +XXX,XX @@ void arm_log_exception(CPUState *cs)
401
[EXCP_DIVBYZERO] = "v7M DIVBYZERO UsageFault",
402
[EXCP_VSERR] = "Virtual SERR",
403
[EXCP_GPC] = "Granule Protection Check",
404
+ [EXCP_NMI] = "NMI",
405
+ [EXCP_VINMI] = "Virtual IRQ NMI",
406
+ [EXCP_VFNMI] = "Virtual FIQ NMI",
407
};
408
409
if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
410
--
54
--
411
2.34.1
55
2.34.1
diff view generated by jsdifflib
New patch
1
Set the Float3NaNPropRule explicitly for loongarch, and remove the
2
ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-19-peter.maydell@linaro.org
7
---
8
target/loongarch/tcg/fpu_helper.c | 1 +
9
fpu/softfloat-specialize.c.inc | 2 --
10
2 files changed, 1 insertion(+), 2 deletions(-)
11
12
diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/loongarch/tcg/fpu_helper.c
15
+++ b/target/loongarch/tcg/fpu_helper.c
16
@@ -XXX,XX +XXX,XX @@ void restore_fp_status(CPULoongArchState *env)
17
* case sets InvalidOp and returns the input value 'c'
18
*/
19
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
20
+ set_float_3nan_prop_rule(float_3nan_prop_s_cab, &env->fp_status);
21
}
22
23
int ieee_ex_to_loongarch(int xcpt)
24
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
25
index XXXXXXX..XXXXXXX 100644
26
--- a/fpu/softfloat-specialize.c.inc
27
+++ b/fpu/softfloat-specialize.c.inc
28
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
29
} else {
30
rule = float_3nan_prop_s_cab;
31
}
32
-#elif defined(TARGET_LOONGARCH64)
33
- rule = float_3nan_prop_s_cab;
34
#elif defined(TARGET_PPC)
35
/*
36
* If fRA is a NaN return it; otherwise if fRB is a NaN return it;
37
--
38
2.34.1
diff view generated by jsdifflib
New patch
1
Set the Float3NaNPropRule explicitly for PPC, and remove the
2
ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-20-peter.maydell@linaro.org
7
---
8
target/ppc/cpu_init.c | 8 ++++++++
9
fpu/softfloat-specialize.c.inc | 6 ------
10
2 files changed, 8 insertions(+), 6 deletions(-)
11
12
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/ppc/cpu_init.c
15
+++ b/target/ppc/cpu_init.c
16
@@ -XXX,XX +XXX,XX @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type)
17
*/
18
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status);
19
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->vec_status);
20
+ /*
21
+ * NaN propagation for fused multiply-add:
22
+ * if fRA is a NaN return it; otherwise if fRB is a NaN return it;
23
+ * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
24
+ * whereas QEMU labels the operands as (a * b) + c.
25
+ */
26
+ set_float_3nan_prop_rule(float_3nan_prop_acb, &env->fp_status);
27
+ set_float_3nan_prop_rule(float_3nan_prop_acb, &env->vec_status);
28
/*
29
* For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
30
* to return an input NaN if we have one (ie c) rather than generating
31
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
32
index XXXXXXX..XXXXXXX 100644
33
--- a/fpu/softfloat-specialize.c.inc
34
+++ b/fpu/softfloat-specialize.c.inc
35
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
36
} else {
37
rule = float_3nan_prop_s_cab;
38
}
39
-#elif defined(TARGET_PPC)
40
- /*
41
- * If fRA is a NaN return it; otherwise if fRB is a NaN return it;
42
- * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
43
- */
44
- rule = float_3nan_prop_acb;
45
#elif defined(TARGET_S390X)
46
rule = float_3nan_prop_s_abc;
47
#elif defined(TARGET_SPARC)
48
--
49
2.34.1
diff view generated by jsdifflib
New patch
1
Set the Float3NaNPropRule explicitly for s390x, and remove the
2
ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-21-peter.maydell@linaro.org
7
---
8
target/s390x/cpu.c | 1 +
9
fpu/softfloat-specialize.c.inc | 2 --
10
2 files changed, 1 insertion(+), 2 deletions(-)
11
12
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/s390x/cpu.c
15
+++ b/target/s390x/cpu.c
16
@@ -XXX,XX +XXX,XX @@ static void s390_cpu_reset_hold(Object *obj, ResetType type)
17
set_float_detect_tininess(float_tininess_before_rounding,
18
&env->fpu_status);
19
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fpu_status);
20
+ set_float_3nan_prop_rule(float_3nan_prop_s_abc, &env->fpu_status);
21
set_float_infzeronan_rule(float_infzeronan_dnan_always,
22
&env->fpu_status);
23
/* fall through */
24
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
25
index XXXXXXX..XXXXXXX 100644
26
--- a/fpu/softfloat-specialize.c.inc
27
+++ b/fpu/softfloat-specialize.c.inc
28
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
29
} else {
30
rule = float_3nan_prop_s_cab;
31
}
32
-#elif defined(TARGET_S390X)
33
- rule = float_3nan_prop_s_abc;
34
#elif defined(TARGET_SPARC)
35
rule = float_3nan_prop_s_cba;
36
#elif defined(TARGET_XTENSA)
37
--
38
2.34.1
diff view generated by jsdifflib
New patch
1
Set the Float3NaNPropRule explicitly for SPARC, and remove the
2
ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-22-peter.maydell@linaro.org
7
---
8
target/sparc/cpu.c | 2 ++
9
fpu/softfloat-specialize.c.inc | 2 --
10
2 files changed, 2 insertions(+), 2 deletions(-)
11
12
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/sparc/cpu.c
15
+++ b/target/sparc/cpu.c
16
@@ -XXX,XX +XXX,XX @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
17
* the CPU state struct so it won't get zeroed on reset.
18
*/
19
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &env->fp_status);
20
+ /* For fused-multiply add, prefer SNaN over QNaN, then C->B->A */
21
+ set_float_3nan_prop_rule(float_3nan_prop_s_cba, &env->fp_status);
22
/* For inf * 0 + NaN, return the input NaN */
23
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
24
25
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
26
index XXXXXXX..XXXXXXX 100644
27
--- a/fpu/softfloat-specialize.c.inc
28
+++ b/fpu/softfloat-specialize.c.inc
29
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
30
} else {
31
rule = float_3nan_prop_s_cab;
32
}
33
-#elif defined(TARGET_SPARC)
34
- rule = float_3nan_prop_s_cba;
35
#elif defined(TARGET_XTENSA)
36
if (status->use_first_nan) {
37
rule = float_3nan_prop_abc;
38
--
39
2.34.1
diff view generated by jsdifflib
New patch
1
Set the Float3NaNPropRule explicitly for Arm, and remove the
2
ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-23-peter.maydell@linaro.org
7
---
8
target/mips/fpu_helper.h | 4 ++++
9
target/mips/msa.c | 3 +++
10
fpu/softfloat-specialize.c.inc | 8 +-------
11
3 files changed, 8 insertions(+), 7 deletions(-)
12
13
diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/mips/fpu_helper.h
16
+++ b/target/mips/fpu_helper.h
17
@@ -XXX,XX +XXX,XX @@ static inline void restore_snan_bit_mode(CPUMIPSState *env)
18
{
19
bool nan2008 = env->active_fpu.fcr31 & (1 << FCR31_NAN2008);
20
FloatInfZeroNaNRule izn_rule;
21
+ Float3NaNPropRule nan3_rule;
22
23
/*
24
* With nan2008, SNaNs are silenced in the usual way.
25
@@ -XXX,XX +XXX,XX @@ static inline void restore_snan_bit_mode(CPUMIPSState *env)
26
*/
27
izn_rule = nan2008 ? float_infzeronan_dnan_never : float_infzeronan_dnan_always;
28
set_float_infzeronan_rule(izn_rule, &env->active_fpu.fp_status);
29
+ nan3_rule = nan2008 ? float_3nan_prop_s_cab : float_3nan_prop_s_abc;
30
+ set_float_3nan_prop_rule(nan3_rule, &env->active_fpu.fp_status);
31
+
32
}
33
34
static inline void restore_fp_status(CPUMIPSState *env)
35
diff --git a/target/mips/msa.c b/target/mips/msa.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/target/mips/msa.c
38
+++ b/target/mips/msa.c
39
@@ -XXX,XX +XXX,XX @@ void msa_reset(CPUMIPSState *env)
40
set_float_2nan_prop_rule(float_2nan_prop_s_ab,
41
&env->active_tc.msa_fp_status);
42
43
+ set_float_3nan_prop_rule(float_3nan_prop_s_cab,
44
+ &env->active_tc.msa_fp_status);
45
+
46
/* clear float_status exception flags */
47
set_float_exception_flags(0, &env->active_tc.msa_fp_status);
48
49
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
50
index XXXXXXX..XXXXXXX 100644
51
--- a/fpu/softfloat-specialize.c.inc
52
+++ b/fpu/softfloat-specialize.c.inc
53
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
54
}
55
56
if (rule == float_3nan_prop_none) {
57
-#if defined(TARGET_MIPS)
58
- if (snan_bit_is_one(status)) {
59
- rule = float_3nan_prop_s_abc;
60
- } else {
61
- rule = float_3nan_prop_s_cab;
62
- }
63
-#elif defined(TARGET_XTENSA)
64
+#if defined(TARGET_XTENSA)
65
if (status->use_first_nan) {
66
rule = float_3nan_prop_abc;
67
} else {
68
--
69
2.34.1
diff view generated by jsdifflib
New patch
1
Set the Float3NaNPropRule explicitly for xtensa, and remove the
2
ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-24-peter.maydell@linaro.org
7
---
8
target/xtensa/fpu_helper.c | 2 ++
9
fpu/softfloat-specialize.c.inc | 8 --------
10
2 files changed, 2 insertions(+), 8 deletions(-)
11
12
diff --git a/target/xtensa/fpu_helper.c b/target/xtensa/fpu_helper.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/xtensa/fpu_helper.c
15
+++ b/target/xtensa/fpu_helper.c
16
@@ -XXX,XX +XXX,XX @@ void xtensa_use_first_nan(CPUXtensaState *env, bool use_first)
17
set_use_first_nan(use_first, &env->fp_status);
18
set_float_2nan_prop_rule(use_first ? float_2nan_prop_ab : float_2nan_prop_ba,
19
&env->fp_status);
20
+ set_float_3nan_prop_rule(use_first ? float_3nan_prop_abc : float_3nan_prop_cba,
21
+ &env->fp_status);
22
}
23
24
void HELPER(wur_fpu2k_fcr)(CPUXtensaState *env, uint32_t v)
25
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
26
index XXXXXXX..XXXXXXX 100644
27
--- a/fpu/softfloat-specialize.c.inc
28
+++ b/fpu/softfloat-specialize.c.inc
29
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
30
}
31
32
if (rule == float_3nan_prop_none) {
33
-#if defined(TARGET_XTENSA)
34
- if (status->use_first_nan) {
35
- rule = float_3nan_prop_abc;
36
- } else {
37
- rule = float_3nan_prop_cba;
38
- }
39
-#else
40
rule = float_3nan_prop_abc;
41
-#endif
42
}
43
44
assert(rule != float_3nan_prop_none);
45
--
46
2.34.1
diff view generated by jsdifflib
New patch
1
Set the Float3NaNPropRule explicitly for i386. We had no
2
i386-specific behaviour in the old ifdef ladder, so we were using the
3
default "prefer a then b then c" fallback; this is actually the
4
correct per-the-spec handling for i386.
1
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20241202131347.498124-25-peter.maydell@linaro.org
9
---
10
target/i386/tcg/fpu_helper.c | 1 +
11
1 file changed, 1 insertion(+)
12
13
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/i386/tcg/fpu_helper.c
16
+++ b/target/i386/tcg/fpu_helper.c
17
@@ -XXX,XX +XXX,XX @@ void cpu_init_fp_statuses(CPUX86State *env)
18
* there are multiple input NaNs they are selected in the order a, b, c.
19
*/
20
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status);
21
+ set_float_3nan_prop_rule(float_3nan_prop_abc, &env->sse_status);
22
}
23
24
static inline uint8_t save_exception_flags(CPUX86State *env)
25
--
26
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
Set the Float3NaNPropRule explicitly for HPPA, and remove the
2
ifdef from pickNaNMulAdd().
2
3
3
Set or clear PSTATE.ALLINT on taking an exception to ELx according to the
4
HPPA is the only target that was using the default branch of the
4
SCTLR_ELx.SPINTMASK bit.
5
ifdef ladder (other targets either do not use muladd or set
6
default_nan_mode), so we can remove the ifdef fallback entirely now
7
(allowing the "rule not set" case to fall into the default of the
8
switch statement and assert).
5
9
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
10
We add a TODO note that the HPPA rule is probably wrong; this is
11
not a behavioural change for this refactoring.
12
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Message-id: 20241202131347.498124-26-peter.maydell@linaro.org
9
Message-id: 20240407081733.3231820-10-ruanjinjie@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
16
---
12
target/arm/helper.c | 8 ++++++++
17
target/hppa/fpu_helper.c | 8 ++++++++
13
1 file changed, 8 insertions(+)
18
fpu/softfloat-specialize.c.inc | 4 ----
19
2 files changed, 8 insertions(+), 4 deletions(-)
14
20
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
21
diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c
16
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
23
--- a/target/hppa/fpu_helper.c
18
+++ b/target/arm/helper.c
24
+++ b/target/hppa/fpu_helper.c
19
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
25
@@ -XXX,XX +XXX,XX @@ void HELPER(loaded_fr0)(CPUHPPAState *env)
26
* HPPA does note implement a CPU reset method at all...
27
*/
28
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status);
29
+ /*
30
+ * TODO: The HPPA architecture reference only documents its NaN
31
+ * propagation rule for 2-operand operations. Testing on real hardware
32
+ * might be necessary to confirm whether this order for muladd is correct.
33
+ * Not preferring the SNaN is almost certainly incorrect as it diverges
34
+ * from the documented rules for 2-operand operations.
35
+ */
36
+ set_float_3nan_prop_rule(float_3nan_prop_abc, &env->fp_status);
37
/* For inf * 0 + NaN, return the input NaN */
38
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
39
}
40
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
41
index XXXXXXX..XXXXXXX 100644
42
--- a/fpu/softfloat-specialize.c.inc
43
+++ b/fpu/softfloat-specialize.c.inc
44
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
20
}
45
}
21
}
46
}
22
47
23
+ if (cpu_isar_feature(aa64_nmi, cpu)) {
48
- if (rule == float_3nan_prop_none) {
24
+ if (!(env->cp15.sctlr_el[new_el] & SCTLR_SPINTMASK)) {
49
- rule = float_3nan_prop_abc;
25
+ new_mode |= PSTATE_ALLINT;
50
- }
26
+ } else {
51
-
27
+ new_mode &= ~PSTATE_ALLINT;
52
assert(rule != float_3nan_prop_none);
28
+ }
53
if (have_snan && (rule & R_3NAN_SNAN_MASK)) {
29
+ }
54
/* We have at least one SNaN input and should prefer it */
30
+
31
pstate_write(env, PSTATE_DAIF | new_mode);
32
env->aarch64 = true;
33
aarch64_restore_sp(env, new_el);
34
--
55
--
35
2.34.1
56
2.34.1
diff view generated by jsdifflib
New patch
1
The use_first_nan field in float_status was an xtensa-specific way to
2
select at runtime from two different NaN propagation rules. Now that
3
xtensa is using the target-agnostic NaN propagation rule selection
4
that we've just added, we can remove use_first_nan, because there is
5
no longer any code that reads it.
1
6
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20241202131347.498124-27-peter.maydell@linaro.org
10
---
11
include/fpu/softfloat-helpers.h | 5 -----
12
include/fpu/softfloat-types.h | 1 -
13
target/xtensa/fpu_helper.c | 1 -
14
3 files changed, 7 deletions(-)
15
16
diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/fpu/softfloat-helpers.h
19
+++ b/include/fpu/softfloat-helpers.h
20
@@ -XXX,XX +XXX,XX @@ static inline void set_snan_bit_is_one(bool val, float_status *status)
21
status->snan_bit_is_one = val;
22
}
23
24
-static inline void set_use_first_nan(bool val, float_status *status)
25
-{
26
- status->use_first_nan = val;
27
-}
28
-
29
static inline void set_no_signaling_nans(bool val, float_status *status)
30
{
31
status->no_signaling_nans = val;
32
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
33
index XXXXXXX..XXXXXXX 100644
34
--- a/include/fpu/softfloat-types.h
35
+++ b/include/fpu/softfloat-types.h
36
@@ -XXX,XX +XXX,XX @@ typedef struct float_status {
37
* softfloat-specialize.inc.c)
38
*/
39
bool snan_bit_is_one;
40
- bool use_first_nan;
41
bool no_signaling_nans;
42
/* should overflowed results subtract re_bias to its exponent? */
43
bool rebias_overflow;
44
diff --git a/target/xtensa/fpu_helper.c b/target/xtensa/fpu_helper.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/target/xtensa/fpu_helper.c
47
+++ b/target/xtensa/fpu_helper.c
48
@@ -XXX,XX +XXX,XX @@ static const struct {
49
50
void xtensa_use_first_nan(CPUXtensaState *env, bool use_first)
51
{
52
- set_use_first_nan(use_first, &env->fp_status);
53
set_float_2nan_prop_rule(use_first ? float_2nan_prop_ab : float_2nan_prop_ba,
54
&env->fp_status);
55
set_float_3nan_prop_rule(use_first ? float_3nan_prop_abc : float_3nan_prop_cba,
56
--
57
2.34.1
diff view generated by jsdifflib
1
We pass a ResetType argument to the Resettable class enter
1
Currently m68k_cpu_reset_hold() calls floatx80_default_nan(NULL)
2
phase method, but we don't pass it to hold and exit, even though
2
to get the NaN bit pattern to reset the FPU registers. This
3
the callsites have it readily available. This means that if
3
works because it happens that our implementation of
4
a device cared about the ResetType it would need to record it
4
floatx80_default_nan() doesn't actually look at the float_status
5
in the enter phase method to use later on. Pass the type to
5
pointer except for TARGET_MIPS. However, this isn't guaranteed,
6
all three of the phase methods to avoid having to do that.
6
and to be able to remove the ifdef in floatx80_default_nan()
7
we're going to need a real float_status here.
7
8
8
Commit created with
9
Rearrange m68k_cpu_reset_hold() so that we initialize env->fp_status
9
10
earlier, and thus can pass it to floatx80_default_nan().
10
for dir in hw target include; do \
11
spatch --macro-file scripts/cocci-macro-file.h \
12
--sp-file scripts/coccinelle/reset-type.cocci \
13
--keep-comments --smpl-spacing --in-place \
14
--include-headers --dir $dir; done
15
16
and no manual edits.
17
11
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
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>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Reviewed-by: Luc Michel <luc.michel@amd.com>
14
Message-id: 20241202131347.498124-28-peter.maydell@linaro.org
22
Message-id: 20240412160809.1260625-5-peter.maydell@linaro.org
23
---
15
---
24
include/hw/resettable.h | 4 ++--
16
target/m68k/cpu.c | 12 +++++++-----
25
hw/adc/npcm7xx_adc.c | 2 +-
17
1 file changed, 7 insertions(+), 5 deletions(-)
26
hw/arm/pxa2xx_pic.c | 2 +-
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(-)
119
18
120
diff --git a/include/hw/resettable.h b/include/hw/resettable.h
121
index XXXXXXX..XXXXXXX 100644
122
--- a/include/hw/resettable.h
123
+++ b/include/hw/resettable.h
124
@@ -XXX,XX +XXX,XX @@ typedef enum ResetType {
125
* the callback.
126
*/
127
typedef void (*ResettableEnterPhase)(Object *obj, ResetType type);
128
-typedef void (*ResettableHoldPhase)(Object *obj);
129
-typedef void (*ResettableExitPhase)(Object *obj);
130
+typedef void (*ResettableHoldPhase)(Object *obj, ResetType type);
131
+typedef void (*ResettableExitPhase)(Object *obj, ResetType type);
132
typedef ResettableState * (*ResettableGetState)(Object *obj);
133
typedef void (*ResettableTrFunction)(Object *obj);
134
typedef ResettableTrFunction (*ResettableGetTrFunction)(Object *obj);
135
diff --git a/hw/adc/npcm7xx_adc.c b/hw/adc/npcm7xx_adc.c
136
index XXXXXXX..XXXXXXX 100644
137
--- a/hw/adc/npcm7xx_adc.c
138
+++ b/hw/adc/npcm7xx_adc.c
139
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_adc_enter_reset(Object *obj, ResetType type)
140
npcm7xx_adc_reset(s);
141
}
142
143
-static void npcm7xx_adc_hold_reset(Object *obj)
144
+static void npcm7xx_adc_hold_reset(Object *obj, ResetType type)
145
{
146
NPCM7xxADCState *s = NPCM7XX_ADC(obj);
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
161
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
162
index XXXXXXX..XXXXXXX 100644
163
--- a/hw/arm/smmu-common.c
164
+++ b/hw/arm/smmu-common.c
165
@@ -XXX,XX +XXX,XX @@ static void smmu_base_realize(DeviceState *dev, Error **errp)
166
}
167
}
168
169
-static void smmu_base_reset_hold(Object *obj)
170
+static void smmu_base_reset_hold(Object *obj, ResetType type)
171
{
172
SMMUState *s = ARM_SMMU(obj);
173
174
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
175
index XXXXXXX..XXXXXXX 100644
176
--- a/hw/arm/smmuv3.c
177
+++ b/hw/arm/smmuv3.c
178
@@ -XXX,XX +XXX,XX @@ static void smmu_init_irq(SMMUv3State *s, SysBusDevice *dev)
179
}
180
}
181
182
-static void smmu_reset_hold(Object *obj)
183
+static void smmu_reset_hold(Object *obj, ResetType type)
184
{
185
SMMUv3State *s = ARM_SMMUV3(obj);
186
SMMUv3Class *c = ARM_SMMUV3_GET_CLASS(s);
187
188
if (c->parent_phases.hold) {
189
- c->parent_phases.hold(obj);
190
+ c->parent_phases.hold(obj, type);
191
}
192
193
smmuv3_init_regs(s);
194
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
195
index XXXXXXX..XXXXXXX 100644
196
--- a/hw/arm/stellaris.c
197
+++ b/hw/arm/stellaris.c
198
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_enter(Object *obj, ResetType type)
199
s->dcgc[0] = 1;
200
}
201
202
-static void stellaris_sys_reset_hold(Object *obj)
203
+static void stellaris_sys_reset_hold(Object *obj, ResetType type)
204
{
205
ssys_state *s = STELLARIS_SYS(obj);
206
207
@@ -XXX,XX +XXX,XX @@ static void stellaris_sys_reset_hold(Object *obj)
208
ssys_calculate_system_clock(s, true);
209
}
210
211
-static void stellaris_sys_reset_exit(Object *obj)
212
+static void stellaris_sys_reset_exit(Object *obj, ResetType type)
213
{
214
}
215
216
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_reset_enter(Object *obj, ResetType type)
217
i2c_end_transfer(s->bus);
218
}
219
220
-static void stellaris_i2c_reset_hold(Object *obj)
221
+static void stellaris_i2c_reset_hold(Object *obj, ResetType type)
222
{
223
stellaris_i2c_state *s = STELLARIS_I2C(obj);
224
225
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_reset_hold(Object *obj)
226
s->mcr = 0;
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
19
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
1563
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
1564
--- a/target/m68k/cpu.c
21
--- a/target/m68k/cpu.c
1565
+++ b/target/m68k/cpu.c
22
+++ b/target/m68k/cpu.c
1566
@@ -XXX,XX +XXX,XX @@ static void m68k_unset_feature(CPUM68KState *env, int feature)
23
@@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type)
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);
24
CPUState *cs = CPU(obj);
1574
M68kCPUClass *mcc = M68K_CPU_GET_CLASS(obj);
25
M68kCPUClass *mcc = M68K_CPU_GET_CLASS(obj);
1575
@@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj)
26
CPUM68KState *env = cpu_env(cs);
27
- floatx80 nan = floatx80_default_nan(NULL);
28
+ floatx80 nan;
1576
int i;
29
int i;
1577
30
1578
if (mcc->parent_phases.hold) {
31
if (mcc->parent_phases.hold) {
1579
- mcc->parent_phases.hold(obj);
32
@@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type)
1580
+ mcc->parent_phases.hold(obj, type);
33
#else
1581
}
34
cpu_m68k_set_sr(env, SR_S | SR_I);
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
35
#endif
1591
36
- for (i = 0; i < 8; i++) {
1592
-static void mb_cpu_reset_hold(Object *obj)
37
- env->fregs[i].d = nan;
1593
+static void mb_cpu_reset_hold(Object *obj, ResetType type)
38
- }
1594
{
39
- cpu_m68k_set_fpcr(env, 0);
1595
CPUState *cs = CPU(obj);
40
/*
1596
MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
41
* M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL
1597
@@ -XXX,XX +XXX,XX @@ static void mb_cpu_reset_hold(Object *obj)
42
* 3.4 FLOATING-POINT INSTRUCTION DETAILS
1598
CPUMBState *env = &cpu->env;
43
@@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type)
1599
44
* preceding paragraph for nonsignaling NaNs.
1600
if (mcc->parent_phases.hold) {
45
*/
1601
- mcc->parent_phases.hold(obj);
46
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status);
1602
+ mcc->parent_phases.hold(obj, type);
47
+
1603
}
48
+ nan = floatx80_default_nan(&env->fp_status);
1604
49
+ for (i = 0; i < 8; i++) {
1605
memset(env, 0, offsetof(CPUMBState, end_reset_fields));
50
+ env->fregs[i].d = nan;
1606
diff --git a/target/mips/cpu.c b/target/mips/cpu.c
51
+ }
1607
index XXXXXXX..XXXXXXX 100644
52
+ cpu_m68k_set_fpcr(env, 0);
1608
--- a/target/mips/cpu.c
53
env->fpsr = 0;
1609
+++ b/target/mips/cpu.c
54
1610
@@ -XXX,XX +XXX,XX @@ static int mips_cpu_mmu_index(CPUState *cs, bool ifunc)
55
/* TODO: We should set PC from the interrupt vector. */
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];
1799
--
56
--
1800
2.34.1
57
2.34.1
diff view generated by jsdifflib
New patch
1
We create our 128-bit default NaN by calling parts64_default_nan()
2
and then adjusting the result. We can do the same trick for creating
3
the floatx80 default NaN, which lets us drop a target ifdef.
1
4
5
floatx80 is used only by:
6
i386
7
m68k
8
arm nwfpe old floating-point emulation emulation support
9
(which is essentially dead, especially the parts involving floatx80)
10
PPC (only in the xsrqpxp instruction, which just rounds an input
11
value by converting to floatx80 and back, so will never generate
12
the default NaN)
13
14
The floatx80 default NaN as currently implemented is:
15
m68k: sign = 0, exp = 1...1, int = 1, frac = 1....1
16
i386: sign = 1, exp = 1...1, int = 1, frac = 10...0
17
18
These are the same as the parts64_default_nan for these architectures.
19
20
This is technically a possible behaviour change for arm linux-user
21
nwfpe emulation emulation, because the default NaN will now have the
22
sign bit clear. But we were already generating a different floatx80
23
default NaN from the real kernel emulation we are supposedly
24
following, which appears to use an all-bits-1 value:
25
https://elixir.bootlin.com/linux/v6.12/source/arch/arm/nwfpe/softfloat-specialize#L267
26
27
This won't affect the only "real" use of the nwfpe emulation, which
28
is ancient binaries that used it as part of the old floating point
29
calling convention; that only uses loads and stores of 32 and 64 bit
30
floats, not any of the floatx80 behaviour the original hardware had.
31
We also get the nwfpe float64 default NaN value wrong:
32
https://elixir.bootlin.com/linux/v6.12/source/arch/arm/nwfpe/softfloat-specialize#L166
33
so if we ever cared about this obscure corner the right fix would be
34
to correct that so nwfpe used its own default-NaN setting rather
35
than the Arm VFP one.
36
37
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
38
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
39
Message-id: 20241202131347.498124-29-peter.maydell@linaro.org
40
---
41
fpu/softfloat-specialize.c.inc | 20 ++++++++++----------
42
1 file changed, 10 insertions(+), 10 deletions(-)
43
44
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
45
index XXXXXXX..XXXXXXX 100644
46
--- a/fpu/softfloat-specialize.c.inc
47
+++ b/fpu/softfloat-specialize.c.inc
48
@@ -XXX,XX +XXX,XX @@ static void parts128_silence_nan(FloatParts128 *p, float_status *status)
49
floatx80 floatx80_default_nan(float_status *status)
50
{
51
floatx80 r;
52
+ /*
53
+ * Extrapolate from the choices made by parts64_default_nan to fill
54
+ * in the floatx80 format. We assume that floatx80's explicit
55
+ * integer bit is always set (this is true for i386 and m68k,
56
+ * which are the only real users of this format).
57
+ */
58
+ FloatParts64 p64;
59
+ parts64_default_nan(&p64, status);
60
61
- /* None of the targets that have snan_bit_is_one use floatx80. */
62
- assert(!snan_bit_is_one(status));
63
-#if defined(TARGET_M68K)
64
- r.low = UINT64_C(0xFFFFFFFFFFFFFFFF);
65
- r.high = 0x7FFF;
66
-#else
67
- /* X86 */
68
- r.low = UINT64_C(0xC000000000000000);
69
- r.high = 0xFFFF;
70
-#endif
71
+ r.high = 0x7FFF | (p64.sign << 15);
72
+ r.low = (1ULL << DECOMPOSED_BINARY_POINT) | p64.frac;
73
return r;
74
}
75
76
--
77
2.34.1
diff view generated by jsdifflib
New patch
1
In target/loongarch's helper_fclass_s() and helper_fclass_d() we pass
2
a zero-initialized float_status struct to float32_is_quiet_nan() and
3
float64_is_quiet_nan(), with the cryptic comment "for
4
snan_bit_is_one".
1
5
6
This pattern appears to have been copied from target/riscv, where it
7
is used because the functions there do not have ready access to the
8
CPU state struct. The comment presumably refers to the fact that the
9
main reason the is_quiet_nan() functions want the float_state is
10
because they want to know about the snan_bit_is_one config.
11
12
In the loongarch helpers, though, we have the CPU state struct
13
to hand. Use the usual env->fp_status here. This avoids our needing
14
to track that we need to update the initializer of the local
15
float_status structs when the core softfloat code adds new
16
options for targets to configure their behaviour.
17
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Message-id: 20241202131347.498124-30-peter.maydell@linaro.org
21
---
22
target/loongarch/tcg/fpu_helper.c | 6 ++----
23
1 file changed, 2 insertions(+), 4 deletions(-)
24
25
diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c
26
index XXXXXXX..XXXXXXX 100644
27
--- a/target/loongarch/tcg/fpu_helper.c
28
+++ b/target/loongarch/tcg/fpu_helper.c
29
@@ -XXX,XX +XXX,XX @@ uint64_t helper_fclass_s(CPULoongArchState *env, uint64_t fj)
30
} else if (float32_is_zero_or_denormal(f)) {
31
return sign ? 1 << 4 : 1 << 8;
32
} else if (float32_is_any_nan(f)) {
33
- float_status s = { }; /* for snan_bit_is_one */
34
- return float32_is_quiet_nan(f, &s) ? 1 << 1 : 1 << 0;
35
+ return float32_is_quiet_nan(f, &env->fp_status) ? 1 << 1 : 1 << 0;
36
} else {
37
return sign ? 1 << 3 : 1 << 7;
38
}
39
@@ -XXX,XX +XXX,XX @@ uint64_t helper_fclass_d(CPULoongArchState *env, uint64_t fj)
40
} else if (float64_is_zero_or_denormal(f)) {
41
return sign ? 1 << 4 : 1 << 8;
42
} else if (float64_is_any_nan(f)) {
43
- float_status s = { }; /* for snan_bit_is_one */
44
- return float64_is_quiet_nan(f, &s) ? 1 << 1 : 1 << 0;
45
+ return float64_is_quiet_nan(f, &env->fp_status) ? 1 << 1 : 1 << 0;
46
} else {
47
return sign ? 1 << 3 : 1 << 7;
48
}
49
--
50
2.34.1
diff view generated by jsdifflib
New patch
1
In the frem helper, we have a local float_status because we want to
2
execute the floatx80_div() with a custom rounding mode. Instead of
3
zero-initializing the local float_status and then having to set it up
4
with the m68k standard behaviour (including the NaN propagation rule
5
and copying the rounding precision from env->fp_status), initialize
6
it as a complete copy of env->fp_status. This will avoid our having
7
to add new code in this function for every new config knob we add
8
to fp_status.
1
9
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20241202131347.498124-31-peter.maydell@linaro.org
13
---
14
target/m68k/fpu_helper.c | 6 ++----
15
1 file changed, 2 insertions(+), 4 deletions(-)
16
17
diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/m68k/fpu_helper.c
20
+++ b/target/m68k/fpu_helper.c
21
@@ -XXX,XX +XXX,XX @@ void HELPER(frem)(CPUM68KState *env, FPReg *res, FPReg *val0, FPReg *val1)
22
23
fp_rem = floatx80_rem(val1->d, val0->d, &env->fp_status);
24
if (!floatx80_is_any_nan(fp_rem)) {
25
- float_status fp_status = { };
26
+ /* Use local temporary fp_status to set different rounding mode */
27
+ float_status fp_status = env->fp_status;
28
uint32_t quotient;
29
int sign;
30
31
/* Calculate quotient directly using round to nearest mode */
32
- set_float_2nan_prop_rule(float_2nan_prop_ab, &fp_status);
33
set_float_rounding_mode(float_round_nearest_even, &fp_status);
34
- set_floatx80_rounding_precision(
35
- get_floatx80_rounding_precision(&env->fp_status), &fp_status);
36
fp_quot.d = floatx80_div(val1->d, val0->d, &fp_status);
37
38
sign = extractFloatx80Sign(fp_quot.d);
39
--
40
2.34.1
diff view generated by jsdifflib
New patch
1
In cf_fpu_gdb_get_reg() and cf_fpu_gdb_set_reg() we do the conversion
2
from float64 to floatx80 using a scratch float_status, because we
3
don't want the conversion to affect the CPU's floating point exception
4
status. Currently we use a zero-initialized float_status. This will
5
get steadily more awkward as we add config knobs to float_status
6
that the target must initialize. Avoid having to add any of that
7
configuration here by instead initializing our local float_status
8
from the env->fp_status.
1
9
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20241202131347.498124-32-peter.maydell@linaro.org
13
---
14
target/m68k/helper.c | 6 ++++--
15
1 file changed, 4 insertions(+), 2 deletions(-)
16
17
diff --git a/target/m68k/helper.c b/target/m68k/helper.c
18
index XXXXXXX..XXXXXXX 100644
19
--- a/target/m68k/helper.c
20
+++ b/target/m68k/helper.c
21
@@ -XXX,XX +XXX,XX @@ static int cf_fpu_gdb_get_reg(CPUState *cs, GByteArray *mem_buf, int n)
22
CPUM68KState *env = &cpu->env;
23
24
if (n < 8) {
25
- float_status s = {};
26
+ /* Use scratch float_status so any exceptions don't change CPU state */
27
+ float_status s = env->fp_status;
28
return gdb_get_reg64(mem_buf, floatx80_to_float64(env->fregs[n].d, &s));
29
}
30
switch (n) {
31
@@ -XXX,XX +XXX,XX @@ static int cf_fpu_gdb_set_reg(CPUState *cs, uint8_t *mem_buf, int n)
32
CPUM68KState *env = &cpu->env;
33
34
if (n < 8) {
35
- float_status s = {};
36
+ /* Use scratch float_status so any exceptions don't change CPU state */
37
+ float_status s = env->fp_status;
38
env->fregs[n].d = float64_to_floatx80(ldq_be_p(mem_buf), &s);
39
return 8;
40
}
41
--
42
2.34.1
diff view generated by jsdifflib
1
Add the NMIAR CPU interface registers which deal with acknowledging NMI.
1
In the helper functions flcmps and flcmpd we use a scratch float_status
2
so that we don't change the CPU state if the comparison raises any
3
floating point exception flags. Instead of zero-initializing this
4
scratch float_status, initialize it as a copy of env->fp_status. This
5
avoids the need to explicitly initialize settings like the NaN
6
propagation rule or others we might add to softfloat in future.
2
7
3
When introduce NMI interrupt, there are some updates to the semantics for the
8
To do this we need to pass the CPU env pointer in to the helper.
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
9
10
And the APR and RPR has NMI bits which should be handled correctly.
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20241202131347.498124-33-peter.maydell@linaro.org
13
---
14
target/sparc/helper.h | 4 ++--
15
target/sparc/fop_helper.c | 8 ++++----
16
target/sparc/translate.c | 4 ++--
17
3 files changed, 8 insertions(+), 8 deletions(-)
11
18
12
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
19
diff --git a/target/sparc/helper.h b/target/sparc/helper.h
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
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
20
hw/intc/gicv3_internal.h | 5 +
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(-)
25
26
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
27
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/intc/gicv3_internal.h
21
--- a/target/sparc/helper.h
29
+++ b/hw/intc/gicv3_internal.h
22
+++ b/target/sparc/helper.h
30
@@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1)
23
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(fcmpd, TCG_CALL_NO_WG, i32, env, f64, f64)
31
#define ICC_CTLR_EL3_A3V (1U << 15)
24
DEF_HELPER_FLAGS_3(fcmped, TCG_CALL_NO_WG, i32, env, f64, f64)
32
#define ICC_CTLR_EL3_NDS (1U << 17)
25
DEF_HELPER_FLAGS_3(fcmpq, TCG_CALL_NO_WG, i32, env, i128, i128)
33
26
DEF_HELPER_FLAGS_3(fcmpeq, TCG_CALL_NO_WG, i32, env, i128, i128)
34
+#define ICC_AP1R_EL1_NMI (1ULL << 63)
27
-DEF_HELPER_FLAGS_2(flcmps, TCG_CALL_NO_RWG_SE, i32, f32, f32)
35
+#define ICC_RPR_EL1_NSNMI (1ULL << 62)
28
-DEF_HELPER_FLAGS_2(flcmpd, TCG_CALL_NO_RWG_SE, i32, f64, f64)
36
+#define ICC_RPR_EL1_NMI (1ULL << 63)
29
+DEF_HELPER_FLAGS_3(flcmps, TCG_CALL_NO_RWG_SE, i32, env, f32, f32)
37
+
30
+DEF_HELPER_FLAGS_3(flcmpd, TCG_CALL_NO_RWG_SE, i32, env, f64, f64)
38
#define ICH_VMCR_EL2_VENG0_SHIFT 0
31
DEF_HELPER_2(raise_exception, noreturn, env, int)
39
#define ICH_VMCR_EL2_VENG0 (1U << ICH_VMCR_EL2_VENG0_SHIFT)
32
40
#define ICH_VMCR_EL2_VENG1_SHIFT 1
33
DEF_HELPER_FLAGS_3(faddd, TCG_CALL_NO_WG, f64, env, f64, f64)
41
@@ -XXX,XX +XXX,XX @@ FIELD(VTE, RDBASE, 42, RDBASE_PROCNUM_LENGTH)
34
diff --git a/target/sparc/fop_helper.c b/target/sparc/fop_helper.c
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
35
index XXXXXXX..XXXXXXX 100644
51
--- a/include/hw/intc/arm_gicv3_common.h
36
--- a/target/sparc/fop_helper.c
52
+++ b/include/hw/intc/arm_gicv3_common.h
37
+++ b/target/sparc/fop_helper.c
53
@@ -XXX,XX +XXX,XX @@ struct GICv3CPUState {
38
@@ -XXX,XX +XXX,XX @@ uint32_t helper_fcmpeq(CPUSPARCState *env, Int128 src1, Int128 src2)
54
39
return finish_fcmp(env, r, GETPC());
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
}
40
}
82
41
83
+static uint64_t icv_nmiar1_read(CPUARMState *env, const ARMCPRegInfo *ri)
42
-uint32_t helper_flcmps(float32 src1, float32 src2)
84
+{
43
+uint32_t helper_flcmps(CPUSPARCState *env, float32 src1, float32 src2)
85
+ /* todo */
86
+ uint64_t intid = INTID_SPURIOUS;
87
+ return intid;
88
+}
89
+
90
static uint32_t icc_fullprio_mask(GICv3CPUState *cs)
91
{
44
{
92
/*
45
/*
93
@@ -XXX,XX +XXX,XX @@ static int icc_highest_active_prio(GICv3CPUState *cs)
46
* FLCMP never raises an exception nor modifies any FSR fields.
47
* Perform the comparison with a dummy fp environment.
94
*/
48
*/
95
int i;
49
- float_status discard = { };
96
50
+ float_status discard = env->fp_status;
97
+ if (cs->nmi_support) {
51
FloatRelation r;
98
+ /*
52
99
+ * If an NMI is active this takes precedence over anything else
53
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard);
100
+ * for priority purposes; the NMI bit is only in the AP1R0 bit.
54
@@ -XXX,XX +XXX,XX @@ uint32_t helper_flcmps(float32 src1, float32 src2)
101
+ * We return here the effective priority of the NMI, which is
55
g_assert_not_reached();
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
+
153
return false;
154
}
56
}
155
57
156
@@ -XXX,XX +XXX,XX @@ static void icc_activate_irq(GICv3CPUState *cs, int irq)
58
-uint32_t helper_flcmpd(float64 src1, float64 src2)
157
int aprbit = prio >> (8 - cs->prebits);
59
+uint32_t helper_flcmpd(CPUSPARCState *env, float64 src1, float64 src2)
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
{
60
{
174
GICv3CPUState *cs = icc_cs_from_env(env);
61
- float_status discard = { };
175
+ int el = arm_current_el(env);
62
+ float_status discard = env->fp_status;
176
uint64_t intid;
63
FloatRelation r;
177
64
178
if (icv_access(env, HCR_IMO)) {
65
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard);
179
@@ -XXX,XX +XXX,XX @@ static uint64_t icc_iar1_read(CPUARMState *env, const ARMCPRegInfo *ri)
66
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
180
}
67
index XXXXXXX..XXXXXXX 100644
181
68
--- a/target/sparc/translate.c
182
if (!gicv3_intid_is_special(intid)) {
69
+++ b/target/sparc/translate.c
183
- icc_activate_irq(cs, intid);
70
@@ -XXX,XX +XXX,XX @@ static bool trans_FLCMPs(DisasContext *dc, arg_FLCMPs *a)
184
+ if (cs->hppi.nmi && env->cp15.sctlr_el[el] & SCTLR_NMI) {
71
185
+ intid = INTID_NMI;
72
src1 = gen_load_fpr_F(dc, a->rs1);
186
+ } else {
73
src2 = gen_load_fpr_F(dc, a->rs2);
187
+ icc_activate_irq(cs, intid);
74
- gen_helper_flcmps(cpu_fcc[a->cc], src1, src2);
188
+ }
75
+ gen_helper_flcmps(cpu_fcc[a->cc], tcg_env, src1, src2);
189
}
76
return advance_pc(dc);
190
191
trace_gicv3_icc_iar1_read(gicv3_redist_affid(cs), intid);
192
return intid;
193
}
77
}
194
78
195
+static uint64_t icc_nmiar1_read(CPUARMState *env, const ARMCPRegInfo *ri)
79
@@ -XXX,XX +XXX,XX @@ static bool trans_FLCMPd(DisasContext *dc, arg_FLCMPd *a)
196
+{
80
197
+ GICv3CPUState *cs = icc_cs_from_env(env);
81
src1 = gen_load_fpr_D(dc, a->rs1);
198
+ uint64_t intid;
82
src2 = gen_load_fpr_D(dc, a->rs2);
199
+
83
- gen_helper_flcmpd(cpu_fcc[a->cc], src1, src2);
200
+ if (icv_access(env, HCR_IMO)) {
84
+ gen_helper_flcmpd(cpu_fcc[a->cc], tcg_env, src1, src2);
201
+ return icv_nmiar1_read(env, ri);
85
return advance_pc(dc);
202
+ }
203
+
204
+ if (!icc_hppi_can_preempt(cs)) {
205
+ intid = INTID_SPURIOUS;
206
+ } else {
207
+ intid = icc_hppir1_value(cs, env);
208
+ }
209
+
210
+ if (!gicv3_intid_is_special(intid)) {
211
+ if (!cs->hppi.nmi) {
212
+ intid = INTID_SPURIOUS;
213
+ } else {
214
+ icc_activate_irq(cs, intid);
215
+ }
216
+ }
217
+
218
+ trace_gicv3_icc_nmiar1_read(gicv3_redist_affid(cs), intid);
219
+ return intid;
220
+}
221
+
222
static void icc_drop_prio(GICv3CPUState *cs, int grp)
223
{
224
/* Drop the priority of the currently active interrupt in
225
@@ -XXX,XX +XXX,XX @@ static void icc_drop_prio(GICv3CPUState *cs, int grp)
226
if (!*papr) {
227
continue;
228
}
229
+
230
+ if (i == 0 && cs->nmi_support && (*papr & ICC_AP1R_EL1_NMI)) {
231
+ *papr &= (~ICC_AP1R_EL1_NMI);
232
+ break;
233
+ }
234
+
235
/* Clear the lowest set bit */
236
*papr &= *papr - 1;
237
break;
238
@@ -XXX,XX +XXX,XX @@ static int icc_highest_active_group(GICv3CPUState *cs)
239
*/
240
int i;
241
242
+ if (cs->nmi_support) {
243
+ if (cs->icc_apr[GICV3_G1][0] & ICC_AP1R_EL1_NMI) {
244
+ return GICV3_G1;
245
+ }
246
+ if (cs->icc_apr[GICV3_G1NS][0] & ICC_AP1R_EL1_NMI) {
247
+ return GICV3_G1NS;
248
+ }
249
+ }
250
+
251
for (i = 0; i < ARRAY_SIZE(cs->icc_apr[0]); i++) {
252
int g0ctz = ctz32(cs->icc_apr[GICV3_G0][i]);
253
int g1ctz = ctz32(cs->icc_apr[GICV3_G1][i]);
254
@@ -XXX,XX +XXX,XX @@ static void icc_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
255
return;
256
}
257
258
- cs->icc_apr[grp][regno] = value & 0xFFFFFFFFU;
259
+ if (cs->nmi_support) {
260
+ cs->icc_apr[grp][regno] = value & (0xFFFFFFFFU | ICC_AP1R_EL1_NMI);
261
+ } else {
262
+ cs->icc_apr[grp][regno] = value & 0xFFFFFFFFU;
263
+ }
264
gicv3_cpuif_update(cs);
265
}
86
}
266
87
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
347
--
88
--
348
2.34.1
89
2.34.1
diff view generated by jsdifflib
New patch
1
In the helper_compute_fprf functions, we pass a dummy float_status
2
in to the is_signaling_nan() function. This is unnecessary, because
3
we have convenient access to the CPU env pointer here and that
4
is already set up with the correct values for the snan_bit_is_one
5
and no_signaling_nans config settings. is_signaling_nan() doesn't
6
ever update the fp_status with any exception flags, so there is
7
no reason not to use env->fp_status here.
1
8
9
Use env->fp_status instead of the dummy fp_status.
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20241202131347.498124-34-peter.maydell@linaro.org
14
---
15
target/ppc/fpu_helper.c | 3 +--
16
1 file changed, 1 insertion(+), 2 deletions(-)
17
18
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/ppc/fpu_helper.c
21
+++ b/target/ppc/fpu_helper.c
22
@@ -XXX,XX +XXX,XX @@ void helper_compute_fprf_##tp(CPUPPCState *env, tp arg) \
23
} else if (tp##_is_infinity(arg)) { \
24
fprf = neg ? 0x09 << FPSCR_FPRF : 0x05 << FPSCR_FPRF; \
25
} else { \
26
- float_status dummy = { }; /* snan_bit_is_one = 0 */ \
27
- if (tp##_is_signaling_nan(arg, &dummy)) { \
28
+ if (tp##_is_signaling_nan(arg, &env->fp_status)) { \
29
fprf = 0x00 << FPSCR_FPRF; \
30
} else { \
31
fprf = 0x11 << FPSCR_FPRF; \
32
--
33
2.34.1
diff view generated by jsdifflib
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Add the USART to the SoC and connect it to the other implemented devices.
3
Now that float_status has a bunch of fp parameters,
4
it is easier to copy an existing structure than create
5
one from scratch. Begin by copying the structure that
6
corresponds to the FPSR and make only the adjustments
7
required for BFloat16 semantics.
4
8
5
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20240329174402.60382-5-arnaud.minier@telecom-paris.fr
12
Message-id: 20241203203949.483774-2-richard.henderson@linaro.org
9
[PMM: fixed a few checkpatch nits]
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
14
---
12
docs/system/arm/b-l475e-iot01a.rst | 2 +-
15
target/arm/tcg/vec_helper.c | 20 +++++++-------------
13
include/hw/arm/stm32l4x5_soc.h | 7 +++
16
1 file changed, 7 insertions(+), 13 deletions(-)
14
hw/arm/stm32l4x5_soc.c | 83 +++++++++++++++++++++++++++---
15
hw/arm/Kconfig | 1 +
16
4 files changed, 86 insertions(+), 7 deletions(-)
17
17
18
diff --git a/docs/system/arm/b-l475e-iot01a.rst b/docs/system/arm/b-l475e-iot01a.rst
18
diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c
19
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
20
--- a/docs/system/arm/b-l475e-iot01a.rst
20
--- a/target/arm/tcg/vec_helper.c
21
+++ b/docs/system/arm/b-l475e-iot01a.rst
21
+++ b/target/arm/tcg/vec_helper.c
22
@@ -XXX,XX +XXX,XX @@ Currently B-L475E-IOT01A machine's only supports the following devices:
22
@@ -XXX,XX +XXX,XX @@ bool is_ebf(CPUARMState *env, float_status *statusp, float_status *oddstatusp)
23
- STM32L4x5 SYSCFG (System configuration controller)
23
* no effect on AArch32 instructions.
24
- STM32L4x5 RCC (Reset and clock control)
24
*/
25
- STM32L4x5 GPIOs (General-purpose I/Os)
25
bool ebf = is_a64(env) && env->vfp.fpcr & FPCR_EBF;
26
+- STM32L4x5 USARTs, UARTs and LPUART (Serial ports)
26
- *statusp = (float_status){
27
27
- .tininess_before_rounding = float_tininess_before_rounding,
28
Missing devices
28
- .float_rounding_mode = float_round_to_odd_inf,
29
"""""""""""""""
29
- .flush_to_zero = true,
30
30
- .flush_inputs_to_zero = true,
31
The B-L475E-IOT01A does *not* support the following devices:
31
- .default_nan_mode = true,
32
32
- };
33
-- Serial ports (UART)
34
- Analog to Digital Converter (ADC)
35
- SPI controller
36
- Timer controller (TIMER)
37
diff --git a/include/hw/arm/stm32l4x5_soc.h b/include/hw/arm/stm32l4x5_soc.h
38
index XXXXXXX..XXXXXXX 100644
39
--- a/include/hw/arm/stm32l4x5_soc.h
40
+++ b/include/hw/arm/stm32l4x5_soc.h
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
+
33
+
56
struct Stm32l4x5SocState {
34
+ *statusp = env->vfp.fp_status;
57
SysBusDevice parent_obj;
35
+ set_default_nan_mode(true, statusp);
58
36
59
@@ -XXX,XX +XXX,XX @@ struct Stm32l4x5SocState {
37
if (ebf) {
60
Stm32l4x5SyscfgState syscfg;
38
- float_status *fpst = &env->vfp.fp_status;
61
Stm32l4x5RccState rcc;
39
- set_flush_to_zero(get_flush_to_zero(fpst), statusp);
62
Stm32l4x5GpioState gpio[NUM_GPIOS];
40
- set_flush_inputs_to_zero(get_flush_inputs_to_zero(fpst), statusp);
63
+ Stm32l4x5UsartBaseState usart[STM_NUM_USARTS];
41
- set_float_rounding_mode(get_float_rounding_mode(fpst), statusp);
64
+ Stm32l4x5UsartBaseState uart[STM_NUM_UARTS];
42
-
65
+ Stm32l4x5UsartBaseState lpuart;
43
/* EBF=1 needs to do a step with round-to-odd semantics */
66
44
*oddstatusp = *statusp;
67
MemoryRegion sram1;
45
set_float_rounding_mode(float_round_to_odd, oddstatusp);
68
MemoryRegion sram2;
46
+ } else {
69
diff --git a/hw/arm/stm32l4x5_soc.c b/hw/arm/stm32l4x5_soc.c
47
+ set_flush_to_zero(true, statusp);
70
index XXXXXXX..XXXXXXX 100644
48
+ set_flush_inputs_to_zero(true, statusp);
71
--- a/hw/arm/stm32l4x5_soc.c
49
+ set_float_rounding_mode(float_round_to_odd_inf, statusp);
72
+++ b/hw/arm/stm32l4x5_soc.c
73
@@ -XXX,XX +XXX,XX @@
74
#include "sysemu/sysemu.h"
75
#include "hw/or-irq.h"
76
#include "hw/arm/stm32l4x5_soc.h"
77
+#include "hw/char/stm32l4x5_usart.h"
78
#include "hw/gpio/stm32l4x5_gpio.h"
79
#include "hw/qdev-clock.h"
80
#include "hw/misc/unimp.h"
81
@@ -XXX,XX +XXX,XX @@ static const struct {
82
{ 0x48001C00, 0x0000000F, 0x00000000, 0x00000000 },
83
};
84
85
+static const hwaddr usart_addr[] = {
86
+ 0x40013800, /* "USART1", 0x400 */
87
+ 0x40004400, /* "USART2", 0x400 */
88
+ 0x40004800, /* "USART3", 0x400 */
89
+};
90
+static const hwaddr uart_addr[] = {
91
+ 0x40004C00, /* "UART4" , 0x400 */
92
+ 0x40005000 /* "UART5" , 0x400 */
93
+};
94
+
95
+#define LPUART_BASE_ADDRESS 0x40008000
96
+
97
+static const int usart_irq[] = { 37, 38, 39 };
98
+static const int uart_irq[] = { 52, 53 };
99
+#define LPUART_IRQ 70
100
+
101
static void stm32l4x5_soc_initfn(Object *obj)
102
{
103
Stm32l4x5SocState *s = STM32L4X5_SOC(obj);
104
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_initfn(Object *obj)
105
g_autofree char *name = g_strdup_printf("gpio%c", 'a' + i);
106
object_initialize_child(obj, name, &s->gpio[i], TYPE_STM32L4X5_GPIO);
107
}
50
}
108
+
51
-
109
+ for (int i = 0; i < STM_NUM_USARTS; i++) {
52
return ebf;
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);
120
}
53
}
121
54
122
static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
123
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp)
124
sysbus_mmio_map(busdev, 0, RCC_BASE_ADDRESS);
125
sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, RCC_IRQ));
126
127
+ /* USART devices */
128
+ for (int i = 0; i < STM_NUM_USARTS; i++) {
129
+ g_autofree char *name = g_strdup_printf("usart%d-out", i + 1);
130
+ dev = DEVICE(&(s->usart[i]));
131
+ qdev_prop_set_chr(dev, "chardev", serial_hd(i));
132
+ qdev_connect_clock_in(dev, "clk",
133
+ qdev_get_clock_out(DEVICE(&(s->rcc)), name));
134
+ busdev = SYS_BUS_DEVICE(dev);
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
217
--
55
--
218
2.34.1
56
2.34.1
219
57
220
58
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
Currently we hardcode the default NaN value in parts64_default_nan()
2
using a compile-time ifdef ladder. This is awkward for two cases:
3
* for single-QEMU-binary we can't hard-code target-specifics like this
4
* for Arm FEAT_AFP the default NaN value depends on FPCR.AH
5
(specifically the sign bit is different)
2
6
3
Add ALLINT MSR (immediate) to decodetree, in which the CRm is 0b000x. The
7
Add a field to float_status to specify the default NaN value; fall
4
EL0 check is necessary to ALLINT, and the EL1 check is necessary when
8
back to the old ifdef behaviour if these are not set.
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
9
8
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
10
The default NaN value is specified by setting a uint8_t to a
11
pattern corresponding to the sign and upper fraction parts of
12
the NaN; the lower bits of the fraction are set from bit 0 of
13
the pattern.
14
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Message-id: 20241202131347.498124-35-peter.maydell@linaro.org
11
Message-id: 20240407081733.3231820-5-ruanjinjie@huawei.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
18
---
14
target/arm/tcg/helper-a64.h | 1 +
19
include/fpu/softfloat-helpers.h | 11 +++++++
15
target/arm/tcg/a64.decode | 1 +
20
include/fpu/softfloat-types.h | 10 ++++++
16
target/arm/tcg/helper-a64.c | 12 ++++++++++++
21
fpu/softfloat-specialize.c.inc | 55 ++++++++++++++++++++-------------
17
target/arm/tcg/translate-a64.c | 19 +++++++++++++++++++
22
3 files changed, 54 insertions(+), 22 deletions(-)
18
4 files changed, 33 insertions(+)
19
23
20
diff --git a/target/arm/tcg/helper-a64.h b/target/arm/tcg/helper-a64.h
24
diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h
21
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/tcg/helper-a64.h
26
--- a/include/fpu/softfloat-helpers.h
23
+++ b/target/arm/tcg/helper-a64.h
27
+++ b/include/fpu/softfloat-helpers.h
24
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64)
28
@@ -XXX,XX +XXX,XX @@ static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule,
25
DEF_HELPER_2(msr_i_spsel, void, env, i32)
29
status->float_infzeronan_rule = rule;
26
DEF_HELPER_2(msr_i_daifset, void, env, i32)
27
DEF_HELPER_2(msr_i_daifclear, void, env, i32)
28
+DEF_HELPER_1(msr_set_allint_el1, void, env)
29
DEF_HELPER_3(vfp_cmph_a64, i64, f16, f16, ptr)
30
DEF_HELPER_3(vfp_cmpeh_a64, i64, f16, f16, ptr)
31
DEF_HELPER_3(vfp_cmps_a64, i64, f32, f32, ptr)
32
diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/arm/tcg/a64.decode
35
+++ b/target/arm/tcg/a64.decode
36
@@ -XXX,XX +XXX,XX @@ MSR_i_DIT 1101 0101 0000 0 011 0100 .... 010 11111 @msr_i
37
MSR_i_TCO 1101 0101 0000 0 011 0100 .... 100 11111 @msr_i
38
MSR_i_DAIFSET 1101 0101 0000 0 011 0100 .... 110 11111 @msr_i
39
MSR_i_DAIFCLEAR 1101 0101 0000 0 011 0100 .... 111 11111 @msr_i
40
+MSR_i_ALLINT 1101 0101 0000 0 001 0100 000 imm:1 000 11111
41
MSR_i_SVCR 1101 0101 0000 0 011 0100 0 mask:2 imm:1 011 11111
42
43
# MRS, MSR (register), SYS, SYSL. These are all essentially the
44
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/target/arm/tcg/helper-a64.c
47
+++ b/target/arm/tcg/helper-a64.c
48
@@ -XXX,XX +XXX,XX @@ void HELPER(msr_i_spsel)(CPUARMState *env, uint32_t imm)
49
update_spsel(env, imm);
50
}
30
}
51
31
52
+void HELPER(msr_set_allint_el1)(CPUARMState *env)
32
+static inline void set_float_default_nan_pattern(uint8_t dnan_pattern,
33
+ float_status *status)
53
+{
34
+{
54
+ /* ALLINT update to PSTATE. */
35
+ status->default_nan_pattern = dnan_pattern;
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;
62
+}
36
+}
63
+
37
+
64
static void daif_check(CPUARMState *env, uint32_t op,
38
static inline void set_flush_to_zero(bool val, float_status *status)
65
uint32_t imm, uintptr_t ra)
66
{
39
{
67
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
40
status->flush_to_zero = val;
68
index XXXXXXX..XXXXXXX 100644
41
@@ -XXX,XX +XXX,XX @@ static inline FloatInfZeroNaNRule get_float_infzeronan_rule(float_status *status
69
--- a/target/arm/tcg/translate-a64.c
42
return status->float_infzeronan_rule;
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;
73
}
43
}
74
44
75
+static bool trans_MSR_i_ALLINT(DisasContext *s, arg_i *a)
45
+static inline uint8_t get_float_default_nan_pattern(float_status *status)
76
+{
46
+{
77
+ if (!dc_isar_feature(aa64_nmi, s) || s->current_el == 0) {
47
+ return status->default_nan_pattern;
78
+ return false;
79
+ }
80
+
81
+ if (a->imm == 0) {
82
+ clear_pstate_bits(PSTATE_ALLINT);
83
+ } else if (s->current_el > 1) {
84
+ set_pstate_bits(PSTATE_ALLINT);
85
+ } else {
86
+ gen_helper_msr_set_allint_el1(tcg_env);
87
+ }
88
+
89
+ /* Exit the cpu loop to re-evaluate pending IRQs. */
90
+ s->base.is_jmp = DISAS_UPDATE_EXIT;
91
+ return true;
92
+}
48
+}
93
+
49
+
94
static bool trans_MSR_i_SVCR(DisasContext *s, arg_MSR_i_SVCR *a)
50
static inline bool get_flush_to_zero(float_status *status)
95
{
51
{
96
if (!dc_isar_feature(aa64_sme, s) || a->mask == 0) {
52
return status->flush_to_zero;
53
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
54
index XXXXXXX..XXXXXXX 100644
55
--- a/include/fpu/softfloat-types.h
56
+++ b/include/fpu/softfloat-types.h
57
@@ -XXX,XX +XXX,XX @@ typedef struct float_status {
58
/* should denormalised inputs go to zero and set the input_denormal flag? */
59
bool flush_inputs_to_zero;
60
bool default_nan_mode;
61
+ /*
62
+ * The pattern to use for the default NaN. Here the high bit specifies
63
+ * the default NaN's sign bit, and bits 6..0 specify the high bits of the
64
+ * fractional part. The low bits of the fractional part are copies of bit 0.
65
+ * The exponent of the default NaN is (as for any NaN) always all 1s.
66
+ * Note that a value of 0 here is not a valid NaN. The target must set
67
+ * this to the correct non-zero value, or we will assert when trying to
68
+ * create a default NaN.
69
+ */
70
+ uint8_t default_nan_pattern;
71
/*
72
* The flags below are not used on all specializations and may
73
* constant fold away (see snan_bit_is_one()/no_signalling_nans() in
74
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
75
index XXXXXXX..XXXXXXX 100644
76
--- a/fpu/softfloat-specialize.c.inc
77
+++ b/fpu/softfloat-specialize.c.inc
78
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
79
{
80
bool sign = 0;
81
uint64_t frac;
82
+ uint8_t dnan_pattern = status->default_nan_pattern;
83
84
+ if (dnan_pattern == 0) {
85
#if defined(TARGET_SPARC) || defined(TARGET_M68K)
86
- /* !snan_bit_is_one, set all bits */
87
- frac = (1ULL << DECOMPOSED_BINARY_POINT) - 1;
88
-#elif defined(TARGET_I386) || defined(TARGET_X86_64) \
89
+ /* Sign bit clear, all frac bits set */
90
+ dnan_pattern = 0b01111111;
91
+#elif defined(TARGET_I386) || defined(TARGET_X86_64) \
92
|| defined(TARGET_MICROBLAZE)
93
- /* !snan_bit_is_one, set sign and msb */
94
- frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1);
95
- sign = 1;
96
+ /* Sign bit set, most significant frac bit set */
97
+ dnan_pattern = 0b11000000;
98
#elif defined(TARGET_HPPA)
99
- /* snan_bit_is_one, set msb-1. */
100
- frac = 1ULL << (DECOMPOSED_BINARY_POINT - 2);
101
+ /* Sign bit clear, msb-1 frac bit set */
102
+ dnan_pattern = 0b00100000;
103
#elif defined(TARGET_HEXAGON)
104
- sign = 1;
105
- frac = ~0ULL;
106
+ /* Sign bit set, all frac bits set. */
107
+ dnan_pattern = 0b11111111;
108
#else
109
- /*
110
- * This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V,
111
- * S390, SH4, TriCore, and Xtensa. Our other supported targets
112
- * do not have floating-point.
113
- */
114
- if (snan_bit_is_one(status)) {
115
- /* set all bits other than msb */
116
- frac = (1ULL << (DECOMPOSED_BINARY_POINT - 1)) - 1;
117
- } else {
118
- /* set msb */
119
- frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1);
120
- }
121
+ /*
122
+ * This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V,
123
+ * S390, SH4, TriCore, and Xtensa. Our other supported targets
124
+ * do not have floating-point.
125
+ */
126
+ if (snan_bit_is_one(status)) {
127
+ /* sign bit clear, set all frac bits other than msb */
128
+ dnan_pattern = 0b00111111;
129
+ } else {
130
+ /* sign bit clear, set frac msb */
131
+ dnan_pattern = 0b01000000;
132
+ }
133
#endif
134
+ }
135
+ assert(dnan_pattern != 0);
136
+
137
+ sign = dnan_pattern >> 7;
138
+ /*
139
+ * Place default_nan_pattern [6:0] into bits [62:56],
140
+ * and replecate bit [0] down into [55:0]
141
+ */
142
+ frac = deposit64(0, DECOMPOSED_BINARY_POINT - 7, 7, dnan_pattern);
143
+ frac = deposit64(frac, 0, DECOMPOSED_BINARY_POINT - 7, -(dnan_pattern & 1));
144
145
*p = (FloatParts64) {
146
.cls = float_class_qnan,
97
--
147
--
98
2.34.1
148
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for the tests/fp code.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-36-peter.maydell@linaro.org
6
---
7
tests/fp/fp-bench.c | 1 +
8
tests/fp/fp-test-log2.c | 1 +
9
tests/fp/fp-test.c | 1 +
10
3 files changed, 3 insertions(+)
11
12
diff --git a/tests/fp/fp-bench.c b/tests/fp/fp-bench.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/tests/fp/fp-bench.c
15
+++ b/tests/fp/fp-bench.c
16
@@ -XXX,XX +XXX,XX @@ static void run_bench(void)
17
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &soft_status);
18
set_float_3nan_prop_rule(float_3nan_prop_s_cab, &soft_status);
19
set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &soft_status);
20
+ set_float_default_nan_pattern(0b01000000, &soft_status);
21
22
f = bench_funcs[operation][precision];
23
g_assert(f);
24
diff --git a/tests/fp/fp-test-log2.c b/tests/fp/fp-test-log2.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/tests/fp/fp-test-log2.c
27
+++ b/tests/fp/fp-test-log2.c
28
@@ -XXX,XX +XXX,XX @@ int main(int ac, char **av)
29
int i;
30
31
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf);
32
+ set_float_default_nan_pattern(0b01000000, &qsf);
33
set_float_rounding_mode(float_round_nearest_even, &qsf);
34
35
test.d = 0.0;
36
diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/tests/fp/fp-test.c
39
+++ b/tests/fp/fp-test.c
40
@@ -XXX,XX +XXX,XX @@ void run_test(void)
41
*/
42
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf);
43
set_float_3nan_prop_rule(float_3nan_prop_s_cab, &qsf);
44
+ set_float_default_nan_pattern(0b01000000, &qsf);
45
set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &qsf);
46
47
genCases_setLevel(test_level);
48
--
49
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
Set the default NaN pattern explicitly, and remove the ifdef from
2
parts64_default_nan().
2
3
3
When PSTATE.ALLINT is set, an IRQ or FIQ interrupt that is targeted to
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
ELx, with or without superpriority is masked. As Richard suggested, place
5
ALLINT bit in PSTATE in env->pstate.
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>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Message-id: 20241202131347.498124-37-peter.maydell@linaro.org
17
Message-id: 20240407081733.3231820-3-ruanjinjie@huawei.com
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
7
---
20
target/arm/cpu.h | 1 +
8
target/microblaze/cpu.c | 2 ++
21
target/arm/tcg/helper-a64.c | 4 ++--
9
fpu/softfloat-specialize.c.inc | 3 +--
22
2 files changed, 3 insertions(+), 2 deletions(-)
10
2 files changed, 3 insertions(+), 2 deletions(-)
23
11
24
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
12
diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
25
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/cpu.h
14
--- a/target/microblaze/cpu.c
27
+++ b/target/arm/cpu.h
15
+++ b/target/microblaze/cpu.c
28
@@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu);
16
@@ -XXX,XX +XXX,XX @@ static void mb_cpu_reset_hold(Object *obj, ResetType type)
29
#define PSTATE_D (1U << 9)
17
* this architecture.
30
#define PSTATE_BTYPE (3U << 10)
18
*/
31
#define PSTATE_SSBS (1U << 12)
19
set_float_2nan_prop_rule(float_2nan_prop_x87, &env->fp_status);
32
+#define PSTATE_ALLINT (1U << 13)
20
+ /* Default NaN: sign bit set, most significant frac bit set */
33
#define PSTATE_IL (1U << 20)
21
+ set_float_default_nan_pattern(0b11000000, &env->fp_status);
34
#define PSTATE_SS (1U << 21)
22
35
#define PSTATE_PAN (1U << 22)
23
#if defined(CONFIG_USER_ONLY)
36
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
24
/* start in user mode with interrupts enabled. */
25
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
37
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/tcg/helper-a64.c
27
--- a/fpu/softfloat-specialize.c.inc
39
+++ b/target/arm/tcg/helper-a64.c
28
+++ b/fpu/softfloat-specialize.c.inc
40
@@ -XXX,XX +XXX,XX @@ illegal_return:
29
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
41
*/
30
#if defined(TARGET_SPARC) || defined(TARGET_M68K)
42
env->pstate |= PSTATE_IL;
31
/* Sign bit clear, all frac bits set */
43
env->pc = new_pc;
32
dnan_pattern = 0b01111111;
44
- spsr &= PSTATE_NZCV | PSTATE_DAIF;
33
-#elif defined(TARGET_I386) || defined(TARGET_X86_64) \
45
- spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF);
34
- || defined(TARGET_MICROBLAZE)
46
+ spsr &= PSTATE_NZCV | PSTATE_DAIF | PSTATE_ALLINT;
35
+#elif defined(TARGET_I386) || defined(TARGET_X86_64)
47
+ spsr |= pstate_read(env) & ~(PSTATE_NZCV | PSTATE_DAIF | PSTATE_ALLINT);
36
/* Sign bit set, most significant frac bit set */
48
pstate_write(env, spsr);
37
dnan_pattern = 0b11000000;
49
if (!arm_singlestep_active(env)) {
38
#elif defined(TARGET_HPPA)
50
env->pstate &= ~PSTATE_SS;
51
--
39
--
52
2.34.1
40
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly, and remove the ifdef from
2
parts64_default_nan().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-38-peter.maydell@linaro.org
7
---
8
target/i386/tcg/fpu_helper.c | 4 ++++
9
fpu/softfloat-specialize.c.inc | 3 ---
10
2 files changed, 4 insertions(+), 3 deletions(-)
11
12
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/i386/tcg/fpu_helper.c
15
+++ b/target/i386/tcg/fpu_helper.c
16
@@ -XXX,XX +XXX,XX @@ void cpu_init_fp_statuses(CPUX86State *env)
17
*/
18
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status);
19
set_float_3nan_prop_rule(float_3nan_prop_abc, &env->sse_status);
20
+ /* Default NaN: sign bit set, most significant frac bit set */
21
+ set_float_default_nan_pattern(0b11000000, &env->fp_status);
22
+ set_float_default_nan_pattern(0b11000000, &env->mmx_status);
23
+ set_float_default_nan_pattern(0b11000000, &env->sse_status);
24
}
25
26
static inline uint8_t save_exception_flags(CPUX86State *env)
27
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
28
index XXXXXXX..XXXXXXX 100644
29
--- a/fpu/softfloat-specialize.c.inc
30
+++ b/fpu/softfloat-specialize.c.inc
31
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
32
#if defined(TARGET_SPARC) || defined(TARGET_M68K)
33
/* Sign bit clear, all frac bits set */
34
dnan_pattern = 0b01111111;
35
-#elif defined(TARGET_I386) || defined(TARGET_X86_64)
36
- /* Sign bit set, most significant frac bit set */
37
- dnan_pattern = 0b11000000;
38
#elif defined(TARGET_HPPA)
39
/* Sign bit clear, msb-1 frac bit set */
40
dnan_pattern = 0b00100000;
41
--
42
2.34.1
diff view generated by jsdifflib
1
Rather than directly calling the device's implementation of its 'hold'
1
Set the default NaN pattern explicitly, and remove the ifdef from
2
reset phase, call device_cold_reset(). This means we don't have to
2
parts64_default_nan().
3
adjust this callsite when we add another argument to the function
4
signature for the hold and exit reset methods.
5
3
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Luc Michel <luc.michel@amd.com>
6
Message-id: 20241202131347.498124-39-peter.maydell@linaro.org
9
Message-id: 20240412160809.1260625-3-peter.maydell@linaro.org
10
---
7
---
11
hw/i2c/allwinner-i2c.c | 3 +--
8
target/hppa/fpu_helper.c | 2 ++
12
hw/sensor/adm1272.c | 2 +-
9
fpu/softfloat-specialize.c.inc | 3 ---
13
2 files changed, 2 insertions(+), 3 deletions(-)
10
2 files changed, 2 insertions(+), 3 deletions(-)
14
11
15
diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c
12
diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c
16
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/i2c/allwinner-i2c.c
14
--- a/target/hppa/fpu_helper.c
18
+++ b/hw/i2c/allwinner-i2c.c
15
+++ b/target/hppa/fpu_helper.c
19
@@ -XXX,XX +XXX,XX @@ static void allwinner_i2c_write(void *opaque, hwaddr offset,
16
@@ -XXX,XX +XXX,XX @@ void HELPER(loaded_fr0)(CPUHPPAState *env)
20
break;
17
set_float_3nan_prop_rule(float_3nan_prop_abc, &env->fp_status);
21
case TWI_SRST_REG:
18
/* For inf * 0 + NaN, return the input NaN */
22
if (((value & TWI_SRST_MASK) == 0) && (s->srst & TWI_SRST_MASK)) {
19
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
23
- /* Perform reset */
20
+ /* Default NaN: sign bit clear, msb-1 frac bit set */
24
- allwinner_i2c_reset_hold(OBJECT(s));
21
+ set_float_default_nan_pattern(0b00100000, &env->fp_status);
25
+ device_cold_reset(DEVICE(s));
22
}
26
}
23
27
s->srst = value & TWI_SRST_MASK;
24
void cpu_hppa_loaded_fr0(CPUHPPAState *env)
28
break;
25
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
29
diff --git a/hw/sensor/adm1272.c b/hw/sensor/adm1272.c
30
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/sensor/adm1272.c
27
--- a/fpu/softfloat-specialize.c.inc
32
+++ b/hw/sensor/adm1272.c
28
+++ b/fpu/softfloat-specialize.c.inc
33
@@ -XXX,XX +XXX,XX @@ static int adm1272_write_data(PMBusDevice *pmdev, const uint8_t *buf,
29
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
34
break;
30
#if defined(TARGET_SPARC) || defined(TARGET_M68K)
35
31
/* Sign bit clear, all frac bits set */
36
case ADM1272_MFR_POWER_CYCLE:
32
dnan_pattern = 0b01111111;
37
- adm1272_exit_reset((Object *)s);
33
-#elif defined(TARGET_HPPA)
38
+ device_cold_reset(DEVICE(s));
34
- /* Sign bit clear, msb-1 frac bit set */
39
break;
35
- dnan_pattern = 0b00100000;
40
36
#elif defined(TARGET_HEXAGON)
41
case ADM1272_HYSTERESIS_LOW:
37
/* Sign bit set, all frac bits set. */
38
dnan_pattern = 0b11111111;
42
--
39
--
43
2.34.1
40
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for the alpha target.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-40-peter.maydell@linaro.org
6
---
7
target/alpha/cpu.c | 2 ++
8
1 file changed, 2 insertions(+)
9
10
diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/target/alpha/cpu.c
13
+++ b/target/alpha/cpu.c
14
@@ -XXX,XX +XXX,XX @@ static void alpha_cpu_initfn(Object *obj)
15
* operand in Fa. That is float_2nan_prop_ba.
16
*/
17
set_float_2nan_prop_rule(float_2nan_prop_x87, &env->fp_status);
18
+ /* Default NaN: sign bit clear, msb frac bit set */
19
+ set_float_default_nan_pattern(0b01000000, &env->fp_status);
20
#if defined(CONFIG_USER_ONLY)
21
env->flags = ENV_FLAG_PS_USER | ENV_FLAG_FEN;
22
cpu_alpha_store_fpcr(env, (uint64_t)(FPCR_INVD | FPCR_DZED | FPCR_OVFD
23
--
24
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for the arm target.
2
This includes setting it for the old linux-user nwfpe emulation.
3
For nwfpe, our default doesn't match the real kernel, but we
4
avoid making a behaviour change in this commit.
1
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20241202131347.498124-41-peter.maydell@linaro.org
9
---
10
linux-user/arm/nwfpe/fpa11.c | 5 +++++
11
target/arm/cpu.c | 2 ++
12
2 files changed, 7 insertions(+)
13
14
diff --git a/linux-user/arm/nwfpe/fpa11.c b/linux-user/arm/nwfpe/fpa11.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/linux-user/arm/nwfpe/fpa11.c
17
+++ b/linux-user/arm/nwfpe/fpa11.c
18
@@ -XXX,XX +XXX,XX @@ void resetFPA11(void)
19
* this late date.
20
*/
21
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &fpa11->fp_status);
22
+ /*
23
+ * Use the same default NaN value as Arm VFP. This doesn't match
24
+ * the Linux kernel's nwfpe emulation, which uses an all-1s value.
25
+ */
26
+ set_float_default_nan_pattern(0b01000000, &fpa11->fp_status);
27
}
28
29
void SetRoundingMode(const unsigned int opcode)
30
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/target/arm/cpu.c
33
+++ b/target/arm/cpu.c
34
@@ -XXX,XX +XXX,XX @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
35
* the pseudocode function the arguments are in the order c, a, b.
36
* * 0 * Inf + NaN returns the default NaN if the input NaN is quiet,
37
* and the input NaN if it is signalling
38
+ * * Default NaN has sign bit clear, msb frac bit set
39
*/
40
static void arm_set_default_fp_behaviours(float_status *s)
41
{
42
@@ -XXX,XX +XXX,XX @@ static void arm_set_default_fp_behaviours(float_status *s)
43
set_float_2nan_prop_rule(float_2nan_prop_s_ab, s);
44
set_float_3nan_prop_rule(float_3nan_prop_s_cab, s);
45
set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, s);
46
+ set_float_default_nan_pattern(0b01000000, s);
47
}
48
49
static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)
50
--
51
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for loongarch.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-42-peter.maydell@linaro.org
6
---
7
target/loongarch/tcg/fpu_helper.c | 2 ++
8
1 file changed, 2 insertions(+)
9
10
diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/target/loongarch/tcg/fpu_helper.c
13
+++ b/target/loongarch/tcg/fpu_helper.c
14
@@ -XXX,XX +XXX,XX @@ void restore_fp_status(CPULoongArchState *env)
15
*/
16
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
17
set_float_3nan_prop_rule(float_3nan_prop_s_cab, &env->fp_status);
18
+ /* Default NaN: sign bit clear, msb frac bit set */
19
+ set_float_default_nan_pattern(0b01000000, &env->fp_status);
20
}
21
22
int ieee_ex_to_loongarch(int xcpt)
23
--
24
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for m68k.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-43-peter.maydell@linaro.org
6
---
7
target/m68k/cpu.c | 2 ++
8
fpu/softfloat-specialize.c.inc | 2 +-
9
2 files changed, 3 insertions(+), 1 deletion(-)
10
11
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/m68k/cpu.c
14
+++ b/target/m68k/cpu.c
15
@@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type)
16
* preceding paragraph for nonsignaling NaNs.
17
*/
18
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status);
19
+ /* Default NaN: sign bit clear, all frac bits set */
20
+ set_float_default_nan_pattern(0b01111111, &env->fp_status);
21
22
nan = floatx80_default_nan(&env->fp_status);
23
for (i = 0; i < 8; i++) {
24
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
25
index XXXXXXX..XXXXXXX 100644
26
--- a/fpu/softfloat-specialize.c.inc
27
+++ b/fpu/softfloat-specialize.c.inc
28
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
29
uint8_t dnan_pattern = status->default_nan_pattern;
30
31
if (dnan_pattern == 0) {
32
-#if defined(TARGET_SPARC) || defined(TARGET_M68K)
33
+#if defined(TARGET_SPARC)
34
/* Sign bit clear, all frac bits set */
35
dnan_pattern = 0b01111111;
36
#elif defined(TARGET_HEXAGON)
37
--
38
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
Set the default NaN pattern explicitly for MIPS. Note that this
2
is our only target which currently changes the default NaN
3
at runtime (which it was previously doing indirectly when it
4
changed the snan_bit_is_one setting).
2
5
3
Add support for FEAT_NMI. NMI (FEAT_NMI) is an mandatory feature in
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
ARMv8.8-A and ARM v9.3-A.
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20241202131347.498124-44-peter.maydell@linaro.org
9
---
10
target/mips/fpu_helper.h | 7 +++++++
11
target/mips/msa.c | 3 +++
12
2 files changed, 10 insertions(+)
5
13
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
14
diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h
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>
11
---
12
target/arm/internals.h | 3 +++
13
1 file changed, 3 insertions(+)
14
15
diff --git a/target/arm/internals.h b/target/arm/internals.h
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/internals.h
16
--- a/target/mips/fpu_helper.h
18
+++ b/target/arm/internals.h
17
+++ b/target/mips/fpu_helper.h
19
@@ -XXX,XX +XXX,XX @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id)
18
@@ -XXX,XX +XXX,XX @@ static inline void restore_snan_bit_mode(CPUMIPSState *env)
20
if (isar_feature_aa64_mte(id)) {
19
set_float_infzeronan_rule(izn_rule, &env->active_fpu.fp_status);
21
valid |= PSTATE_TCO;
20
nan3_rule = nan2008 ? float_3nan_prop_s_cab : float_3nan_prop_s_abc;
22
}
21
set_float_3nan_prop_rule(nan3_rule, &env->active_fpu.fp_status);
23
+ if (isar_feature_aa64_nmi(id)) {
22
+ /*
24
+ valid |= PSTATE_ALLINT;
23
+ * With nan2008, the default NaN value has the sign bit clear and the
25
+ }
24
+ * frac msb set; with the older mode, the sign bit is clear, and all
26
25
+ * frac bits except the msb are set.
27
return valid;
26
+ */
27
+ set_float_default_nan_pattern(nan2008 ? 0b01000000 : 0b00111111,
28
+ &env->active_fpu.fp_status);
29
30
}
31
32
diff --git a/target/mips/msa.c b/target/mips/msa.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/mips/msa.c
35
+++ b/target/mips/msa.c
36
@@ -XXX,XX +XXX,XX @@ void msa_reset(CPUMIPSState *env)
37
/* Inf * 0 + NaN returns the input NaN */
38
set_float_infzeronan_rule(float_infzeronan_dnan_never,
39
&env->active_tc.msa_fp_status);
40
+ /* Default NaN: sign bit clear, frac msb set */
41
+ set_float_default_nan_pattern(0b01000000,
42
+ &env->active_tc.msa_fp_status);
28
}
43
}
29
--
44
--
30
2.34.1
45
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for openrisc.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-45-peter.maydell@linaro.org
6
---
7
target/openrisc/cpu.c | 2 ++
8
1 file changed, 2 insertions(+)
9
10
diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/target/openrisc/cpu.c
13
+++ b/target/openrisc/cpu.c
14
@@ -XXX,XX +XXX,XX @@ static void openrisc_cpu_reset_hold(Object *obj, ResetType type)
15
*/
16
set_float_2nan_prop_rule(float_2nan_prop_x87, &cpu->env.fp_status);
17
18
+ /* Default NaN: sign bit clear, frac msb set */
19
+ set_float_default_nan_pattern(0b01000000, &cpu->env.fp_status);
20
21
#ifndef CONFIG_USER_ONLY
22
cpu->env.picmr = 0x00000000;
23
--
24
2.34.1
diff view generated by jsdifflib
1
Some devices and machines need to handle the reset before a vmsave
1
Set the default NaN pattern explicitly for ppc.
2
snapshot is loaded differently -- the main user is the handling of
3
RNG seed information, which does not want to put a new RNG seed into
4
a ROM blob when we are doing a snapshot load.
5
6
Currently this kind of reset handling is supported only for:
7
* TYPE_MACHINE reset methods, which take a ShutdownCause argument
8
* reset functions registered with qemu_register_reset_nosnapshotload
9
10
To allow a three-phase-reset device to also distinguish "snapshot
11
load" reset from the normal kind, add a new ResetType
12
RESET_TYPE_SNAPSHOT_LOAD. All our existing reset methods ignore
13
the reset type, so we don't need to update any device code.
14
15
Add the enum type, and make qemu_devices_reset() use the
16
right reset type for the ShutdownCause it is passed. This
17
allows us to get rid of the device_reset_reason global we
18
were using to implement qemu_register_reset_nosnapshotload().
19
2
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
22
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Message-id: 20241202131347.498124-46-peter.maydell@linaro.org
23
Reviewed-by: Luc Michel <luc.michel@amd.com>
24
Message-id: 20240412160809.1260625-7-peter.maydell@linaro.org
25
---
6
---
26
docs/devel/reset.rst | 17 ++++++++++++++---
7
target/ppc/cpu_init.c | 4 ++++
27
include/hw/resettable.h | 1 +
8
1 file changed, 4 insertions(+)
28
hw/core/reset.c | 15 ++++-----------
29
hw/core/resettable.c | 4 ----
30
4 files changed, 19 insertions(+), 18 deletions(-)
31
9
32
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
10
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
33
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
34
--- a/docs/devel/reset.rst
12
--- a/target/ppc/cpu_init.c
35
+++ b/docs/devel/reset.rst
13
+++ b/target/ppc/cpu_init.c
36
@@ -XXX,XX +XXX,XX @@ instantly reset an object, without keeping it in reset state, just call
14
@@ -XXX,XX +XXX,XX @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type)
37
``resettable_reset()``. These functions take two parameters: a pointer to the
15
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
38
object to reset and a reset type.
16
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->vec_status);
39
17
40
-Several types of reset will be supported. For now only cold reset is defined;
18
+ /* Default NaN: sign bit clear, set frac msb */
41
-others may be added later. The Resettable interface handles reset types with an
19
+ set_float_default_nan_pattern(0b01000000, &env->fp_status);
42
-enum:
20
+ set_float_default_nan_pattern(0b01000000, &env->vec_status);
43
+The Resettable interface handles reset types with an enum ``ResetType``:
44
45
``RESET_TYPE_COLD``
46
Cold reset is supported by every resettable object. In QEMU, it means we reset
47
@@ -XXX,XX +XXX,XX @@ enum:
48
from what is a real hardware cold reset. It differs from other resets (like
49
warm or bus resets) which may keep certain parts untouched.
50
51
+``RESET_TYPE_SNAPSHOT_LOAD``
52
+ This is called for a reset which is being done to put the system into a
53
+ clean state prior to loading a snapshot. (This corresponds to a reset
54
+ with ``SHUTDOWN_CAUSE_SNAPSHOT_LOAD``.) Almost all devices should treat
55
+ this the same as ``RESET_TYPE_COLD``. The main exception is devices which
56
+ have some non-deterministic state they want to reinitialize to a different
57
+ value on each cold reset, such as RNG seed information, and which they
58
+ must not reinitialize on a snapshot-load reset.
59
+
21
+
60
+Devices which implement reset methods must treat any unknown ``ResetType``
22
for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) {
61
+as equivalent to ``RESET_TYPE_COLD``; this will reduce the amount of
23
ppc_spr_t *spr = &env->spr_cb[i];
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
68
index XXXXXXX..XXXXXXX 100644
69
--- a/include/hw/resettable.h
70
+++ b/include/hw/resettable.h
71
@@ -XXX,XX +XXX,XX @@ typedef struct ResettableState ResettableState;
72
*/
73
typedef enum ResetType {
74
RESET_TYPE_COLD,
75
+ RESET_TYPE_SNAPSHOT_LOAD,
76
} ResetType;
77
78
/*
79
diff --git a/hw/core/reset.c b/hw/core/reset.c
80
index XXXXXXX..XXXXXXX 100644
81
--- a/hw/core/reset.c
82
+++ b/hw/core/reset.c
83
@@ -XXX,XX +XXX,XX @@ static ResettableContainer *get_root_reset_container(void)
84
return root_reset_container;
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;
105
}
106
lr->func(lr->opaque);
107
@@ -XXX,XX +XXX,XX @@ void qemu_unregister_resettable(Object *obj)
108
109
void qemu_devices_reset(ShutdownCause reason)
110
{
111
- device_reset_reason = reason;
112
+ ResetType type = (reason == SHUTDOWN_CAUSE_SNAPSHOT_LOAD) ?
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);
118
}
119
diff --git a/hw/core/resettable.c b/hw/core/resettable.c
120
index XXXXXXX..XXXXXXX 100644
121
--- a/hw/core/resettable.c
122
+++ b/hw/core/resettable.c
123
@@ -XXX,XX +XXX,XX @@ void resettable_reset(Object *obj, ResetType type)
124
125
void resettable_assert_reset(Object *obj, ResetType type)
126
{
127
- /* TODO: change this assert when adding support for other reset types */
128
- assert(type == RESET_TYPE_COLD);
129
trace_resettable_reset_assert_begin(obj, type);
130
assert(!enter_phase_in_progress);
131
132
@@ -XXX,XX +XXX,XX @@ void resettable_assert_reset(Object *obj, ResetType type)
133
134
void resettable_release_reset(Object *obj, ResetType type)
135
{
136
- /* TODO: change this assert when adding support for other reset types */
137
- assert(type == RESET_TYPE_COLD);
138
trace_resettable_reset_release_begin(obj, type);
139
assert(!enter_phase_in_progress);
140
24
141
--
25
--
142
2.34.1
26
2.34.1
143
144
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
Set the default NaN pattern explicitly for sh4. Note that sh4
2
is one of the only three targets (the others being HPPA and
3
sometimes MIPS) that has snan_bit_is_one set.
2
4
3
If the CPU implements FEAT_NMI, then turn on the NMI support in the
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
GICv3 too. It's permitted to have a configuration with FEAT_NMI in
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
the CPU (and thus NMI support in the CPU interfaces too) but no NMI
7
Message-id: 20241202131347.498124-47-peter.maydell@linaro.org
6
support in the distributor and redistributor, but this isn't a very
8
---
7
useful setup as it's close to having no NMI support at all.
9
target/sh4/cpu.c | 2 ++
10
1 file changed, 2 insertions(+)
8
11
9
We don't need to gate the enabling of NMI in the GIC behind a
12
diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
10
machine version property, because none of our current CPUs
11
implement FEAT_NMI, and '-cpu max' is not something we maintain
12
migration compatibility across versions for. So we can always
13
enable the GIC NMI support when the CPU has it.
14
15
Neither hvf nor KVM support NMI in the GIC yet, so we don't enable
16
it unless we're using TCG.
17
18
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
20
Message-id: 20240407081733.3231820-25-ruanjinjie@huawei.com
21
[PMM: Update comment and commit message]
22
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
---
25
hw/arm/virt.c | 19 +++++++++++++++++++
26
1 file changed, 19 insertions(+)
27
28
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
29
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/arm/virt.c
14
--- a/target/sh4/cpu.c
31
+++ b/hw/arm/virt.c
15
+++ b/target/sh4/cpu.c
32
@@ -XXX,XX +XXX,XX @@ static void create_v2m(VirtMachineState *vms)
16
@@ -XXX,XX +XXX,XX @@ static void superh_cpu_reset_hold(Object *obj, ResetType type)
33
vms->msi_controller = VIRT_MSI_CTRL_GICV2M;
17
set_flush_to_zero(1, &env->fp_status);
18
#endif
19
set_default_nan_mode(1, &env->fp_status);
20
+ /* sign bit clear, set all frac bits other than msb */
21
+ set_float_default_nan_pattern(0b00111111, &env->fp_status);
34
}
22
}
35
23
36
+/*
24
static void superh_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
37
+ * If the CPU has FEAT_NMI, then turn on the NMI support in the GICv3 too.
38
+ * It's permitted to have a configuration with NMI in the CPU (and thus the
39
+ * GICv3 CPU interface) but not in the distributor/redistributors, but it's
40
+ * not very useful.
41
+ */
42
+static bool gicv3_nmi_present(VirtMachineState *vms)
43
+{
44
+ ARMCPU *cpu = ARM_CPU(qemu_get_cpu(0));
45
+
46
+ return tcg_enabled() && cpu_isar_feature(aa64_nmi, cpu) &&
47
+ (vms->gic_version != VIRT_GIC_VERSION_2);
48
+}
49
+
50
static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
51
{
52
MachineState *ms = MACHINE(vms);
53
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
54
vms->virt);
55
}
56
}
57
+
58
+ if (gicv3_nmi_present(vms)) {
59
+ qdev_prop_set_bit(vms->gic, "has-nmi", true);
60
+ }
61
+
62
gicbusdev = SYS_BUS_DEVICE(vms->gic);
63
sysbus_realize_and_unref(gicbusdev, &error_fatal);
64
sysbus_mmio_map(gicbusdev, 0, vms->memmap[VIRT_GIC_DIST].base);
65
--
25
--
66
2.34.1
26
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
Set the default NaN pattern explicitly for rx.
2
2
3
In CPU Interface, if the IRQ has the non-maskable property, report NMI to
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
the corresponding PE.
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-48-peter.maydell@linaro.org
6
---
7
target/rx/cpu.c | 2 ++
8
1 file changed, 2 insertions(+)
5
9
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
10
diff --git a/target/rx/cpu.c b/target/rx/cpu.c
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
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/intc/arm_gicv3_cpuif.c | 4 ++++
13
1 file changed, 4 insertions(+)
14
15
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
16
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/arm_gicv3_cpuif.c
12
--- a/target/rx/cpu.c
18
+++ b/hw/intc/arm_gicv3_cpuif.c
13
+++ b/target/rx/cpu.c
19
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs)
14
@@ -XXX,XX +XXX,XX @@ static void rx_cpu_reset_hold(Object *obj, ResetType type)
20
/* Tell the CPU about its highest priority pending interrupt */
15
* then prefer dest over source", which is float_2nan_prop_s_ab.
21
int irqlevel = 0;
16
*/
22
int fiqlevel = 0;
17
set_float_2nan_prop_rule(float_2nan_prop_x87, &env->fp_status);
23
+ int nmilevel = 0;
18
+ /* Default NaN value: sign bit clear, set frac msb */
24
ARMCPU *cpu = ARM_CPU(cs->cpu);
19
+ set_float_default_nan_pattern(0b01000000, &env->fp_status);
25
CPUARMState *env = &cpu->env;
26
27
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs)
28
29
if (isfiq) {
30
fiqlevel = 1;
31
+ } else if (cs->hppi.nmi) {
32
+ nmilevel = 1;
33
} else {
34
irqlevel = 1;
35
}
36
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_update(GICv3CPUState *cs)
37
38
qemu_set_irq(cs->parent_fiq, fiqlevel);
39
qemu_set_irq(cs->parent_irq, irqlevel);
40
+ qemu_set_irq(cs->parent_nmi, nmilevel);
41
}
20
}
42
21
43
static uint64_t icc_pmr_read(CPUARMState *env, const ARMCPRegInfo *ri)
22
static ObjectClass *rx_cpu_class_by_name(const char *cpu_model)
44
--
23
--
45
2.34.1
24
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for s390x.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-49-peter.maydell@linaro.org
6
---
7
target/s390x/cpu.c | 2 ++
8
1 file changed, 2 insertions(+)
9
10
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/target/s390x/cpu.c
13
+++ b/target/s390x/cpu.c
14
@@ -XXX,XX +XXX,XX @@ static void s390_cpu_reset_hold(Object *obj, ResetType type)
15
set_float_3nan_prop_rule(float_3nan_prop_s_abc, &env->fpu_status);
16
set_float_infzeronan_rule(float_infzeronan_dnan_always,
17
&env->fpu_status);
18
+ /* Default NaN value: sign bit clear, frac msb set */
19
+ set_float_default_nan_pattern(0b01000000, &env->fpu_status);
20
/* fall through */
21
case RESET_TYPE_S390_CPU_NORMAL:
22
env->psw.mask &= ~PSW_MASK_RI;
23
--
24
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for SPARC, and remove
2
the ifdef from parts64_default_nan.
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-50-peter.maydell@linaro.org
7
---
8
target/sparc/cpu.c | 2 ++
9
fpu/softfloat-specialize.c.inc | 5 +----
10
2 files changed, 3 insertions(+), 4 deletions(-)
11
12
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/sparc/cpu.c
15
+++ b/target/sparc/cpu.c
16
@@ -XXX,XX +XXX,XX @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
17
set_float_3nan_prop_rule(float_3nan_prop_s_cba, &env->fp_status);
18
/* For inf * 0 + NaN, return the input NaN */
19
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
20
+ /* Default NaN value: sign bit clear, all frac bits set */
21
+ set_float_default_nan_pattern(0b01111111, &env->fp_status);
22
23
cpu_exec_realizefn(cs, &local_err);
24
if (local_err != NULL) {
25
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
26
index XXXXXXX..XXXXXXX 100644
27
--- a/fpu/softfloat-specialize.c.inc
28
+++ b/fpu/softfloat-specialize.c.inc
29
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
30
uint8_t dnan_pattern = status->default_nan_pattern;
31
32
if (dnan_pattern == 0) {
33
-#if defined(TARGET_SPARC)
34
- /* Sign bit clear, all frac bits set */
35
- dnan_pattern = 0b01111111;
36
-#elif defined(TARGET_HEXAGON)
37
+#if defined(TARGET_HEXAGON)
38
/* Sign bit set, all frac bits set. */
39
dnan_pattern = 0b11111111;
40
#else
41
--
42
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
Set the default NaN pattern explicitly for xtensa.
2
2
3
Add GICD_INMIR, GICD_INMIRnE register and support access GICD_INMIR0.
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-51-peter.maydell@linaro.org
6
---
7
target/xtensa/cpu.c | 2 ++
8
1 file changed, 2 insertions(+)
4
9
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
10
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
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
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/intc/gicv3_internal.h | 2 ++
12
hw/intc/arm_gicv3_dist.c | 34 ++++++++++++++++++++++++++++++++++
13
2 files changed, 36 insertions(+)
14
15
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
16
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/gicv3_internal.h
12
--- a/target/xtensa/cpu.c
18
+++ b/hw/intc/gicv3_internal.h
13
+++ b/target/xtensa/cpu.c
19
@@ -XXX,XX +XXX,XX @@
14
@@ -XXX,XX +XXX,XX @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type)
20
#define GICD_SGIR 0x0F00
15
/* For inf * 0 + NaN, return the input NaN */
21
#define GICD_CPENDSGIR 0x0F10
16
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
22
#define GICD_SPENDSGIR 0x0F20
17
set_no_signaling_nans(!dfpu, &env->fp_status);
23
+#define GICD_INMIR 0x0F80
18
+ /* Default NaN value: sign bit clear, set frac msb */
24
+#define GICD_INMIRnE 0x3B00
19
+ set_float_default_nan_pattern(0b01000000, &env->fp_status);
25
#define GICD_IROUTER 0x6000
20
xtensa_use_first_nan(env, !dfpu);
26
#define GICD_IDREGS 0xFFD0
27
28
diff --git a/hw/intc/arm_gicv3_dist.c b/hw/intc/arm_gicv3_dist.c
29
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/intc/arm_gicv3_dist.c
31
+++ b/hw/intc/arm_gicv3_dist.c
32
@@ -XXX,XX +XXX,XX @@ static int gicd_ns_access(GICv3State *s, int irq)
33
return extract32(s->gicd_nsacr[irq / 16], (irq % 16) * 2, 2);
34
}
21
}
35
22
36
+static void gicd_write_bitmap_reg(GICv3State *s, MemTxAttrs attrs,
37
+ uint32_t *bmp, maskfn *maskfn,
38
+ int offset, uint32_t val)
39
+{
40
+ /*
41
+ * Helper routine to implement writing to a "set" register
42
+ * (GICD_INMIR, etc).
43
+ * Semantics implemented here:
44
+ * RAZ/WI for SGIs, PPIs, unimplemented IRQs
45
+ * Bits corresponding to Group 0 or Secure Group 1 interrupts RAZ/WI.
46
+ * offset should be the offset in bytes of the register from the start
47
+ * of its group.
48
+ */
49
+ int irq = offset * 8;
50
+
51
+ if (irq < GIC_INTERNAL || irq >= s->num_irq) {
52
+ return;
53
+ }
54
+ val &= mask_group_and_nsacr(s, attrs, maskfn, irq);
55
+ *gic_bmp_ptr32(bmp, irq) = val;
56
+ gicv3_update(s, irq, 32);
57
+}
58
+
59
static void gicd_write_set_bitmap_reg(GICv3State *s, MemTxAttrs attrs,
60
uint32_t *bmp,
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;
87
--
23
--
88
2.34.1
24
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
Set the default NaN pattern explicitly for hexagon.
2
Remove the ifdef from parts64_default_nan(); the only
3
remaining unconverted targets all use the default case.
2
4
3
In vCPU Interface, if the vIRQ has the non-maskable property, report
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
vINMI to the corresponding vPE.
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20241202131347.498124-52-peter.maydell@linaro.org
8
---
9
target/hexagon/cpu.c | 2 ++
10
fpu/softfloat-specialize.c.inc | 5 -----
11
2 files changed, 2 insertions(+), 5 deletions(-)
5
12
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
13
diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20240407081733.3231820-23-ruanjinjie@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
hw/intc/arm_gicv3_cpuif.c | 14 ++++++++++++--
13
1 file changed, 12 insertions(+), 2 deletions(-)
14
15
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
16
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/arm_gicv3_cpuif.c
15
--- a/target/hexagon/cpu.c
18
+++ b/hw/intc/arm_gicv3_cpuif.c
16
+++ b/target/hexagon/cpu.c
19
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs)
17
@@ -XXX,XX +XXX,XX @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type)
20
int idx;
18
21
int irqlevel = 0;
19
set_default_nan_mode(1, &env->fp_status);
22
int fiqlevel = 0;
20
set_float_detect_tininess(float_tininess_before_rounding, &env->fp_status);
23
+ int nmilevel = 0;
21
+ /* Default NaN value: sign bit set, all frac bits set */
24
22
+ set_float_default_nan_pattern(0b11111111, &env->fp_status);
25
idx = hppvi_index(cs);
26
trace_gicv3_cpuif_virt_update(gicv3_redist_affid(cs), idx,
27
@@ -XXX,XX +XXX,XX @@ void gicv3_cpuif_virt_irq_fiq_update(GICv3CPUState *cs)
28
uint64_t lr = cs->ich_lr_el2[idx];
29
30
if (icv_hppi_can_preempt(cs, lr)) {
31
- /* Virtual interrupts are simple: G0 are always FIQ, and G1 IRQ */
32
+ /*
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);
52
}
23
}
53
24
54
static void gicv3_cpuif_virt_update(GICv3CPUState *cs)
25
static void hexagon_cpu_disas_set_info(CPUState *s, disassemble_info *info)
26
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
27
index XXXXXXX..XXXXXXX 100644
28
--- a/fpu/softfloat-specialize.c.inc
29
+++ b/fpu/softfloat-specialize.c.inc
30
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
31
uint8_t dnan_pattern = status->default_nan_pattern;
32
33
if (dnan_pattern == 0) {
34
-#if defined(TARGET_HEXAGON)
35
- /* Sign bit set, all frac bits set. */
36
- dnan_pattern = 0b11111111;
37
-#else
38
/*
39
* This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V,
40
* S390, SH4, TriCore, and Xtensa. Our other supported targets
41
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
42
/* sign bit clear, set frac msb */
43
dnan_pattern = 0b01000000;
44
}
45
-#endif
46
}
47
assert(dnan_pattern != 0);
48
55
--
49
--
56
2.34.1
50
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for riscv.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-53-peter.maydell@linaro.org
6
---
7
target/riscv/cpu.c | 2 ++
8
1 file changed, 2 insertions(+)
9
10
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/target/riscv/cpu.c
13
+++ b/target/riscv/cpu.c
14
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset_hold(Object *obj, ResetType type)
15
cs->exception_index = RISCV_EXCP_NONE;
16
env->load_res = -1;
17
set_default_nan_mode(1, &env->fp_status);
18
+ /* Default NaN value: sign bit clear, frac msb set */
19
+ set_float_default_nan_pattern(0b01000000, &env->fp_status);
20
env->vill = true;
21
22
#ifndef CONFIG_USER_ONLY
23
--
24
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
Set the default NaN pattern explicitly for tricore.
2
2
3
Add GICR_INMIR0 register and support access GICR_INMIR0.
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-54-peter.maydell@linaro.org
6
---
7
target/tricore/helper.c | 2 ++
8
1 file changed, 2 insertions(+)
4
9
5
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
10
diff --git a/target/tricore/helper.c b/target/tricore/helper.c
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
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>
10
---
11
hw/intc/gicv3_internal.h | 1 +
12
hw/intc/arm_gicv3_redist.c | 19 +++++++++++++++++++
13
2 files changed, 20 insertions(+)
14
15
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
16
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/intc/gicv3_internal.h
12
--- a/target/tricore/helper.c
18
+++ b/hw/intc/gicv3_internal.h
13
+++ b/target/tricore/helper.c
19
@@ -XXX,XX +XXX,XX @@
14
@@ -XXX,XX +XXX,XX @@ void fpu_set_state(CPUTriCoreState *env)
20
#define GICR_ICFGR1 (GICR_SGI_OFFSET + 0x0C04)
15
set_flush_to_zero(1, &env->fp_status);
21
#define GICR_IGRPMODR0 (GICR_SGI_OFFSET + 0x0D00)
16
set_float_detect_tininess(float_tininess_before_rounding, &env->fp_status);
22
#define GICR_NSACR (GICR_SGI_OFFSET + 0x0E00)
17
set_default_nan_mode(1, &env->fp_status);
23
+#define GICR_INMIR0 (GICR_SGI_OFFSET + 0x0F80)
18
+ /* Default NaN pattern: sign bit clear, frac msb set */
24
19
+ set_float_default_nan_pattern(0b01000000, &env->fp_status);
25
/* VLPI redistributor registers, offsets from VLPI_base */
26
#define GICR_VPROPBASER (GICR_VLPI_OFFSET + 0x70)
27
diff --git a/hw/intc/arm_gicv3_redist.c b/hw/intc/arm_gicv3_redist.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/intc/arm_gicv3_redist.c
30
+++ b/hw/intc/arm_gicv3_redist.c
31
@@ -XXX,XX +XXX,XX @@ static int gicr_ns_access(GICv3CPUState *cs, int irq)
32
return extract32(cs->gicr_nsacr, irq * 2, 2);
33
}
20
}
34
21
35
+static void gicr_write_bitmap_reg(GICv3CPUState *cs, MemTxAttrs attrs,
22
uint32_t psw_read(CPUTriCoreState *env)
36
+ uint32_t *reg, uint32_t val)
37
+{
38
+ /* Helper routine to implement writing to a "set" register */
39
+ val &= mask_group(cs, attrs);
40
+ *reg = val;
41
+ gicv3_redist_update(cs);
42
+}
43
+
44
static void gicr_write_set_bitmap_reg(GICv3CPUState *cs, MemTxAttrs attrs,
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;
67
+
68
case GICR_ICFGR0:
69
/* Register is all RAZ/WI or RAO/WI bits */
70
return MEMTX_OK;
71
--
23
--
72
2.34.1
24
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
Now that all our targets have bene converted to explicitly specify
2
their pattern for the default NaN value we can remove the remaining
3
fallback code in parts64_default_nan().
2
4
3
According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
with superpriority is always IRQ, never FIQ, so the NMI exception trap entry
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
behave like IRQ. And VINMI(vIRQ with Superpriority) can be raised from the
7
Message-id: 20241202131347.498124-55-peter.maydell@linaro.org
6
GIC or come from the hcrx_el2.HCRX_VINMI bit, VFNMI(vFIQ with Superpriority)
8
---
7
come from the hcrx_el2.HCRX_VFNMI bit.
9
fpu/softfloat-specialize.c.inc | 14 --------------
10
1 file changed, 14 deletions(-)
8
11
9
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
12
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
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
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
target/arm/helper.c | 3 +++
16
1 file changed, 3 insertions(+)
17
18
diff --git a/target/arm/helper.c b/target/arm/helper.c
19
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/helper.c
14
--- a/fpu/softfloat-specialize.c.inc
21
+++ b/target/arm/helper.c
15
+++ b/fpu/softfloat-specialize.c.inc
22
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
16
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
23
break;
17
uint64_t frac;
24
case EXCP_IRQ:
18
uint8_t dnan_pattern = status->default_nan_pattern;
25
case EXCP_VIRQ:
19
26
+ case EXCP_NMI:
20
- if (dnan_pattern == 0) {
27
+ case EXCP_VINMI:
21
- /*
28
addr += 0x80;
22
- * This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V,
29
break;
23
- * S390, SH4, TriCore, and Xtensa. Our other supported targets
30
case EXCP_FIQ:
24
- * do not have floating-point.
31
case EXCP_VFIQ:
25
- */
32
+ case EXCP_VFNMI:
26
- if (snan_bit_is_one(status)) {
33
addr += 0x100;
27
- /* sign bit clear, set all frac bits other than msb */
34
break;
28
- dnan_pattern = 0b00111111;
35
case EXCP_VSERR:
29
- } else {
30
- /* sign bit clear, set frac msb */
31
- dnan_pattern = 0b01000000;
32
- }
33
- }
34
assert(dnan_pattern != 0);
35
36
sign = dnan_pattern >> 7;
36
--
37
--
37
2.34.1
38
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Add IS and FS bit in ISR_EL1 and handle the read. With CPU_INTERRUPT_NMI or
3
Inline pickNaNMulAdd into its only caller. This makes
4
CPU_INTERRUPT_VINMI, both CPSR_I and ISR_IS must be set. With
4
one assert redundant with the immediately preceding IF.
5
CPU_INTERRUPT_VFNMI, both CPSR_F and ISR_FS must be set.
6
5
7
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20241203203949.483774-3-richard.henderson@linaro.org
10
Message-id: 20240407081733.3231820-9-ruanjinjie@huawei.com
9
[PMM: keep comment from old code in new location]
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
target/arm/cpu.h | 2 ++
12
fpu/softfloat-parts.c.inc | 41 +++++++++++++++++++++++++-
14
target/arm/helper.c | 13 +++++++++++++
13
fpu/softfloat-specialize.c.inc | 54 ----------------------------------
15
2 files changed, 15 insertions(+)
14
2 files changed, 40 insertions(+), 55 deletions(-)
16
15
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
16
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
18
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
18
--- a/fpu/softfloat-parts.c.inc
20
+++ b/target/arm/cpu.h
19
+++ b/fpu/softfloat-parts.c.inc
21
@@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu);
20
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
22
#define CPSR_N (1U << 31)
21
}
23
#define CPSR_NZCV (CPSR_N | CPSR_Z | CPSR_C | CPSR_V)
22
24
#define CPSR_AIF (CPSR_A | CPSR_I | CPSR_F)
23
if (s->default_nan_mode) {
25
+#define ISR_FS (1U << 9)
24
+ /*
26
+#define ISR_IS (1U << 10)
25
+ * We guarantee not to require the target to tell us how to
27
26
+ * pick a NaN if we're always returning the default NaN.
28
#define CPSR_IT (CPSR_IT_0_1 | CPSR_IT_2_7)
27
+ * But if we're not in default-NaN mode then the target must
29
#define CACHED_CPSR_BITS (CPSR_T | CPSR_AIF | CPSR_GE | CPSR_IT | CPSR_Q \
28
+ * specify.
30
diff --git a/target/arm/helper.c b/target/arm/helper.c
29
+ */
31
index XXXXXXX..XXXXXXX 100644
30
which = 3;
32
--- a/target/arm/helper.c
31
+ } else if (infzero) {
33
+++ b/target/arm/helper.c
32
+ /*
34
@@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri)
33
+ * Inf * 0 + NaN -- some implementations return the
35
if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) {
34
+ * default NaN here, and some return the input NaN.
36
ret |= CPSR_I;
35
+ */
37
}
36
+ switch (s->float_infzeronan_rule) {
38
+ if (cs->interrupt_request & CPU_INTERRUPT_VINMI) {
37
+ case float_infzeronan_dnan_never:
39
+ ret |= ISR_IS;
38
+ which = 2;
40
+ ret |= CPSR_I;
39
+ break;
40
+ case float_infzeronan_dnan_always:
41
+ which = 3;
42
+ break;
43
+ case float_infzeronan_dnan_if_qnan:
44
+ which = is_qnan(c->cls) ? 3 : 2;
45
+ break;
46
+ default:
47
+ g_assert_not_reached();
41
+ }
48
+ }
42
} else {
49
} else {
43
if (cs->interrupt_request & CPU_INTERRUPT_HARD) {
50
- which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, have_snan, s);
44
ret |= CPSR_I;
51
+ FloatClass cls[3] = { a->cls, b->cls, c->cls };
45
}
52
+ Float3NaNPropRule rule = s->float_3nan_prop_rule;
46
+
53
+
47
+ if (cs->interrupt_request & CPU_INTERRUPT_NMI) {
54
+ assert(rule != float_3nan_prop_none);
48
+ ret |= ISR_IS;
55
+ if (have_snan && (rule & R_3NAN_SNAN_MASK)) {
49
+ ret |= CPSR_I;
56
+ /* We have at least one SNaN input and should prefer it */
57
+ do {
58
+ which = rule & R_3NAN_1ST_MASK;
59
+ rule >>= R_3NAN_1ST_LENGTH;
60
+ } while (!is_snan(cls[which]));
61
+ } else {
62
+ do {
63
+ which = rule & R_3NAN_1ST_MASK;
64
+ rule >>= R_3NAN_1ST_LENGTH;
65
+ } while (!is_nan(cls[which]));
50
+ }
66
+ }
51
}
67
}
52
68
53
if (hcr_el2 & HCR_FMO) {
69
if (which == 3) {
54
if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) {
70
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
55
ret |= CPSR_F;
71
index XXXXXXX..XXXXXXX 100644
56
}
72
--- a/fpu/softfloat-specialize.c.inc
57
+ if (cs->interrupt_request & CPU_INTERRUPT_VFNMI) {
73
+++ b/fpu/softfloat-specialize.c.inc
58
+ ret |= ISR_FS;
74
@@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
59
+ ret |= CPSR_F;
75
}
60
+ }
76
}
61
} else {
77
62
if (cs->interrupt_request & CPU_INTERRUPT_FIQ) {
78
-/*----------------------------------------------------------------------------
63
ret |= CPSR_F;
79
-| Select which NaN to propagate for a three-input operation.
80
-| For the moment we assume that no CPU needs the 'larger significand'
81
-| information.
82
-| Return values : 0 : a; 1 : b; 2 : c; 3 : default-NaN
83
-*----------------------------------------------------------------------------*/
84
-static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
85
- bool infzero, bool have_snan, float_status *status)
86
-{
87
- FloatClass cls[3] = { a_cls, b_cls, c_cls };
88
- Float3NaNPropRule rule = status->float_3nan_prop_rule;
89
- int which;
90
-
91
- /*
92
- * We guarantee not to require the target to tell us how to
93
- * pick a NaN if we're always returning the default NaN.
94
- * But if we're not in default-NaN mode then the target must
95
- * specify.
96
- */
97
- assert(!status->default_nan_mode);
98
-
99
- if (infzero) {
100
- /*
101
- * Inf * 0 + NaN -- some implementations return the default NaN here,
102
- * and some return the input NaN.
103
- */
104
- switch (status->float_infzeronan_rule) {
105
- case float_infzeronan_dnan_never:
106
- return 2;
107
- case float_infzeronan_dnan_always:
108
- return 3;
109
- case float_infzeronan_dnan_if_qnan:
110
- return is_qnan(c_cls) ? 3 : 2;
111
- default:
112
- g_assert_not_reached();
113
- }
114
- }
115
-
116
- assert(rule != float_3nan_prop_none);
117
- if (have_snan && (rule & R_3NAN_SNAN_MASK)) {
118
- /* We have at least one SNaN input and should prefer it */
119
- do {
120
- which = rule & R_3NAN_1ST_MASK;
121
- rule >>= R_3NAN_1ST_LENGTH;
122
- } while (!is_snan(cls[which]));
123
- } else {
124
- do {
125
- which = rule & R_3NAN_1ST_MASK;
126
- rule >>= R_3NAN_1ST_LENGTH;
127
- } while (!is_nan(cls[which]));
128
- }
129
- return which;
130
-}
131
-
132
/*----------------------------------------------------------------------------
133
| Returns 1 if the double-precision floating-point value `a' is a quiet
134
| NaN; otherwise returns 0.
64
--
135
--
65
2.34.1
136
2.34.1
137
138
diff view generated by jsdifflib
1
The npcm7xx_clk and npcm7xx_gcr device reset methods look at
1
From: Richard Henderson <richard.henderson@linaro.org>
2
the ResetType argument and only handle RESET_TYPE_COLD,
3
producing a warning if another reset type is passed. This
4
is different from how every other three-phase-reset method
5
we have works, and makes it difficult to add new reset types.
6
2
7
A better pattern is "assume that any reset type you don't know
3
Remove "3" as a special case for which and simply
8
about should be handled like RESET_TYPE_COLD"; switch these
4
branch to return the desired value.
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.
12
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20241203203949.483774-4-richard.henderson@linaro.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@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
18
---
10
---
19
hw/misc/npcm7xx_clk.c | 13 +++----------
11
fpu/softfloat-parts.c.inc | 20 ++++++++++----------
20
hw/misc/npcm7xx_gcr.c | 12 ++++--------
12
1 file changed, 10 insertions(+), 10 deletions(-)
21
2 files changed, 7 insertions(+), 18 deletions(-)
22
13
23
diff --git a/hw/misc/npcm7xx_clk.c b/hw/misc/npcm7xx_clk.c
14
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
24
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
25
--- a/hw/misc/npcm7xx_clk.c
16
--- a/fpu/softfloat-parts.c.inc
26
+++ b/hw/misc/npcm7xx_clk.c
17
+++ b/fpu/softfloat-parts.c.inc
27
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_clk_enter_reset(Object *obj, ResetType type)
18
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
28
19
* But if we're not in default-NaN mode then the target must
29
QEMU_BUILD_BUG_ON(sizeof(s->regs) != sizeof(cold_reset_values));
20
* specify.
30
21
*/
31
- switch (type) {
22
- which = 3;
32
- case RESET_TYPE_COLD:
23
+ goto default_nan;
33
- memcpy(s->regs, cold_reset_values, sizeof(cold_reset_values));
24
} else if (infzero) {
34
- s->ref_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
25
/*
35
- npcm7xx_clk_update_all_clocks(s);
26
* Inf * 0 + NaN -- some implementations return the
36
- return;
27
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
28
*/
29
switch (s->float_infzeronan_rule) {
30
case float_infzeronan_dnan_never:
31
- which = 2;
32
break;
33
case float_infzeronan_dnan_always:
34
- which = 3;
35
- break;
36
+ goto default_nan;
37
case float_infzeronan_dnan_if_qnan:
38
- which = is_qnan(c->cls) ? 3 : 2;
39
+ if (is_qnan(c->cls)) {
40
+ goto default_nan;
41
+ }
42
break;
43
default:
44
g_assert_not_reached();
45
}
46
+ which = 2;
47
} else {
48
FloatClass cls[3] = { a->cls, b->cls, c->cls };
49
Float3NaNPropRule rule = s->float_3nan_prop_rule;
50
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
51
}
52
}
53
54
- if (which == 3) {
55
- parts_default_nan(a, s);
56
- return a;
37
- }
57
- }
38
-
58
-
39
+ memcpy(s->regs, cold_reset_values, sizeof(cold_reset_values));
59
switch (which) {
40
+ s->ref_ns = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
60
case 0:
41
+ npcm7xx_clk_update_all_clocks(s);
61
break;
42
/*
62
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
43
* A small number of registers need to be reset on a core domain reset,
63
parts_silence_nan(a, s);
44
* but no such reset type exists yet.
64
}
45
*/
65
return a;
46
- qemu_log_mask(LOG_UNIMP, "%s: reset type %d not implemented.",
66
+
47
- __func__, type);
67
+ default_nan:
68
+ parts_default_nan(a, s);
69
+ return a;
48
}
70
}
49
71
50
static void npcm7xx_clk_init_clock_hierarchy(NPCM7xxCLKState *s)
72
/*
51
diff --git a/hw/misc/npcm7xx_gcr.c b/hw/misc/npcm7xx_gcr.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/misc/npcm7xx_gcr.c
54
+++ b/hw/misc/npcm7xx_gcr.c
55
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_gcr_enter_reset(Object *obj, ResetType type)
56
57
QEMU_BUILD_BUG_ON(sizeof(s->regs) != sizeof(cold_reset_values));
58
59
- switch (type) {
60
- case RESET_TYPE_COLD:
61
- memcpy(s->regs, cold_reset_values, sizeof(s->regs));
62
- s->regs[NPCM7XX_GCR_PWRON] = s->reset_pwron;
63
- s->regs[NPCM7XX_GCR_MDLR] = s->reset_mdlr;
64
- s->regs[NPCM7XX_GCR_INTCR3] = s->reset_intcr3;
65
- break;
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;
71
}
72
73
static void npcm7xx_gcr_realize(DeviceState *dev, Error **errp)
74
--
73
--
75
2.34.1
74
2.34.1
76
75
77
76
diff view generated by jsdifflib
1
Update the reset documentation's example code to match the new API
1
From: Richard Henderson <richard.henderson@linaro.org>
2
for the hold and exit phase method APIs where they take a ResetType
3
argument.
4
2
3
Assign the pointer return value to 'a' directly,
4
rather than going through an intermediary index.
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20241203203949.483774-5-richard.henderson@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@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
docs/devel/reset.rst | 8 ++++----
11
fpu/softfloat-parts.c.inc | 32 ++++++++++----------------------
12
1 file changed, 4 insertions(+), 4 deletions(-)
12
1 file changed, 10 insertions(+), 22 deletions(-)
13
13
14
diff --git a/docs/devel/reset.rst b/docs/devel/reset.rst
14
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/docs/devel/reset.rst
16
--- a/fpu/softfloat-parts.c.inc
17
+++ b/docs/devel/reset.rst
17
+++ b/fpu/softfloat-parts.c.inc
18
@@ -XXX,XX +XXX,XX @@ in reset.
18
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
19
mydev->var = 0;
19
FloatPartsN *c, float_status *s,
20
int ab_mask, int abc_mask)
21
{
22
- int which;
23
bool infzero = (ab_mask == float_cmask_infzero);
24
bool have_snan = (abc_mask & float_cmask_snan);
25
+ FloatPartsN *ret;
26
27
if (unlikely(have_snan)) {
28
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
29
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
30
default:
31
g_assert_not_reached();
32
}
33
- which = 2;
34
+ ret = c;
35
} else {
36
- FloatClass cls[3] = { a->cls, b->cls, c->cls };
37
+ FloatPartsN *val[3] = { a, b, c };
38
Float3NaNPropRule rule = s->float_3nan_prop_rule;
39
40
assert(rule != float_3nan_prop_none);
41
if (have_snan && (rule & R_3NAN_SNAN_MASK)) {
42
/* We have at least one SNaN input and should prefer it */
43
do {
44
- which = rule & R_3NAN_1ST_MASK;
45
+ ret = val[rule & R_3NAN_1ST_MASK];
46
rule >>= R_3NAN_1ST_LENGTH;
47
- } while (!is_snan(cls[which]));
48
+ } while (!is_snan(ret->cls));
49
} else {
50
do {
51
- which = rule & R_3NAN_1ST_MASK;
52
+ ret = val[rule & R_3NAN_1ST_MASK];
53
rule >>= R_3NAN_1ST_LENGTH;
54
- } while (!is_nan(cls[which]));
55
+ } while (!is_nan(ret->cls));
56
}
20
}
57
}
21
58
22
- static void mydev_reset_hold(Object *obj)
59
- switch (which) {
23
+ static void mydev_reset_hold(Object *obj, ResetType type)
60
- case 0:
24
{
61
- break;
25
MyDevClass *myclass = MYDEV_GET_CLASS(obj);
62
- case 1:
26
MyDevState *mydev = MYDEV(obj);
63
- a = b;
27
/* call parent class hold phase */
64
- break;
28
if (myclass->parent_phases.hold) {
65
- case 2:
29
- myclass->parent_phases.hold(obj);
66
- a = c;
30
+ myclass->parent_phases.hold(obj, type);
67
- break;
31
}
68
- default:
32
/* set an IO */
69
- g_assert_not_reached();
33
qemu_set_irq(mydev->irq, 1);
70
+ if (is_snan(ret->cls)) {
71
+ parts_silence_nan(ret, s);
34
}
72
}
35
73
- if (is_snan(a->cls)) {
36
- static void mydev_reset_exit(Object *obj)
74
- parts_silence_nan(a, s);
37
+ static void mydev_reset_exit(Object *obj, ResetType type)
75
- }
38
{
76
- return a;
39
MyDevClass *myclass = MYDEV_GET_CLASS(obj);
77
+ return ret;
40
MyDevState *mydev = MYDEV(obj);
78
41
/* call parent class exit phase */
79
default_nan:
42
if (myclass->parent_phases.exit) {
80
parts_default_nan(a, s);
43
- myclass->parent_phases.exit(obj);
44
+ myclass->parent_phases.exit(obj, type);
45
}
46
/* clear an IO */
47
qemu_set_irq(mydev->irq, 0);
48
--
81
--
49
2.34.1
82
2.34.1
50
83
51
84
diff view generated by jsdifflib
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Test:
3
While all indices into val[] should be in [0-2], the mask
4
- read/write from/to the usart registers
4
applied is two bits. To help static analysis see there is
5
- send/receive a character/string over the serial port
5
no possibility of read beyond the end of the array, pad the
6
array to 4 entries, with the final being (implicitly) NULL.
6
7
7
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20241203203949.483774-6-richard.henderson@linaro.org
10
Message-id: 20240329174402.60382-6-arnaud.minier@telecom-paris.fr
11
[PMM: fix checkpatch nits, remove commented out code]
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
12
---
14
tests/qtest/stm32l4x5_usart-test.c | 315 +++++++++++++++++++++++++++++
13
fpu/softfloat-parts.c.inc | 2 +-
15
tests/qtest/meson.build | 4 +-
14
1 file changed, 1 insertion(+), 1 deletion(-)
16
2 files changed, 318 insertions(+), 1 deletion(-)
17
create mode 100644 tests/qtest/stm32l4x5_usart-test.c
18
15
19
diff --git a/tests/qtest/stm32l4x5_usart-test.c b/tests/qtest/stm32l4x5_usart-test.c
16
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
20
new file mode 100644
21
index XXXXXXX..XXXXXXX
22
--- /dev/null
23
+++ b/tests/qtest/stm32l4x5_usart-test.c
24
@@ -XXX,XX +XXX,XX @@
25
+/*
26
+ * QTest testcase for STML4X5_USART
27
+ *
28
+ * Copyright (c) 2023 Arnaud Minier <arnaud.minier@telecom-paris.fr>
29
+ * Copyright (c) 2023 Inès Varhol <ines.varhol@telecom-paris.fr>
30
+ *
31
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
32
+ * See the COPYING file in the top-level directory.
33
+ */
34
+
35
+#include "qemu/osdep.h"
36
+#include "libqtest.h"
37
+#include "hw/misc/stm32l4x5_rcc_internals.h"
38
+#include "hw/registerfields.h"
39
+
40
+#define RCC_BASE_ADDR 0x40021000
41
+/* Use USART 1 ADDR, assume the others work the same */
42
+#define USART1_BASE_ADDR 0x40013800
43
+
44
+/* See stm32l4x5_usart for definitions */
45
+REG32(CR1, 0x00)
46
+ FIELD(CR1, M1, 28, 1)
47
+ FIELD(CR1, OVER8, 15, 1)
48
+ FIELD(CR1, M0, 12, 1)
49
+ FIELD(CR1, PCE, 10, 1)
50
+ FIELD(CR1, TXEIE, 7, 1)
51
+ FIELD(CR1, RXNEIE, 5, 1)
52
+ FIELD(CR1, TE, 3, 1)
53
+ FIELD(CR1, RE, 2, 1)
54
+ FIELD(CR1, UE, 0, 1)
55
+REG32(CR2, 0x04)
56
+REG32(CR3, 0x08)
57
+ FIELD(CR3, OVRDIS, 12, 1)
58
+REG32(BRR, 0x0C)
59
+REG32(GTPR, 0x10)
60
+REG32(RTOR, 0x14)
61
+REG32(RQR, 0x18)
62
+REG32(ISR, 0x1C)
63
+ FIELD(ISR, TXE, 7, 1)
64
+ FIELD(ISR, RXNE, 5, 1)
65
+ FIELD(ISR, ORE, 3, 1)
66
+REG32(ICR, 0x20)
67
+REG32(RDR, 0x24)
68
+REG32(TDR, 0x28)
69
+
70
+#define NVIC_ISPR1 0XE000E204
71
+#define NVIC_ICPR1 0xE000E284
72
+#define USART1_IRQ 37
73
+
74
+static bool check_nvic_pending(QTestState *qts, unsigned int n)
75
+{
76
+ /* No USART interrupts are less than 32 */
77
+ assert(n > 32);
78
+ n -= 32;
79
+ return qtest_readl(qts, NVIC_ISPR1) & (1 << n);
80
+}
81
+
82
+static bool clear_nvic_pending(QTestState *qts, unsigned int n)
83
+{
84
+ /* No USART interrupts are less than 32 */
85
+ assert(n > 32);
86
+ n -= 32;
87
+ qtest_writel(qts, NVIC_ICPR1, (1 << n));
88
+ return true;
89
+}
90
+
91
+/*
92
+ * Wait indefinitely for the flag to be updated.
93
+ * If this is run on a slow CI runner,
94
+ * the meson harness will timeout after 10 minutes for us.
95
+ */
96
+static bool usart_wait_for_flag(QTestState *qts, uint32_t event_addr,
97
+ uint32_t flag)
98
+{
99
+ while (true) {
100
+ if ((qtest_readl(qts, event_addr) & flag)) {
101
+ return true;
102
+ }
103
+ g_usleep(1000);
104
+ }
105
+
106
+ return false;
107
+}
108
+
109
+static void usart_receive_string(QTestState *qts, int sock_fd, const char *in,
110
+ char *out)
111
+{
112
+ int i, in_len = strlen(in);
113
+
114
+ g_assert_true(send(sock_fd, in, in_len, 0) == in_len);
115
+ for (i = 0; i < in_len; i++) {
116
+ g_assert_true(usart_wait_for_flag(qts,
117
+ USART1_BASE_ADDR + A_ISR, R_ISR_RXNE_MASK));
118
+ out[i] = qtest_readl(qts, USART1_BASE_ADDR + A_RDR);
119
+ }
120
+ out[i] = '\0';
121
+}
122
+
123
+static void usart_send_string(QTestState *qts, const char *in)
124
+{
125
+ int i, in_len = strlen(in);
126
+
127
+ for (i = 0; i < in_len; i++) {
128
+ qtest_writel(qts, USART1_BASE_ADDR + A_TDR, in[i]);
129
+ g_assert_true(usart_wait_for_flag(qts,
130
+ USART1_BASE_ADDR + A_ISR, R_ISR_TXE_MASK));
131
+ }
132
+}
133
+
134
+/* Init the RCC clocks to run at 80 MHz */
135
+static void init_clocks(QTestState *qts)
136
+{
137
+ uint32_t value;
138
+
139
+ /* MSIRANGE can be set only when MSI is OFF or READY */
140
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CR), R_CR_MSION_MASK);
141
+
142
+ /* Clocking from MSI, in case MSI was not the default source */
143
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CFGR), 0);
144
+
145
+ /*
146
+ * Update PLL and set MSI as the source clock.
147
+ * PLLM = 1 --> 000
148
+ * PLLN = 40 --> 40
149
+ * PPLLR = 2 --> 00
150
+ * PLLDIV = unused, PLLP = unused (SAI3), PLLQ = unused (48M1)
151
+ * SRC = MSI --> 01
152
+ */
153
+ qtest_writel(qts, (RCC_BASE_ADDR + A_PLLCFGR), R_PLLCFGR_PLLREN_MASK |
154
+ (40 << R_PLLCFGR_PLLN_SHIFT) |
155
+ (0b01 << R_PLLCFGR_PLLSRC_SHIFT));
156
+
157
+ /* PLL activation */
158
+
159
+ value = qtest_readl(qts, (RCC_BASE_ADDR + A_CR));
160
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CR), value | R_CR_PLLON_MASK);
161
+
162
+ /* RCC_CFGR is OK by defaut */
163
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CFGR), 0);
164
+
165
+ /* CCIPR : no periph clock by default */
166
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CCIPR), 0);
167
+
168
+ /* Switches on the PLL clock source */
169
+ value = qtest_readl(qts, (RCC_BASE_ADDR + A_CFGR));
170
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CFGR), (value & ~R_CFGR_SW_MASK) |
171
+ (0b11 << R_CFGR_SW_SHIFT));
172
+
173
+ /* Enable SYSCFG clock enabled */
174
+ qtest_writel(qts, (RCC_BASE_ADDR + A_APB2ENR), R_APB2ENR_SYSCFGEN_MASK);
175
+
176
+ /* Enable the IO port B clock (See p.252) */
177
+ qtest_writel(qts, (RCC_BASE_ADDR + A_AHB2ENR), R_AHB2ENR_GPIOBEN_MASK);
178
+
179
+ /* Enable the clock for USART1 (cf p.259) */
180
+ /* We rewrite SYSCFGEN to not disable it */
181
+ qtest_writel(qts, (RCC_BASE_ADDR + A_APB2ENR),
182
+ R_APB2ENR_SYSCFGEN_MASK | R_APB2ENR_USART1EN_MASK);
183
+
184
+ /* TODO: Enable usart via gpio */
185
+
186
+ /* Set PCLK as the clock for USART1(cf p.272) i.e. reset both bits */
187
+ qtest_writel(qts, (RCC_BASE_ADDR + A_CCIPR), 0);
188
+
189
+ /* Reset USART1 (see p.249) */
190
+ qtest_writel(qts, (RCC_BASE_ADDR + A_APB2RSTR), 1 << 14);
191
+ qtest_writel(qts, (RCC_BASE_ADDR + A_APB2RSTR), 0);
192
+}
193
+
194
+static void init_uart(QTestState *qts)
195
+{
196
+ uint32_t cr1;
197
+
198
+ init_clocks(qts);
199
+
200
+ /*
201
+ * For 115200 bauds, see p.1349.
202
+ * The clock has a frequency of 80Mhz,
203
+ * for 115200, we have to put a divider of 695 = 0x2B7.
204
+ */
205
+ qtest_writel(qts, (USART1_BASE_ADDR + A_BRR), 0x2B7);
206
+
207
+ /*
208
+ * Set the oversampling by 16,
209
+ * disable the parity control and
210
+ * set the word length to 8. (cf p.1377)
211
+ */
212
+ cr1 = qtest_readl(qts, (USART1_BASE_ADDR + A_CR1));
213
+ cr1 &= ~(R_CR1_M1_MASK | R_CR1_M0_MASK | R_CR1_OVER8_MASK | R_CR1_PCE_MASK);
214
+ qtest_writel(qts, (USART1_BASE_ADDR + A_CR1), cr1);
215
+
216
+ /* Enable the transmitter, the receiver and the USART. */
217
+ qtest_writel(qts, (USART1_BASE_ADDR + A_CR1),
218
+ R_CR1_UE_MASK | R_CR1_RE_MASK | R_CR1_TE_MASK);
219
+}
220
+
221
+static void test_write_read(void)
222
+{
223
+ QTestState *qts = qtest_init("-M b-l475e-iot01a");
224
+
225
+ /* Test that we can write and retrieve a value from the device */
226
+ qtest_writel(qts, USART1_BASE_ADDR + A_TDR, 0xFFFFFFFF);
227
+ const uint32_t tdr = qtest_readl(qts, USART1_BASE_ADDR + A_TDR);
228
+ g_assert_cmpuint(tdr, ==, 0x000001FF);
229
+}
230
+
231
+static void test_receive_char(void)
232
+{
233
+ int sock_fd;
234
+ uint32_t cr1;
235
+ QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd);
236
+
237
+ init_uart(qts);
238
+
239
+ /* Try without initializing IRQ */
240
+ g_assert_true(send(sock_fd, "a", 1, 0) == 1);
241
+ usart_wait_for_flag(qts, USART1_BASE_ADDR + A_ISR, R_ISR_RXNE_MASK);
242
+ g_assert_cmphex(qtest_readl(qts, USART1_BASE_ADDR + A_RDR), ==, 'a');
243
+ g_assert_false(check_nvic_pending(qts, USART1_IRQ));
244
+
245
+ /* Now with the IRQ */
246
+ cr1 = qtest_readl(qts, (USART1_BASE_ADDR + A_CR1));
247
+ cr1 |= R_CR1_RXNEIE_MASK;
248
+ qtest_writel(qts, USART1_BASE_ADDR + A_CR1, cr1);
249
+ g_assert_true(send(sock_fd, "b", 1, 0) == 1);
250
+ usart_wait_for_flag(qts, USART1_BASE_ADDR + A_ISR, R_ISR_RXNE_MASK);
251
+ g_assert_cmphex(qtest_readl(qts, USART1_BASE_ADDR + A_RDR), ==, 'b');
252
+ g_assert_true(check_nvic_pending(qts, USART1_IRQ));
253
+ clear_nvic_pending(qts, USART1_IRQ);
254
+
255
+ close(sock_fd);
256
+
257
+ qtest_quit(qts);
258
+}
259
+
260
+static void test_send_char(void)
261
+{
262
+ int sock_fd;
263
+ char s[1];
264
+ uint32_t cr1;
265
+ QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd);
266
+
267
+ init_uart(qts);
268
+
269
+ /* Try without initializing IRQ */
270
+ qtest_writel(qts, USART1_BASE_ADDR + A_TDR, 'c');
271
+ g_assert_true(recv(sock_fd, s, 1, 0) == 1);
272
+ g_assert_cmphex(s[0], ==, 'c');
273
+ g_assert_false(check_nvic_pending(qts, USART1_IRQ));
274
+
275
+ /* Now with the IRQ */
276
+ cr1 = qtest_readl(qts, (USART1_BASE_ADDR + A_CR1));
277
+ cr1 |= R_CR1_TXEIE_MASK;
278
+ qtest_writel(qts, USART1_BASE_ADDR + A_CR1, cr1);
279
+ qtest_writel(qts, USART1_BASE_ADDR + A_TDR, 'd');
280
+ g_assert_true(recv(sock_fd, s, 1, 0) == 1);
281
+ g_assert_cmphex(s[0], ==, 'd');
282
+ g_assert_true(check_nvic_pending(qts, USART1_IRQ));
283
+ clear_nvic_pending(qts, USART1_IRQ);
284
+
285
+ close(sock_fd);
286
+
287
+ qtest_quit(qts);
288
+}
289
+
290
+static void test_receive_str(void)
291
+{
292
+ int sock_fd;
293
+ char s[10];
294
+ QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd);
295
+
296
+ init_uart(qts);
297
+
298
+ usart_receive_string(qts, sock_fd, "hello", s);
299
+ g_assert_true(memcmp(s, "hello", 5) == 0);
300
+
301
+ close(sock_fd);
302
+
303
+ qtest_quit(qts);
304
+}
305
+
306
+static void test_send_str(void)
307
+{
308
+ int sock_fd;
309
+ char s[10];
310
+ QTestState *qts = qtest_init_with_serial("-M b-l475e-iot01a", &sock_fd);
311
+
312
+ init_uart(qts);
313
+
314
+ usart_send_string(qts, "world");
315
+ g_assert_true(recv(sock_fd, s, 10, 0) == 5);
316
+ g_assert_true(memcmp(s, "world", 5) == 0);
317
+
318
+ close(sock_fd);
319
+
320
+ qtest_quit(qts);
321
+}
322
+
323
+int main(int argc, char **argv)
324
+{
325
+ int ret;
326
+
327
+ g_test_init(&argc, &argv, NULL);
328
+ g_test_set_nonfatal_assertions();
329
+
330
+ qtest_add_func("stm32l4x5/usart/write_read", test_write_read);
331
+ qtest_add_func("stm32l4x5/usart/receive_char", test_receive_char);
332
+ qtest_add_func("stm32l4x5/usart/send_char", test_send_char);
333
+ qtest_add_func("stm32l4x5/usart/receive_str", test_receive_str);
334
+ qtest_add_func("stm32l4x5/usart/send_str", test_send_str);
335
+ ret = g_test_run();
336
+
337
+ return ret;
338
+}
339
+
340
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
341
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
342
--- a/tests/qtest/meson.build
18
--- a/fpu/softfloat-parts.c.inc
343
+++ b/tests/qtest/meson.build
19
+++ b/fpu/softfloat-parts.c.inc
344
@@ -XXX,XX +XXX,XX @@ slow_qtests = {
20
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
345
'npcm7xx_pwm-test': 300,
21
}
346
'npcm7xx_watchdog_timer-test': 120,
22
ret = c;
347
'qom-test' : 900,
23
} else {
348
+ 'stm32l4x5_usart-test' : 600,
24
- FloatPartsN *val[3] = { a, b, c };
349
'test-hmp' : 240,
25
+ FloatPartsN *val[R_3NAN_1ST_MASK + 1] = { a, b, c };
350
'pxe-test': 610,
26
Float3NaNPropRule rule = s->float_3nan_prop_rule;
351
'prom-env-test': 360,
27
352
@@ -XXX,XX +XXX,XX @@ qtests_stm32l4x5 = \
28
assert(rule != float_3nan_prop_none);
353
['stm32l4x5_exti-test',
354
'stm32l4x5_syscfg-test',
355
'stm32l4x5_rcc-test',
356
- 'stm32l4x5_gpio-test']
357
+ 'stm32l4x5_gpio-test',
358
+ 'stm32l4x5_usart-test']
359
360
qtests_arm = \
361
(config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \
362
--
29
--
363
2.34.1
30
2.34.1
364
31
365
32
diff view generated by jsdifflib
1
Implement icv_nmiar1_read() for icc_nmiar1_read(), so add definition for
1
From: Richard Henderson <richard.henderson@linaro.org>
2
ICH_LR_EL2.NMI and ICH_AP1R_EL2.NMI bit.
3
2
4
If FEAT_GICv3_NMI is supported, ich_ap_write() should consider ICV_AP1R_EL1.NMI
3
This function is part of the public interface and
5
bit. In icv_activate_irq() and icv_eoir_write(), the ICV_AP1R_EL1.NMI bit
4
is not "specialized" to any target in any way.
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
5
9
By the way, add gicv3_icv_nmiar1_read trace event.
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
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>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
18
Message-id: 20240407081733.3231820-20-ruanjinjie@huawei.com
8
Message-id: 20241203203949.483774-7-richard.henderson@linaro.org
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
10
---
21
hw/intc/gicv3_internal.h | 4 ++
11
fpu/softfloat.c | 52 ++++++++++++++++++++++++++++++++++
22
hw/intc/arm_gicv3_cpuif.c | 105 +++++++++++++++++++++++++++++++++-----
12
fpu/softfloat-specialize.c.inc | 52 ----------------------------------
23
hw/intc/trace-events | 1 +
13
2 files changed, 52 insertions(+), 52 deletions(-)
24
3 files changed, 98 insertions(+), 12 deletions(-)
25
14
26
diff --git a/hw/intc/gicv3_internal.h b/hw/intc/gicv3_internal.h
15
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
27
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/intc/gicv3_internal.h
17
--- a/fpu/softfloat.c
29
+++ b/hw/intc/gicv3_internal.h
18
+++ b/fpu/softfloat.c
30
@@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1)
19
@@ -XXX,XX +XXX,XX @@ void normalizeFloatx80Subnormal(uint64_t aSig, int32_t *zExpPtr,
31
#define ICH_LR_EL2_PRIORITY_SHIFT 48
20
*zExpPtr = 1 - shiftCount;
32
#define ICH_LR_EL2_PRIORITY_LENGTH 8
21
}
33
#define ICH_LR_EL2_PRIORITY_MASK (0xffULL << ICH_LR_EL2_PRIORITY_SHIFT)
22
34
+#define ICH_LR_EL2_NMI (1ULL << 59)
23
+/*----------------------------------------------------------------------------
35
#define ICH_LR_EL2_GROUP (1ULL << 60)
24
+| Takes two extended double-precision floating-point values `a' and `b', one
36
#define ICH_LR_EL2_HW (1ULL << 61)
25
+| of which is a NaN, and returns the appropriate NaN result. If either `a' or
37
#define ICH_LR_EL2_STATE_SHIFT 62
26
+| `b' is a signaling NaN, the invalid exception is raised.
38
@@ -XXX,XX +XXX,XX @@ FIELD(GICR_VPENDBASER, VALID, 63, 1)
27
+*----------------------------------------------------------------------------*/
39
#define ICH_VTR_EL2_PREBITS_SHIFT 26
40
#define ICH_VTR_EL2_PRIBITS_SHIFT 29
41
42
+#define ICV_AP1R_EL1_NMI (1ULL << 63)
43
+#define ICV_RPR_EL1_NMI (1ULL << 63)
44
+
28
+
45
/* ITS Registers */
29
+floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status)
46
30
+{
47
FIELD(GITS_BASER, SIZE, 0, 8)
31
+ bool aIsLargerSignificand;
48
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
32
+ FloatClass a_cls, b_cls;
49
index XXXXXXX..XXXXXXX 100644
33
+
50
--- a/hw/intc/arm_gicv3_cpuif.c
34
+ /* This is not complete, but is good enough for pickNaN. */
51
+++ b/hw/intc/arm_gicv3_cpuif.c
35
+ a_cls = (!floatx80_is_any_nan(a)
52
@@ -XXX,XX +XXX,XX @@ static int ich_highest_active_virt_prio(GICv3CPUState *cs)
36
+ ? float_class_normal
53
int i;
37
+ : floatx80_is_signaling_nan(a, status)
54
int aprmax = ich_num_aprs(cs);
38
+ ? float_class_snan
55
39
+ : float_class_qnan);
56
+ if (cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI) {
40
+ b_cls = (!floatx80_is_any_nan(b)
57
+ return 0x0;
41
+ ? float_class_normal
42
+ : floatx80_is_signaling_nan(b, status)
43
+ ? float_class_snan
44
+ : float_class_qnan);
45
+
46
+ if (is_snan(a_cls) || is_snan(b_cls)) {
47
+ float_raise(float_flag_invalid, status);
58
+ }
48
+ }
59
+
49
+
60
for (i = 0; i < aprmax; i++) {
50
+ if (status->default_nan_mode) {
61
uint32_t apr = cs->ich_apr[GICV3_G0][i] |
51
+ return floatx80_default_nan(status);
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
+ }
52
+ }
122
+
53
+
123
return false;
54
+ if (a.low < b.low) {
124
}
55
+ aIsLargerSignificand = 0;
125
56
+ } else if (b.low < a.low) {
126
@@ -XXX,XX +XXX,XX @@ static void icv_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
57
+ aIsLargerSignificand = 1;
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);
133
+ } else {
58
+ } else {
134
+ cs->ich_apr[grp][regno] = value & 0xFFFFFFFFU;
59
+ aIsLargerSignificand = (a.high < b.high) ? 1 : 0;
135
+ }
136
137
gicv3_cpuif_virt_irq_fiq_update(cs);
138
return;
139
@@ -XXX,XX +XXX,XX @@ static void icv_ctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
140
static uint64_t icv_rpr_read(CPUARMState *env, const ARMCPRegInfo *ri)
141
{
142
GICv3CPUState *cs = icc_cs_from_env(env);
143
- int prio = ich_highest_active_virt_prio(cs);
144
+ uint64_t prio = ich_highest_active_virt_prio(cs);
145
+
146
+ if (cs->ich_apr[GICV3_G1NS][0] & ICV_AP1R_EL1_NMI) {
147
+ prio |= ICV_RPR_EL1_NMI;
148
+ }
149
150
trace_gicv3_icv_rpr_read(gicv3_redist_affid(cs), prio);
151
return prio;
152
@@ -XXX,XX +XXX,XX @@ static void icv_activate_irq(GICv3CPUState *cs, int idx, int grp)
153
*/
154
uint32_t mask = icv_gprio_mask(cs, grp);
155
int prio = ich_lr_prio(cs->ich_lr_el2[idx]) & mask;
156
+ bool nmi = cs->ich_lr_el2[idx] & ICH_LR_EL2_NMI;
157
int aprbit = prio >> (8 - cs->vprebits);
158
int regno = aprbit / 32;
159
int regbit = aprbit % 32;
160
161
cs->ich_lr_el2[idx] &= ~ICH_LR_EL2_STATE_PENDING_BIT;
162
cs->ich_lr_el2[idx] |= ICH_LR_EL2_STATE_ACTIVE_BIT;
163
- cs->ich_apr[grp][regno] |= (1 << regbit);
164
+
165
+ if (nmi) {
166
+ cs->ich_apr[grp][regno] |= ICV_AP1R_EL1_NMI;
167
+ } else {
168
+ cs->ich_apr[grp][regno] |= (1 << regbit);
169
+ }
170
}
171
172
static void icv_activate_vlpi(GICv3CPUState *cs)
173
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri)
174
int grp = ri->crm == 8 ? GICV3_G0 : GICV3_G1NS;
175
int idx = hppvi_index(cs);
176
uint64_t intid = INTID_SPURIOUS;
177
+ int el = arm_current_el(env);
178
179
if (idx == HPPVI_INDEX_VLPI) {
180
if (cs->hppvlpi.grp == grp && icv_hppvlpi_can_preempt(cs)) {
181
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri)
182
} else if (idx >= 0) {
183
uint64_t lr = cs->ich_lr_el2[idx];
184
int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0;
185
+ bool nmi = env->cp15.sctlr_el[el] & SCTLR_NMI && lr & ICH_LR_EL2_NMI;
186
187
if (thisgrp == grp && icv_hppi_can_preempt(cs, lr)) {
188
intid = ich_lr_vintid(lr);
189
if (!gicv3_intid_is_special(intid)) {
190
- icv_activate_irq(cs, idx, grp);
191
+ if (!nmi) {
192
+ icv_activate_irq(cs, idx, grp);
193
+ } else {
194
+ intid = INTID_NMI;
195
+ }
196
} else {
197
/* Interrupt goes from Pending to Invalid */
198
cs->ich_lr_el2[idx] &= ~ICH_LR_EL2_STATE_PENDING_BIT;
199
@@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri)
200
201
static uint64_t icv_nmiar1_read(CPUARMState *env, const ARMCPRegInfo *ri)
202
{
203
- /* todo */
204
+ GICv3CPUState *cs = icc_cs_from_env(env);
205
+ int idx = hppvi_index(cs);
206
uint64_t intid = INTID_SPURIOUS;
207
+
208
+ if (idx >= 0 && idx != HPPVI_INDEX_VLPI) {
209
+ uint64_t lr = cs->ich_lr_el2[idx];
210
+ int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0;
211
+
212
+ if ((thisgrp == GICV3_G1NS) && icv_hppi_can_preempt(cs, lr)) {
213
+ intid = ich_lr_vintid(lr);
214
+ if (!gicv3_intid_is_special(intid)) {
215
+ if (lr & ICH_LR_EL2_NMI) {
216
+ icv_activate_irq(cs, idx, GICV3_G1NS);
217
+ } else {
218
+ intid = INTID_SPURIOUS;
219
+ }
220
+ } else {
221
+ /* Interrupt goes from Pending to Invalid */
222
+ cs->ich_lr_el2[idx] &= ~ICH_LR_EL2_STATE_PENDING_BIT;
223
+ /*
224
+ * We will now return the (bogus) ID from the list register,
225
+ * as per the pseudocode.
226
+ */
227
+ }
228
+ }
229
+ }
60
+ }
230
+
61
+
231
+ trace_gicv3_icv_nmiar1_read(gicv3_redist_affid(cs), intid);
62
+ if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) {
63
+ if (is_snan(b_cls)) {
64
+ return floatx80_silence_nan(b, status);
65
+ }
66
+ return b;
67
+ } else {
68
+ if (is_snan(a_cls)) {
69
+ return floatx80_silence_nan(a, status);
70
+ }
71
+ return a;
72
+ }
73
+}
232
+
74
+
233
+ gicv3_cpuif_virt_update(cs);
75
/*----------------------------------------------------------------------------
234
+
76
| Takes an abstract floating-point value having sign `zSign', exponent `zExp',
235
return intid;
77
| and extended significand formed by the concatenation of `zSig0' and `zSig1',
78
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
79
index XXXXXXX..XXXXXXX 100644
80
--- a/fpu/softfloat-specialize.c.inc
81
+++ b/fpu/softfloat-specialize.c.inc
82
@@ -XXX,XX +XXX,XX @@ floatx80 floatx80_silence_nan(floatx80 a, float_status *status)
83
return a;
236
}
84
}
237
85
238
@@ -XXX,XX +XXX,XX @@ static void icv_increment_eoicount(GICv3CPUState *cs)
86
-/*----------------------------------------------------------------------------
239
ICH_HCR_EL2_EOICOUNT_LENGTH, eoicount + 1);
87
-| Takes two extended double-precision floating-point values `a' and `b', one
240
}
88
-| of which is a NaN, and returns the appropriate NaN result. If either `a' or
241
89
-| `b' is a signaling NaN, the invalid exception is raised.
242
-static int icv_drop_prio(GICv3CPUState *cs)
90
-*----------------------------------------------------------------------------*/
243
+static int icv_drop_prio(GICv3CPUState *cs, bool *nmi)
91
-
244
{
92
-floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status)
245
/* Drop the priority of the currently active virtual interrupt
93
-{
246
* (favouring group 0 if there is a set active bit at
94
- bool aIsLargerSignificand;
247
@@ -XXX,XX +XXX,XX @@ static int icv_drop_prio(GICv3CPUState *cs)
95
- FloatClass a_cls, b_cls;
248
continue;
96
-
249
}
97
- /* This is not complete, but is good enough for pickNaN. */
250
98
- a_cls = (!floatx80_is_any_nan(a)
251
+ if (i == 0 && cs->nmi_support && (*papr1 & ICV_AP1R_EL1_NMI)) {
99
- ? float_class_normal
252
+ *papr1 &= (~ICV_AP1R_EL1_NMI);
100
- : floatx80_is_signaling_nan(a, status)
253
+ *nmi = true;
101
- ? float_class_snan
254
+ return 0xff;
102
- : float_class_qnan);
255
+ }
103
- b_cls = (!floatx80_is_any_nan(b)
256
+
104
- ? float_class_normal
257
/* We can't just use the bit-twiddling hack icc_drop_prio() does
105
- : floatx80_is_signaling_nan(b, status)
258
* because we need to return the bit number we cleared so
106
- ? float_class_snan
259
* it can be compared against the list register's priority field.
107
- : float_class_qnan);
260
@@ -XXX,XX +XXX,XX @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri,
108
-
261
int irq = value & 0xffffff;
109
- if (is_snan(a_cls) || is_snan(b_cls)) {
262
int grp = ri->crm == 8 ? GICV3_G0 : GICV3_G1NS;
110
- float_raise(float_flag_invalid, status);
263
int idx, dropprio;
111
- }
264
+ bool nmi = false;
112
-
265
113
- if (status->default_nan_mode) {
266
trace_gicv3_icv_eoir_write(ri->crm == 8 ? 0 : 1,
114
- return floatx80_default_nan(status);
267
gicv3_redist_affid(cs), value);
115
- }
268
@@ -XXX,XX +XXX,XX @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri,
116
-
269
* error checks" (because that lets us avoid scanning the AP
117
- if (a.low < b.low) {
270
* registers twice).
118
- aIsLargerSignificand = 0;
271
*/
119
- } else if (b.low < a.low) {
272
- dropprio = icv_drop_prio(cs);
120
- aIsLargerSignificand = 1;
273
- if (dropprio == 0xff) {
121
- } else {
274
+ dropprio = icv_drop_prio(cs, &nmi);
122
- aIsLargerSignificand = (a.high < b.high) ? 1 : 0;
275
+ if (dropprio == 0xff && !nmi) {
123
- }
276
/* No active interrupt. It is CONSTRAINED UNPREDICTABLE
124
-
277
* whether the list registers are checked in this
125
- if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) {
278
* situation; we choose not to.
126
- if (is_snan(b_cls)) {
279
@@ -XXX,XX +XXX,XX @@ static void icv_eoir_write(CPUARMState *env, const ARMCPRegInfo *ri,
127
- return floatx80_silence_nan(b, status);
280
uint64_t lr = cs->ich_lr_el2[idx];
128
- }
281
int thisgrp = (lr & ICH_LR_EL2_GROUP) ? GICV3_G1NS : GICV3_G0;
129
- return b;
282
int lr_gprio = ich_lr_prio(lr) & icv_gprio_mask(cs, grp);
130
- } else {
283
+ bool thisnmi = lr & ICH_LR_EL2_NMI;
131
- if (is_snan(a_cls)) {
284
132
- return floatx80_silence_nan(a, status);
285
- if (thisgrp == grp && lr_gprio == dropprio) {
133
- }
286
+ if (thisgrp == grp && (lr_gprio == dropprio || (thisnmi & nmi))) {
134
- return a;
287
if (!icv_eoi_split(env, cs) || irq >= GICV3_LPI_INTID_START) {
135
- }
288
/*
136
-}
289
* Priority drop and deactivate not split: deactivate irq now.
137
-
290
@@ -XXX,XX +XXX,XX @@ static void ich_ap_write(CPUARMState *env, const ARMCPRegInfo *ri,
138
/*----------------------------------------------------------------------------
291
139
| Returns 1 if the quadruple-precision floating-point value `a' is a quiet
292
trace_gicv3_ich_ap_write(ri->crm & 1, regno, gicv3_redist_affid(cs), value);
140
| NaN; otherwise returns 0.
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"
327
--
141
--
328
2.34.1
142
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Wire the new NMI and VINMI interrupt line from the GIC to each CPU if it
3
Unpacking and repacking the parts may be slightly more work
4
is not GICv2.
4
than we did before, but we get to reuse more code. For a
5
code path handling exceptional values, this is an improvement.
5
6
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20241203203949.483774-8-richard.henderson@linaro.org
8
Message-id: 20240407081733.3231820-12-ruanjinjie@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
hw/arm/virt.c | 10 +++++++++-
12
fpu/softfloat.c | 43 +++++--------------------------------------
12
1 file changed, 9 insertions(+), 1 deletion(-)
13
1 file changed, 5 insertions(+), 38 deletions(-)
13
14
14
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
15
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/arm/virt.c
17
--- a/fpu/softfloat.c
17
+++ b/hw/arm/virt.c
18
+++ b/fpu/softfloat.c
18
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
19
@@ -XXX,XX +XXX,XX @@ void normalizeFloatx80Subnormal(uint64_t aSig, int32_t *zExpPtr,
19
20
20
/* Wire the outputs from each CPU's generic timer and the GICv3
21
floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status)
21
* maintenance interrupt signal to the appropriate GIC PPI inputs,
22
{
22
- * and the GIC's IRQ/FIQ/VIRQ/VFIQ interrupt outputs to the CPU's inputs.
23
- bool aIsLargerSignificand;
23
+ * and the GIC's IRQ/FIQ/VIRQ/VFIQ/NMI/VINMI interrupt outputs to the
24
- FloatClass a_cls, b_cls;
24
+ * CPU's inputs.
25
+ FloatParts128 pa, pb, *pr;
25
*/
26
26
for (i = 0; i < smp_cpus; i++) {
27
- /* This is not complete, but is good enough for pickNaN. */
27
DeviceState *cpudev = DEVICE(qemu_get_cpu(i));
28
- a_cls = (!floatx80_is_any_nan(a)
28
@@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem)
29
- ? float_class_normal
29
qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ));
30
- : floatx80_is_signaling_nan(a, status)
30
sysbus_connect_irq(gicbusdev, i + 3 * smp_cpus,
31
- ? float_class_snan
31
qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ));
32
- : float_class_qnan);
32
+
33
- b_cls = (!floatx80_is_any_nan(b)
33
+ if (vms->gic_version != VIRT_GIC_VERSION_2) {
34
- ? float_class_normal
34
+ sysbus_connect_irq(gicbusdev, i + 4 * smp_cpus,
35
- : floatx80_is_signaling_nan(b, status)
35
+ qdev_get_gpio_in(cpudev, ARM_CPU_NMI));
36
- ? float_class_snan
36
+ sysbus_connect_irq(gicbusdev, i + 5 * smp_cpus,
37
- : float_class_qnan);
37
+ qdev_get_gpio_in(cpudev, ARM_CPU_VINMI));
38
-
38
+ }
39
- if (is_snan(a_cls) || is_snan(b_cls)) {
40
- float_raise(float_flag_invalid, status);
41
- }
42
-
43
- if (status->default_nan_mode) {
44
+ if (!floatx80_unpack_canonical(&pa, a, status) ||
45
+ !floatx80_unpack_canonical(&pb, b, status)) {
46
return floatx80_default_nan(status);
39
}
47
}
40
48
41
fdt_add_gic_node(vms);
49
- if (a.low < b.low) {
50
- aIsLargerSignificand = 0;
51
- } else if (b.low < a.low) {
52
- aIsLargerSignificand = 1;
53
- } else {
54
- aIsLargerSignificand = (a.high < b.high) ? 1 : 0;
55
- }
56
-
57
- if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) {
58
- if (is_snan(b_cls)) {
59
- return floatx80_silence_nan(b, status);
60
- }
61
- return b;
62
- } else {
63
- if (is_snan(a_cls)) {
64
- return floatx80_silence_nan(a, status);
65
- }
66
- return a;
67
- }
68
+ pr = parts_pick_nan(&pa, &pb, status);
69
+ return floatx80_round_pack_canonical(pr, status);
70
}
71
72
/*----------------------------------------------------------------------------
42
--
73
--
43
2.34.1
74
2.34.1
diff view generated by jsdifflib
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Add a function to change the settings of the
3
Inline pickNaN into its only caller. This makes one assert
4
serial connection.
4
redundant with the immediately preceding IF.
5
5
6
Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20241203203949.483774-9-richard.henderson@linaro.org
9
Message-id: 20240329174402.60382-4-arnaud.minier@telecom-paris.fr
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
hw/char/stm32l4x5_usart.c | 98 +++++++++++++++++++++++++++++++++++++++
11
fpu/softfloat-parts.c.inc | 82 +++++++++++++++++++++++++----
13
hw/char/trace-events | 1 +
12
fpu/softfloat-specialize.c.inc | 96 ----------------------------------
14
2 files changed, 99 insertions(+)
13
2 files changed, 73 insertions(+), 105 deletions(-)
15
14
16
diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c
15
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/char/stm32l4x5_usart.c
17
--- a/fpu/softfloat-parts.c.inc
19
+++ b/hw/char/stm32l4x5_usart.c
18
+++ b/fpu/softfloat-parts.c.inc
20
@@ -XXX,XX +XXX,XX @@ static void usart_cancel_transmit(Stm32l4x5UsartBaseState *s)
19
@@ -XXX,XX +XXX,XX @@ static void partsN(return_nan)(FloatPartsN *a, float_status *s)
20
static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
21
float_status *s)
22
{
23
+ int cmp, which;
24
+
25
if (is_snan(a->cls) || is_snan(b->cls)) {
26
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
27
}
28
29
if (s->default_nan_mode) {
30
parts_default_nan(a, s);
31
- } else {
32
- int cmp = frac_cmp(a, b);
33
- if (cmp == 0) {
34
- cmp = a->sign < b->sign;
35
- }
36
+ return a;
37
+ }
38
39
- if (pickNaN(a->cls, b->cls, cmp > 0, s)) {
40
- a = b;
41
- }
42
+ cmp = frac_cmp(a, b);
43
+ if (cmp == 0) {
44
+ cmp = a->sign < b->sign;
45
+ }
46
+
47
+ switch (s->float_2nan_prop_rule) {
48
+ case float_2nan_prop_s_ab:
49
if (is_snan(a->cls)) {
50
- parts_silence_nan(a, s);
51
+ which = 0;
52
+ } else if (is_snan(b->cls)) {
53
+ which = 1;
54
+ } else if (is_qnan(a->cls)) {
55
+ which = 0;
56
+ } else {
57
+ which = 1;
58
}
59
+ break;
60
+ case float_2nan_prop_s_ba:
61
+ if (is_snan(b->cls)) {
62
+ which = 1;
63
+ } else if (is_snan(a->cls)) {
64
+ which = 0;
65
+ } else if (is_qnan(b->cls)) {
66
+ which = 1;
67
+ } else {
68
+ which = 0;
69
+ }
70
+ break;
71
+ case float_2nan_prop_ab:
72
+ which = is_nan(a->cls) ? 0 : 1;
73
+ break;
74
+ case float_2nan_prop_ba:
75
+ which = is_nan(b->cls) ? 1 : 0;
76
+ break;
77
+ case float_2nan_prop_x87:
78
+ /*
79
+ * This implements x87 NaN propagation rules:
80
+ * SNaN + QNaN => return the QNaN
81
+ * two SNaNs => return the one with the larger significand, silenced
82
+ * two QNaNs => return the one with the larger significand
83
+ * SNaN and a non-NaN => return the SNaN, silenced
84
+ * QNaN and a non-NaN => return the QNaN
85
+ *
86
+ * If we get down to comparing significands and they are the same,
87
+ * return the NaN with the positive sign bit (if any).
88
+ */
89
+ if (is_snan(a->cls)) {
90
+ if (is_snan(b->cls)) {
91
+ which = cmp > 0 ? 0 : 1;
92
+ } else {
93
+ which = is_qnan(b->cls) ? 1 : 0;
94
+ }
95
+ } else if (is_qnan(a->cls)) {
96
+ if (is_snan(b->cls) || !is_qnan(b->cls)) {
97
+ which = 0;
98
+ } else {
99
+ which = cmp > 0 ? 0 : 1;
100
+ }
101
+ } else {
102
+ which = 1;
103
+ }
104
+ break;
105
+ default:
106
+ g_assert_not_reached();
107
+ }
108
+
109
+ if (which) {
110
+ a = b;
111
+ }
112
+ if (is_snan(a->cls)) {
113
+ parts_silence_nan(a, s);
114
}
115
return a;
116
}
117
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
118
index XXXXXXX..XXXXXXX 100644
119
--- a/fpu/softfloat-specialize.c.inc
120
+++ b/fpu/softfloat-specialize.c.inc
121
@@ -XXX,XX +XXX,XX @@ bool float32_is_signaling_nan(float32 a_, float_status *status)
21
}
122
}
22
}
123
}
23
124
24
+static void stm32l4x5_update_params(Stm32l4x5UsartBaseState *s)
125
-/*----------------------------------------------------------------------------
25
+{
126
-| Select which NaN to propagate for a two-input operation.
26
+ int speed, parity, data_bits, stop_bits;
127
-| IEEE754 doesn't specify all the details of this, so the
27
+ uint32_t value, usart_div;
128
-| algorithm is target-specific.
28
+ QEMUSerialSetParams ssp;
129
-| The routine is passed various bits of information about the
29
+
130
-| two NaNs and should return 0 to select NaN a and 1 for NaN b.
30
+ /* Select the parity type */
131
-| Note that signalling NaNs are always squashed to quiet NaNs
31
+ if (s->cr1 & R_CR1_PCE_MASK) {
132
-| by the caller, by calling floatXX_silence_nan() before
32
+ if (s->cr1 & R_CR1_PS_MASK) {
133
-| returning them.
33
+ parity = 'O';
134
-|
34
+ } else {
135
-| aIsLargerSignificand is only valid if both a and b are NaNs
35
+ parity = 'E';
136
-| of some kind, and is true if a has the larger significand,
36
+ }
137
-| or if both a and b have the same significand but a is
37
+ } else {
138
-| positive but b is negative. It is only needed for the x87
38
+ parity = 'N';
139
-| tie-break rule.
39
+ }
140
-*----------------------------------------------------------------------------*/
40
+
141
-
41
+ /* Select the number of stop bits */
142
-static int pickNaN(FloatClass a_cls, FloatClass b_cls,
42
+ switch (FIELD_EX32(s->cr2, CR2, STOP)) {
143
- bool aIsLargerSignificand, float_status *status)
43
+ case 0:
144
-{
44
+ stop_bits = 1;
145
- /*
45
+ break;
146
- * We guarantee not to require the target to tell us how to
46
+ case 2:
147
- * pick a NaN if we're always returning the default NaN.
47
+ stop_bits = 2;
148
- * But if we're not in default-NaN mode then the target must
48
+ break;
149
- * specify via set_float_2nan_prop_rule().
49
+ default:
150
- */
50
+ qemu_log_mask(LOG_UNIMP,
151
- assert(!status->default_nan_mode);
51
+ "UNIMPLEMENTED: fractionnal stop bits; CR2[13:12] = %u",
152
-
52
+ FIELD_EX32(s->cr2, CR2, STOP));
153
- switch (status->float_2nan_prop_rule) {
53
+ return;
154
- case float_2nan_prop_s_ab:
54
+ }
155
- if (is_snan(a_cls)) {
55
+
156
- return 0;
56
+ /* Select the length of the word */
157
- } else if (is_snan(b_cls)) {
57
+ switch ((FIELD_EX32(s->cr1, CR1, M1) << 1) | FIELD_EX32(s->cr1, CR1, M0)) {
158
- return 1;
58
+ case 0:
159
- } else if (is_qnan(a_cls)) {
59
+ data_bits = 8;
160
- return 0;
60
+ break;
161
- } else {
61
+ case 1:
162
- return 1;
62
+ data_bits = 9;
163
- }
63
+ break;
164
- break;
64
+ case 2:
165
- case float_2nan_prop_s_ba:
65
+ data_bits = 7;
166
- if (is_snan(b_cls)) {
66
+ break;
167
- return 1;
67
+ default:
168
- } else if (is_snan(a_cls)) {
68
+ qemu_log_mask(LOG_GUEST_ERROR,
169
- return 0;
69
+ "UNDEFINED: invalid word length, CR1.M = 0b11");
170
- } else if (is_qnan(b_cls)) {
70
+ return;
171
- return 1;
71
+ }
172
- } else {
72
+
173
- return 0;
73
+ /* Select the baud rate */
174
- }
74
+ value = FIELD_EX32(s->brr, BRR, BRR);
175
- break;
75
+ if (value < 16) {
176
- case float_2nan_prop_ab:
76
+ qemu_log_mask(LOG_GUEST_ERROR,
177
- if (is_nan(a_cls)) {
77
+ "UNDEFINED: BRR less than 16: %u", value);
178
- return 0;
78
+ return;
179
- } else {
79
+ }
180
- return 1;
80
+
181
- }
81
+ if (FIELD_EX32(s->cr1, CR1, OVER8) == 0) {
182
- break;
82
+ /*
183
- case float_2nan_prop_ba:
83
+ * Oversampling by 16
184
- if (is_nan(b_cls)) {
84
+ * BRR = USARTDIV
185
- return 1;
85
+ */
186
- } else {
86
+ usart_div = value;
187
- return 0;
87
+ } else {
188
- }
88
+ /*
189
- break;
89
+ * Oversampling by 8
190
- case float_2nan_prop_x87:
90
+ * - BRR[2:0] = USARTDIV[3:0] shifted 1 bit to the right.
191
- /*
91
+ * - BRR[3] must be kept cleared.
192
- * This implements x87 NaN propagation rules:
92
+ * - BRR[15:4] = USARTDIV[15:4]
193
- * SNaN + QNaN => return the QNaN
93
+ * - The frequency is multiplied by 2
194
- * two SNaNs => return the one with the larger significand, silenced
94
+ */
195
- * two QNaNs => return the one with the larger significand
95
+ usart_div = ((value & 0xFFF0) | ((value & 0x0007) << 1)) / 2;
196
- * SNaN and a non-NaN => return the SNaN, silenced
96
+ }
197
- * QNaN and a non-NaN => return the QNaN
97
+
198
- *
98
+ speed = clock_get_hz(s->clk) / usart_div;
199
- * If we get down to comparing significands and they are the same,
99
+
200
- * return the NaN with the positive sign bit (if any).
100
+ ssp.speed = speed;
201
- */
101
+ ssp.parity = parity;
202
- if (is_snan(a_cls)) {
102
+ ssp.data_bits = data_bits;
203
- if (is_snan(b_cls)) {
103
+ ssp.stop_bits = stop_bits;
204
- return aIsLargerSignificand ? 0 : 1;
104
+
205
- }
105
+ qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp);
206
- return is_qnan(b_cls) ? 1 : 0;
106
+
207
- } else if (is_qnan(a_cls)) {
107
+ trace_stm32l4x5_usart_update_params(speed, parity, data_bits, stop_bits);
208
- if (is_snan(b_cls) || !is_qnan(b_cls)) {
108
+}
209
- return 0;
109
+
210
- } else {
110
static void stm32l4x5_usart_base_reset_hold(Object *obj, ResetType type)
211
- return aIsLargerSignificand ? 0 : 1;
111
{
212
- }
112
Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj);
213
- } else {
113
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_write(void *opaque, hwaddr addr,
214
- return 1;
114
switch (addr) {
215
- }
115
case A_CR1:
216
- default:
116
s->cr1 = value;
217
- g_assert_not_reached();
117
+ stm32l4x5_update_params(s);
218
- }
118
stm32l4x5_update_irq(s);
219
-}
119
return;
220
-
120
case A_CR2:
221
/*----------------------------------------------------------------------------
121
s->cr2 = value;
222
| Returns 1 if the double-precision floating-point value `a' is a quiet
122
+ stm32l4x5_update_params(s);
223
| NaN; otherwise returns 0.
123
return;
124
case A_CR3:
125
s->cr3 = value;
126
return;
127
case A_BRR:
128
s->brr = value;
129
+ stm32l4x5_update_params(s);
130
return;
131
case A_GTPR:
132
s->gtpr = value;
133
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_init(Object *obj)
134
s->clk = qdev_init_clock_in(DEVICE(s), "clk", NULL, s, 0);
135
}
136
137
+static int stm32l4x5_usart_base_post_load(void *opaque, int version_id)
138
+{
139
+ Stm32l4x5UsartBaseState *s = (Stm32l4x5UsartBaseState *)opaque;
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
154
index XXXXXXX..XXXXXXX 100644
155
--- a/hw/char/trace-events
156
+++ b/hw/char/trace-events
157
@@ -XXX,XX +XXX,XX @@ stm32l4x5_usart_irq_raised(uint32_t reg) "USART: IRQ raised: 0x%08"PRIx32
158
stm32l4x5_usart_irq_lowered(void) "USART: IRQ lowered"
159
stm32l4x5_usart_overrun_detected(uint8_t current, uint8_t received) "USART: Overrun detected, RDR='0x%x', received 0x%x"
160
stm32l4x5_usart_receiver_not_enabled(uint8_t ue_bit, uint8_t re_bit) "USART: Receiver not enabled, UE=0x%x, RE=0x%x"
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"
162
163
# xen_console.c
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"
165
--
224
--
166
2.34.1
225
2.34.1
167
226
168
227
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
According to Arm GIC section 4.6.3 Interrupt superpriority, the interrupt
3
Remember if there was an SNaN, and use that to simplify
4
with superpriority is always IRQ, never FIQ, so handle NMI same as IRQ in
4
float_2nan_prop_s_{ab,ba} to only the snan component.
5
arm_phys_excp_target_el().
5
Then, fall through to the corresponding
6
float_2nan_prop_{ab,ba} case to handle any remaining
7
nans, which must be quiet.
6
8
7
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20240407081733.3231820-8-ruanjinjie@huawei.com
11
Message-id: 20241203203949.483774-10-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
---
13
target/arm/helper.c | 1 +
14
fpu/softfloat-parts.c.inc | 32 ++++++++++++--------------------
14
1 file changed, 1 insertion(+)
15
1 file changed, 12 insertions(+), 20 deletions(-)
15
16
16
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/helper.c
19
--- a/fpu/softfloat-parts.c.inc
19
+++ b/target/arm/helper.c
20
+++ b/fpu/softfloat-parts.c.inc
20
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
21
@@ -XXX,XX +XXX,XX @@ static void partsN(return_nan)(FloatPartsN *a, float_status *s)
21
hcr_el2 = arm_hcr_el2_eff(env);
22
static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
22
switch (excp_idx) {
23
float_status *s)
23
case EXCP_IRQ:
24
{
24
+ case EXCP_NMI:
25
+ bool have_snan = false;
25
scr = ((env->cp15.scr_el3 & SCR_IRQ) == SCR_IRQ);
26
int cmp, which;
26
hcr = hcr_el2 & HCR_IMO;
27
28
if (is_snan(a->cls) || is_snan(b->cls)) {
29
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
30
+ have_snan = true;
31
}
32
33
if (s->default_nan_mode) {
34
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
35
36
switch (s->float_2nan_prop_rule) {
37
case float_2nan_prop_s_ab:
38
- if (is_snan(a->cls)) {
39
- which = 0;
40
- } else if (is_snan(b->cls)) {
41
- which = 1;
42
- } else if (is_qnan(a->cls)) {
43
- which = 0;
44
- } else {
45
- which = 1;
46
+ if (have_snan) {
47
+ which = is_snan(a->cls) ? 0 : 1;
48
+ break;
49
}
50
- break;
51
- case float_2nan_prop_s_ba:
52
- if (is_snan(b->cls)) {
53
- which = 1;
54
- } else if (is_snan(a->cls)) {
55
- which = 0;
56
- } else if (is_qnan(b->cls)) {
57
- which = 1;
58
- } else {
59
- which = 0;
60
- }
61
- break;
62
+ /* fall through */
63
case float_2nan_prop_ab:
64
which = is_nan(a->cls) ? 0 : 1;
65
break;
66
+ case float_2nan_prop_s_ba:
67
+ if (have_snan) {
68
+ which = is_snan(b->cls) ? 1 : 0;
69
+ break;
70
+ }
71
+ /* fall through */
72
case float_2nan_prop_ba:
73
which = is_nan(b->cls) ? 1 : 0;
27
break;
74
break;
28
--
75
--
29
2.34.1
76
2.34.1
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
So far, there is no FEAT_GICv3_NMI support in the in-kernel GIC, so make it
3
Move the fractional comparison to the end of the
4
an error to try to set has-nmi=true for the KVM GICv3.
4
float_2nan_prop_x87 case. This is not required for
5
any other 2nan propagation rule. Reorganize the
6
x87 case itself to break out of the switch when the
7
fractional comparison is not required.
5
8
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20240407081733.3231820-15-ruanjinjie@huawei.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20241203203949.483774-11-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
13
---
11
hw/intc/arm_gicv3_kvm.c | 5 +++++
14
fpu/softfloat-parts.c.inc | 19 +++++++++----------
12
1 file changed, 5 insertions(+)
15
1 file changed, 9 insertions(+), 10 deletions(-)
13
16
14
diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
17
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
15
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/intc/arm_gicv3_kvm.c
19
--- a/fpu/softfloat-parts.c.inc
17
+++ b/hw/intc/arm_gicv3_kvm.c
20
+++ b/fpu/softfloat-parts.c.inc
18
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
21
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
19
return;
22
return a;
20
}
23
}
21
24
22
+ if (s->nmi_support) {
25
- cmp = frac_cmp(a, b);
23
+ error_setg(errp, "NMI is not supported with the in-kernel GIC");
26
- if (cmp == 0) {
24
+ return;
27
- cmp = a->sign < b->sign;
25
+ }
28
- }
26
+
29
-
27
gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);
30
switch (s->float_2nan_prop_rule) {
28
31
case float_2nan_prop_s_ab:
29
for (i = 0; i < s->num_cpu; i++) {
32
if (have_snan) {
33
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
34
* return the NaN with the positive sign bit (if any).
35
*/
36
if (is_snan(a->cls)) {
37
- if (is_snan(b->cls)) {
38
- which = cmp > 0 ? 0 : 1;
39
- } else {
40
+ if (!is_snan(b->cls)) {
41
which = is_qnan(b->cls) ? 1 : 0;
42
+ break;
43
}
44
} else if (is_qnan(a->cls)) {
45
if (is_snan(b->cls) || !is_qnan(b->cls)) {
46
which = 0;
47
- } else {
48
- which = cmp > 0 ? 0 : 1;
49
+ break;
50
}
51
} else {
52
which = 1;
53
+ break;
54
}
55
+ cmp = frac_cmp(a, b);
56
+ if (cmp == 0) {
57
+ cmp = a->sign < b->sign;
58
+ }
59
+ which = cmp > 0 ? 0 : 1;
60
break;
61
default:
62
g_assert_not_reached();
30
--
63
--
31
2.34.1
64
2.34.1
diff view generated by jsdifflib
1
From: Arnaud Minier <arnaud.minier@telecom-paris.fr>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Implement the ability to read and write characters to the
3
Replace the "index" selecting between A and B with a result variable
4
usart using the serial port.
4
of the proper type. This improves clarity within the function.
5
5
6
The character transmission is based on the
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
cmsdk-apb-uart implementation.
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
8
Message-id: 20241203203949.483774-12-richard.henderson@linaro.org
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]
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
10
---
16
include/hw/char/stm32l4x5_usart.h | 1 +
11
fpu/softfloat-parts.c.inc | 28 +++++++++++++---------------
17
hw/char/stm32l4x5_usart.c | 143 ++++++++++++++++++++++++++++++
12
1 file changed, 13 insertions(+), 15 deletions(-)
18
hw/char/trace-events | 7 ++
19
3 files changed, 151 insertions(+)
20
13
21
diff --git a/include/hw/char/stm32l4x5_usart.h b/include/hw/char/stm32l4x5_usart.h
14
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
22
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/char/stm32l4x5_usart.h
16
--- a/fpu/softfloat-parts.c.inc
24
+++ b/include/hw/char/stm32l4x5_usart.h
17
+++ b/fpu/softfloat-parts.c.inc
25
@@ -XXX,XX +XXX,XX @@ struct Stm32l4x5UsartBaseState {
18
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
26
Clock *clk;
19
float_status *s)
27
CharBackend chr;
28
qemu_irq irq;
29
+ guint watch_tag;
30
};
31
32
struct Stm32l4x5UsartBaseClass {
33
diff --git a/hw/char/stm32l4x5_usart.c b/hw/char/stm32l4x5_usart.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/char/stm32l4x5_usart.c
36
+++ b/hw/char/stm32l4x5_usart.c
37
@@ -XXX,XX +XXX,XX @@ REG32(RDR, 0x24)
38
REG32(TDR, 0x28)
39
FIELD(TDR, TDR, 0, 9)
40
41
+static void stm32l4x5_update_irq(Stm32l4x5UsartBaseState *s)
42
+{
43
+ if (((s->isr & R_ISR_WUF_MASK) && (s->cr3 & R_CR3_WUFIE_MASK)) ||
44
+ ((s->isr & R_ISR_CMF_MASK) && (s->cr1 & R_CR1_CMIE_MASK)) ||
45
+ ((s->isr & R_ISR_ABRF_MASK) && (s->cr1 & R_CR1_RXNEIE_MASK)) ||
46
+ ((s->isr & R_ISR_EOBF_MASK) && (s->cr1 & R_CR1_EOBIE_MASK)) ||
47
+ ((s->isr & R_ISR_RTOF_MASK) && (s->cr1 & R_CR1_RTOIE_MASK)) ||
48
+ ((s->isr & R_ISR_CTSIF_MASK) && (s->cr3 & R_CR3_CTSIE_MASK)) ||
49
+ ((s->isr & R_ISR_LBDF_MASK) && (s->cr2 & R_CR2_LBDIE_MASK)) ||
50
+ ((s->isr & R_ISR_TXE_MASK) && (s->cr1 & R_CR1_TXEIE_MASK)) ||
51
+ ((s->isr & R_ISR_TC_MASK) && (s->cr1 & R_CR1_TCIE_MASK)) ||
52
+ ((s->isr & R_ISR_RXNE_MASK) && (s->cr1 & R_CR1_RXNEIE_MASK)) ||
53
+ ((s->isr & R_ISR_IDLE_MASK) && (s->cr1 & R_CR1_IDLEIE_MASK)) ||
54
+ ((s->isr & R_ISR_ORE_MASK) &&
55
+ ((s->cr1 & R_CR1_RXNEIE_MASK) || (s->cr3 & R_CR3_EIE_MASK))) ||
56
+ /* TODO: Handle NF ? */
57
+ ((s->isr & R_ISR_FE_MASK) && (s->cr3 & R_CR3_EIE_MASK)) ||
58
+ ((s->isr & R_ISR_PE_MASK) && (s->cr1 & R_CR1_PEIE_MASK))) {
59
+ qemu_irq_raise(s->irq);
60
+ trace_stm32l4x5_usart_irq_raised(s->isr);
61
+ } else {
62
+ qemu_irq_lower(s->irq);
63
+ trace_stm32l4x5_usart_irq_lowered();
64
+ }
65
+}
66
+
67
+static int stm32l4x5_usart_base_can_receive(void *opaque)
68
+{
69
+ Stm32l4x5UsartBaseState *s = opaque;
70
+
71
+ if (!(s->isr & R_ISR_RXNE_MASK)) {
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
{
20
{
160
Stm32l4x5UsartBaseState *s = STM32L4X5_USART_BASE(obj);
21
bool have_snan = false;
161
@@ -XXX,XX +XXX,XX @@ static void stm32l4x5_usart_base_reset_hold(Object *obj, ResetType type)
22
- int cmp, which;
162
s->isr = 0x020000C0;
23
+ FloatPartsN *ret;
163
s->rdr = 0x00000000;
24
+ int cmp;
164
s->tdr = 0x00000000;
25
165
+
26
if (is_snan(a->cls) || is_snan(b->cls)) {
166
+ usart_cancel_transmit(s);
27
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
167
+ stm32l4x5_update_irq(s);
28
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
168
+}
29
switch (s->float_2nan_prop_rule) {
169
+
30
case float_2nan_prop_s_ab:
170
+static void usart_update_rqr(Stm32l4x5UsartBaseState *s, uint32_t value)
31
if (have_snan) {
171
+{
32
- which = is_snan(a->cls) ? 0 : 1;
172
+ /* TXFRQ */
33
+ ret = is_snan(a->cls) ? a : b;
173
+ /* Reset RXNE flag */
34
break;
174
+ if (value & R_RQR_RXFRQ_MASK) {
35
}
175
+ s->isr &= ~R_ISR_RXNE_MASK;
36
/* fall through */
176
+ }
37
case float_2nan_prop_ab:
177
+ /* MMRQ */
38
- which = is_nan(a->cls) ? 0 : 1;
178
+ /* SBKRQ */
39
+ ret = is_nan(a->cls) ? a : b;
179
+ /* ABRRQ */
40
break;
180
+ stm32l4x5_update_irq(s);
41
case float_2nan_prop_s_ba:
42
if (have_snan) {
43
- which = is_snan(b->cls) ? 1 : 0;
44
+ ret = is_snan(b->cls) ? b : a;
45
break;
46
}
47
/* fall through */
48
case float_2nan_prop_ba:
49
- which = is_nan(b->cls) ? 1 : 0;
50
+ ret = is_nan(b->cls) ? b : a;
51
break;
52
case float_2nan_prop_x87:
53
/*
54
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
55
*/
56
if (is_snan(a->cls)) {
57
if (!is_snan(b->cls)) {
58
- which = is_qnan(b->cls) ? 1 : 0;
59
+ ret = is_qnan(b->cls) ? b : a;
60
break;
61
}
62
} else if (is_qnan(a->cls)) {
63
if (is_snan(b->cls) || !is_qnan(b->cls)) {
64
- which = 0;
65
+ ret = a;
66
break;
67
}
68
} else {
69
- which = 1;
70
+ ret = b;
71
break;
72
}
73
cmp = frac_cmp(a, b);
74
if (cmp == 0) {
75
cmp = a->sign < b->sign;
76
}
77
- which = cmp > 0 ? 0 : 1;
78
+ ret = cmp > 0 ? a : b;
79
break;
80
default:
81
g_assert_not_reached();
82
}
83
84
- if (which) {
85
- a = b;
86
+ if (is_snan(ret->cls)) {
87
+ parts_silence_nan(ret, s);
88
}
89
- if (is_snan(a->cls)) {
90
- parts_silence_nan(a, s);
91
- }
92
- return a;
93
+ return ret;
181
}
94
}
182
95
183
static uint64_t stm32l4x5_usart_base_read(void *opaque, hwaddr addr,
96
static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
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"
254
--
97
--
255
2.34.1
98
2.34.1
256
99
257
100
diff view generated by jsdifflib
1
Ever since the bFLT format support was added in 2006, there has been
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
2
a chunk of code in the file guarded by CONFIG_BINFMT_SHARED_FLAT
3
which is supposedly for shared library support. This is not enabled
4
and it's not possible to enable it, because if you do you'll run into
5
the "#error needs checking" in the calc_reloc() function.
6
2
7
Similarly, CONFIG_BINFMT_ZFLAT exists but can't be enabled because of
3
I'm migrating to Qualcomm's new open source email infrastructure, so
8
an "#error code needs checking" in load_flat_file().
4
update my email address, and update the mailmap to match.
9
5
10
This code is obviously unfinished and has never been used; nobody in
6
Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
11
the intervening 18 years has complained about this or fixed it, so
7
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
12
just delete the dead code. If anybody ever wants the feature they
8
Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com>
13
can always pull it out of git, or (perhaps better) write it from
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
scratch based on the current Linux bFLT loader rather than the one of
10
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
15
18 years ago.
11
Message-id: 20241205114047.1125842-1-leif.lindholm@oss.qualcomm.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
14
MAINTAINERS | 2 +-
15
.mailmap | 5 +++--
16
2 files changed, 4 insertions(+), 3 deletions(-)
16
17
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
diff --git a/MAINTAINERS b/MAINTAINERS
18
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
19
Message-id: 20240411115313.680433-1-peter.maydell@linaro.org
20
---
21
linux-user/flat.h | 5 +-
22
linux-user/flatload.c | 293 ++----------------------------------------
23
2 files changed, 11 insertions(+), 287 deletions(-)
24
25
diff --git a/linux-user/flat.h b/linux-user/flat.h
26
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
27
--- a/linux-user/flat.h
20
--- a/MAINTAINERS
28
+++ b/linux-user/flat.h
21
+++ b/MAINTAINERS
29
@@ -XXX,XX +XXX,XX @@
22
@@ -XXX,XX +XXX,XX @@ F: include/hw/ssi/imx_spi.h
30
23
SBSA-REF
31
#define    FLAT_VERSION            0x00000004L
24
M: Radoslaw Biernacki <rad@semihalf.com>
32
25
M: Peter Maydell <peter.maydell@linaro.org>
33
-#ifdef CONFIG_BINFMT_SHARED_FLAT
26
-R: Leif Lindholm <quic_llindhol@quicinc.com>
34
-#define    MAX_SHARED_LIBS            (4)
27
+R: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
35
-#else
28
R: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
36
+/* QEMU doesn't support bflt shared libraries */
29
L: qemu-arm@nongnu.org
37
#define    MAX_SHARED_LIBS            (1)
30
S: Maintained
38
-#endif
31
diff --git a/.mailmap b/.mailmap
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
32
index XXXXXXX..XXXXXXX 100644
44
--- a/linux-user/flatload.c
33
--- a/.mailmap
45
+++ b/linux-user/flatload.c
34
+++ b/.mailmap
46
@@ -XXX,XX +XXX,XX @@
35
@@ -XXX,XX +XXX,XX @@ Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com>
47
*    JAN/99 -- coded full program relocation (gerg@snapgear.com)
36
Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn>
48
*/
37
James Hogan <jhogan@kernel.org> <james.hogan@imgtec.com>
49
38
Juan Quintela <quintela@trasno.org> <quintela@redhat.com>
50
-/* ??? ZFLAT and shared library support is currently disabled. */
39
-Leif Lindholm <quic_llindhol@quicinc.com> <leif.lindholm@linaro.org>
51
-
40
-Leif Lindholm <quic_llindhol@quicinc.com> <leif@nuviainc.com>
52
/****************************************************************************/
41
+Leif Lindholm <leif.lindholm@oss.qualcomm.com> <quic_llindhol@quicinc.com>
53
42
+Leif Lindholm <leif.lindholm@oss.qualcomm.com> <leif.lindholm@linaro.org>
54
#include "qemu/osdep.h"
43
+Leif Lindholm <leif.lindholm@oss.qualcomm.com> <leif@nuviainc.com>
55
@@ -XXX,XX +XXX,XX @@ struct lib_info {
44
Luc Michel <luc@lmichel.fr> <luc.michel@git.antfield.fr>
56
short loaded;        /* Has this library been loaded? */
45
Luc Michel <luc@lmichel.fr> <luc.michel@greensocs.com>
57
};
46
Luc Michel <luc@lmichel.fr> <lmichel@kalray.eu>
58
59
-#ifdef CONFIG_BINFMT_SHARED_FLAT
60
-static int load_flat_shared_library(int id, struct lib_info *p);
61
-#endif
62
-
63
struct linux_binprm;
64
65
/****************************************************************************/
66
@@ -XXX,XX +XXX,XX @@ static int target_pread(int fd, abi_ulong ptr, abi_ulong len,
67
unlock_user(buf, ptr, len);
68
return ret;
69
}
70
-/****************************************************************************/
71
-
72
-#ifdef CONFIG_BINFMT_ZFLAT
73
-
74
-#include <linux/zlib.h>
75
-
76
-#define LBUFSIZE    4000
77
-
78
-/* gzip flag byte */
79
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
80
-#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
81
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
82
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
83
-#define COMMENT 0x10 /* bit 4 set: file comment present */
84
-#define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
85
-#define RESERVED 0xC0 /* bit 6,7: reserved */
86
-
87
-static int decompress_exec(
88
-    struct linux_binprm *bprm,
89
-    unsigned long offset,
90
-    char *dst,
91
-    long len,
92
-    int fd)
93
-{
94
-    unsigned char *buf;
95
-    z_stream strm;
96
-    loff_t fpos;
97
-    int ret, retval;
98
-
99
-    DBG_FLT("decompress_exec(offset=%x,buf=%x,len=%x)\n",(int)offset, (int)dst, (int)len);
100
-
101
-    memset(&strm, 0, sizeof(strm));
102
-    strm.workspace = kmalloc(zlib_inflate_workspacesize(), GFP_KERNEL);
103
-    if (strm.workspace == NULL) {
104
-        DBG_FLT("binfmt_flat: no memory for decompress workspace\n");
105
-        return -ENOMEM;
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)
384
{
385
struct lib_info libinfo[MAX_SHARED_LIBS];
386
@@ -XXX,XX +XXX,XX @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info)
387
*/
388
start_addr = libinfo[0].entry;
389
390
-#ifdef CONFIG_BINFMT_SHARED_FLAT
391
-#error here
392
- for (i = MAX_SHARED_LIBS-1; i>0; i--) {
393
- if (libinfo[i].loaded) {
394
- /* Push previous first to call address */
395
- --sp;
396
- if (put_user_ual(start_addr, sp))
397
- return -EFAULT;
398
- start_addr = libinfo[i].entry;
399
- }
400
- }
401
-#endif
402
-
403
/* Stash our initial stack pointer into the mm structure */
404
info->start_code = libinfo[0].start_code;
405
info->end_code = libinfo[0].start_code + libinfo[0].text_len;
406
--
47
--
407
2.34.1
48
2.34.1
408
49
409
50
diff view generated by jsdifflib
1
From: Jinjie Ruan <ruanjinjie@huawei.com>
1
From: Vikram Garhwal <vikram.garhwal@bytedance.com>
2
2
3
Augment the GICv3's QOM device interface by adding one
3
Previously, maintainer role was paused due to inactive email id. Commit id:
4
new set of sysbus IRQ line, to signal NMI to each CPU.
4
c009d715721861984c4987bcc78b7ee183e86d75.
5
5
6
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
6
Signed-off-by: Vikram Garhwal <vikram.garhwal@bytedance.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20241204184205.12952-1-vikram.garhwal@bytedance.com
9
Message-id: 20240407081733.3231820-11-ruanjinjie@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
include/hw/intc/arm_gic_common.h | 2 ++
11
MAINTAINERS | 2 ++
13
include/hw/intc/arm_gicv3_common.h | 2 ++
12
1 file changed, 2 insertions(+)
14
hw/intc/arm_gicv3_common.c | 6 ++++++
15
3 files changed, 10 insertions(+)
16
13
17
diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_common.h
14
diff --git a/MAINTAINERS b/MAINTAINERS
18
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/intc/arm_gic_common.h
16
--- a/MAINTAINERS
20
+++ b/include/hw/intc/arm_gic_common.h
17
+++ b/MAINTAINERS
21
@@ -XXX,XX +XXX,XX @@ struct GICState {
18
@@ -XXX,XX +XXX,XX @@ F: tests/qtest/fuzz-sb16-test.c
22
qemu_irq parent_fiq[GIC_NCPU];
19
23
qemu_irq parent_virq[GIC_NCPU];
20
Xilinx CAN
24
qemu_irq parent_vfiq[GIC_NCPU];
21
M: Francisco Iglesias <francisco.iglesias@amd.com>
25
+ qemu_irq parent_nmi[GIC_NCPU];
22
+M: Vikram Garhwal <vikram.garhwal@bytedance.com>
26
+ qemu_irq parent_vnmi[GIC_NCPU];
23
S: Maintained
27
qemu_irq maintenance_irq[GIC_NCPU];
24
F: hw/net/can/xlnx-*
28
25
F: include/hw/net/xlnx-*
29
/* GICD_CTLR; for a GIC with the security extensions the NS banked version
26
@@ -XXX,XX +XXX,XX @@ F: include/hw/rx/
30
diff --git a/include/hw/intc/arm_gicv3_common.h b/include/hw/intc/arm_gicv3_common.h
27
CAN bus subsystem and hardware
31
index XXXXXXX..XXXXXXX 100644
28
M: Pavel Pisa <pisa@cmp.felk.cvut.cz>
32
--- a/include/hw/intc/arm_gicv3_common.h
29
M: Francisco Iglesias <francisco.iglesias@amd.com>
33
+++ b/include/hw/intc/arm_gicv3_common.h
30
+M: Vikram Garhwal <vikram.garhwal@bytedance.com>
34
@@ -XXX,XX +XXX,XX @@ struct GICv3CPUState {
31
S: Maintained
35
qemu_irq parent_fiq;
32
W: https://canbus.pages.fel.cvut.cz/
36
qemu_irq parent_virq;
33
F: net/can/*
37
qemu_irq parent_vfiq;
38
+ qemu_irq parent_nmi;
39
+ qemu_irq parent_vnmi;
40
41
/* Redistributor */
42
uint32_t level; /* Current IRQ level */
43
diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/intc/arm_gicv3_common.c
46
+++ b/hw/intc/arm_gicv3_common.c
47
@@ -XXX,XX +XXX,XX @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler,
48
for (i = 0; i < s->num_cpu; i++) {
49
sysbus_init_irq(sbd, &s->cpu[i].parent_vfiq);
50
}
51
+ for (i = 0; i < s->num_cpu; i++) {
52
+ sysbus_init_irq(sbd, &s->cpu[i].parent_nmi);
53
+ }
54
+ for (i = 0; i < s->num_cpu; i++) {
55
+ sysbus_init_irq(sbd, &s->cpu[i].parent_vnmi);
56
+ }
57
58
memory_region_init_io(&s->iomem_dist, OBJECT(s), ops, s,
59
"gicv3_dist", 0x10000);
60
--
34
--
61
2.34.1
35
2.34.1
diff view generated by jsdifflib