diff mbox

[3/5] user: Refactor lock_user body into do_lock_user

Message ID 145625174428.12025.3426403929640015137.stgit@localhost (mailing list archive)
State New, archived
Headers show

Commit Message

Lluís Vilanova Feb. 23, 2016, 6:22 p.m. UTC
Lock user will later be hooked to raise a tracing event, while the
internal 'do_lock_user' will be used by non-interface code (e.g., string
length computation).

Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
 bsd-user/qemu.h      |   11 ++++++++---
 bsd-user/uaccess.c   |    2 +-
 linux-user/qemu.h    |   11 ++++++++---
 linux-user/uaccess.c |    2 +-
 4 files changed, 18 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 1b5f998..4dad254 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -348,9 +348,7 @@  abi_long copy_to_user(abi_ulong gaddr, void *hptr, size_t len);
    any byteswapping.  lock_user may return either a pointer to the guest
    memory, or a temporary buffer.  */
 
-/* Lock an area of guest memory into the host.  If copy is true then the
-   host area will have the same contents as the guest.  */
-static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy)
+static inline void *do_lock_user(int type, abi_ulong guest_addr, long len, int copy)
 {
     if (!access_ok(type, guest_addr, len))
         return NULL;
@@ -369,6 +367,13 @@  static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy
 #endif
 }
 
+/* Lock an area of guest memory into the host.  If copy is true then the
+   host area will have the same contents as the guest.  */
+static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy)
+{
+    return do_lock_user(type, guest_addr, len, copy);
+}
+
 /* Unlock an area of guest memory.  The first LEN bytes must be
    flushed back to guest memory. host_ptr = NULL is explicitly
    allowed and does nothing. */
diff --git a/bsd-user/uaccess.c b/bsd-user/uaccess.c
index 7cb6d17..69f00db 100644
--- a/bsd-user/uaccess.c
+++ b/bsd-user/uaccess.c
@@ -47,7 +47,7 @@  abi_long target_strlen(abi_ulong guest_addr1)
     guest_addr = guest_addr1;
     for(;;) {
         max_len = TARGET_PAGE_SIZE - (guest_addr & ~TARGET_PAGE_MASK);
-        ptr = lock_user(VERIFY_READ, guest_addr, max_len, 1);
+        ptr = do_lock_user(VERIFY_READ, guest_addr, max_len, 1);
         if (!ptr)
             return -TARGET_EFAULT;
         len = qemu_strnlen((char *)ptr, max_len);
diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index ba5b433..0b71683 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -372,9 +372,7 @@  abi_long copy_to_user(abi_ulong gaddr, void *hptr, size_t len);
    any byteswapping.  lock_user may return either a pointer to the guest
    memory, or a temporary buffer.  */
 
-/* Lock an area of guest memory into the host.  If copy is true then the
-   host area will have the same contents as the guest.  */
-static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy)
+static inline void *do_lock_user(int type, abi_ulong guest_addr, long len, int copy)
 {
     if (!access_ok(type, guest_addr, len))
         return NULL;
@@ -393,6 +391,13 @@  static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy
 #endif
 }
 
+/* Lock an area of guest memory into the host.  If copy is true then the
+   host area will have the same contents as the guest.  */
+static inline void *lock_user(int type, abi_ulong guest_addr, long len, int copy)
+{
+    return do_lock_user(type, guest_addr, len, copy);
+}
+
 /* Unlock an area of guest memory.  The first LEN bytes must be
    flushed back to guest memory. host_ptr = NULL is explicitly
    allowed and does nothing. */
diff --git a/linux-user/uaccess.c b/linux-user/uaccess.c
index 75d890d..fac2464 100644
--- a/linux-user/uaccess.c
+++ b/linux-user/uaccess.c
@@ -47,7 +47,7 @@  abi_long target_strlen(abi_ulong guest_addr1)
     guest_addr = guest_addr1;
     for(;;) {
         max_len = TARGET_PAGE_SIZE - (guest_addr & ~TARGET_PAGE_MASK);
-        ptr = lock_user(VERIFY_READ, guest_addr, max_len, 1);
+        ptr = do_lock_user(VERIFY_READ, guest_addr, max_len, 1);
         if (!ptr)
             return -TARGET_EFAULT;
         len = qemu_strnlen((const char *)ptr, max_len);