]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - arch/arm64/kernel/ptrace.c
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[thirdparty/linux.git] / arch / arm64 / kernel / ptrace.c
index 09bb7fc7d3c2513b3bc8cb2e5545f8c31935e30a..dc6cf0e37194e428519d7d58524ad0f624f4bebb 100644 (file)
@@ -1108,12 +1108,13 @@ static int za_set(struct task_struct *target,
                }
        }
 
-       /* Allocate/reinit ZA storage */
-       sme_alloc(target, true);
-       if (!target->thread.sme_state) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       /*
+        * Only flush the storage if PSTATE.ZA was not already set,
+        * otherwise preserve any existing data.
+        */
+       sme_alloc(target, !thread_za_enabled(&target->thread));
+       if (!target->thread.sme_state)
+               return -ENOMEM;
 
        /* If there is no data then disable ZA */
        if (!count) {