From f136f32870b2948ea2a71a05f8f616cb8ffb5565 Mon Sep 17 00:00:00 2001
From: Avi Kivity <avi@cloudius-systems.com>
Date: Thu, 7 Mar 2013 18:23:50 +0200
Subject: [PATCH] sched: copy the tls image to a new thread, instead of zeroing
 it

With the current memset(), every thread starts out with zero-initialized
tls variables.

Switch to memcpy(), so it gets the proper static initializer.

Fixes conf-preempt=0.
---
 arch/x64/arch-switch.hh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x64/arch-switch.hh b/arch/x64/arch-switch.hh
index f7c89559f..17b3833d3 100644
--- a/arch/x64/arch-switch.hh
+++ b/arch/x64/arch-switch.hh
@@ -80,7 +80,7 @@ void thread::setup_tcb()
     assert(tls.size);
     // FIXME: respect alignment
     void* p = malloc(sched::tls.size + sizeof(*_tcb));
-    memset(p, 0, sched::tls.size);
+    memcpy(p, sched::tls.start, sched::tls.size);
     _tcb = static_cast<thread_control_block*>(p + tls.size);
     _tcb->self = _tcb;
     _tcb->tls_base = p;
-- 
GitLab