Skip to contentSkip to conversation

x86: 46 bit PAE support

PATCH In review Rik van Riel 4 participants 9 messages May 5, 2009 – May 7, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: 46 bit PAE support

Extend the maximum addressable memory on x86-64 from 2^44 to 2^46 bytes. This requires some shuffling around of the vmalloc and virtual memmap memory areas, to keep them away from the direct mapping of up to 64TB of physical memory.

This patch also introduces a guard hole between the vmalloc area and the virtual memory map space. There's really no good reason why we wouldn't have a guard hole there.

---
Testing: booted it on an x86-64 system with 6GB RAM. Did you really think I had access to a system with 64TB of RAM? :)

Documentation/x86/x86_64/mm.txt +5 -4
index 29b52b1..5394132 100644
@@ -6,10 +6,11 @@ Virtual memory map with 4 level page tables:
 0000000000000000 - 00007fffffffffff (=47 bits) user space, different per mm
 hole caused by [48:63] sign extension
 ffff800000000000 - ffff80ffffffffff (=40 bits) guard hole
-ffff880000000000 - ffffc0ffffffffff (=57 TB) direct mapping of all phys. memory
-ffffc10000000000 - ffffc1ffffffffff (=40 bits) hole
-ffffc20000000000 - ffffe1ffffffffff (=45 bits) vmalloc/ioremap space
-ffffe20000000000 - ffffe2ffffffffff (=40 bits) virtual memory map (1TB)
+ffff880000000000 - ffffc8ffffffffff (=64 TB) direct mapping of all phys. memory
+ffffc80000000000 - ffffc8ffffffffff (=40 bits) hole
+ffffc90000000000 - ffffe8ffffffffff (=45 bits) vmalloc/ioremap space
+ffffe90000000000 - ffffe9ffffffffff (=40 bits) hole
+ffffea0000000000 - ffffeaffffffffff (=40 bits) virtual memory map (1TB)
 ... unused hole ...
 ffffffff80000000 - ffffffffa0000000 (=512 MB)  kernel text mapping, from phys 0
 ffffffffa0000000 - fffffffffff00000 (=1536 MB) module mapping space
arch/x86/include/asm/page_64_types.h +1 -1
index d38c91b..786306c 100644
@@ -47,7 +47,7 @@
 #define __START_KERNEL		(__START_KERNEL_map + __PHYSICAL_START)
 #define __START_KERNEL_map	_AC(0xffffffff80000000, UL)
 
-/* See Documentation/x86_64/mm.txt for a description of the memory map. */
+/* See Documentation/x86/x86_64/mm.txt for a description of the memory map. */
 #define __PHYSICAL_MASK_SHIFT	46
 #define __VIRTUAL_MASK_SHIFT	48
 
arch/x86/include/asm/pgtable_64_types.h +4 -4
index fbf42b8..766ea16 100644
@@ -51,11 +51,11 @@ typedef struct { pteval_t pte; } pte_t;
 #define PGDIR_SIZE	(_AC(1, UL) << PGDIR_SHIFT)
 #define PGDIR_MASK	(~(PGDIR_SIZE - 1))
 
-
+/* See Documentation/x86/x86_64/mm.txt for a description of the memory map. */
 #define MAXMEM		 _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL)
-#define VMALLOC_START    _AC(0xffffc20000000000, UL)
-#define VMALLOC_END      _AC(0xffffe1ffffffffff, UL)
-#define VMEMMAP_START	 _AC(0xffffe20000000000, UL)
+#define VMALLOC_START    _AC(0xffffc90000000000, UL)
+#define VMALLOC_END      _AC(0xffffe8ffffffffff, UL)
+#define VMEMMAP_START	 _AC(0xffffea0000000000, UL)
 #define MODULES_VADDR    _AC(0xffffffffa0000000, UL)
 #define MODULES_END      _AC(0xffffffffff000000, UL)
 #define MODULES_LEN   (MODULES_END - MODULES_VADDR)
arch/x86/include/asm/sparsemem.h +1 -1
index e3cc3c0..4517d6b 100644
@@ -27,7 +27,7 @@
 #else /* CONFIG_X86_32 */
 # define SECTION_SIZE_BITS	27 /* matt - 128 is convenient right now */
 # define MAX_PHYSADDR_BITS	44
-# define MAX_PHYSMEM_BITS	44 /* Can be max 45 bits */
+# define MAX_PHYSMEM_BITS	46
 #endif
 
 #endif /* CONFIG_SPARSEMEM */

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 2 lines · Rik van Riel

Testing: booted it on an x86-64 system with 6GB RAM. Did you really think I had access to a system with 64TB of RAM? :)

No, but it would be good if we could test it under Qemu or KVM with an appropriately set up sparse memory map.

-hpa

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
Quoted 6 lines · H. Peter Anvin
Quoted 2 lines · Rik van Riel

