From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: [PATCH 2 of 3] xen/pat: After suspend re-write PAT if BIOS changed it Date: Mon, 02 Apr 2012 16:27:26 -0400 Message-ID: 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, Ian.Jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com, Ian.Campbell@citrix.com, jbeulich@suse.com Cc: konrad.wilk@oracle.com List-Id: xen-devel@lists.xenproject.org # HG changeset patch # User Simon Graham # Date 1333398413 14400 # Node ID caefa03c38366c3e70d937bc95740c5d33c0892a # Parent f1da2ce71ed41d1b74ebe6916ff7710d6579438e 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). And in some cases the PAT was stuck and needed a couple of WRMSRL to actually take. Signed-off-by: Simon Graham Signed-off-by: Konrad Rzeszutek Wilk diff -r f1da2ce71ed4 -r caefa03c3836 xen/arch/x86/acpi/power.c --- a/xen/arch/x86/acpi/power.c Mon Apr 02 16:26:48 2012 -0400 +++ b/xen/arch/x86/acpi/power.c Mon Apr 02 16:26:53 2012 -0400 @@ -41,8 +41,27 @@ 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; + if (!cpu_has_pat) + return; + + rdmsrl(MSR_IA32_CR_PAT, pat); + if (pat != host_pat) { + printk(KERN_INFO PREFIX "Found PAT MSR: 0x%"PRIx64"\n", pat); + printk(KERN_INFO PREFIX "reseting to 0x%"PRIx64"\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%"PRIx64"\n", pat); + } +} + static int device_power_down(void) { console_suspend(); @@ -194,6 +213,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);