-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[lldb][debugserver] Save and restore the SVE/SME register state #134184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb][debugserver] Save and restore the SVE/SME register state #134184
Conversation
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
@llvm/pr-subscribers-lldb Author: Jason Molenda (jasonmolenda) Changesdebugserver 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:
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;
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
CI bots showed a fail in lldb-api.tools/lldb-server.TestGdbRemoteRegisterState.py , will debug and update. https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/23305/ |
) 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
…#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 (cherry picked from commit f1c6612)
…#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 (cherry picked from commit f1c6612)
…#134184) (#10418) 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 (cherry picked from commit f1c6612)
…#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 (cherry picked from commit f1c6612)
…store-sme-registers-around-function-calls-61 [lldb][debugserver] Save and restore the SVE/SME register state (llvm#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.
rdar://146886210