mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 08:00:15 +02:00
Merge pull request #4689 from Sonicadvance1/disable_gcs_protection
Disable GCS in simulator and userspace
This commit is contained in:
2 files changed
+31
No files matched your search
@@ -370,6 +370,8 @@ Arm64Emitter::Arm64Emitter(FEXCore::Context::ContextImpl* ctx, void* EmissionPtr
|
||||
// Hardcode a 256-bit vector width if we are running in the simulator.
|
||||
// Allow the user to override this.
|
||||
Simulator.SetVectorLengthInBits(ForceSVEWidth() ? ForceSVEWidth() : 256);
|
||||
// FEX doesn't support GCS.
|
||||
Simulator.DisableGCSCheck();
|
||||
#endif
|
||||
#ifdef VIXL_DISASSEMBLER
|
||||
// Only setup the disassembler if enabled.
|
||||
|
||||
@@ -270,6 +270,33 @@ void SetupCompatInput(bool enable) {
|
||||
}
|
||||
} // namespace FEX::CompatInput
|
||||
|
||||
namespace FEX::GCS {
|
||||
void CheckForGCS() {
|
||||
#ifndef PR_GET_SHADOW_STACK_STATUS
|
||||
#define PR_GET_SHADOW_STACK_STATUS 74
|
||||
#endif
|
||||
#ifndef PR_LOCK_SHADOW_STACK_STATUS
|
||||
#define PR_LOCK_SHADOW_STACK_STATUS 76
|
||||
#endif
|
||||
#ifndef PR_SHADOW_STACK_ENABLE
|
||||
#define PR_SHADOW_STACK_ENABLE (1ULL << 0)
|
||||
#endif
|
||||
uint64_t ShadowStackWord {};
|
||||
if (prctl(PR_GET_SHADOW_STACK_STATUS, &ShadowStackWord, 0, 0, 0) == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Kernel supports shadow stack.
|
||||
if (ShadowStackWord & PR_SHADOW_STACK_ENABLE) {
|
||||
// Welp.
|
||||
ERROR_AND_DIE_FMT("Shadow stack is enabled which FEX is incompatible with!");
|
||||
}
|
||||
|
||||
// Disable if we've gotten this far, to ensure guest can't try.
|
||||
prctl(PR_LOCK_SHADOW_STACK_STATUS, ~0ULL, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get an FD from an environment variable and then unset the environment variable.
|
||||
*
|
||||
@@ -314,6 +341,8 @@ int main(int argc, char** argv, char** const envp) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
FEX::GCS::CheckForGCS();
|
||||
|
||||
FEX::Config::LoadConfig(std::move(ArgsLoader), Program.ProgramName, envp, PortableInfo);
|
||||
|
||||
// Reload the meta layer
|
||||
|
||||
Reference in new issue
Block a user