diff mbox series

[v5,6/7] xen/guest: prepare hypervisor ops to use alternative calls

Message ID 20200219174354.84726-7-roger.pau@citrix.com (mailing list archive)
State Superseded
Headers show
Series x86: improve assisted tlb flush and use it in guest mode | expand

Commit Message

Roger Pau Monné Feb. 19, 2020, 5:43 p.m. UTC
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(-)

Comments

Jan Beulich Feb. 28, 2020, 4:29 p.m. UTC | #1
On 19.02.2020 18:43, Roger Pau Monne wrote:
> --- 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 = {

This needs to be __initconstrel in order to avoid triggering
(possibly only in the future) section mismatch warnings with
at least some gcc versions. With this and the other instance
adjusted
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan
Roger Pau Monné Feb. 28, 2020, 4:52 p.m. UTC | #2
On Fri, Feb 28, 2020 at 05:29:32PM +0100, Jan Beulich wrote:
> On 19.02.2020 18:43, Roger Pau Monne wrote:
> > --- 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 = {
> 
> This needs to be __initconstrel in order to avoid triggering
> (possibly only in the future) section mismatch warnings with
> at least some gcc versions. With this and the other instance
> adjusted

I can do that when posting a new version, unless you want to pick this
earlier and adjust on commit.

> Reviewed-by: Jan Beulich <jbeulich@suse.com>

Thanks, Roger.
Jan Beulich March 2, 2020, 10:43 a.m. UTC | #3
On 28.02.2020 17:52, Roger Pau Monné wrote:
> On Fri, Feb 28, 2020 at 05:29:32PM +0100, Jan Beulich wrote:
>> On 19.02.2020 18:43, Roger Pau Monne wrote:
>>> --- 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 = {
>>
>> This needs to be __initconstrel in order to avoid triggering
>> (possibly only in the future) section mismatch warnings with
>> at least some gcc versions. With this and the other instance
>> adjusted
> 
> I can do that when posting a new version, unless you want to pick this
> earlier and adjust on commit.

Is this to mean that this 2nd to last patch in the series is
fully independent of the earlier five (also contextually)?
Then of course I'd be fine to make the adjustments and commit.
Please confirm if so.

Jan
Roger Pau Monné March 2, 2020, 11:48 a.m. UTC | #4
On Mon, Mar 02, 2020 at 11:43:14AM +0100, Jan Beulich wrote:
> On 28.02.2020 17:52, Roger Pau Monné wrote:
> > On Fri, Feb 28, 2020 at 05:29:32PM +0100, Jan Beulich wrote:
> >> On 19.02.2020 18:43, Roger Pau Monne wrote:
> >>> --- 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 = {
> >>
> >> This needs to be __initconstrel in order to avoid triggering
> >> (possibly only in the future) section mismatch warnings with
> >> at least some gcc versions. With this and the other instance
> >> adjusted
> > 
> > I can do that when posting a new version, unless you want to pick this
> > earlier and adjust on commit.
> 
> Is this to mean that this 2nd to last patch in the series is
> fully independent of the earlier five (also contextually)?

Right, patches 5 to 7 should be completely independent, as they only
modify code related to Xen running as a guest.

> Then of course I'd be fine to make the adjustments and commit.
> Please confirm if so.

Yes please, do the adjustments on commit if you don't mind.

Thanks, Roger.
diff mbox series

Patch

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,