Some clarifications and updates for the comments, mostly retrieved

from Bruce Evans.  Trim the trailing spaces.

MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2013-06-19 05:05:16 +00:00
parent a0b9cbc8a2
commit c788f92509
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=251988
2 changed files with 50 additions and 42 deletions

View file

@ -88,10 +88,14 @@ dtrace_invop_calltrap_addr:
* error code for those traps where the cpu doesn't in order to maintain
* a consistent frame. We also push a contrived 'trap number'.
*
* The cpu does not push the general registers, we must do that, and we
* must restore them prior to calling 'iret'. The cpu adjusts the %cs and
* %ss segment registers, but does not mess with %ds, %es, or %fs. Thus we
* must load them with appropriate values for supervisor mode operation.
* The CPU does not push the general registers, so we must do that, and we
* must restore them prior to calling 'iret'. The CPU adjusts %cs and %ss
* but does not mess with %ds, %es, %gs or %fs. We swap the %gs base for
* for the kernel mode operation shortly, without changes to the selector
* loaded. Since superuser long mode works with any selectors loaded into
* segment registers other then %cs, which makes them mostly unused in long
* mode, and kernel does not reference %fs, leave them alone. The segment
* registers are reloaded on return to the usermode.
*/
MCOUNT_LABEL(user)

View file

@ -145,13 +145,14 @@ IDTVEC(xmm)
pushl $0; TRAP(T_XMMFLT)
/*
* alltraps entry point. Interrupts are enabled if this was a trap
* gate (TGT), else disabled if this was an interrupt gate (IGT).
* Note that int0x80_syscall is a trap gate. Interrupt gates are
* used by page faults, non-maskable interrupts, debug and breakpoint
* All traps except ones for syscalls jump to alltraps. If
* interrupts were enabled when the trap occurred, then interrupts
* are enabled now if the trap was through a trap gate, else
* disabled if the trap was through an interrupt gate. Note that
* int0x80_syscall is a trap gate. Interrupt gates are used by
* page faults, non-maskable interrupts, debug and breakpoint
* exceptions.
*/
SUPERALIGN_TEXT
.globl alltraps
.type alltraps,@function
@ -215,10 +216,10 @@ norm_ill:
#endif
/*
* SYSCALL CALL GATE (old entry point for a.out binaries)
* Call gate entry for syscalls (lcall 7,0).
* This is used by FreeBSD 1.x a.out executables and "old" NetBSD executables.
*
* The intersegment call has been set up to specify one dummy parameter.
*
* This leaves a place to put eflags so that the call frame can be
* converted to a trap frame. Note that the eflags is (semi-)bogusly
* pushed into (what will be) tf_err and then copied later into the
@ -246,11 +247,13 @@ IDTVEC(lcall_syscall)
jmp doreti
/*
* Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80)
* Trap gate entry for syscalls (int 0x80).
* This is used by FreeBSD ELF executables, "new" NetBSD executables, and all
* Linux executables.
*
* Even though the name says 'int0x80', this is actually a TGT (trap gate)
* rather then an IGT (interrupt gate). Thus interrupts are enabled on
* entry just as they are for a normal syscall.
* Even though the name says 'int0x80', this is actually a trap gate, not an
* interrupt gate. Thus interrupts are enabled on entry just as they are for
* a normal syscall.
*/
SUPERALIGN_TEXT
IDTVEC(int0x80_syscall)
@ -348,12 +351,13 @@ doreti_next:
/*
* PSL_VM must be checked first since segment registers only
* have an RPL in non-VM86 mode.
* ASTs can not be handled now if we are in a vm86 call.
*/
testl $PSL_VM,TF_EFLAGS(%esp) /* are we in vm86 mode? */
testl $PSL_VM,TF_EFLAGS(%esp)
jz doreti_notvm86
movl PCPU(CURPCB),%ecx
testl $PCB_VM86CALL,PCB_FLAGS(%ecx) /* are we in a vm86 call? */
jz doreti_ast /* can handle ASTS now if not */
testl $PCB_VM86CALL,PCB_FLAGS(%ecx)
jz doreti_ast
jmp doreti_exit
doreti_notvm86: