socsvn commit: r269496 - soc2014/op/freebsd-base/sys/i386/i386

op at FreeBSD.org op at FreeBSD.org
Fri Jun 13 00:34:35 UTC 2014


Author: op
Date: Fri Jun 13 00:34:34 2014
New Revision: 269496
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=269496

Log:
  SMAP i386: added stac and clac to funtions which live in support.s and interacted with user-space
  
  git: https://github.com/opntr/opBSD/commits/op/gsoc2014/smap
  
  Signed-off-by: Oliver Pinter <oliver.pntr at gmail.com>
  
  

Modified:
  soc2014/op/freebsd-base/sys/i386/i386/support.s

Modified: soc2014/op/freebsd-base/sys/i386/i386/support.s
==============================================================================
--- soc2014/op/freebsd-base/sys/i386/i386/support.s	Thu Jun 12 23:36:15 2014	(r269495)
+++ soc2014/op/freebsd-base/sys/i386/i386/support.s	Fri Jun 13 00:34:34 2014	(r269496)
@@ -269,6 +269,10 @@
  * These routines set curpcb->pcb_onfault for the time they execute. When a
  * protection violation occurs inside the functions, the trap handler
  * returns to *curpcb->pcb_onfault instead of the function.
+ *
+ * Warning: when Intel SMAP are enabled on CPU, the EFLAGS.AC bit gets
+ * cleared before reaches the fault handler.
+ */
  */
 
 /*
@@ -313,12 +317,16 @@
 
 	shrl	$2,%ecx
 	cld
+	stac					/* open user-space */
 	rep
 	movsl
+	clac					/* close user-space */
 	movb	%bl,%cl
 	andb	$3,%cl
+	stac					/* open user-space */
 	rep
 	movsb
+	clac					/* close user-space */
 
 done_copyout:
 	popl	%ebx
@@ -332,6 +340,9 @@
 
 	ALIGN_TEXT
 copyout_fault:
+	/*
+	 * WARNING: on fault EFLAGS.AC gets cleared by Intel SMAP if available
+	 */
 	popl	%ebx
 	popl	%edi
 	popl	%esi
@@ -364,12 +375,16 @@
 	movb	%cl,%al
 	shrl	$2,%ecx				/* copy longword-wise */
 	cld
+	stac					/* open user-space */
 	rep
 	movsl
+	clac					/* close user-space */
 	movb	%al,%cl
 	andb	$3,%cl				/* copy remaining bytes */
+	stac					/* open user-space */
 	rep
 	movsb
+	clac					/* close user-space */
 
 	popl	%edi
 	popl	%esi
@@ -381,6 +396,9 @@
 
 	ALIGN_TEXT
 copyin_fault:
+	/*
+	 * WARNING: on fault EFLAGS.AC gets cleared by Intel SMAP if available
+	 */
 	popl	%edi
 	popl	%esi
 	movl	PCPU(CURPCB),%edx
@@ -406,7 +424,9 @@
 #ifdef SMP
 	lock
 #endif
+	stac					/* open user-space */
 	cmpxchgl %ecx,(%edx)			/* Compare and set. */
+	clac					/* close user-space */
 
 	/*
 	 * The old value is in %eax.  If the store succeeded it will be the
@@ -434,7 +454,9 @@
 	cmpl	$VM_MAXUSER_ADDRESS-4,%edx	/* verify address is valid */
 	ja	fusufault
 
+	stac					/* open user-space */
 	movl	(%edx),%eax
+	clac					/* close user-space */
 	movl	$0,PCB_ONFAULT(%ecx)
 	ret
 END(fuword32)
@@ -462,7 +484,9 @@
 	cmpl	$VM_MAXUSER_ADDRESS-2,%edx
 	ja	fusufault
 
+	stac					/* open user-space */
 	movzwl	(%edx),%eax
+	clac					/* close user-space */
 	movl	$0,PCB_ONFAULT(%ecx)
 	ret
 END(fuword16)
@@ -475,13 +499,18 @@
 	cmpl	$VM_MAXUSER_ADDRESS-1,%edx
 	ja	fusufault
 
+	stac					/* open user-space */
 	movzbl	(%edx),%eax
+	clac					/* close user-space */
 	movl	$0,PCB_ONFAULT(%ecx)
 	ret
 END(fubyte)
 
 	ALIGN_TEXT
 fusufault:
+	/*
+	 * WARNING: on fault EFLAGS.AC gets cleared by Intel SMAP if available
+	 */
 	movl	PCPU(CURPCB),%ecx
 	xorl	%eax,%eax
 	movl	%eax,PCB_ONFAULT(%ecx)
@@ -503,7 +532,9 @@
 	ja	fusufault
 
 	movl	8(%esp),%eax
+	stac					/* open user-space */
 	movl	%eax,(%edx)
+	clac					/* close user-space */
 	xorl	%eax,%eax
 	movl	PCPU(CURPCB),%ecx
 	movl	%eax,PCB_ONFAULT(%ecx)
@@ -520,7 +551,9 @@
 	ja	fusufault
 
 	movw	8(%esp),%ax
+	stac					/* open user-space */
 	movw	%ax,(%edx)
+	clac					/* close user-space */
 	xorl	%eax,%eax
 	movl	PCPU(CURPCB),%ecx		/* restore trashed register */
 	movl	%eax,PCB_ONFAULT(%ecx)
@@ -536,7 +569,9 @@
 	ja	fusufault
 
 	movb	8(%esp),%al
+	stac					/* open user-space */
 	movb	%al,(%edx)
+	clac					/* close user-space */
 	xorl	%eax,%eax
 	movl	PCPU(CURPCB),%ecx		/* restore trashed register */
 	movl	%eax,PCB_ONFAULT(%ecx)
@@ -580,7 +615,9 @@
 	decl	%edx
 	jz	3f
 
+	stac					/* open user-space */
 	lodsb
+	clac					/* close user-space */
 	stosb
 	orb	%al,%al
 	jnz	2b
@@ -609,7 +646,9 @@
 	movl	24(%esp),%edx
 	testl	%edx,%edx
 	jz	1f
+	stac					/* open user-space */
 	movl	%ecx,(%edx)
+	clac					/* close user-space */
 1:
 	popl	%edi
 	popl	%esi


More information about the svn-soc-all mailing list