From nobody Fri Nov 03 17:55:46 2023 X-Original-To: dev-commits-src-main@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 4SMT1b3y02z4yyNj; Fri, 3 Nov 2023 17:55:47 +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 4SMT1b1L5fz4g3M; Fri, 3 Nov 2023 17:55:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699034147; 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=RgUVmiRf9aCPc5a2kxBTofLk0VcZIwFH4wNUpktog2M=; b=pS/6z8a/h0FDtN6hXGGvJyyh3aHhvaNWYoeqzl9jJn/yCoouvEMsACdtEIQ+GIzaKabkry woZC/8WTh5KuZC63Ozpg0x2f73Ob/z5fX51yYcS3GO1UAPgUMzFPD/Y8H0Zn2g9XuH5NX+ x/OcY+glrhuKODEXT7D2VSZH2Ra/bygKvQHthZQewWATzc3nBoCQf4Lz11YaAMfSi3XeUZ h1FMsx4kCyq1jfxJTy39FkLUKGwC1UEbrcvL0HumTAWNnNZU9Jx+uLvWZ+i+I63dlO5ShB VqduI2tntoW4KYWGPDNDD/pTls5IOUUA2uC57OR4QSm5HOVR+8bGravzRu2e+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699034147; 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=RgUVmiRf9aCPc5a2kxBTofLk0VcZIwFH4wNUpktog2M=; b=oxyJewnB5xtpn17hPyzejNUk6QaV0X+BoqgP0SRDK9KvdC+8DssigyFl0fA/kF92zsWv9c ds0yXu1nGhaJopNczAJhkqgMDaS4f7nwDk8ipVUvTa2Ij6tyrlTKdycFy61mtivM6Ade6U cqmJ7IlwXEG9v7HrTTqZAaxvgS65vtyOZICPWWZBaNQgh5wPhCrQ/L3FAqq3M1IUpGnIkM YeE1q2kzqramKNir8lVJzhxXJDdAlK0il7nVuRJZqr/ILW60evnPeNlCQYSVpAitgobgQz LRXCxA9K/hZ4HfujwOjTKeGZ4yC7bfwE2QlnslyGUBXjWwphwQy+SBQZT7ASmw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699034147; a=rsa-sha256; cv=none; b=xaONrYoHdmMczLLYAQpn9VaPBB54FvQ4wT0WTHPCK7gHJzVBGUhTXqiEwS4HG286nzlHs4 Jg7qXCMbupnpKWecFSJ6QKtTQyitbTQ3OsS99wiR5tYf6kjb78KpruRYkiBvugp8GFgA6u 2AJTbpP6IXo2+i98bl+zcVFCmD2+/to/P0rfHX4aZUdlQ8lB2yW8s24VC9TRjOEaxUs2Tk PeeL4VsXLWPtdbxikeFAYUGf2mnFyeOEF5LhAXPna5U2MEU4qjTEfQgTGQoijlLszNsd/p PlYD2doxHCigfXgnO9khLEnd2Wsr56fIxKotEo5EvKIN2dYc8xVwW85OSOmfLQ== 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 4SMT1b0PC9z8B9; Fri, 3 Nov 2023 17:55:47 +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 3A3HtksO063179; Fri, 3 Nov 2023 17:55:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A3HtkIa063176; Fri, 3 Nov 2023 17:55:46 GMT (envelope-from git) Date: Fri, 3 Nov 2023 17:55:46 GMT Message-Id: <202311031755.3A3HtkIa063176@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alfredo Dal'Ava Junior" Subject: git: 270f75cf3433 - main - powerpc: Fix inconsistent Altivec handling in set_mcontext List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 270f75cf3433807d124cdf1f0072ab801532f425 Auto-Submitted: auto-generated The branch main has been updated by alfredo: URL: https://cgit.FreeBSD.org/src/commit/?id=270f75cf3433807d124cdf1f0072ab801532f425 commit 270f75cf3433807d124cdf1f0072ab801532f425 Author: Shawn Anastasio AuthorDate: 2023-11-03 17:40:18 +0000 Commit: Alfredo Dal'Ava Junior CommitDate: 2023-11-03 17:55:04 +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 --- 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);