From nobody Tue Jul 19 07:37:25 2022 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 4Ln9dx4wPhz4WbVC; Tue, 19 Jul 2022 07:37:25 +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 4Ln9dx40tBz3qC5; Tue, 19 Jul 2022 07:37:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658216245; 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=5aYbKL3/r6s0RpKW/v41qw3Aap6v60oGh1d1uAL1vgs=; b=YQ+42I+IgOS76s5kXekqxN17ZOUKTrP61BZzy/DCzjSAkHO7/64VA8dLn3XaMfT+NmxzAu WzmWuTem0H1t2r49uddIM6ubu/xpzsF5JMY3QZIlhVgPOmk0uzakwVJFLU7vE9jFPRAqdA owU2UziWjgAgERu09k0ru6jnu30bm+7aKMZb/habfaWA1NyK+NAnKlkHFEURO3uA4W1rkE w03koQqOXSebDvwj48ebEWl1J4MWtgGzvuHySPwLaqhiX9naFSfTWd9XSYb/C8pqzXy6ew r3VYmJUOYilwD1XQasuVqkI7Nv1sg4hCrQYJCEfrkj/kE9fSkKoHzGggdr9JFQ== 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 4Ln9dx2sj6z19jT; Tue, 19 Jul 2022 07:37:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 26J7bP94021580; Tue, 19 Jul 2022 07:37:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26J7bPUf021579; Tue, 19 Jul 2022 07:37:25 GMT (envelope-from git) Date: Tue, 19 Jul 2022 07:37:25 GMT Message-Id: <202207190737.26J7bPUf021579@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: 5ab7ba992e69 - stable/13 - Split out vfp_new_thread List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 5ab7ba992e697a21729842d3839e46ff595b6aea Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658216245; 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=5aYbKL3/r6s0RpKW/v41qw3Aap6v60oGh1d1uAL1vgs=; b=EqAmr9aUJfqO4/652Di7WYUHTH03FsAW0+NotBFpqkrOP99KEs1sXi/XK8K2IRQmkjCrVc ggp7HmM1OV5RJCOR1ViT5zOIWH6+epnRNvAcirCeSC9GH9R4bPVLVfSsVANdjdyPw50zVo HZ39Fl4ByVT5+mpy5bRDvp5aBB2Faf6be2PluLtMjBEzlxfWzfr346d7ssCmzkj0OHGsbR y5lBbkrlzL3x514kPUrEocZyg87na7lwMlbqotrkyD8jIgF4hiarDo6icxnGAJO5a0Zn2b NNorvR/WryR99lNsUmVTSk47hLaIIlGVXsZFjHF/SOSKduMQgKr6UFy88XwTSg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658216245; a=rsa-sha256; cv=none; b=LZbe8cDEltYtT7BLxL0EbGtJH/1EtY/jnElE7mJa6z0KBWVwiBg5KWJjwZ2fmzSbcnSEby 6JxsYAdPYzC1njSSM1dAbr3Za8gQoEEdukB7c3JKVHfZrbpG+VbkmDqUw3y39f1pqPEMIE F2UR9sCv73E1vlMHFUJ3yyLy/axr2XcpdIjCgbSic96XjEpSazA2iCVysNn93z9TimUC5T JCw69GrgNiSwgWgaq5ygUl0dr7jX5KEtCw8RK984fZkMGGDxPYQPM7xQRgim2fvqMCJ+c9 QIBKFV/usNqWU7NhmLQj9Co5RAIVQLqFMTL9MfXbFo6DIkATBaexx1f9kaSG4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=5ab7ba992e697a21729842d3839e46ff595b6aea commit 5ab7ba992e697a21729842d3839e46ff595b6aea Author: Andrew Turner AuthorDate: 2022-06-24 11:53:15 +0000 Commit: Andrew Turner CommitDate: 2022-07-19 07:03:31 +0000 Split out vfp_new_thread To keep the vfp thread creation code in one place move into vfp.c. This will also help with adding SVE support as it depends on VFP. Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35615 (cherry picked from commit baf8f20a4af43283a1fbee49b0c2ad906074f20f) --- sys/arm64/arm64/vfp.c | 26 ++++++++++++++++++++++++++ sys/arm64/arm64/vm_machdep.c | 10 +++++----- sys/arm64/include/vfp.h | 1 + 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/sys/arm64/arm64/vfp.c b/sys/arm64/arm64/vfp.c index c740832f9ef0..755143d656dc 100644 --- a/sys/arm64/arm64/vfp.c +++ b/sys/arm64/arm64/vfp.c @@ -199,6 +199,32 @@ vfp_save_state(struct thread *td, struct pcb *pcb) critical_exit(); } +/* + * Update the VFP state for a forked process or new thread. The PCB will + * have been copied from the old thread. + */ +void +vfp_new_thread(struct thread *newtd, struct thread *oldtd, bool fork) +{ + struct pcb *newpcb; + + newpcb = newtd->td_pcb; + + /* Kernel threads start with clean VFP */ + if ((oldtd->td_pflags & TDP_KTHREAD) != 0) { + newpcb->pcb_fpflags &= + ~(PCB_FP_STARTED | PCB_FP_KERN | PCB_FP_NOSAVE); + } else { + MPASS((newpcb->pcb_fpflags & (PCB_FP_KERN|PCB_FP_NOSAVE)) == 0); + if (!fork) { + newpcb->pcb_fpflags &= ~PCB_FP_STARTED; + } + } + + newpcb->pcb_fpusaved = &newpcb->pcb_fpustate; + newpcb->pcb_vfpcpu = UINT_MAX; +} + /* * Reset the FP state to avoid leaking state from the parent process across * execve() (and to ensure that we get a consistent floating point environment diff --git a/sys/arm64/arm64/vm_machdep.c b/sys/arm64/arm64/vm_machdep.c index f99721023320..2d3e5e342889 100644 --- a/sys/arm64/arm64/vm_machdep.c +++ b/sys/arm64/arm64/vm_machdep.c @@ -109,8 +109,8 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) td2->td_pcb->pcb_x[9] = (uintptr_t)td2; td2->td_pcb->pcb_lr = (uintptr_t)fork_trampoline; td2->td_pcb->pcb_sp = (uintptr_t)td2->td_frame; - td2->td_pcb->pcb_fpusaved = &td2->td_pcb->pcb_fpustate; - td2->td_pcb->pcb_vfpcpu = UINT_MAX; + + vfp_new_thread(td2, td1, true); /* Setup to release spin count in fork_exit(). */ td2->td_md.md_spinlock_count = 1; @@ -187,9 +187,9 @@ cpu_copy_thread(struct thread *td, struct thread *td0) td->td_pcb->pcb_x[9] = (uintptr_t)td; td->td_pcb->pcb_lr = (uintptr_t)fork_trampoline; td->td_pcb->pcb_sp = (uintptr_t)td->td_frame; - td->td_pcb->pcb_fpflags &= ~(PCB_FP_STARTED | PCB_FP_KERN | PCB_FP_NOSAVE); - td->td_pcb->pcb_fpusaved = &td->td_pcb->pcb_fpustate; - td->td_pcb->pcb_vfpcpu = UINT_MAX; + + /* Update VFP state for the new thread */ + vfp_new_thread(td, td0, false); /* Setup to release spin count in fork_exit(). */ td->td_md.md_spinlock_count = 1; diff --git a/sys/arm64/include/vfp.h b/sys/arm64/include/vfp.h index 650eb6938f5e..b093ecd768cc 100644 --- a/sys/arm64/include/vfp.h +++ b/sys/arm64/include/vfp.h @@ -67,6 +67,7 @@ struct thread; void vfp_init(void); void vfp_discard(struct thread *); +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 *);