Commit graph

27 commits

Author SHA1 Message Date
Timo Kreuzer 038a2fbb39 [NTOSKRNL]
- Implement saving / restoring debug registers on traps
- Replace the loop in KeContextToTrapFrame with something less ridiculous
- fixes a number of ntdd exception winetests

svn path=/trunk/; revision=56357
2012-04-18 13:39:19 +00:00
Stefan Ginsberg b2cabd4df9 [NTOSKRNL]
- Fix KiEnterV86Mode's check for TRAP_DEBUG to #if instead of #ifdef, it is either defined to 1 or 0, like DBG.

svn path=/trunk/; revision=55709
2012-02-19 10:38:38 +00:00
Thomas Faber f9a5be185d [NTOSKRNL]
- Make Trap debugging usable again. Suggested by Stefan.

svn path=/trunk/; revision=55701
2012-02-19 08:38:09 +00:00
Alex Ionescu 28f0bba7b4 [NTOSKRNL]: Implement SeCheckPrivilegedObject and call it in the two cases where it's needed (when changing process priority) instead of spamming the debug log that we're not doing the check.
[NTOSKRNL]: Implement ProcessUserModeIOPL info level (and implement Ke386SetIopl) instead of spamming we can't do this.
[NTOSKRNL]: Implement ProcessExecuteOptions info level (and implement MmSetExecuteOptions) instead of spamming we can't do this.
[NDK]: Add NoExecute Flags based on ProcessHacker.
No longer spammed to death for every process all the time.

svn path=/trunk/; revision=55688
2012-02-18 23:59:31 +00:00
Timo Kreuzer 30fad2a263 [NTOS]
- More fixes to VDM PUSH/POPF code: 
- When doing a 32bit push, don't store the flags 2 bytes off
- Recalculate HardwareEsp, by substracting the segment part, instead of truncating the flat pointer to 16 bit.

svn path=/trunk/; revision=48781
2010-09-16 19:21:20 +00:00
Aleksey Bragin a5c563dfdb [NTOS]
- Daniel Zimmermann: Fix POPF bugs in VDM mode, namely truncation of the stackpointer to 16 bit and setting proper flags in the trapframe eflags register. This fixes problems with videocards calling int 0x10 VESA BIOS extension.
See issue #5608 for more details.

svn path=/trunk/; revision=48745
2010-09-11 09:20:26 +00:00
Cameron Gutman 8481a4f1b9 [NTOSKRNL]
- Implement Ke386IoSetAccessProcess, Ke386SetIoAccessMap, and Ke386QueryIoAccessMap
[NDK]
- Add definition of KIO_ACCESS_MAP

- Patch by Samuel Serapion
- Fixes bug 2641

svn path=/trunk/; revision=47108
2010-05-05 23:06:32 +00:00
Timo Kreuzer cbdf28bb6a [HEADERS]
Reintegrate header-work branch. Thanks to hours of boring work on the ddk headers (Most of it done by Amine Khaldi), we have now a decent set, which is still incomplete but already relatively close to latest WDK. A clean rebuild is recommended.

svn path=/trunk/; revision=46155
2010-03-12 23:16:29 +00:00
Timo Kreuzer 9ea495ba33 Create a branch for header work.
svn path=/branches/header-work/; revision=45691
2010-02-26 22:57:55 +00:00
Sir Richard 532aff4429 [NTOS/PERF]: Enable VME support. VME stands for Virtual 8086 Mode Extensions, and it's an Intel optimization that makes changes to the IF bit in EFLAGS (CLI, STI, INT, IRETD, PUSHF, POPF) completely transprent: instead of changing the real (protected) bit, which requires the OS to trap and emulate the behavior, the CPU sets a "Fake" IF bit instead. When you're dong in V8086 mode, you simply update your real flag with whatever the fake flag says.
[NTOS]: Enable V8086 Fast-V86 Trap mode for Trap 6 (Invalid Opcode). Because we are now taking zero traps during V8086 mode, we can't do the "BOP lookahead", so the only trap we do get is when we hit the BOP/invalid opcode itself.
[NTOS]: Multiple fixes to V8086 opcode emulation code that I noticed while looking through the source. Also multiple fixes to VDM code.
This change will only impact real hardware and VMWare, since QEMU does not support VME. On VMWare, performance increased up to 400% during bootup (80 million cycles instead of 300 million, in one test).

svn path=/trunk/; revision=45282
2010-01-27 05:34:38 +00:00
Sir Richard 1cb5c9f019 [NTOS]: Remove debug spew (but keep Flag macros and fixes which fixed other bugs), thanks Timo.
svn path=/trunk/; revision=45063
2010-01-13 21:56:14 +00:00
Timo Kreuzer a12f63e380 [NTOS]
KiExitV86Mode is supposed to return a pointer to the protected mode KTRAP_FRAME. Instead it was returning the value of TrapFrame->Edi, which would be identical to PmTrapFrame->Ebp, which doesn't have any particular meaning. Fix it by returning PmTrapFrame directly. Fixes 2nd stage boot.

