From nobody Wed Feb 11 01:09:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528600041801541.7938641031466; Sat, 9 Jun 2018 20:07:21 -0700 (PDT) Received: from localhost ([::1]:42191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqhM-0005Oi-Sk for importer@patchew.org; Sat, 09 Jun 2018 23:07:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqcj-0001VV-1I for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqch-00036T-OP for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:33 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:41349) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqch-00036D-IH for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:02:31 -0400 Received: by mail-pg0-x242.google.com with SMTP id l65-v6so8131785pgl.8 for ; Sat, 09 Jun 2018 20:02:31 -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.02.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:02:29 -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=aZhX4crw3nZleV9x/cupabZl+g+1NR+rOFu8N2TUSEM=; b=X0Hb1JZHWwpbzofYBnr71xsE2MXhAc78z923kvXObE4Iqd7LyapgLoqvxuI3NG1rY/ JyyLaCoq374TIF02RRu5mzoqtpd5Mpco1ShnfUPqTPqVYpkBIYD08R0rwcG4jYu82lqy RZwRNER/o4NEDTzfTj8SEVKy0aHqsBzR6ebIY= 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=aZhX4crw3nZleV9x/cupabZl+g+1NR+rOFu8N2TUSEM=; b=E4BY7YlbwvLlvDPI/mb96fzr65/oOLKPTRwwOXsf7ln6R+GsK6M4N+95ps3/GcY1n+ hCsRf8+ExobK/wpY4Em4SUHe2sajGjkSWPxAqrGZjyb2GRcYq6flKOS9BnDKf7vULUjD 2X3L2YxXa/qemr23MRjkYxKRk6Lg+gO1G4f5VTCIzyesLBBcS6C8YRwV8l8PzLdtHd9W vib0wlHXjyHdZJJ4BdWIOFVhDyPOYvpOGJ5NxNsuUIicgRaoIDhv5uzl6M7+En2e7j05 BjplMcl6AeMVqYLAT0aXampjqGxUNxbMbAbeMb/B5aYbGM+SuJmYniut/o22VVPR30t0 SzJg== X-Gm-Message-State: APt69E0F8AA36tdnaBVl0Wqx8ydvq07HU295BPOQFsFK4jd/L7cl1Ezf mD2TBICuuh2eDpHJk4LOUufgpi2d1Fc= X-Google-Smtp-Source: ADUXVKKsUVbaZ9R0Ms2Lrqw4KlBbIFi7ze36dfd6X9GWW5h1rHS8tmCsU6udzUlojvnv/0FDKpnqBg== X-Received: by 2002:a63:6742:: with SMTP id b63-v6mr10419554pgc.54.1528599750219; Sat, 09 Jun 2018 20:02:30 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:00:34 -1000 Message-Id: <20180610030220.3777-3-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 002/108] linux-user: Split out do_syscall1 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There was supposed to be a single point of return for do_syscall so that tracing works properly. However, there are a few bugs in that area. It is significantly simpler to simply split out an inner function to enforce this. Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson --- linux-user/syscall.c | 77 +++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c212149245..ec3bc1cbe5 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7947,13 +7947,15 @@ static int host_to_target_cpu_mask(const unsigned l= ong *host_mask, return 0; } =20 -/* do_syscall() should always have a single exit point at the end so - that actions, such as logging of syscall results, can be performed. - All errnos that do_syscall() returns must be -TARGET_. */ -abi_long do_syscall(void *cpu_env, int num, abi_long arg1, - abi_long arg2, abi_long arg3, abi_long arg4, - abi_long arg5, abi_long arg6, abi_long arg7, - abi_long arg8) +/* This is an internal helper for do_syscall so that it is easier + * to have a single return point, so that actions, such as logging + * of syscall results, can be performed. + * All errnos that do_syscall() returns must be -TARGET_. + */ +static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6, abi_long arg7, + abi_long arg8) { CPUState *cpu =3D ENV_GET_CPU(cpu_env); abi_long ret; @@ -7961,25 +7963,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long= arg1, struct statfs stfs; void *p; =20 -#if defined(DEBUG_ERESTARTSYS) - /* Debug-only code for exercising the syscall-restart code paths - * in the per-architecture cpu main loops: restart every syscall - * the guest makes once before letting it through. - */ - { - static int flag; - - flag =3D !flag; - if (flag) { - return -TARGET_ERESTARTSYS; - } - } -#endif - - trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6,= arg7, arg8); - if(do_strace) - print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6); - switch(num) { case TARGET_NR_exit: /* In old applications this may be used to implement _exit(2). @@ -12765,11 +12748,47 @@ abi_long do_syscall(void *cpu_env, int num, abi_l= ong arg1, break; } fail: - if(do_strace) - print_syscall_ret(num, ret); - trace_guest_user_syscall_ret(cpu, num, ret); return ret; efault: ret =3D -TARGET_EFAULT; goto fail; } + +abi_long do_syscall(void *cpu_env, int num, abi_long arg1, + abi_long arg2, abi_long arg3, abi_long arg4, + abi_long arg5, abi_long arg6, abi_long arg7, + abi_long arg8) +{ + CPUState *cpu =3D ENV_GET_CPU(cpu_env); + abi_long ret; + +#ifdef DEBUG_ERESTARTSYS + /* Debug-only code for exercising the syscall-restart code paths + * in the per-architecture cpu main loops: restart every syscall + * the guest makes once before letting it through. + */ + { + static bool flag; + flag =3D !flag; + if (flag) { + return -TARGET_ERESTARTSYS; + } + } +#endif + + 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); + ret =3D do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); + print_syscall_ret(num, ret); + } else { + ret =3D do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8); + } + + trace_guest_user_syscall_ret(cpu, num, ret); + return ret; +} --=20 2.17.1