x86: fix i486 suspend to disk CR4 oops
arch/x86/power/cpu_32.c __save_processor_state calls read_cr4() only a i486 CPU doesn't have the CR4 register. Trying to read it produces an invalid opcode oops during suspend to disk. Use the safe rc4 reading op instead. If the value to be written is zero the write is skipped. arch/x86/power/hibernate_asm_32.S done: swapped the use of %eax and %ecx to use jecxz for the zero test and jump over store to %cr4. restore_image: s/%ecx/%eax/ to be consistent with done: In addition to __save_processor_state, acpi_save_state_mem, efi_call_phys_prelog, and efi_call_phys_epilog had checks added (acpi restore was in assembly and already had a check for non-zero). There were other reads and writes of CR4, but MCE and virtualization shouldn't be executed on a i486 anyway. Signed-off-by: David Fries <david@fries.net> Acked-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
39e00fe20a
commit
e532c06f2a
4 changed files with 22 additions and 16 deletions
|
@ -86,7 +86,7 @@ int acpi_save_state_mem(void)
|
||||||
#endif /* !CONFIG_64BIT */
|
#endif /* !CONFIG_64BIT */
|
||||||
|
|
||||||
header->pmode_cr0 = read_cr0();
|
header->pmode_cr0 = read_cr0();
|
||||||
header->pmode_cr4 = read_cr4();
|
header->pmode_cr4 = read_cr4_safe();
|
||||||
header->realmode_flags = acpi_realmode_flags;
|
header->realmode_flags = acpi_realmode_flags;
|
||||||
header->real_magic = 0x12345678;
|
header->real_magic = 0x12345678;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ void efi_call_phys_prelog(void)
|
||||||
* directory. If I have PAE, I just need to duplicate one entry in
|
* directory. If I have PAE, I just need to duplicate one entry in
|
||||||
* page directory.
|
* page directory.
|
||||||
*/
|
*/
|
||||||
cr4 = read_cr4();
|
cr4 = read_cr4_safe();
|
||||||
|
|
||||||
if (cr4 & X86_CR4_PAE) {
|
if (cr4 & X86_CR4_PAE) {
|
||||||
efi_bak_pg_dir_pointer[0].pgd =
|
efi_bak_pg_dir_pointer[0].pgd =
|
||||||
|
@ -91,7 +91,7 @@ void efi_call_phys_epilog(void)
|
||||||
gdt_descr.size = GDT_SIZE - 1;
|
gdt_descr.size = GDT_SIZE - 1;
|
||||||
load_gdt(&gdt_descr);
|
load_gdt(&gdt_descr);
|
||||||
|
|
||||||
cr4 = read_cr4();
|
cr4 = read_cr4_safe();
|
||||||
|
|
||||||
if (cr4 & X86_CR4_PAE) {
|
if (cr4 & X86_CR4_PAE) {
|
||||||
swapper_pg_dir[pgd_index(0)].pgd =
|
swapper_pg_dir[pgd_index(0)].pgd =
|
||||||
|
|
|
@ -45,7 +45,7 @@ static void __save_processor_state(struct saved_context *ctxt)
|
||||||
ctxt->cr0 = read_cr0();
|
ctxt->cr0 = read_cr0();
|
||||||
ctxt->cr2 = read_cr2();
|
ctxt->cr2 = read_cr2();
|
||||||
ctxt->cr3 = read_cr3();
|
ctxt->cr3 = read_cr3();
|
||||||
ctxt->cr4 = read_cr4();
|
ctxt->cr4 = read_cr4_safe();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Needed by apm.c */
|
/* Needed by apm.c */
|
||||||
|
@ -98,6 +98,8 @@ static void __restore_processor_state(struct saved_context *ctxt)
|
||||||
/*
|
/*
|
||||||
* control registers
|
* control registers
|
||||||
*/
|
*/
|
||||||
|
/* cr4 was introduced in the Pentium CPU */
|
||||||
|
if (ctxt->cr4)
|
||||||
write_cr4(ctxt->cr4);
|
write_cr4(ctxt->cr4);
|
||||||
write_cr3(ctxt->cr3);
|
write_cr3(ctxt->cr3);
|
||||||
write_cr2(ctxt->cr2);
|
write_cr2(ctxt->cr2);
|
||||||
|
|
|
@ -28,9 +28,9 @@ ENTRY(swsusp_arch_suspend)
|
||||||
ret
|
ret
|
||||||
|
|
||||||
ENTRY(restore_image)
|
ENTRY(restore_image)
|
||||||
movl resume_pg_dir, %ecx
|
movl resume_pg_dir, %eax
|
||||||
subl $__PAGE_OFFSET, %ecx
|
subl $__PAGE_OFFSET, %eax
|
||||||
movl %ecx, %cr3
|
movl %eax, %cr3
|
||||||
|
|
||||||
movl restore_pblist, %edx
|
movl restore_pblist, %edx
|
||||||
.p2align 4,,7
|
.p2align 4,,7
|
||||||
|
@ -52,17 +52,21 @@ copy_loop:
|
||||||
|
|
||||||
done:
|
done:
|
||||||
/* go back to the original page tables */
|
/* go back to the original page tables */
|
||||||
movl $swapper_pg_dir, %ecx
|
movl $swapper_pg_dir, %eax
|
||||||
subl $__PAGE_OFFSET, %ecx
|
subl $__PAGE_OFFSET, %eax
|
||||||
movl %ecx, %cr3
|
movl %eax, %cr3
|
||||||
/* Flush TLB, including "global" things (vmalloc) */
|
/* Flush TLB, including "global" things (vmalloc) */
|
||||||
movl mmu_cr4_features, %eax
|
movl mmu_cr4_features, %ecx
|
||||||
movl %eax, %edx
|
jecxz 1f # cr4 Pentium and higher, skip if zero
|
||||||
|
movl %ecx, %edx
|
||||||
andl $~(1<<7), %edx; # PGE
|
andl $~(1<<7), %edx; # PGE
|
||||||
movl %edx, %cr4; # turn off PGE
|
movl %edx, %cr4; # turn off PGE
|
||||||
movl %cr3, %ecx; # flush TLB
|
1:
|
||||||
movl %ecx, %cr3
|
movl %cr3, %eax; # flush TLB
|
||||||
movl %eax, %cr4; # turn PGE back on
|
movl %eax, %cr3
|
||||||
|
jecxz 1f # cr4 Pentium and higher, skip if zero
|
||||||
|
movl %ecx, %cr4; # turn PGE back on
|
||||||
|
1:
|
||||||
|
|
||||||
movl saved_context_esp, %esp
|
movl saved_context_esp, %esp
|
||||||
movl saved_context_ebp, %ebp
|
movl saved_context_ebp, %ebp
|
||||||
|
|
Loading…
Reference in a new issue