Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Sep 2002 19:33:49 -0700 (PDT)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 17806 for review
Message-ID:  <200209210233.g8L2Xnkf091881@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=17806

Change 17806 by peter@peter_daintree on 2002/09/20 19:33:42

	remove vm86 process signal sending and receiving

Affected files ...

.. //depot/projects/hammer/sys/x86_64/include/psl.h#2 edit
.. //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#4 edit

Differences ...

==== //depot/projects/hammer/sys/x86_64/include/psl.h#2 (text+ko) ====

@@ -55,10 +55,10 @@
 #define	PSL_IOPL	0x00003000	/* i/o privilege level */
 #define	PSL_NT		0x00004000	/* nested task bit */
 #define	PSL_RF		0x00010000	/* resume flag bit */
-#define	PSL_VM		0x00020000	/* virtual 8086 mode bit */
+/* #define PSL_VM	0x00020000 */	/* virtual 8086 mode bit */
 #define	PSL_AC		0x00040000	/* alignment checking */
-#define	PSL_VIF		0x00080000	/* virtual interrupt enable */
-#define	PSL_VIP		0x00100000	/* virtual interrupt pending */
+/* #define PSL_VIF	0x00080000 */	/* virtual interrupt enable */
+/* #define PSL_VIP	0x00100000 */	/* virtual interrupt pending */
 #define	PSL_ID		0x00200000	/* identification bit */
 
 /*

==== //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#4 (text+ko) ====

@@ -348,35 +348,6 @@
 	PROC_UNLOCK(p);
 
 	/*
-	 * If we're a vm86 process, we want to save the segment registers.
-	 * We also change eflags to be our emulated eflags, not the actual
-	 * eflags.
-	 */
-	if (regs->tf_eflags & PSL_VM) {
-		struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
-		struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86;
-
-		sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs;
-		sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs;
-		sf.sf_uc.uc_mcontext.mc_es = tf->tf_vm86_es;
-		sf.sf_uc.uc_mcontext.mc_ds = tf->tf_vm86_ds;
-
-		if (vm86->vm86_has_vme == 0)
-			sf.sf_uc.uc_mcontext.mc_eflags =
-			    (tf->tf_eflags & ~(PSL_VIF | PSL_VIP)) |
-			    (vm86->vm86_eflags & (PSL_VIF | PSL_VIP));
-
-		/*
-		 * Clear PSL_NT to inhibit T_TSSFLT faults on return from
-		 * syscalls made by the signal handler.  This just avoids
-		 * wasting time for our lazy fixup of such faults.  PSL_NT
-		 * does nothing in vm86 mode, but vm86 programs can set it
-		 * almost legitimately in probes for old cpu types.
-		 */
-		tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP);
-	}
-
-	/*
 	 * Copy the sigframe out to the user's stack.
 	 */
 	if (copyout(&sf, sfp, sizeof(*sfp)) != 0) {
@@ -428,77 +399,40 @@
 	ucp = &uc;
 	regs = td->td_frame;
 	eflags = ucp->uc_mcontext.mc_eflags;
-	if (eflags & PSL_VM) {
-		struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs;
-		struct vm86_kernel *vm86;
+	/*
+	 * Don't allow users to change privileged or reserved flags.
+	 */
+	/*
+	 * XXX do allow users to change the privileged flag PSL_RF.
+	 * The cpu sets PSL_RF in tf_eflags for faults.  Debuggers
+	 * should sometimes set it there too.  tf_eflags is kept in
+	 * the signal context during signal handling and there is no
+	 * other place to remember it, so the PSL_RF bit may be
+	 * corrupted by the signal handler without us knowing.
+	 * Corruption of the PSL_RF bit at worst causes one more or
+	 * one less debugger trap, so allowing it is fairly harmless.
+	 */
+	if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) {
+		printf("sigreturn: eflags = 0x%x\n", eflags);
+		return (EINVAL);
+	}
 
-		/*
-		 * if pcb_ext == 0 or vm86_inited == 0, the user hasn't
-		 * set up the vm86 area, and we can't enter vm86 mode.
-		 */
-		if (td->td_pcb->pcb_ext == 0)
-			return (EINVAL);
-		vm86 = &td->td_pcb->pcb_ext->ext_vm86;
-		if (vm86->vm86_inited == 0)
-			return (EINVAL);
+	/*
+	 * Don't allow users to load a valid privileged %cs.  Let the
+	 * hardware check for invalid selectors, excess privilege in
+	 * other selectors, invalid %eip's and invalid %esp's.
+	 */
+	cs = ucp->uc_mcontext.mc_cs;
+	if (!CS_SECURE(cs)) {
+		printf("sigreturn: cs = 0x%x\n", cs);
+		trapsignal(p, SIGBUS, T_PROTFLT);
+		return (EINVAL);
+	}
 
-		/* Go back to user mode if both flags are set. */
-		if ((eflags & PSL_VIP) && (eflags & PSL_VIF))
-			trapsignal(p, SIGBUS, 0);
-
-		if (vm86->vm86_has_vme) {
-			eflags = (tf->tf_eflags & ~VME_USERCHANGE) |
-			    (eflags & VME_USERCHANGE) | PSL_VM;
-		} else {
-			vm86->vm86_eflags = eflags;	/* save VIF, VIP */
-			eflags = (tf->tf_eflags & ~VM_USERCHANGE) |
-			    (eflags & VM_USERCHANGE) | PSL_VM;
-		}
-		bcopy(&ucp->uc_mcontext.mc_fs, tf, sizeof(struct trapframe));
-		tf->tf_eflags = eflags;
-		tf->tf_vm86_ds = tf->tf_ds;
-		tf->tf_vm86_es = tf->tf_es;
-		tf->tf_vm86_fs = tf->tf_fs;
-		tf->tf_vm86_gs = ucp->uc_mcontext.mc_gs;
-		tf->tf_ds = _udatasel;
-		tf->tf_es = _udatasel;
-		tf->tf_fs = _udatasel;
-	} else {
-		/*
-		 * Don't allow users to change privileged or reserved flags.
-		 */
-		/*
-		 * XXX do allow users to change the privileged flag PSL_RF.
-		 * The cpu sets PSL_RF in tf_eflags for faults.  Debuggers
-		 * should sometimes set it there too.  tf_eflags is kept in
-		 * the signal context during signal handling and there is no
-		 * other place to remember it, so the PSL_RF bit may be
-		 * corrupted by the signal handler without us knowing.
-		 * Corruption of the PSL_RF bit at worst causes one more or
-		 * one less debugger trap, so allowing it is fairly harmless.
-		 */
-		if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) {
-			printf("sigreturn: eflags = 0x%x\n", eflags);
-	    		return (EINVAL);
-		}
-
-		/*
-		 * Don't allow users to load a valid privileged %cs.  Let the
-		 * hardware check for invalid selectors, excess privilege in
-		 * other selectors, invalid %eip's and invalid %esp's.
-		 */
-		cs = ucp->uc_mcontext.mc_cs;
-		if (!CS_SECURE(cs)) {
-			printf("sigreturn: cs = 0x%x\n", cs);
-			trapsignal(p, SIGBUS, T_PROTFLT);
-			return (EINVAL);
-		}
-
-		ret = set_fpcontext(td, &ucp->uc_mcontext);
-		if (ret != 0)
-			return (ret);
-		bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(*regs));
-	}
+	ret = set_fpcontext(td, &ucp->uc_mcontext);
+	if (ret != 0)
+		return (ret);
+	bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(*regs));
 
 	PROC_LOCK(p);
 #if defined(COMPAT_43) || defined(COMPAT_SUNOS)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209210233.g8L2Xnkf091881>