1
First pullreq for arm of the 4.1 series, since I'm back from
1
Nothing earth-shaking in here, just a lot of refactoring and cleanup
2
holiday now. This is mostly my M-profile FPU series and Philippe's
2
and a few bugfixes. I suspect I'll have another pullreq to come in
3
devices.h cleanup. I have a pile of other patchsets to work through
3
the early part of next week...
4
in my to-review folder, but 42 patches is definitely quite
5
big enough to send now...
6
4
7
thanks
5
The following changes since commit 19591e9e0938ea5066984553c256a043bd5d822f:
8
-- PMM
9
6
10
The following changes since commit 413a99a92c13ec408dcf2adaa87918dc81e890c8:
7
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging (2020-08-27 16:59:02 +0100)
11
12
Add Nios II semihosting support. (2019-04-29 16:09:51 +0100)
13
8
14
are available in the Git repository at:
9
are available in the Git repository at:
15
10
16
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20190429
11
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200828
17
12
18
for you to fetch changes up to 437cc27ddfded3bbab6afd5ac1761e0e195edba7:
13
for you to fetch changes up to ed78849d9711805bda37ee026018d6ee7a606d0e:
19
14
20
hw/devices: Move SMSC 91C111 declaration into a new header (2019-04-29 17:57:21 +0100)
15
target/arm: Convert sq{, r}dmulh to gvec for aa64 advsimd (2020-08-28 10:02:50 +0100)
21
16
22
----------------------------------------------------------------
17
----------------------------------------------------------------
23
target-arm queue:
18
target-arm queue:
24
* remove "bag of random stuff" hw/devices.h header
19
* target/arm: Cleanup and refactoring preparatory to SVE2
25
* implement FPU for Cortex-M and enable it for Cortex-M4 and -M33
20
* armsse: Define ARMSSEClass correctly
26
* hw/dma: Compile the bcm2835_dma device as common object
21
* hw/misc/unimp: Improve information provided in log messages
27
* configure: Remove --source-path option
22
* hw/qdev-clock: Avoid calling qdev_connect_clock_in after DeviceRealize
28
* hw/ssi/xilinx_spips: Avoid variable length array
23
* hw/arm/xilinx_zynq: Call qdev_connect_clock_in() before DeviceRealize
29
* hw/arm/smmuv3: Remove SMMUNotifierNode
24
* hw/net/allwinner-sun8i-emac: Use AddressSpace for DMA transfers
25
* hw/sd/allwinner-sdhost: Use AddressSpace for DMA transfers
26
* target/arm: Fill in the WnR syndrome bit in mte_check_fail
27
* target/arm: Clarify HCR_EL2 ARMCPRegInfo type
28
* hw/arm/musicpal: Use AddressSpace for DMA transfers
29
* hw/clock: Minor cleanups
30
* hw/arm/sbsa-ref: fix typo breaking PCIe IRQs
30
31
31
----------------------------------------------------------------
32
----------------------------------------------------------------
32
Eric Auger (1):
33
Eduardo Habkost (1):
33
hw/arm/smmuv3: Remove SMMUNotifierNode
34
armsse: Define ARMSSEClass correctly
34
35
35
Peter Maydell (28):
36
Graeme Gregory (1):
36
hw/ssi/xilinx_spips: Avoid variable length array
37
hw/arm/sbsa-ref: fix typo breaking PCIe IRQs
37
configure: Remove --source-path option
38
target/arm: Make sure M-profile FPSCR RES0 bits are not settable
39
hw/intc/armv7m_nvic: Allow reading of M-profile MVFR* registers
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
38
65
Philippe Mathieu-Daudé (13):
39
Philippe Mathieu-Daudé (14):
66
hw/dma: Compile the bcm2835_dma device as common object
40
hw/clock: Remove unused clock_init*() functions
67
hw/arm/aspeed: Use TYPE_TMP105/TYPE_PCA9552 instead of hardcoded string
41
hw/clock: Let clock_set() return boolean value
68
hw/arm/nseries: Use TYPE_TMP105 instead of hardcoded string
42
hw/clock: Only propagate clock changes if the clock is changed
69
hw/display/tc6393xb: Remove unused functions
43
hw/arm/musicpal: Use AddressSpace for DMA transfers
70
hw/devices: Move TC6393XB declarations into a new header
44
target/arm: Clarify HCR_EL2 ARMCPRegInfo type
71
hw/devices: Move Blizzard declarations into a new header
45
hw/sd/allwinner-sdhost: Use AddressSpace for DMA transfers
72
hw/devices: Move CBus declarations into a new header
46
hw/net/allwinner-sun8i-emac: Use AddressSpace for DMA transfers
73
hw/devices: Move Gamepad declarations into a new header
47
hw/arm/xilinx_zynq: Uninline cadence_uart_create()
74
hw/devices: Move TI touchscreen declarations into a new header
48
hw/arm/xilinx_zynq: Call qdev_connect_clock_in() before DeviceRealize
75
hw/devices: Move LAN9118 declarations into a new header
49
hw/qdev-clock: Uninline qdev_connect_clock_in()
76
hw/net/ne2000-isa: Add guards to the header
50
hw/qdev-clock: Avoid calling qdev_connect_clock_in after DeviceRealize
77
hw/net/lan9118: Export TYPE_LAN9118 and use it instead of hardcoded string
51
hw/misc/unimp: Display value after offset
78
hw/devices: Move SMSC 91C111 declaration into a new header
52
hw/misc/unimp: Display the value with width of the access size
53
hw/misc/unimp: Display the offset with width of the region size
79
54
80
configure | 10 +-
55
Richard Henderson (19):
81
hw/dma/Makefile.objs | 2 +-
56
target/arm: Pass the entire mte descriptor to mte_check_fail
82
include/hw/arm/omap.h | 6 +-
57
target/arm: Fill in the WnR syndrome bit in mte_check_fail
83
include/hw/arm/smmu-common.h | 8 +-
58
qemu/int128: Add int128_lshift
84
include/hw/devices.h | 62 ---
59
target/arm: Split out gen_gvec_fn_zz
85
include/hw/display/blizzard.h | 22 ++
60
target/arm: Split out gen_gvec_fn_zzz, do_zzz_fn
86
include/hw/display/tc6393xb.h | 24 ++
61
target/arm: Rearrange {sve,fp}_check_access assert
87
include/hw/input/gamepad.h | 19 +
62
target/arm: Merge do_vector2_p into do_mov_p
88
include/hw/input/tsc2xxx.h | 36 ++
63
target/arm: Clean up 4-operand predicate expansion
89
include/hw/misc/cbus.h | 32 ++
64
target/arm: Use tcg_gen_gvec_bitsel for trans_SEL_pppp
90
include/hw/net/lan9118.h | 21 +
65
target/arm: Split out gen_gvec_ool_zzzp
91
include/hw/net/ne2000-isa.h | 6 +
66
target/arm: Merge helper_sve_clr_* and helper_sve_movz_*
92
include/hw/net/smc91c111.h | 19 +
67
target/arm: Split out gen_gvec_ool_zzp
93
include/qemu/typedefs.h | 1 -
68
target/arm: Split out gen_gvec_ool_zzz
94
target/arm/cpu.h | 95 ++++-
69
target/arm: Split out gen_gvec_ool_zz
95
target/arm/helper.h | 5 +
70
target/arm: Tidy SVE tszimm shift formats
96
target/arm/translate.h | 3 +
71
target/arm: Generalize inl_qrdmlah_* helper functions
97
hw/arm/aspeed.c | 13 +-
72
target/arm: Convert integer multiply (indexed) to gvec for aa64 advsimd
98
hw/arm/exynos4_boards.c | 3 +-
73
target/arm: Convert integer multiply-add (indexed) to gvec for aa64 advsimd
99
hw/arm/gumstix.c | 2 +-
74
target/arm: Convert sq{, r}dmulh to gvec for aa64 advsimd
100
hw/arm/integratorcp.c | 2 +-
101
hw/arm/kzm.c | 2 +-
102
hw/arm/mainstone.c | 2 +-
103
hw/arm/mps2-tz.c | 3 +-
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
75
76
include/hw/arm/armsse.h | 2 +-
77
include/hw/char/cadence_uart.h | 17 --
78
include/hw/clock.h | 30 +--
79
include/hw/misc/unimp.h | 1 +
80
include/hw/net/allwinner-sun8i-emac.h | 6 +
81
include/hw/qdev-clock.h | 8 +-
82
include/hw/sd/allwinner-sdhost.h | 6 +
83
include/qemu/int128.h | 16 ++
84
target/arm/helper-sve.h | 5 -
85
target/arm/helper.h | 28 +++
86
target/arm/translate.h | 1 +
87
target/arm/sve.decode | 35 ++-
88
hw/arm/allwinner-a10.c | 2 +
89
hw/arm/allwinner-h3.c | 4 +
90
hw/arm/armsse.c | 1 +
91
hw/arm/musicpal.c | 45 ++--
92
hw/arm/sbsa-ref.c | 2 +-
93
hw/arm/xilinx_zynq.c | 24 +-
94
hw/core/clock.c | 7 +-
95
hw/core/qdev-clock.c | 6 +
96
hw/misc/unimp.c | 14 +-
97
hw/net/allwinner-sun8i-emac.c | 46 ++--
98
hw/sd/allwinner-sdhost.c | 37 +++-
99
target/arm/helper.c | 1 -
100
target/arm/mte_helper.c | 19 +-
101
target/arm/sve_helper.c | 70 ++----
102
target/arm/translate-a64.c | 110 ++++++++--
103
target/arm/translate-sve.c | 399 ++++++++++++++--------------------
104
target/arm/vec_helper.c | 182 +++++++++++-----
105
29 files changed, 629 insertions(+), 495 deletions(-)
106
diff view generated by jsdifflib
1
Handle floating point registers in exception return.
1
From: Graeme Gregory <graeme@nuviainc.com>
2
This corresponds to pseudocode functions ValidateExceptionReturn(),
3
ExceptionReturn(), PopStack() and ConsumeExcStackFrame().
4
2
3
Fixing a typo in a previous patch that translated an "i" to a 1
4
and therefore breaking the allocation of PCIe interrupts. This was
5
discovered when virtio-net-pci devices ceased to function correctly.
6
7
Cc: qemu-stable@nongnu.org
8
Fixes: 48ba18e6d3f3 ("hw/arm/sbsa-ref: Simplify by moving the gic in the machine state")
9
Signed-off-by: Graeme Gregory <graeme@nuviainc.com>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 20200821083853.356490-1-graeme@nuviainc.com
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>
7
Message-id: 20190416125744.27770-16-peter.maydell@linaro.org
8
---
13
---
9
target/arm/helper.c | 142 +++++++++++++++++++++++++++++++++++++++++++-
14
hw/arm/sbsa-ref.c | 2 +-
10
1 file changed, 141 insertions(+), 1 deletion(-)
15
1 file changed, 1 insertion(+), 1 deletion(-)
11
16
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
13
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.c
19
--- a/hw/arm/sbsa-ref.c
15
+++ b/target/arm/helper.c
20
+++ b/hw/arm/sbsa-ref.c
16
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
21
@@ -XXX,XX +XXX,XX @@ static void create_pcie(SBSAMachineState *sms)
17
bool rettobase = false;
22
18
bool exc_secure = false;
23
for (i = 0; i < GPEX_NUM_IRQS; i++) {
19
bool return_to_secure;
24
sysbus_connect_irq(SYS_BUS_DEVICE(dev), i,
20
+ bool ftype;
25
- qdev_get_gpio_in(sms->gic, irq + 1));
21
+ bool restore_s16_s31;
26
+ qdev_get_gpio_in(sms->gic, irq + i));
22
27
gpex_set_irq_num(GPEX_HOST(dev), i, irq + i);
23
/* If we're not in Handler mode then jumps to magic exception-exit
24
* addresses don't have magic behaviour. However for the v8M
25
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
26
excret);
27
}
28
}
28
29
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
}
75
}
76
77
+ if (!ftype) {
78
+ /* FP present and we need to handle it */
79
+ if (!return_to_secure &&
80
+ (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPACT_MASK)) {
81
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
82
+ env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK;
83
+ qemu_log_mask(CPU_LOG_INT,
84
+ "...taking SecureFault on existing stackframe: "
85
+ "Secure LSPACT set but exception return is "
86
+ "not to secure state\n");
87
+ v7m_exception_taken(cpu, excret, true, false);
88
+ return;
89
+ }
90
+
91
+ restore_s16_s31 = return_to_secure &&
92
+ (env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK);
93
+
94
+ if (env->v7m.fpccr[return_to_secure] & R_V7M_FPCCR_LSPACT_MASK) {
95
+ /* State in FPU is still valid, just clear LSPACT */
96
+ env->v7m.fpccr[return_to_secure] &= ~R_V7M_FPCCR_LSPACT_MASK;
97
+ } else {
98
+ int i;
99
+ uint32_t fpscr;
100
+ bool cpacr_pass, nsacr_pass;
101
+
102
+ cpacr_pass = v7m_cpacr_pass(env, return_to_secure,
103
+ return_to_priv);
104
+ nsacr_pass = return_to_secure ||
105
+ extract32(env->v7m.nsacr, 10, 1);
106
+
107
+ if (!cpacr_pass) {
108
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
109
+ return_to_secure);
110
+ env->v7m.cfsr[return_to_secure] |= R_V7M_CFSR_NOCP_MASK;
111
+ qemu_log_mask(CPU_LOG_INT,
112
+ "...taking UsageFault on existing "
113
+ "stackframe: CPACR.CP10 prevents unstacking "
114
+ "FP regs\n");
115
+ v7m_exception_taken(cpu, excret, true, false);
116
+ return;
117
+ } else if (!nsacr_pass) {
118
+ armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, true);
119
+ env->v7m.cfsr[M_REG_S] |= R_V7M_CFSR_INVPC_MASK;
120
+ qemu_log_mask(CPU_LOG_INT,
121
+ "...taking Secure UsageFault on existing "
122
+ "stackframe: NSACR.CP10 prevents unstacking "
123
+ "FP regs\n");
124
+ v7m_exception_taken(cpu, excret, true, false);
125
+ return;
126
+ }
127
+
128
+ for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) {
129
+ uint32_t slo, shi;
130
+ uint64_t dn;
131
+ uint32_t faddr = frameptr + 0x20 + 4 * i;
132
+
133
+ if (i >= 16) {
134
+ faddr += 8; /* Skip the slot for the FPSCR */
135
+ }
136
+
137
+ pop_ok = pop_ok &&
138
+ v7m_stack_read(cpu, &slo, faddr, mmu_idx) &&
139
+ v7m_stack_read(cpu, &shi, faddr + 4, mmu_idx);
140
+
141
+ if (!pop_ok) {
142
+ break;
143
+ }
144
+
145
+ dn = (uint64_t)shi << 32 | slo;
146
+ *aa32_vfp_dreg(env, i / 2) = dn;
147
+ }
148
+ pop_ok = pop_ok &&
149
+ v7m_stack_read(cpu, &fpscr, frameptr + 0x60, mmu_idx);
150
+ if (pop_ok) {
151
+ vfp_set_fpscr(env, fpscr);
152
+ }
153
+ if (!pop_ok) {
154
+ /*
155
+ * These regs are 0 if security extension present;
156
+ * otherwise merely UNKNOWN. We zero always.
157
+ */
158
+ for (i = 0; i < (restore_s16_s31 ? 32 : 16); i += 2) {
159
+ *aa32_vfp_dreg(env, i / 2) = 0;
160
+ }
161
+ vfp_set_fpscr(env, 0);
162
+ }
163
+ }
164
+ }
165
+ env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S],
166
+ V7M_CONTROL, FPCA, !ftype);
167
+
168
/* Commit to consuming the stack frame */
169
frameptr += 0x20;
170
+ if (!ftype) {
171
+ frameptr += 0x48;
172
+ if (restore_s16_s31) {
173
+ frameptr += 0x40;
174
+ }
175
+ }
176
/* Undo stack alignment (the SPREALIGN bit indicates that the original
177
* pre-exception SP was not 8-aligned and we added a padding word to
178
* align it, so we undo this by ORing in the bit that increases it
179
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
180
*frame_sp_p = frameptr;
181
}
182
/* This xpsr_write() will invalidate frame_sp_p as it may switch stack */
183
- xpsr_write(env, xpsr, ~XPSR_SPREALIGN);
184
+ xpsr_write(env, xpsr, ~(XPSR_SPREALIGN | XPSR_SFPA));
185
+
186
+ if (env->v7m.secure) {
187
+ bool sfpa = xpsr & XPSR_SFPA;
188
+
189
+ env->v7m.control[M_REG_S] = FIELD_DP32(env->v7m.control[M_REG_S],
190
+ V7M_CONTROL, SFPA, sfpa);
191
+ }
192
193
/* The restored xPSR exception field will be zero if we're
194
* resuming in Thread mode. If that doesn't match what the
195
--
30
--
196
2.20.1
31
2.20.1
197
32
198
33
diff view generated by jsdifflib
1
Enable the FPU by default for the Cortex-M4 and Cortex-M33.
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
clock_init*() inlined funtions are simple wrappers around
4
clock_set*() and are not used. Remove them in favor of clock_set*().
5
6
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20200806123858.30058-2-f4bug@amsat.org
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190416125744.27770-27-peter.maydell@linaro.org
6
---
10
---
7
target/arm/cpu.c | 8 ++++++++
11
include/hw/clock.h | 13 -------------
8
1 file changed, 8 insertions(+)
12
1 file changed, 13 deletions(-)
9
13
10
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
14
diff --git a/include/hw/clock.h b/include/hw/clock.h
11
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
12
--- a/target/arm/cpu.c
16
--- a/include/hw/clock.h
13
+++ b/target/arm/cpu.c
17
+++ b/include/hw/clock.h
14
@@ -XXX,XX +XXX,XX @@ static void cortex_m4_initfn(Object *obj)
18
@@ -XXX,XX +XXX,XX @@ static inline bool clock_is_enabled(const Clock *clk)
15
set_feature(&cpu->env, ARM_FEATURE_M);
19
return clock_get(clk) != 0;
16
set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
20
}
17
set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
21
18
+ set_feature(&cpu->env, ARM_FEATURE_VFP4);
22
-static inline void clock_init(Clock *clk, uint64_t value)
19
cpu->midr = 0x410fc240; /* r0p0 */
23
-{
20
cpu->pmsav7_dregion = 8;
24
- clock_set(clk, value);
21
+ cpu->isar.mvfr0 = 0x10110021;
25
-}
22
+ cpu->isar.mvfr1 = 0x11000011;
26
-static inline void clock_init_hz(Clock *clk, uint64_t value)
23
+ cpu->isar.mvfr2 = 0x00000000;
27
-{
24
cpu->id_pfr0 = 0x00000030;
28
- clock_set_hz(clk, value);
25
cpu->id_pfr1 = 0x00000200;
29
-}
26
cpu->id_dfr0 = 0x00100000;
30
-static inline void clock_init_ns(Clock *clk, uint64_t value)
27
@@ -XXX,XX +XXX,XX @@ static void cortex_m33_initfn(Object *obj)
31
-{
28
set_feature(&cpu->env, ARM_FEATURE_M_MAIN);
32
- clock_set_ns(clk, value);
29
set_feature(&cpu->env, ARM_FEATURE_M_SECURITY);
33
-}
30
set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP);
34
-
31
+ set_feature(&cpu->env, ARM_FEATURE_VFP4);
35
#endif /* QEMU_HW_CLOCK_H */
32
cpu->midr = 0x410fd213; /* r0p3 */
33
cpu->pmsav7_dregion = 16;
34
cpu->sau_sregion = 8;
35
+ cpu->isar.mvfr0 = 0x10110021;
36
+ cpu->isar.mvfr1 = 0x11000011;
37
+ cpu->isar.mvfr2 = 0x00000040;
38
cpu->id_pfr0 = 0x00000030;
39
cpu->id_pfr1 = 0x00000210;
40
cpu->id_dfr0 = 0x00200000;
41
--
36
--
42
2.20.1
37
2.20.1
43
38
44
39
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
This commit finally deletes "hw/devices.h".
3
Let clock_set() return a boolean value whether the clock
4
has been updated or not.
4
5
5
Reviewed-by: Markus Armbruster <armbru@redhat.com>
6
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20190412165416.7977-13-philmd@redhat.com
8
Message-id: 20200806123858.30058-3-f4bug@amsat.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
include/hw/clock.h | 12 +++++++-----
11
include/hw/net/smc91c111.h | 19 +++++++++++++++++++
12
hw/core/clock.c | 7 ++++++-
12
hw/arm/gumstix.c | 2 +-
13
2 files changed, 13 insertions(+), 6 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/include/hw/clock.h b/include/hw/clock.h
23
deleted file mode 100644
16
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX
17
--- a/include/hw/clock.h
25
--- a/include/hw/devices.h
18
+++ b/include/hw/clock.h
26
+++ /dev/null
19
@@ -XXX,XX +XXX,XX @@ void clock_set_source(Clock *clk, Clock *src);
27
@@ -XXX,XX +XXX,XX @@
20
* @value: the clock's value, 0 means unclocked
28
-#ifndef QEMU_DEVICES_H
21
*
29
-#define QEMU_DEVICES_H
22
* Set the local cached period value of @clk to @value.
30
-
31
-/* Devices that have nowhere better to go. */
32
-
33
-#include "hw/hw.h"
34
-
35
-/* smc91c111.c */
36
-void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
37
-
38
-#endif
39
diff --git a/include/hw/net/smc91c111.h b/include/hw/net/smc91c111.h
40
new file mode 100644
41
index XXXXXXX..XXXXXXX
42
--- /dev/null
43
+++ b/include/hw/net/smc91c111.h
44
@@ -XXX,XX +XXX,XX @@
45
+/*
46
+ * SMSC 91C111 Ethernet interface emulation
47
+ *
23
+ *
48
+ * Copyright (c) 2005 CodeSourcery, LLC.
24
+ * @return: true if the clock is changed.
49
+ * Written by Paul Brook
25
*/
50
+ *
26
-void clock_set(Clock *clk, uint64_t value);
51
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
27
+bool clock_set(Clock *clk, uint64_t value);
52
+ * See the COPYING file in the top-level directory.
28
53
+ */
29
-static inline void clock_set_hz(Clock *clk, unsigned hz)
30
+static inline bool clock_set_hz(Clock *clk, unsigned hz)
31
{
32
- clock_set(clk, CLOCK_PERIOD_FROM_HZ(hz));
33
+ return clock_set(clk, CLOCK_PERIOD_FROM_HZ(hz));
34
}
35
36
-static inline void clock_set_ns(Clock *clk, unsigned ns)
37
+static inline bool clock_set_ns(Clock *clk, unsigned ns)
38
{
39
- clock_set(clk, CLOCK_PERIOD_FROM_NS(ns));
40
+ return clock_set(clk, CLOCK_PERIOD_FROM_NS(ns));
41
}
42
43
/**
44
diff --git a/hw/core/clock.c b/hw/core/clock.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/core/clock.c
47
+++ b/hw/core/clock.c
48
@@ -XXX,XX +XXX,XX @@ void clock_clear_callback(Clock *clk)
49
clock_set_callback(clk, NULL, NULL);
50
}
51
52
-void clock_set(Clock *clk, uint64_t period)
53
+bool clock_set(Clock *clk, uint64_t period)
54
{
55
+ if (clk->period == period) {
56
+ return false;
57
+ }
58
trace_clock_set(CLOCK_PATH(clk), CLOCK_PERIOD_TO_NS(clk->period),
59
CLOCK_PERIOD_TO_NS(period));
60
clk->period = period;
54
+
61
+
55
+#ifndef HW_NET_SMC91C111_H
62
+ return true;
56
+#define HW_NET_SMC91C111_H
63
}
57
+
64
58
+#include "hw/irq.h"
65
static void clock_propagate_period(Clock *clk, bool call_callbacks)
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
66
--- a/hw/arm/gumstix.c
67
+++ b/hw/arm/gumstix.c
68
@@ -XXX,XX +XXX,XX @@
69
#include "hw/arm/pxa.h"
70
#include "net/net.h"
71
#include "hw/block/flash.h"
72
-#include "hw/devices.h"
73
+#include "hw/net/smc91c111.h"
74
#include "hw/boards.h"
75
#include "exec/address-spaces.h"
76
#include "sysemu/qtest.h"
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
--
66
--
147
2.20.1
67
2.20.1
148
68
149
69
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
Avoid propagating the clock change when the clock does not change.
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
5
Message-id: 20190412165416.7977-10-philmd@redhat.com
5
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20200806123858.30058-4-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
9
---
8
include/hw/devices.h | 3 ---
10
include/hw/clock.h | 5 +++--
9
include/hw/net/lan9118.h | 19 +++++++++++++++++++
11
1 file changed, 3 insertions(+), 2 deletions(-)
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
12
18
diff --git a/include/hw/devices.h b/include/hw/devices.h
13
diff --git a/include/hw/clock.h b/include/hw/clock.h
19
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/devices.h
15
--- a/include/hw/clock.h
21
+++ b/include/hw/devices.h
16
+++ b/include/hw/clock.h
22
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@ void clock_propagate(Clock *clk);
23
/* smc91c111.c */
18
*/
24
void smc91c111_init(NICInfo *, uint32_t, qemu_irq);
19
static inline void clock_update(Clock *clk, uint64_t value)
25
20
{
26
-/* lan9118.c */
21
- clock_set(clk, value);
27
-void lan9118_init(NICInfo *, uint32_t, qemu_irq);
22
- clock_propagate(clk);
28
-
23
+ if (clock_set(clk, value)) {
29
#endif
24
+ clock_propagate(clk);
30
diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h
25
+ }
31
new file mode 100644
26
}
32
index XXXXXXX..XXXXXXX
27
33
--- /dev/null
28
static inline void clock_update_hz(Clock *clk, unsigned hz)
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
--
29
--
120
2.20.1
30
2.20.1
121
31
122
32
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
Allow the device to execute the DMA transfers in a different
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
AddressSpace.
5
Message-id: 20190412165416.7977-12-philmd@redhat.com
5
6
We keep using the system_memory address space, but via the
7
proper dma_memory_access() API.
8
9
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20200814125533.4047-1-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
13
---
8
include/hw/net/lan9118.h | 2 ++
14
hw/arm/musicpal.c | 45 +++++++++++++++++++++++++++++++--------------
9
hw/arm/exynos4_boards.c | 3 ++-
15
1 file changed, 31 insertions(+), 14 deletions(-)
10
hw/arm/mps2-tz.c | 3 ++-
11
hw/net/lan9118.c | 1 -
12
4 files changed, 6 insertions(+), 3 deletions(-)
13
16
14
diff --git a/include/hw/net/lan9118.h b/include/hw/net/lan9118.h
17
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
15
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
16
--- a/include/hw/net/lan9118.h
19
--- a/hw/arm/musicpal.c
17
+++ b/include/hw/net/lan9118.h
20
+++ b/hw/arm/musicpal.c
18
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@
19
#include "hw/irq.h"
22
#include "hw/audio/wm8750.h"
20
#include "net/net.h"
23
#include "sysemu/block-backend.h"
21
24
#include "sysemu/runstate.h"
22
+#define TYPE_LAN9118 "lan9118"
25
+#include "sysemu/dma.h"
26
#include "exec/address-spaces.h"
27
#include "ui/pixel_ops.h"
28
#include "qemu/cutils.h"
29
@@ -XXX,XX +XXX,XX @@ typedef struct mv88w8618_eth_state {
30
31
MemoryRegion iomem;
32
qemu_irq irq;
33
+ MemoryRegion *dma_mr;
34
+ AddressSpace dma_as;
35
uint32_t smir;
36
uint32_t icr;
37
uint32_t imr;
38
@@ -XXX,XX +XXX,XX @@ typedef struct mv88w8618_eth_state {
39
NICConf conf;
40
} mv88w8618_eth_state;
41
42
-static void eth_rx_desc_put(uint32_t addr, mv88w8618_rx_desc *desc)
43
+static void eth_rx_desc_put(AddressSpace *dma_as, uint32_t addr,
44
+ mv88w8618_rx_desc *desc)
45
{
46
cpu_to_le32s(&desc->cmdstat);
47
cpu_to_le16s(&desc->bytes);
48
cpu_to_le16s(&desc->buffer_size);
49
cpu_to_le32s(&desc->buffer);
50
cpu_to_le32s(&desc->next);
51
- cpu_physical_memory_write(addr, desc, sizeof(*desc));
52
+ dma_memory_write(dma_as, addr, desc, sizeof(*desc));
53
}
54
55
-static void eth_rx_desc_get(uint32_t addr, mv88w8618_rx_desc *desc)
56
+static void eth_rx_desc_get(AddressSpace *dma_as, uint32_t addr,
57
+ mv88w8618_rx_desc *desc)
58
{
59
- cpu_physical_memory_read(addr, desc, sizeof(*desc));
60
+ dma_memory_read(dma_as, addr, desc, sizeof(*desc));
61
le32_to_cpus(&desc->cmdstat);
62
le16_to_cpus(&desc->bytes);
63
le16_to_cpus(&desc->buffer_size);
64
@@ -XXX,XX +XXX,XX @@ static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
65
continue;
66
}
67
do {
68
- eth_rx_desc_get(desc_addr, &desc);
69
+ eth_rx_desc_get(&s->dma_as, desc_addr, &desc);
70
if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) {
71
- cpu_physical_memory_write(desc.buffer + s->vlan_header,
72
+ dma_memory_write(&s->dma_as, desc.buffer + s->vlan_header,
73
buf, size);
74
desc.bytes = size + s->vlan_header;
75
desc.cmdstat &= ~MP_ETH_RX_OWN;
76
@@ -XXX,XX +XXX,XX @@ static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
77
if (s->icr & s->imr) {
78
qemu_irq_raise(s->irq);
79
}
80
- eth_rx_desc_put(desc_addr, &desc);
81
+ eth_rx_desc_put(&s->dma_as, desc_addr, &desc);
82
return size;
83
}
84
desc_addr = desc.next;
85
@@ -XXX,XX +XXX,XX @@ static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
86
return size;
87
}
88
89
-static void eth_tx_desc_put(uint32_t addr, mv88w8618_tx_desc *desc)
90
+static void eth_tx_desc_put(AddressSpace *dma_as, uint32_t addr,
91
+ mv88w8618_tx_desc *desc)
92
{
93
cpu_to_le32s(&desc->cmdstat);
94
cpu_to_le16s(&desc->res);
95
cpu_to_le16s(&desc->bytes);
96
cpu_to_le32s(&desc->buffer);
97
cpu_to_le32s(&desc->next);
98
- cpu_physical_memory_write(addr, desc, sizeof(*desc));
99
+ dma_memory_write(dma_as, addr, desc, sizeof(*desc));
100
}
101
102
-static void eth_tx_desc_get(uint32_t addr, mv88w8618_tx_desc *desc)
103
+static void eth_tx_desc_get(AddressSpace *dma_as, uint32_t addr,
104
+ mv88w8618_tx_desc *desc)
105
{
106
- cpu_physical_memory_read(addr, desc, sizeof(*desc));
107
+ dma_memory_read(dma_as, addr, desc, sizeof(*desc));
108
le32_to_cpus(&desc->cmdstat);
109
le16_to_cpus(&desc->res);
110
le16_to_cpus(&desc->bytes);
111
@@ -XXX,XX +XXX,XX @@ static void eth_send(mv88w8618_eth_state *s, int queue_index)
112
int len;
113
114
do {
115
- eth_tx_desc_get(desc_addr, &desc);
116
+ eth_tx_desc_get(&s->dma_as, desc_addr, &desc);
117
next_desc = desc.next;
118
if (desc.cmdstat & MP_ETH_TX_OWN) {
119
len = desc.bytes;
120
if (len < 2048) {
121
- cpu_physical_memory_read(desc.buffer, buf, len);
122
+ dma_memory_read(&s->dma_as, desc.buffer, buf, len);
123
qemu_send_packet(qemu_get_queue(s->nic), buf, len);
124
}
125
desc.cmdstat &= ~MP_ETH_TX_OWN;
126
s->icr |= 1 << (MP_ETH_IRQ_TXLO_BIT - queue_index);
127
- eth_tx_desc_put(desc_addr, &desc);
128
+ eth_tx_desc_put(&s->dma_as, desc_addr, &desc);
129
}
130
desc_addr = next_desc;
131
} while (desc_addr != s->tx_queue[queue_index]);
132
@@ -XXX,XX +XXX,XX @@ static void mv88w8618_eth_realize(DeviceState *dev, Error **errp)
133
{
134
mv88w8618_eth_state *s = MV88W8618_ETH(dev);
135
136
+ if (!s->dma_mr) {
137
+ error_setg(errp, TYPE_MV88W8618_ETH " 'dma-memory' link not set");
138
+ return;
139
+ }
23
+
140
+
24
void lan9118_init(NICInfo *, uint32_t, qemu_irq);
141
+ address_space_init(&s->dma_as, s->dma_mr, "emac-dma");
25
142
s->nic = qemu_new_nic(&net_mv88w8618_info, &s->conf,
26
#endif
143
object_get_typename(OBJECT(dev)), dev->id, s);
27
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
144
}
28
index XXXXXXX..XXXXXXX 100644
145
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription mv88w8618_eth_vmsd = {
29
--- a/hw/arm/exynos4_boards.c
146
30
+++ b/hw/arm/exynos4_boards.c
147
static Property mv88w8618_eth_properties[] = {
31
@@ -XXX,XX +XXX,XX @@
148
DEFINE_NIC_PROPERTIES(mv88w8618_eth_state, conf),
32
#include "hw/arm/arm.h"
149
+ DEFINE_PROP_LINK("dma-memory", mv88w8618_eth_state, dma_mr,
33
#include "exec/address-spaces.h"
150
+ TYPE_MEMORY_REGION, MemoryRegion *),
34
#include "hw/arm/exynos4210.h"
151
DEFINE_PROP_END_OF_LIST(),
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
}
75
};
152
};
76
153
77
-#define TYPE_LAN9118 "lan9118"
154
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
78
#define LAN9118(obj) OBJECT_CHECK(lan9118_state, (obj), TYPE_LAN9118)
155
qemu_check_nic_model(&nd_table[0], "mv88w8618");
79
156
dev = qdev_new(TYPE_MV88W8618_ETH);
80
typedef struct {
157
qdev_set_nic_properties(dev, &nd_table[0]);
158
+ object_property_set_link(OBJECT(dev), "dma-memory",
159
+ OBJECT(get_system_memory()), &error_fatal);
160
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
161
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, MP_ETH_BASE);
162
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[MP_ETH_IRQ]);
81
--
163
--
82
2.20.1
164
2.20.1
83
165
84
166
diff view generated by jsdifflib
1
The TailChain() pseudocode specifies that a tail chaining
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
exception should sanitize the excReturn all-ones bits and
3
(if there is no FPU) the excReturn FType bits; we weren't
4
doing this.
5
2
3
In commit ce4afed839 ("target/arm: Implement AArch32 HCR and HCR2")
4
the HCR_EL2 register has been changed from type NO_RAW (no underlying
5
state and does not support raw access for state saving/loading) to
6
type CONST (TCG can assume the value to be constant), removing the
7
read/write accessors.
8
We forgot to remove the previous type ARM_CP_NO_RAW. This is not
9
really a problem since the field is overwritten. However it makes
10
code review confuse, so remove it.
11
12
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20200812111223.7787-1-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-14-peter.maydell@linaro.org
9
---
17
---
10
target/arm/helper.c | 8 ++++++++
18
target/arm/helper.c | 1 -
11
1 file changed, 8 insertions(+)
19
1 file changed, 1 deletion(-)
12
20
13
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
14
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
23
--- a/target/arm/helper.c
16
+++ b/target/arm/helper.c
24
+++ b/target/arm/helper.c
17
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
25
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = {
18
qemu_log_mask(CPU_LOG_INT, "...taking pending %s exception %d\n",
26
.access = PL2_RW,
19
targets_secure ? "secure" : "nonsecure", exc);
27
.readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore },
20
28
{ .name = "HCR_EL2", .state = ARM_CP_STATE_BOTH,
21
+ if (dotailchain) {
29
- .type = ARM_CP_NO_RAW,
22
+ /* Sanitize LR FType and PREFIX bits */
30
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
23
+ if (!arm_feature(env, ARM_FEATURE_VFP)) {
31
.access = PL2_RW,
24
+ lr |= R_V7M_EXCRET_FTYPE_MASK;
32
.type = ARM_CP_CONST, .resetvalue = 0 },
25
+ }
26
+ lr = deposit32(lr, 24, 8, 0xff);
27
+ }
28
+
29
if (arm_feature(env, ARM_FEATURE_V8)) {
30
if (arm_feature(env, ARM_FEATURE_M_SECURITY) &&
31
(lr & R_V7M_EXCRET_S_MASK)) {
32
--
33
--
33
2.20.1
34
2.20.1
34
35
35
36
diff view generated by jsdifflib
1
We are close to running out of TB flags for AArch32; we could
1
From: Richard Henderson <richard.henderson@linaro.org>
2
start using the cs_base word, but before we do that we can
3
economise on our usage by sharing the same bits for the VFP
4
VECSTRIDE field and the XScale XSCALE_CPAR field. This
5
works because no XScale CPU ever had VFP.
6
2
3
We need more information than just the mmu_idx in order
4
to create the proper exception syndrome. Only change the
5
function signature so far.
6
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20200813200816.3037186-2-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
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>
9
Message-id: 20190416125744.27770-18-peter.maydell@linaro.org
10
---
11
---
11
target/arm/cpu.h | 10 ++++++----
12
target/arm/mte_helper.c | 10 +++++-----
12
target/arm/cpu.c | 7 +++++++
13
1 file changed, 5 insertions(+), 5 deletions(-)
13
target/arm/helper.c | 6 +++++-
14
target/arm/translate.c | 9 +++++++--
15
4 files changed, 25 insertions(+), 7 deletions(-)
16
14
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
15
diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
17
--- a/target/arm/mte_helper.c
20
+++ b/target/arm/cpu.h
18
+++ b/target/arm/mte_helper.c
21
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1)
19
@@ -XXX,XX +XXX,XX @@ void HELPER(stzgm_tags)(CPUARMState *env, uint64_t ptr, uint64_t val)
22
FIELD(TBFLAG_A32, THUMB, 0, 1)
20
}
23
FIELD(TBFLAG_A32, VECLEN, 1, 3)
21
24
FIELD(TBFLAG_A32, VECSTRIDE, 4, 2)
22
/* Record a tag check failure. */
25
+/*
23
-static void mte_check_fail(CPUARMState *env, int mmu_idx,
26
+ * We store the bottom two bits of the CPAR as TB flags and handle
24
+static void mte_check_fail(CPUARMState *env, uint32_t desc,
27
+ * checks on the other bits at runtime. This shares the same bits as
25
uint64_t dirty_ptr, uintptr_t ra)
28
+ * VECSTRIDE, which is OK as no XScale CPU has VFP.
26
{
29
+ */
27
+ int mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX);
30
+FIELD(TBFLAG_A32, XSCALE_CPAR, 4, 2)
28
ARMMMUIdx arm_mmu_idx = core_to_aa64_mmu_idx(mmu_idx);
31
/*
29
int el, reg_el, tcf, select;
32
* Indicates whether cp register reads and writes by guest code should access
30
uint64_t sctlr;
33
* the secure or nonsecure bank of banked registers; note that this is not
31
@@ -XXX,XX +XXX,XX @@ uint64_t mte_check1(CPUARMState *env, uint32_t desc,
34
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
35
FIELD(TBFLAG_A32, VFPEN, 7, 1)
36
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
37
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
38
-/* We store the bottom two bits of the CPAR as TB flags and handle
39
- * checks on the other bits at runtime
40
- */
41
-FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2)
42
/* For M profile only, Handler (ie not Thread) mode */
43
FIELD(TBFLAG_A32, HANDLER, 21, 1)
44
/* For M profile only, whether we should generate stack-limit checks */
45
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
46
index XXXXXXX..XXXXXXX 100644
47
--- a/target/arm/cpu.c
48
+++ b/target/arm/cpu.c
49
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
50
set_feature(env, ARM_FEATURE_THUMB_DSP);
51
}
32
}
52
33
53
+ /*
34
if (unlikely(!mte_probe1_int(env, desc, ptr, ra, bit55))) {
54
+ * We rely on no XScale CPU having VFP so we can use the same bits in the
35
- int mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX);
55
+ * TB flags field for VECSTRIDE and XSCALE_CPAR.
36
- mte_check_fail(env, mmu_idx, ptr, ra);
56
+ */
37
+ mte_check_fail(env, desc, ptr, ra);
57
+ assert(!(arm_feature(env, ARM_FEATURE_VFP) &&
58
+ arm_feature(env, ARM_FEATURE_XSCALE)));
59
+
60
if (arm_feature(env, ARM_FEATURE_V7) &&
61
!arm_feature(env, ARM_FEATURE_M) &&
62
!arm_feature(env, ARM_FEATURE_PMSA)) {
63
diff --git a/target/arm/helper.c b/target/arm/helper.c
64
index XXXXXXX..XXXXXXX 100644
65
--- a/target/arm/helper.c
66
+++ b/target/arm/helper.c
67
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
68
|| arm_el_is_aa64(env, 1) || arm_feature(env, ARM_FEATURE_M)) {
69
flags = FIELD_DP32(flags, TBFLAG_A32, VFPEN, 1);
70
}
71
- flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar);
72
+ /* Note that XSCALE_CPAR shares bits with VECSTRIDE */
73
+ if (arm_feature(env, ARM_FEATURE_XSCALE)) {
74
+ flags = FIELD_DP32(flags, TBFLAG_A32,
75
+ XSCALE_CPAR, env->cp15.c15_cpar);
76
+ }
77
}
38
}
78
39
79
flags = FIELD_DP32(flags, TBFLAG_ANY, MMUIDX, arm_to_core_mmu_idx(mmu_idx));
40
return useronly_clean_ptr(ptr);
80
diff --git a/target/arm/translate.c b/target/arm/translate.c
41
@@ -XXX,XX +XXX,XX @@ uint64_t mte_checkN(CPUARMState *env, uint32_t desc,
81
index XXXXXXX..XXXXXXX 100644
42
82
--- a/target/arm/translate.c
43
fail_ofs = tag_first + n * TAG_GRANULE - ptr;
83
+++ b/target/arm/translate.c
44
fail_ofs = ROUND_UP(fail_ofs, esize);
84
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
45
- mte_check_fail(env, mmu_idx, ptr + fail_ofs, ra);
85
dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL);
46
+ mte_check_fail(env, desc, ptr + fail_ofs, ra);
86
dc->vfp_enabled = FIELD_EX32(tb_flags, TBFLAG_A32, VFPEN);
47
}
87
dc->vec_len = FIELD_EX32(tb_flags, TBFLAG_A32, VECLEN);
48
88
- dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE);
49
done:
89
- dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR);
50
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(mte_check_zva)(CPUARMState *env, uint32_t desc, uint64_t ptr)
90
+ if (arm_feature(env, ARM_FEATURE_XSCALE)) {
51
fail:
91
+ dc->c15_cpar = FIELD_EX32(tb_flags, TBFLAG_A32, XSCALE_CPAR);
52
/* Locate the first nibble that differs. */
92
+ dc->vec_stride = 0;
53
i = ctz64(mem_tag ^ ptr_tag) >> 4;
93
+ } else {
54
- mte_check_fail(env, mmu_idx, align_ptr + i * TAG_GRANULE, ra);
94
+ dc->vec_stride = FIELD_EX32(tb_flags, TBFLAG_A32, VECSTRIDE);
55
+ mte_check_fail(env, desc, align_ptr + i * TAG_GRANULE, ra);
95
+ dc->c15_cpar = 0;
56
96
+ }
57
done:
97
dc->v7m_handler_mode = FIELD_EX32(tb_flags, TBFLAG_A32, HANDLER);
58
return useronly_clean_ptr(ptr);
98
dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) &&
99
regime_is_secure(env, dc->mmu_idx);
100
--
59
--
101
2.20.1
60
2.20.1
102
61
103
62
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Since uWireSlave is only used in this new header, there is no
3
According to AArch64.TagCheckFault, none of the other ISS values are
4
need to expose it via "qemu/typedefs.h".
4
provided, so we do not need to go so far as merge_syn_data_abort.
5
But we were missing the WnR bit.
5
6
6
Reviewed-by: Markus Armbruster <armbru@redhat.com>
7
Tested-by: Andrey Konovalov <andreyknvl@google.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reported-by: Andrey Konovalov <andreyknvl@google.com>
8
Message-id: 20190412165416.7977-9-philmd@redhat.com
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20200813200816.3037186-3-richard.henderson@linaro.org
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
13
---
11
include/hw/arm/omap.h | 6 +-----
14
target/arm/mte_helper.c | 9 +++++----
12
include/hw/devices.h | 15 ---------------
15
1 file changed, 5 insertions(+), 4 deletions(-)
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
16
23
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
17
diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c
24
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
25
--- a/include/hw/arm/omap.h
19
--- a/target/arm/mte_helper.c
26
+++ b/include/hw/arm/omap.h
20
+++ b/target/arm/mte_helper.c
27
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc,
28
#include "exec/memory.h"
22
{
29
# define hw_omap_h        "omap.h"
23
int mmu_idx = FIELD_EX32(desc, MTEDESC, MIDX);
30
#include "hw/irq.h"
24
ARMMMUIdx arm_mmu_idx = core_to_aa64_mmu_idx(mmu_idx);
31
+#include "hw/input/tsc2xxx.h"
25
- int el, reg_el, tcf, select;
32
#include "target/arm/cpu-qom.h"
26
+ int el, reg_el, tcf, select, is_write, syn;
33
#include "qemu/log.h"
27
uint64_t sctlr;
34
28
35
@@ -XXX,XX +XXX,XX @@ qemu_irq *omap_mpuio_in_get(struct omap_mpuio_s *s);
29
reg_el = regime_el(env, arm_mmu_idx);
36
void omap_mpuio_out_set(struct omap_mpuio_s *s, int line, qemu_irq handler);
30
@@ -XXX,XX +XXX,XX @@ static void mte_check_fail(CPUARMState *env, uint32_t desc,
37
void omap_mpuio_key(struct omap_mpuio_s *s, int row, int col, int down);
31
*/
38
32
cpu_restore_state(env_cpu(env), ra, true);
39
-struct uWireSlave {
33
env->exception.vaddress = dirty_ptr;
40
- uint16_t (*receive)(void *opaque);
34
- raise_exception(env, EXCP_DATA_ABORT,
41
- void (*send)(void *opaque, uint16_t data);
35
- syn_data_abort_no_iss(el != 0, 0, 0, 0, 0, 0, 0x11),
42
- void *opaque;
36
- exception_target_el(env));
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
+
37
+
94
+#ifndef HW_INPUT_TSC2XXX_H
38
+ is_write = FIELD_EX32(desc, MTEDESC, WRITE);
95
+#define HW_INPUT_TSC2XXX_H
39
+ syn = syn_data_abort_no_iss(el != 0, 0, 0, 0, 0, is_write, 0x11);
96
+
40
+ raise_exception(env, EXCP_DATA_ABORT, syn, exception_target_el(env));
97
+#include "hw/irq.h"
41
/* noreturn, but fall through to the assert anyway */
98
+#include "ui/console.h"
42
99
+
43
case 0:
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
--
44
--
208
2.20.1
45
2.20.1
209
46
210
47
diff view generated by jsdifflib
1
The M-profile floating point support has three associated config
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
registers: FPCAR, FPCCR and FPDSCR. It also makes the registers
3
CPACR and NSACR have behaviour other than reads-as-zero.
4
Add support for all of these as simple reads-as-written registers.
5
We will hook up actual functionality later.
6
2
7
The main complexity here is handling the FPCCR register, which
3
Allow the device to execute the DMA transfers in a different
8
has a mix of banked and unbanked bits.
4
AddressSpace.
9
5
10
Note that we don't share storage with the A-profile
6
The A10 and H3 SoC keep using the system_memory address space,
11
cpu->cp15.nsacr and cpu->cp15.cpacr_el1, though the behaviour
7
but via the proper dma_memory_access() API.
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
8
9
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
11
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
12
Message-id: 20200814110057.307-1-f4bug@amsat.org
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Message-id: 20190416125744.27770-4-peter.maydell@linaro.org
20
---
14
---
21
target/arm/cpu.h | 34 ++++++++++++
15
include/hw/sd/allwinner-sdhost.h | 6 ++++++
22
hw/intc/armv7m_nvic.c | 125 ++++++++++++++++++++++++++++++++++++++++++
16
hw/arm/allwinner-a10.c | 2 ++
23
target/arm/cpu.c | 5 ++
17
hw/arm/allwinner-h3.c | 2 ++
24
target/arm/machine.c | 16 ++++++
18
hw/sd/allwinner-sdhost.c | 37 ++++++++++++++++++++++++++------
25
4 files changed, 180 insertions(+)
19
4 files changed, 41 insertions(+), 6 deletions(-)
26
20
27
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
21
diff --git a/include/hw/sd/allwinner-sdhost.h b/include/hw/sd/allwinner-sdhost.h
28
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/cpu.h
23
--- a/include/hw/sd/allwinner-sdhost.h
30
+++ b/target/arm/cpu.h
24
+++ b/include/hw/sd/allwinner-sdhost.h
31
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
25
@@ -XXX,XX +XXX,XX @@ typedef struct AwSdHostState {
32
uint32_t scr[M_REG_NUM_BANKS];
26
/** Interrupt output signal to notify CPU */
33
uint32_t msplim[M_REG_NUM_BANKS];
27
qemu_irq irq;
34
uint32_t psplim[M_REG_NUM_BANKS];
28
35
+ uint32_t fpcar[M_REG_NUM_BANKS];
29
+ /** Memory region where DMA transfers are done */
36
+ uint32_t fpccr[M_REG_NUM_BANKS];
30
+ MemoryRegion *dma_mr;
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
+
31
+
76
/*
32
+ /** Address space used internally for DMA transfers */
77
* System register ID fields.
33
+ AddressSpace dma_as;
78
*/
34
+
79
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
35
/** Number of bytes left in current DMA transfer */
36
uint32_t transfer_cnt;
37
38
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
80
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
81
--- a/hw/intc/armv7m_nvic.c
40
--- a/hw/arm/allwinner-a10.c
82
+++ b/hw/intc/armv7m_nvic.c
41
+++ b/hw/arm/allwinner-a10.c
83
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
42
@@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
84
}
43
}
85
case 0xd84: /* CSSELR */
44
86
return cpu->env.v7m.csselr[attrs.secure];
45
/* SD/MMC */
87
+ case 0xd88: /* CPACR */
46
+ object_property_set_link(OBJECT(&s->mmc0), "dma-memory",
88
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
47
+ OBJECT(get_system_memory()), &error_fatal);
89
+ return 0;
48
sysbus_realize(SYS_BUS_DEVICE(&s->mmc0), &error_fatal);
90
+ }
49
sysbus_mmio_map(SYS_BUS_DEVICE(&s->mmc0), 0, AW_A10_MMC0_BASE);
91
+ return cpu->env.v7m.cpacr[attrs.secure];
50
sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc0), 0, qdev_get_gpio_in(dev, 32));
92
+ case 0xd8c: /* NSACR */
51
diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
93
+ if (!attrs.secure || !arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
52
index XXXXXXX..XXXXXXX 100644
94
+ return 0;
53
--- a/hw/arm/allwinner-h3.c
95
+ }
54
+++ b/hw/arm/allwinner-h3.c
96
+ return cpu->env.v7m.nsacr;
55
@@ -XXX,XX +XXX,XX @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
97
/* TODO: Implement debug registers. */
56
sysbus_mmio_map(SYS_BUS_DEVICE(&s->sid), 0, s->memmap[AW_H3_SID]);
98
case 0xd90: /* MPU_TYPE */
57
99
/* Unified MPU; if the MPU is not present this value is zero */
58
/* SD/MMC */
100
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
59
+ object_property_set_link(OBJECT(&s->mmc0), "dma-memory",
101
return 0;
60
+ OBJECT(get_system_memory()), &error_fatal);
61
sysbus_realize(SYS_BUS_DEVICE(&s->mmc0), &error_fatal);
62
sysbus_mmio_map(SYS_BUS_DEVICE(&s->mmc0), 0, s->memmap[AW_H3_MMC0]);
63
sysbus_connect_irq(SYS_BUS_DEVICE(&s->mmc0), 0,
64
diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c
65
index XXXXXXX..XXXXXXX 100644
66
--- a/hw/sd/allwinner-sdhost.c
67
+++ b/hw/sd/allwinner-sdhost.c
68
@@ -XXX,XX +XXX,XX @@
69
#include "qemu/log.h"
70
#include "qemu/module.h"
71
#include "qemu/units.h"
72
+#include "qapi/error.h"
73
#include "sysemu/blockdev.h"
74
+#include "sysemu/dma.h"
75
+#include "hw/qdev-properties.h"
76
#include "hw/irq.h"
77
#include "hw/sd/allwinner-sdhost.h"
78
#include "migration/vmstate.h"
79
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
80
uint8_t buf[1024];
81
82
/* Read descriptor */
83
- cpu_physical_memory_read(desc_addr, desc, sizeof(*desc));
84
+ dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc));
85
if (desc->size == 0) {
86
desc->size = klass->max_desc_size;
87
} else if (desc->size > klass->max_desc_size) {
88
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
89
90
/* Write to SD bus */
91
if (is_write) {
92
- cpu_physical_memory_read((desc->addr & DESC_SIZE_MASK) + num_done,
93
- buf, buf_bytes);
94
+ dma_memory_read(&s->dma_as,
95
+ (desc->addr & DESC_SIZE_MASK) + num_done,
96
+ buf, buf_bytes);
97
sdbus_write_data(&s->sdbus, buf, buf_bytes);
98
99
/* Read from SD bus */
100
} else {
101
sdbus_read_data(&s->sdbus, buf, buf_bytes);
102
- cpu_physical_memory_write((desc->addr & DESC_SIZE_MASK) + num_done,
103
- buf, buf_bytes);
104
+ dma_memory_write(&s->dma_as,
105
+ (desc->addr & DESC_SIZE_MASK) + num_done,
106
+ buf, buf_bytes);
102
}
107
}
103
return cpu->env.v7m.sfar;
108
num_done += buf_bytes;
104
+ case 0xf34: /* FPCCR */
105
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
106
+ return 0;
107
+ }
108
+ if (attrs.secure) {
109
+ return cpu->env.v7m.fpccr[M_REG_S];
110
+ } else {
111
+ /*
112
+ * NS can read LSPEN, CLRONRET and MONRDY. It can read
113
+ * BFRDY and HFRDY if AIRCR.BFHFNMINS != 0;
114
+ * other non-banked bits RAZ.
115
+ * TODO: MONRDY should RAZ/WI if DEMCR.SDME is set.
116
+ */
117
+ uint32_t value = cpu->env.v7m.fpccr[M_REG_S];
118
+ uint32_t mask = R_V7M_FPCCR_LSPEN_MASK |
119
+ R_V7M_FPCCR_CLRONRET_MASK |
120
+ R_V7M_FPCCR_MONRDY_MASK;
121
+
122
+ if (s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK) {
123
+ mask |= R_V7M_FPCCR_BFRDY_MASK | R_V7M_FPCCR_HFRDY_MASK;
124
+ }
125
+
126
+ value &= mask;
127
+
128
+ value |= cpu->env.v7m.fpccr[M_REG_NS];
129
+ return value;
130
+ }
131
+ case 0xf38: /* FPCAR */
132
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
133
+ return 0;
134
+ }
135
+ return cpu->env.v7m.fpcar[attrs.secure];
136
+ case 0xf3c: /* FPDSCR */
137
+ if (!arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
138
+ return 0;
139
+ }
140
+ return cpu->env.v7m.fpdscr[attrs.secure];
141
case 0xf40: /* MVFR0 */
142
return cpu->isar.mvfr0;
143
case 0xf44: /* MVFR1 */
144
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
145
cpu->env.v7m.csselr[attrs.secure] = value & R_V7M_CSSELR_INDEX_MASK;
146
}
147
break;
148
+ case 0xd88: /* CPACR */
149
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
150
+ /* We implement only the Floating Point extension's CP10/CP11 */
151
+ cpu->env.v7m.cpacr[attrs.secure] = value & (0xf << 20);
152
+ }
153
+ break;
154
+ case 0xd8c: /* NSACR */
155
+ if (attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
156
+ /* We implement only the Floating Point extension's CP10/CP11 */
157
+ cpu->env.v7m.nsacr = value & (3 << 10);
158
+ }
159
+ break;
160
case 0xd90: /* MPU_TYPE */
161
return; /* RO */
162
case 0xd94: /* MPU_CTRL */
163
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value,
164
}
165
break;
166
}
109
}
167
+ case 0xf34: /* FPCCR */
110
168
+ if (arm_feature(&cpu->env, ARM_FEATURE_VFP)) {
111
/* Clear hold flag and flush descriptor */
169
+ /* Not all bits here are banked. */
112
desc->status &= ~DESC_STATUS_HOLD;
170
+ uint32_t fpccr_s;
113
- cpu_physical_memory_write(desc_addr, desc, sizeof(*desc));
171
+
114
+ dma_memory_write(&s->dma_as, desc_addr, desc, sizeof(*desc));
172
+ if (!arm_feature(&cpu->env, ARM_FEATURE_V8)) {
115
173
+ /* Don't allow setting of bits not present in v7M */
116
return num_done;
174
+ value &= (R_V7M_FPCCR_LSPACT_MASK |
117
}
175
+ R_V7M_FPCCR_USER_MASK |
118
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_allwinner_sdhost = {
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
}
119
}
258
};
120
};
259
121
260
+static const VMStateDescription vmstate_m_fp = {
122
+static Property allwinner_sdhost_properties[] = {
261
+ .name = "cpu/m/fp",
123
+ DEFINE_PROP_LINK("dma-memory", AwSdHostState, dma_mr,
262
+ .version_id = 1,
124
+ TYPE_MEMORY_REGION, MemoryRegion *),
263
+ .minimum_version_id = 1,
125
+ DEFINE_PROP_END_OF_LIST(),
264
+ .needed = vfp_needed,
265
+ .fields = (VMStateField[]) {
266
+ VMSTATE_UINT32_ARRAY(env.v7m.fpcar, ARMCPU, M_REG_NUM_BANKS),
267
+ VMSTATE_UINT32_ARRAY(env.v7m.fpccr, ARMCPU, M_REG_NUM_BANKS),
268
+ VMSTATE_UINT32_ARRAY(env.v7m.fpdscr, ARMCPU, M_REG_NUM_BANKS),
269
+ VMSTATE_UINT32_ARRAY(env.v7m.cpacr, ARMCPU, M_REG_NUM_BANKS),
270
+ VMSTATE_UINT32(env.v7m.nsacr, ARMCPU),
271
+ VMSTATE_END_OF_LIST()
272
+ }
273
+};
126
+};
274
+
127
+
275
static const VMStateDescription vmstate_m = {
128
static void allwinner_sdhost_init(Object *obj)
276
.name = "cpu/m",
129
{
277
.version_id = 4,
130
AwSdHostState *s = AW_SDHOST(obj);
278
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m = {
131
@@ -XXX,XX +XXX,XX @@ static void allwinner_sdhost_init(Object *obj)
279
&vmstate_m_scr,
132
sysbus_init_irq(SYS_BUS_DEVICE(s), &s->irq);
280
&vmstate_m_other_sp,
133
}
281
&vmstate_m_v8m,
134
282
+ &vmstate_m_fp,
135
+static void allwinner_sdhost_realize(DeviceState *dev, Error **errp)
283
NULL
136
+{
284
}
137
+ AwSdHostState *s = AW_SDHOST(dev);
285
};
138
+
139
+ if (!s->dma_mr) {
140
+ error_setg(errp, TYPE_AW_SDHOST " 'dma-memory' link not set");
141
+ return;
142
+ }
143
+
144
+ address_space_init(&s->dma_as, s->dma_mr, "sdhost-dma");
145
+}
146
+
147
static void allwinner_sdhost_reset(DeviceState *dev)
148
{
149
AwSdHostState *s = AW_SDHOST(dev);
150
@@ -XXX,XX +XXX,XX @@ static void allwinner_sdhost_class_init(ObjectClass *klass, void *data)
151
152
dc->reset = allwinner_sdhost_reset;
153
dc->vmsd = &vmstate_allwinner_sdhost;
154
+ dc->realize = allwinner_sdhost_realize;
155
+ device_class_set_props(dc, allwinner_sdhost_properties);
156
}
157
158
static void allwinner_sdhost_sun4i_class_init(ObjectClass *klass, void *data)
286
--
159
--
287
2.20.1
160
2.20.1
288
161
289
162
diff view generated by jsdifflib
1
The M-profile FPCCR.ASPEN bit indicates that automatic floating-point
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
context preservation is enabled. Before executing any floating-point
2
3
instruction, if FPCCR.ASPEN is set and the CONTROL FPCA/SFPA bits
3
Allow the device to execute the DMA transfers in a different
4
indicate that there is no active floating point context then we
4
AddressSpace.
5
must create a new context (by initializing FPSCR and setting
5
6
FPCA/SFPA to indicate that the context is now active). In the
6
The H3 SoC keeps using the system_memory address space,
7
pseudocode this is handled by ExecuteFPCheck().
7
but via the proper dma_memory_access() API.
8
8
9
Implement this with a new TB flag which tracks whether we
9
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
10
need to create a new FP context.
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
11
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
12
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
13
Message-id: 20200814122907.27732-1-f4bug@amsat.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Message-id: 20190416125744.27770-20-peter.maydell@linaro.org
15
---
15
---
16
target/arm/cpu.h | 2 ++
16
include/hw/net/allwinner-sun8i-emac.h | 6 ++++
17
target/arm/translate.h | 1 +
17
hw/arm/allwinner-h3.c | 2 ++
18
target/arm/helper.c | 13 +++++++++++++
18
hw/net/allwinner-sun8i-emac.c | 46 +++++++++++++++++----------
19
target/arm/translate.c | 29 +++++++++++++++++++++++++++++
19
3 files changed, 38 insertions(+), 16 deletions(-)
20
4 files changed, 45 insertions(+)
20
21
21
diff --git a/include/hw/net/allwinner-sun8i-emac.h b/include/hw/net/allwinner-sun8i-emac.h
22
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
23
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/cpu.h
23
--- a/include/hw/net/allwinner-sun8i-emac.h
25
+++ b/target/arm/cpu.h
24
+++ b/include/hw/net/allwinner-sun8i-emac.h
26
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
25
@@ -XXX,XX +XXX,XX @@ typedef struct AwSun8iEmacState {
27
FIELD(TBFLAG_A32, VFPEN, 7, 1)
26
/** Interrupt output signal to notify CPU */
28
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
27
qemu_irq irq;
29
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
28
30
+/* For M profile only, set if we must create a new FP context */
29
+ /** Memory region where DMA transfers are done */
31
+FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1)
30
+ MemoryRegion *dma_mr;
32
/* For M profile only, set if FPCCR.S does not match current security state */
31
+
33
FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1)
32
+ /** Address space used internally for DMA transfers */
34
/* For M profile only, Handler (ie not Thread) mode */
33
+ AddressSpace dma_as;
35
diff --git a/target/arm/translate.h b/target/arm/translate.h
34
+
35
/** Generic Network Interface Controller (NIC) for networking API */
36
NICState *nic;
37
38
diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
36
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/translate.h
40
--- a/hw/arm/allwinner-h3.c
38
+++ b/target/arm/translate.h
41
+++ b/hw/arm/allwinner-h3.c
39
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
42
@@ -XXX,XX +XXX,XX @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
40
bool v8m_secure; /* true if v8M and we're in Secure mode */
43
qemu_check_nic_model(&nd_table[0], TYPE_AW_SUN8I_EMAC);
41
bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */
44
qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]);
42
bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */
45
}
43
+ bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */
46
+ object_property_set_link(OBJECT(&s->emac), "dma-memory",
44
/* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI
47
+ OBJECT(get_system_memory()), &error_fatal);
45
* so that top level loop can generate correct syndrome information.
48
sysbus_realize(SYS_BUS_DEVICE(&s->emac), &error_fatal);
46
*/
49
sysbus_mmio_map(SYS_BUS_DEVICE(&s->emac), 0, s->memmap[AW_H3_EMAC]);
47
diff --git a/target/arm/helper.c b/target/arm/helper.c
50
sysbus_connect_irq(SYS_BUS_DEVICE(&s->emac), 0,
51
diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
48
index XXXXXXX..XXXXXXX 100644
52
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/helper.c
53
--- a/hw/net/allwinner-sun8i-emac.c
50
+++ b/target/arm/helper.c
54
+++ b/hw/net/allwinner-sun8i-emac.c
51
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
55
@@ -XXX,XX +XXX,XX @@
52
flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1);
56
57
#include "qemu/osdep.h"
58
#include "qemu/units.h"
59
+#include "qapi/error.h"
60
#include "hw/sysbus.h"
61
#include "migration/vmstate.h"
62
#include "net/net.h"
63
@@ -XXX,XX +XXX,XX @@
64
#include "net/checksum.h"
65
#include "qemu/module.h"
66
#include "exec/cpu-common.h"
67
+#include "sysemu/dma.h"
68
#include "hw/net/allwinner-sun8i-emac.h"
69
70
/* EMAC register offsets */
71
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_update_irq(AwSun8iEmacState *s)
72
qemu_set_irq(s->irq, (s->int_sta & s->int_en) != 0);
73
}
74
75
-static uint32_t allwinner_sun8i_emac_next_desc(FrameDescriptor *desc,
76
+static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
77
+ FrameDescriptor *desc,
78
size_t min_size)
79
{
80
uint32_t paddr = desc->next;
81
82
- cpu_physical_memory_read(paddr, desc, sizeof(*desc));
83
+ dma_memory_read(&s->dma_as, paddr, desc, sizeof(*desc));
84
85
if ((desc->status & DESC_STATUS_CTL) &&
86
(desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
87
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_next_desc(FrameDescriptor *desc,
53
}
88
}
54
89
}
55
+ if (arm_feature(env, ARM_FEATURE_M) &&
90
56
+ (env->v7m.fpccr[env->v7m.secure] & R_V7M_FPCCR_ASPEN_MASK) &&
91
-static uint32_t allwinner_sun8i_emac_get_desc(FrameDescriptor *desc,
57
+ (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) ||
92
+static uint32_t allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
58
+ (env->v7m.secure &&
93
+ FrameDescriptor *desc,
59
+ !(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)))) {
94
uint32_t start_addr,
60
+ /*
95
size_t min_size)
61
+ * ASPEN is set, but FPCA/SFPA indicate that there is no active
96
{
62
+ * FP context; we must create a new FP context before executing
97
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_get_desc(FrameDescriptor *desc,
63
+ * any FP insn.
98
64
+ */
99
/* Note that the list is a cycle. Last entry points back to the head. */
65
+ flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1);
100
while (desc_addr != 0) {
101
- cpu_physical_memory_read(desc_addr, desc, sizeof(*desc));
102
+ dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc));
103
104
if ((desc->status & DESC_STATUS_CTL) &&
105
(desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
106
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_rx_desc(AwSun8iEmacState *s,
107
FrameDescriptor *desc,
108
size_t min_size)
109
{
110
- return allwinner_sun8i_emac_get_desc(desc, s->rx_desc_curr, min_size);
111
+ return allwinner_sun8i_emac_get_desc(s, desc, s->rx_desc_curr, min_size);
112
}
113
114
static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s,
115
FrameDescriptor *desc,
116
size_t min_size)
117
{
118
- return allwinner_sun8i_emac_get_desc(desc, s->tx_desc_head, min_size);
119
+ return allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_head, min_size);
120
}
121
122
-static void allwinner_sun8i_emac_flush_desc(FrameDescriptor *desc,
123
+static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s,
124
+ FrameDescriptor *desc,
125
uint32_t phys_addr)
126
{
127
- cpu_physical_memory_write(phys_addr, desc, sizeof(*desc));
128
+ dma_memory_write(&s->dma_as, phys_addr, desc, sizeof(*desc));
129
}
130
131
static bool allwinner_sun8i_emac_can_receive(NetClientState *nc)
132
@@ -XXX,XX +XXX,XX @@ static ssize_t allwinner_sun8i_emac_receive(NetClientState *nc,
133
<< RX_DESC_STATUS_FRM_LEN_SHIFT;
134
}
135
136
- cpu_physical_memory_write(desc.addr, buf, desc_bytes);
137
- allwinner_sun8i_emac_flush_desc(&desc, s->rx_desc_curr);
138
+ dma_memory_write(&s->dma_as, desc.addr, buf, desc_bytes);
139
+ allwinner_sun8i_emac_flush_desc(s, &desc, s->rx_desc_curr);
140
trace_allwinner_sun8i_emac_receive(s->rx_desc_curr, desc.addr,
141
desc_bytes);
142
143
@@ -XXX,XX +XXX,XX @@ static ssize_t allwinner_sun8i_emac_receive(NetClientState *nc,
144
bytes_left -= desc_bytes;
145
146
/* Move to the next descriptor */
147
- s->rx_desc_curr = allwinner_sun8i_emac_next_desc(&desc, 64);
148
+ s->rx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc, 64);
149
if (!s->rx_desc_curr) {
150
/* Not enough buffer space available */
151
s->int_sta |= INT_STA_RX_BUF_UA;
152
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s)
153
desc.status |= TX_DESC_STATUS_LENGTH_ERR;
154
break;
155
}
156
- cpu_physical_memory_read(desc.addr, packet_buf + packet_bytes, bytes);
157
+ dma_memory_read(&s->dma_as, desc.addr, packet_buf + packet_bytes, bytes);
158
packet_bytes += bytes;
159
desc.status &= ~DESC_STATUS_CTL;
160
- allwinner_sun8i_emac_flush_desc(&desc, s->tx_desc_curr);
161
+ allwinner_sun8i_emac_flush_desc(s, &desc, s->tx_desc_curr);
162
163
/* After the last descriptor, send the packet */
164
if (desc.status2 & TX_DESC_STATUS2_LAST_DESC) {
165
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s)
166
packet_bytes = 0;
167
transmitted++;
168
}
169
- s->tx_desc_curr = allwinner_sun8i_emac_next_desc(&desc, 0);
170
+ s->tx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc, 0);
171
}
172
173
/* Raise transmit completed interrupt */
174
@@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
175
break;
176
case REG_TX_CUR_BUF: /* Transmit Current Buffer */
177
if (s->tx_desc_curr != 0) {
178
- cpu_physical_memory_read(s->tx_desc_curr, &desc, sizeof(desc));
179
+ dma_memory_read(&s->dma_as, s->tx_desc_curr, &desc, sizeof(desc));
180
value = desc.addr;
181
} else {
182
value = 0;
183
@@ -XXX,XX +XXX,XX @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
184
break;
185
case REG_RX_CUR_BUF: /* Receive Current Buffer */
186
if (s->rx_desc_curr != 0) {
187
- cpu_physical_memory_read(s->rx_desc_curr, &desc, sizeof(desc));
188
+ dma_memory_read(&s->dma_as, s->rx_desc_curr, &desc, sizeof(desc));
189
value = desc.addr;
190
} else {
191
value = 0;
192
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_realize(DeviceState *dev, Error **errp)
193
{
194
AwSun8iEmacState *s = AW_SUN8I_EMAC(dev);
195
196
+ if (!s->dma_mr) {
197
+ error_setg(errp, TYPE_AW_SUN8I_EMAC " 'dma-memory' link not set");
198
+ return;
66
+ }
199
+ }
67
+
200
+
68
*pflags = flags;
201
+ address_space_init(&s->dma_as, s->dma_mr, "emac-dma");
69
*cs_base = 0;
202
+
70
}
203
qemu_macaddr_default_if_unset(&s->conf.macaddr);
71
diff --git a/target/arm/translate.c b/target/arm/translate.c
204
s->nic = qemu_new_nic(&net_allwinner_sun8i_emac_info, &s->conf,
72
index XXXXXXX..XXXXXXX 100644
205
object_get_typename(OBJECT(dev)), dev->id, s);
73
--- a/target/arm/translate.c
206
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_realize(DeviceState *dev, Error **errp)
74
+++ b/target/arm/translate.c
207
static Property allwinner_sun8i_emac_properties[] = {
75
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
208
DEFINE_NIC_PROPERTIES(AwSun8iEmacState, conf),
76
/* Don't need to do this for any further FP insns in this TB */
209
DEFINE_PROP_UINT8("phy-addr", AwSun8iEmacState, mii_phy_addr, 0),
77
s->v8m_fpccr_s_wrong = false;
210
+ DEFINE_PROP_LINK("dma-memory", AwSun8iEmacState, dma_mr,
78
}
211
+ TYPE_MEMORY_REGION, MemoryRegion *),
79
+
212
DEFINE_PROP_END_OF_LIST(),
80
+ if (s->v7m_new_fp_ctxt_needed) {
213
};
81
+ /*
82
+ * Create new FP context by updating CONTROL.FPCA, CONTROL.SFPA
83
+ * and the FPSCR.
84
+ */
85
+ TCGv_i32 control, fpscr;
86
+ uint32_t bits = R_V7M_CONTROL_FPCA_MASK;
87
+
88
+ fpscr = load_cpu_field(v7m.fpdscr[s->v8m_secure]);
89
+ gen_helper_vfp_set_fpscr(cpu_env, fpscr);
90
+ tcg_temp_free_i32(fpscr);
91
+ /*
92
+ * We don't need to arrange to end the TB, because the only
93
+ * parts of FPSCR which we cache in the TB flags are the VECLEN
94
+ * and VECSTRIDE, and those don't exist for M-profile.
95
+ */
96
+
97
+ if (s->v8m_secure) {
98
+ bits |= R_V7M_CONTROL_SFPA_MASK;
99
+ }
100
+ control = load_cpu_field(v7m.control[M_REG_S]);
101
+ tcg_gen_ori_i32(control, control, bits);
102
+ store_cpu_field(control, v7m.control[M_REG_S]);
103
+ /* Don't need to do this for any further FP insns in this TB */
104
+ s->v7m_new_fp_ctxt_needed = false;
105
+ }
106
}
107
108
if (extract32(insn, 28, 4) == 0xf) {
109
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
110
regime_is_secure(env, dc->mmu_idx);
111
dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK);
112
dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG);
113
+ dc->v7m_new_fp_ctxt_needed =
114
+ FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED);
115
dc->cp_regs = cpu->cp_regs;
116
dc->features = env->features;
117
214
118
--
215
--
119
2.20.1
216
2.20.1
120
217
121
218
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
As we want to call qdev_connect_clock_in() before the device
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
is realized, we need to uninline cadence_uart_create() first.
5
Message-id: 20190412165416.7977-8-philmd@redhat.com
5
6
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-id: 20200803105647.22223-2-f4bug@amsat.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
10
---
8
include/hw/devices.h | 3 ---
11
include/hw/char/cadence_uart.h | 17 -----------------
9
include/hw/input/gamepad.h | 19 +++++++++++++++++++
12
hw/arm/xilinx_zynq.c | 14 ++++++++++++--
10
hw/arm/stellaris.c | 2 +-
13
2 files changed, 12 insertions(+), 19 deletions(-)
11
hw/input/stellaris_input.c | 2 +-
12
MAINTAINERS | 1 +
13
5 files changed, 22 insertions(+), 5 deletions(-)
14
create mode 100644 include/hw/input/gamepad.h
15
14
16
diff --git a/include/hw/devices.h b/include/hw/devices.h
15
diff --git a/include/hw/char/cadence_uart.h b/include/hw/char/cadence_uart.h
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/devices.h
17
--- a/include/hw/char/cadence_uart.h
19
+++ b/include/hw/devices.h
18
+++ b/include/hw/char/cadence_uart.h
20
@@ -XXX,XX +XXX,XX @@ void *tsc2005_init(qemu_irq pintdav);
19
@@ -XXX,XX +XXX,XX @@ typedef struct {
21
uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
20
Clock *refclk;
22
void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
21
} CadenceUARTState;
23
22
24
-/* stellaris_input.c */
23
-static inline DeviceState *cadence_uart_create(hwaddr addr,
25
-void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
24
- qemu_irq irq,
25
- Chardev *chr)
26
-{
27
- DeviceState *dev;
28
- SysBusDevice *s;
29
-
30
- dev = qdev_new(TYPE_CADENCE_UART);
31
- s = SYS_BUS_DEVICE(dev);
32
- qdev_prop_set_chr(dev, "chardev", chr);
33
- sysbus_realize_and_unref(s, &error_fatal);
34
- sysbus_mmio_map(s, 0, addr);
35
- sysbus_connect_irq(s, 0, irq);
36
-
37
- return dev;
38
-}
26
-
39
-
27
#endif
40
#endif
28
diff --git a/include/hw/input/gamepad.h b/include/hw/input/gamepad.h
41
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
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
42
index XXXXXXX..XXXXXXX 100644
55
--- a/hw/arm/stellaris.c
43
--- a/hw/arm/xilinx_zynq.c
56
+++ b/hw/arm/stellaris.c
44
+++ b/hw/arm/xilinx_zynq.c
57
@@ -XXX,XX +XXX,XX @@
45
@@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine)
58
#include "hw/sysbus.h"
46
sysbus_create_simple(TYPE_CHIPIDEA, 0xE0002000, pic[53 - IRQ_OFFSET]);
59
#include "hw/ssi/ssi.h"
47
sysbus_create_simple(TYPE_CHIPIDEA, 0xE0003000, pic[76 - IRQ_OFFSET]);
60
#include "hw/arm/arm.h"
48
61
-#include "hw/devices.h"
49
- dev = cadence_uart_create(0xE0000000, pic[59 - IRQ_OFFSET], serial_hd(0));
62
#include "qemu/timer.h"
50
+ dev = qdev_new(TYPE_CADENCE_UART);
63
#include "hw/i2c/i2c.h"
51
+ busdev = SYS_BUS_DEVICE(dev);
64
#include "net/net.h"
52
+ qdev_prop_set_chr(dev, "chardev", serial_hd(0));
65
@@ -XXX,XX +XXX,XX @@
53
+ sysbus_realize_and_unref(busdev, &error_fatal);
66
#include "sysemu/sysemu.h"
54
+ sysbus_mmio_map(busdev, 0, 0xE0000000);
67
#include "hw/arm/armv7m.h"
55
+ sysbus_connect_irq(busdev, 0, pic[59 - IRQ_OFFSET]);
68
#include "hw/char/pl011.h"
56
qdev_connect_clock_in(dev, "refclk",
69
+#include "hw/input/gamepad.h"
57
qdev_get_clock_out(slcr, "uart0_ref_clk"));
70
#include "hw/watchdog/cmsdk-apb-watchdog.h"
58
- dev = cadence_uart_create(0xE0001000, pic[82 - IRQ_OFFSET], serial_hd(1));
71
#include "hw/misc/unimp.h"
59
+ dev = qdev_new(TYPE_CADENCE_UART);
72
#include "cpu.h"
60
+ busdev = SYS_BUS_DEVICE(dev);
73
diff --git a/hw/input/stellaris_input.c b/hw/input/stellaris_input.c
61
+ qdev_prop_set_chr(dev, "chardev", serial_hd(1));
74
index XXXXXXX..XXXXXXX 100644
62
+ sysbus_realize_and_unref(busdev, &error_fatal);
75
--- a/hw/input/stellaris_input.c
63
+ sysbus_mmio_map(busdev, 0, 0xE0001000);
76
+++ b/hw/input/stellaris_input.c
64
+ sysbus_connect_irq(busdev, 0, pic[82 - IRQ_OFFSET]);
77
@@ -XXX,XX +XXX,XX @@
65
qdev_connect_clock_in(dev, "refclk",
78
*/
66
qdev_get_clock_out(slcr, "uart1_ref_clk"));
79
#include "qemu/osdep.h"
67
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
--
68
--
99
2.20.1
69
2.20.1
100
70
101
71
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Reviewed-by: Thomas Huth <thuth@redhat.com>
3
Clock canonical name is set in device_set_realized (see the block
4
Reviewed-by: Markus Armbruster <armbru@redhat.com>
4
added to hw/core/qdev.c in commit 0e6934f264).
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
If we connect a clock after the device is realized, this code is
6
Message-id: 20190412165416.7977-7-philmd@redhat.com
6
not executed. This is currently not a problem as this name is only
7
used for trace events, however this disrupt tracing.
8
9
Fix by calling qdev_connect_clock_in() before realizing.
10
11
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
13
Message-id: 20200803105647.22223-3-f4bug@amsat.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
15
---
9
include/hw/devices.h | 14 --------------
16
hw/arm/xilinx_zynq.c | 18 +++++++++---------
10
include/hw/misc/cbus.h | 32 ++++++++++++++++++++++++++++++++
17
1 file changed, 9 insertions(+), 9 deletions(-)
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
18
17
diff --git a/include/hw/devices.h b/include/hw/devices.h
19
diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
18
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/devices.h
21
--- a/hw/arm/xilinx_zynq.c
20
+++ b/include/hw/devices.h
22
+++ b/hw/arm/xilinx_zynq.c
21
@@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
23
@@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine)
22
/* stellaris_input.c */
24
1, 0x0066, 0x0022, 0x0000, 0x0000, 0x0555, 0x2aa,
23
void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
25
0);
24
26
25
-/* cbus.c */
27
- /* Create slcr, keep a pointer to connect clocks */
26
-typedef struct {
28
- slcr = qdev_new("xilinx,zynq_slcr");
27
- qemu_irq clk;
29
- sysbus_realize_and_unref(SYS_BUS_DEVICE(slcr), &error_fatal);
28
- qemu_irq dat;
30
- sysbus_mmio_map(SYS_BUS_DEVICE(slcr), 0, 0xF8000000);
29
- qemu_irq sel;
30
-} CBus;
31
-CBus *cbus_init(qemu_irq dat_out);
32
-void cbus_attach(CBus *bus, void *slave_opaque);
33
-
31
-
34
-void *retu_init(qemu_irq irq, int vilma);
32
/* Create the main clock source, and feed slcr with it */
35
-void *tahvo_init(qemu_irq irq, int betty);
33
zynq_machine->ps_clk = CLOCK(object_new(TYPE_CLOCK));
36
-
34
object_property_add_child(OBJECT(zynq_machine), "ps_clk",
37
-void retu_key_event(void *retu, int state);
35
OBJECT(zynq_machine->ps_clk));
38
-
36
object_unref(OBJECT(zynq_machine->ps_clk));
39
#endif
37
clock_set_hz(zynq_machine->ps_clk, PS_CLK_FREQUENCY);
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
+
38
+
58
+#ifndef HW_MISC_CBUS_H
39
+ /* Create slcr, keep a pointer to connect clocks */
59
+#define HW_MISC_CBUS_H
40
+ slcr = qdev_new("xilinx,zynq_slcr");
60
+
41
qdev_connect_clock_in(slcr, "ps_clk", zynq_machine->ps_clk);
61
+#include "hw/irq.h"
42
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(slcr), &error_fatal);
62
+
43
+ sysbus_mmio_map(SYS_BUS_DEVICE(slcr), 0, 0xF8000000);
63
+typedef struct {
44
64
+ qemu_irq clk;
45
dev = qdev_new(TYPE_A9MPCORE_PRIV);
65
+ qemu_irq dat;
46
qdev_prop_set_uint32(dev, "num-cpu", 1);
66
+ qemu_irq sel;
47
@@ -XXX,XX +XXX,XX @@ static void zynq_init(MachineState *machine)
67
+} CBus;
48
dev = qdev_new(TYPE_CADENCE_UART);
68
+
49
busdev = SYS_BUS_DEVICE(dev);
69
+CBus *cbus_init(qemu_irq dat_out);
50
qdev_prop_set_chr(dev, "chardev", serial_hd(0));
70
+void cbus_attach(CBus *bus, void *slave_opaque);
51
+ qdev_connect_clock_in(dev, "refclk",
71
+
52
+ qdev_get_clock_out(slcr, "uart0_ref_clk"));
72
+void *retu_init(qemu_irq irq, int vilma);
53
sysbus_realize_and_unref(busdev, &error_fatal);
73
+void *tahvo_init(qemu_irq irq, int betty);
54
sysbus_mmio_map(busdev, 0, 0xE0000000);
74
+
55
sysbus_connect_irq(busdev, 0, pic[59 - IRQ_OFFSET]);
75
+void retu_key_event(void *retu, int state);
56
- qdev_connect_clock_in(dev, "refclk",
76
+
57
- qdev_get_clock_out(slcr, "uart0_ref_clk"));
77
+#endif
58
dev = qdev_new(TYPE_CADENCE_UART);
78
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
59
busdev = SYS_BUS_DEVICE(dev);
79
index XXXXXXX..XXXXXXX 100644
60
qdev_prop_set_chr(dev, "chardev", serial_hd(1));
80
--- a/hw/arm/nseries.c
61
+ qdev_connect_clock_in(dev, "refclk",
81
+++ b/hw/arm/nseries.c
62
+ qdev_get_clock_out(slcr, "uart1_ref_clk"));
82
@@ -XXX,XX +XXX,XX @@
63
sysbus_realize_and_unref(busdev, &error_fatal);
83
#include "hw/i2c/i2c.h"
64
sysbus_mmio_map(busdev, 0, 0xE0001000);
84
#include "hw/devices.h"
65
sysbus_connect_irq(busdev, 0, pic[82 - IRQ_OFFSET]);
85
#include "hw/display/blizzard.h"
66
- qdev_connect_clock_in(dev, "refclk",
86
+#include "hw/misc/cbus.h"
67
- qdev_get_clock_out(slcr, "uart1_ref_clk"));
87
#include "hw/misc/tmp105.h"
68
88
#include "hw/block/flash.h"
69
sysbus_create_varargs("cadence_ttc", 0xF8001000,
89
#include "hw/hw.h"
70
pic[42-IRQ_OFFSET], pic[43-IRQ_OFFSET], pic[44-IRQ_OFFSET], NULL);
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
--
71
--
116
2.20.1
72
2.20.1
117
73
118
74
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Reviewed-by: Thomas Huth <thuth@redhat.com>
3
We want to assert the device is not realized. To avoid overloading
4
Reviewed-by: Markus Armbruster <armbru@redhat.com>
4
this header including "hw/qdev-core.h", uninline the function first.
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
5
6
Message-id: 20190412165416.7977-11-philmd@redhat.com
6
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
8
Message-id: 20200803105647.22223-4-f4bug@amsat.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
10
---
9
include/hw/net/ne2000-isa.h | 6 ++++++
11
include/hw/qdev-clock.h | 6 +-----
10
1 file changed, 6 insertions(+)
12
hw/core/qdev-clock.c | 5 +++++
13
2 files changed, 6 insertions(+), 5 deletions(-)
11
14
12
diff --git a/include/hw/net/ne2000-isa.h b/include/hw/net/ne2000-isa.h
15
diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h
13
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
14
--- a/include/hw/net/ne2000-isa.h
17
--- a/include/hw/qdev-clock.h
15
+++ b/include/hw/net/ne2000-isa.h
18
+++ b/include/hw/qdev-clock.h
16
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ Clock *qdev_get_clock_out(DeviceState *dev, const char *name);
17
* This work is licensed under the terms of the GNU GPL, version 2 or later.
20
* Set the source clock of input clock @name of device @dev to @source.
18
* See the COPYING file in the top-level directory.
21
* @source period update will be propagated to @name clock.
19
*/
22
*/
20
+
23
-static inline void qdev_connect_clock_in(DeviceState *dev, const char *name,
21
+#ifndef HW_NET_NE2K_ISA_H
24
- Clock *source)
22
+#define HW_NET_NE2K_ISA_H
25
-{
23
+
26
- clock_set_source(qdev_get_clock_in(dev, name), source);
24
#include "hw/hw.h"
27
-}
25
#include "hw/qdev.h"
28
+void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source);
26
#include "hw/isa/isa.h"
29
27
@@ -XXX,XX +XXX,XX @@ static inline ISADevice *isa_ne2000_init(ISABus *bus, int base, int irq,
30
/**
28
}
31
* qdev_alias_clock:
29
return d;
32
diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/core/qdev-clock.c
35
+++ b/hw/core/qdev-clock.c
36
@@ -XXX,XX +XXX,XX @@ Clock *qdev_alias_clock(DeviceState *dev, const char *name,
37
38
return ncl->clock;
30
}
39
}
31
+
40
+
32
+#endif
41
+void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source)
42
+{
43
+ clock_set_source(qdev_get_clock_in(dev, name), source);
44
+}
33
--
45
--
34
2.20.1
46
2.20.1
35
47
36
48
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Add an entries the Blizzard device in MAINTAINERS.
3
Clock canonical name is set in device_set_realized (see the block
4
added to hw/core/qdev.c in commit 0e6934f264).
5
If we connect a clock after the device is realized, this code is
6
not executed. This is currently not a problem as this name is only
7
used for trace events, however this disrupt tracing.
4
8
5
Reviewed-by: Thomas Huth <thuth@redhat.com>
9
Add a comment to document qdev_connect_clock_in() must be called
6
Reviewed-by: Markus Armbruster <armbru@redhat.com>
10
before the device is realized, and assert this condition.
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
8
Message-id: 20190412165416.7977-6-philmd@redhat.com
12
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
13
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
14
Message-id: 20200803105647.22223-5-f4bug@amsat.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
16
---
11
include/hw/devices.h | 7 -------
17
include/hw/qdev-clock.h | 2 ++
12
include/hw/display/blizzard.h | 22 ++++++++++++++++++++++
18
hw/core/qdev-clock.c | 1 +
13
hw/arm/nseries.c | 1 +
19
2 files changed, 3 insertions(+)
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
20
19
diff --git a/include/hw/devices.h b/include/hw/devices.h
21
diff --git a/include/hw/qdev-clock.h b/include/hw/qdev-clock.h
20
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
21
--- a/include/hw/devices.h
23
--- a/include/hw/qdev-clock.h
22
+++ b/include/hw/devices.h
24
+++ b/include/hw/qdev-clock.h
23
@@ -XXX,XX +XXX,XX @@ void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
25
@@ -XXX,XX +XXX,XX @@ Clock *qdev_get_clock_out(DeviceState *dev, const char *name);
24
/* stellaris_input.c */
26
*
25
void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode);
27
* Set the source clock of input clock @name of device @dev to @source.
26
28
* @source period update will be propagated to @name clock.
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
+ *
29
+ *
46
+ * Copyright (C) 2008 Nokia Corporation
30
+ * Must be called before @dev is realized.
47
+ * Written by Andrzej Zaborowski
31
*/
48
+ *
32
void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source);
49
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
33
50
+ * See the COPYING file in the top-level directory.
34
diff --git a/hw/core/qdev-clock.c b/hw/core/qdev-clock.c
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
35
index XXXXXXX..XXXXXXX 100644
67
--- a/hw/arm/nseries.c
36
--- a/hw/core/qdev-clock.c
68
+++ b/hw/arm/nseries.c
37
+++ b/hw/core/qdev-clock.c
69
@@ -XXX,XX +XXX,XX @@
38
@@ -XXX,XX +XXX,XX @@ Clock *qdev_alias_clock(DeviceState *dev, const char *name,
70
#include "hw/boards.h"
39
71
#include "hw/i2c/i2c.h"
40
void qdev_connect_clock_in(DeviceState *dev, const char *name, Clock *source)
72
#include "hw/devices.h"
41
{
73
+#include "hw/display/blizzard.h"
42
+ assert(!dev->realized);
74
#include "hw/misc/tmp105.h"
43
clock_set_source(qdev_get_clock_in(dev, name), source);
75
#include "hw/block/flash.h"
44
}
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
--
45
--
108
2.20.1
46
2.20.1
109
47
110
48
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Suggested-by: Markus Armbruster <armbru@redhat.com>
3
To better align the read/write accesses, display the value after
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
the offset (read accesses only display the offset).
5
Message-id: 20190412165416.7977-3-philmd@redhat.com
5
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Message-id: 20200812190206.31595-2-f4bug@amsat.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
10
---
9
hw/arm/nseries.c | 3 ++-
11
hw/misc/unimp.c | 8 ++++----
10
1 file changed, 2 insertions(+), 1 deletion(-)
12
1 file changed, 4 insertions(+), 4 deletions(-)
11
13
12
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
14
diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c
13
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/arm/nseries.c
16
--- a/hw/misc/unimp.c
15
+++ b/hw/arm/nseries.c
17
+++ b/hw/misc/unimp.c
16
@@ -XXX,XX +XXX,XX @@
18
@@ -XXX,XX +XXX,XX @@ static uint64_t unimp_read(void *opaque, hwaddr offset, unsigned size)
17
#include "hw/boards.h"
19
{
18
#include "hw/i2c/i2c.h"
20
UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque);
19
#include "hw/devices.h"
21
20
+#include "hw/misc/tmp105.h"
22
- qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read "
21
#include "hw/block/flash.h"
23
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read "
22
#include "hw/hw.h"
24
"(size %d, offset 0x%" HWADDR_PRIx ")\n",
23
#include "hw/bt.h"
25
s->name, size, offset);
24
@@ -XXX,XX +XXX,XX @@ static void n8x0_i2c_setup(struct n800_s *s)
26
return 0;
25
qemu_register_powerdown_notifier(&n8x0_system_powerdown_notifier);
27
@@ -XXX,XX +XXX,XX @@ static void unimp_write(void *opaque, hwaddr offset,
26
28
UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque);
27
/* Attach a TMP105 PM chip (A0 wired to ground) */
29
28
- dev = i2c_create_slave(i2c, "tmp105", N8X0_TMP105_ADDR);
30
qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write "
29
+ dev = i2c_create_slave(i2c, TYPE_TMP105, N8X0_TMP105_ADDR);
31
- "(size %d, value 0x%" PRIx64
30
qdev_connect_gpio_out(dev, 0, tmp_irq);
32
- ", offset 0x%" HWADDR_PRIx ")\n",
33
- s->name, size, value, offset);
34
+ "(size %d, offset 0x%" HWADDR_PRIx
35
+ ", value 0x%" PRIx64 ")\n",
36
+ s->name, size, offset, value);
31
}
37
}
32
38
39
static const MemoryRegionOps unimp_ops = {
33
--
40
--
34
2.20.1
41
2.20.1
35
42
36
43
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Reviewed-by: Thomas Huth <thuth@redhat.com>
3
To quickly notice the access size, display the value with the
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
4
width of the access (i.e. 16-bit access is displayed 0x0000,
5
Reviewed-by: Markus Armbruster <armbru@redhat.com>
5
while 8-bit access 0x00).
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
7
Message-id: 20190412165416.7977-2-philmd@redhat.com
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20200812190206.31595-3-f4bug@amsat.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
11
---
10
hw/arm/aspeed.c | 13 +++++++++----
12
hw/misc/unimp.c | 4 ++--
11
1 file changed, 9 insertions(+), 4 deletions(-)
13
1 file changed, 2 insertions(+), 2 deletions(-)
12
14
13
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
15
diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/aspeed.c
17
--- a/hw/misc/unimp.c
16
+++ b/hw/arm/aspeed.c
18
+++ b/hw/misc/unimp.c
17
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@ static void unimp_write(void *opaque, hwaddr offset,
18
#include "hw/arm/aspeed_soc.h"
20
19
#include "hw/boards.h"
21
qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write "
20
#include "hw/i2c/smbus_eeprom.h"
22
"(size %d, offset 0x%" HWADDR_PRIx
21
+#include "hw/misc/pca9552.h"
23
- ", value 0x%" PRIx64 ")\n",
22
+#include "hw/misc/tmp105.h"
24
- s->name, size, offset, value);
23
#include "qemu/log.h"
25
+ ", value 0x%0*" PRIx64 ")\n",
24
#include "sysemu/block-backend.h"
26
+ s->name, size, offset, size << 1, value);
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
}
27
}
62
28
29
static const MemoryRegionOps unimp_ops = {
63
--
30
--
64
2.20.1
31
2.20.1
65
32
66
33
diff view generated by jsdifflib
1
The M-profile CONTROL register has two bits -- SFPA and FPCA --
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
which relate to floating-point support, and should be RES0 otherwise.
3
Handle them correctly in the MSR/MRS register access code.
4
Neither is banked between security states, so they are stored
5
in v7m.control[M_REG_S] regardless of current security state.
6
2
3
To have a better idea of how big is the region where the offset
4
belongs, display the value with the width of the region size
5
(i.e. a region of 0x1000 bytes uses 0x000 format).
6
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20200812190206.31595-4-f4bug@amsat.org
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>
9
Message-id: 20190416125744.27770-9-peter.maydell@linaro.org
10
---
11
---
11
target/arm/helper.c | 57 ++++++++++++++++++++++++++++++++++++++-------
12
include/hw/misc/unimp.h | 1 +
12
1 file changed, 49 insertions(+), 8 deletions(-)
13
hw/misc/unimp.c | 10 ++++++----
14
2 files changed, 7 insertions(+), 4 deletions(-)
13
15
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
diff --git a/include/hw/misc/unimp.h b/include/hw/misc/unimp.h
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
18
--- a/include/hw/misc/unimp.h
17
+++ b/target/arm/helper.c
19
+++ b/include/hw/misc/unimp.h
18
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
20
@@ -XXX,XX +XXX,XX @@
19
return xpsr_read(env) & mask;
21
typedef struct {
20
break;
22
SysBusDevice parent_obj;
21
case 20: /* CONTROL */
23
MemoryRegion iomem;
22
- return env->v7m.control[env->v7m.secure];
24
+ unsigned offset_fmt_width;
23
+ {
25
char *name;
24
+ uint32_t value = env->v7m.control[env->v7m.secure];
26
uint64_t size;
25
+ if (!env->v7m.secure) {
27
} UnimplementedDeviceState;
26
+ /* SFPA is RAZ/WI from NS; FPCA is stored in the M_REG_S bank */
28
diff --git a/hw/misc/unimp.c b/hw/misc/unimp.c
27
+ value |= env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK;
29
index XXXXXXX..XXXXXXX 100644
28
+ }
30
--- a/hw/misc/unimp.c
29
+ return value;
31
+++ b/hw/misc/unimp.c
30
+ }
32
@@ -XXX,XX +XXX,XX @@ static uint64_t unimp_read(void *opaque, hwaddr offset, unsigned size)
31
case 0x94: /* CONTROL_NS */
33
UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque);
32
/* We have to handle this here because unprivileged Secure code
34
33
* can read the NS CONTROL register.
35
qemu_log_mask(LOG_UNIMP, "%s: unimplemented device read "
34
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
36
- "(size %d, offset 0x%" HWADDR_PRIx ")\n",
35
if (!env->v7m.secure) {
37
- s->name, size, offset);
36
return 0;
38
+ "(size %d, offset 0x%0*" HWADDR_PRIx ")\n",
37
}
39
+ s->name, size, s->offset_fmt_width, offset);
38
- return env->v7m.control[M_REG_NS];
40
return 0;
39
+ return env->v7m.control[M_REG_NS] |
41
}
40
+ (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK);
42
41
}
43
@@ -XXX,XX +XXX,XX @@ static void unimp_write(void *opaque, hwaddr offset,
42
44
UnimplementedDeviceState *s = UNIMPLEMENTED_DEVICE(opaque);
43
if (el == 0) {
45
44
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
46
qemu_log_mask(LOG_UNIMP, "%s: unimplemented device write "
45
*/
47
- "(size %d, offset 0x%" HWADDR_PRIx
46
uint32_t mask = extract32(maskreg, 8, 4);
48
+ "(size %d, offset 0x%0*" HWADDR_PRIx
47
uint32_t reg = extract32(maskreg, 0, 8);
49
", value 0x%0*" PRIx64 ")\n",
48
+ int cur_el = arm_current_el(env);
50
- s->name, size, offset, size << 1, value);
49
51
+ s->name, size, s->offset_fmt_width, offset, size << 1, value);
50
- if (arm_current_el(env) == 0 && reg > 7) {
52
}
51
- /* only xPSR sub-fields may be written by unprivileged */
53
52
+ if (cur_el == 0 && reg > 7 && reg != 20) {
54
static const MemoryRegionOps unimp_ops = {
53
+ /*
55
@@ -XXX,XX +XXX,XX @@ static void unimp_realize(DeviceState *dev, Error **errp)
54
+ * only xPSR sub-fields and CONTROL.SFPA may be written by
55
+ * unprivileged code
56
+ */
57
return;
56
return;
58
}
57
}
59
58
60
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
59
+ s->offset_fmt_width = DIV_ROUND_UP(64 - clz64(s->size - 1), 4);
61
env->v7m.control[M_REG_NS] &= ~R_V7M_CONTROL_NPRIV_MASK;
60
+
62
env->v7m.control[M_REG_NS] |= val & R_V7M_CONTROL_NPRIV_MASK;
61
memory_region_init_io(&s->iomem, OBJECT(s), &unimp_ops, s,
63
}
62
s->name, s->size);
64
+ /*
63
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
65
+ * SFPA is RAZ/WI from NS. FPCA is RO if NSACR.CP10 == 0,
66
+ * RES0 if the FPU is not present, and is stored in the S bank
67
+ */
68
+ if (arm_feature(env, ARM_FEATURE_VFP) &&
69
+ extract32(env->v7m.nsacr, 10, 1)) {
70
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
71
+ env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK;
72
+ }
73
return;
74
case 0x98: /* SP_NS */
75
{
76
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val)
77
env->v7m.faultmask[env->v7m.secure] = val & 1;
78
break;
79
case 20: /* CONTROL */
80
- /* Writing to the SPSEL bit only has an effect if we are in
81
+ /*
82
+ * Writing to the SPSEL bit only has an effect if we are in
83
* thread mode; other bits can be updated by any privileged code.
84
* write_v7m_control_spsel() deals with updating the SPSEL bit in
85
* env->v7m.control, so we only need update the others.
86
* For v7M, we must just ignore explicit writes to SPSEL in handler
87
* mode; for v8M the write is permitted but will have no effect.
88
+ * All these bits are writes-ignored from non-privileged code,
89
+ * except for SFPA.
90
*/
91
- if (arm_feature(env, ARM_FEATURE_V8) ||
92
- !arm_v7m_is_handler_mode(env)) {
93
+ if (cur_el > 0 && (arm_feature(env, ARM_FEATURE_V8) ||
94
+ !arm_v7m_is_handler_mode(env))) {
95
write_v7m_control_spsel(env, (val & R_V7M_CONTROL_SPSEL_MASK) != 0);
96
}
97
- if (arm_feature(env, ARM_FEATURE_M_MAIN)) {
98
+ if (cur_el > 0 && arm_feature(env, ARM_FEATURE_M_MAIN)) {
99
env->v7m.control[env->v7m.secure] &= ~R_V7M_CONTROL_NPRIV_MASK;
100
env->v7m.control[env->v7m.secure] |= val & R_V7M_CONTROL_NPRIV_MASK;
101
}
102
+ if (arm_feature(env, ARM_FEATURE_VFP)) {
103
+ /*
104
+ * SFPA is RAZ/WI from NS or if no FPU.
105
+ * FPCA is RO if NSACR.CP10 == 0, RES0 if the FPU is not present.
106
+ * Both are stored in the S bank.
107
+ */
108
+ if (env->v7m.secure) {
109
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
110
+ env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_SFPA_MASK;
111
+ }
112
+ if (cur_el > 0 &&
113
+ (env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_SECURITY) ||
114
+ extract32(env->v7m.nsacr, 10, 1))) {
115
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
116
+ env->v7m.control[M_REG_S] |= val & R_V7M_CONTROL_FPCA_MASK;
117
+ }
118
+ }
119
break;
120
default:
121
bad_reg:
122
--
64
--
123
2.20.1
65
2.20.1
124
66
125
67
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Eduardo Habkost <ehabkost@redhat.com>
2
2
3
This device is used by both ARM (BCM2836, for raspi2) and AArch64
3
TYPE_ARM_SSE is a TYPE_SYS_BUS_DEVICE subclass, but
4
(BCM2837, for raspi3) targets, and is not CPU-specific.
4
ARMSSEClass::parent_class is declared as DeviceClass.
5
Move it to common object, so we build it once for all targets.
6
5
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6
It never caused any problems by pure luck:
8
Message-id: 20190427133028.12874-1-philmd@redhat.com
7
8
We were not setting class_size for TYPE_ARM_SSE, so class_size of
9
TYPE_SYS_BUS_DEVICE was being used (sizeof(SysBusDeviceClass)).
10
This made the system allocate enough memory for TYPE_ARM_SSE
11
devices even though ARMSSEClass was too small for a sysbus
12
device.
13
14
Additionally, the ARMSSEClass::info field ended up at the same
15
offset as SysBusDeviceClass::explicit_ofw_unit_address. This
16
would make sysbus_get_fw_dev_path() crash for the device.
17
Luckily, sysbus_get_fw_dev_path() never gets called for
18
TYPE_ARM_SSE devices, because qdev_get_fw_dev_path() is only used
19
by the boot device code, and TYPE_ARM_SSE devices don't appear at
20
the fw_boot_order list.
21
22
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
23
Message-id: 20200826181006.4097163-1-ehabkost@redhat.com
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
24
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
25
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
26
---
12
hw/dma/Makefile.objs | 2 +-
27
include/hw/arm/armsse.h | 2 +-
13
1 file changed, 1 insertion(+), 1 deletion(-)
28
hw/arm/armsse.c | 1 +
29
2 files changed, 2 insertions(+), 1 deletion(-)
14
30
15
diff --git a/hw/dma/Makefile.objs b/hw/dma/Makefile.objs
31
diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h
16
index XXXXXXX..XXXXXXX 100644
32
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/dma/Makefile.objs
33
--- a/include/hw/arm/armsse.h
18
+++ b/hw/dma/Makefile.objs
34
+++ b/include/hw/arm/armsse.h
19
@@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx-zdma.o
35
@@ -XXX,XX +XXX,XX @@ typedef struct ARMSSE {
20
36
typedef struct ARMSSEInfo ARMSSEInfo;
21
obj-$(CONFIG_OMAP) += omap_dma.o soc_dma.o
37
22
obj-$(CONFIG_PXA2XX) += pxa2xx_dma.o
38
typedef struct ARMSSEClass {
23
-obj-$(CONFIG_RASPI) += bcm2835_dma.o
39
- DeviceClass parent_class;
24
+common-obj-$(CONFIG_RASPI) += bcm2835_dma.o
40
+ SysBusDeviceClass parent_class;
41
const ARMSSEInfo *info;
42
} ARMSSEClass;
43
44
diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/arm/armsse.c
47
+++ b/hw/arm/armsse.c
48
@@ -XXX,XX +XXX,XX @@ static const TypeInfo armsse_info = {
49
.name = TYPE_ARMSSE,
50
.parent = TYPE_SYS_BUS_DEVICE,
51
.instance_size = sizeof(ARMSSE),
52
+ .class_size = sizeof(ARMSSEClass),
53
.instance_init = armsse_init,
54
.abstract = true,
55
.interfaces = (InterfaceInfo[]) {
25
--
56
--
26
2.20.1
57
2.20.1
27
58
28
59
diff view generated by jsdifflib
1
Implement the code which updates the FPCCR register on an
1
From: Richard Henderson <richard.henderson@linaro.org>
2
exception entry where we are going to use lazy FP stacking.
3
We have to defer to the NVIC to determine whether the
4
various exceptions are currently ready or not.
5
2
3
Add left-shift to match the existing right-shift.
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20200815013145.539409-2-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20190416125744.27770-12-peter.maydell@linaro.org
8
---
9
---
9
target/arm/cpu.h | 14 +++++++++
10
include/qemu/int128.h | 16 ++++++++++++++++
10
hw/intc/armv7m_nvic.c | 34 ++++++++++++++++++++++
11
1 file changed, 16 insertions(+)
11
target/arm/helper.c | 67 ++++++++++++++++++++++++++++++++++++++++++-
12
3 files changed, 114 insertions(+), 1 deletion(-)
13
12
14
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
13
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/cpu.h
15
--- a/include/qemu/int128.h
17
+++ b/target/arm/cpu.h
16
+++ b/include/qemu/int128.h
18
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque);
17
@@ -XXX,XX +XXX,XX @@ static inline Int128 int128_rshift(Int128 a, int n)
19
* (Ignoring -1, this is the same as the RETTOBASE value before completion.)
18
return a >> n;
20
*/
21
int armv7m_nvic_complete_irq(void *opaque, int irq, bool secure);
22
+/**
23
+ * armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
24
+ * @opaque: the NVIC
25
+ * @irq: the exception number to mark pending
26
+ * @secure: false for non-banked exceptions or for the nonsecure
27
+ * version of a banked exception, true for the secure version of a banked
28
+ * exception.
29
+ *
30
+ * Return whether an exception is "ready", i.e. whether the exception is
31
+ * enabled and is configured at a priority which would allow it to
32
+ * interrupt the current execution priority. This controls whether the
33
+ * RDY bit for it in the FPCCR is set.
34
+ */
35
+bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure);
36
/**
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
}
19
}
46
20
47
+bool armv7m_nvic_get_ready_status(void *opaque, int irq, bool secure)
21
+static inline Int128 int128_lshift(Int128 a, int n)
48
+{
22
+{
49
+ /*
23
+ return a << n;
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
+}
24
+}
80
+
25
+
81
/* callback when external interrupt line is changed */
26
static inline Int128 int128_add(Int128 a, Int128 b)
82
static void set_irq_level(void *opaque, int n, int level)
83
{
27
{
84
diff --git a/target/arm/helper.c b/target/arm/helper.c
28
return a + b;
85
index XXXXXXX..XXXXXXX 100644
29
@@ -XXX,XX +XXX,XX @@ static inline Int128 int128_rshift(Int128 a, int n)
86
--- a/target/arm/helper.c
30
}
87
+++ b/target/arm/helper.c
88
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
89
env->thumb = addr & 1;
90
}
31
}
91
32
92
+static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr,
33
+static inline Int128 int128_lshift(Int128 a, int n)
93
+ bool apply_splim)
94
+{
34
+{
95
+ /*
35
+ uint64_t l = a.lo << (n & 63);
96
+ * Like the pseudocode UpdateFPCCR: save state in FPCAR and FPCCR
36
+ if (n >= 64) {
97
+ * that we will need later in order to do lazy FP reg stacking.
37
+ return int128_make128(0, l);
98
+ */
38
+ } else if (n > 0) {
99
+ bool is_secure = env->v7m.secure;
39
+ return int128_make128(l, (a.hi << n) | (a.lo >> (64 - n)));
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
+ }
40
+ }
123
+
41
+ return a;
124
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, LSPACT, 1);
125
+
126
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, S, is_secure);
127
+
128
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, USER, arm_current_el(env) == 0);
129
+
130
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, THREAD,
131
+ !arm_v7m_is_handler_mode(env));
132
+
133
+ hfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_HARD, false);
134
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, HFRDY, hfrdy);
135
+
136
+ bfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_BUS, false);
137
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, BFRDY, bfrdy);
138
+
139
+ mmrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_MEM, is_secure);
140
+ *fpccr = FIELD_DP32(*fpccr, V7M_FPCCR, MMRDY, mmrdy);
141
+
142
+ ns_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, false);
143
+ *fpccr_ns = FIELD_DP32(*fpccr_ns, V7M_FPCCR, UFRDY, ns_ufrdy);
144
+
145
+ monrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_DEBUG, false);
146
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, MONRDY, monrdy);
147
+
148
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
149
+ s_ufrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_USAGE, true);
150
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, UFRDY, s_ufrdy);
151
+
152
+ sfrdy = armv7m_nvic_get_ready_status(nvic, ARMV7M_EXCP_SECURE, false);
153
+ *fpccr_s = FIELD_DP32(*fpccr_s, V7M_FPCCR, SFRDY, sfrdy);
154
+ }
155
+}
42
+}
156
+
43
+
157
static bool v7m_push_stack(ARMCPU *cpu)
44
static inline Int128 int128_add(Int128 a, Int128 b)
158
{
45
{
159
/* Do the "set up stack frame" part of exception entry,
46
uint64_t lo = a.lo + b.lo;
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
--
47
--
170
2.20.1
48
2.20.1
171
49
172
50
diff view generated by jsdifflib
1
Add a new helper function which returns the MMU index to use
1
From: Richard Henderson <richard.henderson@linaro.org>
2
for v7M, where the caller specifies all of the security
3
state, privilege level and whether the execution priority
4
is negative, and reimplement the existing
5
arm_v7m_mmu_idx_for_secstate_and_priv() in terms of it.
6
2
7
We are going to need this for the lazy-FP-stacking code.
3
Model the new function on gen_gvec_fn2 in translate-a64.c, but
4
indicating which kind of register and in which order. Since there
5
is only one user of do_vector2_z, fold it into do_mov_z.
8
6
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20200815013145.539409-3-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20190416125744.27770-21-peter.maydell@linaro.org
12
---
11
---
13
target/arm/cpu.h | 7 +++++++
12
target/arm/translate-sve.c | 19 ++++++++++---------
14
target/arm/helper.c | 14 +++++++++++---
13
1 file changed, 10 insertions(+), 9 deletions(-)
15
2 files changed, 18 insertions(+), 3 deletions(-)
16
14
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
15
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
17
--- a/target/arm/translate-sve.c
20
+++ b/target/arm/cpu.h
18
+++ b/target/arm/translate-sve.c
21
@@ -XXX,XX +XXX,XX @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)
19
@@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s)
22
}
23
}
20
}
24
21
25
+/*
22
/* Invoke a vector expander on two Zregs. */
26
+ * Return the MMU index for a v7M CPU with all relevant information
23
-static bool do_vector2_z(DisasContext *s, GVecGen2Fn *gvec_fn,
27
+ * manually specified.
24
- int esz, int rd, int rn)
28
+ */
29
+ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
30
+ bool secstate, bool priv, bool negpri);
31
+
25
+
32
/* Return the MMU index for a v7M CPU in the specified security and
26
+static void gen_gvec_fn_zz(DisasContext *s, GVecGen2Fn *gvec_fn,
33
* privilege state.
27
+ int esz, int rd, int rn)
34
*/
28
{
35
diff --git a/target/arm/helper.c b/target/arm/helper.c
29
- if (sve_access_check(s)) {
36
index XXXXXXX..XXXXXXX 100644
30
- unsigned vsz = vec_full_reg_size(s);
37
--- a/target/arm/helper.c
31
- gvec_fn(esz, vec_full_reg_offset(s, rd),
38
+++ b/target/arm/helper.c
32
- vec_full_reg_offset(s, rn), vsz, vsz);
39
@@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el)
33
- }
40
return 0;
34
- return true;
35
+ unsigned vsz = vec_full_reg_size(s);
36
+ gvec_fn(esz, vec_full_reg_offset(s, rd),
37
+ vec_full_reg_offset(s, rn), vsz, vsz);
41
}
38
}
42
39
43
-ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
40
/* Invoke a vector expander on three Zregs. */
44
- bool secstate, bool priv)
41
@@ -XXX,XX +XXX,XX @@ static bool do_vector3_z(DisasContext *s, GVecGen3Fn *gvec_fn,
45
+ARMMMUIdx arm_v7m_mmu_idx_all(CPUARMState *env,
42
/* Invoke a vector move on two Zregs. */
46
+ bool secstate, bool priv, bool negpri)
43
static bool do_mov_z(DisasContext *s, int rd, int rn)
47
{
44
{
48
ARMMMUIdx mmu_idx = ARM_MMU_IDX_M;
45
- return do_vector2_z(s, tcg_gen_gvec_mov, 0, rd, rn);
49
46
+ if (sve_access_check(s)) {
50
@@ -XXX,XX +XXX,XX @@ ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
47
+ gen_gvec_fn_zz(s, tcg_gen_gvec_mov, MO_8, rd, rn);
51
mmu_idx |= ARM_MMU_IDX_M_PRIV;
48
+ }
52
}
49
+ return true;
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
}
50
}
62
51
63
+ARMMMUIdx arm_v7m_mmu_idx_for_secstate_and_priv(CPUARMState *env,
52
/* Initialize a Zreg with replications of a 64-bit immediate. */
64
+ bool secstate, bool priv)
65
+{
66
+ bool negpri = armv7m_nvic_neg_prio_requested(env->nvic, secstate);
67
+
68
+ return arm_v7m_mmu_idx_all(env, secstate, priv, negpri);
69
+}
70
+
71
/* Return the MMU index for a v7M CPU in the specified security state */
72
ARMMMUIdx arm_v7m_mmu_idx_for_secstate(CPUARMState *env, bool secstate)
73
{
74
--
53
--
75
2.20.1
54
2.20.1
76
55
77
56
diff view generated by jsdifflib
1
From: Eric Auger <eric.auger@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
The SMMUNotifierNode struct is not necessary and brings extra
3
Model gen_gvec_fn_zzz on gen_gvec_fn3 in translate-a64.c, but
4
complexity so let's remove it. We now directly track the SMMUDevices
4
indicating which kind of register and in which order.
5
which have registered IOMMU MR notifiers.
6
5
7
This is inspired from the same transformation on intel-iommu
6
Model do_zzz_fn on the other do_foo functions that take an
8
done in commit b4a4ba0d68f50f218ee3957b6638dbee32a5eeef
7
argument set and verify sve enabled.
9
("intel-iommu: remove IntelIOMMUNotifierNode")
10
8
11
Signed-off-by: Eric Auger <eric.auger@redhat.com>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Peter Xu <peterx@redhat.com>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Message-id: 20190409160219.19026-1-eric.auger@redhat.com
11
Message-id: 20200815013145.539409-4-richard.henderson@linaro.org
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
13
---
16
include/hw/arm/smmu-common.h | 8 ++------
14
target/arm/translate-sve.c | 43 +++++++++++++++++++++-----------------
17
hw/arm/smmu-common.c | 6 +++---
15
1 file changed, 24 insertions(+), 19 deletions(-)
18
hw/arm/smmuv3.c | 28 +++++++---------------------
19
3 files changed, 12 insertions(+), 30 deletions(-)
20
16
21
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
17
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
22
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/arm/smmu-common.h
19
--- a/target/arm/translate-sve.c
24
+++ b/include/hw/arm/smmu-common.h
20
+++ b/target/arm/translate-sve.c
25
@@ -XXX,XX +XXX,XX @@ typedef struct SMMUDevice {
21
@@ -XXX,XX +XXX,XX @@ static void gen_gvec_fn_zz(DisasContext *s, GVecGen2Fn *gvec_fn,
26
AddressSpace as;
22
}
27
uint32_t cfg_cache_hits;
23
28
uint32_t cfg_cache_misses;
24
/* Invoke a vector expander on three Zregs. */
29
+ QLIST_ENTRY(SMMUDevice) next;
25
-static bool do_vector3_z(DisasContext *s, GVecGen3Fn *gvec_fn,
30
} SMMUDevice;
26
- int esz, int rd, int rn, int rm)
31
27
+static void gen_gvec_fn_zzz(DisasContext *s, GVecGen3Fn *gvec_fn,
32
-typedef struct SMMUNotifierNode {
28
+ int esz, int rd, int rn, int rm)
33
- SMMUDevice *sdev;
34
- QLIST_ENTRY(SMMUNotifierNode) next;
35
-} SMMUNotifierNode;
36
-
37
typedef struct SMMUPciBus {
38
PCIBus *bus;
39
SMMUDevice *pbdev[0]; /* Parent array is sparse, so dynamically alloc */
40
@@ -XXX,XX +XXX,XX @@ typedef struct SMMUState {
41
GHashTable *iotlb;
42
SMMUPciBus *smmu_pcibus_by_bus_num[SMMU_PCI_BUS_MAX];
43
PCIBus *pci_bus;
44
- QLIST_HEAD(, SMMUNotifierNode) notifiers_list;
45
+ QLIST_HEAD(, SMMUDevice) devices_with_notifiers;
46
uint8_t bus_num;
47
PCIBus *primary_bus;
48
} SMMUState;
49
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/hw/arm/smmu-common.c
52
+++ b/hw/arm/smmu-common.c
53
@@ -XXX,XX +XXX,XX @@ inline void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr)
54
/* Unmap all notifiers of all mr's */
55
void smmu_inv_notifiers_all(SMMUState *s)
56
{
29
{
57
- SMMUNotifierNode *node;
30
- if (sve_access_check(s)) {
58
+ SMMUDevice *sdev;
31
- unsigned vsz = vec_full_reg_size(s);
59
32
- gvec_fn(esz, vec_full_reg_offset(s, rd),
60
- QLIST_FOREACH(node, &s->notifiers_list, next) {
33
- vec_full_reg_offset(s, rn),
61
- smmu_inv_notifiers_mr(&node->sdev->iommu);
34
- vec_full_reg_offset(s, rm), vsz, vsz);
62
+ QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
35
- }
63
+ smmu_inv_notifiers_mr(&sdev->iommu);
36
- return true;
64
}
37
+ unsigned vsz = vec_full_reg_size(s);
38
+ gvec_fn(esz, vec_full_reg_offset(s, rd),
39
+ vec_full_reg_offset(s, rn),
40
+ vec_full_reg_offset(s, rm), vsz, vsz);
65
}
41
}
66
42
67
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
43
/* Invoke a vector move on two Zregs. */
68
index XXXXXXX..XXXXXXX 100644
44
@@ -XXX,XX +XXX,XX @@ const uint64_t pred_esz_masks[4] = {
69
--- a/hw/arm/smmuv3.c
45
*** SVE Logical - Unpredicated Group
70
+++ b/hw/arm/smmuv3.c
46
*/
71
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
47
72
/* invalidate an asid/iova tuple in all mr's */
48
+static bool do_zzz_fn(DisasContext *s, arg_rrr_esz *a, GVecGen3Fn *gvec_fn)
73
static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova)
49
+{
50
+ if (sve_access_check(s)) {
51
+ gen_gvec_fn_zzz(s, gvec_fn, a->esz, a->rd, a->rn, a->rm);
52
+ }
53
+ return true;
54
+}
55
+
56
static bool trans_AND_zzz(DisasContext *s, arg_rrr_esz *a)
74
{
57
{
75
- SMMUNotifierNode *node;
58
- return do_vector3_z(s, tcg_gen_gvec_and, 0, a->rd, a->rn, a->rm);
76
+ SMMUDevice *sdev;
59
+ return do_zzz_fn(s, a, tcg_gen_gvec_and);
77
78
- QLIST_FOREACH(node, &s->notifiers_list, next) {
79
- IOMMUMemoryRegion *mr = &node->sdev->iommu;
80
+ QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) {
81
+ IOMMUMemoryRegion *mr = &sdev->iommu;
82
IOMMUNotifier *n;
83
84
trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, iova);
85
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
86
SMMUDevice *sdev = container_of(iommu, SMMUDevice, iommu);
87
SMMUv3State *s3 = sdev->smmu;
88
SMMUState *s = &(s3->smmu_state);
89
- SMMUNotifierNode *node = NULL;
90
- SMMUNotifierNode *next_node = NULL;
91
92
if (new & IOMMU_NOTIFIER_MAP) {
93
int bus_num = pci_bus_num(sdev->bus);
94
@@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu,
95
96
if (old == IOMMU_NOTIFIER_NONE) {
97
trace_smmuv3_notify_flag_add(iommu->parent_obj.name);
98
- node = g_malloc0(sizeof(*node));
99
- node->sdev = sdev;
100
- QLIST_INSERT_HEAD(&s->notifiers_list, node, next);
101
- return;
102
- }
103
-
104
- /* update notifier node with new flags */
105
- QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) {
106
- if (node->sdev == sdev) {
107
- if (new == IOMMU_NOTIFIER_NONE) {
108
- trace_smmuv3_notify_flag_del(iommu->parent_obj.name);
109
- QLIST_REMOVE(node, next);
110
- g_free(node);
111
- }
112
- return;
113
- }
114
+ QLIST_INSERT_HEAD(&s->devices_with_notifiers, sdev, next);
115
+ } else if (new == IOMMU_NOTIFIER_NONE) {
116
+ trace_smmuv3_notify_flag_del(iommu->parent_obj.name);
117
+ QLIST_REMOVE(sdev, next);
118
}
119
}
60
}
120
61
62
static bool trans_ORR_zzz(DisasContext *s, arg_rrr_esz *a)
63
{
64
- return do_vector3_z(s, tcg_gen_gvec_or, 0, a->rd, a->rn, a->rm);
65
+ return do_zzz_fn(s, a, tcg_gen_gvec_or);
66
}
67
68
static bool trans_EOR_zzz(DisasContext *s, arg_rrr_esz *a)
69
{
70
- return do_vector3_z(s, tcg_gen_gvec_xor, 0, a->rd, a->rn, a->rm);
71
+ return do_zzz_fn(s, a, tcg_gen_gvec_xor);
72
}
73
74
static bool trans_BIC_zzz(DisasContext *s, arg_rrr_esz *a)
75
{
76
- return do_vector3_z(s, tcg_gen_gvec_andc, 0, a->rd, a->rn, a->rm);
77
+ return do_zzz_fn(s, a, tcg_gen_gvec_andc);
78
}
79
80
/*
81
@@ -XXX,XX +XXX,XX @@ static bool trans_BIC_zzz(DisasContext *s, arg_rrr_esz *a)
82
83
static bool trans_ADD_zzz(DisasContext *s, arg_rrr_esz *a)
84
{
85
- return do_vector3_z(s, tcg_gen_gvec_add, a->esz, a->rd, a->rn, a->rm);
86
+ return do_zzz_fn(s, a, tcg_gen_gvec_add);
87
}
88
89
static bool trans_SUB_zzz(DisasContext *s, arg_rrr_esz *a)
90
{
91
- return do_vector3_z(s, tcg_gen_gvec_sub, a->esz, a->rd, a->rn, a->rm);
92
+ return do_zzz_fn(s, a, tcg_gen_gvec_sub);
93
}
94
95
static bool trans_SQADD_zzz(DisasContext *s, arg_rrr_esz *a)
96
{
97
- return do_vector3_z(s, tcg_gen_gvec_ssadd, a->esz, a->rd, a->rn, a->rm);
98
+ return do_zzz_fn(s, a, tcg_gen_gvec_ssadd);
99
}
100
101
static bool trans_SQSUB_zzz(DisasContext *s, arg_rrr_esz *a)
102
{
103
- return do_vector3_z(s, tcg_gen_gvec_sssub, a->esz, a->rd, a->rn, a->rm);
104
+ return do_zzz_fn(s, a, tcg_gen_gvec_sssub);
105
}
106
107
static bool trans_UQADD_zzz(DisasContext *s, arg_rrr_esz *a)
108
{
109
- return do_vector3_z(s, tcg_gen_gvec_usadd, a->esz, a->rd, a->rn, a->rm);
110
+ return do_zzz_fn(s, a, tcg_gen_gvec_usadd);
111
}
112
113
static bool trans_UQSUB_zzz(DisasContext *s, arg_rrr_esz *a)
114
{
115
- return do_vector3_z(s, tcg_gen_gvec_ussub, a->esz, a->rd, a->rn, a->rm);
116
+ return do_zzz_fn(s, a, tcg_gen_gvec_ussub);
117
}
118
119
/*
121
--
120
--
122
2.20.1
121
2.20.1
123
122
124
123
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
The M-profile FPCCR.S bit indicates the security status of
1
From: Richard Henderson <richard.henderson@linaro.org>
2
the floating point context. In the pseudocode ExecuteFPCheck()
3
function it is unconditionally set to match the current
4
security state whenever a floating point instruction is
5
executed.
6
2
7
Implement this by adding a new TB flag which tracks whether
3
We want to ensure that access is checked by the time we ask
8
FPCCR.S is different from the current security state, so
4
for a specific fp/vector register. We want to ensure that
9
that we only need to emit the code to update it in the
5
we do not emit two lots of code to raise an exception.
10
less-common case when it is not already set correctly.
11
6
12
Note that we will add the handling for the other work done
7
But sometimes it's difficult to cleanly organize the code
13
by ExecuteFPCheck() in later commits.
8
such that we never pass through sve_check_access exactly once.
9
Allow multiple calls so long as the result is true, that is,
10
no exception to be raised.
14
11
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Message-id: 20200815013145.539409-5-richard.henderson@linaro.org
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Message-id: 20190416125744.27770-19-peter.maydell@linaro.org
18
---
16
---
19
target/arm/cpu.h | 2 ++
17
target/arm/translate.h | 1 +
20
target/arm/translate.h | 1 +
18
target/arm/translate-a64.c | 27 ++++++++++++++++-----------
21
target/arm/helper.c | 5 +++++
19
2 files changed, 17 insertions(+), 11 deletions(-)
22
target/arm/translate.c | 20 ++++++++++++++++++++
23
4 files changed, 28 insertions(+)
24
20
25
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
26
index XXXXXXX..XXXXXXX 100644
27
--- a/target/arm/cpu.h
28
+++ b/target/arm/cpu.h
29
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
30
FIELD(TBFLAG_A32, VFPEN, 7, 1)
31
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
32
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
33
+/* For M profile only, set if FPCCR.S does not match current security state */
34
+FIELD(TBFLAG_A32, FPCCR_S_WRONG, 20, 1)
35
/* For M profile only, Handler (ie not Thread) mode */
36
FIELD(TBFLAG_A32, HANDLER, 21, 1)
37
/* For M profile only, whether we should generate stack-limit checks */
38
diff --git a/target/arm/translate.h b/target/arm/translate.h
21
diff --git a/target/arm/translate.h b/target/arm/translate.h
39
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
40
--- a/target/arm/translate.h
23
--- a/target/arm/translate.h
41
+++ b/target/arm/translate.h
24
+++ b/target/arm/translate.h
42
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
25
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
43
bool v7m_handler_mode;
26
* that it is set at the point where we actually touch the FP regs.
44
bool v8m_secure; /* true if v8M and we're in Secure mode */
45
bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */
46
+ bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */
47
/* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI
48
* so that top level loop can generate correct syndrome information.
49
*/
27
*/
50
diff --git a/target/arm/helper.c b/target/arm/helper.c
28
bool fp_access_checked;
29
+ bool sve_access_checked;
30
/* ARMv8 single-step state (this is distinct from the QEMU gdbstub
31
* single-step support).
32
*/
33
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
51
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
52
--- a/target/arm/helper.c
35
--- a/target/arm/translate-a64.c
53
+++ b/target/arm/helper.c
36
+++ b/target/arm/translate-a64.c
54
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
37
@@ -XXX,XX +XXX,XX @@ static void do_vec_ld(DisasContext *s, int destidx, int element,
55
flags = FIELD_DP32(flags, TBFLAG_A32, STACKCHECK, 1);
38
* unallocated-encoding checks (otherwise the syndrome information
39
* for the resulting exception will be incorrect).
40
*/
41
-static inline bool fp_access_check(DisasContext *s)
42
+static bool fp_access_check(DisasContext *s)
43
{
44
- assert(!s->fp_access_checked);
45
- s->fp_access_checked = true;
46
+ if (s->fp_excp_el) {
47
+ assert(!s->fp_access_checked);
48
+ s->fp_access_checked = true;
49
50
- if (!s->fp_excp_el) {
51
- return true;
52
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
53
+ syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
54
+ return false;
56
}
55
}
57
56
-
58
+ if (arm_feature(env, ARM_FEATURE_M_SECURITY) &&
57
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
59
+ FIELD_EX32(env->v7m.fpccr[M_REG_S], V7M_FPCCR, S) != env->v7m.secure) {
58
- syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
60
+ flags = FIELD_DP32(flags, TBFLAG_A32, FPCCR_S_WRONG, 1);
59
- return false;
61
+ }
60
+ s->fp_access_checked = true;
61
+ return true;
62
}
63
64
/* Check that SVE access is enabled. If it is, return true.
65
@@ -XXX,XX +XXX,XX @@ static inline bool fp_access_check(DisasContext *s)
66
bool sve_access_check(DisasContext *s)
67
{
68
if (s->sve_excp_el) {
69
- gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_sve_access_trap(),
70
- s->sve_excp_el);
71
+ assert(!s->sve_access_checked);
72
+ s->sve_access_checked = true;
62
+
73
+
63
*pflags = flags;
74
+ gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
64
*cs_base = 0;
75
+ syn_sve_access_trap(), s->sve_excp_el);
76
return false;
77
}
78
+ s->sve_access_checked = true;
79
return fp_access_check(s);
65
}
80
}
66
diff --git a/target/arm/translate.c b/target/arm/translate.c
81
67
index XXXXXXX..XXXXXXX 100644
82
@@ -XXX,XX +XXX,XX @@ static void disas_a64_insn(CPUARMState *env, DisasContext *s)
68
--- a/target/arm/translate.c
83
s->base.pc_next += 4;
69
+++ b/target/arm/translate.c
84
70
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
85
s->fp_access_checked = false;
71
}
86
+ s->sve_access_checked = false;
72
}
87
73
88
if (dc_isar_feature(aa64_bti, s)) {
74
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
89
if (s->base.num_insns == 1) {
75
+ /* Handle M-profile lazy FP state mechanics */
76
+
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
+ }
87
+ store_cpu_field(tmp, v7m.fpccr[M_REG_S]);
88
+ /* Don't need to do this for any further FP insns in this TB */
89
+ s->v8m_fpccr_s_wrong = false;
90
+ }
91
+ }
92
+
93
if (extract32(insn, 28, 4) == 0xf) {
94
/*
95
* Encodings with T=1 (Thumb) or unconditional (ARM):
96
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
97
dc->v8m_secure = arm_feature(env, ARM_FEATURE_M_SECURITY) &&
98
regime_is_secure(env, dc->mmu_idx);
99
dc->v8m_stackcheck = FIELD_EX32(tb_flags, TBFLAG_A32, STACKCHECK);
100
+ dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG);
101
dc->cp_regs = cpu->cp_regs;
102
dc->features = env->features;
103
104
--
90
--
105
2.20.1
91
2.20.1
106
92
107
93
diff view generated by jsdifflib
1
Move the NS TBFLAG down from bit 19 to bit 6, which has not
1
From: Richard Henderson <richard.henderson@linaro.org>
2
been used since commit c1e3781090b9d36c60 in 2015, when we
3
started passing the entire MMU index in the TB flags rather
4
than just a 'privilege level' bit.
5
2
6
This rearrangement is not strictly necessary, but means that
3
This is the only user of the function.
7
we can put M-profile-only bits next to each other rather
8
than scattered across the flag word.
9
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20200815013145.539409-6-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20190416125744.27770-17-peter.maydell@linaro.org
13
---
9
---
14
target/arm/cpu.h | 11 ++++++-----
10
target/arm/translate-sve.c | 19 ++++++-------------
15
1 file changed, 6 insertions(+), 5 deletions(-)
11
1 file changed, 6 insertions(+), 13 deletions(-)
16
12
17
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
13
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
18
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.h
15
--- a/target/arm/translate-sve.c
20
+++ b/target/arm/cpu.h
16
+++ b/target/arm/translate-sve.c
21
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_ANY, BE_DATA, 23, 1)
17
@@ -XXX,XX +XXX,XX @@ static void do_dupi_z(DisasContext *s, int rd, uint64_t word)
22
FIELD(TBFLAG_A32, THUMB, 0, 1)
18
tcg_gen_gvec_dup_imm(MO_64, vec_full_reg_offset(s, rd), vsz, vsz, word);
23
FIELD(TBFLAG_A32, VECLEN, 1, 3)
19
}
24
FIELD(TBFLAG_A32, VECSTRIDE, 4, 2)
20
25
+/*
21
-/* Invoke a vector expander on two Pregs. */
26
+ * Indicates whether cp register reads and writes by guest code should access
22
-static bool do_vector2_p(DisasContext *s, GVecGen2Fn *gvec_fn,
27
+ * the secure or nonsecure bank of banked registers; note that this is not
23
- int esz, int rd, int rn)
28
+ * the same thing as the current security state of the processor!
24
-{
29
+ */
25
- if (sve_access_check(s)) {
30
+FIELD(TBFLAG_A32, NS, 6, 1)
26
- unsigned psz = pred_gvec_reg_size(s);
31
FIELD(TBFLAG_A32, VFPEN, 7, 1)
27
- gvec_fn(esz, pred_full_reg_offset(s, rd),
32
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
28
- pred_full_reg_offset(s, rn), psz, psz);
33
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
29
- }
34
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
30
- return true;
35
* checks on the other bits at runtime
31
-}
36
*/
32
-
37
FIELD(TBFLAG_A32, XSCALE_CPAR, 17, 2)
33
/* Invoke a vector expander on three Pregs. */
38
-/* Indicates whether cp register reads and writes by guest code should access
34
static bool do_vector3_p(DisasContext *s, GVecGen3Fn *gvec_fn,
39
- * the secure or nonsecure bank of banked registers; note that this is not
35
int esz, int rd, int rn, int rm)
40
- * the same thing as the current security state of the processor!
36
@@ -XXX,XX +XXX,XX @@ static bool do_vecop4_p(DisasContext *s, const GVecGen4 *gvec_op,
41
- */
37
/* Invoke a vector move on two Pregs. */
42
-FIELD(TBFLAG_A32, NS, 19, 1)
38
static bool do_mov_p(DisasContext *s, int rd, int rn)
43
/* For M profile only, Handler (ie not Thread) mode */
39
{
44
FIELD(TBFLAG_A32, HANDLER, 21, 1)
40
- return do_vector2_p(s, tcg_gen_gvec_mov, 0, rd, rn);
45
/* For M profile only, whether we should generate stack-limit checks */
41
+ if (sve_access_check(s)) {
42
+ unsigned psz = pred_gvec_reg_size(s);
43
+ tcg_gen_gvec_mov(MO_8, pred_full_reg_offset(s, rd),
44
+ pred_full_reg_offset(s, rn), psz, psz);
45
+ }
46
+ return true;
47
}
48
49
/* Set the cpu flags as per a return from an SVE helper. */
46
--
50
--
47
2.20.1
51
2.20.1
48
52
49
53
diff view generated by jsdifflib
1
Enforce that for M-profile various FPSCR bits which are RES0 there
1
From: Richard Henderson <richard.henderson@linaro.org>
2
but have defined meanings on A-profile are never settable. This
2
3
ensures that M-profile code can't enable the A-profile behaviour
3
Move the check for !S into do_pppp_flags, which allows to merge in
4
(notably vector length/stride handling) by accident.
4
do_vecop4_p. Split out gen_gvec_fn_ppp without sve_access_check,
5
5
to mirror gen_gvec_fn_zzz.
6
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20200815013145.539409-7-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-2-peter.maydell@linaro.org
9
---
11
---
10
target/arm/vfp_helper.c | 8 ++++++++
12
target/arm/translate-sve.c | 111 ++++++++++++++-----------------------
11
1 file changed, 8 insertions(+)
13
1 file changed, 43 insertions(+), 68 deletions(-)
12
14
13
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
15
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/vfp_helper.c
17
--- a/target/arm/translate-sve.c
16
+++ b/target/arm/vfp_helper.c
18
+++ b/target/arm/translate-sve.c
17
@@ -XXX,XX +XXX,XX @@ void HELPER(vfp_set_fpscr)(CPUARMState *env, uint32_t val)
19
@@ -XXX,XX +XXX,XX @@ static void do_dupi_z(DisasContext *s, int rd, uint64_t word)
18
val &= ~FPCR_FZ16;
20
}
19
}
21
20
22
/* Invoke a vector expander on three Pregs. */
21
+ if (arm_feature(env, ARM_FEATURE_M)) {
23
-static bool do_vector3_p(DisasContext *s, GVecGen3Fn *gvec_fn,
22
+ /*
24
- int esz, int rd, int rn, int rm)
23
+ * M profile FPSCR is RES0 for the QC, STRIDE, FZ16, LEN bits
25
+static void gen_gvec_fn_ppp(DisasContext *s, GVecGen3Fn *gvec_fn,
24
+ * and also for the trapped-exception-handling bits IxE.
26
+ int rd, int rn, int rm)
25
+ */
27
{
26
+ val &= 0xf7c0009f;
28
- if (sve_access_check(s)) {
29
- unsigned psz = pred_gvec_reg_size(s);
30
- gvec_fn(esz, pred_full_reg_offset(s, rd),
31
- pred_full_reg_offset(s, rn),
32
- pred_full_reg_offset(s, rm), psz, psz);
33
- }
34
- return true;
35
-}
36
-
37
-/* Invoke a vector operation on four Pregs. */
38
-static bool do_vecop4_p(DisasContext *s, const GVecGen4 *gvec_op,
39
- int rd, int rn, int rm, int rg)
40
-{
41
- if (sve_access_check(s)) {
42
- unsigned psz = pred_gvec_reg_size(s);
43
- tcg_gen_gvec_4(pred_full_reg_offset(s, rd),
44
- pred_full_reg_offset(s, rn),
45
- pred_full_reg_offset(s, rm),
46
- pred_full_reg_offset(s, rg),
47
- psz, psz, gvec_op);
48
- }
49
- return true;
50
+ unsigned psz = pred_gvec_reg_size(s);
51
+ gvec_fn(MO_64, pred_full_reg_offset(s, rd),
52
+ pred_full_reg_offset(s, rn),
53
+ pred_full_reg_offset(s, rm), psz, psz);
54
}
55
56
/* Invoke a vector move on two Pregs. */
57
@@ -XXX,XX +XXX,XX @@ static bool do_pppp_flags(DisasContext *s, arg_rprr_s *a,
58
int mofs = pred_full_reg_offset(s, a->rm);
59
int gofs = pred_full_reg_offset(s, a->pg);
60
61
+ if (!a->s) {
62
+ tcg_gen_gvec_4(dofs, nofs, mofs, gofs, psz, psz, gvec_op);
63
+ return true;
27
+ }
64
+ }
28
+
65
+
29
/*
66
if (psz == 8) {
30
* We don't implement trapped exception handling, so the
67
/* Do the operation and the flags generation in temps. */
31
* trap enable bits, IDE|IXE|UFE|OFE|DZE|IOE are all RAZ/WI (not RES0!)
68
TCGv_i64 pd = tcg_temp_new_i64();
69
@@ -XXX,XX +XXX,XX @@ static bool trans_AND_pppp(DisasContext *s, arg_rprr_s *a)
70
.fno = gen_helper_sve_and_pppp,
71
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
72
};
73
- if (a->s) {
74
- return do_pppp_flags(s, a, &op);
75
- } else if (a->rn == a->rm) {
76
- if (a->pg == a->rn) {
77
- return do_mov_p(s, a->rd, a->rn);
78
- } else {
79
- return do_vector3_p(s, tcg_gen_gvec_and, 0, a->rd, a->rn, a->pg);
80
+
81
+ if (!a->s) {
82
+ if (!sve_access_check(s)) {
83
+ return true;
84
+ }
85
+ if (a->rn == a->rm) {
86
+ if (a->pg == a->rn) {
87
+ do_mov_p(s, a->rd, a->rn);
88
+ } else {
89
+ gen_gvec_fn_ppp(s, tcg_gen_gvec_and, a->rd, a->rn, a->pg);
90
+ }
91
+ return true;
92
+ } else if (a->pg == a->rn || a->pg == a->rm) {
93
+ gen_gvec_fn_ppp(s, tcg_gen_gvec_and, a->rd, a->rn, a->rm);
94
+ return true;
95
}
96
- } else if (a->pg == a->rn || a->pg == a->rm) {
97
- return do_vector3_p(s, tcg_gen_gvec_and, 0, a->rd, a->rn, a->rm);
98
- } else {
99
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
100
}
101
+ return do_pppp_flags(s, a, &op);
102
}
103
104
static void gen_bic_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
105
@@ -XXX,XX +XXX,XX @@ static bool trans_BIC_pppp(DisasContext *s, arg_rprr_s *a)
106
.fno = gen_helper_sve_bic_pppp,
107
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
108
};
109
- if (a->s) {
110
- return do_pppp_flags(s, a, &op);
111
- } else if (a->pg == a->rn) {
112
- return do_vector3_p(s, tcg_gen_gvec_andc, 0, a->rd, a->rn, a->rm);
113
- } else {
114
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
115
+
116
+ if (!a->s && a->pg == a->rn) {
117
+ if (sve_access_check(s)) {
118
+ gen_gvec_fn_ppp(s, tcg_gen_gvec_andc, a->rd, a->rn, a->rm);
119
+ }
120
+ return true;
121
}
122
+ return do_pppp_flags(s, a, &op);
123
}
124
125
static void gen_eor_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
126
@@ -XXX,XX +XXX,XX @@ static bool trans_EOR_pppp(DisasContext *s, arg_rprr_s *a)
127
.fno = gen_helper_sve_eor_pppp,
128
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
129
};
130
- if (a->s) {
131
- return do_pppp_flags(s, a, &op);
132
- } else {
133
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
134
- }
135
+ return do_pppp_flags(s, a, &op);
136
}
137
138
static void gen_sel_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
139
@@ -XXX,XX +XXX,XX @@ static bool trans_SEL_pppp(DisasContext *s, arg_rprr_s *a)
140
.fno = gen_helper_sve_sel_pppp,
141
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
142
};
143
+
144
if (a->s) {
145
return false;
146
- } else {
147
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
148
}
149
+ return do_pppp_flags(s, a, &op);
150
}
151
152
static void gen_orr_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
153
@@ -XXX,XX +XXX,XX @@ static bool trans_ORR_pppp(DisasContext *s, arg_rprr_s *a)
154
.fno = gen_helper_sve_orr_pppp,
155
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
156
};
157
- if (a->s) {
158
- return do_pppp_flags(s, a, &op);
159
- } else if (a->pg == a->rn && a->rn == a->rm) {
160
+
161
+ if (!a->s && a->pg == a->rn && a->rn == a->rm) {
162
return do_mov_p(s, a->rd, a->rn);
163
- } else {
164
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
165
}
166
+ return do_pppp_flags(s, a, &op);
167
}
168
169
static void gen_orn_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
170
@@ -XXX,XX +XXX,XX @@ static bool trans_ORN_pppp(DisasContext *s, arg_rprr_s *a)
171
.fno = gen_helper_sve_orn_pppp,
172
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
173
};
174
- if (a->s) {
175
- return do_pppp_flags(s, a, &op);
176
- } else {
177
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
178
- }
179
+ return do_pppp_flags(s, a, &op);
180
}
181
182
static void gen_nor_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
183
@@ -XXX,XX +XXX,XX @@ static bool trans_NOR_pppp(DisasContext *s, arg_rprr_s *a)
184
.fno = gen_helper_sve_nor_pppp,
185
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
186
};
187
- if (a->s) {
188
- return do_pppp_flags(s, a, &op);
189
- } else {
190
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
191
- }
192
+ return do_pppp_flags(s, a, &op);
193
}
194
195
static void gen_nand_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
196
@@ -XXX,XX +XXX,XX @@ static bool trans_NAND_pppp(DisasContext *s, arg_rprr_s *a)
197
.fno = gen_helper_sve_nand_pppp,
198
.prefer_i64 = TCG_TARGET_REG_BITS == 64,
199
};
200
- if (a->s) {
201
- return do_pppp_flags(s, a, &op);
202
- } else {
203
- return do_vecop4_p(s, &op, a->rd, a->rn, a->rm, a->pg);
204
- }
205
+ return do_pppp_flags(s, a, &op);
206
}
207
208
/*
32
--
209
--
33
2.20.1
210
2.20.1
34
211
35
212
diff view generated by jsdifflib
Deleted patch
1
For M-profile the MVFR* ID registers are memory mapped, in the
2
range we implement via the NVIC. Allow them to be read.
3
(If the CPU has no FPU, these registers are defined to be RAZ.)
4
1
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20190416125744.27770-3-peter.maydell@linaro.org
8
---
9
hw/intc/armv7m_nvic.c | 6 ++++++
10
1 file changed, 6 insertions(+)
11
12
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/intc/armv7m_nvic.c
15
+++ b/hw/intc/armv7m_nvic.c
16
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs)
17
return 0;
18
}
19
return cpu->env.v7m.sfar;
20
+ case 0xf40: /* MVFR0 */
21
+ return cpu->isar.mvfr0;
22
+ case 0xf44: /* MVFR1 */
23
+ return cpu->isar.mvfr1;
24
+ case 0xf48: /* MVFR2 */
25
+ return cpu->isar.mvfr2;
26
default:
27
bad_offset:
28
qemu_log_mask(LOG_GUEST_ERROR, "NVIC: Bad read offset 0x%x\n", offset);
29
--
30
2.20.1
31
32
diff view generated by jsdifflib
Deleted patch
1
The only "system register" that M-profile floating point exposes
2
via the VMRS/VMRS instructions is FPSCR, and it does not have
3
the odd special case for rd==15. Add a check to ensure we only
4
expose FPSCR.
5
1
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-5-peter.maydell@linaro.org
9
---
10
target/arm/translate.c | 19 +++++++++++++++++--
11
1 file changed, 17 insertions(+), 2 deletions(-)
12
13
diff --git a/target/arm/translate.c b/target/arm/translate.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/translate.c
16
+++ b/target/arm/translate.c
17
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
18
}
19
}
20
} else { /* !dp */
21
+ bool is_sysreg;
22
+
23
if ((insn & 0x6f) != 0x00)
24
return 1;
25
rn = VFP_SREG_N(insn);
26
+
27
+ is_sysreg = extract32(insn, 21, 1);
28
+
29
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
30
+ /*
31
+ * The only M-profile VFP vmrs/vmsr sysreg is FPSCR.
32
+ * Writes to R15 are UNPREDICTABLE; we choose to undef.
33
+ */
34
+ if (is_sysreg && (rd == 15 || (rn >> 1) != ARM_VFP_FPSCR)) {
35
+ return 1;
36
+ }
37
+ }
38
+
39
if (insn & ARM_CP_RW_BIT) {
40
/* vfp->arm */
41
- if (insn & (1 << 21)) {
42
+ if (is_sysreg) {
43
/* system register */
44
rn >>= 1;
45
46
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
47
}
48
} else {
49
/* arm->vfp */
50
- if (insn & (1 << 21)) {
51
+ if (is_sysreg) {
52
rn >>= 1;
53
/* system register */
54
switch (rn) {
55
--
56
2.20.1
57
58
diff view generated by jsdifflib
1
Pushing registers to the stack for v7M needs to handle three cases:
1
From: Richard Henderson <richard.henderson@linaro.org>
2
* the "normal" case where we pend exceptions
3
* an "ignore faults" case where we set FSR bits but
4
do not pend exceptions (this is used when we are
5
handling some kinds of derived exception on exception entry)
6
* a "lazy FP stacking" case, where different FSR bits
7
are set and the exception is pended differently
8
2
9
Implement this by changing the existing flag argument that
3
The gvec operation was added after the initial implementation
10
tells us whether to ignore faults or not into an enum that
4
of the SEL instruction and was missed in the conversion.
11
specifies which of the 3 modes we should handle.
12
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20200815013145.539409-8-richard.henderson@linaro.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Message-id: 20190416125744.27770-23-peter.maydell@linaro.org
16
---
10
---
17
target/arm/helper.c | 118 +++++++++++++++++++++++++++++---------------
11
target/arm/translate-sve.c | 31 ++++++++-----------------------
18
1 file changed, 79 insertions(+), 39 deletions(-)
12
1 file changed, 8 insertions(+), 23 deletions(-)
19
13
20
diff --git a/target/arm/helper.c b/target/arm/helper.c
14
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
21
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/helper.c
16
--- a/target/arm/translate-sve.c
23
+++ b/target/arm/helper.c
17
+++ b/target/arm/translate-sve.c
24
@@ -XXX,XX +XXX,XX @@ static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv)
18
@@ -XXX,XX +XXX,XX @@ static bool trans_EOR_pppp(DisasContext *s, arg_rprr_s *a)
19
return do_pppp_flags(s, a, &op);
20
}
21
22
-static void gen_sel_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
23
-{
24
- tcg_gen_and_i64(pn, pn, pg);
25
- tcg_gen_andc_i64(pm, pm, pg);
26
- tcg_gen_or_i64(pd, pn, pm);
27
-}
28
-
29
-static void gen_sel_pg_vec(unsigned vece, TCGv_vec pd, TCGv_vec pn,
30
- TCGv_vec pm, TCGv_vec pg)
31
-{
32
- tcg_gen_and_vec(vece, pn, pn, pg);
33
- tcg_gen_andc_vec(vece, pm, pm, pg);
34
- tcg_gen_or_vec(vece, pd, pn, pm);
35
-}
36
-
37
static bool trans_SEL_pppp(DisasContext *s, arg_rprr_s *a)
38
{
39
- static const GVecGen4 op = {
40
- .fni8 = gen_sel_pg_i64,
41
- .fniv = gen_sel_pg_vec,
42
- .fno = gen_helper_sve_sel_pppp,
43
- .prefer_i64 = TCG_TARGET_REG_BITS == 64,
44
- };
45
-
46
if (a->s) {
47
return false;
25
}
48
}
49
- return do_pppp_flags(s, a, &op);
50
+ if (sve_access_check(s)) {
51
+ unsigned psz = pred_gvec_reg_size(s);
52
+ tcg_gen_gvec_bitsel(MO_8, pred_full_reg_offset(s, a->rd),
53
+ pred_full_reg_offset(s, a->pg),
54
+ pred_full_reg_offset(s, a->rn),
55
+ pred_full_reg_offset(s, a->rm), psz, psz);
56
+ }
57
+ return true;
26
}
58
}
27
59
28
+/*
60
static void gen_orr_pg_i64(TCGv_i64 pd, TCGv_i64 pn, TCGv_i64 pm, TCGv_i64 pg)
29
+ * What kind of stack write are we doing? This affects how exceptions
30
+ * generated during the stacking are treated.
31
+ */
32
+typedef enum StackingMode {
33
+ STACK_NORMAL,
34
+ STACK_IGNFAULTS,
35
+ STACK_LAZYFP,
36
+} StackingMode;
37
+
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
--
61
--
209
2.20.1
62
2.20.1
210
63
211
64
diff view generated by jsdifflib
1
For v8M floating point support, transitions from Secure
1
From: Richard Henderson <richard.henderson@linaro.org>
2
to Non-secure state via BLNS and BLXNS must clear the
3
CONTROL.SFPA bit. (This corresponds to the pseudocode
4
BranchToNS() function.)
5
2
3
Model after gen_gvec_fn_zzz et al.
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20200815013145.539409-9-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20190416125744.27770-13-peter.maydell@linaro.org
9
---
9
---
10
target/arm/helper.c | 4 ++++
10
target/arm/translate-sve.c | 35 ++++++++++++++++-------------------
11
1 file changed, 4 insertions(+)
11
1 file changed, 16 insertions(+), 19 deletions(-)
12
12
13
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
14
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/helper.c
15
--- a/target/arm/translate-sve.c
16
+++ b/target/arm/helper.c
16
+++ b/target/arm/translate-sve.c
17
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest)
17
@@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s)
18
/* translate.c should have made BXNS UNDEF unless we're secure */
18
return size_for_gvec(pred_full_reg_size(s));
19
assert(env->v7m.secure);
19
}
20
20
21
+ if (!(dest & 1)) {
21
-/* Invoke a vector expander on two Zregs. */
22
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
22
+/* Invoke an out-of-line helper on 3 Zregs and a predicate. */
23
+ }
23
+static void gen_gvec_ool_zzzp(DisasContext *s, gen_helper_gvec_4 *fn,
24
switch_v7m_security_state(env, dest & 1);
24
+ int rd, int rn, int rm, int pg, int data)
25
env->thumb = 1;
25
+{
26
env->regs[15] = dest & ~1;
26
+ unsigned vsz = vec_full_reg_size(s);
27
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
27
+ tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd),
28
*/
28
+ vec_full_reg_offset(s, rn),
29
write_v7m_exception(env, 1);
29
+ vec_full_reg_offset(s, rm),
30
+ pred_full_reg_offset(s, pg),
31
+ vsz, vsz, data, fn);
32
+}
33
34
+/* Invoke a vector expander on two Zregs. */
35
static void gen_gvec_fn_zz(DisasContext *s, GVecGen2Fn *gvec_fn,
36
int esz, int rd, int rn)
37
{
38
@@ -XXX,XX +XXX,XX @@ static bool trans_UQSUB_zzz(DisasContext *s, arg_rrr_esz *a)
39
40
static bool do_zpzz_ool(DisasContext *s, arg_rprr_esz *a, gen_helper_gvec_4 *fn)
41
{
42
- unsigned vsz = vec_full_reg_size(s);
43
if (fn == NULL) {
44
return false;
30
}
45
}
31
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
46
if (sve_access_check(s)) {
32
switch_v7m_security_state(env, 0);
47
- tcg_gen_gvec_4_ool(vec_full_reg_offset(s, a->rd),
33
env->thumb = 1;
48
- vec_full_reg_offset(s, a->rn),
34
env->regs[15] = dest;
49
- vec_full_reg_offset(s, a->rm),
50
- pred_full_reg_offset(s, a->pg),
51
- vsz, vsz, 0, fn);
52
+ gen_gvec_ool_zzzp(s, fn, a->rd, a->rn, a->rm, a->pg, 0);
53
}
54
return true;
55
}
56
@@ -XXX,XX +XXX,XX @@ static void do_sel_z(DisasContext *s, int rd, int rn, int rm, int pg, int esz)
57
gen_helper_sve_sel_zpzz_b, gen_helper_sve_sel_zpzz_h,
58
gen_helper_sve_sel_zpzz_s, gen_helper_sve_sel_zpzz_d
59
};
60
- unsigned vsz = vec_full_reg_size(s);
61
- tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd),
62
- vec_full_reg_offset(s, rn),
63
- vec_full_reg_offset(s, rm),
64
- pred_full_reg_offset(s, pg),
65
- vsz, vsz, 0, fns[esz]);
66
+ gen_gvec_ool_zzzp(s, fns[esz], rd, rn, rm, pg, 0);
67
}
68
69
#define DO_ZPZZ(NAME, name) \
70
@@ -XXX,XX +XXX,XX @@ static bool trans_RBIT(DisasContext *s, arg_rpr_esz *a)
71
static bool trans_SPLICE(DisasContext *s, arg_rprr_esz *a)
72
{
73
if (sve_access_check(s)) {
74
- unsigned vsz = vec_full_reg_size(s);
75
- tcg_gen_gvec_4_ool(vec_full_reg_offset(s, a->rd),
76
- vec_full_reg_offset(s, a->rn),
77
- vec_full_reg_offset(s, a->rm),
78
- pred_full_reg_offset(s, a->pg),
79
- vsz, vsz, a->esz, gen_helper_sve_splice);
80
+ gen_gvec_ool_zzzp(s, gen_helper_sve_splice,
81
+ a->rd, a->rn, a->rm, a->pg, 0);
82
}
83
return true;
84
}
35
--
85
--
36
2.20.1
86
2.20.1
37
87
38
88
diff view generated by jsdifflib
1
Currently the code in v7m_push_stack() which detects a violation
1
From: Richard Henderson <richard.henderson@linaro.org>
2
of the v8M stack limit simply returns early if it does so. This
2
3
is OK for the current integer-only code, but won't work for the
3
The existing clr functions have only one vector argument, and so
4
floating point handling we're about to add. We need to continue
4
can only clear in place. The existing movz functions have two
5
executing the rest of the function so that we check for other
5
vector arguments, and so can clear while moving. Merge them, with
6
exceptions like not having permission to use the FPU and so
6
a flag that controls the sense of active vs inactive elements
7
that we correctly set the FPCCR state if we are doing lazy
7
being cleared.
8
stacking. Refactor to avoid the early return.
8
9
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20200815013145.539409-10-richard.henderson@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20190416125744.27770-10-peter.maydell@linaro.org
13
---
13
---
14
target/arm/helper.c | 23 ++++++++++++++++++-----
14
target/arm/helper-sve.h | 5 ---
15
1 file changed, 18 insertions(+), 5 deletions(-)
15
target/arm/sve_helper.c | 70 ++++++++------------------------------
16
16
target/arm/translate-sve.c | 53 +++++++++++------------------
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
3 files changed, 34 insertions(+), 94 deletions(-)
18
19
diff --git a/target/arm/helper-sve.h b/target/arm/helper-sve.h
18
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
21
--- a/target/arm/helper-sve.h
20
+++ b/target/arm/helper.c
22
+++ b/target/arm/helper-sve.h
21
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
23
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_3(sve_uminv_h, TCG_CALL_NO_RWG, i64, ptr, ptr, i32)
22
* should ignore further stack faults trying to process
24
DEF_HELPER_FLAGS_3(sve_uminv_s, TCG_CALL_NO_RWG, i64, ptr, ptr, i32)
23
* that derived exception.)
25
DEF_HELPER_FLAGS_3(sve_uminv_d, TCG_CALL_NO_RWG, i64, ptr, ptr, i32)
24
*/
26
25
- bool stacked_ok;
27
-DEF_HELPER_FLAGS_3(sve_clr_b, TCG_CALL_NO_RWG, void, ptr, ptr, i32)
26
+ bool stacked_ok = true, limitviol = false;
28
-DEF_HELPER_FLAGS_3(sve_clr_h, TCG_CALL_NO_RWG, void, ptr, ptr, i32)
27
CPUARMState *env = &cpu->env;
29
-DEF_HELPER_FLAGS_3(sve_clr_s, TCG_CALL_NO_RWG, void, ptr, ptr, i32)
28
uint32_t xpsr = xpsr_read(env);
30
-DEF_HELPER_FLAGS_3(sve_clr_d, TCG_CALL_NO_RWG, void, ptr, ptr, i32)
29
uint32_t frameptr = env->regs[13];
31
-
30
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
32
DEF_HELPER_FLAGS_4(sve_movz_b, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
31
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE,
33
DEF_HELPER_FLAGS_4(sve_movz_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
32
env->v7m.secure);
34
DEF_HELPER_FLAGS_4(sve_movz_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
33
env->regs[13] = limit;
35
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
34
- return true;
36
index XXXXXXX..XXXXXXX 100644
35
+ /*
37
--- a/target/arm/sve_helper.c
36
+ * We won't try to perform any further memory accesses but
38
+++ b/target/arm/sve_helper.c
37
+ * we must continue through the following code to check for
39
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_pnext)(void *vd, void *vg, uint32_t pred_desc)
38
+ * permission faults during FPU state preservation, and we
40
return flags;
39
+ * must update FPCCR if lazy stacking is enabled.
41
}
40
+ */
42
41
+ limitviol = true;
43
-/* Store zero into every active element of Zd. We will use this for two
42
+ stacked_ok = false;
44
- * and three-operand predicated instructions for which logic dictates a
43
}
45
- * zero result. In particular, logical shift by element size, which is
44
}
46
- * otherwise undefined on the host.
45
47
- *
46
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
48
- * For element sizes smaller than uint64_t, we use tables to expand
47
* (which may be taken in preference to the one we started with
49
- * the N bits of the controlling predicate to a byte mask, and clear
48
* if it has higher priority).
50
- * those bytes.
49
*/
51
+/*
50
- stacked_ok =
52
+ * Copy Zn into Zd, and store zero into inactive elements.
51
+ stacked_ok = stacked_ok &&
53
+ * If inv, store zeros into the active elements.
52
v7m_stack_write(cpu, frameptr, env->regs[0], mmu_idx, false) &&
54
*/
53
v7m_stack_write(cpu, frameptr + 4, env->regs[1], mmu_idx, false) &&
55
-void HELPER(sve_clr_b)(void *vd, void *vg, uint32_t desc)
54
v7m_stack_write(cpu, frameptr + 8, env->regs[2], mmu_idx, false) &&
56
-{
55
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
57
- intptr_t i, opr_sz = simd_oprsz(desc) / 8;
56
v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) &&
58
- uint64_t *d = vd;
57
v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false);
59
- uint8_t *pg = vg;
58
60
- for (i = 0; i < opr_sz; i += 1) {
59
- /* Update SP regardless of whether any of the stack accesses failed. */
61
- d[i] &= ~expand_pred_b(pg[H1(i)]);
60
- env->regs[13] = frameptr;
62
- }
61
+ /*
63
-}
62
+ * If we broke a stack limit then SP was already updated earlier;
64
-
63
+ * otherwise we update SP regardless of whether any of the stack
65
-void HELPER(sve_clr_h)(void *vd, void *vg, uint32_t desc)
64
+ * accesses failed or we took some other kind of fault.
66
-{
65
+ */
67
- intptr_t i, opr_sz = simd_oprsz(desc) / 8;
66
+ if (!limitviol) {
68
- uint64_t *d = vd;
67
+ env->regs[13] = frameptr;
69
- uint8_t *pg = vg;
70
- for (i = 0; i < opr_sz; i += 1) {
71
- d[i] &= ~expand_pred_h(pg[H1(i)]);
72
- }
73
-}
74
-
75
-void HELPER(sve_clr_s)(void *vd, void *vg, uint32_t desc)
76
-{
77
- intptr_t i, opr_sz = simd_oprsz(desc) / 8;
78
- uint64_t *d = vd;
79
- uint8_t *pg = vg;
80
- for (i = 0; i < opr_sz; i += 1) {
81
- d[i] &= ~expand_pred_s(pg[H1(i)]);
82
- }
83
-}
84
-
85
-void HELPER(sve_clr_d)(void *vd, void *vg, uint32_t desc)
86
-{
87
- intptr_t i, opr_sz = simd_oprsz(desc) / 8;
88
- uint64_t *d = vd;
89
- uint8_t *pg = vg;
90
- for (i = 0; i < opr_sz; i += 1) {
91
- if (pg[H1(i)] & 1) {
92
- d[i] = 0;
93
- }
94
- }
95
-}
96
-
97
-/* Copy Zn into Zd, and store zero into inactive elements. */
98
void HELPER(sve_movz_b)(void *vd, void *vn, void *vg, uint32_t desc)
99
{
100
intptr_t i, opr_sz = simd_oprsz(desc) / 8;
101
+ uint64_t inv = -(uint64_t)(simd_data(desc) & 1);
102
uint64_t *d = vd, *n = vn;
103
uint8_t *pg = vg;
104
+
105
for (i = 0; i < opr_sz; i += 1) {
106
- d[i] = n[i] & expand_pred_b(pg[H1(i)]);
107
+ d[i] = n[i] & (expand_pred_b(pg[H1(i)]) ^ inv);
108
}
109
}
110
111
void HELPER(sve_movz_h)(void *vd, void *vn, void *vg, uint32_t desc)
112
{
113
intptr_t i, opr_sz = simd_oprsz(desc) / 8;
114
+ uint64_t inv = -(uint64_t)(simd_data(desc) & 1);
115
uint64_t *d = vd, *n = vn;
116
uint8_t *pg = vg;
117
+
118
for (i = 0; i < opr_sz; i += 1) {
119
- d[i] = n[i] & expand_pred_h(pg[H1(i)]);
120
+ d[i] = n[i] & (expand_pred_h(pg[H1(i)]) ^ inv);
121
}
122
}
123
124
void HELPER(sve_movz_s)(void *vd, void *vn, void *vg, uint32_t desc)
125
{
126
intptr_t i, opr_sz = simd_oprsz(desc) / 8;
127
+ uint64_t inv = -(uint64_t)(simd_data(desc) & 1);
128
uint64_t *d = vd, *n = vn;
129
uint8_t *pg = vg;
130
+
131
for (i = 0; i < opr_sz; i += 1) {
132
- d[i] = n[i] & expand_pred_s(pg[H1(i)]);
133
+ d[i] = n[i] & (expand_pred_s(pg[H1(i)]) ^ inv);
134
}
135
}
136
137
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_movz_d)(void *vd, void *vn, void *vg, uint32_t desc)
138
intptr_t i, opr_sz = simd_oprsz(desc) / 8;
139
uint64_t *d = vd, *n = vn;
140
uint8_t *pg = vg;
141
+ uint8_t inv = simd_data(desc);
142
+
143
for (i = 0; i < opr_sz; i += 1) {
144
- d[i] = n[i] & -(uint64_t)(pg[H1(i)] & 1);
145
+ d[i] = n[i] & -(uint64_t)((pg[H1(i)] ^ inv) & 1);
146
}
147
}
148
149
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
150
index XXXXXXX..XXXXXXX 100644
151
--- a/target/arm/translate-sve.c
152
+++ b/target/arm/translate-sve.c
153
@@ -XXX,XX +XXX,XX @@ static bool trans_SADDV(DisasContext *s, arg_rpr_esz *a)
154
*** SVE Shift by Immediate - Predicated Group
155
*/
156
157
-/* Store zero into every active element of Zd. We will use this for two
158
- * and three-operand predicated instructions for which logic dictates a
159
- * zero result.
160
+/*
161
+ * Copy Zn into Zd, storing zeros into inactive elements.
162
+ * If invert, store zeros into the active elements.
163
*/
164
-static bool do_clr_zp(DisasContext *s, int rd, int pg, int esz)
165
-{
166
- static gen_helper_gvec_2 * const fns[4] = {
167
- gen_helper_sve_clr_b, gen_helper_sve_clr_h,
168
- gen_helper_sve_clr_s, gen_helper_sve_clr_d,
169
- };
170
- if (sve_access_check(s)) {
171
- unsigned vsz = vec_full_reg_size(s);
172
- tcg_gen_gvec_2_ool(vec_full_reg_offset(s, rd),
173
- pred_full_reg_offset(s, pg),
174
- vsz, vsz, 0, fns[esz]);
175
- }
176
- return true;
177
-}
178
-
179
-/* Copy Zn into Zd, storing zeros into inactive elements. */
180
-static void do_movz_zpz(DisasContext *s, int rd, int rn, int pg, int esz)
181
+static bool do_movz_zpz(DisasContext *s, int rd, int rn, int pg,
182
+ int esz, bool invert)
183
{
184
static gen_helper_gvec_3 * const fns[4] = {
185
gen_helper_sve_movz_b, gen_helper_sve_movz_h,
186
gen_helper_sve_movz_s, gen_helper_sve_movz_d,
187
};
188
- unsigned vsz = vec_full_reg_size(s);
189
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd),
190
- vec_full_reg_offset(s, rn),
191
- pred_full_reg_offset(s, pg),
192
- vsz, vsz, 0, fns[esz]);
193
+
194
+ if (sve_access_check(s)) {
195
+ unsigned vsz = vec_full_reg_size(s);
196
+ tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd),
197
+ vec_full_reg_offset(s, rn),
198
+ pred_full_reg_offset(s, pg),
199
+ vsz, vsz, invert, fns[esz]);
68
+ }
200
+ }
69
201
+ return true;
70
return !stacked_ok;
202
}
203
204
static bool do_zpzi_ool(DisasContext *s, arg_rpri_esz *a,
205
@@ -XXX,XX +XXX,XX @@ static bool trans_LSR_zpzi(DisasContext *s, arg_rpri_esz *a)
206
/* Shift by element size is architecturally valid.
207
For logical shifts, it is a zeroing operation. */
208
if (a->imm >= (8 << a->esz)) {
209
- return do_clr_zp(s, a->rd, a->pg, a->esz);
210
+ return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true);
211
} else {
212
return do_zpzi_ool(s, a, fns[a->esz]);
213
}
214
@@ -XXX,XX +XXX,XX @@ static bool trans_LSL_zpzi(DisasContext *s, arg_rpri_esz *a)
215
/* Shift by element size is architecturally valid.
216
For logical shifts, it is a zeroing operation. */
217
if (a->imm >= (8 << a->esz)) {
218
- return do_clr_zp(s, a->rd, a->pg, a->esz);
219
+ return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true);
220
} else {
221
return do_zpzi_ool(s, a, fns[a->esz]);
222
}
223
@@ -XXX,XX +XXX,XX @@ static bool trans_ASRD(DisasContext *s, arg_rpri_esz *a)
224
/* Shift by element size is architecturally valid. For arithmetic
225
right shift for division, it is a zeroing operation. */
226
if (a->imm >= (8 << a->esz)) {
227
- return do_clr_zp(s, a->rd, a->pg, a->esz);
228
+ return do_movz_zpz(s, a->rd, a->rd, a->pg, a->esz, true);
229
} else {
230
return do_zpzi_ool(s, a, fns[a->esz]);
231
}
232
@@ -XXX,XX +XXX,XX @@ static bool trans_LD1R_zpri(DisasContext *s, arg_rpri_load *a)
233
234
/* Zero the inactive elements. */
235
gen_set_label(over);
236
- do_movz_zpz(s, a->rd, a->rd, a->pg, esz);
237
- return true;
238
+ return do_movz_zpz(s, a->rd, a->rd, a->pg, esz, false);
239
}
240
241
static void do_st_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,
242
@@ -XXX,XX +XXX,XX @@ static bool trans_MOVPRFX_m(DisasContext *s, arg_rpr_esz *a)
243
244
static bool trans_MOVPRFX_z(DisasContext *s, arg_rpr_esz *a)
245
{
246
- if (sve_access_check(s)) {
247
- do_movz_zpz(s, a->rd, a->rn, a->pg, a->esz);
248
- }
249
- return true;
250
+ return do_movz_zpz(s, a->rd, a->rn, a->pg, a->esz, false);
71
}
251
}
72
--
252
--
73
2.20.1
253
2.20.1
74
254
75
255
diff view generated by jsdifflib
1
In the v7M architecture, if an exception is generated in the process
1
From: Richard Henderson <richard.henderson@linaro.org>
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
Model after gen_gvec_fn_zzz et al.
11
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20200815013145.539409-11-richard.henderson@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
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
---
9
---
16
target/arm/cpu.h | 12 ++++++
10
target/arm/translate-sve.c | 29 ++++++++++++++---------------
17
hw/intc/armv7m_nvic.c | 96 +++++++++++++++++++++++++++++++++++++++++++
11
1 file changed, 14 insertions(+), 15 deletions(-)
18
2 files changed, 108 insertions(+)
19
12
20
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
13
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
21
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/cpu.h
15
--- a/target/arm/translate-sve.c
23
+++ b/target/arm/cpu.h
16
+++ b/target/arm/translate-sve.c
24
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure);
17
@@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s)
25
* a different exception).
18
return size_for_gvec(pred_full_reg_size(s));
26
*/
27
void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure);
28
+/**
29
+ * armv7m_nvic_set_pending_lazyfp: mark this lazy FP exception as pending
30
+ * @opaque: the NVIC
31
+ * @irq: the exception number to mark pending
32
+ * @secure: false for non-banked exceptions or for the nonsecure
33
+ * version of a banked exception, true for the secure version of a banked
34
+ * exception.
35
+ *
36
+ * Similar to armv7m_nvic_set_pending(), but specifically for exceptions
37
+ * generated in the course of lazy stacking of FP registers.
38
+ */
39
+void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure);
40
/**
41
* armv7m_nvic_get_pending_irq_info: return highest priority pending
42
* exception, and whether it targets Secure state
43
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/intc/armv7m_nvic.c
46
+++ b/hw/intc/armv7m_nvic.c
47
@@ -XXX,XX +XXX,XX @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure)
48
do_armv7m_nvic_set_pending(opaque, irq, secure, true);
49
}
19
}
50
20
51
+void armv7m_nvic_set_pending_lazyfp(void *opaque, int irq, bool secure)
21
+/* Invoke an out-of-line helper on 2 Zregs and a predicate. */
22
+static void gen_gvec_ool_zzp(DisasContext *s, gen_helper_gvec_3 *fn,
23
+ int rd, int rn, int pg, int data)
52
+{
24
+{
53
+ /*
25
+ unsigned vsz = vec_full_reg_size(s);
54
+ * Pend an exception during lazy FP stacking. This differs
26
+ tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd),
55
+ * from the usual exception pending because the logic for
27
+ vec_full_reg_offset(s, rn),
56
+ * whether we should escalate depends on the saved context
28
+ pred_full_reg_offset(s, pg),
57
+ * in the FPCCR register, not on the current state of the CPU/NVIC.
29
+ vsz, vsz, data, fn);
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
+}
30
+}
146
+
31
+
147
/* Make pending IRQ active. */
32
/* Invoke an out-of-line helper on 3 Zregs and a predicate. */
148
void armv7m_nvic_acknowledge_irq(void *opaque)
33
static void gen_gvec_ool_zzzp(DisasContext *s, gen_helper_gvec_4 *fn,
34
int rd, int rn, int rm, int pg, int data)
35
@@ -XXX,XX +XXX,XX @@ static bool do_zpz_ool(DisasContext *s, arg_rpr_esz *a, gen_helper_gvec_3 *fn)
36
return false;
37
}
38
if (sve_access_check(s)) {
39
- unsigned vsz = vec_full_reg_size(s);
40
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
41
- vec_full_reg_offset(s, a->rn),
42
- pred_full_reg_offset(s, a->pg),
43
- vsz, vsz, 0, fn);
44
+ gen_gvec_ool_zzp(s, fn, a->rd, a->rn, a->pg, 0);
45
}
46
return true;
47
}
48
@@ -XXX,XX +XXX,XX @@ static bool do_movz_zpz(DisasContext *s, int rd, int rn, int pg,
49
};
50
51
if (sve_access_check(s)) {
52
- unsigned vsz = vec_full_reg_size(s);
53
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd),
54
- vec_full_reg_offset(s, rn),
55
- pred_full_reg_offset(s, pg),
56
- vsz, vsz, invert, fns[esz]);
57
+ gen_gvec_ool_zzp(s, fns[esz], rd, rn, pg, invert);
58
}
59
return true;
60
}
61
@@ -XXX,XX +XXX,XX @@ static bool do_zpzi_ool(DisasContext *s, arg_rpri_esz *a,
62
gen_helper_gvec_3 *fn)
149
{
63
{
64
if (sve_access_check(s)) {
65
- unsigned vsz = vec_full_reg_size(s);
66
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
67
- vec_full_reg_offset(s, a->rn),
68
- pred_full_reg_offset(s, a->pg),
69
- vsz, vsz, a->imm, fn);
70
+ gen_gvec_ool_zzp(s, fn, a->rd, a->rn, a->pg, a->imm);
71
}
72
return true;
73
}
150
--
74
--
151
2.20.1
75
2.20.1
152
76
153
77
diff view generated by jsdifflib
1
Like AArch64, M-profile floating point has no FPEXC enable
1
From: Richard Henderson <richard.henderson@linaro.org>
2
bit to gate floating point; so always set the VFPEN TB flag.
3
2
4
M-profile also has CPACR and NSACR similar to A-profile;
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
they behave slightly differently:
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
* the CPACR is banked between Secure and Non-Secure
5
Message-id: 20200815013145.539409-12-richard.henderson@linaro.org
7
* if the NSACR forces a trap then this is taken to
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
the Secure state, not the Non-Secure state
7
---
8
target/arm/translate-sve.c | 53 +++++++++++++-------------------------
9
1 file changed, 18 insertions(+), 35 deletions(-)
9
10
10
Honour the CPACR and NSACR settings. The NSACR handling
11
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
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
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
18
Message-id: 20190416125744.27770-6-peter.maydell@linaro.org
19
---
20
target/arm/helper.c | 55 +++++++++++++++++++++++++++++++++++++++---
21
target/arm/translate.c | 10 ++++++--
22
2 files changed, 60 insertions(+), 5 deletions(-)
23
24
diff --git a/target/arm/helper.c b/target/arm/helper.c
25
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/helper.c
13
--- a/target/arm/translate-sve.c
27
+++ b/target/arm/helper.c
14
+++ b/target/arm/translate-sve.c
28
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
15
@@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s)
29
return target_el;
16
return size_for_gvec(pred_full_reg_size(s));
30
}
17
}
31
18
32
+/*
19
+/* Invoke an out-of-line helper on 3 Zregs. */
33
+ * Return true if the v7M CPACR permits access to the FPU for the specified
20
+static void gen_gvec_ool_zzz(DisasContext *s, gen_helper_gvec_3 *fn,
34
+ * security state and privilege level.
21
+ int rd, int rn, int rm, int data)
35
+ */
36
+static bool v7m_cpacr_pass(CPUARMState *env, bool is_secure, bool is_priv)
37
+{
22
+{
38
+ switch (extract32(env->v7m.cpacr[is_secure], 20, 2)) {
23
+ unsigned vsz = vec_full_reg_size(s);
39
+ case 0:
24
+ tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd),
40
+ case 2: /* UNPREDICTABLE: we treat like 0 */
25
+ vec_full_reg_offset(s, rn),
41
+ return false;
26
+ vec_full_reg_offset(s, rm),
42
+ case 1:
27
+ vsz, vsz, data, fn);
43
+ return is_priv;
44
+ case 3:
45
+ return true;
46
+ default:
47
+ g_assert_not_reached();
48
+ }
49
+}
28
+}
50
+
29
+
51
static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
30
/* Invoke an out-of-line helper on 2 Zregs and a predicate. */
52
ARMMMUIdx mmu_idx, bool ignfault)
31
static void gen_gvec_ool_zzp(DisasContext *s, gen_helper_gvec_3 *fn,
32
int rd, int rn, int pg, int data)
33
@@ -XXX,XX +XXX,XX @@ static bool do_zzw_ool(DisasContext *s, arg_rrr_esz *a, gen_helper_gvec_3 *fn)
34
return false;
35
}
36
if (sve_access_check(s)) {
37
- unsigned vsz = vec_full_reg_size(s);
38
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
39
- vec_full_reg_offset(s, a->rn),
40
- vec_full_reg_offset(s, a->rm),
41
- vsz, vsz, 0, fn);
42
+ gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, 0);
43
}
44
return true;
45
}
46
@@ -XXX,XX +XXX,XX @@ static bool trans_RDVL(DisasContext *s, arg_RDVL *a)
47
static bool do_adr(DisasContext *s, arg_rrri *a, gen_helper_gvec_3 *fn)
53
{
48
{
54
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
49
if (sve_access_check(s)) {
55
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK;
50
- unsigned vsz = vec_full_reg_size(s);
56
break;
51
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
57
case EXCP_NOCP:
52
- vec_full_reg_offset(s, a->rn),
58
- armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
53
- vec_full_reg_offset(s, a->rm),
59
- env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;
54
- vsz, vsz, a->imm, fn);
60
+ {
55
+ gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, a->imm);
61
+ /*
62
+ * NOCP might be directed to something other than the current
63
+ * security state if this fault is because of NSACR; we indicate
64
+ * the target security state using exception.target_el.
65
+ */
66
+ int target_secstate;
67
+
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
}
56
}
83
57
return true;
84
+ if (arm_feature(env, ARM_FEATURE_M)) {
58
}
85
+ /* CPACR can cause a NOCP UsageFault taken to current security state */
59
@@ -XXX,XX +XXX,XX @@ static bool trans_FTSSEL(DisasContext *s, arg_rrr_esz *a)
86
+ if (!v7m_cpacr_pass(env, env->v7m.secure, cur_el != 0)) {
60
return false;
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
*/
119
if (s->fp_excp_el) {
120
- gen_exception_insn(s, 4, EXCP_UDEF,
121
- syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
122
+ if (arm_dc_feature(s, ARM_FEATURE_M)) {
123
+ gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(),
124
+ s->fp_excp_el);
125
+ } else {
126
+ gen_exception_insn(s, 4, EXCP_UDEF,
127
+ syn_fp_access_trap(1, 0xe, false),
128
+ s->fp_excp_el);
129
+ }
130
return 0;
131
}
61
}
132
62
if (sve_access_check(s)) {
63
- unsigned vsz = vec_full_reg_size(s);
64
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
65
- vec_full_reg_offset(s, a->rn),
66
- vec_full_reg_offset(s, a->rm),
67
- vsz, vsz, 0, fns[a->esz]);
68
+ gen_gvec_ool_zzz(s, fns[a->esz], a->rd, a->rn, a->rm, 0);
69
}
70
return true;
71
}
72
@@ -XXX,XX +XXX,XX @@ static bool trans_TBL(DisasContext *s, arg_rrr_esz *a)
73
};
74
75
if (sve_access_check(s)) {
76
- unsigned vsz = vec_full_reg_size(s);
77
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
78
- vec_full_reg_offset(s, a->rn),
79
- vec_full_reg_offset(s, a->rm),
80
- vsz, vsz, 0, fns[a->esz]);
81
+ gen_gvec_ool_zzz(s, fns[a->esz], a->rd, a->rn, a->rm, 0);
82
}
83
return true;
84
}
85
@@ -XXX,XX +XXX,XX @@ static bool do_zzz_data_ool(DisasContext *s, arg_rrr_esz *a, int data,
86
gen_helper_gvec_3 *fn)
87
{
88
if (sve_access_check(s)) {
89
- unsigned vsz = vec_full_reg_size(s);
90
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
91
- vec_full_reg_offset(s, a->rn),
92
- vec_full_reg_offset(s, a->rm),
93
- vsz, vsz, data, fn);
94
+ gen_gvec_ool_zzz(s, fn, a->rd, a->rn, a->rm, data);
95
}
96
return true;
97
}
98
@@ -XXX,XX +XXX,XX @@ static bool trans_DOT_zzz(DisasContext *s, arg_DOT_zzz *a)
99
};
100
101
if (sve_access_check(s)) {
102
- unsigned vsz = vec_full_reg_size(s);
103
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
104
- vec_full_reg_offset(s, a->rn),
105
- vec_full_reg_offset(s, a->rm),
106
- vsz, vsz, 0, fns[a->u][a->sz]);
107
+ gen_gvec_ool_zzz(s, fns[a->u][a->sz], a->rd, a->rn, a->rm, 0);
108
}
109
return true;
110
}
111
@@ -XXX,XX +XXX,XX @@ static bool trans_DOT_zzx(DisasContext *s, arg_DOT_zzx *a)
112
};
113
114
if (sve_access_check(s)) {
115
- unsigned vsz = vec_full_reg_size(s);
116
- tcg_gen_gvec_3_ool(vec_full_reg_offset(s, a->rd),
117
- vec_full_reg_offset(s, a->rn),
118
- vec_full_reg_offset(s, a->rm),
119
- vsz, vsz, a->index, fns[a->u][a->sz]);
120
+ gen_gvec_ool_zzz(s, fns[a->u][a->sz], a->rd, a->rn, a->rm, a->index);
121
}
122
return true;
123
}
133
--
124
--
134
2.20.1
125
2.20.1
135
126
136
127
diff view generated by jsdifflib
Deleted patch
1
Correct the decode of the M-profile "coprocessor and
2
floating-point instructions" space:
3
* op0 == 0b11 is always unallocated
4
* if the CPU has an FPU then all insns with op1 == 0b101
5
are floating point and go to disas_vfp_insn()
6
1
7
For the moment we leave VLLDM and VLSTM as NOPs; in
8
a later commit we will fill in the proper implementation
9
for the case where an FPU is present.
10
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20190416125744.27770-7-peter.maydell@linaro.org
14
---
15
target/arm/translate.c | 26 ++++++++++++++++++++++----
16
1 file changed, 22 insertions(+), 4 deletions(-)
17
18
diff --git a/target/arm/translate.c b/target/arm/translate.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/translate.c
21
+++ b/target/arm/translate.c
22
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
23
case 6: case 7: case 14: case 15:
24
/* Coprocessor. */
25
if (arm_dc_feature(s, ARM_FEATURE_M)) {
26
- /* We don't currently implement M profile FP support,
27
- * so this entire space should give a NOCP fault, with
28
- * the exception of the v8M VLLDM and VLSTM insns, which
29
- * must be NOPs in Secure state and UNDEF in Nonsecure state.
30
+ /* 0b111x_11xx_xxxx_xxxx_xxxx_xxxx_xxxx_xxxx */
31
+ if (extract32(insn, 24, 2) == 3) {
32
+ goto illegal_op; /* op0 = 0b11 : unallocated */
33
+ }
34
+
35
+ /*
36
+ * Decode VLLDM and VLSTM first: these are nonstandard because:
37
+ * * if there is no FPU then these insns must NOP in
38
+ * Secure state and UNDEF in Nonsecure state
39
+ * * if there is an FPU then these insns do not have
40
+ * the usual behaviour that disas_vfp_insn() provides of
41
+ * being controlled by CPACR/NSACR enable bits or the
42
+ * lazy-stacking logic.
43
*/
44
if (arm_dc_feature(s, ARM_FEATURE_V8) &&
45
(insn & 0xffa00f00) == 0xec200a00) {
46
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
47
/* Just NOP since FP support is not implemented */
48
break;
49
}
50
+ if (arm_dc_feature(s, ARM_FEATURE_VFP) &&
51
+ ((insn >> 8) & 0xe) == 10) {
52
+ /* FP, and the CPU supports it */
53
+ if (disas_vfp_insn(s, insn)) {
54
+ goto illegal_op;
55
+ }
56
+ break;
57
+ }
58
+
59
/* All other insns: NOCP */
60
gen_exception_insn(s, 4, EXCP_NOCP, syn_uncategorized(),
61
default_exception_el(s));
62
--
63
2.20.1
64
65
diff view generated by jsdifflib
Deleted patch
1
If the floating point extension is present, then the SG instruction
2
must clear the CONTROL_S.SFPA bit. Implement this.
3
1
4
(On a no-FPU system the bit will always be zero, so we don't need
5
to make the clearing of the bit conditional on ARM_FEATURE_VFP.)
6
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-8-peter.maydell@linaro.org
10
---
11
target/arm/helper.c | 1 +
12
1 file changed, 1 insertion(+)
13
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
17
+++ b/target/arm/helper.c
18
@@ -XXX,XX +XXX,XX @@ static bool v7m_handle_execute_nsc(ARMCPU *cpu)
19
qemu_log_mask(CPU_LOG_INT, "...really an SG instruction at 0x%08" PRIx32
20
", executing it\n", env->regs[15]);
21
env->regs[14] &= ~1;
22
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_SFPA_MASK;
23
switch_v7m_security_state(env, true);
24
xpsr_write(env, 0, XPSR_IT);
25
env->regs[15] += 4;
26
--
27
2.20.1
28
29
diff view generated by jsdifflib
Deleted patch
1
Handle floating point registers in exception entry.
2
This corresponds to the FP-specific parts of the pseudocode
3
functions ActivateException() and PushStack().
4
1
5
We defer the code corresponding to UpdateFPCCR() to a later patch.
6
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20190416125744.27770-11-peter.maydell@linaro.org
10
---
11
target/arm/helper.c | 98 +++++++++++++++++++++++++++++++++++++++++++--
12
1 file changed, 95 insertions(+), 3 deletions(-)
13
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
17
+++ b/target/arm/helper.c
18
@@ -XXX,XX +XXX,XX @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
19
switch_v7m_security_state(env, targets_secure);
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
}
52
53
- frameptr -= 0x20;
54
+ xpsr &= ~XPSR_SFPA;
55
+ if (env->v7m.secure &&
56
+ (env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) {
57
+ xpsr |= XPSR_SFPA;
58
+ }
59
+
60
+ frameptr -= framesize;
61
62
if (arm_feature(env, ARM_FEATURE_V8)) {
63
uint32_t limit = v7m_sp_limit(env);
64
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_stack(ARMCPU *cpu)
65
v7m_stack_write(cpu, frameptr + 24, env->regs[15], mmu_idx, false) &&
66
v7m_stack_write(cpu, frameptr + 28, xpsr, mmu_idx, false);
67
68
+ if (env->v7m.control[M_REG_S] & R_V7M_CONTROL_FPCA_MASK) {
69
+ /* FPU is active, try to save its registers */
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
--
159
2.20.1
160
161
diff view generated by jsdifflib
1
The magic value pushed onto the callee stack as an integrity
1
From: Richard Henderson <richard.henderson@linaro.org>
2
check is different if floating point is present.
3
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20200815013145.539409-13-richard.henderson@linaro.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
6
Message-id: 20190416125744.27770-15-peter.maydell@linaro.org
7
---
7
---
8
target/arm/helper.c | 22 +++++++++++++++++++---
8
target/arm/translate-sve.c | 20 ++++++++++++--------
9
1 file changed, 19 insertions(+), 3 deletions(-)
9
1 file changed, 12 insertions(+), 8 deletions(-)
10
10
11
diff --git a/target/arm/helper.c b/target/arm/helper.c
11
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
12
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
13
--- a/target/arm/helper.c
13
--- a/target/arm/translate-sve.c
14
+++ b/target/arm/helper.c
14
+++ b/target/arm/translate-sve.c
15
@@ -XXX,XX +XXX,XX @@ load_fail:
15
@@ -XXX,XX +XXX,XX @@ static int pred_gvec_reg_size(DisasContext *s)
16
return false;
16
return size_for_gvec(pred_full_reg_size(s));
17
}
17
}
18
18
19
+static uint32_t v7m_integrity_sig(CPUARMState *env, uint32_t lr)
19
+/* Invoke an out-of-line helper on 2 Zregs. */
20
+static void gen_gvec_ool_zz(DisasContext *s, gen_helper_gvec_2 *fn,
21
+ int rd, int rn, int data)
20
+{
22
+{
21
+ /*
23
+ unsigned vsz = vec_full_reg_size(s);
22
+ * Return the integrity signature value for the callee-saves
24
+ tcg_gen_gvec_2_ool(vec_full_reg_offset(s, rd),
23
+ * stack frame section. @lr is the exception return payload/LR value
25
+ vec_full_reg_offset(s, rn),
24
+ * whose FType bit forms bit 0 of the signature if FP is present.
26
+ vsz, vsz, data, fn);
25
+ */
26
+ uint32_t sig = 0xfefa125a;
27
+
28
+ if (!arm_feature(env, ARM_FEATURE_VFP) || (lr & R_V7M_EXCRET_FTYPE_MASK)) {
29
+ sig |= 1;
30
+ }
31
+ return sig;
32
+}
27
+}
33
+
28
+
34
static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
29
/* Invoke an out-of-line helper on 3 Zregs. */
35
bool ignore_faults)
30
static void gen_gvec_ool_zzz(DisasContext *s, gen_helper_gvec_3 *fn,
36
{
31
int rd, int rn, int rm, int data)
37
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
32
@@ -XXX,XX +XXX,XX @@ static bool trans_FEXPA(DisasContext *s, arg_rr_esz *a)
38
bool stacked_ok;
33
return false;
39
uint32_t limit;
34
}
40
bool want_psp;
35
if (sve_access_check(s)) {
41
+ uint32_t sig;
36
- unsigned vsz = vec_full_reg_size(s);
42
37
- tcg_gen_gvec_2_ool(vec_full_reg_offset(s, a->rd),
43
if (dotailchain) {
38
- vec_full_reg_offset(s, a->rn),
44
bool mode = lr & R_V7M_EXCRET_MODE_MASK;
39
- vsz, vsz, 0, fns[a->esz]);
45
@@ -XXX,XX +XXX,XX @@ static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
40
+ gen_gvec_ool_zz(s, fns[a->esz], a->rd, a->rn, 0);
46
/* Write as much of the stack frame as we can. A write failure may
41
}
47
* cause us to pend a derived exception.
42
return true;
48
*/
43
}
49
+ sig = v7m_integrity_sig(env, lr);
44
@@ -XXX,XX +XXX,XX @@ static bool trans_REV_v(DisasContext *s, arg_rr_esz *a)
50
stacked_ok =
45
};
51
- v7m_stack_write(cpu, frameptr, 0xfefa125b, mmu_idx, ignore_faults) &&
46
52
+ v7m_stack_write(cpu, frameptr, sig, mmu_idx, ignore_faults) &&
47
if (sve_access_check(s)) {
53
v7m_stack_write(cpu, frameptr + 0x8, env->regs[4], mmu_idx,
48
- unsigned vsz = vec_full_reg_size(s);
54
ignore_faults) &&
49
- tcg_gen_gvec_2_ool(vec_full_reg_offset(s, a->rd),
55
v7m_stack_write(cpu, frameptr + 0xc, env->regs[5], mmu_idx,
50
- vec_full_reg_offset(s, a->rn),
56
@@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu)
51
- vsz, vsz, 0, fns[a->esz]);
57
if (return_to_secure &&
52
+ gen_gvec_ool_zz(s, fns[a->esz], a->rd, a->rn, 0);
58
((excret & R_V7M_EXCRET_ES_MASK) == 0 ||
53
}
59
(excret & R_V7M_EXCRET_DCRS_MASK) == 0)) {
54
return true;
60
- uint32_t expected_sig = 0xfefa125b;
55
}
61
uint32_t actual_sig;
62
63
pop_ok = v7m_stack_read(cpu, &actual_sig, frameptr, mmu_idx);
64
65
- if (pop_ok && expected_sig != actual_sig) {
66
+ if (pop_ok && v7m_integrity_sig(env, excret) != actual_sig) {
67
/* Take a SecureFault on the current stack */
68
env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK;
69
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
70
--
56
--
71
2.20.1
57
2.20.1
72
58
73
59
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Reviewed-by: Markus Armbruster <armbru@redhat.com>
3
Rather than require the user to fill in the immediate (shl or shr),
4
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
4
create full formats that include the immediate.
5
Message-id: 20190412165416.7977-5-philmd@redhat.com
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20200815013145.539409-14-richard.henderson@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
10
---
8
include/hw/devices.h | 6 ------
11
target/arm/sve.decode | 35 ++++++++++++++++-------------------
9
include/hw/display/tc6393xb.h | 24 ++++++++++++++++++++++++
12
1 file changed, 16 insertions(+), 19 deletions(-)
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
13
16
diff --git a/include/hw/devices.h b/include/hw/devices.h
14
diff --git a/target/arm/sve.decode b/target/arm/sve.decode
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/devices.h
16
--- a/target/arm/sve.decode
19
+++ b/include/hw/devices.h
17
+++ b/target/arm/sve.decode
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 @@
18
@@ -XXX,XX +XXX,XX @@
37
+/*
19
@rd_rn_i6 ........ ... rn:5 ..... imm:s6 rd:5 &rri
38
+ * Toshiba TC6393XB I/O Controller.
20
39
+ * Found in Sharp Zaurus SL-6000 (tosa) or some
21
# Two register operand, one immediate operand, with predicate,
40
+ * Toshiba e-Series PDAs.
22
-# element size encoded as TSZHL. User must fill in imm.
41
+ *
23
-@rdn_pg_tszimm ........ .. ... ... ... pg:3 ..... rd:5 \
42
+ * Copyright (c) 2007 Hervé Poussineau
24
- &rpri_esz rn=%reg_movprfx esz=%tszimm_esz
43
+ *
25
+# element size encoded as TSZHL.
44
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
26
+@rdn_pg_tszimm_shl ........ .. ... ... ... pg:3 ..... rd:5 \
45
+ * See the COPYING file in the top-level directory.
27
+ &rpri_esz rn=%reg_movprfx esz=%tszimm_esz imm=%tszimm_shl
46
+ */
28
+@rdn_pg_tszimm_shr ........ .. ... ... ... pg:3 ..... rd:5 \
47
+
29
+ &rpri_esz rn=%reg_movprfx esz=%tszimm_esz imm=%tszimm_shr
48
+#ifndef HW_DISPLAY_TC6393XB_H
30
49
+#define HW_DISPLAY_TC6393XB_H
31
# Similarly without predicate.
50
+
32
-@rd_rn_tszimm ........ .. ... ... ...... rn:5 rd:5 \
51
+#include "exec/memory.h"
33
- &rri_esz esz=%tszimm16_esz
52
+#include "hw/irq.h"
34
+@rd_rn_tszimm_shl ........ .. ... ... ...... rn:5 rd:5 \
53
+
35
+ &rri_esz esz=%tszimm16_esz imm=%tszimm16_shl
54
+typedef struct TC6393xbState TC6393xbState;
36
+@rd_rn_tszimm_shr ........ .. ... ... ...... rn:5 rd:5 \
55
+
37
+ &rri_esz esz=%tszimm16_esz imm=%tszimm16_shr
56
+TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
38
57
+ uint32_t base, qemu_irq irq);
39
# Two register operand, one immediate operand, with 4-bit predicate.
58
+qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
40
# User must fill in imm.
59
+
41
@@ -XXX,XX +XXX,XX @@ UMINV 00000100 .. 001 011 001 ... ..... ..... @rd_pg_rn
60
+#endif
42
### SVE Shift by Immediate - Predicated Group
61
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
43
62
index XXXXXXX..XXXXXXX 100644
44
# SVE bitwise shift by immediate (predicated)
63
--- a/hw/arm/tosa.c
45
-ASR_zpzi 00000100 .. 000 000 100 ... .. ... ..... \
64
+++ b/hw/arm/tosa.c
46
- @rdn_pg_tszimm imm=%tszimm_shr
65
@@ -XXX,XX +XXX,XX @@
47
-LSR_zpzi 00000100 .. 000 001 100 ... .. ... ..... \
66
#include "hw/hw.h"
48
- @rdn_pg_tszimm imm=%tszimm_shr
67
#include "hw/arm/pxa.h"
49
-LSL_zpzi 00000100 .. 000 011 100 ... .. ... ..... \
68
#include "hw/arm/arm.h"
50
- @rdn_pg_tszimm imm=%tszimm_shl
69
-#include "hw/devices.h"
51
-ASRD 00000100 .. 000 100 100 ... .. ... ..... \
70
#include "hw/arm/sharpsl.h"
52
- @rdn_pg_tszimm imm=%tszimm_shr
71
#include "hw/pcmcia.h"
53
+ASR_zpzi 00000100 .. 000 000 100 ... .. ... ..... @rdn_pg_tszimm_shr
72
#include "hw/boards.h"
54
+LSR_zpzi 00000100 .. 000 001 100 ... .. ... ..... @rdn_pg_tszimm_shr
73
+#include "hw/display/tc6393xb.h"
55
+LSL_zpzi 00000100 .. 000 011 100 ... .. ... ..... @rdn_pg_tszimm_shl
74
#include "hw/i2c/i2c.h"
56
+ASRD 00000100 .. 000 100 100 ... .. ... ..... @rdn_pg_tszimm_shr
75
#include "hw/ssi/ssi.h"
57
76
#include "hw/sysbus.h"
58
# SVE bitwise shift by vector (predicated)
77
diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
59
ASR_zpzz 00000100 .. 010 000 100 ... ..... ..... @rdn_pg_rm
78
index XXXXXXX..XXXXXXX 100644
60
@@ -XXX,XX +XXX,XX @@ RDVL 00000100 101 11111 01010 imm:s6 rd:5
79
--- a/hw/display/tc6393xb.c
61
### SVE Bitwise Shift - Unpredicated Group
80
+++ b/hw/display/tc6393xb.c
62
81
@@ -XXX,XX +XXX,XX @@
63
# SVE bitwise shift by immediate (unpredicated)
82
#include "qapi/error.h"
64
-ASR_zzi 00000100 .. 1 ..... 1001 00 ..... ..... \
83
#include "qemu/host-utils.h"
65
- @rd_rn_tszimm imm=%tszimm16_shr
84
#include "hw/hw.h"
66
-LSR_zzi 00000100 .. 1 ..... 1001 01 ..... ..... \
85
-#include "hw/devices.h"
67
- @rd_rn_tszimm imm=%tszimm16_shr
86
+#include "hw/display/tc6393xb.h"
68
-LSL_zzi 00000100 .. 1 ..... 1001 11 ..... ..... \
87
#include "hw/block/flash.h"
69
- @rd_rn_tszimm imm=%tszimm16_shl
88
#include "ui/console.h"
70
+ASR_zzi 00000100 .. 1 ..... 1001 00 ..... ..... @rd_rn_tszimm_shr
89
#include "ui/pixel_ops.h"
71
+LSR_zzi 00000100 .. 1 ..... 1001 01 ..... ..... @rd_rn_tszimm_shr
90
diff --git a/MAINTAINERS b/MAINTAINERS
72
+LSL_zzi 00000100 .. 1 ..... 1001 11 ..... ..... @rd_rn_tszimm_shl
91
index XXXXXXX..XXXXXXX 100644
73
92
--- a/MAINTAINERS
74
# SVE bitwise shift by wide elements (unpredicated)
93
+++ b/MAINTAINERS
75
# Note esz != 3
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
--
76
--
103
2.20.1
77
2.20.1
104
78
105
79
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@redhat.com>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
No code used the tc6393xb_gpio_in_get() and tc6393xb_gpio_out_set()
3
Unify add/sub helpers and add a parameter for rounding.
4
functions since their introduction in commit 88d2c950b002. Time to
4
This will allow saturating non-rounding to reuse this code.
5
remove them.
6
5
7
Suggested-by: Markus Armbruster <armbru@redhat.com>
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7
[PMM: fixed accidental use of '=' rather than '+=' in do_sqrdmlah_s]
9
Message-id: 20190412165416.7977-4-philmd@redhat.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20200815013145.539409-15-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
include/hw/devices.h | 3 ---
12
target/arm/vec_helper.c | 80 +++++++++++++++--------------------------
14
hw/display/tc6393xb.c | 16 ----------------
13
1 file changed, 29 insertions(+), 51 deletions(-)
15
2 files changed, 19 deletions(-)
16
14
17
diff --git a/include/hw/devices.h b/include/hw/devices.h
15
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/devices.h
17
--- a/target/arm/vec_helper.c
20
+++ b/include/hw/devices.h
18
+++ b/target/arm/vec_helper.c
21
@@ -XXX,XX +XXX,XX @@ void retu_key_event(void *retu, int state);
19
@@ -XXX,XX +XXX,XX @@
22
typedef struct TC6393xbState TC6393xbState;
23
TC6393xbState *tc6393xb_init(struct MemoryRegion *sysmem,
24
uint32_t base, qemu_irq irq);
25
-void tc6393xb_gpio_out_set(TC6393xbState *s, int line,
26
- qemu_irq handler);
27
-qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s);
28
qemu_irq tc6393xb_l3v_get(TC6393xbState *s);
29
30
#endif
20
#endif
31
diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
21
32
index XXXXXXX..XXXXXXX 100644
22
/* Signed saturating rounding doubling multiply-accumulate high half, 16-bit */
33
--- a/hw/display/tc6393xb.c
23
-static int16_t inl_qrdmlah_s16(int16_t src1, int16_t src2,
34
+++ b/hw/display/tc6393xb.c
24
- int16_t src3, uint32_t *sat)
35
@@ -XXX,XX +XXX,XX @@ struct TC6393xbState {
25
+static int16_t do_sqrdmlah_h(int16_t src1, int16_t src2, int16_t src3,
36
blanked : 1;
26
+ bool neg, bool round, uint32_t *sat)
37
};
27
{
38
28
- /* Simplify:
39
-qemu_irq *tc6393xb_gpio_in_get(TC6393xbState *s)
29
+ /*
30
+ * Simplify:
31
* = ((a3 << 16) + ((e1 * e2) << 1) + (1 << 15)) >> 16
32
* = ((a3 << 15) + (e1 * e2) + (1 << 14)) >> 15
33
*/
34
int32_t ret = (int32_t)src1 * src2;
35
- ret = ((int32_t)src3 << 15) + ret + (1 << 14);
36
+ if (neg) {
37
+ ret = -ret;
38
+ }
39
+ ret += ((int32_t)src3 << 15) + (round << 14);
40
ret >>= 15;
41
+
42
if (ret != (int16_t)ret) {
43
*sat = 1;
44
- ret = (ret < 0 ? -0x8000 : 0x7fff);
45
+ ret = (ret < 0 ? INT16_MIN : INT16_MAX);
46
}
47
return ret;
48
}
49
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_qrdmlah_s16)(CPUARMState *env, uint32_t src1,
50
uint32_t src2, uint32_t src3)
51
{
52
uint32_t *sat = &env->vfp.qc[0];
53
- uint16_t e1 = inl_qrdmlah_s16(src1, src2, src3, sat);
54
- uint16_t e2 = inl_qrdmlah_s16(src1 >> 16, src2 >> 16, src3 >> 16, sat);
55
+ uint16_t e1 = do_sqrdmlah_h(src1, src2, src3, false, true, sat);
56
+ uint16_t e2 = do_sqrdmlah_h(src1 >> 16, src2 >> 16, src3 >> 16,
57
+ false, true, sat);
58
return deposit32(e1, 16, 16, e2);
59
}
60
61
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlah_s16)(void *vd, void *vn, void *vm,
62
uintptr_t i;
63
64
for (i = 0; i < opr_sz / 2; ++i) {
65
- d[i] = inl_qrdmlah_s16(n[i], m[i], d[i], vq);
66
+ d[i] = do_sqrdmlah_h(n[i], m[i], d[i], false, true, vq);
67
}
68
clear_tail(d, opr_sz, simd_maxsz(desc));
69
}
70
71
-/* Signed saturating rounding doubling multiply-subtract high half, 16-bit */
72
-static int16_t inl_qrdmlsh_s16(int16_t src1, int16_t src2,
73
- int16_t src3, uint32_t *sat)
40
-{
74
-{
41
- return s->gpio_in;
75
- /* Similarly, using subtraction:
76
- * = ((a3 << 16) - ((e1 * e2) << 1) + (1 << 15)) >> 16
77
- * = ((a3 << 15) - (e1 * e2) + (1 << 14)) >> 15
78
- */
79
- int32_t ret = (int32_t)src1 * src2;
80
- ret = ((int32_t)src3 << 15) - ret + (1 << 14);
81
- ret >>= 15;
82
- if (ret != (int16_t)ret) {
83
- *sat = 1;
84
- ret = (ret < 0 ? -0x8000 : 0x7fff);
85
- }
86
- return ret;
42
-}
87
-}
43
-
88
-
44
static void tc6393xb_gpio_set(void *opaque, int line, int level)
89
uint32_t HELPER(neon_qrdmlsh_s16)(CPUARMState *env, uint32_t src1,
90
uint32_t src2, uint32_t src3)
45
{
91
{
46
// TC6393xbState *s = opaque;
92
uint32_t *sat = &env->vfp.qc[0];
47
@@ -XXX,XX +XXX,XX @@ static void tc6393xb_gpio_set(void *opaque, int line, int level)
93
- uint16_t e1 = inl_qrdmlsh_s16(src1, src2, src3, sat);
48
// FIXME: how does the chip reflect the GPIO input level change?
94
- uint16_t e2 = inl_qrdmlsh_s16(src1 >> 16, src2 >> 16, src3 >> 16, sat);
95
+ uint16_t e1 = do_sqrdmlah_h(src1, src2, src3, true, true, sat);
96
+ uint16_t e2 = do_sqrdmlah_h(src1 >> 16, src2 >> 16, src3 >> 16,
97
+ true, true, sat);
98
return deposit32(e1, 16, 16, e2);
49
}
99
}
50
100
51
-void tc6393xb_gpio_out_set(TC6393xbState *s, int line,
101
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s16)(void *vd, void *vn, void *vm,
52
- qemu_irq handler)
102
uintptr_t i;
103
104
for (i = 0; i < opr_sz / 2; ++i) {
105
- d[i] = inl_qrdmlsh_s16(n[i], m[i], d[i], vq);
106
+ d[i] = do_sqrdmlah_h(n[i], m[i], d[i], true, true, vq);
107
}
108
clear_tail(d, opr_sz, simd_maxsz(desc));
109
}
110
111
/* Signed saturating rounding doubling multiply-accumulate high half, 32-bit */
112
-static int32_t inl_qrdmlah_s32(int32_t src1, int32_t src2,
113
- int32_t src3, uint32_t *sat)
114
+static int32_t do_sqrdmlah_s(int32_t src1, int32_t src2, int32_t src3,
115
+ bool neg, bool round, uint32_t *sat)
116
{
117
/* Simplify similarly to int_qrdmlah_s16 above. */
118
int64_t ret = (int64_t)src1 * src2;
119
- ret = ((int64_t)src3 << 31) + ret + (1 << 30);
120
+ if (neg) {
121
+ ret = -ret;
122
+ }
123
+ ret += ((int64_t)src3 << 31) + (round << 30);
124
ret >>= 31;
125
+
126
if (ret != (int32_t)ret) {
127
*sat = 1;
128
ret = (ret < 0 ? INT32_MIN : INT32_MAX);
129
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(neon_qrdmlah_s32)(CPUARMState *env, int32_t src1,
130
int32_t src2, int32_t src3)
131
{
132
uint32_t *sat = &env->vfp.qc[0];
133
- return inl_qrdmlah_s32(src1, src2, src3, sat);
134
+ return do_sqrdmlah_s(src1, src2, src3, false, true, sat);
135
}
136
137
void HELPER(gvec_qrdmlah_s32)(void *vd, void *vn, void *vm,
138
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlah_s32)(void *vd, void *vn, void *vm,
139
uintptr_t i;
140
141
for (i = 0; i < opr_sz / 4; ++i) {
142
- d[i] = inl_qrdmlah_s32(n[i], m[i], d[i], vq);
143
+ d[i] = do_sqrdmlah_s(n[i], m[i], d[i], false, true, vq);
144
}
145
clear_tail(d, opr_sz, simd_maxsz(desc));
146
}
147
148
-/* Signed saturating rounding doubling multiply-subtract high half, 32-bit */
149
-static int32_t inl_qrdmlsh_s32(int32_t src1, int32_t src2,
150
- int32_t src3, uint32_t *sat)
53
-{
151
-{
54
- if (line >= TC6393XB_GPIOS) {
152
- /* Simplify similarly to int_qrdmlsh_s16 above. */
55
- fprintf(stderr, "TC6393xb: no GPIO pin %d\n", line);
153
- int64_t ret = (int64_t)src1 * src2;
56
- return;
154
- ret = ((int64_t)src3 << 31) - ret + (1 << 30);
155
- ret >>= 31;
156
- if (ret != (int32_t)ret) {
157
- *sat = 1;
158
- ret = (ret < 0 ? INT32_MIN : INT32_MAX);
57
- }
159
- }
58
-
160
- return ret;
59
- s->handler[line] = handler;
60
-}
161
-}
61
-
162
-
62
static void tc6393xb_gpio_handler_update(TC6393xbState *s)
163
uint32_t HELPER(neon_qrdmlsh_s32)(CPUARMState *env, int32_t src1,
164
int32_t src2, int32_t src3)
63
{
165
{
64
uint32_t level, diff;
166
uint32_t *sat = &env->vfp.qc[0];
167
- return inl_qrdmlsh_s32(src1, src2, src3, sat);
168
+ return do_sqrdmlah_s(src1, src2, src3, true, true, sat);
169
}
170
171
void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm,
172
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm,
173
uintptr_t i;
174
175
for (i = 0; i < opr_sz / 4; ++i) {
176
- d[i] = inl_qrdmlsh_s32(n[i], m[i], d[i], vq);
177
+ d[i] = do_sqrdmlah_s(n[i], m[i], d[i], true, true, vq);
178
}
179
clear_tail(d, opr_sz, simd_maxsz(desc));
180
}
65
--
181
--
66
2.20.1
182
2.20.1
67
183
68
184
diff view generated by jsdifflib
1
Implement the VLSTM instruction for v7M for the FPU present case.
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20200815013145.539409-19-richard.henderson@linaro.org
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190416125744.27770-25-peter.maydell@linaro.org
6
---
7
---
7
target/arm/cpu.h | 2 +
8
target/arm/helper.h | 4 ++++
8
target/arm/helper.h | 2 +
9
target/arm/translate-a64.c | 16 ++++++++++++++++
9
target/arm/helper.c | 84 ++++++++++++++++++++++++++++++++++++++++++
10
target/arm/vec_helper.c | 29 +++++++++++++++++++++++++----
10
target/arm/translate.c | 15 +++++++-
11
3 files changed, 45 insertions(+), 4 deletions(-)
11
4 files changed, 102 insertions(+), 1 deletion(-)
12
12
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
16
+++ b/target/arm/cpu.h
17
@@ -XXX,XX +XXX,XX @@
18
#define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */
19
#define EXCP_STKOF 19 /* v8M STKOF UsageFault */
20
#define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */
21
+#define EXCP_LSERR 21 /* v8M LSERR SecureFault */
22
+#define EXCP_UNALIGNED 22 /* v7M UNALIGNED UsageFault */
23
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
24
25
#define ARMV7M_EXCP_RESET 1
26
diff --git a/target/arm/helper.h b/target/arm/helper.h
13
diff --git a/target/arm/helper.h b/target/arm/helper.h
27
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/helper.h
15
--- a/target/arm/helper.h
29
+++ b/target/arm/helper.h
16
+++ b/target/arm/helper.h
30
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32)
17
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(gvec_uaba_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
31
18
DEF_HELPER_FLAGS_4(gvec_uaba_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
32
DEF_HELPER_1(v7m_preserve_fp_state, void, env)
19
DEF_HELPER_FLAGS_4(gvec_uaba_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
33
20
34
+DEF_HELPER_2(v7m_vlstm, void, env, i32)
21
+DEF_HELPER_FLAGS_4(gvec_mul_idx_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
22
+DEF_HELPER_FLAGS_4(gvec_mul_idx_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
23
+DEF_HELPER_FLAGS_4(gvec_mul_idx_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
35
+
24
+
36
DEF_HELPER_2(v8m_stackcheck, void, env, i32)
25
#ifdef TARGET_AARCH64
37
26
#include "helper-a64.h"
38
DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32)
27
#include "helper-sve.h"
39
diff --git a/target/arm/helper.c b/target/arm/helper.c
28
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
40
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
41
--- a/target/arm/helper.c
30
--- a/target/arm/translate-a64.c
42
+++ b/target/arm/helper.c
31
+++ b/target/arm/translate-a64.c
43
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
32
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
44
g_assert_not_reached();
33
data, gen_helper_gvec_fmlal_idx_a64);
45
}
34
}
46
35
return;
47
+void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
36
+
48
+{
37
+ case 0x08: /* MUL */
49
+ /* translate.c should never generate calls here in user-only mode */
38
+ if (!is_long && !is_scalar) {
50
+ g_assert_not_reached();
39
+ static gen_helper_gvec_3 * const fns[3] = {
40
+ gen_helper_gvec_mul_idx_h,
41
+ gen_helper_gvec_mul_idx_s,
42
+ gen_helper_gvec_mul_idx_d,
43
+ };
44
+ tcg_gen_gvec_3_ool(vec_full_reg_offset(s, rd),
45
+ vec_full_reg_offset(s, rn),
46
+ vec_full_reg_offset(s, rm),
47
+ is_q ? 16 : 8, vec_full_reg_size(s),
48
+ index, fns[size - 1]);
49
+ return;
50
+ }
51
+ break;
52
}
53
54
if (size == 3) {
55
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
56
index XXXXXXX..XXXXXXX 100644
57
--- a/target/arm/vec_helper.c
58
+++ b/target/arm/vec_helper.c
59
@@ -XXX,XX +XXX,XX @@ DO_3OP(gvec_rsqrts_d, helper_rsqrtsf_f64, float64)
60
*/
61
62
#define DO_MUL_IDX(NAME, TYPE, H) \
63
+void HELPER(NAME)(void *vd, void *vn, void *vm, uint32_t desc) \
64
+{ \
65
+ intptr_t i, j, oprsz = simd_oprsz(desc), segment = 16 / sizeof(TYPE); \
66
+ intptr_t idx = simd_data(desc); \
67
+ TYPE *d = vd, *n = vn, *m = vm; \
68
+ for (i = 0; i < oprsz / sizeof(TYPE); i += segment) { \
69
+ TYPE mm = m[H(i + idx)]; \
70
+ for (j = 0; j < segment; j++) { \
71
+ d[i + j] = n[i + j] * mm; \
72
+ } \
73
+ } \
74
+ clear_tail(d, oprsz, simd_maxsz(desc)); \
51
+}
75
+}
52
+
76
+
53
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
77
+DO_MUL_IDX(gvec_mul_idx_h, uint16_t, H2)
54
{
78
+DO_MUL_IDX(gvec_mul_idx_s, uint32_t, H4)
55
/* The TT instructions can be used by unprivileged code, but in
79
+DO_MUL_IDX(gvec_mul_idx_d, uint64_t, )
56
@@ -XXX,XX +XXX,XX @@ static void v7m_update_fpccr(CPUARMState *env, uint32_t frameptr,
80
+
57
}
81
+#undef DO_MUL_IDX
82
+
83
+#define DO_FMUL_IDX(NAME, TYPE, H) \
84
void HELPER(NAME)(void *vd, void *vn, void *vm, void *stat, uint32_t desc) \
85
{ \
86
intptr_t i, j, oprsz = simd_oprsz(desc), segment = 16 / sizeof(TYPE); \
87
@@ -XXX,XX +XXX,XX @@ void HELPER(NAME)(void *vd, void *vn, void *vm, void *stat, uint32_t desc) \
88
clear_tail(d, oprsz, simd_maxsz(desc)); \
58
}
89
}
59
90
60
+void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
91
-DO_MUL_IDX(gvec_fmul_idx_h, float16, H2)
61
+{
92
-DO_MUL_IDX(gvec_fmul_idx_s, float32, H4)
62
+ /* fptr is the value of Rn, the frame pointer we store the FP regs to */
93
-DO_MUL_IDX(gvec_fmul_idx_d, float64, )
63
+ bool s = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
94
+DO_FMUL_IDX(gvec_fmul_idx_h, float16, H2)
64
+ bool lspact = env->v7m.fpccr[s] & R_V7M_FPCCR_LSPACT_MASK;
95
+DO_FMUL_IDX(gvec_fmul_idx_s, float32, H4)
65
+
96
+DO_FMUL_IDX(gvec_fmul_idx_d, float64, )
66
+ assert(env->v7m.secure);
97
67
+
98
-#undef DO_MUL_IDX
68
+ if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) {
99
+#undef DO_FMUL_IDX
69
+ return;
100
70
+ }
101
#define DO_FMLA_IDX(NAME, TYPE, H) \
71
+
102
void HELPER(NAME)(void *vd, void *vn, void *vm, void *va, \
72
+ /* Check access to the coprocessor is permitted */
73
+ if (!v7m_cpacr_pass(env, true, arm_current_el(env) != 0)) {
74
+ raise_exception_ra(env, EXCP_NOCP, 0, 1, GETPC());
75
+ }
76
+
77
+ if (lspact) {
78
+ /* LSPACT should not be active when there is active FP state */
79
+ raise_exception_ra(env, EXCP_LSERR, 0, 1, GETPC());
80
+ }
81
+
82
+ if (fptr & 7) {
83
+ raise_exception_ra(env, EXCP_UNALIGNED, 0, 1, GETPC());
84
+ }
85
+
86
+ /*
87
+ * Note that we do not use v7m_stack_write() here, because the
88
+ * accesses should not set the FSR bits for stacking errors if they
89
+ * fail. (In pseudocode terms, they are AccType_NORMAL, not AccType_STACK
90
+ * or AccType_LAZYFP). Faults in cpu_stl_data() will throw exceptions
91
+ * and longjmp out.
92
+ */
93
+ if (!(env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_LSPEN_MASK)) {
94
+ bool ts = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_TS_MASK;
95
+ int i;
96
+
97
+ for (i = 0; i < (ts ? 32 : 16); i += 2) {
98
+ uint64_t dn = *aa32_vfp_dreg(env, i / 2);
99
+ uint32_t faddr = fptr + 4 * i;
100
+ uint32_t slo = extract64(dn, 0, 32);
101
+ uint32_t shi = extract64(dn, 32, 32);
102
+
103
+ if (i >= 16) {
104
+ faddr += 8; /* skip the slot for the FPSCR */
105
+ }
106
+ cpu_stl_data(env, faddr, slo);
107
+ cpu_stl_data(env, faddr + 4, shi);
108
+ }
109
+ cpu_stl_data(env, fptr + 0x40, vfp_get_fpscr(env));
110
+
111
+ /*
112
+ * If TS is 0 then s0 to s15 and FPSCR are UNKNOWN; we choose to
113
+ * leave them unchanged, matching our choice in v7m_preserve_fp_state.
114
+ */
115
+ if (ts) {
116
+ for (i = 0; i < 32; i += 2) {
117
+ *aa32_vfp_dreg(env, i / 2) = 0;
118
+ }
119
+ vfp_set_fpscr(env, 0);
120
+ }
121
+ } else {
122
+ v7m_update_fpccr(env, fptr, false);
123
+ }
124
+
125
+ env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
126
+}
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
--
103
--
182
2.20.1
104
2.20.1
183
105
184
106
diff view generated by jsdifflib
1
The M-profile architecture floating point system supports
1
From: Richard Henderson <richard.henderson@linaro.org>
2
lazy FP state preservation, where FP registers are not
3
pushed to the stack when an exception occurs but are instead
4
only saved if and when the first FP instruction in the exception
5
handler is executed. Implement this in QEMU, corresponding
6
to the check of LSPACT in the pseudocode ExecuteFPCheck().
7
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20200815013145.539409-20-richard.henderson@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20190416125744.27770-24-peter.maydell@linaro.org
11
---
7
---
12
target/arm/cpu.h | 3 ++
8
target/arm/helper.h | 14 ++++++++++++++
13
target/arm/helper.h | 2 +
9
target/arm/translate-a64.c | 34 ++++++++++++++++++++++++++++++++++
14
target/arm/translate.h | 1 +
10
target/arm/vec_helper.c | 25 +++++++++++++++++++++++++
15
target/arm/helper.c | 112 +++++++++++++++++++++++++++++++++++++++++
11
3 files changed, 73 insertions(+)
16
target/arm/translate.c | 22 ++++++++
17
5 files changed, 140 insertions(+)
18
12
19
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
20
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/cpu.h
22
+++ b/target/arm/cpu.h
23
@@ -XXX,XX +XXX,XX @@
24
#define EXCP_NOCP 17 /* v7M NOCP UsageFault */
25
#define EXCP_INVSTATE 18 /* v7M INVSTATE UsageFault */
26
#define EXCP_STKOF 19 /* v8M STKOF UsageFault */
27
+#define EXCP_LAZYFP 20 /* v7M fault during lazy FP stacking */
28
/* NB: add new EXCP_ defines to the array in arm_log_exception() too */
29
30
#define ARMV7M_EXCP_RESET 1
31
@@ -XXX,XX +XXX,XX @@ FIELD(TBFLAG_A32, NS, 6, 1)
32
FIELD(TBFLAG_A32, VFPEN, 7, 1)
33
FIELD(TBFLAG_A32, CONDEXEC, 8, 8)
34
FIELD(TBFLAG_A32, SCTLR_B, 16, 1)
35
+/* For M profile only, set if FPCCR.LSPACT is set */
36
+FIELD(TBFLAG_A32, LSPACT, 18, 1)
37
/* For M profile only, set if we must create a new FP context */
38
FIELD(TBFLAG_A32, NEW_FP_CTXT_NEEDED, 19, 1)
39
/* For M profile only, set if FPCCR.S does not match current security state */
40
diff --git a/target/arm/helper.h b/target/arm/helper.h
13
diff --git a/target/arm/helper.h b/target/arm/helper.h
41
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
42
--- a/target/arm/helper.h
15
--- a/target/arm/helper.h
43
+++ b/target/arm/helper.h
16
+++ b/target/arm/helper.h
44
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_2(v7m_blxns, void, env, i32)
17
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_4(gvec_mul_idx_h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
45
18
DEF_HELPER_FLAGS_4(gvec_mul_idx_s, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
46
DEF_HELPER_3(v7m_tt, i32, env, i32, i32)
19
DEF_HELPER_FLAGS_4(gvec_mul_idx_d, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32)
47
20
48
+DEF_HELPER_1(v7m_preserve_fp_state, void, env)
21
+DEF_HELPER_FLAGS_5(gvec_mla_idx_h, TCG_CALL_NO_RWG,
22
+ void, ptr, ptr, ptr, ptr, i32)
23
+DEF_HELPER_FLAGS_5(gvec_mla_idx_s, TCG_CALL_NO_RWG,
24
+ void, ptr, ptr, ptr, ptr, i32)
25
+DEF_HELPER_FLAGS_5(gvec_mla_idx_d, TCG_CALL_NO_RWG,
26
+ void, ptr, ptr, ptr, ptr, i32)
49
+
27
+
50
DEF_HELPER_2(v8m_stackcheck, void, env, i32)
28
+DEF_HELPER_FLAGS_5(gvec_mls_idx_h, TCG_CALL_NO_RWG,
51
29
+ void, ptr, ptr, ptr, ptr, i32)
52
DEF_HELPER_4(access_check_cp_reg, void, env, ptr, i32, i32)
30
+DEF_HELPER_FLAGS_5(gvec_mls_idx_s, TCG_CALL_NO_RWG,
53
diff --git a/target/arm/translate.h b/target/arm/translate.h
31
+ void, ptr, ptr, ptr, ptr, i32)
32
+DEF_HELPER_FLAGS_5(gvec_mls_idx_d, TCG_CALL_NO_RWG,
33
+ void, ptr, ptr, ptr, ptr, i32)
34
+
35
#ifdef TARGET_AARCH64
36
#include "helper-a64.h"
37
#include "helper-sve.h"
38
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
54
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
55
--- a/target/arm/translate.h
40
--- a/target/arm/translate-a64.c
56
+++ b/target/arm/translate.h
41
+++ b/target/arm/translate-a64.c
57
@@ -XXX,XX +XXX,XX @@ typedef struct DisasContext {
42
@@ -XXX,XX +XXX,XX @@ static void disas_simd_indexed(DisasContext *s, uint32_t insn)
58
bool v8m_stackcheck; /* true if we need to perform v8M stack limit checks */
59
bool v8m_fpccr_s_wrong; /* true if v8M FPCCR.S != v8m_secure */
60
bool v7m_new_fp_ctxt_needed; /* ASPEN set but no active FP context */
61
+ bool v7m_lspact; /* FPCCR.LSPACT set */
62
/* Immediate value in AArch32 SVC insn; must be set if is_jmp == DISAS_SWI
63
* so that top level loop can generate correct syndrome information.
64
*/
65
diff --git a/target/arm/helper.c b/target/arm/helper.c
66
index XXXXXXX..XXXXXXX 100644
67
--- a/target/arm/helper.c
68
+++ b/target/arm/helper.c
69
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_blxns)(CPUARMState *env, uint32_t dest)
70
g_assert_not_reached();
71
}
72
73
+void HELPER(v7m_preserve_fp_state)(CPUARMState *env)
74
+{
75
+ /* translate.c should never generate calls here in user-only mode */
76
+ g_assert_not_reached();
77
+}
78
+
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
+ }
117
+
118
+ if (!splimviol && stacked_ok) {
119
+ /* We only stack if the stack limit wasn't violated */
120
+ int i;
121
+ ARMMMUIdx mmu_idx;
122
+
123
+ mmu_idx = arm_v7m_mmu_idx_all(env, is_secure, is_priv, negpri);
124
+ for (i = 0; i < (ts ? 32 : 16); i += 2) {
125
+ uint64_t dn = *aa32_vfp_dreg(env, i / 2);
126
+ uint32_t faddr = fpcar + 4 * i;
127
+ uint32_t slo = extract64(dn, 0, 32);
128
+ uint32_t shi = extract64(dn, 32, 32);
129
+
130
+ if (i >= 16) {
131
+ faddr += 8; /* skip the slot for the FPSCR */
132
+ }
133
+ stacked_ok = stacked_ok &&
134
+ v7m_stack_write(cpu, faddr, slo, mmu_idx, STACK_LAZYFP) &&
135
+ v7m_stack_write(cpu, faddr + 4, shi, mmu_idx, STACK_LAZYFP);
136
+ }
137
+
138
+ stacked_ok = stacked_ok &&
139
+ v7m_stack_write(cpu, fpcar + 0x40,
140
+ vfp_get_fpscr(env), mmu_idx, STACK_LAZYFP);
141
+ }
142
+
143
+ /*
144
+ * We definitely pended an exception, but it's possible that it
145
+ * might not be able to be taken now. If its priority permits us
146
+ * to take it now, then we must not update the LSPACT or FP regs,
147
+ * but instead jump out to take the exception immediately.
148
+ * If it's just pending and won't be taken until the current
149
+ * handler exits, then we do update LSPACT and the FP regs.
150
+ */
151
+ take_exception = !stacked_ok &&
152
+ armv7m_nvic_can_take_pending_exception(env->nvic);
153
+
154
+ qemu_mutex_unlock_iothread();
155
+
156
+ if (take_exception) {
157
+ raise_exception_ra(env, EXCP_LAZYFP, 0, 1, GETPC());
158
+ }
159
+
160
+ env->v7m.fpccr[is_secure] &= ~R_V7M_FPCCR_LSPACT_MASK;
161
+
162
+ if (ts) {
163
+ /* Clear s0 to s31 and the FPSCR */
164
+ int i;
165
+
166
+ for (i = 0; i < 32; i += 2) {
167
+ *aa32_vfp_dreg(env, i / 2) = 0;
168
+ }
169
+ vfp_set_fpscr(env, 0);
170
+ }
171
+ /*
172
+ * Otherwise s0 to s15 and FPSCR are UNKNOWN; we choose to leave them
173
+ * unchanged.
174
+ */
175
+}
176
+
177
/* Write to v7M CONTROL.SPSEL bit for the specified security bank.
178
* This may change the current stack pointer between Main and Process
179
* stack pointers if it is done for the CONTROL register for the current
180
@@ -XXX,XX +XXX,XX @@ static void arm_log_exception(int idx)
181
[EXCP_NOCP] = "v7M NOCP UsageFault",
182
[EXCP_INVSTATE] = "v7M INVSTATE UsageFault",
183
[EXCP_STKOF] = "v8M STKOF UsageFault",
184
+ [EXCP_LAZYFP] = "v7M exception during lazy FP stacking",
185
};
186
187
if (idx >= 0 && idx < ARRAY_SIZE(excnames)) {
188
@@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
189
return;
43
return;
190
}
44
}
191
break;
45
break;
192
+ case EXCP_LAZYFP:
46
+
193
+ /*
47
+ case 0x10: /* MLA */
194
+ * We already pended the specific exception in the NVIC in the
48
+ if (!is_long && !is_scalar) {
195
+ * v7m_preserve_fp_state() helper function.
49
+ static gen_helper_gvec_4 * const fns[3] = {
196
+ */
50
+ gen_helper_gvec_mla_idx_h,
51
+ gen_helper_gvec_mla_idx_s,
52
+ gen_helper_gvec_mla_idx_d,
53
+ };
54
+ tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd),
55
+ vec_full_reg_offset(s, rn),
56
+ vec_full_reg_offset(s, rm),
57
+ vec_full_reg_offset(s, rd),
58
+ is_q ? 16 : 8, vec_full_reg_size(s),
59
+ index, fns[size - 1]);
60
+ return;
61
+ }
197
+ break;
62
+ break;
198
default:
63
+
199
cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
64
+ case 0x14: /* MLS */
200
return; /* Never happens. Keep compiler happy. */
65
+ if (!is_long && !is_scalar) {
201
@@ -XXX,XX +XXX,XX @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
66
+ static gen_helper_gvec_4 * const fns[3] = {
202
flags = FIELD_DP32(flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED, 1);
67
+ gen_helper_gvec_mls_idx_h,
68
+ gen_helper_gvec_mls_idx_s,
69
+ gen_helper_gvec_mls_idx_d,
70
+ };
71
+ tcg_gen_gvec_4_ool(vec_full_reg_offset(s, rd),
72
+ vec_full_reg_offset(s, rn),
73
+ vec_full_reg_offset(s, rm),
74
+ vec_full_reg_offset(s, rd),
75
+ is_q ? 16 : 8, vec_full_reg_size(s),
76
+ index, fns[size - 1]);
77
+ return;
78
+ }
79
+ break;
203
}
80
}
204
81
205
+ if (arm_feature(env, ARM_FEATURE_M)) {
82
if (size == 3) {
206
+ bool is_secure = env->v7m.fpccr[M_REG_S] & R_V7M_FPCCR_S_MASK;
83
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
84
index XXXXXXX..XXXXXXX 100644
85
--- a/target/arm/vec_helper.c
86
+++ b/target/arm/vec_helper.c
87
@@ -XXX,XX +XXX,XX @@ DO_MUL_IDX(gvec_mul_idx_d, uint64_t, )
88
89
#undef DO_MUL_IDX
90
91
+#define DO_MLA_IDX(NAME, TYPE, OP, H) \
92
+void HELPER(NAME)(void *vd, void *vn, void *vm, void *va, uint32_t desc) \
93
+{ \
94
+ intptr_t i, j, oprsz = simd_oprsz(desc), segment = 16 / sizeof(TYPE); \
95
+ intptr_t idx = simd_data(desc); \
96
+ TYPE *d = vd, *n = vn, *m = vm, *a = va; \
97
+ for (i = 0; i < oprsz / sizeof(TYPE); i += segment) { \
98
+ TYPE mm = m[H(i + idx)]; \
99
+ for (j = 0; j < segment; j++) { \
100
+ d[i + j] = a[i + j] OP n[i + j] * mm; \
101
+ } \
102
+ } \
103
+ clear_tail(d, oprsz, simd_maxsz(desc)); \
104
+}
207
+
105
+
208
+ if (env->v7m.fpccr[is_secure] & R_V7M_FPCCR_LSPACT_MASK) {
106
+DO_MLA_IDX(gvec_mla_idx_h, uint16_t, +, H2)
209
+ flags = FIELD_DP32(flags, TBFLAG_A32, LSPACT, 1);
107
+DO_MLA_IDX(gvec_mla_idx_s, uint32_t, +, H4)
210
+ }
108
+DO_MLA_IDX(gvec_mla_idx_d, uint64_t, +, )
211
+ }
212
+
109
+
213
*pflags = flags;
110
+DO_MLA_IDX(gvec_mls_idx_h, uint16_t, -, H2)
214
*cs_base = 0;
111
+DO_MLA_IDX(gvec_mls_idx_s, uint32_t, -, H4)
215
}
112
+DO_MLA_IDX(gvec_mls_idx_d, uint64_t, -, )
216
diff --git a/target/arm/translate.c b/target/arm/translate.c
217
index XXXXXXX..XXXXXXX 100644
218
--- a/target/arm/translate.c
219
+++ b/target/arm/translate.c
220
@@ -XXX,XX +XXX,XX @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)
221
if (arm_dc_feature(s, ARM_FEATURE_M)) {
222
/* Handle M-profile lazy FP state mechanics */
223
224
+ /* Trigger lazy-state preservation if necessary */
225
+ if (s->v7m_lspact) {
226
+ /*
227
+ * Lazy state saving affects external memory and also the NVIC,
228
+ * so we must mark it as an IO operation for icount.
229
+ */
230
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
231
+ gen_io_start();
232
+ }
233
+ gen_helper_v7m_preserve_fp_state(cpu_env);
234
+ if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) {
235
+ gen_io_end();
236
+ }
237
+ /*
238
+ * If the preserve_fp_state helper doesn't throw an exception
239
+ * then it will clear LSPACT; we don't need to repeat this for
240
+ * any further FP insns in this TB.
241
+ */
242
+ s->v7m_lspact = false;
243
+ }
244
+
113
+
245
/* Update ownership of FP context: set FPCCR.S to match current state */
114
+#undef DO_MLA_IDX
246
if (s->v8m_fpccr_s_wrong) {
115
+
247
TCGv_i32 tmp;
116
#define DO_FMUL_IDX(NAME, TYPE, H) \
248
@@ -XXX,XX +XXX,XX @@ static void arm_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
117
void HELPER(NAME)(void *vd, void *vn, void *vm, void *stat, uint32_t desc) \
249
dc->v8m_fpccr_s_wrong = FIELD_EX32(tb_flags, TBFLAG_A32, FPCCR_S_WRONG);
118
{ \
250
dc->v7m_new_fp_ctxt_needed =
251
FIELD_EX32(tb_flags, TBFLAG_A32, NEW_FP_CTXT_NEEDED);
252
+ dc->v7m_lspact = FIELD_EX32(tb_flags, TBFLAG_A32, LSPACT);
253
dc->cp_regs = cpu->cp_regs;
254
dc->features = env->features;
255
256
--
119
--
257
2.20.1
120
2.20.1
258
121
259
122
diff view generated by jsdifflib
1
Implement the VLLDM instruction for v7M for the FPU present cas.
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20200815013145.539409-21-richard.henderson@linaro.org
3
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20190416125744.27770-26-peter.maydell@linaro.org
6
---
7
---
7
target/arm/helper.h | 1 +
8
target/arm/helper.h | 10 ++++++++
8
target/arm/helper.c | 54 ++++++++++++++++++++++++++++++++++++++++++
9
target/arm/translate-a64.c | 33 ++++++++++++++++++--------
9
target/arm/translate.c | 2 +-
10
target/arm/vec_helper.c | 48 ++++++++++++++++++++++++++++++++++++++
10
3 files changed, 56 insertions(+), 1 deletion(-)
11
3 files changed, 81 insertions(+), 10 deletions(-)
11
12
12
diff --git a/target/arm/helper.h b/target/arm/helper.h
13
diff --git a/target/arm/helper.h b/target/arm/helper.h
13
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.h
15
--- a/target/arm/helper.h
15
+++ b/target/arm/helper.h
16
+++ b/target/arm/helper.h
16
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(v7m_tt, i32, env, i32, i32)
17
@@ -XXX,XX +XXX,XX @@ DEF_HELPER_FLAGS_5(gvec_mls_idx_s, TCG_CALL_NO_RWG,
17
DEF_HELPER_1(v7m_preserve_fp_state, void, env)
18
DEF_HELPER_FLAGS_5(gvec_mls_idx_d, TCG_CALL_NO_RWG,
18
19
void, ptr, ptr, ptr, ptr, i32)
19
DEF_HELPER_2(v7m_vlstm, void, env, i32)
20
20
+DEF_HELPER_2(v7m_vlldm, void, env, i32)
21
+DEF_HELPER_FLAGS_5(neon_sqdmulh_h, TCG_CALL_NO_RWG,
21
22
+ void, ptr, ptr, ptr, ptr, i32)
22
DEF_HELPER_2(v8m_stackcheck, void, env, i32)
23
+DEF_HELPER_FLAGS_5(neon_sqdmulh_s, TCG_CALL_NO_RWG,
23
24
+ void, ptr, ptr, ptr, ptr, i32)
24
diff --git a/target/arm/helper.c b/target/arm/helper.c
25
+
26
+DEF_HELPER_FLAGS_5(neon_sqrdmulh_h, TCG_CALL_NO_RWG,
27
+ void, ptr, ptr, ptr, ptr, i32)
28
+DEF_HELPER_FLAGS_5(neon_sqrdmulh_s, TCG_CALL_NO_RWG,
29
+ void, ptr, ptr, ptr, ptr, i32)
30
+
31
#ifdef TARGET_AARCH64
32
#include "helper-a64.h"
33
#include "helper-sve.h"
34
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
25
index XXXXXXX..XXXXXXX 100644
35
index XXXXXXX..XXXXXXX 100644
26
--- a/target/arm/helper.c
36
--- a/target/arm/translate-a64.c
27
+++ b/target/arm/helper.c
37
+++ b/target/arm/translate-a64.c
28
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
38
@@ -XXX,XX +XXX,XX @@ static void gen_gvec_op3_fpst(DisasContext *s, bool is_q, int rd, int rn,
29
g_assert_not_reached();
39
tcg_temp_free_ptr(fpst);
30
}
40
}
31
41
32
+void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
42
+/* Expand a 3-operand + qc + operation using an out-of-line helper. */
43
+static void gen_gvec_op3_qc(DisasContext *s, bool is_q, int rd, int rn,
44
+ int rm, gen_helper_gvec_3_ptr *fn)
33
+{
45
+{
34
+ /* translate.c should never generate calls here in user-only mode */
46
+ TCGv_ptr qc_ptr = tcg_temp_new_ptr();
35
+ g_assert_not_reached();
47
+
48
+ tcg_gen_addi_ptr(qc_ptr, cpu_env, offsetof(CPUARMState, vfp.qc));
49
+ tcg_gen_gvec_3_ptr(vec_full_reg_offset(s, rd),
50
+ vec_full_reg_offset(s, rn),
51
+ vec_full_reg_offset(s, rm), qc_ptr,
52
+ is_q ? 16 : 8, vec_full_reg_size(s), 0, fn);
53
+ tcg_temp_free_ptr(qc_ptr);
36
+}
54
+}
37
+
55
+
38
uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, uint32_t op)
56
/* Set ZF and NF based on a 64 bit result. This is alas fiddlier
39
{
57
* than the 32 bit equivalent.
40
/* The TT instructions can be used by unprivileged code, but in
58
*/
41
@@ -XXX,XX +XXX,XX @@ void HELPER(v7m_vlstm)(CPUARMState *env, uint32_t fptr)
59
@@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn)
42
env->v7m.control[M_REG_S] &= ~R_V7M_CONTROL_FPCA_MASK;
60
gen_gvec_fn3(s, is_q, rd, rn, rm, gen_gvec_mla, size);
61
}
62
return;
63
+ case 0x16: /* SQDMULH, SQRDMULH */
64
+ {
65
+ static gen_helper_gvec_3_ptr * const fns[2][2] = {
66
+ { gen_helper_neon_sqdmulh_h, gen_helper_neon_sqrdmulh_h },
67
+ { gen_helper_neon_sqdmulh_s, gen_helper_neon_sqrdmulh_s },
68
+ };
69
+ gen_gvec_op3_qc(s, is_q, rd, rn, rm, fns[size - 1][u]);
70
+ }
71
+ return;
72
case 0x11:
73
if (!u) { /* CMTST */
74
gen_gvec_fn3(s, is_q, rd, rn, rm, gen_gvec_cmtst, size);
75
@@ -XXX,XX +XXX,XX @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn)
76
genenvfn = fns[size][u];
77
break;
78
}
79
- case 0x16: /* SQDMULH, SQRDMULH */
80
- {
81
- static NeonGenTwoOpEnvFn * const fns[2][2] = {
82
- { gen_helper_neon_qdmulh_s16, gen_helper_neon_qrdmulh_s16 },
83
- { gen_helper_neon_qdmulh_s32, gen_helper_neon_qrdmulh_s32 },
84
- };
85
- assert(size == 1 || size == 2);
86
- genenvfn = fns[size - 1][u];
87
- break;
88
- }
89
default:
90
g_assert_not_reached();
91
}
92
diff --git a/target/arm/vec_helper.c b/target/arm/vec_helper.c
93
index XXXXXXX..XXXXXXX 100644
94
--- a/target/arm/vec_helper.c
95
+++ b/target/arm/vec_helper.c
96
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s16)(void *vd, void *vn, void *vm,
97
clear_tail(d, opr_sz, simd_maxsz(desc));
43
}
98
}
44
99
45
+void HELPER(v7m_vlldm)(CPUARMState *env, uint32_t fptr)
100
+void HELPER(neon_sqdmulh_h)(void *vd, void *vn, void *vm,
101
+ void *vq, uint32_t desc)
46
+{
102
+{
47
+ /* fptr is the value of Rn, the frame pointer we load the FP regs from */
103
+ intptr_t i, opr_sz = simd_oprsz(desc);
48
+ assert(env->v7m.secure);
104
+ int16_t *d = vd, *n = vn, *m = vm;
49
+
105
+
50
+ if (!(env->v7m.control[M_REG_S] & R_V7M_CONTROL_SFPA_MASK)) {
106
+ for (i = 0; i < opr_sz / 2; ++i) {
51
+ return;
107
+ d[i] = do_sqrdmlah_h(n[i], m[i], 0, false, false, vq);
52
+ }
108
+ }
53
+
109
+ clear_tail(d, opr_sz, simd_maxsz(desc));
54
+ /* Check access to the coprocessor is permitted */
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
+}
110
+}
92
+
111
+
93
static bool v7m_push_stack(ARMCPU *cpu)
112
+void HELPER(neon_sqrdmulh_h)(void *vd, void *vn, void *vm,
94
{
113
+ void *vq, uint32_t desc)
95
/* Do the "set up stack frame" part of exception entry,
114
+{
96
diff --git a/target/arm/translate.c b/target/arm/translate.c
115
+ intptr_t i, opr_sz = simd_oprsz(desc);
97
index XXXXXXX..XXXXXXX 100644
116
+ int16_t *d = vd, *n = vn, *m = vm;
98
--- a/target/arm/translate.c
117
+
99
+++ b/target/arm/translate.c
118
+ for (i = 0; i < opr_sz / 2; ++i) {
100
@@ -XXX,XX +XXX,XX @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)
119
+ d[i] = do_sqrdmlah_h(n[i], m[i], 0, false, true, vq);
101
TCGv_i32 fptr = load_reg(s, rn);
120
+ }
102
121
+ clear_tail(d, opr_sz, simd_maxsz(desc));
103
if (extract32(insn, 20, 1)) {
122
+}
104
- /* VLLDM */
123
+
105
+ gen_helper_v7m_vlldm(cpu_env, fptr);
124
/* Signed saturating rounding doubling multiply-accumulate high half, 32-bit */
106
} else {
125
static int32_t do_sqrdmlah_s(int32_t src1, int32_t src2, int32_t src3,
107
gen_helper_v7m_vlstm(cpu_env, fptr);
126
bool neg, bool round, uint32_t *sat)
108
}
127
@@ -XXX,XX +XXX,XX @@ void HELPER(gvec_qrdmlsh_s32)(void *vd, void *vn, void *vm,
128
clear_tail(d, opr_sz, simd_maxsz(desc));
129
}
130
131
+void HELPER(neon_sqdmulh_s)(void *vd, void *vn, void *vm,
132
+ void *vq, uint32_t desc)
133
+{
134
+ intptr_t i, opr_sz = simd_oprsz(desc);
135
+ int32_t *d = vd, *n = vn, *m = vm;
136
+
137
+ for (i = 0; i < opr_sz / 4; ++i) {
138
+ d[i] = do_sqrdmlah_s(n[i], m[i], 0, false, false, vq);
139
+ }
140
+ clear_tail(d, opr_sz, simd_maxsz(desc));
141
+}
142
+
143
+void HELPER(neon_sqrdmulh_s)(void *vd, void *vn, void *vm,
144
+ void *vq, uint32_t desc)
145
+{
146
+ intptr_t i, opr_sz = simd_oprsz(desc);
147
+ int32_t *d = vd, *n = vn, *m = vm;
148
+
149
+ for (i = 0; i < opr_sz / 4; ++i) {
150
+ d[i] = do_sqrdmlah_s(n[i], m[i], 0, false, true, vq);
151
+ }
152
+ clear_tail(d, opr_sz, simd_maxsz(desc));
153
+}
154
+
155
/* Integer 8 and 16-bit dot-product.
156
*
157
* Note that for the loops herein, host endianness does not matter
109
--
158
--
110
2.20.1
159
2.20.1
111
160
112
161
diff view generated by jsdifflib