From owner-svn-src-all@freebsd.org Thu Dec 3 01:40:00 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2DA774753DE; Thu, 3 Dec 2020 01:40:00 +0000 (UTC) (envelope-from bdragon@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CmdnD0kfkz4bqx; Thu, 3 Dec 2020 01:40:00 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F22C4114B2; Thu, 3 Dec 2020 01:39:59 +0000 (UTC) (envelope-from bdragon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0B31dxNk032957; Thu, 3 Dec 2020 01:39:59 GMT (envelope-from bdragon@FreeBSD.org) Received: (from bdragon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0B31dxJX032955; Thu, 3 Dec 2020 01:39:59 GMT (envelope-from bdragon@FreeBSD.org) Message-Id: <202012030139.0B31dxJX032955@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdragon set sender to bdragon@FreeBSD.org using -f From: Brandon Bergren Date: Thu, 3 Dec 2020 01:39:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368290 - in head/sys/powerpc: include powerpc X-SVN-Group: head X-SVN-Commit-Author: bdragon X-SVN-Commit-Paths: in head/sys/powerpc: include powerpc X-SVN-Commit-Revision: 368290 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Dec 2020 01:40:00 -0000 Author: bdragon Date: Thu Dec 3 01:39:59 2020 New Revision: 368290 URL: https://svnweb.freebsd.org/changeset/base/368290 Log: [PowerPC64LE] Fix LE VSX/fpr interop In the PCB struct, we need to match the VSX register file layout correctly, as the VSRs shadow the FPRs. In LE, we need to have a dword of padding before the fprs so they end up on the correct side, as the struct may be manipulated by either the FP routines or the VSX routines. Additionally, when saving and restoring fprs, we need to explicitly target the fpr union member so it gets offset correctly on LE. Fixes weirdness with FP registers in VSX-using programs (A FPR that was saved by the FP routines but restored by the VSX routines was becoming 0 due to being loaded to the wrong side of the VSR.) Original patch by jhibbits. Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D27431 Modified: head/sys/powerpc/include/pcb.h head/sys/powerpc/powerpc/fpu.c Modified: head/sys/powerpc/include/pcb.h ============================================================================== --- head/sys/powerpc/include/pcb.h Wed Dec 2 23:16:24 2020 (r368289) +++ head/sys/powerpc/include/pcb.h Thu Dec 3 01:39:59 2020 (r368290) @@ -37,6 +37,8 @@ #ifndef _MACHINE_PCB_H_ #define _MACHINE_PCB_H_ +#include + #include #ifndef _STANDALONE @@ -62,8 +64,16 @@ struct pcb { #define PCB_CFSCR 0x40 /* Process had FSCR updated */ struct fpu { union { +#if _BYTE_ORDER == _BIG_ENDIAN double fpr; uint32_t vsr[4]; +#else + uint32_t vsr[4]; + struct { + double padding; + double fpr; + }; +#endif } fpr[32]; double fpscr; /* FPSCR stored as double for easier access */ } pcb_fpu; /* Floating point processor */ Modified: head/sys/powerpc/powerpc/fpu.c ============================================================================== --- head/sys/powerpc/powerpc/fpu.c Wed Dec 2 23:16:24 2020 (r368289) +++ head/sys/powerpc/powerpc/fpu.c Thu Dec 3 01:39:59 2020 (r368290) @@ -79,7 +79,7 @@ save_fpu_int(struct thread *td) #undef SFP } else { #define SFP(n) __asm ("stfd " #n ", 0(%0)" \ - :: "b"(&pcb->pcb_fpu.fpr[n])); + :: "b"(&pcb->pcb_fpu.fpr[n].fpr)); SFP(0); SFP(1); SFP(2); SFP(3); SFP(4); SFP(5); SFP(6); SFP(7); SFP(8); SFP(9); SFP(10); SFP(11); @@ -164,7 +164,7 @@ enable_fpu(struct thread *td) #undef LFP } else { #define LFP(n) __asm ("lfd " #n ", 0(%0)" \ - :: "b"(&pcb->pcb_fpu.fpr[n])); + :: "b"(&pcb->pcb_fpu.fpr[n].fpr)); LFP(0); LFP(1); LFP(2); LFP(3); LFP(4); LFP(5); LFP(6); LFP(7); LFP(8); LFP(9); LFP(10); LFP(11);