1
target-arm queue for 3.1: mostly bug fixes, but the "turn on
1
Arm queue; bugfixes only.
2
EL2 support for Cortex-A7 and -A15" is technically enabling
3
of a new feature... I think this is OK since we're only at rc1,
4
and it's easy to revert that feature bit flip if necessary.
5
2
6
thanks
3
thanks
7
-- PMM
4
-- PMM
8
5
6
The following changes since commit 48aa8f0ac536db3550a35c295ff7de94e4c33739:
9
7
10
The following changes since commit 5704c36d25ee84e7129722cb0db53df9faefe943:
8
Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2020-11-16' into staging (2020-11-17 11:07:00 +0000)
11
12
Merge remote-tracking branch 'remotes/kraxel/tags/fixes-31-20181112-pull-request' into staging (2018-11-12 15:55:40 +0000)
13
9
14
are available in the Git repository at:
10
are available in the Git repository at:
15
11
16
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20181112
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20201117
17
13
18
for you to fetch changes up to 1a4c1a6dbf60aebddd07753f1013ea896c06ad29:
14
for you to fetch changes up to ab135622cf478585bdfcb68b85e4a817d74a0c42:
19
15
20
target/arm/cpu: Give Cortex-A15 and -A7 the EL2 feature (2018-11-12 16:52:29 +0000)
16
tmp105: Correct handling of temperature limit checks (2020-11-17 12:56:33 +0000)
21
17
22
----------------------------------------------------------------
18
----------------------------------------------------------------
23
target/arm queue:
19
target-arm queue:
24
* Remove no-longer-needed workaround for small SAU regions for v8M
20
* hw/arm/virt: ARM_VIRT must select ARM_GIC
25
* Remove antique TODO comment
21
* exynos: Fix bad printf format specifiers
26
* MAINTAINERS: Add an entry for the 'collie' machine
22
* hw/input/ps2.c: Remove remnants of printf debug
27
* hw/arm/sysbus-fdt: Only call match_fn callback if the type matches
23
* target/openrisc: Remove dead code attempting to check "is timer disabled"
28
* Fix infinite recursion in tlbi_aa64_vmalle1_write()
24
* register: Remove unnecessary NULL check
29
* ARM KVM: fix various bugs in handling of guest debugging
25
* util/cutils: Fix Coverity array overrun in freq_to_str()
30
* Correctly implement handling of HCR_EL2.{VI, VF}
26
* configure: Make "does libgio work" test pull in some actual functions
31
* Hyp mode R14 is shared with User and System
27
* tmp105: reset the T_low and T_High registers
32
* Give Cortex-A15 and -A7 the EL2 feature
28
* tmp105: Correct handling of temperature limit checks
33
29
34
----------------------------------------------------------------
30
----------------------------------------------------------------
35
Alex Bennée (6):
31
Alex Chen (1):
36
target/arm64: properly handle DBGVR RESS bits
32
exynos: Fix bad printf format specifiers
37
target/arm64: hold BQL when calling do_interrupt()
38
target/arm64: kvm debug set target_el when passing exception to guest
39
tests/guest-debug: fix scoping of failcount
40
arm: use symbolic MDCR_TDE in arm_debug_target_el
41
arm: fix aa64_generate_debug_exceptions to work with EL2
42
33
43
Eric Auger (1):
34
Alistair Francis (1):
44
hw/arm/sysbus-fdt: Only call match_fn callback if the type matches
35
register: Remove unnecessary NULL check
45
36
46
Peter Maydell (7):
37
Andrew Jones (1):
47
target/arm: Remove workaround for small SAU regions
38
hw/arm/virt: ARM_VIRT must select ARM_GIC
48
target/arm: Remove antique TODO comment
49
Revert "target/arm: Implement HCR.VI and VF"
50
target/arm: Track the state of our irq lines from the GIC explicitly
51
target/arm: Correctly implement handling of HCR_EL2.{VI, VF}
52
target/arm: Hyp mode R14 is shared with User and System
53
target/arm/cpu: Give Cortex-A15 and -A7 the EL2 feature
54
39
55
Richard Henderson (1):
40
Peter Maydell (5):
56
target/arm: Fix typo in tlbi_aa64_vmalle1_write
41
hw/input/ps2.c: Remove remnants of printf debug
42
target/openrisc: Remove dead code attempting to check "is timer disabled"
43
configure: Make "does libgio work" test pull in some actual functions
44
hw/misc/tmp105: reset the T_low and T_High registers
45
tmp105: Correct handling of temperature limit checks
57
46
58
Thomas Huth (1):
47
Philippe Mathieu-Daudé (1):
59
MAINTAINERS: Add an entry for the 'collie' machine
48
util/cutils: Fix Coverity array overrun in freq_to_str()
60
49
61
target/arm/cpu.h | 44 +++++++++++------
50
configure | 11 +++++--
62
target/arm/internals.h | 34 +++++++++++++
51
hw/misc/tmp105.h | 7 +++++
63
hw/arm/sysbus-fdt.c | 12 +++--
52
hw/core/register.c | 4 ---
64
target/arm/cpu.c | 66 ++++++++++++++++++++++++-
53
hw/input/ps2.c | 9 ------
65
target/arm/helper.c | 101 +++++++++++++-------------------------
54
hw/misc/tmp105.c | 73 ++++++++++++++++++++++++++++++++++++++------
66
target/arm/kvm32.c | 4 +-
55
hw/timer/exynos4210_mct.c | 4 +--
67
target/arm/kvm64.c | 20 +++++++-
56
hw/timer/exynos4210_pwm.c | 8 ++---
68
target/arm/machine.c | 51 +++++++++++++++++++
57
target/openrisc/sys_helper.c | 3 --
69
target/arm/op_helper.c | 4 +-
58
util/cutils.c | 3 +-
70
MAINTAINERS | 7 +++
59
hw/arm/Kconfig | 1 +
71
tests/guest-debug/test-gdbstub.py | 1 +
60
10 files changed, 89 insertions(+), 34 deletions(-)
72
11 files changed, 248 insertions(+), 96 deletions(-)
73
61
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Andrew Jones <drjones@redhat.com>
2
2
3
You should declare you are using a global version of a variable before
3
The removal of the selection of A15MPCORE from ARM_VIRT also
4
you attempt to modify it in a function.
4
removed what A15MPCORE selects, ARM_GIC. We still need ARM_GIC.
5
5
6
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
6
Fixes: bec3c97e0cf9 ("hw/arm/virt: Remove dependency on Cortex-A15 MPCore peripherals")
7
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reported-by: Miroslav Rezanina <mrezanin@redhat.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Signed-off-by: Andrew Jones <drjones@redhat.com>
9
Message-id: 20181109152119.9242-5-alex.bennee@linaro.org
9
Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Message-id: 20201111143440.112763-1-drjones@redhat.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
13
---
12
tests/guest-debug/test-gdbstub.py | 1 +
14
hw/arm/Kconfig | 1 +
13
1 file changed, 1 insertion(+)
15
1 file changed, 1 insertion(+)
14
16
15
diff --git a/tests/guest-debug/test-gdbstub.py b/tests/guest-debug/test-gdbstub.py
17
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
16
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
17
--- a/tests/guest-debug/test-gdbstub.py
19
--- a/hw/arm/Kconfig
18
+++ b/tests/guest-debug/test-gdbstub.py
20
+++ b/hw/arm/Kconfig
19
@@ -XXX,XX +XXX,XX @@ def report(cond, msg):
21
@@ -XXX,XX +XXX,XX @@ config ARM_VIRT
20
print ("PASS: %s" % (msg))
22
imply VFIO_PLATFORM
21
else:
23
imply VFIO_XGMAC
22
print ("FAIL: %s" % (msg))
24
imply TPM_TIS_SYSBUS
23
+ global failcount
25
+ select ARM_GIC
24
failcount += 1
26
select ACPI
25
27
select ARM_SMMUV3
26
28
select GPIO_KEY
27
--
29
--
28
2.19.1
30
2.20.1
29
31
30
32
diff view generated by jsdifflib
1
Hyp mode is an exception to the general rule that each AArch32
1
From: Alex Chen <alex.chen@huawei.com>
2
mode has its own r13, r14 and SPSR -- it has a banked r13 and
3
SPSR but shares its r14 with User and System mode. We were
4
incorrectly implementing it as banked, which meant that on
5
entry to Hyp mode r14 was 0 rather than the USR/SYS r14.
6
2
7
We provide a new function r14_bank_number() which is like
3
We should use printf format specifier "%u" instead of "%d" for
8
the existing bank_number() but provides the index into
4
argument of type "unsigned int".
9
env->banked_r14[]; bank_number() provides the index to use
10
for env->banked_r13[] and env->banked_cpsr[].
11
5
12
All the points in the code that were using bank_number()
6
Reported-by: Euler Robot <euler.robot@huawei.com>
13
to index into env->banked_r14[] are updated for consintency:
7
Signed-off-by: Alex Chen <alex.chen@huawei.com>
14
* switch_mode() -- this is the only place where we fix
8
Message-id: 20201111073651.72804-1-alex.chen@huawei.com
15
an actual bug
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
* aarch64_sync_32_to_64() and aarch64_sync_64_to_32():
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
no behavioural change as we already special-cased Hyp R14
11
---
18
* kvm32.c: no behavioural change since the guest can't ever
12
hw/timer/exynos4210_mct.c | 4 ++--
19
be in Hyp mode, but conceptually the right thing to do
13
hw/timer/exynos4210_pwm.c | 8 ++++----
20
* msr_banked()/mrs_banked(): we can never get to the case
14
2 files changed, 6 insertions(+), 6 deletions(-)
21
that accesses banked_r14[] with tgtmode == ARM_CPU_MODE_HYP,
22
so no behavioural change
23
15
24
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c
25
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
26
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
27
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
28
Message-id: 20181109173553.22341-2-peter.maydell@linaro.org
29
---
30
target/arm/internals.h | 16 ++++++++++++++++
31
target/arm/helper.c | 29 +++++++++++++++--------------
32
target/arm/kvm32.c | 4 ++--
33
target/arm/op_helper.c | 4 ++--
34
4 files changed, 35 insertions(+), 18 deletions(-)
35
36
diff --git a/target/arm/internals.h b/target/arm/internals.h
37
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
38
--- a/target/arm/internals.h
18
--- a/hw/timer/exynos4210_mct.c
39
+++ b/target/arm/internals.h
19
+++ b/hw/timer/exynos4210_mct.c
40
@@ -XXX,XX +XXX,XX @@ static inline int bank_number(int mode)
20
@@ -XXX,XX +XXX,XX @@ static void exynos4210_gcomp_raise_irq(void *opaque, uint32_t id)
41
g_assert_not_reached();
21
/* If CSTAT is pending and IRQ is enabled */
22
if ((s->reg.int_cstat & G_INT_CSTAT_COMP(id)) &&
23
(s->reg.int_enb & G_INT_ENABLE(id))) {
24
- DPRINTF("gcmp timer[%d] IRQ\n", id);
25
+ DPRINTF("gcmp timer[%u] IRQ\n", id);
26
qemu_irq_raise(s->irq[id]);
27
}
42
}
28
}
43
29
@@ -XXX,XX +XXX,XX @@ static void exynos4210_mct_update_freq(Exynos4210MCTState *s)
44
+/**
30
MCT_CFG_GET_DIVIDER(s->reg_mct_cfg));
45
+ * r14_bank_number: Map CPU mode onto register bank for r14
31
46
+ *
32
if (freq != s->freq) {
47
+ * Given an AArch32 CPU mode, return the index into the saved register
33
- DPRINTF("freq=%dHz\n", s->freq);
48
+ * banks to use for the R14 (LR) in that mode. This is the same as
34
+ DPRINTF("freq=%uHz\n", s->freq);
49
+ * bank_number(), except for the special case of Hyp mode, where
35
50
+ * R14 is shared with USR and SYS, unlike its R13 and SPSR.
36
/* global timer */
51
+ * This should be used as the index into env->banked_r14[], and
37
tx_ptimer_set_freq(s->g_timer.ptimer_frc, s->freq);
52
+ * bank_number() used for the index into env->banked_r13[] and
38
diff --git a/hw/timer/exynos4210_pwm.c b/hw/timer/exynos4210_pwm.c
53
+ * env->banked_spsr[].
54
+ */
55
+static inline int r14_bank_number(int mode)
56
+{
57
+ return (mode == ARM_CPU_MODE_HYP) ? BANK_USRSYS : bank_number(mode);
58
+}
59
+
60
void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu);
61
void arm_translate_init(void);
62
63
diff --git a/target/arm/helper.c b/target/arm/helper.c
64
index XXXXXXX..XXXXXXX 100644
39
index XXXXXXX..XXXXXXX 100644
65
--- a/target/arm/helper.c
40
--- a/hw/timer/exynos4210_pwm.c
66
+++ b/target/arm/helper.c
41
+++ b/hw/timer/exynos4210_pwm.c
67
@@ -XXX,XX +XXX,XX @@ static void switch_mode(CPUARMState *env, int mode)
42
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_update_freq(Exynos4210PWMState *s, uint32_t id)
68
43
69
i = bank_number(old_mode);
44
if (freq != s->timer[id].freq) {
70
env->banked_r13[i] = env->regs[13];
45
ptimer_set_freq(s->timer[id].ptimer, s->timer[id].freq);
71
- env->banked_r14[i] = env->regs[14];
46
- DPRINTF("freq=%dHz\n", s->timer[id].freq);
72
env->banked_spsr[i] = env->spsr;
47
+ DPRINTF("freq=%uHz\n", s->timer[id].freq);
73
48
}
74
i = bank_number(mode);
75
env->regs[13] = env->banked_r13[i];
76
- env->regs[14] = env->banked_r14[i];
77
env->spsr = env->banked_spsr[i];
78
+
79
+ env->banked_r14[r14_bank_number(old_mode)] = env->regs[14];
80
+ env->regs[14] = env->banked_r14[r14_bank_number(mode)];
81
}
49
}
82
50
83
/* Physical Interrupt Target EL Lookup Table
51
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque)
84
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env)
52
uint32_t id = s->id;
85
if (mode == ARM_CPU_MODE_HYP) {
53
bool cmp;
86
env->xregs[14] = env->regs[14];
54
87
} else {
55
- DPRINTF("timer %d tick\n", id);
88
- env->xregs[14] = env->banked_r14[bank_number(ARM_CPU_MODE_USR)];
56
+ DPRINTF("timer %u tick\n", id);
89
+ env->xregs[14] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_USR)];
57
90
}
58
/* set irq status */
59
p->reg_tint_cstat |= TINT_CSTAT_STATUS(id);
60
61
/* raise IRQ */
62
if (p->reg_tint_cstat & TINT_CSTAT_ENABLE(id)) {
63
- DPRINTF("timer %d IRQ\n", id);
64
+ DPRINTF("timer %u IRQ\n", id);
65
qemu_irq_raise(p->timer[id].irq);
91
}
66
}
92
67
93
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env)
68
@@ -XXX,XX +XXX,XX @@ static void exynos4210_pwm_tick(void *opaque)
94
env->xregs[16] = env->regs[14];
95
env->xregs[17] = env->regs[13];
96
} else {
97
- env->xregs[16] = env->banked_r14[bank_number(ARM_CPU_MODE_IRQ)];
98
+ env->xregs[16] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_IRQ)];
99
env->xregs[17] = env->banked_r13[bank_number(ARM_CPU_MODE_IRQ)];
100
}
69
}
101
70
102
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env)
71
if (cmp) {
103
env->xregs[18] = env->regs[14];
72
- DPRINTF("auto reload timer %d count to %x\n", id,
104
env->xregs[19] = env->regs[13];
73
+ DPRINTF("auto reload timer %u count to %x\n", id,
105
} else {
74
p->timer[id].reg_tcntb);
106
- env->xregs[18] = env->banked_r14[bank_number(ARM_CPU_MODE_SVC)];
75
ptimer_set_count(p->timer[id].ptimer, p->timer[id].reg_tcntb);
107
+ env->xregs[18] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_SVC)];
76
ptimer_run(p->timer[id].ptimer, 1);
108
env->xregs[19] = env->banked_r13[bank_number(ARM_CPU_MODE_SVC)];
109
}
110
111
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env)
112
env->xregs[20] = env->regs[14];
113
env->xregs[21] = env->regs[13];
114
} else {
115
- env->xregs[20] = env->banked_r14[bank_number(ARM_CPU_MODE_ABT)];
116
+ env->xregs[20] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_ABT)];
117
env->xregs[21] = env->banked_r13[bank_number(ARM_CPU_MODE_ABT)];
118
}
119
120
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env)
121
env->xregs[22] = env->regs[14];
122
env->xregs[23] = env->regs[13];
123
} else {
124
- env->xregs[22] = env->banked_r14[bank_number(ARM_CPU_MODE_UND)];
125
+ env->xregs[22] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_UND)];
126
env->xregs[23] = env->banked_r13[bank_number(ARM_CPU_MODE_UND)];
127
}
128
129
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_32_to_64(CPUARMState *env)
130
env->xregs[i] = env->fiq_regs[i - 24];
131
}
132
env->xregs[29] = env->banked_r13[bank_number(ARM_CPU_MODE_FIQ)];
133
- env->xregs[30] = env->banked_r14[bank_number(ARM_CPU_MODE_FIQ)];
134
+ env->xregs[30] = env->banked_r14[r14_bank_number(ARM_CPU_MODE_FIQ)];
135
}
136
137
env->pc = env->regs[15];
138
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env)
139
if (mode == ARM_CPU_MODE_HYP) {
140
env->regs[14] = env->xregs[14];
141
} else {
142
- env->banked_r14[bank_number(ARM_CPU_MODE_USR)] = env->xregs[14];
143
+ env->banked_r14[r14_bank_number(ARM_CPU_MODE_USR)] = env->xregs[14];
144
}
145
}
146
147
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env)
148
env->regs[14] = env->xregs[16];
149
env->regs[13] = env->xregs[17];
150
} else {
151
- env->banked_r14[bank_number(ARM_CPU_MODE_IRQ)] = env->xregs[16];
152
+ env->banked_r14[r14_bank_number(ARM_CPU_MODE_IRQ)] = env->xregs[16];
153
env->banked_r13[bank_number(ARM_CPU_MODE_IRQ)] = env->xregs[17];
154
}
155
156
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env)
157
env->regs[14] = env->xregs[18];
158
env->regs[13] = env->xregs[19];
159
} else {
160
- env->banked_r14[bank_number(ARM_CPU_MODE_SVC)] = env->xregs[18];
161
+ env->banked_r14[r14_bank_number(ARM_CPU_MODE_SVC)] = env->xregs[18];
162
env->banked_r13[bank_number(ARM_CPU_MODE_SVC)] = env->xregs[19];
163
}
164
165
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env)
166
env->regs[14] = env->xregs[20];
167
env->regs[13] = env->xregs[21];
168
} else {
169
- env->banked_r14[bank_number(ARM_CPU_MODE_ABT)] = env->xregs[20];
170
+ env->banked_r14[r14_bank_number(ARM_CPU_MODE_ABT)] = env->xregs[20];
171
env->banked_r13[bank_number(ARM_CPU_MODE_ABT)] = env->xregs[21];
172
}
173
174
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env)
175
env->regs[14] = env->xregs[22];
176
env->regs[13] = env->xregs[23];
177
} else {
178
- env->banked_r14[bank_number(ARM_CPU_MODE_UND)] = env->xregs[22];
179
+ env->banked_r14[r14_bank_number(ARM_CPU_MODE_UND)] = env->xregs[22];
180
env->banked_r13[bank_number(ARM_CPU_MODE_UND)] = env->xregs[23];
181
}
182
183
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env)
184
env->fiq_regs[i - 24] = env->xregs[i];
185
}
186
env->banked_r13[bank_number(ARM_CPU_MODE_FIQ)] = env->xregs[29];
187
- env->banked_r14[bank_number(ARM_CPU_MODE_FIQ)] = env->xregs[30];
188
+ env->banked_r14[r14_bank_number(ARM_CPU_MODE_FIQ)] = env->xregs[30];
189
}
190
191
env->regs[15] = env->pc;
192
diff --git a/target/arm/kvm32.c b/target/arm/kvm32.c
193
index XXXXXXX..XXXXXXX 100644
194
--- a/target/arm/kvm32.c
195
+++ b/target/arm/kvm32.c
196
@@ -XXX,XX +XXX,XX @@ int kvm_arch_put_registers(CPUState *cs, int level)
197
memcpy(env->usr_regs, env->regs + 8, 5 * sizeof(uint32_t));
198
}
199
env->banked_r13[bn] = env->regs[13];
200
- env->banked_r14[bn] = env->regs[14];
201
env->banked_spsr[bn] = env->spsr;
202
+ env->banked_r14[r14_bank_number(mode)] = env->regs[14];
203
204
/* Now we can safely copy stuff down to the kernel */
205
for (i = 0; i < ARRAY_SIZE(regs); i++) {
206
@@ -XXX,XX +XXX,XX @@ int kvm_arch_get_registers(CPUState *cs)
207
memcpy(env->regs + 8, env->usr_regs, 5 * sizeof(uint32_t));
208
}
209
env->regs[13] = env->banked_r13[bn];
210
- env->regs[14] = env->banked_r14[bn];
211
env->spsr = env->banked_spsr[bn];
212
+ env->regs[14] = env->banked_r14[r14_bank_number(mode)];
213
214
/* VFP registers */
215
r.id = KVM_REG_ARM | KVM_REG_SIZE_U64 | KVM_REG_ARM_VFP;
216
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
217
index XXXXXXX..XXXXXXX 100644
218
--- a/target/arm/op_helper.c
219
+++ b/target/arm/op_helper.c
220
@@ -XXX,XX +XXX,XX @@ void HELPER(msr_banked)(CPUARMState *env, uint32_t value, uint32_t tgtmode,
221
env->banked_r13[bank_number(tgtmode)] = value;
222
break;
223
case 14:
224
- env->banked_r14[bank_number(tgtmode)] = value;
225
+ env->banked_r14[r14_bank_number(tgtmode)] = value;
226
break;
227
case 8 ... 12:
228
switch (tgtmode) {
229
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(mrs_banked)(CPUARMState *env, uint32_t tgtmode, uint32_t regno)
230
case 13:
231
return env->banked_r13[bank_number(tgtmode)];
232
case 14:
233
- return env->banked_r14[bank_number(tgtmode)];
234
+ return env->banked_r14[r14_bank_number(tgtmode)];
235
case 8 ... 12:
236
switch (tgtmode) {
237
case ARM_CPU_MODE_USR:
238
--
77
--
239
2.19.1
78
2.20.1
240
79
241
80
diff view generated by jsdifflib
1
Before we supported direct execution from MMIO regions, we
1
In commit 5edab03d4040 we added tracepoints to the ps2 keyboard
2
implemented workarounds in commit 720424359917887c926a33d2
2
and mouse emulation. However we didn't remove all the debug-by-printf
3
which let us avoid doing so, even if the SAU or MPU region
3
support. In fact there is only one printf() remaining, and it is
4
was less than page-sized.
4
redundant with the trace_ps2_write_mouse() event next to it.
5
5
Remove the printf() and the now-unused DEBUG* macros.
6
Once we implemented execute-from-MMIO, we removed part
7
of those workarounds in commit d4b6275df320cee76; but
8
we forgot the one in get_phys_addr_pmsav8() which
9
suppressed use of small SAU regions in executable regions.
10
Remove that workaround now.
11
6
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
15
Message-id: 20181106163801.14474-1-peter.maydell@linaro.org
10
Message-id: 20201101133258.4240-1-peter.maydell@linaro.org
16
---
11
---
17
target/arm/helper.c | 12 ------------
12
hw/input/ps2.c | 9 ---------
18
1 file changed, 12 deletions(-)
13
1 file changed, 9 deletions(-)
19
14
20
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
21
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/helper.c
17
--- a/hw/input/ps2.c
23
+++ b/target/arm/helper.c
18
+++ b/hw/input/ps2.c
24
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav8(CPUARMState *env, uint32_t address,
19
@@ -XXX,XX +XXX,XX @@
25
20
26
ret = pmsav8_mpu_lookup(env, address, access_type, mmu_idx, phys_ptr,
21
#include "trace.h"
27
txattrs, prot, &mpu_is_subpage, fi, NULL);
22
28
- /*
23
-/* debug PC keyboard */
29
- * TODO: this is a temporary hack to ignore the fact that the SAU region
24
-//#define DEBUG_KBD
30
- * is smaller than a page if this is an executable region. We never
25
-
31
- * supported small MPU regions, but we did (accidentally) allow small
26
-/* debug PC keyboard : only mouse */
32
- * SAU regions, and if we now made small SAU regions not be executable
27
-//#define DEBUG_MOUSE
33
- * then this would break previously working guest code. We can't
28
-
34
- * remove this until/unless we implement support for execution from
29
/* Keyboard Commands */
35
- * small regions.
30
#define KBD_CMD_SET_LEDS    0xED    /* Set keyboard leds */
36
- */
31
#define KBD_CMD_ECHO     0xEE
37
- if (*prot & PAGE_EXEC) {
32
@@ -XXX,XX +XXX,XX @@ void ps2_write_mouse(void *opaque, int val)
38
- sattrs.subpage = false;
33
PS2MouseState *s = (PS2MouseState *)opaque;
39
- }
34
40
*page_size = sattrs.subpage || mpu_is_subpage ? 1 : TARGET_PAGE_SIZE;
35
trace_ps2_write_mouse(opaque, val);
41
return ret;
36
-#ifdef DEBUG_MOUSE
42
}
37
- printf("kbd: write mouse 0x%02x\n", val);
38
-#endif
39
switch(s->common.write_cmd) {
40
default:
41
case -1:
43
--
42
--
44
2.19.1
43
2.20.1
45
44
46
45
diff view generated by jsdifflib
1
The Cortex-A15 and Cortex-A7 both have EL2; now we've implemented
1
In the mtspr helper we attempt to check for "is the timer disabled"
2
it properly we can enable the feature bit.
2
with "if (env->ttmr & TIMER_NONE)". This is wrong because TIMER_NONE
3
is zero and the condition is always false (Coverity complains about
4
the dead code.)
3
5
6
The correct check would be to test whether the TTMR_M field in the
7
register is equal to TIMER_NONE instead. However, the
8
cpu_openrisc_timer_update() function checks whether the timer is
9
enabled (it looks at cpu->env.is_counting, which is set to 0 via
10
cpu_openrisc_count_stop() when the TTMR_M field is set to
11
TIMER_NONE), so there's no need to check for "timer disabled" in the
12
target/openrisc code. Instead, simply remove the dead code.
13
14
Fixes: Coverity CID 1005812
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
16
Acked-by: Stafford Horne <shorne@gmail.com>
6
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
17
Message-id: 20201103114654.18540-1-peter.maydell@linaro.org
7
Message-id: 20181109173553.22341-3-peter.maydell@linaro.org
8
---
18
---
9
target/arm/cpu.c | 2 ++
19
target/openrisc/sys_helper.c | 3 ---
10
1 file changed, 2 insertions(+)
20
1 file changed, 3 deletions(-)
11
21
12
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
22
diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c
13
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/cpu.c
24
--- a/target/openrisc/sys_helper.c
15
+++ b/target/arm/cpu.c
25
+++ b/target/openrisc/sys_helper.c
16
@@ -XXX,XX +XXX,XX @@ static void cortex_a7_initfn(Object *obj)
26
@@ -XXX,XX +XXX,XX @@ void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb)
17
set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
27
18
set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
28
case TO_SPR(10, 1): /* TTCR */
19
set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
29
cpu_openrisc_count_set(cpu, rb);
20
+ set_feature(&cpu->env, ARM_FEATURE_EL2);
30
- if (env->ttmr & TIMER_NONE) {
21
set_feature(&cpu->env, ARM_FEATURE_EL3);
31
- return;
22
cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A7;
32
- }
23
cpu->midr = 0x410fc075;
33
cpu_openrisc_timer_update(cpu);
24
@@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj)
34
break;
25
set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
35
#endif
26
set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS);
27
set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
28
+ set_feature(&cpu->env, ARM_FEATURE_EL2);
29
set_feature(&cpu->env, ARM_FEATURE_EL3);
30
cpu->kvm_target = QEMU_KVM_ARM_TARGET_CORTEX_A15;
31
cpu->midr = 0x412fc0f1;
32
--
36
--
33
2.19.1
37
2.20.1
34
38
35
39
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Alistair Francis <alistair.francis@wdc.com>
2
2
3
This would cause an infinite recursion or loop.
3
This patch fixes CID 1432800 by removing an unnecessary check.
4
4
5
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
5
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
6
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
8
Message-id: 20181110121711.15257-1-richard.henderson@linaro.org
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
8
---
12
target/arm/helper.c | 2 +-
9
hw/core/register.c | 4 ----
13
1 file changed, 1 insertion(+), 1 deletion(-)
10
1 file changed, 4 deletions(-)
14
11
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
12
diff --git a/hw/core/register.c b/hw/core/register.c
16
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
14
--- a/hw/core/register.c
18
+++ b/target/arm/helper.c
15
+++ b/hw/core/register.c
19
@@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vmalle1_write(CPUARMState *env, const ARMCPRegInfo *ri,
16
@@ -XXX,XX +XXX,XX @@ static RegisterInfoArray *register_init_block(DeviceState *owner,
20
CPUState *cs = ENV_GET_CPU(env);
17
int index = rae[i].addr / data_size;
21
18
RegisterInfo *r = &ri[index];
22
if (tlb_force_broadcast(env)) {
19
23
- tlbi_aa64_vmalle1_write(env, NULL, value);
20
- if (data + data_size * index == 0 || !&rae[i]) {
24
+ tlbi_aa64_vmalle1is_write(env, NULL, value);
21
- continue;
25
return;
22
- }
26
}
23
-
24
/* Init the register, this will zero it. */
25
object_initialize((void *)r, sizeof(*r), TYPE_REGISTER);
27
26
28
--
27
--
29
2.19.1
28
2.20.1
30
29
31
30
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Fix the assertion failure when running interrupts.
3
Fix Coverity CID 1435957: Memory - illegal accesses (OVERRUN):
4
4
5
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
5
>>> Overrunning array "suffixes" of 7 8-byte elements at element
6
index 7 (byte offset 63) using index "idx" (which evaluates to 7).
7
8
Note, the biggest input value freq_to_str() can accept is UINT64_MAX,
9
which is ~18.446 EHz, less than 1000 EHz.
10
11
Reported-by: Eduardo Habkost <ehabkost@redhat.com>
12
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
8
Message-id: 20181109152119.9242-3-alex.bennee@linaro.org
15
Reviewed-by: Luc Michel <luc@lmichel.fr>
16
Message-id: 20201101215755.2021421-1-f4bug@amsat.org
17
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
20
---
11
target/arm/kvm64.c | 2 ++
21
util/cutils.c | 3 ++-
12
1 file changed, 2 insertions(+)
22
1 file changed, 2 insertions(+), 1 deletion(-)
13
23
14
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
24
diff --git a/util/cutils.c b/util/cutils.c
15
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/kvm64.c
26
--- a/util/cutils.c
17
+++ b/target/arm/kvm64.c
27
+++ b/util/cutils.c
18
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit)
28
@@ -XXX,XX +XXX,XX @@ char *freq_to_str(uint64_t freq_hz)
19
cs->exception_index = EXCP_BKPT;
29
double freq = freq_hz;
20
env->exception.syndrome = debug_exit->hsr;
30
size_t idx = 0;
21
env->exception.vaddress = debug_exit->far;
31
22
+ qemu_mutex_lock_iothread();
32
- while (freq >= 1000.0 && idx < ARRAY_SIZE(suffixes)) {
23
cc->do_interrupt(cs);
33
+ while (freq >= 1000.0) {
24
+ qemu_mutex_unlock_iothread();
34
freq /= 1000.0;
25
35
idx++;
26
return false;
36
}
37
+ assert(idx < ARRAY_SIZE(suffixes));
38
39
return g_strdup_printf("%0.3g %sHz", freq, suffixes[idx]);
27
}
40
}
28
--
41
--
29
2.19.1
42
2.20.1
30
43
31
44
diff view generated by jsdifflib
1
Remove a TODO comment about implementing the vectored interrupt
1
In commit 76346b6264a9b01979 we tried to add a configure check that
2
controller. We have had an implementation of that for a decade;
2
the libgio pkg-config data was correct, which builds an executable
3
it's in hw/intc/pl190.c.
3
linked against it. Unfortunately this doesn't catch the problem
4
(missing static library dependency info), because a "do nothing" test
5
source file doesn't have any symbol references that cause the linker
6
to pull in .o files from libgio.a, and so we don't see the "missing
7
symbols from libmount" error that a full QEMU link triggers.
8
9
(The ineffective test went unnoticed because of a typo that
10
effectively disabled libgio unconditionally, but after commit
11
3569a5dfc11f2 fixed that, a static link of the system emulator on
12
Ubuntu stopped working again.)
13
14
Improve the gio test by having the test source fragment reference a
15
g_dbus function (which is what is indirectly causing us to end up
16
wanting functions from libmount).
4
17
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
19
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
7
Message-id: 20181106164118.16184-1-peter.maydell@linaro.org
20
Message-id: 20201116104617.18333-1-peter.maydell@linaro.org
8
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
10
---
21
---
11
target/arm/helper.c | 1 -
22
configure | 11 +++++++++--
12
1 file changed, 1 deletion(-)
23
1 file changed, 9 insertions(+), 2 deletions(-)
13
24
14
diff --git a/target/arm/helper.c b/target/arm/helper.c
25
diff --git a/configure b/configure
15
index XXXXXXX..XXXXXXX 100644
26
index XXXXXXX..XXXXXXX 100755
16
--- a/target/arm/helper.c
27
--- a/configure
17
+++ b/target/arm/helper.c
28
+++ b/configure
18
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
29
@@ -XXX,XX +XXX,XX @@ if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
19
return;
30
# Check that the libraries actually work -- Ubuntu 18.04 ships
20
}
31
# with pkg-config --static --libs data for gio-2.0 that is missing
21
32
# -lblkid and will give a link error.
22
- /* TODO: Vectored interrupt controller. */
33
- write_c_skeleton
23
switch (cs->exception_index) {
34
- if compile_prog "" "$gio_libs" ; then
24
case EXCP_UDEF:
35
+ cat > $TMPC <<EOF
25
new_mode = ARM_CPU_MODE_UND;
36
+#include <gio/gio.h>
37
+int main(void)
38
+{
39
+ g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
40
+ return 0;
41
+}
42
+EOF
43
+ if compile_prog "$gio_cflags" "$gio_libs" ; then
44
gio=yes
45
else
46
gio=no
26
--
47
--
27
2.19.1
48
2.20.1
28
49
29
50
diff view generated by jsdifflib
Deleted patch
1
From: Thomas Huth <thuth@redhat.com>
2
1
3
There is no active maintainer, but since Peter is picking up
4
patches via qemu-arm@nongnu.org, I think we could at least use
5
"Odd Fixes" as status here.
6
7
Signed-off-by: Thomas Huth <thuth@redhat.com>
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
9
Message-id: 1541528230-31817-1-git-send-email-thuth@redhat.com
10
[PMM: Also add myself as an M: contact]
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
MAINTAINERS | 7 +++++++
14
1 file changed, 7 insertions(+)
15
16
diff --git a/MAINTAINERS b/MAINTAINERS
17
index XXXXXXX..XXXXXXX 100644
18
--- a/MAINTAINERS
19
+++ b/MAINTAINERS
20
@@ -XXX,XX +XXX,XX @@ F: hw/*/pxa2xx*
21
F: hw/misc/mst_fpga.c
22
F: include/hw/arm/pxa.h
23
24
+Sharp SL-5500 (Collie) PDA
25
+M: Peter Maydell <peter.maydell@linaro.org>
26
+L: qemu-arm@nongnu.org
27
+S: Odd Fixes
28
+F: hw/arm/collie.c
29
+F: hw/arm/strongarm*
30
+
31
Stellaris
32
M: Peter Maydell <peter.maydell@linaro.org>
33
L: qemu-arm@nongnu.org
34
--
35
2.19.1
36
37
diff view generated by jsdifflib
Deleted patch
1
From: Eric Auger <eric.auger@redhat.com>
2
1
3
Commit af7d64ede0b9 (hw/arm/sysbus-fdt: Allow device matching with DT
4
compatible value) introduced a match_fn callback which gets called
5
for each registered combo to check whether a sysbus device can be
6
dynamically instantiated. However the callback gets called even if
7
the device type does not match the binding combo typename field.
8
This causes an assert when passing "-device ramfb" to the qemu
9
command line as vfio_platform_match() gets called on a non
10
vfio-platform device.
11
12
To fix this regression, let's change the add_fdt_node() logic so
13
that we first check the type and if the match_fn callback is defined,
14
then we also call it.
15
16
Binding combos only requesting a type check do not define the
17
match_fn callback.
18
19
Fixes: af7d64ede0b9 (hw/arm/sysbus-fdt: Allow device matching with
20
DT compatible value)
21
22
Signed-off-by: Eric Auger <eric.auger@redhat.com>
23
Reported-by: Thomas Huth <thuth@redhat.com>
24
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
25
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
26
Message-id: 20181106184212.29377-1-eric.auger@redhat.com
27
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
28
---
29
hw/arm/sysbus-fdt.c | 12 +++++++-----
30
1 file changed, 7 insertions(+), 5 deletions(-)
31
32
diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c
33
index XXXXXXX..XXXXXXX 100644
34
--- a/hw/arm/sysbus-fdt.c
35
+++ b/hw/arm/sysbus-fdt.c
36
@@ -XXX,XX +XXX,XX @@ static bool type_match(SysBusDevice *sbdev, const BindingEntry *entry)
37
return !strcmp(object_get_typename(OBJECT(sbdev)), entry->typename);
38
}
39
40
-#define TYPE_BINDING(type, add_fn) {(type), NULL, (add_fn), type_match}
41
+#define TYPE_BINDING(type, add_fn) {(type), NULL, (add_fn), NULL}
42
43
/* list of supported dynamic sysbus bindings */
44
static const BindingEntry bindings[] = {
45
@@ -XXX,XX +XXX,XX @@ static void add_fdt_node(SysBusDevice *sbdev, void *opaque)
46
for (i = 0; i < ARRAY_SIZE(bindings); i++) {
47
const BindingEntry *iter = &bindings[i];
48
49
- if (iter->match_fn(sbdev, iter)) {
50
- ret = iter->add_fn(sbdev, opaque);
51
- assert(!ret);
52
- return;
53
+ if (type_match(sbdev, iter)) {
54
+ if (!iter->match_fn || iter->match_fn(sbdev, iter)) {
55
+ ret = iter->add_fn(sbdev, opaque);
56
+ assert(!ret);
57
+ return;
58
+ }
59
}
60
}
61
error_report("Device %s can not be dynamically instantiated",
62
--
63
2.19.1
64
65
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
This only fails with some (broken) versions of gdb but we should
4
treat the top bits of DBGBVR as RESS. Properly sign extend QEMU's
5
reference copy of dbgbvr and also update the register descriptions in
6
the comment.
7
8
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Message-id: 20181109152119.9242-2-alex.bennee@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
target/arm/kvm64.c | 17 +++++++++++++++--
14
1 file changed, 15 insertions(+), 2 deletions(-)
15
16
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
17
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/kvm64.c
19
+++ b/target/arm/kvm64.c
20
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_init_debug(CPUState *cs)
21
* capable of fancier matching but that will require exposing that
22
* fanciness to GDB's interface
23
*
24
- * D7.3.2 DBGBCR<n>_EL1, Debug Breakpoint Control Registers
25
+ * DBGBCR<n>_EL1, Debug Breakpoint Control Registers
26
*
27
* 31 24 23 20 19 16 15 14 13 12 9 8 5 4 3 2 1 0
28
* +------+------+-------+-----+----+------+-----+------+-----+---+
29
@@ -XXX,XX +XXX,XX @@ static void kvm_arm_init_debug(CPUState *cs)
30
* SSC/HMC/PMC: Security, Higher and Priv access control (Table D-12)
31
* BAS: Byte Address Select (RES1 for AArch64)
32
* E: Enable bit
33
+ *
34
+ * DBGBVR<n>_EL1, Debug Breakpoint Value Registers
35
+ *
36
+ * 63 53 52 49 48 2 1 0
37
+ * +------+-----------+----------+-----+
38
+ * | RESS | VA[52:49] | VA[48:2] | 0 0 |
39
+ * +------+-----------+----------+-----+
40
+ *
41
+ * Depending on the addressing mode bits the top bits of the register
42
+ * are a sign extension of the highest applicable VA bit. Some
43
+ * versions of GDB don't do it correctly so we ensure they are correct
44
+ * here so future PC comparisons will work properly.
45
*/
46
+
47
static int insert_hw_breakpoint(target_ulong addr)
48
{
49
HWBreakpoint brk = {
50
.bcr = 0x1, /* BCR E=1, enable */
51
- .bvr = addr
52
+ .bvr = sextract64(addr, 0, 53)
53
};
54
55
if (cur_hw_bps >= max_hw_bps) {
56
--
57
2.19.1
58
59
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
When we are debugging the guest all exceptions come our way but might
4
be for the guest's own debug exceptions. We use the ->do_interrupt()
5
infrastructure to inject the exception into the guest. However, we are
6
missing a full setup of the exception structure, causing an assert
7
later down the line.
8
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Message-id: 20181109152119.9242-4-alex.bennee@linaro.org
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
15
target/arm/kvm64.c | 1 +
16
1 file changed, 1 insertion(+)
17
18
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
19
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/kvm64.c
21
+++ b/target/arm/kvm64.c
22
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_exit)
23
cs->exception_index = EXCP_BKPT;
24
env->exception.syndrome = debug_exit->hsr;
25
env->exception.vaddress = debug_exit->far;
26
+ env->exception.target_el = 1;
27
qemu_mutex_lock_iothread();
28
cc->do_interrupt(cs);
29
qemu_mutex_unlock_iothread();
30
--
31
2.19.1
32
33
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
We already have this symbol defined so lets use it.
4
5
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20181109152119.9242-7-alex.bennee@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
target/arm/cpu.h | 2 +-
11
1 file changed, 1 insertion(+), 1 deletion(-)
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 @@ static inline int arm_debug_target_el(CPUARMState *env)
18
19
if (arm_feature(env, ARM_FEATURE_EL2) && !secure) {
20
route_to_el2 = env->cp15.hcr_el2 & HCR_TGE ||
21
- env->cp15.mdcr_el2 & (1 << 8);
22
+ env->cp15.mdcr_el2 & MDCR_TDE;
23
}
24
25
if (route_to_el2) {
26
--
27
2.19.1
28
29
diff view generated by jsdifflib
Deleted patch
1
From: Alex Bennée <alex.bennee@linaro.org>
2
1
3
The test was incomplete and incorrectly caused debug exceptions to be
4
generated when returning to EL2 after a failed attempt to single-step
5
an EL1 instruction. Fix this while cleaning up the function a little.
6
7
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20181109152119.9242-8-alex.bennee@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
target/arm/cpu.h | 39 ++++++++++++++++++++++++---------------
13
1 file changed, 24 insertions(+), 15 deletions(-)
14
15
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
16
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/cpu.h
18
+++ b/target/arm/cpu.h
19
@@ -XXX,XX +XXX,XX @@ static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu)
20
return (cpu->clidr & R_V7M_CLIDR_CTYPE_ALL_MASK) != 0;
21
}
22
23
+/* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */
24
static inline bool aa64_generate_debug_exceptions(CPUARMState *env)
25
{
26
- if (arm_is_secure(env)) {
27
- /* MDCR_EL3.SDD disables debug events from Secure state */
28
- if (extract32(env->cp15.mdcr_el3, 16, 1) != 0
29
- || arm_current_el(env) == 3) {
30
- return false;
31
- }
32
+ int cur_el = arm_current_el(env);
33
+ int debug_el;
34
+
35
+ if (cur_el == 3) {
36
+ return false;
37
}
38
39
- if (arm_current_el(env) == arm_debug_target_el(env)) {
40
- if ((extract32(env->cp15.mdscr_el1, 13, 1) == 0)
41
- || (env->daif & PSTATE_D)) {
42
- return false;
43
- }
44
+ /* MDCR_EL3.SDD disables debug events from Secure state */
45
+ if (arm_is_secure_below_el3(env)
46
+ && extract32(env->cp15.mdcr_el3, 16, 1)) {
47
+ return false;
48
}
49
- return true;
50
+
51
+ /*
52
+ * Same EL to same EL debug exceptions need MDSCR_KDE enabled
53
+ * while not masking the (D)ebug bit in DAIF.
54
+ */
55
+ debug_el = arm_debug_target_el(env);
56
+
57
+ if (cur_el == debug_el) {
58
+ return extract32(env->cp15.mdscr_el1, 13, 1)
59
+ && !(env->daif & PSTATE_D);
60
+ }
61
+
62
+ /* Otherwise the debug target needs to be a higher EL */
63
+ return debug_el > cur_el;
64
}
65
66
static inline bool aa32_generate_debug_exceptions(CPUARMState *env)
67
@@ -XXX,XX +XXX,XX @@ static inline bool aa32_generate_debug_exceptions(CPUARMState *env)
68
* since the pseudocode has it at all callsites except for the one in
69
* CheckSoftwareStep(), where it is elided because both branches would
70
* always return the same value.
71
- *
72
- * Parts of the pseudocode relating to EL2 and EL3 are omitted because we
73
- * don't yet implement those exception levels or their associated trap bits.
74
*/
75
static inline bool arm_generate_debug_exceptions(CPUARMState *env)
76
{
77
--
78
2.19.1
79
80
diff view generated by jsdifflib
1
This reverts commit 8a0fc3a29fc2315325400c738f807d0d4ae0ab7f.
1
The TMP105 datasheet (https://www.ti.com/lit/gpn/tmp105) says that the
2
power-up reset values for the T_low and T_high registers are 80 degrees C
3
and 75 degrees C, which are 0x500 and 0x4B0 hex according to table 5. These
4
values are then shifted right by four bits to give the register reset
5
values, since both registers store the 12 bits of temperature data in bits
6
[15..4] of a 16 bit register.
2
7
3
The implementation of HCR.VI and VF in that commit is not
8
We were resetting these registers to zero, which is problematic for Linux
4
correct -- they do not track the overall "is there a pending
9
guests which enable the alert interrupt and then immediately take an
5
VIRQ or VFIQ" status, but whether there is a pending interrupt
10
unexpected overtemperature alert because the current temperature is above
6
due to "this mechanism", ie the hypervisor having set the VI/VF
11
freezing...
7
bits. The overall pending state for VIRQ and VFIQ is effectively
8
the logical OR of the inbound lines from the GIC with the
9
VI and VF bits. Commit 8a0fc3a29fc231 would result in pending
10
VIRQ/VFIQ possibly being lost when the hypervisor wrote to HCR.
11
12
As a preliminary to implementing the HCR.VI/VF feature properly,
13
revert the broken one entirely.
14
12
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
14
Reviewed-by: Cédric Le Goater <clg@kaod.org>
17
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
15
Message-id: 20201110150023.25533-2-peter.maydell@linaro.org
18
Message-id: 20181109134731.11605-2-peter.maydell@linaro.org
19
---
16
---
20
target/arm/helper.c | 47 ++++-----------------------------------------
17
hw/misc/tmp105.c | 3 +++
21
1 file changed, 4 insertions(+), 43 deletions(-)
18
1 file changed, 3 insertions(+)
22
19
23
diff --git a/target/arm/helper.c b/target/arm/helper.c
20
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
24
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
25
--- a/target/arm/helper.c
22
--- a/hw/misc/tmp105.c
26
+++ b/target/arm/helper.c
23
+++ b/hw/misc/tmp105.c
27
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el3_no_el2_v8_cp_reginfo[] = {
24
@@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c)
28
static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
25
s->faults = tmp105_faultq[(s->config >> 3) & 3];
29
{
26
s->alarm = 0;
30
ARMCPU *cpu = arm_env_get_cpu(env);
27
31
- CPUState *cs = ENV_GET_CPU(env);
28
+ s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */
32
uint64_t valid_mask = HCR_MASK;
29
+ s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */
33
30
+
34
if (arm_feature(env, ARM_FEATURE_EL3)) {
31
tmp105_interrupt_update(s);
35
@@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
36
/* Clear RES0 bits. */
37
value &= valid_mask;
38
39
- /*
40
- * VI and VF are kept in cs->interrupt_request. Modifying that
41
- * requires that we have the iothread lock, which is done by
42
- * marking the reginfo structs as ARM_CP_IO.
43
- * Note that if a write to HCR pends a VIRQ or VFIQ it is never
44
- * possible for it to be taken immediately, because VIRQ and
45
- * VFIQ are masked unless running at EL0 or EL1, and HCR
46
- * can only be written at EL2.
47
- */
48
- g_assert(qemu_mutex_iothread_locked());
49
- if (value & HCR_VI) {
50
- cs->interrupt_request |= CPU_INTERRUPT_VIRQ;
51
- } else {
52
- cs->interrupt_request &= ~CPU_INTERRUPT_VIRQ;
53
- }
54
- if (value & HCR_VF) {
55
- cs->interrupt_request |= CPU_INTERRUPT_VFIQ;
56
- } else {
57
- cs->interrupt_request &= ~CPU_INTERRUPT_VFIQ;
58
- }
59
- value &= ~(HCR_VI | HCR_VF);
60
-
61
/* These bits change the MMU setup:
62
* HCR_VM enables stage 2 translation
63
* HCR_PTW forbids certain page-table setups
64
@@ -XXX,XX +XXX,XX @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri,
65
hcr_write(env, NULL, value);
66
}
32
}
67
33
68
-static uint64_t hcr_read(CPUARMState *env, const ARMCPRegInfo *ri)
69
-{
70
- /* The VI and VF bits live in cs->interrupt_request */
71
- uint64_t ret = env->cp15.hcr_el2 & ~(HCR_VI | HCR_VF);
72
- CPUState *cs = ENV_GET_CPU(env);
73
-
74
- if (cs->interrupt_request & CPU_INTERRUPT_VIRQ) {
75
- ret |= HCR_VI;
76
- }
77
- if (cs->interrupt_request & CPU_INTERRUPT_VFIQ) {
78
- ret |= HCR_VF;
79
- }
80
- return ret;
81
-}
82
-
83
static const ARMCPRegInfo el2_cp_reginfo[] = {
84
{ .name = "HCR_EL2", .state = ARM_CP_STATE_AA64,
85
- .type = ARM_CP_IO,
86
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
87
.access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2),
88
- .writefn = hcr_write, .readfn = hcr_read },
89
+ .writefn = hcr_write },
90
{ .name = "HCR", .state = ARM_CP_STATE_AA32,
91
- .type = ARM_CP_ALIAS | ARM_CP_IO,
92
+ .type = ARM_CP_ALIAS,
93
.cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
94
.access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2),
95
- .writefn = hcr_writelow, .readfn = hcr_read },
96
+ .writefn = hcr_writelow },
97
{ .name = "ELR_EL2", .state = ARM_CP_STATE_AA64,
98
.type = ARM_CP_ALIAS,
99
.opc0 = 3, .opc1 = 4, .crn = 4, .crm = 0, .opc2 = 1,
100
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
101
102
static const ARMCPRegInfo el2_v8_cp_reginfo[] = {
103
{ .name = "HCR2", .state = ARM_CP_STATE_AA32,
104
- .type = ARM_CP_ALIAS | ARM_CP_IO,
105
+ .type = ARM_CP_ALIAS,
106
.cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4,
107
.access = PL2_RW,
108
.fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2),
109
--
34
--
110
2.19.1
35
2.20.1
111
36
112
37
diff view generated by jsdifflib
1
Currently we track the state of the four irq lines from the GIC
1
The TMP105 datasheet says that in Interrupt Mode (when TM==1) the device
2
only via the cs->interrupt_request or KVM irq state. That means
2
signals an alert when the temperature equals or exceeds the T_high value and
3
that we assume that an interrupt is asserted if and only if the
3
then remains high until a device register is read or the device responds to
4
external line is set. This assumption is incorrect for VIRQ
4
the SMBUS Alert Response address, or the device is put into Shutdown Mode.
5
and VFIQ, because the HCR_EL2.{VI,VF} bits allow assertion
5
Thereafter the Alert pin will only be re-signalled when temperature falls
6
of VIRQ and VFIQ separately from the state of the external line.
6
below T_low; alert can then be cleared in the same set of ways, and the
7
device returns to its initial "alert when temperature goes above T_high"
8
mode. (If this textual description is confusing, see figure 3 in the
9
TI datasheet at https://www.ti.com/lit/gpn/tmp105 .)
7
10
8
To handle this, start tracking the state of the external lines
11
We were misimplementing this as a simple "always alert if temperature is
9
explicitly in a CPU state struct field, as is common practice
12
above T_high or below T_low" condition, which gives a spurious alert on
10
for devices.
13
startup if using the "T_high = 80 degrees C, T_low = 75 degrees C" reset
14
limit values.
11
15
12
The complicated part of this is dealing with inbound migration
16
Implement the correct (hysteresis) behaviour by tracking whether we
13
from an older QEMU which didn't have this state. We assume in
17
are currently looking for the temperature to rise over T_high or
14
that case that the older QEMU did not implement the HCR_EL2.{VI,VF}
18
for it to fall below T_low. Our implementation of the comparator
15
bits as generating interrupts, and so the line state matches
19
mode (TM==0) wasn't wrong, but rephrase it to match the way that
16
the current state in cs->interrupt_request. (This is not quite
20
interrupt mode is now handled for clarity.
17
true between commit 8a0fc3a29fc2315325400c7 and its revert, but
18
that commit is broken and never made it into any released QEMU
19
version.)
20
21
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
23
Reviewed-by: Cédric Le Goater <clg@kaod.org>
23
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
24
Message-id: 20201110150023.25533-3-peter.maydell@linaro.org
24
Message-id: 20181109134731.11605-3-peter.maydell@linaro.org
25
---
25
---
26
target/arm/cpu.h | 3 +++
26
hw/misc/tmp105.h | 7 +++++
27
target/arm/cpu.c | 16 ++++++++++++++
27
hw/misc/tmp105.c | 70 +++++++++++++++++++++++++++++++++++++++++-------
28
target/arm/machine.c | 51 ++++++++++++++++++++++++++++++++++++++++++++
28
2 files changed, 68 insertions(+), 9 deletions(-)
29
3 files changed, 70 insertions(+)
30
29
31
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
30
diff --git a/hw/misc/tmp105.h b/hw/misc/tmp105.h
32
index XXXXXXX..XXXXXXX 100644
31
index XXXXXXX..XXXXXXX 100644
33
--- a/target/arm/cpu.h
32
--- a/hw/misc/tmp105.h
34
+++ b/target/arm/cpu.h
33
+++ b/hw/misc/tmp105.h
35
@@ -XXX,XX +XXX,XX @@ typedef struct CPUARMState {
34
@@ -XXX,XX +XXX,XX @@ struct TMP105State {
36
uint64_t esr;
35
int16_t limit[2];
37
} serror;
36
int faults;
38
37
uint8_t alarm;
39
+ /* State of our input IRQ/FIQ/VIRQ/VFIQ lines */
38
+ /*
40
+ uint32_t irq_line_state;
39
+ * The TMP105 initially looks for a temperature rising above T_high;
40
+ * once this is detected, the condition it looks for next is the
41
+ * temperature falling below T_low. This flag is false when initially
42
+ * looking for T_high, true when looking for T_low.
43
+ */
44
+ bool detect_falling;
45
};
46
47
#endif
48
diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/misc/tmp105.c
51
+++ b/hw/misc/tmp105.c
52
@@ -XXX,XX +XXX,XX @@ static void tmp105_alarm_update(TMP105State *s)
53
return;
54
}
55
56
- if ((s->config >> 1) & 1) {                    /* TM */
57
- if (s->temperature >= s->limit[1])
58
- s->alarm = 1;
59
- else if (s->temperature < s->limit[0])
60
- s->alarm = 1;
61
+ if (s->config >> 1 & 1) {
62
+ /*
63
+ * TM == 1 : Interrupt mode. We signal Alert when the
64
+ * temperature rises above T_high, and expect the guest to clear
65
+ * it (eg by reading a device register).
66
+ */
67
+ if (s->detect_falling) {
68
+ if (s->temperature < s->limit[0]) {
69
+ s->alarm = 1;
70
+ s->detect_falling = false;
71
+ }
72
+ } else {
73
+ if (s->temperature >= s->limit[1]) {
74
+ s->alarm = 1;
75
+ s->detect_falling = true;
76
+ }
77
+ }
78
} else {
79
- if (s->temperature >= s->limit[1])
80
- s->alarm = 1;
81
- else if (s->temperature < s->limit[0])
82
- s->alarm = 0;
83
+ /*
84
+ * TM == 0 : Comparator mode. We signal Alert when the temperature
85
+ * rises above T_high, and stop signalling it when the temperature
86
+ * falls below T_low.
87
+ */
88
+ if (s->detect_falling) {
89
+ if (s->temperature < s->limit[0]) {
90
+ s->alarm = 0;
91
+ s->detect_falling = false;
92
+ }
93
+ } else {
94
+ if (s->temperature >= s->limit[1]) {
95
+ s->alarm = 1;
96
+ s->detect_falling = true;
97
+ }
98
+ }
99
}
100
101
tmp105_interrupt_update(s);
102
@@ -XXX,XX +XXX,XX @@ static int tmp105_post_load(void *opaque, int version_id)
103
return 0;
104
}
105
106
+static bool detect_falling_needed(void *opaque)
107
+{
108
+ TMP105State *s = opaque;
41
+
109
+
42
/* Thumb-2 EE state. */
110
+ /*
43
uint32_t teecr;
111
+ * We only need to migrate the detect_falling bool if it's set;
44
uint32_t teehbr;
112
+ * for migration from older machines we assume that it is false
45
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
113
+ * (ie temperature is not out of range).
46
index XXXXXXX..XXXXXXX 100644
114
+ */
47
--- a/target/arm/cpu.c
115
+ return s->detect_falling;
48
+++ b/target/arm/cpu.c
49
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level)
50
[ARM_CPU_VFIQ] = CPU_INTERRUPT_VFIQ
51
};
52
53
+ if (level) {
54
+ env->irq_line_state |= mask[irq];
55
+ } else {
56
+ env->irq_line_state &= ~mask[irq];
57
+ }
58
+
59
switch (irq) {
60
case ARM_CPU_VIRQ:
61
case ARM_CPU_VFIQ:
62
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_kvm_set_irq(void *opaque, int irq, int level)
63
ARMCPU *cpu = opaque;
64
CPUState *cs = CPU(cpu);
65
int kvm_irq = KVM_ARM_IRQ_TYPE_CPU << KVM_ARM_IRQ_TYPE_SHIFT;
66
+ uint32_t linestate_bit;
67
68
switch (irq) {
69
case ARM_CPU_IRQ:
70
kvm_irq |= KVM_ARM_IRQ_CPU_IRQ;
71
+ linestate_bit = CPU_INTERRUPT_HARD;
72
break;
73
case ARM_CPU_FIQ:
74
kvm_irq |= KVM_ARM_IRQ_CPU_FIQ;
75
+ linestate_bit = CPU_INTERRUPT_FIQ;
76
break;
77
default:
78
g_assert_not_reached();
79
}
80
+
81
+ if (level) {
82
+ env->irq_line_state |= linestate_bit;
83
+ } else {
84
+ env->irq_line_state &= ~linestate_bit;
85
+ }
86
+
87
kvm_irq |= cs->cpu_index << KVM_ARM_IRQ_VCPU_SHIFT;
88
kvm_set_irq(kvm_state, kvm_irq, level ? 1 : 0);
89
#endif
90
diff --git a/target/arm/machine.c b/target/arm/machine.c
91
index XXXXXXX..XXXXXXX 100644
92
--- a/target/arm/machine.c
93
+++ b/target/arm/machine.c
94
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_serror = {
95
}
96
};
97
98
+static bool irq_line_state_needed(void *opaque)
99
+{
100
+ return true;
101
+}
116
+}
102
+
117
+
103
+static const VMStateDescription vmstate_irq_line_state = {
118
+static const VMStateDescription vmstate_tmp105_detect_falling = {
104
+ .name = "cpu/irq-line-state",
119
+ .name = "TMP105/detect-falling",
105
+ .version_id = 1,
120
+ .version_id = 1,
106
+ .minimum_version_id = 1,
121
+ .minimum_version_id = 1,
107
+ .needed = irq_line_state_needed,
122
+ .needed = detect_falling_needed,
108
+ .fields = (VMStateField[]) {
123
+ .fields = (VMStateField[]) {
109
+ VMSTATE_UINT32(env.irq_line_state, ARMCPU),
124
+ VMSTATE_BOOL(detect_falling, TMP105State),
110
+ VMSTATE_END_OF_LIST()
125
+ VMSTATE_END_OF_LIST()
111
+ }
126
+ }
112
+};
127
+};
113
+
128
+
114
static bool m_needed(void *opaque)
129
static const VMStateDescription vmstate_tmp105 = {
115
{
130
.name = "TMP105",
116
ARMCPU *cpu = opaque;
131
.version_id = 0,
117
@@ -XXX,XX +XXX,XX @@ static int cpu_pre_save(void *opaque)
132
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_tmp105 = {
118
return 0;
133
VMSTATE_UINT8(alarm, TMP105State),
119
}
134
VMSTATE_I2C_SLAVE(i2c, TMP105State),
120
135
VMSTATE_END_OF_LIST()
121
+static int cpu_pre_load(void *opaque)
136
+ },
122
+{
137
+ .subsections = (const VMStateDescription*[]) {
123
+ ARMCPU *cpu = opaque;
138
+ &vmstate_tmp105_detect_falling,
124
+ CPUARMState *env = &cpu->env;
139
+ NULL
125
+
126
+ /*
127
+ * Pre-initialize irq_line_state to a value that's never valid as
128
+ * real data, so cpu_post_load() can tell whether we've seen the
129
+ * irq-line-state subsection in the incoming migration state.
130
+ */
131
+ env->irq_line_state = UINT32_MAX;
132
+
133
+ return 0;
134
+}
135
+
136
static int cpu_post_load(void *opaque, int version_id)
137
{
138
ARMCPU *cpu = opaque;
139
+ CPUARMState *env = &cpu->env;
140
int i, v;
141
142
+ /*
143
+ * Handle migration compatibility from old QEMU which didn't
144
+ * send the irq-line-state subsection. A QEMU without it did not
145
+ * implement the HCR_EL2.{VI,VF} bits as generating interrupts,
146
+ * so for TCG the line state matches the bits set in cs->interrupt_request.
147
+ * For KVM the line state is not stored in cs->interrupt_request
148
+ * and so this will leave irq_line_state as 0, but this is OK because
149
+ * we only need to care about it for TCG.
150
+ */
151
+ if (env->irq_line_state == UINT32_MAX) {
152
+ CPUState *cs = CPU(cpu);
153
+
154
+ env->irq_line_state = cs->interrupt_request &
155
+ (CPU_INTERRUPT_HARD | CPU_INTERRUPT_FIQ |
156
+ CPU_INTERRUPT_VIRQ | CPU_INTERRUPT_VFIQ);
157
+ }
158
+
159
/* Update the values list from the incoming migration data.
160
* Anything in the incoming data which we don't know about is
161
* a migration failure; anything we know about but the incoming
162
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_arm_cpu = {
163
.version_id = 22,
164
.minimum_version_id = 22,
165
.pre_save = cpu_pre_save,
166
+ .pre_load = cpu_pre_load,
167
.post_load = cpu_post_load,
168
.fields = (VMStateField[]) {
169
VMSTATE_UINT32_ARRAY(env.regs, ARMCPU, 16),
170
@@ -XXX,XX +XXX,XX @@ const VMStateDescription vmstate_arm_cpu = {
171
&vmstate_sve,
172
#endif
173
&vmstate_serror,
174
+ &vmstate_irq_line_state,
175
NULL
176
}
140
}
177
};
141
};
142
143
@@ -XXX,XX +XXX,XX @@ static void tmp105_reset(I2CSlave *i2c)
144
s->config = 0;
145
s->faults = tmp105_faultq[(s->config >> 3) & 3];
146
s->alarm = 0;
147
+ s->detect_falling = false;
148
149
s->limit[0] = 0x4b00; /* T_LOW, 75 degrees C */
150
s->limit[1] = 0x5000; /* T_HIGH, 80 degrees C */
178
--
151
--
179
2.19.1
152
2.20.1
180
153
181
154
diff view generated by jsdifflib
Deleted patch
1
In commit 8a0fc3a29fc2315325400 we tried to implement HCR_EL2.{VI,VF},
2
but we got it wrong and had to revert it.
3
1
4
In that commit we implemented them as simply tracking whether there
5
is a pending virtual IRQ or virtual FIQ. This is not correct -- these
6
bits cause a software-generated VIRQ/VFIQ, which is distinct from
7
whether there is a hardware-generated VIRQ/VFIQ caused by the
8
external interrupt controller. So we need to track separately
9
the HCR_EL2 bit state and the external virq/vfiq line state, and
10
OR the two together to get the actual pending VIRQ/VFIQ state.
11
12
Fixes: 8a0fc3a29fc2315325400c738f807d0d4ae0ab7f
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
15
Message-id: 20181109134731.11605-4-peter.maydell@linaro.org
16
---
17
target/arm/internals.h | 18 ++++++++++++++++
18
target/arm/cpu.c | 48 +++++++++++++++++++++++++++++++++++++++++-
19
target/arm/helper.c | 20 ++++++++++++++++--
20
3 files changed, 83 insertions(+), 3 deletions(-)
21
22
diff --git a/target/arm/internals.h b/target/arm/internals.h
23
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/internals.h
25
+++ b/target/arm/internals.h
26
@@ -XXX,XX +XXX,XX @@ static inline const char *aarch32_mode_name(uint32_t psr)
27
return cpu_mode_names[psr & 0xf];
28
}
29
30
+/**
31
+ * arm_cpu_update_virq: Update CPU_INTERRUPT_VIRQ bit in cs->interrupt_request
32
+ *
33
+ * Update the CPU_INTERRUPT_VIRQ bit in cs->interrupt_request, following
34
+ * a change to either the input VIRQ line from the GIC or the HCR_EL2.VI bit.
35
+ * Must be called with the iothread lock held.
36
+ */
37
+void arm_cpu_update_virq(ARMCPU *cpu);
38
+
39
+/**
40
+ * arm_cpu_update_vfiq: Update CPU_INTERRUPT_VFIQ bit in cs->interrupt_request
41
+ *
42
+ * Update the CPU_INTERRUPT_VFIQ bit in cs->interrupt_request, following
43
+ * a change to either the input VFIQ line from the GIC or the HCR_EL2.VF bit.
44
+ * Must be called with the iothread lock held.
45
+ */
46
+void arm_cpu_update_vfiq(ARMCPU *cpu);
47
+
48
#endif
49
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
50
index XXXXXXX..XXXXXXX 100644
51
--- a/target/arm/cpu.c
52
+++ b/target/arm/cpu.c
53
@@ -XXX,XX +XXX,XX @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
54
}
55
#endif
56
57
+void arm_cpu_update_virq(ARMCPU *cpu)
58
+{
59
+ /*
60
+ * Update the interrupt level for VIRQ, which is the logical OR of
61
+ * the HCR_EL2.VI bit and the input line level from the GIC.
62
+ */
63
+ CPUARMState *env = &cpu->env;
64
+ CPUState *cs = CPU(cpu);
65
+
66
+ bool new_state = (env->cp15.hcr_el2 & HCR_VI) ||
67
+ (env->irq_line_state & CPU_INTERRUPT_VIRQ);
68
+
69
+ if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VIRQ) != 0)) {
70
+ if (new_state) {
71
+ cpu_interrupt(cs, CPU_INTERRUPT_VIRQ);
72
+ } else {
73
+ cpu_reset_interrupt(cs, CPU_INTERRUPT_VIRQ);
74
+ }
75
+ }
76
+}
77
+
78
+void arm_cpu_update_vfiq(ARMCPU *cpu)
79
+{
80
+ /*
81
+ * Update the interrupt level for VFIQ, which is the logical OR of
82
+ * the HCR_EL2.VF bit and the input line level from the GIC.
83
+ */
84
+ CPUARMState *env = &cpu->env;
85
+ CPUState *cs = CPU(cpu);
86
+
87
+ bool new_state = (env->cp15.hcr_el2 & HCR_VF) ||
88
+ (env->irq_line_state & CPU_INTERRUPT_VFIQ);
89
+
90
+ if (new_state != ((cs->interrupt_request & CPU_INTERRUPT_VFIQ) != 0)) {
91
+ if (new_state) {
92
+ cpu_interrupt(cs, CPU_INTERRUPT_VFIQ);
93
+ } else {
94
+ cpu_reset_interrupt(cs, CPU_INTERRUPT_VFIQ);
95
+ }
96
+ }
97
+}
98
+
99
#ifndef CONFIG_USER_ONLY
100
static void arm_cpu_set_irq(void *opaque, int irq, int level)
101
{
102
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_set_irq(void *opaque, int irq, int level)
103
104
switch (irq) {
105
case ARM_CPU_VIRQ:
106
+ assert(arm_feature(env, ARM_FEATURE_EL2));
107
+ arm_cpu_update_virq(cpu);
108
+ break;
109
case ARM_CPU_VFIQ:
110
assert(arm_feature(env, ARM_FEATURE_EL2));
111
- /* fall through */
112
+ arm_cpu_update_vfiq(cpu);
113
+ break;
114
case ARM_CPU_IRQ:
115
case ARM_CPU_FIQ:
116
if (level) {
117
diff --git a/target/arm/helper.c b/target/arm/helper.c
118
index XXXXXXX..XXXXXXX 100644
119
--- a/target/arm/helper.c
120
+++ b/target/arm/helper.c
121
@@ -XXX,XX +XXX,XX @@ static void hcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
122
tlb_flush(CPU(cpu));
123
}
124
env->cp15.hcr_el2 = value;
125
+
126
+ /*
127
+ * Updates to VI and VF require us to update the status of
128
+ * virtual interrupts, which are the logical OR of these bits
129
+ * and the state of the input lines from the GIC. (This requires
130
+ * that we have the iothread lock, which is done by marking the
131
+ * reginfo structs as ARM_CP_IO.)
132
+ * Note that if a write to HCR pends a VIRQ or VFIQ it is never
133
+ * possible for it to be taken immediately, because VIRQ and
134
+ * VFIQ are masked unless running at EL0 or EL1, and HCR
135
+ * can only be written at EL2.
136
+ */
137
+ g_assert(qemu_mutex_iothread_locked());
138
+ arm_cpu_update_virq(cpu);
139
+ arm_cpu_update_vfiq(cpu);
140
}
141
142
static void hcr_writehigh(CPUARMState *env, const ARMCPRegInfo *ri,
143
@@ -XXX,XX +XXX,XX @@ static void hcr_writelow(CPUARMState *env, const ARMCPRegInfo *ri,
144
145
static const ARMCPRegInfo el2_cp_reginfo[] = {
146
{ .name = "HCR_EL2", .state = ARM_CP_STATE_AA64,
147
+ .type = ARM_CP_IO,
148
.opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
149
.access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2),
150
.writefn = hcr_write },
151
{ .name = "HCR", .state = ARM_CP_STATE_AA32,
152
- .type = ARM_CP_ALIAS,
153
+ .type = ARM_CP_ALIAS | ARM_CP_IO,
154
.cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0,
155
.access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.hcr_el2),
156
.writefn = hcr_writelow },
157
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
158
159
static const ARMCPRegInfo el2_v8_cp_reginfo[] = {
160
{ .name = "HCR2", .state = ARM_CP_STATE_AA32,
161
- .type = ARM_CP_ALIAS,
162
+ .type = ARM_CP_ALIAS | ARM_CP_IO,
163
.cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 4,
164
.access = PL2_RW,
165
.fieldoffset = offsetofhigh32(CPUARMState, cp15.hcr_el2),
166
--
167
2.19.1
168
169
diff view generated by jsdifflib