]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
xen/pvshim: support vCPU hotplug
authorRoger Pau Monne <roger.pau@citrix.com>
Tue, 12 Dec 2017 16:09:11 +0000 (16:09 +0000)
committerRoger Pau Monne <roger.pau@citrix.com>
Wed, 13 Dec 2017 09:33:38 +0000 (09:33 +0000)
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/pv/shim.c
xen/common/domain.c
xen/include/asm-x86/pv/shim.h
xen/include/xen/domain.h

index 10f261da87636147eb5f858c242e7f5d89fca108..49d5f1f70213781bee8c463e486492f26f1d3b82 100644 (file)
@@ -747,6 +747,20 @@ long pv_shim_grant_table_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) uop,
     return rc;
 }
 
+long pv_shim_cpu_up(void *data)
+{
+    struct vcpu *v = data;
+    long rc;
+
+    BUG_ON(smp_processor_id() != 0);
+
+    rc = cpu_up_helper((void *)(unsigned long)v->vcpu_id);
+    if ( rc )
+        return rc;
+
+    return vcpu_up(v);
+}
+
 domid_t get_dom0_domid(void)
 {
     uint32_t eax, ebx, ecx, edx;
index 257fbbf769c58f3b1c51a81ae2d7869b18ebd468..e81fa193a47b0a9aeb908fe0ed954157a88adfe0 100644 (file)
@@ -1278,6 +1278,23 @@ int default_initialise_vcpu(struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg)
     return rc;
 }
 
+int vcpu_up(struct vcpu *v)
+{
+    bool wake = false;
+    int rc = 0;
+
+    domain_lock(v->domain);
+    if ( !v->is_initialised )
+        rc = -EINVAL;
+    else
+        wake = test_and_clear_bit(_VPF_down, &v->pause_flags);
+    domain_unlock(v->domain);
+    if ( wake )
+        vcpu_wake(v);
+
+    return rc;
+}
+
 long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
 {
     struct domain *d = current->domain;
@@ -1300,22 +1317,21 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
 
         break;
 
-    case VCPUOP_up: {
-        bool_t wake = 0;
-        domain_lock(d);
-        if ( !v->is_initialised )
-            rc = -EINVAL;
+    case VCPUOP_up:
+        if ( pv_shim && !cpu_online(v->vcpu_id) )
+            rc = continue_hypercall_on_cpu(0, pv_shim_cpu_up, v);
         else
-            wake = test_and_clear_bit(_VPF_down, &v->pause_flags);
-        domain_unlock(d);
-        if ( wake )
-            vcpu_wake(v);
+            rc = vcpu_up(v);
+
         break;
-    }
 
     case VCPUOP_down:
         if ( !test_and_set_bit(_VPF_down, &v->pause_flags) )
             vcpu_sleep_nosync(v);
+        if ( pv_shim && cpu_online(v->vcpu_id) )
+            rc = continue_hypercall_on_cpu(0, cpu_down_helper,
+                                           (void *)(unsigned long)v->vcpu_id);
+
         break;
 
     case VCPUOP_is_up:
index ea8484886111352c6fc2af6b998681caa142adad..fbee6c863e32de8ecde5ccfa72cddca120296e20 100644 (file)
@@ -40,6 +40,7 @@ long pv_shim_event_channel_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg);
 void pv_shim_inject_evtchn(unsigned int port);
 long pv_shim_grant_table_op(unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) uop,
                             unsigned int count, bool compat);
+long pv_shim_cpu_up(void *data);
 domid_t get_dom0_domid(void);
 uint64_t pv_shim_mem(uint64_t rsvd);
 
@@ -76,6 +77,11 @@ static inline long pv_shim_grant_table_op(unsigned int cmd,
     ASSERT_UNREACHABLE();
     return 0;
 }
+static inline long pv_shim_cpu_up(void *data)
+{
+    ASSERT_UNREACHABLE();
+    return 0;
+}
 static inline domid_t get_dom0_domid(void)
 {
     return 0;
index 347f2640470b26c77c066831a63f1c5b61149efb..eb62f1dab1a0ca4a240fb6fd978e4a46b93d7ad1 100644 (file)
@@ -17,6 +17,7 @@ struct vcpu *alloc_vcpu(
     struct domain *d, unsigned int vcpu_id, unsigned int cpu_id);
 struct vcpu *alloc_dom0_vcpu0(struct domain *dom0);
 int vcpu_reset(struct vcpu *);
+int vcpu_up(struct vcpu *v);
 
 struct xen_domctl_getdomaininfo;
 void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info);