mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Yinghai Lu <yinghai@kernel.org>,
	"H. Peter Anvin" <hpa@linux.intel.com>
Subject: [014/105] x86-64, mm: Put early page table high
Date: Tue, 12 Apr 2011 07:34:03 -0700	[thread overview]
Message-ID: <20110412143549.416968403@clark.kroah.org> (raw)
In-Reply-To: <20110412143613.GA19478@kroah.com>

2.6.38-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Yinghai Lu <yinghai@kernel.org>

commit 4b239f458c229de044d6905c2b0f9fe16ed9e01e upstream.

While dubug kdump, found current kernel will have problem with crashkernel=512M.

It turns out that initial mapping is to 512M, and later initial mapping to 4G
(acutally is 2040M in my platform), will put page table near 512M.
then initial mapping to 128g will be near 2g.

before this patch:
[    0.000000] initial memory mapped : 0 - 20000000
[    0.000000] init_memory_mapping: [0x00000000000000-0x0000007f74ffff]
[    0.000000]  0000000000 - 007f600000 page 2M
[    0.000000]  007f600000 - 007f750000 page 4k
[    0.000000] kernel direct mapping tables up to 7f750000 @ [0x1fffc000-0x1fffffff]
[    0.000000]     memblock_x86_reserve_range: [0x1fffc000-0x1fffdfff]          PGTABLE
[    0.000000] init_memory_mapping: [0x00000100000000-0x0000207fffffff]
[    0.000000]  0100000000 - 2080000000 page 2M
[    0.000000] kernel direct mapping tables up to 2080000000 @ [0x7bc01000-0x7bc83fff]
[    0.000000]     memblock_x86_reserve_range: [0x7bc01000-0x7bc7efff]          PGTABLE
[    0.000000] RAMDISK: 7bc84000 - 7f745000
[    0.000000] crashkernel reservation failed - No suitable area found.

after patch:
[    0.000000] initial memory mapped : 0 - 20000000
[    0.000000] init_memory_mapping: [0x00000000000000-0x0000007f74ffff]
[    0.000000]  0000000000 - 007f600000 page 2M
[    0.000000]  007f600000 - 007f750000 page 4k
[    0.000000] kernel direct mapping tables up to 7f750000 @ [0x7f74c000-0x7f74ffff]
[    0.000000]     memblock_x86_reserve_range: [0x7f74c000-0x7f74dfff]          PGTABLE
[    0.000000] init_memory_mapping: [0x00000100000000-0x0000207fffffff]
[    0.000000]  0100000000 - 2080000000 page 2M
[    0.000000] kernel direct mapping tables up to 2080000000 @ [0x207ff7d000-0x207fffffff]
[    0.000000]     memblock_x86_reserve_range: [0x207ff7d000-0x207fffafff]          PGTABLE
[    0.000000] RAMDISK: 7bc84000 - 7f745000
[    0.000000]     memblock_x86_reserve_range: [0x17000000-0x36ffffff]     CRASH KERNEL
[    0.000000] Reserving 512MB of memory at 368MB for crashkernel (System RAM: 133120MB)

It means with the patch, page table for [0, 2g) will need 2g, instead of under 512M,
page table for [4g, 128g) will be near 128g, instead of under 2g.

That would good, if we have lots of memory above 4g, like 1024g, or 2048g or 16T, will not put
related page table under 2g. that would be have chance to fill the under 2g if 1G or 2M page is
not used.

the code change will use add map_low_page() and update unmap_low_page() for 64bit, and use them
to get access the corresponding high memory for page table setting.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <4D0C0734.7060900@kernel.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 arch/x86/mm/init.c    |    9 ++-----
 arch/x86/mm/init_64.c |   63 +++++++++++++++++++++-----------------------------
 2 files changed, 30 insertions(+), 42 deletions(-)

