1 | The following changes since commit 5767815218efd3cbfd409505ed824d5f356044ae: | 1 | First arm pullreq of the cycle; this is mostly my softfloat NaN |
---|---|---|---|
2 | handling series. (Lots more in my to-review queue, but I don't | ||
3 | like pullreqs growing too close to a hundred patches at a time :-)) | ||
2 | 4 | ||
3 | Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging (2024-02-14 15:45:52 +0000) | 5 | thanks |
6 | -- PMM | ||
7 | |||
8 | The following changes since commit 97f2796a3736ed37a1b85dc1c76a6c45b829dd17: | ||
9 | |||
10 | Open 10.0 development tree (2024-12-10 17:41:17 +0000) | ||
4 | 11 | ||
5 | are available in the Git repository at: | 12 | are available in the Git repository at: |
6 | 13 | ||
7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240215 | 14 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20241211 |
8 | 15 | ||
9 | for you to fetch changes up to f780e63fe731b058fe52d43653600d8729a1b5f2: | 16 | for you to fetch changes up to 1abe28d519239eea5cf9620bb13149423e5665f8: |
10 | 17 | ||
11 | docs: Add documentation for the mps3-an536 board (2024-02-15 14:32:39 +0000) | 18 | MAINTAINERS: Add correct email address for Vikram Garhwal (2024-12-11 15:31:09 +0000) |
12 | 19 | ||
13 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
14 | target-arm queue: | 21 | target-arm queue: |
15 | * hw/arm/xilinx_zynq: Wire FIQ between CPU <> GIC | 22 | * hw/net/lan9118: Extract PHY model, reuse with imx_fec, fix bugs |
16 | * linux-user/aarch64: Choose SYNC as the preferred MTE mode | 23 | * fpu: Make muladd NaN handling runtime-selected, not compile-time |
17 | * Fix some errors in SVE/SME handling of MTE tags | 24 | * fpu: Make default NaN pattern runtime-selected, not compile-time |
18 | * hw/pci-host/raven.c: Mark raven_io_ops as implementing unaligned accesses | 25 | * fpu: Minor NaN-related cleanups |
19 | * hw/block/tc58128: Don't emit deprecation warning under qtest | 26 | * MAINTAINERS: email address updates |
20 | * tests/qtest: Fix handling of npcm7xx and GMAC tests | ||
21 | * hw/arm/virt: Wire up non-secure EL2 virtual timer IRQ | ||
22 | * tests/qtest/npcm7xx_emc-test: Connect all NICs to a backend | ||
23 | * Don't assert on vmload/vmsave of M-profile CPUs | ||
24 | * hw/arm/smmuv3: add support for stage 1 access fault | ||
25 | * hw/arm/stellaris: QOM cleanups | ||
26 | * Use new CBAR encoding for all v8 CPUs, not all aarch64 CPUs | ||
27 | * Improve Cortex_R52 IMPDEF sysreg modelling | ||
28 | * Allow access to SPSR_hyp from hyp mode | ||
29 | * New board model mps3-an536 (Cortex-R52) | ||
30 | 27 | ||
31 | ---------------------------------------------------------------- | 28 | ---------------------------------------------------------------- |
32 | Luc Michel (1): | 29 | Bernhard Beschow (5): |
33 | hw/arm/smmuv3: add support for stage 1 access fault | 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 | ||
34 | 35 | ||
35 | Nabih Estefan (1): | 36 | Leif Lindholm (1): |
36 | tests/qtest: Fix GMAC test to run on a machine in upstream QEMU | 37 | MAINTAINERS: update email address for Leif Lindholm |
37 | 38 | ||
38 | Peter Maydell (22): | 39 | Peter Maydell (54): |
39 | hw/pci-host/raven.c: Mark raven_io_ops as implementing unaligned accesses | 40 | fpu: handle raising Invalid for infzero in pick_nan_muladd |
40 | hw/block/tc58128: Don't emit deprecation warning under qtest | 41 | fpu: Check for default_nan_mode before calling pickNaNMulAdd |
41 | tests/qtest/meson.build: Don't include qtests_npcm7xx in qtests_aarch64 | 42 | softfloat: Allow runtime choice of inf * 0 + NaN result |
42 | tests/qtest/bios-tables-test: Allow changes to virt GTDT | 43 | tests/fp: Explicitly set inf-zero-nan rule |
43 | hw/arm/virt: Wire up non-secure EL2 virtual timer IRQ | 44 | target/arm: Set FloatInfZeroNaNRule explicitly |
44 | tests/qtest/bios-tables-tests: Update virt golden reference | 45 | target/s390: Set FloatInfZeroNaNRule explicitly |
45 | hw/arm/npcm7xx: Call qemu_configure_nic_device() for GMAC modules | 46 | target/ppc: Set FloatInfZeroNaNRule explicitly |
46 | tests/qtest/npcm7xx_emc-test: Connect all NICs to a backend | 47 | target/mips: Set FloatInfZeroNaNRule explicitly |
47 | target/arm: Don't get MDCR_EL2 in pmu_counter_enabled() before checking ARM_FEATURE_PMU | 48 | target/sparc: Set FloatInfZeroNaNRule explicitly |
48 | target/arm: Use new CBAR encoding for all v8 CPUs, not all aarch64 CPUs | 49 | target/xtensa: Set FloatInfZeroNaNRule explicitly |
49 | target/arm: The Cortex-R52 has a read-only CBAR | 50 | target/x86: Set FloatInfZeroNaNRule explicitly |
50 | target/arm: Add Cortex-R52 IMPDEF sysregs | 51 | target/loongarch: Set FloatInfZeroNaNRule explicitly |
51 | target/arm: Allow access to SPSR_hyp from hyp mode | 52 | target/hppa: Set FloatInfZeroNaNRule explicitly |
52 | hw/misc/mps2-scc: Fix condition for CFG3 register | 53 | softfloat: Pass have_snan to pickNaNMulAdd |
53 | hw/misc/mps2-scc: Factor out which-board conditionals | 54 | softfloat: Allow runtime choice of NaN propagation for muladd |
54 | hw/misc/mps2-scc: Make changes needed for AN536 FPGA image | 55 | tests/fp: Explicitly set 3-NaN propagation rule |
55 | hw/arm/mps3r: Initial skeleton for mps3-an536 board | 56 | target/arm: Set Float3NaNPropRule explicitly |
56 | hw/arm/mps3r: Add CPUs, GIC, and per-CPU RAM | 57 | target/loongarch: Set Float3NaNPropRule explicitly |
57 | hw/arm/mps3r: Add UARTs | 58 | target/ppc: Set Float3NaNPropRule explicitly |
58 | hw/arm/mps3r: Add GPIO, watchdog, dual-timer, I2C devices | 59 | target/s390x: Set Float3NaNPropRule explicitly |
59 | hw/arm/mps3r: Add remaining devices | 60 | target/sparc: Set Float3NaNPropRule explicitly |
60 | docs: Add documentation for the mps3-an536 board | 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 | ||
61 | 94 | ||
62 | Philippe Mathieu-Daudé (5): | 95 | Richard Henderson (11): |
63 | hw/arm/xilinx_zynq: Wire FIQ between CPU <> GIC | 96 | target/arm: Copy entire float_status in is_ebf |
64 | hw/arm/stellaris: Convert ADC controller to Resettable interface | 97 | softfloat: Inline pickNaNMulAdd |
65 | hw/arm/stellaris: Convert I2C controller to Resettable interface | 98 | softfloat: Use goto for default nan case in pick_nan_muladd |
66 | hw/arm/stellaris: Add missing QOM 'machine' parent | 99 | softfloat: Remove which from parts_pick_nan_muladd |
67 | hw/arm/stellaris: Add missing QOM 'SoC' parent | 100 | softfloat: Pad array size in pick_nan_muladd |
101 | softfloat: Move propagateFloatx80NaN to softfloat.c | ||
102 | softfloat: Use parts_pick_nan in propagateFloatx80NaN | ||
103 | softfloat: Inline pickNaN | ||
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 | ||
68 | 107 | ||
69 | Richard Henderson (6): | 108 | Vikram Garhwal (1): |
70 | linux-user/aarch64: Choose SYNC as the preferred MTE mode | 109 | MAINTAINERS: Add correct email address for Vikram Garhwal |
71 | target/arm: Fix nregs computation in do_{ld,st}_zpa | ||
72 | target/arm: Adjust and validate mtedesc sizem1 | ||
73 | target/arm: Split out make_svemte_desc | ||
74 | target/arm: Handle mte in do_ldrq, do_ldro | ||
75 | target/arm: Fix SVE/SME gross MTE suppression checks | ||
76 | 110 | ||
77 | MAINTAINERS | 3 +- | 111 | MAINTAINERS | 4 +- |
78 | docs/system/arm/mps2.rst | 37 +- | 112 | include/fpu/softfloat-helpers.h | 38 +++- |
79 | configs/devices/arm-softmmu/default.mak | 1 + | 113 | include/fpu/softfloat-types.h | 89 +++++++- |
80 | hw/arm/smmuv3-internal.h | 1 + | 114 | include/hw/net/imx_fec.h | 9 +- |
81 | include/hw/arm/smmu-common.h | 1 + | 115 | include/hw/net/lan9118_phy.h | 37 ++++ |
82 | include/hw/arm/virt.h | 2 + | 116 | include/hw/net/mii.h | 6 + |
83 | include/hw/misc/mps2-scc.h | 1 + | 117 | target/mips/fpu_helper.h | 20 ++ |
84 | linux-user/aarch64/target_prctl.h | 29 +- | 118 | target/sparc/helper.h | 4 +- |
85 | target/arm/internals.h | 2 +- | 119 | fpu/softfloat.c | 19 ++ |
86 | target/arm/tcg/translate-a64.h | 2 + | 120 | hw/net/imx_fec.c | 146 ++------------ |
87 | hw/arm/mps3r.c | 640 ++++++++++++++++++++++++++++++++ | 121 | hw/net/lan9118.c | 137 ++----------- |
88 | hw/arm/npcm7xx.c | 1 + | 122 | hw/net/lan9118_phy.c | 222 ++++++++++++++++++++ |
89 | hw/arm/smmu-common.c | 11 + | 123 | linux-user/arm/nwfpe/fpa11.c | 5 + |
90 | hw/arm/smmuv3.c | 1 + | 124 | target/alpha/cpu.c | 2 + |
91 | hw/arm/stellaris.c | 47 ++- | 125 | target/arm/cpu.c | 10 + |
92 | hw/arm/virt-acpi-build.c | 20 +- | 126 | target/arm/tcg/vec_helper.c | 20 +- |
93 | hw/arm/virt.c | 60 ++- | 127 | target/hexagon/cpu.c | 2 + |
94 | hw/arm/xilinx_zynq.c | 2 + | 128 | target/hppa/fpu_helper.c | 12 ++ |
95 | hw/block/tc58128.c | 4 +- | 129 | target/i386/tcg/fpu_helper.c | 12 ++ |
96 | hw/misc/mps2-scc.c | 138 ++++++- | 130 | target/loongarch/tcg/fpu_helper.c | 14 +- |
97 | hw/pci-host/raven.c | 1 + | 131 | target/m68k/cpu.c | 14 +- |
98 | target/arm/helper.c | 14 +- | 132 | target/m68k/fpu_helper.c | 6 +- |
99 | target/arm/tcg/cpu32.c | 109 ++++++ | 133 | target/m68k/helper.c | 6 +- |
100 | target/arm/tcg/op_helper.c | 43 ++- | 134 | target/microblaze/cpu.c | 2 + |
101 | target/arm/tcg/sme_helper.c | 8 +- | 135 | target/mips/msa.c | 10 + |
102 | target/arm/tcg/sve_helper.c | 12 +- | 136 | target/openrisc/cpu.c | 2 + |
103 | target/arm/tcg/translate-sme.c | 15 +- | 137 | target/ppc/cpu_init.c | 19 ++ |
104 | target/arm/tcg/translate-sve.c | 83 +++-- | 138 | target/ppc/fpu_helper.c | 3 +- |
105 | target/arm/tcg/translate.c | 19 +- | 139 | target/riscv/cpu.c | 2 + |
106 | tests/qtest/npcm7xx_emc-test.c | 5 +- | 140 | target/rx/cpu.c | 2 + |
107 | tests/qtest/npcm_gmac-test.c | 84 +---- | 141 | target/s390x/cpu.c | 5 + |
108 | hw/arm/Kconfig | 5 + | 142 | target/sh4/cpu.c | 2 + |
109 | hw/arm/meson.build | 1 + | 143 | target/sparc/cpu.c | 6 + |
110 | tests/data/acpi/virt/FACP | Bin 276 -> 276 bytes | 144 | target/sparc/fop_helper.c | 8 +- |
111 | tests/data/acpi/virt/GTDT | Bin 96 -> 104 bytes | 145 | target/sparc/translate.c | 4 +- |
112 | tests/qtest/meson.build | 4 +- | 146 | target/tricore/helper.c | 2 + |
113 | 36 files changed, 1184 insertions(+), 222 deletions(-) | 147 | target/xtensa/cpu.c | 4 + |
114 | create mode 100644 hw/arm/mps3r.c | 148 | target/xtensa/fpu_helper.c | 3 +- |
115 | 149 | tests/fp/fp-bench.c | 7 + | |
150 | tests/fp/fp-test-log2.c | 1 + | ||
151 | tests/fp/fp-test.c | 7 + | ||
152 | fpu/softfloat-parts.c.inc | 152 +++++++++++--- | ||
153 | fpu/softfloat-specialize.c.inc | 412 ++------------------------------------ | ||
154 | .mailmap | 5 +- | ||
155 | hw/net/Kconfig | 5 + | ||
156 | hw/net/meson.build | 1 + | ||
157 | hw/net/trace-events | 10 +- | ||
158 | 47 files changed, 778 insertions(+), 730 deletions(-) | ||
159 | create mode 100644 include/hw/net/lan9118_phy.h | ||
160 | create mode 100644 hw/net/lan9118_phy.c | diff view generated by jsdifflib |
1 | The AN536 is another FPGA image for the MPS3 development board. Unlike | 1 | From: Bernhard Beschow <shentey@gmail.com> |
---|---|---|---|
2 | the existing FPGA images we already model, this board uses a Cortex-R | ||
3 | family CPU, and it does not use any equivalent to the M-profile | ||
4 | "Subsystem for Embedded" SoC-equivalent that we model in hw/arm/armsse.c. | ||
5 | It's therefore more convenient for us to model it as a completely | ||
6 | separate C file. | ||
7 | 2 | ||
8 | This commit adds the basic skeleton of the board model, and the | 3 | A very similar implementation of the same device exists in imx_fec. Prepare for |
9 | code to create all the RAM and ROM. We assume that we're probably | 4 | a common implementation by extracting a device model into its own files. |
10 | going to want to add more images in future, so use the same | ||
11 | base class/subclass setup that mps2-tz.c uses, even though at | ||
12 | the moment there's only a single subclass. | ||
13 | 5 | ||
14 | Following commits will add the CPUs and the peripherals. | 6 | Some migration state has been moved into the new device model which breaks |
7 | migration compatibility for the following machines: | ||
8 | * smdkc210 | ||
9 | * realview-* | ||
10 | * vexpress-* | ||
11 | * kzm | ||
12 | * mps2-* | ||
15 | 13 | ||
14 | While breaking migration ABI, fix the size of the MII registers to be 16 bit, | ||
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> | ||
19 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Message-id: 20241102125724.532843-2-shentey@gmail.com | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
17 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
18 | Message-id: 20240206132931.38376-9-peter.maydell@linaro.org | ||
19 | --- | 22 | --- |
20 | MAINTAINERS | 3 +- | 23 | include/hw/net/lan9118_phy.h | 37 ++++++++ |
21 | configs/devices/arm-softmmu/default.mak | 1 + | 24 | hw/net/lan9118.c | 137 +++++----------------------- |
22 | hw/arm/mps3r.c | 239 ++++++++++++++++++++++++ | 25 | hw/net/lan9118_phy.c | 169 +++++++++++++++++++++++++++++++++++ |
23 | hw/arm/Kconfig | 5 + | 26 | hw/net/Kconfig | 4 + |
24 | hw/arm/meson.build | 1 + | 27 | hw/net/meson.build | 1 + |
25 | 5 files changed, 248 insertions(+), 1 deletion(-) | 28 | 5 files changed, 233 insertions(+), 115 deletions(-) |
26 | create mode 100644 hw/arm/mps3r.c | 29 | create mode 100644 include/hw/net/lan9118_phy.h |
30 | create mode 100644 hw/net/lan9118_phy.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 @@ F: include/hw/misc/imx7_*.h | ||
33 | F: hw/pci-host/designware.c | ||
34 | F: include/hw/pci-host/designware.h | ||
35 | |||
36 | -MPS2 | ||
37 | +MPS2 / MPS3 | ||
38 | M: Peter Maydell <peter.maydell@linaro.org> | ||
39 | L: qemu-arm@nongnu.org | ||
40 | S: Maintained | ||
41 | F: hw/arm/mps2.c | ||
42 | F: hw/arm/mps2-tz.c | ||
43 | +F: hw/arm/mps3r.c | ||
44 | F: hw/misc/mps2-*.c | ||
45 | F: include/hw/misc/mps2-*.h | ||
46 | F: hw/arm/armsse.c | ||
47 | diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-softmmu/default.mak | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/configs/devices/arm-softmmu/default.mak | ||
50 | +++ b/configs/devices/arm-softmmu/default.mak | ||
51 | @@ -XXX,XX +XXX,XX @@ CONFIG_ARM_VIRT=y | ||
52 | # CONFIG_INTEGRATOR=n | ||
53 | # CONFIG_FSL_IMX31=n | ||
54 | # CONFIG_MUSICPAL=n | ||
55 | +# CONFIG_MPS3R=n | ||
56 | # CONFIG_MUSCA=n | ||
57 | # CONFIG_CHEETAH=n | ||
58 | # CONFIG_SX1=n | ||
59 | diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c | ||
60 | new file mode 100644 | 33 | new file mode 100644 |
61 | index XXXXXXX..XXXXXXX | 34 | index XXXXXXX..XXXXXXX |
62 | --- /dev/null | 35 | --- /dev/null |
63 | +++ b/hw/arm/mps3r.c | 36 | +++ b/include/hw/net/lan9118_phy.h |
64 | @@ -XXX,XX +XXX,XX @@ | 37 | @@ -XXX,XX +XXX,XX @@ |
65 | +/* | 38 | +/* |
66 | + * Arm MPS3 board emulation for Cortex-R-based FPGA images. | 39 | + * SMSC LAN9118 PHY emulation |
67 | + * (For M-profile images see mps2.c and mps2tz.c.) | ||
68 | + * | 40 | + * |
69 | + * Copyright (c) 2017 Linaro Limited | 41 | + * Copyright (c) 2009 CodeSourcery, LLC. |
70 | + * Written by Peter Maydell | 42 | + * Written by Paul Brook |
71 | + * | 43 | + * |
72 | + * This program is free software; you can redistribute it and/or modify | 44 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
73 | + * it under the terms of the GNU General Public License version 2 or | 45 | + * See the COPYING file in the top-level directory. |
74 | + * (at your option) any later version. | ||
75 | + */ | 46 | + */ |
76 | + | 47 | + |
48 | +#ifndef HW_NET_LAN9118_PHY_H | ||
49 | +#define HW_NET_LAN9118_PHY_H | ||
50 | + | ||
51 | +#include "qom/object.h" | ||
52 | +#include "hw/sysbus.h" | ||
53 | + | ||
54 | +#define TYPE_LAN9118_PHY "lan9118-phy" | ||
55 | +OBJECT_DECLARE_SIMPLE_TYPE(Lan9118PhyState, LAN9118_PHY) | ||
56 | + | ||
57 | +typedef struct Lan9118PhyState { | ||
58 | + SysBusDevice parent_obj; | ||
59 | + | ||
60 | + uint16_t status; | ||
61 | + uint16_t control; | ||
62 | + uint16_t advertise; | ||
63 | + uint16_t ints; | ||
64 | + uint16_t int_mask; | ||
65 | + qemu_irq irq; | ||
66 | + bool link_down; | ||
67 | +} Lan9118PhyState; | ||
68 | + | ||
69 | +void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down); | ||
70 | +void lan9118_phy_reset(Lan9118PhyState *s); | ||
71 | +uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg); | ||
72 | +void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val); | ||
73 | + | ||
74 | +#endif | ||
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 | ||
312 | new file mode 100644 | ||
313 | index XXXXXXX..XXXXXXX | ||
314 | --- /dev/null | ||
315 | +++ b/hw/net/lan9118_phy.c | ||
316 | @@ -XXX,XX +XXX,XX @@ | ||
77 | +/* | 317 | +/* |
78 | + * The MPS3 is an FPGA based dev board. This file handles FPGA images | 318 | + * SMSC LAN9118 PHY emulation |
79 | + * which use the Cortex-R CPUs. We model these separately from the | ||
80 | + * M-profile images, because on M-profile the FPGA image is based on | ||
81 | + * a "Subsystem for Embedded" which is similar to an SoC, whereas | ||
82 | + * the R-profile FPGA images don't have that abstraction layer. | ||
83 | + * | 319 | + * |
84 | + * We model the following FPGA images here: | 320 | + * Copyright (c) 2009 CodeSourcery, LLC. |
85 | + * "mps3-an536" -- dual Cortex-R52 as documented in Arm Application Note AN536 | 321 | + * Written by Paul Brook |
86 | + * | 322 | + * |
87 | + * Application Note AN536: | 323 | + * This code is licensed under the GNU GPL v2 |
88 | + * https://developer.arm.com/documentation/dai0536/latest/ | 324 | + * |
325 | + * Contributions after 2012-01-13 are licensed under the terms of the | ||
326 | + * GNU GPL, version 2 or (at your option) any later version. | ||
89 | + */ | 327 | + */ |
90 | + | 328 | + |
91 | +#include "qemu/osdep.h" | 329 | +#include "qemu/osdep.h" |
92 | +#include "qemu/units.h" | 330 | +#include "hw/net/lan9118_phy.h" |
93 | +#include "qapi/error.h" | 331 | +#include "hw/irq.h" |
94 | +#include "exec/address-spaces.h" | 332 | +#include "hw/resettable.h" |
95 | +#include "cpu.h" | 333 | +#include "migration/vmstate.h" |
96 | +#include "hw/boards.h" | 334 | +#include "qemu/log.h" |
97 | +#include "hw/arm/boot.h" | 335 | + |
98 | + | 336 | +#define PHY_INT_ENERGYON (1 << 7) |
99 | +/* Define the layout of RAM and ROM in a board */ | 337 | +#define PHY_INT_AUTONEG_COMPLETE (1 << 6) |
100 | +typedef struct RAMInfo { | 338 | +#define PHY_INT_FAULT (1 << 5) |
101 | + const char *name; | 339 | +#define PHY_INT_DOWN (1 << 4) |
102 | + hwaddr base; | 340 | +#define PHY_INT_AUTONEG_LP (1 << 3) |
103 | + hwaddr size; | 341 | +#define PHY_INT_PARFAULT (1 << 2) |
104 | + int mrindex; /* index into rams[]; -1 for the system RAM block */ | 342 | +#define PHY_INT_AUTONEG_PAGE (1 << 1) |
105 | + int flags; | 343 | + |
106 | +} RAMInfo; | 344 | +static void lan9118_phy_update_irq(Lan9118PhyState *s) |
107 | + | 345 | +{ |
108 | +/* | 346 | + qemu_set_irq(s->irq, !!(s->ints & s->int_mask)); |
109 | + * The MPS3 DDR is 3GiB, but on a 32-bit host QEMU doesn't permit | 347 | +} |
110 | + * emulation of that much guest RAM, so artificially make it smaller. | 348 | + |
111 | + */ | 349 | +uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg) |
112 | +#if HOST_LONG_BITS == 32 | 350 | +{ |
113 | +#define MPS3_DDR_SIZE (1 * GiB) | 351 | + uint16_t val; |
114 | +#else | 352 | + |
115 | +#define MPS3_DDR_SIZE (3 * GiB) | 353 | + switch (reg) { |
116 | +#endif | 354 | + case 0: /* Basic Control */ |
117 | + | 355 | + return s->control; |
118 | +/* | 356 | + case 1: /* Basic Status */ |
119 | + * Flag values: | 357 | + return s->status; |
120 | + * IS_MAIN: this is the main machine RAM | 358 | + case 2: /* ID1 */ |
121 | + * IS_ROM: this area is read-only | 359 | + return 0x0007; |
122 | + */ | 360 | + case 3: /* ID2 */ |
123 | +#define IS_MAIN 1 | 361 | + return 0xc0d1; |
124 | +#define IS_ROM 2 | 362 | + case 4: /* Auto-neg advertisement */ |
125 | + | 363 | + return s->advertise; |
126 | +#define MPS3R_RAM_MAX 9 | 364 | + case 5: /* Auto-neg Link Partner Ability */ |
127 | + | 365 | + return 0x0f71; |
128 | +typedef enum MPS3RFPGAType { | 366 | + case 6: /* Auto-neg Expansion */ |
129 | + FPGA_AN536, | 367 | + return 1; |
130 | +} MPS3RFPGAType; | 368 | + /* TODO 17, 18, 27, 29, 30, 31 */ |
131 | + | 369 | + case 29: /* Interrupt source. */ |
132 | +struct MPS3RMachineClass { | 370 | + val = s->ints; |
133 | + MachineClass parent; | 371 | + s->ints = 0; |
134 | + MPS3RFPGAType fpga_type; | 372 | + lan9118_phy_update_irq(s); |
135 | + const RAMInfo *raminfo; | 373 | + return val; |
136 | +}; | 374 | + case 30: /* Interrupt mask */ |
137 | + | 375 | + return s->int_mask; |
138 | +struct MPS3RMachineState { | 376 | + default: |
139 | + MachineState parent; | 377 | + qemu_log_mask(LOG_GUEST_ERROR, |
140 | + MemoryRegion ram[MPS3R_RAM_MAX]; | 378 | + "lan9118_phy_read: PHY read reg %d\n", reg); |
141 | +}; | 379 | + return 0; |
142 | + | 380 | + } |
143 | +#define TYPE_MPS3R_MACHINE "mps3r" | 381 | +} |
144 | +#define TYPE_MPS3R_AN536_MACHINE MACHINE_TYPE_NAME("mps3-an536") | 382 | + |
145 | + | 383 | +void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val) |
146 | +OBJECT_DECLARE_TYPE(MPS3RMachineState, MPS3RMachineClass, MPS3R_MACHINE) | 384 | +{ |
147 | + | 385 | + switch (reg) { |
148 | +static const RAMInfo an536_raminfo[] = { | 386 | + case 0: /* Basic Control */ |
149 | + { | 387 | + if (val & 0x8000) { |
150 | + .name = "ATCM", | 388 | + lan9118_phy_reset(s); |
151 | + .base = 0x00000000, | 389 | + break; |
152 | + .size = 0x00008000, | 390 | + } |
153 | + .mrindex = 0, | 391 | + s->control = val & 0x7980; |
154 | + }, { | 392 | + /* Complete autonegotiation immediately. */ |
155 | + /* We model the QSPI flash as simple ROM for now */ | 393 | + if (val & 0x1000) { |
156 | + .name = "QSPI", | 394 | + s->status |= 0x0020; |
157 | + .base = 0x08000000, | 395 | + } |
158 | + .size = 0x00800000, | 396 | + break; |
159 | + .flags = IS_ROM, | 397 | + case 4: /* Auto-neg advertisement */ |
160 | + .mrindex = 1, | 398 | + s->advertise = (val & 0x2d7f) | 0x80; |
161 | + }, { | 399 | + break; |
162 | + .name = "BRAM", | 400 | + /* TODO 17, 18, 27, 31 */ |
163 | + .base = 0x10000000, | 401 | + case 30: /* Interrupt mask */ |
164 | + .size = 0x00080000, | 402 | + s->int_mask = val & 0xff; |
165 | + .mrindex = 2, | 403 | + lan9118_phy_update_irq(s); |
166 | + }, { | 404 | + break; |
167 | + .name = "DDR", | 405 | + default: |
168 | + .base = 0x20000000, | 406 | + qemu_log_mask(LOG_GUEST_ERROR, |
169 | + .size = MPS3_DDR_SIZE, | 407 | + "lan9118_phy_write: PHY write reg %d = 0x%04x\n", reg, val); |
170 | + .mrindex = -1, | 408 | + } |
171 | + }, { | 409 | +} |
172 | + .name = "ATCM0", | 410 | + |
173 | + .base = 0xee000000, | 411 | +void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down) |
174 | + .size = 0x00008000, | 412 | +{ |
175 | + .mrindex = 3, | 413 | + s->link_down = link_down; |
176 | + }, { | 414 | + |
177 | + .name = "BTCM0", | 415 | + /* Autonegotiation status mirrors link status. */ |
178 | + .base = 0xee100000, | 416 | + if (link_down) { |
179 | + .size = 0x00008000, | 417 | + s->status &= ~0x0024; |
180 | + .mrindex = 4, | 418 | + s->ints |= PHY_INT_DOWN; |
181 | + }, { | 419 | + } else { |
182 | + .name = "CTCM0", | 420 | + s->status |= 0x0024; |
183 | + .base = 0xee200000, | 421 | + s->ints |= PHY_INT_ENERGYON; |
184 | + .size = 0x00008000, | 422 | + s->ints |= PHY_INT_AUTONEG_COMPLETE; |
185 | + .mrindex = 5, | 423 | + } |
186 | + }, { | 424 | + lan9118_phy_update_irq(s); |
187 | + .name = "ATCM1", | 425 | +} |
188 | + .base = 0xee400000, | 426 | + |
189 | + .size = 0x00008000, | 427 | +void lan9118_phy_reset(Lan9118PhyState *s) |
190 | + .mrindex = 6, | 428 | +{ |
191 | + }, { | 429 | + s->control = 0x3000; |
192 | + .name = "BTCM1", | 430 | + s->status = 0x7809; |
193 | + .base = 0xee500000, | 431 | + s->advertise = 0x01e1; |
194 | + .size = 0x00008000, | 432 | + s->int_mask = 0; |
195 | + .mrindex = 7, | 433 | + s->ints = 0; |
196 | + }, { | 434 | + lan9118_phy_update_link(s, s->link_down); |
197 | + .name = "CTCM1", | 435 | +} |
198 | + .base = 0xee600000, | 436 | + |
199 | + .size = 0x00008000, | 437 | +static void lan9118_phy_reset_hold(Object *obj, ResetType type) |
200 | + .mrindex = 8, | 438 | +{ |
201 | + }, { | 439 | + Lan9118PhyState *s = LAN9118_PHY(obj); |
202 | + .name = NULL, | 440 | + |
441 | + lan9118_phy_reset(s); | ||
442 | +} | ||
443 | + | ||
444 | +static void lan9118_phy_init(Object *obj) | ||
445 | +{ | ||
446 | + Lan9118PhyState *s = LAN9118_PHY(obj); | ||
447 | + | ||
448 | + qdev_init_gpio_out(DEVICE(s), &s->irq, 1); | ||
449 | +} | ||
450 | + | ||
451 | +static const VMStateDescription vmstate_lan9118_phy = { | ||
452 | + .name = "lan9118-phy", | ||
453 | + .version_id = 1, | ||
454 | + .minimum_version_id = 1, | ||
455 | + .fields = (const VMStateField[]) { | ||
456 | + VMSTATE_UINT16(control, Lan9118PhyState), | ||
457 | + VMSTATE_UINT16(status, Lan9118PhyState), | ||
458 | + VMSTATE_UINT16(advertise, Lan9118PhyState), | ||
459 | + VMSTATE_UINT16(ints, Lan9118PhyState), | ||
460 | + VMSTATE_UINT16(int_mask, Lan9118PhyState), | ||
461 | + VMSTATE_BOOL(link_down, Lan9118PhyState), | ||
462 | + VMSTATE_END_OF_LIST() | ||
203 | + } | 463 | + } |
204 | +}; | 464 | +}; |
205 | + | 465 | + |
206 | +static MemoryRegion *mr_for_raminfo(MPS3RMachineState *mms, | 466 | +static void lan9118_phy_class_init(ObjectClass *klass, void *data) |
207 | + const RAMInfo *raminfo) | 467 | +{ |
208 | +{ | 468 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
209 | + /* Return an initialized MemoryRegion for the RAMInfo. */ | 469 | + DeviceClass *dc = DEVICE_CLASS(klass); |
210 | + MemoryRegion *ram; | 470 | + |
211 | + | 471 | + rc->phases.hold = lan9118_phy_reset_hold; |
212 | + if (raminfo->mrindex < 0) { | 472 | + dc->vmsd = &vmstate_lan9118_phy; |
213 | + /* Means this RAMInfo is for QEMU's "system memory" */ | 473 | +} |
214 | + MachineState *machine = MACHINE(mms); | 474 | + |
215 | + assert(!(raminfo->flags & IS_ROM)); | 475 | +static const TypeInfo types[] = { |
216 | + return machine->ram; | 476 | + { |
477 | + .name = TYPE_LAN9118_PHY, | ||
478 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
479 | + .instance_size = sizeof(Lan9118PhyState), | ||
480 | + .instance_init = lan9118_phy_init, | ||
481 | + .class_init = lan9118_phy_class_init, | ||
217 | + } | 482 | + } |
218 | + | ||
219 | + assert(raminfo->mrindex < MPS3R_RAM_MAX); | ||
220 | + ram = &mms->ram[raminfo->mrindex]; | ||
221 | + | ||
222 | + memory_region_init_ram(ram, NULL, raminfo->name, | ||
223 | + raminfo->size, &error_fatal); | ||
224 | + if (raminfo->flags & IS_ROM) { | ||
225 | + memory_region_set_readonly(ram, true); | ||
226 | + } | ||
227 | + return ram; | ||
228 | +} | ||
229 | + | ||
230 | +static void mps3r_common_init(MachineState *machine) | ||
231 | +{ | ||
232 | + MPS3RMachineState *mms = MPS3R_MACHINE(machine); | ||
233 | + MPS3RMachineClass *mmc = MPS3R_MACHINE_GET_CLASS(mms); | ||
234 | + MemoryRegion *sysmem = get_system_memory(); | ||
235 | + | ||
236 | + for (const RAMInfo *ri = mmc->raminfo; ri->name; ri++) { | ||
237 | + MemoryRegion *mr = mr_for_raminfo(mms, ri); | ||
238 | + memory_region_add_subregion(sysmem, ri->base, mr); | ||
239 | + } | ||
240 | +} | ||
241 | + | ||
242 | +static void mps3r_set_default_ram_info(MPS3RMachineClass *mmc) | ||
243 | +{ | ||
244 | + /* | ||
245 | + * Set mc->default_ram_size and default_ram_id from the | ||
246 | + * information in mmc->raminfo. | ||
247 | + */ | ||
248 | + MachineClass *mc = MACHINE_CLASS(mmc); | ||
249 | + const RAMInfo *p; | ||
250 | + | ||
251 | + for (p = mmc->raminfo; p->name; p++) { | ||
252 | + if (p->mrindex < 0) { | ||
253 | + /* Found the entry for "system memory" */ | ||
254 | + mc->default_ram_size = p->size; | ||
255 | + mc->default_ram_id = p->name; | ||
256 | + return; | ||
257 | + } | ||
258 | + } | ||
259 | + g_assert_not_reached(); | ||
260 | +} | ||
261 | + | ||
262 | +static void mps3r_class_init(ObjectClass *oc, void *data) | ||
263 | +{ | ||
264 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
265 | + | ||
266 | + mc->init = mps3r_common_init; | ||
267 | +} | ||
268 | + | ||
269 | +static void mps3r_an536_class_init(ObjectClass *oc, void *data) | ||
270 | +{ | ||
271 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
272 | + MPS3RMachineClass *mmc = MPS3R_MACHINE_CLASS(oc); | ||
273 | + static const char * const valid_cpu_types[] = { | ||
274 | + ARM_CPU_TYPE_NAME("cortex-r52"), | ||
275 | + NULL | ||
276 | + }; | ||
277 | + | ||
278 | + mc->desc = "ARM MPS3 with AN536 FPGA image for Cortex-R52"; | ||
279 | + mc->default_cpus = 2; | ||
280 | + mc->min_cpus = mc->default_cpus; | ||
281 | + mc->max_cpus = mc->default_cpus; | ||
282 | + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-r52"); | ||
283 | + mc->valid_cpu_types = valid_cpu_types; | ||
284 | + mmc->raminfo = an536_raminfo; | ||
285 | + mps3r_set_default_ram_info(mmc); | ||
286 | +} | ||
287 | + | ||
288 | +static const TypeInfo mps3r_machine_types[] = { | ||
289 | + { | ||
290 | + .name = TYPE_MPS3R_MACHINE, | ||
291 | + .parent = TYPE_MACHINE, | ||
292 | + .abstract = true, | ||
293 | + .instance_size = sizeof(MPS3RMachineState), | ||
294 | + .class_size = sizeof(MPS3RMachineClass), | ||
295 | + .class_init = mps3r_class_init, | ||
296 | + }, { | ||
297 | + .name = TYPE_MPS3R_AN536_MACHINE, | ||
298 | + .parent = TYPE_MPS3R_MACHINE, | ||
299 | + .class_init = mps3r_an536_class_init, | ||
300 | + }, | ||
301 | +}; | 483 | +}; |
302 | + | 484 | + |
303 | +DEFINE_TYPES(mps3r_machine_types); | 485 | +DEFINE_TYPES(types) |
304 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | 486 | diff --git a/hw/net/Kconfig b/hw/net/Kconfig |
305 | index XXXXXXX..XXXXXXX 100644 | 487 | index XXXXXXX..XXXXXXX 100644 |
306 | --- a/hw/arm/Kconfig | 488 | --- a/hw/net/Kconfig |
307 | +++ b/hw/arm/Kconfig | 489 | +++ b/hw/net/Kconfig |
308 | @@ -XXX,XX +XXX,XX @@ config MAINSTONE | 490 | @@ -XXX,XX +XXX,XX @@ config VMXNET3_PCI |
309 | select PFLASH_CFI01 | 491 | config SMC91C111 |
310 | select SMC91C111 | 492 | bool |
311 | 493 | ||
312 | +config MPS3R | 494 | +config LAN9118_PHY |
313 | + bool | 495 | + bool |
314 | + default y | 496 | + |
315 | + depends on TCG && ARM | 497 | config LAN9118 |
316 | + | ||
317 | config MUSCA | ||
318 | bool | 498 | bool |
319 | default y | 499 | + select LAN9118_PHY |
320 | diff --git a/hw/arm/meson.build b/hw/arm/meson.build | 500 | select PTIMER |
501 | |||
502 | config NE2000_ISA | ||
503 | diff --git a/hw/net/meson.build b/hw/net/meson.build | ||
321 | index XXXXXXX..XXXXXXX 100644 | 504 | index XXXXXXX..XXXXXXX 100644 |
322 | --- a/hw/arm/meson.build | 505 | --- a/hw/net/meson.build |
323 | +++ b/hw/arm/meson.build | 506 | +++ b/hw/net/meson.build |
324 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_HIGHBANK', if_true: files('highbank.c')) | 507 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_VMXNET3_PCI', if_true: files('vmxnet3.c')) |
325 | arm_ss.add(when: 'CONFIG_INTEGRATOR', if_true: files('integratorcp.c')) | 508 | |
326 | arm_ss.add(when: 'CONFIG_MAINSTONE', if_true: files('mainstone.c')) | 509 | system_ss.add(when: 'CONFIG_SMC91C111', if_true: files('smc91c111.c')) |
327 | arm_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c')) | 510 | system_ss.add(when: 'CONFIG_LAN9118', if_true: files('lan9118.c')) |
328 | +arm_ss.add(when: 'CONFIG_MPS3R', if_true: files('mps3r.c')) | 511 | +system_ss.add(when: 'CONFIG_LAN9118_PHY', if_true: files('lan9118_phy.c')) |
329 | arm_ss.add(when: 'CONFIG_MUSICPAL', if_true: files('musicpal.c')) | 512 | system_ss.add(when: 'CONFIG_NE2000_ISA', if_true: files('ne2000-isa.c')) |
330 | arm_ss.add(when: 'CONFIG_NETDUINOPLUS2', if_true: files('netduinoplus2.c')) | 513 | system_ss.add(when: 'CONFIG_OPENCORES_ETH', if_true: files('opencores_eth.c')) |
331 | arm_ss.add(when: 'CONFIG_OLIMEX_STM32_H405', if_true: files('olimex-stm32-h405.c')) | 514 | system_ss.add(when: 'CONFIG_XGMAC', if_true: files('xgmac.c')) |
332 | -- | 515 | -- |
333 | 2.34.1 | 516 | 2.34.1 |
334 | |||
335 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Bernhard Beschow <shentey@gmail.com> | ||
1 | 2 | ||
3 | imx_fec models the same PHY as lan9118_phy. The code is almost the same with | ||
4 | imx_fec having more logging and tracing. Merge these improvements into | ||
5 | lan9118_phy and reuse in imx_fec to fix the code duplication. | ||
6 | |||
7 | Some migration state how resides in the new device model which breaks migration | ||
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> | ||
16 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | Message-id: 20241102125724.532843-3-shentey@gmail.com | ||
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
19 | --- | ||
20 | include/hw/net/imx_fec.h | 9 ++- | ||
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(-) | ||
26 | |||
27 | diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h | ||
28 | index XXXXXXX..XXXXXXX 100644 | ||
29 | --- a/include/hw/net/imx_fec.h | ||
30 | +++ b/include/hw/net/imx_fec.h | ||
31 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(IMXFECState, IMX_FEC) | ||
32 | #define TYPE_IMX_ENET "imx.enet" | ||
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 | }, | ||
80 | }; | ||
81 | |||
82 | -#define PHY_INT_ENERGYON (1 << 7) | ||
83 | -#define PHY_INT_AUTONEG_COMPLETE (1 << 6) | ||
84 | -#define PHY_INT_FAULT (1 << 5) | ||
85 | -#define PHY_INT_DOWN (1 << 4) | ||
86 | -#define PHY_INT_AUTONEG_LP (1 << 3) | ||
87 | -#define PHY_INT_PARFAULT (1 << 2) | ||
88 | -#define PHY_INT_AUTONEG_PAGE (1 << 1) | ||
89 | - | ||
90 | static void imx_eth_update(IMXFECState *s); | ||
91 | |||
92 | /* | ||
93 | @@ -XXX,XX +XXX,XX @@ static void imx_eth_update(IMXFECState *s); | ||
94 | * For now we don't handle any GPIO/interrupt line, so the OS will | ||
95 | * have to poll for the PHY status. | ||
96 | */ | ||
97 | -static void imx_phy_update_irq(IMXFECState *s) | ||
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; | ||
260 | + } | ||
261 | + qdev_connect_gpio_out(DEVICE(&s->mii), 0, &s->mii_irq); | ||
262 | + | ||
263 | qemu_macaddr_default_if_unset(&s->conf.macaddr); | ||
264 | |||
265 | s->nic = qemu_new_nic(&imx_eth_net_info, &s->conf, | ||
266 | diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c | ||
267 | index XXXXXXX..XXXXXXX 100644 | ||
268 | --- a/hw/net/lan9118_phy.c | ||
269 | +++ b/hw/net/lan9118_phy.c | ||
270 | @@ -XXX,XX +XXX,XX @@ | ||
271 | * Copyright (c) 2009 CodeSourcery, LLC. | ||
272 | * Written by Paul Brook | ||
273 | * | ||
274 | + * Copyright (c) 2013 Jean-Christophe Dubois. <jcd@tribudubois.net> | ||
275 | + * | ||
276 | * This code is licensed under the GNU GPL v2 | ||
277 | * | ||
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; | ||
345 | } | ||
346 | + | ||
347 | + trace_lan9118_phy_read(val, reg); | ||
348 | + | ||
349 | + return val; | ||
350 | } | ||
351 | |||
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" | ||
471 | -- | ||
472 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Bernhard Beschow <shentey@gmail.com> | ||
1 | 2 | ||
3 | Turns 0x70 into 0xe0 (== 0x70 << 1) which adds the missing MII_ANLPAR_TX and | ||
4 | fixes the MSB of selector field to be zero, as specified in the datasheet. | ||
5 | |||
6 | Fixes: 2a424990170b "LAN9118 emulation" | ||
7 | Signed-off-by: Bernhard Beschow <shentey@gmail.com> | ||
8 | Tested-by: Guenter Roeck <linux@roeck-us.net> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Message-id: 20241102125724.532843-4-shentey@gmail.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/net/lan9118_phy.c | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/net/lan9118_phy.c | ||
19 | +++ b/hw/net/lan9118_phy.c | ||
20 | @@ -XXX,XX +XXX,XX @@ uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg) | ||
21 | val = s->advertise; | ||
22 | break; | ||
23 | case 5: /* Auto-neg Link Partner Ability */ | ||
24 | - val = 0x0f71; | ||
25 | + val = 0x0fe1; | ||
26 | break; | ||
27 | case 6: /* Auto-neg Expansion */ | ||
28 | val = 1; | ||
29 | -- | ||
30 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Bernhard Beschow <shentey@gmail.com> | ||
1 | 2 | ||
3 | Prefer named constants over magic values for better readability. | ||
4 | |||
5 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
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 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/net/mii.h | 6 +++++ | ||
12 | hw/net/lan9118_phy.c | 63 ++++++++++++++++++++++++++++---------------- | ||
13 | 2 files changed, 46 insertions(+), 23 deletions(-) | ||
14 | |||
15 | diff --git a/include/hw/net/mii.h b/include/hw/net/mii.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/net/mii.h | ||
18 | +++ b/include/hw/net/mii.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #define MII_BMSR_JABBER (1 << 1) /* Jabber detected */ | ||
21 | #define MII_BMSR_EXTCAP (1 << 0) /* Ext-reg capability */ | ||
22 | |||
23 | +#define MII_ANAR_RFAULT (1 << 13) /* Say we can detect faults */ | ||
24 | #define MII_ANAR_PAUSE_ASYM (1 << 11) /* Try for asymmetric pause */ | ||
25 | #define MII_ANAR_PAUSE (1 << 10) /* Try for pause */ | ||
26 | #define MII_ANAR_TXFD (1 << 8) | ||
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 | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/net/lan9118_phy.c | ||
49 | +++ b/hw/net/lan9118_phy.c | ||
50 | @@ -XXX,XX +XXX,XX @@ | ||
51 | |||
52 | #include "qemu/osdep.h" | ||
53 | #include "hw/net/lan9118_phy.h" | ||
54 | +#include "hw/net/mii.h" | ||
55 | #include "hw/irq.h" | ||
56 | #include "hw/resettable.h" | ||
57 | #include "migration/vmstate.h" | ||
58 | @@ -XXX,XX +XXX,XX @@ uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg) | ||
59 | uint16_t val; | ||
60 | |||
61 | switch (reg) { | ||
62 | - case 0: /* Basic Control */ | ||
63 | + case MII_BMCR: | ||
64 | val = s->control; | ||
65 | break; | ||
66 | - case 1: /* Basic Status */ | ||
67 | + case MII_BMSR: | ||
68 | val = s->status; | ||
69 | break; | ||
70 | - case 2: /* ID1 */ | ||
71 | - val = 0x0007; | ||
72 | + case MII_PHYID1: | ||
73 | + val = SMSCLAN9118_PHYID1; | ||
74 | break; | ||
75 | - case 3: /* ID2 */ | ||
76 | - val = 0xc0d1; | ||
77 | + case MII_PHYID2: | ||
78 | + val = SMSCLAN9118_PHYID2; | ||
79 | break; | ||
80 | - case 4: /* Auto-neg advertisement */ | ||
81 | + case MII_ANAR: | ||
82 | val = s->advertise; | ||
83 | break; | ||
84 | - case 5: /* Auto-neg Link Partner Ability */ | ||
85 | - val = 0x0fe1; | ||
86 | + case MII_ANLPAR: | ||
87 | + val = MII_ANLPAR_PAUSEASY | MII_ANLPAR_PAUSE | MII_ANLPAR_T4 | | ||
88 | + MII_ANLPAR_TXFD | MII_ANLPAR_TX | MII_ANLPAR_10FD | | ||
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); | ||
166 | -- | ||
167 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Bernhard Beschow <shentey@gmail.com> | ||
1 | 2 | ||
3 | The real device advertises this mode and the device model already advertises | ||
4 | 100 mbps half duplex and 10 mbps full+half duplex. So advertise this mode to | ||
5 | make the model more realistic. | ||
6 | |||
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 | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | hw/net/lan9118_phy.c | 4 ++-- | ||
14 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/net/lan9118_phy.c | ||
19 | +++ b/hw/net/lan9118_phy.c | ||
20 | @@ -XXX,XX +XXX,XX @@ void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val) | ||
21 | break; | ||
22 | case MII_ANAR: | ||
23 | s->advertise = (val & (MII_ANAR_RFAULT | MII_ANAR_PAUSE_ASYM | | ||
24 | - MII_ANAR_PAUSE | MII_ANAR_10FD | MII_ANAR_10 | | ||
25 | - MII_ANAR_SELECT)) | ||
26 | + MII_ANAR_PAUSE | MII_ANAR_TXFD | MII_ANAR_10FD | | ||
27 | + MII_ANAR_10 | MII_ANAR_SELECT)) | ||
28 | | MII_ANAR_TX; | ||
29 | break; | ||
30 | case 30: /* Interrupt mask */ | ||
31 | -- | ||
32 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 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 | The TBI and TCMA bits are located within mtedesc, not desc. | 7 | For the cases where the infzero test in pickNaNMulAdd was |
8 | returning 2, we can delete the check entirely and allow the | ||
9 | code to fall into the normal pick-a-NaN handling, because this | ||
10 | will return 2 anyway (input 'c' being the only NaN in this case). | ||
11 | For the cases where infzero was returning 3 to indicate "return | ||
12 | the default NaN", we must retain that "return 3". | ||
4 | 13 | ||
5 | Cc: qemu-stable@nongnu.org | 14 | For Arm, this looks like it might be a behaviour change because we |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 15 | used to set float_flag_invalid | float_flag_invalid_imz only if C is |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 16 | a quiet NaN. However, it is not, because Arm target code never looks |
8 | Tested-by: Gustavo Romero <gustavo.romero@linaro.org> | 17 | at float_flag_invalid_imz, and for the (0 * inf) + SNaN case we |
9 | Message-id: 20240207025210.8837-7-richard.henderson@linaro.org | 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 | |||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 34 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
35 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
36 | Message-id: 20241202131347.498124-2-peter.maydell@linaro.org | ||
11 | --- | 37 | --- |
12 | target/arm/tcg/sme_helper.c | 8 ++++---- | 38 | fpu/softfloat-parts.c.inc | 13 +++++++------ |
13 | target/arm/tcg/sve_helper.c | 12 ++++++------ | 39 | fpu/softfloat-specialize.c.inc | 29 +---------------------------- |
14 | 2 files changed, 10 insertions(+), 10 deletions(-) | 40 | 2 files changed, 8 insertions(+), 34 deletions(-) |
15 | 41 | ||
16 | diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c | 42 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
17 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/tcg/sme_helper.c | 44 | --- a/fpu/softfloat-parts.c.inc |
19 | +++ b/target/arm/tcg/sme_helper.c | 45 | +++ b/fpu/softfloat-parts.c.inc |
20 | @@ -XXX,XX +XXX,XX @@ void sme_ld1_mte(CPUARMState *env, void *za, uint64_t *vg, | 46 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
21 | desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); | 47 | int ab_mask, int abc_mask) |
22 | 48 | { | |
23 | /* Perform gross MTE suppression early. */ | 49 | int which; |
24 | - if (!tbi_check(desc, bit55) || | 50 | + bool infzero = (ab_mask == float_cmask_infzero); |
25 | - tcma_check(desc, bit55, allocation_tag_from_addr(addr))) { | 51 | |
26 | + if (!tbi_check(mtedesc, bit55) || | 52 | if (unlikely(abc_mask & float_cmask_snan)) { |
27 | + tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) { | 53 | float_raise(float_flag_invalid | float_flag_invalid_snan, s); |
28 | mtedesc = 0; | ||
29 | } | 54 | } |
30 | 55 | ||
31 | @@ -XXX,XX +XXX,XX @@ void sme_st1_mte(CPUARMState *env, void *za, uint64_t *vg, target_ulong addr, | 56 | - which = pickNaNMulAdd(a->cls, b->cls, c->cls, |
32 | desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); | 57 | - ab_mask == float_cmask_infzero, s); |
33 | 58 | + if (infzero) { | |
34 | /* Perform gross MTE suppression early. */ | 59 | + /* This is (0 * inf) + NaN or (inf * 0) + NaN */ |
35 | - if (!tbi_check(desc, bit55) || | 60 | + float_raise(float_flag_invalid | float_flag_invalid_imz, s); |
36 | - tcma_check(desc, bit55, allocation_tag_from_addr(addr))) { | 61 | + } |
37 | + if (!tbi_check(mtedesc, bit55) || | 62 | + |
38 | + tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) { | 63 | + which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s); |
39 | mtedesc = 0; | 64 | |
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; | ||
40 | } | 72 | } |
41 | 73 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | |
42 | diff --git a/target/arm/tcg/sve_helper.c b/target/arm/tcg/sve_helper.c | ||
43 | index XXXXXXX..XXXXXXX 100644 | 74 | index XXXXXXX..XXXXXXX 100644 |
44 | --- a/target/arm/tcg/sve_helper.c | 75 | --- a/fpu/softfloat-specialize.c.inc |
45 | +++ b/target/arm/tcg/sve_helper.c | 76 | +++ b/fpu/softfloat-specialize.c.inc |
46 | @@ -XXX,XX +XXX,XX @@ void sve_ldN_r_mte(CPUARMState *env, uint64_t *vg, target_ulong addr, | 77 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
47 | desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); | 78 | * the default NaN |
48 | 79 | */ | |
49 | /* Perform gross MTE suppression early. */ | 80 | if (infzero && is_qnan(c_cls)) { |
50 | - if (!tbi_check(desc, bit55) || | 81 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); |
51 | - tcma_check(desc, bit55, allocation_tag_from_addr(addr))) { | 82 | return 3; |
52 | + if (!tbi_check(mtedesc, bit55) || | ||
53 | + tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) { | ||
54 | mtedesc = 0; | ||
55 | } | 83 | } |
56 | 84 | ||
57 | @@ -XXX,XX +XXX,XX @@ void sve_ldnfff1_r_mte(CPUARMState *env, void *vg, target_ulong addr, | 85 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
58 | desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); | 86 | * case sets InvalidOp and returns the default NaN |
59 | 87 | */ | |
60 | /* Perform gross MTE suppression early. */ | 88 | if (infzero) { |
61 | - if (!tbi_check(desc, bit55) || | 89 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); |
62 | - tcma_check(desc, bit55, allocation_tag_from_addr(addr))) { | 90 | return 3; |
63 | + if (!tbi_check(mtedesc, bit55) || | 91 | } |
64 | + tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) { | 92 | /* Prefer sNaN over qNaN, in the a, b, c order. */ |
65 | mtedesc = 0; | 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 | - } | ||
112 | + | ||
113 | /* Prefer sNaN over qNaN, in the c, a, b order. */ | ||
114 | if (is_snan(c_cls)) { | ||
115 | return 2; | ||
116 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
117 | * to return an input NaN if we have one (ie c) rather than generating | ||
118 | * a default NaN | ||
119 | */ | ||
120 | - if (infzero) { | ||
121 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); | ||
122 | - return 2; | ||
123 | - } | ||
124 | |||
125 | /* If fRA is a NaN return it; otherwise if fRB is a NaN return it; | ||
126 | * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB | ||
127 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
128 | return 1; | ||
66 | } | 129 | } |
67 | 130 | #elif defined(TARGET_RISCV) | |
68 | @@ -XXX,XX +XXX,XX @@ void sve_stN_r_mte(CPUARMState *env, uint64_t *vg, target_ulong addr, | 131 | - /* For RISC-V, InvalidOp is set when multiplicands are Inf and zero */ |
69 | desc = extract32(desc, 0, SIMD_DATA_SHIFT + SVE_MTEDESC_SHIFT); | 132 | - if (infzero) { |
70 | 133 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); | |
71 | /* Perform gross MTE suppression early. */ | 134 | - } |
72 | - if (!tbi_check(desc, bit55) || | 135 | return 3; /* default NaN */ |
73 | - tcma_check(desc, bit55, allocation_tag_from_addr(addr))) { | 136 | #elif defined(TARGET_S390X) |
74 | + if (!tbi_check(mtedesc, bit55) || | 137 | if (infzero) { |
75 | + tcma_check(mtedesc, bit55, allocation_tag_from_addr(addr))) { | 138 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); |
76 | mtedesc = 0; | 139 | return 3; |
77 | } | 140 | } |
78 | 141 | ||
142 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
143 | return 2; | ||
144 | } | ||
145 | #elif defined(TARGET_SPARC) | ||
146 | - /* For (inf,0,nan) return c. */ | ||
147 | - if (infzero) { | ||
148 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); | ||
149 | - return 2; | ||
150 | - } | ||
151 | /* Prefer SNaN over QNaN, order C, B, A. */ | ||
152 | if (is_snan(c_cls)) { | ||
153 | return 2; | ||
154 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
155 | * For Xtensa, the (inf,zero,nan) case sets InvalidOp and returns | ||
156 | * an input NaN if we have one (ie c). | ||
157 | */ | ||
158 | - if (infzero) { | ||
159 | - float_raise(float_flag_invalid | float_flag_invalid_imz, status); | ||
160 | - return 2; | ||
161 | - } | ||
162 | if (status->use_first_nan) { | ||
163 | if (is_nan(a_cls)) { | ||
164 | return 0; | ||
79 | -- | 165 | -- |
80 | 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 | The MPS SCC device has a lot of different flavours for the various | 1 | IEEE 758 does not define a fixed rule for what NaN to return in |
---|---|---|---|
2 | different MPS FPGA images, which look mostly similar but have | 2 | the case of a fused multiply-add of inf * 0 + NaN. Different |
3 | differences in how particular registers are handled. Currently we | 3 | architectures thus do different things: |
4 | deal with this with a lot of open-coded checks on scc_partno(), but | 4 | * some return the default NaN |
5 | as we add more board types this is getting a bit hard to read. | 5 | * some return the input NaN |
6 | 6 | * Arm returns the default NaN if the input NaN is quiet, | |
7 | Factor out the conditions into some functions which we can | 7 | and the input NaN if it is signalling |
8 | give more descriptive names to. | 8 | |
9 | We want to make this logic be runtime selected rather than | ||
10 | hardcoded into the binary, because: | ||
11 | * this will let us have multiple targets in one QEMU binary | ||
12 | * the Arm FEAT_AFP architectural feature includes letting | ||
13 | the guest select a NaN propagation rule at runtime | ||
14 | |||
15 | In this commit we add an enum for the propagation rule, the field in | ||
16 | float_status, and the corresponding getters and setters. We change | ||
17 | pickNaNMulAdd to honour this, but because all targets still leave | ||
18 | this field at its default 0 value, the fallback logic will pick the | ||
19 | rule type with the old ifdef ladder. | ||
20 | |||
21 | Note that four architectures both use the muladd softfloat functions | ||
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. | ||
9 | 29 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 30 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 31 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Message-id: 20240206132931.38376-7-peter.maydell@linaro.org | 32 | Message-id: 20241202131347.498124-4-peter.maydell@linaro.org |
14 | --- | 33 | --- |
15 | hw/misc/mps2-scc.c | 45 +++++++++++++++++++++++++++++++-------------- | 34 | include/fpu/softfloat-helpers.h | 11 ++++ |
16 | 1 file changed, 31 insertions(+), 14 deletions(-) | 35 | include/fpu/softfloat-types.h | 23 +++++++++ |
17 | 36 | fpu/softfloat-specialize.c.inc | 91 ++++++++++++++++++++++----------- | |
18 | diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c | 37 | 3 files changed, 95 insertions(+), 30 deletions(-) |
38 | |||
39 | diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | 40 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/misc/mps2-scc.c | 41 | --- a/include/fpu/softfloat-helpers.h |
21 | +++ b/hw/misc/mps2-scc.c | 42 | +++ b/include/fpu/softfloat-helpers.h |
22 | @@ -XXX,XX +XXX,XX @@ static int scc_partno(MPS2SCC *s) | 43 | @@ -XXX,XX +XXX,XX @@ static inline void set_float_2nan_prop_rule(Float2NaNPropRule rule, |
23 | return extract32(s->id, 4, 8); | 44 | status->float_2nan_prop_rule = rule; |
24 | } | 45 | } |
25 | 46 | ||
26 | +/* Is CFG_REG2 present? */ | 47 | +static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule, |
27 | +static bool have_cfg2(MPS2SCC *s) | 48 | + float_status *status) |
28 | +{ | 49 | +{ |
29 | + return scc_partno(s) == 0x524 || scc_partno(s) == 0x547; | 50 | + status->float_infzeronan_rule = rule; |
30 | +} | 51 | +} |
31 | + | 52 | + |
32 | +/* Is CFG_REG3 present? */ | 53 | static inline void set_flush_to_zero(bool val, float_status *status) |
33 | +static bool have_cfg3(MPS2SCC *s) | 54 | { |
55 | status->flush_to_zero = val; | ||
56 | @@ -XXX,XX +XXX,XX @@ static inline Float2NaNPropRule get_float_2nan_prop_rule(float_status *status) | ||
57 | return status->float_2nan_prop_rule; | ||
58 | } | ||
59 | |||
60 | +static inline FloatInfZeroNaNRule get_float_infzeronan_rule(float_status *status) | ||
34 | +{ | 61 | +{ |
35 | + return scc_partno(s) != 0x524 && scc_partno(s) != 0x547; | 62 | + return status->float_infzeronan_rule; |
36 | +} | 63 | +} |
37 | + | 64 | + |
38 | +/* Is CFG_REG5 present? */ | 65 | static inline bool get_flush_to_zero(float_status *status) |
39 | +static bool have_cfg5(MPS2SCC *s) | 66 | { |
40 | +{ | 67 | return status->flush_to_zero; |
41 | + return scc_partno(s) == 0x524 || scc_partno(s) == 0x547; | 68 | diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h |
42 | +} | 69 | index XXXXXXX..XXXXXXX 100644 |
43 | + | 70 | --- a/include/fpu/softfloat-types.h |
44 | +/* Is CFG_REG6 present? */ | 71 | +++ b/include/fpu/softfloat-types.h |
45 | +static bool have_cfg6(MPS2SCC *s) | 72 | @@ -XXX,XX +XXX,XX @@ typedef enum __attribute__((__packed__)) { |
46 | +{ | 73 | float_2nan_prop_x87, |
47 | + return scc_partno(s) == 0x524; | 74 | } Float2NaNPropRule; |
48 | +} | 75 | |
49 | + | 76 | +/* |
50 | /* Handle a write via the SYS_CFG channel to the specified function/device. | 77 | + * Rule for result of fused multiply-add 0 * Inf + NaN. |
51 | * Return false on error (reported to guest via SYS_CFGCTRL ERROR bit). | 78 | + * This must be a NaN, but implementations differ on whether this |
52 | */ | 79 | + * is the input NaN or the default NaN. |
53 | @@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size) | 80 | + * |
54 | r = s->cfg1; | 81 | + * You don't need to set this if default_nan_mode is enabled. |
55 | break; | 82 | + * When not in default-NaN mode, it is an error for the target |
56 | case A_CFG2: | 83 | + * not to set the rule in float_status if it uses muladd, and we |
57 | - if (scc_partno(s) != 0x524 && scc_partno(s) != 0x547) { | 84 | + * will assert if we need to handle an input NaN and no rule was |
58 | - /* CFG2 reserved on other boards */ | 85 | + * selected. |
59 | + if (!have_cfg2(s)) { | 86 | + */ |
60 | goto bad_offset; | 87 | +typedef enum __attribute__((__packed__)) { |
88 | + /* No propagation rule specified */ | ||
89 | + float_infzeronan_none = 0, | ||
90 | + /* Result is never the default NaN (so always the input NaN) */ | ||
91 | + float_infzeronan_dnan_never, | ||
92 | + /* Result is always the default NaN */ | ||
93 | + float_infzeronan_dnan_always, | ||
94 | + /* Result is the default NaN if the input NaN is quiet */ | ||
95 | + float_infzeronan_dnan_if_qnan, | ||
96 | +} FloatInfZeroNaNRule; | ||
97 | + | ||
98 | /* | ||
99 | * Floating Point Status. Individual architectures may maintain | ||
100 | * several versions of float_status for different functions. The | ||
101 | @@ -XXX,XX +XXX,XX @@ typedef struct float_status { | ||
102 | FloatRoundMode float_rounding_mode; | ||
103 | FloatX80RoundPrec floatx80_rounding_precision; | ||
104 | Float2NaNPropRule float_2nan_prop_rule; | ||
105 | + FloatInfZeroNaNRule float_infzeronan_rule; | ||
106 | bool tininess_before_rounding; | ||
107 | /* should denormalised results go to zero and set the inexact flag? */ | ||
108 | bool flush_to_zero; | ||
109 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
110 | index XXXXXXX..XXXXXXX 100644 | ||
111 | --- a/fpu/softfloat-specialize.c.inc | ||
112 | +++ b/fpu/softfloat-specialize.c.inc | ||
113 | @@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, | ||
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; | ||
61 | } | 212 | } |
62 | r = s->cfg2; | 213 | } else { |
63 | break; | 214 | - /* |
64 | case A_CFG3: | 215 | - * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan) |
65 | - if (scc_partno(s) == 0x524 || scc_partno(s) == 0x547) { | 216 | - * case sets InvalidOp and returns the input value 'c' |
66 | - /* CFG3 reserved on AN524 */ | 217 | - */ |
67 | + if (!have_cfg3(s)) { | 218 | /* Prefer sNaN over qNaN, in the c, a, b order. */ |
68 | goto bad_offset; | 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, | ||
69 | } | 222 | } |
70 | /* These are user-settable DIP switches on the board. We don't | 223 | } |
71 | @@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size) | 224 | #elif defined(TARGET_LOONGARCH64) |
72 | r = s->cfg4; | 225 | - /* |
73 | break; | 226 | - * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan) |
74 | case A_CFG5: | 227 | - * case sets InvalidOp and returns the input value 'c' |
75 | - if (scc_partno(s) != 0x524 && scc_partno(s) != 0x547) { | 228 | - */ |
76 | - /* CFG5 reserved on other boards */ | 229 | - |
77 | + if (!have_cfg5(s)) { | 230 | /* Prefer sNaN over qNaN, in the c, a, b order. */ |
78 | goto bad_offset; | 231 | if (is_snan(c_cls)) { |
79 | } | 232 | return 2; |
80 | r = s->cfg5; | 233 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
81 | break; | 234 | return 1; |
82 | case A_CFG6: | 235 | } |
83 | - if (scc_partno(s) != 0x524) { | 236 | #elif defined(TARGET_PPC) |
84 | - /* CFG6 reserved on other boards */ | 237 | - /* For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer |
85 | + if (!have_cfg6(s)) { | 238 | - * to return an input NaN if we have one (ie c) rather than generating |
86 | goto bad_offset; | 239 | - * a default NaN |
87 | } | 240 | - */ |
88 | r = s->cfg6; | 241 | - |
89 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value, | 242 | /* If fRA is a NaN return it; otherwise if fRB is a NaN return it; |
90 | } | 243 | * otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB |
91 | break; | 244 | */ |
92 | case A_CFG2: | 245 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
93 | - if (scc_partno(s) != 0x524 && scc_partno(s) != 0x547) { | 246 | return 1; |
94 | - /* CFG2 reserved on other boards */ | 247 | } |
95 | + if (!have_cfg2(s)) { | 248 | #elif defined(TARGET_S390X) |
96 | goto bad_offset; | 249 | - if (infzero) { |
97 | } | 250 | - return 3; |
98 | /* AN524: QSPI Select signal */ | 251 | - } |
99 | s->cfg2 = value; | 252 | - |
100 | break; | 253 | if (is_snan(a_cls)) { |
101 | case A_CFG5: | 254 | return 0; |
102 | - if (scc_partno(s) != 0x524 && scc_partno(s) != 0x547) { | 255 | } else if (is_snan(b_cls)) { |
103 | - /* CFG5 reserved on other boards */ | ||
104 | + if (!have_cfg5(s)) { | ||
105 | goto bad_offset; | ||
106 | } | ||
107 | /* AN524: ACLK frequency in Hz */ | ||
108 | s->cfg5 = value; | ||
109 | break; | ||
110 | case A_CFG6: | ||
111 | - if (scc_partno(s) != 0x524) { | ||
112 | - /* CFG6 reserved on other boards */ | ||
113 | + if (!have_cfg6(s)) { | ||
114 | goto bad_offset; | ||
115 | } | ||
116 | /* AN524: Clock divider for BRAM */ | ||
117 | -- | 256 | -- |
118 | 2.34.1 | 257 | 2.34.1 |
119 | |||
120 | 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 | Add the remaining devices (or unimplemented-device stubs) for | 1 | IEEE 758 does not define a fixed rule for which NaN to pick as the |
---|---|---|---|
2 | this board: SPI controllers, SCC, FPGAIO, I2S, RTC, the | 2 | result if both operands of a 3-operand fused multiply-add operation |
3 | QSPI write-config block, and ethernet. | 3 | are NaNs. As a result different architectures have ended up with |
4 | different rules for propagating NaNs. | ||
5 | |||
6 | QEMU currently hardcodes the NaN propagation logic into the binary | ||
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. | ||
4 | 23 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 24 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 25 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20240206132931.38376-13-peter.maydell@linaro.org | 26 | Message-id: 20241202131347.498124-16-peter.maydell@linaro.org |
8 | --- | 27 | --- |
9 | hw/arm/mps3r.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ | 28 | include/fpu/softfloat-helpers.h | 11 +++ |
10 | 1 file changed, 74 insertions(+) | 29 | include/fpu/softfloat-types.h | 55 +++++++++++ |
11 | 30 | fpu/softfloat-specialize.c.inc | 167 ++++++++------------------------ | |
12 | diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c | 31 | 3 files changed, 107 insertions(+), 126 deletions(-) |
32 | |||
33 | diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/arm/mps3r.c | 35 | --- a/include/fpu/softfloat-helpers.h |
15 | +++ b/hw/arm/mps3r.c | 36 | +++ b/include/fpu/softfloat-helpers.h |
16 | @@ -XXX,XX +XXX,XX @@ | 37 | @@ -XXX,XX +XXX,XX @@ static inline void set_float_2nan_prop_rule(Float2NaNPropRule rule, |
17 | #include "hw/char/cmsdk-apb-uart.h" | 38 | status->float_2nan_prop_rule = rule; |
18 | #include "hw/i2c/arm_sbcon_i2c.h" | 39 | } |
19 | #include "hw/intc/arm_gicv3.h" | 40 | |
20 | +#include "hw/misc/mps2-scc.h" | 41 | +static inline void set_float_3nan_prop_rule(Float3NaNPropRule rule, |
21 | +#include "hw/misc/mps2-fpgaio.h" | 42 | + float_status *status) |
22 | #include "hw/misc/unimp.h" | 43 | +{ |
23 | +#include "hw/net/lan9118.h" | 44 | + status->float_3nan_prop_rule = rule; |
24 | +#include "hw/rtc/pl031.h" | 45 | +} |
25 | +#include "hw/ssi/pl022.h" | 46 | + |
26 | #include "hw/timer/cmsdk-apb-dualtimer.h" | 47 | static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule, |
27 | #include "hw/watchdog/cmsdk-apb-watchdog.h" | 48 | float_status *status) |
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ struct MPS3RMachineState { | ||
30 | CMSDKAPBWatchdog watchdog; | ||
31 | CMSDKAPBDualTimer dualtimer; | ||
32 | ArmSbconI2CState i2c[5]; | ||
33 | + PL022State spi[3]; | ||
34 | + MPS2SCC scc; | ||
35 | + MPS2FPGAIO fpgaio; | ||
36 | + UnimplementedDeviceState i2s_audio; | ||
37 | + PL031State rtc; | ||
38 | Clock *clk; | ||
39 | }; | ||
40 | |||
41 | @@ -XXX,XX +XXX,XX @@ static const RAMInfo an536_raminfo[] = { | ||
42 | } | ||
43 | }; | ||
44 | |||
45 | +static const int an536_oscclk[] = { | ||
46 | + 24000000, /* 24MHz reference for RTC and timers */ | ||
47 | + 50000000, /* 50MHz ACLK */ | ||
48 | + 50000000, /* 50MHz MCLK */ | ||
49 | + 50000000, /* 50MHz GPUCLK */ | ||
50 | + 24576000, /* 24.576MHz AUDCLK */ | ||
51 | + 23750000, /* 23.75MHz HDLCDCLK */ | ||
52 | + 100000000, /* 100MHz DDR4_REF_CLK */ | ||
53 | +}; | ||
54 | + | ||
55 | static MemoryRegion *mr_for_raminfo(MPS3RMachineState *mms, | ||
56 | const RAMInfo *raminfo) | ||
57 | { | 49 | { |
58 | @@ -XXX,XX +XXX,XX @@ static void mps3r_common_init(MachineState *machine) | 50 | @@ -XXX,XX +XXX,XX @@ static inline Float2NaNPropRule get_float_2nan_prop_rule(float_status *status) |
59 | MPS3RMachineClass *mmc = MPS3R_MACHINE_GET_CLASS(mms); | 51 | return status->float_2nan_prop_rule; |
60 | MemoryRegion *sysmem = get_system_memory(); | 52 | } |
61 | DeviceState *gicdev; | 53 | |
62 | + QList *oscclk; | 54 | +static inline Float3NaNPropRule get_float_3nan_prop_rule(float_status *status) |
63 | 55 | +{ | |
64 | mms->clk = clock_new(OBJECT(machine), "CLK"); | 56 | + return status->float_3nan_prop_rule; |
65 | clock_set_hz(mms->clk, CLK_FRQ); | 57 | +} |
66 | @@ -XXX,XX +XXX,XX @@ static void mps3r_common_init(MachineState *machine) | 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 | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/include/fpu/softfloat-types.h | ||
65 | +++ b/include/fpu/softfloat-types.h | ||
66 | @@ -XXX,XX +XXX,XX @@ this code that are retained. | ||
67 | #ifndef SOFTFLOAT_TYPES_H | ||
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) | ||
149 | { | ||
150 | + FloatClass cls[3] = { a_cls, b_cls, c_cls }; | ||
151 | + Float3NaNPropRule rule = status->float_3nan_prop_rule; | ||
152 | + int which; | ||
153 | + | ||
154 | /* | ||
155 | * We guarantee not to require the target to tell us how to | ||
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, | ||
67 | } | 158 | } |
68 | } | 159 | } |
69 | 160 | ||
70 | + for (int i = 0; i < ARRAY_SIZE(mms->spi); i++) { | 161 | + if (rule == float_3nan_prop_none) { |
71 | + g_autofree char *s = g_strdup_printf("spi%d", i); | 162 | #if defined(TARGET_ARM) |
72 | + hwaddr baseaddr = 0xe0104000 + i * 0x1000; | 163 | - |
73 | + | 164 | - /* This looks different from the ARM ARM pseudocode, because the ARM ARM |
74 | + object_initialize_child(OBJECT(mms), s, &mms->spi[i], TYPE_PL022); | 165 | - * puts the operands to a fused mac operation (a*b)+c in the order c,a,b. |
75 | + sysbus_realize(SYS_BUS_DEVICE(&mms->spi[i]), &error_fatal); | 166 | - */ |
76 | + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->spi[i]), 0, baseaddr); | 167 | - if (is_snan(c_cls)) { |
77 | + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->spi[i]), 0, | 168 | - return 2; |
78 | + qdev_get_gpio_in(gicdev, 22 + i)); | 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 | ||
79 | + } | 321 | + } |
80 | + | 322 | + |
81 | + object_initialize_child(OBJECT(mms), "scc", &mms->scc, TYPE_MPS2_SCC); | 323 | + assert(rule != float_3nan_prop_none); |
82 | + qdev_prop_set_uint32(DEVICE(&mms->scc), "scc-cfg0", 0); | 324 | + if (have_snan && (rule & R_3NAN_SNAN_MASK)) { |
83 | + qdev_prop_set_uint32(DEVICE(&mms->scc), "scc-cfg4", 0x2); | 325 | + /* We have at least one SNaN input and should prefer it */ |
84 | + qdev_prop_set_uint32(DEVICE(&mms->scc), "scc-aid", 0x00200008); | 326 | + do { |
85 | + qdev_prop_set_uint32(DEVICE(&mms->scc), "scc-id", 0x41055360); | 327 | + which = rule & R_3NAN_1ST_MASK; |
86 | + oscclk = qlist_new(); | 328 | + rule >>= R_3NAN_1ST_LENGTH; |
87 | + for (int i = 0; i < ARRAY_SIZE(an536_oscclk); i++) { | 329 | + } while (!is_snan(cls[which])); |
88 | + qlist_append_int(oscclk, an536_oscclk[i]); | 330 | + } else { |
331 | + do { | ||
332 | + which = rule & R_3NAN_1ST_MASK; | ||
333 | + rule >>= R_3NAN_1ST_LENGTH; | ||
334 | + } while (!is_nan(cls[which])); | ||
89 | + } | 335 | + } |
90 | + qdev_prop_set_array(DEVICE(&mms->scc), "oscclk", oscclk); | 336 | + return which; |
91 | + sysbus_realize(SYS_BUS_DEVICE(&mms->scc), &error_fatal); | 337 | } |
92 | + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->scc), 0, 0xe0200000); | 338 | |
93 | + | 339 | /*---------------------------------------------------------------------------- |
94 | + create_unimplemented_device("i2s-audio", 0xe0201000, 0x1000); | ||
95 | + | ||
96 | + object_initialize_child(OBJECT(mms), "fpgaio", &mms->fpgaio, | ||
97 | + TYPE_MPS2_FPGAIO); | ||
98 | + qdev_prop_set_uint32(DEVICE(&mms->fpgaio), "prescale-clk", an536_oscclk[1]); | ||
99 | + qdev_prop_set_uint32(DEVICE(&mms->fpgaio), "num-leds", 10); | ||
100 | + qdev_prop_set_bit(DEVICE(&mms->fpgaio), "has-switches", true); | ||
101 | + qdev_prop_set_bit(DEVICE(&mms->fpgaio), "has-dbgctrl", false); | ||
102 | + sysbus_realize(SYS_BUS_DEVICE(&mms->fpgaio), &error_fatal); | ||
103 | + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->fpgaio), 0, 0xe0202000); | ||
104 | + | ||
105 | + create_unimplemented_device("clcd", 0xe0209000, 0x1000); | ||
106 | + | ||
107 | + object_initialize_child(OBJECT(mms), "rtc", &mms->rtc, TYPE_PL031); | ||
108 | + sysbus_realize(SYS_BUS_DEVICE(&mms->rtc), &error_fatal); | ||
109 | + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->rtc), 0, 0xe020a000); | ||
110 | + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->rtc), 0, | ||
111 | + qdev_get_gpio_in(gicdev, 4)); | ||
112 | + | ||
113 | + /* | ||
114 | + * In hardware this is a LAN9220; the LAN9118 is software compatible | ||
115 | + * except that it doesn't support the checksum-offload feature. | ||
116 | + */ | ||
117 | + lan9118_init(0xe0300000, | ||
118 | + qdev_get_gpio_in(gicdev, 18)); | ||
119 | + | ||
120 | + create_unimplemented_device("usb", 0xe0301000, 0x1000); | ||
121 | + create_unimplemented_device("qspi-write-config", 0xe0600000, 0x1000); | ||
122 | + | ||
123 | mms->bootinfo.ram_size = machine->ram_size; | ||
124 | mms->bootinfo.board_id = -1; | ||
125 | mms->bootinfo.loader_start = mmc->loader_start; | ||
126 | -- | 340 | -- |
127 | 2.34.1 | 341 | 2.34.1 |
128 | |||
129 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
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. | ||
1 | 4 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20241202131347.498124-17-peter.maydell@linaro.org | ||
8 | --- | ||
9 | tests/fp/fp-bench.c | 1 + | ||
10 | tests/fp/fp-test.c | 1 + | ||
11 | 2 files changed, 2 insertions(+) | ||
12 | |||
13 | diff --git a/tests/fp/fp-bench.c b/tests/fp/fp-bench.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/tests/fp/fp-bench.c | ||
16 | +++ b/tests/fp/fp-bench.c | ||
17 | @@ -XXX,XX +XXX,XX @@ static void run_bench(void) | ||
18 | * doesn't specify match those used by the Arm architecture. | ||
19 | */ | ||
20 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &soft_status); | ||
21 | + set_float_3nan_prop_rule(float_3nan_prop_s_cab, &soft_status); | ||
22 | set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &soft_status); | ||
23 | |||
24 | f = bench_funcs[operation][precision]; | ||
25 | diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | ||
27 | --- a/tests/fp/fp-test.c | ||
28 | +++ b/tests/fp/fp-test.c | ||
29 | @@ -XXX,XX +XXX,XX @@ void run_test(void) | ||
30 | * doesn't specify match those used by the Arm architecture. | ||
31 | */ | ||
32 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf); | ||
33 | + set_float_3nan_prop_rule(float_3nan_prop_s_cab, &qsf); | ||
34 | set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &qsf); | ||
35 | |||
36 | genCases_setLevel(test_level); | ||
37 | -- | ||
38 | 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-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(-) | ||
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 | + * * 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); | ||
33 | } | ||
34 | |||
35 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/fpu/softfloat-specialize.c.inc | ||
38 | +++ b/fpu/softfloat-specialize.c.inc | ||
39 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, | ||
40 | } | ||
41 | |||
42 | if (rule == float_3nan_prop_none) { | ||
43 | -#if defined(TARGET_ARM) | ||
44 | - /* | ||
45 | - * This looks different from the ARM ARM pseudocode, because the ARM ARM | ||
46 | - * puts the operands to a fused mac operation (a*b)+c in the order c,a,b | ||
47 | - */ | ||
48 | - rule = float_3nan_prop_s_cab; | ||
49 | -#elif defined(TARGET_MIPS) | ||
50 | +#if defined(TARGET_MIPS) | ||
51 | if (snan_bit_is_one(status)) { | ||
52 | rule = float_3nan_prop_s_abc; | ||
53 | } else { | ||
54 | -- | ||
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 |
1 | The Cortex-R52 implements the Configuration Base Address Register | 1 | Set the Float3NaNPropRule explicitly for i386. We had no |
---|---|---|---|
2 | (CBAR), as a read-only register. Add ARM_FEATURE_CBAR_RO to this CPU | 2 | i386-specific behaviour in the old ifdef ladder, so we were using the |
3 | type, so that our implementation provides the register and the | 3 | default "prefer a then b then c" fallback; this is actually the |
4 | associated qdev property. | 4 | correct per-the-spec handling for i386. |
5 | 5 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20240206132931.38376-3-peter.maydell@linaro.org | 8 | Message-id: 20241202131347.498124-25-peter.maydell@linaro.org |
9 | --- | 9 | --- |
10 | target/arm/tcg/cpu32.c | 1 + | 10 | target/i386/tcg/fpu_helper.c | 1 + |
11 | 1 file changed, 1 insertion(+) | 11 | 1 file changed, 1 insertion(+) |
12 | 12 | ||
13 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c | 13 | diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c |
14 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/tcg/cpu32.c | 15 | --- a/target/i386/tcg/fpu_helper.c |
16 | +++ b/target/arm/tcg/cpu32.c | 16 | +++ b/target/i386/tcg/fpu_helper.c |
17 | @@ -XXX,XX +XXX,XX @@ static void cortex_r52_initfn(Object *obj) | 17 | @@ -XXX,XX +XXX,XX @@ void cpu_init_fp_statuses(CPUX86State *env) |
18 | set_feature(&cpu->env, ARM_FEATURE_PMSA); | 18 | * there are multiple input NaNs they are selected in the order a, b, c. |
19 | set_feature(&cpu->env, ARM_FEATURE_NEON); | 19 | */ |
20 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | 20 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status); |
21 | + set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | 21 | + set_float_3nan_prop_rule(float_3nan_prop_abc, &env->sse_status); |
22 | cpu->midr = 0x411fd133; /* r1p3 */ | 22 | } |
23 | cpu->revidr = 0x00000000; | 23 | |
24 | cpu->reset_fpsid = 0x41034023; | 24 | static inline uint8_t save_exception_flags(CPUX86State *env) |
25 | -- | 25 | -- |
26 | 2.34.1 | 26 | 2.34.1 | diff view generated by jsdifflib |
1 | Architecturally, the AArch32 MSR/MRS to/from banked register | 1 | Set the Float3NaNPropRule explicitly for HPPA, and remove the |
---|---|---|---|
2 | instructions are UNPREDICTABLE for attempts to access a banked | 2 | ifdef from pickNaNMulAdd(). |
3 | register that the guest could access in a more direct way (e.g. | ||
4 | using this insn to access r8_fiq when already in FIQ mode). QEMU has | ||
5 | chosen to UNDEF on all of these. | ||
6 | 3 | ||
7 | However, for the case of accessing SPSR_hyp from hyp mode, it turns | 4 | HPPA is the only target that was using the default branch of the |
8 | out that real hardware permits this, with the same effect as if the | 5 | ifdef ladder (other targets either do not use muladd or set |
9 | guest had directly written to SPSR. Further, there is some | 6 | default_nan_mode), so we can remove the ifdef fallback entirely now |
10 | guest code out there that assumes it can do this, because it | 7 | (allowing the "rule not set" case to fall into the default of the |
11 | happens to work on hardware: an example Cortex-R52 startup code | 8 | switch statement and assert). |
12 | fragment uses this, and it got copied into various other places, | ||
13 | including Zephyr. Zephyr was fixed to not use this: | ||
14 | https://github.com/zephyrproject-rtos/zephyr/issues/47330 | ||
15 | but other examples are still out there, like the selftest | ||
16 | binary for the MPS3-AN536. | ||
17 | 9 | ||
18 | For convenience of being able to run guest code, permit | 10 | We add a TODO note that the HPPA rule is probably wrong; this is |
19 | this UNPREDICTABLE access instead of UNDEFing it. | 11 | not a behavioural change for this refactoring. |
20 | 12 | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
23 | Message-id: 20240206132931.38376-5-peter.maydell@linaro.org | 15 | Message-id: 20241202131347.498124-26-peter.maydell@linaro.org |
24 | --- | 16 | --- |
25 | target/arm/tcg/op_helper.c | 43 ++++++++++++++++++++++++++------------ | 17 | target/hppa/fpu_helper.c | 8 ++++++++ |
26 | target/arm/tcg/translate.c | 19 +++++++++++------ | 18 | fpu/softfloat-specialize.c.inc | 4 ---- |
27 | 2 files changed, 43 insertions(+), 19 deletions(-) | 19 | 2 files changed, 8 insertions(+), 4 deletions(-) |
28 | 20 | ||
29 | diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c | 21 | diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c |
30 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/target/arm/tcg/op_helper.c | 23 | --- a/target/hppa/fpu_helper.c |
32 | +++ b/target/arm/tcg/op_helper.c | 24 | +++ b/target/hppa/fpu_helper.c |
33 | @@ -XXX,XX +XXX,XX @@ static void msr_mrs_banked_exc_checks(CPUARMState *env, uint32_t tgtmode, | 25 | @@ -XXX,XX +XXX,XX @@ void HELPER(loaded_fr0)(CPUHPPAState *env) |
26 | * HPPA does note implement a CPU reset method at all... | ||
34 | */ | 27 | */ |
35 | int curmode = env->uncached_cpsr & CPSR_M; | 28 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status); |
36 | 29 | + /* | |
37 | - if (regno == 17) { | 30 | + * TODO: The HPPA architecture reference only documents its NaN |
38 | - /* ELR_Hyp: a special case because access from tgtmode is OK */ | 31 | + * propagation rule for 2-operand operations. Testing on real hardware |
39 | - if (curmode != ARM_CPU_MODE_HYP && curmode != ARM_CPU_MODE_MON) { | 32 | + * might be necessary to confirm whether this order for muladd is correct. |
40 | - goto undef; | 33 | + * Not preferring the SNaN is almost certainly incorrect as it diverges |
41 | + if (tgtmode == ARM_CPU_MODE_HYP) { | 34 | + * from the documented rules for 2-operand operations. |
42 | + /* | 35 | + */ |
43 | + * Handle Hyp target regs first because some are special cases | 36 | + set_float_3nan_prop_rule(float_3nan_prop_abc, &env->fp_status); |
44 | + * which don't want the usual "not accessible from tgtmode" check. | 37 | /* For inf * 0 + NaN, return the input NaN */ |
45 | + */ | 38 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); |
46 | + switch (regno) { | 39 | } |
47 | + case 16 ... 17: /* ELR_Hyp, SPSR_Hyp */ | 40 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc |
48 | + if (curmode != ARM_CPU_MODE_HYP && curmode != ARM_CPU_MODE_MON) { | 41 | index XXXXXXX..XXXXXXX 100644 |
49 | + goto undef; | 42 | --- a/fpu/softfloat-specialize.c.inc |
50 | + } | 43 | +++ b/fpu/softfloat-specialize.c.inc |
51 | + break; | 44 | @@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
52 | + case 13: | ||
53 | + if (curmode != ARM_CPU_MODE_MON) { | ||
54 | + goto undef; | ||
55 | + } | ||
56 | + break; | ||
57 | + default: | ||
58 | + g_assert_not_reached(); | ||
59 | } | ||
60 | return; | ||
61 | } | ||
62 | @@ -XXX,XX +XXX,XX @@ static void msr_mrs_banked_exc_checks(CPUARMState *env, uint32_t tgtmode, | ||
63 | } | 45 | } |
64 | } | 46 | } |
65 | 47 | ||
66 | - if (tgtmode == ARM_CPU_MODE_HYP) { | 48 | - if (rule == float_3nan_prop_none) { |
67 | - /* SPSR_Hyp, r13_hyp: accessible from Monitor mode only */ | 49 | - rule = float_3nan_prop_abc; |
68 | - if (curmode != ARM_CPU_MODE_MON) { | ||
69 | - goto undef; | ||
70 | - } | ||
71 | - } | 50 | - } |
72 | - | 51 | - |
73 | return; | 52 | assert(rule != float_3nan_prop_none); |
74 | 53 | if (have_snan && (rule & R_3NAN_SNAN_MASK)) { | |
75 | undef: | 54 | /* We have at least one SNaN input and should prefer it */ |
76 | @@ -XXX,XX +XXX,XX @@ void HELPER(msr_banked)(CPUARMState *env, uint32_t value, uint32_t tgtmode, | ||
77 | |||
78 | switch (regno) { | ||
79 | case 16: /* SPSRs */ | ||
80 | - env->banked_spsr[bank_number(tgtmode)] = value; | ||
81 | + if (tgtmode == (env->uncached_cpsr & CPSR_M)) { | ||
82 | + /* Only happens for SPSR_Hyp access in Hyp mode */ | ||
83 | + env->spsr = value; | ||
84 | + } else { | ||
85 | + env->banked_spsr[bank_number(tgtmode)] = value; | ||
86 | + } | ||
87 | break; | ||
88 | case 17: /* ELR_Hyp */ | ||
89 | env->elr_el[2] = value; | ||
90 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mrs_banked)(CPUARMState *env, uint32_t tgtmode, uint32_t regno) | ||
91 | |||
92 | switch (regno) { | ||
93 | case 16: /* SPSRs */ | ||
94 | - return env->banked_spsr[bank_number(tgtmode)]; | ||
95 | + if (tgtmode == (env->uncached_cpsr & CPSR_M)) { | ||
96 | + /* Only happens for SPSR_Hyp access in Hyp mode */ | ||
97 | + return env->spsr; | ||
98 | + } else { | ||
99 | + return env->banked_spsr[bank_number(tgtmode)]; | ||
100 | + } | ||
101 | case 17: /* ELR_Hyp */ | ||
102 | return env->elr_el[2]; | ||
103 | case 13: | ||
104 | diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c | ||
105 | index XXXXXXX..XXXXXXX 100644 | ||
106 | --- a/target/arm/tcg/translate.c | ||
107 | +++ b/target/arm/tcg/translate.c | ||
108 | @@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn, | ||
109 | break; | ||
110 | case ARM_CPU_MODE_HYP: | ||
111 | /* | ||
112 | - * SPSR_hyp and r13_hyp can only be accessed from Monitor mode | ||
113 | - * (and so we can forbid accesses from EL2 or below). elr_hyp | ||
114 | - * can be accessed also from Hyp mode, so forbid accesses from | ||
115 | - * EL0 or EL1. | ||
116 | + * r13_hyp can only be accessed from Monitor mode, and so we | ||
117 | + * can forbid accesses from EL2 or below. | ||
118 | + * elr_hyp can be accessed also from Hyp mode, so forbid | ||
119 | + * accesses from EL0 or EL1. | ||
120 | + * SPSR_hyp is supposed to be in the same category as r13_hyp | ||
121 | + * and UNPREDICTABLE if accessed from anything except Monitor | ||
122 | + * mode. However there is some real-world code that will do | ||
123 | + * it because at least some hardware happens to permit the | ||
124 | + * access. (Notably a standard Cortex-R52 startup code fragment | ||
125 | + * does this.) So we permit SPSR_hyp from Hyp mode also, to allow | ||
126 | + * this (incorrect) guest code to run. | ||
127 | */ | ||
128 | - if (!arm_dc_feature(s, ARM_FEATURE_EL2) || s->current_el < 2 || | ||
129 | - (s->current_el < 3 && *regno != 17)) { | ||
130 | + if (!arm_dc_feature(s, ARM_FEATURE_EL2) || s->current_el < 2 | ||
131 | + || (s->current_el < 3 && *regno != 16 && *regno != 17)) { | ||
132 | goto undef; | ||
133 | } | ||
134 | break; | ||
135 | -- | 55 | -- |
136 | 2.34.1 | 56 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Nabih Estefan <nabihestefan@google.com> | 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. | ||
2 | 6 | ||
3 | Fix the nocm_gmac-test.c file to run on a nuvoton 7xx machine instead | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | of 8xx. Also fix comments referencing this and values expecting 8xx. | 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(-) | ||
5 | 15 | ||
6 | Change-Id: Iabd0fba14910c3f1e883c4a9521350f3db9ffab8 | 16 | diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h |
7 | Signed-Off-By: Nabih Estefan <nabihestefan@google.com> | ||
8 | Reviewed-by: Tyrone Ting <kfting@nuvoton.com> | ||
9 | Message-id: 20240208194759.2858582-2-nabihestefan@google.com | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | [PMM: commit message tweaks] | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | tests/qtest/npcm_gmac-test.c | 84 +----------------------------------- | ||
15 | tests/qtest/meson.build | 3 +- | ||
16 | 2 files changed, 4 insertions(+), 83 deletions(-) | ||
17 | |||
18 | diff --git a/tests/qtest/npcm_gmac-test.c b/tests/qtest/npcm_gmac-test.c | ||
19 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/tests/qtest/npcm_gmac-test.c | 18 | --- a/include/fpu/softfloat-helpers.h |
21 | +++ b/tests/qtest/npcm_gmac-test.c | 19 | +++ b/include/fpu/softfloat-helpers.h |
22 | @@ -XXX,XX +XXX,XX @@ typedef struct TestData { | 20 | @@ -XXX,XX +XXX,XX @@ static inline void set_snan_bit_is_one(bool val, float_status *status) |
23 | const GMACModule *module; | 21 | status->snan_bit_is_one = val; |
24 | } TestData; | ||
25 | |||
26 | -/* Values extracted from hw/arm/npcm8xx.c */ | ||
27 | +/* Values extracted from hw/arm/npcm7xx.c */ | ||
28 | static const GMACModule gmac_module_list[] = { | ||
29 | { | ||
30 | .irq = 14, | ||
31 | @@ -XXX,XX +XXX,XX @@ static const GMACModule gmac_module_list[] = { | ||
32 | .irq = 15, | ||
33 | .base_addr = 0xf0804000 | ||
34 | }, | ||
35 | - { | ||
36 | - .irq = 16, | ||
37 | - .base_addr = 0xf0806000 | ||
38 | - }, | ||
39 | - { | ||
40 | - .irq = 17, | ||
41 | - .base_addr = 0xf0808000 | ||
42 | - } | ||
43 | }; | ||
44 | |||
45 | /* Returns the index of the GMAC module. */ | ||
46 | @@ -XXX,XX +XXX,XX @@ static uint32_t gmac_read(QTestState *qts, const GMACModule *mod, | ||
47 | return qtest_readl(qts, mod->base_addr + regno); | ||
48 | } | 22 | } |
49 | 23 | ||
50 | -static uint16_t pcs_read(QTestState *qts, const GMACModule *mod, | 24 | -static inline void set_use_first_nan(bool val, float_status *status) |
51 | - NPCMRegister regno) | ||
52 | -{ | 25 | -{ |
53 | - uint32_t write_value = (regno & 0x3ffe00) >> 9; | 26 | - status->use_first_nan = val; |
54 | - qtest_writel(qts, PCS_BASE_ADDRESS + NPCM_PCS_IND_AC_BA, write_value); | ||
55 | - uint32_t read_offset = regno & 0x1ff; | ||
56 | - return qtest_readl(qts, PCS_BASE_ADDRESS + read_offset); | ||
57 | -} | 27 | -} |
58 | - | 28 | - |
59 | /* Check that GMAC registers are reset to default value */ | 29 | static inline void set_no_signaling_nans(bool val, float_status *status) |
60 | static void test_init(gconstpointer test_data) | ||
61 | { | 30 | { |
62 | const TestData *td = test_data; | 31 | status->no_signaling_nans = val; |
63 | const GMACModule *mod = td->module; | 32 | diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h |
64 | - QTestState *qts = qtest_init("-machine npcm845-evb"); | ||
65 | + QTestState *qts = qtest_init("-machine npcm750-evb"); | ||
66 | |||
67 | #define CHECK_REG32(regno, value) \ | ||
68 | do { \ | ||
69 | g_assert_cmphex(gmac_read(qts, mod, (regno)), ==, (value)); \ | ||
70 | } while (0) | ||
71 | |||
72 | -#define CHECK_REG_PCS(regno, value) \ | ||
73 | - do { \ | ||
74 | - g_assert_cmphex(pcs_read(qts, mod, (regno)), ==, (value)); \ | ||
75 | - } while (0) | ||
76 | - | ||
77 | CHECK_REG32(NPCM_DMA_BUS_MODE, 0x00020100); | ||
78 | CHECK_REG32(NPCM_DMA_XMT_POLL_DEMAND, 0); | ||
79 | CHECK_REG32(NPCM_DMA_RCV_POLL_DEMAND, 0); | ||
80 | @@ -XXX,XX +XXX,XX @@ static void test_init(gconstpointer test_data) | ||
81 | CHECK_REG32(NPCM_GMAC_PTP_TAR, 0); | ||
82 | CHECK_REG32(NPCM_GMAC_PTP_TTSR, 0); | ||
83 | |||
84 | - /* TODO Add registers PCS */ | ||
85 | - if (mod->base_addr == 0xf0802000) { | ||
86 | - CHECK_REG_PCS(NPCM_PCS_SR_CTL_ID1, 0x699e); | ||
87 | - CHECK_REG_PCS(NPCM_PCS_SR_CTL_ID2, 0); | ||
88 | - CHECK_REG_PCS(NPCM_PCS_SR_CTL_STS, 0x8000); | ||
89 | - | ||
90 | - CHECK_REG_PCS(NPCM_PCS_SR_MII_CTRL, 0x1140); | ||
91 | - CHECK_REG_PCS(NPCM_PCS_SR_MII_STS, 0x0109); | ||
92 | - CHECK_REG_PCS(NPCM_PCS_SR_MII_DEV_ID1, 0x699e); | ||
93 | - CHECK_REG_PCS(NPCM_PCS_SR_MII_DEV_ID2, 0x0ced0); | ||
94 | - CHECK_REG_PCS(NPCM_PCS_SR_MII_AN_ADV, 0x0020); | ||
95 | - CHECK_REG_PCS(NPCM_PCS_SR_MII_LP_BABL, 0); | ||
96 | - CHECK_REG_PCS(NPCM_PCS_SR_MII_AN_EXPN, 0); | ||
97 | - CHECK_REG_PCS(NPCM_PCS_SR_MII_EXT_STS, 0xc000); | ||
98 | - | ||
99 | - CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_ABL, 0x0003); | ||
100 | - CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_TX_MAX_DLY_LWR, 0x0038); | ||
101 | - CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_TX_MAX_DLY_UPR, 0); | ||
102 | - CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_TX_MIN_DLY_LWR, 0x0038); | ||
103 | - CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_TX_MIN_DLY_UPR, 0); | ||
104 | - CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_RX_MAX_DLY_LWR, 0x0058); | ||
105 | - CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_RX_MAX_DLY_UPR, 0); | ||
106 | - CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_RX_MIN_DLY_LWR, 0x0048); | ||
107 | - CHECK_REG_PCS(NPCM_PCS_SR_TIM_SYNC_RX_MIN_DLY_UPR, 0); | ||
108 | - | ||
109 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MMD_DIG_CTRL1, 0x2400); | ||
110 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_AN_CTRL, 0); | ||
111 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_AN_INTR_STS, 0x000a); | ||
112 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_TC, 0); | ||
113 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_DBG_CTRL, 0); | ||
114 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_EEE_MCTRL0, 0x899c); | ||
115 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_EEE_TXTIMER, 0); | ||
116 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_EEE_RXTIMER, 0); | ||
117 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_LINK_TIMER_CTRL, 0); | ||
118 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_EEE_MCTRL1, 0); | ||
119 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_DIG_STS, 0x0010); | ||
120 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_ICG_ERRCNT1, 0); | ||
121 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MISC_STS, 0); | ||
122 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_RX_LSTS, 0); | ||
123 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_TX_BSTCTRL0, 0x00a); | ||
124 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_TX_LVLCTRL0, 0x007f); | ||
125 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_TX_GENCTRL0, 0x0001); | ||
126 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_TX_GENCTRL1, 0); | ||
127 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_TX_STS, 0); | ||
128 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_RX_GENCTRL0, 0x0100); | ||
129 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_RX_GENCTRL1, 0x1100); | ||
130 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_RX_LOS_CTRL0, 0x000e); | ||
131 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_MPLL_CTRL0, 0x0100); | ||
132 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_MPLL_CTRL1, 0x0032); | ||
133 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_MPLL_STS, 0x0001); | ||
134 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_MISC_CTRL2, 0); | ||
135 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_LVL_CTRL, 0x0019); | ||
136 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_MISC_CTRL0, 0); | ||
137 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_MP_MISC_CTRL1, 0); | ||
138 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_DIG_CTRL2, 0); | ||
139 | - CHECK_REG_PCS(NPCM_PCS_VR_MII_DIG_ERRCNT_SEL, 0); | ||
140 | - } | ||
141 | - | ||
142 | qtest_quit(qts); | ||
143 | } | ||
144 | |||
145 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
146 | index XXXXXXX..XXXXXXX 100644 | 33 | index XXXXXXX..XXXXXXX 100644 |
147 | --- a/tests/qtest/meson.build | 34 | --- a/include/fpu/softfloat-types.h |
148 | +++ b/tests/qtest/meson.build | 35 | +++ b/include/fpu/softfloat-types.h |
149 | @@ -XXX,XX +XXX,XX @@ qtests_npcm7xx = \ | 36 | @@ -XXX,XX +XXX,XX @@ typedef struct float_status { |
150 | 'npcm7xx_sdhci-test', | 37 | * softfloat-specialize.inc.c) |
151 | 'npcm7xx_smbus-test', | 38 | */ |
152 | 'npcm7xx_timer-test', | 39 | bool snan_bit_is_one; |
153 | - 'npcm7xx_watchdog_timer-test'] + \ | 40 | - bool use_first_nan; |
154 | + 'npcm7xx_watchdog_timer-test', | 41 | bool no_signaling_nans; |
155 | + 'npcm_gmac-test'] + \ | 42 | /* should overflowed results subtract re_bias to its exponent? */ |
156 | (slirp.found() ? ['npcm7xx_emc-test'] : []) | 43 | bool rebias_overflow; |
157 | qtests_aspeed = \ | 44 | diff --git a/target/xtensa/fpu_helper.c b/target/xtensa/fpu_helper.c |
158 | ['aspeed_hace-test', | 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, | ||
159 | -- | 56 | -- |
160 | 2.34.1 | 57 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Currently m68k_cpu_reset_hold() calls floatx80_default_nan(NULL) | ||
2 | to get the NaN bit pattern to reset the FPU registers. This | ||
3 | works because it happens that our implementation of | ||
4 | floatx80_default_nan() doesn't actually look at the float_status | ||
5 | pointer except for TARGET_MIPS. However, this isn't guaranteed, | ||
6 | and to be able to remove the ifdef in floatx80_default_nan() | ||
7 | we're going to need a real float_status here. | ||
1 | 8 | ||
9 | Rearrange m68k_cpu_reset_hold() so that we initialize env->fp_status | ||
10 | earlier, and thus can pass it to floatx80_default_nan(). | ||
11 | |||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20241202131347.498124-28-peter.maydell@linaro.org | ||
15 | --- | ||
16 | target/m68k/cpu.c | 12 +++++++----- | ||
17 | 1 file changed, 7 insertions(+), 5 deletions(-) | ||
18 | |||
19 | diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/target/m68k/cpu.c | ||
22 | +++ b/target/m68k/cpu.c | ||
23 | @@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type) | ||
24 | CPUState *cs = CPU(obj); | ||
25 | M68kCPUClass *mcc = M68K_CPU_GET_CLASS(obj); | ||
26 | CPUM68KState *env = cpu_env(cs); | ||
27 | - floatx80 nan = floatx80_default_nan(NULL); | ||
28 | + floatx80 nan; | ||
29 | int i; | ||
30 | |||
31 | if (mcc->parent_phases.hold) { | ||
32 | @@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type) | ||
33 | #else | ||
34 | cpu_m68k_set_sr(env, SR_S | SR_I); | ||
35 | #endif | ||
36 | - for (i = 0; i < 8; i++) { | ||
37 | - env->fregs[i].d = nan; | ||
38 | - } | ||
39 | - cpu_m68k_set_fpcr(env, 0); | ||
40 | /* | ||
41 | * M68000 FAMILY PROGRAMMER'S REFERENCE MANUAL | ||
42 | * 3.4 FLOATING-POINT INSTRUCTION DETAILS | ||
43 | @@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type) | ||
44 | * preceding paragraph for nonsignaling NaNs. | ||
45 | */ | ||
46 | set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status); | ||
47 | + | ||
48 | + nan = floatx80_default_nan(&env->fp_status); | ||
49 | + for (i = 0; i < 8; i++) { | ||
50 | + env->fregs[i].d = nan; | ||
51 | + } | ||
52 | + cpu_m68k_set_fpcr(env, 0); | ||
53 | env->fpsr = 0; | ||
54 | |||
55 | /* TODO: We should set PC from the interrupt vector. */ | ||
56 | -- | ||
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 | Armv8.1+ CPUs have the Virtual Host Extension (VHE) which adds a | 1 | In the helper functions flcmps and flcmpd we use a scratch float_status |
---|---|---|---|
2 | non-secure EL2 virtual timer. We implemented the timer itself in the | 2 | so that we don't change the CPU state if the comparison raises any |
3 | CPU model, but never wired up its IRQ line to the GIC. | 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. | ||
4 | 7 | ||
5 | Wire up the IRQ line (this is always safe whether the CPU has the | 8 | To do this we need to pass the CPU env pointer in to the helper. |
6 | interrupt or not, since it always creates the outbound IRQ line). | ||
7 | Report it to the guest via dtb and ACPI if the CPU has the feature. | ||
8 | |||
9 | The DTB binding is documented in the kernel's | ||
10 | Documentation/devicetree/bindings/timer/arm\,arch_timer.yaml | ||
11 | and the ACPI table entries are documented in the ACPI specification | ||
12 | version 6.3 or later. | ||
13 | |||
14 | Because the IRQ line ACPI binding is new in 6.3, we need to bump the | ||
15 | FADT table rev to show that we might be using 6.3 features. | ||
16 | |||
17 | Note that exposing this IRQ in the DTB will trigger a bug in EDK2 | ||
18 | versions prior to edk2-stable202311, for users who use the virt board | ||
19 | with 'virtualization=on' to enable EL2 emulation and are booting an | ||
20 | EDK2 guest BIOS, if that EDK2 has assertions enabled. The effect is | ||
21 | that EDK2 will assert on bootup: | ||
22 | |||
23 | ASSERT [ArmTimerDxe] /home/kraxel/projects/qemu/roms/edk2/ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.c(72): PropSize == 36 || PropSize == 48 | ||
24 | |||
25 | If you see that assertion you should do one of: | ||
26 | * update your EDK2 binaries to edk2-stable202311 or newer | ||
27 | * use the 'virt-8.2' versioned machine type | ||
28 | * not use 'virtualization=on' | ||
29 | |||
30 | (The versions shipped with QEMU itself have the fix.) | ||
31 | 9 | ||
32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
33 | Reviewed-by: Ard Biesheuvel <ardb@kernel.org> | 11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
34 | Message-id: 20240122143537.233498-3-peter.maydell@linaro.org | 12 | Message-id: 20241202131347.498124-33-peter.maydell@linaro.org |
35 | --- | 13 | --- |
36 | include/hw/arm/virt.h | 2 ++ | 14 | target/sparc/helper.h | 4 ++-- |
37 | hw/arm/virt-acpi-build.c | 20 ++++++++++---- | 15 | target/sparc/fop_helper.c | 8 ++++---- |
38 | hw/arm/virt.c | 60 ++++++++++++++++++++++++++++++++++------ | 16 | target/sparc/translate.c | 4 ++-- |
39 | 3 files changed, 67 insertions(+), 15 deletions(-) | 17 | 3 files changed, 8 insertions(+), 8 deletions(-) |
40 | 18 | ||
41 | diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h | 19 | diff --git a/target/sparc/helper.h b/target/sparc/helper.h |
42 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
43 | --- a/include/hw/arm/virt.h | 21 | --- a/target/sparc/helper.h |
44 | +++ b/include/hw/arm/virt.h | 22 | +++ b/target/sparc/helper.h |
45 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineClass { | 23 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(fcmpd, TCG_CALL_NO_WG, i32, env, f64, f64) |
46 | /* Machines < 6.2 have no support for describing cpu topology to guest */ | 24 | DEF_HELPER_FLAGS_3(fcmped, TCG_CALL_NO_WG, i32, env, f64, f64) |
47 | bool no_cpu_topology; | 25 | DEF_HELPER_FLAGS_3(fcmpq, TCG_CALL_NO_WG, i32, env, i128, i128) |
48 | bool no_tcg_lpa2; | 26 | DEF_HELPER_FLAGS_3(fcmpeq, TCG_CALL_NO_WG, i32, env, i128, i128) |
49 | + bool no_ns_el2_virt_timer_irq; | 27 | -DEF_HELPER_FLAGS_2(flcmps, TCG_CALL_NO_RWG_SE, i32, f32, f32) |
50 | }; | 28 | -DEF_HELPER_FLAGS_2(flcmpd, TCG_CALL_NO_RWG_SE, i32, f64, f64) |
51 | 29 | +DEF_HELPER_FLAGS_3(flcmps, TCG_CALL_NO_RWG_SE, i32, env, f32, f32) | |
52 | struct VirtMachineState { | 30 | +DEF_HELPER_FLAGS_3(flcmpd, TCG_CALL_NO_RWG_SE, i32, env, f64, f64) |
53 | @@ -XXX,XX +XXX,XX @@ struct VirtMachineState { | 31 | DEF_HELPER_2(raise_exception, noreturn, env, int) |
54 | PCIBus *bus; | 32 | |
55 | char *oem_id; | 33 | DEF_HELPER_FLAGS_3(faddd, TCG_CALL_NO_WG, f64, env, f64, f64) |
56 | char *oem_table_id; | 34 | diff --git a/target/sparc/fop_helper.c b/target/sparc/fop_helper.c |
57 | + bool ns_el2_virt_timer_irq; | ||
58 | }; | ||
59 | |||
60 | #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) | ||
61 | diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | 35 | index XXXXXXX..XXXXXXX 100644 |
63 | --- a/hw/arm/virt-acpi-build.c | 36 | --- a/target/sparc/fop_helper.c |
64 | +++ b/hw/arm/virt-acpi-build.c | 37 | +++ b/target/sparc/fop_helper.c |
65 | @@ -XXX,XX +XXX,XX @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 38 | @@ -XXX,XX +XXX,XX @@ uint32_t helper_fcmpeq(CPUSPARCState *env, Int128 src1, Int128 src2) |
39 | return finish_fcmp(env, r, GETPC()); | ||
66 | } | 40 | } |
67 | 41 | ||
68 | /* | 42 | -uint32_t helper_flcmps(float32 src1, float32 src2) |
69 | - * ACPI spec, Revision 5.1 | 43 | +uint32_t helper_flcmps(CPUSPARCState *env, float32 src1, float32 src2) |
70 | - * 5.2.24 Generic Timer Description Table (GTDT) | 44 | { |
71 | + * ACPI spec, Revision 6.5 | 45 | /* |
72 | + * 5.2.25 Generic Timer Description Table (GTDT) | 46 | * FLCMP never raises an exception nor modifies any FSR fields. |
73 | */ | 47 | * Perform the comparison with a dummy fp environment. |
74 | static void | 48 | */ |
75 | build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 49 | - float_status discard = { }; |
76 | @@ -XXX,XX +XXX,XX @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 50 | + float_status discard = env->fp_status; |
77 | uint32_t irqflags = vmc->claim_edge_triggered_timers ? | 51 | FloatRelation r; |
78 | 1 : /* Interrupt is Edge triggered */ | 52 | |
79 | 0; /* Interrupt is Level triggered */ | 53 | set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard); |
80 | - AcpiTable table = { .sig = "GTDT", .rev = 2, .oem_id = vms->oem_id, | 54 | @@ -XXX,XX +XXX,XX @@ uint32_t helper_flcmps(float32 src1, float32 src2) |
81 | + AcpiTable table = { .sig = "GTDT", .rev = 3, .oem_id = vms->oem_id, | 55 | g_assert_not_reached(); |
82 | .oem_table_id = vms->oem_table_id }; | ||
83 | |||
84 | acpi_table_begin(&table, table_data); | ||
85 | @@ -XXX,XX +XXX,XX @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | ||
86 | build_append_int_noprefix(table_data, 0, 4); | ||
87 | /* Platform Timer Offset */ | ||
88 | build_append_int_noprefix(table_data, 0, 4); | ||
89 | - | ||
90 | + if (vms->ns_el2_virt_timer_irq) { | ||
91 | + /* Virtual EL2 Timer GSIV */ | ||
92 | + build_append_int_noprefix(table_data, ARCH_TIMER_NS_EL2_VIRT_IRQ, 4); | ||
93 | + /* Virtual EL2 Timer Flags */ | ||
94 | + build_append_int_noprefix(table_data, irqflags, 4); | ||
95 | + } else { | ||
96 | + build_append_int_noprefix(table_data, 0, 4); | ||
97 | + build_append_int_noprefix(table_data, 0, 4); | ||
98 | + } | ||
99 | acpi_table_end(linker, &table); | ||
100 | } | 56 | } |
101 | 57 | ||
102 | @@ -XXX,XX +XXX,XX @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) | 58 | -uint32_t helper_flcmpd(float64 src1, float64 src2) |
103 | static void build_fadt_rev6(GArray *table_data, BIOSLinker *linker, | 59 | +uint32_t helper_flcmpd(CPUSPARCState *env, float64 src1, float64 src2) |
104 | VirtMachineState *vms, unsigned dsdt_tbl_offset) | ||
105 | { | 60 | { |
106 | - /* ACPI v6.0 */ | 61 | - float_status discard = { }; |
107 | + /* ACPI v6.3 */ | 62 | + float_status discard = env->fp_status; |
108 | AcpiFadtData fadt = { | 63 | FloatRelation r; |
109 | .rev = 6, | 64 | |
110 | - .minor_ver = 0, | 65 | set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard); |
111 | + .minor_ver = 3, | 66 | diff --git a/target/sparc/translate.c b/target/sparc/translate.c |
112 | .flags = 1 << ACPI_FADT_F_HW_REDUCED_ACPI, | ||
113 | .xdsdt_tbl_offset = &dsdt_tbl_offset, | ||
114 | }; | ||
115 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
116 | index XXXXXXX..XXXXXXX 100644 | 67 | index XXXXXXX..XXXXXXX 100644 |
117 | --- a/hw/arm/virt.c | 68 | --- a/target/sparc/translate.c |
118 | +++ b/hw/arm/virt.c | 69 | +++ b/target/sparc/translate.c |
119 | @@ -XXX,XX +XXX,XX @@ static void create_randomness(MachineState *ms, const char *node) | 70 | @@ -XXX,XX +XXX,XX @@ static bool trans_FLCMPs(DisasContext *dc, arg_FLCMPs *a) |
120 | qemu_fdt_setprop(ms->fdt, node, "rng-seed", seed.rng, sizeof(seed.rng)); | 71 | |
72 | src1 = gen_load_fpr_F(dc, a->rs1); | ||
73 | src2 = gen_load_fpr_F(dc, a->rs2); | ||
74 | - gen_helper_flcmps(cpu_fcc[a->cc], src1, src2); | ||
75 | + gen_helper_flcmps(cpu_fcc[a->cc], tcg_env, src1, src2); | ||
76 | return advance_pc(dc); | ||
121 | } | 77 | } |
122 | 78 | ||
123 | +/* | 79 | @@ -XXX,XX +XXX,XX @@ static bool trans_FLCMPd(DisasContext *dc, arg_FLCMPd *a) |
124 | + * The CPU object always exposes the NS EL2 virt timer IRQ line, | 80 | |
125 | + * but we don't want to advertise it to the guest in the dtb or ACPI | 81 | src1 = gen_load_fpr_D(dc, a->rs1); |
126 | + * table unless it's really going to do something. | 82 | src2 = gen_load_fpr_D(dc, a->rs2); |
127 | + */ | 83 | - gen_helper_flcmpd(cpu_fcc[a->cc], src1, src2); |
128 | +static bool ns_el2_virt_timer_present(void) | 84 | + gen_helper_flcmpd(cpu_fcc[a->cc], tcg_env, src1, src2); |
129 | +{ | 85 | return advance_pc(dc); |
130 | + ARMCPU *cpu = ARM_CPU(qemu_get_cpu(0)); | ||
131 | + CPUARMState *env = &cpu->env; | ||
132 | + | ||
133 | + return arm_feature(env, ARM_FEATURE_AARCH64) && | ||
134 | + arm_feature(env, ARM_FEATURE_EL2) && cpu_isar_feature(aa64_vh, cpu); | ||
135 | +} | ||
136 | + | ||
137 | static void create_fdt(VirtMachineState *vms) | ||
138 | { | ||
139 | MachineState *ms = MACHINE(vms); | ||
140 | @@ -XXX,XX +XXX,XX @@ static void fdt_add_timer_nodes(const VirtMachineState *vms) | ||
141 | "arm,armv7-timer"); | ||
142 | } | ||
143 | qemu_fdt_setprop(ms->fdt, "/timer", "always-on", NULL, 0); | ||
144 | - qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts", | ||
145 | - GIC_FDT_IRQ_TYPE_PPI, | ||
146 | - INTID_TO_PPI(ARCH_TIMER_S_EL1_IRQ), irqflags, | ||
147 | - GIC_FDT_IRQ_TYPE_PPI, | ||
148 | - INTID_TO_PPI(ARCH_TIMER_NS_EL1_IRQ), irqflags, | ||
149 | - GIC_FDT_IRQ_TYPE_PPI, | ||
150 | - INTID_TO_PPI(ARCH_TIMER_VIRT_IRQ), irqflags, | ||
151 | - GIC_FDT_IRQ_TYPE_PPI, | ||
152 | - INTID_TO_PPI(ARCH_TIMER_NS_EL2_IRQ), irqflags); | ||
153 | + if (vms->ns_el2_virt_timer_irq) { | ||
154 | + qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts", | ||
155 | + GIC_FDT_IRQ_TYPE_PPI, | ||
156 | + INTID_TO_PPI(ARCH_TIMER_S_EL1_IRQ), irqflags, | ||
157 | + GIC_FDT_IRQ_TYPE_PPI, | ||
158 | + INTID_TO_PPI(ARCH_TIMER_NS_EL1_IRQ), irqflags, | ||
159 | + GIC_FDT_IRQ_TYPE_PPI, | ||
160 | + INTID_TO_PPI(ARCH_TIMER_VIRT_IRQ), irqflags, | ||
161 | + GIC_FDT_IRQ_TYPE_PPI, | ||
162 | + INTID_TO_PPI(ARCH_TIMER_NS_EL2_IRQ), irqflags, | ||
163 | + GIC_FDT_IRQ_TYPE_PPI, | ||
164 | + INTID_TO_PPI(ARCH_TIMER_NS_EL2_VIRT_IRQ), irqflags); | ||
165 | + } else { | ||
166 | + qemu_fdt_setprop_cells(ms->fdt, "/timer", "interrupts", | ||
167 | + GIC_FDT_IRQ_TYPE_PPI, | ||
168 | + INTID_TO_PPI(ARCH_TIMER_S_EL1_IRQ), irqflags, | ||
169 | + GIC_FDT_IRQ_TYPE_PPI, | ||
170 | + INTID_TO_PPI(ARCH_TIMER_NS_EL1_IRQ), irqflags, | ||
171 | + GIC_FDT_IRQ_TYPE_PPI, | ||
172 | + INTID_TO_PPI(ARCH_TIMER_VIRT_IRQ), irqflags, | ||
173 | + GIC_FDT_IRQ_TYPE_PPI, | ||
174 | + INTID_TO_PPI(ARCH_TIMER_NS_EL2_IRQ), irqflags); | ||
175 | + } | ||
176 | } | 86 | } |
177 | |||
178 | static void fdt_add_cpu_nodes(const VirtMachineState *vms) | ||
179 | @@ -XXX,XX +XXX,XX @@ static void create_gic(VirtMachineState *vms, MemoryRegion *mem) | ||
180 | [GTIMER_VIRT] = ARCH_TIMER_VIRT_IRQ, | ||
181 | [GTIMER_HYP] = ARCH_TIMER_NS_EL2_IRQ, | ||
182 | [GTIMER_SEC] = ARCH_TIMER_S_EL1_IRQ, | ||
183 | + [GTIMER_HYPVIRT] = ARCH_TIMER_NS_EL2_VIRT_IRQ, | ||
184 | }; | ||
185 | |||
186 | for (unsigned irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { | ||
187 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
188 | qdev_realize(DEVICE(cpuobj), NULL, &error_fatal); | ||
189 | object_unref(cpuobj); | ||
190 | } | ||
191 | + | ||
192 | + /* Now we've created the CPUs we can see if they have the hypvirt timer */ | ||
193 | + vms->ns_el2_virt_timer_irq = ns_el2_virt_timer_present() && | ||
194 | + !vmc->no_ns_el2_virt_timer_irq; | ||
195 | + | ||
196 | fdt_add_timer_nodes(vms); | ||
197 | fdt_add_cpu_nodes(vms); | ||
198 | |||
199 | @@ -XXX,XX +XXX,XX @@ DEFINE_VIRT_MACHINE_AS_LATEST(9, 0) | ||
200 | |||
201 | static void virt_machine_8_2_options(MachineClass *mc) | ||
202 | { | ||
203 | + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); | ||
204 | + | ||
205 | virt_machine_9_0_options(mc); | ||
206 | compat_props_add(mc->compat_props, hw_compat_8_2, hw_compat_8_2_len); | ||
207 | + /* | ||
208 | + * Don't expose NS_EL2_VIRT timer IRQ in DTB on ACPI on 8.2 and | ||
209 | + * earlier machines. (Exposing it tickles a bug in older EDK2 | ||
210 | + * guest BIOS binaries.) | ||
211 | + */ | ||
212 | + vmc->no_ns_el2_virt_timer_irq = true; | ||
213 | } | ||
214 | DEFINE_VIRT_MACHINE(8, 2) | ||
215 | 87 | ||
216 | -- | 88 | -- |
217 | 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: Philippe Mathieu-Daudé <philmd@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | QDev objects created with qdev_new() need to manually add | 3 | Now that float_status has a bunch of fp parameters, |
4 | their parent relationship with object_property_add_child(). | 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. | ||
5 | 8 | ||
6 | Since we don't model the SoC, just use a QOM container. | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | 10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
8 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Message-id: 20240213155214.13619-5-philmd@linaro.org | 12 | Message-id: 20241203203949.483774-2-richard.henderson@linaro.org |
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 14 | --- |
13 | hw/arm/stellaris.c | 11 ++++++++++- | 15 | target/arm/tcg/vec_helper.c | 20 +++++++------------- |
14 | 1 file changed, 10 insertions(+), 1 deletion(-) | 16 | 1 file changed, 7 insertions(+), 13 deletions(-) |
15 | 17 | ||
16 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | 18 | diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/stellaris.c | 20 | --- a/target/arm/tcg/vec_helper.c |
19 | +++ b/hw/arm/stellaris.c | 21 | +++ b/target/arm/tcg/vec_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | 22 | @@ -XXX,XX +XXX,XX @@ bool is_ebf(CPUARMState *env, float_status *statusp, float_status *oddstatusp) |
21 | * 400fe000 system control | 23 | * no effect on AArch32 instructions. |
22 | */ | 24 | */ |
23 | 25 | bool ebf = is_a64(env) && env->vfp.fpcr & FPCR_EBF; | |
24 | + Object *soc_container; | 26 | - *statusp = (float_status){ |
25 | DeviceState *gpio_dev[7], *nvic; | 27 | - .tininess_before_rounding = float_tininess_before_rounding, |
26 | qemu_irq gpio_in[7][8]; | 28 | - .float_rounding_mode = float_round_to_odd_inf, |
27 | qemu_irq gpio_out[7][8]; | 29 | - .flush_to_zero = true, |
28 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | 30 | - .flush_inputs_to_zero = true, |
29 | flash_size = (((board->dc0 & 0xffff) + 1) << 1) * 1024; | 31 | - .default_nan_mode = true, |
30 | sram_size = ((board->dc0 >> 18) + 1) * 1024; | 32 | - }; |
31 | |||
32 | + soc_container = object_new("container"); | ||
33 | + object_property_add_child(OBJECT(ms), "soc", soc_container); | ||
34 | + | 33 | + |
35 | /* Flash programming is done via the SCU, so pretend it is ROM. */ | 34 | + *statusp = env->vfp.fp_status; |
36 | memory_region_init_rom(flash, NULL, "stellaris.flash", flash_size, | 35 | + set_default_nan_mode(true, statusp); |
37 | &error_fatal); | 36 | |
38 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | 37 | if (ebf) { |
39 | * need its sysclk output. | 38 | - float_status *fpst = &env->vfp.fp_status; |
40 | */ | 39 | - set_flush_to_zero(get_flush_to_zero(fpst), statusp); |
41 | ssys_dev = qdev_new(TYPE_STELLARIS_SYS); | 40 | - set_flush_inputs_to_zero(get_flush_inputs_to_zero(fpst), statusp); |
42 | + object_property_add_child(soc_container, "sys", OBJECT(ssys_dev)); | 41 | - set_float_rounding_mode(get_float_rounding_mode(fpst), statusp); |
43 | |||
44 | /* | ||
45 | * Most devices come preprogrammed with a MAC address in the user data. | ||
46 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
47 | sysbus_realize_and_unref(SYS_BUS_DEVICE(ssys_dev), &error_fatal); | ||
48 | |||
49 | nvic = qdev_new(TYPE_ARMV7M); | ||
50 | + object_property_add_child(soc_container, "v7m", OBJECT(nvic)); | ||
51 | qdev_prop_set_uint32(nvic, "num-irq", NUM_IRQ_LINES); | ||
52 | qdev_prop_set_uint8(nvic, "num-prio-bits", NUM_PRIO_BITS); | ||
53 | qdev_prop_set_string(nvic, "cpu-type", ms->cpu_type); | ||
54 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
55 | |||
56 | dev = qdev_new(TYPE_STELLARIS_GPTM); | ||
57 | sbd = SYS_BUS_DEVICE(dev); | ||
58 | + object_property_add_child(soc_container, "gptm[*]", OBJECT(dev)); | ||
59 | qdev_connect_clock_in(dev, "clk", | ||
60 | qdev_get_clock_out(ssys_dev, "SYSCLK")); | ||
61 | sysbus_realize_and_unref(sbd, &error_fatal); | ||
62 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
63 | |||
64 | if (board->dc1 & (1 << 3)) { /* watchdog present */ | ||
65 | dev = qdev_new(TYPE_LUMINARY_WATCHDOG); | ||
66 | - | 42 | - |
67 | + object_property_add_child(soc_container, "wdg", OBJECT(dev)); | 43 | /* EBF=1 needs to do a step with round-to-odd semantics */ |
68 | qdev_connect_clock_in(dev, "WDOGCLK", | 44 | *oddstatusp = *statusp; |
69 | qdev_get_clock_out(ssys_dev, "SYSCLK")); | 45 | set_float_rounding_mode(float_round_to_odd, oddstatusp); |
70 | 46 | + } else { | |
71 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | 47 | + set_flush_to_zero(true, statusp); |
72 | SysBusDevice *sbd; | 48 | + set_flush_inputs_to_zero(true, statusp); |
73 | 49 | + set_float_rounding_mode(float_round_to_odd_inf, statusp); | |
74 | dev = qdev_new("pl011_luminary"); | 50 | } |
75 | + object_property_add_child(soc_container, "uart[*]", OBJECT(dev)); | 51 | - |
76 | sbd = SYS_BUS_DEVICE(dev); | 52 | return ebf; |
77 | qdev_prop_set_chr(dev, "chardev", serial_hd(i)); | 53 | } |
78 | sysbus_realize_and_unref(sbd, &error_fatal); | 54 | |
79 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
80 | DeviceState *enet; | ||
81 | |||
82 | enet = qdev_new("stellaris_enet"); | ||
83 | + object_property_add_child(soc_container, "enet", OBJECT(enet)); | ||
84 | if (nd) { | ||
85 | qdev_set_nic_properties(enet, nd); | ||
86 | } else { | ||
87 | -- | 55 | -- |
88 | 2.34.1 | 56 | 2.34.1 |
89 | 57 | ||
90 | 58 | diff view generated by jsdifflib |
1 | The MPS2 SCC device is broadly the same for all FPGA images, but has | 1 | Currently we hardcode the default NaN value in parts64_default_nan() |
---|---|---|---|
2 | minor differences in the behaviour of the CFG registers depending on | 2 | using a compile-time ifdef ladder. This is awkward for two cases: |
3 | the image. In many cases we don't really care about the functionality | 3 | * for single-QEMU-binary we can't hard-code target-specifics like this |
4 | controlled by these registers and a reads-as-written or similar | 4 | * for Arm FEAT_AFP the default NaN value depends on FPCR.AH |
5 | behaviour is sufficient for the moment. | 5 | (specifically the sign bit is different) |
6 | 6 | ||
7 | For the AN536 the required behaviour is: | 7 | Add a field to float_status to specify the default NaN value; fall |
8 | back to the old ifdef behaviour if these are not set. | ||
8 | 9 | ||
9 | * A_CFG0 has CPU reset and halt bits | 10 | The default NaN value is specified by setting a uint8_t to a |
10 | - implement as reads-as-written for the moment | 11 | pattern corresponding to the sign and upper fraction parts of |
11 | * A_CFG1 has flash or ATCM address 0 remap handling | 12 | the NaN; the lower bits of the fraction are set from bit 0 of |
12 | - QEMU doesn't model this; implement as reads-as-written | 13 | the pattern. |
13 | * A_CFG2 has QSPI select (like AN524) | ||
14 | - implemented (no behaviour, as with AN524) | ||
15 | * A_CFG3 is MCC_MSB_ADDR "additional MCC addressing bits" | ||
16 | - QEMU doesn't care about these, so use the existing | ||
17 | RAZ behaviour for convenience | ||
18 | * A_CFG4 is board rev (like all other images) | ||
19 | - no change needed | ||
20 | * A_CFG5 is ACLK frq in hz (like AN524) | ||
21 | - implemented as reads-as-written, as for other boards | ||
22 | * A_CFG6 is core 0 vector table base address | ||
23 | - implemented as reads-as-written for the moment | ||
24 | * A_CFG7 is core 1 vector table base address | ||
25 | - implemented as reads-as-written for the moment | ||
26 | |||
27 | Make the changes necessary for this; leave TODO comments where | ||
28 | appropriate to indicate where we might want to come back and | ||
29 | implement things like CPU reset. | ||
30 | |||
31 | The other aspects of the device specific to this FPGA image (like the | ||
32 | values of the board ID and similar registers) will be set via the | ||
33 | device's qdev properties. | ||
34 | 14 | ||
35 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
36 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
37 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 17 | Message-id: 20241202131347.498124-35-peter.maydell@linaro.org |
38 | Message-id: 20240206132931.38376-8-peter.maydell@linaro.org | ||
39 | --- | 18 | --- |
40 | include/hw/misc/mps2-scc.h | 1 + | 19 | include/fpu/softfloat-helpers.h | 11 +++++++ |
41 | hw/misc/mps2-scc.c | 101 +++++++++++++++++++++++++++++++++---- | 20 | include/fpu/softfloat-types.h | 10 ++++++ |
42 | 2 files changed, 92 insertions(+), 10 deletions(-) | 21 | fpu/softfloat-specialize.c.inc | 55 ++++++++++++++++++++------------- |
22 | 3 files changed, 54 insertions(+), 22 deletions(-) | ||
43 | 23 | ||
44 | diff --git a/include/hw/misc/mps2-scc.h b/include/hw/misc/mps2-scc.h | 24 | diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h |
45 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
46 | --- a/include/hw/misc/mps2-scc.h | 26 | --- a/include/fpu/softfloat-helpers.h |
47 | +++ b/include/hw/misc/mps2-scc.h | 27 | +++ b/include/fpu/softfloat-helpers.h |
48 | @@ -XXX,XX +XXX,XX @@ struct MPS2SCC { | 28 | @@ -XXX,XX +XXX,XX @@ static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule, |
49 | uint32_t cfg4; | 29 | status->float_infzeronan_rule = rule; |
50 | uint32_t cfg5; | ||
51 | uint32_t cfg6; | ||
52 | + uint32_t cfg7; | ||
53 | uint32_t cfgdata_rtn; | ||
54 | uint32_t cfgdata_out; | ||
55 | uint32_t cfgctrl; | ||
56 | diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/hw/misc/mps2-scc.c | ||
59 | +++ b/hw/misc/mps2-scc.c | ||
60 | @@ -XXX,XX +XXX,XX @@ REG32(CFG3, 0xc) | ||
61 | REG32(CFG4, 0x10) | ||
62 | REG32(CFG5, 0x14) | ||
63 | REG32(CFG6, 0x18) | ||
64 | +REG32(CFG7, 0x1c) | ||
65 | REG32(CFGDATA_RTN, 0xa0) | ||
66 | REG32(CFGDATA_OUT, 0xa4) | ||
67 | REG32(CFGCTRL, 0xa8) | ||
68 | @@ -XXX,XX +XXX,XX @@ static int scc_partno(MPS2SCC *s) | ||
69 | /* Is CFG_REG2 present? */ | ||
70 | static bool have_cfg2(MPS2SCC *s) | ||
71 | { | ||
72 | - return scc_partno(s) == 0x524 || scc_partno(s) == 0x547; | ||
73 | + return scc_partno(s) == 0x524 || scc_partno(s) == 0x547 || | ||
74 | + scc_partno(s) == 0x536; | ||
75 | } | 30 | } |
76 | 31 | ||
77 | /* Is CFG_REG3 present? */ | 32 | +static inline void set_float_default_nan_pattern(uint8_t dnan_pattern, |
78 | static bool have_cfg3(MPS2SCC *s) | 33 | + float_status *status) |
79 | { | 34 | +{ |
80 | - return scc_partno(s) != 0x524 && scc_partno(s) != 0x547; | 35 | + status->default_nan_pattern = dnan_pattern; |
81 | + return scc_partno(s) != 0x524 && scc_partno(s) != 0x547 && | ||
82 | + scc_partno(s) != 0x536; | ||
83 | } | ||
84 | |||
85 | /* Is CFG_REG5 present? */ | ||
86 | static bool have_cfg5(MPS2SCC *s) | ||
87 | { | ||
88 | - return scc_partno(s) == 0x524 || scc_partno(s) == 0x547; | ||
89 | + return scc_partno(s) == 0x524 || scc_partno(s) == 0x547 || | ||
90 | + scc_partno(s) == 0x536; | ||
91 | } | ||
92 | |||
93 | /* Is CFG_REG6 present? */ | ||
94 | static bool have_cfg6(MPS2SCC *s) | ||
95 | { | ||
96 | - return scc_partno(s) == 0x524; | ||
97 | + return scc_partno(s) == 0x524 || scc_partno(s) == 0x536; | ||
98 | +} | 36 | +} |
99 | + | 37 | + |
100 | +/* Is CFG_REG7 present? */ | 38 | static inline void set_flush_to_zero(bool val, float_status *status) |
101 | +static bool have_cfg7(MPS2SCC *s) | 39 | { |
40 | status->flush_to_zero = val; | ||
41 | @@ -XXX,XX +XXX,XX @@ static inline FloatInfZeroNaNRule get_float_infzeronan_rule(float_status *status | ||
42 | return status->float_infzeronan_rule; | ||
43 | } | ||
44 | |||
45 | +static inline uint8_t get_float_default_nan_pattern(float_status *status) | ||
102 | +{ | 46 | +{ |
103 | + return scc_partno(s) == 0x536; | 47 | + return status->default_nan_pattern; |
104 | +} | 48 | +} |
105 | + | 49 | + |
106 | +/* Does CFG_REG0 drive the 'remap' GPIO output? */ | 50 | static inline bool get_flush_to_zero(float_status *status) |
107 | +static bool cfg0_is_remap(MPS2SCC *s) | 51 | { |
108 | +{ | 52 | return status->flush_to_zero; |
109 | + return scc_partno(s) != 0x536; | 53 | diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h |
110 | +} | 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); | ||
111 | + | 136 | + |
112 | +/* Is CFG_REG1 driving a set of LEDs? */ | 137 | + sign = dnan_pattern >> 7; |
113 | +static bool cfg1_is_leds(MPS2SCC *s) | 138 | + /* |
114 | +{ | 139 | + * Place default_nan_pattern [6:0] into bits [62:56], |
115 | + return scc_partno(s) != 0x536; | 140 | + * and replecate bit [0] down into [55:0] |
116 | } | 141 | + */ |
117 | 142 | + frac = deposit64(0, DECOMPOSED_BINARY_POINT - 7, 7, dnan_pattern); | |
118 | /* Handle a write via the SYS_CFG channel to the specified function/device. | 143 | + frac = deposit64(frac, 0, DECOMPOSED_BINARY_POINT - 7, -(dnan_pattern & 1)); |
119 | @@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size) | 144 | |
120 | if (!have_cfg3(s)) { | 145 | *p = (FloatParts64) { |
121 | goto bad_offset; | 146 | .cls = float_class_qnan, |
122 | } | ||
123 | - /* These are user-settable DIP switches on the board. We don't | ||
124 | + /* | ||
125 | + * These are user-settable DIP switches on the board. We don't | ||
126 | * model that, so just return zeroes. | ||
127 | + * | ||
128 | + * TODO: for AN536 this is MCC_MSB_ADDR "additional MCC addressing | ||
129 | + * bits". These change which part of the DDR4 the motherboard | ||
130 | + * configuration controller can see in its memory map (see the | ||
131 | + * appnote section 2.4). QEMU doesn't model the MCC at all, so these | ||
132 | + * bits are not interesting to us; read-as-zero is as good as anything | ||
133 | + * else. | ||
134 | */ | ||
135 | r = 0; | ||
136 | break; | ||
137 | @@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size) | ||
138 | } | ||
139 | r = s->cfg6; | ||
140 | break; | ||
141 | + case A_CFG7: | ||
142 | + if (!have_cfg7(s)) { | ||
143 | + goto bad_offset; | ||
144 | + } | ||
145 | + r = s->cfg7; | ||
146 | + break; | ||
147 | case A_CFGDATA_RTN: | ||
148 | r = s->cfgdata_rtn; | ||
149 | break; | ||
150 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value, | ||
151 | * we always reflect bit 0 in the 'remap' GPIO output line, | ||
152 | * and let the board wire it up or not as it chooses. | ||
153 | * TODO on some boards bit 1 is CPU_WAIT. | ||
154 | + * | ||
155 | + * TODO: on the AN536 this register controls reset and halt | ||
156 | + * for both CPUs. For the moment we don't implement this, so the | ||
157 | + * register just reads as written. | ||
158 | */ | ||
159 | s->cfg0 = value; | ||
160 | - qemu_set_irq(s->remap, s->cfg0 & 1); | ||
161 | + if (cfg0_is_remap(s)) { | ||
162 | + qemu_set_irq(s->remap, s->cfg0 & 1); | ||
163 | + } | ||
164 | break; | ||
165 | case A_CFG1: | ||
166 | s->cfg1 = value; | ||
167 | - for (size_t i = 0; i < ARRAY_SIZE(s->led); i++) { | ||
168 | - led_set_state(s->led[i], extract32(value, i, 1)); | ||
169 | + /* | ||
170 | + * On most boards this register drives LEDs. | ||
171 | + * | ||
172 | + * TODO: for AN536 this controls whether flash and ATCM are | ||
173 | + * enabled or disabled on reset. QEMU doesn't model this, and | ||
174 | + * always wires up RAM in the ATCM area and ROM in the flash area. | ||
175 | + */ | ||
176 | + if (cfg1_is_leds(s)) { | ||
177 | + for (size_t i = 0; i < ARRAY_SIZE(s->led); i++) { | ||
178 | + led_set_state(s->led[i], extract32(value, i, 1)); | ||
179 | + } | ||
180 | } | ||
181 | break; | ||
182 | case A_CFG2: | ||
183 | if (!have_cfg2(s)) { | ||
184 | goto bad_offset; | ||
185 | } | ||
186 | - /* AN524: QSPI Select signal */ | ||
187 | + /* AN524, AN536: QSPI Select signal */ | ||
188 | s->cfg2 = value; | ||
189 | break; | ||
190 | case A_CFG5: | ||
191 | if (!have_cfg5(s)) { | ||
192 | goto bad_offset; | ||
193 | } | ||
194 | - /* AN524: ACLK frequency in Hz */ | ||
195 | + /* AN524, AN536: ACLK frequency in Hz */ | ||
196 | s->cfg5 = value; | ||
197 | break; | ||
198 | case A_CFG6: | ||
199 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_write(void *opaque, hwaddr offset, uint64_t value, | ||
200 | goto bad_offset; | ||
201 | } | ||
202 | /* AN524: Clock divider for BRAM */ | ||
203 | + /* AN536: Core 0 vector table base address */ | ||
204 | + s->cfg6 = value; | ||
205 | + break; | ||
206 | + case A_CFG7: | ||
207 | + if (!have_cfg7(s)) { | ||
208 | + goto bad_offset; | ||
209 | + } | ||
210 | + /* AN536: Core 1 vector table base address */ | ||
211 | s->cfg6 = value; | ||
212 | break; | ||
213 | case A_CFGDATA_OUT: | ||
214 | @@ -XXX,XX +XXX,XX @@ static void mps2_scc_finalize(Object *obj) | ||
215 | g_free(s->oscclk_reset); | ||
216 | } | ||
217 | |||
218 | +static bool cfg7_needed(void *opaque) | ||
219 | +{ | ||
220 | + MPS2SCC *s = opaque; | ||
221 | + | ||
222 | + return have_cfg7(s); | ||
223 | +} | ||
224 | + | ||
225 | +static const VMStateDescription vmstate_cfg7 = { | ||
226 | + .name = "mps2-scc/cfg7", | ||
227 | + .version_id = 1, | ||
228 | + .minimum_version_id = 1, | ||
229 | + .needed = cfg7_needed, | ||
230 | + .fields = (const VMStateField[]) { | ||
231 | + VMSTATE_UINT32(cfg7, MPS2SCC), | ||
232 | + VMSTATE_END_OF_LIST() | ||
233 | + } | ||
234 | +}; | ||
235 | + | ||
236 | static const VMStateDescription mps2_scc_vmstate = { | ||
237 | .name = "mps2-scc", | ||
238 | .version_id = 3, | ||
239 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription mps2_scc_vmstate = { | ||
240 | VMSTATE_VARRAY_UINT32(oscclk, MPS2SCC, num_oscclk, | ||
241 | 0, vmstate_info_uint32, uint32_t), | ||
242 | VMSTATE_END_OF_LIST() | ||
243 | + }, | ||
244 | + .subsections = (const VMStateDescription * const []) { | ||
245 | + &vmstate_cfg7, | ||
246 | + NULL | ||
247 | } | ||
248 | }; | ||
249 | |||
250 | -- | 147 | -- |
251 | 2.34.1 | 148 | 2.34.1 |
252 | |||
253 | 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 |
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-37-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/microblaze/cpu.c | 2 ++ | ||
9 | fpu/softfloat-specialize.c.inc | 3 +-- | ||
10 | 2 files changed, 3 insertions(+), 2 deletions(-) | ||
11 | |||
12 | diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/microblaze/cpu.c | ||
15 | +++ b/target/microblaze/cpu.c | ||
16 | @@ -XXX,XX +XXX,XX @@ static void mb_cpu_reset_hold(Object *obj, ResetType type) | ||
17 | * this architecture. | ||
18 | */ | ||
19 | set_float_2nan_prop_rule(float_2nan_prop_x87, &env->fp_status); | ||
20 | + /* Default NaN: sign bit set, most significant frac bit set */ | ||
21 | + set_float_default_nan_pattern(0b11000000, &env->fp_status); | ||
22 | |||
23 | #if defined(CONFIG_USER_ONLY) | ||
24 | /* start in user mode with interrupts enabled. */ | ||
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 | #if defined(TARGET_SPARC) || defined(TARGET_M68K) | ||
31 | /* Sign bit clear, all frac bits set */ | ||
32 | dnan_pattern = 0b01111111; | ||
33 | -#elif defined(TARGET_I386) || defined(TARGET_X86_64) \ | ||
34 | - || defined(TARGET_MICROBLAZE) | ||
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 | -- | ||
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 |
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-39-peter.maydell@linaro.org | ||
7 | --- | ||
8 | target/hppa/fpu_helper.c | 2 ++ | ||
9 | fpu/softfloat-specialize.c.inc | 3 --- | ||
10 | 2 files changed, 2 insertions(+), 3 deletions(-) | ||
11 | |||
12 | diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/target/hppa/fpu_helper.c | ||
15 | +++ b/target/hppa/fpu_helper.c | ||
16 | @@ -XXX,XX +XXX,XX @@ void HELPER(loaded_fr0)(CPUHPPAState *env) | ||
17 | set_float_3nan_prop_rule(float_3nan_prop_abc, &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: sign bit clear, msb-1 frac bit set */ | ||
21 | + set_float_default_nan_pattern(0b00100000, &env->fp_status); | ||
22 | } | ||
23 | |||
24 | void cpu_hppa_loaded_fr0(CPUHPPAState *env) | ||
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 | #if defined(TARGET_SPARC) || defined(TARGET_M68K) | ||
31 | /* Sign bit clear, all frac bits set */ | ||
32 | dnan_pattern = 0b01111111; | ||
33 | -#elif defined(TARGET_HPPA) | ||
34 | - /* Sign bit clear, msb-1 frac bit set */ | ||
35 | - dnan_pattern = 0b00100000; | ||
36 | #elif defined(TARGET_HEXAGON) | ||
37 | /* Sign bit set, all frac bits set. */ | ||
38 | dnan_pattern = 0b11111111; | ||
39 | -- | ||
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 |
1 | Create the CPUs, the GIC, and the per-CPU RAM block for | 1 | Set the default NaN pattern explicitly for the arm target. |
---|---|---|---|
2 | the mps3-an536 board. | 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. | ||
3 | 5 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Message-id: 20240206132931.38376-10-peter.maydell@linaro.org | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20241202131347.498124-41-peter.maydell@linaro.org | ||
6 | --- | 9 | --- |
7 | hw/arm/mps3r.c | 180 ++++++++++++++++++++++++++++++++++++++++++++++++- | 10 | linux-user/arm/nwfpe/fpa11.c | 5 +++++ |
8 | 1 file changed, 177 insertions(+), 3 deletions(-) | 11 | target/arm/cpu.c | 2 ++ |
12 | 2 files changed, 7 insertions(+) | ||
9 | 13 | ||
10 | diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c | 14 | diff --git a/linux-user/arm/nwfpe/fpa11.c b/linux-user/arm/nwfpe/fpa11.c |
11 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/hw/arm/mps3r.c | 16 | --- a/linux-user/arm/nwfpe/fpa11.c |
13 | +++ b/hw/arm/mps3r.c | 17 | +++ b/linux-user/arm/nwfpe/fpa11.c |
14 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ void resetFPA11(void) |
15 | #include "qemu/osdep.h" | 19 | * this late date. |
16 | #include "qemu/units.h" | 20 | */ |
17 | #include "qapi/error.h" | 21 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, &fpa11->fp_status); |
18 | +#include "qapi/qmp/qlist.h" | 22 | + /* |
19 | #include "exec/address-spaces.h" | 23 | + * Use the same default NaN value as Arm VFP. This doesn't match |
20 | #include "cpu.h" | 24 | + * the Linux kernel's nwfpe emulation, which uses an all-1s value. |
21 | #include "hw/boards.h" | 25 | + */ |
22 | +#include "hw/qdev-properties.h" | 26 | + set_float_default_nan_pattern(0b01000000, &fpa11->fp_status); |
23 | #include "hw/arm/boot.h" | ||
24 | +#include "hw/arm/bsa.h" | ||
25 | +#include "hw/intc/arm_gicv3.h" | ||
26 | |||
27 | /* Define the layout of RAM and ROM in a board */ | ||
28 | typedef struct RAMInfo { | ||
29 | @@ -XXX,XX +XXX,XX @@ typedef struct RAMInfo { | ||
30 | #define IS_ROM 2 | ||
31 | |||
32 | #define MPS3R_RAM_MAX 9 | ||
33 | +#define MPS3R_CPU_MAX 2 | ||
34 | + | ||
35 | +#define PERIPHBASE 0xf0000000 | ||
36 | +#define NUM_SPIS 96 | ||
37 | |||
38 | typedef enum MPS3RFPGAType { | ||
39 | FPGA_AN536, | ||
40 | @@ -XXX,XX +XXX,XX @@ struct MPS3RMachineClass { | ||
41 | MachineClass parent; | ||
42 | MPS3RFPGAType fpga_type; | ||
43 | const RAMInfo *raminfo; | ||
44 | + hwaddr loader_start; | ||
45 | }; | ||
46 | |||
47 | struct MPS3RMachineState { | ||
48 | MachineState parent; | ||
49 | + struct arm_boot_info bootinfo; | ||
50 | MemoryRegion ram[MPS3R_RAM_MAX]; | ||
51 | + Object *cpu[MPS3R_CPU_MAX]; | ||
52 | + MemoryRegion cpu_sysmem[MPS3R_CPU_MAX]; | ||
53 | + MemoryRegion sysmem_alias[MPS3R_CPU_MAX]; | ||
54 | + MemoryRegion cpu_ram[MPS3R_CPU_MAX]; | ||
55 | + GICv3State gic; | ||
56 | }; | ||
57 | |||
58 | #define TYPE_MPS3R_MACHINE "mps3r" | ||
59 | @@ -XXX,XX +XXX,XX @@ static MemoryRegion *mr_for_raminfo(MPS3RMachineState *mms, | ||
60 | return ram; | ||
61 | } | 27 | } |
62 | 28 | ||
63 | +/* | 29 | void SetRoundingMode(const unsigned int opcode) |
64 | + * There is no defined secondary boot protocol for Linux for the AN536, | 30 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c |
65 | + * because real hardware has a restriction that atomic operations between | 31 | index XXXXXXX..XXXXXXX 100644 |
66 | + * the two CPUs do not function correctly, and so true SMP is not | 32 | --- a/target/arm/cpu.c |
67 | + * possible. Therefore for cases where the user is directly booting | 33 | +++ b/target/arm/cpu.c |
68 | + * a kernel, we treat the system as essentially uniprocessor, and | 34 | @@ -XXX,XX +XXX,XX @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook, |
69 | + * put the secondary CPU into power-off state (as if the user on the | 35 | * the pseudocode function the arguments are in the order c, a, b. |
70 | + * real hardware had configured the secondary to be halted via the | 36 | * * 0 * Inf + NaN returns the default NaN if the input NaN is quiet, |
71 | + * SCC config registers). | 37 | * and the input NaN if it is signalling |
72 | + * | 38 | + * * Default NaN has sign bit clear, msb frac bit set |
73 | + * Note that the default secondary boot code would not work here anyway | 39 | */ |
74 | + * as it assumes a GICv2, and we have a GICv3. | 40 | static void arm_set_default_fp_behaviours(float_status *s) |
75 | + */ | ||
76 | +static void mps3r_write_secondary_boot(ARMCPU *cpu, | ||
77 | + const struct arm_boot_info *info) | ||
78 | +{ | ||
79 | + /* | ||
80 | + * Power the secondary CPU off. This means we don't need to write any | ||
81 | + * boot code into guest memory. Note that the 'cpu' argument to this | ||
82 | + * function is the primary CPU we passed to arm_load_kernel(), not | ||
83 | + * the secondary. Loop around all the other CPUs, as the boot.c | ||
84 | + * code does for the "disable secondaries if PSCI is enabled" case. | ||
85 | + */ | ||
86 | + for (CPUState *cs = first_cpu; cs; cs = CPU_NEXT(cs)) { | ||
87 | + if (cs != first_cpu) { | ||
88 | + object_property_set_bool(OBJECT(cs), "start-powered-off", true, | ||
89 | + &error_abort); | ||
90 | + } | ||
91 | + } | ||
92 | +} | ||
93 | + | ||
94 | +static void mps3r_secondary_cpu_reset(ARMCPU *cpu, | ||
95 | + const struct arm_boot_info *info) | ||
96 | +{ | ||
97 | + /* We don't need to do anything here because the CPU will be off */ | ||
98 | +} | ||
99 | + | ||
100 | +static void create_gic(MPS3RMachineState *mms, MemoryRegion *sysmem) | ||
101 | +{ | ||
102 | + MachineState *machine = MACHINE(mms); | ||
103 | + DeviceState *gicdev; | ||
104 | + QList *redist_region_count; | ||
105 | + | ||
106 | + object_initialize_child(OBJECT(mms), "gic", &mms->gic, TYPE_ARM_GICV3); | ||
107 | + gicdev = DEVICE(&mms->gic); | ||
108 | + qdev_prop_set_uint32(gicdev, "num-cpu", machine->smp.cpus); | ||
109 | + qdev_prop_set_uint32(gicdev, "num-irq", NUM_SPIS + GIC_INTERNAL); | ||
110 | + redist_region_count = qlist_new(); | ||
111 | + qlist_append_int(redist_region_count, machine->smp.cpus); | ||
112 | + qdev_prop_set_array(gicdev, "redist-region-count", redist_region_count); | ||
113 | + object_property_set_link(OBJECT(&mms->gic), "sysmem", | ||
114 | + OBJECT(sysmem), &error_fatal); | ||
115 | + sysbus_realize(SYS_BUS_DEVICE(&mms->gic), &error_fatal); | ||
116 | + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->gic), 0, PERIPHBASE); | ||
117 | + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->gic), 1, PERIPHBASE + 0x100000); | ||
118 | + /* | ||
119 | + * Wire the outputs from each CPU's generic timer and the GICv3 | ||
120 | + * maintenance interrupt signal to the appropriate GIC PPI inputs, | ||
121 | + * and the GIC's IRQ/FIQ/VIRQ/VFIQ interrupt outputs to the CPU's inputs. | ||
122 | + */ | ||
123 | + for (int i = 0; i < machine->smp.cpus; i++) { | ||
124 | + DeviceState *cpudev = DEVICE(mms->cpu[i]); | ||
125 | + SysBusDevice *gicsbd = SYS_BUS_DEVICE(&mms->gic); | ||
126 | + int intidbase = NUM_SPIS + i * GIC_INTERNAL; | ||
127 | + int irq; | ||
128 | + /* | ||
129 | + * Mapping from the output timer irq lines from the CPU to the | ||
130 | + * GIC PPI inputs used for this board. This isn't a BSA board, | ||
131 | + * but it uses the standard convention for the PPI numbers. | ||
132 | + */ | ||
133 | + const int timer_irq[] = { | ||
134 | + [GTIMER_PHYS] = ARCH_TIMER_NS_EL1_IRQ, | ||
135 | + [GTIMER_VIRT] = ARCH_TIMER_VIRT_IRQ, | ||
136 | + [GTIMER_HYP] = ARCH_TIMER_NS_EL2_IRQ, | ||
137 | + }; | ||
138 | + | ||
139 | + for (irq = 0; irq < ARRAY_SIZE(timer_irq); irq++) { | ||
140 | + qdev_connect_gpio_out(cpudev, irq, | ||
141 | + qdev_get_gpio_in(gicdev, | ||
142 | + intidbase + timer_irq[irq])); | ||
143 | + } | ||
144 | + | ||
145 | + qdev_connect_gpio_out_named(cpudev, "gicv3-maintenance-interrupt", 0, | ||
146 | + qdev_get_gpio_in(gicdev, | ||
147 | + intidbase + ARCH_GIC_MAINT_IRQ)); | ||
148 | + | ||
149 | + qdev_connect_gpio_out_named(cpudev, "pmu-interrupt", 0, | ||
150 | + qdev_get_gpio_in(gicdev, | ||
151 | + intidbase + VIRTUAL_PMU_IRQ)); | ||
152 | + | ||
153 | + sysbus_connect_irq(gicsbd, i, | ||
154 | + qdev_get_gpio_in(cpudev, ARM_CPU_IRQ)); | ||
155 | + sysbus_connect_irq(gicsbd, i + machine->smp.cpus, | ||
156 | + qdev_get_gpio_in(cpudev, ARM_CPU_FIQ)); | ||
157 | + sysbus_connect_irq(gicsbd, i + 2 * machine->smp.cpus, | ||
158 | + qdev_get_gpio_in(cpudev, ARM_CPU_VIRQ)); | ||
159 | + sysbus_connect_irq(gicsbd, i + 3 * machine->smp.cpus, | ||
160 | + qdev_get_gpio_in(cpudev, ARM_CPU_VFIQ)); | ||
161 | + } | ||
162 | +} | ||
163 | + | ||
164 | static void mps3r_common_init(MachineState *machine) | ||
165 | { | 41 | { |
166 | MPS3RMachineState *mms = MPS3R_MACHINE(machine); | 42 | @@ -XXX,XX +XXX,XX @@ static void arm_set_default_fp_behaviours(float_status *s) |
167 | @@ -XXX,XX +XXX,XX @@ static void mps3r_common_init(MachineState *machine) | 43 | set_float_2nan_prop_rule(float_2nan_prop_s_ab, s); |
168 | MemoryRegion *mr = mr_for_raminfo(mms, ri); | 44 | set_float_3nan_prop_rule(float_3nan_prop_s_cab, s); |
169 | memory_region_add_subregion(sysmem, ri->base, mr); | 45 | set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, s); |
170 | } | 46 | + set_float_default_nan_pattern(0b01000000, s); |
171 | + | ||
172 | + assert(machine->smp.cpus <= MPS3R_CPU_MAX); | ||
173 | + for (int i = 0; i < machine->smp.cpus; i++) { | ||
174 | + g_autofree char *sysmem_name = g_strdup_printf("cpu-%d-memory", i); | ||
175 | + g_autofree char *ramname = g_strdup_printf("cpu-%d-memory", i); | ||
176 | + g_autofree char *alias_name = g_strdup_printf("sysmem-alias-%d", i); | ||
177 | + | ||
178 | + /* | ||
179 | + * Each CPU has some private RAM/peripherals, so create the container | ||
180 | + * which will house those, with the whole-machine system memory being | ||
181 | + * used where there's no CPU-specific device. Note that we need the | ||
182 | + * sysmem_alias aliases because we can't put one MR (the original | ||
183 | + * 'sysmem') into more than one other MR. | ||
184 | + */ | ||
185 | + memory_region_init(&mms->cpu_sysmem[i], OBJECT(machine), | ||
186 | + sysmem_name, UINT64_MAX); | ||
187 | + memory_region_init_alias(&mms->sysmem_alias[i], OBJECT(machine), | ||
188 | + alias_name, sysmem, 0, UINT64_MAX); | ||
189 | + memory_region_add_subregion_overlap(&mms->cpu_sysmem[i], 0, | ||
190 | + &mms->sysmem_alias[i], -1); | ||
191 | + | ||
192 | + mms->cpu[i] = object_new(machine->cpu_type); | ||
193 | + object_property_set_link(mms->cpu[i], "memory", | ||
194 | + OBJECT(&mms->cpu_sysmem[i]), &error_abort); | ||
195 | + object_property_set_int(mms->cpu[i], "reset-cbar", | ||
196 | + PERIPHBASE, &error_abort); | ||
197 | + qdev_realize(DEVICE(mms->cpu[i]), NULL, &error_fatal); | ||
198 | + object_unref(mms->cpu[i]); | ||
199 | + | ||
200 | + /* Per-CPU RAM */ | ||
201 | + memory_region_init_ram(&mms->cpu_ram[i], NULL, ramname, | ||
202 | + 0x1000, &error_fatal); | ||
203 | + memory_region_add_subregion(&mms->cpu_sysmem[i], 0xe7c01000, | ||
204 | + &mms->cpu_ram[i]); | ||
205 | + } | ||
206 | + | ||
207 | + create_gic(mms, sysmem); | ||
208 | + | ||
209 | + mms->bootinfo.ram_size = machine->ram_size; | ||
210 | + mms->bootinfo.board_id = -1; | ||
211 | + mms->bootinfo.loader_start = mmc->loader_start; | ||
212 | + mms->bootinfo.write_secondary_boot = mps3r_write_secondary_boot; | ||
213 | + mms->bootinfo.secondary_cpu_reset_hook = mps3r_secondary_cpu_reset; | ||
214 | + arm_load_kernel(ARM_CPU(mms->cpu[0]), machine, &mms->bootinfo); | ||
215 | } | 47 | } |
216 | 48 | ||
217 | static void mps3r_set_default_ram_info(MPS3RMachineClass *mmc) | 49 | static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque) |
218 | @@ -XXX,XX +XXX,XX @@ static void mps3r_set_default_ram_info(MPS3RMachineClass *mmc) | ||
219 | /* Found the entry for "system memory" */ | ||
220 | mc->default_ram_size = p->size; | ||
221 | mc->default_ram_id = p->name; | ||
222 | + mmc->loader_start = p->base; | ||
223 | return; | ||
224 | } | ||
225 | } | ||
226 | @@ -XXX,XX +XXX,XX @@ static void mps3r_an536_class_init(ObjectClass *oc, void *data) | ||
227 | }; | ||
228 | |||
229 | mc->desc = "ARM MPS3 with AN536 FPGA image for Cortex-R52"; | ||
230 | - mc->default_cpus = 2; | ||
231 | - mc->min_cpus = mc->default_cpus; | ||
232 | - mc->max_cpus = mc->default_cpus; | ||
233 | + /* | ||
234 | + * In the real FPGA image there are always two cores, but the standard | ||
235 | + * initial setting for the SCC SYSCON 0x000 register is 0x21, meaning | ||
236 | + * that the second core is held in reset and halted. Many images built for | ||
237 | + * the board do not expect the second core to run at startup (especially | ||
238 | + * since on the real FPGA image it is not possible to use LDREX/STREX | ||
239 | + * in RAM between the two cores, so a true SMP setup isn't supported). | ||
240 | + * | ||
241 | + * As QEMU's equivalent of this, we support both -smp 1 and -smp 2, | ||
242 | + * with the default being -smp 1. This seems a more intuitive UI for | ||
243 | + * QEMU users than, for instance, having a machine property to allow | ||
244 | + * the user to set the initial value of the SYSCON 0x000 register. | ||
245 | + */ | ||
246 | + mc->default_cpus = 1; | ||
247 | + mc->min_cpus = 1; | ||
248 | + mc->max_cpus = 2; | ||
249 | mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-r52"); | ||
250 | mc->valid_cpu_types = valid_cpu_types; | ||
251 | mmc->raminfo = an536_raminfo; | ||
252 | -- | 50 | -- |
253 | 2.34.1 | 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 | Add documentation for the mps3-an536 board type. | 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 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Message-id: 20240206132931.38376-14-peter.maydell@linaro.org | 8 | Message-id: 20241202131347.498124-44-peter.maydell@linaro.org |
6 | --- | 9 | --- |
7 | docs/system/arm/mps2.rst | 37 ++++++++++++++++++++++++++++++++++--- | 10 | target/mips/fpu_helper.h | 7 +++++++ |
8 | 1 file changed, 34 insertions(+), 3 deletions(-) | 11 | target/mips/msa.c | 3 +++ |
12 | 2 files changed, 10 insertions(+) | ||
9 | 13 | ||
10 | diff --git a/docs/system/arm/mps2.rst b/docs/system/arm/mps2.rst | 14 | diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h |
11 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
12 | --- a/docs/system/arm/mps2.rst | 16 | --- a/target/mips/fpu_helper.h |
13 | +++ b/docs/system/arm/mps2.rst | 17 | +++ b/target/mips/fpu_helper.h |
14 | @@ -XXX,XX +XXX,XX @@ | 18 | @@ -XXX,XX +XXX,XX @@ static inline void restore_snan_bit_mode(CPUMIPSState *env) |
15 | -Arm MPS2 and MPS3 boards (``mps2-an385``, ``mps2-an386``, ``mps2-an500``, ``mps2-an505``, ``mps2-an511``, ``mps2-an521``, ``mps3-an524``, ``mps3-an547``) | 19 | set_float_infzeronan_rule(izn_rule, &env->active_fpu.fp_status); |
16 | -========================================================================================================================================================= | 20 | nan3_rule = nan2008 ? float_3nan_prop_s_cab : float_3nan_prop_s_abc; |
17 | +Arm MPS2 and MPS3 boards (``mps2-an385``, ``mps2-an386``, ``mps2-an500``, ``mps2-an505``, ``mps2-an511``, ``mps2-an521``, ``mps3-an524``, ``mps3-an536``, ``mps3-an547``) | 21 | set_float_3nan_prop_rule(nan3_rule, &env->active_fpu.fp_status); |
18 | +========================================================================================================================================================================= | 22 | + /* |
19 | 23 | + * With nan2008, the default NaN value has the sign bit clear and the | |
20 | -These board models all use Arm M-profile CPUs. | 24 | + * frac msb set; with the older mode, the sign bit is clear, and all |
21 | +These board models use Arm M-profile or R-profile CPUs. | 25 | + * frac bits except the msb are set. |
22 | 26 | + */ | |
23 | The Arm MPS2, MPS2+ and MPS3 dev boards are FPGA based (the 2+ has a | 27 | + set_float_default_nan_pattern(nan2008 ? 0b01000000 : 0b00111111, |
24 | bigger FPGA but is otherwise the same as the 2; the 3 has a bigger | 28 | + &env->active_fpu.fp_status); |
25 | @@ -XXX,XX +XXX,XX @@ FPGA image. | 29 | |
26 | 30 | } | |
27 | QEMU models the following FPGA images: | 31 | |
28 | 32 | diff --git a/target/mips/msa.c b/target/mips/msa.c | |
29 | +FPGA images using M-profile CPUs: | 33 | index XXXXXXX..XXXXXXX 100644 |
30 | + | 34 | --- a/target/mips/msa.c |
31 | ``mps2-an385`` | 35 | +++ b/target/mips/msa.c |
32 | Cortex-M3 as documented in Arm Application Note AN385 | 36 | @@ -XXX,XX +XXX,XX @@ void msa_reset(CPUMIPSState *env) |
33 | ``mps2-an386`` | 37 | /* Inf * 0 + NaN returns the input NaN */ |
34 | @@ -XXX,XX +XXX,XX @@ QEMU models the following FPGA images: | 38 | set_float_infzeronan_rule(float_infzeronan_dnan_never, |
35 | ``mps3-an547`` | 39 | &env->active_tc.msa_fp_status); |
36 | Cortex-M55 on an MPS3, as documented in Arm Application Note AN547 | 40 | + /* Default NaN: sign bit clear, frac msb set */ |
37 | 41 | + set_float_default_nan_pattern(0b01000000, | |
38 | +FPGA images using R-profile CPUs: | 42 | + &env->active_tc.msa_fp_status); |
39 | + | 43 | } |
40 | +``mps3-an536`` | ||
41 | + Dual Cortex-R52 on an MPS3, as documented in Arm Application Note AN536 | ||
42 | + | ||
43 | Differences between QEMU and real hardware: | ||
44 | |||
45 | - AN385/AN386 remapping of low 16K of memory to either ZBT SSRAM1 or to | ||
46 | @@ -XXX,XX +XXX,XX @@ Differences between QEMU and real hardware: | ||
47 | flash, but only as simple ROM, so attempting to rewrite the flash | ||
48 | from the guest will fail | ||
49 | - QEMU does not model the USB controller in MPS3 boards | ||
50 | +- AN536 does not support runtime control of CPU reset and halt via | ||
51 | + the SCC CFG_REG0 register. | ||
52 | +- AN536 does not support enabling or disabling the flash and ATCM | ||
53 | + interfaces via the SCC CFG_REG1 register. | ||
54 | +- AN536 does not support setting of the initial vector table | ||
55 | + base address via the SCC CFG_REG6 and CFG_REG7 register config, | ||
56 | + and does not provide a mechanism for specifying these values at | ||
57 | + startup, so all guest images must be built to start from TCM | ||
58 | + (i.e. to expect the interrupt vector base at 0 from reset). | ||
59 | +- AN536 defaults to only creating a single CPU; this is the equivalent | ||
60 | + of the way the real FPGA image usually runs with the second Cortex-R52 | ||
61 | + held in halt via the initial SCC CFG_REG0 register setting. You can | ||
62 | + create the second CPU with ``-smp 2``; both CPUs will then start | ||
63 | + execution immediately on startup. | ||
64 | + | ||
65 | +Note that for the AN536 the first UART is accessible only by | ||
66 | +CPU0, and the second UART is accessible only by CPU1. The | ||
67 | +first UART accessible shared between both CPUs is the third | ||
68 | +UART. Guest software might therefore be built to use either | ||
69 | +the first UART or the third UART; if you don't see any output | ||
70 | +from the UART you are looking at, try one of the others. | ||
71 | +(Even if the AN536 machine is started with a single CPU and so | ||
72 | +no "CPU1-only UART", the UART numbering remains the same, | ||
73 | +with the third UART being the first of the shared ones.) | ||
74 | |||
75 | Machine-specific options | ||
76 | """""""""""""""""""""""" | ||
77 | -- | 44 | -- |
78 | 2.34.1 | 45 | 2.34.1 |
79 | |||
80 | diff view generated by jsdifflib |
1 | We support two different encodings for the AArch32 IMPDEF | 1 | Set the default NaN pattern explicitly for openrisc. |
---|---|---|---|
2 | CBAR register -- older cores like the Cortex A9, A7, A15 | ||
3 | have this at 4, c15, c0, 0; newer cores like the | ||
4 | Cortex A35, A53, A57 and A72 have it at 1 c15 c0 0. | ||
5 | |||
6 | When we implemented this we picked which encoding to | ||
7 | use based on whether the CPU set ARM_FEATURE_AARCH64. | ||
8 | However this isn't right for three cases: | ||
9 | * the qemu-system-arm 'max' CPU, which is supposed to be | ||
10 | a variant on a Cortex-A57; it ought to use the same | ||
11 | encoding the A57 does and which the AArch64 'max' | ||
12 | exposes to AArch32 guest code | ||
13 | * the Cortex-R52, which is AArch32-only but has the CBAR | ||
14 | at the newer encoding (and where we incorrectly are | ||
15 | not yet setting ARM_FEATURE_CBAR_RO anyway) | ||
16 | * any possible future support for other v8 AArch32 | ||
17 | only CPUs, or for supporting "boot the CPU into | ||
18 | AArch32 mode" on our existing cores like the A57 etc | ||
19 | |||
20 | Make the decision of the encoding be based on whether | ||
21 | the CPU implements the ARM_FEATURE_V8 flag instead. | ||
22 | |||
23 | This changes the behaviour only for the qemu-system-arm | ||
24 | '-cpu max'. We don't expect anybody to be relying on the | ||
25 | old behaviour because: | ||
26 | * it's not what the real hardware Cortex-A57 does | ||
27 | (and that's what our ID register claims we are) | ||
28 | * we don't implement the memory-mapped GICv3 support | ||
29 | which is the only thing that exists at the peripheral | ||
30 | base address pointed to by the register | ||
31 | 2 | ||
32 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
33 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
34 | Message-id: 20240206132931.38376-2-peter.maydell@linaro.org | 5 | Message-id: 20241202131347.498124-45-peter.maydell@linaro.org |
35 | --- | 6 | --- |
36 | target/arm/helper.c | 2 +- | 7 | target/openrisc/cpu.c | 2 ++ |
37 | 1 file changed, 1 insertion(+), 1 deletion(-) | 8 | 1 file changed, 2 insertions(+) |
38 | 9 | ||
39 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 10 | diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c |
40 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
41 | --- a/target/arm/helper.c | 12 | --- a/target/openrisc/cpu.c |
42 | +++ b/target/arm/helper.c | 13 | +++ b/target/openrisc/cpu.c |
43 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | 14 | @@ -XXX,XX +XXX,XX @@ static void openrisc_cpu_reset_hold(Object *obj, ResetType type) |
44 | * AArch64 cores we might need to add a specific feature flag | 15 | */ |
45 | * to indicate cores with "flavour 2" CBAR. | 16 | set_float_2nan_prop_rule(float_2nan_prop_x87, &cpu->env.fp_status); |
46 | */ | 17 | |
47 | - if (arm_feature(env, ARM_FEATURE_AARCH64)) { | 18 | + /* Default NaN: sign bit clear, frac msb set */ |
48 | + if (arm_feature(env, ARM_FEATURE_V8)) { | 19 | + set_float_default_nan_pattern(0b01000000, &cpu->env.fp_status); |
49 | /* 32 bit view is [31:18] 0...0 [43:32]. */ | 20 | |
50 | uint32_t cbar32 = (extract64(cpu->reset_cbar, 18, 14) << 18) | 21 | #ifndef CONFIG_USER_ONLY |
51 | | extract64(cpu->reset_cbar, 32, 12); | 22 | cpu->env.picmr = 0x00000000; |
52 | -- | 23 | -- |
53 | 2.34.1 | 24 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Luc Michel <luc.michel@amd.com> | 1 | Set the default NaN pattern explicitly for ppc. |
---|---|---|---|
2 | 2 | ||
3 | An access fault is raised when the Access Flag is not set in the | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | looked-up PTE and the AFFD field is not set in the corresponding context | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | descriptor. This was already implemented for stage 2. Implement it for | 5 | Message-id: 20241202131347.498124-46-peter.maydell@linaro.org |
6 | stage 1 as well. | 6 | --- |
7 | target/ppc/cpu_init.c | 4 ++++ | ||
8 | 1 file changed, 4 insertions(+) | ||
7 | 9 | ||
8 | Signed-off-by: Luc Michel <luc.michel@amd.com> | 10 | diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c |
9 | Reviewed-by: Mostafa Saleh <smostafa@google.com> | ||
10 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
11 | Tested-by: Mostafa Saleh <smostafa@google.com> | ||
12 | Message-id: 20240213082211.3330400-1-luc.michel@amd.com | ||
13 | [PMM: tweaked comment text] | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
15 | --- | ||
16 | hw/arm/smmuv3-internal.h | 1 + | ||
17 | include/hw/arm/smmu-common.h | 1 + | ||
18 | hw/arm/smmu-common.c | 11 +++++++++++ | ||
19 | hw/arm/smmuv3.c | 1 + | ||
20 | 4 files changed, 14 insertions(+) | ||
21 | |||
22 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h | ||
23 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/arm/smmuv3-internal.h | 12 | --- a/target/ppc/cpu_init.c |
25 | +++ b/hw/arm/smmuv3-internal.h | 13 | +++ b/target/ppc/cpu_init.c |
26 | @@ -XXX,XX +XXX,XX @@ static inline int pa_range(STE *ste) | 14 | @@ -XXX,XX +XXX,XX @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type) |
27 | #define CD_EPD(x, sel) extract32((x)->word[0], (16 * (sel)) + 14, 1) | 15 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); |
28 | #define CD_ENDI(x) extract32((x)->word[0], 15, 1) | 16 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->vec_status); |
29 | #define CD_IPS(x) extract32((x)->word[1], 0 , 3) | 17 | |
30 | +#define CD_AFFD(x) extract32((x)->word[1], 3 , 1) | 18 | + /* Default NaN: sign bit clear, set frac msb */ |
31 | #define CD_TBI(x) extract32((x)->word[1], 6 , 2) | 19 | + set_float_default_nan_pattern(0b01000000, &env->fp_status); |
32 | #define CD_HD(x) extract32((x)->word[1], 10 , 1) | 20 | + set_float_default_nan_pattern(0b01000000, &env->vec_status); |
33 | #define CD_HA(x) extract32((x)->word[1], 11 , 1) | ||
34 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/include/hw/arm/smmu-common.h | ||
37 | +++ b/include/hw/arm/smmu-common.h | ||
38 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUTransCfg { | ||
39 | bool disabled; /* smmu is disabled */ | ||
40 | bool bypassed; /* translation is bypassed */ | ||
41 | bool aborted; /* translation is aborted */ | ||
42 | + bool affd; /* AF fault disable */ | ||
43 | uint32_t iotlb_hits; /* counts IOTLB hits */ | ||
44 | uint32_t iotlb_misses; /* counts IOTLB misses*/ | ||
45 | /* Used by stage-1 only. */ | ||
46 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/arm/smmu-common.c | ||
49 | +++ b/hw/arm/smmu-common.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static int smmu_ptw_64_s1(SMMUTransCfg *cfg, | ||
51 | pte_addr, pte, iova, gpa, | ||
52 | block_size >> 20); | ||
53 | } | ||
54 | + | 21 | + |
55 | + /* | 22 | for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) { |
56 | + * QEMU does not currently implement HTTU, so if AFFD and PTE.AF | 23 | ppc_spr_t *spr = &env->spr_cb[i]; |
57 | + * are 0 we take an Access flag fault. (5.4. Context Descriptor) | ||
58 | + * An Access flag fault takes priority over a Permission fault. | ||
59 | + */ | ||
60 | + if (!PTE_AF(pte) && !cfg->affd) { | ||
61 | + info->type = SMMU_PTW_ERR_ACCESS; | ||
62 | + goto error; | ||
63 | + } | ||
64 | + | ||
65 | ap = PTE_AP(pte); | ||
66 | if (is_permission_fault(ap, perm)) { | ||
67 | info->type = SMMU_PTW_ERR_PERMISSION; | ||
68 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/arm/smmuv3.c | ||
71 | +++ b/hw/arm/smmuv3.c | ||
72 | @@ -XXX,XX +XXX,XX @@ static int decode_cd(SMMUTransCfg *cfg, CD *cd, SMMUEventInfo *event) | ||
73 | cfg->oas = MIN(oas2bits(SMMU_IDR5_OAS), cfg->oas); | ||
74 | cfg->tbi = CD_TBI(cd); | ||
75 | cfg->asid = CD_ASID(cd); | ||
76 | + cfg->affd = CD_AFFD(cd); | ||
77 | |||
78 | trace_smmuv3_decode_cd(cfg->oas); | ||
79 | 24 | ||
80 | -- | 25 | -- |
81 | 2.34.1 | 26 | 2.34.1 | diff view generated by jsdifflib |
1 | This board has a lot of UARTs: there is one UART per CPU in the | 1 | Set the default NaN pattern explicitly for sh4. Note that sh4 |
---|---|---|---|
2 | per-CPU peripheral part of the address map, whose interrupts are | 2 | is one of the only three targets (the others being HPPA and |
3 | connected as per-CPU interrupt lines. Then there are 4 UARTs in the | 3 | sometimes MIPS) that has snan_bit_is_one set. |
4 | normal part of the peripheral space, whose interrupts are shared | ||
5 | peripheral interrupts. | ||
6 | |||
7 | Connect and wire them all up; this involves some OR gates where | ||
8 | multiple overflow interrupts are wired into one GIC input. | ||
9 | 4 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
12 | Message-id: 20240206132931.38376-11-peter.maydell@linaro.org | 7 | Message-id: 20241202131347.498124-47-peter.maydell@linaro.org |
13 | --- | 8 | --- |
14 | hw/arm/mps3r.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++ | 9 | target/sh4/cpu.c | 2 ++ |
15 | 1 file changed, 94 insertions(+) | 10 | 1 file changed, 2 insertions(+) |
16 | 11 | ||
17 | diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c | 12 | diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c |
18 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/mps3r.c | 14 | --- a/target/sh4/cpu.c |
20 | +++ b/hw/arm/mps3r.c | 15 | +++ b/target/sh4/cpu.c |
21 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ static void superh_cpu_reset_hold(Object *obj, ResetType type) |
22 | #include "qapi/qmp/qlist.h" | 17 | set_flush_to_zero(1, &env->fp_status); |
23 | #include "exec/address-spaces.h" | 18 | #endif |
24 | #include "cpu.h" | 19 | set_default_nan_mode(1, &env->fp_status); |
25 | +#include "sysemu/sysemu.h" | 20 | + /* sign bit clear, set all frac bits other than msb */ |
26 | #include "hw/boards.h" | 21 | + set_float_default_nan_pattern(0b00111111, &env->fp_status); |
27 | +#include "hw/or-irq.h" | ||
28 | #include "hw/qdev-properties.h" | ||
29 | #include "hw/arm/boot.h" | ||
30 | #include "hw/arm/bsa.h" | ||
31 | +#include "hw/char/cmsdk-apb-uart.h" | ||
32 | #include "hw/intc/arm_gicv3.h" | ||
33 | |||
34 | /* Define the layout of RAM and ROM in a board */ | ||
35 | @@ -XXX,XX +XXX,XX @@ typedef struct RAMInfo { | ||
36 | |||
37 | #define MPS3R_RAM_MAX 9 | ||
38 | #define MPS3R_CPU_MAX 2 | ||
39 | +#define MPS3R_UART_MAX 4 /* shared UART count */ | ||
40 | |||
41 | #define PERIPHBASE 0xf0000000 | ||
42 | #define NUM_SPIS 96 | ||
43 | @@ -XXX,XX +XXX,XX @@ struct MPS3RMachineState { | ||
44 | MemoryRegion sysmem_alias[MPS3R_CPU_MAX]; | ||
45 | MemoryRegion cpu_ram[MPS3R_CPU_MAX]; | ||
46 | GICv3State gic; | ||
47 | + /* per-CPU UARTs followed by the shared UARTs */ | ||
48 | + CMSDKAPBUART uart[MPS3R_CPU_MAX + MPS3R_UART_MAX]; | ||
49 | + OrIRQState cpu_uart_oflow[MPS3R_CPU_MAX]; | ||
50 | + OrIRQState uart_oflow; | ||
51 | }; | ||
52 | |||
53 | #define TYPE_MPS3R_MACHINE "mps3r" | ||
54 | @@ -XXX,XX +XXX,XX @@ struct MPS3RMachineState { | ||
55 | |||
56 | OBJECT_DECLARE_TYPE(MPS3RMachineState, MPS3RMachineClass, MPS3R_MACHINE) | ||
57 | |||
58 | +/* | ||
59 | + * Main clock frequency CLK in Hz (50MHz). In the image there are also | ||
60 | + * ACLK, MCLK, GPUCLK and PERIPHCLK at the same frequency; for our | ||
61 | + * model we just roll them all into one. | ||
62 | + */ | ||
63 | +#define CLK_FRQ 50000000 | ||
64 | + | ||
65 | static const RAMInfo an536_raminfo[] = { | ||
66 | { | ||
67 | .name = "ATCM", | ||
68 | @@ -XXX,XX +XXX,XX @@ static void create_gic(MPS3RMachineState *mms, MemoryRegion *sysmem) | ||
69 | } | ||
70 | } | 22 | } |
71 | 23 | ||
72 | +/* | 24 | static void superh_cpu_disas_set_info(CPUState *cpu, disassemble_info *info) |
73 | + * Create UART uartno, and map it into the MemoryRegion mem at address baseaddr. | ||
74 | + * The qemu_irq arguments are where we connect the various IRQs from the UART. | ||
75 | + */ | ||
76 | +static void create_uart(MPS3RMachineState *mms, int uartno, MemoryRegion *mem, | ||
77 | + hwaddr baseaddr, qemu_irq txirq, qemu_irq rxirq, | ||
78 | + qemu_irq txoverirq, qemu_irq rxoverirq, | ||
79 | + qemu_irq combirq) | ||
80 | +{ | ||
81 | + g_autofree char *s = g_strdup_printf("uart%d", uartno); | ||
82 | + SysBusDevice *sbd; | ||
83 | + | ||
84 | + assert(uartno < ARRAY_SIZE(mms->uart)); | ||
85 | + object_initialize_child(OBJECT(mms), s, &mms->uart[uartno], | ||
86 | + TYPE_CMSDK_APB_UART); | ||
87 | + qdev_prop_set_uint32(DEVICE(&mms->uart[uartno]), "pclk-frq", CLK_FRQ); | ||
88 | + qdev_prop_set_chr(DEVICE(&mms->uart[uartno]), "chardev", serial_hd(uartno)); | ||
89 | + sbd = SYS_BUS_DEVICE(&mms->uart[uartno]); | ||
90 | + sysbus_realize(sbd, &error_fatal); | ||
91 | + memory_region_add_subregion(mem, baseaddr, | ||
92 | + sysbus_mmio_get_region(sbd, 0)); | ||
93 | + sysbus_connect_irq(sbd, 0, txirq); | ||
94 | + sysbus_connect_irq(sbd, 1, rxirq); | ||
95 | + sysbus_connect_irq(sbd, 2, txoverirq); | ||
96 | + sysbus_connect_irq(sbd, 3, rxoverirq); | ||
97 | + sysbus_connect_irq(sbd, 4, combirq); | ||
98 | +} | ||
99 | + | ||
100 | static void mps3r_common_init(MachineState *machine) | ||
101 | { | ||
102 | MPS3RMachineState *mms = MPS3R_MACHINE(machine); | ||
103 | MPS3RMachineClass *mmc = MPS3R_MACHINE_GET_CLASS(mms); | ||
104 | MemoryRegion *sysmem = get_system_memory(); | ||
105 | + DeviceState *gicdev; | ||
106 | |||
107 | for (const RAMInfo *ri = mmc->raminfo; ri->name; ri++) { | ||
108 | MemoryRegion *mr = mr_for_raminfo(mms, ri); | ||
109 | @@ -XXX,XX +XXX,XX @@ static void mps3r_common_init(MachineState *machine) | ||
110 | } | ||
111 | |||
112 | create_gic(mms, sysmem); | ||
113 | + gicdev = DEVICE(&mms->gic); | ||
114 | + | ||
115 | + /* | ||
116 | + * UARTs 0 and 1 are per-CPU; their interrupts are wired to | ||
117 | + * the relevant CPU's PPI 0..3, aka INTID 16..19 | ||
118 | + */ | ||
119 | + for (int i = 0; i < machine->smp.cpus; i++) { | ||
120 | + int intidbase = NUM_SPIS + i * GIC_INTERNAL; | ||
121 | + g_autofree char *s = g_strdup_printf("cpu-uart-oflow-orgate%d", i); | ||
122 | + DeviceState *orgate; | ||
123 | + | ||
124 | + /* The two overflow IRQs from the UART are ORed together into PPI 3 */ | ||
125 | + object_initialize_child(OBJECT(mms), s, &mms->cpu_uart_oflow[i], | ||
126 | + TYPE_OR_IRQ); | ||
127 | + orgate = DEVICE(&mms->cpu_uart_oflow[i]); | ||
128 | + qdev_prop_set_uint32(orgate, "num-lines", 2); | ||
129 | + qdev_realize(orgate, NULL, &error_fatal); | ||
130 | + qdev_connect_gpio_out(orgate, 0, | ||
131 | + qdev_get_gpio_in(gicdev, intidbase + 19)); | ||
132 | + | ||
133 | + create_uart(mms, i, &mms->cpu_sysmem[i], 0xe7c00000, | ||
134 | + qdev_get_gpio_in(gicdev, intidbase + 17), /* tx */ | ||
135 | + qdev_get_gpio_in(gicdev, intidbase + 16), /* rx */ | ||
136 | + qdev_get_gpio_in(orgate, 0), /* txover */ | ||
137 | + qdev_get_gpio_in(orgate, 1), /* rxover */ | ||
138 | + qdev_get_gpio_in(gicdev, intidbase + 18) /* combined */); | ||
139 | + } | ||
140 | + /* | ||
141 | + * UARTs 2 to 5 are whole-system; all overflow IRQs are ORed | ||
142 | + * together into IRQ 17 | ||
143 | + */ | ||
144 | + object_initialize_child(OBJECT(mms), "uart-oflow-orgate", | ||
145 | + &mms->uart_oflow, TYPE_OR_IRQ); | ||
146 | + qdev_prop_set_uint32(DEVICE(&mms->uart_oflow), "num-lines", | ||
147 | + MPS3R_UART_MAX * 2); | ||
148 | + qdev_realize(DEVICE(&mms->uart_oflow), NULL, &error_fatal); | ||
149 | + qdev_connect_gpio_out(DEVICE(&mms->uart_oflow), 0, | ||
150 | + qdev_get_gpio_in(gicdev, 17)); | ||
151 | + | ||
152 | + for (int i = 0; i < MPS3R_UART_MAX; i++) { | ||
153 | + hwaddr baseaddr = 0xe0205000 + i * 0x1000; | ||
154 | + int rxirq = 5 + i * 2, txirq = 6 + i * 2, combirq = 13 + i; | ||
155 | + | ||
156 | + create_uart(mms, i + MPS3R_CPU_MAX, sysmem, baseaddr, | ||
157 | + qdev_get_gpio_in(gicdev, txirq), | ||
158 | + qdev_get_gpio_in(gicdev, rxirq), | ||
159 | + qdev_get_gpio_in(DEVICE(&mms->uart_oflow), i * 2), | ||
160 | + qdev_get_gpio_in(DEVICE(&mms->uart_oflow), i * 2 + 1), | ||
161 | + qdev_get_gpio_in(gicdev, combirq)); | ||
162 | + } | ||
163 | |||
164 | mms->bootinfo.ram_size = machine->ram_size; | ||
165 | mms->bootinfo.board_id = -1; | ||
166 | -- | 25 | -- |
167 | 2.34.1 | 26 | 2.34.1 |
168 | |||
169 | diff view generated by jsdifflib |
1 | Add the Cortex-R52 IMPDEF sysregs, by defining them here and | 1 | Set the default NaN pattern explicitly for rx. |
---|---|---|---|
2 | also by enabling the AUXCR feature which defines the ACTLR | ||
3 | and HACTLR registers. As is our usual practice, we make these | ||
4 | simple reads-as-zero stubs for now. | ||
5 | 2 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
8 | Message-id: 20240206132931.38376-4-peter.maydell@linaro.org | 5 | Message-id: 20241202131347.498124-48-peter.maydell@linaro.org |
9 | --- | 6 | --- |
10 | target/arm/tcg/cpu32.c | 108 +++++++++++++++++++++++++++++++++++++++++ | 7 | target/rx/cpu.c | 2 ++ |
11 | 1 file changed, 108 insertions(+) | 8 | 1 file changed, 2 insertions(+) |
12 | 9 | ||
13 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c | 10 | diff --git a/target/rx/cpu.c b/target/rx/cpu.c |
14 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/tcg/cpu32.c | 12 | --- a/target/rx/cpu.c |
16 | +++ b/target/arm/tcg/cpu32.c | 13 | +++ b/target/rx/cpu.c |
17 | @@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj) | 14 | @@ -XXX,XX +XXX,XX @@ static void rx_cpu_reset_hold(Object *obj, ResetType type) |
18 | define_arm_cp_regs(cpu, cortexr5_cp_reginfo); | 15 | * then prefer dest over source", which is float_2nan_prop_s_ab. |
16 | */ | ||
17 | set_float_2nan_prop_rule(float_2nan_prop_x87, &env->fp_status); | ||
18 | + /* Default NaN value: sign bit clear, set frac msb */ | ||
19 | + set_float_default_nan_pattern(0b01000000, &env->fp_status); | ||
19 | } | 20 | } |
20 | 21 | ||
21 | +static const ARMCPRegInfo cortex_r52_cp_reginfo[] = { | 22 | static ObjectClass *rx_cpu_class_by_name(const char *cpu_model) |
22 | + { .name = "CPUACTLR", .cp = 15, .opc1 = 0, .crm = 15, | ||
23 | + .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, | ||
24 | + { .name = "IMP_ATCMREGIONR", | ||
25 | + .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0, | ||
26 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
27 | + { .name = "IMP_BTCMREGIONR", | ||
28 | + .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 1, | ||
29 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
30 | + { .name = "IMP_CTCMREGIONR", | ||
31 | + .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 2, | ||
32 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
33 | + { .name = "IMP_CSCTLR", | ||
34 | + .cp = 15, .opc1 = 1, .crn = 9, .crm = 1, .opc2 = 0, | ||
35 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
36 | + { .name = "IMP_BPCTLR", | ||
37 | + .cp = 15, .opc1 = 1, .crn = 9, .crm = 1, .opc2 = 1, | ||
38 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
39 | + { .name = "IMP_MEMPROTCLR", | ||
40 | + .cp = 15, .opc1 = 1, .crn = 9, .crm = 1, .opc2 = 2, | ||
41 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
42 | + { .name = "IMP_SLAVEPCTLR", | ||
43 | + .cp = 15, .opc1 = 0, .crn = 11, .crm = 0, .opc2 = 0, | ||
44 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
45 | + { .name = "IMP_PERIPHREGIONR", | ||
46 | + .cp = 15, .opc1 = 0, .crn = 15, .crm = 0, .opc2 = 0, | ||
47 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
48 | + { .name = "IMP_FLASHIFREGIONR", | ||
49 | + .cp = 15, .opc1 = 0, .crn = 15, .crm = 0, .opc2 = 1, | ||
50 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
51 | + { .name = "IMP_BUILDOPTR", | ||
52 | + .cp = 15, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 0, | ||
53 | + .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
54 | + { .name = "IMP_PINOPTR", | ||
55 | + .cp = 15, .opc1 = 0, .crn = 15, .crm = 2, .opc2 = 7, | ||
56 | + .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
57 | + { .name = "IMP_QOSR", | ||
58 | + .cp = 15, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 1, | ||
59 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
60 | + { .name = "IMP_BUSTIMEOUTR", | ||
61 | + .cp = 15, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 2, | ||
62 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
63 | + { .name = "IMP_INTMONR", | ||
64 | + .cp = 15, .opc1 = 1, .crn = 15, .crm = 3, .opc2 = 4, | ||
65 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
66 | + { .name = "IMP_ICERR0", | ||
67 | + .cp = 15, .opc1 = 2, .crn = 15, .crm = 0, .opc2 = 0, | ||
68 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
69 | + { .name = "IMP_ICERR1", | ||
70 | + .cp = 15, .opc1 = 2, .crn = 15, .crm = 0, .opc2 = 1, | ||
71 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
72 | + { .name = "IMP_DCERR0", | ||
73 | + .cp = 15, .opc1 = 2, .crn = 15, .crm = 1, .opc2 = 0, | ||
74 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
75 | + { .name = "IMP_DCERR1", | ||
76 | + .cp = 15, .opc1 = 2, .crn = 15, .crm = 1, .opc2 = 1, | ||
77 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
78 | + { .name = "IMP_TCMERR0", | ||
79 | + .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 0, | ||
80 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
81 | + { .name = "IMP_TCMERR1", | ||
82 | + .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 1, | ||
83 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
84 | + { .name = "IMP_TCMSYNDR0", | ||
85 | + .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 2, | ||
86 | + .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
87 | + { .name = "IMP_TCMSYNDR1", | ||
88 | + .cp = 15, .opc1 = 2, .crn = 15, .crm = 2, .opc2 = 3, | ||
89 | + .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
90 | + { .name = "IMP_FLASHERR0", | ||
91 | + .cp = 15, .opc1 = 2, .crn = 15, .crm = 3, .opc2 = 0, | ||
92 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
93 | + { .name = "IMP_FLASHERR1", | ||
94 | + .cp = 15, .opc1 = 2, .crn = 15, .crm = 3, .opc2 = 1, | ||
95 | + .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
96 | + { .name = "IMP_CDBGDR0", | ||
97 | + .cp = 15, .opc1 = 3, .crn = 15, .crm = 0, .opc2 = 0, | ||
98 | + .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
99 | + { .name = "IMP_CBDGBR1", | ||
100 | + .cp = 15, .opc1 = 3, .crn = 15, .crm = 0, .opc2 = 1, | ||
101 | + .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
102 | + { .name = "IMP_TESTR0", | ||
103 | + .cp = 15, .opc1 = 4, .crn = 15, .crm = 0, .opc2 = 0, | ||
104 | + .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, | ||
105 | + { .name = "IMP_TESTR1", | ||
106 | + .cp = 15, .opc1 = 4, .crn = 15, .crm = 0, .opc2 = 1, | ||
107 | + .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 }, | ||
108 | + { .name = "IMP_CDBGDCI", | ||
109 | + .cp = 15, .opc1 = 0, .crn = 15, .crm = 15, .opc2 = 0, | ||
110 | + .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 }, | ||
111 | + { .name = "IMP_CDBGDCT", | ||
112 | + .cp = 15, .opc1 = 3, .crn = 15, .crm = 2, .opc2 = 0, | ||
113 | + .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 }, | ||
114 | + { .name = "IMP_CDBGICT", | ||
115 | + .cp = 15, .opc1 = 3, .crn = 15, .crm = 2, .opc2 = 1, | ||
116 | + .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 }, | ||
117 | + { .name = "IMP_CDBGDCD", | ||
118 | + .cp = 15, .opc1 = 3, .crn = 15, .crm = 4, .opc2 = 0, | ||
119 | + .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 }, | ||
120 | + { .name = "IMP_CDBGICD", | ||
121 | + .cp = 15, .opc1 = 3, .crn = 15, .crm = 4, .opc2 = 1, | ||
122 | + .access = PL1_W, .type = ARM_CP_NOP, .resetvalue = 0 }, | ||
123 | +}; | ||
124 | + | ||
125 | + | ||
126 | static void cortex_r52_initfn(Object *obj) | ||
127 | { | ||
128 | ARMCPU *cpu = ARM_CPU(obj); | ||
129 | @@ -XXX,XX +XXX,XX @@ static void cortex_r52_initfn(Object *obj) | ||
130 | set_feature(&cpu->env, ARM_FEATURE_NEON); | ||
131 | set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); | ||
132 | set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); | ||
133 | + set_feature(&cpu->env, ARM_FEATURE_AUXCR); | ||
134 | cpu->midr = 0x411fd133; /* r1p3 */ | ||
135 | cpu->revidr = 0x00000000; | ||
136 | cpu->reset_fpsid = 0x41034023; | ||
137 | @@ -XXX,XX +XXX,XX @@ static void cortex_r52_initfn(Object *obj) | ||
138 | |||
139 | cpu->pmsav7_dregion = 16; | ||
140 | cpu->pmsav8r_hdregion = 16; | ||
141 | + | ||
142 | + define_arm_cp_regs(cpu, cortex_r52_cp_reginfo); | ||
143 | } | ||
144 | |||
145 | static void cortex_r5f_initfn(Object *obj) | ||
146 | -- | 23 | -- |
147 | 2.34.1 | 24 | 2.34.1 | diff view generated by jsdifflib |
1 | Currently QEMU will warn if there is a NIC on the board that | 1 | Set the default NaN pattern explicitly for s390x. |
---|---|---|---|
2 | is not connected to a backend. By default the '-nic user' will | ||
3 | get used for all NICs, but if you manually connect a specific | ||
4 | NIC to a specific backend, then the other NICs on the board | ||
5 | have no backend and will be warned about: | ||
6 | |||
7 | qemu-system-arm: warning: nic npcm7xx-emc.1 has no peer | ||
8 | qemu-system-arm: warning: nic npcm-gmac.0 has no peer | ||
9 | qemu-system-arm: warning: nic npcm-gmac.1 has no peer | ||
10 | |||
11 | So suppress those warnings by manually connecting every NIC | ||
12 | on the board to some backend. | ||
13 | 2 | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: David Woodhouse <dwmw@amazon.co.uk> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
16 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 5 | Message-id: 20241202131347.498124-49-peter.maydell@linaro.org |
17 | Message-id: 20240206171231.396392-3-peter.maydell@linaro.org | ||
18 | --- | 6 | --- |
19 | tests/qtest/npcm7xx_emc-test.c | 5 ++++- | 7 | target/s390x/cpu.c | 2 ++ |
20 | 1 file changed, 4 insertions(+), 1 deletion(-) | 8 | 1 file changed, 2 insertions(+) |
21 | 9 | ||
22 | diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c | 10 | diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c |
23 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/tests/qtest/npcm7xx_emc-test.c | 12 | --- a/target/s390x/cpu.c |
25 | +++ b/tests/qtest/npcm7xx_emc-test.c | 13 | +++ b/target/s390x/cpu.c |
26 | @@ -XXX,XX +XXX,XX @@ static int *packet_test_init(int module_num, GString *cmd_line) | 14 | @@ -XXX,XX +XXX,XX @@ static void s390_cpu_reset_hold(Object *obj, ResetType type) |
27 | * KISS and use -nic. The driver accepts 'emc0' and 'emc1' as aliases | 15 | set_float_3nan_prop_rule(float_3nan_prop_s_abc, &env->fpu_status); |
28 | * in the 'model' field to specify the device to match. | 16 | set_float_infzeronan_rule(float_infzeronan_dnan_always, |
29 | */ | 17 | &env->fpu_status); |
30 | - g_string_append_printf(cmd_line, " -nic socket,fd=%d,model=emc%d ", | 18 | + /* Default NaN value: sign bit clear, frac msb set */ |
31 | + g_string_append_printf(cmd_line, " -nic socket,fd=%d,model=emc%d " | 19 | + set_float_default_nan_pattern(0b01000000, &env->fpu_status); |
32 | + "-nic user,model=npcm7xx-emc " | 20 | /* fall through */ |
33 | + "-nic user,model=npcm-gmac " | 21 | case RESET_TYPE_S390_CPU_NORMAL: |
34 | + "-nic user,model=npcm-gmac", | 22 | env->psw.mask &= ~PSW_MASK_RI; |
35 | test_sockets[1], module_num); | ||
36 | |||
37 | g_test_queue_destroy(packet_test_clear, test_sockets); | ||
38 | -- | 23 | -- |
39 | 2.34.1 | 24 | 2.34.1 | diff view generated by jsdifflib |
1 | The patchset adding the GMAC ethernet to this SoC crossed in the | 1 | Set the default NaN pattern explicitly for SPARC, and remove |
---|---|---|---|
2 | mail with the patchset cleaning up the NIC handling. When we | 2 | the ifdef from parts64_default_nan. |
3 | create the GMAC modules we must call qemu_configure_nic_device() | ||
4 | so that the user has the opportunity to use the -nic commandline | ||
5 | option to create a network backend and connect it to the GMACs. | ||
6 | 3 | ||
7 | Add the missing call. | 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(-) | ||
8 | 11 | ||
9 | Fixes: 21e5326a7c ("hw/arm: Add GMAC devices to NPCM7XX SoC") | 12 | diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: David Woodhouse <dwmw@amazon.co.uk> | ||
12 | Message-id: 20240206171231.396392-2-peter.maydell@linaro.org | ||
13 | --- | ||
14 | hw/arm/npcm7xx.c | 1 + | ||
15 | 1 file changed, 1 insertion(+) | ||
16 | |||
17 | diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c | ||
18 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/npcm7xx.c | 14 | --- a/target/sparc/cpu.c |
20 | +++ b/hw/arm/npcm7xx.c | 15 | +++ b/target/sparc/cpu.c |
21 | @@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) | 16 | @@ -XXX,XX +XXX,XX @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp) |
22 | for (i = 0; i < ARRAY_SIZE(s->gmac); i++) { | 17 | set_float_3nan_prop_rule(float_3nan_prop_s_cba, &env->fp_status); |
23 | SysBusDevice *sbd = SYS_BUS_DEVICE(&s->gmac[i]); | 18 | /* For inf * 0 + NaN, return the input NaN */ |
24 | 19 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); | |
25 | + qemu_configure_nic_device(DEVICE(sbd), false, NULL); | 20 | + /* Default NaN value: sign bit clear, all frac bits set */ |
26 | /* | 21 | + set_float_default_nan_pattern(0b01111111, &env->fp_status); |
27 | * The device exists regardless of whether it's connected to a QEMU | 22 | |
28 | * netdev backend. So always instantiate it even if there is no | 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 | ||
29 | -- | 41 | -- |
30 | 2.34.1 | 42 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | Set the default NaN pattern explicitly for xtensa. |
---|---|---|---|
2 | 2 | ||
3 | Share code that creates mtedesc and embeds within simd_desc. | 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 | Cc: qemu-stable@nongnu.org | 10 | diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Tested-by: Gustavo Romero <gustavo.romero@linaro.org> | ||
9 | Message-id: 20240207025210.8837-5-richard.henderson@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | target/arm/tcg/translate-a64.h | 2 ++ | ||
13 | target/arm/tcg/translate-sme.c | 15 +++-------- | ||
14 | target/arm/tcg/translate-sve.c | 47 ++++++++++++++++++---------------- | ||
15 | 3 files changed, 31 insertions(+), 33 deletions(-) | ||
16 | |||
17 | diff --git a/target/arm/tcg/translate-a64.h b/target/arm/tcg/translate-a64.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/tcg/translate-a64.h | 12 | --- a/target/xtensa/cpu.c |
20 | +++ b/target/arm/tcg/translate-a64.h | 13 | +++ b/target/xtensa/cpu.c |
21 | @@ -XXX,XX +XXX,XX @@ bool logic_imm_decode_wmask(uint64_t *result, unsigned int immn, | 14 | @@ -XXX,XX +XXX,XX @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type) |
22 | bool sve_access_check(DisasContext *s); | 15 | /* For inf * 0 + NaN, return the input NaN */ |
23 | bool sme_enabled_check(DisasContext *s); | 16 | set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); |
24 | bool sme_enabled_check_with_svcr(DisasContext *s, unsigned); | 17 | set_no_signaling_nans(!dfpu, &env->fp_status); |
25 | +uint32_t make_svemte_desc(DisasContext *s, unsigned vsz, uint32_t nregs, | 18 | + /* Default NaN value: sign bit clear, set frac msb */ |
26 | + uint32_t msz, bool is_write, uint32_t data); | 19 | + set_float_default_nan_pattern(0b01000000, &env->fp_status); |
27 | 20 | xtensa_use_first_nan(env, !dfpu); | |
28 | /* This function corresponds to CheckStreamingSVEEnabled. */ | ||
29 | static inline bool sme_sm_enabled_check(DisasContext *s) | ||
30 | diff --git a/target/arm/tcg/translate-sme.c b/target/arm/tcg/translate-sme.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | ||
32 | --- a/target/arm/tcg/translate-sme.c | ||
33 | +++ b/target/arm/tcg/translate-sme.c | ||
34 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDST1(DisasContext *s, arg_LDST1 *a) | ||
35 | |||
36 | TCGv_ptr t_za, t_pg; | ||
37 | TCGv_i64 addr; | ||
38 | - int svl, desc = 0; | ||
39 | + uint32_t desc; | ||
40 | bool be = s->be_data == MO_BE; | ||
41 | bool mte = s->mte_active[0]; | ||
42 | |||
43 | @@ -XXX,XX +XXX,XX @@ static bool trans_LDST1(DisasContext *s, arg_LDST1 *a) | ||
44 | tcg_gen_shli_i64(addr, cpu_reg(s, a->rm), a->esz); | ||
45 | tcg_gen_add_i64(addr, addr, cpu_reg_sp(s, a->rn)); | ||
46 | |||
47 | - if (mte) { | ||
48 | - desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s)); | ||
49 | - desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); | ||
50 | - desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); | ||
51 | - desc = FIELD_DP32(desc, MTEDESC, WRITE, a->st); | ||
52 | - desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (1 << a->esz) - 1); | ||
53 | - desc <<= SVE_MTEDESC_SHIFT; | ||
54 | - } else { | ||
55 | + if (!mte) { | ||
56 | addr = clean_data_tbi(s, addr); | ||
57 | } | ||
58 | - svl = streaming_vec_reg_size(s); | ||
59 | - desc = simd_desc(svl, svl, desc); | ||
60 | + | ||
61 | + desc = make_svemte_desc(s, streaming_vec_reg_size(s), 1, a->esz, a->st, 0); | ||
62 | |||
63 | fns[a->esz][be][a->v][mte][a->st](tcg_env, t_za, t_pg, addr, | ||
64 | tcg_constant_i32(desc)); | ||
65 | diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c | ||
66 | index XXXXXXX..XXXXXXX 100644 | ||
67 | --- a/target/arm/tcg/translate-sve.c | ||
68 | +++ b/target/arm/tcg/translate-sve.c | ||
69 | @@ -XXX,XX +XXX,XX @@ static const uint8_t dtype_esz[16] = { | ||
70 | 3, 2, 1, 3 | ||
71 | }; | ||
72 | |||
73 | -static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | ||
74 | - int dtype, uint32_t mte_n, bool is_write, | ||
75 | - gen_helper_gvec_mem *fn) | ||
76 | +uint32_t make_svemte_desc(DisasContext *s, unsigned vsz, uint32_t nregs, | ||
77 | + uint32_t msz, bool is_write, uint32_t data) | ||
78 | { | ||
79 | - unsigned vsz = vec_full_reg_size(s); | ||
80 | - TCGv_ptr t_pg; | ||
81 | uint32_t sizem1; | ||
82 | - int desc = 0; | ||
83 | + uint32_t desc = 0; | ||
84 | |||
85 | - assert(mte_n >= 1 && mte_n <= 4); | ||
86 | - sizem1 = (mte_n << dtype_msz(dtype)) - 1; | ||
87 | + /* Assert all of the data fits, with or without MTE enabled. */ | ||
88 | + assert(nregs >= 1 && nregs <= 4); | ||
89 | + sizem1 = (nregs << msz) - 1; | ||
90 | assert(sizem1 <= R_MTEDESC_SIZEM1_MASK >> R_MTEDESC_SIZEM1_SHIFT); | ||
91 | + assert(data < 1u << SVE_MTEDESC_SHIFT); | ||
92 | + | ||
93 | if (s->mte_active[0]) { | ||
94 | desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s)); | ||
95 | desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); | ||
96 | @@ -XXX,XX +XXX,XX @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | ||
97 | desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); | ||
98 | desc = FIELD_DP32(desc, MTEDESC, SIZEM1, sizem1); | ||
99 | desc <<= SVE_MTEDESC_SHIFT; | ||
100 | - } else { | ||
101 | + } | ||
102 | + return simd_desc(vsz, vsz, desc | data); | ||
103 | +} | ||
104 | + | ||
105 | +static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | ||
106 | + int dtype, uint32_t nregs, bool is_write, | ||
107 | + gen_helper_gvec_mem *fn) | ||
108 | +{ | ||
109 | + TCGv_ptr t_pg; | ||
110 | + uint32_t desc; | ||
111 | + | ||
112 | + if (!s->mte_active[0]) { | ||
113 | addr = clean_data_tbi(s, addr); | ||
114 | } | ||
115 | |||
116 | @@ -XXX,XX +XXX,XX @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | ||
117 | * registers as pointers, so encode the regno into the data field. | ||
118 | * For consistency, do this even for LD1. | ||
119 | */ | ||
120 | - desc = simd_desc(vsz, vsz, zt | desc); | ||
121 | + desc = make_svemte_desc(s, vec_full_reg_size(s), nregs, | ||
122 | + dtype_msz(dtype), is_write, zt); | ||
123 | t_pg = tcg_temp_new_ptr(); | ||
124 | |||
125 | tcg_gen_addi_ptr(t_pg, tcg_env, pred_full_reg_offset(s, pg)); | ||
126 | @@ -XXX,XX +XXX,XX @@ static void do_mem_zpz(DisasContext *s, int zt, int pg, int zm, | ||
127 | int scale, TCGv_i64 scalar, int msz, bool is_write, | ||
128 | gen_helper_gvec_mem_scatter *fn) | ||
129 | { | ||
130 | - unsigned vsz = vec_full_reg_size(s); | ||
131 | TCGv_ptr t_zm = tcg_temp_new_ptr(); | ||
132 | TCGv_ptr t_pg = tcg_temp_new_ptr(); | ||
133 | TCGv_ptr t_zt = tcg_temp_new_ptr(); | ||
134 | - int desc = 0; | ||
135 | - | ||
136 | - if (s->mte_active[0]) { | ||
137 | - desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s)); | ||
138 | - desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); | ||
139 | - desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); | ||
140 | - desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); | ||
141 | - desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (1 << msz) - 1); | ||
142 | - desc <<= SVE_MTEDESC_SHIFT; | ||
143 | - } | ||
144 | - desc = simd_desc(vsz, vsz, desc | scale); | ||
145 | + uint32_t desc; | ||
146 | |||
147 | tcg_gen_addi_ptr(t_pg, tcg_env, pred_full_reg_offset(s, pg)); | ||
148 | tcg_gen_addi_ptr(t_zm, tcg_env, vec_full_reg_offset(s, zm)); | ||
149 | tcg_gen_addi_ptr(t_zt, tcg_env, vec_full_reg_offset(s, zt)); | ||
150 | + | ||
151 | + desc = make_svemte_desc(s, vec_full_reg_size(s), 1, msz, is_write, scale); | ||
152 | fn(tcg_env, t_zt, t_pg, t_zm, scalar, tcg_constant_i32(desc)); | ||
153 | } | 21 | } |
154 | 22 | ||
155 | -- | 23 | -- |
156 | 2.34.1 | 24 | 2.34.1 | diff view generated by jsdifflib |
1 | The raven_io_ops MemoryRegionOps is the only one in the source tree | 1 | Set the default NaN pattern explicitly for hexagon. |
---|---|---|---|
2 | which sets .valid.unaligned to indicate that it should support | 2 | Remove the ifdef from parts64_default_nan(); the only |
3 | unaligned accesses and which does not also set .impl.unaligned to | 3 | remaining unconverted targets all use the default case. |
4 | indicate that its read and write functions can do the unaligned | ||
5 | handling themselves. This is a problem, because at the moment the | ||
6 | core memory system does not implement the support for handling | ||
7 | unaligned accesses by doing a series of aligned accesses and | ||
8 | combining them (system/memory.c:access_with_adjusted_size() has a | ||
9 | TODO comment noting this). | ||
10 | 4 | ||
11 | Fortunately raven_io_read() and raven_io_write() will correctly deal | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | with the case of being passed an unaligned address, so we can fix the | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | missing unaligned access support by setting .impl.unaligned in the | 7 | Message-id: 20241202131347.498124-52-peter.maydell@linaro.org |
14 | MemoryRegionOps struct. | 8 | --- |
9 | target/hexagon/cpu.c | 2 ++ | ||
10 | fpu/softfloat-specialize.c.inc | 5 ----- | ||
11 | 2 files changed, 2 insertions(+), 5 deletions(-) | ||
15 | 12 | ||
16 | Fixes: 9a1839164c9c8f06 ("raven: Implement non-contiguous I/O region") | 13 | diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c |
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
18 | Tested-by: Cédric Le Goater <clg@redhat.com> | ||
19 | Reviewed-by: Cédric Le Goater <clg@redhat.com> | ||
20 | Message-id: 20240112134640.1775041-1-peter.maydell@linaro.org | ||
21 | --- | ||
22 | hw/pci-host/raven.c | 1 + | ||
23 | 1 file changed, 1 insertion(+) | ||
24 | |||
25 | diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c | ||
26 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/hw/pci-host/raven.c | 15 | --- a/target/hexagon/cpu.c |
28 | +++ b/hw/pci-host/raven.c | 16 | +++ b/target/hexagon/cpu.c |
29 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps raven_io_ops = { | 17 | @@ -XXX,XX +XXX,XX @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type) |
30 | .write = raven_io_write, | 18 | |
31 | .endianness = DEVICE_LITTLE_ENDIAN, | 19 | set_default_nan_mode(1, &env->fp_status); |
32 | .impl.max_access_size = 4, | 20 | set_float_detect_tininess(float_tininess_before_rounding, &env->fp_status); |
33 | + .impl.unaligned = true, | 21 | + /* Default NaN value: sign bit set, all frac bits set */ |
34 | .valid.unaligned = true, | 22 | + set_float_default_nan_pattern(0b11111111, &env->fp_status); |
35 | }; | 23 | } |
24 | |||
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); | ||
36 | 48 | ||
37 | -- | 49 | -- |
38 | 2.34.1 | 50 | 2.34.1 |
39 | |||
40 | diff view generated by jsdifflib |
1 | Update the virt golden reference files to say that the FACP is ACPI | 1 | Set the default NaN pattern explicitly for riscv. |
---|---|---|---|
2 | v6.3, and the GTDT table is a revision 3 table with space for the | ||
3 | virtual EL2 timer. | ||
4 | |||
5 | Diffs from iasl: | ||
6 | |||
7 | @@ -XXX,XX +XXX,XX @@ | ||
8 | /* | ||
9 | * Intel ACPI Component Architecture | ||
10 | * AML/ASL+ Disassembler version 20200925 (64-bit version) | ||
11 | * Copyright (c) 2000 - 2020 Intel Corporation | ||
12 | * | ||
13 | - * Disassembly of tests/data/acpi/virt/FACP, Mon Jan 22 13:48:40 2024 | ||
14 | + * Disassembly of /tmp/aml-W8RZH2, Mon Jan 22 13:48:40 2024 | ||
15 | * | ||
16 | * ACPI Data Table [FACP] | ||
17 | * | ||
18 | * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue | ||
19 | */ | ||
20 | |||
21 | [000h 0000 4] Signature : "FACP" [Fixed ACPI Description Table (FADT)] | ||
22 | [004h 0004 4] Table Length : 00000114 | ||
23 | [008h 0008 1] Revision : 06 | ||
24 | -[009h 0009 1] Checksum : 15 | ||
25 | +[009h 0009 1] Checksum : 12 | ||
26 | [00Ah 0010 6] Oem ID : "BOCHS " | ||
27 | [010h 0016 8] Oem Table ID : "BXPC " | ||
28 | [018h 0024 4] Oem Revision : 00000001 | ||
29 | [01Ch 0028 4] Asl Compiler ID : "BXPC" | ||
30 | [020h 0032 4] Asl Compiler Revision : 00000001 | ||
31 | |||
32 | [024h 0036 4] FACS Address : 00000000 | ||
33 | [028h 0040 4] DSDT Address : 00000000 | ||
34 | [02Ch 0044 1] Model : 00 | ||
35 | [02Dh 0045 1] PM Profile : 00 [Unspecified] | ||
36 | [02Eh 0046 2] SCI Interrupt : 0000 | ||
37 | [030h 0048 4] SMI Command Port : 00000000 | ||
38 | [034h 0052 1] ACPI Enable Value : 00 | ||
39 | [035h 0053 1] ACPI Disable Value : 00 | ||
40 | [036h 0054 1] S4BIOS Command : 00 | ||
41 | [037h 0055 1] P-State Control : 00 | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | Use APIC Physical Destination Mode (V4) : 0 | ||
44 | Hardware Reduced (V5) : 1 | ||
45 | Low Power S0 Idle (V5) : 0 | ||
46 | |||
47 | [074h 0116 12] Reset Register : [Generic Address Structure] | ||
48 | [074h 0116 1] Space ID : 00 [SystemMemory] | ||
49 | [075h 0117 1] Bit Width : 00 | ||
50 | [076h 0118 1] Bit Offset : 00 | ||
51 | [077h 0119 1] Encoded Access Width : 00 [Undefined/Legacy] | ||
52 | [078h 0120 8] Address : 0000000000000000 | ||
53 | |||
54 | [080h 0128 1] Value to cause reset : 00 | ||
55 | [081h 0129 2] ARM Flags (decoded below) : 0003 | ||
56 | PSCI Compliant : 1 | ||
57 | Must use HVC for PSCI : 1 | ||
58 | |||
59 | -[083h 0131 1] FADT Minor Revision : 00 | ||
60 | +[083h 0131 1] FADT Minor Revision : 03 | ||
61 | [084h 0132 8] FACS Address : 0000000000000000 | ||
62 | [08Ch 0140 8] DSDT Address : 0000000000000000 | ||
63 | [094h 0148 12] PM1A Event Block : [Generic Address Structure] | ||
64 | [094h 0148 1] Space ID : 00 [SystemMemory] | ||
65 | [095h 0149 1] Bit Width : 00 | ||
66 | [096h 0150 1] Bit Offset : 00 | ||
67 | [097h 0151 1] Encoded Access Width : 00 [Undefined/Legacy] | ||
68 | [098h 0152 8] Address : 0000000000000000 | ||
69 | |||
70 | [0A0h 0160 12] PM1B Event Block : [Generic Address Structure] | ||
71 | [0A0h 0160 1] Space ID : 00 [SystemMemory] | ||
72 | [0A1h 0161 1] Bit Width : 00 | ||
73 | [0A2h 0162 1] Bit Offset : 00 | ||
74 | [0A3h 0163 1] Encoded Access Width : 00 [Undefined/Legacy] | ||
75 | [0A4h 0164 8] Address : 0000000000000000 | ||
76 | |||
77 | @@ -XXX,XX +XXX,XX @@ | ||
78 | [0F5h 0245 1] Bit Width : 00 | ||
79 | [0F6h 0246 1] Bit Offset : 00 | ||
80 | [0F7h 0247 1] Encoded Access Width : 00 [Undefined/Legacy] | ||
81 | [0F8h 0248 8] Address : 0000000000000000 | ||
82 | |||
83 | [100h 0256 12] Sleep Status Register : [Generic Address Structure] | ||
84 | [100h 0256 1] Space ID : 00 [SystemMemory] | ||
85 | [101h 0257 1] Bit Width : 00 | ||
86 | [102h 0258 1] Bit Offset : 00 | ||
87 | [103h 0259 1] Encoded Access Width : 00 [Undefined/Legacy] | ||
88 | [104h 0260 8] Address : 0000000000000000 | ||
89 | |||
90 | [10Ch 0268 8] Hypervisor ID : 00000000554D4551 | ||
91 | |||
92 | Raw Table Data: Length 276 (0x114) | ||
93 | |||
94 | - 0000: 46 41 43 50 14 01 00 00 06 15 42 4F 43 48 53 20 // FACP......BOCHS | ||
95 | + 0000: 46 41 43 50 14 01 00 00 06 12 42 4F 43 48 53 20 // FACP......BOCHS | ||
96 | 0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC | ||
97 | 0020: 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
98 | 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
99 | 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
100 | 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
101 | 0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
102 | 0070: 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
103 | - 0080: 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
104 | + 0080: 00 03 00 03 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
105 | 0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
106 | 00A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
107 | 00B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
108 | 00C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
109 | 00D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
110 | 00E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
111 | 00F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ................ | ||
112 | 0100: 00 00 00 00 00 00 00 00 00 00 00 00 51 45 4D 55 // ............QEMU | ||
113 | 0110: 00 00 00 00 // .... | ||
114 | |||
115 | @@ -XXX,XX +XXX,XX @@ | ||
116 | /* | ||
117 | * Intel ACPI Component Architecture | ||
118 | * AML/ASL+ Disassembler version 20200925 (64-bit version) | ||
119 | * Copyright (c) 2000 - 2020 Intel Corporation | ||
120 | * | ||
121 | - * Disassembly of tests/data/acpi/virt/GTDT, Mon Jan 22 13:48:40 2024 | ||
122 | + * Disassembly of /tmp/aml-XDSZH2, Mon Jan 22 13:48:40 2024 | ||
123 | * | ||
124 | * ACPI Data Table [GTDT] | ||
125 | * | ||
126 | * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue | ||
127 | */ | ||
128 | |||
129 | [000h 0000 4] Signature : "GTDT" [Generic Timer Description Table] | ||
130 | -[004h 0004 4] Table Length : 00000060 | ||
131 | -[008h 0008 1] Revision : 02 | ||
132 | -[009h 0009 1] Checksum : 9C | ||
133 | +[004h 0004 4] Table Length : 00000068 | ||
134 | +[008h 0008 1] Revision : 03 | ||
135 | +[009h 0009 1] Checksum : 93 | ||
136 | [00Ah 0010 6] Oem ID : "BOCHS " | ||
137 | [010h 0016 8] Oem Table ID : "BXPC " | ||
138 | [018h 0024 4] Oem Revision : 00000001 | ||
139 | [01Ch 0028 4] Asl Compiler ID : "BXPC" | ||
140 | [020h 0032 4] Asl Compiler Revision : 00000001 | ||
141 | |||
142 | [024h 0036 8] Counter Block Address : FFFFFFFFFFFFFFFF | ||
143 | [02Ch 0044 4] Reserved : 00000000 | ||
144 | |||
145 | [030h 0048 4] Secure EL1 Interrupt : 0000001D | ||
146 | [034h 0052 4] EL1 Flags (decoded below) : 00000000 | ||
147 | Trigger Mode : 0 | ||
148 | Polarity : 0 | ||
149 | Always On : 0 | ||
150 | |||
151 | [038h 0056 4] Non-Secure EL1 Interrupt : 0000001E | ||
152 | @@ -XXX,XX +XXX,XX @@ | ||
153 | |||
154 | [040h 0064 4] Virtual Timer Interrupt : 0000001B | ||
155 | [044h 0068 4] VT Flags (decoded below) : 00000000 | ||
156 | Trigger Mode : 0 | ||
157 | Polarity : 0 | ||
158 | Always On : 0 | ||
159 | |||
160 | [048h 0072 4] Non-Secure EL2 Interrupt : 0000001A | ||
161 | [04Ch 0076 4] NEL2 Flags (decoded below) : 00000000 | ||
162 | Trigger Mode : 0 | ||
163 | Polarity : 0 | ||
164 | Always On : 0 | ||
165 | [050h 0080 8] Counter Read Block Address : FFFFFFFFFFFFFFFF | ||
166 | |||
167 | [058h 0088 4] Platform Timer Count : 00000000 | ||
168 | [05Ch 0092 4] Platform Timer Offset : 00000000 | ||
169 | +[060h 0096 4] Virtual EL2 Timer GSIV : 00000000 | ||
170 | +[064h 0100 4] Virtual EL2 Timer Flags : 00000000 | ||
171 | |||
172 | -Raw Table Data: Length 96 (0x60) | ||
173 | +Raw Table Data: Length 104 (0x68) | ||
174 | |||
175 | - 0000: 47 54 44 54 60 00 00 00 02 9C 42 4F 43 48 53 20 // GTDT`.....BOCHS | ||
176 | + 0000: 47 54 44 54 68 00 00 00 03 93 42 4F 43 48 53 20 // GTDTh.....BOCHS | ||
177 | 0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC | ||
178 | 0020: 01 00 00 00 FF FF FF FF FF FF FF FF 00 00 00 00 // ................ | ||
179 | 0030: 1D 00 00 00 00 00 00 00 1E 00 00 00 04 00 00 00 // ................ | ||
180 | 0040: 1B 00 00 00 00 00 00 00 1A 00 00 00 00 00 00 00 // ................ | ||
181 | 0050: FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 // ................ | ||
182 | + 0060: 00 00 00 00 00 00 00 00 // ........ | ||
183 | 2 | ||
184 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
185 | Reviewed-by: Ard Biesheuvel <ardb@kernel.org> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
186 | Message-id: 20240122143537.233498-4-peter.maydell@linaro.org | 5 | Message-id: 20241202131347.498124-53-peter.maydell@linaro.org |
187 | --- | 6 | --- |
188 | tests/qtest/bios-tables-test-allowed-diff.h | 2 -- | 7 | target/riscv/cpu.c | 2 ++ |
189 | tests/data/acpi/virt/FACP | Bin 276 -> 276 bytes | 8 | 1 file changed, 2 insertions(+) |
190 | tests/data/acpi/virt/GTDT | Bin 96 -> 104 bytes | ||
191 | 3 files changed, 2 deletions(-) | ||
192 | 9 | ||
193 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | 10 | diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c |
194 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
195 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | 12 | --- a/target/riscv/cpu.c |
196 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | 13 | +++ b/target/riscv/cpu.c |
197 | @@ -1,3 +1 @@ | 14 | @@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset_hold(Object *obj, ResetType type) |
198 | /* List of comma-separated changed AML files to ignore */ | 15 | cs->exception_index = RISCV_EXCP_NONE; |
199 | -"tests/data/acpi/virt/FACP", | 16 | env->load_res = -1; |
200 | -"tests/data/acpi/virt/GTDT", | 17 | set_default_nan_mode(1, &env->fp_status); |
201 | diff --git a/tests/data/acpi/virt/FACP b/tests/data/acpi/virt/FACP | 18 | + /* Default NaN value: sign bit clear, frac msb set */ |
202 | index XXXXXXX..XXXXXXX 100644 | 19 | + set_float_default_nan_pattern(0b01000000, &env->fp_status); |
203 | GIT binary patch | 20 | env->vill = true; |
204 | delta 25 | 21 | |
205 | gcmbQjG=+)F&CxkPgpq-PO=u!l<;2F$$vli407<0<)c^nh | 22 | #ifndef CONFIG_USER_ONLY |
206 | |||
207 | delta 28 | ||
208 | kcmbQjG=+)F&CxkPgpq-PO>`nx<-|!<6Akz$^DuG%0AAS!ssI20 | ||
209 | |||
210 | diff --git a/tests/data/acpi/virt/GTDT b/tests/data/acpi/virt/GTDT | ||
211 | index XXXXXXX..XXXXXXX 100644 | ||
212 | GIT binary patch | ||
213 | delta 25 | ||
214 | bcmYeu;BpUf3CUn!U|^m+kt>V?$N&QXMtB4L | ||
215 | |||
216 | delta 16 | ||
217 | Xcmc~u;BpUf2}xjJU|^avkt+-UB60)u | ||
218 | |||
219 | -- | 23 | -- |
220 | 2.34.1 | 24 | 2.34.1 | diff view generated by jsdifflib |
1 | Allow changes to the virt GTDT -- we are going to add the IRQ | 1 | Set the default NaN pattern explicitly for tricore. |
---|---|---|---|
2 | entry for a new timer to it. | ||
3 | 2 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Ard Biesheuvel <ardb@kernel.org> | 4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20240122143537.233498-2-peter.maydell@linaro.org | 5 | Message-id: 20241202131347.498124-54-peter.maydell@linaro.org |
7 | --- | 6 | --- |
8 | tests/qtest/bios-tables-test-allowed-diff.h | 2 ++ | 7 | target/tricore/helper.c | 2 ++ |
9 | 1 file changed, 2 insertions(+) | 8 | 1 file changed, 2 insertions(+) |
10 | 9 | ||
11 | diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h | 10 | diff --git a/target/tricore/helper.c b/target/tricore/helper.c |
12 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/tests/qtest/bios-tables-test-allowed-diff.h | 12 | --- a/target/tricore/helper.c |
14 | +++ b/tests/qtest/bios-tables-test-allowed-diff.h | 13 | +++ b/target/tricore/helper.c |
15 | @@ -1 +1,3 @@ | 14 | @@ -XXX,XX +XXX,XX @@ void fpu_set_state(CPUTriCoreState *env) |
16 | /* List of comma-separated changed AML files to ignore */ | 15 | set_flush_to_zero(1, &env->fp_status); |
17 | +"tests/data/acpi/virt/FACP", | 16 | set_float_detect_tininess(float_tininess_before_rounding, &env->fp_status); |
18 | +"tests/data/acpi/virt/GTDT", | 17 | set_default_nan_mode(1, &env->fp_status); |
18 | + /* Default NaN pattern: sign bit clear, frac msb set */ | ||
19 | + set_float_default_nan_pattern(0b01000000, &env->fp_status); | ||
20 | } | ||
21 | |||
22 | uint32_t psw_read(CPUTriCoreState *env) | ||
19 | -- | 23 | -- |
20 | 2.34.1 | 24 | 2.34.1 | diff view generated by jsdifflib |
1 | Suppress the deprecation warning when we're running under qtest, | 1 | Now that all our targets have bene converted to explicitly specify |
---|---|---|---|
2 | to avoid "make check" including warning messages in its output. | 2 | their pattern for the default NaN value we can remove the remaining |
3 | fallback code in parts64_default_nan(). | ||
3 | 4 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20240206154151.155620-1-peter.maydell@linaro.org | 7 | Message-id: 20241202131347.498124-55-peter.maydell@linaro.org |
7 | --- | 8 | --- |
8 | hw/block/tc58128.c | 4 +++- | 9 | fpu/softfloat-specialize.c.inc | 14 -------------- |
9 | 1 file changed, 3 insertions(+), 1 deletion(-) | 10 | 1 file changed, 14 deletions(-) |
10 | 11 | ||
11 | diff --git a/hw/block/tc58128.c b/hw/block/tc58128.c | 12 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc |
12 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/block/tc58128.c | 14 | --- a/fpu/softfloat-specialize.c.inc |
14 | +++ b/hw/block/tc58128.c | 15 | +++ b/fpu/softfloat-specialize.c.inc |
15 | @@ -XXX,XX +XXX,XX @@ static sh7750_io_device tc58128 = { | 16 | @@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status) |
16 | 17 | uint64_t frac; | |
17 | int tc58128_init(struct SH7750State *s, const char *zone1, const char *zone2) | 18 | uint8_t dnan_pattern = status->default_nan_pattern; |
18 | { | 19 | |
19 | - warn_report_once("The TC58128 flash device is deprecated"); | 20 | - if (dnan_pattern == 0) { |
20 | + if (!qtest_enabled()) { | 21 | - /* |
21 | + warn_report_once("The TC58128 flash device is deprecated"); | 22 | - * This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V, |
22 | + } | 23 | - * S390, SH4, TriCore, and Xtensa. Our other supported targets |
23 | init_dev(&tc58128_devs[0], zone1); | 24 | - * do not have floating-point. |
24 | init_dev(&tc58128_devs[1], zone2); | 25 | - */ |
25 | return sh7750_register_io_device(s, &tc58128); | 26 | - if (snan_bit_is_one(status)) { |
27 | - /* sign bit clear, set all frac bits other than msb */ | ||
28 | - dnan_pattern = 0b00111111; | ||
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; | ||
26 | -- | 37 | -- |
27 | 2.34.1 | 38 | 2.34.1 |
28 | |||
29 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 3 | Inline pickNaNMulAdd into its only caller. This makes |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | one assert redundant with the immediately preceding IF. |
5 | Message-id: 20240213155214.13619-2-philmd@linaro.org | 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-3-richard.henderson@linaro.org | ||
9 | [PMM: keep comment from old code in new location] | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 11 | --- |
8 | hw/arm/stellaris.c | 6 ++++-- | 12 | fpu/softfloat-parts.c.inc | 41 +++++++++++++++++++++++++- |
9 | 1 file changed, 4 insertions(+), 2 deletions(-) | 13 | fpu/softfloat-specialize.c.inc | 54 ---------------------------------- |
14 | 2 files changed, 40 insertions(+), 55 deletions(-) | ||
10 | 15 | ||
11 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | 16 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
12 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/arm/stellaris.c | 18 | --- a/fpu/softfloat-parts.c.inc |
14 | +++ b/hw/arm/stellaris.c | 19 | +++ b/fpu/softfloat-parts.c.inc |
15 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_trigger(void *opaque, int irq, int level) | 20 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
21 | } | ||
22 | |||
23 | if (s->default_nan_mode) { | ||
24 | + /* | ||
25 | + * We guarantee not to require the target to tell us how to | ||
26 | + * pick a NaN if we're always returning the default NaN. | ||
27 | + * But if we're not in default-NaN mode then the target must | ||
28 | + * specify. | ||
29 | + */ | ||
30 | which = 3; | ||
31 | + } else if (infzero) { | ||
32 | + /* | ||
33 | + * Inf * 0 + NaN -- some implementations return the | ||
34 | + * default NaN here, and some return the input NaN. | ||
35 | + */ | ||
36 | + switch (s->float_infzeronan_rule) { | ||
37 | + case float_infzeronan_dnan_never: | ||
38 | + which = 2; | ||
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(); | ||
48 | + } | ||
49 | } else { | ||
50 | - which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, have_snan, s); | ||
51 | + FloatClass cls[3] = { a->cls, b->cls, c->cls }; | ||
52 | + Float3NaNPropRule rule = s->float_3nan_prop_rule; | ||
53 | + | ||
54 | + assert(rule != float_3nan_prop_none); | ||
55 | + if (have_snan && (rule & R_3NAN_SNAN_MASK)) { | ||
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])); | ||
66 | + } | ||
67 | } | ||
68 | |||
69 | if (which == 3) { | ||
70 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/fpu/softfloat-specialize.c.inc | ||
73 | +++ b/fpu/softfloat-specialize.c.inc | ||
74 | @@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, | ||
16 | } | 75 | } |
17 | } | 76 | } |
18 | 77 | ||
19 | -static void stellaris_adc_reset(StellarisADCState *s) | 78 | -/*---------------------------------------------------------------------------- |
20 | +static void stellaris_adc_reset_hold(Object *obj) | 79 | -| Select which NaN to propagate for a three-input operation. |
21 | { | 80 | -| For the moment we assume that no CPU needs the 'larger significand' |
22 | + StellarisADCState *s = STELLARIS_ADC(obj); | 81 | -| information. |
23 | int n; | 82 | -| Return values : 0 : a; 1 : b; 2 : c; 3 : default-NaN |
24 | 83 | -*----------------------------------------------------------------------------*/ | |
25 | for (n = 0; n < 4; n++) { | 84 | -static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, |
26 | @@ -XXX,XX +XXX,XX @@ static void stellaris_adc_init(Object *obj) | 85 | - bool infzero, bool have_snan, float_status *status) |
27 | memory_region_init_io(&s->iomem, obj, &stellaris_adc_ops, s, | 86 | -{ |
28 | "adc", 0x1000); | 87 | - FloatClass cls[3] = { a_cls, b_cls, c_cls }; |
29 | sysbus_init_mmio(sbd, &s->iomem); | 88 | - Float3NaNPropRule rule = status->float_3nan_prop_rule; |
30 | - stellaris_adc_reset(s); | 89 | - int which; |
31 | qdev_init_gpio_in(dev, stellaris_adc_trigger, 1); | 90 | - |
32 | } | 91 | - /* |
33 | 92 | - * We guarantee not to require the target to tell us how to | |
34 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo stellaris_i2c_info = { | 93 | - * pick a NaN if we're always returning the default NaN. |
35 | static void stellaris_adc_class_init(ObjectClass *klass, void *data) | 94 | - * But if we're not in default-NaN mode then the target must |
36 | { | 95 | - * specify. |
37 | DeviceClass *dc = DEVICE_CLASS(klass); | 96 | - */ |
38 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | 97 | - assert(!status->default_nan_mode); |
39 | 98 | - | |
40 | + rc->phases.hold = stellaris_adc_reset_hold; | 99 | - if (infzero) { |
41 | dc->vmsd = &vmstate_stellaris_adc; | 100 | - /* |
42 | } | 101 | - * Inf * 0 + NaN -- some implementations return the default NaN here, |
43 | 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. | ||
44 | -- | 135 | -- |
45 | 2.34.1 | 136 | 2.34.1 |
46 | 137 | ||
47 | 138 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | QDev objects created with qdev_new() need to manually add | 3 | Remove "3" as a special case for which and simply |
4 | their parent relationship with object_property_add_child(). | 4 | branch to return the desired value. |
5 | 5 | ||
6 | This commit plug the devices which aren't part of the SoC; | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | they will be plugged into a SoC container in the next one. | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | 8 | Message-id: 20241203203949.483774-4-richard.henderson@linaro.org | |
9 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Message-id: 20240213155214.13619-4-philmd@linaro.org | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 10 | --- |
14 | hw/arm/stellaris.c | 4 ++++ | 11 | fpu/softfloat-parts.c.inc | 20 ++++++++++---------- |
15 | 1 file changed, 4 insertions(+) | 12 | 1 file changed, 10 insertions(+), 10 deletions(-) |
16 | 13 | ||
17 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | 14 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/stellaris.c | 16 | --- a/fpu/softfloat-parts.c.inc |
20 | +++ b/hw/arm/stellaris.c | 17 | +++ b/fpu/softfloat-parts.c.inc |
21 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | 18 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
22 | &error_fatal); | 19 | * But if we're not in default-NaN mode then the target must |
23 | 20 | * specify. | |
24 | ssddev = qdev_new("ssd0323"); | 21 | */ |
25 | + object_property_add_child(OBJECT(ms), "oled", OBJECT(ssddev)); | 22 | - which = 3; |
26 | qdev_prop_set_uint8(ssddev, "cs", 1); | 23 | + goto default_nan; |
27 | qdev_realize_and_unref(ssddev, bus, &error_fatal); | 24 | } else if (infzero) { |
28 | 25 | /* | |
29 | gpio_d_splitter = qdev_new(TYPE_SPLIT_IRQ); | 26 | * Inf * 0 + NaN -- some implementations return the |
30 | + object_property_add_child(OBJECT(ms), "splitter", | 27 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
31 | + OBJECT(gpio_d_splitter)); | 28 | */ |
32 | qdev_prop_set_uint32(gpio_d_splitter, "num-lines", 2); | 29 | switch (s->float_infzeronan_rule) { |
33 | qdev_realize_and_unref(gpio_d_splitter, NULL, &error_fatal); | 30 | case float_infzeronan_dnan_never: |
34 | qdev_connect_gpio_out( | 31 | - which = 2; |
35 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | 32 | break; |
36 | DeviceState *gpad; | 33 | case float_infzeronan_dnan_always: |
37 | 34 | - which = 3; | |
38 | gpad = qdev_new(TYPE_STELLARIS_GAMEPAD); | 35 | - break; |
39 | + object_property_add_child(OBJECT(ms), "gamepad", OBJECT(gpad)); | 36 | + goto default_nan; |
40 | for (i = 0; i < ARRAY_SIZE(gpad_keycode); i++) { | 37 | case float_infzeronan_dnan_if_qnan: |
41 | qlist_append_int(gpad_keycode_list, gpad_keycode[i]); | 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(); | ||
42 | } | 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; | ||
57 | - } | ||
58 | - | ||
59 | switch (which) { | ||
60 | case 0: | ||
61 | break; | ||
62 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, | ||
63 | parts_silence_nan(a, s); | ||
64 | } | ||
65 | return a; | ||
66 | + | ||
67 | + default_nan: | ||
68 | + parts_default_nan(a, s); | ||
69 | + return a; | ||
70 | } | ||
71 | |||
72 | /* | ||
43 | -- | 73 | -- |
44 | 2.34.1 | 74 | 2.34.1 |
45 | 75 | ||
46 | 76 | diff view generated by jsdifflib |
1 | It doesn't make sense to read the value of MDCR_EL2 on a non-A-profile | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | CPU, and in fact if you try to do it we will assert: | ||
3 | 2 | ||
4 | #6 0x00007ffff4b95e96 in __GI___assert_fail | 3 | Assign the pointer return value to 'a' directly, |
5 | (assertion=0x5555565a8c70 "!arm_feature(env, ARM_FEATURE_M)", file=0x5555565a6e5c "../../target/arm/helper.c", line=12600, function=0x5555565a9560 <__PRETTY_FUNCTION__.0> "arm_security_space_below_el3") at ./assert/assert.c:101 | 4 | rather than going through an intermediary index. |
6 | #7 0x0000555555ebf412 in arm_security_space_below_el3 (env=0x555557bc8190) at ../../target/arm/helper.c:12600 | ||
7 | #8 0x0000555555ea6f89 in arm_is_el2_enabled (env=0x555557bc8190) at ../../target/arm/cpu.h:2595 | ||
8 | #9 0x0000555555ea942f in arm_mdcr_el2_eff (env=0x555557bc8190) at ../../target/arm/internals.h:1512 | ||
9 | 5 | ||
10 | We might call pmu_counter_enabled() on an M-profile CPU (for example | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
11 | from the migration pre/post hooks in machine.c); this should always | 7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
12 | return false because these CPUs don't set ARM_FEATURE_PMU. | 8 | Message-id: 20241203203949.483774-5-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | fpu/softfloat-parts.c.inc | 32 ++++++++++---------------------- | ||
12 | 1 file changed, 10 insertions(+), 22 deletions(-) | ||
13 | 13 | ||
14 | Avoid the assertion by not calling arm_mdcr_el2_eff() before we | 14 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
15 | have done the early return for "PMU not present". | ||
16 | |||
17 | This fixes an assertion failure if you try to do a loadvm or | ||
18 | savevm for an M-profile board. | ||
19 | |||
20 | Cc: qemu-stable@nongnu.org | ||
21 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2155 | ||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
23 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
24 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
25 | Message-id: 20240208153346.970021-1-peter.maydell@linaro.org | ||
26 | --- | ||
27 | target/arm/helper.c | 12 ++++++++++-- | ||
28 | 1 file changed, 10 insertions(+), 2 deletions(-) | ||
29 | |||
30 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
31 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
32 | --- a/target/arm/helper.c | 16 | --- a/fpu/softfloat-parts.c.inc |
33 | +++ b/target/arm/helper.c | 17 | +++ b/fpu/softfloat-parts.c.inc |
34 | @@ -XXX,XX +XXX,XX @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter) | 18 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
35 | bool enabled, prohibited = false, filtered; | 19 | FloatPartsN *c, float_status *s, |
36 | bool secure = arm_is_secure(env); | 20 | int ab_mask, int abc_mask) |
37 | int el = arm_current_el(env); | 21 | { |
38 | - uint64_t mdcr_el2 = arm_mdcr_el2_eff(env); | 22 | - int which; |
39 | - uint8_t hpmn = mdcr_el2 & MDCR_HPMN; | 23 | bool infzero = (ab_mask == float_cmask_infzero); |
40 | + uint64_t mdcr_el2; | 24 | bool have_snan = (abc_mask & float_cmask_snan); |
41 | + uint8_t hpmn; | 25 | + FloatPartsN *ret; |
42 | 26 | ||
43 | + /* | 27 | if (unlikely(have_snan)) { |
44 | + * We might be called for M-profile cores where MDCR_EL2 doesn't | 28 | float_raise(float_flag_invalid | float_flag_invalid_snan, s); |
45 | + * exist and arm_mdcr_el2_eff() will assert, so this early-exit check | 29 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
46 | + * must be before we read that value. | 30 | default: |
47 | + */ | 31 | g_assert_not_reached(); |
48 | if (!arm_feature(env, ARM_FEATURE_PMU)) { | 32 | } |
49 | return false; | 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 | } | ||
50 | } | 57 | } |
51 | 58 | ||
52 | + mdcr_el2 = arm_mdcr_el2_eff(env); | 59 | - switch (which) { |
53 | + hpmn = mdcr_el2 & MDCR_HPMN; | 60 | - case 0: |
54 | + | 61 | - break; |
55 | if (!arm_feature(env, ARM_FEATURE_EL2) || | 62 | - case 1: |
56 | (counter < hpmn || counter == 31)) { | 63 | - a = b; |
57 | e = env->cp15.c9_pmcr & PMCRE; | 64 | - break; |
65 | - case 2: | ||
66 | - a = c; | ||
67 | - break; | ||
68 | - default: | ||
69 | - g_assert_not_reached(); | ||
70 | + if (is_snan(ret->cls)) { | ||
71 | + parts_silence_nan(ret, s); | ||
72 | } | ||
73 | - if (is_snan(a->cls)) { | ||
74 | - parts_silence_nan(a, s); | ||
75 | - } | ||
76 | - return a; | ||
77 | + return ret; | ||
78 | |||
79 | default_nan: | ||
80 | parts_default_nan(a, s); | ||
58 | -- | 81 | -- |
59 | 2.34.1 | 82 | 2.34.1 |
60 | 83 | ||
61 | 84 | diff view generated by jsdifflib |
1 | We currently guard the CFG3 register read with | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | (scc_partno(s) == 0x524 && scc_partno(s) == 0x547) | ||
3 | which is clearly wrong as it is never true. | ||
4 | 2 | ||
5 | This register is present on all board types except AN524 | 3 | While all indices into val[] should be in [0-2], the mask |
6 | and AN527; correct the condition. | 4 | applied is two bits. To help static analysis see there is |
5 | no possibility of read beyond the end of the array, pad the | ||
6 | array to 4 entries, with the final being (implicitly) NULL. | ||
7 | 7 | ||
8 | Fixes: 6ac80818941829c0 ("hw/misc/mps2-scc: Implement changes for AN547") | 8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Message-id: 20241203203949.483774-6-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
12 | Message-id: 20240206132931.38376-6-peter.maydell@linaro.org | ||
13 | --- | 12 | --- |
14 | hw/misc/mps2-scc.c | 2 +- | 13 | fpu/softfloat-parts.c.inc | 2 +- |
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | 14 | 1 file changed, 1 insertion(+), 1 deletion(-) |
16 | 15 | ||
17 | diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c | 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/hw/misc/mps2-scc.c | 18 | --- a/fpu/softfloat-parts.c.inc |
20 | +++ b/hw/misc/mps2-scc.c | 19 | +++ b/fpu/softfloat-parts.c.inc |
21 | @@ -XXX,XX +XXX,XX @@ static uint64_t mps2_scc_read(void *opaque, hwaddr offset, unsigned size) | 20 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
22 | r = s->cfg2; | ||
23 | break; | ||
24 | case A_CFG3: | ||
25 | - if (scc_partno(s) == 0x524 && scc_partno(s) == 0x547) { | ||
26 | + if (scc_partno(s) == 0x524 || scc_partno(s) == 0x547) { | ||
27 | /* CFG3 reserved on AN524 */ | ||
28 | goto bad_offset; | ||
29 | } | 21 | } |
22 | ret = c; | ||
23 | } else { | ||
24 | - FloatPartsN *val[3] = { a, b, c }; | ||
25 | + FloatPartsN *val[R_3NAN_1ST_MASK + 1] = { a, b, c }; | ||
26 | Float3NaNPropRule rule = s->float_3nan_prop_rule; | ||
27 | |||
28 | assert(rule != float_3nan_prop_none); | ||
30 | -- | 29 | -- |
31 | 2.34.1 | 30 | 2.34.1 |
32 | 31 | ||
33 | 32 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When we added SVE_MTEDESC_SHIFT, we effectively limited the | 3 | This function is part of the public interface and |
4 | maximum size of MTEDESC. Adjust SIZEM1 to consume the remaining | 4 | is not "specialized" to any target in any way. |
5 | bits (32 - 10 - 5 - 12 == 5). Assert that the data to be stored | ||
6 | fits within the field (expecting 8 * 4 - 1 == 31, exact fit). | ||
7 | 5 | ||
8 | Cc: qemu-stable@nongnu.org | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Message-id: 20241203203949.483774-7-richard.henderson@linaro.org |
11 | Tested-by: Gustavo Romero <gustavo.romero@linaro.org> | ||
12 | Message-id: 20240207025210.8837-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 | --- | 10 | --- |
15 | target/arm/internals.h | 2 +- | 11 | fpu/softfloat.c | 52 ++++++++++++++++++++++++++++++++++ |
16 | target/arm/tcg/translate-sve.c | 7 ++++--- | 12 | fpu/softfloat-specialize.c.inc | 52 ---------------------------------- |
17 | 2 files changed, 5 insertions(+), 4 deletions(-) | 13 | 2 files changed, 52 insertions(+), 52 deletions(-) |
18 | 14 | ||
19 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 15 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c |
20 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/internals.h | 17 | --- a/fpu/softfloat.c |
22 | +++ b/target/arm/internals.h | 18 | +++ b/fpu/softfloat.c |
23 | @@ -XXX,XX +XXX,XX @@ FIELD(MTEDESC, TBI, 4, 2) | 19 | @@ -XXX,XX +XXX,XX @@ void normalizeFloatx80Subnormal(uint64_t aSig, int32_t *zExpPtr, |
24 | FIELD(MTEDESC, TCMA, 6, 2) | 20 | *zExpPtr = 1 - shiftCount; |
25 | FIELD(MTEDESC, WRITE, 8, 1) | 21 | } |
26 | FIELD(MTEDESC, ALIGN, 9, 3) | 22 | |
27 | -FIELD(MTEDESC, SIZEM1, 12, SIMD_DATA_BITS - 12) /* size - 1 */ | 23 | +/*---------------------------------------------------------------------------- |
28 | +FIELD(MTEDESC, SIZEM1, 12, SIMD_DATA_BITS - SVE_MTEDESC_SHIFT - 12) /* size - 1 */ | 24 | +| Takes two extended double-precision floating-point values `a' and `b', one |
29 | 25 | +| of which is a NaN, and returns the appropriate NaN result. If either `a' or | |
30 | bool mte_probe(CPUARMState *env, uint32_t desc, uint64_t ptr); | 26 | +| `b' is a signaling NaN, the invalid exception is raised. |
31 | uint64_t mte_check(CPUARMState *env, uint32_t desc, uint64_t ptr, uintptr_t ra); | 27 | +*----------------------------------------------------------------------------*/ |
32 | diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c | 28 | + |
29 | +floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) | ||
30 | +{ | ||
31 | + bool aIsLargerSignificand; | ||
32 | + FloatClass a_cls, b_cls; | ||
33 | + | ||
34 | + /* This is not complete, but is good enough for pickNaN. */ | ||
35 | + a_cls = (!floatx80_is_any_nan(a) | ||
36 | + ? float_class_normal | ||
37 | + : floatx80_is_signaling_nan(a, status) | ||
38 | + ? float_class_snan | ||
39 | + : float_class_qnan); | ||
40 | + b_cls = (!floatx80_is_any_nan(b) | ||
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); | ||
48 | + } | ||
49 | + | ||
50 | + if (status->default_nan_mode) { | ||
51 | + return floatx80_default_nan(status); | ||
52 | + } | ||
53 | + | ||
54 | + if (a.low < b.low) { | ||
55 | + aIsLargerSignificand = 0; | ||
56 | + } else if (b.low < a.low) { | ||
57 | + aIsLargerSignificand = 1; | ||
58 | + } else { | ||
59 | + aIsLargerSignificand = (a.high < b.high) ? 1 : 0; | ||
60 | + } | ||
61 | + | ||
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 | +} | ||
74 | + | ||
75 | /*---------------------------------------------------------------------------- | ||
76 | | Takes an abstract floating-point value having sign `zSign', exponent `zExp', | ||
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 | ||
33 | index XXXXXXX..XXXXXXX 100644 | 79 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/target/arm/tcg/translate-sve.c | 80 | --- a/fpu/softfloat-specialize.c.inc |
35 | +++ b/target/arm/tcg/translate-sve.c | 81 | +++ b/fpu/softfloat-specialize.c.inc |
36 | @@ -XXX,XX +XXX,XX @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | 82 | @@ -XXX,XX +XXX,XX @@ floatx80 floatx80_silence_nan(floatx80 a, float_status *status) |
37 | { | 83 | return a; |
38 | unsigned vsz = vec_full_reg_size(s); | 84 | } |
39 | TCGv_ptr t_pg; | 85 | |
40 | + uint32_t sizem1; | 86 | -/*---------------------------------------------------------------------------- |
41 | int desc = 0; | 87 | -| Takes two extended double-precision floating-point values `a' and `b', one |
42 | 88 | -| of which is a NaN, and returns the appropriate NaN result. If either `a' or | |
43 | assert(mte_n >= 1 && mte_n <= 4); | 89 | -| `b' is a signaling NaN, the invalid exception is raised. |
44 | + sizem1 = (mte_n << dtype_msz(dtype)) - 1; | 90 | -*----------------------------------------------------------------------------*/ |
45 | + assert(sizem1 <= R_MTEDESC_SIZEM1_MASK >> R_MTEDESC_SIZEM1_SHIFT); | ||
46 | if (s->mte_active[0]) { | ||
47 | - int msz = dtype_msz(dtype); | ||
48 | - | 91 | - |
49 | desc = FIELD_DP32(desc, MTEDESC, MIDX, get_mem_index(s)); | 92 | -floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) |
50 | desc = FIELD_DP32(desc, MTEDESC, TBI, s->tbid); | 93 | -{ |
51 | desc = FIELD_DP32(desc, MTEDESC, TCMA, s->tcma); | 94 | - bool aIsLargerSignificand; |
52 | desc = FIELD_DP32(desc, MTEDESC, WRITE, is_write); | 95 | - FloatClass a_cls, b_cls; |
53 | - desc = FIELD_DP32(desc, MTEDESC, SIZEM1, (mte_n << msz) - 1); | 96 | - |
54 | + desc = FIELD_DP32(desc, MTEDESC, SIZEM1, sizem1); | 97 | - /* This is not complete, but is good enough for pickNaN. */ |
55 | desc <<= SVE_MTEDESC_SHIFT; | 98 | - a_cls = (!floatx80_is_any_nan(a) |
56 | } else { | 99 | - ? float_class_normal |
57 | addr = clean_data_tbi(s, addr); | 100 | - : floatx80_is_signaling_nan(a, status) |
101 | - ? float_class_snan | ||
102 | - : float_class_qnan); | ||
103 | - b_cls = (!floatx80_is_any_nan(b) | ||
104 | - ? float_class_normal | ||
105 | - : floatx80_is_signaling_nan(b, status) | ||
106 | - ? float_class_snan | ||
107 | - : float_class_qnan); | ||
108 | - | ||
109 | - if (is_snan(a_cls) || is_snan(b_cls)) { | ||
110 | - float_raise(float_flag_invalid, status); | ||
111 | - } | ||
112 | - | ||
113 | - if (status->default_nan_mode) { | ||
114 | - return floatx80_default_nan(status); | ||
115 | - } | ||
116 | - | ||
117 | - if (a.low < b.low) { | ||
118 | - aIsLargerSignificand = 0; | ||
119 | - } else if (b.low < a.low) { | ||
120 | - aIsLargerSignificand = 1; | ||
121 | - } else { | ||
122 | - aIsLargerSignificand = (a.high < b.high) ? 1 : 0; | ||
123 | - } | ||
124 | - | ||
125 | - if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) { | ||
126 | - if (is_snan(b_cls)) { | ||
127 | - return floatx80_silence_nan(b, status); | ||
128 | - } | ||
129 | - return b; | ||
130 | - } else { | ||
131 | - if (is_snan(a_cls)) { | ||
132 | - return floatx80_silence_nan(a, status); | ||
133 | - } | ||
134 | - return a; | ||
135 | - } | ||
136 | -} | ||
137 | - | ||
138 | /*---------------------------------------------------------------------------- | ||
139 | | Returns 1 if the quadruple-precision floating-point value `a' is a quiet | ||
140 | | NaN; otherwise returns 0. | ||
58 | -- | 141 | -- |
59 | 2.34.1 | 142 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The field is encoded as [0-3], which is convenient for | 3 | Unpacking and repacking the parts may be slightly more work |
4 | indexing our array of function pointers, but the true | 4 | than we did before, but we get to reuse more code. For a |
5 | value is [1-4]. Adjust before calling do_mem_zpa. | 5 | code path handling exceptional values, this is an improvement. |
6 | 6 | ||
7 | Add an assert, and move the comment re passing ZT to | 7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
8 | the helper back next to the relevant code. | 8 | Message-id: 20241203203949.483774-8-richard.henderson@linaro.org |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | fpu/softfloat.c | 43 +++++-------------------------------------- | ||
13 | 1 file changed, 5 insertions(+), 38 deletions(-) | ||
9 | 14 | ||
10 | Cc: qemu-stable@nongnu.org | 15 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c |
11 | Fixes: 206adacfb8d ("target/arm: Add mte helpers for sve scalar + int loads") | ||
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Tested-by: Gustavo Romero <gustavo.romero@linaro.org> | ||
14 | Message-id: 20240207025210.8837-3-richard.henderson@linaro.org | ||
15 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | target/arm/tcg/translate-sve.c | 16 ++++++++-------- | ||
19 | 1 file changed, 8 insertions(+), 8 deletions(-) | ||
20 | |||
21 | diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/tcg/translate-sve.c | 17 | --- a/fpu/softfloat.c |
24 | +++ b/target/arm/tcg/translate-sve.c | 18 | +++ b/fpu/softfloat.c |
25 | @@ -XXX,XX +XXX,XX @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | 19 | @@ -XXX,XX +XXX,XX @@ void normalizeFloatx80Subnormal(uint64_t aSig, int32_t *zExpPtr, |
26 | TCGv_ptr t_pg; | 20 | |
27 | int desc = 0; | 21 | floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) |
28 | 22 | { | |
29 | - /* | 23 | - bool aIsLargerSignificand; |
30 | - * For e.g. LD4, there are not enough arguments to pass all 4 | 24 | - FloatClass a_cls, b_cls; |
31 | - * registers as pointers, so encode the regno into the data field. | 25 | + FloatParts128 pa, pb, *pr; |
32 | - * For consistency, do this even for LD1. | 26 | |
33 | - */ | 27 | - /* This is not complete, but is good enough for pickNaN. */ |
34 | + assert(mte_n >= 1 && mte_n <= 4); | 28 | - a_cls = (!floatx80_is_any_nan(a) |
35 | if (s->mte_active[0]) { | 29 | - ? float_class_normal |
36 | int msz = dtype_msz(dtype); | 30 | - : floatx80_is_signaling_nan(a, status) |
37 | 31 | - ? float_class_snan | |
38 | @@ -XXX,XX +XXX,XX @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | 32 | - : float_class_qnan); |
39 | addr = clean_data_tbi(s, addr); | 33 | - b_cls = (!floatx80_is_any_nan(b) |
34 | - ? float_class_normal | ||
35 | - : floatx80_is_signaling_nan(b, status) | ||
36 | - ? float_class_snan | ||
37 | - : float_class_qnan); | ||
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); | ||
40 | } | 47 | } |
41 | 48 | ||
42 | + /* | 49 | - if (a.low < b.low) { |
43 | + * For e.g. LD4, there are not enough arguments to pass all 4 | 50 | - aIsLargerSignificand = 0; |
44 | + * registers as pointers, so encode the regno into the data field. | 51 | - } else if (b.low < a.low) { |
45 | + * For consistency, do this even for LD1. | 52 | - aIsLargerSignificand = 1; |
46 | + */ | 53 | - } else { |
47 | desc = simd_desc(vsz, vsz, zt | desc); | 54 | - aIsLargerSignificand = (a.high < b.high) ? 1 : 0; |
48 | t_pg = tcg_temp_new_ptr(); | 55 | - } |
49 | 56 | - | |
50 | @@ -XXX,XX +XXX,XX @@ static void do_ld_zpa(DisasContext *s, int zt, int pg, | 57 | - if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) { |
51 | * accessible via the instruction encoding. | 58 | - if (is_snan(b_cls)) { |
52 | */ | 59 | - return floatx80_silence_nan(b, status); |
53 | assert(fn != NULL); | 60 | - } |
54 | - do_mem_zpa(s, zt, pg, addr, dtype, nreg, false, fn); | 61 | - return b; |
55 | + do_mem_zpa(s, zt, pg, addr, dtype, nreg + 1, false, fn); | 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); | ||
56 | } | 70 | } |
57 | 71 | ||
58 | static bool trans_LD_zprr(DisasContext *s, arg_rprr_load *a) | 72 | /*---------------------------------------------------------------------------- |
59 | @@ -XXX,XX +XXX,XX @@ static void do_st_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, | ||
60 | if (nreg == 0) { | ||
61 | /* ST1 */ | ||
62 | fn = fn_single[s->mte_active[0]][be][msz][esz]; | ||
63 | - nreg = 1; | ||
64 | } else { | ||
65 | /* ST2, ST3, ST4 -- msz == esz, enforced by encoding */ | ||
66 | assert(msz == esz); | ||
67 | fn = fn_multiple[s->mte_active[0]][be][nreg - 1][msz]; | ||
68 | } | ||
69 | assert(fn != NULL); | ||
70 | - do_mem_zpa(s, zt, pg, addr, msz_dtype(s, msz), nreg, true, fn); | ||
71 | + do_mem_zpa(s, zt, pg, addr, msz_dtype(s, msz), nreg + 1, true, fn); | ||
72 | } | ||
73 | |||
74 | static bool trans_ST_zprr(DisasContext *s, arg_rprr_store *a) | ||
75 | -- | 73 | -- |
76 | 2.34.1 | 74 | 2.34.1 | diff view generated by jsdifflib |
1 | Add the GPIO, watchdog, dual-timer and I2C devices to the mps3-an536 | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | board. These are all simple devices that just need to be created and | 2 | |
3 | wired up. | 3 | Inline pickNaN into its only caller. This makes one assert |
4 | 4 | redundant with the immediately preceding IF. | |
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-9-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: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
7 | Message-id: 20240206132931.38376-12-peter.maydell@linaro.org | ||
8 | --- | 10 | --- |
9 | hw/arm/mps3r.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ | 11 | fpu/softfloat-parts.c.inc | 82 +++++++++++++++++++++++++---- |
10 | 1 file changed, 59 insertions(+) | 12 | fpu/softfloat-specialize.c.inc | 96 ---------------------------------- |
11 | 13 | 2 files changed, 73 insertions(+), 105 deletions(-) | |
12 | diff --git a/hw/arm/mps3r.c b/hw/arm/mps3r.c | 14 | |
15 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc | ||
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/arm/mps3r.c | 17 | --- a/fpu/softfloat-parts.c.inc |
15 | +++ b/hw/arm/mps3r.c | 18 | +++ b/fpu/softfloat-parts.c.inc |
16 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void partsN(return_nan)(FloatPartsN *a, float_status *s) |
17 | #include "sysemu/sysemu.h" | 20 | static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, |
18 | #include "hw/boards.h" | 21 | float_status *s) |
19 | #include "hw/or-irq.h" | 22 | { |
20 | +#include "hw/qdev-clock.h" | 23 | + int cmp, which; |
21 | #include "hw/qdev-properties.h" | ||
22 | #include "hw/arm/boot.h" | ||
23 | #include "hw/arm/bsa.h" | ||
24 | #include "hw/char/cmsdk-apb-uart.h" | ||
25 | +#include "hw/i2c/arm_sbcon_i2c.h" | ||
26 | #include "hw/intc/arm_gicv3.h" | ||
27 | +#include "hw/misc/unimp.h" | ||
28 | +#include "hw/timer/cmsdk-apb-dualtimer.h" | ||
29 | +#include "hw/watchdog/cmsdk-apb-watchdog.h" | ||
30 | |||
31 | /* Define the layout of RAM and ROM in a board */ | ||
32 | typedef struct RAMInfo { | ||
33 | @@ -XXX,XX +XXX,XX @@ struct MPS3RMachineState { | ||
34 | CMSDKAPBUART uart[MPS3R_CPU_MAX + MPS3R_UART_MAX]; | ||
35 | OrIRQState cpu_uart_oflow[MPS3R_CPU_MAX]; | ||
36 | OrIRQState uart_oflow; | ||
37 | + CMSDKAPBWatchdog watchdog; | ||
38 | + CMSDKAPBDualTimer dualtimer; | ||
39 | + ArmSbconI2CState i2c[5]; | ||
40 | + Clock *clk; | ||
41 | }; | ||
42 | |||
43 | #define TYPE_MPS3R_MACHINE "mps3r" | ||
44 | @@ -XXX,XX +XXX,XX @@ static void mps3r_common_init(MachineState *machine) | ||
45 | MemoryRegion *sysmem = get_system_memory(); | ||
46 | DeviceState *gicdev; | ||
47 | |||
48 | + mms->clk = clock_new(OBJECT(machine), "CLK"); | ||
49 | + clock_set_hz(mms->clk, CLK_FRQ); | ||
50 | + | 24 | + |
51 | for (const RAMInfo *ri = mmc->raminfo; ri->name; ri++) { | 25 | if (is_snan(a->cls) || is_snan(b->cls)) { |
52 | MemoryRegion *mr = mr_for_raminfo(mms, ri); | 26 | float_raise(float_flag_invalid | float_flag_invalid_snan, s); |
53 | memory_region_add_subregion(sysmem, ri->base, mr); | ||
54 | @@ -XXX,XX +XXX,XX @@ static void mps3r_common_init(MachineState *machine) | ||
55 | qdev_get_gpio_in(gicdev, combirq)); | ||
56 | } | 27 | } |
57 | 28 | ||
58 | + for (int i = 0; i < 4; i++) { | 29 | if (s->default_nan_mode) { |
59 | + /* CMSDK GPIO controllers */ | 30 | parts_default_nan(a, s); |
60 | + g_autofree char *s = g_strdup_printf("gpio%d", i); | 31 | - } else { |
61 | + create_unimplemented_device(s, 0xe0000000 + i * 0x1000, 0x1000); | 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; | ||
62 | + } | 45 | + } |
63 | + | 46 | + |
64 | + object_initialize_child(OBJECT(mms), "watchdog", &mms->watchdog, | 47 | + switch (s->float_2nan_prop_rule) { |
65 | + TYPE_CMSDK_APB_WATCHDOG); | 48 | + case float_2nan_prop_s_ab: |
66 | + qdev_connect_clock_in(DEVICE(&mms->watchdog), "WDOGCLK", mms->clk); | 49 | if (is_snan(a->cls)) { |
67 | + sysbus_realize(SYS_BUS_DEVICE(&mms->watchdog), &error_fatal); | 50 | - parts_silence_nan(a, s); |
68 | + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->watchdog), 0, | 51 | + which = 0; |
69 | + qdev_get_gpio_in(gicdev, 0)); | 52 | + } else if (is_snan(b->cls)) { |
70 | + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->watchdog), 0, 0xe0100000); | 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 | + } | ||
71 | + | 108 | + |
72 | + object_initialize_child(OBJECT(mms), "dualtimer", &mms->dualtimer, | 109 | + if (which) { |
73 | + TYPE_CMSDK_APB_DUALTIMER); | 110 | + a = b; |
74 | + qdev_connect_clock_in(DEVICE(&mms->dualtimer), "TIMCLK", mms->clk); | 111 | + } |
75 | + sysbus_realize(SYS_BUS_DEVICE(&mms->dualtimer), &error_fatal); | 112 | + if (is_snan(a->cls)) { |
76 | + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 0, | 113 | + parts_silence_nan(a, s); |
77 | + qdev_get_gpio_in(gicdev, 3)); | 114 | } |
78 | + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 1, | 115 | return a; |
79 | + qdev_get_gpio_in(gicdev, 1)); | 116 | } |
80 | + sysbus_connect_irq(SYS_BUS_DEVICE(&mms->dualtimer), 2, | 117 | diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc |
81 | + qdev_get_gpio_in(gicdev, 2)); | 118 | index XXXXXXX..XXXXXXX 100644 |
82 | + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->dualtimer), 0, 0xe0101000); | 119 | --- a/fpu/softfloat-specialize.c.inc |
83 | + | 120 | +++ b/fpu/softfloat-specialize.c.inc |
84 | + for (int i = 0; i < ARRAY_SIZE(mms->i2c); i++) { | 121 | @@ -XXX,XX +XXX,XX @@ bool float32_is_signaling_nan(float32 a_, float_status *status) |
85 | + static const hwaddr i2cbase[] = {0xe0102000, /* Touch */ | 122 | } |
86 | + 0xe0103000, /* Audio */ | 123 | } |
87 | + 0xe0107000, /* Shield0 */ | 124 | |
88 | + 0xe0108000, /* Shield1 */ | 125 | -/*---------------------------------------------------------------------------- |
89 | + 0xe0109000}; /* DDR4 EEPROM */ | 126 | -| Select which NaN to propagate for a two-input operation. |
90 | + g_autofree char *s = g_strdup_printf("i2c%d", i); | 127 | -| IEEE754 doesn't specify all the details of this, so the |
91 | + | 128 | -| algorithm is target-specific. |
92 | + object_initialize_child(OBJECT(mms), s, &mms->i2c[i], | 129 | -| The routine is passed various bits of information about the |
93 | + TYPE_ARM_SBCON_I2C); | 130 | -| two NaNs and should return 0 to select NaN a and 1 for NaN b. |
94 | + sysbus_realize(SYS_BUS_DEVICE(&mms->i2c[i]), &error_fatal); | 131 | -| Note that signalling NaNs are always squashed to quiet NaNs |
95 | + sysbus_mmio_map(SYS_BUS_DEVICE(&mms->i2c[i]), 0, i2cbase[i]); | 132 | -| by the caller, by calling floatXX_silence_nan() before |
96 | + if (i != 2 && i != 3) { | 133 | -| returning them. |
97 | + /* | 134 | -| |
98 | + * internal-only bus: mark it full to avoid user-created | 135 | -| aIsLargerSignificand is only valid if both a and b are NaNs |
99 | + * i2c devices being plugged into it. | 136 | -| of some kind, and is true if a has the larger significand, |
100 | + */ | 137 | -| or if both a and b have the same significand but a is |
101 | + qbus_mark_full(qdev_get_child_bus(DEVICE(&mms->i2c[i]), "i2c")); | 138 | -| positive but b is negative. It is only needed for the x87 |
102 | + } | 139 | -| tie-break rule. |
103 | + } | 140 | -*----------------------------------------------------------------------------*/ |
104 | + | 141 | - |
105 | mms->bootinfo.ram_size = machine->ram_size; | 142 | -static int pickNaN(FloatClass a_cls, FloatClass b_cls, |
106 | mms->bootinfo.board_id = -1; | 143 | - bool aIsLargerSignificand, float_status *status) |
107 | mms->bootinfo.loader_start = mmc->loader_start; | 144 | -{ |
145 | - /* | ||
146 | - * We guarantee not to require the target to tell us how to | ||
147 | - * pick a NaN if we're always returning the default NaN. | ||
148 | - * But if we're not in default-NaN mode then the target must | ||
149 | - * specify via set_float_2nan_prop_rule(). | ||
150 | - */ | ||
151 | - assert(!status->default_nan_mode); | ||
152 | - | ||
153 | - switch (status->float_2nan_prop_rule) { | ||
154 | - case float_2nan_prop_s_ab: | ||
155 | - if (is_snan(a_cls)) { | ||
156 | - return 0; | ||
157 | - } else if (is_snan(b_cls)) { | ||
158 | - return 1; | ||
159 | - } else if (is_qnan(a_cls)) { | ||
160 | - return 0; | ||
161 | - } else { | ||
162 | - return 1; | ||
163 | - } | ||
164 | - break; | ||
165 | - case float_2nan_prop_s_ba: | ||
166 | - if (is_snan(b_cls)) { | ||
167 | - return 1; | ||
168 | - } else if (is_snan(a_cls)) { | ||
169 | - return 0; | ||
170 | - } else if (is_qnan(b_cls)) { | ||
171 | - return 1; | ||
172 | - } else { | ||
173 | - return 0; | ||
174 | - } | ||
175 | - break; | ||
176 | - case float_2nan_prop_ab: | ||
177 | - if (is_nan(a_cls)) { | ||
178 | - return 0; | ||
179 | - } else { | ||
180 | - return 1; | ||
181 | - } | ||
182 | - break; | ||
183 | - case float_2nan_prop_ba: | ||
184 | - if (is_nan(b_cls)) { | ||
185 | - return 1; | ||
186 | - } else { | ||
187 | - return 0; | ||
188 | - } | ||
189 | - break; | ||
190 | - case float_2nan_prop_x87: | ||
191 | - /* | ||
192 | - * This implements x87 NaN propagation rules: | ||
193 | - * SNaN + QNaN => return the QNaN | ||
194 | - * two SNaNs => return the one with the larger significand, silenced | ||
195 | - * two QNaNs => return the one with the larger significand | ||
196 | - * SNaN and a non-NaN => return the SNaN, silenced | ||
197 | - * QNaN and a non-NaN => return the QNaN | ||
198 | - * | ||
199 | - * If we get down to comparing significands and they are the same, | ||
200 | - * return the NaN with the positive sign bit (if any). | ||
201 | - */ | ||
202 | - if (is_snan(a_cls)) { | ||
203 | - if (is_snan(b_cls)) { | ||
204 | - return aIsLargerSignificand ? 0 : 1; | ||
205 | - } | ||
206 | - return is_qnan(b_cls) ? 1 : 0; | ||
207 | - } else if (is_qnan(a_cls)) { | ||
208 | - if (is_snan(b_cls) || !is_qnan(b_cls)) { | ||
209 | - return 0; | ||
210 | - } else { | ||
211 | - return aIsLargerSignificand ? 0 : 1; | ||
212 | - } | ||
213 | - } else { | ||
214 | - return 1; | ||
215 | - } | ||
216 | - default: | ||
217 | - g_assert_not_reached(); | ||
218 | - } | ||
219 | -} | ||
220 | - | ||
221 | /*---------------------------------------------------------------------------- | ||
222 | | Returns 1 if the double-precision floating-point value `a' is a quiet | ||
223 | | NaN; otherwise returns 0. | ||
108 | -- | 224 | -- |
109 | 2.34.1 | 225 | 2.34.1 |
110 | 226 | ||
111 | 227 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | The API does not generate an error for setting ASYNC | SYNC; that merely | 3 | Remember if there was an SNaN, and use that to simplify |
4 | constrains the selection vs the per-cpu default. For qemu linux-user, | 4 | float_2nan_prop_s_{ab,ba} to only the snan component. |
5 | choose SYNC as the default. | 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 | Cc: qemu-stable@nongnu.org | ||
8 | Reported-by: Gustavo Romero <gustavo.romero@linaro.org> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Tested-by: Gustavo Romero <gustavo.romero@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20240207025210.8837-2-richard.henderson@linaro.org | 11 | Message-id: 20241203203949.483774-10-richard.henderson@linaro.org |
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 13 | --- |
14 | linux-user/aarch64/target_prctl.h | 29 +++++++++++++++++------------ | 14 | fpu/softfloat-parts.c.inc | 32 ++++++++++++-------------------- |
15 | 1 file changed, 17 insertions(+), 12 deletions(-) | 15 | 1 file changed, 12 insertions(+), 20 deletions(-) |
16 | 16 | ||
17 | diff --git a/linux-user/aarch64/target_prctl.h b/linux-user/aarch64/target_prctl.h | 17 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
18 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/linux-user/aarch64/target_prctl.h | 19 | --- a/fpu/softfloat-parts.c.inc |
20 | +++ b/linux-user/aarch64/target_prctl.h | 20 | +++ b/fpu/softfloat-parts.c.inc |
21 | @@ -XXX,XX +XXX,XX @@ static abi_long do_prctl_set_tagged_addr_ctrl(CPUArchState *env, abi_long arg2) | 21 | @@ -XXX,XX +XXX,XX @@ static void partsN(return_nan)(FloatPartsN *a, float_status *s) |
22 | env->tagged_addr_enable = arg2 & PR_TAGGED_ADDR_ENABLE; | 22 | static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, |
23 | 23 | float_status *s) | |
24 | if (cpu_isar_feature(aa64_mte, cpu)) { | 24 | { |
25 | - switch (arg2 & PR_MTE_TCF_MASK) { | 25 | + bool have_snan = false; |
26 | - case PR_MTE_TCF_NONE: | 26 | int cmp, which; |
27 | - case PR_MTE_TCF_SYNC: | 27 | |
28 | - case PR_MTE_TCF_ASYNC: | 28 | if (is_snan(a->cls) || is_snan(b->cls)) { |
29 | - break; | 29 | float_raise(float_flag_invalid | float_flag_invalid_snan, s); |
30 | - default: | 30 | + have_snan = true; |
31 | - return -EINVAL; | 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; | ||
32 | - } | 60 | - } |
33 | - | 61 | - break; |
34 | /* | 62 | + /* fall through */ |
35 | * Write PR_MTE_TCF to SCTLR_EL1[TCF0]. | 63 | case float_2nan_prop_ab: |
36 | - * Note that the syscall values are consistent with hw. | 64 | which = is_nan(a->cls) ? 0 : 1; |
37 | + * | 65 | break; |
38 | + * The kernel has a per-cpu configuration for the sysadmin, | 66 | + case float_2nan_prop_s_ba: |
39 | + * /sys/devices/system/cpu/cpu<N>/mte_tcf_preferred, | 67 | + if (have_snan) { |
40 | + * which qemu does not implement. | 68 | + which = is_snan(b->cls) ? 1 : 0; |
41 | + * | 69 | + break; |
42 | + * Because there is no performance difference between the modes, and | ||
43 | + * because SYNC is most useful for debugging MTE errors, choose SYNC | ||
44 | + * as the preferred mode. With this preference, and the way the API | ||
45 | + * uses only two bits, there is no way for the program to select | ||
46 | + * ASYMM mode. | ||
47 | */ | ||
48 | - env->cp15.sctlr_el[1] = | ||
49 | - deposit64(env->cp15.sctlr_el[1], 38, 2, arg2 >> PR_MTE_TCF_SHIFT); | ||
50 | + unsigned tcf = 0; | ||
51 | + if (arg2 & PR_MTE_TCF_SYNC) { | ||
52 | + tcf = 1; | ||
53 | + } else if (arg2 & PR_MTE_TCF_ASYNC) { | ||
54 | + tcf = 2; | ||
55 | + } | 70 | + } |
56 | + env->cp15.sctlr_el[1] = deposit64(env->cp15.sctlr_el[1], 38, 2, tcf); | 71 | + /* fall through */ |
57 | 72 | case float_2nan_prop_ba: | |
58 | /* | 73 | which = is_nan(b->cls) ? 1 : 0; |
59 | * Write PR_MTE_TAG to GCR_EL1[Exclude]. | 74 | break; |
60 | -- | 75 | -- |
61 | 2.34.1 | 76 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | These functions "use the standard load helpers", but | 3 | Move the fractional comparison to the end of the |
4 | fail to clean_data_tbi or populate mtedesc. | 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 | Cc: qemu-stable@nongnu.org | 9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | Message-id: 20241203203949.483774-11-richard.henderson@linaro.org |
9 | Tested-by: Gustavo Romero <gustavo.romero@linaro.org> | ||
10 | Message-id: 20240207025210.8837-6-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/tcg/translate-sve.c | 15 +++++++++++++-- | 14 | fpu/softfloat-parts.c.inc | 19 +++++++++---------- |
14 | 1 file changed, 13 insertions(+), 2 deletions(-) | 15 | 1 file changed, 9 insertions(+), 10 deletions(-) |
15 | 16 | ||
16 | diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.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/tcg/translate-sve.c | 19 | --- a/fpu/softfloat-parts.c.inc |
19 | +++ b/target/arm/tcg/translate-sve.c | 20 | +++ b/fpu/softfloat-parts.c.inc |
20 | @@ -XXX,XX +XXX,XX @@ static void do_ldrq(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype) | 21 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, |
21 | unsigned vsz = vec_full_reg_size(s); | 22 | return a; |
22 | TCGv_ptr t_pg; | ||
23 | int poff; | ||
24 | + uint32_t desc; | ||
25 | |||
26 | /* Load the first quadword using the normal predicated load helpers. */ | ||
27 | + if (!s->mte_active[0]) { | ||
28 | + addr = clean_data_tbi(s, addr); | ||
29 | + } | ||
30 | + | ||
31 | poff = pred_full_reg_offset(s, pg); | ||
32 | if (vsz > 16) { | ||
33 | /* | ||
34 | @@ -XXX,XX +XXX,XX @@ static void do_ldrq(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype) | ||
35 | |||
36 | gen_helper_gvec_mem *fn | ||
37 | = ldr_fns[s->mte_active[0]][s->be_data == MO_BE][dtype][0]; | ||
38 | - fn(tcg_env, t_pg, addr, tcg_constant_i32(simd_desc(16, 16, zt))); | ||
39 | + desc = make_svemte_desc(s, 16, 1, dtype_msz(dtype), false, zt); | ||
40 | + fn(tcg_env, t_pg, addr, tcg_constant_i32(desc)); | ||
41 | |||
42 | /* Replicate that first quadword. */ | ||
43 | if (vsz > 16) { | ||
44 | @@ -XXX,XX +XXX,XX @@ static void do_ldro(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype) | ||
45 | unsigned vsz_r32; | ||
46 | TCGv_ptr t_pg; | ||
47 | int poff, doff; | ||
48 | + uint32_t desc; | ||
49 | |||
50 | if (vsz < 32) { | ||
51 | /* | ||
52 | @@ -XXX,XX +XXX,XX @@ static void do_ldro(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype) | ||
53 | } | 23 | } |
54 | 24 | ||
55 | /* Load the first octaword using the normal predicated load helpers. */ | 25 | - cmp = frac_cmp(a, b); |
56 | + if (!s->mte_active[0]) { | 26 | - if (cmp == 0) { |
57 | + addr = clean_data_tbi(s, addr); | 27 | - cmp = a->sign < b->sign; |
58 | + } | 28 | - } |
59 | 29 | - | |
60 | poff = pred_full_reg_offset(s, pg); | 30 | switch (s->float_2nan_prop_rule) { |
61 | if (vsz > 32) { | 31 | case float_2nan_prop_s_ab: |
62 | @@ -XXX,XX +XXX,XX @@ static void do_ldro(DisasContext *s, int zt, int pg, TCGv_i64 addr, int dtype) | 32 | if (have_snan) { |
63 | 33 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, | |
64 | gen_helper_gvec_mem *fn | 34 | * return the NaN with the positive sign bit (if any). |
65 | = ldr_fns[s->mte_active[0]][s->be_data == MO_BE][dtype][0]; | 35 | */ |
66 | - fn(tcg_env, t_pg, addr, tcg_constant_i32(simd_desc(32, 32, zt))); | 36 | if (is_snan(a->cls)) { |
67 | + desc = make_svemte_desc(s, 32, 1, dtype_msz(dtype), false, zt); | 37 | - if (is_snan(b->cls)) { |
68 | + fn(tcg_env, t_pg, addr, tcg_constant_i32(desc)); | 38 | - which = cmp > 0 ? 0 : 1; |
69 | 39 | - } else { | |
70 | /* | 40 | + if (!is_snan(b->cls)) { |
71 | * Replicate that first octaword. | 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(); | ||
72 | -- | 63 | -- |
73 | 2.34.1 | 64 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Suggested-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Replace the "index" selecting between A and B with a result variable |
4 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 4 | of the proper type. This improves clarity within the function. |
5 | Message-id: 20240213155214.13619-3-philmd@linaro.org | 5 | |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Message-id: 20241203203949.483774-12-richard.henderson@linaro.org | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 10 | --- |
9 | hw/arm/stellaris.c | 26 ++++++++++++++++++++++---- | 11 | fpu/softfloat-parts.c.inc | 28 +++++++++++++--------------- |
10 | 1 file changed, 22 insertions(+), 4 deletions(-) | 12 | 1 file changed, 13 insertions(+), 15 deletions(-) |
11 | 13 | ||
12 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | 14 | diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc |
13 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/hw/arm/stellaris.c | 16 | --- a/fpu/softfloat-parts.c.inc |
15 | +++ b/hw/arm/stellaris.c | 17 | +++ b/fpu/softfloat-parts.c.inc |
16 | @@ -XXX,XX +XXX,XX @@ static void stellaris_sys_instance_init(Object *obj) | 18 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, |
17 | s->sysclk = qdev_init_clock_out(DEVICE(s), "SYSCLK"); | 19 | float_status *s) |
20 | { | ||
21 | bool have_snan = false; | ||
22 | - int cmp, which; | ||
23 | + FloatPartsN *ret; | ||
24 | + int cmp; | ||
25 | |||
26 | if (is_snan(a->cls) || is_snan(b->cls)) { | ||
27 | float_raise(float_flag_invalid | float_flag_invalid_snan, s); | ||
28 | @@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, | ||
29 | switch (s->float_2nan_prop_rule) { | ||
30 | case float_2nan_prop_s_ab: | ||
31 | if (have_snan) { | ||
32 | - which = is_snan(a->cls) ? 0 : 1; | ||
33 | + ret = is_snan(a->cls) ? a : b; | ||
34 | break; | ||
35 | } | ||
36 | /* fall through */ | ||
37 | case float_2nan_prop_ab: | ||
38 | - which = is_nan(a->cls) ? 0 : 1; | ||
39 | + ret = is_nan(a->cls) ? a : b; | ||
40 | break; | ||
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; | ||
18 | } | 94 | } |
19 | 95 | ||
20 | -/* I2C controller. */ | 96 | static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, |
21 | +/* | ||
22 | + * I2C controller. | ||
23 | + * ??? For now we only implement the master interface. | ||
24 | + */ | ||
25 | |||
26 | #define TYPE_STELLARIS_I2C "stellaris-i2c" | ||
27 | OBJECT_DECLARE_SIMPLE_TYPE(stellaris_i2c_state, STELLARIS_I2C) | ||
28 | @@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_write(void *opaque, hwaddr offset, | ||
29 | stellaris_i2c_update(s); | ||
30 | } | ||
31 | |||
32 | -static void stellaris_i2c_reset(stellaris_i2c_state *s) | ||
33 | +static void stellaris_i2c_reset_enter(Object *obj, ResetType type) | ||
34 | { | ||
35 | + stellaris_i2c_state *s = STELLARIS_I2C(obj); | ||
36 | + | ||
37 | if (s->mcs & STELLARIS_I2C_MCS_BUSBSY) | ||
38 | i2c_end_transfer(s->bus); | ||
39 | +} | ||
40 | + | ||
41 | +static void stellaris_i2c_reset_hold(Object *obj) | ||
42 | +{ | ||
43 | + stellaris_i2c_state *s = STELLARIS_I2C(obj); | ||
44 | |||
45 | s->msa = 0; | ||
46 | s->mcs = 0; | ||
47 | @@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_reset(stellaris_i2c_state *s) | ||
48 | s->mimr = 0; | ||
49 | s->mris = 0; | ||
50 | s->mcr = 0; | ||
51 | +} | ||
52 | + | ||
53 | +static void stellaris_i2c_reset_exit(Object *obj) | ||
54 | +{ | ||
55 | + stellaris_i2c_state *s = STELLARIS_I2C(obj); | ||
56 | + | ||
57 | stellaris_i2c_update(s); | ||
58 | } | ||
59 | |||
60 | @@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_init(Object *obj) | ||
61 | memory_region_init_io(&s->iomem, obj, &stellaris_i2c_ops, s, | ||
62 | "i2c", 0x1000); | ||
63 | sysbus_init_mmio(sbd, &s->iomem); | ||
64 | - /* ??? For now we only implement the master interface. */ | ||
65 | - stellaris_i2c_reset(s); | ||
66 | } | ||
67 | |||
68 | /* Analogue to Digital Converter. This is only partially implemented, | ||
69 | @@ -XXX,XX +XXX,XX @@ type_init(stellaris_machine_init) | ||
70 | static void stellaris_i2c_class_init(ObjectClass *klass, void *data) | ||
71 | { | ||
72 | DeviceClass *dc = DEVICE_CLASS(klass); | ||
73 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
74 | |||
75 | + rc->phases.enter = stellaris_i2c_reset_enter; | ||
76 | + rc->phases.hold = stellaris_i2c_reset_hold; | ||
77 | + rc->phases.exit = stellaris_i2c_reset_exit; | ||
78 | dc->vmsd = &vmstate_stellaris_i2c; | ||
79 | } | ||
80 | |||
81 | -- | 97 | -- |
82 | 2.34.1 | 98 | 2.34.1 |
83 | 99 | ||
84 | 100 | diff view generated by jsdifflib |
1 | We deliberately don't include qtests_npcm7xx in qtests_aarch64, | 1 | From: Leif Lindholm <quic_llindhol@quicinc.com> |
---|---|---|---|
2 | because we already get the coverage of those tests via qtests_arm, | ||
3 | and we don't want to use extra CI minutes testing them twice. | ||
4 | 2 | ||
5 | In commit 327b680877b79c4b we added it to qtests_aarch64; revert | 3 | I'm migrating to Qualcomm's new open source email infrastructure, so |
6 | that change. | 4 | update my email address, and update the mailmap to match. |
7 | 5 | ||
8 | Fixes: 327b680877b79c4b ("tests/qtest: Creating qtest for GMAC Module") | 6 | Signed-off-by: Leif Lindholm <leif.lindholm@oss.qualcomm.com> |
7 | Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com> | ||
8 | Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Message-id: 20241205114047.1125842-1-leif.lindholm@oss.qualcomm.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
11 | Message-id: 20240206163043.315535-1-peter.maydell@linaro.org | ||
12 | --- | 13 | --- |
13 | tests/qtest/meson.build | 1 - | 14 | MAINTAINERS | 2 +- |
14 | 1 file changed, 1 deletion(-) | 15 | .mailmap | 5 +++-- |
16 | 2 files changed, 4 insertions(+), 3 deletions(-) | ||
15 | 17 | ||
16 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | 18 | diff --git a/MAINTAINERS b/MAINTAINERS |
17 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/tests/qtest/meson.build | 20 | --- a/MAINTAINERS |
19 | +++ b/tests/qtest/meson.build | 21 | +++ b/MAINTAINERS |
20 | @@ -XXX,XX +XXX,XX @@ qtests_aarch64 = \ | 22 | @@ -XXX,XX +XXX,XX @@ F: include/hw/ssi/imx_spi.h |
21 | (config_all_devices.has_key('CONFIG_RASPI') ? ['bcm2835-dma-test'] : []) + \ | 23 | SBSA-REF |
22 | (config_all_accel.has_key('CONFIG_TCG') and \ | 24 | M: Radoslaw Biernacki <rad@semihalf.com> |
23 | config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \ | 25 | M: Peter Maydell <peter.maydell@linaro.org> |
24 | - (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \ | 26 | -R: Leif Lindholm <quic_llindhol@quicinc.com> |
25 | ['arm-cpu-features', | 27 | +R: Leif Lindholm <leif.lindholm@oss.qualcomm.com> |
26 | 'numa-test', | 28 | R: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
27 | 'boot-serial-test', | 29 | L: qemu-arm@nongnu.org |
30 | S: Maintained | ||
31 | diff --git a/.mailmap b/.mailmap | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/.mailmap | ||
34 | +++ b/.mailmap | ||
35 | @@ -XXX,XX +XXX,XX @@ Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com> | ||
36 | Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn> | ||
37 | James Hogan <jhogan@kernel.org> <james.hogan@imgtec.com> | ||
38 | Juan Quintela <quintela@trasno.org> <quintela@redhat.com> | ||
39 | -Leif Lindholm <quic_llindhol@quicinc.com> <leif.lindholm@linaro.org> | ||
40 | -Leif Lindholm <quic_llindhol@quicinc.com> <leif@nuviainc.com> | ||
41 | +Leif Lindholm <leif.lindholm@oss.qualcomm.com> <quic_llindhol@quicinc.com> | ||
42 | +Leif Lindholm <leif.lindholm@oss.qualcomm.com> <leif.lindholm@linaro.org> | ||
43 | +Leif Lindholm <leif.lindholm@oss.qualcomm.com> <leif@nuviainc.com> | ||
44 | Luc Michel <luc@lmichel.fr> <luc.michel@git.antfield.fr> | ||
45 | Luc Michel <luc@lmichel.fr> <luc.michel@greensocs.com> | ||
46 | Luc Michel <luc@lmichel.fr> <lmichel@kalray.eu> | ||
28 | -- | 47 | -- |
29 | 2.34.1 | 48 | 2.34.1 |
30 | 49 | ||
31 | 50 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> | 1 | From: Vikram Garhwal <vikram.garhwal@bytedance.com> |
---|---|---|---|
2 | 2 | ||
3 | Similarly to commits dadbb58f59..5ae79fe825 for other ARM boards, | 3 | Previously, maintainer role was paused due to inactive email id. Commit id: |
4 | connect FIQ output of the GIC CPU interfaces to the CPU. | 4 | c009d715721861984c4987bcc78b7ee183e86d75. |
5 | 5 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | 6 | Signed-off-by: Vikram Garhwal <vikram.garhwal@bytedance.com> |
7 | Message-id: 20240130152548.17855-1-philmd@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 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 10 | --- |
11 | hw/arm/xilinx_zynq.c | 2 ++ | 11 | MAINTAINERS | 2 ++ |
12 | 1 file changed, 2 insertions(+) | 12 | 1 file changed, 2 insertions(+) |
13 | 13 | ||
14 | diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c | 14 | diff --git a/MAINTAINERS b/MAINTAINERS |
15 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/xilinx_zynq.c | 16 | --- a/MAINTAINERS |
17 | +++ b/hw/arm/xilinx_zynq.c | 17 | +++ b/MAINTAINERS |
18 | @@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine) | 18 | @@ -XXX,XX +XXX,XX @@ F: tests/qtest/fuzz-sb16-test.c |
19 | sysbus_mmio_map(busdev, 0, MPCORE_PERIPHBASE); | 19 | |
20 | sysbus_connect_irq(busdev, 0, | 20 | Xilinx CAN |
21 | qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_IRQ)); | 21 | M: Francisco Iglesias <francisco.iglesias@amd.com> |
22 | + sysbus_connect_irq(busdev, 1, | 22 | +M: Vikram Garhwal <vikram.garhwal@bytedance.com> |
23 | + qdev_get_gpio_in(DEVICE(cpu), ARM_CPU_FIQ)); | 23 | S: Maintained |
24 | 24 | F: hw/net/can/xlnx-* | |
25 | for (n = 0; n < 64; n++) { | 25 | F: include/hw/net/xlnx-* |
26 | pic[n] = qdev_get_gpio_in(dev, n); | 26 | @@ -XXX,XX +XXX,XX @@ F: include/hw/rx/ |
27 | CAN bus subsystem and hardware | ||
28 | M: Pavel Pisa <pisa@cmp.felk.cvut.cz> | ||
29 | M: Francisco Iglesias <francisco.iglesias@amd.com> | ||
30 | +M: Vikram Garhwal <vikram.garhwal@bytedance.com> | ||
31 | S: Maintained | ||
32 | W: https://canbus.pages.fel.cvut.cz/ | ||
33 | F: net/can/* | ||
27 | -- | 34 | -- |
28 | 2.34.1 | 35 | 2.34.1 |
29 | |||
30 | diff view generated by jsdifflib |