From nobody Thu May 19 16:57:16 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 3AE0D1ADFB43; Thu, 19 May 2022 16:57:17 +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 4L3wy5178tz3JrQ; Thu, 19 May 2022 16:57:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652979437; 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=MmfM95855AJjq9CNWIcVJCfZG9ijammqdbzxaUrqz0w=; b=KDo6pTTya/PV0w+cMJknWwtErl18Nhyr8MU0mxI7G292VpRnoNltcU9N1TmUG6ktNgyuUZ 7QIcNDyXTpuBxReC0acAP7PlnjZRkBNrC3UgPaMUzs7nQrZtMRQJjqy0AD3o2PTqohxyNy IkIaL2OH/OgwSiflmisoYlG6YJbl3WEvQ1+Hkpw+j8aqTZ442v3F8Yloo2fH2EYV4a99pw nnVqBOiGmRSGScFjNktFPXwRNGHKjElas3m+7IaAOXOueWrRfTF4eQz+rY+OM3d9CrXsDM s8gyh1e+QLk3D6TN3A4C6UBknhcS6mfdvQCVj7lCddLt/1A9zmJeg5t0n9CvKA== 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 06AEC2190A; Thu, 19 May 2022 16:57:17 +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 24JGvGXY060701; Thu, 19 May 2022 16:57:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24JGvG0u060700; Thu, 19 May 2022 16:57:16 GMT (envelope-from git) Date: Thu, 19 May 2022 16:57:16 GMT Message-Id: <202205191657.24JGvG0u060700@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 6e2caba7a129 - main - arm64: Enable the floating-point exception traps 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: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6e2caba7a1297eeda4f43e6377667d2e049f24f9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652979437; 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=MmfM95855AJjq9CNWIcVJCfZG9ijammqdbzxaUrqz0w=; b=EGmQwlzhSUKhp0Y9Q+RiHoGU2LA7Xd55qHMnUS71RJVDhEYgu3gn+/9AQ9xrmf5lh1lvjH 42Kd1L6isfmQ3dgWjmfInyaFAEsdD8x+Hm2SN8/7dWr826FBdHgydBeUcr42nBYoBNVhOk bLJ3mCtabbPoFRkTW6R2RrEnMSsv5umYU/cXc/HEZukJEkrFjigPRQQ05QSQyelZyZFGem XYhZfEnj7sYZFJWtAP0WI4j5tPwHGVmqQ7725PgJfX6wI68H4fpoW35f/4jx2PaOTqNgkd VNkBb4NaJWALi/pVH5lwa8N3hl5gyg9/Ct0LfXRJFq41jLyHWGJo5hXQNMJ6CQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652979437; a=rsa-sha256; cv=none; b=yZl7Eln/eDJcZCo5gRID7vU9KRpeZzmnpwKbXBj67cz6UtNOKKiO5A+FjG2JxMz16ZlkTr mkpBOR5t2qu0eiGa1gKg4hLEfULsbzFuoZauwZw7FwhPshS8p0K6J6kLp9CYGVx1y053QA eZ0Bx3eIQEuUl8OUFu1VFOG/fOI//XBo3PmtxE08hFxSzqZ5GTEpD964JQY8rOSaP8m3OT YFTybCOiOv7L23zH9K7FGI5BXYC0cJZWsNsTpbgw+bmhOxH7i9XCMs3TOjuBuYzdTQxhr9 Puxgv63JgmFQhGPqGqto5otcHUsbj/bEy9Vgb1pIXMgDIEq3eAk1x6Ern8BA7A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=6e2caba7a1297eeda4f43e6377667d2e049f24f9 commit 6e2caba7a1297eeda4f43e6377667d2e049f24f9 Author: Dmitry Chagin AuthorDate: 2022-05-19 16:53:56 +0000 Commit: Dmitry Chagin CommitDate: 2022-05-19 16:53:56 +0000 arm64: Enable the floating-point exception traps To enable it user-space needs to call feenableexcept(). FPE_FLTIDO has been added as the IDF bit can't be mapped to any existing FPE code. Reviewed by: andrew@ Differential revision: https://reviews.freebsd.org/D35247 MFC after: 2 weeks --- sys/arm64/arm64/trap.c | 32 +++++++++++++++++++++++++++++++- sys/arm64/include/armreg.h | 8 ++++++++ sys/sys/signal.h | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c index b664501b62fa..5bf6c3d1a81d 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -411,6 +411,29 @@ print_registers(struct trapframe *frame) printf("spsr: %8x\n", frame->tf_spsr); } +#ifdef VFP +static void +fpe_trap(struct thread *td, void *addr, uint32_t exception) +{ + int code; + + code = FPE_FLTIDO; + if ((exception & ISS_FP_TFV) != 0) { + if ((exception & ISS_FP_IOF) != 0) + code = FPE_FLTINV; + else if ((exception & ISS_FP_DZF) != 0) + code = FPE_FLTDIV; + else if ((exception & ISS_FP_OFF) != 0) + code = FPE_FLTOVF; + else if ((exception & ISS_FP_UFF) != 0) + code = FPE_FLTUND; + else if ((exception & ISS_FP_IXF) != 0) + code = FPE_FLTRES; + } + call_trapsignal(td, SIGFPE, code, addr, exception); +} +#endif + void do_el1h_sync(struct thread *td, struct trapframe *frame) { @@ -556,11 +579,18 @@ do_el0_sync(struct thread *td, struct trapframe *frame) switch (exception) { case EXCP_FP_SIMD: - case EXCP_TRAP_FP: #ifdef VFP vfp_restore_state(); #else panic("VFP exception in userland"); +#endif + break; + case EXCP_TRAP_FP: +#ifdef VFP + fpe_trap(td, (void *)frame->tf_elr, esr); + userret(td, frame); +#else + panic("VFP exception in userland"); #endif break; case EXCP_SVC32: diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h index fbed7aa79c38..44b11617fbf1 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -265,6 +265,14 @@ /* ESR_ELx */ #define ESR_ELx_ISS_MASK 0x01ffffff +#define ISS_FP_TFV_SHIFT 23 +#define ISS_FP_TFV (0x01 << ISS_FP_TFV_SHIFT) +#define ISS_FP_IOF 0x01 +#define ISS_FP_DZF 0x02 +#define ISS_FP_OFF 0x04 +#define ISS_FP_UFF 0x08 +#define ISS_FP_IXF 0x10 +#define ISS_FP_IDF 0x80 #define ISS_INSN_FnV (0x01 << 10) #define ISS_INSN_EA (0x01 << 9) #define ISS_INSN_S1PTW (0x01 << 7) diff --git a/sys/sys/signal.h b/sys/sys/signal.h index 9dae3ce04745..27014c20973a 100644 --- a/sys/sys/signal.h +++ b/sys/sys/signal.h @@ -339,6 +339,7 @@ struct siginfo32 { #define FPE_FLTRES 6 /* Floating point inexact result. */ #define FPE_FLTINV 7 /* Invalid floating point operation. */ #define FPE_FLTSUB 8 /* Subscript out of range. */ +#define FPE_FLTIDO 9 /* Input denormal operation */ /* codes for SIGTRAP */ #define TRAP_BRKPT 1 /* Process breakpoint. */