From owner-svn-soc-all@FreeBSD.ORG Wed Jun 4 14:42:51 2014 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1ECA75E6 for ; Wed, 4 Jun 2014 14:42:51 +0000 (UTC) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F392D2A5C for ; Wed, 4 Jun 2014 14:42:50 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.8/8.14.8) with ESMTP id s54Egoaf061710 for ; Wed, 4 Jun 2014 14:42:50 GMT (envelope-from op@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.8/8.14.8/Submit) id s54EgoEr061706 for svn-soc-all@FreeBSD.org; Wed, 4 Jun 2014 14:42:50 GMT (envelope-from op@FreeBSD.org) Date: Wed, 4 Jun 2014 14:42:50 GMT Message-Id: <201406041442.s54EgoEr061706@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to op@FreeBSD.org using -f From: op@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r269064 - soc2014/op/freebsd-base/sys/amd64/amd64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jun 2014 14:42:51 -0000 Author: op Date: Wed Jun 4 14:42:50 2014 New Revision: 269064 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=269064 Log: SMAP AMD64: added stac and clac to funtions which live in support.S and interacted with user-space git: https://github.com/opntr/opBSD/tree/op/gsoc2014/smap Signed-off-by: Oliver Pinter Modified: soc2014/op/freebsd-base/sys/amd64/amd64/support.S Modified: soc2014/op/freebsd-base/sys/amd64/amd64/support.S ============================================================================== --- soc2014/op/freebsd-base/sys/amd64/amd64/support.S Wed Jun 4 14:42:13 2014 (r269063) +++ soc2014/op/freebsd-base/sys/amd64/amd64/support.S Wed Jun 4 14:42:50 2014 (r269064) @@ -203,6 +203,9 @@ * 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. */ /* @@ -244,12 +247,16 @@ shrq $3,%rcx cld + stac /* open user-space */ rep movsq + clac /* close user-space */ movb %dl,%cl andb $7,%cl + stac /* open user-space */ rep movsb + clac /* close user-space */ done_copyout: xorl %eax,%eax @@ -259,6 +266,9 @@ ALIGN_TEXT copyout_fault: + /* + * WARNING: on fault EFLAGS.AC gets cleared by Intel SMAP if available + */ movq PCPU(CURPCB),%rdx movq $0,PCB_ONFAULT(%rdx) movq $EFAULT,%rax @@ -290,12 +300,16 @@ movb %cl,%al shrq $3,%rcx /* copy longword-wise */ cld + stac /* open user-space */ rep movsq + clac /* close user-space */ movb %al,%cl andb $7,%cl /* copy remaining bytes */ + stac /* open user-space */ rep movsb + clac /* close user-space */ done_copyin: xorl %eax,%eax @@ -305,6 +319,9 @@ ALIGN_TEXT copyin_fault: + /* + * WARNING: on fault EFLAGS.AC gets cleared by Intel SMAP if available + */ movq PCPU(CURPCB),%rdx movq $0,PCB_ONFAULT(%rdx) movq $EFAULT,%rax @@ -324,10 +341,12 @@ ja fusufault movl %esi,%eax /* old */ + stac /* open user-space */ #ifdef SMP lock #endif cmpxchgl %edx,(%rdi) /* new = %edx */ + clac /* close user-space */ /* * The old value is in %eax. If the store succeeded it will be the @@ -353,10 +372,12 @@ ja fusufault movq %rsi,%rax /* old */ + stac /* open user-space */ #ifdef SMP lock #endif cmpxchgq %rdx,(%rdi) /* new = %rdx */ + clac /* close user-space */ /* * The old value is in %eax. If the store succeeded it will be the @@ -385,7 +406,9 @@ cmpq %rax,%rdi /* verify address is valid */ ja fusufault + stac /* open user-space */ movq (%rdi),%rax + clac /* close user-space */ movq $0,PCB_ONFAULT(%rcx) ret END(fuword64) @@ -399,7 +422,9 @@ cmpq %rax,%rdi /* verify address is valid */ ja fusufault + stac /* open user-space */ movl (%rdi),%eax + clac /* close user-space */ movq $0,PCB_ONFAULT(%rcx) ret END(fuword32) @@ -426,7 +451,9 @@ cmpq %rax,%rdi ja fusufault + stac /* open user-space */ movzwl (%rdi),%eax + clac /* close user-space */ movq $0,PCB_ONFAULT(%rcx) ret END(fuword16) @@ -439,13 +466,18 @@ cmpq %rax,%rdi ja fusufault + stac /* open user-space */ movzbl (%rdi),%eax + clac /* close user-space */ movq $0,PCB_ONFAULT(%rcx) ret END(fubyte) ALIGN_TEXT fusufault: + /* + * WARNING: on fault EFLAGS.AC gets cleared by Intel SMAP if available + */ movq PCPU(CURPCB),%rcx xorl %eax,%eax movq %rax,PCB_ONFAULT(%rcx) @@ -466,7 +498,9 @@ cmpq %rax,%rdi /* verify address validity */ ja fusufault + stac /* open user-space */ movq %rsi,(%rdi) + clac /* close user-space */ xorl %eax,%eax movq PCPU(CURPCB),%rcx movq %rax,PCB_ONFAULT(%rcx) @@ -482,7 +516,9 @@ cmpq %rax,%rdi /* verify address validity */ ja fusufault + stac /* open user-space */ movl %esi,(%rdi) + clac /* close user-space */ xorl %eax,%eax movq PCPU(CURPCB),%rcx movq %rax,PCB_ONFAULT(%rcx) @@ -497,7 +533,9 @@ cmpq %rax,%rdi /* verify address validity */ ja fusufault + stac /* open user-space */ movw %si,(%rdi) + clac /* close user-space */ xorl %eax,%eax movq PCPU(CURPCB),%rcx /* restore trashed register */ movq %rax,PCB_ONFAULT(%rcx) @@ -513,7 +551,9 @@ ja fusufault movl %esi,%eax + stac /* open user-space */ movb %al,(%rdi) + clac /* close user-space */ xorl %eax,%eax movq PCPU(CURPCB),%rcx /* restore trashed register */ movq %rax,PCB_ONFAULT(%rcx) @@ -555,7 +595,9 @@ decq %rdx jz 3f + stac /* open user-space */ lodsb + clac /* close user-space */ stosb orb %al,%al jnz 2b @@ -584,7 +626,9 @@ testq %r9,%r9 jz 1f subq %rdx,%r8 + stac /* open user-space */ movq %r8,(%r9) + clac /* close user-space */ 1: ret END(copyinstr)