Date: Sat, 10 May 2003 17:35:02 -0700 (PDT) From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 30929 for review Message-ID: <200305110035.h4B0Z2B7022675@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=30929 Change 30929 by marcel@marcel_nfs on 2003/05/10 17:34:36 Get ia32 emulation from the ground again. This currently only works for the break-based syscall path. The EPC-based syscall path needs explicit support. Affected files ... .. //depot/projects/ia64_epc/sys/ia64/ia32/ia32_sysvec.c#5 edit .. //depot/projects/ia64_epc/sys/ia64/ia32/ia32_util.h#2 edit Differences ... ==== //depot/projects/ia64_epc/sys/ia64/ia32/ia32_sysvec.c#5 (text+ko) ==== @@ -86,9 +86,9 @@ 0x50, /* pushl %eax */ 0xcd, 0x80, /* int $0x80 */ 0xeb, 0xfe, /* 0: jmp 0b */ - 0, 0, 0, 0 + 0 }; -static int ia32_szsigcode = sizeof(ia32_sigcode) & ~3; +static int ia32_szsigcode = sizeof(ia32_sigcode); struct sysentvec ia32_freebsd_sysvec = { SYS_MAXSYSCALL, @@ -107,8 +107,8 @@ "FreeBSD ELF", elf32_coredump, NULL, - MINSIGSTKSZ, - 4096, + IA32_MINSIGSTKSZ, + IA32_PAGE_SIZE, 0, IA32_USRSTACK, IA32_USRSTACK, @@ -147,8 +147,8 @@ */ arginfo = (struct ia32_ps_strings *)IA32_PS_STRINGS; szsigcode = *(imgp->proc->p_sysent->sv_szsigcode); - destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE - - roundup((ARG_MAX - imgp->stringspace), sizeof(char *)); + destp = (caddr_t)arginfo - szsigcode - IA32_USRSPACE - + roundup((ARG_MAX - imgp->stringspace), sizeof(char *)); /* * install sigcode @@ -187,6 +187,7 @@ /* * vectp also becomes our initial stack base */ + vectp = (void*)((uintptr_t)vectp & ~15); stack_base = vectp; stringp = imgp->stringbase; @@ -246,14 +247,21 @@ struct segment_descriptor desc; struct vmspace *vmspace = td->td_proc->p_vmspace; + /* + * Pretend we entered the kernel due to an exception so that the + * trapframe gets initialized for exit through exception_restore. + */ + frame->tf_flags = 0; + exec_setregs(td, entry, stack, ps_strings); /* - * Mark this process as using the ia32 instruction set and - * enable the high FP registers by default. + * Adjust the trapframe according to the ia32 runtime. */ frame->tf_special.psr |= IA64_PSR_IS; - frame->tf_special.psr &= ~IA64_PSR_DFH; + frame->tf_special.sp = stack; + frame->tf_special.bspstore = (IA32_PS_STRINGS - ia32_szsigcode - + IA32_USRSPACE + 15) & ~15; codesel = LSEL(LUCODE_SEL, SEL_UPL); datasel = LSEL(LUDATA_SEL, SEL_UPL); @@ -268,10 +276,9 @@ * Build the GDT and LDT. */ gdt = IA32_USRSTACK; - vm_map_find(&vmspace->vm_map, 0, 0, - &gdt, PAGE_SIZE, 0, - VM_PROT_ALL, VM_PROT_ALL, 0); - ldt = gdt + 4096; + vm_map_find(&vmspace->vm_map, 0, 0, &gdt, IA32_PAGE_SIZE << 1, 0, + VM_PROT_ALL, VM_PROT_ALL, 0); + ldt = gdt + IA32_PAGE_SIZE; desc.sd_lolimit = 8*NLDT-1; desc.sd_lobase = ldt & 0xffffff; ==== //depot/projects/ia64_epc/sys/ia64/ia32/ia32_util.h#2 (text+ko) ==== @@ -44,8 +44,11 @@ int ps_nenvstr; /* the number of environment strings */ }; -#define IA32_USRSTACK (4L*1024*1024*1024 - PAGE_SIZE) -#define IA32_PS_STRINGS (IA32_USRSTACK - sizeof(struct ia32_ps_strings)) +#define IA32_MINSIGSTKSZ 2048 +#define IA32_PAGE_SIZE 4096 +#define IA32_USRSTACK (2L*1024*1024*1024 - IA32_PAGE_SIZE*2) +#define IA32_PS_STRINGS (IA32_USRSTACK - sizeof(struct ia32_ps_strings)) +#define IA32_USRSPACE IA32_PAGE_SIZE static __inline caddr_t stackgap_init(void); static __inline void *stackgap_alloc(caddr_t *, size_t); @@ -54,7 +57,7 @@ stackgap_init() { #define szsigcode (*(curproc->p_sysent->sv_szsigcode)) - return (caddr_t)(((caddr_t)IA32_PS_STRINGS) - szsigcode - SPARE_USRSPACE); + return (((caddr_t)IA32_PS_STRINGS) - szsigcode - IA32_USRSPACE); #undef szsigcode }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305110035.h4B0Z2B7022675>