From 8e1e89f01bbc54ea8521df59192705d0c1393541 Mon Sep 17 00:00:00 2001 From: kib Date: Sat, 7 Aug 2010 11:57:13 +0000 Subject: Prefer struct sysentvec sv_psstrings to hardcoding FREEBSD32_PS_STRINGS in the compat32 code. Use sv_usrstack instead of FREEBSD32_USRSTACK as well. MFC after: 1 week --- sys/amd64/ia32/ia32_signal.c | 4 ++-- sys/compat/freebsd32/freebsd32_misc.c | 3 ++- sys/ia64/ia32/ia32_signal.c | 16 +++++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/sys/amd64/ia32/ia32_signal.c b/sys/amd64/ia32/ia32_signal.c index a218ff2..d85a3bb 100644 --- a/sys/amd64/ia32/ia32_signal.c +++ b/sys/amd64/ia32/ia32_signal.c @@ -391,7 +391,7 @@ freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) } regs->tf_rsp = (uintptr_t)sfp; - regs->tf_rip = FREEBSD32_PS_STRINGS - sz_freebsd4_ia32_sigcode; + regs->tf_rip = p->p_sysent->sv_psstrings - sz_freebsd4_ia32_sigcode; regs->tf_rflags &= ~(PSL_T | PSL_D); regs->tf_cs = _ucode32sel; regs->tf_ss = _udatasel; @@ -512,7 +512,7 @@ ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) } regs->tf_rsp = (uintptr_t)sfp; - regs->tf_rip = FREEBSD32_PS_STRINGS - *(p->p_sysent->sv_szsigcode); + regs->tf_rip = p->p_sysent->sv_psstrings - *(p->p_sysent->sv_szsigcode); regs->tf_rflags &= ~(PSL_T | PSL_D); regs->tf_cs = _ucode32sel; regs->tf_ss = _udatasel; diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index 153a2c7..579d81b 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -2541,7 +2541,8 @@ freebsd32_copyout_strings(struct image_params *imgp) execpath_len = strlen(imgp->execpath) + 1; else execpath_len = 0; - arginfo = (struct freebsd32_ps_strings *)FREEBSD32_PS_STRINGS; + arginfo = (struct freebsd32_ps_strings *)curproc->p_sysent-> + sv_psstrings; szsigcode = *(imgp->proc->p_sysent->sv_szsigcode); destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE - roundup(execpath_len, sizeof(char *)) - diff --git a/sys/ia64/ia32/ia32_signal.c b/sys/ia64/ia32/ia32_signal.c index e5eee41..e41f0af 100644 --- a/sys/ia64/ia32/ia32_signal.c +++ b/sys/ia64/ia32/ia32_signal.c @@ -128,7 +128,9 @@ ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack) u_int64_t codeseg, dataseg, gdtseg, ldtseg; struct segment_descriptor desc; struct vmspace *vmspace = td->td_proc->p_vmspace; + struct sysentvec *sv; + sv = td->td_proc->p_sysent; exec_setregs(td, imgp, stack); /* Non-syscall frames are cleared by exec_setregs() */ @@ -142,7 +144,7 @@ ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack) tf->tf_special.sp = stack; /* Point the RSE backstore to something harmless. */ - tf->tf_special.bspstore = (FREEBSD32_PS_STRINGS - sz_ia32_sigcode - + tf->tf_special.bspstore = (sv->sv_psstrings - sz_ia32_sigcode - SPARE_USRSPACE + 15) & ~15; codesel = LSEL(LUCODE_SEL, SEL_UPL); @@ -157,7 +159,7 @@ ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack) /* * Build the GDT and LDT. */ - gdt = FREEBSD32_USRSTACK; + gdt = sv->sv_usrstack; 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; @@ -173,12 +175,12 @@ ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack) desc.sd_hibase = ldt >> 24; copyout(&desc, (caddr_t) gdt + 8*GLDT_SEL, sizeof(desc)); - desc.sd_lolimit = ((FREEBSD32_USRSTACK >> 12) - 1) & 0xffff; + desc.sd_lolimit = ((sv->sv_usrstack >> 12) - 1) & 0xffff; desc.sd_lobase = 0; desc.sd_type = SDT_MEMERA; desc.sd_dpl = SEL_UPL; desc.sd_p = 1; - desc.sd_hilimit = ((FREEBSD32_USRSTACK >> 12) - 1) >> 16; + desc.sd_hilimit = ((sv->sv_usrstack >> 12) - 1) >> 16; desc.sd_def32 = 1; desc.sd_gran = 1; desc.sd_hibase = 0; @@ -187,14 +189,14 @@ ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack) copyout(&desc, (caddr_t) ldt + 8*LUDATA_SEL, sizeof(desc)); codeseg = 0 /* base */ - + (((FREEBSD32_USRSTACK >> 12) - 1) << 32) /* limit */ + + (((sv->sv_usrstack >> 12) - 1) << 32) /* limit */ + ((long)SDT_MEMERA << 52) + ((long)SEL_UPL << 57) + (1L << 59) /* present */ + (1L << 62) /* 32 bits */ + (1L << 63); /* page granularity */ dataseg = 0 /* base */ - + (((FREEBSD32_USRSTACK >> 12) - 1) << 32) /* limit */ + + (((sv->sv_usrstack >> 12) - 1) << 32) /* limit */ + ((long)SDT_MEMRWA << 52) + ((long)SEL_UPL << 57) + (1L << 59) /* present */ @@ -231,7 +233,7 @@ ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack) ia64_set_eflag(PSL_USER); /* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */ - tf->tf_scratch.gr11 = FREEBSD32_PS_STRINGS; + tf->tf_scratch.gr11 = td->td_proc->p_sysent->sv_psstrings; /* * XXX - Linux emulator -- cgit v1.1