From patchwork Sun Jun 10 03:01:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138128 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2595012lji; Sat, 9 Jun 2018 20:41:09 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLZv4b2yjArKGN50EOYMAOpg09UGVN1kX5HcWzVfpoMffxzuF41nP8aNwH0hpnpOn4FsIxE X-Received: by 2002:ac8:2836:: with SMTP id 51-v6mr11744080qtq.131.1528602069563; Sat, 09 Jun 2018 20:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602069; cv=none; d=google.com; s=arc-20160816; b=p8ZmXqkKXk2X+n0zkf41MXyFG8zllSDJadtyaNkx5fb4QPsh83l8TLk9Xn2oxCNdhM eQmtjOzbssjTCKtGI9hsn0gEpv9RfwPRWVH11BM0Y1v6aBIVU8sOXxIIZc5QkKl8gyfd 8lDwMNxgwTMlUVQYa4B9U04MvBBykUlyHy2m2zRKabgqgKtcE4/fKMdv43/gBTQVxY1y rLyhWhsw6qEYGXrscia2N9yXaaex6xfIOvN1vTDjbrO+N4ATGLUn8+S+1sZwTL+xkf+g wnKDBnUwMCxrLc/2ePu/laqEc7JPrbElAbFEcg33n/HMDhfCHyHzf5/qNrBJEeDXo1Sa iavw== 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=+9FBDCGrmf2va8DsMokYKksAPRBWVfDs5ghfJ28qSC0=; b=l75nDYRVok5rwzUj4mM7h3ioQkw4qdgQ69jT98+lf3zQIxRQebPDOkuBwCmrE6mQTX IIO0utF0GZvemaBLYBPx1eF+Ya5AKRF5xisoBGBxJx+Nalerp6LnSUjJdARyXR279Olx kAH7EK5XnEEIddwAOIZpP0xIj8VjOdnzwD3lTmbxKOCisKF+R3vpI0CtrmE3kM5UE4cL VAv8bcZ7+UjwWlPPpUFrKqwdTQGKpHoBb0BXXhsryovEEkOxX7K5LQIiJp0C9/Nw3Hjz +VR+pSRidWGdUd+mOPVYSpHI+rrhC1J37lJ9wMpqyUrYEMnjEFsMc56goU0mQJc5nrQ2 7jJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QaGQnSH4; 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 h33-v6si40712qtk.78.2018.06.09.20.41.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:41:09 -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=QaGQnSH4; 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]:42386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrE5-0002TR-1F for patch@linaro.org; Sat, 09 Jun 2018 23:41:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqeT-0003Aw-DS for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqeR-0003kp-SB for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:21 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:42385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqeR-0003kh-N0 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:19 -0400 Received: by mail-pf0-x244.google.com with SMTP id w7-v6so8478742pfn.9 for ; Sat, 09 Jun 2018 20:04:19 -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=+9FBDCGrmf2va8DsMokYKksAPRBWVfDs5ghfJ28qSC0=; b=QaGQnSH4AJSaU3pshAJBLMIeIVuntQZLVs/6qh7FNGNpkzP1D7Z5CWNLm86gyiUAtq m0yNH91+FfAQCIQ6DooWREUJ0iahxmIu4Fn0GQqlhO3wt69tOHjluPWLL+1pBkAgsJqd 5zWklf9kk5qKSXCuxtjCCyorDVmeviIJ5YHls= 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=+9FBDCGrmf2va8DsMokYKksAPRBWVfDs5ghfJ28qSC0=; b=WOkKuuKQYHJ9SkjZLwU9lpEKSHj/cwH/aypuxHD+5AbvHlTsWnUk0jdMX7vOi33nKE KyAMjzFf+2Tngwb6nOmmr95tasoH38CVVFj3I0OOd1SeQC0vx9UC3q9ZdxMnbAEzXxRb 34KLEgXfQRbwElsoTxMpFSw4bB4t4Ck/vR32YdyMjUhKfPcdMZeyzT1nD93/ZQSk2zQu d6uSJQ2cPLDms6HnorEou0MuHdE1eVXVT0gi2qD1YCjM7McEkZW6Om/BmW7lLVJRkEFP TNExfn2b3ErvnRHvAJ2aEdSMBfP8C9DeclI5RNQOt+Pwf76qTItNynFBKSpys/fQGr5f BL2g== X-Gm-Message-State: APt69E1OH1Y8qTBb0v0ui+/4FXFqiIRdABQPtga5hc0twj6aE+To4CWb 58AZD9N4/a0Zw12q0v2Nlhd7Z2yyvls= X-Received: by 2002:a63:3c4c:: with SMTP id i12-v6mr10447548pgn.309.1528599858541; Sat, 09 Jun 2018 20:04:18 -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.04.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:24 -1000 Message-Id: <20180610030220.3777-53-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::244 Subject: [Qemu-devel] [PATCH v2 052/108] linux-user: Unwrap TARGET_NR_syscall early 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" Unwrapping early produces a much nicer log output. Disallow recursive syscall, as per ARM and MIPS. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4f6c01092b..87374014b1 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -10230,11 +10230,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, switch(num) { case TARGET_NR_vhangup: return get_errno(vhangup()); -#ifdef TARGET_NR_syscall - case TARGET_NR_syscall: - return do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, - arg6, arg7, arg8, 0); -#endif case TARGET_NR_wait4: { int status; @@ -13171,6 +13166,32 @@ abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1, } } #endif +#ifdef TARGET_NR_syscall + /* For the benefit of strace, unwrap NR_syscall now. */ + if (num == TARGET_NR_syscall) { + num = arg1 & 0xffff; + if (num == TARGET_NR_syscall) { + /* Do not allow recursion. */ + ret = -TARGET_ENOSYS; + trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); + if (unlikely(do_strace)) { + print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); + print_syscall_ret(num, ret); + } + trace_guest_user_syscall_ret(cpu, num, ret); + return ret; + } + arg1 = arg2; + arg2 = arg3; + arg3 = arg4; + arg4 = arg5; + arg5 = arg6; + arg6 = arg7; + arg7 = arg8; + arg8 = 0; + } +#endif trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);