This is an archive of the discontinued LLVM Phabricator instance.

[lldb][AArch64] Add testing for SME's ZA and SVG registers
ClosedPublic

Authored by DavidSpickett on Sep 12 2023, 4:49 AM.

Details

Summary

An SME enabled program has the following extra state:

  • Streaming mode or non-streaming mode.
  • ZA enabled or disabled.
  • The active vector length.

Covering the transition between all possible states and all other
possible states is not viable, therefore the testing added here is a cross
section of that, all of which found real bugs in LLDB and the Linux
Kernel during development.

Many of those transitions will not be possible via LLDB
(e.g. disabling ZA) and many more are possible but unlikely to be
used in normal use.

Added testing:

  • TestSVEThreadedDynamic now checks for correct SVG values.
  • New test TestZAThreadedDynamic creates 3 threads with different ZA sizes and states and switches between them verifying the register value (derived from the existing threaded SVE test).
  • New test TestZARegisterSaveRestore starts in a given SME state, runs a set of expressions in various orders, then checks that the original state has been restored.
  • TestArm64DynamicRegsets has ZA and SVG checks added, including writing to ZA to enable it.

Running these tests will as usual require QEMU as there is no
real SME hardware available at this time, and a very recent
kernel.

Diff Detail

Event Timeline

DavidSpickett created this revision.Sep 12 2023, 4:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 12 2023, 4:49 AM
DavidSpickett requested review of this revision.Sep 12 2023, 4:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 12 2023, 4:50 AM

This patch requires rebasing does not apply cleanly on top of its parent.

Should all be updated now.

Rebase after changes to previous patch to arm64 regsets test.

Update tests now that ZA is part of SME register set.

Reformat changes with black.

I'll hold off landing any of the prior patches until this is reviewed, in case I have to go back and move things.

omjavaid added inline comments.Sep 19 2023, 12:49 AM
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
180

How can we differentiate between disabled ZA (read as all zeros) and enabled ZA actually set to all zeros?

lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py
104

is there a reference somewhere in clang or gcc documentation for USE_SSVE flag?

lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/Makefile
4

is USE_SSVE a subset of sve+sme?

DavidSpickett added inline comments.Sep 19 2023, 1:01 AM
lldb/test/API/commands/register/register/aarch64_dynamic_regset/TestArm64DynamicRegsets.py
180

In this specific test we write a non-zero value to avoid that issue, but I assume you mean generally.

The user should refer to the SVCR register, SVCR.ZA specifically, to know if the value they're seeing is the active ZA or not. You can see an example of that if you look at the changes to this file in https://reviews.llvm.org/D154927.

Again, the user has to know what bit to look for but I'll eventually address that with the register fields work.

lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/Makefile
4

It's a define I made up for the purposes of the test, it's in the existing tests but not well documented. I'll push something to address that in the existing tests and check the new ones here for this and other defines I've added.

We need sve to update sve registers and sme to be able to move into the za register (/the rows of the za register).

DavidSpickett marked 2 inline comments as done.Sep 19 2023, 1:59 AM
DavidSpickett added inline comments.
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/Makefile
4

https://github.com/llvm/llvm-project/commit/91f46ece9efca7a1109b5837a1b24f2a251bb0cc

USE_SSVE and friends are just defines -D... made up for specific tests.

omjavaid accepted this revision.Sep 19 2023, 3:03 AM

this looks good

lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/main.c
13

Is this a kernel requirement or just the way ptrace is implemented.?

This revision is now accepted and ready to land.Sep 19 2023, 3:03 AM
DavidSpickett added inline comments.Sep 19 2023, 3:15 AM
lldb/test/API/commands/register/register/aarch64_za_register/za_dynamic_resize/main.c
13

It's an architecture decision, I'll clarify the comment.

Clarify comment about SIGILL from inactive ZA.

Fix some leftover clang-format issues.

DavidSpickett marked an inline comment as done.Sep 19 2023, 3:18 AM

Fix some python formatting.