Use the MI macro TRAPF_USERMODE() instead of open-coded checks for
authorbde <bde@FreeBSD.org>
Wed, 14 Sep 2016 12:57:40 +0000 (12:57 +0000)
committerbde <bde@FreeBSD.org>
Wed, 14 Sep 2016 12:57:40 +0000 (12:57 +0000)
commitd58cd5baa4f8a9edaf4823357b0db1f8e8d15ac8
tree7878596e08e9b7762cfba698c65839c095bdeae7
parent386ddae58459341ec567604707805814a2128a57
Use the MI macro TRAPF_USERMODE() instead of open-coded checks for
SEL_UPL and sometimes PSL_VM.  This is just a style change on amd64,
but on i386 it fixes 1 unimportant place where the PSL_VM check was
missing and starts fixing 1 important place where the PSL_VM check
had a logic error.

Fix logic errors in treating vm86 bioscall mode as kernel mode.  The
main place checked all the necessary flags, but put the necessary
parentheses for the PSL_VM and PCB_VM86CALL checks in the wrong
place.  The broken case is only reached if a vm86 bioscall uses a
%cs which is nonzero mod 4, but that is unusual -- most bios calls
start with %cs = 0xc000 or 0xf000 and rarely change it.  Another
place was missing the check for PCB_VM86CALL, but was only reachable
if there are bugs virtualizing PSL_I.

Add a macro TF_HAS_STACKREGS() and use this instead of converting
open-coded checks of SEL_UPL, etc. to TRAPF_USERMODE() when we only
care about whether the frame has stack registers.  This fixes 3
places in my recent fix for register variables in vm86 mode where I
messed up the PSL_VM check and cleans up other places.
sys/amd64/amd64/trap.c
sys/i386/i386/db_trace.c
sys/i386/i386/trap.c
sys/x86/include/frame.h