From patchwork Wed May 31 13:08:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 100745 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp292827obc; Wed, 31 May 2017 06:08:59 -0700 (PDT) X-Received: by 10.200.51.66 with SMTP id u2mr31313801qta.12.1496236139864; Wed, 31 May 2017 06:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496236139; cv=none; d=google.com; s=arc-20160816; b=ulcIH52rmUrnksiwkzQc9gi82KnLQCKNR+2GCFIMbnEm8+vs1GRlGlv/Cjpuiw1mPr hLsUmKd10BgAV2o14GoKxztJgMwmD9xdpz9ptHNwKMjbesWcODBGYcyFG59sT2pDLYW2 wm2KoZiBJGYnCN2r+TSTRNjyYKZpTlo8Po77idvTrMFGJQ1EnVjOdOzW+QuszG+GoADH Qmp4zGW7XokN+YDsV2NYDjaxpLGA9tBktPHC9FbdjpAShBMU8sJJzEHcLGYonAQ41VxD b6WN2zMq4Nm5TobG/uCGdOiY+BAlzzpOBzqNQ73j9XZdJNh3uDgyTai3qzC69bNUozjX uy6Q== 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=1v97PnDIrhxByjUCVxjqIOe26eIkHOTAzNcJ3Z1LSCM=; b=cqBieOJJ93u36cOSSHbSC1Z+A8mRRoptXDa3APjoqdxq6AdE9dIjDkGU6X319Fz9vz URY+wdz6+/f6FPaCQIYHJHBV+dictGckxdvo0AzvouP5C08Gg6h/V5hcSQcXVMuyjIKE Yh4UpCm61sUEMqfAgFdo2VB5w1i+sdCk0XSKI8bKfA1ncyQwZifIY6vrO/gOoYHJGRPu IPsCGDsaHeOKYOZJ6/CabCYblyCSO2XnQ7XPFksXxNiLXUfenI40pXOLoJEATGxCS8vd 7MX/reggQJCQ4C06uoSxXGyadFGcnClfgaauL4dY2PxQeDj5FLBIMrMH8SIGdPVTbxw6 jfZA== ARC-Authentication-Results: i=1; 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 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 c3si16133424qkb.54.2017.05.31.06.08.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 31 May 2017 06:08: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 sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:59320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG3Mv-0007SP-6r for patch@linaro.org; Wed, 31 May 2017 09:08:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG3Ma-0007S6-Fc for qemu-devel@nongnu.org; Wed, 31 May 2017 09:08:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG3MZ-0003bt-7L for qemu-devel@nongnu.org; Wed, 31 May 2017 09:08:36 -0400 Received: from mail-lf0-x232.google.com ([2a00:1450:4010:c07::232]:35553) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dG3MY-0003bT-W4 for qemu-devel@nongnu.org; Wed, 31 May 2017 09:08:35 -0400 Received: by mail-lf0-x232.google.com with SMTP id c184so3857929lfe.2 for ; Wed, 31 May 2017 06:08:34 -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=1v97PnDIrhxByjUCVxjqIOe26eIkHOTAzNcJ3Z1LSCM=; b=evZkuvKhphpv82/JZuOI+//5zng4ZCV+nrPT2mBe4WIrUsfqY0vbr/SFQH8vMPG5KY uCAUu5QkpwIqZHYWCj2GBxdpVwIYki2jQAzTPYYpJnHC6V1WdwXIUm0FzK1/N+BKC+gk TH86h1pNItQQfsNdhVZJqXP3D7qUdI0LEqzOM= 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=1v97PnDIrhxByjUCVxjqIOe26eIkHOTAzNcJ3Z1LSCM=; b=b7SgWSixbxVJCCrdqy49XDBIvOnAW8ddCJ2Im2JH6DKTToIb1u4kH2W0942oLnQvYJ oh9zYlo5w/Hi4l/HL5iTWLgCHwqi1NVEjfnAchK/UybFYho91tSXIQ5U7KduH2oL156S QJkg67Du58M7qnUTeg40QmlRz+WrCJovczZWyOq1oLCiBA0n+mKCSvih57Gnz+AuTm8K CaQ843wAuV2Kq7a+8WNcPyyA5ZBCuhrk3z4DdCqSYu+fRBhyaHiYBerzsbOtAiN9TMYY QDJ1aAWWnqF2RWtdhuAwJo36GKgyvtP7XPND/nWG6qKhnE9bzc5miXUw7OpTrq219Yh0 Wc1g== X-Gm-Message-State: AODbwcBGeO3oe6wAOnvPq3cBflVfl9x0AfgR+J0kCVW+cYPoJ9S9yNZY yPkQ2XgJUMslqhiSOd2Y1g== X-Received: by 10.46.15.10 with SMTP id 10mr7836071ljp.12.1496236113559; Wed, 31 May 2017 06:08:33 -0700 (PDT) Received: from localhost.localdomain (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id o101sm3741766lfg.3.2017.05.31.06.08.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 May 2017 06:08:32 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 16:08:14 +0300 Message-Id: <562a20b4ef63bdde6e2e5bac0da02302aeb5299f.1496234766.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::232 Subject: [Qemu-devel] [PULL 02/15] linux-user: fix eventfd 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@linaro.org, Laurent Vivier , stefanha@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier When a fd is opened using eventfd(), a read provides a 64bit counter in the host byte order, and a write increase the internal counter by the provided 64bit value. Signed-off-by: Laurent Vivier Signed-off-by: Riku Voipio --- linux-user/syscall.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) -- 2.11.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b2b563e388..2da8426aaa 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7671,6 +7671,28 @@ static target_timer_t get_timer_id(abi_long arg) return timerid; } +static abi_long swap_data_eventfd(void *buf, size_t len) +{ + uint64_t *counter = buf; + int i; + + if (len < sizeof(uint64_t)) { + return -EINVAL; + } + + for (i = 0; i < len; i += sizeof(uint64_t)) { + *counter = tswap64(*counter); + counter++; + } + + return len; +} + +static TargetFdTrans target_eventfd_trans = { + .host_to_target_data = swap_data_eventfd, + .target_to_host_data = swap_data_eventfd, +}; + /* do_syscall() should always have a single exit point at the end so that actions, such as logging of syscall results, can be performed. All errnos that do_syscall() returns must be -TARGET_. */ @@ -11876,7 +11898,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #if defined(TARGET_NR_eventfd) case TARGET_NR_eventfd: ret = get_errno(eventfd(arg1, 0)); - fd_trans_unregister(ret); + fd_trans_register(ret, &target_eventfd_trans); break; #endif #if defined(TARGET_NR_eventfd2) @@ -11890,7 +11912,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, host_flags |= O_CLOEXEC; } ret = get_errno(eventfd(arg1, host_flags)); - fd_trans_unregister(ret); + fd_trans_register(ret, &target_eventfd_trans); break; } #endif