[Lldb-commits] [lldb] [lldb][AArch64] Add SME2's ZT0 register (PR #70205)

David Spickett via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 26 01:18:44 PDT 2023


================
@@ -625,6 +662,18 @@ NativeRegisterContextLinux_arm64::CacheAllRegisters(uint32_t &cached_size) {
     error = ReadZA();
     if (error.Fail())
       return error;
+
+    // We will only be restoring ZT data if ZA is active. As writing to an
+    // inactive ZT enables ZA, which may not be desireable.
+    if (GetRegisterInfo().IsZTEnabled() &&
+        m_za_header.size > sizeof(m_za_header)) {
----------------
DavidSpickett wrote:

It's actually "if ZT0 is present and ZA is active", and ZA being active implies that zt0 is also active.

We have a bit of a word salad here as the existing checks are `IsFooEnabled()` because if for example, PAC is enabled it means we have the registers.

ZA threw a spanner in these works because `IsZAEnabled` can be true as in, it is present. Whether it's enabled, meaning it's "active" and SVCR.ZA is set, that's what we have to check the header for.

...which is to say I agree this is very confusing.

What the current code says is:
```
if (
  // Do we have ZT0 present, meaning, do we have SME2?
  GetRegisterInfo().IsZTEnabled() &&
  // Do we have a ZA header and is that header telling us that ZA is active?
  m_za_header.size > sizeof(m_za_header)) {
```

Because ironically, you can tell if zt0 would be active by checking if za is active, since they both use the svcr.za bit.

Let me see what I can do about this code right now, and I think I'll change all the `IsFooEnabled` to `IsFooPresent` in another PR for clarity sake.

https://github.com/llvm/llvm-project/pull/70205


More information about the lldb-commits mailing list