diff options
author | kib <kib@FreeBSD.org> | 2017-08-21 15:11:58 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2017-08-21 15:11:58 +0000 |
commit | 6d573278b42b4e6be5518e94c61416c213872aa8 (patch) | |
tree | 34da4c223ea74700ec3bd907bc6b9f9198cfd326 | |
parent | 117cc8c1ec5e8ce154269fb1357d75288a295add (diff) | |
download | FreeBSD-src-6d573278b42b4e6be5518e94c61416c213872aa8.zip FreeBSD-src-6d573278b42b4e6be5518e94c61416c213872aa8.tar.gz |
MFC r322667,r322706:
Improve i386 #UD low-level kdtrace hook.
-rw-r--r-- | sys/i386/i386/exception.s | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s index 73c67fe..b5b5a11 100644 --- a/sys/i386/i386/exception.s +++ b/sys/i386/i386/exception.s @@ -183,21 +183,29 @@ calltrap: #ifdef KDTRACE_HOOKS SUPERALIGN_TEXT IDTVEC(ill) - /* Check if there is no DTrace hook registered. */ - cmpl $0,dtrace_invop_jump_addr + /* + * Check if a DTrace hook is registered. The default (data) segment + * cannot be used for this since %ds is not known good until we + * verify that the entry was from kernel mode. + */ + cmpl $0,%ss:dtrace_invop_jump_addr je norm_ill - /* Check if this is a user fault. */ - cmpl $GSEL_KPL, 4(%esp) /* Check the code segment. */ - - /* If so, just handle it as a normal trap. */ + /* + * Check if this is a user fault. If so, just handle it as a normal + * trap. + */ + cmpl $GSEL_KPL, 4(%esp) /* Check the code segment */ jne norm_ill + testl $PSL_VM, 8(%esp) /* and vm86 mode. */ + jnz norm_ill /* * This is a kernel instruction fault that might have been caused * by a DTrace provider. */ - pushal /* Push all registers onto the stack. */ + pushal + cld /* * Set our jump address for the jump back in the event that |