Testing: booted it on an x86-64 system with 6GB RAM. Did you really think I had access to a system with 64TB of RAM? :)

No, but it would be good if we could test it under Qemu or KVM with an appropriately set up sparse memory map.

I don't have a system with 1TB either, which is how much space the memmap[] would take...

Signature · 7 lines
All rights reversed.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw
Quoted 10 lines · Rik van Riel
Quoted 6 lines · H. Peter Anvin
Quoted 2 lines · Rik van Riel

Testing: booted it on an x86-64 system with 6GB RAM. Did you really think I had access to a system with 64TB of RAM? :)

No, but it would be good if we could test it under Qemu or KVM with an appropriately set up sparse memory map.

I don't have a system with 1TB either, which is how much space the memmap[] would take...

Not if the physical layout is sparse. I.e. something silly like:

BIOS-e820: 0000000100000000 - 0000000140000000 (usable)
BIOS-e820: 0000200000000000 - 0000200040000000 (usable)

Which is 1GB of RAM at 4GB physical offset, and another 1GB of RAM at 32 TB physical offset. Takes two gigs of real RAM and a kernel modified with your patch, to not get confused by this :-)

Ingo

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
In reply to Rik van Riel
Quoted 10 lines · Rik van Riel
Quoted 6 lines · H. Peter Anvin
Quoted 2 lines · Rik van Riel

Testing: booted it on an x86-64 system with 6GB RAM. Did you really think I had access to a system with 64TB of RAM? :)

No, but it would be good if we could test it under Qemu or KVM with an appropriately set up sparse memory map.

I don't have a system with 1TB either, which is how much space the memmap[] would take...

Do we really have 1 byte overhead per 64 bytes of RAM?
Pavel

Signature · 8 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#5 lore raw
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Rik van Riel
Quoted 4 lines · H. Peter Anvin
Quoted 2 lines · Rik van Riel

Testing: booted it on an x86-64 system with 6GB RAM. Did you really think I had access to a system with 64TB of RAM? :)

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

No, but it would be good if we could test it under Qemu or KVM with an appropriately set up sparse memory map.

I don't have a system with 1TB either, which is how much space the memmap[] would take...

Do we really have 1 byte overhead per 64 bytes of RAM?
Pavel

Yes, struct page is ~64 bytes, and 64*64 == 4096.

Alas, it's not a problem: my suggestion wasnt to simulate 64 TB of RAM. My suggestion was to create a sparse physical memory map (in a virtual machine) that spreads ~1GB of RAM all around the 64 TB physical address space. That will test whether the kernel is able to map and work with such physical addresses. (which will cover most of the issues)

A good look at /debug/x86/dump_pagetables with such a system booted up would be nice as well - to make sure every virtual memory range is in its proper area, and that there's enough free space around them.

Ingo

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw
Quoted 10 lines · Ingo Molnar

Yes, struct page is ~64 bytes, and 64*64 == 4096.

Alas, it's not a problem: my suggestion wasnt to simulate 64 TB of RAM. My suggestion was to create a sparse physical memory map (in a virtual machine) that spreads ~1GB of RAM all around the 64 TB physical address space. That will test whether the kernel is able to map and work with such physical addresses. (which will cover most of the issues)

Quoted 5 lines

A good look at /debug/x86/dump_pagetables with such a system booted up would be nice as well - to make sure every virtual memory range is in its proper area, and that there's enough free space around them.

We're working on simulating this at Intel. We should hopefully be able to test this next week.

-hpa

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#7 lore raw
Quoted 11 lines · H. Peter Anvin
Quoted 10 lines · Ingo Molnar

Yes, struct page is ~64 bytes, and 64*64 == 4096.

Alas, it's not a problem: my suggestion wasnt to simulate 64 TB of RAM. My suggestion was to create a sparse physical memory map (in a virtual machine) that spreads ~1GB of RAM all around the 64 TB physical address space. That will test whether the kernel is able to map and work with such physical addresses. (which will cover most of the issues)

Quoted 8 lines
Quoted 5 lines

A good look at /debug/x86/dump_pagetables with such a system booted up would be nice as well - to make sure every virtual memory range is in its proper area, and that there's enough free space around them.

We're working on simulating this at Intel. We should hopefully be able to test this next week.

Wow, very nice!

It would be nice to do it on a KVM basis and submit the weird-memory-layout submission to the KVM tree. It would be helpful with the reproduction of weird, memory layout dependent bugs too for example. Plus we could create a test facility that randomizes the physical memory layout (with a given fragmentation level).

Ingo

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw

[tip:x86/mm] x86: 46 bit physical address support on 64 bits

In reply to Rik van Riel
Commit-ID:  c898faf91b3ec6b0f6efa35831b3984fa3331db0
Gitweb:     http://git.kernel.org/tip/c898faf91b3ec6b0f6efa35831b3984fa3331db0
Author:     Rik van Riel <[email protected]>
AuthorDate: Tue, 5 May 2009 17:28:56 -0400
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 5 May 2009 19:10:18 -0700

