untrusted comment: signature from openbsd 6.1 base secret key
RWQEQa33SgQSEgFdJXBKKtCtqCSWRbNuGiMg8R3y15838QSYV1RoJH0464rW3C50MAjpcKkwYAboSTvq3+Tdd9ENZRmkkRWOLwI=
OpenBSD 6.1 errata 030, 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:
KK=`sysctl -n kern.osversion | cut -d# -f1`
cd /usr/src/sys/arch/`machine`/compile/$KK
make obj
make config
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.
@@ -254,7 +256,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:
@@ -251,6 +260,7 @@ copyfault:
case T_TSSFLT|T_USER:
case T_SEGNPFLT|T_USER:
case T_STKFLT|T_USER:
+user_trap:
#ifdef TRAP_SIGDEBUG
printf("pid %d (%s): %s at rip %llx addr %llx\n",
p->p_p->ps_pid, p->p_p->ps_comm, "BUS",