Author: Jason Molenda Date: 2025-04-03T15:48:54-07:00 New Revision: f1c6612202d88cbde224387621327a31609f2177
URL: https://github.com/llvm/llvm-project/commit/f1c6612202d88cbde224387621327a31609f2177 DIFF: https://github.com/llvm/llvm-project/commit/f1c6612202d88cbde224387621327a31609f2177.diff LOG: [lldb][debugserver] Save and restore the SVE/SME register state (#134184) debugserver isn't saving and restoring the SVE/SME register state around inferior function calls. Making arbitrary function calls while in Streaming SVE mode is generally a poor idea because a NEON instruction can be hit and crash the expression execution, which is how I missed this, but they should be handled correctly if the user knows it is safe to do. Re-landing this change after fixing an incorrect behavior on systems without SME support. rdar://146886210 Added: Modified: lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp Removed: ################################################################################ diff --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp index 34a4ee21f8502..6ee1466612ee1 100644 --- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp +++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp @@ -2952,8 +2952,15 @@ kern_return_t DNBArchMachARM64::SetRegisterState(int set) { return err; switch (set) { - case e_regSetALL: - return SetGPRState() | SetVFPState() | SetEXCState() | SetDBGState(false); + case e_regSetALL: { + kern_return_t ret = + SetGPRState() | SetVFPState() | SetEXCState() | SetDBGState(false); + if (CPUHasSME()) { + SetSVEState(); + SetSMEState(); + } + return ret; + } case e_regSetGPR: return SetGPRState(); case e_regSetVFP: @@ -3123,6 +3130,12 @@ uint32_t DNBArchMachARM64::SaveRegisterState() { "error: %s regs failed to read: %u", "VFP", kret); } else { + if (CPUHasSME()) { + // These can fail when processor is not in streaming SVE mode, + // and that failure should be ignored. + GetSVEState(force); + GetSMEState(force); + } const uint32_t save_id = GetNextRegisterStateSaveID(); m_saved_register_states[save_id] = m_state.context; return save_id; @@ -3150,6 +3163,12 @@ bool DNBArchMachARM64::RestoreRegisterState(uint32_t save_id) { save_id, "VFP", kret); success = false; } + if (CPUHasSME()) { + // These can fail when processor is not in streaming SVE mode, + // and that failure should be ignored. + SetSVEState(); + SetSMEState(); + } m_saved_register_states.erase(pos); return success; } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits