Module Name: src
Committed By: isaki
Date: Sat Dec 28 11:09:43 UTC 2024
Modified Files:
src/sys/arch/m68k/fpe: fpu_emulate.c
Log Message:
m68k/fpe: Several bugfixes in FDBcc and FTRAPcc emulation.
In fpu_emul_type1(),
- If test_cc() returns >0, it's an error, that is an illegal instruction in
this case. So it should just return without doing anything.
By this fix, FTRAPcc with illegal cc now causes SIGILL correctly.
- In result, branch can only be 0 or -1 after that. It makes code simple.
By this cleanup, FDBcc with illegal cc now causes SIGILL correctly.
- FTRAPcc must advance PC regardless of whether the condition is met.
(although FTRAPcc does not work at this point by anothor problem)
To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/arch/m68k/fpe/fpu_emulate.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/m68k/fpe/fpu_emulate.c
diff -u src/sys/arch/m68k/fpe/fpu_emulate.c:1.43 src/sys/arch/m68k/fpe/fpu_emulate.c:1.44
--- src/sys/arch/m68k/fpe/fpu_emulate.c:1.43 Sat Dec 28 05:56:15 2024
+++ src/sys/arch/m68k/fpe/fpu_emulate.c Sat Dec 28 11:09:43 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu_emulate.c,v 1.43 2024/12/28 05:56:15 isaki Exp $ */
+/* $NetBSD: fpu_emulate.c,v 1.44 2024/12/28 11:09:43 isaki Exp $ */
/*
* Copyright (c) 1995 Gordon W. Ross
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu_emulate.c,v 1.43 2024/12/28 05:56:15 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_emulate.c,v 1.44 2024/12/28 11:09:43 isaki Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -1010,6 +1010,8 @@ fpu_emul_type1(struct fpemu *fe, struct
unsigned short sval;
branch = test_cc(fe, insn->is_word1);
+ if (branch > 0)
+ return branch;
fe->fe_fpframe->fpf_fpsr = fe->fe_fpsr;
insn->is_advance = 4;
@@ -1017,10 +1019,10 @@ fpu_emul_type1(struct fpemu *fe, struct
switch (insn->is_opcode & 070) {
case 010: /* fdbcc */
- if (branch == -1) {
+ if (branch) {
/* advance */
insn->is_advance = 6;
- } else if (!branch) {
+ } else {
/* decrement Dn and if (Dn != -1) branch */
uint16_t count = frame->f_regs[insn->is_opcode & 7];
@@ -1049,8 +1051,6 @@ fpu_emul_type1(struct fpemu *fe, struct
/* write it back */
frame->f_regs[insn->is_opcode & 7] &= 0xffff0000;
frame->f_regs[insn->is_opcode & 7] |= (uint32_t)count;
- } else { /* got a signal */
- sig = SIGFPE;
}
break;
@@ -1068,12 +1068,9 @@ fpu_emul_type1(struct fpemu *fe, struct
return SIGILL;
break;
}
+ insn->is_advance = advance;
- if (branch == 0) {
- /* no trap */
- insn->is_advance = advance;
- sig = 0;
- } else {
+ if (branch) {
/* trap */
sig = SIGFPE;
}
@@ -1088,14 +1085,8 @@ fpu_emul_type1(struct fpemu *fe, struct
if (sig) {
break;
}
- if (branch == -1 || branch == 0) {
- /* set result */
- sig = fpu_store_ea(frame, insn, &insn->is_ea,
- (char *)&branch);
- } else {
- /* got an exception */
- sig = branch;
- }
+ /* set result */
+ sig = fpu_store_ea(frame, insn, &insn->is_ea, (char *)&branch);
break;
}
return sig;