Patchwork linux-user: take RESERVED_VA into account for g2h_valid()

login
register
mail settings
Submitter Alexander Graf
Date Feb. 2, 2012, 2:19 a.m.
Message ID <1328149148-13422-1-git-send-email-agraf@suse.de>
Download mbox | patch
Permalink /patch/139048/
State New
Headers show

Comments

Alexander Graf - Feb. 2, 2012, 2:19 a.m.
When running with -R (RESERVED_VA > 0) all guest virtual addresses
are within the [0..RESERVED_VA] range. Reflect this with g2h_valid()
too so we can safely check for boundaries of our guest address space.

This is required to have the /proc/self/maps code not show maps that
aren't accessible from the guest process's point of view.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 cpu-all.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Patch

diff --git a/cpu-all.h b/cpu-all.h
index e2c3c49..d42a06e 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -204,7 +204,8 @@  extern unsigned long reserved_va;
 #else
 #define h2g_valid(x) ({ \
     unsigned long __guest = (unsigned long)(x) - GUEST_BASE; \
-    __guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS); \
+    (__guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS)) && \
+    (!RESERVED_VA || (__guest < RESERVED_VA)); \
 })
 #endif