From: miod Date: Sun, 3 Mar 2024 11:03:13 +0000 (+0000) Subject: Workaround a 88100 errata where a FPU imprecise exception may be raised X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2caa9399b095152614f81b881bd30a8d45721926;p=openbsd Workaround a 88100 errata where a FPU imprecise exception may be raised for floating-point-to-int conversions by mistake (these instructions are not supposed to raise this exception). --- diff --git a/sys/arch/m88k/m88k/m88100_fp.c b/sys/arch/m88k/m88k/m88100_fp.c index 199e0191904..250cfe3fc14 100644 --- a/sys/arch/m88k/m88k/m88100_fp.c +++ b/sys/arch/m88k/m88k/m88100_fp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m88100_fp.c,v 1.5 2020/08/19 10:10:58 mpi Exp $ */ +/* $OpenBSD: m88100_fp.c,v 1.6 2024/03/03 11:03:13 miod Exp $ */ /* * Copyright (c) 2007, 2014, Miodrag Vallat. @@ -355,6 +355,24 @@ m88100_fpu_imprecise_exception(struct trapframe *frame) /* Reset the exception cause register */ __asm__ volatile ("fstcr %r0, %fcr0"); + /* + * The 88100 errata for mask C82N (rev 0x0a) documents that an + * imprecise exception may be raised for integer instructions + * returning an inexact result. + * However, there is nothing to do in this case, since the result + * is not a floating-point value, and has been correctly put in + * the destination register; we simply need to to ignore that + * exception. + */ + switch ((frame->tf_fpit >> 11) & 0x1f) { + case 0x09: /* int */ + case 0x0a: /* nint */ + case 0x0b: /* trnc */ + return; + default: + break; + } + /* * Pick the inexact result, build a float32 or a float64 out of it, and * normalize it to the destination width.