From nobody Mon Dec 15 23:27:07 2025 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 164366309053849.29400828700125; Mon, 31 Jan 2022 13:04:50 -0800 (PST) Received: from localhost ([::1]:54530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEdqz-0006Qy-NN for importer@patchew.org; Mon, 31 Jan 2022 16:04:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEcnl-00054A-3i for qemu-devel@nongnu.org; Mon, 31 Jan 2022 14:57:25 -0500 Received: from [2607:f8b0:4864:20::d32] (port=35660 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 1nEcnb-0002ey-PJ for qemu-devel@nongnu.org; Mon, 31 Jan 2022 14:57:24 -0500 Received: by mail-io1-xd32.google.com with SMTP id 9so18465605iou.2 for ; Mon, 31 Jan 2022 11:56:55 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id j2sm1972989ilu.82.2022.01.31.11.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 11:56:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2cxVzUGQfUKapU6iJyRCNz3mEY37Sx777/SzAWGZs48=; b=MntQDAUF+/auInE6Lqv2Hrz1wQucNLiwZVcLEFAdbVoUdla4N9cJroz027SYU0jmai bym8Q+CefIMnXb6HdNsbNppSZdQhUS0hZBSfsLFBu0vhmEM+3PfjBMAhfZYUY208pYsi KUMDIwxFqj2TIVF6t1oUUjZ2fM/+KinhnK2NsRKQ5P+Zxi8tM39MDPjLDgnco0ziCvkb liqdoIOrOROl0y2I9GuUWek/1Vy49Zjdj3b1oM5XEXfTUFVZdDH1BWKo/v0vh3DIv0vB ixQsCiaTvsndxqS7UixeOL14GAgGNZY5SBh86CAhYSVKzTIzzqlamwoRkcrWNh3vaIMp jHdA== 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=2uAVJDSEt83R2Tu2lX2LXgGbo9sNtwQtVuOo70QCQejoimX+SkTX02fPQqIKPqMbVA IHLuLSElX0LEcDRcsK46oB1kJRkwZJ6zvo6H697zPgMt4Jp4dtusB1+3q9x9KHV9y8yD bHgbkgUUabJhxHJF6nBvAg2sXtDa8kMHRqY+mBS27SjVZYryZq7jWmtKWS7f+EO9K3Pe GFiXnuWtvUsDKyMeeopcrEgm7gTGDfffnSekviCQhFvSX/88Yt963LBB/w5+qaL918nV 5z/ZiKKxgRRMjNxZ13kisqAfHHrSWLzNhK1cOn8/ASw5uw9gHH1ucOb3oHqmIxsunn6S N/iw== X-Gm-Message-State: AOAM532j99k8d+v8v9ZsjiJm7p5bR9uoTwsMefa4UvRBx1Osh9VDTqso NGUOIver5JTlma5l+UjHJXDBdIKwiBbp9w== X-Google-Smtp-Source: ABdhPJz7tdoYrAfNvMqFqbOiBYos4+yoliNsdImVX0FNS95u4CRV+HlFE2x19bMXkZOmB53MLfDfEA== X-Received: by 2002:a6b:4417:: with SMTP id r23mr11906817ioa.23.1643659014974; Mon, 31 Jan 2022 11:56:54 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 25/40] bsd-user/signal.c: Implement rewind_if_in_safe_syscall Date: Mon, 31 Jan 2022 12:56:21 -0700 Message-Id: <20220131195636.31991-26-imp@bsdimp.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220131195636.31991-1-imp@bsdimp.com> References: <20220131195636.31991-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d32 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d32; envelope-from=imp@bsdimp.com; helo=mail-io1-xd32.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001, 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: 1643663093104100001 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