win-pvdrivers
changeset 1064:1d6eae98e552
Remove vlapic mapping from TPR patching. It was never supported and causes a crash under 4.3.x
author | James Harper <james.harper@bendigoit.com.au> |
---|---|
date | Thu Oct 03 18:11:30 2013 +1000 (2013-10-03) |
parents | fe04dbceb0b2 |
children | 00d29add6a2a |
files | xenpci/xenpci_patch_kernel.c |
line diff
1.1 --- a/xenpci/xenpci_patch_kernel.c Thu Oct 03 18:10:21 2013 +1000 1.2 +++ b/xenpci/xenpci_patch_kernel.c Thu Oct 03 18:11:30 2013 +1000 1.3 @@ -45,8 +45,7 @@ static PHYSICAL_ADDRESS lapic_page[MAX_V 1.4 static volatile PVOID lapic[MAX_VIRT_CPUS]; 1.5 static ULONG tpr_cache[MAX_VIRT_CPUS]; 1.6 #define PATCH_METHOD_LOCK_MOVE_CR0 1 1.7 -#define PATCH_METHOD_MAPPED_VLAPIC 2 1.8 -#define PATCH_METHOD_CACHED_TPR 3 1.9 +#define PATCH_METHOD_CACHED_TPR 2 1.10 static ULONG patch_method; 1.11 1.12 static ULONG 1.13 @@ -56,9 +55,6 @@ SaveTprProcValue(ULONG cpu, ULONG value) 1.14 case PATCH_METHOD_CACHED_TPR: 1.15 tpr_cache[cpu] = value; 1.16 break; 1.17 - case PATCH_METHOD_MAPPED_VLAPIC: 1.18 - /* no need to save here */ 1.19 - break; 1.20 } 1.21 return value; 1.22 } 1.23 @@ -71,9 +67,6 @@ SaveTpr() { 1.24 case PATCH_METHOD_LOCK_MOVE_CR0: 1.25 case PATCH_METHOD_CACHED_TPR: 1.26 return SaveTprProcValue(cpu, *(PULONG)LAPIC_TASKPRI); 1.27 - case PATCH_METHOD_MAPPED_VLAPIC: 1.28 - /* no need to save here */ 1.29 - break; 1.30 } 1.31 return 0; 1.32 } 1.33 @@ -116,19 +109,6 @@ WriteTpr(ULONG new_tpr_value) { 1.34 tpr_cache[cpu] = new_tpr_value; 1.35 } 1.36 break; 1.37 - case PATCH_METHOD_MAPPED_VLAPIC: 1.38 - /* need to set the new tpr value and then check for pending interrupts to avoid a race */ 1.39 - *(PULONG)((PUCHAR)lapic[cpu] + 0x80) = new_tpr_value & 0xff; 1.40 - KeMemoryBarrier(); 1.41 - IRR = ApicHighestVector((PULONG)((PUCHAR)lapic[cpu] + 0x200)); 1.42 - if (IRR == -1) 1.43 - return; 1.44 - ISR = ApicHighestVector((PULONG)((PUCHAR)lapic[cpu] + 0x100)); 1.45 - if (ISR == -1) 1.46 - ISR = 0; 1.47 - if ((ULONG)(IRR >> 4) > max((ULONG)(ISR >> 4), ((new_tpr_value & 0xf0) >> 4))) 1.48 - *(PULONG)LAPIC_TASKPRI = new_tpr_value; 1.49 - break; 1.50 } 1.51 } 1.52 1.53 @@ -141,8 +121,6 @@ ReadTpr() { 1.54 case PATCH_METHOD_LOCK_MOVE_CR0: 1.55 case PATCH_METHOD_CACHED_TPR: 1.56 return tpr_cache[cpu]; 1.57 - case PATCH_METHOD_MAPPED_VLAPIC: 1.58 - return *(PULONG)((PUCHAR)lapic[cpu] + 0x80); 1.59 default: 1.60 return 0; 1.61 } 1.62 @@ -281,48 +259,9 @@ IsMoveCr8Supported() { 1.63 return FALSE; 1.64 } 1.65 1.66 -static ULONG 1.67 -MapVlapic(PXENPCI_DEVICE_DATA xpdd) { 1.68 - struct xen_add_to_physmap xatp; 1.69 - ULONG rc = EINVAL; 1.70 - ULONG ActiveProcessorCount; 1.71 - int i; 1.72 - 1.73 - FUNCTION_ENTER(); 1.74 - 1.75 -#if (NTDDI_VERSION >= NTDDI_WINXP) 1.76 - ActiveProcessorCount = (ULONG)KeNumberProcessors; 1.77 -#else 1.78 - ActiveProcessorCount = (ULONG)*KeNumberProcessors; 1.79 -#endif 1.80 - 1.81 - for (i = 0; i < (int)ActiveProcessorCount; i++) { 1.82 - FUNCTION_MSG("mapping lapic for cpu = %d\n", i); 1.83 - 1.84 - lapic_page[i] = XenPci_AllocMMIO(xpdd, PAGE_SIZE); 1.85 - lapic[i] = MmMapIoSpace(lapic_page[i], PAGE_SIZE, MmCached); 1.86 - 1.87 - xatp.domid = DOMID_SELF; 1.88 - xatp.idx = i; 1.89 - xatp.space = XENMAPSPACE_vlapic; 1.90 - xatp.gpfn = (xen_pfn_t)(lapic_page[i].QuadPart >> PAGE_SHIFT); 1.91 - FUNCTION_MSG("gpfn = %x\n", xatp.gpfn); 1.92 - rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp); 1.93 - FUNCTION_MSG("hypervisor memory op (XENMAPSPACE_vlapic_regs) ret = %d\n", rc); 1.94 - if (rc != 0) { 1.95 - FUNCTION_EXIT(); 1.96 - return rc; 1.97 - } 1.98 - } 1.99 - FUNCTION_EXIT(); 1.100 - 1.101 - return rc; 1.102 -} 1.103 - 1.104 VOID 1.105 XenPci_PatchKernel(PXENPCI_DEVICE_DATA xpdd, PVOID base, ULONG length) { 1.106 patch_info_t patch_info; 1.107 - ULONG rc; 1.108 #if (NTDDI_VERSION >= NTDDI_WINXP) 1.109 RTL_OSVERSIONINFOEXW version_info; 1.110 #endif 1.111 @@ -354,18 +293,8 @@ XenPci_PatchKernel(PXENPCI_DEVICE_DATA x 1.112 FUNCTION_MSG("Using LOCK MOVE CR0 TPR patch\n"); 1.113 patch_method = PATCH_METHOD_LOCK_MOVE_CR0; 1.114 } else { 1.115 - rc = MapVlapic(xpdd); 1.116 - if (rc == -EACCES) { 1.117 - FUNCTION_MSG("Xen already using VMX LAPIC acceleration. No patch required\n"); 1.118 - return; 1.119 - } 1.120 - if (!rc) { 1.121 - FUNCTION_MSG("Using mapped vLAPIC TPR patch\n"); 1.122 - patch_method = PATCH_METHOD_MAPPED_VLAPIC; 1.123 - } else { 1.124 - FUNCTION_MSG("Using cached TPR patch\n"); 1.125 - patch_method = PATCH_METHOD_CACHED_TPR; 1.126 - } 1.127 + FUNCTION_MSG("Using cached TPR patch\n"); 1.128 + patch_method = PATCH_METHOD_CACHED_TPR; 1.129 } 1.130 patch_info.base = base; 1.131 patch_info.length = length;