Page MenuHomeFreeBSD

D17806.id49891.diff
No OneTemporary

D17806.id49891.diff

Index: sys/powerpc/include/trap.h
===================================================================
--- sys/powerpc/include/trap.h
+++ sys/powerpc/include/trap.h
@@ -103,6 +103,9 @@
#define EXC_SPFPD 0x2f30 /* SPE Floating-point Data */
#define EXC_SPFPR 0x2f40 /* SPE Floating-point Round */
+/* POWER8 */
+#define EXC_SOFT_PATCH 0x1500 /* POWER8 Soft Patch Exception */
+
#define EXC_LAST 0x2f00 /* Last possible exception vector */
#define EXC_AST 0x3000 /* Fake AST vector */
Index: sys/powerpc/powerpc/trap.c
===================================================================
--- sys/powerpc/powerpc/trap.c
+++ sys/powerpc/powerpc/trap.c
@@ -95,6 +95,8 @@
void handle_kernel_slb_spill(int, register_t, register_t);
static int handle_user_slb_spill(pmap_t pm, vm_offset_t addr);
extern int n_slbs;
+
+static void normalize_inputs(void);
#endif
extern vm_offset_t __startkernel;
@@ -382,6 +384,12 @@
ucode = BUS_OBJERR;
break;
+#if defined(__powerpc64__) && defined(AIM)
+ case EXC_SOFT_PATCH:
+ normalize_inputs();
+ break;
+#endif
+
default:
trap_fatal(frame);
}
@@ -908,6 +916,50 @@
return (-1);
}
+
+#if defined(__powerpc64__) && defined(AIM)
+#define MSKNSHL(x, m, n) "(((" #x ") & " #m ") << " #n ")"
+#define MSKNSHR(x, m, n) "(((" #x ") & " #m ") >> " #n ")"
+
+/* xvcpsgndp instruction, built in opcode format.
+ * This can be changed to use mnemonic after a toolchain update.
+ */
+#define XVCPSGNDP(xt, xa, xb) \
+ __asm __volatile(".long (" \
+ MSKNSHL(60, 0x3f, 26) " | " \
+ MSKNSHL(xt, 0x1f, 21) " | " \
+ MSKNSHL(xa, 0x1f, 16) " | " \
+ MSKNSHL(xb, 0x1f, 11) " | " \
+ MSKNSHL(240, 0xff, 3) " | " \
+ MSKNSHR(xa, 0x20, 3) " | " \
+ MSKNSHR(xa, 0x20, 4) " | " \
+ MSKNSHR(xa, 0x20, 5) ")")
+
+/* Macros to normalize 1 or 10 VSX registers */
+#define NORM(x) XVCPSGNDP(x, x, x)
+#define NORM10(x) \
+ NORM(x ## 0); NORM(x ## 1); NORM(x ## 2); NORM(x ## 3); NORM(x ## 4); \
+ NORM(x ## 5); NORM(x ## 6); NORM(x ## 7); NORM(x ## 8); NORM(x ## 9)
+
+static void
+normalize_inputs(void)
+{
+ int msr;
+
+ /* enable VSX */
+ msr = mfmsr();
+ mtmsr(msr | PSL_FP | PSL_VEC | PSL_VSX);
+
+ NORM(0); NORM(1); NORM(2); NORM(3); NORM(4);
+ NORM(5); NORM(6); NORM(7); NORM(8); NORM(9);
+ NORM10(1); NORM10(2); NORM10(3); NORM10(4); NORM10(5);
+ NORM(60); NORM(61); NORM(62); NORM(63);
+
+ /* restore MSR */
+ isync();
+ mtmsr(msr);
+}
+#endif
#ifdef KDB
int

File Metadata

Mime Type
text/plain
Expires
Fri, Aug 28, 2:53 AM (13 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37257976
Default Alt Text
D17806.id49891.diff (2 KB)

Event Timeline