From owner-svn-src-all@FreeBSD.ORG Tue Mar 11 10:26:54 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 82CA1221; Tue, 11 Mar 2014 10:26:54 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6F9DC7C; Tue, 11 Mar 2014 10:26:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s2BAQsj4023395; Tue, 11 Mar 2014 10:26:54 GMT (envelope-from royger@svn.freebsd.org) Received: (from royger@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s2BAQsq3023394; Tue, 11 Mar 2014 10:26:54 GMT (envelope-from royger@svn.freebsd.org) Message-Id: <201403111026.s2BAQsq3023394@svn.freebsd.org> From: Roger Pau Monné Date: Tue, 11 Mar 2014 10:26:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263013 - head/sys/x86/xen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Mar 2014 10:26:54 -0000 Author: royger Date: Tue Mar 11 10:26:53 2014 New Revision: 263013 URL: http://svnweb.freebsd.org/changeset/base/263013 Log: xen: changes to hvm code in order to support PVH guests On PVH we don't need to init the shared info page, or disable emulated devices. Also, make sure PV IPIs are set before starting the APs. Approved by: gibbs Sponsored by: Citrix Systems R&D x86/xen/hvm.c: - Return early from functions that are no-ops on Xen PVH guests. - In order to make sure PV IPIs are setup before AP startup, initialize them in SI_SUB_SMP-1. Modified: head/sys/x86/xen/hvm.c Modified: head/sys/x86/xen/hvm.c ============================================================================== --- head/sys/x86/xen/hvm.c Tue Mar 11 10:26:16 2014 (r263012) +++ head/sys/x86/xen/hvm.c Tue Mar 11 10:26:53 2014 (r263013) @@ -350,7 +350,7 @@ xen_setup_cpus(void) { int i; - if (!xen_hvm_domain() || !xen_vector_callback_enabled) + if (!xen_vector_callback_enabled) return; #ifdef __amd64__ @@ -422,6 +422,14 @@ xen_hvm_init_shared_info_page(void) { struct xen_add_to_physmap xatp; + if (xen_pv_domain()) { + /* + * Already setup in the PV case, shared_info is passed inside + * of the start_info struct at start of day. + */ + return; + } + if (HYPERVISOR_shared_info == NULL) { HYPERVISOR_shared_info = malloc(PAGE_SIZE, M_XENHVM, M_NOWAIT); if (HYPERVISOR_shared_info == NULL) @@ -498,6 +506,15 @@ enum { static void xen_hvm_disable_emulated_devices(void) { + + if (xen_pv_domain()) { + /* + * No emulated devices in the PV case, so no need to unplug + * anything. + */ + return; + } + if (inw(XEN_MAGIC_IOPORT) != XMI_MAGIC) return; @@ -522,9 +539,19 @@ xen_hvm_init(enum xen_hvm_init_type init if (error != 0) return; + /* + * If xen_domain_type is not set at this point + * it means we are inside a (PV)HVM guest, because + * for PVH the guest type is set much earlier + * (see hammer_time_xen). + */ + if (!xen_domain()) { + xen_domain_type = XEN_HVM_DOMAIN; + vm_guest = VM_GUEST_XEN; + } + setup_xen_features(); cpu_ops = xen_hvm_cpu_ops; - vm_guest = VM_GUEST_XEN; break; case XEN_HVM_INIT_RESUME: if (error != 0) @@ -539,9 +566,15 @@ xen_hvm_init(enum xen_hvm_init_type init } xen_vector_callback_enabled = 0; - xen_domain_type = XEN_HVM_DOMAIN; - xen_hvm_init_shared_info_page(); xen_hvm_set_callback(NULL); + + /* + * On (PV)HVM domains we need to request the hypervisor to + * fill the shared info page, for PVH guest the shared_info page + * is passed inside the start_info struct and is already set, so this + * functions are no-ops. + */ + xen_hvm_init_shared_info_page(); xen_hvm_disable_emulated_devices(); } @@ -573,6 +606,9 @@ xen_set_vcpu_id(void) struct pcpu *pc; int i; + if (!xen_hvm_domain()) + return; + /* Set vcpu_id to acpi_id */ CPU_FOREACH(i) { pc = pcpu_find(i); @@ -616,7 +652,8 @@ xen_hvm_cpu_init(void) SYSINIT(xen_hvm_init, SI_SUB_HYPERVISOR, SI_ORDER_FIRST, xen_hvm_sysinit, NULL); #ifdef SMP -SYSINIT(xen_setup_cpus, SI_SUB_SMP, SI_ORDER_FIRST, xen_setup_cpus, NULL); +/* We need to setup IPIs before APs are started */ +SYSINIT(xen_setup_cpus, SI_SUB_SMP-1, SI_ORDER_FIRST, xen_setup_cpus, NULL); #endif SYSINIT(xen_hvm_cpu_init, SI_SUB_INTR, SI_ORDER_FIRST, xen_hvm_cpu_init, NULL); SYSINIT(xen_set_vcpu_id, SI_SUB_CPU, SI_ORDER_ANY, xen_set_vcpu_id, NULL);