From nobody Sun Nov 22 19:28:59 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 4jXfJX1N9dz72c3S for ; Sun, 22 Nov 2026 19:29:00 +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 4jXfJW6XGwz4VCm for ; Sun, 22 Nov 2026 19:28:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795375739; 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=A6KgIvTywiA1vFpDCi/E7GAVfQckMRs1Hyg9PiAMtkw=; b=tns8PJ+LUv383MGah04B5gu8TTeg7EECfrazPc8ZUTCCHE+Zhe03fPrA+W/Q5zZwb2YovV epHZPoCOwylAkLywS2BgBTZyED5onaBxDMwLz0JcACAoMEkVpiDu2KwH/wAuqXRI9p5VXD bK5B2D1pXwgftuQPhXT6DNsxg+Abvh22c9GNbR73YTmrC6AFPlsCX4NHCClRy2hyvwHL+I JDk1lmy5vMLRARKm9ogv1yzqceS319u9W2xuuAm0G2t1zUPEZC9qPMIEKV4XdWuh1FIbm4 JLrwkxVOyJqnGfn3Qh0IDXF0Dt5upa3Z5VOsZPNhYk1Pmde/5Iy/XnM9YujjUg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795375739; b=BD4znIXGJ1/OHZeWKynI85iI7eAKxq/fkrtPg6cghf8BDNMuhRfLYdWMki/52XSMLIu0A6 7pAwhk8mMyFGfyildeSbyaVGCijnty2cm+NkJFOL/FM9coxomHVXJLkQFLs/8X5u/N7zHM gfRKPtmk0x76nh2TD6nw7iZ/O0Qa8p3vbkZMYKn57du8Bb5h9tnkWbB+ZUk5YBOFyUNRVp hpL6qW2rtSxLfo6Mpo2hlXDxcUsH5IWMBHEP6h5nzGObYhpCh/aRBBQ8bkz0vQFNGMzmE+ Z8683jw6BH2lzHfruOu/3r45gXkWpjK8usOANLRIsARLaN5gopYVKfPM6O6cdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795375739; 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=A6KgIvTywiA1vFpDCi/E7GAVfQckMRs1Hyg9PiAMtkw=; b=XpuWqmjam7zTobzSGY/BAPoqv/d9UtNEful5DiqNWvlsZhnDR0dvFNCxghLv9PCULzVt6v EULiLbTUl7Uk2J+z8qqhx8hppiONZnAMMJldOK+W9lPk0gxgwUsixzNd6jy+eot6wBu2Ec UBOIvvvG8XnjLwSz4j2ZAbf7w4hiydZn2yUJStj9807yNDXvzntO/+6OYKlm3fdmMyubV9 wJKvY8H8XVGN+I63hK0FgtQV2iQBoKVzinF+WHlSxXnr3ANLu2x8MwKpYb1G24IvVizQ+P bBEcRqq8bI+lRFmP2a+VHpNG4nViGWEaqGzh9x+vA5UDHhYN3whId/2UBjTxVA== 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 4jXfJW67mbzHFC for ; Sun, 22 Nov 2026 19:28:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 255b8 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 22 Nov 2026 19:28:59 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Piotr Kubaj Subject: git: 3795cef2747e - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: 3795cef2747ed885db8fb0dd43911d4dfda6619b Auto-Submitted: auto-generated Date: Sun, 22 Nov 2026 19:28:59 +0000 Message-Id: <6b03427b.255b8.4939f053@gitrepo.freebsd.org> The branch stable/15 has been updated by pkubaj: URL: https://cgit.FreeBSD.org/src/commit/?id=3795cef2747ed885db8fb0dd43911d4dfda6619b commit 3795cef2747ed885db8fb0dd43911d4dfda6619b Author: Piotr Kubaj AuthorDate: 2026-10-18 10:41:39 +0000 Commit: Piotr Kubaj CommitDate: 2026-11-22 19:28:39 +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 c4f356875af0..928e5cf2f0eb 100644 --- a/sys/powerpc/powerpc/altivec.c +++ b/sys/powerpc/powerpc/altivec.c @@ -71,7 +71,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 @@ -123,8 +131,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]));