From patchwork Fri Aug 15 11:01:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35450 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f197.google.com (mail-ig0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 09B12203C5 for ; Fri, 15 Aug 2014 11:15:10 +0000 (UTC) Received: by mail-ig0-f197.google.com with SMTP id r2sf4092123igi.0 for ; Fri, 15 Aug 2014 04:15:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=vyTAyykrQORHyfpSqxbxulZuI49AQB4uhWU29t3BNq8=; b=lrUD9AxlNLzx73UiunlBe3J1ie7fvX/jrTvmIzikkf9hXCMSQsN1BwbrzUOYDCD1a6 MxrfR2Tidf5MgINOabGmkt14CNuvWZv3SA90oGgx8eosAXQwrBYoU6FHxLVhPwl0teXp YR7H/NISxbmZ4FiB0l3Agcw+qh7kIFl/wWSf0E5DKZufoUSWRUviniCErVchsxlD5I2u ftZxjMZ+rRnROIuqK68VtA/9K7rvrpSQKbbry/0VrSwWhkoungw4L/8WlyMcJqb9Hhld 1V41H+8gDupM2UgcEBygMDUXPOcwyZ3PNTtjvgok/lRbuG+bcx6fmx9CtG4QHblS4AiB XzBg== X-Gm-Message-State: ALoCoQld/yT/Y9McsEPZcMalppilveOAdDRCdIM7Pdw374Qtrj5M1YQ7WSFPbYmUgnzGEE6bEg7p X-Received: by 10.182.171.67 with SMTP id as3mr9012115obc.34.1408101310196; Fri, 15 Aug 2014 04:15:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.18.193 with SMTP id 59ls1347190qgf.7.gmail; Fri, 15 Aug 2014 04:15:10 -0700 (PDT) X-Received: by 10.224.43.10 with SMTP id u10mr26797019qae.20.1408101310036; Fri, 15 Aug 2014 04:15:10 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id y64si11350851qgy.116.2014.08.15.04.15.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:15:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id le20so2790442vcb.28 for ; Fri, 15 Aug 2014 04:15:09 -0700 (PDT) X-Received: by 10.52.28.40 with SMTP id y8mr326359vdg.60.1408101309798; Fri, 15 Aug 2014 04:15:09 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp104716vcb; Fri, 15 Aug 2014 04:15:09 -0700 (PDT) X-Received: by 10.224.92.83 with SMTP id q19mr25863449qam.29.1408101308805; Fri, 15 Aug 2014 04:15:08 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o40si11381884qga.46.2014.08.15.04.15.08 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:15:08 -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; Received: from localhost ([::1]:58699 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFTQ-0001Z5-8f for patch@linaro.org; Fri, 15 Aug 2014 07:15:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGh-0004xT-HT for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:02:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIFGV-000740-Go for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:59 -0400 Received: from afflict.kos.to ([92.243.29.197]:57617) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGV-00072o-79 for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:47 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 7094926698; Fri, 15 Aug 2014 13:01:45 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 15 Aug 2014 14:01:40 +0300 Message-Id: <5f4d10a571ddc09f03b789ab64def4ef02b30f36.1408100160.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: Peter Maydell , Tom Musta Subject: [Qemu-devel] [PULL 22/24] linux-user: Support target-to-host translation of mlockall argument X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Tom Musta The argument to the mlockall system call is not necessarily the same on all platforms and thus may require translation prior to passing to the host. For example, PowerPC 64 bit platforms define values for MCL_CURRENT (0x2000) and MCL_FUTURE (0x4000) which are different from Intel platforms (0x1 and 0x2, respectively) Signed-off-by: Tom Musta Signed-off-by: Riku Voipio --- linux-user/aarch64/syscall.h | 2 ++ linux-user/alpha/syscall.h | 2 ++ linux-user/arm/syscall.h | 2 ++ linux-user/cris/syscall.h | 2 ++ linux-user/i386/syscall.h | 2 ++ linux-user/m68k/syscall.h | 2 ++ linux-user/microblaze/syscall.h | 2 ++ linux-user/mips/syscall.h | 2 ++ linux-user/mips64/syscall.h | 2 ++ linux-user/openrisc/syscall.h | 2 ++ linux-user/ppc/syscall.h | 2 ++ linux-user/s390x/syscall.h | 2 ++ linux-user/sh4/syscall.h | 2 ++ linux-user/sparc/syscall.h | 2 ++ linux-user/sparc64/syscall.h | 2 ++ linux-user/syscall.c | 17 ++++++++++++++++- linux-user/unicore32/syscall.h | 2 ++ linux-user/x86_64/syscall.h | 2 ++ 18 files changed, 50 insertions(+), 1 deletion(-) diff --git a/linux-user/aarch64/syscall.h b/linux-user/aarch64/syscall.h index d1f4823..dc72a15 100644 --- a/linux-user/aarch64/syscall.h +++ b/linux-user/aarch64/syscall.h @@ -9,3 +9,5 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "3.8.0" #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 diff --git a/linux-user/alpha/syscall.h b/linux-user/alpha/syscall.h index 3adedeb..245cff2 100644 --- a/linux-user/alpha/syscall.h +++ b/linux-user/alpha/syscall.h @@ -253,3 +253,5 @@ struct target_pt_regs { #define TARGET_UAC_NOFIX 2 #define TARGET_UAC_SIGBUS 4 #define TARGET_MINSIGSTKSZ 4096 +#define TARGET_MLOCKALL_MCL_CURRENT 0x2000 +#define TARGET_MLOCKALL_MCL_FUTURE 0x4000 diff --git a/linux-user/arm/syscall.h b/linux-user/arm/syscall.h index cdadb0c..3844a96 100644 --- a/linux-user/arm/syscall.h +++ b/linux-user/arm/syscall.h @@ -46,3 +46,5 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 diff --git a/linux-user/cris/syscall.h b/linux-user/cris/syscall.h index a75bcc4..2957b0d 100644 --- a/linux-user/cris/syscall.h +++ b/linux-user/cris/syscall.h @@ -40,5 +40,7 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS2 #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 #endif diff --git a/linux-user/i386/syscall.h b/linux-user/i386/syscall.h index acf6856..906aaac 100644 --- a/linux-user/i386/syscall.h +++ b/linux-user/i386/syscall.h @@ -148,3 +148,5 @@ struct target_vm86plus_struct { #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 diff --git a/linux-user/m68k/syscall.h b/linux-user/m68k/syscall.h index f8553f8..9218493 100644 --- a/linux-user/m68k/syscall.h +++ b/linux-user/m68k/syscall.h @@ -19,5 +19,7 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 void do_m68k_simcall(CPUM68KState *, int); diff --git a/linux-user/microblaze/syscall.h b/linux-user/microblaze/syscall.h index 2a5e160..3c1ed27 100644 --- a/linux-user/microblaze/syscall.h +++ b/linux-user/microblaze/syscall.h @@ -50,5 +50,7 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 #endif diff --git a/linux-user/mips/syscall.h b/linux-user/mips/syscall.h index 0b4662c..35ca23b 100644 --- a/linux-user/mips/syscall.h +++ b/linux-user/mips/syscall.h @@ -229,3 +229,5 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 diff --git a/linux-user/mips64/syscall.h b/linux-user/mips64/syscall.h index 39b8bed..6733107 100644 --- a/linux-user/mips64/syscall.h +++ b/linux-user/mips64/syscall.h @@ -226,3 +226,5 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 diff --git a/linux-user/openrisc/syscall.h b/linux-user/openrisc/syscall.h index e5e6180..8ac0365 100644 --- a/linux-user/openrisc/syscall.h +++ b/linux-user/openrisc/syscall.h @@ -25,3 +25,5 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 diff --git a/linux-user/ppc/syscall.h b/linux-user/ppc/syscall.h index 5311cc6..0daf5cd 100644 --- a/linux-user/ppc/syscall.h +++ b/linux-user/ppc/syscall.h @@ -71,3 +71,5 @@ struct target_revectored_struct { #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 0x2000 +#define TARGET_MLOCKALL_MCL_FUTURE 0x4000 diff --git a/linux-user/s390x/syscall.h b/linux-user/s390x/syscall.h index b11a3b2..35f170a 100644 --- a/linux-user/s390x/syscall.h +++ b/linux-user/s390x/syscall.h @@ -25,3 +25,5 @@ struct target_pt_regs { #define TARGET_CLONE_BACKWARDS2 #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 diff --git a/linux-user/sh4/syscall.h b/linux-user/sh4/syscall.h index 285ecf3..7aa4f23 100644 --- a/linux-user/sh4/syscall.h +++ b/linux-user/sh4/syscall.h @@ -13,3 +13,5 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 diff --git a/linux-user/sparc/syscall.h b/linux-user/sparc/syscall.h index ae40744..58573b9 100644 --- a/linux-user/sparc/syscall.h +++ b/linux-user/sparc/syscall.h @@ -16,3 +16,5 @@ struct target_pt_regs { */ #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 4096 +#define TARGET_MLOCKALL_MCL_CURRENT 0x2000 +#define TARGET_MLOCKALL_MCL_FUTURE 0x4000 diff --git a/linux-user/sparc64/syscall.h b/linux-user/sparc64/syscall.h index 816a00f..8398d3f 100644 --- a/linux-user/sparc64/syscall.h +++ b/linux-user/sparc64/syscall.h @@ -17,3 +17,5 @@ struct target_pt_regs { */ #define TARGET_CLONE_BACKWARDS #define TARGET_MINSIGSTKSZ 4096 +#define TARGET_MLOCKALL_MCL_CURRENT 0x2000 +#define TARGET_MLOCKALL_MCL_FUTURE 0x4000 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e4be32c..c4f6454 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4968,6 +4968,21 @@ static inline abi_long target_to_host_sigevent(struct sigevent *host_sevp, return 0; } +#if defined(TARGET_NR_mlockall) +static inline int target_to_host_mlockall_arg(int arg) +{ + int result = 0; + + if (arg & TARGET_MLOCKALL_MCL_CURRENT) { + result |= MCL_CURRENT; + } + if (arg & TARGET_MLOCKALL_MCL_FUTURE) { + result |= MCL_FUTURE; + } + return result; +} +#endif + #if defined(TARGET_NR_stat64) || defined(TARGET_NR_newfstatat) static inline abi_long host_to_target_stat64(void *cpu_env, abi_ulong target_addr, @@ -6890,7 +6905,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #endif #ifdef TARGET_NR_mlockall case TARGET_NR_mlockall: - ret = get_errno(mlockall(arg1)); + ret = get_errno(mlockall(target_to_host_mlockall_arg(arg1))); break; #endif #ifdef TARGET_NR_munlockall diff --git a/linux-user/unicore32/syscall.h b/linux-user/unicore32/syscall.h index 3ed6237..385a975 100644 --- a/linux-user/unicore32/syscall.h +++ b/linux-user/unicore32/syscall.h @@ -54,5 +54,7 @@ struct target_pt_regs { #define UNAME_MINIMUM_RELEASE "2.6.32" #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 #endif /* __UC32_SYSCALL_H__ */ diff --git a/linux-user/x86_64/syscall.h b/linux-user/x86_64/syscall.h index 5828b91..88b3c3f 100644 --- a/linux-user/x86_64/syscall.h +++ b/linux-user/x86_64/syscall.h @@ -98,3 +98,5 @@ struct target_msqid64_ds { #define TARGET_ARCH_GET_FS 0x1003 #define TARGET_ARCH_GET_GS 0x1004 #define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2