All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Paul Durrant <pdurrant@amazon.com>,
	Jan Beulich <jbeulich@suse.com>, Wei Liu <wl@xen.org>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH v5 6/7] xen/guest: prepare hypervisor ops to use alternative calls
Date: Wed, 19 Feb 2020 18:43:53 +0100	[thread overview]
Message-ID: <20200219174354.84726-7-roger.pau@citrix.com> (raw)
In-Reply-To: <20200219174354.84726-1-roger.pau@citrix.com>

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@citrix.com>
Reviewed-by: Wei Liu <wl@xen.org>
Reviewed-by: Paul Durrant <pdurrant@amazon.com>
---
Changes since v3:
 - New in this version.
---
 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..70f4cd5ae0 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 __initdata 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..f151b07548 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 __initdata ops = {
     .name = "Xen",
     .setup = setup,
     .ap_setup = ap_setup,
-- 
2.25.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2020-02-19 17:45 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-19 17:43 [Xen-devel] [PATCH v5 0/7] x86: improve assisted tlb flush and use it in guest mode Roger Pau Monne
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 1/7] x86/hvm: allow ASID flush when v != current Roger Pau Monne
2020-02-28 13:29   ` Jan Beulich
2020-02-28 15:27     ` Roger Pau Monné
2020-02-28 15:47       ` Jan Beulich
2020-02-28 16:20         ` Roger Pau Monné
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 2/7] x86/paging: add TLB flush hooks Roger Pau Monne
2020-02-28 14:50   ` Jan Beulich
2020-02-28 16:19     ` Roger Pau Monné
2020-02-28 16:40       ` Jan Beulich
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 3/7] x86/hap: improve hypervisor assisted guest TLB flush Roger Pau Monne
2020-02-28 13:58   ` Jan Beulich
2020-02-28 16:31     ` Roger Pau Monné
2020-02-28 16:44       ` Jan Beulich
2020-02-28 16:57         ` Roger Pau Monné
2020-02-28 17:02           ` Jan Beulich
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 4/7] x86/tlb: introduce a flush guests TLB flag Roger Pau Monne
2020-02-28 16:14   ` Jan Beulich
2020-02-28 16:50     ` Roger Pau Monné
2020-03-02 10:31       ` Jan Beulich
2020-03-02 16:50         ` Roger Pau Monné
2020-03-03  8:50           ` Jan Beulich
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 5/7] x86/tlb: allow disabling the TLB clock Roger Pau Monne
2020-02-28 16:25   ` Jan Beulich
2020-02-19 17:43 ` Roger Pau Monne [this message]
2020-02-28 16:29   ` [Xen-devel] [PATCH v5 6/7] xen/guest: prepare hypervisor ops to use alternative calls Jan Beulich
2020-02-28 16:52     ` Roger Pau Monné
2020-03-02 10:43       ` Jan Beulich
2020-03-02 11:48         ` Roger Pau Monné
2020-02-19 17:43 ` [Xen-devel] [PATCH v5 7/7] x86/tlb: use Xen L0 assisted TLB flush when available Roger Pau Monne
2020-02-28 17:00   ` Jan Beulich
2020-02-28 17:23     ` Roger Pau Monné
2020-03-02 10:52       ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200219174354.84726-7-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=pdurrant@amazon.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.