Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/i386 Sync with amd64, in particular, add END()...
details: https://anonhg.NetBSD.org/src/rev/c1cd39c59f34
branches: trunk
changeset: 359056:c1cd39c59f34
user: maxv <maxv%NetBSD.org@localhost>
date: Sat Jan 27 07:45:57 2018 +0000
description:
Sync with amd64, in particular, add END() markers, don't fall through
functions, narrow the copy windows, and remove suword.
diffstat:
sys/arch/i386/i386/copy.S | 222 +++++++++++++++++++++++-----------------------
1 files changed, 111 insertions(+), 111 deletions(-)
diffs (truncated from 652 to 300 lines):
diff -r 07612312bf32 -r c1cd39c59f34 sys/arch/i386/i386/copy.S
--- a/sys/arch/i386/i386/copy.S Sat Jan 27 03:54:01 2018 +0000
+++ b/sys/arch/i386/i386/copy.S Sat Jan 27 07:45:57 2018 +0000
@@ -1,7 +1,6 @@
-/* $NetBSD: copy.S,v 1.25 2016/09/16 12:28:41 maxv Exp $ */
-/* NetBSD: locore.S,v 1.34 2005/04/01 11:59:31 yamt Exp $ */
+/* $NetBSD: copy.S,v 1.26 2018/01/27 07:45:57 maxv Exp $ */
-/*-
+/*
* Copyright (c) 1998, 2000, 2004, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
@@ -30,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-/*-
+/*
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
@@ -65,7 +64,7 @@
*/
#include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: copy.S,v 1.25 2016/09/16 12:28:41 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: copy.S,v 1.26 2018/01/27 07:45:57 maxv Exp $");
#include "assym.h"
@@ -75,8 +74,8 @@
#include <machine/cputypes.h>
#define GET_CURPCB(reg) \
- movl CPUVAR(CURLWP), reg; \
- movl L_PCB(reg), reg
+ movl CPUVAR(CURLWP),reg; \
+ movl L_PCB(reg),reg
/*
* These are arranged so that the abnormal case is a forwards
@@ -86,10 +85,10 @@
#define DEFERRED_SWITCH_CHECK \
CHECK_DEFERRED_SWITCH ; \
jnz 99f ; \
- 98:
+98:
#define DEFERRED_SWITCH_CALL \
- 99: ; \
+99: ; \
call _C_LABEL(do_pmap_load) ; \
jmp 98b
@@ -109,25 +108,26 @@
*/
NENTRY(do_pmap_load)
pushl %ebp
- movl %esp, %ebp
+ movl %esp,%ebp
pushl %ebx
- movl CPUVAR(CURLWP), %ebx
+ movl CPUVAR(CURLWP),%ebx
1:
incl L_NOPREEMPT(%ebx)
call _C_LABEL(pmap_load)
decl L_NOPREEMPT(%ebx)
jnz 2f
- cmpl $0, L_DOPREEMPT(%ebx)
+ cmpl $0,L_DOPREEMPT(%ebx)
jz 2f
pushl $0
call _C_LABEL(kpreempt)
- addl $4, %esp
+ addl $4,%esp
2:
- cmpl $0, CPUVAR(WANT_PMAPLOAD)
+ cmpl $0,CPUVAR(WANT_PMAPLOAD)
jnz 1b
popl %ebx
leave
ret
+END(do_pmap_load)
/*
* void *return_address(unsigned int level);
@@ -151,12 +151,12 @@
movl 0x4(%eax),%eax
movl $0,PCB_ONFAULT(%edx)
ret
+END(return_address)
/*
* int kcopy(const void *from, void *to, size_t len);
- * Copy len bytes, abort on fault.
+ * Copy len bytes from and to kernel memory, and abort on fault.
*/
-/* LINTSTUB: Func: int kcopy(const void *from, void *to, size_t len) */
ENTRY(kcopy)
pushl %esi
pushl %edi
@@ -206,6 +206,7 @@
popl %esi
xorl %eax,%eax
ret
+END(kcopy)
/*****************************************************************************/
@@ -219,110 +220,107 @@
* Copy len bytes into the user's address space.
* see copyout(9)
*/
-
-/* LINTSTUB: Func: int copyout(const void *kaddr, void *uaddr, size_t len) */
ENTRY(copyout)
DEFERRED_SWITCH_CHECK
pushl %esi
pushl %edi
- movl 12(%esp),%esi
- movl 16(%esp),%edi
- movl 20(%esp),%eax
-.Lcopyout_start:
- /*
- * We check that the end of the destination buffer is not past the end
- * of the user's address space.
- */
+ movl 12(%esp),%esi /* from */
+ movl 16(%esp),%edi /* to */
+ movl 20(%esp),%eax /* len */
+
movl %edi,%edx
addl %eax,%edx
jc _C_LABEL(copy_efault)
cmpl $VM_MAXUSER_ADDRESS,%edx
ja _C_LABEL(copy_efault)
+
+.Lcopyout_start:
movl %eax,%ecx
shrl $2,%ecx
rep
movsl
andl $3,%eax
- jz 1f
+ jz .Lcopyout_end
movl %eax,%ecx
rep
movsb
-1:
.Lcopyout_end:
+
popl %edi
popl %esi
xorl %eax,%eax
ret
DEFERRED_SWITCH_CALL
+END(copyout)
/*
* int copyin(const void *from, void *to, size_t len);
* Copy len bytes from the user's address space.
* see copyin(9)
*/
-
-/* LINTSTUB: Func: int copyin(const void *uaddr, void *kaddr, size_t len) */
ENTRY(copyin)
DEFERRED_SWITCH_CHECK
pushl %esi
pushl %edi
- movl 12(%esp),%esi
- movl 16(%esp),%edi
- movl 20(%esp),%eax
- /*
- * We check that the end of the source buffer is not past the end of
- * the user's address space. If it's not, then we only need to check
- * that each page is readable, and the CPU will do that for us.
- */
-.Lcopyin_start:
+ movl 12(%esp),%esi /* from */
+ movl 16(%esp),%edi /* to */
+ movl 20(%esp),%eax /* len */
+
movl %esi,%edx
addl %eax,%edx
jc _C_LABEL(copy_efault)
cmpl $VM_MAXUSER_ADDRESS,%edx
ja _C_LABEL(copy_efault)
+
+.Lcopyin_start:
movl %eax,%ecx
shrl $2,%ecx
rep
movsl
andl $3,%eax
- jz 1f
+ jz .Lcopyin_end
movl %eax,%ecx
rep
movsb
-1:
.Lcopyin_end:
+
popl %edi
popl %esi
xorl %eax,%eax
ret
DEFERRED_SWITCH_CALL
+END(copyin)
-/* LINTSTUB: Ignore */
NENTRY(copy_efault)
movl $EFAULT,%eax
+ popl %edi
+ popl %esi
+ ret
+END(copy_efault)
/*
* kcopy_fault is used by kcopy and copy_fault is used by copyin/out.
*
* they're distinguished for lazy pmap switching. see trap().
*/
-/* LINTSTUB: Ignore */
+
NENTRY(kcopy_fault)
popl %edi
popl %esi
ret
+END(kcopy_fault)
-/* LINTSTUB: Ignore */
NENTRY(copy_fault)
popl %edi
popl %esi
ret
+END(copy_fault)
-/* LINTSTUB: Ignore */
NENTRY(return_address_fault)
- movl $0,PCB_ONFAULT(%edx)
- movl $0,%eax
+ movl $0,PCB_ONFAULT(%edx)
+ movl $0,%eax
ret
+END(return_address_fault)
/*
* int copyoutstr(const void *from, void *to, size_t maxlen, size_t *lencopied);
@@ -332,16 +330,14 @@
* return 0 or EFAULT.
* see copyoutstr(9)
*/
-/* LINTSTUB: Func: int copyoutstr(const void *kaddr, void *uaddr, size_t len, size_t *done) */
ENTRY(copyoutstr)
DEFERRED_SWITCH_CHECK
pushl %esi
pushl %edi
- movl 12(%esp),%esi /* esi = from */
- movl 16(%esp),%edi /* edi = to */
- movl 20(%esp),%edx /* edx = maxlen */
-.Lcopyoutstr_start:
-5:
+ movl 12(%esp),%esi /* esi = from */
+ movl 16(%esp),%edi /* edi = to */
+ movl 20(%esp),%edx /* edx = maxlen */
+
/*
* Get min(%edx, VM_MAXUSER_ADDRESS-%edi).
*/
@@ -352,16 +348,16 @@
jae 1f
movl %eax,%edx
movl %eax,20(%esp)
-
1: incl %edx
+.Lcopyoutstr_start:
1: decl %edx
jz 2f
lodsb
stosb
testb %al,%al
+ jnz 1b
.Lcopyoutstr_end:
- jnz 1b
/* Success -- 0 byte reached. */
decl %edx
@@ -374,6 +370,7 @@
movl $ENAMETOOLONG,%eax
jmp copystr_return
DEFERRED_SWITCH_CALL
+END(copyoutstr)
/*
* int copyinstr(const void *from, void *to, size_t maxlen, size_t *lencopied);
@@ -383,7 +380,6 @@
* return 0 or EFAULT.
* see copyinstr(9)
Home |
Main Index |
Thread Index |
Old Index