From patchwork Mon Jan 16 22:36:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 643110 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp842297pvb; Mon, 16 Jan 2023 14:38:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXvMnnyQsr64rhY/jXO6Nn0CZugTF6x+lPqbbWi2o5M165a68ceGNoMUmNl7+FxhOdmcJV/G X-Received: by 2002:ac8:7a8b:0:b0:3b6:2b50:15eb with SMTP id x11-20020ac87a8b000000b003b62b5015ebmr11271240qtr.57.1673908688645; Mon, 16 Jan 2023 14:38:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673908688; cv=none; d=google.com; s=arc-20160816; b=wKNs0aY1fP8DjhaDUAFif6RJsIWbhjZfweE+O9Ck4+x7Qmr5+LC4pIlC3pBnJtIGD3 6LleVFoDog/zXQ+CTRh8P+8krrsmPcIxSm4nfM7wtnNilysC+Jh3Chi7ySUv9V/6Xj9D JURVzDkGSRSpDlHuNVEVs7w0NSY0y71e+q600T9m4mzEJZ9fgK13yqRJnydB2SxyT8E6 58mcLOFEuxOCTD3C+HnSGtw9kV0uRqOB3dH8t6xWT7NIv+etPOhQ5+4HVkbgX6g8At8P qcUTbvSlHaltRP8CVpb3p4k24dcd/p2Zx++kw3y+/fx3WVF+gmLvAZNSIvALIdGsMmz5 cbmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sVoQ+dZBxCCrOAQkIYFBP0Uz5/oWgbT60mps7v3rv5w=; b=pKqEMcEUAEovSlDUe6BespvWuZf3ERiiHGH9odJFJHO5U29vluGVmmfd0l8NTP979i HM2Om/X38fVvxcqzZWvLhhHCUqB/yRDvYAqBQlccqujQxt8G9yqvj0m2n64RKb1xzzF3 7IMuETr0XzYF0/GUPqnFbiAUPW+osM5jPDjGEkqd14dQJo1EBOzwDbRT9iTeE52zaldz helAQFnK52M7/kQYKQVu7vXEKKE2vFycJDdTEC0E6tSe4oeyyAcSyeubxBPTYCwx9eQW 3X4rAWOVr4aYlebkFmM5dILEutcQz8GThFfG7ZZjPoqZsRoBPAoVRBAFngJ5pAjDMHwP //og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kjQPhh7y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bl5-20020a05622a244500b003a68ea8af2csi2626080qtb.83.2023.01.16.14.38.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jan 2023 14:38:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kjQPhh7y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHY5v-0000Wb-Oe; Mon, 16 Jan 2023 17:36:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHY5t-0000PQ-87 for qemu-devel@nongnu.org; Mon, 16 Jan 2023 17:36:45 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pHY5r-0001MF-L1 for qemu-devel@nongnu.org; Mon, 16 Jan 2023 17:36:45 -0500 Received: by mail-pl1-x629.google.com with SMTP id k12so9586595plk.0 for ; Mon, 16 Jan 2023 14:36:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sVoQ+dZBxCCrOAQkIYFBP0Uz5/oWgbT60mps7v3rv5w=; b=kjQPhh7y6UmxHQT083q4jKpXzCOGnRVkRlBOiQfevp+dtKPpMRseWca1yXPQ9ZMx64 SuYh4/KLFO1mnSrjdjaxsKZSNDXRKrQk5qdfyqIz9kJf8jf3czzLieFL0pOmYAMtZzHq mE3pdJLo9z7dOpAoNGs9k3+GsE1Ts0ZLh1hxNGL/BLn9MzqrZZuoNPV44dxOLxdNR6di E4YE7Dt013/1JyU04xjOSmTvHxFn4rX04waA1K2cQ2KkzaMmg6e0HKcwCyKyTX5NDyGk lyH13LW0g22dcZk332w8tD/SPRFXqEZj7u9SVOMmkGevc3f1F+MS6XbJmdaITnBTHvr5 N94A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sVoQ+dZBxCCrOAQkIYFBP0Uz5/oWgbT60mps7v3rv5w=; b=o574qI2VOXx3Nmi1e+HExI308A5VRMqAoc/3qwWs9HN0M7gtv/M075anxePo7jfCHN ob65yXePOKXGFk0js7Fs7UMjIMHV9jEbrfEO1JZYu81w7kjbfnoFkmoFMu7aiqzzvtGE ulglzcoi6wr+AdbbbRKxwqzHHXrGFji+5twdBf1q8pxKDtNcwxdzUmRo+XllZcnQ4nA3 /0sA/IRKpwhB4tmCJzXzSSJpapl/sHD5WvzW/8Cn+S6SjYGUvsMF0r7l0SAG+8++2yIb fpaUKnvuop+YvfK8b3XMGYJWgDP3QOgmLIkvg6Uy7LMJ2Alr6qsGSz16BFoONWgeO0ZV OkSQ== X-Gm-Message-State: AFqh2krHjIaY+vqyC+bCbUhdBAj+HOv5mV1hB6FPV4rcDptZMk332byb FdWc/3j5qOjanahxDwJHQ+BYyqkXNtQO/jox X-Received: by 2002:a17:902:d50e:b0:191:4378:ec06 with SMTP id b14-20020a170902d50e00b001914378ec06mr30669211plg.61.1673908602048; Mon, 16 Jan 2023 14:36:42 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id n3-20020a170903110300b00189f2fdbdd0sm19742492plh.234.2023.01.16.14.36.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 14:36:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Ilya Leoshkevich , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 1/5] linux-user: Clean up when exiting due to a signal Date: Mon, 16 Jan 2023 12:36:33 -1000 Message-Id: <20230116223637.3512814-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230116223637.3512814-1-richard.henderson@linaro.org> References: <20230116223637.3512814-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Ilya Leoshkevich When exiting due to an exit() syscall, qemu-user calls preexit_cleanup(), but this is currently not the case when exiting due to a signal. This leads to various buffers not being flushed (e.g., for gprof, for gcov, and for the upcoming perf support). Add the missing call. Signed-off-by: Ilya Leoshkevich Reviewed-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20230112152013.125680-2-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- linux-user/signal.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 61c6fa3fcf..098f3a787d 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -695,7 +695,7 @@ void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, /* abort execution with signal */ static G_NORETURN -void dump_core_and_abort(int target_sig) +void dump_core_and_abort(CPUArchState *cpu_env, int target_sig) { CPUState *cpu = thread_cpu; CPUArchState *env = cpu->env_ptr; @@ -724,6 +724,8 @@ void dump_core_and_abort(int target_sig) target_sig, strsignal(host_sig), "core dumped" ); } + preexit_cleanup(cpu_env, 128 + target_sig); + /* The proper exit code for dying from an uncaught signal is * -. The kernel doesn't allow exit() or _exit() to pass * a negative value. To get the proper exit code we need to @@ -1058,12 +1060,12 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig, sig != TARGET_SIGURG && sig != TARGET_SIGWINCH && sig != TARGET_SIGCONT) { - dump_core_and_abort(sig); + dump_core_and_abort(cpu_env, sig); } } else if (handler == TARGET_SIG_IGN) { /* ignore sig */ } else if (handler == TARGET_SIG_ERR) { - dump_core_and_abort(sig); + dump_core_and_abort(cpu_env, sig); } else { /* compute the blocked signals during the handler execution */ sigset_t *blocked_set;