[Qemu-devel] [PATCH] target/arm: Initialize ARMMMUFaultInfo in v7m_stack_read/write

Peter Maydell posted 1 patch 7 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20181011172057.9466-1-peter.maydell@linaro.org
Test docker-clang@ubuntu passed
Test checkpatch passed
Test docker-quick@centos7 passed
Test docker-mingw@fedora passed
target/arm/helper.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[Qemu-devel] [PATCH] target/arm: Initialize ARMMMUFaultInfo in v7m_stack_read/write
Posted by Peter Maydell 7 years ago
The get_phys_addr() functions take a pointer to an ARMMMUFaultInfo
struct, which they fill in only if a fault occurs. This means that
the caller must always zero-initialize the struct before passing
it in. We forgot to do this in v7m_stack_read() and v7m_stack_write().
Correct the error.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
Noticed this in passing while I was working in the file on
an entirely different issue.

 target/arm/helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/arm/helper.c b/target/arm/helper.c
index c83f7c1109c..e3368e7edc5 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -6469,7 +6469,7 @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,
     target_ulong page_size;
     hwaddr physaddr;
     int prot;
-    ARMMMUFaultInfo fi;
+    ARMMMUFaultInfo fi = {};
     bool secure = mmu_idx & ARM_MMU_IDX_M_S;
     int exc;
     bool exc_secure;
@@ -6531,7 +6531,7 @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr,
     target_ulong page_size;
     hwaddr physaddr;
     int prot;
-    ARMMMUFaultInfo fi;
+    ARMMMUFaultInfo fi = {};
     bool secure = mmu_idx & ARM_MMU_IDX_M_S;
     int exc;
     bool exc_secure;
-- 
2.19.0


Re: [Qemu-devel] [PATCH] target/arm: Initialize ARMMMUFaultInfo in v7m_stack_read/write
Posted by Richard Henderson 7 years ago
On 10/11/18 10:20 AM, Peter Maydell wrote:
> The get_phys_addr() functions take a pointer to an ARMMMUFaultInfo
> struct, which they fill in only if a fault occurs. This means that
> the caller must always zero-initialize the struct before passing
> it in. We forgot to do this in v7m_stack_read() and v7m_stack_write().
> Correct the error.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> Noticed this in passing while I was working in the file on
> an entirely different issue.
> 
>  target/arm/helper.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~