mirror of
https://github.com/decompals/wibo.git
synced 2025-12-12 14:46:09 +00:00
Save/restore fs/gs segments when re-entering host code
This commit is contained in:
12
src/main.cpp
12
src/main.cpp
@@ -347,6 +347,14 @@ int main(int argc, char **argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint16_t hostFsSelector = 0;
|
||||
uint16_t hostGsSelector = 0;
|
||||
asm volatile("mov %%fs, %0" : "=r"(hostFsSelector));
|
||||
asm volatile("mov %%gs, %0" : "=r"(hostGsSelector));
|
||||
tib.hostFsSelector = hostFsSelector;
|
||||
tib.hostGsSelector = hostGsSelector;
|
||||
tib.hostSegmentsValid = 1;
|
||||
|
||||
// Determine the guest program name
|
||||
auto guestArgs = wibo::splitCommandLine(cmdLine.c_str());
|
||||
std::string programName;
|
||||
@@ -483,6 +491,10 @@ int main(int argc, char **argv) {
|
||||
|
||||
// Invoke the damn thing
|
||||
asm("movw %0, %%fs; call *%1" : : "r"(wibo::tibSelector), "r"(entryPoint));
|
||||
if (tib.hostSegmentsValid) {
|
||||
asm volatile("movw %0, %%fs" : : "r"(tib.hostFsSelector) : "memory");
|
||||
asm volatile("movw %0, %%gs" : : "r"(tib.hostGsSelector) : "memory");
|
||||
}
|
||||
DEBUG_LOG("We came back\n");
|
||||
wibo::shutdownModuleRegistry();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user