--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -33,7 +33,7 @@ int direct_gbpages
 static void __init find_early_table_space(unsigned long end, int use_pse,
 					  int use_gbpages)
 {
-	unsigned long puds, pmds, ptes, tables, start;
+	unsigned long puds, pmds, ptes, tables, start = 0, good_end = end;
 	phys_addr_t base;
 
 	puds = (end + PUD_SIZE - 1) >> PUD_SHIFT;
@@ -73,12 +73,9 @@ static void __init find_early_table_spac
 	 * need roughly 0.5KB per GB.
 	 */
 #ifdef CONFIG_X86_32
-	start = 0x7000;
-#else
-	start = 0x8000;
+	good_end = max_pfn_mapped << PAGE_SHIFT;
 #endif
-	base = memblock_find_in_range(start, max_pfn_mapped<<PAGE_SHIFT,
-					tables, PAGE_SIZE);
+	base = memblock_find_in_range(start, good_end, tables, PAGE_SIZE);
 	if (base == MEMBLOCK_ERROR)
 		panic("Cannot find space for the kernel page tables");
 
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -334,12 +334,28 @@ static __ref void *alloc_low_page(unsign
 	return adr;
 }
 
+static __ref void *map_low_page(void *virt)
+{
+	void *adr;
+	unsigned long phys, left;
+
+	if (after_bootmem)
+		return virt;
+
+	phys = __pa(virt);
+	left = phys & (PAGE_SIZE - 1);
+	adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
+	adr = (void *)(((unsigned long)adr) | left);
+
+	return adr;
+}
+
 static __ref void unmap_low_page(void *adr)
 {
 	if (after_bootmem)
 		return;
 
-	early_iounmap(adr, PAGE_SIZE);
+	early_iounmap((void *)((unsigned long)adr & PAGE_MASK), PAGE_SIZE);
 }
 
 static unsigned long __meminit
@@ -387,15 +403,6 @@ phys_pte_init(pte_t *pte_page, unsigned
 }
 
 static unsigned long __meminit
-phys_pte_update(pmd_t *pmd, unsigned long address, unsigned long end,
-		pgprot_t prot)
-{
-	pte_t *pte = (pte_t *)pmd_page_vaddr(*pmd);
-
-	return phys_pte_init(pte, address, end, prot);
-}
-
-static unsigned long __meminit
 phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end,
 	      unsigned long page_size_mask, pgprot_t prot)
 {
@@ -421,8 +428,10 @@ phys_pmd_init(pmd_t *pmd_page, unsigned
 		if (pmd_val(*pmd)) {
 			if (!pmd_large(*pmd)) {
 				spin_lock(&init_mm.page_table_lock);
-				last_map_addr = phys_pte_update(pmd, address,
+				pte = map_low_page((pte_t *)pmd_page_vaddr(*pmd));
+				last_map_addr = phys_pte_init(pte, address,
 								end, prot);
+				unmap_low_page(pte);
 				spin_unlock(&init_mm.page_table_lock);
 				continue;
 			}
@@ -469,18 +478,6 @@ phys_pmd_init(pmd_t *pmd_page, unsigned
 }
 
 static unsigned long __meminit
-phys_pmd_update(pud_t *pud, unsigned long address, unsigned long end,
-		unsigned long page_size_mask, pgprot_t prot)
-{
-	pmd_t *pmd = pmd_offset(pud, 0);
-	unsigned long last_map_addr;
-
-	last_map_addr = phys_pmd_init(pmd, address, end, page_size_mask, prot);
-	__flush_tlb_all();
-	return last_map_addr;
-}
-
-static unsigned long __meminit
 phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
 			 unsigned long page_size_mask)
 {
@@ -505,8 +502,11 @@ phys_pud_init(pud_t *pud_page, unsigned
 
 		if (pud_val(*pud)) {
 			if (!pud_large(*pud)) {
-				last_map_addr = phys_pmd_update(pud, addr, end,
+				pmd = map_low_page(pmd_offset(pud, 0));
+				last_map_addr = phys_pmd_init(pmd, addr, end,
 							 page_size_mask, prot);
+				unmap_low_page(pmd);
+				__flush_tlb_all();
 				continue;
 			}
 			/*
@@ -554,17 +554,6 @@ phys_pud_init(pud_t *pud_page, unsigned
 	return last_map_addr;
 }
 
-static unsigned long __meminit
-phys_pud_update(pgd_t *pgd, unsigned long addr, unsigned long end,
-		 unsigned long page_size_mask)
-{
-	pud_t *pud;
-
-	pud = (pud_t *)pgd_page_vaddr(*pgd);
-
-	return phys_pud_init(pud, addr, end, page_size_mask);
-}
-
 unsigned long __meminit
 kernel_physical_mapping_init(unsigned long start,
 			     unsigned long end,
@@ -588,8 +577,10 @@ kernel_physical_mapping_init(unsigned lo
 			next = end;
 
 		if (pgd_val(*pgd)) {
-			last_map_addr = phys_pud_update(pgd, __pa(start),
+			pud = map_low_page((pud_t *)pgd_page_vaddr(*pgd));
+			last_map_addr = phys_pud_init(pud, __pa(start),
 						 __pa(end), page_size_mask);
+			unmap_low_page(pud);
 			continue;
 		}
 



  parent reply	other threads:[~2011-04-12 14:58 UTC|newest]

Thread overview: 126+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-12 14:36 [000/105] 2.6.38.3-stable review Greg KH
2011-04-12 14:33 ` [001/105] ALSA: HDA: New AD1984A model for Dell Precision R5500 Greg KH
2011-04-12 14:33 ` [002/105] ALSA: hda - Fix SPDIF out regression on ALC889 Greg KH
2011-04-12 14:33 ` [003/105] ALSA: Fix yet another race in disconnection Greg KH
2011-04-12 14:33 ` [004/105] ALSA: vmalloc buffers should use normal mmap Greg KH
2011-04-12 14:33 ` [005/105] perf: Better fit max unprivileged mlock pages for tools needs Greg KH
2011-04-12 14:33 ` [006/105] myri10ge: fix rmmod crash Greg KH
2011-04-12 14:33 ` [007/105] cciss: fix lost command issue Greg KH
2011-04-12 14:33 ` [008/105] ath9k: Fix kernel panic in AR2427 Greg KH
2011-04-12 14:33 ` [009/105] sound/oss/opl3: validate voice and channel indexes Greg KH
2011-04-12 14:33 ` [010/105] mac80211: initialize sta->last_rx in sta_info_alloc Greg KH
2011-04-12 14:34 ` [011/105] [SCSI] ses: show devices for enclosures with no page 7 Greg KH
2011-04-12 14:34 ` [012/105] [SCSI] ses: Avoid kernel panic when lun 0 is not mapped Greg KH
2011-04-12 14:34 ` [013/105] PCI/ACPI: Report ASPM support to BIOS if not disabled from command line Greg KH
2011-04-12 14:34 ` Greg KH [this message]
2011-04-12 15:25   ` [014/105] x86-64, mm: Put early page table high Stefano Stabellini
2011-04-12 17:23     ` Greg KH
2011-04-12 14:34 ` [015/105] eCryptfs: Unlock page in write_begin error path Greg KH
2011-04-12 14:34 ` [016/105] eCryptfs: ecryptfs_keyring_auth_tok_for_sig() bug fix Greg KH
2011-04-12 14:34 ` [017/105] crypto: aesni-intel - fixed problem with packets that are not multiple of 64bytes Greg KH
2011-04-12 14:34 ` [018/105] staging: usbip: bugfixes related to kthread conversion Greg KH
2011-04-12 14:34 ` [019/105] staging: usbip: bugfix add number of packets for isochronous frames Greg KH
2011-04-12 14:34 ` [020/105] staging: usbip: bugfix for isochronous packets and optimization Greg KH
2011-04-12 14:34 ` [021/105] staging: hv: use sync_bitops when interacting with the hypervisor Greg KH
2011-04-12 14:34 ` [022/105] staging: hv: Fix GARP not sent after Quick Migration Greg KH
2011-04-12 14:34 ` [023/105] Relax si_code check in rt_sigqueueinfo and rt_tgsigqueueinfo Greg KH
2011-04-12 14:34 ` [024/105] xfs: register the inode cache shrinker before quotachecks Greg KH
2011-04-12 14:34 ` [025/105] amd64_edac: Fix potential memleak Greg KH
2011-04-12 14:34 ` [026/105] watchdog: s3c2410_wdt.c: Convert release_resource to release_region/release_mem_region Greg KH
2011-04-12 14:34 ` [027/105] watchdog: " Greg KH
2011-04-12 14:34 ` [028/105] watchdog: sp5100_tco.c: Check if firmware has set correct value in tcobase Greg KH
2011-04-12 14:34 ` [029/105] irda: validate peer name and attribute lengths Greg KH
2011-04-12 14:34 ` [030/105] irda: prevent heap corruption on invalid nickname Greg KH
2011-04-12 14:34 ` [031/105] powerpc: Fix accounting of softirq time when idle Greg KH
2011-04-12 14:34 ` [032/105] nilfs2: fix data loss in mmap page write for hole blocks Greg KH
2011-04-12 14:34 ` [033/105] ASoC: Explicitly say registerless widgets have no register Greg KH
2011-04-12 14:34 ` [034/105] ASoC: imx: set watermarks for mx2-dma Greg KH
2011-04-12 14:34 ` [035/105] ASoC: imx: fix burstsize for DMA Greg KH
2011-04-12 14:34 ` [036/105] ASoC: Fix CODEC device name for Corgi Greg KH
2011-04-12 14:34 ` [037/105] ALSA: ens1371: fix Creative Ectiva support Greg KH
2011-04-12 14:34 ` [038/105] ALSA: pcm: fix infinite loop in snd_pcm_update_hw_ptr0() Greg KH
2011-04-12 14:34 ` [039/105] ALSA: HDA: Add dock mic quirk for Lenovo Thinkpad X220 Greg KH
2011-04-12 14:34 ` [040/105] ALSA: HDA: Fix dock mic for Lenovo X220-tablet Greg KH
2011-04-12 14:34 ` [041/105] ALSA: hda - HDMI: Fix MCP7x audio infoframe checksums Greg KH
2011-04-12 14:34 ` [042/105] ALSA: HDA: Fix single internal mic on ALC275 (Sony Vaio VPCSB1C5E) Greg KH
2011-04-12 14:34 ` [043/105] net: fix ethtool->set_flags not intended -EINVAL return value Greg KH
2011-04-12 14:34 ` [044/105] drm/radeon/kms: add some new ontario pci ids Greg KH
2011-04-12 14:34 ` [045/105] drm/radeon/kms: add some sanity checks to obj info record parsingi (v2) Greg KH
2011-04-12 14:34 ` [046/105] inotify: fix double free/corruption of stuct user Greg KH
2011-04-12 14:34 ` [047/105] HID: hid-magicmouse: Increase evdev buffer size Greg KH
2011-04-12 14:34 ` [048/105] perf: Fix task_struct reference leak Greg KH
2011-04-12 14:34 ` [049/105] perf: Rebase max unprivileged mlock threshold on top of page size Greg KH
2011-04-12 14:34 ` [050/105] ROSE: prevent heap corruption with bad facilities Greg KH
2011-04-12 14:34 ` [051/105] Btrfs: Fix uninitialized root flags for subvolumes Greg KH
2011-04-12 14:34 ` [052/105] x86, mtrr, pat: Fix one cpu getting out of sync during resume Greg KH
2011-04-12 14:34 ` [053/105] Input: synaptics - fix crash in synaptics_module_init() Greg KH
2011-04-12 14:34 ` [054/105] ath9k: fix a chip wakeup related crash in ath9k_start Greg KH
2011-04-12 14:34 ` [055/105] mac80211: fix a crash in minstrel_ht in HT mode with no supported MCS rates Greg KH
2011-04-12 14:34 ` [056/105] staging: IIO: IMU: ADIS16400: Fix up SPI messages cs_change behavior Greg KH
2011-04-12 14:34 ` [057/105] staging: IIO: IMU: ADIS16400: Add delay after self test Greg KH
2011-04-12 14:34 ` [058/105] staging: IIO: IMU: ADIS16400: Fix addresses of GYRO and ACCEL calibration offset Greg KH
2011-04-12 14:34 ` [059/105] staging: IIO: IMU: ADIS16400: Make sure only enabled scan_elements are pushed into the ring Greg KH
2011-04-12 14:34 ` [060/105] UBIFS: do not read flash unnecessarily Greg KH
2011-04-12 14:34 ` [061/105] UBIFS: fix oops on error path in read_pnode Greg KH
2011-04-12 14:34 ` [062/105] UBIFS: fix debugging failure in dbg_check_space_info Greg KH
2011-04-12 14:34 ` [063/105] quota: Dont write quota info in dquot_commit() Greg KH
2011-04-12 14:34 ` [064/105] mm: avoid wrapping vm_pgoff in mremap() Greg KH
2011-04-12 14:34 ` [065/105] Revert "net/sunrpc: Use static const char arrays" Greg KH
2011-04-12 14:34 ` [066/105] iwlwifi: accept EEPROM version 0x423 for iwl6000 Greg KH
2011-04-12 14:34 ` [067/105] p54usb: IDs for two new devices Greg KH
2011-04-12 14:34 ` [068/105] rt2x00: Fix radio off hang issue for PCIE interface Greg KH
2011-04-12 14:34 ` [069/105] rt2x00: fix cancelling uninitialized work Greg KH
2011-04-12 14:34 ` [070/105] wl12xx: fix potential buffer overflow in testmode nvs push Greg KH
2011-04-12 14:35 ` [071/105] [media] media/radio/wl1273: fix build errors Greg KH
2011-04-12 14:35 ` [072/105] b43: allocate receive buffers big enough for max frame len + offset Greg KH
2011-04-12 14:35 ` [073/105] Bluetooth: sco: fix information leak to userspace Greg KH
2011-04-12 14:35 ` [074/105] bridge: netfilter: fix information leak Greg KH
2011-04-12 14:35 ` [075/105] Bluetooth: bnep: fix buffer overflow Greg KH
2011-04-12 14:35 ` [076/105] Bluetooth: add support for Apple MacBook Pro 8,2 Greg KH
2011-04-13 15:57   ` Grant Likely
2011-04-13 16:18     ` [stable] [076/105] Bluetooth: add support for Apple MacBook Pro 8, 2 Greg KH
2011-04-12 14:35 ` [077/105] Treat writes as new when holes span across page boundaries Greg KH
2011-04-12 14:35 ` [078/105] char/tpm: Fix unitialized usage of data buffer Greg KH
2011-04-12 14:35 ` [079/105] netfilter: ip_tables: fix infoleak to userspace Greg KH
2011-04-12 14:35 ` [080/105] netfilter: xtables: fix reentrancy Greg KH
2011-04-12 14:35 ` [081/105] netfilter: arp_tables: fix infoleak to userspace Greg KH
2011-04-12 14:35 ` [082/105] netfilter: ipt_CLUSTERIP: fix buffer overflow Greg KH
2011-04-12 14:35 ` [083/105] ipv6: netfilter: ip6_tables: fix infoleak to userspace Greg KH
2011-04-12 14:35 ` [084/105] [SCSI] scsi_transport_iscsi: make priv_sess file writeable only by root Greg KH
2011-04-12 14:35 ` [085/105] mfd: ab8500: world-writable debugfs register-* files Greg KH
2011-04-12 14:35 ` [086/105] mfd: ab3500: " Greg KH
2011-04-12 14:35 ` [087/105] mfd: ab3100: world-writable debugfs *_priv files Greg KH
2011-04-12 14:35 ` [088/105] drivers/rtc/rtc-ds1511.c: world-writable sysfs nvram file Greg KH
2011-04-12 14:35 ` [089/105] drivers/misc/ep93xx_pwm.c: world-writable sysfs files Greg KH
2011-04-12 14:35 ` [090/105] drivers/leds/leds-lp5523.c: world-writable engine* " Greg KH
2011-04-12 14:35 ` [091/105] drivers/leds/leds-lp5521.c: world-writable sysfs engine* files Greg KH
2011-04-12 14:35 ` [092/105] econet: 4 byte infoleak to the network Greg KH
2011-04-12 14:35 ` [093/105] netfilter: h323: bug in parsing of ASN1 SEQOF field Greg KH
2011-04-12 14:35 ` [094/105] sound/oss: remove offset from load_patch callbacks Greg KH
2011-04-12 14:35 ` [095/105] [media] drivers/media/video/tlg2300/pd-video.c: Remove second mutex_unlock in pd_vidioc_s_fmt Greg KH
2011-04-12 14:35 ` [096/105] acer-wmi: does not set persistence state by rfkill_init_sw_state Greg KH
2011-04-12 14:35 ` [097/105] [PATCH] Revert "x86: Cleanup highmap after brk is concluded" Greg KH
2011-04-12 14:35 ` [098/105] Squashfs: Use vmalloc rather than kmalloc for zlib workspace Greg KH
2011-04-12 14:35 ` [099/105] Squashfs: handle corruption of directory structure Greg KH
2011-04-12 14:35 ` [100/105] atm/solos-pci: Dont include frame pseudo-header on transmit hex-dump Greg KH
2011-04-12 14:35 ` [101/105] atm/solos-pci: Dont flap VCs when carrier state changes Greg KH
2011-04-12 14:35 ` [102/105] ext4: fix a double free in ext4_register_li_request Greg KH
2011-04-12 14:35 ` [103/105] ext4: fix credits computing for indirect mapped files Greg KH
2011-04-12 14:35 ` [104/105] nfsd: fix auth_domain reference leak on nlm operations Greg KH
2011-04-12 14:35 ` [105/105] nfsd4: fix oops on lock failure Greg KH
2011-04-17 15:03   ` OGAWA Hirofumi
2011-04-17 16:10     ` Linus Torvalds
2011-04-18 15:32       ` J. Bruce Fields
2011-04-18 15:42         ` J. Bruce Fields
2011-04-18 16:08         ` OGAWA Hirofumi
2011-04-18 16:10           ` OGAWA Hirofumi
2011-04-18 16:39             ` OGAWA Hirofumi
2011-04-18 16:59               ` Linus Torvalds
2011-04-18 17:16                 ` J. Bruce Fields
2011-04-18 18:21                   ` [stable] " Greg KH
2011-04-18 21:12               ` OGAWA Hirofumi
2011-04-19  8:21                 ` OGAWA Hirofumi
2011-04-19 20:43                   ` J. Bruce Fields
2011-04-19 21:17                     ` OGAWA Hirofumi
2011-04-19 21:33                       ` J. Bruce Fields
2011-04-20 23:23                         ` nfsd bugfixes for 2.6.39 J. Bruce Fields

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110412143549.416968403@clark.kroah.org \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=hpa@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®