From 642012a299ae4cd97f97b1192c27a5c68a171d9f Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Thu, 24 Nov 2005 03:54:38 +0000 Subject: [PATCH] ppc32 only: clarify meaning of second arg of VG_(mk_SysRes_ppc32_linux) and fix an inconsistent use of it, from m_signals. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5231 --- coregrind/m_signals.c | 10 ++++++---- coregrind/m_syscall.c | 14 ++++++++------ coregrind/pub_core_syscall.h | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c index 9dcf1879fe..2b4d23c8a1 100644 --- a/coregrind/m_signals.c +++ b/coregrind/m_signals.c @@ -155,10 +155,12 @@ typedef struct SigQueue { # define VG_UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.mc_gregs[1]) # define VG_UCONTEXT_FRAME_PTR(uc) ((uc)->uc_mcontext.mc_gregs[1]) # define VG_UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.mc_gregs[0]) -# define VG_UCONTEXT_SYSCALL_SYSRES(uc) \ - /* Convert the values in uc_mcontext r3,cr into a SysRes. */ \ - VG_(mk_SysRes_ppc32_linux)( (uc)->uc_mcontext.mc_gregs[3], \ - (uc)->uc_mcontext.mc_gregs[VKI_PT_CCR] ) +# define VG_UCONTEXT_SYSCALL_SYSRES(uc) \ + /* Convert the values in uc_mcontext r3,cr into a SysRes. */ \ + VG_(mk_SysRes_ppc32_linux)( \ + (uc)->uc_mcontext.mc_gregs[3], \ + (((uc)->uc_mcontext.mc_gregs[VKI_PT_CCR] >> 28) & 1) \ + ) # define VG_UCONTEXT_LINK_REG(uc) ((uc)->uc_mcontext.mc_gregs[VKI_PT_LNK]) #else diff --git a/coregrind/m_syscall.c b/coregrind/m_syscall.c index fa94a4b856..af90517293 100644 --- a/coregrind/m_syscall.c +++ b/coregrind/m_syscall.c @@ -70,9 +70,10 @@ SysRes VG_(mk_SysRes_amd64_linux) ( Word val ) { } /* PPC uses the CR7.SO bit to flag an error (CR0 in IBM-speke) */ -SysRes VG_(mk_SysRes_ppc32_linux) ( UInt val, UInt errflag ) { +/* Note this must be in the bottom bit of the second arg */ +SysRes VG_(mk_SysRes_ppc32_linux) ( UInt val, UInt cr0so ) { SysRes res; - res.isError = errflag != 0; + res.isError = (cr0so & 1) != 0; res.val = val; return res; } @@ -167,13 +168,14 @@ asm( ".previous\n" ); #elif defined(VGP_ppc32_linux) -/* Incoming args (syscall number + up to 6 args) come in %r0, %r3:%r8 +/* Incoming args (syscall number + up to 6 args) come in %r3:%r9. The syscall number goes in %r0. The args are passed to the syscall in the regs %r3:%r8, i.e. the kernel's syscall calling convention. The %cr0.so bit flags an error. - We return the syscall return value in %r3, and the %cr in %r4. + We return the syscall return value in %r3, and the %cr0.so in + the lowest bit of %r4. We return a ULong, of which %r3 is the high word, and %r4 the low. No callee-save regs are clobbered, so no saving/restoring is needed. */ @@ -214,8 +216,8 @@ SysRes VG_(do_syscall) ( UWord sysno, UWord a1, UWord a2, UWord a3, #elif defined(VGP_ppc32_linux) ULong ret = do_syscall_WRK(sysno,a1,a2,a3,a4,a5,a6); UInt val = (UInt)(ret>>32); - UInt errflag = (UInt)(ret); - return VG_(mk_SysRes_ppc32_linux)( val, errflag ); + UInt cr0so = (UInt)(ret); + return VG_(mk_SysRes_ppc32_linux)( val, cr0so ); #else # error Unknown platform #endif diff --git a/coregrind/pub_core_syscall.h b/coregrind/pub_core_syscall.h index d6be42804f..f5c7628192 100644 --- a/coregrind/pub_core_syscall.h +++ b/coregrind/pub_core_syscall.h @@ -63,7 +63,7 @@ extern SysRes VG_(do_syscall) ( UWord sysno, extern SysRes VG_(mk_SysRes_x86_linux) ( Word val ); extern SysRes VG_(mk_SysRes_amd64_linux) ( Word val ); -extern SysRes VG_(mk_SysRes_ppc32_linux) ( UInt val, UInt errflag ); +extern SysRes VG_(mk_SysRes_ppc32_linux) ( UInt val, UInt cr0so ); extern SysRes VG_(mk_SysRes_Error) ( UWord val ); extern SysRes VG_(mk_SysRes_Success) ( UWord val ); -- 2.47.2