mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-20 15:24:25 +00:00
- Rename the lcall system call handler from Xsyscall to Xlcall_syscall
to be more like Xint0x80_syscall and less like c function syscall(). - Reduce code duplication between the int0x80 and lcall handlers by shuffling the elfags into the right place, saving the sizeof the instruction in tf_err and jumping into the common int0x80 code. Reviewed by: peter
This commit is contained in:
parent
f310d6cfbf
commit
631d7bf3da
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=73001
|
@ -168,10 +168,8 @@ db_nextframe(fp, ip)
|
|||
frame_type = TRAP;
|
||||
} else if (!strncmp(name, "Xresume", 7)) {
|
||||
frame_type = INTERRUPT;
|
||||
} else if (!strcmp(name, "_Xsyscall") ||
|
||||
!strcmp(name, "Xsyscall") ||
|
||||
!strcmp(name, "_Xint0x80_syscall") ||
|
||||
!strcmp(name, "Xint0x80_syscall")) {
|
||||
} else if (!strcmp(name, "Xlcall_syscall") ||
|
||||
!strcmp(name, "Xint0x80_syscall")) {
|
||||
frame_type = SYSCALL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,25 +234,11 @@ calltrap:
|
|||
* does it will release the lock prior to returning.
|
||||
*/
|
||||
SUPERALIGN_TEXT
|
||||
IDTVEC(syscall)
|
||||
pushfl /* save eflags in tf_err for now */
|
||||
subl $4,%esp /* skip over tf_trapno */
|
||||
pushal
|
||||
pushl %ds
|
||||
pushl %es
|
||||
pushl %fs
|
||||
mov $KDSEL,%ax /* switch to kernel segments */
|
||||
mov %ax,%ds
|
||||
mov %ax,%es
|
||||
mov $KPSEL,%ax
|
||||
mov %ax,%fs
|
||||
movl TF_ERR(%esp),%eax /* copy saved eflags to final spot */
|
||||
movl %eax,TF_EFLAGS(%esp)
|
||||
movl $7,TF_ERR(%esp) /* sizeof "lcall 7,0" */
|
||||
FAKE_MCOUNT(13*4(%esp))
|
||||
call _syscall
|
||||
MEXITCOUNT
|
||||
jmp _doreti
|
||||
IDTVEC(lcall_syscall)
|
||||
pushfl /* save eflags */
|
||||
popl 8(%esp) /* shuffle into tf_eflags */
|
||||
pushl $7 /* sizeof "lcall 7,0" */
|
||||
jmp syscall_with_err_pushed
|
||||
|
||||
/*
|
||||
* Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80)
|
||||
|
@ -266,7 +252,9 @@ IDTVEC(syscall)
|
|||
*/
|
||||
SUPERALIGN_TEXT
|
||||
IDTVEC(int0x80_syscall)
|
||||
subl $8,%esp /* skip over tf_trapno and tf_err */
|
||||
pushl $2 /* sizeof "int 0x80" */
|
||||
syscall_with_err_pushed:
|
||||
subl $4,%esp /* skip over tf_trapno */
|
||||
pushal
|
||||
pushl %ds
|
||||
pushl %es
|
||||
|
@ -276,7 +264,6 @@ IDTVEC(int0x80_syscall)
|
|||
mov %ax,%es
|
||||
mov $KPSEL,%ax
|
||||
mov %ax,%fs
|
||||
movl $2,TF_ERR(%esp) /* sizeof "int 0x80" */
|
||||
FAKE_MCOUNT(13*4(%esp))
|
||||
call _syscall
|
||||
MEXITCOUNT
|
||||
|
|
|
@ -234,25 +234,11 @@ calltrap:
|
|||
* does it will release the lock prior to returning.
|
||||
*/
|
||||
SUPERALIGN_TEXT
|
||||
IDTVEC(syscall)
|
||||
pushfl /* save eflags in tf_err for now */
|
||||
subl $4,%esp /* skip over tf_trapno */
|
||||
pushal
|
||||
pushl %ds
|
||||
pushl %es
|
||||
pushl %fs
|
||||
mov $KDSEL,%ax /* switch to kernel segments */
|
||||
mov %ax,%ds
|
||||
mov %ax,%es
|
||||
mov $KPSEL,%ax
|
||||
mov %ax,%fs
|
||||
movl TF_ERR(%esp),%eax /* copy saved eflags to final spot */
|
||||
movl %eax,TF_EFLAGS(%esp)
|
||||
movl $7,TF_ERR(%esp) /* sizeof "lcall 7,0" */
|
||||
FAKE_MCOUNT(13*4(%esp))
|
||||
call _syscall
|
||||
MEXITCOUNT
|
||||
jmp _doreti
|
||||
IDTVEC(lcall_syscall)
|
||||
pushfl /* save eflags */
|
||||
popl 8(%esp) /* shuffle into tf_eflags */
|
||||
pushl $7 /* sizeof "lcall 7,0" */
|
||||
jmp syscall_with_err_pushed
|
||||
|
||||
/*
|
||||
* Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80)
|
||||
|
@ -266,7 +252,9 @@ IDTVEC(syscall)
|
|||
*/
|
||||
SUPERALIGN_TEXT
|
||||
IDTVEC(int0x80_syscall)
|
||||
subl $8,%esp /* skip over tf_trapno and tf_err */
|
||||
pushl $2 /* sizeof "int 0x80" */
|
||||
syscall_with_err_pushed:
|
||||
subl $4,%esp /* skip over tf_trapno */
|
||||
pushal
|
||||
pushl %ds
|
||||
pushl %es
|
||||
|
@ -276,7 +264,6 @@ IDTVEC(int0x80_syscall)
|
|||
mov %ax,%es
|
||||
mov $KPSEL,%ax
|
||||
mov %ax,%fs
|
||||
movl $2,TF_ERR(%esp) /* sizeof "int 0x80" */
|
||||
FAKE_MCOUNT(13*4(%esp))
|
||||
call _syscall
|
||||
MEXITCOUNT
|
||||
|
|
|
@ -1417,7 +1417,7 @@ extern inthand_t
|
|||
IDTVEC(bnd), IDTVEC(ill), IDTVEC(dna), IDTVEC(fpusegm),
|
||||
IDTVEC(tss), IDTVEC(missing), IDTVEC(stk), IDTVEC(prot),
|
||||
IDTVEC(page), IDTVEC(mchk), IDTVEC(rsvd), IDTVEC(fpu), IDTVEC(align),
|
||||
IDTVEC(syscall), IDTVEC(int0x80_syscall);
|
||||
IDTVEC(lcall_syscall), IDTVEC(int0x80_syscall);
|
||||
|
||||
void
|
||||
sdtossd(sd, ssd)
|
||||
|
@ -2030,14 +2030,14 @@ init386(first)
|
|||
/* make a call gate to reenter kernel with */
|
||||
gdp = &ldt[LSYS5CALLS_SEL].gd;
|
||||
|
||||
x = (int) &IDTVEC(syscall);
|
||||
gdp->gd_looffset = x++;
|
||||
x = (int) &IDTVEC(lcall_syscall);
|
||||
gdp->gd_looffset = x;
|
||||
gdp->gd_selector = GSEL(GCODE_SEL,SEL_KPL);
|
||||
gdp->gd_stkcpy = 1;
|
||||
gdp->gd_type = SDT_SYS386CGT;
|
||||
gdp->gd_dpl = SEL_UPL;
|
||||
gdp->gd_p = 1;
|
||||
gdp->gd_hioffset = ((int) &IDTVEC(syscall)) >>16;
|
||||
gdp->gd_hioffset = x >> 16;
|
||||
|
||||
/* XXX does this work? */
|
||||
ldt[LBSDICALLS_SEL] = ldt[LSYS5CALLS_SEL];
|
||||
|
|
|
@ -112,7 +112,7 @@ static int trap_pfault __P((struct trapframe *, int, vm_offset_t));
|
|||
static void trap_fatal __P((struct trapframe *, vm_offset_t));
|
||||
void dblfault_handler __P((void));
|
||||
|
||||
extern inthand_t IDTVEC(syscall);
|
||||
extern inthand_t IDTVEC(lcall_syscall);
|
||||
|
||||
#define MAX_TRAP_MSG 28
|
||||
static char *trap_msg[] = {
|
||||
|
@ -565,7 +565,7 @@ trap(frame)
|
|||
break;
|
||||
|
||||
case T_TRCTRAP: /* trace trap */
|
||||
if (frame.tf_eip == (int)IDTVEC(syscall)) {
|
||||
if (frame.tf_eip == (int)IDTVEC(lcall_syscall)) {
|
||||
/*
|
||||
* We've just entered system mode via the
|
||||
* syscall lcall. Continue single stepping
|
||||
|
@ -574,7 +574,7 @@ trap(frame)
|
|||
*/
|
||||
goto out;
|
||||
}
|
||||
if (frame.tf_eip == (int)IDTVEC(syscall) + 1) {
|
||||
if (frame.tf_eip == (int)IDTVEC(lcall_syscall) + 1) {
|
||||
/*
|
||||
* The syscall handler has now saved the
|
||||
* flags. Stop single stepping it.
|
||||
|
|
|
@ -168,10 +168,8 @@ db_nextframe(fp, ip)
|
|||
frame_type = TRAP;
|
||||
} else if (!strncmp(name, "Xresume", 7)) {
|
||||
frame_type = INTERRUPT;
|
||||
} else if (!strcmp(name, "_Xsyscall") ||
|
||||
!strcmp(name, "Xsyscall") ||
|
||||
!strcmp(name, "_Xint0x80_syscall") ||
|
||||
!strcmp(name, "Xint0x80_syscall")) {
|
||||
} else if (!strcmp(name, "Xlcall_syscall") ||
|
||||
!strcmp(name, "Xint0x80_syscall")) {
|
||||
frame_type = SYSCALL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,25 +234,11 @@ calltrap:
|
|||
* does it will release the lock prior to returning.
|
||||
*/
|
||||
SUPERALIGN_TEXT
|
||||
IDTVEC(syscall)
|
||||
pushfl /* save eflags in tf_err for now */
|
||||
subl $4,%esp /* skip over tf_trapno */
|
||||
pushal
|
||||
pushl %ds
|
||||
pushl %es
|
||||
pushl %fs
|
||||
mov $KDSEL,%ax /* switch to kernel segments */
|
||||
mov %ax,%ds
|
||||
mov %ax,%es
|
||||
mov $KPSEL,%ax
|
||||
mov %ax,%fs
|
||||
movl TF_ERR(%esp),%eax /* copy saved eflags to final spot */
|
||||
movl %eax,TF_EFLAGS(%esp)
|
||||
movl $7,TF_ERR(%esp) /* sizeof "lcall 7,0" */
|
||||
FAKE_MCOUNT(13*4(%esp))
|
||||
call _syscall
|
||||
MEXITCOUNT
|
||||
jmp _doreti
|
||||
IDTVEC(lcall_syscall)
|
||||
pushfl /* save eflags */
|
||||
popl 8(%esp) /* shuffle into tf_eflags */
|
||||
pushl $7 /* sizeof "lcall 7,0" */
|
||||
jmp syscall_with_err_pushed
|
||||
|
||||
/*
|
||||
* Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80)
|
||||
|
@ -266,7 +252,9 @@ IDTVEC(syscall)
|
|||
*/
|
||||
SUPERALIGN_TEXT
|
||||
IDTVEC(int0x80_syscall)
|
||||
subl $8,%esp /* skip over tf_trapno and tf_err */
|
||||
pushl $2 /* sizeof "int 0x80" */
|
||||
syscall_with_err_pushed:
|
||||
subl $4,%esp /* skip over tf_trapno */
|
||||
pushal
|
||||
pushl %ds
|
||||
pushl %es
|
||||
|
@ -276,7 +264,6 @@ IDTVEC(int0x80_syscall)
|
|||
mov %ax,%es
|
||||
mov $KPSEL,%ax
|
||||
mov %ax,%fs
|
||||
movl $2,TF_ERR(%esp) /* sizeof "int 0x80" */
|
||||
FAKE_MCOUNT(13*4(%esp))
|
||||
call _syscall
|
||||
MEXITCOUNT
|
||||
|
|
|
@ -1417,7 +1417,7 @@ extern inthand_t
|
|||
IDTVEC(bnd), IDTVEC(ill), IDTVEC(dna), IDTVEC(fpusegm),
|
||||
IDTVEC(tss), IDTVEC(missing), IDTVEC(stk), IDTVEC(prot),
|
||||
IDTVEC(page), IDTVEC(mchk), IDTVEC(rsvd), IDTVEC(fpu), IDTVEC(align),
|
||||
IDTVEC(syscall), IDTVEC(int0x80_syscall);
|
||||
IDTVEC(lcall_syscall), IDTVEC(int0x80_syscall);
|
||||
|
||||
void
|
||||
sdtossd(sd, ssd)
|
||||
|
@ -2030,14 +2030,14 @@ init386(first)
|
|||
/* make a call gate to reenter kernel with */
|
||||
gdp = &ldt[LSYS5CALLS_SEL].gd;
|
||||
|
||||
x = (int) &IDTVEC(syscall);
|
||||
gdp->gd_looffset = x++;
|
||||
x = (int) &IDTVEC(lcall_syscall);
|
||||
gdp->gd_looffset = x;
|
||||
gdp->gd_selector = GSEL(GCODE_SEL,SEL_KPL);
|
||||
gdp->gd_stkcpy = 1;
|
||||
gdp->gd_type = SDT_SYS386CGT;
|
||||
gdp->gd_dpl = SEL_UPL;
|
||||
gdp->gd_p = 1;
|
||||
gdp->gd_hioffset = ((int) &IDTVEC(syscall)) >>16;
|
||||
gdp->gd_hioffset = x >> 16;
|
||||
|
||||
/* XXX does this work? */
|
||||
ldt[LBSDICALLS_SEL] = ldt[LSYS5CALLS_SEL];
|
||||
|
|
|
@ -112,7 +112,7 @@ static int trap_pfault __P((struct trapframe *, int, vm_offset_t));
|
|||
static void trap_fatal __P((struct trapframe *, vm_offset_t));
|
||||
void dblfault_handler __P((void));
|
||||
|
||||
extern inthand_t IDTVEC(syscall);
|
||||
extern inthand_t IDTVEC(lcall_syscall);
|
||||
|
||||
#define MAX_TRAP_MSG 28
|
||||
static char *trap_msg[] = {
|
||||
|
@ -565,7 +565,7 @@ trap(frame)
|
|||
break;
|
||||
|
||||
case T_TRCTRAP: /* trace trap */
|
||||
if (frame.tf_eip == (int)IDTVEC(syscall)) {
|
||||
if (frame.tf_eip == (int)IDTVEC(lcall_syscall)) {
|
||||
/*
|
||||
* We've just entered system mode via the
|
||||
* syscall lcall. Continue single stepping
|
||||
|
@ -574,7 +574,7 @@ trap(frame)
|
|||
*/
|
||||
goto out;
|
||||
}
|
||||
if (frame.tf_eip == (int)IDTVEC(syscall) + 1) {
|
||||
if (frame.tf_eip == (int)IDTVEC(lcall_syscall) + 1) {
|
||||
/*
|
||||
* The syscall handler has now saved the
|
||||
* flags. Stop single stepping it.
|
||||
|
|
|
@ -153,7 +153,7 @@
|
|||
#define _Xrsvd Xrsvd
|
||||
#define _Xspuriousint Xspuriousint
|
||||
#define _Xstk Xstk
|
||||
#define _Xsyscall Xsyscall
|
||||
#define _Xlcall_syscall Xlcall_syscall
|
||||
#define _Xtss Xtss
|
||||
#define __default_ldt _default_ldt
|
||||
#define __ucodesel _ucodesel
|
||||
|
|
|
@ -112,7 +112,7 @@ static int trap_pfault __P((struct trapframe *, int, vm_offset_t));
|
|||
static void trap_fatal __P((struct trapframe *, vm_offset_t));
|
||||
void dblfault_handler __P((void));
|
||||
|
||||
extern inthand_t IDTVEC(syscall);
|
||||
extern inthand_t IDTVEC(lcall_syscall);
|
||||
|
||||
#define MAX_TRAP_MSG 28
|
||||
static char *trap_msg[] = {
|
||||
|
@ -565,7 +565,7 @@ trap(frame)
|
|||
break;
|
||||
|
||||
case T_TRCTRAP: /* trace trap */
|
||||
if (frame.tf_eip == (int)IDTVEC(syscall)) {
|
||||
if (frame.tf_eip == (int)IDTVEC(lcall_syscall)) {
|
||||
/*
|
||||
* We've just entered system mode via the
|
||||
* syscall lcall. Continue single stepping
|
||||
|
@ -574,7 +574,7 @@ trap(frame)
|
|||
*/
|
||||
goto out;
|
||||
}
|
||||
if (frame.tf_eip == (int)IDTVEC(syscall) + 1) {
|
||||
if (frame.tf_eip == (int)IDTVEC(lcall_syscall) + 1) {
|
||||
/*
|
||||
* The syscall handler has now saved the
|
||||
* flags. Stop single stepping it.
|
||||
|
|
Loading…
Reference in a new issue