Skip to content

[lldb][AArch64][Linux] Add register field information for SME's SVCR register #71809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@

using namespace lldb_private;

LinuxArm64RegisterFlags::Fields
LinuxArm64RegisterFlags::DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2) {
(void)hwcap;
(void)hwcap2;
// Represents the pseudo register that lldb-server builds, which itself
// matches the architectural register SCVR. The fields match SVCR in the Arm
// manual.
return {
{"ZA", 1},
{"SM", 0},
};
}

LinuxArm64RegisterFlags::Fields
LinuxArm64RegisterFlags::DetectMTECtrlFields(uint64_t hwcap, uint64_t hwcap2) {
(void)hwcap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class LinuxArm64RegisterFlags {
static Fields DetectFPSRFields(uint64_t hwcap, uint64_t hwcap2);
static Fields DetectFPCRFields(uint64_t hwcap, uint64_t hwcap2);
static Fields DetectMTECtrlFields(uint64_t hwcap, uint64_t hwcap2);
static Fields DetectSVCRFields(uint64_t hwcap, uint64_t hwcap2);

struct RegisterEntry {
RegisterEntry(llvm::StringRef name, unsigned size, DetectorFn detector)
Expand All @@ -68,11 +69,12 @@ class LinuxArm64RegisterFlags {
llvm::StringRef m_name;
RegisterFlags m_flags;
DetectorFn m_detector;
} m_registers[4] = {
} m_registers[5] = {
RegisterEntry("cpsr", 4, DetectCPSRFields),
RegisterEntry("fpsr", 4, DetectFPSRFields),
RegisterEntry("fpcr", 4, DetectFPCRFields),
RegisterEntry("mte_ctrl", 8, DetectMTECtrlFields),
RegisterEntry("svcr", 8, DetectSVCRFields),
};

// Becomes true once field detection has been run for all registers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,12 @@ def za_expr_test_impl(self, sve_mode, za_state, swap_start_vl):
self.runCmd("register read " + sve_reg_names)
sve_values = self.res.GetOutput()

svcr_value = 1 if sve_mode == Mode.SSVE else 0
if za_state == ZA.Enabled:
svcr_value += 2
za = 1 if za_state == ZA.Enabled else 0
sm = 1 if sve_mode == Mode.SSVE else 0
svcr_value = "0x{:016x}".format((za << 1) | sm)
expected_svcr = [svcr_value]
if self.hasXMLSupport():
expected_svcr.append("(ZA = {}, SM = {})".format(za, sm))

has_zt0 = self.isAArch64SME2()

Expand All @@ -201,7 +204,8 @@ def check_regs():
self.assertEqual(start_vg, self.read_vg())

self.expect("register read " + sve_reg_names, substrs=[sve_values])
self.expect("register read svcr", substrs=["0x{:016x}".format(svcr_value)])

self.expect("register read svcr", substrs=expected_svcr)

for expr in exprs:
expr_cmd = "expression {}()".format(expr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@

import lldb
import itertools
from enum import Enum
from enum import IntEnum
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *


class Mode(Enum):
class Mode(IntEnum):
SVE = 0
SSVE = 1


class ZA(Enum):
class ZA(IntEnum):
Disabled = 0
Enabled = 1

Expand Down Expand Up @@ -56,7 +56,12 @@ def check_corefile(self, corefile):
svcr = 1 if sve_mode == Mode.SSVE else 0
if za == ZA.Enabled:
svcr |= 2
self.expect("register read svcr", substrs=["0x{:016x}".format(svcr)])

expected_svcr = ["0x{:016x}".format(svcr)]
if self.hasXMLSupport():
expected_svcr.append("(ZA = {:d}, SM = {})".format(za, sve_mode))

self.expect("register read svcr", substrs=expected_svcr)

repeat_bytes = lambda v, n: " ".join(["0x{:02x}".format(v)] * n)

Expand Down