All,
Attached is a patch to fix the mem= parameter to a Xenified kernel, i.e.
/boot/grub/grub.conf:
title RHEL5 i386 Xen (2.6.18-8.1.3.el5xen)
root (hd0,8)
kernel /boot/xen.gz-2.6.18-8.1.3.el5 com1=115200,8n1
module /boot/vmlinuz-2.6.18-8.1.3.el5xen ro root=LABEL=RHEL5_i386 mem=1G
module /boot/initrd-2.6.18-8.1.3.el5xen.img
While this isn''t a common thing to do, it would be nice if this
"just worked"
the same way it does on bare-metal, without crashing (which is what it currently
does). The problem comes down to this piece of code in
arch/[i386,x86_64]/kernel/setup-xen.c:
/* Make sure we have a correctly sized P->M table. */
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
phys_to_machine_mapping = alloc_bootmem_low_pages(
max_pfn * sizeof(unsigned long));
memset(phys_to_machine_mapping, ~0,
max_pfn * sizeof(unsigned long));
memcpy(phys_to_machine_mapping,
(unsigned long *)xen_start_info->mfn_list,
xen_start_info->nr_pages * sizeof(unsigned long));
free_bootmem(
__pa(xen_start_info->mfn_list),
PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
sizeof(unsigned long))));
There are really 3 cases that need to be considered:
1) max_pfn == xen_start_info->nr_pages - this is the normal case, when no
kernel
or HV parameters are passed when dom0 boots
2) max_pfn > xen_start_info->nr_pages - this is the case when a domU is
started, and maxmem > memory in the configuration file
3) max_pfn < xen_start_info->nr_pages - this is the case when specifying
mem(or highmem= on i386) on the dom0 or domU command line.
The third case is the one that is currently broken. Looking at the code above,
you can see that the array allocated for the p2m table is too small in that
case, and during the subsequent memcpy() can cause a page fault and then an
OOPs. The attached patch handles the third case by decreasing the reservation,
and only copying the appropriate number of entries into the p2m table.
The patch is against a 3.0.3-based 2.6.18 kernel, but should apply with
relatively little problem on current unstable.
Comments/question welcome.
Chris Lalancette
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel