From: Jesse Larrew <jlarrew@redhat.com> Date: Tue, 2 Dec 2008 15:30:30 -0500 Subject: [ppc64] fix system calls on Cell entered with XER.SO=1 Message-id: 20081202203005.24859.26959.sendpatchset@squad5-lp1.lab.bos.redhat.com O-Subject: [PATCH RHEL5.3 BZ474196] powerpc: Fix system calls on Cell entered with XER.SO=1 Bugzilla: 474196 RH-Acked-by: Prarit Bhargava <prarit@redhat.com> RH-Acked-by: David Howells <dhowells@redhat.com> RH-Acked-by: Pete Zaitcev <zaitcev@redhat.com> RHBZ#: ====== https://bugzilla.redhat.com/show_bug.cgi?id=474196 Description: =========== This is a bugfix for the Cell B.E. architecture. 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. RHEL Version Found: ================ RHEL 5.3 kABI Status: ============ No symbols were harmed. Brew: ===== Built on all platforms. http://brewweb.devel.redhat.com/brew/taskinfo?taskID=1586612 Upstream Status: ================ Upstream in 2.6.28-rc7. Commit ab598b6680f1e74c267d1547ee352f3e1e530f89 http://www.kernel.org/pub/linux/kernel/v2.6/snapshots/patch-2.6.28-rc6-git4.log http://git.kernel.org/gitweb.cgi?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=ab598b6680f1e74c267d1547ee352f3e1e530f89 Test Status: ============ The following testcase will verify the fix: diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index 635ce3c..1616017 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -59,12 +59,18 @@ system_call_common: beq- 1f ld r1,PACAKSAVE(r13) 1: std r10,0(r1) - crclr so std r11,_NIP(r1) std r12,_MSR(r1) std r0,GPR0(r1) std r10,GPR1(r1) ACCOUNT_CPU_USER_ENTRY(r10, r11) + /* + * This "crclr so" clears CR0.SO, which is the error indication on + * return from this system call. There must be no cmp instruction + * between it and the "mfcr r9" below, otherwise if XER.SO is set, + * CR0.SO will get set, causing all system calls to appear to fail. + */ + crclr so std r2,GPR2(r1) std r3,GPR3(r1) std r4,GPR4(r1)