Module Name:    src
Committed By:   rin
Date:           Wed Jul 15 09:10:14 UTC 2020

Modified Files:
        src/sys/arch/powerpc/booke: trap.c
        src/sys/arch/powerpc/ibm4xx: trap.c

Log Message:
For booke and ibm4xx, emulate m[ft]msr in user mode, in the same
manner as oea.

Now, user process can decide by itself whether floating-point
exception triggers SIGFPE or not via fenv(3).


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/powerpc/booke/trap.c
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/powerpc/ibm4xx/trap.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/powerpc/booke/trap.c
diff -u src/sys/arch/powerpc/booke/trap.c:1.33 src/sys/arch/powerpc/booke/trap.c:1.34
--- src/sys/arch/powerpc/booke/trap.c:1.33	Wed Jul 15 07:44:34 2020
+++ src/sys/arch/powerpc/booke/trap.c	Wed Jul 15 09:10:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.33 2020/07/15 07:44:34 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.34 2020/07/15 09:10:14 rin Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.33 2020/07/15 07:44:34 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: trap.c,v 1.34 2020/07/15 09:10:14 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altivec.h"
@@ -437,10 +437,7 @@ emulate_opcode(struct trapframe *tf, ksi
 		return true;
 	}
 
-	/*
-	 * If we bothered to emulate FP, we would try to do so here.
-	 */
-	return false;
+	return emulate_mxmsr(curlwp, tf, opcode);
 }
 
 static int

Index: src/sys/arch/powerpc/ibm4xx/trap.c
diff -u src/sys/arch/powerpc/ibm4xx/trap.c:1.84 src/sys/arch/powerpc/ibm4xx/trap.c:1.85
--- src/sys/arch/powerpc/ibm4xx/trap.c:1.84	Wed Jul 15 08:48:40 2020
+++ src/sys/arch/powerpc/ibm4xx/trap.c	Wed Jul 15 09:10:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.84 2020/07/15 08:48:40 rin Exp $	*/
+/*	$NetBSD: trap.c,v 1.85 2020/07/15 09:10:14 rin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -69,7 +69,7 @@
 #define	__UFETCHSTORE_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.84 2020/07/15 08:48:40 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.85 2020/07/15 09:10:14 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -287,6 +287,7 @@ vm_signal:
 		if (rv == 0) {
 			break;
 		}
+isi:
 		KSI_INIT_TRAP(&ksi);
 		ksi.ksi_trap = EXC_ISI;
 		ksi.ksi_addr = (void *)tf->tf_srr0;
@@ -324,6 +325,20 @@ sigtrap:
 			}
 			ksi.ksi_code = TRAP_BRKPT;
 			ksi.ksi_signo = SIGTRAP;
+		} else if (tf->tf_esr & ESR_PPR) {
+			uint32_t opcode;
+
+			rv = copyin((void *)tf->tf_srr0, &opcode,
+			    sizeof(opcode));
+			if (rv)
+				goto isi;
+			if (emulate_mxmsr(l, tf, opcode)) {
+				tf->tf_srr0 += 4;
+				break;
+			}
+
+			ksi.ksi_code = ILL_PRVOPC;
+			ksi.ksi_signo = SIGILL;
 		} else {
 			pcb = lwp_getpcb(l);
 

Reply via email to