x86/xen: fix percpu vcpu_info allocation
[platform/kernel/linux-starfive.git] / arch / x86 / xen / enlighten.c
index 0337392..3c61bb9 100644 (file)
@@ -33,9 +33,12 @@ EXPORT_SYMBOL_GPL(hypercall_page);
  * and xen_vcpu_setup for details. By default it points to share_info->vcpu_info
  * but during boot it is switched to point to xen_vcpu_info.
  * The pointer is used in xen_evtchn_do_upcall to acknowledge pending events.
+ * Make sure that xen_vcpu_info doesn't cross a page boundary by making it
+ * cache-line aligned (the struct is guaranteed to have a size of 64 bytes,
+ * which matches the cache line size of 64-bit x86 processors).
  */
 DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
-DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info);
+DEFINE_PER_CPU_ALIGNED(struct vcpu_info, xen_vcpu_info);
 
 /* Linux <-> Xen vCPU id mapping */
 DEFINE_PER_CPU(uint32_t, xen_vcpu_id);
@@ -160,6 +163,7 @@ void xen_vcpu_setup(int cpu)
        int err;
        struct vcpu_info *vcpup;
 
+       BUILD_BUG_ON(sizeof(*vcpup) > SMP_CACHE_BYTES);
        BUG_ON(HYPERVISOR_shared_info == &xen_dummy_shared_info);
 
        /*