svn commit: r339449 - head/sys/amd64/include
Mateusz Guzik
mjg at FreeBSD.org
Sat Oct 20 17:00:20 UTC 2018
Author: mjg
Date: Sat Oct 20 17:00:18 2018
New Revision: 339449
URL: https://svnweb.freebsd.org/changeset/base/339449
Log:
amd64: relax constraints in curthread and curpcb
This makes the compiler less likely to reload the content from %gs.
The 'P' modifier drops all synteax prefixes and 'n' constraint treats
input as a known at compilation time immediate integer.
Example reloading victim was spinlock_enter.
Stolen from: OpenBSD
Reported by: jtl
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17615
Modified:
head/sys/amd64/include/pcpu.h
Modified: head/sys/amd64/include/pcpu.h
==============================================================================
--- head/sys/amd64/include/pcpu.h Sat Oct 20 16:59:43 2018 (r339448)
+++ head/sys/amd64/include/pcpu.h Sat Oct 20 17:00:18 2018 (r339449)
@@ -227,8 +227,7 @@ __curthread(void)
{
struct thread *td;
- __asm("movq %%gs:%1,%0" : "=r" (td)
- : "m" (*(char *)OFFSETOF_CURTHREAD));
+ __asm("movq %%gs:%P1,%0" : "=r" (td) : "n" (OFFSETOF_CURTHREAD));
return (td);
}
#ifdef __clang__
@@ -242,7 +241,7 @@ __curpcb(void)
{
struct pcb *pcb;
- __asm("movq %%gs:%1,%0" : "=r" (pcb) : "m" (*(char *)OFFSETOF_CURPCB));
+ __asm("movq %%gs:%P1,%0" : "=r" (pcb) : "n" (OFFSETOF_CURPCB));
return (pcb);
}
#define curpcb (__curpcb())
More information about the svn-src-all
mailing list