qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Lluís Vilanova" <vilanova@ac.upc.edu>
To: qemu-devel@nongnu.org
Cc: Blue Swirl <blauwirbel@gmail.com>,
	Riku Voipio <riku.voipio@iki.fi>,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 3/5] user: Refactor lock_user body into do_lock_user
Date: Tue, 23 Feb 2016 19:22:24 +0100	[thread overview]
Message-ID: <145625174428.12025.3426403929640015137.stgit@localhost> (raw)
In-Reply-To: <145625172744.12025.2350972792125742783.stgit@localhost>

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

  parent reply	other threads:[~2016-02-23 18:22 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-23 18:22 [Qemu-devel] [PATCH 0/5] trace: Add events for vCPU memory accesses Lluís Vilanova
2016-02-23 18:22 ` [Qemu-devel] [PATCH 1/5] exec: [tcg] Track which vCPU is performing translation and execution Lluís Vilanova
2016-03-16 15:01   ` Peter Maydell
2016-02-23 18:22 ` [Qemu-devel] [PATCH 2/5] trace: [all] Add "guest_vmem" event Lluís Vilanova
2016-03-16 15:01   ` Peter Maydell
2016-03-17 19:22     ` Lluís Vilanova
2016-03-17 20:18       ` Richard Henderson
2016-03-17 20:25       ` Peter Maydell
2016-03-18 18:50         ` Lluís Vilanova
2016-03-19 13:59           ` Peter Maydell
2016-03-20 18:09             ` Lluís Vilanova
2016-03-20 19:59               ` Peter Maydell
2016-03-21 16:51                 ` Lluís Vilanova
2016-02-23 18:22 ` Lluís Vilanova [this message]
2016-02-23 18:22 ` [Qemu-devel] [PATCH 4/5] user: Set current vCPU during syscall execution Lluís Vilanova
2016-02-23 18:22 ` [Qemu-devel] [PATCH 5/5] trace: [all] Add "guest_vmem_user_syscall" event Lluís Vilanova
2016-03-02 10:55 ` [Qemu-devel] [PATCH 0/5] trace: Add events for vCPU memory accesses Stefan Hajnoczi
2016-03-16 15:10   ` Peter Maydell
2016-03-22 12:55     ` Stefan Hajnoczi
2016-03-22 14:02       ` Lluís Vilanova
2016-03-22 14:47         ` Peter Maydell
2016-03-22 19:23           ` Lluís Vilanova
2016-03-22 20:23             ` Peter Maydell
2016-03-23 14:08               ` Lluís Vilanova

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=145625174428.12025.3426403929640015137.stgit@localhost \
    --to=vilanova@ac.upc.edu \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).