From nobody Sun Nov 22 19:29:30 2026 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 4jXfK71Npjz72c5g for ; Sun, 22 Nov 2026 19:29:31 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jXfK65Rz8z4W1J for ; Sun, 22 Nov 2026 19:29:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795375770; 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=ZBS/s1jzOenIqf1Zb5/XLOtKjWPU/+x6b2CIGL0VlvA=; b=eyIwvtZgm5y2nk1j0hAdN0ROX0kETyBNl0HAyMitJFtMLLWvc3sc1fJf1/v6eORKSWaMtS Svk03p8MS/wwXh7zru6GBh2PMc4tshmDgzBA9PuQJxON5WFmofse7TztO0V74ggeLwWokf rFoKBNDkzWNwKDrCMFaSRiHyVoMjHkNKa8HLkv20KewA6aqzuaQ8J/rN3xGpbnyF6J6uae uV3Gr8yOLHUEyOvs40ylag72JjEeF1IpzKgjF0mqI7BDDcFPNpHIxzKpNLfWLuzyTj2zKo 1RL7tTK1RtEt5m1LehBbrDD6ROGprOq7nJoUmibYi3WqPNcy+SEWBiBYKgFdog== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795375770; b=empH2ru984Gy5DJ5pa1wiylerq+6SZD1pXyaBUzgoHRYDnICr7ShKXI5qMR9Z7fzWJzM8x foPHOfjqbVQORLHA9slCc9q++p1ZPIo5BB00gC4t5NfvVsvcJk0w9cYvcx0reNSBtPt2AS nhlzWSPUEQusUXGgVD66Di46/62bEGpYTZSZ+itrXaAdMmPNzP1nZPeRmXvRulKR7JmsE1 xI5kGPfoSAFC6/mcDI4lHZbeKsis/PZap7/T0u1FCbz9DoUm9aXLLPSV0GF4BxNMe5lDXd bOeciogovAUlf4kyvHv4klG+K914cjqXgJb66/4OGve0kWOEh8dq804ohDWsrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795375770; 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=ZBS/s1jzOenIqf1Zb5/XLOtKjWPU/+x6b2CIGL0VlvA=; b=p/t6VZTIyZfCkCt9TzZqv9XfqUKd/RfoZDqfrLOeBXqlDMjae2KgPVlWfxj0ly0hte8dF6 ljEELuAXVSWIHrFjH8vq/7jGs593mi1FhbkA3XCBT8hK0V4jChGbfIc5XCWpJVmLeWlBFb M8wJSRWa2reIFyp5YOcXUd8hXlUEY8YaKCxChopVEVtdDzRXCdQYFmyMe7+h01cle0Rtmk 6fLC2R3RTTaf+zKYn7OpYvBLpQNDm6PUnbMflEVUOKbqYt7UcibDHp2fbQUWOtj9vicycw kQin2jSnTBcZ3d1UMY0VsmymN/j2KfSJbYB8byvM3P5LqxQpVyxvKETaNRqhaw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jXfK64jV2zGJ1 for ; Sun, 22 Nov 2026 19:29:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 26f06 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 22 Nov 2026 19:29:30 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Piotr Kubaj Subject: git: 835c11cf44e9 - stable/14 - powerpc: fix the VSCR save and restore on little endian List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: pkubaj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 835c11cf44e90086ab5198b32491a317a7c226b4 Auto-Submitted: auto-generated Date: Sun, 22 Nov 2026 19:29:30 +0000 Message-Id: <6b03429a.26f06.3e0edce1@gitrepo.freebsd.org> The branch stable/14 has been updated by pkubaj: URL: https://cgit.FreeBSD.org/src/commit/?id=835c11cf44e90086ab5198b32491a317a7c226b4 commit 835c11cf44e90086ab5198b32491a317a7c226b4 Author: Piotr Kubaj AuthorDate: 2026-10-18 10:41:39 +0000 Commit: Piotr Kubaj CommitDate: 2026-11-22 14:41:03 +0000 powerpc: fix the VSCR save and restore on little endian VSCR was saved and restored through stvewx/lvewx at byte 12 of a 16 byte slot. Which element those instructions move at a given address depends on the byte order, so on little-endian kernels they touched VR bits 0-31 instead of the 96-127 where mfvscr/mtvscr keep VSCR: every context switch and signal reset VSCR to 0, losing NJ and SAT. Replicate the word into all four elements first so that the element choice no longer matters. VSCR[NJ] set with mtvscr read back as 0 after a usleep on a little-endian kernel; it is preserved now. Reviewed by: adrian, jhibbits MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D61525 (cherry picked from commit 27b4bb447eababd60da777065a813d2379050850) --- sys/powerpc/powerpc/altivec.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sys/powerpc/powerpc/altivec.c b/sys/powerpc/powerpc/altivec.c index 5072cf3dc6f6..e0f807cc0b53 100644 --- a/sys/powerpc/powerpc/altivec.c +++ b/sys/powerpc/powerpc/altivec.c @@ -72,7 +72,15 @@ save_vec_int(struct thread *td) STVX(28); STVX(29); STVX(30); STVX(31); #undef STVX - __asm __volatile("mfvscr 0; stvewx 0,0,%0" :: "b"(&pcb->pcb_vec.vscr)); + /* + * mfvscr places VSCR in bits 96-127 of the vector register, but + * which word stvewx stores at a given address depends on the byte + * order (in little-endian mode element positions are reversed). + * Replicate VSCR into all four words first, so the store is right + * either way. + */ + __asm __volatile("mfvscr 0; vspltw 0,0,3; stvewx 0,0,%0" + :: "b"(&pcb->pcb_vec.vscr)); /* * Disable vector unit again @@ -124,8 +132,18 @@ enable_vec(struct thread *td) * (this needs to done before loading the user's vector registers * since we need to use a scratch vector register) */ - __asm __volatile("vxor 0,0,0; lvewx 0,0,%0; mtvscr 0" \ + /* + * lvewx loads the word into whichever element the byte order maps + * that address to; replicate it into all words so that mtvscr finds + * it in bits 96-127 either way. + */ +#if _BYTE_ORDER == _BIG_ENDIAN + __asm __volatile("lvewx 0,0,%0; vspltw 0,0,3; mtvscr 0" \ + :: "b"(&pcb->pcb_vec.vscr)); +#else + __asm __volatile("lvewx 0,0,%0; vspltw 0,0,0; mtvscr 0" \ :: "b"(&pcb->pcb_vec.vscr)); +#endif #define LVX(n) __asm ("lvx " #n ",0,%0" \ :: "b"(&pcb->pcb_vec.vr[n]));