diff options
author | Paul Mackerras <paulus@samba.org> | 2008-11-30 06:49:45 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-11-30 17:40:19 -0500 |
commit | ab598b6680f1e74c267d1547ee352f3e1e530f89 (patch) | |
tree | 3b90956dfdb03c19c8fb7eed1072600c7bc3c05b /arch/powerpc/kernel | |
parent | 960cedb4e3eedec6394f224fc832c7a23f35a799 (diff) |
powerpc: Fix system calls on Cell entered with XER.SO=1
It turns out that on Cell, on a kernel with CONFIG_VIRT_CPU_ACCOUNTING
= y, if a program sets the SO (summary overflow) bit in the XER and
then does a system call, the SO bit in CR0 will be set on return
regardless of whether the system call detected an error. Since CR0.SO
is used as the error indication from the system call, this means that
all system calls appear to fail.
The reason is that the workaround for the timebase bug on Cell uses a
compare instruction. With CONFIG_VIRT_CPU_ACCOUNTING = y, the
ACCOUNT_CPU_USER_ENTRY macro reads the timebase, so we end up doing a
compare instruction, which copies XER.SO to CR0.SO. Since we were
doing this in the system call entry patch after clearing CR0.SO but
before saving the CR, this meant that the saved CR image had CR0.SO
set if XER.SO was set on entry.
This fixes it by moving the clearing of CR0.SO to after the
ACCOUNT_CPU_USER_ENTRY call in the system call entry path.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r-- | arch/powerpc/kernel/entry_64.S | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index e6d52845854f..e0bcf9354286 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S | |||
@@ -57,12 +57,18 @@ system_call_common: | |||
57 | beq- 1f | 57 | beq- 1f |
58 | ld r1,PACAKSAVE(r13) | 58 | ld r1,PACAKSAVE(r13) |
59 | 1: std r10,0(r1) | 59 | 1: std r10,0(r1) |
60 | crclr so | ||
61 | std r11,_NIP(r1) | 60 | std r11,_NIP(r1) |
62 | std r12,_MSR(r1) | 61 | std r12,_MSR(r1) |
63 | std r0,GPR0(r1) | 62 | std r0,GPR0(r1) |
64 | std r10,GPR1(r1) | 63 | std r10,GPR1(r1) |
65 | ACCOUNT_CPU_USER_ENTRY(r10, r11) | 64 | ACCOUNT_CPU_USER_ENTRY(r10, r11) |
65 | /* | ||
66 | * This "crclr so" clears CR0.SO, which is the error indication on | ||
67 | * return from this system call. There must be no cmp instruction | ||
68 | * between it and the "mfcr r9" below, otherwise if XER.SO is set, | ||
69 | * CR0.SO will get set, causing all system calls to appear to fail. | ||
70 | */ | ||
71 | crclr so | ||
66 | std r2,GPR2(r1) | 72 | std r2,GPR2(r1) |
67 | std r3,GPR3(r1) | 73 | std r3,GPR3(r1) |
68 | std r4,GPR4(r1) | 74 | std r4,GPR4(r1) |