1
First pullreq for arm of the 4.1 series, since I'm back from
1
The following changes since commit bf4460a8d9a86f6cfe05d7a7f470c48e3a93d8b2:
2
holiday now. This is mostly my M-profile FPU series and Philippe's
3
devices.h cleanup. I have a pile of other patchsets to work through
4
in my to-review folder, but 42 patches is definitely quite
5
big enough to send now...
6
2
7
thanks
3
Merge tag 'pull-tcg-20230123' of https://gitlab.com/rth7680/qemu into staging (2023-02-03 09:30:45 +0000)
8
-- PMM
9
10
The following changes since commit 413a99a92c13ec408dcf2adaa87918dc81e890c8:
11
12
Add Nios II semihosting support. (2019-04-29 16:09:51 +0100)
13
4
14
are available in the Git repository at:
5
are available in the Git repository at:
15
6
16
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190429
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230203
17
8
18
for you to fetch changes up to 437cc27ddfded3bbab6afd5ac1761e0e195edba7:
9
for you to fetch changes up to bb18151d8bd9bedc497ee9d4e8d81b39a4e5bbf6:
19
10
20
hw/devices: Move SMSC 91C111 declaration into a new header (2019-04-29 17:57:21 +0100)
11
target/arm: Enable FEAT_FGT on '-cpu max' (2023-02-03 12:59:24 +0000)
21
12
22
----------------------------------------------------------------
13
----------------------------------------------------------------
23
target-arm queue:
14
target-arm queue:
24
* remove "bag of random stuff" hw/devices.h header
15
* Fix physical address resolution for Stage2
25
* implement FPU for Cortex-M and enable it for Cortex-M4 and -M33
16
* pl011: refactoring, implement reset method
26
* hw/dma: Compile the bcm2835_dma device as common object
17
* Support GICv3 with hvf acceleration
27
* configure: Remove --source-path option
18
* sbsa-ref: remove cortex-a76 from list of supported cpus
28
* hw/ssi/xilinx_spips: Avoid variable length array
19
* Correct syndrome for ATS12NSO* traps at Secure EL1
29
* hw/arm/smmuv3: Remove SMMUNotifierNode
20
* Fix priority of HSTR_EL2 traps vs UNDEFs
21
* Implement FEAT_FGT for '-cpu max'
30
22
31
----------------------------------------------------------------
23
----------------------------------------------------------------
32
Eric Auger (1):
24
Alexander Graf (3):
33
hw/arm/smmuv3: Remove SMMUNotifierNode
25
hvf: arm: Add support for GICv3
26
hw/arm/virt: Consolidate GIC finalize logic
27
hw/arm/virt: Make accels in GIC finalize logic explicit
34
28
35
Peter Maydell (28):
29
Evgeny Iakovlev (4):
36
hw/ssi/xilinx_spips: Avoid variable length array
30
hw/char/pl011: refactor FIFO depth handling code
37
configure: Remove --source-path option
31
hw/char/pl011: add post_load hook for backwards-compatibility
38
target/arm: Make sure M-profile FPSCR RES0 bits are not settable
32
hw/char/pl011: implement a reset method
39
hw/intc/armv7m_nvic: Allow reading of M-profile MVFR* registers
33
hw/char/pl011: better handling of FIFO flags on LCR reset
40
target/arm: Implement dummy versions of M-profile FP-related registers
41
target/arm: Disable most VFP sysregs for M-profile
42
target/arm: Honour M-profile FP enable bits
43
target/arm: Decode FP instructions for M profile
44
target/arm: Clear CONTROL_S.SFPA in SG insn if FPU present
45
target/arm: Handle SFPA and FPCA bits in reads and writes of CONTROL
46
target/arm/helper: don't return early for STKOF faults during stacking
47
target/arm: Handle floating point registers in exception entry
48
target/arm: Implement v7m_update_fpccr()
49
target/arm: Clear CONTROL.SFPA in BXNS and BLXNS
50
target/arm: Clean excReturn bits when tail chaining
51
target/arm: Allow for floating point in callee stack integrity check
52
target/arm: Handle floating point registers in exception return
53
target/arm: Move NS TBFLAG from bit 19 to bit 6
54
target/arm: Overlap VECSTRIDE and XSCALE_CPAR TB flags
55
target/arm: Set FPCCR.S when executing M-profile floating point insns
56
target/arm: Activate M-profile floating point context when FPCCR.ASPEN is set
57
target/arm: New helper function arm_v7m_mmu_idx_all()
58
target/arm: New function armv7m_nvic_set_pending_lazyfp()
59
target/arm: Add lazy-FP-stacking support to v7m_stack_write()
60
target/arm: Implement M-profile lazy FP state preservation
61
target/arm: Implement VLSTM for v7M CPUs with an FPU
62
target/arm: Implement VLLDM for v7M CPUs with an FPU
63
target/arm: Enable FPU for Cortex-M4 and Cortex-M33
64
34
65
Philippe Mathieu-Daudé (13):
35
Marcin Juszkiewicz (1):
66
hw/dma: Compile the bcm2835_dma device as common object
36
sbsa-ref: remove cortex-a76 from list of supported cpus
67
hw/arm/aspeed: Use TYPE_TMP105/TYPE_PCA9552 instead of hardcoded string
68
hw/arm/nseries: Use TYPE_TMP105 instead of hardcoded string
69
hw/display/tc6393xb: Remove unused functions
70
hw/devices: Move TC6393XB declarations into a new header
71
hw/devices: Move Blizzard declarations into a new header
72
hw/devices: Move CBus declarations into a new header
73
hw/devices: Move Gamepad declarations into a new header
74
hw/devices: Move TI touchscreen declarations into a new header
75
hw/devices: Move LAN9118 declarations into a new header
76
hw/net/ne2000-isa: Add guards to the header
77
hw/net/lan9118: Export TYPE_LAN9118 and use it instead of hardcoded string
78
hw/devices: Move SMSC 91C111 declaration into a new header
79
37
80
configure | 10 +-
38
Peter Maydell (23):
81
hw/dma/Makefile.objs | 2 +-
39
target/arm: Name AT_S1E1RP and AT_S1E1WP cpregs correctly
82
include/hw/arm/omap.h | 6 +-
40
target/arm: Correct syndrome for ATS12NSO* at Secure EL1
83
include/hw/arm/smmu-common.h | 8 +-
41
target/arm: Remove CP_ACCESS_TRAP_UNCATEGORIZED_{EL2, EL3}
84
include/hw/devices.h | 62 ---
42
target/arm: Move do_coproc_insn() syndrome calculation earlier
85
include/hw/display/blizzard.h | 22 ++
43
target/arm: All UNDEF-at-EL0 traps take priority over HSTR_EL2 traps
86
include/hw/display/tc6393xb.h | 24 ++
44
target/arm: Make HSTR_EL2 traps take priority over UNDEF-at-EL1
87
include/hw/input/gamepad.h | 19 +
45
target/arm: Disable HSTR_EL2 traps if EL2 is not enabled
88
include/hw/input/tsc2xxx.h | 36 ++
46
target/arm: Define the FEAT_FGT registers
89
include/hw/misc/cbus.h | 32 ++
47
target/arm: Implement FGT trapping infrastructure
90
include/hw/net/lan9118.h | 21 +
48
target/arm: Mark up sysregs for HFGRTR bits 0..11
91
include/hw/net/ne2000-isa.h | 6 +
49
target/arm: Mark up sysregs for HFGRTR bits 12..23
92
include/hw/net/smc91c111.h | 19 +
50
target/arm: Mark up sysregs for HFGRTR bits 24..35
93
include/qemu/typedefs.h | 1 -
51
target/arm: Mark up sysregs for HFGRTR bits 36..63
94
target/arm/cpu.h | 95 ++++-
52
target/arm: Mark up sysregs for HDFGRTR bits 0..11
95
target/arm/helper.h | 5 +
53
target/arm: Mark up sysregs for HDFGRTR bits 12..63
96
target/arm/translate.h | 3 +
54
target/arm: Mark up sysregs for HFGITR bits 0..11
97
hw/arm/aspeed.c | 13 +-
55
target/arm: Mark up sysregs for HFGITR bits 12..17
98
hw/arm/exynos4_boards.c | 3 +-
56
target/arm: Mark up sysregs for HFGITR bits 18..47
99
hw/arm/gumstix.c | 2 +-
57
target/arm: Mark up sysregs for HFGITR bits 48..63
100
hw/arm/integratorcp.c | 2 +-
58
target/arm: Implement the HFGITR_EL2.ERET trap
101
hw/arm/kzm.c | 2 +-
59
target/arm: Implement the HFGITR_EL2.SVC_EL0 and SVC_EL1 traps
102
hw/arm/mainstone.c | 2 +-
60
target/arm: Implement MDCR_EL2.TDCC and MDCR_EL3.TDCC traps
103
hw/arm/mps2-tz.c | 3 +-
61
target/arm: Enable FEAT_FGT on '-cpu max'
104
hw/arm/mps2.c | 2 +-
105
hw/arm/nseries.c | 7 +-
106
hw/arm/palm.c | 2 +-
107
hw/arm/realview.c | 3 +-
108
hw/arm/smmu-common.c | 6 +-
109
hw/arm/smmuv3.c | 28 +-
110
hw/arm/stellaris.c | 2 +-
111
hw/arm/tosa.c | 2 +-
112
hw/arm/versatilepb.c | 2 +-
113
hw/arm/vexpress.c | 2 +-
114
hw/display/blizzard.c | 2 +-
115
hw/display/tc6393xb.c | 18 +-
116
hw/input/stellaris_input.c | 2 +-
117
hw/input/tsc2005.c | 2 +-
118
hw/input/tsc210x.c | 4 +-
119
hw/intc/armv7m_nvic.c | 261 +++++++++++++
120
hw/misc/cbus.c | 2 +-
121
hw/net/lan9118.c | 3 +-
122
hw/net/smc91c111.c | 2 +-
123
hw/ssi/xilinx_spips.c | 6 +-
124
target/arm/cpu.c | 20 +
125
target/arm/helper.c | 873 +++++++++++++++++++++++++++++++++++++++---
126
target/arm/machine.c | 16 +
127
target/arm/translate.c | 150 +++++++-
128
target/arm/vfp_helper.c | 8 +
129
MAINTAINERS | 7 +
130
50 files changed, 1595 insertions(+), 235 deletions(-)
131
delete mode 100644 include/hw/devices.h
132
create mode 100644 include/hw/display/blizzard.h
133
create mode 100644 include/hw/display/tc6393xb.h
134
create mode 100644 include/hw/input/gamepad.h
135
create mode 100644 include/hw/input/tsc2xxx.h
136
create mode 100644 include/hw/misc/cbus.h
137
create mode 100644 include/hw/net/lan9118.h
138
create mode 100644 include/hw/net/smc91c111.h
139
62
63
Richard Henderson (2):
64
hw/arm: Use TYPE_ARM_SMMUV3
65
target/arm: Fix physical address resolution for Stage2
66
67
docs/system/arm/emulation.rst | 1 +
68
include/hw/arm/virt.h | 15 +-
69
include/hw/char/pl011.h | 5 +-
70
target/arm/cpregs.h | 484 +++++++++++++++++++++++++++++++++++++++++-
71
target/arm/cpu.h | 18 ++
72
target/arm/internals.h | 20 ++
73
target/arm/syndrome.h | 10 +
74
target/arm/translate.h | 6 +
75
hw/arm/sbsa-ref.c | 4 +-
76
hw/arm/virt.c | 203 +++++++++---------
77
hw/char/pl011.c | 93 ++++++--
78
hw/intc/arm_gicv3_cpuif.c | 18 +-
79
target/arm/cpu64.c | 1 +
80
target/arm/debug_helper.c | 46 +++-
81
target/arm/helper.c | 245 ++++++++++++++++++++-
82
target/arm/hvf/hvf.c | 151 +++++++++++++
83
target/arm/op_helper.c | 58 ++++-
84
target/arm/ptw.c | 2 +-
85
target/arm/translate-a64.c | 22 +-
86
target/arm/translate.c | 125 +++++++----
87
target/arm/hvf/trace-events | 2 +
88
21 files changed, 1340 insertions(+), 189 deletions(-)
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This commit finally deletes "hw/devices.h".
3
Use the macro instead of two explicit string literals.
4
4
5
Reviewed-by: Markus Armbruster <armbru@redhat.com>
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Message-id: 20190412165416.7977-13-philmd@redhat.com
7
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
Message-id: 20230124232059.4017615-1-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
include/hw/devices.h | 11 -----------
11
hw/arm/sbsa-ref.c | 3 ++-
11
include/hw/net/smc91c111.h | 19 +++++++++++++++++++
12
hw/arm/virt.c | 2 +-
12
hw/arm/gumstix.c | 2 +-
13
2 files changed, 3 insertions(+), 2 deletions(-)
13
hw/arm/integratorcp.c | 2 +-
14
hw/arm/mainstone.c | 2 +-
15
hw/arm/realview.c | 2 +-
16
hw/arm/versatilepb.c | 2 +-
17
hw/net/smc91c111.c | 2 +-
18
8 files changed, 25 insertions(+), 17 deletions(-)
19
delete mode 100644 include/hw/devices.h
20
create mode 100644 include/hw/net/smc91c111.h
21
14
22
diff --git a/include/hw/devices.h b/include/hw/devices.h
15
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
23
deleted file mode 100644
16
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX
17
--- a/hw/arm/sbsa-ref.c
25
--- a/include/hw/devices.h
18
+++ b/hw/arm/sbsa-ref.c
26
+++ /dev/null
27
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
28
-#ifndef QEMU_DEVICES_H
20
#include "exec/hwaddr.h"
29
-#define QEMU_DEVICES_H
21
#include "kvm_arm.h"
30
-
22
#include "hw/arm/boot.h"
31
-/* Devices that have nowhere better to go. */
23
+#include "hw/arm/smmuv3.h"
32
-
24
#include "hw/block/flash.h"
33
-#include "hw/hw.h"
25
#include "hw/boards.h"
34
-
26
#include "hw/ide/internal.h"
35
-/* smc91c111.c */
27
@@ -XXX,XX +XXX,XX @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
36
-void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
28
DeviceState *dev;
37
-
29
int i;
38
-#endif
30
39
diff --git a/include/hw/net/smc91c111.h b/include/hw/net/smc91c111.h
31
- dev = qdev_new("arm-smmuv3");
40
new file mode 100644
32
+ dev = qdev_new(TYPE_ARM_SMMUV3);
41
index XXXXXXX..XXXXXXX
33
42
--- /dev/null
34
object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
43
+++ b/include/hw/net/smc91c111.h
35
&error_abort);
44
@@ -XXX,XX +XXX,XX @@
36
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
45
+/*
46
+ * SMSC 91C111 Ethernet interface emulation
47
+ *
48
+ * Copyright (c) 2005 CodeSourcery, LLC.
49
+ * Written by Paul Brook
50
+ *
51
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
52
+ * See the COPYING file in the top-level directory.
53
+ */
54
+
55
+#ifndef HW_NET_SMC91C111_H
56
+#define HW_NET_SMC91C111_H
57
+
58
+#include "hw/irq.h"
59
+#include "net/net.h"
60
+
61
+void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
62
+
63
+#endif
64
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
65
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
66
--- a/hw/arm/gumstix.c
38
--- a/hw/arm/virt.c
67
+++ b/hw/arm/gumstix.c
39
+++ b/hw/arm/virt.c
68
@@ -XXX,XX +XXX,XX @@
40
@@ -XXX,XX +XXX,XX @@ static void create_smmu(const VirtMachineState *vms,
69
#include "hw/arm/pxa.h"
41
return;
70
#include "net/net.h"
42
}
71
#include "hw/block/flash.h"
43
72
-#include "hw/devices.h"
44
- dev = qdev_new("arm-smmuv3");
73
+#include "hw/net/smc91c111.h"
45
+ dev = qdev_new(TYPE_ARM_SMMUV3);
74
#include "hw/boards.h"
46
75
#include "exec/address-spaces.h"
47
object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
76
#include "sysemu/qtest.h"
48
&error_abort);
77
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/hw/arm/integratorcp.c
80
+++ b/hw/arm/integratorcp.c
81
@@ -XXX,XX +XXX,XX @@
82
#include "qemu-common.h"
83
#include "cpu.h"
84
#include "hw/sysbus.h"
85
-#include "hw/devices.h"
86
#include "hw/boards.h"
87
#include "hw/arm/arm.h"
88
#include "hw/misc/arm_integrator_debug.h"
89
+#include "hw/net/smc91c111.h"
90
#include "net/net.h"
91
#include "exec/address-spaces.h"
92
#include "sysemu/sysemu.h"
93
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
94
index XXXXXXX..XXXXXXX 100644
95
--- a/hw/arm/mainstone.c
96
+++ b/hw/arm/mainstone.c
97
@@ -XXX,XX +XXX,XX @@
98
#include "hw/arm/pxa.h"
99
#include "hw/arm/arm.h"
100
#include "net/net.h"
101
-#include "hw/devices.h"
102
+#include "hw/net/smc91c111.h"
103
#include "hw/boards.h"
104
#include "hw/block/flash.h"
105
#include "hw/sysbus.h"
106
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
107
index XXXXXXX..XXXXXXX 100644
108
--- a/hw/arm/realview.c
109
+++ b/hw/arm/realview.c
110
@@ -XXX,XX +XXX,XX @@
111
#include "hw/sysbus.h"
112
#include "hw/arm/arm.h"
113
#include "hw/arm/primecell.h"
114
-#include "hw/devices.h"
115
#include "hw/net/lan9118.h"
116
+#include "hw/net/smc91c111.h"
117
#include "hw/pci/pci.h"
118
#include "net/net.h"
119
#include "sysemu/sysemu.h"
120
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
121
index XXXXXXX..XXXXXXX 100644
122
--- a/hw/arm/versatilepb.c
123
+++ b/hw/arm/versatilepb.c
124
@@ -XXX,XX +XXX,XX @@
125
#include "cpu.h"
126
#include "hw/sysbus.h"
127
#include "hw/arm/arm.h"
128
-#include "hw/devices.h"
129
+#include "hw/net/smc91c111.h"
130
#include "net/net.h"
131
#include "sysemu/sysemu.h"
132
#include "hw/pci/pci.h"
133
diff --git a/hw/net/smc91c111.c b/hw/net/smc91c111.c
134
index XXXXXXX..XXXXXXX 100644
135
--- a/hw/net/smc91c111.c
136
+++ b/hw/net/smc91c111.c
137
@@ -XXX,XX +XXX,XX @@
138
#include "qemu/osdep.h"
139
#include "hw/sysbus.h"
140
#include "net/net.h"
141
-#include "hw/devices.h"
142
+#include "hw/net/smc91c111.h"
143
#include "qemu/log.h"
144
/* For crc32 */
145
#include <zlib.h>
146
--
49
--
147
2.20.1
50
2.34.1
148
51
149
52
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
This device is used by both ARM (BCM2836, for raspi2) and AArch64
3
Conversion to probe_access_full missed applying the page offset.
4
(BCM2837, for raspi3) targets, and is not CPU-specific.
5
Move it to common object, so we build it once for all targets.
6
4
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Cc: qemu-stable@nongnu.org
8
Message-id: 20190427133028.12874-1-philmd@redhat.com
6
Reported-by: Sid Manning <sidneym@quicinc.com>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Message-id: 20230126233134.103193-1-richard.henderson@linaro.org
10
Fixes: f3639a64f602 ("target/arm: Use softmmu tlbs for page table walking")
11
Signed-off-by: Richard Henderson <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
hw/dma/Makefile.objs | 2 +-
14
target/arm/ptw.c | 2 +-
13
1 file changed, 1 insertion(+), 1 deletion(-)
15
1 file changed, 1 insertion(+), 1 deletion(-)
14
16
15
diff --git a/hw/dma/Makefile.objs b/hw/dma/Makefile.objs
17
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
16
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/dma/Makefile.objs
19
--- a/target/arm/ptw.c
18
+++ b/hw/dma/Makefile.objs
20
+++ b/target/arm/ptw.c
19
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx-zdma.o
21
@@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw,
20
22
if (unlikely(flags & TLB_INVALID_MASK)) {
21
obj-$(CONFIG_OMAP) += omap_dma.o soc_dma.o
23
goto fail;
22
obj-$(CONFIG_PXA2XX) += pxa2xx_dma.o
24
}
23
-obj-$(CONFIG_RASPI) += bcm2835_dma.o
25
- ptw->out_phys = full->phys_addr;
24
+common-obj-$(CONFIG_RASPI) += bcm2835_dma.o
26
+ ptw->out_phys = full->phys_addr | (addr & ~TARGET_PAGE_MASK);
27
ptw->out_rw = full->prot & PAGE_WRITE;
28
pte_attrs = full->pte_attrs;
29
pte_secure = full->attrs.secure;
25
--
30
--
26
2.20.1
31
2.34.1
27
32
28
33
diff view generated by jsdifflib
1
In the v7M architecture, if an exception is generated in the process
1
From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
2
of doing the lazy stacking of FP registers, the handling of
3
possible escalation to HardFault is treated differently to the normal
4
approach: it works based on the saved information about exception
5
readiness that was stored in the FPCCR when the stack frame was
6
created. Provide a new function armv7m_nvic_set_pending_lazyfp()
7
which pends exceptions during lazy stacking, and implements
8
this logic.
9
2
10
This corresponds to the pseudocode TakePreserveFPException().
3
PL011 can be in either of 2 modes depending guest config: FIFO and
4
single register. The last mode could be viewed as a 1-element-deep FIFO.
11
5
6
Current code open-codes a bunch of depth-dependent logic. Refactor FIFO
7
depth handling code to isolate calculating current FIFO depth.
8
9
One functional (albeit guest-invisible) side-effect of this change is
10
that previously we would always increment s->read_pos in UARTDR read
11
handler even if FIFO was disabled, now we are limiting read_pos to not
12
exceed FIFO depth (read_pos itself is reset to 0 if user disables FIFO).
13
14
Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
17
Message-id: 20230123162304.26254-2-eiakovlev@linux.microsoft.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20190416125744.27770-22-peter.maydell@linaro.org
15
---
19
---
16
target/arm/cpu.h | 12 ++++++
20
include/hw/char/pl011.h | 5 ++++-
17
hw/intc/armv7m_nvic.c | 96 +++++++++++++++++++++++++++++++++++++++++++
21
hw/char/pl011.c | 30 ++++++++++++++++++------------
18
2 files changed, 108 insertions(+)
22
2 files changed, 22 insertions(+), 13 deletions(-)
19
23
20
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
24
diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h
21
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/cpu.h
26
--- a/include/hw/char/pl011.h
23
+++ b/target/arm/cpu.h
27
+++ b/include/hw/char/pl011.h
24
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure);
28
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(PL011State, PL011)
25
* a different exception).
29
/* This shares the same struct (and cast macro) as the base pl011 device */
26
*/
30
#define TYPE_PL011_LUMINARY "pl011_luminary"
27
void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure);
31
28
+/**
32
+/* Depth of UART FIFO in bytes, when FIFO mode is enabled (else depth == 1) */
29
+ * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending
33
+#define PL011_FIFO_DEPTH 16
30
+ * @opaque: the NVIC
34
+
31
+ * @irq: the exception number to mark pending
35
struct PL011State {
32
+ * @secure: false for non-banked exceptions or for the nonsecure
36
SysBusDevice parent_obj;
33
+ * version of a banked exception, true for the secure version of a banked
37
34
+ * exception.
38
@@ -XXX,XX +XXX,XX @@ struct PL011State {
35
+ *
39
uint32_t dmacr;
36
+ * Similar to armv7m_nvic_set_pending(), but specifically for exceptions
40
uint32_t int_enabled;
37
+ * generated in the course of lazy stacking of FP registers.
41
uint32_t int_level;
38
+ */
42
- uint32_t read_fifo[16];
39
+void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure);
43
+ uint32_t read_fifo[PL011_FIFO_DEPTH];
40
/**
44
uint32_t ilpr;
41
* armv7m_nvic_get_pending_irq_info: return highest priority pending
45
uint32_t ibrd;
42
* exception, and whether it targets Secure state
46
uint32_t fbrd;
43
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
47
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
44
index XXXXXXX..XXXXXXX 100644
48
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/intc/armv7m_nvic.c
49
--- a/hw/char/pl011.c
46
+++ b/hw/intc/armv7m_nvic.c
50
+++ b/hw/char/pl011.c
47
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure)
51
@@ -XXX,XX +XXX,XX @@ static void pl011_update(PL011State *s)
48
do_armv7m_nvic_set_pending(opaque, irq, secure, true);
52
}
49
}
53
}
50
54
51
+void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure)
55
+static bool pl011_is_fifo_enabled(PL011State *s)
52
+{
56
+{
53
+ /*
57
+ return (s->lcr & 0x10) != 0;
54
+ * Pend an exception during lazy FP stacking. This differs
55
+ * from the usual exception pending because the logic for
56
+ * whether we should escalate depends on the saved context
57
+ * in the FPCCR register, not on the current state of the CPU/NVIC.
58
+ */
59
+ NVICState *s = (NVICState *)opaque;
60
+ bool banked = exc_is_banked(irq);
61
+ VecInfo *vec;
62
+ bool targets_secure;
63
+ bool escalate = false;
64
+ /*
65
+ * We will only look at bits in fpccr if this is a banked exception
66
+ * (in which case 'secure' tells us whether it is the S or NS version).
67
+ * All the bits for the non-banked exceptions are in fpccr_s.
68
+ */
69
+ uint32_t fpccr_s = s->cpu->env.v7m.fpccr[M_REG_S];
70
+ uint32_t fpccr = s->cpu->env.v7m.fpccr[secure];
71
+
72
+ assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
73
+ assert(!secure || banked);
74
+
75
+ vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq];
76
+
77
+ targets_secure = banked ? secure : exc_targets_secure(s, irq);
78
+
79
+ switch (irq) {
80
+ case ARMV7M_EXCP_DEBUG:
81
+ if (!(fpccr_s & R_V7M_FPCCR_MONRDY_MASK)) {
82
+ /* Ignore DebugMonitor exception */
83
+ return;
84
+ }
85
+ break;
86
+ case ARMV7M_EXCP_MEM:
87
+ escalate = !(fpccr & R_V7M_FPCCR_MMRDY_MASK);
88
+ break;
89
+ case ARMV7M_EXCP_USAGE:
90
+ escalate = !(fpccr & R_V7M_FPCCR_UFRDY_MASK);
91
+ break;
92
+ case ARMV7M_EXCP_BUS:
93
+ escalate = !(fpccr_s & R_V7M_FPCCR_BFRDY_MASK);
94
+ break;
95
+ case ARMV7M_EXCP_SECURE:
96
+ escalate = !(fpccr_s & R_V7M_FPCCR_SFRDY_MASK);
97
+ break;
98
+ default:
99
+ g_assert_not_reached();
100
+ }
101
+
102
+ if (escalate) {
103
+ /*
104
+ * Escalate to HardFault: faults that initially targeted Secure
105
+ * continue to do so, even if HF normally targets NonSecure.
106
+ */
107
+ irq = ARMV7M_EXCP_HARD;
108
+ if (arm_feature(&s->cpu->env, ARM_FEATURE_M_SECURITY) &&
109
+ (targets_secure ||
110
+ !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK))) {
111
+ vec = &s->sec_vectors[irq];
112
+ } else {
113
+ vec = &s->vectors[irq];
114
+ }
115
+ }
116
+
117
+ if (!vec->enabled ||
118
+ nvic_exec_prio(s) <= exc_group_prio(s, vec->prio, secure)) {
119
+ if (!(fpccr_s & R_V7M_FPCCR_HFRDY_MASK)) {
120
+ /*
121
+ * We want to escalate to HardFault but the context the
122
+ * FP state belongs to prevents the exception pre-empting.
123
+ */
124
+ cpu_abort(&s->cpu->parent_obj,
125
+ "Lockup: can't escalate to HardFault during "
126
+ "lazy FP register stacking\n");
127
+ }
128
+ }
129
+
130
+ if (escalate) {
131
+ s->cpu->env.v7m.hfsr |= R_V7M_HFSR_FORCED_MASK;
132
+ }
133
+ if (!vec->pending) {
134
+ vec->pending = 1;
135
+ /*
136
+ * We do not call nvic_irq_update(), because we know our caller
137
+ * is going to handle causing us to take the exception by
138
+ * raising EXCP_LAZYFP, so raising the IRQ line would be
139
+ * pointless extra work. We just need to recompute the
140
+ * priorities so that armv7m_nvic_can_take_pending_exception()
141
+ * returns the right answer.
142
+ */
143
+ nvic_recompute_state(s);
144
+ }
145
+}
58
+}
146
+
59
+
147
/* Make pending IRQ active. */
60
+static inline unsigned pl011_get_fifo_depth(PL011State *s)
148
void armv7m_nvic_acknowledge_irq(void *opaque)
61
+{
62
+ /* Note: FIFO depth is expected to be power-of-2 */
63
+ return pl011_is_fifo_enabled(s) ? PL011_FIFO_DEPTH : 1;
64
+}
65
+
66
static uint64_t pl011_read(void *opaque, hwaddr offset,
67
unsigned size)
149
{
68
{
69
@@ -XXX,XX +XXX,XX @@ static uint64_t pl011_read(void *opaque, hwaddr offset,
70
c = s->read_fifo[s->read_pos];
71
if (s->read_count > 0) {
72
s->read_count--;
73
- if (++s->read_pos == 16)
74
- s->read_pos = 0;
75
+ s->read_pos = (s->read_pos + 1) & (pl011_get_fifo_depth(s) - 1);
76
}
77
if (s->read_count == 0) {
78
s->flags |= PL011_FLAG_RXFE;
79
@@ -XXX,XX +XXX,XX @@ static int pl011_can_receive(void *opaque)
80
PL011State *s = (PL011State *)opaque;
81
int r;
82
83
- if (s->lcr & 0x10) {
84
- r = s->read_count < 16;
85
- } else {
86
- r = s->read_count < 1;
87
- }
88
+ r = s->read_count < pl011_get_fifo_depth(s);
89
trace_pl011_can_receive(s->lcr, s->read_count, r);
90
return r;
91
}
92
@@ -XXX,XX +XXX,XX @@ static void pl011_put_fifo(void *opaque, uint32_t value)
93
{
94
PL011State *s = (PL011State *)opaque;
95
int slot;
96
+ unsigned pipe_depth;
97
98
- slot = s->read_pos + s->read_count;
99
- if (slot >= 16)
100
- slot -= 16;
101
+ pipe_depth = pl011_get_fifo_depth(s);
102
+ slot = (s->read_pos + s->read_count) & (pipe_depth - 1);
103
s->read_fifo[slot] = value;
104
s->read_count++;
105
s->flags &= ~PL011_FLAG_RXFE;
106
trace_pl011_put_fifo(value, s->read_count);
107
- if (!(s->lcr & 0x10) || s->read_count == 16) {
108
+ if (s->read_count == pipe_depth) {
109
trace_pl011_put_fifo_full();
110
s->flags |= PL011_FLAG_RXFF;
111
}
112
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pl011 = {
113
VMSTATE_UINT32(dmacr, PL011State),
114
VMSTATE_UINT32(int_enabled, PL011State),
115
VMSTATE_UINT32(int_level, PL011State),
116
- VMSTATE_UINT32_ARRAY(read_fifo, PL011State, 16),
117
+ VMSTATE_UINT32_ARRAY(read_fifo, PL011State, PL011_FIFO_DEPTH),
118
VMSTATE_UINT32(ilpr, PL011State),
119
VMSTATE_UINT32(ibrd, PL011State),
120
VMSTATE_UINT32(fbrd, PL011State),
150
--
121
--
151
2.20.1
122
2.34.1
152
123
153
124
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
Previous change slightly modified the way we handle data writes when
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
FIFO is disabled. Previously we kept incrementing read_pos and were
5
Message-id: 20190412165416.7977-12-philmd@redhat.com
5
storing data at that position, although we only have a
6
single-register-deep FIFO now. Then we changed it to always store data
7
at pos 0.
8
9
If guest disables FIFO and the proceeds to read data, it will work out
10
fine, because we still read from current read_pos before setting it to
11
0.
12
13
However, to make code less fragile, introduce a post_load hook for
14
PL011State and move fixup read FIFO state when FIFO is disabled. Since
15
we are introducing a post_load hook, also do some sanity checking on
16
untrusted incoming input state.
17
18
Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
19
Message-id: 20230123162304.26254-3-eiakovlev@linux.microsoft.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
21
---
8
include/hw/net/lan9118.h | 2 ++
22
hw/char/pl011.c | 25 +++++++++++++++++++++++++
9
hw/arm/exynos4_boards.c | 3 ++-
23
1 file changed, 25 insertions(+)
10
hw/arm/mps2-tz.c | 3 ++-
11
hw/net/lan9118.c | 1 -
12
4 files changed, 6 insertions(+), 3 deletions(-)
13
24
14
diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h
25
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
15
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
16
--- a/include/hw/net/lan9118.h
27
--- a/hw/char/pl011.c
17
+++ b/include/hw/net/lan9118.h
28
+++ b/hw/char/pl011.c
18
@@ -XXX,XX +XXX,XX @@
29
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pl011_clock = {
19
#include "hw/irq.h"
20
#include "net/net.h"
21
22
+#define TYPE_LAN9118 "lan9118"
23
+
24
void lan9118_init(NICInfo *, uint32_t, qemu_irq);
25
26
#endif
27
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
28
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/arm/exynos4_boards.c
30
+++ b/hw/arm/exynos4_boards.c
31
@@ -XXX,XX +XXX,XX @@
32
#include "hw/arm/arm.h"
33
#include "exec/address-spaces.h"
34
#include "hw/arm/exynos4210.h"
35
+#include "hw/net/lan9118.h"
36
#include "hw/boards.h"
37
38
#undef DEBUG
39
@@ -XXX,XX +XXX,XX @@ static void lan9215_init(uint32_t base, qemu_irq irq)
40
/* This should be a 9215 but the 9118 is close enough */
41
if (nd_table[0].used) {
42
qemu_check_nic_model(&nd_table[0], "lan9118");
43
- dev = qdev_create(NULL, "lan9118");
44
+ dev = qdev_create(NULL, TYPE_LAN9118);
45
qdev_set_nic_properties(dev, &nd_table[0]);
46
qdev_prop_set_uint32(dev, "mode_16bit", 1);
47
qdev_init_nofail(dev);
48
diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/arm/mps2-tz.c
51
+++ b/hw/arm/mps2-tz.c
52
@@ -XXX,XX +XXX,XX @@
53
#include "hw/arm/armsse.h"
54
#include "hw/dma/pl080.h"
55
#include "hw/ssi/pl022.h"
56
+#include "hw/net/lan9118.h"
57
#include "net/net.h"
58
#include "hw/core/split-irq.h"
59
60
@@ -XXX,XX +XXX,XX @@ static MemoryRegion *make_eth_dev(MPS2TZMachineState *mms, void *opaque,
61
* except that it doesn't support the checksum-offload feature.
62
*/
63
qemu_check_nic_model(nd, "lan9118");
64
- mms->lan9118 = qdev_create(NULL, "lan9118");
65
+ mms->lan9118 = qdev_create(NULL, TYPE_LAN9118);
66
qdev_set_nic_properties(mms->lan9118, nd);
67
qdev_init_nofail(mms->lan9118);
68
69
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
70
index XXXXXXX..XXXXXXX 100644
71
--- a/hw/net/lan9118.c
72
+++ b/hw/net/lan9118.c
73
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_lan9118_packet = {
74
}
30
}
75
};
31
};
76
32
77
-#define TYPE_LAN9118 "lan9118"
33
+static int pl011_post_load(void *opaque, int version_id)
78
#define LAN9118(obj) OBJECT_CHECK(lan9118_state, (obj), TYPE_LAN9118)
34
+{
79
35
+ PL011State* s = opaque;
80
typedef struct {
36
+
37
+ /* Sanity-check input state */
38
+ if (s->read_pos >= ARRAY_SIZE(s->read_fifo) ||
39
+ s->read_count > ARRAY_SIZE(s->read_fifo)) {
40
+ return -1;
41
+ }
42
+
43
+ if (!pl011_is_fifo_enabled(s) && s->read_count > 0 && s->read_pos > 0) {
44
+ /*
45
+ * Older versions of PL011 didn't ensure that the single
46
+ * character in the FIFO in FIFO-disabled mode is in
47
+ * element 0 of the array; convert to follow the current
48
+ * code's assumptions.
49
+ */
50
+ s->read_fifo[0] = s->read_fifo[s->read_pos];
51
+ s->read_pos = 0;
52
+ }
53
+
54
+ return 0;
55
+}
56
+
57
static const VMStateDescription vmstate_pl011 = {
58
.name = "pl011",
59
.version_id = 2,
60
.minimum_version_id = 2,
61
+ .post_load = pl011_post_load,
62
.fields = (VMStateField[]) {
63
VMSTATE_UINT32(readbuff, PL011State),
64
VMSTATE_UINT32(flags, PL011State),
81
--
65
--
82
2.20.1
66
2.34.1
83
84
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
2
2
3
Suggested-by: Markus Armbruster <armbru@redhat.com>
3
PL011 currently lacks a reset method. Implement it.
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
5
Message-id: 20190412165416.7977-3-philmd@redhat.com
5
Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20230123162304.26254-4-eiakovlev@linux.microsoft.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
10
---
9
hw/arm/nseries.c | 3 ++-
11
hw/char/pl011.c | 26 +++++++++++++++++++++-----
10
1 file changed, 2 insertions(+), 1 deletion(-)
12
1 file changed, 21 insertions(+), 5 deletions(-)
11
13
12
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
14
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
13
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/arm/nseries.c
16
--- a/hw/char/pl011.c
15
+++ b/hw/arm/nseries.c
17
+++ b/hw/char/pl011.c
16
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ static void pl011_init(Object *obj)
17
#include "hw/boards.h"
19
s->clk = qdev_init_clock_in(DEVICE(obj), "clk", pl011_clock_update, s,
18
#include "hw/i2c/i2c.h"
20
ClockUpdate);
19
#include "hw/devices.h"
21
20
+#include "hw/misc/tmp105.h"
22
- s->read_trigger = 1;
21
#include "hw/block/flash.h"
23
- s->ifl = 0x12;
22
#include "hw/hw.h"
24
- s->cr = 0x300;
23
#include "hw/bt.h"
25
- s->flags = 0x90;
24
@@ -XXX,XX +XXX,XX @@ static void n8x0_i2c_setup(struct n800_s *s)
26
-
25
qemu_register_powerdown_notifier(&n8x0_system_powerdown_notifier);
27
s->id = pl011_id_arm;
26
27
/* Attach a TMP105 PM chip (A0 wired to ground) */
28
- dev = i2c_create_slave(i2c, "tmp105", N8X0_TMP105_ADDR);
29
+ dev = i2c_create_slave(i2c, TYPE_TMP105, N8X0_TMP105_ADDR);
30
qdev_connect_gpio_out(dev, 0, tmp_irq);
31
}
28
}
32
29
30
@@ -XXX,XX +XXX,XX @@ static void pl011_realize(DeviceState *dev, Error **errp)
31
pl011_event, NULL, s, NULL, true);
32
}
33
34
+static void pl011_reset(DeviceState *dev)
35
+{
36
+ PL011State *s = PL011(dev);
37
+
38
+ s->lcr = 0;
39
+ s->rsr = 0;
40
+ s->dmacr = 0;
41
+ s->int_enabled = 0;
42
+ s->int_level = 0;
43
+ s->ilpr = 0;
44
+ s->ibrd = 0;
45
+ s->fbrd = 0;
46
+ s->read_pos = 0;
47
+ s->read_count = 0;
48
+ s->read_trigger = 1;
49
+ s->ifl = 0x12;
50
+ s->cr = 0x300;
51
+ s->flags = 0x90;
52
+}
53
+
54
static void pl011_class_init(ObjectClass *oc, void *data)
55
{
56
DeviceClass *dc = DEVICE_CLASS(oc);
57
58
dc->realize = pl011_realize;
59
+ dc->reset = pl011_reset;
60
dc->vmsd = &vmstate_pl011;
61
device_class_set_props(dc, pl011_properties);
62
}
33
--
63
--
34
2.20.1
64
2.34.1
35
65
36
66
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
2
2
3
No code used the tc6393xb_gpio_in_get() and tc6393xb_gpio_out_set()
3
Current FIFO handling code does not reset RXFE/RXFF flags when guest
4
functions since their introduction in commit 88d2c950b002. Time to
4
resets FIFO by writing to UARTLCR register, although internal FIFO state
5
remove them.
5
is reset to 0 read count. Actual guest-visible flag update will happen
6
only on next data read or write attempt. As a result of that any guest
7
that expects RXFE flag to be set (and RXFF to be cleared) after resetting
8
FIFO will never see that happen.
6
9
7
Suggested-by: Markus Armbruster <armbru@redhat.com>
10
Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Message-id: 20190412165416.7977-4-philmd@redhat.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Message-id: 20230123162304.26254-5-eiakovlev@linux.microsoft.com
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
14
---
13
include/hw/devices.h | 3 ---
15
hw/char/pl011.c | 18 +++++++++++++-----
14
hw/display/tc6393xb.c | 16 ----------------
16
1 file changed, 13 insertions(+), 5 deletions(-)
15
2 files changed, 19 deletions(-)
16
17
17
diff --git a/include/hw/devices.h b/include/hw/devices.h
18
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
18
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/devices.h
20
--- a/hw/char/pl011.c
20
+++ b/include/hw/devices.h
21
+++ b/hw/char/pl011.c
21
@@ -XXX,XX +XXX,XX @@ void retu_key_event(void *retu, int state);
22
@@ -XXX,XX +XXX,XX @@ static inline unsigned pl011_get_fifo_depth(PL011State *s)
22
typedef struct TC6393xbState TC6393xbState;
23
return pl011_is_fifo_enabled(s) ? PL011_FIFO_DEPTH : 1;
23
TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
24
}
24
uint32_t base, qemu_irq irq);
25
25
-void tc6393xb_gpio_out_set(TC6393xbState *s, int line,
26
+static inline void pl011_reset_fifo(PL011State *s)
26
- qemu_irq handler);
27
+{
27
-qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s);
28
+ s->read_count = 0;
28
qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
29
+ s->read_pos = 0;
29
30
+
30
#endif
31
+ /* Reset FIFO flags */
31
diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
32
+ s->flags &= ~(PL011_FLAG_RXFF | PL011_FLAG_TXFF);
32
index XXXXXXX..XXXXXXX 100644
33
+ s->flags |= PL011_FLAG_RXFE | PL011_FLAG_TXFE;
33
--- a/hw/display/tc6393xb.c
34
+}
34
+++ b/hw/display/tc6393xb.c
35
+
35
@@ -XXX,XX +XXX,XX @@ struct TC6393xbState {
36
static uint64_t pl011_read(void *opaque, hwaddr offset,
36
blanked : 1;
37
unsigned size)
37
};
38
39
-qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s)
40
-{
41
- return s->gpio_in;
42
-}
43
-
44
static void tc6393xb_gpio_set(void *opaque, int line, int level)
45
{
38
{
46
// TC6393xbState *s = opaque;
39
@@ -XXX,XX +XXX,XX @@ static void pl011_write(void *opaque, hwaddr offset,
47
@@ -XXX,XX +XXX,XX @@ static void tc6393xb_gpio_set(void *opaque, int line, int level)
40
case 11: /* UARTLCR_H */
48
// FIXME: how does the chip reflect the GPIO input level change?
41
/* Reset the FIFO state on FIFO enable or disable */
42
if ((s->lcr ^ value) & 0x10) {
43
- s->read_count = 0;
44
- s->read_pos = 0;
45
+ pl011_reset_fifo(s);
46
}
47
if ((s->lcr ^ value) & 0x1) {
48
int break_enable = value & 0x1;
49
@@ -XXX,XX +XXX,XX @@ static void pl011_reset(DeviceState *dev)
50
s->ilpr = 0;
51
s->ibrd = 0;
52
s->fbrd = 0;
53
- s->read_pos = 0;
54
- s->read_count = 0;
55
s->read_trigger = 1;
56
s->ifl = 0x12;
57
s->cr = 0x300;
58
- s->flags = 0x90;
59
+ s->flags = 0;
60
+ pl011_reset_fifo(s);
49
}
61
}
50
62
51
-void tc6393xb_gpio_out_set(TC6393xbState *s, int line,
63
static void pl011_class_init(ObjectClass *oc, void *data)
52
- qemu_irq handler)
53
-{
54
- if (line >= TC6393XB_GPIOS) {
55
- fprintf(stderr, "TC6393xb: no GPIO pin %d\n", line);
56
- return;
57
- }
58
-
59
- s->handler[line] = handler;
60
-}
61
-
62
static void tc6393xb_gpio_handler_update(TC6393xbState *s)
63
{
64
uint32_t level, diff;
65
--
64
--
66
2.20.1
65
2.34.1
67
68
diff view generated by jsdifflib
1
Implement the VLLDM instruction for v7M for the FPU present cas.
1
From: Alexander Graf <agraf@csgraf.de>
2
2
3
We currently only support GICv2 emulation. To also support GICv3, we will
4
need to pass a few system registers into their respective handler functions.
5
6
This patch adds support for HVF to call into the TCG callbacks for GICv3
7
system register handlers. This is safe because the GICv3 TCG code is generic
8
as long as we limit ourselves to EL0 and EL1 - which are the only modes
9
supported by HVF.
10
11
To make sure nobody trips over that, we also annotate callbacks that don't
12
work in HVF mode, such as EL state change hooks.
13
14
With GICv3 support in place, we can run with more than 8 vCPUs.
15
16
Signed-off-by: Alexander Graf <agraf@csgraf.de>
17
Message-id: 20230128224459.70676-1-agraf@csgraf.de
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190416125744.27770-26-peter.maydell@linaro.org
6
---
20
---
7
target/arm/helper.h | 1 +
21
hw/intc/arm_gicv3_cpuif.c | 16 +++-
8
target/arm/helper.c | 54 ++++++++++++++++++++++++++++++++++++++++++
22
target/arm/hvf/hvf.c | 151 ++++++++++++++++++++++++++++++++++++
9
target/arm/translate.c | 2 +-
23
target/arm/hvf/trace-events | 2 +
10
3 files changed, 56 insertions(+), 1 deletion(-)
24
3 files changed, 168 insertions(+), 1 deletion(-)
11
25
12
diff --git a/target/arm/helper.h b/target/arm/helper.h
26
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
13
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.h
28
--- a/hw/intc/arm_gicv3_cpuif.c
15
+++ b/target/arm/helper.h
29
+++ b/hw/intc/arm_gicv3_cpuif.c
16
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32)
30
@@ -XXX,XX +XXX,XX @@
17
DEF_HELPER_1(v7m_preserve_fp_state, void, env)
31
#include "hw/irq.h"
18
32
#include "cpu.h"
19
DEF_HELPER_2(v7m_vlstm, void, env, i32)
33
#include "target/arm/cpregs.h"
20
+DEF_HELPER_2(v7m_vlldm, void, env, i32)
34
+#include "sysemu/tcg.h"
21
35
+#include "sysemu/qtest.h"
22
DEF_HELPER_2(v8m_stackcheck, void, env, i32)
36
23
37
/*
24
diff --git a/target/arm/helper.c b/target/arm/helper.c
38
* Special case return value from hppvi_index(); must be larger than
39
@@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s)
40
* which case we'd get the wrong value.
41
* So instead we define the regs with no ri->opaque info, and
42
* get back to the GICv3CPUState from the CPUARMState.
43
+ *
44
+ * These CP regs callbacks can be called from either TCG or HVF code.
45
*/
46
define_arm_cp_regs(cpu, gicv3_cpuif_reginfo);
47
48
@@ -XXX,XX +XXX,XX @@ void gicv3_init_cpuif(GICv3State *s)
49
define_arm_cp_regs(cpu, gicv3_cpuif_ich_apxr23_reginfo);
50
}
51
}
52
- arm_register_el_change_hook(cpu, gicv3_cpuif_el_change_hook, cs);
53
+ if (tcg_enabled() || qtest_enabled()) {
54
+ /*
55
+ * We can only trap EL changes with TCG. However the GIC interrupt
56
+ * state only changes on EL changes involving EL2 or EL3, so for
57
+ * the non-TCG case this is OK, as EL2 and EL3 can't exist.
58
+ */
59
+ arm_register_el_change_hook(cpu, gicv3_cpuif_el_change_hook, cs);
60
+ } else {
61
+ assert(!arm_feature(&cpu->env, ARM_FEATURE_EL2));
62
+ assert(!arm_feature(&cpu->env, ARM_FEATURE_EL3));
63
+ }
64
}
65
}
66
diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
25
index XXXXXXX..XXXXXXX 100644
67
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/helper.c
68
--- a/target/arm/hvf/hvf.c
27
+++ b/target/arm/helper.c
69
+++ b/target/arm/hvf/hvf.c
28
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
70
@@ -XXX,XX +XXX,XX @@
29
g_assert_not_reached();
71
#define SYSREG_PMCCNTR_EL0 SYSREG(3, 3, 9, 13, 0)
72
#define SYSREG_PMCCFILTR_EL0 SYSREG(3, 3, 14, 15, 7)
73
74
+#define SYSREG_ICC_AP0R0_EL1 SYSREG(3, 0, 12, 8, 4)
75
+#define SYSREG_ICC_AP0R1_EL1 SYSREG(3, 0, 12, 8, 5)
76
+#define SYSREG_ICC_AP0R2_EL1 SYSREG(3, 0, 12, 8, 6)
77
+#define SYSREG_ICC_AP0R3_EL1 SYSREG(3, 0, 12, 8, 7)
78
+#define SYSREG_ICC_AP1R0_EL1 SYSREG(3, 0, 12, 9, 0)
79
+#define SYSREG_ICC_AP1R1_EL1 SYSREG(3, 0, 12, 9, 1)
80
+#define SYSREG_ICC_AP1R2_EL1 SYSREG(3, 0, 12, 9, 2)
81
+#define SYSREG_ICC_AP1R3_EL1 SYSREG(3, 0, 12, 9, 3)
82
+#define SYSREG_ICC_ASGI1R_EL1 SYSREG(3, 0, 12, 11, 6)
83
+#define SYSREG_ICC_BPR0_EL1 SYSREG(3, 0, 12, 8, 3)
84
+#define SYSREG_ICC_BPR1_EL1 SYSREG(3, 0, 12, 12, 3)
85
+#define SYSREG_ICC_CTLR_EL1 SYSREG(3, 0, 12, 12, 4)
86
+#define SYSREG_ICC_DIR_EL1 SYSREG(3, 0, 12, 11, 1)
87
+#define SYSREG_ICC_EOIR0_EL1 SYSREG(3, 0, 12, 8, 1)
88
+#define SYSREG_ICC_EOIR1_EL1 SYSREG(3, 0, 12, 12, 1)
89
+#define SYSREG_ICC_HPPIR0_EL1 SYSREG(3, 0, 12, 8, 2)
90
+#define SYSREG_ICC_HPPIR1_EL1 SYSREG(3, 0, 12, 12, 2)
91
+#define SYSREG_ICC_IAR0_EL1 SYSREG(3, 0, 12, 8, 0)
92
+#define SYSREG_ICC_IAR1_EL1 SYSREG(3, 0, 12, 12, 0)
93
+#define SYSREG_ICC_IGRPEN0_EL1 SYSREG(3, 0, 12, 12, 6)
94
+#define SYSREG_ICC_IGRPEN1_EL1 SYSREG(3, 0, 12, 12, 7)
95
+#define SYSREG_ICC_PMR_EL1 SYSREG(3, 0, 4, 6, 0)
96
+#define SYSREG_ICC_RPR_EL1 SYSREG(3, 0, 12, 11, 3)
97
+#define SYSREG_ICC_SGI0R_EL1 SYSREG(3, 0, 12, 11, 7)
98
+#define SYSREG_ICC_SGI1R_EL1 SYSREG(3, 0, 12, 11, 5)
99
+#define SYSREG_ICC_SRE_EL1 SYSREG(3, 0, 12, 12, 5)
100
+
101
#define WFX_IS_WFE (1 << 0)
102
103
#define TMR_CTL_ENABLE (1 << 0)
104
@@ -XXX,XX +XXX,XX @@ static bool is_id_sysreg(uint32_t reg)
105
SYSREG_CRM(reg) < 8;
30
}
106
}
31
107
32
+void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
108
+static uint32_t hvf_reg2cp_reg(uint32_t reg)
33
+{
109
+{
34
+ /* translate.c should never generate calls here in user-only mode */
110
+ return ENCODE_AA64_CP_REG(CP_REG_ARM64_SYSREG_CP,
35
+ g_assert_not_reached();
111
+ (reg >> SYSREG_CRN_SHIFT) & SYSREG_CRN_MASK,
112
+ (reg >> SYSREG_CRM_SHIFT) & SYSREG_CRM_MASK,
113
+ (reg >> SYSREG_OP0_SHIFT) & SYSREG_OP0_MASK,
114
+ (reg >> SYSREG_OP1_SHIFT) & SYSREG_OP1_MASK,
115
+ (reg >> SYSREG_OP2_SHIFT) & SYSREG_OP2_MASK);
36
+}
116
+}
37
+
117
+
38
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
118
+static bool hvf_sysreg_read_cp(CPUState *cpu, uint32_t reg, uint64_t *val)
119
+{
120
+ ARMCPU *arm_cpu = ARM_CPU(cpu);
121
+ CPUARMState *env = &arm_cpu->env;
122
+ const ARMCPRegInfo *ri;
123
+
124
+ ri = get_arm_cp_reginfo(arm_cpu->cp_regs, hvf_reg2cp_reg(reg));
125
+ if (ri) {
126
+ if (ri->accessfn) {
127
+ if (ri->accessfn(env, ri, true) != CP_ACCESS_OK) {
128
+ return false;
129
+ }
130
+ }
131
+ if (ri->type & ARM_CP_CONST) {
132
+ *val = ri->resetvalue;
133
+ } else if (ri->readfn) {
134
+ *val = ri->readfn(env, ri);
135
+ } else {
136
+ *val = CPREG_FIELD64(env, ri);
137
+ }
138
+ trace_hvf_vgic_read(ri->name, *val);
139
+ return true;
140
+ }
141
+
142
+ return false;
143
+}
144
+
145
static int hvf_sysreg_read(CPUState *cpu, uint32_t reg, uint32_t rt)
39
{
146
{
40
/* The TT instructions can be used by unprivileged code, but in
147
ARMCPU *arm_cpu = ARM_CPU(cpu);
41
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
148
@@ -XXX,XX +XXX,XX @@ static int hvf_sysreg_read(CPUState *cpu, uint32_t reg, uint32_t rt)
42
env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
149
case SYSREG_OSDLR_EL1:
150
/* Dummy register */
151
break;
152
+ case SYSREG_ICC_AP0R0_EL1:
153
+ case SYSREG_ICC_AP0R1_EL1:
154
+ case SYSREG_ICC_AP0R2_EL1:
155
+ case SYSREG_ICC_AP0R3_EL1:
156
+ case SYSREG_ICC_AP1R0_EL1:
157
+ case SYSREG_ICC_AP1R1_EL1:
158
+ case SYSREG_ICC_AP1R2_EL1:
159
+ case SYSREG_ICC_AP1R3_EL1:
160
+ case SYSREG_ICC_ASGI1R_EL1:
161
+ case SYSREG_ICC_BPR0_EL1:
162
+ case SYSREG_ICC_BPR1_EL1:
163
+ case SYSREG_ICC_DIR_EL1:
164
+ case SYSREG_ICC_EOIR0_EL1:
165
+ case SYSREG_ICC_EOIR1_EL1:
166
+ case SYSREG_ICC_HPPIR0_EL1:
167
+ case SYSREG_ICC_HPPIR1_EL1:
168
+ case SYSREG_ICC_IAR0_EL1:
169
+ case SYSREG_ICC_IAR1_EL1:
170
+ case SYSREG_ICC_IGRPEN0_EL1:
171
+ case SYSREG_ICC_IGRPEN1_EL1:
172
+ case SYSREG_ICC_PMR_EL1:
173
+ case SYSREG_ICC_SGI0R_EL1:
174
+ case SYSREG_ICC_SGI1R_EL1:
175
+ case SYSREG_ICC_SRE_EL1:
176
+ case SYSREG_ICC_CTLR_EL1:
177
+ /* Call the TCG sysreg handler. This is only safe for GICv3 regs. */
178
+ if (!hvf_sysreg_read_cp(cpu, reg, &val)) {
179
+ hvf_raise_exception(cpu, EXCP_UDEF, syn_uncategorized());
180
+ }
181
+ break;
182
default:
183
if (is_id_sysreg(reg)) {
184
/* ID system registers read as RES0 */
185
@@ -XXX,XX +XXX,XX @@ static void pmswinc_write(CPUARMState *env, uint64_t value)
186
}
43
}
187
}
44
188
45
+void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
189
+static bool hvf_sysreg_write_cp(CPUState *cpu, uint32_t reg, uint64_t val)
46
+{
190
+{
47
+ /* fptr is the value of Rn, the frame pointer we load the FP regs from */
191
+ ARMCPU *arm_cpu = ARM_CPU(cpu);
48
+ assert(env->v7m.secure);
192
+ CPUARMState *env = &arm_cpu->env;
49
+
193
+ const ARMCPRegInfo *ri;
50
+ if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) {
194
+
51
+ return;
195
+ ri = get_arm_cp_reginfo(arm_cpu->cp_regs, hvf_reg2cp_reg(reg));
196
+
197
+ if (ri) {
198
+ if (ri->accessfn) {
199
+ if (ri->accessfn(env, ri, false) != CP_ACCESS_OK) {
200
+ return false;
201
+ }
202
+ }
203
+ if (ri->writefn) {
204
+ ri->writefn(env, ri, val);
205
+ } else {
206
+ CPREG_FIELD64(env, ri) = val;
207
+ }
208
+
209
+ trace_hvf_vgic_write(ri->name, val);
210
+ return true;
52
+ }
211
+ }
53
+
212
+
54
+ /* Check access to the coprocessor is permitted */
213
+ return false;
55
+ if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) {
56
+ raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC());
57
+ }
58
+
59
+ if (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK) {
60
+ /* State in FP is still valid */
61
+ env->v7m.fpccr[M_REG_S] &= ~R_V7M_FPCCR_LSPACT_MASK;
62
+ } else {
63
+ bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK;
64
+ int i;
65
+ uint32_t fpscr;
66
+
67
+ if (fptr & 7) {
68
+ raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC());
69
+ }
70
+
71
+ for (i = 0; i < (ts ? 32 : 16); i += 2) {
72
+ uint32_t slo, shi;
73
+ uint64_t dn;
74
+ uint32_t faddr = fptr + 4 * i;
75
+
76
+ if (i >= 16) {
77
+ faddr += 8; /* skip the slot for the FPSCR */
78
+ }
79
+
80
+ slo = cpu_ldl_data(env, faddr);
81
+ shi = cpu_ldl_data(env, faddr + 4);
82
+
83
+ dn = (uint64_t) shi << 32 | slo;
84
+ *aa32_vfp_dreg(env, i / 2) = dn;
85
+ }
86
+ fpscr = cpu_ldl_data(env, fptr + 0x40);
87
+ vfp_set_fpscr(env, fpscr);
88
+ }
89
+
90
+ env->v7m.control[M_REG_S] |= R_V7M_CONTROL_FPCA_MASK;
91
+}
214
+}
92
+
215
+
93
static bool v7m_push_stack(ARMCPU *cpu)
216
static int hvf_sysreg_write(CPUState *cpu, uint32_t reg, uint64_t val)
94
{
217
{
95
/* Do the "set up stack frame" part of exception entry,
218
ARMCPU *arm_cpu = ARM_CPU(cpu);
96
diff --git a/target/arm/translate.c b/target/arm/translate.c
219
@@ -XXX,XX +XXX,XX @@ static int hvf_sysreg_write(CPUState *cpu, uint32_t reg, uint64_t val)
220
case SYSREG_OSDLR_EL1:
221
/* Dummy register */
222
break;
223
+ case SYSREG_ICC_AP0R0_EL1:
224
+ case SYSREG_ICC_AP0R1_EL1:
225
+ case SYSREG_ICC_AP0R2_EL1:
226
+ case SYSREG_ICC_AP0R3_EL1:
227
+ case SYSREG_ICC_AP1R0_EL1:
228
+ case SYSREG_ICC_AP1R1_EL1:
229
+ case SYSREG_ICC_AP1R2_EL1:
230
+ case SYSREG_ICC_AP1R3_EL1:
231
+ case SYSREG_ICC_ASGI1R_EL1:
232
+ case SYSREG_ICC_BPR0_EL1:
233
+ case SYSREG_ICC_BPR1_EL1:
234
+ case SYSREG_ICC_CTLR_EL1:
235
+ case SYSREG_ICC_DIR_EL1:
236
+ case SYSREG_ICC_EOIR0_EL1:
237
+ case SYSREG_ICC_EOIR1_EL1:
238
+ case SYSREG_ICC_HPPIR0_EL1:
239
+ case SYSREG_ICC_HPPIR1_EL1:
240
+ case SYSREG_ICC_IAR0_EL1:
241
+ case SYSREG_ICC_IAR1_EL1:
242
+ case SYSREG_ICC_IGRPEN0_EL1:
243
+ case SYSREG_ICC_IGRPEN1_EL1:
244
+ case SYSREG_ICC_PMR_EL1:
245
+ case SYSREG_ICC_SGI0R_EL1:
246
+ case SYSREG_ICC_SGI1R_EL1:
247
+ case SYSREG_ICC_SRE_EL1:
248
+ /* Call the TCG sysreg handler. This is only safe for GICv3 regs. */
249
+ if (!hvf_sysreg_write_cp(cpu, reg, val)) {
250
+ hvf_raise_exception(cpu, EXCP_UDEF, syn_uncategorized());
251
+ }
252
+ break;
253
default:
254
cpu_synchronize_state(cpu);
255
trace_hvf_unhandled_sysreg_write(env->pc, reg,
256
diff --git a/target/arm/hvf/trace-events b/target/arm/hvf/trace-events
97
index XXXXXXX..XXXXXXX 100644
257
index XXXXXXX..XXXXXXX 100644
98
--- a/target/arm/translate.c
258
--- a/target/arm/hvf/trace-events
99
+++ b/target/arm/translate.c
259
+++ b/target/arm/hvf/trace-events
100
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
260
@@ -XXX,XX +XXX,XX @@ hvf_unknown_hvc(uint64_t x0) "unknown HVC! 0x%016"PRIx64
101
TCGv_i32 fptr = load_reg(s, rn);
261
hvf_unknown_smc(uint64_t x0) "unknown SMC! 0x%016"PRIx64
102
262
hvf_exit(uint64_t syndrome, uint32_t ec, uint64_t pc) "exit: 0x%"PRIx64" [ec=0x%x pc=0x%"PRIx64"]"
103
if (extract32(insn, 20, 1)) {
263
hvf_psci_call(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3, uint32_t cpuid) "PSCI Call x0=0x%016"PRIx64" x1=0x%016"PRIx64" x2=0x%016"PRIx64" x3=0x%016"PRIx64" cpu=0x%x"
104
- /* VLLDM */
264
+hvf_vgic_write(const char *name, uint64_t val) "vgic write to %s [val=0x%016"PRIx64"]"
105
+ gen_helper_v7m_vlldm(cpu_env, fptr);
265
+hvf_vgic_read(const char *name, uint64_t val) "vgic read from %s [val=0x%016"PRIx64"]"
106
} else {
107
gen_helper_v7m_vlstm(cpu_env, fptr);
108
}
109
--
266
--
110
2.20.1
267
2.34.1
111
112
diff view generated by jsdifflib
1
From: Eric Auger <eric.auger@redhat.com>
1
From: Alexander Graf <agraf@csgraf.de>
2
2
3
The SMMUNotifierNode struct is not necessary and brings extra
3
Up to now, the finalize_gic_version() code open coded what is essentially
4
complexity so let's remove it. We now directly track the SMMUDevices
4
a support bitmap match between host/emulation environment and desired
5
which have registered IOMMU MR notifiers.
5
target GIC type.
6
6
7
This is inspired from the same transformation on intel-iommu
7
This open coding leads to undesirable side effects. For example, a VM with
8
done in commit b4a4ba0d68f50f218ee3957b6638dbee32a5eeef
8
KVM and -smp 10 will automatically choose GICv3 while the same command
9
("intel-iommu: remove IntelIOMMUNotifierNode")
9
line with TCG will stay on GICv2 and fail the launch.
10
10
11
Signed-off-by: Eric Auger <eric.auger@redhat.com>
11
This patch combines the TCG and KVM matching code paths by making
12
Reviewed-by: Peter Xu <peterx@redhat.com>
12
everything a 2 pass process. First, we determine which GIC versions the
13
Message-id: 20190409160219.19026-1-eric.auger@redhat.com
13
current environment is able to support, then we go through a single
14
state machine to determine which target GIC mode that means for us.
15
16
After this patch, the only user noticable changes should be consolidated
17
error messages as well as TCG -M virt supporting -smp > 8 automatically.
18
19
Signed-off-by: Alexander Graf <agraf@csgraf.de>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
22
Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
23
Message-id: 20221223090107.98888-2-agraf@csgraf.de
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
25
---
16
include/hw/arm/smmu-common.h | 8 ++------
26
include/hw/arm/virt.h | 15 ++--
17
hw/arm/smmu-common.c | 6 +++---
27
hw/arm/virt.c | 198 ++++++++++++++++++++++--------------------
18
hw/arm/smmuv3.c | 28 +++++++---------------------
28
2 files changed, 112 insertions(+), 101 deletions(-)
19
3 files changed, 12 insertions(+), 30 deletions(-)
29
20
30
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
21
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
22
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/arm/smmu-common.h
32
--- a/include/hw/arm/virt.h
24
+++ b/include/hw/arm/smmu-common.h
33
+++ b/include/hw/arm/virt.h
25
@@ -XXX,XX +XXX,XX @@ typedef struct SMMUDevice {
34
@@ -XXX,XX +XXX,XX @@ typedef enum VirtMSIControllerType {
26
AddressSpace as;
35
} VirtMSIControllerType;
27
uint32_t cfg_cache_hits;
36
28
uint32_t cfg_cache_misses;
37
typedef enum VirtGICType {
29
+ QLIST_ENTRY(SMMUDevice) next;
38
- VIRT_GIC_VERSION_MAX,
30
} SMMUDevice;
39
- VIRT_GIC_VERSION_HOST,
31
40
- VIRT_GIC_VERSION_2,
32
-typedef struct SMMUNotifierNode {
41
- VIRT_GIC_VERSION_3,
33
- SMMUDevice *sdev;
42
- VIRT_GIC_VERSION_4,
34
- QLIST_ENTRY(SMMUNotifierNode) next;
43
+ VIRT_GIC_VERSION_MAX = 0,
35
-} SMMUNotifierNode;
44
+ VIRT_GIC_VERSION_HOST = 1,
36
-
45
+ /* The concrete GIC values have to match the GIC version number */
37
typedef struct SMMUPciBus {
46
+ VIRT_GIC_VERSION_2 = 2,
38
PCIBus *bus;
47
+ VIRT_GIC_VERSION_3 = 3,
39
SMMUDevice *pbdev[0]; /* Parent array is sparse, so dynamically alloc */
48
+ VIRT_GIC_VERSION_4 = 4,
40
@@ -XXX,XX +XXX,XX @@ typedef struct SMMUState {
49
VIRT_GIC_VERSION_NOSEL,
41
GHashTable *iotlb;
50
} VirtGICType;
42
SMMUPciBus *smmu_pcibus_by_bus_num[SMMU_PCI_BUS_MAX];
51
43
PCIBus *pci_bus;
52
+#define VIRT_GIC_VERSION_2_MASK BIT(VIRT_GIC_VERSION_2)
44
- QLIST_HEAD(, SMMUNotifierNode) notifiers_list;
53
+#define VIRT_GIC_VERSION_3_MASK BIT(VIRT_GIC_VERSION_3)
45
+ QLIST_HEAD(, SMMUDevice) devices_with_notifiers;
54
+#define VIRT_GIC_VERSION_4_MASK BIT(VIRT_GIC_VERSION_4)
46
uint8_t bus_num;
55
+
47
PCIBus *primary_bus;
56
struct VirtMachineClass {
48
} SMMUState;
57
MachineClass parent;
49
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
58
bool disallow_affinity_adjustment;
59
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
50
index XXXXXXX..XXXXXXX 100644
60
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/arm/smmu-common.c
61
--- a/hw/arm/virt.c
52
+++ b/hw/arm/smmu-common.c
62
+++ b/hw/arm/virt.c
53
@@ -XXX,XX +XXX,XX @@ inline void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr)
63
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
54
/* Unmap all notifiers of all mr's */
55
void smmu_inv_notifiers_all(SMMUState *s)
56
{
57
- SMMUNotifierNode *node;
58
+ SMMUDevice *sdev;
59
60
- QLIST_FOREACH(node, &s->notifiers_list, next) {
61
- smmu_inv_notifiers_mr(&node->sdev->iommu);
62
+ QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
63
+ smmu_inv_notifiers_mr(&sdev->iommu);
64
}
64
}
65
}
65
}
66
66
67
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
67
+static VirtGICType finalize_gic_version_do(const char *accel_name,
68
index XXXXXXX..XXXXXXX 100644
68
+ VirtGICType gic_version,
69
--- a/hw/arm/smmuv3.c
69
+ int gics_supported,
70
+++ b/hw/arm/smmuv3.c
70
+ unsigned int max_cpus)
71
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
71
+{
72
/* invalidate an asid/iova tuple in all mr's */
72
+ /* Convert host/max/nosel to GIC version number */
73
static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova)
73
+ switch (gic_version) {
74
+ case VIRT_GIC_VERSION_HOST:
75
+ if (!kvm_enabled()) {
76
+ error_report("gic-version=host requires KVM");
77
+ exit(1);
78
+ }
79
+
80
+ /* For KVM, gic-version=host means gic-version=max */
81
+ return finalize_gic_version_do(accel_name, VIRT_GIC_VERSION_MAX,
82
+ gics_supported, max_cpus);
83
+ case VIRT_GIC_VERSION_MAX:
84
+ if (gics_supported & VIRT_GIC_VERSION_4_MASK) {
85
+ gic_version = VIRT_GIC_VERSION_4;
86
+ } else if (gics_supported & VIRT_GIC_VERSION_3_MASK) {
87
+ gic_version = VIRT_GIC_VERSION_3;
88
+ } else {
89
+ gic_version = VIRT_GIC_VERSION_2;
90
+ }
91
+ break;
92
+ case VIRT_GIC_VERSION_NOSEL:
93
+ if ((gics_supported & VIRT_GIC_VERSION_2_MASK) &&
94
+ max_cpus <= GIC_NCPU) {
95
+ gic_version = VIRT_GIC_VERSION_2;
96
+ } else if (gics_supported & VIRT_GIC_VERSION_3_MASK) {
97
+ /*
98
+ * in case the host does not support v2 emulation or
99
+ * the end-user requested more than 8 VCPUs we now default
100
+ * to v3. In any case defaulting to v2 would be broken.
101
+ */
102
+ gic_version = VIRT_GIC_VERSION_3;
103
+ } else if (max_cpus > GIC_NCPU) {
104
+ error_report("%s only supports GICv2 emulation but more than 8 "
105
+ "vcpus are requested", accel_name);
106
+ exit(1);
107
+ }
108
+ break;
109
+ case VIRT_GIC_VERSION_2:
110
+ case VIRT_GIC_VERSION_3:
111
+ case VIRT_GIC_VERSION_4:
112
+ break;
113
+ }
114
+
115
+ /* Check chosen version is effectively supported */
116
+ switch (gic_version) {
117
+ case VIRT_GIC_VERSION_2:
118
+ if (!(gics_supported & VIRT_GIC_VERSION_2_MASK)) {
119
+ error_report("%s does not support GICv2 emulation", accel_name);
120
+ exit(1);
121
+ }
122
+ break;
123
+ case VIRT_GIC_VERSION_3:
124
+ if (!(gics_supported & VIRT_GIC_VERSION_3_MASK)) {
125
+ error_report("%s does not support GICv3 emulation", accel_name);
126
+ exit(1);
127
+ }
128
+ break;
129
+ case VIRT_GIC_VERSION_4:
130
+ if (!(gics_supported & VIRT_GIC_VERSION_4_MASK)) {
131
+ error_report("%s does not support GICv4 emulation, is virtualization=on?",
132
+ accel_name);
133
+ exit(1);
134
+ }
135
+ break;
136
+ default:
137
+ error_report("logic error in finalize_gic_version");
138
+ exit(1);
139
+ break;
140
+ }
141
+
142
+ return gic_version;
143
+}
144
+
145
/*
146
* finalize_gic_version - Determines the final gic_version
147
* according to the gic-version property
148
@@ -XXX,XX +XXX,XX @@ static void virt_set_memmap(VirtMachineState *vms, int pa_bits)
149
*/
150
static void finalize_gic_version(VirtMachineState *vms)
74
{
151
{
75
- SMMUNotifierNode *node;
152
+ const char *accel_name = current_accel_name();
76
+ SMMUDevice *sdev;
153
unsigned int max_cpus = MACHINE(vms)->smp.max_cpus;
77
154
+ int gics_supported = 0;
78
- QLIST_FOREACH(node, &s->notifiers_list, next) {
155
79
- IOMMUMemoryRegion *mr = &node->sdev->iommu;
156
- if (kvm_enabled()) {
80
+ QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
157
- int probe_bitmap;
81
+ IOMMUMemoryRegion *mr = &sdev->iommu;
158
+ /* Determine which GIC versions the current environment supports */
82
IOMMUNotifier *n;
159
+ if (kvm_enabled() && kvm_irqchip_in_kernel()) {
83
160
+ int probe_bitmap = kvm_arm_vgic_probe();
84
trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, iova);
161
85
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
162
- if (!kvm_irqchip_in_kernel()) {
86
SMMUDevice *sdev = container_of(iommu, SMMUDevice, iommu);
163
- switch (vms->gic_version) {
87
SMMUv3State *s3 = sdev->smmu;
164
- case VIRT_GIC_VERSION_HOST:
88
SMMUState *s = &(s3->smmu_state);
165
- warn_report(
89
- SMMUNotifierNode *node = NULL;
166
- "gic-version=host not relevant with kernel-irqchip=off "
90
- SMMUNotifierNode *next_node = NULL;
167
- "as only userspace GICv2 is supported. Using v2 ...");
91
168
- return;
92
if (new & IOMMU_NOTIFIER_MAP) {
169
- case VIRT_GIC_VERSION_MAX:
93
int bus_num = pci_bus_num(sdev->bus);
170
- case VIRT_GIC_VERSION_NOSEL:
94
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
171
- vms->gic_version = VIRT_GIC_VERSION_2;
95
172
- return;
96
if (old == IOMMU_NOTIFIER_NONE) {
173
- case VIRT_GIC_VERSION_2:
97
trace_smmuv3_notify_flag_add(iommu->parent_obj.name);
174
- return;
98
- node = g_malloc0(sizeof(*node));
175
- case VIRT_GIC_VERSION_3:
99
- node->sdev = sdev;
176
- error_report(
100
- QLIST_INSERT_HEAD(&s->notifiers_list, node, next);
177
- "gic-version=3 is not supported with kernel-irqchip=off");
178
- exit(1);
179
- case VIRT_GIC_VERSION_4:
180
- error_report(
181
- "gic-version=4 is not supported with kernel-irqchip=off");
182
- exit(1);
183
- }
184
- }
185
-
186
- probe_bitmap = kvm_arm_vgic_probe();
187
if (!probe_bitmap) {
188
error_report("Unable to determine GIC version supported by host");
189
exit(1);
190
}
191
192
- switch (vms->gic_version) {
193
- case VIRT_GIC_VERSION_HOST:
194
- case VIRT_GIC_VERSION_MAX:
195
- if (probe_bitmap & KVM_ARM_VGIC_V3) {
196
- vms->gic_version = VIRT_GIC_VERSION_3;
197
- } else {
198
- vms->gic_version = VIRT_GIC_VERSION_2;
199
- }
200
- return;
201
- case VIRT_GIC_VERSION_NOSEL:
202
- if ((probe_bitmap & KVM_ARM_VGIC_V2) && max_cpus <= GIC_NCPU) {
203
- vms->gic_version = VIRT_GIC_VERSION_2;
204
- } else if (probe_bitmap & KVM_ARM_VGIC_V3) {
205
- /*
206
- * in case the host does not support v2 in-kernel emulation or
207
- * the end-user requested more than 8 VCPUs we now default
208
- * to v3. In any case defaulting to v2 would be broken.
209
- */
210
- vms->gic_version = VIRT_GIC_VERSION_3;
211
- } else if (max_cpus > GIC_NCPU) {
212
- error_report("host only supports in-kernel GICv2 emulation "
213
- "but more than 8 vcpus are requested");
214
- exit(1);
215
- }
216
- break;
217
- case VIRT_GIC_VERSION_2:
218
- case VIRT_GIC_VERSION_3:
219
- break;
220
- case VIRT_GIC_VERSION_4:
221
- error_report("gic-version=4 is not supported with KVM");
222
- exit(1);
223
+ if (probe_bitmap & KVM_ARM_VGIC_V2) {
224
+ gics_supported |= VIRT_GIC_VERSION_2_MASK;
225
}
226
-
227
- /* Check chosen version is effectively supported by the host */
228
- if (vms->gic_version == VIRT_GIC_VERSION_2 &&
229
- !(probe_bitmap & KVM_ARM_VGIC_V2)) {
230
- error_report("host does not support in-kernel GICv2 emulation");
231
- exit(1);
232
- } else if (vms->gic_version == VIRT_GIC_VERSION_3 &&
233
- !(probe_bitmap & KVM_ARM_VGIC_V3)) {
234
- error_report("host does not support in-kernel GICv3 emulation");
235
- exit(1);
236
+ if (probe_bitmap & KVM_ARM_VGIC_V3) {
237
+ gics_supported |= VIRT_GIC_VERSION_3_MASK;
238
}
101
- return;
239
- return;
102
- }
240
- }
103
-
241
-
104
- /* update notifier node with new flags */
242
- /* TCG mode */
105
- QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) {
243
- switch (vms->gic_version) {
106
- if (node->sdev == sdev) {
244
- case VIRT_GIC_VERSION_NOSEL:
107
- if (new == IOMMU_NOTIFIER_NONE) {
245
- vms->gic_version = VIRT_GIC_VERSION_2;
108
- trace_smmuv3_notify_flag_del(iommu->parent_obj.name);
246
- break;
109
- QLIST_REMOVE(node, next);
247
- case VIRT_GIC_VERSION_MAX:
110
- g_free(node);
248
+ } else if (kvm_enabled() && !kvm_irqchip_in_kernel()) {
111
- }
249
+ /* KVM w/o kernel irqchip can only deal with GICv2 */
112
- return;
250
+ gics_supported |= VIRT_GIC_VERSION_2_MASK;
251
+ accel_name = "KVM with kernel-irqchip=off";
252
+ } else {
253
+ gics_supported |= VIRT_GIC_VERSION_2_MASK;
254
if (module_object_class_by_name("arm-gicv3")) {
255
- /* CONFIG_ARM_GICV3_TCG was set */
256
+ gics_supported |= VIRT_GIC_VERSION_3_MASK;
257
if (vms->virt) {
258
/* GICv4 only makes sense if CPU has EL2 */
259
- vms->gic_version = VIRT_GIC_VERSION_4;
260
- } else {
261
- vms->gic_version = VIRT_GIC_VERSION_3;
262
+ gics_supported |= VIRT_GIC_VERSION_4_MASK;
263
}
264
- } else {
265
- vms->gic_version = VIRT_GIC_VERSION_2;
266
}
267
- break;
268
- case VIRT_GIC_VERSION_HOST:
269
- error_report("gic-version=host requires KVM");
270
- exit(1);
271
- case VIRT_GIC_VERSION_4:
272
- if (!vms->virt) {
273
- error_report("gic-version=4 requires virtualization enabled");
274
- exit(1);
113
- }
275
- }
114
+ QLIST_INSERT_HEAD(&s->devices_with_notifiers, sdev, next);
276
- break;
115
+ } else if (new == IOMMU_NOTIFIER_NONE) {
277
- case VIRT_GIC_VERSION_2:
116
+ trace_smmuv3_notify_flag_del(iommu->parent_obj.name);
278
- case VIRT_GIC_VERSION_3:
117
+ QLIST_REMOVE(sdev, next);
279
- break;
118
}
280
}
281
+
282
+ /*
283
+ * Then convert helpers like host/max to concrete GIC versions and ensure
284
+ * the desired version is supported
285
+ */
286
+ vms->gic_version = finalize_gic_version_do(accel_name, vms->gic_version,
287
+ gics_supported, max_cpus);
119
}
288
}
120
289
290
/*
121
--
291
--
122
2.20.1
292
2.34.1
123
124
diff view generated by jsdifflib
Deleted patch
1
In the stripe8() function we use a variable length array; however
2
we know that the maximum length required is MAX_NUM_BUSSES. Use
3
a fixed-length array and an assert instead.
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
8
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
9
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
10
Message-id: 20190328152635.2794-1-peter.maydell@linaro.org
11
---
12
hw/ssi/xilinx_spips.c | 6 ++++--
13
1 file changed, 4 insertions(+), 2 deletions(-)
14
15
diff --git a/hw/ssi/xilinx_spips.c b/hw/ssi/xilinx_spips.c
16
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/ssi/xilinx_spips.c
18
+++ b/hw/ssi/xilinx_spips.c
19
@@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_qspips_reset(DeviceState *d)
20
21
static inline void stripe8(uint8_t *x, int num, bool dir)
22
{
23
- uint8_t r[num];
24
- memset(r, 0, sizeof(uint8_t) * num);
25
+ uint8_t r[MAX_NUM_BUSSES];
26
int idx[2] = {0, 0};
27
int bit[2] = {0, 7};
28
int d = dir;
29
30
+ assert(num <= MAX_NUM_BUSSES);
31
+ memset(r, 0, sizeof(uint8_t) * num);
32
+
33
for (idx[0] = 0; idx[0] < num; ++idx[0]) {
34
for (bit[0] = 7; bit[0] >= 0; bit[0]--) {
35
r[idx[!d]] |= x[idx[d]] & 1 << bit[d] ? 1 << bit[!d] : 0;
36
--
37
2.20.1
38
39
diff view generated by jsdifflib
Deleted patch
1
Normally configure identifies the source path by looking
2
at the location where the configure script itself exists.
3
We also provide a --source-path option which lets the user
4
manually override this.
5
1
6
There isn't really an obvious use case for the --source-path
7
option, and in commit 927128222b0a91f56c13a in 2017 we
8
accidentally added some logic that looks at $source_path
9
before the command line option that overrides it has been
10
processed.
11
12
The fact that nobody complained suggests that there isn't
13
any use of this option and we aren't testing it either;
14
remove it. This allows us to move the "make $source_path
15
absolute" logic up so that there is no window in the script
16
where $source_path is set but not yet absolute.
17
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
20
Message-id: 20190318134019.23729-1-peter.maydell@linaro.org
21
---
22
configure | 10 ++--------
23
1 file changed, 2 insertions(+), 8 deletions(-)
24
25
diff --git a/configure b/configure
26
index XXXXXXX..XXXXXXX 100755
27
--- a/configure
28
+++ b/configure
29
@@ -XXX,XX +XXX,XX @@ ld_has() {
30
31
# default parameters
32
source_path=$(dirname "$0")
33
+# make source path absolute
34
+source_path=$(cd "$source_path"; pwd)
35
cpu=""
36
iasl="iasl"
37
interp_prefix="/usr/gnemul/qemu-%M"
38
@@ -XXX,XX +XXX,XX @@ for opt do
39
;;
40
--cxx=*) CXX="$optarg"
41
;;
42
- --source-path=*) source_path="$optarg"
43
- ;;
44
--cpu=*) cpu="$optarg"
45
;;
46
--extra-cflags=*) QEMU_CFLAGS="$QEMU_CFLAGS $optarg"
47
@@ -XXX,XX +XXX,XX @@ if test "$debug_info" = "yes"; then
48
LDFLAGS="-g $LDFLAGS"
49
fi
50
51
-# make source path absolute
52
-source_path=$(cd "$source_path"; pwd)
53
-
54
# running configure in the source tree?
55
# we know that's the case if configure is there.
56
if test -f "./configure"; then
57
@@ -XXX,XX +XXX,XX @@ for opt do
58
;;
59
--interp-prefix=*) interp_prefix="$optarg"
60
;;
61
- --source-path=*)
62
- ;;
63
--cross-prefix=*)
64
;;
65
--cc=*)
66
@@ -XXX,XX +XXX,XX @@ $(echo Available targets: $default_target_list | \
67
--target-list-exclude=LIST exclude a set of targets from the default target-list
68
69
Advanced options (experts only):
70
- --source-path=PATH path of source code [$source_path]
71
--cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]
72
--cc=CC use C compiler CC [$cc]
73
--iasl=IASL use ACPI compiler IASL [$iasl]
74
--
75
2.20.1
76
77
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Alexander Graf <agraf@csgraf.de>
2
2
3
Reviewed-by: Thomas Huth <thuth@redhat.com>
3
Let's explicitly list out all accelerators that we support when trying to
4
Reviewed-by: Markus Armbruster <armbru@redhat.com>
4
determine the supported set of GIC versions. KVM was already separate, so
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
the only missing one is HVF which simply reuses all of TCG's emulation
6
Message-id: 20190412165416.7977-11-philmd@redhat.com
6
code and thus has the same compatibility matrix.
7
8
Signed-off-by: Alexander Graf <agraf@csgraf.de>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
11
Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20221223090107.98888-3-agraf@csgraf.de
14
[PMM: Added qtest to the list of accelerators]
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
16
---
9
include/hw/net/ne2000-isa.h | 6 ++++++
17
hw/arm/virt.c | 7 ++++++-
10
1 file changed, 6 insertions(+)
18
1 file changed, 6 insertions(+), 1 deletion(-)
11
19
12
diff --git a/include/hw/net/ne2000-isa.h b/include/hw/net/ne2000-isa.h
20
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
13
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
14
--- a/include/hw/net/ne2000-isa.h
22
--- a/hw/arm/virt.c
15
+++ b/include/hw/net/ne2000-isa.h
23
+++ b/hw/arm/virt.c
16
@@ -XXX,XX +XXX,XX @@
24
@@ -XXX,XX +XXX,XX @@
17
* This work is licensed under the terms of the GNU GPL, version 2 or later.
25
#include "sysemu/numa.h"
18
* See the COPYING file in the top-level directory.
26
#include "sysemu/runstate.h"
19
*/
27
#include "sysemu/tpm.h"
20
+
28
+#include "sysemu/tcg.h"
21
+#ifndef HW_NET_NE2K_ISA_H
29
#include "sysemu/kvm.h"
22
+#define HW_NET_NE2K_ISA_H
30
#include "sysemu/hvf.h"
23
+
31
+#include "sysemu/qtest.h"
24
#include "hw/hw.h"
32
#include "hw/loader.h"
25
#include "hw/qdev.h"
33
#include "qapi/error.h"
26
#include "hw/isa/isa.h"
34
#include "qemu/bitops.h"
27
@@ -XXX,XX +XXX,XX @@ static inline ISADevice *isa_ne2000_init(ISABus *bus, int base, int irq,
35
@@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms)
36
/* KVM w/o kernel irqchip can only deal with GICv2 */
37
gics_supported |= VIRT_GIC_VERSION_2_MASK;
38
accel_name = "KVM with kernel-irqchip=off";
39
- } else {
40
+ } else if (tcg_enabled() || hvf_enabled() || qtest_enabled()) {
41
gics_supported |= VIRT_GIC_VERSION_2_MASK;
42
if (module_object_class_by_name("arm-gicv3")) {
43
gics_supported |= VIRT_GIC_VERSION_3_MASK;
44
@@ -XXX,XX +XXX,XX @@ static void finalize_gic_version(VirtMachineState *vms)
45
gics_supported |= VIRT_GIC_VERSION_4_MASK;
46
}
47
}
48
+ } else {
49
+ error_report("Unsupported accelerator, can not determine GIC support");
50
+ exit(1);
28
}
51
}
29
return d;
52
30
}
53
/*
31
+
32
+#endif
33
--
54
--
34
2.20.1
55
2.34.1
35
56
36
57
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
Cortex-A76 supports 40bits of address space. sbsa-ref's memory
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
starts above this limit.
5
Message-id: 20190412165416.7977-10-philmd@redhat.com
5
6
Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230126114416.2447685-1-marcin.juszkiewicz@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
include/hw/devices.h | 3 ---
12
hw/arm/sbsa-ref.c | 1 -
9
include/hw/net/lan9118.h | 19 +++++++++++++++++++
13
1 file changed, 1 deletion(-)
10
hw/arm/kzm.c | 2 +-
11
hw/arm/mps2.c | 2 +-
12
hw/arm/realview.c | 1 +
13
hw/arm/vexpress.c | 2 +-
14
hw/net/lan9118.c | 2 +-
15
7 files changed, 24 insertions(+), 7 deletions(-)
16
create mode 100644 include/hw/net/lan9118.h
17
14
18
diff --git a/include/hw/devices.h b/include/hw/devices.h
15
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/devices.h
17
--- a/hw/arm/sbsa-ref.c
21
+++ b/include/hw/devices.h
18
+++ b/hw/arm/sbsa-ref.c
22
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static const int sbsa_ref_irqmap[] = {
23
/* smc91c111.c */
20
static const char * const valid_cpus[] = {
24
void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
21
ARM_CPU_TYPE_NAME("cortex-a57"),
25
22
ARM_CPU_TYPE_NAME("cortex-a72"),
26
-/* lan9118.c */
23
- ARM_CPU_TYPE_NAME("cortex-a76"),
27
-void lan9118_init(NICInfo *, uint32_t, qemu_irq);
24
ARM_CPU_TYPE_NAME("neoverse-n1"),
28
-
25
ARM_CPU_TYPE_NAME("max"),
29
#endif
26
};
30
diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h
31
new file mode 100644
32
index XXXXXXX..XXXXXXX
33
--- /dev/null
34
+++ b/include/hw/net/lan9118.h
35
@@ -XXX,XX +XXX,XX @@
36
+/*
37
+ * SMSC LAN9118 Ethernet interface emulation
38
+ *
39
+ * Copyright (c) 2009 CodeSourcery, LLC.
40
+ * Written by Paul Brook
41
+ *
42
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
43
+ * See the COPYING file in the top-level directory.
44
+ */
45
+
46
+#ifndef HW_NET_LAN9118_H
47
+#define HW_NET_LAN9118_H
48
+
49
+#include "hw/irq.h"
50
+#include "net/net.h"
51
+
52
+void lan9118_init(NICInfo *, uint32_t, qemu_irq);
53
+
54
+#endif
55
diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/hw/arm/kzm.c
58
+++ b/hw/arm/kzm.c
59
@@ -XXX,XX +XXX,XX @@
60
#include "qemu/error-report.h"
61
#include "exec/address-spaces.h"
62
#include "net/net.h"
63
-#include "hw/devices.h"
64
+#include "hw/net/lan9118.h"
65
#include "hw/char/serial.h"
66
#include "sysemu/qtest.h"
67
68
diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
69
index XXXXXXX..XXXXXXX 100644
70
--- a/hw/arm/mps2.c
71
+++ b/hw/arm/mps2.c
72
@@ -XXX,XX +XXX,XX @@
73
#include "hw/timer/cmsdk-apb-timer.h"
74
#include "hw/timer/cmsdk-apb-dualtimer.h"
75
#include "hw/misc/mps2-scc.h"
76
-#include "hw/devices.h"
77
+#include "hw/net/lan9118.h"
78
#include "net/net.h"
79
80
typedef enum MPS2FPGAType {
81
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
82
index XXXXXXX..XXXXXXX 100644
83
--- a/hw/arm/realview.c
84
+++ b/hw/arm/realview.c
85
@@ -XXX,XX +XXX,XX @@
86
#include "hw/arm/arm.h"
87
#include "hw/arm/primecell.h"
88
#include "hw/devices.h"
89
+#include "hw/net/lan9118.h"
90
#include "hw/pci/pci.h"
91
#include "net/net.h"
92
#include "sysemu/sysemu.h"
93
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
94
index XXXXXXX..XXXXXXX 100644
95
--- a/hw/arm/vexpress.c
96
+++ b/hw/arm/vexpress.c
97
@@ -XXX,XX +XXX,XX @@
98
#include "hw/sysbus.h"
99
#include "hw/arm/arm.h"
100
#include "hw/arm/primecell.h"
101
-#include "hw/devices.h"
102
+#include "hw/net/lan9118.h"
103
#include "hw/i2c/i2c.h"
104
#include "net/net.h"
105
#include "sysemu/sysemu.h"
106
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
107
index XXXXXXX..XXXXXXX 100644
108
--- a/hw/net/lan9118.c
109
+++ b/hw/net/lan9118.c
110
@@ -XXX,XX +XXX,XX @@
111
#include "hw/sysbus.h"
112
#include "net/net.h"
113
#include "net/eth.h"
114
-#include "hw/devices.h"
115
+#include "hw/net/lan9118.h"
116
#include "sysemu/sysemu.h"
117
#include "hw/ptimer.h"
118
#include "qemu/log.h"
119
--
27
--
120
2.20.1
28
2.34.1
121
29
122
30
diff view generated by jsdifflib
1
Pushing registers to the stack for v7M needs to handle three cases:
1
The encodings 0,0,C7,C9,0 and 0,0,C7,C9,1 are AT SP1E1RP and AT
2
* the "normal" case where we pend exceptions
2
S1E1WP, but our ARMCPRegInfo definitions for them incorrectly name
3
* an "ignore faults" case where we set FSR bits but
3
them AT S1E1R and AT S1E1W (which are entirely different
4
do not pend exceptions (this is used when we are
4
instructions). Fix the names.
5
handling some kinds of derived exception on exception entry)
6
* a "lazy FP stacking" case, where different FSR bits
7
are set and the exception is pended differently
8
5
9
Implement this by changing the existing flag argument that
6
(This has no guest-visible effect as the names are for debug purposes
10
tells us whether to ignore faults or not into an enum that
7
only.)
11
specifies which of the 3 modes we should handle.
12
8
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20190416125744.27770-23-peter.maydell@linaro.org
11
Tested-by: Fuad Tabba <tabba@google.com>
12
Message-id: 20230130182459.3309057-2-peter.maydell@linaro.org
13
Message-id: 20230127175507.2895013-2-peter.maydell@linaro.org
16
---
14
---
17
target/arm/helper.c | 118 +++++++++++++++++++++++++++++---------------
15
target/arm/helper.c | 4 ++--
18
1 file changed, 79 insertions(+), 39 deletions(-)
16
1 file changed, 2 insertions(+), 2 deletions(-)
19
17
20
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
diff --git a/target/arm/helper.c b/target/arm/helper.c
21
index XXXXXXX..XXXXXXX 100644
19
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/helper.c
20
--- a/target/arm/helper.c
23
+++ b/target/arm/helper.c
21
+++ b/target/arm/helper.c
24
@@ -XXX,XX +XXX,XX @@ static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv)
22
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = {
25
}
23
26
}
24
#ifndef CONFIG_USER_ONLY
27
25
static const ARMCPRegInfo ats1e1_reginfo[] = {
28
+/*
26
- { .name = "AT_S1E1R", .state = ARM_CP_STATE_AA64,
29
+ * What kind of stack write are we doing? This affects how exceptions
27
+ { .name = "AT_S1E1RP", .state = ARM_CP_STATE_AA64,
30
+ * generated during the stacking are treated.
28
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 0,
31
+ */
29
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
32
+typedef enum StackingMode {
30
.writefn = ats_write64 },
33
+ STACK_NORMAL,
31
- { .name = "AT_S1E1W", .state = ARM_CP_STATE_AA64,
34
+ STACK_IGNFAULTS,
32
+ { .name = "AT_S1E1WP", .state = ARM_CP_STATE_AA64,
35
+ STACK_LAZYFP,
33
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1,
36
+} StackingMode;
34
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
37
+
35
.writefn = ats_write64 },
38
static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
39
- ARMMMUIdx mmu_idx, bool ignfault)
40
+ ARMMMUIdx mmu_idx, StackingMode mode)
41
{
42
CPUState *cs = CPU(cpu);
43
CPUARMState *env = &cpu->env;
44
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
45
&attrs, &prot, &page_size, &fi, NULL)) {
46
/* MPU/SAU lookup failed */
47
if (fi.type == ARMFault_QEMU_SFault) {
48
- qemu_log_mask(CPU_LOG_INT,
49
- "...SecureFault with SFSR.AUVIOL during stacking\n");
50
- env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK | R_V7M_SFSR_SFARVALID_MASK;
51
+ if (mode == STACK_LAZYFP) {
52
+ qemu_log_mask(CPU_LOG_INT,
53
+ "...SecureFault with SFSR.LSPERR "
54
+ "during lazy stacking\n");
55
+ env->v7m.sfsr |= R_V7M_SFSR_LSPERR_MASK;
56
+ } else {
57
+ qemu_log_mask(CPU_LOG_INT,
58
+ "...SecureFault with SFSR.AUVIOL "
59
+ "during stacking\n");
60
+ env->v7m.sfsr |= R_V7M_SFSR_AUVIOL_MASK;
61
+ }
62
+ env->v7m.sfsr |= R_V7M_SFSR_SFARVALID_MASK;
63
env->v7m.sfar = addr;
64
exc = ARMV7M_EXCP_SECURE;
65
exc_secure = false;
66
} else {
67
- qemu_log_mask(CPU_LOG_INT, "...MemManageFault with CFSR.MSTKERR\n");
68
- env->v7m.cfsr[secure] |= R_V7M_CFSR_MSTKERR_MASK;
69
+ if (mode == STACK_LAZYFP) {
70
+ qemu_log_mask(CPU_LOG_INT,
71
+ "...MemManageFault with CFSR.MLSPERR\n");
72
+ env->v7m.cfsr[secure] |= R_V7M_CFSR_MLSPERR_MASK;
73
+ } else {
74
+ qemu_log_mask(CPU_LOG_INT,
75
+ "...MemManageFault with CFSR.MSTKERR\n");
76
+ env->v7m.cfsr[secure] |= R_V7M_CFSR_MSTKERR_MASK;
77
+ }
78
exc = ARMV7M_EXCP_MEM;
79
exc_secure = secure;
80
}
81
@@ -XXX,XX +XXX,XX @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
82
attrs, &txres);
83
if (txres != MEMTX_OK) {
84
/* BusFault trying to write the data */
85
- qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.STKERR\n");
86
- env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_STKERR_MASK;
87
+ if (mode == STACK_LAZYFP) {
88
+ qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.LSPERR\n");
89
+ env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_LSPERR_MASK;
90
+ } else {
91
+ qemu_log_mask(CPU_LOG_INT, "...BusFault with BFSR.STKERR\n");
92
+ env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_STKERR_MASK;
93
+ }
94
exc = ARMV7M_EXCP_BUS;
95
exc_secure = false;
96
goto pend_fault;
97
@@ -XXX,XX +XXX,XX @@ pend_fault:
98
* later if we have two derived exceptions.
99
* The only case when we must not pend the exception but instead
100
* throw it away is if we are doing the push of the callee registers
101
- * and we've already generated a derived exception. Even in this
102
- * case we will still update the fault status registers.
103
+ * and we've already generated a derived exception (this is indicated
104
+ * by the caller passing STACK_IGNFAULTS). Even in this case we will
105
+ * still update the fault status registers.
106
*/
107
- if (!ignfault) {
108
+ switch (mode) {
109
+ case STACK_NORMAL:
110
armv7m_nvic_set_pending_derived(env->nvic, exc, exc_secure);
111
+ break;
112
+ case STACK_LAZYFP:
113
+ armv7m_nvic_set_pending_lazyfp(env->nvic, exc, exc_secure);
114
+ break;
115
+ case STACK_IGNFAULTS:
116
+ break;
117
}
118
return false;
119
}
120
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
121
uint32_t limit;
122
bool want_psp;
123
uint32_t sig;
124
+ StackingMode smode = ignore_faults ? STACK_IGNFAULTS : STACK_NORMAL;
125
126
if (dotailchain) {
127
bool mode = lr & R_V7M_EXCRET_MODE_MASK;
128
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
129
*/
130
sig = v7m_integrity_sig(env, lr);
131
stacked_ok =
132
- v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) &&
133
- v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx,
134
- ignore_faults) &&
135
- v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx,
136
- ignore_faults) &&
137
- v7m_stack_write(cpu, frameptr + 0x10, env->regs[6], mmu_idx,
138
- ignore_faults) &&
139
- v7m_stack_write(cpu, frameptr + 0x14, env->regs[7], mmu_idx,
140
- ignore_faults) &&
141
- v7m_stack_write(cpu, frameptr + 0x18, env->regs[8], mmu_idx,
142
- ignore_faults) &&
143
- v7m_stack_write(cpu, frameptr + 0x1c, env->regs[9], mmu_idx,
144
- ignore_faults) &&
145
- v7m_stack_write(cpu, frameptr + 0x20, env->regs[10], mmu_idx,
146
- ignore_faults) &&
147
- v7m_stack_write(cpu, frameptr + 0x24, env->regs[11], mmu_idx,
148
- ignore_faults);
149
+ v7m_stack_write(cpu, frameptr, sig, mmu_idx, smode) &&
150
+ v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx, smode) &&
151
+ v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx, smode) &&
152
+ v7m_stack_write(cpu, frameptr + 0x10, env->regs[6], mmu_idx, smode) &&
153
+ v7m_stack_write(cpu, frameptr + 0x14, env->regs[7], mmu_idx, smode) &&
154
+ v7m_stack_write(cpu, frameptr + 0x18, env->regs[8], mmu_idx, smode) &&
155
+ v7m_stack_write(cpu, frameptr + 0x1c, env->regs[9], mmu_idx, smode) &&
156
+ v7m_stack_write(cpu, frameptr + 0x20, env->regs[10], mmu_idx, smode) &&
157
+ v7m_stack_write(cpu, frameptr + 0x24, env->regs[11], mmu_idx, smode);
158
159
/* Update SP regardless of whether any of the stack accesses failed. */
160
*frame_sp_p = frameptr;
161
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
162
* if it has higher priority).
163
*/
164
stacked_ok = stacked_ok &&
165
- v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) &&
166
- v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) &&
167
- v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) &&
168
- v7m_stack_write(cpu, frameptr + 12, env->regs[3], mmu_idx, false) &&
169
- v7m_stack_write(cpu, frameptr + 16, env->regs[12], mmu_idx, false) &&
170
- v7m_stack_write(cpu, frameptr + 20, env->regs[14], mmu_idx, false) &&
171
- v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) &&
172
- v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false);
173
+ v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, STACK_NORMAL) &&
174
+ v7m_stack_write(cpu, frameptr + 4, env->regs[1],
175
+ mmu_idx, STACK_NORMAL) &&
176
+ v7m_stack_write(cpu, frameptr + 8, env->regs[2],
177
+ mmu_idx, STACK_NORMAL) &&
178
+ v7m_stack_write(cpu, frameptr + 12, env->regs[3],
179
+ mmu_idx, STACK_NORMAL) &&
180
+ v7m_stack_write(cpu, frameptr + 16, env->regs[12],
181
+ mmu_idx, STACK_NORMAL) &&
182
+ v7m_stack_write(cpu, frameptr + 20, env->regs[14],
183
+ mmu_idx, STACK_NORMAL) &&
184
+ v7m_stack_write(cpu, frameptr + 24, env->regs[15],
185
+ mmu_idx, STACK_NORMAL) &&
186
+ v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, STACK_NORMAL);
187
188
if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) {
189
/* FPU is active, try to save its registers */
190
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
191
faddr += 8; /* skip the slot for the FPSCR */
192
}
193
stacked_ok = stacked_ok &&
194
- v7m_stack_write(cpu, faddr, slo, mmu_idx, false) &&
195
- v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, false);
196
+ v7m_stack_write(cpu, faddr, slo,
197
+ mmu_idx, STACK_NORMAL) &&
198
+ v7m_stack_write(cpu, faddr + 4, shi,
199
+ mmu_idx, STACK_NORMAL);
200
}
201
stacked_ok = stacked_ok &&
202
v7m_stack_write(cpu, frameptr + 0x60,
203
- vfp_get_fpscr(env), mmu_idx, false);
204
+ vfp_get_fpscr(env), mmu_idx, STACK_NORMAL);
205
if (cpacr_pass) {
206
for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) {
207
*aa32_vfp_dreg(env, i / 2) = 0;
208
--
36
--
209
2.20.1
37
2.34.1
210
211
diff view generated by jsdifflib
1
Handle floating point registers in exception return.
1
The AArch32 ATS12NSO* address translation operations are supposed to
2
This corresponds to pseudocode functions ValidateExceptionReturn(),
2
trap to either EL2 or EL3 if they're executed at Secure EL1 (which
3
ExceptionReturn(), PopStack() and ConsumeExcStackFrame().
3
can only happen if EL3 is AArch64). We implement this, but we got
4
the syndrome value wrong: like other traps to EL2 or EL3 on an
5
AArch32 cpreg access, they should report the 0x3 syndrome, not the
6
0x0 'uncategorized' syndrome. This is clear in the access pseudocode
7
for these instructions.
8
9
Fix the syndrome value for these operations by correcting the
10
returned value from the ats_access() function.
4
11
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20190416125744.27770-16-peter.maydell@linaro.org
14
Tested-by: Fuad Tabba <tabba@google.com>
15
Message-id: 20230130182459.3309057-3-peter.maydell@linaro.org
16
Message-id: 20230127175507.2895013-3-peter.maydell@linaro.org
8
---
17
---
9
target/arm/helper.c | 142 +++++++++++++++++++++++++++++++++++++++++++-
18
target/arm/helper.c | 4 ++--
10
1 file changed, 141 insertions(+), 1 deletion(-)
19
1 file changed, 2 insertions(+), 2 deletions(-)
11
20
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
21
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.c
23
--- a/target/arm/helper.c
15
+++ b/target/arm/helper.c
24
+++ b/target/arm/helper.c
16
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
25
@@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri,
17
bool rettobase = false;
26
if (arm_current_el(env) == 1) {
18
bool exc_secure = false;
27
if (arm_is_secure_below_el3(env)) {
19
bool return_to_secure;
28
if (env->cp15.scr_el3 & SCR_EEL2) {
20
+ bool ftype;
29
- return CP_ACCESS_TRAP_UNCATEGORIZED_EL2;
21
+ bool restore_s16_s31;
30
+ return CP_ACCESS_TRAP_EL2;
22
31
}
23
/* If we're not in Handler mode then jumps to magic exception-exit
32
- return CP_ACCESS_TRAP_UNCATEGORIZED_EL3;
24
* addresses don't have magic behaviour. However for the v8M
33
+ return CP_ACCESS_TRAP_EL3;
25
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
26
excret);
27
}
28
29
+ ftype = excret & R_V7M_EXCRET_FTYPE_MASK;
30
+
31
+ if (!arm_feature(env, ARM_FEATURE_VFP) && !ftype) {
32
+ qemu_log_mask(LOG_GUEST_ERROR, "M profile: zero FTYPE in exception "
33
+ "exit PC value 0x%" PRIx32 " is UNPREDICTABLE "
34
+ "if FPU not present\n",
35
+ excret);
36
+ ftype = true;
37
+ }
38
+
39
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
40
/* EXC_RETURN.ES validation check (R_SMFL). We must do this before
41
* we pick which FAULTMASK to clear.
42
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
43
*/
44
write_v7m_control_spsel_for_secstate(env, return_to_sp_process, exc_secure);
45
46
+ /*
47
+ * Clear scratch FP values left in caller saved registers; this
48
+ * must happen before any kind of tail chaining.
49
+ */
50
+ if ((env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_CLRONRET_MASK) &&
51
+ (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) {
52
+ if (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK) {
53
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
54
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
55
+ qemu_log_mask(CPU_LOG_INT, "...taking SecureFault on existing "
56
+ "stackframe: error during lazy state deactivation\n");
57
+ v7m_exception_taken(cpu, excret, true, false);
58
+ return;
59
+ } else {
60
+ /* Clear s0..s15 and FPSCR */
61
+ int i;
62
+
63
+ for (i = 0; i < 16; i += 2) {
64
+ *aa32_vfp_dreg(env, i / 2) = 0;
65
+ }
66
+ vfp_set_fpscr(env, 0);
67
+ }
68
+ }
69
+
70
if (sfault) {
71
env->v7m.sfsr |= R_V7M_SFSR_INVER_MASK;
72
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
73
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
74
}
34
}
35
return CP_ACCESS_TRAP_UNCATEGORIZED;
75
}
36
}
76
77
+ if (!ftype) {
78
+ /* FP present and we need to handle it */
79
+ if (!return_to_secure &&
80
+ (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK)) {
81
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
82
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
83
+ qemu_log_mask(CPU_LOG_INT,
84
+ "...taking SecureFault on existing stackframe: "
85
+ "Secure LSPACT set but exception return is "
86
+ "not to secure state\n");
87
+ v7m_exception_taken(cpu, excret, true, false);
88
+ return;
89
+ }
90
+
91
+ restore_s16_s31 = return_to_secure &&
92
+ (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK);
93
+
94
+ if (env->v7m.fpccr[return_to_secure] & R_V7M_FPCCR_LSPACT_MASK) {
95
+ /* State in FPU is still valid, just clear LSPACT */
96
+ env->v7m.fpccr[return_to_secure] &= ~R_V7M_FPCCR_LSPACT_MASK;
97
+ } else {
98
+ int i;
99
+ uint32_t fpscr;
100
+ bool cpacr_pass, nsacr_pass;
101
+
102
+ cpacr_pass = v7m_cpacr_pass(env, return_to_secure,
103
+ return_to_priv);
104
+ nsacr_pass = return_to_secure ||
105
+ extract32(env->v7m.nsacr, 10, 1);
106
+
107
+ if (!cpacr_pass) {
108
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
109
+ return_to_secure);
110
+ env->v7m.cfsr[return_to_secure] |= R_V7M_CFSR_NOCP_MASK;
111
+ qemu_log_mask(CPU_LOG_INT,
112
+ "...taking UsageFault on existing "
113
+ "stackframe: CPACR.CP10 prevents unstacking "
114
+ "FP regs\n");
115
+ v7m_exception_taken(cpu, excret, true, false);
116
+ return;
117
+ } else if (!nsacr_pass) {
118
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, true);
119
+ env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_INVPC_MASK;
120
+ qemu_log_mask(CPU_LOG_INT,
121
+ "...taking Secure UsageFault on existing "
122
+ "stackframe: NSACR.CP10 prevents unstacking "
123
+ "FP regs\n");
124
+ v7m_exception_taken(cpu, excret, true, false);
125
+ return;
126
+ }
127
+
128
+ for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) {
129
+ uint32_t slo, shi;
130
+ uint64_t dn;
131
+ uint32_t faddr = frameptr + 0x20 + 4 * i;
132
+
133
+ if (i >= 16) {
134
+ faddr += 8; /* Skip the slot for the FPSCR */
135
+ }
136
+
137
+ pop_ok = pop_ok &&
138
+ v7m_stack_read(cpu, &slo, faddr, mmu_idx) &&
139
+ v7m_stack_read(cpu, &shi, faddr + 4, mmu_idx);
140
+
141
+ if (!pop_ok) {
142
+ break;
143
+ }
144
+
145
+ dn = (uint64_t)shi << 32 | slo;
146
+ *aa32_vfp_dreg(env, i / 2) = dn;
147
+ }
148
+ pop_ok = pop_ok &&
149
+ v7m_stack_read(cpu, &fpscr, frameptr + 0x60, mmu_idx);
150
+ if (pop_ok) {
151
+ vfp_set_fpscr(env, fpscr);
152
+ }
153
+ if (!pop_ok) {
154
+ /*
155
+ * These regs are 0 if security extension present;
156
+ * otherwise merely UNKNOWN. We zero always.
157
+ */
158
+ for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) {
159
+ *aa32_vfp_dreg(env, i / 2) = 0;
160
+ }
161
+ vfp_set_fpscr(env, 0);
162
+ }
163
+ }
164
+ }
165
+ env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S],
166
+ V7M_CONTROL, FPCA, !ftype);
167
+
168
/* Commit to consuming the stack frame */
169
frameptr += 0x20;
170
+ if (!ftype) {
171
+ frameptr += 0x48;
172
+ if (restore_s16_s31) {
173
+ frameptr += 0x40;
174
+ }
175
+ }
176
/* Undo stack alignment (the SPREALIGN bit indicates that the original
177
* pre-exception SP was not 8-aligned and we added a padding word to
178
* align it, so we undo this by ORing in the bit that increases it
179
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
180
*frame_sp_p = frameptr;
181
}
182
/* This xpsr_write() will invalidate frame_sp_p as it may switch stack */
183
- xpsr_write(env, xpsr, ~XPSR_SPREALIGN);
184
+ xpsr_write(env, xpsr, ~(XPSR_SPREALIGN | XPSR_SFPA));
185
+
186
+ if (env->v7m.secure) {
187
+ bool sfpa = xpsr & XPSR_SFPA;
188
+
189
+ env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S],
190
+ V7M_CONTROL, SFPA, sfpa);
191
+ }
192
193
/* The restored xPSR exception field will be zero if we're
194
* resuming in Thread mode. If that doesn't match what the
195
--
37
--
196
2.20.1
38
2.34.1
197
198
diff view generated by jsdifflib
1
Enable the FPU by default for the Cortex-M4 and Cortex-M33.
1
We added the CPAccessResult values CP_ACCESS_TRAP_UNCATEGORIZED_EL2
2
and CP_ACCESS_TRAP_UNCATEGORIZED_EL3 purely in order to use them in
3
the ats_access() function, but doing so was incorrect (a bug fixed in
4
a previous commit). There aren't any cases where we want an access
5
function to be able to request a trap to EL2 or EL3 with a zero
6
syndrome value, so remove these enum values.
7
8
As well as cleaning up dead code, the motivation here is that
9
we'd like to implement fine-grained-trap handling in
10
helper_access_check_cp_reg(). Although the fine-grained traps
11
to EL2 are always lower priority than trap-to-same-EL and
12
higher priority than trap-to-EL3, they are in the middle of
13
various other kinds of trap-to-EL2. Knowing that a trap-to-EL2
14
must always for us have the same syndrome (ie that an access
15
function will return CP_ACCESS_TRAP_EL2 and there is no other
16
kind of trap-to-EL2 enum value) means we don't have to try
17
to choose which of the two syndrome values to report if the
18
access would trap to EL2 both for the fine-grained-trap and
19
because the access function requires it.
2
20
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
22
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190416125744.27770-27-peter.maydell@linaro.org
23
Tested-by: Fuad Tabba <tabba@google.com>
24
Message-id: 20230130182459.3309057-4-peter.maydell@linaro.org
25
Message-id: 20230127175507.2895013-4-peter.maydell@linaro.org
6
---
26
---
7
target/arm/cpu.c | 8 ++++++++
27
target/arm/cpregs.h | 4 ++--
8
1 file changed, 8 insertions(+)
28
target/arm/op_helper.c | 2 ++
29
2 files changed, 4 insertions(+), 2 deletions(-)
9
30
10
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
31
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
11
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
12
--- a/target/arm/cpu.c
33
--- a/target/arm/cpregs.h
13
+++ b/target/arm/cpu.c
34
+++ b/target/arm/cpregs.h
14
@@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj)
35
@@ -XXX,XX +XXX,XX @@ typedef enum CPAccessResult {
15
set_feature(&cpu->env, ARM_FEATURE_M);
36
* Access fails and results in an exception syndrome 0x0 ("uncategorized").
16
set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
37
* Note that this is not a catch-all case -- the set of cases which may
17
set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
38
* result in this failure is specifically defined by the architecture.
18
+ set_feature(&cpu->env, ARM_FEATURE_VFP4);
39
+ * This trap is always to the usual target EL, never directly to a
19
cpu->midr = 0x410fc240; /* r0p0 */
40
+ * specified target EL.
20
cpu->pmsav7_dregion = 8;
41
*/
21
+ cpu->isar.mvfr0 = 0x10110021;
42
CP_ACCESS_TRAP_UNCATEGORIZED = (2 << 2),
22
+ cpu->isar.mvfr1 = 0x11000011;
43
- CP_ACCESS_TRAP_UNCATEGORIZED_EL2 = CP_ACCESS_TRAP_UNCATEGORIZED | 2,
23
+ cpu->isar.mvfr2 = 0x00000000;
44
- CP_ACCESS_TRAP_UNCATEGORIZED_EL3 = CP_ACCESS_TRAP_UNCATEGORIZED | 3,
24
cpu->id_pfr0 = 0x00000030;
45
} CPAccessResult;
25
cpu->id_pfr1 = 0x00000200;
46
26
cpu->id_dfr0 = 0x00100000;
47
typedef struct ARMCPRegInfo ARMCPRegInfo;
27
@@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj)
48
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
28
set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
49
index XXXXXXX..XXXXXXX 100644
29
set_feature(&cpu->env, ARM_FEATURE_M_SECURITY);
50
--- a/target/arm/op_helper.c
30
set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
51
+++ b/target/arm/op_helper.c
31
+ set_feature(&cpu->env, ARM_FEATURE_VFP4);
52
@@ -XXX,XX +XXX,XX @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key,
32
cpu->midr = 0x410fd213; /* r0p3 */
53
case CP_ACCESS_TRAP:
33
cpu->pmsav7_dregion = 16;
54
break;
34
cpu->sau_sregion = 8;
55
case CP_ACCESS_TRAP_UNCATEGORIZED:
35
+ cpu->isar.mvfr0 = 0x10110021;
56
+ /* Only CP_ACCESS_TRAP traps are direct to a specified EL */
36
+ cpu->isar.mvfr1 = 0x11000011;
57
+ assert((res & CP_ACCESS_EL_MASK) == 0);
37
+ cpu->isar.mvfr2 = 0x00000040;
58
if (cpu_isar_feature(aa64_ids, cpu) && isread &&
38
cpu->id_pfr0 = 0x00000030;
59
arm_cpreg_in_idspace(ri)) {
39
cpu->id_pfr1 = 0x00000210;
60
/*
40
cpu->id_dfr0 = 0x00200000;
41
--
61
--
42
2.20.1
62
2.34.1
43
44
diff view generated by jsdifflib
1
Correct the decode of the M-profile "coprocessor and
1
Rearrange the code in do_coproc_insn() so that we calculate the
2
floating-point instructions" space:
2
syndrome value for a potential trap early; we're about to add a
3
* op0 == 0b11 is always unallocated
3
second check that wants this value earlier than where it is currently
4
* if the CPU has an FPU then all insns with op1 == 0b101
4
determined.
5
are floating point and go to disas_vfp_insn()
6
5
7
For the moment we leave VLLDM and VLSTM as NOPs; in
6
(Specifically, a trap to EL2 because of HSTR_EL2 should take
8
a later commit we will fill in the proper implementation
7
priority over an UNDEF to EL1, even when the UNDEF is because
9
for the case where an FPU is present.
8
the register does not exist at all or because its ri->access
9
bits non-configurably fail the access. So the check we put in
10
for HSTR_EL2 trapping at EL1 (which needs the syndrome) is
11
going to have to be done before the check "is the ARMCPRegInfo
12
pointer NULL".)
13
14
This commit is just code motion; the change to HSTR_EL2
15
handling that will use the 'syndrome' variable is in a
16
subsequent commit.
10
17
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20190416125744.27770-7-peter.maydell@linaro.org
20
Tested-by: Fuad Tabba <tabba@google.com>
21
Message-id: 20230130182459.3309057-5-peter.maydell@linaro.org
22
Message-id: 20230127175507.2895013-5-peter.maydell@linaro.org
14
---
23
---
15
target/arm/translate.c | 26 ++++++++++++++++++++++----
24
target/arm/translate.c | 83 +++++++++++++++++++++---------------------
16
1 file changed, 22 insertions(+), 4 deletions(-)
25
1 file changed, 41 insertions(+), 42 deletions(-)
17
26
18
diff --git a/target/arm/translate.c b/target/arm/translate.c
27
diff --git a/target/arm/translate.c b/target/arm/translate.c
19
index XXXXXXX..XXXXXXX 100644
28
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/translate.c
29
--- a/target/arm/translate.c
21
+++ b/target/arm/translate.c
30
+++ b/target/arm/translate.c
22
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
31
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
23
case 6: case 7: case 14: case 15:
32
const ARMCPRegInfo *ri = get_arm_cp_reginfo(s->cp_regs, key);
24
/* Coprocessor. */
33
TCGv_ptr tcg_ri = NULL;
25
if (arm_dc_feature(s, ARM_FEATURE_M)) {
34
bool need_exit_tb;
26
- /* We don't currently implement M profile FP support,
35
+ uint32_t syndrome;
27
- * so this entire space should give a NOCP fault, with
28
- * the exception of the v8M VLLDM and VLSTM insns, which
29
- * must be NOPs in Secure state and UNDEF in Nonsecure state.
30
+ /* 0b111x_11xx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx */
31
+ if (extract32(insn, 24, 2) == 3) {
32
+ goto illegal_op; /* op0 = 0b11 : unallocated */
33
+ }
34
+
36
+
35
+ /*
37
+ /*
36
+ * Decode VLLDM and VLSTM first: these are nonstandard because:
38
+ * Note that since we are an implementation which takes an
37
+ * * if there is no FPU then these insns must NOP in
39
+ * exception on a trapped conditional instruction only if the
38
+ * Secure state and UNDEF in Nonsecure state
40
+ * instruction passes its condition code check, we can take
39
+ * * if there is an FPU then these insns do not have
41
+ * advantage of the clause in the ARM ARM that allows us to set
40
+ * the usual behaviour that disas_vfp_insn() provides of
42
+ * the COND field in the instruction to 0xE in all cases.
41
+ * being controlled by CPACR/NSACR enable bits or the
43
+ * We could fish the actual condition out of the insn (ARM)
42
+ * lazy-stacking logic.
44
+ * or the condexec bits (Thumb) but it isn't necessary.
43
*/
45
+ */
44
if (arm_dc_feature(s, ARM_FEATURE_V8) &&
46
+ switch (cpnum) {
45
(insn & 0xffa00f00) == 0xec200a00) {
47
+ case 14:
46
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
48
+ if (is64) {
47
/* Just NOP since FP support is not implemented */
49
+ syndrome = syn_cp14_rrt_trap(1, 0xe, opc1, crm, rt, rt2,
48
break;
50
+ isread, false);
49
}
51
+ } else {
50
+ if (arm_dc_feature(s, ARM_FEATURE_VFP) &&
52
+ syndrome = syn_cp14_rt_trap(1, 0xe, opc1, opc2, crn, crm,
51
+ ((insn >> 8) & 0xe) == 10) {
53
+ rt, isread, false);
52
+ /* FP, and the CPU supports it */
54
+ }
53
+ if (disas_vfp_insn(s, insn)) {
55
+ break;
54
+ goto illegal_op;
56
+ case 15:
55
+ }
57
+ if (is64) {
56
+ break;
58
+ syndrome = syn_cp15_rrt_trap(1, 0xe, opc1, crm, rt, rt2,
57
+ }
59
+ isread, false);
58
+
60
+ } else {
59
/* All other insns: NOCP */
61
+ syndrome = syn_cp15_rt_trap(1, 0xe, opc1, opc2, crn, crm,
60
gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(),
62
+ rt, isread, false);
61
default_exception_el(s));
63
+ }
64
+ break;
65
+ default:
66
+ /*
67
+ * ARMv8 defines that only coprocessors 14 and 15 exist,
68
+ * so this can only happen if this is an ARMv7 or earlier CPU,
69
+ * in which case the syndrome information won't actually be
70
+ * guest visible.
71
+ */
72
+ assert(!arm_dc_feature(s, ARM_FEATURE_V8));
73
+ syndrome = syn_uncategorized();
74
+ break;
75
+ }
76
77
if (!ri) {
78
/*
79
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
80
* Note that on XScale all cp0..c13 registers do an access check
81
* call in order to handle c15_cpar.
82
*/
83
- uint32_t syndrome;
84
-
85
- /*
86
- * Note that since we are an implementation which takes an
87
- * exception on a trapped conditional instruction only if the
88
- * instruction passes its condition code check, we can take
89
- * advantage of the clause in the ARM ARM that allows us to set
90
- * the COND field in the instruction to 0xE in all cases.
91
- * We could fish the actual condition out of the insn (ARM)
92
- * or the condexec bits (Thumb) but it isn't necessary.
93
- */
94
- switch (cpnum) {
95
- case 14:
96
- if (is64) {
97
- syndrome = syn_cp14_rrt_trap(1, 0xe, opc1, crm, rt, rt2,
98
- isread, false);
99
- } else {
100
- syndrome = syn_cp14_rt_trap(1, 0xe, opc1, opc2, crn, crm,
101
- rt, isread, false);
102
- }
103
- break;
104
- case 15:
105
- if (is64) {
106
- syndrome = syn_cp15_rrt_trap(1, 0xe, opc1, crm, rt, rt2,
107
- isread, false);
108
- } else {
109
- syndrome = syn_cp15_rt_trap(1, 0xe, opc1, opc2, crn, crm,
110
- rt, isread, false);
111
- }
112
- break;
113
- default:
114
- /*
115
- * ARMv8 defines that only coprocessors 14 and 15 exist,
116
- * so this can only happen if this is an ARMv7 or earlier CPU,
117
- * in which case the syndrome information won't actually be
118
- * guest visible.
119
- */
120
- assert(!arm_dc_feature(s, ARM_FEATURE_V8));
121
- syndrome = syn_uncategorized();
122
- break;
123
- }
124
-
125
gen_set_condexec(s);
126
gen_update_pc(s, 0);
127
tcg_ri = tcg_temp_new_ptr();
62
--
128
--
63
2.20.1
129
2.34.1
64
65
diff view generated by jsdifflib
1
Enforce that for M-profile various FPSCR bits which are RES0 there
1
The HSTR_EL2 register has a collection of trap bits which allow
2
but have defined meanings on A-profile are never settable. This
2
trapping to EL2 for AArch32 EL0 or EL1 accesses to coprocessor
3
ensures that M-profile code can't enable the A-profile behaviour
3
registers. The specification of these bits is that when the bit is
4
(notably vector length/stride handling) by accident.
4
set we should trap
5
* EL1 accesses
6
* EL0 accesses, if the access is not UNDEFINED when the
7
trap bit is 0
8
9
In other words, all UNDEF traps from EL0 to EL1 take precedence over
10
the HSTR_EL2 trap to EL2. (Since this is all AArch32, the only kind
11
of trap-to-EL1 is the UNDEF.)
12
13
Our implementation doesn't quite get this right -- we check for traps
14
in the order:
15
* no such register
16
* ARMCPRegInfo::access bits
17
* HSTR_EL2 trap bits
18
* ARMCPRegInfo::accessfn
19
20
So UNDEFs that happen because of the access bits or because the
21
register doesn't exist at all correctly take priority over the
22
HSTR_EL2 trap, but where a register can UNDEF at EL0 because of the
23
accessfn we are incorrectly always taking the HSTR_EL2 trap. There
24
aren't many of these, but one example is the PMCR; if you look at the
25
access pseudocode for this register you can see that UNDEFs taken
26
because of the value of PMUSERENR.EN are checked before the HSTR_EL2
27
bit.
28
29
Rearrange helper_access_check_cp_reg() so that we always call the
30
accessfn, and use its return value if it indicates that the access
31
traps to EL0 rather than continuing to do the HSTR_EL2 check.
5
32
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
33
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
34
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-2-peter.maydell@linaro.org
35
Tested-by: Fuad Tabba <tabba@google.com>
36
Message-id: 20230130182459.3309057-6-peter.maydell@linaro.org
37
Message-id: 20230127175507.2895013-6-peter.maydell@linaro.org
9
---
38
---
10
target/arm/vfp_helper.c | 8 ++++++++
39
target/arm/op_helper.c | 21 ++++++++++++++++-----
11
1 file changed, 8 insertions(+)
40
1 file changed, 16 insertions(+), 5 deletions(-)
12
41
13
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
42
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
14
index XXXXXXX..XXXXXXX 100644
43
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/vfp_helper.c
44
--- a/target/arm/op_helper.c
16
+++ b/target/arm/vfp_helper.c
45
+++ b/target/arm/op_helper.c
17
@@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
46
@@ -XXX,XX +XXX,XX @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key,
18
val &= ~FPCR_FZ16;
47
goto fail;
19
}
48
}
20
49
21
+ if (arm_feature(env, ARM_FEATURE_M)) {
50
+ if (ri->accessfn) {
22
+ /*
51
+ res = ri->accessfn(env, ri, isread);
23
+ * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits
24
+ * and also for the trapped-exception-handling bits IxE.
25
+ */
26
+ val &= 0xf7c0009f;
27
+ }
52
+ }
28
+
53
+
29
/*
54
/*
30
* We don't implement trapped exception handling, so the
55
- * Check for an EL2 trap due to HSTR_EL2. We expect EL0 accesses
31
* trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!)
56
- * to sysregs non accessible at EL0 to have UNDEF-ed already.
57
+ * If the access function indicates a trap from EL0 to EL1 then
58
+ * that always takes priority over the HSTR_EL2 trap. (If it indicates
59
+ * a trap to EL3, then the HSTR_EL2 trap takes priority; if it indicates
60
+ * a trap to EL2, then the syndrome is the same either way so we don't
61
+ * care whether technically the architecture says that HSTR_EL2 trap or
62
+ * the other trap takes priority. So we take the "check HSTR_EL2" path
63
+ * for all of those cases.)
64
*/
65
+ if (res != CP_ACCESS_OK && ((res & CP_ACCESS_EL_MASK) == 0) &&
66
+ arm_current_el(env) == 0) {
67
+ goto fail;
68
+ }
69
+
70
if (!is_a64(env) && arm_current_el(env) < 2 && ri->cp == 15 &&
71
(arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) {
72
uint32_t mask = 1 << ri->crn;
73
@@ -XXX,XX +XXX,XX @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key,
74
}
75
}
76
77
- if (ri->accessfn) {
78
- res = ri->accessfn(env, ri, isread);
79
- }
80
if (likely(res == CP_ACCESS_OK)) {
81
return ri;
82
}
32
--
83
--
33
2.20.1
84
2.34.1
34
35
diff view generated by jsdifflib
Deleted patch
1
For M-profile the MVFR* ID registers are memory mapped, in the
2
range we implement via the NVIC. Allow them to be read.
3
(If the CPU has no FPU, these registers are defined to be RAZ.)
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20190416125744.27770-3-peter.maydell@linaro.org
8
---
9
hw/intc/armv7m_nvic.c | 6 ++++++
10
1 file changed, 6 insertions(+)
11
12
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/intc/armv7m_nvic.c
15
+++ b/hw/intc/armv7m_nvic.c
16
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
17
return 0;
18
}
19
return cpu->env.v7m.sfar;
20
+ case 0xf40: /* MVFR0 */
21
+ return cpu->isar.mvfr0;
22
+ case 0xf44: /* MVFR1 */
23
+ return cpu->isar.mvfr1;
24
+ case 0xf48: /* MVFR2 */
25
+ return cpu->isar.mvfr2;
26
default:
27
bad_offset:
28
qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset);
29
--
30
2.20.1
31
32
diff view generated by jsdifflib
1
The only "system register" that M-profile floating point exposes
1
The semantics of HSTR_EL2 require that it traps cpreg accesses
2
via the VMRS/VMRS instructions is FPSCR, and it does not have
2
to EL2 for:
3
the odd special case for rd==15. Add a check to ensure we only
3
* EL1 accesses
4
expose FPSCR.
4
* EL0 accesses, if the access is not UNDEFINED when the
5
trap bit is 0
6
7
(You can see this in the I_ZFGJP priority ordering, where HSTR_EL2
8
traps from EL1 to EL2 are priority 12, UNDEFs are priority 13, and
9
HSTR_EL2 traps from EL0 are priority 15.)
10
11
However, we don't get this right for EL1 accesses which UNDEF because
12
the register doesn't exist at all or because its ri->access bits
13
non-configurably forbid the access. At EL1, check for the HSTR_EL2
14
trap early, before either of these UNDEF reasons.
15
16
We have to retain the HSTR_EL2 check in access_check_cp_reg(),
17
because at EL0 any kind of UNDEF-to-EL1 (including "no such
18
register", "bad ri->access" and "ri->accessfn returns 'trap to EL1'")
19
takes precedence over the trap to EL2. But we only need to do that
20
check for EL0 now.
5
21
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
Tested-by: Fuad Tabba <tabba@google.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
24
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-5-peter.maydell@linaro.org
25
Message-id: 20230130182459.3309057-7-peter.maydell@linaro.org
26
Message-id: 20230127175507.2895013-7-peter.maydell@linaro.org
9
---
27
---
10
target/arm/translate.c | 19 +++++++++++++++++--
28
target/arm/op_helper.c | 6 +++++-
11
1 file changed, 17 insertions(+), 2 deletions(-)
29
target/arm/translate.c | 28 +++++++++++++++++++++++++++-
30
2 files changed, 32 insertions(+), 2 deletions(-)
12
31
32
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/target/arm/op_helper.c
35
+++ b/target/arm/op_helper.c
36
@@ -XXX,XX +XXX,XX @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key,
37
goto fail;
38
}
39
40
- if (!is_a64(env) && arm_current_el(env) < 2 && ri->cp == 15 &&
41
+ /*
42
+ * HSTR_EL2 traps from EL1 are checked earlier, in generated code;
43
+ * we only need to check here for traps from EL0.
44
+ */
45
+ if (!is_a64(env) && arm_current_el(env) == 0 && ri->cp == 15 &&
46
(arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) {
47
uint32_t mask = 1 << ri->crn;
48
13
diff --git a/target/arm/translate.c b/target/arm/translate.c
49
diff --git a/target/arm/translate.c b/target/arm/translate.c
14
index XXXXXXX..XXXXXXX 100644
50
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate.c
51
--- a/target/arm/translate.c
16
+++ b/target/arm/translate.c
52
+++ b/target/arm/translate.c
17
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
53
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
18
}
54
break;
19
}
55
}
20
} else { /* !dp */
56
21
+ bool is_sysreg;
57
+ if (s->hstr_active && cpnum == 15 && s->current_el == 1) {
58
+ /*
59
+ * At EL1, check for a HSTR_EL2 trap, which must take precedence
60
+ * over the UNDEF for "no such register" or the UNDEF for "access
61
+ * permissions forbid this EL1 access". HSTR_EL2 traps from EL0
62
+ * only happen if the cpreg doesn't UNDEF at EL0, so we do those in
63
+ * access_check_cp_reg(), after the checks for whether the access
64
+ * configurably trapped to EL1.
65
+ */
66
+ uint32_t maskbit = is64 ? crm : crn;
22
+
67
+
23
if ((insn & 0x6f) != 0x00)
68
+ if (maskbit != 4 && maskbit != 14) {
24
return 1;
69
+ /* T4 and T14 are RES0 so never cause traps */
25
rn = VFP_SREG_N(insn);
70
+ TCGv_i32 t;
71
+ DisasLabel over = gen_disas_label(s);
26
+
72
+
27
+ is_sysreg = extract32(insn, 21, 1);
73
+ t = load_cpu_offset(offsetoflow32(CPUARMState, cp15.hstr_el2));
74
+ tcg_gen_andi_i32(t, t, 1u << maskbit);
75
+ tcg_gen_brcondi_i32(TCG_COND_EQ, t, 0, over.label);
76
+ tcg_temp_free_i32(t);
28
+
77
+
29
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
78
+ gen_exception_insn(s, 0, EXCP_UDEF, syndrome);
30
+ /*
79
+ set_disas_label(s, over);
31
+ * The only M-profile VFP vmrs/vmsr sysreg is FPSCR.
80
+ }
32
+ * Writes to R15 are UNPREDICTABLE; we choose to undef.
81
+ }
33
+ */
34
+ if (is_sysreg && (rd == 15 || (rn >> 1) != ARM_VFP_FPSCR)) {
35
+ return 1;
36
+ }
37
+ }
38
+
82
+
39
if (insn & ARM_CP_RW_BIT) {
83
if (!ri) {
40
/* vfp->arm */
84
/*
41
- if (insn & (1 << 21)) {
85
* Unknown register; this might be a guest error or a QEMU
42
+ if (is_sysreg) {
86
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
43
/* system register */
87
return;
44
rn >>= 1;
88
}
45
89
46
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
90
- if (s->hstr_active || ri->accessfn ||
47
}
91
+ if ((s->hstr_active && s->current_el == 0) || ri->accessfn ||
48
} else {
92
(arm_dc_feature(s, ARM_FEATURE_XSCALE) && cpnum < 14)) {
49
/* arm->vfp */
93
/*
50
- if (insn & (1 << 21)) {
94
* Emit code to perform further access permissions checks at
51
+ if (is_sysreg) {
52
rn >>= 1;
53
/* system register */
54
switch (rn) {
55
--
95
--
56
2.20.1
96
2.34.1
57
58
diff view generated by jsdifflib
1
Handle floating point registers in exception entry.
1
The HSTR_EL2 register is not supposed to have an effect unless EL2 is
2
This corresponds to the FP-specific parts of the pseudocode
2
enabled in the current security state. We weren't checking for this,
3
functions ActivateException() and PushStack().
3
which meant that if the guest set up the HSTR_EL2 register we would
4
incorrectly trap even for accesses from Secure EL0 and EL1.
4
5
5
We defer the code corresponding to UpdateFPCCR() to a later patch.
6
Add the missing checks. (Other places where we look at HSTR_EL2
7
for the not-in-v8A bits TTEE and TJDBX are already checking that
8
we are in NS EL0 or EL1, so there we alredy know EL2 is enabled.)
6
9
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-11-peter.maydell@linaro.org
12
Tested-by: Fuad Tabba <tabba@google.com>
13
Message-id: 20230130182459.3309057-8-peter.maydell@linaro.org
14
Message-id: 20230127175507.2895013-8-peter.maydell@linaro.org
10
---
15
---
11
target/arm/helper.c | 98 +++++++++++++++++++++++++++++++++++++++++++--
16
target/arm/helper.c | 2 +-
12
1 file changed, 95 insertions(+), 3 deletions(-)
17
target/arm/op_helper.c | 1 +
18
2 files changed, 2 insertions(+), 1 deletion(-)
13
19
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
20
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
22
--- a/target/arm/helper.c
17
+++ b/target/arm/helper.c
23
+++ b/target/arm/helper.c
18
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
24
@@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el,
19
switch_v7m_security_state(env, targets_secure);
25
DP_TBFLAG_A32(flags, VFPEN, 1);
20
write_v7m_control_spsel(env, 0);
21
arm_clear_exclusive(env);
22
+ /* Clear SFPA and FPCA (has no effect if no FPU) */
23
+ env->v7m.control[M_REG_S] &=
24
+ ~(R_V7M_CONTROL_FPCA_MASK | R_V7M_CONTROL_SFPA_MASK);
25
/* Clear IT bits */
26
env->condexec_bits = 0;
27
env->regs[14] = lr;
28
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
29
uint32_t xpsr = xpsr_read(env);
30
uint32_t frameptr = env->regs[13];
31
ARMMMUIdx mmu_idx = arm_mmu_idx(env);
32
+ uint32_t framesize;
33
+ bool nsacr_cp10 = extract32(env->v7m.nsacr, 10, 1);
34
+
35
+ if ((env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) &&
36
+ (env->v7m.secure || nsacr_cp10)) {
37
+ if (env->v7m.secure &&
38
+ env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK) {
39
+ framesize = 0xa8;
40
+ } else {
41
+ framesize = 0x68;
42
+ }
43
+ } else {
44
+ framesize = 0x20;
45
+ }
46
47
/* Align stack pointer if the guest wants that */
48
if ((frameptr & 4) &&
49
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
50
xpsr |= XPSR_SPREALIGN;
51
}
26
}
52
27
53
- frameptr -= 0x20;
28
- if (el < 2 && env->cp15.hstr_el2 &&
54
+ xpsr &= ~XPSR_SFPA;
29
+ if (el < 2 && env->cp15.hstr_el2 && arm_is_el2_enabled(env) &&
55
+ if (env->v7m.secure &&
30
(arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) {
56
+ (env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) {
31
DP_TBFLAG_A32(flags, HSTR_ACTIVE, 1);
57
+ xpsr |= XPSR_SFPA;
32
}
58
+ }
33
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
59
+
34
index XXXXXXX..XXXXXXX 100644
60
+ frameptr -= framesize;
35
--- a/target/arm/op_helper.c
61
36
+++ b/target/arm/op_helper.c
62
if (arm_feature(env, ARM_FEATURE_V8)) {
37
@@ -XXX,XX +XXX,XX @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key,
63
uint32_t limit = v7m_sp_limit(env);
38
* we only need to check here for traps from EL0.
64
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
39
*/
65
v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) &&
40
if (!is_a64(env) && arm_current_el(env) == 0 && ri->cp == 15 &&
66
v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false);
41
+ arm_is_el2_enabled(env) &&
67
42
(arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) {
68
+ if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) {
43
uint32_t mask = 1 << ri->crn;
69
+ /* FPU is active, try to save its registers */
44
70
+ bool fpccr_s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
71
+ bool lspact = env->v7m.fpccr[fpccr_s] & R_V7M_FPCCR_LSPACT_MASK;
72
+
73
+ if (lspact && arm_feature(env, ARM_FEATURE_M_SECURITY)) {
74
+ qemu_log_mask(CPU_LOG_INT,
75
+ "...SecureFault because LSPACT and FPCA both set\n");
76
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
77
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
78
+ } else if (!env->v7m.secure && !nsacr_cp10) {
79
+ qemu_log_mask(CPU_LOG_INT,
80
+ "...Secure UsageFault with CFSR.NOCP because "
81
+ "NSACR.CP10 prevents stacking FP regs\n");
82
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, M_REG_S);
83
+ env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK;
84
+ } else {
85
+ if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) {
86
+ /* Lazy stacking disabled, save registers now */
87
+ int i;
88
+ bool cpacr_pass = v7m_cpacr_pass(env, env->v7m.secure,
89
+ arm_current_el(env) != 0);
90
+
91
+ if (stacked_ok && !cpacr_pass) {
92
+ /*
93
+ * Take UsageFault if CPACR forbids access. The pseudocode
94
+ * here does a full CheckCPEnabled() but we know the NSACR
95
+ * check can never fail as we have already handled that.
96
+ */
97
+ qemu_log_mask(CPU_LOG_INT,
98
+ "...UsageFault with CFSR.NOCP because "
99
+ "CPACR.CP10 prevents stacking FP regs\n");
100
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
101
+ env->v7m.secure);
102
+ env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;
103
+ stacked_ok = false;
104
+ }
105
+
106
+ for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) {
107
+ uint64_t dn = *aa32_vfp_dreg(env, i / 2);
108
+ uint32_t faddr = frameptr + 0x20 + 4 * i;
109
+ uint32_t slo = extract64(dn, 0, 32);
110
+ uint32_t shi = extract64(dn, 32, 32);
111
+
112
+ if (i >= 16) {
113
+ faddr += 8; /* skip the slot for the FPSCR */
114
+ }
115
+ stacked_ok = stacked_ok &&
116
+ v7m_stack_write(cpu, faddr, slo, mmu_idx, false) &&
117
+ v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, false);
118
+ }
119
+ stacked_ok = stacked_ok &&
120
+ v7m_stack_write(cpu, frameptr + 0x60,
121
+ vfp_get_fpscr(env), mmu_idx, false);
122
+ if (cpacr_pass) {
123
+ for (i = 0; i < ((framesize == 0xa8) ? 32 : 16); i += 2) {
124
+ *aa32_vfp_dreg(env, i / 2) = 0;
125
+ }
126
+ vfp_set_fpscr(env, 0);
127
+ }
128
+ } else {
129
+ /* Lazy stacking enabled, save necessary info to stack later */
130
+ /* TODO : equivalent of UpdateFPCCR() pseudocode */
131
+ }
132
+ }
133
+ }
134
+
135
/*
136
* If we broke a stack limit then SP was already updated earlier;
137
* otherwise we update SP regardless of whether any of the stack
138
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
139
140
if (arm_feature(env, ARM_FEATURE_V8)) {
141
lr = R_V7M_EXCRET_RES1_MASK |
142
- R_V7M_EXCRET_DCRS_MASK |
143
- R_V7M_EXCRET_FTYPE_MASK;
144
+ R_V7M_EXCRET_DCRS_MASK;
145
/* The S bit indicates whether we should return to Secure
146
* or NonSecure (ie our current state).
147
* The ES bit indicates whether we're taking this exception
148
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
149
if (env->v7m.secure) {
150
lr |= R_V7M_EXCRET_S_MASK;
151
}
152
+ if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK)) {
153
+ lr |= R_V7M_EXCRET_FTYPE_MASK;
154
+ }
155
} else {
156
lr = R_V7M_EXCRET_RES1_MASK |
157
R_V7M_EXCRET_S_MASK |
158
--
45
--
159
2.20.1
46
2.34.1
160
161
diff view generated by jsdifflib
1
Implement the code which updates the FPCCR register on an
1
Define the system registers which are provided by the
2
exception entry where we are going to use lazy FP stacking.
2
FEAT_FGT fine-grained trap architectural feature:
3
We have to defer to the NVIC to determine whether the
3
HFGRTR_EL2, HFGWTR_EL2, HDFGRTR_EL2, HDFGWTR_EL2, HFGITR_EL2
4
various exceptions are currently ready or not.
4
5
All these registers are a set of bit fields, where each bit is set
6
for a trap and clear to not trap on a particular system register
7
access. The R and W register pairs are for system registers,
8
allowing trapping to be done separately for reads and writes; the I
9
register is for system instructions where trapping is on instruction
10
execution.
11
12
The data storage in the CPU state struct is arranged as a set of
13
arrays rather than separate fields so that when we're looking up the
14
bits for a system register access we can just index into the array
15
rather than having to use a switch to select a named struct member.
16
The later FEAT_FGT2 will add extra elements to these arrays.
17
18
The field definitions for the new registers are in cpregs.h because
19
in practice the code that needs them is code that also needs
20
the cpregs information; cpu.h is included in a lot more files.
21
We're also going to add some FGT-specific definitions to cpregs.h
22
in the next commit.
23
24
We do not implement HAFGRTR_EL2, because we don't implement
25
FEAT_AMUv1.
5
26
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20190416125744.27770-12-peter.maydell@linaro.org
28
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
29
Tested-by: Fuad Tabba <tabba@google.com>
30
Message-id: 20230130182459.3309057-9-peter.maydell@linaro.org
31
Message-id: 20230127175507.2895013-9-peter.maydell@linaro.org
8
---
32
---
9
target/arm/cpu.h | 14 +++++++++
33
target/arm/cpregs.h | 285 ++++++++++++++++++++++++++++++++++++++++++++
10
hw/intc/armv7m_nvic.c | 34 ++++++++++++++++++++++
34
target/arm/cpu.h | 15 +++
11
target/arm/helper.c | 67 ++++++++++++++++++++++++++++++++++++++++++-
35
target/arm/helper.c | 40 +++++++
12
3 files changed, 114 insertions(+), 1 deletion(-)
36
3 files changed, 340 insertions(+)
13
37
38
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
39
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/cpregs.h
41
+++ b/target/arm/cpregs.h
42
@@ -XXX,XX +XXX,XX @@ typedef enum CPAccessResult {
43
CP_ACCESS_TRAP_UNCATEGORIZED = (2 << 2),
44
} CPAccessResult;
45
46
+/* Indexes into fgt_read[] */
47
+#define FGTREG_HFGRTR 0
48
+#define FGTREG_HDFGRTR 1
49
+/* Indexes into fgt_write[] */
50
+#define FGTREG_HFGWTR 0
51
+#define FGTREG_HDFGWTR 1
52
+/* Indexes into fgt_exec[] */
53
+#define FGTREG_HFGITR 0
54
+
55
+FIELD(HFGRTR_EL2, AFSR0_EL1, 0, 1)
56
+FIELD(HFGRTR_EL2, AFSR1_EL1, 1, 1)
57
+FIELD(HFGRTR_EL2, AIDR_EL1, 2, 1)
58
+FIELD(HFGRTR_EL2, AMAIR_EL1, 3, 1)
59
+FIELD(HFGRTR_EL2, APDAKEY, 4, 1)
60
+FIELD(HFGRTR_EL2, APDBKEY, 5, 1)
61
+FIELD(HFGRTR_EL2, APGAKEY, 6, 1)
62
+FIELD(HFGRTR_EL2, APIAKEY, 7, 1)
63
+FIELD(HFGRTR_EL2, APIBKEY, 8, 1)
64
+FIELD(HFGRTR_EL2, CCSIDR_EL1, 9, 1)
65
+FIELD(HFGRTR_EL2, CLIDR_EL1, 10, 1)
66
+FIELD(HFGRTR_EL2, CONTEXTIDR_EL1, 11, 1)
67
+FIELD(HFGRTR_EL2, CPACR_EL1, 12, 1)
68
+FIELD(HFGRTR_EL2, CSSELR_EL1, 13, 1)
69
+FIELD(HFGRTR_EL2, CTR_EL0, 14, 1)
70
+FIELD(HFGRTR_EL2, DCZID_EL0, 15, 1)
71
+FIELD(HFGRTR_EL2, ESR_EL1, 16, 1)
72
+FIELD(HFGRTR_EL2, FAR_EL1, 17, 1)
73
+FIELD(HFGRTR_EL2, ISR_EL1, 18, 1)
74
+FIELD(HFGRTR_EL2, LORC_EL1, 19, 1)
75
+FIELD(HFGRTR_EL2, LOREA_EL1, 20, 1)
76
+FIELD(HFGRTR_EL2, LORID_EL1, 21, 1)
77
+FIELD(HFGRTR_EL2, LORN_EL1, 22, 1)
78
+FIELD(HFGRTR_EL2, LORSA_EL1, 23, 1)
79
+FIELD(HFGRTR_EL2, MAIR_EL1, 24, 1)
80
+FIELD(HFGRTR_EL2, MIDR_EL1, 25, 1)
81
+FIELD(HFGRTR_EL2, MPIDR_EL1, 26, 1)
82
+FIELD(HFGRTR_EL2, PAR_EL1, 27, 1)
83
+FIELD(HFGRTR_EL2, REVIDR_EL1, 28, 1)
84
+FIELD(HFGRTR_EL2, SCTLR_EL1, 29, 1)
85
+FIELD(HFGRTR_EL2, SCXTNUM_EL1, 30, 1)
86
+FIELD(HFGRTR_EL2, SCXTNUM_EL0, 31, 1)
87
+FIELD(HFGRTR_EL2, TCR_EL1, 32, 1)
88
+FIELD(HFGRTR_EL2, TPIDR_EL1, 33, 1)
89
+FIELD(HFGRTR_EL2, TPIDRRO_EL0, 34, 1)
90
+FIELD(HFGRTR_EL2, TPIDR_EL0, 35, 1)
91
+FIELD(HFGRTR_EL2, TTBR0_EL1, 36, 1)
92
+FIELD(HFGRTR_EL2, TTBR1_EL1, 37, 1)
93
+FIELD(HFGRTR_EL2, VBAR_EL1, 38, 1)
94
+FIELD(HFGRTR_EL2, ICC_IGRPENN_EL1, 39, 1)
95
+FIELD(HFGRTR_EL2, ERRIDR_EL1, 40, 1)
96
+FIELD(HFGRTR_EL2, ERRSELR_EL1, 41, 1)
97
+FIELD(HFGRTR_EL2, ERXFR_EL1, 42, 1)
98
+FIELD(HFGRTR_EL2, ERXCTLR_EL1, 43, 1)
99
+FIELD(HFGRTR_EL2, ERXSTATUS_EL1, 44, 1)
100
+FIELD(HFGRTR_EL2, ERXMISCN_EL1, 45, 1)
101
+FIELD(HFGRTR_EL2, ERXPFGF_EL1, 46, 1)
102
+FIELD(HFGRTR_EL2, ERXPFGCTL_EL1, 47, 1)
103
+FIELD(HFGRTR_EL2, ERXPFGCDN_EL1, 48, 1)
104
+FIELD(HFGRTR_EL2, ERXADDR_EL1, 49, 1)
105
+FIELD(HFGRTR_EL2, NACCDATA_EL1, 50, 1)
106
+/* 51-53: RES0 */
107
+FIELD(HFGRTR_EL2, NSMPRI_EL1, 54, 1)
108
+FIELD(HFGRTR_EL2, NTPIDR2_EL0, 55, 1)
109
+/* 56-63: RES0 */
110
+
111
+/* These match HFGRTR but bits for RO registers are RES0 */
112
+FIELD(HFGWTR_EL2, AFSR0_EL1, 0, 1)
113
+FIELD(HFGWTR_EL2, AFSR1_EL1, 1, 1)
114
+FIELD(HFGWTR_EL2, AMAIR_EL1, 3, 1)
115
+FIELD(HFGWTR_EL2, APDAKEY, 4, 1)
116
+FIELD(HFGWTR_EL2, APDBKEY, 5, 1)
117
+FIELD(HFGWTR_EL2, APGAKEY, 6, 1)
118
+FIELD(HFGWTR_EL2, APIAKEY, 7, 1)
119
+FIELD(HFGWTR_EL2, APIBKEY, 8, 1)
120
+FIELD(HFGWTR_EL2, CONTEXTIDR_EL1, 11, 1)
121
+FIELD(HFGWTR_EL2, CPACR_EL1, 12, 1)
122
+FIELD(HFGWTR_EL2, CSSELR_EL1, 13, 1)
123
+FIELD(HFGWTR_EL2, ESR_EL1, 16, 1)
124
+FIELD(HFGWTR_EL2, FAR_EL1, 17, 1)
125
+FIELD(HFGWTR_EL2, LORC_EL1, 19, 1)
126
+FIELD(HFGWTR_EL2, LOREA_EL1, 20, 1)
127
+FIELD(HFGWTR_EL2, LORN_EL1, 22, 1)
128
+FIELD(HFGWTR_EL2, LORSA_EL1, 23, 1)
129
+FIELD(HFGWTR_EL2, MAIR_EL1, 24, 1)
130
+FIELD(HFGWTR_EL2, PAR_EL1, 27, 1)
131
+FIELD(HFGWTR_EL2, SCTLR_EL1, 29, 1)
132
+FIELD(HFGWTR_EL2, SCXTNUM_EL1, 30, 1)
133
+FIELD(HFGWTR_EL2, SCXTNUM_EL0, 31, 1)
134
+FIELD(HFGWTR_EL2, TCR_EL1, 32, 1)
135
+FIELD(HFGWTR_EL2, TPIDR_EL1, 33, 1)
136
+FIELD(HFGWTR_EL2, TPIDRRO_EL0, 34, 1)
137
+FIELD(HFGWTR_EL2, TPIDR_EL0, 35, 1)
138
+FIELD(HFGWTR_EL2, TTBR0_EL1, 36, 1)
139
+FIELD(HFGWTR_EL2, TTBR1_EL1, 37, 1)
140
+FIELD(HFGWTR_EL2, VBAR_EL1, 38, 1)
141
+FIELD(HFGWTR_EL2, ICC_IGRPENN_EL1, 39, 1)
142
+FIELD(HFGWTR_EL2, ERRSELR_EL1, 41, 1)
143
+FIELD(HFGWTR_EL2, ERXCTLR_EL1, 43, 1)
144
+FIELD(HFGWTR_EL2, ERXSTATUS_EL1, 44, 1)
145
+FIELD(HFGWTR_EL2, ERXMISCN_EL1, 45, 1)
146
+FIELD(HFGWTR_EL2, ERXPFGCTL_EL1, 47, 1)
147
+FIELD(HFGWTR_EL2, ERXPFGCDN_EL1, 48, 1)
148
+FIELD(HFGWTR_EL2, ERXADDR_EL1, 49, 1)
149
+FIELD(HFGWTR_EL2, NACCDATA_EL1, 50, 1)
150
+FIELD(HFGWTR_EL2, NSMPRI_EL1, 54, 1)
151
+FIELD(HFGWTR_EL2, NTPIDR2_EL0, 55, 1)
152
+
153
+FIELD(HFGITR_EL2, ICIALLUIS, 0, 1)
154
+FIELD(HFGITR_EL2, ICIALLU, 1, 1)
155
+FIELD(HFGITR_EL2, ICIVAU, 2, 1)
156
+FIELD(HFGITR_EL2, DCIVAC, 3, 1)
157
+FIELD(HFGITR_EL2, DCISW, 4, 1)
158
+FIELD(HFGITR_EL2, DCCSW, 5, 1)
159
+FIELD(HFGITR_EL2, DCCISW, 6, 1)
160
+FIELD(HFGITR_EL2, DCCVAU, 7, 1)
161
+FIELD(HFGITR_EL2, DCCVAP, 8, 1)
162
+FIELD(HFGITR_EL2, DCCVADP, 9, 1)
163
+FIELD(HFGITR_EL2, DCCIVAC, 10, 1)
164
+FIELD(HFGITR_EL2, DCZVA, 11, 1)
165
+FIELD(HFGITR_EL2, ATS1E1R, 12, 1)
166
+FIELD(HFGITR_EL2, ATS1E1W, 13, 1)
167
+FIELD(HFGITR_EL2, ATS1E0R, 14, 1)
168
+FIELD(HFGITR_EL2, ATS1E0W, 15, 1)
169
+FIELD(HFGITR_EL2, ATS1E1RP, 16, 1)
170
+FIELD(HFGITR_EL2, ATS1E1WP, 17, 1)
171
+FIELD(HFGITR_EL2, TLBIVMALLE1OS, 18, 1)
172
+FIELD(HFGITR_EL2, TLBIVAE1OS, 19, 1)
173
+FIELD(HFGITR_EL2, TLBIASIDE1OS, 20, 1)
174
+FIELD(HFGITR_EL2, TLBIVAAE1OS, 21, 1)
175
+FIELD(HFGITR_EL2, TLBIVALE1OS, 22, 1)
176
+FIELD(HFGITR_EL2, TLBIVAALE1OS, 23, 1)
177
+FIELD(HFGITR_EL2, TLBIRVAE1OS, 24, 1)
178
+FIELD(HFGITR_EL2, TLBIRVAAE1OS, 25, 1)
179
+FIELD(HFGITR_EL2, TLBIRVALE1OS, 26, 1)
180
+FIELD(HFGITR_EL2, TLBIRVAALE1OS, 27, 1)
181
+FIELD(HFGITR_EL2, TLBIVMALLE1IS, 28, 1)
182
+FIELD(HFGITR_EL2, TLBIVAE1IS, 29, 1)
183
+FIELD(HFGITR_EL2, TLBIASIDE1IS, 30, 1)
184
+FIELD(HFGITR_EL2, TLBIVAAE1IS, 31, 1)
185
+FIELD(HFGITR_EL2, TLBIVALE1IS, 32, 1)
186
+FIELD(HFGITR_EL2, TLBIVAALE1IS, 33, 1)
187
+FIELD(HFGITR_EL2, TLBIRVAE1IS, 34, 1)
188
+FIELD(HFGITR_EL2, TLBIRVAAE1IS, 35, 1)
189
+FIELD(HFGITR_EL2, TLBIRVALE1IS, 36, 1)
190
+FIELD(HFGITR_EL2, TLBIRVAALE1IS, 37, 1)
191
+FIELD(HFGITR_EL2, TLBIRVAE1, 38, 1)
192
+FIELD(HFGITR_EL2, TLBIRVAAE1, 39, 1)
193
+FIELD(HFGITR_EL2, TLBIRVALE1, 40, 1)
194
+FIELD(HFGITR_EL2, TLBIRVAALE1, 41, 1)
195
+FIELD(HFGITR_EL2, TLBIVMALLE1, 42, 1)
196
+FIELD(HFGITR_EL2, TLBIVAE1, 43, 1)
197
+FIELD(HFGITR_EL2, TLBIASIDE1, 44, 1)
198
+FIELD(HFGITR_EL2, TLBIVAAE1, 45, 1)
199
+FIELD(HFGITR_EL2, TLBIVALE1, 46, 1)
200
+FIELD(HFGITR_EL2, TLBIVAALE1, 47, 1)
201
+FIELD(HFGITR_EL2, CFPRCTX, 48, 1)
202
+FIELD(HFGITR_EL2, DVPRCTX, 49, 1)
203
+FIELD(HFGITR_EL2, CPPRCTX, 50, 1)
204
+FIELD(HFGITR_EL2, ERET, 51, 1)
205
+FIELD(HFGITR_EL2, SVC_EL0, 52, 1)
206
+FIELD(HFGITR_EL2, SVC_EL1, 53, 1)
207
+FIELD(HFGITR_EL2, DCCVAC, 54, 1)
208
+FIELD(HFGITR_EL2, NBRBINJ, 55, 1)
209
+FIELD(HFGITR_EL2, NBRBIALL, 56, 1)
210
+
211
+FIELD(HDFGRTR_EL2, DBGBCRN_EL1, 0, 1)
212
+FIELD(HDFGRTR_EL2, DBGBVRN_EL1, 1, 1)
213
+FIELD(HDFGRTR_EL2, DBGWCRN_EL1, 2, 1)
214
+FIELD(HDFGRTR_EL2, DBGWVRN_EL1, 3, 1)
215
+FIELD(HDFGRTR_EL2, MDSCR_EL1, 4, 1)
216
+FIELD(HDFGRTR_EL2, DBGCLAIM, 5, 1)
217
+FIELD(HDFGRTR_EL2, DBGAUTHSTATUS_EL1, 6, 1)
218
+FIELD(HDFGRTR_EL2, DBGPRCR_EL1, 7, 1)
219
+/* 8: RES0: OSLAR_EL1 is WO */
220
+FIELD(HDFGRTR_EL2, OSLSR_EL1, 9, 1)
221
+FIELD(HDFGRTR_EL2, OSECCR_EL1, 10, 1)
222
+FIELD(HDFGRTR_EL2, OSDLR_EL1, 11, 1)
223
+FIELD(HDFGRTR_EL2, PMEVCNTRN_EL0, 12, 1)
224
+FIELD(HDFGRTR_EL2, PMEVTYPERN_EL0, 13, 1)
225
+FIELD(HDFGRTR_EL2, PMCCFILTR_EL0, 14, 1)
226
+FIELD(HDFGRTR_EL2, PMCCNTR_EL0, 15, 1)
227
+FIELD(HDFGRTR_EL2, PMCNTEN, 16, 1)
228
+FIELD(HDFGRTR_EL2, PMINTEN, 17, 1)
229
+FIELD(HDFGRTR_EL2, PMOVS, 18, 1)
230
+FIELD(HDFGRTR_EL2, PMSELR_EL0, 19, 1)
231
+/* 20: RES0: PMSWINC_EL0 is WO */
232
+/* 21: RES0: PMCR_EL0 is WO */
233
+FIELD(HDFGRTR_EL2, PMMIR_EL1, 22, 1)
234
+FIELD(HDFGRTR_EL2, PMBLIMITR_EL1, 23, 1)
235
+FIELD(HDFGRTR_EL2, PMBPTR_EL1, 24, 1)
236
+FIELD(HDFGRTR_EL2, PMBSR_EL1, 25, 1)
237
+FIELD(HDFGRTR_EL2, PMSCR_EL1, 26, 1)
238
+FIELD(HDFGRTR_EL2, PMSEVFR_EL1, 27, 1)
239
+FIELD(HDFGRTR_EL2, PMSFCR_EL1, 28, 1)
240
+FIELD(HDFGRTR_EL2, PMSICR_EL1, 29, 1)
241
+FIELD(HDFGRTR_EL2, PMSIDR_EL1, 30, 1)
242
+FIELD(HDFGRTR_EL2, PMSIRR_EL1, 31, 1)
243
+FIELD(HDFGRTR_EL2, PMSLATFR_EL1, 32, 1)
244
+FIELD(HDFGRTR_EL2, TRC, 33, 1)
245
+FIELD(HDFGRTR_EL2, TRCAUTHSTATUS, 34, 1)
246
+FIELD(HDFGRTR_EL2, TRCAUXCTLR, 35, 1)
247
+FIELD(HDFGRTR_EL2, TRCCLAIM, 36, 1)
248
+FIELD(HDFGRTR_EL2, TRCCNTVRn, 37, 1)
249
+/* 38, 39: RES0 */
250
+FIELD(HDFGRTR_EL2, TRCID, 40, 1)
251
+FIELD(HDFGRTR_EL2, TRCIMSPECN, 41, 1)
252
+/* 42: RES0: TRCOSLAR is WO */
253
+FIELD(HDFGRTR_EL2, TRCOSLSR, 43, 1)
254
+FIELD(HDFGRTR_EL2, TRCPRGCTLR, 44, 1)
255
+FIELD(HDFGRTR_EL2, TRCSEQSTR, 45, 1)
256
+FIELD(HDFGRTR_EL2, TRCSSCSRN, 46, 1)
257
+FIELD(HDFGRTR_EL2, TRCSTATR, 47, 1)
258
+FIELD(HDFGRTR_EL2, TRCVICTLR, 48, 1)
259
+/* 49: RES0: TRFCR_EL1 is WO */
260
+FIELD(HDFGRTR_EL2, TRBBASER_EL1, 50, 1)
261
+FIELD(HDFGRTR_EL2, TRBIDR_EL1, 51, 1)
262
+FIELD(HDFGRTR_EL2, TRBLIMITR_EL1, 52, 1)
263
+FIELD(HDFGRTR_EL2, TRBMAR_EL1, 53, 1)
264
+FIELD(HDFGRTR_EL2, TRBPTR_EL1, 54, 1)
265
+FIELD(HDFGRTR_EL2, TRBSR_EL1, 55, 1)
266
+FIELD(HDFGRTR_EL2, TRBTRG_EL1, 56, 1)
267
+FIELD(HDFGRTR_EL2, PMUSERENR_EL0, 57, 1)
268
+FIELD(HDFGRTR_EL2, PMCEIDN_EL0, 58, 1)
269
+FIELD(HDFGRTR_EL2, NBRBIDR, 59, 1)
270
+FIELD(HDFGRTR_EL2, NBRBCTL, 60, 1)
271
+FIELD(HDFGRTR_EL2, NBRBDATA, 61, 1)
272
+FIELD(HDFGRTR_EL2, NPMSNEVFR_EL1, 62, 1)
273
+FIELD(HDFGRTR_EL2, PMBIDR_EL1, 63, 1)
274
+
275
+/*
276
+ * These match HDFGRTR_EL2, but bits for RO registers are RES0.
277
+ * A few bits are for WO registers, where the HDFGRTR_EL2 bit is RES0.
278
+ */
279
+FIELD(HDFGWTR_EL2, DBGBCRN_EL1, 0, 1)
280
+FIELD(HDFGWTR_EL2, DBGBVRN_EL1, 1, 1)
281
+FIELD(HDFGWTR_EL2, DBGWCRN_EL1, 2, 1)
282
+FIELD(HDFGWTR_EL2, DBGWVRN_EL1, 3, 1)
283
+FIELD(HDFGWTR_EL2, MDSCR_EL1, 4, 1)
284
+FIELD(HDFGWTR_EL2, DBGCLAIM, 5, 1)
285
+FIELD(HDFGWTR_EL2, DBGPRCR_EL1, 7, 1)
286
+FIELD(HDFGWTR_EL2, OSLAR_EL1, 8, 1)
287
+FIELD(HDFGWTR_EL2, OSLSR_EL1, 9, 1)
288
+FIELD(HDFGWTR_EL2, OSECCR_EL1, 10, 1)
289
+FIELD(HDFGWTR_EL2, OSDLR_EL1, 11, 1)
290
+FIELD(HDFGWTR_EL2, PMEVCNTRN_EL0, 12, 1)
291
+FIELD(HDFGWTR_EL2, PMEVTYPERN_EL0, 13, 1)
292
+FIELD(HDFGWTR_EL2, PMCCFILTR_EL0, 14, 1)
293
+FIELD(HDFGWTR_EL2, PMCCNTR_EL0, 15, 1)
294
+FIELD(HDFGWTR_EL2, PMCNTEN, 16, 1)
295
+FIELD(HDFGWTR_EL2, PMINTEN, 17, 1)
296
+FIELD(HDFGWTR_EL2, PMOVS, 18, 1)
297
+FIELD(HDFGWTR_EL2, PMSELR_EL0, 19, 1)
298
+FIELD(HDFGWTR_EL2, PMSWINC_EL0, 20, 1)
299
+FIELD(HDFGWTR_EL2, PMCR_EL0, 21, 1)
300
+FIELD(HDFGWTR_EL2, PMBLIMITR_EL1, 23, 1)
301
+FIELD(HDFGWTR_EL2, PMBPTR_EL1, 24, 1)
302
+FIELD(HDFGWTR_EL2, PMBSR_EL1, 25, 1)
303
+FIELD(HDFGWTR_EL2, PMSCR_EL1, 26, 1)
304
+FIELD(HDFGWTR_EL2, PMSEVFR_EL1, 27, 1)
305
+FIELD(HDFGWTR_EL2, PMSFCR_EL1, 28, 1)
306
+FIELD(HDFGWTR_EL2, PMSICR_EL1, 29, 1)
307
+FIELD(HDFGWTR_EL2, PMSIRR_EL1, 31, 1)
308
+FIELD(HDFGWTR_EL2, PMSLATFR_EL1, 32, 1)
309
+FIELD(HDFGWTR_EL2, TRC, 33, 1)
310
+FIELD(HDFGWTR_EL2, TRCAUXCTLR, 35, 1)
311
+FIELD(HDFGWTR_EL2, TRCCLAIM, 36, 1)
312
+FIELD(HDFGWTR_EL2, TRCCNTVRn, 37, 1)
313
+FIELD(HDFGWTR_EL2, TRCIMSPECN, 41, 1)
314
+FIELD(HDFGWTR_EL2, TRCOSLAR, 42, 1)
315
+FIELD(HDFGWTR_EL2, TRCPRGCTLR, 44, 1)
316
+FIELD(HDFGWTR_EL2, TRCSEQSTR, 45, 1)
317
+FIELD(HDFGWTR_EL2, TRCSSCSRN, 46, 1)
318
+FIELD(HDFGWTR_EL2, TRCVICTLR, 48, 1)
319
+FIELD(HDFGWTR_EL2, TRFCR_EL1, 49, 1)
320
+FIELD(HDFGWTR_EL2, TRBBASER_EL1, 50, 1)
321
+FIELD(HDFGWTR_EL2, TRBLIMITR_EL1, 52, 1)
322
+FIELD(HDFGWTR_EL2, TRBMAR_EL1, 53, 1)
323
+FIELD(HDFGWTR_EL2, TRBPTR_EL1, 54, 1)
324
+FIELD(HDFGWTR_EL2, TRBSR_EL1, 55, 1)
325
+FIELD(HDFGWTR_EL2, TRBTRG_EL1, 56, 1)
326
+FIELD(HDFGWTR_EL2, PMUSERENR_EL0, 57, 1)
327
+FIELD(HDFGWTR_EL2, NBRBCTL, 60, 1)
328
+FIELD(HDFGWTR_EL2, NBRBDATA, 61, 1)
329
+FIELD(HDFGWTR_EL2, NPMSNEVFR_EL1, 62, 1)
330
+
331
typedef struct ARMCPRegInfo ARMCPRegInfo;
332
333
/*
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
334
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
15
index XXXXXXX..XXXXXXX 100644
335
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu.h
336
--- a/target/arm/cpu.h
17
+++ b/target/arm/cpu.h
337
+++ b/target/arm/cpu.h
18
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque);
338
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
19
* (Ignoring -1, this is the same as the RETTOBASE value before completion.)
339
uint64_t disr_el1;
20
*/
340
uint64_t vdisr_el2;
21
int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure);
341
uint64_t vsesr_el2;
22
+/**
342
+
23
+ * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
343
+ /*
24
+ * @opaque: the NVIC
344
+ * Fine-Grained Trap registers. We store these as arrays so the
25
+ * @irq: the exception number to mark pending
345
+ * access checking code doesn't have to manually select
26
+ * @secure: false for non-banked exceptions or for the nonsecure
346
+ * HFGRTR_EL2 vs HFDFGRTR_EL2 etc when looking up the bit to test.
27
+ * version of a banked exception, true for the secure version of a banked
347
+ * FEAT_FGT2 will add more elements to these arrays.
28
+ * exception.
348
+ */
29
+ *
349
+ uint64_t fgt_read[2]; /* HFGRTR, HDFGRTR */
30
+ * Return whether an exception is "ready", i.e. whether the exception is
350
+ uint64_t fgt_write[2]; /* HFGWTR, HDFGWTR */
31
+ * enabled and is configured at a priority which would allow it to
351
+ uint64_t fgt_exec[1]; /* HFGITR */
32
+ * interrupt the current execution priority. This controls whether the
352
} cp15;
33
+ * RDY bit for it in the FPCCR is set.
353
34
+ */
354
struct {
35
+bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure);
355
@@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_tgran64_2(const ARMISARegisters *id)
36
/**
356
return t >= 2 || (t == 0 && isar_feature_aa64_tgran64(id));
37
* armv7m_nvic_raw_execution_priority: return the raw execution priority
38
* @opaque: the NVIC
39
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
40
index XXXXXXX..XXXXXXX 100644
41
--- a/hw/intc/armv7m_nvic.c
42
+++ b/hw/intc/armv7m_nvic.c
43
@@ -XXX,XX +XXX,XX @@ int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure)
44
return ret;
45
}
357
}
46
358
47
+bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
359
+static inline bool isar_feature_aa64_fgt(const ARMISARegisters *id)
48
+{
360
+{
49
+ /*
361
+ return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, FGT) != 0;
50
+ * Return whether an exception is "ready", i.e. it is enabled and is
51
+ * configured at a priority which would allow it to interrupt the
52
+ * current execution priority.
53
+ *
54
+ * irq and secure have the same semantics as for armv7m_nvic_set_pending():
55
+ * for non-banked exceptions secure is always false; for banked exceptions
56
+ * it indicates which of the exceptions is required.
57
+ */
58
+ NVICState *s = (NVICState *)opaque;
59
+ bool banked = exc_is_banked(irq);
60
+ VecInfo *vec;
61
+ int running = nvic_exec_prio(s);
62
+
63
+ assert(irq > ARMV7M_EXCP_RESET && irq < s->num_irq);
64
+ assert(!secure || banked);
65
+
66
+ /*
67
+ * HardFault is an odd special case: we always check against -1,
68
+ * even if we're secure and HardFault has priority -3; we never
69
+ * need to check for enabled state.
70
+ */
71
+ if (irq == ARMV7M_EXCP_HARD) {
72
+ return running > -1;
73
+ }
74
+
75
+ vec = (banked && secure) ? &s->sec_vectors[irq] : &s->vectors[irq];
76
+
77
+ return vec->enabled &&
78
+ exc_group_prio(s, vec->prio, secure) < running;
79
+}
362
+}
80
+
363
+
81
/* callback when external interrupt line is changed */
364
static inline bool isar_feature_aa64_ccidx(const ARMISARegisters *id)
82
static void set_irq_level(void *opaque, int n, int level)
83
{
365
{
366
return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, CCIDX) != 0;
84
diff --git a/target/arm/helper.c b/target/arm/helper.c
367
diff --git a/target/arm/helper.c b/target/arm/helper.c
85
index XXXXXXX..XXXXXXX 100644
368
index XXXXXXX..XXXXXXX 100644
86
--- a/target/arm/helper.c
369
--- a/target/arm/helper.c
87
+++ b/target/arm/helper.c
370
+++ b/target/arm/helper.c
88
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
371
@@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
89
env->thumb = addr & 1;
372
if (cpu_isar_feature(aa64_hcx, cpu)) {
90
}
373
valid_mask |= SCR_HXEN;
91
374
}
92
+static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr,
375
+ if (cpu_isar_feature(aa64_fgt, cpu)) {
93
+ bool apply_splim)
376
+ valid_mask |= SCR_FGTEN;
377
+ }
378
} else {
379
valid_mask &= ~(SCR_RW | SCR_ST);
380
if (cpu_isar_feature(aa32_ras, cpu)) {
381
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo scxtnum_reginfo[] = {
382
.access = PL3_RW,
383
.fieldoffset = offsetof(CPUARMState, scxtnum_el[3]) },
384
};
385
+
386
+static CPAccessResult access_fgt(CPUARMState *env, const ARMCPRegInfo *ri,
387
+ bool isread)
94
+{
388
+{
95
+ /*
389
+ if (arm_current_el(env) == 2 &&
96
+ * Like the pseudocode UpdateFPCCR: save state in FPCAR and FPCCR
390
+ arm_feature(env, ARM_FEATURE_EL3) && !(env->cp15.scr_el3 & SCR_FGTEN)) {
97
+ * that we will need later in order to do lazy FP reg stacking.
391
+ return CP_ACCESS_TRAP_EL3;
98
+ */
99
+ bool is_secure = env->v7m.secure;
100
+ void *nvic = env->nvic;
101
+ /*
102
+ * Some bits are unbanked and live always in fpccr[M_REG_S]; some bits
103
+ * are banked and we want to update the bit in the bank for the
104
+ * current security state; and in one case we want to specifically
105
+ * update the NS banked version of a bit even if we are secure.
106
+ */
107
+ uint32_t *fpccr_s = &env->v7m.fpccr[M_REG_S];
108
+ uint32_t *fpccr_ns = &env->v7m.fpccr[M_REG_NS];
109
+ uint32_t *fpccr = &env->v7m.fpccr[is_secure];
110
+ bool hfrdy, bfrdy, mmrdy, ns_ufrdy, s_ufrdy, sfrdy, monrdy;
111
+
112
+ env->v7m.fpcar[is_secure] = frameptr & ~0x7;
113
+
114
+ if (apply_splim && arm_feature(env, ARM_FEATURE_V8)) {
115
+ bool splimviol;
116
+ uint32_t splim = v7m_sp_limit(env);
117
+ bool ign = armv7m_nvic_neg_prio_requested(nvic, is_secure) &&
118
+ (env->v7m.ccr[is_secure] & R_V7M_CCR_STKOFHFNMIGN_MASK);
119
+
120
+ splimviol = !ign && frameptr < splim;
121
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, SPLIMVIOL, splimviol);
122
+ }
392
+ }
123
+
393
+ return CP_ACCESS_OK;
124
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, LSPACT, 1);
394
+}
125
+
395
+
126
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, S, is_secure);
396
+static const ARMCPRegInfo fgt_reginfo[] = {
127
+
397
+ { .name = "HFGRTR_EL2", .state = ARM_CP_STATE_AA64,
128
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, USER, arm_current_el(env) == 0);
398
+ .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4,
129
+
399
+ .access = PL2_RW, .accessfn = access_fgt,
130
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, THREAD,
400
+ .fieldoffset = offsetof(CPUARMState, cp15.fgt_read[FGTREG_HFGRTR]) },
131
+ !arm_v7m_is_handler_mode(env));
401
+ { .name = "HFGWTR_EL2", .state = ARM_CP_STATE_AA64,
132
+
402
+ .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 5,
133
+ hfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_HARD, false);
403
+ .access = PL2_RW, .accessfn = access_fgt,
134
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, HFRDY, hfrdy);
404
+ .fieldoffset = offsetof(CPUARMState, cp15.fgt_write[FGTREG_HFGWTR]) },
135
+
405
+ { .name = "HDFGRTR_EL2", .state = ARM_CP_STATE_AA64,
136
+ bfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_BUS, false);
406
+ .opc0 = 3, .opc1 = 4, .crn = 3, .crm = 1, .opc2 = 4,
137
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, BFRDY, bfrdy);
407
+ .access = PL2_RW, .accessfn = access_fgt,
138
+
408
+ .fieldoffset = offsetof(CPUARMState, cp15.fgt_read[FGTREG_HDFGRTR]) },
139
+ mmrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_MEM, is_secure);
409
+ { .name = "HDFGWTR_EL2", .state = ARM_CP_STATE_AA64,
140
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, MMRDY, mmrdy);
410
+ .opc0 = 3, .opc1 = 4, .crn = 3, .crm = 1, .opc2 = 5,
141
+
411
+ .access = PL2_RW, .accessfn = access_fgt,
142
+ ns_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, false);
412
+ .fieldoffset = offsetof(CPUARMState, cp15.fgt_write[FGTREG_HDFGWTR]) },
143
+ *fpccr_ns = FIELD_DP32(*fpccr_ns, V7M_FPCCR, UFRDY, ns_ufrdy);
413
+ { .name = "HFGITR_EL2", .state = ARM_CP_STATE_AA64,
144
+
414
+ .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 6,
145
+ monrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_DEBUG, false);
415
+ .access = PL2_RW, .accessfn = access_fgt,
146
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, MONRDY, monrdy);
416
+ .fieldoffset = offsetof(CPUARMState, cp15.fgt_exec[FGTREG_HFGITR]) },
147
+
417
+};
148
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
418
#endif /* TARGET_AARCH64 */
149
+ s_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, true);
419
150
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, UFRDY, s_ufrdy);
420
static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri,
151
+
421
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
152
+ sfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_SECURE, false);
422
if (cpu_isar_feature(aa64_scxtnum, cpu)) {
153
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, SFRDY, sfrdy);
423
define_arm_cp_regs(cpu, scxtnum_reginfo);
424
}
425
+
426
+ if (cpu_isar_feature(aa64_fgt, cpu)) {
427
+ define_arm_cp_regs(cpu, fgt_reginfo);
154
+ }
428
+ }
155
+}
429
#endif
156
+
430
157
static bool v7m_push_stack(ARMCPU *cpu)
431
if (cpu_isar_feature(any_predinv, cpu)) {
158
{
159
/* Do the "set up stack frame" part of exception entry,
160
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
161
}
162
} else {
163
/* Lazy stacking enabled, save necessary info to stack later */
164
- /* TODO : equivalent of UpdateFPCCR() pseudocode */
165
+ v7m_update_fpccr(env, frameptr + 0x20, true);
166
}
167
}
168
}
169
--
432
--
170
2.20.1
433
2.34.1
171
172
diff view generated by jsdifflib
1
The M-profile architecture floating point system supports
1
Implement the machinery for fine-grained traps on normal sysregs.
2
lazy FP state preservation, where FP registers are not
2
Any sysreg with a fine-grained trap will set the new field to
3
pushed to the stack when an exception occurs but are instead
3
indicate which FGT register bit it should trap on.
4
only saved if and when the first FP instruction in the exception
4
5
handler is executed. Implement this in QEMU, corresponding
5
FGT traps only happen when an AArch64 EL2 enables them for
6
to the check of LSPACT in the pseudocode ExecuteFPCheck().
6
an AArch64 EL1. They therefore are only relevant for AArch32
7
cpregs when the cpreg can be accessed from EL0. The logic
8
in access_check_cp_reg() will check this, so it is safe to
9
add a .fgt marking to an ARM_CP_STATE_BOTH ARMCPRegInfo.
10
11
The DO_BIT and DO_REV_BIT macros define enum constants FGT_##bitname
12
which can be used to specify the FGT bit, eg
13
.fgt = FGT_AFSR0_EL1
14
(We assume that there is no bit name duplication across the FGT
15
registers, for brevity's sake.)
16
17
Subsequent commits will add the .fgt fields to the relevant register
18
definitions and define the FGT_nnn values for them.
19
20
Note that some of the FGT traps are for instructions that we don't
21
handle via the cpregs mechanisms (mostly these are instruction traps).
22
Those we will have to handle separately.
7
23
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
25
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20190416125744.27770-24-peter.maydell@linaro.org
26
Tested-by: Fuad Tabba <tabba@google.com>
27
Message-id: 20230130182459.3309057-10-peter.maydell@linaro.org
28
Message-id: 20230127175507.2895013-10-peter.maydell@linaro.org
11
---
29
---
12
target/arm/cpu.h | 3 ++
30
target/arm/cpregs.h | 72 ++++++++++++++++++++++++++++++++++++++
13
target/arm/helper.h | 2 +
31
target/arm/cpu.h | 1 +
14
target/arm/translate.h | 1 +
32
target/arm/internals.h | 20 +++++++++++
15
target/arm/helper.c | 112 +++++++++++++++++++++++++++++++++++++++++
33
target/arm/translate.h | 2 ++
16
target/arm/translate.c | 22 ++++++++
34
target/arm/helper.c | 9 +++++
17
5 files changed, 140 insertions(+)
35
target/arm/op_helper.c | 30 ++++++++++++++++
18
36
target/arm/translate-a64.c | 3 +-
37
target/arm/translate.c | 2 ++
38
8 files changed, 138 insertions(+), 1 deletion(-)
39
40
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
41
index XXXXXXX..XXXXXXX 100644
42
--- a/target/arm/cpregs.h
43
+++ b/target/arm/cpregs.h
44
@@ -XXX,XX +XXX,XX @@ FIELD(HDFGWTR_EL2, NBRBCTL, 60, 1)
45
FIELD(HDFGWTR_EL2, NBRBDATA, 61, 1)
46
FIELD(HDFGWTR_EL2, NPMSNEVFR_EL1, 62, 1)
47
48
+/* Which fine-grained trap bit register to check, if any */
49
+FIELD(FGT, TYPE, 10, 3)
50
+FIELD(FGT, REV, 9, 1) /* Is bit sense reversed? */
51
+FIELD(FGT, IDX, 6, 3) /* Index within a uint64_t[] array */
52
+FIELD(FGT, BITPOS, 0, 6) /* Bit position within the uint64_t */
53
+
54
+/*
55
+ * Macros to define FGT_##bitname enum constants to use in ARMCPRegInfo::fgt
56
+ * fields. We assume for brevity's sake that there are no duplicated
57
+ * bit names across the various FGT registers.
58
+ */
59
+#define DO_BIT(REG, BITNAME) \
60
+ FGT_##BITNAME = FGT_##REG | R_##REG##_EL2_##BITNAME##_SHIFT
61
+
62
+/* Some bits have reversed sense, so 0 means trap and 1 means not */
63
+#define DO_REV_BIT(REG, BITNAME) \
64
+ FGT_##BITNAME = FGT_##REG | FGT_REV | R_##REG##_EL2_##BITNAME##_SHIFT
65
+
66
+typedef enum FGTBit {
67
+ /*
68
+ * These bits tell us which register arrays to use:
69
+ * if FGT_R is set then reads are checked against fgt_read[];
70
+ * if FGT_W is set then writes are checked against fgt_write[];
71
+ * if FGT_EXEC is set then all accesses are checked against fgt_exec[].
72
+ *
73
+ * For almost all bits in the R/W register pairs, the bit exists in
74
+ * both registers for a RW register, in HFGRTR/HDFGRTR for a RO register
75
+ * with the corresponding HFGWTR/HDFGTWTR bit being RES0, and vice-versa
76
+ * for a WO register. There are unfortunately a couple of exceptions
77
+ * (PMCR_EL0, TRFCR_EL1) where the register being trapped is RW but
78
+ * the FGT system only allows trapping of writes, not reads.
79
+ *
80
+ * Note that we arrange these bits so that a 0 FGTBit means "no trap".
81
+ */
82
+ FGT_R = 1 << R_FGT_TYPE_SHIFT,
83
+ FGT_W = 2 << R_FGT_TYPE_SHIFT,
84
+ FGT_EXEC = 4 << R_FGT_TYPE_SHIFT,
85
+ FGT_RW = FGT_R | FGT_W,
86
+ /* Bit to identify whether trap bit is reversed sense */
87
+ FGT_REV = R_FGT_REV_MASK,
88
+
89
+ /*
90
+ * If a bit exists in HFGRTR/HDFGRTR then either the register being
91
+ * trapped is RO or the bit also exists in HFGWTR/HDFGWTR, so we either
92
+ * want to trap for both reads and writes or else it's harmless to mark
93
+ * it as trap-on-writes.
94
+ * If a bit exists only in HFGWTR/HDFGWTR then either the register being
95
+ * trapped is WO, or else it is one of the two oddball special cases
96
+ * which are RW but have only a write trap. We mark these as only
97
+ * FGT_W so we get the right behaviour for those special cases.
98
+ * (If a bit was added in future that provided only a read trap for an
99
+ * RW register we'd need to do something special to get the FGT_R bit
100
+ * only. But this seems unlikely to happen.)
101
+ *
102
+ * So for the DO_BIT/DO_REV_BIT macros: use FGT_HFGRTR/FGT_HDFGRTR if
103
+ * the bit exists in that register. Otherwise use FGT_HFGWTR/FGT_HDFGWTR.
104
+ */
105
+ FGT_HFGRTR = FGT_RW | (FGTREG_HFGRTR << R_FGT_IDX_SHIFT),
106
+ FGT_HFGWTR = FGT_W | (FGTREG_HFGWTR << R_FGT_IDX_SHIFT),
107
+ FGT_HDFGRTR = FGT_RW | (FGTREG_HDFGRTR << R_FGT_IDX_SHIFT),
108
+ FGT_HDFGWTR = FGT_W | (FGTREG_HDFGWTR << R_FGT_IDX_SHIFT),
109
+ FGT_HFGITR = FGT_EXEC | (FGTREG_HFGITR << R_FGT_IDX_SHIFT),
110
+} FGTBit;
111
+
112
+#undef DO_BIT
113
+#undef DO_REV_BIT
114
+
115
typedef struct ARMCPRegInfo ARMCPRegInfo;
116
117
/*
118
@@ -XXX,XX +XXX,XX @@ struct ARMCPRegInfo {
119
CPAccessRights access;
120
/* Security state: ARM_CP_SECSTATE_* bits/values */
121
CPSecureState secure;
122
+ /*
123
+ * Which fine-grained trap register bit to check, if any. This
124
+ * value encodes both the trap register and bit within it.
125
+ */
126
+ FGTBit fgt;
127
/*
128
* The opaque pointer passed to define_arm_cp_regs_with_opaque() when
129
* this register was defined: can be used to hand data through to the
19
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
130
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
20
index XXXXXXX..XXXXXXX 100644
131
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/cpu.h
132
--- a/target/arm/cpu.h
22
+++ b/target/arm/cpu.h
133
+++ b/target/arm/cpu.h
23
@@ -XXX,XX +XXX,XX @@
134
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, FPEXC_EL, 8, 2)
24
#define EXCP_NOCP 17 /* v7M NOCP UsageFault */
135
/* Memory operations require alignment: SCTLR_ELx.A or CCR.UNALIGN_TRP */
25
#define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */
136
FIELD(TBFLAG_ANY, ALIGN_MEM, 10, 1)
26
#define EXCP_STKOF 19 /* v8M STKOF UsageFault */
137
FIELD(TBFLAG_ANY, PSTATE__IL, 11, 1)
27
+#define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */
138
+FIELD(TBFLAG_ANY, FGT_ACTIVE, 12, 1)
28
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
139
29
140
/*
30
#define ARMV7M_EXCP_RESET 1
141
* Bit usage when in AArch32 state, both A- and M-profile.
31
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
142
diff --git a/target/arm/internals.h b/target/arm/internals.h
32
FIELD(TBFLAG_A32, VFPEN, 7, 1)
143
index XXXXXXX..XXXXXXX 100644
33
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
144
--- a/target/arm/internals.h
34
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
145
+++ b/target/arm/internals.h
35
+/* For M profile only, set if FPCCR.LSPACT is set */
146
@@ -XXX,XX +XXX,XX @@ static inline uint64_t arm_mdcr_el2_eff(CPUARMState *env)
36
+FIELD(TBFLAG_A32, LSPACT, 18, 1)
147
((1 << (1 - 1)) | (1 << (2 - 1)) | \
37
/* For M profile only, set if we must create a new FP context */
148
(1 << (4 - 1)) | (1 << (8 - 1)) | (1 << (16 - 1)))
38
FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1)
149
39
/* For M profile only, set if FPCCR.S does not match current security state */
150
+/*
40
diff --git a/target/arm/helper.h b/target/arm/helper.h
151
+ * Return true if it is possible to take a fine-grained-trap to EL2.
41
index XXXXXXX..XXXXXXX 100644
152
+ */
42
--- a/target/arm/helper.h
153
+static inline bool arm_fgt_active(CPUARMState *env, int el)
43
+++ b/target/arm/helper.h
154
+{
44
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(v7m_blxns, void, env, i32)
155
+ /*
45
156
+ * The Arm ARM only requires the "{E2H,TGE} != {1,1}" test for traps
46
DEF_HELPER_3(v7m_tt, i32, env, i32, i32)
157
+ * that can affect EL0, but it is harmless to do the test also for
47
158
+ * traps on registers that are only accessible at EL1 because if the test
48
+DEF_HELPER_1(v7m_preserve_fp_state, void, env)
159
+ * returns true then we can't be executing at EL1 anyway.
49
+
160
+ * FGT traps only happen when EL2 is enabled and EL1 is AArch64;
50
DEF_HELPER_2(v8m_stackcheck, void, env, i32)
161
+ * traps from AArch32 only happen for the EL0 is AArch32 case.
51
162
+ */
52
DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32)
163
+ return cpu_isar_feature(aa64_fgt, env_archcpu(env)) &&
164
+ el < 2 && arm_is_el2_enabled(env) &&
165
+ arm_el_is_aa64(env, 1) &&
166
+ (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE) &&
167
+ (!arm_feature(env, ARM_FEATURE_EL3) || (env->cp15.scr_el3 & SCR_FGTEN));
168
+}
169
+
170
#endif
53
diff --git a/target/arm/translate.h b/target/arm/translate.h
171
diff --git a/target/arm/translate.h b/target/arm/translate.h
54
index XXXXXXX..XXXXXXX 100644
172
index XXXXXXX..XXXXXXX 100644
55
--- a/target/arm/translate.h
173
--- a/target/arm/translate.h
56
+++ b/target/arm/translate.h
174
+++ b/target/arm/translate.h
57
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
175
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
58
bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */
176
bool is_nonstreaming;
59
bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */
177
/* True if MVE insns are definitely not predicated by VPR or LTPSIZE */
60
bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */
178
bool mve_no_pred;
61
+ bool v7m_lspact; /* FPCCR.LSPACT set */
179
+ /* True if fine-grained traps are active */
62
/* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI
180
+ bool fgt_active;
63
* so that top level loop can generate correct syndrome information.
181
/*
64
*/
182
* >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI.
183
* < 0, set by the current instruction.
65
diff --git a/target/arm/helper.c b/target/arm/helper.c
184
diff --git a/target/arm/helper.c b/target/arm/helper.c
66
index XXXXXXX..XXXXXXX 100644
185
index XXXXXXX..XXXXXXX 100644
67
--- a/target/arm/helper.c
186
--- a/target/arm/helper.c
68
+++ b/target/arm/helper.c
187
+++ b/target/arm/helper.c
69
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
188
@@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el,
70
g_assert_not_reached();
189
if (arm_singlestep_active(env)) {
190
DP_TBFLAG_ANY(flags, SS_ACTIVE, 1);
191
}
192
+
193
return flags;
71
}
194
}
72
195
73
+void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
196
@@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el,
74
+{
197
DP_TBFLAG_A32(flags, HSTR_ACTIVE, 1);
75
+ /* translate.c should never generate calls here in user-only mode */
198
}
76
+ g_assert_not_reached();
199
77
+}
200
+ if (arm_fgt_active(env, el)) {
78
+
201
+ DP_TBFLAG_ANY(flags, FGT_ACTIVE, 1);
79
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
80
{
81
/* The TT instructions can be used by unprivileged code, but in
82
@@ -XXX,XX +XXX,XX @@ pend_fault:
83
return false;
84
}
85
86
+void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
87
+{
88
+ /*
89
+ * Preserve FP state (because LSPACT was set and we are about
90
+ * to execute an FP instruction). This corresponds to the
91
+ * PreserveFPState() pseudocode.
92
+ * We may throw an exception if the stacking fails.
93
+ */
94
+ ARMCPU *cpu = arm_env_get_cpu(env);
95
+ bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
96
+ bool negpri = !(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_HFRDY_MASK);
97
+ bool is_priv = !(env->v7m.fpccr[is_secure] & R_V7M_FPCCR_USER_MASK);
98
+ bool splimviol = env->v7m.fpccr[is_secure] & R_V7M_FPCCR_SPLIMVIOL_MASK;
99
+ uint32_t fpcar = env->v7m.fpcar[is_secure];
100
+ bool stacked_ok = true;
101
+ bool ts = is_secure && (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK);
102
+ bool take_exception;
103
+
104
+ /* Take the iothread lock as we are going to touch the NVIC */
105
+ qemu_mutex_lock_iothread();
106
+
107
+ /* Check the background context had access to the FPU */
108
+ if (!v7m_cpacr_pass(env, is_secure, is_priv)) {
109
+ armv7m_nvic_set_pending_lazyfp(env->nvic, ARMV7M_EXCP_USAGE, is_secure);
110
+ env->v7m.cfsr[is_secure] |= R_V7M_CFSR_NOCP_MASK;
111
+ stacked_ok = false;
112
+ } else if (!is_secure && !extract32(env->v7m.nsacr, 10, 1)) {
113
+ armv7m_nvic_set_pending_lazyfp(env->nvic, ARMV7M_EXCP_USAGE, M_REG_S);
114
+ env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_NOCP_MASK;
115
+ stacked_ok = false;
116
+ }
202
+ }
117
+
203
+
118
+ if (!splimviol && stacked_ok) {
204
if (env->uncached_cpsr & CPSR_IL) {
119
+ /* We only stack if the stack limit wasn't violated */
205
DP_TBFLAG_ANY(flags, PSTATE__IL, 1);
120
+ int i;
206
}
121
+ ARMMMUIdx mmu_idx;
207
@@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
122
+
208
DP_TBFLAG_ANY(flags, PSTATE__IL, 1);
123
+ mmu_idx = arm_v7m_mmu_idx_all(env, is_secure, is_priv, negpri);
209
}
124
+ for (i = 0; i < (ts ? 32 : 16); i += 2) {
210
125
+ uint64_t dn = *aa32_vfp_dreg(env, i / 2);
211
+ if (arm_fgt_active(env, el)) {
126
+ uint32_t faddr = fpcar + 4 * i;
212
+ DP_TBFLAG_ANY(flags, FGT_ACTIVE, 1);
127
+ uint32_t slo = extract64(dn, 0, 32);
213
+ }
128
+ uint32_t shi = extract64(dn, 32, 32);
214
+
129
+
215
if (cpu_isar_feature(aa64_mte, env_archcpu(env))) {
130
+ if (i >= 16) {
216
/*
131
+ faddr += 8; /* skip the slot for the FPSCR */
217
* Set MTE_ACTIVE if any access may be Checked, and leave clear
132
+ }
218
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
133
+ stacked_ok = stacked_ok &&
219
index XXXXXXX..XXXXXXX 100644
134
+ v7m_stack_write(cpu, faddr, slo, mmu_idx, STACK_LAZYFP) &&
220
--- a/target/arm/op_helper.c
135
+ v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, STACK_LAZYFP);
221
+++ b/target/arm/op_helper.c
222
@@ -XXX,XX +XXX,XX @@ const void *HELPER(access_check_cp_reg)(CPUARMState *env, uint32_t key,
223
}
224
}
225
226
+ /*
227
+ * Fine-grained traps also are lower priority than undef-to-EL1,
228
+ * higher priority than trap-to-EL3, and we don't care about priority
229
+ * order with other EL2 traps because the syndrome value is the same.
230
+ */
231
+ if (arm_fgt_active(env, arm_current_el(env))) {
232
+ uint64_t trapword = 0;
233
+ unsigned int idx = FIELD_EX32(ri->fgt, FGT, IDX);
234
+ unsigned int bitpos = FIELD_EX32(ri->fgt, FGT, BITPOS);
235
+ bool rev = FIELD_EX32(ri->fgt, FGT, REV);
236
+ bool trapbit;
237
+
238
+ if (ri->fgt & FGT_EXEC) {
239
+ assert(idx < ARRAY_SIZE(env->cp15.fgt_exec));
240
+ trapword = env->cp15.fgt_exec[idx];
241
+ } else if (isread && (ri->fgt & FGT_R)) {
242
+ assert(idx < ARRAY_SIZE(env->cp15.fgt_read));
243
+ trapword = env->cp15.fgt_read[idx];
244
+ } else if (!isread && (ri->fgt & FGT_W)) {
245
+ assert(idx < ARRAY_SIZE(env->cp15.fgt_write));
246
+ trapword = env->cp15.fgt_write[idx];
136
+ }
247
+ }
137
+
248
+
138
+ stacked_ok = stacked_ok &&
249
+ trapbit = extract64(trapword, bitpos, 1);
139
+ v7m_stack_write(cpu, fpcar + 0x40,
250
+ if (trapbit != rev) {
140
+ vfp_get_fpscr(env), mmu_idx, STACK_LAZYFP);
251
+ res = CP_ACCESS_TRAP_EL2;
141
+ }
252
+ goto fail;
142
+
143
+ /*
144
+ * We definitely pended an exception, but it's possible that it
145
+ * might not be able to be taken now. If its priority permits us
146
+ * to take it now, then we must not update the LSPACT or FP regs,
147
+ * but instead jump out to take the exception immediately.
148
+ * If it's just pending and won't be taken until the current
149
+ * handler exits, then we do update LSPACT and the FP regs.
150
+ */
151
+ take_exception = !stacked_ok &&
152
+ armv7m_nvic_can_take_pending_exception(env->nvic);
153
+
154
+ qemu_mutex_unlock_iothread();
155
+
156
+ if (take_exception) {
157
+ raise_exception_ra(env, EXCP_LAZYFP, 0, 1, GETPC());
158
+ }
159
+
160
+ env->v7m.fpccr[is_secure] &= ~R_V7M_FPCCR_LSPACT_MASK;
161
+
162
+ if (ts) {
163
+ /* Clear s0 to s31 and the FPSCR */
164
+ int i;
165
+
166
+ for (i = 0; i < 32; i += 2) {
167
+ *aa32_vfp_dreg(env, i / 2) = 0;
168
+ }
169
+ vfp_set_fpscr(env, 0);
170
+ }
171
+ /*
172
+ * Otherwise s0 to s15 and FPSCR are UNKNOWN; we choose to leave them
173
+ * unchanged.
174
+ */
175
+}
176
+
177
/* Write to v7M CONTROL.SPSEL bit for the specified security bank.
178
* This may change the current stack pointer between Main and Process
179
* stack pointers if it is done for the CONTROL register for the current
180
@@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx)
181
[EXCP_NOCP] = "v7M NOCP UsageFault",
182
[EXCP_INVSTATE] = "v7M INVSTATE UsageFault",
183
[EXCP_STKOF] = "v8M STKOF UsageFault",
184
+ [EXCP_LAZYFP] = "v7M exception during lazy FP stacking",
185
};
186
187
if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
188
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
189
return;
190
}
191
break;
192
+ case EXCP_LAZYFP:
193
+ /*
194
+ * We already pended the specific exception in the NVIC in the
195
+ * v7m_preserve_fp_state() helper function.
196
+ */
197
+ break;
198
default:
199
cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
200
return; /* Never happens. Keep compiler happy. */
201
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
202
flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1);
203
}
204
205
+ if (arm_feature(env, ARM_FEATURE_M)) {
206
+ bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
207
+
208
+ if (env->v7m.fpccr[is_secure] & R_V7M_FPCCR_LSPACT_MASK) {
209
+ flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1);
210
+ }
253
+ }
211
+ }
254
+ }
212
+
255
+
213
*pflags = flags;
256
if (likely(res == CP_ACCESS_OK)) {
214
*cs_base = 0;
257
return ri;
215
}
258
}
259
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
260
index XXXXXXX..XXXXXXX 100644
261
--- a/target/arm/translate-a64.c
262
+++ b/target/arm/translate-a64.c
263
@@ -XXX,XX +XXX,XX @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,
264
return;
265
}
266
267
- if (ri->accessfn) {
268
+ if (ri->accessfn || (ri->fgt && s->fgt_active)) {
269
/* Emit code to perform further access permissions checks at
270
* runtime; this may result in an exception.
271
*/
272
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase,
273
dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL);
274
dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM);
275
dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL);
276
+ dc->fgt_active = EX_TBFLAG_ANY(tb_flags, FGT_ACTIVE);
277
dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL);
278
dc->sme_excp_el = EX_TBFLAG_A64(tb_flags, SMEEXC_EL);
279
dc->vl = (EX_TBFLAG_A64(tb_flags, VL) + 1) * 16;
216
diff --git a/target/arm/translate.c b/target/arm/translate.c
280
diff --git a/target/arm/translate.c b/target/arm/translate.c
217
index XXXXXXX..XXXXXXX 100644
281
index XXXXXXX..XXXXXXX 100644
218
--- a/target/arm/translate.c
282
--- a/target/arm/translate.c
219
+++ b/target/arm/translate.c
283
+++ b/target/arm/translate.c
220
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
284
@@ -XXX,XX +XXX,XX @@ static void do_coproc_insn(DisasContext *s, int cpnum, int is64,
221
if (arm_dc_feature(s, ARM_FEATURE_M)) {
285
}
222
/* Handle M-profile lazy FP state mechanics */
286
223
287
if ((s->hstr_active && s->current_el == 0) || ri->accessfn ||
224
+ /* Trigger lazy-state preservation if necessary */
288
+ (ri->fgt && s->fgt_active) ||
225
+ if (s->v7m_lspact) {
289
(arm_dc_feature(s, ARM_FEATURE_XSCALE) && cpnum < 14)) {
226
+ /*
290
/*
227
+ * Lazy state saving affects external memory and also the NVIC,
291
* Emit code to perform further access permissions checks at
228
+ * so we must mark it as an IO operation for icount.
229
+ */
230
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
231
+ gen_io_start();
232
+ }
233
+ gen_helper_v7m_preserve_fp_state(cpu_env);
234
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
235
+ gen_io_end();
236
+ }
237
+ /*
238
+ * If the preserve_fp_state helper doesn't throw an exception
239
+ * then it will clear LSPACT; we don't need to repeat this for
240
+ * any further FP insns in this TB.
241
+ */
242
+ s->v7m_lspact = false;
243
+ }
244
+
245
/* Update ownership of FP context: set FPCCR.S to match current state */
246
if (s->v8m_fpccr_s_wrong) {
247
TCGv_i32 tmp;
248
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
292
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
249
dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG);
293
dc->fp_excp_el = EX_TBFLAG_ANY(tb_flags, FPEXC_EL);
250
dc->v7m_new_fp_ctxt_needed =
294
dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM);
251
FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED);
295
dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL);
252
+ dc->v7m_lspact = FIELD_EX32(tb_flags, TBFLAG_A32, LSPACT);
296
+ dc->fgt_active = EX_TBFLAG_ANY(tb_flags, FGT_ACTIVE);
253
dc->cp_regs = cpu->cp_regs;
297
254
dc->features = env->features;
298
if (arm_feature(env, ARM_FEATURE_M)) {
255
299
dc->vfp_enabled = 1;
256
--
300
--
257
2.20.1
301
2.34.1
258
259
diff view generated by jsdifflib
1
The magic value pushed onto the callee stack as an integrity
1
Mark up the sysreg definitions for the registers trapped
2
check is different if floating point is present.
2
by HFGRTR/HFGWTR bits 0..11.
3
3
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20190416125744.27770-15-peter.maydell@linaro.org
6
Tested-by: Fuad Tabba <tabba@google.com>
7
Message-id: 20230130182459.3309057-11-peter.maydell@linaro.org
8
Message-id: 20230127175507.2895013-11-peter.maydell@linaro.org
7
---
9
---
8
target/arm/helper.c | 22 +++++++++++++++++++---
10
target/arm/cpregs.h | 14 ++++++++++++++
9
1 file changed, 19 insertions(+), 3 deletions(-)
11
target/arm/helper.c | 17 +++++++++++++++++
12
2 files changed, 31 insertions(+)
10
13
14
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpregs.h
17
+++ b/target/arm/cpregs.h
18
@@ -XXX,XX +XXX,XX @@ typedef enum FGTBit {
19
FGT_HDFGRTR = FGT_RW | (FGTREG_HDFGRTR << R_FGT_IDX_SHIFT),
20
FGT_HDFGWTR = FGT_W | (FGTREG_HDFGWTR << R_FGT_IDX_SHIFT),
21
FGT_HFGITR = FGT_EXEC | (FGTREG_HFGITR << R_FGT_IDX_SHIFT),
22
+
23
+ /* Trap bits in HFGRTR_EL2 / HFGWTR_EL2, starting from bit 0. */
24
+ DO_BIT(HFGRTR, AFSR0_EL1),
25
+ DO_BIT(HFGRTR, AFSR1_EL1),
26
+ DO_BIT(HFGRTR, AIDR_EL1),
27
+ DO_BIT(HFGRTR, AMAIR_EL1),
28
+ DO_BIT(HFGRTR, APDAKEY),
29
+ DO_BIT(HFGRTR, APDBKEY),
30
+ DO_BIT(HFGRTR, APGAKEY),
31
+ DO_BIT(HFGRTR, APIAKEY),
32
+ DO_BIT(HFGRTR, APIBKEY),
33
+ DO_BIT(HFGRTR, CCSIDR_EL1),
34
+ DO_BIT(HFGRTR, CLIDR_EL1),
35
+ DO_BIT(HFGRTR, CONTEXTIDR_EL1),
36
} FGTBit;
37
38
#undef DO_BIT
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
39
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
index XXXXXXX..XXXXXXX 100644
40
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
41
--- a/target/arm/helper.c
14
+++ b/target/arm/helper.c
42
+++ b/target/arm/helper.c
15
@@ -XXX,XX +XXX,XX @@ load_fail:
43
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cp_reginfo[] = {
16
return false;
44
{ .name = "CONTEXTIDR_EL1", .state = ARM_CP_STATE_BOTH,
17
}
45
.opc0 = 3, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 1,
18
46
.access = PL1_RW, .accessfn = access_tvm_trvm,
19
+static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr)
47
+ .fgt = FGT_CONTEXTIDR_EL1,
20
+{
48
.secure = ARM_CP_SECSTATE_NS,
21
+ /*
49
.fieldoffset = offsetof(CPUARMState, cp15.contextidr_el[1]),
22
+ * Return the integrity signature value for the callee-saves
50
.resetvalue = 0, .writefn = contextidr_write, .raw_writefn = raw_write, },
23
+ * stack frame section. @lr is the exception return payload/LR value
51
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
24
+ * whose FType bit forms bit 0 of the signature if FP is present.
52
.opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 0,
25
+ */
53
.access = PL1_R,
26
+ uint32_t sig = 0xfefa125a;
54
.accessfn = access_tid4,
27
+
55
+ .fgt = FGT_CCSIDR_EL1,
28
+ if (!arm_feature(env, ARM_FEATURE_VFP) || (lr & R_V7M_EXCRET_FTYPE_MASK)) {
56
.readfn = ccsidr_read, .type = ARM_CP_NO_RAW },
29
+ sig |= 1;
57
{ .name = "CSSELR", .state = ARM_CP_STATE_BOTH,
30
+ }
58
.opc0 = 3, .crn = 0, .crm = 0, .opc1 = 2, .opc2 = 0,
31
+ return sig;
59
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
32
+}
60
.opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 7,
33
+
61
.access = PL1_R, .type = ARM_CP_CONST,
34
static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
62
.accessfn = access_aa64_tid1,
35
bool ignore_faults)
63
+ .fgt = FGT_AIDR_EL1,
36
{
64
.resetvalue = 0 },
37
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
65
/*
38
bool stacked_ok;
66
* Auxiliary fault status registers: these also are IMPDEF, and we
39
uint32_t limit;
67
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
40
bool want_psp;
68
{ .name = "AFSR0_EL1", .state = ARM_CP_STATE_BOTH,
41
+ uint32_t sig;
69
.opc0 = 3, .opc1 = 0, .crn = 5, .crm = 1, .opc2 = 0,
42
70
.access = PL1_RW, .accessfn = access_tvm_trvm,
43
if (dotailchain) {
71
+ .fgt = FGT_AFSR0_EL1,
44
bool mode = lr & R_V7M_EXCRET_MODE_MASK;
72
.type = ARM_CP_CONST, .resetvalue = 0 },
45
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
73
{ .name = "AFSR1_EL1", .state = ARM_CP_STATE_BOTH,
46
/* Write as much of the stack frame as we can. A write failure may
74
.opc0 = 3, .opc1 = 0, .crn = 5, .crm = 1, .opc2 = 1,
47
* cause us to pend a derived exception.
75
.access = PL1_RW, .accessfn = access_tvm_trvm,
48
*/
76
+ .fgt = FGT_AFSR1_EL1,
49
+ sig = v7m_integrity_sig(env, lr);
77
.type = ARM_CP_CONST, .resetvalue = 0 },
50
stacked_ok =
78
/*
51
- v7m_stack_write(cpu, frameptr, 0xfefa125b, mmu_idx, ignore_faults) &&
79
* MAIR can just read-as-written because we don't implement caches
52
+ v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) &&
80
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lpae_cp_reginfo[] = {
53
v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx,
81
{ .name = "AMAIR0", .state = ARM_CP_STATE_BOTH,
54
ignore_faults) &&
82
.opc0 = 3, .crn = 10, .crm = 3, .opc1 = 0, .opc2 = 0,
55
v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx,
83
.access = PL1_RW, .accessfn = access_tvm_trvm,
56
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
84
+ .fgt = FGT_AMAIR_EL1,
57
if (return_to_secure &&
85
.type = ARM_CP_CONST, .resetvalue = 0 },
58
((excret & R_V7M_EXCRET_ES_MASK) == 0 ||
86
/* AMAIR1 is mapped to AMAIR_EL1[63:32] */
59
(excret & R_V7M_EXCRET_DCRS_MASK) == 0)) {
87
{ .name = "AMAIR1", .cp = 15, .crn = 10, .crm = 3, .opc1 = 0, .opc2 = 1,
60
- uint32_t expected_sig = 0xfefa125b;
88
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pauth_reginfo[] = {
61
uint32_t actual_sig;
89
{ .name = "APDAKEYLO_EL1", .state = ARM_CP_STATE_AA64,
62
90
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 0,
63
pop_ok = v7m_stack_read(cpu, &actual_sig, frameptr, mmu_idx);
91
.access = PL1_RW, .accessfn = access_pauth,
64
92
+ .fgt = FGT_APDAKEY,
65
- if (pop_ok && expected_sig != actual_sig) {
93
.fieldoffset = offsetof(CPUARMState, keys.apda.lo) },
66
+ if (pop_ok && v7m_integrity_sig(env, excret) != actual_sig) {
94
{ .name = "APDAKEYHI_EL1", .state = ARM_CP_STATE_AA64,
67
/* Take a SecureFault on the current stack */
95
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 1,
68
env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK;
96
.access = PL1_RW, .accessfn = access_pauth,
69
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
97
+ .fgt = FGT_APDAKEY,
98
.fieldoffset = offsetof(CPUARMState, keys.apda.hi) },
99
{ .name = "APDBKEYLO_EL1", .state = ARM_CP_STATE_AA64,
100
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 2,
101
.access = PL1_RW, .accessfn = access_pauth,
102
+ .fgt = FGT_APDBKEY,
103
.fieldoffset = offsetof(CPUARMState, keys.apdb.lo) },
104
{ .name = "APDBKEYHI_EL1", .state = ARM_CP_STATE_AA64,
105
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 2, .opc2 = 3,
106
.access = PL1_RW, .accessfn = access_pauth,
107
+ .fgt = FGT_APDBKEY,
108
.fieldoffset = offsetof(CPUARMState, keys.apdb.hi) },
109
{ .name = "APGAKEYLO_EL1", .state = ARM_CP_STATE_AA64,
110
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 3, .opc2 = 0,
111
.access = PL1_RW, .accessfn = access_pauth,
112
+ .fgt = FGT_APGAKEY,
113
.fieldoffset = offsetof(CPUARMState, keys.apga.lo) },
114
{ .name = "APGAKEYHI_EL1", .state = ARM_CP_STATE_AA64,
115
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 3, .opc2 = 1,
116
.access = PL1_RW, .accessfn = access_pauth,
117
+ .fgt = FGT_APGAKEY,
118
.fieldoffset = offsetof(CPUARMState, keys.apga.hi) },
119
{ .name = "APIAKEYLO_EL1", .state = ARM_CP_STATE_AA64,
120
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 0,
121
.access = PL1_RW, .accessfn = access_pauth,
122
+ .fgt = FGT_APIAKEY,
123
.fieldoffset = offsetof(CPUARMState, keys.apia.lo) },
124
{ .name = "APIAKEYHI_EL1", .state = ARM_CP_STATE_AA64,
125
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 1,
126
.access = PL1_RW, .accessfn = access_pauth,
127
+ .fgt = FGT_APIAKEY,
128
.fieldoffset = offsetof(CPUARMState, keys.apia.hi) },
129
{ .name = "APIBKEYLO_EL1", .state = ARM_CP_STATE_AA64,
130
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 2,
131
.access = PL1_RW, .accessfn = access_pauth,
132
+ .fgt = FGT_APIBKEY,
133
.fieldoffset = offsetof(CPUARMState, keys.apib.lo) },
134
{ .name = "APIBKEYHI_EL1", .state = ARM_CP_STATE_AA64,
135
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 1, .opc2 = 3,
136
.access = PL1_RW, .accessfn = access_pauth,
137
+ .fgt = FGT_APIBKEY,
138
.fieldoffset = offsetof(CPUARMState, keys.apib.hi) },
139
};
140
141
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
142
.opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 1,
143
.access = PL1_R, .type = ARM_CP_CONST,
144
.accessfn = access_tid4,
145
+ .fgt = FGT_CLIDR_EL1,
146
.resetvalue = cpu->clidr
147
};
148
define_one_arm_cp_reg(cpu, &clidr);
70
--
149
--
71
2.20.1
150
2.34.1
72
73
diff view generated by jsdifflib
1
Implement the VLSTM instruction for v7M for the FPU present case.
1
Mark up the sysreg definitions for the registers trapped
2
by HFGRTR/HFGWTR bits 12..23.
2
3
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190416125744.27770-25-peter.maydell@linaro.org
6
Tested-by: Fuad Tabba <tabba@google.com>
7
Message-id: 20230130182459.3309057-12-peter.maydell@linaro.org
8
Message-id: 20230127175507.2895013-12-peter.maydell@linaro.org
6
---
9
---
7
target/arm/cpu.h | 2 +
10
target/arm/cpregs.h | 12 ++++++++++++
8
target/arm/helper.h | 2 +
11
target/arm/helper.c | 12 ++++++++++++
9
target/arm/helper.c | 84 ++++++++++++++++++++++++++++++++++++++++++
12
2 files changed, 24 insertions(+)
10
target/arm/translate.c | 15 +++++++-
11
4 files changed, 102 insertions(+), 1 deletion(-)
12
13
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
16
--- a/target/arm/cpregs.h
16
+++ b/target/arm/cpu.h
17
+++ b/target/arm/cpregs.h
17
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ typedef enum FGTBit {
18
#define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */
19
DO_BIT(HFGRTR, CCSIDR_EL1),
19
#define EXCP_STKOF 19 /* v8M STKOF UsageFault */
20
DO_BIT(HFGRTR, CLIDR_EL1),
20
#define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */
21
DO_BIT(HFGRTR, CONTEXTIDR_EL1),
21
+#define EXCP_LSERR 21 /* v8M LSERR SecureFault */
22
+ DO_BIT(HFGRTR, CPACR_EL1),
22
+#define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */
23
+ DO_BIT(HFGRTR, CSSELR_EL1),
23
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
24
+ DO_BIT(HFGRTR, CTR_EL0),
24
25
+ DO_BIT(HFGRTR, DCZID_EL0),
25
#define ARMV7M_EXCP_RESET 1
26
+ DO_BIT(HFGRTR, ESR_EL1),
26
diff --git a/target/arm/helper.h b/target/arm/helper.h
27
+ DO_BIT(HFGRTR, FAR_EL1),
27
index XXXXXXX..XXXXXXX 100644
28
+ DO_BIT(HFGRTR, ISR_EL1),
28
--- a/target/arm/helper.h
29
+ DO_BIT(HFGRTR, LORC_EL1),
29
+++ b/target/arm/helper.h
30
+ DO_BIT(HFGRTR, LOREA_EL1),
30
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32)
31
+ DO_BIT(HFGRTR, LORID_EL1),
31
32
+ DO_BIT(HFGRTR, LORN_EL1),
32
DEF_HELPER_1(v7m_preserve_fp_state, void, env)
33
+ DO_BIT(HFGRTR, LORSA_EL1),
33
34
} FGTBit;
34
+DEF_HELPER_2(v7m_vlstm, void, env, i32)
35
35
+
36
#undef DO_BIT
36
DEF_HELPER_2(v8m_stackcheck, void, env, i32)
37
38
DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32)
39
diff --git a/target/arm/helper.c b/target/arm/helper.c
37
diff --git a/target/arm/helper.c b/target/arm/helper.c
40
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/helper.c
39
--- a/target/arm/helper.c
42
+++ b/target/arm/helper.c
40
+++ b/target/arm/helper.c
43
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
41
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = {
44
g_assert_not_reached();
42
.access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, },
45
}
43
{ .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3,
46
44
.crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access,
47
+void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
45
+ .fgt = FGT_CPACR_EL1,
48
+{
46
.access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.cpacr_el1),
49
+ /* translate.c should never generate calls here in user-only mode */
47
.resetfn = cpacr_reset, .writefn = cpacr_write, .readfn = cpacr_read },
50
+ g_assert_not_reached();
48
};
51
+}
49
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
52
+
50
.opc0 = 3, .crn = 0, .crm = 0, .opc1 = 2, .opc2 = 0,
53
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
51
.access = PL1_RW,
54
{
52
.accessfn = access_tid4,
55
/* The TT instructions can be used by unprivileged code, but in
53
+ .fgt = FGT_CSSELR_EL1,
56
@@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr,
54
.writefn = csselr_write, .resetvalue = 0,
57
}
55
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.csselr_s),
58
}
56
offsetof(CPUARMState, cp15.csselr_ns) } },
59
57
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
60
+void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
58
.resetfn = arm_cp_reset_ignore },
61
+{
59
{ .name = "ISR_EL1", .state = ARM_CP_STATE_BOTH,
62
+ /* fptr is the value of Rn, the frame pointer we store the FP regs to */
60
.opc0 = 3, .opc1 = 0, .crn = 12, .crm = 1, .opc2 = 0,
63
+ bool s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
61
+ .fgt = FGT_ISR_EL1,
64
+ bool lspact = env->v7m.fpccr[s] & R_V7M_FPCCR_LSPACT_MASK;
62
.type = ARM_CP_NO_RAW, .access = PL1_R, .readfn = isr_read },
65
+
63
/* 32 bit ITLB invalidates */
66
+ assert(env->v7m.secure);
64
{ .name = "ITLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 0,
67
+
65
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_pmsa_cp_reginfo[] = {
68
+ if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) {
66
{ .name = "FAR_EL1", .state = ARM_CP_STATE_AA64,
69
+ return;
67
.opc0 = 3, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 0,
70
+ }
68
.access = PL1_RW, .accessfn = access_tvm_trvm,
71
+
69
+ .fgt = FGT_FAR_EL1,
72
+ /* Check access to the coprocessor is permitted */
70
.fieldoffset = offsetof(CPUARMState, cp15.far_el[1]),
73
+ if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) {
71
.resetvalue = 0, },
74
+ raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC());
72
};
75
+ }
73
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = {
76
+
74
{ .name = "ESR_EL1", .state = ARM_CP_STATE_AA64,
77
+ if (lspact) {
75
.opc0 = 3, .crn = 5, .crm = 2, .opc1 = 0, .opc2 = 0,
78
+ /* LSPACT should not be active when there is active FP state */
76
.access = PL1_RW, .accessfn = access_tvm_trvm,
79
+ raise_exception_ra(env, EXCP_LSERR, 0, 1, GETPC());
77
+ .fgt = FGT_ESR_EL1,
80
+ }
78
.fieldoffset = offsetof(CPUARMState, cp15.esr_el[1]), .resetvalue = 0, },
81
+
79
{ .name = "TTBR0_EL1", .state = ARM_CP_STATE_BOTH,
82
+ if (fptr & 7) {
80
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 0,
83
+ raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC());
81
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
84
+ }
82
{ .name = "DCZID_EL0", .state = ARM_CP_STATE_AA64,
85
+
83
.opc0 = 3, .opc1 = 3, .opc2 = 7, .crn = 0, .crm = 0,
86
+ /*
84
.access = PL0_R, .type = ARM_CP_NO_RAW,
87
+ * Note that we do not use v7m_stack_write() here, because the
85
+ .fgt = FGT_DCZID_EL0,
88
+ * accesses should not set the FSR bits for stacking errors if they
86
.readfn = aa64_dczid_read },
89
+ * fail. (In pseudocode terms, they are AccType_NORMAL, not AccType_STACK
87
{ .name = "DC_ZVA", .state = ARM_CP_STATE_AA64,
90
+ * or AccType_LAZYFP). Faults in cpu_stl_data() will throw exceptions
88
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 4, .opc2 = 1,
91
+ * and longjmp out.
89
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo lor_reginfo[] = {
92
+ */
90
{ .name = "LORSA_EL1", .state = ARM_CP_STATE_AA64,
93
+ if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) {
91
.opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 0,
94
+ bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK;
92
.access = PL1_RW, .accessfn = access_lor_other,
95
+ int i;
93
+ .fgt = FGT_LORSA_EL1,
96
+
94
.type = ARM_CP_CONST, .resetvalue = 0 },
97
+ for (i = 0; i < (ts ? 32 : 16); i += 2) {
95
{ .name = "LOREA_EL1", .state = ARM_CP_STATE_AA64,
98
+ uint64_t dn = *aa32_vfp_dreg(env, i / 2);
96
.opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 1,
99
+ uint32_t faddr = fptr + 4 * i;
97
.access = PL1_RW, .accessfn = access_lor_other,
100
+ uint32_t slo = extract64(dn, 0, 32);
98
+ .fgt = FGT_LOREA_EL1,
101
+ uint32_t shi = extract64(dn, 32, 32);
99
.type = ARM_CP_CONST, .resetvalue = 0 },
102
+
100
{ .name = "LORN_EL1", .state = ARM_CP_STATE_AA64,
103
+ if (i >= 16) {
101
.opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 2,
104
+ faddr += 8; /* skip the slot for the FPSCR */
102
.access = PL1_RW, .accessfn = access_lor_other,
105
+ }
103
+ .fgt = FGT_LORN_EL1,
106
+ cpu_stl_data(env, faddr, slo);
104
.type = ARM_CP_CONST, .resetvalue = 0 },
107
+ cpu_stl_data(env, faddr + 4, shi);
105
{ .name = "LORC_EL1", .state = ARM_CP_STATE_AA64,
108
+ }
106
.opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 3,
109
+ cpu_stl_data(env, fptr + 0x40, vfp_get_fpscr(env));
107
.access = PL1_RW, .accessfn = access_lor_other,
110
+
108
+ .fgt = FGT_LORC_EL1,
111
+ /*
109
.type = ARM_CP_CONST, .resetvalue = 0 },
112
+ * If TS is 0 then s0 to s15 and FPSCR are UNKNOWN; we choose to
110
{ .name = "LORID_EL1", .state = ARM_CP_STATE_AA64,
113
+ * leave them unchanged, matching our choice in v7m_preserve_fp_state.
111
.opc0 = 3, .opc1 = 0, .crn = 10, .crm = 4, .opc2 = 7,
114
+ */
112
.access = PL1_R, .accessfn = access_lor_ns,
115
+ if (ts) {
113
+ .fgt = FGT_LORID_EL1,
116
+ for (i = 0; i < 32; i += 2) {
114
.type = ARM_CP_CONST, .resetvalue = 0 },
117
+ *aa32_vfp_dreg(env, i / 2) = 0;
115
};
118
+ }
116
119
+ vfp_set_fpscr(env, 0);
117
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
120
+ }
118
{ .name = "CTR_EL0", .state = ARM_CP_STATE_AA64,
121
+ } else {
119
.opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 0, .crm = 0,
122
+ v7m_update_fpccr(env, fptr, false);
120
.access = PL0_R, .accessfn = ctr_el0_access,
123
+ }
121
+ .fgt = FGT_CTR_EL0,
124
+
122
.type = ARM_CP_CONST, .resetvalue = cpu->ctr },
125
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
123
/* TCMTR and TLBTR exist in v8 but have no 64-bit versions */
126
+}
124
{ .name = "TCMTR",
127
+
128
static bool v7m_push_stack(ARMCPU *cpu)
129
{
130
/* Do the "set up stack frame" part of exception entry,
131
@@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx)
132
[EXCP_INVSTATE] = "v7M INVSTATE UsageFault",
133
[EXCP_STKOF] = "v8M STKOF UsageFault",
134
[EXCP_LAZYFP] = "v7M exception during lazy FP stacking",
135
+ [EXCP_LSERR] = "v8M LSERR UsageFault",
136
+ [EXCP_UNALIGNED] = "v7M UNALIGNED UsageFault",
137
};
138
139
if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
140
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
141
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
142
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_STKOF_MASK;
143
break;
144
+ case EXCP_LSERR:
145
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
146
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
147
+ break;
148
+ case EXCP_UNALIGNED:
149
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
150
+ env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK;
151
+ break;
152
case EXCP_SWI:
153
/* The PC already points to the next instruction. */
154
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure);
155
diff --git a/target/arm/translate.c b/target/arm/translate.c
156
index XXXXXXX..XXXXXXX 100644
157
--- a/target/arm/translate.c
158
+++ b/target/arm/translate.c
159
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
160
if (!s->v8m_secure || (insn & 0x0040f0ff)) {
161
goto illegal_op;
162
}
163
- /* Just NOP since FP support is not implemented */
164
+
165
+ if (arm_dc_feature(s, ARM_FEATURE_VFP)) {
166
+ TCGv_i32 fptr = load_reg(s, rn);
167
+
168
+ if (extract32(insn, 20, 1)) {
169
+ /* VLLDM */
170
+ } else {
171
+ gen_helper_v7m_vlstm(cpu_env, fptr);
172
+ }
173
+ tcg_temp_free_i32(fptr);
174
+
175
+ /* End the TB, because we have updated FP control bits */
176
+ s->base.is_jmp = DISAS_UPDATE;
177
+ }
178
break;
179
}
180
if (arm_dc_feature(s, ARM_FEATURE_VFP) &&
181
--
125
--
182
2.20.1
126
2.34.1
183
184
diff view generated by jsdifflib
1
For v8M floating point support, transitions from Secure
1
Mark up the sysreg definitions for the registers trapped
2
to Non-secure state via BLNS and BLXNS must clear the
2
by HFGRTR/HFGWTR bits 24..35.
3
CONTROL.SFPA bit. (This corresponds to the pseudocode
4
BranchToNS() function.)
5
3
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-13-peter.maydell@linaro.org
6
Tested-by: Fuad Tabba <tabba@google.com>
7
Message-id: 20230130182459.3309057-13-peter.maydell@linaro.org
8
Message-id: 20230127175507.2895013-13-peter.maydell@linaro.org
9
---
9
---
10
target/arm/helper.c | 4 ++++
10
target/arm/cpregs.h | 12 ++++++++++++
11
1 file changed, 4 insertions(+)
11
target/arm/helper.c | 14 ++++++++++++++
12
2 files changed, 26 insertions(+)
12
13
14
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpregs.h
17
+++ b/target/arm/cpregs.h
18
@@ -XXX,XX +XXX,XX @@ typedef enum FGTBit {
19
DO_BIT(HFGRTR, LORID_EL1),
20
DO_BIT(HFGRTR, LORN_EL1),
21
DO_BIT(HFGRTR, LORSA_EL1),
22
+ DO_BIT(HFGRTR, MAIR_EL1),
23
+ DO_BIT(HFGRTR, MIDR_EL1),
24
+ DO_BIT(HFGRTR, MPIDR_EL1),
25
+ DO_BIT(HFGRTR, PAR_EL1),
26
+ DO_BIT(HFGRTR, REVIDR_EL1),
27
+ DO_BIT(HFGRTR, SCTLR_EL1),
28
+ DO_BIT(HFGRTR, SCXTNUM_EL1),
29
+ DO_BIT(HFGRTR, SCXTNUM_EL0),
30
+ DO_BIT(HFGRTR, TCR_EL1),
31
+ DO_BIT(HFGRTR, TPIDR_EL1),
32
+ DO_BIT(HFGRTR, TPIDRRO_EL0),
33
+ DO_BIT(HFGRTR, TPIDR_EL0),
34
} FGTBit;
35
36
#undef DO_BIT
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
37
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
39
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
40
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest)
41
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
18
/* translate.c should have made BXNS UNDEF unless we're secure */
42
{ .name = "MAIR_EL1", .state = ARM_CP_STATE_AA64,
19
assert(env->v7m.secure);
43
.opc0 = 3, .opc1 = 0, .crn = 10, .crm = 2, .opc2 = 0,
20
44
.access = PL1_RW, .accessfn = access_tvm_trvm,
21
+ if (!(dest & 1)) {
45
+ .fgt = FGT_MAIR_EL1,
22
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
46
.fieldoffset = offsetof(CPUARMState, cp15.mair_el[1]),
23
+ }
47
.resetvalue = 0 },
24
switch_v7m_security_state(env, dest & 1);
48
{ .name = "MAIR_EL3", .state = ARM_CP_STATE_AA64,
25
env->thumb = 1;
49
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = {
26
env->regs[15] = dest & ~1;
50
{ .name = "TPIDR_EL0", .state = ARM_CP_STATE_AA64,
27
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
51
.opc0 = 3, .opc1 = 3, .opc2 = 2, .crn = 13, .crm = 0,
28
*/
52
.access = PL0_RW,
29
write_v7m_exception(env, 1);
53
+ .fgt = FGT_TPIDR_EL0,
30
}
54
.fieldoffset = offsetof(CPUARMState, cp15.tpidr_el[0]), .resetvalue = 0 },
31
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
55
{ .name = "TPIDRURW", .cp = 15, .crn = 13, .crm = 0, .opc1 = 0, .opc2 = 2,
32
switch_v7m_security_state(env, 0);
56
.access = PL0_RW,
33
env->thumb = 1;
57
+ .fgt = FGT_TPIDR_EL0,
34
env->regs[15] = dest;
58
.bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tpidrurw_s),
59
offsetoflow32(CPUARMState, cp15.tpidrurw_ns) },
60
.resetfn = arm_cp_reset_ignore },
61
{ .name = "TPIDRRO_EL0", .state = ARM_CP_STATE_AA64,
62
.opc0 = 3, .opc1 = 3, .opc2 = 3, .crn = 13, .crm = 0,
63
.access = PL0_R | PL1_W,
64
+ .fgt = FGT_TPIDRRO_EL0,
65
.fieldoffset = offsetof(CPUARMState, cp15.tpidrro_el[0]),
66
.resetvalue = 0},
67
{ .name = "TPIDRURO", .cp = 15, .crn = 13, .crm = 0, .opc1 = 0, .opc2 = 3,
68
.access = PL0_R | PL1_W,
69
+ .fgt = FGT_TPIDRRO_EL0,
70
.bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tpidruro_s),
71
offsetoflow32(CPUARMState, cp15.tpidruro_ns) },
72
.resetfn = arm_cp_reset_ignore },
73
{ .name = "TPIDR_EL1", .state = ARM_CP_STATE_AA64,
74
.opc0 = 3, .opc1 = 0, .opc2 = 4, .crn = 13, .crm = 0,
75
.access = PL1_RW,
76
+ .fgt = FGT_TPIDR_EL1,
77
.fieldoffset = offsetof(CPUARMState, cp15.tpidr_el[1]), .resetvalue = 0 },
78
{ .name = "TPIDRPRW", .opc1 = 0, .cp = 15, .crn = 13, .crm = 0, .opc2 = 4,
79
.access = PL1_RW,
80
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = {
81
{ .name = "TCR_EL1", .state = ARM_CP_STATE_AA64,
82
.opc0 = 3, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 2,
83
.access = PL1_RW, .accessfn = access_tvm_trvm,
84
+ .fgt = FGT_TCR_EL1,
85
.writefn = vmsa_tcr_el12_write,
86
.raw_writefn = raw_write,
87
.resetvalue = 0,
88
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
89
.type = ARM_CP_ALIAS,
90
.opc0 = 3, .opc1 = 0, .crn = 7, .crm = 4, .opc2 = 0,
91
.access = PL1_RW, .resetvalue = 0,
92
+ .fgt = FGT_PAR_EL1,
93
.fieldoffset = offsetof(CPUARMState, cp15.par_el[1]),
94
.writefn = par_write },
95
#endif
96
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo scxtnum_reginfo[] = {
97
{ .name = "SCXTNUM_EL0", .state = ARM_CP_STATE_AA64,
98
.opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 7,
99
.access = PL0_RW, .accessfn = access_scxtnum,
100
+ .fgt = FGT_SCXTNUM_EL0,
101
.fieldoffset = offsetof(CPUARMState, scxtnum_el[0]) },
102
{ .name = "SCXTNUM_EL1", .state = ARM_CP_STATE_AA64,
103
.opc0 = 3, .opc1 = 0, .crn = 13, .crm = 0, .opc2 = 7,
104
.access = PL1_RW, .accessfn = access_scxtnum,
105
+ .fgt = FGT_SCXTNUM_EL1,
106
.fieldoffset = offsetof(CPUARMState, scxtnum_el[1]) },
107
{ .name = "SCXTNUM_EL2", .state = ARM_CP_STATE_AA64,
108
.opc0 = 3, .opc1 = 4, .crn = 13, .crm = 0, .opc2 = 7,
109
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
110
{ .name = "MIDR_EL1", .state = ARM_CP_STATE_BOTH,
111
.opc0 = 3, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 0,
112
.access = PL1_R, .type = ARM_CP_NO_RAW, .resetvalue = cpu->midr,
113
+ .fgt = FGT_MIDR_EL1,
114
.fieldoffset = offsetof(CPUARMState, cp15.c0_cpuid),
115
.readfn = midr_read },
116
/* crn = 0 op1 = 0 crm = 0 op2 = 7 : AArch32 aliases of MIDR */
117
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
118
.opc0 = 3, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 6,
119
.access = PL1_R,
120
.accessfn = access_aa64_tid1,
121
+ .fgt = FGT_REVIDR_EL1,
122
.type = ARM_CP_CONST, .resetvalue = cpu->revidr },
123
};
124
ARMCPRegInfo id_v8_midr_alias_cp_reginfo = {
125
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
126
ARMCPRegInfo mpidr_cp_reginfo[] = {
127
{ .name = "MPIDR_EL1", .state = ARM_CP_STATE_BOTH,
128
.opc0 = 3, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 5,
129
+ .fgt = FGT_MPIDR_EL1,
130
.access = PL1_R, .readfn = mpidr_read, .type = ARM_CP_NO_RAW },
131
};
132
#ifdef CONFIG_USER_ONLY
133
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
134
.name = "SCTLR", .state = ARM_CP_STATE_BOTH,
135
.opc0 = 3, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 0,
136
.access = PL1_RW, .accessfn = access_tvm_trvm,
137
+ .fgt = FGT_SCTLR_EL1,
138
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.sctlr_s),
139
offsetof(CPUARMState, cp15.sctlr_ns) },
140
.writefn = sctlr_write, .resetvalue = cpu->reset_sctlr,
35
--
141
--
36
2.20.1
142
2.34.1
37
38
diff view generated by jsdifflib
1
We are close to running out of TB flags for AArch32; we could
1
Mark up the sysreg definitions for the registers trapped
2
start using the cs_base word, but before we do that we can
2
by HFGRTR/HFGWTR bits 36..63.
3
economise on our usage by sharing the same bits for the VFP
3
4
VECSTRIDE field and the XScale XSCALE_CPAR field. This
4
Of these, some correspond to RAS registers which we implement as
5
works because no XScale CPU ever had VFP.
5
always-UNDEF: these don't need any extra handling for FGT because the
6
UNDEF-to-EL1 always takes priority over any theoretical
7
FGT-trap-to-EL2.
8
9
Bit 50 (NACCDATA_EL1) is for the ACCDATA_EL1 register which is part
10
of the FEAT_LS64_ACCDATA feature which we don't yet implement.
6
11
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-18-peter.maydell@linaro.org
14
Tested-by: Fuad Tabba <tabba@google.com>
15
Message-id: 20230130182459.3309057-14-peter.maydell@linaro.org
16
Message-id: 20230127175507.2895013-14-peter.maydell@linaro.org
10
---
17
---
11
target/arm/cpu.h | 10 ++++++----
18
target/arm/cpregs.h | 7 +++++++
12
target/arm/cpu.c | 7 +++++++
19
hw/intc/arm_gicv3_cpuif.c | 2 ++
13
target/arm/helper.c | 6 +++++-
20
target/arm/helper.c | 10 ++++++++++
14
target/arm/translate.c | 9 +++++++--
21
3 files changed, 19 insertions(+)
15
4 files changed, 25 insertions(+), 7 deletions(-)
16
22
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
23
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
18
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
25
--- a/target/arm/cpregs.h
20
+++ b/target/arm/cpu.h
26
+++ b/target/arm/cpregs.h
21
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1)
27
@@ -XXX,XX +XXX,XX @@ typedef enum FGTBit {
22
FIELD(TBFLAG_A32, THUMB, 0, 1)
28
DO_BIT(HFGRTR, TPIDR_EL1),
23
FIELD(TBFLAG_A32, VECLEN, 1, 3)
29
DO_BIT(HFGRTR, TPIDRRO_EL0),
24
FIELD(TBFLAG_A32, VECSTRIDE, 4, 2)
30
DO_BIT(HFGRTR, TPIDR_EL0),
25
+/*
31
+ DO_BIT(HFGRTR, TTBR0_EL1),
26
+ * We store the bottom two bits of the CPAR as TB flags and handle
32
+ DO_BIT(HFGRTR, TTBR1_EL1),
27
+ * checks on the other bits at runtime. This shares the same bits as
33
+ DO_BIT(HFGRTR, VBAR_EL1),
28
+ * VECSTRIDE, which is OK as no XScale CPU has VFP.
34
+ DO_BIT(HFGRTR, ICC_IGRPENN_EL1),
29
+ */
35
+ DO_BIT(HFGRTR, ERRIDR_EL1),
30
+FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2)
36
+ DO_REV_BIT(HFGRTR, NSMPRI_EL1),
31
/*
37
+ DO_REV_BIT(HFGRTR, NTPIDR2_EL0),
32
* Indicates whether cp register reads and writes by guest code should access
38
} FGTBit;
33
* the secure or nonsecure bank of banked registers; note that this is not
39
34
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
40
#undef DO_BIT
35
FIELD(TBFLAG_A32, VFPEN, 7, 1)
41
diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c
36
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
37
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
38
-/* We store the bottom two bits of the CPAR as TB flags and handle
39
- * checks on the other bits at runtime
40
- */
41
-FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2)
42
/* For M profile only, Handler (ie not Thread) mode */
43
FIELD(TBFLAG_A32, HANDLER, 21, 1)
44
/* For M profile only, whether we should generate stack-limit checks */
45
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
46
index XXXXXXX..XXXXXXX 100644
42
index XXXXXXX..XXXXXXX 100644
47
--- a/target/arm/cpu.c
43
--- a/hw/intc/arm_gicv3_cpuif.c
48
+++ b/target/arm/cpu.c
44
+++ b/hw/intc/arm_gicv3_cpuif.c
49
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
45
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = {
50
set_feature(env, ARM_FEATURE_THUMB_DSP);
46
.opc0 = 3, .opc1 = 0, .crn = 12, .crm = 12, .opc2 = 6,
51
}
47
.type = ARM_CP_IO | ARM_CP_NO_RAW,
52
48
.access = PL1_RW, .accessfn = gicv3_fiq_access,
53
+ /*
49
+ .fgt = FGT_ICC_IGRPENN_EL1,
54
+ * We rely on no XScale CPU having VFP so we can use the same bits in the
50
.readfn = icc_igrpen_read,
55
+ * TB flags field for VECSTRIDE and XSCALE_CPAR.
51
.writefn = icc_igrpen_write,
56
+ */
52
},
57
+ assert(!(arm_feature(env, ARM_FEATURE_VFP) &&
53
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gicv3_cpuif_reginfo[] = {
58
+ arm_feature(env, ARM_FEATURE_XSCALE)));
54
.opc0 = 3, .opc1 = 0, .crn = 12, .crm = 12, .opc2 = 7,
59
+
55
.type = ARM_CP_IO | ARM_CP_NO_RAW,
60
if (arm_feature(env, ARM_FEATURE_V7) &&
56
.access = PL1_RW, .accessfn = gicv3_irq_access,
61
!arm_feature(env, ARM_FEATURE_M) &&
57
+ .fgt = FGT_ICC_IGRPENN_EL1,
62
!arm_feature(env, ARM_FEATURE_PMSA)) {
58
.readfn = icc_igrpen_read,
59
.writefn = icc_igrpen_write,
60
},
63
diff --git a/target/arm/helper.c b/target/arm/helper.c
61
diff --git a/target/arm/helper.c b/target/arm/helper.c
64
index XXXXXXX..XXXXXXX 100644
62
index XXXXXXX..XXXXXXX 100644
65
--- a/target/arm/helper.c
63
--- a/target/arm/helper.c
66
+++ b/target/arm/helper.c
64
+++ b/target/arm/helper.c
67
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
65
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = {
68
|| arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) {
66
{ .name = "TTBR0_EL1", .state = ARM_CP_STATE_BOTH,
69
flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1);
67
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 0,
70
}
68
.access = PL1_RW, .accessfn = access_tvm_trvm,
71
- flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar);
69
+ .fgt = FGT_TTBR0_EL1,
72
+ /* Note that XSCALE_CPAR shares bits with VECSTRIDE */
70
.writefn = vmsa_ttbr_write, .resetvalue = 0,
73
+ if (arm_feature(env, ARM_FEATURE_XSCALE)) {
71
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr0_s),
74
+ flags = FIELD_DP32(flags, TBFLAG_A32,
72
offsetof(CPUARMState, cp15.ttbr0_ns) } },
75
+ XSCALE_CPAR, env->cp15.c15_cpar);
73
{ .name = "TTBR1_EL1", .state = ARM_CP_STATE_BOTH,
76
+ }
74
.opc0 = 3, .opc1 = 0, .crn = 2, .crm = 0, .opc2 = 1,
77
}
75
.access = PL1_RW, .accessfn = access_tvm_trvm,
78
76
+ .fgt = FGT_TTBR1_EL1,
79
flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx));
77
.writefn = vmsa_ttbr_write, .resetvalue = 0,
80
diff --git a/target/arm/translate.c b/target/arm/translate.c
78
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.ttbr1_s),
81
index XXXXXXX..XXXXXXX 100644
79
offsetof(CPUARMState, cp15.ttbr1_ns) } },
82
--- a/target/arm/translate.c
80
@@ -XXX,XX +XXX,XX @@ static void disr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t val)
83
+++ b/target/arm/translate.c
81
* ERRSELR_EL1
84
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
82
* may generate UNDEFINED, which is the effect we get by not
85
dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL);
83
* listing them at all.
86
dc->vfp_enabled = FIELD_EX32(tb_flags, TBFLAG_A32, VFPEN);
84
+ *
87
dc->vec_len = FIELD_EX32(tb_flags, TBFLAG_A32, VECLEN);
85
+ * These registers have fine-grained trap bits, but UNDEF-to-EL1
88
- dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE);
86
+ * is higher priority than FGT-to-EL2 so we do not need to list them
89
- dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR);
87
+ * in order to check for an FGT.
90
+ if (arm_feature(env, ARM_FEATURE_XSCALE)) {
88
*/
91
+ dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR);
89
static const ARMCPRegInfo minimal_ras_reginfo[] = {
92
+ dc->vec_stride = 0;
90
{ .name = "DISR_EL1", .state = ARM_CP_STATE_BOTH,
93
+ } else {
91
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo minimal_ras_reginfo[] = {
94
+ dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE);
92
{ .name = "ERRIDR_EL1", .state = ARM_CP_STATE_BOTH,
95
+ dc->c15_cpar = 0;
93
.opc0 = 3, .opc1 = 0, .crn = 5, .crm = 3, .opc2 = 0,
96
+ }
94
.access = PL1_R, .accessfn = access_terr,
97
dc->v7m_handler_mode = FIELD_EX32(tb_flags, TBFLAG_A32, HANDLER);
95
+ .fgt = FGT_ERRIDR_EL1,
98
dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) &&
96
.type = ARM_CP_CONST, .resetvalue = 0 },
99
regime_is_secure(env, dc->mmu_idx);
97
{ .name = "VDISR_EL2", .state = ARM_CP_STATE_BOTH,
98
.opc0 = 3, .opc1 = 4, .crn = 12, .crm = 1, .opc2 = 1,
99
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo sme_reginfo[] = {
100
{ .name = "TPIDR2_EL0", .state = ARM_CP_STATE_AA64,
101
.opc0 = 3, .opc1 = 3, .crn = 13, .crm = 0, .opc2 = 5,
102
.access = PL0_RW, .accessfn = access_tpidr2,
103
+ .fgt = FGT_NTPIDR2_EL0,
104
.fieldoffset = offsetof(CPUARMState, cp15.tpidr2_el0) },
105
{ .name = "SVCR", .state = ARM_CP_STATE_AA64,
106
.opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 2,
107
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo sme_reginfo[] = {
108
{ .name = "SMPRI_EL1", .state = ARM_CP_STATE_AA64,
109
.opc0 = 3, .opc1 = 0, .crn = 1, .crm = 2, .opc2 = 4,
110
.access = PL1_RW, .accessfn = access_esm,
111
+ .fgt = FGT_NSMPRI_EL1,
112
.type = ARM_CP_CONST, .resetvalue = 0 },
113
{ .name = "SMPRIMAP_EL2", .state = ARM_CP_STATE_AA64,
114
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 2, .opc2 = 5,
115
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
116
{ .name = "VBAR", .state = ARM_CP_STATE_BOTH,
117
.opc0 = 3, .crn = 12, .crm = 0, .opc1 = 0, .opc2 = 0,
118
.access = PL1_RW, .writefn = vbar_write,
119
+ .fgt = FGT_VBAR_EL1,
120
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.vbar_s),
121
offsetof(CPUARMState, cp15.vbar_ns) },
122
.resetvalue = 0 },
100
--
123
--
101
2.20.1
124
2.34.1
102
103
diff view generated by jsdifflib
1
The M-profile floating point support has three associated config
1
Mark up the sysreg definitons for the registers trapped
2
registers: FPCAR, FPCCR and FPDSCR. It also makes the registers
2
by HDFGRTR/HDFGWTR bits 0..11. These cover various debug
3
CPACR and NSACR have behaviour other than reads-as-zero.
3
related registers.
4
Add support for all of these as simple reads-as-written registers.
5
We will hook up actual functionality later.
6
7
The main complexity here is handling the FPCCR register, which
8
has a mix of banked and unbanked bits.
9
10
Note that we don't share storage with the A-profile
11
cpu->cp15.nsacr and cpu->cp15.cpacr_el1, though the behaviour
12
is quite similar, for two reasons:
13
* the M profile CPACR is banked between security states
14
* it preserves the invariant that M profile uses no state
15
inside the cp15 substruct
16
4
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Message-id: 20190416125744.27770-4-peter.maydell@linaro.org
7
Tested-by: Fuad Tabba <tabba@google.com>
8
Message-id: 20230130182459.3309057-15-peter.maydell@linaro.org
9
Message-id: 20230127175507.2895013-15-peter.maydell@linaro.org
20
---
10
---
21
target/arm/cpu.h | 34 ++++++++++++
11
target/arm/cpregs.h | 12 ++++++++++++
22
hw/intc/armv7m_nvic.c | 125 ++++++++++++++++++++++++++++++++++++++++++
12
target/arm/debug_helper.c | 11 +++++++++++
23
target/arm/cpu.c | 5 ++
13
2 files changed, 23 insertions(+)
24
target/arm/machine.c | 16 ++++++
25
4 files changed, 180 insertions(+)
26
14
27
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
15
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
28
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/cpu.h
17
--- a/target/arm/cpregs.h
30
+++ b/target/arm/cpu.h
18
+++ b/target/arm/cpregs.h
31
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
19
@@ -XXX,XX +XXX,XX @@ typedef enum FGTBit {
32
uint32_t scr[M_REG_NUM_BANKS];
20
DO_BIT(HFGRTR, ERRIDR_EL1),
33
uint32_t msplim[M_REG_NUM_BANKS];
21
DO_REV_BIT(HFGRTR, NSMPRI_EL1),
34
uint32_t psplim[M_REG_NUM_BANKS];
22
DO_REV_BIT(HFGRTR, NTPIDR2_EL0),
35
+ uint32_t fpcar[M_REG_NUM_BANKS];
36
+ uint32_t fpccr[M_REG_NUM_BANKS];
37
+ uint32_t fpdscr[M_REG_NUM_BANKS];
38
+ uint32_t cpacr[M_REG_NUM_BANKS];
39
+ uint32_t nsacr;
40
} v7m;
41
42
/* Information associated with an exception about to be taken:
43
@@ -XXX,XX +XXX,XX @@ FIELD(V7M_CSSELR, LEVEL, 1, 3)
44
*/
45
FIELD(V7M_CSSELR, INDEX, 0, 4)
46
47
+/* v7M FPCCR bits */
48
+FIELD(V7M_FPCCR, LSPACT, 0, 1)
49
+FIELD(V7M_FPCCR, USER, 1, 1)
50
+FIELD(V7M_FPCCR, S, 2, 1)
51
+FIELD(V7M_FPCCR, THREAD, 3, 1)
52
+FIELD(V7M_FPCCR, HFRDY, 4, 1)
53
+FIELD(V7M_FPCCR, MMRDY, 5, 1)
54
+FIELD(V7M_FPCCR, BFRDY, 6, 1)
55
+FIELD(V7M_FPCCR, SFRDY, 7, 1)
56
+FIELD(V7M_FPCCR, MONRDY, 8, 1)
57
+FIELD(V7M_FPCCR, SPLIMVIOL, 9, 1)
58
+FIELD(V7M_FPCCR, UFRDY, 10, 1)
59
+FIELD(V7M_FPCCR, RES0, 11, 15)
60
+FIELD(V7M_FPCCR, TS, 26, 1)
61
+FIELD(V7M_FPCCR, CLRONRETS, 27, 1)
62
+FIELD(V7M_FPCCR, CLRONRET, 28, 1)
63
+FIELD(V7M_FPCCR, LSPENS, 29, 1)
64
+FIELD(V7M_FPCCR, LSPEN, 30, 1)
65
+FIELD(V7M_FPCCR, ASPEN, 31, 1)
66
+/* These bits are banked. Others are non-banked and live in the M_REG_S bank */
67
+#define R_V7M_FPCCR_BANKED_MASK \
68
+ (R_V7M_FPCCR_LSPACT_MASK | \
69
+ R_V7M_FPCCR_USER_MASK | \
70
+ R_V7M_FPCCR_THREAD_MASK | \
71
+ R_V7M_FPCCR_MMRDY_MASK | \
72
+ R_V7M_FPCCR_SPLIMVIOL_MASK | \
73
+ R_V7M_FPCCR_UFRDY_MASK | \
74
+ R_V7M_FPCCR_ASPEN_MASK)
75
+
23
+
76
/*
24
+ /* Trap bits in HDFGRTR_EL2 / HDFGWTR_EL2, starting from bit 0. */
77
* System register ID fields.
25
+ DO_BIT(HDFGRTR, DBGBCRN_EL1),
78
*/
26
+ DO_BIT(HDFGRTR, DBGBVRN_EL1),
79
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
27
+ DO_BIT(HDFGRTR, DBGWCRN_EL1),
28
+ DO_BIT(HDFGRTR, DBGWVRN_EL1),
29
+ DO_BIT(HDFGRTR, MDSCR_EL1),
30
+ DO_BIT(HDFGRTR, DBGCLAIM),
31
+ DO_BIT(HDFGWTR, OSLAR_EL1),
32
+ DO_BIT(HDFGRTR, OSLSR_EL1),
33
+ DO_BIT(HDFGRTR, OSECCR_EL1),
34
+ DO_BIT(HDFGRTR, OSDLR_EL1),
35
} FGTBit;
36
37
#undef DO_BIT
38
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
80
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
81
--- a/hw/intc/armv7m_nvic.c
40
--- a/target/arm/debug_helper.c
82
+++ b/hw/intc/armv7m_nvic.c
41
+++ b/target/arm/debug_helper.c
83
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
42
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
84
}
43
{ .name = "MDSCR_EL1", .state = ARM_CP_STATE_BOTH,
85
case 0xd84: /* CSSELR */
44
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 2,
86
return cpu->env.v7m.csselr[attrs.secure];
45
.access = PL1_RW, .accessfn = access_tda,
87
+ case 0xd88: /* CPACR */
46
+ .fgt = FGT_MDSCR_EL1,
88
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
47
.fieldoffset = offsetof(CPUARMState, cp15.mdscr_el1),
89
+ return 0;
48
.resetvalue = 0 },
90
+ }
49
/*
91
+ return cpu->env.v7m.cpacr[attrs.secure];
50
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
92
+ case 0xd8c: /* NSACR */
51
{ .name = "OSECCR_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14,
93
+ if (!attrs.secure || !arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
52
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 2,
94
+ return 0;
53
.access = PL1_RW, .accessfn = access_tda,
95
+ }
54
+ .fgt = FGT_OSECCR_EL1,
96
+ return cpu->env.v7m.nsacr;
55
.type = ARM_CP_CONST, .resetvalue = 0 },
97
/* TODO: Implement debug registers. */
56
/*
98
case 0xd90: /* MPU_TYPE */
57
* DBGDSCRint[15,12,5:2] map to MDSCR_EL1[15,12,5:2]. Map all bits as
99
/* Unified MPU; if the MPU is not present this value is zero */
58
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
100
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
59
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 4,
101
return 0;
60
.access = PL1_W, .type = ARM_CP_NO_RAW,
102
}
61
.accessfn = access_tdosa,
103
return cpu->env.v7m.sfar;
62
+ .fgt = FGT_OSLAR_EL1,
104
+ case 0xf34: /* FPCCR */
63
.writefn = oslar_write },
105
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
64
{ .name = "OSLSR_EL1", .state = ARM_CP_STATE_BOTH,
106
+ return 0;
65
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 1, .opc2 = 4,
107
+ }
66
.access = PL1_R, .resetvalue = 10,
108
+ if (attrs.secure) {
67
.accessfn = access_tdosa,
109
+ return cpu->env.v7m.fpccr[M_REG_S];
68
+ .fgt = FGT_OSLSR_EL1,
110
+ } else {
69
.fieldoffset = offsetof(CPUARMState, cp15.oslsr_el1) },
111
+ /*
70
/* Dummy OSDLR_EL1: 32-bit Linux will read this */
112
+ * NS can read LSPEN, CLRONRET and MONRDY. It can read
71
{ .name = "OSDLR_EL1", .state = ARM_CP_STATE_BOTH,
113
+ * BFRDY and HFRDY if AIRCR.BFHFNMINS != 0;
72
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 3, .opc2 = 4,
114
+ * other non-banked bits RAZ.
73
.access = PL1_RW, .accessfn = access_tdosa,
115
+ * TODO: MONRDY should RAZ/WI if DEMCR.SDME is set.
74
+ .fgt = FGT_OSDLR_EL1,
116
+ */
75
.writefn = osdlr_write,
117
+ uint32_t value = cpu->env.v7m.fpccr[M_REG_S];
76
.fieldoffset = offsetof(CPUARMState, cp15.osdlr_el1) },
118
+ uint32_t mask = R_V7M_FPCCR_LSPEN_MASK |
77
/*
119
+ R_V7M_FPCCR_CLRONRET_MASK |
78
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
120
+ R_V7M_FPCCR_MONRDY_MASK;
79
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 6,
121
+
80
.type = ARM_CP_ALIAS,
122
+ if (s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
81
.access = PL1_RW, .accessfn = access_tda,
123
+ mask |= R_V7M_FPCCR_BFRDY_MASK | R_V7M_FPCCR_HFRDY_MASK;
82
+ .fgt = FGT_DBGCLAIM,
124
+ }
83
.writefn = dbgclaimset_write, .readfn = dbgclaimset_read },
125
+
84
{ .name = "DBGCLAIMCLR_EL1", .state = ARM_CP_STATE_BOTH,
126
+ value &= mask;
85
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 6,
127
+
86
.access = PL1_RW, .accessfn = access_tda,
128
+ value |= cpu->env.v7m.fpccr[M_REG_NS];
87
+ .fgt = FGT_DBGCLAIM,
129
+ return value;
88
.writefn = dbgclaimclr_write, .raw_writefn = raw_write,
130
+ }
89
.fieldoffset = offsetof(CPUARMState, cp15.dbgclaim) },
131
+ case 0xf38: /* FPCAR */
132
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
133
+ return 0;
134
+ }
135
+ return cpu->env.v7m.fpcar[attrs.secure];
136
+ case 0xf3c: /* FPDSCR */
137
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
138
+ return 0;
139
+ }
140
+ return cpu->env.v7m.fpdscr[attrs.secure];
141
case 0xf40: /* MVFR0 */
142
return cpu->isar.mvfr0;
143
case 0xf44: /* MVFR1 */
144
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
145
cpu->env.v7m.csselr[attrs.secure] = value & R_V7M_CSSELR_INDEX_MASK;
146
}
147
break;
148
+ case 0xd88: /* CPACR */
149
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
150
+ /* We implement only the Floating Point extension's CP10/CP11 */
151
+ cpu->env.v7m.cpacr[attrs.secure] = value & (0xf << 20);
152
+ }
153
+ break;
154
+ case 0xd8c: /* NSACR */
155
+ if (attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
156
+ /* We implement only the Floating Point extension's CP10/CP11 */
157
+ cpu->env.v7m.nsacr = value & (3 << 10);
158
+ }
159
+ break;
160
case 0xd90: /* MPU_TYPE */
161
return; /* RO */
162
case 0xd94: /* MPU_CTRL */
163
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
164
}
165
break;
166
}
167
+ case 0xf34: /* FPCCR */
168
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
169
+ /* Not all bits here are banked. */
170
+ uint32_t fpccr_s;
171
+
172
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
173
+ /* Don't allow setting of bits not present in v7M */
174
+ value &= (R_V7M_FPCCR_LSPACT_MASK |
175
+ R_V7M_FPCCR_USER_MASK |
176
+ R_V7M_FPCCR_THREAD_MASK |
177
+ R_V7M_FPCCR_HFRDY_MASK |
178
+ R_V7M_FPCCR_MMRDY_MASK |
179
+ R_V7M_FPCCR_BFRDY_MASK |
180
+ R_V7M_FPCCR_MONRDY_MASK |
181
+ R_V7M_FPCCR_LSPEN_MASK |
182
+ R_V7M_FPCCR_ASPEN_MASK);
183
+ }
184
+ value &= ~R_V7M_FPCCR_RES0_MASK;
185
+
186
+ if (!attrs.secure) {
187
+ /* Some non-banked bits are configurably writable by NS */
188
+ fpccr_s = cpu->env.v7m.fpccr[M_REG_S];
189
+ if (!(fpccr_s & R_V7M_FPCCR_LSPENS_MASK)) {
190
+ uint32_t lspen = FIELD_EX32(value, V7M_FPCCR, LSPEN);
191
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, LSPEN, lspen);
192
+ }
193
+ if (!(fpccr_s & R_V7M_FPCCR_CLRONRETS_MASK)) {
194
+ uint32_t cor = FIELD_EX32(value, V7M_FPCCR, CLRONRET);
195
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, CLRONRET, cor);
196
+ }
197
+ if ((s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
198
+ uint32_t hfrdy = FIELD_EX32(value, V7M_FPCCR, HFRDY);
199
+ uint32_t bfrdy = FIELD_EX32(value, V7M_FPCCR, BFRDY);
200
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, HFRDY, hfrdy);
201
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, BFRDY, bfrdy);
202
+ }
203
+ /* TODO MONRDY should RAZ/WI if DEMCR.SDME is set */
204
+ {
205
+ uint32_t monrdy = FIELD_EX32(value, V7M_FPCCR, MONRDY);
206
+ fpccr_s = FIELD_DP32(fpccr_s, V7M_FPCCR, MONRDY, monrdy);
207
+ }
208
+
209
+ /*
210
+ * All other non-banked bits are RAZ/WI from NS; write
211
+ * just the banked bits to fpccr[M_REG_NS].
212
+ */
213
+ value &= R_V7M_FPCCR_BANKED_MASK;
214
+ cpu->env.v7m.fpccr[M_REG_NS] = value;
215
+ } else {
216
+ fpccr_s = value;
217
+ }
218
+ cpu->env.v7m.fpccr[M_REG_S] = fpccr_s;
219
+ }
220
+ break;
221
+ case 0xf38: /* FPCAR */
222
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
223
+ value &= ~7;
224
+ cpu->env.v7m.fpcar[attrs.secure] = value;
225
+ }
226
+ break;
227
+ case 0xf3c: /* FPDSCR */
228
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
229
+ value &= 0x07c00000;
230
+ cpu->env.v7m.fpdscr[attrs.secure] = value;
231
+ }
232
+ break;
233
case 0xf50: /* ICIALLU */
234
case 0xf58: /* ICIMVAU */
235
case 0xf5c: /* DCIMVAC */
236
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
237
index XXXXXXX..XXXXXXX 100644
238
--- a/target/arm/cpu.c
239
+++ b/target/arm/cpu.c
240
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s)
241
env->v7m.ccr[M_REG_S] |= R_V7M_CCR_UNALIGN_TRP_MASK;
242
}
243
244
+ if (arm_feature(env, ARM_FEATURE_VFP)) {
245
+ env->v7m.fpccr[M_REG_NS] = R_V7M_FPCCR_ASPEN_MASK;
246
+ env->v7m.fpccr[M_REG_S] = R_V7M_FPCCR_ASPEN_MASK |
247
+ R_V7M_FPCCR_LSPEN_MASK | R_V7M_FPCCR_S_MASK;
248
+ }
249
/* Unlike A/R profile, M profile defines the reset LR value */
250
env->regs[14] = 0xffffffff;
251
252
diff --git a/target/arm/machine.c b/target/arm/machine.c
253
index XXXXXXX..XXXXXXX 100644
254
--- a/target/arm/machine.c
255
+++ b/target/arm/machine.c
256
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m_v8m = {
257
}
258
};
90
};
259
91
@@ -XXX,XX +XXX,XX @@ void define_debug_regs(ARMCPU *cpu)
260
+static const VMStateDescription vmstate_m_fp = {
92
{ .name = dbgbvr_el1_name, .state = ARM_CP_STATE_BOTH,
261
+ .name = "cpu/m/fp",
93
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 4,
262
+ .version_id = 1,
94
.access = PL1_RW, .accessfn = access_tda,
263
+ .minimum_version_id = 1,
95
+ .fgt = FGT_DBGBVRN_EL1,
264
+ .needed = vfp_needed,
96
.fieldoffset = offsetof(CPUARMState, cp15.dbgbvr[i]),
265
+ .fields = (VMStateField[]) {
97
.writefn = dbgbvr_write, .raw_writefn = raw_write
266
+ VMSTATE_UINT32_ARRAY(env.v7m.fpcar, ARMCPU, M_REG_NUM_BANKS),
98
},
267
+ VMSTATE_UINT32_ARRAY(env.v7m.fpccr, ARMCPU, M_REG_NUM_BANKS),
99
{ .name = dbgbcr_el1_name, .state = ARM_CP_STATE_BOTH,
268
+ VMSTATE_UINT32_ARRAY(env.v7m.fpdscr, ARMCPU, M_REG_NUM_BANKS),
100
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 5,
269
+ VMSTATE_UINT32_ARRAY(env.v7m.cpacr, ARMCPU, M_REG_NUM_BANKS),
101
.access = PL1_RW, .accessfn = access_tda,
270
+ VMSTATE_UINT32(env.v7m.nsacr, ARMCPU),
102
+ .fgt = FGT_DBGBCRN_EL1,
271
+ VMSTATE_END_OF_LIST()
103
.fieldoffset = offsetof(CPUARMState, cp15.dbgbcr[i]),
272
+ }
104
.writefn = dbgbcr_write, .raw_writefn = raw_write
273
+};
105
},
274
+
106
@@ -XXX,XX +XXX,XX @@ void define_debug_regs(ARMCPU *cpu)
275
static const VMStateDescription vmstate_m = {
107
{ .name = dbgwvr_el1_name, .state = ARM_CP_STATE_BOTH,
276
.name = "cpu/m",
108
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 6,
277
.version_id = 4,
109
.access = PL1_RW, .accessfn = access_tda,
278
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = {
110
+ .fgt = FGT_DBGWVRN_EL1,
279
&vmstate_m_scr,
111
.fieldoffset = offsetof(CPUARMState, cp15.dbgwvr[i]),
280
&vmstate_m_other_sp,
112
.writefn = dbgwvr_write, .raw_writefn = raw_write
281
&vmstate_m_v8m,
113
},
282
+ &vmstate_m_fp,
114
{ .name = dbgwcr_el1_name, .state = ARM_CP_STATE_BOTH,
283
NULL
115
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = i, .opc2 = 7,
284
}
116
.access = PL1_RW, .accessfn = access_tda,
285
};
117
+ .fgt = FGT_DBGWCRN_EL1,
118
.fieldoffset = offsetof(CPUARMState, cp15.dbgwcr[i]),
119
.writefn = dbgwcr_write, .raw_writefn = raw_write
120
},
286
--
121
--
287
2.20.1
122
2.34.1
288
289
diff view generated by jsdifflib
1
If the floating point extension is present, then the SG instruction
1
Mark up the sysreg definitions for the registers trapped
2
must clear the CONTROL_S.SFPA bit. Implement this.
2
by HDFGRTR/HDFGWTR bits 12..x.
3
3
4
(On a no-FPU system the bit will always be zero, so we don't need
4
Bits 12..22 and bit 58 are for PMU registers.
5
to make the clearing of the bit conditional on ARM_FEATURE_VFP.)
5
6
The remaining bits in HDFGRTR/HDFGWTR are for traps on
7
registers that are part of features we don't implement:
8
9
Bits 23..32 and 63 : FEAT_SPE
10
Bits 33..48 : FEAT_ETE
11
Bits 50..56 : FEAT_TRBE
12
Bits 59..61 : FEAT_BRBE
13
Bit 62 : FEAT_SPEv1p2.
6
14
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-8-peter.maydell@linaro.org
17
Tested-by: Fuad Tabba <tabba@google.com>
18
Message-id: 20230130182459.3309057-16-peter.maydell@linaro.org
19
Message-id: 20230127175507.2895013-16-peter.maydell@linaro.org
10
---
20
---
11
target/arm/helper.c | 1 +
21
target/arm/cpregs.h | 12 ++++++++++++
12
1 file changed, 1 insertion(+)
22
target/arm/helper.c | 37 +++++++++++++++++++++++++++++++++++++
13
23
2 files changed, 49 insertions(+)
24
25
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
26
index XXXXXXX..XXXXXXX 100644
27
--- a/target/arm/cpregs.h
28
+++ b/target/arm/cpregs.h
29
@@ -XXX,XX +XXX,XX @@ typedef enum FGTBit {
30
DO_BIT(HDFGRTR, OSLSR_EL1),
31
DO_BIT(HDFGRTR, OSECCR_EL1),
32
DO_BIT(HDFGRTR, OSDLR_EL1),
33
+ DO_BIT(HDFGRTR, PMEVCNTRN_EL0),
34
+ DO_BIT(HDFGRTR, PMEVTYPERN_EL0),
35
+ DO_BIT(HDFGRTR, PMCCFILTR_EL0),
36
+ DO_BIT(HDFGRTR, PMCCNTR_EL0),
37
+ DO_BIT(HDFGRTR, PMCNTEN),
38
+ DO_BIT(HDFGRTR, PMINTEN),
39
+ DO_BIT(HDFGRTR, PMOVS),
40
+ DO_BIT(HDFGRTR, PMSELR_EL0),
41
+ DO_BIT(HDFGWTR, PMSWINC_EL0),
42
+ DO_BIT(HDFGWTR, PMCR_EL0),
43
+ DO_BIT(HDFGRTR, PMMIR_EL1),
44
+ DO_BIT(HDFGRTR, PMCEIDN_EL0),
45
} FGTBit;
46
47
#undef DO_BIT
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
48
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
index XXXXXXX..XXXXXXX 100644
49
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
50
--- a/target/arm/helper.c
17
+++ b/target/arm/helper.c
51
+++ b/target/arm/helper.c
18
@@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu)
52
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
19
qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32
53
.fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmcnten),
20
", executing it\n", env->regs[15]);
54
.writefn = pmcntenset_write,
21
env->regs[14] &= ~1;
55
.accessfn = pmreg_access,
22
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
56
+ .fgt = FGT_PMCNTEN,
23
switch_v7m_security_state(env, true);
57
.raw_writefn = raw_write },
24
xpsr_write(env, 0, XPSR_IT);
58
{ .name = "PMCNTENSET_EL0", .state = ARM_CP_STATE_AA64, .type = ARM_CP_IO,
25
env->regs[15] += 4;
59
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 1,
60
.access = PL0_RW, .accessfn = pmreg_access,
61
+ .fgt = FGT_PMCNTEN,
62
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmcnten), .resetvalue = 0,
63
.writefn = pmcntenset_write, .raw_writefn = raw_write },
64
{ .name = "PMCNTENCLR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 2,
65
.access = PL0_RW,
66
.fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmcnten),
67
.accessfn = pmreg_access,
68
+ .fgt = FGT_PMCNTEN,
69
.writefn = pmcntenclr_write,
70
.type = ARM_CP_ALIAS | ARM_CP_IO },
71
{ .name = "PMCNTENCLR_EL0", .state = ARM_CP_STATE_AA64,
72
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 2,
73
.access = PL0_RW, .accessfn = pmreg_access,
74
+ .fgt = FGT_PMCNTEN,
75
.type = ARM_CP_ALIAS | ARM_CP_IO,
76
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmcnten),
77
.writefn = pmcntenclr_write },
78
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
79
.access = PL0_RW, .type = ARM_CP_IO,
80
.fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmovsr),
81
.accessfn = pmreg_access,
82
+ .fgt = FGT_PMOVS,
83
.writefn = pmovsr_write,
84
.raw_writefn = raw_write },
85
{ .name = "PMOVSCLR_EL0", .state = ARM_CP_STATE_AA64,
86
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 3,
87
.access = PL0_RW, .accessfn = pmreg_access,
88
+ .fgt = FGT_PMOVS,
89
.type = ARM_CP_ALIAS | ARM_CP_IO,
90
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr),
91
.writefn = pmovsr_write,
92
.raw_writefn = raw_write },
93
{ .name = "PMSWINC", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 4,
94
.access = PL0_W, .accessfn = pmreg_access_swinc,
95
+ .fgt = FGT_PMSWINC_EL0,
96
.type = ARM_CP_NO_RAW | ARM_CP_IO,
97
.writefn = pmswinc_write },
98
{ .name = "PMSWINC_EL0", .state = ARM_CP_STATE_AA64,
99
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 4,
100
.access = PL0_W, .accessfn = pmreg_access_swinc,
101
+ .fgt = FGT_PMSWINC_EL0,
102
.type = ARM_CP_NO_RAW | ARM_CP_IO,
103
.writefn = pmswinc_write },
104
{ .name = "PMSELR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 5,
105
.access = PL0_RW, .type = ARM_CP_ALIAS,
106
+ .fgt = FGT_PMSELR_EL0,
107
.fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmselr),
108
.accessfn = pmreg_access_selr, .writefn = pmselr_write,
109
.raw_writefn = raw_write},
110
{ .name = "PMSELR_EL0", .state = ARM_CP_STATE_AA64,
111
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 5,
112
.access = PL0_RW, .accessfn = pmreg_access_selr,
113
+ .fgt = FGT_PMSELR_EL0,
114
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmselr),
115
.writefn = pmselr_write, .raw_writefn = raw_write, },
116
{ .name = "PMCCNTR", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 0,
117
.access = PL0_RW, .resetvalue = 0, .type = ARM_CP_ALIAS | ARM_CP_IO,
118
+ .fgt = FGT_PMCCNTR_EL0,
119
.readfn = pmccntr_read, .writefn = pmccntr_write32,
120
.accessfn = pmreg_access_ccntr },
121
{ .name = "PMCCNTR_EL0", .state = ARM_CP_STATE_AA64,
122
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 13, .opc2 = 0,
123
.access = PL0_RW, .accessfn = pmreg_access_ccntr,
124
+ .fgt = FGT_PMCCNTR_EL0,
125
.type = ARM_CP_IO,
126
.fieldoffset = offsetof(CPUARMState, cp15.c15_ccnt),
127
.readfn = pmccntr_read, .writefn = pmccntr_write,
128
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
129
{ .name = "PMCCFILTR", .cp = 15, .opc1 = 0, .crn = 14, .crm = 15, .opc2 = 7,
130
.writefn = pmccfiltr_write_a32, .readfn = pmccfiltr_read_a32,
131
.access = PL0_RW, .accessfn = pmreg_access,
132
+ .fgt = FGT_PMCCFILTR_EL0,
133
.type = ARM_CP_ALIAS | ARM_CP_IO,
134
.resetvalue = 0, },
135
{ .name = "PMCCFILTR_EL0", .state = ARM_CP_STATE_AA64,
136
.opc0 = 3, .opc1 = 3, .crn = 14, .crm = 15, .opc2 = 7,
137
.writefn = pmccfiltr_write, .raw_writefn = raw_write,
138
.access = PL0_RW, .accessfn = pmreg_access,
139
+ .fgt = FGT_PMCCFILTR_EL0,
140
.type = ARM_CP_IO,
141
.fieldoffset = offsetof(CPUARMState, cp15.pmccfiltr_el0),
142
.resetvalue = 0, },
143
{ .name = "PMXEVTYPER", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 1,
144
.access = PL0_RW, .type = ARM_CP_NO_RAW | ARM_CP_IO,
145
.accessfn = pmreg_access,
146
+ .fgt = FGT_PMEVTYPERN_EL0,
147
.writefn = pmxevtyper_write, .readfn = pmxevtyper_read },
148
{ .name = "PMXEVTYPER_EL0", .state = ARM_CP_STATE_AA64,
149
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 13, .opc2 = 1,
150
.access = PL0_RW, .type = ARM_CP_NO_RAW | ARM_CP_IO,
151
.accessfn = pmreg_access,
152
+ .fgt = FGT_PMEVTYPERN_EL0,
153
.writefn = pmxevtyper_write, .readfn = pmxevtyper_read },
154
{ .name = "PMXEVCNTR", .cp = 15, .crn = 9, .crm = 13, .opc1 = 0, .opc2 = 2,
155
.access = PL0_RW, .type = ARM_CP_NO_RAW | ARM_CP_IO,
156
.accessfn = pmreg_access_xevcntr,
157
+ .fgt = FGT_PMEVCNTRN_EL0,
158
.writefn = pmxevcntr_write, .readfn = pmxevcntr_read },
159
{ .name = "PMXEVCNTR_EL0", .state = ARM_CP_STATE_AA64,
160
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 13, .opc2 = 2,
161
.access = PL0_RW, .type = ARM_CP_NO_RAW | ARM_CP_IO,
162
.accessfn = pmreg_access_xevcntr,
163
+ .fgt = FGT_PMEVCNTRN_EL0,
164
.writefn = pmxevcntr_write, .readfn = pmxevcntr_read },
165
{ .name = "PMUSERENR", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 0,
166
.access = PL0_R | PL1_RW, .accessfn = access_tpm,
167
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
168
.writefn = pmuserenr_write, .raw_writefn = raw_write },
169
{ .name = "PMINTENSET", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 1,
170
.access = PL1_RW, .accessfn = access_tpm,
171
+ .fgt = FGT_PMINTEN,
172
.type = ARM_CP_ALIAS | ARM_CP_IO,
173
.fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pminten),
174
.resetvalue = 0,
175
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
176
{ .name = "PMINTENSET_EL1", .state = ARM_CP_STATE_AA64,
177
.opc0 = 3, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 1,
178
.access = PL1_RW, .accessfn = access_tpm,
179
+ .fgt = FGT_PMINTEN,
180
.type = ARM_CP_IO,
181
.fieldoffset = offsetof(CPUARMState, cp15.c9_pminten),
182
.writefn = pmintenset_write, .raw_writefn = raw_write,
183
.resetvalue = 0x0 },
184
{ .name = "PMINTENCLR", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 2,
185
.access = PL1_RW, .accessfn = access_tpm,
186
+ .fgt = FGT_PMINTEN,
187
.type = ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO_RAW,
188
.fieldoffset = offsetof(CPUARMState, cp15.c9_pminten),
189
.writefn = pmintenclr_write, },
190
{ .name = "PMINTENCLR_EL1", .state = ARM_CP_STATE_AA64,
191
.opc0 = 3, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 2,
192
.access = PL1_RW, .accessfn = access_tpm,
193
+ .fgt = FGT_PMINTEN,
194
.type = ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO_RAW,
195
.fieldoffset = offsetof(CPUARMState, cp15.c9_pminten),
196
.writefn = pmintenclr_write },
197
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmovsset_cp_reginfo[] = {
198
/* PMOVSSET is not implemented in v7 before v7ve */
199
{ .name = "PMOVSSET", .cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 3,
200
.access = PL0_RW, .accessfn = pmreg_access,
201
+ .fgt = FGT_PMOVS,
202
.type = ARM_CP_ALIAS | ARM_CP_IO,
203
.fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmovsr),
204
.writefn = pmovsset_write,
205
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmovsset_cp_reginfo[] = {
206
{ .name = "PMOVSSET_EL0", .state = ARM_CP_STATE_AA64,
207
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 14, .opc2 = 3,
208
.access = PL0_RW, .accessfn = pmreg_access,
209
+ .fgt = FGT_PMOVS,
210
.type = ARM_CP_ALIAS | ARM_CP_IO,
211
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr),
212
.writefn = pmovsset_write,
213
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
214
ARMCPRegInfo pmcr = {
215
.name = "PMCR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 0,
216
.access = PL0_RW,
217
+ .fgt = FGT_PMCR_EL0,
218
.type = ARM_CP_IO | ARM_CP_ALIAS,
219
.fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmcr),
220
.accessfn = pmreg_access, .writefn = pmcr_write,
221
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
222
.name = "PMCR_EL0", .state = ARM_CP_STATE_AA64,
223
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 0,
224
.access = PL0_RW, .accessfn = pmreg_access,
225
+ .fgt = FGT_PMCR_EL0,
226
.type = ARM_CP_IO,
227
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmcr),
228
.resetvalue = cpu->isar.reset_pmcr_el0,
229
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
230
{ .name = pmevcntr_name, .cp = 15, .crn = 14,
231
.crm = 8 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7,
232
.access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS,
233
+ .fgt = FGT_PMEVCNTRN_EL0,
234
.readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn,
235
.accessfn = pmreg_access_xevcntr },
236
{ .name = pmevcntr_el0_name, .state = ARM_CP_STATE_AA64,
237
.opc0 = 3, .opc1 = 3, .crn = 14, .crm = 8 | (3 & (i >> 3)),
238
.opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access_xevcntr,
239
.type = ARM_CP_IO,
240
+ .fgt = FGT_PMEVCNTRN_EL0,
241
.readfn = pmevcntr_readfn, .writefn = pmevcntr_writefn,
242
.raw_readfn = pmevcntr_rawread,
243
.raw_writefn = pmevcntr_rawwrite },
244
{ .name = pmevtyper_name, .cp = 15, .crn = 14,
245
.crm = 12 | (3 & (i >> 3)), .opc1 = 0, .opc2 = i & 7,
246
.access = PL0_RW, .type = ARM_CP_IO | ARM_CP_ALIAS,
247
+ .fgt = FGT_PMEVTYPERN_EL0,
248
.readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn,
249
.accessfn = pmreg_access },
250
{ .name = pmevtyper_el0_name, .state = ARM_CP_STATE_AA64,
251
.opc0 = 3, .opc1 = 3, .crn = 14, .crm = 12 | (3 & (i >> 3)),
252
.opc2 = i & 7, .access = PL0_RW, .accessfn = pmreg_access,
253
+ .fgt = FGT_PMEVTYPERN_EL0,
254
.type = ARM_CP_IO,
255
.readfn = pmevtyper_readfn, .writefn = pmevtyper_writefn,
256
.raw_writefn = pmevtyper_rawwrite },
257
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
258
{ .name = "PMCEID2", .state = ARM_CP_STATE_AA32,
259
.cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 4,
260
.access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST,
261
+ .fgt = FGT_PMCEIDN_EL0,
262
.resetvalue = extract64(cpu->pmceid0, 32, 32) },
263
{ .name = "PMCEID3", .state = ARM_CP_STATE_AA32,
264
.cp = 15, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 5,
265
.access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST,
266
+ .fgt = FGT_PMCEIDN_EL0,
267
.resetvalue = extract64(cpu->pmceid1, 32, 32) },
268
};
269
define_arm_cp_regs(cpu, v81_pmu_regs);
270
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
271
.name = "PMMIR_EL1", .state = ARM_CP_STATE_BOTH,
272
.opc0 = 3, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 6,
273
.access = PL1_R, .accessfn = pmreg_access, .type = ARM_CP_CONST,
274
+ .fgt = FGT_PMMIR_EL1,
275
.resetvalue = 0
276
};
277
define_one_arm_cp_reg(cpu, &v84_pmmir);
278
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
279
{ .name = "PMCEID0", .state = ARM_CP_STATE_AA32,
280
.cp = 15, .opc1 = 0, .crn = 9, .crm = 12, .opc2 = 6,
281
.access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST,
282
+ .fgt = FGT_PMCEIDN_EL0,
283
.resetvalue = extract64(cpu->pmceid0, 0, 32) },
284
{ .name = "PMCEID0_EL0", .state = ARM_CP_STATE_AA64,
285
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 6,
286
.access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST,
287
+ .fgt = FGT_PMCEIDN_EL0,
288
.resetvalue = cpu->pmceid0 },
289
{ .name = "PMCEID1", .state = ARM_CP_STATE_AA32,
290
.cp = 15, .opc1 = 0, .crn = 9, .crm = 12, .opc2 = 7,
291
.access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST,
292
+ .fgt = FGT_PMCEIDN_EL0,
293
.resetvalue = extract64(cpu->pmceid1, 0, 32) },
294
{ .name = "PMCEID1_EL0", .state = ARM_CP_STATE_AA64,
295
.opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 7,
296
.access = PL0_R, .accessfn = pmreg_access, .type = ARM_CP_CONST,
297
+ .fgt = FGT_PMCEIDN_EL0,
298
.resetvalue = cpu->pmceid1 },
299
};
300
#ifdef CONFIG_USER_ONLY
26
--
301
--
27
2.20.1
302
2.34.1
28
29
diff view generated by jsdifflib
1
Currently the code in v7m_push_stack() which detects a violation
1
Mark up the sysreg definitions for the system instructions
2
of the v8M stack limit simply returns early if it does so. This
2
trapped by HFGITR bits 0..11. These bits cover various
3
is OK for the current integer-only code, but won't work for the
3
cache maintenance operations.
4
floating point handling we're about to add. We need to continue
5
executing the rest of the function so that we check for other
6
exceptions like not having permission to use the FPU and so
7
that we correctly set the FPCCR state if we are doing lazy
8
stacking. Refactor to avoid the early return.
9
4
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20190416125744.27770-10-peter.maydell@linaro.org
7
Tested-by: Fuad Tabba <tabba@google.com>
8
Message-id: 20230130182459.3309057-17-peter.maydell@linaro.org
9
Message-id: 20230127175507.2895013-17-peter.maydell@linaro.org
13
---
10
---
14
target/arm/helper.c | 23 ++++++++++++++++++-----
11
target/arm/cpregs.h | 14 ++++++++++++++
15
1 file changed, 18 insertions(+), 5 deletions(-)
12
target/arm/helper.c | 28 ++++++++++++++++++++++++++++
13
2 files changed, 42 insertions(+)
16
14
15
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpregs.h
18
+++ b/target/arm/cpregs.h
19
@@ -XXX,XX +XXX,XX @@ typedef enum FGTBit {
20
DO_BIT(HDFGWTR, PMCR_EL0),
21
DO_BIT(HDFGRTR, PMMIR_EL1),
22
DO_BIT(HDFGRTR, PMCEIDN_EL0),
23
+
24
+ /* Trap bits in HFGITR_EL2, starting from bit 0 */
25
+ DO_BIT(HFGITR, ICIALLUIS),
26
+ DO_BIT(HFGITR, ICIALLU),
27
+ DO_BIT(HFGITR, ICIVAU),
28
+ DO_BIT(HFGITR, DCIVAC),
29
+ DO_BIT(HFGITR, DCISW),
30
+ DO_BIT(HFGITR, DCCSW),
31
+ DO_BIT(HFGITR, DCCISW),
32
+ DO_BIT(HFGITR, DCCVAU),
33
+ DO_BIT(HFGITR, DCCVAP),
34
+ DO_BIT(HFGITR, DCCVADP),
35
+ DO_BIT(HFGITR, DCCIVAC),
36
+ DO_BIT(HFGITR, DCZVA),
37
} FGTBit;
38
39
#undef DO_BIT
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
40
diff --git a/target/arm/helper.c b/target/arm/helper.c
18
index XXXXXXX..XXXXXXX 100644
41
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
42
--- a/target/arm/helper.c
20
+++ b/target/arm/helper.c
43
+++ b/target/arm/helper.c
21
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
44
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
22
* should ignore further stack faults trying to process
45
#ifndef CONFIG_USER_ONLY
23
* that derived exception.)
46
/* Avoid overhead of an access check that always passes in user-mode */
24
*/
47
.accessfn = aa64_zva_access,
25
- bool stacked_ok;
48
+ .fgt = FGT_DCZVA,
26
+ bool stacked_ok = true, limitviol = false;
49
#endif
27
CPUARMState *env = &cpu->env;
50
},
28
uint32_t xpsr = xpsr_read(env);
51
{ .name = "CURRENTEL", .state = ARM_CP_STATE_AA64,
29
uint32_t frameptr = env->regs[13];
52
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
30
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
53
{ .name = "IC_IALLUIS", .state = ARM_CP_STATE_AA64,
31
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
54
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 1, .opc2 = 0,
32
env->v7m.secure);
55
.access = PL1_W, .type = ARM_CP_NOP,
33
env->regs[13] = limit;
56
+ .fgt = FGT_ICIALLUIS,
34
- return true;
57
.accessfn = access_ticab },
35
+ /*
58
{ .name = "IC_IALLU", .state = ARM_CP_STATE_AA64,
36
+ * We won't try to perform any further memory accesses but
59
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 5, .opc2 = 0,
37
+ * we must continue through the following code to check for
60
.access = PL1_W, .type = ARM_CP_NOP,
38
+ * permission faults during FPU state preservation, and we
61
+ .fgt = FGT_ICIALLU,
39
+ * must update FPCCR if lazy stacking is enabled.
62
.accessfn = access_tocu },
40
+ */
63
{ .name = "IC_IVAU", .state = ARM_CP_STATE_AA64,
41
+ limitviol = true;
64
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 5, .opc2 = 1,
42
+ stacked_ok = false;
65
.access = PL0_W, .type = ARM_CP_NOP,
43
}
66
+ .fgt = FGT_ICIVAU,
44
}
67
.accessfn = access_tocu },
45
68
{ .name = "DC_IVAC", .state = ARM_CP_STATE_AA64,
46
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
69
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 1,
47
* (which may be taken in preference to the one we started with
70
.access = PL1_W, .accessfn = aa64_cacheop_poc_access,
48
* if it has higher priority).
71
+ .fgt = FGT_DCIVAC,
49
*/
72
.type = ARM_CP_NOP },
50
- stacked_ok =
73
{ .name = "DC_ISW", .state = ARM_CP_STATE_AA64,
51
+ stacked_ok = stacked_ok &&
74
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 2,
52
v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) &&
75
+ .fgt = FGT_DCISW,
53
v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) &&
76
.access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP },
54
v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) &&
77
{ .name = "DC_CVAC", .state = ARM_CP_STATE_AA64,
55
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
78
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 1,
56
v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) &&
79
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
57
v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false);
80
.accessfn = aa64_cacheop_poc_access },
58
81
{ .name = "DC_CSW", .state = ARM_CP_STATE_AA64,
59
- /* Update SP regardless of whether any of the stack accesses failed. */
82
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2,
60
- env->regs[13] = frameptr;
83
+ .fgt = FGT_DCCSW,
61
+ /*
84
.access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP },
62
+ * If we broke a stack limit then SP was already updated earlier;
85
{ .name = "DC_CVAU", .state = ARM_CP_STATE_AA64,
63
+ * otherwise we update SP regardless of whether any of the stack
86
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 11, .opc2 = 1,
64
+ * accesses failed or we took some other kind of fault.
87
.access = PL0_W, .type = ARM_CP_NOP,
65
+ */
88
+ .fgt = FGT_DCCVAU,
66
+ if (!limitviol) {
89
.accessfn = access_tocu },
67
+ env->regs[13] = frameptr;
90
{ .name = "DC_CIVAC", .state = ARM_CP_STATE_AA64,
68
+ }
91
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 1,
69
92
.access = PL0_W, .type = ARM_CP_NOP,
70
return !stacked_ok;
93
+ .fgt = FGT_DCCIVAC,
71
}
94
.accessfn = aa64_cacheop_poc_access },
95
{ .name = "DC_CISW", .state = ARM_CP_STATE_AA64,
96
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 2,
97
+ .fgt = FGT_DCCISW,
98
.access = PL1_W, .accessfn = access_tsw, .type = ARM_CP_NOP },
99
/* TLBI operations */
100
{ .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64,
101
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpop_reg[] = {
102
{ .name = "DC_CVAP", .state = ARM_CP_STATE_AA64,
103
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 1,
104
.access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END,
105
+ .fgt = FGT_DCCVAP,
106
.accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn },
107
};
108
109
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo dcpodp_reg[] = {
110
{ .name = "DC_CVADP", .state = ARM_CP_STATE_AA64,
111
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 1,
112
.access = PL0_W, .type = ARM_CP_NO_RAW | ARM_CP_SUPPRESS_TB_END,
113
+ .fgt = FGT_DCCVADP,
114
.accessfn = aa64_cacheop_poc_access, .writefn = dccvap_writefn },
115
};
116
#endif /*CONFIG_USER_ONLY*/
117
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_reginfo[] = {
118
{ .name = "DC_IGVAC", .state = ARM_CP_STATE_AA64,
119
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 3,
120
.type = ARM_CP_NOP, .access = PL1_W,
121
+ .fgt = FGT_DCIVAC,
122
.accessfn = aa64_cacheop_poc_access },
123
{ .name = "DC_IGSW", .state = ARM_CP_STATE_AA64,
124
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 4,
125
+ .fgt = FGT_DCISW,
126
.type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw },
127
{ .name = "DC_IGDVAC", .state = ARM_CP_STATE_AA64,
128
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 5,
129
.type = ARM_CP_NOP, .access = PL1_W,
130
+ .fgt = FGT_DCIVAC,
131
.accessfn = aa64_cacheop_poc_access },
132
{ .name = "DC_IGDSW", .state = ARM_CP_STATE_AA64,
133
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 6,
134
+ .fgt = FGT_DCISW,
135
.type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw },
136
{ .name = "DC_CGSW", .state = ARM_CP_STATE_AA64,
137
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 4,
138
+ .fgt = FGT_DCCSW,
139
.type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw },
140
{ .name = "DC_CGDSW", .state = ARM_CP_STATE_AA64,
141
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 6,
142
+ .fgt = FGT_DCCSW,
143
.type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw },
144
{ .name = "DC_CIGSW", .state = ARM_CP_STATE_AA64,
145
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 4,
146
+ .fgt = FGT_DCCISW,
147
.type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw },
148
{ .name = "DC_CIGDSW", .state = ARM_CP_STATE_AA64,
149
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 6,
150
+ .fgt = FGT_DCCISW,
151
.type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw },
152
};
153
154
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = {
155
{ .name = "DC_CGVAP", .state = ARM_CP_STATE_AA64,
156
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 3,
157
.type = ARM_CP_NOP, .access = PL0_W,
158
+ .fgt = FGT_DCCVAP,
159
.accessfn = aa64_cacheop_poc_access },
160
{ .name = "DC_CGDVAP", .state = ARM_CP_STATE_AA64,
161
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 5,
162
.type = ARM_CP_NOP, .access = PL0_W,
163
+ .fgt = FGT_DCCVAP,
164
.accessfn = aa64_cacheop_poc_access },
165
{ .name = "DC_CGVADP", .state = ARM_CP_STATE_AA64,
166
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 3,
167
.type = ARM_CP_NOP, .access = PL0_W,
168
+ .fgt = FGT_DCCVADP,
169
.accessfn = aa64_cacheop_poc_access },
170
{ .name = "DC_CGDVADP", .state = ARM_CP_STATE_AA64,
171
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 13, .opc2 = 5,
172
.type = ARM_CP_NOP, .access = PL0_W,
173
+ .fgt = FGT_DCCVADP,
174
.accessfn = aa64_cacheop_poc_access },
175
{ .name = "DC_CIGVAC", .state = ARM_CP_STATE_AA64,
176
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 3,
177
.type = ARM_CP_NOP, .access = PL0_W,
178
+ .fgt = FGT_DCCIVAC,
179
.accessfn = aa64_cacheop_poc_access },
180
{ .name = "DC_CIGDVAC", .state = ARM_CP_STATE_AA64,
181
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 5,
182
.type = ARM_CP_NOP, .access = PL0_W,
183
+ .fgt = FGT_DCCIVAC,
184
.accessfn = aa64_cacheop_poc_access },
185
{ .name = "DC_GVA", .state = ARM_CP_STATE_AA64,
186
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 4, .opc2 = 3,
187
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = {
188
#ifndef CONFIG_USER_ONLY
189
/* Avoid overhead of an access check that always passes in user-mode */
190
.accessfn = aa64_zva_access,
191
+ .fgt = FGT_DCZVA,
192
#endif
193
},
194
{ .name = "DC_GZVA", .state = ARM_CP_STATE_AA64,
195
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = {
196
#ifndef CONFIG_USER_ONLY
197
/* Avoid overhead of an access check that always passes in user-mode */
198
.accessfn = aa64_zva_access,
199
+ .fgt = FGT_DCZVA,
200
#endif
201
},
202
};
72
--
203
--
73
2.20.1
204
2.34.1
74
75
diff view generated by jsdifflib
1
The TailChain() pseudocode specifies that a tail chaining
1
Mark up the sysreg definitions for the system instructions
2
exception should sanitize the excReturn all-ones bits and
2
trapped by HFGITR bits 12..17. These bits cover AT address
3
(if there is no FPU) the excReturn FType bits; we weren't
3
translation instructions.
4
doing this.
5
4
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-14-peter.maydell@linaro.org
7
Tested-by: Fuad Tabba <tabba@google.com>
8
Message-id: 20230130182459.3309057-18-peter.maydell@linaro.org
9
Message-id: 20230127175507.2895013-18-peter.maydell@linaro.org
9
---
10
---
10
target/arm/helper.c | 8 ++++++++
11
target/arm/cpregs.h | 6 ++++++
11
1 file changed, 8 insertions(+)
12
target/arm/helper.c | 6 ++++++
13
2 files changed, 12 insertions(+)
12
14
15
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpregs.h
18
+++ b/target/arm/cpregs.h
19
@@ -XXX,XX +XXX,XX @@ typedef enum FGTBit {
20
DO_BIT(HFGITR, DCCVADP),
21
DO_BIT(HFGITR, DCCIVAC),
22
DO_BIT(HFGITR, DCZVA),
23
+ DO_BIT(HFGITR, ATS1E1R),
24
+ DO_BIT(HFGITR, ATS1E1W),
25
+ DO_BIT(HFGITR, ATS1E0R),
26
+ DO_BIT(HFGITR, ATS1E0W),
27
+ DO_BIT(HFGITR, ATS1E1RP),
28
+ DO_BIT(HFGITR, ATS1E1WP),
29
} FGTBit;
30
31
#undef DO_BIT
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
32
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
34
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
35
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
36
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
18
qemu_log_mask(CPU_LOG_INT, "...taking pending %s exception %d\n",
37
{ .name = "AT_S1E1R", .state = ARM_CP_STATE_AA64,
19
targets_secure ? "secure" : "nonsecure", exc);
38
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 0,
20
39
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
21
+ if (dotailchain) {
40
+ .fgt = FGT_ATS1E1R,
22
+ /* Sanitize LR FType and PREFIX bits */
41
.writefn = ats_write64 },
23
+ if (!arm_feature(env, ARM_FEATURE_VFP)) {
42
{ .name = "AT_S1E1W", .state = ARM_CP_STATE_AA64,
24
+ lr |= R_V7M_EXCRET_FTYPE_MASK;
43
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 1,
25
+ }
44
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
26
+ lr = deposit32(lr, 24, 8, 0xff);
45
+ .fgt = FGT_ATS1E1W,
27
+ }
46
.writefn = ats_write64 },
28
+
47
{ .name = "AT_S1E0R", .state = ARM_CP_STATE_AA64,
29
if (arm_feature(env, ARM_FEATURE_V8)) {
48
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 2,
30
if (arm_feature(env, ARM_FEATURE_M_SECURITY) &&
49
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
31
(lr & R_V7M_EXCRET_S_MASK)) {
50
+ .fgt = FGT_ATS1E0R,
51
.writefn = ats_write64 },
52
{ .name = "AT_S1E0W", .state = ARM_CP_STATE_AA64,
53
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 3,
54
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
55
+ .fgt = FGT_ATS1E0W,
56
.writefn = ats_write64 },
57
{ .name = "AT_S12E1R", .state = ARM_CP_STATE_AA64,
58
.opc0 = 1, .opc1 = 4, .crn = 7, .crm = 8, .opc2 = 4,
59
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo ats1e1_reginfo[] = {
60
{ .name = "AT_S1E1RP", .state = ARM_CP_STATE_AA64,
61
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 0,
62
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
63
+ .fgt = FGT_ATS1E1RP,
64
.writefn = ats_write64 },
65
{ .name = "AT_S1E1WP", .state = ARM_CP_STATE_AA64,
66
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 9, .opc2 = 1,
67
.access = PL1_W, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC,
68
+ .fgt = FGT_ATS1E1WP,
69
.writefn = ats_write64 },
70
};
71
32
--
72
--
33
2.20.1
73
2.34.1
34
35
diff view generated by jsdifflib
1
The M-profile CONTROL register has two bits -- SFPA and FPCA --
1
Mark up the sysreg definitions for the system instructions
2
which relate to floating-point support, and should be RES0 otherwise.
2
trapped by HFGITR bits 18..47. These bits cover TLBI
3
Handle them correctly in the MSR/MRS register access code.
3
TLB maintenance instructions.
4
Neither is banked between security states, so they are stored
4
5
in v7m.control[M_REG_S] regardless of current security state.
5
(If we implemented FEAT_XS we would need to trap some of the
6
instructions added by that feature using these bits; but we don't
7
yet, so will need to add the .fgt markup when we do.)
6
8
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-9-peter.maydell@linaro.org
11
Tested-by: Fuad Tabba <tabba@google.com>
12
Message-id: 20230130182459.3309057-19-peter.maydell@linaro.org
13
Message-id: 20230127175507.2895013-19-peter.maydell@linaro.org
10
---
14
---
11
target/arm/helper.c | 57 ++++++++++++++++++++++++++++++++++++++-------
15
target/arm/cpregs.h | 30 ++++++++++++++++++++++++++++++
12
1 file changed, 49 insertions(+), 8 deletions(-)
16
target/arm/helper.c | 30 ++++++++++++++++++++++++++++++
17
2 files changed, 60 insertions(+)
13
18
19
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/cpregs.h
22
+++ b/target/arm/cpregs.h
23
@@ -XXX,XX +XXX,XX @@ typedef enum FGTBit {
24
DO_BIT(HFGITR, ATS1E0W),
25
DO_BIT(HFGITR, ATS1E1RP),
26
DO_BIT(HFGITR, ATS1E1WP),
27
+ DO_BIT(HFGITR, TLBIVMALLE1OS),
28
+ DO_BIT(HFGITR, TLBIVAE1OS),
29
+ DO_BIT(HFGITR, TLBIASIDE1OS),
30
+ DO_BIT(HFGITR, TLBIVAAE1OS),
31
+ DO_BIT(HFGITR, TLBIVALE1OS),
32
+ DO_BIT(HFGITR, TLBIVAALE1OS),
33
+ DO_BIT(HFGITR, TLBIRVAE1OS),
34
+ DO_BIT(HFGITR, TLBIRVAAE1OS),
35
+ DO_BIT(HFGITR, TLBIRVALE1OS),
36
+ DO_BIT(HFGITR, TLBIRVAALE1OS),
37
+ DO_BIT(HFGITR, TLBIVMALLE1IS),
38
+ DO_BIT(HFGITR, TLBIVAE1IS),
39
+ DO_BIT(HFGITR, TLBIASIDE1IS),
40
+ DO_BIT(HFGITR, TLBIVAAE1IS),
41
+ DO_BIT(HFGITR, TLBIVALE1IS),
42
+ DO_BIT(HFGITR, TLBIVAALE1IS),
43
+ DO_BIT(HFGITR, TLBIRVAE1IS),
44
+ DO_BIT(HFGITR, TLBIRVAAE1IS),
45
+ DO_BIT(HFGITR, TLBIRVALE1IS),
46
+ DO_BIT(HFGITR, TLBIRVAALE1IS),
47
+ DO_BIT(HFGITR, TLBIRVAE1),
48
+ DO_BIT(HFGITR, TLBIRVAAE1),
49
+ DO_BIT(HFGITR, TLBIRVALE1),
50
+ DO_BIT(HFGITR, TLBIRVAALE1),
51
+ DO_BIT(HFGITR, TLBIVMALLE1),
52
+ DO_BIT(HFGITR, TLBIVAE1),
53
+ DO_BIT(HFGITR, TLBIASIDE1),
54
+ DO_BIT(HFGITR, TLBIVAAE1),
55
+ DO_BIT(HFGITR, TLBIVALE1),
56
+ DO_BIT(HFGITR, TLBIVAALE1),
57
} FGTBit;
58
59
#undef DO_BIT
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
60
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
index XXXXXXX..XXXXXXX 100644
61
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
62
--- a/target/arm/helper.c
17
+++ b/target/arm/helper.c
63
+++ b/target/arm/helper.c
18
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
64
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
19
return xpsr_read(env) & mask;
65
{ .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64,
20
break;
66
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0,
21
case 20: /* CONTROL */
67
.access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW,
22
- return env->v7m.control[env->v7m.secure];
68
+ .fgt = FGT_TLBIVMALLE1IS,
23
+ {
69
.writefn = tlbi_aa64_vmalle1is_write },
24
+ uint32_t value = env->v7m.control[env->v7m.secure];
70
{ .name = "TLBI_VAE1IS", .state = ARM_CP_STATE_AA64,
25
+ if (!env->v7m.secure) {
71
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1,
26
+ /* SFPA is RAZ/WI from NS; FPCA is stored in the M_REG_S bank */
72
.access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW,
27
+ value |= env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK;
73
+ .fgt = FGT_TLBIVAE1IS,
28
+ }
74
.writefn = tlbi_aa64_vae1is_write },
29
+ return value;
75
{ .name = "TLBI_ASIDE1IS", .state = ARM_CP_STATE_AA64,
30
+ }
76
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2,
31
case 0x94: /* CONTROL_NS */
77
.access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW,
32
/* We have to handle this here because unprivileged Secure code
78
+ .fgt = FGT_TLBIASIDE1IS,
33
* can read the NS CONTROL register.
79
.writefn = tlbi_aa64_vmalle1is_write },
34
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
80
{ .name = "TLBI_VAAE1IS", .state = ARM_CP_STATE_AA64,
35
if (!env->v7m.secure) {
81
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3,
36
return 0;
82
.access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW,
37
}
83
+ .fgt = FGT_TLBIVAAE1IS,
38
- return env->v7m.control[M_REG_NS];
84
.writefn = tlbi_aa64_vae1is_write },
39
+ return env->v7m.control[M_REG_NS] |
85
{ .name = "TLBI_VALE1IS", .state = ARM_CP_STATE_AA64,
40
+ (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK);
86
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5,
41
}
87
.access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW,
42
88
+ .fgt = FGT_TLBIVALE1IS,
43
if (el == 0) {
89
.writefn = tlbi_aa64_vae1is_write },
44
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
90
{ .name = "TLBI_VAALE1IS", .state = ARM_CP_STATE_AA64,
45
*/
91
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7,
46
uint32_t mask = extract32(maskreg, 8, 4);
92
.access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW,
47
uint32_t reg = extract32(maskreg, 0, 8);
93
+ .fgt = FGT_TLBIVAALE1IS,
48
+ int cur_el = arm_current_el(env);
94
.writefn = tlbi_aa64_vae1is_write },
49
95
{ .name = "TLBI_VMALLE1", .state = ARM_CP_STATE_AA64,
50
- if (arm_current_el(env) == 0 && reg > 7) {
96
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0,
51
- /* only xPSR sub-fields may be written by unprivileged */
97
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
52
+ if (cur_el == 0 && reg > 7 && reg != 20) {
98
+ .fgt = FGT_TLBIVMALLE1,
53
+ /*
99
.writefn = tlbi_aa64_vmalle1_write },
54
+ * only xPSR sub-fields and CONTROL.SFPA may be written by
100
{ .name = "TLBI_VAE1", .state = ARM_CP_STATE_AA64,
55
+ * unprivileged code
101
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 1,
56
+ */
102
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
57
return;
103
+ .fgt = FGT_TLBIVAE1,
58
}
104
.writefn = tlbi_aa64_vae1_write },
59
105
{ .name = "TLBI_ASIDE1", .state = ARM_CP_STATE_AA64,
60
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
106
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 2,
61
env->v7m.control[M_REG_NS] &= ~R_V7M_CONTROL_NPRIV_MASK;
107
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
62
env->v7m.control[M_REG_NS] |= val & R_V7M_CONTROL_NPRIV_MASK;
108
+ .fgt = FGT_TLBIASIDE1,
63
}
109
.writefn = tlbi_aa64_vmalle1_write },
64
+ /*
110
{ .name = "TLBI_VAAE1", .state = ARM_CP_STATE_AA64,
65
+ * SFPA is RAZ/WI from NS. FPCA is RO if NSACR.CP10 == 0,
111
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3,
66
+ * RES0 if the FPU is not present, and is stored in the S bank
112
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
67
+ */
113
+ .fgt = FGT_TLBIVAAE1,
68
+ if (arm_feature(env, ARM_FEATURE_VFP) &&
114
.writefn = tlbi_aa64_vae1_write },
69
+ extract32(env->v7m.nsacr, 10, 1)) {
115
{ .name = "TLBI_VALE1", .state = ARM_CP_STATE_AA64,
70
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
116
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5,
71
+ env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK;
117
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
72
+ }
118
+ .fgt = FGT_TLBIVALE1,
73
return;
119
.writefn = tlbi_aa64_vae1_write },
74
case 0x98: /* SP_NS */
120
{ .name = "TLBI_VAALE1", .state = ARM_CP_STATE_AA64,
75
{
121
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 7,
76
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
122
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
77
env->v7m.faultmask[env->v7m.secure] = val & 1;
123
+ .fgt = FGT_TLBIVAALE1,
78
break;
124
.writefn = tlbi_aa64_vae1_write },
79
case 20: /* CONTROL */
125
{ .name = "TLBI_IPAS2E1IS", .state = ARM_CP_STATE_AA64,
80
- /* Writing to the SPSEL bit only has an effect if we are in
126
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 1,
81
+ /*
127
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbirange_reginfo[] = {
82
+ * Writing to the SPSEL bit only has an effect if we are in
128
{ .name = "TLBI_RVAE1IS", .state = ARM_CP_STATE_AA64,
83
* thread mode; other bits can be updated by any privileged code.
129
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 2, .opc2 = 1,
84
* write_v7m_control_spsel() deals with updating the SPSEL bit in
130
.access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW,
85
* env->v7m.control, so we only need update the others.
131
+ .fgt = FGT_TLBIRVAE1IS,
86
* For v7M, we must just ignore explicit writes to SPSEL in handler
132
.writefn = tlbi_aa64_rvae1is_write },
87
* mode; for v8M the write is permitted but will have no effect.
133
{ .name = "TLBI_RVAAE1IS", .state = ARM_CP_STATE_AA64,
88
+ * All these bits are writes-ignored from non-privileged code,
134
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 2, .opc2 = 3,
89
+ * except for SFPA.
135
.access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW,
90
*/
136
+ .fgt = FGT_TLBIRVAAE1IS,
91
- if (arm_feature(env, ARM_FEATURE_V8) ||
137
.writefn = tlbi_aa64_rvae1is_write },
92
- !arm_v7m_is_handler_mode(env)) {
138
{ .name = "TLBI_RVALE1IS", .state = ARM_CP_STATE_AA64,
93
+ if (cur_el > 0 && (arm_feature(env, ARM_FEATURE_V8) ||
139
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 2, .opc2 = 5,
94
+ !arm_v7m_is_handler_mode(env))) {
140
.access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW,
95
write_v7m_control_spsel(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0);
141
+ .fgt = FGT_TLBIRVALE1IS,
96
}
142
.writefn = tlbi_aa64_rvae1is_write },
97
- if (arm_feature(env, ARM_FEATURE_M_MAIN)) {
143
{ .name = "TLBI_RVAALE1IS", .state = ARM_CP_STATE_AA64,
98
+ if (cur_el > 0 && arm_feature(env, ARM_FEATURE_M_MAIN)) {
144
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 2, .opc2 = 7,
99
env->v7m.control[env->v7m.secure] &= ~R_V7M_CONTROL_NPRIV_MASK;
145
.access = PL1_W, .accessfn = access_ttlbis, .type = ARM_CP_NO_RAW,
100
env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK;
146
+ .fgt = FGT_TLBIRVAALE1IS,
101
}
147
.writefn = tlbi_aa64_rvae1is_write },
102
+ if (arm_feature(env, ARM_FEATURE_VFP)) {
148
{ .name = "TLBI_RVAE1OS", .state = ARM_CP_STATE_AA64,
103
+ /*
149
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 1,
104
+ * SFPA is RAZ/WI from NS or if no FPU.
150
.access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
105
+ * FPCA is RO if NSACR.CP10 == 0, RES0 if the FPU is not present.
151
+ .fgt = FGT_TLBIRVAE1OS,
106
+ * Both are stored in the S bank.
152
.writefn = tlbi_aa64_rvae1is_write },
107
+ */
153
{ .name = "TLBI_RVAAE1OS", .state = ARM_CP_STATE_AA64,
108
+ if (env->v7m.secure) {
154
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 3,
109
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
155
.access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
110
+ env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_SFPA_MASK;
156
+ .fgt = FGT_TLBIRVAAE1OS,
111
+ }
157
.writefn = tlbi_aa64_rvae1is_write },
112
+ if (cur_el > 0 &&
158
{ .name = "TLBI_RVALE1OS", .state = ARM_CP_STATE_AA64,
113
+ (env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_SECURITY) ||
159
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 5,
114
+ extract32(env->v7m.nsacr, 10, 1))) {
160
.access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
115
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
161
+ .fgt = FGT_TLBIRVALE1OS,
116
+ env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK;
162
.writefn = tlbi_aa64_rvae1is_write },
117
+ }
163
{ .name = "TLBI_RVAALE1OS", .state = ARM_CP_STATE_AA64,
118
+ }
164
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 7,
119
break;
165
.access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
120
default:
166
+ .fgt = FGT_TLBIRVAALE1OS,
121
bad_reg:
167
.writefn = tlbi_aa64_rvae1is_write },
168
{ .name = "TLBI_RVAE1", .state = ARM_CP_STATE_AA64,
169
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 1,
170
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
171
+ .fgt = FGT_TLBIRVAE1,
172
.writefn = tlbi_aa64_rvae1_write },
173
{ .name = "TLBI_RVAAE1", .state = ARM_CP_STATE_AA64,
174
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 3,
175
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
176
+ .fgt = FGT_TLBIRVAAE1,
177
.writefn = tlbi_aa64_rvae1_write },
178
{ .name = "TLBI_RVALE1", .state = ARM_CP_STATE_AA64,
179
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 5,
180
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
181
+ .fgt = FGT_TLBIRVALE1,
182
.writefn = tlbi_aa64_rvae1_write },
183
{ .name = "TLBI_RVAALE1", .state = ARM_CP_STATE_AA64,
184
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 7,
185
.access = PL1_W, .accessfn = access_ttlb, .type = ARM_CP_NO_RAW,
186
+ .fgt = FGT_TLBIRVAALE1,
187
.writefn = tlbi_aa64_rvae1_write },
188
{ .name = "TLBI_RIPAS2E1IS", .state = ARM_CP_STATE_AA64,
189
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 0, .opc2 = 2,
190
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo tlbios_reginfo[] = {
191
{ .name = "TLBI_VMALLE1OS", .state = ARM_CP_STATE_AA64,
192
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 0,
193
.access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
194
+ .fgt = FGT_TLBIVMALLE1OS,
195
.writefn = tlbi_aa64_vmalle1is_write },
196
{ .name = "TLBI_VAE1OS", .state = ARM_CP_STATE_AA64,
197
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 1,
198
+ .fgt = FGT_TLBIVAE1OS,
199
.access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
200
.writefn = tlbi_aa64_vae1is_write },
201
{ .name = "TLBI_ASIDE1OS", .state = ARM_CP_STATE_AA64,
202
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 2,
203
.access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
204
+ .fgt = FGT_TLBIASIDE1OS,
205
.writefn = tlbi_aa64_vmalle1is_write },
206
{ .name = "TLBI_VAAE1OS", .state = ARM_CP_STATE_AA64,
207
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 3,
208
.access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
209
+ .fgt = FGT_TLBIVAAE1OS,
210
.writefn = tlbi_aa64_vae1is_write },
211
{ .name = "TLBI_VALE1OS", .state = ARM_CP_STATE_AA64,
212
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 5,
213
.access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
214
+ .fgt = FGT_TLBIVALE1OS,
215
.writefn = tlbi_aa64_vae1is_write },
216
{ .name = "TLBI_VAALE1OS", .state = ARM_CP_STATE_AA64,
217
.opc0 = 1, .opc1 = 0, .crn = 8, .crm = 1, .opc2 = 7,
218
.access = PL1_W, .accessfn = access_ttlbos, .type = ARM_CP_NO_RAW,
219
+ .fgt = FGT_TLBIVAALE1OS,
220
.writefn = tlbi_aa64_vae1is_write },
221
{ .name = "TLBI_ALLE2OS", .state = ARM_CP_STATE_AA64,
222
.opc0 = 1, .opc1 = 4, .crn = 8, .crm = 1, .opc2 = 0,
122
--
223
--
123
2.20.1
224
2.34.1
124
125
diff view generated by jsdifflib
1
Like AArch64, M-profile floating point has no FPEXC enable
1
Mark up the sysreg definitions for the system instructions
2
bit to gate floating point; so always set the VFPEN TB flag.
2
trapped by HFGITR bits 48..63.
3
3
4
M-profile also has CPACR and NSACR similar to A-profile;
4
Some of these bits are for trapping instructions which are
5
they behave slightly differently:
5
not in the system instruction encoding (i.e. which are
6
* the CPACR is banked between Secure and Non-Secure
6
not handled by the ARMCPRegInfo mechanism):
7
* if the NSACR forces a trap then this is taken to
7
* ERET, ERETAA, ERETAB
8
the Secure state, not the Non-Secure state
8
* SVC
9
9
10
Honour the CPACR and NSACR settings. The NSACR handling
10
We will have to handle those separately and manually.
11
requires us to borrow the exception.target_el field
12
(usually meaningless for M profile) to distinguish the
13
NOCP UsageFault taken to Secure state from the more
14
usual fault taken to the current security state.
15
11
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Message-id: 20190416125744.27770-6-peter.maydell@linaro.org
14
Tested-by: Fuad Tabba <tabba@google.com>
15
Message-id: 20230130182459.3309057-20-peter.maydell@linaro.org
16
Message-id: 20230127175507.2895013-20-peter.maydell@linaro.org
19
---
17
---
20
target/arm/helper.c | 55 +++++++++++++++++++++++++++++++++++++++---
18
target/arm/cpregs.h | 4 ++++
21
target/arm/translate.c | 10 ++++++--
19
target/arm/helper.c | 9 +++++++++
22
2 files changed, 60 insertions(+), 5 deletions(-)
20
2 files changed, 13 insertions(+)
23
21
22
diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
23
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/cpregs.h
25
+++ b/target/arm/cpregs.h
26
@@ -XXX,XX +XXX,XX @@ typedef enum FGTBit {
27
DO_BIT(HFGITR, TLBIVAAE1),
28
DO_BIT(HFGITR, TLBIVALE1),
29
DO_BIT(HFGITR, TLBIVAALE1),
30
+ DO_BIT(HFGITR, CFPRCTX),
31
+ DO_BIT(HFGITR, DVPRCTX),
32
+ DO_BIT(HFGITR, CPPRCTX),
33
+ DO_BIT(HFGITR, DCCVAC),
34
} FGTBit;
35
36
#undef DO_BIT
24
diff --git a/target/arm/helper.c b/target/arm/helper.c
37
diff --git a/target/arm/helper.c b/target/arm/helper.c
25
index XXXXXXX..XXXXXXX 100644
38
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/helper.c
39
--- a/target/arm/helper.c
27
+++ b/target/arm/helper.c
40
+++ b/target/arm/helper.c
28
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
41
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
29
return target_el;
42
{ .name = "DC_CVAC", .state = ARM_CP_STATE_AA64,
30
}
43
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 1,
31
44
.access = PL0_W, .type = ARM_CP_NOP,
32
+/*
45
+ .fgt = FGT_DCCVAC,
33
+ * Return true if the v7M CPACR permits access to the FPU for the specified
46
.accessfn = aa64_cacheop_poc_access },
34
+ * security state and privilege level.
47
{ .name = "DC_CSW", .state = ARM_CP_STATE_AA64,
35
+ */
48
.opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 2,
36
+static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv)
49
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = {
37
+{
50
{ .name = "DC_CGVAC", .state = ARM_CP_STATE_AA64,
38
+ switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) {
51
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 3,
39
+ case 0:
52
.type = ARM_CP_NOP, .access = PL0_W,
40
+ case 2: /* UNPREDICTABLE: we treat like 0 */
53
+ .fgt = FGT_DCCVAC,
41
+ return false;
54
.accessfn = aa64_cacheop_poc_access },
42
+ case 1:
55
{ .name = "DC_CGDVAC", .state = ARM_CP_STATE_AA64,
43
+ return is_priv;
56
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 10, .opc2 = 5,
44
+ case 3:
57
.type = ARM_CP_NOP, .access = PL0_W,
45
+ return true;
58
+ .fgt = FGT_DCCVAC,
46
+ default:
59
.accessfn = aa64_cacheop_poc_access },
47
+ g_assert_not_reached();
60
{ .name = "DC_CGVAP", .state = ARM_CP_STATE_AA64,
48
+ }
61
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 12, .opc2 = 3,
49
+}
62
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri,
50
+
63
static const ARMCPRegInfo predinv_reginfo[] = {
51
static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
64
{ .name = "CFP_RCTX", .state = ARM_CP_STATE_AA64,
52
ARMMMUIdx mmu_idx, bool ignfault)
65
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 3, .opc2 = 4,
53
{
66
+ .fgt = FGT_CFPRCTX,
54
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
67
.type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv },
55
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK;
68
{ .name = "DVP_RCTX", .state = ARM_CP_STATE_AA64,
56
break;
69
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 3, .opc2 = 5,
57
case EXCP_NOCP:
70
+ .fgt = FGT_DVPRCTX,
58
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
71
.type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv },
59
- env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;
72
{ .name = "CPP_RCTX", .state = ARM_CP_STATE_AA64,
60
+ {
73
.opc0 = 1, .opc1 = 3, .crn = 7, .crm = 3, .opc2 = 7,
61
+ /*
74
+ .fgt = FGT_CPPRCTX,
62
+ * NOCP might be directed to something other than the current
75
.type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv },
63
+ * security state if this fault is because of NSACR; we indicate
76
/*
64
+ * the target security state using exception.target_el.
77
* Note the AArch32 opcodes have a different OPC1.
65
+ */
66
+ int target_secstate;
67
+
68
+ if (env->exception.target_el == 3) {
69
+ target_secstate = M_REG_S;
70
+ } else {
71
+ target_secstate = env->v7m.secure;
72
+ }
73
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, target_secstate);
74
+ env->v7m.cfsr[target_secstate] |= R_V7M_CFSR_NOCP_MASK;
75
break;
76
+ }
77
case EXCP_INVSTATE:
78
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
79
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK;
80
@@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el)
81
return 0;
82
}
83
84
+ if (arm_feature(env, ARM_FEATURE_M)) {
85
+ /* CPACR can cause a NOCP UsageFault taken to current security state */
86
+ if (!v7m_cpacr_pass(env, env->v7m.secure, cur_el != 0)) {
87
+ return 1;
88
+ }
89
+
90
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY) && !env->v7m.secure) {
91
+ if (!extract32(env->v7m.nsacr, 10, 1)) {
92
+ /* FP insns cause a NOCP UsageFault taken to Secure */
93
+ return 3;
94
+ }
95
+ }
96
+
97
+ return 0;
98
+ }
99
+
100
/* The CPACR controls traps to EL1, or PL1 if we're 32 bit:
101
* 0, 2 : trap EL0 and EL1/PL1 accesses
102
* 1 : trap only EL0 accesses
103
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
104
flags = FIELD_DP32(flags, TBFLAG_A32, SCTLR_B, arm_sctlr_b(env));
105
flags = FIELD_DP32(flags, TBFLAG_A32, NS, !access_secure_reg(env));
106
if (env->vfp.xregs[ARM_VFP_FPEXC] & (1 << 30)
107
- || arm_el_is_aa64(env, 1)) {
108
+ || arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) {
109
flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1);
110
}
111
flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar);
112
diff --git a/target/arm/translate.c b/target/arm/translate.c
113
index XXXXXXX..XXXXXXX 100644
114
--- a/target/arm/translate.c
115
+++ b/target/arm/translate.c
116
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
117
* for attempts to execute invalid vfp/neon encodings with FP disabled.
118
*/
78
*/
119
if (s->fp_excp_el) {
79
{ .name = "CFPRCTX", .state = ARM_CP_STATE_AA32,
120
- gen_exception_insn(s, 4, EXCP_UDEF,
80
.cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 4,
121
- syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
81
+ .fgt = FGT_CFPRCTX,
122
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
82
.type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv },
123
+ gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(),
83
{ .name = "DVPRCTX", .state = ARM_CP_STATE_AA32,
124
+ s->fp_excp_el);
84
.cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 5,
125
+ } else {
85
+ .fgt = FGT_DVPRCTX,
126
+ gen_exception_insn(s, 4, EXCP_UDEF,
86
.type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv },
127
+ syn_fp_access_trap(1, 0xe, false),
87
{ .name = "CPPRCTX", .state = ARM_CP_STATE_AA32,
128
+ s->fp_excp_el);
88
.cp = 15, .opc1 = 0, .crn = 7, .crm = 3, .opc2 = 7,
129
+ }
89
+ .fgt = FGT_CPPRCTX,
130
return 0;
90
.type = ARM_CP_NOP, .access = PL0_W, .accessfn = access_predinv },
131
}
91
};
132
92
133
--
93
--
134
2.20.1
94
2.34.1
135
136
diff view generated by jsdifflib
1
The M-profile FPCCR.S bit indicates the security status of
1
Implement the HFGITR_EL2.ERET fine-grained trap. This traps
2
the floating point context. In the pseudocode ExecuteFPCheck()
2
execution from AArch64 EL1 of ERET, ERETAA and ERETAB. The trap is
3
function it is unconditionally set to match the current
3
reported with a syndrome value of 0x1a.
4
security state whenever a floating point instruction is
5
executed.
6
4
7
Implement this by adding a new TB flag which tracks whether
5
The trap must take precedence over a possible pointer-authentication
8
FPCCR.S is different from the current security state, so
6
trap for ERETAA and ERETAB.
9
that we only need to emit the code to update it in the
10
less-common case when it is not already set correctly.
11
12
Note that we will add the handling for the other work done
13
by ExecuteFPCheck() in later commits.
14
7
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20190416125744.27770-19-peter.maydell@linaro.org
10
Tested-by: Fuad Tabba <tabba@google.com>
11
Message-id: 20230130182459.3309057-21-peter.maydell@linaro.org
12
Message-id: 20230127175507.2895013-21-peter.maydell@linaro.org
18
---
13
---
19
target/arm/cpu.h | 2 ++
14
target/arm/cpu.h | 1 +
20
target/arm/translate.h | 1 +
15
target/arm/syndrome.h | 10 ++++++++++
21
target/arm/helper.c | 5 +++++
16
target/arm/translate.h | 2 ++
22
target/arm/translate.c | 20 ++++++++++++++++++++
17
target/arm/helper.c | 3 +++
23
4 files changed, 28 insertions(+)
18
target/arm/translate-a64.c | 10 ++++++++++
19
5 files changed, 26 insertions(+)
24
20
25
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
26
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
27
--- a/target/arm/cpu.h
23
--- a/target/arm/cpu.h
28
+++ b/target/arm/cpu.h
24
+++ b/target/arm/cpu.h
29
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
25
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A64, PSTATE_ZA, 23, 1)
30
FIELD(TBFLAG_A32, VFPEN, 7, 1)
26
FIELD(TBFLAG_A64, SVL, 24, 4)
31
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
27
/* Indicates that SME Streaming mode is active, and SMCR_ELx.FA64 is not. */
32
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
28
FIELD(TBFLAG_A64, SME_TRAP_NONSTREAMING, 28, 1)
33
+/* For M profile only, set if FPCCR.S does not match current security state */
29
+FIELD(TBFLAG_A64, FGT_ERET, 29, 1)
34
+FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1)
30
35
/* For M profile only, Handler (ie not Thread) mode */
31
/*
36
FIELD(TBFLAG_A32, HANDLER, 21, 1)
32
* Helpers for using the above.
37
/* For M profile only, whether we should generate stack-limit checks */
33
diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h
34
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/syndrome.h
36
+++ b/target/arm/syndrome.h
37
@@ -XXX,XX +XXX,XX @@ enum arm_exception_class {
38
EC_AA64_SMC = 0x17,
39
EC_SYSTEMREGISTERTRAP = 0x18,
40
EC_SVEACCESSTRAP = 0x19,
41
+ EC_ERETTRAP = 0x1a,
42
EC_SMETRAP = 0x1d,
43
EC_INSNABORT = 0x20,
44
EC_INSNABORT_SAME_EL = 0x21,
45
@@ -XXX,XX +XXX,XX @@ static inline uint32_t syn_sve_access_trap(void)
46
return EC_SVEACCESSTRAP << ARM_EL_EC_SHIFT;
47
}
48
49
+/*
50
+ * eret_op is bits [1:0] of the ERET instruction, so:
51
+ * 0 for ERET, 2 for ERETAA, 3 for ERETAB.
52
+ */
53
+static inline uint32_t syn_erettrap(int eret_op)
54
+{
55
+ return (EC_ERETTRAP << ARM_EL_EC_SHIFT) | ARM_EL_IL | eret_op;
56
+}
57
+
58
static inline uint32_t syn_smetrap(SMEExceptionType etype, bool is_16bit)
59
{
60
return (EC_SMETRAP << ARM_EL_EC_SHIFT)
38
diff --git a/target/arm/translate.h b/target/arm/translate.h
61
diff --git a/target/arm/translate.h b/target/arm/translate.h
39
index XXXXXXX..XXXXXXX 100644
62
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/translate.h
63
--- a/target/arm/translate.h
41
+++ b/target/arm/translate.h
64
+++ b/target/arm/translate.h
42
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
65
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
43
bool v7m_handler_mode;
66
bool mve_no_pred;
44
bool v8m_secure; /* true if v8M and we're in Secure mode */
67
/* True if fine-grained traps are active */
45
bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */
68
bool fgt_active;
46
+ bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */
69
+ /* True if fine-grained trap on ERET is enabled */
47
/* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI
70
+ bool fgt_eret;
48
* so that top level loop can generate correct syndrome information.
71
/*
49
*/
72
* >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI.
73
* < 0, set by the current instruction.
50
diff --git a/target/arm/helper.c b/target/arm/helper.c
74
diff --git a/target/arm/helper.c b/target/arm/helper.c
51
index XXXXXXX..XXXXXXX 100644
75
index XXXXXXX..XXXXXXX 100644
52
--- a/target/arm/helper.c
76
--- a/target/arm/helper.c
53
+++ b/target/arm/helper.c
77
+++ b/target/arm/helper.c
54
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
78
@@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
55
flags = FIELD_DP32(flags, TBFLAG_A32, STACKCHECK, 1);
79
80
if (arm_fgt_active(env, el)) {
81
DP_TBFLAG_ANY(flags, FGT_ACTIVE, 1);
82
+ if (FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, ERET)) {
83
+ DP_TBFLAG_A64(flags, FGT_ERET, 1);
84
+ }
56
}
85
}
57
86
58
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY) &&
87
if (cpu_isar_feature(aa64_mte, env_archcpu(env))) {
59
+ FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) {
88
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
60
+ flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1);
61
+ }
62
+
63
*pflags = flags;
64
*cs_base = 0;
65
}
66
diff --git a/target/arm/translate.c b/target/arm/translate.c
67
index XXXXXXX..XXXXXXX 100644
89
index XXXXXXX..XXXXXXX 100644
68
--- a/target/arm/translate.c
90
--- a/target/arm/translate-a64.c
69
+++ b/target/arm/translate.c
91
+++ b/target/arm/translate-a64.c
70
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
92
@@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)
71
}
93
if (op4 != 0) {
72
}
94
goto do_unallocated;
73
95
}
74
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
96
+ if (s->fgt_eret) {
75
+ /* Handle M-profile lazy FP state mechanics */
97
+ gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(op3), 2);
76
+
98
+ return;
77
+ /* Update ownership of FP context: set FPCCR.S to match current state */
78
+ if (s->v8m_fpccr_s_wrong) {
79
+ TCGv_i32 tmp;
80
+
81
+ tmp = load_cpu_field(v7m.fpccr[M_REG_S]);
82
+ if (s->v8m_secure) {
83
+ tcg_gen_ori_i32(tmp, tmp, R_V7M_FPCCR_S_MASK);
84
+ } else {
85
+ tcg_gen_andi_i32(tmp, tmp, ~R_V7M_FPCCR_S_MASK);
86
+ }
99
+ }
87
+ store_cpu_field(tmp, v7m.fpccr[M_REG_S]);
100
dst = tcg_temp_new_i64();
88
+ /* Don't need to do this for any further FP insns in this TB */
101
tcg_gen_ld_i64(dst, cpu_env,
89
+ s->v8m_fpccr_s_wrong = false;
102
offsetof(CPUARMState, elr_el[s->current_el]));
90
+ }
103
@@ -XXX,XX +XXX,XX @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)
91
+ }
104
if (rn != 0x1f || op4 != 0x1f) {
92
+
105
goto do_unallocated;
93
if (extract32(insn, 28, 4) == 0xf) {
106
}
94
/*
107
+ /* The FGT trap takes precedence over an auth trap. */
95
* Encodings with T=1 (Thumb) or unconditional (ARM):
108
+ if (s->fgt_eret) {
96
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
109
+ gen_exception_insn_el(s, 0, EXCP_UDEF, syn_erettrap(op3), 2);
97
dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) &&
110
+ return;
98
regime_is_secure(env, dc->mmu_idx);
111
+ }
99
dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK);
112
dst = tcg_temp_new_i64();
100
+ dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG);
113
tcg_gen_ld_i64(dst, cpu_env,
101
dc->cp_regs = cpu->cp_regs;
114
offsetof(CPUARMState, elr_el[s->current_el]));
102
dc->features = env->features;
115
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase,
103
116
dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM);
117
dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL);
118
dc->fgt_active = EX_TBFLAG_ANY(tb_flags, FGT_ACTIVE);
119
+ dc->fgt_eret = EX_TBFLAG_A64(tb_flags, FGT_ERET);
120
dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL);
121
dc->sme_excp_el = EX_TBFLAG_A64(tb_flags, SMEEXC_EL);
122
dc->vl = (EX_TBFLAG_A64(tb_flags, VL) + 1) * 16;
104
--
123
--
105
2.20.1
124
2.34.1
106
107
diff view generated by jsdifflib
1
The M-profile FPCCR.ASPEN bit indicates that automatic floating-point
1
Implement the HFGITR_EL2.SVC_EL0 and SVC_EL1 fine-grained traps.
2
context preservation is enabled. Before executing any floating-point
2
These trap execution of the SVC instruction from AArch32 and AArch64.
3
instruction, if FPCCR.ASPEN is set and the CONTROL FPCA/SFPA bits
3
(As usual, AArch32 can only trap from EL0, as fine grained traps are
4
indicate that there is no active floating point context then we
4
disabled with an AArch32 EL1.)
5
must create a new context (by initializing FPSCR and setting
6
FPCA/SFPA to indicate that the context is now active). In the
7
pseudocode this is handled by ExecuteFPCheck().
8
9
Implement this with a new TB flag which tracks whether we
10
need to create a new FP context.
11
5
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20190416125744.27770-20-peter.maydell@linaro.org
8
Tested-by: Fuad Tabba <tabba@google.com>
9
Message-id: 20230130182459.3309057-22-peter.maydell@linaro.org
10
Message-id: 20230127175507.2895013-22-peter.maydell@linaro.org
15
---
11
---
16
target/arm/cpu.h | 2 ++
12
target/arm/cpu.h | 1 +
17
target/arm/translate.h | 1 +
13
target/arm/translate.h | 2 ++
18
target/arm/helper.c | 13 +++++++++++++
14
target/arm/helper.c | 20 ++++++++++++++++++++
19
target/arm/translate.c | 29 +++++++++++++++++++++++++++++
15
target/arm/translate-a64.c | 9 ++++++++-
20
4 files changed, 45 insertions(+)
16
target/arm/translate.c | 12 +++++++++---
17
5 files changed, 40 insertions(+), 4 deletions(-)
21
18
22
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
19
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
23
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/cpu.h
21
--- a/target/arm/cpu.h
25
+++ b/target/arm/cpu.h
22
+++ b/target/arm/cpu.h
26
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
23
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, FPEXC_EL, 8, 2)
27
FIELD(TBFLAG_A32, VFPEN, 7, 1)
24
FIELD(TBFLAG_ANY, ALIGN_MEM, 10, 1)
28
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
25
FIELD(TBFLAG_ANY, PSTATE__IL, 11, 1)
29
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
26
FIELD(TBFLAG_ANY, FGT_ACTIVE, 12, 1)
30
+/* For M profile only, set if we must create a new FP context */
27
+FIELD(TBFLAG_ANY, FGT_SVC, 13, 1)
31
+FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1)
28
32
/* For M profile only, set if FPCCR.S does not match current security state */
29
/*
33
FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1)
30
* Bit usage when in AArch32 state, both A- and M-profile.
34
/* For M profile only, Handler (ie not Thread) mode */
35
diff --git a/target/arm/translate.h b/target/arm/translate.h
31
diff --git a/target/arm/translate.h b/target/arm/translate.h
36
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/translate.h
33
--- a/target/arm/translate.h
38
+++ b/target/arm/translate.h
34
+++ b/target/arm/translate.h
39
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
35
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
40
bool v8m_secure; /* true if v8M and we're in Secure mode */
36
bool fgt_active;
41
bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */
37
/* True if fine-grained trap on ERET is enabled */
42
bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */
38
bool fgt_eret;
43
+ bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */
39
+ /* True if fine-grained trap on SVC is enabled */
44
/* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI
40
+ bool fgt_svc;
45
* so that top level loop can generate correct syndrome information.
41
/*
46
*/
42
* >= 0, a copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI.
43
* < 0, set by the current instruction.
47
diff --git a/target/arm/helper.c b/target/arm/helper.c
44
diff --git a/target/arm/helper.c b/target/arm/helper.c
48
index XXXXXXX..XXXXXXX 100644
45
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/helper.c
46
--- a/target/arm/helper.c
50
+++ b/target/arm/helper.c
47
+++ b/target/arm/helper.c
51
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
48
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_mmu_idx(CPUARMState *env)
52
flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1);
49
return arm_mmu_idx_el(env, arm_current_el(env));
50
}
51
52
+static inline bool fgt_svc(CPUARMState *env, int el)
53
+{
54
+ /*
55
+ * Assuming fine-grained-traps are active, return true if we
56
+ * should be trapping on SVC instructions. Only AArch64 can
57
+ * trap on an SVC at EL1, but we don't need to special-case this
58
+ * because if this is AArch32 EL1 then arm_fgt_active() is false.
59
+ * We also know el is 0 or 1.
60
+ */
61
+ return el == 0 ?
62
+ FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, SVC_EL0) :
63
+ FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, SVC_EL1);
64
+}
65
+
66
static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el,
67
ARMMMUIdx mmu_idx,
68
CPUARMTBFlags flags)
69
@@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el,
70
71
if (arm_fgt_active(env, el)) {
72
DP_TBFLAG_ANY(flags, FGT_ACTIVE, 1);
73
+ if (fgt_svc(env, el)) {
74
+ DP_TBFLAG_ANY(flags, FGT_SVC, 1);
75
+ }
53
}
76
}
54
77
55
+ if (arm_feature(env, ARM_FEATURE_M) &&
78
if (env->uncached_cpsr & CPSR_IL) {
56
+ (env->v7m.fpccr[env->v7m.secure] & R_V7M_FPCCR_ASPEN_MASK) &&
79
@@ -XXX,XX +XXX,XX @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
57
+ (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) ||
80
if (FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, ERET)) {
58
+ (env->v7m.secure &&
81
DP_TBFLAG_A64(flags, FGT_ERET, 1);
59
+ !(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)))) {
82
}
60
+ /*
83
+ if (fgt_svc(env, el)) {
61
+ * ASPEN is set, but FPCA/SFPA indicate that there is no active
84
+ DP_TBFLAG_ANY(flags, FGT_SVC, 1);
62
+ * FP context; we must create a new FP context before executing
85
+ }
63
+ * any FP insn.
86
}
64
+ */
87
65
+ flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1);
88
if (cpu_isar_feature(aa64_mte, env_archcpu(env))) {
66
+ }
89
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
67
+
90
index XXXXXXX..XXXXXXX 100644
68
*pflags = flags;
91
--- a/target/arm/translate-a64.c
69
*cs_base = 0;
92
+++ b/target/arm/translate-a64.c
70
}
93
@@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn)
94
int opc = extract32(insn, 21, 3);
95
int op2_ll = extract32(insn, 0, 5);
96
int imm16 = extract32(insn, 5, 16);
97
+ uint32_t syndrome;
98
99
switch (opc) {
100
case 0:
101
@@ -XXX,XX +XXX,XX @@ static void disas_exc(DisasContext *s, uint32_t insn)
102
*/
103
switch (op2_ll) {
104
case 1: /* SVC */
105
+ syndrome = syn_aa64_svc(imm16);
106
+ if (s->fgt_svc) {
107
+ gen_exception_insn_el(s, 0, EXCP_UDEF, syndrome, 2);
108
+ break;
109
+ }
110
gen_ss_advance(s);
111
- gen_exception_insn(s, 4, EXCP_SWI, syn_aa64_svc(imm16));
112
+ gen_exception_insn(s, 4, EXCP_SWI, syndrome);
113
break;
114
case 2: /* HVC */
115
if (s->current_el == 0) {
116
@@ -XXX,XX +XXX,XX @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase,
117
dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM);
118
dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL);
119
dc->fgt_active = EX_TBFLAG_ANY(tb_flags, FGT_ACTIVE);
120
+ dc->fgt_svc = EX_TBFLAG_ANY(tb_flags, FGT_SVC);
121
dc->fgt_eret = EX_TBFLAG_A64(tb_flags, FGT_ERET);
122
dc->sve_excp_el = EX_TBFLAG_A64(tb_flags, SVEEXC_EL);
123
dc->sme_excp_el = EX_TBFLAG_A64(tb_flags, SMEEXC_EL);
71
diff --git a/target/arm/translate.c b/target/arm/translate.c
124
diff --git a/target/arm/translate.c b/target/arm/translate.c
72
index XXXXXXX..XXXXXXX 100644
125
index XXXXXXX..XXXXXXX 100644
73
--- a/target/arm/translate.c
126
--- a/target/arm/translate.c
74
+++ b/target/arm/translate.c
127
+++ b/target/arm/translate.c
75
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
128
@@ -XXX,XX +XXX,XX @@ static bool trans_SVC(DisasContext *s, arg_SVC *a)
76
/* Don't need to do this for any further FP insns in this TB */
129
(a->imm == semihost_imm)) {
77
s->v8m_fpccr_s_wrong = false;
130
gen_exception_internal_insn(s, EXCP_SEMIHOST);
78
}
131
} else {
79
+
132
- gen_update_pc(s, curr_insn_len(s));
80
+ if (s->v7m_new_fp_ctxt_needed) {
133
- s->svc_imm = a->imm;
81
+ /*
134
- s->base.is_jmp = DISAS_SWI;
82
+ * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA
135
+ if (s->fgt_svc) {
83
+ * and the FPSCR.
136
+ uint32_t syndrome = syn_aa32_svc(a->imm, s->thumb);
84
+ */
137
+ gen_exception_insn_el(s, 0, EXCP_UDEF, syndrome, 2);
85
+ TCGv_i32 control, fpscr;
138
+ } else {
86
+ uint32_t bits = R_V7M_CONTROL_FPCA_MASK;
139
+ gen_update_pc(s, curr_insn_len(s));
87
+
140
+ s->svc_imm = a->imm;
88
+ fpscr = load_cpu_field(v7m.fpdscr[s->v8m_secure]);
141
+ s->base.is_jmp = DISAS_SWI;
89
+ gen_helper_vfp_set_fpscr(cpu_env, fpscr);
90
+ tcg_temp_free_i32(fpscr);
91
+ /*
92
+ * We don't need to arrange to end the TB, because the only
93
+ * parts of FPSCR which we cache in the TB flags are the VECLEN
94
+ * and VECSTRIDE, and those don't exist for M-profile.
95
+ */
96
+
97
+ if (s->v8m_secure) {
98
+ bits |= R_V7M_CONTROL_SFPA_MASK;
99
+ }
100
+ control = load_cpu_field(v7m.control[M_REG_S]);
101
+ tcg_gen_ori_i32(control, control, bits);
102
+ store_cpu_field(control, v7m.control[M_REG_S]);
103
+ /* Don't need to do this for any further FP insns in this TB */
104
+ s->v7m_new_fp_ctxt_needed = false;
105
+ }
142
+ }
106
}
143
}
107
144
return true;
108
if (extract32(insn, 28, 4) == 0xf) {
145
}
109
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
146
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
110
regime_is_secure(env, dc->mmu_idx);
147
dc->align_mem = EX_TBFLAG_ANY(tb_flags, ALIGN_MEM);
111
dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK);
148
dc->pstate_il = EX_TBFLAG_ANY(tb_flags, PSTATE__IL);
112
dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG);
149
dc->fgt_active = EX_TBFLAG_ANY(tb_flags, FGT_ACTIVE);
113
+ dc->v7m_new_fp_ctxt_needed =
150
+ dc->fgt_svc = EX_TBFLAG_ANY(tb_flags, FGT_SVC);
114
+ FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED);
151
115
dc->cp_regs = cpu->cp_regs;
152
if (arm_feature(env, ARM_FEATURE_M)) {
116
dc->features = env->features;
153
dc->vfp_enabled = 1;
117
118
--
154
--
119
2.20.1
155
2.34.1
120
121
diff view generated by jsdifflib
1
Add a new helper function which returns the MMU index to use
1
FEAT_FGT also implements an extra trap bit in the MDCR_EL2 and
2
for v7M, where the caller specifies all of the security
2
MDCR_EL3 registers: bit TDCC enables trapping of use of the Debug
3
state, privilege level and whether the execution priority
3
Comms Channel registers OSDTRRX_EL1, OSDTRTX_EL1, MDCCSR_EL0,
4
is negative, and reimplement the existing
4
MDCCINT_EL0, DBGDTR_EL0, DBGDTRRX_EL0 and DBGDTRTX_EL0 (and their
5
arm_v7m_mmu_idx_for_secstate_and_priv() in terms of it.
5
AArch32 equivalents). This trapping is independent of whether
6
fine-grained traps are enabled or not.
6
7
7
We are going to need this for the lazy-FP-stacking code.
8
Implement these extra traps. (We don't implement DBGDTR_EL0,
9
DBGDTRRX_EL0 and DBGDTRTX_EL0.)
8
10
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20190416125744.27770-21-peter.maydell@linaro.org
13
Tested-by: Fuad Tabba <tabba@google.com>
14
Message-id: 20230130182459.3309057-23-peter.maydell@linaro.org
15
Message-id: 20230127175507.2895013-23-peter.maydell@linaro.org
12
---
16
---
13
target/arm/cpu.h | 7 +++++++
17
target/arm/debug_helper.c | 35 +++++++++++++++++++++++++++++++----
14
target/arm/helper.c | 14 +++++++++++---
18
1 file changed, 31 insertions(+), 4 deletions(-)
15
2 files changed, 18 insertions(+), 3 deletions(-)
16
19
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
20
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
18
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
22
--- a/target/arm/debug_helper.c
20
+++ b/target/arm/cpu.h
23
+++ b/target/arm/debug_helper.c
21
@@ -XXX,XX +XXX,XX @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
24
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tda(CPUARMState *env, const ARMCPRegInfo *ri,
22
}
25
return CP_ACCESS_OK;
23
}
26
}
24
27
25
+/*
28
+/*
26
+ * Return the MMU index for a v7M CPU with all relevant information
29
+ * Check for traps to Debug Comms Channel registers. If FEAT_FGT
27
+ * manually specified.
30
+ * is implemented then these are controlled by MDCR_EL2.TDCC for
31
+ * EL2 and MDCR_EL3.TDCC for EL3. They are also controlled by
32
+ * the general debug access trap bits MDCR_EL2.TDA and MDCR_EL3.TDA.
28
+ */
33
+ */
29
+ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
34
+static CPAccessResult access_tdcc(CPUARMState *env, const ARMCPRegInfo *ri,
30
+ bool secstate, bool priv, bool negpri);
35
+ bool isread)
36
+{
37
+ int el = arm_current_el(env);
38
+ uint64_t mdcr_el2 = arm_mdcr_el2_eff(env);
39
+ bool mdcr_el2_tda = (mdcr_el2 & MDCR_TDA) || (mdcr_el2 & MDCR_TDE) ||
40
+ (arm_hcr_el2_eff(env) & HCR_TGE);
41
+ bool mdcr_el2_tdcc = cpu_isar_feature(aa64_fgt, env_archcpu(env)) &&
42
+ (mdcr_el2 & MDCR_TDCC);
43
+ bool mdcr_el3_tdcc = cpu_isar_feature(aa64_fgt, env_archcpu(env)) &&
44
+ (env->cp15.mdcr_el3 & MDCR_TDCC);
31
+
45
+
32
/* Return the MMU index for a v7M CPU in the specified security and
46
+ if (el < 2 && (mdcr_el2_tda || mdcr_el2_tdcc)) {
33
* privilege state.
47
+ return CP_ACCESS_TRAP_EL2;
34
*/
48
+ }
35
diff --git a/target/arm/helper.c b/target/arm/helper.c
49
+ if (el < 3 && ((env->cp15.mdcr_el3 & MDCR_TDA) || mdcr_el3_tdcc)) {
36
index XXXXXXX..XXXXXXX 100644
50
+ return CP_ACCESS_TRAP_EL3;
37
--- a/target/arm/helper.c
51
+ }
38
+++ b/target/arm/helper.c
52
+ return CP_ACCESS_OK;
39
@@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el)
40
return 0;
41
}
42
43
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
44
- bool secstate, bool priv)
45
+ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
46
+ bool secstate, bool priv, bool negpri)
47
{
48
ARMMMUIdx mmu_idx = ARM_MMU_IDX_M;
49
50
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
51
mmu_idx |= ARM_MMU_IDX_M_PRIV;
52
}
53
54
- if (armv7m_nvic_neg_prio_requested(env->nvic, secstate)) {
55
+ if (negpri) {
56
mmu_idx |= ARM_MMU_IDX_M_NEGPRI;
57
}
58
59
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
60
return mmu_idx;
61
}
62
63
+ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
64
+ bool secstate, bool priv)
65
+{
66
+ bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate);
67
+
68
+ return arm_v7m_mmu_idx_all(env, secstate, priv, negpri);
69
+}
53
+}
70
+
54
+
71
/* Return the MMU index for a v7M CPU in the specified security state */
55
static void oslar_write(CPUARMState *env, const ARMCPRegInfo *ri,
72
ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
56
uint64_t value)
73
{
57
{
58
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
59
*/
60
{ .name = "MDCCSR_EL0", .state = ARM_CP_STATE_AA64,
61
.opc0 = 2, .opc1 = 3, .crn = 0, .crm = 1, .opc2 = 0,
62
- .access = PL0_R, .accessfn = access_tda,
63
+ .access = PL0_R, .accessfn = access_tdcc,
64
.type = ARM_CP_CONST, .resetvalue = 0 },
65
/*
66
* OSDTRRX_EL1/OSDTRTX_EL1 are used for save and restore of DBGDTRRX_EL0.
67
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
68
*/
69
{ .name = "OSDTRRX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14,
70
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 2,
71
- .access = PL1_RW, .accessfn = access_tda,
72
+ .access = PL1_RW, .accessfn = access_tdcc,
73
.type = ARM_CP_CONST, .resetvalue = 0 },
74
{ .name = "OSDTRTX_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14,
75
.opc0 = 2, .opc1 = 0, .crn = 0, .crm = 3, .opc2 = 2,
76
- .access = PL1_RW, .accessfn = access_tda,
77
+ .access = PL1_RW, .accessfn = access_tdcc,
78
.type = ARM_CP_CONST, .resetvalue = 0 },
79
/*
80
* OSECCR_EL1 provides a mechanism for an operating system
81
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
82
*/
83
{ .name = "MDCCINT_EL1", .state = ARM_CP_STATE_BOTH,
84
.cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 0,
85
- .access = PL1_RW, .accessfn = access_tda,
86
+ .access = PL1_RW, .accessfn = access_tdcc,
87
.type = ARM_CP_NOP },
88
/*
89
* Dummy DBGCLAIM registers.
74
--
90
--
75
2.20.1
91
2.34.1
76
77
diff view generated by jsdifflib
1
Move the NS TBFLAG down from bit 19 to bit 6, which has not
1
Update the ID registers for TCG's '-cpu max' to report the
2
been used since commit c1e3781090b9d36c60 in 2015, when we
2
presence of FEAT_FGT Fine-Grained Traps support.
3
started passing the entire MMU index in the TB flags rather
4
than just a 'privilege level' bit.
5
6
This rearrangement is not strictly necessary, but means that
7
we can put M-profile-only bits next to each other rather
8
than scattered across the flag word.
9
3
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20190416125744.27770-17-peter.maydell@linaro.org
6
Tested-by: Fuad Tabba <tabba@google.com>
7
Message-id: 20230130182459.3309057-24-peter.maydell@linaro.org
8
Message-id: 20230127175507.2895013-24-peter.maydell@linaro.org
13
---
9
---
14
target/arm/cpu.h | 11 ++++++-----
10
docs/system/arm/emulation.rst | 1 +
15
1 file changed, 6 insertions(+), 5 deletions(-)
11
target/arm/cpu64.c | 1 +
12
2 files changed, 2 insertions(+)
16
13
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst
18
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
16
--- a/docs/system/arm/emulation.rst
20
+++ b/target/arm/cpu.h
17
+++ b/docs/system/arm/emulation.rst
21
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1)
18
@@ -XXX,XX +XXX,XX @@ the following architecture extensions:
22
FIELD(TBFLAG_A32, THUMB, 0, 1)
19
- FEAT_ETS (Enhanced Translation Synchronization)
23
FIELD(TBFLAG_A32, VECLEN, 1, 3)
20
- FEAT_EVT (Enhanced Virtualization Traps)
24
FIELD(TBFLAG_A32, VECSTRIDE, 4, 2)
21
- FEAT_FCMA (Floating-point complex number instructions)
25
+/*
22
+- FEAT_FGT (Fine-Grained Traps)
26
+ * Indicates whether cp register reads and writes by guest code should access
23
- FEAT_FHM (Floating-point half-precision multiplication instructions)
27
+ * the secure or nonsecure bank of banked registers; note that this is not
24
- FEAT_FP16 (Half-precision floating-point data processing)
28
+ * the same thing as the current security state of the processor!
25
- FEAT_FRINTTS (Floating-point to integer instructions)
29
+ */
26
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
30
+FIELD(TBFLAG_A32, NS, 6, 1)
27
index XXXXXXX..XXXXXXX 100644
31
FIELD(TBFLAG_A32, VFPEN, 7, 1)
28
--- a/target/arm/cpu64.c
32
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
29
+++ b/target/arm/cpu64.c
33
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
30
@@ -XXX,XX +XXX,XX @@ static void aarch64_max_initfn(Object *obj)
34
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
31
t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN16_2, 2); /* 16k stage2 supported */
35
* checks on the other bits at runtime
32
t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN64_2, 2); /* 64k stage2 supported */
36
*/
33
t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 2); /* 4k stage2 supported */
37
FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2)
34
+ t = FIELD_DP64(t, ID_AA64MMFR0, FGT, 1); /* FEAT_FGT */
38
-/* Indicates whether cp register reads and writes by guest code should access
35
cpu->isar.id_aa64mmfr0 = t;
39
- * the secure or nonsecure bank of banked registers; note that this is not
36
40
- * the same thing as the current security state of the processor!
37
t = cpu->isar.id_aa64mmfr1;
41
- */
42
-FIELD(TBFLAG_A32, NS, 19, 1)
43
/* For M profile only, Handler (ie not Thread) mode */
44
FIELD(TBFLAG_A32, HANDLER, 21, 1)
45
/* For M profile only, whether we should generate stack-limit checks */
46
--
38
--
47
2.20.1
39
2.34.1
48
49
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Reviewed-by: Thomas Huth <thuth@redhat.com>
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
5
Reviewed-by: Markus Armbruster <armbru@redhat.com>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Message-id: 20190412165416.7977-2-philmd@redhat.com
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
hw/arm/aspeed.c | 13 +++++++++----
11
1 file changed, 9 insertions(+), 4 deletions(-)
12
13
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/aspeed.c
16
+++ b/hw/arm/aspeed.c
17
@@ -XXX,XX +XXX,XX @@
18
#include "hw/arm/aspeed_soc.h"
19
#include "hw/boards.h"
20
#include "hw/i2c/smbus_eeprom.h"
21
+#include "hw/misc/pca9552.h"
22
+#include "hw/misc/tmp105.h"
23
#include "qemu/log.h"
24
#include "sysemu/block-backend.h"
25
#include "hw/loader.h"
26
@@ -XXX,XX +XXX,XX @@ static void ast2500_evb_i2c_init(AspeedBoardState *bmc)
27
eeprom_buf);
28
29
/* The AST2500 EVB expects a LM75 but a TMP105 is compatible */
30
- i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7), "tmp105", 0x4d);
31
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 7),
32
+ TYPE_TMP105, 0x4d);
33
34
/* The AST2500 EVB does not have an RTC. Let's pretend that one is
35
* plugged on the I2C bus header */
36
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
37
AspeedSoCState *soc = &bmc->soc;
38
uint8_t *eeprom_buf = g_malloc0(8 * 1024);
39
40
- i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), "pca9552", 0x60);
41
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 3), TYPE_PCA9552,
42
+ 0x60);
43
44
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 4), "tmp423", 0x4c);
45
i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 5), "tmp423", 0x4c);
46
47
/* The Witherspoon expects a TMP275 but a TMP105 is compatible */
48
- i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), "tmp105", 0x4a);
49
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 9), TYPE_TMP105,
50
+ 0x4a);
51
52
/* The witherspoon board expects Epson RX8900 I2C RTC but a ds1338 is
53
* good enough */
54
@@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedBoardState *bmc)
55
56
smbus_eeprom_init_one(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), 0x51,
57
eeprom_buf);
58
- i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), "pca9552",
59
+ i2c_create_slave(aspeed_i2c_get_bus(DEVICE(&soc->i2c), 11), TYPE_PCA9552,
60
0x60);
61
}
62
63
--
64
2.20.1
65
66
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Message-id: 20190412165416.7977-5-philmd@redhat.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
include/hw/devices.h | 6 ------
9
include/hw/display/tc6393xb.h | 24 ++++++++++++++++++++++++
10
hw/arm/tosa.c | 2 +-
11
hw/display/tc6393xb.c | 2 +-
12
MAINTAINERS | 1 +
13
5 files changed, 27 insertions(+), 8 deletions(-)
14
create mode 100644 include/hw/display/tc6393xb.h
15
16
diff --git a/include/hw/devices.h b/include/hw/devices.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/devices.h
19
+++ b/include/hw/devices.h
20
@@ -XXX,XX +XXX,XX @@ void *tahvo_init(qemu_irq irq, int betty);
21
22
void retu_key_event(void *retu, int state);
23
24
-/* tc6393xb.c */
25
-typedef struct TC6393xbState TC6393xbState;
26
-TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
27
- uint32_t base, qemu_irq irq);
28
-qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
29
-
30
#endif
31
diff --git a/include/hw/display/tc6393xb.h b/include/hw/display/tc6393xb.h
32
new file mode 100644
33
index XXXXXXX..XXXXXXX
34
--- /dev/null
35
+++ b/include/hw/display/tc6393xb.h
36
@@ -XXX,XX +XXX,XX @@
37
+/*
38
+ * Toshiba TC6393XB I/O Controller.
39
+ * Found in Sharp Zaurus SL-6000 (tosa) or some
40
+ * Toshiba e-Series PDAs.
41
+ *
42
+ * Copyright (c) 2007 Hervé Poussineau
43
+ *
44
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
45
+ * See the COPYING file in the top-level directory.
46
+ */
47
+
48
+#ifndef HW_DISPLAY_TC6393XB_H
49
+#define HW_DISPLAY_TC6393XB_H
50
+
51
+#include "exec/memory.h"
52
+#include "hw/irq.h"
53
+
54
+typedef struct TC6393xbState TC6393xbState;
55
+
56
+TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
57
+ uint32_t base, qemu_irq irq);
58
+qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
59
+
60
+#endif
61
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
62
index XXXXXXX..XXXXXXX 100644
63
--- a/hw/arm/tosa.c
64
+++ b/hw/arm/tosa.c
65
@@ -XXX,XX +XXX,XX @@
66
#include "hw/hw.h"
67
#include "hw/arm/pxa.h"
68
#include "hw/arm/arm.h"
69
-#include "hw/devices.h"
70
#include "hw/arm/sharpsl.h"
71
#include "hw/pcmcia.h"
72
#include "hw/boards.h"
73
+#include "hw/display/tc6393xb.h"
74
#include "hw/i2c/i2c.h"
75
#include "hw/ssi/ssi.h"
76
#include "hw/sysbus.h"
77
diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/hw/display/tc6393xb.c
80
+++ b/hw/display/tc6393xb.c
81
@@ -XXX,XX +XXX,XX @@
82
#include "qapi/error.h"
83
#include "qemu/host-utils.h"
84
#include "hw/hw.h"
85
-#include "hw/devices.h"
86
+#include "hw/display/tc6393xb.h"
87
#include "hw/block/flash.h"
88
#include "ui/console.h"
89
#include "ui/pixel_ops.h"
90
diff --git a/MAINTAINERS b/MAINTAINERS
91
index XXXXXXX..XXXXXXX 100644
92
--- a/MAINTAINERS
93
+++ b/MAINTAINERS
94
@@ -XXX,XX +XXX,XX @@ F: hw/misc/mst_fpga.c
95
F: hw/misc/max111x.c
96
F: include/hw/arm/pxa.h
97
F: include/hw/arm/sharpsl.h
98
+F: include/hw/display/tc6393xb.h
99
100
SABRELITE / i.MX6
101
M: Peter Maydell <peter.maydell@linaro.org>
102
--
103
2.20.1
104
105
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Add an entries the Blizzard device in MAINTAINERS.
4
5
Reviewed-by: Thomas Huth <thuth@redhat.com>
6
Reviewed-by: Markus Armbruster <armbru@redhat.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Message-id: 20190412165416.7977-6-philmd@redhat.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
include/hw/devices.h | 7 -------
12
include/hw/display/blizzard.h | 22 ++++++++++++++++++++++
13
hw/arm/nseries.c | 1 +
14
hw/display/blizzard.c | 2 +-
15
MAINTAINERS | 2 ++
16
5 files changed, 26 insertions(+), 8 deletions(-)
17
create mode 100644 include/hw/display/blizzard.h
18
19
diff --git a/include/hw/devices.h b/include/hw/devices.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/include/hw/devices.h
22
+++ b/include/hw/devices.h
23
@@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
24
/* stellaris_input.c */
25
void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
26
27
-/* blizzard.c */
28
-void *s1d13745_init(qemu_irq gpio_int);
29
-void s1d13745_write(void *opaque, int dc, uint16_t value);
30
-void s1d13745_write_block(void *opaque, int dc,
31
- void *buf, size_t len, int pitch);
32
-uint16_t s1d13745_read(void *opaque, int dc);
33
-
34
/* cbus.c */
35
typedef struct {
36
qemu_irq clk;
37
diff --git a/include/hw/display/blizzard.h b/include/hw/display/blizzard.h
38
new file mode 100644
39
index XXXXXXX..XXXXXXX
40
--- /dev/null
41
+++ b/include/hw/display/blizzard.h
42
@@ -XXX,XX +XXX,XX @@
43
+/*
44
+ * Epson S1D13744/S1D13745 (Blizzard/Hailstorm/Tornado) LCD/TV controller.
45
+ *
46
+ * Copyright (C) 2008 Nokia Corporation
47
+ * Written by Andrzej Zaborowski
48
+ *
49
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
50
+ * See the COPYING file in the top-level directory.
51
+ */
52
+
53
+#ifndef HW_DISPLAY_BLIZZARD_H
54
+#define HW_DISPLAY_BLIZZARD_H
55
+
56
+#include "hw/irq.h"
57
+
58
+void *s1d13745_init(qemu_irq gpio_int);
59
+void s1d13745_write(void *opaque, int dc, uint16_t value);
60
+void s1d13745_write_block(void *opaque, int dc,
61
+ void *buf, size_t len, int pitch);
62
+uint16_t s1d13745_read(void *opaque, int dc);
63
+
64
+#endif
65
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
66
index XXXXXXX..XXXXXXX 100644
67
--- a/hw/arm/nseries.c
68
+++ b/hw/arm/nseries.c
69
@@ -XXX,XX +XXX,XX @@
70
#include "hw/boards.h"
71
#include "hw/i2c/i2c.h"
72
#include "hw/devices.h"
73
+#include "hw/display/blizzard.h"
74
#include "hw/misc/tmp105.h"
75
#include "hw/block/flash.h"
76
#include "hw/hw.h"
77
diff --git a/hw/display/blizzard.c b/hw/display/blizzard.c
78
index XXXXXXX..XXXXXXX 100644
79
--- a/hw/display/blizzard.c
80
+++ b/hw/display/blizzard.c
81
@@ -XXX,XX +XXX,XX @@
82
#include "qemu/osdep.h"
83
#include "qemu-common.h"
84
#include "ui/console.h"
85
-#include "hw/devices.h"
86
+#include "hw/display/blizzard.h"
87
#include "ui/pixel_ops.h"
88
89
typedef void (*blizzard_fn_t)(uint8_t *, const uint8_t *, unsigned int);
90
diff --git a/MAINTAINERS b/MAINTAINERS
91
index XXXXXXX..XXXXXXX 100644
92
--- a/MAINTAINERS
93
+++ b/MAINTAINERS
94
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
95
L: qemu-arm@nongnu.org
96
S: Odd Fixes
97
F: hw/arm/nseries.c
98
+F: hw/display/blizzard.c
99
F: hw/input/lm832x.c
100
F: hw/input/tsc2005.c
101
F: hw/misc/cbus.c
102
F: hw/timer/twl92230.c
103
+F: include/hw/display/blizzard.h
104
105
Palm
106
M: Andrzej Zaborowski <balrogg@gmail.com>
107
--
108
2.20.1
109
110
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Reviewed-by: Thomas Huth <thuth@redhat.com>
4
Reviewed-by: Markus Armbruster <armbru@redhat.com>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
Message-id: 20190412165416.7977-7-philmd@redhat.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
include/hw/devices.h | 14 --------------
10
include/hw/misc/cbus.h | 32 ++++++++++++++++++++++++++++++++
11
hw/arm/nseries.c | 1 +
12
hw/misc/cbus.c | 2 +-
13
MAINTAINERS | 1 +
14
5 files changed, 35 insertions(+), 15 deletions(-)
15
create mode 100644 include/hw/misc/cbus.h
16
17
diff --git a/include/hw/devices.h b/include/hw/devices.h
18
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/devices.h
20
+++ b/include/hw/devices.h
21
@@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
22
/* stellaris_input.c */
23
void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
24
25
-/* cbus.c */
26
-typedef struct {
27
- qemu_irq clk;
28
- qemu_irq dat;
29
- qemu_irq sel;
30
-} CBus;
31
-CBus *cbus_init(qemu_irq dat_out);
32
-void cbus_attach(CBus *bus, void *slave_opaque);
33
-
34
-void *retu_init(qemu_irq irq, int vilma);
35
-void *tahvo_init(qemu_irq irq, int betty);
36
-
37
-void retu_key_event(void *retu, int state);
38
-
39
#endif
40
diff --git a/include/hw/misc/cbus.h b/include/hw/misc/cbus.h
41
new file mode 100644
42
index XXXXXXX..XXXXXXX
43
--- /dev/null
44
+++ b/include/hw/misc/cbus.h
45
@@ -XXX,XX +XXX,XX @@
46
+/*
47
+ * CBUS three-pin bus and the Retu / Betty / Tahvo / Vilma / Avilma /
48
+ * Hinku / Vinku / Ahne / Pihi chips used in various Nokia platforms.
49
+ * Based on reverse-engineering of a linux driver.
50
+ *
51
+ * Copyright (C) 2008 Nokia Corporation
52
+ * Written by Andrzej Zaborowski
53
+ *
54
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
55
+ * See the COPYING file in the top-level directory.
56
+ */
57
+
58
+#ifndef HW_MISC_CBUS_H
59
+#define HW_MISC_CBUS_H
60
+
61
+#include "hw/irq.h"
62
+
63
+typedef struct {
64
+ qemu_irq clk;
65
+ qemu_irq dat;
66
+ qemu_irq sel;
67
+} CBus;
68
+
69
+CBus *cbus_init(qemu_irq dat_out);
70
+void cbus_attach(CBus *bus, void *slave_opaque);
71
+
72
+void *retu_init(qemu_irq irq, int vilma);
73
+void *tahvo_init(qemu_irq irq, int betty);
74
+
75
+void retu_key_event(void *retu, int state);
76
+
77
+#endif
78
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
79
index XXXXXXX..XXXXXXX 100644
80
--- a/hw/arm/nseries.c
81
+++ b/hw/arm/nseries.c
82
@@ -XXX,XX +XXX,XX @@
83
#include "hw/i2c/i2c.h"
84
#include "hw/devices.h"
85
#include "hw/display/blizzard.h"
86
+#include "hw/misc/cbus.h"
87
#include "hw/misc/tmp105.h"
88
#include "hw/block/flash.h"
89
#include "hw/hw.h"
90
diff --git a/hw/misc/cbus.c b/hw/misc/cbus.c
91
index XXXXXXX..XXXXXXX 100644
92
--- a/hw/misc/cbus.c
93
+++ b/hw/misc/cbus.c
94
@@ -XXX,XX +XXX,XX @@
95
#include "qemu/osdep.h"
96
#include "hw/hw.h"
97
#include "hw/irq.h"
98
-#include "hw/devices.h"
99
+#include "hw/misc/cbus.h"
100
#include "sysemu/sysemu.h"
101
102
//#define DEBUG
103
diff --git a/MAINTAINERS b/MAINTAINERS
104
index XXXXXXX..XXXXXXX 100644
105
--- a/MAINTAINERS
106
+++ b/MAINTAINERS
107
@@ -XXX,XX +XXX,XX @@ F: hw/input/tsc2005.c
108
F: hw/misc/cbus.c
109
F: hw/timer/twl92230.c
110
F: include/hw/display/blizzard.h
111
+F: include/hw/misc/cbus.h
112
113
Palm
114
M: Andrzej Zaborowski <balrogg@gmail.com>
115
--
116
2.20.1
117
118
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
Message-id: 20190412165416.7977-8-philmd@redhat.com
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
8
include/hw/devices.h | 3 ---
9
include/hw/input/gamepad.h | 19 +++++++++++++++++++
10
hw/arm/stellaris.c | 2 +-
11
hw/input/stellaris_input.c | 2 +-
12
MAINTAINERS | 1 +
13
5 files changed, 22 insertions(+), 5 deletions(-)
14
create mode 100644 include/hw/input/gamepad.h
15
16
diff --git a/include/hw/devices.h b/include/hw/devices.h
17
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/devices.h
19
+++ b/include/hw/devices.h
20
@@ -XXX,XX +XXX,XX @@ void *tsc2005_init(qemu_irq pintdav);
21
uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
22
void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
23
24
-/* stellaris_input.c */
25
-void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
26
-
27
#endif
28
diff --git a/include/hw/input/gamepad.h b/include/hw/input/gamepad.h
29
new file mode 100644
30
index XXXXXXX..XXXXXXX
31
--- /dev/null
32
+++ b/include/hw/input/gamepad.h
33
@@ -XXX,XX +XXX,XX @@
34
+/*
35
+ * Gamepad style buttons connected to IRQ/GPIO lines
36
+ *
37
+ * Copyright (c) 2007 CodeSourcery.
38
+ * Written by Paul Brook
39
+ *
40
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
41
+ * See the COPYING file in the top-level directory.
42
+ */
43
+
44
+#ifndef HW_INPUT_GAMEPAD_H
45
+#define HW_INPUT_GAMEPAD_H
46
+
47
+#include "hw/irq.h"
48
+
49
+/* stellaris_input.c */
50
+void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
51
+
52
+#endif
53
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
54
index XXXXXXX..XXXXXXX 100644
55
--- a/hw/arm/stellaris.c
56
+++ b/hw/arm/stellaris.c
57
@@ -XXX,XX +XXX,XX @@
58
#include "hw/sysbus.h"
59
#include "hw/ssi/ssi.h"
60
#include "hw/arm/arm.h"
61
-#include "hw/devices.h"
62
#include "qemu/timer.h"
63
#include "hw/i2c/i2c.h"
64
#include "net/net.h"
65
@@ -XXX,XX +XXX,XX @@
66
#include "sysemu/sysemu.h"
67
#include "hw/arm/armv7m.h"
68
#include "hw/char/pl011.h"
69
+#include "hw/input/gamepad.h"
70
#include "hw/watchdog/cmsdk-apb-watchdog.h"
71
#include "hw/misc/unimp.h"
72
#include "cpu.h"
73
diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c
74
index XXXXXXX..XXXXXXX 100644
75
--- a/hw/input/stellaris_input.c
76
+++ b/hw/input/stellaris_input.c
77
@@ -XXX,XX +XXX,XX @@
78
*/
79
#include "qemu/osdep.h"
80
#include "hw/hw.h"
81
-#include "hw/devices.h"
82
+#include "hw/input/gamepad.h"
83
#include "ui/console.h"
84
85
typedef struct {
86
diff --git a/MAINTAINERS b/MAINTAINERS
87
index XXXXXXX..XXXXXXX 100644
88
--- a/MAINTAINERS
89
+++ b/MAINTAINERS
90
@@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org>
91
L: qemu-arm@nongnu.org
92
S: Maintained
93
F: hw/*/stellaris*
94
+F: include/hw/input/gamepad.h
95
96
Versatile Express
97
M: Peter Maydell <peter.maydell@linaro.org>
98
--
99
2.20.1
100
101
diff view generated by jsdifflib
Deleted patch
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
2
1
3
Since uWireSlave is only used in this new header, there is no
4
need to expose it via "qemu/typedefs.h".
5
6
Reviewed-by: Markus Armbruster <armbru@redhat.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Message-id: 20190412165416.7977-9-philmd@redhat.com
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
include/hw/arm/omap.h | 6 +-----
12
include/hw/devices.h | 15 ---------------
13
include/hw/input/tsc2xxx.h | 36 ++++++++++++++++++++++++++++++++++++
14
include/qemu/typedefs.h | 1 -
15
hw/arm/nseries.c | 2 +-
16
hw/arm/palm.c | 2 +-
17
hw/input/tsc2005.c | 2 +-
18
hw/input/tsc210x.c | 4 ++--
19
MAINTAINERS | 2 ++
20
9 files changed, 44 insertions(+), 26 deletions(-)
21
create mode 100644 include/hw/input/tsc2xxx.h
22
23
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
24
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/arm/omap.h
26
+++ b/include/hw/arm/omap.h
27
@@ -XXX,XX +XXX,XX @@
28
#include "exec/memory.h"
29
# define hw_omap_h        "omap.h"
30
#include "hw/irq.h"
31
+#include "hw/input/tsc2xxx.h"
32
#include "target/arm/cpu-qom.h"
33
#include "qemu/log.h"
34
35
@@ -XXX,XX +XXX,XX @@ qemu_irq *omap_mpuio_in_get(struct omap_mpuio_s *s);
36
void omap_mpuio_out_set(struct omap_mpuio_s *s, int line, qemu_irq handler);
37
void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down);
38
39
-struct uWireSlave {
40
- uint16_t (*receive)(void *opaque);
41
- void (*send)(void *opaque, uint16_t data);
42
- void *opaque;
43
-};
44
struct omap_uwire_s;
45
void omap_uwire_attach(struct omap_uwire_s *s,
46
uWireSlave *slave, int chipselect);
47
diff --git a/include/hw/devices.h b/include/hw/devices.h
48
index XXXXXXX..XXXXXXX 100644
49
--- a/include/hw/devices.h
50
+++ b/include/hw/devices.h
51
@@ -XXX,XX +XXX,XX @@
52
/* Devices that have nowhere better to go. */
53
54
#include "hw/hw.h"
55
-#include "ui/console.h"
56
57
/* smc91c111.c */
58
void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
59
@@ -XXX,XX +XXX,XX @@ void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
60
/* lan9118.c */
61
void lan9118_init(NICInfo *, uint32_t, qemu_irq);
62
63
-/* tsc210x.c */
64
-uWireSlave *tsc2102_init(qemu_irq pint);
65
-uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav);
66
-I2SCodec *tsc210x_codec(uWireSlave *chip);
67
-uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len);
68
-void tsc210x_set_transform(uWireSlave *chip,
69
- MouseTransformInfo *info);
70
-void tsc210x_key_event(uWireSlave *chip, int key, int down);
71
-
72
-/* tsc2005.c */
73
-void *tsc2005_init(qemu_irq pintdav);
74
-uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
75
-void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
76
-
77
#endif
78
diff --git a/include/hw/input/tsc2xxx.h b/include/hw/input/tsc2xxx.h
79
new file mode 100644
80
index XXXXXXX..XXXXXXX
81
--- /dev/null
82
+++ b/include/hw/input/tsc2xxx.h
83
@@ -XXX,XX +XXX,XX @@
84
+/*
85
+ * TI touchscreen controller
86
+ *
87
+ * Copyright (c) 2006 Andrzej Zaborowski
88
+ * Copyright (C) 2008 Nokia Corporation
89
+ *
90
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
91
+ * See the COPYING file in the top-level directory.
92
+ */
93
+
94
+#ifndef HW_INPUT_TSC2XXX_H
95
+#define HW_INPUT_TSC2XXX_H
96
+
97
+#include "hw/irq.h"
98
+#include "ui/console.h"
99
+
100
+typedef struct uWireSlave {
101
+ uint16_t (*receive)(void *opaque);
102
+ void (*send)(void *opaque, uint16_t data);
103
+ void *opaque;
104
+} uWireSlave;
105
+
106
+/* tsc210x.c */
107
+uWireSlave *tsc2102_init(qemu_irq pint);
108
+uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav);
109
+I2SCodec *tsc210x_codec(uWireSlave *chip);
110
+uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len);
111
+void tsc210x_set_transform(uWireSlave *chip, MouseTransformInfo *info);
112
+void tsc210x_key_event(uWireSlave *chip, int key, int down);
113
+
114
+/* tsc2005.c */
115
+void *tsc2005_init(qemu_irq pintdav);
116
+uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
117
+void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
118
+
119
+#endif
120
diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h
121
index XXXXXXX..XXXXXXX 100644
122
--- a/include/qemu/typedefs.h
123
+++ b/include/qemu/typedefs.h
124
@@ -XXX,XX +XXX,XX @@ typedef struct RAMBlock RAMBlock;
125
typedef struct Range Range;
126
typedef struct SHPCDevice SHPCDevice;
127
typedef struct SSIBus SSIBus;
128
-typedef struct uWireSlave uWireSlave;
129
typedef struct VirtIODevice VirtIODevice;
130
typedef struct Visitor Visitor;
131
typedef void SaveStateHandler(QEMUFile *f, void *opaque);
132
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
133
index XXXXXXX..XXXXXXX 100644
134
--- a/hw/arm/nseries.c
135
+++ b/hw/arm/nseries.c
136
@@ -XXX,XX +XXX,XX @@
137
#include "ui/console.h"
138
#include "hw/boards.h"
139
#include "hw/i2c/i2c.h"
140
-#include "hw/devices.h"
141
#include "hw/display/blizzard.h"
142
+#include "hw/input/tsc2xxx.h"
143
#include "hw/misc/cbus.h"
144
#include "hw/misc/tmp105.h"
145
#include "hw/block/flash.h"
146
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
147
index XXXXXXX..XXXXXXX 100644
148
--- a/hw/arm/palm.c
149
+++ b/hw/arm/palm.c
150
@@ -XXX,XX +XXX,XX @@
151
#include "hw/arm/omap.h"
152
#include "hw/boards.h"
153
#include "hw/arm/arm.h"
154
-#include "hw/devices.h"
155
+#include "hw/input/tsc2xxx.h"
156
#include "hw/loader.h"
157
#include "exec/address-spaces.h"
158
#include "cpu.h"
159
diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c
160
index XXXXXXX..XXXXXXX 100644
161
--- a/hw/input/tsc2005.c
162
+++ b/hw/input/tsc2005.c
163
@@ -XXX,XX +XXX,XX @@
164
#include "hw/hw.h"
165
#include "qemu/timer.h"
166
#include "ui/console.h"
167
-#include "hw/devices.h"
168
+#include "hw/input/tsc2xxx.h"
169
#include "trace.h"
170
171
#define TSC_CUT_RESOLUTION(value, p)    ((value) >> (16 - (p ? 12 : 10)))
172
diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
173
index XXXXXXX..XXXXXXX 100644
174
--- a/hw/input/tsc210x.c
175
+++ b/hw/input/tsc210x.c
176
@@ -XXX,XX +XXX,XX @@
177
#include "audio/audio.h"
178
#include "qemu/timer.h"
179
#include "ui/console.h"
180
-#include "hw/arm/omap.h"    /* For I2SCodec and uWireSlave */
181
-#include "hw/devices.h"
182
+#include "hw/arm/omap.h" /* For I2SCodec */
183
+#include "hw/input/tsc2xxx.h"
184
185
#define TSC_DATA_REGISTERS_PAGE        0x0
186
#define TSC_CONTROL_REGISTERS_PAGE    0x1
187
diff --git a/MAINTAINERS b/MAINTAINERS
188
index XXXXXXX..XXXXXXX 100644
189
--- a/MAINTAINERS
190
+++ b/MAINTAINERS
191
@@ -XXX,XX +XXX,XX @@ F: hw/input/tsc2005.c
192
F: hw/misc/cbus.c
193
F: hw/timer/twl92230.c
194
F: include/hw/display/blizzard.h
195
+F: include/hw/input/tsc2xxx.h
196
F: include/hw/misc/cbus.h
197
198
Palm
199
@@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org
200
S: Odd Fixes
201
F: hw/arm/palm.c
202
F: hw/input/tsc210x.c
203
+F: include/hw/input/tsc2xxx.h
204
205
Raspberry Pi
206
M: Peter Maydell <peter.maydell@linaro.org>
207
--
208
2.20.1
209
210
diff view generated by jsdifflib