Hi, Keir,
The recent super page support patch checked in met some problem when EPT was
enabled. The patch lost some code during checking in.
From our experience, in EPT enabled situation, we has to split
the last 2M of the guest memory to 4k pages instead of 2M contiguous, the
reason is that, in tools side, 5 special pages are located in guest high end
memory, and the guard page will be decreased then. It will result to set the
p2m entry with order 0 to be invalid, in normal logic, this will result to set
the whole 2m p2m entry with order 9 to be invalid, then all the other 4k pages
in the last 2M cannot be accessed. The end result is that we will get “Bad
address” error when we create guest with EPT.
Following is the patch we handle it, please comments.
diff -r af77354c03e4 tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c Tue May 20 22:37:05
2008 +0800
+++ b/tools/libxc/xc_hvm_build.c Wed
May 21 00:05:15 2008 +0800
@@ -220,10 +220,10 @@ static int setup_guest(int xc_handle,
rc =
xc_domain_memory_populate_physmap(
xc_handle,
dom, 0xa0, 0, 0, &page_array[0x00]);
cur_pages = 0xc0;
- while ( (rc == 0) && (nr_pages
> cur_pages) )
+ while ( (rc == 0) && (nr_pages -
0x200 > cur_pages) )
{
/* Clip
count to maximum 8MB extent. */
- unsigned long
count = nr_pages - cur_pages;
+ unsigned long
count = nr_pages - 0x200 - cur_pages;
if ( count
> 2048 )
count = 2048;
@@ -266,6 +266,12 @@ static int setup_guest(int xc_handle,
}
}
+ if ( nr_pages - cur_pages )
+ {
+ rc =
xc_domain_memory_populate_physmap(
+
xc_handle, dom, nr_pages - cur_pages, 0, 0, &page_array[cur_pages]);
+ }
+
if ( rc != 0 )
{
PERROR("Could not allocate memory for HVM guest.\n");
Thanks
Xiaohui