Patchwork [1/1,Natty] x86, hibernate: Initialize mmu_cr4_features during boot

login
register
mail settings
Submitter Herton Ronaldo Krzesinski
Date April 7, 2011, 9:15 p.m.
Message ID <1302210948-5799-2-git-send-email-herton.krzesinski@canonical.com>
Download mbox | patch
Permalink /patch/90233/
State New
Headers show

Comments

Herton Ronaldo Krzesinski - April 7, 2011, 9:15 p.m.
From: H. Peter Anvin <hpa@linux.intel.com>

Restore the initialization of mmu_cr4_features during boot, which was
removed without comment in checkin e5f15b45ddf3afa2bbbb10c7ea34fb32b6de0a0e

x86: Cleanup highmap after brk is concluded

thereby breaking resume from hibernate.  This restores previous
functionality in approximately the same place, and corrects the
reading of %cr4 on pre-CPUID hardware (%cr4 exists if and only if
CPUID is supported.)

However, part of the problem is that the hibernate suspend/resume
sequence should manage the save/restore of %cr4 explicitly.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <201104020154.57136.rjw@sisk.pl>
(cherry picked from commit 4da9484bdece39ab0b098fa711e095e3e9fc8684)
Tested-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
BugLink: http://bugs.launchpad.net/bugs/752870
Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
---
 arch/x86/kernel/setup.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
Stefan Bader - April 8, 2011, 7:09 a.m.
On 04/07/2011 11:15 PM, Herton Ronaldo Krzesinski wrote:
> From: H. Peter Anvin <hpa@linux.intel.com>
> 
> Restore the initialization of mmu_cr4_features during boot, which was
> removed without comment in checkin e5f15b45ddf3afa2bbbb10c7ea34fb32b6de0a0e
> 
> x86: Cleanup highmap after brk is concluded
> 
> thereby breaking resume from hibernate.  This restores previous
> functionality in approximately the same place, and corrects the
> reading of %cr4 on pre-CPUID hardware (%cr4 exists if and only if
> CPUID is supported.)
> 
> However, part of the problem is that the hibernate suspend/resume
> sequence should manage the save/restore of %cr4 explicitly.
> 
> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
> Cc: Rafael J. Wysocki <rjw@sisk.pl>
> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Cc: Yinghai Lu <yinghai@kernel.org>
> LKML-Reference: <201104020154.57136.rjw@sisk.pl>
> (cherry picked from commit 4da9484bdece39ab0b098fa711e095e3e9fc8684)
> Tested-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
> BugLink: http://bugs.launchpad.net/bugs/752870
> Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
> ---
>  arch/x86/kernel/setup.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> index e543fe9..4e59873 100644
> --- a/arch/x86/kernel/setup.c
> +++ b/arch/x86/kernel/setup.c
> @@ -1013,6 +1013,11 @@ void __init setup_arch(char **cmdline_p)
>  	paging_init();
>  	x86_init.paging.pagetable_setup_done(swapper_pg_dir);
>  
> +	if (boot_cpu_data.cpuid_level >= 0) {
> +		/* A CPU has %cr4 if and only if it has CPUID */
> +		mmu_cr4_features = read_cr4();
> +	}
> +
>  #ifdef CONFIG_X86_32
>  	/* sync back kernel address range */
>  	clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY,
Looks ok

Acked-by: Stefan Bader <stefan.bader@canonical.com>
John Johansen - April 8, 2011, 9:58 a.m.
On 04/07/2011 02:15 PM, Herton Ronaldo Krzesinski wrote:
> From: H. Peter Anvin <hpa@linux.intel.com>
> 
> Restore the initialization of mmu_cr4_features during boot, which was
> removed without comment in checkin e5f15b45ddf3afa2bbbb10c7ea34fb32b6de0a0e
> 
> x86: Cleanup highmap after brk is concluded
> 
> thereby breaking resume from hibernate.  This restores previous
> functionality in approximately the same place, and corrects the
> reading of %cr4 on pre-CPUID hardware (%cr4 exists if and only if
> CPUID is supported.)
> 
> However, part of the problem is that the hibernate suspend/resume
> sequence should manage the save/restore of %cr4 explicitly.
> 
> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
> Cc: Rafael J. Wysocki <rjw@sisk.pl>
> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Cc: Yinghai Lu <yinghai@kernel.org>
> LKML-Reference: <201104020154.57136.rjw@sisk.pl>
> (cherry picked from commit 4da9484bdece39ab0b098fa711e095e3e9fc8684)
> Tested-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
> BugLink: http://bugs.launchpad.net/bugs/752870
> Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
> ---
>  arch/x86/kernel/setup.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> index e543fe9..4e59873 100644
> --- a/arch/x86/kernel/setup.c
> +++ b/arch/x86/kernel/setup.c
> @@ -1013,6 +1013,11 @@ void __init setup_arch(char **cmdline_p)
>  	paging_init();
>  	x86_init.paging.pagetable_setup_done(swapper_pg_dir);
>  
> +	if (boot_cpu_data.cpuid_level >= 0) {
> +		/* A CPU has %cr4 if and only if it has CPUID */
> +		mmu_cr4_features = read_cr4();
> +	}
> +
>  #ifdef CONFIG_X86_32
>  	/* sync back kernel address range */
>  	clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY,

I tried to replicate this and test on my amd64 machine but it appears, hibernate
is failing at an earlier point for me.

The patch looks good though
Acked-by: John Johansnen <john.johansen@canonical.com>

Patch

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index e543fe9..4e59873 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1013,6 +1013,11 @@  void __init setup_arch(char **cmdline_p)
 	paging_init();
 	x86_init.paging.pagetable_setup_done(swapper_pg_dir);
 
+	if (boot_cpu_data.cpuid_level >= 0) {
+		/* A CPU has %cr4 if and only if it has CPUID */
+		mmu_cr4_features = read_cr4();
+	}
+
 #ifdef CONFIG_X86_32
 	/* sync back kernel address range */
 	clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY,