Skip to contentSkip to conversation

x86/vcpu: Remove struct vcpu allocation restriction when possible

PATCH In review Andrew Cooper 4 participants 4 messages Nov 5, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/vcpu: Remove struct vcpu allocation restriction when possible

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.

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: George Dunlap <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>

v2:
* Plumb struct domain into alloc_vcpu_struct()

---
 xen/arch/arm/domain.c    | 2 +-
 xen/arch/x86/domain.c    | 7 +++++--
 xen/common/domain.c      | 2 +-
 xen/include/xen/domain.h | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)
xen/arch/arm/domain.c +1 -1
index feebbf5..8043287 100644
@@ -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;
 
xen/arch/x86/domain.c +5 -2
index 943f95b..f6fe954 100644
@@ -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;
xen/common/domain.c +1 -1
index b8d4848..d6650f0 100644
@@ -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;
xen/include/xen/domain.h +1 -1
index 5e393fd..33e4148 100644
@@ -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. */
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 05.11.18 at 14:17, <[email protected]> wrote:

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.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v2 1/1
#2 lore raw
In reply to Andrew Cooper
Quoted 7 lines · Andrew Cooper

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.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by on v2 1/1
#3 lore raw
In reply to Andrew Cooper

Hi,

Quoted 15 lines · Andrew Cooper

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.

---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: George Dunlap <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>

Quoted 4 lines

v2:
* Plumb struct domain into alloc_vcpu_struct()

---
  xen/arch/arm/domain.c    | 2 +-
Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel