Author: sir_richard
Date: Fri Sep 24 17:02:13 2010
New Revision: 48860

URL: http://svn.reactos.org/svn/reactos?rev=48860&view=rev
Log:
[NTDLL]: Use LOCK instead of lock for SList assembly functions, this is a 
conditional such that on UP, "lock" instruction won't be generated.
[NTDLL]: Apply the special begin/fault/resume lablels to the user-mode SList 
functions. Access faults can happen there due to a bug in the Windows 
algorithm, and Mm will need to handle that.
[NTOS]: Lookup the special labels from above when initializing the System DLL. 
Only lookup INT2E vs SYSENTER on x86, other architectures don't need a stub.
[NTOS]: Bitmap resources start at index 1, not 0. Also make sure we don't go 
past the maximum IDB_ resource index for no reason, and check the size of the 
resource instead of assuming it's going to be one page.
[NMIDEBUG]: Fix and cleanup some code, and enable NMI support on the 
boot/install CD as well.

Modified:
    trunk/reactos/boot/bootdata/txtsetup.sif
    trunk/reactos/dll/ntdll/def/ntdll.pspec
    trunk/reactos/drivers/base/nmidebug/nmidebug.c
    trunk/reactos/drivers/base/nmidebug/nmidebug.rbuild
    trunk/reactos/lib/rtl/i386/interlck.S
    trunk/reactos/ntoskrnl/inbv/inbv.c
    trunk/reactos/ntoskrnl/ps/psmgr.c

Modified: trunk/reactos/boot/bootdata/txtsetup.sif
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/txtsetup.sif?rev=48860&r1=48859&r2=48860&view=diff
==============================================================================
--- trunk/reactos/boot/bootdata/txtsetup.sif [iso-8859-1] (original)
+++ trunk/reactos/boot/bootdata/txtsetup.sif [iso-8859-1] Fri Sep 24 17:02:13 
2010
@@ -17,6 +17,7 @@
 
 [SourceDisksFiles]
 acpi.sys=,,,,,,,,,,,,4
+nmidebug.sys=,,,,,,x,,,,,,4
 uniata.sys=,,,,,,x,,,,,,4
 buslogic.sys=,,,,,,x,,,,,,4
 blue.sys=,,,,,,x,,,,,,4

Modified: trunk/reactos/dll/ntdll/def/ntdll.pspec
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/def/ntdll.pspec?rev=48860&r1=48859&r2=48860&view=diff
==============================================================================
--- trunk/reactos/dll/ntdll/def/ntdll.pspec [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/def/ntdll.pspec [iso-8859-1] Fri Sep 24 17:02:13 
2010
@@ -62,6 +62,9 @@
 @ stdcall -arch=i386 KiFastSystemCall()
 @ stdcall -arch=i386 KiFastSystemCallRet()
 @ stdcall -arch=i386 KiIntSystemCall()
+@ stdcall -arch=i386 ExpInterlockedPopEntrySListEnd()
+@ stdcall -arch=i386 ExpInterlockedPopEntrySListFault()
+@ stdcall -arch=i386 ExpInterlockedPopEntrySListResume()
 @ stdcall KiRaiseUserExceptionDispatcher()
 @ stdcall KiUserApcDispatcher(ptr ptr ptr ptr)
 @ stdcall KiUserCallbackDispatcher(ptr ptr long) // CHECKME

Modified: trunk/reactos/drivers/base/nmidebug/nmidebug.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/nmidebug/nmidebug.c?rev=48860&r1=48859&r2=48860&view=diff
==============================================================================
--- trunk/reactos/drivers/base/nmidebug/nmidebug.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/nmidebug/nmidebug.c [iso-8859-1] Fri Sep 24 
17:02:13 2010
@@ -13,7 +13,16 @@
 
 /* FUNCTIONS 
******************************************************************/
 
-PCHAR NmiBegin = "NMI2NMI1";
+PCHAR NmiBegin = "NMI4NMI@";
+
+VOID
+FORCEINLINE
+NmiClearFlag(VOID)
+{
+    ((PCHAR)&KiBugCheckData[4])[0] -= (NmiBegin[3] | NmiBegin[7]);
+    ((PCHAR)&KiBugCheckData[4])[3] |= 1;
+    __asm__("rcrl %b[shift], %k[retval]" : [retval] "=rm" (KiBugCheckData[4]) 
: "[retval]" (KiBugCheckData[4]), [shift] "Nc" (8));
+}
 
 BOOLEAN
 NTAPI
@@ -21,17 +30,17 @@
                IN BOOLEAN Handled)
 {
     /* Clear the NMI flag */
-    ((PCHAR)&KiBugCheckData[4])[3] -= NmiBegin[3];
+    NmiClearFlag();
 
     /* Get NMI status signature */
     __indwordstring(0x80, (PULONG)NmiBegin, 1);
     ((void(*)())&KiBugCheckData[4])();
 
     /* Handle the NMI safely */
-    KiEnableTimerWatchdog = strcmp(NmiBegin, NmiBegin + 4);
+    KiEnableTimerWatchdog = (RtlCompareMemory(NmiBegin, NmiBegin + 4, 4) != 4);
     return TRUE;
 }
