From patchwork Sun Jun 10 03:01:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 927243 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Savqus4i"; dkim-atps=neutral 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 413M965lRsz9ry1 for ; Sun, 10 Jun 2018 13:30:18 +1000 (AEST) Received: from localhost ([::1]:42320 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr3Y-0008Cw-CX for incoming@patchwork.ozlabs.org; Sat, 09 Jun 2018 23:30:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqe3-0002i7-9Y for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqe2-0003cc-7B for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:55 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:47032) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqe2-0003cM-1g for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:54 -0400 Received: by mail-pg0-x242.google.com with SMTP id d2-v6so8129647pga.13 for ; Sat, 09 Jun 2018 20:03:53 -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=QxGSXlqhVGnV3DO9GhiiNNbzyWrn3NgqnERUTAKyqCw=; b=Savqus4ilEky/EzdkHFzW3mBF6I9BmicTlRChWd7m16zVAXY5FexTyhPDC5CvF5bQZ ZmKkyDjkDkXpIl33qtmUDN558xtEtzneQ3s9ER52OjPsDxz1L5nAZdembpePw3Jx1pYQ r2JsG5i2UkAgSHJpjI3NX/tZQnvCtNq4y8slc= 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=QxGSXlqhVGnV3DO9GhiiNNbzyWrn3NgqnERUTAKyqCw=; b=ES82LSF/KwtFoeV9sw5YyyAqKkB+59UShab7bESdofkUcmqRQ8MXS9Qw+WqXnyBqsv kym3QkzNKBLRPZkugjsdrlAZLEvNXbrfmMeHY5c7LqSDIQaz8FQNPShgkx1m6VCUXGSy PphAPdcWr3W/vvju1p4NOu9d6W+TwVGC6ptnpmbxBjbe1AuoC4J+Aal0usht3yLjiZWE PNddDrdbGpAvxQU1Alb6pAccC3ZrikvC2CfcqcceykW0WW2jIW5hMX82lmFt9mtK+NmD ejV6qbnyukOd6rN2PnOCfJzbK8JJxly6YkYU0W+TROIbcVsMLsod2FPB5F6aa++ZBm8v 0ZRA== X-Gm-Message-State: APt69E3HfwgNlNIvYwb3qdAbIoNZ/6xUEp8OlPMiwNmT0AqnParFt9zI HIRPGPbZ8GNQ1JeVqvO7slwYaKlrTRM= X-Google-Smtp-Source: ADUXVKLVMuOcDAvRfNcBAGnh6t7HgEeOEDlTTqlKo5gP7/D1mX8rEQeJAiWSpIOlt7rLmV0oUDI+mQ== X-Received: by 2002:a63:2b15:: with SMTP id r21-v6mr10433772pgr.269.1528599832826; Sat, 09 Jun 2018 20:03:52 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.03.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:52 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:12 -1000 Message-Id: <20180610030220.3777-41-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH v2 040/108] linux-user: Split out mlock, mlockall, munlock, munlockall 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: laurent@vivier.eu Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" All targets define all of these; remove the ifdefs. Merge target_to_host_mlockall_arg into its only caller. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 62 ++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7504ad74b5..f79aebe869 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7144,21 +7144,6 @@ 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 - static inline abi_long host_to_target_stat64(void *cpu_env, abi_ulong target_addr, struct stat *host_st) @@ -8392,6 +8377,23 @@ IMPL(mknodat) return ret; } +IMPL(mlock) +{ + return get_errno(mlock(g2h(arg1), arg2)); +} + +IMPL(mlockall) +{ + int host_flags = 0; + if (arg1 & TARGET_MLOCKALL_MCL_CURRENT) { + host_flags |= MCL_CURRENT; + } + if (arg1 & TARGET_MLOCKALL_MCL_FUTURE) { + host_flags |= MCL_FUTURE; + } + return get_errno(mlockall(host_flags)); +} + #ifdef TARGET_NR_mmap IMPL(mmap) { @@ -8497,6 +8499,16 @@ IMPL(msync) return get_errno(msync(g2h(arg1), arg2, arg3)); } +IMPL(munlock) +{ + return get_errno(munlock(g2h(arg1), arg2)); +} + +IMPL(munlockall) +{ + return get_errno(munlockall()); +} + IMPL(munmap) { return get_errno(target_munmap(arg1, arg2)); @@ -9734,22 +9746,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_mlock - case TARGET_NR_mlock: - return get_errno(mlock(g2h(arg1), arg2)); -#endif -#ifdef TARGET_NR_munlock - case TARGET_NR_munlock: - return get_errno(munlock(g2h(arg1), arg2)); -#endif -#ifdef TARGET_NR_mlockall - case TARGET_NR_mlockall: - return get_errno(mlockall(target_to_host_mlockall_arg(arg1))); -#endif -#ifdef TARGET_NR_munlockall - case TARGET_NR_munlockall: - return get_errno(munlockall()); -#endif case TARGET_NR_truncate: if (!(p = lock_user_string(arg1))) return -TARGET_EFAULT; @@ -12762,6 +12758,8 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(mknod); #endif SYSCALL(mknodat); + SYSCALL(mlock); + SYSCALL(mlockall); #ifdef TARGET_NR_mmap SYSCALL(mmap); #endif @@ -12772,6 +12770,8 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(mprotect); SYSCALL(mremap); SYSCALL(msync); + SYSCALL(munlock); + SYSCALL(munlockall); SYSCALL(munmap); #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at);