From 5c001ba645ce56c8b4d689078ce1078185d5df5d Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Tue, 22 Mar 2005 16:12:18 +0000 Subject: [PATCH] Allocate executable space to detect cpu features (cpuid). aka don't crash on non-executable .data sections on x86-64 with NX support enabled. --- BasiliskII/src/uae_cpu/compiler/codegen_x86.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/BasiliskII/src/uae_cpu/compiler/codegen_x86.cpp b/BasiliskII/src/uae_cpu/compiler/codegen_x86.cpp index 9c1036b4..2286be1b 100644 --- a/BasiliskII/src/uae_cpu/compiler/codegen_x86.cpp +++ b/BasiliskII/src/uae_cpu/compiler/codegen_x86.cpp @@ -3671,7 +3671,12 @@ x86_get_cpu_vendor(struct cpuinfo_x86 *c) static void cpuid(uae_u32 op, uae_u32 *eax, uae_u32 *ebx, uae_u32 *ecx, uae_u32 *edx) { - static uae_u8 cpuid_space[256]; + const int CPUID_SPACE = 4096; + uae_u8* cpuid_space = (uae_u8 *)vm_acquire(CPUID_SPACE); + if (cpuid_space == VM_MAP_FAILED) + abort(); + vm_protect(cpuid_space, CPUID_SPACE, VM_PAGE_READ | VM_PAGE_WRITE | VM_PAGE_EXECUTE); + static uae_u32 s_op, s_eax, s_ebx, s_ecx, s_edx; uae_u8* tmp=get_target(); @@ -3699,6 +3704,8 @@ cpuid(uae_u32 op, uae_u32 *eax, uae_u32 *ebx, uae_u32 *ecx, uae_u32 *edx) if (ebx != NULL) *ebx = s_ebx; if (ecx != NULL) *ecx = s_ecx; if (edx != NULL) *edx = s_edx; + + vm_release(cpuid_space, CPUID_SPACE); } static void