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 last2M 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 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 20/5/08 09:27, "Xin, Xiaohui" <xiaohui.xin@intel.com> wrote:> 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. >The patch may make sense since it avoids needlessly shattering a physical 2MB extent, but actually your underlying EPT logic should be able to handle this shattering anyway. It is allowable to allocate superpages and free 4kB pages and your EPT mis-handling of this case is a bug. I think the underlying Xen fix should be implemented, tested and applied first, before considering this tools patch. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ok, that may make sense, and I will make the patch for it. Thanks Xiaohui ________________________________ From: Keir Fraser [mailto:keir.fraser@eu.citrix.com] Sent: Tuesday, May 20, 2008 4:40 PM To: Xin, Xiaohui Cc: xen-devel@lists.xensource.com Subject: Re: [Xen-devel]about the super page support with EPT On 20/5/08 09:27, "Xin, Xiaohui" <xiaohui.xin@intel.com> wrote: 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 last2M 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. The patch may make sense since it avoids needlessly shattering a physical 2MB extent, but actually your underlying EPT logic should be able to handle this shattering anyway. It is allowable to allocate superpages and free 4kB pages and your EPT mis-handling of this case is a bug. I think the underlying Xen fix should be implemented, tested and applied first, before considering this tools patch. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel