win-pvdrivers

diff xenpci/xenpci_fdo.c @ 1093:5be1f70687ad

Refactor xenpci init to fix a bug when drivers are installed on a non-xen machine
author James Harper <james.harper@bendigoit.com.au>
date Mon Jan 13 20:24:56 2014 +1100 (2014-01-13)
parents 471c94d04d8a
children 05efa89a4ef7
line diff
     1.1 --- a/xenpci/xenpci_fdo.c	Sat Jan 04 18:17:51 2014 +1100
     1.2 +++ b/xenpci/xenpci_fdo.c	Mon Jan 13 20:24:56 2014 +1100
     1.3 @@ -33,69 +33,6 @@ static EVT_WDF_WORKITEM XenPci_SuspendRe
     1.4  static KSTART_ROUTINE XenPci_BalloonThreadProc;
     1.5  #endif
     1.6  
     1.7 -#define XEN_SIGNATURE_LOWER 0x40000000
     1.8 -#define XEN_SIGNATURE_UPPER 0x4000FFFF
     1.9 -
    1.10 -USHORT xen_version_major = (USHORT)-1;
    1.11 -USHORT xen_version_minor = (USHORT)-1;
    1.12 -PVOID hypercall_stubs = NULL;
    1.13 -
    1.14 -static VOID
    1.15 -hvm_get_hypercall_stubs() {
    1.16 -  ULONG base;
    1.17 -  DWORD32 cpuid_output[4];
    1.18 -  char xensig[13];
    1.19 -  ULONG i;
    1.20 -  ULONG pages;
    1.21 -  ULONG msr;
    1.22 -
    1.23 -  if (hypercall_stubs) {
    1.24 -    FUNCTION_MSG("hypercall_stubs alread set\n");
    1.25 -    return;
    1.26 -  }
    1.27 -
    1.28 -  for (base = XEN_SIGNATURE_LOWER; base < XEN_SIGNATURE_UPPER; base += 0x100) {
    1.29 -    __cpuid(cpuid_output, base);
    1.30 -    *(ULONG*)(xensig + 0) = cpuid_output[1];
    1.31 -    *(ULONG*)(xensig + 4) = cpuid_output[2];
    1.32 -    *(ULONG*)(xensig + 8) = cpuid_output[3];
    1.33 -    xensig[12] = '\0';
    1.34 -    FUNCTION_MSG("base = 0x%08x, Xen Signature = %s, EAX = 0x%08x\n", base, xensig, cpuid_output[0]);
    1.35 -    if (!strncmp("XenVMMXenVMM", xensig, 12) && ((cpuid_output[0] - base) >= 2))
    1.36 -      break;
    1.37 -  }
    1.38 -  if (base == XEN_SIGNATURE_UPPER) {
    1.39 -    FUNCTION_MSG("Cannot find Xen signature\n");
    1.40 -    return;
    1.41 -  }
    1.42 -
    1.43 -  __cpuid(cpuid_output, base + 1);
    1.44 -  xen_version_major = (USHORT)(cpuid_output[0] >> 16);
    1.45 -  xen_version_minor = (USHORT)(cpuid_output[0] & 0xFFFF);
    1.46 -  FUNCTION_MSG("Xen Version %d.%d\n", xen_version_major, xen_version_minor);
    1.47 -
    1.48 -  __cpuid(cpuid_output, base + 2);
    1.49 -  pages = cpuid_output[0];
    1.50 -  msr = cpuid_output[1];
    1.51 -
    1.52 -  hypercall_stubs = ExAllocatePoolWithTag(NonPagedPool, pages * PAGE_SIZE, XENPCI_POOL_TAG);
    1.53 -  FUNCTION_MSG("Hypercall area at %p\n", hypercall_stubs);
    1.54 -
    1.55 -  if (!hypercall_stubs)
    1.56 -    return;
    1.57 -  for (i = 0; i < pages; i++) {
    1.58 -    ULONGLONG pfn;
    1.59 -    pfn = (MmGetPhysicalAddress((PUCHAR)hypercall_stubs + i * PAGE_SIZE).QuadPart >> PAGE_SHIFT);
    1.60 -    __writemsr(msr, (pfn << PAGE_SHIFT) + i);
    1.61 -  }
    1.62 -}
    1.63 -
    1.64 -static VOID
    1.65 -hvm_free_hypercall_stubs() {
    1.66 -  ExFreePoolWithTag(hypercall_stubs, XENPCI_POOL_TAG);
    1.67 -  hypercall_stubs = NULL;
    1.68 -}
    1.69 -
    1.70  static VOID
    1.71  XenPci_MapHalThenPatchKernel(PXENPCI_DEVICE_DATA xpdd)
    1.72  {
    1.73 @@ -175,11 +112,6 @@ XenPci_Init(PXENPCI_DEVICE_DATA xpdd)
    1.74    FUNCTION_ENTER();
    1.75  
    1.76    if (!hypercall_stubs)
    1.77 -  {
    1.78 -    XN_ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
    1.79 -    hvm_get_hypercall_stubs();
    1.80 -  }
    1.81 -  if (!hypercall_stubs)
    1.82      return STATUS_UNSUCCESSFUL;
    1.83  
    1.84    if (!xpdd->shared_info_area)