From patchwork Sun Jun 10 03:01:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138112 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2588258lji; Sat, 9 Jun 2018 20:29:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJpooRrzVk9Wp4zD9nqlcwFcI5HsNojuJ7mOixG61GBHvx2uehOCpl9sLeo+VyrWjjGb3B1 X-Received: by 2002:a37:8943:: with SMTP id l64-v6mr10603680qkd.134.1528601347145; Sat, 09 Jun 2018 20:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528601347; cv=none; d=google.com; s=arc-20160816; b=M0ipMSHYUaM+jGsklKdZiEiODn4W61fYuvZ6k7hU2H25g9/1j0I4Srrr2SpLac+nSs ts9EYlTJsQWrlux5a6TZWPwoctVHErpcLGsQvj13nGTPfClq0Et8XGCsb++zLjEoZKZ4 D4gXAycbJnkwVFHJNRWq8FFELE79/RcBM6u61iI8MopQ1fIZj95bb7oVwnUkPJGWL0w9 zt0G58yMuN1TbUQxldIy8J/TAyX9ykYvXtxL8c1DJwsHi+j5exzBQE7q6tqtuNJRmMNI Lod/94HN13xAxLjGbCssS/vjBybKYiz8AawTTgsTFLQ6Da2S/uyagQam9jRNJIK49xhY Tgtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=X1WxCmt0CcNso6cR9qzCWvyUwSVdM9PtMoZxkMDzt6g=; b=xsRb+dR3VShmEGlr9MvNE6TgWFMrqzmJoJg/4r5Ol1kPDwuxUlI5bhIRKXKr8K3/P7 MtpB7WYO5ciGfBgf8EMwiGim0/0uPLY+wRCxzHPI+HphUEIzFgEBggp0kvfxhRSxAPIE BVTyiKqWAtK5OXCApS7mrnGjwhVgZlD78IVlIPX/oiQCK1JdKMOlnVsUpxNa3j/sp6vu M+RUALYBvzAqhhiCGgFLmVJTpFBSWewErmrg8TazPoBX00npcG6MVy3xsH1r1LKg3G0F 4PDiAH945rsFvsPESk8uXE0gr4A0uFpLqCOY6jXPS9Q6LlrvcYar7BMhIUXeGTkJPcNf +6fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YJGyXx2Q; 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 sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o37-v6si1845386qtj.9.2018.06.09.20.29.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:29:07 -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 header.s=google header.b=YJGyXx2Q; 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 sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRr2Q-0007ML-Jv for patch@linaro.org; Sat, 09 Jun 2018 23:29:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqe2-0002hX-Qx for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqe0-0003c3-GK for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:54 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:45905) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqe0-0003bo-69 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:03:52 -0400 Received: by mail-pl0-x243.google.com with SMTP id c23-v6so10384472plz.12 for ; Sat, 09 Jun 2018 20:03:52 -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=X1WxCmt0CcNso6cR9qzCWvyUwSVdM9PtMoZxkMDzt6g=; b=YJGyXx2QgA6qiF5hC0tfTHbeUwFmwINHJfwDG5gioJ12FJzCd8KvxRuhyTXG491Y+0 os3qnoSNZ55RCNF6J6abD0p9HpzFk0SoZ52BJDhOT9qiqNNhazTA0hAYDPJyhuKd7WwK nRfJ5ZE7l+9tTtc0+ko5JnNrMKscOtuPL/XEw= 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=X1WxCmt0CcNso6cR9qzCWvyUwSVdM9PtMoZxkMDzt6g=; b=Gjuzcxq41MB13KioKeMTRrV1Zp3KPynBARWMXX9NN+u1zwA1wquZLybkX9cqVeMVSt rx65iKkB6MwFxWXfi7L0ps8f3LBlDPqP/ekdfpJVqpoYa1M3Ployy+XfqtZ5fiCfWh2M iWEJrZgS6aKyZWQZBzU6yrdJHEOv5oziKWVBOLgLICft41N+q/2jX8ptp5QEEEGyqKT5 beu0k+VLcXse4H/WdxCxNFoVQLuQXp/qMuS0lczx2f9uJYJTb+y0Qk1q22QcWcUUZcQG WYpzDhspNWZi1g+/yFWaMDdLNIYhnRWlSkh5/4Sh9WDq31lQk3xeWzLrtev5MGLrW3dB 9adA== X-Gm-Message-State: APt69E0XZnQgcSMsRqLFK9wMEg0gmFOjcDGNac5hn6oXCZ3DQ7jZhyt/ LQ9Oo/t86MO1kTC6hNULWeJhu5pxoz4= X-Received: by 2002:a17:902:301:: with SMTP id 1-v6mr12922652pld.127.1528599830959; Sat, 09 Jun 2018 20:03:50 -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.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:03:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:11 -1000 Message-Id: <20180610030220.3777-40-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:c01::243 Subject: [Qemu-devel] [PATCH v2 039/108] linux-user: Split out mprotect, mremap, msync, munmap 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All targets define all of these; remove the ifdefs. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 61 ++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 25 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a3374955da..7504ad74b5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8471,6 +8471,37 @@ IMPL(mount) return ret; } +IMPL(mprotect) +{ + /* Special hack to detect libc making the stack executable. */ + if (arg3 & PROT_GROWSDOWN) { + CPUState *cpu = ENV_GET_CPU(cpu_env); + TaskState *ts = cpu->opaque; + + if (arg1 >= ts->info->stack_limit && arg1 <= ts->info->start_stack) { + arg3 &= ~PROT_GROWSDOWN; + arg2 = arg2 + arg1 - ts->info->stack_limit; + arg1 = ts->info->stack_limit; + } + } + return get_errno(target_mprotect(arg1, arg2, arg3)); +} + +IMPL(mremap) +{ + return get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); +} + +IMPL(msync) +{ + return get_errno(msync(g2h(arg1), arg2, arg3)); +} + +IMPL(munmap) +{ + return get_errno(target_munmap(arg1, arg2)); +} + #ifdef CONFIG_OPEN_BY_HANDLE IMPL(name_to_handle_at) { @@ -9696,37 +9727,13 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, abi_long arg5, abi_long arg6, abi_long arg7, abi_long arg8) { - CPUState *cpu = ENV_GET_CPU(cpu_env); + CPUState *cpu __attribute__((unused)) = ENV_GET_CPU(cpu_env); abi_long ret; struct stat st; struct statfs stfs; void *p; switch(num) { - case TARGET_NR_munmap: - return get_errno(target_munmap(arg1, arg2)); - case TARGET_NR_mprotect: - { - TaskState *ts = cpu->opaque; - /* Special hack to detect libc making the stack executable. */ - if ((arg3 & PROT_GROWSDOWN) - && arg1 >= ts->info->stack_limit - && arg1 <= ts->info->start_stack) { - arg3 &= ~PROT_GROWSDOWN; - arg2 = arg2 + arg1 - ts->info->stack_limit; - arg1 = ts->info->stack_limit; - } - } - return get_errno(target_mprotect(arg1, arg2, arg3)); -#ifdef TARGET_NR_mremap - case TARGET_NR_mremap: - return get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5)); -#endif - /* ??? msync/mlock/munlock are broken for softmmu. */ -#ifdef TARGET_NR_msync - case TARGET_NR_msync: - return get_errno(msync(g2h(arg1), arg2, arg3)); -#endif #ifdef TARGET_NR_mlock case TARGET_NR_mlock: return get_errno(mlock(g2h(arg1), arg2)); @@ -12762,6 +12769,10 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(mmap2); #endif SYSCALL(mount); + SYSCALL(mprotect); + SYSCALL(mremap); + SYSCALL(msync); + SYSCALL(munmap); #ifdef CONFIG_OPEN_BY_HANDLE SYSCALL(name_to_handle_at); #endif