]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
x86/xen: use xen_vcpu_id mapping for HYPERVISOR_vcpu_op
authorVitaly Kuznetsov <vkuznets@redhat.com>
Thu, 30 Jun 2016 15:56:38 +0000 (17:56 +0200)
committerBob Liu <bob.liu@oracle.com>
Thu, 20 Oct 2016 08:02:22 +0000 (04:02 -0400)
HYPERVISOR_vcpu_op() passes Linux's idea of vCPU id as a parameter
while Xen's idea is expected. In some cases these ideas diverge so we
need to do remapping.

Convert all callers of HYPERVISOR_vcpu_op() to use xen_vcpu_nr().

Leave xen_fill_possible_map() and xen_filter_cpu_maps() intact as
they're only being called by PV guests before perpu areas are
initialized. While the issue could be solved by switching to
early_percpu for xen_vcpu_id I think it's not worth it: PV guests will
probably never get to the point where their idea of vCPU id diverges
from Xen's.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
(cherry picked from commit ad5475f9faf5186b7f59de2c6481ee3e211f1ed7)
Signed-off-by: Bob Liu <bob.liu@oracle.com>
Orabug: 24820937

 Conflicts:
arch/x86/xen/enlighten.c
arch/x86/xen/time.c

arch/arm/xen/enlighten.c
arch/x86/xen/enlighten.c
arch/x86/xen/irq.c
arch/x86/xen/smp.c
arch/x86/xen/time.c
drivers/xen/events/events_base.c
drivers/xen/time.c

index a19260266c27de3a13f5127f7ce6964f4723ceb8..1f26b623b59bf35a257e7effda5cfa49a3322507 100644 (file)
@@ -171,7 +171,8 @@ static void xen_percpu_init(void)
        info.mfn = virt_to_gfn(vcpup);
        info.offset = xen_offset_in_page(vcpup);
 
-       err = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, cpu, &info);
+       err = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, xen_vcpu_nr(cpu),
+                                &info);
        BUG_ON(err);
        per_cpu(xen_vcpu, cpu) = vcpup;
 
index d8e05dc7ecddf79cbaea09579785cd79a8671519..eb6d6dc8148e937d3923ae01396138883d4e3005 100644 (file)
@@ -228,7 +228,8 @@ static void xen_vcpu_setup(int cpu)
           hypervisor has no unregister variant and this hypercall does not
           allow to over-write info.mfn and info.offset.
         */
-       err = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, cpu, &info);
+       err = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, xen_vcpu_nr(cpu),
+                                &info);
 
        if (err) {
                printk(KERN_DEBUG "register_vcpu_info failed: err=%d\n", err);
@@ -263,10 +264,10 @@ void xen_vcpu_restore(void)
                bool is_up = false;
 
                if (vcpuops)
-                       is_up = HYPERVISOR_vcpu_op(VCPUOP_is_up, cpu, NULL);
+                       is_up = HYPERVISOR_vcpu_op(VCPUOP_is_up, xen_vcpu_nr(cpu), NULL);
 
                if (vcpuops && other_cpu && is_up &&
-                   HYPERVISOR_vcpu_op(VCPUOP_down, cpu, NULL))
+                   HYPERVISOR_vcpu_op(VCPUOP_down, xen_vcpu_nr(cpu), NULL))
                        BUG();
 
                xen_setup_runstate_info(cpu);
@@ -275,7 +276,7 @@ void xen_vcpu_restore(void)
                        xen_vcpu_setup(cpu);
 
                if (vcpuops && other_cpu && is_up &&
-                   HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL))
+                   HYPERVISOR_vcpu_op(VCPUOP_up, xen_vcpu_nr(cpu), NULL))
                        BUG();
        }
 }
index a1207cb6472a90ce9e57deeb1bd63eb8ebd74c4d..33e92955e09d0ab7d202e3cb4d6fb154ddee5cbe 100644 (file)
@@ -109,7 +109,8 @@ static void xen_safe_halt(void)
 static void xen_halt(void)
 {
        if (irqs_disabled())
-               HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
+               HYPERVISOR_vcpu_op(VCPUOP_down,
+                                  xen_vcpu_nr(smp_processor_id()), NULL);
        else
                xen_safe_halt();
 }
index 06ffef70c64bd3cf513c14b17c2ec3e72b07441f..182f7f6e9a2e850e996f7368c388fd01bb07e1a2 100644 (file)
@@ -458,7 +458,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
 #endif
        ctxt->user_regs.esp = idle->thread.sp0 - sizeof(struct pt_regs);
        ctxt->ctrlreg[3] = xen_pfn_to_cr3(virt_to_gfn(swapper_pg_dir));
-       if (HYPERVISOR_vcpu_op(VCPUOP_initialise, cpu, ctxt))
+       if (HYPERVISOR_vcpu_op(VCPUOP_initialise, xen_vcpu_nr(cpu), ctxt))
                BUG();
 
        kfree(ctxt);
@@ -496,7 +496,7 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
        if (rc)
                return rc;
 
-       rc = HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL);
+       rc = HYPERVISOR_vcpu_op(VCPUOP_up, xen_vcpu_nr(cpu), NULL);
        BUG_ON(rc);
 
        while (cpu_report_state(cpu) != CPU_ONLINE)
