diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2015-03-13 08:13:36 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2015-03-25 06:49:44 -0400 |
commit | 3c1a3bcea945f9d59ab1fe3d319c67c0ff56100f (patch) | |
tree | 9e8e7c58195b04850ccd5e87e48c5930b137ebb3 /arch/s390/mm | |
parent | 8a5d8473dd7e2b0bc2864e34bd6836b520589fa1 (diff) |
s390/maccess: improve s390_kernel_write()
Use the sturg instruction instead of the stura instruction. This allows to
modify up to eight bytes in a row instead of only four.
For function tracer enabling and disabling this reduces the time needed to
modify the text sections by 50%, since for each mcount call site six bytes
need to be changed.
Also remove the EXTABLE entries, since calls to this function are not
supposed to fail.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/mm')
-rw-r--r-- | arch/s390/mm/maccess.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/arch/s390/mm/maccess.c b/arch/s390/mm/maccess.c index fb737e9e0683..8a993a53fcd6 100644 --- a/arch/s390/mm/maccess.c +++ b/arch/s390/mm/maccess.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Access kernel memory without faulting -- s390 specific implementation. | 2 | * Access kernel memory without faulting -- s390 specific implementation. |
3 | * | 3 | * |
4 | * Copyright IBM Corp. 2009 | 4 | * Copyright IBM Corp. 2009, 2015 |
5 | * | 5 | * |
6 | * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>, | 6 | * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>, |
7 | * | 7 | * |
@@ -18,28 +18,25 @@ | |||
18 | 18 | ||
19 | static notrace long s390_kernel_write_odd(void *dst, const void *src, size_t size) | 19 | static notrace long s390_kernel_write_odd(void *dst, const void *src, size_t size) |
20 | { | 20 | { |
21 | unsigned long count, aligned; | 21 | unsigned long aligned, offset, count; |
22 | int offset, mask; | 22 | char tmp[8]; |
23 | int rc = -EFAULT; | ||
24 | 23 | ||
25 | aligned = (unsigned long) dst & ~3UL; | 24 | aligned = (unsigned long) dst & ~7UL; |
26 | offset = (unsigned long) dst & 3; | 25 | offset = (unsigned long) dst & 7UL; |
27 | count = min_t(unsigned long, 4 - offset, size); | 26 | size = min(8UL - offset, size); |
28 | mask = (0xf << (4 - count)) & 0xf; | 27 | count = size - 1; |
29 | mask >>= offset; | ||
30 | asm volatile( | 28 | asm volatile( |
31 | " bras 1,0f\n" | 29 | " bras 1,0f\n" |
32 | " icm 0,0,0(%3)\n" | 30 | " mvc 0(1,%4),0(%5)\n" |
33 | "0: l 0,0(%1)\n" | 31 | "0: mvc 0(8,%3),0(%0)\n" |
34 | " lra %1,0(%1)\n" | 32 | " ex %1,0(1)\n" |
35 | "1: ex %2,0(1)\n" | 33 | " lg %1,0(%3)\n" |
36 | "2: stura 0,%1\n" | 34 | " lra %0,0(%0)\n" |
37 | " la %0,0\n" | 35 | " sturg %1,%0\n" |
38 | "3:\n" | 36 | : "+&a" (aligned), "+&a" (count), "=m" (tmp) |
39 | EX_TABLE(0b,3b) EX_TABLE(1b,3b) EX_TABLE(2b,3b) | 37 | : "a" (&tmp), "a" (&tmp[offset]), "a" (src) |
40 | : "+d" (rc), "+a" (aligned) | 38 | : "cc", "memory", "1"); |
41 | : "a" (mask), "a" (src) : "cc", "memory", "0", "1"); | 39 | return size; |
42 | return rc ? rc : count; | ||
43 | } | 40 | } |
44 | 41 | ||
45 | /* | 42 | /* |
@@ -50,8 +47,8 @@ static notrace long s390_kernel_write_odd(void *dst, const void *src, size_t siz | |||
50 | * | 47 | * |
51 | * This function writes to kernel memory bypassing DAT and possible page table | 48 | * This function writes to kernel memory bypassing DAT and possible page table |
52 | * write protection. It writes to the destination using the sturg instruction. | 49 | * write protection. It writes to the destination using the sturg instruction. |
53 | * Therefore we have a read-modify-write sequence: the function reads four | 50 | * Therefore we have a read-modify-write sequence: the function reads eight |
54 | * bytes from destination at a four byte boundary, modifies the bytes | 51 | * bytes from destination at an eight byte boundary, modifies the bytes |
55 | * requested and writes the result back in a loop. | 52 | * requested and writes the result back in a loop. |
56 | * | 53 | * |
57 | * Note: this means that this function may not be called concurrently on | 54 | * Note: this means that this function may not be called concurrently on |
@@ -60,12 +57,10 @@ static notrace long s390_kernel_write_odd(void *dst, const void *src, size_t siz | |||
60 | */ | 57 | */ |
61 | void notrace s390_kernel_write(void *dst, const void *src, size_t size) | 58 | void notrace s390_kernel_write(void *dst, const void *src, size_t size) |
62 | { | 59 | { |
63 | long copied = 0; | 60 | long copied; |
64 | 61 | ||
65 | while (size) { | 62 | while (size) { |
66 | copied = s390_kernel_write_odd(dst, src, size); | 63 | copied = s390_kernel_write_odd(dst, src, size); |
67 | if (copied < 0) | ||
68 | break; | ||
69 | dst += copied; | 64 | dst += copied; |
70 | src += copied; | 65 | src += copied; |
71 | size -= copied; | 66 | size -= copied; |