svn commit: r322345 - stable/11/lib/libc/x86/sys

Konstantin Belousov kostikbel at gmail.com
Sun Aug 13 13:38:16 UTC 2017


On Sun, Aug 13, 2017 at 03:13:11PM +0200, Andre Albsmeier wrote:
> On Thu, 10-Aug-2017 at 09:00:15 +0000, Konstantin Belousov wrote:
> > Author: kib
> > Date: Thu Aug 10 09:00:15 2017
> > New Revision: 322345
> > URL: https://svnweb.freebsd.org/changeset/base/322345
> > 
> > Log:
> >   MFC r321608:
> >   Use MFENCE to serialize RDTSC on non-Intel CPUs.
> 
> This broke libc on my
> 
> FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0)
> VT(vga): text 80x25
> CPU: AMD-K6tm w/ multimedia extensions (199.44-MHz 586-class CPU)
>   Origin="AuthenticAMD"  Id=0x562  Family=0x5  Model=0x6  Stepping=2
>   Features=0x8001bf<FPU,VME,DE,PSE,TSC,MSR,MCE,CX8,MMX>
>   AMD Features=0x400<<b10>>
> 
> On system start, it actually makes various programmes hang until
> Ctrl-C is pressed. Reboot is not possible (endlessly hanging with
> 'zillions of defunct processes).
> 
> Going back to r322042 fixes it...

Indeed code is broken on i386 machines which have CPUID but no SSE.
Try this.

diff --git a/lib/libc/x86/sys/__vdso_gettc.c b/lib/libc/x86/sys/__vdso_gettc.c
index 4ada5e7eac1..ef2ca69edf7 100644
--- a/lib/libc/x86/sys/__vdso_gettc.c
+++ b/lib/libc/x86/sys/__vdso_gettc.c
@@ -101,6 +101,7 @@ init_fence(void)
 #if defined(__i386__)
 	u_int cpuid_supported, p[4];
 
+	lfence_works = LMB_NONE;
 	__asm __volatile(
 	    "	pushfl\n"
 	    "	popl	%%eax\n"
@@ -121,8 +122,7 @@ init_fence(void)
 		cpuidp(0x1, p);
 		if ((p[3] & CPUID_SSE2) != 0)
 			lfence_works = select_lmb();
-	} else
-		lfence_works = LMB_NONE;
+	}
 #elif defined(__amd64__)
 	lfence_works = select_lmb();
 #else


More information about the svn-src-all mailing list