From patchwork Sun Jun 10 03:01:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138134 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2597614lji; Sat, 9 Jun 2018 20:46:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLtCX5OtiLmWTqwKi1eQxSIal5JlXGIeItRYTlE0HP87YLrpLcP+bjE4/3zEJIXebdSYKSB X-Received: by 2002:a37:a241:: with SMTP id l62-v6mr10296399qke.329.1528602366676; Sat, 09 Jun 2018 20:46:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602366; cv=none; d=google.com; s=arc-20160816; b=nXs+pxwEGC1DjVwBCN2UQzyyDKEGW2UAJGdIoSh92ovqCuAvGEPbfECRui9349vKA2 AjQYz27BvoL4exVOayUhPUr2uadZ8xEs8me21wGT3y+um1EHOsYoGbAvNFhg7mYn6YiL nx/so6rGMQL4TeDzXadXyowb3i0jCKSdU2szDicX0QmyvP/dV5JukTgLmRGsYOjwc0jS KO8nw1ypROc7i0XXhMRv3hObZJB3KU4M0r3J1cZQ2ZD7MtV/uvBGG5+txLaYe8jo3zXg PseVx1kLFOEnk7Hji+3ocXwZXWNmWZylCcwFPMYmv5x9cvoCtHdQnY8lo0UwJ8vL/LZs ae7Q== 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=qLsfi8GrsvhESP+qp9nMm079y5R91LfHICSUFAzSBXg=; b=TvvHNJrJ2BtoFC4eKIl9JzvJfKK2kAIt1yANGzpPzieQuJYm44fE/JBIiSZMQxQLSf 4ABTVM06tq60cKLt6oPAq/ZNGnVALEU/h5EEvuCECqouwOU7zBqgmm17dsgxliBBclix +E73donFsBE9bh4zzqdLkwYpsMMLw+wEuofVuuN5TI9tHm3jjJto5cGvY9tFMhqk547G voOSBbV1VOWPIsl28XExXrEo+W5VTJ5qrt93ViPTXevbV1s7gX6OZ2hew0gfG/8jpoQM fEOZthrMYGNVva8D4iR/fUdzEykNsFqpkFNc/PHYiVGAc4qPy5BLHq1ywJjGLWYzmfIA U4OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kTSLoGNi; 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 k97-v6si1952182qte.98.2018.06.09.20.46.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:46:06 -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=kTSLoGNi; 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]:42415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrIs-0007qI-3q for patch@linaro.org; Sat, 09 Jun 2018 23:46:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeY-0003Co-KX for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeX-0003mR-9I for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:26 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:41584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeX-0003mG-1O for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:25 -0400 Received: by mail-pl0-x241.google.com with SMTP id az12-v6so10380409plb.8 for ; Sat, 09 Jun 2018 20:04:24 -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=qLsfi8GrsvhESP+qp9nMm079y5R91LfHICSUFAzSBXg=; b=kTSLoGNiAj8VXkOcCMrDQwGe4N96FkdHh8Y3nImVYIioAZt6C0GyvSfPsv5B9pinav wooxe9tyvf1+niK0hsrGTzwsJVnBfhyOp87NugWQ09rubQcvmSHQsAhALf8nGtRi/z+O Ev2qfhY3Drs6yUUVMxdyiqzJIERL2nges21GQ= 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=qLsfi8GrsvhESP+qp9nMm079y5R91LfHICSUFAzSBXg=; b=lkMt0tSQk9tCVQYrLrqhRvI/Jx2gOFOM9cBflDidirC527eTK40mdlfK2rSR6ZP/2p XafMryHoyqGKYozRD+7O3ZaBQStlTC2a54lWqxMCQesaPltX76DlNT3XO77bnyFqKO9Q RLyMf8MXN7jL9pluGyK3QF4oIdXEE7cpVW+2wA1HI6/ZMRG9H4AyYwz9e9wDLEmneFYI WXMIMMX9yMfen5xKy5SN8gL/KIhs88q7fXCNkI8mhBzHYXzDXjMtyuryBjMGNmxB26Kp b3x7RhU2nGln/WRpkbuAvT1AQg9TenJtz0UiE10fZ0m1KEwPHTJ96yJUIIoOaZcE0EQn rSrA== X-Gm-Message-State: APt69E2dMC8MxhdDEJcxt7saO4OYc6/lUzHqaI6C3DM/X4P0qoWfOyXs DB/bbeg2RgTesL5JDsiJ+SJYpUzmg5g= X-Received: by 2002:a17:902:760e:: with SMTP id k14-v6mr12931152pll.310.1528599863759; Sat, 09 Jun 2018 20:04:23 -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.04.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:26 -1000 Message-Id: <20180610030220.3777-55-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:c01::241 Subject: [Qemu-devel] [PATCH v2 054/108] linux-user: Split out ipc 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" At the same time, merge do_ipc into the new function. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 193 ++++++++++++++++++------------------------- 1 file changed, 82 insertions(+), 111 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a0fbbbbb4a..6ac7532ea6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4962,113 +4962,6 @@ static inline abi_long do_shmdt(abi_ulong shmaddr) return rv; } -#ifdef TARGET_NR_ipc -/* ??? This only works with linear mappings. */ -/* do_ipc() must return target values and target errnos. */ -static abi_long do_ipc(CPUArchState *cpu_env, - unsigned int call, abi_long first, - abi_long second, abi_long third, - abi_long ptr, abi_long fifth) -{ - int version; - abi_long ret = 0; - - version = call >> 16; - call &= 0xffff; - - switch (call) { - case IPCOP_semop: - ret = do_semop(first, ptr, second); - break; - - case IPCOP_semget: - ret = get_errno(semget(first, second, third)); - break; - - case IPCOP_semctl: { - /* The semun argument to semctl is passed by value, so dereference the - * ptr argument. */ - abi_ulong atptr; - get_user_ual(atptr, ptr); - ret = do_semctl(first, second, third, atptr); - break; - } - - case IPCOP_msgget: - ret = get_errno(msgget(first, second)); - break; - - case IPCOP_msgsnd: - ret = do_msgsnd(first, ptr, second, third); - break; - - case IPCOP_msgctl: - ret = do_msgctl(first, second, ptr); - break; - - case IPCOP_msgrcv: - switch (version) { - case 0: - { - struct target_ipc_kludge { - abi_long msgp; - abi_long msgtyp; - } *tmp; - - if (!lock_user_struct(VERIFY_READ, tmp, ptr, 1)) { - ret = -TARGET_EFAULT; - break; - } - - ret = do_msgrcv(first, tswapal(tmp->msgp), second, tswapal(tmp->msgtyp), third); - - unlock_user_struct(tmp, ptr, 0); - break; - } - default: - ret = do_msgrcv(first, ptr, second, fifth, third); - } - break; - - case IPCOP_shmat: - switch (version) { - default: - { - abi_ulong raddr; - raddr = do_shmat(cpu_env, first, ptr, second); - if (is_error(raddr)) - return get_errno(raddr); - if (put_user_ual(raddr, third)) - return -TARGET_EFAULT; - break; - } - case 1: - ret = -TARGET_EINVAL; - break; - } - break; - case IPCOP_shmdt: - ret = do_shmdt(ptr); - break; - - case IPCOP_shmget: - /* IPC_* flag values are the same on all linux platforms */ - ret = get_errno(shmget(first, second, third)); - break; - - /* IPC_* and SHM_* command values are the same on all linux platforms */ - case IPCOP_shmctl: - ret = do_shmctl(first, second, ptr); - break; - default: - gemu_log("Unsupported ipc call: %d (version %d)\n", call, version); - ret = -TARGET_ENOSYS; - break; - } - return ret; -} -#endif - /* kernel structure types definitions */ #define STRUCT(name, ...) STRUCT_ ## name, @@ -8425,6 +8318,85 @@ IMPL(ioctl) return ret; } +#ifdef TARGET_NR_ipc +IMPL(ipc) +{ + unsigned int call = arg1; + abi_long first = arg2; + abi_long second = arg3; + abi_long third = arg4; + abi_long ptr = arg5; + abi_long fifth = arg6; + int version; + abi_long ret; + abi_ulong atptr; + + version = call >> 16; + call &= 0xffff; + + /* IPC_* and SHM_* command values are the same on all linux platforms */ + switch (call) { + case IPCOP_semop: + return do_semop(first, ptr, second); + case IPCOP_semget: + return get_errno(semget(first, second, third)); + case IPCOP_semctl: + /* The semun argument to semctl is passed by value, + * so dereference the ptr argument. + */ + get_user_ual(atptr, ptr); + return do_semctl(first, second, third, atptr); + + case IPCOP_msgget: + return get_errno(msgget(first, second)); + case IPCOP_msgsnd: + return do_msgsnd(first, ptr, second, third); + case IPCOP_msgctl: + return do_msgctl(first, second, ptr); + case IPCOP_msgrcv: + if (version == 0) { + struct target_ipc_kludge { + abi_long msgp; + abi_long msgtyp; + } *tmp; + + if (!lock_user_struct(VERIFY_READ, tmp, ptr, 1)) { + return -TARGET_EFAULT; + } + + ret = do_msgrcv(first, tswapal(tmp->msgp), second, + tswapal(tmp->msgtyp), third); + unlock_user_struct(tmp, ptr, 0); + return ret; + } + return do_msgrcv(first, ptr, second, fifth, third); + + case IPCOP_shmat: + if (version == 1) { + return -TARGET_EINVAL; + } + ret = do_shmat(cpu_env, first, ptr, second); + if (is_error(ret)) { + return get_errno(ret); + } + if (put_user_ual(ret, third)) { + return -TARGET_EFAULT; + } + return ret; + case IPCOP_shmdt: + return do_shmdt(ptr); + case IPCOP_shmget: + return get_errno(shmget(first, second, third)); + case IPCOP_shmctl: + return do_shmctl(first, second, ptr); + + default: + gemu_log("Unsupported ipc call: %d (version %d)\n", call, version); + return -TARGET_ENOSYS; + } +} +#endif + IMPL(kill) { return get_errno(safe_kill(arg1, target_to_host_signal(arg2))); @@ -10300,10 +10272,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_ipc - case TARGET_NR_ipc: - return do_ipc(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6); -#endif #ifdef TARGET_NR_semget case TARGET_NR_semget: return get_errno(semget(arg1, arg2, arg3)); @@ -12941,6 +12909,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(getxpid); #endif SYSCALL(ioctl); +#ifdef TARGET_NR_ipc + SYSCALL(ipc); +#endif SYSCALL(kill); #ifdef TARGET_NR_link SYSCALL(link);