Commit Graph

43 Commits

Author SHA1 Message Date
Morilli 542f917b1f fix a new waterboxhost warning 2024-10-18 23:54:18 +02:00
Morilli c80416245e specify nightly toolchain in rust-toolchain.toml
not touching whatever the fuck build-release.bat is
2024-09-03 07:37:18 +02:00
Morilli 959484ee13 fix a waterboxhost compile warning 2024-09-03 07:36:29 +02:00
CasualPokePlayer 4ad33b3d06 Rebuild waterboxhost on Debian 10
Also fix the build scripts to explicitly use nightly (which waterboxhost does need currently)
2024-06-17 21:35:57 -07:00
CasualPokePlayer 6e5de797d2 Build rust projects with x86_64-win7-windows-msvc target 2024-06-17 19:41:52 -07:00
Morilli 39d3c28bc3 Update waterboxhost dependencies
- closes #3279
2024-06-15 16:16:13 +02:00
Morilli af25174906 Fix some waterboxhost warnings
🤞that this is correct
2024-04-30 19:28:33 +02:00
James Groom 4217be1528
waterboxhost: Add missing import, tests now run 2023-07-28 04:42:45 +10:00
nattthebear 281e3be4a8
bare minimum implementation of getpid/getppid (#3641) 2023-04-19 21:29:45 -04:00
CasualPokePlayer a46c47d271 git ignore build directory for waterboxhost 2023-04-18 21:35:58 -07:00
nattthebear 64512851fe
Fix up some more issues with Waterbox and 0 size elf data (#3590) 2023-03-23 08:28:10 -04:00
nattthebear eb5ebda53f
Waterbox: Fix various problems with 0 length sections and segments (#3586)
* waterbox: fix crash when init_array is size 0

* also handle 0 len segments
2023-03-18 19:50:32 -04:00
nattthebear 91e6d8023a
waterbox: invis section tweak (#3580)
don't fail when a 0 byte section starts at the same place as invis
2023-03-14 21:02:38 -04:00
Morilli bde5ee5167 Fix waterboxhost for version 1.60.0-nightly
closes #2750
2022-01-29 00:22:54 +01:00
nattthebear 2ea62ffea6
Handle reentrant calls in waterbox (#3007)
Fixes #2585
2021-11-23 14:20:12 -05:00
CasualPokePlayer 41128abc37
[melonDS] Redo porting, waterbox style now (#2945)
Co-authored-by: nattthebear <goyuken@gmail.com>
2021-10-24 21:40:23 +03:00
nattthebear 2c0c6aa0bb rename a bunch of shit because someone has a fetish for RFCs
rust maintains its reputation as a less annoying language to write systems code in than C, but only just barely.

yeets #2750
2021-05-26 16:07:07 -04:00
YoshiRulz 8e7f171ae9
Copy to Assets and output when building wbox cores and host 2021-04-28 16:06:41 +10:00
nattthebear 72ea5ce866
Waterbox: Allow SEH unwinding through guest calls. (#2519)
The goal of the separate stacks was to allow this, but I never quite finished the job.  Now, when a SEH exception (generally a Rust panic in a guest syscall handler, or a C# Exception in a callback) tries to unwind through guest code, it works.  Note that we don't actually unwind the guest stack, as there's nothing useful to be gained from that;  When an emulator core throws an exception like this, it should be considered completely hosed.  Throw it out and get a new one.

There were two bugs stopping this from working.

First of all, we had custom thunks that lacked sufficient unwind information for RtlUnwind to get through.  For the sysv <-> msabi adapter, this was fixed by making it regular Rust code instead of hand assembled junkus.  So the compiler generates valid unwind information for all of that.  Then we just JIT a small stub on top in the MsHostSysVGuest code, which needs no unwind information because it won't throw an exception itself and transparently passes execution to something with valid unwind information without invalidating that information.  (NB:  Clr JIT stubs use the same strategy.)  For the host <-> guest stack transition code, a small hand generated unwind stub was added to interop.s that is registered with `RtlAddFunctionTable`.  I've seen the unwind work successfully without this second set of unwind information, but better safe than sorry.

Secondly, our misuse of SubSystemTib caught up with us.  It's an old field, allegedly from OS/2, that we repurposed to hold TLS information needed for the waterbox stack transitions.  Most people think nothing uses it any more, but in fact if it's set to a non-NULL value, but doesn't contain valid information, `KERNELBASE!GetModuleFileNameW` will crash when it tries to get a module name from there.  The fix here was to simply tighten up our usage of SubSystemTib:  We were already nulling it out when returning from guest code, but not when calling back to host code in guest code.

Fixes #2487.  Unwinding of this sort has never worked well in waterbox; the reason why that issue is more recent is that the particular reproducing case of firmware didn't cause an exception in a callback in older code; the exception happened in pure managed code.
2020-12-13 19:12:16 -05:00
nattthebear 98ad14ff47 Fix two semi-related savestate bugs in waterbox.
We had two instances where the act of sealing could lose snapshots that were never recovered.  It's oof.
2020-10-13 09:10:46 -04:00
nattthebear 27e600c1ac Fix some confusions in no-dirty-detection mode
This caused some awful crashes, but doesn't affect any real release builds of waterboxhost
2020-10-13 09:10:40 -04:00
James Groom a5d166cf71
Partial fix for #2353 (files in dev builds) (#2410)
* Move .so libraries to dll dir, update some build scripts

* Move OpenTK.dll.config with OpenTK.dll

* Keep EmuHawkMono.sh in Windows-built artifacts

* Add Package.sh to match QuickTestBuildAndPackage.bat

used as `Dist/BuildRelease.sh && Dist/Package.sh`

* Update GitLab CI to use Package.sh
2020-09-18 20:08:34 -05:00
nattthebear 78bf2285fc
Waterbox: Add pseudo-thread implementation and experimental DobieStation (PS2) core (#2263)
Waterbox supports threads now, but they're not real threads on the host side because that's complicated and can be nondeterministic. Instead, everything is scheduled to share one host thread. This means that scheduling is actually cooperative and certain patterns of spinlocks and other nonsense can fail to work at all, but "regular" code probably will.

With this, add DobieStation PS2 core. This core was selected because it has threads and is otherwise simple to port; easy to build and a good core/frontend separation. It's not a wonderful core however, with low speed (made abysmally lower by our lack of real threads) and low compatibility, so it remains a curiosity for now.
2020-08-01 07:03:29 -04:00
nattthebear 1c606c1eb6 waterbox - expose read-only information about the guest memory page table 2020-07-23 16:08:24 -04:00
nattthebear 356abf6c43 Really, actually, truly fix the waterbox savestate snafu, probably
The description in the previous commit is accurate, but the problem runs deeper and was on the whole a complete failure for me to appreciate the difference between active and swapped in on memoryblocks.  Bleeecch.
2020-07-23 15:20:04 -04:00
nattthebear e343f6bd26 Fix a complete savestate snafu in waterbox
This was broken by 175556529e, with two related issues:  When we allowed for some operations to happen even when the block is inactive, we didn't account for the fact that in swapin, the block technically is not active yet (the lock is not on the self), and similarly in swapout, the lock has already been moved out of self.  The former caused all memory areas to revert to RWX at the host OS level after a swap, so no dirty detection was done.  After the former was fixed, the latter caused saved costacks to still get missed.

At the same time we ran into a perfect storm with costacks on Windows; if a stack page is not yet dirty, but we hit a fault for something else, Windows will not call our VEH handler unless the TIB stack extents are satisfactory, since it needs userspace to fix up the TIB extents via VEH or SEH handler, but there's already an exception pending.
2020-07-23 13:30:58 -04:00
nattthebear c7e8744664 Add an extra exclamation point to indicate that code is VERY IMPORTANT
This broke any waterbox core that called in to native code in the same EnterExit() right after sealing.  All nyma cores were broken, 32x was not, didn't check the rest.  Regressed in 175556529e.

It worked fine in release mode, theoretically
2020-07-18 11:54:05 -04:00
nattthebear 175556529e waterboxhost refactor
Set up a second mirror of guest memory; easily accomplished because we were already using memfd_create / CreateFileMappingW.
This lets us simplify a lot of host code that has to access guest memory that may not be active right now, or might have been mprotect()ed to something weird.  Activate is only needed now to run guest code, or when the C# side wants to peer into guest memory for memory domains and such (waterboxhost does not share the mirror address with the C# side).
2020-07-13 19:38:29 -04:00
nattthebear beb51ab286 Fix a linux waterbox-releated crash
Repro steps:
1) Load any waterbox core
2) Do anything that would trigger a NullReferenceException on C# side that you'd normally expect to be caught
2020-07-12 11:03:12 -04:00
nattthebear d354faeec1 probably fix linux waterbox issue 2020-07-12 07:49:18 -04:00
nattthebear b0e6174467 minor cleanup 2020-07-08 13:54:47 -04:00
nattthebear a67fa70632 waterbox linux - rework to avoid possible memory leak
Bizhawk never would hit this because it only ever runs waterboxes in one host thread, but an application that spun up many threads and ran waterboxes in each would leak 32 bytes of heap for each native thread destroyed, which is super duper not really meaningful at all
2020-07-08 07:22:15 -04:00
nattthebear c8985e3007
Waterbox: Stack Marshalling (#2209)
Waterbox guest code now runs on a stack inside the guest memory space. This removes some potential opportunities for nondeterminism and makes future porting of libco-enabled cores easier.
2020-07-07 17:48:12 -04:00
nattthebear 3a18f6356d Rebuild all of waterbox as sysvabi, not msabi
This helps linux at the expense of windows, except it seems like windows gets a nice little speed up as well
2020-07-03 18:21:48 -04:00
nattthebear fa5885d7a1
Rewrite WaterboxHost in rust. (#2190)
This replaces the old managed one.  The only direct effect of this is to fix some hard to reproduce crashes in bsnes.

In the long run, we'll use this new code to help build more waterbox features.
2020-07-03 11:45:59 -04:00
nattthebear c1caa3e346 More crusty progress 2020-06-28 10:21:36 -04:00
nattthebear 6ff2d801e6 memoryblock experiments continue 2020-06-23 15:01:49 -04:00
nattthebear 92525576cc more krusty krab 2020-06-22 18:15:11 -04:00
nattthebear b0007c83f4 more musings 2020-06-21 14:09:38 -04:00
nattthebear 3f6ffeb573 krusty 2020-06-20 18:07:17 -04:00
nattthebear 440a340cb5 remove what should have been ignored 2020-06-20 13:49:58 -04:00
nattthebear be81bc12c2 more wip 2020-06-20 10:30:41 -04:00
nattthebear ee6c2ba679 Watch babby's first rust program... one commit at a time
Working on some ideas to potentially replace WaterboxHost
2020-06-19 20:56:16 -04:00