lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080109035534.GA30321@basil.nowhere.org>
Date:	Wed, 9 Jan 2008 04:55:34 +0100
From:	Andi Kleen <andi@...stfloor.org>
To:	mingo@...e.hu, tglx@...utronix.de, linux-kernel@...r.kernel.org
Subject: More breakage in native_rdtsc out of line in git-x86


I had some boot failures here with git-x86 with init and hotplug all 
segfaulting early on userland with new glibc.  Bisecting found

commit 6aea5bc37fa790eaf3a942f0785985914568e214
Author: Ingo Molnar <mingo@...e.hu>
Date:   Sat Jan 5 13:27:08 2008 +0100

    x86: move native_read_tsc() offline
    
    move native_read_tsc() offline.

I think the problem is that the vsyscall/vdso code calls it through
vread and for that it has to be exported. There seems to be also
another bug with the old style vsyscalls not using the TSC vread
that masks it on older glibc

Stepping with gdb through old style vgettimeofday() confirms that RDTSC is 
not used.

A long time ago we had a similar problem once and it was because of a 
problem exporting the vsyscall variables in vmlinux.lds.S -- looks like that 
has reappeared.

I think the new glibc shows it because it uses the vDSO not 
the older vsyscall and the new vDSO probably still works. Anyways haven't 
investigated why that is in detail yet, but that's a separate 
regression.

Back to the boot failure:

Unfortunately simply adding __vsyscall_fn to native_read_tsc doesn't 
work -- causes early kernel faults like

PANIC: early exception rip ffffffffff600105 error 10 cr2 ffffffffff600105
Pid: 0, comm: swapper Not tainted 2.6.24-rc6 #58

Call Trace:
 [<ffffffff80211dec>] native_sched_clock+0x9/0x3f
 [<ffffffff8022b758>] init_idle+0x33/0xd1
 [<ffffffff80825449>] sched_init+0x26d/0x283
 [<ffffffff80815899>] start_kernel+0x10b/0x2bd
 [<ffffffff80815114>] _sinittext+0x114/0x11b

Not sure why that is -- in theory the vsyscall functions should be callable 
from the main kernel. Might be a binutils problem or another code
regression.

Anyways it looks like the only good fix is to either revert that or
fork into two functions one for vread() and another for normal tsc ->read()

This is all in addition to the problem of it having incorrect barriers.
I note that my original patch didn't have any of these problems.

I'm using the appended revert patch here as a workaround for now.

-Andi


Revert rdtsc out of line change

Reverts 

commit 6aea5bc37fa790eaf3a942f0785985914568e214
Author: Ingo Molnar <mingo@...e.hu>
Date:   Sat Jan 5 13:27:08 2008 +0100

    x86: move native_read_tsc() offline

    move native_read_tsc() offline.

The function is called by vsyscalls in ring 3, so it can't be out of line this way.

Signed-off-by: Andi Kleen <ak@...e.de>

Index: linux/arch/x86/kernel/rtc.c
===================================================================
--- linux.orig/arch/x86/kernel/rtc.c
+++ linux/arch/x86/kernel/rtc.c
@@ -194,14 +194,3 @@ int update_persistent_clock(struct times
 {
 	return set_rtc_mmss(now.tv_sec);
 }
-
-unsigned long long native_read_tsc(void)
-{
-	DECLARE_ARGS(val, low, high);
-
-	asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
-	rdtsc_barrier();
-
-	return EAX_EDX_VAL(val, low, high);
-}
-
Index: linux/include/asm-x86/msr.h
===================================================================
--- linux.orig/include/asm-x86/msr.h
+++ linux/include/asm-x86/msr.h
@@ -91,7 +91,13 @@ static inline int native_write_msr_safe(
 	return err;
 }
 
-extern unsigned long long native_read_tsc(void);
+static inline unsigned long long native_read_tsc(void)
+{
+	DECLARE_ARGS(val, low, high);
+
+	asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
+	return EAX_EDX_VAL(val, low, high);
+}
 
 static inline unsigned long long native_read_pmc(int counter)
 {


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