x86: 46 bit physical address support on 64 bits

Extend the maximum addressable memory on x86-64 from 2^44 to 2^46 bytes. This requires some shuffling around of the vmalloc and virtual memmap memory areas, to keep them away from the direct mapping of up to 64TB of physical memory.

This patch also introduces a guard hole between the vmalloc area and the virtual memory map space. There's really no good reason why we wouldn't have a guard hole there.

[ Impact: future hardware enablement ]

LKML-Reference: <[email protected]>

---
 Documentation/x86/x86_64/mm.txt         |    9 +++++----
 arch/x86/include/asm/page_64_types.h    |    2 +-
 arch/x86/include/asm/pgtable_64_types.h |    8 ++++----
 arch/x86/include/asm/sparsemem.h        |    2 +-
 4 files changed, 11 insertions(+), 10 deletions(-)
Documentation/x86/x86_64/mm.txt +5 -4
index 29b52b1..5394132 100644
@@ -6,10 +6,11 @@ Virtual memory map with 4 level page tables:
 0000000000000000 - 00007fffffffffff (=47 bits) user space, different per mm
 hole caused by [48:63] sign extension
 ffff800000000000 - ffff80ffffffffff (=40 bits) guard hole
-ffff880000000000 - ffffc0ffffffffff (=57 TB) direct mapping of all phys. memory
-ffffc10000000000 - ffffc1ffffffffff (=40 bits) hole
-ffffc20000000000 - ffffe1ffffffffff (=45 bits) vmalloc/ioremap space
-ffffe20000000000 - ffffe2ffffffffff (=40 bits) virtual memory map (1TB)
+ffff880000000000 - ffffc8ffffffffff (=64 TB) direct mapping of all phys. memory
+ffffc80000000000 - ffffc8ffffffffff (=40 bits) hole
+ffffc90000000000 - ffffe8ffffffffff (=45 bits) vmalloc/ioremap space
+ffffe90000000000 - ffffe9ffffffffff (=40 bits) hole
+ffffea0000000000 - ffffeaffffffffff (=40 bits) virtual memory map (1TB)
 ... unused hole ...
 ffffffff80000000 - ffffffffa0000000 (=512 MB)  kernel text mapping, from phys 0
 ffffffffa0000000 - fffffffffff00000 (=1536 MB) module mapping space
arch/x86/include/asm/page_64_types.h +1 -1
index 3f58718..6fadb02 100644
@@ -47,7 +47,7 @@
 #define __START_KERNEL		(__START_KERNEL_map + __PHYSICAL_START)
 #define __START_KERNEL_map	_AC(0xffffffff80000000, UL)
 
-/* See Documentation/x86_64/mm.txt for a description of the memory map. */
+/* See Documentation/x86/x86_64/mm.txt for a description of the memory map. */
 #define __PHYSICAL_MASK_SHIFT	46
 #define __VIRTUAL_MASK_SHIFT	48
 
arch/x86/include/asm/pgtable_64_types.h +4 -4
index fbf42b8..766ea16 100644
@@ -51,11 +51,11 @@ typedef struct { pteval_t pte; } pte_t;
 #define PGDIR_SIZE	(_AC(1, UL) << PGDIR_SHIFT)
 #define PGDIR_MASK	(~(PGDIR_SIZE - 1))
 
-
+/* See Documentation/x86/x86_64/mm.txt for a description of the memory map. */
 #define MAXMEM		 _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL)
-#define VMALLOC_START    _AC(0xffffc20000000000, UL)
-#define VMALLOC_END      _AC(0xffffe1ffffffffff, UL)
-#define VMEMMAP_START	 _AC(0xffffe20000000000, UL)
+#define VMALLOC_START    _AC(0xffffc90000000000, UL)
+#define VMALLOC_END      _AC(0xffffe8ffffffffff, UL)
+#define VMEMMAP_START	 _AC(0xffffea0000000000, UL)
 #define MODULES_VADDR    _AC(0xffffffffa0000000, UL)
 #define MODULES_END      _AC(0xffffffffff000000, UL)
 #define MODULES_LEN   (MODULES_END - MODULES_VADDR)
arch/x86/include/asm/sparsemem.h +1 -1
index e3cc3c0..4517d6b 100644
@@ -27,7 +27,7 @@
 #else /* CONFIG_X86_32 */
 # define SECTION_SIZE_BITS	27 /* matt - 128 is convenient right now */
 # define MAX_PHYSADDR_BITS	44
-# define MAX_PHYSMEM_BITS	44 /* Can be max 45 bits */
+# define MAX_PHYSMEM_BITS	46
 #endif
 
 #endif /* CONFIG_SPARSEMEM */