From nobody Mon Dec 18 02:11:44 2023 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 4StjxY29DYz54djn; Mon, 18 Dec 2023 02:11:45 +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 4StjxX5M71z3L1Q; Mon, 18 Dec 2023 02:11:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1702865504; 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=6Vnn6S/uxA0usKMjebYAfenc/qLYz4WMP2N5IjNGY0o=; b=lPozLB8q4qx+RxYqgQs4zPB5V/rdrA8c1mXbZHrYSmENZOHNlJmTzChNOt6rWmVF68MV46 lXaxqb/uvXE+rOpgJKnfdQW2NIv9o4iDWE5eVsGkf6LcoicVg1pjaUr+HytfZnsd3Xyibu yrEfTsJ/7T8WHd1H6zu1I7fUZS9oHJAysZJFrcFJZpHQssXgRMK6MQ+pdKIiDSazDGgmqJ zsxBmhkhjmbzQ1189lC84+EqkmgRP77v395F6GZsyFOsxbzK3ZtY20EMN12P2ub+IZXAUx /zSYypqXXf2jSA471qovbc6lfjuquXlM4XU6LhnLWyOeo6Jao/QnzjKdKmSRcA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1702865504; a=rsa-sha256; cv=none; b=ogU/z9yxP/FUEqm6ZVZH88RmSSDvxkL8MrmQ9YhERzhD3rtkxY2io0f94FGIdSigWnK906 GuC98U+rAs/LmKOKAuwliifdDhgB2tIkwoEvxOanXnZ/7B8EId5o4LIxnni+NXpR1XOYGT JcBKzECtQvd9LPiyjsKvSjgv9T2B1p5fWTD9kne8IrEu+jj4uGLE38DBFibhd2mQ8wmU7L 3AuX+dlhsGh5Guovm2IjXP9QYTY2onsPuQAv5adG41vONvpica3YLt2HvZ/U+30XnMiRo9 jCnqjLs8jy22bn4XYhwYgogAGPEFbu4flhatJPmkauISJqUux58idGWRcHeDPw== 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=1702865504; 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=6Vnn6S/uxA0usKMjebYAfenc/qLYz4WMP2N5IjNGY0o=; b=mDz7JZjRj3EP+WCrNK0MVq7a8FMfI4g13HLcJwXhkm6P9SX8S4zKH0S4bWOW2lsGUF5Vil D7sQOWFhXlhhbZXesA5i5AkPDJ/QOSTPD+iFVmu3f2lhQl5DmD0WBxKo4LWAqPT5XLw8J+ H39KZUvF3mnuwsm0Tn0OKnvGg2ulsZi+8hNcwl9q6Bfaap7kjLrBCeRKHy7gLDgolANC/p 7ybtPkqw9470K/+GXEOkeg4WWOp0sqtZOhRJlzfMnlLlVomPiIGpr0ZzaRGdmtKe1ET8Hw G/wI50xQuYfsuRmuM4IG+bl38c7wPijM7YiFUWqeDDK64kfKM8S1UsqPzugD0w== 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 4StjxX43LVz12q3; Mon, 18 Dec 2023 02:11:44 +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 3BI2BiBT074687; Mon, 18 Dec 2023 02:11:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BI2BigI074684; Mon, 18 Dec 2023 02:11:44 GMT (envelope-from git) Date: Mon, 18 Dec 2023 02:11:44 GMT Message-Id: <202312180211.3BI2BigI074684@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 42d1aa88628e - stable/14 - arm: Handle VFP exceptions from the kernel 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 42d1aa88628eb1652da648ef6b274155424541ec Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=42d1aa88628eb1652da648ef6b274155424541ec commit 42d1aa88628eb1652da648ef6b274155424541ec Author: Mark Johnston AuthorDate: 2023-12-11 14:08:34 +0000 Commit: Mark Johnston CommitDate: 2023-12-18 02:07:48 +0000 arm: Handle VFP exceptions from the kernel vfp_bounce() is called when handling an undefined instruction exception, to see if we need to enable the VFP. Previously it would unconditionally panic if the exception came from the kernel, which was simply wrong, and it did not permit lazy initialization of VFP state in the kernel. However, this functionality can be useful and is supported by arm's fpu_kern_enter() implementation. Thus, relax assertions and consume the exception if the thread was in an FPU section. Based on a patch from Stormshield. Reviewed by: andrew MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D42971 (cherry picked from commit 03a07de0d5ee7d58069152070c42d55f7ec32b7c) --- sys/arm/arm/vfp.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sys/arm/arm/vfp.c b/sys/arm/arm/vfp.c index f2979d4a2b27..bbcb468391b6 100644 --- a/sys/arm/arm/vfp.c +++ b/sys/arm/arm/vfp.c @@ -196,8 +196,9 @@ vfp_init(void) SYSINIT(vfp, SI_SUB_CPU, SI_ORDER_ANY, vfp_init, NULL); -/* start VFP unit, restore the vfp registers from the PCB and retry - * the instruction +/* + * Start the VFP unit, restore the VFP registers from the PCB and retry + * the instruction. */ static int vfp_bounce(u_int addr, u_int insn, struct trapframe *frame, int code) @@ -206,9 +207,6 @@ vfp_bounce(u_int addr, u_int insn, struct trapframe *frame, int code) struct pcb *curpcb; ksiginfo_t ksi; - if ((code & FAULT_USER) == 0) - panic("undefined floating point instruction in supervisor mode"); - critical_enter(); /* @@ -242,13 +240,19 @@ vfp_bounce(u_int addr, u_int insn, struct trapframe *frame, int code) return 1; } + curpcb = curthread->td_pcb; + if ((code & FAULT_USER) == 0 && + (curpcb->pcb_fpflags & PCB_FP_KERN) == 0) { + critical_exit(); + return (1); + } + /* * If the last time this thread used the VFP it was on this core, and * the last thread to use the VFP on this core was this thread, then the * VFP state is valid, otherwise restore this thread's state to the VFP. */ fmxr(fpexc, fpexc | VFPEXC_EN); - curpcb = curthread->td_pcb; cpu = PCPU_GET(cpuid); if (curpcb->pcb_vfpcpu != cpu || curthread != PCPU_GET(fpcurthread)) { vfp_restore(curpcb->pcb_vfpsaved); @@ -258,7 +262,8 @@ vfp_bounce(u_int addr, u_int insn, struct trapframe *frame, int code) critical_exit(); - KASSERT(curpcb->pcb_vfpsaved == &curpcb->pcb_vfpstate, + KASSERT((code & FAULT_USER) == 0 || + curpcb->pcb_vfpsaved == &curpcb->pcb_vfpstate, ("Kernel VFP state in use when entering userspace")); return (0);