__tls_get_addr problem with recent current
Kostik Belousov
kostikbel at gmail.com
Sat Aug 30 18:38:10 UTC 2008
On Sat, Aug 30, 2008 at 09:46:05AM -0700, Artem Belevich wrote:
> Hi,
>
> Did someone figure out what was/is causing this problem? I believe
> I've ran into the same issue on a freshly built (Aug 29th) RELENG_7 on
> amd64 (Q9450 w/ 8GB RAM).
>
> What's strange is that in my case the problem pops up when I run
> 32-bit binaries from RELENG_6. Otherwise the system is stable. I can
> buildworld continuously with -j8 without any problems. However, when I
> try to build my code using hacked make from FreeBSD6/i386 things start
> falling apart. All of a sudden I get cores from FreeBSD7/amd64
> binaries. All of them, as far as I can tell crash in __tls_get_addr.
> So far I've been unable to reproduce the crashes in any other
> scenarios, but I'm still trying.
>
> Interestingly enough, crash always occurs on "mov %fs:0x0,%rdi" instruction,
> yet the same code in the same binaries works fine when binaries are used
> without mixing amd64/i386 binaries. Could that be that amd64 might
> somehow inherit invalid registers from i386 binaries?
Quite possible, almost sure. Could you, please, check whether the
change below would fix it for you ?
diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S
index f34b0cc..9e13ef4 100644
--- a/sys/amd64/amd64/cpu_switch.S
+++ b/sys/amd64/amd64/cpu_switch.S
@@ -265,6 +265,10 @@ load_seg:
movl PCB_DS(%r8),%ds
movl PCB_ES(%r8),%es
movl PCB_FS(%r8),%fs
+ movl $MSR_FSBASE,%ecx
+ rdmsr
+ shlq $32,%rdx
+ leaq (%rax,%rdx),%r9
jmp done_load_seg
/* Restore userland %gs while preserving kernel gsbase */
2: movq PCB_GS32P(%r8),%rax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20080830/21de45ff/attachment.pgp
More information about the freebsd-current
mailing list