]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
x86/vcpu: Remove struct vcpu allocation restriction when possible
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 2 Nov 2018 17:46:38 +0000 (17:46 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 5 Nov 2018 17:07:11 +0000 (17:07 +0000)
There is no need for struct vcpu to live below the 4G boundary for PV guests,
or for HVM vcpus using HAP.

Plumb struct domain into alloc_vcpu_struct() so the x86 version can query the
domain's type and paging settings.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/domain.c
xen/arch/x86/domain.c
xen/common/domain.c
xen/include/xen/domain.h

index feebbf5a921511e3f25d192e4d6d7187c0e7856f..80432872d65d63b8de6fa414e7cde215d7d6c53a 100644 (file)
@@ -516,7 +516,7 @@ void dump_pageframe_info(struct domain *d)
 #define MAX_PAGES_PER_VCPU  1
 #endif
 
-struct vcpu *alloc_vcpu_struct(void)
+struct vcpu *alloc_vcpu_struct(const struct domain *d)
 {
     struct vcpu *v;
 
index 943f95b676b274fa3613c3fbd652004521dca493..f6fe954313e880ad736db2c1c4766a4bc4a26677 100644 (file)
@@ -302,7 +302,7 @@ void free_domain_struct(struct domain *d)
     free_xenheap_page(d);
 }
 
-struct vcpu *alloc_vcpu_struct(void)
+struct vcpu *alloc_vcpu_struct(const struct domain *d)
 {
     struct vcpu *v;
     /*
@@ -311,8 +311,11 @@ struct vcpu *alloc_vcpu_struct(void)
      * may require that the shadow CR3 points below 4GB, and hence the whole
      * structure must satisfy this restriction. Thus we specify MEMF_bits(32).
      */
+    unsigned int memflags =
+        (is_hvm_domain(d) && paging_mode_shadow(d)) ? MEMF_bits(32) : 0;
+
     BUILD_BUG_ON(sizeof(*v) > PAGE_SIZE);
-    v = alloc_xenheap_pages(0, MEMF_bits(32));
+    v = alloc_xenheap_pages(0, memflags);
     if ( v != NULL )
         clear_page(v);
     return v;
index b8d4848970803a084abd6b69f57cea0fd608dd77..d6650f0656b39d6b03fcb6d55917f75f183c8e2d 100644 (file)
@@ -140,7 +140,7 @@ struct vcpu *vcpu_create(
 
     BUG_ON((!is_idle_domain(d) || vcpu_id) && d->vcpu[vcpu_id]);
 
-    if ( (v = alloc_vcpu_struct()) == NULL )
+    if ( (v = alloc_vcpu_struct(d)) == NULL )
         return NULL;
 
     v->domain = d;
index 5e393fd7f245612cf46d384a943f343cabb01ed9..33e41486cb22d7ed7f9423532c7f2d266c629cbc 100644 (file)
@@ -36,7 +36,7 @@ struct domain *alloc_domain_struct(void);
 void free_domain_struct(struct domain *d);
 
 /* Allocate/free a VCPU structure. */
-struct vcpu *alloc_vcpu_struct(void);
+struct vcpu *alloc_vcpu_struct(const struct domain *d);
 void free_vcpu_struct(struct vcpu *v);
 
 /* Allocate/free a PIRQ structure. */