From patchwork Sun Jun 10 03:02:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138178 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2617130lji; Sat, 9 Jun 2018 21:19:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLybFj99ARbA+GM2ZMA6YvbRx+EW/yqnO/Orx2OoMiWNq4sDO47WIBb3V3OhRN7DbbN0CZC X-Received: by 2002:a37:6e83:: with SMTP id j125-v6mr6881046qkc.237.1528604394274; Sat, 09 Jun 2018 21:19:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604394; cv=none; d=google.com; s=arc-20160816; b=nFwIk09jHEZObJS6ydfy15LrF/q7ufKw7U5dE00v87uQ6+8ZRrsO2Yf8aku3RDZjB/ xBCnHFg6M60TJ3kUpIZyn+89f7SmHEEmsTK6E7kdwO77Kdidn9kvU83+LvEoDm/e00Qe b8BmpuiSsKc1WD3AAhmH/fPEfCwq9SyJRMfe/8ZVneoDSrh03MWQWpsZVYT9eYj7ZaEr m+Jbcgl7RZprEbXkHk1SNnzSfC3/yn8lDKI+Q20rOMObBO51fx6ElKMw6fJ+ZnMpcqJy baSQlC2mbqtNQLYdsSJ8P6Ju5jt/I5wKeIe/7UWwZJNILzzAoYVjCAtBf4uSVUoZP0+O zWMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=FSpu2eU4yP7W5bv4XVKK/hTWwA7/qFdooXWRU7ozHlQ=; b=SmYnI1Td4gDGuLu2hL5etfN1rJzMT/mYnaob1iNdoIJT38eawRuv1oiDLcGYCJVM1q TWeOdhebYTb8PYqoOngfHfw9rc7B/Ee+b/UNsBCEsFnMBLbYtx3So1s6e71jwUaxLF3V y+Jj+4hva+T+a/LrrY6FJAiqLC1UgzPeOFI/mog8ScfXrxEflvuMKJmULXzsAoND5nDB EWiC3I9GHZrVGDGEP94MYd87jQCscAmkudHpccvgd/tn4VaNcemzcXb9AyYlp0mOKpIC +UBFgIIc0xr/43YlTVqjPqr8QFCyZTGus2iySaTy7SMP399B6pfBwqwJGd0loVsjuiXC rYmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EBGDYVS1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w13-v6si3800732qto.294.2018.06.09.21.19.54 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:19:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EBGDYVS1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrpZ-0004xt-P1 for patch@linaro.org; Sun, 10 Jun 2018 00:19:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfo-0004Su-Cn for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfm-0004hU-V3 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:44 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:38123) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfm-0004hC-MX for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:42 -0400 Received: by mail-pf0-x242.google.com with SMTP id b74-v6so8494801pfl.5 for ; Sat, 09 Jun 2018 20:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FSpu2eU4yP7W5bv4XVKK/hTWwA7/qFdooXWRU7ozHlQ=; b=EBGDYVS1oA8sAF2dA9p+kgFknnzOJziBKAYgLAdgsz3WRYHg/Q57luM9wEr8cf8oZV J/c5LyB2QhRMjbeehxK0yLHxICi2WXKhnNArGCcZkTlFeY5aGANoBSGK41lTo98L0GlJ w2PY8gN8hpi0TbUmFBEKIFa5IX13wzoLrPH9s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FSpu2eU4yP7W5bv4XVKK/hTWwA7/qFdooXWRU7ozHlQ=; b=Tx1lfDqpKjUB3bQPei6ZKd5t/l+A/E2Lk2uWKNaXFqUeJ119SHbi2/5XPtkI0DRt7d j66wmH9J/l8MuBOs+u0+cS1HHoUweZ5OPrYZSclG49WNs9jZ4GtDKj5rOTYMBvJIcT61 8EUxcgDlWEwIs1ubnRbl93hA78/ZSuo9VLUi92QN+xjD4UyQF7NvzujOEkWWQI9u+V5L tYK84TcdZaCW2mxQIhKGf66olx7EuuBFcU9S0KrP0fXnTzjNCu97s8BBLgwkUJZbOrbl 3JKIPRN/qtvoBE361b9Bteom0+SKN5EHmYuJpO+kBJr8MMYr0RmhJ0oEEY946VmjN4RW vO6Q== X-Gm-Message-State: APt69E2DZlhaeFKJlUXB63RtKZa3NBpr72TkO3dAHSq4dfrEvI6KWg16 Ksb5SgIfJbkQiGTPq+FHcrcB4wa+KXY= X-Received: by 2002:a62:3e11:: with SMTP id l17-v6mr12304343pfa.18.1528599941462; Sat, 09 Jun 2018 20:05:41 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:07 -1000 Message-Id: <20180610030220.3777-96-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v2 095/108] linux-user: Split out mq syscalls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This includes mq_getsetattr, mq_open, mq_timedreceive, mq_timedsend, and mq_unlink. All targets define these syscalls; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 211 +++++++++++++++++++++++-------------------- 1 file changed, 112 insertions(+), 99 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a540c1455b..0c312cd156 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -77,6 +77,7 @@ #ifdef CONFIG_INOTIFY #include #endif +#include #define termios host_termios #define winsize host_winsize @@ -1000,12 +1001,10 @@ static int safe_semtimedop(int semid, struct sembuf *tsops, unsigned nsops, (long)timeout); } #endif -#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) safe_syscall5(int, mq_timedsend, int, mqdes, const char *, msg_ptr, size_t, len, unsigned, prio, const struct timespec *, timeout) safe_syscall5(int, mq_timedreceive, int, mqdes, char *, msg_ptr, size_t, len, unsigned *, prio, const struct timespec *, timeout) -#endif /* We do ioctl like this rather than via safe_syscall3 to preserve the * "third argument might be integer or pointer or not present" behaviour of * the libc function. @@ -1382,9 +1381,6 @@ static inline abi_long copy_from_user_timezone(struct timezone *tz, return 0; } -#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) -#include - static inline abi_long copy_from_user_mq_attr(struct mq_attr *attr, abi_ulong target_mq_attr_addr) { @@ -1422,7 +1418,6 @@ static inline abi_long copy_to_user_mq_attr(abi_ulong target_mq_attr_addr, return 0; } -#endif #if defined(TARGET_NR_select) || defined(TARGET_NR__newselect) /* do_select() must return target values and target errnos. */ @@ -9836,6 +9831,112 @@ IMPL(mprotect) return get_errno(target_mprotect(arg1, arg2, arg3)); } +IMPL(mq_getsetattr) +{ + struct mq_attr in, out; + abi_long ret = 0; + + if (arg2 != 0) { + ret = copy_from_user_mq_attr(&in, arg2); + if (ret) { + return ret; + } + ret = get_errno(mq_setattr(arg1, &in, &out)); + } else if (arg3 != 0) { + ret = get_errno(mq_getattr(arg1, &out)); + } + if (ret == 0 && arg3 != 0) { + ret = copy_to_user_mq_attr(arg3, &out); + } + return ret; +} + +IMPL(mq_open) +{ + struct mq_attr posix_mq_attr; + struct mq_attr *pposix_mq_attr; + int host_flags; + abi_long ret; + char *p; + + host_flags = target_to_host_bitmask(arg2, fcntl_flags_tbl); + pposix_mq_attr = NULL; + if (arg4) { + if (copy_from_user_mq_attr(&posix_mq_attr, arg4) != 0) { + return -TARGET_EFAULT; + } + pposix_mq_attr = &posix_mq_attr; + } + p = lock_user_string(arg1 - 1); + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mq_open(p, host_flags, arg3, pposix_mq_attr)); + unlock_user(p, arg1, 0); + return ret; +} + +IMPL(mq_timedreceive) +{ + struct timespec ts; + unsigned int prio; + abi_long ret; + void *p; + + p = lock_user(VERIFY_READ, arg2, arg3, 1); + if (arg5 != 0) { + ret = target_to_host_timespec(&ts, arg5); + if (ret == 0) { + ret = get_errno(safe_mq_timedreceive(arg1, p, arg3, &prio, &ts)); + if (ret == 0) { + ret = host_to_target_timespec(arg5, &ts); + } + } + } else { + ret = get_errno(safe_mq_timedreceive(arg1, p, arg3, &prio, NULL)); + } + unlock_user(p, arg2, arg3); + if (ret == 0 && arg4 != 0) { + ret = put_user_u32(prio, arg4); + } + return ret; +} + +IMPL(mq_timedsend) +{ + struct timespec ts; + abi_long ret; + void *p; + + p = lock_user(VERIFY_READ, arg2, arg3, 1); + if (arg5 != 0) { + ret = target_to_host_timespec(&ts, arg5); + if (ret == 0) { + ret = get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, &ts)); + if (ret == 0) { + ret = host_to_target_timespec(arg5, &ts); + } + } + } else { + ret = get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, NULL)); + } + unlock_user(p, arg2, arg3); + return ret; +} + +IMPL(mq_unlink) +{ + char *p = lock_user_string(arg1 - 1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(mq_unlink(p)); + unlock_user(p, arg1, 0); + return ret; +} + IMPL(mremap) { return get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); @@ -12609,101 +12710,8 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, { CPUState *cpu __attribute__((unused)) = ENV_GET_CPU(cpu_env); abi_long ret; - void *p; switch(num) { -#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) - case TARGET_NR_mq_open: - { - struct mq_attr posix_mq_attr; - struct mq_attr *pposix_mq_attr; - int host_flags; - - host_flags = target_to_host_bitmask(arg2, fcntl_flags_tbl); - pposix_mq_attr = NULL; - if (arg4) { - if (copy_from_user_mq_attr(&posix_mq_attr, arg4) != 0) { - return -TARGET_EFAULT; - } - pposix_mq_attr = &posix_mq_attr; - } - p = lock_user_string(arg1 - 1); - if (!p) { - return -TARGET_EFAULT; - } - ret = get_errno(mq_open(p, host_flags, arg3, pposix_mq_attr)); - unlock_user (p, arg1, 0); - } - return ret; - - case TARGET_NR_mq_unlink: - p = lock_user_string(arg1 - 1); - if (!p) { - return -TARGET_EFAULT; - } - ret = get_errno(mq_unlink(p)); - unlock_user (p, arg1, 0); - return ret; - - case TARGET_NR_mq_timedsend: - { - struct timespec ts; - - p = lock_user (VERIFY_READ, arg2, arg3, 1); - if (arg5 != 0) { - target_to_host_timespec(&ts, arg5); - ret = get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, &ts)); - host_to_target_timespec(arg5, &ts); - } else { - ret = get_errno(safe_mq_timedsend(arg1, p, arg3, arg4, NULL)); - } - unlock_user (p, arg2, arg3); - } - return ret; - - case TARGET_NR_mq_timedreceive: - { - struct timespec ts; - unsigned int prio; - - p = lock_user (VERIFY_READ, arg2, arg3, 1); - if (arg5 != 0) { - target_to_host_timespec(&ts, arg5); - ret = get_errno(safe_mq_timedreceive(arg1, p, arg3, - &prio, &ts)); - host_to_target_timespec(arg5, &ts); - } else { - ret = get_errno(safe_mq_timedreceive(arg1, p, arg3, - &prio, NULL)); - } - unlock_user (p, arg2, arg3); - if (arg4 != 0) - put_user_u32(prio, arg4); - } - return ret; - - /* Not implemented for now... */ -/* case TARGET_NR_mq_notify: */ -/* break; */ - - case TARGET_NR_mq_getsetattr: - { - struct mq_attr posix_mq_attr_in, posix_mq_attr_out; - ret = 0; - if (arg2 != 0) { - copy_from_user_mq_attr(&posix_mq_attr_in, arg2); - ret = get_errno(mq_setattr(arg1, &posix_mq_attr_in, - &posix_mq_attr_out)); - } else if (arg3 != 0) { - ret = get_errno(mq_getattr(arg1, &posix_mq_attr_out)); - } - if (ret == 0 && arg3 != 0) { - copy_to_user_mq_attr(arg3, &posix_mq_attr_out); - } - } - return ret; -#endif - #ifdef CONFIG_SPLICE #ifdef TARGET_NR_tee case TARGET_NR_tee: @@ -13537,6 +13545,11 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(mount); SYSCALL(mprotect); + SYSCALL(mq_getsetattr); + SYSCALL(mq_open); + SYSCALL(mq_timedreceive); + SYSCALL(mq_timedsend); + SYSCALL(mq_unlink); SYSCALL(mremap); #ifdef TARGET_NR_msgctl SYSCALL(msgctl);