llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Jason Molenda (jasonmolenda)

<details>
<summary>Changes</summary>

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.

rdar://146886210

---
Full diff: https://github.com/llvm/llvm-project/pull/134184.diff


1 Files Affected:

- (modified) lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
(+29-1) 


``````````diff
diff --git a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp 
b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
index 34a4ee21f8502..fb23744393d43 100644
--- a/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp
@@ -2953,7 +2953,14 @@ kern_return_t DNBArchMachARM64::SetRegisterState(int 
set) {
 
   switch (set) {
   case e_regSetALL:
-    return SetGPRState() | SetVFPState() | SetEXCState() | SetDBGState(false);
+  {
+    kern_return_t ret = SetGPRState() | SetVFPState() | SetEXCState() | 
SetDBGState(false);
+    if (CPUHasSME()) {
+      ret |= SetSVEState();
+      ret |= SetSMEState();
+    }
+    return ret;
+  }
   case e_regSetGPR:
     return SetGPRState();
   case e_regSetVFP:
@@ -3122,6 +3129,15 @@ uint32_t DNBArchMachARM64::SaveRegisterState() {
     DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
                                  "error: %s regs failed to read: %u",
                      "VFP", kret);
+  } else if (CPUHasSME() && (kret = SetSVEState() != KERN_SUCCESS)) {
+    DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
+                                 "error: %s regs failed to read: %u",
+                     "SVE", kret);
+  }
+  else if (CPUHasSME() && (kret = SetSMEState() != KERN_SUCCESS)) {
+    DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::SaveRegisterState () "
+                                 "error: %s regs failed to read: %u",
+                     "SME", kret);
   } else {
     const uint32_t save_id = GetNextRegisterStateSaveID();
     m_saved_register_states[save_id] = m_state.context;
@@ -3149,6 +3165,18 @@ bool DNBArchMachARM64::RestoreRegisterState(uint32_t 
save_id) {
                                    "write: %u",
                        save_id, "VFP", kret);
       success = false;
+    } else if ((kret = SetSVEState()) != KERN_SUCCESS) {
+      DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::RestoreRegisterState "
+                                   "(save_id = %u) error: %s regs failed to "
+                                   "write: %u",
+                       save_id, "SVE", kret);
+      success = false;
+    } else if ((kret = SetSMEState()) != KERN_SUCCESS) {
+      DNBLogThreadedIf(LOG_THREAD, "DNBArchMachARM64::RestoreRegisterState "
+                                   "(save_id = %u) error: %s regs failed to "
+                                   "write: %u",
+                       save_id, "SME", kret);
+      success = false;
     }
     m_saved_register_states.erase(pos);
     return success;

``````````

</details>


https://github.com/llvm/llvm-project/pull/134184
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to