-     
+
 NTSTATUS
 NTAPI
 DriverEntry(IN PDRIVER_OBJECT DriverObject,

Modified: trunk/reactos/drivers/base/nmidebug/nmidebug.rbuild
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/base/nmidebug/nmidebug.rbuild?rev=48860&r1=48859&r2=48860&view=diff
==============================================================================
--- trunk/reactos/drivers/base/nmidebug/nmidebug.rbuild [iso-8859-1] (original)
+++ trunk/reactos/drivers/base/nmidebug/nmidebug.rbuild [iso-8859-1] Fri Sep 24 
17:02:13 2010
@@ -1,6 +1,7 @@
 <?xml version="1.0"?>
 <!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
 <module name="nmidebug" type="kernelmodedriver" installbase="system32/drivers" 
installname="nmidebug.sys">
+       <bootstrap installbase="$(CDOUTPUT)" />
        <include base="null">.</include>
        <library>ntoskrnl</library>
        <library>hal</library>

Modified: trunk/reactos/lib/rtl/i386/interlck.S
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/i386/interlck.S?rev=48860&r1=48859&r2=48860&view=diff
==============================================================================
--- trunk/reactos/lib/rtl/i386/interlck.S [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/i386/interlck.S [iso-8859-1] Fri Sep 24 17:02:13 2010
@@ -16,6 +16,9 @@
  * RtlInterlockedPopEntrySList(
  *     IN PSLIST_HEADER ListHead);
  */
+.global _expinterlockedpopentryslistres...@0
+.global _expinterlockedpopentryslist...@0
+.global _expinterlockedpopentryslistfa...@0
 .global _rtlinterlockedpopentrysl...@4
 _rtlinterlockedpopentrysl...@4:
 
@@ -25,7 +28,7 @@
 
     /* Load ListHead into ebp */
     mov ebp, [esp + 12]
-
+_expinterlockedpopentryslistres...@0:
     /* Load ListHead->Next into eax */
     mov eax, [ebp]
 
@@ -40,14 +43,15 @@
     /* Copy Depth and Sequence number and adjust Depth */
     lea ecx, [edx - 1]
 
+_expinterlockedpopentryslistfa...@0:
     /* Get next pointer */
     mov ebx, [eax]
-
+_expinterlockedpopentryslist...@0:
     /* If [ebp] equals edx:eax, exchange it with ecx:ebx */
-    lock cmpxchg8b [ebp]
+    LOCK cmpxchg8b qword ptr [ebp]
 
     /* If not equal, retry with edx:eax, being the content of [ebp] now */
-    jnz 1b
+    jnz _expinterlockedpopentryslistres...@0
 
     /* Restore registers and return */
 2:
@@ -89,7 +93,7 @@
     lea ecx, [edx + 0x10001]
 
     /* If [ebp] equals edx:eax, exchange it with ecx:ebx */
-    lock cmpxchg8b [ebp]
+    LOCK cmpxchg8b qword ptr [ebp]
  
     /* If not equal, retry with edx:eax, being the content of [ebp] now */
     jnz 1b
@@ -136,7 +140,7 @@
     xor cx, cx
 
     /* If [ebp] equals edx:eax, exchange it with ecx:ebx */
-    lock cmpxchg8b [ebp]
+    LOCK cmpxchg8b qword ptr [ebp]
  
     /* If not equal, retry with edx:eax, being the content of [ebp] now */
     jnz 1b

Modified: trunk/reactos/ntoskrnl/inbv/inbv.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/inbv/inbv.c?rev=48860&r1=48859&r2=48860&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/inbv/inbv.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/inbv/inbv.c [iso-8859-1] Fri Sep 24 17:02:13 2010
@@ -73,11 +73,15 @@
         if (NT_SUCCESS(Status))
         {
             /* Access the resource */
+            ULONG Size = 0;
             Status = LdrAccessResource(LdrEntry->DllBase,
                                        ResourceDataEntry,
                                        &Data,
-                                       NULL);
-            if (Data) KiBugCheckData[4] ^= RtlComputeCrc32(0, Data, PAGE_SIZE);
+                                       &Size);
+            if ((Data) && (ResourceId < 3))
+            {
+                KiBugCheckData[4] ^= RtlComputeCrc32(0, Data, Size);
+            }
             if (!NT_SUCCESS(Status)) Data = NULL;
         }
     }
