From nobody Sat Nov 14 12:12:11 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 4jRY0C3fnSz70wRZ for ; Sat, 14 Nov 2026 12:12:11 +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 4jRY0C347Zz3FQq for ; Sat, 14 Nov 2026 12:12:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794658331; 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=6K+xYM9P158lMvy5ue+VF/GiVcMnJFhlaRIkbjxMKgQ=; b=El9eUkVYtWGq6ksy6GfUsZKoB0UCFzBBhzSeLddUDGa5Nz1U//rtq6gTuawjnEV0BXnURg 3YESQwBbZ0xfpbsM2UyJMnRk1BTFYA2tX8IMbnWoYKlWKK+GEBiF+YEshZ1O4+wwZvafyp AC3nJzkAJioXLHLZ/OEGQExjiCUduWhUBfZOwXCIxBTsZO/leorZcNps4xWagHf2Z8gfNU eUU437kMlbTfEJDK8/mgL1K/k3OSCSsMg7w8vDcGopeCpmGdHuicvUlh0bKI4ADfjX0O4T nZ6lk1osLy163GEMgHaDLGXFGKabLSHWm/HT3UQWu0PNRGRCtizvlcsJ4C3TAw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794658331; b=BAujqjOBvJ5ggnPTBGJJWs3BNJZjkBzFzw88IwzMLzcNX7sC42TuhZxdkfxWB7P9UnS5OX Rk/RnW+ODd4SW3Cgmy+jkSa8LBtgme03OiUytp4T3tk7yyVfQ8LA/hWXwXVBQ5zmi83I6p if/flDEpr88HSNDi7upLREFKuzw80qvA6juJlcOxlGhmKGasVxM28cGp0LctJo+f4xREMA io1NeOVrD+DsoDk9SdKr7tvNJoPXUeRwhORUG1j0V8hqNclyfz8aJD3mz7PnH1a7xzZI9m Yp3P9/clDEAu/n5XRAc/1MF3V2J3ZB1KFdI//b75orv6gQ8iKLiIESdDwbEk0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794658331; 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=6K+xYM9P158lMvy5ue+VF/GiVcMnJFhlaRIkbjxMKgQ=; b=rLES3sRmRuzp5y/pnT/ji7L1tP7e8d5B10efenQFckrlG+RZOolrfdaCka+T2xNnZ/vwJR z+nibS0zwXwKJsU/EXN9Lds/EZyvl0wL2js47bO+UWrz6ayaqYFCkIxGJXVkD8qkVRq6DG +Nox76Ai9Xd/96BDmBir5oZ3gyI468REVYnmzi0Fal146pB1joSJkrcIu6RYqLwYUX7w4J Gch3zdnmUxqZp7um6C4aPVWa0j3wysSBN2ocMej2psWNgToChwiBvpx7HTKiQ/erAsO717 Ch6v0yPbofILHjLXEGG6CiLcnjA8G9lk2OqyAuzCQQma2JoYPlBYt2+5O3Umtw== 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 4jRY0C2k9dzKWR for ; Sat, 14 Nov 2026 12:12:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 23ac0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 14 Nov 2026 12:12:11 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Piotr Kubaj Subject: git: 27b4bb447eab - main - 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/main X-Git-Reftype: branch X-Git-Commit: 27b4bb447eababd60da777065a813d2379050850 Auto-Submitted: auto-generated Date: Sat, 14 Nov 2026 12:12:11 +0000 Message-Id: <6af8501b.23ac0.33f4dded@gitrepo.freebsd.org> The branch main has been updated by pkubaj: URL: https://cgit.FreeBSD.org/src/commit/?id=27b4bb447eababd60da777065a813d2379050850 commit 27b4bb447eababd60da777065a813d2379050850 Author: Piotr Kubaj AuthorDate: 2026-10-18 10:41:39 +0000 Commit: Piotr Kubaj CommitDate: 2026-11-14 12:06:34 +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 --- 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]));