From nobody Tue Sep 10 18:20:14 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4X3Bnq0pHZz5WNKW; Tue, 10 Sep 2024 18:20:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X3Bnq05bYz4Ljx; Tue, 10 Sep 2024 18:20:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725992415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ru+fULNBMLRgGm+OUWA+Wd/7gtCcyDgj9+HcYxx45gI=; b=A25oWN0hFY9DnwMyzarhj2q6oLGrxTtoU+uFXusiW5eoxhsfMiVeylOPonDiNDFlJ9cprY 0b7ha/2AHajkjrEDyaFw/4NAD5gVvZvu8DPO3OXR37ba05eQVafPb1Dp+LaALcsxF3vCz/ Z3NvZ8MMTIY4q8MqRCCf6sFcxpdgpg0SsqZIqx2eNN8fDDp5Kwq6pcJW6s5QTAEseYTeLq +ThUlY/K++5zLidomSntJzZKk8Kr0A4Zh2QoHxoqGu0jX2emrE9TJMObz1Yuepv42o8xV1 aJd1HiuATPjAS63lQxtkXyVYCNsqo/jS0vhZ2g98BnS9kLf8/XzunrW90x8LjA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725992415; a=rsa-sha256; cv=none; b=T6BqbzlBL8Eyd5j5xVbROeJFzDDma0NFu3WEYNGaLdYrTXM4V595s+wJ2AmbPSrOJYf6Vk eBD8Cn1GTPOGuBI/YIBU1LVsPXrtRNOMykTC0ckXgmnBqsMENy/0AQXlWCpzLSmDS4qjTq 08XJk03Wt7suH5icE3hlZzCUSLGbMsAa9WikRYfIUbMo/l3luiKQagHP/HTKy76MQD1JJd nLfqcteErKswJy1sN0H9s/6MaQG5sTRvdmMVImIUYRdQMtPkhfR0c1dPs2iONeFKUZ+FAe N/O1wD0oZrlnnD8MRS/jm+6dXnhwRmvX+OWKKo4m+4qCEjq9e4z7LNUrNBiaVg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725992415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ru+fULNBMLRgGm+OUWA+Wd/7gtCcyDgj9+HcYxx45gI=; b=u/x+fEeGE+PDfmtj8g9R5gpMsscYpK5+LtRy7KIsZLO/AJx/DALRVtHiuJAuvx5ExMyfgJ Wgk9QnE82HX4EKC19mcfJ4YAP+aJcOFO4T5MXJxHz7NP8ulK758M3rW2zf7ZTt5BlX6mIi CTyHGp2eT1lXKTFv9GdoqXbPlUGR0QV2a0w1cTaoQioYqOgvOtvSlUFb2Ok1cRpa/eNAFT R8Pn+Wg0E8e2PBcbAWzcB2I6E7xkvff36AlHwoOb8A8JQAyhhcBQLc2MudTueeAfa3sy0v S9r1uDkEfsfI/7D8ugijtmzbEl6MJ5DI1Z5xrqlMrnSqQYwmQ8sxsGL7Xs7coA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4X3Bnp6ppszy3N; Tue, 10 Sep 2024 18:20:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48AIKECh029035; Tue, 10 Sep 2024 18:20:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48AIKEj7029027; Tue, 10 Sep 2024 18:20:14 GMT (envelope-from git) Date: Tue, 10 Sep 2024 18:20:14 GMT Message-Id: <202409101820.48AIKEj7029027@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 5a800e965345 - main - Revert "arm64: write PID in CONTEXTIDR_EL1 on ctx switch" List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5a800e9653456e47aefec43c2c8aee4fa7ab42a6 Auto-Submitted: auto-generated The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=5a800e9653456e47aefec43c2c8aee4fa7ab42a6 commit 5a800e9653456e47aefec43c2c8aee4fa7ab42a6 Author: Jessica Clarke AuthorDate: 2024-09-10 18:14:39 +0000 Commit: Jessica Clarke CommitDate: 2024-09-10 18:14:39 +0000 Revert "arm64: write PID in CONTEXTIDR_EL1 on ctx switch" arm64_pid_in_contextidr is a bool yet is loaded as a 64-bit word, so reads out of bounds and will get unknown junk in the upper bits, which may cause false (the default) to be interpreted as true by the following cbz. This also doesn't even link depending on the variable's alignment, currently breaking the clang-12 and clang-13 jobs in GitHub Actions. Whilst fixing that to use ldrb instead would be trivial, there's a similar issue reading p_pid below, which is an int32_t yet read as a 64-bit word again. Fixing this means using ldrw or ldrsw, but it's not clear whether the expectation is for the PID to be zero-extended or sign-extended. Revert the commit to fix the build and, if it builds, the run-time behaviour until it can be corrected and re-landed. This reverts commit f05795e3f65f305cb770ae91d8e9c8f05d267e0d. --- sys/arm64/arm64/genassym.c | 2 -- sys/arm64/arm64/swtch.S | 17 ----------------- sys/arm64/arm64/sys_machdep.c | 6 ------ 3 files changed, 25 deletions(-) diff --git a/sys/arm64/arm64/genassym.c b/sys/arm64/arm64/genassym.c index 5a20169d51c3..a4db825e976c 100644 --- a/sys/arm64/arm64/genassym.c +++ b/sys/arm64/arm64/genassym.c @@ -58,8 +58,6 @@ ASSYM(PCB_TPIDRRO, offsetof(struct pcb, pcb_tpidrro_el0)); ASSYM(PCB_ONFAULT, offsetof(struct pcb, pcb_onfault)); ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags)); -ASSYM(PR_PID, offsetof(struct proc, p_pid)); - ASSYM(SF_UC, offsetof(struct sigframe, sf_uc)); ASSYM(TD_PROC, offsetof(struct thread, td_proc)); diff --git a/sys/arm64/arm64/swtch.S b/sys/arm64/arm64/swtch.S index 3a2bf2cb5a7f..6af70ca839a0 100644 --- a/sys/arm64/arm64/swtch.S +++ b/sys/arm64/arm64/swtch.S @@ -55,15 +55,6 @@ 999: .endm -.macro pid_in_context_idr label - adrp x9, arm64_pid_in_contextidr - ldr x10, [x9, :lo12:arm64_pid_in_contextidr] - cbz x10, \label - ldr x9, [x1, #TD_PROC] - ldr x10, [x9, #PR_PID] - msr contextidr_el1, x10 -.endm - /* * void cpu_throw(struct thread *old, struct thread *new) */ @@ -75,12 +66,8 @@ ENTRY(cpu_throw) ldr x4, [x0, #TD_PCB] ldr w5, [x4, #PCB_FLAGS] clear_step_flag w5, x6 - 1: - /* debug/trace: set CONTEXTIDR_EL1 to current PID, if enabled */ - pid_in_context_idr 2f -2: #ifdef VFP /* Backup the new thread pointer around a call to C code */ mov x19, x1 @@ -160,10 +147,6 @@ ENTRY(cpu_switch) mov x20, x1 mov x21, x2 - /* debug/trace: set CONTEXTIDR_EL1 to current PID, if enabled */ - pid_in_context_idr 0f - -0: #ifdef VFP bl vfp_save_state_switch mov x0, x20 diff --git a/sys/arm64/arm64/sys_machdep.c b/sys/arm64/arm64/sys_machdep.c index eedee1d27015..eedc57f7c572 100644 --- a/sys/arm64/arm64/sys_machdep.c +++ b/sys/arm64/arm64/sys_machdep.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -81,8 +80,3 @@ sysarch(struct thread *td, struct sysarch_args *uap) return (error); } - -bool arm64_pid_in_contextidr = false; -SYSCTL_BOOL(_machdep, OID_AUTO, pid_in_contextidr, CTLFLAG_RW, - &arm64_pid_in_contextidr, false, - "Save PID into CONTEXTIDR_EL1 register on context switch");