diff mbox series

[v5,03/12] x86/smp: don't online cpu if hypervisor_ap_setup fails

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

Commit Message

Wei Liu Jan. 29, 2020, 8:20 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>
---
 xen/arch/x86/smpboot.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Roger Pau Monne Jan. 30, 2020, 10:10 a.m. UTC | #1
On Wed, Jan 29, 2020 at 08:20:25PM +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>

Thanks, Roger.
Jan Beulich Jan. 31, 2020, 1:53 p.m. UTC | #2
On 29.01.2020 21:20, 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>
> ---
>  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 )
> +    {
> +        printk("CPU%d: Failed to initialise hypervisor functions. Not coming online.\n", cpu);
> +        cpu_error = rc;
> +        goto halt;
> +    }

There are a few things done up from here which may possibly
better come after hypervisor interface setup (the two APIC
related calls in particular). Are you sure you can safely
move it this far down in the function?

Jan
Wei Liu Jan. 31, 2020, 2:10 p.m. UTC | #3
On Fri, Jan 31, 2020 at 02:53:45PM +0100, Jan Beulich wrote:
> On 29.01.2020 21:20, 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>
> > ---
> >  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 )
> > +    {
> > +        printk("CPU%d: Failed to initialise hypervisor functions. Not coming online.\n", cpu);
> > +        cpu_error = rc;
> > +        goto halt;
> > +    }
> 
> There are a few things done up from here which may possibly
> better come after hypervisor interface setup (the two APIC
> related calls in particular). Are you sure you can safely
> move it this far down in the function?

Xen guest's usage of APIC is no different than, say, hvm's usage. If hvm
can be this far down, Xen / Hyper-V can, too.

Furthermore, APIC code has no dependency on guest code.

Wei.

> 
> Jan
Jan Beulich Jan. 31, 2020, 2:34 p.m. UTC | #4
On 31.01.2020 15:10, Wei Liu wrote:
> On Fri, Jan 31, 2020 at 02:53:45PM +0100, Jan Beulich wrote:
>> On 29.01.2020 21:20, 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>
>>> ---
>>>  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 )
>>> +    {
>>> +        printk("CPU%d: Failed to initialise hypervisor functions. Not coming online.\n", cpu);
>>> +        cpu_error = rc;
>>> +        goto halt;
>>> +    }
>>
>> There are a few things done up from here which may possibly
>> better come after hypervisor interface setup (the two APIC
>> related calls in particular). Are you sure you can safely
>> move it this far down in the function?
> 
> Xen guest's usage of APIC is no different than, say, hvm's usage. If hvm
> can be this far down, Xen / Hyper-V can, too.
> 
> Furthermore, APIC code has no dependency on guest code.

Hmm, okay, there's no way for a HVM guest to run without LAPIC
emulation right now. This should be fine then:
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan
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);