From nobody Sun May 19 06:04:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163677972187939.73145718494516; Fri, 12 Nov 2021 21:02:01 -0800 (PST) Received: from localhost ([::1]:46328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mllAu-0006bk-Ue for importer@patchew.org; Sat, 13 Nov 2021 00:02:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mll5z-00075d-7O for qemu-devel@nongnu.org; Fri, 12 Nov 2021 23:56:55 -0500 Received: from [2607:f8b0:4864:20::d34] (port=37857 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 1mll5v-0003M9-T3 for qemu-devel@nongnu.org; Fri, 12 Nov 2021 23:56:54 -0500 Received: by mail-io1-xd34.google.com with SMTP id k21so13845792ioh.4 for ; Fri, 12 Nov 2021 20:56:51 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id r14sm5414455iov.14.2021.11.12.20.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 20:56:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8S4suhXJjmAAl79YQ+hrQqaT6PvDtJNGpGFTtHdTrfM=; b=mMdEyPNIC9UjoKWbKLJOddGy+fasHBMM3XvOjx3DegIbxZ+O/fLUNdQq4r2BDZvZfz aZyql13EMuwwmxW4XrRCtYiP9H62X4hVCCHqrDJVBL/W36wZl9P4fAT0Whv8fWdWzhjJ tCeTL4BrYSLk4UZ+oyejlXLQbSPyADrefKyACclKWy8wk3qpZc4oHPCaQ5M3gXLiWSaw EK7oD0S3vcHRSfEtRaYKjBaje6ZmKomQn7pBuNq7JV9HJjufh27y5hx+JZjRTBnA3f1i rxFQzgUMBQtqgSh+B0sizTLtjFp+y0/is4UfSoRv4vS3LGTVjs5C+3syu3GIWPcONcpg +0Dg== 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=8S4suhXJjmAAl79YQ+hrQqaT6PvDtJNGpGFTtHdTrfM=; b=VLhqKFONvLYIy92QwQuVdIJ8T9OcMmIodMpJv4vGVyZcTvVCKjMAFVdYfperpL4qei XRS2C1QTegJRrPtwD/XC1NBbE6tEU9XxBceyQj7Elhtc1XrK5hLDgZ04+8zai+cYGH5u kcEuST6Pqs32KqTOKx/RQmB/JudieKeTPoUPMcH6hmpCALkMSfwanjlbJn1gW+HztZS8 pFsaGxCugYwzmKtQq+lZXki0NsWeGOJPhRvEWrt3RhJDjPxzPXHovK1yYGUzbZ2427Fu pg29wqJmRF5q1KlKeAp32cuUgzvpWBnQFNzLfedvyJh3JfsoMns+vQqd5AtwvaSEfXNw ue5Q== X-Gm-Message-State: AOAM53211JPDuFaDKlSjeb+eyn5FbUw5Tz/ebrANsbNsF+IOyur4UMdK WJ/dmnMhWv49E5Xqgz0IO/CRyaNjbfMARQ== X-Google-Smtp-Source: ABdhPJwXQgHe+iZ4KAuri0BmoecC9vLQcQALUXkUGlBdLY7idOz0aioQ3cIdGgYMEXcU/e+MbaCB/Q== X-Received: by 2002:a02:caac:: with SMTP id e12mr16035487jap.29.1636779409492; Fri, 12 Nov 2021 20:56:49 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [RFC v3 1/5] linux-user: Add host_signal_set_pc to set pc in mcontext Date: Fri, 12 Nov 2021 21:55:59 -0700 Message-Id: <20211113045603.60391-2-imp@bsdimp.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211113045603.60391-1-imp@bsdimp.com> References: <20211113045603.60391-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d34 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d34; envelope-from=imp@bsdimp.com; helo=mail-io1-xd34.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Philippe Mathieu-Daude , Laurent Vivier , Konrad Witaszczyk , 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: 1636779722280100001 Add a new function host_signal_set_pc to set the next pc in an mcontext. The caller should ensure this is a valid PC for execution. Signed-off-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- linux-user/host/aarch64/host-signal.h | 5 +++++ linux-user/host/alpha/host-signal.h | 5 +++++ linux-user/host/arm/host-signal.h | 5 +++++ linux-user/host/i386/host-signal.h | 5 +++++ linux-user/host/mips/host-signal.h | 5 +++++ linux-user/host/ppc/host-signal.h | 5 +++++ linux-user/host/riscv/host-signal.h | 5 +++++ linux-user/host/s390/host-signal.h | 5 +++++ linux-user/host/sparc/host-signal.h | 9 +++++++++ linux-user/host/x86_64/host-signal.h | 5 +++++ 10 files changed, 54 insertions(+) diff --git a/linux-user/host/aarch64/host-signal.h b/linux-user/host/aarch6= 4/host-signal.h index 0c0b08383a..9770b36dc1 100644 --- a/linux-user/host/aarch64/host-signal.h +++ b/linux-user/host/aarch64/host-signal.h @@ -35,6 +35,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.pc; } =20 +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.pc =3D pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { struct _aarch64_ctx *hdr; diff --git a/linux-user/host/alpha/host-signal.h b/linux-user/host/alpha/ho= st-signal.h index e080be412f..f4c942948a 100644 --- a/linux-user/host/alpha/host-signal.h +++ b/linux-user/host/alpha/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.sc_pc; } =20 +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.sc_pc =3D pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { uint32_t *pc =3D (uint32_t *)host_signal_pc(uc); diff --git a/linux-user/host/arm/host-signal.h b/linux-user/host/arm/host-s= ignal.h index efb165c0c5..6c095773c0 100644 --- a/linux-user/host/arm/host-signal.h +++ b/linux-user/host/arm/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.arm_pc; } =20 +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.arm_pc =3D pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { /* diff --git a/linux-user/host/i386/host-signal.h b/linux-user/host/i386/host= -signal.h index 4c8eef99ce..abe1ece5c9 100644 --- a/linux-user/host/i386/host-signal.h +++ b/linux-user/host/i386/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.gregs[REG_EIP]; } =20 +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.gregs[REG_EIP] =3D pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { return uc->uc_mcontext.gregs[REG_TRAPNO] =3D=3D 0xe diff --git a/linux-user/host/mips/host-signal.h b/linux-user/host/mips/host= -signal.h index ef341f7c20..c666ed8c3f 100644 --- a/linux-user/host/mips/host-signal.h +++ b/linux-user/host/mips/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.pc; } =20 +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.pc =3D pc; +} + #if defined(__misp16) || defined(__mips_micromips) #error "Unsupported encoding" #endif diff --git a/linux-user/host/ppc/host-signal.h b/linux-user/host/ppc/host-s= ignal.h index a491c413dc..1d8e658ff7 100644 --- a/linux-user/host/ppc/host-signal.h +++ b/linux-user/host/ppc/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.regs->nip; } =20 +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.regs->nip =3D pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { return uc->uc_mcontext.regs->trap !=3D 0x400 diff --git a/linux-user/host/riscv/host-signal.h b/linux-user/host/riscv/ho= st-signal.h index 3b168cb58b..a4f170efb0 100644 --- a/linux-user/host/riscv/host-signal.h +++ b/linux-user/host/riscv/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.__gregs[REG_PC]; } =20 +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) { /* diff --git a/linux-user/host/s390/host-signal.h b/linux-user/host/s390/host= -signal.h index 26990e4893..a524f2ab00 100644 --- a/linux-user/host/s390/host-signal.h +++ b/linux-user/host/s390/host-signal.h @@ -16,6 +16,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.psw.addr; } =20 +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.psw.addr =3D pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { uint16_t *pinsn =3D (uint16_t *)host_signal_pc(uc); diff --git a/linux-user/host/sparc/host-signal.h b/linux-user/host/sparc/ho= st-signal.h index 5e71d33f8e..7342936071 100644 --- a/linux-user/host/sparc/host-signal.h +++ b/linux-user/host/sparc/host-signal.h @@ -20,6 +20,15 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) #endif } =20 +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ +#ifdef __arch64__ + uc->uc_mcontext.mc_gregs[MC_PC] =3D pc; +#else + uc->uc_mcontext.gregs[REG_PC] =3D pc; +#endif +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { uint32_t insn =3D *(uint32_t *)host_signal_pc(uc); diff --git a/linux-user/host/x86_64/host-signal.h b/linux-user/host/x86_64/= host-signal.h index 883d2fcf65..c71d597eb2 100644 --- a/linux-user/host/x86_64/host-signal.h +++ b/linux-user/host/x86_64/host-signal.h @@ -15,6 +15,11 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc) return uc->uc_mcontext.gregs[REG_RIP]; } =20 +static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) +{ + uc->uc_mcontext.gregs[REG_RIP] =3D pc; +} + static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) { return uc->uc_mcontext.gregs[REG_TRAPNO] =3D=3D 0xe --=20 2.33.0 From nobody Sun May 19 06:04:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636779607063970.7501631748765; Fri, 12 Nov 2021 21:00:07 -0800 (PST) Received: from localhost ([::1]:43870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mll94-0004qo-0m for importer@patchew.org; Sat, 13 Nov 2021 00:00:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mll5x-00074Q-NC for qemu-devel@nongnu.org; Fri, 12 Nov 2021 23:56:53 -0500 Received: from [2607:f8b0:4864:20::d33] (port=39677 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 1mll5v-0003M8-R8 for qemu-devel@nongnu.org; Fri, 12 Nov 2021 23:56:53 -0500 Received: by mail-io1-xd33.google.com with SMTP id c3so13847612iob.6 for ; Fri, 12 Nov 2021 20:56:51 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id r14sm5414455iov.14.2021.11.12.20.56.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 20:56:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bH8XlQNlVgldgvvPm+sZMzPHlugap+34WnaEJEfYxSY=; b=LNRHWtHvU2nuJdT/04F+aEjQprm5hv1j9RA3i8FRmGOm/gTMEbUnyaQeMqeH9xZT3R VZ7TRpP2hmieiM/xWNuYWdxRaJDOB0UrawWZgJvuX7aJrKfWJ2XOsmfBDxQoP9StogWe y/y2KKl+sUgl3yykTmOVCWOPtxEUQD6W/bWclGT99zn5gDpQgWmsPcXGAZuZSnOVIgnr JLdVcSjZqoCutFCBRlLL4mSpMb+Jty9ZtdIUJdBKT+1GeovpwWd6Z+54XoxuYYkxqFZk KUMRA33g0WH/UZY8eTD2OI61FJUllq23LoGVPDV59mh7N4LpDSkBUrGeT44/hqxtBkpr I0ew== 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=bH8XlQNlVgldgvvPm+sZMzPHlugap+34WnaEJEfYxSY=; b=2TjMeKIQt9aJ6o0YOQ+PeOcadGs+ph6pTcnxOF4FUM5yUCa+CVAK6jjZvixJCweH8t mLrZZW2hd5tNC1KnctKvXJjGYRKFoaD1M1+KHERRUKTFyVC8p/Rvgv+cF11qsMLcwkNR WqZnCtRVRPvGmxdCxYsHlmtlWoov5zMyZCn48xlz8UgvClGUBtRh9dAsny0bDHnzrYub kn3/MyQ/skQrAcjAjh4G4QB6fBBYsWe+vsoKI4Q2SjU12fHiqLa6Y5UqF5z1rb5jxNSR sSaw8sCn5myY3EdA3wV+XCks+gdoLC7YkuC0mAkl7ZJ/Qlu1xPRodXULXgRGgNiwEuQ4 Y9Tw== X-Gm-Message-State: AOAM531o3UL0GB27/UyLc5XalLr2TVoZ4L9Tpd+bHFgDfF6M8my/Kg7r 4C1JQGMhKqN0cfhdVo5HCY7RU8kxIE5ncA== X-Google-Smtp-Source: ABdhPJysNrnxzM0ArcY6CwA6ZL8MTa9t/4e+ML+JiiRe+W25YWax6D/cNtJO9+3wb7uUcEZis3ogvg== X-Received: by 2002:a05:6602:2e90:: with SMTP id m16mr14069223iow.92.1636779410446; Fri, 12 Nov 2021 20:56:50 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [RFC v3 2/5] linux-user/signal.c: Create a common rewind_if_in_safe_syscall Date: Fri, 12 Nov 2021 21:56:00 -0700 Message-Id: <20211113045603.60391-3-imp@bsdimp.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211113045603.60391-1-imp@bsdimp.com> References: <20211113045603.60391-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d33 (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d33; envelope-from=imp@bsdimp.com; helo=mail-io1-xd33.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Philippe Mathieu-Daude , Laurent Vivier , Konrad Witaszczyk , 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: 1636779607949100001 All instances of rewind_if_in_safe_syscall are the same, differing only in how the instruction point is fetched from the ucontext and the size of the registers. Use host_signal_pc and new host_signal_set_pc interfaces to fetch the pointer to the PC and adjust if needed. Delete all the old copies of rewind_if_in_safe_syscall. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/host/aarch64/hostdep.h | 20 -------------------- linux-user/host/arm/hostdep.h | 20 -------------------- linux-user/host/i386/hostdep.h | 20 -------------------- linux-user/host/ppc64/hostdep.h | 20 -------------------- linux-user/host/riscv/hostdep.h | 20 -------------------- linux-user/host/s390x/hostdep.h | 20 -------------------- linux-user/host/x86_64/hostdep.h | 20 -------------------- linux-user/safe-syscall.h | 3 +++ linux-user/signal.c | 14 +++++++++++++- 9 files changed, 16 insertions(+), 141 deletions(-) diff --git a/linux-user/host/aarch64/hostdep.h b/linux-user/host/aarch64/ho= stdep.h index a8d41a21ad..39299d798a 100644 --- a/linux-user/host/aarch64/hostdep.h +++ b/linux-user/host/aarch64/hostdep.h @@ -15,24 +15,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL =20 -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* 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 puc; - __u64 *pcreg =3D &uc->uc_mcontext.pc; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg =3D (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/host/arm/hostdep.h b/linux-user/host/arm/hostdep.h index 9276fe6ceb..86b137875a 100644 --- a/linux-user/host/arm/hostdep.h +++ b/linux-user/host/arm/hostdep.h @@ -15,24 +15,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL =20 -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* 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 puc; - unsigned long *pcreg =3D &uc->uc_mcontext.arm_pc; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg =3D (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/host/i386/hostdep.h b/linux-user/host/i386/hostdep.h index 073be74d87..ce7136501f 100644 --- a/linux-user/host/i386/hostdep.h +++ b/linux-user/host/i386/hostdep.h @@ -15,24 +15,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL =20 -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* 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 puc; - greg_t *pcreg =3D &uc->uc_mcontext.gregs[REG_EIP]; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg =3D (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/host/ppc64/hostdep.h b/linux-user/host/ppc64/hostde= p.h index 98979ad917..0c290dd904 100644 --- a/linux-user/host/ppc64/hostdep.h +++ b/linux-user/host/ppc64/hostdep.h @@ -15,24 +15,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL =20 -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* 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 puc; - unsigned long *pcreg =3D &uc->uc_mcontext.gp_regs[PT_NIP]; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg =3D (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/host/riscv/hostdep.h b/linux-user/host/riscv/hostde= p.h index 2ba07456ae..7f67c22868 100644 --- a/linux-user/host/riscv/hostdep.h +++ b/linux-user/host/riscv/hostdep.h @@ -11,24 +11,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL =20 -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* 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 puc; - unsigned long *pcreg =3D &uc->uc_mcontext.__gregs[REG_PC]; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg =3D (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/host/s390x/hostdep.h b/linux-user/host/s390x/hostde= p.h index 4f0171f36f..d801145854 100644 --- a/linux-user/host/s390x/hostdep.h +++ b/linux-user/host/s390x/hostdep.h @@ -15,24 +15,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL =20 -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* 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 puc; - unsigned long *pcreg =3D &uc->uc_mcontext.psw.addr; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg =3D (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/host/x86_64/hostdep.h b/linux-user/host/x86_64/host= dep.h index a4fefb5114..9c62bd26bd 100644 --- a/linux-user/host/x86_64/hostdep.h +++ b/linux-user/host/x86_64/hostdep.h @@ -15,24 +15,4 @@ /* We have a safe-syscall.inc.S */ #define HAVE_SAFE_SYSCALL =20 -#ifndef __ASSEMBLER__ - -/* These are defined by the safe-syscall.inc.S file */ -extern char safe_syscall_start[]; -extern char safe_syscall_end[]; - -/* 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 puc; - greg_t *pcreg =3D &uc->uc_mcontext.gregs[REG_RIP]; - - if (*pcreg > (uintptr_t)safe_syscall_start - && *pcreg < (uintptr_t)safe_syscall_end) { - *pcreg =3D (uintptr_t)safe_syscall_start; - } -} - -#endif /* __ASSEMBLER__ */ - #endif diff --git a/linux-user/safe-syscall.h b/linux-user/safe-syscall.h index 6bc0390262..aaa9ffc0e2 100644 --- a/linux-user/safe-syscall.h +++ b/linux-user/safe-syscall.h @@ -127,6 +127,9 @@ #ifdef HAVE_SAFE_SYSCALL /* The core part of this function is implemented in assembly */ extern long safe_syscall_base(int *pending, long number, ...); +/* These are defined by the safe-syscall.inc.S file */ +extern char safe_syscall_start[]; +extern char safe_syscall_end[]; =20 #define safe_syscall(...) \ ({ \ diff --git a/linux-user/signal.c b/linux-user/signal.c index 81c45bfce9..ee038c2399 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -793,7 +793,19 @@ int queue_signal(CPUArchState *env, int sig, int si_ty= pe, return 1; /* indicates that the signal was queued */ } =20 -#ifndef HAVE_SAFE_SYSCALL +#ifdef HAVE_SAFE_SYSCALL +/* 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); + } +} +#else static inline void rewind_if_in_safe_syscall(void *puc) { /* Default version: never rewind */ --=20 2.33.0 From nobody Sun May 19 06:04:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636779508129631.2853752851682; Fri, 12 Nov 2021 20:58:28 -0800 (PST) Received: from localhost ([::1]:37788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mll7S-0000ge-Gh for importer@patchew.org; Fri, 12 Nov 2021 23:58:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mll5z-00075P-1r for qemu-devel@nongnu.org; Fri, 12 Nov 2021 23:56:55 -0500 Received: from [2607:f8b0:4864:20::12d] (port=46748 helo=mail-il1-x12d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mll5w-0003MI-Mu for qemu-devel@nongnu.org; Fri, 12 Nov 2021 23:56:54 -0500 Received: by mail-il1-x12d.google.com with SMTP id i11so10935874ilv.13 for ; Fri, 12 Nov 2021 20:56:52 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id r14sm5414455iov.14.2021.11.12.20.56.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 20:56:50 -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=1RfAt+Gj4t0D2XZYXWOpd5I5gxE3FaCADzEKGgm/8V0=; b=CMsX56wYPh2FbALXg2ax8x+gMQA+TFxhW6C1PgIL2kF/1qkRqQAkZC2V/BiaLyq6TD Z3nTZk+uujQUzd1YR6m7JIxRdEMRh870oNXozOlvulv7ZJgKqRdMttoglTBe5eKuFEPn jVCEwayIoYAAxMholF8mZ2tERl8qV7QTXZYeHJNTjwXTgHdFfnbzKta35Oa/zm3cshGO 9JqJSUmrWO2iCSZfJnymfnJvOmh+FUNAuUqJ7hnd0HZifFz02J5vl7aLrCUiUqrzkBcC iDREQNG/2IsqkzzOjx5kpKJlG/mk4uL7vdBicHQUfDKYCvG4TSoNlFaq6R1y866RXFiX m0Jw== 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=1RfAt+Gj4t0D2XZYXWOpd5I5gxE3FaCADzEKGgm/8V0=; b=n+VFauWLYOiprU7sdfYTDM+XDHz0oV2VYYDAvtrexzzVh/4JsmCMxvskNlIELYpMdj cU8t08hVh1g6l5H/auY8thR0q3QihNQuVlbhqVjo/ad+3E/pey7c99/L6dAux4CH4f/E ukmklq68/y4UjOnnCp62zBnZE8GruVsdIhveIUPx15I2M5LC2XqXQnInWxkQ0J8aNaiC puCcNlKlrOjNRotDx62wEaRocSaHBc1yZWTu+UJaBc9NB0le0k7o7Ak9AActS4vHcoig z05r2oAezCvvHsW7YXLtJ0HiD/06UkUguDNU23XKSuOxTVh0+B2CsZL6xxt0AV68BepA bR1A== X-Gm-Message-State: AOAM531e+s+n9oe1x4y3JcJC8tF9TwpV03bivS9Uw4gnuKwl0b8OhS1K Ij3oupxn4JO6uVDv3qoKqDfihlryhdVVFA== X-Google-Smtp-Source: ABdhPJyPSbKsX67YHdeU6VnQ0zBg70+vNbFNJvRqQvCWqVYFKCOmDyqnCpbPktPDMDyUQeiU1V38RA== X-Received: by 2002:a05:6e02:b4f:: with SMTP id f15mr3429926ilu.38.1636779411345; Fri, 12 Nov 2021 20:56:51 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [RFC v3 3/5] linux-user/safe-syscall.inc.S: Move to common-user Date: Fri, 12 Nov 2021 21:56:01 -0700 Message-Id: <20211113045603.60391-4-imp@bsdimp.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211113045603.60391-1-imp@bsdimp.com> References: <20211113045603.60391-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12d; envelope-from=imp@bsdimp.com; helo=mail-il1-x12d.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Philippe Mathieu-Daude , Laurent Vivier , Konrad Witaszczyk , 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: 1636779510575100001 Content-Type: text/plain; charset="utf-8" Move all the safe_syscall.inc.S files to common-user. They are almost identical between linux-user and bsd-user to re-use. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- {linux-user =3D> common-user}/host/aarch64/safe-syscall.inc.S | 0 {linux-user =3D> common-user}/host/arm/safe-syscall.inc.S | 0 {linux-user =3D> common-user}/host/i386/safe-syscall.inc.S | 0 {linux-user =3D> common-user}/host/ppc64/safe-syscall.inc.S | 0 {linux-user =3D> common-user}/host/riscv/safe-syscall.inc.S | 0 {linux-user =3D> common-user}/host/s390x/safe-syscall.inc.S | 0 {linux-user =3D> common-user}/host/x86_64/safe-syscall.inc.S | 0 meson.build | 1 + 8 files changed, 1 insertion(+) rename {linux-user =3D> common-user}/host/aarch64/safe-syscall.inc.S (100%) rename {linux-user =3D> common-user}/host/arm/safe-syscall.inc.S (100%) rename {linux-user =3D> common-user}/host/i386/safe-syscall.inc.S (100%) rename {linux-user =3D> common-user}/host/ppc64/safe-syscall.inc.S (100%) rename {linux-user =3D> common-user}/host/riscv/safe-syscall.inc.S (100%) rename {linux-user =3D> common-user}/host/s390x/safe-syscall.inc.S (100%) rename {linux-user =3D> common-user}/host/x86_64/safe-syscall.inc.S (100%) diff --git a/linux-user/host/aarch64/safe-syscall.inc.S b/common-user/host/= aarch64/safe-syscall.inc.S similarity index 100% rename from linux-user/host/aarch64/safe-syscall.inc.S rename to common-user/host/aarch64/safe-syscall.inc.S diff --git a/linux-user/host/arm/safe-syscall.inc.S b/common-user/host/arm/= safe-syscall.inc.S similarity index 100% rename from linux-user/host/arm/safe-syscall.inc.S rename to common-user/host/arm/safe-syscall.inc.S diff --git a/linux-user/host/i386/safe-syscall.inc.S b/common-user/host/i38= 6/safe-syscall.inc.S similarity index 100% rename from linux-user/host/i386/safe-syscall.inc.S rename to common-user/host/i386/safe-syscall.inc.S diff --git a/linux-user/host/ppc64/safe-syscall.inc.S b/common-user/host/pp= c64/safe-syscall.inc.S similarity index 100% rename from linux-user/host/ppc64/safe-syscall.inc.S rename to common-user/host/ppc64/safe-syscall.inc.S diff --git a/linux-user/host/riscv/safe-syscall.inc.S b/common-user/host/ri= scv/safe-syscall.inc.S similarity index 100% rename from linux-user/host/riscv/safe-syscall.inc.S rename to common-user/host/riscv/safe-syscall.inc.S diff --git a/linux-user/host/s390x/safe-syscall.inc.S b/common-user/host/s3= 90x/safe-syscall.inc.S similarity index 100% rename from linux-user/host/s390x/safe-syscall.inc.S rename to common-user/host/s390x/safe-syscall.inc.S diff --git a/linux-user/host/x86_64/safe-syscall.inc.S b/common-user/host/x= 86_64/safe-syscall.inc.S similarity index 100% rename from linux-user/host/x86_64/safe-syscall.inc.S rename to common-user/host/x86_64/safe-syscall.inc.S diff --git a/meson.build b/meson.build index 9702fdce6d..728d305403 100644 --- a/meson.build +++ b/meson.build @@ -2872,6 +2872,7 @@ foreach target : target_dirs if 'CONFIG_LINUX_USER' in config_target base_dir =3D 'linux-user' target_inc +=3D include_directories('linux-user/host/' / config_host= ['ARCH']) + target_inc +=3D include_directories('common-user/host/' / config_hos= t['ARCH']) endif if 'CONFIG_BSD_USER' in config_target base_dir =3D 'bsd-user' --=20 2.33.0 From nobody Sun May 19 06:04:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636779509091548.9369488936288; Fri, 12 Nov 2021 20:58:29 -0800 (PST) Received: from localhost ([::1]:37888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mll7U-0000l0-3I for importer@patchew.org; Fri, 12 Nov 2021 23:58:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mll5z-00075Y-4g for qemu-devel@nongnu.org; Fri, 12 Nov 2021 23:56:55 -0500 Received: from [2607:f8b0:4864:20::12d] (port=38872 helo=mail-il1-x12d.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mll5x-0003MM-FI for qemu-devel@nongnu.org; Fri, 12 Nov 2021 23:56:54 -0500 Received: by mail-il1-x12d.google.com with SMTP id m11so11007339ilh.5 for ; Fri, 12 Nov 2021 20:56:53 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id r14sm5414455iov.14.2021.11.12.20.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 20:56:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/cI7/lZ29fPR8PehHUnyTqOz707sUTy3NDk8wdWBImQ=; b=wNsPTT8KprmBo+K671mMfXxdGVVbUpGXQDBDRatJMCX3MLsNTK0WvMhTNVxEvy8cej RyMs3OiE8PmExD6umrZaBdP4DoVnijqD1eU4CkZpVfXEQ+4ne2u7ulMI/APppMBWFo+A qH6vlPyq0ERzOkQMtwZbveht1bY+Z2oN0M30qNRSkk/aWdYEEMkn8LfsiKGP4pIpn6fA 5AM2o8dLb6ak9uaBnTEvXJEUd+rF/8+qvvI5++dlIMQMh4C14wF4jg4XACCqT1DODBl5 RpDySDvBwe7pqkOtxIhSJuxF12S/7EUvE1jWkTCSEqwsxlUnRnpdzUcEgN/vkMWEe5nd JO3w== 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=/cI7/lZ29fPR8PehHUnyTqOz707sUTy3NDk8wdWBImQ=; b=0oBhAPoTCM18rUYXNiIR/guoG+3uPnuL70aR5py5hWjj2SHKn71JNgh5kHocpRmVCp UCnXgb2h8y7QSRqhQIADqdz0C0T3qoP5d/Hipiu6aexSR0zTIW20wtKU7Ilik0uupPRv 4eCeSNxjOg7f4OC1agvhcofeYiD0DPOoRL06a071ky7Jb7N5wraKU+HrvWCZbTfimDSP BQ38bTpXPL3ZSSWhca//M0kc4AKn+84DUw+OvhmJBNLxMTmIrbSVXJqhU/XmSKUQQKGW cQLAMs3bDaGSy1g7NBoJq+8tCWJ1dohelvvcIepj0XUiWCc8ipGcWRjEtTeaH0kon4zG edFA== X-Gm-Message-State: AOAM533IewQvC8L/L+gQZKw5bvhRpN6qOKoe8Mle1BFKkxuXHLjEisfk Tccl+pv+Kt6cI1TuY2FpvyBUlOpqJStCSQ== X-Google-Smtp-Source: ABdhPJwwUkbnhVXXSkrNm1ndNv+N7RIj22056XGlV6NksiW9pGA7sfyWCdtE5bHVWofno3vF42mUSg== X-Received: by 2002:a05:6e02:144e:: with SMTP id p14mr12271986ilo.180.1636779412254; Fri, 12 Nov 2021 20:56:52 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [RFC v3 4/5] common-user: Adjust system call return on FreeBSD Date: Fri, 12 Nov 2021 21:56:02 -0700 Message-Id: <20211113045603.60391-5-imp@bsdimp.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211113045603.60391-1-imp@bsdimp.com> References: <20211113045603.60391-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::12d (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12d; envelope-from=imp@bsdimp.com; helo=mail-il1-x12d.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Philippe Mathieu-Daude , Laurent Vivier , Konrad Witaszczyk , 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: 1636780412365100001 Content-Type: text/plain; charset="utf-8" All the *-users generally use the negative errno return codes to signal errno for a system call. FreeBSD's system calls, on the other hand, returns errno, not -errno. Add ifdefs for FreeBSD to make the adjustment on the 4 hosts that we have support for. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- common-user/host/aarch64/safe-syscall.inc.S | 8 ++++++++ common-user/host/arm/safe-syscall.inc.S | 7 +++++++ common-user/host/i386/safe-syscall.inc.S | 9 +++++++++ common-user/host/x86_64/safe-syscall.inc.S | 9 +++++++++ 4 files changed, 33 insertions(+) diff --git a/common-user/host/aarch64/safe-syscall.inc.S b/common-user/host= /aarch64/safe-syscall.inc.S index bc1f5a9792..9f9525fe25 100644 --- a/common-user/host/aarch64/safe-syscall.inc.S +++ b/common-user/host/aarch64/safe-syscall.inc.S @@ -64,6 +64,14 @@ safe_syscall_start: svc 0x0 safe_syscall_end: /* code path for having successfully executed the syscall */ +#ifdef __FreeBSD__ + /* + * FreeBSD kernel returns C bit set with positive errno. + * Encode this for use in bsd-user as -errno: + * x0 =3D !c ? x0 : -x0 + */ + csneg x0, x0, x0, cc +#endif ret =20 0: diff --git a/common-user/host/arm/safe-syscall.inc.S b/common-user/host/arm= /safe-syscall.inc.S index 88c4958504..459e5f87c2 100644 --- a/common-user/host/arm/safe-syscall.inc.S +++ b/common-user/host/arm/safe-syscall.inc.S @@ -78,6 +78,13 @@ safe_syscall_start: swi 0 safe_syscall_end: /* code path for having successfully executed the syscall */ +#ifdef __FreeBSD__ + /* + * FreeBSD kernel returns C bit set with positive errno. + * Encode this for use in bsd-user as -errno: + */ + negcs r0, r0 +#endif pop { r4, r5, r6, r7, r8, pc } =20 1: diff --git a/common-user/host/i386/safe-syscall.inc.S b/common-user/host/i3= 86/safe-syscall.inc.S index 9e58fc6504..ba55a35e92 100644 --- a/common-user/host/i386/safe-syscall.inc.S +++ b/common-user/host/i386/safe-syscall.inc.S @@ -75,6 +75,15 @@ safe_syscall_start: int $0x80 safe_syscall_end: /* code path for having successfully executed the syscall */ +#ifdef __FreeBSD__ + /* + * FreeBSD kernel returns C bit set with positive errno. + * Encode this for use in bsd-user as -errno: + */ + jnb 2f + neg %eax +2: +#endif pop %ebx .cfi_remember_state .cfi_adjust_cfa_offset -4 diff --git a/common-user/host/x86_64/safe-syscall.inc.S b/common-user/host/= x86_64/safe-syscall.inc.S index f36992daa3..46c527e058 100644 --- a/common-user/host/x86_64/safe-syscall.inc.S +++ b/common-user/host/x86_64/safe-syscall.inc.S @@ -72,6 +72,15 @@ safe_syscall_start: syscall safe_syscall_end: /* code path for having successfully executed the syscall */ +#ifdef __FreeBSD__ + /* + * FreeBSD kernel returns C bit set with positive errno. + * Encode this for use in bsd-user as -errno: + */ + jnb 2f + neg %rax +2: +#endif pop %rbp .cfi_remember_state .cfi_def_cfa_offset 8 --=20 2.33.0 From nobody Sun May 19 06:04:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1636779811508728.4629574158203; Fri, 12 Nov 2021 21:03:31 -0800 (PST) Received: from localhost ([::1]:48550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mllCM-00088X-0d for importer@patchew.org; Sat, 13 Nov 2021 00:03:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mll60-00077c-7C for qemu-devel@nongnu.org; Fri, 12 Nov 2021 23:56:56 -0500 Received: from [2607:f8b0:4864:20::d2c] (port=43648 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 1mll5y-0003Me-FI for qemu-devel@nongnu.org; Fri, 12 Nov 2021 23:56:55 -0500 Received: by mail-io1-xd2c.google.com with SMTP id z26so13786506iod.10 for ; Fri, 12 Nov 2021 20:56:54 -0800 (PST) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id r14sm5414455iov.14.2021.11.12.20.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 20:56:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xX0hIQSZjL8ZR7arM3SqbUY2tpWX5DtaOT38oFoQlVs=; b=s0+R+QnZ9cRezKbYnHenbv8CsI8Km6OGbbyFZwKt4kn3+r2AfTceoa/JsL3VJaAU1P 20o/siBSLhNSN3rGDlPOq6h53ZFpb3z5qF62MirR8lTtR9X/X1IJiiVgjcQgj8jAk57P eb8m4Mz761hDg1X3hlXMTM/HCVvaH5exYihgdGqw/yV9wq91o4h7D7VvQ1zVoFJgOt3d Q8hq0peLkIjRN2A4k2nsHfAIgeBzDI2t+jJLX1K9Pshbx9QwQtG/3smA2rRh8erwUxMA d616gtSYZ1Mo5vsmIkSNj9aEAMMIJzAbhXXQxOXrEi9j3Ivg/wC0/xr0vOEP58VWp+sj +PaA== 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=xX0hIQSZjL8ZR7arM3SqbUY2tpWX5DtaOT38oFoQlVs=; b=SMEaANdVUGrGIONxPpwU1m1Ie+L3DqFpHfrjaVmmg+Bm/JUhshryjSivcMEsLNfKhw 0jsIcJzbirGbKaleEJePsTIsD+DaQQyEmo5/9o1Gto+hnHgVO4sIIWYF/q6MYYh5BU81 o0rU3Q9OKdZYqITs64XdoKhZrbGOcSH+wopLP76Vz7+67GcNetz9sTi4WAF1G/EWeIXY qwCvihLglJ6va2DaBGM3O+emncWooFJgqejy6tDJIlF1gzs5+9fmTeCPIZ5OW8eECDac aFQXQpo9w1Ih6JpPDTfOVdEASaRxJFPeaDGmrZLjMiiLhdlSsaIrf7hEi7fUSctSwfcG Z0CQ== X-Gm-Message-State: AOAM530yKZCVfff4wy/2Ne5/yq/Qh2kg3eciSbvjyFJlPinllFMHQH8d UWk3fcx3Hm5PJNlXBTPCrTUVawT0k2MkmQ== X-Google-Smtp-Source: ABdhPJwFiF+wTum5KPwky+ZyWA7aN/BZot1XPStRVIsidCK/Z2SVJQX+NRrtNnvgaIYWJG+v3O295w== X-Received: by 2002:a05:6638:f83:: with SMTP id h3mr15598889jal.102.1636779413104; Fri, 12 Nov 2021 20:56:53 -0800 (PST) From: Warner Losh To: qemu-devel@nongnu.org Subject: [RFC v3 5/5] *-user: move safe-syscall.* to common-user Date: Fri, 12 Nov 2021 21:56:03 -0700 Message-Id: <20211113045603.60391-6-imp@bsdimp.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211113045603.60391-1-imp@bsdimp.com> References: <20211113045603.60391-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::d2c (failed) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d2c; envelope-from=imp@bsdimp.com; helo=mail-io1-xd2c.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Philippe Mathieu-Daude , Laurent Vivier , Konrad Witaszczyk , 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: 1636779813115100001 Content-Type: text/plain; charset="utf-8" Move linux-user/safe-syscall.S to common-user/common-safe-syscall.S and replace it with a #include "common-safe-syscall.S" so that bsd-user can also use it. Also move safe-syscall.h so that it can define a few more externs. Signed-off-by: Warner Losh --- common-user/common-safe-syscall.S | 30 +++++++++++++++++++++ {linux-user =3D> common-user}/safe-syscall.h | 0 linux-user/safe-syscall.S | 31 +--------------------- linux-user/signal.c | 1 + meson.build | 1 + 5 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 common-user/common-safe-syscall.S rename {linux-user =3D> common-user}/safe-syscall.h (100%) diff --git a/common-user/common-safe-syscall.S b/common-user/common-safe-sy= scall.S new file mode 100644 index 0000000000..42ea7c40ba --- /dev/null +++ b/common-user/common-safe-syscall.S @@ -0,0 +1,30 @@ +/* + * safe-syscall.S : include the host-specific assembly fragment + * to handle signals occurring at the same time as system calls. + * + * Written by Peter Maydell + * + * Copyright (C) 2016 Linaro Limited + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "hostdep.h" +#include "target_errno_defs.h" + +/* We have the correct host directory on our include path + * so that this will pull in the right fragment for the architecture. + */ +#ifdef HAVE_SAFE_SYSCALL +#include "safe-syscall.inc.S" +#endif + +/* We must specifically say that we're happy for the stack to not be + * executable, otherwise the toolchain will default to assuming our + * assembly needs an executable stack and the whole QEMU binary will + * needlessly end up with one. This should be the last thing in this file. + */ +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", %progbits +#endif diff --git a/linux-user/safe-syscall.h b/common-user/safe-syscall.h similarity index 100% rename from linux-user/safe-syscall.h rename to common-user/safe-syscall.h diff --git a/linux-user/safe-syscall.S b/linux-user/safe-syscall.S index 42ea7c40ba..c86f0aea74 100644 --- a/linux-user/safe-syscall.S +++ b/linux-user/safe-syscall.S @@ -1,30 +1 @@ -/* - * safe-syscall.S : include the host-specific assembly fragment - * to handle signals occurring at the same time as system calls. - * - * Written by Peter Maydell - * - * Copyright (C) 2016 Linaro Limited - * - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * See the COPYING file in the top-level directory. - */ - -#include "hostdep.h" -#include "target_errno_defs.h" - -/* We have the correct host directory on our include path - * so that this will pull in the right fragment for the architecture. - */ -#ifdef HAVE_SAFE_SYSCALL -#include "safe-syscall.inc.S" -#endif - -/* We must specifically say that we're happy for the stack to not be - * executable, otherwise the toolchain will default to assuming our - * assembly needs an executable stack and the whole QEMU binary will - * needlessly end up with one. This should be the last thing in this file. - */ -#if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack, "", %progbits -#endif +#include "common-safe-syscall.S" diff --git a/linux-user/signal.c b/linux-user/signal.c index ee038c2399..cfda166f9c 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -31,6 +31,7 @@ #include "trace.h" #include "signal-common.h" #include "host-signal.h" +#include "safe-syscall.h" =20 static struct target_sigaction sigact_table[TARGET_NSIG]; =20 diff --git a/meson.build b/meson.build index 728d305403..2f3b0fb2d6 100644 --- a/meson.build +++ b/meson.build @@ -2873,6 +2873,7 @@ foreach target : target_dirs base_dir =3D 'linux-user' target_inc +=3D include_directories('linux-user/host/' / config_host= ['ARCH']) target_inc +=3D include_directories('common-user/host/' / config_hos= t['ARCH']) + target_inc +=3D include_directories('common-user') endif if 'CONFIG_BSD_USER' in config_target base_dir =3D 'bsd-user' --=20 2.33.0