From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1641745336; cv=none; d=zohomail.com; s=zohoarc; b=nX0BMpiI0QLXL+6phYzEcNVhr7zW2Wp/WPhjyZ/l9REBjvzWj1dRpVFG9F9MrKe7fzsVgk4ouQRK+F3r6HjjltG65bIFDVNfcRVYnyec8qGCNTn+Wy66yRLHzXiWRfMaSsD9wHp/uckEg6+55o+Oh271vYkbmDjQT8qmcD7zJd0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641745336; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=99bS4MtDz1+z8o/MYw3wovNzM4oigqAnsWI545u6azU=; b=TmkrbC8L8ikNyojwXQg2YmGM2cccidYRfMphh4c2JggaveC2PicixdZBFbfJeZ/xbY9tsPNQNcBeZyNDH1CsiEapErYGUnvzzk3GEROyA7w5DUg6iKTQKfoH1Wn+Rg6U7/5PJ8HDpLKDdlmFiNT7/NT+i1F1694y03S+7sq2QEQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745335897617.0553404318591; Sun, 9 Jan 2022 08:22:15 -0800 (PST) Received: from localhost ([::1]:54574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6axS-0008DN-8U for importer@patchew.org; Sun, 09 Jan 2022 11:22:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6aup-0005Ln-MY for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:32 -0500 Received: from [2607:f8b0:4864:20::d33] (port=38774 helo=mail-io1-xd33.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6auo-00075K-0l for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:31 -0500 Received: by mail-io1-xd33.google.com with SMTP id u8so14396296iol.5 for ; Sun, 09 Jan 2022 08:19:29 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=99bS4MtDz1+z8o/MYw3wovNzM4oigqAnsWI545u6azU=; b=BDwXzvhJZEIApEPOUaqjj8iv/wZdmlBT8TcBUu0tEDfBd65eJALozPWbCm/E7Jv9bS t1ifaGFBh0a4lJMzCYkAYZ+XaxbjRT/7GPgxYG+L55okcGJXohgebLeWrAe2ZLkitJVN fKRnht2e71V45lCmy6iZPwcB2UbwwvpK44nI18D1Wh6GJUNoqsA6LGd6xu2SWVye9f6p XsNCBKA/ZKzLb5DgclsFVUxyj6+Dcjbs4Mdr5qHVpn07il29UYI+YzLKrRhBjsZDnHof FpZaKP5VkcZjBBht3WaWcLfxfESkLPOLRb7/0+ghV8sECjqBpwCBpyrJ60e4qlBeSH/f 9LgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=99bS4MtDz1+z8o/MYw3wovNzM4oigqAnsWI545u6azU=; b=y1Rn24sb8slXF2XHCr5C5YKE3LVVeoteMJynU4ntTHxC53D2PGXM5NYrVxfDUUje8q YkDWO98iZkKt2G5IE28agdTZ6XtSvb2vw2tuaA5w990vtDKVqpsJSQPlzEPafwdY9lG5 Dkjcs+cVuRx5wkgD+CADxXW8ek8JqDVUaAVZdI7tIDoqGUUTFg+WbsY1tvyBJy3e4V7p 0dWcdoxg7X0C0zlNXcEj5tDvLIPQc51h+KFxxVPwjAY4JCDJJJNOLOplQ11oYxTv6QLH LOLY9SnO7AVAidNJiPhsMs0oF2cCtrt4n4fHwmpY6mb80cjSTQ9E6N7IvjYS10CyasKo 9d1w== X-Gm-Message-State: AOAM533+ekgxJZUrt6LnPLaG2rMVA4kwV7YjelUW4HcDkS+KA2eHXVMz 4TvC1NAhXaRNZ6fRixYfIDQu1vJAzuDVoiwb X-Google-Smtp-Source: ABdhPJxLcjoI3x+pI+pCc0FmdfvbG/f8kU11oQPbIQChYeTgvBAN9mu1qpyj8rmsxQyuMmfIQ6mHJw== X-Received: by 2002:a02:b054:: with SMTP id q20mr28869036jah.247.1641745168427; Sun, 09 Jan 2022 08:19:28 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 01/30] bsd-user/arm/target_arch_cpu.h: Move EXCP_ATOMIC to match linux-user Date: Sun, 9 Jan 2022 09:18:54 -0700 Message-Id: <20220109161923.85683-2-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d33 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d33; envelope-from=imp@bsdimp.com; helo=mail-io1-xd33.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1641745338758100001 Content-Type: text/plain; charset="utf-8" Move the EXCP_ATOMIC case to match linux-user/arm/cpu_loop.c:cpu_loop ordering. Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_cpu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index c675419c30a..c526fc73502 100644 --- a/bsd-user/arm/target_arch_cpu.h +++ b/bsd-user/arm/target_arch_cpu.h @@ -180,12 +180,12 @@ static inline void target_cpu_loop(CPUARMState *env) queue_signal(env, info.si_signo, &info); } break; - case EXCP_ATOMIC: - cpu_exec_step_atomic(cs); - break; case EXCP_YIELD: /* nothing to do here for user-mode, just resume guest code */ break; + case EXCP_ATOMIC: + cpu_exec_step_atomic(cs); + break; default: fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting= \n", trapnr); --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745338429184.52926777657933; Sun, 9 Jan 2022 08:22:18 -0800 (PST) Received: from localhost ([::1]:54740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6axV-0008K0-G2 for importer@patchew.org; Sun, 09 Jan 2022 11:22:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6aur-0005M2-4O for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:34 -0500 Received: from [2607:f8b0:4864:20::12e] (port=46615 helo=mail-il1-x12e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6aup-00075O-5V for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:32 -0500 Received: by mail-il1-x12e.google.com with SMTP id e8so9249571ilm.13 for ; Sun, 09 Jan 2022 08:19:30 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ToPw1lb/7gSL+1Pg8gDpDNCotwUl1c4vZ43gWdUHFE0=; b=Te8rKZ+/gafC74iQ7Ut0k3F5IjPGdOT/OmyfvaUWXvWKyo70rC4UmjELCHx1CiVXou f0DfVTbDTAQQz0bRJSSTLDuzhoe3JJ+vZMPdTWAO25eqwqYC1SSZ56YZs4a8Xi0M8DZG 9PbP5UKRlt4Nog2GBBGsMB14IDBOE6BkWrhI/LGtTBJeXKIq2/MXF4EGUc1vXbw/NQwN CfkbmaNNR61Zuu7pfHU0RoLRuWFeYLVU1EzhcvnkEzL7NprSP2XBI/+HzD93IFBYOa+0 5oKTT5nB0nYGlAD7OxolcwgjPapGYvcnYPS+ynDcnfnnLWu4agxLUCYCeV37h1lGLdlS yfkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ToPw1lb/7gSL+1Pg8gDpDNCotwUl1c4vZ43gWdUHFE0=; b=7LNwySjdDiXq8vFcszWZdBRcZyDvUMCo0/4LVypP3eSvfxNFGgwzsyFkaafhBvUgmi fL26iE2ZC/0tGJagPv4RAdd46S5PEky0d1hXegQwLU9mvmPG1cW16HigCIbVbkthZJhz LYAVWIAJhooXNVn4U4z70PHdTu4BT2Zw4rL20U7jemVEuqv9CWXq3KfqQaZB9ZAoxjL2 dSJApDlKdf3XSY5y2znHk9lY5AOK5svv3k4zLoeNzt/QS4KU9fttF5b1MnLMhHGkXat8 lJA9mDs5nuy+nN1QThubW5DUVzIPdCDwxWLZr6JZr7GkPshUY+zMpiTYnNdwqoP20zw2 fukw== X-Gm-Message-State: AOAM531x44GnFAHZZTHOVTRh+0AZPeZRinJ1iAfMlPt7X/HrXQEb49HZ lPYRLs8KuQNNvWs8E00WhsXfIdFLjvkPUkIN X-Google-Smtp-Source: ABdhPJzSW81IDvR1s7vcgFXHh/IBJcElOjbTGI/Oj0DbmB9fYN5vDANOFkiATEgc6y/OnV3fVqmXNA== X-Received: by 2002:a05:6e02:1588:: with SMTP id m8mr18376184ilu.113.1641745169887; Sun, 09 Jan 2022 08:19:29 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 02/30] bsd-user/signal.c: implement force_sig_fault Date: Sun, 9 Jan 2022 09:18:55 -0700 Message-Id: <20220109161923.85683-3-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12e (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12e; envelope-from=imp@bsdimp.com; helo=mail-il1-x12e.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641745340348100005 Content-Type: text/plain; charset="utf-8" Start to implement the force_sig_fault code. This currently just calls queue_signal(). The bsd-user fork version of that will handle this the synchronous nature of this call. Add signal-common.h to hold signal helper functions like force_sig_fault. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/signal-common.h | 14 ++++++++++++++ bsd-user/signal.c | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 bsd-user/signal-common.h diff --git a/bsd-user/signal-common.h b/bsd-user/signal-common.h new file mode 100644 index 00000000000..6207417d39e --- /dev/null +++ b/bsd-user/signal-common.h @@ -0,0 +1,14 @@ +/* + * Emulation of BSD signals + * + * Copyright (c) 2013 Stacey Son + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef SIGNAL_COMMON_H +#define SIGNAL_COMMON_H + +void force_sig_fault(int sig, int code, abi_ulong addr); + +#endif diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 05b277c6422..1206d0d728c 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -19,6 +19,7 @@ =20 #include "qemu/osdep.h" #include "qemu.h" +#include "signal-common.h" =20 /* * Stubbed out routines until we merge signal support from bsd-user @@ -34,6 +35,23 @@ void queue_signal(CPUArchState *env, int sig, target_sig= info_t *info) qemu_log_mask(LOG_UNIMP, "No signal queueing, dropping signal %d\n", s= ig); } =20 +/* + * Force a synchronously taken QEMU_SI_FAULT signal. For QEMU the + * 'force' part is handled in process_pending_signals(). + */ +void force_sig_fault(int sig, int code, abi_ulong addr) +{ + CPUState *cpu =3D thread_cpu; + CPUArchState *env =3D cpu->env_ptr; + target_siginfo_t info =3D {}; + + info.si_signo =3D sig; + info.si_errno =3D 0; + info.si_code =3D code; + info.si_addr =3D addr; + queue_signal(env, sig, &info); +} + void signal_init(void) { } --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745340327674.8561976014039; Sun, 9 Jan 2022 08:22:20 -0800 (PST) Received: from localhost ([::1]:54808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6axW-0008Mf-GX for importer@patchew.org; Sun, 09 Jan 2022 11:22:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6aus-0005MD-H3 for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:34 -0500 Received: from [2607:f8b0:4864:20::d31] (port=36360 helo=mail-io1-xd31.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6auq-00075Z-73 for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:33 -0500 Received: by mail-io1-xd31.google.com with SMTP id w22so3878906iov.3 for ; Sun, 09 Jan 2022 08:19:31 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pqqXPwF6yBDT7HgMyJ17HExIlciTQ3azRU2lsjDmYEg=; b=HTsI3WEuuXfxOpFAMcsDC1v9fpCtbL5XNlfevmloMjhjRI802y36v27cRbRfT/2ui4 og6oP/GPG3mhkerCD9+XcMMg75SOqFhrwb9Ehi75JYtTeWUOUJFaKRNrcjsPYdjYeM+T PiLCx5QmRq1XfGhk2Riui/PQoQNpuF772nB7m+G2ayTwYPNIalHe8/TFGqTM1cRx3QLg qa+ENmIMtwnPdan4Fdv3NKHrEiwdtB9oGu5vg8zvQA+uF3UXLvdMq9ybykX3Nso9JmES 5HS/w6ByTxjXghdhB526k7ePAGJJhR0c0k+mvXlKp7ySchmcqy0QnkPlSr09+j6eHhH/ yM7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pqqXPwF6yBDT7HgMyJ17HExIlciTQ3azRU2lsjDmYEg=; b=xNKf/ElTlFFIP7ZIx8U3GLTa9kcluz5A40byeDQNjN7Si7ZtaUv8d0lEuE29/frs6s RqVH+VmKdfhyHfEfO3QEiwtvow6DdYLZXRmwuVetjzpsO6c5++SdGXONkxQTPqxFYnmV VGUgu+iB9KfuJiVO8zrROcsNOBgMLDG/bgkVdbdnCa17p2fcsB2uC8GI9QueFGPsBlXc M9gE6Mkr5cYx5Gp2tDrVbfgTFe2l+ibnHjBjfOu+kuebe9wfLaFDo81+ydwddGWqQJF1 3Y9x2ensHSEL9L0XGoIxpz0Ud0C49bVP5YAkWvPrfKqSNfAOg4vU4O+Nf10yLG5TwHh6 /3Fw== X-Gm-Message-State: AOAM53288rKoXS+yb0GRJJLc47LIkVM3hLlZ2vKsPMrZii9bczs8/VaS J4ZqibyqrQ1V6I02ffePvjP8Dq5nPMkCl1kU X-Google-Smtp-Source: ABdhPJw+Dis2OIVPlkGuJsdBb6Xo75wHP0bJ8Dwsoj0X45Iovn+g5WFVxnU6TOPFhCRJzg7b8SsGdg== X-Received: by 2002:a02:c60e:: with SMTP id i14mr28366490jan.207.1641745170909; Sun, 09 Jan 2022 08:19:30 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 03/30] bsd-user/signal.c: Implement cpu_loop_exit_sigsegv Date: Sun, 9 Jan 2022 09:18:56 -0700 Message-Id: <20220109161923.85683-4-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d31 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d31; envelope-from=imp@bsdimp.com; helo=mail-io1-xd31.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641745342396100007 Content-Type: text/plain; charset="utf-8" First attempt at implementing cpu_loop_exit_sigsegv, mostly copied from linux-user version of this function. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/signal.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 1206d0d728c..12de0e2dea4 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qemu.h" #include "signal-common.h" +#include "hw/core/tcg-cpu-ops.h" =20 /* * Stubbed out routines until we merge signal support from bsd-user @@ -63,9 +64,17 @@ void process_pending_signals(CPUArchState *cpu_env) void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, MMUAccessType access_type, bool maperr, uintptr= _t ra) { - qemu_log_mask(LOG_UNIMP, "No signal support for SIGSEGV\n"); - /* unreachable */ - abort(); + const struct TCGCPUOps *tcg_ops =3D CPU_GET_CLASS(cpu)->tcg_ops; + + if (tcg_ops->record_sigsegv) { + tcg_ops->record_sigsegv(cpu, addr, access_type, maperr, ra); + } + + force_sig_fault(TARGET_SIGSEGV, + maperr ? TARGET_SEGV_MAPERR : TARGET_SEGV_ACCERR, + addr); + cpu->exception_index =3D EXCP_INTERRUPT; + cpu_loop_exit_restore(cpu, ra); } =20 void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745503445616.6568488832215; Sun, 9 Jan 2022 08:25:03 -0800 (PST) Received: from localhost ([::1]:35050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6b0A-0005ab-FE for importer@patchew.org; Sun, 09 Jan 2022 11:25:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6aus-0005ME-Gy for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:34 -0500 Received: from [2607:f8b0:4864:20::d30] (port=40681 helo=mail-io1-xd30.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6aur-00075j-1K for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:34 -0500 Received: by mail-io1-xd30.google.com with SMTP id q5so14351951ioj.7 for ; Sun, 09 Jan 2022 08:19:32 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q1qZC5vNCCsIJYSakIBaD2nrV2Zz0bBAsRBqPjX58yY=; b=oB2WgEMXJBs9il3FzijYpkTGxzvbcWIhDRvtkZRF9cDK1Evhs5B46givztN89Yhy8O 5mAdCzMtCFKohV5ZY5oN3f1FwK0xMeLVoGNIkRuQX07K1MYdI9SwmU5fAWn/I1nkQnmL cVLLcCRQbr9TnK7OGe7q9qF2fB9WwvAfitka4t+G1MfGyQlIldXuyfDi73Bud9Rv+6Ga DAKcVgyVXAe2noedQvkcgxlKh4SZZKVZ35T0rs+6+3OMcTPxuLpK/t0Df5E7cb1XP2z3 RT6CE9wCrkjDqc6AZClTq0va6403/Wl/t1kg3ir6iUmVk2aiBl0vK722+ItCsEoP6TCT aFKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q1qZC5vNCCsIJYSakIBaD2nrV2Zz0bBAsRBqPjX58yY=; b=sNkI0DnHZPhKxOn1Bdbu4ITiEV+67QvkeNcnBS7/P8cTSuWO6TRZ2xjtDrWj/ltkbo 5TVcTxLHYsNTwfv2qTkOoxS0ynUGC1+GlZQsusTLjWg0zHJkuFTVuqNAXIwRDHofnVqd SjxQTkqUstu9uDf5PlZout26M3dHl6sHnNQ+WwjzAOj/cIMrW3iFdff0+DY3NIIvWUoT A8Fw03IyCIxgXDyuetpaw3I0ozdfl9CBpbx9RG92rgwTOxmZofDvpzrje71s4zSS3W05 DqYCv8IyC7wNtYpmZV9NiXofQFH+MjIWi7xhOGv4hWULyi3u2h/dUTZutTZfMJkQ7pIq RrNQ== X-Gm-Message-State: AOAM533tFVfeox31daNdyWsOIt7N39eBmQccJ0lfB49kLEXM1dOGcHfC ire/N2UDy34s+WFawftwR39quISLr5msWJUp X-Google-Smtp-Source: ABdhPJz9J0p8t9Iub1LfZWE31sgsvKTpJ5BOCaDUisTLq2jj1TQE3tkIjG5/3j2LyPkBrBBHQ6UlMA== X-Received: by 2002:a05:6602:1484:: with SMTP id a4mr3213539iow.112.1641745171768; Sun, 09 Jan 2022 08:19:31 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 04/30] bsd-user/signal.c: implement cpu_loop_exit_sigbus Date: Sun, 9 Jan 2022 09:18:57 -0700 Message-Id: <20220109161923.85683-5-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d30 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641745505547100001 Content-Type: text/plain; charset="utf-8" First attempt at implementing cpu_loop_exit_sigbus, mostly copied from linux-user version of this function. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/signal.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 12de0e2dea4..844dfa19095 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -80,7 +80,13 @@ void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong a= ddr, void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, MMUAccessType access_type, uintptr_t ra) { - qemu_log_mask(LOG_UNIMP, "No signal support for SIGBUS\n"); - /* unreachable */ - abort(); + const struct TCGCPUOps *tcg_ops =3D CPU_GET_CLASS(cpu)->tcg_ops; + + if (tcg_ops->record_sigbus) { + tcg_ops->record_sigbus(cpu, addr, access_type, ra); + } + + force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, addr); + cpu->exception_index =3D EXCP_INTERRUPT; + cpu_loop_exit_restore(cpu, ra); } --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1641745504; cv=none; d=zohomail.com; s=zohoarc; b=TGFBLvIcG6g1rzZVr6c9Q4gU0xMltSLB9Ctugn4+HCWhqDmu7P7YJSYy44ONYqvITDifttKRwuSTwP/Ud7NXAWOkARYfrjRiHp/1YOuPyDCVly52+1+WkZjA+4Nu+r2lKOztL+lJx6da8xh4XbTkCqc0pth7TMLKeipJDQx8Eps= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641745504; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dyAUpEDzRYL6p8x32pfiafDgm01DpIQ/wKUR1iah5qg=; b=IoDcN78rsregF9QFO/oIcXCvv+21+grN2Dvgmi2UgC+g24yAMazq6nLuBpCfeKS+Ui5pfhN//BAcDRz1PE3nr2ER7+iqmrxx3Asgcbb7rm5eg5anA7joTr9oWJoyvl+RUNSC4cauD8SGBFdca5QEUEa1Rj4n9yzuqSV8gcw2dIw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745504404790.2372789626688; Sun, 9 Jan 2022 08:25:04 -0800 (PST) Received: from localhost ([::1]:35086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6b0B-0005bn-Ee for importer@patchew.org; Sun, 09 Jan 2022 11:25:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6auu-0005NA-6t for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:36 -0500 Received: from [2607:f8b0:4864:20::12e] (port=45600 helo=mail-il1-x12e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6aus-00075x-OI for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:35 -0500 Received: by mail-il1-x12e.google.com with SMTP id h5so970397ilq.12 for ; Sun, 09 Jan 2022 08:19:34 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dyAUpEDzRYL6p8x32pfiafDgm01DpIQ/wKUR1iah5qg=; b=7qxQfOYRP6CNe6ZsSVBz60cpkFNFeCrhZYNmXzoEqakZ1/ndOWBOeAdquUcJHTLJOO nijGZjAQlVgbBCkp6g+p77JWdfI+766yn4mSGVCiPhBYPA0EnP64A1SIVXRFVZ+A81O0 oYjGWuNRy2fOcQByC7OcdOWD5axA16Eru7NUYrscxalHyP7YsVLnmlhdfyLWI6SMvVTx OdOGjKEsX3j+7qMl8tsgh83Z5B8/YF4NmKZe7AyCgbC2I/REfZVmNVEvTFeRbvYcinsj rbSc6cIQLt5DghcZoIvYHg0lZZpeRZtFJJchscRL1vPPDEtRo1sJgbswPzMsjfrWS/ZV 8p5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dyAUpEDzRYL6p8x32pfiafDgm01DpIQ/wKUR1iah5qg=; b=XcgCqhGINPrpE2mNAbjnWrmPBLnulUndkH5ixx2vJ7/IVsD33ZcalFE2aMMfq8bqAu EkDK3G65aX58VIzfyjz7AJ2/hILL8XwT84jrvCkBu6SiO3ImTda+bz8Dkg5zqDw+37eH +6kuRW1SMeozetwqjZW8MYTSlKGuLSTI+x5W83cS0P1SRRPwmAYmJpEf7JifhHJY3mMr QB9ojskO3YKRpSAlZeiWyC5kaNex7CaBRNN3iLZgBId1C1UShEbj0HEZqNuHGOsIHvLM VkLepIj29IqXP/Qk8J8DeOwqEdlD1ro6csXm1vWBH55ZE2q7ek152NtQGrnViTvaHuoS antw== X-Gm-Message-State: AOAM53378exstLnsUsAkK4HK0csvDgCkx93W5ZLjgKp0NLbRfbQBPcJD VyNAK/F9EpIti1ZGm39PjlW9mBfa8uWr+Lwx X-Google-Smtp-Source: ABdhPJyCxYpnPnFK+86BfcvFklQE3Gl8AjCPSGB91vYklkqcqD3rJMTPYlMm6xUymjg+zyr9ahx3Vw== X-Received: by 2002:a92:c26a:: with SMTP id h10mr2912982ild.320.1641745173002; Sun, 09 Jan 2022 08:19:33 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 05/30] bsd-user/arm/arget_arch_cpu.h: Move EXCP_DEBUG and EXCP_BKPT together Date: Sun, 9 Jan 2022 09:18:58 -0700 Message-Id: <20220109161923.85683-6-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12e (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12e; envelope-from=imp@bsdimp.com; helo=mail-il1-x12e.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1641745505554100002 Content-Type: text/plain; charset="utf-8" Implement EXCP_DEBUG and EXCP_BKPT the same, as is done in linux-user. The prior adjustment of register 15 isn't needed, so remove that. Remove a redunant comment (that code in FreeBSD never handled break points). Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_cpu.h | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index c526fc73502..05b19ce6119 100644 --- a/bsd-user/arm/target_arch_cpu.h +++ b/bsd-user/arm/target_arch_cpu.h @@ -21,6 +21,7 @@ #define _TARGET_ARCH_CPU_H_ =20 #include "target_arch.h" +#include "signal-common.h" =20 #define TARGET_DEFAULT_CPU_MODEL "any" =20 @@ -64,19 +65,7 @@ static inline void target_cpu_loop(CPUARMState *env) } break; case EXCP_SWI: - case EXCP_BKPT: { - /* - * system call - * See arm/arm/trap.c cpu_fetch_syscall_args() - */ - if (trapnr =3D=3D EXCP_BKPT) { - if (env->thumb) { - env->regs[15] +=3D 2; - } else { - env->regs[15] +=3D 4; - } - } n =3D env->regs[7]; if (bsd_type =3D=3D target_freebsd) { int ret; @@ -171,14 +160,8 @@ static inline void target_cpu_loop(CPUARMState *env) queue_signal(env, info.si_signo, &info); break; case EXCP_DEBUG: - { - - info.si_signo =3D TARGET_SIGTRAP; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - info.si_addr =3D env->exception.vaddress; - queue_signal(env, info.si_signo, &info); - } + case EXCP_BKPT: + force_sig_fault(TARGET_SIGTRAP, TARGET_TRAP_BRKPT, env->regs[1= 5]); break; case EXCP_YIELD: /* nothing to do here for user-mode, just resume guest code */ --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1641745504; cv=none; d=zohomail.com; s=zohoarc; b=lbixklF7GotzCp2rb3a2zmC+QnwHtUwWGLJVu3X35fqsl+NV2fHBUohKfxmXDwEBvJUZVCxdyVXffkIGbpZFsNBonnpRmccAjfmUxRzsQC76kvKgg7cd9TR+yoM5lUlvhCx0BxqOaaPxZXBTHQw7+F3TKl3Zb8SRh8arFyYK2fs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641745504; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rYbOaGywm/gXp+KUiOApi+gy1fj4x1kM6ZqHK5ccGBE=; b=L56otSqt9BKe8HRObzwsTqEEJntRhNGsh3nKnjvMnzYQ0vnhU1LAL+xCgaMZMkgY5Djg+Gd4qpElLbJIJw+1io2wvV57tbhFclc5dklWwUZgXszNkZofneLTM1c6a/7BU3wic+mgbXQaGTYzsKcV1qlRt7SU0Olr81ZKJ6FHcRA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745504860669.4304693541743; Sun, 9 Jan 2022 08:25:04 -0800 (PST) Received: from localhost ([::1]:35144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6b0B-0005eE-Q6 for importer@patchew.org; Sun, 09 Jan 2022 11:25:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6auv-0005OD-0u for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:38 -0500 Received: from [2607:f8b0:4864:20::12b] (port=43636 helo=mail-il1-x12b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6aut-00076C-Nl for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:36 -0500 Received: by mail-il1-x12b.google.com with SMTP id d3so9259607ilr.10 for ; Sun, 09 Jan 2022 08:19:35 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rYbOaGywm/gXp+KUiOApi+gy1fj4x1kM6ZqHK5ccGBE=; b=kdr7OHNd0H9bEHLo905dqlkvCy2I1C9PXVh2f0JVEkfy6T28GaIE3JywFDH1vY6n/8 tvdNNI1yvcK07OeRZhZqj4OiGghQZ+WIwRLJ+EnyIl02CnjRF1i4nisW4bn330xUt5yo 2t+icccQh6RJ9/WBWywS6G7ThkmJY5fOEPhVdTeILC3UKe9ExGfpMne01jz0uzXgIblO JIPnk6y9QY3JOefZEUyd1I1qwXFDmd6PmpzwYmygFO61OBeJbMBrw7ETxsLr7eM/x6KO crDy8BmxccecuGKnZwKnp6Bc9R2WA75S6LFS3gRAECjJZdQ3P6LrziruZ2w0ogfsBL3F bFqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rYbOaGywm/gXp+KUiOApi+gy1fj4x1kM6ZqHK5ccGBE=; b=QeQQBmvOIbZMjdTK3ajjNAZJyKmCbtxa77o7HWFFeoGEkuEi2ghHi62xdZuBfj5Rnr IAWh0eARTtii3fGQ5zTwoMw5+TluI/y3e6fmS6co15uu3EQUvb7X40LtR0g9YFosQntV 5noZQxZ0RPBY/gDpy9YOVhSlo8e4R9rqDNSUTwOdnUvGKLJxPowbyBVLHAIFp5OYTWlZ /vJ8fusE2MWshGF9d6ym+lzQDfmbnL6dEdevEqbZQj0zDtWWZ19gWDuvzW2AfjPKvVfk gZMHy2AsmUB+OW2SkjpEHFdLLH3A+M68jYQI/dK09TiMX6sc89TP7YwiBB09QyQ+HmFn PuTA== X-Gm-Message-State: AOAM5310bywbuVsM+493VS3Jm48zDHMPVgCFiNgnMkqOdaWYQr/9v0V2 TkvGilvWm+z2AKXGL76p5LRGuj98M2Psgz9H X-Google-Smtp-Source: ABdhPJyTnNFXsutbWUNR0i6pqLTMqiNA8o8Z+Hz1F1GbpkunHExtzPt1RpSlvC+XVnkQALU2gQFGgA== X-Received: by 2002:a05:6e02:1a84:: with SMTP id k4mr31563316ilv.29.1641745174371; Sun, 09 Jan 2022 08:19:34 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 06/30] bsd-user/arm/target_arch_cpu.h: Correct code pointer Date: Sun, 9 Jan 2022 09:18:59 -0700 Message-Id: <20220109161923.85683-7-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12b (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12b; envelope-from=imp@bsdimp.com; helo=mail-il1-x12b.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1641745507261100005 Content-Type: text/plain; charset="utf-8" The code has moved in FreeBSD since the emulator was started, update the comment to reflect that change. Remove now-redundant comment saying the same thing (but incorrectly). Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index 05b19ce6119..905f13aa1b9 100644 --- a/bsd-user/arm/target_arch_cpu.h +++ b/bsd-user/arm/target_arch_cpu.h @@ -73,7 +73,7 @@ static inline void target_cpu_loop(CPUARMState *env) int32_t syscall_nr =3D n; int32_t arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8; =20 - /* See arm/arm/trap.c cpu_fetch_syscall_args() */ + /* See arm/arm/syscall.c cpu_fetch_syscall_args() */ if (syscall_nr =3D=3D TARGET_FREEBSD_NR_syscall) { syscall_nr =3D env->regs[0]; arg1 =3D env->regs[1]; --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1641745595; cv=none; d=zohomail.com; s=zohoarc; b=Y5HI/IvRUdgA23W4pgd/y/b0PeJD71IfdDElBBwty/gLZ9FwF814Bh4T2YUmGzlpx7SsbKyk4LXOjtfDi/0JpUZmeBN8AJz1UO8QUm2llpuTqaqLOz3D3W7TRZVA5oJfA1kfXPF5V6En2diLgk93PiyA5rWMxJutQpwlhNfBhHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641745595; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uqy0flKsbKkUSoZqssjXKCl5UFRKmvmV8nOqjaZTBpE=; b=O61q+e9hyLop02rwEPqzAaTgzDkOQCCjYQVW3yCa76b5y71mzCIBW1InC2IwYjofmCoQ69bSMAfZdMiOKGhCwbX2HdkDDILOxOPF3+KZXKz25uaCMqTcu4A6+J1teo3GGUDKgiGM78MEifvIqwqBLBHdGFz5O1rlvxVs7RvATVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745595103120.92772137000452; Sun, 9 Jan 2022 08:26:35 -0800 (PST) Received: from localhost ([::1]:37966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6b1e-0007ZK-5R for importer@patchew.org; Sun, 09 Jan 2022 11:26:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6auw-0005OL-6w for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:38 -0500 Received: from [2607:f8b0:4864:20::d2d] (port=42914 helo=mail-io1-xd2d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6auu-00076L-Ui for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:37 -0500 Received: by mail-io1-xd2d.google.com with SMTP id o7so14344097ioo.9 for ; Sun, 09 Jan 2022 08:19:36 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uqy0flKsbKkUSoZqssjXKCl5UFRKmvmV8nOqjaZTBpE=; b=b9jx0XmJ9ZNnO8eaGPsQ+8ttWuB4QBKG7lVwSvfXO0WgAjDK1ZZFFYPENYa/tGyVa3 19Uuw9ZTectCo99hpybcdsjblPgPD3R95Qkyr5sfVdwwOl80fnc9hqC/Ij0JeS3AgU0/ X++lYVsd1By+uEs1SxkCo21i/hg6GPjUW8EiBsuCm8N3L4YvgzPtgsUkhOAVq9Pb30u/ kd3SRi9OEgDvgSo1n3z6AZ9weRb4o2KfXPCYeO0WntIupfc88ngASe7SCkFJFXKAchhp e+h85I5wOkSRFdEKBHXf/0X+OtAn+zFCV1rl/TfJkeMNV26Pkd1JsinT3tdweLa7NlP9 +JyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uqy0flKsbKkUSoZqssjXKCl5UFRKmvmV8nOqjaZTBpE=; b=aYpWt0ColynLUzdYHGHYyWl7G0qWca4wZegQvvVfeutMnxfkkPdvMiW1/asrHuEsKD BWHSg5L0TRmaRyeQluzY5RbvTx4VXi8JQ87SbDho+hl/fkwCyb66OxSaE5+nvrLgVa8F Uvw92Q9bIbl2UWESB6vQ5zRT1DbRgFk/3o/bhvGrSWlwToZuTa5qqPLxjYmN/hoWTIE7 nHA/it1PeCreUn7ebkHZzGRcc1rBUpHeYTq+JRwiFFuF8Sm7UqkBeMorOz7gX69ESx+q O6TZzl6z+KtlVZaXo+hs5bq3+zuFf3anWmPvk8iCKMQj9etu5jKIGh4ku13zDrgVECJO zPdw== X-Gm-Message-State: AOAM532K8pMycuFuWosUf+7P51gTx5gGpD2NJJ9po0EzwvgguVExA9nP FUkUUGx3cBGHHRpbfVPbvx4wNy4IhdshMyoT X-Google-Smtp-Source: ABdhPJzve/tZK3fjbT4Zox+8MplHAElU+jI6lj8ifJ0jox5rVfZqqLIhIRHXccEXtXnoDs3Zobn9TA== X-Received: by 2002:a05:6602:2ac2:: with SMTP id m2mr1222043iov.152.1641745175302; Sun, 09 Jan 2022 08:19:35 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 07/30] bsd-user/arm/target_arch_cpu.h: Use force_sig_fault for EXCP_UDEF Date: Sun, 9 Jan 2022 09:19:00 -0700 Message-Id: <20220109161923.85683-8-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2d; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2d.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1641745597002100001 Content-Type: text/plain; charset="utf-8" Use force_sig_fault to implement unknown opcode. This just uninlines that function, so simplify things by using it. Fold in EXCP_NOCP and EXCP_INVSTATE, as is done in linux-user. Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_cpu.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index 905f13aa1b9..996a361e3fe 100644 --- a/bsd-user/arm/target_arch_cpu.h +++ b/bsd-user/arm/target_arch_cpu.h @@ -51,18 +51,12 @@ static inline void target_cpu_loop(CPUARMState *env) process_queued_cpu_work(cs); switch (trapnr) { case EXCP_UDEF: - { - /* See arm/arm/undefined.c undefinedinstruction(); */ - info.si_addr =3D env->regs[15]; - - /* illegal instruction */ - info.si_signo =3D TARGET_SIGILL; - info.si_errno =3D 0; - info.si_code =3D TARGET_ILL_ILLOPC; - queue_signal(env, info.si_signo, &info); - - /* TODO: What about instruction emulation? */ - } + case EXCP_NOCP: + case EXCP_INVSTATE: + /* + * See arm/arm/undefined.c undefinedinstruction(); + */ + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->regs[15= ]); break; case EXCP_SWI: { --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1641745719; cv=none; d=zohomail.com; s=zohoarc; b=VLqGZowxVNwbSze96Lhyp6bVPPAx3emtKNJSv8p2pL3novoc6NKmPXW0CWJwevoWjM6TUPDyo29AbX/P8k2i/HxBROSwkjrb+TmeUAxj/oyl4YQtMXglSQX0b1IjWLheINh6CSK7ojmf7yKEMLOGW9Qlyf+CjowVpfX6llOmniU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641745719; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NWE35M5y7jk9AxHhr1h+K7kB1EAcuO0k+kc2X1bs6cU=; b=azTiqHz8LyW7llNNiBQBFagoZrNz1dwoq6XkxuneusoWUzfToOm3NlwVAtm+EXLGGJdwcD0mu2hTi3DeRiFqDspduCBmtvefN5iDg5et5VI4Faax1pRu2paqe89Oa/73Fglu2tfmEiLjmhaimBJkXjcvBZuzywYtGTYJ8Gb40c4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164174571906224.287294160298188; Sun, 9 Jan 2022 08:28:39 -0800 (PST) Received: from localhost ([::1]:43814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6b3d-00034K-VV for importer@patchew.org; Sun, 09 Jan 2022 11:28:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6av0-0005Y0-2z for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:42 -0500 Received: from [2607:f8b0:4864:20::d2a] (port=40676 helo=mail-io1-xd2a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6auy-00076c-L2 for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:41 -0500 Received: by mail-io1-xd2a.google.com with SMTP id q5so14352192ioj.7 for ; Sun, 09 Jan 2022 08:19:40 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NWE35M5y7jk9AxHhr1h+K7kB1EAcuO0k+kc2X1bs6cU=; b=sjetmxgZKNt6hXT961KklsVpGaYUpoPUBJezAza6TBEDXubT8O3rSGRAucKycG5Qug M+RwEtf+4MGTXGksmmXueksyB7UVlZSCW7JQDSK5N0VUPWL2bjAWuVwr/kpkXMuJskRY kaIyEuRBK7Boljj+aceTcYeJqOiT3Qu35uOFZ3mixlbtyfRptk9zLKqc/lznkJXqVs7D o7SSFAn/xxXAusYVIWE5MJ/K73UzcxQOkBhrG7chlDLZRavTVL3oHYcg23UgjkzVh0dy DdgmFs2TNCkovDTHPWtag12Q8vz/cHwBnBHzX479WDVcq/W70tPmc6ruuVhy9iTO/YWx tTyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NWE35M5y7jk9AxHhr1h+K7kB1EAcuO0k+kc2X1bs6cU=; b=AdbyjytD8Ct8vfeIGrRV+9ALIHLsTUkFjIARLD+HMKrg7kh4d1Ngv0/qmJ6LbX4yO+ oTG9SzhaOkaWtQGKoei51/5K7xqurQw9U66UTYFIOe9d9BxglWBfxvxTkFU6+QpQ2qDy 9mK8iTyccLf3tVX/bCPCss/8Dok4n1uSZ70kifyiVLw2oWNIZ4EsxPWeJ5Q7b4NdMjpT MTRkG7lQIX/cGqtjuWIEqm8dU6cEj7F3xDk38dlcE7P8yBdp9+2udWUaJG3YD391OuDf PKx82Zz7WagxCHZFbj325CTZoxuK0N7jnK3nkzBvM6Tlg82c0yM98CCXMlZ7yNlTYv14 DtFA== X-Gm-Message-State: AOAM532KqIyA44NMRfp6RdBPcjSSoDlQ0H3fWCM27E0CpujGfR1mJn+W iqBzs4BHW74Vks6c4c+RS1G9Fxn5wU2DrAA4 X-Google-Smtp-Source: ABdhPJzjHmqoAAo7lzunnUtUGxZ2SKVMayJoynU6PWXl/jbrsoI5nr0v9f4dIPAE6dLjpzYEz4rTFg== X-Received: by 2002:a05:6602:134a:: with SMTP id i10mr33498520iov.147.1641745177795; Sun, 09 Jan 2022 08:19:37 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 08/30] bsd-user/arm/target_arch_cpu.h: Implement data faults Date: Sun, 9 Jan 2022 09:19:01 -0700 Message-Id: <20220109161923.85683-9-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2a; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2a.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1641745720650100005 Content-Type: text/plain; charset="utf-8" Update for the richer set of data faults that are now possible. Copied largely from linux-user/arm/cpu_loop.c Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_cpu.h | 44 ++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index 996a361e3fe..51e592bcfe7 100644 --- a/bsd-user/arm/target_arch_cpu.h +++ b/bsd-user/arm/target_arch_cpu.h @@ -39,8 +39,7 @@ static inline void target_cpu_init(CPUARMState *env, =20 static inline void target_cpu_loop(CPUARMState *env) { - int trapnr; - target_siginfo_t info; + int trapnr, si_signo, si_code; unsigned int n; CPUState *cs =3D env_cpu(env); =20 @@ -143,15 +142,40 @@ static inline void target_cpu_loop(CPUARMState *env) /* just indicate that signals should be handled asap */ break; case EXCP_PREFETCH_ABORT: - /* See arm/arm/trap.c prefetch_abort_handler() */ case EXCP_DATA_ABORT: - /* See arm/arm/trap.c data_abort_handler() */ - info.si_signo =3D TARGET_SIGSEGV; - info.si_errno =3D 0; - /* XXX: check env->error_code */ - info.si_code =3D 0; - info.si_addr =3D env->exception.vaddress; - queue_signal(env, info.si_signo, &info); + /* + * See arm/arm/trap-v6.c prefetch_abort_handler() and data_abo= rt_handler() + * + * However, FreeBSD maps these to a generic value and then use= s that + * to maybe fault in pages in vm/vm_fault.c:vm_fault_trap(). I + * believe that the indirection maps the same as Linux, but ha= ven't + * chased down every single possible indirection. + */ + + /* For user-only we don't set TTBCR_EAE, so look at the FSR. */ + switch (env->exception.fsr & 0x1f) { + case 0x1: /* Alignment */ + si_signo =3D TARGET_SIGBUS; + si_code =3D TARGET_BUS_ADRALN; + break; + case 0x3: /* Access flag fault, level 1 */ + case 0x6: /* Access flag fault, level 2 */ + case 0x9: /* Domain fault, level 1 */ + case 0xb: /* Domain fault, level 2 */ + case 0xd: /* Permision fault, level 1 */ + case 0xf: /* Permision fault, level 2 */ + si_signo =3D TARGET_SIGSEGV; + si_code =3D TARGET_SEGV_ACCERR; + break; + case 0x5: /* Translation fault, level 1 */ + case 0x7: /* Translation fault, level 2 */ + si_signo =3D TARGET_SIGSEGV; + si_code =3D TARGET_SEGV_MAPERR; + break; + default: + g_assert_not_reached(); + } + force_sig_fault(si_signo, si_code, env->exception.vaddress); break; case EXCP_DEBUG: case EXCP_BKPT: --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745716246596.4334153839021; Sun, 9 Jan 2022 08:28:36 -0800 (PST) Received: from localhost ([::1]:43644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6b3b-0002xs-1s for importer@patchew.org; Sun, 09 Jan 2022 11:28:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6av0-0005Zp-HM for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:42 -0500 Received: from [2607:f8b0:4864:20::d2e] (port=46971 helo=mail-io1-xd2e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6auz-00076g-6j for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:42 -0500 Received: by mail-io1-xd2e.google.com with SMTP id w9so1346243iol.13 for ; Sun, 09 Jan 2022 08:19:40 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ES958KZKo5L8ikxaMtAOpI9/vZpy1zFREkT997pUi2c=; b=Ew6xBrV/iqN3Lq6qviqeLQhp31SZH4hyfzZkk6AgSWx61ujtaRfjRSAXA2pJMzvYDr MlwD9qOVEF0t86SbriaekZz37Dzl5xfgbvCuWASMTDQ4BfIZOZHwUAqLj5lTACGgRI5M yAbMcaT3sKOTMRagA3gvISkgU2TOmxVvo7YZWPzHdAbMTpzHfc+PakXeaZA87/IfMA3d f1zlw7UOurw5dnh0gsrddYJ+MoAZ9STXqW4fUWuArXDxAIXEY2hGjs3ttjRZcXDEVwrx 3EaLkoxy1fM3ICVfs2MhxLX8HTMeNpFq1jwoSX+AnIL2nfpW1NrLA8GyqULors03XIzc U2HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ES958KZKo5L8ikxaMtAOpI9/vZpy1zFREkT997pUi2c=; b=CFXGZLs6zo2qCTOW9sVNfNlrqRv7ngAnTVSS/3/hJxFsSBk2/JOmoQDURoo1uDPgZb +/g77upb9Cf1MNx1Zy3m9mVaVvaPRmAeXhHikEl+vrLFp8DYK807g1gq+IFzB8FEeoIg g5lh9gooI/BK/LaRHS6hi5IJfx+aFU+TXsIpbda9tYLqwz97WT4mA5yyHAxOQ9ojyvTk jlRx1OByeuubLWm0/hGmP7pCGxaVM5IUyFLWkhFxQ6G8oQxQJmeKCQRMfK/eGqtPSRVw /CU3PatLzudnkMXL383wBJ7uxv1Wz0aBZo2iWAYUU85PjNcK0o8yYCZMTp2ahaa22NIl xbfQ== X-Gm-Message-State: AOAM532h/GBsznEe2RFL4MNp8n5p1uJTCM65+Xgn4D0eQzgrLqqx6aem 1aDJQxu3iaTJUsEIUg7ovat0ggJhbUa9BaRO X-Google-Smtp-Source: ABdhPJzUUgMxh839zDr6Lj1dDQxFIyJCbX/pw+HUa1dVr8Tk8wQguIjUVXBJz2zzATkB2kybo8cI0g== X-Received: by 2002:a6b:f804:: with SMTP id o4mr34000090ioh.110.1641745179817; Sun, 09 Jan 2022 08:19:39 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 09/30] bsd-user/signal.c: implement abstract target / host signal translation Date: Sun, 9 Jan 2022 09:19:02 -0700 Message-Id: <20220109161923.85683-10-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2e (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2e; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2e.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641745718638100001 Content-Type: text/plain; charset="utf-8" Implement host_to_target_signal and target_to_host_signal. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Peter Maydell --- bsd-user/qemu.h | 2 ++ bsd-user/signal.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 1b3b974afe9..334f8b1d715 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -210,6 +210,8 @@ long do_sigreturn(CPUArchState *env); long do_rt_sigreturn(CPUArchState *env); void queue_signal(CPUArchState *env, int sig, target_siginfo_t *info); abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp); +int target_to_host_signal(int sig); +int host_to_target_signal(int sig); =20 /* mmap.c */ int target_mprotect(abi_ulong start, abi_ulong len, int prot); diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 844dfa19095..7ea86149981 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -2,6 +2,7 @@ * Emulation of BSD signals * * Copyright (c) 2003 - 2008 Fabrice Bellard + * Copyright (c) 2013 Stacey Son * * 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 @@ -27,6 +28,16 @@ * fork. */ =20 +int host_to_target_signal(int sig) +{ + return sig; +} + +int target_to_host_signal(int sig) +{ + return sig; +} + /* * Queue a signal so that it will be send to the virtual CPU as soon as * possible. --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745754397360.58714089229636; Sun, 9 Jan 2022 08:29:14 -0800 (PST) Received: from localhost ([::1]:46430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6b4D-0004pi-E4 for importer@patchew.org; Sun, 09 Jan 2022 11:29:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6av2-0005gT-LM for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:44 -0500 Received: from [2607:f8b0:4864:20::d2f] (port=36359 helo=mail-io1-xd2f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6av1-00076u-3a for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:44 -0500 Received: by mail-io1-xd2f.google.com with SMTP id w22so3879305iov.3 for ; Sun, 09 Jan 2022 08:19:42 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/pXfXOZAWxFzYm835/ZHZbEkGgV0ubBNuOitacKiu3M=; b=jFcAhrunVq/CIXC8FdII9/7CC044uwHPe6AS62BYwGmU678NUYAoRUsjjtOf4ytUjN IX9rpfzpQsvtCQ/mIIasEkPYPqwsFr/iClDqO9VsxzzguAY3kIfrN9vLEdG20NT+ENB1 q3UhrVy7FoaA8RHRpgfF68Mg0asnaLIpxO5VdDV+4n9uoxwNbrS7r4txEzeJPivA1Bqk rBoVUCh3CyY97MDKHkAjaPhSKhMzj9VyEap5+q6GekZlF796kiF2VnjHNsV2eIMgUdG0 GZJIJVFGIbs2zEhfIlNpxOnykKRG/RU73WaoDpBQ1Je7MQ36HI2KklA5c63sUUlJUg22 r9XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/pXfXOZAWxFzYm835/ZHZbEkGgV0ubBNuOitacKiu3M=; b=zKIsi2e6NePCbn+ycdMyATktEzoLsEgYk+T1Kit2UB8tE37Tx3YP2+hLdLiWQ1kCdR RAFqPHlNWz/UUnCGwWNZI4+GBRe4N/6nYwWbj6m1NbE7bIUi2jqCq55oSy4RsiV0Xx/C 28Wp43k8nacQXw0+lY63BgUAlnxM1BipqOkDv6o9vzAHXxoUg2zvo+IQl69uHoHohNfQ DN1BxVI90kmHgkV74KnqxwgRyrY5QLF7V9swJ/+0Q5170WX4LroZDz6S9Rkfu9dvo5VY CVzidBPuTffhCFSAVxipaUjAqWbV3zdJgpaI427V8ivENVLtEuKyTsUQvT3drxqs5k/F DpzA== X-Gm-Message-State: AOAM531uNe3ffMIldT+C0pjmNsbPl/EqZpvRUd3Uw8Mx6kq5THxLxwHP n0TGEtq/kD7DLfz375aPOHnwkNg4SYqNXQPs X-Google-Smtp-Source: ABdhPJx5noQP9DaZz3hVf0bXQb9UFzsHG044LoM3A+tuKrysLp7i/NNbIA3upiTN8GekiIa2xTzXbg== X-Received: by 2002:a02:b707:: with SMTP id g7mr36176701jam.86.1641745180767; Sun, 09 Jan 2022 08:19:40 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 10/30] bsd-user/signal.c: Implement signal_init() Date: Sun, 9 Jan 2022 09:19:03 -0700 Message-Id: <20220109161923.85683-11-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2f (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2f; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2f.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641745756721100001 Content-Type: text/plain; charset="utf-8" Initialize the signal state for the emulator. Setup a set of sane default signal handlers, mirroring the host's signals. For fatal signals (those that exit by default), establish our own set of signal handlers. Stub out the actual signal handler we use for the moment. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/qemu.h | 1 + bsd-user/signal.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 334f8b1d715..0e0b8db708b 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -97,6 +97,7 @@ typedef struct TaskState { struct qemu_sigqueue sigqueue_table[MAX_SIGQUEUE_SIZE]; /* siginfo que= ue */ struct qemu_sigqueue *first_free; /* first free siginfo queue entry */ int signal_pending; /* non zero if a signal may be pending */ + sigset_t signal_mask; =20 uint8_t stack[]; } __attribute__((aligned(16))) TaskState; diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 7ea86149981..b2c91c39379 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -28,6 +28,9 @@ * fork. */ =20 +static struct target_sigaction sigact_table[TARGET_NSIG]; +static void host_signal_handler(int host_sig, siginfo_t *info, void *puc); + int host_to_target_signal(int sig) { return sig; @@ -47,6 +50,28 @@ void queue_signal(CPUArchState *env, int sig, target_sig= info_t *info) qemu_log_mask(LOG_UNIMP, "No signal queueing, dropping signal %d\n", s= ig); } =20 +static int fatal_signal(int sig) +{ + + switch (sig) { + case TARGET_SIGCHLD: + case TARGET_SIGURG: + case TARGET_SIGWINCH: + case TARGET_SIGINFO: + /* Ignored by default. */ + return 0; + case TARGET_SIGCONT: + case TARGET_SIGSTOP: + case TARGET_SIGTSTP: + case TARGET_SIGTTIN: + case TARGET_SIGTTOU: + /* Job control signals. */ + return 0; + default: + return 1; + } +} + /* * Force a synchronously taken QEMU_SI_FAULT signal. For QEMU the * 'force' part is handled in process_pending_signals(). @@ -64,8 +89,51 @@ void force_sig_fault(int sig, int code, abi_ulong addr) queue_signal(env, sig, &info); } =20 +static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) +{ +} + void signal_init(void) { + TaskState *ts =3D (TaskState *)thread_cpu->opaque; + struct sigaction act; + struct sigaction oact; + int i; + int host_sig; + + /* Set the signal mask from the host mask. */ + sigprocmask(0, 0, &ts->signal_mask); + + /* + * Set all host signal handlers. ALL signals are blocked during the + * handlers to serialize them. + */ + memset(sigact_table, 0, sizeof(sigact_table)); + + sigfillset(&act.sa_mask); + act.sa_sigaction =3D host_signal_handler; + act.sa_flags =3D SA_SIGINFO; + + for (i =3D 1; i <=3D TARGET_NSIG; i++) { + host_sig =3D target_to_host_signal(i); + sigaction(host_sig, NULL, &oact); + if (oact.sa_sigaction =3D=3D (void *)SIG_IGN) { + sigact_table[i - 1]._sa_handler =3D TARGET_SIG_IGN; + } else if (oact.sa_sigaction =3D=3D (void *)SIG_DFL) { + sigact_table[i - 1]._sa_handler =3D TARGET_SIG_DFL; + } + /* + * If there's already a handler installed then something has + * gone horribly wrong, so don't even try to handle that case. + * Install some handlers for our own use. We need at least + * SIGSEGV and SIGBUS, to detect exceptions. We can not just + * trap all signals because it affects syscall interrupt + * behavior. But do trap all default-fatal signals. + */ + if (fatal_signal(i)) { + sigaction(host_sig, &act, NULL); + } + } } =20 void process_pending_signals(CPUArchState *cpu_env) --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1641745933; cv=none; d=zohomail.com; s=zohoarc; b=SRtPQh4Bi7De9U5lfUv5zC7x/iXJgnlunJ8IbNTQUMyvgxOtzZaRbFDoeFq5uifus0kCS+emoLU79s9rY6Dpbp+xa2aAGbp4q6wpksQvwSsJVJ5mc7t0bxbCoiBkxIQQBxtJlcXl0EFER6jIEqiA4w+KtLPFI2R3h7MVUi43fRI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641745933; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=m6zT6JmKfXUxNyMR/vcgYSHHm0Jg54YZ5K/1F7EtxxU=; b=lmnG5CpqN1O+0op3vNawLThqIDGC/Ka4NjT+FRQrJjF4H+VYyqgUvU6xGkLBD9tzdfExeQtM3IU0Zq0PSotvyhqK4DRdc/pahpjRLzLFyuAf3oUOldqksj6uaYfdnaTjbsARvyj4l42c5749da1kcJmrRBn+FGNe5t3pIK4V9W0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164174593326980.07275882291015; Sun, 9 Jan 2022 08:32:13 -0800 (PST) Received: from localhost ([::1]:55032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6b76-0002FV-8P for importer@patchew.org; Sun, 09 Jan 2022 11:32:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6av3-0005kK-T8 for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:46 -0500 Received: from [2607:f8b0:4864:20::d34] (port=38776 helo=mail-io1-xd34.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6av2-000770-F7 for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:45 -0500 Received: by mail-io1-xd34.google.com with SMTP id u8so14396878iol.5 for ; Sun, 09 Jan 2022 08:19:44 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m6zT6JmKfXUxNyMR/vcgYSHHm0Jg54YZ5K/1F7EtxxU=; b=6Rh1fTkPJDtjmQJAI/U6koy7sZ5zlBP2ELNeY7wGSLX1NEG7xKuSCdAyRU5jpSp6+l DsPT3nmJKB2XfWBEWY0Pu3NcuAuQg2ijU++T2il+8hmhgZLjPRkwGW89ayj1hZL8LOGC ufJYkzpLZqHEdf6XJF1t9vFQZvIFug6jNERXpY+o8KXaKsb7yRkdfT0BYJMZWZMF41ix 5erRKXpuj08Sp0NQDlL4rApv8xjdHWoLv2/x6txLIBlJcjJN4bqPQN42zmX+9Zwr1HN/ vr57SG31PlCcYRvOoF1YxGQUbDSwfDJMw5a+IMfBO9hSmokFwGHfWYfSWlDoDpkiWB5a topg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m6zT6JmKfXUxNyMR/vcgYSHHm0Jg54YZ5K/1F7EtxxU=; b=vXTPZljHZGi9xpdBeAbhn2ksxwwNWGMbsW86lPFtxe7rEst6FQNTnuu9OELMSr6ACp B3g1RU8faxmXrwtKa4UkiqKwUmm1Y8tv5nIk/vWAZDIQ97PqVcgbyP3pczYwSA0WtMeY TqB6qT8JODlF218xEQYHygGrbLAoXXLcOYFV6rfT5afj34JAIyy7r9tO8G62WHYW2vIH S2RlnTW+v/i4iKRRIhlofH3bVJMQsoFR784gfzGVYQ4SW4u0tjAL+LI8FzP+6p/kuSnh u37I8Y9wWXVOyFuNY8SJ+EegCeStIBRIJij/quuwwQRejMLk7GhJp2ErXM7XcoMYK1+U Qxhg== X-Gm-Message-State: AOAM531DOcyMn8cldgn5QA8syXmTgjtO3DCE0lXOb5A4vEPTTs1Ru3zx yLV88n5K3f0kATJPn+OT/PYozl2Xs8nHws/8 X-Google-Smtp-Source: ABdhPJxXbTvIyf6WtyVmcjfUCYp98DDGTdNJjK8CWo4/qlt4YEQRohMuL3WlkJ08sKVIwXP/theTIA== X-Received: by 2002:a05:6638:183:: with SMTP id a3mr30980033jaq.51.1641745183095; Sun, 09 Jan 2022 08:19:43 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 11/30] bsd-user/host/arm/host-signal.h: Implement host_signal_* Date: Sun, 9 Jan 2022 09:19:04 -0700 Message-Id: <20220109161923.85683-12-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d34 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d34; envelope-from=imp@bsdimp.com; helo=mail-io1-xd34.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1641745935684100001 Content-Type: text/plain; charset="utf-8" Implement host_signal_pc, host_signal_set_pc and host_signal_write for arm. Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/host/arm/host-signal.h | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 bsd-user/host/arm/host-signal.h diff --git a/bsd-user/host/arm/host-signal.h b/bsd-user/host/arm/host-signa= l.h new file mode 100644 index 00000000000..e403c26caed --- /dev/null +++ b/bsd-user/host/arm/host-signal.h @@ -0,0 +1,39 @@ +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2021 Warner Losh + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef ARM_HOST_SIGNAL_H +#define ARM_HOST_SIGNAL_H + +#include + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.__gregs[_REG_PC]; +} + +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.__gregs[_REG_PC] =3D pc; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + /* + * In the FSR, bit 11 is WnR. FreeBSD returns this as part of the + * si_info.si_trapno which we don't have access to here. We assume th= at uc + * is part of a trapframe and reach around to get to the si_info that'= s in + * the sigframe just before it, though this may be unwise. + */ + siginfo_t *si; + si =3D &((siginfo_t *)uc)[-1]; + uint32_t fsr =3D si->si_trapno; + + return extract32(fsr, 11, 1); +} + +#endif --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1641745717; cv=none; d=zohomail.com; s=zohoarc; b=jTqbSIicivJc2SAB96cx/sOdxUoMG0cj1y+l4of2779y7ujIAKv8xMGSm4WqguCSK+v+cQAWylS0YRH1M/gpOApDK2IgCJiEdqRhoEy2l+DHMrEC0t0ydxGCCEXWjqXrmHCLaPWn4sFKTpzW260tL1izZjZWsh+uoLz2vjA0U+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641745717; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aSPn1D4N9Nfp4DBqbA7GxaN2fsEyfYy+UjlDYEXO52E=; b=k5pVG4hofSFsn5nWrFUGqvVInEXt3Zhu31o9BU7FLWwrz6BXifvtZiKooz2h8tLiPJ7+rViNe6FsyTj6w4dRs77ok9YgaHWVPO3B5kU00nlhR66DcSMzBnM8EeCHNzau0u3zSN1G57oPX8Gr0sxB6i6O8xzybjlwkfCC+EJSuks= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745717819171.97388032728918; Sun, 9 Jan 2022 08:28:37 -0800 (PST) Received: from localhost ([::1]:43810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6b3c-00034B-Gt for importer@patchew.org; Sun, 09 Jan 2022 11:28:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6av4-0005l0-Nt for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:47 -0500 Received: from [2607:f8b0:4864:20::d2c] (port=34561 helo=mail-io1-xd2c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6av3-000779-AM for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:46 -0500 Received: by mail-io1-xd2c.google.com with SMTP id j1so4481629iob.1 for ; Sun, 09 Jan 2022 08:19:44 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aSPn1D4N9Nfp4DBqbA7GxaN2fsEyfYy+UjlDYEXO52E=; b=T/5XNQKOm5MkT1yAtWuBkS05Faz0/OgwQdrRyV2AOfxw9lErd8L+kJZ/Z09j6PIPNr pquFEucrT2Gdj40PZbzMXpcl16dTKcSuRUJzkUIG6dZrGKnOCgzWr5VGw+4/bIjgT9uS fZsJc1Hr3Jh2jk63HYA5wVg6WZ9xudDH14YcdJX8SaV+CoVjW338YQmRLIXpZv6M0/Mw GDbmSJ52VXz4tomiCG6mZy4jxKU9kpKfTxO9lCFgZNjnOlANPTLyQ3OuSQDLGTYid5eq iIJSF6JKuuNZCQmqZCMpiRbRwgIO533o6VTFnFPd7xrVAm5KAoIXgsbICE8GGdxn/5PA dyVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aSPn1D4N9Nfp4DBqbA7GxaN2fsEyfYy+UjlDYEXO52E=; b=2UMMMkvNMv2nXm9TleImiVBCVQ6H+nBbndZfY3s3L6LU0xdqSpLqE+Wj44IrOT4pI/ 3Bo42dXU5RvJ3NmGfM3E7LML7HSG6BUXhqZlX5v1h165dR2/mVTB8xYXppP60uL8fjHJ x1dR1QOCR1M5gQKxfD+2pEYNizEFkRtUG10izl3jdDb8RW6fKYPsItIiPpFta6q5AMPd 1DPvhOsA66NevFmchcLZDRp5FHEXZNz+5qD7K4hU7nlY657jLTeQq8/R58rB4wT/CNM9 4Qrrxq3rfO0ky7uxFvjjClXmjf5Sx5dE7K3Pbnaozk8sQpAxDbDnz85stNXUEq+Eqg3u a4xA== X-Gm-Message-State: AOAM531rSFqIpzdeaXPscV93DGiaJ65HGebQWGAJeivlJz9vQjrWygjq 3GT1pPe/S2OsSnuAU3iJHIdabeOB2oaAX67j X-Google-Smtp-Source: ABdhPJx106QswmlYpK72eg5pf3KTSS7QG0HO5hO11iVaK5n4/KuCYB4cTk503yYEMcMP1ZC8NztonA== X-Received: by 2002:a02:cc2a:: with SMTP id o10mr33727847jap.197.1641745183962; Sun, 09 Jan 2022 08:19:43 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 12/30] bsd-user/host/i386/host-signal.h: Implement host_signal_* Date: Sun, 9 Jan 2022 09:19:05 -0700 Message-Id: <20220109161923.85683-13-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2c (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2c; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1641745718638100002 Content-Type: text/plain; charset="utf-8" Implement host_signal_pc, host_signal_set_pc and host_signal_write for i386. Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/host/i386/host-signal.h | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 bsd-user/host/i386/host-signal.h diff --git a/bsd-user/host/i386/host-signal.h b/bsd-user/host/i386/host-sig= nal.h new file mode 100644 index 00000000000..169e61b154c --- /dev/null +++ b/bsd-user/host/i386/host-signal.h @@ -0,0 +1,37 @@ +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2021 Warner Losh + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef I386_HOST_SIGNAL_H +#define I386_HOST_SIGNAL_H + +#include +#include +#include +#include + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.mc_eip; +} + +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.mc_eip =3D pc; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + /* + * Look in sys/i386/i386/trap.c. NOTE: mc_err =3D=3D tr_err due to typ= e punning + * between a trapframe and mcontext on FreeBSD/i386. + */ + return uc->uc_mcontext.mc_trapno =3D=3D T_PAGEFLT && + uc->uc_mcontext.mc_err & PGEX_W; +} + +#endif --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1641746232; cv=none; d=zohomail.com; s=zohoarc; b=egjkgTjT9OdeqfrzLp/BAkkH73s58ovh+wvR6BFM4xDuZqbYvyrgQ3N/TRpZ2Y1kp4s+x+sbQEvLK436GzKWnNnt3rEzw6FkP8XEIByhkPLIQnv4z0N+ZI34YqJfrWKF87g5sGJy5kCYucU1+fbjf620rthw34eyboPxBiyVCdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641746232; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3+mDsyE6iKW/0OlAkZLrdWVvhPaN3N+mGKQdNQNNxRM=; b=RstbKx7xdP38mDq80HOMk10edGg5Q3sK7FBQlo3MRfCqRfgsCTXxrNt1Z/uIrmX4DEphTA9FJbLPSjWzwyuYUzhU+POdKEnKEqo3bxHHiFaGA4wv5jevj30dQO6PDJyaCRY65P99T/CuRpB+++VR+hv82m4Iwknmji13mtb27Io= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641746232044215.67335617273727; Sun, 9 Jan 2022 08:37:12 -0800 (PST) Received: from localhost ([::1]:35212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bBv-0000hN-35 for importer@patchew.org; Sun, 09 Jan 2022 11:37:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6av5-0005n0-FF for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:47 -0500 Received: from [2607:f8b0:4864:20::d36] (port=44768 helo=mail-io1-xd36.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6av4-00077F-5u for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:47 -0500 Received: by mail-io1-xd36.google.com with SMTP id h23so14307224iol.11 for ; Sun, 09 Jan 2022 08:19:45 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3+mDsyE6iKW/0OlAkZLrdWVvhPaN3N+mGKQdNQNNxRM=; b=F39kkwpo0rH2GF3Qwo/hur6eSDX0eQwZcaTyiSoz+UvZ3/Q6dWdrXKSUNv9dUWbXQn q5nNi6bdmpRD4ZVok+HYZcpC8E9nK0dCPzTGwS7T9xMBEyfrE37Uvgje0l8d3tJR0TCl YS7gmzd001Puxw8fjhuzOstXY8pBh1dYjEKKzariGgTodXwhMQtBMdRhUUR6c1UtEZaj ajdMK+3FDwYMgNjjvKpf5pMrWsLSKSWssbaKsmGN/ssGmbsebgVXUeL0U6sWJvRHT52c 0CA1R4sVzbWrksrP8RLxbxIfi0MTmFspKrOhdgff0eqTyHUCUPFgEAEz/C52rEQUexGQ 4GiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3+mDsyE6iKW/0OlAkZLrdWVvhPaN3N+mGKQdNQNNxRM=; b=VkYrqPeC049axiGMi9r/lTRuLTweS64ZqPPzujHrVEpbJHB0TTY7RdygMoOJ5ta643 bGRKbm8ker06HgFaZ4cjykknDj0nUUEvSFsS1+bXBYviLGohhsdZsG1NSTR7zviDbHxl Or1FS1lchyB9ybstBHzzFxK+hKCXzEE1K6QmkG9nlmJzUId053Plc79S551UULkihJIU D88usQcPCwH2XBRGyy3koWyiL+AU0cminzAOjGXcJWojZBTUlTSruSCxU8jZ1gBaHtu0 7cO6nh7PENuj3lXYLu86hEyZ++dw5nAT/JkbtO8lDffiEI3vjORvYgvMKy1sDOD+3UGj mrFA== X-Gm-Message-State: AOAM532Dy1sDbS4Mc6sGvOQ3/RfZyT2kUdtDpYKAeRTx7N4K+fl/XSFH R7USM83KXTCCEjL23SVbGIGyUB4KnAQ8jwpJ X-Google-Smtp-Source: ABdhPJwJHJwqzzWTTro2FJ97Z8BufOfgUeJI/umXoQuH1NW80ioa3mTHgFygCBng/pqg4CAkoW9smQ== X-Received: by 2002:a05:6638:359f:: with SMTP id v31mr32430668jal.59.1641745184902; Sun, 09 Jan 2022 08:19:44 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 13/30] bsd-user/host/x86_64/host-signal.h: Implement host_signal_* Date: Sun, 9 Jan 2022 09:19:06 -0700 Message-Id: <20220109161923.85683-14-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d36 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d36; envelope-from=imp@bsdimp.com; helo=mail-io1-xd36.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1641746232913100001 Content-Type: text/plain; charset="utf-8" Implement host_signal_pc, host_signal_set_pc and host_signal_write for x86_64. Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/host/x86_64/host-signal.h | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 bsd-user/host/x86_64/host-signal.h diff --git a/bsd-user/host/x86_64/host-signal.h b/bsd-user/host/x86_64/host= -signal.h new file mode 100644 index 00000000000..43961685df1 --- /dev/null +++ b/bsd-user/host/x86_64/host-signal.h @@ -0,0 +1,37 @@ +/* + * host-signal.h: signal info dependent on the host architecture + * + * Copyright (c) 2021 Warner Losh + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef X86_64_HOST_SIGNAL_H +#define X86_64_HOST_SIGNAL_H + +#include +#include +#include +#include + +static inline uintptr_t host_signal_pc(ucontext_t *uc) +{ + return uc->uc_mcontext.mc_rip; +} + +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.mc_rip =3D pc; +} + +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) +{ + /* + * Look in sys/amd64/amd64/trap.c. NOTE: mc_err =3D=3D tr_err due to t= ype punning + * between a trapframe and mcontext on FreeBSD/amd64. + */ + return uc->uc_mcontext.mc_trapno =3D=3D T_PAGEFLT && + uc->uc_mcontext.mc_err & PGEX_W; +} + +#endif --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1641745875; cv=none; d=zohomail.com; s=zohoarc; b=dAqxwnHc1hIrsUQZ3KwxF3uIUeicsqBmPL91FGmIqIQVUj0mPNC5MaSut1N0w8slO0XMQTchsWUdZc19wyDKrxYU7AaFIB61VCDNiVnW87RsbU0fUAraWxW7ZyTZMtfDuzlZZXyRD8SnOKTGbuOkqzt9oOHFCUYyOfaQ5uJzozc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641745875; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FNsF0kPrBvF91LIoX0lOquy9muwxYzG8QlRG6UOuR70=; b=hEw93I6xiKjxNnJeLAKsVWNWFTVIr03CbyPdPgHiyMMtEaGw2K9/+5YXJLmwXJcv3sjDOSGNVJj1LXo2gN8evNyOyXP5cv/bNjSaz+k73UKpMwPbetBhXbzd6RkJ8S59jbY9kYM31ehwmhUzOaQFYDxcC481xvZkOwmTwNEABgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745875009873.7404076414533; Sun, 9 Jan 2022 08:31:15 -0800 (PST) Received: from localhost ([::1]:52468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6b69-0000R9-Vh for importer@patchew.org; Sun, 09 Jan 2022 11:31:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6av6-0005pE-GS for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:48 -0500 Received: from [2607:f8b0:4864:20::d35] (port=37679 helo=mail-io1-xd35.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6av5-00077Q-1t for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:48 -0500 Received: by mail-io1-xd35.google.com with SMTP id 19so14370998ioz.4 for ; Sun, 09 Jan 2022 08:19:46 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FNsF0kPrBvF91LIoX0lOquy9muwxYzG8QlRG6UOuR70=; b=bHQg8cAN+sBDTCDn1ObIOVwCCtG+lpJ5W9C7fcpZ1X9CqM9mqBEuNg+5E3avNWyXXJ K4wdfvCGU3uw9OuxfNAeVA8fESVTHXIscyuAGFhYFfPhonS4E3WleJX797vdOQ2ZeuLf Xef1o5/tPwn9nkHTXicR4GNTJns0pUc8vQEzMZI10LJcEAV1x2euCN4Uwus52MmHQxaJ U+ma629sylo7X0sZy5N6Wx9wh7rbCQl+kFKr6ADWywhU6uKebjfBmCQAYCst1CKUYSKD Qrr0d76HVL4GIIbY61VhM8+PEJ2k+ULX90jFs01aMqiir3oFLzYca+owynLlDnk/3r1/ YhQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FNsF0kPrBvF91LIoX0lOquy9muwxYzG8QlRG6UOuR70=; b=EnXibFjoVhMyKb9dptZaqalcKRHw2MJqVg6Kv3HRlDmEpjuudkTf+r3oKO/t+qnJTt rzC+zpGIIkAXbwVF74YlDxyWVkiaT5QNxqoYWHmOrQeyh5SrDQEnI5Sqmb87ULWNovTB 67/IPu5PYmEqbjrN3VTaWsJPWErSns2uaaas7SDKGDJ3bYt3TXuPQIgu0VtjQpZBi5Sp U5QlvzBsQUHCGgVOdQ/XYn0iySSaQweuHszXrLMLipbJQLQQ/Rsa7WNQC/YqJ7SIcQxH cSLgldEwf8snT2RrriYMkBrNiNukvkTN5SjJQnK1bcvzhxKWXmi+/TmCNbjEdqYrTahH ma0w== X-Gm-Message-State: AOAM532XzoWIDrsg/sjZnij+g18UKhKatmOkOaAWeWVZOkUD5PTES47X bOdY+mrhnCNPYcIgxFVJskKMvEJVolnujtyY X-Google-Smtp-Source: ABdhPJx4g9Ar4G2WQfDJy+TnBhoHZoxiieaNTmzsvFpjr3jNAVYtGW5zFkIIeQaI3xNQNWarsyHx8A== X-Received: by 2002:a02:a413:: with SMTP id c19mr32077515jal.202.1641745185829; Sun, 09 Jan 2022 08:19:45 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 14/30] bsd-user: Add host signals to the build Date: Sun, 9 Jan 2022 09:19:07 -0700 Message-Id: <20220109161923.85683-15-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d35 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1641745875651100003 Content-Type: text/plain; charset="utf-8" Start to add the host signal functionality to the build. Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/meson.build | 1 + bsd-user/signal.c | 1 + meson.build | 1 + 3 files changed, 3 insertions(+) diff --git a/bsd-user/meson.build b/bsd-user/meson.build index 9fcb80c3fa8..a768e65d35e 100644 --- a/bsd-user/meson.build +++ b/bsd-user/meson.build @@ -4,6 +4,7 @@ endif =20 bsd_user_ss =3D ss.source_set() =20 +common_user_inc +=3D include_directories('host/' / host_arch) common_user_inc +=3D include_directories('.') =20 bsd_user_ss.add(files( diff --git a/bsd-user/signal.c b/bsd-user/signal.c index b2c91c39379..bf5c7eb0c02 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -22,6 +22,7 @@ #include "qemu.h" #include "signal-common.h" #include "hw/core/tcg-cpu-ops.h" +#include "host-signal.h" =20 /* * Stubbed out routines until we merge signal support from bsd-user diff --git a/meson.build b/meson.build index c1b1db1e28c..99bb7ba3a57 100644 --- a/meson.build +++ b/meson.build @@ -2932,6 +2932,7 @@ foreach target : target_dirs if 'CONFIG_BSD_USER' in config_target base_dir =3D 'bsd-user' target_inc +=3D include_directories('bsd-user/' / targetos) + target_inc +=3D include_directories('bsd-user/host/' / host_arch) dir =3D base_dir / abi arch_srcs +=3D files(dir / 'signal.c', dir / 'target_arch_cpu.c') endif --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641746149921183.47562224537978; Sun, 9 Jan 2022 08:35:49 -0800 (PST) Received: from localhost ([::1]:60750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bAa-0006J4-LU for importer@patchew.org; Sun, 09 Jan 2022 11:35:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6av8-0005qO-Cm for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:50 -0500 Received: from [2607:f8b0:4864:20::d2c] (port=44759 helo=mail-io1-xd2c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6av5-00078p-Tc for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:49 -0500 Received: by mail-io1-xd2c.google.com with SMTP id h23so14307271iol.11 for ; Sun, 09 Jan 2022 08:19:47 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+/wWrTe4LnbRZSWmDfzF4YJqyeP25q6xhkQF31qFpIY=; b=QkW3se70RUui28GL7YyzzUnNe4OrguooRhK5xTmOYCtKPbYYpypyc+jlr0M8MkfYn3 FjgkLRjzOlOBk+0lRuKaQLq9W2OQEdY5slLJ1GEx5zyfZdR0H/u8WHk9KcpJc7sH2EOL hbYYwP1nZaMQwS1I6RvC1weWb2kkisIrzxXL4O/1i44vgS96277YtEDEJ+17V2uOyaTt Uu/y1j8c0obJdsWUIpQR39dEBMK8ilzcoNfeuAAjh5YlU0zP7cshin8ciOswZ5qZigva 8ziTqENq6ZDmuN7qKJq2oydFLjHEjDUmmYQJLJvJcTnRMHXvCKViiDX0wp/e7elF2Qx1 VIiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+/wWrTe4LnbRZSWmDfzF4YJqyeP25q6xhkQF31qFpIY=; b=NY0EZfzQ31AdHj3r3lGRE2vUcPAyfu0By0SJpwo082D8QlwVrYmPS2Xl/7bd9ZCtEP a3Srrd/z2KO8Zke7fZVXJMYBHZWA4W34zOj2fPj57tqgqiEvKpk2a9tud2xHSFSsFkpv ZnlrY5RWWOW+Vzrt1dsPyzcMi5a4DzgJnx1Ec/z6ll3fkPC0nmhQ3N90aK4mc7lgxuuJ myDZ/CNSLrZtOC/uVKZOFJSzAwEa/JDNI/c/yC4IQbb3aTWZRiq0bmOdPXYrRnAFx+Gc sylJUoTSlfotVSW+EjTmmZtKFVHxiSPDFpyp7gK/AXPoNFr13MuYgmzVgwV1gaAXKM92 SKCw== X-Gm-Message-State: AOAM531oYicCEaj6JQumtxi5b7qq4k1+cbJm9qAsbJNywJGiPyoiWrNE kwjG8qOFxYbCg9rIhb3DCodPdL34B+Wbcuvo X-Google-Smtp-Source: ABdhPJwMaoCuISxY7rYYmuT1DAZQQl2E+CgHJMgKjxK8P+aTN6ivsrZpm3H0YlrWt0J5+BFBNesk6Q== X-Received: by 2002:a05:6638:2641:: with SMTP id n1mr33151002jat.265.1641745186723; Sun, 09 Jan 2022 08:19:46 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 15/30] bsd-user: Add trace events for bsd-usr Date: Sun, 9 Jan 2022 09:19:08 -0700 Message-Id: <20220109161923.85683-16-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2c (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2c; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641746150901100001 Content-Type: text/plain; charset="utf-8" Add the bsd-user specific events and infrastructure. Only include the linux-user trace events for linux-user, not bsd-user. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/signal.c | 1 + bsd-user/trace-events | 11 +++++++++++ bsd-user/trace.h | 1 + meson.build | 5 ++++- 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 bsd-user/trace-events create mode 100644 bsd-user/trace.h diff --git a/bsd-user/signal.c b/bsd-user/signal.c index bf5c7eb0c02..7168d851be8 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -21,6 +21,7 @@ #include "qemu/osdep.h" #include "qemu.h" #include "signal-common.h" +#include "trace.h" #include "hw/core/tcg-cpu-ops.h" #include "host-signal.h" =20 diff --git a/bsd-user/trace-events b/bsd-user/trace-events new file mode 100644 index 00000000000..a624a9fc34e --- /dev/null +++ b/bsd-user/trace-events @@ -0,0 +1,11 @@ +# See docs/tracing.txt for syntax documentation. + +# bsd-user/signal.c +user_setup_frame(void *env, uint64_t frame_addr) "env=3D%p frame_addr=3D0x= %"PRIx64 +user_setup_rt_frame(void *env, uint64_t frame_addr) "env=3D%p frame_addr= =3D0x%"PRIx64 +user_do_rt_sigreturn(void *env, uint64_t frame_addr) "env=3D%p frame_addr= =3D0x%"PRIx64 +user_do_sigreturn(void *env, uint64_t frame_addr) "env=3D%p frame_addr=3D0= x%"PRIx64 +user_force_sig(void *env, int target_sig, int host_sig) "env=3D%p signal %= d (host %d)" +user_handle_signal(void *env, int target_sig) "env=3D%p signal %d" +user_host_signal(void *env, int host_sig, int target_sig) "env=3D%p signal= %d (target %d(" +user_queue_signal(void *env, int target_sig) "env=3D%p signal %d" diff --git a/bsd-user/trace.h b/bsd-user/trace.h new file mode 100644 index 00000000000..593c0204add --- /dev/null +++ b/bsd-user/trace.h @@ -0,0 +1 @@ +#include "trace/trace-bsd_user.h" diff --git a/meson.build b/meson.build index 99bb7ba3a57..9fc9e0ddab9 100644 --- a/meson.build +++ b/meson.build @@ -2437,9 +2437,12 @@ trace_events_subdirs =3D [ 'monitor', 'util', ] -if have_user +if have_linux_user trace_events_subdirs +=3D [ 'linux-user' ] endif +if have_bsd_user + trace_events_subdirs +=3D [ 'bsd-user' ] +endif if have_block trace_events_subdirs +=3D [ 'authz', --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641746464050615.693998596304; Sun, 9 Jan 2022 08:41:04 -0800 (PST) Received: from localhost ([::1]:42942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bFe-00063q-Gp for importer@patchew.org; Sun, 09 Jan 2022 11:41:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50596) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6av9-0005tB-9r for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:51 -0500 Received: from [2607:f8b0:4864:20::d35] (port=42923 helo=mail-io1-xd35.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6av6-000792-Tw for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:51 -0500 Received: by mail-io1-xd35.google.com with SMTP id o7so14344500ioo.9 for ; Sun, 09 Jan 2022 08:19:48 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zb02sLCJzpt+9eV8e5SNqnK+bO9oNMK4sRt96jmqBiI=; b=YShUIeQKyBrE0BD3UkJHRnaFM7i6qtMfEReOC82lGKlOdtJnGkDSPjaUUSVehLk9zm 7z42K7YvkA2pZWgpy88mr2vDvUTxkaKXl7dRTXHThtYgqo1GqQDJoXp0LtT2hGdsisqp 15esNCII26elqkjVLc3EVP7Bi3ACqMBOlRXTXa3WspbZOlf6bqwepJlt4g6vmbfULoWz 2FoMfypFPjoSgrFxkyWx1j4IPKcjGks2TjZ2/FGKJT9JAKieqOs/RW0SSWGDidGTwW7u zGK5+Kq0K0CdpsL0+wuZ7TlzehGeIMisRb70zzg+Zd0O1ClfpzkZ8M8q/Uzmm32vzCPi BIyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zb02sLCJzpt+9eV8e5SNqnK+bO9oNMK4sRt96jmqBiI=; b=wq9cxttAOGZn/PEe++wa1NhkcqLNrgvaXM4Uh1gqD+guYDIjzgTO0XcMz0toWkFhT4 bTvMS+RxNsR+E/nY9Upj8iR1ucFaAcsxdjINvHNKtMMl7WlXz7efFP0d5PLYfnK1CswP wB7K8DIHw3qoMTtfADn+OizGxWDDbCedlvTcYSRbNYeSEuJUHADNC8xeoAygdbbZPcq3 ob4s6BhIDaZY4tZGbgrPXZ7AZok1xi3moSLMegk+vEtDEQIMON7mp20/ND/8Nb3j4y5x E9nZbxpMVVq28w+awCCKQGGT2f6SP9CeOhQnxjstLx8NfYRvfWtiR4w2r6r4C7+GpW4x szGg== X-Gm-Message-State: AOAM5334pBkfwt5HDFD0K0E7qvVtU8p2lL9LLwogjPPH+1KEgJzFyhCT 6KXlKBK2tbcN+I8Wr+cOglyEnaL3z08k0lMx X-Google-Smtp-Source: ABdhPJxkOEYJj/ZPqFSP+wJohIc1vY95JK7k2yfLMSrn1ex1tZaKjTrswJRrnl6bmbx88Co1xnH4HQ== X-Received: by 2002:a05:6638:142:: with SMTP id y2mr34591693jao.195.1641745187680; Sun, 09 Jan 2022 08:19:47 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 16/30] bsd-user/signal.c: host_to_target_siginfo_noswap Date: Sun, 9 Jan 2022 09:19:09 -0700 Message-Id: <20220109161923.85683-17-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d35 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641746464634100001 Content-Type: text/plain; charset="utf-8" Implement conversion of host to target siginfo. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/signal.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 7168d851be8..3fe8b2d9898 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -43,6 +43,43 @@ int target_to_host_signal(int sig) return sig; } =20 +/* Siginfo conversion. */ +static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, + const siginfo_t *info) +{ + int sig, code; + + sig =3D host_to_target_signal(info->si_signo); + /* XXX should have host_to_target_si_code() */ + code =3D tswap32(info->si_code); + tinfo->si_signo =3D sig; + tinfo->si_errno =3D info->si_errno; + tinfo->si_code =3D info->si_code; + tinfo->si_pid =3D info->si_pid; + tinfo->si_uid =3D info->si_uid; + tinfo->si_status =3D info->si_status; + tinfo->si_addr =3D (abi_ulong)(unsigned long)info->si_addr; + /* si_value is opaque to kernel */ + tinfo->si_value.sival_ptr =3D + (abi_ulong)(unsigned long)info->si_value.sival_ptr; + if (SIGILL =3D=3D sig || SIGFPE =3D=3D sig || SIGSEGV =3D=3D sig || SI= GBUS =3D=3D sig || + SIGTRAP =3D=3D sig) { + tinfo->_reason._fault._trapno =3D info->_reason._fault._trapno; + } +#ifdef SIGPOLL + if (SIGPOLL =3D=3D sig) { + tinfo->_reason._poll._band =3D info->_reason._poll._band; + } +#endif + if (SI_TIMER =3D=3D code) { + int timerid; + + timerid =3D info->_reason._timer._timerid; + tinfo->_reason._timer._timerid =3D timerid; + tinfo->_reason._timer._overrun =3D info->_reason._timer._overrun; + } +} + /* * Queue a signal so that it will be send to the virtual CPU as soon as * possible. --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1641745873; cv=none; d=zohomail.com; s=zohoarc; b=K3J7Sbkg7hPxfDMx61rnW0avrnL0ToIDtwNxZYJia6Y2Jc+m3JTsIIyTAMfyfvykLe/NDFEVZ3gr6GzL1qVBtJLbqSfKLxw0EgpmOSwsW0mlyV3I1v+cX29atlAQTqSAJp5bHV3XWqkrwmDaTXiZJ62XKFtcBJRcOgiuNMDsO2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641745873; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t/ddjl6cauPiUQiB6NQmi9s5X3E+m4nw8GVj1ngqf4I=; b=fe8ymBMpNJ5gglz4hEOQogF59691wQHXJUYl9IhLPsaQ6qzy/IpJ0CKSeUeyo1CjYUDObnTGcCwWVQ8TZsiWAYNTf/X5pVLQWHU9WSrjf7/Z91fL5u5pxAyiUz6D5bjS6ZImW31N+ohqAiLoRGJhc2dD5w/WT0NzEEfgyIvEqIU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745873568355.449794923264; Sun, 9 Jan 2022 08:31:13 -0800 (PST) Received: from localhost ([::1]:52380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6b68-0000Na-Jp for importer@patchew.org; Sun, 09 Jan 2022 11:31:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avA-0005xJ-L3 for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:52 -0500 Received: from [2607:f8b0:4864:20::d2a] (port=39641 helo=mail-io1-xd2a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6av9-00079N-05 for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:52 -0500 Received: by mail-io1-xd2a.google.com with SMTP id y11so14357391iod.6 for ; Sun, 09 Jan 2022 08:19:50 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t/ddjl6cauPiUQiB6NQmi9s5X3E+m4nw8GVj1ngqf4I=; b=P7MIXVCNd+zhIp3BrORauPsxXaaaaTwM+yY2YXZJojHu8jCa1e7MPH9GNPWqlbq4jj fwLKqygQBhVjWUVEnYcwWSYbLgM98PCKLF78hBR9jpkjhz44Jm15e+ZqyLbhFfx4W/gT 2GuOjk6OiK+cS9b3l2N+RCd6AdI2Ys2aVFuWYJy2uT520QgV3AX4+5rk2vbis+eVIzcY uyxBJV4SsFeZ18NZJDKEaYHbJTdAZn1NAAaqC/tizd0xYhMf5hH16c11JiB771786XpV m2QIxGnJaksB05xCnoO59ihZhbWKn1GZzGwZpgAq3/T9yyCFvrqdpQB2ji6UqUUO3AXS doHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t/ddjl6cauPiUQiB6NQmi9s5X3E+m4nw8GVj1ngqf4I=; b=7Y0jZhvsa7IcGEPICIYHDnjMHXdpaLmtHxS/7g3W1pbfpP2bhmBkPxUSdBI2Rc3T+3 l0xq7kJF5U1AqmOCLZQnYGSggGbRYLCqvx2SDcMjGu+cJwo4iMLZ5vwvsCOB7iCblH0q ndFQonUa0YV6vTfjH2SElLGHO77iryLQXaLXhbKB9O4Z9RgZd3xwLVHhrS/4yNkHCrJR AYFKG5COXTI0M+JxsdhqkpCKQFr6QagPOhRp19EVsZNdms/BVUR0XZbGOmSwujkh+Jkc PSlqXsFHnaEWYPZq6e0uhM3LfoKNP9fQX0pxjPyMEKt5Wnf+uqATd9CUj+CmThk4NBnk tmVQ== X-Gm-Message-State: AOAM531J75796Ht0hPWwVqAY2Izdr0MdOEsxdtwARETRr4+NO0i/Pc4u 5g/o8r6GxhBEneSobjJ42u7ojY6ms0YYlXmb X-Google-Smtp-Source: ABdhPJx0XGZ+e6zVGFPp5pJuKntWNc62jKYkg9BxscoOyZHNfBYeyX+VRltoKL1hfZfl4mvujnnsgg== X-Received: by 2002:a05:6602:2c09:: with SMTP id w9mr33728215iov.89.1641745188735; Sun, 09 Jan 2022 08:19:48 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 17/30] bsd-user/signal.c: Implement rewind_if_in_safe_syscall Date: Sun, 9 Jan 2022 09:19:10 -0700 Message-Id: <20220109161923.85683-18-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2a; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2a.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bsdimp-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1641745875403100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/qemu.h | 2 ++ bsd-user/signal.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 0e0b8db708b..e5e97632c82 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -454,4 +454,6 @@ static inline void *lock_user_string(abi_ulong guest_ad= dr) =20 #include =20 +#include "user/safe-syscall.h" + #endif /* QEMU_H */ diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 3fe8b2d9898..b1331f63d61 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -43,6 +43,18 @@ int target_to_host_signal(int sig) return sig; } =20 +/* Adjust the signal context to rewind out of safe-syscall if we're in it = */ +static inline void rewind_if_in_safe_syscall(void *puc) +{ + ucontext_t *uc =3D (ucontext_t *)puc; + uintptr_t pcreg =3D host_signal_pc(uc); + + if (pcreg > (uintptr_t)safe_syscall_start + && pcreg < (uintptr_t)safe_syscall_end) { + host_signal_set_pc(uc, (uintptr_t)safe_syscall_start); + } +} + /* Siginfo conversion. */ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, const siginfo_t *info) --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641746366465887.5276185915361; Sun, 9 Jan 2022 08:39:26 -0800 (PST) Received: from localhost ([::1]:40780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bE5-0004ai-Hn for importer@patchew.org; Sun, 09 Jan 2022 11:39:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avA-0005xZ-N6 for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:52 -0500 Received: from [2607:f8b0:4864:20::135] (port=43646 helo=mail-il1-x135.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6av8-00079P-S0 for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:52 -0500 Received: by mail-il1-x135.google.com with SMTP id d3so9259924ilr.10 for ; Sun, 09 Jan 2022 08:19:50 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jYUR7vQogyslfO2q6GByzMN483i8JjtEIEoYTGxZlJs=; b=OOQha7vK2/OVWkX2MhXmgI7Hg/tEDDSKRyVmNn/N+PbsVrSs3XIKlbClMzD6mlkMtK miaBTaSxslE1hjl6Sgufh9UaDzX200X2XP7LuQ0twLTTfiZQiMWNdYsDSTALLYzbCTLm aNEioyfgSkJltsysTfyjD8cj8CGRmy3VOU+HFKakNaLEEg5xhxw6dsJYQ9/7akIqyude 1GWhM5L/GcUZMrJ2QrdeavPDuJtkjIp6Wqj2hSBHZ9Ig06KDHiaIK15CAJblAwKelV2N lsqVMAfMeIudHAfJmnxRT+Y8kmHaN+qxAx4ZQXgB9xs8tMpxTI3msdkLB3ZLrrL9Vabn 6Pqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jYUR7vQogyslfO2q6GByzMN483i8JjtEIEoYTGxZlJs=; b=rGjUjFP9XuOo4RCRCYjcgV3avGy3WqHSAdjU59HYpEUsZOoNiT25RKszBgh6jCFaIN ILqNKcdWtDwpOPY2EM0jMvw1TY6fwq4HhuWwlOvq8HAvXpwos+OhkwkZmG8eu2/1bD8u SneAQ/F3mEkpBHTD8fRpDrv9c3ZlrD4nUmFt2iDlD7ES1V3BRTyQp7cQSiHEZsrbIMy+ /9qu6LYJOqhJsiVkonjt07ngdmRpnN2WhYYGF3vFo1NpzhVY76L+S1WCSwqkyB21PY/S tFBwX07Y2rciNKM4fILLM52lNlXPl6zNvMIZ8vpmwJMoCw40e+136hrmSMYIOG8H/QhA 2rKg== X-Gm-Message-State: AOAM532zbm9AcVMIS0K8B4KTBBkkVwXd8uG/M1dGfPftKlutfQ4ZEpRn 8Y5NkD9GdTcX6F/Nsu4LhTAy0eU8zixVNTjs X-Google-Smtp-Source: ABdhPJxbReUcplEMwaoMl3QY4dh4baeUsoC7D+uWQc690Tw7NxvHstBotkDLp4gozCijEj8/9HLwkw== X-Received: by 2002:a05:6e02:1449:: with SMTP id p9mr32031168ilo.66.1641745189535; Sun, 09 Jan 2022 08:19:49 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 18/30] bsd-user/signal.c: Implement host_signal_handler Date: Sun, 9 Jan 2022 09:19:11 -0700 Message-Id: <20220109161923.85683-19-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::135 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::135; envelope-from=imp@bsdimp.com; helo=mail-il1-x135.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641746368471100001 Content-Type: text/plain; charset="utf-8" Implement host_signal_handler to handle signals generated by the host and to do safe system calls. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/signal.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index b1331f63d61..a6e07277fb2 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -142,6 +142,111 @@ void force_sig_fault(int sig, int code, abi_ulong add= r) =20 static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) { + CPUState *cpu =3D thread_cpu; + CPUArchState *env =3D cpu->env_ptr; + int sig; + target_siginfo_t tinfo; + ucontext_t *uc =3D puc; + uintptr_t pc =3D 0; + bool sync_sig =3D false; + + /* + * Non-spoofed SIGSEGV and SIGBUS are synchronous, and need special + * handling wrt signal blocking and unwinding. + */ + if ((host_sig =3D=3D SIGSEGV || host_sig =3D=3D SIGBUS) && info->si_co= de > 0) { + MMUAccessType access_type; + uintptr_t host_addr; + abi_ptr guest_addr; + bool is_write; + + host_addr =3D (uintptr_t)info->si_addr; + + /* + * Convert forcefully to guest address space: addresses outside + * reserved_va are still valid to report via SEGV_MAPERR. + */ + guest_addr =3D h2g_nocheck(host_addr); + + pc =3D host_signal_pc(uc); + is_write =3D host_signal_write(info, uc); + access_type =3D adjust_signal_pc(&pc, is_write); + + if (host_sig =3D=3D SIGSEGV) { + bool maperr =3D true; + + if (info->si_code =3D=3D SEGV_ACCERR && h2g_valid(host_addr)) { + /* If this was a write to a TB protected page, restart. */ + if (is_write && + handle_sigsegv_accerr_write(cpu, &uc->uc_sigmask, + pc, guest_addr)) { + return; + } + + /* + * With reserved_va, the whole address space is PROT_NONE, + * which means that we may get ACCERR when we want MAPERR. + */ + if (page_get_flags(guest_addr) & PAGE_VALID) { + maperr =3D false; + } else { + info->si_code =3D SEGV_MAPERR; + } + } + + sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); + cpu_loop_exit_sigsegv(cpu, guest_addr, access_type, maperr, pc= ); + } else { + sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL); + if (info->si_code =3D=3D BUS_ADRALN) { + cpu_loop_exit_sigbus(cpu, guest_addr, access_type, pc); + } + } + + sync_sig =3D true; + } + + /* Get the target signal number. */ + sig =3D host_to_target_signal(host_sig); + if (sig < 1 || sig > TARGET_NSIG) { + return; + } + trace_user_host_signal(cpu, host_sig, sig); + + host_to_target_siginfo_noswap(&tinfo, info); + + queue_signal(env, sig, &tinfo); /* XXX how to cope with failure?= */ + /* + * Linux does something else here -> the queue signal may be wrong, but + * maybe not. And then it does the rewind_if_in_safe_syscall + */ + + /* + * For synchronous signals, unwind the cpu state to the faulting + * insn and then exit back to the main loop so that the signal + * is delivered immediately. + XXXX Should this be in queue_signal? + */ + if (sync_sig) { + cpu->exception_index =3D EXCP_INTERRUPT; + cpu_loop_exit_restore(cpu, pc); + } + + rewind_if_in_safe_syscall(puc); + + /* + * Block host signals until target signal handler entered. We + * can't block SIGSEGV or SIGBUS while we're executing guest + * code in case the guest code provokes one in the window between + * now and it getting out to the main loop. Signals will be + * unblocked again in process_pending_signals(). + */ + sigfillset(&uc->uc_sigmask); + sigdelset(&uc->uc_sigmask, SIGSEGV); + sigdelset(&uc->uc_sigmask, SIGBUS); + + /* Interrupt the virtual CPU as soon as possible. */ + cpu_exit(thread_cpu); } =20 void signal_init(void) --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641746696256666.5645562089607; Sun, 9 Jan 2022 08:44:56 -0800 (PST) Received: from localhost ([::1]:48438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bJP-0001pc-BB for importer@patchew.org; Sun, 09 Jan 2022 11:44:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avB-0005zo-Ak for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:53 -0500 Received: from [2607:f8b0:4864:20::d2d] (port=35399 helo=mail-io1-xd2d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6av9-00079Z-NR for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:53 -0500 Received: by mail-io1-xd2d.google.com with SMTP id y70so14419651iof.2 for ; Sun, 09 Jan 2022 08:19:51 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pThHCeH4xmr6L8Ou79hre21omTxoT/W58GNaYNpkKbs=; b=zswI86oSK2kwmLKBxIguyVjaDC85sZmIua0d6EBwzEIMB8EecFUV4yPL4dGh7hSCEP cPLfJeRcgXU6ePiOLebM1Van9GDYhLGf8vVeGOvH47OYUQnEHa5f3K9IYQDt7gtFo+Qf dDRC2RS2StXkKzjgkieLhID1f9MCcAD65ohbTNFrd92PShTFLPnLoHGKnYLoma/is03V 2El4aXgpdUkyELqovtMxSPlwft2cl6g0NfnZdkbkr3qY1scVW1W1oJR6TltsMS9zARtn 6onSje0j8vfkKmNp/qTaA/CYCTW3/Yl/nAWM4Iqkomri/Hcp2XC2EyUVFc5wYkdYoThf aEfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pThHCeH4xmr6L8Ou79hre21omTxoT/W58GNaYNpkKbs=; b=H3lD8aOuxVZ4ojU9Jk9XWodFzUej6bM1UE66Qk6uoIICNm9KuXCVHe1rQH394sbylp OR/SAsMbf4L0WhjIiU9pOnhaFouZfQE7fCwxLEAvd3VsaaHeMJDA8WRokeWIR1qcX5qV lDSJe0nNR0rUygSLchHXmGuXq8Z3qYn25USSPWYLtgNyKAwYUMJWau7BQAoQm4VrzYPN u3k9QME0GiXwGIywZ0cGal/rKCwfx3pB2vLBCQltgpjwLs613H8uMvk3lLJ1/7TjijZ2 jvgQeexN2W0NhKyYiTgF8V9c3WdouMxHFTa9HZx0wyaVVdIUwFzZaroMgULrjOkd7nbO 0tXg== X-Gm-Message-State: AOAM533ykEBo6DjgG8OJLlQGqKcqv0A0EavqlKpV5k8WSCDSq8U6aqR2 YCAzG1ZHDTLCWmJ3SHgJVjnmrZD91hbQtRs0 X-Google-Smtp-Source: ABdhPJwlvDOXwL2l2VfeBqSih7mELFvrsEYV/zGJEI4fnC1LQHkIcwV0yilG7+LqElowtgPh38Dwbw== X-Received: by 2002:a02:6d6b:: with SMTP id e43mr1150959jaf.165.1641745190468; Sun, 09 Jan 2022 08:19:50 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 19/30] bsd-user/strace.c: print_taken_signal Date: Sun, 9 Jan 2022 09:19:12 -0700 Message-Id: <20220109161923.85683-20-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2d; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2d.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641746698661100001 Content-Type: text/plain; charset="utf-8" print_taken_signal() prints signals when we're tracing signals. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/qemu.h | 10 +++++ bsd-user/strace.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index e5e97632c82..7c54a933eb8 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -202,6 +202,16 @@ print_openbsd_syscall(int num, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, abi_long arg6); void print_openbsd_syscall_ret(int num, abi_long ret); +/** + * print_taken_signal: + * @target_signum: target signal being taken + * @tinfo: target_siginfo_t which will be passed to the guest for the sign= al + * + * Print strace output indicating that this signal is being taken by the g= uest, + * in a format similar to: + * --- SIGSEGV {si_signo=3DSIGSEGV, si_code=3DSI_KERNEL, si_addr=3D0} --- + */ +void print_taken_signal(int target_signum, const target_siginfo_t *tinfo); extern int do_strace; =20 /* signal.c */ diff --git a/bsd-user/strace.c b/bsd-user/strace.c index be40b8a20cf..a77d10dd6b6 100644 --- a/bsd-user/strace.c +++ b/bsd-user/strace.c @@ -31,6 +31,24 @@ int do_strace; /* * Utility functions */ +static const char * +get_comma(int last) +{ + return (last) ? "" : ","; +} + +/* + * Prints out raw parameter using given format. Caller needs + * to do byte swapping if needed. + */ +static void +print_raw_param(const char *fmt, abi_long param, int last) +{ + char format[64]; + + (void)snprintf(format, sizeof(format), "%s%s", fmt, get_comma(last)); + gemu_log(format, param); +} =20 static void print_sysctl(const struct syscallname *name, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4, abi_long arg5, @@ -239,3 +257,82 @@ void print_openbsd_syscall_ret(int num, abi_long ret) =20 print_syscall_ret(num, ret, openbsd_scnames, ARRAY_SIZE(openbsd_scname= s)); } + +static void +print_signal(abi_ulong arg, int last) +{ + const char *signal_name =3D NULL; + switch (arg) { + case TARGET_SIGHUP: + signal_name =3D "SIGHUP"; + break; + case TARGET_SIGINT: + signal_name =3D "SIGINT"; + break; + case TARGET_SIGQUIT: + signal_name =3D "SIGQUIT"; + break; + case TARGET_SIGILL: + signal_name =3D "SIGILL"; + break; + case TARGET_SIGABRT: + signal_name =3D "SIGABRT"; + break; + case TARGET_SIGFPE: + signal_name =3D "SIGFPE"; + break; + case TARGET_SIGKILL: + signal_name =3D "SIGKILL"; + break; + case TARGET_SIGSEGV: + signal_name =3D "SIGSEGV"; + break; + case TARGET_SIGPIPE: + signal_name =3D "SIGPIPE"; + break; + case TARGET_SIGALRM: + signal_name =3D "SIGALRM"; + break; + case TARGET_SIGTERM: + signal_name =3D "SIGTERM"; + break; + case TARGET_SIGUSR1: + signal_name =3D "SIGUSR1"; + break; + case TARGET_SIGUSR2: + signal_name =3D "SIGUSR2"; + break; + case TARGET_SIGCHLD: + signal_name =3D "SIGCHLD"; + break; + case TARGET_SIGCONT: + signal_name =3D "SIGCONT"; + break; + case TARGET_SIGSTOP: + signal_name =3D "SIGSTOP"; + break; + case TARGET_SIGTTIN: + signal_name =3D "SIGTTIN"; + break; + case TARGET_SIGTTOU: + signal_name =3D "SIGTTOU"; + break; + } + if (signal_name =3D=3D NULL) { + print_raw_param("%ld", arg, last); + return; + } + gemu_log("%s%s", signal_name, get_comma(last)); +} + +void print_taken_signal(int target_signum, const target_siginfo_t *tinfo) +{ + /* + * Print the strace output for a signal being taken: + * --- SIGSEGV {si_signo=3DSIGSEGV, si_code=3DSI_KERNEL, si_addr=3D0} = --- + */ + gemu_log("%d ", getpid()); + gemu_log("--- "); + print_signal(target_signum, 1); + gemu_log(" ---\n"); +} --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641746869772260.751915504846; Sun, 9 Jan 2022 08:47:49 -0800 (PST) Received: from localhost ([::1]:53412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bMC-0005GG-Mh for importer@patchew.org; Sun, 09 Jan 2022 11:47:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avC-00061p-HD for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:54 -0500 Received: from [2607:f8b0:4864:20::d2a] (port=42913 helo=mail-io1-xd2a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6avA-00079l-Jm for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:53 -0500 Received: by mail-io1-xd2a.google.com with SMTP id o7so14344666ioo.9 for ; Sun, 09 Jan 2022 08:19:52 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9sjpK/1Q5swTBppTUsP0f41/QFdeOShmYIkZ4Qj7tck=; b=Ax16X5REnQTCoZ3Oh3iBUty7PP15pgH5lS9JpPmPHHCW55hgolBRRVM/U36A3Q1uFi GH9tOLXYJIOvl73xRV3k9zOd+ZYPeTEYLcPJnVD1ZTgQFRTwUhRcaHIOTm55CnMwaBpe u+MgvvuJqM0y2np9dNt1eWR+4WCuloaU6rPlKj8IL5EqpuJWNutZDEu3IEwFn8E7dznY faWhvuHfmuGXX3c2nVceKSvJ2f984zMDh32zNVkBM7nQolJE4h/hJTJPo4HdD0TPglls rQWC2UCM8kGg84pl2P4n4LJcIerHB6ryzwhZONOzXVBNgNbPxhV8IrMDeUgHIIHzCLn4 4hFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9sjpK/1Q5swTBppTUsP0f41/QFdeOShmYIkZ4Qj7tck=; b=jm6fyVkfg6lKQDFzJPdjYNngGiVLrkd7lf/QO3kiGPuhdWvRvw8hhvR4o3uar2GDgq iX5uAJnt7xt8baTnvW/ZUpHNuFZe2M4uKTE7M6y8M8kM5/pTdS/p2CKctsDZ8nFqQ7M8 1CFXOxHDsK3GxLr5itKe3hCjSDJ4FOENrdkzUhIHnMEjqpgUFY1KqrPff899oCmbdxll PJWgJmP0dbT1R8ZmcUpeUlDE6iPupgF4+tBBrI5Pe5HvkoqtB3ATTwiBAjKLUmRR7uAr 8i9mS7v1xRyZ1sMJZhk90VLUJ/FIyKHHyQsM6z4J3joaoAZ1Oi0/nw78xhiY4t80j3lA HFOg== X-Gm-Message-State: AOAM5306MZY5RjRyBIvSLFCQVxl5eSgMr3090R+AP3ruAyUhMThG5rTN 7ZpgMVxYoxl5CmNEVGQu7Wog32ApmS0Mpyul X-Google-Smtp-Source: ABdhPJybV1bTcaWslZ5uXs8kbM/JY2OUJgUpFIakDGBq1n4u2NHW8u+dBaNUSa2yaGUp9Em5Slzc0Q== X-Received: by 2002:a05:6638:418a:: with SMTP id az10mr34763800jab.179.1641745191316; Sun, 09 Jan 2022 08:19:51 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 20/30] bsd-user/signal.c: core_dump_signal Date: Sun, 9 Jan 2022 09:19:13 -0700 Message-Id: <20220109161923.85683-21-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2a (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2a; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2a.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641746870891100001 Content-Type: text/plain; charset="utf-8" Returns 1 for signals that cause core files. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/signal.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index a6e07277fb2..824535be8b8 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -92,6 +92,23 @@ static inline void host_to_target_siginfo_noswap(target_= siginfo_t *tinfo, } } =20 +/* Returns 1 if given signal should dump core if not handled. */ +static int core_dump_signal(int sig) +{ + switch (sig) { + case TARGET_SIGABRT: + case TARGET_SIGFPE: + case TARGET_SIGILL: + case TARGET_SIGQUIT: + case TARGET_SIGSEGV: + case TARGET_SIGTRAP: + case TARGET_SIGBUS: + return 1; + default: + return 0; + } +} + /* * Queue a signal so that it will be send to the virtual CPU as soon as * possible. --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164174662042699.03218095622458; Sun, 9 Jan 2022 08:43:40 -0800 (PST) Received: from localhost ([::1]:46940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bI9-0000ca-V5 for importer@patchew.org; Sun, 09 Jan 2022 11:43:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avC-00062c-Qc for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:54 -0500 Received: from [2607:f8b0:4864:20::d30] (port=38773 helo=mail-io1-xd30.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6avB-0007A1-CH for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:54 -0500 Received: by mail-io1-xd30.google.com with SMTP id u8so14397237iol.5 for ; Sun, 09 Jan 2022 08:19:53 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gB3attyXcs9o/p6L5UleYu8j20xJN9LVJFH807AOJfw=; b=1K5DyfRi5qWoJahHYUhIU3MxPW2Fp9ih8k+TIugcH0mPt8qWuA3XSoH4L/30bVdowG tsLP3eLDmbGKEGLxFlOHDHOg4ZWzTLEt72NxUbun59aCSHDeavX4dO3va7dJ4M4gaPTA yc187Pm3uTZ/JcadmCPaRF0dnAOO87rq4gB59A86Trh1FWF47/DFWAJdROn/cDKiWesM 3AjB8ECHZyOej/6glITlK6a/AKws+XozUQaabNwN9HQH/zhUQNZDKPYwZiJ2d3wjrzRu NFI92X/ScQSHw7BSDZ/9JyMb9rfBIjZevcbM6PBnEots0Yj7hp0Qt4H43tzU6xcLhLXF p2Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gB3attyXcs9o/p6L5UleYu8j20xJN9LVJFH807AOJfw=; b=3R7A4WMeGPqf3N6KXRY66+/Y/CU8ffWcwrW7ufSMpfn/nPZcDQgCrMeIjILHBKKIg2 scQtwTYFK97RMIYl/WPjj+JpSN/hILGp/5pl6zgSbjCb6JA5hadg0sWdFnViTtC2u2+4 i+C9ZNHfCEdcXyfcpnfDdwyOunFbrJoUNHlXc+zKdBGJyPPF56nk7wVOq5TwGqo50hy0 U/Gpv4Eity8O+2Soga6h1UXepb36d9RVx+jY+elODYo6/HgUOShpIIEGJvW1AJiRuVvV kiN2euwa7lNk6uv0n6qQONrXBp00cOF1lKfjM+u+72LC8Tu0nqjRaA8mbuVpHJ52sEhA 5Uhw== X-Gm-Message-State: AOAM533RXg5e8j1qbPaflDbAb6llGHRrJIjFBLQypmPdtbHp26JIJP/M jebG/mtxzmx1iwovBd9qp5RJLAGL0Auzyc0h X-Google-Smtp-Source: ABdhPJzv4HYkiUXGnJ7jhcFixy5EPG+OvEg4CQ1H7tuitRWqz0j1TOmjtIjGgElElX71VzvIo0ZSfQ== X-Received: by 2002:a05:6638:10ea:: with SMTP id g10mr35244447jae.117.1641745192180; Sun, 09 Jan 2022 08:19:52 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 21/30] bsd-user/signal.c: force_sig Date: Sun, 9 Jan 2022 09:19:14 -0700 Message-Id: <20220109161923.85683-22-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d30 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641746622506100001 Content-Type: text/plain; charset="utf-8" Force delivering a signal and generating a core file. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/qemu.h | 1 + bsd-user/signal.c | 59 +++++++++++++++++++++++++++++++++++++++++ bsd-user/syscall_defs.h | 1 + 3 files changed, 61 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 7c54a933eb8..e12617f5d69 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -223,6 +223,7 @@ void queue_signal(CPUArchState *env, int sig, target_si= ginfo_t *info); abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp); int target_to_host_signal(int sig); int host_to_target_signal(int sig); +void QEMU_NORETURN force_sig(int target_sig); =20 /* mmap.c */ int target_mprotect(abi_ulong start, abi_ulong len, int prot); diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 824535be8b8..97f42f9c45e 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -109,6 +109,65 @@ static int core_dump_signal(int sig) } } =20 +/* Abort execution with signal. */ +void QEMU_NORETURN force_sig(int target_sig) +{ + CPUArchState *env =3D thread_cpu->env_ptr; + CPUState *cpu =3D env_cpu(env); + TaskState *ts =3D cpu->opaque; + int core_dumped =3D 0; + int host_sig; + struct sigaction act; + + host_sig =3D target_to_host_signal(target_sig); + gdb_signalled(env, target_sig); + + /* Dump core if supported by target binary format */ + if (core_dump_signal(target_sig) && (ts->bprm->core_dump !=3D NULL)) { + stop_all_tasks(); + core_dumped =3D + ((*ts->bprm->core_dump)(target_sig, env) =3D=3D 0); + } + if (core_dumped) { + struct rlimit nodump; + + /* + * We already dumped the core of target process, we don't want + * a coredump of qemu itself. + */ + getrlimit(RLIMIT_CORE, &nodump); + nodump.rlim_cur =3D 0; + setrlimit(RLIMIT_CORE, &nodump); + (void) fprintf(stderr, "qemu: uncaught target signal %d (%s) " + "- %s\n", target_sig, strsignal(host_sig), "core dumped"); + } + + /* + * 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 + * actually die from an uncaught signal. Here the default signal + * handler is installed, we send ourself a signal and we wait for + * it to arrive. + */ + memset(&act, 0, sizeof(act)); + sigfillset(&act.sa_mask); + act.sa_handler =3D SIG_DFL; + sigaction(host_sig, &act, NULL); + + kill(getpid(), host_sig); + + /* + * Make sure the signal isn't masked (just reuse the mask inside + * of act). + */ + sigdelset(&act.sa_mask, host_sig); + sigsuspend(&act.sa_mask); + + /* unreachable */ + abort(); +} + /* * Queue a signal so that it will be send to the virtual CPU as soon as * possible. diff --git a/bsd-user/syscall_defs.h b/bsd-user/syscall_defs.h index 04a1a886d7b..62b472b990b 100644 --- a/bsd-user/syscall_defs.h +++ b/bsd-user/syscall_defs.h @@ -21,6 +21,7 @@ #define _SYSCALL_DEFS_H_ =20 #include +#include =20 #include "errno_defs.h" =20 --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641747041782839.8083100875631; Sun, 9 Jan 2022 08:50:41 -0800 (PST) Received: from localhost ([::1]:57864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bOy-0008Fb-RZ for importer@patchew.org; Sun, 09 Jan 2022 11:50:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avE-00064y-9q for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:57 -0500 Received: from [2607:f8b0:4864:20::d2e] (port=33414 helo=mail-io1-xd2e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6avC-0007AB-Iq for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:55 -0500 Received: by mail-io1-xd2e.google.com with SMTP id s6so14447648ioj.0 for ; Sun, 09 Jan 2022 08:19:54 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=x/chF1pI+UgVoNqn57r2leNeMHFRdDwZrT3qt9wYBRc=; b=U2f4+tYn7j8TbXZhW5JgUR3l8g4Tej4KxnLr3w9xUo2d7oETsWahY9CraBeG/KK/y7 fybI8w6X3lOP0BBeM10KOlMx+PCe6zG4BTVvpceGHPfsDZ/lhMfkuvXoo3gL7C1znle3 IrpVEmB4YVSXBjHDeEPVZTtXTAdVg8BQGuobReDi0g0R8/usIwUlVzQSB8oxH7oNKd5U ImBuSigg2burAiOAkkpX+EjOeewxzB0BOLwLaYeM8UnW91+BAXzLXiUfkHFkw9+h6vBj ekMPHapL8KVZ22bAXumXk1NP4SCvNUKoYZMxbojpNYyVjndSDdV3l9ZCrJnQQXyA9+mi 3Ntg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=x/chF1pI+UgVoNqn57r2leNeMHFRdDwZrT3qt9wYBRc=; b=jryJhwBD5HOHZrX0HOUW2ORlijo6NhoGvCUST3vsV24i3zRXJt5Bxj/c9wD2WOZntA iF2NSyULUZHzuOpOoenvohdUhrNQccSKO51rKy1g4+YoHepR91Cf1LpnpB0UshS/rc5W 0PouGFDhU94BwCw3vnK/xvccssBnBqwh1YXQV7w2G+25/332mbIOsAhfwrNTRcbbjbNR PkgatSfPZ8DKCclPNhcWDYeW8/qp7TDao9fAdWNPfcO0UUVbjbxamdZPgrRrC7aOnBRs LfaUScIG9Mpao8rrsmtz//6RGHtdXADPjowxBpIl8UGnYDH2onRQx99KvKVzaEnfv9Tj Oycg== X-Gm-Message-State: AOAM530RoNmYITmB7IV/fWzojDAXRjReQUyZYxMJeX9jo/2A/d8ouzyC jxFmCPGjixXMAwwDsf48uzLf+SDNTrQyfmWl X-Google-Smtp-Source: ABdhPJxGbjopkOv2UiFTEe0MQFf3W6Dnvm22aQ2nhjrc1lUgf5e3M4W7YwcYu5VAFqlky2DfUnhTug== X-Received: by 2002:a05:6602:2f09:: with SMTP id q9mr6676893iow.55.1641745193062; Sun, 09 Jan 2022 08:19:53 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 22/30] bsd-user/signal.c: Fill in queue_signal Date: Sun, 9 Jan 2022 09:19:15 -0700 Message-Id: <20220109161923.85683-23-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2e (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2e; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2e.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641747044115100001 Content-Type: text/plain; charset="utf-8" Fill in queue signal implementation, as well as routines allocate and delete elements of the signal queue. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/signal.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 97f42f9c45e..93c3b3c5033 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -109,6 +109,29 @@ static int core_dump_signal(int sig) } } =20 +/* Signal queue handling. */ +static inline struct qemu_sigqueue *alloc_sigqueue(CPUArchState *env) +{ + CPUState *cpu =3D env_cpu(env); + TaskState *ts =3D cpu->opaque; + struct qemu_sigqueue *q =3D ts->first_free; + + if (!q) { + return NULL; + } + ts->first_free =3D q->next; + return q; +} + +static inline void free_sigqueue(CPUArchState *env, struct qemu_sigqueue *= q) +{ + + CPUState *cpu =3D env_cpu(env); + TaskState *ts =3D cpu->opaque; + q->next =3D ts->first_free; + ts->first_free =3D q; +} + /* Abort execution with signal. */ void QEMU_NORETURN force_sig(int target_sig) { @@ -174,7 +197,54 @@ void QEMU_NORETURN force_sig(int target_sig) */ void queue_signal(CPUArchState *env, int sig, target_siginfo_t *info) { - qemu_log_mask(LOG_UNIMP, "No signal queueing, dropping signal %d\n", s= ig); + CPUState *cpu =3D env_cpu(env); + TaskState *ts =3D cpu->opaque; + struct emulated_sigtable *k; + struct qemu_sigqueue *q, **pq; + + k =3D &ts->sigtab[sig - 1]; + trace_user_queue_signal(env, sig); /* We called this in the caller? XX= X */ + /* + * XXX does the segv changes make this go away? -- I think so + */ + if (sig =3D=3D TARGET_SIGSEGV && sigismember(&ts->signal_mask, SIGSEGV= )) { + /* + * Guest has blocked SIGSEGV but we got one anyway. Assume this is= a + * forced SIGSEGV (ie one the kernel handles via force_sig_info be= cause + * it got a real MMU fault). A blocked SIGSEGV in that situation is + * treated as if using the default handler. This is not correct if= some + * other process has randomly sent us a SIGSEGV via kill(), but th= at is + * not easy to distinguish at this point, so we assume it doesn't + * happen. + */ + force_sig(sig); + } + + pq =3D &k->first; + + /* + * FreeBSD signals are always queued. Linux only queues real time sig= nals. + * XXX this code is not thread safe. "What lock protects ts->sigtab?" + */ + if (!k->pending) { + /* first signal */ + q =3D &k->info; + } else { + q =3D alloc_sigqueue(env); + if (!q) { + return; /* XXX WHAT TO DO */ + } + while (*pq !=3D NULL) { + pq =3D &(*pq)->next; + } + } + *pq =3D q; + q->info =3D *info; + q->next =3D NULL; + k->pending =3D 1; + /* Signal that a new signal is pending. */ + ts->signal_pending =3D 1; + return; } =20 static int fatal_signal(int sig) --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641747168045401.54928839558136; Sun, 9 Jan 2022 08:52:48 -0800 (PST) Received: from localhost ([::1]:34174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bR0-0002yN-Oa for importer@patchew.org; Sun, 09 Jan 2022 11:52:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avE-000655-Nh for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:57 -0500 Received: from [2607:f8b0:4864:20::d30] (port=33416 helo=mail-io1-xd30.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6avD-0007AK-5o for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:56 -0500 Received: by mail-io1-xd30.google.com with SMTP id s6so14447666ioj.0 for ; Sun, 09 Jan 2022 08:19:54 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fCMeGvHXcPe5nbOM6HUuXOOWBSNv3m2HcRt+xLifomg=; b=cRoIzdRtJCiqyel6RF2xA//EqUOgvI+nOVv7PrP5pm8dp80v3QZns4eO//mkbkyGNW Id0agKP4hU40odwAcgL8xp1ZilWBE75nfak44aT1xCUni1vccOG6apIWv1jtpI6HuybK F0pkP4MJmj1Hmf6lMFI48se3f+w0eTZbCUWurjDcuHQVAvZIOehx+7oUtZUVJ8AicQGA ucbJw9o7q6GwsCTwxu3WaZeK1raOcWXYB73dgCfwGY0hWKt5GqSC3OsnzYAvlsBrs4K+ Ff2dy6MCj4JJSbVl+fg6/8qVr6PWZMtqSE5BSo6mkNm+qo3+jwwjVvJB2NwoxQ2aFyDj +NcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fCMeGvHXcPe5nbOM6HUuXOOWBSNv3m2HcRt+xLifomg=; b=LkvbhnuCZiA3Ez45oeL+qv2umhrlzqHRFJq8yCBzzFVqQaCWIvI+SciFIPkRFjeOz+ MHldWVFXv5y8AWqAxk2dwukZyRUl1W6ikEQ/L6aPvDZMAtQ12X/xf2NReJ2PmMnuvPyz 2gnwk2tE1fD3CLhMrmNGAeX/qXOQ2w+iwjLXHNnsvaQ960+kjig9RFqbl2ta1X6tPugp URP2ULM7D7uKfaHaV6j7zIIEZXVAQr21fJYpiSU6c+xJweMKb6m4TB2slH8lehmYJfOU DDFdlaexBmkSlhIt084dm+sqejc+k743RH75AZPuzNf9dorfVaPd4ohfH5uNJ0JMrYBM UO+Q== X-Gm-Message-State: AOAM53007PFfkZZzmYNhovDO2zIllpl2sT1l18q4pty1g8B/UMb3E+Ja ipH033kGqTKtjVwXSiTs0G/d8qeQHQK4UumX X-Google-Smtp-Source: ABdhPJyFTxbSaVXSeR8g0X8YpJBBtkqtHXn+FLQ9Tv9mThCLYzGcwmaIs7IyWOrbfouGAHd4BHMFIA== X-Received: by 2002:a02:734b:: with SMTP id a11mr25761749jae.168.1641745193983; Sun, 09 Jan 2022 08:19:53 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 23/30] bsd-user/signal.c: sigset manipulation routines. Date: Sun, 9 Jan 2022 09:19:16 -0700 Message-Id: <20220109161923.85683-24-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d30 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641747170625100001 Content-Type: text/plain; charset="utf-8" target_sigemptyset: resets a set to having no bits set qemu_sigorset: computes the or of two sets target_sigaddset: adds a signal to a set target_sigismember: returns true when signal is a member host_to_target_sigset_internal: convert host sigset to target host_to_target_sigset: convert host sigset to target target_to_host_sigset_internal: convert target sigset to host target_to_host_sigset: convert target sigset to host Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/qemu.h | 3 ++ bsd-user/signal.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index e12617f5d69..e8c417c7c33 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -223,7 +223,10 @@ void queue_signal(CPUArchState *env, int sig, target_s= iginfo_t *info); abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp); int target_to_host_signal(int sig); int host_to_target_signal(int sig); +void host_to_target_sigset(target_sigset_t *d, const sigset_t *s); +void target_to_host_sigset(sigset_t *d, const target_sigset_t *s); void QEMU_NORETURN force_sig(int target_sig); +int qemu_sigorset(sigset_t *dest, const sigset_t *left, const sigset_t *ri= ght); =20 /* mmap.c */ int target_mprotect(abi_ulong start, abi_ulong len, int prot); diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 93c3b3c5033..8dadc9a39a7 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -32,6 +32,9 @@ =20 static struct target_sigaction sigact_table[TARGET_NSIG]; static void host_signal_handler(int host_sig, siginfo_t *info, void *puc); +static void target_to_host_sigset_internal(sigset_t *d, + const target_sigset_t *s); + =20 int host_to_target_signal(int sig) { @@ -43,6 +46,44 @@ int target_to_host_signal(int sig) return sig; } =20 +static inline void target_sigemptyset(target_sigset_t *set) +{ + memset(set, 0, sizeof(*set)); +} + +#include + +int +qemu_sigorset(sigset_t *dest, const sigset_t *left, const sigset_t *right) +{ + sigset_t work; + int i; + + sigemptyset(&work); + for (i =3D 1; i < NSIG; ++i) { + if (sigismember(left, i) || sigismember(right, i)) { + sigaddset(&work, i); + } + } + + *dest =3D work; + return 0; +} + +static inline void target_sigaddset(target_sigset_t *set, int signum) +{ + signum--; + uint32_t mask =3D (uint32_t)1 << (signum % TARGET_NSIG_BPW); + set->__bits[signum / TARGET_NSIG_BPW] |=3D mask; +} + +static inline int target_sigismember(const target_sigset_t *set, int signu= m) +{ + signum--; + abi_ulong mask =3D (abi_ulong)1 << (signum % TARGET_NSIG_BPW); + return (set->__bits[signum / TARGET_NSIG_BPW] & mask) !=3D 0; +} + /* Adjust the signal context to rewind out of safe-syscall if we're in it = */ static inline void rewind_if_in_safe_syscall(void *puc) { @@ -55,6 +96,54 @@ static inline void rewind_if_in_safe_syscall(void *puc) } } =20 +static void host_to_target_sigset_internal(target_sigset_t *d, + const sigset_t *s) +{ + int i; + + target_sigemptyset(d); + for (i =3D 1; i <=3D TARGET_NSIG; i++) { + if (sigismember(s, i)) { + target_sigaddset(d, host_to_target_signal(i)); + } + } +} + +void host_to_target_sigset(target_sigset_t *d, const sigset_t *s) +{ + target_sigset_t d1; + int i; + + host_to_target_sigset_internal(&d1, s); + for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { + d->__bits[i] =3D tswap32(d1.__bits[i]); + } +} + +static void target_to_host_sigset_internal(sigset_t *d, + const target_sigset_t *s) +{ + int i; + + sigemptyset(d); + for (i =3D 1; i <=3D TARGET_NSIG; i++) { + if (target_sigismember(s, i)) { + sigaddset(d, target_to_host_signal(i)); + } + } +} + +void target_to_host_sigset(sigset_t *d, const target_sigset_t *s) +{ + target_sigset_t s1; + int i; + + for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { + s1.__bits[i] =3D tswap32(s->__bits[i]); + } + target_to_host_sigset_internal(d, &s1); +} + /* Siginfo conversion. */ static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, const siginfo_t *info) --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164174613867713.619188373207749; Sun, 9 Jan 2022 08:35:38 -0800 (PST) Received: from localhost ([::1]:60674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bAO-0006Ef-04 for importer@patchew.org; Sun, 09 Jan 2022 11:35:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avF-00066T-Kt for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:57 -0500 Received: from [2607:f8b0:4864:20::d2c] (port=46971 helo=mail-io1-xd2c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6avE-0007AU-1h for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:57 -0500 Received: by mail-io1-xd2c.google.com with SMTP id w9so1346715iol.13 for ; Sun, 09 Jan 2022 08:19:55 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zXKd+4Q2EYN8IsQpSvhQcGeQyVEk0TEwvPd02H3ZhQQ=; b=PR1B495tcN4+myT7kgWZ+ex8n+p4nKFq6+vQr75xlYGycdkNAtAxf4+MsAh9gU6SKA 0lnxbuEqnRENhEgTYa3Po+SAjRAtkFjmIR976gW9doWktgOLkp+c1yLLSXgbkuv5MheL 2L0TsgM/S98X0UaXDCYLCbtSgrDGHGTMhdhxhRXjdIlUNmgstbnwgewsUIwUdld+We6L WXGsYHnmWYatovEV33QNAErMwSFwRuf+fvNLzEb97q1K+DYkvQ7DcvpxYgCA6DklBu4M GGiAqgMF86GXimYIw+NuuXzGuDWrJkcedte29v6bIK8Uc8sZvOB7GodPBMhKstlpHjvV TQoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zXKd+4Q2EYN8IsQpSvhQcGeQyVEk0TEwvPd02H3ZhQQ=; b=Q0VOxHyoZd8ET/UgCqpoU63djmHImYMpUYakujHs6+GOI3dPKrJeSmaoz8DiH/INr8 SJIDUmuoskqT4NyNLYmNdFOTaggErg09TZKOpxF0xUGSHYLURuwhX7SDC+SjnakClu1c OyttK955ODMlVx4voEnJNuf1xf5GO3n6NjVvqbYifvWMZBB99V35FaG9AqOC7Zskk8vy BuugxbQnf5kjDAM3QXO9Yu/jZ+cVVrmAedxD1QA4g0vtNu1NqDXh5Xu3a4HV9PYM2lEk mkBF3kUUzb5/eW7yzjfTfKotM4vY3Fze18K6t615H86pxGNmDEnGv7DPEIr4R9Ev4zMK LiEQ== X-Gm-Message-State: AOAM532+tSCE8cY/VnBYn+/6o+UWKdE/v9jv2ooI4pJ4mj6w15C1yr3I Hhu1UhVL8Dvc7RTJ27TPEvmz0fMOr7Gj1L15 X-Google-Smtp-Source: ABdhPJwoDJGnQFcf7EYj+7tFQe5I2WEe42Enug77lIkTqUwI+1eGUg9siYMXYtqdNsnjpmzR4T3EgA== X-Received: by 2002:a02:9308:: with SMTP id d8mr1198215jah.52.1641745194757; Sun, 09 Jan 2022 08:19:54 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 24/30] bsd-user/signal.c: setup_frame Date: Sun, 9 Jan 2022 09:19:17 -0700 Message-Id: <20220109161923.85683-25-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2c (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2c; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641746141118100001 Content-Type: text/plain; charset="utf-8" setup_frame sets up a signalled stack frame. Associated routines to extract the pointer to the stack frame and to support alternate stacks. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/signal.c | 166 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 144 insertions(+), 22 deletions(-) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 8dadc9a39a7..8e1427553da 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -30,11 +30,27 @@ * fork. */ =20 +static target_stack_t target_sigaltstack_used =3D { + .ss_sp =3D 0, + .ss_size =3D 0, + .ss_flags =3D TARGET_SS_DISABLE, +}; + static struct target_sigaction sigact_table[TARGET_NSIG]; static void host_signal_handler(int host_sig, siginfo_t *info, void *puc); static void target_to_host_sigset_internal(sigset_t *d, const target_sigset_t *s); =20 +static inline int on_sig_stack(unsigned long sp) +{ + return sp - target_sigaltstack_used.ss_sp < target_sigaltstack_used.ss= _size; +} + +static inline int sas_ss_flags(unsigned long sp) +{ + return target_sigaltstack_used.ss_size =3D=3D 0 ? SS_DISABLE : on_sig_= stack(sp) + ? SS_ONSTACK : 0; +} =20 int host_to_target_signal(int sig) { @@ -336,28 +352,6 @@ void queue_signal(CPUArchState *env, int sig, target_s= iginfo_t *info) return; } =20 -static int fatal_signal(int sig) -{ - - switch (sig) { - case TARGET_SIGCHLD: - case TARGET_SIGURG: - case TARGET_SIGWINCH: - case TARGET_SIGINFO: - /* Ignored by default. */ - return 0; - case TARGET_SIGCONT: - case TARGET_SIGSTOP: - case TARGET_SIGTSTP: - case TARGET_SIGTTIN: - case TARGET_SIGTTOU: - /* Job control signals. */ - return 0; - default: - return 1; - } -} - /* * Force a synchronously taken QEMU_SI_FAULT signal. For QEMU the * 'force' part is handled in process_pending_signals(). @@ -484,6 +478,134 @@ static void host_signal_handler(int host_sig, siginfo= _t *info, void *puc) cpu_exit(thread_cpu); } =20 +static int fatal_signal(int sig) +{ + + switch (sig) { + case TARGET_SIGCHLD: + case TARGET_SIGURG: + case TARGET_SIGWINCH: + case TARGET_SIGINFO: + /* Ignored by default. */ + return 0; + case TARGET_SIGCONT: + case TARGET_SIGSTOP: + case TARGET_SIGTSTP: + case TARGET_SIGTTIN: + case TARGET_SIGTTOU: + /* Job control signals. */ + return 0; + default: + return 1; + } +} + +static inline abi_ulong get_sigframe(struct target_sigaction *ka, + CPUArchState *regs, size_t frame_size) +{ + abi_ulong sp; + + /* Use default user stack */ + sp =3D get_sp_from_cpustate(regs); + + if ((ka->sa_flags & TARGET_SA_ONSTACK) && (sas_ss_flags(sp) =3D=3D 0))= { + sp =3D target_sigaltstack_used.ss_sp + + target_sigaltstack_used.ss_size; + } + +#if defined(TARGET_MIPS) || defined(TARGET_ARM) + return (sp - frame_size) & ~7; +#elif defined(TARGET_AARCH64) + return (sp - frame_size) & ~15; +#else + return sp - frame_size; +#endif +} + +/* compare to mips/mips/pm_machdep.c and sparc64/sparc64/machdep.c sendsig= () */ +static void setup_frame(int sig, int code, struct target_sigaction *ka, + target_sigset_t *set, target_siginfo_t *tinfo, CPUArchState *regs) +{ + struct target_sigframe *frame; + abi_ulong frame_addr; + int i; + + frame_addr =3D get_sigframe(ka, regs, sizeof(*frame)); + trace_user_setup_frame(regs, frame_addr); + if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { + goto give_sigsegv; + } + + memset(frame, 0, sizeof(*frame)); +#if defined(TARGET_MIPS) + int mflags =3D on_sig_stack(frame_addr) ? TARGET_MC_ADD_MAGIC : + TARGET_MC_SET_ONSTACK | TARGET_MC_ADD_MAGIC; +#else + int mflags =3D 0; +#endif + if (get_mcontext(regs, &frame->sf_uc.uc_mcontext, mflags)) { + goto give_sigsegv; + } + + for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { + if (__put_user(set->__bits[i], &frame->sf_uc.uc_sigmask.__bits[i])= ) { + goto give_sigsegv; + } + } + + if (tinfo) { + frame->sf_si.si_signo =3D tinfo->si_signo; + frame->sf_si.si_errno =3D tinfo->si_errno; + frame->sf_si.si_code =3D tinfo->si_code; + frame->sf_si.si_pid =3D tinfo->si_pid; + frame->sf_si.si_uid =3D tinfo->si_uid; + frame->sf_si.si_status =3D tinfo->si_status; + frame->sf_si.si_addr =3D tinfo->si_addr; + + if (TARGET_SIGILL =3D=3D sig || TARGET_SIGFPE =3D=3D sig || + TARGET_SIGSEGV =3D=3D sig || TARGET_SIGBUS =3D=3D sig || + TARGET_SIGTRAP =3D=3D sig) { + frame->sf_si._reason._fault._trapno =3D tinfo->_reason._fault.= _trapno; + } + + /* + * If si_code is one of SI_QUEUE, SI_TIMER, SI_ASYNCIO, or + * SI_MESGQ, then si_value contains the application-specified + * signal value. Otherwise, the contents of si_value are + * undefined. + */ + if (SI_QUEUE =3D=3D code || SI_TIMER =3D=3D code || SI_ASYNCIO =3D= =3D code || + SI_MESGQ =3D=3D code) { + frame->sf_si.si_value.sival_int =3D tinfo->si_value.sival_int; + } + + if (SI_TIMER =3D=3D code) { + frame->sf_si._reason._timer._timerid =3D + tinfo->_reason._timer._timerid; + frame->sf_si._reason._timer._overrun =3D + tinfo->_reason._timer._overrun; + } + +#ifdef SIGPOLL + if (SIGPOLL =3D=3D sig) { + frame->sf_si._reason._band =3D tinfo->_reason._band; + } +#endif + + } + + if (set_sigtramp_args(regs, sig, frame, frame_addr, ka)) { + goto give_sigsegv; + } + + unlock_user_struct(frame, frame_addr, 1); + return; + +give_sigsegv: + unlock_user_struct(frame, frame_addr, 1); + force_sig(TARGET_SIGSEGV); +} + void signal_init(void) { TaskState *ts =3D (TaskState *)thread_cpu->opaque; --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641746838212853.8402187023048; Sun, 9 Jan 2022 08:47:18 -0800 (PST) Received: from localhost ([::1]:52076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bLg-0004NJ-Ve for importer@patchew.org; Sun, 09 Jan 2022 11:47:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avG-00067M-9G for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:58 -0500 Received: from [2607:f8b0:4864:20::d30] (port=37675 helo=mail-io1-xd30.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6avE-0007Ae-R7 for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:58 -0500 Received: by mail-io1-xd30.google.com with SMTP id 19so14371352ioz.4 for ; Sun, 09 Jan 2022 08:19:56 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IgeZV4dDM0VUWpp2I79PpeH7DAHq3pnTFE5wkPhwXEM=; b=BLy3SW1QPED7JYXdDROsFQjJdV3a6ogI3epJPSmhIp/S/WXwqxJ7QPXwzOxKF4woUp u3NqO1nR8FUNupNgmhbM+5Y8GQu6//gAJK3tvl7XMYqOd+QcZJl+vgo+uELrx7P5MKJ0 V3Icv5mMtd0cv3XAY3I74dUxdu8WcPlvCfm9jBZtJSSyBsbH5YpkxByuE6ic29rddcsh 25VpgvtbkBGGJniYHQ3h6/XKNxHK0hlKh3iIod6tNH4DdaxAG+DB3BbTq+FhQvflsLIr nGQSUMcuDBlyLrvH+FVgcJHCEm+/s2HMx62mG60Zy5RpUw59EXu95Zj2FHmqg07PG2Kl HVkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IgeZV4dDM0VUWpp2I79PpeH7DAHq3pnTFE5wkPhwXEM=; b=bvDS3yziktWEjvy6J074wfB5ZA1xcGzIPtMwgRcFw53bOcwkcjEplS2LUi+gEf60Lr UQMl9SqcheKclwfee26ZbM6ZtY7Qg5lcrH1yFlOWAxVwfGq/WWoYDH5oPuft39jIay7S 05f/6fBCElj0tyo2yu0O9SyA/gTKUrAa5SpOWsCF9At/NgZ7tVPuZB5pJDzvpmc0DLhM MXRuL5tsJCea2ReX2t2Moy5KJyqnOb+MohHAOqdrs7C7gQGTwsSeMEX+OraZJBRqvaIX OTXEBUTdCqkszh+dBD45V1j3b5WRP4y/5UYtRk0CIYy7KlTPUH4dvq8yj/8800boy2VI jiHA== X-Gm-Message-State: AOAM532ppchKCXCTuWh9nXtaqZt2m8u9zVSTPE7iJOTz3yoPzRJGCNRn Qywi6FN3r8ruowQPptfZSRL+848ecpupGDLX X-Google-Smtp-Source: ABdhPJwE8Bo00S5CiQoTS7BpmwEM7wSwlMROZ+6pC+PGJs9LBwTFtfbbE6ljtpXvOZTBQ7roL8a4Kg== X-Received: by 2002:a02:a517:: with SMTP id e23mr32516509jam.35.1641745195616; Sun, 09 Jan 2022 08:19:55 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 25/30] bsd-user/signal.c: handle_pending_signal Date: Sun, 9 Jan 2022 09:19:18 -0700 Message-Id: <20220109161923.85683-26-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d30 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641746839041100001 Content-Type: text/plain; charset="utf-8" Handle a queued signal. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/qemu.h | 2 + bsd-user/signal.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index e8c417c7c33..011fdfebbaa 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -97,7 +97,9 @@ typedef struct TaskState { struct qemu_sigqueue sigqueue_table[MAX_SIGQUEUE_SIZE]; /* siginfo que= ue */ struct qemu_sigqueue *first_free; /* first free siginfo queue entry */ int signal_pending; /* non zero if a signal may be pending */ + bool in_sigsuspend; sigset_t signal_mask; + sigset_t sigsuspend_mask; =20 uint8_t stack[]; } __attribute__((aligned(16))) TaskState; diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 8e1427553da..934528d5fb0 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -649,6 +649,102 @@ void signal_init(void) } } =20 +static void handle_pending_signal(CPUArchState *cpu_env, int sig, + struct emulated_sigtable *k) +{ + CPUState *cpu =3D env_cpu(cpu_env); + TaskState *ts =3D cpu->opaque; + struct qemu_sigqueue *q; + struct target_sigaction *sa; + int code; + sigset_t set; + abi_ulong handler; + target_siginfo_t tinfo; + target_sigset_t target_old_set; + + trace_user_handle_signal(cpu_env, sig); + + /* Dequeue signal. */ + q =3D k->first; + k->first =3D q->next; + if (!k->first) { + k->pending =3D 0; + } + + sig =3D gdb_handlesig(cpu, sig); + if (!sig) { + sa =3D NULL; + handler =3D TARGET_SIG_IGN; + } else { + sa =3D &sigact_table[sig - 1]; + handler =3D sa->_sa_handler; + } + + if (do_strace) { + print_taken_signal(sig, &q->info); + } + + if (handler =3D=3D TARGET_SIG_DFL) { + /* + * default handler : ignore some signal. The other are job + * control or fatal. + */ + if (TARGET_SIGTSTP =3D=3D sig || TARGET_SIGTTIN =3D=3D sig || + TARGET_SIGTTOU =3D=3D sig) { + kill(getpid(), SIGSTOP); + } else if (TARGET_SIGCHLD !=3D sig && TARGET_SIGURG !=3D sig && + TARGET_SIGINFO !=3D sig && + TARGET_SIGWINCH !=3D sig && TARGET_SIGCONT !=3D sig) { + force_sig(sig); + } + } else if (TARGET_SIG_IGN =3D=3D handler) { + /* ignore sig */ + } else if (TARGET_SIG_ERR =3D=3D handler) { + force_sig(sig); + } else { + /* compute the blocked signals during the handler execution */ + sigset_t *blocked_set; + + target_to_host_sigset(&set, &sa->sa_mask); + /* + * SA_NODEFER indicates that the current signal should not be + * blocked during the handler. + */ + if (!(sa->sa_flags & TARGET_SA_NODEFER)) { + sigaddset(&set, target_to_host_signal(sig)); + } + + /* + * Save the previous blocked signal state to restore it at the + * end of the signal execution (see do_sigreturn). + */ + host_to_target_sigset_internal(&target_old_set, &ts->signal_mask); + + blocked_set =3D ts->in_sigsuspend ? + &ts->sigsuspend_mask : &ts->signal_mask; + qemu_sigorset(&ts->signal_mask, blocked_set, &set); + ts->in_sigsuspend =3D false; + sigprocmask(SIG_SETMASK, &ts->signal_mask, NULL); + + /* XXX VM86 on x86 ??? */ + + code =3D q->info.si_code; + /* prepare the stack frame of the virtual CPU */ + if (sa->sa_flags & TARGET_SA_SIGINFO) { + tswap_siginfo(&tinfo, &q->info); + setup_frame(sig, code, sa, &target_old_set, &tinfo, cpu_env); + } else { + setup_frame(sig, code, sa, &target_old_set, NULL, cpu_env); + } + if (sa->sa_flags & TARGET_SA_RESETHAND) { + sa->_sa_handler =3D TARGET_SIG_DFL; + } + } + if (q !=3D &k->info) { + free_sigqueue(cpu_env, q); + } +} + void process_pending_signals(CPUArchState *cpu_env) { } --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641747353087992.6326663772234; Sun, 9 Jan 2022 08:55:53 -0800 (PST) Received: from localhost ([::1]:36584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bTz-0004ej-Sc for importer@patchew.org; Sun, 09 Jan 2022 11:55:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avH-00068D-8E for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:20:00 -0500 Received: from [2607:f8b0:4864:20::133] (port=46621 helo=mail-il1-x133.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6avF-0007An-RB for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:59 -0500 Received: by mail-il1-x133.google.com with SMTP id e8so9250308ilm.13 for ; Sun, 09 Jan 2022 08:19:57 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lCK1OHSQl9Im63sCA2nGuP0lIosQYGcMtjnevAY5QWY=; b=zGl1r8b7hJqY0CNcHh6s3ZTmt1PGSbtT89B0dJjsQu7KTwvJN8PJFilKhW1NdWJ47q 5tMmBXLnBibzq58VLmz6T0y4E1LHepHp5h8D9S6q26G5bUsPC3JOP/JId0H17KWeRnwr y4M6F4NrtrLL982CgQFvH0OKIeHxBDqRUZRG8g4aQmym3PCDsXhyflxBE5M1jXHn0vpM xTjT8oia864Yr1O2IoTsx8KL9ckfh6UnV19RT3KqEfznl9kvtatpOk6EIxqToxItzZCz pKmeFLDg/iG9kaXbHC0/sk+q25HINfjYBm8w+tItQb+T+cB6K6VpFVQnUOtp1SWqZyDN UM0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lCK1OHSQl9Im63sCA2nGuP0lIosQYGcMtjnevAY5QWY=; b=D8bFMVHSseBWj5TqfVSmxAQgzmrdmzgWEYjIui1YuGLnPUjBp9pT8ZIf2O0W0urgAF 42X0WbohbzY+Vpc3mPjqMemHAuvKpqryWFKv3uSYzggyyKGcqSIKuIQvZvWtTr34sGzX aFhpq1g/4syRMOsl5HkijyhgKaxGZmomg8STm0y2PfJtaC0YYfI1zQfEKpBRzWCAuYfW /EFBSbVEbpMcnR6hQObEAolRJY9ebdk4g6jH3QjvndmUl5CEiLySVRTpQRpcajKdpmOW 3rdgd0Z2bPAzWiExniehuywRElcgZ1Xrkvf0Pb3dILujvGSTQB3FUu3fdjsv6FM4EUpt wOPw== X-Gm-Message-State: AOAM530ZOSV3sD5Rv9zGrgK2IVhz2zEQ5Zfx4iHKt8Opt/wUo4UK7PEC PJiWJbU7uQ1hxVDMQ9BY6aeee6OUJhLav/di X-Google-Smtp-Source: ABdhPJxuaDs9GUeKRXAchpa00FQYwlGHQjSF/qY0D3MKlaihcI4m/qI8JyZ6amADiq+4X6wicp912g== X-Received: by 2002:a05:6e02:b45:: with SMTP id f5mr35815937ilu.131.1641745196531; Sun, 09 Jan 2022 08:19:56 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 26/30] bsd-user/signal.c: tswap_siginfo Date: Sun, 9 Jan 2022 09:19:19 -0700 Message-Id: <20220109161923.85683-27-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::133 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::133; envelope-from=imp@bsdimp.com; helo=mail-il1-x133.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641747354411100001 Content-Type: text/plain; charset="utf-8" Convert siginfo from targer to host. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/signal.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 934528d5fb0..c954d0f4f37 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -197,6 +197,40 @@ static inline void host_to_target_siginfo_noswap(targe= t_siginfo_t *tinfo, } } =20 +static void tswap_siginfo(target_siginfo_t *tinfo, const target_siginfo_t = *info) +{ + int sig, code; + + sig =3D info->si_signo; + code =3D info->si_code; + tinfo->si_signo =3D tswap32(sig); + tinfo->si_errno =3D tswap32(info->si_errno); + tinfo->si_code =3D tswap32(info->si_code); + tinfo->si_pid =3D tswap32(info->si_pid); + tinfo->si_uid =3D tswap32(info->si_uid); + tinfo->si_status =3D tswap32(info->si_status); + tinfo->si_addr =3D tswapal(info->si_addr); + /* + * Unswapped, because we passed it through mostly untouched. si_value= is + * opaque to the kernel, so we didn't bother with potentially wasting = cycles + * to swap it into host byte order. + */ + tinfo->si_value.sival_ptr =3D info->si_value.sival_ptr; + if (SIGILL =3D=3D sig || SIGFPE =3D=3D sig || SIGSEGV =3D=3D sig || SI= GBUS =3D=3D sig || + SIGTRAP =3D=3D sig) { + tinfo->_reason._fault._trapno =3D tswap32(info->_reason._fault._tr= apno); + } +#ifdef SIGPOLL + if (SIGPOLL =3D=3D sig) { + tinfo->_reason._poll._band =3D tswap32(info->_reason._poll._band); + } +#endif + if (SI_TIMER =3D=3D code) { + tinfo->_reason._timer._timerid =3D tswap32(info->_reason._timer._t= imerid); + tinfo->_reason._timer._overrun =3D tswap32(info->_reason._timer._o= verrun); + } +} + /* Returns 1 if given signal should dump core if not handled. */ static int core_dump_signal(int sig) { --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641747442592680.869012158651; Sun, 9 Jan 2022 08:57:22 -0800 (PST) Received: from localhost ([::1]:38852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bVR-0006Hg-Iw for importer@patchew.org; Sun, 09 Jan 2022 11:57:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avH-00068E-Tb for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:20:00 -0500 Received: from [2607:f8b0:4864:20::12c] (port=41678 helo=mail-il1-x12c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6avG-0007Ay-Fp for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:19:59 -0500 Received: by mail-il1-x12c.google.com with SMTP id r16so7581237ile.8 for ; Sun, 09 Jan 2022 08:19:58 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0P5M3SYYhj6/NJKc2UQgkWoQEN0Yf6hQsN8Efb/RAIs=; b=TrVxpudwls+XUnqPM3BPhYIxbacH1sRyGNRhilhJZowoYdfsxrev9oMdQKPf6lDyHw M+o3uSXIL6gi1a/J0vc/dBxOmZSSJFrI+/OQTJ1pFXnPr3bPTcz8cZaCSTYHBZiltetf riXf2vhn37c+dCBXH8ZvQ3NvUJqT72Kf51FevgIli9oo9Q+ZfCDOkw4qy8hxnfrlfpak mKqsgWhePCLlO4Qbex26cSoIK0Rher5Ck2QMHC/PRqr8nAQoON8ayzKILd6d06fTvFNx e54zSowz3sRv8xBRkvTJq4Ua1sqJrX86nhJX0/qUs8xxHoHAEUUHBL4XMnTVRPslsCrv fIJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0P5M3SYYhj6/NJKc2UQgkWoQEN0Yf6hQsN8Efb/RAIs=; b=FdGJNih0tdmU3gslaAY4CHWu1PR3FEWR8IA3ApL3jlyLI9GuPv/PAtSAQlJfRmENuA sk3mkLGbdC2gOCXkgDoInYxAVcfyewMJ+ZorQ9wLx7SX7Xr0suxmMxqxypoX77XDkoQt MJQnIP8OSu2FxJEemltdMG8+LyrnKMDwDvt3KWOBkaOhu6LJQjyXeLcwq5/+1fr6xkgq KEmFkShqYzgkuZfSb1VdNQLC6nf6xZtpTuE/aAf9UWMQoteCBefeaeFvpOG6q9RQObOh TJCsjpNehULUFhIdtBTxmRrBN8rMimn3zSF7LWx+Rmyz5tgzP7vvyNMIzd3D6V7h/KT7 KnXg== X-Gm-Message-State: AOAM530qTcJZPd7ue2aBY9iqtvI5rSsy6qmM1zbYhRH4RVpg6mR0/NLw Cz8zB5yMpGSl4iM0cgMVSXphL4B6NM8mbONJ X-Google-Smtp-Source: ABdhPJyoc4/st2Wxbej2x4rns8XodZ2W6cD2TXIJfjK7CGST7ga9IIHqZPQt7CxMftZqxxMTD8PUIA== X-Received: by 2002:a92:c26c:: with SMTP id h12mr36419561ild.229.1641745197295; Sun, 09 Jan 2022 08:19:57 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 27/30] bsd-user/signal.c: process_pending_signals Date: Sun, 9 Jan 2022 09:19:20 -0700 Message-Id: <20220109161923.85683-28-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12c (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12c; envelope-from=imp@bsdimp.com; helo=mail-il1-x12c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641747443850100001 Content-Type: text/plain; charset="utf-8" Process the currently queued signals. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/signal.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index c954d0f4f37..1dd6dbb4ee1 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -781,6 +781,40 @@ static void handle_pending_signal(CPUArchState *cpu_en= v, int sig, =20 void process_pending_signals(CPUArchState *cpu_env) { + CPUState *cpu =3D env_cpu(cpu_env); + int sig; + sigset_t *blocked_set, set; + struct emulated_sigtable *k; + TaskState *ts =3D cpu->opaque; + + while (qatomic_read(&ts->signal_pending)) { + /* FIXME: This is not threadsafe. */ + + sigfillset(&set); + sigprocmask(SIG_SETMASK, &set, 0); + + k =3D ts->sigtab; + blocked_set =3D ts->in_sigsuspend ? + &ts->sigsuspend_mask : &ts->signal_mask; + for (sig =3D 1; sig <=3D TARGET_NSIG; sig++, k++) { + if (k->pending && + !sigismember(blocked_set, target_to_host_signal(sig))) { + handle_pending_signal(cpu_env, sig, k); + } + } + + /* + * unblock signals and check one more time. Unblocking signals may= cause + * us to take anothe rhost signal, which will set signal_pending a= gain. + */ + qatomic_set(&ts->signal_pending, 0); + ts->in_sigsuspend =3D false; + set =3D ts->signal_mask; + sigdelset(&set, SIGSEGV); + sigdelset(&set, SIGBUS); + sigprocmask(SIG_SETMASK, &set, 0); + } + ts->in_sigsuspend =3D false; } =20 void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641747573736789.5002799535437; Sun, 9 Jan 2022 08:59:33 -0800 (PST) Received: from localhost ([::1]:41236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bXY-0007wm-B6 for importer@patchew.org; Sun, 09 Jan 2022 11:59:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avI-00068l-O2 for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:20:00 -0500 Received: from [2607:f8b0:4864:20::135] (port=42497 helo=mail-il1-x135.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6avH-0007B7-7Z for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:20:00 -0500 Received: by mail-il1-x135.google.com with SMTP id f4so825026ilr.9 for ; Sun, 09 Jan 2022 08:19:58 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gTX3zM6smFoEquaIJybdvpTjFCFbJNXb/5rINY7LIQo=; b=L/MSVHwB8AVpORzYnUuqFaAdnQx0MCkgnFhOe7jlr4ciQCDlHpFabpUNvjnZobtT8k xPIB2iPULl580r5B2XNxFA3+husDOZgXXJmLNjNWwP0zgZDQFysLgVjemosimel6hrwL u16gjUPikS7GRD4yrXQ2OlFEeTa4Ja3am0w5Mv3iimceXcTdN5V/Xyz0dYBaAUTTU3K/ 2D0lvTamTe61yel6dtHN3BvONrJeF8q4XlTW0ajIKXZLxVPhfYzOMBGxT5JbwyBDFk41 IHHGwkFE0j7w6CMONVzyqdN1MdO2tFOvALFhPE8fX0C+exeF9Hr8I6aViWtZIO6WlM0f orfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gTX3zM6smFoEquaIJybdvpTjFCFbJNXb/5rINY7LIQo=; b=Nhk+JuWpPXf70mUz0kOk6M1D6l1khzP+pNcHWsSUoQjzdstWy0ZcETcN53aVCMPxRU 8X+oxFn9I+eakiuAVDqK0GlCKh21KmGTLhgs0G6A3uov746jd+C4ShwIZbEpobOB6Qy1 /FwO7WOxO3Uvt8VhtW9nc0cmDee9T/8YvGlhped03aEzMiLbyWIinArQ9r6Cz8PoCq1J gbtLOZc7fccV3Q02qebu+PLW8X+P3b7njwyzNgSWB4/7qL3rXGdoOh72MZu+QeYvpgc/ npSdgN18un69gZHwwDv9aFoIzVk1GaqNifyiua264PjLpP5RYxU2SxPAz2AUxWCsH2wf alDA== X-Gm-Message-State: AOAM531jc1qJLzCCyDvE8TYbP8oR8TE9xcuQllXhzX0ls9HDb89mej+A W6wFTiMog5xV07LOWpTWOusGDbeWjG10lTDi X-Google-Smtp-Source: ABdhPJyL+DddUt3yBauKrxNVP+niqC/M+lRsyQI/mONEXB6aUjdqnIB2ApAaesMMa8WtFnTUcfyUSA== X-Received: by 2002:a05:6e02:16cb:: with SMTP id 11mr35774063ilx.59.1641745198112; Sun, 09 Jan 2022 08:19:58 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 28/30] bsd-user/signal.c: implement do_sigreturn Date: Sun, 9 Jan 2022 09:19:21 -0700 Message-Id: <20220109161923.85683-29-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::135 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::135; envelope-from=imp@bsdimp.com; helo=mail-il1-x135.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641747575975100001 Content-Type: text/plain; charset="utf-8" Implements the meat of a sigreturn(2) system call via do_sigreturn, and helper reset_signal_mask. Fix the prototype of do_sigreturn in qemu.h and remove do_rt_sigreturn since it's linux only. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/qemu.h | 3 +-- bsd-user/signal.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 011fdfebbaa..b8c64ca0e5b 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -219,14 +219,13 @@ extern int do_strace; /* signal.c */ void process_pending_signals(CPUArchState *cpu_env); void signal_init(void); -long do_sigreturn(CPUArchState *env); -long do_rt_sigreturn(CPUArchState *env); void queue_signal(CPUArchState *env, int sig, target_siginfo_t *info); abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp); int target_to_host_signal(int sig); int host_to_target_signal(int sig); void host_to_target_sigset(target_sigset_t *d, const sigset_t *s); void target_to_host_sigset(sigset_t *d, const target_sigset_t *s); +long do_sigreturn(CPUArchState *regs, abi_ulong addr); void QEMU_NORETURN force_sig(int target_sig); int qemu_sigorset(sigset_t *dest, const sigset_t *left, const sigset_t *ri= ght); =20 diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 1dd6dbb4ee1..d11f5eddd7e 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -640,6 +640,62 @@ give_sigsegv: force_sig(TARGET_SIGSEGV); } =20 +static int reset_signal_mask(target_ucontext_t *ucontext) +{ + int i; + sigset_t blocked; + target_sigset_t target_set; + TaskState *ts =3D (TaskState *)thread_cpu->opaque; + + for (i =3D 0; i < TARGET_NSIG_WORDS; i++) + if (__get_user(target_set.__bits[i], + &ucontext->uc_sigmask.__bits[i])) { + return -TARGET_EFAULT; + } + target_to_host_sigset_internal(&blocked, &target_set); + ts->signal_mask =3D blocked; + sigprocmask(SIG_SETMASK, &ts->signal_mask, NULL); + + return 0; +} + +long do_sigreturn(CPUArchState *regs, abi_ulong addr) +{ + long ret; + abi_ulong target_ucontext; + target_ucontext_t *ucontext =3D NULL; + + /* Get the target ucontext address from the stack frame */ + ret =3D get_ucontext_sigreturn(regs, addr, &target_ucontext); + if (is_error(ret)) { + return ret; + } + trace_user_do_sigreturn(regs, addr); + if (!lock_user_struct(VERIFY_READ, ucontext, target_ucontext, 0)) { + goto badframe; + } + + /* Set the register state back to before the signal. */ + if (set_mcontext(regs, &ucontext->uc_mcontext, 1)) { + goto badframe; + } + + /* And reset the signal mask. */ + if (reset_signal_mask(ucontext)) { + goto badframe; + } + + unlock_user_struct(ucontext, target_ucontext, 0); + return -TARGET_EJUSTRETURN; + +badframe: + if (ucontext !=3D NULL) { + unlock_user_struct(ucontext, target_ucontext, 0); + } + force_sig(TARGET_SIGSEGV); + return -TARGET_EFAULT; +} + void signal_init(void) { TaskState *ts =3D (TaskState *)thread_cpu->opaque; --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641745870446872.783845137751; Sun, 9 Jan 2022 08:31:10 -0800 (PST) Received: from localhost ([::1]:52200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6b64-0000G2-G8 for importer@patchew.org; Sun, 09 Jan 2022 11:31:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avJ-0006AV-My for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:20:02 -0500 Received: from [2607:f8b0:4864:20::12f] (port=45602 helo=mail-il1-x12f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6avH-0007BI-W5 for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:20:01 -0500 Received: by mail-il1-x12f.google.com with SMTP id h5so971121ilq.12 for ; Sun, 09 Jan 2022 08:19:59 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c6borLsFCV/9M2I8djvoBUxpRCi7Ch9JmdF3mHscVAw=; b=BuOTztHmPCAopAalk0n6uAVAauYXfnPkr50Ds9769GLM0jDG3Glgc2P2x1rd7YLauu z6CJDdqtwNU02EFCMIndFeIXUJJX+0Bu03Xx6Yd0ARWclHwoZUmMCs/TGm8IM3LtAuJT BCxZTao6IyDRzukVJUKL6GB8AAABdP1L7Z3Kz1qpK3yTj2qKqLxkiqvyOxPrjMDoKy9S hjcObj9pZ+V84x5XsnrED1t0eyvwPtnkZtw08N2cMAre5r5ExqAiRy6rJtMrf22UoDcP ZmqJMvjav4eVlVNpGIBHqFEDeC7zWgKF4owcMRWcAFHJR5JfrF2qGks0ulwg4VvYr4bu Vlnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c6borLsFCV/9M2I8djvoBUxpRCi7Ch9JmdF3mHscVAw=; b=PDU5q51hkgnrECqVBO4VVjWMKT3xTkhNVq6T+/lm4Nk5fLMI0ppt1JJCQDHxZSCH4A C9xPSQfUjgY7EumV3TlcBFCtXSEEFaoFqOSKs+khYgYmODPXaVNZlAKUhHWdS70etm+/ HZpACxdzLcYy+MkTLKIMwXvd9pgp84c98BsdgovCXt97Uk5rtfLwTG74f0ITcHlPCy3t uruxsUNJFAT96VdIMILglBc0o/VgriLqHCBslb/t00v85OacRarsZCW7MlHzV4lxu/HM XXI3dz6WRvwPxLyZzhvDSJL5mODJtFLNTRTZJXSEkvYN/ytreUs06LUPeTtGIOhq/pzH kfCQ== X-Gm-Message-State: AOAM53231rX1vCeHaR6zsi66P7RLwD6v8n0zf9GW+hqo86PtJn9QGZ/S xUXlKzmid9h5wDBNEOSazqOFTX8D3OU84fzd X-Google-Smtp-Source: ABdhPJzlLY5OsYrWB+d+0uwVeawSuEcK8hVY6BYhGNnzPIzL5W+dAtOmQTktZ8ZingIxWTZzJVyXuw== X-Received: by 2002:a05:6e02:2189:: with SMTP id j9mr34162505ila.264.1641745198800; Sun, 09 Jan 2022 08:19:58 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 29/30] bsd-user/signal.c: implement do_sigaction Date: Sun, 9 Jan 2022 09:19:22 -0700 Message-Id: <20220109161923.85683-30-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12f (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12f; envelope-from=imp@bsdimp.com; helo=mail-il1-x12f.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641745871164100001 Content-Type: text/plain; charset="utf-8" Implement the meat of the sigaction(2) system call with do_sigaction and helper routiner block_signals (which is also used to implemement signal masking so it's global). Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/qemu.h | 21 +++++++++++++ bsd-user/signal.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index b8c64ca0e5b..c643d6ba246 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -226,8 +226,29 @@ int host_to_target_signal(int sig); void host_to_target_sigset(target_sigset_t *d, const sigset_t *s); void target_to_host_sigset(sigset_t *d, const target_sigset_t *s); long do_sigreturn(CPUArchState *regs, abi_ulong addr); +int do_sigaction(int sig, const struct target_sigaction *act, + struct target_sigaction *oact); void QEMU_NORETURN force_sig(int target_sig); int qemu_sigorset(sigset_t *dest, const sigset_t *left, const sigset_t *ri= ght); +/** + * block_signals: block all signals while handling this guest syscall + * + * Block all signals, and arrange that the signal mask is returned to + * its correct value for the guest before we resume execution of guest cod= e. + * If this function returns non-zero, then the caller should immediately + * return -TARGET_ERESTARTSYS to the main loop, which will take the pending + * signal and restart execution of the syscall. + * If block_signals() returns zero, then the caller can continue with + * emulation of the system call knowing that no signals can be taken + * (and therefore that no race conditions will result). + * This should only be called once, because if it is called a second time + * it will always return non-zero. (Think of it like a mutex that can't + * be recursively locked.) + * Signals will be unblocked again by process_pending_signals(). + * + * Return value: non-zero if there was a pending signal, zero if not. + */ +int block_signals(void); /* Returns non zero if signal pending */ =20 /* mmap.c */ int target_mprotect(abi_ulong start, abi_ulong len, int prot); diff --git a/bsd-user/signal.c b/bsd-user/signal.c index d11f5eddd7e..f055d1db407 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -231,6 +231,22 @@ static void tswap_siginfo(target_siginfo_t *tinfo, con= st target_siginfo_t *info) } } =20 +int block_signals(void) +{ + TaskState *ts =3D (TaskState *)thread_cpu->opaque; + sigset_t set; + + /* + * It's OK to block everything including SIGSEGV, because we won't run= any + * further guest code before unblocking signals in + * process_pending_signals(). + */ + sigfillset(&set); + sigprocmask(SIG_SETMASK, &set, 0); + + return qatomic_xchg(&ts->signal_pending, 1); +} + /* Returns 1 if given signal should dump core if not handled. */ static int core_dump_signal(int sig) { @@ -534,6 +550,66 @@ static int fatal_signal(int sig) } } =20 +/* do_sigaction() return host values and errnos */ +int do_sigaction(int sig, const struct target_sigaction *act, + struct target_sigaction *oact) +{ + struct target_sigaction *k; + struct sigaction act1; + int host_sig; + int ret =3D 0; + + if (sig < 1 || sig > TARGET_NSIG || TARGET_SIGKILL =3D=3D sig || + TARGET_SIGSTOP =3D=3D sig) { + return -EINVAL; + } + + if (block_signals()) { + return -TARGET_ERESTART; + } + + k =3D &sigact_table[sig - 1]; + if (oact) { + oact->_sa_handler =3D tswapal(k->_sa_handler); + oact->sa_flags =3D tswap32(k->sa_flags); + oact->sa_mask =3D k->sa_mask; + } + if (act) { + /* XXX: this is most likely not threadsafe. */ + k->_sa_handler =3D tswapal(act->_sa_handler); + k->sa_flags =3D tswap32(act->sa_flags); + k->sa_mask =3D act->sa_mask; + + /* Update the host signal state. */ + host_sig =3D target_to_host_signal(sig); + if (host_sig !=3D SIGSEGV && host_sig !=3D SIGBUS) { + memset(&act1, 0, sizeof(struct sigaction)); + sigfillset(&act1.sa_mask); + act1.sa_flags =3D SA_SIGINFO; + if (k->sa_flags & TARGET_SA_RESTART) { + act1.sa_flags |=3D SA_RESTART; + } + /* + * Note: It is important to update the host kernel signal mas= k to + * avoid getting unexpected interrupted system calls. + */ + if (k->_sa_handler =3D=3D TARGET_SIG_IGN) { + act1.sa_sigaction =3D (void *)SIG_IGN; + } else if (k->_sa_handler =3D=3D TARGET_SIG_DFL) { + if (fatal_signal(sig)) { + act1.sa_sigaction =3D host_signal_handler; + } else { + act1.sa_sigaction =3D (void *)SIG_DFL; + } + } else { + act1.sa_sigaction =3D host_signal_handler; + } + ret =3D sigaction(host_sig, &act1, NULL); + } + } + return ret; +} + static inline abi_ulong get_sigframe(struct target_sigaction *ka, CPUArchState *regs, size_t frame_size) { --=20 2.33.1 From nobody Fri May 3 14:53:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641748033045816.1452051108321; Sun, 9 Jan 2022 09:07:13 -0800 (PST) Received: from localhost ([::1]:49678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n6bex-0005Sg-LE for importer@patchew.org; Sun, 09 Jan 2022 12:07:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n6avK-0006Ai-Cc for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:20:02 -0500 Received: from [2607:f8b0:4864:20::12c] (port=43638 helo=mail-il1-x12c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n6avI-0007BS-Rj for qemu-devel@nongnu.org; Sun, 09 Jan 2022 11:20:02 -0500 Received: by mail-il1-x12c.google.com with SMTP id d3so9260242ilr.10 for ; Sun, 09 Jan 2022 08:20:00 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id u10sm2683386ilq.76.2022.01.09.08.19.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jan 2022 08:19:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mc4CUh2gJxot/MQaLDy06nT8Q11jcB6ohTSNqNi0sPk=; b=c2mppuBHEt8e/Uf9TuWnL2f16aAw5kcQEkTXrGn0im1ASCNfAD4LWChmBCCqKU11c5 qtHxrmMAFxmtUm6FNTSBGth8qCOfJUlTtLEl2ViUxxVfwqf/H0vyLXUDeS9eZch5AtcK 2LK3gHruOaLp42D6YFSGNJ5IXyHXPo3gl3R1XntRDpkFGeGI3WcyE12BRPL6dK7P8Upj vbVmPyLotinR9XIGPNpNtWaTt3CDSmJb69L2qnZnmRRtVQiiXhB2jMCBx/QhpKfi2nkv xhEQ+vfPzkUuVBvkrZyVAx47fu3irRtak154q/1Vgmxf0DRdPEzer0wkpgigibepsan7 IqHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mc4CUh2gJxot/MQaLDy06nT8Q11jcB6ohTSNqNi0sPk=; b=65uhCkHG44K0dZrxDcKtVDr6XMNz8vsJM4vPubtpYHyrvri35GXZqMUKQ/IgeUc1ve HzsdeOikVBCcxG6YoeHCy3NXPfje1jLTOgRGvetZFBQy+Q6vDc/TGMWlogtqqaKTOKyN rfuuULLPhKaE98Bq8rGi2yqWgM/xfUzyDdGp1wP4n/ccymtksSJcCh3yle1l8e/xyzT9 LMDcs1o/9IbZ39XXe5IfACd4q9rN+KvPc9WSzwULqxXXUsEDgDHEu7WBEgcNdtVpYvQ1 IJtN2LgmlcQcoLY2BROh1PEoPRwyHervwtMqW7uHVvLM1CxPuw4GP0Bnd1u17rOCbls4 1M3w== X-Gm-Message-State: AOAM531A5o2ii6K4cYofGxD4YSRiLseCz9GFTOaXWoXevYnARIhujvVJ bZBWGDBF5Zj11GPL/vphHUw2Gq5+ajS6UXQZ X-Google-Smtp-Source: ABdhPJzOdyDcBA7+X3OSEXZNnoQwBXSy4MZn6IBaGg+K0nPQB8uiHkNg+C3+ucMLA5b3JetahoBHdg== X-Received: by 2002:a92:cc92:: with SMTP id x18mr8851996ilo.196.1641745199660; Sun, 09 Jan 2022 08:19:59 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH 30/30] bsd-user/signal.c: do_sigaltstack Date: Sun, 9 Jan 2022 09:19:23 -0700 Message-Id: <20220109161923.85683-31-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220109161923.85683-1-imp@bsdimp.com> References: <20220109161923.85683-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12c (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12c; envelope-from=imp@bsdimp.com; helo=mail-il1-x12c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no 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: , Cc: Kyle Evans , Stacey Son , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1641748033685100001 Content-Type: text/plain; charset="utf-8" Implement the meat of the sigaltstack(2) system call with do_sigaltstack. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh --- bsd-user/qemu.h | 1 + bsd-user/signal.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index c643d6ba246..fcdea460ed2 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -226,6 +226,7 @@ int host_to_target_signal(int sig); void host_to_target_sigset(target_sigset_t *d, const sigset_t *s); void target_to_host_sigset(sigset_t *d, const target_sigset_t *s); long do_sigreturn(CPUArchState *regs, abi_ulong addr); +abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp); int do_sigaction(int sig, const struct target_sigaction *act, struct target_sigaction *oact); void QEMU_NORETURN force_sig(int target_sig); diff --git a/bsd-user/signal.c b/bsd-user/signal.c index f055d1db407..e5e5e28c60c 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -528,6 +528,72 @@ static void host_signal_handler(int host_sig, siginfo_= t *info, void *puc) cpu_exit(thread_cpu); } =20 +/* do_sigaltstack() returns target values and errnos. */ +/* compare to kern/kern_sig.c sys_sigaltstack() and kern_sigaltstack() */ +abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp) +{ + int ret; + target_stack_t oss; + + if (uoss_addr) { + /* Save current signal stack params */ + oss.ss_sp =3D tswapl(target_sigaltstack_used.ss_sp); + oss.ss_size =3D tswapl(target_sigaltstack_used.ss_size); + oss.ss_flags =3D tswapl(sas_ss_flags(sp)); + } + + if (uss_addr) { + target_stack_t *uss; + target_stack_t ss; + size_t minstacksize =3D TARGET_MINSIGSTKSZ; + + ret =3D -TARGET_EFAULT; + if (!lock_user_struct(VERIFY_READ, uss, uss_addr, 1)) { + goto out; + } + __get_user(ss.ss_sp, &uss->ss_sp); + __get_user(ss.ss_size, &uss->ss_size); + __get_user(ss.ss_flags, &uss->ss_flags); + unlock_user_struct(uss, uss_addr, 0); + + ret =3D -TARGET_EPERM; + if (on_sig_stack(sp)) { + goto out; + } + + ret =3D -TARGET_EINVAL; + if (ss.ss_flags !=3D TARGET_SS_DISABLE + && ss.ss_flags !=3D TARGET_SS_ONSTACK + && ss.ss_flags !=3D 0) { + goto out; + } + + if (ss.ss_flags =3D=3D TARGET_SS_DISABLE) { + ss.ss_size =3D 0; + ss.ss_sp =3D 0; + } else { + ret =3D -TARGET_ENOMEM; + if (ss.ss_size < minstacksize) { + goto out; + } + } + + target_sigaltstack_used.ss_sp =3D ss.ss_sp; + target_sigaltstack_used.ss_size =3D ss.ss_size; + } + + if (uoss_addr) { + ret =3D -TARGET_EFAULT; + if (copy_to_user(uoss_addr, &oss, sizeof(oss))) { + goto out; + } + } + + ret =3D 0; +out: + return ret; +} + static int fatal_signal(int sig) { =20 --=20 2.33.1