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: 632271 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3rPqZ66QhRz9s36 for ; Wed, 8 Jun 2016 23:50:06 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=UYh9kHe3; dkim-atps=neutral Received: from localhost ([::1]:57104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdrw-0005U8-TU for incoming@patchwork.ozlabs.org; Wed, 08 Jun 2016 09:50:04 -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+incoming=patchwork.ozlabs.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(-) 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