From nobody Thu Mar 21 10:13:46 2024 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 4V0hBN64sdz5FkpF; Thu, 21 Mar 2024 10:13:48 +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 4V0hBN0j1Gz4548; Thu, 21 Mar 2024 10:13:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711016028; 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=1GEQyjjkIChFFSoauKF/ZwOYKeLnX8J/Rkm3JAHAOpE=; b=khdEWLWM8Z7o/KP+D/2PNCn71tzq3xNJvrxlk7CcuM6kaoxpINzqNiQRwsZZQDPewbHrvd Frsra6ZLg+YyCbITG0hD+gp8Zws0lW0RADXRs37ssxF9JXtT3+P71Qx+mqFXJNDMZlz5ZG 3qHO3RKJSEjnBRTGRHL8cWKSov5TfbuXHXxOAqhuLxLi8zT3RktfoZsMIOPRnYSSMQGPXs CpR+m6zRGeS2k7x1/0Y86RQ7Z6x8q4/zUZKuFGnCNCNJDrUFzawdZhTkK05GcKwk5GIEO5 bRSJTIk1cJQRrnf9Sx16MSHbfY4qXb8Qdko9ED6R7U26/9vimhiWZXxM+MU63w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1711016028; a=rsa-sha256; cv=none; b=iAf2Lx/8FQyO2h1u3B9ECFvA4UfR+CxzlGm954i0AfDQLY19H6Ic3MeHEfxebfL/3D4g1b OW4cANwYdz1jLh9/20nNjLPAwxRq/2ABA6mo7cW/RvgLP/w1xVo+CgSM62zrni3d4DODQ1 bMPmwAImVG/umKEuiHEBaFm/euA69KrfLEctqsBa6wf7feJye8P0wUctSz5nQ6mALxDbAg f4oT/HyOWQ2j0iqrwqvIZXtB7ZpEovi7HT1CeuPynFDOquZwy0p97Qlv/0+3vjiX5SnoaO NWIdzraFSq3pOShSfdJ7XT9H9O4rvpGJ7B+ZqR+3d995Y/Qw92Sfk16enmrQTQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711016028; 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=1GEQyjjkIChFFSoauKF/ZwOYKeLnX8J/Rkm3JAHAOpE=; b=jtan9RTET6JabqbY1Pqp2CG9+dVf+Ok6Xi+f897/scP/emHLZoMD9opRfnF6bjak2S+fN6 ehUd1TLl/lQk3B52RARKyGYqkGiEMYUfF8BX+Mp+5d8ecfQIgbWyJrxvDLIcnrQ6Tdnqvy A0MRf4K6ve+qmNDsnGbPr0CcaLSGMlU9XJbf6N8aKRWGYpficFLFQMpTfZjrMRXEE92xl5 Vq2qn9ARLOcCorBi70JULWeF2dgistb9dN2ovqdMmctNc5HEMO7apcRrVOKzAMQnn1rGqt gWPkWUch40q9Mkc9eFPvWjufItQKOUMTKuvVayIFbaMPFb+NJP2rTfb1T95wyA== 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 4V0hBL5d7XzXR6; Thu, 21 Mar 2024 10:13:46 +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 42LADk7I032353; Thu, 21 Mar 2024 10:13:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42LADk3F032350; Thu, 21 Mar 2024 10:13:46 GMT (envelope-from git) Date: Thu, 21 Mar 2024 10:13:46 GMT Message-Id: <202403211013.42LADk3F032350@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 12257233e8fd - main - arm64: Split out a savectx version of vfp_save_state 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: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 12257233e8fd94ab24e1a84ad87126af2a7be33b Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=12257233e8fd94ab24e1a84ad87126af2a7be33b commit 12257233e8fd94ab24e1a84ad87126af2a7be33b Author: Andrew Turner AuthorDate: 2024-01-03 17:41:42 +0000 Commit: Andrew Turner CommitDate: 2024-03-21 10:13:24 +0000 arm64: Split out a savectx version of vfp_save_state Rather than try to detect when vfp_save_state is called by savectx use a separate function that sets up the pcb as needed. Reviewed by: imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D43304 --- sys/arm64/arm64/swtch.S | 4 +--- sys/arm64/arm64/vfp.c | 42 ++++++++++++++++++++++++++---------------- sys/arm64/include/vfp.h | 1 + 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/sys/arm64/arm64/swtch.S b/sys/arm64/arm64/swtch.S index 4c9851da3dc6..9c43de3a9eae 100644 --- a/sys/arm64/arm64/swtch.S +++ b/sys/arm64/arm64/swtch.S @@ -270,9 +270,7 @@ ENTRY(savectx) /* Store the VFP registers */ #ifdef VFP mov x28, lr - mov x1, x0 /* move pcb to the correct register */ - mov x0, xzr /* td = NULL */ - bl vfp_save_state + bl vfp_save_state_savectx mov lr, x28 #endif diff --git a/sys/arm64/arm64/vfp.c b/sys/arm64/arm64/vfp.c index ced1a446f0a8..749d5b81bfc8 100644 --- a/sys/arm64/arm64/vfp.c +++ b/sys/arm64/arm64/vfp.c @@ -166,25 +166,11 @@ vfp_restore(struct vfpstate *state) : : "r"(fpcr), "r"(fpsr), "r"(vfp_state)); } -void -vfp_save_state(struct thread *td, struct pcb *pcb) +static void +vfp_save_state_common(struct thread *td, struct pcb *pcb) { uint32_t cpacr; - KASSERT(pcb != NULL, ("NULL vfp pcb")); - KASSERT(td == NULL || td->td_pcb == pcb, ("Invalid vfp pcb")); - - /* - * savectx() will be called on panic with dumppcb as an argument, - * dumppcb doesn't have pcb_fpusaved set, so set it to save - * the VFP registers. - */ - if (pcb->pcb_fpusaved == NULL) - pcb->pcb_fpusaved = &pcb->pcb_fpustate; - - if (td == NULL) - td = curthread; - critical_enter(); /* * Only store the registers if the VFP is enabled, @@ -202,6 +188,30 @@ vfp_save_state(struct thread *td, struct pcb *pcb) critical_exit(); } +void +vfp_save_state(struct thread *td, struct pcb *pcb) +{ + KASSERT(td != NULL, ("NULL vfp thread")); + KASSERT(pcb != NULL, ("NULL vfp pcb")); + KASSERT(td->td_pcb == pcb, ("Invalid vfp pcb")); + + vfp_save_state_common(td, pcb); +} + +void +vfp_save_state_savectx(struct pcb *pcb) +{ + /* + * savectx() will be called on panic with dumppcb as an argument, + * dumppcb doesn't have pcb_fpusaved set, so set it to save + * the VFP registers. + */ + MPASS(pcb->pcb_fpusaved == NULL); + pcb->pcb_fpusaved = &pcb->pcb_fpustate; + + vfp_save_state_common(curthread, pcb); +} + /* * Update the VFP state for a forked process or new thread. The PCB will * have been copied from the old thread. diff --git a/sys/arm64/include/vfp.h b/sys/arm64/include/vfp.h index 8c3d56918822..7f4c86e7737d 100644 --- a/sys/arm64/include/vfp.h +++ b/sys/arm64/include/vfp.h @@ -78,6 +78,7 @@ void vfp_new_thread(struct thread *, struct thread *, bool); void vfp_reset_state(struct thread *, struct pcb *); void vfp_restore_state(void); void vfp_save_state(struct thread *, struct pcb *); +void vfp_save_state_savectx(struct pcb *); struct fpu_kern_ctx;