From nobody Fri Jun 17 19:40:48 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 7301B85D486; Fri, 17 Jun 2022 19:40:49 +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 4LPqCN6RgFz3hZw; Fri, 17 Jun 2022 19:40:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494849; 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=AZeZwOnUOYwUe7wFnZS8RjCTdiR4w6dWqm8AAqiIl/A=; b=FzOAgrIYOVJU47OD4fnY3Iy24z0IY3M5SMbNPI1kjf2sbcC0LAMv4XBiGNS3iu/Vgpg/7T pBHWvnl76QffKMhrVx0oVmozswT462l/w6jiM9XYo+HsVld+fMPt2eGKOPuolY5b1iuxlS ftDFv6aJPgLCxUbYxn2ig8cN9ZWSnL+nbn1y5XLpLagqUlC0dbaj2pzNkFE5ZfI5+L9Lsf SLwaxY7lbs2DU9g11ZXUuk8Amepbg8zl8IdX/w/o5Dt9JkZDohqDxS9n31o0BVlDWEFPT5 1XstfK9URmytpv4wuxwYDgmaVbNVP9n9GRkftQcmvMprmP0rpM51cXp/YNnE3w== 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 54201259D3; Fri, 17 Jun 2022 19:40:48 +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 25HJemA7026295; Fri, 17 Jun 2022 19:40:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJemtu026294; Fri, 17 Jun 2022 19:40:48 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:40:48 GMT Message-Id: <202206171940.25HJemtu026294@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: 570206bdc227 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 570206bdc227c59d1e1e34f76387d3817d2c0354 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494849; 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=AZeZwOnUOYwUe7wFnZS8RjCTdiR4w6dWqm8AAqiIl/A=; b=mu0NRp04BqxHnLB6eFvKvRpEKrmbj2d9HzWCbmYYUCfaL7NCTl8KuPIEVyA1VuZZH8Xkud 39M8ZQTV0+yxLIlWdXTIdw1IP4nLJOG/4EUQp6CEfH4SAsBBTNfLKLCeYSYf7qpci0UkKB nzK3a4jjkQyHkfiHZQ+zzoOmlsiu4za59E0ThzcwzsDR/VgY7EVLnlbchDfP3qG2dR0o2m GTQ7aiAIdQksuuHeNz6iCY11TbqJWcKqIg4L1OBggyShGPwP4jlJwwuQ9fyWpp+yaXM8dS 4rmarFoNkLfIu7h0PtuToM3GD9tYiobxauex2od3x40uT9/3/lNwYlcrBXLsWw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494849; a=rsa-sha256; cv=none; b=Flgd9HSkN1Q5j6lQDF2rZOJZCvSpawAQyqMSDk28dqmxfAbSkc26x7cqvfnBbaRnAylg/R MK1Iyw/xGKgletnFh/MPe8NmenO95zFTpIxKQFkT6d8nQeimFr4LYEp2joj28gKNI3JeO+ rTa8x/F64cWCGK6cjZ8L/pSKof6VK7fKVAw7AOXB9CLrxSOIPdxxTXaRC1zojgNzR8M8pc FxhN6kTsvjHkC4o2Du4p9yXnsbfASA9FhW2+yah4UseEBahWSGXUwC7C6z/gceNlTY1Wm+ qxTt7iVIz1OvUpRd6jmb/wBTbTcE05kK0KAd6aP5AcsUCFRpYe9BrwCaFW2ywA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=570206bdc227c59d1e1e34f76387d3817d2c0354 commit 570206bdc227c59d1e1e34f76387d3817d2c0354 Author: Dmitry Chagin AuthorDate: 2022-05-19 16:53:56 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:35:25 +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 (cherry picked from commit 6e2caba7a1297eeda4f43e6377667d2e049f24f9) --- 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 5638bb9f496e..e9afbd47c0af 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -409,6 +409,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) { @@ -548,11 +571,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 8dc517f11a20..e16b17aa4cab 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -179,6 +179,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 8b45a521c3ee..5985ec9e94ee 100644 --- a/sys/sys/signal.h +++ b/sys/sys/signal.h @@ -332,6 +332,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. */