summaryrefslogtreecommitdiff
path: root/DevTools
AgeCommit message (Collapse)Author
2020-07-16UserspaceEmulator: Fix incorrect SALC behaviorAndreas Kling
As @tzoz pointed out, SALC should set AL to 0xff when CF=1, not 0x01. Fixes #2819.
2020-07-16UserspaceEmulator: Let's say "Use-after-free" instead of "UAF"Andreas Kling
I don't know why I went with the compact format here.
2020-07-16UserspaceEmulator: Cache the location and size of "malloc" and "free"Andreas Kling
This allows us to quickly skip some auditing checks while we're inside malloc/free themselves.
2020-07-15UserspaceEmulator: Don't complain about free(nullptr)Andreas Kling
2020-07-15UserspaceEmulator: Add the getrandom() syscallAndreas Kling
2020-07-15UserspaceEmulator: Fix bogus use of "errno" in shbuf related syscallsAndreas Kling
When we're making direct syscalls, there's no "errno" involved. Thanks to Sergey for spotting these.
2020-07-15UserspaceEmulator: Log invalid and double free() calls :^)Andreas Kling
We can easily catch free() on never-malloced addresses, as well as double calls to free() on the same address, so let's do it!
2020-07-15UserspaceEmulator: Catch use-after-frees by tracking malloc/free :^)Andreas Kling
This patch introduces a "MallocTracer" to the UserspaceEmulator. If this object is present on the Emulator, it can be notified whenever the emulated program does a malloc() or free(). The notifications come in via a magic instruction sequence that we embed in the LibC malloc() and free() functions. The sequence is: "salc x2, push reg32 x2, pop reg32 x3" The data about the malloc/free operation is in the three pushes. We make sure the sequence is harmless when running natively. Memory accesses on MmapRegion are then audited to see if they fall inside a known-to-be-freed malloc chunk. If so, we complain loud and red in the debugger output. :^) This is very, very cool! :^) It's also a whole lot slower than before, since now we're auditing memory accesses against a new set of metadata. This will need to be optimized (and running in this mode should be opt-in, perhaps even a separate program, etc.)
2020-07-15UserspaceEmulator: Add some more syscalls :^)Andreas Kling
Here's set_process_icon(), gettimeofday() and clock_gettime().
2020-07-15UserspaceEmulator: Add partial support for the SHLD/SHRD instructionsAndreas Kling
We don't support all the addressing modes yet, but it won't be very hard to add the rest of them when needed.
2020-07-15UserspaceEmulator: Add support for shared buffers (shbuf)Andreas Kling
We track these separately from regular mmap() regions, as they have slightly different behaviors.
2020-07-15UserspaceEmulator: Dump backtrace on FPU instructionAndreas Kling
2020-07-15UserspaceEmulator: Implement MUL_RM32Andreas Kling
2020-07-15UserspaceEmulator: Implement the 32-bit BSWAP instruction :^)Andreas Kling
2020-07-15UserspaceEmulator: Implement an assortment of system callsAndreas Kling
Here goes mkdir(), unlink(), socket(), getsockopt(), fchmod() bind(), connect(), listen(), select() and recvfrom(). They're not perfect but they seem to work. :^)
2020-07-15UserspaceEmulator: Implement IDIV_RM32Andreas Kling
2020-07-15UserspaceEmulator: Implement the CBW/CDQ/CWD/CWDE instructionsAndreas Kling
2020-07-15LibX86+UserspaceEmulator: Don't store a32 in MemoryOrRegisterReferenceAndreas Kling
The a32 bit tells us whether a memory address is 32-bit or not. We already have this information in Instruction, so just plumb that around instead of double-caching the bit.
2020-07-15UserspaceEmulator: Implement virt$pipe()Sergey Bugaev
2020-07-15LibGUI: Use enum for TextEditor modes & add new DisplayOnly modethankyouverycool
Adds a new, more restrictive read-only state to TextEditor which forbids copying, selecting, editor cursors, and context menus. Provides a unique appearance on focus which accomodates ComboBox widgets. All TextEditor modes are now accessed by enum and set_mode() which sets the editor to Editable, ReadOnly or DisplayOnly. Updates applications still using set_readonly().
2020-07-13LibX86+UserspaceEmulator: Devirtualize and inline more instruction codeAndreas Kling
Use some template hacks to force GCC to inline more of the instruction decoding stuff into the UserspaceEmulator main execution loop. This is my last optimization for today, and we've gone from ~60 seconds when running "UserspaceEmulator UserspaceEmulator id" to ~8 seconds :^)
2020-07-13UserspaceEmulator: Mark some generic instructions ALWAYS_INLINE :^)Andreas Kling
2020-07-13UserspaceEmulator: Move the SoftCPU stream virtuals to the headerAndreas Kling
They don't actually get inlined yet, but at least this devirtualizes them which is nice.
2020-07-13UserspaceEmulator+LibX86: Turn on -O3 optimization for emulation codeAndreas Kling
Since this code is performance-sensitive, let's have the compiler do whatever it can to help us with the most important files. This yields a ~8% speedup.
2020-07-13UserspaceEmulator: Add a very simple instruction fetch cacheAndreas Kling
To avoid MMU region lookup on every single instruction fetch, we now cache a raw pointer to the current instruction. This gets automatically invalidated when we jump somewhere, but as long as we're executing sequentially, instruction fetches will hit the cache and bypass all the region lookup stuff. This is about a ~2x speedup. :^)
2020-07-13UserspaceEmulator: Add the POPFD instructionAndreas Kling
I'm not sure the mask I'm using here is completely correct, but it's not terribly important since we're a userspace-only emulator anyway.
2020-07-13UserspaceEmulator: Add the NOT instruction (with bonus: NOP!)Andreas Kling
2020-07-13UserspaceEmulator: Add the STC/CLC and STD/CLD instructionsAndreas Kling
2020-07-13UserspaceEmulator: Implement the ADC instructionAndreas Kling
2020-07-13UserspaceEmulator: Make SBB actually respect the SoftCPU carry flagAndreas Kling
We were forgetting to set the host CPU's carry flag before executing the SBB instruction. This made the result a bit unpredictable. :^)
2020-07-13UserspaceEmulator: Remove an unnecessary step in some instructionsAndreas Kling
We don't need to move the result of shifts around like this, we can just use inline assembly outputs to make it end up in the right place.
2020-07-13UserspaceEmulator: Fix wrong ESI/EDI step sizes in MOVSW and MOVSDAndreas Kling
2020-07-13UserspaceEmulator: Add some more syscallsAndreas Kling
We can now unmap mapped memory, among other things. This is all very ad-hoc as I'm trying to run UserspaceEmulator inside itself. :^)
2020-07-13UserspaceEmulator: Add basic support for memory-mapped filesAndreas Kling
MmapRegion now supports using an mmap'ed file descriptor as backing.
2020-07-13UserspaceEmulator: Implement the PUSHFD instructionAndreas Kling
2020-07-13UserspaceEmulator: Make mmap'ed memory track read/write protectionAndreas Kling
Here's the first time we get a taste of better information than the real hardware can give us: unlike x86 CPUs, we can actually support write-only memory, so now we do! While this isn't immediately useful, it's still pretty cool. :^)
2020-07-13UserspaceEmulator: Pass arguments through to emulated processAndreas Kling
Ultimately we'll want to support passing some options to the emulator as well, but for now just pass all arguments (except argv[0] of course) through to the emulated process. This is still not perfect, but slightly better than what we had before.
2020-07-13UserspaceEmulator: Move SimpleRegion to its own filesAndreas Kling
2020-07-13UserspaceEmulator: Support the fstat() and get_process_name() syscallsAndreas Kling
For now, we just pretend that the process name is "EMULATED". We can probably do better though. :^)
2020-07-12UserspaceEmulator: Move exit() syscall logging to debug outputAndreas Kling
We want the emulated program to appear without noise in the terminal.
2020-07-12UserspaceEmulator: Put some syscall logging behind DEBUG_SPAMAndreas Kling
2020-07-12UserspaceEmulator: Implement enough syscalls to get /bin/id running :^)Andreas Kling
2020-07-12UserspaceEmulator: Implement/stub out various syscallsAndreas Kling
Moving forward on getting /bin/id to run inside the emulator. :^)
2020-07-12UserspaceEmulator: Disable per-instruction trace dumps for nowAndreas Kling
With tracing turned on, it's just too slow when doing big operations like initializing malloc freelists.
2020-07-12UserspaceEmulator: Put the executable name in argv[0] :^)Andreas Kling
The emulated program can now find its own name in argv[0]. Very cool!
2020-07-12UserspaceEmulator: Add Emulator::dump_backtrace()Andreas Kling
This gives you a nice, symbolicated backtrace at the current EIP. :^)
2020-07-12UserspaceEmulator: "Add" a couple of syscallsAndreas Kling
This patch adds gettid() and stubs out pledge() and unveil() for now.
2020-07-12UserspaceEmulator: Fix missing sign extension in PUSH_imm8Andreas Kling
2020-07-12UserspaceEmulator: Add some convenient SoftMMU APIs for copying dataAndreas Kling
We'll soon want to copy data in and out of the SoftMMU memory space.
2020-07-12UserspaceEmulator: Implement the XADD instructionAndreas Kling