svn commit: r338629 - head/sys/x86/xen

Roger Pau Monné royger at FreeBSD.org
Thu Sep 13 07:12:17 UTC 2018


Author: royger
Date: Thu Sep 13 07:12:16 2018
New Revision: 338629
URL: https://svnweb.freebsd.org/changeset/base/338629

Log:
  xen: fix setting legacy PVH vcpu id
  
  The recommended way to obtain the vcpu id is using the cpuid
  instruction with a specific leaf value. This leaf value must be
  obtained at runtime, and it's done when populating the hypercall page.
  
  Legacy PVH however will get the hypercall page populated by the
  hypervisor itself before booting, so the cpuid leaf was not actually
  set, thus preventing setting the vcpu id value from cpuid.
  
  Fix this by making sure the cpuid leaf has been probed before
  attempting to set the vcpu id.
  
  Approved by:		re (gjb)
  Sponsored by:		Citrix Systems R&D

Modified:
  head/sys/x86/xen/hvm.c

Modified: head/sys/x86/xen/hvm.c
==============================================================================
--- head/sys/x86/xen/hvm.c	Thu Sep 13 07:11:11 2018	(r338628)
+++ head/sys/x86/xen/hvm.c	Thu Sep 13 07:12:16 2018	(r338629)
@@ -163,6 +163,12 @@ xen_hvm_init_hypercall_stubs(enum xen_hvm_init_type in
 {
 	uint32_t regs[4];
 
+	/* Legacy PVH will get here without the cpuid leaf being set. */
+	if (cpuid_base == 0)
+		cpuid_base = xen_hvm_cpuid_base();
+	if (cpuid_base == 0)
+		return (ENXIO);
+
 	if (xen_domain() && init_type == XEN_HVM_INIT_LATE) {
 		/*
 		 * If the domain type is already set we can assume that the
@@ -172,10 +178,6 @@ xen_hvm_init_hypercall_stubs(enum xen_hvm_init_type in
 		hypervisor_version();
 		return 0;
 	}
-
-	cpuid_base = xen_hvm_cpuid_base();
-	if (cpuid_base == 0)
-		return (ENXIO);
 
 	if (init_type == XEN_HVM_INIT_LATE)
 		hypervisor_version();


More information about the svn-src-head mailing list