untrusted comment: signature from openbsd 6.0 base secret key
RWSho3oKSqgLQ8qux8rz3eB2vYfGGBp/WEBKuVcfHufa00nR7p6V4CY/PXEgdDI9ppw8n4LLVaLAQGdoP1yAZ8bxfyVE9kIzLgI=
OpenBSD 6.0 errata 044, October 4th, 2017:
Correctly handle exceptions when restoring an invalid FPU context.
This is the second revision of the patch.
And then rebuild and install a new kernel:
cd /usr/src/sys/arch/`machine`/conf
KK=`sysctl -n kern.osversion | cut -d# -f1`
config $KK
cd ../compile/$KK
make
make install
+void xrstor_user(struct savefpu *_addr, uint64_t _mask);
+
/*
* We do lazy initialization and switching using the TS bit in cr0 and the
* MDP_USEDFPU bit in mdproc.
@@ -285,7 +287,7 @@ fpudna(struct cpu_info *ci)
p->p_md.md_flags |= MDP_USEDFPU;
} else {
if (xsave_mask) {
- xrstor(sfp, xsave_mask);
+ xrstor_user(sfp, xsave_mask);
} else {
static double zero = 0.0;
case T_PROTFLT:
+ /*
+ * Check for xrstor faulting because of invalid xstate
+ * We do this by looking at the address of the
+ * instruction that faulted.
+ */
+ if (frame->tf_rip == (u_int64_t)xrstor_fault && p != NULL) {
+ fpusave_proc(p, 0);
+ goto user_trap;
+ }
case T_SEGNPFLT:
case T_ALIGNFLT:
case T_TSSFLT:
@@ -252,6 +261,7 @@ copyfault:
case T_SEGNPFLT|T_USER:
case T_STKFLT|T_USER:
case T_NMI|T_USER:
+user_trap:
#ifdef TRAP_SIGDEBUG
printf("pid %d (%s): BUS at rip %lx addr %lx\n",
p->p_pid, p->p_comm, frame->tf_rip, rcr2());