From patchwork Mon Feb 20 03:23:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655042 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1180017wrc; Sun, 19 Feb 2023 19:25:23 -0800 (PST) X-Google-Smtp-Source: AK7set9AnBKJRw0ItzYCrbKFqCPHUovLqs9Iv8eJc6v0D7mXCHF25xp05siSoo7aU+brMDXv1I/i X-Received: by 2002:a05:6214:b6d:b0:570:7026:2a19 with SMTP id ey13-20020a0562140b6d00b0057070262a19mr4846834qvb.36.1676863523201; Sun, 19 Feb 2023 19:25:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676863523; cv=none; d=google.com; s=arc-20160816; b=0GDIIyAQ8F1gkqvVf3mVSENpj0FkT4/gr4P/Q7yerzjA0+IMomc9q9Xbp4R+hgcJjd H4Wt2BaLZzrc3VB0tlyJKczvyXI49bwg5mcsD3NC91IJJR9OLUYo4BlSnwzGUvB+aahx pxpUhGwPHUH/5zHieDkd36JFCDZEnNo7lhhhteah1cNOGpkgJcAcwz8HLW6zK9J6r8+D 7X8zzfldRIJFnU+/UOYvlwhO9ub1AVRPHJmqThtD18zZNeyUpXZrcOD6iaOGEgyX4gYJ K2S4KRrjAsmM8trISavjzm3lzmJOUg8PE/QFJWHc5usbgWhkC5BracVNBvrkZRKi29RY 4hXg== 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=XxLQVkzo6u05XRu/oTQ+Gc3Lg7Bmhol2RuzS9iezzHg=; b=EDd55HZ6o5JRSb/YRjwjgS0WwKJ7wWjjHtLP/5RDYZOwc4eoUS8c9qiZHNEbOgOi2y 8ONZHjeGWEMis8nuXp3z9mLCSZ82iLsKsxWwAxTaLIURShwKERw9e5YCIda8pIaPU58p JFfRE99REdexsVJ1q5A5DtlrIYUyw8nje4oMLkfmhB5p7tZQUtP3jLrsQcfIR0adniWd InTmw3qt3I/qBqEoQvcy8wyP32CxJOgKq+3az6KZgNpMFgGtlqiGV1ZBN4cXUcBpFl1g UTDl7EgvhogIoI+L0vDytn4ik/qcYFDR3puDIsyE1CoUMRLjBBROQ6Z9d+i3eWJB8N4Q yHcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XxN1Mgox; 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 fi14-20020a0562141a4e00b005376fc51789si267262qvb.43.2023.02.19.19.25.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 19 Feb 2023 19:25:23 -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=XxN1Mgox; 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 1pTwmV-0001Bb-GN; Sun, 19 Feb 2023 22:23:59 -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 1pTwmT-0001BL-O4 for qemu-devel@nongnu.org; Sun, 19 Feb 2023 22:23:57 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pTwmS-0005r1-3S for qemu-devel@nongnu.org; Sun, 19 Feb 2023 22:23:57 -0500 Received: by mail-pj1-x1029.google.com with SMTP id o17-20020a17090ab89100b002349a303ca5so1791277pjr.4 for ; Sun, 19 Feb 2023 19:23:55 -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=XxLQVkzo6u05XRu/oTQ+Gc3Lg7Bmhol2RuzS9iezzHg=; b=XxN1MgoxJd+U40U4KikY3FrdJHZe589HIYBw2KbcFVTsXOSHr947bsO/hYW81ogxaM 0YPWov4BhN37Ze4ehJsn+9pBNfPZZnayfudgoV5Vqxw4UwnyI0sHOrp7NXs7xD2t0bjF z9AxvXyG1SA+jsR68THjoSEInFg51zg8RNVCian6a02l4lgh+wDNsxqTTTekgt00MpYB Lri8SOiAlZPxbZdwYRU/CIW01+eZ4fM/4aX1ufBOo+OpszIQvyH0P0iTEw7SZRbutJUq jJYZ0VYPfPxtpB3r1YfcTo1m2Gwdkbcx//1rZeufODgZe2gIz4BJjh8JOe4vPFef9uoX L9zg== 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=XxLQVkzo6u05XRu/oTQ+Gc3Lg7Bmhol2RuzS9iezzHg=; b=MofwVnMCuw4hkFbeBZ5yJ969s44fHysU+4GLpO+tlOE0E6KLG9EOa6PUiicGnIFt9E OJpkQbNafnFEjSpI1BGK05xqntQM1gPxettutCsV5j5p2JmQKnbnH1ODrcmiANzPxTkX WH0Cc3EJsi1zX62oiKi9YWNB0RdX4Jlb8Dc/MAr1pXiEUokSNe4GB18JuWXNzRAloNPy GqfJbZH9nZafpDVDfmFAG+vslOBg69kJALu+BRBPs38OMeoq8boI6PxnB43rRhQEjkyN CmtsBDH1wW2YFzye/Of5KdDbjcoRCQGhFyus4FrMS+TBUzmVEZqWgDm53yEFbMsker0k 8rrA== X-Gm-Message-State: AO0yUKWHj89zascypSFmzuG9C1SX9WHKHbEIHSvbaNuUwzexJCay4QuL 43jL9I8g7eBzX+RlJxI4X0S8lZozfRoskJpTpJw= X-Received: by 2002:a17:902:c408:b0:19a:9984:5590 with SMTP id k8-20020a170902c40800b0019a99845590mr1393472plk.5.1676863434603; Sun, 19 Feb 2023 19:23:54 -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 l11-20020a170902d34b00b00198e1bc9d83sm6621302plk.266.2023.02.19.19.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Feb 2023 19:23:54 -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 6/7] tests/tcg/linux-test: Add linux-fork-trap test Date: Sun, 19 Feb 2023 17:23:37 -1000 Message-Id: <20230220032338.5619-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230220032338.5619-1-richard.henderson@linaro.org> References: <20230220032338.5619-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.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 Check that dying due to a signal does not deadlock. Reviewed-by: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Ilya Leoshkevich Message-Id: <20230214140829.45392-5-iii@linux.ibm.com> Signed-off-by: Richard Henderson --- tests/tcg/multiarch/linux/linux-fork-trap.c | 51 +++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/tcg/multiarch/linux/linux-fork-trap.c diff --git a/tests/tcg/multiarch/linux/linux-fork-trap.c b/tests/tcg/multiarch/linux/linux-fork-trap.c new file mode 100644 index 0000000000..2bfef800c3 --- /dev/null +++ b/tests/tcg/multiarch/linux/linux-fork-trap.c @@ -0,0 +1,51 @@ +/* + * Test that a fork()ed process terminates after __builtin_trap(). + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include +#include +#include +#include +#include +#include + +int main(void) +{ + struct rlimit nodump; + pid_t err, pid; + int wstatus; + + pid = fork(); + assert(pid != -1); + if (pid == 0) { + /* We are about to crash on purpose; disable core dumps. */ + if (getrlimit(RLIMIT_CORE, &nodump)) { + return EXIT_FAILURE; + } + nodump.rlim_cur = 0; + if (setrlimit(RLIMIT_CORE, &nodump)) { + return EXIT_FAILURE; + } + /* + * An alternative would be to dereference a NULL pointer, but that + * would be an UB in C. + */ + printf("about to trigger fault...\n"); +#if defined(__MICROBLAZE__) + /* + * gcc emits "bri 0", which is an endless loop. + * Take glibc's ABORT_INSTRUCTION. + */ + asm volatile("brki r0,-1"); +#else + __builtin_trap(); +#endif + } + err = waitpid(pid, &wstatus, 0); + assert(err == pid); + assert(WIFSIGNALED(wstatus)); + printf("faulting thread exited cleanly\n"); + + return EXIT_SUCCESS; +}