ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] syscalls/signal06: loop being clobbered by syscall on clang
@ 2022-08-19 21:31 Edward Liaw via ltp
  2022-08-19 22:34 ` Viktor Martensson via ltp
  0 siblings, 1 reply; 2+ messages in thread
From: Edward Liaw via ltp @ 2022-08-19 21:31 UTC (permalink / raw)
  To: ltp; +Cc: kernel-team

Indicate to the compiler that the syscall will modify registers rcx
and r11 to prevent loop from getting clobbered.

Signed-off-by: Edward Liaw <edliaw@google.com>

---
When I combined the asm instruction into one line, it threw an error
that the "Asm-specifier for input or output variable conflicts with asm
clobber list" for rax.  I omitted it for now, but I'm not sure if that
is correct.

Also, is it ok to change the subject line like I did?
---
 testcases/kernel/syscalls/signal/signal06.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/signal/signal06.c b/testcases/kernel/syscalls/signal/signal06.c
index 64f886ee3..fba380610 100644
--- a/testcases/kernel/syscalls/signal/signal06.c
+++ b/testcases/kernel/syscalls/signal/signal06.c
@@ -72,8 +72,7 @@ void test(void)
 	while (D == VALUE && loop < LOOPS) {
 		/* sys_tkill(pid, SIGHUP); asm to avoid save/reload
 		 * fp regs around c call */
-		asm ("" : : "a"(__NR_tkill), "D"(pid), "S"(SIGHUP));
-		asm ("syscall" : : : "ax");
+		asm volatile ("syscall" : : "a"(__NR_tkill), "D"(pid), "S"(SIGHUP) : "rcx", "r11");
 
 		loop++;
 	}
-- 
2.37.2.609.g9ff673ca1a-goog


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH v2] syscalls/signal06: loop being clobbered by syscall on clang
  2022-08-19 21:31 [LTP] [PATCH v2] syscalls/signal06: loop being clobbered by syscall on clang Edward Liaw via ltp
@ 2022-08-19 22:34 ` Viktor Martensson via ltp
  0 siblings, 0 replies; 2+ messages in thread
From: Viktor Martensson via ltp @ 2022-08-19 22:34 UTC (permalink / raw)
  To: Edward Liaw; +Cc: kernel-team, ltp


[-- Attachment #1.1: Type: text/plain, Size: 2020 bytes --]

Hello!

The syscall will get the return value in %rax I believe, so it may be wise
to indicate that it gets modified no? I would assume something like

*int foo; *
asm volatile ("syscall" : *"=a" (foo)*: "a"(__NR_tkill), "D"(pid),
"S"(SIGHUP) : "rcx", "r11");

would instruct the compiler to expect that %rax has been modified, and it
can't rely on it staying the same. An optimization pass may otherwise take
away the repeated setting of __NR_tkill in %rax.

/V

On Fri, Aug 19, 2022 at 2:31 PM 'Edward Liaw' via kernel-team <
kernel-team@android.com> wrote:

> Indicate to the compiler that the syscall will modify registers rcx
> and r11 to prevent loop from getting clobbered.
>
> Signed-off-by: Edward Liaw <edliaw@google.com>
>
> ---
> When I combined the asm instruction into one line, it threw an error
> that the "Asm-specifier for input or output variable conflicts with asm
> clobber list" for rax.  I omitted it for now, but I'm not sure if that
> is correct.
>
> Also, is it ok to change the subject line like I did?
> ---
>  testcases/kernel/syscalls/signal/signal06.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/signal/signal06.c
> b/testcases/kernel/syscalls/signal/signal06.c
> index 64f886ee3..fba380610 100644
> --- a/testcases/kernel/syscalls/signal/signal06.c
> +++ b/testcases/kernel/syscalls/signal/signal06.c
> @@ -72,8 +72,7 @@ void test(void)
>         while (D == VALUE && loop < LOOPS) {
>                 /* sys_tkill(pid, SIGHUP); asm to avoid save/reload
>                  * fp regs around c call */
> -               asm ("" : : "a"(__NR_tkill), "D"(pid), "S"(SIGHUP));
> -               asm ("syscall" : : : "ax");
> +               asm volatile ("syscall" : : "a"(__NR_tkill), "D"(pid),
> "S"(SIGHUP) : "rcx", "r11");
>
>                 loop++;
>         }
> --
> 2.37.2.609.g9ff673ca1a-goog
>
> --
> To unsubscribe from this group and stop receiving emails from it, send an
> email to kernel-team+unsubscribe@android.com.
>
>

[-- Attachment #1.2: Type: text/html, Size: 3075 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2022-08-22  9:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-19 21:31 [LTP] [PATCH v2] syscalls/signal06: loop being clobbered by syscall on clang Edward Liaw via ltp
2022-08-19 22:34 ` Viktor Martensson via ltp

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 NNTP newsgroup(s).