@@ -52,10 +52,12 @@ void __init hypervisor_setup(void)
ops->setup();
}
-void hypervisor_ap_setup(void)
+int hypervisor_ap_setup(void)
{
if ( ops && ops->ap_setup )
- ops->ap_setup();
+ return ops->ap_setup();
+
+ return 0;
}
void hypervisor_resume(void)
@@ -113,16 +113,16 @@ static int map_vcpuinfo(void)
info.mfn = virt_to_mfn(&vcpu_info[vcpu]);
info.offset = (unsigned long)&vcpu_info[vcpu] & ~PAGE_MASK;
rc = xen_hypercall_vcpu_op(VCPUOP_register_vcpu_info, vcpu, &info);
- if ( rc )
- {
- BUG_ON(vcpu >= XEN_LEGACY_MAX_VCPUS);
- this_cpu(vcpu_info) = &XEN_shared_info->vcpu_info[vcpu];
- }
- else
+ if ( !rc )
{
this_cpu(vcpu_info) = &vcpu_info[vcpu];
set_bit(vcpu, vcpu_info_mapped);
}
+ else if ( vcpu < XEN_LEGACY_MAX_VCPUS )
+ {
+ rc = 0;
+ this_cpu(vcpu_info) = &XEN_shared_info->vcpu_info[vcpu];
+ }
return rc;
}
@@ -257,11 +257,17 @@ static void __init setup(void)
init_evtchn();
}
-static void ap_setup(void)
+static int ap_setup(void)
{
+ int rc;
+
set_vcpu_id();
- map_vcpuinfo();
- init_evtchn();
+ rc = map_vcpuinfo();
+
+ if ( !rc )
+ init_evtchn();
+
+ return rc;
}
int xg_alloc_unused_page(mfn_t *mfn)
@@ -25,7 +25,7 @@ struct hypervisor_ops {
/* Main setup routine */
void (*setup)(void);
/* AP setup */
- void (*ap_setup)(void);
+ int (*ap_setup)(void);
/* Resume from suspension */
void (*resume)(void);
};
@@ -34,7 +34,7 @@ struct hypervisor_ops {
const char *hypervisor_probe(void);
void hypervisor_setup(void);
-void hypervisor_ap_setup(void);
+int hypervisor_ap_setup(void);
void hypervisor_resume(void);
#else
@@ -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 void hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); }
+static inline int hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); return 0; }
static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); }
#endif /* CONFIG_GUEST */
We want to be able to handle AP setup error in the upper layer. Signed-off-by: Wei Liu <liuwe@microsoft.com> --- v6: 1. Change map_vcpuinfo as well 2. Make code shorter --- xen/arch/x86/guest/hypervisor.c | 6 ++++-- xen/arch/x86/guest/xen/xen.c | 24 +++++++++++++++--------- xen/include/asm-x86/guest/hypervisor.h | 6 +++--- 3 files changed, 22 insertions(+), 14 deletions(-)