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: 9164667 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7C9E260467 for ; Wed, 8 Jun 2016 13:36:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70395282DC for ; Wed, 8 Jun 2016 13:36:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64A0E28305; Wed, 8 Jun 2016 13:36:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FSL_HELO_HOME, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 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 mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3BA0B282DC for ; Wed, 8 Jun 2016 13:36:12 +0000 (UTC) Received: from localhost ([::1]:57037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdeV-0000WX-6L for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Jun 2016 09:36:11 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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