From 73ba54bd296540d6933e505b83078ebca54a09e0 Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 25 Nov 2025 06:58:31 +0000 Subject: [PATCH] Enforce W^X on macro jit --- src/video_core/macro/macro_jit_x64.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/video_core/macro/macro_jit_x64.cpp b/src/video_core/macro/macro_jit_x64.cpp index f8811d29c8..65935f6c62 100644 --- a/src/video_core/macro/macro_jit_x64.cpp +++ b/src/video_core/macro/macro_jit_x64.cpp @@ -44,10 +44,20 @@ std::bitset<32> PersistentCallerSavedRegs() { return PERSISTENT_REGISTERS & Common::X64::ABI_ALL_CALLER_SAVED; } +/// @brief Must enforce W^X constraints, as we yet don't havea global "NO_EXECUTE" support flag +/// the speed loss is minimal, and in fact may be negligible, however for your peace of mind +/// I simply included known OSes whom had W^X issues +#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) +static const auto default_cg_mode = Xbyak::DontSetProtectRWE; +#else +static const auto default_cg_mode = nullptr; //Allow RWE +#endif + class MacroJITx64Impl final : public Xbyak::CodeGenerator, public CachedMacro { public: explicit MacroJITx64Impl(Engines::Maxwell3D& maxwell3d_, const std::vector& code_) - : CodeGenerator{MAX_CODE_SIZE}, code{code_}, maxwell3d{maxwell3d_} { + : Xbyak::CodeGenerator(MAX_CODE_SIZE, default_cg_mode) + , code{code_}, maxwell3d{maxwell3d_} { Compile(); }