MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / CheckForGCS

Function CheckForGCS

Source/Tools/FEXLoader/FEXLoader.cpp:237–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235
236namespace FEX::GCS {
237void CheckForGCS() {
238#ifndef PR_GET_SHADOW_STACK_STATUS
239#define PR_GET_SHADOW_STACK_STATUS 74
240#endif
241#ifndef PR_LOCK_SHADOW_STACK_STATUS
242#define PR_LOCK_SHADOW_STACK_STATUS 76
243#endif
244#ifndef PR_SHADOW_STACK_ENABLE
245#define PR_SHADOW_STACK_ENABLE (1ULL << 0)
246#endif
247 uint64_t ShadowStackWord {};
248 if (prctl(PR_GET_SHADOW_STACK_STATUS, &ShadowStackWord, 0, 0, 0) == -1) {
249 return;
250 }
251
252 // Kernel supports shadow stack.
253 if (ShadowStackWord & PR_SHADOW_STACK_ENABLE) {
254 // Welp.
255 ERROR_AND_DIE_FMT("Shadow stack is enabled which FEX is incompatible with!");
256 }
257
258 // Disable if we've gotten this far, to ensure guest can't try.
259 prctl(PR_LOCK_SHADOW_STACK_STATUS, ~0ULL, 0, 0, 0);
260}
261} // namespace FEX::GCS
262
263/**

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected