Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fsgsbase on hostrunner #4104

Closed
Sonicadvance1 opened this issue Oct 4, 2024 · 0 comments · Fixed by #4109
Closed

Fix fsgsbase on hostrunner #4104

Sonicadvance1 opened this issue Oct 4, 2024 · 0 comments · Fixed by #4109

Comments

@Sonicadvance1
Copy link
Member

Sonicadvance1 commented Oct 4, 2024

Once herumi/xbyak#193 is merged, rebase xbyak on latest.

Then make sure to save and restore fs/gs in the hostrunner.
This will let our unittests use wrfsbase without breaking host TLS, since it can be restored.

Example for just fs, but should include gs also:

diff --git a/Source/Tools/TestHarnessRunner/TestHarnessRunner/HostRunner.cpp b/Source/Tools/TestHarnessRunner/TestHarnessRunner/HostRunner.cpp
index 0e9b88cca..9a816ccac 100644
--- a/Source/Tools/TestHarnessRunner/TestHarnessRunner/HostRunner.cpp
+++ b/Source/Tools/TestHarnessRunner/TestHarnessRunner/HostRunner.cpp
@@ -51,7 +51,8 @@ public:
     push(r13);
     push(r14);
     push(r15);
-    sub(rsp, 8);
+    rdfsbase(rbx);
+    push(rbx);

     // Save this stack pointer so we can cleanly shutdown the emulation with a long jump
     // regardless of where we were in the stack
@@ -103,8 +104,8 @@ public:

     ThreadStopHandlerAddress = getCurr<uint64_t>();

-    add(rsp, 8);
-
+    pop(rbx);
+    wrfsbase(rbx);
     pop(r15);
     pop(r14);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant