Skip to content
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
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -986,9 +986,6 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER
# Linux uses a bootstrap program to reserve address space
if (YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY)
if (YOKAI_TARGET_ARCH_ARM64)
add_executable(nacl_helper_bootstrap-armhf tools/nacl_helper_bootstrap-armhf/nacl_helper_bootstrap-armhf.cpp)
add_dependencies(runtime_deps nacl_helper_bootstrap-armhf)

add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
${FULL_OUTPUT_DIR}/lib-armhf
Expand Down
48 changes: 29 additions & 19 deletions src/engine/framework/VirtualMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,22 @@ static void CheckMinAddressSysctlTooLarge()
#endif // __linux__
}

#if defined(__linux__) && (defined(YOKAI_ARCH_ARM64) || defined(YOKAI_ARCH_ARMHF))
static bool OnArm64()
{
#if defined(YOKAI_ARCH_ARM64)
bool onArm64 = true;
#elif defined(YOKAI_ARCH_ARMHF)
bool onArm64 = false;
struct utsname buf;
if (!uname(&buf)) {
onArm64 = !strcmp(buf.machine, "aarch64");
}
#endif
return onArm64;
}
#endif

// Platform-specific code to load a module
static std::pair<Sys::OSHandle, IPC::Socket> InternalLoadModule(std::pair<IPC::Socket, IPC::Socket> pair, const char* const* args, bool reserve_mem, FS::File stderrRedirect = FS::File(), bool inheritEnvironment = false)
{
Expand Down Expand Up @@ -283,13 +299,22 @@ static std::pair<Sys::OSHandle, IPC::Socket> InternalLoadModule(std::pair<IPC::S
Sys::Error("VM: failed to construct posix_spawn_file_actions_t");
}

pid_t pid;
char* emptyEnv[2] = {};
#if defined(__linux__) && (defined(YOKAI_ARCH_ARM64) || defined(YOKAI_ARCH_ARMHF))
if (OnArm64()) {
emptyEnv[0] = const_cast<char*>("LD_LIBRARY_PATH=lib-armhf");
if (0 != posix_spawn_file_actions_addchdir_np(&fileActions, FS::GetLibPath().c_str())) {
Sys::Error("failed posix_spawn_file_actions_addchdir");
}
}
#endif

// By default, the child process gets an empty environment for sandboxing.
// When Box64 emulation is used, the child needs to inherit the parent's
// environment so Box64 can find its configuration (e.g. ~/.box64rc, HOME)
// and honor settings like BOX64_DYNAREC_PERFMAP.
char* emptyEnv[] = {nullptr};
char** envp = inheritEnvironment ? environ : emptyEnv;
pid_t pid;
int err = posix_spawn(&pid, args[0], &fileActions, nullptr, const_cast<char* const*>(args), envp);
posix_spawn_file_actions_destroy(&fileActions);
if (err != 0) {
Expand Down Expand Up @@ -394,11 +419,7 @@ static std::pair<Sys::OSHandle, IPC::Socket> CreateNaClVM(std::pair<IPC::Socket,
}
#else
if (vm_nacl_bootstrap.Get()) {
#if defined(YOKAI_ARCH_ARM64)
bootstrap = FS::Path::Build(naclPath, "nacl_helper_bootstrap-armhf");
#else
bootstrap = FS::Path::Build(naclPath, "nacl_helper_bootstrap");
#endif

if (!FS::RawPath::FileExists(bootstrap)) {
Sys::Error("NaCl bootstrap helper not found: %s", bootstrap);
Expand All @@ -423,17 +444,6 @@ static std::pair<Sys::OSHandle, IPC::Socket> CreateNaClVM(std::pair<IPC::Socket,
if (enableQualification) {
#if defined(__linux__) && (defined(YOKAI_ARCH_ARM64) || defined(YOKAI_ARCH_ARMHF))
if (workaround_naclArchitecture_arm64_disableQualification.Get()) {
#if defined(YOKAI_ARCH_ARM64)
bool onArm64 = true;
#elif defined(YOKAI_ARCH_ARMHF)
bool onArm64 = false;

struct utsname buf;
if (!uname(&buf)) {
onArm64 = !strcmp(buf.machine, "aarch64");
}
#endif

/* This is required to run armhf NaCl loader on arm64 kernel
otherwise nexe loading fails with this message:

Expand All @@ -449,8 +459,8 @@ static std::pair<Sys::OSHandle, IPC::Socket> CreateNaClVM(std::pair<IPC::Socket,

But the nexe will load and run. */

if (onArm64) {
Log::Warn("Disabling NaCL platform qualification on arm64 kernel architecture.");
if (OnArm64()) {
Log::Warn("Disabling NaCl platform qualification on arm64 kernel architecture.");
enableQualification = false;
}
}
Expand Down
62 changes: 0 additions & 62 deletions tools/nacl_helper_bootstrap-armhf/nacl_helper_bootstrap-armhf.cpp

This file was deleted.

Loading