Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F154164593
D17526.id49040.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D17526.id49040.diff
View Options
Index: sys/amd64/amd64/support.S
===================================================================
--- sys/amd64/amd64/support.S
+++ sys/amd64/amd64/support.S
@@ -446,14 +446,27 @@
.endif
.endm
+.macro COPYINOUT_BEGIN
+.endm
+
+.macro COPYINOUT_END
+ movq %rax,PCB_ONFAULT(%r11)
+ POP_FRAME_POINTER
+.endm
+
+.macro COPYINOUT_SMAP_END
+ SMAP_ENABLE smap=1
+ COPYINOUT_END
+.endm
+
/*
* copyout(from_kernel, to_user, len)
* %rdi, %rsi, %rdx
*/
.macro COPYOUT smap erms
PUSH_FRAME_POINTER
- movq PCPU(CURPCB),%r9
- movq $copy_fault,PCB_ONFAULT(%r9)
+ movq PCPU(CURPCB),%r11
+ movq $copy_fault,PCB_ONFAULT(%r11)
/*
* Check explicitly for non-user addresses. If 486 write protection
@@ -479,43 +492,27 @@
ja copy_fault
/*
- * Set up arguments for rep movs*.
+ * Set return value to zero. Remaining failure mode goes through
+ * copy_fault.
+ */
+ xorl %eax,%eax
+
+ /*
+ * Set up arguments for MEMMOVE.
*/
movq %rdi,%r8
movq %rsi,%rdi
movq %r8,%rsi
movq %rdx,%rcx
- /*
- * Set return value to zero. Remaining failure mode goes through
- * copy_fault.
- */
- xorl %eax,%eax
SMAP_DISABLE \smap
-.if \erms == 0
- cmpq $15,%rcx
- jbe 1f
- shrq $3,%rcx
- rep
- movsq
- movb %dl,%cl
- andb $7,%cl
- jne 1f
- SMAP_ENABLE \smap
- movq %rax,PCB_ONFAULT(%r9)
- POP_FRAME_POINTER
- ret
- ALIGN_TEXT
-1:
+.if \smap == 1
+ MEMMOVE erms=\erms overlap=0 begin=COPYINOUT_BEGIN end=COPYINOUT_SMAP_END
+.else
+ MEMMOVE erms=\erms overlap=0 begin=COPYINOUT_BEGIN end=COPYINOUT_END
.endif
- rep
- movsb
-
- SMAP_ENABLE \smap
- movq %rax,PCB_ONFAULT(%r9)
- POP_FRAME_POINTER
- ret
+ /* NOTREACHED */
.endm
ENTRY(copyout_nosmap_std)
@@ -540,8 +537,8 @@
*/
.macro COPYIN smap erms
PUSH_FRAME_POINTER
- movq PCPU(CURPCB),%r9
- movq $copy_fault,PCB_ONFAULT(%r9)
+ movq PCPU(CURPCB),%r11
+ movq $copy_fault,PCB_ONFAULT(%r11)
/*
* make sure address is valid
@@ -553,37 +550,20 @@
cmpq %rcx,%rax
ja copy_fault
+ xorl %eax,%eax
+
movq %rdi,%r8
movq %rsi,%rdi
movq %r8,%rsi
movq %rdx,%rcx
- xorl %eax,%eax
-
SMAP_DISABLE \smap
-.if \erms == 0
- cmpq $15,%rcx
- jbe 1f
- shrq $3,%rcx /* copy longword-wise */
- rep
- movsq
- movb %dl,%cl
- andb $7,%cl /* copy remaining bytes */
- jne 1f
- SMAP_ENABLE \smap
- movq %rax,PCB_ONFAULT(%r9)
- POP_FRAME_POINTER
- ret
- ALIGN_TEXT
-1:
+.if \smap == 1
+ MEMMOVE erms=\erms overlap=0 begin=COPYINOUT_BEGIN end=COPYINOUT_SMAP_END
+.else
+ MEMMOVE erms=\erms overlap=0 begin=COPYINOUT_BEGIN end=COPYINOUT_END
.endif
- rep
- movsb
-
- SMAP_ENABLE \smap
- movq %rax,PCB_ONFAULT(%r9)
- POP_FRAME_POINTER
- ret
+ /* NOTREACHED */
.endm
ENTRY(copyin_nosmap_std)
@@ -605,7 +585,7 @@
ALIGN_TEXT
/* Trap entry clears PSL.AC */
copy_fault:
- movq $0,PCB_ONFAULT(%r9)
+ movq $0,PCB_ONFAULT(%r11)
movl $EFAULT,%eax
POP_FRAME_POINTER
ret
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 27, 6:04 PM (4 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32234394
Default Alt Text
D17526.id49040.diff (2 KB)
Attached To
Mode
D17526: amd64: employ MEMMOVE in copyin/copyout
Attached
Detach File
Event Timeline
Log In to Comment