From nobody Sat Feb 7 08:02:22 2026 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 1643412834170799.718014889584; Fri, 28 Jan 2022 15:33:54 -0800 (PST) Received: from localhost ([::1]:36248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDakZ-0003TS-G6 for importer@patchew.org; Fri, 28 Jan 2022 18:33:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDaf0-0008Ru-6j for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:06 -0500 Received: from [2607:f8b0:4864:20::d31] (port=39666 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 1nDaey-0001Vs-2m for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:05 -0500 Received: by mail-io1-xd31.google.com with SMTP id c188so9689652iof.6 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=q2wkolIh2lCmSomI63wI2LjQYXEA5OUzuuGqVAAxz7A=; b=eoHolp6VAsu4nrTykIcCClKiVglqXAB5LdS0OYymnoRNWrZ/2S1blPKkOk17YCFCOJ xLPvWzYVOW1yx9ue0BmJPOyj9QvftQghXs2G3YKr3KTK+BjFfmisL+zvq7qcUN/gK7uw 3kT8x6gh2D9DK2PDR5XxOaD5W2/Rzk3vMk9u4+1CBti9PH1X2LUcT5PORTTs7owDfaCX abZ5rPxKJESshqpOUk6ffORQrua2K7263xBjvvNk2qG3iFkyBtANzX7mr9h3nsosFWft FfeJcOStfgFjJpUhUI8z1eziS2E1GeUlgby5pwgo+GHV42A3CTWNud4hD+u+1XculZe1 Yr7w== 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=q2wkolIh2lCmSomI63wI2LjQYXEA5OUzuuGqVAAxz7A=; b=3CHdKyWmRelql6xMKhOxAUOCCRGS5pWfv+z+yzXMfMdsEF0HB48Dn1SYPKhTtpD7+B H/O6369ZQxNx0t2lggmjZliBVCJ58CLcwsZXnwtK8O4XX5mtKKFn3Ljps+/w66aISL9c Vcf6bLj2p1SN5D1Kg+8hclF0FDxeUzGigGIVeuotbHDg/Sf8YiHw3HGoCugSD+Q+hyAU U16kxlD0EkPFAUnh9Y4UF5nRkFOcbZVqS8iyf5ohhJjNMcTHURuZW786KNDmMdJZnbai vNNN3Y801JLQ85dol9hZfMJGvXwrLDsJW99DXrp8KFLULwhsZSCsPTPQ+v5FlN+LYrGf ttrg== X-Gm-Message-State: AOAM531pxS8zsoAnwPmwP9dN4Wk0U9952ieGkvVfREQz1IqhAKHTHQKA M5n5Fjp84J80ABLh8cSPdA5ML91GRH8E1Q== X-Google-Smtp-Source: ABdhPJxUgfLJvYhzhLRaQXS91tIl95CgzWUHkfhLqScUGKx15K6nuu1VvbeBYCSAdmtQFvWWnXsGgQ== X-Received: by 2002:a5d:8341:: with SMTP id q1mr6387464ior.185.1643412481983; Fri, 28 Jan 2022 15:28:01 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 01/40] bsd-user: Complete FreeBSD siginfo Date: Fri, 28 Jan 2022 16:27:26 -0700 Message-Id: <20220128232805.86191-2-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643412836517100001 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 Sat Feb 7 08:02:22 2026 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 1643412946396777.6857288940405; Fri, 28 Jan 2022 15:35:46 -0800 (PST) Received: from localhost ([::1]:40182 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDamP-0006E0-Mz for importer@patchew.org; Fri, 28 Jan 2022 18:35:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDaf1-0008Tm-Fk for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:07 -0500 Received: from [2607:f8b0:4864:20::d2a] (port=44823 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 1nDaey-0001X5-Df for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:07 -0500 Received: by mail-io1-xd2a.google.com with SMTP id p63so8828911iod.11 for ; Fri, 28 Jan 2022 15:28:04 -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 o11sm14323111ilm.20.2022.01.28.15.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=kxfL+Uf67jAojsgUJ24l/wKbWp/n0flIHdow2eRHTNw=; b=Cy5fD63LEKmvglTo90Kgza9uNxYTowdqL3l83Rhhx4x2TS2t/ES6Ka3xZ33ZXmR2wa L6kW5G4J3qOwBvNE8lyKNJ7pKu6bRnebmkGC3xNIPNzEvKE74VX2JEtYH70ecN3I1+FP y1mj7HRjjRtmYm9aI+3r1p9i1u6MRK6vF7aEssInzEqGv8qUirTBG7E54LdIKd3r9soZ k0lQakEHRAzd5/OdP9hjivHoGsk255ClU57mcB/ZVVYmInzNk/Iabiax36RLVEnT6M3p K4D9wRJPupprXH7u4O0WACtYnL/nFclXCVO87YyNhCS1Za9jmi29vpX5OXPY26hrjM4q CGLQ== 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=kxfL+Uf67jAojsgUJ24l/wKbWp/n0flIHdow2eRHTNw=; b=EONK/dIijZ/SRmiuH5tAUXgL67zYUo/s/gm6XCWAAvw4hDOcUWknDatFs+GFioVrsT HmgNn+PRLGT5MlD+Eid5MqRJKOXAYyI9axhRDBA7t3+T89j8rnQQarqCsBFaNXLI4jeN NXtJJj3gmNixuQgnbUCL65MAIFYU2Q/Vp2ViXNGy0Eh7w59/OIDxwN10LuUya1Wdtw7q qrb2K0pTdyUc0kfweAn9QT95nafpVsiT960mGGzYyS18QFRdcC4xg+mGhBq4oLIUH7dW CPT77vTsDIqe8mXF2IaID9WtfsMBUPD+5hCr5pwYg6aSQr3Xg3NQrU4YQeWrgS6OKGNh vw8g== X-Gm-Message-State: AOAM531/RZEoxMBozQi09/xo0m3SKUPgsDP9NUfrwqf7td+FpRztGcSp 9QcwUH5lZJWgs2KLk66JLa6WWcq73QXr/A== X-Google-Smtp-Source: ABdhPJwgthcwvCOVUNIs7s3X0PHgjKnUr5OJHQ3eb3Qa6pogUJaHjQbYIporGUL7BI7g/KRNQxhO3A== X-Received: by 2002:a05:6602:121a:: with SMTP id y26mr6673673iot.1.1643412483104; Fri, 28 Jan 2022 15:28:03 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 02/40] bsd-user: Create setup_sigframe_arch to setup sigframe context Date: Fri, 28 Jan 2022 16:27:27 -0700 Message-Id: <20220128232805.86191-3-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643412948757100001 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..43700d08f71 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 *env, 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 Sat Feb 7 08:02:22 2026 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 1643412834250256.4809465989034; Fri, 28 Jan 2022 15:33:54 -0800 (PST) Received: from localhost ([::1]:36382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDakb-0003YY-GN for importer@patchew.org; Fri, 28 Jan 2022 18:33:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDaf1-0008Ts-Io for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:07 -0500 Received: from [2607:f8b0:4864:20::132] (port=42581 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 1nDaez-0001XP-GY for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:07 -0500 Received: by mail-il1-x132.google.com with SMTP id u5so6739919ilq.9 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=TqTK+KI3YcgM6rmeXyGDTKC+kTxHQQ89yzMVSFkLyKI=; b=Hd3Wq8I+R5yACIFm7mqb87NukpSthJMdFfp6JthvEn/Dub3rMSoh+iNY3ckKygSIzx W/ohQCfHMM6Wn32PkYR6fVznnDTt/rBH9hEQHFC3r39VCxpXMMzMExZRcFceUEJO2Sax lz9FrJMNTiDdGL4pvKNzTFnvBFXLCZc4H47pOXZhd4NhS0wJpJGM3hXkBmN3CgdPXW2c IXjPde9fa5OdZvxQqFJJ02Ilmd6whKUmmY8Ak5SpWkzL1steoj7QcCZ08csnC+NXfcgo XRZV6ixxJVIFm8MPZvEuYYNZaxYx/WQZ81awvR3JKHBiPMFvX6RPvlWvU2h00Eacu+pV pUMg== 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=TqTK+KI3YcgM6rmeXyGDTKC+kTxHQQ89yzMVSFkLyKI=; b=jgGEMM+793gSbPDzVfF5IzlokbwEd5/v2BrUrFpCNwWHZYx6zfV8t1GeJ/Ok5l3Lob WK4Tbsn4VzT/myklyteHQeUQ00zer19TccjZfOs2dsB5WRVto00QUY+g9+p6dEGUpG/i IDIrW/WFpi2EYQqz70J09H0hNz3S94T1E2J3g4Nl5mSO0wNbvIGrUOB2NKBSJrhN9Srz ywzWmz9eNUp5mBXJFujblRXaje7tIVBTfh6ONwkPNAsZeB3j6X6em68Y6X7hXcN8Mv24 oDInyxqyhb9GoqMrP78FgLjycdPwFnU6bvxgq9sDVudHg42WSHRCpt47tODfu5Lj8Uz4 v/Lg== X-Gm-Message-State: AOAM533NPTm8fMTpyO7iDJb6BWXGCHsuJz4iYrJEofFFkiQ70dM4yrWx kqZaQa5RNNRAzXW72st8kL1XZB9+u3KENg== X-Google-Smtp-Source: ABdhPJy4uqiMyXj5pnSF0x6xhE1ZvN6lLGENU2mPcoZr90Ou5PpG7odY9SQs7zIpCVL5xqtZw1NCwQ== X-Received: by 2002:a92:c569:: with SMTP id b9mr2686601ilj.132.1643412484109; Fri, 28 Jan 2022 15:28:04 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 03/40] bsd-user/arm/signal.c: Implement setup_sigframe_arch for arm Date: Fri, 28 Jan 2022 16:27:28 -0700 Message-Id: <20220128232805.86191-4-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643412837554100003 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 ++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 17 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() */ --=20 2.33.1 From nobody Sat Feb 7 08:02:22 2026 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 1643413078218240.05816618178687; Fri, 28 Jan 2022 15:37:58 -0800 (PST) Received: from localhost ([::1]:45344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDaoX-0001Uh-H8 for importer@patchew.org; Fri, 28 Jan 2022 18:37:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDaf2-0008Ui-0s for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:08 -0500 Received: from [2607:f8b0:4864:20::d34] (port=33790 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 1nDaf0-0001XV-9H for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:07 -0500 Received: by mail-io1-xd34.google.com with SMTP id y84so9767974iof.0 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=k9zDtgXS+L05+ekpD7VMpQo1Lh9R8HC1kSXvuE27qsY=; b=vPe0G4qPQRHboU6hfGKF9oJrby3F7Ghjbx/PDoDIDScE1IdtTifGuKJUGCoOBk+spM ahcEMQnSjn71T969Tm6QD9y20Ld4sSBQkKf/CUYsuW19gUVLiItXfPintBEfLFITSQR2 dh8gm5dzjAJmDwmy1DkGCr1ASQiTGKCaMHlFKtjjDb1WOs78BXZF7BCdLenQtyQBNbj5 Tx2nvpre5MDmlYiEuzdfAJgIQb/rHiwlBM6M/uvqf8T3++Kpc8DalIv6V5zM7JIWogFI Lhs+XXek/CaMlPKLIf1YviruMcyk+w4OefjOLHJwG3UWDdwnnUt0BVgduYEe4Gzo46Ye Fywg== 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=k9zDtgXS+L05+ekpD7VMpQo1Lh9R8HC1kSXvuE27qsY=; b=gBKf6amRvLtY6bZ0BdzaGHWtzS0xMpi2ZFSJeZu7bf1cSUUo5Ov69wBmNaLUa8gTau HpOYKwTRZBN4FxDHVIXtqEREKWjXywGjG9DZ/XcBm9gyL7ClaHiwpF6jPSBZJWf8v3gA kiVQouIT5aEvxC593yKSATjcJKcUd2eBHkKJWWMfxPa8eWeuzBKXwGFcfVfgL49Jbf6L WCiOPrMm8txuRXeFtlfcmS6AfZXtMNRj+MnkLtBeI5mlSI+KJcDXEk6Hocvbuc/YVCWq ah+hUuzx1cAFIGDESt2WiTGT6Jb+xcwGbzJyfmJSgPio1d6njrMrYhfsRpy8EjOFlNTV XUFg== X-Gm-Message-State: AOAM532fao+oioFwo1hYaqyvlqWtcjkf9PRXoVZAR3lgXoJFii66Mw3X q3C+F8lw+Gs0xvwoopn6q0M6jGEVly86nQ== X-Google-Smtp-Source: ABdhPJwGsgWlsFPSEWym54cAsrutTimGRyA+kHsxMuIuBnQUO0JDtTA3PgVMozr13BdeDT5TnYersw== X-Received: by 2002:a6b:ef06:: with SMTP id k6mr6467809ioh.70.1643412485061; Fri, 28 Jan 2022 15:28:05 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 04/40] bsd-user/arm/signal.c: get_mcontext should zero vfp data Date: Fri, 28 Jan 2022 16:27:29 -0700 Message-Id: <20220128232805.86191-5-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413081072100001 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bsd-user/arm/signal.c b/bsd-user/arm/signal.c index 9026343b478..2b1dd745d13 100644 --- a/bsd-user/arm/signal.c +++ b/bsd-user/arm/signal.c @@ -109,6 +109,15 @@ 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 get_mcontext doesn't save VFP info, but sets the pointer = and + * size to zero. Applications that need the VFP state use + * sysarch(ARM_GET_VFPSTATE) and are expected to adjust mcontext after= that. + */ + 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 Sat Feb 7 08:02:22 2026 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 1643412838125317.25139943864247; Fri, 28 Jan 2022 15:33:58 -0800 (PST) Received: from localhost ([::1]:36514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDake-0003ew-VC for importer@patchew.org; Fri, 28 Jan 2022 18:33:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDaf3-00005U-10 for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:09 -0500 Received: from [2607:f8b0:4864:20::135] (port=42584 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 1nDaf1-0001Xl-Do for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:08 -0500 Received: by mail-il1-x135.google.com with SMTP id u5so6739964ilq.9 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=tyuB/O2WEXIGgHuAFX6b2tzEg4QPq9MhpbLYs5ZniS4=; b=AFftqhkz1iOb7ASFN5GjhxkYVaMeRpV9vUGz25DxPr7hrsupVIyj3Acvql3WL9mav9 HprGSwryoGntT3Bu+hgWyY/f3ukYZ4d/xGcodzoVMmJ+GyHDM61NLlk0THU0cagQ5wCj KeJCRm1V7vDqML3JHPQr6IBCVhgyCISW0aI+YVWMQhxkcDl1BOX/+H5GuuUbhcFkay3l ztm6R4Ujs263eUyQC1F+h7ZjivAX6qgPj9NgnUWMaL28p6LaVyOfEFuN3hlJVDfLpWkQ HPl1gUXzOzTO+Afcg5fq9DWwDz1HAo2oFFkj5TwWL47F3uOIdvmN1VrWBvOtkRvZ2N/9 SEXQ== 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=tyuB/O2WEXIGgHuAFX6b2tzEg4QPq9MhpbLYs5ZniS4=; b=XAx817P+OlBKdOyPbsMX07s2yozqKS+w1x3P404FIeBXAJx5T4nfoeLjK4dygQTUIj sJkHaDuOfsNkTRy9p5CMo+0uH20PrvKr6/aPHAhyFf+2MDDVq/GAEc+mv3tnvWgk8G/c 3g/8u1/mFTVr+pne3zr20cnxdLP5bO+677rwgaz+eQMs6ZJXxDC19Ga7WrU3iDigwJpC WYZINbbWkac4HFL05WJoUQdQZl4QZm/8W7gosWvF7uwurmlTBlhoWwkPXQ7BB1ISZc3E rmV43flU7o56VKG6JjCsCzegn3FChlnRLh+L2kLyj79MPiLIXf/CU7Pvgdz1gq23XpYA BBBw== X-Gm-Message-State: AOAM531qs4iyij5JeDh9rl2B4m37m2j5gPgE3FfWpjgbNrb3l6gC1UrZ DyV1ua8KyOzXkixyg3XpM4B2GGd+lWg2iQ== X-Google-Smtp-Source: ABdhPJyf57dh9lbtELbXTeC6v1qevipTk4Tpwe3D2VO7nQNHVKxdH+9l0Ji1My4pxAlRtwdku2EE2Q== X-Received: by 2002:a92:dc09:: with SMTP id t9mr6937498iln.94.1643412486134; Fri, 28 Jan 2022 15:28:06 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 05/40] bsd-user: Remove vestiges of signal queueing code Date: Fri, 28 Jan 2022 16:27:30 -0700 Message-Id: <20220128232805.86191-6-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643412839672100001 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 Sat Feb 7 08:02:22 2026 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 16434130651451012.030458967996; Fri, 28 Jan 2022 15:37:45 -0800 (PST) Received: from localhost ([::1]:44872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDaoK-0001BP-CY for importer@patchew.org; Fri, 28 Jan 2022 18:37:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDaf3-00007s-O8 for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:09 -0500 Received: from [2607:f8b0:4864:20::136] (port=42585 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 1nDaf2-0001Y9-4t for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:09 -0500 Received: by mail-il1-x136.google.com with SMTP id u5so6739981ilq.9 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=kr3WAg3LFuIjGK7Kv0poOIctPcCnCwAaBtFgS4qf/b0=; b=EGQfi2OYtf+Tjn38X5SRr6Yi23jyF+NQmZG1OJc0T+6vvMA7nHzliBhipgdKwpzy6p +LheHwiBWWDciAnMm3G3+VAkvlkStJnr1JKuvSU1jerVst5uZ/70kSbPsE92BUj9wkI2 cw5O8LO2XhoJMs0kchJa0HYVMrsHECxqZbU8xBcHCSfVUIG7Vbm9HGZ+3tB3eKtBkQNT ZFr6rS7jBD8XGrF+VO2noPYdAjY0Hku1lFnVV2PZtSVMwYhMA63XUhZPNkTD2chw6W1p SLO1tAp9dI+Ce0Bf+KOOqgza1zupJSZq5fiQxIuwP/Ip2ZstTkdwJPWPa6Kk31sLS7gs Z6QQ== 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=kr3WAg3LFuIjGK7Kv0poOIctPcCnCwAaBtFgS4qf/b0=; b=Ro4T3HoY6Rl3OldmjKawcBdJ7jn7yQwupxXZSjMXLVMdu14ISJWXYaETg4mF0hdKBL d5eiYrxaBsfPGvFjBgN8sr3dxSYz7NnGDUFses701PJ8fb1VZpA7gSOb5NsWFrEQ91mv EZ3aUGt7LDhphX3+pVjGMtM/rVJuwB98uENRjNtKwYTLlBasDwA5b1ygtKIL9Iwpsks/ kwxM2RNsycJ+TJakuvnQ1c/KcuLnnuWaYoshPrIAfX6xEcUWGmRtEVS7QvZiDPKlGqel JBGT2kkjyUPFN/b7i84i0JD1HczpOXJCJwluXD7qppyE3s+EEejKjmL3Irs9iNDXv0wZ wAyA== X-Gm-Message-State: AOAM530IxMrv8kdGL1o2JAgn47U0Pyk4yYEKtbPFhqcAMxbr3HcwRslJ 1+B+32R5hQodq3Dtu8J35hNDXqFknEW2Gg== X-Google-Smtp-Source: ABdhPJxALKHTo8wJbrF1qraw/ziKtKMLqbqkDwlXTU0CEWR135lyC1zWD3qI9u3MTzNxZoSKa7tTwg== X-Received: by 2002:a05:6e02:1c4b:: with SMTP id d11mr7573955ilg.273.1643412486977; Fri, 28 Jan 2022 15:28:06 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 06/40] bsd-user: Bring in docs from linux-user for signal_pending Date: Fri, 28 Jan 2022 16:27:31 -0700 Message-Id: <20220128232805.86191-7-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413067862100001 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 Sat Feb 7 08:02:22 2026 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 1643413194881415.9131009372868; Fri, 28 Jan 2022 15:39:54 -0800 (PST) Received: from localhost ([::1]:48934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDaqP-0003wt-Oq for importer@patchew.org; Fri, 28 Jan 2022 18:39:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDaf5-0000AF-2d for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:11 -0500 Received: from [2607:f8b0:4864:20::d36] (port=45774 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 1nDaf3-0001YV-Cz for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:10 -0500 Received: by mail-io1-xd36.google.com with SMTP id s18so9651759ioa.12 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=6fk8Rm7tbwnMJwW6ytgiwa7PMfU+rVxxXH2pSHcB2Zs=; b=xl32rECUvOVa+CP0V/A57Pn1QgQcJRMejpDe+R0QfefrpjLAAfAF0CzwQorvvG+HaL LHO/4nqAvmCiNHwW9AG7vVvct+0MlYK9SRP79ErjhRz2PFQEoIhjBAPIs66u2MjtZjgs M3xpoMsLp8pZp/owQj614MYIhV3CkDF0/ZleutTcIxWUPYsIbCV7Bp3Lh/ncDMtSkN/g ktJ4H4oR3gdKkSzqayizOVLm3kuvVf/UT88lzQKEXtN9AhU7KEvUrBVuu6McNKutqWBJ U3SnMl2LutXnQPgG3haDDHUZF6fOLoEOmN+pcj0KihFa3vnIx+jIZyhLp8+0PznbeZGX vrqw== 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=4GLrM3X9V428cHFFL7EK5HUzK9OBaTnDZ2VK/YTMp5yiZZdUkmg4uNJ2ddEn8L+FAA GIf3+Lrj0CLzEoBUV0CN/Eyn7LC15vIXKpT6I5T4MSndfDNDHRt37rENT7QaC/vIFr0b QFmjdFzG9hHdTWSDR5oxI4nR2ixlm/4GeWu7XazGSHKnOwN4P5fMHQZpCfU3NvabuRnu Ho/zDUK3OyCqLqPaU2wYz+MSdVeqzSjKuSeU7WbCVCvU1yN7+w2NQOWp39ksl+n3B9cq q4SQpKvbVAyVyku4XgjmOQXxwH7RyOvRehgEaKkOtLZ9hNvgep81I6MrAs2AZDUIRdm1 W3BQ== X-Gm-Message-State: AOAM533JoPMLVSr0oJr6jJngwLFGmB7FA5vdxtblQOzwT23lZFAhGV/N DIiqtRouMwTZopsFMLBFTqaT30Hvk8H3eA== X-Google-Smtp-Source: ABdhPJxNKfzZgyJNNB2p/5yXWrrD6Nwnug11NvB2NtF0q3B6jLt44pywOWDzwSFa7YHRvNR8lCHyvQ== X-Received: by 2002:a05:6638:1450:: with SMTP id l16mr779747jad.30.1643412487959; Fri, 28 Jan 2022 15:28:07 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 07/40] bsd-user/arm/target_arch_cpu.h: Move EXCP_ATOMIC to match linux-user Date: Fri, 28 Jan 2022 16:27:32 -0700 Message-Id: <20220128232805.86191-8-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413197783100001 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 Sat Feb 7 08:02:22 2026 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 1643413306110367.57009857791957; Fri, 28 Jan 2022 15:41:46 -0800 (PST) Received: from localhost ([::1]:53588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDasD-0007Bh-EF for importer@patchew.org; Fri, 28 Jan 2022 18:41:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDaf6-0000DA-0C for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:12 -0500 Received: from [2607:f8b0:4864:20::d29] (port=41648 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 1nDaf4-0001Yq-CV for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:11 -0500 Received: by mail-io1-xd29.google.com with SMTP id q204so9678413iod.8 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=/PjL9OS801//J6FLPGxe5bj91YwywO1H07GXqkeIugE=; b=u8LJvgrJOy9CU1AwK1LOQ1IWuJwk0y6ZsHxiSxw8N3mKnOAIsEeC3Y8pyle3iGHoxq aP3MAEMdz0iqS71U/WFWT81tY1qhWOvNKPotFJ/tzzTVVm51kdoGEyjsh2r2eJSYvS+A BcX+xCDrPoolpmqV+308o7w/8xkqo0xH6iv1wIn7RubMVCNgo7cfk44GU2eJOhJh0xBF MPAR7XRVumNntHDvxNCaSNn70X/ZTD6zotCOp+vUcxftpyoD+uh43GvJnqDRSW9u/a8K MxK10RZ8bLI/IH94xOVY/MLW3ky2cCoqlNHBKMdrbGhKRa43maMUzpIvpdMJ7gvPuS8q cVzQ== 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=PzSg0yKWE+8NywKXV6efbdWcUvSKLxQfAafqN3e77AOzZSSqid3J9W+xGDRe+FeCbD xsaktan0wkQM9DFuBJjyHEPyJHOQ5Xx5G2/9bRHql9T7zAsm1Da2hFkGplZYh7NfCBZn R2wWXXPnGxP39u6ly0qyMGGpfyULwM2Z55KJQpyuwrCx4nY9CPIVIAL9cmVoAGjtSZKT 0+7Iou+5cBAFUJZHtNTt2VOjvI7ChJGCGsK9WMWEE0sZpjxjc1W088X5NHZgdG5f51kM HPfAfSE1MlUzENP3dasmkgHkBcOPN+HD3Hma4rtD+ZIbsOOTKg+P6mSJfjlmqlmKdCm3 ZDXg== X-Gm-Message-State: AOAM532dm9lk+t+6+dmupVM2XBMIsjeQ69eiA3nmb01giuckcMIatQpo q1aozn8XfSTYWo0h/k2+GgGBZvjBU4Zxcg== X-Google-Smtp-Source: ABdhPJzBbsfBR/ynpE9HTt3SsA6LzkU1+Hp1PRCJotDf4M7l3LCa2Zg3OMZH7td/ohboWAAYpqjdgA== X-Received: by 2002:a05:6638:28f:: with SMTP id c15mr6079096jaq.188.1643412489003; Fri, 28 Jan 2022 15:28:09 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 08/40] bsd-user/signal.c: implement force_sig_fault Date: Fri, 28 Jan 2022 16:27:33 -0700 Message-Id: <20220128232805.86191-9-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413307779100001 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 Sat Feb 7 08:02:23 2026 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 1643413503552465.94911883783845; Fri, 28 Jan 2022 15:45:03 -0800 (PST) Received: from localhost ([::1]:33822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDavO-0004g3-6A for importer@patchew.org; Fri, 28 Jan 2022 18:45:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDaf6-0000H8-UU for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:12 -0500 Received: from [2607:f8b0:4864:20::d31] (port=34802 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 1nDaf5-0001Z2-C7 for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:12 -0500 Received: by mail-io1-xd31.google.com with SMTP id i62so9719959ioa.1 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:09 -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=IIwWr4XQkvp7rEwjOGXmWZZadDj8kG6ZitoG4k00onk=; b=tjYLNQne+w/q/cgCQOn9/MCpZo8OsZ+agiKl2NycwIwh4lFOwW40xkiwTKz810AA66 6dMuwek1kTtTozxadyjK5q36yT6pdqCQYo1iShx/1r7xAz50cXaNBqMwzC6NHtkO51Ov bfIvbuwxPzCuDgBg4XiXDuIE14pUW+YsVx+Wf92dAFYbypTcn0uG/V3X7bat1xyjg/Ao KmwKyCAS7fy8osHDRVpiMZ015OTWxybxqEAwTh+hBBpqL0IDx64Eu7MGKcBk5XhFLtYn WFl1EOhRVOc8DuMp3qSZdckiJTccugCaSn+U6bGAhUKs/jEH8fJ1WqUMN7MpVk1LjkRt MTNA== 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=IIwWr4XQkvp7rEwjOGXmWZZadDj8kG6ZitoG4k00onk=; b=t/Wuh4MRJAamuwOjBY17lGEDIA4BvP6VxNP/wnFsBM6csnst7Wi1NtP+c3fYUhUrVl mFjoAreesh/MbCW8FJSFq6SD3xi5jRQA7DuES1QljKebvW2AsYDl2X9sMC4SjmeUuqEc tl+hSdUk5W6NpdL3A6V6vaUw74NzDIKUXXX6ZZyCNm2sbKNYamX2sErZH/bT/60sD3Vh GRkCMutJ3QU8h58H/DUHqu/glnUOM3ymx0gmfYCVkGTGYn9rIL8IqyAKJJGN83XkyYVL 1smcH8nGqx/BiNZ7z0FAD9MgmL6iZOcbaZb337UbNG7/HPIWF+r/bJnRvoho4ucFiIBY 2KGA== X-Gm-Message-State: AOAM530qPCed6jBjx1Pxcdc0aEcqT2GLmZfQ7gWH3qbFDOmubHUD8py5 TYjeXZ6nt3foRfwK1cKpCNEV55qgye07JQ== X-Google-Smtp-Source: ABdhPJwac7O+HX+W6J5ce2nHrB5kjyGREmUQS8E1HbOxbkk1bVkx3lvkpioWH2FJcxOilAazAD9gAA== X-Received: by 2002:a05:6638:4105:: with SMTP id ay5mr6057564jab.128.1643412490084; Fri, 28 Jan 2022 15:28:10 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 09/40] bsd-user/signal-common.h: Move signal functions prototypes to here Date: Fri, 28 Jan 2022 16:27:34 -0700 Message-Id: <20220128232805.86191-10-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413505199100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/arm/target_arch_cpu.h | 1 + bsd-user/i386/target_arch_cpu.h | 1 + bsd-user/qemu.h | 8 -------- bsd-user/signal-common.h | 6 ++++++ bsd-user/x86_64/target_arch_cpu.h | 1 + 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index c526fc73502..b7f728fd667 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 diff --git a/bsd-user/i386/target_arch_cpu.h b/bsd-user/i386/target_arch_cp= u.h index b28602adbbd..472a96689fc 100644 --- a/bsd-user/i386/target_arch_cpu.h +++ b/bsd-user/i386/target_arch_cpu.h @@ -20,6 +20,7 @@ #define _TARGET_ARCH_CPU_H_ =20 #include "target_arch.h" +#include "signal-common.h" =20 #define TARGET_DEFAULT_CPU_MODEL "qemu32" =20 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 diff --git a/bsd-user/x86_64/target_arch_cpu.h b/bsd-user/x86_64/target_arc= h_cpu.h index 5172b230f09..14def48adb5 100644 --- a/bsd-user/x86_64/target_arch_cpu.h +++ b/bsd-user/x86_64/target_arch_cpu.h @@ -20,6 +20,7 @@ #define _TARGET_ARCH_CPU_H_ =20 #include "target_arch.h" +#include "signal-common.h" =20 #define TARGET_DEFAULT_CPU_MODEL "qemu64" =20 --=20 2.33.1 From nobody Sat Feb 7 08:02:23 2026 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 1643413310949447.9955977918414; Fri, 28 Jan 2022 15:41:50 -0800 (PST) Received: from localhost ([::1]:54028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDasI-0007VU-2h for importer@patchew.org; Fri, 28 Jan 2022 18:41:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDaf8-0000NY-E7 for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:14 -0500 Received: from [2607:f8b0:4864:20::d35] (port=34806 helo=mail-io1-xd35.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nDaf6-0001ZK-Rb for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:14 -0500 Received: by mail-io1-xd35.google.com with SMTP id i62so9720042ioa.1 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=SGJfV2pZjNq6/Lkgq5idUT85KpfDUjfI//YVpMiMT3c=; b=QWcIZtVhZIDHRFETahoxwHZ+ElEbZDAgdWLwPfTMDIOhcOMEuuCxsArgqcV7qfayXS YpkETfPkfrjJ6OxWJ2NiDX6Aoyx7m4Fz6f4rF+6Y7DA4u+aoWIy4yqzx4HYUZbhhuzaG zgbqtiCtVcyG8VoHeBCxDUNJFZAsK3jOjS1m9YFTO+KFcIR7z5+xQ4yao1dQTaV5oBAH LttDPbRgVf+73zGoE8ilH1hEcbjhQjZImMT02FnJT7Ks2GDIUcasba3lOO5Z2aR78FgT d+6pYjzcGp1AUMnCRgOaNMylbhfubM1lGm56m0nlI/lHpqwd58800BkgiFFHRoKpzuSH ZKVw== 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=w0gRz6DawksI4dW2+9pgYroKsdPTNSl5eQ1ozCPnnDJu8FKZoNtGn7XCYTHgPvMnCB BP5olxcOQzOdNIMz7+hidC39thuCnaIkYSr/lUj357AQw0/DmFnWCpXT4YTQlyEMCNgZ YdYe1yE+gl0+tH/iDtHBVUHyftm6yN9K4dyDDU+/ZFBKkJgDI5BxZzWX758p0E1QWmOk vsYCkxXT9TKH4qYPrAtf6TurOEoyFfEexJipRc4GvLdD8qkd3tSrLthi2HDLaUDvvAEw kNEVRR3LPOYM/DaA5m2bsOvNBKW7sM1/6EHTTNoAhGalZRP6wzcR9FyUjcOsn+L5Zjli psEw== X-Gm-Message-State: AOAM531b6E1MfEn8KYIw1TELaevC0nQhL5BnCuN3o0mvCdinYtQ9rhvP ik8QLBtOpYpAW9XdY/pXjdC5YsQiifJcfg== X-Google-Smtp-Source: ABdhPJyWF5Y9qhfd7XTl/K0hHe/bu6obTBrzGG2Gju6I2qXXwA26VIiKBY7JHozU1AugtasTn8kWLw== X-Received: by 2002:a02:2208:: with SMTP id o8mr2378771jao.72.1643412491562; Fri, 28 Jan 2022 15:28:11 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 10/40] bsd-user/signal.c: Implement cpu_loop_exit_sigsegv Date: Fri, 28 Jan 2022 16:27:35 -0700 Message-Id: <20220128232805.86191-11-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d35 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413312234100001 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 Sat Feb 7 08:02:23 2026 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 1643413844861653.9424429888437; Fri, 28 Jan 2022 15:50:44 -0800 (PST) Received: from localhost ([::1]:42446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDb0s-0002kt-PE for importer@patchew.org; Fri, 28 Jan 2022 18:50:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDaf9-0000RS-OR for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:15 -0500 Received: from [2607:f8b0:4864:20::d2a] (port=40851 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 1nDaf8-0001ZZ-0O for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:15 -0500 Received: by mail-io1-xd2a.google.com with SMTP id d188so9675804iof.7 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=WzkIKVsgbL3BkTFsfAwelEbf+OyNiGDSqNoHVUm1RWE=; b=27G8bB0YIjGVrKBfMwY4oJ0vdwIkw9oQF8IAfEAi6BGxS8b5M7cmdxsWT+71l7TC2E pZ/EHyS8YB0v6CITgmmtLzkKL8qoiXCbmzZtuE4G4SUIjwuL81ikhbiY554P1JjRG2uO N+yK/dBEab6B+Yw1mtsS+FikraCdOJNzZHL9bSTObsCEQmcvPSFJcBXB19EI7SjnJpVy xVwUrd7YpghutUoh0nUrwUMTgmblOZYqUbHOYc9TjbzcOMbLkaqbYyQu+Ajln3LuWxd5 ckUUS4LPwPTHUQorDOhAOO7gk3QmmVer0TtDW4p916aQ5itw2qXCFfdE36K4SpfNgFvv P4Iw== 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=PWWKPiZxNT3z8j0yfyEMA9D/WkJpoiZsyBqZaPCjqwi00B40ibxWygJszrhOOk669h AIhaaDwPavYTj3azgqZQSKTJwjGTjBuqvpadsQHxqqJG0NXjkYaOfKVE5vaxi94vzgKg x9nL48eb6hTzorniu9ExcTGXn+3+ZXxtQmnw9Nwal28qo/7GwqqGK3PWQ4uPQj5gVQtf cIRzpOacRITnLBoyO1IhapWxs6mNgFXz6a4QF8tbaE8Kia+86ZGxnbPIVPdOSwz1mJqh IOVWL5TRLbBVf98yk3elFQFxVyUljRoVucEuWPB7ROnfcs9GniVuE49X6GKDxAf70W3J ZPJA== X-Gm-Message-State: AOAM532b7ZWzuRXhKaLxvMl68cxFsRXODZuW5XTq1JzBOxnLfaQWKsos VKfOH98CxDSGx67mKZy1ulwi4jfEhkJj8w== X-Google-Smtp-Source: ABdhPJyxHXuleZSh+P15PraIDHtKIlV3QF1qUEjp5hYsmkPU06tHzPXgdFLnuIFAViAKPoWW8N6cxw== X-Received: by 2002:a02:c944:: with SMTP id u4mr6342350jao.42.1643412492833; Fri, 28 Jan 2022 15:28:12 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 11/40] bsd-user/signal.c: implement cpu_loop_exit_sigbus Date: Fri, 28 Jan 2022 16:27:36 -0700 Message-Id: <20220128232805.86191-12-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413847852100001 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 Sat Feb 7 08:02:23 2026 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 1643413377198951.107966919182; Fri, 28 Jan 2022 15:42:57 -0800 (PST) Received: from localhost ([::1]:57620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDatM-0001cX-GE for importer@patchew.org; Fri, 28 Jan 2022 18:42:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafh-0000Wj-3Y for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:49 -0500 Received: from [2607:f8b0:4864:20::d33] (port=35496 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 1nDaf9-0001Zm-GP for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:16 -0500 Received: by mail-io1-xd33.google.com with SMTP id 9so9732659iou.2 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=Bc6DcyWj3C/koTrEJ9qrW7xAW1qoks2DIh1czZk9FmE=; b=hsCB0dPgpT8URvuWnyeolp0f8NZLqBSNNPdxd/O8M3o8gatPj9VVhAlzappTIl96PK BFpkMi9RbKRmEaneIjBe7JNWyN0/1HBjHzG6WQmUcHt0FnDVVk46L7W4flrJseDh0LVT mg0WfkR0LqlW273os67Eh3pCOcYrv7W7IWjemDoxSN3FndBlzBZnwXZjO3lOkimHJGAt Zl8QituWfd1+w39YZwFq9/HfUfudDXaz4q6FNoKmNeWSi9o8oiV2VF44lZ/5xFWPZ+0p yuoQipnOd9yeMiR5UhXdnIjocTMwd2XTEzWA67SZAzMi/5wzi81+BARp4g6r51lCEA94 yXVg== 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=Bc6DcyWj3C/koTrEJ9qrW7xAW1qoks2DIh1czZk9FmE=; b=ZaTHiltd4fPCYUhyXtILKdNAyVXg2vtHVZ+cJ72bkQYr7BQngRXjg11oc0Sed+RQ0U CKc6oHTd9WSTCg2af8xySd8Taf6+nOZiLvTLKZpxok2MqYpdLMARdR+jjUhPfXgvKcgY EH9vA2S79lqzYmNjg7GGZvTx2r57mAVY4uW2/lIgY2SO1Rhu0Aq/GVZyEIBHAFOsTeuM soLP6fK1O+NzMNm5lXCpoQEjKBHv0BQ/OsPhjjFtdtOREqyIkeLivrqnMnQltrYInKgB S+Zcz9GrPNYUMfFrfTmwx2WBMo9DfBON9OT+uoDRCrfuvwOguDbDbpEeDCqbwqAPAQUL Y8Hg== X-Gm-Message-State: AOAM530mWzlWqD4JDcNM5TgMAoP4LeMU9aFyHKMnR8jlJH/bNKkTHq3L TBDtPH2vJyejWz4PjSYqV+U1jimRDpYW5w== X-Google-Smtp-Source: ABdhPJykd1tXVxAv1Ik7z+IhZJMANbxcLulR89EMPfoQadoTXJdau2krjJN9nL6Em7qHtrIUpOWlDQ== X-Received: by 2002:a05:6602:2d95:: with SMTP id k21mr6749066iow.107.1643412494234; Fri, 28 Jan 2022 15:28:14 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 12/40] bsd-user/arm/arget_arch_cpu.h: Move EXCP_DEBUG and EXCP_BKPT together Date: Fri, 28 Jan 2022 16:27:37 -0700 Message-Id: <20220128232805.86191-13-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413379568100001 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 | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h index b7f728fd667..05b19ce6119 100644 --- a/bsd-user/arm/target_arch_cpu.h +++ b/bsd-user/arm/target_arch_cpu.h @@ -65,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; @@ -172,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 Sat Feb 7 08:02:23 2026 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 1643414058761276.22590672795207; Fri, 28 Jan 2022 15:54:18 -0800 (PST) Received: from localhost ([::1]:51122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDb4L-0000t3-VU for importer@patchew.org; Fri, 28 Jan 2022 18:54:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafj-0000cW-PW for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:51 -0500 Received: from [2607:f8b0:4864:20::d35] (port=37859 helo=mail-io1-xd35.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nDafe-0001a0-SK for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:51 -0500 Received: by mail-io1-xd35.google.com with SMTP id n17so9711625iod.4 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=w4FRMcODA3Yw9ipRGV2deCv5GoQkPWInOh9N0fcX/6E=; b=tnmcn5JbKC7RrwS20rhduMINKhyivRaNITtiRiTQzbcJRtWeVhLHGjdYeqkwtqlHDU EzofFOKK01TgAt4lEB+rSL36siQuO5c1lZwbNy9r8r4Y4I9Nrx0koYqqLd+hWZduCkkz Li2XvI29uBt1+EZl4xMEmUunnQ48TYXdZeZayFof2cb/N1yqrZcpOp5uJ4gg87TecuV1 RJ7hu2IWtXcwMNI3oFmhI9adFSnbnPsnpF7YeQxJzrX8INOaut86zIgW8NFKcDD911vz 9iTfk0PTv6Zs/Vj2IVqjEo3s/8Y7+HehGWIKfKPC+1ZJw13rnoVpzPBpX87m3peiiRnC uVvg== 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=gntcTvkCJJmWBSoqbPFN+4RGK58B3tm6ham4uBfwFOySo9QvgpdVuRGrKVoa5G/ubg S9Rc56ziP5dIbQAfgmxSz0QkstW2Y+25y66pjKk55ERBqbrkdD6drqTkmslC1DX3YYg6 Hyo8cqdFZnm/mVKJqpaP2g0AA82kv5JhsB94dHCou8IPC0umjJFoQqH3sLrfk4zfi09b KTXFFORo42E0uQWXeahl01XkyOvdVSPAS8rUtVSZPEV7yIt4aRrEF721zWytGMgybEii zXdsRROy9MPdF3KpiKKUvOuPsR70jXeBp0c/ugPvLOBEz2033iWcHXNRbTImBvJD/gM2 0iOg== X-Gm-Message-State: AOAM532agMeawcGJWjlCljVCyk+wCp7VstWoSjbfhI74fiwnoyf8P7lD nL35dDUU5WXyJe9AA1bFvfGSucpWTLrqAQ== X-Google-Smtp-Source: ABdhPJx59YwmwOuatQtpjOnK8VMZ8A8agPvMP3++LKsASEmRmN6k/tT6oYxQY9mm6EhnXhod3RDlew== X-Received: by 2002:a02:ba14:: with SMTP id z20mr236481jan.102.1643412495451; Fri, 28 Jan 2022 15:28:15 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 13/40] bsd-user/arm/target_arch_cpu.h: Correct code pointer Date: Fri, 28 Jan 2022 16:27:38 -0700 Message-Id: <20220128232805.86191-14-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d35 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643414061258100001 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 Sat Feb 7 08:02:23 2026 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 1643413364305403.01729792496633; Fri, 28 Jan 2022 15:42:44 -0800 (PST) Received: from localhost ([::1]:56828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDat9-00015D-FW for importer@patchew.org; Fri, 28 Jan 2022 18:42:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafj-0000cV-U2 for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:52 -0500 Received: from [2607:f8b0:4864:20::d31] (port=46958 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 1nDafg-0001a6-Kq for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:51 -0500 Received: by mail-io1-xd31.google.com with SMTP id e79so9637260iof.13 for ; Fri, 28 Jan 2022 15:28:17 -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 o11sm14323111ilm.20.2022.01.28.15.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=p0pz1mYsxMG+ZM0MzZl75FORMdT6nHp51WXALYPrt0k=; b=xSRPQRbiZtFVU3uJ2oInngkgw+MOwuE36L8TW3aA3a6dz9yQPFXS6m6v4pLlVYDonh Moj/cJhQ/Bgy7dAvfCRBGbeprDt1kApIRfd2OVjp01tVQYD/fBT9KQNJAf3tEK0qGWaR kHinkzDygUayrqqOC82XMIKz2fkUvdxXQgjqTz+T8ynRgyPkMJP94oQY0mJ31HMgRd3M MvyXiVjOncewZbvW9Th1t+nksAo6f8ZG5oyQhbUA07PB4sdFinXpDngZrQknxxfnVJmj 9qF+dqutqd6CJPPjtCt5h5OjNnbbF/E7t1TW9imFps6OsF/y1Fk72egm76R+JB+A0Hyz LEOQ== 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=p0pz1mYsxMG+ZM0MzZl75FORMdT6nHp51WXALYPrt0k=; b=36snB8/0plPg5Nfu0ckIEh1AOrMMP6rlcXWOFDYLZE2tOIL0mxymjdh6wfONWpkmnt v+B8weTVxAFkHD5sZQVPZxiWqBb8RPs56ufMZVZ6L03OwsXFPuJ7G3LMrdkxzZP7hsOx vzp301c2T1DVcwf/4Hwm360WGq/DEcsaxaVWEz9RlC2dU5yGjLLE9Qz//Yx84sKXLSNc 1VtLnG/uYMmGn6SLOwvhOfhQoP5lGXc3+hn7tlvcMPBSoZ0PHSC2hYg8tpKOhD3m0Iwe /APkNO1nbnRPLzmWQAU0MZaMaGkcwmCKDgmqsjVp0iYc995iUtVeMno4Fiq25APYa6Zs 8eNQ== X-Gm-Message-State: AOAM530lB0taL5gsNRt9/rlXVm/SSg8dKy6wOtn0/d11L5frdU0UVtGC 8w8goEVwrBAkLobPvy6uPdwIpzW3MmMSXw== X-Google-Smtp-Source: ABdhPJyEG7mZ1fiJgIChqa6c9iLD0dBZPi5yNopKLqBL5ASZ0jQK8vqo74M2r4cN8L2UZH2G6hVkdQ== X-Received: by 2002:a05:6602:1409:: with SMTP id t9mr6507399iov.176.1643412496927; Fri, 28 Jan 2022 15:28:16 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 14/40] bsd-user/arm/target_arch_cpu.h: Use force_sig_fault for EXCP_UDEF Date: Fri, 28 Jan 2022 16:27:39 -0700 Message-Id: <20220128232805.86191-15-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413366201100001 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..9d790176420 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 (these can't come from= qemu) + * 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 Sat Feb 7 08:02:23 2026 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 1643413646679942.7530513286505; Fri, 28 Jan 2022 15:47:26 -0800 (PST) Received: from localhost ([::1]:37086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDaxh-0007Il-Ud for importer@patchew.org; Fri, 28 Jan 2022 18:47:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafm-0000fo-Cg for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:54 -0500 Received: from [2607:f8b0:4864:20::d29] (port=44824 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 1nDafg-0001aA-Mu for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:53 -0500 Received: by mail-io1-xd29.google.com with SMTP id p63so8829467iod.11 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=+DlEs5WrZvuXfm29/4/3j1YKa0M1X3SLWmqACMEYKjk=; b=6dtBZu+3Z5s2Yiy6dlqBqBLqJtvUtjOC+dMHQWeWOA7JLp/skUvm1HrdghdreEinkH 7mZqvkJgmP3F+fa+qlYrQZePg4F47U/GBifZM8LN1aleJp/R+TjNPPOJgirZOs5JU6Mz 2WxaZXlHoh2MDZlAs19im+TNPlzYPGBCtAKXmOkQFV/PNgSjrNK7kdcQ9L7eYozapc4i 0Qebqrde05xO1B7lVKUR0B+LciDnovRq9ZDDGMHrPFoQ7rBUAOX3rKSBKgZSo/0hA/83 t9BiBRLRpQgI9z7j/sg4KGDjp43A3AXvrZOtO/VucQeVGUTos9LaF5sme/JnQHHrp2hC hDbA== 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=+DlEs5WrZvuXfm29/4/3j1YKa0M1X3SLWmqACMEYKjk=; b=QT72RqNDY1iQ1RYDwkIOwoxhPqBrzZJFsBG25uecK+TLxJBkQA3Bpr+Sy4KLcifJcI B1FDN3EYVqnURGRr/ePaEfOpNkBN47oD/N/MCvqjUmcWO1HAGU+BCNg4Wl1p7JwBWDv4 u+tcjAryazUjyu+aoryP1ZA4opHsy17N+oyUTuYUgitRHQG3VFfTkI8X0e5DohBdDkzX ujToEofLUB3OpM+9wo4/AdnqT1V8obMUb8Abk+74AUxXg6c+ic8pg9J1fGfPgc77lSHu XmGh/nrFvKZVVO/xfPocB7Fyt7dd8lAyI0Ml/rPcH/VtFZTXwaMJ6ztqXpKETukwf5as KCNg== X-Gm-Message-State: AOAM531hV0vE0lcrtSW/BcNAuR/7r9BV7kQDQd+lp1bAdxqV10neAJQ9 vRkotyGVzYUIy7SCDwIAykdakjrjMtLKkg== X-Google-Smtp-Source: ABdhPJzN+fQmVkNV4cKMer90iUCOqaDBE+SlSIJpZllZOQjhGCAdjpQYk1PppqvBVXU/0fTCFP/4wA== X-Received: by 2002:a6b:905:: with SMTP id t5mr6729323ioi.86.1643412498009; Fri, 28 Jan 2022 15:28:18 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 15/40] bsd-user/arm/target_arch_cpu.h: Implement data faults Date: Fri, 28 Jan 2022 16:27:40 -0700 Message-Id: <20220128232805.86191-16-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413649195100001 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 9d790176420..2b395d5c97f 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 Sat Feb 7 08:02:23 2026 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 1643414645534750.4853343743318; Fri, 28 Jan 2022 16:04:05 -0800 (PST) Received: from localhost ([::1]:40474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbDo-00058n-Qi for importer@patchew.org; Fri, 28 Jan 2022 19:04:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafm-0000fr-CU for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:54 -0500 Received: from [2607:f8b0:4864:20::d2a] (port=43744 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 1nDafg-0001aE-N9 for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:53 -0500 Received: by mail-io1-xd2a.google.com with SMTP id z199so9685251iof.10 for ; Fri, 28 Jan 2022 15:28:19 -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 o11sm14323111ilm.20.2022.01.28.15.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=kcZ/fxJZTdiXxs5uHcd2Nm1OFR/CKnoGxaFeU6jvAsI=; b=pzci1BDorZmXncrG5UQtZ5vYbjjeDRaxAQlUQRryeUX7/s3mq8cWpWFbWOJjTmJ5OK amAfZpHlq3vK+/pHnzy8rW+HdE6QNybh94xPbLkbKB7q9G4xP1LGA9dexE/v4Yy43Mxz O2k91j5sWmPbZKwvbV23Dvs+uGrzYo+WVPAr9Lg5Ng9nyH152Qfk/mzGw1obt1aK7vLl EyNGOapSe4h7FzKTdJfJo97AeXZoLAdQaCcdjXlhLT7TBnq5plVwaKCANPFLc6n6dw03 F1Tjdd5LZqUWIOpBXyk8AzicHXoNS5tEuez6UCizlsGiTLy9KbVJVx9HdgNSNKB67pPt lF4Q== 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=kcZ/fxJZTdiXxs5uHcd2Nm1OFR/CKnoGxaFeU6jvAsI=; b=OgJVkcduY3z+vCp+EahBzYBo9HZKksyunwAW9RPYIKfCjJbLexUVYF+IWAvcPTI4cs wHE6ma8n8AQcyR7axUoRQmcfwc6z/clWt1XPStKdG494Hih4qGB6O9YhZ8oD8ddYjSFt L+xGO2VGUmrP0xYkzd9w7DhNvrVKH0KQR0ZOOdBks7J9r4X1aIvrCt/1MU3cdRMB4l7s YjGid/ApAttZNry4bfQE9JTIulGGq6TdSqgqySLYRzQtlY1QF/wyJLvGTRk4odM9d59f ZmXxGXtADfiy+sTTe1mLGJiittlunC8my/uXarYdlGsXFYr1WD347UOGdpq6kr6tArWs RP3w== X-Gm-Message-State: AOAM530UVxSaWG6Bnpd5OHGgoloB98g/ME3BSt0B2TZYpDFOKcTeiqc7 gCYxqmi7n88AmA10xeShcef4lxnHW0MhgA== X-Google-Smtp-Source: ABdhPJyIJOfZOlxhQOseFDDUe+DSC+SUk+dadvFGAo9IC0ay18eEcTVyx7L/B85FwpRy97ClH+zl5A== X-Received: by 2002:a02:23c5:: with SMTP id u188mr2356809jau.55.1643412498812; Fri, 28 Jan 2022 15:28:18 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 16/40] bsd-user/signal.c: implement abstract target / host signal translation Date: Fri, 28 Jan 2022 16:27:41 -0700 Message-Id: <20220128232805.86191-17-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643414648229100001 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 Sat Feb 7 08:02:23 2026 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 1643415147933987.566707474357; Fri, 28 Jan 2022 16:12:27 -0800 (PST) Received: from localhost ([::1]:51494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbLu-0007Yq-Uz for importer@patchew.org; Fri, 28 Jan 2022 19:12:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafr-0000kZ-JT for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:01 -0500 Received: from [2607:f8b0:4864:20::d2f] (port=36362 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 1nDafg-0001aI-Pq for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:58 -0500 Received: by mail-io1-xd2f.google.com with SMTP id h7so9703578iof.3 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=l8RA7yWCAX4kkKStNQOwlFxMIKNeQ5iUFxaPSVvYcxY=; b=ASi2uvA7MpDbQn5ObKYtpwcQI9JepGWAtou7fW4JPHzSz+wXTCHCj8S/uLWQahYul9 i1fbPa7JmhPCvBnZg30R9E6f9VaOTYoUJeO7XZuKhW8YTkX1riateqvv4s2M+nwVcmWX CIN6VEfJ6mXHdJHlyvO+YpTABRcwkyFg1SjMHSFOmdvTB/mEQYFCJGvhCZBfFbWiBzat dRFKHi83uDaEFRsd4Iu+FUnIw76XQNi6hIlFK9Nnr+dBYf/zG+YVEuhSIW9UCCDd0v7t f1mAIOH1Li/l0W1x6xW60TTK3RZXc3marVIJWGoToc1f11MGXNjLSh3Gn/sp2K1Z1WXK gmhA== 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=2HQgZ90PijmZPK13SmV2Hh/FA9CxCfFypDbREv2z0esA5C/cTRng5yEtRAuqvka81X ybANRKPo27af7H7cbcZAvdDV/9tSrFU5z9LJhpnvWxd6n2Yokh/9nRcAg4pRCyb1sJH4 jFCJM1UxICaDt8pOAriQYwdLucR2GHiV9a8zJfwxFYkcd9q2oMOkRxcJpafchYpIvHkt anBjkWbeQXfrNwHMLj9Vmm+XveY7YPY/YCVrXafqFUAi/o8yO0aHO1zwO8tFXV74varU 3rSdXAO1Q21KsZecbiTRF1ScqcVAgBV46zlJwRpU4kqdViH5+4Gn6rFq668B/qobQ+hf 3ZoA== X-Gm-Message-State: AOAM531JLvP82hEZBB3u9pwRS72vgMcv5uewaCgYLoMhLAZpOJ8rMiTJ MV7Ck74zSBhPzsewLrV7maV6W1LIRPrZXQ== X-Google-Smtp-Source: ABdhPJyMMVEoVKcvHHSYa4iis/VkozVCKkbExtgmOLeofTUqhpW38dn+/WTxd2uL3FVtHeCs/39Aew== X-Received: by 2002:a05:6638:1913:: with SMTP id p19mr5512110jal.181.1643412499834; Fri, 28 Jan 2022 15:28:19 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 17/40] bsd-user/signal.c: Implement signal_init() Date: Fri, 28 Jan 2022 16:27:42 -0700 Message-Id: <20220128232805.86191-18-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643415150211100003 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 Sat Feb 7 08:02:23 2026 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 1643413911347552.4309069879824; Fri, 28 Jan 2022 15:51:51 -0800 (PST) Received: from localhost ([::1]:45564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDb1y-0005F2-K6 for importer@patchew.org; Fri, 28 Jan 2022 18:51:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafr-0000kc-Jo for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:01 -0500 Received: from [2607:f8b0:4864:20::d30] (port=44831 helo=mail-io1-xd30.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nDafg-0001aN-OY for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:58 -0500 Received: by mail-io1-xd30.google.com with SMTP id p63so8829545iod.11 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=wqlbtS2VUgC/Bp8lefRD+Zfc/A3KiIGoEh621L0tTtg=; b=ej1j4TgqYUvMVwoKQQJGW2ig2mr32w/WD3EAgBEWgs2qjICiDJZlW4ubK+T0nXMlx+ fsjZ9pq/nVzc6yLyprMqxTCkRM01YvrDIzlIXxh2Fa284cDcJpH/DT79iwrYS+WUA06f T2G0Yg/WKs4ExfSEWpwbY4XF/BzIh0BzitEO1eKXdbXo3KWuM+u7jWtB9HL8FOtdjtom Y+EHPfZKSe26G+LWnz8hWVG7qpbIUh+PIuuTvsXoZ94w0LCnC4wlpOf8Yacxo5XZKdo3 BAsQjnUyj2m4PE5zfiuq4SakMGNQyQfob3/ljC23b/lerFtlcS9IC1Lr9h8++j+e81EL oQwA== 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=wqlbtS2VUgC/Bp8lefRD+Zfc/A3KiIGoEh621L0tTtg=; b=o8j/j2PoNikAcc4BD4CUAVc5W5+FL3uJi+lKdAd3oQR4TCpDdBzdeCFHlDI+p3t0SG XEKgErqfVz8roqq4s8uTYIlyrktNkH/rtZ+DbBBpp9RS+pUZu5BRA7AfcLcS4+Fgtl3S aW+e2vNSEFYHZ4qGQX33PF+qji58X5gmAmOPrR6+BxllBdpqU3GgmFd1NQMogXd4v3f3 20Q6bUzIqTwDEwruQAyVdpGiIh9FPqO4XDF7mNZmi7BLVOW4Uj1SVJc17Hryyf36cAVn yebM9knNtAkPg7ep3+WgdSR2DAusOI8jhxr6pxJsph/K1eZhOMbICbRCYptgNV19ZQ7K 7gxw== X-Gm-Message-State: AOAM531yFWTGCfeKxZUR3mzHog+l6F71LkQxzok6ibaSnZcqVqP3Hd5G MshZ3Y/evjsJhyA0A0ELmANu1uss35+Mgg== X-Google-Smtp-Source: ABdhPJxU3EMU4IaLhLu05S2kQ3htHSRXXSF/YosIOxEPTcN0i3Tcd35C0Wu3vs3yQ1/OysYmu4YEFw== X-Received: by 2002:a6b:5a05:: with SMTP id o5mr6549826iob.19.1643412501208; Fri, 28 Jan 2022 15:28:21 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 18/40] bsd-user/signal.c: Add si_type argument to queue_signal Date: Fri, 28 Jan 2022 16:27:43 -0700 Message-Id: <20220128232805.86191-19-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d30 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413913763100001 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 Sat Feb 7 08:02:23 2026 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 1643413557396905.5184810227485; Fri, 28 Jan 2022 15:45:57 -0800 (PST) Received: from localhost ([::1]:34186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDawG-0004vn-CC for importer@patchew.org; Fri, 28 Jan 2022 18:45:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafr-0000kd-JL for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:01 -0500 Received: from [2607:f8b0:4864:20::131] (port=38694 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 1nDafg-0001aR-Oe for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:59 -0500 Received: by mail-il1-x131.google.com with SMTP id i1so6770267ils.5 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=1mpwYZNs4mJXgxPDyP8VAeZVM/ryFURuOJnVXj3MG+M=; b=u97vf602JKJV2/pGsxk/oR1Z8Gqp3y1lH95B6unSIh6MozQ17k//oMbo16XUEni2Mr /JQjMkSZ4qofbLlAKSQMtyHR7XK96uSPug4AkrCUR7+zOQhSQ1+yevH64AqBVksJLGOS gfDWtUN2ujR1GEgIUlnEFLTwpo1AjoH3hF6vn44rulNwgMwttgvYosXnn5cOYfWKhoCT LuU1dpMXfHqPoOF/04BUuIwsnDjyL1Jq/ZBGNrcDCo3KS+f6bg9adHX+C8qYm30xUEQx aBZ1Z39NfFK4SPunGN2R+WoqG96qMwPBF5oGDUdAtn4NHaS4OoVjR6ZEM6k39nvoS0/p JzzQ== 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=1mpwYZNs4mJXgxPDyP8VAeZVM/ryFURuOJnVXj3MG+M=; b=tnY8/8zMlbsm297VUke036zbLIR8GAnoXnR8X5qiB9ImG+NzLpmKKRu41fMCihIMIl KhKyJF6FEUFYIV2szKHGEcijkqsfvJbqesRkOfpCdIj83bBIjtdT9E3C5iL6FWtN/kmv OAgt9+P+MVlUCt9OqXYo05/+VsBCKTIPOg4KQs+whYqaeYW1GWHRTsjCcvazUBYEB6++ k/fPyQK+P2dSJfy8Fxuvbsyn0cRNNIjj1p+WNTTrXI2bswzsBf73iY3VGKJ0PNW8BapX HNPwmrgo+sD4BujGKJnIiEcC5+GG1w6eEoRrNYTXKi3IIZMcnlKb3Izotf788EzaNcq8 xG3Q== X-Gm-Message-State: AOAM5302OUA7MzL645SRPioQ1FC2WqeIvpT8+WRkeVpUVtr/6dSBKCyZ RSBJ8vzj7X/SRlIo5tu9cqFi8JdHKMQKQA== X-Google-Smtp-Source: ABdhPJyh/6CaT1Tokts6vpUci1O/javSrhHMXSyclKXpjRP+OEIvHOEqUCnqAJBiugQTMAPSGqIrag== X-Received: by 2002:a92:c685:: with SMTP id o5mr182660ilg.153.1643412502279; Fri, 28 Jan 2022 15:28:22 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 19/40] bsd-user/host/arm/host-signal.h: Implement host_signal_* Date: Fri, 28 Jan 2022 16:27:44 -0700 Message-Id: <20220128232805.86191-20-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413560036100001 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 Sat Feb 7 08:02:23 2026 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 1643414524981294.60008059505515; Fri, 28 Jan 2022 16:02:04 -0800 (PST) Received: from localhost ([::1]:35688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbBs-0001ua-8B for importer@patchew.org; Fri, 28 Jan 2022 19:02:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafr-0000ka-K7 for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:01 -0500 Received: from [2607:f8b0:4864:20::d35] (port=33281 helo=mail-io1-xd35.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nDafh-0001aZ-1D for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:58 -0500 Received: by mail-io1-xd35.google.com with SMTP id y84so9768641iof.0 for ; Fri, 28 Jan 2022 15:28:25 -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 o11sm14323111ilm.20.2022.01.28.15.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=6lp+mf01Obw62O4XR76se3KsYTrGoqPsoy/y1+puMOw=; b=a8VtirO52CbuAFtpIEC3Gk7gCk7FGNXpf1FUnNam/NRjegMfjn3cJuhIoCxPqKKyCe HCVt/gRwtmM8OGyfgMUlxICj0LHw/aDsV9nDTkPJQ6YIuTfKrg8FOTC974MzjjcVthjx GOkJwDXvSvHLaq9t9jKw33of669z2sUIOmL9Lm2gY/L2AU0AuuT+6oeDghy8+KCx8PKz pYqY2S09Qjs1JtaPwuqoAf+kL8PD1ZQTtIbVgsvDJ8q64k9VmhQBaO7N6jdM0XZtSIy0 sAVMdgj2RIhJPMagZXoclr9ArF4NdNChowCrEn569zJ71NSEjBc70nIjY+CgoPsr7apM opUg== 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=pXSctxY+5zP1ZIYh2lgwc10qOwarpdMlKttasmfgksnyU+FG2LM9zgGtjlwjLEOwh1 /2UwztO4yWCSJByJtKdrIlyAIAD+E7bU/MSb1eQlE4DLb6JOq/QEVfKcCCkz8ro/emsH mBy145VsP93UNgOIR4zjKF26ILej/pDjDn7z/YGQaWouI1ULpqVow4c8KxixfbvMeHXg L7hdC0BHquCjEg25c6dcFU3Pib00swgMIpkMSsUl0avDX3R3S/o3eNWmWxOL7eVmSeaW /MQvoQmQhesT1n+bBBnFOyC0Syf4wkb8rvqOsc1pswyywWGCLdr/OVb2AKWeGfgN75Bt NhZg== X-Gm-Message-State: AOAM5323x8H1b/loxLcWMA6h+/h62kriVvgb47p6dJim+K6ZFJv32FtU ghyZFMii0qTjbrjk1ZX1aq2CxhLkhNDBhg== X-Google-Smtp-Source: ABdhPJzMmkqf1vDsx3tSBJ/VkypFc841TrWazWjfyQJPWZ299HHaepW7NGGZZugsA+BFLoSyeTQyQA== X-Received: by 2002:a05:6638:3045:: with SMTP id u5mr4979429jak.105.1643412504591; Fri, 28 Jan 2022 15:28:24 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 20/40] bsd-user/host/i386/host-signal.h: Implement host_signal_* Date: Fri, 28 Jan 2022 16:27:45 -0700 Message-Id: <20220128232805.86191-21-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d35 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643414526237100001 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 Sat Feb 7 08:02:23 2026 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 1643414968622207.68766541908292; Fri, 28 Jan 2022 16:09:28 -0800 (PST) Received: from localhost ([::1]:47142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbJ1-0004Fb-LE for importer@patchew.org; Fri, 28 Jan 2022 19:09:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafr-0000kb-KE for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:01 -0500 Received: from [2607:f8b0:4864:20::134] (port=46750 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 1nDafg-0001af-PT for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:58 -0500 Received: by mail-il1-x134.google.com with SMTP id e8so6733367ilm.13 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=+J/ZcXBMkl7vIRUbXRkoafaooBA4s7iAGTsSYqX/VvY=; b=OtRKQ0OyHjbDTlZb8uDTFiqizwycj/piUQPqgrK1iBRncpZuiPHVjYopHPonWSq9nW y8B32pggl4KSoyyv6Hc1JrxZkoW4B+DYQpVxrWiZlgbMGZC+wn+FGqexEKciucMSgabN IAJQo6r5wveXmlWmdPZzAzELriWBiAIsBrzY5wDTlTUHhUhScK+CqQnaFTD+6cJC08+W xJCt+sxatQerdvoJt/csygEjXOZK5YDnlV4aO3iS+ngtTML5vrzANDVfkvuNRsBHhBYT R6Y8astKPWv0InG8VIOOxTL41a2sf5GnNNW4Cd0kkQZrqpKuhnKK0ulG0wf9OOm5sL8L aFqg== 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=p5udkMpflq9sbC7oK+J2SBhYGATJRwjuWXj9Huv2VsCZEVRHFUi9UjBJQf5Bofc24t RRGyH5MIunFps9FyAWjbUqhxEby8kIR70cAVMc5IyyZQynGIVVL+FGnCyrH43clm8YBw nYs8h2XwN1d4zuVBboJ6yZLuwPc9IJ3DTfmSU5Bb0zlwIano4T5BrHVTRPjKhAa1tmVi Jl7EHmEO+UANaOos4s6LLEz/9qOZbPVI13f43goVq9ndq/tsAULUDCX3rN6kgjMfs/ne wAydr6zE3MU8dEqYsQNKTv9xcCx2VhkPm9kczhI0OAWc4zTc8clPDi6Q1NF6d5ZpiH/9 vWTA== X-Gm-Message-State: AOAM531uZ+n4n01fGJ+NANnba6cDuHsVJQxYbbKaDubiBIZ3xOklimaI V6/9fv0O0FwV8u8pBS8se65OEqcfY9fTMg== X-Google-Smtp-Source: ABdhPJz9VaoGPFK7v6ISWipt17w5dy1ddBB+AWVTZzUfYaY0cxGEEbWFums4qIX1v1uMBaJ5lKOHgg== X-Received: by 2002:a05:6e02:b4f:: with SMTP id f15mr7631077ilu.265.1643412505450; Fri, 28 Jan 2022 15:28:25 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 21/40] bsd-user/host/x86_64/host-signal.h: Implement host_signal_* Date: Fri, 28 Jan 2022 16:27:46 -0700 Message-Id: <20220128232805.86191-22-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643414971634100001 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 Sat Feb 7 08:02:23 2026 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 164341533934591.90681013280425; Fri, 28 Jan 2022 16:15:39 -0800 (PST) Received: from localhost ([::1]:55664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbP0-00023J-KE for importer@patchew.org; Fri, 28 Jan 2022 19:15:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafr-0000kf-Jn for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:01 -0500 Received: from [2607:f8b0:4864:20::d30] (port=44832 helo=mail-io1-xd30.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nDafh-0001aj-1A for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:58 -0500 Received: by mail-io1-xd30.google.com with SMTP id p63so8829724iod.11 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=Uu/c8NbwOYwvWKC+skM1aHWNApehobWbRU2Oop3qnVw=; b=IYyvzCKyoEZ/T94A97bRvcEKj0QusehXenCc/Bue1w1dg0Wzbvk/XMjx8Gdnt5malM kizuj+B972FyXMHez472P1nWHtn1Vv9R61uy+La2E/1tJyKdHXgTqTGcI+XYb4ep9rTk q9eqNoXoO/ilfupeg4THUSELZEJTkRwW9ystyJjcuNB1iEV0aM/sdn5H3RaVfJHLupsl QuYh43oXQM/f4joa361rHw6/6b/VQHdZpoDRqCOPN2ZcbpC7WtgBnpzErm0mxAmapr9f FAZXT7TYrjBDEEAxHMs2UrjY91nmuPx9FQo5YpbsY+AYF/CTsmucGYCc8YWScJLSlCPx XXNg== 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=Uu/c8NbwOYwvWKC+skM1aHWNApehobWbRU2Oop3qnVw=; b=l+2OH87Ni5cC4WeQiCIRgzuqL9069KmNAJemhF+WILdm6KBaM1K/88zYIONcATnMWu tbWhmR/voRL+fKt7T3ekaIOcSOsrDtVL7kQe31KBRXRTs+XQFbTjw++Ai/hm30kmqkUL pkQFfEItKYMk/nPVPZcqycLHvxnmZU4w7QMx2Yg2vje6fVAhldmYQQPP9MZEswLdMAnW TJxCFAlbfG8H4ps9pRdhCAjv68AGZ+A2l8jO5g75AN7O1eYXb+NVOxkRZYM3axs2WYeb KEFAzOcdCyhv1uoFeBZFMv51yRocvGkmlznl2Lnx2uUHbZzfM7NYAJNGZ064zLqZSpRM R60g== X-Gm-Message-State: AOAM531lrS3+cFlssV/AEv30OHkbiBb9NY3uF4XQwci4wcpU7YBdTvo7 3/reu5NMnv0p25pKGtQZxPwuOYMW3gVxhA== X-Google-Smtp-Source: ABdhPJwtGbSUBVdNJiUxHxR9ieVaUJP15kz605ggfDlPWGAcpWKpIzzY758pwjlL2ryLdqyvCGZqIw== X-Received: by 2002:a02:ccb9:: with SMTP id t25mr5949816jap.290.1643412506236; Fri, 28 Jan 2022 15:28:26 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 22/40] bsd-user: Add host signals to the build Date: Fri, 28 Jan 2022 16:27:47 -0700 Message-Id: <20220128232805.86191-23-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d30 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d30; envelope-from=imp@bsdimp.com; helo=mail-io1-xd30.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643415340209100001 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/signal.c | 1 + meson.build | 1 + 2 files changed, 2 insertions(+) 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 5dbc9a7a365..155403d44f4 100644 --- a/meson.build +++ b/meson.build @@ -2947,6 +2947,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 Sat Feb 7 08:02:23 2026 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 1643414226195441.35245570081713; Fri, 28 Jan 2022 15:57:06 -0800 (PST) Received: from localhost ([::1]:55094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDb73-0003Z1-3v for importer@patchew.org; Fri, 28 Jan 2022 18:57:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafr-0000kY-JN for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:01 -0500 Received: from [2607:f8b0:4864:20::d34] (port=46962 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 1nDafh-0001an-1c for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:58 -0500 Received: by mail-io1-xd34.google.com with SMTP id e79so9637634iof.13 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=o+QXYNucUNSFJmHLJBCESvObOSc/YtVcWa7eAm4Hhi8=; b=UfJIkjbc5RndC1KbqQV1UkY8oJCJNKKEbQuGb1LmZaJ88X/4jy/SxxcIl79D7pS0RG CHUwY45uFuwroca1Gr2iaWt1m3fm3DVOFZ3yfarJGaljrDDRDQh/ePOsLZO0prs9HIQF 3ofbp7LEfp5rWxiYcNX3N9h2ZyEKRVMf4VDJkxJYuWZuJTP/5O0IJQrSM4Rf7+Adw2js NVtxx9Ab339aBaMbTZKra4fVuScEaWP4i5YIb6t8jNhDJ76XFcsFZ7NqlFplmBejklOE T0IqkPYGmWJCIUIP7NP4TdfetCQJulHPygW+ZbG8/raPCEIiYaVax3A8Ol7+/UoLYekP 6AfA== 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=o+QXYNucUNSFJmHLJBCESvObOSc/YtVcWa7eAm4Hhi8=; b=kOeW5+WTuC8Ogij6hINplirCfATIDDSWVZ+StpH+fiNLVwT8+pPn6yaTsKLWMmeslI aBAXfq8ogAxFm18Y4InMJaJuk3nHTRwpT3NaEnekk7FLyvia2R4A7WwzrW8DQnnUKPW6 9dtVF/n12Fjk7IKGAZLR857VPD1FH2KgD/FTylYjsZxtt1KjV/RcHnnJXpjyd5A4oznf dh6VR6E0vDDldgE7Rlel9WWoWm2l5Uv4fWktwjPk4Hm3TvG+OFvgZkMj0B4JNRog9hkp vyme0OsNj5sVogphnHyIYn2oCrBg92z6DiF0TpG9IHr7PK6H6Nfck6ZwBT3fmXpV+ws7 y8Eg== X-Gm-Message-State: AOAM533irBR/NuUXPEkA3yawdpySXf0F8BBn09pJqtRVE/pkOPxdju2O JylT31RWr/+epShRZJZX3wauNHDXWrEFrw== X-Google-Smtp-Source: ABdhPJwBPnEiCEmXg0pkvQx0cQpL0i+1ldyC83bhvZegwW1hldYWTluBfzHgnr5PBZUy/7CzhfzR/Q== X-Received: by 2002:a02:c8c8:: with SMTP id q8mr1419088jao.243.1643412507649; Fri, 28 Jan 2022 15:28:27 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 23/40] bsd-user: Add trace events for bsd-user Date: Fri, 28 Jan 2022 16:27:48 -0700 Message-Id: <20220128232805.86191-24-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643414228018100001 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 155403d44f4..5f433550718 100644 --- a/meson.build +++ b/meson.build @@ -2458,9 +2458,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 Sat Feb 7 08:02:23 2026 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 164341366133987.99740088773547; Fri, 28 Jan 2022 15:47:41 -0800 (PST) Received: from localhost ([::1]:37908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDaxw-0007s5-JS for importer@patchew.org; Fri, 28 Jan 2022 18:47:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafm-0000fs-DQ for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:54 -0500 Received: from [2607:f8b0:4864:20::d2c] (port=38584 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 1nDafg-0001as-Mq for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:53 -0500 Received: by mail-io1-xd2c.google.com with SMTP id w7so9703558ioj.5 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=zR/nS77HGi58NxQ6lCjkdyeychDCjgXBLWsqt7gXmDg=; b=N+tAUsyONZ3fqjywYXCm/S8hbwMB3pAEwDQ7uex1ACcy+8/5hsW4WMwwPHBZIQZzCu 5UJILroKztfxFbP+neXLpGuk21wJpMxa2GWRZkigJIAVa8McpffctaeTqu7MvABc1LkG I9K11637T7mfK47ohREMpxrb/H/o5BN7kdBDm4LpLHYyX1WHsu7GVvvC9FHSHFBZl7a6 7JzpQOV2Ax9sF+nP0A4YBVK0rI5s99BKLq6L+31b8xge3XN8PSvbb/AbRkCCFkRW1DmE x8EuEg6p7qakWvmcec8HRz1f7CKY2YknK1FzwW3iGjZ1ZEyCYzrx3Jl2cj0lBG4cfjqj dDmg== 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=zR/nS77HGi58NxQ6lCjkdyeychDCjgXBLWsqt7gXmDg=; b=WTVdFkDLQW9QZYlchYJ5rPr+PS4dR+3R5yXkxZVZ8pkU4uM8aPPKInD7ZLCmh5OC9h XoxyGE+/o8CDh5UhmiVveTzkroGccRFeeivZu+JOaNsV3kH9Bf6FvkfhGS/S0nE7kiBC m64blrbpTMMxVbpHnwEBRlj9MdH9c8uZsYrx85C14PO9lnbYvm/8GaLkNRHyMXnvCEUM T/ZqDdjKx0lMpEjzaqVYIHTidDFVs7RuLyvXVPPJC5TtWx9ABfR6AkhpUZlWTaBT5ty5 OYhM8GhF9T/7wX7qtih8AZM48U6HHgRhYcSkfCn60OWKXyjY2iY5L9eGhUipDU3AScjx WeJA== X-Gm-Message-State: AOAM530pKgbipRSkukolS+q3KLcNvFWCty5jY3q+hvg6H1L3gJBnu7Bd Gb2QTiV1cWaHNlLIfOqtt/JXSf2NSHtyJA== X-Google-Smtp-Source: ABdhPJxdn2BGwztF/+RiHK93gbItC13+6tVycPT59BJ0yJnzf5DcbNung78eLT/snFpODtoL40/hcA== X-Received: by 2002:a05:6602:1547:: with SMTP id h7mr599628iow.46.1643412508708; Fri, 28 Jan 2022 15:28:28 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 24/40] bsd-user/signal.c: host_to_target_siginfo_noswap Date: Fri, 28 Jan 2022 16:27:49 -0700 Message-Id: <20220128232805.86191-25-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413662722100001 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 Sat Feb 7 08:02:23 2026 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 1643413950423552.9357524732744; Fri, 28 Jan 2022 15:52:30 -0800 (PST) Received: from localhost ([::1]:46466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDb2b-0005rt-NR for importer@patchew.org; Fri, 28 Jan 2022 18:52:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafr-0000ke-KH for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:01 -0500 Received: from [2607:f8b0:4864:20::d2f] (port=41656 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 1nDafg-0001aw-Ol for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:58 -0500 Received: by mail-io1-xd2f.google.com with SMTP id q204so9679252iod.8 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=2cxVzUGQfUKapU6iJyRCNz3mEY37Sx777/SzAWGZs48=; b=mqPYau6BZSOjx1Yyr2PcHIXydufDYzi5wGSCMj0y3widGHG5xNhnySzeUVVQ9gArs6 0vkGwF7eJ0fub0/Sa+Bvla4CFfsbxaXeMSBG2ifpv1hXKDxvwJqAn55pZfVmmXEC7UFu nEXw02lBJUbsFpfFZ7ZwCeT3vzi9+fAYtfOfx8zZAC4WgnfI/bMLxYGgKKm34EV5Gjzj OwbtbUIt673JBOI+Stg5R+mlnmqAfpPt1Oncr3EoNNPFNr/zASzZOaoTndNO7Q1OYF6r G/spej2/9m2JtsWB9ElZHW1sYI5WDwRlWBNVbKLJXxKZcC9bBl5Id3g6pwRZQ9A5OYtW sahw== 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=X+By1lO7B1C6xkMWBNTzuvWjjsSDdJFOUam6WhhFrVWFqXMru5BPjYhuC9jY1rHZs6 mzZA+i7ScgomAh+RXREDUykKkPpLGgcoGKDaNK7FNdX6XxVqH1+lLy0hK4pktpKLxDsw WmurVuuNAWHjiZ+01msLFJSGSuiqFr8PIw44KQkjv9gAFztxJ0FL+5w3j3WEmVR5RWh/ 2JJoGXApsiHpGVOalGDqIVtm9RfNkoyYbigf2z+ekTAQ450dFYrLhLC9HnzdrIrX8O0n GLSCYq7oetLIv0NICZzkMqrUmvjMsnzKdLC1COt1AzsWJGAxX0/bLkELAYnFY0tuz4Q9 vKeQ== X-Gm-Message-State: AOAM533xHxDQQ7vfHkJLvvbAMj6b0eU7UtU8mkVIseVd5XoXURRLWr6R wpz7OmvzyerqwYsyiQYjDGpoNMSwt9NFxQ== X-Google-Smtp-Source: ABdhPJweJI0hjKaijWEdAeKDD7lX82DZcdgfrYkb3LHWZgjN+XpdVXcX2OGKlBkxStENhW9wc8BwMg== X-Received: by 2002:a05:6638:ecd:: with SMTP id q13mr787014jas.297.1643412510082; Fri, 28 Jan 2022 15:28:30 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 25/40] bsd-user/signal.c: Implement rewind_if_in_safe_syscall Date: Fri, 28 Jan 2022 16:27:50 -0700 Message-Id: <20220128232805.86191-26-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413953475100001 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 Sat Feb 7 08:02:23 2026 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 1643414464268544.1685730471094; Fri, 28 Jan 2022 16:01:04 -0800 (PST) Received: from localhost ([::1]:59856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbAs-0007Ab-Tj for importer@patchew.org; Fri, 28 Jan 2022 19:01:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafm-0000fn-CQ for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:54 -0500 Received: from [2607:f8b0:4864:20::d2f] (port=35494 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 1nDafg-0001b0-Ob for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:28:53 -0500 Received: by mail-io1-xd2f.google.com with SMTP id 9so9733318iou.2 for ; Fri, 28 Jan 2022 15:28:31 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id o11sm14323111ilm.20.2022.01.28.15.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=hAe6rnov1L/1Q8gAAU9EYHXCUv7q8m8Zw5gDaFIXI5o=; b=i590g+HIdO2YPXG1Jc+7+1DbgGl3NDXJCJ81jg8KH3F4Nw7G+h/VftksJZ/HYGilTD l8OLaJlvTzQjWroCJfSYJs31TK7xP7U0tyjj8wnu1mHSaAQaH1XduipPGKPBgXNGhW/A 7dWGWCWqXUBbChKOv9yGi5GL7rg31zRp6qAsResRyUWu7WGvNZYgaYrHWJ3nmSBqaW7M 42YnA85KkfcHavUEJGYZSaPMaarCAtstbaREnWeHaORtbfhbkC337x2cab4TEDmEcXrn ZDLEO8WsHtRSyj6frSBrbS7KWWSzPm5+Au1GwaJ75Vg5RMTvo6yGPDscQQ4WptrKeccx HkVQ== 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=hAe6rnov1L/1Q8gAAU9EYHXCUv7q8m8Zw5gDaFIXI5o=; b=qP1VoL1Rmr4QKwOTDCnNWnRrCR9MWnXJeVxqj+FLeWWGWzo3DLWApLjyh2m3uAFSMZ 88HYLQab8Mle5Rk0ivmAVkBJFIZ4t3kQzEew6BS5LTEWArXv1DihX0tkZfFbu8ubpzzo Rob1iGP8h6031iZg9yJlI4I+NMkZvtLGQnsDemTGXV7sSsvNW7EIsuKL3dtJU8K7zsqS xP1R20kHa1wYR0sDj9+C0/10iDQSbY3bt7P9lasg6O/jYaryDLxrNuNpDY2RVy6UzIFE x4ufoOinVxHxVbbXbTsFv4STvsZ5lOA41rPW/F1eTMFOQi6DK0Tsjf/JcDn+ZwkLtq8D fNoQ== X-Gm-Message-State: AOAM531iEMQavWYbtAVCl/3CJYq0pmw7tVLhLkc0l71ODl9iPLpl3qWz qNF0XHXW58y8P7XPF6UGtiLhwpjMV4/Kjw== X-Google-Smtp-Source: ABdhPJyJqborm+GJ2Fcp9KcUWVpvvLxEhN0ooSP7tkftZaELuHIcznbVeNwTB+JzYaVzBBxsOi1vTA== X-Received: by 2002:a05:6638:12d6:: with SMTP id v22mr3423242jas.202.1643412510967; Fri, 28 Jan 2022 15:28:30 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 26/40] bsd-user/signal.c: Implement host_signal_handler Date: Fri, 28 Jan 2022 16:27:51 -0700 Message-Id: <20220128232805.86191-27-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643414467512100001 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 Sat Feb 7 08:02:23 2026 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 1643415832839240.35411010999337; Fri, 28 Jan 2022 16:23:52 -0800 (PST) Received: from localhost ([::1]:36090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbWx-0008QY-Ta for importer@patchew.org; Fri, 28 Jan 2022 19:23:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafy-0000qK-OW for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:08 -0500 Received: from [2607:f8b0:4864:20::d31] (port=41658 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 1nDafi-0001b4-4i for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:04 -0500 Received: by mail-io1-xd31.google.com with SMTP id q204so9679328iod.8 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=sPl9lqrZjcfTpqegDhQDXRvfLIYwDJ07NuHAvjSC0jE=; b=a/Ow4cnhtWLOoclxNpD6jZT+838cyXdkwwrH6rtBVSwbNLO+nz3r26feAVITO/eliD pVKjD3QICIrnJkZU/9iV0Ke3jF1+VaXFTv0NDaEGKbC3aEQt/+8KLPKxE1yUtrzMhqgi Vsf2pI8IZ35xB63CaY1LGKXDpc7PdhOekm0KI7KWFPlXRnaNQZiI55Ya0D7IcTCppb5k dpsepgtprd2uZ5DOC5qHPsViv3HKzTGjDyYVY39+SKrf3D2amAcPOyDv2iVw/4bWTC6C VE9iMesl+dfIZ6gD2VFqVnwyAdrvnarXb4LDd3aw+qITRgBf9Q4ETsaPlrJeEPYeIhQJ cssQ== 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=P/7+JBH0IgYQjLt1hBmT6Zsw6tbi6DYzBNz2ymzWA+SwFLo47oafb8F5Wp0k19ovf6 cOCEzC2Ko4XsMDxEjxxsqw9RlwUFN2P/6W/EmRHYy8AiMe2ESviTEx19ouwID/JXHRSi Dw/7edFRt7NkEkLV/gPtPicdryex+rm5BJWQIgz7LjCSuXFh8jU5zbHmTHQWhGhPWaSS ucuSinrmSi2ZUXKQxZ+49msUD00/2XUvqlYyGbjDo4XmGIklV954AFypMf/gDQ8v7wBy +NCCebqQRmk8kiL33rhpkgr4QMK9pVgOfuDUX75iKYyHNRkWHY7E8xzrVVgCBOIWn+uT zFdQ== X-Gm-Message-State: AOAM530ZyXzstdFwfFx4VaM9n9bKBEmbaMtAWHgPpb9gpUYV1Dd2dlET XQ02zBmtwlu05YWeivmGxdujt2r2TiQCJg== X-Google-Smtp-Source: ABdhPJzPN30O5nxjObgGg8aoB5RZkQi37PkfLoz12rjmCDQcg8n/yUJ8dcp0wbMg4EsRBTyG+H+TBA== X-Received: by 2002:a5e:8711:: with SMTP id y17mr6289313ioj.175.1643412511871; Fri, 28 Jan 2022 15:28:31 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 27/40] bsd-user/strace.c: print_taken_signal Date: Fri, 28 Jan 2022 16:27:52 -0700 Message-Id: <20220128232805.86191-28-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643415835153100001 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 Sat Feb 7 08:02:23 2026 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 164341506268535.99517374874847; Fri, 28 Jan 2022 16:11:02 -0800 (PST) Received: from localhost ([::1]:49216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbKX-0005qh-Pu for importer@patchew.org; Fri, 28 Jan 2022 19:11:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafy-0000qQ-Ut for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:08 -0500 Received: from [2607:f8b0:4864:20::d34] (port=35499 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 1nDafh-0001b8-8G for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:06 -0500 Received: by mail-io1-xd34.google.com with SMTP id 9so9733433iou.2 for ; Fri, 28 Jan 2022 15:28: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 o11sm14323111ilm.20.2022.01.28.15.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28: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=U8VtaM8f6H1mBedMcMN2t5hogqkVzA4l3N+z2sTiAUQ=; b=0W4CxeF2+pgujyaOgj9CfPAnDZFo4JLKzUuk7+ApE2+MLvo9S5woNtx6ruQXuYOcPS MAESSzdCKJDUKbdInPlZsiG1YTQ63PREnFEDSoTrBreFHQy+UcDFnkOYG5aMn2VljvlJ OVhHfDn8ttaISlASXhoWJPLY7h/H6FfBQSAXuGin90a5RNF9HQvEkEteKB5ofampmUdW U7J/g6oUPuoWrUsUiJzrekxJZ/PdtO4Vhp+mTZWczYxq2Hh4vJD6/CIJ4i9h4BUBauWZ /z3ziUCzdCRG6wjFzOe8R5tyRKWm3JgJaQewfMHitmZdGFGWFhwhleaa5VqJcLTcYroE lLwQ== 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=7/UyJ0aM4mkTE+KPgD+ngP83fuik+rP/kuT/ZIBHnjHQlLlCXg6L28ZRE6Q0lcqIrl fWeDi6G9IrTufMleJWchFp8i6PVketHS7sFfNwvs0t5cIDzRT6p70W9H5f8cjx6NDQ1J 0MrsaIU3Wi55dcFN47ei3m0f6ls4EzCGqJVm93o5atNAGoVbI+jwyKHyYljwZbH9ixq5 4FcpfkJA7ZlZ6vvolxE8Yiq+F4BOM0pF6STCjWBJWRwT9a0fH2PHWb8mthzjTofMQGcr U23XMlh1gVI5dMPiL/gVjSv0EBt65lWWXlCGdpKwELHj46ZzQW+VGhPlivpqAqyyzOdo Fuhw== X-Gm-Message-State: AOAM531U4CaTTnqo5EeLAc4QmBL8s+kzE89d51A9lUtZpR1YwWv1fC84 Xzxtf3Z4ieBOw+xenNnYRBV+xL4U+o9nIg== X-Google-Smtp-Source: ABdhPJyhXXIuaxwZlMdJ7BLcMQU9YCJqWJo+Yrl9VorwmMf0RmIyYbYi9zVkaVrS8URVfeP7wB5lvA== X-Received: by 2002:a05:6602:1302:: with SMTP id h2mr6762269iov.65.1643412513661; Fri, 28 Jan 2022 15:28:33 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 28/40] bsd-user/signal.c: Implement dump_core_and_abort Date: Fri, 28 Jan 2022 16:27:53 -0700 Message-Id: <20220128232805.86191-29-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643415064850100001 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 Sat Feb 7 08:02:23 2026 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 1643413856665350.6437721169226; Fri, 28 Jan 2022 15:50:56 -0800 (PST) Received: from localhost ([::1]:42622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDb13-0002sW-Nb for importer@patchew.org; Fri, 28 Jan 2022 18:50:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafw-0000oB-Ro for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:04 -0500 Received: from [2607:f8b0:4864:20::d32] (port=34805 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 1nDafi-0001bD-FD for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:04 -0500 Received: by mail-io1-xd32.google.com with SMTP id i62so9720936ioa.1 for ; Fri, 28 Jan 2022 15:28:48 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id o11sm14323111ilm.20.2022.01.28.15.28.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MVWZUYxrpCifraNDGYSj461HH4N52sJPo6Fc3sNZUKk=; b=SKNLiLJx7kUYdSiGyFtGWagPIFJIAeW38/JzLx72XtDQlKwQyN4bwcfvMYUqXwafFz 6PmYNpqsVdh8EEgT0f7XsJM7Y/+wRKffcSsp3iofzqvHxRR3dTcQa+B/Zq1+HKULRJXg NPNSlxNDwtO+R+XzL7zVm7nS6/AokLudiKY4BiH5sesftsu3C4L+zuo3PqtrZGfhmuS0 ASBsFXs0svV5hxbO7dc5KHXIW/LEWqCmd9LGgEkYgykmXeaO66p6szfa7bYi1q6gjdtE biJ0OiffYuJBYFnKA/6oG4TnA0oW7Kk+OtcaQy81MPHw6R/eAXj4Jd+wAFGf19Sk+YgS RbYQ== 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=MVWZUYxrpCifraNDGYSj461HH4N52sJPo6Fc3sNZUKk=; b=f/ll18NMDrVmjEsQeTk2y/HhyFYCZAWS0lh5HaRLLkulyzeFsjPn8e4/WYo4s4q943 KQsxVoyykV+WU99+fsQ0j/CS3gf+zvUQBtmN0NLUSSzqN4LnfesuzgnjDT4kfdIEqqZS zDbIQZMU/fCoNmjcZIozqhToqJgA3ibZO8Z+cv4bGd5rUt1DyqkGipBcKoE+mDwcKYW/ 908es1OcNU9cg1b9F93IsLOv4LIXlUAetApbygs1Rq8pnl24kUg2jcXAWr3sXyf4QVyK JZEeVz2ORz35fpb5Wx7qGNzZO3889joZgpDU7SpjHX7gOPSFdNKbYY6v1Sll5fcY3RuH bFiw== X-Gm-Message-State: AOAM531wkih8BIowsUowpeTUekGPcnXeotHV89EFfrwoOce0skLiiHFU l+B8D/UqEUwZ4BObqt0lSqTdsYbjQRpqPA== X-Google-Smtp-Source: ABdhPJy9YFodkovJdgOKjHAYuUSbpQmle9sofC4sfw2ARORPVMZDqV6hG7WLUilcClaGuDkIErEN0g== X-Received: by 2002:a05:6602:2e90:: with SMTP id m16mr6703387iow.74.1643412514732; Fri, 28 Jan 2022 15:28:34 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 29/40] bsd-user/signal.c: Fill in queue_signal Date: Fri, 28 Jan 2022 16:27:54 -0700 Message-Id: <20220128232805.86191-30-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643413859185100001 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 | 5 +++++ bsd-user/signal.c | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index a7964776fdb..1648a509b9c 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -85,6 +85,11 @@ typedef struct TaskState { struct bsd_binprm *bprm; struct image_info *info; =20 + struct emulated_sigtable sync_signal; + /* + * TODO: Since we block all signals while returning to the main CPU + * loop, this needn't be an array + */ 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 Sat Feb 7 08:02:23 2026 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 1643416090906762.8846941133354; Fri, 28 Jan 2022 16:28:10 -0800 (PST) Received: from localhost ([::1]:40374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbb7-0003Cl-KN for importer@patchew.org; Fri, 28 Jan 2022 19:28:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDag3-0000t9-Ix for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:12 -0500 Received: from [2607:f8b0:4864:20::d2b] (port=42735 helo=mail-io1-xd2b.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nDafi-0001bE-UP for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:08 -0500 Received: by mail-io1-xd2b.google.com with SMTP id r144so9659744iod.9 for ; Fri, 28 Jan 2022 15:28:48 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id o11sm14323111ilm.20.2022.01.28.15.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rw3tCyrqXVGsCR1NJHkGgUyguO31bINLvGmuRP6N6Bw=; b=E2/5Eu6z3Y+04KpoPr9MjkG+22j5QaD6K/agC+9iTnYs/wzeIH0DyOPqxaSvbilo4P sivx84dV9/NExuVYe4z8sLiNpt6OJepwXcyyHUwLLdf3/P3tyRaV2TU6dvTVMEFQQGaY 5mwyy3qePV+kmaValGkTibw8mlK8WTVMQOfOyZa1y+nZtFJmFtLtVDsM31yytOkXu+6l XpA345B6Imx+zkXtl8/Y5Fv0Gbl8lLqwrmDizQXPhsB4q7JHAl/duczYbpknMf6boJWE nWjM6D+YLA0kzGX5pCSvDExkmX93x3l8KgyjOIB0ZnQoJpDlDn+ygvLJOlwzQer2PmRU n+8Q== 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=rw3tCyrqXVGsCR1NJHkGgUyguO31bINLvGmuRP6N6Bw=; b=PGw0ZTZ0NOl1hb85GRZtr9TXe34fnuSaliW6VVBH75kBjAAlkdDDsSAdld9Slxq16h 72ExQzX9SXyRNNk80Exz/AsdXz/6PKfAkpVf241GWd040Sy4g2n61KpOGOpbYY2oUjkx SZVMT/TeLTAW74PplE9HzTAZ3awlVNQ5CAboNCiRmsbkTBelEqggTsTs00Ij90Izai1O brgr5OvzDYa35arsAOKPSbR/R1XiWqayS5D+cYPNkWyHCO2YBHuJbxcM4GX0FVcD+R1t FW/a4599hlo1oQ+VX3xjvWCL9VtqlnbmxDu1aSMctGHmXAC/T2tN9zgZDV5L00WEIcak qdRA== X-Gm-Message-State: AOAM530Rt9/pvB3oqvIYKzipmes9Uv+g98Uq62CLvT244zModwRDiuf6 LFyygPL4+icRHZ/afZjmPTDSeqLpCb+/Mw== X-Google-Smtp-Source: ABdhPJwIFN4GL+CZYKhWlCcTfdk+T5Ii3Ulez/L6YtVM6AMMNmPt5zRK/gs+vsnGAWU9NhV6PKqaig== X-Received: by 2002:a6b:8e89:: with SMTP id q131mr6634114iod.77.1643412516161; Fri, 28 Jan 2022 15:28:36 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 30/40] bsd-user/signal.c: sigset manipulation routines. Date: Fri, 28 Jan 2022 16:27:55 -0700 Message-Id: <20220128232805.86191-31-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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::d2b (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::d2b; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2b.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643416094296100001 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 Sat Feb 7 08:02:23 2026 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 164341568100342.64943199576669; Fri, 28 Jan 2022 16:21:21 -0800 (PST) Received: from localhost ([::1]:33978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbUV-0006vs-Rb for importer@patchew.org; Fri, 28 Jan 2022 19:21:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafy-0000qJ-OY for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:08 -0500 Received: from [2607:f8b0:4864:20::d34] (port=40863 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 1nDafi-0001bG-FE for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:04 -0500 Received: by mail-io1-xd34.google.com with SMTP id d188so9676666iof.7 for ; Fri, 28 Jan 2022 15:28:48 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id o11sm14323111ilm.20.2022.01.28.15.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:36 -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=C76G+GuQMn9cxisURWPURc1dlhmprPr1u46P1kEgqjQ=; b=k/XZn5GQqft5690/c68hNofjVVo42CoA+zOHp4v4m1tXWEPbOEb7+XEsi9p2u2YiuN sRtHvY6i9bOjNszXQkyoiyrH1eZmZt9xnOEBIPrF/In8oZbxzUzz+dTGBbWRR4JpNdsB eZFvJJBoYSlwipp3tpUC75Pw9OtjVYX4/jsfPpEVbSlYSAIQ/hQ/e1+0vxe/wMmZ3eWU IXEJ/URWZTUcBo/Txw7x5vA/M5htkACZInJBi/fp82gt514gyNY59Lg42n9OiX8DQbGs 6BRF+6kmBCcRmKmCFFUkE5kVRMJct1SEaVtmUp7+KbZ6byl7aV9xaHytySX8DW2gisy9 uWSw== 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=C76G+GuQMn9cxisURWPURc1dlhmprPr1u46P1kEgqjQ=; b=f5+Be4S0trWyao9Zo2ttrr8tvh51xVVr2Qs+nH1qqSJ1OVkobb0QjOsscwWXPh+3e4 k67EMp22yrFHjM4ZAy8WiMSxGCBwVtY2z3p99OsbStSzswiimodoPyJcNCwXURR1NfNL KaaEPuLl1bmYq3bkopNDGq0kUyKfvfWRLH8xTucY5NCb0n+cBknZFbHzDOBh0lL9gEUW TDMI0ReLT4meEk41b6fjCuk8g/a1PSarL03X5X3BsAEFzchMwdBqIOx5EvHAaMvKS8GQ vT8Mb5EbHOBIjSsolF1wR0T4awMtBnEnFTqQk22yckRAHVQYaQO8XV4hEAH3UA76oBqd /oiQ== X-Gm-Message-State: AOAM5306SUSNd+4U9qdoo98n9PGBGGmVW3x2GD0OdgGdC1EHc2QQO395 +VyjbjoryGxldcZt1Cw6U8iweT8fn8XORw== X-Google-Smtp-Source: ABdhPJwh/w0cT6RfPNQY46H4diCS1iMrrlZUW4SF6P2ZU+xS3MHAiE2Rhs2P7WeUSYiyjQMBQEll+g== X-Received: by 2002:a02:b0d8:: with SMTP id w24mr2557068jah.241.1643412517104; Fri, 28 Jan 2022 15:28:37 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 31/40] bsd-user/signal.c: setup_frame Date: Fri, 28 Jan 2022 16:27:56 -0700 Message-Id: <20220128232805.86191-32-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643415683798100001 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 | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 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 1648a509b9c..de20650a00d 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -107,7 +107,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..dbc13736073 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,79 @@ 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; + } + +/* TODO: make this a target_arch function / define */ +#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 Sat Feb 7 08:02:23 2026 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 1643415504815139.03084778992445; Fri, 28 Jan 2022 16:18:24 -0800 (PST) Received: from localhost ([::1]:59492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbRf-0004pv-3V for importer@patchew.org; Fri, 28 Jan 2022 19:18:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafy-0000qP-T9 for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:08 -0500 Received: from [2607:f8b0:4864:20::d2c] (port=35492 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 1nDafi-0001bH-Gv for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:05 -0500 Received: by mail-io1-xd2c.google.com with SMTP id 9so9733612iou.2 for ; Fri, 28 Jan 2022 15:28:48 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id o11sm14323111ilm.20.2022.01.28.15.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:37 -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=LXHWOyKgi1YLQ++jL8z64ESafHKvZ4x5SjsBEBXqU1c=; b=svCeWaGnXbKPNzF+Wi0NCD9Zx9HyFO/IfRzN8fAlYFIOwhPqMdjOEbMxo5zZYHQauW SimihmSnBTXjCCWG7N4HWEJpeqO4rhDTz2NUcueb+QOpG/VJ7jaNl/Uhg8sv1eCGbjFv rUZvIqNJNjtQO7ujGCaOFYUHey20JJ8GAYGfTfF7xdL5tecURLyUDZY+H3vb6W745dhW rrS2E/94LSiTG2L7/3TqNUdvxlS/RPGdb69QoNwvxLjLyWxoO+uVawxyKncp1XAeHTNG 9hDnf7uwpfCWTx5aKJqnqcARlhM4QZEhGpK7NBvZtnQnTWBjdSwSUYB6hcIcg+3wmie3 3trA== 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=LXHWOyKgi1YLQ++jL8z64ESafHKvZ4x5SjsBEBXqU1c=; b=0u6KuURBMfarhKWmAE52biq6S6e6lc+PfHB7Jf6CO1THXGoAOfb6xybTtfxM2GjRq0 8pTkXwgXj2R7tTb1rQ7iUrLLNAAUV4mxBlJJV4cuL54rtAODhlVTKv1VFCI2Ss1cv5f1 d/fB3zoykM0Rl5+HBJ6UOR/3EXcNAwjAK0R/bWr0Fk1wOM1EqX7xCLN4eIL1I93aOs1u pLfxg0n5ZbIVAsIDmwlnc8dEHs3WT++VfMO3tSIfy++LSckXBChgxQEX0AqTq/NRs6zQ jUxk2Sx637J7otzJg7R8oGaWOMfDzsCPvl4eUV+4fZDAJXj5wXwR8oo9TlTbvHKnOiaQ NosA== X-Gm-Message-State: AOAM532TvHAHYdO7PDW2Ne+IEe2HLnREp/1vdn7iUb5+pZBlqM82LJNC yZcT4CyP7JYikdJvl2uBultHJSmWkw4U1Q== X-Google-Smtp-Source: ABdhPJwAYSuWWkHWdevTCQligG1WL8pF/wOMJ75H5pQLjKiPZE/au/TJnmVJFAOEaxqHmcH6Fv7a0A== X-Received: by 2002:a02:cf9d:: with SMTP id w29mr5656496jar.29.1643412518450; Fri, 28 Jan 2022 15:28:38 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 32/40] bsd-user/signal.c: handle_pending_signal Date: Fri, 28 Jan 2022 16:27:57 -0700 Message-Id: <20220128232805.86191-33-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643415506898100001 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 de20650a00d..02921ac8b3b 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -99,6 +99,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: @@ -106,6 +108,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 dbc13736073..366e047cccc 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -616,6 +616,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 Sat Feb 7 08:02:23 2026 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 1643414101830518.2042499527298; Fri, 28 Jan 2022 15:55:01 -0800 (PST) Received: from localhost ([::1]:54194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDb53-0002x6-5T for importer@patchew.org; Fri, 28 Jan 2022 18:55:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDag4-0000tN-4C for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:12 -0500 Received: from [2607:f8b0:4864:20::d33] (port=46962 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 1nDafi-0001bI-UU for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:08 -0500 Received: by mail-io1-xd33.google.com with SMTP id e79so9638143iof.13 for ; Fri, 28 Jan 2022 15:28:48 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id o11sm14323111ilm.20.2022.01.28.15.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r5D/XxRSLmmsB5rAEeVEsKXhTzCrfhyXP8EzMrhJHxQ=; b=dS7yuikl/7GIkxCvhMCpTYOeybrf4dW+O3VbTrkgvAPvrzu8zEd0p57yBfax9CVu4B pn79n6+ZnRqU9JyABMUlRNv+hlIP71edCn9yq+UN84peqmzGMu2WKBF4iYRoho02uOv+ TahXxh9+RzZQqGMKt7sCDSnL2S+Nd7tw7QUG1sAu8L/DwHRU3uCoSBeH92rd2Ivlri2i nyESiySds6Y0axmzNGzFx0EObM/jfs86x2Ks8ZcwFUiqtlR+PTUx1UdWlGdGFFvtySdS ito4VEsU/EC9dd61IfUFoNbm6IFyx3NLq8cjC4P8lL+qU0OW0dyn+KvVUPZaQKmiS3+h pghA== 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=r5D/XxRSLmmsB5rAEeVEsKXhTzCrfhyXP8EzMrhJHxQ=; b=rp9Z2jJcLA4Eoqf/D+Oo59uqVkD/tl+KFzcrKdpz6Eyi3UstZb31Tz6oabW+CW/Lj4 F/mY00KNzSiX2jyueU8s/xpB89In3C8RZcpzxKvi06bskoj6ArwTpF4WysBIPXwoVg4i xwuACLSeF+rrDZLqNvy2zzst8AQk81I24dFfDTPU9XIVhWF/FvPqxm+FVF3sKQtVZEYo ePK2cQPrsV9l9hb9vx0/tv4Sw6Pg0hmoP3pC9Z4NlrXKLJ/Qr/ckb164DzemRnKLStYD wuqIAhdgalmsiFjmes65zwZWrlQOA92MW1XnylEi34sQ3ZHbt8OZd2E1FLnhTI/ICJ4x SzUA== X-Gm-Message-State: AOAM532UxFIUrQdaNPMQFkBFBhCn9FRwrGcitCMlYRmR8dtxwoAHpwLT PdGob+gb9pqUIpe3MXEpcQ/VeH21WkGQ1A== X-Google-Smtp-Source: ABdhPJw2S2BHrLQ5ORZGNRclRpRmLBwjTxubx18+Ly9zyfcTRlKE/bF2uyEk1tmXZuvNH9w9/2JIdw== X-Received: by 2002:a05:6638:389a:: with SMTP id b26mr5141577jav.158.1643412519344; Fri, 28 Jan 2022 15:28:39 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 33/40] bsd-user/signal.c: tswap_siginfo Date: Fri, 28 Jan 2022 16:27:58 -0700 Message-Id: <20220128232805.86191-34-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643414103363100001 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 366e047cccc..34e8c811ad6 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 Sat Feb 7 08:02:23 2026 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 1643414060300816.7843518320684; Fri, 28 Jan 2022 15:54:20 -0800 (PST) Received: from localhost ([::1]:51218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDb4N-0000wm-D2 for importer@patchew.org; Fri, 28 Jan 2022 18:54:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafy-0000qS-Vn for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:08 -0500 Received: from [2607:f8b0:4864:20::d29] (port=45765 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 1nDafi-0001bJ-FR for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:06 -0500 Received: by mail-io1-xd29.google.com with SMTP id s18so9653085ioa.12 for ; Fri, 28 Jan 2022 15:28:48 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id o11sm14323111ilm.20.2022.01.28.15.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yFznSEKSLa4wr4LT6m629JqoMGJyil+XeLDgIrumdQM=; b=bBhIB7fpjkX15uJlky2DIAm0jocicqU/eRephtQMqCcQYWU1ii3iQahHPi2uLAS+bz Iu8C2pfkE/26sUwSpCKggPucunHd6MNVP07ynUTXd8pS/YDYa4bOD0HcEMXa7V6uIZD1 VQYsxVWO8oU7AlZQT+HxPuVERTZzvSZbSl72ocfRE2ATtLrbKl+i2t2T0mZTVHOYRDRM J2Rt2m34g30StzTktcbo5bfKxHWO03PlEDnHuqZVRUHlyRlVynF659JsuT32gAfVuY+z 1EZStsLZ6zYrNpWb5OIaN1THLpSqkBGR/wzct6SER93z4H6PFS0xJ65NviiiGSdK32NY QCJA== 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=yFznSEKSLa4wr4LT6m629JqoMGJyil+XeLDgIrumdQM=; b=DePXAQYkCaaYqlNz3zy5EN6QIznX65xhIE0hummLKAeC1MzAxQGgI7frwub6zQ0UiA pF1hF658GGPt5Yn48HMdUXgk3VZzfFygjQYnzrtqhTQwILKrrSI3geXlsfih5te3+BaS hNIwTL+FKOFKl4Mt1aZhPSQTL8lUYhK5VeeFnJOzgbrXxpu6ZXMvrCmyAdSXD+y0Xe63 j6gB8V16Z4rKunYCebBgD8JGJwzUnRpf1Pjyeun9lC7UJ7RdcwO5DuiFxTQPuTz/J3rS 4BbmhR5z5PmNM08s0i+zf9EMSEK/d0/3yjHkVtnKbwv7vjb/PkRtUMZQK7YCYLFKpOcf Le6A== X-Gm-Message-State: AOAM531GXCRuT6NQ4JBJ3MBzwWpN2dErljei4zencXtTr5wZF+h1EXjK Tq+xDbCGxlQ6rHAJEK8JZMolL67ycH0XjQ== X-Google-Smtp-Source: ABdhPJyS8FkunFSXLhlBIgnbrMYxUwWBh4Idi1HEyLuGbu+FPFN1hUd0oQkUiVPiyAcllXDoc69OdQ== X-Received: by 2002:a05:6638:1450:: with SMTP id l16mr780510jad.30.1643412520555; Fri, 28 Jan 2022 15:28:40 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 34/40] bsd-user/signal.c: process_pending_signals Date: Fri, 28 Jan 2022 16:27:59 -0700 Message-Id: <20220128232805.86191-35-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643414061563100003 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 34e8c811ad6..4b398745f45 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -756,8 +756,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 another host 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 Sat Feb 7 08:02:23 2026 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 1643414860591368.13324762666684; Fri, 28 Jan 2022 16:07:40 -0800 (PST) Received: from localhost ([::1]:44244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbHF-0008WK-Kn for importer@patchew.org; Fri, 28 Jan 2022 19:07:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafy-0000qN-SU for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:08 -0500 Received: from [2607:f8b0:4864:20::d2f] (port=34803 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 1nDafi-0001bL-BP for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:04 -0500 Received: by mail-io1-xd2f.google.com with SMTP id i62so9721216ioa.1 for ; Fri, 28 Jan 2022 15:28:48 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id o11sm14323111ilm.20.2022.01.28.15.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EfXU/bU5UrfXlO2lCXn1UwsX0yCOpSJYrOS4ONrz1/I=; b=o3ZPRmjEOhUj3IlO8sVSmIoYaM0lAJqlLz8/yMckhRcbPatoGUBwkgrg4fhj5yG9LY ehVoWzlc39OWN64s2KH8hTpbTyR+4eaTv0VvLCLo+eygN3i9WwbURgwqay9+4iSTGchN Iwn1mRlcRRP9CysgKn1bCM49okhgQsfYAzCDn7SsSVBFL1esUz1WNCgSRQBaERJ8DA6r eYm62nmD+h/oAstyDUzsYXhg24dzxd+p+PIxWVEZ7617EZSH7mbaCWVN7CGjkOm3X1g8 9zwhPYfPi9jgLICog2vGA45PaAA75ENPBpNC7HAwxF5g4Gx08eAJ5qh4TMoMunlmmx9O FonQ== 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=EfXU/bU5UrfXlO2lCXn1UwsX0yCOpSJYrOS4ONrz1/I=; b=4rF4lKwe02eitiyUrU2dG433kbR56N/zL/hrqSpsvO74bKK+sPw65pQo/dU/HZyuov BfWiNMAojNVuNo+YMt9OPkenKcUT5Ixo+H8PZTfhqB8ICbDE1CBrDXLqt5hiyasfyevT GSIHOpaZCEetViu8sxG6XWkt18rzlS7ExrQncMQR3RAPAFSDw4fouCZntD8DMiixtZwV ME9UviyireMiIwMJ6hpuRzL5Ewo8QCKi2Vc2nH4Fh0d7QljT2bBn12DWIAzLqdinQYt5 UCY1olA4TAhMIRZeBXfr7n7y6xZ9kmmQDKyWJ9psmhspVFCS/7vUbe5Uy7YcOg8sJnYD lS0g== X-Gm-Message-State: AOAM531u1I9fS631+kHJriaCav62YQkC3CdLHd2qw3SXaKkCRuOrtI+Q F8wcDkFqAZrpedfUbEK6kYsFuBdSTVAgaA== X-Google-Smtp-Source: ABdhPJzA9CqAhfs611qcVmGEAsHsXHFs8mK7NvxG0XNN8TzMV3gHAwBAE9JOzVJylyG7+F1Et+IjHQ== X-Received: by 2002:a05:6638:28f:: with SMTP id c15mr6079850jaq.188.1643412521438; Fri, 28 Jan 2022 15:28:41 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 35/40] bsd-user/signal.c: implement do_sigreturn Date: Fri, 28 Jan 2022 16:28:00 -0700 Message-Id: <20220128232805.86191-36-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643414863069100001 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 Reviewed-by: Richard Henderson --- bsd-user/signal-common.h | 2 +- bsd-user/signal.c | 55 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 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 4b398745f45..79e1128d4f6 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -627,6 +627,61 @@ 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; + + 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 Sat Feb 7 08:02:23 2026 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 1643415229742667.244085593527; Fri, 28 Jan 2022 16:13:49 -0800 (PST) Received: from localhost ([::1]:53416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbND-0000TB-98 for importer@patchew.org; Fri, 28 Jan 2022 19:13:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDag1-0000s6-4E for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:09 -0500 Received: from [2607:f8b0:4864:20::d2e] (port=46958 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 1nDafi-0001bM-QR for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:06 -0500 Received: by mail-io1-xd2e.google.com with SMTP id e79so9638224iof.13 for ; Fri, 28 Jan 2022 15:28:49 -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 o11sm14323111ilm.20.2022.01.28.15.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:42 -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=Rj0hwqiot9yKo/V2+tI2H/WfjhvlejzlOrnB8xJDZDI=; b=1Ne4YOWiNqatRAwpRYoWsGuwuRMknECzzGtNjRspXz+5i0BKAY/sbfT4OkzG1pdpZC /y8qg9fBeZeoCXAeFqwfs+u4zpwps06X8ttciy3gCWmzgp3nZFmM8ZJUgB37FyJ7BZoJ IehI+0W1M+BCHQwLbjEMJDY4fr5taUlsvSBllC4/P2kunb5kDpbLTRS1ZuMArafiEvQ9 YVCdC4izpm3tQwyY2oq3ktXh4at/GKVHszTyQWzjye27BUyD4+zZEA8nFqw7tl+7hbDv lfUZANMxfej12vM7wEmLM8uqXWmjEXhze82ZfIe1fizjS7TzcJleckAvp2OaTpH89BV0 l9Qw== 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=Rj0hwqiot9yKo/V2+tI2H/WfjhvlejzlOrnB8xJDZDI=; b=3G4jpCDLXQk6z4ThstL8nZr3VYSedmmX0nvGoKzuKrRFemRk8kOoB3SGLzKDUKvLKi tu4IRNCiRbEuvu0Ck0QvpY4TIiKn2c440UMMFCS/lrZ+EcgOluUCKWoWkEVwRbNAZCx1 jqZSWOMTtHgg3U0OA8hYKzRYTUSKA5u0PgDCqjKP4/UeOggUKnBDf1h9BmietknsaoXd cnN3jiUClhgOlJCmZYhvkCfL+ieAzrG/rUXaAxd2OFTtcaM6FLrEWCd23U9Ijt+GqRlA JcTJDGImIlC5IE1fAw/Vd1vIW/3+0AU1qBIAbKsD+hpS3mKZSSfN5ifD9gP/y/A/LMzz Z3Wg== X-Gm-Message-State: AOAM5303xVRpir045xS/uygiz3JUxYPqPnUHBD77l2y3zdh1b5ns61Mo Jf10KaSbl1K9ZWMTnMbZb/PqpeMUxjDzog== X-Google-Smtp-Source: ABdhPJwjlkrXeK5E3aTH3D/a/27V5S2o42IIv6uhIf9omDm09fcQx39tl9B9JP4aigssjlxVSm2+Lw== X-Received: by 2002:a02:2208:: with SMTP id o8mr2379496jao.72.1643412522377; Fri, 28 Jan 2022 15:28:42 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 36/40] bsd-user/signal.c: implement do_sigaction Date: Fri, 28 Jan 2022 16:28:01 -0700 Message-Id: <20220128232805.86191-37-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643415233329100001 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 Reviewed-by: Richard Henderson --- bsd-user/signal-common.h | 22 +++++++++++ bsd-user/signal.c | 83 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 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 79e1128d4f6..24074d629e2 100644 --- a/bsd-user/signal.c +++ b/bsd-user/signal.c @@ -309,6 +309,25 @@ 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(). We depend on the FreeBSD behaivor here w= here + * this will only affect this thread's signal mask. We don't use + * pthread_sigmask which might seem more correct because that routine = also + * does odd things with SIGCANCEL to implement pthread_cancel(). + */ + 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 +573,70 @@ 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) { + return -TARGET_EINVAL; + } + + if ((sig =3D=3D TARGET_SIGKILL || sig =3D=3D TARGET_SIGSTOP) && + act !=3D NULL && act->_sa_handler !=3D TARGET_SIG_DFL) { + return -TARGET_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 Sat Feb 7 08:02:23 2026 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 1643414513756979.4676137068948; Fri, 28 Jan 2022 16:01:53 -0800 (PST) Received: from localhost ([::1]:34850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbBg-0001L3-UD for importer@patchew.org; Fri, 28 Jan 2022 19:01:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDag4-0000tM-4I for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:12 -0500 Received: from [2607:f8b0:4864:20::d35] (port=42745 helo=mail-io1-xd35.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nDafi-0001bN-TH for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:08 -0500 Received: by mail-io1-xd35.google.com with SMTP id r144so9659987iod.9 for ; Fri, 28 Jan 2022 15:28:49 -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 o11sm14323111ilm.20.2022.01.28.15.28.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:42 -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=xt+oTYyYNro3WmsG/26k6iJ8qTdnlnX7PCd42MTysmw=; b=rEqnvtbKIIGO1cTGPVckJiE/CADWzErN1Av8V6saP1AqYhXc/t9+DbY2Ny94WIlsnY KubSv6bo+aRZ7kggBeuX4kEv27hvpMkXbjzKuBmP3+z7MrltVRt1dAOYSEsjSQBGmMXs dzakf4HBy0jAOcg+w3f5GQrp/O8CEkCdneC8bGbfREo+FrdPmiXYl872QyTYpF+jqBwO 7H5PykAR0ow4zqblB/p0bHGo3/oHLhPeiJ0M3Wy7cytBnrnqOxeJW5PanH+szAR+ASzs i4MGgXpmbbmQrEJnVzLwlo9UNLAIx5tkD1u+eHY94/v0vFkZAFmIqNPITpkjuaLx7ceQ X0vQ== 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=xt+oTYyYNro3WmsG/26k6iJ8qTdnlnX7PCd42MTysmw=; b=yPJBqT4xuZ1bhZqKT/NIR3NX5+vPng6YAcVUoUUkaOa1ppYdfJxEmhQDV3JNhlzC4G SyVi5VXkrp4hmcwrtAyfqm4KwEMDHw8dJi+TDINbB8F2CXeJPJseT2aXycC2RYQ8IjRc YJl6MrUBxxvzMVwgxUPqyLqgMejzdMQMfTmpiHhKjQors6WhnwXRKF8yXSFdR/Mzq//K ky24UlYUnUKicqWpDFoH3eZQNAQjpYfFavhFwdss4oln8TgYccgdRatL1igM4X2Jzv74 1PsuTKc83YOeOBISJPHIg41QBYxZ/5Pu2QpqG16NBSHVwDr0+MWmyRgrOmrVUPkxa2Gr QGeg== X-Gm-Message-State: AOAM533W6UF5Yt0+VGbNsbV9QQiahnBckRSQYkXfVPvoe7x2edawL6QM uMylFTeVMXgDiSBc6vncVucNkn/9LCZeWg== X-Google-Smtp-Source: ABdhPJwBtPq38TXe8h+hTyqhIVsZNOUggccK2SqPgxIcQkKrZJheUwUdlrvdQPon2gD4XfZUzTP6GQ== X-Received: by 2002:a05:6602:2e88:: with SMTP id m8mr218673iow.79.1643412523288; Fri, 28 Jan 2022 15:28:43 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 37/40] bsd-user/signal.c: do_sigaltstack Date: Fri, 28 Jan 2022 16:28:02 -0700 Message-Id: <20220128232805.86191-38-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d35 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d35; envelope-from=imp@bsdimp.com; helo=mail-io1-xd35.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643414515933100001 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 24074d629e2..65687fbe7dc 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, @@ -573,6 +568,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 Sat Feb 7 08:02:23 2026 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 1643414645522611.6682494099633; Fri, 28 Jan 2022 16:04:05 -0800 (PST) Received: from localhost ([::1]:40498 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbDo-00059f-OL for importer@patchew.org; Fri, 28 Jan 2022 19:04:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDag4-0000tL-3v for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:12 -0500 Received: from [2607:f8b0:4864:20::12c] (port=44992 helo=mail-il1-x12c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nDafi-0001bO-SV for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:08 -0500 Received: by mail-il1-x12c.google.com with SMTP id p7so2671791ilp.11 for ; Fri, 28 Jan 2022 15:28:49 -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 o11sm14323111ilm.20.2022.01.28.15.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pumpyPycN9DoXDBuQYFrkloUl4gD+5Jdk6jBPn6GXxc=; b=W7Uy4/BlWJUPIZED1wTDImcoappz76S2KHAveYqXmM83LE2kRjduJGoRWxRHl/nRWw sxVkFu0IAwlzWaYn6kNgMANR0G7JbVuu1eReXUCV5a/SI36jaDQVwPwGUQe42y0KAIgD 1wfB94s7FZ/AFLnO922SH0fJW0m7kUNob/Lre1AICsDAIVj0W/y6iImmNkkFsMcBeFim XrLjb+ZPegVPfwrnG0U1okC5TSzSnOC5KS0uFpnLT0JiHL6YqBz+dLJsJBbl9ikLP3Is xJNomsKWab+Q8mmeGXxwGllGevaxoqWUsIHz6CMZFrG+cxuY9KGrfVRh2t1Qzgb96C/X +1IQ== 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=pumpyPycN9DoXDBuQYFrkloUl4gD+5Jdk6jBPn6GXxc=; b=e2xJbp2oHpxknarrj42BlPeSSPyNNmY5QSLw6SNsywVl3si87p0PHwaHHHUJLQB2tu AdzpG8iaPmwWWu50bZPGyoFZ6NRGS6m2w5D68nHHXgIp3c6ibw8H95JCeq3mmbPbXaB5 JP5zBinhwDsiGcGGu4gQ3o7qNghuC106sWpGOYmtiFYTTk0KinMYDBi/TFTfiO17tyAq GvAAa7DIfHKAqRG+MzAtwPsIyId5oIzlPTCtuHEM1VF1rXDztn1zoPAi5GQyfY7R0TyQ IfCDmYi+x72pOjsosTQjD+mXP1Z5k0G4FVWjWyegjNxotoHeAT1xNny3PqUzs+78WkQf ULpw== X-Gm-Message-State: AOAM5300I/FJS9hJ6GpSrdTYi0r5Sio/7ySjlbxNJ4Bkm0ymJ9v8yGHq lJEmBkLA0b0JpD6IIWIJnPEpkLfvZCkL4w== X-Google-Smtp-Source: ABdhPJzZhb1o2ScudWMHmcbkFjHHFY7hj42osivFiE9q/OzVjiTUau5+V6TgnRuWR2ePiuNrah3xjQ== X-Received: by 2002:a92:8748:: with SMTP id d8mr7348050ilm.186.1643412524709; Fri, 28 Jan 2022 15:28:44 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 38/40] MAINTAINERS: Add tests/vm/*bsd to the list to get reviews on Date: Fri, 28 Jan 2022 16:28:03 -0700 Message-Id: <20220128232805.86191-39-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12c (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12c; envelope-from=imp@bsdimp.com; helo=mail-il1-x12c.google.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643414648311100003 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 e4b3a4bcdf4..b7487f9b54b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3181,6 +3181,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 Sat Feb 7 08:02:23 2026 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 1643414464181758.6507645724577; Fri, 28 Jan 2022 16:01:04 -0800 (PST) Received: from localhost ([::1]:59956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbAs-0007Ga-UZ for importer@patchew.org; Fri, 28 Jan 2022 19:01:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafy-0000qO-Se for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:08 -0500 Received: from [2607:f8b0:4864:20::d2a] (port=39665 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 1nDafi-0001bQ-Qd for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:05 -0500 Received: by mail-io1-xd2a.google.com with SMTP id c188so9691291iof.6 for ; Fri, 28 Jan 2022 15:28:48 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id o11sm14323111ilm.20.2022.01.28.15.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cJUtiOr7bO9JD4Wqr53h0+Q8HUYGQ4WMAMmhjYNlvEg=; b=e7/hBEWrvW4iU2OGdnmnlVIgq3l0azXfD2Zw81gyn/5KVqJUcdWzHVPlXrCN3z8zMd kWhnFSLMaU8yrNil7yhGbhLSIJc7HEGzw69FKgjmRIgAFC3Jo1juEiAlJt4mh+1lr2qZ NtemYUACsAEq6XJcp9JK0/i+57g/REfFQDsylYY30p3FAt5mlEfOp5TefRlrGPVglhD+ XuxTNjPar17hdGf90uomyZBggRn++ESoNP6dFL39xjd9AMN79IFZgjC8+wGrw8+A7wuU g3gmZOLn6Gj4tGu1lgrt9Ne3pPTpfQO9aP6kTWkRwofAw24gGFJO3GVWincsw4S7CfOf k5rQ== 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=cJUtiOr7bO9JD4Wqr53h0+Q8HUYGQ4WMAMmhjYNlvEg=; b=7RHQCzm8OyXjr70RfPA6QLwVJKIy/oh//BreX9pUOx7b20fL2PlPMA4nJ5yfxxJyhA OoCbM1UbE2RmaCTgaI8CWNAkoge66hLo7z4cs0jauTwnCEBB6+CwleANyffySktR04CR bUzNLFdYmxO7/LOGm0zjoiJW8HU/QN5Bmid/ppBtDUptRD+vq43CQinzvOWoqNfvaQmg mZx6W9pyj4//yl6e3ovlCWjrSopGqzwfnYnNPVu6CmShEPk7jDZr7evQKMIQb67lOBmL vAsZnzCfYvAxbzu7lFlWwVGXbnOF6F6Lwl8EnVwIF/MJg5dxrSwVrMoce/pzdXf7u+OS sjrA== X-Gm-Message-State: AOAM5321j1g8Kt31BP5m0T77XL48Ark6AT8UTyd8YAAFqF9yRIloc+WN GZ6TqI8QUii41DFWIYhCCKeNt9HD+RhIAQ== X-Google-Smtp-Source: ABdhPJzwg1/qf660rH7snJUty94BONM0l4+wget3S8bWcGgcBU51qUOB+NgMHYe8cnl8t5C/nd4wTQ== X-Received: by 2002:a05:6638:358b:: with SMTP id v11mr3452895jal.224.1643412525808; Fri, 28 Jan 2022 15:28:45 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 39/40] bsd-user: Rename arg name for target_cpu_reset to env Date: Fri, 28 Jan 2022 16:28:04 -0700 Message-Id: <20220128232805.86191-40-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643414467573100003 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 2b395d5c97f..b087db48fa4 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 472a96689fc..3cbf69d8af2 100644 --- a/bsd-user/i386/target_arch_cpu.h +++ b/bsd-user/i386/target_arch_cpu.h @@ -200,9 +200,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 14def48adb5..0a9c0f08946 100644 --- a/bsd-user/x86_64/target_arch_cpu.h +++ b/bsd-user/x86_64/target_arch_cpu.h @@ -238,9 +238,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 Sat Feb 7 08:02:23 2026 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 1643415891986836.1095729943812; Fri, 28 Jan 2022 16:24:51 -0800 (PST) Received: from localhost ([::1]:38226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nDbXv-0001WL-5B for importer@patchew.org; Fri, 28 Jan 2022 19:24:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDafy-0000qR-Uv for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:08 -0500 Received: from [2607:f8b0:4864:20::132] (port=35484 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 1nDafi-0001bR-QS for qemu-devel@nongnu.org; Fri, 28 Jan 2022 18:29:06 -0500 Received: by mail-il1-x132.google.com with SMTP id w5so6781416ilo.2 for ; Fri, 28 Jan 2022 15:28:48 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id o11sm14323111ilm.20.2022.01.28.15.28.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:28:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0gTkuAZAhwvC63lNdvy3u7JBBQLnkso7fXqMJsrKqkM=; b=oc8z9NQFJ8i7T/+yQZQy+h90rFSA4b8X3Wdlp1kqjTXORlNrXU5t8ucndWSVZeKoQ0 unj2W3aAm6HUjmrWSOnln1q2rtwkfxGqxwWNeNIoqUf3sMtDPUirfNsa7Fn0u01v7RAE ZXSogQLIlIOV9uY2i1M7KNqjNEGqBuOno7jyv9a3PnbGvdD94SFo2v54BnhAHeZxu15P VpZHyHwOZxevIgQq6t8U6zx6FsuE4DxWnxBfmLKNVhsiPst5Tf/DjR10YlICyZCXBP+r boqbO3qkL8l+QesUblS6/uWv8nxoch/+em6vpBTMFrK9Kped3qv7S5hljEEC7p7z69/W X8gA== 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=0gTkuAZAhwvC63lNdvy3u7JBBQLnkso7fXqMJsrKqkM=; b=sTE7/bUyFvaCPIuzadJSGRAuLBWzsF6cX4fWZa7JoDc5argqZSobWrBPmhhONJEPOV dA6VDWMCU7ZSq5gGBOXqPzfZl/fUluZYF6go/mdz8zNgyyzNpbWXWdynV2Eyg/jn/qLY FQ32RjZdNJ0qm1Hjx+hd5yh+FyHQg6P0UuVZbU/aeEZjzpdeuxJ8MrstNIOFTSUdSvtt 63kSxm2lE9KMMmwdn5r3t4btithFOukV/urbxDQKyHG58I3v1lItnHy6D2FU6yJDDG33 0rELNrBponTWhRhxlyvJkwCqTJHRsuVg7VfTKTeJ+PFSKQC1fNbMSehfmsuy3RG+x1XZ 9Shg== X-Gm-Message-State: AOAM533nFnIYEw1f3mhcX0YbnASs1qfkj/qqxAe8buu4IRTemBbWikdj cexNaG2t71U1kcLOSrHx1Ds3SItFeW6s5w== X-Google-Smtp-Source: ABdhPJxyTYuDPDzdu+PwA+9HGRWAP7fgjgpdywdhbPbs2w70EySU1Gq9mnDm+ui2eZQLaAvGASVGvg== X-Received: by 2002:a05:6e02:1488:: with SMTP id n8mr6918330ilk.12.1643412526917; Fri, 28 Jan 2022 15:28:46 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PATCH v3 40/40] bsd-user/freebsd/target_os_ucontext.h: Prefer env as arg name for CPUArchState args Date: Fri, 28 Jan 2022 16:28:05 -0700 Message-Id: <20220128232805.86191-41-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220128232805.86191-1-imp@bsdimp.com> References: <20220128232805.86191-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: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) 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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1643415895220100001 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