From fd1ccbe10cbeb7ee1570645416680b92dc26196d Mon Sep 17 00:00:00 2001 From: ReactOS Portable Systems Group Date: Thu, 31 Dec 2009 23:56:40 +0000 Subject: [PATCH] NMI Support Patch 2: [HAL]: Simplify IDT write-protection handling (always make it R/W and restore it to previous state). [HAL]: Avoid two superflous TLB flushes. svn path=/trunk/; revision=44842 --- reactos/hal/halx86/generic/bios.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/reactos/hal/halx86/generic/bios.c b/reactos/hal/halx86/generic/bios.c index ca79a65e84d..c0e4c2a31f5 100644 --- a/reactos/hal/halx86/generic/bios.c +++ b/reactos/hal/halx86/generic/bios.c @@ -254,18 +254,8 @@ HalpBiosDisplayReset(VOID) * the cmpxchg8b lock errata. Unprotect them here so we can set our custom * invalid op-code handler. */ - if (KeGetCurrentPrcb()->CpuType == 5) - { - /* Get the PTE and check if it is has been write protected yet */ - IdtPte = GetPteAddress(((PKIPCR)KeGetPcr())->IDT); - if (IdtPte->Write == 0) - { - /* Remove the protection and flush the TLB */ - IdtPte->Write = 1; - __writecr3(__readcr3()); - RestoreWriteProtection = TRUE; - } - } + IdtPte = GetPteAddress(((PKIPCR)KeGetPcr())->IDT); + RestoreWriteProtection = IdtPte->Write; /* Use special invalid opcode and GPF trap handlers */ HalpSwitchToRealModeTrapHandlers(); @@ -279,15 +269,9 @@ HalpBiosDisplayReset(VOID) /* Restore kernel trap handlers */ HalpRestoreTrapHandlers(); - /* Check if we removed the write protection before */ - if (RestoreWriteProtection) - { - /* Get the PTE, restore the write protection and flush the TLB */ - IdtPte = GetPteAddress(((PKIPCR)KeGetPcr())->IDT); - IdtPte->Write = 0; - __writecr3(__readcr3()); - } - + /* Restore write permission */ + IdtPte->Write = RestoreWriteProtection; + /* Restore TSS and IOPM */ HalpRestoreIoPermissionsAndTask();