// - Get rid of KiRosPrintAddress and use KiDumpParameterImages instead.\r
// - Sanitize some context fields during conversions.\r
// - Implement stack fault and segment fault handlers.\r
-// - Figure out why ES/DS gets messed up in VMWare, when doing KiServiceExit only,\r
-// and only when called from user-mode, and returning to user-mode.\r
// - Add DR macro/save and VM macro/save.\r
// - Implement KiCallbackReturn, KiGetTickCount, KiRaiseAssertion.\r
//\r
pushl %fs\r
pushl %gs\r
pushl $0xceafbeef\r
- movl $KGDT_R0_DATA,%eax\r
- movl %eax,%ds\r
- movl %eax,%es\r
- movl %eax,%gs\r
+\r
+ /* Load DS/ES (with override) */\r
+ .intel_syntax noprefix\r
+ mov eax, KGDT_R3_DATA + RPL_MASK\r
+ .byte 0x66\r
+ mov ds, ax\r
+ .byte 0x66\r
+ mov es, ax\r
+\r
+ /* Clear gs */\r
+ xor eax, eax\r
+ .byte 0x66\r
+ mov gs, ax\r
+ .att_syntax\r
movl $KGDT_R0_PCR,%eax\r
movl %eax,%fs\r
pushl %esp\r
@KiSwapContextInternal@0:
/* Set the Thread to running */
- mov byte ptr [esi+KTHREAD_STATE], Running
+ mov byte ptr es:[esi+KTHREAD_STATE], Running
/* Save the IRQL */
push ecx
__asm__ ("movl %0, %%ds\n\t"
"movl %0, %%es\n\t"
"movl %1, %%fs\n\t"
- "movl %0, %%gs\n\t"
+ "xor %%ax, %%ax\n\t"
+ "movw %%ax, %%gs\n\t"
: /* no output */
- : "a" (KGDT_R0_DATA), "d" (KGDT_R0_PCR));
+ : "a" (KGDT_R3_DATA | RPL_MASK), "d" (KGDT_R0_PCR));
__asm__ ("pushl %0\n\t"
"pushl $.l4\n\t"
"lret\n\t"
__asm
{
lgdt Descriptor;
- mov ax, KGDT_R0_DATA;
+ mov ax, KGDT_R3_DATA | RPL_MASK;
mov dx, KGDT_R0_PCR;
mov ds, ax;
mov es, ax;
mov fs, dx;
+ xor ax, ax
mov gs, ax;
push KGDT_R0_CODE;
push offset l4 ;
/* Load the PCR selector */
movl $KGDT_R0_PCR, %eax
movl %eax, %fs
-
+
+ /* Load DS/ES (with override) */
+ .intel_syntax noprefix
+ mov eax, KGDT_R3_DATA + RPL_MASK
+ .byte 0x66
+ mov ds, ax
+ .byte 0x66
+ mov es, ax
+ .att_syntax
+
cmpl $AP_MAGIC, %ecx
jne .m1
mov ecx, KGDT_R0_PCR
mov fs, cx
- /* Set DS/ES to Kernel Selector */
- mov ecx, KGDT_R0_DATA
+ /* Set DS/ES to User Selector */
+ mov ecx, KGDT_R3_DATA | RPL_MASK
mov ds, cx
mov es, cx
/* Skip the other registers */
sub esp, 0x48
- /* Hack: it seems that on VMWare someone damages ES/DS on exit. Investigate! */
- mov dword ptr [esp+KTRAP_FRAME_DS], KGDT_R3_DATA + RPL_MASK
- mov dword ptr [esp+KTRAP_FRAME_ES], KGDT_R3_DATA + RPL_MASK
-
/* Make space for us on the stack */
sub ebp, 0x29C
/* Check for, and deliver, User-Mode APCs if needed */
CHECK_FOR_APC_DELIVER 1
- /* Hack for VMWare: Sometimes ES/DS seem to be invalid when returning to user-mode. Investigate! */
- mov es, [ebp+KTRAP_FRAME_ES]
- mov ds, [ebp+KTRAP_FRAME_DS]
-
/* Exit and cleanup */
TRAP_EPILOG FromSystemCall, DoRestorePreviousMode, DoNotRestoreSegments, DoNotRestoreVolatiles, DoRestoreEverything
.endfunc