From patchwork Tue Feb 23 18:22:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 8395371 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B65A99F372 for ; Tue, 23 Feb 2016 18:24:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 07B7B202EC for ; Tue, 23 Feb 2016 18:24:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B95D202E6 for ; Tue, 23 Feb 2016 18:24:46 +0000 (UTC) Received: from localhost ([::1]:59166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYHdd-0004Zh-IC for patchwork-qemu-devel@patchwork.kernel.org; Tue, 23 Feb 2016 13:24:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34334) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYHbY-0001R1-Ud for qemu-devel@nongnu.org; Tue, 23 Feb 2016 13:22:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYHbV-0006VR-OO for qemu-devel@nongnu.org; Tue, 23 Feb 2016 13:22:36 -0500 Received: from roura.ac.upc.es ([147.83.33.10]:36345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYHbV-0006VE-CJ for qemu-devel@nongnu.org; Tue, 23 Feb 2016 13:22:33 -0500 Received: from gw-3.ac.upc.es (gw-3.ac.upc.es [147.83.30.9]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id u1NIMOfH000906; Tue, 23 Feb 2016 19:22:24 +0100 Received: from localhost (unknown [84.88.51.85]) by gw-3.ac.upc.es (Postfix) with ESMTPSA id BC5E87EF; Tue, 23 Feb 2016 19:22:24 +0100 (CET) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Tue, 23 Feb 2016 19:22:24 +0100 Message-Id: <145625174428.12025.3426403929640015137.stgit@localhost> X-Mailer: git-send-email 2.7.0 In-Reply-To: <145625172744.12025.2350972792125742783.stgit@localhost> References: <145625172744.12025.2350972792125742783.stgit@localhost> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by roura.ac.upc.es id u1NIMOfH000906 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.83.33.10 Cc: Blue Swirl , Riku Voipio , Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 3/5] user: Refactor lock_user body into do_lock_user X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);