Deleted Added
full compact
hvm.c (256071) hvm.c (256073)
1/*
2 * Copyright (c) 2008, 2013 Citrix Systems, Inc.
3 * Copyright (c) 2012 Spectra Logic Corporation
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2008, 2013 Citrix Systems, Inc.
3 * Copyright (c) 2012 Spectra Logic Corporation
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/x86/xen/hvm.c 256071 2013-10-05 19:51:09Z gibbs $");
29__FBSDID("$FreeBSD: head/sys/x86/xen/hvm.c 256073 2013-10-05 23:11:01Z gibbs $");
30
31#include <sys/param.h>
32#include <sys/bus.h>
33#include <sys/kernel.h>
34#include <sys/malloc.h>
35#include <sys/proc.h>
36#include <sys/smp.h>
37#include <sys/systm.h>

--- 701 unchanged lines hidden (view full) ---

739
740static void
741xen_hvm_sysinit(void *arg __unused)
742{
743 xen_hvm_init(XEN_HVM_INIT_COLD);
744}
745
746static void
30
31#include <sys/param.h>
32#include <sys/bus.h>
33#include <sys/kernel.h>
34#include <sys/malloc.h>
35#include <sys/proc.h>
36#include <sys/smp.h>
37#include <sys/systm.h>

--- 701 unchanged lines hidden (view full) ---

739
740static void
741xen_hvm_sysinit(void *arg __unused)
742{
743 xen_hvm_init(XEN_HVM_INIT_COLD);
744}
745
746static void
747xen_set_vcpu_id(void)
748{
749 struct pcpu *pc;
750 int i;
751
752 /* Set vcpu_id to acpi_id */
753 CPU_FOREACH(i) {
754 pc = pcpu_find(i);
755 pc->pc_vcpu_id = pc->pc_acpi_id;
756 if (bootverbose)
757 printf("XEN: CPU %u has VCPU ID %u\n",
758 i, pc->pc_vcpu_id);
759 }
760}
761
762static void
747xen_hvm_cpu_init(void)
748{
749 struct vcpu_register_vcpu_info info;
750 struct vcpu_info *vcpu_info;
751 int cpu, rc;
752
753 if (!xen_domain())
754 return;
755
756 if (DPCPU_GET(vcpu_info) != NULL) {
757 /*
758 * vcpu_info is already set. We're resuming
759 * from a failed migration and our pre-suspend
760 * configuration is still valid.
761 */
762 return;
763 }
764
765 vcpu_info = DPCPU_PTR(vcpu_local_info);
763xen_hvm_cpu_init(void)
764{
765 struct vcpu_register_vcpu_info info;
766 struct vcpu_info *vcpu_info;
767 int cpu, rc;
768
769 if (!xen_domain())
770 return;
771
772 if (DPCPU_GET(vcpu_info) != NULL) {
773 /*
774 * vcpu_info is already set. We're resuming
775 * from a failed migration and our pre-suspend
776 * configuration is still valid.
777 */
778 return;
779 }
780
781 vcpu_info = DPCPU_PTR(vcpu_local_info);
766 cpu = PCPU_GET(acpi_id);
782 cpu = PCPU_GET(vcpu_id);
767 info.mfn = vtophys(vcpu_info) >> PAGE_SHIFT;
768 info.offset = vtophys(vcpu_info) - trunc_page(vtophys(vcpu_info));
769
770 rc = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, cpu, &info);
771 if (rc != 0)
772 DPCPU_SET(vcpu_info, &HYPERVISOR_shared_info->vcpu_info[cpu]);
773 else
774 DPCPU_SET(vcpu_info, vcpu_info);
775}
776
777SYSINIT(xen_hvm_init, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, xen_hvm_sysinit, NULL);
778#ifdef SMP
779SYSINIT(xen_setup_cpus, SI_SUB_SMP, SI_ORDER_FIRST, xen_setup_cpus, NULL);
780#endif
781SYSINIT(xen_hvm_cpu_init, SI_SUB_INTR, SI_ORDER_FIRST, xen_hvm_cpu_init, NULL);
783 info.mfn = vtophys(vcpu_info) >> PAGE_SHIFT;
784 info.offset = vtophys(vcpu_info) - trunc_page(vtophys(vcpu_info));
785
786 rc = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, cpu, &info);
787 if (rc != 0)
788 DPCPU_SET(vcpu_info, &HYPERVISOR_shared_info->vcpu_info[cpu]);
789 else
790 DPCPU_SET(vcpu_info, vcpu_info);
791}
792
793SYSINIT(xen_hvm_init, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, xen_hvm_sysinit, NULL);
794#ifdef SMP
795SYSINIT(xen_setup_cpus, SI_SUB_SMP, SI_ORDER_FIRST, xen_setup_cpus, NULL);
796#endif
797SYSINIT(xen_hvm_cpu_init, SI_SUB_INTR, SI_ORDER_FIRST, xen_hvm_cpu_init, NULL);
798SYSINIT(xen_set_vcpu_id, SI_SUB_CPU, SI_ORDER_ANY, xen_set_vcpu_id, NULL);