@@ -524,7 +524,8 @@ static int xen_cpu_disable(void)
 
 static void xen_cpu_die(unsigned int cpu)
 {
-       while (xen_pv_domain() && HYPERVISOR_vcpu_op(VCPUOP_is_up, cpu, NULL)) {
+       while (xen_pv_domain() && HYPERVISOR_vcpu_op(VCPUOP_is_up,
+                                                    xen_vcpu_nr(cpu), NULL)) {
                __set_current_state(TASK_UNINTERRUPTIBLE);
                schedule_timeout(HZ/10);
        }
@@ -540,7 +541,7 @@ static void xen_cpu_die(unsigned int cpu)
 static void xen_play_dead(void) /* used only with HOTPLUG_CPU */
 {
        play_dead_common();
-       HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
+       HYPERVISOR_vcpu_op(VCPUOP_down, xen_vcpu_nr(smp_processor_id()), NULL);
        cpu_bringup();
        /*
         * commit 4b0c0f294 (tick: Cleanup NOHZ per cpu data on cpu down)
@@ -578,7 +579,7 @@ static void stop_self(void *v)
 
        set_cpu_online(cpu, false);
 
-       HYPERVISOR_vcpu_op(VCPUOP_down, cpu, NULL);
+       HYPERVISOR_vcpu_op(VCPUOP_down, xen_vcpu_nr(cpu), NULL);
        BUG();
 }
 
index 33659e3276138763560d4d17434130a65486759d..ae8a641d4bd1569054835a9241f447166d3e7849 100644 (file)
@@ -231,8 +231,6 @@ static const struct clock_event_device xen_timerop_clockevent = {
        .set_next_event = xen_timerop_set_next_event,
 };
 
-
-
 static void xen_vcpuop_set_mode(enum clock_event_mode mode,
                                struct clock_event_device *evt)
 {
@@ -242,16 +240,15 @@ static void xen_vcpuop_set_mode(enum clock_event_mode mode,
        case CLOCK_EVT_MODE_PERIODIC:
                WARN_ON(1);     /* unsupported */
                break;
-
        case CLOCK_EVT_MODE_ONESHOT:
-               if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
+               if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, xen_vcpu_nr(cpu), NULL))
                        BUG();
                break;
 
        case CLOCK_EVT_MODE_UNUSED:
        case CLOCK_EVT_MODE_SHUTDOWN:
-               if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, cpu, NULL) ||
-                   HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
+               if (HYPERVISOR_vcpu_op(VCPUOP_stop_singleshot_timer, xen_vcpu_nr(cpu), NULL) ||
+                   HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, xen_vcpu_nr(cpu), NULL))
                        BUG();
                break;
        case CLOCK_EVT_MODE_RESUME:
@@ -272,7 +269,8 @@ static int xen_vcpuop_set_next_event(unsigned long delta,
        /* Get an event anyway, even if the timeout is already expired */
        single.flags = 0;
 
-       ret = HYPERVISOR_vcpu_op(VCPUOP_set_singleshot_timer, cpu, &single);
+       ret = HYPERVISOR_vcpu_op(VCPUOP_set_singleshot_timer, xen_vcpu_nr(cpu),
+                                &single);
        BUG_ON(ret != 0);
 
        return ret;
@@ -370,7 +368,8 @@ void xen_timer_resume(void)
                return;
 
        for_each_online_cpu(cpu) {
-               if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
+               if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer,
+                                      xen_vcpu_nr(cpu), NULL))
                        BUG();
        }
 }
@@ -390,7 +389,8 @@ static void __init xen_time_init(void)
 
        clocksource_register_hz(&xen_clocksource, NSEC_PER_SEC);
 
-       if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL) == 0) {
+       if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, xen_vcpu_nr(cpu),
+                              NULL) == 0) {
                /* Successfully turned off 100Hz tick, so we have the
                   vcpuop-based timer interface */
                printk(KERN_DEBUG "Xen: using vcpuop timer interface\n");
index b4a47a57e706366c06aa6dccd1fcc51f6b02e6f7..ac6975c0e5d2fa1720d6f36dd22eb9e051c6407d 100644 (file)
@@ -1210,7 +1210,8 @@ void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector)
 
 #ifdef CONFIG_X86
        if (unlikely(vector == XEN_NMI_VECTOR)) {
-               int rc =  HYPERVISOR_vcpu_op(VCPUOP_send_nmi, cpu, NULL);
+               int rc =  HYPERVISOR_vcpu_op(VCPUOP_send_nmi, xen_vcpu_nr(cpu),
+                                            NULL);
                if (rc < 0)
                        printk(KERN_WARNING "Sending nmi to CPU%d failed (rc:%d)\n", cpu, rc);
                return;
index a7fe35b58341240b252464629484cd8004a24886..48c3f698306798bbdcdd42763262d80bf3cec173 100644 (file)
@@ -95,7 +95,7 @@ void xen_setup_runstate_info(int cpu)
        area.addr.v = &per_cpu(xen_runstate, cpu);
 
        if (HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area,
-                              cpu, &area))
+                              xen_vcpu_nr(cpu), &area))
                BUG();
 }