From: Konrad Rzeszutek Wilk Subject: [PATCH 3 of 6] xen/pat: After suspend re-write PAT if BIOS changed it Date: Sat, 24 Mar 2012 13:41:44 -0400 Message-ID: <75798a472b1a9121adda.1332610904@phenom.dumpdata.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com, keir.fraser@eu.citrix.com, Ian.Jackson@eu.citrix.com, Ian.Campbell@citrix.com Cc: konrad.wilk@oracle.com List-Id: xen-devel@lists.xenproject.org # HG changeset patch # User Simon Graham # Date 1332610898 14400 # Node ID 75798a472b1a9121adda166b6fd05ba8473a44f0 # Parent d097c3ba42f601af65b53a0c84973855aab64aa9 xen/pat: After suspend re-write PAT if BIOS changed it. Certain AMD machines (this was a MSI or GigaBYTE BIOS) after resume would reset the PAT MSR causing rather weird issues - where the pages would (say they would be set to WC) would end up with the wrong type (as they would use the BIOS PAT instead of the one set by the hypervisor). Signed-off-by: Simon Graham Signed-off-by: Konrad Rzeszutek Wilk diff -r d097c3ba42f6 -r 75798a472b1a xen/arch/x86/acpi/power.c --- a/xen/arch/x86/acpi/power.c Sat Mar 24 12:54:12 2012 -0400 +++ b/xen/arch/x86/acpi/power.c Sat Mar 24 13:41:38 2012 -0400 @@ -41,8 +41,25 @@ static DEFINE_SPINLOCK(pm_lock); struct acpi_sleep_info acpi_sinfo; +static void pat_resume(void); void do_suspend_lowlevel(void); +static void +pat_resume() +{ + u64 pat; + + rdmsrl(MSR_IA32_CR_PAT, pat); + if (pat != host_pat) { + printk(KERN_INFO PREFIX "Found PAT MSR: 0x%lx\n", pat); + printk(KERN_INFO PREFIX "reseting to 0x%lx\n", host_pat); + wrmsrl(MSR_IA32_CR_PAT, host_pat); + rdmsrl(MSR_IA32_CR_PAT, pat); + if (pat != host_pat) + printk(KERN_WARNING PREFIX "PAT MSR stuck on: 0x%lx\n", pat); + } +} + static int device_power_down(void) { console_suspend(); @@ -194,6 +211,7 @@ static int enter_state(u32 state) if ( cpu_has_efer ) write_efer(read_efer()); + pat_resume(); device_power_up(); mcheck_init(&boot_cpu_data, 0);