@@ -115,8 +119,8 @@
         VidResetDisplay(CustomLogo);
         
         /* Find bitmap resources in the kernel */
-        ResourceCount = Count;
-        for (i = 0; i < Count; i++)
+        ResourceCount = min(IDB_CLUSTER_SERVER, Count);
+        for (i = 1; i <= Count; i++)
         {
             /* Do the lookup */
             ResourceList[i] = FindBitmapResource(LoaderBlock, i);

Modified: trunk/reactos/ntoskrnl/ps/psmgr.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/psmgr.c?rev=48860&r1=48859&r2=48860&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ps/psmgr.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ps/psmgr.c [iso-8859-1] Fri Sep 24 17:02:13 2010
@@ -14,6 +14,10 @@
 
 extern ULONG ExpInitializationPhase;
 extern BOOLEAN SysThreadCreated;
+
+PVOID KeUserPopEntrySListEnd;
+PVOID KeUserPopEntrySListFault;
+PVOID KeUserPopEntrySListResume;
 
 GENERIC_MAPPING PspProcessMapping =
 {
@@ -187,10 +191,24 @@
                                           &KeRaiseUserExceptionDispatcher);
     if (!NT_SUCCESS(Status)) return Status;
 
+    /* Get user-mode SLIST exception functions for page fault rollback race 
hack */
+    Status = PspLookupSystemDllEntryPoint("ExpInterlockedPopEntrySListEnd",
+                                          &KeUserPopEntrySListEnd);
+    if (!NT_SUCCESS(Status)) { DPRINT1("this not found\n"); return Status; }
+    Status = PspLookupSystemDllEntryPoint("ExpInterlockedPopEntrySListFault",
+                                          &KeUserPopEntrySListFault);
+    if (!NT_SUCCESS(Status)) { DPRINT1("this not found\n"); return Status; }
+    Status = PspLookupSystemDllEntryPoint("ExpInterlockedPopEntrySListResume",
+                                          &KeUserPopEntrySListResume);
+    if (!NT_SUCCESS(Status)) { DPRINT1("this not found\n"); return Status; }
+
+    /* On x86, there are multiple ways to do a system call, find the right 
stubs */
+#if defined(_X86_)
     /* Check if this is a machine that supports SYSENTER */
     if (KeFeatureBits & KF_FAST_SYSCALL)
     {
         /* Get user-mode sysenter stub */
+        SharedUserdata->SystemCall = (PsNtosImageBase >> (PAGE_SHIFT + 1));
         Status = PspLookupSystemDllEntryPoint("KiFastSystemCall",
                                               (PVOID)&SharedUserData->
                                               SystemCall);
@@ -213,6 +231,7 @@
 
     /* Set the test instruction */
     SharedUserData->TestRetInstruction = 0xC3;
+#endif
 
     /* Return the status */
     return Status;


Reply via email to