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: 769116 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wd9mJ2lTTz9s3T for ; Wed, 31 May 2017 23:09:20 +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="UOhqYglH"; dkim-atps=neutral Received: from localhost ([::1]:59322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG3NF-0007TD-U8 for incoming@patchwork.ozlabs.org; Wed, 31 May 2017 09:09:18 -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+incoming=patchwork.ozlabs.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(-) 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