vserver 1.9.5.x5
[linux-2.6.git] / arch / x86_64 / kernel / suspend_asm.S
index 8a39998..633a869 100644 (file)
@@ -1,6 +1,9 @@
-/* Originally gcc generated, modified by hand
+/* Copyright 2004,2005 Pavel Machek <pavel@suse.cz>, Andi Kleen <ak@suse.de>, Rafael J. Wysocki <rjw@sisk.pl>
  *
- * This may not use any stack, nor any variable that is not "NoSave":
+ * Distribute under GPLv2.
+ *
+ * swsusp_arch_resume may not use any stack, nor any variable that is
+ * not "NoSave" during copying pages:
  *
  * Its rewriting one kernel image with another. What is stack in "old"
  * image could very well be data page in "new" image, and overwriting
@@ -11,6 +14,7 @@
 #include <linux/linkage.h>
 #include <asm/segment.h>
 #include <asm/page.h>
+#include <asm/offset.h>
 
 ENTRY(swsusp_arch_suspend)
 
@@ -49,43 +53,28 @@ ENTRY(swsusp_arch_resume)
        movq    %rcx, %cr3;
        movq    %rax, %cr4;  # turn PGE back on
 
+       movq    pagedir_nosave(%rip), %rdx
+       /* compute the limit */
        movl    nr_copy_pages(%rip), %eax
-       xorl    %ecx, %ecx
-       movq    $0, %r10
        testl   %eax, %eax
        jz      done
-.L105:
-       xorl    %esi, %esi
-       movq    $0, %r11
-       jmp     .L104
-       .p2align 4,,7
-copy_one_page:
-       movq    %r10, %rcx
-.L104:
-       movq    pagedir_nosave(%rip), %rdx
-       movq    %rcx, %rax
-       salq    $5, %rax
-       movq    8(%rdx,%rax), %rcx
-       movq    (%rdx,%rax), %rax
-       movzbl  (%rsi,%rax), %eax
-       movb    %al, (%rsi,%rcx)
-
-       movq    %cr3, %rax;  # flush TLB
-       movq    %rax, %cr3;
+       movq    %rdx,%r8
+       movl    $SIZEOF_PBE,%r9d
+       mul             %r9  # with rax, clobbers rdx
+       movq    %r8, %rdx
+       addq    %r8, %rax
+loop:
+       /* get addresses from the pbe and copy the page */
+       movq    pbe_address(%rdx), %rsi
+       movq    pbe_orig_address(%rdx), %rdi
+       movq    $512, %rcx
+       rep
+       movsq
 
-       movq    %r11, %rax
-       incq    %rax
-       cmpq    $4095, %rax
-       movq    %rax, %rsi
-       movq    %rax, %r11
-       jbe     copy_one_page
-       movq    %r10, %rax
-       incq    %rax
-       movq    %rax, %rcx
-       movq    %rax, %r10
-       mov     nr_copy_pages(%rip), %eax
-       cmpq    %rax, %rcx
-       jb      .L105
+       /* progress to the next pbe */
+       addq    $SIZEOF_PBE, %rdx
+       cmpq    %rax, %rdx
+       jb      loop
 done:
        movl    $24, %eax
        movl    %eax, %ds