mirror of
https://github.com/Bareflank/hypervisor
synced 2026-08-17 06:23:04 -04:00
Loader: Build the arch target defined by CMake
This patch fixes an issue that could arise if the following conditions are met: - set HYPERVISOR_TARGET_ARCH to Intel in CMake - build the loader for Linux on an AMD machine - On AMD, `make driver_quick`, then `make start` -> computer hangs This occurs because the loader is built using the architecture of the build machine while the hypervisor is built using the target arch set during cmake configuration which can be different. The cpu checks are done inside the Linux driver which will succeed and load the hypervisor which is using Intel specific instructions causing the machine to hang when it tries to start on AMD. We now use the cmake HYPERVISOR_TARGET_ARCH variable in Makefile which will keep the hypervisor and the Linux driver in sync.
This commit is contained in:
parent
f548617a99
commit
d2030b602d
5 changed files with 14 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -78,6 +78,7 @@ loader/**/*.o
|
|||
loader/**/*.o.cmd
|
||||
loader/**/*.cmd
|
||||
loader/**/*.dwo
|
||||
loader/linux/Makefile
|
||||
|
||||
# Windows Loader
|
||||
loader/windows/x64/
|
||||
|
|
|
|||
|
|
@ -20,6 +20,12 @@
|
|||
# SOFTWARE.
|
||||
|
||||
if(HYPERVISOR_BUILD_LOADER AND NOT HYPERVISOR_TARGET_ARCH STREQUAL "aarch64")
|
||||
configure_file(
|
||||
${hypervisor_SOURCE_DIR}/loader/linux/Makefile.in
|
||||
${hypervisor_SOURCE_DIR}/loader/linux/Makefile
|
||||
@ONLY
|
||||
)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_custom_target(loader_build
|
||||
COMMAND ${CMAKE_COMMAND} -E chdir ${hypervisor_SOURCE_DIR}/loader/linux make CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}'
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
# SOFTWARE.
|
||||
|
||||
TARGET_MODULE := bareflank_loader
|
||||
VENDOR_ID := $(shell lscpu | grep 'Vendor ID')
|
||||
VENDOR_ID := @HYPERVISOR_TARGET_ARCH@
|
||||
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
obj-m := $(TARGET_MODULE).o
|
||||
|
|
@ -84,17 +84,17 @@ check_for_amd(void) NOEXCEPT
|
|||
intrinsic_cpuid(&eax, &ebx, &ecx, &edx);
|
||||
|
||||
if (CPUID_VENDOR_EBX != ebx) {
|
||||
bferror_x32("cpu is vendor is not AuthenticAMD", ebx);
|
||||
bferror_x32("cpu vendor is not AuthenticAMD", ebx);
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
if (CPUID_VENDOR_ECX != ecx) {
|
||||
bferror_x32("cpu is vendor is not AuthenticAMD", ecx);
|
||||
bferror_x32("cpu vendor is not AuthenticAMD", ecx);
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
if (CPUID_VENDOR_EDX != edx) {
|
||||
bferror_x32("cpu is vendor is not AuthenticAMD", edx);
|
||||
bferror_x32("cpu vendor is not AuthenticAMD", edx);
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,17 +106,17 @@ check_for_intel(void) NOEXCEPT
|
|||
intrinsic_cpuid(&eax, &ebx, &ecx, &edx);
|
||||
|
||||
if (CPUID_VENDOR_EBX != ebx) {
|
||||
bferror_x32("cpu is vendor is not GenuineIntel", ebx);
|
||||
bferror_x32("cpu vendor is not GenuineIntel", ebx);
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
if (CPUID_VENDOR_ECX != ecx) {
|
||||
bferror_x32("cpu is vendor is not GenuineIntel", ecx);
|
||||
bferror_x32("cpu vendor is not GenuineIntel", ecx);
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
if (CPUID_VENDOR_EDX != edx) {
|
||||
bferror_x32("cpu is vendor is not GenuineIntel", edx);
|
||||
bferror_x32("cpu vendor is not GenuineIntel", edx);
|
||||
return LOADER_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue