Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Feb 2010 14:17:23 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r204197 - head/sys/powerpc/aim
Message-ID:  <201002221417.o1MEHNju067259@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Mon Feb 22 14:17:23 2010
New Revision: 204197
URL: http://svn.freebsd.org/changeset/base/204197

Log:
  Allow user programs to execute mfpvr instructions. Linux allows this, and
  some math-related software like GMP expects to be able to use it to pick
  a target appropriately.
  
  MFC after:	1 week

Modified:
  head/sys/powerpc/aim/trap.c

Modified: head/sys/powerpc/aim/trap.c
==============================================================================
--- head/sys/powerpc/aim/trap.c	Mon Feb 22 14:12:23 2010	(r204196)
+++ head/sys/powerpc/aim/trap.c	Mon Feb 22 14:17:23 2010	(r204197)
@@ -82,6 +82,7 @@ static void	printtrap(u_int vector, stru
 		    int user);
 static int	trap_pfault(struct trapframe *frame, int user);
 static int	fix_unaligned(struct thread *td, struct trapframe *frame);
+static int	ppc_instr_emulate(struct trapframe *frame);
 static int	handle_onfault(struct trapframe *frame);
 static void	syscall(struct trapframe *frame);
 
@@ -209,7 +210,9 @@ trap(struct trapframe *frame)
 			/* Identify the trap reason */
 			if (frame->srr1 & EXC_PGM_TRAP)
 				sig = SIGTRAP;
- 			else
+ 			else if (ppc_instr_emulate(frame) == 0)
+				frame->srr0 += 4;
+			else
 				sig = SIGILL;
 			break;
 
@@ -615,3 +618,21 @@ fix_unaligned(struct thread *td, struct 
 
 	return -1;
 }
+
+static int
+ppc_instr_emulate(struct trapframe *frame)
+{
+	uint32_t instr;
+	int reg;
+
+	instr = fuword32((void *)frame->srr0);
+
+	if ((instr & 0xfc1fffff) == 0x7c1f42a6) {	/* mfpvr */
+		reg = (instr & ~0xfc1fffff) >> 21;
+		frame->fixreg[reg] = mfpvr();
+		return (0);
+	}
+
+	return (-1);
+}
+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002221417.o1MEHNju067259>