PERFORCE change 30940 for review

Marcel Moolenaar marcel at FreeBSD.org
Sat May 10 23:55:51 PDT 2003


http://perforce.freebsd.org/chv.cgi?CH=30940

Change 30940 by marcel at marcel_nfs on 2003/05/10 23:55:30

	o  Do not clear the frame flag as it results in an improper
	   trapframe for returning through EPC.
	o  Clear the scratch registers manually and make sure ndirty
	   is 0.
	o  While here, make the diff unreadably by s/frame/tf/ for
	   consistency.

Affected files ...

.. //depot/projects/ia64_epc/sys/ia64/ia32/ia32_sysvec.c#6 edit

Differences ...

==== //depot/projects/ia64_epc/sys/ia64/ia32/ia32_sysvec.c#6 (text+ko) ====

@@ -240,27 +240,27 @@
 static void
 ia32_setregs(struct thread *td, u_long entry, u_long stack, u_long ps_strings)
 {
-	struct trapframe *frame = td->td_frame;
+	struct trapframe *tf = td->td_frame;
 	vm_offset_t gdt, ldt;
 	u_int64_t codesel, datasel, ldtsel;
 	u_int64_t codeseg, dataseg, gdtseg, ldtseg;
 	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);
+
+	/* Non-syscall frames are cleared by exec_setregs() */
+	if (tf->tf_flags & FRAME_SYSCALL) {
+		bzero(&tf->tf_scratch, sizeof(tf->tf_scratch));
+		bzero(&tf->tf_scratch_fp, sizeof(tf->tf_scratch_fp));
+	} else
+		tf->tf_special.ndirty = 0;
 
-	exec_setregs(td, entry, stack, ps_strings);
+	tf->tf_special.psr |= IA64_PSR_IS;
+	tf->tf_special.sp = stack;
 
-	/*
-	 * Adjust the trapframe according to the ia32 runtime.
-	 */
-	frame->tf_special.psr |= IA64_PSR_IS;
-	frame->tf_special.sp = stack;
-	frame->tf_special.bspstore = (IA32_PS_STRINGS - ia32_szsigcode -
+	/* Point the RSE backstore to something harmless. */
+	tf->tf_special.bspstore = (IA32_PS_STRINGS - ia32_szsigcode -
 	    IA32_USRSPACE + 15) & ~15;
 
 	codesel = LSEL(LUCODE_SEL, SEL_UPL);
@@ -268,9 +268,9 @@
 	ldtsel = GSEL(GLDT_SEL, SEL_UPL);
 
 	/* Setup ia32 segment registers. */
-	frame->tf_scratch.gr16 = (datasel << 48) | (datasel << 32) |
+	tf->tf_scratch.gr16 = (datasel << 48) | (datasel << 32) |
 	    (datasel << 16) | datasel;
-	frame->tf_scratch.gr17 = (ldtsel << 32) | (datasel << 16) | codesel;
+	tf->tf_scratch.gr17 = (ldtsel << 32) | (datasel << 16) | codesel;
 
 	/*
 	 * Build the GDT and LDT.
@@ -319,12 +319,12 @@
 		+ (1L << 62) /* 32 bits */
 		+ (1L << 63); /* page granularity */
 
-	frame->tf_scratch.csd = codeseg;
-	frame->tf_scratch.ssd = dataseg;
-	frame->tf_scratch.gr24 = dataseg; /* ESD */
-	frame->tf_scratch.gr27 = dataseg; /* DSD */
-	frame->tf_scratch.gr28 = dataseg; /* FSD */
-	frame->tf_scratch.gr29 = dataseg; /* GSD */
+	tf->tf_scratch.csd = codeseg;
+	tf->tf_scratch.ssd = dataseg;
+	tf->tf_scratch.gr24 = dataseg; /* ESD */
+	tf->tf_scratch.gr27 = dataseg; /* DSD */
+	tf->tf_scratch.gr28 = dataseg; /* FSD */
+	tf->tf_scratch.gr29 = dataseg; /* GSD */
 
 	gdtseg = gdt		/* base */
 		+ ((8L*NGDT - 1) << 32) /* limit */
@@ -341,15 +341,15 @@
 		+ (0L << 62) /* 16 bits */
 		+ (0L << 63); /* byte granularity */
 
-	frame->tf_scratch.gr30 = ldtseg; /* LDTD */
-	frame->tf_scratch.gr31 = gdtseg; /* GDTD */
+	tf->tf_scratch.gr30 = ldtseg; /* LDTD */
+	tf->tf_scratch.gr31 = gdtseg; /* GDTD */
 
 	/* Set ia32 control registers on this processor. */
 	ia64_set_cflg(CR0_PE | CR0_PG | ((long)(CR4_XMM | CR4_FXSR) << 32));
 	ia64_set_eflag(PSL_USER);
 
 	/* PS_STRINGS value for BSD/OS binaries.  It is 0 for non-BSD/OS. */
-	frame->tf_scratch.gr11 = IA32_PS_STRINGS;
+	tf->tf_scratch.gr11 = IA32_PS_STRINGS;
 
 	/*
 	 * XXX - Linux emulator


More information about the p4-projects mailing list