[tip:x86/urgent] x86, mm: Fix CONFIG_VMSPLIT_1G and 2G_OPT trampoline

Previous thread: [PATCH 00/24] Support for Qualcomm msm8660 target by Jeff Ohlstein on Tuesday, August 24, 2010 - 9:57 pm. (50 messages)

Next thread: Re: Using perf probe with arguments throws a fatal error. by Masami Hiramatsu on Tuesday, August 24, 2010 - 10:47 pm. (2 messages)
From: Hugh Dickins
Date: Tuesday, August 24, 2010 - 10:44 pm

rc2 kernel crashes when booting second cpu on this CONFIG_VMSPLIT_2G_OPT
laptop: whereas cloning from kernel to low mappings pgd range does need
to limit by both KERNEL_PGD_PTRS and KERNEL_PGD_BOUNDARY, cloning kernel
pgd range itself must not be limited by the smaller KERNEL_PGD_BOUNDARY.

Signed-off-by: Hugh Dickins <hughd@google.com>
---

 arch/x86/kernel/trampoline.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- 2.6.36-rc2/arch/x86/kernel/trampoline.c.0	2010-08-22 18:56:44.000000000 -0700
+++ linux/arch/x86/kernel/trampoline.c	2010-08-24 22:11:08.000000000 -0700
@@ -45,8 +45,7 @@ void __init setup_trampoline_page_table(
 	/* Copy kernel address range */
 	clone_pgd_range(trampoline_pg_dir + KERNEL_PGD_BOUNDARY,
 			swapper_pg_dir + KERNEL_PGD_BOUNDARY,
-			min_t(unsigned long, KERNEL_PGD_PTRS,
-			      KERNEL_PGD_BOUNDARY));
+			KERNEL_PGD_PTRS);
 
 	/* Initialize low mappings */
 	clone_pgd_range(trampoline_pg_dir,
--

From: Borislav Petkov
Date: Tuesday, August 24, 2010 - 11:30 pm

From: Hugh Dickins <hughd@google.com>

Yep, makes sense.

In looking around for other swapper_pg_dir manipulations, there's this
piece in <arch/x86/kernel/reboot.c:machine_real_restart()>:

       /* Remap the kernel at virtual address zero, as well as offset zero
          from the kernel segment.  This assumes the kernel segment starts at
          virtual address PAGE_OFFSET. */
       memcpy(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
               sizeof(swapper_pg_dir [0]) * KERNEL_PGD_PTRS);

and we're cloning to low mappings here but still take KERNEL_PGD_PTRS.

In the CONFIG_VMSPLIT_2G_OPT case, KERNEL_PGD_BOUNDARY and
KERNEL_PGD_PTRS are 480 and 544, respectively, and IINM, and we end up
overwriting the virtual mappings beginning at PAGE_OFFSET.



-- 
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

--

From: H. Peter Anvin
Date: Wednesday, August 25, 2010 - 12:06 am

It doesn't matter on reboot, but the right thing would be to switch to
the trampoline page table here.  Same with suspend.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

--

From: Borislav Petkov
Date: Wednesday, August 25, 2010 - 12:13 am

From: "H. Peter Anvin" <hpa@zytor.com>

Yeah, I do that in my other patch (http://lkml.org/lkml/2010/8/24/61)
which adds the initial_page_table and keeps swapper_pg_dir clear of low
mappings. I'll add Hugh's fix there too and will start testing to see
what happens :).

-- 
Regards/Gruss,
Boris.

Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen
Registergericht Muenchen, HRB Nr. 43632

--

From: tip-bot for Hugh Dickins
Date: Wednesday, August 25, 2010 - 12:13 am

Commit-ID:  b7d460897739e02f186425b7276e3fdb1595cea7
Gitweb:     http://git.kernel.org/tip/b7d460897739e02f186425b7276e3fdb1595cea7
Author:     Hugh Dickins <hughd@google.com>
AuthorDate: Tue, 24 Aug 2010 22:44:12 -0700
Committer:  H. Peter Anvin <hpa@zytor.com>
CommitDate: Tue, 24 Aug 2010 23:05:17 -0700

x86, mm: Fix CONFIG_VMSPLIT_1G and 2G_OPT trampoline

rc2 kernel crashes when booting second cpu on this CONFIG_VMSPLIT_2G_OPT
laptop: whereas cloning from kernel to low mappings pgd range does need
to limit by both KERNEL_PGD_PTRS and KERNEL_PGD_BOUNDARY, cloning kernel
pgd range itself must not be limited by the smaller KERNEL_PGD_BOUNDARY.

Signed-off-by: Hugh Dickins <hughd@google.com>
LKML-Reference: <alpine.LSU.2.00.1008242235120.2515@sister.anvils>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
 arch/x86/kernel/trampoline.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/trampoline.c b/arch/x86/kernel/trampoline.c
index a874495..e2a5952 100644
--- a/arch/x86/kernel/trampoline.c
+++ b/arch/x86/kernel/trampoline.c
@@ -45,8 +45,7 @@ void __init setup_trampoline_page_table(void)
 	/* Copy kernel address range */
 	clone_pgd_range(trampoline_pg_dir + KERNEL_PGD_BOUNDARY,
 			swapper_pg_dir + KERNEL_PGD_BOUNDARY,
-			min_t(unsigned long, KERNEL_PGD_PTRS,
-			      KERNEL_PGD_BOUNDARY));
+			KERNEL_PGD_PTRS);
 
 	/* Initialize low mappings */
 	clone_pgd_range(trampoline_pg_dir,
--

Previous thread: [PATCH 00/24] Support for Qualcomm msm8660 target by Jeff Ohlstein on Tuesday, August 24, 2010 - 9:57 pm. (50 messages)

Next thread: Re: Using perf probe with arguments throws a fatal error. by Masami Hiramatsu on Tuesday, August 24, 2010 - 10:47 pm. (2 messages)