From patchwork Tue Oct 3 19:20:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 728824 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:1305:b0:23f:8cfb:5ad7 with SMTP id s5csp43198lto; Tue, 3 Oct 2023 12:22:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcIiwNzADoCAS+AQksQ7W3sp9XDTsq/zsYrJPnrxYTgWpPkb2SDTjq2cpg/6qZr95tKcfB X-Received: by 2002:a05:620a:1708:b0:76e:f90d:85d1 with SMTP id az8-20020a05620a170800b0076ef90d85d1mr213469qkb.26.1696360942843; Tue, 03 Oct 2023 12:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696360942; cv=none; d=google.com; s=arc-20160816; b=iwDtazXbtlInCYB8LvOwDv266QuJmtrMbedCJmEoq85gpVjP8GNZ5A6HFJwR7iNEhq B4Cj9rmrQ6UcR9EaLpbyX5f/FCSJ5yl0qinfXaH9byaNA3ECFrDZgN8qT9mEE6FTO3oh INJHHwO8MXjLd/DnMmbiAIhQ4fKkMKmjYR74OSJKfokPPB3q3Mx+vhVkObaw1rWiCF4e X7h4KKnIgY7GyDyfJWro4Eh3TgH+VZf9cbOTdsARmnp1xMpRGBasc6fxntLD2Rsboex5 A2GPh9aaHr9O5ASFhydBpBrhbQt5H7RqeE1U02wXs/DaEUypL/JDAWaep8aBberQajmH EXVw== 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=MD3OzDuuDGgXDQMB1J8iXNmpATULZDtwIUTwe03wb+E=; fh=YRZ+qgYKjKfO+J7iYLqJ+AhmJljeW1N2qgZkMPPeD1I=; b=HBpRnJP+5uhJZyKrWo9i/d/vCKgZN6VfB+4yymt5hEQVfBGez5EkZAPrxNGkVxzXdw fm7hwuQ5OpE6X3VkETolNMbXZgUAZ/n4j1rq5IugpFndAQbCyZGqedUdnzI4pKjD/02y t8xlHF2nIdDBv+huFoSUzt9EemO31TbzNDUSgYebpEomYTL6gUCJ2MZ8iRk+SMcgqGFd ne6ZgoZQd+/SzPSmId09eu7/1ZAa5S61QOyciUtcb7Oc1t99KySDYQLRb8OJSnK7dfCp 2MATAE3IhHXPqCYDXS09ymqBnGLJhxmt/QZ7M/s4F6qZ5sIr+THMULM7cIYGPTd7XPvu XoCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ABfllLMS; 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 re19-20020a05620a8e1300b0077419b27787si805489qkn.177.2023.10.03.12.22.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Oct 2023 12:22:22 -0700 (PDT) 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=ABfllLMS; 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 1qnkxR-00054Y-VP; Tue, 03 Oct 2023 15:21:28 -0400 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 1qnkws-0004th-2a for qemu-devel@nongnu.org; Tue, 03 Oct 2023 15:20:53 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnkwT-0004eG-UK for qemu-devel@nongnu.org; Tue, 03 Oct 2023 15:20:49 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1c7373cff01so1235335ad.1 for ; Tue, 03 Oct 2023 12:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696360821; x=1696965621; darn=nongnu.org; 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=MD3OzDuuDGgXDQMB1J8iXNmpATULZDtwIUTwe03wb+E=; b=ABfllLMSoaA4iPE8tJXyJl5SB2E/2UKGesTeXJrLzkg39n0xKwqVg8Pq/9ZtiQWijk 64uldqz/Sol8WbmmIxj2mHx9tQe6FqTVZM1tDNkd4NtHkh+xCeq5KWk6cHwajL3l7kzW qumOz/8PzWY3+H53lbzMooP7xfKuMLIwl61KnnnNCNx+kCeFLi8IQ7dErKl0i/taw0/d ttH26pFF+wF25bktr2JzVgCEwqROtUHGgH//scM8bQfEu9F3uSrYAjUp6ZAuarj4JuMV rEqN2fK5mzir36TtE+qbAI2+MKAn5pyzFry4I0pxIB2xHYKjrD6nP1/+COjpy1cfO05Z v6/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696360821; x=1696965621; 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=MD3OzDuuDGgXDQMB1J8iXNmpATULZDtwIUTwe03wb+E=; b=Ij+auvVWAsjEX/LV6hLIUCcvMu/ObQ3UflWgT09NC0e6UoYLT8lmKdQbyL15rjTi1o 6/tH5oRj8+LvHip2uv5F3D7sNcFZ5huhw6EdM9hcdx3eLssIrasieShseeYwDtiGPggT +4sAYP0UOhXnMaqRWdrvesKQlt1hzzYam4XH/PQgGKoWywl8EmTgSaSSg5QarKhNtPKf 6UKiGcDen3kJwvyWcrG7+7tYM0prsDqY3DMCc2php82eZZhIY1wFmSkvJ0ybPfjc3aG7 xMIbhJqgIRdqorXbRSRmbgcsXJkesu1DtXor0wvl4SwH/6UsfqGxXoERsDN3JGVamxCT 6N4Q== X-Gm-Message-State: AOJu0YyIzcr05K9KnD2OF2wWJew1PHGGipz4Wcw8l5/+FVZg+NtTDwD+ AS2YceePLxCAfeebiEKuG8u5hHTfRV0wBkZ4ZXs= X-Received: by 2002:a17:902:db0a:b0:1c3:432f:9f69 with SMTP id m10-20020a170902db0a00b001c3432f9f69mr247445plx.23.1696360821237; Tue, 03 Oct 2023 12:20:21 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id w5-20020a170902d3c500b001c5fd2a28d3sm1978497plb.28.2023.10.03.12.20.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 12:20:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: laurent@vivier.eu, deller@gmx.de Subject: [PATCH v5 8/9] linux-user: Detect and report host SIGILL, SIGFPE, SIGTRAP Date: Tue, 3 Oct 2023 12:20:11 -0700 Message-Id: <20231003192012.1674888-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003192012.1674888-1-richard.henderson@linaro.org> References: <20231003192012.1674888-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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, T_SPF_TEMPERROR=0.01 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 These signals, when not spoofed via kill(), are always bugs. Use die_from_signal to report this sensibly. Signed-off-by: Richard Henderson --- linux-user/signal.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 706b8ac7a7..b67077f320 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -796,6 +796,43 @@ void die_from_signal(siginfo_t *info) break; } break; + case SIGILL: + sig = "ILL"; + switch (info->si_code) { + case ILL_ILLOPC: + code = "ILLOPC"; + break; + case ILL_ILLOPN: + code = "ILLOPN"; + break; + case ILL_ILLADR: + code = "ILLADR"; + break; + case ILL_PRVOPC: + code = "PRVOPC"; + break; + case ILL_PRVREG: + code = "PRVREG"; + break; + case ILL_COPROC: + code = "COPROC"; + break; + } + break; + case SIGFPE: + sig = "FPE"; + switch (info->si_code) { + case FPE_INTDIV: + code = "INTDIV"; + break; + case FPE_INTOVF: + code = "INTOVF"; + break; + } + break; + case SIGTRAP: + sig = "TRAP"; + break; default: snprintf(sigbuf, sizeof(sigbuf), "%d", info->si_signo); sig = sigbuf; @@ -900,7 +937,8 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) /* * Non-spoofed SIGSEGV and SIGBUS are synchronous, and need special - * handling wrt signal blocking and unwinding. + * handling wrt signal blocking and unwinding. Non-spoofed SIGILL, + * SIGFPE, SIGTRAP are always host bugs. */ if (info->si_code > 0) { switch (host_sig) { @@ -912,6 +950,10 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) host_sigbus_handler(cpu, info, uc); sync_sig = true; break; + case SIGILL: + case SIGFPE: + case SIGTRAP: + die_from_signal(info); } }