[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH for-4.12 4/8] x86/shadow: alloc enough pages so initialization doesn't fail



Current code in shadow_enable will allocate a shadow pool of 4MB
regardless of the values of sh_min_allocation or
shadow_min_acceptable_pages, which means that calls to
shadow_alloc_p2m_page can fail even after the check and allocation
done just above.

Fix this by always checking that the pool is big enough so the rest of
the shadow_init function cannot fail due to lack of pages in the
shadow pool. This is relevant to shadow_alloc_p2m_page which requires
a minimum amount of shadow_min_acceptable_pages(d) + 1 in the pool.

This allows booting a guest using shadow and more than 6 vCPUs.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Tim Deegan <tim@xxxxxxx>
Cc: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
---
I think this should be considered for 4.12, or else attempting to
create a shadow guest with more than 6 vCPUs fails.
---
 xen/arch/x86/mm/shadow/common.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
index c49aeb5e60..78525ddd23 100644
--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -2705,6 +2705,11 @@ int shadow_enable(struct domain *d, u32 mode)
     uint32_t *e;
     int rv = 0;
     struct p2m_domain *p2m = p2m_get_hostp2m(d);
+    /*
+     * Required minimum amount of pool pages plus 4MB. This is required so the
+     * calls to p2m_alloc_table and shadow_alloc_p2m_page below don't fail.
+     */
+    unsigned int min_pages = shadow_min_acceptable_pages(d) + 1024;
 
     mode |= PG_SH_enable;
 
@@ -2719,10 +2724,10 @@ int shadow_enable(struct domain *d, u32 mode)
 
     /* Init the shadow memory allocation if the user hasn't done so */
     old_pages = d->arch.paging.shadow.total_pages;
-    if ( old_pages < sh_min_allocation(d) + d->arch.paging.shadow.p2m_pages )
+    if ( old_pages < min_pages )
     {
         paging_lock(d);
-        rv = shadow_set_allocation(d, 1024, NULL); /* Use at least 4MB */
+        rv = shadow_set_allocation(d, min_pages, NULL);
         if ( rv != 0 )
         {
             shadow_set_allocation(d, 0, NULL);
-- 
2.20.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.