From patchwork Sun Jun 10 03:01:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 927289 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="MM9gzF8U"; 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 413Mvb24CXz9s1B for ; Sun, 10 Jun 2018 14:03:39 +1000 (AEST) Received: from localhost ([::1]:42511 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrZo-0006uH-Sj for incoming@patchwork.ozlabs.org; Sun, 10 Jun 2018 00:03:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfV-0004AM-Rw for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfU-0004Tt-JY for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:25 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35885) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfU-0004SS-AV for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:24 -0400 Received: by mail-pf0-x241.google.com with SMTP id a12-v6so8499859pfi.3 for ; Sat, 09 Jun 2018 20:05:24 -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=necN1lO+nHCcY51p1EFxrAesRsn55Shjd6qdfMOwjsg=; b=MM9gzF8U9JSe63RMFVVqsvXvuh/7WEsofGgCSlAtz/fLP8RzpL7USVSarGHiCtDJt3 iyQ+6333TQowtaZJiGCc+txkA6OOGEoBxVdbEh/k4OMsjwQ8RMhC3L+ht72YhrVK0/+U +QkVJy21BM50VvobISm+uDrpCW6/cCH41HsvA= 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=necN1lO+nHCcY51p1EFxrAesRsn55Shjd6qdfMOwjsg=; b=US7IDC7SDM/AOcJ4Sj0fK92O75pqUM7ZTTTKXzQBjXdU9AYsz/yxiQX0mbISctfAll CHgzkf72ILctFmDs/Z6Yb7ZNa+ONkiM0o1XqxSmkeOTJoxamzGD8cfK5zDDjTwpYfAne O9NWjmnjqTEZ9e7giTz+JoIiFmWu+4IyXRnZYQGQ1gkB5c/ffihX2RDfQdbVzzc1Yw0B xzNO/+XWiOkgSY2QFsTaWzYtoc7EsSObdHq4LUrJ9j1qCGGBEY2yic5qT3ZPjKAhjibE hNsyFJiclsDPgAHgwdWSUQn0ao+DhpHQ8a2NN6HZyIMenlqg0rargFn2PSPlvMk5qun7 zUzg== X-Gm-Message-State: APt69E2Uf2Nr+kUJIt+d1gUcFhaGD6/FVjjrQBsMe2zXNPxyCVKaJEs4 V/GsULB12gYNuIfxNPEi5Ug8S3c0MTw= X-Google-Smtp-Source: ADUXVKJebiRtKkj/xYipqArew8LNBMxf/kQ5ylJcA3t8WsJZuynZl2N9UPw+mS6iK6KtMZr0pzy0Mg== X-Received: by 2002:a65:4cc3:: with SMTP id n3-v6mr10271520pgt.98.1528599923176; Sat, 09 Jun 2018 20:05:23 -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.05.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:57 -1000 Message-Id: <20180610030220.3777-86-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:c00::241 Subject: [Qemu-devel] [PATCH v2 085/108] linux-user: Split out cacheflush, fcntl64, getpagesize, madvise 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 madvise; remove the ifdef. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 144 ++++++++++++++++++++++++------------------- 1 file changed, 80 insertions(+), 64 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5f056cf660..bcddb28947 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7675,6 +7675,14 @@ IMPL(brk) return do_brk(arg1); } +#ifdef TARGET_NR_cacheflush +IMPL(cacheflush) +{ + /* Self-modifying code is handled automatically, so nothing needed. */ + return 0; +} +#endif + IMPL(capget) { struct target_user_cap_header *target_header; @@ -8269,6 +8277,52 @@ IMPL(fcntl) } #endif +#if TARGET_ABI_BITS == 32 +IMPL(fcntl64) +{ + int cmd; + struct flock64 fl; + from_flock64_fn *copyfrom = copy_from_user_flock64; + to_flock64_fn *copyto = copy_to_user_flock64; + abi_long ret; + +#ifdef TARGET_ARM + if (!((CPUARMState *)cpu_env)->eabi) { + copyfrom = copy_from_user_oabi_flock64; + copyto = copy_to_user_oabi_flock64; + } +#endif + cmd = target_to_host_fcntl_cmd(arg2); + if (cmd == -TARGET_EINVAL) { + return -TARGET_EINVAL; + } + + switch (arg2) { + case TARGET_F_GETLK64: + ret = copyfrom(&fl, arg3); + if (ret) { + return ret; + } + ret = get_errno(fcntl(arg1, cmd, &fl)); + if (ret == 0) { + ret = copyto(arg3, &fl); + } + return ret; + + case TARGET_F_SETLK64: + case TARGET_F_SETLKW64: + ret = copyfrom(&fl, arg3); + if (ret) { + return ret; + } + return get_errno(safe_fcntl(arg1, cmd, &fl)); + + default: + return do_fcntl(arg1, arg2, arg3); + } +} +#endif + IMPL(fdatasync) { return get_errno(fdatasync(arg1)); @@ -8709,6 +8763,13 @@ IMPL(getitimer) return ret; } +#ifdef TARGET_NR_getpagesize +IMPL(getpagesize) +{ + return TARGET_PAGE_SIZE; +} +#endif + #ifdef TARGET_NR_getpeername IMPL(getpeername) { @@ -9247,6 +9308,15 @@ IMPL(lstat64) } #endif +IMPL(madvise) +{ + /* A straight passthrough may not be safe because qemu sometimes + turns private file-backed mappings into anonymous mappings. + This will break MADV_DONTNEED. + This is a hint, so ignoring and returning success is ok. */ + return 0; +} + IMPL(mincore) { void *a, *p; @@ -12114,70 +12184,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_madvise - case TARGET_NR_madvise: - /* A straight passthrough may not be safe because qemu sometimes - turns private file-backed mappings into anonymous mappings. - This will break MADV_DONTNEED. - This is a hint, so ignoring and returning success is ok. */ - return 0; -#endif -#if TARGET_ABI_BITS == 32 - case TARGET_NR_fcntl64: - { - int cmd; - struct flock64 fl; - from_flock64_fn *copyfrom = copy_from_user_flock64; - to_flock64_fn *copyto = copy_to_user_flock64; - -#ifdef TARGET_ARM - if (!((CPUARMState *)cpu_env)->eabi) { - copyfrom = copy_from_user_oabi_flock64; - copyto = copy_to_user_oabi_flock64; - } -#endif - - cmd = target_to_host_fcntl_cmd(arg2); - if (cmd == -TARGET_EINVAL) { - return cmd; - } - - switch(arg2) { - case TARGET_F_GETLK64: - ret = copyfrom(&fl, arg3); - if (ret) { - break; - } - ret = get_errno(fcntl(arg1, cmd, &fl)); - if (ret == 0) { - ret = copyto(arg3, &fl); - } - break; - - case TARGET_F_SETLK64: - case TARGET_F_SETLKW64: - ret = copyfrom(&fl, arg3); - if (ret) { - break; - } - ret = get_errno(safe_fcntl(arg1, cmd, &fl)); - break; - default: - ret = do_fcntl(arg1, arg2, arg3); - break; - } - return ret; - } -#endif -#ifdef TARGET_NR_cacheflush - case TARGET_NR_cacheflush: - /* self-modifying code is handled automatically, so nothing needed */ - return 0; -#endif -#ifdef TARGET_NR_getpagesize - case TARGET_NR_getpagesize: - return TARGET_PAGE_SIZE; -#endif case TARGET_NR_gettid: return get_errno(gettid()); #ifdef TARGET_NR_readahead @@ -13179,6 +13185,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(bind); #endif SYSCALL(brk); +#ifdef TARGET_NR_cacheflush + SYSCALL(cacheflush); +#endif SYSCALL(capget); SYSCALL(capset); #ifdef CONFIG_CLOCK_ADJTIME @@ -13236,6 +13245,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(fchownat); #ifdef TARGET_NR_fcntl SYSCALL(fcntl); +#endif +#if TARGET_ABI_BITS == 32 + SYSCALL(fcntl64); #endif SYSCALL(fdatasync); SYSCALL(flock); @@ -13292,6 +13304,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(getgroups32); #endif SYSCALL(getitimer); +#ifdef TARGET_NR_getpagesize + SYSCALL(getpagesize); +#endif #ifdef TARGET_NR_getpeername SYSCALL(getpeername); #endif @@ -13372,6 +13387,7 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_lstat64 SYSCALL(lstat64); #endif + SYSCALL(madvise); SYSCALL(mincore); #ifdef TARGET_NR_mkdir SYSCALL(mkdir);