mlewis@dolphin.tcspa.ibm.com (Mark S. Lewis) (03/10/90)
Subject: Fix for APC floating point problem (part 1/2) IBM/4.3
Index: /sys/ca/{trap.c, ioim.h}
Description:
There is an unusual set of circumstances that could cause
certain models of the IBM RT System (6150, 6151) and the IBM
6152 Academic System to give inaccurate floating point arithmetic
results. Although the probability of its occurrence is
extremely remote, we are informing our customers and
providing a fix.
These fixes are designed to detect the circumstances where
a floating point error could potentially occur and to
prevent the floating point error from occurring.
The complete fix is comprised of 3 components: a patch
to vmunix, a patch to the floating point library, and a
new version of the Fortran compiler hf77.
V1.27_kit.1 - Patch to the kernel (this file)
V1.27_kit.2 - Patch to the floating point library
hf77_12.1_tar.Z - Fortran hf77 with fix
(628233 bytes, 20410 checksum)
The Fortran compiler can be copied (uucp) from the IBM support
host ibmsupt from the directory /usr/spool/uucppublic/ibm43-fixes.
(See V1.28 for details.)
Fix:
Following is a patch to the kernel. Apply this patch to the
Dec 88 release of IBM/4.3. Make the kernel and install it.
See "Building IBM/4.3 Systems with Config" in volume II
of the manual.
cd /sys/ca
patch -p1 < V1.27_kit.1
*** trap.c Thu Jan 4 17:50:06 1990
--- trap.c.fix Mon Jan 8 16:40:57 1990
***************
*** 1,15 ****
/*
! * 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1986,1987,1988
* LICENSED MATERIALS - PROPERTY OF IBM
* REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
*/
! /* $Header:trap.c 11.5$ */
! /* $ACIS:trap.c 11.5$ */
/* $Source: /ibm/acis/usr/sys/ca/RCS/trap.c,v $ */
#if !defined(lint) && !defined(NO_RCS_HDRS)
! static char *rcsid = "$Header:trap.c 11.5$";
#endif
#if defined(DEBUG) && !defined(SYSCALLTRACE)
#define SYSCALLTRACE
#endif
--- 1,16 ----
/*
! * 5799-CGZ (C) COPYRIGHT IBM CORPORATION 1986,1987,1988
* LICENSED MATERIALS - PROPERTY OF IBM
* REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
*/
! /* $Header: trap.c,v 12.2 89/06/07 13:48:42 cslater Exp $ */
! /* $ACIS:trap.c 9.0$ */
/* $Source: /ibm/acis/usr/sys/ca/RCS/trap.c,v $ */
#if !defined(lint) && !defined(NO_RCS_HDRS)
! static char *rcsid = "$Header: trap.c,v 12.2 89/06/07 13:48:42 cslater
Exp $";
#endif
+
#if defined(DEBUG) && !defined(SYSCALLTRACE)
#define SYSCALLTRACE
#endif
***************
*** 136,141 ****
--- 137,147 ----
goto grave;
}
if (locr0[ECR_COUNT] > 1)
+ if (check_apc_bug(locr0)) {
+ i = SIGBUS;
+ break;
+ }
+ if (locr0[ECR_COUNT] > 1)
info = apc_mux(locr0,info); /* handle multiple exceptions */
info = (info&(NBPG-1)) | (locr0[EX1_ADDR] & (-NBPG));
/* fall thru for now */
***************
*** 142,147 ****
--- 148,158 ----
#endif ROMPC
case DPAGE_FAULT + USER: /* data page fault */
case IPAGE_FAULT + USER: /* inst page fault */
+ if (locr0[ECR_COUNT] > 1)
+ if (check_apc_bug(locr0)) {
+ i = SIGBUS;
+ break;
+ }
if (info & MMU_EX_KEYS) {
#ifdef SIM_CHG_BIT
if (GETSEG(info) == 0xf) {
***************
*** 1101,1103 ****
--- 1112,1137 ----
}
#endif ROMPC
+
+ static
+ check_apc_bug(locr0)
+ register int *locr0;
+ {
+ int addr2 = locr0[EX2_ADDR];
+ int ctl2 = locr0[EX2_CTL];
+ int addr1 = locr0[EX1_ADDR];
+ int ctl1 = locr0[EX1_CTL];
+
+ if (GETSEG(addr1) == 0xf && GETSEG(addr2) == 0xf &&
+ IS_FLOAT(addr1) && IS_FLOAT(addr2))
+ if (addr1 == addr2 && ctl1 == ctl2 &&
+ locr0[EX1_DATA] == locr0[EX2_DATA])
+ {
+ DEBUGF(1, printf("possible CPU fault:\n"));
+ DEBUGF(1, printf("addr1=addr2=%x\n",addr1));
+ DEBUGF(1, printf("ctl1=ctl2=%x\n",ctl1));
+ DEBUGF(1, printf("EX1_DATA=EX2_DATA=%x\n",locr0[EX1_DATA]));
+ return 1;
+ }
+ return 0;
+ }
*** ioim.h Mon Jan 8 10:29:04 1990
--- ioim.h.fix Mon Jan 8 10:31:47 1990
***************
*** 1,14 ****
/*
! * 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1987
* LICENSED MATERIALS - PROPERTY OF IBM
* REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
*/
! /* $Header:ioim.h 12.0$ */
! /* $ACIS:ioim.h 12.0$ */
/* $Source: /ibm/acis/usr/sys/ca/RCS/ioim.h,v $ */
#if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS)
! static char *rcsidioim = "$Header:ioim.h 12.0$";
#endif
#ifdef ROMPC
--- 1,13 ----
/*
! * P_R_P_Q_# (C) COPYRIGHT IBM CORPORATION 1987
* LICENSED MATERIALS - PROPERTY OF IBM
* REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
*/
! /* $Header: ioim.h,v 12.1 89/05/12 11:44:14 triha Exp $ */
/* $Source: /ibm/acis/usr/sys/ca/RCS/ioim.h,v $ */
#if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS)
! static char *rcsidioim = "$Header: ioim.h,v 12.1 89/05/12 11:44:14
triha Exp $";
#endif
#ifdef ROMPC
***************
*** 157,162 ****
--- 156,163 ----
/* GETSUBSEG() is defined in mmu.h */
#define IS_IOCC(reg) (GETSUBSEG(reg) == 0 || GETSUBSEG(reg) == 4)
#define IS_68881(reg) (GETSUBSEG(reg) == 0x0c || GETSUBSEG(reg) == 0x0d)
+ #define IS_FLOAT(reg) (GETSUBSEG(reg) >= 0x0c)
+ #define IS_FPA(reg) (GETSUBSEG(reg) == 0x0e || GETSUBSEG(reg) == 0x0f)
#define IS_CANCELLED(reg) ((reg)&EX_CANCELLED)
/**/
/*
=====----- Mark S. Lewis, IBM AWD Palo Alto -----======
inet: mlewis%ibmsupt@uunet.uu.net (415) 855-4486
uucp: uunet!ibmsupt!mlewis IBM Tie Line: 465-4486mlewis@dolphin.tcspa.ibm.com (Mark S. Lewis) (03/10/90)
Subject: Fix for APC floating point problem (part 2/2) IBM/4.3
Index: /usr/src/usr.lib/libfp/genfp/{f881gen, fpa2gen}.c
Description:
There is an unusual set of circumstances that could cause
certain models of the IBM RT System (6150, 6151) and the IBM
6152 Academic System to give inaccurate floating point arithmetic
results. Although the probability of its occurrence is
extremely remote, we are informing our customers and
providing a fix.
These fixes are designed to detect the circumstances where
a floating point error could potentially occur and to
prevent the floating point error from occurring.
The complete fix is comprised of 3 components: a patch
to vmunix, a patch to the floating point library, and a
new version of the fortran compiler hf77.
V1.27_kit.1 - Patch to kernel
V1.27_kit.2 - Patch to fp library (this file)
hf77_12.1_tar.Z - hf77 with APC fix
(628233 bytes, 20410 checksum)
The fortran compiler can be copied (uucp) from the IBM support
host ibmsupt from the directory /usr/spool/uucppublic/ibm43-fixes.
(See V1.28 for details.)
Fix:
Following is a patch to the floating point library. Apply
this patch to the Dec 88 release of IBM/4.3. Make and install
the new library.
cd /usr/src/usr.lib/libfp/genfp
patch -p1 < V1.27_kit.2
*** f881gen.c Thu Jan 4 17:47:18 1990
--- f881gen.c.fix Thu Jan 4 16:43:32 1990
***************
*** 1,14 ****
/*
! * 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1987,1988
* LICENSED MATERIALS - PROPERTY OF IBM
* REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
*/
! /* $Header:f881gen.c 12.0$ */
! /* $ACIS:f881gen.c 12.0$ */
/* $Source: /ibm/acis/usr/src/usr.lib/libfp/genfp/RCS/f881gen.c,v $ */
#ifndef lint
! static char *rcsid = "$Header:f881gen.c 12.0$";
#endif
#include "fpgen.h"
--- 1,13 ----
/*
! * P_R_P_Q_# (C) COPYRIGHT IBM CORPORATION 1987,1988
* LICENSED MATERIALS - PROPERTY OF IBM
* REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
*/
! /* $Header: f881gen.c,v 12.1 89/05/09 23:21:46 triha Exp $ */
/* $Source: /ibm/acis/usr/src/usr.lib/libfp/genfp/RCS/f881gen.c,v $ */
#ifndef lint
! static char *rcsid = "$Header: f881gen.c,v 12.1 89/05/09 23:21:46
triha Exp $";
#endif
#include "fpgen.h"
***************
*** 406,411 ****
--- 405,411 ----
/* move the value on stack into which_scr */
i += _fp_inst_store(&newcode[i], ra, rr, f881_WRITE_SCR(which_scr));
+ newcode[i++] = RTi_SYNC;
return (i);
} /* end _mv_gr2fpscr */
***************
*** 917,923 ****
f881_PREC_MASK,f881_PREC_SINGLE);
inst.L = f881inst(f881_F2F,fdst,fdst,OP881_MOVE);
icode += _fp_new_inst_store(&newcode[icode],gi,r0,inst);
! }
} else { /* need to move opnd1 <- freg */
if (is_uint(resprec) && check_version(VERSION_UNSIGNED))
icode += _f881_sub_2to31(&newcode[icode],gi,fdst,ra,ri);
--- 917,926 ----
f881_PREC_MASK,f881_PREC_SINGLE);
inst.L = f881inst(f881_F2F,fdst,fdst,OP881_MOVE);
icode += _fp_new_inst_store(&newcode[icode],gi,r0,inst);
! } else if ((gi->data->opcode == FP_MOVE) &&
! ((hi_optype_of(gi,1) == ADDRTYPE) ||
! (hi_optype_of(gi,1) == IMMEDTYPE)))
! newcode[icode++] = RTi_SYNC;
} else { /* need to move opnd1 <- freg */
if (is_uint(resprec) && check_version(VERSION_UNSIGNED))
icode += _f881_sub_2to31(&newcode[icode],gi,fdst,ra,ri);
***************
*** 1049,1055 ****
f881_PREC_MASK,f881_PREC_SINGLE);
inst.L = f881inst(f881_F2F,fdst,fdst,OP881_MOVE);
icode += _fp_new_inst_store(&newcode[icode],gi,r0,inst);
! }
} else { /* need to move opnd1 <- freg */
if (is_uint(resprec) && check_version(VERSION_UNSIGNED))
icode += _f881_sub_2to31(&newcode[icode],gi,fdst,ra,ri);
--- 1052,1060 ----
f881_PREC_MASK,f881_PREC_SINGLE);
inst.L = f881inst(f881_F2F,fdst,fdst,OP881_MOVE);
icode += _fp_new_inst_store(&newcode[icode],gi,r0,inst);
! } else if ((hi_optype_of(gi,1) == ADDRTYPE) ||
! (hi_optype_of(gi,1) == IMMEDTYPE))
! newcode[icode++] = RTi_SYNC;
} else { /* need to move opnd1 <- freg */
if (is_uint(resprec) && check_version(VERSION_UNSIGNED))
icode += _f881_sub_2to31(&newcode[icode],gi,fdst,ra,ri);
***************
*** 1192,1198 ****
f881_PREC_MASK,f881_PREC_SINGLE);
inst.L = f881inst(f881_F2F,fdst,fdst,OP881_MOVE);
icode += _fp_new_inst_store(&newcode[icode],gi,r0,inst);
! }
} else { /* need to move opnd1 <- freg */
if (is_uint(resprec) && check_version(VERSION_UNSIGNED))
icode += _f881_sub_2to31(&newcode[icode],gi,fdst,ra,ri);
--- 1197,1204 ----
f881_PREC_MASK,f881_PREC_SINGLE);
inst.L = f881inst(f881_F2F,fdst,fdst,OP881_MOVE);
icode += _fp_new_inst_store(&newcode[icode],gi,r0,inst);
! } else if ((arg2type == ADDRTYPE) || (arg2type == IMMEDTYPE))
! newcode[icode++] = RTi_SYNC;
} else { /* need to move opnd1 <- freg */
if (is_uint(resprec) && check_version(VERSION_UNSIGNED))
icode += _f881_sub_2to31(&newcode[icode],gi,fdst,ra,ri);
*** fpa2gen.c Thu Jan 4 17:47:09 1990
--- fpa2gen.c.fix Thu Jan 4 16:45:41 1990
***************
*** 1,14 ****
/*
! * 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1987,1988
* LICENSED MATERIALS - PROPERTY OF IBM
* REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
*/
! /* $Header:fpa2gen.c 12.0$ */
! /* $ACIS:fpa2gen.c 12.0$ */
/* $Source: /ibm/acis/usr/src/usr.lib/libfp/genfp/RCS/fpa2gen.c,v $ */
#ifndef lint
! static char *rcsid = "$Header:fpa2gen.c 12.0$";
#endif
#include "fpgen.h"
--- 1,13 ----
/*
! * P_R_P_Q_# (C) COPYRIGHT IBM CORPORATION 1987,1988
* LICENSED MATERIALS - PROPERTY OF IBM
* REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
*/
! /* $Header: fpa2gen.c,v 12.1 89/05/09 23:22:32 triha Exp $ */
/* $Source: /ibm/acis/usr/src/usr.lib/libfp/genfp/RCS/fpa2gen.c,v $ */
#ifndef lint
! static char *rcsid = "$Header: fpa2gen.c,v 12.1 89/05/09 23:22:32
triha Exp $";
#endif
#include "fpgen.h"
***************
*** 226,231 ****
--- 225,231 ----
else
instr = fpa2DMAwrite(freg,len);
i += _fp_new_inst_store(&newcode[i], gi, rx, instr);
+ newcode[i++] = RTi_SYNC;
if (rx != byteval_of(gi, opndnum)) fp_free_genr(gi, rx);
return(i);
***************
*** 333,338 ****
--- 333,339 ----
(freg1*2), (freg1*2),
length_of(opprec));
i += _fp_new_inst_store(&newcode[i], gi, rx, instr);
+ newcode[i++] = RTi_SYNC;
if (rx != byteval_of(gi, arg)) fp_free_genr(gi, rx);
break;
***************
*** 570,575 ****
--- 571,578 ----
(freg1*2), (freg2*2),
length_of(opprec));
i += _fp_new_inst_store(&newcode[i], gi, rx, instr);
+ if ((arg1type == ADDRTYPE) || (arg1type == IMMEDTYPE))
+ newcode[i++] = RTi_SYNC;
if ((arg1type != GREGTYPE) && (rx != arg1byte))
fp_free_genr(gi, rx);
***************
*** 584,589 ****
--- 587,594 ----
(freg1*2), (freg2*2),
length_of(opprec));
i += _fp_new_inst_store(&newcode[i], gi, rx, instr);
+ if ((arg2type == ADDRTYPE) || (arg2type == IMMEDTYPE))
+ newcode[i++] = RTi_SYNC;
if ((arg2type != GREGTYPE) && (rx != arg2byte))
fp_free_genr(gi, rx);
***************
*** 732,737 ****
--- 737,743 ----
}
instr = fpa2DMAread(first_savef,N_WORDS);
icode += _fp_new_inst_store(&newcode[icode], gi, basereg, instr);
+ newcode[icode++] = RTi_SYNC;
fp_free_genr(gi, rx);
***************
*** 793,798 ****
--- 799,805 ----
current_freg >>= 1; /* advance to next freg */
} /* end for */
+ newcode[icode++] = RTi_SYNC;
fp_free_genr(gi, rx);
return(icode);
=====----- Mark S. Lewis, IBM AWD Palo Alto -----======
inet: mlewis%ibmsupt@uunet.uu.net (415) 855-4486
uucp: uunet!ibmsupt!mlewis IBM Tie Line: 465-4486