[Vm-dev] [commit] r2330 - Merge
http://lists.squeakfoundation.org/pipermail/vm-dev/2010-April/004187.html
commits at squeakvm.org
commits at squeakvm.org
Wed Nov 3 17:10:36 UTC 2010
Author: eliot
Date: 2010-11-03 10:10:35 -0700 (Wed, 03 Nov 2010)
New Revision: 2330
Modified:
branches/Cog/platforms/Cross/plugins/BochsIA32Plugin/sqBochsIA32Plugin.cpp
branches/Cog/platforms/win32/plugins/FilePlugin/sqWin32FilePrims.c
branches/Cog/processors/IA32/bochs/cpu/cpu.cc
branches/Cog/unixbuild/HowToBuild
Log:
Merge http://lists.squeakfoundation.org/pipermail/vm-dev/2010-April/004187.html
fix (EOF testing on win32).
Add execution protection to Bochs IA32 simulator plugin.
Update unix build info for ubuntu.
Modified: branches/Cog/platforms/Cross/plugins/BochsIA32Plugin/sqBochsIA32Plugin.cpp
===================================================================
--- branches/Cog/platforms/Cross/plugins/BochsIA32Plugin/sqBochsIA32Plugin.cpp 2010-10-13 18:39:14 UTC (rev 2329)
+++ branches/Cog/platforms/Cross/plugins/BochsIA32Plugin/sqBochsIA32Plugin.cpp 2010-11-03 17:10:35 UTC (rev 2330)
@@ -92,8 +92,8 @@
int
singleStepCPUInSizeMinAddressReadWrite(void *cpu,
- void *memory, ulong byteSize,
- ulong minReadAddr, ulong minWriteAddr)
+ void *memory, ulong byteSize,
+ ulong minAddr, ulong minWriteMaxExecAddr)
{
BX_CPU_C *anx86 = (BX_CPU_C *)cpu;
@@ -101,33 +101,36 @@
return BadCPUInstance;
theMemory = (unsigned char *)memory;
theMemorySize = byteSize;
- minReadAddress = minReadAddr;
- minWriteAddress = minWriteAddr;
- if (anx86->gen_reg[BX_32BIT_REG_EIP].dword.erx >= theMemorySize)
- return MemoryBoundsError;
+ minReadAddress = minAddr;
+ minWriteAddress = minWriteMaxExecAddr;
+#if 0
+ if (anx86->gen_reg[BX_32BIT_REG_EIP].dword.erx >= minWriteMaxExecAddr)
+ return anx86->gen_reg[BX_32BIT_REG_EIP].dword.erx >= byteSize
+ ? MemoryBoundsError
+ : ExecutionError;
+#endif
if ((theErrorAcorn = setjmp(anx86->jmp_buf_env)) != 0) {
anx86->gen_reg[BX_32BIT_REG_EIP].dword.erx = anx86->prev_rip;
return theErrorAcorn;
}
blidx = 0;
- bx_cpu.sregs[BX_SEG_REG_CS].cache.u.segment.limit_scaled =
+ bx_cpu.sregs[BX_SEG_REG_CS].cache.u.segment.limit_scaled = minWriteMaxExecAddr - 1;
bx_cpu.sregs[BX_SEG_REG_DS].cache.u.segment.limit_scaled =
bx_cpu.sregs[BX_SEG_REG_SS].cache.u.segment.limit_scaled = byteSize;
- bx_cpu.sregs[BX_SEG_REG_CS].cache.u.segment.limit =
+ bx_cpu.sregs[BX_SEG_REG_CS].cache.u.segment.limit = minWriteMaxExecAddr >> 16;
bx_cpu.sregs[BX_SEG_REG_DS].cache.u.segment.limit =
bx_cpu.sregs[BX_SEG_REG_SS].cache.u.segment.limit = byteSize >> 16;
anx86->eipFetchPtr = theMemory;
- anx86->eipPageWindowSize = theMemorySize;
+ anx86->eipPageWindowSize = minWriteMaxExecAddr;
anx86->cpu_single_step();
return blidx == 0 ? 0 : SomethingLoggedError;
}
int
- runCPUInSizeMinAddressReadWrite(void *cpu,
- void *memory, ulong byteSize,
- ulong minReadAddr, ulong minWriteAddr)
+ runCPUInSizeMinAddressReadWrite(void *cpu, void *memory, ulong byteSize,
+ ulong minAddr, ulong minWriteMaxExecAddr)
{
BX_CPU_C *anx86 = (BX_CPU_C *)cpu;
@@ -135,24 +138,28 @@
return BadCPUInstance;
theMemory = (unsigned char *)memory;
theMemorySize = byteSize;
- minReadAddress = minReadAddr;
- minWriteAddress = minWriteAddr;
- if (anx86->gen_reg[BX_32BIT_REG_EIP].dword.erx >= theMemorySize)
- return MemoryBoundsError;
+ minReadAddress = minAddr;
+ minWriteAddress = minWriteMaxExecAddr;
+#if 0
+ if (anx86->gen_reg[BX_32BIT_REG_EIP].dword.erx >= minWriteMaxExecAddr)
+ return anx86->gen_reg[BX_32BIT_REG_EIP].dword.erx >= byteSize
+ ? MemoryBoundsError
+ : ExecutionError;
+#endif
if ((theErrorAcorn = setjmp(anx86->jmp_buf_env)) != 0) {
anx86->gen_reg[BX_32BIT_REG_EIP].dword.erx = anx86->prev_rip;
return theErrorAcorn;
}
blidx = 0;
- bx_cpu.sregs[BX_SEG_REG_CS].cache.u.segment.limit_scaled =
+ bx_cpu.sregs[BX_SEG_REG_CS].cache.u.segment.limit_scaled = minWriteMaxExecAddr - 1;
bx_cpu.sregs[BX_SEG_REG_DS].cache.u.segment.limit_scaled =
bx_cpu.sregs[BX_SEG_REG_SS].cache.u.segment.limit_scaled = byteSize;
- bx_cpu.sregs[BX_SEG_REG_CS].cache.u.segment.limit =
+ bx_cpu.sregs[BX_SEG_REG_CS].cache.u.segment.limit = minWriteMaxExecAddr >> 16;
bx_cpu.sregs[BX_SEG_REG_DS].cache.u.segment.limit =
bx_cpu.sregs[BX_SEG_REG_SS].cache.u.segment.limit = byteSize >> 16;
anx86->eipFetchPtr = theMemory;
- anx86->eipPageWindowSize = theMemorySize;
+ anx86->eipPageWindowSize = minWriteMaxExecAddr;
bx_pc_system.kill_bochs_request = 0;
anx86->cpu_loop(0 /* = "run forever" until exception or interupt */);
if (anx86->stop_reason != STOP_NO_REASON) {
@@ -415,12 +422,7 @@
last_read_address = (bx_address)-1;
}
-// Cut-down parts of cpu/cpu.cc
-void BX_CPU_C::prefetch(void)
-{
-}
-
// Cut-down parts of memory/misc_mem.cc for cpu/debugstuff.cc
bx_bool BX_MEM_C::dbg_fetch_mem(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, Bit8u *buf)
{
Modified: branches/Cog/platforms/win32/plugins/FilePlugin/sqWin32FilePrims.c
===================================================================
--- branches/Cog/platforms/win32/plugins/FilePlugin/sqWin32FilePrims.c 2010-10-13 18:39:14 UTC (rev 2329)
+++ branches/Cog/platforms/win32/plugins/FilePlugin/sqWin32FilePrims.c 2010-11-03 17:10:35 UTC (rev 2330)
@@ -83,7 +83,7 @@
if (!sqFileValid(f)) FAIL();
ofs.offset = 0;
ofs.dwLow = SetFilePointer(FILE_HANDLE(f), 0, &ofs.dwHigh, FILE_CURRENT);
- return ofs.offset == sqFileSize(f);
+ return ofs.offset >= sqFileSize(f);
}
sqInt sqFileClose(SQFile *f) {
Modified: branches/Cog/processors/IA32/bochs/cpu/cpu.cc
===================================================================
--- branches/Cog/processors/IA32/bochs/cpu/cpu.cc 2010-10-13 18:39:14 UTC (rev 2329)
+++ branches/Cog/processors/IA32/bochs/cpu/cpu.cc 2010-11-03 17:10:35 UTC (rev 2330)
@@ -677,7 +677,6 @@
// * ROM boundary: 2k (dont care since we are only reading)
// * segment boundary: any
-#if !COG
void BX_CPU_C::prefetch(void)
{
bx_address laddr = BX_CPU_THIS_PTR get_laddr(BX_SEG_REG_CS, RIP);
@@ -708,6 +707,7 @@
}
}
+#if !COG
bx_address lpf = LPFOf(laddr);
unsigned TLB_index = BX_TLB_INDEX_OF(lpf, 0);
bx_TLB_entry *tlbEntry = &BX_CPU_THIS_PTR TLB.entry[TLB_index];
@@ -715,9 +715,9 @@
if ((tlbEntry->lpf == lpf) && !(tlbEntry->accessBits & USER_PL)) {
pAddr = A20ADDR(tlbEntry->ppf | pageOffset);
-#if BX_SupportGuest2HostTLB
+# if BX_SupportGuest2HostTLB
fetchPtr = (Bit8u*) (tlbEntry->hostPageAddr);
-#endif
+# endif
}
else {
if (BX_CPU_THIS_PTR cr0.get_PG()) {
@@ -749,15 +749,15 @@
}
}
-#if BX_SUPPORT_ICACHE
+# if BX_SUPPORT_ICACHE
BX_CPU_THIS_PTR currPageWriteStampPtr = pageWriteStampTable.getPageWriteStampPtr(pAddr);
Bit32u pageWriteStamp = *(BX_CPU_THIS_PTR currPageWriteStampPtr);
pageWriteStamp &= ~ICacheWriteStampFetchModeMask; // Clear out old fetch mode bits
pageWriteStamp |= BX_CPU_THIS_PTR fetchModeMask; // And add new ones
pageWriteStampTable.setPageWriteStamp(pAddr, pageWriteStamp);
-#endif
+# endif
+#endif /* !COG */
}
-#endif
void BX_CPU_C::boundaryFetch(const Bit8u *fetchPtr, unsigned remainingInPage, bxInstruction_c *i)
{
Modified: branches/Cog/unixbuild/HowToBuild
===================================================================
--- branches/Cog/unixbuild/HowToBuild 2010-10-13 18:39:14 UTC (rev 2329)
+++ branches/Cog/unixbuild/HowToBuild 2010-11-03 17:10:35 UTC (rev 2330)
@@ -9,6 +9,10 @@
3. Open a shell, cd into the unixbuild/bld directory and execute
../../platforms/unix/config/configure CFLAGS="-g -O2 -msse2 -D_GNU_SOURCE -DNDEBUG -DITIMER_HEARTBEAT=1 -DNO_VM_PROFILE=1 -DCOGMTVM=0 -DDEBUGVM=0" LIBS=-lpthread
make install prefix=WhereYouWantTheVmToGo
+
+ N.B. On Ubuntu *do not* supply "LIBS=-lpthread", i.e. use
+ ../../platforms/unix/config/configure CFLAGS="-g -O2 -msse2 -D_GNU_SOURCE -DNDEBUG -DITIMER_HEARTBEAT=1 -DNO_VM_PROFILE=1 -DCOGMTVM=0 -DDEBUGVM=0"
+
4. At the end of it you'll get a new VM in the path provided via -prefix
More information about the Vm-dev
mailing list