From nobody Tue Feb 10 03:20:42 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 1529926304200299.6807539738934; Mon, 25 Jun 2018 04:31:44 -0700 (PDT) Received: from localhost ([::1]:45597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXPic-0004uE-P5 for importer@patchew.org; Mon, 25 Jun 2018 07:31:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXPXA-00052V-Us for qemu-devel@nongnu.org; Mon, 25 Jun 2018 07:19:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXPX9-0008Ff-Ol for qemu-devel@nongnu.org; Mon, 25 Jun 2018 07:19:48 -0400 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:40445) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXPX9-0008FN-IB for qemu-devel@nongnu.org; Mon, 25 Jun 2018 07:19:47 -0400 Received: by mail-wr0-x244.google.com with SMTP id g18-v6so13254800wro.7 for ; Mon, 25 Jun 2018 04:19:47 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 132-v6sm16385839wmr.33.2018.06.25.04.19.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Jun 2018 04:19:41 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 9A25B3E0AC0; Mon, 25 Jun 2018 12:19:36 +0100 (BST) 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 :mime-version:content-transfer-encoding; bh=8LmrDKoPzfnRy55Xx37Cc/LgWjZWnBFXZ76bEvyVuwY=; b=T2QRZg3igxHdmcCA/km203o/wRadjuzF93Odp07K4WJG5z6DKiHrHVdqRx2WPRkG2D u2OaBzHl6HV3fWq0Ovnc6BWnwdRrA6sMlrOOiXWaIx6gIdkbAVXOZrSc7W/lldkBwaxR oRTn3NvMqKm5Z23gB+TSqWAL4Iszyb4XHzs2E= 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:mime-version:content-transfer-encoding; bh=8LmrDKoPzfnRy55Xx37Cc/LgWjZWnBFXZ76bEvyVuwY=; b=IJitUOgsbZFRcgjD+fXTW8ie/iC6STzq6bR+nfE3c5hjl4NBl6zeVvbUKIKW0VwJhw Ns5a60+gL//65YEyvAlX6EzJBeDId069TkrM3pSbEfiJgo4GT/D0Zyz/i/uiniKFvTaB m6PMdy9hSxaCq0x6/GXCZjlwEiOjIGV/BcRDAm/HxrscIBlOLteCdB/wwMPBnzPkczn7 sb+E8jUGVj/TWBTs3FyYjzSBgqj+bhHD/FVAB2V4LVRoMafGi9FXiaWsEori9K5GhhgI V5G6a6m3DOtGM6kI8FC/kWc63MCiwD2zd8Z3GU5GbEN6NXGHiUnuXewVWJvGKbtFW6mG 8r4g== X-Gm-Message-State: APt69E33SoAk9V3IT1r3Qrb0CHoaEnUYoB8YVsBRrD5J8fIlEUF6s1jI EZS1cEMd3Kwhbuq5fRM0wXSNrg== X-Google-Smtp-Source: AAOMgpfcArkfSeVfejqwcZ2eQKOIshwkiG3xqAihFNvHWJWt9A+WKclvrl3VxNKZwze/R4welzBZZw== X-Received: by 2002:adf:8345:: with SMTP id 63-v6mr398445wrd.37.1529925586450; Mon, 25 Jun 2018 04:19:46 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: cota@braap.org, famz@redhat.com, berrange@redhat.com, f4bug@amsat.org, richard.henderson@linaro.org, balrogg@gmail.com, aurelien@aurel32.net, agraf@suse.de Date: Mon, 25 Jun 2018 12:19:34 +0100 Message-Id: <20180625111935.26108-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180625111935.26108-1-alex.bennee@linaro.org> References: <20180625111935.26108-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PATCH v1 09/10] linux-user: introduce preexit_cleanup 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: Riku Voipio , =?UTF-8?q?Alex=20Benn=C3=A9e?= , qemu-devel@nongnu.org, Laurent Vivier 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 To avoid repeating ourselves move our preexit clean-up code into a helper function. I figured the continuing effort to split of the syscalls made it worthwhile creating a new file for it now. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/Makefile.objs | 2 +- linux-user/exit.c | 28 ++++++++++++++++++++++++++++ linux-user/qemu.h | 8 ++++++++ linux-user/syscall.c | 10 ++-------- 4 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 linux-user/exit.c diff --git a/linux-user/Makefile.objs b/linux-user/Makefile.objs index 59a5c17354..b5dfb71f25 100644 --- a/linux-user/Makefile.objs +++ b/linux-user/Makefile.objs @@ -1,7 +1,7 @@ obj-y =3D main.o syscall.o strace.o mmap.o signal.o \ elfload.o linuxload.o uaccess.o uname.o \ safe-syscall.o $(TARGET_ABI_DIR)/signal.o \ - $(TARGET_ABI_DIR)/cpu_loop.o + $(TARGET_ABI_DIR)/cpu_loop.o exit.o =20 obj-$(TARGET_HAS_BFLT) +=3D flatload.o obj-$(TARGET_I386) +=3D vm86.o diff --git a/linux-user/exit.c b/linux-user/exit.c new file mode 100644 index 0000000000..aed8713fae --- /dev/null +++ b/linux-user/exit.c @@ -0,0 +1,28 @@ +/* + * exit support for qemu + * + * Copyright (c) 2018 Alex Benn=C3=A9e + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +#include "qemu/osdep.h" +#include "qemu.h" + +void preexit_cleanup(CPUArchState *env, int code) +{ +#ifdef TARGET_GPROF + _mcleanup(); +#endif + gdb_exit(env, code); +} diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 793cd4df04..bb85c81aa4 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -623,6 +623,14 @@ static inline int is_error(abi_long ret) return (abi_ulong)ret >=3D (abi_ulong)(-4096); } =20 +/** + * preexit_cleanup: housekeeping before the guest exits + * + * env: the CPU state + * code: the exit code + */ +void preexit_cleanup(CPUArchState *env, int code); + /* Include target-specific struct and function definitions; * they may need access to the target-independent structures * above, so include them last. diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2117fb13b4..7c66442357 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8018,10 +8018,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long= arg1, } =20 cpu_list_unlock(); -#ifdef TARGET_GPROF - _mcleanup(); -#endif - gdb_exit(cpu_env, arg1); + preexit_cleanup(cpu_env, arg1); _exit(arg1); ret =3D 0; /* avoid warning */ break; @@ -10127,10 +10124,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_lo= ng arg1, #ifdef __NR_exit_group /* new thread calls */ case TARGET_NR_exit_group: -#ifdef TARGET_GPROF - _mcleanup(); -#endif - gdb_exit(cpu_env, arg1); + preexit_cleanup(cpu_env, arg1); ret =3D get_errno(exit_group(arg1)); break; #endif --=20 2.17.1