public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] powerpc: Add missing registers to clobbers list for syscalls [BZ #27623]
@ 2021-03-29 13:35 Matheus Castanho
  2021-04-01  7:40 ` Nicholas Piggin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Matheus Castanho @ 2021-03-29 13:35 UTC (permalink / raw)
  To: libc-alpha; +Cc: npiggin, tuliom, schwab

Some registers that can be clobbered by the kernel during a syscall are not
listed on the clobbers list in sysdeps/unix/sysv/linux/powerpc/sysdep.h.

For syscalls using sc:
    - XER is zeroed by the kernel on exit

For syscalls using scv:
    - XER is zeroed by the kernel on exit
    - Different from the sc case, most CR fields can be clobbered (according to
      the ELF ABI and the Linux kernel's syscall ABI for powerpc
      (linux/Documentation/powerpc/syscall64-abi.rst)

The same should apply to vsyscalls, which effectively execute a function call
but are not currently adding these registers as clobbers either.

These are likely not causing issues today, but they should be added to the
clobbers list just in case things change on the kernel side in the future.

Reported-by: Nicholas Piggin <npiggin@gmail.com>
---

Changes from v1:
  - Add XER, CR1, CR5-7 to vsyscall clobbers list

---
 sysdeps/unix/sysv/linux/powerpc/sysdep.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 6b99464e61..2f31f9177b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -56,7 +56,9 @@
        "0:"								\
        : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),        \
          "+r" (r7), "+r" (r8)						\
-       : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory");	\
+       : : "r9", "r10", "r11", "r12",					\
+           "cr0", "cr1", "cr5", "cr6", "cr7",				\
+           "xer", "lr", "ctr", "memory");				\
     __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3));		        \
     (long int) r0 & (1 << 28) ? -rval : rval;				\
   })
@@ -86,7 +88,8 @@
 	 "=&r" (r6), "=&r" (r7), "=&r" (r8)	\
        : ASM_INPUT_##nr			\
        : "r9", "r10", "r11", "r12",		\
-	 "lr", "ctr", "memory");		\
+	 "cr0", "cr1", "cr5", "cr6", "cr7",	\
+	 "xer", "lr", "ctr", "memory"); 	\
     r3;					\
   })

@@ -101,7 +104,7 @@
 	 "=&r" (r6), "=&r" (r7), "=&r" (r8)	\
        : ASM_INPUT_##nr			\
        : "r9", "r10", "r11", "r12",		\
-	 "cr0", "ctr", "memory");		\
+	 "xer", "cr0", "ctr", "memory");	\
     r0 & (1 << 28) ? -r3 : r3;			\
   })

--
2.30.2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] powerpc: Add missing registers to clobbers list for syscalls [BZ #27623]
  2021-03-29 13:35 [PATCH v2] powerpc: Add missing registers to clobbers list for syscalls [BZ #27623] Matheus Castanho
@ 2021-04-01  7:40 ` Nicholas Piggin
  2021-04-09 13:07 ` Raphael M Zinsly
  2021-04-16 11:44 ` Matheus Castanho
  2 siblings, 0 replies; 4+ messages in thread
From: Nicholas Piggin @ 2021-04-01  7:40 UTC (permalink / raw)
  To: libc-alpha, Matheus Castanho; +Cc: schwab, tuliom, Segher Boessenkool

Excerpts from Matheus Castanho's message of March 29, 2021 11:35 pm:
> Some registers that can be clobbered by the kernel during a syscall are not
> listed on the clobbers list in sysdeps/unix/sysv/linux/powerpc/sysdep.h.
> 
> For syscalls using sc:
>     - XER is zeroed by the kernel on exit
> 
> For syscalls using scv:
>     - XER is zeroed by the kernel on exit
>     - Different from the sc case, most CR fields can be clobbered (according to
>       the ELF ABI and the Linux kernel's syscall ABI for powerpc
>       (linux/Documentation/powerpc/syscall64-abi.rst)
> 
> The same should apply to vsyscalls, which effectively execute a function call
> but are not currently adding these registers as clobbers either.
> 
> These are likely not causing issues today, but they should be added to the
> clobbers list just in case things change on the kernel side in the future.
> 
> Reported-by: Nicholas Piggin <npiggin@gmail.com>

As far as I can tell, this should be matching the kernel now.

Thanks,
Nick

> ---
> 
> Changes from v1:
>   - Add XER, CR1, CR5-7 to vsyscall clobbers list
> 
> ---
>  sysdeps/unix/sysv/linux/powerpc/sysdep.h | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> index 6b99464e61..2f31f9177b 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> @@ -56,7 +56,9 @@
>         "0:"								\
>         : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),        \
>           "+r" (r7), "+r" (r8)						\
> -       : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory");	\
> +       : : "r9", "r10", "r11", "r12",					\
> +           "cr0", "cr1", "cr5", "cr6", "cr7",				\
> +           "xer", "lr", "ctr", "memory");				\
>      __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3));		        \
>      (long int) r0 & (1 << 28) ? -rval : rval;				\
>    })
> @@ -86,7 +88,8 @@
>  	 "=&r" (r6), "=&r" (r7), "=&r" (r8)	\
>         : ASM_INPUT_##nr			\
>         : "r9", "r10", "r11", "r12",		\
> -	 "lr", "ctr", "memory");		\
> +	 "cr0", "cr1", "cr5", "cr6", "cr7",	\
> +	 "xer", "lr", "ctr", "memory"); 	\
>      r3;					\
>    })
> 
> @@ -101,7 +104,7 @@
>  	 "=&r" (r6), "=&r" (r7), "=&r" (r8)	\
>         : ASM_INPUT_##nr			\
>         : "r9", "r10", "r11", "r12",		\
> -	 "cr0", "ctr", "memory");		\
> +	 "xer", "cr0", "ctr", "memory");	\
>      r0 & (1 << 28) ? -r3 : r3;			\
>    })
> 
> --
> 2.30.2
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] powerpc: Add missing registers to clobbers list for syscalls [BZ #27623]
  2021-03-29 13:35 [PATCH v2] powerpc: Add missing registers to clobbers list for syscalls [BZ #27623] Matheus Castanho
  2021-04-01  7:40 ` Nicholas Piggin
@ 2021-04-09 13:07 ` Raphael M Zinsly
  2021-04-16 11:44 ` Matheus Castanho
  2 siblings, 0 replies; 4+ messages in thread
From: Raphael M Zinsly @ 2021-04-09 13:07 UTC (permalink / raw)
  To: Matheus Castanho, libc-alpha

The patch LGTM!

On 29/03/2021 10:35, Matheus Castanho via Libc-alpha wrote:
> Some registers that can be clobbered by the kernel during a syscall are not
> listed on the clobbers list in sysdeps/unix/sysv/linux/powerpc/sysdep.h.
> 
> For syscalls using sc:
>      - XER is zeroed by the kernel on exit
> 
> For syscalls using scv:
>      - XER is zeroed by the kernel on exit
>      - Different from the sc case, most CR fields can be clobbered (according to
>        the ELF ABI and the Linux kernel's syscall ABI for powerpc
>        (linux/Documentation/powerpc/syscall64-abi.rst)
> 
> The same should apply to vsyscalls, which effectively execute a function call
> but are not currently adding these registers as clobbers either.
> 
> These are likely not causing issues today, but they should be added to the
> clobbers list just in case things change on the kernel side in the future.
> 
> Reported-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> 
> Changes from v1:
>    - Add XER, CR1, CR5-7 to vsyscall clobbers list
> 
> ---
>   sysdeps/unix/sysv/linux/powerpc/sysdep.h | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> index 6b99464e61..2f31f9177b 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> @@ -56,7 +56,9 @@
>          "0:"								\
>          : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),        \
>            "+r" (r7), "+r" (r8)						\
> -       : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory");	\
> +       : : "r9", "r10", "r11", "r12",					\
> +           "cr0", "cr1", "cr5", "cr6", "cr7",				\
> +           "xer", "lr", "ctr", "memory");				\
>       __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3));		        \
>       (long int) r0 & (1 << 28) ? -rval : rval;				\
>     })
> @@ -86,7 +88,8 @@
>   	 "=&r" (r6), "=&r" (r7), "=&r" (r8)	\
>          : ASM_INPUT_##nr			\
>          : "r9", "r10", "r11", "r12",		\
> -	 "lr", "ctr", "memory");		\
> +	 "cr0", "cr1", "cr5", "cr6", "cr7",	\
> +	 "xer", "lr", "ctr", "memory"); 	\
>       r3;					\
>     })
> 
> @@ -101,7 +104,7 @@
>   	 "=&r" (r6), "=&r" (r7), "=&r" (r8)	\
>          : ASM_INPUT_##nr			\
>          : "r9", "r10", "r11", "r12",		\
> -	 "cr0", "ctr", "memory");		\
> +	 "xer", "cr0", "ctr", "memory");	\
>       r0 & (1 << 28) ? -r3 : r3;			\
>     })
> 
> --
> 2.30.2
> 

Best Regards,
-- 
Raphael Moreira Zinsly
IBM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] powerpc: Add missing registers to clobbers list for syscalls [BZ #27623]
  2021-03-29 13:35 [PATCH v2] powerpc: Add missing registers to clobbers list for syscalls [BZ #27623] Matheus Castanho
  2021-04-01  7:40 ` Nicholas Piggin
  2021-04-09 13:07 ` Raphael M Zinsly
@ 2021-04-16 11:44 ` Matheus Castanho
  2 siblings, 0 replies; 4+ messages in thread
From: Matheus Castanho @ 2021-04-16 11:44 UTC (permalink / raw)
  To: Matheus Castanho; +Cc: tuliom, schwab, npiggin, libc-alpha


Pushed as 5d61fc2021922b4f572be218dad5b299e2939346

--
Matheus Castanho

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-16 11:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-29 13:35 [PATCH v2] powerpc: Add missing registers to clobbers list for syscalls [BZ #27623] Matheus Castanho
2021-04-01  7:40 ` Nicholas Piggin
2021-04-09 13:07 ` Raphael M Zinsly
2021-04-16 11:44 ` Matheus Castanho

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).