mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	Andy Lutomirski <luto@kernel.org>
Subject: [PATCH] x86/vdso: add rcx clobber in syscall gettimeofday fallback
Date: Sun, 12 May 2024 07:55:28 +0300	[thread overview]
Message-ID: <e6ceb3bf-5c96-4b0a-9567-e9bcca0b821a@p183> (raw)

syscall instruction in fallback code is missing "rcx" and "r11" clobbers.

It doesn't seem to cause any problems because the C code looks like:

	if (do_hres(&vd[CS_HRES_COARSE], CLOCK_REALTIME, &ts))
        	return gettimeofday_fallback(tv, tz);

and assembly looks like

	__vdso_gettimeofday:
		 0:	lea    r9, [rip]
		 7:	test   rdi,rdi
		 a:	je     b7
		10:	mov    r8d, [r9]
		13:	test   r8b, 1
		17:	jne    bf
		1d:	cmp    [rip], 1
		24:	jne    c6
		2a:	rdtsc

		c6:	mov	eax, 96
		cb:	syscall
	====>	cd:	ret		<====

rcx and r11 are caller-saved and nothing seems to use those registers
after syscall and before returning from vDSO.

Fixes: 7ac870747988 ("x86/vdso: Switch to generic vDSO implementation")
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 arch/x86/include/asm/vdso/gettimeofday.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/x86/include/asm/vdso/gettimeofday.h
+++ b/arch/x86/include/asm/vdso/gettimeofday.h
@@ -86,7 +86,7 @@ long gettimeofday_fallback(struct __kernel_old_timeval *_tv,
 	long ret;
 
 	asm("syscall" : "=a" (ret) :
-	    "0" (__NR_gettimeofday), "D" (_tv), "S" (_tz) : "memory");
+	    "0" (__NR_gettimeofday), "D" (_tv), "S" (_tz) : "rcx", "r11", "memory");
 
 	return ret;
 }

                 reply	other threads:[~2024-05-12  4:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e6ceb3bf-5c96-4b0a-9567-e9bcca0b821a@p183 \
    --to=adobriyan@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=vincenzo.frascino@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®