qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target/arm: Fix 32-bit address truncation
@ 2018-01-19 19:46 Ard Biesheuvel
  2018-01-22 11:12 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2018-01-19 19:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, rth, Ard Biesheuvel

Commit ("3b39d734141a target/arm: Handle page table walk load failures
correctly") modified both versions of the page table walking code (i.e.,
arm_ldl_ptw and arm_ldq_ptw) to record the result of the translation in
a temporary 'data' variable so that it can be inspected before being
returned. However, arm_ldq_ptw() returns an uint64_t, and using a
temporary uint32_t variable truncates the upper bits, corrupting the
result. This causes problems when using more than 4 GB of memory in
a TCG guest. So use a uint64_t instead.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 target/arm/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/arm/helper.c b/target/arm/helper.c
index 67059033019c..a41b6c3a1b82 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -8368,7 +8368,7 @@ static uint64_t arm_ldq_ptw(CPUState *cs, hwaddr addr, bool is_secure,
     MemTxAttrs attrs = {};
     MemTxResult result = MEMTX_OK;
     AddressSpace *as;
-    uint32_t data;
+    uint64_t data;
 
     attrs.secure = is_secure;
     as = arm_addressspace(cs, attrs);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] target/arm: Fix 32-bit address truncation
  2018-01-19 19:46 [Qemu-devel] [PATCH] target/arm: Fix 32-bit address truncation Ard Biesheuvel
@ 2018-01-22 11:12 ` Peter Maydell
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2018-01-22 11:12 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: QEMU Developers, Richard Henderson

On 19 January 2018 at 19:46, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> Commit ("3b39d734141a target/arm: Handle page table walk load failures
> correctly") modified both versions of the page table walking code (i.e.,
> arm_ldl_ptw and arm_ldq_ptw) to record the result of the translation in
> a temporary 'data' variable so that it can be inspected before being
> returned. However, arm_ldq_ptw() returns an uint64_t, and using a
> temporary uint32_t variable truncates the upper bits, corrupting the
> result. This causes problems when using more than 4 GB of memory in
> a TCG guest. So use a uint64_t instead.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Oops. As you probably guessed, I wrote the 32-bit load function
first and then failed to update it correctly when writing the 64-bit
version...

Applied to target-arm.next, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-22 11:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-19 19:46 [Qemu-devel] [PATCH] target/arm: Fix 32-bit address truncation Ard Biesheuvel
2018-01-22 11:12 ` Peter Maydell

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).