git: a013e285dfd6 - main - x86 tsc: mark %eax as earlyclobber in tscp_get_timecount_low().

Konstantin Belousov kib at FreeBSD.org
Sun Jan 10 22:08:52 UTC 2021


The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=a013e285dfd6b89b1908ca13febb0fdb0a7f3b1f

commit a013e285dfd6b89b1908ca13febb0fdb0a7f3b1f
Author:     Konstantin Belousov <kib at FreeBSD.org>
AuthorDate: 2021-01-10 22:05:49 +0000
Commit:     Konstantin Belousov <kib at FreeBSD.org>
CommitDate: 2021-01-10 22:05:49 +0000

    x86 tsc: mark %eax as earlyclobber in tscp_get_timecount_low().
    
    i386 codegen insists on preloading tc_priv into register on i386, and
    this register cannot be %eax because RDTSCP instruction clobbers it
    before it is used.
    
    Reported and tested by: dim
    MFC after:      6 days
    Sponsored by:   The FreeBSD Foundation
---
 sys/x86/x86/tsc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c
index ad8108c8a7ea..85924df98312 100644
--- a/sys/x86/x86/tsc.c
+++ b/sys/x86/x86/tsc.c
@@ -826,7 +826,7 @@ tscp_get_timecount_low(struct timecounter *tc)
 	uint32_t rv;
 
 	__asm __volatile("rdtscp; movl %1, %%ecx; shrd %%cl, %%edx, %0"
-	    : "=a" (rv) : "m" (tc->tc_priv) : "ecx", "edx");
+	    : "=&a" (rv) : "m" (tc->tc_priv) : "ecx", "edx");
 	return (rv);
 }
 


More information about the dev-commits-src-all mailing list