All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen: fix s3 resume on AMD CPUs
@ 2009-06-05  8:00 Christoph Egger
  2009-06-05  8:21 ` Keir Fraser
  0 siblings, 1 reply; 6+ messages in thread
From: Christoph Egger @ 2009-06-05  8:00 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 389 bytes --]


Hi,

attached patch fixes S3 resume on AMD CPUs.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>

-- 
---to satisfy European Law for business letters:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen
Geschaeftsfuehrer: Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

[-- Attachment #2: xen_s3.diff --]
[-- Type: text/x-diff, Size: 3447 bytes --]

diff -r 2e522b843a21 xen/arch/x86/boot/wakeup.S
--- a/xen/arch/x86/boot/wakeup.S	Wed Jun 03 18:27:05 2009 +0100
+++ b/xen/arch/x86/boot/wakeup.S	Fri Jun 05 08:32:21 2009 +0200
@@ -4,6 +4,7 @@
 
         .align 16
 ENTRY(wakeup_start)
+        nop
         cli
         cld
 
@@ -105,11 +106,14 @@ video_mode:     .long 0
 video_flags:    .long 0
 
         .code32
+        .align 16
 
         # Now in protect mode, with paging disabled
         # Add offset for any reference to xen specific symbols
 
 wakeup_32:
+        nop
+        /* Set up segment registers and initial stack for protected mode */
         mov     $BOOT_DS, %eax
         mov     %eax, %ds
         mov     %eax, %ss
@@ -128,35 +132,55 @@ wakeup_32:
         mov     $X86_CR4_PAE, %ecx
         mov     %ecx, %cr4
 
-        /* Load pagetable base register */
-        mov     $sym_phys(idle_pg_table),%eax
-        add     bootsym_phys(trampoline_xen_phys_start),%eax
-        mov     %eax,%cr3
-
-        /* Will cpuid feature change after resume? */
-        /* Set up EFER (Extended Feature Enable Register). */
+        /*
+         * First switch to Long Mode. Do not restore the original
+         * MSR EFER value directly as enabling the NX bit without
+         * paging will result in a #GPF on AMD CPUs.
+         */
         mov     bootsym_phys(cpuid_ext_features),%edi
         test    $0x20100800,%edi /* SYSCALL/SYSRET, No Execute, Long Mode? */
-        jz      .Lskip_eferw
+        jz      .Lskip_efer1
         movl    $MSR_EFER,%ecx
         rdmsr
 #if CONFIG_PAGING_LEVELS == 4
         btsl    $_EFER_LME,%eax /* Long Mode      */
-        btsl    $_EFER_SCE,%eax /* SYSCALL/SYSRET */
+        wrmsr
 #endif
-        btl     $20,%edi        /* No Execute?    */
+
+.Lskip_efer1:
+        /* Load pagetable base register */
+        movl    $sym_phys(idle_pg_table),%eax
+        addl    bootsym_phys(trampoline_xen_phys_start),%eax
+        movl    %eax,%cr3
+
+        /* Enable paging */
+        movl    %cr0,%eax
+        orl $(X86_CR0_PG|X86_CR0_AM|X86_CR0_WP|X86_CR0_NE|X86_CR0_ET|X86_CR0_TS|X86_CR0_MP|X86_CR0_PE),%eax
+        movl    %eax,%cr0
+        /* Flush prefetch queue */
+        jmp     1f
+1:      jmp     1f
+1:
+
+        /*
+         * Load the normal system of MSR EFER.  This includes
+         * enabling the SYSCALL extension and NXE (if supported). 
+         */
+        testl   $0x20100800,%edi /* SYSCALL/SYSRET, No Execute, Long Mode? */
+        jz      .Lskip_efer2
+        movl    $MSR_EFER, %ecx
+        rdmsr
+#if CONFIG_PAGING_LEVELS == 4
+        btsl    $_EFER_SCE,%eax	/* SYSCALL/SYSRET */
+#endif
+        btl     $20,%edi        /* No Execute? */
         jnc     1f
-        btsl    $_EFER_NX,%eax  /* No Execute     */
+        btsl    $_EFER_NX,%eax  /* No Execute */
 1:      wrmsr
-.Lskip_eferw:
+.Lskip_efer2:
 
         wbinvd
 
-        mov     $0x80050033,%eax /* hi-to-lo: PG,AM,WP,NE,ET,MP,PE */
-        mov     %eax,%cr0
-        jmp     1f
-1:
-
 #if defined(__x86_64__)
 
         /* Now in compatibility mode. Long-jump to 64-bit mode */
@@ -174,8 +198,9 @@ wakeup_64:
         mov     $(__HYPERVISOR_DS64), %eax
         mov     %eax, %ds
 
-        # long jump to return point, with cs reload
-        rex64 ljmp    *ret_point(%rip)
+        /* long jump to return point, with cs reload */
+        movq    ret_point(%rip), %rbx
+        jmp     *%rbx
 
         .align 8
 ret_point:

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-06-16  9:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-05  8:00 [PATCH] xen: fix s3 resume on AMD CPUs Christoph Egger
2009-06-05  8:21 ` Keir Fraser
2009-06-15 15:33   ` Christoph Egger
2009-06-16  8:30     ` Jan Beulich
2009-06-16  8:52       ` Christoph Egger
2009-06-16  9:38       ` Keir Fraser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.