From nobody Thu May 2 08:44:36 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 1643074445471334.19752825361047; Mon, 24 Jan 2022 17:34:05 -0800 (PST) Received: from localhost ([::1]:46308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAih-0004fg-M4 for importer@patchew.org; Mon, 24 Jan 2022 20:34:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAej-0001fS-C0 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:29:57 -0500 Received: from [2607:f8b0:4864:20::131] (port=37452 helo=mail-il1-x131.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAeh-0001KP-Np for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:29:57 -0500 Received: by mail-il1-x131.google.com with SMTP id z4so363277ilz.4 for ; Mon, 24 Jan 2022 17:29: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 q14sm2061687ilo.63.2022.01.24.17.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:29: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=mJ0ggAZ5G2KuobyUQ2EAEWVzlqR8jmiWD0n6bcTFpIM=; b=KYcKjJkcc1KpDIpU4C2f2H7XhRb0+UEs4BoYDnned9xSJMAyDlanZhUHydkDtDAU4O J7rVFYUzC3iMFzlAzqaSgNHShwybmQBvhujj+4FgTJLFto0/TnJlSnzk6dNz2XNBzGtU p8DilNs5EDet0/KjKMQd+QyTkpv16U0+FmJgmLjLhggzK/KiEXy6GLcbNaMIqvUgbFYb EdRezLR9dyeM/IWTh7iC5HPh4lEQ157csyBvDXPlERu3F7JBjBn6Tat7nHVwBECks3/C 0AoAdkW8YCIJ0q3L/sCIHf3JbFqWAXPynquXe7YOCz2DKJNLbKJHZ6euho97iD9yaj+r +3IA== 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=mJ0ggAZ5G2KuobyUQ2EAEWVzlqR8jmiWD0n6bcTFpIM=; b=Z/Td/OsDS2ur3XcafNO/nGcAtaR5Hnd2tPYCK2gjPd95LjQJZFGdQ4VuVqxienF+uo QlIQHqqudW4NtYVyF5xP59+x/8QhabZOMvZz0QKurJg5SpCW+tHIIku5RZ8ogKjqQfjH I/LLjGvij/RrnbmErk5pOFgyDfrlEFZ7/whCKPvor6vKhZsZzY9PfenGnnXlYi7LXr2N MilJ7s2VaW0XeXwFTamfhsYHi11C2umyuCNQXX+nFUNWg9VAJUQbuRr6AagtmhEeR12y Uuw7fPoasHnYVKV5vi2Vu4ajnMWLRdMYKzLEMuxrIBMMHzO5pGJEwngHQhlmjN0AXX4y MFFA== X-Gm-Message-State: AOAM531MsN1nMT6D6i02iDRkOrgzdkerCT8RnOoIW75spNubBs6t/GBb z5llmXXmZaeZU2U8rgNexqOvcJJKlSKYgw== X-Google-Smtp-Source: ABdhPJxxG6rqek7ddhvF2sLFYf7eQWqnbByrATwjbYDu8oJOa3Nb3nlhmjf/rLivGN/9E52qQYf2jA== X-Received: by 2002:a92:d74a:: with SMTP id e10mr10114209ilq.268.1643074194091; Mon, 24 Jan 2022 17:29:54 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 01/40] bsd-user: Complete FreeBSD siginfo Date: Mon, 24 Jan 2022 18:29:08 -0700 Message-Id: <20220125012947.14974-2-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::131 (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::131; envelope-from=imp@bsdimp.com; helo=mail-il1-x131.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643074448914100001 Content-Type: text/plain; charset="utf-8" Fill in the missing FreeBSD siginfo fields, and add some comments. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/target_os_siginfo.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bsd-user/freebsd/target_os_siginfo.h b/bsd-user/freebsd/target= _os_siginfo.h index 84944faa4d3..d50a3034a88 100644 --- a/bsd-user/freebsd/target_os_siginfo.h +++ b/bsd-user/freebsd/target_os_siginfo.h @@ -71,11 +71,24 @@ typedef struct target_siginfo { int32_t _mqd; } _mesgp; =20 - /* SIGPOLL */ + /* SIGPOLL -- Not really genreated in FreeBSD ??? */ struct { int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ } _poll; =20 + struct { + int _mqd; + } _mesgq; + + struct { + /* + * Syscall number for signals delivered as a result of system = calls + * denied by Capsicum. + */ + int _syscall; + } _capsicum; + + /* Spare for future growth */ struct { abi_long __spare1__; int32_t __spare2_[7]; --=20 2.33.1 From nobody Thu May 2 08:44:36 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 164307492178825.18689975922439; Mon, 24 Jan 2022 17:42:01 -0800 (PST) Received: from localhost ([::1]:55028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAqO-0002L8-Jh for importer@patchew.org; Mon, 24 Jan 2022 20:42:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAek-0001iE-KW for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:29:58 -0500 Received: from [2607:f8b0:4864:20::d2d] (port=46735 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 1nCAei-0001KT-9k for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:29:58 -0500 Received: by mail-io1-xd2d.google.com with SMTP id e79so21848863iof.13 for ; Mon, 24 Jan 2022 17:29: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 q14sm2061687ilo.63.2022.01.24.17.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:29: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=eLMMLGn5PlEMmATCOZX5ewFX0bdTWxFb8sG6Cl9Zh90=; b=fyZp1PcQdFyP0fwjRM4b1lnL46PH6FqfifOva+maIyvxdD8VD4U5M06RMqhjJNIwzA t60KtmXlD91EzSpo9ClvxjX8Z0d7fgHWJfBgJdi835MD5LMWQ7NW/mgb38MTnUiPN89Y txqFItbadCZBX8WBPNhF3obqzhu5bXiYPFs+aNUyrco4I1O4p2CcOcRA8k1EW5v/UUcm UnF5lXacTKq2KxpjYT/0R1+AI1snhZVNOukGgUSCVR2KYa7FBTWDaMRXsy43ASNuU/Q0 WdrKcscl7g0EvaKPVnRLBkeiP+FQQLLtqDS6XhVLCF0vbly88xSSLx+dqtvSQUXuTlyc PUgg== 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=eLMMLGn5PlEMmATCOZX5ewFX0bdTWxFb8sG6Cl9Zh90=; b=Wap5OsZMdbr3JetUgBu/dKwUpFWvKuSVAbrZ9UBQumOKbR4i0IYOOwmRxjR7cAkZdy g/waMWl+Lds0VI+YghplNZnAdLOCXcM2rW2XL/9JQnnQ0vN488BlyQe5Ylg0MXHervIR JgEymNKLM7d6mG5YxZjgXhkPUE4Gc705Uawmkn7xki2WohHndb3ZFN43RwMxYASRAVZf ZWVSk6z0XvgPeMkqVYNBxJqHdmqsrr2M2bv0SaFYeZ7EWobbTMwUGdtl1GXyTpsP4E4u L1I5Pz6AF/QFIop/JhXOu2YuFSMdjfwl01dFzQSSqg6WD9xpAlTAH/Ml6c1txQ9RVQag 6o7Q== X-Gm-Message-State: AOAM533heeFY+B6BVFXglKWzZu6TgDNKBRpd3FhQ7n22T2v5ZvGp7u8v KnRgt2RlSRtLLt2VjxBTiZ47GqucoqP2EQ== X-Google-Smtp-Source: ABdhPJyUim9Mw7erIwl6+IQaOA3YtyPNxUEC0lfFT2dA6fQ2XoqTRcdEtAjgy91KPa3FFgJF1lY5xw== X-Received: by 2002:a02:1d07:: with SMTP id 7mr1779385jaj.154.1643074195067; Mon, 24 Jan 2022 17:29:55 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 02/40] bsd-user: Create setup_sigframe_arch to setup sigframe context Date: Mon, 24 Jan 2022 18:29:09 -0700 Message-Id: <20220125012947.14974-3-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643074924312100001 Content-Type: text/plain; charset="utf-8" Define setup_sigframe_arch whose job it is to setup the mcontext for the sigframe. Implement for x86 to just call mcontext. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/target_os_signal.h | 3 +++ bsd-user/i386/signal.c | 13 +++++++++++++ bsd-user/x86_64/signal.c | 13 +++++++++++++ 3 files changed, 29 insertions(+) diff --git a/bsd-user/freebsd/target_os_signal.h b/bsd-user/freebsd/target_= os_signal.h index 3ed454e086d..7491629477a 100644 --- a/bsd-user/freebsd/target_os_signal.h +++ b/bsd-user/freebsd/target_os_signal.h @@ -4,6 +4,9 @@ #include "target_os_siginfo.h" #include "target_arch_signal.h" =20 +abi_long setup_sigframe_arch(CPUArchState *regs, abi_ulong frame_addr, + struct target_sigframe *frame, int flags); + /* Compare to sys/signal.h */ #define TARGET_SIGHUP 1 /* hangup */ #define TARGET_SIGINT 2 /* interrupt */ diff --git a/bsd-user/i386/signal.c b/bsd-user/i386/signal.c index 2939d32400c..5dd975ce56a 100644 --- a/bsd-user/i386/signal.c +++ b/bsd-user/i386/signal.c @@ -32,6 +32,19 @@ abi_long set_sigtramp_args(CPUX86State *env, int sig, return 0; } =20 +/* + * Compare to i386/i386/exec_machdep.c sendsig() + * Assumes that the memory is locked if frame points to user memory. + */ +abi_long setup_sigframe_arch(CPUX86State *env, abi_ulong frame_addr, + struct target_sigframe *frame, int flags) +{ + target_mcontext_t *mcp =3D &frame->sf_uc.uc_mcontext; + + get_mcontext(env, mcp, flags); + return 0; +} + /* Compare to i386/i386/machdep.c get_mcontext() */ abi_long get_mcontext(CPUX86State *regs, target_mcontext_t *mcp, int flags) { diff --git a/bsd-user/x86_64/signal.c b/bsd-user/x86_64/signal.c index 8885152a7da..c3875bc4c6a 100644 --- a/bsd-user/x86_64/signal.c +++ b/bsd-user/x86_64/signal.c @@ -30,6 +30,19 @@ abi_long set_sigtramp_args(CPUX86State *regs, return 0; } =20 +/* + * Compare to amd64/amd64/exec_machdep.c sendsig() + * Assumes that the memory is locked if frame points to user memory. + */ +abi_long setup_sigframe_arch(CPUX86State *env, abi_ulong frame_addr, + struct target_sigframe *frame, int flags) +{ + target_mcontext_t *mcp =3D &frame->sf_uc.uc_mcontext; + + get_mcontext(env, mcp, flags); + return 0; +} + /* Compare to amd64/amd64/machdep.c get_mcontext() */ abi_long get_mcontext(CPUX86State *regs, target_mcontext_t *mcp, int flags) --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643075050490571.1415145404109; Mon, 24 Jan 2022 17:44:10 -0800 (PST) Received: from localhost ([::1]:57668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAsT-00045l-Lc for importer@patchew.org; Mon, 24 Jan 2022 20:44:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAek-0001j0-S2 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:29:58 -0500 Received: from [2607:f8b0:4864:20::134] (port=44595 helo=mail-il1-x134.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAej-0001KX-1a for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:29:58 -0500 Received: by mail-il1-x134.google.com with SMTP id i14so15512199ila.11 for ; Mon, 24 Jan 2022 17:29: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 q14sm2061687ilo.63.2022.01.24.17.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:29: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=QLlVji/Hrm3v4RO/pA+fXtXBOTfzZIpOWxrvHKyxFYs=; b=eWTcYnuDCqy1gf040EQWZK2UtWelRb0uOXJ7TwH+wYyC1h3Khla9QAK0vpMUphse4E KwxdjOo4mmEV2xC1cbAcKuunBAVKhuJN2LCY4SWbwhdh6zqHsbOGOgbJ6Mztzz1oQ2a8 zAFu5b+TEI/OVLVF7yF/pU5bB41AuB4wdEuC6h+BfMwUj9dx4dxQz0GKDAcR33+CK8BR HxGRRm/kxMqeAGs5rVZRHYUsfjyaLZgZPtiIyu+R8+HKzFQdvjztkI7x3yiFegcaUEcY G8cRljRf/0n2jsssuiKO4gtAjACmvB51CGvJx2ytg5HrWWIPKQRi9sUY4dpaUEjT2oFm bUww== 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=QLlVji/Hrm3v4RO/pA+fXtXBOTfzZIpOWxrvHKyxFYs=; b=HbBev5s8qmZPJO/IXlovU8y1g9vLGIZPfZYr+voOIrsPYCHQSU3gPXBoDlI9B+5ND0 von2fLwFeRA3U2NJ1Zf9ROfMuul7e0UNbUmaUnOwf4y9dGlkAtf9H7wK6et/Z7sQmaQ5 nAaJfshjLXRyKrsh+X0xU24P0uw1id17Ed/qT/8uYxDKsEcIHkQcCT3tNmVgcCMcrwys hYBZ1JNIO8Vn13xW1w8FZ4WwgDikmeOi1+HYrQltDJ60L1kjeRIL8ZzI/d0Wz7OT9NlH ZM3D/smz/zMgyw7TsYXHtvJs/y7HGxVhiPBd25L7Hm5wB/MHe2DJGsozvRkKu0hFDd/e m2xw== X-Gm-Message-State: AOAM531FAuFbP/LBbtv7cx+g94PxJy+AUKgPJz/jzGMnqN4c5V4bTkR9 GpKULwmOYScSD/xNcxlLixZlOKs1oHsYdw== X-Google-Smtp-Source: ABdhPJyxkaicv9Kfh+SL74lhwmCc3+z/2cyhmjJ/8bFKr7IyIQv4ncQGWv1hnJ3ZxD1kMnWViuSVUw== X-Received: by 2002:a05:6e02:20ee:: with SMTP id q14mr10203513ilv.44.1643074195799; Mon, 24 Jan 2022 17:29:55 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 03/40] bsd-user/arm/signal.c: Implement setup_sigframe_arch for arm Date: Mon, 24 Jan 2022 18:29:10 -0700 Message-Id: <20220125012947.14974-4-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::134 (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::134; envelope-from=imp@bsdimp.com; helo=mail-il1-x134.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075052497100001 Content-Type: text/plain; charset="utf-8" Fix the broken context setting for arm. FreeBSD's get_mcontext does not fill in the vfp info. It's filled in in sigframe(). This corresponds to the new setup_sigframe_arch which fills in mcontext, then adjusts it to point to the vfp context in the sigframe and fills in that context as well. Add pointer to where this code is done. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/arm/signal.c | 50 +++++++++++++++++++---------- bsd-user/freebsd/target_os_signal.h | 2 +- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/bsd-user/arm/signal.c b/bsd-user/arm/signal.c index 1478f008d13..9026343b478 100644 --- a/bsd-user/arm/signal.c +++ b/bsd-user/arm/signal.c @@ -59,19 +59,31 @@ abi_long set_sigtramp_args(CPUARMState *env, int sig, return 0; } =20 +static abi_long get_vfpcontext(CPUARMState *env, abi_ulong frame_addr, + struct target_sigframe *frame) +{ + /* see sendsig and get_vfpcontext in sys/arm/arm/exec_machdep.c */ + target_mcontext_vfp_t *vfp =3D &frame->sf_vfp; + target_mcontext_t *mcp =3D &frame->sf_uc.uc_mcontext; + + /* Assumes that mcp and vfp are locked */ + for (int i =3D 0; i < 32; i++) { + vfp->mcv_reg[i] =3D tswap64(*aa32_vfp_dreg(env, i)); + } + vfp->mcv_fpscr =3D tswap32(vfp_get_fpscr(env)); + mcp->mc_vfp_size =3D tswap32(sizeof(*vfp)); + mcp->mc_vfp_ptr =3D tswap32(frame_addr + ((uintptr_t)vfp - (uintptr_t)= frame)); + return 0; +} + /* - * Compare to arm/arm/machdep.c get_mcontext() + * Compare to arm/arm/exec_machdep.c get_mcontext() * Assumes that the memory is locked if mcp points to user memory. */ abi_long get_mcontext(CPUARMState *env, target_mcontext_t *mcp, int flags) { - int err =3D 0; uint32_t *gr =3D mcp->__gregs; =20 - if (mcp->mc_vfp_size !=3D 0 && mcp->mc_vfp_size !=3D sizeof(target_mco= ntext_vfp_t)) { - return -TARGET_EINVAL; - } - gr[TARGET_REG_CPSR] =3D tswap32(cpsr_read(env)); if (flags & TARGET_MC_GET_CLEAR_RET) { gr[TARGET_REG_R0] =3D 0; @@ -97,17 +109,21 @@ abi_long get_mcontext(CPUARMState *env, target_mcontex= t_t *mcp, int flags) gr[TARGET_REG_LR] =3D tswap32(env->regs[14]); gr[TARGET_REG_PC] =3D tswap32(env->regs[15]); =20 - if (mcp->mc_vfp_size !=3D 0 && mcp->mc_vfp_ptr !=3D 0) { - /* see get_vfpcontext in sys/arm/arm/exec_machdep.c */ - target_mcontext_vfp_t *vfp; - vfp =3D lock_user(VERIFY_WRITE, mcp->mc_vfp_ptr, sizeof(*vfp), 0); - for (int i =3D 0; i < 32; i++) { - vfp->mcv_reg[i] =3D tswap64(*aa32_vfp_dreg(env, i)); - } - vfp->mcv_fpscr =3D tswap32(vfp_get_fpscr(env)); - unlock_user(vfp, mcp->mc_vfp_ptr, sizeof(*vfp)); - } - return err; + return 0; +} + +/* + * Compare to arm/arm/exec_machdep.c sendsig() + * Assumes that the memory is locked if frame points to user memory. + */ +abi_long setup_sigframe_arch(CPUARMState *env, abi_ulong frame_addr, + struct target_sigframe *frame, int flags) +{ + target_mcontext_t *mcp =3D &frame->sf_uc.uc_mcontext; + + get_mcontext(env, mcp, flags); + get_vfpcontext(env, frame_addr, frame); + return 0; } =20 /* Compare to arm/arm/exec_machdep.c set_mcontext() */ diff --git a/bsd-user/freebsd/target_os_signal.h b/bsd-user/freebsd/target_= os_signal.h index 7491629477a..43700d08f71 100644 --- a/bsd-user/freebsd/target_os_signal.h +++ b/bsd-user/freebsd/target_os_signal.h @@ -4,7 +4,7 @@ #include "target_os_siginfo.h" #include "target_arch_signal.h" =20 -abi_long setup_sigframe_arch(CPUArchState *regs, abi_ulong frame_addr, +abi_long setup_sigframe_arch(CPUArchState *env, abi_ulong frame_addr, struct target_sigframe *frame, int flags); =20 /* Compare to sys/signal.h */ --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643074449305130.36894936142835; Mon, 24 Jan 2022 17:34:09 -0800 (PST) Received: from localhost ([::1]:46524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAim-0004nu-BX for importer@patchew.org; Mon, 24 Jan 2022 20:34:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAem-0001lt-0k for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:00 -0500 Received: from [2607:f8b0:4864:20::d29] (port=33509 helo=mail-io1-xd29.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAek-0001Ko-C7 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:29:59 -0500 Received: by mail-io1-xd29.google.com with SMTP id y84so5491458iof.0 for ; Mon, 24 Jan 2022 17:29: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 q14sm2061687ilo.63.2022.01.24.17.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:29: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=GkYatV3ZgRqTPknoAin9rpPN5p7SZS/B/G0X4rcmyM8=; b=edUW7AeCsYWIwd9qLyg1cE9GrYuGKnogwD4lGQe0BHQ/knT78wxPOwrZcYrUELxj8G eQy9FtzKKN67h81CWY5pPyFy4xbMnzxtcqbFI2CZ0dUnvN9soPvbfyODW8c9su/V0LAA kRVx2QqRaOsNSda2x3StV6M4mM4VqBlT54Bj9St2qkU2BxARqP/gHF/2I0FwE/FbjwVe wntBr0PblKboJ45dtfqYIyvgtB5lEF4GRLPcNd08PQ9p2WR0W2SpNgVGnrO9AwWztEpq ibW4/qjZffRDgNAAoDWQpNxXUOJ/yobNMT697+c2ugtlwJDIQ5irhw1PWsByc/J/ohP6 zMag== 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=GkYatV3ZgRqTPknoAin9rpPN5p7SZS/B/G0X4rcmyM8=; b=3iUxAaAi/lmMifSepNEQrS/J2PA0TSqgN/F1IcVRoteytLKIRwv5lVGBicJ8AUDvHb e6RWDBnT0ImcLhWJr9pC4C+cgvHonYcXeagQzxibkSIpk9kEau4iBd+eiMLdN2ttnNJt L9eTB42Mh/4nXrWrBuafJ7inO5eHXOO6+pAZGztY0WIUibXLP+YXb5x05G5/f3dBl2Bq VIHHInaCuRkHf2qWYXVYYnBPH2WAHYR/BG9IRl470MD7T2eTBzzgu/Q2Hyo0y1AWYADb mGSQFWYM2UFrN9mJdV74IhPxck6vARXiQc4S7VX3ZzS+dkQlz/JCzFgqD42sIA2mO038 OuxQ== X-Gm-Message-State: AOAM5317GrXZVo/VFIzVqheOm1noSbByrImVnGTuUXGWOOOoyW2sg+C0 Y0dI1kTxFydtNlcxv0Z7yLLeph9/uOlpLA== X-Google-Smtp-Source: ABdhPJxIEIndr7G3SIvRtdEHY1/W4GMEpJo89teh6IULZsduL6/LSNsGoGRhtg1LtGRCpFDRSVIFAQ== X-Received: by 2002:a5d:9851:: with SMTP id p17mr9780784ios.85.1643074196955; Mon, 24 Jan 2022 17:29:56 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 04/40] bsd-user/arm/signal.c: get_mcontext should zero vfp data Date: Mon, 24 Jan 2022 18:29:11 -0700 Message-Id: <20220125012947.14974-5-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::d29 (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::d29; envelope-from=imp@bsdimp.com; helo=mail-io1-xd29.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643074450806100003 Content-Type: text/plain; charset="utf-8" FreeBSD's get_mcontext doesn't return any vfp data. Instead, it zeros out the vfp feilds (and all the spare fields). Impelement this behavior. We're still missing the sysarch(ARM_GET_VFPCONTEXT) syscall, though. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/arm/signal.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bsd-user/arm/signal.c b/bsd-user/arm/signal.c index 9026343b478..6eadc6e3c56 100644 --- a/bsd-user/arm/signal.c +++ b/bsd-user/arm/signal.c @@ -109,6 +109,14 @@ abi_long get_mcontext(CPUARMState *env, target_mcontex= t_t *mcp, int flags) gr[TARGET_REG_LR] =3D tswap32(env->regs[14]); gr[TARGET_REG_PC] =3D tswap32(env->regs[15]); =20 + /* + * FreeBSD's set_mcontext doesn't save VFP info, but blanks it out ins= tead. + * Instead, sysarch(ARM_GET_VFPSTATE) is used instead. + */ + mcp->mc_vfp_size =3D 0; + mcp->mc_vfp_ptr =3D 0; + memset(&mcp->mc_spare, 0, sizeof(mcp->mc_spare)); + return 0; } =20 --=20 2.33.1 From nobody Thu May 2 08:44:36 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 16430751916151.8966835464484575; Mon, 24 Jan 2022 17:46:31 -0800 (PST) Received: from localhost ([::1]:35220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAuk-0008BQ-Rg for importer@patchew.org; Mon, 24 Jan 2022 20:46:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAem-0001p4-Tz for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:00 -0500 Received: from [2607:f8b0:4864:20::12b] (port=46964 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 1nCAel-0001Kx-B6 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:00 -0500 Received: by mail-il1-x12b.google.com with SMTP id e8so15515355ilm.13 for ; Mon, 24 Jan 2022 17:29: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 q14sm2061687ilo.63.2022.01.24.17.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:29: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=4d3e+/an8YON2HYoyz+uLjT/Co+WU68pc6DpMLzJ0cI=; b=EVIGIR/yt4CI+w9D5jYNdFLjHhzMn+KQj6/wX729OGOf7b9x3VEjPlxeDGYhetFnz9 rvP03V6N1xN0l+yIE9FQvXdW+PGGAVIKFKnjbGnUWKAGfzeB2ty0g7HdS1s0b51kcugs i+dDyCD02H7I1q0i5cleNAN0CFTtWZfhLC2nHd7m4I8FVKnZkGjxvhjqaVTbWNRwjAvz AoFQ8NekvhvdwtzVnmYk9EdT/vd1KFJWjL0jSZsXS52ozeBktb2FVF2YM5+F0jFuWC2T w7mRORgPyzqsThNYGAtG7ZC3/9OQVDtxNP/RN6Xo58om75thUi3wX/T4/VSJX7duUnzn DqfQ== 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=4d3e+/an8YON2HYoyz+uLjT/Co+WU68pc6DpMLzJ0cI=; b=C2a3QrYH/icRcmoOUqz3rkIZrliWRAa7kwoyB86Xcipxu1JPS8+bBoRdd3K+zY/lYH idziC/0uubOhaz0ys46e1gTvdElRZklnlu3CJn1auGC/33OCzD/Rbk8cnRomXH5uKZZZ DG3iargKZAC2EkgKk1urBCuo05q7VCRY2q9sury6cCRCuCsf3Y2isztLuQ9HpJgWYEhD oH0QVP+yte+zli0J/x4qCi5kYAxI+HW56Xc4Z4UUz1NJK1eByj2wksilRYYJ6XaeOu/s vI+PXNT3vxS0R9FEwufyVw4HkRmERkQl5xi6g5hAJSa4FisalcYkSEixsKhyGWu3IRYd Zs3A== X-Gm-Message-State: AOAM530llQL97W4fTQV1mVIXyiK5CJJqPuiSZ/QZTdIo70QuhstQRDbm RNrD3RP/ZDjo8zlUK9rW/14ZQP8atAMR5A== X-Google-Smtp-Source: ABdhPJzmK3840VwvSN6fq98AolvPsIuSa1oxfcP8/4a5oICA6vhNZQIDyeAWpa34ygj6dnSIAyWXHg== X-Received: by 2002:a05:6e02:b44:: with SMTP id f4mr9993254ilu.125.1643074197800; Mon, 24 Jan 2022 17:29:57 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 05/40] bsd-user: Remove vestiges of signal queueing code Date: Mon, 24 Jan 2022 18:29:12 -0700 Message-Id: <20220125012947.14974-6-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075194458100001 Content-Type: text/plain; charset="utf-8" bsd-user was copied from linux-user at a time when it queued signals. Remove those vestiges of thse code. Retain the init function, even though it's now empty since other stuff will likely be added there. Make it static since it's not called from outside of main.c Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/main.c | 9 +-------- bsd-user/qemu.h | 13 +------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index cb5ea402361..29cf4e15693 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -215,15 +215,8 @@ void qemu_cpu_kick(CPUState *cpu) } =20 /* Assumes contents are already zeroed. */ -void init_task_state(TaskState *ts) +static void init_task_state(TaskState *ts) { - int i; - - ts->first_free =3D ts->sigqueue_table; - for (i =3D 0; i < MAX_SIGQUEUE_SIZE - 1; i++) { - ts->sigqueue_table[i].next =3D &ts->sigqueue_table[i + 1]; - } - ts->sigqueue_table[i].next =3D NULL; } =20 void gemu_log(const char *fmt, ...) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 1b3b974afe9..4dd209e402d 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -70,17 +70,9 @@ struct image_info { uint32_t elf_flags; }; =20 -#define MAX_SIGQUEUE_SIZE 1024 - -struct qemu_sigqueue { - struct qemu_sigqueue *next; - target_siginfo_t info; -}; - struct emulated_sigtable { int pending; /* true if signal is pending */ - struct qemu_sigqueue *first; - struct qemu_sigqueue info; /* Put first signal info here */ + target_siginfo_t info; }; =20 /* @@ -94,14 +86,11 @@ typedef struct TaskState { struct image_info *info; =20 struct emulated_sigtable sigtab[TARGET_NSIG]; - 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 */ =20 uint8_t stack[]; } __attribute__((aligned(16))) TaskState; =20 -void init_task_state(TaskState *ts); void stop_all_tasks(void); extern const char *qemu_uname_release; =20 --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643074923036213.18001021687587; Mon, 24 Jan 2022 17:42:03 -0800 (PST) Received: from localhost ([::1]:55234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAqQ-0002Ti-6S for importer@patchew.org; Mon, 24 Jan 2022 20:42:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAen-0001r3-Hx for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:01 -0500 Received: from [2607:f8b0:4864:20::d32] (port=43957 helo=mail-io1-xd32.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAel-0001LA-Ur for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:01 -0500 Received: by mail-io1-xd32.google.com with SMTP id z199so7381829iof.10 for ; Mon, 24 Jan 2022 17:29: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 q14sm2061687ilo.63.2022.01.24.17.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:29: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=isDrZY482S3xfWT+5+PbxzFl8WVxw/V/ZKa7flzM0e0=; b=PKxlAmj2ihfQaeajGExa3WrJCJuKYJkmU2CcOktnQQJm+u3jp8WyJmmS24oU3W78WC 324f4oneDSpjF3Us5nG+3RweveeScX9fsIZgTZ36CZPv1gic6qc3qm0kNgCr8s+cN8KG 7vkQJSEht43QZFd1KqbXRF8jO6gOuuBrhoyHMQG1kdrOzIUqvaS9dl7XgAOmwtwpvUgq Sr/v43FY8NCly8zVxROwbIX6fEx15339WIi2POp7HETPz6brd2C+cnyAaPbrIeWMKoQR xb/Er6Pd98Go/HAUXZtcCNBfs42GLZB/KJ4DJ4PuTavas+mnAoQHuf0on/rLzNNsBeUE fB/Q== 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=isDrZY482S3xfWT+5+PbxzFl8WVxw/V/ZKa7flzM0e0=; b=PEO6vdnHMF+RRpq5r8M3Bh997ZakyielABzDmdKnsr88NhxiKXflRiwDf3ngninx3e sDUXrwJKOCZVL3C5IYRkTETKi4QiflYi6LoCu0ZonyLP9nR8RT1TYNLIUJhsqGgeCGpH +ShrTzQxJAFRRpPncU0dpF4MZ+TlYxEe/zbX32Jr8mv8Fn7XFXE4tUcy0+aMA17LCEqW y83Rla8HrvN+9BMuWFltS+HpKdlPafaAu/sWc1fzNvEa2n9nnUJCKgH26CEg3DeYqY6g VWYdDb41M+o+H6glRkk5Q0rin1w7YcZ60LiXVLjVU7XAWJosZrWfNGc7P9eyHLPoWHON fa3w== X-Gm-Message-State: AOAM530afjnnRWbpdROYMnlKmy7f94T4pedYaWgniHIy0kYbFziH940x V2xOsplF1U+TaCd57FBTMlvUC5UXW6PY5w== X-Google-Smtp-Source: ABdhPJzNdWACEfoYyAQ4kAaQlJUMl8jPWPk8NOSmHf/fxjlpRySFv9x16/z7fX66pHcQ+L3XGHxYmQ== X-Received: by 2002:a5d:8b82:: with SMTP id p2mr9436168iol.214.1643074198745; Mon, 24 Jan 2022 17:29:58 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 06/40] bsd-user: Bring in docs from linux-user for signal_pending Date: Mon, 24 Jan 2022 18:29:13 -0700 Message-Id: <20220125012947.14974-7-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::d32 (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::d32; envelope-from=imp@bsdimp.com; helo=mail-io1-xd32.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643074924735100003 Content-Type: text/plain; charset="utf-8" This is currently unused, so no code adjustments are needed. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/qemu.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 4dd209e402d..671b26f00cc 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -86,7 +86,14 @@ typedef struct TaskState { struct image_info *info; =20 struct emulated_sigtable sigtab[TARGET_NSIG]; - int signal_pending; /* non zero if a signal may be pending */ + /* + * Nonzero if process_pending_signals() needs to do something (either + * handle a pending signal or unblock signals). + * This flag is written from a signal handler so should be accessed via + * the qatomic_read() and qatomic_set() functions. (It is not accessed + * from multiple threads.) + */ + int signal_pending; =20 uint8_t stack[]; } __attribute__((aligned(16))) TaskState; --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643074454498126.353868422593; Mon, 24 Jan 2022 17:34:14 -0800 (PST) Received: from localhost ([::1]:46734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAir-0004wS-Bi for importer@patchew.org; Mon, 24 Jan 2022 20:34:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAeo-0001t6-Dz for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:02 -0500 Received: from [2607:f8b0:4864:20::132] (port=43929 helo=mail-il1-x132.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAem-0001LM-Qw for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:02 -0500 Received: by mail-il1-x132.google.com with SMTP id d3so15513240ilr.10 for ; Mon, 24 Jan 2022 17:30: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 q14sm2061687ilo.63.2022.01.24.17.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:29: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=6fk8Rm7tbwnMJwW6ytgiwa7PMfU+rVxxXH2pSHcB2Zs=; b=C0Cwemy+kyRB4ZCElXqsSRSJkZBcBZkHNb5a5IAg+jYd1GN+QedmnE2SuwV86PEftS YjAkdU4eKwAsS6wJJmFj2lQ/2d0ZPpX8nIdTzgQJ/0k5JNbA6d6tXHWBRUYORKRUm8kt SNoWEZxTPfFcopivdg45m3hXLp69oieMkjMi7mwCjpGjOGIv58CcGMLk+IJHAlNniewK 7dSkmxJ4FaZPoPuBAm3xRrtmf2ZOReFoZ1HUPFLdeNuUsKmExiERlmnoYNkTiJIfCt6u zh9zpUp09JnIsq0lYFDLhNjfQ29q6KRTAjpu7C8MVb8c+nC0T73cVFh0sv5jWQbRzwGc XFyA== 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=6fk8Rm7tbwnMJwW6ytgiwa7PMfU+rVxxXH2pSHcB2Zs=; b=IIQSnCKqOU46zYHYuX+rApJSYALqrEaPD6YGR/GwgMnXdskBtgDdaG8LYvaBNxuOoJ ScI1yXfHBoGXl9DXAbjmjUTn/5lptiXsK3s+XtJ4tFvBFez20LLvr6yH7gNmy3ra/hmK 9hM+WWjBEaxwzdSu+sZOY5+YmGbRdx8fdIumFGyRb7UQgiieGYDPoI/FvvY0zf4DHWm8 yt/OruhRXvPFyY3EigPGXIM5IfZ71ZxU/Rfu7Q2GSEy+S2ekRPsxcHD7C1/FUub6zvWP Gmz92folFz3fi/eiqR2xSFRbJEe+KMf7ikyfBfEF7+fE7LUHNzavhzA44o9JdFMl87fG TRgw== X-Gm-Message-State: AOAM530FWLb4pPkxqZ4HASt7672IIjboKmArlDn7V1yfI3nqDFQMJo7S fgpVf2NIPjf7KjMPw5Anst3sa/PJWWhkng== X-Google-Smtp-Source: ABdhPJynhVBIVgrG60+lM/gaH0bdTHpCZraLg1AttrKuHkCVGxbERdFo7fYMSb09T2ipoInkgwaAqQ== X-Received: by 2002:a92:d70c:: with SMTP id m12mr9976921iln.275.1643074199494; Mon, 24 Jan 2022 17:29:59 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 07/40] bsd-user/arm/target_arch_cpu.h: Move EXCP_ATOMIC to match linux-user Date: Mon, 24 Jan 2022 18:29:14 -0700 Message-Id: <20220125012947.14974-8-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::132 (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::132; envelope-from=imp@bsdimp.com; helo=mail-il1-x132.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643074458150100001 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 Thu May 2 08:44:36 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 1643075370439166.0869866476612; Mon, 24 Jan 2022 17:49:30 -0800 (PST) Received: from localhost ([::1]:43566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAxd-0005PD-HJ for importer@patchew.org; Mon, 24 Jan 2022 20:49:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAep-0001wF-IJ for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:03 -0500 Received: from [2607:f8b0:4864:20::131] (port=42820 helo=mail-il1-x131.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAen-0001Lc-V6 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:03 -0500 Received: by mail-il1-x131.google.com with SMTP id u5so15515108ilq.9 for ; Mon, 24 Jan 2022 17:30:01 -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 q14sm2061687ilo.63.2022.01.24.17.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:00 -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=/PjL9OS801//J6FLPGxe5bj91YwywO1H07GXqkeIugE=; b=tVYd1zC5mC4CJkl3VP4ooUHmxppuy5WW2HrCuhpkWL60U6qyi5hOv7Q9lMCqu6zond /O59XcsL1CPlfRIMs6QIe3Xw2/zIyq9tNZtCSpG7V0l0+F2ondReFnuDcXMB2BsQoHDB rnJyKkLkCp61afksyKINwlfrtP9PU6O8j37Tn3qCQJf1DYVCZiweYyo34HAru4MHiBuG HByZQAaU5ll8RTd9oJq1+lYRXhPaeHaa93Mr4V8IGAH1r/QyAjwCOjNzhughlXWCm2sE H/VmjgXbTgldj4Xs/ISENqbIWKYuwglVfW3S7IeJ2RJMrcD9QePJi9u3Dn3yghXK0MXc 68zg== 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=/PjL9OS801//J6FLPGxe5bj91YwywO1H07GXqkeIugE=; b=ejG+6tPzaFjI1T+E1LWFtaXD3Ic0Uj+vzxxu0oYOi81ajUbb27YCXQ6BMwEl2xSO3L 76wc1Z2jdfHIXSAaFxI2mz1KIkvtYjCHRcBkh3JcmxarlPrEFr1vLQZSjdcttQ/bqfe4 3CB0NKrn+CkohjvPuzyCUK0WMhN8Xkk3BZ8ShbUMs91PHiyA35tZruXOG9n7HFs/KvHa W1RQsp1loU08WJO46mZDI+SHUeHWFrLvMbKsNgXLF4XjcELDkJJwHWmmngpY+1jmNjzt t7AEi24w+FK0009kRatNehtaNJyVaKLLuy5HMfS6/Qigz9NXSrdo2zjol0sPOdjUd2S8 C6/Q== X-Gm-Message-State: AOAM532XJk5wSDnBgTaWlwXVVxhKphcUQI/JA012h4UHmqfe7u1Jvnb8 UtFgsRk3YQj+LBLulx5BUx045Xb98tUjMQ== X-Google-Smtp-Source: ABdhPJzWxDzdUvxt5gUMdpOaHiYq3JFNW+LvVF+p0bTJO0QZvERqOK3zQAN3TuvcXA155dDpkXUlZw== X-Received: by 2002:a05:6e02:1c0c:: with SMTP id l12mr10392801ilh.273.1643074200758; Mon, 24 Jan 2022 17:30:00 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 08/40] bsd-user/signal.c: implement force_sig_fault Date: Mon, 24 Jan 2022 18:29:15 -0700 Message-Id: <20220125012947.14974-9-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::131 (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::131; envelope-from=imp@bsdimp.com; helo=mail-il1-x131.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075373265100001 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 Thu May 2 08:44:36 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 1643075193604650.3011158939013; Mon, 24 Jan 2022 17:46:33 -0800 (PST) Received: from localhost ([::1]:35388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAum-0008Hu-R1 for importer@patchew.org; Mon, 24 Jan 2022 20:46:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAer-00020M-Oi for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:06 -0500 Received: from [2607:f8b0:4864:20::12e] (port=45900 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 1nCAeq-0001OV-0z for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:05 -0500 Received: by mail-il1-x12e.google.com with SMTP id h30so15509977ila.12 for ; Mon, 24 Jan 2022 17:30:03 -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 q14sm2061687ilo.63.2022.01.24.17.30.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:01 -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=iCsKA4kDQTvpLyBCS5CIeJJTF7x2VsyKrnhUovgahmE=; b=0wsUT0mGXxZSxaL98MEGwGxwwcM+aewrDnUfasx1CP8wy92AAjfx6su497DMSY5/mb LSNVm55cTttZXG21Kp9f5G9QP/OWCunLMau7BtjeJfFlZnJ+8kmBv/hGV4I96GpM7DE7 VS8udWtjHWpCKtO2S+zQ38jAZl1KROnZ5JYEAm0bOMT123nAwJRGgajI7xjwC2WryFiS +kp3vHnk0f+QYQKU+WK/iXJJuG7sHzdXFCclP462TyQ16RmhkDCzYPEM6c6nx8OSxMJo 2lt8vUH3HEev3wveBja7R4xcYI5HDnG65cNFSUXtwva9+pDT4QU8NEYeiBC/GCjz3zfp npmg== 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=iCsKA4kDQTvpLyBCS5CIeJJTF7x2VsyKrnhUovgahmE=; b=F+NQDZjiLmFOte6xqFEpQOjeHZHIv6pLd2yX0eOvS07zQSFgDl8JkIpDf3iWXCE7GB jzBOtMykcYkHLNPKgfCjDCPj5IDsy4Il7CcuKVBpg+l3A7QrnL3I/cmZ/11f9MbZ8nzb nGWEWNsYoYJ30I465Nx1ZA6hDP1oO1ttvfxhH29vNM8TW6Ah9lUZkZha3s+O/jlAiSVA f7vnouGQ4JSPaCh1Yf//Hhaq7pNd4YVBBFa30c2y4i7nwqs317eAILcnK2aL82NuXxLb U+1sCk/30WZSjD2aJqrUlttK12TRGt0f26dpmjoW8Bym24r1U+dSDzvErvaHzViSwAk1 WUJw== X-Gm-Message-State: AOAM530Uw6ModoVJMeRgRxdlJ6IZo4PsOIaqHT6+TbnenSG9crQJIi4j cQeWORXVjdWMwueek/fDbKJTCHnGUTzRRA== X-Google-Smtp-Source: ABdhPJylM9MXxwwVMPcHHNwJisr3PktKTHuZdYDrdHTOu5cueXijxGpfxoc6KQJQfQDZrv1SN9D0Mw== X-Received: by 2002:a05:6e02:1be6:: with SMTP id y6mr9475389ilv.12.1643074201537; Mon, 24 Jan 2022 17:30:01 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 09/40] bsd-user/signal-common.h: Move signal functions prototypes to here Date: Mon, 24 Jan 2022 18:29:16 -0700 Message-Id: <20220125012947.14974-10-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075196511100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/qemu.h | 8 -------- bsd-user/signal-common.h | 6 ++++++ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 671b26f00cc..99c37fc9942 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -199,14 +199,6 @@ print_openbsd_syscall(int num, void print_openbsd_syscall_ret(int num, abi_long ret); extern int do_strace; =20 -/* 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); - /* mmap.c */ int target_mprotect(abi_ulong start, abi_ulong len, int prot); abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, diff --git a/bsd-user/signal-common.h b/bsd-user/signal-common.h index 6207417d39e..f9a9d1e01aa 100644 --- a/bsd-user/signal-common.h +++ b/bsd-user/signal-common.h @@ -9,6 +9,12 @@ #ifndef SIGNAL_COMMON_H #define SIGNAL_COMMON_H =20 +long do_rt_sigreturn(CPUArchState *env); +abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp); +long do_sigreturn(CPUArchState *env); void force_sig_fault(int sig, int code, abi_ulong addr); +void process_pending_signals(CPUArchState *env); +void queue_signal(CPUArchState *env, int sig, target_siginfo_t *info); +void signal_init(void); =20 #endif --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643075248975506.35372771265304; Mon, 24 Jan 2022 17:47:28 -0800 (PST) Received: from localhost ([::1]:37810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAvf-0001Um-UM for importer@patchew.org; Mon, 24 Jan 2022 20:47:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAer-00020d-T8 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:06 -0500 Received: from [2607:f8b0:4864:20::136] (port=35413 helo=mail-il1-x136.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAeq-0001Qs-9b for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:05 -0500 Received: by mail-il1-x136.google.com with SMTP id w5so11303429ilo.2 for ; Mon, 24 Jan 2022 17:30:03 -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 q14sm2061687ilo.63.2022.01.24.17.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:02 -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=SGJfV2pZjNq6/Lkgq5idUT85KpfDUjfI//YVpMiMT3c=; b=zaznoxWd0srZPl+qaqHf1GF7dHQJgiY5Uiv9kBHEwzWmcIeqXmbMWvfmsJNFx5Nl9c +Fbq9Gx4FYkJozpK79dyhqTWbI1TCD4WCgu7L2ecsZwHt/ZU/gNdFsBdyLYzy9fPSnRn kMA2MCZG9Tqw0yMkSvkxB1pWSo4uV8hSLYsmAlOen3KdKW5kA6xNATNO54AnJAX8bvK+ pwRYfTVL5ty35mIEScE943LrewJqO7YW5+Nak4Ppq62iXoVRKafUJtNXltSw5B7Tf7gJ vUb47ZqHzidGZLerlQx5cfChCFldCKzIiTDaVlal3Ze4eMVXZfKsIYnXohIuNxibxm0W zIRg== 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=SGJfV2pZjNq6/Lkgq5idUT85KpfDUjfI//YVpMiMT3c=; b=keg91uoA+hoi2GnOhlV2uM8nW4wqOHQ2szHzXtAnqHN+EQqu2VQHhaYr13x4g/IPDa YRVnGXm+LZpxiAHeO1Ss2gkk9L4HLqZDWJOpceoO1ry6hebx7JTKEEfSTbH2+Rjgo1Ik U4tTjng9GCzT4SGFvo9hWxW4Ne5bKBJPu+8wc7oIXU2w/fdyUPFx/V9drXU5vjMlDcy+ iktIoHZTu7wreydcEm+jlvjY1xw7y3J6aTGwXQs6dW4+x3gcVEx3bpfrsu5dI2F9U5BF Zh3AnhjRyE3LSpgKZhBqQhR59xVQMz35cqZGDn040qZFyK1VCBE4S1w86DbfuFswvEKq 5pqA== X-Gm-Message-State: AOAM532ur+uBb32LzFspf6QArcJVl8b9WZ+h7j7bB7bq9FhcYR3mWl2N Cxgr3In51eqpKxbV3uAV4hKVr1baiumKZw== X-Google-Smtp-Source: ABdhPJwsdvU540BXAfubCYvr5g11mSxESkAkcltajNiEn8GjH+6Cfo68YgUMUCFSVIxSvjKP/XHI6Q== X-Received: by 2002:a92:874f:: with SMTP id d15mr10587613ilm.194.1643074203056; Mon, 24 Jan 2022 17:30:03 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 10/40] bsd-user/signal.c: Implement cpu_loop_exit_sigsegv Date: Mon, 24 Jan 2022 18:29:17 -0700 Message-Id: <20220125012947.14974-11-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::136 (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::136; envelope-from=imp@bsdimp.com; helo=mail-il1-x136.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075252198100001 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 Thu May 2 08:44:36 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 1643074925960440.8308884660328; Mon, 24 Jan 2022 17:42:05 -0800 (PST) Received: from localhost ([::1]:55452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAqS-0002ci-Un for importer@patchew.org; Mon, 24 Jan 2022 20:42:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAeu-00024H-BH for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:08 -0500 Received: from [2607:f8b0:4864:20::12b] (port=43923 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 1nCAes-0001Y2-6h for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:07 -0500 Received: by mail-il1-x12b.google.com with SMTP id d3so15513358ilr.10 for ; Mon, 24 Jan 2022 17:30:05 -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 q14sm2061687ilo.63.2022.01.24.17.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:03 -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=WzkIKVsgbL3BkTFsfAwelEbf+OyNiGDSqNoHVUm1RWE=; b=SCXtFDXpljyUqYpZ8Zk61wxGCjAk0V4hUbVT+IMQZiCq4Gj3d4L1+fVGMjq6hgJv9s eMRVaL6KmL3osxIf07McrxU9nqyyBKSLz0hTUS9XWBeDg0c15J2zMkkcSj777obas7Ba pQZEC9Ob9nDQXr4Sc418SvPjhUq6nD+FgtJBcLPZhUSfT0eS0eLaTaVvVJ0ez24qAGD/ a02EwAuhdvaXvJrW8reH4O/XEl+x8xXVgfBBa6p/r9+Cpo87OHGGhvBU4iVgwv3WiJPC d5m3hDv5ChYAMdpgB9/4um2Pg4QqfdPE8AAeCxWe/ZHT46fN0q7G/9JBAxPpGaH2Fzfg DP0w== 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=WzkIKVsgbL3BkTFsfAwelEbf+OyNiGDSqNoHVUm1RWE=; b=6+xjLT8TRYYYUT3zrPuoodGNFLUW+tyFHhCQCqiuEYYya139ThYZkHHwi/fYAm/pDV DEC1NesDk+Sr/01b4g8i1EBEC7jng2c2QDl0dpEW8G0EnMB8C/20iqGNQc8ujnJnFYN/ pq8GDmWvG/P68ziAl4bJqupEIxf5rAsRLqMyBodFBxR+2YCPBFG6HBGBdAs1dqSKdZ9Z 7mv84ZMBkbRj2EteB67GrY7Vo0BlK7SogQ6rf182/uKXmNAP9V3izHkl5dfC5GTw1WFZ taSVxW3x+0xTrVWYeCgDWKwZZpi7axfxbRswNocw4su2Mt9N7JOxhjreO/c4nPiuM8Fr 52KQ== X-Gm-Message-State: AOAM530t9QJZl10OrCQdO8qY+54HJNZ6WN3TMsJOmxBCn71WzFYVht9P DpahGCywbwHjfedHWB2Dk+Lw4gb8vL55WA== X-Google-Smtp-Source: ABdhPJx7RVpGRzwtrnXVzZqalnrWUtWFYKLFCfQTfZ9TkqGNKONK6wNLEWMw2PksJf5HGiSZujK3eA== X-Received: by 2002:a05:6e02:144a:: with SMTP id p10mr10742457ilo.152.1643074204509; Mon, 24 Jan 2022 17:30:04 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 11/40] bsd-user/signal.c: implement cpu_loop_exit_sigbus Date: Mon, 24 Jan 2022 18:29:18 -0700 Message-Id: <20220125012947.14974-12-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643074927792100001 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 Thu May 2 08:44:36 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 1643075199031110.59942897903784; Mon, 24 Jan 2022 17:46:39 -0800 (PST) Received: from localhost ([::1]:35708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAus-0008Ud-8a for importer@patchew.org; Mon, 24 Jan 2022 20:46:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAeu-00024O-IY for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:08 -0500 Received: from [2607:f8b0:4864:20::d2f] (port=41736 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 1nCAes-0001YA-Ct for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:08 -0500 Received: by mail-io1-xd2f.google.com with SMTP id q204so7308613iod.8 for ; Mon, 24 Jan 2022 17:30:06 -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 q14sm2061687ilo.63.2022.01.24.17.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:04 -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=+79e/lT5oImcwf0ZHJypaQ4U50180OWSu5YZS9+fYVQ=; b=EjRj29hi4V6Mtk1iYrs1FP8XN91HaR9TA8ijpGknfsT48FG+yi+b+ZjWUarxv1ApyR RUuKJFU1Gx6ynm6VkRW0YtfqKEgmP5uhlwxGf2kIjhEQMDLP35Dx5RvK25I2wgxKCrcr nU3kZZpTZV7Xw/ffByVh0CzNdtXsSp1Oxj9IXpJ3fbxNoxzsYsqFFY9IPeVjY7mp6FAA WQDiLk+p2QHjbsleCnTOF/NGveLVTAYtGds8qdVf7UJF6GRCzcy1/tJvc/X4KmKsSLkk vbNFysDJEpdC1VjM4dQmW4fNs2klZG4m00JzTFDK71UYR0KfNFqyaCiHe+zvZOL+8JpD PZUQ== 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=+79e/lT5oImcwf0ZHJypaQ4U50180OWSu5YZS9+fYVQ=; b=dzbyPwiYwdYWyV3j1XGU3xNKX0zF+2O/7EFbBts6pt/XTD2tw+uPLNngJd6lF+oE9B 1DZJu48yYWzSWLDx0k+lNM9tWaZj5tPO290HjxH8c6EyBxSIJUp+gxPj//DsENhO7AQg V3mwKNhzLd8MP9jpyYR658Q2OzxM+d9IeEMc29WaPaeT1Z+jk/ipirWVqmr/pw6bbC+M Pe2dJbajiARuQytBRHKd2T08Z6zbNGdGwo6gD9Uh3G8VW0T1lrrd+T+b+yq11yczPpAv Rd1/jddOgoPq2uDD5U9Fct42XXtbWvWJ5kEKb6vqK9AJA8yTDNeKRRtkK6bcZX/JufC6 rBLw== X-Gm-Message-State: AOAM5306c8lkylAYiGFG8FVFjuncXKZgCWyo+/Aemw/SsA4bdBC/TBIN A1bZIs+JY+dLG+BJXXBrmck88BxDINm/gg== X-Google-Smtp-Source: ABdhPJwF5JyHU4gbtik6yKU0uYm0Ww2LOQHErXHcfRBjoAtlfwJSqg4LCul4fL3gKRyxongcfCEU5A== X-Received: by 2002:a05:6638:3009:: with SMTP id r9mr7997480jak.261.1643074205196; Mon, 24 Jan 2022 17:30:05 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 12/40] bsd-user/arm/arget_arch_cpu.h: Move EXCP_DEBUG and EXCP_BKPT together Date: Mon, 24 Jan 2022 18:29:19 -0700 Message-Id: <20220125012947.14974-13-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075201210100001 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). It's unclear why BKPT was an alias for system calls, but FreeBSD doesn't do that today. 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 Thu May 2 08:44:36 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 1643075397715714.9008280641232; Mon, 24 Jan 2022 17:49:57 -0800 (PST) Received: from localhost ([::1]:46100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAy5-00077A-10 for importer@patchew.org; Mon, 24 Jan 2022 20:49:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAev-00025v-I6 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:09 -0500 Received: from [2607:f8b0:4864:20::d33] (port=42616 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 1nCAet-0001YT-HQ for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:09 -0500 Received: by mail-io1-xd33.google.com with SMTP id a12so21879303iod.9 for ; Mon, 24 Jan 2022 17:30:07 -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 q14sm2061687ilo.63.2022.01.24.17.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:05 -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=w4FRMcODA3Yw9ipRGV2deCv5GoQkPWInOh9N0fcX/6E=; b=ylFtY/F0LJ4W+jqf4U24IArnezLeEHYSO7HvvjD74R4dXiugfN05rTao/Pyjh2jj6J 82fVyKOGF+vnfjUIToBT7+ZK35ZOEWAhlVfsQxYXERPrYjoWGpCievv9dEk8+x1FfcqE Zq7tKU1lsbZdvQhRq3rnohtqd/o9PmXy/aLJpFgwgXfpaDWjVOvpj/di0zE8idA4MI1Q x31sAYTtYRMtQAQ8yluTf10UPeSFyIQnZ4f48o6OuKRN+4d0eIw1QhNb+yEMsS1WHJT/ hHZrqDZuVHBeBwCQRrM8IUspJ8UYGMTFI3Bcx/JXOggxFVJ54YB/OMJ7bkPsw8l+Q4cB Btpg== 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=w4FRMcODA3Yw9ipRGV2deCv5GoQkPWInOh9N0fcX/6E=; b=ZbgA7Forda1jb1oowJ7vXqxTAwIkGDzX/h4rQxX0r5IgoAjktTqDJC8wAcQSiM95CM O5mXEQuadMIqXz3rgW+Aeinz+eKwyBHyf7/ERTmqK3eTDeRO8JNJR/cTygb5WOu1fat2 UQMAwCyFfNVpWTZPPHGB/NYprNpzS+rHmjsHeQxuUz/YPS4Gu1Aa58YRR2cLxlF6wwqM jcswruBoiyvEBnQutR6n79EtF1+xiOMNKMoreCJGU6j+PnpOw7X3Lf+oUFpYiaZS5/T1 4rGY13RMWFhHgi/s6YEyBUOGyirQ4PHMUtr7z9kt5IiCbh+Cty6zCiUJ8vCtXtjm7Qqh ENWA== X-Gm-Message-State: AOAM531NhSlC78bB5RE1Iwwta1x+QRF2KmOFHz8HlMSk2HbbdK12M0be J1Pn3d6BQXjD1HJEBt7dwXy6CJKY/xpHOA== X-Google-Smtp-Source: ABdhPJz+OlUhSEAWLwauDig8xk/yKHori6tBJA9pqG4BF8BsZQIcToQModdZ1ZkWnDs0oo2G8gH0OA== X-Received: by 2002:a05:6602:3402:: with SMTP id n2mr609721ioz.148.1643074206315; Mon, 24 Jan 2022 17:30:06 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 13/40] bsd-user/arm/target_arch_cpu.h: Correct code pointer Date: Mon, 24 Jan 2022 18:29:20 -0700 Message-Id: <20220125012947.14974-14-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075399837100001 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. 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 Thu May 2 08:44:36 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 1643075375054250.5432768145106; Mon, 24 Jan 2022 17:49:35 -0800 (PST) Received: from localhost ([::1]:44096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAxi-0005kp-4z for importer@patchew.org; Mon, 24 Jan 2022 20:49:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAew-00026r-N7 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:10 -0500 Received: from [2607:f8b0:4864:20::130] (port=34599 helo=mail-il1-x130.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAeu-0001Yg-KR for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:09 -0500 Received: by mail-il1-x130.google.com with SMTP id y17so3992721ilm.1 for ; Mon, 24 Jan 2022 17:30:08 -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 q14sm2061687ilo.63.2022.01.24.17.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:06 -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=noTZDMDgxbMiF6g0sA7fOvqo2GF//eMNgPA2d32SWUU=; b=4f+n1VBOJvLQPUgh1x1oMJJOngoTGIojOojIInghM1m6ChhVXOL/SFQMBGVwanY/eG /sgdWXaPZbZ5k1z7O/oE9TkIzJzdUc8zCsPB3BplyciVrT6ESQL0KcPRLvq+tS/Vx6wy T7npvjOucnT8BdisQynzu1mCjr2b7Q3leLfcdnfp1DNYhqZfuBAZR7+ZS329SOZz9iB2 v/F7hzVoF2V1VSCJMxdCJ+qfaE4oeWwTxVtDMmLSEXxUBXjb6cbGj2J8C6liRWiszzv0 5ilk/27YqPlffXLofKgR+07fInMi4v+9Mo9HHQQnZYF69YRApAIAN/hHwbGrx6qIPE4U lhAA== 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=noTZDMDgxbMiF6g0sA7fOvqo2GF//eMNgPA2d32SWUU=; b=IeOcEZmFvC7OnD9oVlNol07tBChHE3V8yEgP/3ezSJF5+HXAzQWnSUO1o7uBhI68Yu RC8e0gryh6PFGpFsEbwzZ2g1LVpyXhpmT92pvoXUJu8sGnzcNinE4ZcFYiBXLAJ1NNXd XprT0lG2QFsoCCzqeDD/69pEkrACcxfUPLDWpxgYQW8YrJd5FQNUZokavjLvtOsZEJcz 78Pm/iXEcUjXhTRa56hY+Ioa490eQQTJEVgB2ZNOpt2mhglQmoQJVxwmjhy5vkukgFTc ysn3swMiJAjbdBox2mCmMnuF1gdZYFBe3TXoVUtjtQZ/raYlNnQyeo59/+PjxGB0hHKb kVkg== X-Gm-Message-State: AOAM531qOBf8HX7mg3Spo7yavYHcVLQCd8C0tEctd9rpCMDkxHCRommq huDbeByk8rbtVDvQmuLzqHvOPcLzOw8qcQ== X-Google-Smtp-Source: ABdhPJwOAdnIYgV2t184CBRU6o4XobUnmJhEd7/MYPld/yXllQxyHnOnaPzXfTqBHmyOvsVlReqQwg== X-Received: by 2002:a05:6e02:1a8d:: with SMTP id k13mr10432862ilv.223.1643074207183; Mon, 24 Jan 2022 17:30:07 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 14/40] bsd-user/arm/target_arch_cpu.h: Use force_sig_fault for EXCP_UDEF Date: Mon, 24 Jan 2022 18:29:21 -0700 Message-Id: <20220125012947.14974-15-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::130 (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::130; envelope-from=imp@bsdimp.com; helo=mail-il1-x130.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075377521100001 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. Make a note about slight differences with FreeBSD in case any of them turn out to be important later. Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_cpu.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index 905f13aa1b9..f4b72939b2d 100644 --- a/bsd-user/arm/target_arch_cpu.h +++ b/bsd-user/arm/target_arch_cpu.h @@ -51,18 +51,19 @@ 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(); + * + * A number of details aren't emulated (they likely don't matt= er): + * o Misaligned PC generates ILL_ILLADR + * o Thumb-2 instructions generate ILLADR + * o Both modes implement coprocessor instructions, which we d= on't + * do here. FreeBSD just implements them for the VFP coproce= ssor + * and special kernel breakpoints, trace points, dtrace, etc. + */ + force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPC, env->regs[15= ]); break; case EXCP_SWI: { --=20 2.33.1 From nobody Thu May 2 08:44:36 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 164307558417033.82710770877168; Mon, 24 Jan 2022 17:53:04 -0800 (PST) Received: from localhost ([::1]:54550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCB15-0004Un-Dq for importer@patchew.org; Mon, 24 Jan 2022 20:53:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAex-00027f-Ha for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:11 -0500 Received: from [2607:f8b0:4864:20::133] (port=40793 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 1nCAev-0001Yy-I5 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:10 -0500 Received: by mail-il1-x133.google.com with SMTP id s1so273331ilj.7 for ; Mon, 24 Jan 2022 17:30:09 -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 q14sm2061687ilo.63.2022.01.24.17.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:07 -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=CjD6pNrb8Cxfr/lH07t3FSihICXtScIbMn43yN5Gho8=; b=IGVMI6ANj623zVvfYSkE++O3167mtODc9e+LwXZFZgAUq3xFrgnB8jAGXYz8rJ3D0E ZH7/w/A5nSsi8Tm6aJPxbqQtTAYOXudr2782IjlpFn+HubKEyfNvp/EQPWGsb74oO6SP MlysP6/xZMnw3Aq7ihC8yw/t+cztr+RvLctlLStPEs1qx5aNdjQEC+6IL0DNy28GBxo8 xJ40feQSb5XlIxWwXqBkZrcnjjoZVg7K5vsOiGuoJIkXH4CtswvRsHIsAPCteqORYf70 KxHATiMvUi/9EPk0UjJJFhcd5nxG+h4ucofqiFiUpU2SEpuj1zVbJQnuG3c/Uycn/EaZ 4yyg== 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=CjD6pNrb8Cxfr/lH07t3FSihICXtScIbMn43yN5Gho8=; b=iNm39IFxR3zxk1EIvUqgI6TFn/KCZZOjkAssYW8DVSTfOiOR7247pblvGwVp+NHwp1 8a8QxkrnouXhmaomQ5xfYnvgBPdgheDNWYuCVCpy6XDWlYKPE5hkJndwbNbFB6JQL55f 8CC1hoLhNdp1PHQyxqDYboFV79t7mRst6ChflzRagEsFu+vqKQce9tUmtNCtcr8KA9PS OYowbqxknV3S2e2BjCA8jua2khP72YUaKmWgwZ1/AzYd8CkBL5iJ9p2H+WZZkPZ2LIUE x0co/oJdSzjt17DiF00hUWW0ps6dpn6MHUmMy8r6ZkSXlKD4/8E427M0MLQ1u4ZZBAl3 wQvg== X-Gm-Message-State: AOAM530K22oJ7eZlpDwN7UIxnWXCJZ9jeO8iSCBz6iBSKGj5r8NHQtb9 SCy1X8f56h5FpDRGjJbZoyQJYvMs7Y3x7w== X-Google-Smtp-Source: ABdhPJzKuXWZMHecpTg3lpR9yVTWdihLWlXxy/WZ4zokpehH2jLsGrgDpikNRPJeGVS/x3vpBgutPQ== X-Received: by 2002:a05:6e02:12a4:: with SMTP id f4mr9919451ilr.77.1643074208253; Mon, 24 Jan 2022 17:30:08 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 15/40] bsd-user/arm/target_arch_cpu.h: Implement data faults Date: Mon, 24 Jan 2022 18:29:22 -0700 Message-Id: <20220125012947.14974-16-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075585632100001 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, with minor typo fixes. Signed-off-by: Warner Losh Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_cpu.h | 45 ++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index f4b72939b2d..2f1ab4c6ac2 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 @@ -150,15 +149,41 @@ 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_abort_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: /* Permission fault, level 1 */ + case 0xf: /* Permission 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 Thu May 2 08:44:36 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 1643075753321516.9564590698852; Mon, 24 Jan 2022 17:55:53 -0800 (PST) Received: from localhost ([::1]:34958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCB3o-0001mJ-F9 for importer@patchew.org; Mon, 24 Jan 2022 20:55:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAf1-00028N-NY for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:17 -0500 Received: from [2607:f8b0:4864:20::d2f] (port=38769 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 1nCAew-0001ZL-Jc for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:12 -0500 Received: by mail-io1-xd2f.google.com with SMTP id w7so21896846ioj.5 for ; Mon, 24 Jan 2022 17:30:10 -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 q14sm2061687ilo.63.2022.01.24.17.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:08 -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=HYXtjEPqD4J9+1lVRxBYunG+LQova7RJ34dMsONkl5Q=; b=gAZhIWEYL31J4qg2t+FIWH1x7Y8QkDrL4Ow4MAzY7CW0uRFBVNx1bpDYJPzNeobJoL +QXlOZIF3XA8MJ+hjTBYvWcNNqLO4a4WAWprdK1PSE3waI1gkic2tZeSazSzMU4GAkf1 OndPzHDvXp6Z2eDFDQi5b5fE2R1xVQhpjAvTbMzu80Y8hAqZTFLrYU+o9UIC+1GA/KuJ 5QVTWzEnelYp1xVTo7AM5MDASljtoi8pPWAc0EzPFROpCvOpdctVLbqHJoRJQmPddqkr bt+gx0YG+BQPHUjye3mq+eg+gABUa8Q6nZC9czBHpFaWSJGnXQLETa5EO13dqmh/q9P0 cHOQ== 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=HYXtjEPqD4J9+1lVRxBYunG+LQova7RJ34dMsONkl5Q=; b=mkDO3OWDpqtdlJIFTHiPTrG5u1CQW3DqUt5Ub6zKjTS3Tq2uoKBOx85Pb9kcMjBrUh tyl32JSBUupAutFQUZ29FJ9+hPFWYgdpBFQl1r45G/KbR13s8TAVdPAz2Gi/sRsWlov6 ENh7qk60IK/jWS2BT37k4efoYtXl3Hbt0FVodbKtrK8KuJowYP4oVW9Z9kuoz0WTn0tP ib3hh4gV6XfQQnbFpQ9TOsOuaCkoTURK0iplHqhw+pEkiIx0grPPpX1wgr1kMILiJlJs FmciuOtGLJKb+dN5STfRmZxWaBs+8TGEIjFiOcTL20keYlJWZvEKfqtIZoiaDzETj2Lf YTlg== X-Gm-Message-State: AOAM530dPHNRzTdmtpcVT0a6Hvyda2qpEeTpKOU8Y7t6+lTi6Q4H1x7m 186Y8/VGCZvGfT0Y1GRMUk/uij1z81y/mQ== X-Google-Smtp-Source: ABdhPJyIbRSXoJp79ulEbGcpbrZl4D12P/zpRoy8YcqMXPwOvWFQNjDKWAP+aXSIQGXVU+v+l38i/g== X-Received: by 2002:a05:6638:29b:: with SMTP id c27mr309835jaq.149.1643074209367; Mon, 24 Jan 2022 17:30:09 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 16/40] bsd-user/signal.c: implement abstract target / host signal translation Date: Mon, 24 Jan 2022 18:29:23 -0700 Message-Id: <20220125012947.14974-17-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075755759100001 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 Reviewed-by: Richard Henderson --- bsd-user/signal-common.h | 2 ++ bsd-user/signal.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/bsd-user/signal-common.h b/bsd-user/signal-common.h index f9a9d1e01aa..efed23d9efb 100644 --- a/bsd-user/signal-common.h +++ b/bsd-user/signal-common.h @@ -13,8 +13,10 @@ long do_rt_sigreturn(CPUArchState *env); abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp); long do_sigreturn(CPUArchState *env); void force_sig_fault(int sig, int code, abi_ulong addr); +int host_to_target_signal(int sig); void process_pending_signals(CPUArchState *env); void queue_signal(CPUArchState *env, int sig, target_siginfo_t *info); void signal_init(void); +int target_to_host_signal(int sig); =20 #endif diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 844dfa19095..1313baec96a 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,21 @@ * fork. */ =20 +/* + * The BSD ABIs use the same singal numbers across all the CPU architectur= es, so + * (unlike Linux) these functions are just the identity mapping. This migh= t not + * be true for XyzBSD running on AbcBSD, which doesn't currently work. + */ +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 Thu May 2 08:44:36 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 1643075587396580.4335272383064; Mon, 24 Jan 2022 17:53:07 -0800 (PST) Received: from localhost ([::1]:54854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCB18-0004hC-EF for importer@patchew.org; Mon, 24 Jan 2022 20:53:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfB-0002FR-4a for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:25 -0500 Received: from [2607:f8b0:4864:20::136] (port=40796 helo=mail-il1-x136.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAf2-0001ZY-Bt for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:19 -0500 Received: by mail-il1-x136.google.com with SMTP id s1so273397ilj.7 for ; Mon, 24 Jan 2022 17:30:11 -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 q14sm2061687ilo.63.2022.01.24.17.30.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:10 -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=l8RA7yWCAX4kkKStNQOwlFxMIKNeQ5iUFxaPSVvYcxY=; b=f28uQQM3t1aj2vr6JigcbOa8nTSfYhX9O2kZXSvUf6fqdXGhb2jjWj200fy4X/9oKE nMDO1Hk9kjjinAkBMIYwKleSMJpHmZhx+/8YlCFOk0usDpgrLx0l0kSgBoys2OkBxJ2U NCr5VBZUBu7qhjXz4W74OAJv+/AZaO+GxXjI7VW+zLXXGro411WMJf4ltt5ThbSCdQjm PlURyFTggGCqQZNAdbW9kaqwbK3wHy+GpFqHLiOU4x1+HQe9S9zRBJYvWYuDcTAMDwHY xN0WyN799IOQa7N0/R6icOZe89CMUxFzowSGTphMWDpMyvUPG6n8htRpzgtXAdeNTbx8 366A== 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=l8RA7yWCAX4kkKStNQOwlFxMIKNeQ5iUFxaPSVvYcxY=; b=ii4qpvjOpnj4ac9vAO2bcSQkD+NNBICoBO6xAk/87NCr5/XwWFbHOVD98ATql+rKqB 7CsNaVDaNwVpcvMuJXPTxoPAe3xKjo/LdydSMoHx2fT2Vg3GEbmQsVFQ3xdXKLbQE0q7 z4Y5P6VVFGyobbC9byRej4hPMJYc+VnSvXFnlO6lgkRFpXhfOonb5Wr4nisuh+eMHhQU lb8OIlmawtYE1Ury6Ec7UkyReGOTeEhSNoooaOwafM9hZs1VYBtmLWMcVFjMZt2xEKfh fQd/UqotS+gP1hrEAMj4imQnNhlTfe9hGRxpCpnSwWKSR8EpZQM/PEJvVoXq6MfcK8Z2 1hHA== X-Gm-Message-State: AOAM531oi5vdEDhhQpHdEdpdPGpYwR296EeJrAWS3xRSjOt4sXemPhKB rH2E6ftp/Q76xpFIxHxSSCgmE31nbWfpHg== X-Google-Smtp-Source: ABdhPJznwLwnRuumOVSoKcSl6PT4c5d4FahGKIHya4oUJTrtvWpzFzt6vdTc/cKwU3rxGclchi4ubQ== X-Received: by 2002:a05:6e02:152b:: with SMTP id i11mr10426016ilu.188.1643074210568; Mon, 24 Jan 2022 17:30:10 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 17/40] bsd-user/signal.c: Implement signal_init() Date: Mon, 24 Jan 2022 18:29:24 -0700 Message-Id: <20220125012947.14974-18-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::136 (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::136; envelope-from=imp@bsdimp.com; helo=mail-il1-x136.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075589972100001 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 XXX SIGPROF P= ENDING --- bsd-user/qemu.h | 7 +++++ bsd-user/signal.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 99c37fc9942..49f01932a53 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -94,6 +94,13 @@ typedef struct TaskState { * from multiple threads.) */ int signal_pending; + /* + * This thread's signal mask, as requested by the guest program. + * The actual signal mask of this thread may differ: + * + we don't let SIGSEGV and SIGBUS be blocked while running guest c= ode + * + sometimes we block all signals to avoid races + */ + 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 1313baec96a..3ef7cf5e23c 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); + /* * The BSD ABIs use the same singal numbers across all the CPU architectur= es, so * (unlike Linux) these functions are just the identity mapping. This migh= t not @@ -52,6 +55,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(). @@ -69,8 +94,50 @@ 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); + + 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++) { +#ifdef CONFIG_GPROF + if (i =3D=3D TARGET_SIGPROF) { + continue; + } +#endif + 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 Thu May 2 08:44:36 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 1643075563995101.2159552980487; Mon, 24 Jan 2022 17:52:43 -0800 (PST) Received: from localhost ([::1]:52506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCB0l-000386-5i for importer@patchew.org; Mon, 24 Jan 2022 20:52:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAf4-000292-6z for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:19 -0500 Received: from [2607:f8b0:4864:20::12d] (port=41932 helo=mail-il1-x12d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAf0-0001Zi-Br for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:17 -0500 Received: by mail-il1-x12d.google.com with SMTP id 15so1248350ilg.8 for ; Mon, 24 Jan 2022 17:30:12 -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 q14sm2061687ilo.63.2022.01.24.17.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:10 -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=GIrKzMc5jPXfhdAYwt0g5AuLCXCZz7PvOJlt6bMXYhA=; b=0YcQbTJTpfzQ+GUYYecg5AY2a2P4xfABKSwLMMCF2hitFsqzqNvYPelQen1E4ZhOv/ ky8CQDjS3wzjYhH/xCGH3jlR8372pvpScNM0Hb8zl8PsgLNRvHmZ26fR8Q9NT6LrkAOg Bi4VsalhKAbzHCDzWqUSJT3yIRRIsJontqMwuPe3Lg96wtcv/LncuJwsaYMav9FRxKJL ejgZCbRWqaU0rj3kffxAh4uHiO78rDggOlo276NgPhwBm8VQof7GYsFxXIHETb9fWsTn YXKtsWS5VpH+firm/0pcEAopCF36q/ciNeE7SpTLU7gCIkGPoNqxTw59vq1ZQht6du5/ bzxw== 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=GIrKzMc5jPXfhdAYwt0g5AuLCXCZz7PvOJlt6bMXYhA=; b=bVtrTHsvnzuI9bGAhIfYSVDU7HYCSAON4Jsv9fljATZljuEH/zsvMZhEJl7zfK/NaY QEJ4Lp1myxOwlmMHz6KnOpX80zg8OBqYaLOsh/4WPRXZhHEddwlQ/yS3BsRKF7sSvaJ6 Prl0qKUuu6kj8+Xmqs2wEuqYP5JLLZncBRkyVgkhiNzdlW6eQpJHEnyuXDojIlie6IjI wXbsg5FniAZsW9peyqkiIeb5Ny7G5aCXGlNMcCMK432f7ALHCzH5Gm5cWN9bnaWacGvn On50eoiPIEJoySEkNWD71V3iQQP+erWx/A7Ql7LEeTXLgqAKTOjr9s0TkpZ1+hw8Bd0D +7Yw== X-Gm-Message-State: AOAM530Cb+YAnHglGmRRUwi/80X6mXvp5zskeMpryj0CG41eA5VLicrf c+iW1cXksRclaouc0N3XbnaeIc8ZDmqhgg== X-Google-Smtp-Source: ABdhPJx9B+4gc9/+AdvSyYZfsoBnXUsiA/O01MMRPmbiH/7cXvoF8/SgiPA/bZzwuFqQJOwpiyT/dQ== X-Received: by 2002:a92:d7cf:: with SMTP id g15mr10540549ilq.46.1643074211345; Mon, 24 Jan 2022 17:30:11 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 18/40] bsd-user/signal.c: Add si_type argument to queue_signal Date: Mon, 24 Jan 2022 18:29:25 -0700 Message-Id: <20220125012947.14974-19-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::12d (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::12d; envelope-from=imp@bsdimp.com; helo=mail-il1-x12d.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075565569100003 Content-Type: text/plain; charset="utf-8" Mirror the linux-user practice and add a si_type argument to queue signal. This will be transported as the upper 8 bits in the si_type element of siginfo so that we know what bits of the structure are valid and so we can properly implement host_to_target_siginfo_noswap and tswap_siginfo. Adapt the one caller of queue_signal to the new interface. Use all the same names as Linux (except _RT which we don't treat differently, unlike Linux), though some are unused. Place this into signal-common.h since that's a better place given bsd-user's structure. Move prototype of queue_signal to signal-common.h to mirror linux-user's location. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/signal-common.h | 26 +++++++++++++++++++++++++- bsd-user/signal.c | 5 +++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/bsd-user/signal-common.h b/bsd-user/signal-common.h index efed23d9efb..80e9503238a 100644 --- a/bsd-user/signal-common.h +++ b/bsd-user/signal-common.h @@ -15,8 +15,32 @@ long do_sigreturn(CPUArchState *env); void force_sig_fault(int sig, int code, abi_ulong addr); int host_to_target_signal(int sig); void process_pending_signals(CPUArchState *env); -void queue_signal(CPUArchState *env, int sig, target_siginfo_t *info); +void queue_signal(CPUArchState *env, int sig, int si_type, + target_siginfo_t *info); void signal_init(void); int target_to_host_signal(int sig); =20 +/* + * Within QEMU the top 8 bits of si_code indicate which of the parts of the + * union in target_siginfo is valid. This only applies between + * host_to_target_siginfo_noswap() and tswap_siginfo(); it does not appear + * either within host siginfo_t or in target_siginfo structures which we g= et + * from the guest userspace program. Linux kenrels use this internally, bu= t BSD + * kernels don't do this, but its a useful abstraction. + * + * The linux-user version of this uses the top 16 bits, but FreeBSD's SI_U= SER + * and other signal indepenent SI_ codes have bit 16 set, so we only use t= he top + * byte instead. + * + * For FreeBSD, we have si_pid, si_uid, si_status, and si_addr always. Lin= ux and + * {Open,Net}BSD have a different approach (where their reason field is la= rger, + * but whose siginfo has fewer fields always). + */ +#define QEMU_SI_NOINFO 0 /* nothing other than si_signo valid */ +#define QEMU_SI_FAULT 1 /* _fault is valid in _reason */ +#define QEMU_SI_TIMER 2 /* _timer is valid in _reason */ +#define QEMU_SI_MESGQ 3 /* _mesgq is valid in _reason */ +#define QEMU_SI_POLL 4 /* _poll is valid in _reason */ +#define QEMU_SI_CAPSICUM 5 /* _capsicum is valid in _reason */ + #endif diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 3ef7cf5e23c..ad8437a8bfb 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -50,7 +50,8 @@ int target_to_host_signal(int sig) * Queue a signal so that it will be send to the virtual CPU as soon as * possible. */ -void queue_signal(CPUArchState *env, int sig, target_siginfo_t *info) +void queue_signal(CPUArchState *env, int sig, int si_type, + target_siginfo_t *info) { qemu_log_mask(LOG_UNIMP, "No signal queueing, dropping signal %d\n", s= ig); } @@ -91,7 +92,7 @@ void force_sig_fault(int sig, int code, abi_ulong addr) info.si_errno =3D 0; info.si_code =3D code; info.si_addr =3D addr; - queue_signal(env, sig, &info); + queue_signal(env, sig, QEMU_SI_FAULT, &info); } =20 static void host_signal_handler(int host_sig, siginfo_t *info, void *puc) --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643075755542216.33795968983998; Mon, 24 Jan 2022 17:55:55 -0800 (PST) Received: from localhost ([::1]:35176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCB3q-0001vW-SM for importer@patchew.org; Mon, 24 Jan 2022 20:55:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfB-0002FT-5t for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:30 -0500 Received: from [2607:f8b0:4864:20::12b] (port=45898 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 1nCAf3-0001Zy-Sn for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:19 -0500 Received: by mail-il1-x12b.google.com with SMTP id h30so15510253ila.12 for ; Mon, 24 Jan 2022 17:30:14 -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 q14sm2061687ilo.63.2022.01.24.17.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:11 -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=ke/+X5Zea6HMmQRZ3wmrxLwRK299Km5+GDI9cZXaqxw=; b=YoE7R6BfFiusBr+LgBY7ap8JyofTxgrJCaPhce6VJUQ4ume/uZ0EKztfP1+AqHeAS6 u1/VP76oE1zLg0GcLqfsp2i1CoXEtGx17qeSP0GlVvI7fNScs5wvcD09aaGVT9IZ+Clz /Ycc9MH44uWBFNRJMn/FO201xXUfpxre1lxjAJB9HIlBiGfTptziOBpoFeQyunbT+KEX FbeqfQyemGQ5PGRgOtJHyloFYJm6gaFtkFnjpyR+ZfgMRcWduvJdGj002XCk4gcPH4Gf wtNdhTUSJlc0lRB8QXs+4XhJnx+zHS9PyxLsEqXCSspeDmoaF31TRSUtDIMUEVXCkAW5 RlgA== 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=ke/+X5Zea6HMmQRZ3wmrxLwRK299Km5+GDI9cZXaqxw=; b=pVKGQwEleEVrVK6LbXNylz+GAWpSgRmo9IY3fcH4qHhppNXCKbCq5Cj+wqyaCHJame rb59tKobIk0YOB+HwWwZenbmZvfV0JETwvbZFkEr3qbRTUcnS22p/sERi0DZK5wzPvcF df5qUYDJYB/FwqgkOzEQVxA3p0KstkXL91J8O2ysziJpf+V7xpthBL+ALCXfqrhXSWLJ vxWexSALpq0LR7naFfTYGyYpwdSqchaWwEnmkAc1ASabuGyEcAYBOQVglmbsBsvJHNAo hb2mSrXGFP66YexEYbcUbxDe5IDYewd25MbRclBNxH9ExK7Q66vAi1C3fNAFL0MhY8x1 yWPQ== X-Gm-Message-State: AOAM531GJld6lHf6v120+mPVRQKsvG9ue252gXoS9B6yn+M1nHUOufHU YLC53e5M7691Am69ycygCzmTKLUCiJTI+g== X-Google-Smtp-Source: ABdhPJyTub0cs9kMxWoa2zocHmOv4UAq04/9QATDTT+ZYDi4dsBnR3aDaqLX05JHdNAol19v0ZUoig== X-Received: by 2002:a05:6e02:148a:: with SMTP id n10mr10224575ilk.228.1643074212197; Mon, 24 Jan 2022 17:30:12 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 19/40] bsd-user/host/arm/host-signal.h: Implement host_signal_* Date: Mon, 24 Jan 2022 18:29:26 -0700 Message-Id: <20220125012947.14974-20-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075758172100001 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 Reviewed-by: Richard Henderson --- bsd-user/host/arm/host-signal.h | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 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..56679bd6993 --- /dev/null +++ b/bsd-user/host/arm/host-signal.h @@ -0,0 +1,35 @@ +/* + * 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. + */ + uint32_t fsr =3D info->si_trapno; + + return extract32(fsr, 11, 1); +} + +#endif --=20 2.33.1 From nobody Thu May 2 08:44:36 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 164307537287393.07854010868357; Mon, 24 Jan 2022 17:49:32 -0800 (PST) Received: from localhost ([::1]:43820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCAxg-0005Zl-4F for importer@patchew.org; Mon, 24 Jan 2022 20:49:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfH-0002Hs-9D for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:34 -0500 Received: from [2607:f8b0:4864:20::134] (port=44596 helo=mail-il1-x134.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAf3-0001Zu-W6 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:27 -0500 Received: by mail-il1-x134.google.com with SMTP id i14so15512592ila.11 for ; Mon, 24 Jan 2022 17:30:13 -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 q14sm2061687ilo.63.2022.01.24.17.30.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:12 -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=6lp+mf01Obw62O4XR76se3KsYTrGoqPsoy/y1+puMOw=; b=HzoTLHwHZzUMXXd4kmxLBvsxjhUB5suqPlthEbHXhKw7WUQYKnXFknxSD6hRC2TaNl S99PwoGmmZvr97RVsMYdN5BXv+w/Ewcmhk9ysdjCA3VqXlHxTY/XkzozSOfJVdJufesx Yb0JNWuovWDxvgoZmB9bHJtgSnL2mXTyRhaP9sG7cWZiwNtlq0UDJhQGYvmju7vvgtZN b7rvHSIEW0oRgAPkrZP1G9Gcb5R+zOlGDxBPFeDVeaLvhepcIU1PeSQV/28Iga8LOBeS NqAy+amK1YinBFmRBfH0lxDuaBZNDsV46k4fHUR8h/76XRXeY9zBhC8TcdaGhOYrfwyD djzg== 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=6lp+mf01Obw62O4XR76se3KsYTrGoqPsoy/y1+puMOw=; b=fUctrxu4KcTtwcFiGMTJVwVc1NHoITpCje7gkGsslroaBXySW1dJN5ZPSc9DoNhbKV x5mLuv4462nHvrbLHJ1dKJrEz/hUuzpwlM/gdjhW/wxAxMchKk/o+/g/8a/Cjp4w2lWO dv5JOqYyWHxwxNWkv24x3Ln+mlC9aeS467eS3CgKRE9hRyShPnWPYXUiHYTeu5VXmyuc 36cib/hLEpMiNAb2KxKZXYb+XC0mKBNWqaJSLfMjZxdNBhLW6ZNxino5m1+g21KeBQEV 4BPm97BG3IZB4qOxatcbcrqQLgsSpxbDhiZrK2+WR53NxvVhpzWR5Z63iLH47887u7t8 7E9Q== X-Gm-Message-State: AOAM532rBnCYkCuN3voW/YbAbG9c+IL+CKSesGrRHxYs+MVFta/AjJ0r nPy46oUaubQdjS9dDCHu9AGB98+AFbm44Q== X-Google-Smtp-Source: ABdhPJyLfzUeBzeHUi7xQLzdHsMJXAhKicv1VkTR89WcoFkT4JC3WVNEk4405pvFT8ZH5LFLmCYllA== X-Received: by 2002:a92:d810:: with SMTP id y16mr3443664ilm.64.1643074212939; Mon, 24 Jan 2022 17:30:12 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 20/40] bsd-user/host/i386/host-signal.h: Implement host_signal_* Date: Mon, 24 Jan 2022 18:29:27 -0700 Message-Id: <20220125012947.14974-21-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::134 (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::134; envelope-from=imp@bsdimp.com; helo=mail-il1-x134.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075375405100001 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 Thu May 2 08:44:36 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 1643076192173355.91374079762295; Mon, 24 Jan 2022 18:03:12 -0800 (PST) Received: from localhost ([::1]:49806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBAt-0003Se-9W for importer@patchew.org; Mon, 24 Jan 2022 21:03:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfE-0002HN-Qw for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:34 -0500 Received: from [2607:f8b0:4864:20::d34] (port=36419 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 1nCAf6-0001b3-UO for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:25 -0500 Received: by mail-io1-xd34.google.com with SMTP id h7so3932729iof.3 for ; Mon, 24 Jan 2022 17:30:15 -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 q14sm2061687ilo.63.2022.01.24.17.30.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:13 -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=+J/ZcXBMkl7vIRUbXRkoafaooBA4s7iAGTsSYqX/VvY=; b=2diA3o40TXRs9BMo/oVpUPOE72XfIVQRq1RCua2JLRrzr3WJyhPUM/emD3EcojQkjN Ly6b551pXbZSWWEDpA4rdfbQ0akvo8GH1NRtHlZQBWONgZP07vPhEzwhN6tqn1A+cQV+ JCtRIi5kgwTO5jwxhNaBui+MwoK406M4Yic2UYSwyhtaotQtNLQfaQaC6WC3D7UsCjfV APkMN/YxN8rnaufsk8hbbh+DCJvaoqazAMOhA/JzlnxGNWiwN8X8DQLdKHPaniuOyCKD yp//mEJ0FZdI7Ieg5RsgYuAqQfGto1HARLHdagDDsQb+AYuI3xI0l/a0JHS9ypnVP8ZV xL9g== 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=+J/ZcXBMkl7vIRUbXRkoafaooBA4s7iAGTsSYqX/VvY=; b=gK9uAbexjt3oDA1q1BrzlsIaYADttz3FuZ9fy6sKzSrB4nvXDskvW3R+dOZofd35Xj U17Wk/TLU/gifwJUND0owdiii3Y9sOuFxuEZNMvjFJX+xPz4up524pvBjdflhu9NzAlN CChJVzfEnPpAEM3P3abfn/Gfxri69JCiFYaL0ek9y8jQ3vqRb0/2iGvjDOmrJvXtzMOX f5c6SOw585i1eb828VFp2OCurMoO3TLAQNd8U44z25ZbwqKioNJqKlPrQqhe2FK+TTRC G7TNKg82pB5X56FIHSI2579eEf1TVoGELTS+DK7UnQmWLbotp61Us0OTf8xDMYoBEysh 9W0g== X-Gm-Message-State: AOAM530qdxxFD4FZoRBIYQgCNEwUF0y81YzG8lurE8Q6oI3sz45fpmCO zOy2Pn31G1RkQkDS4ejgslk0nk08+y8TCA== X-Google-Smtp-Source: ABdhPJxHkDtpx3p5hAUEKvEFB6jgVDXkkwwoOQC8OFir1SBHkjcpjdMf9NKKAurnZLL1Wx4EszHo2g== X-Received: by 2002:a6b:5813:: with SMTP id m19mr2297652iob.172.1643074214034; Mon, 24 Jan 2022 17:30:14 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 21/40] bsd-user/host/x86_64/host-signal.h: Implement host_signal_* Date: Mon, 24 Jan 2022 18:29:28 -0700 Message-Id: <20220125012947.14974-22-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643076195228100007 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..47ca19f8814 --- /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 Thu May 2 08:44:36 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 1643076725602778.1051578194216; Mon, 24 Jan 2022 18:12:05 -0800 (PST) Received: from localhost ([::1]:40528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBJU-0007rA-Gi for importer@patchew.org; Mon, 24 Jan 2022 21:12:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfG-0002Hq-P9 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:34 -0500 Received: from [2607:f8b0:4864:20::129] (port=36678 helo=mail-il1-x129.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAf3-0001bW-W4 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:26 -0500 Received: by mail-il1-x129.google.com with SMTP id x3so825928ilm.3 for ; Mon, 24 Jan 2022 17:30:15 -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 q14sm2061687ilo.63.2022.01.24.17.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:14 -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=FSWCgQKiyULwg5VoJlgEfHBBGDIs0nJGXZTOGloR69s=; b=0sXDRlAXso5kllQhkF+6OgfayCl7YYCk1KRm5RQh+287v/OUylJux4HZhtD2YxVm3q O59jky4Ayzdur5giEAUFEGDTkJEpd8esmOtRUXUrvwObxoOQBzP1Q6XoaiKDKKt+OfOI B8c28dBs/KvsVVzC1k9flwYj6Jwb/Zz79B9plfQq7WAQ9PS5fvKIBIQM0PSUV2P0/lGE FXQW92ZUgmJmp8uMCvvJ7jxlLOVwwL6loQynR+myIg+SnqooIxV8/sl/F0hilXSR3rjM RYTbXziRraik+oWmwUSJRISpHRVO89F2womWJnDboCIatHqB0yakauLPEmL6BabzKfYs Gu3A== 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=FSWCgQKiyULwg5VoJlgEfHBBGDIs0nJGXZTOGloR69s=; b=ukaa1IjB2Kl5KJUscYf7mp6cOQUz7YNDPAOEhCacxUD/waaIa89cUXxUZaOl3pJtvo bfDaqPFqhPLv36Mo3sD0qKzIJjI8wkx4/i0wdEpF3OAoInHTUyfDSF0/HHaK+tiwXIFx BOy42HpA7zd9rnLnWlSL1aivygjxwp1ozfP5/Q8jpO63o6IhFlKlLuvfgQoe1ew0DzHr ur0zTGl3mJrHnXG0l8qQ0MqyKVy2ulJViKr5VBbWhjtFNsvqlVPQKzCr10H7EwfRsyB3 8eYdMixcREi5xihkfVpkQ1pXxhI16yCSR/eMvN+un1NfN1FJjIOaE/kfE7i0sanEpDPN Wmmg== X-Gm-Message-State: AOAM5335/sOggOk9IQBK9OsxPzuCW4jPmHcqhG9pWEAiCzISJDZL7WAr bMu16owxSZIpogZBR0QG6jdxpEf3e2U9hw== X-Google-Smtp-Source: ABdhPJysrsEKtCivfo+uG97WGYev297evqZIZF3nP7/RT820pMQp9ZgNJ984+xxUco6HDs5yI7E1IA== X-Received: by 2002:a05:6e02:1305:: with SMTP id g5mr2760199ilr.322.1643074214830; Mon, 24 Jan 2022 17:30:14 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 22/40] bsd-user: Add host signals to the build Date: Mon, 24 Jan 2022 18:29:29 -0700 Message-Id: <20220125012947.14974-23-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::129 (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::129; envelope-from=imp@bsdimp.com; helo=mail-il1-x129.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643076727967100001 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 ad8437a8bfb..f3e020e004a 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 Thu May 2 08:44:36 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 1643075674392383.2651122381401; Mon, 24 Jan 2022 17:54:34 -0800 (PST) Received: from localhost ([::1]:60984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCB2X-0000JP-I1 for importer@patchew.org; Mon, 24 Jan 2022 20:54:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfB-0002FS-67 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:30 -0500 Received: from [2607:f8b0:4864:20::d29] (port=41732 helo=mail-io1-xd29.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAf3-0001cs-VC for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:20 -0500 Received: by mail-io1-xd29.google.com with SMTP id q204so7309385iod.8 for ; Mon, 24 Jan 2022 17:30:16 -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 q14sm2061687ilo.63.2022.01.24.17.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:15 -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=JTWhVqKCstOU5FgvuzfWAofNmVQ+VpRI+KgX0kH49N8=; b=lEVU/BRgoWxD7tp8r9ABLdPNZs60V4cfRXhG2D2M9mIVMIXbmB9xeb+EsqsVLiYCYF hm4uY6jpg6NXVuvHF7IUSLJtjK8cpusN9ik5/s7IdvdNTWnolIzR/Aw4T2Yh6DRNEhzx awhanticd9H34HNFoBV1UqNhWK+X9KlZlP1ElfOpz6jsv1LRZtx0OwDR//XEX/o8q/Xd c0+9ivX+DNE2tmtgIFrUAs4AetK49BO3AOktspi5f+9ZK1IH21dit2MykI2haaQ/NCEd FtsDkrcjQ1EC6CAkwf3+WPE8s8Jlace5YiC40mWXoIntIoPFps9qMrEtQw6SmfT3D5Iy CRjg== 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=JTWhVqKCstOU5FgvuzfWAofNmVQ+VpRI+KgX0kH49N8=; b=VAYSYuIP0hdp8cXlQbtSDUOPwS+joQZvzalOIP+diqiodJ/H4Y92/W64HgsnIez33O kRgApvk6pwgeKD+h3IKzc94Q5xRkGcRbeXg43dVmK5uiT0uFNnz5q0k2oTzhOYxF4ii8 PH0WpgOCGAZMCi0/Hk2iwU5cxTmuTaiR4rfs1pvtbmLRXtL5ToDOokDpZpgBCNXQA2Wy 2cRgvLSJyE2Ve0mmUQBRNZ0DqRZa6pRGkdRmpS/6lFMJzcbk4fEhZ2BkI4m/UjpWP982 TmfsX1+gqRRiJH684DRJStW6jsQDIL0MYXqNEzATIYQI4f58zUAbsR7sVEYLjhSboiYh P3lw== X-Gm-Message-State: AOAM530EjTgeRtjZ0x95XdTrcnXGG7Ifqiq+KrEI87MJo17TBXiy1CIM wqTmpzPXqIJY7qaSimLxXtyA2245axSXUg== X-Google-Smtp-Source: ABdhPJyrHFg9VEIJUvZKNqeom6PZ4Up2CotcQyof0bzxr41Mfa7opzaZe6wuRIFD19UWGOgb8dklTw== X-Received: by 2002:a5d:8f86:: with SMTP id l6mr1278075iol.138.1643074216054; Mon, 24 Jan 2022 17:30:16 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 23/40] bsd-user: Add trace events for bsd-user Date: Mon, 24 Jan 2022 18:29:30 -0700 Message-Id: <20220125012947.14974-24-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::d29 (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::d29; envelope-from=imp@bsdimp.com; helo=mail-io1-xd29.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075676837100001 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 f3e020e004a..cb0036acb61 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..843896f6271 --- /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_dump_core_and_abort(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 Thu May 2 08:44:36 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 1643076252199629.3659801814586; Mon, 24 Jan 2022 18:04:12 -0800 (PST) Received: from localhost ([::1]:52318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBBr-00059P-G4 for importer@patchew.org; Mon, 24 Jan 2022 21:04:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfH-0002Hv-9s for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:34 -0500 Received: from [2607:f8b0:4864:20::134] (port=40795 helo=mail-il1-x134.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAfA-0001da-SL for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:27 -0500 Received: by mail-il1-x134.google.com with SMTP id s1so273598ilj.7 for ; Mon, 24 Jan 2022 17:30:18 -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 q14sm2061687ilo.63.2022.01.24.17.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:16 -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=8FxIJphu/joXYzE9rIY/0LH6iwnQR3a3YB/Ccc+Adhs=; b=RuwJiihe10VBTC/8M6zls7IOcehc4cOF5z6lk63GIdE9TkywEPKbzT+B6Nm7Jv04Ex Zy51XUb+wkKMnzIeBCloAeDTa6uNv8DFgUSgBKtmMVbqR+ukvE+ZcFYv57zSG1f6EDum PxVqNM3PUln4Dh9+9s+KaXRF2dO9A8QwbwddQSO284jCLrT5plNMDj3DhSNJAcN5zpyx FPWEHz3teF0r55JhMuImNvKySwngp3Cc1jhE8acFZoGMO9ZPAhmwdKa+zb0R+1Y9faOp oqXG8brC0QIwsNd0Oypm5UTyS//qTgpH6+uHgPNzE8URtKvjuN9vHAqkUiAHPVB/bD9Z l5/A== 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=8FxIJphu/joXYzE9rIY/0LH6iwnQR3a3YB/Ccc+Adhs=; b=3MUhHV/z760oU4lnqleIgqdZbiIFGKo8ADVq/XdhAtm5nqXd+PgvRa08/amDxGakvc 3T1odB+hzM6LP0LbR+ikFN/P0O0mD0nxvoFn/1vUNbrfTJCnGVCV6jDnAd4ciUXNqGiE zs7/TzZ42iIcrSuhIRi5mDUJgX5JVlGXt0UFdMQYG4BXJwuZHyPSKbEcQOuGRVt0xI4c HsIenu7zRz+qobvUU9qmMSJIw8S9/0ho6swRHcd6mNJXYD6GzAJ75J6iijXKTp/I/BaK j89RgfYcNQnqpgq0gqmzuVvV+r1zkrAVxYi8zV742s0cygdlFLkqr1wMEQcXQBXw3+Oi qIMA== X-Gm-Message-State: AOAM53203aYA4WNnc66pB/ze0p2RP6bUWd9mfsouAkepbCu57pYbu6LT vHPZmV7jfDOhbqkEbKoLRn7LjYnuYlqiEg== X-Google-Smtp-Source: ABdhPJxuStuqnmLvR0BFl1t6HL8kCh6AULecDvxGNj4MI71PDGTAq03+I5rZC8Khu6vaVB4rAEFQsA== X-Received: by 2002:a05:6e02:1707:: with SMTP id u7mr10603033ill.92.1643074217186; Mon, 24 Jan 2022 17:30:17 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 24/40] bsd-user/signal.c: host_to_target_siginfo_noswap Date: Mon, 24 Jan 2022 18:29:31 -0700 Message-Id: <20220125012947.14974-25-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::134 (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::134; envelope-from=imp@bsdimp.com; helo=mail-il1-x134.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643076253677100001 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 Reviewed-by: Richard Henderson --- bsd-user/signal.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index cb0036acb61..db8cf0a08f1 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -48,6 +48,119 @@ int target_to_host_signal(int sig) return sig; } =20 +static bool has_trapno(int tsig) +{ + return tsig =3D=3D TARGET_SIGILL || + tsig =3D=3D TARGET_SIGFPE || + tsig =3D=3D TARGET_SIGSEGV || + tsig =3D=3D TARGET_SIGBUS || + tsig =3D=3D TARGET_SIGTRAP; +} + + +/* Siginfo conversion. */ + +/* + * Populate tinfo w/o swapping based on guessing which fields are valid. + */ +static inline void host_to_target_siginfo_noswap(target_siginfo_t *tinfo, + const siginfo_t *info) +{ + int sig =3D host_to_target_signal(info->si_signo); + int si_code =3D info->si_code; + int si_type; + + /* + * Make sure we that the variable portion of the target siginfo is zer= oed + * out so we don't leak anything into that. + */ + memset(&tinfo->_reason, 0, sizeof(tinfo->_reason)); + + /* + * This is awkward, because we have to use a combination of the si_cod= e and + * si_signo to figure out which of the union's members are valid.o We + * therefore make our best guess. + * + * Once we have made our guess, we record it in the top 16 bits of + * the si_code, so that tswap_siginfo() later can use it. + * tswap_siginfo() will strip these top bits out before writing + * si_code to the guest (sign-extending the lower bits). + */ + 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. On all FreeBSD platforms, + * sizeof(sival_ptr) >=3D sizeof(sival_int) so the following + * always will copy the larger element. + */ + tinfo->si_value.sival_ptr =3D + (abi_ulong)(unsigned long)info->si_value.sival_ptr; + + switch (si_code) { + /* + * All the SI_xxx codes that are defined here are global to + * all the signals (they have values that none of the other, + * more specific signal info will set). + */ + case SI_USER: + case SI_LWP: + case SI_KERNEL: + case SI_QUEUE: + case SI_ASYNCIO: + /* + * Only the fixed parts are valid (though FreeBSD doesn't always + * set all the fields to non-zero values. + */ + si_type =3D QEMU_SI_NOINFO; + break; + case SI_TIMER: + tinfo->_reason._timer._timerid =3D info->_reason._timer._timerid; + tinfo->_reason._timer._overrun =3D info->_reason._timer._overrun; + si_type =3D QEMU_SI_TIMER; + break; + case SI_MESGQ: + tinfo->_reason._mesgq._mqd =3D info->_reason._mesgq._mqd; + si_type =3D QEMU_SI_MESGQ; + break; + default: + /* + * We have to go based on the signal number now to figure out + * what's valid. + */ + if (has_trapno(sig)) { + tinfo->_reason._fault._trapno =3D info->_reason._fault._trapno; + si_type =3D QEMU_SI_FAULT; + } +#ifdef TARGET_SIGPOLL + /* + * FreeBSD never had SIGPOLL, but emulates it for Linux so there's + * a chance it may popup in the future. + */ + if (sig =3D=3D TARGET_SIGPOLL) { + tinfo->_reason._poll._band =3D info->_reason._poll._band; + si_type =3D QEMU_SI_POLL; + } +#endif + /* + * Unsure that this can actually be generated, and our support for + * capsicum is somewhere between weak and non-existant, but if we = get + * one, then we know what to save. + */ + if (sig =3D=3D TARGET_SIGTRAP) { + tinfo->_reason._capsicum._syscall =3D + info->_reason._capsicum._syscall; + si_type =3D QEMU_SI_CAPSICUM; + } + break; + } + tinfo->si_code =3D deposit32(si_code, 24, 8, si_type); +} + /* * Queue a signal so that it will be send to the virtual CPU as soon as * possible. --=20 2.33.1 From nobody Thu May 2 08:44:36 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 164307647365250.278619792135146; Mon, 24 Jan 2022 18:07:53 -0800 (PST) Received: from localhost ([::1]:57534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBFQ-0000Iy-RO for importer@patchew.org; Mon, 24 Jan 2022 21:07:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfG-0002Hr-OA for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:34 -0500 Received: from [2607:f8b0:4864:20::d2e] (port=39494 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 1nCAfA-0001df-Ly for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:27 -0500 Received: by mail-io1-xd2e.google.com with SMTP id p20so225267iod.6 for ; Mon, 24 Jan 2022 17:30:18 -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 q14sm2061687ilo.63.2022.01.24.17.30.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:17 -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=2cxVzUGQfUKapU6iJyRCNz3mEY37Sx777/SzAWGZs48=; b=QeoZcB2SrI8ufWWf3DZzZ0xsjEr1U64zl14kFyK8sVfCMEaAJA/N85plhyLvx/6Vq2 8UjvGZqp0mYvoHKLBz3QCJvXDKXHIGis92liOkAjbmxYpbFf88JQ1o8UTNXG7rRDs8eI MghTgrEavV5HdfGZwCVHujb+KatTHI2dfCzofbVfrHD0RlnsqwpCAFMAJCSozPqdnVew 2AMsqp2hW2aP3nqH9wOhdpXsfROsDtn/IvI+9RQTbvYqpyWunwRHLFBQJJggcXMROSD6 VQBIDeKnRvmZD13cUkUCFotssQJR4dfOJkptW0vpbUgWfPWkZ8xEZrAL4ImMN+MTAWZ0 P+ow== 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=2cxVzUGQfUKapU6iJyRCNz3mEY37Sx777/SzAWGZs48=; b=JaEERsfzklHxg/remjJYtOjR/U6q9VdXvWPq9Qjd2iSq8s8l7r3Msih1PhuKafI8YU NkjwXFgX/meRDLonwO4c1Cvq8RvV4bf6SPRiax40feKH0XTcCsbGel69D06xrM0nEFog ZCIZH/BwnGTjvxfHLMyZbe0aKBlHvdB26NnMTNnr2GiyB8VYh9wnWWyrGbCUZnY5kxYM ir8OlYUMcgJF0sAtRR1/Xiu1PVMNsnDr/Ctu+GuaIpW7ARjRTtptGn5cUfBSE4SdyeU+ pEOsGEboN6H0v/nGcxm5AYhAZ8Q42KmLikHBkUUaJHcD9FfhFhmGfuL68Ef2LKqQpFLG ceVQ== X-Gm-Message-State: AOAM5307Vw5LaAmrLwgAquGVMKAiXVphApC4qpD9pi4q/gdxapF/vEB8 yG7GTzE6uyTeiDXxOOI/6INsdvXqZ42GLw== X-Google-Smtp-Source: ABdhPJxxLHZNWD25YapPtetfECozPVR6nTGbWB1oWVWjYimsqM1klcKgUmQf+zgbKYakDXZV+FAKKw== X-Received: by 2002:a02:7159:: with SMTP id n25mr7700493jaf.29.1643074217803; Mon, 24 Jan 2022 17:30:17 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 25/40] bsd-user/signal.c: Implement rewind_if_in_safe_syscall Date: Mon, 24 Jan 2022 18:29:32 -0700 Message-Id: <20220125012947.14974-26-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643076475758100001 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 | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 49f01932a53..8ed1bfbca89 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -446,4 +446,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 db8cf0a08f1..454aef2993e 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -48,6 +48,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); + } +} + static bool has_trapno(int tsig) { return tsig =3D=3D TARGET_SIGILL || @@ -57,7 +69,6 @@ static bool has_trapno(int tsig) tsig =3D=3D TARGET_SIGTRAP; } =20 - /* Siginfo conversion. */ =20 /* --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643075856286423.6234056601196; Mon, 24 Jan 2022 17:57:36 -0800 (PST) Received: from localhost ([::1]:41272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCB5T-000625-GM for importer@patchew.org; Mon, 24 Jan 2022 20:57:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfH-0002Hy-EC for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:34 -0500 Received: from [2607:f8b0:4864:20::135] (port=44598 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 1nCAfB-0001eY-5Q for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:28 -0500 Received: by mail-il1-x135.google.com with SMTP id i14so15512728ila.11 for ; Mon, 24 Jan 2022 17:30:20 -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 q14sm2061687ilo.63.2022.01.24.17.30.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:18 -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=CtYVvWfH9x9cRnCoXF+LtmvVjtc64lkASxqj16OdIm0=; b=g2Pkys/OJh0vOkRRy89SUh3Xi5gEtIHn4I3LviN6wVizrjaDvI4r/+GzYTZ8RWbCcO jBHPkyhLuga6L9FjoyAf7xMfKBhyyM16dWsO1vC31YHSLgqEK112Dw1vNxoz7JNEhq3K 3Hla0xYu/aXYcKcrfDkIwCnYsobb7kZLohP+E3O6/nJs6DnGMaNH6x1rI/mno7p98giZ ugXl9c7Ic/pFj3ZquXm1VYhjaIa0arVpJTWVzrN/w8e8CA6Gq5E1EwS8XvX/axvf3zUz AHIGSLZv+wQmqDitTO7f7ChqzxFESUt4th1qRFh35ovNv84J8Qn4NMb7bYT146Ztizn0 Mrbw== 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=CtYVvWfH9x9cRnCoXF+LtmvVjtc64lkASxqj16OdIm0=; b=fnmRyObso/oAq2zgXYB7cxwhyxK7BXc0RiauX/KcKEcSs9Q4T9iFiKs0sA3N17Kxp9 SylVx3Ai1kqKsN4+B/eNRx7jPse0Xt4NcbtUM6G+++bSHbVE/hZDcGW210tX9CDbsH0I BiECE4Fi8/9p3v+z/PxtJrvB7oOTdeBp5InBwLzK0nljQ8YZm/OYOMT5Vy0C0dEh1CWG bbZDWrLK0TF2r3P6ErJzDCT+JrCfk39eh1eS44V74N6pRr4SEdu+q1eqTZ9nH6M6ZIXy kgNdn75SIkHu0QQ3MlhXt+Yc2RtjSyxSH0fbTXg2jmoUtPwYbcIxxrImPDjzvCN7wdsj USRw== X-Gm-Message-State: AOAM531Vb7UUIrbe0IjzE8c6Kfja7xaKD58jq2WTa51ni+EdkFdrv+Hd MoQw6Xu5X1xGiYqCbm9ROXbcsxiyo8MiOg== X-Google-Smtp-Source: ABdhPJyNxQWIKlDJEsFMdjYHa19GPSVpTCaLhaJ3uaU8NAW6NG8sXdBa892C23UPe4ggM6JFyTtKiA== X-Received: by 2002:a05:6e02:1aa7:: with SMTP id l7mr10687773ilv.193.1643074218901; Mon, 24 Jan 2022 17:30:18 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 26/40] bsd-user/signal.c: Implement host_signal_handler Date: Mon, 24 Jan 2022 18:29:33 -0700 Message-Id: <20220125012947.14974-27-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075859062100001 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 Reviewed-by: Richard Henderson --- bsd-user/signal.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 454aef2993e..24cf4b1120b 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -223,6 +223,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) { + CPUArchState *env =3D thread_cpu->env_ptr; + CPUState *cpu =3D env_cpu(env); + TaskState *ts =3D cpu->opaque; + target_siginfo_t tinfo; + ucontext_t *uc =3D puc; + struct emulated_sigtable *k; + int guest_sig; + 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. */ + guest_sig =3D host_to_target_signal(host_sig); + if (guest_sig < 1 || guest_sig > TARGET_NSIG) { + return; + } + trace_user_host_signal(cpu, host_sig, guest_sig); + + host_to_target_siginfo_noswap(&tinfo, info); + + k =3D &ts->sigtab[guest_sig - 1]; + k->info =3D tinfo; + k->pending =3D guest_sig; + ts->signal_pending =3D 1; + + /* + * 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. + */ + 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 Thu May 2 08:44:36 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 1643075916736738.0988786888626; Mon, 24 Jan 2022 17:58:36 -0800 (PST) Received: from localhost ([::1]:43764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCB6S-0007iJ-0Y for importer@patchew.org; Mon, 24 Jan 2022 20:58:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfH-0002Hx-Ao for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:34 -0500 Received: from [2607:f8b0:4864:20::d2f] (port=41738 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 1nCAfA-0001f3-Lc for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:27 -0500 Received: by mail-io1-xd2f.google.com with SMTP id q204so7309534iod.8 for ; Mon, 24 Jan 2022 17:30:20 -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 q14sm2061687ilo.63.2022.01.24.17.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:19 -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=sPl9lqrZjcfTpqegDhQDXRvfLIYwDJ07NuHAvjSC0jE=; b=Vj+TSqYIivaAXh2697dkc7JUaCbIPrPykbeAttUFfrcvI29QqgG+KEKY+WQfq1srbF ZA1zM2BhevYTcE1lGPCnCVNUbx6phpFBMuKA8W/QMa/PqyNYjxcI+0Cfm3Ac2EJ05Yew UkQOjTREmAsmH2n5+KQHaHRXijfJzlGC6cNZhwZ42P/j6JxRVPZv+4kcNdVl9YCOZS8y V5WF2q8/QEKXv5jpzxBaPO/nLr0wWM0XCPHvzbk2fLKskQozutSiKcd/AT8fyx9c525W IhJYcLysycMfFMlc/iKhD/YvOBdS7dvOoAUNCrN27rhzJ5iIvJriA2mJFb3yjEac58z5 975w== 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=sPl9lqrZjcfTpqegDhQDXRvfLIYwDJ07NuHAvjSC0jE=; b=sdzPSxAeTIYeie0Rbnf3P+E9cxZ9tvPWAcIJcAiZkC6GJbEaJN/RoOS/W3QIohkNnA GTfKO3Vc++NCrmveR/Hq9lkp6AlpGUgxwVep/urA2Rh1SeORdVf3Faif6p08jh7pYy0d wu5ZHaS0YF0jh4OAJs7pv5itpzcAyg5+Nb8RXe8QAuBfZ9S5FcjpzbPwhtC3uj98/bp5 v6ApUYnC0Ly4jOe6RzJy00aO6lcJE2OsNBADzvYHOKRbHLhofamETvAlcyKIfaakRj78 uef93Ci/Kdvje+5KrtZYR5KRK846xuNrmcfVbihpqwusHS1tM8+ShQ8ovluCsMztr05i +jTA== X-Gm-Message-State: AOAM532TYsBmW+V69ekE/52zW/GXwK2UwyOZu3PgIxqBdBfNVgEFjhs8 ab+NhBSC7gapXm+TGJEG3o9FOy7lKe+24w== X-Google-Smtp-Source: ABdhPJwORMzPA4LAFNItsvD9SgY13JPzxmo9Q66iIgqgU8erIVNwN1QcP42D2Dy15sTbtkie/3/+hw== X-Received: by 2002:a05:6638:149:: with SMTP id y9mr4313748jao.316.1643074220011; Mon, 24 Jan 2022 17:30:20 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 27/40] bsd-user/strace.c: print_taken_signal Date: Mon, 24 Jan 2022 18:29:34 -0700 Message-Id: <20220125012947.14974-28-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075919064100001 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 8ed1bfbca89..a7964776fdb 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -204,6 +204,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 /* mmap.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 Thu May 2 08:44:36 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 1643076848735911.1735948361209; Mon, 24 Jan 2022 18:14:08 -0800 (PST) Received: from localhost ([::1]:44428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBLT-0002Po-Jz for importer@patchew.org; Mon, 24 Jan 2022 21:14:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfH-0002Hw-A8 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:34 -0500 Received: from [2607:f8b0:4864:20::133] (port=38787 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 1nCAfA-0001fu-Rj for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:27 -0500 Received: by mail-il1-x133.google.com with SMTP id i1so9530255ils.5 for ; Mon, 24 Jan 2022 17:30:22 -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 q14sm2061687ilo.63.2022.01.24.17.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:20 -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=U8VtaM8f6H1mBedMcMN2t5hogqkVzA4l3N+z2sTiAUQ=; b=SjVcDEeEx8uNS25DJkmRY+0UCV8QJUVxzPP7eaz7QEmLkjWd3VWdu3yfqYaWiwsYYf UHZgWvBNSbPJWirNgZcU3N2FYEZHtzsEuPaLk+I+lVGMEBjS1mqzT/cfFq/GycRSFnAa 2iuBwoBnuKxbQ1jeqzlhqLp1VFiNClxAIAPeBMrb8QMpCE4wwqnr2ycFtELmA6nCLV6X hhZDraGEMflJfn2eyo56aP9GXpxomyNiBjZz3b+AS2N42XSKh4I84l8zdEGNvzlWaJyn Ezsd6apX4RJLB4nbo9FH0smuKWwlxwzU8vu+VW67Pw66fomIvKOq9Wf2QEfUJ8ZtRz7I hyog== 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=U8VtaM8f6H1mBedMcMN2t5hogqkVzA4l3N+z2sTiAUQ=; b=WhqKiTEMf55mECLTYs3kh8/lZHUO2R46xuRI0rFZo/ZSghR+dyyf/Z0ZheMENrgLz/ Hx1eZKLPanJOaLDiKsbbn+N2SMsFZI3H8Yx3Vk82eSfJ07xt3uDz0kylzCGgFqifqwOn JqOrv9rlb3KKagWsQn1JBk5O837+e1KSvDPs/JCJbuvz0C5VonPvupK5VIj0dujE662G F3ZDA4+pFQbDq4qZfQGLWgquVmZtZHUnpYglhDAeSMSNP/UzL1Pod39783qFf4+t4h61 bVB8lwK30WEkIjGp4sZj3AWH6l+U1DGETpuPvNDQMHltOc2rlb80gJyIitnaZG8h2mix N+8w== X-Gm-Message-State: AOAM532m8atuujLT9tHELjhETcAlPlRgc3GfIB5tyhkMim65xXosBkPk +5ggQfXH/gC7v9AcvM5gBEFT73JEYZAZwQ== X-Google-Smtp-Source: ABdhPJxAqTWBwSSk56flz6vmAhOVf09CSvWmu6y/6+6jonYmzjvt3mHejrLL4FhipcveMkXIYJmFtQ== X-Received: by 2002:a05:6e02:20c1:: with SMTP id 1mr10135214ilq.169.1643074221003; Mon, 24 Jan 2022 17:30:21 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 28/40] bsd-user/signal.c: Implement dump_core_and_abort Date: Mon, 24 Jan 2022 18:29:35 -0700 Message-Id: <20220125012947.14974-29-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643076850985100001 Content-Type: text/plain; charset="utf-8" Force delivering a signal and generating a core file. It's a global function for the moment... Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/signal.c | 76 +++++++++++++++++++++++++++++++++++++++++ bsd-user/syscall_defs.h | 1 + 2 files changed, 77 insertions(+) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 24cf4b1120b..ccda7adbeef 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -172,6 +172,82 @@ static inline void host_to_target_siginfo_noswap(targe= t_siginfo_t *tinfo, tinfo->si_code =3D deposit32(si_code, 24, 8, si_type); } =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; + } +} + +/* Abort execution with signal. */ +static void QEMU_NORETURN dump_core_and_abort(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 Thu May 2 08:44:36 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 1643076539884808.0095716063018; Mon, 24 Jan 2022 18:08:59 -0800 (PST) Received: from localhost ([::1]:59942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBGU-0001vB-Vw for importer@patchew.org; Mon, 24 Jan 2022 21:08:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfH-0002Ht-9o for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:34 -0500 Received: from [2607:f8b0:4864:20::134] (port=39802 helo=mail-il1-x134.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAfA-0001g7-TI for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:28 -0500 Received: by mail-il1-x134.google.com with SMTP id z7so664452ilb.6 for ; Mon, 24 Jan 2022 17:30:23 -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 q14sm2061687ilo.63.2022.01.24.17.30.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:21 -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=zdl+PF9o92N/RKpPea/Fbgqg/k7pry6t4SM3rNCIkIo=; b=lgpPifzNL8pdutqdXOCR8Z/gWsS8Ht7CC+pis/OCm0ft4qEONMMtmKOSCKXhFoRfKc VxHQfZOgpyHspR1X6DwaYFmPTIJKATGTtYTBg4ALn4WFmENXphS7og7c6VVDF71yqP1M zS+h3RXVlkgmFaFYG13ZXzGmjJUdxQZtbVSruZZ8NYmrDOZvfYaiQFpYZ1vrrPsyzPbl dz5Rmi3xYyEPzp9orrMz2yvpUMjSej75bkuk3PGqeYJGqyUGMvWuye2I3KvciPcm03zG bcPQ0tJS8jknvfX3LoYedstAbWCydm65PchtWfWA0CVU4Zj6S+M4ds7ifL5PB+KM/dOZ cj2g== 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=zdl+PF9o92N/RKpPea/Fbgqg/k7pry6t4SM3rNCIkIo=; b=A0XcWGtrnpDQj3tLpw7PX++k+wvENPoh3g6ckFz4uXWXkjLInXGfr8g9UWqYXRWMvu 465PM3VGBagjOEm48ZTVuJpCEodLmpSB33wrHqAAygwD2D/5jOURwirISCEB9X5i1Vdm 6Gogdk5Uif3reIuOteo6NcRZR7yjPNML6qf6qDWIDKSaAxXpFMSi91l+MYYAxTfSANf2 hrusmKGL1NKLWKhgx7hX8U+DQ8ibtFnzW72xW1cQaIocOAn8hueblOXwJCQ4vEeTnusy aP4xPQcjulI8T0KP9JWYze0uaqVZTPXLGt2nOje2OA2PCnNCt4Mg5YxO2yNv8W9MrYj2 /FGA== X-Gm-Message-State: AOAM533IYEQGpv3JaJBEkciXYzXnjIkduH3GZ8fASgcTQ+gfdKqBNTEp phQs4pebLnHtfTv7Wltr4wGjFCY4967jOA== X-Google-Smtp-Source: ABdhPJxHa30PLjW+dCCLF5WZ7iaL3pa3hTJ4f/xAv/oy5gM+4cHBHo9mkcGbhppM6LVDUk3EJQrFAw== X-Received: by 2002:a92:c563:: with SMTP id b3mr10811231ilj.150.1643074222374; Mon, 24 Jan 2022 17:30:22 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 29/40] bsd-user/signal.c: Fill in queue_signal Date: Mon, 24 Jan 2022 18:29:36 -0700 Message-Id: <20220125012947.14974-30-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::134 (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::134; envelope-from=imp@bsdimp.com; helo=mail-il1-x134.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643076541819100001 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 Reviewed-by: Richard Henderson --- bsd-user/qemu.h | 1 + bsd-user/signal.c | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index a7964776fdb..fe0aedcdf3f 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -85,6 +85,7 @@ typedef struct TaskState { struct bsd_binprm *bprm; struct image_info *info; =20 + struct emulated_sigtable sync_signal; struct emulated_sigtable sigtab[TARGET_NSIG]; /* * Nonzero if process_pending_signals() needs to do something (either diff --git a/bsd-user/signal.c b/bsd-user/signal.c index ccda7adbeef..34663f7a28a 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -255,7 +255,18 @@ static void QEMU_NORETURN dump_core_and_abort(int targ= et_sig) void queue_signal(CPUArchState *env, int sig, int si_type, 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; + + trace_user_queue_signal(env, sig); + + info->si_code =3D deposit32(info->si_code, 24, 8, si_type); + + ts->sync_signal.info =3D *info; + ts->sync_signal.pending =3D sig; + /* Signal that a new signal is pending. */ + qatomic_set(&ts->signal_pending, 1); + return; } =20 static int fatal_signal(int sig) --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643075914293211.70647723736977; Mon, 24 Jan 2022 17:58:34 -0800 (PST) Received: from localhost ([::1]:43548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCB6P-0007ZE-B3 for importer@patchew.org; Mon, 24 Jan 2022 20:58:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfH-0002Hu-9a for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:34 -0500 Received: from [2607:f8b0:4864:20::d32] (port=34556 helo=mail-io1-xd32.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAfA-0001gC-Sg for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:28 -0500 Received: by mail-io1-xd32.google.com with SMTP id i62so6182432ioa.1 for ; Mon, 24 Jan 2022 17:30:24 -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 q14sm2061687ilo.63.2022.01.24.17.30.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:22 -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=LXI7ye1YfNMtjTAslCNcE2+lbnxuDIlXJX1FRpvyy5s=; b=by76lzPdcMqKcXlrnPfExhalarSTaw7HTQvdfuG7V1FS8N0wW1U1RUcnGvYm6ShyOy DctQyL4wHDZLZ/EEg/NyDA5dAWZ7MzTIFuBwyKfF/S1YLmryl/004SI/bpFuqxFs+WBF kjr0MFYf8bZAGqAHT5fNpzW5QBZZX1PyUVNLtEh39PQue5D8LXBO6zXY8dzk/H9b2HQr /6jI2eDYDVvIsnNk+caMnoY/g4HYNLkbHblR6I2TzUiHAGbeHOxTbDW/0rWc6STY/92l Zcwwlz/Ly6v0AIDdmcEduoJ8V69O4pmOAYzrlXJ8lkUpzjzQwizpjdedMKZGEqbRpOdW QXhQ== 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=LXI7ye1YfNMtjTAslCNcE2+lbnxuDIlXJX1FRpvyy5s=; b=fUbPRtI8AkhfbhpH26ANc6zhm4fYIp0KyyrB2HB5j9N/QWwOwKl5r2OI8IfTty4dhr ny49dkzxTnyaEX4e38W0f9oGOl3rWF6xj9baDieKeAwY5LsPwSILLdllsWBieWuzOMY7 phmFzbPREiOrEo0Z4dSXzpT4uIKUbUte2CoyxNyaq9L66zPH+DQRFPWUoijWuYczx7zF +s4WHo5s+L/3V0N7vq2YotEE2vPQOYyWUMyZCEy+mKQ6G1lGuVMHbD6otBUR69Hu9XQ+ R6A43Amk0zT+EmUqk9voOOg5O+bD0fjk5SOQ8Cqm6ZisEQU8nW9/B/sNRK19K/GLUeIB nJyQ== X-Gm-Message-State: AOAM531rGZCKV4bgNPwS/gF4JamTbXgigTObbTLE8CgPwpVsvEaRnCS5 VQFvIxrUBXX+tq+quxzwoIOH/och/3u+Sg== X-Google-Smtp-Source: ABdhPJx2nmgm7ka9FxGWflh3zeZPD9u/GELdoKd6C5JKc0OQZiFk5ppCwLRHt1KcPjCl7SfsHyR4Ww== X-Received: by 2002:a5d:8b8c:: with SMTP id p12mr4036388iol.90.1643074223248; Mon, 24 Jan 2022 17:30:23 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 30/40] bsd-user/signal.c: sigset manipulation routines. Date: Mon, 24 Jan 2022 18:29:37 -0700 Message-Id: <20220125012947.14974-31-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::d32 (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::d32; envelope-from=imp@bsdimp.com; helo=mail-io1-xd32.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075915472100001 Content-Type: text/plain; charset="utf-8" target_sigemptyset: resets a set to having no bits set 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 Reviewed-by: Richard Henderson --- bsd-user/signal-common.h | 2 ++ bsd-user/signal.c | 74 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/bsd-user/signal-common.h b/bsd-user/signal-common.h index 80e9503238a..ee819266f54 100644 --- a/bsd-user/signal-common.h +++ b/bsd-user/signal-common.h @@ -14,11 +14,13 @@ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong u= oss_addr, abi_ulong sp); long do_sigreturn(CPUArchState *env); void force_sig_fault(int sig, int code, abi_ulong addr); int host_to_target_signal(int sig); +void host_to_target_sigset(target_sigset_t *d, const sigset_t *s); void process_pending_signals(CPUArchState *env); void queue_signal(CPUArchState *env, int sig, int si_type, target_siginfo_t *info); void signal_init(void); int target_to_host_signal(int sig); +void target_to_host_sigset(sigset_t *d, const target_sigset_t *s); =20 /* * Within QEMU the top 8 bits of si_code indicate which of the parts of the diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 34663f7a28a..84dafa4e9fe 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 /* * The BSD ABIs use the same singal numbers across all the CPU architectur= es, so @@ -48,6 +51,25 @@ int target_to_host_signal(int sig) return sig; } =20 +static inline void target_sigemptyset(target_sigset_t *set) +{ + memset(set, 0, sizeof(*set)); +} + +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) { @@ -60,6 +82,58 @@ static inline void rewind_if_in_safe_syscall(void *puc) } } =20 +/* + * Note: The following take advantage of the BSD signal property that all + * signals are available on all architectures. + */ +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 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 < _SIG_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); +} + static bool has_trapno(int tsig) { return tsig =3D=3D TARGET_SIGILL || --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643075561115128.32785997076166; Mon, 24 Jan 2022 17:52:41 -0800 (PST) Received: from localhost ([::1]:52222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCB0i-0002wF-2J for importer@patchew.org; Mon, 24 Jan 2022 20:52:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfK-0002I2-2G for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:35 -0500 Received: from [2607:f8b0:4864:20::d31] (port=39498 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 1nCAfG-0001gs-Df for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:33 -0500 Received: by mail-io1-xd31.google.com with SMTP id p20so225536iod.6 for ; Mon, 24 Jan 2022 17:30:26 -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 q14sm2061687ilo.63.2022.01.24.17.30.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:23 -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=iFTjAIV7XEYSvKhiK50EBNfAbXI4YsjRaEW1MDHr5eo=; b=7nz3YqLsodDr7IMDEWjDlhtT2DjixE1xJCl5nYBMz101sS9xa3BOwllG6gLY6eAWfK IfO6wbuEJY53ELXElcbGF0IyPdokMiVYlZSwbA/f2w9qr4/emeMuRyEulYxQ7zR5HKWJ USJA3YDy7/VOImBujx0xFg9Gyp7nuYgLi2vYNP6wX62QNnkcW+SpGkq1DhuxQuto9zZq 71hshBB/3qtDk0VVBxJD0Stbrvv363QKlSdWvls3uWOIg79Lw4A8EY/x9n3o04HZgZP+ LJEuRyk6eF4DXqhhtiyLIrjbUQhJAX+h/7ALRvLp4naxZGejfY7FELLU65wmX1fITq40 BNSA== 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=iFTjAIV7XEYSvKhiK50EBNfAbXI4YsjRaEW1MDHr5eo=; b=j+WB60NSkNV8C4TEIYpNaChTVXwU/BzK7sKJz7jjaJ7+GH0vKDKOztNRyc8x/5jiaR 0QH8Gx1tJRrut9QGwc2L520SKX49cFQ9vWroSQIyBk160DFJOYtTyaEqNd41zJf+NoBM R4MbPme8qxGYRErV+pYaGdE+dTj7tkiWA+D4uCckU/GBUVLB5vXts8fRntgxZssFtveh nIbPRTRaIFBVRdF6F3HCRQzV+CW/nZaR5AYnjSsx1Y0BuexWWFJvY1zuCAeSitG7i146 ef+CSE+9hxuHIQ2HwKTFxU1WBPtOSpyfRTZF0xCn9WNIP2/fQBAnZCvM84Eq5XtentxP WEFw== X-Gm-Message-State: AOAM532eoWPdeQY2IqxYakf32W1j5jax+6Ln/ExKJJl+hZwQU+OTADJH E5X/rqBk7zaCbkAHkBYEeiyelDk8TSg5mg== X-Google-Smtp-Source: ABdhPJyNahVIYHe8akwKm4rbMOu6RHdTww6bgwSY5mdAsUOoX/3EGQH5yYLZej1lYrAlnk+AQl6oAA== X-Received: by 2002:a5d:9b0c:: with SMTP id y12mr9239146ion.190.1643074224356; Mon, 24 Jan 2022 17:30:24 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 31/40] bsd-user/signal.c: setup_frame Date: Mon, 24 Jan 2022 18:29:38 -0700 Message-Id: <20220125012947.14974-32-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075563964100001 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 Reviewed-by: Richard Henderson --- bsd-user/main.c | 5 +++ bsd-user/qemu.h | 3 +- bsd-user/signal.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 29cf4e15693..f1d58e905e7 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -217,6 +217,11 @@ void qemu_cpu_kick(CPUState *cpu) /* Assumes contents are already zeroed. */ static void init_task_state(TaskState *ts) { + ts->sigaltstack_used =3D (struct target_sigaltstack) { + .ss_sp =3D 0, + .ss_size =3D 0, + .ss_flags =3D TARGET_SS_DISABLE, + }; } =20 void gemu_log(const char *fmt, ...) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index fe0aedcdf3f..05be5de3f03 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -103,7 +103,8 @@ typedef struct TaskState { */ sigset_t signal_mask; =20 - uint8_t stack[]; + /* This thread's sigaltstack, if it has one */ + struct target_sigaltstack sigaltstack_used; } __attribute__((aligned(16))) TaskState; =20 void stop_all_tasks(void); diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 84dafa4e9fe..79a7083ddb3 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -35,6 +35,16 @@ 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(TaskState *ts, unsigned long sp) +{ + return sp - ts->sigaltstack_used.ss_sp < ts->sigaltstack_used.ss_size; +} + +static inline int sas_ss_flags(TaskState *ts, unsigned long sp) +{ + return ts->sigaltstack_used.ss_size =3D=3D 0 ? SS_DISABLE : + on_sig_stack(ts, sp) ? SS_ONSTACK : 0; +} =20 /* * The BSD ABIs use the same singal numbers across all the CPU architectur= es, so @@ -491,6 +501,78 @@ static void host_signal_handler(int host_sig, siginfo_= t *info, void *puc) cpu_exit(thread_cpu); } =20 +static inline abi_ulong get_sigframe(struct target_sigaction *ka, + CPUArchState *env, size_t frame_size) +{ + TaskState *ts =3D (TaskState *)thread_cpu->opaque; + abi_ulong sp; + + /* Use default user stack */ + sp =3D get_sp_from_cpustate(env); + + if ((ka->sa_flags & TARGET_SA_ONSTACK) && sas_ss_flags(ts, sp) =3D=3D = 0) { + sp =3D ts->sigaltstack_used.ss_sp + ts->sigaltstack_used.ss_size; + } + +#if 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 $M/$M/exec_machdep.c sendsig and sys/kern/kern_sig.c sigexit= */ + +static void setup_frame(int sig, int code, struct target_sigaction *ka, + target_sigset_t *set, target_siginfo_t *tinfo, CPUArchState *env) +{ + struct target_sigframe *frame; + abi_ulong frame_addr; + int i; + + frame_addr =3D get_sigframe(ka, env, sizeof(*frame)); + trace_user_setup_frame(env, frame_addr); + if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) { + unlock_user_struct(frame, frame_addr, 1); + dump_core_and_abort(TARGET_SIGILL); + return; + } + + memset(frame, 0, sizeof(*frame)); + setup_sigframe_arch(env, frame_addr, frame, 0); + + for (i =3D 0; i < TARGET_NSIG_WORDS; i++) { + __put_user(set->__bits[i], &frame->sf_uc.uc_sigmask.__bits[i]); + } + + 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; + /* see host_to_target_siginfo_noswap() for more details */ + frame->sf_si.si_value.sival_ptr =3D tinfo->si_value.sival_ptr; + /* + * At this point, whatever is in the _reason union is complete + * and in target order, so just copy the whole thing over, even + * if it's too large for this specific signal. + * host_to_target_siginfo_noswap() and tswap_siginfo() have ensured + * that's so. + */ + memcpy(&frame->sf_si._reason, &tinfo->_reason, + sizeof(tinfo->_reason)); + } + + set_sigtramp_args(env, sig, frame, frame_addr, ka); + + unlock_user_struct(frame, frame_addr, 1); +} + void signal_init(void) { TaskState *ts =3D (TaskState *)thread_cpu->opaque; --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643076988682599.2298174379574; Mon, 24 Jan 2022 18:16:28 -0800 (PST) Received: from localhost ([::1]:46704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBNj-00045O-TI for importer@patchew.org; Mon, 24 Jan 2022 21:16:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfI-0002I1-JN for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:35 -0500 Received: from [2607:f8b0:4864:20::d2d] (port=43955 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 1nCAfE-0001gq-I6 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:31 -0500 Received: by mail-io1-xd2d.google.com with SMTP id z199so7383140iof.10 for ; Mon, 24 Jan 2022 17:30:26 -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 q14sm2061687ilo.63.2022.01.24.17.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:24 -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=xNhtUGDKIHI+f2l21MCXghBiVRPXoDubfC9kQtHgX8o=; b=PXeRSuGeFP/nwXp9yqAi9Diw0zEc+HVPxgIi++cYeRWkJyyJWqzYeQ1c3Bgy6yRVie 6gm4sPVkRGhYx7GjO+6sWLh+hoqq42AS+ymqNStKcm415dSVK+VbOKxVDyeetEfDLpd8 4qGnoKT8urrAlqIdcHUzrrj59HYQ1lFpHCBHXu6HuuQMBrHVFfdGG+3U5BCwA9qNVkF6 kGfQHnPHB3m5tISZMkss5rrOKzlza7rdsvGoaRhTR5jgs6H5ax2G6mclj18UCco9g03k kKwo5kQt/l3UkMaxAAmFUrPC7l9BuhBrJdoAD8FjxX4w2+GLiMnXUcOINlIGDkBwInw9 sJfg== 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=xNhtUGDKIHI+f2l21MCXghBiVRPXoDubfC9kQtHgX8o=; b=yRRivLN/EeVSXoxVHi24nEGeHW6JxB6HJEiZrrEJ+FZv30NVuEdqRTgaNB+gkPpDJR GHqng+csRgKpbYtNoufsWGMO7qFl9MqQorbR5JpPKJwuzAaFy1IUO5w1C+9/3WAmwQSb uUnuomqUtO+OUOKVAqNcqRiiM+YjqNDR24MkRxtXAweZF0cZn+nMzoG4+/ZRS2Rcb2ai UQTccNT28JJDP9B8OhbA89TrJSpLYCCZTtI8ELNo3CyBMPgQfHu/LDHINbx6VXFf0NAj EkwSv3SDOn7A+GkVccjeTzxEHm8dNvjycsZ1UIVolHbR9F3b1I03EYnIiIQU0JlxX5N4 VVfw== X-Gm-Message-State: AOAM532ONfWw3oNZTrcnsqH3cAexpIBl5kprcz+bhbB6nsyNi6J3l57W Rt/LGiTfIFbZgUHUo4L0zu7hc+olLWqh4A== X-Google-Smtp-Source: ABdhPJzjrIXUGyQu1XQKayVFL8Au14j1HTuK71iPZmusswR8N7HBcVhcUw3rPMAosSa2vpZkadtdDg== X-Received: by 2002:a6b:ee16:: with SMTP id i22mr3856840ioh.63.1643074225588; Mon, 24 Jan 2022 17:30:25 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 32/40] bsd-user/signal.c: handle_pending_signal Date: Mon, 24 Jan 2022 18:29:39 -0700 Message-Id: <20220125012947.14974-33-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643076990706100001 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 Reviewed-by: Richard Henderson --- bsd-user/qemu.h | 7 ++++ bsd-user/signal.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index 05be5de3f03..376b3d48eba 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -95,6 +95,8 @@ typedef struct TaskState { * from multiple threads.) */ int signal_pending; + /* True if we're leaving a sigsuspend and sigsuspend_mask is valid. */ + bool in_sigsuspend; /* * This thread's signal mask, as requested by the guest program. * The actual signal mask of this thread may differ: @@ -102,6 +104,11 @@ typedef struct TaskState { * + sometimes we block all signals to avoid races */ sigset_t signal_mask; + /* + * The signal mask imposed by a guest sigsuspend syscall, if we are + * currently in the middle of such a syscall + */ + sigset_t sigsuspend_mask; =20 /* This thread's sigaltstack, if it has one */ struct target_sigaltstack sigaltstack_used; diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 79a7083ddb3..d82d916bfbc 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -615,6 +615,93 @@ void signal_init(void) } } =20 +static void handle_pending_signal(CPUArchState *env, int sig, + struct emulated_sigtable *k) +{ + CPUState *cpu =3D env_cpu(env); + TaskState *ts =3D cpu->opaque; + 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(env, sig); + + 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, &k->info); + } + + if (handler =3D=3D TARGET_SIG_DFL) { + /* + * default handler : ignore some signal. The other are job + * control or fatal. + */ + if (sig =3D=3D TARGET_SIGTSTP || sig =3D=3D TARGET_SIGTTIN || + sig =3D=3D TARGET_SIGTTOU) { + kill(getpid(), SIGSTOP); + } else if (sig !=3D TARGET_SIGCHLD && sig !=3D TARGET_SIGURG && + sig !=3D TARGET_SIGINFO && sig !=3D TARGET_SIGWINCH && + sig !=3D TARGET_SIGCONT) { + dump_core_and_abort(sig); + } + } else if (handler =3D=3D TARGET_SIG_IGN) { + /* ignore sig */ + } else if (handler =3D=3D TARGET_SIG_ERR) { + dump_core_and_abort(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; + 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 k->info.si_code; /* From host, so no si_type */ + /* prepare the stack frame of the virtual CPU */ + if (sa->sa_flags & TARGET_SA_SIGINFO) { + tswap_siginfo(&tinfo, &k->info); + setup_frame(sig, code, sa, &target_old_set, &tinfo, env); + } else { + setup_frame(sig, code, sa, &target_old_set, NULL, env); + } + if (sa->sa_flags & TARGET_SA_RESETHAND) { + sa->_sa_handler =3D TARGET_SIG_DFL; + } + } +} + void process_pending_signals(CPUArchState *cpu_env) { } --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643077160925157.72462719710586; Mon, 24 Jan 2022 18:19:20 -0800 (PST) Received: from localhost ([::1]:50916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBQV-000709-Qg for importer@patchew.org; Mon, 24 Jan 2022 21:19:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfK-0002IM-VR for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:37 -0500 Received: from [2607:f8b0:4864:20::d2d] (port=45627 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 1nCAfH-0001h2-5P for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:33 -0500 Received: by mail-io1-xd2d.google.com with SMTP id s18so5354863ioa.12 for ; Mon, 24 Jan 2022 17:30:27 -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 q14sm2061687ilo.63.2022.01.24.17.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:25 -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=aO65Pa339vzG5+2plDRCAGuhrhvy2TJ9xI/5vsKtHyQ=; b=W4uJlz93fk01iwPXKa4xOk24Xg8PgCjAmA925T4yMJor0TvMjffNCx5+zP3RR8AH+v w9UWB/mjrsOkHorytSLj7aZZaDErnwHOCaxi3x615GVzW76Jj29AwFT9goxGUKRLf925 tlsxkfdVDER/3L81wctqDBTlOKSfIcYYKWBQfVz6guPFKDXwVYRJCJ032+zxzdtmAv57 itg34+wXjjhfyb9j9Ku6Tiok5gPuqVn+w2gzgMqzrAWtUZLKlApSXINQSkUpBhj2o1dh vvLo4pFf1975h1+Rj1V954XbdfIEWKzwxtdYPyPfWHVEwdvMGZPrVP8yCepVDxyP0b4W knsg== 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=aO65Pa339vzG5+2plDRCAGuhrhvy2TJ9xI/5vsKtHyQ=; b=EutvdboZqhOPEXD/7X83Ww+hvR890YTLKwCd3VI8y6v77XzJeHg4/mYYE/BICAVsNC lQt+kCvQNRQIKEhBmQpiEz5RhYe0b6P5MEuiAWjFAg1Fn+5AN+/8fxcSlwsT6olbP6bG 4SZmb5+MvqnX9qQIDNdLjg6TG1KHH7pbXxHq6wjYBWUXm9ILHyecsQpBg3qdFm9tMpp9 LXTBTpALcdF4OU2lsMlrh8pD7evfibLCiJZzfYVWRXs2gBqtc36t3Eb8ivh0bCCMn5UI pp/+qkXjzoZM/PCmmAgBK6Kk3eSbxyptltbJwdhU1VZt6qQYgvO2mr/cRHBWEmpTDM7/ sDXQ== X-Gm-Message-State: AOAM533n3TtTzgK/LGNCnigA1GCojLo77BslsoKBwTTei2A464OGC3al 3LwMXLMvT3sKVrqVkaWFOiEoDqpml5m2KQ== X-Google-Smtp-Source: ABdhPJwrN8BOZi/H/6PgQLZDbws0XfcUt4duAqr+ZYAbxpkQbwW7L6YbENqpTIMerCpajJvHclwdwQ== X-Received: by 2002:a02:2388:: with SMTP id u130mr8713393jau.183.1643074226466; Mon, 24 Jan 2022 17:30:26 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 33/40] bsd-user/signal.c: tswap_siginfo Date: Mon, 24 Jan 2022 18:29:40 -0700 Message-Id: <20220125012947.14974-34-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643077162750100001 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 Reviewed-by: Richard Henderson --- bsd-user/signal.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index d82d916bfbc..aef1fa95490 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -256,6 +256,59 @@ static inline void host_to_target_siginfo_noswap(targe= t_siginfo_t *tinfo, tinfo->si_code =3D deposit32(si_code, 24, 8, si_type); } =20 +static void tswap_siginfo(target_siginfo_t *tinfo, const target_siginfo_t = *info) +{ + int si_type =3D extract32(info->si_code, 24, 8); + int si_code =3D sextract32(info->si_code, 0, 24); + + __put_user(info->si_signo, &tinfo->si_signo); + __put_user(info->si_errno, &tinfo->si_errno); + __put_user(si_code, &tinfo->si_code); /* Zero out si_type, it's intern= al */ + __put_user(info->si_pid, &tinfo->si_pid); + __put_user(info->si_uid, &tinfo->si_uid); + __put_user(info->si_status, &tinfo->si_status); + __put_user(info->si_addr, &tinfo->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; + + /* + * We can use our internal marker of which fields in the structure + * are valid, rather than duplicating the guesswork of + * host_to_target_siginfo_noswap() here. + */ + switch (si_type) { + case QEMU_SI_NOINFO: /* No additional info */ + break; + case QEMU_SI_FAULT: + __put_user(info->_reason._fault._trapno, + &tinfo->_reason._fault._trapno); + break; + case QEMU_SI_TIMER: + __put_user(info->_reason._timer._timerid, + &tinfo->_reason._timer._timerid); + __put_user(info->_reason._timer._overrun, + &tinfo->_reason._timer._overrun); + break; + case QEMU_SI_MESGQ: + __put_user(info->_reason._mesgq._mqd, &tinfo->_reason._mesgq._mqd); + break; + case QEMU_SI_POLL: + /* Note: Not generated on FreeBSD */ + __put_user(info->_reason._poll._band, &tinfo->_reason._poll._band); + break; + case QEMU_SI_CAPSICUM: + __put_user(info->_reason._capsicum._syscall, + &tinfo->_reason._capsicum._syscall); + break; + default: + g_assert_not_reached(); + } +} + /* Returns 1 if given signal should dump core if not handled. */ static int core_dump_signal(int sig) { --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643075672801435.99149342904343; Mon, 24 Jan 2022 17:54:32 -0800 (PST) Received: from localhost ([::1]:60794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCB2V-0000B5-Sa for importer@patchew.org; Mon, 24 Jan 2022 20:54:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfK-0002IK-RX for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:37 -0500 Received: from [2607:f8b0:4864:20::d2a] (port=34549 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 1nCAfG-0001hD-Hb for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:33 -0500 Received: by mail-io1-xd2a.google.com with SMTP id i62so6182582ioa.1 for ; Mon, 24 Jan 2022 17:30:28 -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 q14sm2061687ilo.63.2022.01.24.17.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30: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=Z6B0UYkYb5Cq1cN896g5C6kZxdkS9tZeevAeukDKWKo=; b=RLMFTjaXnXId99GyMM5lj0p2YcRt8Ljw4tVjeYNuJgaE+tJgVcvj6I+CVpc46qt/mS 6ZYqXZhwYLVLuIM8VhXBQpq7uyVtJVCjdvip2ADDL4y4qaiGeZXOipD/DB3hQzmQTlMf Qr6MeSNt+EqX43JcspO1b7o4qSJDeCtf3tWc3fsUDFrKApoW1VzPkU3XeLzDQwJmf/yN C551D3REoqRRTJjoogpVKhR54j9zwJt8Zz3IbOnJeTeHOEIvqzOXWYx1qsWtl4mID/qc s7LQVQ04Q2yIRwO2HT4GaIVxF61oRe0AZVYprI3lZ5nbSCMnMgTO2bMaDXhb8PLpgsyU aOpg== 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=Z6B0UYkYb5Cq1cN896g5C6kZxdkS9tZeevAeukDKWKo=; b=zTqD+RucamFfUMi1pi5CTyP67buw71L+g850w63nS3Qwxa7MaVVE2+gHqPRZqTtNK7 2MdL8Z2JWygqJUiJQVJ4KDMFgklT6rlKACMJ8LdLU4jXTwLLW6ycIAabMpVvvfA8TbKd yjQIqXqRJ0X1WjHlqiSaSWgbHnSry7eP5ZvqiuKRQuaVkjMz3aWXlN1SegND27xoAOMd E9ifW1s3Tc/moBGSK4LFYUbTS+MnfBM4tfpB/RsZU/Vw96Lnb2o0f6FonbdCh27b6Kaf KmjKNG3KrspmQOL8WXVWLCTUX95wPjCEOOkvmjQe7BExo7s7Qm8kN8ViIx4mqBAVVnEj HIDw== X-Gm-Message-State: AOAM532slCDMrYW/uo6ZVvV5CW31yWgscKFyEwli7n3lEDrVHyXZAKpk cCBHNe3i8bsSZuKtr98GgXp+nPpiVj7OFg== X-Google-Smtp-Source: ABdhPJxnYaiCykVxwWlHz47RlDslOC+bT9QvLBuyHg6eo/WnJDwnBFgb/ZV/n3Jb07RxYllOLRGjMQ== X-Received: by 2002:a05:6602:585:: with SMTP id v5mr2917876iox.101.1643074227808; Mon, 24 Jan 2022 17:30:27 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 34/40] bsd-user/signal.c: process_pending_signals Date: Mon, 24 Jan 2022 18:29:41 -0700 Message-Id: <20220125012947.14974-35-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075674651100001 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 Reviewed-by: Richard Henderson --- bsd-user/signal.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index aef1fa95490..9ec4354d232 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -755,8 +755,62 @@ static void handle_pending_signal(CPUArchState *env, i= nt sig, } } =20 -void process_pending_signals(CPUArchState *cpu_env) +void process_pending_signals(CPUArchState *env) { + CPUState *cpu =3D env_cpu(env); + int sig; + sigset_t *blocked_set, set; + struct emulated_sigtable *k; + TaskState *ts =3D cpu->opaque; + + while (qatomic_read(&ts->signal_pending)) { + sigfillset(&set); + sigprocmask(SIG_SETMASK, &set, 0); + + restart_scan: + sig =3D ts->sync_signal.pending; + if (sig) { + /* + * Synchronous signals are forced by the emulated CPU in some = way. + * If they are set to ignore, restore the default handler (see + * sys/kern_sig.c trapsignal() and execsigs() for this behavio= r) + * though maybe this is done only when forcing exit for non SI= GCHLD. + */ + if (sigismember(&ts->signal_mask, target_to_host_signal(sig)) = || + sigact_table[sig - 1]._sa_handler =3D=3D TARGET_SIG_IGN) { + sigdelset(&ts->signal_mask, target_to_host_signal(sig)); + sigact_table[sig - 1]._sa_handler =3D TARGET_SIG_DFL; + } + handle_pending_signal(env, sig, &ts->sync_signal); + } + + k =3D ts->sigtab; + for (sig =3D 1; sig <=3D TARGET_NSIG; sig++, k++) { + blocked_set =3D ts->in_sigsuspend ? + &ts->sigsuspend_mask : &ts->signal_mask; + if (k->pending && + !sigismember(blocked_set, target_to_host_signal(sig))) { + handle_pending_signal(env, sig, k); + /* + * Restart scan from the beginning, as handle_pending_sign= al + * might have resulted in a new synchronous signal (eg SIG= SEGV). + */ + goto restart_scan; + } + } + + /* + * 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 Thu May 2 08:44:36 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 1643077059856516.6201781653506; Mon, 24 Jan 2022 18:17:39 -0800 (PST) Received: from localhost ([::1]:48812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBOt-0005YI-73 for importer@patchew.org; Mon, 24 Jan 2022 21:17:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfK-0002IN-VR for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:37 -0500 Received: from [2607:f8b0:4864:20::d2e] (port=34553 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 1nCAfI-0001hR-9V for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:34 -0500 Received: by mail-io1-xd2e.google.com with SMTP id i62so6182624ioa.1 for ; Mon, 24 Jan 2022 17:30: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 q14sm2061687ilo.63.2022.01.24.17.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30: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=MCYcM3kga127WLQBa8pK54CGRf4Pbm+0uZfMuXdE2Fs=; b=jGsEp9Vk+QEL1jUvB+nlAQy1KmXus3PVEqU9JenKjj048qzwPZLFd5YixgQCQtXim8 e1XJ8fa0+ycloOdPUvx/xKmpwLw6H+IsREzDw9aV3xciEaXWORJM53fhag4U5vM+J5ZN ZNXdiLHf6v8sdBmk8mSIu6j1rrIbrSdK2HxnwJHIOB5VCE6a2dSCKXyZ2I+6oqlEdwOh vwWA4DyU93l1FLTAWP3UgFB4RxuXcIIf/m5136jJRY7AXhiM3tIxddADulV+S1YJOS+k vQT3zqfsEIMJczyvXetG39YPlP3l097xntimD4JY1at1g6+uIpYW+oKniIhW+yIoJIcX b3ag== 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=MCYcM3kga127WLQBa8pK54CGRf4Pbm+0uZfMuXdE2Fs=; b=FdiuzLIWOCrPoHBY3gMjcKpTmkDLCSXhplTyCBjfmdwGaR2VvhYn+GVUUYvTu0BwQm 8+Dr6Ho8A+OA1CTpjma27eg0Oij6F9F/w6dl2dmD+wigRho5tyBo9W+3LpzWRifHEgtG lqU6KYN0ViLZoNNsjQNU2fWaAeIHU0urcCOjJ4Mp1dC+K8qUrkwE/BdvRSXp8IrhZcRn ziDs8aJZMvZ4zkFe899UZBEI2K7aMUEIN3SSkZNzLM1p8Fj8hHRT38ZaW5ST6j9lN6AW MWOdlZ9vQm8fm+uR5c+/qSAgWCotTNmhEhLB7UJ60n9U8UaF2VBKSii6ssDc2NlMAHGC Xl8g== X-Gm-Message-State: AOAM531FkG7XnBfb25vlTw6ULFqe7T4M5FZYWGiFnkRSp9mlFNbMz0iG fBBUrTiSA4ENsR9Deyv4mCIEuej3808pXw== X-Google-Smtp-Source: ABdhPJwVJyAIMzG0ZKTV0VQHkhwrnE+Exm0VmgizHfkDo8dvzWyP5l3xB/cgX08KoVQ5D8t8LZ8WvA== X-Received: by 2002:a05:6638:272c:: with SMTP id m44mr8608672jav.320.1643074228896; Mon, 24 Jan 2022 17:30:28 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 35/40] bsd-user/signal.c: implement do_sigreturn Date: Mon, 24 Jan 2022 18:29:42 -0700 Message-Id: <20220125012947.14974-36-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643077062043100001 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 PENDING COMMENTS: from Peter Maydell do_sigreturn() itself shouldn't be setting the active signal mask, at least if you follow the linux-user design. It just sets the thread's signal_mask field in the TaskState by calling set_sigmask(), and then on our way out in the main cpu loop we'll call process_pending_signals() which sets the real thread signal mask to that value. (This, together with do_sigreturn() calling block_signals() before it starts work, avoids some race conditions where a host signal is delivered as soon as we unblock, I think.) --- bsd-user/signal-common.h | 2 +- bsd-user/signal.c | 56 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/bsd-user/signal-common.h b/bsd-user/signal-common.h index ee819266f54..786ec592d18 100644 --- a/bsd-user/signal-common.h +++ b/bsd-user/signal-common.h @@ -11,7 +11,7 @@ =20 long do_rt_sigreturn(CPUArchState *env); abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp); -long do_sigreturn(CPUArchState *env); +long do_sigreturn(CPUArchState *env, abi_ulong addr); void force_sig_fault(int sig, int code, abi_ulong addr); int host_to_target_signal(int sig); void host_to_target_sigset(target_sigset_t *d, const sigset_t *s); diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 9ec4354d232..05caf812ccb 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -626,6 +626,62 @@ static void setup_frame(int sig, int code, struct targ= et_sigaction *ka, unlock_user_struct(frame, frame_addr, 1); } =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; +} + +/* See sys/$M/$M/exec_machdep.c sigreturn() */ +long do_sigreturn(CPUArchState *env, 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(env, addr, &target_ucontext); + if (is_error(ret)) { + return ret; + } + trace_user_do_sigreturn(env, 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(env, &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); + } + return -TARGET_EFAULT; +} + void signal_init(void) { TaskState *ts =3D (TaskState *)thread_cpu->opaque; --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643076250205690.5428419010248; Mon, 24 Jan 2022 18:04:10 -0800 (PST) Received: from localhost ([::1]:52124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBBp-0004z4-DI for importer@patchew.org; Mon, 24 Jan 2022 21:04:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfL-0002Io-C6 for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:43 -0500 Received: from [2607:f8b0:4864:20::d2f] (port=38772 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 1nCAfI-0001hz-9n for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:35 -0500 Received: by mail-io1-xd2f.google.com with SMTP id w7so21897841ioj.5 for ; Mon, 24 Jan 2022 17:30: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 q14sm2061687ilo.63.2022.01.24.17.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30:29 -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=AdXJK5vRD+aFmx8B1X94UEIrCjBlqtw2OQzi+bUw0AU=; b=Dkr9I2cPXs7Lgl3kR6j/1EM2oiWrz5om0yhmvWhSb38qeEHYuqu/PZn3JBkieSSQPl gB7ugETgN++b/oX7cUd+fajGDs8u4wu6IktSXk5d9rDTB96fi+WLXfl9JrVNAtomqzZg u3qx3vHJoWODzfFYRJm5Mj3zlbkqBZxQdBO5guYx1T0WJpbJ5RCj6iX21UelRvfDb075 Ebf9sTa3Om/AiQ/FWzjShUt38L6G8h20kCWciUePlLJEMwLANAVHBoznpQ4siEnBBF8E MbcbgB+vWeWINCRig9z9eekliA1pAHW5YHVrvD7fdj/GiRAoeVCoucoCfJGodk1bAzQW aOoQ== 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=AdXJK5vRD+aFmx8B1X94UEIrCjBlqtw2OQzi+bUw0AU=; b=qYzhLBh94r3iemloBn3/8n1MgZTYfrlUiunDFlrTvufbYfuNek2xz9ekQTJkiU+1Lt lMwwt8A015GI/Gaqr/xVSNCjZ9URPKzt3U+vihdTz/agEC4praxCdeydFF5gdjvnAFLU MQklA3t9eHLZsegwLO4YXsM3XBMTyhiaiDZxcCnEHpMI1QcvZ4ggPCFiZvcyG5iW1vdU r5tq42OkVjrwhPCniRZD9DC0xXhLpbjWq3V/EWbb4EPN15PhqUx8pZkvuc5nVrH3FIpM 8celFIs7KOBQ1mDPKdpHvP1y8umzDnF6Ww93lvZqNFumFsqKqFWKnXn34dEdTa7hkP7Z 1pnQ== X-Gm-Message-State: AOAM532LYyaEJA6ZZ8C3JiXyu+c+yn3ktB0a4IOMhO0ljR0juPwHdvMU ryWjVeTEgRthpgMB5789RxcSNbyJoi+QbA== X-Google-Smtp-Source: ABdhPJwWpx3Oz8MIYQngu3708fBMG2QuPuXuZn7LIw3Hz/Io4SexvImyVo7ewOXUu7QMrRoHJTeROg== X-Received: by 2002:a6b:6211:: with SMTP id f17mr9236724iog.216.1643074229962; Mon, 24 Jan 2022 17:30:29 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 36/40] bsd-user/signal.c: implement do_sigaction Date: Mon, 24 Jan 2022 18:29:43 -0700 Message-Id: <20220125012947.14974-37-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643076251319100001 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 Pending Comments from Peter Maydell (1) in block_signals, sigprocmast For linux-user we rely on sigprocmask() in a multithreaded program setting the signal mask for only the calling thread, which isn't POSIX-mandated. (Arguably we should use pthread_sigmask() instead, but we don't for basically historical reasons since linux-user is host-OS-specific anyway.) Does BSD have the same "this changes this thread's signal mask" semantics for sigprocmask()? (2) do_sigaction, first if validating which signals can be sent Kernel seems to allow SIGKILL and SIGSTOP unless act is non-NULL and act->sa_handler is SIG_DFL ? https://github.com/freebsd/freebsd-src/blob/main/sys/kern/kern_sig.c#L747 (Compare linux-user commit ee3500d33a7431, a recent bugfix.) (3) Noting confusion in do_sigaction between host and target errnos (they are identical on BSD, but we should still return the right sort in case it ever does matter). --- bsd-user/signal-common.h | 22 ++++++++++++ bsd-user/signal.c | 76 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/bsd-user/signal-common.h b/bsd-user/signal-common.h index 786ec592d18..7ff8e8f2e40 100644 --- a/bsd-user/signal-common.h +++ b/bsd-user/signal-common.h @@ -9,7 +9,29 @@ #ifndef SIGNAL_COMMON_H #define SIGNAL_COMMON_H =20 +/** + * 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 */ + long do_rt_sigreturn(CPUArchState *env); +int do_sigaction(int sig, const struct target_sigaction *act, + struct target_sigaction *oact); abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong= sp); long do_sigreturn(CPUArchState *env, abi_ulong addr); void force_sig_fault(int sig, int code, abi_ulong addr); diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 05caf812ccb..42021556d65 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -309,6 +309,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) { @@ -554,6 +570,66 @@ static void host_signal_handler(int host_sig, siginfo_= t *info, void *puc) cpu_exit(thread_cpu); } =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 || sig =3D=3D TARGET_SIGKILL || + sig =3D=3D TARGET_SIGSTOP) { + 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 *env, size_t frame_size) { --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643077307894976.5455342904849; Mon, 24 Jan 2022 18:21:47 -0800 (PST) Received: from localhost ([::1]:53000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBSt-0008RM-4h for importer@patchew.org; Mon, 24 Jan 2022 21:21:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfL-0002Iq-Kp for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:43 -0500 Received: from [2607:f8b0:4864:20::d36] (port=46748 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 1nCAfJ-0001iH-EY for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:35 -0500 Received: by mail-io1-xd36.google.com with SMTP id e79so21850537iof.13 for ; Mon, 24 Jan 2022 17:30: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 q14sm2061687ilo.63.2022.01.24.17.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30: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=qw0iKda6K/BG/4NkGq3qGLHqviR4+9EjUAirJBptKSg=; b=vE/wuRmr+pfr56k7pnnLZnvYXgb0KjZ3Kk660eW1r5X1BdSrBw5nRU3nYoPUUG56bX BOg4wNIGcU6Tn8lDBxBQz3/Lc7q5yN8jg/iVzI8CrFGkG0Mf07ONAyXEYjX/eDQHeUgT pghTBbzP/HNXZagT9L/ziGQSneJO0bxRj5twyYSBAq6pLY4T134oD+DEImbz6Q142yj5 iXgEc4tltPYmirfsAD3X8lk30OhXx8bBubuMsUN7vQdlOX8KMRkHuwKw5K0WvSo9VvUh We/mJ2/5D/3lQF7zyr2c/DElNzMTyn2xMlQy4J0a0RkAijwkboAScxQXezsJGFkcaH6k o89g== 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=qw0iKda6K/BG/4NkGq3qGLHqviR4+9EjUAirJBptKSg=; b=GK0ZoZAlswig3fKOWdm5P0abj3blkXViGT1euebnqT2ePGcgzCtwK7wDYwGcYHKVQ5 uHqgpdB7eE47Jn/Dq4K4R4huCmfo89bt5gWOlOrQHTbwF7ZPEdLE7Elx8GRr3TtD3S/H reKCYKKNmBnowYYL55ayxZqNNer2LNgwrrzTqJ6u8JoRuvE3fmigRjSQey+r9SR6ssYO qxnTCkY67QIBGtUWo/6/BLuFiIJl3aOM5gQr/2jm3f4B1ApIIY0tFuZ4eIS60KS5kVH7 cKD5Psjdy462401jMq85IDG86yyizTilXH4y+ZiD9uQ4ji0DGkC+ZhC2EFltEjW4CA4O GhEQ== X-Gm-Message-State: AOAM531PRzu/b9HZYqKM8BMDhGLYRyI6khGV7TONzL+QZ7JiQRTeuug3 TapZR9ATtD7e6KxNqxV0o+QNRaBsHv3j5w== X-Google-Smtp-Source: ABdhPJyTUudy6xdbqsh7I6LyBPaDZXKVt+kfVF+UTKmV696muKK864AGLNpg0IKw25V+598+wPlJLA== X-Received: by 2002:a5d:88cb:: with SMTP id i11mr9537596iol.119.1643074231128; Mon, 24 Jan 2022 17:30:31 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 37/40] bsd-user/signal.c: do_sigaltstack Date: Mon, 24 Jan 2022 18:29:44 -0700 Message-Id: <20220125012947.14974-38-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Stacey Son , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643077309092100001 Content-Type: text/plain; charset="utf-8" Implement the meat of the sigaltstack(2) system call with do_sigaltstack. With that, all the stubbed out routines are complete, so remove now-incorrect comment. Signed-off-by: Stacey Son Signed-off-by: Kyle Evans Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/signal.c | 72 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 5 deletions(-) diff --git a/bsd-user/signal.c b/bsd-user/signal.c index 42021556d65..4ec5598eb43 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -25,11 +25,6 @@ #include "hw/core/tcg-cpu-ops.h" #include "host-signal.h" =20 -/* - * Stubbed out routines until we merge signal support from bsd-user - * fork. - */ - 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, @@ -570,6 +565,73 @@ 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) +{ + TaskState *ts =3D (TaskState *)thread_cpu->opaque; + int ret; + target_stack_t oss; + + if (uoss_addr) { + /* Save current signal stack params */ + oss.ss_sp =3D tswapl(ts->sigaltstack_used.ss_sp); + oss.ss_size =3D tswapl(ts->sigaltstack_used.ss_size); + oss.ss_flags =3D tswapl(sas_ss_flags(ts, 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(ts, 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; + } + } + + ts->sigaltstack_used.ss_sp =3D ss.ss_sp; + ts->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; +} + /* do_sigaction() return host values and errnos */ int do_sigaction(int sig, const struct target_sigaction *act, struct target_sigaction *oact) --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643076537760314.5979896432183; Mon, 24 Jan 2022 18:08:57 -0800 (PST) Received: from localhost ([::1]:59714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBGS-0001lt-Lg for importer@patchew.org; Mon, 24 Jan 2022 21:08:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfN-0002Ix-Rk for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:47 -0500 Received: from [2607:f8b0:4864:20::d2c] (port=44724 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 1nCAfJ-0001iR-PY for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:35 -0500 Received: by mail-io1-xd2c.google.com with SMTP id h23so21793540iol.11 for ; Mon, 24 Jan 2022 17:30: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 q14sm2061687ilo.63.2022.01.24.17.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30: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=vBJhsJ5JDmPAbCw0pkCICn7DGftKZRdcsDaqxXoafK8=; b=K2FTHJPdwmrsdqIi5KBKsm8r1fxfV84ZkkaH9/33iCm+z8hbti0krUXKvx8KiMPcO8 SDqj5mQEQc448n9bxXMjUyo2ItuH5ST7O10EubeXDht1pksG3RJ8VvXIZdtK67mKxUhp c4V40dSqypPShHzPTU+wykr64dutKjIRg50G6I7AUdBrCJeGZXzmAXhfZ3S0ESDpv5py NVb9f8BKdvELMWhnBcMTVWQA4UlU6Ffv8mX41yXM4EoLrTAbJjSnfRbn0UvNMlfab3p2 2GLBUf58kd+PGmA3oJTdJfUrMTgStEU94EnoRNCt+Q6RUzXdAxXa5ZlR4WAKcr0QdS9k DyDQ== 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=vBJhsJ5JDmPAbCw0pkCICn7DGftKZRdcsDaqxXoafK8=; b=WQI35PxC/gM/nB4256g7SbveetiBScYH3NKArPgail8KVBDiysVRXpeG980Sd6Hk30 6ktMXn+Y82h0F7rcdvctm6Ep37GY1/09ROC5OBZ6k5PE1D1VuGG51yt8g0L0/1dujbzt Cx4LyN++vNutcBzCMDb1FCIZnufpKAezwSjh8/X+y5c6PczSETGFtmm9C3ATpeN6wLG1 qjQCmjOCmxwtPCDJVDa8Ub4cIUt82CgbC+6P6ePFWZ2Bmqm2T72iGweuJnv9uYnPmI+v Y6QYFFpuWAgy0Hu1XXhui/ZVCWC1XVngYp/hm8oOgpsfIcQsi60fZ74zQ/9UUh3AFqWx K0iw== X-Gm-Message-State: AOAM53155qQWDXEU8nXQ7Qw7UvjZnZbnfiTYTfWTkBDlhO3ik+A6r1mg V/mz3A78ATf9CngjF2UbBEdGVcaScn9I8A== X-Google-Smtp-Source: ABdhPJx55RVkwgngaC9lSEFCGzFIJ9Zfv4xueLYKMlm8mzAHH42DCjVXMeJb6YlckBh4ocoT9vcpqw== X-Received: by 2002:a02:a101:: with SMTP id f1mr7618793jag.12.1643074231911; Mon, 24 Jan 2022 17:30:31 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 38/40] MAINTAINERS: Add tests/vm/*bsd to the list to get reviews on Date: Mon, 24 Jan 2022 18:29:45 -0700 Message-Id: <20220125012947.14974-39-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643076539659100001 Content-Type: text/plain; charset="utf-8" tests/vm/*bsd (especailly tests/vm/freebsd) are adjacent to the bsd-user stuff and we're keen on keeping them working as well. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index c98a61caeee..a2809761f65 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3101,6 +3101,7 @@ R: Kyle Evans S: Maintained F: bsd-user/ F: configs/targets/*-bsd-user.mak +F: tests/vm/*bsd T: git https://github.com/qemu-bsd-user/qemu-bsd-user bsd-user-rebase-3.1 =20 Linux user --=20 2.33.1 From nobody Thu May 2 08:44:36 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 16430758542590.6660096022360449; Mon, 24 Jan 2022 17:57:34 -0800 (PST) Received: from localhost ([::1]:41146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCB5R-0005xF-8d for importer@patchew.org; Mon, 24 Jan 2022 20:57:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfN-0002Iw-RT for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:47 -0500 Received: from [2607:f8b0:4864:20::d29] (port=46736 helo=mail-io1-xd29.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCAfK-0001ia-It for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:35 -0500 Received: by mail-io1-xd29.google.com with SMTP id e79so21850662iof.13 for ; Mon, 24 Jan 2022 17:30: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 q14sm2061687ilo.63.2022.01.24.17.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30: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=RYOIzW6/ZHDz9enhrfWJlbCeES2xGOl72iMdp9Riye4=; b=lNFVxgTZ+THyEJ7Cc8cUcGQYskycK9GIBir6c2xol5CEM1Lru44SppMDi3dsSnO/IP BcC9dE/LHZkuB24YU1McVbZdyj6/AJ1KAWb/fXTZkW+zydb9JoBF+ab+t1V124Xs5tqc s7M6XP9DEz38t5G/FAscEyBA0lmkqXTTdQOD9OtpgiSlRGYrFkHdWaNFMsb4Yz01oLZm pjAhpMAYDWxTSmlVI5Yv1tyi/ULImRTX+8jvktD3S3MtZ8Ge912uCJFvqK+7NXrBh8td ng7BFZJGdp7TmVbylooNIvDyXNn6QXuwh06X0yfVP5WTiPxhiBpUziHYnY1SKakn+GH5 7WIg== 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=RYOIzW6/ZHDz9enhrfWJlbCeES2xGOl72iMdp9Riye4=; b=6GeZ992bCVw+HGlzVRs10eslyeODVqz63DNaJFsE+Rfjq0tR7RzJdDaVX5dLol4o9p 8+hiey2Fq/vfXneqE/7dlpy5OYwSOzB7NFoQQcY7sLJSodKZJB9Yqgs/T1AnzJYpMbKP BcO8RMWLVhcWCrMjSqIj3mxyDPBmDBEygBvTtCUDk/QLkSX3EJGPlppwAvNMJkIa8TSE tzAsuRsblxdz/W010XmhVNPsvGCT4mfEtGBgAWO+SfbCtG/jM+Hd9MN2v1UhFU4Wdr59 uZ1ckHUT9AXAs0SE4p5p0f9zqbzWTOUGxrvl1vT0u4lmT/WuX9H/QyRDqxlZBkwUQbpm zf6g== X-Gm-Message-State: AOAM530dGQJU9R35x6rRyuypkYRcPB3S5veEWrifokqN/zEiqOMhvXDG lbxWnAMOACRyuw08HM7GUoN6re9848ahdA== X-Google-Smtp-Source: ABdhPJzHGHHELHPwGaB9lyQwtZAMUjd1qcmuGd+s30BDMrNmG8wddnPcGO7OUN8+5xdKt23lC45f0A== X-Received: by 2002:a02:77ca:: with SMTP id g193mr7048206jac.166.1643074233002; Mon, 24 Jan 2022 17:30:33 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 39/40] bsd-user: Rename arg name for target_cpu_reset to env Date: Mon, 24 Jan 2022 18:29:46 -0700 Message-Id: <20220125012947.14974-40-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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::d29 (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::d29; envelope-from=imp@bsdimp.com; helo=mail-io1-xd29.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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643075856945100001 Content-Type: text/plain; charset="utf-8" Rename the parameter name for target_cpu_reset's CPUArchState * arg from cpu to env. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_cpu.h | 2 +- bsd-user/i386/target_arch_cpu.h | 4 ++-- bsd-user/x86_64/target_arch_cpu.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index 2f1ab4c6ac2..a52c39f6943 100644 --- a/bsd-user/arm/target_arch_cpu.h +++ b/bsd-user/arm/target_arch_cpu.h @@ -213,7 +213,7 @@ static inline void target_cpu_clone_regs(CPUARMState *e= nv, target_ulong newsp) env->regs[0] =3D 0; } =20 -static inline void target_cpu_reset(CPUArchState *cpu) +static inline void target_cpu_reset(CPUArchState *env) { } =20 diff --git a/bsd-user/i386/target_arch_cpu.h b/bsd-user/i386/target_arch_cp= u.h index b28602adbbd..91849b5804a 100644 --- a/bsd-user/i386/target_arch_cpu.h +++ b/bsd-user/i386/target_arch_cpu.h @@ -199,9 +199,9 @@ static inline void target_cpu_clone_regs(CPUX86State *e= nv, target_ulong newsp) env->regs[R_EAX] =3D 0; } =20 -static inline void target_cpu_reset(CPUArchState *cpu) +static inline void target_cpu_reset(CPUArchState *env) { - cpu_reset(env_cpu(cpu)); + cpu_reset(env_cpu(env)); } =20 #endif /* ! _TARGET_ARCH_CPU_H_ */ diff --git a/bsd-user/x86_64/target_arch_cpu.h b/bsd-user/x86_64/target_arc= h_cpu.h index 5172b230f09..535aa9192da 100644 --- a/bsd-user/x86_64/target_arch_cpu.h +++ b/bsd-user/x86_64/target_arch_cpu.h @@ -237,9 +237,9 @@ static inline void target_cpu_clone_regs(CPUX86State *e= nv, target_ulong newsp) env->regs[R_EAX] =3D 0; } =20 -static inline void target_cpu_reset(CPUArchState *cpu) +static inline void target_cpu_reset(CPUArchState *env) { - cpu_reset(env_cpu(cpu)); + cpu_reset(env_cpu(env)); } =20 #endif /* ! _TARGET_ARCH_CPU_H_ */ --=20 2.33.1 From nobody Thu May 2 08:44:36 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 1643076192732569.866550900183; Mon, 24 Jan 2022 18:03:12 -0800 (PST) Received: from localhost ([::1]:49780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCBAt-0003Rr-TQ for importer@patchew.org; Mon, 24 Jan 2022 21:03:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCAfd-0002Lx-ON for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:53 -0500 Received: from [2607:f8b0:4864:20::d34] (port=35754 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 1nCAfL-0001ip-DV for qemu-devel@nongnu.org; Mon, 24 Jan 2022 20:30:43 -0500 Received: by mail-io1-xd34.google.com with SMTP id 9so6250672iou.2 for ; Mon, 24 Jan 2022 17:30: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 q14sm2061687ilo.63.2022.01.24.17.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 17:30: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=A1ZBzgH8dEhST4JS/JsP+0ckGcGlmqn92Dci6AKt6gs=; b=JBnpK3lpc6yP1mY5x8N3AKuqdlGNR5NkhPPrckkpzSgem0FByaYDKR9KU/qxDqbTOU D0zUvJWnTnzIyvi67LtT1zaaeQW6nfg+2pBHB6ZQ3wZPmecW+68vqBitBO4QaYq78DVO F92JJKAXTDKliVvm+ARzvtD8rtfLkphVwFJ5A5EEhyrbkrMmgZR4kmg8fax9jb8AYeU4 wG9DeKnObRYWPeMbSdtgzYUZvh/Tp1Us5Oe36CJyz48cXM2XC/Ra4556MpPmQhm6RtQo F029VS1d/Mbg4VREV7/rcsS42rQMZ27Dex6+pK9jCLPN4ZP+sxN9AVwPLRrjGnyuczNK OI/A== 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=A1ZBzgH8dEhST4JS/JsP+0ckGcGlmqn92Dci6AKt6gs=; b=j6QqgwFhrO+LFy8QkSqdAfP9gd94B7vq7MoC3sL6Hztx0hZZ/4f67XhhCpqzAnYQvw askdlMoo003yqJhvkYXpZPyNT0n52iX0K0vSRJSXM5UJ1y1VWDNSB7NPkl3YZOJKzMXu TUBwXfJRTmM4nJwI9m1Q0qwGC0d7CECcWuilWlAIV80JmGL017sfPBDKoAqIlpwClErM AgeagO87/sp7sBJUNaCdTLNFFWuLjun6ovUY/xlNPXQpEjZ+YavJAsT7urWLqz+5r5Wh zRZe2WERN3Is+Yg2FLwInGduBE4M/P/G+nUw+zkO1bi50PxsNgLU0x6a3I2FoIYvcL9V +A0g== X-Gm-Message-State: AOAM530n8b+f1mRLxGF7ZtJACJIdSi25ngd1lyB4x9i/wd0tN5n4p8rt qLN9Bx4+IBEfs/PozF4XD/EvqJRmkPwgpQ== X-Google-Smtp-Source: ABdhPJyG2BC7rE5hOoipnQSNye573NevVZ40DWeYLaePLlQvOZA0Tgs0mGL76+mJJDeM+6xNEuXl4Q== X-Received: by 2002:a02:c551:: with SMTP id g17mr100274jaj.305.1643074234061; Mon, 24 Jan 2022 17:30:34 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v2 40/40] bsd-user/freebsd/target_os_ucontext.h: Prefer env as arg name for CPUArchState args Date: Mon, 24 Jan 2022 18:29:47 -0700 Message-Id: <20220125012947.14974-41-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220125012947.14974-1-imp@bsdimp.com> References: <20220125012947.14974-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, PDS_HP_HELO_NORDNS=0.001, 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: Peter Maydell , Kyle Evans , Richard Henderson , def@FreeBSD.org, jrtc27@FreeBSD.org, 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: 1643076195230100008 Content-Type: text/plain; charset="utf-8" Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/freebsd/target_os_ucontext.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bsd-user/freebsd/target_os_ucontext.h b/bsd-user/freebsd/targe= t_os_ucontext.h index 41b28b2c150..b196b1c629f 100644 --- a/bsd-user/freebsd/target_os_ucontext.h +++ b/bsd-user/freebsd/target_os_ucontext.h @@ -36,9 +36,9 @@ abi_long set_sigtramp_args(CPUArchState *env, int sig, struct target_sigframe *frame, abi_ulong frame_addr, struct target_sigaction *ka); -abi_long get_mcontext(CPUArchState *regs, target_mcontext_t *mcp, int flag= s); -abi_long set_mcontext(CPUArchState *regs, target_mcontext_t *mcp, int srfl= ag); -abi_long get_ucontext_sigreturn(CPUArchState *regs, abi_ulong target_sf, +abi_long get_mcontext(CPUArchState *env, target_mcontext_t *mcp, int flags= ); +abi_long set_mcontext(CPUArchState *env, target_mcontext_t *mcp, int srfla= g); +abi_long get_ucontext_sigreturn(CPUArchState *env, abi_ulong target_sf, abi_ulong *target_uc); =20 #endif /* TARGET_OS_UCONTEXT_H */ --=20 2.33.1