Add support for FP and XMM changeregonbp
This commit is contained in:
parent
45c5434a14
commit
59aadfd08e
@ -37,7 +37,7 @@
|
||||
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.GNU_ELF" id="cdt.managedbuild.target.gnu.platform.base.387108783" name="Debug Platform" osList="linux,hpux,aix,qnx" superClass="cdt.managedbuild.target.gnu.platform.base"/>
|
||||
|
||||
<builder arguments="" command="make" id="cdt.managedbuild.target.gnu.builder.base.1775951058" incrementalBuildTarget="install" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/>
|
||||
<builder arguments="efiusb" command="make" id="cdt.managedbuild.target.gnu.builder.base.1775951058" incrementalBuildTarget="install" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/>
|
||||
|
||||
<tool id="cdt.managedbuild.tool.gnu.archiver.base.821420179" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
|
||||
|
||||
|
@ -44,6 +44,7 @@ all:
|
||||
@${CC} ${CFLAGS} exports.c -c -o exports.o
|
||||
@${CC} ${CFLAGS} maps.c -c -o maps.o
|
||||
@${CC} ${CFLAGS} list.c -c -o list.o
|
||||
@${CC} ${CFLAGS} displaydebug.c -c -o displaydebug.o
|
||||
|
||||
@echo "part1"
|
||||
ifneq ($(SERIALPORT), 0)
|
||||
@ -57,9 +58,9 @@ ifneq ($(SERIALPORT), 0)
|
||||
endif
|
||||
|
||||
ifeq ($(SERIALPORT),0)
|
||||
@${LD} ${LDFLAGS} vmma.o main.o neward.o common.o commona.o apica.o vmmhelper.o multicore.o mm.o vmpaging.o vmevent_invalidstate.o vmeventhandler.o realmodeemu.o pmodeemu.o vmcall.o keyboard.o osspecific.o offloados.o ultimap.o pci.o apic.o test.o testa.o vmeventhandler_amd.o vmxemu.o vmxsetup.o epthandler.o exports.o vbe3.o vbe3a.o psod32.o maps.o list.o ./distorm64/wstring.o ./distorm64/x86defs.o ./distorm64/textdefs.o ./distorm64/insts.o ./distorm64/prefix.o ./distorm64/instructions.o ./distorm64/decoder.o ./distorm64/operands.o ./distorm64/distorm.o -o ../vmm.elf -Map ../vmm.map
|
||||
@${LD} ${LDFLAGS} vmma.o main.o neward.o common.o commona.o apica.o vmmhelper.o multicore.o mm.o vmpaging.o vmevent_invalidstate.o vmeventhandler.o realmodeemu.o pmodeemu.o vmcall.o keyboard.o osspecific.o offloados.o ultimap.o pci.o apic.o test.o testa.o vmeventhandler_amd.o vmxemu.o vmxsetup.o epthandler.o exports.o vbe3.o vbe3a.o psod32.o maps.o list.o displaydebug.o ./distorm64/wstring.o ./distorm64/x86defs.o ./distorm64/textdefs.o ./distorm64/insts.o ./distorm64/prefix.o ./distorm64/instructions.o ./distorm64/decoder.o ./distorm64/operands.o ./distorm64/distorm.o -o ../vmm.elf -Map ../vmm.map
|
||||
else
|
||||
@${LD} ${LDFLAGS} vmma.o main.o neward.o common.o commona.o apica.o vmmhelper.o multicore.o mm.o vmpaging.o vmevent_invalidstate.o vmeventhandler.o realmodeemu.o pmodeemu.o vmcall.o keyboard.o osspecific.o offloados.o ultimap.o pci.o apic.o test.o testa.o vmeventhandler_amd.o vmxemu.o vmxsetup.o epthandler.o exports.o luahandler.o vbe3.o vbe3a.o psod32.o maps.o list.o ./distorm64/wstring.o ./distorm64/x86defs.o ./distorm64/textdefs.o ./distorm64/insts.o ./distorm64/prefix.o ./distorm64/instructions.o ./distorm64/decoder.o ./distorm64/operands.o ./distorm64/distorm.o ./lua/lapi.o ./lua/lobject.o ./lua/ldo.o ./lua/lgc.o ./lua/lstate.o ./lua/ldebug.o ./lua/ltm.o ./lua/lvm.o ./lua/ltable.o ./lua/lstring.o ./lua/lfunc.o ./lua/lzio.o ./lua/ldump.o ./lua/lmem.o ./lua/lundump.o ./lua/lparser.o ./lua/lopcodes.o ./lua/llex.o ./lua/lcode.o ./lua/lctype.o ./lua/lauxlib.o ./lua/lstrlib.o ./lua/linit.o ./lua/lbaselib.o -o ../vmm.elf -Map ../vmm.map
|
||||
@${LD} ${LDFLAGS} vmma.o main.o neward.o common.o commona.o apica.o vmmhelper.o multicore.o mm.o vmpaging.o vmevent_invalidstate.o vmeventhandler.o realmodeemu.o pmodeemu.o vmcall.o keyboard.o osspecific.o offloados.o ultimap.o pci.o apic.o test.o testa.o vmeventhandler_amd.o vmxemu.o vmxsetup.o epthandler.o exports.o luahandler.o vbe3.o vbe3a.o psod32.o maps.o list.o displaydebug.o ./distorm64/wstring.o ./distorm64/x86defs.o ./distorm64/textdefs.o ./distorm64/insts.o ./distorm64/prefix.o ./distorm64/instructions.o ./distorm64/decoder.o ./distorm64/operands.o ./distorm64/distorm.o ./lua/lapi.o ./lua/lobject.o ./lua/ldo.o ./lua/lgc.o ./lua/lstate.o ./lua/ldebug.o ./lua/ltm.o ./lua/lvm.o ./lua/ltable.o ./lua/lstring.o ./lua/lfunc.o ./lua/lzio.o ./lua/ldump.o ./lua/lmem.o ./lua/lundump.o ./lua/lparser.o ./lua/lopcodes.o ./lua/llex.o ./lua/lcode.o ./lua/lctype.o ./lua/lauxlib.o ./lua/lstrlib.o ./lua/linit.o ./lua/lbaselib.o -o ../vmm.elf -Map ../vmm.map
|
||||
endif
|
||||
@objcopy -O binary ../vmm.elf ../vmm.bin
|
||||
@echo "vmm done"
|
||||
|
@ -8,6 +8,7 @@ multiple sources. (e.g vmm and vmloader)
|
||||
#include "keyboard.h"
|
||||
#include "main.h"
|
||||
#include "mm.h"
|
||||
#include "displaydebug.h"
|
||||
|
||||
//#include <ieee754.h>
|
||||
|
||||
@ -18,9 +19,14 @@ QWORD textmemory=0x0b8000;
|
||||
criticalSection sendstringfCS;
|
||||
criticalSection sendstringCS;
|
||||
|
||||
|
||||
|
||||
#if DISPLAYDEBUG==1
|
||||
int linessincelastkey=0;
|
||||
PStackList displaydebuglog_back, displaydebuglog_forward;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
int screenheight=25;
|
||||
@ -123,12 +129,14 @@ size_t strspn(const char *str, const char *chars)
|
||||
void exit(int status)
|
||||
{
|
||||
sendstringf("Exited DBVM with status %d\n", status);
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
void abort(void)
|
||||
{
|
||||
sendstringf("Exited DBVM\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -878,10 +886,11 @@ int vbuildstring(char *str, int size, char *string, __builtin_va_list arglist)
|
||||
|
||||
void sendstring(char *s UNUSED)
|
||||
{
|
||||
#if DISPLAYDEBUG==1
|
||||
displayline(s);
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
#if DISPLAYDEBUG==1
|
||||
displayline(s);
|
||||
#else
|
||||
|
||||
int i;
|
||||
|
||||
if (nosendchar[getAPICID()])
|
||||
@ -894,6 +903,7 @@ void sendstring(char *s UNUSED)
|
||||
sendchar(s[i]);
|
||||
|
||||
csLeave(&sendstringCS);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -914,9 +924,9 @@ void sendstringf(char *string UNUSED, ...)
|
||||
sl=vbuildstring(temps,200,string,arglist);
|
||||
__builtin_va_end(arglist);
|
||||
|
||||
#if DISPLAYDEBUG==1
|
||||
#if DISPLAYDEBUG==1
|
||||
displayline(temps); //instead of sending the output to the serial port, output to the display
|
||||
#else
|
||||
#else
|
||||
csEnter(&sendstringfCS);
|
||||
csEnter(&sendstringCS);
|
||||
|
||||
@ -928,7 +938,7 @@ void sendstringf(char *string UNUSED, ...)
|
||||
|
||||
csLeave(&sendstringCS);
|
||||
csLeave(&sendstringfCS);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1075,6 +1085,7 @@ void csLeave(PcriticalSection CS)
|
||||
else
|
||||
{
|
||||
sendstringf("csLeave called for a non-locked or non-owned critical section\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
@ -1752,7 +1763,9 @@ void nextline(void)
|
||||
}
|
||||
else
|
||||
currentdisplayline++;
|
||||
#if DISPLAYDEBUG==1
|
||||
//#if DISPLAYDEBUG==1
|
||||
#if 0 //disabling this while testing uefi graphics boot (nokb)
|
||||
{
|
||||
linessincelastkey++;
|
||||
if (linessincelastkey>=screenheight-1)
|
||||
{
|
||||
@ -1801,6 +1814,7 @@ void nextline(void)
|
||||
currentdisplayrow=0;
|
||||
linessincelastkey=0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
#define CHECKAPICID
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define ULTIMAPDEBUG //for debugging ultimap (I seem to have misplaced my serial port...)
|
||||
|
||||
#define EXIT_FAILURE 0xffffffff
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "maps.h"
|
||||
#include "list.h"
|
||||
#include "vmeventhandler.h"
|
||||
#include "displaydebug.h"
|
||||
|
||||
QWORD EPTMapPhysicalMemory(pcpuinfo currentcpuinfo, QWORD physicalAddress, int forcesmallpage);
|
||||
|
||||
@ -660,6 +661,10 @@ int ept_cloak_removechangeregonbp(QWORD physicalAddress)
|
||||
unsigned char *executable=(unsigned char *)ChangeRegBPList[i].cloakdata->Executable;
|
||||
executable[physicalAddress & 0xfff]=ChangeRegBPList[i].originalbyte;
|
||||
ChangeRegBPList[i].Active=0;
|
||||
|
||||
/* _wbinvd();
|
||||
vpid_invalidate();
|
||||
ept_invalidate();*/
|
||||
result=0;
|
||||
}
|
||||
}
|
||||
@ -670,7 +675,7 @@ int ept_cloak_removechangeregonbp(QWORD physicalAddress)
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOL ept_handleSoftwareBreakpoint(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
BOOL ept_handleSoftwareBreakpoint(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *fxsave)
|
||||
{
|
||||
//check if it is a cloaked instruction
|
||||
int i;
|
||||
@ -718,6 +723,42 @@ BOOL ept_handleSoftwareBreakpoint(pcpuinfo currentcpuinfo, VMRegisters *vmregist
|
||||
if (ChangeRegBPList[i].changereginfo.Flags.changeR14) vmregisters->r14=ChangeRegBPList[i].changereginfo.newR14;
|
||||
if (ChangeRegBPList[i].changereginfo.Flags.changeR15) vmregisters->r15=ChangeRegBPList[i].changereginfo.newR15;
|
||||
|
||||
if (ChangeRegBPList[i].changereginfo.changeFP)
|
||||
{
|
||||
int r;
|
||||
for (r=0; r<8; r++)
|
||||
if (ChangeRegBPList[i].changereginfo.changeFP & (1<<r))
|
||||
{
|
||||
copymem((void*)((QWORD)(&fxsave->FP_MM0)+10*r), (void*)((QWORD)(&fxsave->FP_MM0)+10*r),10);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (ChangeRegBPList[i].changereginfo.changeXMM)
|
||||
{
|
||||
int r;
|
||||
for (r=0; r<15; r++)
|
||||
{
|
||||
BYTE mask=(ChangeRegBPList[i].changereginfo.changeXMM >> (4*r)) & 0xf;
|
||||
if (mask)
|
||||
{
|
||||
DWORD *destparts=(DWORD *)((QWORD)(&fxsave->XMM0)+16*r);
|
||||
DWORD *sourceparts=(DWORD *)((QWORD)(&ChangeRegBPList[i].changereginfo.newXMM0)+16*r);
|
||||
int p;
|
||||
|
||||
for (p=0; p<4; p++)
|
||||
{
|
||||
if (mask & (1 << p))
|
||||
destparts[p]=sourceparts[p];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
RFLAGS flags;
|
||||
flags.value=vmread(vm_guest_rflags);
|
||||
if (ChangeRegBPList[i].changereginfo.Flags.changeCF) flags.CF=ChangeRegBPList[i].changereginfo.Flags.newCF;
|
||||
@ -2143,6 +2184,7 @@ QWORD EPTMapPhysicalMemory(pcpuinfo currentcpuinfo, QWORD physicalAddress, int f
|
||||
if (!fullmap)
|
||||
{
|
||||
sendstring("Assertion Fail: fullmap is false for a 1 page range");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ int ept_cloak_readOriginal(pcpuinfo currentcpuinfo, VMRegisters *registers, QWOR
|
||||
int ept_cloak_writeOriginal(pcpuinfo currentcpuinfo, VMRegisters *registers, QWORD physicalAddress, QWORD source);
|
||||
int ept_cloak_changeregonbp(QWORD physicalAddress, PCHANGEREGONBPINFO changereginfo);
|
||||
int ept_cloak_removechangeregonbp(QWORD physicalAddress);
|
||||
BOOL ept_handleSoftwareBreakpoint(pcpuinfo currentcpuinfo, VMRegisters *vmregisters);
|
||||
BOOL ept_handleSoftwareBreakpoint(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *fxsave);
|
||||
|
||||
void ept_reset();
|
||||
void ept_invalidate();
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "list.h"
|
||||
|
||||
#include "displaydebug.h"
|
||||
|
||||
|
||||
int addresslist_findclosestIndex(PAddressList l, QWORD address) //internal function for add
|
||||
@ -61,6 +61,7 @@ void addresslist_add(PAddressList l, QWORD address, void *data)
|
||||
if (l->list[s].address == address)
|
||||
{
|
||||
//error, already in the list
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "mm.h"
|
||||
#include "neward.h"
|
||||
#include "apic.h"
|
||||
#include "displaydebug.h"
|
||||
|
||||
#include "multicore.h"
|
||||
#include "inthandlers.h"
|
||||
@ -32,6 +33,7 @@
|
||||
|
||||
#include "luahandler.h"
|
||||
|
||||
|
||||
//#include "psod.h" //for pink screen of death support
|
||||
|
||||
/*
|
||||
@ -122,9 +124,12 @@ int cinthandler(unsigned long long *stack, int intnr) //todo: move to it's own s
|
||||
sendstringfCS.ignorelock=1;
|
||||
#endif
|
||||
|
||||
ddDrawRectangle(DDHorizontalResolution-100,0,100,100,_rdtsc());
|
||||
|
||||
if (readMSRSafe(IA32_FS_BASE_MSR)==0)
|
||||
{
|
||||
sendstringf("Invalid FS base during exception\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1) ;
|
||||
}
|
||||
|
||||
@ -248,6 +253,7 @@ int cinthandler(unsigned long long *stack, int intnr) //todo: move to it's own s
|
||||
cpuinfo->NMIOccured=2;
|
||||
}
|
||||
*/
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -263,6 +269,7 @@ int cinthandler(unsigned long long *stack, int intnr) //todo: move to it's own s
|
||||
longjmp(cpuinfo->OnException, 0x100 | intnr);
|
||||
|
||||
sendstringf("longjmp just went through...\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -299,6 +306,8 @@ int cinthandler(unsigned long long *stack, int intnr) //todo: move to it's own s
|
||||
}
|
||||
sendstring("not expected\n\r");
|
||||
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
|
||||
|
||||
|
||||
sendstring("Status:\n\r");
|
||||
@ -483,6 +492,7 @@ void setints(void)
|
||||
if (intvector==NULL)
|
||||
{
|
||||
sendstring("setints was called too early");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while(1);
|
||||
}
|
||||
|
||||
@ -768,6 +778,8 @@ void vmm_entry2_hlt(pcpuinfo currentcpuinfo)
|
||||
|
||||
while (1)
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
|
||||
if (currentcpuinfo)
|
||||
currentcpuinfo->active=0;
|
||||
a=1;
|
||||
@ -1085,6 +1097,7 @@ void vmm_entry(void)
|
||||
if (original->cpucount>1000)
|
||||
{
|
||||
sendstringf("More than 1000 cpu\'s are currently not supported\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -1094,7 +1107,61 @@ void vmm_entry(void)
|
||||
foundcpus=original->cpucount;
|
||||
APStartsInSIPI=0; //AP should start according to the original state
|
||||
}
|
||||
|
||||
if (original->FrameBufferBase)
|
||||
{
|
||||
DDFrameBufferBase=original->FrameBufferBase;
|
||||
DDFrameBufferSize=original->FrameBufferSize;
|
||||
DDHorizontalResolution=original->HorizontalResolution;
|
||||
DDVerticalResolution=original->VerticalResolution;
|
||||
DDPixelsPerScanLine=original->PixelsPerScanLine;
|
||||
|
||||
if (DDFrameBufferBase)
|
||||
{
|
||||
char c=0;
|
||||
/* sendstring("Before mapping of the framebuffer\n");
|
||||
while (c==0)
|
||||
{
|
||||
c=waitforchar();
|
||||
}
|
||||
sendstring("Mapping framebuffer\n");*/
|
||||
|
||||
//DDFrameBuffer=mapPhysicalMemoryGlobal(0x90000000, 8294400);
|
||||
//DDFrameBuffer=(unsigned char *)mapPhysicalMemory(0x90000000, 8294400);
|
||||
|
||||
|
||||
DDFrameBuffer=(unsigned char *)mapPhysicalMemoryGlobal(DDFrameBufferBase, DDFrameBufferSize);
|
||||
if (DDFrameBuffer==NULL)
|
||||
{
|
||||
sendstring("Failure mapping memory");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
|
||||
/* SetPageToWriteThrough(DDFrameBuffer);*/
|
||||
ddDrawRectangle(0,0,DDHorizontalResolution, DDVerticalResolution,0x00ff00);
|
||||
/* ddDrawRectangle(0,0,100,100,0xff00ff);
|
||||
ddDrawRectangle(DDHorizontalResolution-100,0,100,100,0xff0000);
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0x0000ff);
|
||||
ddDrawRectangle(DDHorizontalResolution-100,DDVerticalResolution-100,100,100,0xffffff);*/
|
||||
|
||||
/*
|
||||
unsigned int pi;
|
||||
for (pi=0; pi<DDFrameBufferSize; pi++)
|
||||
{
|
||||
DDFrameBuffer[pi]=0x30; //*(unsigned char *)((QWORD)0x00400000+(QWORD)pi);
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//while (1) ;
|
||||
unmapPhysicalMemory(original, sizeof(OriginalState));
|
||||
|
||||
}
|
||||
|
||||
if (needtospawnApplicationProcessors) //e.g UEFI boot with missing mpsupport
|
||||
@ -1168,6 +1235,7 @@ void vmm_entry(void)
|
||||
if (GDT_BASE==NULL)
|
||||
{
|
||||
sendstring("Memory allocation failed\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1) ;
|
||||
}
|
||||
|
||||
@ -2743,6 +2811,7 @@ void startvmx(pcpuinfo currentcpuinfo)
|
||||
if (currentcpuinfo->vmxon_region==NULL)
|
||||
{
|
||||
sendstringf(">>>>>>>>>>>>>>>>>>>>vmxon allocation has failed<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -2756,6 +2825,7 @@ void startvmx(pcpuinfo currentcpuinfo)
|
||||
|
||||
if (currentcpuinfo->vmcs_region==NULL)
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
sendstringf(">>>>>>>>>>>>>>>>>>>>vmcs_region allocation has failed<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
|
||||
while (1);
|
||||
}
|
||||
@ -2819,6 +2889,8 @@ void startvmx(pcpuinfo currentcpuinfo)
|
||||
|
||||
launchVMX(currentcpuinfo);
|
||||
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
|
||||
displayline("Exit from launchVMX, if you see this, something horrible has happened\n");
|
||||
sendstring("Exit from launchVMX\n\r");
|
||||
|
||||
@ -2885,6 +2957,8 @@ void startvmx(pcpuinfo currentcpuinfo)
|
||||
sendstringf("End of startvmx (entryrsp=%6, returnrsp=%6)\n\r",entryrsp,getRSP());
|
||||
#endif
|
||||
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0x00ffff);
|
||||
|
||||
if (currentcpuinfo->cpunr==0)
|
||||
displayline("bye...\n");
|
||||
}
|
||||
|
@ -18,11 +18,11 @@ $(shell mkdir -p $(DEPDIR) >/dev/null)
|
||||
#CFILES=main.o neward.o common.o vmmhelper.o multicore.o mm.o vmpaging.o vmevent_invalidstate.o vmeventhandler.o realmodeemu.o pmodeemu.o vmcall.o keyboard.o osspecific.o offloados.o ultimap.o pci.o apic.o test.o vmeventhandler_amd.o vmxemu.o vmxsetup.o epthandler.o exports.o vbe3.o
|
||||
|
||||
ifeq ($(SERIALPORT),0)
|
||||
FILES=vmma.o main.o neward.o common.o commona.o apica.o vmmhelper.o multicore.o mm.o vmpaging.o vmevent_invalidstate.o vmeventhandler.o realmodeemu.o pmodeemu.o vmcall.o keyboard.o osspecific.o offloados.o ultimap.o pci.o apic.o test.o testa.o vmeventhandler_amd.o vmxemu.o vmxsetup.o epthandler.o exports.o vbe3.o vbe3a.o psod32.o maps.o list.o
|
||||
FILES=vmma.o main.o neward.o common.o commona.o apica.o vmmhelper.o multicore.o mm.o vmpaging.o vmevent_invalidstate.o vmeventhandler.o realmodeemu.o pmodeemu.o vmcall.o keyboard.o osspecific.o offloados.o ultimap.o pci.o apic.o test.o testa.o vmeventhandler_amd.o vmxemu.o vmxsetup.o epthandler.o exports.o vbe3.o vbe3a.o psod32.o maps.o list.o displaydebug.o
|
||||
|
||||
LUAFILES=
|
||||
else
|
||||
FILES=vmma.o main.o neward.o common.o commona.o apica.o vmmhelper.o multicore.o mm.o vmpaging.o vmevent_invalidstate.o vmeventhandler.o realmodeemu.o pmodeemu.o vmcall.o keyboard.o osspecific.o offloados.o ultimap.o pci.o apic.o test.o testa.o vmeventhandler_amd.o vmxemu.o vmxsetup.o epthandler.o exports.o luahandler.o vbe3.o vbe3a.o psod32.o maps.o list.o
|
||||
FILES=vmma.o main.o neward.o common.o commona.o apica.o vmmhelper.o multicore.o mm.o vmpaging.o vmevent_invalidstate.o vmeventhandler.o realmodeemu.o pmodeemu.o vmcall.o keyboard.o osspecific.o offloados.o ultimap.o pci.o apic.o test.o testa.o vmeventhandler_amd.o vmxemu.o vmxsetup.o epthandler.o exports.o luahandler.o vbe3.o vbe3a.o psod32.o maps.o list.o displaydebug.o
|
||||
|
||||
LUAFILES=./lua/lapi.o ./lua/lobject.o ./lua/ldo.o ./lua/lgc.o ./lua/lstate.o ./lua/ldebug.o ./lua/ltm.o ./lua/lvm.o ./lua/ltable.o ./lua/lstring.o ./lua/lfunc.o ./lua/lzio.o ./lua/ldump.o ./lua/lmem.o ./lua/lundump.o ./lua/lparser.o ./lua/lopcodes.o ./lua/llex.o ./lua/lcode.o ./lua/lctype.o ./lua/lauxlib.o ./lua/lstrlib.o ./lua/linit.o ./lua/lbaselib.o
|
||||
endif
|
||||
|
@ -10,6 +10,7 @@ Just used for basic initialization allocation, frees shouldn't happen too often
|
||||
#include "multicore.h"
|
||||
#include "common.h"
|
||||
#include "vmmhelper.h"
|
||||
#include "displaydebug.h"
|
||||
|
||||
//#define sendstringf(s,x...)
|
||||
//#define sendstring(s)
|
||||
@ -359,7 +360,7 @@ int mmFindMapPositionForSize(pcpuinfo cpuinfo, int size)
|
||||
j++;
|
||||
|
||||
if (j>=1024)
|
||||
break; //not enough space left
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (needed==0)
|
||||
@ -585,6 +586,7 @@ void unmapPhysicalMemoryGlobal(void *virtualaddress, int size)
|
||||
else
|
||||
{
|
||||
sendstringf("invalid global address (%6) given to unmapPhysicalMemoryGlobal\n",virtualaddress);
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -608,6 +610,7 @@ void unmapPhysicalMemory(void *virtualaddress, int size)
|
||||
if ((pos<0) || (pos>1024))
|
||||
{
|
||||
sendstringf("%d: invalid address given to unmapPhysicalMemory (%6)\n",c->cpunr, virtualaddress);
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -743,6 +746,7 @@ void *addPhysicalPageToDBVM(QWORD address)
|
||||
if (pagetableentry->P)
|
||||
{
|
||||
sendstringf("Assertion failure. Virtual address %6 was already present\n", VirtualAddress);
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -974,6 +978,8 @@ void *malloc2(unsigned int size)
|
||||
}
|
||||
|
||||
sendstring("OUT OF MEMORY\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
|
||||
while (1)
|
||||
jtagbp();
|
||||
|
||||
@ -1117,6 +1123,7 @@ void *realloc(void *old, size_t size)
|
||||
else
|
||||
{
|
||||
sendstringf("realloc error\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1) ;
|
||||
}
|
||||
}
|
||||
@ -1227,6 +1234,7 @@ void InitializeMM(UINT64 FirstFreeVirtualAddress)
|
||||
if (pagedirlvl4[pml4index].P) //pml4index should be 511
|
||||
{
|
||||
sendstring("Assertion failed. pagedirlvl4[pml4index].P is not 0. It should be\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
*(QWORD*)(&pagedirlvl4[pml4index])=getCR3();
|
||||
|
@ -68,7 +68,12 @@ typedef struct
|
||||
UINT64 fsbase;
|
||||
UINT64 gsbase;
|
||||
UINT64 APEntryPage; //page below 1MB (for AP cpu bootcode)
|
||||
UINT64 Uncached; //physical address holding a map detailing which regions are uncached (for EPT) (sorted)
|
||||
UINT64 FrameBufferBase; //in case of uefi boot the framebuffer address for output
|
||||
UINT64 FrameBufferSize;
|
||||
UINT64 HorizontalResolution;
|
||||
UINT64 VerticalResolution;
|
||||
UINT64 PixelsPerScanLine;
|
||||
UINT64 PixelFormat;
|
||||
} __attribute__((__packed__)) OriginalState, *POriginalState;
|
||||
|
||||
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "psod32.h"
|
||||
#include "eptstructs.h"
|
||||
#include "epthandler.h"
|
||||
#include "displaydebug.h"
|
||||
|
||||
|
||||
//#pragma GCC push_options
|
||||
//#pragma GCC optimize ("O0")
|
||||
@ -1574,6 +1576,77 @@ int _handleVMCallInstruction(pcpuinfo currentcpuinfo, VMRegisters *vmregisters,
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
case VMCALL_CLOAKEX_ACTIVATE:
|
||||
{
|
||||
//same as cloak but lets you specify a small section of the page
|
||||
if (hasEPTsupport)
|
||||
vmregisters->rax=ept_cloakex_activate(((PVMCALL_CLOAKEX_ACTIVATE_PARAM)vmcall_instruction)->physicalAddress,
|
||||
((PVMCALL_CLOAKEX_ACTIVATE_PARAM)vmcall_instruction)->size);
|
||||
else
|
||||
vmregisters->rax=0xcedead;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case VMCALL_CLOAK_ADDTOWHITELIST:
|
||||
{
|
||||
//whitelists a CR3 and/or RIP (
|
||||
if (hasEPTsupport)
|
||||
vmregisters->rax=ept_cloak_addtowhitelist(((PVMCALL_CLOAKEX_ACTIVATE_PARAM)vmcall_instruction)->physicalAddress,
|
||||
((PVMCALL_CLOAK_WHITELIST)vmcall_instruction)->CR3,
|
||||
((PVMCALL_CLOAK_WHITELIST)vmcall_instruction)->RIP);
|
||||
else
|
||||
vmregisters->rax=0xcedead;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case VMCALL_CLOAK_REMOVEFROMWHITELIST:
|
||||
{
|
||||
if (hasEPTsupport)
|
||||
vmregisters->rax=ept_cloak_removefromwhitelist(((PVMCALL_CLOAKEX_ACTIVATE_PARAM)vmcall_instruction)->physicalAddress,
|
||||
((PVMCALL_CLOAK_WHITELIST)vmcall_instruction)->CR3,
|
||||
((PVMCALL_CLOAK_WHITELIST)vmcall_instruction)->RIP);
|
||||
else
|
||||
vmregisters->rax=0xcedead;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case VMCALL_CLOAK_STARTACCESSWATCH:
|
||||
{
|
||||
if (hasEPTsupport)
|
||||
vmregisters->rax=ept_cloak_startaccesswatch(((PVMCALL_CLOAKEX_ACTIVATE_PARAM)vmcall_instruction)->physicalAddress,
|
||||
((PVMCALL_CLOAKEX_ACTIVATE_PARAM)vmcall_instruction)->maxcount);
|
||||
else
|
||||
vmregisters->rax=0xcedead;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case VMCALL_CLOAK_FETCHACCESSWATCHRESULTS:
|
||||
{
|
||||
//returns a list of CR3 and RIP's and if they read or write, or both
|
||||
if (hasEPTsupport)
|
||||
vmregisters->rax=ept_cloak_fetchaccesswatchresults(((PVMCALL_CLOAKEX_ACTIVATE_PARAM)vmcall_instruction)->physicalAddress);
|
||||
else
|
||||
vmregisters->rax=0xcedead;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case VMCALL_CLOAK_STOPACCESSWATCH:
|
||||
{
|
||||
if (hasEPTsupport)
|
||||
vmregisters->rax=ept_cloak_stopaccesswatch(((PVMCALL_CLOAKEX_ACTIVATE_PARAM)vmcall_instruction)->physicalAddress);
|
||||
else
|
||||
vmregisters->rax=0xcedead;
|
||||
|
||||
break;
|
||||
}*/
|
||||
|
||||
|
||||
case VMCALL_CLOAK_DEACTIVATE:
|
||||
{
|
||||
if (hasEPTsupport)
|
||||
@ -1949,6 +2022,7 @@ int _handleVMCall(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
int r=handleRealModeInt0x15(currentcpuinfo, vmregisters, vmread(vm_exit_instructionlength));
|
||||
|
||||
sendstringf("handleRealModeInt0x15 returned %d (should be 0)\n",r);
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
if (r)
|
||||
{
|
||||
while (1);
|
||||
@ -2083,6 +2157,7 @@ int handleVMCall(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
except
|
||||
{
|
||||
sendstringf("no jtag available\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
tryend
|
||||
|
@ -127,6 +127,8 @@ typedef struct
|
||||
unsigned reserved : 3;
|
||||
} Flags;
|
||||
|
||||
QWORD changeXMM; //16 nibbles, each bit is one dword
|
||||
QWORD changeFP;
|
||||
QWORD newRAX;
|
||||
QWORD newRBX;
|
||||
QWORD newRCX;
|
||||
@ -144,6 +146,56 @@ typedef struct
|
||||
QWORD newR13;
|
||||
QWORD newR14;
|
||||
QWORD newR15;
|
||||
|
||||
QWORD newFP0;
|
||||
QWORD newFP0_H;
|
||||
QWORD newFP1;
|
||||
QWORD newFP1_H;
|
||||
QWORD newFP2;
|
||||
QWORD newFP2_H;
|
||||
QWORD newFP3;
|
||||
QWORD newFP3_H;
|
||||
QWORD newFP4;
|
||||
QWORD newFP4_H;
|
||||
QWORD newFP5;
|
||||
QWORD newFP5_H;
|
||||
QWORD newFP6;
|
||||
QWORD newFP6_H;
|
||||
QWORD newFP7;
|
||||
QWORD newFP7_H;
|
||||
QWORD newXMM0;
|
||||
QWORD newXMM0_H;
|
||||
QWORD newXMM1;
|
||||
QWORD newXMM1_H;
|
||||
QWORD newXMM2;
|
||||
QWORD newXMM2_H;
|
||||
QWORD newXMM3;
|
||||
QWORD newXMM3_H;
|
||||
QWORD newXMM4;
|
||||
QWORD newXMM4_H;
|
||||
QWORD newXMM5;
|
||||
QWORD newXMM5_H;
|
||||
QWORD newXMM6;
|
||||
QWORD newXMM6_H;
|
||||
QWORD newXMM7;
|
||||
QWORD newXMM7_H;
|
||||
QWORD newXMM8;
|
||||
QWORD newXMM8_H;
|
||||
QWORD newXMM9;
|
||||
QWORD newXMM9_H;
|
||||
QWORD newXMM10;
|
||||
QWORD newXMM10_H;
|
||||
QWORD newXMM11;
|
||||
QWORD newXMM11_H;
|
||||
QWORD newXMM12;
|
||||
QWORD newXMM12_H;
|
||||
QWORD newXMM13;
|
||||
QWORD newXMM13_H;
|
||||
QWORD newXMM14;
|
||||
QWORD newXMM14_H;
|
||||
QWORD newXMM15;
|
||||
QWORD newXMM15_H;
|
||||
|
||||
} __attribute__((__packed__)) CHANGEREGONBPINFO, *PCHANGEREGONBPINFO;
|
||||
|
||||
typedef struct
|
||||
|
@ -21,6 +21,7 @@ vmeventhandler.c: This will handle the events
|
||||
#include "vmxemu.h"
|
||||
#include "epthandler.h"
|
||||
#include "vmxsetup.h"
|
||||
#include "displaydebug.h"
|
||||
|
||||
|
||||
#ifndef DEBUG
|
||||
@ -717,6 +718,8 @@ int handle_cr3_callback(pcpuinfo currentcpuinfo,VMRegisters *vmregisters)
|
||||
nosendchar[getAPICID()]=0;
|
||||
sendstringf("Handling cr3 edit. Is %x wants to set it to %x:\n\r", vmread(0x6802), currentcpuinfo->guestCR3);
|
||||
sendstring("Also, currently not implemented so no idea how this happened\n\r");
|
||||
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
|
||||
|
||||
@ -2246,6 +2249,7 @@ int setVM_CR0(pcpuinfo currentcpuinfo, UINT64 newcr0)
|
||||
{
|
||||
nosendchar[getAPICID()]=0;
|
||||
sendstringf("IF is not 0 when switching to protected mode\n\r");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -3426,7 +3430,13 @@ int handleInterruptProtectedMode(pcpuinfo currentcpuinfo, VMRegisters *vmregiste
|
||||
sendvmstate(currentcpuinfo, vmregisters);
|
||||
displayPreviousStates();
|
||||
ShowCurrentInstructions(currentcpuinfo);
|
||||
while (1) ;
|
||||
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,_rdtsc() & 0xffffff);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3564,13 +3574,13 @@ int handleInterruptProtectedMode(pcpuinfo currentcpuinfo, VMRegisters *vmregiste
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL handleSoftwareBreakpoint(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
BOOL handleSoftwareBreakpoint(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *fxsave)
|
||||
{
|
||||
//handle software breakpoints
|
||||
sendstringf("Software breakpoint\n");
|
||||
if (hasEPTsupport)
|
||||
{
|
||||
if (ept_handleSoftwareBreakpoint(currentcpuinfo, vmregisters))
|
||||
if (ept_handleSoftwareBreakpoint(currentcpuinfo, vmregisters, fxsave))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -3580,7 +3590,7 @@ BOOL handleSoftwareBreakpoint(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
return FALSE; //unhandled
|
||||
}
|
||||
|
||||
VMSTATUS handleInterrupt(pcpuinfo currentcpuinfo, VMRegisters *vmregisters) //nightmare function. Needs rewrite
|
||||
VMSTATUS handleInterrupt(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *fxsave) //nightmare function. Needs rewrite
|
||||
{
|
||||
// int origsc;
|
||||
|
||||
@ -3597,7 +3607,7 @@ VMSTATUS handleInterrupt(pcpuinfo currentcpuinfo, VMRegisters *vmregisters) //ni
|
||||
|
||||
if ((intinfo.interruptvector==3) && (intinfo.type==itSoftwareException))
|
||||
{
|
||||
if (handleSoftwareBreakpoint(currentcpuinfo, vmregisters))
|
||||
if (handleSoftwareBreakpoint(currentcpuinfo, vmregisters, fxsave))
|
||||
return VM_OK;
|
||||
}
|
||||
|
||||
@ -3688,6 +3698,7 @@ int handleSingleStep(pcpuinfo currentcpuinfo)
|
||||
|
||||
if (r)
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -3835,13 +3846,14 @@ int handleVMEvent(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *f
|
||||
ept_invalidate(); //test
|
||||
*/
|
||||
|
||||
|
||||
switch (exit_reason) //exit reason
|
||||
{
|
||||
case 0: //interrupt
|
||||
{
|
||||
int result;
|
||||
|
||||
result=handleInterrupt(currentcpuinfo, vmregisters);
|
||||
result=handleInterrupt(currentcpuinfo, vmregisters, fxsave);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -3880,6 +3892,7 @@ int handleVMEvent(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *f
|
||||
|
||||
case 2: //tripple fault
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
sendstring("A TRIPPLE FAULT HAPPENED. NORMALLY THE SYSTEM WOULD REBOOT NOW\n\r");
|
||||
return 1;
|
||||
}
|
||||
@ -3927,6 +3940,7 @@ int handleVMEvent(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *f
|
||||
sendstringf("vm_execution_controls_cpu=%6\n", vmread(vm_execution_controls_cpu));
|
||||
|
||||
#ifndef DEBUG
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
#endif
|
||||
}
|
||||
@ -3946,7 +3960,11 @@ int handleVMEvent(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *f
|
||||
}
|
||||
|
||||
case 9:
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
return handleTaskswitch(currentcpuinfo, vmregisters);
|
||||
}
|
||||
|
||||
case 10: //CPUID
|
||||
{
|
||||
@ -3958,6 +3976,9 @@ int handleVMEvent(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *f
|
||||
case 11:
|
||||
{
|
||||
//currently not supported
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
|
||||
sendstring("GETSEC\n\r");
|
||||
raiseInvalidOpcodeException(currentcpuinfo);
|
||||
return 0;
|
||||
@ -4039,6 +4060,9 @@ int handleVMEvent(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *f
|
||||
case 0xce00: //special exit reasons (vmresume/vmlaunch failures)
|
||||
case 0xce01:
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
|
||||
sendstring("VMX instruction called...\n\r");
|
||||
return handleIntelVMXInstruction(currentcpuinfo, vmregisters);
|
||||
//return raiseInvalidOpcodeException(currentcpuinfo);
|
||||
@ -4088,6 +4112,7 @@ int handleVMEvent(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *f
|
||||
|
||||
case 33: //inv. guest
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
sendstringf("VM-Entry failure due to invalid guest\n\r");
|
||||
result=handleInvalidEntryState(currentcpuinfo, vmregisters);
|
||||
|
||||
@ -4122,6 +4147,7 @@ int handleVMEvent(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *f
|
||||
|
||||
sendstring("(Un)expected monitor trap flag\n\r");
|
||||
#ifndef DEBUG
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1) ;
|
||||
#else
|
||||
return 0;
|
||||
@ -4233,11 +4259,15 @@ int handleVMEvent(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *f
|
||||
|
||||
case vm_exit_vmx_preemptiontimer_reachedzero:
|
||||
{
|
||||
IA32_VMX_MISC.IA32_VMX_MISC=readMSR(0x485);
|
||||
//IA32_VMX_MISC.IA32_VMX_MISC=readMSR(0x485);
|
||||
|
||||
|
||||
nosendchar[getAPICID()]=0;
|
||||
//sendstringf("%d: %x:%6 (vmm rsp=%6 , freemem=%x)\n", currentcpuinfo->cpunr, vmread(vm_guest_cs),vmread(vm_guest_rip), getRSP(), maxAllocatableMemory());
|
||||
vmwrite(vm_preemption_timer_value,IA32_VMX_MISC.vmx_premption_timer_tsc_relation*10000000);
|
||||
|
||||
vmwrite(vm_preemption_timer_value,10000);
|
||||
|
||||
ddDrawRectangle(0,0,100,100,_rdtsc());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4247,6 +4277,7 @@ int handleVMEvent(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *f
|
||||
return handleIntelVMXInstruction(currentcpuinfo, vmregisters);
|
||||
|
||||
#ifdef DEBUG
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
#endif
|
||||
// return 1;
|
||||
@ -4254,6 +4285,7 @@ int handleVMEvent(pcpuinfo currentcpuinfo, VMRegisters *vmregisters, FXSAVE64 *f
|
||||
|
||||
case vm_exit_invpcid:
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while(1);
|
||||
return 1;
|
||||
}
|
||||
|
@ -523,11 +523,6 @@ sub rsp,15*8
|
||||
mov [rsp+14*8],rax
|
||||
mov [rsp+11*8],rdx
|
||||
|
||||
rdtsc
|
||||
|
||||
mov dword [fs:0x18],eax ;lasttsc
|
||||
mov dword [fs:0x1c],edx
|
||||
|
||||
|
||||
mov [rsp],r15
|
||||
mov [rsp+1*8],r14
|
||||
@ -606,22 +601,6 @@ jae vmxloop_exitvm
|
||||
|
||||
;returned 0, so
|
||||
|
||||
;adjust the TSC
|
||||
rdtsc ;current time
|
||||
shl rdx,32
|
||||
or rax,rdx
|
||||
|
||||
mov rdx,qword [fs:0x18] ;entry time
|
||||
|
||||
;rax is new timestamp
|
||||
;rdx is old timestamp
|
||||
|
||||
sub rax,rdx ;rax is now the difference
|
||||
add rax,100
|
||||
add qword [fs:0x20],rax ;add to the total delay
|
||||
|
||||
|
||||
|
||||
;restore vmx registers (esp-36)
|
||||
pop r15
|
||||
pop r14
|
||||
@ -646,10 +625,6 @@ vmresume
|
||||
;restore state of vmm
|
||||
|
||||
|
||||
%ifdef JTAG
|
||||
db 0xf1 ;jtag breakpoint
|
||||
%endif
|
||||
|
||||
pop r15
|
||||
pop r14
|
||||
pop r13
|
||||
@ -689,9 +664,6 @@ pop rax
|
||||
|
||||
vmlaunch
|
||||
|
||||
%ifdef JTAG
|
||||
db 0xf1 ;jtag breakpoint
|
||||
%endif
|
||||
|
||||
;never executed unless on error
|
||||
;restore state of vmm
|
||||
@ -717,9 +689,7 @@ pop rbx
|
||||
pop rax
|
||||
|
||||
vmresume
|
||||
%ifdef JTAG
|
||||
db 0xf1 ;jtag breakpoint
|
||||
%endif
|
||||
|
||||
|
||||
;never executed unless on error
|
||||
mov dword [fs:0x10],0xce00 ;exitreason 0xce00
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "exports.h"
|
||||
#include "luahandler.h"
|
||||
|
||||
#include "displaydebug.h"
|
||||
|
||||
#ifndef DEBUG
|
||||
#define sendstringf(s,x...)
|
||||
#define sendstring(s)
|
||||
@ -760,6 +762,7 @@ int vmexit2(pcpuinfo currentcpuinfo, UINT64 *registers, void *fxsave)
|
||||
#else
|
||||
|
||||
|
||||
int showlife=0;
|
||||
|
||||
int vmexit(pcpuinfo currentcpuinfo, UINT64 *registers, void *fxsave)
|
||||
#endif
|
||||
@ -774,6 +777,14 @@ int vmexit(pcpuinfo currentcpuinfo, UINT64 *registers, void *fxsave)
|
||||
lastexitsindex++;
|
||||
lastexitsindex=lastexitsindex % 10;
|
||||
|
||||
// if ((showlife % 2)==0)
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-10,10,10,0x0000ff);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef CHECKAPICID
|
||||
if (currentcpuinfo)
|
||||
{
|
||||
@ -798,8 +809,11 @@ int vmexit(pcpuinfo currentcpuinfo, UINT64 *registers, void *fxsave)
|
||||
{
|
||||
BOOL r=dbvm_plugin_exit_pre(exportlist, currentcpuinfo, registers, fxsave);
|
||||
if (r)
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (currentcpuinfo==NULL)
|
||||
@ -807,6 +821,8 @@ int vmexit(pcpuinfo currentcpuinfo, UINT64 *registers, void *fxsave)
|
||||
nosendchar[getAPICID()]=0;
|
||||
sendstringf("currentcpuinfo==NULL");
|
||||
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -818,6 +834,8 @@ int vmexit(pcpuinfo currentcpuinfo, UINT64 *registers, void *fxsave)
|
||||
if (dbvm_plugin_exit_post)
|
||||
dbvm_plugin_exit_post(exportlist, currentcpuinfo, registers, fxsave, &r);
|
||||
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -888,6 +906,8 @@ int vmexit(pcpuinfo currentcpuinfo, UINT64 *registers, void *fxsave)
|
||||
|
||||
if (currentcpuinfo->NMIOccured==2) //nmi occured but no NMI window support
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0x0000ff);
|
||||
|
||||
currentcpuinfo->NMIOccured=0;
|
||||
return raiseNMI();
|
||||
}
|
||||
@ -895,8 +915,17 @@ int vmexit(pcpuinfo currentcpuinfo, UINT64 *registers, void *fxsave)
|
||||
//currentcpuinfo->lastTSCTouch=_rdtsc();
|
||||
|
||||
|
||||
//if ((showlife % 2)==0)
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-10,10,10,0x00ff00);
|
||||
}
|
||||
|
||||
showlife++;
|
||||
|
||||
|
||||
if ((result!=0) && ((result >> 8) != 0xce) )//on release, if an unexpected event happens, just fail the instruction and hope the OS won't make a too big mess out of it
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (wait) ; //remove for release
|
||||
|
||||
if ((vmread(vm_exit_reason) & 0x7fffffff)==vm_exit_invalid_guest_state) //invalid state
|
||||
@ -905,7 +934,15 @@ int vmexit(pcpuinfo currentcpuinfo, UINT64 *registers, void *fxsave)
|
||||
return raiseInvalidOpcodeException(currentcpuinfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
//nosendchar[getAPICID()]=0;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "vmeventhandler.h"
|
||||
#include "vmcall.h"
|
||||
#include "mm.h"
|
||||
#include "displaydebug.h"
|
||||
|
||||
|
||||
int emulatevmx=1;
|
||||
@ -100,12 +101,14 @@ int handleByGuest(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
if (currentcpuinfo->vmxdata.runningvmx==0)
|
||||
{
|
||||
sendstringf("handleByGuest was called while runningvmx is 0");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
else
|
||||
if (currentcpuinfo->vmxdata.insideVMXRootMode==0)
|
||||
{
|
||||
sendstringf("runningvmx but insideVMXRootMode is 0\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -114,6 +117,7 @@ int handleByGuest(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
if (ptrld)
|
||||
{
|
||||
sendstringf("failure loading the vmcs_regionPA\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while(1);
|
||||
}
|
||||
|
||||
@ -178,12 +182,14 @@ int handleByGuest(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
{
|
||||
nosendchar[getAPICID()]=0;
|
||||
sendstring("For some messed up reason the gdt is paged out...");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
if (error)
|
||||
{
|
||||
sendstring("OK, WTF is going on here!");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
|
||||
}
|
||||
@ -227,6 +233,7 @@ int handleByGuest(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
sendvmstate(currentcpuinfo, vmregisters);
|
||||
|
||||
sendstringf("vm_guest_cr3(%6) does not match currentcpuinfo->vmxdata.originalhoststate.CR3(%6)\n",vmread(vm_guest_cr3),currentcpuinfo->vmxdata.originalhoststate.CR3 );
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -458,6 +465,7 @@ int handle_vmclear(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
else
|
||||
{
|
||||
sendstring("Failure restoring guest vmx hoststate");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -534,6 +542,7 @@ int handle_vmlaunch(pcpuinfo currentcpuinfo, VMRegisters *vmregisters UNUSED)
|
||||
if (currentcpuinfo->vmxdata.runningvmx)
|
||||
{
|
||||
sendstring("Assertion failed. runningvmx was not 0\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -577,6 +586,7 @@ int handle_vmresume(pcpuinfo currentcpuinfo, VMRegisters *vmregisters UNUSED)
|
||||
if (currentcpuinfo->vmxdata.runningvmx)
|
||||
{
|
||||
sendstring("Assertion failed. runningvmx was not 0\n");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -1143,6 +1153,7 @@ int handle_vmptrld(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
if (r)
|
||||
{
|
||||
sendstringf("restore: vmptrld failed: %d (error=%d)\n", vmread(vm_errorcode));
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
@ -1204,6 +1215,7 @@ int handle_vmptrld(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
if (debugstate.CR3!=getCR3())
|
||||
{
|
||||
sendstringf("wrong cr3 was set in the hoststate");
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
@ -1365,6 +1377,7 @@ int handleIntelVMXInstruction(pcpuinfo currentcpuinfo, VMRegisters *vmregisters)
|
||||
int err=lastexception;
|
||||
|
||||
sendstringf("Something shitty happened when emulating VMX (%6: %d)\n", ExceptionRIP, err);
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
|
||||
while (1);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "epthandler.h"
|
||||
#include "neward.h"
|
||||
#include "displaydebug.h"
|
||||
|
||||
|
||||
criticalSection setupVMX_lock;
|
||||
@ -1165,8 +1166,7 @@ void setupVMX(pcpuinfo currentcpuinfo)
|
||||
|
||||
sendstringf("Set vm_execution_controls_pin to %8 (became %8)\n", (ULONG)IA32_VMX_PINBASED_CTLS, (DWORD)vmread(vm_execution_controls_pin));
|
||||
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
|
||||
|
||||
//check if the system supports preemption, and if so, enable it
|
||||
{
|
||||
@ -1174,14 +1174,11 @@ void setupVMX(pcpuinfo currentcpuinfo)
|
||||
if (usablepinbasedBits & ACTIVATE_VMX_PREEMPTION_TIMER)
|
||||
{
|
||||
displayline("Preemption is possible\n");
|
||||
vmwrite(vm_execution_controls_pin,(ULONG)IA32_VMX_PINBASED_CTLS | ACTIVATE_VMX_PREEMPTION_TIMER);
|
||||
vmwrite(vm_preemption_timer_value,IA32_VMX_MISC.vmx_premption_timer_tsc_relation*100000);
|
||||
vmwrite(vm_execution_controls_pin,vmread(vm_execution_controls_pin) | ACTIVATE_VMX_PREEMPTION_TIMER);
|
||||
vmwrite(vm_preemption_timer_value,10000);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
globalTSC=_rdtsc();
|
||||
@ -1842,6 +1839,7 @@ void setupVMX(pcpuinfo currentcpuinfo)
|
||||
{
|
||||
sendstringf("No low region:\n");
|
||||
sendARD();
|
||||
ddDrawRectangle(0,DDVerticalResolution-100,100,100,0xff0000);
|
||||
while (1);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user