* [Qemu-devel] [PATCH] target/arm: Use v7m_stack_read() for reading the frame signature
@ 2018-04-19 14:21 Peter Maydell
2018-04-19 16:58 ` Philippe Mathieu-Daudé
2018-04-19 19:29 ` Richard Henderson
0 siblings, 2 replies; 3+ messages in thread
From: Peter Maydell @ 2018-04-19 14:21 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: patches
In commit 95695effe8caa552b8f2 we changed the v7M/v8M stack
pop code to use a new v7m_stack_read() function that checks
whether the read should fail due to an MPU or bus abort.
We missed one call though, the one which reads the signature
word for the callee-saved register part of the frame.
Correct the omission.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/helper.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index b14fdab140..2ebd086ef2 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -6913,7 +6913,6 @@ static bool v7m_push_stack(ARMCPU *cpu)
static void do_v7m_exception_exit(ARMCPU *cpu)
{
CPUARMState *env = &cpu->env;
- CPUState *cs = CPU(cpu);
uint32_t excret;
uint32_t xpsr;
bool ufault = false;
@@ -7112,9 +7111,11 @@ static void do_v7m_exception_exit(ARMCPU *cpu)
((excret & R_V7M_EXCRET_ES_MASK) == 0 ||
(excret & R_V7M_EXCRET_DCRS_MASK) == 0)) {
uint32_t expected_sig = 0xfefa125b;
- uint32_t actual_sig = ldl_phys(cs->as, frameptr);
+ uint32_t actual_sig;
- if (expected_sig != actual_sig) {
+ pop_ok = v7m_stack_read(cpu, &actual_sig, frameptr, mmu_idx);
+
+ if (pop_ok && expected_sig != actual_sig) {
/* Take a SecureFault on the current stack */
env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK;
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
@@ -7125,7 +7126,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu)
return;
}
- pop_ok =
+ pop_ok = pop_ok &&
v7m_stack_read(cpu, &env->regs[4], frameptr + 0x8, mmu_idx) &&
v7m_stack_read(cpu, &env->regs[4], frameptr + 0x8, mmu_idx) &&
v7m_stack_read(cpu, &env->regs[5], frameptr + 0xc, mmu_idx) &&
--
2.17.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] target/arm: Use v7m_stack_read() for reading the frame signature
2018-04-19 14:21 [Qemu-devel] [PATCH] target/arm: Use v7m_stack_read() for reading the frame signature Peter Maydell
@ 2018-04-19 16:58 ` Philippe Mathieu-Daudé
2018-04-19 19:29 ` Richard Henderson
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-04-19 16:58 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: patches
On 04/19/2018 11:21 AM, Peter Maydell wrote:
> In commit 95695effe8caa552b8f2 we changed the v7M/v8M stack
> pop code to use a new v7m_stack_read() function that checks
> whether the read should fail due to an MPU or bus abort.
> We missed one call though, the one which reads the signature
> word for the callee-saved register part of the frame.
Good catch.
> Correct the omission.
I checked, this was the unique omission.
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> target/arm/helper.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/target/arm/helper.c b/target/arm/helper.c
> index b14fdab140..2ebd086ef2 100644
> --- a/target/arm/helper.c
> +++ b/target/arm/helper.c
> @@ -6913,7 +6913,6 @@ static bool v7m_push_stack(ARMCPU *cpu)
> static void do_v7m_exception_exit(ARMCPU *cpu)
> {
> CPUARMState *env = &cpu->env;
> - CPUState *cs = CPU(cpu);
> uint32_t excret;
> uint32_t xpsr;
> bool ufault = false;
> @@ -7112,9 +7111,11 @@ static void do_v7m_exception_exit(ARMCPU *cpu)
> ((excret & R_V7M_EXCRET_ES_MASK) == 0 ||
> (excret & R_V7M_EXCRET_DCRS_MASK) == 0)) {
> uint32_t expected_sig = 0xfefa125b;
> - uint32_t actual_sig = ldl_phys(cs->as, frameptr);
> + uint32_t actual_sig;
>
> - if (expected_sig != actual_sig) {
> + pop_ok = v7m_stack_read(cpu, &actual_sig, frameptr, mmu_idx);
> +
> + if (pop_ok && expected_sig != actual_sig) {
> /* Take a SecureFault on the current stack */
> env->v7m.sfsr |= R_V7M_SFSR_INVIS_MASK;
> armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SECURE, false);
> @@ -7125,7 +7126,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu)
> return;
> }
>
> - pop_ok =
> + pop_ok = pop_ok &&
> v7m_stack_read(cpu, &env->regs[4], frameptr + 0x8, mmu_idx) &&
> v7m_stack_read(cpu, &env->regs[4], frameptr + 0x8, mmu_idx) &&
> v7m_stack_read(cpu, &env->regs[5], frameptr + 0xc, mmu_idx) &&
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] target/arm: Use v7m_stack_read() for reading the frame signature
2018-04-19 14:21 [Qemu-devel] [PATCH] target/arm: Use v7m_stack_read() for reading the frame signature Peter Maydell
2018-04-19 16:58 ` Philippe Mathieu-Daudé
@ 2018-04-19 19:29 ` Richard Henderson
1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2018-04-19 19:29 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: patches
On 04/19/2018 04:21 AM, Peter Maydell wrote:
> In commit 95695effe8caa552b8f2 we changed the v7M/v8M stack
> pop code to use a new v7m_stack_read() function that checks
> whether the read should fail due to an MPU or bus abort.
> We missed one call though, the one which reads the signature
> word for the callee-saved register part of the frame.
>
> Correct the omission.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> target/arm/helper.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-19 19:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-19 14:21 [Qemu-devel] [PATCH] target/arm: Use v7m_stack_read() for reading the frame signature Peter Maydell
2018-04-19 16:58 ` Philippe Mathieu-Daudé
2018-04-19 19:29 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).