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: 927258 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="QaGQnSH4"; 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 413MPz6DWLz9s1B for ; Sun, 10 Jun 2018 13:41:27 +1000 (AEST) Received: from localhost ([::1]:42386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrEL-0002TR-Ep for incoming@patchwork.ozlabs.org; Sat, 09 Jun 2018 23:41:25 -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-Google-Smtp-Source: ADUXVKIV4xXDwAl7amkJQLos9jXFgpXYTnkxYS9YZvajajBDPOFssbyEI4fPghRsaDDJnCLStfF0sA== 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+incoming=patchwork.ozlabs.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(-) 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);