Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Sep 2018 07:12:16 +0000 (UTC)
From:      =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= <royger@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r338629 - head/sys/x86/xen
Message-ID:  <201809130712.w8D7CGhR025392@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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();



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201809130712.w8D7CGhR025392>