From patchwork Fri Aug 2 19:02:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Jeanson X-Patchwork-Id: 1968482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=Jq6BDhQR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WbFf173mrz1yZl for ; Sat, 3 Aug 2024 05:05:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3BF113860763 for ; Fri, 2 Aug 2024 19:05:28 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:203:b2ee::31e5]) by sourceware.org (Postfix) with ESMTPS id E2192385DDC4 for ; Fri, 2 Aug 2024 19:02:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E2192385DDC4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E2192385DDC4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:5300:203:b2ee::31e5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625384; cv=none; b=TGnwczxKxExNm6x9kme0qYItgLqxzDeCl+ZHk+pKtwunkX8oZhL8I+eQYMF8Gz/u4rEHGGD6SeT/oNZqnxzQsZJ0CX4owvhZLQ+6bZEfEyJkDtw+xqOQJxaj7raGRtCk94AV6EypvjMtTIVAuH60Sj6YxoNkLMs4f3R9mbMdjOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722625384; c=relaxed/simple; bh=36M3TDuYP6v2jYxKrJK9e8aoGTVsMv5nppmXoUhTmbU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=W5jnUxb12SEld3Dt8jLoenMyLB4lHDFunalT/6vhRUlNY/fEyR2hJZ3imnHyyR4ebuB7Qk9FMyroEiINHSJqmv/dmm0DFZ+kLyftz55pg5fBsucawz5RsFb6T/jkWpgFNgDcC5qxc6xDb+aTd0LlActlYzvBEVEhq93WCayf2mk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1722625379; bh=36M3TDuYP6v2jYxKrJK9e8aoGTVsMv5nppmXoUhTmbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jq6BDhQRWFs6WzzfAWn50EpkLAOZ7RgpAaMXYqFxTS8PRXEsxKMDrljrkcn35p6uk gUgl5hAx9cjzvCtAh453ULDyP9+H9QO5L+fxLV8mrimdUWN42IbbkPfG2edfBOkzEP fLEDzF2BrxMKvEcu7C3S6pms4cs1RekNF2Y0Mq2DxkGndywkAuDjuLHCfow64JoO8l ZLiu+ZoiRSjBtIHStTRLJW4BRGg8MYltRKM7n5gDxCkyBKXZ9LT9EnQuCj23q8eT3x IYWOW97RX/RwerlGXbdNyOh18d2fAFKAksAlOdT+xUZNvhs4IaEvIBIWeOz51c52p7 QXgu81WcVbBDQ== Received: from mj-deb12-aarch64-glibc.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4WbFb73sfpz1Fl2; Fri, 2 Aug 2024 15:02:59 -0400 (EDT) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH RFC v11 13/17] nptl: add RSEQ_SIG for RISC-V Date: Fri, 2 Aug 2024 15:02:26 -0400 Message-Id: <20240801-rseq-abi-v11-split-v11-13-b7bbc0138bfd@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> References: <20240801-rseq-abi-v11-split-v11-0-b7bbc0138bfd@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org Enable RSEQ for RISC-V, support was added in Linux 5.18. Signed-off-by: Michael Jeanson --- sysdeps/unix/sysv/linux/riscv/bits/rseq.h | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/sysdeps/unix/sysv/linux/riscv/bits/rseq.h b/sysdeps/unix/sysv/linux/riscv/bits/rseq.h new file mode 100644 index 0000000000..dfc1fc9315 --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/bits/rseq.h @@ -0,0 +1,44 @@ +/* Restartable Sequences Linux riscv architecture header. + Copyright (C) 2021-2024 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#ifndef _SYS_RSEQ_H +# error "Never use directly; include instead." +#endif + +/* RSEQ_SIG is a signature required before each abort handler code. + + It is a 32-bit value that maps to actual architecture code compiled + into applications and libraries. It needs to be defined for each + architecture. When choosing this value, it needs to be taken into + account that generating invalid instructions may have ill effects on + tools like objdump, and may also have impact on the CPU speculative + execution efficiency in some cases. + + Select the instruction "csrw mhartid, x0" as the RSEQ_SIG. Unlike + other architectures, the ebreak instruction has no immediate field for + distinguishing purposes. Hence, ebreak is not suitable as RSEQ_SIG. + "csrw mhartid, x0" can also satisfy the RSEQ requirement because it + is an uncommon instruction and will raise an illegal instruction + exception when executed in all modes. */ + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define RSEQ_SIG 0xf1401073 +#else +/* RSEQ is currently only supported on Little-Endian. */ +#endif