@@ -44,51 +44,49 @@ static const __initconst struct hypervisor_x86 * const hypervisors[] =
44
44
const struct hypervisor_x86 * x86_hyper ;
45
45
EXPORT_SYMBOL (x86_hyper );
46
46
47
- static inline void __init
47
+ static inline const struct hypervisor_x86 * __init
48
48
detect_hypervisor_vendor (void )
49
49
{
50
- const struct hypervisor_x86 * h , * const * p ;
50
+ const struct hypervisor_x86 * h = NULL , * const * p ;
51
51
uint32_t pri , max_pri = 0 ;
52
52
53
53
for (p = hypervisors ; p < hypervisors + ARRAY_SIZE (hypervisors ); p ++ ) {
54
- h = * p ;
55
- pri = h -> detect ();
56
- if (pri != 0 && pri > max_pri ) {
54
+ pri = (* p )-> detect ();
55
+ if (pri > max_pri ) {
57
56
max_pri = pri ;
58
- x86_hyper = h ;
57
+ h = * p ;
59
58
}
60
59
}
61
60
62
- if (max_pri )
63
- pr_info ("Hypervisor detected: %s\n" , x86_hyper -> name );
61
+ if (h )
62
+ pr_info ("Hypervisor detected: %s\n" , h -> name );
63
+
64
+ return h ;
64
65
}
65
66
66
- void __init init_hypervisor_platform ( void )
67
+ static void __init copy_array ( const void * src , void * target , unsigned int size )
67
68
{
69
+ unsigned int i , n = size / sizeof (void * );
70
+ const void * const * from = (const void * const * )src ;
71
+ const void * * to = (const void * * )target ;
68
72
69
- detect_hypervisor_vendor ();
70
-
71
- if (!x86_hyper )
72
- return ;
73
-
74
- if (x86_hyper -> init_platform )
75
- x86_hyper -> init_platform ();
73
+ for (i = 0 ; i < n ; i ++ )
74
+ if (from [i ])
75
+ to [i ] = from [i ];
76
76
}
77
77
78
- bool __init hypervisor_x2apic_available (void )
78
+ void __init init_hypervisor_platform (void )
79
79
{
80
- return x86_hyper &&
81
- x86_hyper -> x2apic_available &&
82
- x86_hyper -> x2apic_available ();
83
- }
80
+ const struct hypervisor_x86 * h ;
84
81
85
- void hypervisor_pin_vcpu ( int cpu )
86
- {
87
- if (!x86_hyper )
82
+ h = detect_hypervisor_vendor ();
83
+
84
+ if (!h )
88
85
return ;
89
86
90
- if (x86_hyper -> pin_vcpu )
91
- x86_hyper -> pin_vcpu (cpu );
92
- else
93
- WARN_ONCE (1 , "vcpu pinning requested but not supported!\n" );
87
+ copy_array (& h -> init , & x86_init .hyper , sizeof (h -> init ));
88
+ copy_array (& h -> runtime , & x86_platform .hyper , sizeof (h -> runtime ));
89
+
90
+ x86_hyper = h ;
91
+ x86_init .hyper .init_platform ();
94
92
}
0 commit comments