1
Arm pullreq: Rémi's ARMv8.4-SEL2 support is the big thing here.
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
thanks
5
thanks
4
-- PMM
6
-- PMM
5
7
6
The following changes since commit f1fcb6851aba6dd9838886dc179717a11e344a1c:
8
The following changes since commit 97f2796a3736ed37a1b85dc1c76a6c45b829dd17:
7
9
8
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2021-01-19' into staging (2021-01-19 11:57:07 +0000)
10
Open 10.0 development tree (2024-12-10 17:41:17 +0000)
9
11
10
are available in the Git repository at:
12
are available in the Git repository at:
11
13
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210119
14
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20241211
13
15
14
for you to fetch changes up to 6d39956891b3d1857af84f72f0230a6d99eb3b6a:
16
for you to fetch changes up to 1abe28d519239eea5cf9620bb13149423e5665f8:
15
17
16
docs: Build and install all the docs in a single manual (2021-01-19 14:38:53 +0000)
18
MAINTAINERS: Add correct email address for Vikram Garhwal (2024-12-11 15:31:09 +0000)
17
19
18
----------------------------------------------------------------
20
----------------------------------------------------------------
19
target-arm queue:
21
target-arm queue:
20
* Implement IMPDEF pauth algorithm
22
* hw/net/lan9118: Extract PHY model, reuse with imx_fec, fix bugs
21
* Support ARMv8.4-SEL2
23
* fpu: Make muladd NaN handling runtime-selected, not compile-time
22
* Fix bug where we were truncating predicate vector lengths in SVE insns
24
* fpu: Make default NaN pattern runtime-selected, not compile-time
23
* Implement new pvpanic-pci device
25
* fpu: Minor NaN-related cleanups
24
* npcm7xx_adc-test: Fix memleak in adc_qom_set
26
* MAINTAINERS: email address updates
25
* target/arm/m_helper: Silence GCC 10 maybe-uninitialized error
26
* docs: Build and install all the docs in a single manual
27
27
28
----------------------------------------------------------------
28
----------------------------------------------------------------
29
Gan Qixin (1):
29
Bernhard Beschow (5):
30
npcm7xx_adc-test: Fix memleak in adc_qom_set
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
31
35
32
Mihai Carabas (4):
36
Leif Lindholm (1):
33
hw/misc/pvpanic: split-out generic and bus dependent code
37
MAINTAINERS: update email address for Leif Lindholm
34
hw/misc/pvpanic: add PCI interface support
35
pvpanic : update pvpanic spec document
36
tests/qtest: add a test case for pvpanic-pci
37
38
38
Peter Maydell (1):
39
Peter Maydell (54):
39
docs: Build and install all the docs in a single manual
40
fpu: handle raising Invalid for infzero in pick_nan_muladd
41
fpu: Check for default_nan_mode before calling pickNaNMulAdd
42
softfloat: Allow runtime choice of inf * 0 + NaN result
43
tests/fp: Explicitly set inf-zero-nan rule
44
target/arm: Set FloatInfZeroNaNRule explicitly
45
target/s390: Set FloatInfZeroNaNRule explicitly
46
target/ppc: Set FloatInfZeroNaNRule explicitly
47
target/mips: Set FloatInfZeroNaNRule explicitly
48
target/sparc: Set FloatInfZeroNaNRule explicitly
49
target/xtensa: Set FloatInfZeroNaNRule explicitly
50
target/x86: Set FloatInfZeroNaNRule explicitly
51
target/loongarch: Set FloatInfZeroNaNRule explicitly
52
target/hppa: Set FloatInfZeroNaNRule explicitly
53
softfloat: Pass have_snan to pickNaNMulAdd
54
softfloat: Allow runtime choice of NaN propagation for muladd
55
tests/fp: Explicitly set 3-NaN propagation rule
56
target/arm: Set Float3NaNPropRule explicitly
57
target/loongarch: Set Float3NaNPropRule explicitly
58
target/ppc: Set Float3NaNPropRule explicitly
59
target/s390x: Set Float3NaNPropRule explicitly
60
target/sparc: Set Float3NaNPropRule explicitly
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
40
94
41
Philippe Mathieu-Daudé (1):
95
Richard Henderson (11):
42
target/arm/m_helper: Silence GCC 10 maybe-uninitialized error
96
target/arm: Copy entire float_status in is_ebf
97
softfloat: Inline pickNaNMulAdd
98
softfloat: Use goto for default nan case in pick_nan_muladd
99
softfloat: Remove which from parts_pick_nan_muladd
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
43
107
44
Richard Henderson (7):
108
Vikram Garhwal (1):
45
target/arm: Implement an IMPDEF pauth algorithm
109
MAINTAINERS: Add correct email address for Vikram Garhwal
46
target/arm: Add cpu properties to control pauth
47
target/arm: Use object_property_add_bool for "sve" property
48
target/arm: Introduce PREDDESC field definitions
49
target/arm: Update PFIRST, PNEXT for pred_desc
50
target/arm: Update ZIP, UZP, TRN for pred_desc
51
target/arm: Update REV, PUNPK for pred_desc
52
110
53
Rémi Denis-Courmont (19):
111
MAINTAINERS | 4 +-
54
target/arm: remove redundant tests
112
include/fpu/softfloat-helpers.h | 38 +++-
55
target/arm: add arm_is_el2_enabled() helper
113
include/fpu/softfloat-types.h | 89 +++++++-
56
target/arm: use arm_is_el2_enabled() where applicable
114
include/hw/net/imx_fec.h | 9 +-
57
target/arm: use arm_hcr_el2_eff() where applicable
115
include/hw/net/lan9118_phy.h | 37 ++++
58
target/arm: factor MDCR_EL2 common handling
116
include/hw/net/mii.h | 6 +
59
target/arm: Define isar_feature function to test for presence of SEL2
117
target/mips/fpu_helper.h | 20 ++
60
target/arm: add 64-bit S-EL2 to EL exception table
118
target/sparc/helper.h | 4 +-
61
target/arm: add MMU stage 1 for Secure EL2
119
fpu/softfloat.c | 19 ++
62
target/arm: add ARMv8.4-SEL2 system registers
120
hw/net/imx_fec.c | 146 ++------------
63
target/arm: handle VMID change in secure state
121
hw/net/lan9118.c | 137 ++-----------
64
target/arm: do S1_ptw_translate() before address space lookup
122
hw/net/lan9118_phy.c | 222 ++++++++++++++++++++
65
target/arm: translate NS bit in page-walks
123
linux-user/arm/nwfpe/fpa11.c | 5 +
66
target/arm: generalize 2-stage page-walk condition
124
target/alpha/cpu.c | 2 +
67
target/arm: secure stage 2 translation regime
125
target/arm/cpu.c | 10 +
68
target/arm: set HPFAR_EL2.NS on secure stage 2 faults
126
target/arm/tcg/vec_helper.c | 20 +-
69
target/arm: revector to run-time pick target EL
127
target/hexagon/cpu.c | 2 +
70
target/arm: Implement SCR_EL2.EEL2
128
target/hppa/fpu_helper.c | 12 ++
71
target/arm: enable Secure EL2 in max CPU
129
target/i386/tcg/fpu_helper.c | 12 ++
72
target/arm: refactor vae1_tlbmask()
130
target/loongarch/tcg/fpu_helper.c | 14 +-
73
131
target/m68k/cpu.c | 14 +-
74
docs/conf.py | 46 ++++-
132
target/m68k/fpu_helper.c | 6 +-
75
docs/devel/conf.py | 15 --
133
target/m68k/helper.c | 6 +-
76
docs/index.html.in | 17 --
134
target/microblaze/cpu.c | 2 +
77
docs/interop/conf.py | 28 ---
135
target/mips/msa.c | 10 +
78
docs/meson.build | 64 +++---
136
target/openrisc/cpu.c | 2 +
79
docs/specs/conf.py | 16 --
137
target/ppc/cpu_init.c | 19 ++
80
docs/specs/pci-ids.txt | 1 +
138
target/ppc/fpu_helper.c | 3 +-
81
docs/specs/pvpanic.txt | 13 +-
139
target/riscv/cpu.c | 2 +
82
docs/system/arm/cpu-features.rst | 21 ++
140
target/rx/cpu.c | 2 +
83
docs/system/conf.py | 28 ---
141
target/s390x/cpu.c | 5 +
84
docs/tools/conf.py | 37 ----
142
target/sh4/cpu.c | 2 +
85
docs/user/conf.py | 15 --
143
target/sparc/cpu.c | 6 +
86
include/hw/misc/pvpanic.h | 24 ++-
144
target/sparc/fop_helper.c | 8 +-
87
include/hw/pci/pci.h | 1 +
145
target/sparc/translate.c | 4 +-
88
include/qemu/xxhash.h | 98 +++++++++
146
target/tricore/helper.c | 2 +
89
target/arm/cpu-param.h | 2 +-
147
target/xtensa/cpu.c | 4 +
90
target/arm/cpu.h | 107 ++++++++--
148
target/xtensa/fpu_helper.c | 3 +-
91
target/arm/internals.h | 45 +++++
149
tests/fp/fp-bench.c | 7 +
92
hw/misc/pvpanic-isa.c | 94 +++++++++
150
tests/fp/fp-test-log2.c | 1 +
93
hw/misc/pvpanic-pci.c | 95 +++++++++
151
tests/fp/fp-test.c | 7 +
94
hw/misc/pvpanic.c | 85 +-------
152
fpu/softfloat-parts.c.inc | 152 +++++++++++---
95
target/arm/cpu.c | 23 ++-
153
fpu/softfloat-specialize.c.inc | 412 ++------------------------------------
96
target/arm/cpu64.c | 65 ++++--
154
.mailmap | 5 +-
97
target/arm/helper-a64.c | 8 +-
155
hw/net/Kconfig | 5 +
98
target/arm/helper.c | 414 ++++++++++++++++++++++++++-------------
156
hw/net/meson.build | 1 +
99
target/arm/m_helper.c | 2 +-
157
hw/net/trace-events | 10 +-
100
target/arm/monitor.c | 1 +
158
47 files changed, 778 insertions(+), 730 deletions(-)
101
target/arm/op_helper.c | 4 +-
159
create mode 100644 include/hw/net/lan9118_phy.h
102
target/arm/pauth_helper.c | 27 ++-
160
create mode 100644 hw/net/lan9118_phy.c
103
target/arm/sve_helper.c | 33 ++--
104
target/arm/tlb_helper.c | 3 +
105
target/arm/translate-a64.c | 4 +
106
target/arm/translate-sve.c | 31 ++-
107
target/arm/translate.c | 36 +++-
108
tests/qtest/arm-cpu-features.c | 13 ++
109
tests/qtest/npcm7xx_adc-test.c | 1 +
110
tests/qtest/pvpanic-pci-test.c | 62 ++++++
111
.gitlab-ci.yml | 4 +-
112
hw/i386/Kconfig | 2 +-
113
hw/misc/Kconfig | 12 +-
114
hw/misc/meson.build | 4 +-
115
tests/qtest/meson.build | 3 +-
116
42 files changed, 1080 insertions(+), 524 deletions(-)
117
delete mode 100644 docs/devel/conf.py
118
delete mode 100644 docs/index.html.in
119
delete mode 100644 docs/interop/conf.py
120
delete mode 100644 docs/specs/conf.py
121
delete mode 100644 docs/system/conf.py
122
delete mode 100644 docs/tools/conf.py
123
delete mode 100644 docs/user/conf.py
124
create mode 100644 hw/misc/pvpanic-isa.c
125
create mode 100644 hw/misc/pvpanic-pci.c
126
create mode 100644 tests/qtest/pvpanic-pci-test.c
127
diff view generated by jsdifflib
1
From: Mihai Carabas <mihai.carabas@oracle.com>
1
From: Bernhard Beschow <shentey@gmail.com>
2
2
3
Add PCI interface support for PVPANIC device. Create a new file pvpanic-pci.c
3
A very similar implementation of the same device exists in imx_fec. Prepare for
4
where the PCI specific routines reside and update the build system with the new
4
a common implementation by extracting a device model into its own files.
5
files and config structure.
6
5
7
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
6
Some migration state has been moved into the new device model which breaks
8
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
7
migration compatibility for the following machines:
8
* smdkc210
9
* realview-*
10
* vexpress-*
11
* kzm
12
* mps2-*
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>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
[PMM: wrapped one long line]
20
Message-id: 20241102125724.532843-2-shentey@gmail.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
22
---
13
docs/specs/pci-ids.txt | 1 +
23
include/hw/net/lan9118_phy.h | 37 ++++++++
14
include/hw/misc/pvpanic.h | 1 +
24
hw/net/lan9118.c | 137 +++++-----------------------
15
include/hw/pci/pci.h | 1 +
25
hw/net/lan9118_phy.c | 169 +++++++++++++++++++++++++++++++++++
16
hw/misc/pvpanic-pci.c | 95 +++++++++++++++++++++++++++++++++++++++
26
hw/net/Kconfig | 4 +
17
hw/misc/Kconfig | 6 +++
27
hw/net/meson.build | 1 +
18
hw/misc/meson.build | 1 +
28
5 files changed, 233 insertions(+), 115 deletions(-)
19
6 files changed, 105 insertions(+)
29
create mode 100644 include/hw/net/lan9118_phy.h
20
create mode 100644 hw/misc/pvpanic-pci.c
30
create mode 100644 hw/net/lan9118_phy.c
21
31
22
diff --git a/docs/specs/pci-ids.txt b/docs/specs/pci-ids.txt
32
diff --git a/include/hw/net/lan9118_phy.h b/include/hw/net/lan9118_phy.h
23
index XXXXXXX..XXXXXXX 100644
24
--- a/docs/specs/pci-ids.txt
25
+++ b/docs/specs/pci-ids.txt
26
@@ -XXX,XX +XXX,XX @@ PCI devices (other than virtio):
27
1b36:000d PCI xhci usb host adapter
28
1b36:000f mdpy (mdev sample device), linux/samples/vfio-mdev/mdpy.c
29
1b36:0010 PCIe NVMe device (-device nvme)
30
+1b36:0011 PCI PVPanic device (-device pvpanic-pci)
31
32
All these devices are documented in docs/specs.
33
34
diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h
35
index XXXXXXX..XXXXXXX 100644
36
--- a/include/hw/misc/pvpanic.h
37
+++ b/include/hw/misc/pvpanic.h
38
@@ -XXX,XX +XXX,XX @@
39
#include "qom/object.h"
40
41
#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"
42
+#define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci"
43
44
#define PVPANIC_IOPORT_PROP "ioport"
45
46
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
47
index XXXXXXX..XXXXXXX 100644
48
--- a/include/hw/pci/pci.h
49
+++ b/include/hw/pci/pci.h
50
@@ -XXX,XX +XXX,XX @@ extern bool pci_available;
51
#define PCI_DEVICE_ID_REDHAT_PCIE_BRIDGE 0x000e
52
#define PCI_DEVICE_ID_REDHAT_MDPY 0x000f
53
#define PCI_DEVICE_ID_REDHAT_NVME 0x0010
54
+#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0011
55
#define PCI_DEVICE_ID_REDHAT_QXL 0x0100
56
57
#define FMT_PCIBUS PRIx64
58
diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c
59
new file mode 100644
33
new file mode 100644
60
index XXXXXXX..XXXXXXX
34
index XXXXXXX..XXXXXXX
61
--- /dev/null
35
--- /dev/null
62
+++ b/hw/misc/pvpanic-pci.c
36
+++ b/include/hw/net/lan9118_phy.h
63
@@ -XXX,XX +XXX,XX @@
37
@@ -XXX,XX +XXX,XX @@
64
+/*
38
+/*
65
+ * QEMU simulated PCI pvpanic device.
39
+ * SMSC LAN9118 PHY emulation
66
+ *
40
+ *
67
+ * Copyright (C) 2020 Oracle
41
+ * Copyright (c) 2009 CodeSourcery, LLC.
68
+ *
42
+ * Written by Paul Brook
69
+ * Authors:
70
+ * Mihai Carabas <mihai.carabas@oracle.com>
71
+ *
43
+ *
72
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
44
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
73
+ * See the COPYING file in the top-level directory.
45
+ * See the COPYING file in the top-level directory.
46
+ */
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 @@
317
+/*
318
+ * SMSC LAN9118 PHY emulation
74
+ *
319
+ *
320
+ * Copyright (c) 2009 CodeSourcery, LLC.
321
+ * Written by Paul Brook
322
+ *
323
+ * This code is licensed under the GNU GPL v2
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.
75
+ */
327
+ */
76
+
328
+
77
+#include "qemu/osdep.h"
329
+#include "qemu/osdep.h"
330
+#include "hw/net/lan9118_phy.h"
331
+#include "hw/irq.h"
332
+#include "hw/resettable.h"
333
+#include "migration/vmstate.h"
78
+#include "qemu/log.h"
334
+#include "qemu/log.h"
79
+#include "qemu/module.h"
335
+
80
+#include "sysemu/runstate.h"
336
+#define PHY_INT_ENERGYON (1 << 7)
81
+
337
+#define PHY_INT_AUTONEG_COMPLETE (1 << 6)
82
+#include "hw/nvram/fw_cfg.h"
338
+#define PHY_INT_FAULT (1 << 5)
83
+#include "hw/qdev-properties.h"
339
+#define PHY_INT_DOWN (1 << 4)
84
+#include "migration/vmstate.h"
340
+#define PHY_INT_AUTONEG_LP (1 << 3)
85
+#include "hw/misc/pvpanic.h"
341
+#define PHY_INT_PARFAULT (1 << 2)
86
+#include "qom/object.h"
342
+#define PHY_INT_AUTONEG_PAGE (1 << 1)
87
+#include "hw/pci/pci.h"
343
+
88
+
344
+static void lan9118_phy_update_irq(Lan9118PhyState *s)
89
+OBJECT_DECLARE_SIMPLE_TYPE(PVPanicPCIState, PVPANIC_PCI_DEVICE)
345
+{
90
+
346
+ qemu_set_irq(s->irq, !!(s->ints & s->int_mask));
91
+/*
347
+}
92
+ * PVPanicPCIState for PCI device
348
+
93
+ */
349
+uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg)
94
+typedef struct PVPanicPCIState {
350
+{
95
+ PCIDevice dev;
351
+ uint16_t val;
96
+ PVPanicState pvpanic;
352
+
97
+} PVPanicPCIState;
353
+ switch (reg) {
98
+
354
+ case 0: /* Basic Control */
99
+static const VMStateDescription vmstate_pvpanic_pci = {
355
+ return s->control;
100
+ .name = "pvpanic-pci",
356
+ case 1: /* Basic Status */
357
+ return s->status;
358
+ case 2: /* ID1 */
359
+ return 0x0007;
360
+ case 3: /* ID2 */
361
+ return 0xc0d1;
362
+ case 4: /* Auto-neg advertisement */
363
+ return s->advertise;
364
+ case 5: /* Auto-neg Link Partner Ability */
365
+ return 0x0f71;
366
+ case 6: /* Auto-neg Expansion */
367
+ return 1;
368
+ /* TODO 17, 18, 27, 29, 30, 31 */
369
+ case 29: /* Interrupt source. */
370
+ val = s->ints;
371
+ s->ints = 0;
372
+ lan9118_phy_update_irq(s);
373
+ return val;
374
+ case 30: /* Interrupt mask */
375
+ return s->int_mask;
376
+ default:
377
+ qemu_log_mask(LOG_GUEST_ERROR,
378
+ "lan9118_phy_read: PHY read reg %d\n", reg);
379
+ return 0;
380
+ }
381
+}
382
+
383
+void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val)
384
+{
385
+ switch (reg) {
386
+ case 0: /* Basic Control */
387
+ if (val & 0x8000) {
388
+ lan9118_phy_reset(s);
389
+ break;
390
+ }
391
+ s->control = val & 0x7980;
392
+ /* Complete autonegotiation immediately. */
393
+ if (val & 0x1000) {
394
+ s->status |= 0x0020;
395
+ }
396
+ break;
397
+ case 4: /* Auto-neg advertisement */
398
+ s->advertise = (val & 0x2d7f) | 0x80;
399
+ break;
400
+ /* TODO 17, 18, 27, 31 */
401
+ case 30: /* Interrupt mask */
402
+ s->int_mask = val & 0xff;
403
+ lan9118_phy_update_irq(s);
404
+ break;
405
+ default:
406
+ qemu_log_mask(LOG_GUEST_ERROR,
407
+ "lan9118_phy_write: PHY write reg %d = 0x%04x\n", reg, val);
408
+ }
409
+}
410
+
411
+void lan9118_phy_update_link(Lan9118PhyState *s, bool link_down)
412
+{
413
+ s->link_down = link_down;
414
+
415
+ /* Autonegotiation status mirrors link status. */
416
+ if (link_down) {
417
+ s->status &= ~0x0024;
418
+ s->ints |= PHY_INT_DOWN;
419
+ } else {
420
+ s->status |= 0x0024;
421
+ s->ints |= PHY_INT_ENERGYON;
422
+ s->ints |= PHY_INT_AUTONEG_COMPLETE;
423
+ }
424
+ lan9118_phy_update_irq(s);
425
+}
426
+
427
+void lan9118_phy_reset(Lan9118PhyState *s)
428
+{
429
+ s->control = 0x3000;
430
+ s->status = 0x7809;
431
+ s->advertise = 0x01e1;
432
+ s->int_mask = 0;
433
+ s->ints = 0;
434
+ lan9118_phy_update_link(s, s->link_down);
435
+}
436
+
437
+static void lan9118_phy_reset_hold(Object *obj, ResetType type)
438
+{
439
+ Lan9118PhyState *s = LAN9118_PHY(obj);
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",
101
+ .version_id = 1,
453
+ .version_id = 1,
102
+ .minimum_version_id = 1,
454
+ .minimum_version_id = 1,
103
+ .fields = (VMStateField[]) {
455
+ .fields = (const VMStateField[]) {
104
+ VMSTATE_PCI_DEVICE(dev, PVPanicPCIState),
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),
105
+ VMSTATE_END_OF_LIST()
462
+ VMSTATE_END_OF_LIST()
106
+ }
463
+ }
107
+};
464
+};
108
+
465
+
109
+static void pvpanic_pci_realizefn(PCIDevice *dev, Error **errp)
466
+static void lan9118_phy_class_init(ObjectClass *klass, void *data)
110
+{
467
+{
111
+ PVPanicPCIState *s = PVPANIC_PCI_DEVICE(dev);
468
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
112
+ PVPanicState *ps = &s->pvpanic;
113
+
114
+ pvpanic_setup_io(&s->pvpanic, DEVICE(s), 2);
115
+
116
+ pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &ps->mr);
117
+}
118
+
119
+static Property pvpanic_pci_properties[] = {
120
+ DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events,
121
+ PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
122
+ DEFINE_PROP_END_OF_LIST(),
123
+};
124
+
125
+static void pvpanic_pci_class_init(ObjectClass *klass, void *data)
126
+{
127
+ DeviceClass *dc = DEVICE_CLASS(klass);
469
+ DeviceClass *dc = DEVICE_CLASS(klass);
128
+ PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass);
470
+
129
+
471
+ rc->phases.hold = lan9118_phy_reset_hold;
130
+ device_class_set_props(dc, pvpanic_pci_properties);
472
+ dc->vmsd = &vmstate_lan9118_phy;
131
+
473
+}
132
+ pc->realize = pvpanic_pci_realizefn;
474
+
133
+ pc->vendor_id = PCI_VENDOR_ID_REDHAT;
475
+static const TypeInfo types[] = {
134
+ pc->device_id = PCI_DEVICE_ID_REDHAT_PVPANIC;
476
+ {
135
+ pc->revision = 1;
477
+ .name = TYPE_LAN9118_PHY,
136
+ pc->class_id = PCI_CLASS_SYSTEM_OTHER;
478
+ .parent = TYPE_SYS_BUS_DEVICE,
137
+ dc->vmsd = &vmstate_pvpanic_pci;
479
+ .instance_size = sizeof(Lan9118PhyState),
138
+
480
+ .instance_init = lan9118_phy_init,
139
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
481
+ .class_init = lan9118_phy_class_init,
140
+}
141
+
142
+static TypeInfo pvpanic_pci_info = {
143
+ .name = TYPE_PVPANIC_PCI_DEVICE,
144
+ .parent = TYPE_PCI_DEVICE,
145
+ .instance_size = sizeof(PVPanicPCIState),
146
+ .class_init = pvpanic_pci_class_init,
147
+ .interfaces = (InterfaceInfo[]) {
148
+ { INTERFACE_CONVENTIONAL_PCI_DEVICE },
149
+ { }
150
+ }
482
+ }
151
+};
483
+};
152
+
484
+
153
+static void pvpanic_register_types(void)
485
+DEFINE_TYPES(types)
154
+{
486
diff --git a/hw/net/Kconfig b/hw/net/Kconfig
155
+ type_register_static(&pvpanic_pci_info);
156
+}
157
+
158
+type_init(pvpanic_register_types);
159
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
160
index XXXXXXX..XXXXXXX 100644
487
index XXXXXXX..XXXXXXX 100644
161
--- a/hw/misc/Kconfig
488
--- a/hw/net/Kconfig
162
+++ b/hw/misc/Kconfig
489
+++ b/hw/net/Kconfig
163
@@ -XXX,XX +XXX,XX @@ config IOTKIT_SYSINFO
490
@@ -XXX,XX +XXX,XX @@ config VMXNET3_PCI
164
config PVPANIC_COMMON
491
config SMC91C111
165
bool
492
bool
166
493
167
+config PVPANIC_PCI
494
+config LAN9118_PHY
168
+ bool
495
+ bool
169
+ default y if PCI_DEVICES
496
+
170
+ depends on PCI
497
config LAN9118
171
+ select PVPANIC_COMMON
172
+
173
config PVPANIC_ISA
174
bool
498
bool
175
depends on ISA_BUS
499
+ select LAN9118_PHY
176
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
500
select PTIMER
501
502
config NE2000_ISA
503
diff --git a/hw/net/meson.build b/hw/net/meson.build
177
index XXXXXXX..XXXXXXX 100644
504
index XXXXXXX..XXXXXXX 100644
178
--- a/hw/misc/meson.build
505
--- a/hw/net/meson.build
179
+++ b/hw/misc/meson.build
506
+++ b/hw/net/meson.build
180
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c'))
507
@@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_VMXNET3_PCI', if_true: files('vmxnet3.c'))
181
softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c'))
508
182
509
system_ss.add(when: 'CONFIG_SMC91C111', if_true: files('smc91c111.c'))
183
softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c'))
510
system_ss.add(when: 'CONFIG_LAN9118', if_true: files('lan9118.c'))
184
+softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c'))
511
+system_ss.add(when: 'CONFIG_LAN9118_PHY', if_true: files('lan9118_phy.c'))
185
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
512
system_ss.add(when: 'CONFIG_NE2000_ISA', if_true: files('ne2000-isa.c'))
186
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c'))
513
system_ss.add(when: 'CONFIG_OPENCORES_ETH', if_true: files('opencores_eth.c'))
187
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c'))
514
system_ss.add(when: 'CONFIG_XGMAC', if_true: files('xgmac.c'))
188
--
515
--
189
2.20.1
516
2.34.1
190
191
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Bernhard Beschow <shentey@gmail.com>
2
2
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
3
imx_fec models the same PHY as lan9118_phy. The code is almost the same with
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
imx_fec having more logging and tracing. Merge these improvements into
5
Message-id: 20210112104511.36576-9-remi.denis.courmont@huawei.com
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
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
19
---
8
target/arm/cpu.h | 7 +++++++
20
include/hw/net/imx_fec.h | 9 ++-
9
target/arm/helper.c | 24 ++++++++++++++++++++++++
21
hw/net/imx_fec.c | 146 ++++-----------------------------------
10
2 files changed, 31 insertions(+)
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(-)
11
26
12
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
27
diff --git a/include/hw/net/imx_fec.h b/include/hw/net/imx_fec.h
13
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu.h
29
--- a/include/hw/net/imx_fec.h
15
+++ b/target/arm/cpu.h
30
+++ b/include/hw/net/imx_fec.h
16
@@ -XXX,XX +XXX,XX @@ typedef struct {
31
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(IMXFECState, IMX_FEC)
17
uint32_t base_mask;
32
#define TYPE_IMX_ENET "imx.enet"
18
} TCR;
33
19
34
#include "hw/sysbus.h"
20
+#define VTCR_NSW (1u << 29)
35
+#include "hw/net/lan9118_phy.h"
21
+#define VTCR_NSA (1u << 30)
36
+#include "hw/irq.h"
22
+#define VSTCR_SW VTCR_NSW
37
#include "net/net.h"
23
+#define VSTCR_SA VTCR_NSA
38
24
+
39
#define ENET_EIR 1
25
/* Define a maximum sized vector register.
40
@@ -XXX,XX +XXX,XX @@ struct IMXFECState {
26
* For 32-bit, this is a 128-bit NEON/AdvSIMD register.
41
uint32_t tx_descriptor[ENET_TX_RING_NUM];
27
* For 64-bit, this is a 2048-bit SVE register.
42
uint32_t tx_ring_num;
28
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
43
29
uint64_t ttbr1_el[4];
44
- uint32_t phy_status;
30
};
45
- uint32_t phy_control;
31
uint64_t vttbr_el2; /* Virtualization Translation Table Base. */
46
- uint32_t phy_advertise;
32
+ uint64_t vsttbr_el2; /* Secure Virtualization Translation Table. */
47
- uint32_t phy_int;
33
/* MMU translation table base control. */
48
- uint32_t phy_int_mask;
34
TCR tcr_el[4];
49
+ Lan9118PhyState mii;
35
TCR vtcr_el2; /* Virtualization Translation Control. */
50
+ IRQState mii_irq;
36
+ TCR vstcr_el2; /* Secure Virtualization Translation Control. */
51
uint32_t phy_num;
37
uint32_t c2_data; /* MPU data cacheable bits. */
52
bool phy_connected;
38
uint32_t c2_insn; /* MPU instruction cacheable bits. */
53
struct IMXFECState *phy_consumer;
39
union { /* MMU domain access control register
54
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
40
diff --git a/target/arm/helper.c b/target/arm/helper.c
41
index XXXXXXX..XXXXXXX 100644
55
index XXXXXXX..XXXXXXX 100644
42
--- a/target/arm/helper.c
56
--- a/hw/net/imx_fec.c
43
+++ b/target/arm/helper.c
57
+++ b/hw/net/imx_fec.c
44
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_v8_cp_reginfo[] = {
58
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx_eth_txdescs = {
45
REGINFO_SENTINEL
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
},
46
};
80
};
47
81
48
+static CPAccessResult sel2_access(CPUARMState *env, const ARMCPRegInfo *ri,
82
-#define PHY_INT_ENERGYON (1 << 7)
49
+ bool isread)
83
-#define PHY_INT_AUTONEG_COMPLETE (1 << 6)
50
+{
84
-#define PHY_INT_FAULT (1 << 5)
51
+ if (arm_current_el(env) == 3 || arm_is_secure_below_el3(env)) {
85
-#define PHY_INT_DOWN (1 << 4)
52
+ return CP_ACCESS_OK;
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;
53
+ }
260
+ }
54
+ return CP_ACCESS_TRAP_UNCATEGORIZED;
261
+ qdev_connect_gpio_out(DEVICE(&s->mii), 0, &s->mii_irq);
55
+}
262
+
56
+
263
qemu_macaddr_default_if_unset(&s->conf.macaddr);
57
+static const ARMCPRegInfo el2_sec_cp_reginfo[] = {
264
58
+ { .name = "VSTTBR_EL2", .state = ARM_CP_STATE_AA64,
265
s->nic = qemu_new_nic(&imx_eth_net_info, &s->conf,
59
+ .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 6, .opc2 = 0,
266
diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c
60
+ .access = PL2_RW, .accessfn = sel2_access,
267
index XXXXXXX..XXXXXXX 100644
61
+ .fieldoffset = offsetof(CPUARMState, cp15.vsttbr_el2) },
268
--- a/hw/net/lan9118_phy.c
62
+ { .name = "VSTCR_EL2", .state = ARM_CP_STATE_AA64,
269
+++ b/hw/net/lan9118_phy.c
63
+ .opc0 = 3, .opc1 = 4, .crn = 2, .crm = 6, .opc2 = 2,
270
@@ -XXX,XX +XXX,XX @@
64
+ .access = PL2_RW, .accessfn = sel2_access,
271
* Copyright (c) 2009 CodeSourcery, LLC.
65
+ .fieldoffset = offsetof(CPUARMState, cp15.vstcr_el2) },
272
* Written by Paul Brook
66
+ REGINFO_SENTINEL
273
*
67
+};
274
+ * Copyright (c) 2013 Jean-Christophe Dubois. <jcd@tribudubois.net>
68
+
275
+ *
69
static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
276
* This code is licensed under the GNU GPL v2
70
bool isread)
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)
71
{
353
{
72
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
354
+ trace_lan9118_phy_write(val, reg);
73
if (arm_feature(env, ARM_FEATURE_V8)) {
355
+
74
define_arm_cp_regs(cpu, el2_v8_cp_reginfo);
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
+ }
75
}
372
}
76
+ if (cpu_isar_feature(aa64_sel2, cpu)) {
373
break;
77
+ define_arm_cp_regs(cpu, el2_sec_cp_reginfo);
374
case 4: /* Auto-neg advertisement */
78
+ }
375
s->advertise = (val & 0x2d7f) | 0x80;
79
/* RVBAR_EL2 is only implemented if EL2 is the highest EL */
376
break;
80
if (!arm_feature(env, ARM_FEATURE_EL3)) {
377
- /* TODO 17, 18, 27, 31 */
81
ARMCPRegInfo rvbar = {
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"
82
--
471
--
83
2.20.1
472
2.34.1
84
85
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Bernhard Beschow <shentey@gmail.com>
2
2
3
When building with GCC 10.2 configured with --extra-cflags=-Os, we get:
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.
4
5
5
target/arm/m_helper.c: In function ‘arm_v7m_cpu_do_interrupt’:
6
Fixes: 2a424990170b "LAN9118 emulation"
6
target/arm/m_helper.c:1811:16: error: ‘restore_s16_s31’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
7
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
7
1811 | if (restore_s16_s31) {
8
Tested-by: Guenter Roeck <linux@roeck-us.net>
8
| ^
9
target/arm/m_helper.c:1350:10: note: ‘restore_s16_s31’ was declared here
10
1350 | bool restore_s16_s31;
11
| ^~~~~~~~~~~~~~~
12
cc1: all warnings being treated as errors
13
14
Initialize the 'restore_s16_s31' variable to silence the warning.
15
16
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Message-id: 20210119062739.589049-1-f4bug@amsat.org
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20241102125724.532843-4-shentey@gmail.com
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
12
---
21
target/arm/m_helper.c | 2 +-
13
hw/net/lan9118_phy.c | 2 +-
22
1 file changed, 1 insertion(+), 1 deletion(-)
14
1 file changed, 1 insertion(+), 1 deletion(-)
23
15
24
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
16
diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c
25
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/m_helper.c
18
--- a/hw/net/lan9118_phy.c
27
+++ b/target/arm/m_helper.c
19
+++ b/hw/net/lan9118_phy.c
28
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
20
@@ -XXX,XX +XXX,XX @@ uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg)
29
bool exc_secure = false;
21
val = s->advertise;
30
bool return_to_secure;
22
break;
31
bool ftype;
23
case 5: /* Auto-neg Link Partner Ability */
32
- bool restore_s16_s31;
24
- val = 0x0f71;
33
+ bool restore_s16_s31 = false;
25
+ val = 0x0fe1;
34
26
break;
35
/*
27
case 6: /* Auto-neg Expansion */
36
* If we're not in Handler mode then jumps to magic exception-exit
28
val = 1;
37
--
29
--
38
2.20.1
30
2.34.1
39
40
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Bernhard Beschow <shentey@gmail.com>
2
2
3
On ARMv8-A, accesses by 32-bit secure EL1 to monitor registers trap to
3
Prefer named constants over magic values for better readability.
4
the upper (64-bit) EL. With Secure EL2 support, we can no longer assume
5
that that is always EL3, so make room for the value to be computed at
6
run-time.
7
4
8
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
10
Message-id: 20210112104511.36576-16-remi.denis.courmont@huawei.com
7
Tested-by: Guenter Roeck <linux@roeck-us.net>
8
Message-id: 20241102125724.532843-5-shentey@gmail.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
10
---
13
target/arm/translate.c | 23 +++++++++++++++++++++--
11
include/hw/net/mii.h | 6 +++++
14
1 file changed, 21 insertions(+), 2 deletions(-)
12
hw/net/lan9118_phy.c | 63 ++++++++++++++++++++++++++++----------------
13
2 files changed, 46 insertions(+), 23 deletions(-)
15
14
16
diff --git a/target/arm/translate.c b/target/arm/translate.c
15
diff --git a/include/hw/net/mii.h b/include/hw/net/mii.h
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/translate.c
17
--- a/include/hw/net/mii.h
19
+++ b/target/arm/translate.c
18
+++ b/include/hw/net/mii.h
20
@@ -XXX,XX +XXX,XX @@ static void unallocated_encoding(DisasContext *s)
19
@@ -XXX,XX +XXX,XX @@
21
default_exception_el(s));
20
#define MII_BMSR_JABBER (1 << 1) /* Jabber detected */
22
}
21
#define MII_BMSR_EXTCAP (1 << 0) /* Ext-reg capability */
23
22
24
+static void gen_exception_el(DisasContext *s, int excp, uint32_t syn,
23
+#define MII_ANAR_RFAULT (1 << 13) /* Say we can detect faults */
25
+ TCGv_i32 tcg_el)
24
#define MII_ANAR_PAUSE_ASYM (1 << 11) /* Try for asymmetric pause */
26
+{
25
#define MII_ANAR_PAUSE (1 << 10) /* Try for pause */
27
+ TCGv_i32 tcg_excp;
26
#define MII_ANAR_TXFD (1 << 8)
28
+ TCGv_i32 tcg_syn;
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
29
+
42
+
30
+ gen_set_condexec(s);
43
/* RealTek 8211E */
31
+ gen_set_pc_im(s, s->pc_curr);
44
#define RTL8211E_PHYID1 0x001c
32
+ tcg_excp = tcg_const_i32(excp);
45
#define RTL8211E_PHYID2 0xc915
33
+ tcg_syn = tcg_const_i32(syn);
46
diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c
34
+ gen_helper_exception_with_syndrome(cpu_env, tcg_excp, tcg_syn, tcg_el);
47
index XXXXXXX..XXXXXXX 100644
35
+ tcg_temp_free_i32(tcg_syn);
48
--- a/hw/net/lan9118_phy.c
36
+ tcg_temp_free_i32(tcg_excp);
49
+++ b/hw/net/lan9118_phy.c
37
+ s->base.is_jmp = DISAS_NORETURN;
50
@@ -XXX,XX +XXX,XX @@
38
+}
51
39
+
52
#include "qemu/osdep.h"
40
/* Force a TB lookup after an instruction that changes the CPU state. */
53
#include "hw/net/lan9118_phy.h"
41
static inline void gen_lookup_tb(DisasContext *s)
54
+#include "hw/net/mii.h"
42
{
55
#include "hw/irq.h"
43
@@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn,
56
#include "hw/resettable.h"
44
/* If we're in Secure EL1 (which implies that EL3 is AArch64)
57
#include "migration/vmstate.h"
45
* then accesses to Mon registers trap to EL3
58
@@ -XXX,XX +XXX,XX @@ uint16_t lan9118_phy_read(Lan9118PhyState *s, int reg)
46
*/
59
uint16_t val;
47
- exc_target = 3;
60
48
- goto undef;
61
switch (reg) {
49
+ TCGv_i32 tcg_el = tcg_const_i32(3);
62
- case 0: /* Basic Control */
50
+
63
+ case MII_BMCR:
51
+ gen_exception_el(s, EXCP_UDEF, syn_uncategorized(), tcg_el);
64
val = s->control;
52
+ tcg_temp_free_i32(tcg_el);
65
break;
53
+ return false;
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
}
54
}
118
}
55
break;
119
break;
56
case ARM_CPU_MODE_HYP:
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);
57
--
166
--
58
2.20.1
167
2.34.1
59
60
diff view generated by jsdifflib
1
From: Mihai Carabas <mihai.carabas@oracle.com>
1
From: Bernhard Beschow <shentey@gmail.com>
2
2
3
Add a test case for pvpanic-pci device. The scenario is the same as pvpapnic
3
The real device advertises this mode and the device model already advertises
4
ISA device, but is using the PCI bus.
4
100 mbps half duplex and 10 mbps full+half duplex. So advertise this mode to
5
make the model more realistic.
5
6
6
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
7
Acked-by: Thomas Huth <thuth@redhat.com>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
9
Tested-by: Guenter Roeck <linux@roeck-us.net>
10
Message-id: 20241102125724.532843-6-shentey@gmail.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
12
---
11
tests/qtest/pvpanic-pci-test.c | 62 ++++++++++++++++++++++++++++++++++
13
hw/net/lan9118_phy.c | 4 ++--
12
tests/qtest/meson.build | 1 +
14
1 file changed, 2 insertions(+), 2 deletions(-)
13
2 files changed, 63 insertions(+)
14
create mode 100644 tests/qtest/pvpanic-pci-test.c
15
15
16
diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c
16
diff --git a/hw/net/lan9118_phy.c b/hw/net/lan9118_phy.c
17
new file mode 100644
18
index XXXXXXX..XXXXXXX
19
--- /dev/null
20
+++ b/tests/qtest/pvpanic-pci-test.c
21
@@ -XXX,XX +XXX,XX @@
22
+/*
23
+ * QTest testcase for PV Panic PCI device
24
+ *
25
+ * Copyright (C) 2020 Oracle
26
+ *
27
+ * Authors:
28
+ * Mihai Carabas <mihai.carabas@oracle.com>
29
+ *
30
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
31
+ * See the COPYING file in the top-level directory.
32
+ *
33
+ */
34
+
35
+#include "qemu/osdep.h"
36
+#include "libqos/libqtest.h"
37
+#include "qapi/qmp/qdict.h"
38
+#include "libqos/pci.h"
39
+#include "libqos/pci-pc.h"
40
+#include "hw/pci/pci_regs.h"
41
+
42
+static void test_panic(void)
43
+{
44
+ uint8_t val;
45
+ QDict *response, *data;
46
+ QTestState *qts;
47
+ QPCIBus *pcibus;
48
+ QPCIDevice *dev;
49
+ QPCIBar bar;
50
+
51
+ qts = qtest_init("-device pvpanic-pci");
52
+ pcibus = qpci_new_pc(qts, NULL);
53
+ dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0));
54
+ qpci_device_enable(dev);
55
+ bar = qpci_iomap(dev, 0, NULL);
56
+
57
+ qpci_memread(dev, bar, 0, &val, sizeof(val));
58
+ g_assert_cmpuint(val, ==, 3);
59
+
60
+ val = 1;
61
+ qpci_memwrite(dev, bar, 0, &val, sizeof(val));
62
+
63
+ response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED");
64
+ g_assert(qdict_haskey(response, "data"));
65
+ data = qdict_get_qdict(response, "data");
66
+ g_assert(qdict_haskey(data, "action"));
67
+ g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause");
68
+ qobject_unref(response);
69
+
70
+ qtest_quit(qts);
71
+}
72
+
73
+int main(int argc, char **argv)
74
+{
75
+ int ret;
76
+
77
+ g_test_init(&argc, &argv, NULL);
78
+ qtest_add_func("/pvpanic-pci/panic", test_panic);
79
+
80
+ ret = g_test_run();
81
+
82
+ return ret;
83
+}
84
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
85
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
86
--- a/tests/qtest/meson.build
18
--- a/hw/net/lan9118_phy.c
87
+++ b/tests/qtest/meson.build
19
+++ b/hw/net/lan9118_phy.c
88
@@ -XXX,XX +XXX,XX @@ endif
20
@@ -XXX,XX +XXX,XX @@ void lan9118_phy_write(Lan9118PhyState *s, int reg, uint16_t val)
89
21
break;
90
qtests_pci = \
22
case MII_ANAR:
91
(config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : []) + \
23
s->advertise = (val & (MII_ANAR_RFAULT | MII_ANAR_PAUSE_ASYM |
92
+ (config_all_devices.has_key('CONFIG_PVPANIC_PCI') ? ['pvpanic-pci-test'] : []) + \
24
- MII_ANAR_PAUSE | MII_ANAR_10FD | MII_ANAR_10 |
93
(config_all_devices.has_key('CONFIG_IVSHMEM_DEVICE') ? ['ivshmem-test'] : [])
25
- MII_ANAR_SELECT))
94
26
+ MII_ANAR_PAUSE | MII_ANAR_TXFD | MII_ANAR_10FD |
95
qtests_i386 = \
27
+ MII_ANAR_10 | MII_ANAR_SELECT))
28
| MII_ANAR_TX;
29
break;
30
case 30: /* Interrupt mask */
96
--
31
--
97
2.20.1
32
2.34.1
98
99
diff view generated by jsdifflib
New patch
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.
1
6
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".
13
14
For Arm, this looks like it might be a behaviour change because we
15
used to set float_flag_invalid | float_flag_invalid_imz only if C is
16
a quiet NaN. However, it is not, because Arm target code never looks
17
at float_flag_invalid_imz, and for the (0 * inf) + SNaN case we
18
already raised float_flag_invalid via the "abc_mask &
19
float_cmask_snan" check in pick_nan_muladd.
20
21
For any target architecture using the "default implementation" at the
22
bottom of the ifdef, this is a behaviour change but will be fixing a
23
bug (where we failed to raise the Invalid exception for (0 * inf +
24
QNaN). The architectures using the default case are:
25
* hppa
26
* i386
27
* sh4
28
* tricore
29
30
The x86, Tricore and SH4 CPU architecture manuals are clear that this
31
should have raised Invalid; HPPA is a bit vaguer but still seems
32
clear enough.
33
34
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
35
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
36
Message-id: 20241202131347.498124-2-peter.maydell@linaro.org
37
---
38
fpu/softfloat-parts.c.inc | 13 +++++++------
39
fpu/softfloat-specialize.c.inc | 29 +----------------------------
40
2 files changed, 8 insertions(+), 34 deletions(-)
41
42
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
43
index XXXXXXX..XXXXXXX 100644
44
--- a/fpu/softfloat-parts.c.inc
45
+++ b/fpu/softfloat-parts.c.inc
46
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
47
int ab_mask, int abc_mask)
48
{
49
int which;
50
+ bool infzero = (ab_mask == float_cmask_infzero);
51
52
if (unlikely(abc_mask & float_cmask_snan)) {
53
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
54
}
55
56
- which = pickNaNMulAdd(a->cls, b->cls, c->cls,
57
- ab_mask == float_cmask_infzero, s);
58
+ if (infzero) {
59
+ /* This is (0 * inf) + NaN or (inf * 0) + NaN */
60
+ float_raise(float_flag_invalid | float_flag_invalid_imz, s);
61
+ }
62
+
63
+ which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s);
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;
72
}
73
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
74
index XXXXXXX..XXXXXXX 100644
75
--- a/fpu/softfloat-specialize.c.inc
76
+++ b/fpu/softfloat-specialize.c.inc
77
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
78
* the default NaN
79
*/
80
if (infzero && is_qnan(c_cls)) {
81
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
82
return 3;
83
}
84
85
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
86
* case sets InvalidOp and returns the default NaN
87
*/
88
if (infzero) {
89
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
90
return 3;
91
}
92
/* Prefer sNaN over qNaN, in the a, b, c order. */
93
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
94
* For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
95
* case sets InvalidOp and returns the input value 'c'
96
*/
97
- if (infzero) {
98
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
99
- return 2;
100
- }
101
/* Prefer sNaN over qNaN, in the c, a, b order. */
102
if (is_snan(c_cls)) {
103
return 2;
104
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
105
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
106
* case sets InvalidOp and returns the input value 'c'
107
*/
108
- if (infzero) {
109
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
110
- return 2;
111
- }
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;
129
}
130
#elif defined(TARGET_RISCV)
131
- /* For RISC-V, InvalidOp is set when multiplicands are Inf and zero */
132
- if (infzero) {
133
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
134
- }
135
return 3; /* default NaN */
136
#elif defined(TARGET_S390X)
137
if (infzero) {
138
- float_raise(float_flag_invalid | float_flag_invalid_imz, status);
139
return 3;
140
}
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;
165
--
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
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
IEEE 758 does not define a fixed rule for what NaN to return in
2
2
the case of a fused multiply-add of inf * 0 + NaN. Different
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
3
architectures thus do different things:
4
* some return the default NaN
5
* some return the input NaN
6
* Arm returns the default NaN if the input NaN is quiet,
7
and the input NaN if it is signalling
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.
29
30
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
31
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20210112104511.36576-6-remi.denis.courmont@huawei.com
32
Message-id: 20241202131347.498124-4-peter.maydell@linaro.org
6
[PMM: tweaked commit message to match reduced scope of patch
7
following rebase]
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
33
---
10
target/arm/cpu.h | 5 +++++
34
include/fpu/softfloat-helpers.h | 11 ++++
11
1 file changed, 5 insertions(+)
35
include/fpu/softfloat-types.h | 23 +++++++++
12
36
fpu/softfloat-specialize.c.inc | 91 ++++++++++++++++++++++-----------
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
37
3 files changed, 95 insertions(+), 30 deletions(-)
38
39
diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h
14
index XXXXXXX..XXXXXXX 100644
40
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
41
--- a/include/fpu/softfloat-helpers.h
16
+++ b/target/arm/cpu.h
42
+++ b/include/fpu/softfloat-helpers.h
17
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_sve(const ARMISARegisters *id)
43
@@ -XXX,XX +XXX,XX @@ static inline void set_float_2nan_prop_rule(Float2NaNPropRule rule,
18
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0;
44
status->float_2nan_prop_rule = rule;
19
}
45
}
20
46
21
+static inline bool isar_feature_aa64_sel2(const ARMISARegisters *id)
47
+static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule,
48
+ float_status *status)
22
+{
49
+{
23
+ return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SEL2) != 0;
50
+ status->float_infzeronan_rule = rule;
24
+}
51
+}
25
+
52
+
26
static inline bool isar_feature_aa64_vh(const ARMISARegisters *id)
53
static inline void set_flush_to_zero(bool val, float_status *status)
27
{
54
{
28
return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0;
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)
61
+{
62
+ return status->float_infzeronan_rule;
63
+}
64
+
65
static inline bool get_flush_to_zero(float_status *status)
66
{
67
return status->flush_to_zero;
68
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
69
index XXXXXXX..XXXXXXX 100644
70
--- a/include/fpu/softfloat-types.h
71
+++ b/include/fpu/softfloat-types.h
72
@@ -XXX,XX +XXX,XX @@ typedef enum __attribute__((__packed__)) {
73
float_2nan_prop_x87,
74
} Float2NaNPropRule;
75
76
+/*
77
+ * Rule for result of fused multiply-add 0 * Inf + NaN.
78
+ * This must be a NaN, but implementations differ on whether this
79
+ * is the input NaN or the default NaN.
80
+ *
81
+ * You don't need to set this if default_nan_mode is enabled.
82
+ * When not in default-NaN mode, it is an error for the target
83
+ * not to set the rule in float_status if it uses muladd, and we
84
+ * will assert if we need to handle an input NaN and no rule was
85
+ * selected.
86
+ */
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;
212
}
213
} else {
214
- /*
215
- * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
216
- * case sets InvalidOp and returns the input value 'c'
217
- */
218
/* Prefer sNaN over qNaN, in the c, a, b order. */
219
if (is_snan(c_cls)) {
220
return 2;
221
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
222
}
223
}
224
#elif defined(TARGET_LOONGARCH64)
225
- /*
226
- * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
227
- * case sets InvalidOp and returns the input value 'c'
228
- */
229
-
230
/* Prefer sNaN over qNaN, in the c, a, b order. */
231
if (is_snan(c_cls)) {
232
return 2;
233
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
234
return 1;
235
}
236
#elif defined(TARGET_PPC)
237
- /* For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
238
- * to return an input NaN if we have one (ie c) rather than generating
239
- * a default NaN
240
- */
241
-
242
/* If fRA is a NaN return it; otherwise if fRB is a NaN return it;
243
* otherwise return fRC. Note that muladd on PPC is (fRA * fRC) + frB
244
*/
245
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
246
return 1;
247
}
248
#elif defined(TARGET_S390X)
249
- if (infzero) {
250
- return 3;
251
- }
252
-
253
if (is_snan(a_cls)) {
254
return 0;
255
} else if (is_snan(b_cls)) {
29
--
256
--
30
2.20.1
257
2.34.1
31
32
diff view generated by jsdifflib
New patch
1
Explicitly set a rule in the softfloat tests for the inf-zero-nan
2
muladd special case. In meson.build we put -DTARGET_ARM in fpcflags,
3
and so we should select here the Arm rule of
4
float_infzeronan_dnan_if_qnan.
1
5
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20241202131347.498124-5-peter.maydell@linaro.org
9
---
10
tests/fp/fp-bench.c | 5 +++++
11
tests/fp/fp-test.c | 5 +++++
12
2 files changed, 10 insertions(+)
13
14
diff --git a/tests/fp/fp-bench.c b/tests/fp/fp-bench.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/fp/fp-bench.c
17
+++ b/tests/fp/fp-bench.c
18
@@ -XXX,XX +XXX,XX @@ static void run_bench(void)
19
{
20
bench_func_t f;
21
22
+ /*
23
+ * These implementation-defined choices for various things IEEE
24
+ * doesn't specify match those used by the Arm architecture.
25
+ */
26
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &soft_status);
27
+ set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &soft_status);
28
29
f = bench_funcs[operation][precision];
30
g_assert(f);
31
diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c
32
index XXXXXXX..XXXXXXX 100644
33
--- a/tests/fp/fp-test.c
34
+++ b/tests/fp/fp-test.c
35
@@ -XXX,XX +XXX,XX @@ void run_test(void)
36
{
37
unsigned int i;
38
39
+ /*
40
+ * These implementation-defined choices for various things IEEE
41
+ * doesn't specify match those used by the Arm architecture.
42
+ */
43
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &qsf);
44
+ set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, &qsf);
45
46
genCases_setLevel(test_level);
47
verCases_maxErrorCount = n_max_errors;
48
--
49
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the Arm target,
2
so we can remove the ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-6-peter.maydell@linaro.org
7
---
8
target/arm/cpu.c | 3 +++
9
fpu/softfloat-specialize.c.inc | 8 +-------
10
2 files changed, 4 insertions(+), 7 deletions(-)
11
12
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu.c
15
+++ b/target/arm/cpu.c
16
@@ -XXX,XX +XXX,XX @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
17
* * tininess-before-rounding
18
* * 2-input NaN propagation prefers SNaN over QNaN, and then
19
* operand A over operand B (see FPProcessNaNs() pseudocode)
20
+ * * 0 * Inf + NaN returns the default NaN if the input NaN is quiet,
21
+ * and the input NaN if it is signalling
22
*/
23
static void arm_set_default_fp_behaviours(float_status *s)
24
{
25
set_float_detect_tininess(float_tininess_before_rounding, s);
26
set_float_2nan_prop_rule(float_2nan_prop_s_ab, s);
27
+ set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, s);
28
}
29
30
static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)
31
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
32
index XXXXXXX..XXXXXXX 100644
33
--- a/fpu/softfloat-specialize.c.inc
34
+++ b/fpu/softfloat-specialize.c.inc
35
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
36
/*
37
* Temporarily fall back to ifdef ladder
38
*/
39
-#if defined(TARGET_ARM)
40
- /*
41
- * For ARM, the (inf,zero,qnan) case returns the default NaN,
42
- * but (inf,zero,snan) returns the input NaN.
43
- */
44
- rule = float_infzeronan_dnan_if_qnan;
45
-#elif defined(TARGET_MIPS)
46
+#if defined(TARGET_MIPS)
47
if (snan_bit_is_one(status)) {
48
/*
49
* For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
50
--
51
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for s390, so we
2
can remove the ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-7-peter.maydell@linaro.org
7
---
8
target/s390x/cpu.c | 2 ++
9
fpu/softfloat-specialize.c.inc | 2 --
10
2 files changed, 2 insertions(+), 2 deletions(-)
11
12
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/s390x/cpu.c
15
+++ b/target/s390x/cpu.c
16
@@ -XXX,XX +XXX,XX @@ static void s390_cpu_reset_hold(Object *obj, ResetType type)
17
set_float_detect_tininess(float_tininess_before_rounding,
18
&env->fpu_status);
19
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fpu_status);
20
+ set_float_infzeronan_rule(float_infzeronan_dnan_always,
21
+ &env->fpu_status);
22
/* fall through */
23
case RESET_TYPE_S390_CPU_NORMAL:
24
env->psw.mask &= ~PSW_MASK_RI;
25
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
26
index XXXXXXX..XXXXXXX 100644
27
--- a/fpu/softfloat-specialize.c.inc
28
+++ b/fpu/softfloat-specialize.c.inc
29
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
30
* a default NaN
31
*/
32
rule = float_infzeronan_dnan_never;
33
-#elif defined(TARGET_S390X)
34
- rule = float_infzeronan_dnan_always;
35
#endif
36
}
37
38
--
39
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the PPC target,
2
so we can remove the ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-8-peter.maydell@linaro.org
7
---
8
target/ppc/cpu_init.c | 7 +++++++
9
fpu/softfloat-specialize.c.inc | 7 +------
10
2 files changed, 8 insertions(+), 6 deletions(-)
11
12
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/ppc/cpu_init.c
15
+++ b/target/ppc/cpu_init.c
16
@@ -XXX,XX +XXX,XX @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type)
17
*/
18
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status);
19
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->vec_status);
20
+ /*
21
+ * For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
22
+ * to return an input NaN if we have one (ie c) rather than generating
23
+ * a default NaN
24
+ */
25
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
26
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->vec_status);
27
28
for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) {
29
ppc_spr_t *spr = &env->spr_cb[i];
30
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
31
index XXXXXXX..XXXXXXX 100644
32
--- a/fpu/softfloat-specialize.c.inc
33
+++ b/fpu/softfloat-specialize.c.inc
34
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
35
*/
36
rule = float_infzeronan_dnan_never;
37
}
38
-#elif defined(TARGET_PPC) || defined(TARGET_SPARC) || \
39
+#elif defined(TARGET_SPARC) || \
40
defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
41
defined(TARGET_I386) || defined(TARGET_LOONGARCH)
42
/*
43
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
44
* case sets InvalidOp and returns the input value 'c'
45
*/
46
- /*
47
- * For PPC, the (inf,zero,qnan) case sets InvalidOp, but we prefer
48
- * to return an input NaN if we have one (ie c) rather than generating
49
- * a default NaN
50
- */
51
rule = float_infzeronan_dnan_never;
52
#endif
53
}
54
--
55
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the MIPS target,
2
so we can remove the ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-9-peter.maydell@linaro.org
7
---
8
target/mips/fpu_helper.h | 9 +++++++++
9
target/mips/msa.c | 4 ++++
10
fpu/softfloat-specialize.c.inc | 16 +---------------
11
3 files changed, 14 insertions(+), 15 deletions(-)
12
13
diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/mips/fpu_helper.h
16
+++ b/target/mips/fpu_helper.h
17
@@ -XXX,XX +XXX,XX @@ static inline void restore_flush_mode(CPUMIPSState *env)
18
static inline void restore_snan_bit_mode(CPUMIPSState *env)
19
{
20
bool nan2008 = env->active_fpu.fcr31 & (1 << FCR31_NAN2008);
21
+ FloatInfZeroNaNRule izn_rule;
22
23
/*
24
* With nan2008, SNaNs are silenced in the usual way.
25
@@ -XXX,XX +XXX,XX @@ static inline void restore_snan_bit_mode(CPUMIPSState *env)
26
*/
27
set_snan_bit_is_one(!nan2008, &env->active_fpu.fp_status);
28
set_default_nan_mode(!nan2008, &env->active_fpu.fp_status);
29
+ /*
30
+ * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
31
+ * case sets InvalidOp and returns the default NaN.
32
+ * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
33
+ * case sets InvalidOp and returns the input value 'c'.
34
+ */
35
+ izn_rule = nan2008 ? float_infzeronan_dnan_never : float_infzeronan_dnan_always;
36
+ set_float_infzeronan_rule(izn_rule, &env->active_fpu.fp_status);
37
}
38
39
static inline void restore_fp_status(CPUMIPSState *env)
40
diff --git a/target/mips/msa.c b/target/mips/msa.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/target/mips/msa.c
43
+++ b/target/mips/msa.c
44
@@ -XXX,XX +XXX,XX @@ void msa_reset(CPUMIPSState *env)
45
46
/* set proper signanling bit meaning ("1" means "quiet") */
47
set_snan_bit_is_one(0, &env->active_tc.msa_fp_status);
48
+
49
+ /* Inf * 0 + NaN returns the input NaN */
50
+ set_float_infzeronan_rule(float_infzeronan_dnan_never,
51
+ &env->active_tc.msa_fp_status);
52
}
53
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
54
index XXXXXXX..XXXXXXX 100644
55
--- a/fpu/softfloat-specialize.c.inc
56
+++ b/fpu/softfloat-specialize.c.inc
57
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
58
/*
59
* Temporarily fall back to ifdef ladder
60
*/
61
-#if defined(TARGET_MIPS)
62
- if (snan_bit_is_one(status)) {
63
- /*
64
- * For MIPS systems that conform to IEEE754-1985, the (inf,zero,nan)
65
- * case sets InvalidOp and returns the default NaN
66
- */
67
- rule = float_infzeronan_dnan_always;
68
- } else {
69
- /*
70
- * For MIPS systems that conform to IEEE754-2008, the (inf,zero,nan)
71
- * case sets InvalidOp and returns the input value 'c'
72
- */
73
- rule = float_infzeronan_dnan_never;
74
- }
75
-#elif defined(TARGET_SPARC) || \
76
+#if defined(TARGET_SPARC) || \
77
defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
78
defined(TARGET_I386) || defined(TARGET_LOONGARCH)
79
/*
80
--
81
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the SPARC target,
2
so we can remove the ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-10-peter.maydell@linaro.org
7
---
8
target/sparc/cpu.c | 2 ++
9
fpu/softfloat-specialize.c.inc | 3 +--
10
2 files changed, 3 insertions(+), 2 deletions(-)
11
12
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/sparc/cpu.c
15
+++ b/target/sparc/cpu.c
16
@@ -XXX,XX +XXX,XX @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
17
* the CPU state struct so it won't get zeroed on reset.
18
*/
19
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &env->fp_status);
20
+ /* For inf * 0 + NaN, return the input NaN */
21
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
22
23
cpu_exec_realizefn(cs, &local_err);
24
if (local_err != NULL) {
25
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
26
index XXXXXXX..XXXXXXX 100644
27
--- a/fpu/softfloat-specialize.c.inc
28
+++ b/fpu/softfloat-specialize.c.inc
29
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
30
/*
31
* Temporarily fall back to ifdef ladder
32
*/
33
-#if defined(TARGET_SPARC) || \
34
- defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
35
+#if defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
36
defined(TARGET_I386) || defined(TARGET_LOONGARCH)
37
/*
38
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
39
--
40
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the xtensa target,
2
so we can remove the ifdef from pickNaNMulAdd().
1
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20241202131347.498124-11-peter.maydell@linaro.org
7
---
8
target/xtensa/cpu.c | 2 ++
9
fpu/softfloat-specialize.c.inc | 2 +-
10
2 files changed, 3 insertions(+), 1 deletion(-)
11
12
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/xtensa/cpu.c
15
+++ b/target/xtensa/cpu.c
16
@@ -XXX,XX +XXX,XX @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type)
17
reset_mmu(env);
18
cs->halted = env->runstall;
19
#endif
20
+ /* For inf * 0 + NaN, return the input NaN */
21
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
22
set_no_signaling_nans(!dfpu, &env->fp_status);
23
xtensa_use_first_nan(env, !dfpu);
24
}
25
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
26
index XXXXXXX..XXXXXXX 100644
27
--- a/fpu/softfloat-specialize.c.inc
28
+++ b/fpu/softfloat-specialize.c.inc
29
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
30
/*
31
* Temporarily fall back to ifdef ladder
32
*/
33
-#if defined(TARGET_XTENSA) || defined(TARGET_HPPA) || \
34
+#if defined(TARGET_HPPA) || \
35
defined(TARGET_I386) || defined(TARGET_LOONGARCH)
36
/*
37
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
38
--
39
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the x86 target.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-12-peter.maydell@linaro.org
6
---
7
target/i386/tcg/fpu_helper.c | 7 +++++++
8
fpu/softfloat-specialize.c.inc | 2 +-
9
2 files changed, 8 insertions(+), 1 deletion(-)
10
11
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/i386/tcg/fpu_helper.c
14
+++ b/target/i386/tcg/fpu_helper.c
15
@@ -XXX,XX +XXX,XX @@ void cpu_init_fp_statuses(CPUX86State *env)
16
*/
17
set_float_2nan_prop_rule(float_2nan_prop_x87, &env->mmx_status);
18
set_float_2nan_prop_rule(float_2nan_prop_x87, &env->sse_status);
19
+ /*
20
+ * Only SSE has multiply-add instructions. In the SDM Section 14.5.2
21
+ * "Fused-Multiply-ADD (FMA) Numeric Behavior" the NaN handling is
22
+ * specified -- for 0 * inf + NaN the input NaN is selected, and if
23
+ * there are multiple input NaNs they are selected in the order a, b, c.
24
+ */
25
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status);
26
}
27
28
static inline uint8_t save_exception_flags(CPUX86State *env)
29
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
30
index XXXXXXX..XXXXXXX 100644
31
--- a/fpu/softfloat-specialize.c.inc
32
+++ b/fpu/softfloat-specialize.c.inc
33
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
34
* Temporarily fall back to ifdef ladder
35
*/
36
#if defined(TARGET_HPPA) || \
37
- defined(TARGET_I386) || defined(TARGET_LOONGARCH)
38
+ defined(TARGET_LOONGARCH)
39
/*
40
* For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
41
* case sets InvalidOp and returns the input value 'c'
42
--
43
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the loongarch target.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-13-peter.maydell@linaro.org
6
---
7
target/loongarch/tcg/fpu_helper.c | 5 +++++
8
fpu/softfloat-specialize.c.inc | 7 +------
9
2 files changed, 6 insertions(+), 6 deletions(-)
10
11
diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/loongarch/tcg/fpu_helper.c
14
+++ b/target/loongarch/tcg/fpu_helper.c
15
@@ -XXX,XX +XXX,XX @@ void restore_fp_status(CPULoongArchState *env)
16
&env->fp_status);
17
set_flush_to_zero(0, &env->fp_status);
18
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status);
19
+ /*
20
+ * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
21
+ * case sets InvalidOp and returns the input value 'c'
22
+ */
23
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
24
}
25
26
int ieee_ex_to_loongarch(int xcpt)
27
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
28
index XXXXXXX..XXXXXXX 100644
29
--- a/fpu/softfloat-specialize.c.inc
30
+++ b/fpu/softfloat-specialize.c.inc
31
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
32
/*
33
* Temporarily fall back to ifdef ladder
34
*/
35
-#if defined(TARGET_HPPA) || \
36
- defined(TARGET_LOONGARCH)
37
- /*
38
- * For LoongArch systems that conform to IEEE754-2008, the (inf,zero,nan)
39
- * case sets InvalidOp and returns the input value 'c'
40
- */
41
+#if defined(TARGET_HPPA)
42
rule = float_infzeronan_dnan_never;
43
#endif
44
}
45
--
46
2.34.1
diff view generated by jsdifflib
New patch
1
Set the FloatInfZeroNaNRule explicitly for the HPPA target,
2
so we can remove the ifdef from pickNaNMulAdd().
1
3
4
As this is the last target to be converted to explicitly setting
5
the rule, we can remove the fallback code in pickNaNMulAdd()
6
entirely.
7
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20241202131347.498124-14-peter.maydell@linaro.org
11
---
12
target/hppa/fpu_helper.c | 2 ++
13
fpu/softfloat-specialize.c.inc | 13 +------------
14
2 files changed, 3 insertions(+), 12 deletions(-)
15
16
diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/hppa/fpu_helper.c
19
+++ b/target/hppa/fpu_helper.c
20
@@ -XXX,XX +XXX,XX @@ void HELPER(loaded_fr0)(CPUHPPAState *env)
21
* HPPA does note implement a CPU reset method at all...
22
*/
23
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status);
24
+ /* For inf * 0 + NaN, return the input NaN */
25
+ set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
26
}
27
28
void cpu_hppa_loaded_fr0(CPUHPPAState *env)
29
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
30
index XXXXXXX..XXXXXXX 100644
31
--- a/fpu/softfloat-specialize.c.inc
32
+++ b/fpu/softfloat-specialize.c.inc
33
@@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
34
static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
35
bool infzero, float_status *status)
36
{
37
- FloatInfZeroNaNRule rule = status->float_infzeronan_rule;
38
-
39
/*
40
* We guarantee not to require the target to tell us how to
41
* pick a NaN if we're always returning the default NaN.
42
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
43
*/
44
assert(!status->default_nan_mode);
45
46
- if (rule == float_infzeronan_none) {
47
- /*
48
- * Temporarily fall back to ifdef ladder
49
- */
50
-#if defined(TARGET_HPPA)
51
- rule = float_infzeronan_dnan_never;
52
-#endif
53
- }
54
-
55
if (infzero) {
56
/*
57
* Inf * 0 + NaN -- some implementations return the default NaN here,
58
* and some return the input NaN.
59
*/
60
- switch (rule) {
61
+ switch (status->float_infzeronan_rule) {
62
case float_infzeronan_dnan_never:
63
return 2;
64
case float_infzeronan_dnan_always:
65
--
66
2.34.1
diff view generated by jsdifflib
New patch
1
The new implementation of pickNaNMulAdd() will find it convenient
2
to know whether at least one of the three arguments to the muladd
3
was a signaling NaN. We already calculate that in the caller,
4
so pass it in as a new bool have_snan.
1
5
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20241202131347.498124-15-peter.maydell@linaro.org
9
---
10
fpu/softfloat-parts.c.inc | 5 +++--
11
fpu/softfloat-specialize.c.inc | 2 +-
12
2 files changed, 4 insertions(+), 3 deletions(-)
13
14
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
15
index XXXXXXX..XXXXXXX 100644
16
--- a/fpu/softfloat-parts.c.inc
17
+++ b/fpu/softfloat-parts.c.inc
18
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
19
{
20
int which;
21
bool infzero = (ab_mask == float_cmask_infzero);
22
+ bool have_snan = (abc_mask & float_cmask_snan);
23
24
- if (unlikely(abc_mask & float_cmask_snan)) {
25
+ if (unlikely(have_snan)) {
26
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
27
}
28
29
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
30
if (s->default_nan_mode) {
31
which = 3;
32
} else {
33
- which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, s);
34
+ which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, have_snan, s);
35
}
36
37
if (which == 3) {
38
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
39
index XXXXXXX..XXXXXXX 100644
40
--- a/fpu/softfloat-specialize.c.inc
41
+++ b/fpu/softfloat-specialize.c.inc
42
@@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
43
| Return values : 0 : a; 1 : b; 2 : c; 3 : default-NaN
44
*----------------------------------------------------------------------------*/
45
static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
46
- bool infzero, float_status *status)
47
+ bool infzero, bool have_snan, float_status *status)
48
{
49
/*
50
* We guarantee not to require the target to tell us how to
51
--
52
2.34.1
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
IEEE 758 does not define a fixed rule for which NaN to pick as the
2
2
result if both operands of a 3-operand fused multiply-add operation
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
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.
23
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
25
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20210112104511.36576-19-remi.denis.courmont@huawei.com
26
Message-id: 20241202131347.498124-16-peter.maydell@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
27
---
8
target/arm/helper.c | 25 +++++++++++--------------
28
include/fpu/softfloat-helpers.h | 11 +++
9
1 file changed, 11 insertions(+), 14 deletions(-)
29
include/fpu/softfloat-types.h | 55 +++++++++++
10
30
fpu/softfloat-specialize.c.inc | 167 ++++++++------------------------
11
diff --git a/target/arm/helper.c b/target/arm/helper.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
12
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
35
--- a/include/fpu/softfloat-helpers.h
14
+++ b/target/arm/helper.c
36
+++ b/include/fpu/softfloat-helpers.h
15
@@ -XXX,XX +XXX,XX @@ static CPAccessResult aa64_cacheop_pou_access(CPUARMState *env,
37
@@ -XXX,XX +XXX,XX @@ static inline void set_float_2nan_prop_rule(Float2NaNPropRule rule,
16
static int vae1_tlbmask(CPUARMState *env)
38
status->float_2nan_prop_rule = rule;
39
}
40
41
+static inline void set_float_3nan_prop_rule(Float3NaNPropRule rule,
42
+ float_status *status)
43
+{
44
+ status->float_3nan_prop_rule = rule;
45
+}
46
+
47
static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule,
48
float_status *status)
17
{
49
{
18
uint64_t hcr = arm_hcr_el2_eff(env);
50
@@ -XXX,XX +XXX,XX @@ static inline Float2NaNPropRule get_float_2nan_prop_rule(float_status *status)
19
+ uint16_t mask;
51
return status->float_2nan_prop_rule;
20
52
}
21
if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) {
53
22
- uint16_t mask = ARMMMUIdxBit_E20_2 |
54
+static inline Float3NaNPropRule get_float_3nan_prop_rule(float_status *status)
23
- ARMMMUIdxBit_E20_2_PAN |
55
+{
24
- ARMMMUIdxBit_E20_0;
56
+ return status->float_3nan_prop_rule;
57
+}
58
+
59
static inline FloatInfZeroNaNRule get_float_infzeronan_rule(float_status *status)
60
{
61
return status->float_infzeronan_rule;
62
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
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,
158
}
159
}
160
161
+ if (rule == float_3nan_prop_none) {
162
#if defined(TARGET_ARM)
25
-
163
-
26
- if (arm_is_secure_below_el3(env)) {
164
- /* This looks different from the ARM ARM pseudocode, because the ARM ARM
27
- mask >>= ARM_MMU_IDX_A_NS;
165
- * puts the operands to a fused mac operation (a*b)+c in the order c,a,b.
166
- */
167
- if (is_snan(c_cls)) {
168
- return 2;
169
- } else if (is_snan(a_cls)) {
170
- return 0;
171
- } else if (is_snan(b_cls)) {
172
- return 1;
173
- } else if (is_qnan(c_cls)) {
174
- return 2;
175
- } else if (is_qnan(a_cls)) {
176
- return 0;
177
- } else {
178
- return 1;
179
- }
180
+ /*
181
+ * This looks different from the ARM ARM pseudocode, because the ARM ARM
182
+ * puts the operands to a fused mac operation (a*b)+c in the order c,a,b
183
+ */
184
+ rule = float_3nan_prop_s_cab;
185
#elif defined(TARGET_MIPS)
186
- if (snan_bit_is_one(status)) {
187
- /* Prefer sNaN over qNaN, in the a, b, c order. */
188
- if (is_snan(a_cls)) {
189
- return 0;
190
- } else if (is_snan(b_cls)) {
191
- return 1;
192
- } else if (is_snan(c_cls)) {
193
- return 2;
194
- } else if (is_qnan(a_cls)) {
195
- return 0;
196
- } else if (is_qnan(b_cls)) {
197
- return 1;
198
+ if (snan_bit_is_one(status)) {
199
+ rule = float_3nan_prop_s_abc;
200
} else {
201
- return 2;
202
+ rule = float_3nan_prop_s_cab;
203
}
204
- } else {
205
- /* Prefer sNaN over qNaN, in the c, a, b order. */
206
- if (is_snan(c_cls)) {
207
- return 2;
208
- } else if (is_snan(a_cls)) {
209
- return 0;
210
- } else if (is_snan(b_cls)) {
211
- return 1;
212
- } else if (is_qnan(c_cls)) {
213
- return 2;
214
- } else if (is_qnan(a_cls)) {
215
- return 0;
216
- } else {
217
- return 1;
28
- }
218
- }
29
-
219
- }
30
- return mask;
220
#elif defined(TARGET_LOONGARCH64)
31
- } else if (arm_is_secure_below_el3(env)) {
221
- /* Prefer sNaN over qNaN, in the c, a, b order. */
32
- return ARMMMUIdxBit_SE10_1 |
222
- if (is_snan(c_cls)) {
33
- ARMMMUIdxBit_SE10_1_PAN |
223
- return 2;
34
- ARMMMUIdxBit_SE10_0;
224
- } else if (is_snan(a_cls)) {
35
+ mask = ARMMMUIdxBit_E20_2 |
225
- return 0;
36
+ ARMMMUIdxBit_E20_2_PAN |
226
- } else if (is_snan(b_cls)) {
37
+ ARMMMUIdxBit_E20_0;
227
- return 1;
38
} else {
228
- } else if (is_qnan(c_cls)) {
39
- return ARMMMUIdxBit_E10_1 |
229
- return 2;
40
+ mask = ARMMMUIdxBit_E10_1 |
230
- } else if (is_qnan(a_cls)) {
41
ARMMMUIdxBit_E10_1_PAN |
231
- return 0;
42
ARMMMUIdxBit_E10_0;
232
- } else {
43
}
233
- return 1;
44
+
234
- }
45
+ if (arm_is_secure_below_el3(env)) {
235
+ rule = float_3nan_prop_s_cab;
46
+ mask >>= ARM_MMU_IDX_A_NS;
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
47
+ }
321
+ }
48
+
322
+
49
+ return mask;
323
+ assert(rule != float_3nan_prop_none);
324
+ if (have_snan && (rule & R_3NAN_SNAN_MASK)) {
325
+ /* We have at least one SNaN input and should prefer it */
326
+ do {
327
+ which = rule & R_3NAN_1ST_MASK;
328
+ rule >>= R_3NAN_1ST_LENGTH;
329
+ } while (!is_snan(cls[which]));
330
+ } else {
331
+ do {
332
+ which = rule & R_3NAN_1ST_MASK;
333
+ rule >>= R_3NAN_1ST_LENGTH;
334
+ } while (!is_nan(cls[which]));
335
+ }
336
+ return which;
50
}
337
}
51
338
52
/* Return 56 if TBI is enabled, 64 otherwise. */
339
/*----------------------------------------------------------------------------
53
--
340
--
54
2.20.1
341
2.34.1
55
56
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
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
Set the Float3NaNPropRule explicitly for Arm, and remove the
2
ifdef from pickNaNMulAdd().
2
3
3
In this context, the HCR value is the effective value, and thus is
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
zero in secure mode. The tests for HCR.{F,I}MO are sufficient.
5
6
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210112104511.36576-1-remi.denis.courmont@huawei.com
6
Message-id: 20241202131347.498124-18-peter.maydell@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
7
---
11
target/arm/cpu.c | 8 ++++----
8
target/arm/cpu.c | 5 +++++
12
target/arm/helper.c | 10 ++++------
9
fpu/softfloat-specialize.c.inc | 8 +-------
13
2 files changed, 8 insertions(+), 10 deletions(-)
10
2 files changed, 6 insertions(+), 7 deletions(-)
14
11
15
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
12
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
16
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu.c
14
--- a/target/arm/cpu.c
18
+++ b/target/arm/cpu.c
15
+++ b/target/arm/cpu.c
19
@@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
16
@@ -XXX,XX +XXX,XX @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
20
break;
17
* * tininess-before-rounding
21
18
* * 2-input NaN propagation prefers SNaN over QNaN, and then
22
case EXCP_VFIQ:
19
* operand A over operand B (see FPProcessNaNs() pseudocode)
23
- if (secure || !(hcr_el2 & HCR_FMO) || (hcr_el2 & HCR_TGE)) {
20
+ * * 3-input NaN propagation prefers SNaN over QNaN, and then
24
- /* VFIQs are only taken when hypervized and non-secure. */
21
+ * operand C over A over B (see FPProcessNaNs3() pseudocode,
25
+ if (!(hcr_el2 & HCR_FMO) || (hcr_el2 & HCR_TGE)) {
22
+ * but note that for QEMU muladd is a * b + c, whereas for
26
+ /* VFIQs are only taken when hypervized. */
23
+ * the pseudocode function the arguments are in the order c, a, b.
27
return false;
24
* * 0 * Inf + NaN returns the default NaN if the input NaN is quiet,
28
}
25
* and the input NaN if it is signalling
29
return !(env->daif & PSTATE_F);
26
*/
30
case EXCP_VIRQ:
27
@@ -XXX,XX +XXX,XX @@ static void arm_set_default_fp_behaviours(float_status *s)
31
- if (secure || !(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) {
28
{
32
- /* VIRQs are only taken when hypervized and non-secure. */
29
set_float_detect_tininess(float_tininess_before_rounding, s);
33
+ if (!(hcr_el2 & HCR_IMO) || (hcr_el2 & HCR_TGE)) {
30
set_float_2nan_prop_rule(float_2nan_prop_s_ab, s);
34
+ /* VIRQs are only taken when hypervized. */
31
+ set_float_3nan_prop_rule(float_3nan_prop_s_cab, s);
35
return false;
32
set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, s);
36
}
33
}
37
return !(env->daif & PSTATE_I);
34
38
diff --git a/target/arm/helper.c b/target/arm/helper.c
35
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
39
index XXXXXXX..XXXXXXX 100644
36
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/helper.c
37
--- a/fpu/softfloat-specialize.c.inc
41
+++ b/target/arm/helper.c
38
+++ b/fpu/softfloat-specialize.c.inc
42
@@ -XXX,XX +XXX,XX @@ static void csselr_write(CPUARMState *env, const ARMCPRegInfo *ri,
39
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
43
static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri)
44
{
45
CPUState *cs = env_cpu(env);
46
- uint64_t hcr_el2 = arm_hcr_el2_eff(env);
47
+ bool el1 = arm_current_el(env) == 1;
48
+ uint64_t hcr_el2 = el1 ? arm_hcr_el2_eff(env) : 0;
49
uint64_t ret = 0;
50
- bool allow_virt = (arm_current_el(env) == 1 &&
51
- (!arm_is_secure_below_el3(env) ||
52
- (env->cp15.scr_el3 & SCR_EEL2)));
53
54
- if (allow_virt && (hcr_el2 & HCR_IMO)) {
55
+ if (hcr_el2 & HCR_IMO) {
56
if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) {
57
ret |= CPSR_I;
58
}
59
@@ -XXX,XX +XXX,XX @@ static uint64_t isr_read(CPUARMState *env, const ARMCPRegInfo *ri)
60
}
61
}
40
}
62
41
63
- if (allow_virt && (hcr_el2 & HCR_FMO)) {
42
if (rule == float_3nan_prop_none) {
64
+ if (hcr_el2 & HCR_FMO) {
43
-#if defined(TARGET_ARM)
65
if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) {
44
- /*
66
ret |= CPSR_F;
45
- * This looks different from the ARM ARM pseudocode, because the ARM ARM
67
}
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 {
68
--
54
--
69
2.20.1
55
2.34.1
70
71
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
From: Gan Qixin <ganqixin@huawei.com>
1
Set the Float3NaNPropRule explicitly for i386. We had no
2
i386-specific behaviour in the old ifdef ladder, so we were using the
3
default "prefer a then b then c" fallback; this is actually the
4
correct per-the-spec handling for i386.
2
5
3
The adc_qom_set function didn't free "response", which caused an indirect
4
memory leak. So use qobject_unref() to fix it.
5
6
ASAN shows memory leak stack:
7
8
Indirect leak of 593280 byte(s) in 144 object(s) allocated from:
9
#0 0x7f9a5e7e8d4e in __interceptor_calloc (/lib64/libasan.so.5+0x112d4e)
10
#1 0x7f9a5e607a50 in g_malloc0 (/lib64/libglib-2.0.so.0+0x55a50)
11
#2 0x55b1bebf636b in qdict_new ../qobject/qdict.c:30
12
#3 0x55b1bec09699 in parse_object ../qobject/json-parser.c:318
13
#4 0x55b1bec0b2df in parse_value ../qobject/json-parser.c:546
14
#5 0x55b1bec0b6a9 in json_parser_parse ../qobject/json-parser.c:580
15
#6 0x55b1bec060d1 in json_message_process_token ../qobject/json-streamer.c:92
16
#7 0x55b1bec16a12 in json_lexer_feed_char ../qobject/json-lexer.c:313
17
#8 0x55b1bec16fbd in json_lexer_feed ../qobject/json-lexer.c:350
18
#9 0x55b1bec06453 in json_message_parser_feed ../qobject/json-streamer.c:121
19
#10 0x55b1bebc2d51 in qmp_fd_receive ../tests/qtest/libqtest.c:614
20
#11 0x55b1bebc2f5e in qtest_qmp_receive_dict ../tests/qtest/libqtest.c:636
21
#12 0x55b1bebc2e6c in qtest_qmp_receive ../tests/qtest/libqtest.c:624
22
#13 0x55b1bebc3340 in qtest_vqmp ../tests/qtest/libqtest.c:715
23
#14 0x55b1bebc3942 in qtest_qmp ../tests/qtest/libqtest.c:756
24
#15 0x55b1bebbd64a in adc_qom_set ../tests/qtest/npcm7xx_adc-test.c:127
25
#16 0x55b1bebbd793 in adc_write_input ../tests/qtest/npcm7xx_adc-test.c:140
26
#17 0x55b1bebbdf92 in test_convert_external ../tests/qtest/npcm7xx_adc-test.c:246
27
28
Reported-by: Euler Robot <euler.robot@huawei.com>
29
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
30
Reviewed-by: Hao Wu <wuhaotsh@google.com>
31
Message-id: 20210118065627.79903-1-ganqixin@huawei.com
32
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
33
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>
8
Message-id: 20241202131347.498124-25-peter.maydell@linaro.org
34
---
9
---
35
tests/qtest/npcm7xx_adc-test.c | 1 +
10
target/i386/tcg/fpu_helper.c | 1 +
36
1 file changed, 1 insertion(+)
11
1 file changed, 1 insertion(+)
37
12
38
diff --git a/tests/qtest/npcm7xx_adc-test.c b/tests/qtest/npcm7xx_adc-test.c
13
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
39
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
40
--- a/tests/qtest/npcm7xx_adc-test.c
15
--- a/target/i386/tcg/fpu_helper.c
41
+++ b/tests/qtest/npcm7xx_adc-test.c
16
+++ b/target/i386/tcg/fpu_helper.c
42
@@ -XXX,XX +XXX,XX @@ static void adc_qom_set(QTestState *qts, const ADC *adc,
17
@@ -XXX,XX +XXX,XX @@ void cpu_init_fp_statuses(CPUX86State *env)
43
path, name, value);
18
* there are multiple input NaNs they are selected in the order a, b, c.
44
/* The qom set message returns successfully. */
19
*/
45
g_assert_true(qdict_haskey(response, "return"));
20
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->sse_status);
46
+ qobject_unref(response);
21
+ set_float_3nan_prop_rule(float_3nan_prop_abc, &env->sse_status);
47
}
22
}
48
23
49
static void adc_write_input(QTestState *qts, const ADC *adc,
24
static inline uint8_t save_exception_flags(CPUX86State *env)
50
--
25
--
51
2.20.1
26
2.34.1
52
53
diff view generated by jsdifflib
New patch
1
Set the Float3NaNPropRule explicitly for HPPA, and remove the
2
ifdef from pickNaNMulAdd().
1
3
4
HPPA is the only target that was using the default branch of the
5
ifdef ladder (other targets either do not use muladd or set
6
default_nan_mode), so we can remove the ifdef fallback entirely now
7
(allowing the "rule not set" case to fall into the default of the
8
switch statement and assert).
9
10
We add a TODO note that the HPPA rule is probably wrong; this is
11
not a behavioural change for this refactoring.
12
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20241202131347.498124-26-peter.maydell@linaro.org
16
---
17
target/hppa/fpu_helper.c | 8 ++++++++
18
fpu/softfloat-specialize.c.inc | 4 ----
19
2 files changed, 8 insertions(+), 4 deletions(-)
20
21
diff --git a/target/hppa/fpu_helper.c b/target/hppa/fpu_helper.c
22
index XXXXXXX..XXXXXXX 100644
23
--- a/target/hppa/fpu_helper.c
24
+++ b/target/hppa/fpu_helper.c
25
@@ -XXX,XX +XXX,XX @@ void HELPER(loaded_fr0)(CPUHPPAState *env)
26
* HPPA does note implement a CPU reset method at all...
27
*/
28
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &env->fp_status);
29
+ /*
30
+ * TODO: The HPPA architecture reference only documents its NaN
31
+ * propagation rule for 2-operand operations. Testing on real hardware
32
+ * might be necessary to confirm whether this order for muladd is correct.
33
+ * Not preferring the SNaN is almost certainly incorrect as it diverges
34
+ * from the documented rules for 2-operand operations.
35
+ */
36
+ set_float_3nan_prop_rule(float_3nan_prop_abc, &env->fp_status);
37
/* For inf * 0 + NaN, return the input NaN */
38
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
39
}
40
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
41
index XXXXXXX..XXXXXXX 100644
42
--- a/fpu/softfloat-specialize.c.inc
43
+++ b/fpu/softfloat-specialize.c.inc
44
@@ -XXX,XX +XXX,XX @@ static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
45
}
46
}
47
48
- if (rule == float_3nan_prop_none) {
49
- rule = float_3nan_prop_abc;
50
- }
51
-
52
assert(rule != float_3nan_prop_none);
53
if (have_snan && (rule & R_3NAN_SNAN_MASK)) {
54
/* We have at least one SNaN input and should prefer it */
55
--
56
2.34.1
diff view generated by jsdifflib
New patch
1
The use_first_nan field in float_status was an xtensa-specific way to
2
select at runtime from two different NaN propagation rules. Now that
3
xtensa is using the target-agnostic NaN propagation rule selection
4
that we've just added, we can remove use_first_nan, because there is
5
no longer any code that reads it.
1
6
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20241202131347.498124-27-peter.maydell@linaro.org
10
---
11
include/fpu/softfloat-helpers.h | 5 -----
12
include/fpu/softfloat-types.h | 1 -
13
target/xtensa/fpu_helper.c | 1 -
14
3 files changed, 7 deletions(-)
15
16
diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/fpu/softfloat-helpers.h
19
+++ b/include/fpu/softfloat-helpers.h
20
@@ -XXX,XX +XXX,XX @@ static inline void set_snan_bit_is_one(bool val, float_status *status)
21
status->snan_bit_is_one = val;
22
}
23
24
-static inline void set_use_first_nan(bool val, float_status *status)
25
-{
26
- status->use_first_nan = val;
27
-}
28
-
29
static inline void set_no_signaling_nans(bool val, float_status *status)
30
{
31
status->no_signaling_nans = val;
32
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
33
index XXXXXXX..XXXXXXX 100644
34
--- a/include/fpu/softfloat-types.h
35
+++ b/include/fpu/softfloat-types.h
36
@@ -XXX,XX +XXX,XX @@ typedef struct float_status {
37
* softfloat-specialize.inc.c)
38
*/
39
bool snan_bit_is_one;
40
- bool use_first_nan;
41
bool no_signaling_nans;
42
/* should overflowed results subtract re_bias to its exponent? */
43
bool rebias_overflow;
44
diff --git a/target/xtensa/fpu_helper.c b/target/xtensa/fpu_helper.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/target/xtensa/fpu_helper.c
47
+++ b/target/xtensa/fpu_helper.c
48
@@ -XXX,XX +XXX,XX @@ static const struct {
49
50
void xtensa_use_first_nan(CPUXtensaState *env, bool use_first)
51
{
52
- set_use_first_nan(use_first, &env->fp_status);
53
set_float_2nan_prop_rule(use_first ? float_2nan_prop_ab : float_2nan_prop_ba,
54
&env->fp_status);
55
set_float_3nan_prop_rule(use_first ? float_3nan_prop_abc : float_3nan_prop_cba,
56
--
57
2.34.1
diff view generated by jsdifflib
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
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
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.
2
9
3
In the secure stage 2 translation regime, the VSTCR.SW and VTCR.NSW
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
bits can invert the secure flag for pagetable walks. This patchset
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
allows S1_ptw_translate() to change the non-secure bit.
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(-)
6
16
7
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
17
diff --git a/target/m68k/helper.c b/target/m68k/helper.c
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20210112104511.36576-11-remi.denis.courmont@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/helper.c | 9 ++++++---
13
1 file changed, 6 insertions(+), 3 deletions(-)
14
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
19
--- a/target/m68k/helper.c
18
+++ b/target/arm/helper.c
20
+++ b/target/m68k/helper.c
19
@@ -XXX,XX +XXX,XX @@ static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx,
21
@@ -XXX,XX +XXX,XX @@ static int cf_fpu_gdb_get_reg(CPUState *cs, GByteArray *mem_buf, int n)
20
22
CPUM68KState *env = &cpu->env;
21
/* Translate a S1 pagetable walk through S2 if needed. */
23
22
static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
24
if (n < 8) {
23
- hwaddr addr, MemTxAttrs txattrs,
25
- float_status s = {};
24
+ hwaddr addr, bool *is_secure,
26
+ /* Use scratch float_status so any exceptions don't change CPU state */
25
ARMMMUFaultInfo *fi)
27
+ float_status s = env->fp_status;
26
{
28
return gdb_get_reg64(mem_buf, floatx80_to_float64(env->fregs[n].d, &s));
27
if (arm_mmu_idx_is_stage1_of_2(mmu_idx) &&
28
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
29
int s2prot;
30
int ret;
31
ARMCacheAttrs cacheattrs = {};
32
+ MemTxAttrs txattrs = {};
33
+
34
+ assert(!*is_secure); /* TODO: S-EL2 */
35
36
ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, ARMMMUIdx_Stage2,
37
false,
38
@@ -XXX,XX +XXX,XX @@ static uint32_t arm_ldl_ptw(CPUState *cs, hwaddr addr, bool is_secure,
39
AddressSpace *as;
40
uint32_t data;
41
42
+ addr = S1_ptw_translate(env, mmu_idx, addr, &is_secure, fi);
43
attrs.secure = is_secure;
44
as = arm_addressspace(cs, attrs);
45
- addr = S1_ptw_translate(env, mmu_idx, addr, attrs, fi);
46
if (fi->s1ptw) {
47
return 0;
48
}
29
}
49
@@ -XXX,XX +XXX,XX @@ static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure,
30
switch (n) {
50
AddressSpace *as;
31
@@ -XXX,XX +XXX,XX @@ static int cf_fpu_gdb_set_reg(CPUState *cs, uint8_t *mem_buf, int n)
51
uint64_t data;
32
CPUM68KState *env = &cpu->env;
52
33
53
+ addr = S1_ptw_translate(env, mmu_idx, addr, &is_secure, fi);
34
if (n < 8) {
54
attrs.secure = is_secure;
35
- float_status s = {};
55
as = arm_addressspace(cs, attrs);
36
+ /* Use scratch float_status so any exceptions don't change CPU state */
56
- addr = S1_ptw_translate(env, mmu_idx, addr, attrs, fi);
37
+ float_status s = env->fp_status;
57
if (fi->s1ptw) {
38
env->fregs[n].d = float64_to_floatx80(ldq_be_p(mem_buf), &s);
58
return 0;
39
return 8;
59
}
40
}
60
--
41
--
61
2.20.1
42
2.34.1
62
63
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
In the helper functions flcmps and flcmpd we use a scratch float_status
2
so that we don't change the CPU state if the comparison raises any
3
floating point exception flags. Instead of zero-initializing this
4
scratch float_status, initialize it as a copy of env->fp_status. This
5
avoids the need to explicitly initialize settings like the NaN
6
propagation rule or others we might add to softfloat in future.
2
7
3
Without hardware acceleration, a cryptographically strong
8
To do this we need to pass the CPU env pointer in to the helper.
4
algorithm is too expensive for pauth_computepac.
5
9
6
Even with hardware accel, we are not currently expecting
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
to link the linux-user binaries to any crypto libraries,
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
and doing so would generally make the --static build fail.
12
Message-id: 20241202131347.498124-33-peter.maydell@linaro.org
13
---
14
target/sparc/helper.h | 4 ++--
15
target/sparc/fop_helper.c | 8 ++++----
16
target/sparc/translate.c | 4 ++--
17
3 files changed, 8 insertions(+), 8 deletions(-)
9
18
10
So choose XXH64 as a reasonably quick and decent hash.
19
diff --git a/target/sparc/helper.h b/target/sparc/helper.h
11
12
Tested-by: Mark Rutland <mark.rutland@arm.com>
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20210111235740.462469-2-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
include/qemu/xxhash.h | 98 +++++++++++++++++++++++++++++++++++++++
19
target/arm/cpu.h | 15 ++++--
20
target/arm/pauth_helper.c | 27 +++++++++--
21
3 files changed, 131 insertions(+), 9 deletions(-)
22
23
diff --git a/include/qemu/xxhash.h b/include/qemu/xxhash.h
24
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
25
--- a/include/qemu/xxhash.h
21
--- a/target/sparc/helper.h
26
+++ b/include/qemu/xxhash.h
22
+++ b/target/sparc/helper.h
27
@@ -XXX,XX +XXX,XX @@ static inline uint32_t qemu_xxhash6(uint64_t ab, uint64_t cd, uint32_t e,
23
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(fcmpd, TCG_CALL_NO_WG, i32, env, f64, f64)
28
return qemu_xxhash7(ab, cd, e, f, 0);
24
DEF_HELPER_FLAGS_3(fcmped, TCG_CALL_NO_WG, i32, env, f64, f64)
25
DEF_HELPER_FLAGS_3(fcmpq, TCG_CALL_NO_WG, i32, env, i128, i128)
26
DEF_HELPER_FLAGS_3(fcmpeq, TCG_CALL_NO_WG, i32, env, i128, i128)
27
-DEF_HELPER_FLAGS_2(flcmps, TCG_CALL_NO_RWG_SE, i32, f32, f32)
28
-DEF_HELPER_FLAGS_2(flcmpd, TCG_CALL_NO_RWG_SE, i32, f64, f64)
29
+DEF_HELPER_FLAGS_3(flcmps, TCG_CALL_NO_RWG_SE, i32, env, f32, f32)
30
+DEF_HELPER_FLAGS_3(flcmpd, TCG_CALL_NO_RWG_SE, i32, env, f64, f64)
31
DEF_HELPER_2(raise_exception, noreturn, env, int)
32
33
DEF_HELPER_FLAGS_3(faddd, TCG_CALL_NO_WG, f64, env, f64, f64)
34
diff --git a/target/sparc/fop_helper.c b/target/sparc/fop_helper.c
35
index XXXXXXX..XXXXXXX 100644
36
--- a/target/sparc/fop_helper.c
37
+++ b/target/sparc/fop_helper.c
38
@@ -XXX,XX +XXX,XX @@ uint32_t helper_fcmpeq(CPUSPARCState *env, Int128 src1, Int128 src2)
39
return finish_fcmp(env, r, GETPC());
29
}
40
}
30
41
31
+/*
42
-uint32_t helper_flcmps(float32 src1, float32 src2)
32
+ * Component parts of the XXH64 algorithm from
43
+uint32_t helper_flcmps(CPUSPARCState *env, float32 src1, float32 src2)
33
+ * https://github.com/Cyan4973/xxHash/blob/v0.8.0/xxhash.h
34
+ *
35
+ * The complete algorithm looks like
36
+ *
37
+ * i = 0;
38
+ * if (len >= 32) {
39
+ * v1 = seed + XXH_PRIME64_1 + XXH_PRIME64_2;
40
+ * v2 = seed + XXH_PRIME64_2;
41
+ * v3 = seed + 0;
42
+ * v4 = seed - XXH_PRIME64_1;
43
+ * do {
44
+ * v1 = XXH64_round(v1, get64bits(input + i));
45
+ * v2 = XXH64_round(v2, get64bits(input + i + 8));
46
+ * v3 = XXH64_round(v3, get64bits(input + i + 16));
47
+ * v4 = XXH64_round(v4, get64bits(input + i + 24));
48
+ * } while ((i += 32) <= len);
49
+ * h64 = XXH64_mergerounds(v1, v2, v3, v4);
50
+ * } else {
51
+ * h64 = seed + XXH_PRIME64_5;
52
+ * }
53
+ * h64 += len;
54
+ *
55
+ * for (; i + 8 <= len; i += 8) {
56
+ * h64 ^= XXH64_round(0, get64bits(input + i));
57
+ * h64 = rol64(h64, 27) * XXH_PRIME64_1 + XXH_PRIME64_4;
58
+ * }
59
+ * for (; i + 4 <= len; i += 4) {
60
+ * h64 ^= get32bits(input + i) * PRIME64_1;
61
+ * h64 = rol64(h64, 23) * XXH_PRIME64_2 + XXH_PRIME64_3;
62
+ * }
63
+ * for (; i < len; i += 1) {
64
+ * h64 ^= get8bits(input + i) * XXH_PRIME64_5;
65
+ * h64 = rol64(h64, 11) * XXH_PRIME64_1;
66
+ * }
67
+ *
68
+ * return XXH64_avalanche(h64)
69
+ *
70
+ * Exposing the pieces instead allows for simplified usage when
71
+ * the length is a known constant and the inputs are in registers.
72
+ */
73
+#define XXH_PRIME64_1 0x9E3779B185EBCA87ULL
74
+#define XXH_PRIME64_2 0xC2B2AE3D27D4EB4FULL
75
+#define XXH_PRIME64_3 0x165667B19E3779F9ULL
76
+#define XXH_PRIME64_4 0x85EBCA77C2B2AE63ULL
77
+#define XXH_PRIME64_5 0x27D4EB2F165667C5ULL
78
+
79
+static inline uint64_t XXH64_round(uint64_t acc, uint64_t input)
80
+{
81
+ return rol64(acc + input * XXH_PRIME64_2, 31) * XXH_PRIME64_1;
82
+}
83
+
84
+static inline uint64_t XXH64_mergeround(uint64_t acc, uint64_t val)
85
+{
86
+ return (acc ^ XXH64_round(0, val)) * XXH_PRIME64_1 + XXH_PRIME64_4;
87
+}
88
+
89
+static inline uint64_t XXH64_mergerounds(uint64_t v1, uint64_t v2,
90
+ uint64_t v3, uint64_t v4)
91
+{
92
+ uint64_t h64;
93
+
94
+ h64 = rol64(v1, 1) + rol64(v2, 7) + rol64(v3, 12) + rol64(v4, 18);
95
+ h64 = XXH64_mergeround(h64, v1);
96
+ h64 = XXH64_mergeround(h64, v2);
97
+ h64 = XXH64_mergeround(h64, v3);
98
+ h64 = XXH64_mergeround(h64, v4);
99
+
100
+ return h64;
101
+}
102
+
103
+static inline uint64_t XXH64_avalanche(uint64_t h64)
104
+{
105
+ h64 ^= h64 >> 33;
106
+ h64 *= XXH_PRIME64_2;
107
+ h64 ^= h64 >> 29;
108
+ h64 *= XXH_PRIME64_3;
109
+ h64 ^= h64 >> 32;
110
+ return h64;
111
+}
112
+
113
+static inline uint64_t qemu_xxhash64_4(uint64_t a, uint64_t b,
114
+ uint64_t c, uint64_t d)
115
+{
116
+ uint64_t v1 = QEMU_XXHASH_SEED + XXH_PRIME64_1 + XXH_PRIME64_2;
117
+ uint64_t v2 = QEMU_XXHASH_SEED + XXH_PRIME64_2;
118
+ uint64_t v3 = QEMU_XXHASH_SEED + 0;
119
+ uint64_t v4 = QEMU_XXHASH_SEED - XXH_PRIME64_1;
120
+
121
+ v1 = XXH64_round(v1, a);
122
+ v2 = XXH64_round(v2, b);
123
+ v3 = XXH64_round(v3, c);
124
+ v4 = XXH64_round(v4, d);
125
+
126
+ return XXH64_avalanche(XXH64_mergerounds(v1, v2, v3, v4));
127
+}
128
+
129
#endif /* QEMU_XXHASH_H */
130
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
131
index XXXXXXX..XXXXXXX 100644
132
--- a/target/arm/cpu.h
133
+++ b/target/arm/cpu.h
134
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fcma(const ARMISARegisters *id)
135
static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id)
136
{
44
{
137
/*
45
/*
138
- * Note that while QEMU will only implement the architected algorithm
46
* FLCMP never raises an exception nor modifies any FSR fields.
139
- * QARMA, and thus APA+GPA, the host cpu for kvm may use implementation
47
* Perform the comparison with a dummy fp environment.
140
- * defined algorithms, and thus API+GPI, and this predicate controls
141
- * migration of the 128-bit keys.
142
+ * Return true if any form of pauth is enabled, as this
143
+ * predicate controls migration of the 128-bit keys.
144
*/
48
*/
145
return (id->id_aa64isar1 &
49
- float_status discard = { };
146
(FIELD_DP64(0, ID_AA64ISAR1, APA, 0xf) |
50
+ float_status discard = env->fp_status;
147
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id)
51
FloatRelation r;
148
FIELD_DP64(0, ID_AA64ISAR1, GPI, 0xf))) != 0;
52
53
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard);
54
@@ -XXX,XX +XXX,XX @@ uint32_t helper_flcmps(float32 src1, float32 src2)
55
g_assert_not_reached();
149
}
56
}
150
57
151
+static inline bool isar_feature_aa64_pauth_arch(const ARMISARegisters *id)
58
-uint32_t helper_flcmpd(float64 src1, float64 src2)
152
+{
59
+uint32_t helper_flcmpd(CPUSPARCState *env, float64 src1, float64 src2)
153
+ /*
154
+ * Return true if pauth is enabled with the architected QARMA algorithm.
155
+ * QEMU will always set APA+GPA to the same value.
156
+ */
157
+ return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA) != 0;
158
+}
159
+
160
static inline bool isar_feature_aa64_sb(const ARMISARegisters *id)
161
{
60
{
162
return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, SB) != 0;
61
- float_status discard = { };
163
diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c
62
+ float_status discard = env->fp_status;
63
FloatRelation r;
64
65
set_float_2nan_prop_rule(float_2nan_prop_s_ba, &discard);
66
diff --git a/target/sparc/translate.c b/target/sparc/translate.c
164
index XXXXXXX..XXXXXXX 100644
67
index XXXXXXX..XXXXXXX 100644
165
--- a/target/arm/pauth_helper.c
68
--- a/target/sparc/translate.c
166
+++ b/target/arm/pauth_helper.c
69
+++ b/target/sparc/translate.c
167
@@ -XXX,XX +XXX,XX @@
70
@@ -XXX,XX +XXX,XX @@ static bool trans_FLCMPs(DisasContext *dc, arg_FLCMPs *a)
168
#include "exec/cpu_ldst.h"
71
169
#include "exec/helper-proto.h"
72
src1 = gen_load_fpr_F(dc, a->rs1);
170
#include "tcg/tcg-gvec-desc.h"
73
src2 = gen_load_fpr_F(dc, a->rs2);
171
+#include "qemu/xxhash.h"
74
- gen_helper_flcmps(cpu_fcc[a->cc], src1, src2);
172
75
+ gen_helper_flcmps(cpu_fcc[a->cc], tcg_env, src1, src2);
173
76
return advance_pc(dc);
174
static uint64_t pac_cell_shuffle(uint64_t i)
175
@@ -XXX,XX +XXX,XX @@ static uint64_t tweak_inv_shuffle(uint64_t i)
176
return o;
177
}
77
}
178
78
179
-static uint64_t pauth_computepac(uint64_t data, uint64_t modifier,
79
@@ -XXX,XX +XXX,XX @@ static bool trans_FLCMPd(DisasContext *dc, arg_FLCMPd *a)
180
- ARMPACKey key)
80
181
+static uint64_t pauth_computepac_architected(uint64_t data, uint64_t modifier,
81
src1 = gen_load_fpr_D(dc, a->rs1);
182
+ ARMPACKey key)
82
src2 = gen_load_fpr_D(dc, a->rs2);
183
{
83
- gen_helper_flcmpd(cpu_fcc[a->cc], src1, src2);
184
static const uint64_t RC[5] = {
84
+ gen_helper_flcmpd(cpu_fcc[a->cc], tcg_env, src1, src2);
185
0x0000000000000000ull,
85
return advance_pc(dc);
186
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_computepac(uint64_t data, uint64_t modifier,
187
return workingval;
188
}
86
}
189
87
190
+static uint64_t pauth_computepac_impdef(uint64_t data, uint64_t modifier,
191
+ ARMPACKey key)
192
+{
193
+ return qemu_xxhash64_4(data, modifier, key.lo, key.hi);
194
+}
195
+
196
+static uint64_t pauth_computepac(CPUARMState *env, uint64_t data,
197
+ uint64_t modifier, ARMPACKey key)
198
+{
199
+ if (cpu_isar_feature(aa64_pauth_arch, env_archcpu(env))) {
200
+ return pauth_computepac_architected(data, modifier, key);
201
+ } else {
202
+ return pauth_computepac_impdef(data, modifier, key);
203
+ }
204
+}
205
+
206
static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,
207
ARMPACKey *key, bool data)
208
{
209
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier,
210
bot_bit = 64 - param.tsz;
211
ext_ptr = deposit64(ptr, bot_bit, top_bit - bot_bit, ext);
212
213
- pac = pauth_computepac(ext_ptr, modifier, *key);
214
+ pac = pauth_computepac(env, ext_ptr, modifier, *key);
215
216
/*
217
* Check if the ptr has good extension bits and corrupt the
218
@@ -XXX,XX +XXX,XX @@ static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier,
219
uint64_t pac, orig_ptr, test;
220
221
orig_ptr = pauth_original_ptr(ptr, param);
222
- pac = pauth_computepac(orig_ptr, modifier, *key);
223
+ pac = pauth_computepac(env, orig_ptr, modifier, *key);
224
bot_bit = 64 - param.tsz;
225
top_bit = 64 - 8 * param.tbi;
226
227
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(pacga)(CPUARMState *env, uint64_t x, uint64_t y)
228
uint64_t pac;
229
230
pauth_check_trap(env, arm_current_el(env), GETPC());
231
- pac = pauth_computepac(x, y, env->keys.apga);
232
+ pac = pauth_computepac(env, x, y, env->keys.apga);
233
234
return pac & 0xffffffff00000000ull;
235
}
236
--
88
--
237
2.20.1
89
2.34.1
238
239
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: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
SVE predicate operations cannot use the "usual" simd_desc
3
Now that float_status has a bunch of fp parameters,
4
encoding, because the lengths are not a multiple of 8.
4
it is easier to copy an existing structure than create
5
But we were abusing the SIMD_* fields to store values anyway.
5
one from scratch. Begin by copying the structure that
6
This abuse broke when SIMD_OPRSZ_BITS was modified in e2e7168a214.
6
corresponds to the FPSR and make only the adjustments
7
required for BFloat16 semantics.
7
8
8
Introduce a new set of field definitions for exclusive use
9
of predicates, so that it is obvious what kind of predicate
10
we are manipulating. To be used in future patches.
11
12
Cc: qemu-stable@nongnu.org
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20210113062650.593824-2-richard.henderson@linaro.org
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20241203203949.483774-2-richard.henderson@linaro.org
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
14
---
18
target/arm/internals.h | 9 +++++++++
15
target/arm/tcg/vec_helper.c | 20 +++++++-------------
19
1 file changed, 9 insertions(+)
16
1 file changed, 7 insertions(+), 13 deletions(-)
20
17
21
diff --git a/target/arm/internals.h b/target/arm/internals.h
18
diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c
22
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/internals.h
20
--- a/target/arm/tcg/vec_helper.c
24
+++ b/target/arm/internals.h
21
+++ b/target/arm/tcg/vec_helper.c
25
@@ -XXX,XX +XXX,XX @@ void arm_log_exception(int idx);
22
@@ -XXX,XX +XXX,XX @@ bool is_ebf(CPUARMState *env, float_status *statusp, float_status *oddstatusp)
26
#define LOG2_TAG_GRANULE 4
23
* no effect on AArch32 instructions.
27
#define TAG_GRANULE (1 << LOG2_TAG_GRANULE)
24
*/
28
25
bool ebf = is_a64(env) && env->vfp.fpcr & FPCR_EBF;
29
+/*
26
- *statusp = (float_status){
30
+ * SVE predicates are 1/8 the size of SVE vectors, and cannot use
27
- .tininess_before_rounding = float_tininess_before_rounding,
31
+ * the same simd_desc() encoding due to restrictions on size.
28
- .float_rounding_mode = float_round_to_odd_inf,
32
+ * Use these instead.
29
- .flush_to_zero = true,
33
+ */
30
- .flush_inputs_to_zero = true,
34
+FIELD(PREDDESC, OPRSZ, 0, 6)
31
- .default_nan_mode = true,
35
+FIELD(PREDDESC, ESZ, 6, 2)
32
- };
36
+FIELD(PREDDESC, DATA, 8, 24)
37
+
33
+
38
/*
34
+ *statusp = env->vfp.fp_status;
39
* The SVE simd_data field, for memory ops, contains either
35
+ set_default_nan_mode(true, statusp);
40
* rd (5 bits) or a shift count (2 bits).
36
37
if (ebf) {
38
- float_status *fpst = &env->vfp.fp_status;
39
- set_flush_to_zero(get_flush_to_zero(fpst), statusp);
40
- set_flush_inputs_to_zero(get_flush_inputs_to_zero(fpst), statusp);
41
- set_float_rounding_mode(get_float_rounding_mode(fpst), statusp);
42
-
43
/* EBF=1 needs to do a step with round-to-odd semantics */
44
*oddstatusp = *statusp;
45
set_float_rounding_mode(float_round_to_odd, oddstatusp);
46
+ } else {
47
+ set_flush_to_zero(true, statusp);
48
+ set_flush_inputs_to_zero(true, statusp);
49
+ set_float_rounding_mode(float_round_to_odd_inf, statusp);
50
}
51
-
52
return ebf;
53
}
54
41
--
55
--
42
2.20.1
56
2.34.1
43
57
44
58
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
Currently we hardcode the default NaN value in parts64_default_nan()
2
using a compile-time ifdef ladder. This is awkward for two cases:
3
* for single-QEMU-binary we can't hard-code target-specifics like this
4
* for Arm FEAT_AFP the default NaN value depends on FPCR.AH
5
(specifically the sign bit is different)
2
6
3
This checks if EL2 is enabled (meaning EL2 registers take effects) in
7
Add a field to float_status to specify the default NaN value; fall
4
the current security context.
8
back to the old ifdef behaviour if these are not set.
5
9
6
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
10
The default NaN value is specified by setting a uint8_t to a
11
pattern corresponding to the sign and upper fraction parts of
12
the NaN; the lower bits of the fraction are set from bit 0 of
13
the pattern.
14
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210112104511.36576-2-remi.denis.courmont@huawei.com
17
Message-id: 20241202131347.498124-35-peter.maydell@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
18
---
11
target/arm/cpu.h | 17 +++++++++++++++++
19
include/fpu/softfloat-helpers.h | 11 +++++++
12
1 file changed, 17 insertions(+)
20
include/fpu/softfloat-types.h | 10 ++++++
21
fpu/softfloat-specialize.c.inc | 55 ++++++++++++++++++++-------------
22
3 files changed, 54 insertions(+), 22 deletions(-)
13
23
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
24
diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h
15
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu.h
26
--- a/include/fpu/softfloat-helpers.h
17
+++ b/target/arm/cpu.h
27
+++ b/include/fpu/softfloat-helpers.h
18
@@ -XXX,XX +XXX,XX @@ static inline bool arm_is_secure(CPUARMState *env)
28
@@ -XXX,XX +XXX,XX @@ static inline void set_float_infzeronan_rule(FloatInfZeroNaNRule rule,
19
return arm_is_secure_below_el3(env);
29
status->float_infzeronan_rule = rule;
20
}
30
}
21
31
22
+/*
32
+static inline void set_float_default_nan_pattern(uint8_t dnan_pattern,
23
+ * Return true if the current security state has AArch64 EL2 or AArch32 Hyp.
33
+ float_status *status)
24
+ * This corresponds to the pseudocode EL2Enabled()
25
+ */
26
+static inline bool arm_is_el2_enabled(CPUARMState *env)
27
+{
34
+{
28
+ if (arm_feature(env, ARM_FEATURE_EL2)) {
35
+ status->default_nan_pattern = dnan_pattern;
29
+ return !arm_is_secure_below_el3(env);
30
+ }
31
+ return false;
32
+}
36
+}
33
+
37
+
38
static inline void set_flush_to_zero(bool val, float_status *status)
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)
46
+{
47
+ return status->default_nan_pattern;
48
+}
49
+
50
static inline bool get_flush_to_zero(float_status *status)
51
{
52
return status->flush_to_zero;
53
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
54
index XXXXXXX..XXXXXXX 100644
55
--- a/include/fpu/softfloat-types.h
56
+++ b/include/fpu/softfloat-types.h
57
@@ -XXX,XX +XXX,XX @@ typedef struct float_status {
58
/* should denormalised inputs go to zero and set the input_denormal flag? */
59
bool flush_inputs_to_zero;
60
bool default_nan_mode;
61
+ /*
62
+ * The pattern to use for the default NaN. Here the high bit specifies
63
+ * the default NaN's sign bit, and bits 6..0 specify the high bits of the
64
+ * fractional part. The low bits of the fractional part are copies of bit 0.
65
+ * The exponent of the default NaN is (as for any NaN) always all 1s.
66
+ * Note that a value of 0 here is not a valid NaN. The target must set
67
+ * this to the correct non-zero value, or we will assert when trying to
68
+ * create a default NaN.
69
+ */
70
+ uint8_t default_nan_pattern;
71
/*
72
* The flags below are not used on all specializations and may
73
* constant fold away (see snan_bit_is_one()/no_signalling_nans() in
74
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
75
index XXXXXXX..XXXXXXX 100644
76
--- a/fpu/softfloat-specialize.c.inc
77
+++ b/fpu/softfloat-specialize.c.inc
78
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
79
{
80
bool sign = 0;
81
uint64_t frac;
82
+ uint8_t dnan_pattern = status->default_nan_pattern;
83
84
+ if (dnan_pattern == 0) {
85
#if defined(TARGET_SPARC) || defined(TARGET_M68K)
86
- /* !snan_bit_is_one, set all bits */
87
- frac = (1ULL << DECOMPOSED_BINARY_POINT) - 1;
88
-#elif defined(TARGET_I386) || defined(TARGET_X86_64) \
89
+ /* Sign bit clear, all frac bits set */
90
+ dnan_pattern = 0b01111111;
91
+#elif defined(TARGET_I386) || defined(TARGET_X86_64) \
92
|| defined(TARGET_MICROBLAZE)
93
- /* !snan_bit_is_one, set sign and msb */
94
- frac = 1ULL << (DECOMPOSED_BINARY_POINT - 1);
95
- sign = 1;
96
+ /* Sign bit set, most significant frac bit set */
97
+ dnan_pattern = 0b11000000;
98
#elif defined(TARGET_HPPA)
99
- /* snan_bit_is_one, set msb-1. */
100
- frac = 1ULL << (DECOMPOSED_BINARY_POINT - 2);
101
+ /* Sign bit clear, msb-1 frac bit set */
102
+ dnan_pattern = 0b00100000;
103
#elif defined(TARGET_HEXAGON)
104
- sign = 1;
105
- frac = ~0ULL;
106
+ /* Sign bit set, all frac bits set. */
107
+ dnan_pattern = 0b11111111;
34
#else
108
#else
35
static inline bool arm_is_secure_below_el3(CPUARMState *env)
109
- /*
36
{
110
- * This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V,
37
@@ -XXX,XX +XXX,XX @@ static inline bool arm_is_secure(CPUARMState *env)
111
- * S390, SH4, TriCore, and Xtensa. Our other supported targets
38
{
112
- * do not have floating-point.
39
return false;
113
- */
40
}
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);
41
+
136
+
42
+static inline bool arm_is_el2_enabled(CPUARMState *env)
137
+ sign = dnan_pattern >> 7;
43
+{
138
+ /*
44
+ return false;
139
+ * Place default_nan_pattern [6:0] into bits [62:56],
45
+}
140
+ * and replecate bit [0] down into [55:0]
46
#endif
141
+ */
47
142
+ frac = deposit64(0, DECOMPOSED_BINARY_POINT - 7, 7, dnan_pattern);
48
/**
143
+ frac = deposit64(frac, 0, DECOMPOSED_BINARY_POINT - 7, -(dnan_pattern & 1));
144
145
*p = (FloatParts64) {
146
.cls = float_class_qnan,
49
--
147
--
50
2.20.1
148
2.34.1
51
52
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
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
Set the default NaN pattern explicitly for the arm target.
2
This includes setting it for the old linux-user nwfpe emulation.
3
For nwfpe, our default doesn't match the real kernel, but we
4
avoid making a behaviour change in this commit.
2
5
3
This adds handling for the SCR_EL3.EEL2 bit.
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20241202131347.498124-41-peter.maydell@linaro.org
9
---
10
linux-user/arm/nwfpe/fpa11.c | 5 +++++
11
target/arm/cpu.c | 2 ++
12
2 files changed, 7 insertions(+)
4
13
5
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
14
diff --git a/linux-user/arm/nwfpe/fpa11.c b/linux-user/arm/nwfpe/fpa11.c
6
Message-id: 20210112104511.36576-17-remi.denis.courmont@huawei.com
7
[PMM: Applied fixes for review issues noted by RTH:
8
- check for FEATURE_AARCH64 before checking sel2 isar feature
9
- correct the commit message subject line]
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
target/arm/cpu.h | 8 ++++++--
14
target/arm/cpu.c | 2 +-
15
target/arm/helper.c | 19 ++++++++++++++++---
16
target/arm/translate.c | 15 +++++++++++++--
17
4 files changed, 36 insertions(+), 8 deletions(-)
18
19
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
20
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/cpu.h
16
--- a/linux-user/arm/nwfpe/fpa11.c
22
+++ b/target/arm/cpu.h
17
+++ b/linux-user/arm/nwfpe/fpa11.c
23
@@ -XXX,XX +XXX,XX @@ static inline bool arm_is_secure(CPUARMState *env)
18
@@ -XXX,XX +XXX,XX @@ void resetFPA11(void)
24
static inline bool arm_is_el2_enabled(CPUARMState *env)
19
* this late date.
25
{
20
*/
26
if (arm_feature(env, ARM_FEATURE_EL2)) {
21
set_float_2nan_prop_rule(float_2nan_prop_s_ab, &fpa11->fp_status);
27
- return !arm_is_secure_below_el3(env);
22
+ /*
28
+ if (arm_is_secure_below_el3(env)) {
23
+ * Use the same default NaN value as Arm VFP. This doesn't match
29
+ return (env->cp15.scr_el3 & SCR_EEL2) != 0;
24
+ * the Linux kernel's nwfpe emulation, which uses an all-1s value.
30
+ }
25
+ */
31
+ return true;
26
+ set_float_default_nan_pattern(0b01000000, &fpa11->fp_status);
32
}
33
return false;
34
}
27
}
35
@@ -XXX,XX +XXX,XX @@ static inline bool arm_el_is_aa64(CPUARMState *env, int el)
28
36
return aa64;
29
void SetRoundingMode(const unsigned int opcode)
37
}
38
39
- if (arm_feature(env, ARM_FEATURE_EL3)) {
40
+ if (arm_feature(env, ARM_FEATURE_EL3) &&
41
+ ((env->cp15.scr_el3 & SCR_NS) || !(env->cp15.scr_el3 & SCR_EEL2))) {
42
aa64 = aa64 && (env->cp15.scr_el3 & SCR_RW);
43
}
44
45
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
30
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
46
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
47
--- a/target/arm/cpu.c
32
--- a/target/arm/cpu.c
48
+++ b/target/arm/cpu.c
33
+++ b/target/arm/cpu.c
49
@@ -XXX,XX +XXX,XX @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,
34
@@ -XXX,XX +XXX,XX @@ void arm_register_el_change_hook(ARMCPU *cpu, ARMELChangeHookFn *hook,
50
* masked from Secure state. The HCR and SCR settings
35
* the pseudocode function the arguments are in the order c, a, b.
51
* don't affect the masking logic, only the interrupt routing.
36
* * 0 * Inf + NaN returns the default NaN if the input NaN is quiet,
52
*/
37
* and the input NaN if it is signalling
53
- if (target_el == 3 || !secure) {
38
+ * * Default NaN has sign bit clear, msb frac bit set
54
+ if (target_el == 3 || !secure || (env->cp15.scr_el3 & SCR_EEL2)) {
39
*/
55
unmasked = true;
40
static void arm_set_default_fp_behaviours(float_status *s)
56
}
57
} else {
58
diff --git a/target/arm/helper.c b/target/arm/helper.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/target/arm/helper.c
61
+++ b/target/arm/helper.c
62
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_trap_aa32s_el1(CPUARMState *env,
63
return CP_ACCESS_OK;
64
}
65
if (arm_is_secure_below_el3(env)) {
66
+ if (env->cp15.scr_el3 & SCR_EEL2) {
67
+ return CP_ACCESS_TRAP_EL2;
68
+ }
69
return CP_ACCESS_TRAP_EL3;
70
}
71
/* This will be EL1 NS and EL2 NS, which just UNDEF */
72
@@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
73
if (cpu_isar_feature(aa64_pauth, cpu)) {
74
valid_mask |= SCR_API | SCR_APK;
75
}
76
+ if (cpu_isar_feature(aa64_sel2, cpu)) {
77
+ valid_mask |= SCR_EEL2;
78
+ }
79
if (cpu_isar_feature(aa64_mte, cpu)) {
80
valid_mask |= SCR_ATA;
81
}
82
@@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri,
83
bool isread)
84
{
41
{
85
if (ri->opc2 & 4) {
42
@@ -XXX,XX +XXX,XX @@ static void arm_set_default_fp_behaviours(float_status *s)
86
- /* The ATS12NSO* operations must trap to EL3 if executed in
43
set_float_2nan_prop_rule(float_2nan_prop_s_ab, s);
87
+ /* The ATS12NSO* operations must trap to EL3 or EL2 if executed in
44
set_float_3nan_prop_rule(float_3nan_prop_s_cab, s);
88
* Secure EL1 (which can only happen if EL3 is AArch64).
45
set_float_infzeronan_rule(float_infzeronan_dnan_if_qnan, s);
89
* They are simply UNDEF if executed from NS EL1.
46
+ set_float_default_nan_pattern(0b01000000, s);
90
* They function normally from EL2 or EL3.
47
}
91
*/
48
92
if (arm_current_el(env) == 1) {
49
static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)
93
if (arm_is_secure_below_el3(env)) {
94
+ if (env->cp15.scr_el3 & SCR_EEL2) {
95
+ return CP_ACCESS_TRAP_UNCATEGORIZED_EL2;
96
+ }
97
return CP_ACCESS_TRAP_UNCATEGORIZED_EL3;
98
}
99
return CP_ACCESS_TRAP_UNCATEGORIZED;
100
@@ -XXX,XX +XXX,XX @@ static void ats1h_write(CPUARMState *env, const ARMCPRegInfo *ri,
101
static CPAccessResult at_s1e2_access(CPUARMState *env, const ARMCPRegInfo *ri,
102
bool isread)
103
{
104
- if (arm_current_el(env) == 3 && !(env->cp15.scr_el3 & SCR_NS)) {
105
+ if (arm_current_el(env) == 3 &&
106
+ !(env->cp15.scr_el3 & (SCR_NS | SCR_EEL2))) {
107
return CP_ACCESS_TRAP;
108
}
109
return CP_ACCESS_OK;
110
@@ -XXX,XX +XXX,XX @@ static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
111
bool isread)
112
{
113
/* The NSACR is RW at EL3, and RO for NS EL1 and NS EL2.
114
- * At Secure EL1 it traps to EL3.
115
+ * At Secure EL1 it traps to EL3 or EL2.
116
*/
117
if (arm_current_el(env) == 3) {
118
return CP_ACCESS_OK;
119
}
120
if (arm_is_secure_below_el3(env)) {
121
+ if (env->cp15.scr_el3 & SCR_EEL2) {
122
+ return CP_ACCESS_TRAP_EL2;
123
+ }
124
return CP_ACCESS_TRAP_EL3;
125
}
126
/* Accesses from EL1 NS and EL2 NS are UNDEF for write but allow reads. */
127
diff --git a/target/arm/translate.c b/target/arm/translate.c
128
index XXXXXXX..XXXXXXX 100644
129
--- a/target/arm/translate.c
130
+++ b/target/arm/translate.c
131
@@ -XXX,XX +XXX,XX @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn,
132
}
133
if (s->current_el == 1) {
134
/* If we're in Secure EL1 (which implies that EL3 is AArch64)
135
- * then accesses to Mon registers trap to EL3
136
+ * then accesses to Mon registers trap to Secure EL2, if it exists,
137
+ * otherwise EL3.
138
*/
139
- TCGv_i32 tcg_el = tcg_const_i32(3);
140
+ TCGv_i32 tcg_el;
141
+
142
+ if (arm_dc_feature(s, ARM_FEATURE_AARCH64) &&
143
+ dc_isar_feature(aa64_sel2, s)) {
144
+ /* Target EL is EL<3 minus SCR_EL3.EEL2> */
145
+ tcg_el = load_cpu_field(cp15.scr_el3);
146
+ tcg_gen_sextract_i32(tcg_el, tcg_el, ctz32(SCR_EEL2), 1);
147
+ tcg_gen_addi_i32(tcg_el, tcg_el, 3);
148
+ } else {
149
+ tcg_el = tcg_const_i32(3);
150
+ }
151
152
gen_exception_el(s, EXCP_UDEF, syn_uncategorized(), tcg_el);
153
tcg_temp_free_i32(tcg_el);
154
--
50
--
155
2.20.1
51
2.34.1
156
157
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for loongarch.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-42-peter.maydell@linaro.org
6
---
7
target/loongarch/tcg/fpu_helper.c | 2 ++
8
1 file changed, 2 insertions(+)
9
10
diff --git a/target/loongarch/tcg/fpu_helper.c b/target/loongarch/tcg/fpu_helper.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/target/loongarch/tcg/fpu_helper.c
13
+++ b/target/loongarch/tcg/fpu_helper.c
14
@@ -XXX,XX +XXX,XX @@ void restore_fp_status(CPULoongArchState *env)
15
*/
16
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
17
set_float_3nan_prop_rule(float_3nan_prop_s_cab, &env->fp_status);
18
+ /* Default NaN: sign bit clear, msb frac bit set */
19
+ set_float_default_nan_pattern(0b01000000, &env->fp_status);
20
}
21
22
int ieee_ex_to_loongarch(int xcpt)
23
--
24
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for m68k.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-43-peter.maydell@linaro.org
6
---
7
target/m68k/cpu.c | 2 ++
8
fpu/softfloat-specialize.c.inc | 2 +-
9
2 files changed, 3 insertions(+), 1 deletion(-)
10
11
diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/m68k/cpu.c
14
+++ b/target/m68k/cpu.c
15
@@ -XXX,XX +XXX,XX @@ static void m68k_cpu_reset_hold(Object *obj, ResetType type)
16
* preceding paragraph for nonsignaling NaNs.
17
*/
18
set_float_2nan_prop_rule(float_2nan_prop_ab, &env->fp_status);
19
+ /* Default NaN: sign bit clear, all frac bits set */
20
+ set_float_default_nan_pattern(0b01111111, &env->fp_status);
21
22
nan = floatx80_default_nan(&env->fp_status);
23
for (i = 0; i < 8; i++) {
24
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
25
index XXXXXXX..XXXXXXX 100644
26
--- a/fpu/softfloat-specialize.c.inc
27
+++ b/fpu/softfloat-specialize.c.inc
28
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
29
uint8_t dnan_pattern = status->default_nan_pattern;
30
31
if (dnan_pattern == 0) {
32
-#if defined(TARGET_SPARC) || defined(TARGET_M68K)
33
+#if defined(TARGET_SPARC)
34
/* Sign bit clear, all frac bits set */
35
dnan_pattern = 0b01111111;
36
#elif defined(TARGET_HEXAGON)
37
--
38
2.34.1
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
Set the default NaN pattern explicitly for MIPS. Note that this
2
is our only target which currently changes the default NaN
3
at runtime (which it was previously doing indirectly when it
4
changed the snan_bit_is_one setting).
2
5
3
The VTTBR write callback so far assumes that the underlying VM lies in
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
non-secure state. This handles the secure state scenario.
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20241202131347.498124-44-peter.maydell@linaro.org
9
---
10
target/mips/fpu_helper.h | 7 +++++++
11
target/mips/msa.c | 3 +++
12
2 files changed, 10 insertions(+)
5
13
6
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
14
diff --git a/target/mips/fpu_helper.h b/target/mips/fpu_helper.h
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210112104511.36576-10-remi.denis.courmont@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/helper.c | 13 +++++++++----
12
1 file changed, 9 insertions(+), 4 deletions(-)
13
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
16
--- a/target/mips/fpu_helper.h
17
+++ b/target/arm/helper.c
17
+++ b/target/mips/fpu_helper.h
18
@@ -XXX,XX +XXX,XX @@ static void vttbr_write(CPUARMState *env, const ARMCPRegInfo *ri,
18
@@ -XXX,XX +XXX,XX @@ static inline void restore_snan_bit_mode(CPUMIPSState *env)
19
* the combined stage 1&2 tlbs (EL10_1 and EL10_0).
19
set_float_infzeronan_rule(izn_rule, &env->active_fpu.fp_status);
20
*/
20
nan3_rule = nan2008 ? float_3nan_prop_s_cab : float_3nan_prop_s_abc;
21
if (raw_read(env, ri) != value) {
21
set_float_3nan_prop_rule(nan3_rule, &env->active_fpu.fp_status);
22
- tlb_flush_by_mmuidx(cs,
22
+ /*
23
- ARMMMUIdxBit_E10_1 |
23
+ * With nan2008, the default NaN value has the sign bit clear and the
24
- ARMMMUIdxBit_E10_1_PAN |
24
+ * frac msb set; with the older mode, the sign bit is clear, and all
25
- ARMMMUIdxBit_E10_0);
25
+ * frac bits except the msb are set.
26
+ uint16_t mask = ARMMMUIdxBit_E10_1 |
26
+ */
27
+ ARMMMUIdxBit_E10_1_PAN |
27
+ set_float_default_nan_pattern(nan2008 ? 0b01000000 : 0b00111111,
28
+ ARMMMUIdxBit_E10_0;
28
+ &env->active_fpu.fp_status);
29
+
29
30
+ if (arm_is_secure_below_el3(env)) {
30
}
31
+ mask >>= ARM_MMU_IDX_A_NS;
31
32
+ }
32
diff --git a/target/mips/msa.c b/target/mips/msa.c
33
+
33
index XXXXXXX..XXXXXXX 100644
34
+ tlb_flush_by_mmuidx(cs, mask);
34
--- a/target/mips/msa.c
35
raw_write(env, ri, value);
35
+++ b/target/mips/msa.c
36
}
36
@@ -XXX,XX +XXX,XX @@ void msa_reset(CPUMIPSState *env)
37
/* Inf * 0 + NaN returns the input NaN */
38
set_float_infzeronan_rule(float_infzeronan_dnan_never,
39
&env->active_tc.msa_fp_status);
40
+ /* Default NaN: sign bit clear, frac msb set */
41
+ set_float_default_nan_pattern(0b01000000,
42
+ &env->active_tc.msa_fp_status);
37
}
43
}
38
--
44
--
39
2.20.1
45
2.34.1
40
41
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for openrisc.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-45-peter.maydell@linaro.org
6
---
7
target/openrisc/cpu.c | 2 ++
8
1 file changed, 2 insertions(+)
9
10
diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/target/openrisc/cpu.c
13
+++ b/target/openrisc/cpu.c
14
@@ -XXX,XX +XXX,XX @@ static void openrisc_cpu_reset_hold(Object *obj, ResetType type)
15
*/
16
set_float_2nan_prop_rule(float_2nan_prop_x87, &cpu->env.fp_status);
17
18
+ /* Default NaN: sign bit clear, frac msb set */
19
+ set_float_default_nan_pattern(0b01000000, &cpu->env.fp_status);
20
21
#ifndef CONFIG_USER_ONLY
22
cpu->env.picmr = 0x00000000;
23
--
24
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for ppc.
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-46-peter.maydell@linaro.org
6
---
7
target/ppc/cpu_init.c | 4 ++++
8
1 file changed, 4 insertions(+)
9
10
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/target/ppc/cpu_init.c
13
+++ b/target/ppc/cpu_init.c
14
@@ -XXX,XX +XXX,XX @@ static void ppc_cpu_reset_hold(Object *obj, ResetType type)
15
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
16
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->vec_status);
17
18
+ /* Default NaN: sign bit clear, set frac msb */
19
+ set_float_default_nan_pattern(0b01000000, &env->fp_status);
20
+ set_float_default_nan_pattern(0b01000000, &env->vec_status);
21
+
22
for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) {
23
ppc_spr_t *spr = &env->spr_cb[i];
24
25
--
26
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for sh4. Note that sh4
2
is one of the only three targets (the others being HPPA and
3
sometimes MIPS) that has snan_bit_is_one set.
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-47-peter.maydell@linaro.org
8
---
9
target/sh4/cpu.c | 2 ++
10
1 file changed, 2 insertions(+)
11
12
diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/target/sh4/cpu.c
15
+++ b/target/sh4/cpu.c
16
@@ -XXX,XX +XXX,XX @@ static void superh_cpu_reset_hold(Object *obj, ResetType type)
17
set_flush_to_zero(1, &env->fp_status);
18
#endif
19
set_default_nan_mode(1, &env->fp_status);
20
+ /* sign bit clear, set all frac bits other than msb */
21
+ set_float_default_nan_pattern(0b00111111, &env->fp_status);
22
}
23
24
static void superh_cpu_disas_set_info(CPUState *cpu, disassemble_info *info)
25
--
26
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for rx.
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-48-peter.maydell@linaro.org
6
---
7
target/rx/cpu.c | 2 ++
8
1 file changed, 2 insertions(+)
9
10
diff --git a/target/rx/cpu.c b/target/rx/cpu.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/target/rx/cpu.c
13
+++ b/target/rx/cpu.c
14
@@ -XXX,XX +XXX,XX @@ static void rx_cpu_reset_hold(Object *obj, ResetType type)
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);
20
}
21
22
static ObjectClass *rx_cpu_class_by_name(const char *cpu_model)
23
--
24
2.34.1
diff view generated by jsdifflib
New patch
1
Set the default NaN pattern explicitly for s390x.
1
2
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-49-peter.maydell@linaro.org
6
---
7
target/s390x/cpu.c | 2 ++
8
1 file changed, 2 insertions(+)
9
10
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/target/s390x/cpu.c
13
+++ b/target/s390x/cpu.c
14
@@ -XXX,XX +XXX,XX @@ static void s390_cpu_reset_hold(Object *obj, ResetType type)
15
set_float_3nan_prop_rule(float_3nan_prop_s_abc, &env->fpu_status);
16
set_float_infzeronan_rule(float_infzeronan_dnan_always,
17
&env->fpu_status);
18
+ /* Default NaN value: sign bit clear, frac msb set */
19
+ set_float_default_nan_pattern(0b01000000, &env->fpu_status);
20
/* fall through */
21
case RESET_TYPE_S390_CPU_NORMAL:
22
env->psw.mask &= ~PSW_MASK_RI;
23
--
24
2.34.1
diff view generated by jsdifflib
1
When we first converted our documentation to Sphinx, we split it into
1
Set the default NaN pattern explicitly for SPARC, and remove
2
multiple manuals (system, interop, tools, etc), which are all built
2
the ifdef from parts64_default_nan.
3
separately. The primary driver for this was wanting to be able to
4
avoid shipping the 'devel' manual to end-users. However, this is
5
working against the grain of the way Sphinx wants to be used and
6
causes some annoyances:
7
* Cross-references between documents become much harder or
8
possibly impossible
9
* There is no single index to the whole documentation
10
* Within one manual there's no links or table-of-contents info
11
that lets you easily navigate to the others
12
* The devel manual doesn't get published on the QEMU website
13
(it would be nice to able to refer to it there)
14
15
Merely hiding our developer documentation from end users seems like
16
it's not enough benefit for these costs. Combine all the
17
documentation into a single manual (the same way that the readthedocs
18
site builds it) and install the whole thing. The previous manual
19
divisions remain as the new top level sections in the manual.
20
21
* The per-manual conf.py files are no longer needed
22
* The man_pages[] specifications previously in each per-manual
23
conf.py move to the top level conf.py
24
* docs/meson.build logic is simplified as we now only need to run
25
Sphinx once for the HTML and then once for the manpages5B
26
* The old index.html.in that produced the top-level page with
27
links to each manual is no longer needed
28
29
Unfortunately this means that we now have to build the HTML
30
documentation into docs/manual in the build tree rather than directly
31
into docs/; otherwise it is too awkward to ensure we install only the
32
built manual and not also the dependency info, stamp file, etc. The
33
manual still ends up in the same place in the final installed
34
directory, but anybody who was consulting documentation from within
35
the build tree will have to adjust where they're looking.
36
3
37
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
38
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
39
Message-id: 20210115154449.4801-1-peter.maydell@linaro.org
6
Message-id: 20241202131347.498124-50-peter.maydell@linaro.org
40
---
7
---
41
docs/conf.py | 46 ++++++++++++++++++++++++++++++-
8
target/sparc/cpu.c | 2 ++
42
docs/devel/conf.py | 15 -----------
9
fpu/softfloat-specialize.c.inc | 5 +----
43
docs/index.html.in | 17 ------------
10
2 files changed, 3 insertions(+), 4 deletions(-)
44
docs/interop/conf.py | 28 -------------------
45
docs/meson.build | 64 +++++++++++++++++---------------------------
46
docs/specs/conf.py | 16 -----------
47
docs/system/conf.py | 28 -------------------
48
docs/tools/conf.py | 37 -------------------------
49
docs/user/conf.py | 15 -----------
50
.gitlab-ci.yml | 4 +--
51
10 files changed, 72 insertions(+), 198 deletions(-)
52
delete mode 100644 docs/devel/conf.py
53
delete mode 100644 docs/index.html.in
54
delete mode 100644 docs/interop/conf.py
55
delete mode 100644 docs/specs/conf.py
56
delete mode 100644 docs/system/conf.py
57
delete mode 100644 docs/tools/conf.py
58
delete mode 100644 docs/user/conf.py
59
11
60
diff --git a/docs/conf.py b/docs/conf.py
12
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
61
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
62
--- a/docs/conf.py
14
--- a/target/sparc/cpu.c
63
+++ b/docs/conf.py
15
+++ b/target/sparc/cpu.c
64
@@ -XXX,XX +XXX,XX @@ latex_documents = [
16
@@ -XXX,XX +XXX,XX @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
65
17
set_float_3nan_prop_rule(float_3nan_prop_s_cba, &env->fp_status);
66
# -- Options for manual page output ---------------------------------------
18
/* For inf * 0 + NaN, return the input NaN */
67
# Individual manual/conf.py can override this to create man pages
19
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
68
-man_pages = []
20
+ /* Default NaN value: sign bit clear, all frac bits set */
69
+man_pages = [
21
+ set_float_default_nan_pattern(0b01111111, &env->fp_status);
70
+ ('interop/qemu-ga', 'qemu-ga',
22
71
+ 'QEMU Guest Agent',
23
cpu_exec_realizefn(cs, &local_err);
72
+ ['Michael Roth <mdroth@linux.vnet.ibm.com>'], 8),
24
if (local_err != NULL) {
73
+ ('interop/qemu-ga-ref', 'qemu-ga-ref',
25
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
74
+ 'QEMU Guest Agent Protocol Reference',
75
+ [], 7),
76
+ ('interop/qemu-qmp-ref', 'qemu-qmp-ref',
77
+ 'QEMU QMP Reference Manual',
78
+ [], 7),
79
+ ('interop/qemu-storage-daemon-qmp-ref', 'qemu-storage-daemon-qmp-ref',
80
+ 'QEMU Storage Daemon QMP Reference Manual',
81
+ [], 7),
82
+ ('system/qemu-manpage', 'qemu',
83
+ 'QEMU User Documentation',
84
+ ['Fabrice Bellard'], 1),
85
+ ('system/qemu-block-drivers', 'qemu-block-drivers',
86
+ 'QEMU block drivers reference',
87
+ ['Fabrice Bellard and the QEMU Project developers'], 7),
88
+ ('system/qemu-cpu-models', 'qemu-cpu-models',
89
+ 'QEMU CPU Models',
90
+ ['The QEMU Project developers'], 7),
91
+ ('tools/qemu-img', 'qemu-img',
92
+ 'QEMU disk image utility',
93
+ ['Fabrice Bellard'], 1),
94
+ ('tools/qemu-nbd', 'qemu-nbd',
95
+ 'QEMU Disk Network Block Device Server',
96
+ ['Anthony Liguori <anthony@codemonkey.ws>'], 8),
97
+ ('tools/qemu-pr-helper', 'qemu-pr-helper',
98
+ 'QEMU persistent reservation helper',
99
+ [], 8),
100
+ ('tools/qemu-storage-daemon', 'qemu-storage-daemon',
101
+ 'QEMU storage daemon',
102
+ [], 1),
103
+ ('tools/qemu-trace-stap', 'qemu-trace-stap',
104
+ 'QEMU SystemTap trace tool',
105
+ [], 1),
106
+ ('tools/virtfs-proxy-helper', 'virtfs-proxy-helper',
107
+ 'QEMU 9p virtfs proxy filesystem helper',
108
+ ['M. Mohan Kumar'], 1),
109
+ ('tools/virtiofsd', 'virtiofsd',
110
+ 'QEMU virtio-fs shared file system daemon',
111
+ ['Stefan Hajnoczi <stefanha@redhat.com>',
112
+ 'Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>'], 1),
113
+]
114
115
# -- Options for Texinfo output -------------------------------------------
116
117
diff --git a/docs/devel/conf.py b/docs/devel/conf.py
118
deleted file mode 100644
119
index XXXXXXX..XXXXXXX
120
--- a/docs/devel/conf.py
121
+++ /dev/null
122
@@ -XXX,XX +XXX,XX @@
123
-# -*- coding: utf-8 -*-
124
-#
125
-# QEMU documentation build configuration file for the 'devel' manual.
126
-#
127
-# This includes the top level conf file and then makes any necessary tweaks.
128
-import sys
129
-import os
130
-
131
-qemu_docdir = os.path.abspath("..")
132
-parent_config = os.path.join(qemu_docdir, "conf.py")
133
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
134
-
135
-# This slightly misuses the 'description', but is the best way to get
136
-# the manual title to appear in the sidebar.
137
-html_theme_options['description'] = u'Developer''s Guide'
138
diff --git a/docs/index.html.in b/docs/index.html.in
139
deleted file mode 100644
140
index XXXXXXX..XXXXXXX
141
--- a/docs/index.html.in
142
+++ /dev/null
143
@@ -XXX,XX +XXX,XX @@
144
-<!DOCTYPE html>
145
-<html lang="en">
146
- <head>
147
- <meta charset="UTF-8">
148
- <title>QEMU @VERSION@ Documentation</title>
149
- </head>
150
- <body>
151
- <h1>QEMU @VERSION@ Documentation</h1>
152
- <ul>
153
- <li><a href="system/index.html">System Emulation User's Guide</a></li>
154
- <li><a href="user/index.html">User Mode Emulation User's Guide</a></li>
155
- <li><a href="tools/index.html">Tools Guide</a></li>
156
- <li><a href="interop/index.html">System Emulation Management and Interoperability Guide</a></li>
157
- <li><a href="specs/index.html">System Emulation Guest Hardware Specifications</a></li>
158
- </ul>
159
- </body>
160
-</html>
161
diff --git a/docs/interop/conf.py b/docs/interop/conf.py
162
deleted file mode 100644
163
index XXXXXXX..XXXXXXX
164
--- a/docs/interop/conf.py
165
+++ /dev/null
166
@@ -XXX,XX +XXX,XX @@
167
-# -*- coding: utf-8 -*-
168
-#
169
-# QEMU documentation build configuration file for the 'interop' manual.
170
-#
171
-# This includes the top level conf file and then makes any necessary tweaks.
172
-import sys
173
-import os
174
-
175
-qemu_docdir = os.path.abspath("..")
176
-parent_config = os.path.join(qemu_docdir, "conf.py")
177
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
178
-
179
-# This slightly misuses the 'description', but is the best way to get
180
-# the manual title to appear in the sidebar.
181
-html_theme_options['description'] = u'System Emulation Management and Interoperability Guide'
182
-
183
-# One entry per manual page. List of tuples
184
-# (source start file, name, description, authors, manual section).
185
-man_pages = [
186
- ('qemu-ga', 'qemu-ga', u'QEMU Guest Agent',
187
- ['Michael Roth <mdroth@linux.vnet.ibm.com>'], 8),
188
- ('qemu-ga-ref', 'qemu-ga-ref', 'QEMU Guest Agent Protocol Reference',
189
- [], 7),
190
- ('qemu-qmp-ref', 'qemu-qmp-ref', 'QEMU QMP Reference Manual',
191
- [], 7),
192
- ('qemu-storage-daemon-qmp-ref', 'qemu-storage-daemon-qmp-ref',
193
- 'QEMU Storage Daemon QMP Reference Manual', [], 7),
194
-]
195
diff --git a/docs/meson.build b/docs/meson.build
196
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
197
--- a/docs/meson.build
27
--- a/fpu/softfloat-specialize.c.inc
198
+++ b/docs/meson.build
28
+++ b/fpu/softfloat-specialize.c.inc
199
@@ -XXX,XX +XXX,XX @@ if build_docs
29
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
200
meson.source_root() / 'docs/sphinx/qmp_lexer.py',
30
uint8_t dnan_pattern = status->default_nan_pattern;
201
qapi_gen_depends ]
31
202
32
if (dnan_pattern == 0) {
203
- configure_file(output: 'index.html',
33
-#if defined(TARGET_SPARC)
204
- input: files('index.html.in'),
34
- /* Sign bit clear, all frac bits set */
205
- configuration: {'VERSION': meson.project_version()},
35
- dnan_pattern = 0b01111111;
206
- install_dir: qemu_docdir)
36
-#elif defined(TARGET_HEXAGON)
207
- manuals = [ 'devel', 'interop', 'tools', 'specs', 'system', 'user' ]
37
+#if defined(TARGET_HEXAGON)
208
man_pages = {
38
/* Sign bit set, all frac bits set. */
209
- 'interop' : {
39
dnan_pattern = 0b11111111;
210
'qemu-ga.8': (have_tools ? 'man8' : ''),
40
#else
211
'qemu-ga-ref.7': 'man7',
212
'qemu-qmp-ref.7': 'man7',
213
'qemu-storage-daemon-qmp-ref.7': (have_tools ? 'man7' : ''),
214
- },
215
- 'tools': {
216
'qemu-img.1': (have_tools ? 'man1' : ''),
217
'qemu-nbd.8': (have_tools ? 'man8' : ''),
218
'qemu-pr-helper.8': (have_tools ? 'man8' : ''),
219
@@ -XXX,XX +XXX,XX @@ if build_docs
220
'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''),
221
'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''),
222
'virtiofsd.1': (have_virtiofsd ? 'man1' : ''),
223
- },
224
- 'system': {
225
'qemu.1': 'man1',
226
'qemu-block-drivers.7': 'man7',
227
'qemu-cpu-models.7': 'man7'
228
- },
229
}
230
231
sphinxdocs = []
232
sphinxmans = []
233
- foreach manual : manuals
234
- private_dir = meson.current_build_dir() / (manual + '.p')
235
- output_dir = meson.current_build_dir() / manual
236
- input_dir = meson.current_source_dir() / manual
237
238
- this_manual = custom_target(manual + ' manual',
239
+ private_dir = meson.current_build_dir() / 'manual.p'
240
+ output_dir = meson.current_build_dir() / 'manual'
241
+ input_dir = meson.current_source_dir()
242
+
243
+ this_manual = custom_target('QEMU manual',
244
build_by_default: build_docs,
245
- output: [manual + '.stamp'],
246
- input: [files('conf.py'), files(manual / 'conf.py')],
247
- depfile: manual + '.d',
248
+ output: 'docs.stamp',
249
+ input: files('conf.py'),
250
+ depfile: 'docs.d',
251
depend_files: sphinx_extn_depends,
252
command: [SPHINX_ARGS, '-Ddepfile=@DEPFILE@',
253
'-Ddepfile_stamp=@OUTPUT0@',
254
'-b', 'html', '-d', private_dir,
255
input_dir, output_dir])
256
- sphinxdocs += this_manual
257
- if build_docs and manual != 'devel'
258
- install_subdir(output_dir, install_dir: qemu_docdir)
259
- endif
260
+ sphinxdocs += this_manual
261
+ install_subdir(output_dir, install_dir: qemu_docdir, strip_directory: true)
262
263
- these_man_pages = []
264
- install_dirs = []
265
- foreach page, section : man_pages.get(manual, {})
266
- these_man_pages += page
267
- install_dirs += section == '' ? false : get_option('mandir') / section
268
- endforeach
269
- if these_man_pages.length() > 0
270
- sphinxmans += custom_target(manual + ' man pages',
271
- build_by_default: build_docs,
272
- output: these_man_pages,
273
- input: this_manual,
274
- install: build_docs,
275
- install_dir: install_dirs,
276
- command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
277
- input_dir, meson.current_build_dir()])
278
- endif
279
+ these_man_pages = []
280
+ install_dirs = []
281
+ foreach page, section : man_pages
282
+ these_man_pages += page
283
+ install_dirs += section == '' ? false : get_option('mandir') / section
284
endforeach
285
+
286
+ sphinxmans += custom_target('QEMU man pages',
287
+ build_by_default: build_docs,
288
+ output: these_man_pages,
289
+ input: this_manual,
290
+ install: build_docs,
291
+ install_dir: install_dirs,
292
+ command: [SPHINX_ARGS, '-b', 'man', '-d', private_dir,
293
+ input_dir, meson.current_build_dir()])
294
+
295
alias_target('sphinxdocs', sphinxdocs)
296
alias_target('html', sphinxdocs)
297
alias_target('man', sphinxmans)
298
diff --git a/docs/specs/conf.py b/docs/specs/conf.py
299
deleted file mode 100644
300
index XXXXXXX..XXXXXXX
301
--- a/docs/specs/conf.py
302
+++ /dev/null
303
@@ -XXX,XX +XXX,XX @@
304
-# -*- coding: utf-8 -*-
305
-#
306
-# QEMU documentation build configuration file for the 'specs' manual.
307
-#
308
-# This includes the top level conf file and then makes any necessary tweaks.
309
-import sys
310
-import os
311
-
312
-qemu_docdir = os.path.abspath("..")
313
-parent_config = os.path.join(qemu_docdir, "conf.py")
314
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
315
-
316
-# This slightly misuses the 'description', but is the best way to get
317
-# the manual title to appear in the sidebar.
318
-html_theme_options['description'] = \
319
- u'System Emulation Guest Hardware Specifications'
320
diff --git a/docs/system/conf.py b/docs/system/conf.py
321
deleted file mode 100644
322
index XXXXXXX..XXXXXXX
323
--- a/docs/system/conf.py
324
+++ /dev/null
325
@@ -XXX,XX +XXX,XX @@
326
-# -*- coding: utf-8 -*-
327
-#
328
-# QEMU documentation build configuration file for the 'system' manual.
329
-#
330
-# This includes the top level conf file and then makes any necessary tweaks.
331
-import sys
332
-import os
333
-
334
-qemu_docdir = os.path.abspath("..")
335
-parent_config = os.path.join(qemu_docdir, "conf.py")
336
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
337
-
338
-# This slightly misuses the 'description', but is the best way to get
339
-# the manual title to appear in the sidebar.
340
-html_theme_options['description'] = u'System Emulation User''s Guide'
341
-
342
-# One entry per manual page. List of tuples
343
-# (source start file, name, description, authors, manual section).
344
-man_pages = [
345
- ('qemu-manpage', 'qemu', u'QEMU User Documentation',
346
- ['Fabrice Bellard'], 1),
347
- ('qemu-block-drivers', 'qemu-block-drivers',
348
- u'QEMU block drivers reference',
349
- ['Fabrice Bellard and the QEMU Project developers'], 7),
350
- ('qemu-cpu-models', 'qemu-cpu-models',
351
- u'QEMU CPU Models',
352
- ['The QEMU Project developers'], 7)
353
-]
354
diff --git a/docs/tools/conf.py b/docs/tools/conf.py
355
deleted file mode 100644
356
index XXXXXXX..XXXXXXX
357
--- a/docs/tools/conf.py
358
+++ /dev/null
359
@@ -XXX,XX +XXX,XX @@
360
-# -*- coding: utf-8 -*-
361
-#
362
-# QEMU documentation build configuration file for the 'tools' manual.
363
-#
364
-# This includes the top level conf file and then makes any necessary tweaks.
365
-import sys
366
-import os
367
-
368
-qemu_docdir = os.path.abspath("..")
369
-parent_config = os.path.join(qemu_docdir, "conf.py")
370
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
371
-
372
-# This slightly misuses the 'description', but is the best way to get
373
-# the manual title to appear in the sidebar.
374
-html_theme_options['description'] = \
375
- u'Tools Guide'
376
-
377
-# One entry per manual page. List of tuples
378
-# (source start file, name, description, authors, manual section).
379
-man_pages = [
380
- ('qemu-img', 'qemu-img', u'QEMU disk image utility',
381
- ['Fabrice Bellard'], 1),
382
- ('qemu-storage-daemon', 'qemu-storage-daemon', u'QEMU storage daemon',
383
- [], 1),
384
- ('qemu-nbd', 'qemu-nbd', u'QEMU Disk Network Block Device Server',
385
- ['Anthony Liguori <anthony@codemonkey.ws>'], 8),
386
- ('qemu-pr-helper', 'qemu-pr-helper', 'QEMU persistent reservation helper',
387
- [], 8),
388
- ('qemu-trace-stap', 'qemu-trace-stap', u'QEMU SystemTap trace tool',
389
- [], 1),
390
- ('virtfs-proxy-helper', 'virtfs-proxy-helper',
391
- u'QEMU 9p virtfs proxy filesystem helper',
392
- ['M. Mohan Kumar'], 1),
393
- ('virtiofsd', 'virtiofsd', u'QEMU virtio-fs shared file system daemon',
394
- ['Stefan Hajnoczi <stefanha@redhat.com>',
395
- 'Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>'], 1),
396
-]
397
diff --git a/docs/user/conf.py b/docs/user/conf.py
398
deleted file mode 100644
399
index XXXXXXX..XXXXXXX
400
--- a/docs/user/conf.py
401
+++ /dev/null
402
@@ -XXX,XX +XXX,XX @@
403
-# -*- coding: utf-8 -*-
404
-#
405
-# QEMU documentation build configuration file for the 'user' manual.
406
-#
407
-# This includes the top level conf file and then makes any necessary tweaks.
408
-import sys
409
-import os
410
-
411
-qemu_docdir = os.path.abspath("..")
412
-parent_config = os.path.join(qemu_docdir, "conf.py")
413
-exec(compile(open(parent_config, "rb").read(), parent_config, 'exec'))
414
-
415
-# This slightly misuses the 'description', but is the best way to get
416
-# the manual title to appear in the sidebar.
417
-html_theme_options['description'] = u'User Mode Emulation User''s Guide'
418
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
419
index XXXXXXX..XXXXXXX 100644
420
--- a/.gitlab-ci.yml
421
+++ b/.gitlab-ci.yml
422
@@ -XXX,XX +XXX,XX @@ pages:
423
-t "Welcome to the QEMU sourcecode"
424
- mv HTML public/src
425
# Project documentation
426
- - mv build/docs/index.html public/
427
- - for i in devel interop specs system tools user ; do mv build/docs/$i public/ ; done
428
+ - make -C build install DESTDIR=$(pwd)/temp-install
429
+ - mv temp-install/usr/local/share/doc/qemu/* public/
430
artifacts:
431
paths:
432
- public
433
--
41
--
434
2.20.1
42
2.34.1
435
436
diff view generated by jsdifflib
1
From: Mihai Carabas <mihai.carabas@oracle.com>
1
Set the default NaN pattern explicitly for xtensa.
2
2
3
Add pvpanic PCI device support details in docs/specs/pvpanic.txt.
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20241202131347.498124-51-peter.maydell@linaro.org
6
---
7
target/xtensa/cpu.c | 2 ++
8
1 file changed, 2 insertions(+)
4
9
5
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
10
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
6
[fixed s/device/bus/ error]
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
docs/specs/pvpanic.txt | 13 ++++++++++++-
11
1 file changed, 12 insertions(+), 1 deletion(-)
12
13
diff --git a/docs/specs/pvpanic.txt b/docs/specs/pvpanic.txt
14
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
15
--- a/docs/specs/pvpanic.txt
12
--- a/target/xtensa/cpu.c
16
+++ b/docs/specs/pvpanic.txt
13
+++ b/target/xtensa/cpu.c
17
@@ -XXX,XX +XXX,XX @@
14
@@ -XXX,XX +XXX,XX @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type)
18
PVPANIC DEVICE
15
/* For inf * 0 + NaN, return the input NaN */
19
==============
16
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
20
17
set_no_signaling_nans(!dfpu, &env->fp_status);
21
-pvpanic device is a simulated ISA device, through which a guest panic
18
+ /* Default NaN value: sign bit clear, set frac msb */
22
+pvpanic device is a simulated device, through which a guest panic
19
+ set_float_default_nan_pattern(0b01000000, &env->fp_status);
23
event is sent to qemu, and a QMP event is generated. This allows
20
xtensa_use_first_nan(env, !dfpu);
24
management apps (e.g. libvirt) to be notified and respond to the event.
21
}
25
26
@@ -XXX,XX +XXX,XX @@ The management app has the option of waiting for GUEST_PANICKED events,
27
and/or polling for guest-panicked RunState, to learn when the pvpanic
28
device has fired a panic event.
29
30
+The pvpanic device can be implemented as an ISA device (using IOPORT) or as a
31
+PCI device.
32
+
33
ISA Interface
34
-------------
35
36
@@ -XXX,XX +XXX,XX @@ bit 1: a guest panic has happened and will be handled by the guest;
37
the host should record it or report it, but should not affect
38
the execution of the guest.
39
40
+PCI Interface
41
+-------------
42
+
43
+The PCI interface is similar to the ISA interface except that it uses an MMIO
44
+address space provided by its BAR0, 1 byte long. Any machine with a PCI bus
45
+can enable a pvpanic device by adding '-device pvpanic-pci' to the command
46
+line.
47
+
48
ACPI Interface
49
--------------
50
22
51
--
23
--
52
2.20.1
24
2.34.1
53
54
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
Set the default NaN pattern explicitly for hexagon.
2
Remove the ifdef from parts64_default_nan(); the only
3
remaining unconverted targets all use the default case.
2
4
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20210112104511.36576-15-remi.denis.courmont@huawei.com
7
Message-id: 20241202131347.498124-52-peter.maydell@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
---
8
target/arm/cpu.h | 2 ++
9
target/hexagon/cpu.c | 2 ++
9
target/arm/internals.h | 2 ++
10
fpu/softfloat-specialize.c.inc | 5 -----
10
target/arm/helper.c | 6 ++++++
11
2 files changed, 2 insertions(+), 5 deletions(-)
11
target/arm/tlb_helper.c | 3 +++
12
4 files changed, 13 insertions(+)
13
12
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
13
diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu.h
15
--- a/target/hexagon/cpu.c
17
+++ b/target/arm/cpu.h
16
+++ b/target/hexagon/cpu.c
18
@@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)
17
@@ -XXX,XX +XXX,XX @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type)
19
#define HCR_TWEDEN (1ULL << 59)
18
20
#define HCR_TWEDEL MAKE_64BIT_MASK(60, 4)
19
set_default_nan_mode(1, &env->fp_status);
21
20
set_float_detect_tininess(float_tininess_before_rounding, &env->fp_status);
22
+#define HPFAR_NS (1ULL << 63)
21
+ /* Default NaN value: sign bit set, all frac bits set */
23
+
22
+ set_float_default_nan_pattern(0b11111111, &env->fp_status);
24
#define SCR_NS (1U << 0)
23
}
25
#define SCR_IRQ (1U << 1)
24
26
#define SCR_FIQ (1U << 2)
25
static void hexagon_cpu_disas_set_info(CPUState *s, disassemble_info *info)
27
diff --git a/target/arm/internals.h b/target/arm/internals.h
26
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
28
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/internals.h
28
--- a/fpu/softfloat-specialize.c.inc
30
+++ b/target/arm/internals.h
29
+++ b/fpu/softfloat-specialize.c.inc
31
@@ -XXX,XX +XXX,XX @@ typedef enum ARMFaultType {
30
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
32
* @s2addr: Address that caused a fault at stage 2
31
uint8_t dnan_pattern = status->default_nan_pattern;
33
* @stage2: True if we faulted at stage 2
32
34
* @s1ptw: True if we faulted at stage 2 while doing a stage 1 page-table walk
33
if (dnan_pattern == 0) {
35
+ * @s1ns: True if we faulted on a non-secure IPA while in secure state
34
-#if defined(TARGET_HEXAGON)
36
* @ea: True if we should set the EA (external abort type) bit in syndrome
35
- /* Sign bit set, all frac bits set. */
37
*/
36
- dnan_pattern = 0b11111111;
38
typedef struct ARMMMUFaultInfo ARMMMUFaultInfo;
37
-#else
39
@@ -XXX,XX +XXX,XX @@ struct ARMMMUFaultInfo {
38
/*
40
int domain;
39
* This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V,
41
bool stage2;
40
* S390, SH4, TriCore, and Xtensa. Our other supported targets
42
bool s1ptw;
41
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
43
+ bool s1ns;
42
/* sign bit clear, set frac msb */
44
bool ea;
43
dnan_pattern = 0b01000000;
45
};
46
47
diff --git a/target/arm/helper.c b/target/arm/helper.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/helper.c
50
+++ b/target/arm/helper.c
51
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
52
target_el = 3;
53
} else {
54
env->cp15.hpfar_el2 = extract64(fi.s2addr, 12, 47) << 4;
55
+ if (arm_is_secure_below_el3(env) && fi.s1ns) {
56
+ env->cp15.hpfar_el2 |= HPFAR_NS;
57
+ }
58
target_el = 2;
59
}
60
take_exc = true;
61
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
62
fi->s2addr = addr;
63
fi->stage2 = true;
64
fi->s1ptw = true;
65
+ fi->s1ns = !*is_secure;
66
return ~0;
67
}
44
}
68
if ((arm_hcr_el2_eff(env) & HCR_PTW) &&
45
-#endif
69
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
70
fi->s2addr = addr;
71
fi->stage2 = true;
72
fi->s1ptw = true;
73
+ fi->s1ns = !*is_secure;
74
return ~0;
75
}
76
77
@@ -XXX,XX +XXX,XX @@ do_fault:
78
/* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */
79
fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2 ||
80
mmu_idx == ARMMMUIdx_Stage2_S);
81
+ fi->s1ns = mmu_idx == ARMMMUIdx_Stage2;
82
return true;
83
}
84
85
diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c
86
index XXXXXXX..XXXXXXX 100644
87
--- a/target/arm/tlb_helper.c
88
+++ b/target/arm/tlb_helper.c
89
@@ -XXX,XX +XXX,XX @@ static void QEMU_NORETURN arm_deliver_fault(ARMCPU *cpu, vaddr addr,
90
if (fi->stage2) {
91
target_el = 2;
92
env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4;
93
+ if (arm_is_secure_below_el3(env) && fi->s1ns) {
94
+ env->cp15.hpfar_el2 |= HPFAR_NS;
95
+ }
96
}
46
}
97
same_el = (arm_current_el(env) == target_el);
47
assert(dnan_pattern != 0);
98
48
99
--
49
--
100
2.20.1
50
2.34.1
101
102
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
Set the default NaN pattern explicitly for riscv.
2
2
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20210112104511.36576-18-remi.denis.courmont@huawei.com
5
Message-id: 20241202131347.498124-53-peter.maydell@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
6
---
8
target/arm/cpu64.c | 1 +
7
target/riscv/cpu.c | 2 ++
9
1 file changed, 1 insertion(+)
8
1 file changed, 2 insertions(+)
10
9
11
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
10
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
12
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/cpu64.c
12
--- a/target/riscv/cpu.c
14
+++ b/target/arm/cpu64.c
13
+++ b/target/riscv/cpu.c
15
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
14
@@ -XXX,XX +XXX,XX @@ static void riscv_cpu_reset_hold(Object *obj, ResetType type)
16
t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
15
cs->exception_index = RISCV_EXCP_NONE;
17
t = FIELD_DP64(t, ID_AA64PFR0, FP, 1);
16
env->load_res = -1;
18
t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1);
17
set_default_nan_mode(1, &env->fp_status);
19
+ t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1);
18
+ /* Default NaN value: sign bit clear, frac msb set */
20
cpu->isar.id_aa64pfr0 = t;
19
+ set_float_default_nan_pattern(0b01000000, &env->fp_status);
21
20
env->vill = true;
22
t = cpu->isar.id_aa64pfr1;
21
22
#ifndef CONFIG_USER_ONLY
23
--
23
--
24
2.20.1
24
2.34.1
25
26
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
Set the default NaN pattern explicitly for tricore.
2
2
3
This adds a common helper to compute the effective value of MDCR_EL2.
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
That is the actual value if EL2 is enabled in the current security
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
context, or 0 elsewise.
5
Message-id: 20241202131347.498124-54-peter.maydell@linaro.org
6
---
7
target/tricore/helper.c | 2 ++
8
1 file changed, 2 insertions(+)
6
9
7
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
10
diff --git a/target/tricore/helper.c b/target/tricore/helper.c
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20210112104511.36576-5-remi.denis.courmont@huawei.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/helper.c | 38 ++++++++++++++++++++++----------------
13
1 file changed, 22 insertions(+), 16 deletions(-)
14
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
index XXXXXXX..XXXXXXX 100644
11
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
12
--- a/target/tricore/helper.c
18
+++ b/target/arm/helper.c
13
+++ b/target/tricore/helper.c
19
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_trap_aa32s_el1(CPUARMState *env,
14
@@ -XXX,XX +XXX,XX @@ void fpu_set_state(CPUTriCoreState *env)
20
return CP_ACCESS_TRAP_UNCATEGORIZED;
15
set_flush_to_zero(1, &env->fp_status);
16
set_float_detect_tininess(float_tininess_before_rounding, &env->fp_status);
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);
21
}
20
}
22
21
23
+static uint64_t arm_mdcr_el2_eff(CPUARMState *env)
22
uint32_t psw_read(CPUTriCoreState *env)
24
+{
25
+ return arm_is_el2_enabled(env) ? env->cp15.mdcr_el2 : 0;
26
+}
27
+
28
/* Check for traps to "powerdown debug" registers, which are controlled
29
* by MDCR.TDOSA
30
*/
31
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tdosa(CPUARMState *env, const ARMCPRegInfo *ri,
32
bool isread)
33
{
34
int el = arm_current_el(env);
35
- bool mdcr_el2_tdosa = (env->cp15.mdcr_el2 & MDCR_TDOSA) ||
36
- (env->cp15.mdcr_el2 & MDCR_TDE) ||
37
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
38
+ bool mdcr_el2_tdosa = (mdcr_el2 & MDCR_TDOSA) || (mdcr_el2 & MDCR_TDE) ||
39
(arm_hcr_el2_eff(env) & HCR_TGE);
40
41
- if (el < 2 && mdcr_el2_tdosa && !arm_is_secure_below_el3(env)) {
42
+ if (el < 2 && mdcr_el2_tdosa) {
43
return CP_ACCESS_TRAP_EL2;
44
}
45
if (el < 3 && (env->cp15.mdcr_el3 & MDCR_TDOSA)) {
46
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tdra(CPUARMState *env, const ARMCPRegInfo *ri,
47
bool isread)
48
{
49
int el = arm_current_el(env);
50
- bool mdcr_el2_tdra = (env->cp15.mdcr_el2 & MDCR_TDRA) ||
51
- (env->cp15.mdcr_el2 & MDCR_TDE) ||
52
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
53
+ bool mdcr_el2_tdra = (mdcr_el2 & MDCR_TDRA) || (mdcr_el2 & MDCR_TDE) ||
54
(arm_hcr_el2_eff(env) & HCR_TGE);
55
56
- if (el < 2 && mdcr_el2_tdra && !arm_is_secure_below_el3(env)) {
57
+ if (el < 2 && mdcr_el2_tdra) {
58
return CP_ACCESS_TRAP_EL2;
59
}
60
if (el < 3 && (env->cp15.mdcr_el3 & MDCR_TDA)) {
61
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tda(CPUARMState *env, const ARMCPRegInfo *ri,
62
bool isread)
63
{
64
int el = arm_current_el(env);
65
- bool mdcr_el2_tda = (env->cp15.mdcr_el2 & MDCR_TDA) ||
66
- (env->cp15.mdcr_el2 & MDCR_TDE) ||
67
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
68
+ bool mdcr_el2_tda = (mdcr_el2 & MDCR_TDA) || (mdcr_el2 & MDCR_TDE) ||
69
(arm_hcr_el2_eff(env) & HCR_TGE);
70
71
- if (el < 2 && mdcr_el2_tda && !arm_is_secure_below_el3(env)) {
72
+ if (el < 2 && mdcr_el2_tda) {
73
return CP_ACCESS_TRAP_EL2;
74
}
75
if (el < 3 && (env->cp15.mdcr_el3 & MDCR_TDA)) {
76
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tpm(CPUARMState *env, const ARMCPRegInfo *ri,
77
bool isread)
78
{
79
int el = arm_current_el(env);
80
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
81
82
- if (el < 2 && (env->cp15.mdcr_el2 & MDCR_TPM)
83
- && !arm_is_secure_below_el3(env)) {
84
+ if (el < 2 && (mdcr_el2 & MDCR_TPM)) {
85
return CP_ACCESS_TRAP_EL2;
86
}
87
if (el < 3 && (env->cp15.mdcr_el3 & MDCR_TPM)) {
88
@@ -XXX,XX +XXX,XX @@ static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri,
89
* trapping to EL2 or EL3 for other accesses.
90
*/
91
int el = arm_current_el(env);
92
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
93
94
if (el == 0 && !(env->cp15.c9_pmuserenr & 1)) {
95
return CP_ACCESS_TRAP;
96
}
97
- if (el < 2 && (env->cp15.mdcr_el2 & MDCR_TPM)
98
- && !arm_is_secure_below_el3(env)) {
99
+ if (el < 2 && (mdcr_el2 & MDCR_TPM)) {
100
return CP_ACCESS_TRAP_EL2;
101
}
102
if (el < 3 && (env->cp15.mdcr_el3 & MDCR_TPM)) {
103
@@ -XXX,XX +XXX,XX @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter)
104
bool enabled, prohibited, filtered;
105
bool secure = arm_is_secure(env);
106
int el = arm_current_el(env);
107
- uint8_t hpmn = env->cp15.mdcr_el2 & MDCR_HPMN;
108
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
109
+ uint8_t hpmn = mdcr_el2 & MDCR_HPMN;
110
111
if (!arm_feature(env, ARM_FEATURE_PMU)) {
112
return false;
113
@@ -XXX,XX +XXX,XX @@ static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter)
114
(counter < hpmn || counter == 31)) {
115
e = env->cp15.c9_pmcr & PMCRE;
116
} else {
117
- e = env->cp15.mdcr_el2 & MDCR_HPME;
118
+ e = mdcr_el2 & MDCR_HPME;
119
}
120
enabled = e && (env->cp15.c9_pmcnten & (1 << counter));
121
122
if (!secure) {
123
if (el == 2 && (counter < hpmn || counter == 31)) {
124
- prohibited = env->cp15.mdcr_el2 & MDCR_HPMD;
125
+ prohibited = mdcr_el2 & MDCR_HPMD;
126
} else {
127
prohibited = false;
128
}
129
--
23
--
130
2.20.1
24
2.34.1
131
132
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
Now that all our targets have bene converted to explicitly specify
2
their pattern for the default NaN value we can remove the remaining
3
fallback code in parts64_default_nan().
2
4
3
The stage_1_mmu_idx() already effectively keeps track of which
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
translation regimes have two stages. Don't hard-code another test.
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20241202131347.498124-55-peter.maydell@linaro.org
8
---
9
fpu/softfloat-specialize.c.inc | 14 --------------
10
1 file changed, 14 deletions(-)
5
11
6
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
12
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210112104511.36576-13-remi.denis.courmont@huawei.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
target/arm/helper.c | 13 ++++++-------
12
1 file changed, 6 insertions(+), 7 deletions(-)
13
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
14
--- a/fpu/softfloat-specialize.c.inc
17
+++ b/target/arm/helper.c
15
+++ b/fpu/softfloat-specialize.c.inc
18
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
16
@@ -XXX,XX +XXX,XX @@ static void parts64_default_nan(FloatParts64 *p, float_status *status)
19
target_ulong *page_size,
17
uint64_t frac;
20
ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
18
uint8_t dnan_pattern = status->default_nan_pattern;
21
{
19
22
- if (mmu_idx == ARMMMUIdx_E10_0 ||
20
- if (dnan_pattern == 0) {
23
- mmu_idx == ARMMMUIdx_E10_1 ||
21
- /*
24
- mmu_idx == ARMMMUIdx_E10_1_PAN) {
22
- * This case is true for Alpha, ARM, MIPS, OpenRISC, PPC, RISC-V,
25
+ ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx);
23
- * S390, SH4, TriCore, and Xtensa. Our other supported targets
26
+
24
- * do not have floating-point.
27
+ if (mmu_idx != s1_mmu_idx) {
25
- */
28
/* Call ourselves recursively to do the stage 1 and then stage 2
26
- if (snan_bit_is_one(status)) {
29
- * translations.
27
- /* sign bit clear, set all frac bits other than msb */
30
+ * translations if mmu_idx is a two-stage regime.
28
- dnan_pattern = 0b00111111;
31
*/
29
- } else {
32
if (arm_feature(env, ARM_FEATURE_EL2)) {
30
- /* sign bit clear, set frac msb */
33
hwaddr ipa;
31
- dnan_pattern = 0b01000000;
34
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
32
- }
35
int ret;
33
- }
36
ARMCacheAttrs cacheattrs2 = {};
34
assert(dnan_pattern != 0);
37
35
38
- ret = get_phys_addr(env, address, access_type,
36
sign = dnan_pattern >> 7;
39
- stage_1_mmu_idx(mmu_idx), &ipa, attrs,
40
- prot, page_size, fi, cacheattrs);
41
+ ret = get_phys_addr(env, address, access_type, s1_mmu_idx, &ipa,
42
+ attrs, prot, page_size, fi, cacheattrs);
43
44
/* If S1 fails or S2 is disabled, return early. */
45
if (ret || regime_translation_disabled(env, ARMMMUIdx_Stage2)) {
46
--
37
--
47
2.20.1
38
2.34.1
48
49
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 crypto overhead of emulating pauth can be significant for
3
Inline pickNaNMulAdd into its only caller. This makes
4
some workloads. Add two boolean properties that allows the
4
one assert redundant with the immediately preceding IF.
5
feature to be turned off, on with the architected algorithm,
6
or on with an implementation defined algorithm.
7
5
8
We need two intermediate booleans to control the state while
9
parsing properties lest we clobber ID_AA64ISAR1 into an invalid
10
intermediate state.
11
12
Tested-by: Mark Rutland <mark.rutland@arm.com>
13
Reviewed-by: Andrew Jones <drjones@redhat.com>
14
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20210111235740.462469-3-richard.henderson@linaro.org
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
16
[PMM: fixed docs typo, tweaked text to clarify that the impdef
8
Message-id: 20241203203949.483774-3-richard.henderson@linaro.org
17
algorithm is specific to QEMU]
9
[PMM: keep comment from old code in new location]
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
11
---
20
docs/system/arm/cpu-features.rst | 21 +++++++++++++++++
12
fpu/softfloat-parts.c.inc | 41 +++++++++++++++++++++++++-
21
target/arm/cpu.h | 10 ++++++++
13
fpu/softfloat-specialize.c.inc | 54 ----------------------------------
22
target/arm/cpu.c | 13 +++++++++++
14
2 files changed, 40 insertions(+), 55 deletions(-)
23
target/arm/cpu64.c | 40 ++++++++++++++++++++++++++++----
24
target/arm/monitor.c | 1 +
25
tests/qtest/arm-cpu-features.c | 13 +++++++++++
26
6 files changed, 94 insertions(+), 4 deletions(-)
27
15
28
diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst
16
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
29
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
30
--- a/docs/system/arm/cpu-features.rst
18
--- a/fpu/softfloat-parts.c.inc
31
+++ b/docs/system/arm/cpu-features.rst
19
+++ b/fpu/softfloat-parts.c.inc
32
@@ -XXX,XX +XXX,XX @@ the list of KVM VCPU features and their descriptions.
20
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
33
influence the guest scheduler behavior and/or be
21
}
34
exposed to the guest userspace.
22
35
23
if (s->default_nan_mode) {
36
+TCG VCPU Features
24
+ /*
37
+=================
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;
38
+
53
+
39
+TCG VCPU features are CPU features that are specific to TCG.
54
+ assert(rule != float_3nan_prop_none);
40
+Below is the list of TCG VCPU features and their descriptions.
55
+ if (have_snan && (rule & R_3NAN_SNAN_MASK)) {
41
+
56
+ /* We have at least one SNaN input and should prefer it */
42
+ pauth Enable or disable `FEAT_Pauth`, pointer
57
+ do {
43
+ authentication. By default, the feature is
58
+ which = rule & R_3NAN_1ST_MASK;
44
+ enabled with `-cpu max`.
59
+ rule >>= R_3NAN_1ST_LENGTH;
45
+
60
+ } while (!is_snan(cls[which]));
46
+ pauth-impdef When `FEAT_Pauth` is enabled, either the
61
+ } else {
47
+ *impdef* (Implementation Defined) algorithm
62
+ do {
48
+ is enabled or the *architected* QARMA algorithm
63
+ which = rule & R_3NAN_1ST_MASK;
49
+ is enabled. By default the impdef algorithm
64
+ rule >>= R_3NAN_1ST_LENGTH;
50
+ is disabled, and QARMA is enabled.
65
+ } while (!is_nan(cls[which]));
51
+
52
+ The architected QARMA algorithm has good
53
+ cryptographic properties, but can be quite slow
54
+ to emulate. The impdef algorithm used by QEMU
55
+ is non-cryptographic but significantly faster.
56
+
57
SVE CPU Properties
58
==================
59
60
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
61
index XXXXXXX..XXXXXXX 100644
62
--- a/target/arm/cpu.h
63
+++ b/target/arm/cpu.h
64
@@ -XXX,XX +XXX,XX @@ typedef struct {
65
#ifdef TARGET_AARCH64
66
# define ARM_MAX_VQ 16
67
void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp);
68
+void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp);
69
#else
70
# define ARM_MAX_VQ 1
71
static inline void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) { }
72
+static inline void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) { }
73
#endif
74
75
typedef struct ARMVectorReg {
76
@@ -XXX,XX +XXX,XX @@ struct ARMCPU {
77
uint64_t reset_cbar;
78
uint32_t reset_auxcr;
79
bool reset_hivecs;
80
+
81
+ /*
82
+ * Intermediate values used during property parsing.
83
+ * Once finalized, the values should be read from ID_AA64ISAR1.
84
+ */
85
+ bool prop_pauth;
86
+ bool prop_pauth_impdef;
87
+
88
/* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */
89
uint32_t dcz_blocksize;
90
uint64_t rvbar;
91
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
92
index XXXXXXX..XXXXXXX 100644
93
--- a/target/arm/cpu.c
94
+++ b/target/arm/cpu.c
95
@@ -XXX,XX +XXX,XX @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp)
96
error_propagate(errp, local_err);
97
return;
98
}
99
+
100
+ /*
101
+ * KVM does not support modifications to this feature.
102
+ * We have not registered the cpu properties when KVM
103
+ * is in use, so the user will not be able to set them.
104
+ */
105
+ if (!kvm_enabled()) {
106
+ arm_cpu_pauth_finalize(cpu, &local_err);
107
+ if (local_err != NULL) {
108
+ error_propagate(errp, local_err);
109
+ return;
110
+ }
111
+ }
66
+ }
112
}
67
}
113
68
114
if (kvm_enabled()) {
69
if (which == 3) {
115
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
70
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
116
index XXXXXXX..XXXXXXX 100644
71
index XXXXXXX..XXXXXXX 100644
117
--- a/target/arm/cpu64.c
72
--- a/fpu/softfloat-specialize.c.inc
118
+++ b/target/arm/cpu64.c
73
+++ b/fpu/softfloat-specialize.c.inc
119
@@ -XXX,XX +XXX,XX @@
74
@@ -XXX,XX +XXX,XX @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls,
120
#include "sysemu/kvm.h"
121
#include "kvm_arm.h"
122
#include "qapi/visitor.h"
123
+#include "hw/qdev-properties.h"
124
+
125
126
#ifndef CONFIG_USER_ONLY
127
static uint64_t a57_a53_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
128
@@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj)
129
}
75
}
130
}
76
}
131
77
132
+void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp)
78
-/*----------------------------------------------------------------------------
133
+{
79
-| Select which NaN to propagate for a three-input operation.
134
+ int arch_val = 0, impdef_val = 0;
80
-| For the moment we assume that no CPU needs the 'larger significand'
135
+ uint64_t t;
81
-| information.
136
+
82
-| Return values : 0 : a; 1 : b; 2 : c; 3 : default-NaN
137
+ /* TODO: Handle HaveEnhancedPAC, HaveEnhancedPAC2, HaveFPAC. */
83
-*----------------------------------------------------------------------------*/
138
+ if (cpu->prop_pauth) {
84
-static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls,
139
+ if (cpu->prop_pauth_impdef) {
85
- bool infzero, bool have_snan, float_status *status)
140
+ impdef_val = 1;
86
-{
141
+ } else {
87
- FloatClass cls[3] = { a_cls, b_cls, c_cls };
142
+ arch_val = 1;
88
- Float3NaNPropRule rule = status->float_3nan_prop_rule;
143
+ }
89
- int which;
144
+ } else if (cpu->prop_pauth_impdef) {
90
-
145
+ error_setg(errp, "cannot enable pauth-impdef without pauth");
91
- /*
146
+ error_append_hint(errp, "Add pauth=on to the CPU property list.\n");
92
- * We guarantee not to require the target to tell us how to
147
+ }
93
- * pick a NaN if we're always returning the default NaN.
148
+
94
- * But if we're not in default-NaN mode then the target must
149
+ t = cpu->isar.id_aa64isar1;
95
- * specify.
150
+ t = FIELD_DP64(t, ID_AA64ISAR1, APA, arch_val);
96
- */
151
+ t = FIELD_DP64(t, ID_AA64ISAR1, GPA, arch_val);
97
- assert(!status->default_nan_mode);
152
+ t = FIELD_DP64(t, ID_AA64ISAR1, API, impdef_val);
98
-
153
+ t = FIELD_DP64(t, ID_AA64ISAR1, GPI, impdef_val);
99
- if (infzero) {
154
+ cpu->isar.id_aa64isar1 = t;
100
- /*
155
+}
101
- * Inf * 0 + NaN -- some implementations return the default NaN here,
156
+
102
- * and some return the input NaN.
157
+static Property arm_cpu_pauth_property =
103
- */
158
+ DEFINE_PROP_BOOL("pauth", ARMCPU, prop_pauth, true);
104
- switch (status->float_infzeronan_rule) {
159
+static Property arm_cpu_pauth_impdef_property =
105
- case float_infzeronan_dnan_never:
160
+ DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false);
106
- return 2;
161
+
107
- case float_infzeronan_dnan_always:
162
/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host);
108
- return 3;
163
* otherwise, a CPU with as many features enabled as our emulation supports.
109
- case float_infzeronan_dnan_if_qnan:
164
* The version of '-cpu max' for qemu-system-arm is defined in cpu.c;
110
- return is_qnan(c_cls) ? 3 : 2;
165
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
111
- default:
166
t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2);
112
- g_assert_not_reached();
167
t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1);
113
- }
168
t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1);
114
- }
169
- t = FIELD_DP64(t, ID_AA64ISAR1, APA, 1); /* PAuth, architected only */
115
-
170
- t = FIELD_DP64(t, ID_AA64ISAR1, API, 0);
116
- assert(rule != float_3nan_prop_none);
171
- t = FIELD_DP64(t, ID_AA64ISAR1, GPA, 1);
117
- if (have_snan && (rule & R_3NAN_SNAN_MASK)) {
172
- t = FIELD_DP64(t, ID_AA64ISAR1, GPI, 0);
118
- /* We have at least one SNaN input and should prefer it */
173
t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1);
119
- do {
174
t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1);
120
- which = rule & R_3NAN_1ST_MASK;
175
t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 1);
121
- rule >>= R_3NAN_1ST_LENGTH;
176
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
122
- } while (!is_snan(cls[which]));
177
cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */
123
- } else {
178
cpu->dcz_blocksize = 7; /* 512 bytes */
124
- do {
179
#endif
125
- which = rule & R_3NAN_1ST_MASK;
180
+
126
- rule >>= R_3NAN_1ST_LENGTH;
181
+ /* Default to PAUTH on, with the architected algorithm. */
127
- } while (!is_nan(cls[which]));
182
+ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_property);
128
- }
183
+ qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property);
129
- return which;
184
}
130
-}
185
131
-
186
aarch64_add_sve_properties(obj);
132
/*----------------------------------------------------------------------------
187
diff --git a/target/arm/monitor.c b/target/arm/monitor.c
133
| Returns 1 if the double-precision floating-point value `a' is a quiet
188
index XXXXXXX..XXXXXXX 100644
134
| NaN; otherwise returns 0.
189
--- a/target/arm/monitor.c
190
+++ b/target/arm/monitor.c
191
@@ -XXX,XX +XXX,XX @@ static const char *cpu_model_advertised_features[] = {
192
"sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280",
193
"sve1408", "sve1536", "sve1664", "sve1792", "sve1920", "sve2048",
194
"kvm-no-adjvtime", "kvm-steal-time",
195
+ "pauth", "pauth-impdef",
196
NULL
197
};
198
199
diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c
200
index XXXXXXX..XXXXXXX 100644
201
--- a/tests/qtest/arm-cpu-features.c
202
+++ b/tests/qtest/arm-cpu-features.c
203
@@ -XXX,XX +XXX,XX @@ static void sve_tests_sve_off_kvm(const void *data)
204
qtest_quit(qts);
205
}
206
207
+static void pauth_tests_default(QTestState *qts, const char *cpu_type)
208
+{
209
+ assert_has_feature_enabled(qts, cpu_type, "pauth");
210
+ assert_has_feature_disabled(qts, cpu_type, "pauth-impdef");
211
+ assert_set_feature(qts, cpu_type, "pauth", false);
212
+ assert_set_feature(qts, cpu_type, "pauth", true);
213
+ assert_set_feature(qts, cpu_type, "pauth-impdef", true);
214
+ assert_set_feature(qts, cpu_type, "pauth-impdef", false);
215
+ assert_error(qts, cpu_type, "cannot enable pauth-impdef without pauth",
216
+ "{ 'pauth': false, 'pauth-impdef': true }");
217
+}
218
+
219
static void test_query_cpu_model_expansion(const void *data)
220
{
221
QTestState *qts;
222
@@ -XXX,XX +XXX,XX @@ static void test_query_cpu_model_expansion(const void *data)
223
assert_has_feature_enabled(qts, "cortex-a57", "aarch64");
224
225
sve_tests_default(qts, "max");
226
+ pauth_tests_default(qts, "max");
227
228
/* Test that features that depend on KVM generate errors without. */
229
assert_error(qts, "max",
230
--
135
--
231
2.20.1
136
2.34.1
232
137
233
138
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
3
Remove "3" as a special case for which and simply
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
branch to return the desired value.
5
Message-id: 20210112104511.36576-14-remi.denis.courmont@huawei.com
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20241203203949.483774-4-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
10
---
8
target/arm/cpu.h | 6 +++-
11
fpu/softfloat-parts.c.inc | 20 ++++++++++----------
9
target/arm/internals.h | 22 ++++++++++++
12
1 file changed, 10 insertions(+), 10 deletions(-)
10
target/arm/helper.c | 78 +++++++++++++++++++++++++++++-------------
11
3 files changed, 81 insertions(+), 25 deletions(-)
12
13
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
16
--- a/fpu/softfloat-parts.c.inc
16
+++ b/target/arm/cpu.h
17
+++ b/fpu/softfloat-parts.c.inc
17
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx {
18
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
18
ARMMMUIdx_Stage1_E0 = 0 | ARM_MMU_IDX_NOTLB,
19
* But if we're not in default-NaN mode then the target must
19
ARMMMUIdx_Stage1_E1 = 1 | ARM_MMU_IDX_NOTLB,
20
* specify.
20
ARMMMUIdx_Stage1_E1_PAN = 2 | ARM_MMU_IDX_NOTLB,
21
*/
21
+ ARMMMUIdx_Stage1_SE0 = 3 | ARM_MMU_IDX_NOTLB,
22
- which = 3;
22
+ ARMMMUIdx_Stage1_SE1 = 4 | ARM_MMU_IDX_NOTLB,
23
+ goto default_nan;
23
+ ARMMMUIdx_Stage1_SE1_PAN = 5 | ARM_MMU_IDX_NOTLB,
24
} else if (infzero) {
24
/*
25
/*
25
* Not allocated a TLB: used only for second stage of an S12 page
26
* Inf * 0 + NaN -- some implementations return the
26
* table walk, or for descriptor loads during first stage of an S1
27
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
27
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx {
28
*/
28
* then various TLB flush insns which currently are no-ops or flush
29
switch (s->float_infzeronan_rule) {
29
* only stage 1 MMU indexes will need to change to flush stage 2.
30
case float_infzeronan_dnan_never:
30
*/
31
- which = 2;
31
- ARMMMUIdx_Stage2 = 3 | ARM_MMU_IDX_NOTLB,
32
+ ARMMMUIdx_Stage2 = 6 | ARM_MMU_IDX_NOTLB,
33
+ ARMMMUIdx_Stage2_S = 7 | ARM_MMU_IDX_NOTLB,
34
35
/*
36
* M-profile.
37
diff --git a/target/arm/internals.h b/target/arm/internals.h
38
index XXXXXXX..XXXXXXX 100644
39
--- a/target/arm/internals.h
40
+++ b/target/arm/internals.h
41
@@ -XXX,XX +XXX,XX @@ static inline bool regime_has_2_ranges(ARMMMUIdx mmu_idx)
42
case ARMMMUIdx_Stage1_E0:
43
case ARMMMUIdx_Stage1_E1:
44
case ARMMMUIdx_Stage1_E1_PAN:
45
+ case ARMMMUIdx_Stage1_SE0:
46
+ case ARMMMUIdx_Stage1_SE1:
47
+ case ARMMMUIdx_Stage1_SE1_PAN:
48
case ARMMMUIdx_E10_0:
49
case ARMMMUIdx_E10_1:
50
case ARMMMUIdx_E10_1_PAN:
51
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx)
52
case ARMMMUIdx_SE20_0:
53
case ARMMMUIdx_SE20_2:
54
case ARMMMUIdx_SE20_2_PAN:
55
+ case ARMMMUIdx_Stage1_SE0:
56
+ case ARMMMUIdx_Stage1_SE1:
57
+ case ARMMMUIdx_Stage1_SE1_PAN:
58
case ARMMMUIdx_SE2:
59
+ case ARMMMUIdx_Stage2_S:
60
case ARMMMUIdx_MSPrivNegPri:
61
case ARMMMUIdx_MSUserNegPri:
62
case ARMMMUIdx_MSPriv:
63
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx)
64
{
65
switch (mmu_idx) {
66
case ARMMMUIdx_Stage1_E1_PAN:
67
+ case ARMMMUIdx_Stage1_SE1_PAN:
68
case ARMMMUIdx_E10_1_PAN:
69
case ARMMMUIdx_E20_2_PAN:
70
case ARMMMUIdx_SE10_1_PAN:
71
@@ -XXX,XX +XXX,XX @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
72
case ARMMMUIdx_E20_2:
73
case ARMMMUIdx_E20_2_PAN:
74
case ARMMMUIdx_Stage2:
75
+ case ARMMMUIdx_Stage2_S:
76
case ARMMMUIdx_SE2:
77
case ARMMMUIdx_E2:
78
return 2;
79
case ARMMMUIdx_SE3:
80
return 3;
81
case ARMMMUIdx_SE10_0:
82
+ case ARMMMUIdx_Stage1_SE0:
83
return arm_el_is_aa64(env, 3) ? 1 : 3;
84
case ARMMMUIdx_SE10_1:
85
case ARMMMUIdx_SE10_1_PAN:
86
case ARMMMUIdx_Stage1_E0:
87
case ARMMMUIdx_Stage1_E1:
88
case ARMMMUIdx_Stage1_E1_PAN:
89
+ case ARMMMUIdx_Stage1_SE1:
90
+ case ARMMMUIdx_Stage1_SE1_PAN:
91
case ARMMMUIdx_E10_0:
92
case ARMMMUIdx_E10_1:
93
case ARMMMUIdx_E10_1_PAN:
94
@@ -XXX,XX +XXX,XX @@ static inline TCR *regime_tcr(CPUARMState *env, ARMMMUIdx mmu_idx)
95
if (mmu_idx == ARMMMUIdx_Stage2) {
96
return &env->cp15.vtcr_el2;
97
}
98
+ if (mmu_idx == ARMMMUIdx_Stage2_S) {
99
+ /*
100
+ * Note: Secure stage 2 nominally shares fields from VTCR_EL2, but
101
+ * those are not currently used by QEMU, so just return VSTCR_EL2.
102
+ */
103
+ return &env->cp15.vstcr_el2;
104
+ }
105
return &env->cp15.tcr_el[regime_el(env, mmu_idx)];
106
}
107
108
@@ -XXX,XX +XXX,XX @@ static inline bool arm_mmu_idx_is_stage1_of_2(ARMMMUIdx mmu_idx)
109
case ARMMMUIdx_Stage1_E0:
110
case ARMMMUIdx_Stage1_E1:
111
case ARMMMUIdx_Stage1_E1_PAN:
112
+ case ARMMMUIdx_Stage1_SE0:
113
+ case ARMMMUIdx_Stage1_SE1:
114
+ case ARMMMUIdx_Stage1_SE1_PAN:
115
return true;
116
default:
117
return false;
118
diff --git a/target/arm/helper.c b/target/arm/helper.c
119
index XXXXXXX..XXXXXXX 100644
120
--- a/target/arm/helper.c
121
+++ b/target/arm/helper.c
122
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
123
uint32_t syn, fsr, fsc;
124
bool take_exc = false;
125
126
- if (fi.s1ptw && current_el == 1 && !arm_is_secure(env)
127
+ if (fi.s1ptw && current_el == 1
128
&& arm_mmu_idx_is_stage1_of_2(mmu_idx)) {
129
/*
130
* Synchronous stage 2 fault on an access made as part of the
131
@@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
132
/* fall through */
133
case 1:
134
if (ri->crm == 9 && (env->uncached_cpsr & CPSR_PAN)) {
135
- mmu_idx = (secure ? ARMMMUIdx_SE10_1_PAN
136
+ mmu_idx = (secure ? ARMMMUIdx_Stage1_SE1_PAN
137
: ARMMMUIdx_Stage1_E1_PAN);
138
} else {
139
- mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_Stage1_E1;
140
+ mmu_idx = secure ? ARMMMUIdx_Stage1_SE1 : ARMMMUIdx_Stage1_E1;
141
}
142
break;
32
break;
143
default:
33
case float_infzeronan_dnan_always:
144
@@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
34
- which = 3;
145
mmu_idx = ARMMMUIdx_SE10_0;
35
- break;
146
break;
36
+ goto default_nan;
147
case 2:
37
case float_infzeronan_dnan_if_qnan:
148
+ g_assert(!secure); /* ARMv8.4-SecEL2 is 64-bit only */
38
- which = is_qnan(c->cls) ? 3 : 2;
149
mmu_idx = ARMMMUIdx_Stage1_E0;
39
+ if (is_qnan(c->cls)) {
150
break;
40
+ goto default_nan;
151
case 1:
41
+ }
152
- mmu_idx = secure ? ARMMMUIdx_SE10_0 : ARMMMUIdx_Stage1_E0;
153
+ mmu_idx = secure ? ARMMMUIdx_Stage1_SE0 : ARMMMUIdx_Stage1_E0;
154
break;
42
break;
155
default:
43
default:
156
g_assert_not_reached();
44
g_assert_not_reached();
157
@@ -XXX,XX +XXX,XX @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri,
158
switch (ri->opc1) {
159
case 0: /* AT S1E1R, AT S1E1W, AT S1E1RP, AT S1E1WP */
160
if (ri->crm == 9 && (env->pstate & PSTATE_PAN)) {
161
- mmu_idx = (secure ? ARMMMUIdx_SE10_1_PAN
162
+ mmu_idx = (secure ? ARMMMUIdx_Stage1_SE1_PAN
163
: ARMMMUIdx_Stage1_E1_PAN);
164
} else {
165
- mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_Stage1_E1;
166
+ mmu_idx = secure ? ARMMMUIdx_Stage1_SE1 : ARMMMUIdx_Stage1_E1;
167
}
168
break;
169
case 4: /* AT S1E2R, AT S1E2W */
170
@@ -XXX,XX +XXX,XX @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri,
171
}
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:
172
break;
61
break;
173
case 2: /* AT S1E0R, AT S1E0W */
62
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
174
- mmu_idx = secure ? ARMMMUIdx_SE10_0 : ARMMMUIdx_Stage1_E0;
63
parts_silence_nan(a, s);
175
+ mmu_idx = secure ? ARMMMUIdx_Stage1_SE0 : ARMMMUIdx_Stage1_E0;
176
break;
177
case 4: /* AT S12E1R, AT S12E1W */
178
mmu_idx = secure ? ARMMMUIdx_SE10_1 : ARMMMUIdx_E10_1;
179
@@ -XXX,XX +XXX,XX @@ static inline bool regime_translation_disabled(CPUARMState *env,
180
181
hcr_el2 = arm_hcr_el2_eff(env);
182
183
- if (mmu_idx == ARMMMUIdx_Stage2) {
184
+ if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
185
/* HCR.DC means HCR.VM behaves as 1 */
186
return (hcr_el2 & (HCR_DC | HCR_VM)) == 0;
187
}
64
}
188
@@ -XXX,XX +XXX,XX @@ static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx,
65
return a;
189
if (mmu_idx == ARMMMUIdx_Stage2) {
190
return env->cp15.vttbr_el2;
191
}
192
+ if (mmu_idx == ARMMMUIdx_Stage2_S) {
193
+ return env->cp15.vsttbr_el2;
194
+ }
195
if (ttbrn == 0) {
196
return env->cp15.ttbr0_el[regime_el(env, mmu_idx)];
197
} else {
198
@@ -XXX,XX +XXX,XX @@ static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx,
199
static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx)
200
{
201
switch (mmu_idx) {
202
+ case ARMMMUIdx_SE10_0:
203
+ return ARMMMUIdx_Stage1_SE0;
204
+ case ARMMMUIdx_SE10_1:
205
+ return ARMMMUIdx_Stage1_SE1;
206
+ case ARMMMUIdx_SE10_1_PAN:
207
+ return ARMMMUIdx_Stage1_SE1_PAN;
208
case ARMMMUIdx_E10_0:
209
return ARMMMUIdx_Stage1_E0;
210
case ARMMMUIdx_E10_1:
211
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx)
212
case ARMMMUIdx_E20_0:
213
case ARMMMUIdx_SE20_0:
214
case ARMMMUIdx_Stage1_E0:
215
+ case ARMMMUIdx_Stage1_SE0:
216
case ARMMMUIdx_MUser:
217
case ARMMMUIdx_MSUser:
218
case ARMMMUIdx_MUserNegPri:
219
@@ -XXX,XX +XXX,XX @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64,
220
int wxn = 0;
221
222
assert(mmu_idx != ARMMMUIdx_Stage2);
223
+ assert(mmu_idx != ARMMMUIdx_Stage2_S);
224
225
user_rw = simple_ap_to_rw_prot_is_user(ap, true);
226
if (is_user) {
227
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
228
hwaddr s2pa;
229
int s2prot;
230
int ret;
231
+ ARMMMUIdx s2_mmu_idx = *is_secure ? ARMMMUIdx_Stage2_S
232
+ : ARMMMUIdx_Stage2;
233
ARMCacheAttrs cacheattrs = {};
234
MemTxAttrs txattrs = {};
235
236
- assert(!*is_secure); /* TODO: S-EL2 */
237
-
238
- ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, ARMMMUIdx_Stage2,
239
- false,
240
+ ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, s2_mmu_idx, false,
241
&s2pa, &txattrs, &s2prot, &s2size, fi,
242
&cacheattrs);
243
if (ret) {
244
@@ -XXX,XX +XXX,XX @@ static int aa64_va_parameter_tbi(uint64_t tcr, ARMMMUIdx mmu_idx)
245
{
246
if (regime_has_2_ranges(mmu_idx)) {
247
return extract64(tcr, 37, 2);
248
- } else if (mmu_idx == ARMMMUIdx_Stage2) {
249
+ } else if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
250
return 0; /* VTCR_EL2 */
251
} else {
252
/* Replicate the single TBI bit so we always have 2 bits. */
253
@@ -XXX,XX +XXX,XX @@ static int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx)
254
{
255
if (regime_has_2_ranges(mmu_idx)) {
256
return extract64(tcr, 51, 2);
257
- } else if (mmu_idx == ARMMMUIdx_Stage2) {
258
+ } else if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
259
return 0; /* VTCR_EL2 */
260
} else {
261
/* Replicate the single TBID bit so we always have 2 bits. */
262
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
263
tsz = extract32(tcr, 0, 6);
264
using64k = extract32(tcr, 14, 1);
265
using16k = extract32(tcr, 15, 1);
266
- if (mmu_idx == ARMMMUIdx_Stage2) {
267
+ if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
268
/* VTCR_EL2 */
269
hpd = false;
270
} else {
271
@@ -XXX,XX +XXX,XX @@ static ARMVAParameters aa32_va_parameters(CPUARMState *env, uint32_t va,
272
int select, tsz;
273
bool epd, hpd;
274
275
+ assert(mmu_idx != ARMMMUIdx_Stage2_S);
276
+
66
+
277
if (mmu_idx == ARMMMUIdx_Stage2) {
67
+ default_nan:
278
/* VTCR */
68
+ parts_default_nan(a, s);
279
bool sext = extract32(tcr, 4, 1);
69
+ return a;
280
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
281
goto do_fault;
282
}
283
284
- if (mmu_idx != ARMMMUIdx_Stage2) {
285
+ if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) {
286
/* The starting level depends on the virtual address size (which can
287
* be up to 48 bits) and the translation granule size. It indicates
288
* the number of strides (stride bits at a time) needed to
289
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
290
attrs = extract64(descriptor, 2, 10)
291
| (extract64(descriptor, 52, 12) << 10);
292
293
- if (mmu_idx == ARMMMUIdx_Stage2) {
294
+ if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
295
/* Stage 2 table descriptors do not include any attribute fields */
296
break;
297
}
298
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
299
300
ap = extract32(attrs, 4, 2);
301
302
- if (mmu_idx == ARMMMUIdx_Stage2) {
303
- ns = true;
304
+ if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
305
+ ns = mmu_idx == ARMMMUIdx_Stage2;
306
xn = extract32(attrs, 11, 2);
307
*prot = get_S2prot(env, ap, xn, s1_is_el0);
308
} else {
309
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, uint64_t address,
310
arm_tlb_bti_gp(txattrs) = true;
311
}
312
313
- if (mmu_idx == ARMMMUIdx_Stage2) {
314
+ if (mmu_idx == ARMMMUIdx_Stage2 || mmu_idx == ARMMMUIdx_Stage2_S) {
315
cacheattrs->attrs = convert_stage2_attrs(env, extract32(attrs, 0, 4));
316
} else {
317
/* Index into MAIR registers for cache attributes */
318
@@ -XXX,XX +XXX,XX @@ do_fault:
319
fi->type = fault_type;
320
fi->level = level;
321
/* Tag the error as S2 for failed S1 PTW at S2 or ordinary S2. */
322
- fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2);
323
+ fi->stage2 = fi->s1ptw || (mmu_idx == ARMMMUIdx_Stage2 ||
324
+ mmu_idx == ARMMMUIdx_Stage2_S);
325
return true;
326
}
70
}
327
71
328
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
72
/*
329
int s2_prot;
330
int ret;
331
ARMCacheAttrs cacheattrs2 = {};
332
+ ARMMMUIdx s2_mmu_idx;
333
+ bool is_el0;
334
335
ret = get_phys_addr(env, address, access_type, s1_mmu_idx, &ipa,
336
attrs, prot, page_size, fi, cacheattrs);
337
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
338
return ret;
339
}
340
341
+ s2_mmu_idx = attrs->secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
342
+ is_el0 = mmu_idx == ARMMMUIdx_E10_0 || mmu_idx == ARMMMUIdx_SE10_0;
343
+
344
/* S1 is done. Now do S2 translation. */
345
- ret = get_phys_addr_lpae(env, ipa, access_type, ARMMMUIdx_Stage2,
346
- mmu_idx == ARMMMUIdx_E10_0,
347
+ ret = get_phys_addr_lpae(env, ipa, access_type, s2_mmu_idx, is_el0,
348
phys_ptr, attrs, &s2_prot,
349
page_size, fi, &cacheattrs2);
350
fi->s2addr = ipa;
351
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
352
cacheattrs->shareability = 0;
353
}
354
*cacheattrs = combine_cacheattrs(*cacheattrs, cacheattrs2);
355
+
356
+ /* Check if IPA translates to secure or non-secure PA space. */
357
+ if (arm_is_secure_below_el3(env)) {
358
+ if (attrs->secure) {
359
+ attrs->secure =
360
+ !(env->cp15.vstcr_el2.raw_tcr & (VSTCR_SA | VSTCR_SW));
361
+ } else {
362
+ attrs->secure =
363
+ !((env->cp15.vtcr_el2.raw_tcr & (VTCR_NSA | VTCR_NSW))
364
+ || (env->cp15.vstcr_el2.raw_tcr & VSTCR_SA));
365
+ }
366
+ }
367
return 0;
368
} else {
369
/*
370
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
371
* MMU disabled. S1 addresses within aa64 translation regimes are
372
* still checked for bounds -- see AArch64.TranslateAddressS1Off.
373
*/
374
- if (mmu_idx != ARMMMUIdx_Stage2) {
375
+ if (mmu_idx != ARMMMUIdx_Stage2 && mmu_idx != ARMMMUIdx_Stage2_S) {
376
int r_el = regime_el(env, mmu_idx);
377
if (arm_el_is_aa64(env, r_el)) {
378
int pamax = arm_pamax(env_archcpu(env));
379
--
73
--
380
2.20.1
74
2.34.1
381
75
382
76
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This will simplify accessing HCR conditionally in secure state.
3
Assign the pointer return value to 'a' directly,
4
rather than going through an intermediary index.
4
5
5
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Message-id: 20210112104511.36576-4-remi.denis.courmont@huawei.com
8
Message-id: 20241203203949.483774-5-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
---
10
target/arm/helper.c | 31 ++++++++++++++++++-------------
11
fpu/softfloat-parts.c.inc | 32 ++++++++++----------------------
11
1 file changed, 18 insertions(+), 13 deletions(-)
12
1 file changed, 10 insertions(+), 22 deletions(-)
12
13
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
16
--- a/fpu/softfloat-parts.c.inc
16
+++ b/target/arm/helper.c
17
+++ b/fpu/softfloat-parts.c.inc
17
@@ -XXX,XX +XXX,XX @@ static CPAccessResult aa64_cacheop_pou_access(CPUARMState *env,
18
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
18
19
FloatPartsN *c, float_status *s,
19
static int vae1_tlbmask(CPUARMState *env)
20
int ab_mask, int abc_mask)
20
{
21
{
21
- /* Since we exclude secure first, we may read HCR_EL2 directly. */
22
- int which;
22
- if (arm_is_secure_below_el3(env)) {
23
bool infzero = (ab_mask == float_cmask_infzero);
23
- return ARMMMUIdxBit_SE10_1 |
24
bool have_snan = (abc_mask & float_cmask_snan);
24
- ARMMMUIdxBit_SE10_1_PAN |
25
+ FloatPartsN *ret;
25
- ARMMMUIdxBit_SE10_0;
26
26
- } else if ((env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE))
27
if (unlikely(have_snan)) {
27
- == (HCR_E2H | HCR_TGE)) {
28
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
28
+ uint64_t hcr = arm_hcr_el2_eff(env);
29
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
29
+
30
default:
30
+ if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) {
31
g_assert_not_reached();
31
return ARMMMUIdxBit_E20_2 |
32
}
32
ARMMMUIdxBit_E20_2_PAN |
33
- which = 2;
33
ARMMMUIdxBit_E20_0;
34
+ ret = c;
34
+ } else if (arm_is_secure_below_el3(env)) {
35
+ return ARMMMUIdxBit_SE10_1 |
36
+ ARMMMUIdxBit_SE10_1_PAN |
37
+ ARMMMUIdxBit_SE10_0;
38
} else {
35
} else {
39
return ARMMMUIdxBit_E10_1 |
36
- FloatClass cls[3] = { a->cls, b->cls, c->cls };
40
ARMMMUIdxBit_E10_1_PAN |
37
+ FloatPartsN *val[3] = { a, b, c };
41
@@ -XXX,XX +XXX,XX @@ static inline uint64_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx)
38
Float3NaNPropRule rule = s->float_3nan_prop_rule;
42
static inline bool regime_translation_disabled(CPUARMState *env,
39
43
ARMMMUIdx mmu_idx)
40
assert(rule != float_3nan_prop_none);
44
{
41
if (have_snan && (rule & R_3NAN_SNAN_MASK)) {
45
+ uint64_t hcr_el2;
42
/* We have at least one SNaN input and should prefer it */
46
+
43
do {
47
if (arm_feature(env, ARM_FEATURE_M)) {
44
- which = rule & R_3NAN_1ST_MASK;
48
switch (env->v7m.mpu_ctrl[regime_is_secure(env, mmu_idx)] &
45
+ ret = val[rule & R_3NAN_1ST_MASK];
49
(R_V7M_MPU_CTRL_ENABLE_MASK | R_V7M_MPU_CTRL_HFNMIENA_MASK)) {
46
rule >>= R_3NAN_1ST_LENGTH;
50
@@ -XXX,XX +XXX,XX @@ static inline bool regime_translation_disabled(CPUARMState *env,
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));
51
}
56
}
52
}
57
}
53
58
54
+ hcr_el2 = arm_hcr_el2_eff(env);
59
- switch (which) {
55
+
60
- case 0:
56
if (mmu_idx == ARMMMUIdx_Stage2) {
61
- break;
57
/* HCR.DC means HCR.VM behaves as 1 */
62
- case 1:
58
- return (env->cp15.hcr_el2 & (HCR_DC | HCR_VM)) == 0;
63
- a = b;
59
+ return (hcr_el2 & (HCR_DC | HCR_VM)) == 0;
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);
60
}
72
}
61
73
- if (is_snan(a->cls)) {
62
- if (env->cp15.hcr_el2 & HCR_TGE) {
74
- parts_silence_nan(a, s);
63
+ if (hcr_el2 & HCR_TGE) {
75
- }
64
/* TGE means that NS EL0/1 act as if SCTLR_EL1.M is zero */
76
- return a;
65
if (!regime_is_secure(env, mmu_idx) && regime_el(env, mmu_idx) == 1) {
77
+ return ret;
66
return true;
78
67
}
79
default_nan:
68
}
80
parts_default_nan(a, s);
69
70
- if ((env->cp15.hcr_el2 & HCR_DC) && arm_mmu_idx_is_stage1_of_2(mmu_idx)) {
71
+ if ((hcr_el2 & HCR_DC) && arm_mmu_idx_is_stage1_of_2(mmu_idx)) {
72
/* HCR.DC means SCTLR_EL1.M behaves as 0 */
73
return true;
74
}
75
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
76
fi->s1ptw = true;
77
return ~0;
78
}
79
- if ((env->cp15.hcr_el2 & HCR_PTW) && (cacheattrs.attrs & 0xf0) == 0) {
80
+ if ((arm_hcr_el2_eff(env) & HCR_PTW) &&
81
+ (cacheattrs.attrs & 0xf0) == 0) {
82
/*
83
* PTW set and S1 walk touched S2 Device memory:
84
* generate Permission fault.
85
@@ -XXX,XX +XXX,XX @@ static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs)
86
uint8_t hihint = 0, lohint = 0;
87
88
if (hiattr != 0) { /* normal memory */
89
- if ((env->cp15.hcr_el2 & HCR_CD) != 0) { /* cache disabled */
90
+ if (arm_hcr_el2_eff(env) & HCR_CD) { /* cache disabled */
91
hiattr = loattr = 1; /* non-cacheable */
92
} else {
93
if (hiattr != 1) { /* Write-through or write-back */
94
@@ -XXX,XX +XXX,XX @@ bool get_phys_addr(CPUARMState *env, target_ulong address,
95
}
96
97
/* Combine the S1 and S2 cache attributes. */
98
- if (env->cp15.hcr_el2 & HCR_DC) {
99
+ if (arm_hcr_el2_eff(env) & HCR_DC) {
100
/*
101
* HCR.DC forces the first stage attributes to
102
* Normal Non-Shareable,
103
--
81
--
104
2.20.1
82
2.34.1
105
83
106
84
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Update all users of do_perm_pred2 for the new
3
While all indices into val[] should be in [0-2], the mask
4
predicate descriptor field definitions.
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.
5
7
6
Cc: qemu-stable@nongnu.org
7
Buglink: https://bugs.launchpad.net/bugs/1908551
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20210113062650.593824-5-richard.henderson@linaro.org
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20241203203949.483774-6-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
12
---
13
target/arm/sve_helper.c | 8 ++++----
13
fpu/softfloat-parts.c.inc | 2 +-
14
target/arm/translate-sve.c | 13 ++++---------
14
1 file changed, 1 insertion(+), 1 deletion(-)
15
2 files changed, 8 insertions(+), 13 deletions(-)
16
15
17
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.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/target/arm/sve_helper.c
18
--- a/fpu/softfloat-parts.c.inc
20
+++ b/target/arm/sve_helper.c
19
+++ b/fpu/softfloat-parts.c.inc
21
@@ -XXX,XX +XXX,XX @@ static uint8_t reverse_bits_8(uint8_t x, int n)
20
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
22
21
}
23
void HELPER(sve_rev_p)(void *vd, void *vn, uint32_t pred_desc)
22
ret = c;
24
{
23
} else {
25
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
24
- FloatPartsN *val[3] = { a, b, c };
26
- int esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
25
+ FloatPartsN *val[R_3NAN_1ST_MASK + 1] = { a, b, c };
27
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
26
Float3NaNPropRule rule = s->float_3nan_prop_rule;
28
+ int esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
27
29
intptr_t i, oprsz_2 = oprsz / 2;
28
assert(rule != float_3nan_prop_none);
30
31
if (oprsz <= 8) {
32
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_rev_p)(void *vd, void *vn, uint32_t pred_desc)
33
34
void HELPER(sve_punpk_p)(void *vd, void *vn, uint32_t pred_desc)
35
{
36
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
37
- intptr_t high = extract32(pred_desc, SIMD_DATA_SHIFT + 2, 1);
38
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
39
+ intptr_t high = FIELD_EX32(pred_desc, PREDDESC, DATA);
40
uint64_t *d = vd;
41
intptr_t i;
42
43
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/arm/translate-sve.c
46
+++ b/target/arm/translate-sve.c
47
@@ -XXX,XX +XXX,XX @@ static bool do_perm_pred2(DisasContext *s, arg_rr_esz *a, bool high_odd,
48
TCGv_ptr t_d = tcg_temp_new_ptr();
49
TCGv_ptr t_n = tcg_temp_new_ptr();
50
TCGv_i32 t_desc;
51
- int desc;
52
+ uint32_t desc = 0;
53
54
tcg_gen_addi_ptr(t_d, cpu_env, pred_full_reg_offset(s, a->rd));
55
tcg_gen_addi_ptr(t_n, cpu_env, pred_full_reg_offset(s, a->rn));
56
57
- /* Predicate sizes may be smaller and cannot use simd_desc.
58
- We cannot round up, as we do elsewhere, because we need
59
- the exact size for ZIP2 and REV. We retain the style for
60
- the other helpers for consistency. */
61
-
62
- desc = vsz - 2;
63
- desc = deposit32(desc, SIMD_DATA_SHIFT, 2, a->esz);
64
- desc = deposit32(desc, SIMD_DATA_SHIFT + 2, 2, high_odd);
65
+ desc = FIELD_DP32(desc, PREDDESC, OPRSZ, vsz);
66
+ desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz);
67
+ desc = FIELD_DP32(desc, PREDDESC, DATA, high_odd);
68
t_desc = tcg_const_i32(desc);
69
70
fn(t_d, t_n, t_desc);
71
--
29
--
72
2.20.1
30
2.34.1
73
31
74
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
The interface for object_property_add_bool is simpler,
3
This function is part of the public interface and
4
making the code easier to understand.
4
is not "specialized" to any target in any way.
5
5
6
Reviewed-by: Andrew Jones <drjones@redhat.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210111235740.462469-4-richard.henderson@linaro.org
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20241203203949.483774-7-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
10
---
11
target/arm/cpu64.c | 24 ++++++++++--------------
11
fpu/softfloat.c | 52 ++++++++++++++++++++++++++++++++++
12
1 file changed, 10 insertions(+), 14 deletions(-)
12
fpu/softfloat-specialize.c.inc | 52 ----------------------------------
13
2 files changed, 52 insertions(+), 52 deletions(-)
13
14
14
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
15
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
15
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu64.c
17
--- a/fpu/softfloat.c
17
+++ b/target/arm/cpu64.c
18
+++ b/fpu/softfloat.c
18
@@ -XXX,XX +XXX,XX @@ static void cpu_max_set_sve_max_vq(Object *obj, Visitor *v, const char *name,
19
@@ -XXX,XX +XXX,XX @@ void normalizeFloatx80Subnormal(uint64_t aSig, int32_t *zExpPtr,
19
cpu->sve_max_vq = max_vq;
20
*zExpPtr = 1 - shiftCount;
20
}
21
}
21
22
22
+/*
23
+/*----------------------------------------------------------------------------
23
+ * Note that cpu_arm_get/set_sve_vq cannot use the simpler
24
+| Takes two extended double-precision floating-point values `a' and `b', one
24
+ * object_property_add_bool interface because they make use
25
+| of which is a NaN, and returns the appropriate NaN result. If either `a' or
25
+ * of the contents of "name" to determine which bit on which
26
+| `b' is a signaling NaN, the invalid exception is raised.
26
+ * to operate.
27
+*----------------------------------------------------------------------------*/
27
+ */
28
+
28
static void cpu_arm_get_sve_vq(Object *obj, Visitor *v, const char *name,
29
+floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status)
29
void *opaque, Error **errp)
30
+{
30
{
31
+ bool aIsLargerSignificand;
31
@@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve_vq(Object *obj, Visitor *v, const char *name,
32
+ FloatClass a_cls, b_cls;
32
set_bit(vq - 1, cpu->sve_vq_init);
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
79
index XXXXXXX..XXXXXXX 100644
80
--- a/fpu/softfloat-specialize.c.inc
81
+++ b/fpu/softfloat-specialize.c.inc
82
@@ -XXX,XX +XXX,XX @@ floatx80 floatx80_silence_nan(floatx80 a, float_status *status)
83
return a;
33
}
84
}
34
85
35
-static void cpu_arm_get_sve(Object *obj, Visitor *v, const char *name,
86
-/*----------------------------------------------------------------------------
36
- void *opaque, Error **errp)
87
-| Takes two extended double-precision floating-point values `a' and `b', one
37
+static bool cpu_arm_get_sve(Object *obj, Error **errp)
88
-| of which is a NaN, and returns the appropriate NaN result. If either `a' or
38
{
89
-| `b' is a signaling NaN, the invalid exception is raised.
39
ARMCPU *cpu = ARM_CPU(obj);
90
-*----------------------------------------------------------------------------*/
40
- bool value = cpu_isar_feature(aa64_sve, cpu);
41
-
91
-
42
- visit_type_bool(v, name, &value, errp);
92
-floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status)
43
+ return cpu_isar_feature(aa64_sve, cpu);
93
-{
44
}
94
- bool aIsLargerSignificand;
45
95
- FloatClass a_cls, b_cls;
46
-static void cpu_arm_set_sve(Object *obj, Visitor *v, const char *name,
96
-
47
- void *opaque, Error **errp)
97
- /* This is not complete, but is good enough for pickNaN. */
48
+static void cpu_arm_set_sve(Object *obj, bool value, Error **errp)
98
- a_cls = (!floatx80_is_any_nan(a)
49
{
99
- ? float_class_normal
50
ARMCPU *cpu = ARM_CPU(obj);
100
- : floatx80_is_signaling_nan(a, status)
51
- bool value;
101
- ? float_class_snan
52
uint64_t t;
102
- : float_class_qnan);
53
103
- b_cls = (!floatx80_is_any_nan(b)
54
- if (!visit_type_bool(v, name, &value, errp)) {
104
- ? float_class_normal
55
- return;
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);
56
- }
111
- }
57
-
112
-
58
if (value && kvm_enabled() && !kvm_arm_sve_supported()) {
113
- if (status->default_nan_mode) {
59
error_setg(errp, "'sve' feature not supported by KVM on this host");
114
- return floatx80_default_nan(status);
60
return;
115
- }
61
@@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj)
116
-
62
{
117
- if (a.low < b.low) {
63
uint32_t vq;
118
- aIsLargerSignificand = 0;
64
119
- } else if (b.low < a.low) {
65
- object_property_add(obj, "sve", "bool", cpu_arm_get_sve,
120
- aIsLargerSignificand = 1;
66
- cpu_arm_set_sve, NULL, NULL);
121
- } else {
67
+ object_property_add_bool(obj, "sve", cpu_arm_get_sve, cpu_arm_set_sve);
122
- aIsLargerSignificand = (a.high < b.high) ? 1 : 0;
68
123
- }
69
for (vq = 1; vq <= ARM_MAX_VQ; ++vq) {
124
-
70
char name[8];
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.
71
--
141
--
72
2.20.1
142
2.34.1
73
74
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 two were odd, in that do_pfirst_pnext passed the
3
Unpacking and repacking the parts may be slightly more work
4
count of 64-bit words rather than bytes. Change to pass
4
than we did before, but we get to reuse more code. For a
5
the standard pred_full_reg_size to avoid confusion.
5
code path handling exceptional values, this is an improvement.
6
6
7
Cc: qemu-stable@nongnu.org
8
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20210113062650.593824-3-richard.henderson@linaro.org
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>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
target/arm/sve_helper.c | 7 ++++---
12
fpu/softfloat.c | 43 +++++--------------------------------------
14
target/arm/translate-sve.c | 6 +++---
13
1 file changed, 5 insertions(+), 38 deletions(-)
15
2 files changed, 7 insertions(+), 6 deletions(-)
16
14
17
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
15
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/sve_helper.c
17
--- a/fpu/softfloat.c
20
+++ b/target/arm/sve_helper.c
18
+++ b/fpu/softfloat.c
21
@@ -XXX,XX +XXX,XX @@ static intptr_t last_active_element(uint64_t *g, intptr_t words, intptr_t esz)
19
@@ -XXX,XX +XXX,XX @@ void normalizeFloatx80Subnormal(uint64_t aSig, int32_t *zExpPtr,
22
return (intptr_t)-1 << esz;
20
21
floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status)
22
{
23
- bool aIsLargerSignificand;
24
- FloatClass a_cls, b_cls;
25
+ FloatParts128 pa, pb, *pr;
26
27
- /* This is not complete, but is good enough for pickNaN. */
28
- a_cls = (!floatx80_is_any_nan(a)
29
- ? float_class_normal
30
- : floatx80_is_signaling_nan(a, status)
31
- ? float_class_snan
32
- : float_class_qnan);
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);
47
}
48
49
- if (a.low < b.low) {
50
- aIsLargerSignificand = 0;
51
- } else if (b.low < a.low) {
52
- aIsLargerSignificand = 1;
53
- } else {
54
- aIsLargerSignificand = (a.high < b.high) ? 1 : 0;
55
- }
56
-
57
- if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) {
58
- if (is_snan(b_cls)) {
59
- return floatx80_silence_nan(b, status);
60
- }
61
- return b;
62
- } else {
63
- if (is_snan(a_cls)) {
64
- return floatx80_silence_nan(a, status);
65
- }
66
- return a;
67
- }
68
+ pr = parts_pick_nan(&pa, &pb, status);
69
+ return floatx80_round_pack_canonical(pr, status);
23
}
70
}
24
71
25
-uint32_t HELPER(sve_pfirst)(void *vd, void *vg, uint32_t words)
72
/*----------------------------------------------------------------------------
26
+uint32_t HELPER(sve_pfirst)(void *vd, void *vg, uint32_t pred_desc)
27
{
28
+ intptr_t words = DIV_ROUND_UP(FIELD_EX32(pred_desc, PREDDESC, OPRSZ), 8);
29
uint32_t flags = PREDTEST_INIT;
30
uint64_t *d = vd, *g = vg;
31
intptr_t i = 0;
32
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_pfirst)(void *vd, void *vg, uint32_t words)
33
34
uint32_t HELPER(sve_pnext)(void *vd, void *vg, uint32_t pred_desc)
35
{
36
- intptr_t words = extract32(pred_desc, 0, SIMD_OPRSZ_BITS);
37
- intptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
38
+ intptr_t words = DIV_ROUND_UP(FIELD_EX32(pred_desc, PREDDESC, OPRSZ), 8);
39
+ intptr_t esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
40
uint32_t flags = PREDTEST_INIT;
41
uint64_t *d = vd, *g = vg, esz_mask;
42
intptr_t i, next;
43
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/target/arm/translate-sve.c
46
+++ b/target/arm/translate-sve.c
47
@@ -XXX,XX +XXX,XX @@ static bool do_pfirst_pnext(DisasContext *s, arg_rr_esz *a,
48
TCGv_ptr t_pd = tcg_temp_new_ptr();
49
TCGv_ptr t_pg = tcg_temp_new_ptr();
50
TCGv_i32 t;
51
- unsigned desc;
52
+ unsigned desc = 0;
53
54
- desc = DIV_ROUND_UP(pred_full_reg_size(s), 8);
55
- desc = deposit32(desc, SIMD_DATA_SHIFT, 2, a->esz);
56
+ desc = FIELD_DP32(desc, PREDDESC, OPRSZ, pred_full_reg_size(s));
57
+ desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz);
58
59
tcg_gen_addi_ptr(t_pd, cpu_env, pred_full_reg_offset(s, a->rd));
60
tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, a->rn));
61
--
73
--
62
2.20.1
74
2.34.1
63
64
diff view generated by jsdifflib
1
From: Mihai Carabas <mihai.carabas@oracle.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
To ease the PCI device addition in next patches, split the code as follows:
3
Inline pickNaN into its only caller. This makes one assert
4
- generic code (read/write/setup) is being kept in pvpanic.c
4
redundant with the immediately preceding IF.
5
- ISA dependent code moved to pvpanic-isa.c
5
6
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Also, rename:
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
- ISA_PVPANIC_DEVICE -> PVPANIC_ISA_DEVICE.
8
Message-id: 20241203203949.483774-9-richard.henderson@linaro.org
9
- TYPE_PVPANIC -> TYPE_PVPANIC_ISA.
10
- MemoryRegion io -> mr.
11
- pvpanic_ioport_* in pvpanic_*.
12
13
Update the build system with the new files and config structure.
14
15
Signed-off-by: Mihai Carabas <mihai.carabas@oracle.com>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
10
---
19
include/hw/misc/pvpanic.h | 23 +++++++++-
11
fpu/softfloat-parts.c.inc | 82 +++++++++++++++++++++++++----
20
hw/misc/pvpanic-isa.c | 94 +++++++++++++++++++++++++++++++++++++++
12
fpu/softfloat-specialize.c.inc | 96 ----------------------------------
21
hw/misc/pvpanic.c | 85 +++--------------------------------
13
2 files changed, 73 insertions(+), 105 deletions(-)
22
hw/i386/Kconfig | 2 +-
14
23
hw/misc/Kconfig | 6 ++-
15
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
24
hw/misc/meson.build | 3 +-
25
tests/qtest/meson.build | 2 +-
26
7 files changed, 130 insertions(+), 85 deletions(-)
27
create mode 100644 hw/misc/pvpanic-isa.c
28
29
diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h
30
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
31
--- a/include/hw/misc/pvpanic.h
17
--- a/fpu/softfloat-parts.c.inc
32
+++ b/include/hw/misc/pvpanic.h
18
+++ b/fpu/softfloat-parts.c.inc
33
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static void partsN(return_nan)(FloatPartsN *a, float_status *s)
34
20
static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
35
#include "qom/object.h"
21
float_status *s)
36
22
{
37
-#define TYPE_PVPANIC "pvpanic"
23
+ int cmp, which;
38
+#define TYPE_PVPANIC_ISA_DEVICE "pvpanic"
39
40
#define PVPANIC_IOPORT_PROP "ioport"
41
42
+/* The bit of supported pv event, TODO: include uapi header and remove this */
43
+#define PVPANIC_F_PANICKED 0
44
+#define PVPANIC_F_CRASHLOADED 1
45
+
24
+
46
+/* The pv event value */
25
if (is_snan(a->cls) || is_snan(b->cls)) {
47
+#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED)
26
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
48
+#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED)
27
}
28
29
if (s->default_nan_mode) {
30
parts_default_nan(a, s);
31
- } else {
32
- int cmp = frac_cmp(a, b);
33
- if (cmp == 0) {
34
- cmp = a->sign < b->sign;
35
- }
36
+ return a;
37
+ }
38
39
- if (pickNaN(a->cls, b->cls, cmp > 0, s)) {
40
- a = b;
41
- }
42
+ cmp = frac_cmp(a, b);
43
+ if (cmp == 0) {
44
+ cmp = a->sign < b->sign;
45
+ }
49
+
46
+
50
+/*
47
+ switch (s->float_2nan_prop_rule) {
51
+ * PVPanicState for any device type
48
+ case float_2nan_prop_s_ab:
52
+ */
49
if (is_snan(a->cls)) {
53
+typedef struct PVPanicState PVPanicState;
50
- parts_silence_nan(a, s);
54
+struct PVPanicState {
51
+ which = 0;
55
+ MemoryRegion mr;
52
+ } else if (is_snan(b->cls)) {
56
+ uint8_t events;
53
+ which = 1;
57
+};
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
+ }
58
+
108
+
59
+void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size);
109
+ if (which) {
60
+
110
+ a = b;
61
static inline uint16_t pvpanic_port(void)
111
+ }
62
{
112
+ if (is_snan(a->cls)) {
63
- Object *o = object_resolve_path_type("", TYPE_PVPANIC, NULL);
113
+ parts_silence_nan(a, s);
64
+ Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA_DEVICE, NULL);
65
if (!o) {
66
return 0;
67
}
114
}
68
diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c
115
return a;
69
new file mode 100644
116
}
70
index XXXXXXX..XXXXXXX
117
diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc
71
--- /dev/null
72
+++ b/hw/misc/pvpanic-isa.c
73
@@ -XXX,XX +XXX,XX @@
74
+/*
75
+ * QEMU simulated pvpanic device.
76
+ *
77
+ * Copyright Fujitsu, Corp. 2013
78
+ *
79
+ * Authors:
80
+ * Wen Congyang <wency@cn.fujitsu.com>
81
+ * Hu Tao <hutao@cn.fujitsu.com>
82
+ *
83
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
84
+ * See the COPYING file in the top-level directory.
85
+ *
86
+ */
87
+
88
+#include "qemu/osdep.h"
89
+#include "qemu/log.h"
90
+#include "qemu/module.h"
91
+#include "sysemu/runstate.h"
92
+
93
+#include "hw/nvram/fw_cfg.h"
94
+#include "hw/qdev-properties.h"
95
+#include "hw/misc/pvpanic.h"
96
+#include "qom/object.h"
97
+#include "hw/isa/isa.h"
98
+
99
+OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE)
100
+
101
+/*
102
+ * PVPanicISAState for ISA device and
103
+ * use ioport.
104
+ */
105
+struct PVPanicISAState {
106
+ ISADevice parent_obj;
107
+
108
+ uint16_t ioport;
109
+ PVPanicState pvpanic;
110
+};
111
+
112
+static void pvpanic_isa_initfn(Object *obj)
113
+{
114
+ PVPanicISAState *s = PVPANIC_ISA_DEVICE(obj);
115
+
116
+ pvpanic_setup_io(&s->pvpanic, DEVICE(s), 1);
117
+}
118
+
119
+static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
120
+{
121
+ ISADevice *d = ISA_DEVICE(dev);
122
+ PVPanicISAState *s = PVPANIC_ISA_DEVICE(dev);
123
+ PVPanicState *ps = &s->pvpanic;
124
+ FWCfgState *fw_cfg = fw_cfg_find();
125
+ uint16_t *pvpanic_port;
126
+
127
+ if (!fw_cfg) {
128
+ return;
129
+ }
130
+
131
+ pvpanic_port = g_malloc(sizeof(*pvpanic_port));
132
+ *pvpanic_port = cpu_to_le16(s->ioport);
133
+ fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port,
134
+ sizeof(*pvpanic_port));
135
+
136
+ isa_register_ioport(d, &ps->mr, s->ioport);
137
+}
138
+
139
+static Property pvpanic_isa_properties[] = {
140
+ DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505),
141
+ DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
142
+ DEFINE_PROP_END_OF_LIST(),
143
+};
144
+
145
+static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
146
+{
147
+ DeviceClass *dc = DEVICE_CLASS(klass);
148
+
149
+ dc->realize = pvpanic_isa_realizefn;
150
+ device_class_set_props(dc, pvpanic_isa_properties);
151
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
152
+}
153
+
154
+static TypeInfo pvpanic_isa_info = {
155
+ .name = TYPE_PVPANIC_ISA_DEVICE,
156
+ .parent = TYPE_ISA_DEVICE,
157
+ .instance_size = sizeof(PVPanicISAState),
158
+ .instance_init = pvpanic_isa_initfn,
159
+ .class_init = pvpanic_isa_class_init,
160
+};
161
+
162
+static void pvpanic_register_types(void)
163
+{
164
+ type_register_static(&pvpanic_isa_info);
165
+}
166
+
167
+type_init(pvpanic_register_types)
168
diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
169
index XXXXXXX..XXXXXXX 100644
118
index XXXXXXX..XXXXXXX 100644
170
--- a/hw/misc/pvpanic.c
119
--- a/fpu/softfloat-specialize.c.inc
171
+++ b/hw/misc/pvpanic.c
120
+++ b/fpu/softfloat-specialize.c.inc
172
@@ -XXX,XX +XXX,XX @@
121
@@ -XXX,XX +XXX,XX @@ bool float32_is_signaling_nan(float32 a_, float_status *status)
173
#include "hw/misc/pvpanic.h"
174
#include "qom/object.h"
175
176
-/* The bit of supported pv event, TODO: include uapi header and remove this */
177
-#define PVPANIC_F_PANICKED 0
178
-#define PVPANIC_F_CRASHLOADED 1
179
-
180
-/* The pv event value */
181
-#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED)
182
-#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED)
183
-
184
-typedef struct PVPanicState PVPanicState;
185
-DECLARE_INSTANCE_CHECKER(PVPanicState, ISA_PVPANIC_DEVICE,
186
- TYPE_PVPANIC)
187
-
188
static void handle_event(int event)
189
{
190
static bool logged;
191
@@ -XXX,XX +XXX,XX @@ static void handle_event(int event)
192
}
122
}
193
}
123
}
194
124
195
-#include "hw/isa/isa.h"
125
-/*----------------------------------------------------------------------------
126
-| Select which NaN to propagate for a two-input operation.
127
-| IEEE754 doesn't specify all the details of this, so the
128
-| algorithm is target-specific.
129
-| The routine is passed various bits of information about the
130
-| two NaNs and should return 0 to select NaN a and 1 for NaN b.
131
-| Note that signalling NaNs are always squashed to quiet NaNs
132
-| by the caller, by calling floatXX_silence_nan() before
133
-| returning them.
134
-|
135
-| aIsLargerSignificand is only valid if both a and b are NaNs
136
-| of some kind, and is true if a has the larger significand,
137
-| or if both a and b have the same significand but a is
138
-| positive but b is negative. It is only needed for the x87
139
-| tie-break rule.
140
-*----------------------------------------------------------------------------*/
196
-
141
-
197
-struct PVPanicState {
142
-static int pickNaN(FloatClass a_cls, FloatClass b_cls,
198
- ISADevice parent_obj;
143
- bool aIsLargerSignificand, float_status *status)
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);
199
-
152
-
200
- MemoryRegion io;
153
- switch (status->float_2nan_prop_rule) {
201
- uint16_t ioport;
154
- case float_2nan_prop_s_ab:
202
- uint8_t events;
155
- if (is_snan(a_cls)) {
203
-};
156
- return 0;
204
-
157
- } else if (is_snan(b_cls)) {
205
/* return supported events on read */
158
- return 1;
206
-static uint64_t pvpanic_ioport_read(void *opaque, hwaddr addr, unsigned size)
159
- } else if (is_qnan(a_cls)) {
207
+static uint64_t pvpanic_read(void *opaque, hwaddr addr, unsigned size)
160
- return 0;
208
{
161
- } else {
209
PVPanicState *pvp = opaque;
162
- return 1;
210
return pvp->events;
163
- }
211
}
164
- break;
212
165
- case float_2nan_prop_s_ba:
213
-static void pvpanic_ioport_write(void *opaque, hwaddr addr, uint64_t val,
166
- if (is_snan(b_cls)) {
214
+static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val,
167
- return 1;
215
unsigned size)
168
- } else if (is_snan(a_cls)) {
216
{
169
- return 0;
217
handle_event(val);
170
- } else if (is_qnan(b_cls)) {
218
}
171
- return 1;
219
172
- } else {
220
static const MemoryRegionOps pvpanic_ops = {
173
- return 0;
221
- .read = pvpanic_ioport_read,
174
- }
222
- .write = pvpanic_ioport_write,
175
- break;
223
+ .read = pvpanic_read,
176
- case float_2nan_prop_ab:
224
+ .write = pvpanic_write,
177
- if (is_nan(a_cls)) {
225
.impl = {
178
- return 0;
226
.min_access_size = 1,
179
- } else {
227
.max_access_size = 1,
180
- return 1;
228
},
181
- }
229
};
182
- break;
230
183
- case float_2nan_prop_ba:
231
-static void pvpanic_isa_initfn(Object *obj)
184
- if (is_nan(b_cls)) {
232
+void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size)
185
- return 1;
233
{
186
- } else {
234
- PVPanicState *s = ISA_PVPANIC_DEVICE(obj);
187
- return 0;
235
-
188
- }
236
- memory_region_init_io(&s->io, OBJECT(s), &pvpanic_ops, s, "pvpanic", 1);
189
- break;
237
+ memory_region_init_io(&s->mr, OBJECT(dev), &pvpanic_ops, s, "pvpanic", size);
190
- case float_2nan_prop_x87:
238
}
191
- /*
239
-
192
- * This implements x87 NaN propagation rules:
240
-static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
193
- * SNaN + QNaN => return the QNaN
241
-{
194
- * two SNaNs => return the one with the larger significand, silenced
242
- ISADevice *d = ISA_DEVICE(dev);
195
- * two QNaNs => return the one with the larger significand
243
- PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
196
- * SNaN and a non-NaN => return the SNaN, silenced
244
- FWCfgState *fw_cfg = fw_cfg_find();
197
- * QNaN and a non-NaN => return the QNaN
245
- uint16_t *pvpanic_port;
198
- *
246
-
199
- * If we get down to comparing significands and they are the same,
247
- if (!fw_cfg) {
200
- * return the NaN with the positive sign bit (if any).
248
- return;
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();
249
- }
218
- }
250
-
251
- pvpanic_port = g_malloc(sizeof(*pvpanic_port));
252
- *pvpanic_port = cpu_to_le16(s->ioport);
253
- fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port,
254
- sizeof(*pvpanic_port));
255
-
256
- isa_register_ioport(d, &s->io, s->ioport);
257
-}
219
-}
258
-
220
-
259
-static Property pvpanic_isa_properties[] = {
221
/*----------------------------------------------------------------------------
260
- DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicState, ioport, 0x505),
222
| Returns 1 if the double-precision floating-point value `a' is a quiet
261
- DEFINE_PROP_UINT8("events", PVPanicState, events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED),
223
| NaN; otherwise returns 0.
262
- DEFINE_PROP_END_OF_LIST(),
263
-};
264
-
265
-static void pvpanic_isa_class_init(ObjectClass *klass, void *data)
266
-{
267
- DeviceClass *dc = DEVICE_CLASS(klass);
268
-
269
- dc->realize = pvpanic_isa_realizefn;
270
- device_class_set_props(dc, pvpanic_isa_properties);
271
- set_bit(DEVICE_CATEGORY_MISC, dc->categories);
272
-}
273
-
274
-static TypeInfo pvpanic_isa_info = {
275
- .name = TYPE_PVPANIC,
276
- .parent = TYPE_ISA_DEVICE,
277
- .instance_size = sizeof(PVPanicState),
278
- .instance_init = pvpanic_isa_initfn,
279
- .class_init = pvpanic_isa_class_init,
280
-};
281
-
282
-static void pvpanic_register_types(void)
283
-{
284
- type_register_static(&pvpanic_isa_info);
285
-}
286
-
287
-type_init(pvpanic_register_types)
288
diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
289
index XXXXXXX..XXXXXXX 100644
290
--- a/hw/i386/Kconfig
291
+++ b/hw/i386/Kconfig
292
@@ -XXX,XX +XXX,XX @@ config PC
293
imply ISA_DEBUG
294
imply PARALLEL
295
imply PCI_DEVICES
296
- imply PVPANIC
297
+ imply PVPANIC_ISA
298
imply QXL
299
imply SEV
300
imply SGA
301
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
302
index XXXXXXX..XXXXXXX 100644
303
--- a/hw/misc/Kconfig
304
+++ b/hw/misc/Kconfig
305
@@ -XXX,XX +XXX,XX @@ config IOTKIT_SYSCTL
306
config IOTKIT_SYSINFO
307
bool
308
309
-config PVPANIC
310
+config PVPANIC_COMMON
311
+ bool
312
+
313
+config PVPANIC_ISA
314
bool
315
depends on ISA_BUS
316
+ select PVPANIC_COMMON
317
318
config AUX
319
bool
320
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
321
index XXXXXXX..XXXXXXX 100644
322
--- a/hw/misc/meson.build
323
+++ b/hw/misc/meson.build
324
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_EMC141X', if_true: files('emc141x.c'))
325
softmmu_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c'))
326
softmmu_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c'))
327
softmmu_ss.add(when: 'CONFIG_LED', if_true: files('led.c'))
328
+softmmu_ss.add(when: 'CONFIG_PVPANIC_COMMON', if_true: files('pvpanic.c'))
329
330
# ARM devices
331
softmmu_ss.add(when: 'CONFIG_PL310', if_true: files('arm_l2x0.c'))
332
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_IOTKIT_SYSINFO', if_true: files('iotkit-sysinfo.c')
333
softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c'))
334
softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c'))
335
336
-softmmu_ss.add(when: 'CONFIG_PVPANIC', if_true: files('pvpanic.c'))
337
+softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c'))
338
softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c'))
339
softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c'))
340
softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c'))
341
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
342
index XXXXXXX..XXXXXXX 100644
343
--- a/tests/qtest/meson.build
344
+++ b/tests/qtest/meson.build
345
@@ -XXX,XX +XXX,XX @@ qtests_i386 = \
346
(config_host.has_key('CONFIG_LINUX') and \
347
config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \
348
(config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \
349
- (config_all_devices.has_key('CONFIG_PVPANIC') ? ['pvpanic-test'] : []) + \
350
+ (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \
351
(config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \
352
(config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \
353
(config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \
354
--
224
--
355
2.20.1
225
2.34.1
356
226
357
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
Update all users of do_perm_pred3 for the new
3
Remember if there was an SNaN, and use that to simplify
4
predicate descriptor field definitions.
4
float_2nan_prop_s_{ab,ba} to only the snan component.
5
Then, fall through to the corresponding
6
float_2nan_prop_{ab,ba} case to handle any remaining
7
nans, which must be quiet.
5
8
6
Cc: qemu-stable@nongnu.org
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210113062650.593824-4-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20241203203949.483774-10-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
13
---
12
target/arm/sve_helper.c | 18 +++++++++---------
14
fpu/softfloat-parts.c.inc | 32 ++++++++++++--------------------
13
target/arm/translate-sve.c | 12 ++++--------
15
1 file changed, 12 insertions(+), 20 deletions(-)
14
2 files changed, 13 insertions(+), 17 deletions(-)
15
16
16
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
17
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/sve_helper.c
19
--- a/fpu/softfloat-parts.c.inc
19
+++ b/target/arm/sve_helper.c
20
+++ b/fpu/softfloat-parts.c.inc
20
@@ -XXX,XX +XXX,XX @@ static uint64_t compress_bits(uint64_t x, int n)
21
@@ -XXX,XX +XXX,XX @@ static void partsN(return_nan)(FloatPartsN *a, float_status *s)
21
22
static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
22
void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
23
float_status *s)
23
{
24
{
24
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
25
+ bool have_snan = false;
25
- int esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
26
int cmp, which;
26
- intptr_t high = extract32(pred_desc, SIMD_DATA_SHIFT + 2, 1);
27
27
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
28
if (is_snan(a->cls) || is_snan(b->cls)) {
28
+ int esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
29
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
29
+ intptr_t high = FIELD_EX32(pred_desc, PREDDESC, DATA);
30
+ have_snan = true;
30
uint64_t *d = vd;
31
}
31
intptr_t i;
32
32
33
if (s->default_nan_mode) {
33
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
34
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
34
35
35
void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
36
switch (s->float_2nan_prop_rule) {
36
{
37
case float_2nan_prop_s_ab:
37
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
38
- if (is_snan(a->cls)) {
38
- int esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
39
- which = 0;
39
- int odd = extract32(pred_desc, SIMD_DATA_SHIFT + 2, 1) << esz;
40
- } else if (is_snan(b->cls)) {
40
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
41
- which = 1;
41
+ int esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
42
- } else if (is_qnan(a->cls)) {
42
+ int odd = FIELD_EX32(pred_desc, PREDDESC, DATA) << esz;
43
- which = 0;
43
uint64_t *d = vd, *n = vn, *m = vm;
44
- } else {
44
uint64_t l, h;
45
- which = 1;
45
intptr_t i;
46
+ if (have_snan) {
46
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
47
+ which = is_snan(a->cls) ? 0 : 1;
47
48
+ break;
48
void HELPER(sve_trn_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
49
}
49
{
50
- break;
50
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
51
- case float_2nan_prop_s_ba:
51
- uintptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
52
- if (is_snan(b->cls)) {
52
- bool odd = extract32(pred_desc, SIMD_DATA_SHIFT + 2, 1);
53
- which = 1;
53
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
54
- } else if (is_snan(a->cls)) {
54
+ int esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
55
- which = 0;
55
+ int odd = FIELD_EX32(pred_desc, PREDDESC, DATA);
56
- } else if (is_qnan(b->cls)) {
56
uint64_t *d = vd, *n = vn, *m = vm;
57
- which = 1;
57
uint64_t mask;
58
- } else {
58
int shr, shl;
59
- which = 0;
59
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
60
- }
60
index XXXXXXX..XXXXXXX 100644
61
- break;
61
--- a/target/arm/translate-sve.c
62
+ /* fall through */
62
+++ b/target/arm/translate-sve.c
63
case float_2nan_prop_ab:
63
@@ -XXX,XX +XXX,XX @@ static bool do_perm_pred3(DisasContext *s, arg_rrr_esz *a, bool high_odd,
64
which = is_nan(a->cls) ? 0 : 1;
64
65
break;
65
unsigned vsz = pred_full_reg_size(s);
66
+ case float_2nan_prop_s_ba:
66
67
+ if (have_snan) {
67
- /* Predicate sizes may be smaller and cannot use simd_desc.
68
+ which = is_snan(b->cls) ? 1 : 0;
68
- We cannot round up, as we do elsewhere, because we need
69
+ break;
69
- the exact size for ZIP2 and REV. We retain the style for
70
+ }
70
- the other helpers for consistency. */
71
+ /* fall through */
71
TCGv_ptr t_d = tcg_temp_new_ptr();
72
case float_2nan_prop_ba:
72
TCGv_ptr t_n = tcg_temp_new_ptr();
73
which = is_nan(b->cls) ? 1 : 0;
73
TCGv_ptr t_m = tcg_temp_new_ptr();
74
break;
74
TCGv_i32 t_desc;
75
- int desc;
76
+ uint32_t desc = 0;
77
78
- desc = vsz - 2;
79
- desc = deposit32(desc, SIMD_DATA_SHIFT, 2, a->esz);
80
- desc = deposit32(desc, SIMD_DATA_SHIFT + 2, 2, high_odd);
81
+ desc = FIELD_DP32(desc, PREDDESC, OPRSZ, vsz);
82
+ desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz);
83
+ desc = FIELD_DP32(desc, PREDDESC, DATA, high_odd);
84
85
tcg_gen_addi_ptr(t_d, cpu_env, pred_full_reg_offset(s, a->rd));
86
tcg_gen_addi_ptr(t_n, cpu_env, pred_full_reg_offset(s, a->rn));
87
--
75
--
88
2.20.1
76
2.34.1
89
90
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Do not assume that EL2 is available in and only in non-secure context.
3
Move the fractional comparison to the end of the
4
That equivalence is broken by ARMv8.4-SEL2.
4
float_2nan_prop_x87 case. This is not required for
5
any other 2nan propagation rule. Reorganize the
6
x87 case itself to break out of the switch when the
7
fractional comparison is not required.
5
8
6
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20210112104511.36576-3-remi.denis.courmont@huawei.com
11
Message-id: 20241203203949.483774-11-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
13
---
11
target/arm/cpu.h | 4 ++--
14
fpu/softfloat-parts.c.inc | 19 +++++++++----------
12
target/arm/helper-a64.c | 8 +-------
15
1 file changed, 9 insertions(+), 10 deletions(-)
13
target/arm/helper.c | 33 +++++++++++++--------------------
14
3 files changed, 16 insertions(+), 29 deletions(-)
15
16
16
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
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/cpu.h
19
--- a/fpu/softfloat-parts.c.inc
19
+++ b/target/arm/cpu.h
20
+++ b/fpu/softfloat-parts.c.inc
20
@@ -XXX,XX +XXX,XX @@ static inline bool arm_el_is_aa64(CPUARMState *env, int el)
21
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
21
return aa64;
22
return a;
22
}
23
}
23
24
24
- if (arm_feature(env, ARM_FEATURE_EL2) && !arm_is_secure_below_el3(env)) {
25
- cmp = frac_cmp(a, b);
25
+ if (arm_is_el2_enabled(env)) {
26
- if (cmp == 0) {
26
aa64 = aa64 && (env->cp15.hcr_el2 & HCR_RW);
27
- cmp = a->sign < b->sign;
27
}
28
29
@@ -XXX,XX +XXX,XX @@ static inline int arm_debug_target_el(CPUARMState *env)
30
bool secure = arm_is_secure(env);
31
bool route_to_el2 = false;
32
33
- if (arm_feature(env, ARM_FEATURE_EL2) && !secure) {
34
+ if (arm_is_el2_enabled(env)) {
35
route_to_el2 = env->cp15.hcr_el2 & HCR_TGE ||
36
env->cp15.mdcr_el2 & MDCR_TDE;
37
}
38
diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c
39
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/helper-a64.c
41
+++ b/target/arm/helper-a64.c
42
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
43
if (new_el == -1) {
44
goto illegal_return;
45
}
46
- if (new_el > cur_el
47
- || (new_el == 2 && !arm_feature(env, ARM_FEATURE_EL2))) {
48
+ if (new_el > cur_el || (new_el == 2 && !arm_is_el2_enabled(env))) {
49
/* Disallow return to an EL which is unimplemented or higher
50
* than the current one.
51
*/
52
@@ -XXX,XX +XXX,XX @@ void HELPER(exception_return)(CPUARMState *env, uint64_t new_pc)
53
goto illegal_return;
54
}
55
56
- if (new_el == 2 && arm_is_secure_below_el3(env)) {
57
- /* Return to the non-existent secure-EL2 */
58
- goto illegal_return;
59
- }
28
- }
60
-
29
-
61
if (new_el == 1 && (arm_hcr_el2_eff(env) & HCR_TGE)) {
30
switch (s->float_2nan_prop_rule) {
62
goto illegal_return;
31
case float_2nan_prop_s_ab:
63
}
32
if (have_snan) {
64
diff --git a/target/arm/helper.c b/target/arm/helper.c
33
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
65
index XXXXXXX..XXXXXXX 100644
34
* return the NaN with the positive sign bit (if any).
66
--- a/target/arm/helper.c
35
*/
67
+++ b/target/arm/helper.c
36
if (is_snan(a->cls)) {
68
@@ -XXX,XX +XXX,XX @@ static CPAccessResult cpacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
37
- if (is_snan(b->cls)) {
69
{
38
- which = cmp > 0 ? 0 : 1;
70
if (arm_feature(env, ARM_FEATURE_V8)) {
39
- } else {
71
/* Check if CPACR accesses are to be trapped to EL2 */
40
+ if (!is_snan(b->cls)) {
72
- if (arm_current_el(env) == 1 &&
41
which = is_qnan(b->cls) ? 1 : 0;
73
- (env->cp15.cptr_el[2] & CPTR_TCPAC) && !arm_is_secure(env)) {
42
+ break;
74
+ if (arm_current_el(env) == 1 && arm_is_el2_enabled(env) &&
43
}
75
+ (env->cp15.cptr_el[2] & CPTR_TCPAC)) {
44
} else if (is_qnan(a->cls)) {
76
return CP_ACCESS_TRAP_EL2;
45
if (is_snan(b->cls) || !is_qnan(b->cls)) {
77
/* Check if CPACR accesses are to be trapped to EL3 */
46
which = 0;
78
} else if (arm_current_el(env) < 3 &&
47
- } else {
79
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx,
48
- which = cmp > 0 ? 0 : 1;
80
bool isread)
49
+ break;
81
{
82
unsigned int cur_el = arm_current_el(env);
83
- bool secure = arm_is_secure(env);
84
+ bool has_el2 = arm_is_el2_enabled(env);
85
uint64_t hcr = arm_hcr_el2_eff(env);
86
87
switch (cur_el) {
88
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx,
89
}
50
}
90
} else {
51
} else {
91
/* If HCR_EL2.<E2H> == 0: check CNTHCTL_EL2.EL1PCEN. */
52
which = 1;
92
- if (arm_feature(env, ARM_FEATURE_EL2) &&
53
+ break;
93
- timeridx == GTIMER_PHYS && !secure &&
94
+ if (has_el2 && timeridx == GTIMER_PHYS &&
95
!extract32(env->cp15.cnthctl_el2, 1, 1)) {
96
return CP_ACCESS_TRAP_EL2;
97
}
98
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx,
99
100
case 1:
101
/* Check CNTHCTL_EL2.EL1PCTEN, which changes location based on E2H. */
102
- if (arm_feature(env, ARM_FEATURE_EL2) &&
103
- timeridx == GTIMER_PHYS && !secure &&
104
+ if (has_el2 && timeridx == GTIMER_PHYS &&
105
(hcr & HCR_E2H
106
? !extract32(env->cp15.cnthctl_el2, 10, 1)
107
: !extract32(env->cp15.cnthctl_el2, 0, 1))) {
108
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_timer_access(CPUARMState *env, int timeridx,
109
bool isread)
110
{
111
unsigned int cur_el = arm_current_el(env);
112
- bool secure = arm_is_secure(env);
113
+ bool has_el2 = arm_is_el2_enabled(env);
114
uint64_t hcr = arm_hcr_el2_eff(env);
115
116
switch (cur_el) {
117
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_timer_access(CPUARMState *env, int timeridx,
118
/* fall through */
119
120
case 1:
121
- if (arm_feature(env, ARM_FEATURE_EL2) &&
122
- timeridx == GTIMER_PHYS && !secure) {
123
+ if (has_el2 && timeridx == GTIMER_PHYS) {
124
if (hcr & HCR_E2H) {
125
/* If HCR_EL2.<E2H,TGE> == '10': check CNTHCTL_EL2.EL1PTEN. */
126
if (!extract32(env->cp15.cnthctl_el2, 11, 1)) {
127
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo strongarm_cp_reginfo[] = {
128
129
static uint64_t midr_read(CPUARMState *env, const ARMCPRegInfo *ri)
130
{
131
- ARMCPU *cpu = env_archcpu(env);
132
unsigned int cur_el = arm_current_el(env);
133
- bool secure = arm_is_secure(env);
134
135
- if (arm_feature(&cpu->env, ARM_FEATURE_EL2) && !secure && cur_el == 1) {
136
+ if (arm_is_el2_enabled(env) && cur_el == 1) {
137
return env->cp15.vpidr_el2;
138
}
139
return raw_read(env, ri);
140
@@ -XXX,XX +XXX,XX @@ static uint64_t mpidr_read_val(CPUARMState *env)
141
static uint64_t mpidr_read(CPUARMState *env, const ARMCPRegInfo *ri)
142
{
143
unsigned int cur_el = arm_current_el(env);
144
- bool secure = arm_is_secure(env);
145
146
- if (arm_feature(env, ARM_FEATURE_EL2) && !secure && cur_el == 1) {
147
+ if (arm_is_el2_enabled(env) && cur_el == 1) {
148
return env->cp15.vmpidr_el2;
149
}
150
return mpidr_read_val(env);
151
@@ -XXX,XX +XXX,XX @@ uint64_t arm_hcr_el2_eff(CPUARMState *env)
152
{
153
uint64_t ret = env->cp15.hcr_el2;
154
155
- if (arm_is_secure_below_el3(env)) {
156
+ if (!arm_is_el2_enabled(env)) {
157
/*
158
* "This register has no effect if EL2 is not enabled in the
159
* current Security state". This is ARMv8.4-SecEL2 speak for
160
@@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el)
161
/* CPTR_EL2. Since TZ and TFP are positive,
162
* they will be zero when EL2 is not present.
163
*/
164
- if (el <= 2 && !arm_is_secure_below_el3(env)) {
165
+ if (el <= 2 && arm_is_el2_enabled(env)) {
166
if (env->cp15.cptr_el[2] & CPTR_TZ) {
167
return 2;
168
}
54
}
169
@@ -XXX,XX +XXX,XX @@ static int bad_mode_switch(CPUARMState *env, int mode, CPSRWriteType write_type)
55
+ cmp = frac_cmp(a, b);
170
}
56
+ if (cmp == 0) {
171
return 0;
57
+ cmp = a->sign < b->sign;
172
case ARM_CPU_MODE_HYP:
58
+ }
173
- return !arm_feature(env, ARM_FEATURE_EL2)
59
+ which = cmp > 0 ? 0 : 1;
174
- || arm_current_el(env) < 2 || arm_is_secure_below_el3(env);
60
break;
175
+ return !arm_is_el2_enabled(env) || arm_current_el(env) < 2;
176
case ARM_CPU_MODE_MON:
177
return arm_current_el(env) < 3;
178
default:
61
default:
179
@@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el)
62
g_assert_not_reached();
180
181
/* CPTR_EL2 : present in v7VE or v8 */
182
if (cur_el <= 2 && extract32(env->cp15.cptr_el[2], 10, 1)
183
- && !arm_is_secure_below_el3(env)) {
184
+ && arm_is_el2_enabled(env)) {
185
/* Trap FP ops at EL2, NS-EL1 or NS-EL0 to EL2 */
186
return 2;
187
}
188
--
63
--
189
2.20.1
64
2.34.1
190
191
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This adds the MMU indices for EL2 stage 1 in secure state.
3
Replace the "index" selecting between A and B with a result variable
4
of the proper type. This improves clarity within the function.
4
5
5
To keep code contained, which is largelly identical between secure and
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
non-secure modes, the MMU indices are reassigned. The new assignments
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
provide a systematic pattern with a non-secure bit.
8
Message-id: 20241203203949.483774-12-richard.henderson@linaro.org
8
9
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20210112104511.36576-8-remi.denis.courmont@huawei.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
10
---
14
target/arm/cpu-param.h | 2 +-
11
fpu/softfloat-parts.c.inc | 28 +++++++++++++---------------
15
target/arm/cpu.h | 35 ++++++----
12
1 file changed, 13 insertions(+), 15 deletions(-)
16
target/arm/internals.h | 12 ++++
17
target/arm/helper.c | 127 ++++++++++++++++++++++++-------------
18
target/arm/translate-a64.c | 4 ++
19
5 files changed, 123 insertions(+), 57 deletions(-)
20
13
21
diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h
14
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
22
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/cpu-param.h
16
--- a/fpu/softfloat-parts.c.inc
24
+++ b/target/arm/cpu-param.h
17
+++ b/fpu/softfloat-parts.c.inc
25
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
26
# define TARGET_PAGE_BITS_MIN 10
19
float_status *s)
27
#endif
28
29
-#define NB_MMU_MODES 11
30
+#define NB_MMU_MODES 15
31
32
#endif
33
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
34
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/cpu.h
36
+++ b/target/arm/cpu.h
37
@@ -XXX,XX +XXX,XX @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync);
38
#define ARM_MMU_IDX_NOTLB 0x20 /* does not have a TLB */
39
#define ARM_MMU_IDX_M 0x40 /* M profile */
40
41
+/* Meanings of the bits for A profile mmu idx values */
42
+#define ARM_MMU_IDX_A_NS 0x8
43
+
44
/* Meanings of the bits for M profile mmu idx values */
45
#define ARM_MMU_IDX_M_PRIV 0x1
46
#define ARM_MMU_IDX_M_NEGPRI 0x2
47
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdx {
48
/*
49
* A-profile.
50
*/
51
- ARMMMUIdx_E10_0 = 0 | ARM_MMU_IDX_A,
52
- ARMMMUIdx_E20_0 = 1 | ARM_MMU_IDX_A,
53
+ ARMMMUIdx_SE10_0 = 0 | ARM_MMU_IDX_A,
54
+ ARMMMUIdx_SE20_0 = 1 | ARM_MMU_IDX_A,
55
+ ARMMMUIdx_SE10_1 = 2 | ARM_MMU_IDX_A,
56
+ ARMMMUIdx_SE20_2 = 3 | ARM_MMU_IDX_A,
57
+ ARMMMUIdx_SE10_1_PAN = 4 | ARM_MMU_IDX_A,
58
+ ARMMMUIdx_SE20_2_PAN = 5 | ARM_MMU_IDX_A,
59
+ ARMMMUIdx_SE2 = 6 | ARM_MMU_IDX_A,
60
+ ARMMMUIdx_SE3 = 7 | ARM_MMU_IDX_A,
61
62
- ARMMMUIdx_E10_1 = 2 | ARM_MMU_IDX_A,
63
- ARMMMUIdx_E10_1_PAN = 3 | ARM_MMU_IDX_A,
64
-
65
- ARMMMUIdx_E2 = 4 | ARM_MMU_IDX_A,
66
- ARMMMUIdx_E20_2 = 5 | ARM_MMU_IDX_A,
67
- ARMMMUIdx_E20_2_PAN = 6 | ARM_MMU_IDX_A,
68
-
69
- ARMMMUIdx_SE10_0 = 7 | ARM_MMU_IDX_A,
70
- ARMMMUIdx_SE10_1 = 8 | ARM_MMU_IDX_A,
71
- ARMMMUIdx_SE10_1_PAN = 9 | ARM_MMU_IDX_A,
72
- ARMMMUIdx_SE3 = 10 | ARM_MMU_IDX_A,
73
+ ARMMMUIdx_E10_0 = ARMMMUIdx_SE10_0 | ARM_MMU_IDX_A_NS,
74
+ ARMMMUIdx_E20_0 = ARMMMUIdx_SE20_0 | ARM_MMU_IDX_A_NS,
75
+ ARMMMUIdx_E10_1 = ARMMMUIdx_SE10_1 | ARM_MMU_IDX_A_NS,
76
+ ARMMMUIdx_E20_2 = ARMMMUIdx_SE20_2 | ARM_MMU_IDX_A_NS,
77
+ ARMMMUIdx_E10_1_PAN = ARMMMUIdx_SE10_1_PAN | ARM_MMU_IDX_A_NS,
78
+ ARMMMUIdx_E20_2_PAN = ARMMMUIdx_SE20_2_PAN | ARM_MMU_IDX_A_NS,
79
+ ARMMMUIdx_E2 = ARMMMUIdx_SE2 | ARM_MMU_IDX_A_NS,
80
81
/*
82
* These are not allocated TLBs and are used only for AT system
83
@@ -XXX,XX +XXX,XX @@ typedef enum ARMMMUIdxBit {
84
TO_CORE_BIT(E20_2),
85
TO_CORE_BIT(E20_2_PAN),
86
TO_CORE_BIT(SE10_0),
87
+ TO_CORE_BIT(SE20_0),
88
TO_CORE_BIT(SE10_1),
89
+ TO_CORE_BIT(SE20_2),
90
TO_CORE_BIT(SE10_1_PAN),
91
+ TO_CORE_BIT(SE20_2_PAN),
92
+ TO_CORE_BIT(SE2),
93
TO_CORE_BIT(SE3),
94
95
TO_CORE_BIT(MUser),
96
diff --git a/target/arm/internals.h b/target/arm/internals.h
97
index XXXXXXX..XXXXXXX 100644
98
--- a/target/arm/internals.h
99
+++ b/target/arm/internals.h
100
@@ -XXX,XX +XXX,XX @@ static inline bool regime_has_2_ranges(ARMMMUIdx mmu_idx)
101
case ARMMMUIdx_SE10_0:
102
case ARMMMUIdx_SE10_1:
103
case ARMMMUIdx_SE10_1_PAN:
104
+ case ARMMMUIdx_SE20_0:
105
+ case ARMMMUIdx_SE20_2:
106
+ case ARMMMUIdx_SE20_2_PAN:
107
return true;
108
default:
109
return false;
110
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx)
111
case ARMMMUIdx_SE10_0:
112
case ARMMMUIdx_SE10_1:
113
case ARMMMUIdx_SE10_1_PAN:
114
+ case ARMMMUIdx_SE20_0:
115
+ case ARMMMUIdx_SE20_2:
116
+ case ARMMMUIdx_SE20_2_PAN:
117
+ case ARMMMUIdx_SE2:
118
case ARMMMUIdx_MSPrivNegPri:
119
case ARMMMUIdx_MSUserNegPri:
120
case ARMMMUIdx_MSPriv:
121
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx)
122
case ARMMMUIdx_E10_1_PAN:
123
case ARMMMUIdx_E20_2_PAN:
124
case ARMMMUIdx_SE10_1_PAN:
125
+ case ARMMMUIdx_SE20_2_PAN:
126
return true;
127
default:
128
return false;
129
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx)
130
static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)
131
{
20
{
132
switch (mmu_idx) {
21
bool have_snan = false;
133
+ case ARMMMUIdx_SE20_0:
22
- int cmp, which;
134
+ case ARMMMUIdx_SE20_2:
23
+ FloatPartsN *ret;
135
+ case ARMMMUIdx_SE20_2_PAN:
24
+ int cmp;
136
case ARMMMUIdx_E20_0:
25
137
case ARMMMUIdx_E20_2:
26
if (is_snan(a->cls) || is_snan(b->cls)) {
138
case ARMMMUIdx_E20_2_PAN:
27
float_raise(float_flag_invalid | float_flag_invalid_snan, s);
139
case ARMMMUIdx_Stage2:
28
@@ -XXX,XX +XXX,XX @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b,
140
+ case ARMMMUIdx_SE2:
29
switch (s->float_2nan_prop_rule) {
141
case ARMMMUIdx_E2:
30
case float_2nan_prop_s_ab:
142
return 2;
31
if (have_snan) {
143
case ARMMMUIdx_SE3:
32
- which = is_snan(a->cls) ? 0 : 1;
144
diff --git a/target/arm/helper.c b/target/arm/helper.c
33
+ ret = is_snan(a->cls) ? a : b;
145
index XXXXXXX..XXXXXXX 100644
146
--- a/target/arm/helper.c
147
+++ b/target/arm/helper.c
148
@@ -XXX,XX +XXX,XX @@ static int gt_phys_redir_timeridx(CPUARMState *env)
149
case ARMMMUIdx_E20_0:
150
case ARMMMUIdx_E20_2:
151
case ARMMMUIdx_E20_2_PAN:
152
+ case ARMMMUIdx_SE20_0:
153
+ case ARMMMUIdx_SE20_2:
154
+ case ARMMMUIdx_SE20_2_PAN:
155
return GTIMER_HYP;
156
default:
157
return GTIMER_PHYS;
158
@@ -XXX,XX +XXX,XX @@ static int gt_virt_redir_timeridx(CPUARMState *env)
159
case ARMMMUIdx_E20_0:
160
case ARMMMUIdx_E20_2:
161
case ARMMMUIdx_E20_2_PAN:
162
+ case ARMMMUIdx_SE20_0:
163
+ case ARMMMUIdx_SE20_2:
164
+ case ARMMMUIdx_SE20_2_PAN:
165
return GTIMER_HYPVIRT;
166
default:
167
return GTIMER_VIRT;
168
@@ -XXX,XX +XXX,XX @@ static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
169
mmu_idx = ARMMMUIdx_SE3;
170
break;
34
break;
171
case 2:
35
}
172
- g_assert(!secure); /* TODO: ARMv8.4-SecEL2 */
36
/* fall through */
173
+ g_assert(!secure); /* ARMv8.4-SecEL2 is 64-bit only */
37
case float_2nan_prop_ab:
174
/* fall through */
38
- which = is_nan(a->cls) ? 0 : 1;
175
case 1:
39
+ ret = is_nan(a->cls) ? a : b;
176
if (ri->crm == 9 && (env->uncached_cpsr & CPSR_PAN)) {
40
break;
177
@@ -XXX,XX +XXX,XX @@ static void ats_write64(CPUARMState *env, const ARMCPRegInfo *ri,
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;
178
}
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;
179
break;
71
break;
180
case 4: /* AT S1E2R, AT S1E2W */
181
- mmu_idx = ARMMMUIdx_E2;
182
+ mmu_idx = secure ? ARMMMUIdx_SE2 : ARMMMUIdx_E2;
183
break;
184
case 6: /* AT S1E3R, AT S1E3W */
185
mmu_idx = ARMMMUIdx_SE3;
186
@@ -XXX,XX +XXX,XX @@ static void vmsa_tcr_ttbr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri,
187
*/
188
if (extract64(raw_read(env, ri) ^ value, 48, 16) &&
189
(arm_hcr_el2_eff(env) & HCR_E2H)) {
190
- tlb_flush_by_mmuidx(env_cpu(env),
191
- ARMMMUIdxBit_E20_2 |
192
- ARMMMUIdxBit_E20_2_PAN |
193
- ARMMMUIdxBit_E20_0);
194
+ uint16_t mask = ARMMMUIdxBit_E20_2 |
195
+ ARMMMUIdxBit_E20_2_PAN |
196
+ ARMMMUIdxBit_E20_0;
197
+
198
+ if (arm_is_secure_below_el3(env)) {
199
+ mask >>= ARM_MMU_IDX_A_NS;
200
+ }
201
+
202
+ tlb_flush_by_mmuidx(env_cpu(env), mask);
203
}
204
raw_write(env, ri, value);
205
}
206
@@ -XXX,XX +XXX,XX @@ static int vae1_tlbmask(CPUARMState *env)
207
uint64_t hcr = arm_hcr_el2_eff(env);
208
209
if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) {
210
- return ARMMMUIdxBit_E20_2 |
211
- ARMMMUIdxBit_E20_2_PAN |
212
- ARMMMUIdxBit_E20_0;
213
+ uint16_t mask = ARMMMUIdxBit_E20_2 |
214
+ ARMMMUIdxBit_E20_2_PAN |
215
+ ARMMMUIdxBit_E20_0;
216
+
217
+ if (arm_is_secure_below_el3(env)) {
218
+ mask >>= ARM_MMU_IDX_A_NS;
219
+ }
220
+
221
+ return mask;
222
} else if (arm_is_secure_below_el3(env)) {
223
return ARMMMUIdxBit_SE10_1 |
224
ARMMMUIdxBit_SE10_1_PAN |
225
@@ -XXX,XX +XXX,XX @@ static int tlbbits_for_regime(CPUARMState *env, ARMMMUIdx mmu_idx,
226
227
static int vae1_tlbbits(CPUARMState *env, uint64_t addr)
228
{
229
+ uint64_t hcr = arm_hcr_el2_eff(env);
230
ARMMMUIdx mmu_idx;
231
232
/* Only the regime of the mmu_idx below is significant. */
233
- if (arm_is_secure_below_el3(env)) {
234
- mmu_idx = ARMMMUIdx_SE10_0;
235
- } else if ((env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE))
236
- == (HCR_E2H | HCR_TGE)) {
237
+ if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) {
238
mmu_idx = ARMMMUIdx_E20_0;
239
} else {
240
mmu_idx = ARMMMUIdx_E10_0;
241
}
242
+
243
+ if (arm_is_secure_below_el3(env)) {
244
+ mmu_idx &= ~ARM_MMU_IDX_A_NS;
245
+ }
246
+
247
return tlbbits_for_regime(env, mmu_idx, addr);
248
}
249
250
@@ -XXX,XX +XXX,XX @@ static int alle1_tlbmask(CPUARMState *env)
251
252
static int e2_tlbmask(CPUARMState *env)
253
{
254
- /* TODO: ARMv8.4-SecEL2 */
255
- return ARMMMUIdxBit_E20_0 |
256
- ARMMMUIdxBit_E20_2 |
257
- ARMMMUIdxBit_E20_2_PAN |
258
- ARMMMUIdxBit_E2;
259
+ if (arm_is_secure_below_el3(env)) {
260
+ return ARMMMUIdxBit_SE20_0 |
261
+ ARMMMUIdxBit_SE20_2 |
262
+ ARMMMUIdxBit_SE20_2_PAN |
263
+ ARMMMUIdxBit_SE2;
264
+ } else {
265
+ return ARMMMUIdxBit_E20_0 |
266
+ ARMMMUIdxBit_E20_2 |
267
+ ARMMMUIdxBit_E20_2_PAN |
268
+ ARMMMUIdxBit_E2;
269
+ }
270
}
271
272
static void tlbi_aa64_alle1_write(CPUARMState *env, const ARMCPRegInfo *ri,
273
@@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
274
{
275
CPUState *cs = env_cpu(env);
276
uint64_t pageaddr = sextract64(value << 12, 0, 56);
277
- int bits = tlbbits_for_regime(env, ARMMMUIdx_E2, pageaddr);
278
+ bool secure = arm_is_secure_below_el3(env);
279
+ int mask = secure ? ARMMMUIdxBit_SE2 : ARMMMUIdxBit_E2;
280
+ int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2,
281
+ pageaddr);
282
283
- tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr,
284
- ARMMMUIdxBit_E2, bits);
285
+ tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, mask, bits);
286
}
287
288
static void tlbi_aa64_vae3is_write(CPUARMState *env, const ARMCPRegInfo *ri,
289
@@ -XXX,XX +XXX,XX @@ uint64_t arm_sctlr(CPUARMState *env, int el)
290
/* Only EL0 needs to be adjusted for EL1&0 or EL2&0. */
291
if (el == 0) {
292
ARMMMUIdx mmu_idx = arm_mmu_idx_el(env, 0);
293
- el = (mmu_idx == ARMMMUIdx_E20_0 ? 2 : 1);
294
+ el = (mmu_idx == ARMMMUIdx_E20_0 || mmu_idx == ARMMMUIdx_SE20_0)
295
+ ? 2 : 1;
296
}
297
return env->cp15.sctlr_el[el];
298
}
299
@@ -XXX,XX +XXX,XX @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx)
300
switch (mmu_idx) {
301
case ARMMMUIdx_SE10_0:
302
case ARMMMUIdx_E20_0:
303
+ case ARMMMUIdx_SE20_0:
304
case ARMMMUIdx_Stage1_E0:
305
case ARMMMUIdx_MUser:
306
case ARMMMUIdx_MSUser:
307
@@ -XXX,XX +XXX,XX @@ int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
308
case ARMMMUIdx_E10_0:
309
case ARMMMUIdx_E20_0:
310
case ARMMMUIdx_SE10_0:
311
+ case ARMMMUIdx_SE20_0:
312
return 0;
313
case ARMMMUIdx_E10_1:
314
case ARMMMUIdx_E10_1_PAN:
315
@@ -XXX,XX +XXX,XX @@ int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
316
case ARMMMUIdx_E2:
317
case ARMMMUIdx_E20_2:
318
case ARMMMUIdx_E20_2_PAN:
319
+ case ARMMMUIdx_SE2:
320
+ case ARMMMUIdx_SE20_2:
321
+ case ARMMMUIdx_SE20_2_PAN:
322
return 2;
323
case ARMMMUIdx_SE3:
324
return 3;
325
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
326
327
ARMMMUIdx arm_mmu_idx_el(CPUARMState *env, int el)
328
{
329
+ ARMMMUIdx idx;
330
+ uint64_t hcr;
331
+
332
if (arm_feature(env, ARM_FEATURE_M)) {
333
return arm_v7m_mmu_idx_for_secstate(env, env->v7m.secure);
334
}
335
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_mmu_idx_el(CPUARMState *env, int el)
336
/* See ARM pseudo-function ELIsInHost. */
337
switch (el) {
338
case 0:
339
- if (arm_is_secure_below_el3(env)) {
340
- return ARMMMUIdx_SE10_0;
341
+ hcr = arm_hcr_el2_eff(env);
342
+ if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) {
343
+ idx = ARMMMUIdx_E20_0;
344
+ } else {
345
+ idx = ARMMMUIdx_E10_0;
346
}
72
}
347
- if ((env->cp15.hcr_el2 & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)
73
cmp = frac_cmp(a, b);
348
- && arm_el_is_aa64(env, 2)) {
74
if (cmp == 0) {
349
- return ARMMMUIdx_E20_0;
75
cmp = a->sign < b->sign;
350
- }
351
- return ARMMMUIdx_E10_0;
352
+ break;
353
case 1:
354
- if (arm_is_secure_below_el3(env)) {
355
- if (env->pstate & PSTATE_PAN) {
356
- return ARMMMUIdx_SE10_1_PAN;
357
- }
358
- return ARMMMUIdx_SE10_1;
359
- }
360
if (env->pstate & PSTATE_PAN) {
361
- return ARMMMUIdx_E10_1_PAN;
362
+ idx = ARMMMUIdx_E10_1_PAN;
363
+ } else {
364
+ idx = ARMMMUIdx_E10_1;
365
}
76
}
366
- return ARMMMUIdx_E10_1;
77
- which = cmp > 0 ? 0 : 1;
367
+ break;
78
+ ret = cmp > 0 ? a : b;
368
case 2:
79
break;
369
- /* TODO: ARMv8.4-SecEL2 */
370
/* Note that TGE does not apply at EL2. */
371
- if ((env->cp15.hcr_el2 & HCR_E2H) && arm_el_is_aa64(env, 2)) {
372
+ if (arm_hcr_el2_eff(env) & HCR_E2H) {
373
if (env->pstate & PSTATE_PAN) {
374
- return ARMMMUIdx_E20_2_PAN;
375
+ idx = ARMMMUIdx_E20_2_PAN;
376
+ } else {
377
+ idx = ARMMMUIdx_E20_2;
378
}
379
- return ARMMMUIdx_E20_2;
380
+ } else {
381
+ idx = ARMMMUIdx_E2;
382
}
383
- return ARMMMUIdx_E2;
384
+ break;
385
case 3:
386
return ARMMMUIdx_SE3;
387
default:
80
default:
388
g_assert_not_reached();
81
g_assert_not_reached();
389
}
82
}
390
+
83
391
+ if (arm_is_secure_below_el3(env)) {
84
- if (which) {
392
+ idx &= ~ARM_MMU_IDX_A_NS;
85
- a = b;
393
+ }
86
+ if (is_snan(ret->cls)) {
394
+
87
+ parts_silence_nan(ret, s);
395
+ return idx;
88
}
89
- if (is_snan(a->cls)) {
90
- parts_silence_nan(a, s);
91
- }
92
- return a;
93
+ return ret;
396
}
94
}
397
95
398
ARMMMUIdx arm_mmu_idx(CPUARMState *env)
96
static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,
399
@@ -XXX,XX +XXX,XX @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
400
break;
401
case ARMMMUIdx_E20_2:
402
case ARMMMUIdx_E20_2_PAN:
403
- /* TODO: ARMv8.4-SecEL2 */
404
+ case ARMMMUIdx_SE20_2:
405
+ case ARMMMUIdx_SE20_2_PAN:
406
/*
407
* Note that EL20_2 is gated by HCR_EL2.E2H == 1, but EL20_0 is
408
* gated by HCR_EL2.<E2H,TGE> == '11', and so is LDTR.
409
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
410
index XXXXXXX..XXXXXXX 100644
411
--- a/target/arm/translate-a64.c
412
+++ b/target/arm/translate-a64.c
413
@@ -XXX,XX +XXX,XX @@ static int get_a64_user_mem_index(DisasContext *s)
414
case ARMMMUIdx_SE10_1_PAN:
415
useridx = ARMMMUIdx_SE10_0;
416
break;
417
+ case ARMMMUIdx_SE20_2:
418
+ case ARMMMUIdx_SE20_2_PAN:
419
+ useridx = ARMMMUIdx_SE20_0;
420
+ break;
421
default:
422
g_assert_not_reached();
423
}
424
--
97
--
425
2.20.1
98
2.34.1
426
99
427
100
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Leif Lindholm <quic_llindhol@quicinc.com>
2
2
3
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
3
I'm migrating to Qualcomm's new open source email infrastructure, so
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
4
update my email address, and update the mailmap to match.
5
Message-id: 20210112104511.36576-12-remi.denis.courmont@huawei.com
5
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
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
13
---
8
target/arm/helper.c | 12 ++++++++++++
14
MAINTAINERS | 2 +-
9
1 file changed, 12 insertions(+)
15
.mailmap | 5 +++--
16
2 files changed, 4 insertions(+), 3 deletions(-)
10
17
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
diff --git a/MAINTAINERS b/MAINTAINERS
12
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
20
--- a/MAINTAINERS
14
+++ b/target/arm/helper.c
21
+++ b/MAINTAINERS
15
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
22
@@ -XXX,XX +XXX,XX @@ F: include/hw/ssi/imx_spi.h
16
fi->s1ptw = true;
23
SBSA-REF
17
return ~0;
24
M: Radoslaw Biernacki <rad@semihalf.com>
18
}
25
M: Peter Maydell <peter.maydell@linaro.org>
19
+
26
-R: Leif Lindholm <quic_llindhol@quicinc.com>
20
+ if (arm_is_secure_below_el3(env)) {
27
+R: Leif Lindholm <leif.lindholm@oss.qualcomm.com>
21
+ /* Check if page table walk is to secure or non-secure PA space. */
28
R: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
22
+ if (*is_secure) {
29
L: qemu-arm@nongnu.org
23
+ *is_secure = !(env->cp15.vstcr_el2.raw_tcr & VSTCR_SW);
30
S: Maintained
24
+ } else {
31
diff --git a/.mailmap b/.mailmap
25
+ *is_secure = !(env->cp15.vtcr_el2.raw_tcr & VTCR_NSW);
32
index XXXXXXX..XXXXXXX 100644
26
+ }
33
--- a/.mailmap
27
+ } else {
34
+++ b/.mailmap
28
+ assert(!*is_secure);
35
@@ -XXX,XX +XXX,XX @@ Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com>
29
+ }
36
Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn>
30
+
37
James Hogan <jhogan@kernel.org> <james.hogan@imgtec.com>
31
addr = s2pa;
38
Juan Quintela <quintela@trasno.org> <quintela@redhat.com>
32
}
39
-Leif Lindholm <quic_llindhol@quicinc.com> <leif.lindholm@linaro.org>
33
return addr;
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>
34
--
47
--
35
2.20.1
48
2.34.1
36
49
37
50
diff view generated by jsdifflib
1
From: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
1
From: Vikram Garhwal <vikram.garhwal@bytedance.com>
2
2
3
With the ARMv8.4-SEL2 extension, EL2 is a legal exception level in
3
Previously, maintainer role was paused due to inactive email id. Commit id:
4
secure mode, though it can only be AArch64.
4
c009d715721861984c4987bcc78b7ee183e86d75.
5
5
6
This patch adds the target EL for exceptions from 64-bit S-EL2.
6
Signed-off-by: Vikram Garhwal <vikram.garhwal@bytedance.com>
7
7
Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com>
8
It also fixes the target EL to EL2 when HCR.{A,F,I}MO are set in secure
8
Message-id: 20241204184205.12952-1-vikram.garhwal@bytedance.com
9
mode. Those values were never used in practice as the effective value of
10
HCR was always 0 in secure mode.
11
12
Signed-off-by: Rémi Denis-Courmont <remi.denis.courmont@huawei.com>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20210112104511.36576-7-remi.denis.courmont@huawei.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
10
---
17
target/arm/helper.c | 10 +++++-----
11
MAINTAINERS | 2 ++
18
target/arm/op_helper.c | 4 ++--
12
1 file changed, 2 insertions(+)
19
2 files changed, 7 insertions(+), 7 deletions(-)
20
13
21
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
diff --git a/MAINTAINERS b/MAINTAINERS
22
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
23
--- a/target/arm/helper.c
16
--- a/MAINTAINERS
24
+++ b/target/arm/helper.c
17
+++ b/MAINTAINERS
25
@@ -XXX,XX +XXX,XX @@ static const int8_t target_el_table[2][2][2][2][2][4] = {
18
@@ -XXX,XX +XXX,XX @@ F: tests/qtest/fuzz-sb16-test.c
26
{{/* 0 1 1 0 */{ 3, 3, 3, -1 },{ 3, -1, -1, 3 },},
19
27
{/* 0 1 1 1 */{ 3, 3, 3, -1 },{ 3, -1, -1, 3 },},},},},
20
Xilinx CAN
28
{{{{/* 1 0 0 0 */{ 1, 1, 2, -1 },{ 1, 1, -1, 1 },},
21
M: Francisco Iglesias <francisco.iglesias@amd.com>
29
- {/* 1 0 0 1 */{ 2, 2, 2, -1 },{ 1, 1, -1, 1 },},},
22
+M: Vikram Garhwal <vikram.garhwal@bytedance.com>
30
- {{/* 1 0 1 0 */{ 1, 1, 1, -1 },{ 1, 1, -1, 1 },},
23
S: Maintained
31
- {/* 1 0 1 1 */{ 2, 2, 2, -1 },{ 1, 1, -1, 1 },},},},
24
F: hw/net/can/xlnx-*
32
+ {/* 1 0 0 1 */{ 2, 2, 2, -1 },{ 2, 2, -1, 1 },},},
25
F: include/hw/net/xlnx-*
33
+ {{/* 1 0 1 0 */{ 1, 1, 1, -1 },{ 1, 1, 1, 1 },},
26
@@ -XXX,XX +XXX,XX @@ F: include/hw/rx/
34
+ {/* 1 0 1 1 */{ 2, 2, 2, -1 },{ 2, 2, 2, 1 },},},},
27
CAN bus subsystem and hardware
35
{{{/* 1 1 0 0 */{ 3, 3, 3, -1 },{ 3, 3, -1, 3 },},
28
M: Pavel Pisa <pisa@cmp.felk.cvut.cz>
36
{/* 1 1 0 1 */{ 3, 3, 3, -1 },{ 3, 3, -1, 3 },},},
29
M: Francisco Iglesias <francisco.iglesias@amd.com>
37
- {{/* 1 1 1 0 */{ 3, 3, 3, -1 },{ 3, 3, -1, 3 },},
30
+M: Vikram Garhwal <vikram.garhwal@bytedance.com>
38
- {/* 1 1 1 1 */{ 3, 3, 3, -1 },{ 3, 3, -1, 3 },},},},},
31
S: Maintained
39
+ {{/* 1 1 1 0 */{ 3, 3, 3, -1 },{ 3, 3, 3, 3 },},
32
W: https://canbus.pages.fel.cvut.cz/
40
+ {/* 1 1 1 1 */{ 3, 3, 3, -1 },{ 3, 3, 3, 3 },},},},},
33
F: net/can/*
41
};
42
43
/*
44
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/target/arm/op_helper.c
47
+++ b/target/arm/op_helper.c
48
@@ -XXX,XX +XXX,XX @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome,
49
target_el = exception_target_el(env);
50
break;
51
case CP_ACCESS_TRAP_EL2:
52
- /* Requesting a trap to EL2 when we're in EL3 or S-EL0/1 is
53
+ /* Requesting a trap to EL2 when we're in EL3 is
54
* a bug in the access function.
55
*/
56
- assert(!arm_is_secure(env) && arm_current_el(env) != 3);
57
+ assert(arm_current_el(env) != 3);
58
target_el = 2;
59
break;
60
case CP_ACCESS_TRAP_EL3:
61
--
34
--
62
2.20.1
35
2.34.1
63
64
diff view generated by jsdifflib