win-pvdrivers

changeset 772:47876d124c24

patch the IDT for DbgPrint on all CPU's, not just the current CPU.
author James Harper <james.harper@bendigoit.com.au>
date Mon Feb 01 12:17:02 2010 +1100 (2010-02-01)
parents 358a1bf4efaf
children aa428237f288
files xenpci/xenpci_dbgprint.c
line diff
     1.1 --- a/xenpci/xenpci_dbgprint.c	Mon Feb 01 12:16:38 2010 +1100
     1.2 +++ b/xenpci/xenpci_dbgprint.c	Mon Feb 01 12:17:02 2010 +1100
     1.3 @@ -126,17 +126,44 @@ XenPci_DbgPrintCallback(PSTRING output, 
     1.4    XenDbgPrint(output->Buffer, output->Length);
     1.5  }
     1.6  
     1.7 +#if 0
     1.8 +typedef struct _hook_info {
     1.9 +  PIDT_ENTRY idt_entry;
    1.10 +} hook_info_t;
    1.11 +#endif
    1.12 +
    1.13 +#if (NTDDI_VERSION < NTDDI_VISTA)
    1.14 +#ifndef _AMD64_ // can't patch IDT on AMD64 unfortunately - results in bug check 0x109
    1.15 +static VOID
    1.16 +XenPci_HookDbgPrint_High(PVOID context)
    1.17 +{
    1.18 +  IDT idt;
    1.19 +  PIDT_ENTRY idt_entry;
    1.20 +
    1.21 +  UNREFERENCED_PARAMETER(context);  
    1.22 + 
    1.23 +  idt.limit = 0;
    1.24 +  __sidt(&idt);
    1.25 +  idt_entry = &idt.entries[0x2D];
    1.26 +  #ifdef _AMD64_ 
    1.27 +  Int2dHandlerOld = (PVOID)((ULONG_PTR)idt_entry->addr_0_15 | ((ULONG_PTR)idt_entry->addr_16_31 << 16) | ((ULONG_PTR)idt_entry->addr_32_63 << 32));
    1.28 +  #else
    1.29 +  Int2dHandlerOld = (PVOID)((ULONG_PTR)idt_entry->addr_0_15 | ((ULONG_PTR)idt_entry->addr_16_31 << 16));
    1.30 +  #endif
    1.31 +  idt_entry->addr_0_15 = (USHORT)(ULONG_PTR)Int2dHandlerNew;
    1.32 +  idt_entry->addr_16_31 = (USHORT)((ULONG_PTR)Int2dHandlerNew >> 16);
    1.33 +  #ifdef _AMD64_ 
    1.34 +  idt_entry->addr_32_63 = (ULONG)((ULONG_PTR)Int2dHandlerNew >> 32);
    1.35 +  #endif
    1.36 +}
    1.37 +#endif
    1.38 +#endif
    1.39 +
    1.40  NTSTATUS
    1.41  XenPci_HookDbgPrint()
    1.42  {
    1.43    NTSTATUS status = STATUS_SUCCESS;
    1.44 -#if (NTDDI_VERSION < NTDDI_VISTA)
    1.45 -#ifndef _AMD64_ // can't patch IDT on AMD64 unfortunately - results in bug check 0x109
    1.46 -  IDT idt;
    1.47 -  PIDT_ENTRY idt_entry;
    1.48 -  KIRQL old_irql;
    1.49 -#endif
    1.50 -#endif  
    1.51 +
    1.52    if (READ_PORT_USHORT(XEN_IOPORT_MAGIC) == 0x49d2
    1.53      || READ_PORT_USHORT(XEN_IOPORT_MAGIC) == 0xd249)
    1.54    {
    1.55 @@ -154,23 +181,7 @@ XenPci_HookDbgPrint()
    1.56  #else
    1.57      KdPrint((__DRIVER_NAME "     DbgSetDebugPrintCallback not found\n"));      
    1.58  #ifndef _AMD64_ // can't patch IDT on AMD64 unfortunately - results in bug check 0x109
    1.59 -    idt.limit = 0;
    1.60 -    __sidt(&idt);
    1.61 -    idt_entry = &idt.entries[0x2D];
    1.62 -    _disable();
    1.63 -    KeRaiseIrql(HIGH_LEVEL, &old_irql);
    1.64 -    #ifdef _AMD64_ 
    1.65 -    Int2dHandlerOld = (PVOID)((ULONG_PTR)idt_entry->addr_0_15 | ((ULONG_PTR)idt_entry->addr_16_31 << 16) | ((ULONG_PTR)idt_entry->addr_32_63 << 32));
    1.66 -    #else
    1.67 -    Int2dHandlerOld = (PVOID)((ULONG_PTR)idt_entry->addr_0_15 | ((ULONG_PTR)idt_entry->addr_16_31 << 16));
    1.68 -    #endif
    1.69 -    idt_entry->addr_0_15 = (USHORT)(ULONG_PTR)Int2dHandlerNew;
    1.70 -    idt_entry->addr_16_31 = (USHORT)((ULONG_PTR)Int2dHandlerNew >> 16);
    1.71 -    #ifdef _AMD64_ 
    1.72 -    idt_entry->addr_32_63 = (ULONG)((ULONG_PTR)Int2dHandlerNew >> 32);
    1.73 -    #endif
    1.74 -    KeLowerIrql(old_irql);
    1.75 -    _enable();
    1.76 +    XenPci_HighSync(XenPci_HookDbgPrint_High, XenPci_HookDbgPrint_High, NULL);
    1.77  #endif
    1.78  #endif
    1.79    }