diff options
author | Tom Cosgrove <tom@cvs.openbsd.org> | 2007-05-29 23:02:03 +0000 |
---|---|---|
committer | Tom Cosgrove <tom@cvs.openbsd.org> | 2007-05-29 23:02:03 +0000 |
commit | 4142e42ef390d2ccf270d89472ed05cdc4bf3e18 (patch) | |
tree | 0de81e0fc2bfa614be19936f7a9bb411a3164f59 | |
parent | 9249900025fb71e4cb52e5135bf3709c87e6a550 (diff) |
Improve copyinstr and copyoutstr by performing the check against
VM_MAXUSER_ADDRESS before running the loop rather than for every
byte we copy. Saves 4 bytes in locore :)
Similar to how this is done on amd64.
ok weingart@ art@
-rw-r--r-- | sys/arch/i386/i386/locore.s | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index 559bf5d09d2..5a39b580a5c 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.113 2007/05/29 18:18:20 tom Exp $ */ +/* $OpenBSD: locore.s,v 1.114 2007/05/29 23:02:02 tom Exp $ */ /* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */ /*- @@ -1083,6 +1083,10 @@ ENTRY(copyoutstr) */ movl $VM_MAXUSER_ADDRESS,%eax subl %edi,%eax + jbe _C_LABEL(copystr_fault) # die if CF == 1 || ZF == 1 + # i.e. make sure that %edi + # is below VM_MAXUSER_ADDRESS + cmpl %edx,%eax jae 1f movl %eax,%edx @@ -1093,8 +1097,6 @@ ENTRY(copyoutstr) 1: decl %edx jz 2f - cmpl $VM_MAXUSER_ADDRESS,%edi - jae _C_LABEL(copystr_fault) lodsb stosb testb %al,%al @@ -1137,6 +1139,9 @@ ENTRY(copyinstr) */ movl $VM_MAXUSER_ADDRESS,%eax subl %esi,%eax + jbe _C_LABEL(copystr_fault) # Error if CF == 1 || ZF == 1 + # i.e. make sure that %esi + # is below VM_MAXUSER_ADDRESS cmpl %edx,%eax jae 1f movl %eax,%edx @@ -1147,8 +1152,6 @@ ENTRY(copyinstr) 1: decl %edx jz 2f - cmpl $VM_MAXUSER_ADDRESS,%esi - jae _C_LABEL(copystr_fault) lodsb stosb testb %al,%al |