1
ARM queue for 2.10: all M profile bugfixes...
1
A small set of arm bugfixes for rc0.
2
2
3
thanks
4
-- PMM
5
3
6
The following changes since commit 25dd0e77898c3e10796d4cbeb35e8af5ba6ce975:
7
4
8
Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-fetch' into staging (2017-07-31 11:27:43 +0100)
5
The following changes since commit 5853e92207193e967abf5e4c25b4a551c7604725:
6
7
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-cocoa-20171107' into staging (2017-11-07 12:19:48 +0000)
9
8
10
are available in the git repository at:
9
are available in the git repository at:
11
10
12
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20170731
11
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20171107
13
12
14
for you to fetch changes up to 89cbc3778a3d61761e2231e740269218c9a8a41d:
13
for you to fetch changes up to 8a7348b5d62d7ea16807e6bea54b448a0184bb0f:
15
14
16
hw/mps2_scc: fix incorrect properties (2017-07-31 13:11:56 +0100)
15
hw/intc/arm_gicv3_its: Don't abort on table save failure (2017-11-07 13:03:52 +0000)
17
16
18
----------------------------------------------------------------
17
----------------------------------------------------------------
19
target-arm queue:
18
target-arm queue:
20
* fix broken properties on MPS2 SCC device
19
* arm_gicv3_its: Don't abort on table save failure
21
* fix MPU trace handling of write vs exec
20
* arm_gicv3_its: Fix the VM termination in vm_change_state_handler()
22
* fix MPU M profile bugs:
21
* translate.c: Fix usermode big-endian AArch32 LDREXD and STREXD
23
- not handling system space or PPB region correctly
22
* hw/arm: Mark the "fsl,imx31/25/6" devices with user_creatable = false
24
- not resetting state
23
* arm: implement cache/shareability attribute bits for PAR registers
25
- not migrating MPU_RNR
26
24
27
----------------------------------------------------------------
25
----------------------------------------------------------------
28
Peter Maydell (6):
26
Andrew Baumann (1):
29
target/arm: Correct MPU trace handling of write vs execute
27
arm: implement cache/shareability attribute bits for PAR registers
30
target/arm: Don't do MPU lookups for addresses in M profile PPB region
31
target/arm: Don't allow guest to make System space executable for M profile
32
target/arm: Rename cp15.c6_rgnr to pmsav7.rnr
33
target/arm: Move PMSAv7 reset into arm_cpu_reset() so M profile MPUs get reset
34
target/arm: Migrate MPU_RNR register state for M profile cores
35
28
36
Philippe Mathieu-Daudé (1):
29
Eric Auger (1):
37
hw/mps2_scc: fix incorrect properties
30
hw/intc/arm_gicv3_its: Don't abort on table save failure
38
31
39
target/arm/cpu.h | 3 +--
32
Peter Maydell (1):
40
hw/intc/armv7m_nvic.c | 14 +++++-----
33
translate.c: Fix usermode big-endian AArch32 LDREXD and STREXD
41
hw/misc/mps2-scc.c | 4 +--
42
target/arm/cpu.c | 14 ++++++++++
43
target/arm/helper.c | 71 ++++++++++++++++++++++++++++++++++-----------------
44
target/arm/machine.c | 30 +++++++++++++++++++++-
45
6 files changed, 101 insertions(+), 35 deletions(-)
46
34
35
Shanker Donthineni (1):
36
hw/intc/arm_gicv3_its: Fix the VM termination in vm_change_state_handler()
37
38
Thomas Huth (3):
39
hw/arm: Mark the "fsl,imx6" device with user_creatable = false
40
hw/arm: Mark the "fsl,imx25" device with user_creatable = false
41
hw/arm: Mark the "fsl,imx31" device with user_creatable = false
42
43
hw/arm/fsl-imx25.c | 6 +-
44
hw/arm/fsl-imx31.c | 6 +-
45
hw/arm/fsl-imx6.c | 3 +-
46
hw/intc/arm_gicv3_its_kvm.c | 12 +--
47
target/arm/helper.c | 178 ++++++++++++++++++++++++++++++++++++++++----
48
target/arm/translate.c | 39 ++++++++--
49
6 files changed, 214 insertions(+), 30 deletions(-)
50
diff view generated by jsdifflib
1
For an M profile v7PMSA, the system space (0xe0000000 - 0xffffffff) can
1
From: Andrew Baumann <Andrew.Baumann@microsoft.com>
2
never be executable, even if the guest tries to set the MPU registers
2
3
up that way. Enforce this restriction.
3
On a successful address translation instruction, PAR is supposed to
4
4
contain cacheability and shareability attributes determined by the
5
translation. We previously returned 0 for these bits (in line with the
6
general strategy of ignoring caches and memory attributes), but some
7
guest OSes may depend on them.
8
9
This patch collects the attribute bits in the page-table walk, and
10
updates PAR with the correct attributes for all LPAE translations.
11
Short descriptor formats still return 0 for these bits, as in the
12
prior implementation.
13
14
Signed-off-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
15
Message-id: 20171031223830.4608-1-Andrew.Baumann@microsoft.com
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Message-id: 1501153150-19984-3-git-send-email-peter.maydell@linaro.org
8
---
18
---
9
target/arm/helper.c | 16 +++++++++++++++-
19
target/arm/helper.c | 178 +++++++++++++++++++++++++++++++++++++++++++++++-----
10
1 file changed, 15 insertions(+), 1 deletion(-)
20
1 file changed, 164 insertions(+), 14 deletions(-)
11
21
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
22
diff --git a/target/arm/helper.c b/target/arm/helper.c
13
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.c
24
--- a/target/arm/helper.c
15
+++ b/target/arm/helper.c
25
+++ b/target/arm/helper.c
16
@@ -XXX,XX +XXX,XX @@ static inline bool m_is_ppb_region(CPUARMState *env, uint32_t address)
26
@@ -XXX,XX +XXX,XX @@
17
extract32(address, 20, 12) == 0xe00;
27
#define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */
28
29
#ifndef CONFIG_USER_ONLY
30
+/* Cacheability and shareability attributes for a memory access */
31
+typedef struct ARMCacheAttrs {
32
+ unsigned int attrs:8; /* as in the MAIR register encoding */
33
+ unsigned int shareability:2; /* as in the SH field of the VMSAv8-64 PTEs */
34
+} ARMCacheAttrs;
35
+
36
static bool get_phys_addr(CPUARMState *env, target_ulong address,
37
MMUAccessType access_type, ARMMMUIdx mmu_idx,
38
hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
39
target_ulong *page_size, uint32_t *fsr,
40
- ARMMMUFaultInfo *fi);
41
+ ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs);
42
43
static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
44
MMUAccessType access_type, ARMMMUIdx mmu_idx,
45
hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,
46
target_ulong *page_size_ptr, uint32_t *fsr,
47
- ARMMMUFaultInfo *fi);
48
+ ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs);
49
50
/* Security attributes for an address, as returned by v8m_security_lookup. */
51
typedef struct V8M_SAttributes {
52
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
53
uint64_t par64;
54
MemTxAttrs attrs = {};
55
ARMMMUFaultInfo fi = {};
56
+ ARMCacheAttrs cacheattrs = {};
57
58
- ret = get_phys_addr(env, value, access_type, mmu_idx,
59
- &phys_addr, &attrs, &prot, &page_size, &fsr, &fi);
60
+ ret = get_phys_addr(env, value, access_type, mmu_idx, &phys_addr, &attrs,
61
+ &prot, &page_size, &fsr, &fi, &cacheattrs);
62
if (extended_addresses_enabled(env)) {
63
/* fsr is a DFSR/IFSR value for the long descriptor
64
* translation table format, but with WnR always clear.
65
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
66
if (!attrs.secure) {
67
par64 |= (1 << 9); /* NS */
68
}
69
- /* We don't set the ATTR or SH fields in the PAR. */
70
+ par64 |= (uint64_t)cacheattrs.attrs << 56; /* ATTR */
71
+ par64 |= cacheattrs.shareability << 7; /* SH */
72
} else {
73
par64 |= 1; /* F */
74
par64 |= (fsr & 0x3f) << 1; /* FS */
75
@@ -XXX,XX +XXX,XX @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,
76
return false;
77
}
78
if (get_phys_addr(env, addr, MMU_INST_FETCH, mmu_idx,
79
- &physaddr, &attrs, &prot, &page_size, &fsr, &fi)) {
80
+ &physaddr, &attrs, &prot, &page_size, &fsr, &fi, NULL)) {
81
/* the MPU lookup failed */
82
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK;
83
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM, env->v7m.secure);
84
@@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx,
85
int ret;
86
87
ret = get_phys_addr_lpae(env, addr, 0, ARMMMUIdx_S2NS, &s2pa,
88
- &txattrs, &s2prot, &s2size, fsr, fi);
89
+ &txattrs, &s2prot, &s2size, fsr, fi, NULL);
90
if (ret) {
91
fi->s2addr = addr;
92
fi->stage2 = true;
93
@@ -XXX,XX +XXX,XX @@ static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level,
94
return true;
18
}
95
}
19
96
20
+static inline bool m_is_system_region(CPUARMState *env, uint32_t address)
97
+/* Translate from the 4-bit stage 2 representation of
98
+ * memory attributes (without cache-allocation hints) to
99
+ * the 8-bit representation of the stage 1 MAIR registers
100
+ * (which includes allocation hints).
101
+ *
102
+ * ref: shared/translation/attrs/S2AttrDecode()
103
+ * .../S2ConvertAttrsHints()
104
+ */
105
+static uint8_t convert_stage2_attrs(CPUARMState *env, uint8_t s2attrs)
21
+{
106
+{
22
+ /* True if address is in the M profile system region
107
+ uint8_t hiattr = extract32(s2attrs, 2, 2);
23
+ * 0xe0000000 - 0xffffffff
108
+ uint8_t loattr = extract32(s2attrs, 0, 2);
24
+ */
109
+ uint8_t hihint = 0, lohint = 0;
25
+ return arm_feature(env, ARM_FEATURE_M) && extract32(address, 29, 3) == 0x7;
110
+
111
+ if (hiattr != 0) { /* normal memory */
112
+ if ((env->cp15.hcr_el2 & HCR_CD) != 0) { /* cache disabled */
113
+ hiattr = loattr = 1; /* non-cacheable */
114
+ } else {
115
+ if (hiattr != 1) { /* Write-through or write-back */
116
+ hihint = 3; /* RW allocate */
117
+ }
118
+ if (loattr != 1) { /* Write-through or write-back */
119
+ lohint = 3; /* RW allocate */
120
+ }
121
+ }
122
+ }
123
+
124
+ return (hiattr << 6) | (hihint << 4) | (loattr << 2) | lohint;
26
+}
125
+}
27
+
126
+
28
static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
127
static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
29
int access_type, ARMMMUIdx mmu_idx,
128
MMUAccessType access_type, ARMMMUIdx mmu_idx,
30
hwaddr *phys_ptr, int *prot, uint32_t *fsr)
129
hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,
31
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
130
target_ulong *page_size_ptr, uint32_t *fsr,
32
get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
131
- ARMMMUFaultInfo *fi)
33
} else { /* a MPU hit! */
132
+ ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
34
uint32_t ap = extract32(env->pmsav7.dracr[n], 8, 3);
133
{
35
+ uint32_t xn = extract32(env->pmsav7.dracr[n], 12, 1);
134
ARMCPU *cpu = arm_env_get_cpu(env);
36
+
135
CPUState *cs = CPU(cpu);
37
+ if (m_is_system_region(env, address)) {
136
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
38
+ /* System space is always execute never */
137
*/
39
+ xn = 1;
138
txattrs->secure = false;
139
}
140
+
141
+ if (cacheattrs != NULL) {
142
+ if (mmu_idx == ARMMMUIdx_S2NS) {
143
+ cacheattrs->attrs = convert_stage2_attrs(env,
144
+ extract32(attrs, 0, 4));
145
+ } else {
146
+ /* Index into MAIR registers for cache attributes */
147
+ uint8_t attrindx = extract32(attrs, 0, 3);
148
+ uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)];
149
+ assert(attrindx <= 7);
150
+ cacheattrs->attrs = extract64(mair, attrindx * 8, 8);
151
+ }
152
+ cacheattrs->shareability = extract32(attrs, 6, 2);
153
+ }
154
+
155
*phys_ptr = descaddr;
156
*page_size_ptr = page_size;
157
return false;
158
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
159
return false;
160
}
161
162
+/* Combine either inner or outer cacheability attributes for normal
163
+ * memory, according to table D4-42 and pseudocode procedure
164
+ * CombineS1S2AttrHints() of ARM DDI 0487B.b (the ARMv8 ARM).
165
+ *
166
+ * NB: only stage 1 includes allocation hints (RW bits), leading to
167
+ * some asymmetry.
168
+ */
169
+static uint8_t combine_cacheattr_nibble(uint8_t s1, uint8_t s2)
170
+{
171
+ if (s1 == 4 || s2 == 4) {
172
+ /* non-cacheable has precedence */
173
+ return 4;
174
+ } else if (extract32(s1, 2, 2) == 0 || extract32(s1, 2, 2) == 2) {
175
+ /* stage 1 write-through takes precedence */
176
+ return s1;
177
+ } else if (extract32(s2, 2, 2) == 2) {
178
+ /* stage 2 write-through takes precedence, but the allocation hint
179
+ * is still taken from stage 1
180
+ */
181
+ return (2 << 2) | extract32(s1, 0, 2);
182
+ } else { /* write-back */
183
+ return s1;
184
+ }
185
+}
186
+
187
+/* Combine S1 and S2 cacheability/shareability attributes, per D4.5.4
188
+ * and CombineS1S2Desc()
189
+ *
190
+ * @s1: Attributes from stage 1 walk
191
+ * @s2: Attributes from stage 2 walk
192
+ */
193
+static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2)
194
+{
195
+ uint8_t s1lo = extract32(s1.attrs, 0, 4), s2lo = extract32(s2.attrs, 0, 4);
196
+ uint8_t s1hi = extract32(s1.attrs, 4, 4), s2hi = extract32(s2.attrs, 4, 4);
197
+ ARMCacheAttrs ret;
198
+
199
+ /* Combine shareability attributes (table D4-43) */
200
+ if (s1.shareability == 2 || s2.shareability == 2) {
201
+ /* if either are outer-shareable, the result is outer-shareable */
202
+ ret.shareability = 2;
203
+ } else if (s1.shareability == 3 || s2.shareability == 3) {
204
+ /* if either are inner-shareable, the result is inner-shareable */
205
+ ret.shareability = 3;
206
+ } else {
207
+ /* both non-shareable */
208
+ ret.shareability = 0;
209
+ }
210
+
211
+ /* Combine memory type and cacheability attributes */
212
+ if (s1hi == 0 || s2hi == 0) {
213
+ /* Device has precedence over normal */
214
+ if (s1lo == 0 || s2lo == 0) {
215
+ /* nGnRnE has precedence over anything */
216
+ ret.attrs = 0;
217
+ } else if (s1lo == 4 || s2lo == 4) {
218
+ /* non-Reordering has precedence over Reordering */
219
+ ret.attrs = 4; /* nGnRE */
220
+ } else if (s1lo == 8 || s2lo == 8) {
221
+ /* non-Gathering has precedence over Gathering */
222
+ ret.attrs = 8; /* nGRE */
223
+ } else {
224
+ ret.attrs = 0xc; /* GRE */
225
+ }
226
+
227
+ /* Any location for which the resultant memory type is any
228
+ * type of Device memory is always treated as Outer Shareable.
229
+ */
230
+ ret.shareability = 2;
231
+ } else { /* Normal memory */
232
+ /* Outer/inner cacheability combine independently */
233
+ ret.attrs = combine_cacheattr_nibble(s1hi, s2hi) << 4
234
+ | combine_cacheattr_nibble(s1lo, s2lo);
235
+
236
+ if (ret.attrs == 0x44) {
237
+ /* Any location for which the resultant memory type is Normal
238
+ * Inner Non-cacheable, Outer Non-cacheable is always treated
239
+ * as Outer Shareable.
240
+ */
241
+ ret.shareability = 2;
242
+ }
243
+ }
244
+
245
+ return ret;
246
+}
247
+
248
+
249
/* get_phys_addr - get the physical address for this virtual address
250
*
251
* Find the physical address corresponding to the given virtual address,
252
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav5(CPUARMState *env, uint32_t address,
253
* @prot: set to the permissions for the page containing phys_ptr
254
* @page_size: set to the size of the page containing phys_ptr
255
* @fsr: set to the DFSR/IFSR value on failure
256
+ * @fi: set to fault info if the translation fails
257
+ * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes
258
*/
259
static bool get_phys_addr(CPUARMState *env, target_ulong address,
260
MMUAccessType access_type, ARMMMUIdx mmu_idx,
261
hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot,
262
target_ulong *page_size, uint32_t *fsr,
263
- ARMMMUFaultInfo *fi)
264
+ ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs)
265
{
266
if (mmu_idx == ARMMMUIdx_S12NSE0 || mmu_idx == ARMMMUIdx_S12NSE1) {
267
/* Call ourselves recursively to do the stage 1 and then stage 2
268
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr(CPUARMState *env, target_ulong address,
269
hwaddr ipa;
270
int s2_prot;
271
int ret;
272
+ ARMCacheAttrs cacheattrs2 = {};
273
274
ret = get_phys_addr(env, address, access_type,
275
stage_1_mmu_idx(mmu_idx), &ipa, attrs,
276
- prot, page_size, fsr, fi);
277
+ prot, page_size, fsr, fi, cacheattrs);
278
279
/* If S1 fails or S2 is disabled, return early. */
280
if (ret || regime_translation_disabled(env, ARMMMUIdx_S2NS)) {
281
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr(CPUARMState *env, target_ulong address,
282
/* S1 is done. Now do S2 translation. */
283
ret = get_phys_addr_lpae(env, ipa, access_type, ARMMMUIdx_S2NS,
284
phys_ptr, attrs, &s2_prot,
285
- page_size, fsr, fi);
286
+ page_size, fsr, fi,
287
+ cacheattrs != NULL ? &cacheattrs2 : NULL);
288
fi->s2addr = ipa;
289
/* Combine the S1 and S2 perms. */
290
*prot &= s2_prot;
291
+
292
+ /* Combine the S1 and S2 cache attributes, if needed */
293
+ if (!ret && cacheattrs != NULL) {
294
+ *cacheattrs = combine_cacheattrs(*cacheattrs, cacheattrs2);
40
+ }
295
+ }
41
296
+
42
if (is_user) { /* User mode AP bit decoding */
297
return ret;
43
switch (ap) {
298
} else {
44
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
299
/*
45
}
300
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr(CPUARMState *env, target_ulong address,
46
301
47
/* execute never */
302
if (regime_using_lpae_format(env, mmu_idx)) {
48
- if (env->pmsav7.dracr[n] & (1 << 12)) {
303
return get_phys_addr_lpae(env, address, access_type, mmu_idx, phys_ptr,
49
+ if (xn) {
304
- attrs, prot, page_size, fsr, fi);
50
*prot &= ~PAGE_EXEC;
305
+ attrs, prot, page_size, fsr, fi, cacheattrs);
51
}
306
} else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) {
52
}
307
return get_phys_addr_v6(env, address, access_type, mmu_idx, phys_ptr,
308
attrs, prot, page_size, fsr, fi);
309
@@ -XXX,XX +XXX,XX @@ bool arm_tlb_fill(CPUState *cs, vaddr address,
310
311
ret = get_phys_addr(env, address, access_type,
312
core_to_arm_mmu_idx(env, mmu_idx), &phys_addr,
313
- &attrs, &prot, &page_size, fsr, fi);
314
+ &attrs, &prot, &page_size, fsr, fi, NULL);
315
if (!ret) {
316
/* Map a single [sub]page. */
317
phys_addr &= TARGET_PAGE_MASK;
318
@@ -XXX,XX +XXX,XX @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,
319
*attrs = (MemTxAttrs) {};
320
321
ret = get_phys_addr(env, addr, 0, mmu_idx, &phys_addr,
322
- attrs, &prot, &page_size, &fsr, &fi);
323
+ attrs, &prot, &page_size, &fsr, &fi, NULL);
324
325
if (ret) {
326
return -1;
53
--
327
--
54
2.7.4
328
2.7.4
55
329
56
330
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Thomas Huth <thuth@redhat.com>
2
2
3
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
3
This device causes QEMU to abort if the user tries to instantiate it:
4
Message-id: 20170729234930.725-1-f4bug@amsat.org
4
5
$ qemu-system-aarch64 -M sabrelite -smp 1,maxcpus=2 -device fsl,,imx6
6
Unexpected error in qemu_chr_fe_init() at chardev/char-fe.c:222:
7
qemu-system-aarch64: -device fsl,,imx6: Device 'serial0' is in use
8
Aborted (core dumped)
9
10
The device uses serial_hds[] directly in its realize function, so it
11
can not be instantiated again by the user.
12
13
Signed-off-by: Thomas Huth <thuth@redhat.com>
14
Message-id: 1509519537-6964-2-git-send-email-thuth@redhat.com
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
17
---
8
hw/misc/mps2-scc.c | 4 ++--
18
hw/arm/fsl-imx6.c | 3 ++-
9
1 file changed, 2 insertions(+), 2 deletions(-)
19
1 file changed, 2 insertions(+), 1 deletion(-)
10
20
11
diff --git a/hw/misc/mps2-scc.c b/hw/misc/mps2-scc.c
21
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
12
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/misc/mps2-scc.c
23
--- a/hw/arm/fsl-imx6.c
14
+++ b/hw/misc/mps2-scc.c
24
+++ b/hw/arm/fsl-imx6.c
15
@@ -XXX,XX +XXX,XX @@ static Property mps2_scc_properties[] = {
25
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6_class_init(ObjectClass *oc, void *data)
16
/* Values for various read-only ID registers (which are specific
26
DeviceClass *dc = DEVICE_CLASS(oc);
17
* to the board model or FPGA image)
27
18
*/
28
dc->realize = fsl_imx6_realize;
19
- DEFINE_PROP_UINT32("scc-cfg4", MPS2SCC, aid, 0),
29
-
20
+ DEFINE_PROP_UINT32("scc-cfg4", MPS2SCC, cfg4, 0),
30
dc->desc = "i.MX6 SOC";
21
DEFINE_PROP_UINT32("scc-aid", MPS2SCC, aid, 0),
31
+ /* Reason: Uses serial_hds[] in the realize() function */
22
- DEFINE_PROP_UINT32("scc-id", MPS2SCC, aid, 0),
32
+ dc->user_creatable = false;
23
+ DEFINE_PROP_UINT32("scc-id", MPS2SCC, id, 0),
33
}
24
/* These are the initial settings for the source clocks on the board.
34
25
* In hardware they can be configured via a config file read by the
35
static const TypeInfo fsl_imx6_type_info = {
26
* motherboard configuration controller to suit the FPGA image.
27
--
36
--
28
2.7.4
37
2.7.4
29
38
30
39
diff view generated by jsdifflib
1
The PMSAv7 region number register is migrated for R profile
1
From: Thomas Huth <thuth@redhat.com>
2
cores using the cpreg scheme, but M profile doesn't use
3
cpregs, and so we weren't migrating the MPU_RNR register state
4
at all. Fix that by adding a migration subsection for the
5
M profile case.
6
2
3
QEMU currently crashes when the user tries to instantiate the fsl,imx25
4
device manually:
5
6
$ aarch64-softmmu/qemu-system-aarch64 -S -M imx25-pdk -device fsl,,imx25
7
**
8
ERROR:/home/thuth/devel/qemu/tcg/tcg.c:538:tcg_register_thread:
9
assertion failed: (n < max_cpus)
10
11
The imx25-pdk board (which is the one that uses this CPU type) only
12
supports one CPU, and the realize function of the "fsl,imx25" device
13
also uses serial_hds[] directly, so this device clearly can not be
14
instantiated twice and thus we should mark it with user_creatable = 0.
15
16
Signed-off-by: Thomas Huth <thuth@redhat.com>
17
Message-id: 1509519537-6964-3-git-send-email-thuth@redhat.com
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 1501153150-19984-6-git-send-email-peter.maydell@linaro.org
10
---
20
---
11
target/arm/machine.c | 28 ++++++++++++++++++++++++++++
21
hw/arm/fsl-imx25.c | 6 +++++-
12
1 file changed, 28 insertions(+)
22
1 file changed, 5 insertions(+), 1 deletion(-)
13
23
14
diff --git a/target/arm/machine.c b/target/arm/machine.c
24
diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
15
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/machine.c
26
--- a/hw/arm/fsl-imx25.c
17
+++ b/target/arm/machine.c
27
+++ b/hw/arm/fsl-imx25.c
18
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pmsav7 = {
28
@@ -XXX,XX +XXX,XX @@ static void fsl_imx25_class_init(ObjectClass *oc, void *data)
19
}
29
DeviceClass *dc = DEVICE_CLASS(oc);
20
};
30
21
31
dc->realize = fsl_imx25_realize;
22
+static bool pmsav7_rnr_needed(void *opaque)
32
-
23
+{
33
dc->desc = "i.MX25 SOC";
24
+ ARMCPU *cpu = opaque;
34
+ /*
25
+ CPUARMState *env = &cpu->env;
35
+ * Reason: uses serial_hds in realize and the imx25 board does not
26
+
36
+ * support multiple CPUs
27
+ /* For R profile cores pmsav7.rnr is migrated via the cpreg
28
+ * "RGNR" definition in helper.h. For M profile we have to
29
+ * migrate it separately.
30
+ */
37
+ */
31
+ return arm_feature(env, ARM_FEATURE_M);
38
+ dc->user_creatable = false;
32
+}
39
}
33
+
40
34
+static const VMStateDescription vmstate_pmsav7_rnr = {
41
static const TypeInfo fsl_imx25_type_info = {
35
+ .name = "cpu/pmsav7-rnr",
36
+ .version_id = 1,
37
+ .minimum_version_id = 1,
38
+ .needed = pmsav7_rnr_needed,
39
+ .fields = (VMStateField[]) {
40
+ VMSTATE_UINT32(env.pmsav7.rnr, ARMCPU),
41
+ VMSTATE_END_OF_LIST()
42
+ }
43
+};
44
+
45
static int get_cpsr(QEMUFile *f, void *opaque, size_t size,
46
VMStateField *field)
47
{
48
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_arm_cpu = {
49
&vmstate_iwmmxt,
50
&vmstate_m,
51
&vmstate_thumb2ee,
52
+ /* pmsav7_rnr must come before pmsav7 so that we have the
53
+ * region number before we test it in the VMSTATE_VALIDATE
54
+ * in vmstate_pmsav7.
55
+ */
56
+ &vmstate_pmsav7_rnr,
57
&vmstate_pmsav7,
58
NULL
59
}
60
--
42
--
61
2.7.4
43
2.7.4
62
44
63
45
diff view generated by jsdifflib
1
The M profile PMSAv7 specification says that if the address being looked
1
From: Thomas Huth <thuth@redhat.com>
2
up is in the PPB region (0xe0000000 - 0xe00fffff) then we do not use
3
the MPU regions but always use the default memory map. Implement this
4
(we were previously behaving like an R profile PMSAv7, which does not
5
special case this).
6
2
3
QEMU currently crashes when the user tries to instantiate the fsl,imx31
4
device manually:
5
6
$ aarch64-softmmu/qemu-system-aarch64 -M kzm -device fsl,,imx31
7
**
8
ERROR:/home/thuth/devel/qemu/tcg/tcg.c:538:tcg_register_thread:
9
assertion failed: (n < max_cpus)
10
Aborted (core dumped)
11
12
The kzm board (which is the one that uses this CPU type) only supports
13
one CPU, and the realize function of the "fsl,imx31" device also uses
14
serial_hds[] directly, so this device clearly can not be instantiated
15
twice and thus we should mark it with user_creatable = false.
16
17
Signed-off-by: Thomas Huth <thuth@redhat.com>
18
Message-id: 1509519537-6964-4-git-send-email-thuth@redhat.com
19
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 1501153150-19984-2-git-send-email-peter.maydell@linaro.org
10
---
21
---
11
target/arm/helper.c | 17 ++++++++++++++++-
22
hw/arm/fsl-imx31.c | 6 +++++-
12
1 file changed, 16 insertions(+), 1 deletion(-)
23
1 file changed, 5 insertions(+), 1 deletion(-)
13
24
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
25
diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c
15
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/helper.c
27
--- a/hw/arm/fsl-imx31.c
17
+++ b/target/arm/helper.c
28
+++ b/hw/arm/fsl-imx31.c
18
@@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu,
29
@@ -XXX,XX +XXX,XX @@ static void fsl_imx31_class_init(ObjectClass *oc, void *data)
19
}
30
DeviceClass *dc = DEVICE_CLASS(oc);
31
32
dc->realize = fsl_imx31_realize;
33
-
34
dc->desc = "i.MX31 SOC";
35
+ /*
36
+ * Reason: uses serial_hds in realize and the kzm board does not
37
+ * support multiple CPUs
38
+ */
39
+ dc->user_creatable = false;
20
}
40
}
21
41
22
+static inline bool m_is_ppb_region(CPUARMState *env, uint32_t address)
42
static const TypeInfo fsl_imx31_type_info = {
23
+{
24
+ /* True if address is in the M profile PPB region 0xe0000000 - 0xe00fffff */
25
+ return arm_feature(env, ARM_FEATURE_M) &&
26
+ extract32(address, 20, 12) == 0xe00;
27
+}
28
+
29
static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
30
int access_type, ARMMMUIdx mmu_idx,
31
hwaddr *phys_ptr, int *prot, uint32_t *fsr)
32
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
33
*phys_ptr = address;
34
*prot = 0;
35
36
- if (regime_translation_disabled(env, mmu_idx)) { /* MPU disabled */
37
+ if (regime_translation_disabled(env, mmu_idx) ||
38
+ m_is_ppb_region(env, address)) {
39
+ /* MPU disabled or M profile PPB access: use default memory map.
40
+ * The other case which uses the default memory map in the
41
+ * v7M ARM ARM pseudocode is exception vector reads from the vector
42
+ * table. In QEMU those accesses are done in arm_v7m_load_vector(),
43
+ * which always does a direct read using address_space_ldl(), rather
44
+ * than going via this function, so we don't need to check that here.
45
+ */
46
get_phys_addr_pmsav7_default(env, mmu_idx, address, prot);
47
} else { /* MPU enabled */
48
for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) {
49
--
43
--
50
2.7.4
44
2.7.4
51
45
52
46
diff view generated by jsdifflib
1
When the PMSAv7 implementation was originally added it was for R profile
1
For AArch32 LDREXD and STREXD, architecturally the 32-bit word at the
2
CPUs only, and reset was handled using the cpreg .resetfn hooks.
2
lowest address is always Rt and the one at addr+4 is Rt2, even if the
3
Unfortunately for M profile cores this doesn't work, because they do
3
CPU is big-endian. Our implementation does these with a single
4
not register any cpregs. Move the reset handling into arm_cpu_reset(),
4
64-bit store, so if we're big-endian then we need to put the two
5
where it will work for both R profile and M profile cores.
5
32-bit halves together in the opposite order to little-endian,
6
so that they end up in the right places. We were trying to do
7
this with the gen_aa32_frob64() function, but that is not correct
8
for the usermode emulator, because there there is a distinction
9
between "load a 64 bit value" (which does a BE 64-bit access
10
and doesn't need swapping) and "load two 32 bit values as one
11
64 bit access" (where we still need to do the swapping, like
12
system mode BE32).
6
13
14
Fixes: https://bugs.launchpad.net/qemu/+bug/1725267
15
Cc: qemu-stable@nongnu.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
17
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 1501153150-19984-5-git-send-email-peter.maydell@linaro.org
18
Message-id: 1509622400-13351-1-git-send-email-peter.maydell@linaro.org
10
---
19
---
11
target/arm/cpu.c | 14 ++++++++++++++
20
target/arm/translate.c | 39 ++++++++++++++++++++++++++++++++++-----
12
target/arm/helper.c | 28 ++++++++++++----------------
21
1 file changed, 34 insertions(+), 5 deletions(-)
13
2 files changed, 26 insertions(+), 16 deletions(-)
14
22
15
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
23
diff --git a/target/arm/translate.c b/target/arm/translate.c
16
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu.c
25
--- a/target/arm/translate.c
18
+++ b/target/arm/cpu.c
26
+++ b/target/arm/translate.c
19
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s)
27
@@ -XXX,XX +XXX,XX @@ static void gen_load_exclusive(DisasContext *s, int rt, int rt2,
20
28
TCGv_i32 tmp2 = tcg_temp_new_i32();
21
env->vfp.xregs[ARM_VFP_FPEXC] = 0;
29
TCGv_i64 t64 = tcg_temp_new_i64();
22
#endif
30
31
- gen_aa32_ld_i64(s, t64, addr, get_mem_index(s), opc);
32
+ /* For AArch32, architecturally the 32-bit word at the lowest
33
+ * address is always Rt and the one at addr+4 is Rt2, even if
34
+ * the CPU is big-endian. That means we don't want to do a
35
+ * gen_aa32_ld_i64(), which invokes gen_aa32_frob64() as if
36
+ * for an architecturally 64-bit access, but instead do a
37
+ * 64-bit access using MO_BE if appropriate and then split
38
+ * the two halves.
39
+ * This only makes a difference for BE32 user-mode, where
40
+ * frob64() must not flip the two halves of the 64-bit data
41
+ * but this code must treat BE32 user-mode like BE32 system.
42
+ */
43
+ TCGv taddr = gen_aa32_addr(s, addr, opc);
23
+
44
+
24
+ if (arm_feature(env, ARM_FEATURE_PMSA) &&
45
+ tcg_gen_qemu_ld_i64(t64, taddr, get_mem_index(s), opc);
25
+ arm_feature(env, ARM_FEATURE_V7)) {
46
+ tcg_temp_free(taddr);
26
+ if (cpu->pmsav7_dregion > 0) {
47
tcg_gen_mov_i64(cpu_exclusive_val, t64);
27
+ memset(env->pmsav7.drbar, 0,
48
- tcg_gen_extr_i64_i32(tmp, tmp2, t64);
28
+ sizeof(*env->pmsav7.drbar) * cpu->pmsav7_dregion);
49
+ if (s->be_data == MO_BE) {
29
+ memset(env->pmsav7.drsr, 0,
50
+ tcg_gen_extr_i64_i32(tmp2, tmp, t64);
30
+ sizeof(*env->pmsav7.drsr) * cpu->pmsav7_dregion);
51
+ } else {
31
+ memset(env->pmsav7.dracr, 0,
52
+ tcg_gen_extr_i64_i32(tmp, tmp2, t64);
32
+ sizeof(*env->pmsav7.dracr) * cpu->pmsav7_dregion);
33
+ }
53
+ }
34
+ env->pmsav7.rnr = 0;
54
tcg_temp_free_i64(t64);
35
+ }
55
36
+
56
store_reg(s, rt2, tmp2);
37
set_flush_to_zero(1, &env->vfp.standard_fp_status);
57
@@ -XXX,XX +XXX,XX @@ static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2,
38
set_flush_inputs_to_zero(1, &env->vfp.standard_fp_status);
58
TCGv_i64 n64 = tcg_temp_new_i64();
39
set_default_nan_mode(1, &env->vfp.standard_fp_status);
59
40
diff --git a/target/arm/helper.c b/target/arm/helper.c
60
t2 = load_reg(s, rt2);
41
index XXXXXXX..XXXXXXX 100644
61
- tcg_gen_concat_i32_i64(n64, t1, t2);
42
--- a/target/arm/helper.c
62
+ /* For AArch32, architecturally the 32-bit word at the lowest
43
+++ b/target/arm/helper.c
63
+ * address is always Rt and the one at addr+4 is Rt2, even if
44
@@ -XXX,XX +XXX,XX @@ static void pmsav7_write(CPUARMState *env, const ARMCPRegInfo *ri,
64
+ * the CPU is big-endian. Since we're going to treat this as a
45
*u32p = value;
65
+ * single 64-bit BE store, we need to put the two halves in the
46
}
66
+ * opposite order for BE to LE, so that they end up in the right
47
67
+ * places.
48
-static void pmsav7_reset(CPUARMState *env, const ARMCPRegInfo *ri)
68
+ * We don't want gen_aa32_frob64() because that does the wrong
49
-{
69
+ * thing for BE32 usermode.
50
- ARMCPU *cpu = arm_env_get_cpu(env);
70
+ */
51
- uint32_t *u32p = *(uint32_t **)raw_ptr(env, ri);
71
+ if (s->be_data == MO_BE) {
52
-
72
+ tcg_gen_concat_i32_i64(n64, t2, t1);
53
- if (!u32p) {
73
+ } else {
54
- return;
74
+ tcg_gen_concat_i32_i64(n64, t1, t2);
55
- }
75
+ }
56
-
76
tcg_temp_free_i32(t2);
57
- memset(u32p, 0, sizeof(*u32p) * cpu->pmsav7_dregion);
77
- gen_aa32_frob64(s, n64);
58
-}
78
59
-
79
tcg_gen_atomic_cmpxchg_i64(o64, taddr, cpu_exclusive_val, n64,
60
static void pmsav7_rgnr_write(CPUARMState *env, const ARMCPRegInfo *ri,
80
get_mem_index(s), opc);
61
uint64_t value)
81
tcg_temp_free_i64(n64);
62
{
82
63
@@ -XXX,XX +XXX,XX @@ static void pmsav7_rgnr_write(CPUARMState *env, const ARMCPRegInfo *ri,
83
- gen_aa32_frob64(s, o64);
64
}
84
tcg_gen_setcond_i64(TCG_COND_NE, o64, o64, cpu_exclusive_val);
65
85
tcg_gen_extrl_i64_i32(t0, o64);
66
static const ARMCPRegInfo pmsav7_cp_reginfo[] = {
67
+ /* Reset for all these registers is handled in arm_cpu_reset(),
68
+ * because the PMSAv7 is also used by M-profile CPUs, which do
69
+ * not register cpregs but still need the state to be reset.
70
+ */
71
{ .name = "DRBAR", .cp = 15, .crn = 6, .opc1 = 0, .crm = 1, .opc2 = 0,
72
.access = PL1_RW, .type = ARM_CP_NO_RAW,
73
.fieldoffset = offsetof(CPUARMState, pmsav7.drbar),
74
- .readfn = pmsav7_read, .writefn = pmsav7_write, .resetfn = pmsav7_reset },
75
+ .readfn = pmsav7_read, .writefn = pmsav7_write,
76
+ .resetfn = arm_cp_reset_ignore },
77
{ .name = "DRSR", .cp = 15, .crn = 6, .opc1 = 0, .crm = 1, .opc2 = 2,
78
.access = PL1_RW, .type = ARM_CP_NO_RAW,
79
.fieldoffset = offsetof(CPUARMState, pmsav7.drsr),
80
- .readfn = pmsav7_read, .writefn = pmsav7_write, .resetfn = pmsav7_reset },
81
+ .readfn = pmsav7_read, .writefn = pmsav7_write,
82
+ .resetfn = arm_cp_reset_ignore },
83
{ .name = "DRACR", .cp = 15, .crn = 6, .opc1 = 0, .crm = 1, .opc2 = 4,
84
.access = PL1_RW, .type = ARM_CP_NO_RAW,
85
.fieldoffset = offsetof(CPUARMState, pmsav7.dracr),
86
- .readfn = pmsav7_read, .writefn = pmsav7_write, .resetfn = pmsav7_reset },
87
+ .readfn = pmsav7_read, .writefn = pmsav7_write,
88
+ .resetfn = arm_cp_reset_ignore },
89
{ .name = "RGNR", .cp = 15, .crn = 6, .opc1 = 0, .crm = 2, .opc2 = 0,
90
.access = PL1_RW,
91
.fieldoffset = offsetof(CPUARMState, pmsav7.rnr),
92
- .writefn = pmsav7_rgnr_write },
93
+ .writefn = pmsav7_rgnr_write,
94
+ .resetfn = arm_cp_reset_ignore },
95
REGINFO_SENTINEL
96
};
97
86
98
--
87
--
99
2.7.4
88
2.7.4
100
89
101
90
diff view generated by jsdifflib
1
Correct off-by-one bug in the PSMAv7 MPU tracing where it would print
1
From: Shanker Donthineni <shankerd@codeaurora.org>
2
a write access as "reading", an insn fetch as "writing", and a read
3
access as "execute".
4
2
5
Since we have an MMUAccessType enum now, we can make the code clearer
3
The commit cddafd8f353d ("hw/intc/arm_gicv3_its: Implement state save
6
in the process by using that rather than the raw 0/1/2 values.
4
/restore") breaks the backward compatibility with the older kernels
5
where vITS save/restore support is not available. The vmstate function
6
vm_change_state_handler() should not be registered if the running kernel
7
doesn't support ITS save/restore feature. Otherwise VM instance will be
8
killed whenever vmstate callback function is invoked.
7
9
10
Observed a virtual machine shutdown with QEMU-2.10+linux-4.11 when testing
11
the reboot command "virsh reboot <domain> --mode acpi" instead of reboot.
12
13
KVM Error: 'KVM_SET_DEVICE_ATTR failed: Group 4 attr 0x00000000000001'
14
15
Signed-off-by: Shanker Donthineni <shankerd@codeaurora.org>
16
Reviewed-by: Eric Auger <eric.auger@redhat.com>
17
Message-id: 1509712671-16299-1-git-send-email-shankerd@codeaurora.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Richard Henderson <rth@twiddle.net>
10
Message-id: 1500906792-18010-1-git-send-email-peter.maydell@linaro.org
11
---
19
---
12
target/arm/helper.c | 4 ++--
20
hw/intc/arm_gicv3_its_kvm.c | 4 ++--
13
1 file changed, 2 insertions(+), 2 deletions(-)
21
1 file changed, 2 insertions(+), 2 deletions(-)
14
22
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
23
diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c
16
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
25
--- a/hw/intc/arm_gicv3_its_kvm.c
18
+++ b/target/arm/helper.c
26
+++ b/hw/intc/arm_gicv3_its_kvm.c
19
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr(CPUARMState *env, target_ulong address,
27
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_its_realize(DeviceState *dev, Error **errp)
20
phys_ptr, prot, fsr);
28
error_free(s->migration_blocker);
21
qemu_log_mask(CPU_LOG_MMU, "PMSAv7 MPU lookup for %s at 0x%08" PRIx32
29
return;
22
" mmu_idx %u -> %s (prot %c%c%c)\n",
30
}
23
- access_type == 1 ? "reading" :
31
+ } else {
24
- (access_type == 2 ? "writing" : "execute"),
32
+ qemu_add_vm_change_state_handler(vm_change_state_handler, s);
25
+ access_type == MMU_DATA_LOAD ? "reading" :
33
}
26
+ (access_type == MMU_DATA_STORE ? "writing" : "execute"),
34
27
(uint32_t)address, mmu_idx,
35
kvm_msi_use_devid = true;
28
ret ? "Miss" : "Hit",
36
kvm_gsi_direct_mapping = false;
29
*prot & PAGE_READ ? 'r' : '-',
37
kvm_msi_via_irqfd_allowed = kvm_irqfds_enabled();
38
-
39
- qemu_add_vm_change_state_handler(vm_change_state_handler, s);
40
}
41
42
/**
30
--
43
--
31
2.7.4
44
2.7.4
32
45
33
46
diff view generated by jsdifflib
1
Almost all of the PMSAv7 state is in the pmsav7 substruct of
1
From: Eric Auger <eric.auger@redhat.com>
2
the ARM CPU state structure. The exception is the region
3
number register, which is in cp15.c6_rgnr. This exception
4
is a bit odd for M profile, which otherwise generally does
5
not store state in the cp15 substruct.
6
2
7
Rename cp15.c6_rgnr to pmsav7.rnr accordingly.
3
The ITS is not fully properly reset at the moment. Caches are
4
not emptied.
8
5
6
After a reset, in case we attempt to save the state before
7
the bound devices have registered their MSIs and after the
8
1st level table has been allocated by the ITS driver
9
(device BASER is valid), the first level entries are still
10
invalid. If the device cache is not empty (devices registered
11
before the reset), vgic_its_save_device_tables fails with -EINVAL.
12
This causes a QEMU abort().
13
14
Cc: qemu-stable@nongnu.org
15
Signed-off-by: Eric Auger <eric.auger@redhat.com>
16
Reported-by: wanghaibin <wanghaibin.wang@huawei.com>
17
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
11
Message-id: 1501153150-19984-4-git-send-email-peter.maydell@linaro.org
12
---
19
---
13
target/arm/cpu.h | 3 +--
20
hw/intc/arm_gicv3_its_kvm.c | 8 ++------
14
hw/intc/armv7m_nvic.c | 14 +++++++-------
21
1 file changed, 2 insertions(+), 6 deletions(-)
15
target/arm/helper.c | 6 +++---
16
target/arm/machine.c | 2 +-
17
4 files changed, 12 insertions(+), 13 deletions(-)
18
22
19
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
23
diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c
20
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/cpu.h
25
--- a/hw/intc/arm_gicv3_its_kvm.c
22
+++ b/target/arm/cpu.h
26
+++ b/hw/intc/arm_gicv3_its_kvm.c
23
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
27
@@ -XXX,XX +XXX,XX @@ static void vm_change_state_handler(void *opaque, int running,
24
uint64_t par_el[4];
28
{
25
};
29
GICv3ITSState *s = (GICv3ITSState *)opaque;
26
30
Error *err = NULL;
27
- uint32_t c6_rgnr;
31
- int ret;
28
-
32
29
uint32_t c9_insn; /* Cache lockdown registers. */
33
if (running) {
30
uint32_t c9_data;
31
uint64_t c9_pmcr; /* performance monitor control register */
32
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
33
uint32_t *drbar;
34
uint32_t *drsr;
35
uint32_t *dracr;
36
+ uint32_t rnr;
37
} pmsav7;
38
39
void *nvic;
40
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
41
index XXXXXXX..XXXXXXX 100644
42
--- a/hw/intc/armv7m_nvic.c
43
+++ b/hw/intc/armv7m_nvic.c
44
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset)
45
case 0xd94: /* MPU_CTRL */
46
return cpu->env.v7m.mpu_ctrl;
47
case 0xd98: /* MPU_RNR */
48
- return cpu->env.cp15.c6_rgnr;
49
+ return cpu->env.pmsav7.rnr;
50
case 0xd9c: /* MPU_RBAR */
51
case 0xda4: /* MPU_RBAR_A1 */
52
case 0xdac: /* MPU_RBAR_A2 */
53
case 0xdb4: /* MPU_RBAR_A3 */
54
{
55
- int region = cpu->env.cp15.c6_rgnr;
56
+ int region = cpu->env.pmsav7.rnr;
57
58
if (region >= cpu->pmsav7_dregion) {
59
return 0;
60
@@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset)
61
case 0xdb0: /* MPU_RASR_A2 */
62
case 0xdb8: /* MPU_RASR_A3 */
63
{
64
- int region = cpu->env.cp15.c6_rgnr;
65
+ int region = cpu->env.pmsav7.rnr;
66
67
if (region >= cpu->pmsav7_dregion) {
68
return 0;
69
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value)
70
PRIu32 "/%" PRIu32 "\n",
71
value, cpu->pmsav7_dregion);
72
} else {
73
- cpu->env.cp15.c6_rgnr = value;
74
+ cpu->env.pmsav7.rnr = value;
75
}
76
break;
77
case 0xd9c: /* MPU_RBAR */
78
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value)
79
region, cpu->pmsav7_dregion);
80
return;
81
}
82
- cpu->env.cp15.c6_rgnr = region;
83
+ cpu->env.pmsav7.rnr = region;
84
} else {
85
- region = cpu->env.cp15.c6_rgnr;
86
+ region = cpu->env.pmsav7.rnr;
87
}
88
89
if (region >= cpu->pmsav7_dregion) {
90
@@ -XXX,XX +XXX,XX @@ static void nvic_writel(NVICState *s, uint32_t offset, uint32_t value)
91
case 0xdb0: /* MPU_RASR_A2 */
92
case 0xdb8: /* MPU_RASR_A3 */
93
{
94
- int region = cpu->env.cp15.c6_rgnr;
95
+ int region = cpu->env.pmsav7.rnr;
96
97
if (region >= cpu->pmsav7_dregion) {
98
return;
99
diff --git a/target/arm/helper.c b/target/arm/helper.c
100
index XXXXXXX..XXXXXXX 100644
101
--- a/target/arm/helper.c
102
+++ b/target/arm/helper.c
103
@@ -XXX,XX +XXX,XX @@ static uint64_t pmsav7_read(CPUARMState *env, const ARMCPRegInfo *ri)
104
return 0;
105
}
106
107
- u32p += env->cp15.c6_rgnr;
108
+ u32p += env->pmsav7.rnr;
109
return *u32p;
110
}
111
112
@@ -XXX,XX +XXX,XX @@ static void pmsav7_write(CPUARMState *env, const ARMCPRegInfo *ri,
113
return;
34
return;
114
}
35
}
115
36
116
- u32p += env->cp15.c6_rgnr;
37
- ret = kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
117
+ u32p += env->pmsav7.rnr;
38
- KVM_DEV_ARM_ITS_SAVE_TABLES, NULL, true, &err);
118
tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */
39
+ kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
119
*u32p = value;
40
+ KVM_DEV_ARM_ITS_SAVE_TABLES, NULL, true, &err);
41
if (err) {
42
error_report_err(err);
43
}
44
- if (ret < 0 && ret != -EFAULT) {
45
- abort();
46
- }
120
}
47
}
121
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav7_cp_reginfo[] = {
48
122
.readfn = pmsav7_read, .writefn = pmsav7_write, .resetfn = pmsav7_reset },
49
static void kvm_arm_its_realize(DeviceState *dev, Error **errp)
123
{ .name = "RGNR", .cp = 15, .crn = 6, .opc1 = 0, .crm = 2, .opc2 = 0,
124
.access = PL1_RW,
125
- .fieldoffset = offsetof(CPUARMState, cp15.c6_rgnr),
126
+ .fieldoffset = offsetof(CPUARMState, pmsav7.rnr),
127
.writefn = pmsav7_rgnr_write },
128
REGINFO_SENTINEL
129
};
130
diff --git a/target/arm/machine.c b/target/arm/machine.c
131
index XXXXXXX..XXXXXXX 100644
132
--- a/target/arm/machine.c
133
+++ b/target/arm/machine.c
134
@@ -XXX,XX +XXX,XX @@ static bool pmsav7_rgnr_vmstate_validate(void *opaque, int version_id)
135
{
136
ARMCPU *cpu = opaque;
137
138
- return cpu->env.cp15.c6_rgnr < cpu->pmsav7_dregion;
139
+ return cpu->env.pmsav7.rnr < cpu->pmsav7_dregion;
140
}
141
142
static const VMStateDescription vmstate_pmsav7 = {
143
--
50
--
144
2.7.4
51
2.7.4
145
52
146
53
diff view generated by jsdifflib