From patchwork Wed Jun 8 13:30:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 69639 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2500580qgf; Wed, 8 Jun 2016 06:38:00 -0700 (PDT) X-Received: by 10.55.217.24 with SMTP id u24mr4391998qki.93.1465393080081; Wed, 08 Jun 2016 06:38:00 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q70si661416qkc.252.2016.06.08.06.38.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:38:00 -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]:57042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdgF-0001ac-Fn for patch@linaro.org; Wed, 08 Jun 2016 09:37:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZW-0004P2-0P for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAdZT-0005oM-TG for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:00 -0400 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]:33941) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZT-0005o8-Lm for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:59 -0400 Received: by mail-lf0-x229.google.com with SMTP id s186so5875105lfs.1 for ; Wed, 08 Jun 2016 06:30:59 -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=T3kOWh3xpzaOxNtRvQx97kR6eI7Jhb5NZrkBsp1O85w=; b=bNmUG1S48Xo2aeEoGKDU2WM7CczFK/xsGPHqxVoSXVklqdfnIE+LQ1iiPwxNzax8oF 3yRPpDQ6ldJzzhhcoyey0uOoJUulrIVYkmFAgKzcqfiV5JMpNVnygq6WlVHlMgcJBunW 6Bf27J+FMHbp9x4xktt2FGeUVAyTIyFJDJCkc= 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=T3kOWh3xpzaOxNtRvQx97kR6eI7Jhb5NZrkBsp1O85w=; b=Wj7zN77CSacwE0nJ7AniJPohzGHmw50r6F9NNqPw8aKEY2SK8RXbM51EETaFQoevG0 8M97EcwVuNFlWXw7S8YMowiT+sqSg6aNAvRHqlXSJPTwF5VhfzwyHPDU2SodRwKdfvIW V7Y+Yt8RLVXvGv64wpQmr8PWOy3Fl2QZCPNTJ9+P3zdPWy3wPdTGfH037ZjtvNygOAdO yD63ZjxvhUSJX2PzM7gZQiDmut7Vof29rwjcNqKMkwNDp0fVDrgH/Msb9tcUlcnoAYla R9oM/V1OHHtgzXze3l3Z4TtEvFKBb3vPUxYLZkLWEK5CrIUyV0skrQw1AEr79amE5Y6y MkSg== X-Gm-Message-State: ALyK8tLLDpFECMebaI0qPGGV2MmeJoxRTYX7jaJNqlp5VLYGk///zlDTe0bbmrwROFi7mcyX X-Received: by 10.46.1.197 with SMTP id f66mr1381214lji.52.1465392658961; Wed, 08 Jun 2016 06:30:58 -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.30.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:30:58 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 16:30:07 +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::229 Subject: [Qemu-devel] [PULL 26/44] linux-user: Fix NR_fadvise64 and NR_fadvise64_64 for 32-bit guests 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 Fix errors in the implementation of NR_fadvise64 and NR_fadvise64_64 for 32-bit guests, which pass their off_t values in register pairs. We can't use the 64-bit code path for this, so split out the 32-bit cases, so that we can correctly handle the "only offset is 64-bit" and "both offset and length are 64-bit" syscall flavours, and "uses aligned register pairs" and "does not" flavours of target. Signed-off-by: Peter Maydell Reviewed-by: Laurent Vivier Signed-off-by: Riku Voipio --- linux-user/syscall.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) -- 2.1.4 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 8c08e7c..5cff9f7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9981,6 +9981,44 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = -host_to_target_errno(ret); break; #endif + +#if TARGET_ABI_BITS == 32 + +#ifdef TARGET_NR_fadvise64_64 + case TARGET_NR_fadvise64_64: + /* 6 args: fd, offset (high, low), len (high, low), advice */ + if (regpairs_aligned(cpu_env)) { + /* offset is in (3,4), len in (5,6) and advice in 7 */ + arg2 = arg3; + arg3 = arg4; + arg4 = arg5; + arg5 = arg6; + arg6 = arg7; + } + ret = -host_to_target_errno(posix_fadvise(arg1, + target_offset64(arg2, arg3), + target_offset64(arg4, arg5), + arg6)); + break; +#endif + +#ifdef TARGET_NR_fadvise64 + case TARGET_NR_fadvise64: + /* 5 args: fd, offset (high, low), len, advice */ + if (regpairs_aligned(cpu_env)) { + /* offset is in (3,4), len in 5 and advice in 6 */ + arg2 = arg3; + arg3 = arg4; + arg4 = arg5; + arg5 = arg6; + } + ret = -host_to_target_errno(posix_fadvise(arg1, + target_offset64(arg2, arg3), + arg4, arg5)); + break; +#endif + +#else /* not a 32-bit ABI */ #if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_fadvise64) #ifdef TARGET_NR_fadvise64_64 case TARGET_NR_fadvise64_64: @@ -10000,6 +10038,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = -posix_fadvise(arg1, arg2, arg3, arg4); break; #endif +#endif /* end of 64-bit ABI fadvise handling */ + #ifdef TARGET_NR_madvise case TARGET_NR_madvise: /* A straight passthrough may not be safe because qemu sometimes