aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2008-04-27 23:52:31 -0400
committerPaul Mackerras <paulus@samba.org>2008-04-29 01:57:34 -0400
commit745a14cc264b1832c638e41812e0cb04328b2db1 (patch)
tree427272e0a4a1f3df96f007b1df53b73d572ec63e /arch
parenta01e035ebb552223c03f2d9138ffc73f2d4d3965 (diff)
[POWERPC] Add fast little-endian switch system call
This adds a system call on 64-bit platforms for switching between little-endian and big-endian modes that is much faster than doing a prctl call. This system call is handled as a special case right at the start of the system call entry code, and because it is a special case, it uses a system call number which is out of the range of normal system calls, namely 0x1ebe. Measurements with lmbench on a 4.2GHz POWER6 showed no measurable change in the speed of normal system calls with this patch. Switching endianness with this new system call takes around 60ns on a 4.2GHz POWER6, compared with around 300ns to switch endian mode with a prctl. This can provide a significant performance advantage for emulators for little-endian architectures that want to switch between big-endian and little-endian mode frequently, e.g. because they are generating instructions sequences on the fly and they want to run those sequences in little-endian mode. The other thing about this system call is that it doesn't clobber as many registers as a normal system call. It only clobbers r12. Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/kernel/head_64.S11
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 215973a2c8d5..024805e1747d 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -239,6 +239,10 @@ instruction_access_slb_pSeries:
239 .globl system_call_pSeries 239 .globl system_call_pSeries
240system_call_pSeries: 240system_call_pSeries:
241 HMT_MEDIUM 241 HMT_MEDIUM
242BEGIN_FTR_SECTION
243 cmpdi r0,0x1ebe
244 beq- 1f
245END_FTR_SECTION_IFSET(CPU_FTR_REAL_LE)
242 mr r9,r13 246 mr r9,r13
243 mfmsr r10 247 mfmsr r10
244 mfspr r13,SPRN_SPRG3 248 mfspr r13,SPRN_SPRG3
@@ -253,6 +257,13 @@ system_call_pSeries:
253 rfid 257 rfid
254 b . /* prevent speculative execution */ 258 b . /* prevent speculative execution */
255 259
260/* Fast LE/BE switch system call */
2611: mfspr r12,SPRN_SRR1
262 xori r12,r12,MSR_LE
263 mtspr SPRN_SRR1,r12
264 rfid /* return to userspace */
265 b .
266
256 STD_EXCEPTION_PSERIES(0xd00, single_step) 267 STD_EXCEPTION_PSERIES(0xd00, single_step)
257 STD_EXCEPTION_PSERIES(0xe00, trap_0e) 268 STD_EXCEPTION_PSERIES(0xe00, trap_0e)
258 269