svn path=/trunk/; revision=45062
2010-01-13 21:31:55 +00:00
Sir Richard de10db923c [NTOS]: Fix some bugs and cleanup V8086 code in regards to flags usage.
[NTOS]: Add VDM debug spew to see why there's now an invalid opcode on Windows builds of VMWare and certain QEmu combinations. (Note: the double fault issue is fixed, this is a new issue).

svn path=/trunk/; revision=45057
2010-01-13 03:43:03 +00:00
Sir Richard 68ca27a00d Patch that fixes VMWare boot (and should fix QEMu/KVM boot on the testbot):
[NTOS]: A trap can get us into a state where DS/ES are invalid, making any pointer dereference (on DS/ES segmented memory, not SS, the stack) crash (and probably double-fault). Therefore, we have to be careful to switch to a good DS/ES before touching the TrapFrame pointer, which we don't have in ESP like the ASM code, but in a DS/ES-segmented register. For V8086 traps we can switch to the good DS/ES immediately, but for other kinds of traps, we actually need to save the current (bad) segments first. So we save them on the stack now, then switch to the good ones, then store the stack values into the trap frame. This is what happens on a non-optimized (-O0) build. On an optimized build, the segments will end up in registers instead, which is fine too (they'll be direct values). The order of instructions is guaranteed since the segment macros are volatile.
[NTOS]: The GPF and Invalid Opcode handlers are performance critical when talking about V8086 traps, because they control the main flow of execution during that mode (GPFs will be issued for any privileged instruction we need to emulate, and invalid opcode might be generated for BOPs). Because of this, we employ a fast entry/exit macro into V8086 mode since we can make certain assumptions. We detect, and use, such scenarios when the V8086 flag is enabled in EFLAGS. However, because we can land in a GPF handler with an invalid DS/ES, as some V8086 code could trample this during BIOS calls for example, we must make sure that we are on a valid DS/ES before dereferencing any pointer. We fixup DS/ES either in KiEnterTrap (for normal entry/exit) or, for V86, in KiEnterV86Trap. Notice the problem: we need to detect which of these to use early on but we can't touch the EFLAGS in the frame because DS/ES could be invalid. Thankfully SS is always guaranteed valid, so stack dereferences are game! We therefore read the EFLAGS here, in assembly, where we can touch ESP as we please. We save this in EDX, which will be used as the second argument for the FASTCALL C trap entry. When we make the fast V86 check, we use the parameter instead of the trap frame, leading us to using the correct trap entry function, which fixes up DS/ES and lets us go on our merry way...
[NTOS]: Make appropriate changes to GENERATE_TRAP_HANDLERS macro.
[NTOS]: Switch to using well-known NT trap handler names (hex-based, double-zeroed) instead of decimal-based trap handler names which are confusing.
[NTOS]: Clean up some debug spew.

svn path=/trunk/; revision=45052
2010-01-12 05:50:45 +00:00
Sir Richard 1f21afc098 [NTOS]: Bring back a simplified GPF handler just for V8086 opcode detection and V8086 exit, to see if this resolves testbot booting.
svn path=/trunk/; revision=45048
2010-01-11 19:41:50 +00:00
Sir Richard 0feb759f62 [NTOS]: Switch to a slightly (perhaps, hopefully?) safer version of V86 entry/exit to see if this fixes the buildbot boot (suffice it to say, the original code works fine on my test machine, but since half the developers seem to be using GCC 4.4 and the others GCC 4.1, I wouldn't be surprised if there's compiler subtleties involved).
svn path=/trunk/; revision=45046
2010-01-11 18:26:46 +00:00
Sir Richard 0fc870d7d9 Trap handlers in C patch 7 of X:
[NTOS]: Implement GPF handler (trap 13) in C. This was by far the most complex one of them, since it also servces two complex purposes: to handle V86 emulation since the real-mode code will generate GPFs during privileged instructions, and it will detect an illegal IRET, check if it's the known V8086 Exit IRET, and then jump to V86 exit code.
    [NTOS]: Get rid of even more V8086 assembly since the GPF handler is now C. Deleted the entire V8086 assembly file.
    [NTOS]: Get rid of a bunch of helper ASM functions that nobody is using anymore since almost all the trap handlers are in C.

