Skip to contentSkip to conversation

x86/guest/xen: only set HVM parameter on BSP

PATCH In review Wei Liu 3 participants 3 messages Feb 5, 2020 – Feb 6, 2020

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 x86/guest/xen: only set HVM parameter on BSP

There is no need for every CPU to set a guest property.

---
 xen/arch/x86/guest/xen/xen.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
xen/arch/x86/guest/xen/xen.c +13 -9
index 1f868f2f8d..3cf8f667a1 100644
@@ -206,11 +206,6 @@ static int init_evtchn(void)
 {
     static uint8_t evtchn_upcall_vector;
     int rc;
-    struct xen_hvm_param a = {
-        .domid = DOMID_SELF,
-        .index = HVM_PARAM_CALLBACK_IRQ,
-        .value = 1,
-    };
 
     if ( !evtchn_upcall_vector )
         alloc_direct_apic_vector(&evtchn_upcall_vector, xen_evtchn_upcall);
@@ -225,10 +220,19 @@ static int init_evtchn(void)
         return rc;
     }
 
-    /* Trick toolstack to think we are enlightened */
-    rc = xen_hypercall_hvm_op(HVMOP_set_param, &a);
-    if ( rc )
-        printk("Unable to set HVM_PARAM_CALLBACK_IRQ\n");
+    if ( smp_processor_id() == 0 )
+    {
+        struct xen_hvm_param a = {
+            .domid = DOMID_SELF,
+            .index = HVM_PARAM_CALLBACK_IRQ,
+            .value = 1,
+        };
+
+        /* Trick toolstack to think we are enlightened */
+        rc = xen_hypercall_hvm_op(HVMOP_set_param, &a);
+        if ( rc )
+            printk("Unable to set HVM_PARAM_CALLBACK_IRQ\n");
+    }
 
     return rc;
 }
Signature · 7 lines
2.20.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#2 lore raw
In reply to Wei Liu
Quoted 3 lines · Wei Liu

There is no need for every CPU to set a guest property.

I will send a patch shortly to introduce an IS_BSP macro, as it would make the code clearer IMO.

Thanks, Roger.

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