svn commit: r211006 - in head/sys: amd64/ia32 compat/freebsd32 ia64/ia32

Konstantin Belousov kib at FreeBSD.org
Sat Aug 7 11:57:13 UTC 2010


Author: kib
Date: Sat Aug  7 11:57:13 2010
New Revision: 211006
URL: http://svn.freebsd.org/changeset/base/211006

Log:
  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

Modified:
  head/sys/amd64/ia32/ia32_signal.c
  head/sys/compat/freebsd32/freebsd32_misc.c
  head/sys/ia64/ia32/ia32_signal.c

Modified: head/sys/amd64/ia32/ia32_signal.c
==============================================================================
--- head/sys/amd64/ia32/ia32_signal.c	Sat Aug  7 11:53:38 2010	(r211005)
+++ head/sys/amd64/ia32/ia32_signal.c	Sat Aug  7 11:57:13 2010	(r211006)
@@ -391,7 +391,7 @@ freebsd4_ia32_sendsig(sig_t catcher, ksi
 	}
 
 	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 *
 	}
 
 	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;

Modified: head/sys/compat/freebsd32/freebsd32_misc.c
==============================================================================
--- head/sys/compat/freebsd32/freebsd32_misc.c	Sat Aug  7 11:53:38 2010	(r211005)
+++ head/sys/compat/freebsd32/freebsd32_misc.c	Sat Aug  7 11:57:13 2010	(r211006)
@@ -2541,7 +2541,8 @@ freebsd32_copyout_strings(struct image_p
 		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 *)) -

Modified: head/sys/ia64/ia32/ia32_signal.c
==============================================================================
--- head/sys/ia64/ia32/ia32_signal.c	Sat Aug  7 11:53:38 2010	(r211005)
+++ head/sys/ia64/ia32/ia32_signal.c	Sat Aug  7 11:57:13 2010	(r211006)
@@ -128,7 +128,9 @@ ia32_setregs(struct thread *td, struct i
 	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 i
 	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 i
 	/*
 	 * 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 i
 	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 i
 	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 i
 	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


More information about the svn-src-all mailing list