Permalink
Browse files

Correct panic caused by attaching both Xen PV and HyperV virtualization

aware drivers on Xen hypervisors that advertise support for some
HyperV features.

x86/xen/hvm.c:
	When running in HVM mode on a Xen hypervisor, set vm_guest
	to VM_GUEST_XEN so other virtualization aware components in
	the FreeBSD kernel can detect this mode is active.

dev/hyperv/vmbus/hv_hv.c:
	Use vm_guest to ignore Xen's HyperV emulation when Xen is
	detected and Xen PV drivers are active.

Reported by:	Shanker Balan
Submitted by:	Roger Pau Monné
Sponsored by:	Citrix Systems R&D
Reviewed by:	gibbs
Approved by:	re (Xen blanket)
  • Loading branch information...
1 parent e688525 commit 716c2031c71f1b1fbd78da6494f5c5e2a5115e9b gibbs committed Oct 5, 2013
Showing with 11 additions and 0 deletions.
  1. +10 −0 sys/dev/hyperv/vmbus/hv_hv.c
  2. +1 −0 sys/x86/xen/hvm.c
@@ -29,6 +29,8 @@
/**
* Implements low-level interactions with Hypver-V/Azure
*/
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/malloc.h>
@@ -88,6 +90,14 @@ hv_vmbus_query_hypervisor_presence(void)
{
u_int regs[4];
int hyper_v_detected = 0;
+
+ /*
+ * When Xen is detected and native Xen PV support is enabled,
+ * ignore Xen's HyperV emulation.
+ */
+ if (vm_guest == VM_GUEST_XEN)
+ return (0);
+
do_cpuid(1, regs);
if (regs[2] & 0x80000000) { /* if(a hypervisor is detected) */
/* make sure this really is Hyper-V */
View
@@ -700,6 +700,7 @@ xen_hvm_init(enum xen_hvm_init_type init_type)
setup_xen_features();
cpu_ops = xen_hvm_cpu_ops;
+ vm_guest = VM_GUEST_XEN;
break;
case XEN_HVM_INIT_RESUME:
if (error != 0)

0 comments on commit 716c203

Please sign in to comment.