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

Added check for AVX on boot #1067

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UnleashedRecomp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ if (WIN32)
Synchronization
winmm
)
endif()
endif()

target_link_libraries(UnleashedRecomp PRIVATE
fmt::fmt
Expand Down
26 changes: 25 additions & 1 deletion UnleashedRecomp/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdafx.h>
#include <cpuid.h>
#include <cpu/guest_thread.h>
#include <gpu/video.h>
#include <kernel/function.h>
Expand Down Expand Up @@ -147,6 +148,29 @@ uint32_t LdrLoadModule(const std::filesystem::path &path)
return entry;
}

__attribute__((constructor(101), target("no-avx,no-avx2"), noinline))
void init()
{
#ifdef __x86_64__
uint32_t eax, ebx, ecx, edx;

// Execute CPUID for processor info and feature bits.
__get_cpuid(1, &eax, &ebx, &ecx, &edx);

// Check for AVX support.
if ((ecx & (1 << 28)) == 0)
{
printf("[*] CPU does not support the AVX instruction set.\n");

#ifdef _WIN32
MessageBoxA(nullptr, "Your CPU does not meet the minimum system requirements.", "Unleashed Recompiled", MB_ICONERROR);
#endif

std::_Exit(1);
}
#endif
}

int main(int argc, char *argv[])
{
#ifdef _WIN32
Expand All @@ -156,7 +180,7 @@ int main(int argc, char *argv[])
os::process::CheckConsole();

if (!os::registry::Init())
LOGN_WARNING("OS doesn't support registry");
LOGN_WARNING("OS does not support registry.");

os::logger::Init();

Expand Down
Loading