From nobody Sun Nov 19 21:03:27 2023 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 4SYNQm27Gdz51L4N; Sun, 19 Nov 2023 21:03:28 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SYNQl6Bq5z3M5d; Sun, 19 Nov 2023 21:03:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700427807; 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=q0mkvE9HRAbxRfeN5BXqtgglo65EZepE3koGJlY8uII=; b=LbitBKJhJVwLU/JsQrmiPlG2r2YyzuaMVwmAO8whf21Ww8nDKO59wHapPp5crlBIRsNqko 3R76nZCJ8fL+Cu+J0tDCzw06SyEV1zMtkmi+LpiJmoI8bEXHYD1ij/CGawhtLVaJl72qLh KeUGq1uM1ULTsoaM6mAwWldlYj4zErmWVLvrcDeSNOjLjVStI0aIXSv8p8cGIVcetq1AR3 KYoeULWGIEsj/Xu10E/0q+a3VVUWc1TmK8j0PNsfQWwqMZmZ1Wn6oxjio6raV+MRavvzNT HSbSiGsYKramuXgL6k5wPE8rE1NkO0ldnZcwEycyUDU6HyBslgO6YAIfErwiYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700427807; 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=q0mkvE9HRAbxRfeN5BXqtgglo65EZepE3koGJlY8uII=; b=F2o8VApdOnxpFrS8d+OgCC2dGAys3iFRYuVFeizShaiX8bimeqZQkNraASplwKRXYTUUcP afiyhdEVaoWo4rMlK2XpClifeF1NZiWMSSrx7rLWD9Wn5xUFrrgfUU/QIipL3iQKX9a1iI YrbGSyWY8rcw5c/12DFrV5HasGp8uFQfVT2/495lzpd/Z0kKQuTWswZY+0/xJxt3o2AkL8 WOCsiVPF/YDmZ8UPRkjcn74KuUKhhzMBpsGpJDLFv/qdZ58RoJUt0lCyvIvs7OrpTDwJ2T 5waoaZIadDlo62JNWzkXhqbSoiAMsP888Z97IeZt675LyP7c42VFbFkIsVl2tg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700427807; a=rsa-sha256; cv=none; b=ZdBvyYxbcJid157CKekWsTO6IkpJLXt5VZ9cBOuugpodzcndulYei+Znz9xLbHtSRT9oPa P6ndz9wBtnh6GwtSHDjleceKiPQa8VCWBUz2WXXAp60JaMqZsjDakuyO6Bs2m/tk49rEOk Z+t4P08rd5WFsxKAYPSAAgxkTk1fUUZbLelcdbqDEhFSQc3OXnXqHz6H2SbyZ6d/95chOt 46kA9p68d0PI+Q7lbBBZNG6/SD1GhpRTC/DkZGj747+nBq2hMJbqkT7Kue2Ff9RAK+X4a6 kYpISS9m+u/Os2chxK1NQ/0XFXLsRnfpLp7oQ0aPjQDa7uXHcIGvvdZ3v57Rtg== 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 4SYNQl5J3Lz9T9; Sun, 19 Nov 2023 21:03:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AJL3R4H085378; Sun, 19 Nov 2023 21:03:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AJL3R3H085375; Sun, 19 Nov 2023 21:03:27 GMT (envelope-from git) Date: Sun, 19 Nov 2023 21:03:27 GMT Message-Id: <202311192103.3AJL3R3H085375@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alfredo Dal'Ava Junior" Subject: git: 62646709fd67 - stable/14 - powerpc: Fix inconsistent Altivec handling in set_mcontext 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: alfredo X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 62646709fd67d239bba13cb1c59f3720c6f59a3d Auto-Submitted: auto-generated The branch stable/14 has been updated by alfredo: URL: https://cgit.FreeBSD.org/src/commit/?id=62646709fd67d239bba13cb1c59f3720c6f59a3d commit 62646709fd67d239bba13cb1c59f3720c6f59a3d Author: Shawn Anastasio AuthorDate: 2023-11-03 17:40:18 +0000 Commit: Alfredo Dal'Ava Junior CommitDate: 2023-11-19 20:57:57 +0000 powerpc: Fix inconsistent Altivec handling in set_mcontext When support for fpu_kern_enter/fpu_kern_leave was added to powerpc, set_mcontext was updated to handle Altivec state restoration in the same way that the FPU state by lazily restoring the context on the first trap. However the function was not correctly updated to unconditionally clear the PCB_VEC and PSL_VEC bits from the pcb's flags and srr1 respectively which can sometimes result in a mismatch between a process's MSR[VEC] state and its pcb_flags. Fix this by simply clearing the VEC flags unconditionally in set_mcontext, which is already done for FPU/VSX. Fixes: a6662c37b6ffe ("powerpc: Implement fpu_kern_enter/fpu_kern_leave") Reviewed by: alfredo MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D42417 (cherry picked from commit 270f75cf3433807d124cdf1f0072ab801532f425) --- sys/powerpc/powerpc/exec_machdep.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/powerpc/powerpc/exec_machdep.c b/sys/powerpc/powerpc/exec_machdep.c index 05d3a3cf79ba..0b1751a76454 100644 --- a/sys/powerpc/powerpc/exec_machdep.c +++ b/sys/powerpc/powerpc/exec_machdep.c @@ -528,8 +528,8 @@ set_mcontext(struct thread *td, mcontext_t *mcp) * Additionally, ensure VSX is disabled as well, as it is illegal * to leave it turned on when FP or VEC are off. */ - tf->srr1 &= ~(PSL_FP | PSL_VSX); - pcb->pcb_flags &= ~(PCB_FPU | PCB_VSX); + tf->srr1 &= ~(PSL_FP | PSL_VSX | PSL_VEC); + pcb->pcb_flags &= ~(PCB_FPU | PCB_VSX | PCB_VEC); if (mcp->mc_flags & _MC_FP_VALID) { /* enable_fpu() will happen lazily on a fault */ @@ -550,9 +550,6 @@ set_mcontext(struct thread *td, mcontext_t *mcp) pcb->pcb_vec.vscr = mcp->mc_vscr; pcb->pcb_vec.vrsave = mcp->mc_vrsave; memcpy(pcb->pcb_vec.vr, mcp->mc_avec, sizeof(mcp->mc_avec)); - } else { - tf->srr1 &= ~PSL_VEC; - pcb->pcb_flags &= ~PCB_VEC; } return (0);