svn path=/trunk/; revision=45038
2010-01-11 05:53:57 +00:00
Sir Richard 38de4a0a1c [NTOS]: Rewrite BIOS Call (V8086) Entry/Exit routines in C. Only 4 lines of ASM stub remain. This wasn't fun... the stack dancing alone gives you headaches. Who ever thought of dynamically sized trap frames!
svn path=/trunk/; revision=45037
2010-01-11 03:47:17 +00:00
Sir Richard 15b66143d6 [NTOS]: Implement all V8086 Opcode emulation in C instead of ASM.
svn path=/trunk/; revision=45029
2010-01-10 15:40:00 +00:00
Stefan Ginsberg beba1269e6 - Get rid of TAG() from the kernel
- mmtypes.h: Goodbye TAG(), you won't be missed

svn path=/trunk/; revision=42920
2009-08-24 18:19:53 +00:00
Stefan Ginsberg 8e1c35ecc1 - Stub out Ke386IoSetAccessProcess, Ke386SetIoAccessMap and Ke386QueryIoAccessMap
- Reference: "The Simplest Device Drivers" http://www.freewebs.com/four-f/KmdTut/kmd03.html

svn path=/trunk/; revision=37147
2008-11-02 11:48:24 +00:00
Stefan Ginsberg f9eb539194 - Fix an assertion by casting to internal structures correctly
svn path=/trunk/; revision=36893
2008-10-22 13:24:01 +00:00
Johannes Anderwald 9b71253be1 set most of trunk svn property eol-style:native
svn path=/trunk/; revision=24701
2006-11-08 11:47:44 +00:00
Alex Ionescu 6d56cb39a6 - Fix dozens of missing typecast errors.
- Other MSVC/WDK compatibility fixes.

svn path=/trunk/; revision=24657
2006-10-26 01:49:51 +00:00
Thomas Bluemel 39500f9853 - Change RtlMoveMemory to RtlCopyMemory where memory regions are never overlapping
- Re-Secure a few Nt stubs by adding SEH/Probing where neccessary

svn path=/trunk/; revision=24599
2006-10-22 09:06:58 +00:00
Alex Ionescu a9bb1c6668 - Add about two dozen new bugcheck codes and strings.
- Major cleanup of exp.c to move out deprecated and old code.
- Use KdDebuggerNotPresent to determine if KDBG is there or not. KdDebuggerEnable is now set whenever booting with debugging -- even if only serial port or screen debugging.
- Complete cleanup and major rewrite/improvement of bugcheck code:
  - Moved stack dump routines to bug.c and cleaned them up. Next step is to remove most of them and implement them properly as part of RtlCaptureStackBackTrace and RtlWalkFrameChain.
  - Use InbvDisplayString for everything now. BSODs will only truly show on screen. (however, part of the KeBugCheckWithTf improvements, a special "if debugger enabled" BSOD will also be displayed for debugging purposes).
  - Do checksum calculation in bugcheck callbacks.
  - Detect and display which drivers belong to which EIP.
  - Implemented code to select the proper verbose BSOD message depending on the bug check code.
  - Also implemented code to detect a variety of "known" bug check codes and to recover more data on them, and/or modify them accordingly. Sadly ROS doesn't yet make use of most of these codes.
  - Factored out and split some code into individual routines.
  - Look and functionality is now identical to Windows XP.
  - Stack trace will only be shown if KDBG isn't connected. If KDBG is connected you can do "bt" anyway (which is more powerful).

svn path=/trunk/; revision=23794
2006-08-30 05:22:56 +00:00
Alex Ionescu 28122cd8d9 - Complete and utter reimplementation of V86 Mode for Ke386CallBios. Details below. Tested on QEMU/VMWARE. May give you a breakpoint/crash on real hardware - please let me know the V86 opcode displayed on the debug log/screen if this is the case *if you see such a message*.
- Got rid of all the previous related assembly code and implemented Ki386SetupAndExitToV86Mode and Ki386BiosCallREturnAddress.
- Implemented GPF (Trap 13) code for V86 faults (which will happen in V86 mode). Implement a generic Ki386HandleOpcodeV86 handler that increments counts and calls the right opcode handler.
- Implemented an Opcode Table Entry Index and Opcode Table array for mapping opcodes that caused a GPF to their V86 handlers/emulators.
- Implemented handlers for PUSHF, POPF, CLI, STI, IRETD and INTnn, which is what QEMU/VMWare and *most* VIDEO ROM BIOS code should use.
- Created a /vdm tree and moved all NTVDM/VDM specific code there.
- Halfplemented VdmStart/EndExecution APIs which the BIOS ROM V86 implementation is built upon. Currently don't handle VDM at all, only this V86 mode.
- Also added code for NtVdmControl and fixed up CSRSS and ACPI's calls to this API.
- Added detection and FIXMEs for support of VMEs in VMWare, Bochs and real hardware (VME is not yet supported).
- Move exp.c fixmes to krnlfun and remove kernel fun entries that this patch fixes.

svn path=/trunk/; revision=23763
2006-08-28 23:56:35 +00:00