From nobody Mon Dec 11 14:16:37 2023 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 4SpkMB73KLz53f3G; Mon, 11 Dec 2023 14:16:38 +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 4SpkMB0W74z3YcV; Mon, 11 Dec 2023 14:16:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1702304198; 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=S6HTAINyJuBF4+RsPiz1OACG41ea1pwsZ6dtS8qmjvs=; b=hYYDp8BLLY5MZhxxbWpx1HzCOidjrzZbOpe/3F5IEjTmZzA6HZ0ZjQGvVNHIoxI2/+pog6 v6xwb5pNOCVMkC1P0iClC/AAoVYGsYBD7//VVeUqpdV+R3t9SDodQVar03Rqz/eZsxuLWA Zkf3KIzhlbOayXK8z3/kbF641k2ZY5hlcHLhmShfjo+0m/YKbKDrPS2wPNnoCVeRasbyRs lWQR4x8EiIwtVsbBLOPqcuaKA2OZAwvnXcGYC2uZuM3AT5eJa5a+AjtpHWizlEx55fh57W QxSbSmz8GyMc7FZcALK4XOUOHBWoWL8ZdOyXJnhM65HfqnxzW4K9s2TTr8jc2g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1702304198; a=rsa-sha256; cv=none; b=ezz2gXzSKsXTU/z6E6ZKQ+jAaE5JMFpFkzZKhHFBJhBKl62goH7+H0MyBEz1kwH+3CB8IH 7Oz1miZjgIsyAeouejkqCGYaI5V3Z/s8G4TylHiMPj8bYYQpqEh6PDYnoQd7TVdoS6elkf ZloHa9qtild33Q29Hh8XKy5ziMPjYFkopjq1sp7hLCkY3X3Jsgh16hW1vj0ZDgq5Azf6ob OQ7wAG56rhcbd5mevfHHPRsmksGyFqzwKA7cdQyaxvSmhAVVu9KkrZlFJ70B7xBQZsICTJ BqOLEWgfEC1GKS33/qiDmy2Ixj6aCXTMYo1ZWbs97prCGYYf9FkbE8vrJq5UAQ== 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=1702304198; 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=S6HTAINyJuBF4+RsPiz1OACG41ea1pwsZ6dtS8qmjvs=; b=Ia2brGu1Z0evQshszx/tQ7l0fy/NFXr94k6XD4/2UW3Z9411TgszcLaJtczXE/94/G179T ucok9cqG2oquKbdXsNhknqr9iutyAB6baO1/ptZxjyrAs3HS5zbVUblXv0HUMiU6iL972j roMcnCeCp7/aV13mGfV6XR+HvMCqu8jRW/p/MUYukE2UDWLVpRZQcydC4cjoFy9q8hBj61 IPTTykIub6APBQgw1jVvMNijzCAMlpNzQuZGKnj21aCSEFPoRx2L+pmAKAg9IF2uyPnkJE +c5LCy5oQQjgwulc7qTPxemVQL82xNwD26EMVajSna9JqCbSm3HCNULy0XHDmQ== 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 4SpkM96hB1zZBh; Mon, 11 Dec 2023 14:16:37 +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 3BBEGb7S072034; Mon, 11 Dec 2023 14:16:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BBEGbHX072031; Mon, 11 Dec 2023 14:16:37 GMT (envelope-from git) Date: Mon, 11 Dec 2023 14:16:37 GMT Message-Id: <202312111416.3BBEGbHX072031@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 03a07de0d5ee - main - arm: Handle VFP exceptions from the kernel 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 03a07de0d5ee7d58069152070c42d55f7ec32b7c Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=03a07de0d5ee7d58069152070c42d55f7ec32b7c commit 03a07de0d5ee7d58069152070c42d55f7ec32b7c Author: Mark Johnston AuthorDate: 2023-12-11 14:08:34 +0000 Commit: Mark Johnston CommitDate: 2023-12-11 14:08:34 +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 --- 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);