From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Egger Subject: Re: [PATCH] xen: fix s3 resume on AMD CPUs Date: Mon, 15 Jun 2009 17:33:02 +0200 Message-ID: <200906151733.02897.Christoph.Egger@amd.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_ummNKVKF/Qq+r1Q" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Keir Fraser List-Id: xen-devel@lists.xenproject.org --Boundary-00=_ummNKVKF/Qq+r1Q Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Friday 05 June 2009 10:21:26 Keir Fraser wrote: > On 05/06/2009 09:00, "Christoph Egger" wrote: > > attached patch fixes S3 resume on AMD CPUs. > > > > Signed-off-by: Christoph Egger > > Please make a minimal patch and explain each individual change. This one > has bizarre additional alignment, nops, double short jumps, > longjmp->shortjmp but keeps a comment which is then incorrect. Why are they > needed? Is the need documented? I don't see anything similar in Linux > 2.6.27 wakeup routines (2.6.27 is what I happen to have to hand). > > I won't take your random permutations on this file of all files especially, > since it is a pain in the arse to debug when it gets broken. Attached patch adds a few comments, turns a long jump into a short jump to avoid a #GP. Reload %cs via lretq right after stack pointer has been restored. Signed-off-by: Christoph Egger --Boundary-00=_ummNKVKF/Qq+r1Q Content-Type: text/x-diff; charset="iso-8859-1"; name="xen_s3.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen_s3.diff" diff -r 112680f620bf xen/arch/x86/acpi/wakeup_prot.S --- a/xen/arch/x86/acpi/wakeup_prot.S Mon Jun 08 18:23:57 2009 +0100 +++ b/xen/arch/x86/acpi/wakeup_prot.S Wed Jun 10 15:15:16 2009 +0200 @@ -142,6 +142,12 @@ __ret_point: LOAD_GREG(sp) #if defined(__x86_64__) + /* Reload code selector */ + pushq $(__HYPERVISOR_CS64) + leaq 1f(%rip),%rax + pushq %rax + lretq +1: mov REF(saved_cr8), %rax mov %rax, %cr8 diff -r 112680f620bf xen/arch/x86/boot/wakeup.S --- a/xen/arch/x86/boot/wakeup.S Mon Jun 08 18:23:57 2009 +0100 +++ b/xen/arch/x86/boot/wakeup.S Wed Jun 10 15:15:16 2009 +0200 @@ -110,6 +110,7 @@ video_flags: .long 0 # Add offset for any reference to xen specific symbols wakeup_32: + /* Set up segment registers and initial stack for protected mode */ mov $BOOT_DS, %eax mov %eax, %ds mov %eax, %ss @@ -152,8 +153,10 @@ 1: wrmsr wbinvd + /* Enable paging */ mov $0x80050033,%eax /* hi-to-lo: PG,AM,WP,NE,ET,MP,PE */ mov %eax,%cr0 + /* Flush prefetch queue */ jmp 1f 1: @@ -174,8 +177,11 @@ wakeup_64: mov $(__HYPERVISOR_DS64), %eax mov %eax, %ds - # long jump to return point, with cs reload - rex64 ljmp *ret_point(%rip) + /* Continue with wakeup in the high-level wakeup code. + * Reload cs there. + */ + movq ret_point(%rip), %rbx + jmp *%rbx .align 8 ret_point: --Boundary-00=_ummNKVKF/Qq+r1Q Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_ummNKVKF/Qq+r1Q--