Commit 9ac1e4a8 authored by Pavel Machek's avatar Pavel Machek Committed by Linus Torvalds

[PATCH] swsusp: fix x86-64 - do not use memory in copy loop

In assembly code, there are some problems with "nosave" section (linker was
doing something stupid, like duplicating the section).  We attempted to fix
it, but fix was worse then first problem.  This fixes is for good: We no
longer use any memory in the copy loop.  (Plus it fixes indentation and
uses meaningful labels.)
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c5cada67
...@@ -39,29 +39,28 @@ ENTRY(swsusp_arch_resume) ...@@ -39,29 +39,28 @@ ENTRY(swsusp_arch_resume)
/* set up cr3 */ /* set up cr3 */
leaq init_level4_pgt(%rip),%rax leaq init_level4_pgt(%rip),%rax
subq $__START_KERNEL_map,%rax subq $__START_KERNEL_map,%rax
movq %rax,%cr3 movq %rax,%cr3
movq mmu_cr4_features(%rip), %rax movq mmu_cr4_features(%rip), %rax
movq %rax, %rdx movq %rax, %rdx
andq $~(1<<7), %rdx # PGE andq $~(1<<7), %rdx # PGE
movq %rdx, %cr4; # turn off PGE movq %rdx, %cr4; # turn off PGE
movq %cr3, %rcx; # flush TLB movq %cr3, %rcx; # flush TLB
movq %rcx, %cr3; movq %rcx, %cr3;
movq %rax, %cr4; # turn PGE back on movq %rax, %cr4; # turn PGE back on
movl nr_copy_pages(%rip), %eax movl nr_copy_pages(%rip), %eax
xorl %ecx, %ecx xorl %ecx, %ecx
movq $0, loop(%rip) movq $0, %r10
testl %eax, %eax testl %eax, %eax
je .L108 jz done
.L105: .L105:
xorl %esi, %esi xorl %esi, %esi
movq $0, loop2(%rip) movq $0, %r11
jmp .L104 jmp .L104
.p2align 4,,7 .p2align 4,,7
.L111: copy_one_page:
movq loop(%rip), %rcx movq %r10, %rcx
.L104: .L104:
movq pagedir_nosave(%rip), %rdx movq pagedir_nosave(%rip), %rdx
movq %rcx, %rax movq %rcx, %rax
...@@ -71,27 +70,26 @@ ENTRY(swsusp_arch_resume) ...@@ -71,27 +70,26 @@ ENTRY(swsusp_arch_resume)
movzbl (%rsi,%rax), %eax movzbl (%rsi,%rax), %eax
movb %al, (%rsi,%rcx) movb %al, (%rsi,%rcx)
movq %cr3, %rax; # flush TLB movq %cr3, %rax; # flush TLB
movq %rax, %cr3; movq %rax, %cr3;
movq loop2(%rip), %rax movq %r11, %rax
incq %rax incq %rax
cmpq $4095, %rax cmpq $4095, %rax
movq %rax, %rsi movq %rax, %rsi
movq %rax, loop2(%rip) movq %rax, %r11
jbe .L111 jbe copy_one_page
movq loop(%rip), %rax movq %r10, %rax
incq %rax incq %rax
movq %rax, %rcx movq %rax, %rcx
movq %rax, loop(%rip) movq %rax, %r10
mov nr_copy_pages(%rip), %eax mov nr_copy_pages(%rip), %eax
cmpq %rax, %rcx cmpq %rax, %rcx
jb .L105 jb .L105
.L108: done:
.align 4
movl $24, %eax movl $24, %eax
movl %eax, %ds
movl %eax, %ds
movq saved_context_esp(%rip), %rsp movq saved_context_esp(%rip), %rsp
movq saved_context_ebp(%rip), %rbp movq saved_context_ebp(%rip), %rbp
movq saved_context_eax(%rip), %rax movq saved_context_eax(%rip), %rax
...@@ -111,10 +109,3 @@ ENTRY(swsusp_arch_resume) ...@@ -111,10 +109,3 @@ ENTRY(swsusp_arch_resume)
pushq saved_context_eflags(%rip) ; popfq pushq saved_context_eflags(%rip) ; popfq
call swsusp_restore call swsusp_restore
ret ret
.section .data.nosave
loop:
.quad 0
loop2:
.quad 0
.previous
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment