Skip to content

Commit 8daf124

Browse files
committed
Small fix to the zeroing of the SME regs before attempting reads
When the process is not in Streaming SVE Mode, all of the SME thread_get_state calls will fail. Zero out the buffers that we were going to write data into, so we don't leave old data in them that might be sent to lldb (particularly in a GetRegisterContext "g" packet response, where we need to read all registers to complete the response).
1 parent 697340e commit 8daf124

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,9 @@ kern_return_t DNBArchMachARM64::GetSMEState(bool force) {
515515
// will fail, and we may return uninitialized data in the register context.
516516
memset(&m_state.context.sme.svcr, 0, ARM_SME_STATE_COUNT * sizeof(uint32_t));
517517
memset(m_state.context.sme.za.data(), 0, m_state.context.sme.za.size());
518+
if (CPUHasSME2())
519+
memset(&m_state.context.sme.zt0, 0,
520+
ARM_SME2_STATE_COUNT * sizeof(uint32_t));
518521

519522
// Read the registers from our thread
520523
mach_msg_type_number_t count = ARM_SME_STATE_COUNT;
@@ -526,7 +529,6 @@ kern_return_t DNBArchMachARM64::GetSMEState(bool force) {
526529
if (kret != KERN_SUCCESS)
527530
return kret;
528531

529-
memset(m_state.context.sme.za.data(), 0, m_state.context.sme.za.size());
530532

531533
size_t za_size = m_state.context.sme.svl_b * m_state.context.sme.svl_b;
532534
const size_t max_chunk_size = 4096;
@@ -553,8 +555,6 @@ kern_return_t DNBArchMachARM64::GetSMEState(bool force) {
553555
}
554556

555557
if (CPUHasSME2()) {
556-
memset(&m_state.context.sme.zt0, 0,
557-
ARM_SME2_STATE_COUNT * sizeof(uint32_t));
558558
count = ARM_SME2_STATE_COUNT;
559559
kret = thread_get_state(m_thread->MachPortNumber(), ARM_SME2_STATE,
560560
(thread_state_t)&m_state.context.sme.zt0, &count);

0 commit comments

Comments
 (0)