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

[Xen-changelog] [xen master] xen/guest: prepare hypervisor ops to use alternative calls



commit a0e1af54ce7492fb267daa46120fc18f814ad4d1
Author:     Roger Pau Monné <roger.pau@xxxxxxxxxx>
AuthorDate: Mon Mar 2 15:37:35 2020 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Mar 2 15:37:35 2020 +0100

    xen/guest: prepare hypervisor ops to use alternative calls
    
    Adapt the hypervisor ops framework so it can be used with the
    alternative calls framework. So far no hooks are modified to make use
    of the alternatives patching, as they are not in any hot path.
    
    No functional change intended.
    
    Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Reviewed-by: Wei Liu <wl@xxxxxxx>
    Reviewed-by: Paul Durrant <pdurrant@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/guest/hyperv/hyperv.c |  2 +-
 xen/arch/x86/guest/hypervisor.c    | 41 +++++++++++++++++++-------------------
 xen/arch/x86/guest/xen/xen.c       |  2 +-
 3 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/xen/arch/x86/guest/hyperv/hyperv.c 
b/xen/arch/x86/guest/hyperv/hyperv.c
index fabc62b0d6..5ad16cf0fe 100644
--- a/xen/arch/x86/guest/hyperv/hyperv.c
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -199,7 +199,7 @@ static void __init e820_fixup(struct e820map *e820)
         panic("Unable to reserve Hyper-V hypercall range\n");
 }
 
-static const struct hypervisor_ops ops = {
+static const struct hypervisor_ops __initconstrel ops = {
     .name = "Hyper-V",
     .setup = setup,
     .ap_setup = ap_setup,
diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
index 5fd433c8d4..647cdb1367 100644
--- a/xen/arch/x86/guest/hypervisor.c
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -24,52 +24,53 @@
 #include <asm/cache.h>
 #include <asm/guest.h>
 
-static const struct hypervisor_ops *__read_mostly ops;
+static struct hypervisor_ops __read_mostly ops;
 
 const char *__init hypervisor_probe(void)
 {
+    const struct hypervisor_ops *fns;
+
     if ( !cpu_has_hypervisor )
         return NULL;
 
-    ops = xg_probe();
-    if ( ops )
-        return ops->name;
+    fns = xg_probe();
+    if ( !fns )
+        /*
+         * Detection of Hyper-V must come after Xen to avoid false positive due
+         * to viridian support
+         */
+        fns = hyperv_probe();
 
-    /*
-     * Detection of Hyper-V must come after Xen to avoid false positive due
-     * to viridian support
-     */
-    ops = hyperv_probe();
-    if ( ops )
-        return ops->name;
+    if ( fns )
+        ops = *fns;
 
-    return NULL;
+    return ops.name;
 }
 
 void __init hypervisor_setup(void)
 {
-    if ( ops && ops->setup )
-        ops->setup();
+    if ( ops.setup )
+        ops.setup();
 }
 
 int hypervisor_ap_setup(void)
 {
-    if ( ops && ops->ap_setup )
-        return ops->ap_setup();
+    if ( ops.ap_setup )
+        return ops.ap_setup();
 
     return 0;
 }
 
 void hypervisor_resume(void)
 {
-    if ( ops && ops->resume )
-        ops->resume();
+    if ( ops.resume )
+        ops.resume();
 }
 
 void __init hypervisor_e820_fixup(struct e820map *e820)
 {
-    if ( ops && ops->e820_fixup )
-        ops->e820_fixup(e820);
+    if ( ops.e820_fixup )
+        ops.e820_fixup(e820);
 }
 
 /*
diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index 3cf8f667a1..e74fd1e995 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -324,7 +324,7 @@ static void __init e820_fixup(struct e820map *e820)
         pv_shim_fixup_e820(e820);
 }
 
-static const struct hypervisor_ops ops = {
+static const struct hypervisor_ops __initconstrel ops = {
     .name = "Xen",
     .setup = setup,
     .ap_setup = ap_setup,
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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