|
From: Hartmut B. <har...@te...> - 2002-05-08 08:19:52
|
> -----Ursprungliche Nachricht----- > Von: David Welch [SMTP:we...@cw...] > Gesendet am: Mittwoch, 8. Mai 2002 09:57 > An: rea...@li... > Betreff: Re: [ros-kernel] CVS commit: ReactOS > > On Wed, May 08, 2002 at 12:52:36AM +0200, Hartmut Birr wrote: > > Fixed a bug in MmNotPresentFaultSectionView. > > > Could you explain the reason for this change. If two processes have a not present fault within the same address range, there is called MmNotPresentFaultSectionView. The first get the pageop and handles the fault. The second use this page, if the event in the pageop is signaled. If the first process terminate before the second can map the page, than is the page unmapped and not longer valid. There occurs a bug check within the following call to MmReferencePage. If gcc uses piping, there are started three processes within a short time and two of them does also exit at the same time. The page fault occurs within msvcrt.dll when __atexit_ptr is accessed from exit. The faulting address is __atexit_ptr. The first fix was to init this variable within DllMain but the real problem is in MmNotPresentFaultSectionView. - Hartmut |
|
From: <we...@cw...> - 2002-05-08 15:16:18
|
Quoting Hartmut Birr <har...@te...>: > > If two processes have a not present fault within the same address range, > there is called MmNotPresentFaultSectionView. The first get the pageop > and handles the fault. The second use this page, if the event in the pageop > is signaled. If the first process terminate before the second can map the > page, than is the page unmapped and not longer valid. There occurs a bug > check within the following call to MmReferencePage. If gcc uses piping, > there are started three processes within a short time and two of them > does also exit at the same time. The page fault occurs within msvcrt.dll when > __atexit_ptr is accessed from exit. The faulting address is __atexit_ptr. > The first fix was to init this variable within DllMain but the real > problem is in MmNotPresentFaultSectionView. > Ok, thanks for the explanation. I don't think this fixes all the problems of this type: for example MmNotPresentFaultSectionView doesn't even reference the section so it could be freed by the time it returns after waiting for the page operation. The fix I was considering was to check for pending page operations on a unmap/process exit and either wait for them to complete or abandon freeing section pages that are about to be used in another process. |
|
From: Casper H. <ch...@us...> - 2002-05-08 17:03:55
|
Made PICE compile with GCC 3.2.
Support multiple debug targets at the same time.
E.g. to use both serial logging on COM1 and GDB remote debugging on COM2
use:
/DEBUGPORT=COM1 /COM2 /DEBUGPORT=GDB
Index: apps/pice/loader/main.c
===================================================================
RCS file: /CVS/ReactOS/reactos/apps/pice/loader/main.c,v
retrieving revision 1.8
diff -u -p -r1.8 main.c
--- apps/pice/loader/main.c 15 Jan 2002 04:35:13 -0000 1.8
+++ apps/pice/loader/main.c 8 May 2002 16:54:19 -0000
@@ -226,9 +226,11 @@ void process_stabs(
SymbolFileHeader.ulOffsetToSrcFiles = sizeof(PICE_SYMBOLFILE_HEADER)+sectionHeadersSize+nGlobalLen+nGlobalStrLen+nStabLen+nStrLen;
SymbolFileHeader.ulNumberOfSrcFiles = ulCurrentSrcFile;
- printf("sectionHeaderSize: %ld, nGlobalLen: %ld, nGlobalStrLen: %ld, nStabLen: %ld,
- nStrLen: %ld, ulCurrentSrcFile: %ld, ulOffsetToStabs: %ld \n", sectionHeadersSize, nGlobalLen, nGlobalStrLen,
+ printf("sectionHeaderSize: %ld, nGlobalLen: %ld, nGlobalStrLen: %ld, nStabLen: %ld, "
+ "nStrLen: %ld, ulCurrentSrcFile: %ld, ulOffsetToStabs: %ld\n",
+ sectionHeadersSize, nGlobalLen, nGlobalStrLen,
nStabLen, nStrLen, ulCurrentSrcFile, SymbolFileHeader.ulOffsetToStabs);
+
WriteFile(fileout,&SymbolFileHeader,sizeof(PICE_SYMBOLFILE_HEADER),&wrote, NULL);
WriteFile(fileout,section,sectionHeadersSize,&wrote, NULL);
WriteFile(fileout,pGlobals,nGlobalLen,&wrote, NULL);
Index: apps/pice/module/bp.c
===================================================================
RCS file: /CVS/ReactOS/reactos/apps/pice/module/bp.c,v
retrieving revision 1.5
diff -u -p -r1.5 bp.c
--- apps/pice/module/bp.c 30 Jan 2002 20:42:04 -0000 1.5
+++ apps/pice/module/bp.c 8 May 2002 16:54:19 -0000
@@ -694,11 +694,11 @@ void RevirtualizeBreakpointsForModule(PD
// NewInt3Handler()
//
//*************************************************************************
-__asm__ ("
-NewInt3Handler:
- pushl $" STR(REASON_INT3) "
- // call debugger loop
- jmp NewInt31Handler
+__asm__ ("\n\t \
+NewInt3Handler:\n\t \
+ pushl $" STR(REASON_INT3) "\n\t \
+ // call debugger loop\n\t \
+ jmp NewInt31Handler\n\t \
");
Index: apps/pice/module/dblflt.c
===================================================================
RCS file: /CVS/ReactOS/reactos/apps/pice/module/dblflt.c,v
retrieving revision 1.3
diff -u -p -r1.3 dblflt.c
--- apps/pice/module/dblflt.c 14 Jan 2002 22:04:08 -0000 1.3
+++ apps/pice/module/dblflt.c 8 May 2002 16:54:19 -0000
@@ -59,31 +59,31 @@ void HandleDoubleFault(FRAME* ptr)
// NewDblFltHandler()
//
//*************************************************************************
-__asm__ ("
-NewDblFltHandler:
- pushfl
- cli
- cld
- pushal
- pushl %ds
-
- // setup default data selectors
- movw %ss,%ax
- movw %ax,%ds
-
- // get frame ptr
- lea 40(%esp),%eax
- pushl %eax
- call _HandleDoubleFault
- addl $4,%esp
-
- popl %ds
- popal
- popfl
- // remove error code from stack and replace with reason code
- movl $" STR(REASON_DOUBLE_FAULT) ",(%esp)
- // call debugger loop
- jmp NewInt31Handler");
+__asm__ (" \
+NewDblFltHandler:\n\t \
+ pushfl\n\t \
+ cli;\n\t \
+ cld;\n\t \
+ pushal;\n\t \
+ pushl %ds;\n\t \
+\n\t \
+ // setup default data selectors\n\t \
+ movw %ss,%ax\n\t \
+ movw %ax,%ds\n\t \
+\n\t \
+ // get frame ptr\n\t \
+ lea 40(%esp),%eax\n\t \
+ pushl %eax\n\t \
+ call _HandleDoubleFault\n\t \
+ addl $4,%esp\n\t \
+\n\t \
+ popl %ds\n\t \
+ popal\n\t \
+ popfl\n\t \
+ // remove error code from stack and replace with reason code\n\t \
+ movl $" STR(REASON_DOUBLE_FAULT) ",(%esp)\n\t \
+ // call debugger loop\n\t \
+ jmp NewInt31Handler\n\t");
//*************************************************************************
Index: apps/pice/module/gpfault.c
===================================================================
RCS file: /CVS/ReactOS/reactos/apps/pice/module/gpfault.c,v
retrieving revision 1.5
diff -u -p -r1.5 gpfault.c
--- apps/pice/module/gpfault.c 30 Jan 2002 20:42:04 -0000 1.5
+++ apps/pice/module/gpfault.c 8 May 2002 16:54:19 -0000
@@ -59,30 +59,30 @@ void HandleGPFault(FRAME* ptr)
// NewGPFaultHandler()
//
//*************************************************************************
-__asm__ ("
-NewGPFaultHandler:
- pushfl
- cli
- cld
- pushal
- pushl %ds
-
- // setup default data selectors
- movw %ss,%ax
- movw %ax,%ds
-
- // get frame ptr
- lea 40(%esp),%eax
- pushl %eax
- call _HandleGPFault
- addl $4,%esp
-
- popl %ds
- popal
- popfl
- // remove error code from stack and replace with reason code
- movl $" STR(REASON_GP_FAULT) ",(%esp)
- // call debugger loop
+__asm__ ("\n\t \
+NewGPFaultHandler:\n\t \
+ pushfl\n\t \
+ cli\n\t \
+ cld\n\t \
+ pushal\n\t \
+ pushl %ds\n\t \
+\n\t \
+ // setup default data selectors\n\t \
+ movw %ss,%ax\n\t \
+ movw %ax,%ds\n\t \
+\n\t \
+ // get frame ptr\n\t \
+ lea 40(%esp),%eax\n\t \
+ pushl %eax\n\t \
+ call _HandleGPFault\n\t \
+ addl $4,%esp\n\t \
+\n\t \
+ popl %ds\n\t \
+ popal\n\t \
+ popfl\n\t \
+ // remove error code from stack and replace with reason code\n\t \
+ movl $" STR(REASON_GP_FAULT) ",(%esp)\n\t \
+ // call debugger loop\n\t \
jmp NewInt31Handler");
Index: apps/pice/module/init.c
===================================================================
RCS file: /CVS/ReactOS/reactos/apps/pice/module/init.c,v
retrieving revision 1.7
diff -u -p -r1.7 init.c
--- apps/pice/module/init.c 26 Jan 2002 05:17:45 -0000 1.7
+++ apps/pice/module/init.c 8 May 2002 16:54:20 -0000
@@ -249,9 +249,9 @@ BOOLEAN InitPICE(void)
CurrentEIP = (ULONG)RealIsr;
CurrentDS = CurrentSS = GLOBAL_DATA_SEGMENT;
- __asm__("
- mov %%esp,%%eax
- mov %%eax,_CurrentESP
+ __asm__("\n\t \
+ mov %%esp,%%eax\n\t \
+ mov %%eax,_CurrentESP\n\t \
":::"eax");
@@ -259,13 +259,13 @@ BOOLEAN InitPICE(void)
Ver(NULL);
// disable HW breakpoints
- __asm__("
- xorl %%eax,%%eax
- mov %%eax,%%dr6
- mov %%eax,%%dr7
- mov %%dr0,%%eax
- mov %%dr1,%%eax
- mov %%dr2,%%eax
+ __asm__("\n\t \
+ xorl %%eax,%%eax\n\t \
+ mov %%eax,%%dr6\n\t \
+ mov %%eax,%%dr7\n\t \
+ mov %%dr0,%%eax\n\t \
+ mov %%dr1,%%eax\n\t \
+ mov %%dr2,%%eax\n\t \
mov %%dr3,%%eax"
:::"eax"
);
@@ -290,12 +290,12 @@ BOOLEAN InitPICE(void)
DPRINT((0,"about to do initial break...\n"));
// simulate an initial break
- __asm__("
- pushfl
- pushl %cs
- pushl $initialreturnpoint
- pushl $" STR(REASON_CTRLF) "
- jmp NewInt31Handler
+ __asm__("\n\t \
+ pushfl\n\t \
+ pushl %cs\n\t \
+ pushl $initialreturnpoint\n\t \
+ pushl $" STR(REASON_CTRLF) "\n\t \
+ jmp NewInt31Handler\n\t \
initialreturnpoint:");
}
else
Index: apps/pice/module/parse.c
===================================================================
RCS file: /CVS/ReactOS/reactos/apps/pice/module/parse.c,v
retrieving revision 1.15
diff -u -p -r1.15 parse.c
--- apps/pice/module/parse.c 10 Feb 2002 02:01:31 -0000 1.15
+++ apps/pice/module/parse.c 8 May 2002 16:54:22 -0000
@@ -2029,8 +2029,8 @@ COMMAND_PROTOTYPE(Ver)
COMMAND_PROTOTYPE(Hboot)
{
// nudge the reset line through keyboard controller
- __asm__("
- movb $0xFE,%al
+ __asm__("\n\t \
+ movb $0xFE,%al\n\t \
outb %al,$0x64");
// never gets here
return TRUE;
Index: apps/pice/module/patch.c
===================================================================
RCS file: /CVS/ReactOS/reactos/apps/pice/module/patch.c,v
retrieving revision 1.10
diff -u -p -r1.10 patch.c
--- apps/pice/module/patch.c 10 Feb 2002 20:21:40 -0000 1.10
+++ apps/pice/module/patch.c 8 May 2002 16:54:22 -0000
@@ -101,12 +101,12 @@ BOOLEAN PiceKbdIsr (
bEnterNow=TRUE;
bControl=FALSE;
// simulate an initial break
- __asm__("
- pushfl
- pushl %cs
- pushl $returnpoint
- pushl $" STR(REASON_CTRLF) "
- jmp NewInt31Handler
+ __asm__("\n\t \
+ pushfl\n\t \
+ pushl %cs\n\t \
+ pushl $returnpoint\n\t \
+ pushl $" STR(REASON_CTRLF) "\n\t \
+ jmp NewInt31Handler\n\t \
returnpoint:");
*pByte = 0x1d | 0x80 | 0x7f;
bForward=TRUE;
Index: apps/pice/module/pgflt.c
===================================================================
RCS file: /CVS/ReactOS/reactos/apps/pice/module/pgflt.c,v
retrieving revision 1.10
diff -u -p -r1.10 pgflt.c
--- apps/pice/module/pgflt.c 30 Jan 2002 20:42:04 -0000 1.10
+++ apps/pice/module/pgflt.c 8 May 2002 16:54:22 -0000
@@ -290,71 +290,71 @@ ULONG HandlePageFault(FRAME* ptr)
// NewIntEHandler()
//
//*************************************************************************
-__asm__ ("
-NewIntEHandler:
- pushfl
- cli
- cld
- pushal
- pushl %ds
-
- // setup default data selectors
- movw %ss,%ax
- movw %ax,%ds
-
- /*
- * Load the PCR selector.
- */
- movl %fs, %eax
- movl %eax, _OLD_PCR
- movl _PCR_SEL, %eax
- movl %eax, %fs
-
- // get frame ptr
- lea 40(%esp),%eax
- pushl %eax
- call _HandlePageFault
- addl $4,%esp
-
- pushl %eax
- movl _OLD_PCR, %eax
- movl %eax, %fs
- popl %eax
-
- cmpl $0,%eax
- je call_old_inte_handler
-
- cmpl $2,%eax
- je call_handler_unknown_reason
-
- popl %ds
- popal
- popfl
- // remove error code. will be restored later when we call
- // original handler again.
- addl $4,%esp
- // call debugger loop
- pushl $" STR(REASON_PAGEFAULT) "
- jmp NewInt31Handler
-
-call_old_inte_handler:
- popl %ds
- popal
- popfl
- // chain to old handler
- .byte 0x2e
- jmp *_OldIntEHandler
-
-call_handler_unknown_reason:
- popl %ds
- popal
- popfl
- // remove error code. will be restored later when we call
- // original handler again.
- addl $4,%esp
- // call debugger loop
- pushl $" STR(REASON_INTERNAL_ERROR) "
- jmp NewInt31Handler
+__asm__ ("\n\t \
+NewIntEHandler:\n\t \
+ pushfl\n\t \
+ cli\n\t \
+ cld\n\t \
+ pushal\n\t \
+ pushl %ds\n\t \
+\n\t \
+ // setup default data selectors\n\t \
+ movw %ss,%ax\n\t \
+ movw %ax,%ds\n\t \
+\n\t \
+ /*\n\t \
+ * Load the PCR selector.\n\t \
+ */\n\t \
+ movl %fs, %eax\n\t \
+ movl %eax, _OLD_PCR\n\t \
+ movl _PCR_SEL, %eax\n\t \
+ movl %eax, %fs\n\t \
+\n\t \
+ // get frame ptr\n\t \
+ lea 40(%esp),%eax\n\t \
+ pushl %eax\n\t \
+ call _HandlePageFault\n\t \
+ addl $4,%esp\n\t \
+\n\t \
+ pushl %eax\n\t \
+ movl _OLD_PCR, %eax\n\t \
+ movl %eax, %fs\n\t \
+ popl %eax\n\t \
+\n\t \
+ cmpl $0,%eax\n\t \
+ je call_old_inte_handler\n\t \
+\n\t \
+ cmpl $2,%eax\n\t \
+ je call_handler_unknown_reason\n\t \
+\n\t \
+ popl %ds\n\t \
+ popal\n\t \
+ popfl\n\t \
+ // remove error code. will be restored later when we call\n\t \
+ // original handler again.\n\t \
+ addl $4,%esp\n\t \
+ // call debugger loop\n\t \
+ pushl $" STR(REASON_PAGEFAULT) "\n\t \
+ jmp NewInt31Handler\n\t \
+\n\t \
+call_old_inte_handler:\n\t \
+ popl %ds\n\t \
+ popal\n\t \
+ popfl\n\t \
+ // chain to old handler\n\t \
+ .byte 0x2e\n\t \
+ jmp *_OldIntEHandler\n\t \
+\n\t \
+call_handler_unknown_reason:\n\t \
+ popl %ds\n\t \
+ popal\n\t \
+ popfl\n\t \
+ // remove error code. will be restored later when we call\n\t \
+ // original handler again.\n\t \
+ addl $4,%esp\n\t \
+ // call debugger loop\n\t \
+ pushl $" STR(REASON_INTERNAL_ERROR) "\n\t \
+ jmp NewInt31Handler\n\t \
");
Index: apps/pice/module/shell.c
===================================================================
RCS file: /CVS/ReactOS/reactos/apps/pice/module/shell.c,v
retrieving revision 1.9
diff -u -p -r1.9 shell.c
--- apps/pice/module/shell.c 10 Feb 2002 20:21:40 -0000 1.9
+++ apps/pice/module/shell.c 8 May 2002 16:54:23 -0000
@@ -439,17 +439,17 @@ void DebuggerShell(void)
ulLastLineDisplayedOffset = 0;
PrintRingBuffer(wWindow[OUTPUT_WINDOW].cy-1);
// setup a safe stack for parsing
- __asm__ __volatile__("
- movl %2,%%eax
- movl %%esp,%%ebx
- mov %%ebx,%0
- leal _aulNewStack,%%ebx
- addl $0x1FFF0,%%ebx
- movl %%ebx,%%esp
- pushl $0
- pushl %%eax
- call _Parse
- movl %0,%%ebx
+ __asm__ __volatile__("\n\t \
+ movl %2,%%eax\n\t \
+ movl %%esp,%%ebx\n\t \
+ mov %%ebx,%0\n\t \
+ leal _aulNewStack,%%ebx\n\t \
+ addl $0x1FFF0,%%ebx\n\t \
+ movl %%ebx,%%esp\n\t \
+ pushl $0\n\t \
+ pushl %%eax\n\t \
+ call _Parse\n\t \
+ movl %0,%%ebx\n\t \
movl %%ebx,%%esp"
:"=m" (ulOldStack)
:"m" (ulOldStack),"m" (ucCommandBuffer)
@@ -528,17 +528,17 @@ void DebuggerShell(void)
PrintRingBuffer(wWindow[OUTPUT_WINDOW].cy-1);
// setup a safe stack for parsing
- __asm__ __volatile__("
- movl %2,%%eax
- movl %%esp,%%ebx
- mov %%ebx,%0
- leal _aulNewStack,%%ebx
- addl $0x1FFF0,%%ebx
- movl %%ebx,%%esp
- pushl $1
- pushl %%eax
- call _Parse
- movl %0,%%ebx
+ __asm__ __volatile__("\n\t \
+ movl %2,%%eax\n\t \
+ movl %%esp,%%ebx\n\t \
+ mov %%ebx,%0\n\t \
+ leal _aulNewStack,%%ebx\n\t \
+ addl $0x1FFF0,%%ebx\n\t \
+ movl %%ebx,%%esp\n\t \
+ pushl $1\n\t \
+ pushl %%eax\n\t \
+ call _Parse\n\t \
+ movl %0,%%ebx\n\t \
movl %%ebx,%%esp"
:"=m" (ulOldStack)
:"m" (ulOldStack),"m" (ucCommandBuffer)
@@ -1138,11 +1138,11 @@ void RealIsr(ULONG dwReasonForBreak)
DPRINT((0,"REASON_HARDWARE_BP\n"));
// disable HW breakpoints
- __asm__("
- movl %%dr6,%%eax
- movl %%eax,%0
- xorl %%eax,%%eax
- movl %%eax,%%dr6
+ __asm__("\n\t \
+ movl %%dr6,%%eax\n\t \
+ movl %%eax,%0\n\t \
+ xorl %%eax,%%eax\n\t \
+ movl %%eax,%%dr6\n\t \
movl %%eax,%%dr7"
:"=m" (ulReason)
:
@@ -1399,32 +1399,32 @@ void RealIsr(ULONG dwReasonForBreak)
DPRINT((0,"RealIsr(): saving registers\n"));
// save the extended regs
__asm__ __volatile__
- ("
- pushl %eax
- movw %es,%ax
- movw %ax,_CurrentES
- //movw %fs,%ax
- //movw %ax,_CurrentFS
- movw %gs,%ax
- movw %ax,_CurrentGS
- movl %dr0,%eax
- movl %eax,_CurrentDR0
- movl %dr1,%eax
- movl %eax,_CurrentDR1
- movl %dr2,%eax
- movl %eax,_CurrentDR2
- movl %dr3,%eax
- movl %eax,_CurrentDR3
- movl %dr6,%eax
- movl %eax,_CurrentDR6
- movl %dr7,%eax
- movl %eax,_CurrentDR7
- movl %cr0,%eax
- movl %eax,_CurrentCR0
- movl %cr2,%eax
- movl %eax,_CurrentCR2
- movl %cr3,%eax
- movl %eax,_CurrentCR3
+ ("\n\t \
+ pushl %eax\n\t \
+ movw %es,%ax\n\t \
+ movw %ax,_CurrentES\n\t \
+ //movw %fs,%ax\n\t \
+ //movw %ax,_CurrentFS\n\t \
+ movw %gs,%ax\n\t \
+ movw %ax,_CurrentGS\n\t \
+ movl %dr0,%eax\n\t \
+ movl %eax,_CurrentDR0\n\t \
+ movl %dr1,%eax\n\t \
+ movl %eax,_CurrentDR1\n\t \
+ movl %dr2,%eax\n\t \
+ movl %eax,_CurrentDR2\n\t \
+ movl %dr3,%eax\n\t \
+ movl %eax,_CurrentDR3\n\t \
+ movl %dr6,%eax\n\t \
+ movl %eax,_CurrentDR6\n\t \
+ movl %dr7,%eax\n\t \
+ movl %eax,_CurrentDR7\n\t \
+ movl %cr0,%eax\n\t \
+ movl %eax,_CurrentCR0\n\t \
+ movl %cr2,%eax\n\t \
+ movl %eax,_CurrentCR2\n\t \
+ movl %cr3,%eax\n\t \
+ movl %eax,_CurrentCR3\n\t \
popl %eax"
);
@@ -1464,174 +1464,174 @@ common_return_point:
}
-__asm__(".global NewInt31Handler
-NewInt31Handler:
- cli
- cld
-
- pushl %eax
- pushl %ds
-
- movw %ss,%ax
- mov %ax,%ds
-
- mov 0x4(%esp),%eax
- movl %eax,_CurrentEAX
- movl %ebx,_CurrentEBX
- movl %ecx,_CurrentECX
- movl %edx,_CurrentEDX
- movl %esi,_CurrentESI
- movl %edi,_CurrentEDI
- movl %ebp,_CurrentEBP
- movl (%esp),%eax
- movw %ax,_CurrentDS
-
- // test for V86 mode
- testl $0x20000,5*4(%esp)
- jz notV86
-
- int $0x03
-
-notV86:
- // test if stack switched (ring3->ring0 transition)
- // stack is switched if orig. SS is not global kernel code segment
- movl 4*4(%esp),%eax
- cmpw $" STR(GLOBAL_CODE_SEGMENT) ",%ax
- je notswitched
-
- // switched stack
- movl 6*4(%esp),%eax
- mov %eax,_CurrentESP
- mov 7*4(%esp),%eax
- movzwl %ax,%eax
- mov %ax,_CurrentSS
- jmp afterswitch
-
-notswitched:
- // didn't switch stack
- movl %esp,_CurrentESP
- addl $24,_CurrentESP
- movw %ss,%ax
- movzwl %ax,%eax
- mov %ax,_CurrentSS
-
-afterswitch:
- // save EIP
- mov 3*4(%esp),%eax
- mov %eax,_CurrentEIP
- //save CS
- mov 4*4(%esp),%eax
- movzwl %ax,%eax
- movw %ax,_CurrentCS
- // save flags
- movl 5*4(%esp),%eax
- andl $0xFFFFFEFF,%eax
- movl %eax,_CurrentEFL
-
- pushal
-
- // get reason code
- mov 0x28(%esp),%ebx
-
- /*
- * Load the PCR selector.
- */
-
- movl %fs, %eax
- movl %eax, _OLD_PCR
- movl _PCR_SEL, %eax
- movl %eax, %fs
-
- // setup a large work stack
- movl %esp,%eax
- movl %eax,_ulRealStackPtr
-
- pushl %ebx
- call _RealIsr
- addl $4,%esp
-
- pushl %eax
- movl _OLD_PCR, %eax
- movl %eax, %fs
- popl %eax
-
- // restore all regs
- popal
-
- // do an EOI to IRQ controller (because we definitely pressed some key)
- // TODO: SMP APIC support
- movb $0x20,%al
- outb %al,$0x20
-
- popl %ds
- popl %eax
-
- // remove reason code
- addl $4,%esp
-
- // make EAX available
- pushl %eax
-
- // modify or restore EFLAGS
- .byte 0x2e
- mov _CurrentEFL,%eax
- mov %eax,3*4(%esp)
- .byte 0x2e
- movzwl _CurrentCS,%eax
- mov %eax,2*4(%esp)
- .byte 0x2e
- mov _CurrentEIP,%eax
- mov %eax,1*4(%esp)
-
- // restore EAX
- popl %eax
-
- // do we need to call old INT1 handler
- .byte 0x2e
- cmp $0,_dwCallOldInt1Handler
- je do_iret2
-
- // call INT3 handler
- .byte 0x2e
- jmp *_OldInt1Handler
-
-do_iret2:
- // do we need to call old INT3 handler
- .byte 0x2e
- cmp $0,_dwCallOldInt3Handler
- je do_iret1
-
- // call INT3 handler
- .byte 0x2e
- jmp *_OldInt3Handler
-
-do_iret1:
- // do we need to call old pagefault handler
- .byte 0x2e
- cmp $0,_dwCallOldIntEHandler
- je do_iret3
-
- // call old pagefault handler
- .byte 0x2e
- pushl _error_code
- .byte 0x2e
- jmp *_OldIntEHandler
-
-do_iret3:
- // do we need to call old general protection fault handler
- .byte 0x2e
- cmp $0,_dwCallOldGPFaultHandler
- je do_iret
-
- // call old pagefault handler
- .byte 0x2e
- pushl _error_code
- .byte 0x2e
- jmp *_OldGPFaultHandler
-
-do_iret:
- //ei
- //int3
+__asm__(".global NewInt31Handler\n\t \
+NewInt31Handler:\n\t \
+ cli\n\t \
+ cld\n\t \
+\n\t \
+ pushl %eax\n\t \
+ pushl %ds\n\t \
+\n\t \
+ movw %ss,%ax\n\t \
+ mov %ax,%ds\n\t \
+\n\t \
+ mov 0x4(%esp),%eax\n\t \
+ movl %eax,_CurrentEAX\n\t \
+ movl %ebx,_CurrentEBX\n\t \
+ movl %ecx,_CurrentECX\n\t \
+ movl %edx,_CurrentEDX\n\t \
+ movl %esi,_CurrentESI\n\t \
+ movl %edi,_CurrentEDI\n\t \
+ movl %ebp,_CurrentEBP\n\t \
+ movl (%esp),%eax\n\t \
+ movw %ax,_CurrentDS\n\t \
+\n\t \
+ // test for V86 mode\n\t \
+ testl $0x20000,5*4(%esp)\n\t \
+ jz notV86\n\t \
+\n\t \
+ int $0x03\n\t \
+\n\t \
+notV86:\n\t \
+ // test if stack switched (ring3->ring0 transition)\n\t \
+ // stack is switched if orig. SS is not global kernel code segment\n\t \
+ movl 4*4(%esp),%eax\n\t \
+ cmpw $" STR(GLOBAL_CODE_SEGMENT) ",%ax\n\t \
+ je notswitched\n\t \
+\n\t \
+ // switched stack\n\t \
+ movl 6*4(%esp),%eax\n\t \
+ mov %eax,_CurrentESP\n\t \
+ mov 7*4(%esp),%eax\n\t \
+ movzwl %ax,%eax\n\t \
+ mov %ax,_CurrentSS\n\t \
+ jmp afterswitch\n\t \
+\n\t \
+notswitched:\n\t \
+ // didn't switch stack\n\t \
+ movl %esp,_CurrentESP\n\t \
+ addl $24,_CurrentESP\n\t \
+ movw %ss,%ax\n\t \
+ movzwl %ax,%eax\n\t \
+ mov %ax,_CurrentSS\n\t \
+\n\t \
+afterswitch:\n\t \
+ // save EIP\n\t \
+ mov 3*4(%esp),%eax\n\t \
+ mov %eax,_CurrentEIP\n\t \
+ //save CS\n\t \
+ mov 4*4(%esp),%eax\n\t \
+ movzwl %ax,%eax\n\t \
+ movw %ax,_CurrentCS\n\t \
+ // save flags\n\t \
+ movl 5*4(%esp),%eax\n\t \
+ andl $0xFFFFFEFF,%eax\n\t \
+ movl %eax,_CurrentEFL\n\t \
+\n\t \
+ pushal\n\t \
+\n\t \
+ // get reason code\n\t \
+ mov 0x28(%esp),%ebx\n\t \
+\n\t \
+ /*\n\t \
+ * Load the PCR selector.\n\t \
+ */\n\t \
+\n\t \
+ movl %fs, %eax\n\t \
+ movl %eax, _OLD_PCR\n\t \
+ movl _PCR_SEL, %eax\n\t \
+ movl %eax, %fs\n\t \
+\n\t \
+ // setup a large work stack\n\t \
+ movl %esp,%eax\n\t \
+ movl %eax,_ulRealStackPtr\n\t \
+\n\t \
+ pushl %ebx\n\t \
+ call _RealIsr\n\t \
+ addl $4,%esp\n\t \
+\n\t \
+ pushl %eax\n\t \
+ movl _OLD_PCR, %eax\n\t \
+ movl %eax, %fs\n\t \
+ popl %eax\n\t \
+\n\t \
+ // restore all regs\n\t \
+ popal\n\t \
+\n\t \
+ // do an EOI to IRQ controller (because we definitely pressed some key)\n\t \
+ // TODO: SMP APIC support\n\t \
+ movb $0x20,%al\n\t \
+ outb %al,$0x20\n\t \
+\n\t \
+ popl %ds\n\t \
+ popl %eax\n\t \
+\n\t \
+ // remove reason code\n\t \
+ addl $4,%esp\n\t \
+\n\t \
+ // make EAX available\n\t \
+ pushl %eax\n\t \
+\n\t \
+ // modify or restore EFLAGS\n\t \
+ .byte 0x2e\n\t \
+ mov _CurrentEFL,%eax\n\t \
+ mov %eax,3*4(%esp)\n\t \
+ .byte 0x2e\n\t \
+ movzwl _CurrentCS,%eax\n\t \
+ mov %eax,2*4(%esp)\n\t \
+ .byte 0x2e\n\t \
+ mov _CurrentEIP,%eax\n\t \
+ mov %eax,1*4(%esp)\n\t \
+\n\t \
+ // restore EAX\n\t \
+ popl %eax\n\t \
+\n\t \
+ // do we need to call old INT1 handler\n\t \
+ .byte 0x2e\n\t \
+ cmp $0,_dwCallOldInt1Handler\n\t \
+ je do_iret2\n\t \
+\n\t \
+ // call INT3 handler\n\t \
+ .byte 0x2e\n\t \
+ jmp *_OldInt1Handler\n\t \
+\n\t \
+do_iret2:\n\t \
+ // do we need to call old INT3 handler\n\t \
+ .byte 0x2e\n\t \
+ cmp $0,_dwCallOldInt3Handler\n\t \
+ je do_iret1\n\t \
+\n\t \
+ // call INT3 handler\n\t \
+ .byte 0x2e\n\t \
+ jmp *_OldInt3Handler\n\t \
+\n\t \
+do_iret1:\n\t \
+ // do we need to call old pagefault handler\n\t \
+ .byte 0x2e\n\t \
+ cmp $0,_dwCallOldIntEHandler\n\t \
+ je do_iret3\n\t \
+\n\t \
+ // call old pagefault handler\n\t \
+ .byte 0x2e\n\t \
+ pushl _error_code\n\t \
+ .byte 0x2e\n\t \
+ jmp *_OldIntEHandler\n\t \
+\n\t \
+do_iret3:\n\t \
+ // do we need to call old general protection fault handler\n\t \
+ .byte 0x2e\n\t \
+ cmp $0,_dwCallOldGPFaultHandler\n\t \
+ je do_iret\n\t \
+\n\t \
+ // call old pagefault handler\n\t \
+ .byte 0x2e\n\t \
+ pushl _error_code\n\t \
+ .byte 0x2e\n\t \
+ jmp *_OldGPFaultHandler\n\t \
+\n\t \
+do_iret:\n\t \
+ //ei\n\t \
+ //int3\n\t \
iretl ");
//
@@ -1639,18 +1639,18 @@ do_iret:
//
// IDTs keyboard IRQ points here
//
-__asm__ ("
-NewGlobalInt31Handler:
- .byte 0x2e
- cmpb $0,_bEnterNow
- jne dotheenter
-
- // chain to old handler
- .byte 0x2e
- jmp *_OldGlobalInt31Handler
-
-dotheenter:
- pushl $" STR(REASON_CTRLF) "
+__asm__ ("\n\t \
+NewGlobalInt31Handler:\n\t \
+ .byte 0x2e\n\t \
+ cmpb $0,_bEnterNow\n\t \
+ jne dotheenter\n\t \
+\n\t \
+ // chain to old handler\n\t \
+ .byte 0x2e\n\t \
+ jmp *_OldGlobalInt31Handler\n\t \
+\n\t \
+dotheenter:\n\t \
+ pushl $" STR(REASON_CTRLF) "\n\t \
jmp NewInt31Handler "
);
Index: apps/pice/module/syscall.c
===================================================================
RCS file: /CVS/ReactOS/reactos/apps/pice/module/syscall.c,v
retrieving revision 1.4
diff -u -p -r1.4 syscall.c
--- apps/pice/module/syscall.c 14 Jan 2002 22:04:08 -0000 1.4
+++ apps/pice/module/syscall.c 8 May 2002 16:54:23 -0000
@@ -156,39 +156,39 @@ void CSyscallHandler(FRAME_SYSCALL* ptr,
*/
}
-__asm__ ("
-NewSyscallHandler:
- // save used regs
- pushfl
- cli
- cld
- pushal
- pushl %ds
-
- // push the syscall number
- pushl %ebx
- pushl %eax
-
- // frame ptr
- lea 48(%esp),%eax
- pushl %eax
-
- // setup default data selectors
- movw %ss,%ax
- movw %ax,%ds
-
- call _CSyscallHandler
-
- // remove pushed params
- add $12,%esp
-
- // restore used regs
- popl %ds
- popal
- popfl
-
- // chain to old handler
- .byte 0x2e
+__asm__ ("\n\t \
+NewSyscallHandler:\n\t \
+ // save used regs\n\t \
+ pushfl\n\t \
+ cli\n\t \
+ cld\n\t \
+ pushal\n\t \
+ pushl %ds\n\t \
+\n\t \
+ // push the syscall number\n\t \
+ pushl %ebx\n\t \
+ pushl %eax\n\t \
+\n\t \
+ // frame ptr\n\t \
+ lea 48(%esp),%eax\n\t \
+ pushl %eax\n\t \
+\n\t \
+ // setup default data selectors\n\t \
+ movw %ss,%ax\n\t \
+ movw %ax,%ds\n\t \
+\n\t \
+ call _CSyscallHandler\n\t \
+\n\t \
+ // remove pushed params\n\t \
+ add $12,%esp\n\t \
+\n\t \
+ // restore used regs\n\t \
+ popl %ds\n\t \
+ popal\n\t \
+ popfl\n\t \
+\n\t \
+ // chain to old handler\n\t \
+ .byte 0x2e\n\t \
jmp *_OldSyscallHandler");
void InstallSyscallHook(void)
Index: apps/pice/module/trace.c
===================================================================
RCS file: /CVS/ReactOS/reactos/apps/pice/module/trace.c,v
retrieving revision 1.4
diff -u -p -r1.4 trace.c
--- apps/pice/module/trace.c 31 Jan 2002 05:30:06 -0000 1.4
+++ apps/pice/module/trace.c 8 May 2002 16:54:23 -0000
@@ -60,21 +60,21 @@ BOOLEAN InstallTraceHook(void)
//this asm function must be at least second in the file. otherwise gcc does not
//generate correct code.
-__asm__("
-NewInt1Handler:
- pushl %eax
- movl %dr6,%eax
- testl $(1<<14),%eax
- jz exceptionnotsinglestep
-
- popl %eax
- pushl $" STR(REASON_SINGLESTEP) "
- jmp NewInt31Handler
-
-exceptionnotsinglestep:
- popl %eax
- pushl $" STR(REASON_HARDWARE_BP) "
- jmp NewInt31Handler
+__asm__("\n\t \
+NewInt1Handler:\n\t \
+ pushl %eax\n\t \
+ movl %dr6,%eax\n\t \
+ testl $(1<<14),%eax\n\t \
+ jz exceptionnotsinglestep\n\t \
+\n\t \
+ popl %eax\n\t \
+ pushl $" STR(REASON_SINGLESTEP) "\n\t \
+ jmp NewInt31Handler\n\t \
+\n\t \
+exceptionnotsinglestep:\n\t \
+ popl %eax\n\t \
+ pushl $" STR(REASON_HARDWARE_BP) "\n\t \
+ jmp NewInt31Handler\n\t \
");
void DeInstallTraceHook(void)
Index: apps/pice/module/utils.c
===================================================================
RCS file: /CVS/ReactOS/reactos/apps/pice/module/utils.c,v
retrieving revision 1.19
diff -u -p -r1.19 utils.c
--- apps/pice/module/utils.c 10 Feb 2002 20:21:40 -0000 1.19
+++ apps/pice/module/utils.c 8 May 2002 16:54:24 -0000
@@ -812,8 +812,8 @@ ULONG GetLinearAddress(USHORT Segment,UL
{
DPRINT((0,"GetLinearAddress(): Segment is in LDT\n"));
// get LDT selector
- __asm__("
- sldt %%ax
+ __asm__("\n\t \
+ sldt %%ax\n\t \
mov %%ax,%0"
:"=m" (Segment));
if(Segment)
@@ -900,12 +900,12 @@ void SetHardwareBreakPoint(ULONG ulAddre
DPRINT((0,"mask = %x\n",mask));
__asm__ __volatile__
- ("
- xorl %%eax,%%eax
- mov %%eax,%%dr6
- mov %%dr7,%%eax
- orl %0,%%eax
- mov %%eax,%%dr7
+ ("\n\t \
+ xorl %%eax,%%eax\n\t \
+ mov %%eax,%%dr6\n\t \
+ mov %%dr7,%%eax\n\t \
+ orl %0,%%eax\n\t \
+ mov %%eax,%%dr7\n\t \
"
:
:"m" (mask)
@@ -915,9 +915,9 @@ void SetHardwareBreakPoint(ULONG ulAddre
{
case 0:
__asm__ __volatile__
- ("
- mov %0,%%eax
- mov %%eax,%%dr0
+ ("\n\t \
+ mov %0,%%eax\n\t \
+ mov %%eax,%%dr0\n\t \
"
:
:"m" (ulAddress)
@@ -925,9 +925,9 @@ void SetHardwareBreakPoint(ULONG ulAddre
break;
case 1:
__asm__ __volatile__
- ("
- mov %0,%%eax
- mov %%eax,%%dr1
+ ("\n\t \
+ mov %0,%%eax\n\t \
+ mov %%eax,%%dr1\n\t \
"
:
:"m" (ulAddress)
@@ -935,9 +935,9 @@ void SetHardwareBreakPoint(ULONG ulAddre
break;
case 2:
__asm__ __volatile__
- ("
- mov %0,%%eax
- mov %%eax,%%dr2
+ ("\n\t \
+ mov %0,%%eax\n\t \
+ mov %%eax,%%dr2\n\t \
"
:
:"m" (ulAddress)
@@ -945,9 +945,9 @@ void SetHardwareBr...
[truncated message content] |
|
From: Phillip S. <ps...@cf...> - 2002-05-08 19:32:55
|
It should not be possible to delete a section while a page is being faulted in from it, because when the section is mapped, the section object should be referenced, thus preventing it from being freed. The fault doesn't need to reference the section, because it is referenced as soon as it is mapped. At 04:16 PM 5/8/2002 +0100, you wrote: >Ok, thanks for the explanation. I don't think this fixes all the problems >of this type: for example MmNotPresentFaultSectionView doesn't even >reference the section so it could be freed by the time it returns after >waiting for the page operation. The fix I was considering was to check for >pending page operations on a unmap/process exit and either wait for them >to complete or abandon freeing section pages that are about to be used in >another process. |
|
From: David W. <we...@cw...> - 2002-05-08 21:19:52
|
On Wed, May 08, 2002 at 03:29:18PM -0400, Phillip Susi wrote: > It should not be possible to delete a section while a page is being faulted > in from it, because when the section is mapped, the section object should > be referenced, thus preventing it from being freed. The fault doesn't need > to reference the section, because it is referenced as soon as it is mapped. > Yes but one thread in a process could be faulting on a section while the other unmaps it. Of course this would be a very stupid application and it still might cause an exception but it shouldn't cause the kernel itself to crash or exhibit unboundedly undefined behaviour. |
|
From: Phillip S. <ps...@cf...> - 2002-05-10 16:07:28
|
This shouldn't be able to happen because the page fault path should reference/lock the address space/page tables as it is updating them, and that would prevent it from being unmapped. It might be a good idea for the unmap code to be able to cancel pending paging IO though, and then unmap. This way paging IO to a slow device, such as a slow network server, couldn't prevent a process from being terminated quickly. At 10:20 PM 5/8/2002 +0000, you wrote: >On Wed, May 08, 2002 at 03:29:18PM -0400, Phillip Susi wrote: > > It should not be possible to delete a section while a page is being > faulted > > in from it, because when the section is mapped, the section object should > > be referenced, thus preventing it from being freed. The fault doesn't > need > > to reference the section, because it is referenced as soon as it is mapped. > > >Yes but one thread in a process could be faulting on a section while the >other unmaps it. Of course this would be a very stupid application and >it still might cause an exception but it shouldn't cause the kernel >itself to crash or exhibit unboundedly undefined behaviour. |