From patchwork Wed May 31 13:08:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 100746 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp292841obc; Wed, 31 May 2017 06:09:01 -0700 (PDT) X-Received: by 10.233.222.134 with SMTP id s128mr28525704qkf.190.1496236141598; Wed, 31 May 2017 06:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496236141; cv=none; d=google.com; s=arc-20160816; b=JgNZE6BitwmppZawkmBeJVl1EDPyzsVRRQr+LhNfJk2Uhj1ku84awgKXkIB/URYBFs 25JASuGNnvfYS89T+1zNkYx5gx8mcKenYYi+g307x9zaiWgVsdbnG2zarwsMEduvJ41W UXfUJTrhG/Rl2S423DVNj7Dm+bbwOgY6Uwz+uc6NtaBSGASgTctSQRqO3WQYVbLm04a2 WM9OVBk65hWiagm69akaWgpH5czmtdK69Rjtx9PphfNaiqfrTpUn7IOYBaWAFl2xl8vO ykkmD5LoKZENu+P0I9b7LVOqF1AsClGsWDfwnqd+gm0FuH0bDZO7SjHP3tktJrD8bdwr sGIw== 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=RMgOLgG5+c/J+Ro9pPRuDczuj3GrHSRqyBZcuJsbxVE=; b=V5VhQEdkr1e9kcNWSLLbw3mNVuzQySpKK3K8Wjctv14CU0OFUk+/uk8RAPuLOjkgfF a5K5dFfKCiaLL1hehqKw2YlR6Ixplows1jrzFwr0wEBTQHC+9t6RSIUZeKvZhTwJbSQr eR3zmdbfkYtsZDDyBSnJhFwQK8A0Ro3H82PaN6Fon0xwvJ6pAO0hFNJqxObdA3rPO7+P cpbmbNzt6YIg+yTbQdVONRtPWlaplUcCTDFwDQ2O/G5snGZUJTRxDhK98TAwier2eQFo 1tgk5AbJaONEQdggAmJAzmjsC6zN50mpKOQqYesgaFnqeE/x219h0oN3bHY5y3hZIh6b vt0w== 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 d27si16180907qtb.47.2017.05.31.06.09.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 31 May 2017 06:09:01 -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]:59322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG3Mx-0007TD-0g for patch@linaro.org; Wed, 31 May 2017 09:08:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG3Ma-0007S5-Bk 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 1dG3MX-0003bN-N2 for qemu-devel@nongnu.org; Wed, 31 May 2017 09:08:36 -0400 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]:35899) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dG3MX-0003au-Fw for qemu-devel@nongnu.org; Wed, 31 May 2017 09:08:33 -0400 Received: by mail-lf0-x229.google.com with SMTP id h4so8613228lfj.3 for ; Wed, 31 May 2017 06:08:33 -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=RMgOLgG5+c/J+Ro9pPRuDczuj3GrHSRqyBZcuJsbxVE=; b=UOhqYglHdi1P6bL4mtfwI9h6TLTluDK+X8qloa9rKVPk2/Cw89l4A7/UP+De1SpyA2 32rRozdAQk1etJUXVjy+8ex2spuBqtznHBsTIfD8puH5cewH8v7SgmoHOTy0aY2si0C9 1Wx115maE4APGdGcaFs61wbgG1uRl5kVPdoRk= 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=RMgOLgG5+c/J+Ro9pPRuDczuj3GrHSRqyBZcuJsbxVE=; b=qBHky6OJ1rbIMP/RUeHUaWx2glOwp4HaK0khq3vtLhKLYlMxlNHGLX1k6ybdWmEfms kdfP3JrgX/S2YctuNdI1i7mA6r5EWUokVMMLzlRhjGkuyd7SQXuCceF+B0Gk43z/1cr6 X3kNG+U+RiGjkulO5UmMHGxOwdcEnVJlShd6cfXPYRbEEpGTbOwjrc+buebYrvauMv1H Segok8dh2CEfDYr+yzSgVAnw3MnpTJoxZrTB/9Ndb0czr7dgAG0eSj6WXY6QAkk2s5m0 613kfO+tKue/ANkTabYT4apodFXOYUtYngpz7fIK1llwNA7VNH7hzNEgXIlQkOPqPucF nScg== X-Gm-Message-State: AODbwcA8h3gtH/i8bDyYHFsfBtr9hxg6wehUWEG/X04hyN3TgSdd5WYQ YuOAbyvkMY4uHwHMdXEmdg== X-Received: by 10.46.20.9 with SMTP id u9mr8704137ljd.14.1496236112046; Wed, 31 May 2017 06:08:32 -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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 May 2017 06:08:30 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 16:08:13 +0300 Message-Id: <04b9bcf911af2b4563b1f1b2e8a103b796dcc9eb.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::229 Subject: [Qemu-devel] [PULL 01/15] linux-user: call fd_trans_target_to_host_data() for write() 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 As for sendmsg() or sendto(), we must call the target to host data translator if it is defined. This is needed for eventfd(): the write() syscall allows to add a value to the internal counter, and so, it must be byte-swapped to the host order. Signed-off-by: Laurent Vivier Signed-off-by: Riku Voipio --- linux-user/syscall.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.11.0 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cec8428589..b2b563e388 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7767,7 +7767,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_write: if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; - ret = get_errno(safe_write(arg1, p, arg3)); + if (fd_trans_target_to_host_data(arg1)) { + void *copy = g_malloc(arg3); + memcpy(copy, p, arg3); + ret = fd_trans_target_to_host_data(arg1)(copy, arg3); + if (ret >= 0) { + ret = get_errno(safe_write(arg1, copy, ret)); + } + g_free(copy); + } else { + ret = get_errno(safe_write(arg1, p, arg3)); + } unlock_user(p, arg2, 0); break; #ifdef TARGET_NR_open