Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86, suspend: Handle CPUs which fail to #GP on RDMSR

There are CPUs which have errata causing RDMSR of a nonexistent MSR to
not fault. We would then try to WRMSR to restore the value of that
MSR, causing a crash. Specifically, some Pentium M variants would
have this problem trying to save and restore the non-existent EFER,
causing a crash on resume.

Work around this by making sure we can write back the result at
suspend time.

Huge thanks to Christian Sünkenberg for finding the offending erratum
that finally deciphered the mystery.

Reported-and-tested-by: Johan Heinrich <onny@project-insanity.org>
Debugged-by: Christian Sünkenberg <christian.suenkenberg@student.kit.edu>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Link: http://lkml.kernel.org/r/51DDC972.3010005@student.kit.edu
Cc: <stable@vger.kernel.org> # v3.7+

+16 -2
+16 -2
arch/x86/kernel/acpi/sleep.c
··· 48 48 #ifndef CONFIG_64BIT 49 49 native_store_gdt((struct desc_ptr *)&header->pmode_gdt); 50 50 51 + /* 52 + * We have to check that we can write back the value, and not 53 + * just read it. At least on 90 nm Pentium M (Family 6, Model 54 + * 13), reading an invalid MSR is not guaranteed to trap, see 55 + * Erratum X4 in "Intel Pentium M Processor on 90 nm Process 56 + * with 2-MB L2 Cache and Intel® Processor A100 and A110 on 90 57 + * nm process with 512-KB L2 Cache Specification Update". 58 + */ 51 59 if (!rdmsr_safe(MSR_EFER, 52 60 &header->pmode_efer_low, 53 - &header->pmode_efer_high)) 61 + &header->pmode_efer_high) && 62 + !wrmsr_safe(MSR_EFER, 63 + header->pmode_efer_low, 64 + header->pmode_efer_high)) 54 65 header->pmode_behavior |= (1 << WAKEUP_BEHAVIOR_RESTORE_EFER); 55 66 #endif /* !CONFIG_64BIT */ 56 67 ··· 72 61 } 73 62 if (!rdmsr_safe(MSR_IA32_MISC_ENABLE, 74 63 &header->pmode_misc_en_low, 75 - &header->pmode_misc_en_high)) 64 + &header->pmode_misc_en_high) && 65 + !wrmsr_safe(MSR_IA32_MISC_ENABLE, 66 + header->pmode_misc_en_low, 67 + header->pmode_misc_en_high)) 76 68 header->pmode_behavior |= 77 69 (1 << WAKEUP_BEHAVIOR_RESTORE_MISC_ENABLE); 78 70 header->realmode_flags = acpi_realmode_flags;