From patchwork Wed Jun 8 13:30:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 69647 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2506758qgf; Wed, 8 Jun 2016 06:50:59 -0700 (PDT) X-Received: by 10.140.181.70 with SMTP id c67mr4951350qha.20.1465393859626; Wed, 08 Jun 2016 06:50:59 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f91si727183qga.24.2016.06.08.06.50.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:50:59 -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; 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 dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdsp-0005U8-37 for patch@linaro.org; Wed, 08 Jun 2016 09:50:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZn-0004f3-JE for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAdZi-0005sS-7F for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:19 -0400 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]:36354) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZh-0005sG-VN for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:14 -0400 Received: by mail-lf0-x22d.google.com with SMTP id j5so5845958lfb.3 for ; Wed, 08 Jun 2016 06:31:13 -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=0mRaK7PIecWICfqeF3T4GuoCDZ8Atu090sHYRl4ME0Q=; b=UYh9kHe3hADZsygtSRpU56DQ15bYgkSy624IKxi7oleUVHV7CXFXiOMbU6fF9z0xfO Ss7yL8DZ6KswpMHKzobCkrBKj3ImEFoJ2VB7Mmf0BFtHwlbcgKe9Md4+CmGDaWiDD7j2 cju9DEhWLOhTHUxC+v4sSkcSIA145b/u/tDM4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0mRaK7PIecWICfqeF3T4GuoCDZ8Atu090sHYRl4ME0Q=; b=XawaeOYUQahjWIWSsTAplIFv0b7K6/YMGZqrD3zmjkjFaueQiuK0OceQALoVhbUk6n xuk7+PhatnJzS4IsP2yA9vD2iIWLAM6HMAqgrwjV8gNkHsYvHy6sUxgEIV5+kpl3szfM eLPG6TiwsQub9Xrfb/M3ZZrD5RN+nC8avALXqmyS3WGX6ttM1omLh+tT2i+kRTsckbaw ikkt88jDSbd9oW4E5RaL9a+84wkwFP23MOSb70Tm31NClb65aBon1dtQoG/MbolKDy1B KAVK9QxNN5otgTJVOmN/bjKPQ4e07nshhVkr6dV0vLj0KekUgqR9UBnMLOViwb105DiR mN1A== X-Gm-Message-State: ALyK8tIcc4pfaXAXWNf6YwBoqPA4pUpSzTa1Oaz1vrUTE/uo8EIgTKZM+oGqdPA/wIxUeukC X-Received: by 10.25.43.70 with SMTP id r67mr3765041lfr.80.1465392673205; Wed, 08 Jun 2016 06:31:13 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id 2sm139854lja.37.2016.06.08.06.31.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:31:12 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 16:30:19 +0300 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22d Subject: [Qemu-devel] [PULL 38/44] linux-user: Use safe_syscall wrapper for semop 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: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Use the safe_syscall wrapper for the semop syscall or IPC operation. (We implement via the semtimedop syscall to make it easier to implement the guest semtimedop syscall later.) Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- 2.1.4 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a193849..3ccb367 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -732,6 +732,8 @@ safe_syscall4(int, msgsnd, int, msgid, const void *, msgp, size_t, sz, int, flags) safe_syscall5(int, msgrcv, int, msgid, void *, msgp, size_t, sz, long, msgtype, int, flags) +safe_syscall4(int, semtimedop, int, semid, struct sembuf *, tsops, + unsigned, nsops, const struct timespec *, timeout) #else /* This host kernel architecture uses a single ipc syscall; fake up * wrappers for the sub-operations to hide this implementation detail. @@ -740,6 +742,7 @@ safe_syscall5(int, msgrcv, int, msgid, void *, msgp, size_t, sz, * sys/ipc.h ones. So we just define them here, and rely on them being * the same for all host architectures. */ +#define Q_SEMTIMEDOP 4 #define Q_MSGSND 11 #define Q_MSGRCV 12 #define Q_IPCCALL(VERSION, OP) ((VERSION) << 16 | (OP)) @@ -754,6 +757,12 @@ static int safe_msgrcv(int msgid, void *msgp, size_t sz, long type, int flags) { return safe_ipc(Q_IPCCALL(1, Q_MSGRCV), msgid, sz, flags, msgp, type); } +static int safe_semtimedop(int semid, struct sembuf *tsops, unsigned nsops, + const struct timespec *timeout) +{ + return safe_ipc(Q_IPCCALL(0, Q_SEMTIMEDOP), semid, nsops, 0, tsops, + (long)timeout); +} #endif #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) safe_syscall5(int, mq_timedsend, int, mqdes, const char *, msg_ptr, @@ -3680,7 +3689,7 @@ static inline abi_long do_semop(int semid, abi_long ptr, unsigned nsops) if (target_to_host_sembuf(sops, ptr, nsops)) return -TARGET_EFAULT; - return get_errno(semop(semid, sops, nsops)); + return get_errno(safe_semtimedop(semid, sops, nsops, NULL)); } struct target_msqid_ds