x86: setup segment registers before percpu areas

The base of the percpu area is stored in the %gs base, and writing
to %gs destroys it.  Move setup_segments earlier, before the %gs
base is written, and keep setup_percpu_area close so that the base
is updated close to the selector.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/x86/cstart.S b/x86/cstart.S
index 5288252..409cb00 100644
--- a/x86/cstart.S
+++ b/x86/cstart.S
@@ -109,7 +109,11 @@
 
 .globl start
 start:
+        lgdtl gdt32_descr
+        setup_segments
         mov $stacktop, %esp
+        setup_percpu_area
+
         push %ebx
         call setup_multiboot
         addl $4, %esp
@@ -117,14 +121,10 @@
         mov mb_cmdline(%ebx), %eax
         mov %eax, __args
         call __setup_args
-        setup_percpu_area
         call prepare_32
         jmpl $8, $start32
 
 prepare_32:
-        lgdtl gdt32_descr
-	setup_segments
-
 	mov %cr4, %eax
 	bts $4, %eax  // pse
 	mov %eax, %cr4