xref: /OK3568_Linux_fs/kernel/arch/x86/xen/enlighten.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun 
3*4882a593Smuzhiyun #ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG
4*4882a593Smuzhiyun #include <linux/memblock.h>
5*4882a593Smuzhiyun #endif
6*4882a593Smuzhiyun #include <linux/cpu.h>
7*4882a593Smuzhiyun #include <linux/kexec.h>
8*4882a593Smuzhiyun #include <linux/slab.h>
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #include <xen/xen.h>
11*4882a593Smuzhiyun #include <xen/features.h>
12*4882a593Smuzhiyun #include <xen/page.h>
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun #include <asm/xen/hypercall.h>
15*4882a593Smuzhiyun #include <asm/xen/hypervisor.h>
16*4882a593Smuzhiyun #include <asm/cpu.h>
17*4882a593Smuzhiyun #include <asm/e820/api.h>
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #include "xen-ops.h"
20*4882a593Smuzhiyun #include "smp.h"
21*4882a593Smuzhiyun #include "pmu.h"
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(hypercall_page);
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun /*
26*4882a593Smuzhiyun  * Pointer to the xen_vcpu_info structure or
27*4882a593Smuzhiyun  * &HYPERVISOR_shared_info->vcpu_info[cpu]. See xen_hvm_init_shared_info
28*4882a593Smuzhiyun  * and xen_vcpu_setup for details. By default it points to share_info->vcpu_info
29*4882a593Smuzhiyun  * but if the hypervisor supports VCPUOP_register_vcpu_info then it can point
30*4882a593Smuzhiyun  * to xen_vcpu_info. The pointer is used in __xen_evtchn_do_upcall to
31*4882a593Smuzhiyun  * acknowledge pending events.
32*4882a593Smuzhiyun  * Also more subtly it is used by the patched version of irq enable/disable
33*4882a593Smuzhiyun  * e.g. xen_irq_enable_direct and xen_iret in PV mode.
34*4882a593Smuzhiyun  *
35*4882a593Smuzhiyun  * The desire to be able to do those mask/unmask operations as a single
36*4882a593Smuzhiyun  * instruction by using the per-cpu offset held in %gs is the real reason
37*4882a593Smuzhiyun  * vcpu info is in a per-cpu pointer and the original reason for this
38*4882a593Smuzhiyun  * hypercall.
39*4882a593Smuzhiyun  *
40*4882a593Smuzhiyun  */
41*4882a593Smuzhiyun DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun /*
44*4882a593Smuzhiyun  * Per CPU pages used if hypervisor supports VCPUOP_register_vcpu_info
45*4882a593Smuzhiyun  * hypercall. This can be used both in PV and PVHVM mode. The structure
46*4882a593Smuzhiyun  * overrides the default per_cpu(xen_vcpu, cpu) value.
47*4882a593Smuzhiyun  */
48*4882a593Smuzhiyun DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info);
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun /* Linux <-> Xen vCPU id mapping */
51*4882a593Smuzhiyun DEFINE_PER_CPU(uint32_t, xen_vcpu_id);
52*4882a593Smuzhiyun EXPORT_PER_CPU_SYMBOL(xen_vcpu_id);
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun unsigned long *machine_to_phys_mapping = (void *)MACH2PHYS_VIRT_START;
55*4882a593Smuzhiyun EXPORT_SYMBOL(machine_to_phys_mapping);
56*4882a593Smuzhiyun unsigned long  machine_to_phys_nr;
57*4882a593Smuzhiyun EXPORT_SYMBOL(machine_to_phys_nr);
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun struct start_info *xen_start_info;
60*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(xen_start_info);
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun struct shared_info xen_dummy_shared_info;
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun __read_mostly int xen_have_vector_callback;
65*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(xen_have_vector_callback);
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun /*
68*4882a593Smuzhiyun  * NB: These need to live in .data or alike because they're used by
69*4882a593Smuzhiyun  * xen_prepare_pvh() which runs before clearing the bss.
70*4882a593Smuzhiyun  */
71*4882a593Smuzhiyun enum xen_domain_type __ro_after_init xen_domain_type = XEN_NATIVE;
72*4882a593Smuzhiyun EXPORT_SYMBOL_GPL(xen_domain_type);
73*4882a593Smuzhiyun uint32_t xen_start_flags __section(".data") = 0;
74*4882a593Smuzhiyun EXPORT_SYMBOL(xen_start_flags);
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun /*
77*4882a593Smuzhiyun  * Point at some empty memory to start with. We map the real shared_info
78*4882a593Smuzhiyun  * page as soon as fixmap is up and running.
79*4882a593Smuzhiyun  */
80*4882a593Smuzhiyun struct shared_info *HYPERVISOR_shared_info = &xen_dummy_shared_info;
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun /*
83*4882a593Smuzhiyun  * Flag to determine whether vcpu info placement is available on all
84*4882a593Smuzhiyun  * VCPUs.  We assume it is to start with, and then set it to zero on
85*4882a593Smuzhiyun  * the first failure.  This is because it can succeed on some VCPUs
86*4882a593Smuzhiyun  * and not others, since it can involve hypervisor memory allocation,
87*4882a593Smuzhiyun  * or because the guest failed to guarantee all the appropriate
88*4882a593Smuzhiyun  * constraints on all VCPUs (ie buffer can't cross a page boundary).
89*4882a593Smuzhiyun  *
90*4882a593Smuzhiyun  * Note that any particular CPU may be using a placed vcpu structure,
91*4882a593Smuzhiyun  * but we can only optimise if the all are.
92*4882a593Smuzhiyun  *
93*4882a593Smuzhiyun  * 0: not available, 1: available
94*4882a593Smuzhiyun  */
95*4882a593Smuzhiyun int xen_have_vcpu_info_placement = 1;
96*4882a593Smuzhiyun 
xen_cpu_up_online(unsigned int cpu)97*4882a593Smuzhiyun static int xen_cpu_up_online(unsigned int cpu)
98*4882a593Smuzhiyun {
99*4882a593Smuzhiyun 	xen_init_lock_cpu(cpu);
100*4882a593Smuzhiyun 	return 0;
101*4882a593Smuzhiyun }
102*4882a593Smuzhiyun 
xen_cpuhp_setup(int (* cpu_up_prepare_cb)(unsigned int),int (* cpu_dead_cb)(unsigned int))103*4882a593Smuzhiyun int xen_cpuhp_setup(int (*cpu_up_prepare_cb)(unsigned int),
104*4882a593Smuzhiyun 		    int (*cpu_dead_cb)(unsigned int))
105*4882a593Smuzhiyun {
106*4882a593Smuzhiyun 	int rc;
107*4882a593Smuzhiyun 
108*4882a593Smuzhiyun 	rc = cpuhp_setup_state_nocalls(CPUHP_XEN_PREPARE,
109*4882a593Smuzhiyun 				       "x86/xen/guest:prepare",
110*4882a593Smuzhiyun 				       cpu_up_prepare_cb, cpu_dead_cb);
111*4882a593Smuzhiyun 	if (rc >= 0) {
112*4882a593Smuzhiyun 		rc = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
113*4882a593Smuzhiyun 					       "x86/xen/guest:online",
114*4882a593Smuzhiyun 					       xen_cpu_up_online, NULL);
115*4882a593Smuzhiyun 		if (rc < 0)
116*4882a593Smuzhiyun 			cpuhp_remove_state_nocalls(CPUHP_XEN_PREPARE);
117*4882a593Smuzhiyun 	}
118*4882a593Smuzhiyun 
119*4882a593Smuzhiyun 	return rc >= 0 ? 0 : rc;
120*4882a593Smuzhiyun }
121*4882a593Smuzhiyun 
xen_vcpu_setup_restore(int cpu)122*4882a593Smuzhiyun static int xen_vcpu_setup_restore(int cpu)
123*4882a593Smuzhiyun {
124*4882a593Smuzhiyun 	int rc = 0;
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun 	/* Any per_cpu(xen_vcpu) is stale, so reset it */
127*4882a593Smuzhiyun 	xen_vcpu_info_reset(cpu);
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun 	/*
130*4882a593Smuzhiyun 	 * For PVH and PVHVM, setup online VCPUs only. The rest will
131*4882a593Smuzhiyun 	 * be handled by hotplug.
132*4882a593Smuzhiyun 	 */
133*4882a593Smuzhiyun 	if (xen_pv_domain() ||
134*4882a593Smuzhiyun 	    (xen_hvm_domain() && cpu_online(cpu))) {
135*4882a593Smuzhiyun 		rc = xen_vcpu_setup(cpu);
136*4882a593Smuzhiyun 	}
137*4882a593Smuzhiyun 
138*4882a593Smuzhiyun 	return rc;
139*4882a593Smuzhiyun }
140*4882a593Smuzhiyun 
141*4882a593Smuzhiyun /*
142*4882a593Smuzhiyun  * On restore, set the vcpu placement up again.
143*4882a593Smuzhiyun  * If it fails, then we're in a bad state, since
144*4882a593Smuzhiyun  * we can't back out from using it...
145*4882a593Smuzhiyun  */
xen_vcpu_restore(void)146*4882a593Smuzhiyun void xen_vcpu_restore(void)
147*4882a593Smuzhiyun {
148*4882a593Smuzhiyun 	int cpu, rc;
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun 	for_each_possible_cpu(cpu) {
151*4882a593Smuzhiyun 		bool other_cpu = (cpu != smp_processor_id());
152*4882a593Smuzhiyun 		bool is_up;
153*4882a593Smuzhiyun 
154*4882a593Smuzhiyun 		if (xen_vcpu_nr(cpu) == XEN_VCPU_ID_INVALID)
155*4882a593Smuzhiyun 			continue;
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun 		/* Only Xen 4.5 and higher support this. */
158*4882a593Smuzhiyun 		is_up = HYPERVISOR_vcpu_op(VCPUOP_is_up,
159*4882a593Smuzhiyun 					   xen_vcpu_nr(cpu), NULL) > 0;
160*4882a593Smuzhiyun 
161*4882a593Smuzhiyun 		if (other_cpu && is_up &&
162*4882a593Smuzhiyun 		    HYPERVISOR_vcpu_op(VCPUOP_down, xen_vcpu_nr(cpu), NULL))
163*4882a593Smuzhiyun 			BUG();
164*4882a593Smuzhiyun 
165*4882a593Smuzhiyun 		if (xen_pv_domain() || xen_feature(XENFEAT_hvm_safe_pvclock))
166*4882a593Smuzhiyun 			xen_setup_runstate_info(cpu);
167*4882a593Smuzhiyun 
168*4882a593Smuzhiyun 		rc = xen_vcpu_setup_restore(cpu);
169*4882a593Smuzhiyun 		if (rc)
170*4882a593Smuzhiyun 			pr_emerg_once("vcpu restore failed for cpu=%d err=%d. "
171*4882a593Smuzhiyun 					"System will hang.\n", cpu, rc);
172*4882a593Smuzhiyun 		/*
173*4882a593Smuzhiyun 		 * In case xen_vcpu_setup_restore() fails, do not bring up the
174*4882a593Smuzhiyun 		 * VCPU. This helps us avoid the resulting OOPS when the VCPU
175*4882a593Smuzhiyun 		 * accesses pvclock_vcpu_time via xen_vcpu (which is NULL.)
176*4882a593Smuzhiyun 		 * Note that this does not improve the situation much -- now the
177*4882a593Smuzhiyun 		 * VM hangs instead of OOPSing -- with the VCPUs that did not
178*4882a593Smuzhiyun 		 * fail, spinning in stop_machine(), waiting for the failed
179*4882a593Smuzhiyun 		 * VCPUs to come up.
180*4882a593Smuzhiyun 		 */
181*4882a593Smuzhiyun 		if (other_cpu && is_up && (rc == 0) &&
182*4882a593Smuzhiyun 		    HYPERVISOR_vcpu_op(VCPUOP_up, xen_vcpu_nr(cpu), NULL))
183*4882a593Smuzhiyun 			BUG();
184*4882a593Smuzhiyun 	}
185*4882a593Smuzhiyun }
186*4882a593Smuzhiyun 
xen_vcpu_info_reset(int cpu)187*4882a593Smuzhiyun void xen_vcpu_info_reset(int cpu)
188*4882a593Smuzhiyun {
189*4882a593Smuzhiyun 	if (xen_vcpu_nr(cpu) < MAX_VIRT_CPUS) {
190*4882a593Smuzhiyun 		per_cpu(xen_vcpu, cpu) =
191*4882a593Smuzhiyun 			&HYPERVISOR_shared_info->vcpu_info[xen_vcpu_nr(cpu)];
192*4882a593Smuzhiyun 	} else {
193*4882a593Smuzhiyun 		/* Set to NULL so that if somebody accesses it we get an OOPS */
194*4882a593Smuzhiyun 		per_cpu(xen_vcpu, cpu) = NULL;
195*4882a593Smuzhiyun 	}
196*4882a593Smuzhiyun }
197*4882a593Smuzhiyun 
xen_vcpu_setup(int cpu)198*4882a593Smuzhiyun int xen_vcpu_setup(int cpu)
199*4882a593Smuzhiyun {
200*4882a593Smuzhiyun 	struct vcpu_register_vcpu_info info;
201*4882a593Smuzhiyun 	int err;
202*4882a593Smuzhiyun 	struct vcpu_info *vcpup;
203*4882a593Smuzhiyun 
204*4882a593Smuzhiyun 	BUG_ON(HYPERVISOR_shared_info == &xen_dummy_shared_info);
205*4882a593Smuzhiyun 
206*4882a593Smuzhiyun 	/*
207*4882a593Smuzhiyun 	 * This path is called on PVHVM at bootup (xen_hvm_smp_prepare_boot_cpu)
208*4882a593Smuzhiyun 	 * and at restore (xen_vcpu_restore). Also called for hotplugged
209*4882a593Smuzhiyun 	 * VCPUs (cpu_init -> xen_hvm_cpu_prepare_hvm).
210*4882a593Smuzhiyun 	 * However, the hypercall can only be done once (see below) so if a VCPU
211*4882a593Smuzhiyun 	 * is offlined and comes back online then let's not redo the hypercall.
212*4882a593Smuzhiyun 	 *
213*4882a593Smuzhiyun 	 * For PV it is called during restore (xen_vcpu_restore) and bootup
214*4882a593Smuzhiyun 	 * (xen_setup_vcpu_info_placement). The hotplug mechanism does not
215*4882a593Smuzhiyun 	 * use this function.
216*4882a593Smuzhiyun 	 */
217*4882a593Smuzhiyun 	if (xen_hvm_domain()) {
218*4882a593Smuzhiyun 		if (per_cpu(xen_vcpu, cpu) == &per_cpu(xen_vcpu_info, cpu))
219*4882a593Smuzhiyun 			return 0;
220*4882a593Smuzhiyun 	}
221*4882a593Smuzhiyun 
222*4882a593Smuzhiyun 	if (xen_have_vcpu_info_placement) {
223*4882a593Smuzhiyun 		vcpup = &per_cpu(xen_vcpu_info, cpu);
224*4882a593Smuzhiyun 		info.mfn = arbitrary_virt_to_mfn(vcpup);
225*4882a593Smuzhiyun 		info.offset = offset_in_page(vcpup);
226*4882a593Smuzhiyun 
227*4882a593Smuzhiyun 		/*
228*4882a593Smuzhiyun 		 * Check to see if the hypervisor will put the vcpu_info
229*4882a593Smuzhiyun 		 * structure where we want it, which allows direct access via
230*4882a593Smuzhiyun 		 * a percpu-variable.
231*4882a593Smuzhiyun 		 * N.B. This hypercall can _only_ be called once per CPU.
232*4882a593Smuzhiyun 		 * Subsequent calls will error out with -EINVAL. This is due to
233*4882a593Smuzhiyun 		 * the fact that hypervisor has no unregister variant and this
234*4882a593Smuzhiyun 		 * hypercall does not allow to over-write info.mfn and
235*4882a593Smuzhiyun 		 * info.offset.
236*4882a593Smuzhiyun 		 */
237*4882a593Smuzhiyun 		err = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info,
238*4882a593Smuzhiyun 					 xen_vcpu_nr(cpu), &info);
239*4882a593Smuzhiyun 
240*4882a593Smuzhiyun 		if (err) {
241*4882a593Smuzhiyun 			pr_warn_once("register_vcpu_info failed: cpu=%d err=%d\n",
242*4882a593Smuzhiyun 				     cpu, err);
243*4882a593Smuzhiyun 			xen_have_vcpu_info_placement = 0;
244*4882a593Smuzhiyun 		} else {
245*4882a593Smuzhiyun 			/*
246*4882a593Smuzhiyun 			 * This cpu is using the registered vcpu info, even if
247*4882a593Smuzhiyun 			 * later ones fail to.
248*4882a593Smuzhiyun 			 */
249*4882a593Smuzhiyun 			per_cpu(xen_vcpu, cpu) = vcpup;
250*4882a593Smuzhiyun 		}
251*4882a593Smuzhiyun 	}
252*4882a593Smuzhiyun 
253*4882a593Smuzhiyun 	if (!xen_have_vcpu_info_placement)
254*4882a593Smuzhiyun 		xen_vcpu_info_reset(cpu);
255*4882a593Smuzhiyun 
256*4882a593Smuzhiyun 	return ((per_cpu(xen_vcpu, cpu) == NULL) ? -ENODEV : 0);
257*4882a593Smuzhiyun }
258*4882a593Smuzhiyun 
xen_reboot(int reason)259*4882a593Smuzhiyun void xen_reboot(int reason)
260*4882a593Smuzhiyun {
261*4882a593Smuzhiyun 	struct sched_shutdown r = { .reason = reason };
262*4882a593Smuzhiyun 	int cpu;
263*4882a593Smuzhiyun 
264*4882a593Smuzhiyun 	for_each_online_cpu(cpu)
265*4882a593Smuzhiyun 		xen_pmu_finish(cpu);
266*4882a593Smuzhiyun 
267*4882a593Smuzhiyun 	if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
268*4882a593Smuzhiyun 		BUG();
269*4882a593Smuzhiyun }
270*4882a593Smuzhiyun 
271*4882a593Smuzhiyun static int reboot_reason = SHUTDOWN_reboot;
272*4882a593Smuzhiyun static bool xen_legacy_crash;
xen_emergency_restart(void)273*4882a593Smuzhiyun void xen_emergency_restart(void)
274*4882a593Smuzhiyun {
275*4882a593Smuzhiyun 	xen_reboot(reboot_reason);
276*4882a593Smuzhiyun }
277*4882a593Smuzhiyun 
278*4882a593Smuzhiyun static int
xen_panic_event(struct notifier_block * this,unsigned long event,void * ptr)279*4882a593Smuzhiyun xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
280*4882a593Smuzhiyun {
281*4882a593Smuzhiyun 	if (!kexec_crash_loaded()) {
282*4882a593Smuzhiyun 		if (xen_legacy_crash)
283*4882a593Smuzhiyun 			xen_reboot(SHUTDOWN_crash);
284*4882a593Smuzhiyun 
285*4882a593Smuzhiyun 		reboot_reason = SHUTDOWN_crash;
286*4882a593Smuzhiyun 
287*4882a593Smuzhiyun 		/*
288*4882a593Smuzhiyun 		 * If panic_timeout==0 then we are supposed to wait forever.
289*4882a593Smuzhiyun 		 * However, to preserve original dom0 behavior we have to drop
290*4882a593Smuzhiyun 		 * into hypervisor. (domU behavior is controlled by its
291*4882a593Smuzhiyun 		 * config file)
292*4882a593Smuzhiyun 		 */
293*4882a593Smuzhiyun 		if (panic_timeout == 0)
294*4882a593Smuzhiyun 			panic_timeout = -1;
295*4882a593Smuzhiyun 	}
296*4882a593Smuzhiyun 	return NOTIFY_DONE;
297*4882a593Smuzhiyun }
298*4882a593Smuzhiyun 
parse_xen_legacy_crash(char * arg)299*4882a593Smuzhiyun static int __init parse_xen_legacy_crash(char *arg)
300*4882a593Smuzhiyun {
301*4882a593Smuzhiyun 	xen_legacy_crash = true;
302*4882a593Smuzhiyun 	return 0;
303*4882a593Smuzhiyun }
304*4882a593Smuzhiyun early_param("xen_legacy_crash", parse_xen_legacy_crash);
305*4882a593Smuzhiyun 
306*4882a593Smuzhiyun static struct notifier_block xen_panic_block = {
307*4882a593Smuzhiyun 	.notifier_call = xen_panic_event,
308*4882a593Smuzhiyun 	.priority = INT_MIN
309*4882a593Smuzhiyun };
310*4882a593Smuzhiyun 
xen_panic_handler_init(void)311*4882a593Smuzhiyun int xen_panic_handler_init(void)
312*4882a593Smuzhiyun {
313*4882a593Smuzhiyun 	atomic_notifier_chain_register(&panic_notifier_list, &xen_panic_block);
314*4882a593Smuzhiyun 	return 0;
315*4882a593Smuzhiyun }
316*4882a593Smuzhiyun 
xen_pin_vcpu(int cpu)317*4882a593Smuzhiyun void xen_pin_vcpu(int cpu)
318*4882a593Smuzhiyun {
319*4882a593Smuzhiyun 	static bool disable_pinning;
320*4882a593Smuzhiyun 	struct sched_pin_override pin_override;
321*4882a593Smuzhiyun 	int ret;
322*4882a593Smuzhiyun 
323*4882a593Smuzhiyun 	if (disable_pinning)
324*4882a593Smuzhiyun 		return;
325*4882a593Smuzhiyun 
326*4882a593Smuzhiyun 	pin_override.pcpu = cpu;
327*4882a593Smuzhiyun 	ret = HYPERVISOR_sched_op(SCHEDOP_pin_override, &pin_override);
328*4882a593Smuzhiyun 
329*4882a593Smuzhiyun 	/* Ignore errors when removing override. */
330*4882a593Smuzhiyun 	if (cpu < 0)
331*4882a593Smuzhiyun 		return;
332*4882a593Smuzhiyun 
333*4882a593Smuzhiyun 	switch (ret) {
334*4882a593Smuzhiyun 	case -ENOSYS:
335*4882a593Smuzhiyun 		pr_warn("Unable to pin on physical cpu %d. In case of problems consider vcpu pinning.\n",
336*4882a593Smuzhiyun 			cpu);
337*4882a593Smuzhiyun 		disable_pinning = true;
338*4882a593Smuzhiyun 		break;
339*4882a593Smuzhiyun 	case -EPERM:
340*4882a593Smuzhiyun 		WARN(1, "Trying to pin vcpu without having privilege to do so\n");
341*4882a593Smuzhiyun 		disable_pinning = true;
342*4882a593Smuzhiyun 		break;
343*4882a593Smuzhiyun 	case -EINVAL:
344*4882a593Smuzhiyun 	case -EBUSY:
345*4882a593Smuzhiyun 		pr_warn("Physical cpu %d not available for pinning. Check Xen cpu configuration.\n",
346*4882a593Smuzhiyun 			cpu);
347*4882a593Smuzhiyun 		break;
348*4882a593Smuzhiyun 	case 0:
349*4882a593Smuzhiyun 		break;
350*4882a593Smuzhiyun 	default:
351*4882a593Smuzhiyun 		WARN(1, "rc %d while trying to pin vcpu\n", ret);
352*4882a593Smuzhiyun 		disable_pinning = true;
353*4882a593Smuzhiyun 	}
354*4882a593Smuzhiyun }
355*4882a593Smuzhiyun 
356*4882a593Smuzhiyun #ifdef CONFIG_HOTPLUG_CPU
xen_arch_register_cpu(int num)357*4882a593Smuzhiyun void xen_arch_register_cpu(int num)
358*4882a593Smuzhiyun {
359*4882a593Smuzhiyun 	arch_register_cpu(num);
360*4882a593Smuzhiyun }
361*4882a593Smuzhiyun EXPORT_SYMBOL(xen_arch_register_cpu);
362*4882a593Smuzhiyun 
xen_arch_unregister_cpu(int num)363*4882a593Smuzhiyun void xen_arch_unregister_cpu(int num)
364*4882a593Smuzhiyun {
365*4882a593Smuzhiyun 	arch_unregister_cpu(num);
366*4882a593Smuzhiyun }
367*4882a593Smuzhiyun EXPORT_SYMBOL(xen_arch_unregister_cpu);
368*4882a593Smuzhiyun #endif
369