diff mbox series

[v6,02/11] x86/smp: don't online cpu if hypervisor_ap_setup fails

Message ID 20200131174930.31045-3-liuwe@microsoft.com (mailing list archive)
State Superseded
Headers show
Series More Hyper-V infrastructures | expand

Commit Message

Wei Liu Jan. 31, 2020, 5:49 p.m. UTC
Push hypervisor_ap_setup down to smp_callin.

Take the chance to replace xen_guest with cpu_has_hypervisor.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/smpboot.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Wei Liu Feb. 4, 2020, 11:20 a.m. UTC | #1
On Fri, Jan 31, 2020 at 05:49:21PM +0000, Wei Liu wrote:
> Push hypervisor_ap_setup down to smp_callin.
> 
> Take the chance to replace xen_guest with cpu_has_hypervisor.
> 
> Signed-off-by: Wei Liu <liuwe@microsoft.com>
> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> ---
>  xen/arch/x86/smpboot.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
> index c9d1ab4423..93b86a09e9 100644
> --- a/xen/arch/x86/smpboot.c
> +++ b/xen/arch/x86/smpboot.c
> @@ -199,6 +199,13 @@ static void smp_callin(void)
>          goto halt;
>      }
>  
> +    if ( cpu_has_hypervisor && (rc = hypervisor_ap_setup()) != 0 )

In light of a comment made by Roger yesterday, with this change the
ASSERT_UNREACHABLE in hypervisor_ap_setup() stub should be dropped, to
deal with Xen running on a hypervisor with !CONFIG_GUEST.

I have folded in the following diff:

diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h
index b503854c5b..64383f0c3d 100644
--- a/xen/include/asm-x86/guest/hypervisor.h
+++ b/xen/include/asm-x86/guest/hypervisor.h
@@ -44,7 +44,7 @@ void hypervisor_resume(void);

 static inline const char *hypervisor_probe(void) { return NULL; }
 static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); }
-static inline int hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); return 0; }
+static inline int hypervisor_ap_setup(void) { return 0; }
 static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); }
Roger Pau Monné Feb. 4, 2020, 11:23 a.m. UTC | #2
On Tue, Feb 04, 2020 at 11:20:38AM +0000, Wei Liu wrote:
> On Fri, Jan 31, 2020 at 05:49:21PM +0000, Wei Liu wrote:
> > Push hypervisor_ap_setup down to smp_callin.
> > 
> > Take the chance to replace xen_guest with cpu_has_hypervisor.
> > 
> > Signed-off-by: Wei Liu <liuwe@microsoft.com>
> > Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
> > Reviewed-by: Jan Beulich <jbeulich@suse.com>
> > ---
> >  xen/arch/x86/smpboot.c | 10 +++++++---
> >  1 file changed, 7 insertions(+), 3 deletions(-)
> > 
> > diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
> > index c9d1ab4423..93b86a09e9 100644
> > --- a/xen/arch/x86/smpboot.c
> > +++ b/xen/arch/x86/smpboot.c
> > @@ -199,6 +199,13 @@ static void smp_callin(void)
> >          goto halt;
> >      }
> >  
> > +    if ( cpu_has_hypervisor && (rc = hypervisor_ap_setup()) != 0 )
> 
> In light of a comment made by Roger yesterday, with this change the
> ASSERT_UNREACHABLE in hypervisor_ap_setup() stub should be dropped, to
> deal with Xen running on a hypervisor with !CONFIG_GUEST.
> 
> I have folded in the following diff:
> 
> diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h
> index b503854c5b..64383f0c3d 100644
> --- a/xen/include/asm-x86/guest/hypervisor.h
> +++ b/xen/include/asm-x86/guest/hypervisor.h
> @@ -44,7 +44,7 @@ void hypervisor_resume(void);
> 
>  static inline const char *hypervisor_probe(void) { return NULL; }
>  static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); }
> -static inline int hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); return 0; }
> +static inline int hypervisor_ap_setup(void) { return 0; }
>  static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); }

Oh, I didn't notice this one indeed. Please keep my R-b.

Thanks, Roger.
diff mbox series

Patch

diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index c9d1ab4423..93b86a09e9 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -199,6 +199,13 @@  static void smp_callin(void)
         goto halt;
     }
 
+    if ( cpu_has_hypervisor && (rc = hypervisor_ap_setup()) != 0 )
+    {
+        printk("CPU%d: Failed to initialise hypervisor functions. Not coming online.\n", cpu);
+        cpu_error = rc;
+        goto halt;
+    }
+
     if ( (rc = hvm_cpu_up()) != 0 )
     {
         printk("CPU%d: Failed to initialise HVM. Not coming online.\n", cpu);
@@ -371,9 +378,6 @@  void start_secondary(void *unused)
 
     tsx_init(); /* Needs microcode.  May change HLE/RTM feature bits. */
 
-    if ( xen_guest )
-        hypervisor_ap_setup();
-
     smp_callin();
 
     set_cpu_sibling_map(cpu);