================
@@ -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
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to