From: Maxwell Pirtle Date: Wed, 1 Feb 2023 13:52:53 +0000 (+0100) Subject: Add patch for arm64 Ubuntu 22.04 in UnwindContext X-Git-Tag: v3.34~559^2 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5989a6d624a0a270ec5be99747eb431f701912a4 Add patch for arm64 Ubuntu 22.04 in UnwindContext The `mcontext_t` struct on Ubuntu 22.04 running on arm64 is missing the `fregs` field. This causes a compilation failure in `src/mc/inspect/mc_unw.cpp` since the code there assumes the field exists on linux-arm64. This commit adds a new CMake variable SIMGRID_PROCESSOR_arm64 to account for the additional architecture more explicitly and to better fit the context surrounding the code where the fix was made --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 84fe7f3210..366f0e38f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,19 +184,28 @@ IF(CMAKE_SYSTEM_PROCESSOR MATCHES ".86|AMD64|amd64") message(STATUS "System processor: i686 (${CMAKE_SYSTEM_PROCESSOR}, 32 bits)") set(SIMGRID_PROCESSOR_i686 1) set(SIMGRID_PROCESSOR_x86_64 0) + set(SIMGRID_PROCESSOR_arm64 0) ELSE() message(STATUS "System processor: x86_64 (${CMAKE_SYSTEM_PROCESSOR}, 64 bits)") set(SIMGRID_PROCESSOR_i686 0) set(SIMGRID_PROCESSOR_x86_64 1) + set(SIMGRID_PROCESSOR_arm64 0) ENDIF() if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") message(STATUS "Disable fast raw contexts on x32 ABI.") else() set(HAVE_RAW_CONTEXTS 1) endif() +ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + message(STATUS "System processor: arm64 (${CMAKE_SYSTEM_PROCESSOR}, 64 bits)") + set(SIMGRID_PROCESSOR_i686 0) + set(SIMGRID_PROCESSOR_x86_64 0) + set(SIMGRID_PROCESSOR_arm64 1) ELSE() + message(STATUS "System processor (${CMAKE_SYSTEM_PROCESSOR}) not explicitly accounted for") set(SIMGRID_PROCESSOR_i686 0) set(SIMGRID_PROCESSOR_x86_64 0) + set(SIMGRID_PROCESSOR_arm64 0) ENDIF() include(CheckFunctionExists) diff --git a/src/internal_config.h.in b/src/internal_config.h.in index a6dcbd59c4..e13c6ffa7d 100644 --- a/src/internal_config.h.in +++ b/src/internal_config.h.in @@ -48,6 +48,7 @@ /* Variables for the raw contexts (to select the right assembly code) */ #cmakedefine01 SIMGRID_PROCESSOR_i686 #cmakedefine01 SIMGRID_PROCESSOR_x86_64 +#cmakedefine01 SIMGRID_PROCESSOR_arm64 /* Variables for the SysV contexts */ @sg_makecontext_stack_addr@ diff --git a/src/mc/inspect/mc_unw.cpp b/src/mc/inspect/mc_unw.cpp index 2c66603693..746fb3155d 100644 --- a/src/mc/inspect/mc_unw.cpp +++ b/src/mc/inspect/mc_unw.cpp @@ -225,7 +225,7 @@ void UnwindContext::initialize(simgrid::mc::RemoteProcess* process, unw_context_ // Take a copy of the context for our own purpose: this->unwind_context_ = *c; -#if SIMGRID_PROCESSOR_x86_64 || SIMGRID_PROCESSOR_i686 || defined(__aarch64__) +#if SIMGRID_PROCESSOR_x86_64 || SIMGRID_PROCESSOR_i686 #ifdef __linux__ // On x86_64, ucontext_t contains a pointer to itself for FP registers. // We don't really need support for FR registers as they are caller saved @@ -234,6 +234,12 @@ void UnwindContext::initialize(simgrid::mc::RemoteProcess* process, unw_context_ // Let's ignore this and see what happens: this->unwind_context_.uc_mcontext.fpregs = nullptr; #endif +#elif SIMGRID_PROCESSOR_arm64 +#ifdef __linux__ + // On ARM64, ucontext_t doesn't contain `fpregs` and the FP registers + // are instead held in the `__reserved` field of the struct. It doesn't + // appear anything needs to be done here, although this should be verified +#endif #else // Do we need to do any fixup like this? #error Target CPU type is not handled.