Skip to contentSkip to conversation

Fix for xen guest with mem > 3.7G

PATCH Applied Roberto De Ioris 3 participants 8 messages Sep 13, 2008 – Sep 15, 2008

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

Xen domU kernel 2.6.26 and 2.6.27-rc cannot allocate more than 3.7GB of ram on my PAE systems (compiled with gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)).

I have found the problem is in function xen_memory_setup (in arch/x86/xen/setup.c).

It set max_pfn as 'unsigned long' but add_memory_region() takes 'unsigned long long'.

I do not know if it is a compiler problem but this is the simple fix (works on my systems):

setup.c renamed from setup.c.orig +1 -1
@@ -36,7 +36,7 @@
 
 char * __init xen_memory_setup(void)
 {
-	unsigned long max_pfn = xen_start_info->nr_pages;
+	unsigned long long max_pfn = xen_start_info->nr_pages;
 
 	e820.nr_map = 0;
 	add_memory_region(0, LOWMEMSIZE(), E820_RAM);
Signature · 3 lines
Roberto De Ioris
http://unbit.it
JID: [email protected]
#1 lore raw
Quoted 4 lines · Roberto De Ioris

Xen domU kernel 2.6.26 and 2.6.27-rc cannot allocate more than 3.7GB of ram on my PAE systems (compiled with gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)).

Quoted 9 lines

I have found the problem is in function xen_memory_setup (in arch/x86/xen/setup.c).

It set max_pfn as 'unsigned long' but add_memory_region() takes 'unsigned long long'.

I do not know if it is a compiler problem but this is the simple fix (works on my systems):

Thanks very much for the patch. We have a more general fix for this in Ingo's tip.git tree, but I overlooked that this particular problem affected current -rc.

Ingo, this is fixed by the phys_addr_t + PFN_PHYS() patches. Should we send them up to Linus, or do an ad-hoc fix in this one place?

Thanks,
J

Quoted 15 lines
setup.c renamed from setup.c.orig +1 -1
@@ -36,7 +36,7 @@
 
 char * __init xen_memory_setup(void)
 {
-	unsigned long max_pfn = xen_start_info->nr_pages;
+	unsigned long long max_pfn = xen_start_info->nr_pages;
 
 	e820.nr_map = 0;
 	add_memory_region(0, LOWMEMSIZE(), E820_RAM);
#2 lore raw
Quoted 15 lines · Jeremy Fitzhardinge
Quoted 4 lines · Roberto De Ioris

Xen domU kernel 2.6.26 and 2.6.27-rc cannot allocate more than 3.7GB of ram on my PAE systems (compiled with gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)).

Quoted 9 lines

I have found the problem is in function xen_memory_setup (in arch/x86/xen/setup.c).

It set max_pfn as 'unsigned long' but add_memory_region() takes 'unsigned long long'.

I do not know if it is a compiler problem but this is the simple fix (works on my systems):

Quoted 6 lines

Thanks very much for the patch. We have a more general fix for this in Ingo's tip.git tree, but I overlooked that this particular problem affected current -rc.

Ingo, this is fixed by the phys_addr_t + PFN_PHYS() patches. Should we send them up to Linus, or do an ad-hoc fix in this one place?

send an ad-hoc fix please .. the phys_addr_t patches have a too wide impact i think.

Ingo

#3 lore raw

PATCH 1/1 xen: Fix for xen guest with mem > 3.7G

PFN_PHYS() can truncate large addresses unless its passed a suitable large type. This is fixed more generally in the patch series introducing phys_addr_t, but we need a short-term fix to solve a regression.

---
 arch/x86/xen/setup.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

===================================================================

arch/x86/xen/setup.c +1 -1
@@ -42,7 +42,7 @@
 
 	e820.nr_map = 0;
 
-	e820_add_region(0, PFN_PHYS(max_pfn), E820_RAM);
+	e820_add_region(0, PFN_PHYS((u64)max_pfn), E820_RAM);
 
 	/*
 	 * Even though this is normal, usable memory under Xen, reserve
Applied
#4 lore raw

Re: [PATCH] xen: Fix for xen guest with mem > 3.7G

Quoted 7 lines · Jeremy Fitzhardinge

PFN_PHYS() can truncate large addresses unless its passed a suitable large type. This is fixed more generally in the patch series introducing phys_addr_t, but we need a short-term fix to solve a regression.

applied to tip/x86/urgent (see below), thanks guys!

Ingo

-------------->

Quoted 1 line

From 5670a43d710a12fcbbfaefd3991002768b488d82 Mon Sep 17 00:00:00 2001

From: Jeremy Fitzhardinge <[email protected]>
Date: Sun, 14 Sep 2008 07:42:23 -0700
Subject: [PATCH] xen: fix for xen guest with mem > 3.7G

PFN_PHYS() can truncate large addresses unless its passed a suitable large type. This is fixed more generally in the patch series introducing phys_addr_t, but we need a short-term fix to solve a Xen regression reported by Roberto De Ioris.

---
 arch/x86/xen/setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/xen/setup.c +1 -1
index b6acc3a..d679010 100644
@@ -42,7 +42,7 @@ char * __init xen_memory_setup(void)
 
 	e820.nr_map = 0;
 
-	e820_add_region(0, PFN_PHYS(max_pfn), E820_RAM);
+	e820_add_region(0, PFN_PHYS((u64)max_pfn), E820_RAM);
 
 	/*
 	 * Even though this is normal, usable memory under Xen, reserve
#5 lore raw

Re: [PATCH] xen: Fix for xen guest with mem > 3.7G

In reply to Jeremy Fitzhardinge
Quoted 15 lines · Jeremy Fitzhardinge

PFN_PHYS() can truncate large addresses unless its passed a suitable large type. This is fixed more generally in the patch series introducing phys_addr_t, but we need a short-term fix to solve a regression.

---
 arch/x86/xen/setup.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

===================================================================

arch/x86/xen/setup.c line 48

Quoted 8 lines
arch/x86/xen/setup.c +1 -1
@@ -42,7 +42,7 @@
 
 	e820.nr_map = 0;
 
-	e820_add_region(0, PFN_PHYS(max_pfn), E820_RAM);
+	e820_add_region(0, PFN_PHYS((u64)max_pfn), E820_RAM);
 
 	/*
 	 * Even though this is normal, usable memory under Xen, reserve

In this way you pass a 64bit integer to the function, but max_pfn in origin is still 32bit.

max_pfn need to be 64bit to supporto more than 4GB

Quoted 2 lines
Signature · 3 lines
Roberto De Ioris
http://unbit.it
JID: [email protected]
#6 lore raw

Re: [PATCH] xen: Fix for xen guest with mem > 3.7G

Quoted 5 lines · Roberto De Ioris

In this way you pass a 64bit integer to the function, but max_pfn in origin is still 32bit.

max_pfn need to be 64bit to supporto more than 4GB

No, a 32-bit pfn (page frame number) is sufficient for 2^44 bytes of memory. Does this patch work for you?

J

#7 lore raw

Re: [PATCH] xen: Fix for xen guest with mem > 3.7G

Quoted 11 lines · Jeremy Fitzhardinge
Quoted 5 lines · Roberto De Ioris

In this way you pass a 64bit integer to the function, but max_pfn in origin is still 32bit.

max_pfn need to be 64bit to supporto more than 4GB

No, a 32-bit pfn (page frame number) is sufficient for 2^44 bytes of memory. Does this patch work for you?

J

Ops, you are right, pfn is not in bytes ;)

The patch works.

Signature · 3 lines
Roberto De Ioris
http://unbit.it
JID: [email protected]